import type Graphic from "../../Graphic.js";
import type Accessor from "../../core/Accessor.js";
import type Collection from "../../core/Collection.js";
import type AttachmentsOrderByInfo from "../../popup/support/AttachmentsOrderByInfo.js";
import type AttachmentInfo from "../../rest/query/support/AttachmentInfo.js";
import type { AttachmentsCapabilities } from "./types.js";
import type { GraphicProperties } from "../../Graphic.js";
import type { AttachmentsOrderByInfoProperties } from "../../popup/support/AttachmentsOrderByInfo.js";

export interface AttachmentsViewModelProperties extends Partial<Pick<AttachmentsViewModel, "activeAttachmentInfo" | "attachmentKeywords" | "attachmentTypes" | "capabilities" | "mode">> {
  /** The graphic for the attachments. */
  graphic?: GraphicProperties | null;
  /** An array of [AttachmentsOrderByInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-support-AttachmentsOrderByInfo.html) indicating the display order for the attachments, and whether they should be sorted in ascending `asc` or descending `desc` order. */
  orderByFields?: AttachmentsOrderByInfoProperties[] | null;
}

export type AttachmentsViewModelState = "disabled" | "loading" | "ready";

export type AttachmentsViewModelMode = "add" | "edit" | "view";

/**
 * Provides the logic for the [Attachments](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attachments.html) widget.
 *
 * @since 4.15
 * @see [Attachments](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attachments.html)
 * @see [Editor](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html)
 * @see [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html)
 * @see [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html)
 * @see [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html)
 * @see [AttachmentInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query-support-AttachmentInfo.html)
 * @see [AttachmentsContent](https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-AttachmentsContent.html)
 * @see [ArcGIS REST API - Attachment Infos (Feature Service)](https://developers.arcgis.com/rest/services-reference/attachment-infos-feature-service-.htm)
 * @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
 */
export default class AttachmentsViewModel extends Accessor {
  constructor(properties?: AttachmentsViewModelProperties);
  /**
   * The current [AttachmentInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query-support-AttachmentInfo.html) being edited.
   *
   * @see [ArcGIS REST API - Attachment Infos (Feature Service)](https://developers.arcgis.com/rest/services-reference/attachment-infos-feature-service-.htm)
   */
  accessor activeAttachmentInfo: AttachmentInfo | null | undefined;
  /**
   * A collection of [AttachmentInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query-support-AttachmentInfo.html) defined on a feature.
   *
   * @see [ArcGIS REST API - Attachment Infos (Feature Service)](https://developers.arcgis.com/rest/services-reference/attachment-infos-feature-service-.htm)
   */
  get attachmentInfos(): Collection<AttachmentInfo>;
  /** An array of strings used to identify attachment(s). When attachments are displayed, this property is used to query attachments using an exact match on the keywords provided. */
  accessor attachmentKeywords: string[] | null | undefined;
  /** An array of strings representing MIME types. When attachments are displayed, this property is used to query attachments based on MIME type. Valid values: application, audio, image, model, text, and video. */
  accessor attachmentTypes: ("application" | "audio" | "image" | "model" | "text" | "video")[] | null | undefined;
  /**
   * Configures the attachment editing functionality that can be performed by the user.
   *
   * @since 4.27
   */
  accessor capabilities: AttachmentsCapabilities;
  /** The graphic for the attachments. */
  get graphic(): Graphic | null | undefined;
  set graphic(value: GraphicProperties | null | undefined);
  /**
   * The current mode performed by the user.
   *
   * @default "view"
   */
  accessor mode: AttachmentsViewModelMode;
  /** An array of [AttachmentsOrderByInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-support-AttachmentsOrderByInfo.html) indicating the display order for the attachments, and whether they should be sorted in ascending `asc` or descending `desc` order. */
  get orderByFields(): AttachmentsOrderByInfo[] | null | undefined;
  set orderByFields(value: AttachmentsOrderByInfoProperties[] | null | undefined);
  /**
   * The current state of the widget.
   *
   * @default "ready"
   */
  get state(): AttachmentsViewModelState;
  /**
   * Defines whether or not the feature supports resizing attachments. This depends on whether the
   * feature layer's [capabilities.attachment.supportsResize](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) is set to `true`.
   */
  get supportsResizeAttachments(): boolean;
  /**
   * Queries for the attachments on a feature. Attachments for multiple features can be queried if the layer's
   * [capabilities.operations.supportsQueryAttachments](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) is `true`.
   *
   * @returns When resolved, returns the [AttachmentInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query-support-AttachmentInfo.html)
   * of the queried feature.
   * @see [FeatureLayer#queryAttachments()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryAttachments)
   */
  getAttachments(): Promise<AttachmentInfo[]>;
}