import type Portal from "./Portal.js";
import type PortalItem from "./PortalItem.js";
import type PortalQueryResult from "./PortalQueryResult.js";
import type { JSONSupport, JSONSupportMixinProperties } from "../core/JSONSupport.js";
import type { AbortOptions } from "../core/promiseUtils.js";
import type { PortalQueryParamsProperties } from "./PortalQueryParams.js";
import type { Members } from "./types.js";

export interface PortalGroupProperties extends JSONSupportMixinProperties, Partial<Pick<PortalGroup, "access" | "description" | "id" | "isInvitationOnly" | "owner" | "portal" | "snippet" | "sourceJSON" | "tags" | "title">> {
  /** The date the group was created. */
  created?: (Date | number | string) | null;
  /** The date the group was last modified. */
  modified?: (Date | number | string) | null;
}

/**
 * The group resource represents a group within the [Portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html). A group resource represents
 * a group (e.g., "San Bernardino Fires"). The visibility of the group to other users
 * is determined by the [access](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#access) property. If the group is private, no one
 * except the administrators and the members of the group will be able to see it. If the
 * group is shared with an organization, than all members of the organization are able
 * to find the group. For additional information, see [the ArcGIS REST API documentation for Group](https://developers.arcgis.com/rest/users-groups-and-items/group.htm).
 *
 * @since 4.0
 * @see [ArcGIS Organization portals](https://developers.arcgis.com/javascript/latest/arcgis-organization-portals/)
 * @see [Portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html)
 */
export default class PortalGroup extends JSONSupport {
  constructor(properties?: PortalGroupProperties);
  /** The access privileges on the group which determines who can see and access the group. */
  accessor access: "private" | "org" | "public" | null | undefined;
  /** The date the group was created. */
  get created(): Date | null | undefined;
  set created(value: (Date | number | string) | null | undefined);
  /** A detailed description of the group. */
  accessor description: string | null | undefined;
  /** The unique id for the group. */
  accessor id: string | null | undefined;
  /**
   * If set to `true`, then users will not be able to apply to join the group.
   *
   * @default false
   */
  accessor isInvitationOnly: boolean;
  /** The date the group was last modified. */
  get modified(): Date | null | undefined;
  set modified(value: (Date | number | string) | null | undefined);
  /** The username of the group's owner. */
  accessor owner: string | null | undefined;
  /** The portal associated with the group. */
  accessor portal: Portal | null | undefined;
  /** A short summary that describes the group. */
  accessor snippet: string | null | undefined;
  /**
   * The JSON used to create the property values when the `PortalGroup` is created.
   * Although most commonly used properties are exposed on the `PortalGroup` class directly,
   * this provides access to all information returned for the portal group. This property is
   * useful if working in an application built using an older version of the API which
   * requires access to a portal's group properties from a more recent version.
   *
   * @since 4.28
   * @see [ArcGIS REST API - Group](https://developers.arcgis.com/rest/users-groups-and-items/group.htm)
   */
  accessor sourceJSON: any;
  /** User defined tags that describe the group. */
  accessor tags: string[] | null | undefined;
  /**
   * The URL to the thumbnail used for the group.
   *
   * @since 4.4
   * @see [getThumbnailUrl()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#getThumbnailUrl)
   */
  get thumbnailUrl(): string | null | undefined;
  /**
   * The title of the group. This is the name that is displayed to users. It is also
   * used to refer to the group. Every group must have a title and it must be unique.
   */
  accessor title: string | null | undefined;
  /** The URL to the group. */
  get url(): string | null | undefined;
  /**
   * If present, fetches the group's category schema.
   *
   * @param options - An object with the following properties.
   * @returns Resolves to an array of objects containing the following properties:
   *
   * Property | Type | Description
   * ---------|--------|-------------
   * title | string | The title of the category schema.
   * categories | object[] | An array of objects containing a title and an optional array of subcategories.
   * @since 4.8
   * @example
   * // Fetch featured group members
   * portal.fetchFeaturedGroups().then(function(groups){
   *   groups.forEach(function(group){
   *     // Fetch group category schema
   *     group.fetchCategorySchema().then(function(schemas){
   *       schemas.forEach(function(schema){
   *         console.log("schema: ", schema);
   *       })
   *     });
   *   });
   * });
   */
  fetchCategorySchema(options?: AbortOptions | null | undefined): Promise<object[]>;
  /**
   * Fetches the current members of the group. This method is only available to members or
   * administrators of the group. View the ArcGIS REST API documentation
   * for the [Group Users](https://developers.arcgis.com/rest/users-groups-and-items/group-users.htm)
   * for more details.
   *
   * @param options - An object with the following properties.
   * @returns Resolves to an object with the members of the group.
   * @example
   * // Fetch featured group members
   * portal.fetchFeaturedGroups().then(function(groups){
   *    groups.forEach(function(group){
   *      group.fetchMembers().then(function(members){
   *        console.log("member", members);
   *      });
   *    });
   * });
   */
  fetchMembers(options?: AbortOptions | null | undefined): Promise<Members>;
  /**
   * Get the URL to the thumbnail image for the group.
   *
   * Available width sizes: 150, 300 and 600.
   *
   * @param width - The desired image width.
   * @returns The URL to the thumbnail image.
   * @since 4.4
   */
  getThumbnailUrl(width?: number): string | null | undefined;
  /**
   * Executes a query against the group to return an array of [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html) objects
   * that match the input query.
   *
   * @param queryParams - The input query parameters
   *  defined in [PortalQueryParams](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html).
   * @param options - An object with the following properties.
   * @returns When resolved, resolves to an instance of [PortalQueryResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html)
   * which contains a `results` array of [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html) objects representing
   * all the items that match the input query.
   */
  queryItems(queryParams?: PortalQueryParamsProperties, options?: AbortOptions | null | undefined): Promise<PortalQueryResult<PortalItem>>;
}