/// <reference path="../../index.d.ts" />
import type TemplateItem from "@arcgis/core/widgets/FeatureTemplates/TemplateItem.js";
import type TemplateItemGroup from "@arcgis/core/widgets/FeatureTemplates/TemplateItemGroup.js";
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
import type { ArcgisReferenceElement, IconName } from "../types.js";
import type { SelectEvent, FeatureTemplatesViewModelState } from "@arcgis/core/widgets/FeatureTemplates/FeatureTemplatesViewModel.js";
import type { MapViewOrSceneView } from "@arcgis/core/views/MapViewOrSceneView.js";
import type { HeadingLevel } from "@arcgis/core/widgets/support/types.js";
import type { Icon } from "@esri/calcite-components/components/calcite-icon";

/**
 * > [!WARNING]
 * >
 * > This is a **legacy component**. It relies on an underlying widget as part of our migration to native web components.
 * >
 * > A fully native replacement for this component is in development. Once it reaches feature parity, the legacy component will be deprecated and no longer maintained. At that point, development should use the native component.
 *
 * The FeatureTemplates component is part of an editing workflow. Its main purpose is to display [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) templates from one or more feature layers.
 *
 * @since 5.0
 */
export abstract class ArcgisFeatureTemplatesLegacy extends LitElement {
  /**
   * If true, the component will not be destroyed automatically when it is
   * disconnected from the document. This is useful when you want to move the
   * component to a different place on the page, or temporarily hide it. If this
   * is set, make sure to call the [destroy()](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-templates-legacy/#destroy) method when you are done to
   * prevent memory leaks.
   *
   * @default false
   */
  accessor autoDestroyDisabled: boolean;
  /**
   * A function that can be defined to disable specific
   * [template items](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTemplates/TemplateItem/)
   * within the component. The function takes an object containing a
   * [layer](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTemplates/TemplateItem/#layer)
   * and [template](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTemplates/TemplateItem/#template). If the function returns `true`, the item is disabled.
   */
  accessor disabledItemFunction: DisabledItemFunction;
  /**
   * Text used to filter items.
   *
   * @default ""
   */
  accessor filterText: string;
  /**
   * Indicates the heading level to use for the labels of grouped feature templates.
   * By default, the group label is rendered
   * as a level 4 heading (e.g. `<h4>Group label</h4>`). Depending on the component's placement
   * in your app, you may need to adjust this heading for proper semantics. This is
   * important for meeting accessibility standards.
   *
   * @default 4
   * @since 4.20
   * @see [Heading Elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements)
   * @example
   * // Group label will render as an <h3>
   * featureTemplates.headingLevel = 3;
   */
  accessor headingLevel: HeadingLevel;
  /**
   * Indicates whether the templates filter displays.
   *
   * @default false
   * @since 5.0
   */
  accessor hideFilter: boolean;
  /**
   * Icon which represents the component.
   * Typically used when the component is controlled by another component (e.g. by the Expand component).
   *
   * @default "list-rectangle"
   * @see [Calcite Icons](https://developers.arcgis.com/calcite-design-system/icons/)
   */
  get icon(): Icon["icon"];
  set icon(value: IconName);
  get items(): Array<TemplateItem | TemplateItemGroup>;
  /** The component's default label. */
  accessor label: string;
  /**
   * By assigning the `id` attribute of the Map or Scene component to this property, you can position a child component anywhere in the DOM while still maintaining a connection to the Map or Scene.
   *
   * @see [Associate components with a Map or Scene component](https://developers.arcgis.com/javascript/latest/programming-patterns/#associate-components-with-a-map-or-scene-component)
   */
  accessor referenceElement: ArcgisReferenceElement | string | undefined;
  get selectedItem(): TemplateItem | undefined;
  /**
   * Specifies the selection behavior of list items. The `"single"` selection mode keeps the clicked list item selected. Whereas, `"none"` does not preserve the selection after clicking the list item.
   *
   * @default "none"
   */
  accessor selectionMode: "single" | "none" | null | undefined;
  /**
   * The current state of the component.
   *
   * @default "disabled"
   */
  get state(): FeatureTemplatesViewModelState;
  /** A reference to the MapView or SceneView. */
  accessor view: MapViewOrSceneView | null | undefined;
  /** Permanently destroy the component. */
  destroy(): Promise<void>;
  /**
   * Selects the template item to use.
   *
   * @param item - The template item to select.
   */
  select(item: null | undefined | TemplateItem): void;
  "@setterTypes": {
    icon?: IconName;
  };
  /** Emitted when the value of a property is changed. Use this to listen to changes to properties. */
  readonly arcgisPropertyChange: import("@arcgis/lumina").TargetedEvent<this, { name: "state"; }>;
  /** Emitted when the component associated with a map or scene view is ready to be interacted with. */
  readonly arcgisReady: import("@arcgis/lumina").TargetedEvent<this, void>;
  readonly arcgisSelect: import("@arcgis/lumina").TargetedEvent<this, SelectEvent>;
  readonly "@eventTypes": {
    arcgisPropertyChange: ArcgisFeatureTemplatesLegacy["arcgisPropertyChange"]["detail"];
    arcgisReady: ArcgisFeatureTemplatesLegacy["arcgisReady"]["detail"];
    arcgisSelect: ArcgisFeatureTemplatesLegacy["arcgisSelect"]["detail"];
  };
}

/** @param params */
export type DisabledItemFunction = (params: Pick<TemplateItem, "layer" | "template">) => boolean;