import type CodedValue from "./CodedValue.js";
import type Domain from "./Domain.js";
import type { DomainProperties } from "./Domain.js";
import type { CodedValueProperties } from "./CodedValue.js";

export interface CodedValueDomainProperties extends DomainProperties {
  /** An array of the coded values in the domain. */
  codedValues?: CodedValueProperties[];
}

/**
 * Information about the coded values belonging to the domain.
 * Coded value domains specify a valid set of values for a
 * [Field](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/).
 * Each [valid value](https://developers.arcgis.com/javascript/latest/references/core/layers/support/CodedValue/#CodedValueProperties) is assigned a [unique name](https://developers.arcgis.com/javascript/latest/references/core/layers/support/CodedValue/#CodedValueProperties).
 * For example, in a layer for water mains, water main features may be buried under different types of
 * surfaces as signified by a GroundSurfaceType field: pavement, gravel, sand, or none (for exposed water mains).
 * The coded value domain includes both the actual value that is stored in the database (for example, 1 for pavement)
 * and a more user-friendly description of what that value actually means.
 *
 * @since 4.0
 * @see [Domain Objects - ArcGIS Server REST API](https://developers.arcgis.com/documentation/common-data-types/domain-objects.htm)
 * @see [Field](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/)
 */
export default class CodedValueDomain extends Domain {
  constructor(properties?: CodedValueDomainProperties);
  /** An array of the coded values in the domain. */
  get codedValues(): CodedValue[];
  set codedValues(value: CodedValueProperties[]);
  /** The domain type. */
  get type(): "coded-value";
  /**
   * Returns the name of the coded-value associated with the specified code.
   *
   * @param code - The code associated with the desired name, e.g. `1` could be a code used for a returned name of `pavement`.
   * @returns The name of the coded value as specified by the `code`.
   */
  getName(code: string | number): string | null | undefined;
}