"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

require("core-js/modules/es.object.set-prototype-of.js");

require("core-js/modules/es.object.get-prototype-of.js");

require("core-js/modules/es.reflect.construct.js");

require("core-js/modules/es.object.create.js");

require("core-js/modules/es.symbol.js");

require("core-js/modules/es.symbol.description.js");

require("core-js/modules/es.object.to-string.js");

require("core-js/modules/es.symbol.iterator.js");

require("core-js/modules/es.array.iterator.js");

require("core-js/modules/es.string.iterator.js");

require("core-js/modules/web.dom-collections.iterator.js");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.BaseResourceWithId = void 0;

require("core-js/modules/es.array.concat.js");

require("core-js/modules/es.function.name.js");

require("core-js/modules/es.object.define-property.js");

var _baseResourceWithErrorHandling = require("./base-resource-with-error-handling");

var _errors = require("./errors");

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var BaseResourceWithId = /*#__PURE__*/function (_BaseResourceWithErro) {
  _inherits(BaseResourceWithId, _BaseResourceWithErro);

  var _super = _createSuper(BaseResourceWithId);

  function BaseResourceWithId() {
    var _this;

    _classCallCheck(this, BaseResourceWithId);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));

    _defineProperty(_assertThisInitialized(_this), "_id", void 0);

    return _this;
  }

  _createClass(BaseResourceWithId, [{
    key: "id",
    get:
    /**
     * The id for the resource.
     */
    function get() {
      return this._id;
    },
    set: function set(id) {
      if (this.id && this.id !== id) {
        var _cls$resourceName;

        var cls = this.constructor;
        throw new _errors.UpdateIdError((_cls$resourceName = cls === null || cls === void 0 ? void 0 : cls.resourceName) !== null && _cls$resourceName !== void 0 ? _cls$resourceName : cls.name);
      }

      this._id = id;
    }
  }]);

  return BaseResourceWithId;
}(_baseResourceWithErrorHandling.BaseResourceWithErrorHandling);

exports.BaseResourceWithId = BaseResourceWithId;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21tb24vYmFzZS1yZXNvdXJjZS13aXRoLWlkLnRzIl0sIm5hbWVzIjpbIkJhc2VSZXNvdXJjZVdpdGhJZCIsIl9pZCIsImlkIiwiY2xzIiwiY29uc3RydWN0b3IiLCJVcGRhdGVJZEVycm9yIiwicmVzb3VyY2VOYW1lIiwibmFtZSIsIkJhc2VSZXNvdXJjZVdpdGhFcnJvckhhbmRsaW5nIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7O0FBQ0E7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztJQUVhQSxrQjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQ1g7QUFDRjtBQUNBO0FBQ0UsbUJBQW9DO0FBQ2xDLGFBQU8sS0FBS0MsR0FBWjtBQUNELEs7U0FFRCxhQUFjQyxFQUFkLEVBQXNDO0FBQ3BDLFVBQUksS0FBS0EsRUFBTCxJQUFXLEtBQUtBLEVBQUwsS0FBWUEsRUFBM0IsRUFBK0I7QUFBQTs7QUFDN0IsWUFBTUMsR0FBRyxHQUFHLEtBQUtDLFdBQWpCO0FBQ0EsY0FBTSxJQUFJQyxxQkFBSixzQkFBa0JGLEdBQWxCLGFBQWtCQSxHQUFsQix1QkFBa0JBLEdBQUcsQ0FBRUcsWUFBdkIsaUVBQXVDSCxHQUFHLENBQUNJLElBQTNDLENBQU47QUFDRDs7QUFDRCxXQUFLTixHQUFMLEdBQVdDLEVBQVg7QUFDRDs7OztFQWRx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