"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Lifecycle_exports = {};
__export(Lifecycle_exports, {
  CrashedDependenciesError: () => CrashedDependenciesError,
  CrashedDependencyError: () => CrashedDependencyError,
  DependencyLifecycleError: () => DependencyLifecycleError,
  DestroyedDependencyError: () => DestroyedDependencyError,
  Lifecycle: () => Lifecycle,
  UninitializedDependencyError: () => UninitializedDependencyError,
  UnsupportedDependencyError: () => UnsupportedDependencyError,
  UnsupportedDependencyStatusError: () => UnsupportedDependencyStatusError
});
module.exports = __toCommonJS(Lifecycle_exports);
var import_MatterError = require("../MatterError.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
var Lifecycle;
((Lifecycle2) => {
  let Status;
  ((Status2) => {
    Status2["Unknown"] = "unknown";
    Status2["Inactive"] = "inactive";
    Status2["Initializing"] = "initializing";
    Status2["Active"] = "active";
    Status2["Crashed"] = "crashed";
    Status2["Destroying"] = "destroying";
    Status2["Destroyed"] = "destroyed";
  })(Status = Lifecycle2.Status || (Lifecycle2.Status = {}));
  function assertActive(status, description) {
    if (!description) {
      description = "dependency";
    }
    switch (status) {
      case "active" /* Active */:
        return;
      case "inactive" /* Inactive */:
        throw new UninitializedDependencyError(description, "is not initialized");
      case "initializing" /* Initializing */:
        throw new UninitializedDependencyError(description, "is still initializing");
      case "crashed" /* Crashed */:
        throw new CrashedDependencyError(description, "initialization failed");
      case "destroying" /* Destroying */:
        throw new DestroyedDependencyError(description, "is closing");
      case "destroyed" /* Destroyed */:
        throw new DestroyedDependencyError(description, "is closed");
    }
    throw new DependencyLifecycleError(description, `status "${status}" is unknown`);
  }
  Lifecycle2.assertActive = assertActive;
})(Lifecycle || (Lifecycle = {}));
class DependencyLifecycleError extends import_MatterError.ImplementationError {
  constructor(what, why) {
    super(`${what} ${why}`);
  }
}
class UnsupportedDependencyStatusError extends DependencyLifecycleError {
}
class UninitializedDependencyError extends DependencyLifecycleError {
}
class CrashedDependencyError extends DependencyLifecycleError {
  subject;
}
class DestroyedDependencyError extends DependencyLifecycleError {
}
class UnsupportedDependencyError extends DependencyLifecycleError {
}
class CrashedDependenciesError extends import_MatterError.MatterAggregateError {
}
//# sourceMappingURL=Lifecycle.js.map
