import type Terminal from "./Terminal.js";
import type { JSONSupport, JSONSupportMixinProperties } from "../../core/JSONSupport.js";
import type { TerminalProperties } from "./Terminal.js";

export interface TerminalConfigurationProperties extends JSONSupportMixinProperties, Partial<Pick<TerminalConfiguration, "defaultConfiguration" | "id" | "name" | "traversabilityModel">> {
  /** An array of [terminals](https://developers.arcgis.com/javascript/latest/api-reference/esri-networks-support-Terminal.html) defined in this configuration. */
  terminals?: TerminalProperties[];
}

export type TraversabilityModelType = "directional" | "bidirectional";

/**
 * A device feature can be assigned a terminal configuration which could have one or more terminals. The terminal configuration defines the terminals and the permissable paths between them.
 * For example, a device feature could have a Dual Terminal configuration which has a High and a Low terminal. A downstream trace starting from High side terminal will return the Low side terminal however the same trace starting from the Low side terminal won't return the High side terminal.
 *
 * Another example, a transformer with  tri-state terminal configuration (3 terminals) H, X1, X2. The allowed paths are H->X1 and H->X2 with a default path H->X1. Running a downstream trace from the H terminal will select X1 and anything underneath it but not X2. The device path can be altered with the terminalConfiguration field.
 * ```js
 *      H
 *
 *    /   \
 *
 * X1       X2
 * ```
 * The terminal class defines terminal properties.
 *
 * @since 4.20
 * @see [Learn more about terminal management](https://pro.arcgis.com/en/pro-app/latest/help/data/utility-network/about-terminal-management.htm)
 * @see [UtilityNetwork](https://developers.arcgis.com/javascript/latest/api-reference/esri-networks-UtilityNetwork.html)
 */
export default class TerminalConfiguration extends JSONSupport {
  constructor(properties?: TerminalConfigurationProperties);
  /** The default terminal configuration path defined. */
  accessor defaultConfiguration: string | null | undefined;
  /** A unique numeric identifier of the terminal configuration. */
  accessor id: number | null | undefined;
  /** The name of the terminal configuration. */
  accessor name: string | null | undefined;
  /** An array of [terminals](https://developers.arcgis.com/javascript/latest/api-reference/esri-networks-support-Terminal.html) defined in this configuration. */
  get terminals(): Terminal[];
  set terminals(value: TerminalProperties[]);
  /** Terminal configurations can be defined as directional or bidirectional. In a directional traversability model, one or more terminals can be defined as `upstream` where the flow of commodity enters or leaves. */
  accessor traversabilityModel: TraversabilityModelType | null | undefined;
}