{"version":3,"file":"DownloadUtility.bWr9jdlU.mjs","names":["url","_Fragment"],"sources":["https:/framerusercontent.com/modules/pzNdiywFBOlTkrfOOQqi/VSI0NOV7MiipJGkZfWMG/DownloadUtility.js"],"sourcesContent":["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function DownloadUtility({url,renamedFile}){const myCustomFunction=()=>{fetch(url).then(response=>response.blob()).then(blob=>{const url=window.URL.createObjectURL(blob);const link=document.createElement(\"a\");link.href=url;link.download=renamedFile||getFileNameFromUrl(url)||\"download\";document.body.appendChild(link);link.click();document.body.removeChild(link);window.URL.revokeObjectURL(url);}).catch(error=>{console.error(\"Error downloading the file:\",error);});};useEffect(()=>{const downloadLinks=document.querySelectorAll(`[href=\"${url}\"]`);downloadLinks.forEach(downloadLink=>downloadLink.addEventListener(\"click\",event=>{// Prevent the default link behavior\n    event.preventDefault();// Call your custom function\n    myCustomFunction();}));},[]);return /*#__PURE__*/_jsx(_Fragment,{});}addPropertyControls(DownloadUtility,{url:{title:\"File hosting URL\",type:ControlType.String},renamedFile:{title:\"File download name\",type:ControlType.String}});function getFileNameFromUrl(url){const decodedUrl=decodeURIComponent(url);const parts=decodedUrl.split(\"/\");return parts[parts.length-1];}/*import { useState } from \"react\"\nimport { motion } from \"framer-motion\"\nimport { addPropertyControls, ControlType } from \"framer\"\n\n// Learn more: https://www.framer.com/docs/guides/overrides/\n// By Vinaykumar C (www.linkedin.com/in/vinay-sc)\n\nexport default function Download(props) {\n    const { title, tint, style, file, downloadFileName } = props\n\n    const downloadFile = () => {\n        fetch(file)\n            .then((response) => response.blob())\n            .then((blob) => {\n                const url = window.URL.createObjectURL(blob)\n                const link = document.createElement(\"a\")\n                link.href = url\n                link.download =\n                    downloadFileName || getFileNameFromUrl(file) || \"download\"\n                document.body.appendChild(link)\n                link.click()\n                document.body.removeChild(link)\n                window.URL.revokeObjectURL(url)\n            })\n            .catch((error) => {\n                console.error(\"Error downloading the file:\", error)\n            })\n    }\n\n    return (\n        <motion.div style={{ ...style, ...containerStyle }}>\n            <motion.div\n                onTap={downloadFile}\n                style={{\n                    margin: 40,\n                    padding: 40,\n                    borderRadius: 20,\n                    backgroundColor: tint,\n                    color: \"white\",\n                    fontSize: \"2em\",\n                    fontWeight: \"bold\",\n                    width: \"100%\",\n                    height: \"100%\",\n                }}\n                whileHover={{ scale: 1.01 }}\n            >\n                {title}\n            </motion.div>\n        </motion.div>\n    )\n}\n\nDownload.defaultProps = {\n    tint: \"#09F\",\n    title: \"Download\",\n    downloadFileName: \"\",\n}\n\naddPropertyControls(Download, {\n    tint: {\n        title: \"Tint\",\n        type: ControlType.Color,\n    },\n    title: {\n        title: \"Label\",\n        type: ControlType.String,\n    },\n    file: {\n        title: \"File\",\n        type: ControlType.File,\n        allowedFileTypes: [],\n    },\n    downloadFileName: {\n        title: \"Download File Name\",\n        type: ControlType.String,\n        defaultValue: \"\",\n    },\n})\n\nconst containerStyle = {\n    display: \"flex\",\n    justifyContent: \"center\",\n    alignItems: \"center\",\n    overflow: \"hidden\",\n}\n\nfunction getFileNameFromUrl(url) {\n    const decodedUrl = decodeURIComponent(url)\n    const parts = decodedUrl.split(\"/\")\n    return parts[parts.length - 1]\n}*/\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DownloadUtility\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadUtility.map"],"mappings":"iTAAkJ,SAAwB,EAAgB,CAAC,MAAI,cAAY,CAAC,CAAC,IAAM,EAAiB,IAAI,CAAC,MAAM,EAAI,CAAC,KAAK,GAAU,EAAS,MAAM,CAAC,CAAC,KAAK,GAAM,CAAC,IAAMA,EAAI,EAAO,IAAI,gBAAgB,EAAK,CAAO,EAAK,SAAS,cAAc,IAAI,CAA2J,AAA1J,EAAK,KAAKA,EAAI,EAAK,SAAS,GAAa,EAAmBA,EAAI,EAAE,WAAW,SAAS,KAAK,YAAY,EAAK,CAAC,EAAK,OAAO,CAAC,SAAS,KAAK,YAAY,EAAK,CAAC,EAAO,IAAI,gBAAgBA,EAAI,AAAE,EAAC,CAAC,MAAM,GAAO,CAAC,QAAQ,MAAM,8BAA8B,EAAM,AAAE,EAAC,AAAE,EAEnlB,MAFolB,GAAU,IAAI,CAAC,IAAM,EAAc,SAAS,kBAAkB,SAAS,EAAI,IAAI,CAAC,EAAc,QAAQ,GAAc,EAAa,iBAAiB,QAAQ,GAAO,CAElxB,AADA,EAAM,gBAAgB,CACtB,GAAkB,AAAE,EAAC,CAAC,AAAE,EAAC,CAAE,EAAC,CAAqB,EAAKC,EAAU,CAAE,EAAC,AAAE,CAA+J,SAAS,EAAmB,EAAI,CAAC,IAAM,EAAW,mBAAmB,EAAI,CAAO,EAAM,EAAW,MAAM,IAAI,CAAC,OAAO,EAAM,EAAM,OAAO,EAAI,cAAzS,IAFzE,GAAiE,IAA6B,IAAoD,CAEzE,EAAoB,EAAgB,CAAC,IAAI,CAAC,MAAM,mBAAmB,KAAK,EAAY,MAAO,EAAC,YAAY,CAAC,MAAM,qBAAqB,KAAK,EAAY,MAAO,CAAC,EAAC"}