"use strict";

exports.__esModule = true;
exports.default = void 0;

var _componentClass = _interopRequireDefault(require("./component-class"));

exports.Component = _componentClass.default;

var _parseComponent = _interopRequireDefault(require("./parse-component"));

var _customComponents = _interopRequireDefault(require("./custom-components"));

var _componentMixins = _interopRequireDefault(require("./component-mixins"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function registerComponentMixin(name, mixin) {
  _componentMixins.default[name] = mixin;
}

function registerComponent(tagName, component) {
  _customComponents.default[tagName] = component;
}

var _default = {
  name: 'component',
  static: {
    Component: _componentClass.default,
    registerComponentMixin: registerComponentMixin,
    registerComponent: registerComponent
  },
  create: function create() {
    var app = this;
    app.component = {
      registerComponentMixin: registerComponentMixin,
      registerComponent: registerComponent,
      parse: function parse(componentString) {
        return (0, _parseComponent.default)(componentString);
      },
      create: function create(options, context, children) {
        if (typeof options === 'function') {
          var root = options.root,
              el = options.el; // eslint-disable-next-line

          return new options(app, {
            isClassComponent: true,
            root: root,
            el: el
          }, context, children);
        }

        return new _componentClass.default(app, options, context, children);
      }
    };
  }
};
exports.default = _default;