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

/**
 * Specifies the style of the visibility toggle displayed in layer lists.
 *
 * @since 5.0
 * @see [BasemapLayerList.visibilityAppearance](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#visibilityAppearance)
 * @see [CatalogLayerList.visibilityAppearance](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList.html#visibilityAppearance)
 * @see [LayerList.visibilityAppearance](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#visibilityAppearance)
 */
export type VisibilityAppearance = "default" | "checkbox";

/**
 * A function used to filter which [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html) objects appear in the layer list.
 *
 * @param item - The list item to evaluate for inclusion.
 * @since 5.0
 * @see [BasemapLayerList.baseFilterPredicate](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#baseFilterPredicate)
 * @see [BasemapLayerList.referenceFilterPredicate](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#referenceFilterPredicate)
 * @see [CatalogLayerList.filterPredicate](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList.html#filterPredicate)
 * @see [LayerList.filterPredicate](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#filterPredicate)
 */
export type FilterPredicate = (item: ListItem) => boolean;

/**
 * A function for customizing a list item as it is created in the layer lists.
 *
 * @param event - The event containing the list item to customize.
 * @since 5.0
 * @see [BasemapLayerList.baseListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#baseListItemCreatedFunction)
 * @see [BasemapLayerList.referenceListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#referenceListItemCreatedFunction)
 * @see [BasemapLayerListViewModel.baseListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList-BasemapLayerListViewModel.html#baseListItemCreatedFunction)
 * @see [BasemapLayerListViewModel.referenceListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList-BasemapLayerListViewModel.html#referenceListItemCreatedFunction)
 * @see [CatalogLayerList.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList.html#listItemCreatedFunction)
 * @see [CatalogLayerListViewModel.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList-CatalogLayerListViewModel.html#listItemCreatedFunction)
 * @see [LayerList.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction)
 * @see [LayerListViewModel.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#listItemCreatedFunction)
 */
export type ListItemModifier = (event: ListItemModifierEvent) => void;

/**
 * The event object passed to a listItemCreatedFunction in the layer lists.
 * Provides access to the list item being created, allowing you to customize its properties, actions, panel content, or visibility before rendering.
 *
 * @since 5.0
 * @see [BasemapLayerList.baseListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#baseListItemCreatedFunction)
 * @see [BasemapLayerList.referenceListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#referenceListItemCreatedFunction)
 * @see [BasemapLayerListViewModel.baseListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList-BasemapLayerListViewModel.html#baseListItemCreatedFunction)
 * @see [BasemapLayerListViewModel.referenceListItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList-BasemapLayerListViewModel.html#referenceListItemCreatedFunction)
 * @see [CatalogLayerList.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList.html#listItemCreatedFunction)
 * @see [CatalogLayerListViewModel.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList-CatalogLayerListViewModel.html#listItemCreatedFunction)
 * @see [LayerList.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction)
 * @see [LayerListViewModel.listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#listItemCreatedFunction)
 */
export interface ListItemModifierEvent {
  /**
   * The list item instance created by the LayerList. Modify this object to change the item's text, actions, panel content, or visibility.
   *
   * @since 5.0
   */
  item: ListItem;
}

/**
 * An action element that can be used in the layer lists.
 *
 * @since 5.0
 * @see [BasemapLayerList.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList.html#triggerAction)
 * @see [BasemapLayerListViewModel.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapLayerList-BasemapLayerListViewModel.html#triggerAction)
 * @see [CatalogLayerList.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList.html#triggerAction)
 * @see [CatalogLayerListViewModel.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CatalogLayerList-CatalogLayerListViewModel.html#triggerAction)
 * @see [LayerList.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#triggerAction)
 * @see [LayerListViewModel.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#triggerAction)
 * @see [TableList.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-TableList.html#triggerAction)
 * @see [TableListViewModel.triggerAction()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-TableList-TableListViewModel.html#triggerAction)
 */
export type Action = ActionButton | ActionToggle;

/**
 * Describes the current state of the list items in the [LayerListViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html).
 *
 * @since 5.0
 * @see [LayerListViewModel.state](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#state)
 */
export type State = "ready" | "loading" | "disabled";