var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

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

export var CustomField = function () {
  /**
   * @param {String} type
   * @param {String} alias
   * @param {String} attachedTo
   * @param {String} title
   * @param [rest]
   */
  function CustomField(_ref) {
    var type = _ref.type,
        alias = _ref.alias,
        attachedTo = _ref.attachedTo,
        title = _ref.title,
        rest = _objectWithoutProperties(_ref, ["type", "alias", "attachedTo", "title"]);

    _classCallCheck(this, CustomField);

    this.props = Object.assign({ type: type, alias: alias, attachedTo: attachedTo, title: title }, rest);
  }

  /**
   * @type {String}
   */


  _createClass(CustomField, [{
    key: "toJSON",


    /**
     * @return {{}}
     */
    value: function toJSON() {
      return JSON.parse(JSON.stringify(this.props));
    }

    /**
     * @type {string}
     */

  }, {
    key: "getHandlerClass",
    value: function getHandlerClass() {
      return "Application\\DeskPRO\\CustomFields\\Handler\\" + (this.type.charAt(0).toUpperCase() + this.type.slice(1));
    }
  }, {
    key: "getQualifiedAlias",
    value: function getQualifiedAlias(appId) {
      return "app:" + appId + ":" + this.alias;
    }
  }, {
    key: "type",
    get: function get() {
      return this.props.type;
    }

    /**
     * @type {String}
     */

  }, {
    key: "title",
    get: function get() {
      return this.props.title;
    }

    /**
     * @type {String}
     */

  }, {
    key: "attachedTo",
    get: function get() {
      return this.props.attachedTo;
    }

    /**
     * @type {String}
     */

  }, {
    key: "alias",
    get: function get() {
      return this.props.alias;
    }
  }]);

  return CustomField;
}();