import type ActionButton from "../../support/actions/ActionButton.js";
import type ActionToggle from "../../support/actions/ActionToggle.js";
import type ListItem from "./ListItem.js";

export type VisibilityAppearance = "default" | "checkbox";

/**
 * Specifies a function to handle filtering layer [list items](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html).
 *
 * @param item - A list item
 *   created by the LayerList.
 */
export type FilterPredicate = (item: ListItem) => boolean;

/**
 * Function definition for the [LayerList#listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction), [BasemapLayerList#baseListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#baseListItemCreatedFunction),
 * and [BasemapLayerList#referenceListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#referenceListItemCreatedFunction) properties.
 * See the example snippets in the documentations for those properties for more details.
 *
 * @param event - An object containing a list item created by the LayerList.
 */
export type ListItemModifier = (event: ListItemModifierEvent) => void;

export interface ListItemModifierEvent {
  /**
   * A list item
   *   created by the LayerList. You can modify the properties of this item to customize
   *   the text, actions, panel content, and visibility of the list item. See the
   *   documentation for the [LayerList#listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction) for more details.
   */
  item: ListItem;
}

export type Action = ActionButton | ActionToggle;

export type State = "ready" | "loading" | "disabled";