import {
  execaSync,
  fileExistsSync
} from "./chunk-LA4HX5WI.js";
import "./chunk-XVNW332R.js";
import "./chunk-XEDHKQZA.js";
import {
  cwd,
  joinPath,
  sniffForPath
} from "./chunk-T2GATXSP.js";
import {
  require_lib
} from "./chunk-CBD6UXLA.js";
import "./chunk-CBBS4CV7.js";
import "./chunk-SNOECVP4.js";
import "./chunk-NEOIQ6PN.js";
import "./chunk-7Q3MMWAC.js";
import "./chunk-MX4RJDBM.js";
import "./chunk-NB4NLOEJ.js";
import "./chunk-UBB7JKND.js";
import "./chunk-522OB3EU.js";
import "./chunk-PNN7RS7Y.js";
import {
  __toESM,
  init_cjs_shims
} from "./chunk-POZ5MGPT.js";

// ../cli-kit/dist/public/node/custom-oclif-loader.js
init_cjs_shims();
var import_core = __toESM(require_lib(), 1), ShopifyConfig = class extends import_core.Config {
  constructor(options) {
    let currentPath = cwd(), path = sniffForPath() ?? currentPath, currentPathMightBeHydrogenMonorepo = /(shopify|hydrogen)\/hydrogen/i.test(currentPath), ignoreHydrogenMonorepo = process.env.IGNORE_HYDROGEN_MONOREPO;
    currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo && (path = execaSync("npm", ["prefix"]).stdout.trim()), fileExistsSync(joinPath(path, "package.json")) && (options.pluginAdditions = {
      core: ["@shopify/cli-hydrogen"],
      path
    }), super(options), this.determinePriority = this.customPriority;
  }
  customPriority(commands) {
    let oclifPlugins = this.pjson.oclif.plugins ?? [];
    return commands.sort((aCommand, bCommand) => {
      let pluginAliasA = aCommand.pluginAlias ?? "A-Cannot-Find-This", pluginAliasB = bCommand.pluginAlias ?? "B-Cannot-Find-This", aIndex = oclifPlugins.indexOf(pluginAliasA), bIndex = oclifPlugins.indexOf(pluginAliasB);
      return aCommand.pluginType === "core" && bCommand.pluginAlias === "@shopify/cli-hydrogen" ? 1 : aCommand.pluginAlias === "@shopify/cli-hydrogen" && bCommand.pluginType === "core" ? -1 : aCommand.pluginType === "core" && bCommand.pluginType === "core" ? aIndex - bIndex : bCommand.pluginType === "core" && aCommand.pluginType !== "core" ? 1 : aCommand.pluginType === "core" && bCommand.pluginType !== "core" ? -1 : aCommand.pluginType === "jit" && bCommand.pluginType !== "jit" ? 1 : bCommand.pluginType === "jit" && aCommand.pluginType !== "jit" ? -1 : 0;
    })[0];
  }
};
export {
  ShopifyConfig
};
//# sourceMappingURL=custom-oclif-loader-IEXPGBA7.js.map
