import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  addUserFields
} from "./chunk-UJ4SA2PC.js";
import {
  messages_default
} from "./chunk-ZHQREOZP.js";
import {
  DebugLogProvider
} from "./chunk-IIF6P6XG.js";
import {
  AccountAuthProvider,
  BiProvider,
  CliError,
  CliErrorCode,
  ErrorReporterProvider,
  I18nProvider,
  PanoramaProvider,
  ProjectModelProvider,
  createRendererToString,
  getDebugLogFilePath,
  isLoggedInToAccount,
  require_react
} from "./chunk-ESTYQVMX.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-4EFJZ3GQ.js";

// src/non-interactive/logger.ts
init_esm_shims();
function log(message) {
  console.log(message);
}

// 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(AccountAuthProvider, null, /* @__PURE__ */ import_react.default.createElement(I18nProvider, { messages: messages_default }, /* @__PURE__ */ import_react.default.createElement(DebugLogProvider, { filePath: debugLogFilePath }, /* @__PURE__ */ import_react.default.createElement(ProjectModelProvider, { value: model, watchForChanges: false }, renderFn((...args) => {
        renderer.unmount();
        resolve(...args);
      }))))))))
    );
    renderer.waitUntilExit().catch(reject);
  });
}

export {
  log,
  executeCommand
};
//# sourceMappingURL=chunk-VDQEUTFT.js.map