import { makeAutoObservable } from 'mobx';
import { uniqueId } from '../utils';
import Prop from './prop';
var Props = /*#__PURE__*/function () {
  function Props(owner, values) {
    var _this = this;
    if (values === void 0) {
      values = {};
    }
    this.id = uniqueId('props');
    this.items = [];
    this.owner = void 0;
    makeAutoObservable(this, {
      owner: false,
      id: false
    });
    this.owner = owner;
    this.items = Object.keys(values).map(function (key) {
      return new Prop(_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(this, undefined, propName);
      this.items.push(prop);
    }
    return prop;
  };
  return Props;
}();
export { Props as default };