import type { DefinitionEditorJson } from "./DefinitionEditorJson.js";
import type { DrawingInfoJson } from "./DrawingInfoJson.js";
import type { FieldJson } from "./FieldJson.js";
import type { ExtentJson } from "./GeometryJson.js";
import type { PopupInfoJson } from "./PopupInfoJson.js";
import type { SpatialReferenceJson } from "./SpatialReferenceJson.js";
import type { TemplateJson } from "./TemplateJson.js";
import type { TypeJson } from "./TypeJson.js";
/**
 * The LayerDefinition object defines the attribute schema and drawing
 * information for a layer drawn using client-side graphics. This could include
 * a feature collection, a CSV file referenced through the web, or a single
 * layer in an ArcGIS map service. Also used for dynamic layers.
 *
 * See
 * {@link https://developers.arcgis.com/web-map-specification/objects/layerDefinition/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/layerDefinition/}.
 */
export interface LayerDefinitionJson {
    /**
     * Boolean value indicating whether the geometry of the features in the
     * layer can be edited.
     */
    allowGeometryUpdates?: boolean | null;
    /**
     * A comma-separated string listing which editing operations are allowed on
     * an editable feature service. Available operations include: Create |
     * Delete | Query | Update | Editing.
     */
    capabilities?: string | null;
    /**
     * String value for the copyright text information for the layer.
     */
    copyrightText?: string | null;
    /**
     * Numeric value indicating the server version of the layer.
     */
    currentVersion?: number | null;
    /**
     * Boolean value indicating whether the layer's visibility is turned on.
     */
    defaultVisibility?: boolean | null;
    /**
     * Stores interactive filters.
     */
    definitionEditor?: DefinitionEditorJson | null;
    /**
     * An optional SQL-based definition expression that narrows down the data to
     * be displayed in the layer. Used with ArcGIS Server map services.
     */
    definitionExpression?: string | null;
    /**
     * String value of the layer as defined in the map service.
     */
    description?: string | null;
    /**
     * The name of the field that best summarizes the feature. Values from this
     * field are used by default as the titles for pop-up windows.
     */
    displayField?: string | null;
    /**
     * A drawingInfo object containing drawing, labeling, and transparency
     * information for the layer.
     */
    drawingInfo?: DrawingInfoJson | null;
    /**
     * Specifies how graphics are placed on the vertical axis (z). This property
     * may only be used in a SceneView.
     */
    elevationInfo?: ElevationInfoJson | null;
    /**
     * The rectangular map extent that should be requested from the service,
     * given in the format [[xmin, ymin],[xmax,ymax]].
     */
    extent?: ExtentJson | null;
    /**
     * Feature reductions declutter the screen by hiding features that would
     * otherwise intersect with other features on screen.
     */
    featureReduction?: FeatureReductionJson | null;
    /**
     * The layer-specific overrides of field properties. Used by
     * SubtypeGroupLayer to modify field information for each subtype. Any field
     * missing from this array should be hidden.
     */
    fieldOverrides?: FieldOverrideJson[] | null;
    /**
     * An array of Field objects containing information about the attribute
     * fields for the feature collection or layer.
     */
    fields?: FieldJson[] | null;
    /**
     * Contains floor-awareness information for the layer. See
     * {@link https://developers.arcgis.com/web-map-specification/objects/layerFloorInfo/}.
     */
    floorInfo?: {
        /**
         * The name of the attribute field that contains a floor's level ID used
         * for floor filtering.
         */
        floorField: string;
    } | null;
    /**
     * The type of geometry used in the layer definition. One of the
     * GeometryType constants.
     */
    geometryType?: string | null;
    /**
     * The unique identifier for a feature or table row within a geodatabase.
     */
    globalIdField?: string | null;
    /**
     * Indicates whether attachments should be loaded for the layer.
     */
    hasAttachments?: boolean | null;
    /**
     * Boolean value indicating whether layer has M values.
     */
    hasM?: boolean | null;
    /**
     * Boolean value indicating whether data changes. True if it does not.
     */
    hasStaticData?: boolean | null;
    /**
     * Boolean value indicating whether layer has Z values.
     */
    hasZ?: boolean | null;
    /**
     * String value indicating the HTML popup type. Possible values are listed
     * in the htmlPopupType table below.
     */
    htmlPopupType?: "esriServerHTMLPopupTypeAsHTMLText" | "esriServerHTMLPopupTypeAsURL" | "esriServerHTMLPopupTypeNone" | null;
    /**
     * The identifier assigned to the layer.
     */
    id?: string | number | null;
    /**
     * Boolean value indicating whether the data is versioned.
     */
    isDataVersioned?: boolean | null;
    /**
     * Numeric value indicating the maximum number of records that will be
     * returned at once for a query.
     */
    maxRecordCount?: number | null;
    /**
     * A number representing the maximum scale at which the layer definition
     * will be applied. The number is the scale's denominator; thus, a value of
     * 2400 represents a scale of 1/2,400. A value of 0 indicates that the layer
     * definition will be applied no matter how far you zoom in.
     */
    maxScale?: number | null;
    /**
     * A number representing the minimum scale at which the layer definition
     * will be applied. The number is the scale's denominator; thus, a value of
     * 2400 represents a scale of 1/2,400.
     */
    minScale?: number | null;
    /**
     * A string containing a unique name for the layer that could be displayed
     * in a legend.
     */
    name?: string | null;
    /**
     * Indicates the name of the object ID field in the dataset.
     */
    objectIdField?: string | null;
    /**
     * Determines the display order of features on the map.
     */
    orderBy?: OrderByClauseJson[] | null;
    /**
     * Dictates whether a client can support having an end user modify symbols
     * on individual features.
     */
    overrideSymbols?: boolean | null;
    /**
     * Indicates range information.
     */
    rangeInfos?: RangeInfoJson[] | null;
    /**
     * An object indicating the layerDefinition's layer source. See
     * {@link https://developers.arcgis.com/web-map-specification/objects/source/}
     * {@link https://developers.arcgis.com/web-scene-specification/objects/source/}.
     */
    source?: DynamicDataLayerJson | DynamicMapLayerJson | null;
    /**
     * An object containing the WKID or WKT identifying the spatial reference of
     * the layer's geometry.
     */
    spatialReference?: SpatialReferenceJson | null;
    /**
     * String value indicating the output formats that are supported in a query.
     */
    supportedQueryFormats?: string | null;
    /**
     * Boolean value indicating whether the layer supports orderByFields in a
     * query operation.
     */
    supportsAdvancedQueries?: boolean | null;
    /**
     * Boolean value indicating whether the layer supports uploading attachments
     * with the Uploads operation. This can be then used in the Add Attachment
     * and Update Attachment operations.
     */
    supportsAttachmentsByUploadId?: boolean | null;
    /**
     * Boolean value indicating whether the layer supports the Calculate REST
     * operation when updating features.
     */
    supportsCalculate?: boolean | null;
    /**
     * Boolean value indicating whether the layer supports rolling back edits
     * made on a feature layer if some of the edits fail.
     */
    supportsRollbackOnFailureParameter?: boolean | null;
    /**
     * Boolean value indicating whether feature layer query operations support
     * statistical functions.
     */
    supportsStatistics?: boolean | null;
    /**
     * Boolean value indicating whether the validateSQL operation is supported
     * across a feature service layer.
     */
    supportsValidateSql?: boolean | null;
    /**
     * An array of template objects describing features that can be created in
     * this layer. Templates are used with map notes, other feature collections,
     * and editable web-based CSV layers. They are not used with ArcGIS feature
     * services, which already have feature templates defined in the service.
     *
     * Templates are defined as a property of the layer definition when there
     * are no types defined; otherwise, templates are defined as properties of
     * the types.
     */
    templates?: TemplateJson[] | null;
    /**
     * The time info metadata of the layer. May be set for feature layers inside
     * a feature collection item.
     */
    timeInfo?: LayerTimeInfoJson | null;
    /**
     * Indicates whether the layerDefinition applies to a "Feature Layer" or a
     * "Table".
     */
    type?: string | null;
    /**
     * The name of the field holding the type ID for the features, if types
     * exist for the dataset. Each available type has an ID, and each feature's
     * typeIdField can be read to determine the type for each feature.
     */
    typeIdField?: string | null;
    /**
     * An array of Type objects available for the dataset. This is used when the
     * typeIdField is populated.
     *
     * Types contain information about the combinations of attributes that are
     * allowed for features in the dataset. Each feature in the dataset can have
     * a type, indicated in its typeIdField.
     */
    types?: TypeJson[] | null;
    /**
     * String value indicating the attribute field that is used to control the
     * visibility of a feature. If applicable, when rendering a feature the
     * client should use this field to control visibility. The field's values
     * are 0 = do not display, 1 = display.
     */
    visibilityField?: string | null;
}
/**
 * Defines overridden properties on a field for a specific view of the data. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/fieldOverride/}.
 */
export interface FieldOverrideJson {
    /**
     * A string containing the overridden field alias.
     */
    alias?: string | null;
    /**
     * A Boolean determining whether users can edit this field.
     */
    editable?: boolean | null;
    /**
     * A string containing the field name as defined by the service.
     */
    name?: string | null;
}
/**
 * Time info if the layer/table supports querying and exporting maps based on
 * time. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/layerTimeInfo/}.
 */
export interface LayerTimeInfoJson {
    /**
     * The name of the attribute field that contains the end time information.
     */
    endTimeField?: string | null;
    /**
     * The default time-related export options for this layer.
     */
    exportOptions?: TimeInfoExportOptionsJson | null;
    /**
     * Indicates whether service has live data.
     */
    hasLiveData?: boolean | null;
    /**
     * The name of the attribute field that contains the start time information.
     */
    startTimeField?: string | null;
    /**
     * The time extent for all the data in the layer.
     */
    timeExtent?: [number, number] | null;
    /**
     * Time interval of the data in the layer. Typically used for the TimeSlider
     * when animating the layer.
     */
    timeInterval?: number | null;
    /**
     * Temporal unit in which the time interval is measured.
     */
    timeIntervalUnits?: TemporalUnitJsonType | null;
    /**
     * Defines information about daylight savings time and the time zone in
     * which data was collected. See
     * {@link https://developers.arcgis.com/web-map-specification/objects/timeReference/}.
     */
    timeReference?: {
        /**
         * Indicates whether the time reference takes into account daylight
         * savings time.
         */
        respectsDaylightSaving: boolean;
        /**
         * The time zone in which the data was captured.
         */
        timeZone?: string | null;
    } | null;
    /**
     * The field that contains the trackId.
     */
    trackIdField: string;
}
/**
 * The default time-related export options for a layer. See
 * https://developers.arcgis.com/web-map-specification/objects/timeInfoExportOptions/.
 */
export interface TimeInfoExportOptionsJson {
    /**
     * If true, draw all the features from the beginning of time for that data.
     */
    timeDataCumulative?: boolean | null;
    /**
     * Time offset value for this layer so that it can be overlaid on the top of
     * a previous or future time period.
     */
    timeOffset?: number | null;
    /**
     * Temporal unit in which the time offset is measured.
     */
    timeOffsetUnits?: TemporalUnitJsonType | null;
    /**
     * If true, use the time extent specified by the time parameter.
     */
    useTime?: boolean | null;
}
/**
 * Temporal units in which a time value can be measured.
 */
export type TemporalUnitJsonType = "esriTimeUnitsCenturies" | "esriTimeUnitsDays" | "esriTimeUnitsDecades" | "esriTimeUnitsHours" | "esriTimeUnitsMilliseconds" | "esriTimeUnitsMinutes" | "esriTimeUnitsMonths" | "esriTimeUnitsSeconds" | "esriTimeUnitsUnknown" | "esriTimeUnitsWeeks" | "esriTimeUnitsYears";
/**
 * A clause in a layer definition's `orderBy` property.
 */
export interface OrderByClauseJson {
    /**
     * The number or date field whose values will be used to sort features.
     */
    field?: string | null;
    /**
     * The [Arcade
     * expression](https://developers.arcgis.com/javascript/latest/arcade/)
     * whose return value will be used to sort features. (Currently undocumented
     * by ESRI's Webmap Spec).
     *
     * [Read
     * more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-OrderedLayer.html#orderBy).
     */
    valueExpression?: string | null;
    /**
     * The sort order.
     */
    order?: "asc" | "desc" | null;
}
/**
 * Defines how the graphic is placed with respect to the terrain surface.
 */
export type ElevationModeJsonType = 
/**
 * Graphics are draped on the terrain surface. This is the default value for
 * features with Polyline or Polygon geometries and features with Point
 * geometries rendered with ObjectSymbol3DLayers.
 */
"onTheGround"
/**
 * The graphic is placed at a specified height/elevation above the ground.
 * This elevation is determined by adding the value of offset to the
 * elevation of the terrain surface. This is the default value for Point
 * geometries rendered with IconSymbol3DLayers.
 */
 | "relativeToGround"
/**
 * Graphics are placed at an absolute height relative to the datum. The
 * absolute height is determined by each feature's z value. This mode works
 * like relative-to-ground with the difference that terrain elevation is
 * discarded.
 */
 | "relativeToScene"
/**
 * Graphics are placed at an absolute height above sea level. This height is
 * determined by the value of offset and doesn't take the elevation of the
 * terrain into account. This is the default value of features with any
 * geometry type where hasZ is true.
 */
 | "absoluteHeight";
/**
 * Specifies how graphics are placed on the vertical axis (z). This property may
 * only be used in a SceneView. See
 * {@link https://developers.arcgis.com/web-scene-specification/objects/elevationInfo/}.
 */
export interface ElevationInfoJson {
    /**
     * Deprecated with 1.8, use featureExpressionInfo instead. Ignores geometry
     * z-values.
     */
    featureExpression?: unknown | null;
    /**
     * Sets the offset distance, type and other parameters.
     */
    featureExpressionInfo?: FeatureExpressionInfoJson | null;
    /**
     * Determines how the service elevation values are combined with the basemap
     * elevation.
     */
    mode?: ElevationModeJsonType | null;
    /**
     * Offset is always added to the result of the above logic except for
     * `"onTheGround"` where offset is ignored.
     */
    offset?: number | null;
    /**
     * A string value indicating the unit for the values in elevationInfo.
     * Applies to both offset and featureExpressionInfo. Defaults to meter if
     * not set. Supported units: "foot", "kilometer", "meter", "mile",
     * "us-foot", "yard".
     */
    unit?: string | null;
}
/**
 * An object that defines an expression for per-feature elevation. If not set,
 * geometry.z values are used for elevation. Unit is applied to the resulting
 * expression value.
 */
export interface FeatureExpressionInfoJson {
    /**
     * An Arcade expression evaluating to a number. Value of "0" does not use
     * geometry.z values.
     */
    expression?: string | null;
    /**
     * Title of the expression.
     */
    title?: string | null;
}
/**
 * Range Information.
 *
 * See
 * {@link https://developers.arcgis.com/web-scene-specification/objects/rangeInfo/}.
 */
export interface RangeInfoJson {
    /**
     * Contains the min and max values within which the features are visible.
     */
    currentRangeExtent?: [number, number] | null;
    /**
     * Field name to used for the range.
     */
    field?: string | null;
    /**
     * Contains the min and max values of all the features for this rangeInfo.
     */
    fullRangeExtent?: [number, number] | null;
    /**
     * A unique name that can be referenced by webMap.activeRanges.
     */
    name?: string | null;
    /**
     * Type of range object. Value of this property must be rangeInfo.
     */
    type: "rangeInfo";
}
/**
 * A dynamic data layer derived from a registered workspace. More information on
 * this can be found in the ArcGIS REST API help. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/dynamicDataLayer_source/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/dynamicDataLayer_source/}.
 */
export interface DynamicDataLayerJson {
    /**
     * This object applies if the layerDefinition source is set to
     * DynamicDataLayer. See
     * {@link https://developers.arcgis.com/web-map-specification/objects/dataSource/}
     * {@link https://developers.arcgis.com/web-scene-specification/objects/dataSource/}.
     */
    dataSource?: DataSourceJson | null;
    /**
     * An array of objects specifying information about an attribute field.
     */
    fields?: FieldJson[] | null;
    /**
     * A string value indicating the type. This value is dataLayer.
     */
    type: "dataLayer";
}
/**
 * A dynamic map layer refers to a layer in the current map service. More
 * information on this can be found in the ArcGIS REST API help. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/dynamicMapLayer_source/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/dynamicMapLayer_source/}.
 */
export interface DynamicMapLayerJson {
    /**
     * If applicable, specify this to use an alternate geodatabase version.
     */
    gdbVersion?: string | null;
    /**
     * The current map layer's ID.
     */
    mapLayerId?: number | null;
    /**
     * A string value indicating the type. This value is mapLayer.
     */
    type: "mapLayer";
}
/**
 * This object applies if the layerDefinition source is set to DynamicDataLayer.
 * See
 * {@link https://developers.arcgis.com/web-map-specification/objects/dataSource/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/dataSource/}.
 */
export type DataSourceJson = JoinTableDataSourceJson | QueryTableDataSourceJson | RasterDataSourceJson | TableDataSourceJson;
/**
 * Base class for DataSource. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/dataSource/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/dataSource/}.
 */
export interface DataSourceJsonBase {
    /**
     * Type of the DataSource.
     */
    type: "joinTable" | "queryTable" | "raster" | "table";
    /**
     * The unique string value used to identify the data-source's workspace.
     */
    workspaceId?: string | null;
}
/**
 * Join Table data source is the result of a join operation. Nested joins are
 * supported. To use nested joins, set either leftTableSource or
 * rightTableSource to be a joinTable. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/joinTableDataSource/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/joinTableDataSource/}.
 */
export interface JoinTableDataSourceJson extends DataSourceJsonBase {
    /**
     * The type of join (left outer or left inner).
     */
    joinType?: JoinJsonType | null;
    /**
     * Field name from the left table.
     */
    leftTableKey?: string | null;
    /**
     * The left source. If the leftTableSource is a table, the resulting
     * joinTable is a table. If the leftTableSource is a layer, the resulting
     * joinTable is a layer.
     */
    leftTableSource?: DynamicDataLayerJson | DynamicMapLayerJson | null;
    /**
     * Field name from the right table.
     */
    rightTableKey?: string | null;
    /**
     * The right table source.
     */
    rightTableSource?: DynamicDataLayerJson | DynamicMapLayerJson | null;
    /**
     * @inheritDoc
     */
    type: "joinTable";
}
/**
 * The type of the JoinTableDataSource.
 */
export type JoinJsonType = "esriLeftOuterJoin" | "esriLeftInnerJoin";
/**
 * Query table data source is a layer/table that is defined by a SQL query. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/queryTableDataSource/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/queryTableDataSource/}.
 */
export interface QueryTableDataSourceJson extends DataSourceJsonBase {
    /**
     * The geometry type. When querying a table that does not have a geometry
     * column, do not include geometryType.
     */
    geometryType?: "esriGeometryPoint" | "esriGeometryMultipoint" | "esriGeometryPolyline" | "esriGeometryPolygon" | null;
    /**
     * Comma separated list of identifier fields. There are only certain field
     * types that can be used as a unique identifier. These field types include
     * integer, string, GUID, and date. If a single integer field is specified,
     * map server uses the values in that field directly to uniquely identify
     * all features and rows returned from a queryTable. However, if a single
     * string field or a group of fields is used as the unique identifier, map
     * server maps those unique values to an integer.
     */
    oidFields?: string | null;
    /**
     * The SQL query.
     */
    query?: string | null;
    /**
     * The spatial reference of the geometry column. When querying a table that
     * does not have a geometry column, do not include spatialReference.
     */
    spatialReference?: SpatialReferenceJson | null;
    /**
     * @inheritDoc
     */
    type: "queryTable";
}
/**
 * Raster data source is a file-based raster that resides in a registered raster
 * workspace. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/rasterDataSource/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/rasterDataSource/}.
 */
export interface RasterDataSourceJson extends DataSourceJsonBase {
    /**
     * The fully-qualified string value used to specify where the dataSource is
     * derived.
     */
    dataSourceName?: string | null;
    /**
     * @inheritDoc
     */
    type: "raster";
}
/**
 * Table data source is a table, feature class, or raster that resides in a
 * registered workspace (either a folder or geodatabase). In the case of a
 * geodatabase, if versioned, use version to switch to an alternate geodatabase
 * version. If version is empty or missing, the registered geodatabase version
 * will be used. See
 * {@link https://developers.arcgis.com/web-map-specification/objects/tableDataSource/}
 * {@link https://developers.arcgis.com/web-scene-specification/objects/tableDataSource/}.
 */
export interface TableDataSourceJson extends DataSourceJsonBase {
    /**
     * The fully-qualified string value used to specify where the dataSource is
     * derived.
     */
    dataSourceName?: string | null;
    /**
     * If applicable, the value indicating the version of the geodatabase.
     */
    gdbVersion?: string | null;
    /**
     * @inheritDoc
     */
    type: "table";
}
/**
 * Feature reductions declutter the screen by hiding features that would
 * otherwise intersect with other features on screen.
 */
export type FeatureReductionJson = FeatureReductionClusterJson | FeatureReductionSelectionJson;
/**
 * Feature reduction of type cluster declutters the screen by hiding features
 * that would otherwise intersect with other features on screen. The default
 * clusterRadius for the JavaScript API is 60.
 */
export interface FeatureReductionClusterJson {
    /**
     * The type of feature reduction.
     */
    type: "cluster";
    /**
     * Size of the largest cluster, in screen units (points).
     */
    clusterMaxSize?: number | null;
    /**
     * Size of the smallest cluster, in screen units (points).
     */
    clusterMinSize?: number | null;
    /**
     * Strength of clustering, in screen units (points).
     */
    clusterRadius?: number | null;
    /**
     * Indicates whether to ignore popups defined by the service item.
     */
    disablePopup?: boolean | null;
    /**
     * Contains labeling information for the cluster.
     */
    drawingInfo?: DrawingInfoJson | null;
    /**
     * Defines the look and feel of popup windows when a user clicks or queries
     * a feature.
     */
    popupInfo?: PopupInfoJson | null;
    /**
     * Defines whether labels should be shown in the clusters.
     */
    showLabels?: boolean | null;
}
/**
 * Feature reduction of type selection declutters the screen by hiding features
 * that would otherwise intersect with other features on screen. The default
 * behavior of this feature reduction type is to select features by depth order,
 * i.e. hide all features that would otherwise be overlapped by at least one
 * other feature which is closer to the viewer.
 */
export interface FeatureReductionSelectionJson {
    /**
     * The type of feature reduction.
     */
    type: "selection";
}
