/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Behavior } from "#behavior/Behavior.js";
import { ClusterBehavior } from "#behavior/cluster/ClusterBehavior.js";
import type { ClusterState } from "#behavior/cluster/ClusterState.js";
import { ActionContext } from "#behavior/context/ActionContext.js";
import { ValueSupervisor } from "#behavior/supervision/ValueSupervisor.js";
import { Endpoint } from "#endpoint/Endpoint.js";
import { Environment, Environmental } from "@matter/general";
import { FabricManager } from "@matter/protocol";
import { AttributeId, type ClusterTyping } from "@matter/types";
import { Thermostat } from "@matter/types/clusters/thermostat";
/**
 * Handles atomic write handling according to Matter definitions.
 * The implementation tries to be generic, but is currently only used by the Thermostat cluster, so the atomic write
 * types are imported from there.
 *
 * The logic requires that the cluster behavior implements the following additional events as "pure Observable()" events,
 * because the current implementation logic requires error thrown by the event handlers to signal validation failures to
 * be thrown back to te emitter. This is not the case for official state events.
 * * `${attributeName}$AtomicChanging` - emitted when an attribute is changed as part of an atomic write, before the value
 *   is actually changed. Receives the new value, the old value and the action context as parameters.
 * * `${attributeName}$AtomicChanged` - emitted when an attribute is changed as part of an atomic write, after the value
 *   is actually changed. Receives the new value, the old value and the action context as parameters.
 *
 * TODO: Move out of thermostat behavior into a more generic behavior handler once used by other clusters too. Then we
 *  also need to adjust how it is handled.
 *  Proper solution might be to add the handling of the atomic Request command on interaction level and leave the
 *  transaction open until it is rolled back or committed. This might have side effects on other parts of the system though.
 *  So lets do that later when we have more clusters using it.
 */
export declare class AtomicWriteHandler {
    #private;
    constructor(fabricManager: FabricManager);
    static [Environmental.create](env: Environment): AtomicWriteHandler;
    close(): void;
    /**
     * Implements the begin write logic for an atomic write.
     */
    beginWrite(request: Thermostat.AtomicRequest, context: ActionContext, endpoint: Endpoint, cluster: Behavior.Type): Thermostat.AtomicResponse;
    /**
     * Handles writing a value for an attribute as part of an ongoing atomic write.
     * It uses the *$AtomicChanging* event to trigger validation of the partial write.
     */
    writeAttribute(context: ValueSupervisor.Session, endpoint: Endpoint, cluster: ClusterBehavior.Type, attribute: AttributeId, value: unknown): void;
    /**
     * Implements the commit logic for an atomic write.
     */
    commitWrite<B extends Behavior.Type>(request: Thermostat.AtomicRequest, context: ActionContext, endpoint: Endpoint, cluster: B, clusterState: ClusterState.Type<ClusterTyping, B>): Promise<Thermostat.AtomicResponse>;
    /**
     * Implements the rollback logic for an atomic write.
     */
    rollbackWrite(request: Thermostat.AtomicRequest, context: ActionContext, endpoint: Endpoint, cluster: Behavior.Type): Thermostat.AtomicResponse;
    /**
     * Returns the pending value for the given attribute and peer, if any.
     */
    pendingValueForAttributeAndPeer(context: ValueSupervisor.Session, endpoint: Endpoint, cluster: ClusterBehavior.Type, attribute: AttributeId): unknown;
}
//# sourceMappingURL=AtomicWriteHandler.d.ts.map