"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getStrictCoatGlobalLockfile = getStrictCoatGlobalLockfile;
exports.getStrictCoatLocalLockfile = getStrictCoatLocalLockfile;

/**
 * Adds all missing properties to a parsed global lockfile,
 * to access these properties safely in following code
 *
 * @param lockfile The global lockfile that has been read from the disk
 */
function getStrictCoatGlobalLockfile(lockfile) {
  var _lockfile$files$map, _lockfile$files, _lockfile$setup, _lockfile$scripts, _lockfile$dependencie, _lockfile$dependencie2, _lockfile$dependencie3, _lockfile$dependencie4, _lockfile$dependencie5, _lockfile$dependencie6, _lockfile$dependencie7, _lockfile$dependencie8;

  return {
    version: lockfile.version,
    files: (_lockfile$files$map = (_lockfile$files = lockfile.files) === null || _lockfile$files === void 0 ? void 0 : _lockfile$files.map(file => {
      if (file.once) {
        return {
          path: file.path,
          once: true
        };
      }

      return {
        path: file.path,
        once: false,
        hash: file.hash
      };
    })) !== null && _lockfile$files$map !== void 0 ? _lockfile$files$map : [],
    setup: (_lockfile$setup = lockfile.setup) !== null && _lockfile$setup !== void 0 ? _lockfile$setup : {},
    scripts: (_lockfile$scripts = lockfile.scripts) !== null && _lockfile$scripts !== void 0 ? _lockfile$scripts : [],
    dependencies: {
      dependencies: (_lockfile$dependencie = (_lockfile$dependencie2 = lockfile.dependencies) === null || _lockfile$dependencie2 === void 0 ? void 0 : _lockfile$dependencie2.dependencies) !== null && _lockfile$dependencie !== void 0 ? _lockfile$dependencie : [],
      devDependencies: (_lockfile$dependencie3 = (_lockfile$dependencie4 = lockfile.dependencies) === null || _lockfile$dependencie4 === void 0 ? void 0 : _lockfile$dependencie4.devDependencies) !== null && _lockfile$dependencie3 !== void 0 ? _lockfile$dependencie3 : [],
      peerDependencies: (_lockfile$dependencie5 = (_lockfile$dependencie6 = lockfile.dependencies) === null || _lockfile$dependencie6 === void 0 ? void 0 : _lockfile$dependencie6.peerDependencies) !== null && _lockfile$dependencie5 !== void 0 ? _lockfile$dependencie5 : [],
      optionalDependencies: (_lockfile$dependencie7 = (_lockfile$dependencie8 = lockfile.dependencies) === null || _lockfile$dependencie8 === void 0 ? void 0 : _lockfile$dependencie8.optionalDependencies) !== null && _lockfile$dependencie7 !== void 0 ? _lockfile$dependencie7 : []
    }
  };
}
/**
 * Adds all missing properties to a parsed local lockfile,
 * to access these properties safely in following code
 *
 * @param lockfile The local lockfile that has been read from the disk
 */


function getStrictCoatLocalLockfile(lockfile) {
  var _lockfile$files$map2, _lockfile$files2, _lockfile$setup2;

  return {
    version: lockfile.version,
    files: (_lockfile$files$map2 = (_lockfile$files2 = lockfile.files) === null || _lockfile$files2 === void 0 ? void 0 : _lockfile$files2.map(file => {
      if (file.once) {
        return {
          path: file.path,
          once: true
        };
      }

      return {
        path: file.path,
        once: false,
        hash: file.hash
      };
    })) !== null && _lockfile$files$map2 !== void 0 ? _lockfile$files$map2 : [],
    setup: (_lockfile$setup2 = lockfile.setup) !== null && _lockfile$setup2 !== void 0 ? _lockfile$setup2 : {}
  };
}