"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _mobx = require("mobx");
var _utils = require("../utils");
var _prop = _interopRequireDefault(require("./prop"));
var Props = exports["default"] = /*#__PURE__*/function () {
  function Props(owner, values) {
    var _this = this;
    if (values === void 0) {
      values = {};
    }
    this.id = (0, _utils.uniqueId)('props');
    this.items = [];
    this.owner = void 0;
    (0, _mobx.makeAutoObservable)(this, {
      owner: false,
      id: false
    });
    this.owner = owner;
    this.items = Object.keys(values).map(function (key) {
      return new _prop["default"](_this, values[key], key);
    });
  }
  var _proto = Props.prototype;
  _proto["export"] = function _export() {
    var result = {};
    this.items.forEach(function (item) {
      result[item.name] = item["export"]();
    });
    return result;
  };
  _proto.getProp = function getProp(propName, createIfNone) {
    if (createIfNone === void 0) {
      createIfNone = true;
    }
    var prop = this.items.find(function (prop) {
      return prop.name === propName;
    });
    if (createIfNone && !prop) {
      prop = new _prop["default"](this, undefined, propName);
      this.items.push(prop);
    }
    return prop;
  };
  return Props;
}();