"use strict";

exports.__esModule = true;
exports.mergeActionsForNarrowMode = mergeActionsForNarrowMode;
function normalizeToGroups(items) {
  if (!items || items.length === 0) {
    return [];
  }
  return Array.isArray(items[0]) ? items : [items];
}
function toMoreActionsItem(subitem) {
  return {
    text: subitem.label ?? '',
    onClick: subitem.onClick ?? (() => {}),
    prefixIcon: subitem.prefixIcon,
    disabled: subitem.disabled,
    subtitle: subitem.subtitle,
    dataHook: subitem.dataHook,
    biName: subitem.biName,
    biAdditionalInfo: subitem.biAdditionalInfo
  };
}
function secondaryActionsToGroups(secondaryActions) {
  if (!secondaryActions) {
    return [];
  }
  const {
    label,
    onClick,
    prefixIcon,
    disabled,
    biName,
    biAdditionalInfo,
    subItems
  } = secondaryActions.props;
  if (subItems && subItems.length > 0) {
    return normalizeToGroups(subItems).map(group => group.map(toMoreActionsItem));
  }
  if (label) {
    return [[{
      text: label,
      onClick: onClick ?? (() => {}),
      prefixIcon,
      disabled,
      biName,
      biAdditionalInfo
    }]];
  }
  return [];
}
function mergeActionsForNarrowMode(secondaryActions, moreActionsItems) {
  const secondaryGroups = secondaryActionsToGroups(secondaryActions);
  const moreActionsGroups = normalizeToGroups(moreActionsItems);
  return [...secondaryGroups, ...moreActionsGroups];
}
//# sourceMappingURL=transformSecondaryActionsToMoreActions.js.map