{"version":3,"file":"DownloadButton.D87fOnrP.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/jLBpDh9xzp4GIBukqtiK/hzFmpKb6kQ0hLm3QGfP6/DownloadButton.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";function OptimizationFriendly({loading,loaded}){const[isLoading,setLoading]=useState(true);useEffect(()=>setLoading(false),[]);return isLoading?loading:loaded;}const downloadFile=(file,downloadFileName)=>{fetch(file).then(response=>response.blob()).then(blob=>{const url=window.URL.createObjectURL(blob);const link=document.createElement(\"a\");link.href=url;link.download=downloadFileName||getFileNameFromUrl(file)||\"download\";document.body.appendChild(link);link.click();document.body.removeChild(link);window.URL.revokeObjectURL(url);}).catch(error=>{console.error(\"Error downloading the file:\",error);});};export default function Download(props){const{title,tint,fontColor,fontSize,style,file,downloadFileName}=props;return /*#__PURE__*/_jsx(motion.div,{style:{...style,...containerStyle},children:/*#__PURE__*/_jsx(OptimizationFriendly,{loading:/*#__PURE__*/_jsx(motion.div,{onTap:()=>{},style:{margin:0,padding:\"10px 12px\",borderRadius:8,backgroundColor:tint,color:fontColor,fontSize:fontSize,fontWeight:\"bold\",width:\"100%\",height:\"100%\"},whileHover:{scale:1.01},children:\"Laden\"}),loaded:/*#__PURE__*/_jsx(motion.div,{onTap:()=>downloadFile(file,downloadFileName),style:{margin:0,padding:\"10px 12px\",borderRadius:8,backgroundColor:tint,color:fontColor,fontSize:fontSize,fontWeight:\"bold\",width:\"100%\",height:\"100%\"},whileHover:{scale:1.01},children:title})})});}Download.defaultProps={tint:\"#09F\",title:\"Download\",downloadFileName:\"\",fontColor:\"#FFF\",fontSize:14};addPropertyControls(Download,{tint:{title:\"Tint\",type:ControlType.Color},title:{title:\"Label\",type:ControlType.String},file:{title:\"File\",type:ControlType.File,allowedFileTypes:[]},downloadFileName:{title:\"Download File Name\",type:ControlType.String,defaultValue:\"\"},fontColor:{title:\"Textcolor\",type:ControlType.Color},fontSize:{title:\"Textsize\",type:ControlType.Number}});const containerStyle={display:\"flex\",justifyContent:\"center\",alignItems:\"center\",overflow:\"hidden\"};function getFileNameFromUrl(url){const decodedUrl=decodeURIComponent(url);const parts=decodedUrl.split(\"/\");return parts[parts.length-1];}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Download\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadButton.map"],"mappings":"kYAAuK,SAAS,EAAqB,CAAC,UAAQ,SAAO,CAAC,CAAC,GAAK,CAAC,EAAU,EAAW,CAACA,EAAS,IAA0C,OAApC,MAAc,EAAW,IAAO,EAAE,EAAS,EAAU,EAAQ,CAAQ,CAAgc,SAAwB,EAAS,EAAM,CAAC,GAAK,CAAC,QAAM,OAAK,YAAU,WAAS,QAAM,OAAK,mBAAiB,CAAC,EAAM,OAAoB,EAAK,EAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAM,GAAG,EAAe,CAAC,SAAsB,EAAK,EAAqB,CAAC,QAAqB,EAAK,EAAO,IAAI,CAAC,UAAU,CAAE,EAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,YAAY,aAAa,EAAE,gBAAgB,EAAK,MAAM,EAAmB,WAAS,WAAW,OAAO,MAAM,OAAO,OAAO,OAAO,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,SAAS,QAAQ,EAAE,OAAoB,EAAK,EAAO,IAAI,CAAC,UAAU,EAAa,EAAK,GAAkB,MAAM,CAAC,OAAO,EAAE,QAAQ,YAAY,aAAa,EAAE,gBAAgB,EAAK,MAAM,EAAmB,WAAS,WAAW,OAAO,MAAM,OAAO,OAAO,OAAO,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,SAAS,EAAM,EAAE,EAAE,CAAG,CAAgkB,SAAS,EAAmB,EAAI,CAAC,IAA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