{"version":3,"file":"DownloadButton.BUspAiz2.mjs","names":["useState","__esmMin","init_npm_react_18_3_1","init_jsx_runtime","c","ce","_e","motion","init_framer_motion_DhsWWWsN","addPropertyControls","ControlType","init_framer_CmdSJ2Oe","FileDownloadButton","blobUrl","setBlobUrl","props","isPublishedSiteOrSSG","initializeBlob","fileUrl","srcType","SrcType","srcURL","srcFile","blob","error","getCursor","isInPublishedSiteOrSSG","downloadURL","buttonTitle","fileName","init_DownloadButton"],"sources":["https:/framerusercontent.com/modules/vHCRC9NWbaC75t7X0Gln/lnH8CnZxc7Qi9KhdVFe1/DownloadButton.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 36\n * @framerSupportedLayoutWidth fixed\n * @framerIntrinsicHeight 36\n * @framerSupportedLayoutHeight fixed\n */const SrcType={Upload:\"Upload\",URL:\"URL\"};FileDownloadButton.variables={cmsFile:{type:\"file\",title:\"CMS File Upload\"}};export default function FileDownloadButton(props){const[blobUrl,setBlobUrl]=useState(null);const{srcType,srcFile,srcURL,fileName}=props;const isPublishedSiteOrSSG=()=>{if(typeof document===\"undefined\")return true;const metaTag=document.querySelector('meta[name=\"framer-search-index\"]');return!!metaTag;};const initializeBlob=async()=>{const fileUrl=srcType===SrcType.URL?srcURL:srcFile;if(fileUrl){try{const response=await fetch(fileUrl);const blob=await response.blob();const blobUrl=URL.createObjectURL(blob);setBlobUrl(blobUrl);}catch(error){console.error(\"Error creating blob URL:\",error);}}};useEffect(()=>{initializeBlob();return()=>{if(blobUrl){URL.revokeObjectURL(blobUrl);}};},[srcType,srcFile,srcURL]);const getCursor=()=>{if(srcType===SrcType.URL&&srcURL)return\"pointer\";if(srcType===SrcType.Upload&&srcFile)return\"pointer\";return\"auto\";};const isInPublishedSiteOrSSG=isPublishedSiteOrSSG();const downloadURL=isInPublishedSiteOrSSG&&srcType===SrcType.URL?srcURL:srcType===SrcType.Upload?srcFile:null;const buttonTitle=isInPublishedSiteOrSSG?\"Download File\":\"Publish to Download\";return /*#__PURE__*/_jsx(motion.a,{target:\"_blank\",href:blobUrl||downloadURL,download:fileName||\"download\",title:buttonTitle,style:{backgroundColor:\"transparent\",display:\"block\",width:\"100%\",height:\"100%\",cursor:getCursor(),userSelect:\"none\"},children:props.children});}FileDownloadButton.displayName=\"File Download Button\";addPropertyControls(FileDownloadButton,{srcType:{type:ControlType.Enum,displaySegmentedControl:true,title:\"Source\",options:[SrcType.Upload,SrcType.URL]},srcURL:{type:ControlType.String,title:\" \",placeholder:\"../example.pdf\",hidden:props=>props.srcType===SrcType.Upload},srcFile:{type:ControlType.File,title:\" \",allowedFileTypes:[],hidden:props=>props.srcType===SrcType.URL},fileName:{type:ControlType.String,placeholder:\"File Name\",defaultValue:\"downloaded-file\",title:\"File Name\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FileDownloadButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadButton.map"],"mappings":"A,mOAM0H,SAAwBY,EAAmB,EAAM,CAAC,GAAK,CAACC,EAAQC,GAAYd,EAAS,IAAI,EAAO,CAAC,UAAQ,UAAQ,SAAO,YAAUe,EAAYC,MAA6B,OAAO,SAAW,KAAuG,CAAC,CAAlE,SAAS,cAAc,kCAAkD,EAAUC,EAAe,SAAS,CAAC,IAAMC,EAAQC,IAAUC,EAAQ,IAAIC,EAAOC,EAAQ,GAAGJ,EAAS,GAAG,CAAqC,IAAMK,EAAK,MAAM,MAAhC,MAAML,CAAO,EAAA,CAA4B,KAAK,EAAQL,EAAQ,IAAI,gBAAgBU,CAAI,EAAET,EAAWD,CAAO,CAAE,OAAOW,EAAM,CAAC,QAAQ,MAAM,2BAA2BA,CAAK,CAAE,CAAE,EAAEnB,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