/**
 * @public
 * A disclosure identifying if the app generated this asset using AI.
 *
 * @remarks
 * Helps users make informed decisions about the content they interact with.
 *
 * AI is generally defined as any machine system that, given an objective, infers how to generate an output from an input.
 * Some examples include "generative AI", "large language models", and "machine learning".
 *
 * **App Generated**
 *
 * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
 * the app makes a request to a third-party service to do so.
 *
 * A significantly altered asset means the AI changes key information or details, such as
 * removing or replacing key components in the original content, which can include applying style transfer, or changing facial expressions.
 *
 * Label this asset as 'app_generated' under these conditions:
 *
 * The following is true:
 *
 * - The app generates the asset in response to a user's request (including past requests), for example, the asset is not from an asset library.
 *
 * And any of these conditions are also true:
 *
 *  - The AI creates entirely new content from scratch.
 *  - The AI introduces new multimedia, details, or creative elements not originally present.
 *  - The AI removes and replaces the asset's key components.
 *  - The AI alters the asset's appearance, meaning, or context in a way that conveys a different message than the original.
 *
 * **None**
 *
 * 'none' indicates when the asset wasn't generated by the app as a part of any user's specific request, for example, a third-party
 * request, or when the asset wasn't significantly altered by AI.
 */
export declare type AiDisclosure = "app_generated" | "none";

declare type AllOrNone<T> = T | Never<T>;

/**
 * @public
 * A bounding box.
 */
export declare type Anchor = {
  /**
   * The height of the bounding box, in pixels.
   */
  height: number;
  /**
   * The width of the bounding box, in pixels.
   */
  width: number;
  /**
   * The top position of the bounding box, in pixels.
   */
  top: number;
  /**
   * The left position of the bounding box, in pixels.
   */
  left: number;
};

/**
 * @public
 * Options for uploading an asset to the user's private media library.
 */
export declare type AssetUploadOptions =
  | ImageUploadOptions
  | VideoUploadOptions
  | AudioUploadOptions;

/**
 * @public
 * The MIME type of an audio file that's supported by Canva's backend.
 */
export declare type AudioMimeType =
  | "audio/mpeg"
  | "audio/mp4"
  | "audio/x-m4a"
  | "audio/mp3"
  | "audio/ogg"
  | "audio/wav"
  | "audio/x-wav"
  | "audio/wave"
  | "audio/vnd.wave"
  | "audio/x-pn-wav"
  | "audio/webm";

/**
 * @public
 * A unique identifier that points to an audio asset in Canva's backend.
 */
export declare type AudioRef = string & {
  __audioRef: never;
};

/**
 * @public
 * Options for uploading an audio asset to the user's private media library.
 */
export declare type AudioUploadOptions = {
  /**
   * The type of asset.
   */
  type: "audio";
  /**
   * The URL of the audio file to upload to the user's private media library.
   *
   * @remarks
   * Requirements:
   *
   * - Must use HTTPS
   * - Must return a `200` status code
   * - `Content-Type` must match the file's MIME type
   * - Must be publicly accessible (i.e. not a localhost URL)
   * - Must not redirect
   * - Must not contain an IP address
   * - Maximum length: 4096 characters
   * - Must not contain whitespace
   * - Must not contain these characters: `>`, `<`, `{`, `}`, `^`, backticks
   * - Maximum file size: 50MB
   */
  url: string;
  /**
   * The MIME type of the audio file.
   */
  mimeType: AudioMimeType;
  /**
   * A human-readable title for the audio asset.
   *
   * @remarks
   * This title is displayed in the Canva editor.
   */
  title: string;
  /**
   * The initial playback duration of the audio file, in milliseconds.
   */
  durationMs: number;
  /**
   * A disclosure identifying if the app generated this audio using AI.
   *
   * @remarks
   * Helps users make informed decisions about the content they interact with.
   * See {@link AiDisclosure} for the full definition.
   *
   * **App Generated**
   *
   * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
   * the app requests a third-party service to take similar action on an audio asset using AI.
   *
   * Required for the following cases (this list is not exhaustive):
   *  | Case                                                             | Reason                               |
   *  | --                                                               | --                                   |
   *  | AI generates a music track from scratch                          | Creates new creative content         |
   *  | AI generates sounds from scratch e.g. animal sounds              | Creates new creative content         |
   *  | AI converts text to speech                                       | Creates new creative content         |
   *  | AI changes the mood or genre of audio/music                      | Significantly alters context         |
   *  | AI adjusts pitch or tempo for a creative purpose                 | Significantly alters context         |
   *
   * **None**
   *
   * 'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of a request to
   * third-party hosted content.
   *
   * Required for the following cases (this list is not exhaustive):
   *  | Case                                                    | Reason                                    |
   *  | --                                                      | --                                        |
   *  | Asset comes from an asset library                       | Didn't generate the asset itself          |
   *  | AI balances audio across speakers                       | A minor correction                        |
   */
  aiDisclosure: AiDisclosure;
};

/**
 * @public
 * A function that closes the currently open color selector.
 */
export declare type CloseColorSelectorFn = () => void;

/**
 * @public
 * A color.
 */
export declare type Color = SolidColor;

/**
 * @public
 * A selected color.
 */
export declare type ColorSelection = {
  /**
   * A solid color.
   */
  ["solid"]: SolidColor;
};

/**
 * @public
 * A color selection event.
 */
export declare type ColorSelectionEvent<Scope extends ColorSelectionScope> = {
  /**
   * The selected color.
   *
   * @remarks
   * The exact properties depends on the configured `scope`.
   */
  selection: ColorSelection[Scope];
};

/**
 * @public
 * Determines the appearance and behavior of a color selector.
 */
export declare type ColorSelectionScope = "solid";

/**
 * @public
 * Options for configuring a color selector.
 */
export declare interface ColorSelectorOpts<Scope extends ColorSelectionScope> {
  /**
   * The supported scopes, used to determine the appearance and behavior of the color selector.
   */
  scopes: Scope[];
  /**
   * The color to display as selected when the color selector is opened.
   *
   * @remarks
   * This is only required if there are multiple UI components for selecting colors.
   * For example, if the app renders multiple `Swatch` components.
   *
   * If this value is `undefined`, the most recently selected color will be displayed as selected.
   *
   * This property only affects **Document colors** and **Default colors**.
   */
  selectedColor?: ColorSelection[Scope];
  /**
   * A callback that runs when the user selects a color.
   * @param event - The color selection event.
   */
  onColorSelect(event: ColorSelectionEvent<Scope>): void;
}

/**
 * @public
 * A set of dimensions.
 */
export declare type Dimensions = {
  /**
   * A width, in pixels.
   */
  width: number;
  /**
   * A height, in pixels.
   */
  height: number;
};

/**
 * @public
 * Lists a curated selection of fonts available for use within Canva when no `options` is provided,
 * otherwise performs filtering based on the criteria specified in the `options`.
 *
 * @remarks
 * To list all available fonts, please use the `requestFontSelection` method.
 */
export declare const findFonts: (
  options?: FindFontsOptions,
) => Promise<FindFontsResponse>;

/**
 * @public
 * Options for retrieving a list of fonts.
 */
export declare type FindFontsOptions = {
  /**
   * The refs of the fonts to retrieve.
   */
  fontRefs?: readonly FontRef[];
};

/**
 * @public
 * The result of retrieving a list of fonts.
 */
export declare type FindFontsResponse = {
  /**
   * The retrieved fonts.
   */
  fonts: readonly Font[];
};

/**
 * @public
 * A font.
 */
export declare type Font = {
  /**
   * A unique identifier that points to a font asset in Canva's backend.
   */
  ref: FontRef;
  /**
   * The name of the font.
   */
  name: string;
  /**
   * The available font weights for the font.
   */
  weights: readonly FontWeight[];
  /**
   * The URL of an image that renders a preview of the font.
   */
  previewUrl?: string;
};

/**
 * @public
 * A unique identifier that points to a font asset in Canva's backend.
 */
export declare type FontRef = string & {
  __fontRef: never;
};

/**
 * @public
 * Options for configuring a font picker.
 */
export declare type FontSelectionRequest = {
  /**
   * The ref of a font to display as selected when the font picker is opened.
   */
  selectedFontRef?: FontRef;
};

/**
 * @public
 * The result of selecting a font from a font picker.
 */
export declare type FontSelectionResponse =
  | {
      /**
       * The type of result.
       */
      type: "completed";
      /**
       * The selected font.
       */
      font: Font;
    }
  | {
      /**
       * The type of result.
       */
      type: "aborted";
    };

/**
 * @public
 * The style of a font.
 */
export declare type FontStyle = "normal" | "italic";

/**
 * @public
 * The weight (thickness) of a font.
 */
export declare type FontWeight = {
  /**
   * The name of the font weight.
   */
  weight: FontWeightName;
  /**
   * The font styles available for this specific font weight.
   */
  styles: FontStyle[];
};

/**
 * @public
 * The name of a font weight.
 */
export declare type FontWeightName =
  | "normal"
  | "thin"
  | "extralight"
  | "light"
  | "medium"
  | "semibold"
  | "bold"
  | "ultrabold"
  | "heavy";

/**
 * @public
 * Returns a temporary URL to an asset already present in the current design.
 */
export declare const getTemporaryUrl: {
  (options: GetTemporaryUrlForImageOptions): Promise<TemporaryUrlForImage>;
  (options: GetTemporaryUrlForVideoOptions): Promise<TemporaryUrlForVideo>;
  (options: GetTemporaryUrlOptions): Promise<TemporaryUrl>;
};

/**
 * @public
 * Options for retrieving a temporary URL that points to an image asset in Canva's backend.
 */
export declare type GetTemporaryUrlForImageOptions = {
  /**
   * The type of asset.
   */
  type: "image";
  /**
   * A unique identifier that points to an image asset in Canva's backend.
   */
  ref: ImageRef;
};

/**
 * @public
 * Options for retrieving a temporary URL that points to a video asset in Canva's backend.
 */
export declare type GetTemporaryUrlForVideoOptions = {
  /**
   * The type of asset.
   */
  type: "video";
  /**
   * A unique identifier that points to a video asset in Canva's backend.
   */
  ref: VideoRef;
};

/**
 * @public
 * Options for retrieving a temporary URL that points to an asset in Canva's backend.
 */
export declare type GetTemporaryUrlOptions =
  | GetTemporaryUrlForImageOptions
  | GetTemporaryUrlForVideoOptions;

/**
 * @public
 * The MIME type of an image file that's supported by Canva's backend.
 */
export declare type ImageMimeType =
  | "image/jpeg"
  | "image/heic"
  | "image/png"
  | "image/svg+xml"
  | "image/webp"
  | "image/tiff";

/**
 * @public
 * A unique identifier that points to an image asset in Canva's backend.
 */
export declare type ImageRef = string & {
  __imageRef: never;
};

/**
 * @public
 * Options for uploading an image asset to the user's private media library.
 */
export declare type ImageUploadOptions = {
  /**
   * The type of asset.
   */
  type: "image";
  /**
   * The ref of the original asset from which this new asset was derived.
   *
   * @remarks
   * For example, if an app applies an effect to an image, `parentRef` should contain the ref of the original image.
   */
  parentRef?: ImageRef;
  /**
   * The URL of the image file to upload.
   * This can be an external URL or a data URL.
   *
   * @remarks
   * Requirements for external URLs:
   *
   * - Must use HTTPS
   * - Must return a `200` status code
   * - `Content-Type` must match the file's MIME type
   * - Must be publicly accessible (i.e. not a localhost URL)
   * - Must not redirect
   * - Must not contain an IP address
   * - Maximum length: 4096 characters
   * - Must not contain whitespace
   * - Must not contain these characters: `>`, `<`, `{`, `}`, `^`, backticks
   * - Maximum file size: 50MB
   *
   * Requirements for data URLs:
   *
   * - Must include `;base64` for base64-encoded data
   * - Maximum size: 10MB (10 × 1024 × 1024 characters)
   *
   * Requirements for SVGs:
   *
   * - Disallowed elements:
   *    - `a`
   *    - `altglyph`
   *    - `altglyphdef`
   *    - `altglyphitem`
   *    - `animate`
   *    - `animatemotion`
   *    - `animatetransform`
   *    - `cursor`
   *    - `discard`
   *    - `font`
   *    - `font-face`
   *    - `font-face-format`
   *    - `font-face-name`
   *    - `font-face-src`
   *    - `font-face-uri`
   *    - `foreignobject`
   *    - `glyph`
   *    - `glyphref`
   *    - `missing-glyph`
   *    - `mpath`
   *    - `script`
   *    - `set`
   *    - `switch`
   *    - `tref`
   * - Disallowed attributes:
   *    - `crossorigin`
   *    - `lang`
   *    - `media`
   *    - `onload`
   *    - `ping`
   *    - `referrerpolicy`
   *    - `rel`
   *    - `rendering-intent`
   *    - `requiredextensions`
   *    - `requiredfeatures`
   *    - `systemlanguage`
   *    - `tabindex`
   *    - `transform-origin`
   *    - `unicode`
   *    - `vector-effect`
   * - The `href` attribute of an `image` element only supports data URLs for PNG and JPEG images.
   * - The URL in the `href` attribute must not point to a location outside of the SVG.
   * - The `style` attribute must not use the `mix-blend-mode` property.
   */
  url: string;
  /**
   * The MIME type of the image file.
   */
  mimeType: ImageMimeType;
  /**
   * The URL of a thumbnail image to display while the image is queued for upload.
   * This can be an external URL or a data URL.
   *
   * @remarks
   * Requirements for external URLs:
   *
   * - Must use HTTPS
   * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
   * - Must be a PNG, JPEG, or SVG file
   * - Maximum length: 4096 characters
   *
   * Requirements for data URLs:
   *
   * - Must include `;base64` for base64-encoded data
   * - Maximum size: 10MB (10 × 1024 × 1024 characters)
   */
  thumbnailUrl: string;
  /**
   * A disclosure identifying if the app generated this image using AI
   *
   * @remarks
   * Helps users make informed decisions about the content they interact with.
   * See {@link AiDisclosure} for the full definition.
   *
   * **App Generated**
   *
   * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
   * the app requests a third-party service to take similar action on an image using AI.
   *
   *  Required for the following cases (this list is not exhaustive):
   *  | Case                                                            | Reason                               |
   *  | --                                                              | --                                   |
   *  | AI generates a new image from scratch                           | Creates new creative content         |
   *  | AI changes the style of the image e.g. makes it cartoon         | Significantly alters the style       |
   *  | AI removes an object and replaces it with new content           | Creates new creative content         |
   *  | AI changes the facial expression of a person in an image        | Can alter content's original meaning |
   *  | AI composites multiple images together                          | Significantly alters context         |
   *  | AI expands an image by generating new content to fill the edges | Creates new creative content         |
   *  | AI replaces background by generating new content                | Creates new creative content         |
   *
   * **None**
   *
   * 'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of a request
   * to third-party hosted content.
   *
   * Required for the following cases (this list is not exhaustive):
   *  | Case                                                    | Reason                                    |
   *  | --                                                      | --                                        |
   *  | Asset comes from an asset library                       | Didn't generate the asset itself          |
   *  | AI corrects red eyes                                    | A minor correction                        |
   *  | AI removes background without replacement               | Doesn't change original meaning by itself |
   *  | AI changes the color of an object in an image           | Doesn't change original meaning by itself |
   *  | AI detects image defects and suggests manual fixes      | Didn't change the asset itself            |
   *  | AI adjusts brightness and contrast on an image          | Doesn't change original meaning by itself |
   *  | AI upscales an image                                    | Doesn't change original meaning by itself |
   */
  aiDisclosure: AiDisclosure;
} & AllOrNone<Dimensions>;

declare type Never<T> = {
  [key in keyof T]?: never;
};

/**
 * @public
 * Prompts the user to choose a color that can be used within Canva.
 *
 */
export declare const openColorSelector: <Scope extends ColorSelectionScope>(
  anchor: Anchor,
  options: ColorSelectorOpts<Scope>,
) => Promise<CloseColorSelectorFn>;

/**
 * @public
 * An asset that's queued for upload to the user's private media library.
 */
export declare type QueuedAsset = QueuedImage | QueuedVideo | QueuedAudio;

/**
 * @public
 * An audio asset that's queued for upload to the user's private media library.
 */
export declare type QueuedAudio = {
  /**
   * A unique identifier that points to the audio asset in Canva's backend.
   */
  ref: AudioRef;
  /**
   * Returns a `Promise` that resolves when the asset has finished uploading.
   */
  readonly whenUploaded: () => Promise<void>;
};

/**
 * @public
 * An image asset that's queued for upload to the user's private media library.
 */
export declare type QueuedImage = {
  /**
   * A unique identifier that points to an image asset in Canva's backend.
   */
  ref: ImageRef;
  /**
   * Returns a `Promise` that resolves when the asset has finished uploading.
   */
  readonly whenUploaded: () => Promise<void>;
};

/**
 * @public
 * A video asset that's queued for upload to the user's private media library.
 */
export declare type QueuedVideo = {
  /**
   * A unique identifier that points to a video asset in Canva's backend.
   */
  ref: VideoRef;
  /**
   * Returns a `Promise` that resolves when the asset has finished uploading.
   */
  readonly whenUploaded: () => Promise<void>;
};

/**
 * @public
 * A unique identifier that points to an asset in Canva's backend.
 */
export declare type Ref = ImageRef | VideoRef | AudioRef;

/**
 * @public
 * Prompts the user to choose a font that can be used within Canva.
 */
export declare const requestFontSelection: (
  request?: FontSelectionRequest,
) => Promise<FontSelectionResponse>;

/**
 * @public
 * A solid color.
 */
export declare type SolidColor = {
  /**
   * The type of color.
   */
  type: "solid";
  /**
   * The color as a hexadecimal code.
   *
   * @remarks
   * This is always a 6-digit code that's prefixed with a `#` symbol.
   *
   * @example
   * "#ff0099"
   */
  hexString: string;
};

/**
 * @public
 * The result of retrieving a temporary URL of an asset in Canva's backend.
 */
export declare type TemporaryUrl = TemporaryUrlForImage | TemporaryUrlForVideo;

/**
 * @public
 * The result of retrieving a temporary URL of an image asset in Canva's backend.
 */
export declare type TemporaryUrlForImage = {
  /**
   * The type of asset.
   */
  type: "image";
  /**
   * A unique identifier that points to an image asset in Canva's backend.
   */
  ref: ImageRef;
  /**
   * A temporary URL for downloading the asset.
   */
  url: string;
};

/**
 * @public
 * The result of retrieving a temporary URL of a video asset in Canva's backend.
 */
export declare type TemporaryUrlForVideo = {
  /**
   * The type of asset.
   */
  type: "video";
  /**
   * A unique identifier that points to a video asset in Canva's backend.
   */
  ref: VideoRef;
  /**
   * A temporary URL for downloading the asset.
   */
  url: string;
};

/**
 * @public
 * This method creates a new asset upload task and adds it to the upload queue.
 * It returns a asset reference, and a function called `whenUploaded()` that can
 * be used to await the upload task completion.
 */
export declare const upload: {
  (options: ImageUploadOptions): Promise<QueuedImage>;
  (options: VideoUploadOptions): Promise<QueuedVideo>;
  (options: AudioUploadOptions): Promise<QueuedAudio>;
  (options: AssetUploadOptions): Promise<QueuedAsset>;
};

/**
 * @public
 * The MIME type of a video file that's supported by Canva's backend.
 *
 * @remarks
 * - GIFs are treated as videos, not images.
 * - `"application/json"` is only used for Lottie files.
 */
export declare type VideoMimeType =
  | "video/avi"
  | "image/gif"
  | "video/x-m4v"
  | "video/x-matroska"
  | "video/quicktime"
  | "video/mp4"
  | "video/mpeg"
  | "video/webm"
  | "application/json";

/**
 * @public
 * A unique identifier that points to a video asset in Canva's backend.
 */
export declare type VideoRef = string & {
  __videoRef: never;
};

/**
 * @public
 * Options for uploading a video asset to the user's private media library.
 */
export declare type VideoUploadOptions = {
  /**
   * The type of asset.
   */
  type: "video";
  /**
   * The ref of the original asset from which this new asset was derived.
   *
   * @remarks
   * For example, if an app applies an effect to a video, `parentRef` should contain the ref of the original video.
   */
  parentRef?: VideoRef;
  /**
   * The URL of the video file to upload.
   *
   * @remarks
   * Requirements:
   *
   * - Must use HTTPS
   * - Must return a `200` status code
   * - `Content-Type` must match the file's MIME type
   * - Must be publicly accessible (i.e. not a localhost URL)
   * - Must not redirect
   * - Must not contain an IP address
   * - Maximum length: 4096 characters
   * - Must not contain whitespace
   * - Must not contain these characters: `>`, `<`, `{`, `}`, `^`, backticks
   * - Maximum file size: 100MB
   */
  url: string;
  /**
   * The MIME type of the video file.
   */
  mimeType: VideoMimeType;
  /**
   * The URL of a thumbnail video to display while the video is queued for upload.
   *
   * @remarks
   * Requirements:
   *
   * - Must use HTTPS
   * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
   * - Maximum length: 4096 characters
   */
  thumbnailVideoUrl?: string;
  /**
   * The URL of a thumbnail image to use as a fallback if `thumbnailVideoUrl` isn't provided.
   * This can be an external URL or a data URL.
   *
   * @remarks
   * Requirements for external URLs:
   *
   * - Must use HTTPS
   * - Must support [Cross-Origin Resource Sharing](https://www.canva.dev/docs/apps/cross-origin-resource-sharing/)
   * - Must be a PNG, JPEG, or SVG file
   * - Maximum length: 4096 characters
   *
   * Requirements for data URLs:
   *
   * - Must include `;base64` for base64-encoded data
   * - Maximum size: 10MB (10 × 1024 × 1024 characters)
   */
  thumbnailImageUrl: string;
  /**
   * A disclosure identifying if the app generated this video using AI.
   *
   * @remarks
   * Helps users make informed decisions about the content they interact with.
   * See {@link AiDisclosure} for the full definition.
   *
   * **App Generated**
   *
   * 'app_generated' indicates when the app creates or significantly alters an asset using AI. Includes when
   * the app requests a third-party service to take similar action on a video using AI.
   *
   *  Required for the following cases (this list is not exhaustive):
   *  | Case                                                             | Reason                               |
   *  | --                                                               | --                                   |
   *  | AI generates a new video from scratch                            | Creates new creative content         |
   *  | AI changes the style of the video e.g. makes it cartoon          | Significantly alters the style       |
   *  | AI adds subtitles that rely on subjective interpretation         | Creates new creative content         |
   *  | AI expands a video by generating new content to fill the edges   | Creates new creative content         |
   *  | AI animates an image                                             | Creates new creative content         |
   *  | AI fixes defects e.g. blur in a video by generating details      | Creates new creative content         |
   *  | AI generates a talking head presenter                            | Creates new creative content         |
   *
   * **None**
   *
   * 'none' indicates when the app doesn't create or significantly alter an asset using AI, or as a part of
   * a request to third-party hosted content.
   *
   * Required for the following cases (this list is not exhaustive):
   *  | Case                                                     | Reason                                    |
   *  | --                                                       | --                                        |
   *  | Asset comes from an asset library                        | Didn't generate the asset itself          |
   *  | AI corrects red eyes                                     | A minor correction                        |
   *  | AI adjusts brightness and contrast on a video            | Doesn't change original meaning by itself |
   *  | AI creates a slow motion effect in a video               | Doesn't change original meaning by itself |
   *  | AI adds AI word-by-word transcribed subtitles to a video | Doesn't change original meaning by itself |
   */
  aiDisclosure: AiDisclosure;
} & AllOrNone<Dimensions>;

export {};
