import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  ProjectModelProvider
} from "./chunk-RDF2RA4E.js";
import {
  PanoramaProvider
} from "./chunk-ECBO3UFC.js";
import {
  addUserFields
} from "./chunk-VC5Q2AI5.js";
import {
  AuthProvider,
  BiProvider,
  DebugLogProvider,
  ErrorReporterProvider,
  isLoggedInToAccount
} from "./chunk-HWT3LUJJ.js";
import {
  createRendererToString
} from "./chunk-YL4347CI.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import {
  getDebugLogFilePath
} from "./chunk-YT5BPQDJ.js";
import {
  CliError,
  CliErrorCode
} from "./chunk-MTT3QXBC.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-astro-commands/src/non-interactive/execute-command.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
async function executeCommand(services, model, renderFn) {
  const authData = await isLoggedInToAccount();
  if (!authData) {
    throw new CliError({
      code: CliErrorCode.AuthenticationRequired(),
      cause: null
    });
  }
  services.errorReporter.setUser({ id: authData.userInfo.userId });
  addUserFields(services.biLogger, authData.userInfo.userId);
  const renderer = createRendererToString({ stripAnsi: false });
  const debugLogFilePath = getDebugLogFilePath(model.projectFolder);
  return new Promise((resolve, reject) => {
    renderer.render(
      /* @__PURE__ */ import_react.default.createElement(BiProvider, { value: services.biLogger }, /* @__PURE__ */ import_react.default.createElement(ErrorReporterProvider, { value: services.errorReporter }, /* @__PURE__ */ import_react.default.createElement(PanoramaProvider, { value: services.panorama }, /* @__PURE__ */ import_react.default.createElement(AuthProvider, null, /* @__PURE__ */ import_react.default.createElement(DebugLogProvider, { filePath: debugLogFilePath }, /* @__PURE__ */ import_react.default.createElement(ProjectModelProvider, { value: model }, renderFn((...args) => {
        renderer.unmount();
        resolve(...args);
      })))))))
    );
    renderer.waitUntilExit().catch(reject);
  });
}

export {
  executeCommand
};
//# sourceMappingURL=chunk-LLHBMTXU.js.map