/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	// The require scope
/******/ 	var __webpack_require__ = {};
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	(() => {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = (exports) => {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	})();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "default": () => (/* binding */ src)
});

;// CONCATENATED MODULE: external "@babel/runtime/helpers/defineProperty"
const defineProperty_namespaceObject = require("@babel/runtime/helpers/defineProperty");
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_namespaceObject);
;// CONCATENATED MODULE: external "@tkey/core"
const core_namespaceObject = require("@tkey/core");
var core_default = /*#__PURE__*/__webpack_require__.n(core_namespaceObject);
;// CONCATENATED MODULE: external "@tkey/service-provider-base"
const service_provider_base_namespaceObject = require("@tkey/service-provider-base");
;// CONCATENATED MODULE: external "@tkey/service-provider-torus"
const service_provider_torus_namespaceObject = require("@tkey/service-provider-torus");
;// CONCATENATED MODULE: external "@tkey/share-serialization"
const share_serialization_namespaceObject = require("@tkey/share-serialization");
;// CONCATENATED MODULE: external "@tkey/share-transfer"
const share_transfer_namespaceObject = require("@tkey/share-transfer");
;// CONCATENATED MODULE: external "@tkey/storage-layer-torus"
const storage_layer_torus_namespaceObject = require("@tkey/storage-layer-torus");
;// CONCATENATED MODULE: ./src/index.ts

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) { defineProperty_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 (core_default()) {
  constructor(args) {
    const {
      modules = {},
      serviceProvider,
      storageLayer,
      customAuthArgs,
      serverTimeOffset
    } = args || {};
    const defaultModules = {
      [share_transfer_namespaceObject.SHARE_TRANSFER_MODULE_NAME]: new share_transfer_namespaceObject.ShareTransferModule(),
      [share_serialization_namespaceObject.SHARE_SERIALIZATION_MODULE_NAME]: new share_serialization_namespaceObject.ShareSerializationModule()
    };
    let finalServiceProvider;
    let finalStorageLayer;
    if (!serviceProvider) {
      finalServiceProvider = new service_provider_torus_namespaceObject.TorusServiceProvider({
        customAuthArgs
      });
    } else {
      finalServiceProvider = serviceProvider;
    }
    if (!storageLayer) {
      finalStorageLayer = new storage_layer_torus_namespaceObject.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 = {},
      customAuthArgs,
      serverTimeOffset = 0
    } = args || {};
    const defaultModules = {
      [share_transfer_namespaceObject.SHARE_TRANSFER_MODULE_NAME]: new share_transfer_namespaceObject.ShareTransferModule(),
      [share_serialization_namespaceObject.SHARE_SERIALIZATION_MODULE_NAME]: new share_serialization_namespaceObject.ShareSerializationModule()
    };
    const finalServiceProvider = serviceProvider || service_provider_torus_namespaceObject.TorusServiceProvider.fromJSON(tempOldServiceProvider) || service_provider_base_namespaceObject.ServiceProviderBase.fromJSON(tempOldServiceProvider) || new service_provider_torus_namespaceObject.TorusServiceProvider({
      customAuthArgs
    });
    tempOldStorageLayer.serviceProvider = finalServiceProvider;
    const finalStorageLayer = storageLayer || storage_layer_torus_namespaceObject.MockStorageLayer.fromJSON(tempOldStorageLayer) || storage_layer_torus_namespaceObject.TorusStorageLayer.fromJSON(tempOldStorageLayer) || new storage_layer_torus_namespaceObject.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 */ const src = (ThresholdKey);
module.exports = __webpack_exports__;
/******/ })()
;
//# sourceMappingURL=default.cjs.js.map