{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/cewQ79vLWdlkUuAJN2l8/Orr9PxnzxVs59ZoYBxAU/DownloadButton.js"],
  "sourcesContent": ["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { motion } from \"framer-motion\";\nimport { addPropertyControls, ControlType } from \"framer\"; /**\n                                                           * @framerSupportedLayoutWidth relative\n                                                           * @framerSupportedLayoutHeight relative\n                                                           */\nexport default function Download(props) {\n  const {\n    title,\n    tint,\n    style,\n    file,\n    downloadFileName\n  } = props;\n  const downloadFile = async () => {\n    // Fetch session token\n    const token = localStorage.getItem(\"lottielab_session_token\"); // Check if logged in\n    if (!token) {\n      window.location.href = \"/sign-up\";\n      return;\n    }\n    const framerContentResponse = await fetch(file);\n    const documentFormat = await framerContentResponse.json();\n    const body = new FormData();\n    body.append(\"file_names[]\", downloadFileName);\n    body.append(\"schema_versions[]\", documentFormat.version);\n    body.append(\"document_files[]\", JSON.stringify(documentFormat));\n    body.append(\"lottie_files[]\", JSON.stringify({}));\n    body.append(\"in_drafts\", \"true\");\n    const response = await fetch(`https://api.lottielab.com/api/v1/lottie_files/upload`, {\n      method: \"POST\",\n      headers: {\n        Authorization: token\n      },\n      body\n    });\n    const uploadedFiles = (await response.json()).files;\n    const fileId = uploadedFiles[0].id;\n    window.location.href = `/editor?file=${fileId}`;\n  };\n  return /*#__PURE__*/_jsx(motion.div, {\n    style: {\n      ...style,\n      ...containerStyle\n    },\n    children: /*#__PURE__*/_jsx(motion.div, {\n      onTap: downloadFile,\n      style: {\n        width: \"100%\",\n        height: \"100%\",\n        backgroundColor: tint,\n        color: \"white\",\n        fontSize: \"2em\",\n        fontWeight: \"bold\"\n      },\n      whileHover: {\n        scale: 1.01\n      },\n      children: title\n    })\n  });\n}\n;\nDownload.defaultProps = {\n  tint: \"#09F\",\n  title: \"Download\",\n  downloadFileName: \"\"\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});\nconst containerStyle = {\n  width: \"100%\"\n};\nfunction getFileName(url) {\n  const decodedUrl = decodeURIComponent(url);\n  const parts = decodedUrl.split(\"/\");\n  return parts[parts.length - 1];\n}\nexport const __FramerMetadata__ = {\n  \"exports\": {\n    \"default\": {\n      \"type\": \"reactComponent\",\n      \"name\": \"Download\",\n      \"slots\": [],\n      \"annotations\": {\n        \"framerContractVersion\": \"1\",\n        \"framerSupportedLayoutHeight\": \"relative\",\n        \"framerSupportedLayoutWidth\": \"relative\"\n      }\n    },\n    \"__FramerMetadata__\": {\n      \"type\": \"variable\"\n    }\n  }\n};\n//# sourceMappingURL=./DownloadButton.map"],
  "mappings": "yIAMe,SAARA,EAA0BC,EAAO,CACtC,GAAM,CACJ,MAAAC,EACA,KAAAC,EACA,MAAAC,EACA,KAAAC,EACA,iBAAAC,CACF,EAAIL,EACEM,EAAe,SAAY,CAE/B,IAAMC,EAAQ,aAAa,QAAQ,yBAAyB,EAC5D,GAAI,CAACA,EAAO,CACVC,EAAO,SAAS,KAAO,WACvB,OAGF,IAAMC,EAAiB,MADO,MAAM,MAAML,CAAI,GACK,KAAK,EAClDM,EAAO,IAAI,SACjBA,EAAK,OAAO,eAAgBL,CAAgB,EAC5CK,EAAK,OAAO,oBAAqBD,EAAe,OAAO,EACvDC,EAAK,OAAO,mBAAoB,KAAK,UAAUD,CAAc,CAAC,EAC9DC,EAAK,OAAO,iBAAkB,KAAK,UAAU,CAAC,CAAC,CAAC,EAChDA,EAAK,OAAO,YAAa,MAAM,EAS/B,IAAMC,GADiB,MAPN,MAAM,MAAM,uDAAwD,CACnF,OAAQ,OACR,QAAS,CACP,cAAeJ,CACjB,EACA,KAAAG,CACF,CAAC,GACqC,KAAK,GAAG,MACjB,CAAC,EAAE,GAChCF,EAAO,SAAS,KAAO,gBAAgBG,GACzC,EACA,OAAoBC,EAAKC,EAAO,IAAK,CACnC,MAAO,CACL,GAAGV,EACH,GAAGW,CACL,EACA,SAAuBF,EAAKC,EAAO,IAAK,CACtC,MAAOP,EACP,MAAO,CACL,MAAO,OACP,OAAQ,OACR,gBAAiBJ,EACjB,MAAO,QACP,SAAU,MACV,WAAY,MACd,EACA,WAAY,CACV,MAAO,IACT,EACA,SAAUD,CACZ,CAAC,CACH,CAAC,CACH,CAEAF,EAAS,aAAe,CACtB,KAAM,OACN,MAAO,WACP,iBAAkB,EACpB,EACAgB,EAAoBhB,EAAU,CAC5B,KAAM,CACJ,MAAO,OACP,KAAMiB,EAAY,KACpB,EACA,MAAO,CACL,MAAO,QACP,KAAMA,EAAY,MACpB,EACA,KAAM,CACJ,MAAO,OACP,KAAMA,EAAY,KAClB,iBAAkB,CAAC,CACrB,EACA,iBAAkB,CAChB,MAAO,qBACP,KAAMA,EAAY,OAClB,aAAc,EAChB,CACF,CAAC,EACD,IAAMF,EAAiB,CACrB,MAAO,MACT",
  "names": ["Download", "props", "title", "tint", "style", "file", "downloadFileName", "downloadFile", "token", "window", "documentFormat", "body", "fileId", "p", "motion", "containerStyle", "addPropertyControls", "ControlType"]
}
