{"version":3,"file":"Download.DNnCtxwC.mjs","names":["useState"],"sources":["https:/framer.com/m/framer/store.js@^1.0.0","https:/framer.com/m/Utils-QTIc.js","https:/framerusercontent.com/modules/OPY7tLO5Gxd7ex26JOYE/29HTjqEunUDHjIgwIVIM/Download.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{ControlType}from\"framer\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";export const updateChildren=(children,properties)=>{return[{...children,props:{...children.props,children:{...children.props.children,props:{...children.props.children.props,children:{...children.props.children.props.children,props:{...children.props.children.props.children.props,...properties}}}}}}];};export const SettingsMessage=({icon=\"✨\",title,description,containerStyle})=>{return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",textAlign:\"center\",justifyContent:\"center\",backgroundColor:\"rgba(136, 85, 255, 0.1)\",overflow:\"hidden\",...containerStyle},children:[/*#__PURE__*/_jsx(\"span\",{role:\"img\",\"aria-label\":\"icon\",style:{fontSize:\"32px\"},children:icon}),/*#__PURE__*/_jsxs(\"div\",{style:{maxWidth:\"240px\"},children:[/*#__PURE__*/_jsx(\"h1\",{style:{fontSize:11,color:\"#96F\",fontWeight:600},children:title}),/*#__PURE__*/_jsx(\"p\",{style:{fontSize:11,color:\"rgba(153, 102, 255, 0.7)\",lineHeight:1.5},children:description})]})]});};export const getBorder=border=>{if(!border)return{border:\"none\"};const{width,color,style}=border;return{borderWidth:width,borderColor:color,borderStyle:style};};export const borderProperty=(title=\"Border\",width=\"0px\",color=\"#fff\")=>({title,type:ControlType.Object,controls:{width:{title:\"Width\",type:ControlType.Padding,defaultValue:width},color:{title:\"Color\",type:ControlType.Color,defaultValue:color},style:{type:ControlType.Enum,defaultValue:\"solid\",options:[\"solid\",\"dashed\",\"dotted\",\"double\"],optionTitles:[\"Solid\",\"Dashed\",\"Dotted\",\"Double\"]}}});export const getBoxShadow=property=>{const{x,y,blur,color}=property.shadow;return`${x}px ${y}px ${blur}px ${color}`;};export const shadowProperty={type:ControlType.Object,controls:{color:{title:\"Color\",type:ControlType.Color,defaultValue:\"#bfbfbf\"},x:{title:\"X\",type:ControlType.Number,defaultValue:0,min:-100,max:100},y:{title:\"Y\",type:ControlType.Number,defaultValue:0,min:-100,max:100},blur:{title:\"Blur\",type:ControlType.Number,defaultValue:0,min:0,max:100}}};export const heightProperty={height:{type:ControlType.Enum,defaultValue:\"auto\",displaySegmentedControl:true,options:[\"auto\",\"fixed\"],optionTitles:[\"Auto\",\"Fixed\"]},heightNumber:{title:\" \",type:ControlType.Number,defaultValue:50,hidden(props){return props.height===\"auto\";}}};export const getHeight=property=>{if(property.height===\"auto\"){return property.height;}else{return`${property.heightNumber}px`;}};export const getPageQueryParam=()=>{const urlParams=new URLSearchParams(window.location.search);const pageParam=urlParams.get(\"page\");return pageParam?parseInt(pageParam,10):1;};export const updatePageQueryParam=newPage=>{const url=new URL(window.location.href);url.searchParams.set(\"page\",newPage);window.history.replaceState({},\"\",url.toString());};export const scrollToTop=(withScroll,scrollTop,scrollBehavior)=>{if(withScroll){window.scrollTo({top:scrollTop,behavior:scrollBehavior});}};//Pagination\nexport const usePaginationStore=createStore({});export const findQueryInProps=obj=>{if(obj==null)return null;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return obj.query;// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){let result=findQueryInProps(obj[key]);if(result!==null)return result;}}// If `query` is not found\nreturn null;};export const updateQueryInProps=(obj,newQuery)=>{if(obj==null)return obj;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return{...obj,query:newQuery};// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){const updatedChild=updateQueryInProps(obj[key],newQuery);if(updatedChild!==obj[key]){return{...obj,[key]:updatedChild};}}}return obj;};\nexport const __FramerMetadata__ = {\"exports\":{\"borderProperty\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getBoxShadow\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getHeight\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateChildren\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getPageQueryParam\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"usePaginationStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updatePageQueryParam\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getBorder\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrollToTop\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SettingsMessage\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateQueryInProps\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"heightProperty\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"shadowProperty\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"findQueryInProps\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Utils.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{SettingsMessage}from\"https://framer.com/m/Utils-QTIc.js\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 300\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicHeight 150\n */export default function Download({source,url,file,fileName,children,style}){const newChildren=Array.isArray(children)?children[0]:children;if(!newChildren||newChildren.length===0){return /*#__PURE__*/_jsx(SettingsMessage,{title:\"Set Up the Component\",description:\"Add layer or component to the button property.\",containerStyle:style});}const handleDownload=async()=>{const fileUrl=source===\"upload\"?file:url;try{const response=await fetch(fileUrl);const blob=await response.blob();const blobUrl=URL.createObjectURL(blob);// Get the extension from either the file or URL\nconst getExtension=path=>{const ext=path.split(\".\").pop();return ext&&ext.length<=4?`.${ext}`:\"\";};const extension=source===\"upload\"?getExtension(file):getExtension(url);// Add extension only if fileName doesn't already include it\nconst finalFileName=fileName.includes(\".\")?fileName:`${fileName||\"download\"}${extension}`;const link=document.createElement(\"a\");link.href=blobUrl;link.download=finalFileName;document.body.appendChild(link);link.click();document.body.removeChild(link);URL.revokeObjectURL(blobUrl);}catch(error){console.error(\"Download failed:\",error);}};return /*#__PURE__*/_jsx(\"div\",{onClick:handleDownload,style:style,children:newChildren});}Download.displayName=\"Download\";addPropertyControls(Download,{children:{title:\"Button\",type:ControlType.ComponentInstance},source:{title:\"Source\",type:ControlType.Enum,defaultValue:\"upload\",displaySegmentedControl:true,options:[\"upload\",\"url\"],optionTitles:[\"Upload\",\"URL\"]},url:{title:\" \",type:ControlType.String,placeholder:\"../example.pdf\",hidden(props){return props.source!==\"url\";}},file:{type:ControlType.File,title:\" \",allowedFileTypes:[\"txt\",\"pdf\",\"jpg\",\"jpeg\",\"png\"],hidden(props){return props.source!==\"upload\";}},fileName:{title:\"File Name\",type:ControlType.String,placeholder:\"File Name\",defaultValue:\"Download\",description:\"Full tutorial on [NewOffset](https://newoffset.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Download\",\"slots\":[\"children\"],\"annotations\":{\"framerIntrinsicHeight\":\"150\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"300\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Download.map"],"mappings":"2UAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,MAAM,EAAE,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAC,EAChI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,EAC7D,EAAa,IA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