import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import RelationalField from "./RelationalField";
import { forwardsOneToOneDescriptor, backwardsOneToOneDescriptor } from "../descriptors";
/**
 * @memberof module:fields
 */

export var OneToOne =
/*#__PURE__*/
function (_RelationalField) {
  _inheritsLoose(OneToOne, _RelationalField);

  function OneToOne() {
    return _RelationalField.apply(this, arguments) || this;
  }

  var _proto = OneToOne.prototype;

  _proto.getBackwardsFieldName = function getBackwardsFieldName(model) {
    return this.relatedName || model.modelName.toLowerCase();
  };

  _proto.createForwardsDescriptor = function createForwardsDescriptor(fieldName, model, toModel, throughModel) {
    return forwardsOneToOneDescriptor(fieldName, toModel.modelName);
  };

  _proto.createBackwardsDescriptor = function createBackwardsDescriptor(fieldName, model, toModel, throughModel) {
    return backwardsOneToOneDescriptor(fieldName, model.modelName);
  };

  return OneToOne;
}(RelationalField);
export default OneToOne;