import { IconElement, PopoverMenuProps } from '@wix/design-system';
import type React from 'react';

export type ActionSubitem = {
  /**
   * A callback that runs each time the button is clicked.
   * @external
   */
  onClick?: any;
  /**
   * Button label.
   * @external
   */
  label?: string;
  /**
   * Subtitle text displayed for buttons in the popover menu.
   * @external
   */
  subtitle?: string;
  /**
   * An icon displayed before the button label.
   * @external
   */
  prefixIcon?: IconElement;
  /**
   * An optional tooltip when the popover is disabled.
   * @external
   */
  tooltip?: string;
  /**
   * An optional disabled flag.
   * @external
   */
  disabled?: boolean;
  /**
   *  A data-hook for the button.
   * @external
   */
  dataHook?: string;
  /**
   * A unique name for a `cairoPageCtaClicked` BI event.
   * @internal
   */
  biName?: string;
  /**
   * Additional info for a `cairoPageCtaClicked` BI event.
   * @internal
   */
  biAdditionalInfo?: string;
  /**
   * Action items to render in a popover menu. Use nested arrays to group actions. A divider is added between each group.
   * @overrideType [ActionSubitem[]](./?path=/story/common-types--actionsubitem) | [ActionSubitem[][]](./?path=/story/common-types--actionsubitem)
   * @external
   */
  subItems?: ActionSubitem[] | ActionSubitem[][];
  /**
   * Custom [`PopoverMenuProps`](https://www.docs.wixdesignsystem.com/?path=/story/components-overlays--popovermenu) to pass to the sub-items popover menu.
   * @external
   */
  popoverMenuProps?: Partial<PopoverMenuProps>;
  /**
   * Optional ref to the underlying button element (for focus restoration, etc.).
   * @external
   */
  ref?: React.Ref<HTMLButtonElement>;
};

export type MultiBulkActionSubItem = ActionSubitem;

export type ActionSubitemLabelPrivate = {
  sectionTitle: string;
  dataHook?: string;
};

export type ActionSubItemPrivate = Omit<ActionSubitem, 'subItems'> & {
  subItems?: (
    | (ActionSubitem & {
        componentId?: string;
        appId?: string;
      })
    | ActionSubitemLabelPrivate
  )[][];
};
