/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ClientRequest } from "#action/client/ClientRequest.js";
import { Duration } from "@matter/general";
import { ClusterType, CommandData, InvokeRequest, TlvSchema } from "@matter/types";
import { Specifier } from "./Specifier.js";
export interface InvokeCommandData extends CommandData {
    timed?: boolean;
}
export interface Invoke extends InvokeRequest {
    /** Timeout only relevant for Client Interactions */
    timeout?: Duration;
    /** Expected processing time of the command on the server side to calculated response timeout */
    expectedProcessingTime?: Duration;
    /** Whether to use extended timeout for fail-safe messages.  Overwrites the expectedProcessingTime if both are set */
    useExtendedFailSafeMessageResponseTimeout?: boolean;
    /**
     * Controls automatic command batching for single-command invokes.
     *
     * - `undefined` — batch with zero delay (commands in the same timer tick are combined)
     * - `Duration` — batch with the specified collection window
     * - `false` — disable batching; execute immediately
     */
    batchDuration?: false | Duration;
}
export interface CommandDecodeDetails {
    responseSchema: TlvSchema<any>;
}
export interface ClientInvoke extends Invoke, ClientRequest {
    commands: Map<number | undefined, Invoke.AnyCommandRequest>;
    skipValidation?: boolean;
}
/**
 * Request invocation of one or more commands.
 */
export declare function Invoke(options: Invoke.Definition): ClientInvoke;
/**
 * Request invocation multiple commands with defined options
 */
export declare function Invoke(options: Invoke.Definition, ...commands: Invoke.CommandRequest<any>[]): ClientInvoke;
/**
 * Request invocation multiple commands as list of Commands with default options.
 */
export declare function Invoke(...commands: Invoke.CommandRequest<any>[]): ClientInvoke;
export declare namespace Invoke {
    interface Definition {
        /** List of commands to invoke */
        commands: (Invoke.CommandRequest<any> | Invoke.LegacyCommandRequest)[];
        /** Tell the server to not send a response */
        suppressResponse?: boolean;
        /** Whether this is sent as a timed request, if no timeout is specified a default is used */
        timed?: boolean;
        /** Timeout when sent as a timed request, if timed flag is not set it will be set automatically */
        timeout?: Duration;
        /** Interaction model revision to use, if not specified a default is used */
        interactionModelRevision?: number;
        /** Processing time of the command of the server assumed for this invoke. If not set a default is used */
        expectedProcessingTime?: Duration;
        /** Whether to use extended timeout for fail-safe messages.  Overwrites the expectedProcessingTime if both are set */
        useExtendedFailSafeMessageResponseTimeout?: boolean;
        /** Whether to skip validation of command fields against schema */
        skipValidation?: boolean;
    }
    function Command<const C extends Specifier.ClusterLike>(request: Invoke.CommandRequest<C>, skipValidation?: boolean): InvokeCommandData;
    /**
     * @deprecated
     * Use {@link CommandRequest} with {@link ClusterType.Command}.
     */
    function Command(request: Invoke.LegacyCommandRequest, skipValidation?: boolean): InvokeCommandData;
    function Command(request: Invoke.AnyCommandRequest, skipValidation?: boolean): InvokeCommandData;
    /**
     * @deprecated
     * Legacy command request using ClusterType commands.  Use {@link CommandRequest} with
     * {@link ClusterType.Command}.
     */
    interface LegacyCommandRequest {
        cluster: Specifier.Cluster;
        command: Specifier.ClusterTypeCommand;
        endpoint?: Specifier.Endpoint;
        fields?: unknown;
        commandName?: string;
        commandRef?: number;
    }
    /**
     * Union of new-style and legacy command requests.
     */
    type AnyCommandRequest = CommandRequest<any> | LegacyCommandRequest;
    /**
     * Type guard for legacy command requests.
     */
    function isLegacy(request: AnyCommandRequest): request is LegacyCommandRequest;
    type CommandRequest<C extends Specifier.Cluster = Specifier.Cluster, CMD extends Specifier.Command<Specifier.ClusterFor<C>> = Specifier.Command<Specifier.ClusterFor<C>>> = ConcreteCommandRequest<C, CMD> | WildcardCommandRequest<C, CMD>;
    type ConcreteCommandRequest<C extends Specifier.Cluster = Specifier.Cluster, CMD extends Specifier.Command<Specifier.ClusterFor<C>> = Specifier.Command<Specifier.ClusterFor<C>>> = WildcardCommandRequest<C, CMD> & {
        endpoint: Specifier.Endpoint;
    };
    /**
     * @deprecated
     * Use the overload accepting {@link ConcreteCommandRequest}.
     */
    function ConcreteCommandRequest(data: Invoke.LegacyCommandRequest): Invoke.LegacyCommandRequest;
    function ConcreteCommandRequest<const C extends Specifier.ClusterLike>(data: Invoke.ConcreteCommandRequest<C>): Invoke.ConcreteCommandRequest<any>;
    type WildcardCommandRequest<C extends Specifier.Cluster = Specifier.Cluster, CMD extends Specifier.Command<Specifier.ClusterFor<C>> = Specifier.Command<Specifier.ClusterFor<C>>> = {
        cluster: C;
        command: CMD;
        commandName?: string;
        commandRef?: number;
    } & Fields<Specifier.CommandFor<Specifier.ClusterFor<C>, CMD>>;
    /**
     * @deprecated
     * Use the overload accepting {@link WildcardCommandRequest}.
     */
    function WildcardCommandRequest(data: Invoke.LegacyCommandRequest): Invoke.LegacyCommandRequest;
    function WildcardCommandRequest<const C extends Specifier.ClusterLike>(data: Invoke.WildcardCommandRequest<C>): Invoke.WildcardCommandRequest<any>;
    /**
     * Extract the command element from a command request.
     */
    function commandOf<const R extends CommandRequest>(request: R): ClusterType.Command;
    /**
     * Extract the request type from a command's function signature phantom type.
     */
    type RequestOf<C extends ClusterType.Command = ClusterType.Command> = C extends ClusterType.Command<infer F> ? F extends (request: infer R, ...args: unknown[]) => unknown ? R : void : void;
    type Fields<C extends ClusterType.Command> = RequestOf<C> extends void ? {} : undefined extends RequestOf<C> ? {
        fields?: RequestOf<C>;
    } : {
        fields: RequestOf<C>;
    };
}
//# sourceMappingURL=Invoke.d.ts.map