module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 7);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

module.exports = require("@tkey/share-serialization");

/***/ }),
/* 1 */
/***/ (function(module, exports) {

module.exports = require("@tkey/share-transfer");

/***/ }),
/* 2 */
/***/ (function(module, exports) {

module.exports = require("@tkey/storage-layer-torus");

/***/ }),
/* 3 */
/***/ (function(module, exports) {

module.exports = require("@tkey/service-provider-torus");

/***/ }),
/* 4 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/defineProperty");

/***/ }),
/* 5 */
/***/ (function(module, exports) {

module.exports = require("@tkey/core");

/***/ }),
/* 6 */
/***/ (function(module, exports) {

module.exports = require("@tkey/service-provider-base");

/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _tkey_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
/* harmony import */ var _tkey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_tkey_core__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _tkey_service_provider_base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
/* harmony import */ var _tkey_service_provider_base__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_tkey_service_provider_base__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _tkey_service_provider_torus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
/* harmony import */ var _tkey_service_provider_torus__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_tkey_service_provider_torus__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _tkey_share_serialization__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(0);
/* harmony import */ var _tkey_share_serialization__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_tkey_share_serialization__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _tkey_share_transfer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
/* harmony import */ var _tkey_share_transfer__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_tkey_share_transfer__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _tkey_storage_layer_torus__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2);
/* harmony import */ var _tkey_storage_layer_torus__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_tkey_storage_layer_torus__WEBPACK_IMPORTED_MODULE_6__);


function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }








class ThresholdKey extends _tkey_core__WEBPACK_IMPORTED_MODULE_1___default.a {
  constructor(args) {
    const {
      modules = {},
      serviceProvider,
      storageLayer,
      directParams,
      serverTimeOffset
    } = args || {};
    const defaultModules = {
      [_tkey_share_transfer__WEBPACK_IMPORTED_MODULE_5__["SHARE_TRANSFER_MODULE_NAME"]]: new _tkey_share_transfer__WEBPACK_IMPORTED_MODULE_5__["ShareTransferModule"](),
      [_tkey_share_serialization__WEBPACK_IMPORTED_MODULE_4__["SHARE_SERIALIZATION_MODULE_NAME"]]: new _tkey_share_serialization__WEBPACK_IMPORTED_MODULE_4__["ShareSerializationModule"]()
    };
    let finalServiceProvider;
    let finalStorageLayer;

    if (!serviceProvider) {
      finalServiceProvider = new _tkey_service_provider_torus__WEBPACK_IMPORTED_MODULE_3__["TorusServiceProvider"]({
        directParams
      });
    } else {
      finalServiceProvider = serviceProvider;
    }

    if (!storageLayer) {
      finalStorageLayer = new _tkey_storage_layer_torus__WEBPACK_IMPORTED_MODULE_6__["TorusStorageLayer"]({
        hostUrl: "https://metadata.tor.us",
        serverTimeOffset
      });
    } else {
      finalStorageLayer = storageLayer;
    }

    super(_objectSpread(_objectSpread({}, args || {}), {}, {
      modules: _objectSpread(_objectSpread({}, defaultModules), modules),
      serviceProvider: finalServiceProvider,
      storageLayer: finalStorageLayer
    }));
  }

  static async fromJSON(value, args) {
    const {
      storageLayer: tempOldStorageLayer,
      serviceProvider: tempOldServiceProvider
    } = value;
    const {
      storageLayer,
      serviceProvider,
      modules = {},
      directParams,
      serverTimeOffset = 0
    } = args || {};
    const defaultModules = {
      [_tkey_share_transfer__WEBPACK_IMPORTED_MODULE_5__["SHARE_TRANSFER_MODULE_NAME"]]: new _tkey_share_transfer__WEBPACK_IMPORTED_MODULE_5__["ShareTransferModule"](),
      [_tkey_share_serialization__WEBPACK_IMPORTED_MODULE_4__["SHARE_SERIALIZATION_MODULE_NAME"]]: new _tkey_share_serialization__WEBPACK_IMPORTED_MODULE_4__["ShareSerializationModule"]()
    };
    const finalServiceProvider = serviceProvider || _tkey_service_provider_torus__WEBPACK_IMPORTED_MODULE_3__["TorusServiceProvider"].fromJSON(tempOldServiceProvider) || _tkey_service_provider_base__WEBPACK_IMPORTED_MODULE_2__["ServiceProviderBase"].fromJSON(tempOldServiceProvider) || new _tkey_service_provider_torus__WEBPACK_IMPORTED_MODULE_3__["TorusServiceProvider"]({
      directParams
    });
    tempOldStorageLayer.serviceProvider = finalServiceProvider;
    const finalStorageLayer = storageLayer || _tkey_storage_layer_torus__WEBPACK_IMPORTED_MODULE_6__["MockStorageLayer"].fromJSON(tempOldStorageLayer) || _tkey_storage_layer_torus__WEBPACK_IMPORTED_MODULE_6__["TorusStorageLayer"].fromJSON(tempOldStorageLayer) || new _tkey_storage_layer_torus__WEBPACK_IMPORTED_MODULE_6__["TorusStorageLayer"]({
      hostUrl: "https://metadata.tor.us",
      serverTimeOffset
    });
    return super.fromJSON(value, _objectSpread(_objectSpread({}, args || {}), {}, {
      modules: _objectSpread(_objectSpread({}, defaultModules), modules),
      serviceProvider: finalServiceProvider,
      storageLayer: finalStorageLayer
    }));
  }

}

/* harmony default export */ __webpack_exports__["default"] = (ThresholdKey);

/***/ })
/******/ ]);
//# sourceMappingURL=default.cjs.js.map