{"version":3,"file":"DownloadButton.DNBhfRXw.mjs","names":["useState","blobUrl"],"sources":["https:/framerusercontent.com/modules/sOY76eAe5VfA2LolONrF/AMAMvxAeSkFXzcuOauQQ/DownloadButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function DownloadButton(props){const{file,fileName,buttonText,backgroundColor,textColor,hoverColor,borderRadius,iconSize,buttonFont,showFileUrl,style}=props;const[isHovered,setIsHovered]=useState(false);const[blobUrl,setBlobUrl]=useState(null);const initializeBlob=async()=>{if(file){const response=await fetch(file);const blob=await response.blob();const blobUrl=URL.createObjectURL(blob);setBlobUrl(blobUrl);}};useEffect(()=>{initializeBlob();},[file]);// Get file extension from the original file URL\nconst getFileExtension=url=>{const match=url.match(/\\.([^.?]+)(\\?|$)/);return match?match[1]:\"\";};// Ensure filename has correct extension\nconst getDownloadFilename=()=>{if(!file||!fileName)return fileName;const fileExtension=getFileExtension(file);if(!fileExtension)return fileName;// Check if filename already has the correct extension\nif(fileName.toLowerCase().endsWith(`.${fileExtension.toLowerCase()}`)){return fileName;}// Add the extension\nreturn`${fileName}.${fileExtension}`;};const hasFile=file&&file.length>0;const downloadFilename=getDownloadFilename();return /*#__PURE__*/_jsx(\"a\",{href:blobUrl,download:downloadFilename,style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",textDecoration:\"none\",cursor:hasFile?\"pointer\":\"not-allowed\",pointerEvents:hasFile?\"auto\":\"none\",...style},tabIndex:hasFile?0:-1,\"aria-disabled\":!hasFile,onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),onClick:()=>{if(showFileUrl&&file){console.log(\"File URL:\",file);}},children:/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",background:hasFile?isHovered?hoverColor:backgroundColor:\"#CCCCCC\",color:hasFile?textColor:\"#666666\",border:\"none\",borderRadius:borderRadius,opacity:hasFile?1:.6,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",gap:8,...buttonFont,transition:\"background-color 0.2s ease\"},children:[/*#__PURE__*/_jsxs(\"svg\",{width:iconSize,height:iconSize,viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"7,10 12,15 17,10\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"12\",y1:\"15\",x2:\"12\",y2:\"3\"})]}),buttonText]})});}addPropertyControls(DownloadButton,{file:{type:ControlType.File,title:\"File to Download\",allowedFileTypes:[]},fileName:{type:ControlType.String,title:\"Download Filename\",defaultValue:\"my-file\",placeholder:\"Enter filename\"},buttonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Download File\"},backgroundColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#000000\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#333333\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:32,unit:\"px\"},iconSize:{type:ControlType.Number,title:\"Icon Size\",defaultValue:16,min:8,max:48,unit:\"px\"},buttonFont:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},showFileUrl:{type:ControlType.Boolean,title:\"Show File URL\",defaultValue:false,enabledTitle:\"Console Log\",disabledTitle:\"Normal\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DownloadButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadButton.map"],"mappings":"iRAGG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,aAAW,kBAAgB,YAAU,aAAW,eAAa,WAAS,aAAW,cAAY,SAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,KAAK,CAAO,EAAe,SAAS,CAAC,GAAG,EAAK,CAAkC,IAAM,EAAK,MAA7B,MAAM,MAAM,EAAK,EAA2B,MAAM,CAAOC,EAAQ,IAAI,gBAAgB,EAAK,CAAC,EAAWA,EAAQ,GAAI,MAAc,CAAC,GAAgB,EAAG,CAAC,EAAK,CAAC,CACxd,IAAM,EAAiB,GAAK,CAAC,IAAM,EAAM,EAAI,MAAM,mBAAmB,CAAC,OAAO,EAAM,EAAM,GAAG,IACvF,MAAwB,CAAC,GAAG,CAAC,GAAM,CAAC,EAAS,OAAO,EAAS,IAAM,EAAc,EAAiB,EAAK,CAE7G,MAFiH,CAAC,GAC/G,EAAS,aAAa,CAAC,SAAS,IAAI,EAAc,aAAa,GAAG,CAAS,EACxE,GAAG,EAAS,GAAG,KAAwB,EAAQ,GAAM,EAAK,OAAO,EAAQ,EAAiB,GAAqB,CAAC,OAAoB,EAAK,IAAI,CAAC,KAAK,EAAQ,SAAS,EAAiB,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,QAAQ,OAAO,WAAW,SAAS,eAAe,SAAS,eAAe,OAAO,OAAO,EAAQ,UAAU,cAAc,cAAc,EAAQ,OAAO,OAAO,GAAG,EAAM,CAAC,SAAS,EAAQ,EAAE,GAAG,gBAAgB,CAAC,EAAQ,iBAAiB,EAAa,GAAK,CAAC,iBAAiB,EAAa,GAAM,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