import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  package_default,
  reportCommandStartEvent
} from "./chunk-VCRQW6IK.js";
import {
  HttpClientProvider,
  buildHttpClientHeaders
} from "./chunk-BRX4HWJE.js";
import {
  PanoramaProvider,
  createCommandTransaction
} from "./chunk-ZBFOAJ5H.js";
import {
  BiProvider,
  ErrorReporterProvider
} from "./chunk-YHFCDWGT.js";
import {
  render
} from "./chunk-QK47PIWK.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// src/commands/render-command.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
async function renderCommand(command, { biLogger, errorReporter, panorama }, tree) {
  await runCommand(command, { biLogger, errorReporter, panorama }, async () => {
    const headers = buildHttpClientHeaders({
      flow: "CLI",
      command: command.name(),
      cliVersion: package_default.version
    });
    await render(
      /* @__PURE__ */ import_react.default.createElement(BiProvider, { value: biLogger }, /* @__PURE__ */ import_react.default.createElement(ErrorReporterProvider, { value: errorReporter }, /* @__PURE__ */ import_react.default.createElement(PanoramaProvider, { value: panorama }, /* @__PURE__ */ import_react.default.createElement(HttpClientProvider, { headers }, tree))))
    );
  });
}
async function runCommand(command, services, commandFn) {
  const commandStatus = reportCommandStartEvent(services.biLogger, command);
  const transaction = createCommandTransaction(services.panorama, command);
  try {
    transaction.start();
    await commandFn();
    transaction.finish();
    commandStatus.succeed();
  } catch (e) {
    commandStatus.failed(e);
    throw e;
  }
}

export {
  renderCommand,
  runCommand
};
//# sourceMappingURL=chunk-E4JIOXZN.js.map