/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Behavior } from "#behavior/Behavior.js";
import { BehaviorBacking } from "#behavior/internal/BehaviorBacking.js";
import { Datasource } from "#behavior/state/managed/Datasource.js";
import { Diagnostic, Immutable, Lifecycle, MaybePromise } from "@matter/general";
import { ClusterTypeProtocol, Val } from "@matter/protocol";
import type { Agent } from "../Agent.js";
import type { Endpoint } from "../Endpoint.js";
import type { SupportedBehaviors } from "./SupportedBehaviors.js";
export interface SupportedElements {
    features: Set<string>;
    attributes: Set<string>;
    commands: Set<string>;
    events: Set<string>;
}
/**
 * This class manages {@link Behavior} instances owned by a {@link Endpoint}.
 */
export declare class Behaviors {
    #private;
    [Diagnostic.value]: Diagnostic[];
    /**
     * The {@link SupportedBehaviors} of the {@link Endpoint}.
     */
    get supported(): SupportedBehaviors;
    /**
     * Obtain the specific {@link Behavior.Type} used by the endpoint for implementation if the endpoint supports
     * {@link type}.
     */
    typeFor<T extends Behavior.Type>(type: T): T | undefined;
    /**
     * The list of active behaviors.
     */
    get active(): Behavior.Type[];
    get status(): Record<string, Lifecycle.Status>;
    get detailedDiagnostic(): Diagnostic[][];
    constructor(endpoint: Endpoint, options: Record<string, object | undefined>);
    /**
     * Activate any behaviors designated for immediate activation.  Returns a promise iff any behaviors have ongoing
     * initialization.
     *
     * Throws an error if any behavior crashes, but we allow all behaviors to settle before throwing.  The goal is to
     * surface multiple configuration errors and prevent inconsistent state caused by partial initialization.
     */
    initialize(): MaybePromise;
    /**
     * Does the {@link Endpoint} support a specified behavior?
     */
    has<T extends Behavior.Type>(type: T): boolean;
    /**
     * Does the {@link Endpoint} support a specified behavior by its behavior Id?
     */
    has(typeId: string): boolean;
    /**
     * Add behavior support dynamically at runtime.  Typically called via {@link Agent.require}.
     */
    require<T extends Behavior.Type>(type: T, options?: Behavior.Options<T>): void;
    /**
     * Create a behavior synchronously.  Fails if the behavior is not fully initialized.
     */
    createSync(type: Behavior.Type, agent: Agent): Behavior;
    /**
     * Create a behavior asynchronously.  Waits for the behavior to complete initialization.
     */
    createAsync(type: Behavior.Type, agent: Agent): Promise<void>;
    /**
     * Create a behavior, possibly asynchronously.
     *
     * This method returns a {@link Promise} only if await is necessary so the behavior can be used immediately if
     * possible.
     */
    createMaybeAsync(type: Behavior.Type, agent: Agent): MaybePromise<Behavior>;
    /**
     * Activate a behavior.
     *
     * Semantically identical to createAsync() but does not return a {@link Promise} or throw an error.
     *
     * Behaviors that fail initialization will be marked with crashed {@link status}.
     */
    activate(type: Behavior.Type, agent: Agent): void;
    /**
     * Determine if a specified behavior is supported and active.
     */
    isActive(type: Behavior.Type | string): boolean;
    /**
     * Destroy all behaviors that are initialized (have backings present).  The object may be reused after close.
     */
    close(): Promise<void>;
    /**
     * Add support for an additional behavior.
     *
     * This should generally only be used prior to initialization.  It may cause subtle errors if incompatible types are
     * injected once the endpoint is initialized.
     */
    inject(type: Behavior.Type, options?: Behavior.Options, notify?: boolean): void;
    /**
     * Drop support for a behavior.
     *
     * This is intended for synchronization with peers and should not be used for servers as Matter does not allow an
     * endpoint to change its set of supported clusters.
     */
    drop(id: string): MaybePromise<void>;
    /**
     * Ensure a set of behavior requirements are met.  Throws an error detailing missing requirements.
     */
    validateRequirements(requirements?: SupportedBehaviors): void;
    /**
     * Obtain default values for a behavior.  This is state values as present when the behavior is first initialized for
     * a new endpoint.
     */
    defaultsFor(type: Behavior.Type): Val.Struct | undefined;
    /**
     * Retrieve the options for a behavior type provided to the endpoint.
     */
    optionsFor(type: Behavior.Type): object | undefined;
    /**
     * Access internal state for a {@link Behavior}.
     *
     * Internal state is not a stable API and not intended for consumption outside the behavior.  However, it is not
     * truly private and may be accessed by tightly coupled implementation.
     *
     * As this API is intended for use by "friendly" code, it does not perform the same initialization assertions as
     * does access to {@link Behavior.State} and {@link Behavior.Events}.
     */
    internalsOf<T extends Behavior.Type>(type: T): InstanceType<T["Internal"]>;
    /**
     * Obtain current data version of behavior.
     */
    versionOf(type: Behavior.Type): number;
    /**
     * Obtain current data version of behavior by its behavior Id, if existing
     */
    versionOf(typeId: string): number | undefined;
    /**
     * @throws ImplementationError if the behavior is not supported.
     */
    backingFor(type: Behavior.Type): BehaviorBacking;
    /**
     * Access elements supported by a behavior.
     */
    elementsOf(type: Behavior.Type): SupportedElements;
    /**
     * Access the state view of a behavior if loaded.
     */
    maybeStateOf(behaviorId: string): Immutable<Val.Struct> | undefined;
    [Symbol.iterator](): ArrayIterator<Behavior.Type>;
    /**
     * Create a read-only online view of a behavior.
     */
    createOnlineView(type: Behavior.Type): Datasource<import("../../index.js").StateType>;
}
export declare namespace Behaviors {
    interface ProtocolContext {
        descriptor: ClusterTypeProtocol;
        datasource: Datasource;
    }
}
//# sourceMappingURL=Behaviors.d.ts.map