/**
 * @license
 * Copyright 2022-2024 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { EndpointLifecycle } from "#endpoint/properties/EndpointLifecycle.js";
import { AsyncObservable, Observable } from "#general";
class NodeLifecycle extends EndpointLifecycle {
  #online = AsyncObservable();
  #offline = Observable();
  #commissioned = Observable();
  #decommissioned = Observable();
  #initialized = Observable();
  #isOnline = false;
  #isCommissioned = false;
  constructor(endpoint) {
    super(endpoint);
    this.#online.on(() => {
      this.#isOnline = true;
    });
    this.#offline.on(() => {
      this.#isOnline = false;
    });
    this.#commissioned.on(() => {
      this.#isCommissioned = true;
    });
    this.#decommissioned.on(() => {
      this.#isCommissioned = false;
    });
    this.#initialized.on((isCommissioned) => {
      this.#isCommissioned = isCommissioned;
    });
  }
  /**
   * True when the node is connected to the network.
   */
  get isOnline() {
    return this.#isOnline;
  }
  /**
   * Emits when the node is first online.
   */
  get online() {
    return this.#online;
  }
  /**
   * Emits when the node's endpoint tree is ready/initialized and used to initialize the commissioning state
   */
  get initialized() {
    return this.#initialized;
  }
  /**
   * Emits when the node goes offline.
   */
  get offline() {
    return this.#offline;
  }
  /**
   * True when the node is part of at least one fabric.
   */
  get isCommissioned() {
    return this.#isCommissioned;
  }
  /**
   * Emits when node is first commissioned.
   */
  get commissioned() {
    return this.#commissioned;
  }
  /**
   * Emits when node is no longer comissioned.
   */
  get decommissioned() {
    return this.#decommissioned;
  }
}
export {
  NodeLifecycle
};
//# sourceMappingURL=NodeLifecycle.js.map
