import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
function getExtensionModuleField(_x, _x2, _x3) {
  return _getExtensionModuleField.apply(this, arguments);
}
/** attempt to get the custom resolver for this field, or throw */
function _getExtensionModuleField() {
  _getExtensionModuleField = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(manifest, fieldType, handlerLink) {
    var type, handler;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          if (handlerLink.type) {
            _context.next = 2;
            break;
          }
          throw new Error("Missing type!");
        case 2:
          if (manifest.modules.fields) {
            _context.next = 4;
            break;
          }
          throw new Error("No definition of fields for extension type \"".concat(manifest.type, "\" and key \"").concat(manifest.key, "\""));
        case 4:
          if (manifest.modules.fields[fieldType]) {
            _context.next = 6;
            break;
          }
          throw new Error("No definition for field type \"".concat(fieldType, "\" on manifest for extension with type \"").concat(manifest.type, "\" and key \"").concat(manifest.key, "\""));
        case 6:
          type = handlerLink.type;
          handler = manifest.modules.fields[fieldType][type];
          if (handler) {
            _context.next = 10;
            break;
          }
          throw new Error("No handler of type \"".concat(type, "\" for extension type \"").concat(manifest.type, "\" and key \"").concat(manifest.key, "\""));
        case 10:
          return _context.abrupt("return", handler);
        case 11:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return _getExtensionModuleField.apply(this, arguments);
}
export function getCustomFieldResolver(_x4, _x5) {
  return _getCustomFieldResolver.apply(this, arguments);
}

/** attempt to get the serializer for this field, or throw */
function _getCustomFieldResolver() {
  _getCustomFieldResolver = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(manifest, handlerLink) {
    var handler;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          _context2.next = 2;
          return getExtensionModuleField(manifest, 'custom', handlerLink);
        case 2:
          handler = _context2.sent;
          return _context2.abrupt("return", handler.resolver);
        case 4:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  }));
  return _getCustomFieldResolver.apply(this, arguments);
}
export function getFieldSerializer(_x6, _x7) {
  return _getFieldSerializer.apply(this, arguments);
}

/** attempt to get the deserializer for this field, or throw */
function _getFieldSerializer() {
  _getFieldSerializer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(manifest, handlerLink) {
    var handler;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) switch (_context3.prev = _context3.next) {
        case 0:
          _context3.next = 2;
          return getExtensionModuleField(manifest, 'fieldset', handlerLink);
        case 2:
          handler = _context3.sent;
          return _context3.abrupt("return", handler.serializer);
        case 4:
        case "end":
          return _context3.stop();
      }
    }, _callee3);
  }));
  return _getFieldSerializer.apply(this, arguments);
}
export function getFieldDeserializer(_x8, _x9) {
  return _getFieldDeserializer.apply(this, arguments);
}

/** attempt to get the user field context provider for this field, or throw */
function _getFieldDeserializer() {
  _getFieldDeserializer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(manifest, handlerLink) {
    var handler;
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) switch (_context4.prev = _context4.next) {
        case 0:
          _context4.next = 2;
          return getExtensionModuleField(manifest, 'fieldset', handlerLink);
        case 2:
          handler = _context4.sent;
          return _context4.abrupt("return", handler.deserializer);
        case 4:
        case "end":
          return _context4.stop();
      }
    }, _callee4);
  }));
  return _getFieldDeserializer.apply(this, arguments);
}
export function getUserFieldContextProvider(_x10, _x11) {
  return _getUserFieldContextProvider.apply(this, arguments);
}
function _getUserFieldContextProvider() {
  _getUserFieldContextProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(manifest, handlerLink) {
    var handler;
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) switch (_context5.prev = _context5.next) {
        case 0:
          _context5.next = 2;
          return getExtensionModuleField(manifest, 'user', handlerLink);
        case 2:
          handler = _context5.sent;
          return _context5.abrupt("return", handler.provider);
        case 4:
        case "end":
          return _context5.stop();
      }
    }, _callee5);
  }));
  return _getUserFieldContextProvider.apply(this, arguments);
}