/**
 * @license
 * Copyright 2025-2026 Open Home Foundation
 * SPDX-License-Identifier: Apache-2.0
 */
function formatHex(value) {
  let hex = value.toString(16).toUpperCase();
  if (hex.length < 4) {
    hex = hex.padStart(4, "0");
  } else if (hex.length % 2 !== 0) {
    hex = "0" + hex;
  }
  return `0x${hex}`;
}
function formatNodeAddress(fabricIndex, nodeId) {
  const fabricPart = fabricIndex !== void 0 ? fabricIndex : "?";
  return `@${fabricPart}:${nodeId.toString(16)}`;
}
function getEffectiveFabricIndex(serverFabricIndex, isTestNode) {
  return isTestNode || serverFabricIndex === void 0 ? void 0 : serverFabricIndex;
}
function formatNodeAddressFromAny(fabricIndex, nodeId) {
  let numericId;
  if (typeof nodeId === "bigint") {
    numericId = nodeId;
  } else if (typeof nodeId === "number") {
    numericId = BigInt(nodeId);
  } else {
    try {
      numericId = BigInt(nodeId);
    } catch {
      return "";
    }
  }
  return formatNodeAddress(fabricIndex, numericId);
}
export {
  formatHex,
  formatNodeAddress,
  formatNodeAddressFromAny,
  getEffectiveFabricIndex
};
//# sourceMappingURL=format_hex.js.map
