import {
  reportAnalyticsEvent
} from "../chunk-QEPDWTYB.js";
import {
  getNextDeprecationDate
} from "../chunk-LHICDI3H.js";
import "../chunk-O7YFJ6MY.js";
import "../chunk-JWZLOUHD.js";
import "../chunk-VSLR7ET4.js";
import "../chunk-ZUU6SR63.js";
import "../chunk-ONG7EKNR.js";
import "../chunk-BYPQXSAL.js";
import {
  addSensitiveMetadata,
  getAllSensitiveMetadata,
  outputDebug,
  renderWarning
} from "../chunk-IW7KNM7Q.js";
import "../chunk-2HGYYNE5.js";
import "../chunk-XVNW332R.js";
import "../chunk-HFAVKTDR.js";
import "../chunk-EI5KZ5NN.js";
import "../chunk-CBBS4CV7.js";
import "../chunk-SNOECVP4.js";
import "../chunk-UBB7JKND.js";
import "../chunk-NEOIQ6PN.js";
import "../chunk-7Q3MMWAC.js";
import "../chunk-MX4RJDBM.js";
import "../chunk-NB4NLOEJ.js";
import "../chunk-522OB3EU.js";
import {
  init_cjs_shims
} from "../chunk-POZ5MGPT.js";

// src/hooks/postrun.ts
init_cjs_shims();

// ../cli-kit/dist/public/node/hooks/postrun.js
init_cjs_shims();

// ../cli-kit/dist/public/node/hooks/deprecations.js
init_cjs_shims();
var postrun = (Command) => {
  let nextDeprecationDate = getNextDeprecationDate();
  if (nextDeprecationDate) {
    let forThemes = Command.id.includes("theme");
    renderUpgradeWarning(nextDeprecationDate, forThemes);
  }
};
function renderUpgradeWarning(upgradeByDate, forThemes) {
  let headline = `Upgrade to the latest CLI version by ${new Intl.DateTimeFormat("default", {
    year: "numeric",
    month: "long",
    day: "numeric"
  }).format(upgradeByDate)}.`;
  renderWarning({
    headline,
    body: "This command requires an upgrade to continue working as intended.",
    nextSteps: [["Run", { command: "upgrade" }, "to", {
      link: {
        label: "upgrade Shopify CLI",
        url: forThemes ? "https://shopify.dev/docs/themes/tools/cli#upgrade-shopify-cli" : "https://shopify.dev/docs/apps/tools/cli#upgrade-shopify-cli"
      }
    }]]
  });
}

// ../cli-kit/dist/public/node/hooks/postrun.js
var hook = async ({ config, Command }) => {
  await detectStopCommand(Command), await reportAnalyticsEvent({ config, exitMode: "ok" }), postrun(Command);
  let command = Command.id.replace(/:/g, " ");
  outputDebug(`Completed command ${command}`);
};
async function detectStopCommand(commandClass) {
  let currentTime = (/* @__PURE__ */ new Date()).getTime();
  if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, "analyticsStopCommand")) {
    let stopCommand = commandClass.analyticsStopCommand();
    if (stopCommand) {
      let { commandStartOptions } = getAllSensitiveMetadata();
      await addSensitiveMetadata(() => ({
        commandStartOptions: {
          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
          ...commandStartOptions,
          startTime: currentTime,
          startCommand: stopCommand
        }
      }));
    }
  }
}
export {
  hook as default
};
//# sourceMappingURL=postrun.js.map
