import { __name } from './chunk-6AXVLTU5.js';
import { LogLevelLabel } from '@storm-software/config-tools/types';

async function buildApplication(log, context, hooks) {
  log(LogLevelLabel.TRACE, "Executing build process for the Storm Stack application.");
  await hooks.callHook("build:application", context).catch((error) => {
    log(LogLevelLabel.ERROR, `An error occured while building the Storm Stack application: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while building the Storm Stack application", {
      cause: error
    });
  });
}
__name(buildApplication, "buildApplication");
async function buildLibrary(log, context, hooks) {
  log(LogLevelLabel.TRACE, "Executing build process for the Storm Stack library.");
  await hooks.callHook("build:library", context).catch((error) => {
    log(LogLevelLabel.ERROR, `An error occured while building the Storm Stack library: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while building the Storm Stack library", {
      cause: error
    });
  });
}
__name(buildLibrary, "buildLibrary");

// src/build/index.ts
async function build(log, context, hooks) {
  await hooks.callHook("build:begin", context).catch((error) => {
    log(LogLevelLabel.ERROR, `An error occured while starting the build process for the Storm Stack project: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while starting the build process for the Storm Stack project", {
      cause: error
    });
  });
  if (context.options.projectType === "application") {
    await buildApplication(log, context, hooks);
  } else {
    await buildLibrary(log, context, hooks);
  }
  await hooks.callHook("build:complete", context).catch((error) => {
    log(LogLevelLabel.ERROR, `An error occured while finishing the build process for the Storm Stack project: ${error.message} 
${error.stack ?? ""}`);
    throw new Error("An error occured while finishing the build process for the Storm Stack project", {
      cause: error
    });
  });
}
__name(build, "build");

export { build };
//# sourceMappingURL=chunk-2PGIUBQM.js.map
//# sourceMappingURL=chunk-2PGIUBQM.js.map