import type Collection from "../core/Collection.js";
import type VersionManagementService from "./VersionManagementService.js";
import type { JSONSupportMixin } from "../core/JSONSupport.js";
import type { Loadable, LoadableMixinProperties } from "../core/Loadable.js";
import type { AbortOptions } from "../core/promiseUtils.js";
import type { AlterVersionParametersProperties } from "../rest/versionManagement/gdbVersion/support/AlterVersionParameters.js";
import type { VersionInfoExtended as VersionInfoExtendedJSON, VersionIdentifier, VersionInfo, ServiceResult } from "./support/jsonTypes.js";
import type { VersionAdapter } from "./versionAdapters/types.js";

export interface VersioningStateProperties extends LoadableMixinProperties, Partial<Pick<VersioningState, "currentVersion" | "currentVersionInfo" | "featureServiceUrl" | "state" | "url" | "usePersistentReadSessions" | "versionableItems" | "versionInfos" | "versionManagementService">> {}

/**
 * This class provides functionality for managing versions in a versioned geodatabase.
 * It includes methods for starting and stopping editing, changing versions, undoing and redoing edits, and retrieving version information.
 *
 * @since 4.30
 * @see [Version Management Service](https://developers.arcgis.com/rest/services-reference/enterprise/version-management-service.htm)
 * @see [Version Management Component](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-version-management)
 * @example
 * const [utils, WebMap] = await $arcgis.import([
 *   "@arcgis/core/versionManagement/versionAdapters/utils.js",
 *   "@arcgis/core/WebMap.js"
 * ]);
 * const webmap = new WebMap({
 *   portalItem: { // autocasts as new PortalItem()
 *     id: "e691172598f04ea8881cd2a4adaa45ba"
 *   }
 * });
 * const versioningStates = await utils.createVersioningStates(webmap, false);
 */
export default class VersioningState extends VersioningStateSuperclass {
  constructor(properties?: VersioningStateProperties);
  /** The current version. */
  accessor currentVersion: VersionIdentifier | Date;
  /** Contains information on the current version. */
  accessor currentVersionInfo: VersionInfo | null | undefined;
  /** Contains the default version's name and guid. */
  get defaultVersionIdentifier(): VersionIdentifier;
  /** The absolute URL of the REST endpoint for the feature service housing the version management service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online. */
  accessor featureServiceUrl: string;
  /** If true, current version is the default version. */
  get isDefault(): boolean;
  /**
   * Indicates whether the instance has loaded. When `true`,
   * the properties of the object can be accessed. A WebMap is considered loaded
   * when its [WebDocument2D#layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebDocument2D.html#layers) and [WebDocument2D#basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebDocument2D.html#basemap) are created, but not
   * yet loaded.
   *
   * @default false
   */
  get loaded(): boolean;
  /**
   * The state of the current version.
   *
   * @default "lock-none"
   */
  accessor state: "lock-none" | "lock-read" | "lock-write";
  /** The absolute URL of the REST endpoint for the version management service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online. */
  accessor url: string;
  /**
   * If the set to `true`, the current version will have a read lock. Additionally, when switching versions, the new current version will also have a read lock.
   *
   * @default false
   */
  accessor usePersistentReadSessions: boolean;
  /** Contains a collection of all versionable in the versioning state class. */
  accessor versionableItems: Collection<VersionAdapter>;
  /** Contains list of all available versions. */
  accessor versionInfos: VersionInfo[];
  /** Contains metadata about the version management service. */
  accessor versionManagementService: VersionManagementService;
  /**
   * The alter operation allows you to change the geodatabase version's name, description, owner, and access permissions.
   *
   * > [!CAUTION]
   * >
   * > **License**
   * >
   * > This method requires the feature service and version management service to be published with [ArcGIS Enterprise](https://enterprise.arcgis.com/en/get-started/latest/windows/what-is-arcgis-enterprise-.htm) version 11.2 or higher.
   * > Organization members must be assigned a license for the [ArcGIS Advanced Editing user type extension](https://enterprise.arcgis.com/en/portal/latest/administer/windows/license-user-type-extensions.htm#ESRI_SECTION1_B75DA80066744473AD5DD1312734654A) to use this method.
   *
   * @param versionIdentifier - Identifier for a version.
   * @param props - Contains properties that will be altered.
   * @returns Returns true if version was altered successfully.
   * @since 4.30
   * @example
   * const result = await versioningState.alterVersion(
   *   { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" },
   *   {
   *     versionName: "versionName",
   *     ownerName: "newOwner",
   *     description: "newDescription",
   *     access: "public"
   *   }
   *  );
   */
  alterVersion(versionIdentifier: VersionIdentifier, props: AlterVersionParametersProperties): Promise<boolean>;
  /**
   * Method used to change a layer's version/moment or network's version/moment. Method allows changing version from named version to named version,
   * or from default version to a moment and vice versa.
   *
   * @param toVersion - Incoming Version or Date.
   * @returns Returns a map of VersionAdapter and ServiceResult.
   * @since 4.30
   * @example
   * await versioningState.changeVersion(
   *   { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}
   * );
   */
  changeVersion(toVersion: VersionIdentifier | Date): Promise<Map<VersionAdapter, ServiceResult>>;
  /**
   * Deletes a version given the following parameters.
   *
   * > [!CAUTION]
   * >
   * > **License**
   * >
   * > This method requires the feature service and version management service to be published with [ArcGIS Enterprise](https://enterprise.arcgis.com/en/get-started/latest/windows/what-is-arcgis-enterprise-.htm) version 11.2 or higher.
   * > Organization members must be assigned a license for the [ArcGIS Advanced Editing user type extension](https://enterprise.arcgis.com/en/portal/latest/administer/windows/license-user-type-extensions.htm#ESRI_SECTION1_B75DA80066744473AD5DD1312734654A) to use this method.
   *
   * @param versionIdentifier - Identifier for a version.
   * @returns Specifies if the selected version was deleted.
   * @since 4.30
   * @example
   * versioningState.deleteVersion({
   *   name: "versionName",
   *   guid: "{422D1B63-D795-4478-A4B1-AD6109377075}"
   * });
   */
  deleteVersion(versionIdentifier: VersionIdentifier): Promise<boolean>;
  /**
   * Method used to get extended information about a version.
   *
   * @returns Contains extended info about given version.
   * @since 4.30
   */
  getVersionInfoExtended(): Promise<VersionInfoExtendedJSON | null | undefined>;
  /**
   * Returns all versions accessible to the currently logged-in user.
   *
   * @param refresh - If refresh is true, a new REST call will be made to the server to get the available versions.
   * @returns Contains extended info about given version.
   * @since 4.30
   */
  getVersionInfos(refresh?: boolean): Promise<VersionInfo[]>;
  /**
   * Triggers the loading of the version management service instance.
   *
   * Fully loads the Version Management Service definition.
   *
   * @param options - Additional options.
   * @returns Resolves when the Feature Service is [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-versionManagement-VersioningState.html#loaded).
   */
  load(options?: AbortOptions | null | undefined): Promise<this>;
  /**
   * This method redos the last edit made while in an edit session.
   *
   * @returns Specifies if redo was successful.
   * @since 4.30
   */
  redo(): Promise<ServiceResult>;
  /**
   * Using the specified session ID an exclusive lock is obtained for the session on the version. The exclusive lock can only be obtained if no other shared or exclusive locks are present and the session currently holds a shared lock.
   * The exclusive lock ensures read and write isolation for the session holding the lock.
   * The exclusive lock is downgraded to a shared lock by using the stopEditing operation.
   *
   * @returns Specifies if start editing was successful.
   * @since 4.30
   * @example await versioningState.startEditing();
   */
  startEditing(): Promise<ServiceResult>;
  /**
   * Using the specified session id, the exclusive lock for the version is downgraded to a shared lock.
   * The saveEdits parameter specifies if the edits for the session should be saved (true) or discarded (false).
   *
   * @param saveEdits - If set to true edits will be saved, if false edits will not be saved.
   * @returns Specifies if stop editing was successful.
   * @since 4.30
   * @example await versioningState.stopEditing(true);
   */
  stopEditing(saveEdits: boolean): Promise<ServiceResult>;
  /**
   * This method undos the last edit made while in an edit session.
   *
   * @returns Specifies if undo was successful.
   * @since 4.30
   */
  undo(): Promise<ServiceResult>;
}
declare const VersioningStateSuperclass: typeof Loadable & typeof JSONSupportMixin