"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 NodeJsBle_exports = {};
__export(NodeJsBle_exports, {
  NodeJsBle: () => NodeJsBle
});
module.exports = __toCommonJS(NodeJsBle_exports);
var import_protocol = require("#protocol");
var import_BlenoBleServer = require("./BlenoBleServer.js");
var import_BlenoPeripheralInterface = require("./BlenoPeripheralInterface.js");
var import_BleScanner = require("./BleScanner.js");
var import_NobleBleChannel = require("./NobleBleChannel.js");
var import_NobleBleClient = require("./NobleBleClient.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class NodeJsBle extends import_protocol.Ble {
  #options;
  #blePeripheralInstance;
  #bleCentralInstance;
  #bleScanner;
  #bleCentralInterface;
  #blePeripheralInterface;
  constructor(options) {
    super();
    this.#options = options;
    if (options?.environment && options.hciId === void 0) {
      const hciId = options.environment.vars.number("ble.hci.id");
      if (hciId !== void 0) {
        this.#options = {
          ...options,
          hciId
        };
      }
    }
  }
  get #blePeripheralServer() {
    if (this.#blePeripheralInstance === void 0) {
      this.#blePeripheralInstance = new import_BlenoBleServer.BlenoBleServer(this.#options);
    }
    return this.#blePeripheralInstance;
  }
  get #bleCentralClient() {
    if (this.#bleCentralInstance === void 0) {
      this.#bleCentralInstance = new import_NobleBleClient.NobleBleClient(this.#options);
    }
    return this.#bleCentralInstance;
  }
  get peripheralInterface() {
    if (this.#blePeripheralInterface === void 0) {
      this.#blePeripheralInterface = new import_BlenoPeripheralInterface.BlenoPeripheralInterface(this.#blePeripheralServer);
    }
    return this.#blePeripheralInterface;
  }
  get centralInterface() {
    if (this.#bleCentralInterface === void 0) {
      this.#bleCentralInterface = new import_NobleBleChannel.NobleBleCentralInterface(this.scanner);
    }
    return this.#bleCentralInterface;
  }
  get scanner() {
    if (this.#bleScanner === void 0) {
      this.#bleScanner = new import_BleScanner.BleScanner(this.#bleCentralClient);
    }
    return this.#bleScanner;
  }
}
//# sourceMappingURL=NodeJsBle.js.map
