"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.SharedComponent = void 0; var _lodash = _interopRequireDefault(require("lodash")); var _autocomplete_component = require("./autocomplete_component"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ class SharedComponent extends _autocomplete_component.AutocompleteComponent { constructor(name, parent) { super(name); this._nextDict = {}; if (parent) { parent.addComponent(this); } // for debugging purposes this._parent = parent; } /* return the first component with a given name */ getComponent(name) { return (this._nextDict[name] || [undefined])[0]; } addComponent(component) { const current = this._nextDict[component.name] || []; current.push(component); this._nextDict[component.name] = current; this.next = [].concat.apply([], _lodash.default.values(this._nextDict)); } } exports.SharedComponent = SharedComponent;