{"version":3,"sources":["jsdelivr-header.js","/npm/insta-save@1.0.0/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;ACLA,MAAM,MAAQ,QAAQ,cAChB,IAAM,QAAQ,OACd,IAAM,QAAQ,OACd,GAAK,QAAQ,MAEb,QAAU,IAAI,MAAM,CACxB,IAAK,CAAC,IAAK,4BAA6B,OACxC,OAAQ,CAAC,IAAK,kBAAmB,QACjC,IAAK,CAAC,IAAK,8CAA+C,YAGtD,SAAW,GAAO,6DAA6D,IAE/E,SAAY,GAAQ,MAAM,GAC7B,MAAK,GAAO,EAAI,SAChB,MAAK,IACJ,GAAoB,OAAhB,EAAI,QACN,MAAM,IAAI,MAAM,4CAElB,OAAO,EAAI,UAIf,SAAS,eAAc,IAAE,EAAG,OAAE,EAAM,IAAE,EAAM,SACtC,GAAO,IAAI,KAAK,OAAS,EAC3B,SAAS,SAAS,GAAO,IAAI,KAAK,KAC/B,MAAK,CAAC,EAAS,MACd,IAAI,IAAE,GAAQ,EAAO,MAAK,GAAS,EAAM,aAAe,KAAQ,EAAO,EAAO,OAAS,GAEvF,OADA,EAAS,GAAU,IAAI,MAAM,GAAK,SAAS,MAAM,KAAK,UAAU,GACzD,KAER,KAAK,OACL,MAAK,GAAO,EAAI,WAChB,MAAK,GAAU,GAAG,cAAc,EAAQ,KACxC,MAAM,QAAQ,OAEjB,IAAI,MAAM,mBAEd,CAEA,SAAS,eAAe,GAItB,OAHK,EAAQ,MACX,EAAQ,IAAM,QAET,CACT,CAEA,cAAc,eAAe","file":"/npm/insta-save@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/insta-save@1.0.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\nconst fetch = require('node-fetch')\nconst URL = require('url')\nconst cli = require('cli')\nconst fs = require('fs')\n\nconst options = cli.parse({\n  url: ['u', 'The url of image or video', 'url'],\n  output: ['o', 'The output file', 'file'],\n  res: ['r', 'The resolution of the image: 1080, 720 etc.', 'string']\n})\n\nconst fetchURL = url => `https://electron.forfuture.tech/insta/api/v1/download?url=${url}`\n\nconst download = (url) => fetch(url)\n  .then(res => res.json())\n  .then(res => {\n    if (res.message !== 'OK') {\n      throw new Error('Download failed. Check URL and try again')\n    }\n    return res.images\n  })\n\n\nfunction startDownload({ url, output, res = '720p' }) {\n  if (url || cli.args.length > 0) {\n    download(fetchURL(url || cli.args[0]))\n      .then((images = []) => {\n        let { url } = images.find(image => image.resolution === res) || images[images.length - 1]\n        output = output || URL.parse(url).pathname.split('/').reverse()[0]\n        return url\n      })\n      .then(fetch)\n      .then(res => res.buffer())\n      .then(buffer => fs.writeFileSync(output, buffer))\n      .catch(console.error)\n  } else {\n    cli.error('No URL supplied.')\n  }\n}\n\nfunction getDefaultOpts(options) {\n  if (!options.res) {\n    options.res = '720p'\n  }\n  return options\n}\n\nstartDownload(getDefaultOpts(options))"]}