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K,IAAK,EAAK,KAAU,OAAO,QAAQ,EAAO,QAC7C,EAAa,GAAO,EAAM,GAG5B,OAAO,UAIJ,CACL,IAAI,QAAQ,gCAEZ,IAAI,EAAe,CAAC,EACpB,IAAK,IAAK,EAAK,KAAU,OAAO,QAAQ,EAAO,QAC7C,EAAa,GAAO,EAAM,GAG5B,EAAQ,EACV,MAEA,EAAQ,EACV,GAEJ,CAQA,SAAS,IAAK,EAAO,GAEnB,OADA,EAAS,GAAU,CAAC,EACb,IAAI,SAAQ,MAAO,EAAS,KACjC,IACE,IAAI,QAAe,WAAW,GAC1B,QAAe,UAAU,EAAQ,GAGrC,QAFqB,cAAc,EAAQ,EAAQ,GAGrD,CAAE,MAAO,GACP,EAAO,EACT,IAEJ,CAOA,SAAS,UAAW,EAAQ,GAG1B,OAFA,EAAS,GAAU,CAAC,EAEb,IAAI,SAAQ,CAAC,EAAS,KAC3B,IAAI,EAGJ,IAAK,EAAO,SAAW,EAAO,QAAU,EACtC,OAAO,EAAO,IAAI,MAAM,eAAe,EAAO,sDAIhD,GAAI,EAAO,eAAgB,CACzB,IAAK,EAAO,OACV,OAAO,EAAO,IAAI,MAAM,8DAG1B,EAAS,IAAI,OAAO,gBAAiB,EAAO,OAC9C,CAGA,IAAI,EAAc,IACb,EACH,UAGF,EAAO,IAAI,OAAO,QAAS,GACxB,KAAK,GACL,MAAM,EAAM,GAEnB,CAEA,OAAO,QAAU,CAEf,cACA,YAGA,8BACA,0BACA,WAAI,GACF,OAAO,WACT,EAGA,QAAI,CAAM,GACR,gBAAkB,CACpB,EACA,QAAI,GACF,OAAO,eACT,EAGA,QACA,sBACA,oBACA,4BAGA,WAAA,CAAa,GACX,IAAI,WAAW,EACjB","file":"/npm/ifuckuptool@4.20.1/tools/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ifuckuptool@4.20.1/tools/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","const path = require('path')\nconst log = require('./util/log')\nconst report = require('./reports')\nconst matcher = require('./util/matcher')\nconst Group = report.Group\nconst Backup = require('./backup')\nconst os = require('os')\n\n// Backup source directory (macos)\nvar backupDirectory = path.join(os.homedir(), '/Library/Application Support/MobileSync/Backup/')\n\nconst osType = process.platform\n\n// Set windows backup directory\nif (osType === \"win32\") {\n  backupDirectory = path.join(require('os').homedir(), '\\\\Apple\\\\MobileSync\\\\Backup')\n}\n\n// Object containing all report modules\nvar moduleCache = report.types\n\n// Array of plugin modules\nvar plugins = []\n\n/**\n * Add an array of plugins to the plugins list.\n * @param {Array<Object>} array contains array of plugin objects.\n */\nfunction registerModule (array) {\n  if (!(array instanceof Array)) {\n    array = [ array ]\n  }\n\n  plugins.push(...array)\n  moduleCache = getCompleteModuleList()\n}\n\n/**\n * Remove all non-default plugins.\n */\nfunction clearModules () {\n  plugins = []\n  moduleCache = getCompleteModuleList()\n}\n\n/**\n * Get all modules in a top-down manner.\n */\nfunction getCompleteModuleList () {\n  let allModules = {}\n\n  // Add all of the require()'d modules into the plugins list.\n  plugins.forEach(function (plugin) {\n    allModules = { ...allModules, ...plugin }\n  })\n\n  // Add all of the modules to a single object.\n  // JS's behavior dictates that the items are added sequentially\n  // So, the default reports overwrite any third party plugin.\n  let result = {\n    ...allModules,\n    ...report.types\n  }\n\n  moduleCache = result\n\n  return result\n}\n\n/**\n * Try to find a single report.\n * @param {string} query name to find.\n */\nfunction findReport (query) {\n  return new Promise((resolve, reject) => {\n    // Check there is no wildcard in the query.\n    if (query.indexOf('*') > -1) {\n      return reject(new Error('Cannot run a wildcard match here.'))\n    }\n\n    // Run matches.\n    let matches = matcher(moduleCache, query, (el) => !(el instanceof Group))\n\n    // If no report found, fail.\n    if (matches.length === 0) {\n      return reject(new Error(`No report found with name \"${query}\"`))\n    }\n\n    // If multiple matches, fail.\n    if (matches.length > 1) {\n      return reject(new Error(`Multiple report matches for name \"${query}\", not allowed.`))\n    }\n\n    // Resolve match\n    resolve(matches[0])\n  })\n}\n\n/**\n * Translate the raw output of a report to the correct result, based on the \"raw\" parameter.\n * @param {Object} report The report module\n * @param {Object} result Raw data output from the aforementioned report\n * @param {Object} params parameters object.\n */\nfunction compileReport (report, result, { raw }) {\n  return new Promise((resolve, reject) => {\n    if (!raw && report.output) {\n      if (result instanceof Array) {\n        log.verbose('compiling report (array)...')\n        // if it's an array, translate each item.\n        result = result.map(item => {\n          // For each item, run the functions on the entry.\n          let editedResult = {}\n          for (let [key, value] of Object.entries(report.output)) {\n            editedResult[key] = value(item)\n          }\n\n          return editedResult\n        })\n\n        resolve(result)\n      } else {\n        log.verbose('compiling report (single)...')\n        // Otherwise, translate the object returned.\n        let editedResult = {}\n        for (let [key, value] of Object.entries(report.output)) {\n          editedResult[key] = value(result)\n        }\n\n        resolve(editedResult)\n      }\n    } else {\n      resolve(result)\n    }\n  })\n}\n\n/**\n * Run a named report and resolve to it's output.\n * The output is formatted based on the `report.output` key, if the params.raw option is NOT set to true.\n * @param {string} query report name\n * @param {Object=} params parameters.\n */\nfunction run (query, params) {\n  params = params || {}\n  return new Promise(async (resolve, reject) => {\n    try {\n      let report = await findReport(query)\n      let result = await runReport(report, params)\n      let compiled = await compileReport(report, result, params)\n\n      resolve(compiled)\n    } catch (e) {\n      reject(e)\n    }\n  })\n}\n\n/**\n * Run a report\n * @param {object} report report module\n * @param {object=} params parameters\n */\nfunction runReport (report, params) {\n  params = params || {}\n\n  return new Promise((resolve, reject) => {\n    var backup\n\n    // Cannot run < v3 backups in this manner.\n    if (!report.version || report.version < 3) {\n      return reject(new Error(`Cannot call ${report.name} as a module, it is not updated to the v3 api`))\n    }\n\n    // If it requires a backup and none is provided, reject.\n    if (report.requiresBackup) {\n      if (!params.backup) {\n        return reject(new Error('Please specify the `backup` parameter to run this report.'))\n      }\n\n      backup = new Backup(backupDirectory, params.backup)\n    }\n\n    // Input params to func\n    let inputParams = {\n      ...params,\n      backup\n    }\n\n    report.run(module.exports, inputParams)\n      .then(resolve)\n      .catch(reject)\n  })\n}\n\nmodule.exports = {\n  // Exported Libraries\n  Backup,\n  Group,\n\n  // Module management\n  registerModule,\n  clearModules,\n  get modules () {\n    return moduleCache\n  },\n\n  // Source directory\n  set base (value) {\n    backupDirectory = value\n  },\n  get base () {\n    return backupDirectory\n  },\n\n  // Runners\n  run,\n  findReport,\n  runReport,\n  compileReport,\n\n  // misc\n  setLogLevel (lvl) {\n    log.setVerbose(lvl)\n  }\n}\n"]}