import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
import { BaseController } from "@metamask/base-controller";
import type { Messenger } from "@metamask/messenger";
import type { Json } from "@metamask/utils";
import type { PermissionSubjectMetadata } from "./PermissionController.cjs";
import type { PermissionControllerHasPermissionsAction } from "./PermissionController-method-action-types.cjs";
import type { SubjectMetadataControllerMethodActions } from "./SubjectMetadataController-method-action-types.cjs";
declare const controllerName = "SubjectMetadataController";
type SubjectOrigin = string;
/**
 * The different kinds of subjects that MetaMask may interact with, including
 * third parties and itself (e.g., when the background communicated with the UI).
 */
export declare enum SubjectType {
    Extension = "extension",
    Internal = "internal",
    Unknown = "unknown",
    Website = "website",
    Snap = "snap"
}
export type SubjectMetadata = PermissionSubjectMetadata & {
    [key: string]: Json;
    name: string | null;
    subjectType: SubjectType | null;
    extensionId: string | null;
    iconUrl: string | null;
};
type SubjectMetadataToAdd = PermissionSubjectMetadata & {
    name?: string | null;
    subjectType?: SubjectType | null;
    extensionId?: string | null;
    iconUrl?: string | null;
} & Record<string, Json>;
export type SubjectMetadataControllerState = {
    subjectMetadata: Record<SubjectOrigin, SubjectMetadata>;
};
export type SubjectMetadataControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SubjectMetadataControllerState>;
/**
 * @deprecated Use `SubjectMetadataControllerGetStateAction` instead.
 */
export type GetSubjectMetadataState = SubjectMetadataControllerGetStateAction;
/**
 * @deprecated Use `SubjectMetadataControllerGetSubjectMetadataAction` instead.
 */
export type GetSubjectMetadata = {
    type: `${typeof controllerName}:getSubjectMetadata`;
    handler: (origin: SubjectOrigin) => SubjectMetadata | undefined;
};
/**
 * @deprecated Use `SubjectMetadataControllerAddSubjectMetadataAction` instead.
 */
export type AddSubjectMetadata = {
    type: `${typeof controllerName}:addSubjectMetadata`;
    handler: (metadata: SubjectMetadataToAdd) => void;
};
export type SubjectMetadataControllerActions = SubjectMetadataControllerGetStateAction | SubjectMetadataControllerMethodActions;
export type SubjectMetadataStateChange = ControllerStateChangeEvent<typeof controllerName, SubjectMetadataControllerState>;
export type SubjectMetadataControllerEvents = SubjectMetadataStateChange;
type AllowedActions = PermissionControllerHasPermissionsAction;
export type SubjectMetadataControllerMessenger = Messenger<typeof controllerName, SubjectMetadataControllerActions | AllowedActions, SubjectMetadataControllerEvents>;
type SubjectMetadataControllerOptions = {
    messenger: SubjectMetadataControllerMessenger;
    subjectCacheLimit: number;
    state?: Partial<SubjectMetadataControllerState>;
};
/**
 * A controller for storing metadata associated with permission subjects. More
 * or less, a cache.
 */
export declare class SubjectMetadataController extends BaseController<typeof controllerName, SubjectMetadataControllerState, SubjectMetadataControllerMessenger> {
    #private;
    constructor({ messenger, subjectCacheLimit, state, }: SubjectMetadataControllerOptions);
    /**
     * Clears the state of this controller. Also resets the cache of subjects
     * encountered since startup, so as to not prematurely reach the cache limit.
     */
    clearState(): void;
    /**
     * Stores domain metadata for the given origin (subject). Deletes metadata for
     * subjects without permissions in a FIFO manner once more than
     * {@link SubjectMetadataController.subjectCacheLimit} distinct origins have
     * been added since boot.
     *
     * In order to prevent a degraded user experience,
     * metadata is never deleted for subjects with permissions, since metadata
     * cannot yet be requested on demand.
     *
     * @param metadata - The subject metadata to store.
     */
    addSubjectMetadata(metadata: SubjectMetadataToAdd): void;
    /**
     * Gets the subject metadata for the given origin, if any.
     *
     * @param origin - The origin for which to get the subject metadata.
     * @returns The subject metadata, if any, or `undefined` otherwise.
     */
    getSubjectMetadata(origin: SubjectOrigin): SubjectMetadata | undefined;
    /**
     * Deletes all subjects without permissions from the controller's state.
     */
    trimMetadataState(): void;
}
export {};
//# sourceMappingURL=SubjectMetadataController.d.cts.map