/// <reference path="../../index.d.ts" />
import type Collection from "@arcgis/core/core/Collection.js";
import type Point from "@arcgis/core/geometry/Point.js";
import type Graphic from "@arcgis/core/Graphic.js";
import type Layer from "@arcgis/core/layers/Layer.js";
import type TerminalConfiguration from "@arcgis/core/networks/support/TerminalConfiguration.js";
import type UtilityNetwork from "@arcgis/core/networks/UtilityNetwork.js";
import type TraceLocation from "@arcgis/core/rest/networks/support/TraceLocation.js";
import type MapView from "@arcgis/core/views/MapView.js";
import type SketchViewModel from "@arcgis/core/widgets/Sketch/SketchViewModel.js";
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
import type { T9nMeta } from "@arcgis/lumina/controllers";

/**
 * This is a sub-component used by the **ArcgisUtilityNetworkTraceAnalysis** component.
 *
 * This sub-component takes a map view as an input.
 * It allows users to select locations on the map to use as trace inputs.
 *
 * @since 4.34
 * @internal
 */
export abstract class ArcgisUtilityNetworkTraceLocation extends LitElement {
  /**
   * A function to run after a hit test is performed to select a trace location. If left empty, the first graphic from the hit test results will be used as the trace location.
   * This function allows for modification of the selected graphic before it is added as a trace location, such as changing its attributes or geometry.
   * If the promise is rejected, the selection process will be cancelled.
   *
   * @internal
   */
  accessor afterHitTest: ((graphics: Graphic[]) => Promise<Graphic>) | undefined;
  /** @default false */
  accessor autoDestroyDisabled: boolean;
  /**
   * A function to run before trace location selection starts.
   *
   * @internal
   */
  accessor beforeTraceLocationSelectStart: (() => Promise<void>) | undefined;
  accessor filterLayers: Collection<Layer> | undefined;
  /** @internal */
  protected messages: {
      buttons: { clear: string; };
      componentLabel: string;
      errors: {};
      labels: {
          close: string;
          unknown: string;
      };
      types: {
          barrier: {
              buttonText: string;
              description: string;
              heading: string;
              message: string;
          };
          startingPoint: {
              buttonText: string;
              description: string;
              heading: string;
              message: string;
          };
          stoppingPoint: {
              buttonText: string;
              description: string;
              heading: string;
              message: string;
          };
      };
  } & T9nMeta<{
      buttons: { clear: string; };
      componentLabel: string;
      errors: {};
      labels: {
          close: string;
          unknown: string;
      };
      types: {
          barrier: {
              buttonText: string;
              description: string;
              heading: string;
              message: string;
          };
          startingPoint: {
              buttonText: string;
              description: string;
              heading: string;
              message: string;
          };
          stoppingPoint: {
              buttonText: string;
              description: string;
              heading: string;
              message: string;
          };
      };
  }>;
  accessor sketchViewModel: SketchViewModel | undefined;
  /** @default 0.05 */
  accessor spatialTolerance: number;
  accessor traceLocations: Collection<FlagInfo> | undefined;
  /** @default "starting-point" */
  accessor traceLocationType: TraceLocationType;
  /** @required */
  accessor utilityNetwork: UtilityNetwork | undefined;
  /** @required */
  accessor view: MapView | undefined;
  /** Permanently destroy the component. */
  destroy(): Promise<void>;
  readonly arcgisTraceLocationChange: import("@arcgis/lumina").TargetedEvent<this, void>;
  /**
   * Fires when the user completes the selection of a trace location.
   *
   * @internal
   */
  readonly arcgisTraceLocationSelectEnd: import("@arcgis/lumina").TargetedEvent<this, void>;
  /**
   * Fires when the user begins selection of a trace location.
   * Can be prevented to stop the selection.
   *
   * @internal
   */
  readonly arcgisTraceLocationSelectStart: import("@arcgis/lumina").TargetedEvent<this, SelectStartPayload>;
  readonly "@eventTypes": {
    arcgisTraceLocationChange: ArcgisUtilityNetworkTraceLocation["arcgisTraceLocationChange"]["detail"];
    arcgisTraceLocationSelectEnd: ArcgisUtilityNetworkTraceLocation["arcgisTraceLocationSelectEnd"]["detail"];
    arcgisTraceLocationSelectStart: ArcgisUtilityNetworkTraceLocation["arcgisTraceLocationSelectStart"]["detail"];
  };
}

/** @internal */
export interface FlagInfo {
  traceLocation: TraceLocation;
  flagProperties: {
      title: string;
      expanded?: boolean;
      terminalConfiguration?: TerminalConfiguration;
      selectedTerminals?: Set<number>;
  };
  spatialProperties: {
      mapPoint?: Point;
      mapGraphic?: Graphic;
      flagGraphic?: Graphic;
  };
}

/** @internal */
export type TraceLocationType = "barrier" | "starting-point" | "stopping-point";

/** @internal */
export interface SelectStartPayload {
  cancelSelect: () => void;
}