/** * The pictures a decision's state holds: image parts, or image assets, anywhere in an object or a * list, each named by its path, which a question writes in backticks, such as `photo`, `faces.happy`, * or `frames[2].frame`. */ import { type MediaResolveOptions } from '../evaluate/media.js'; import type { MediaPart } from '../types/evaluate.js'; /** A picture in a decision's state, and where it is. */ export interface DecisionPicture { /** Its path in the state, as a question names it in backticks: `photo`, `faces.happy`, or `frames[2].frame`. */ path: string; /** The picture: an image part, `{ type: 'image', source }`, or an image asset. */ part: MediaPart; } /** A picture's bytes, read for a provider that sends them. */ export interface ReadDecisionPicture extends DecisionPicture { /** Its bytes. */ bytes: Uint8Array; /** Its MIME type, as its first bytes say, whatever it was declared as. */ mimeType: string; /** Its width in pixels, from its header. */ width?: number; /** Its height in pixels. */ height?: number; } /** Every picture in a state, in the order they appear, each with its path. A picture used twice is listed at both. */ export declare function statePictures(state: unknown): DecisionPicture[]; /** * The state with each picture replaced by what `replace` returns for it, copying only the objects and * lists on the way to one, so a state without pictures comes back as it was given. */ export declare function replacePictures(state: unknown, replace: (picture: DecisionPicture) => unknown): unknown; /** * Identifies a picture without its bytes, for a cache key or a trace: a digest of what it holds, or * where it is when it is a file or at a URL, so a picture changed at the same path is keyed the same. */ export declare function pictureDigest(part: MediaPart): string; /** * Reads a picture's bytes, with the media family's readers: bytes and base64 as they are, a file with * `readFile`, a URL with `fetch`, and a stored asset from `assets`. Throws `DecisionError` * `DECISION_INVALID`, naming the picture's path, for one that cannot be read or is not a picture. */ export declare function readPicture(picture: DecisionPicture, options?: MediaResolveOptions): Promise;