{"version":3,"file":"PDF_Button.DllP_y-F.mjs","names":["useState","useCallback","_jsx","__esmMin","init_npm_react_18_3_1","window","init_ssg_sandbox_shims","init_jsx_runtime","ne","c","_e","addPropertyControls","init_framer_BWzg2IRg","ControlType","PdfButton","label","pdfFile","action","viewer","fileName","padding","borderRadius","textColor","backgroundColor","style","font","hover","url","downloadName","resolvedDownloadName","viewerUrl","isHover","setIsHover","handleClick","res","blob","blobUrl","a","init_PDF_Button","props"],"sources":["https:/framerusercontent.com/modules/DEGWZ5F5zwi3gBZKpQeD/DtSXjpqzhyBUmQ3sWLVr/PDF_Button.js"],"sourcesContent":["// PdfButton — Open New (Google/Mozilla/Browser) or Download\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useCallback,useState}from\"react\";/**\n * @framerIntrinsicWidth 160\n * @framerIntrinsicHeight 48\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerDisableUnlink\n */export default function PdfButton({label=\"Open PDF\",pdfFile,action=\"openNew\",viewer=\"google\",fileName=\"document.pdf\",padding=\"12px 28px\",borderRadius=\"8px\",textColor=\"#FFFFFF\",backgroundColor=\"#111111\",style,font,hover={scale:1.05,opacity:1,transition:.25}}){const url=(pdfFile||\"\").trim();const downloadName=(fileName||\"\").trim();const resolvedDownloadName=downloadName?/\\.pdf$/i.test(downloadName)?downloadName:`${downloadName}.pdf`:\"\";// Build viewer URL for opening in a new tab\nconst viewerUrl=url?viewer===\"google\"?`https://docs.google.com/gview?embedded=1&url=${encodeURIComponent(url)}`:viewer===\"mozilla\"?`https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(url)}`:url// browser native (raw PDF)\n:\"\";const[isHover,setIsHover]=useState(false);const handleClick=useCallback(async()=>{if(!url)return;if(action===\"openNew\"){if(viewer===\"browser\"){try{const res=await fetch(url,{mode:\"cors\"});if(!res.ok)throw new Error(\"Fetch failed\");const blob=await res.blob();const blobUrl=URL.createObjectURL(blob);window.open(blobUrl,\"_blank\",\"noopener,noreferrer\");setTimeout(()=>URL.revokeObjectURL(blobUrl),1e4);return;}catch{// Fall back to direct open if CORS blocks or fetch fails\n}}window.open(viewerUrl,\"_blank\",\"noopener,noreferrer\");return;}// action === \"download\"\ntry{const res=await fetch(url,{mode:\"cors\"});if(!res.ok)throw new Error(\"Fetch failed\");const blob=await res.blob();const blobUrl=URL.createObjectURL(blob);const a=document.createElement(\"a\");a.href=blobUrl;a.download=resolvedDownloadName;document.body.appendChild(a);a.click();document.body.removeChild(a);setTimeout(()=>URL.revokeObjectURL(blobUrl),1e4);return;}catch{// Fall back to direct download if CORS blocks or fetch fails\n}const a=document.createElement(\"a\");a.href=url;a.download=resolvedDownloadName;document.body.appendChild(a);a.click();document.body.removeChild(a);},[action,resolvedDownloadName,url,viewerUrl]);return /*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":label,onClick:handleClick,onMouseEnter:()=>setIsHover(true),onMouseLeave:()=>setIsHover(false),style:{...style,width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:backgroundColor,color:textColor,border:\"none\",borderRadius,padding,cursor:\"pointer\",...font,transform:isHover?`scale(${hover?.scale??1.05})`:\"scale(1)\",opacity:isHover?hover?.opacity??1:1,transition:`transform ${hover?.transition??.25}s ease, opacity ${hover?.transition??.25}s ease`,willChange:\"transform, opacity\"},children:label});}addPropertyControls(PdfButton,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Open PDF\"},pdfFile:{type:ControlType.File,allowedFileTypes:[\"pdf\"],title:\"PDF\"},viewer:{type:ControlType.Enum,title:\"Viewer\",options:[\"google\",\"mozilla\",\"browser\"],optionTitles:[\"Google Docs\",\"Mozilla pdf.js\",\"Browser Native\"],defaultValue:\"google\",hidden:props=>props.action!==\"openNew\"},action:{type:ControlType.Enum,title:\"Action\",options:[\"openNew\",\"download\"],optionTitles:[\"New Tab\",\"Download\"],defaultValue:\"openNew\",displaySegmentedControl:true},fileName:{type:ControlType.String,title:\"File Name\",defaultValue:\"document.pdf\",hidden:props=>props.action!==\"download\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"12px 28px\"},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"8px\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#FFFFFF\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#111111\"},hover:{type:ControlType.Object,title:\"Hover\",controls:{scale:{type:ControlType.Number,title:\"Scale\",defaultValue:1.05,min:.8,max:1.5,step:.01},opacity:{type:ControlType.Number,title:\"Opacity\",defaultValue:1,min:.1,max:1,step:.05},transition:{type:ControlType.Number,title:\"Transition (s)\",defaultValue:.25,min:0,max:2,step:.05}}},// Group: Font\nfont:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"16px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},group:\"Font\",description:`Made with ❤️ by [camillehaidar.com](https://camillehaidar.com)`}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PdfButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\",\"framerIntrinsicWidth\":\"160\",\"framerIntrinsicHeight\":\"48\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PDF_Button.map"],"mappings":"A,+LAOG,SAAwBc,EAAU,CAACC,QAAM,WAAWC,UAAQC,SAAO,UAAUC,SAAO,SAASC,WAAS,eAAeC,UAAQ,YAAYC,eAAa,MAAMC,YAAU,UAAUC,kBAAgB,UAAUC,QAAMC,OAAKC,QAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,WAAW,GAAG,GAAG,CAAC,IAAMC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