"use strict";

import _ from 'lodash';
import { switchTabByIndex } from "../actions/layoutActions.js";
import ParentNode from "./ParentNode.js";
export default class BottomTabsNode extends ParentNode {
  constructor(layout, parentNode) {
    super(layout, 'BottomTabs', parentNode);
    this.selectedIndex = layout.data?.options?.bottomTabs?.currentTabIndex || 0;
  }
  mergeOptions(_options) {
    super.mergeOptions(_options);
    const {
      options
    } = this.data;
    if (options.bottomTabs?.currentTabIndex) {
      this.selectedIndex = options.bottomTabs?.currentTabIndex;
      switchTabByIndex(this, this.selectedIndex);
    }
    if (options.bottomTabs?.currentTabId) {
      const index = _.findIndex(this.children, child => child.nodeId === options?.bottomTabs?.currentTabId);
      if (index !== -1) this.selectedIndex = index;
      switchTabByIndex(this, this.selectedIndex);
    }
  }
  getVisibleLayout() {
    return this.children[this.selectedIndex].getVisibleLayout();
  }
}
//# sourceMappingURL=BottomTabsNode.js.map