import type MapView from "@arcgis/core/views/MapView.js";
import type SceneView from "@arcgis/core/views/SceneView.js";
import type FeatureLayerView from "@arcgis/core/views/layers/FeatureLayerView.js";
import type { SupportedLayer } from "../../interfaces.js";
import type { WebChart } from "../../spec/web-chart.js";
import type { RESTRendererType } from "../../spec/rest-js-object-literals.js";
import type { ICodedValue } from "../../spec/rest-js-types.js";

/** @internal */
export interface QueryObjectProps {
  chartConfig: WebChart;
  layer?: FeatureLayerView | SupportedLayer;
  view?: MapView | SceneView;
  filterByExtent?: boolean;
}

/** @internal */
export interface RendererInfo {
  rendererType?: RESTRendererType;
  rendererField?: string;
  rendererNormalizationField?: string;
}

/** @internal */
export interface ServerRestInfo {
  currentVersion?: string;
  fullVersion?: string;
  owningSystemUrl?: string;
  owningTenant?: string;
  authInfo?: {
      isTokenBasedSecurity: boolean;
      tokenServicesUrl: string;
  };
}

/**
 * Store information about coded-value domains in the subtype
 *
 * @internal
 */
export interface ICodedValueDomain {
  fieldName: string;
  name: string;
  codedValues?: ICodedValue[];
}

/**
 * Store information about featureType
 *
 * @internal
 */
export interface IFeatureType {
  id: number | string;
  name: string;
  domains?: ICodedValueDomain[];
}

/**
 * Store information about subtypes from the feature layer, if any, with:
 * - either the couple typeIdField + types
 * - or the couple subtypeField + subtypes
 *  representing the field name and information associating a code with a name
 *
 * @internal
 */
export interface SubtypeInfo {
  typeIdField?: string;
  types?: IFeatureType[];
  subtypeField?: string;
  subtypes?: IFeatureType[];
}

export type QueryObject = FeatureLayerView | SupportedLayer | undefined;