{"version":3,"file":"FileDownloadButton_2.DU7OBQ2S.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/ZtEzCqo2xQjl2vsLsQOc/OTaOHAwFsIFfd44IKNfA/FileDownloadButton_2.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{useState,useEffect}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 120\n * @framerIntrinsicHeight 44\n */export default function FileDownloadButton(props){const[blobUrl,setBlobUrl]=useState(null);const initializeBlob=async()=>{if(!props.file)return;try{const response=await fetch(props.file);if(!response.ok){throw new Error(`HTTP error! status: ${response.status}`);}const blob=await response.blob();const blobUrl=URL.createObjectURL(blob);setBlobUrl(blobUrl);}catch(error){console.error(\"Error loading file:\",error);}};useEffect(()=>{// Clean up previous blob URL\nif(blobUrl){URL.revokeObjectURL(blobUrl);setBlobUrl(null);}initializeBlob();// Cleanup function\nreturn()=>{if(blobUrl){URL.revokeObjectURL(blobUrl);}};},[props.file])// Re-run when file changes\n;const handleDownload=e=>{// If blob URL isn't ready, try direct download\nif(!blobUrl&&props.file){e.preventDefault();// Create a temporary link for direct download\nconst link=document.createElement(\"a\");link.href=props.file;link.download=props.fileName||\"download\";document.body.appendChild(link);link.click();document.body.removeChild(link);}// If blobUrl exists, the normal href download will work\n};let button=/*#__PURE__*/_jsxs(\"a\",{href:blobUrl||props.file,download:props.fileName||\"download\",onClick:handleDownload,style:{backgroundColor:props.fill,display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",width:\"auto\",minWidth:\"fit-content\",textDecoration:\"none\",userSelect:\"none\",color:props.fontColor,cursor:props.pointerCursor?\"pointer\":\"auto\",padding:props.paddingIsMixed?`${props.paddingTopLeft}px ${props.paddingTopRight}px ${props.paddingBottomRight}px ${props.paddingBottomLeft}px`:`${props.padding}px`,borderRadius:props.radiusIsMixed?`${props.radiusTopLeft}px ${props.radiusTopRight}px ${props.radiusBottomRight}px ${props.radiusBottomLeft}px`:`${props.radius}px`,whiteSpace:\"nowrap\",...props.font,...props.style},children:[props.leadingIcon&&/*#__PURE__*/_jsx(\"img\",{src:props.leadingIcon,alt:\"Leading Icon\",style:{marginRight:props.title?`${props.iconSpacing}px`:\"0px\",width:`${props.iconSize}px`,height:`${props.iconSize}px`,flexShrink:0}}),props.icon&&!props.leadingIcon&&/*#__PURE__*/_jsx(\"img\",{src:props.icon,alt:\"Icon\",style:{marginRight:props.title?`${props.iconSpacing}px`:\"0px\",width:`${props.iconSize}px`,height:`${props.iconSize}px`,flexShrink:0}}),props.title&&/*#__PURE__*/_jsx(\"span\",{style:{flexShrink:0},children:props.title}),props.trailingIcon&&/*#__PURE__*/_jsx(\"img\",{src:props.trailingIcon,alt:\"Trailing Icon\",style:{marginLeft:props.title?`${props.iconSpacing}px`:\"0px\",width:`${props.iconSize}px`,height:`${props.iconSize}px`,flexShrink:0}})]});let buttonLayer=button;if(props.effects){buttonLayer=/*#__PURE__*/_jsx(motion.div,{whileHover:{scale:props.effects.hoverScale},whileTap:{scale:props.effects.pressScale},initial:false,transition:props.effects.transition,style:{display:\"inline-block\",...props.style},children:button});}return buttonLayer;}FileDownloadButton.displayName=\"File Download Button\";const effectsDefault={hoverScale:1,pressScale:.9};addPropertyControls(FileDownloadButton,{file:{type:ControlType.File,allowedFileTypes:[],description:\"Up to 50MB\"},fileName:{type:ControlType.String,placeholder:\"download\",defaultValue:\"download\",description:\"The filename for the downloaded file\"},title:{type:ControlType.String,defaultValue:\"Download\",description:\"Button text/label\"},leadingIcon:{type:ControlType.Image,optional:true,description:\"Icon displayed before the text\"},trailingIcon:{type:ControlType.Image,optional:true,description:\"Icon displayed after the text\"},icon:{type:ControlType.Image,optional:true,description:\"Legacy icon support (use leadingIcon instead)\",hidden:props=>!!(props.leadingIcon||props.trailingIcon)},iconSize:{type:ControlType.Number,defaultValue:16,min:0,description:\"Size for all icons\"},iconSpacing:{type:ControlType.Number,defaultValue:8,min:0,description:\"Space between icons and text\"},fill:{type:ControlType.Color,defaultValue:\"#EDEDED\",optional:true},fontColor:{type:ControlType.Color,defaultValue:\"#000\"},font:{type:\"font\",controls:\"extended\"},padding:{type:ControlType.Number,defaultValue:12,min:0,step:1,displayStepper:true},radius:{type:ControlType.FusedNumber,defaultValue:8,toggleKey:\"radiusIsMixed\",toggleTitles:[\"All\",\"Individual\"],valueKeys:[\"radiusTopLeft\",\"radiusTopRight\",\"radiusBottomRight\",\"radiusBottomLeft\"],valueLabels:[\"TL\",\"TR\",\"BR\",\"BL\"],min:0},pointerCursor:{type:ControlType.Boolean,defaultValue:true},effects:{type:ControlType.Object,defaultValue:effectsDefault,optional:true,buttonTitle:\"Hover & Press\",icon:\"effect\",controls:{hoverScale:{type:ControlType.Number,defaultValue:effectsDefault.hoverScale,min:0,step:.01,displayStepper:true},pressScale:{type:ControlType.Number,defaultValue:effectsDefault.pressScale,min:0,step:.01,displayStepper:true},transition:{type:ControlType.Transition}}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FileDownloadButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\",\"framerIntrinsicHeight\":\"44\",\"framerIntrinsicWidth\":\"120\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FileDownloadButton_2.map"],"mappings":"0OAKG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,EAAQ,GAAYA,EAAS,IAAI,EAAQ,EAAe,SAAS,CAAK,KAAM,KAAY,GAAG,CAAC,IAAM,EAAS,MAAM,MAAM,EAAM,IAAI,EAAE,GAAG,CAAC,EAAS,GAAI,MAAU,MAAM,uBAAuB,EAAS,QAAQ,EAAG,IAAM,EAAK,MAAM,EAAS,KAAK,EAAQ,EAAQ,IAAI,gBAAgB,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