"use strict";
var h = Object.create;
var k = Object.defineProperty;
var c = Object.getOwnPropertyDescriptor;
var l = Object.getOwnPropertyNames;
var d = Object.getPrototypeOf, v = Object.prototype.hasOwnProperty;
var u = (o, s, r, e) => {
  if (s && typeof s == "object" || typeof s == "function")
    for (let a of l(s))
      !v.call(o, a) && a !== r && k(o, a, { get: () => s[a], enumerable: !(e = c(s, a)) || e.enumerable });
  return o;
};
var n = (o, s, r) => (r = o != null ? h(d(o)) : {}, u(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  s || !o || !o.__esModule ? k(r, "default", { value: o, enumerable: !0 }) : r,
  o
));

// src/bin/index.ts
var y = require("node:child_process"), i = require("node:fs"), b = require("node:path");

// src/common/versions.ts
var p = {
  "@storybook/addon-a11y": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/addon-docs": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/addon-jest": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/addon-links": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/addon-onboarding": "0.0.0-pr-31473-sha-09b29507",
  "storybook-addon-pseudo-states": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/addon-themes": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/addon-vitest": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/builder-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/builder-webpack5": "0.0.0-pr-31473-sha-09b29507",
  storybook: "0.0.0-pr-31473-sha-09b29507",
  "@storybook/angular": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/ember": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/html-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/nextjs": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/nextjs-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/preact-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/react-native-web-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/react-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/react-webpack5": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/server-webpack5": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/svelte-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/sveltekit": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/vue3-vite": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/web-components-vite": "0.0.0-pr-31473-sha-09b29507",
  sb: "0.0.0-pr-31473-sha-09b29507",
  "@storybook/cli": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/codemod": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/core-webpack": "0.0.0-pr-31473-sha-09b29507",
  "create-storybook": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/csf-plugin": "0.0.0-pr-31473-sha-09b29507",
  "eslint-plugin-storybook": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/react-dom-shim": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/preset-create-react-app": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/preset-react-webpack": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/preset-server-webpack": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/html": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/preact": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/react": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/server": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/svelte": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/vue3": "0.0.0-pr-31473-sha-09b29507",
  "@storybook/web-components": "0.0.0-pr-31473-sha-09b29507"
};

// src/bin/index.ts
var t = process.argv.slice(2);
if (["dev", "build", "index"].includes(t[0]))
  require("storybook/internal/cli/bin");
else {
  let o;
  if (t[0] === "init") {
    let r;
    try {
      r = require.resolve("create-storybook/package.json");
    } catch {
    }
    r ? JSON.parse((0, i.readFileSync)(r, "utf-8")).version === p["create-storybook"] && (o = [
      "node",
      (0, b.join)((0, b.dirname)(r), "bin", "index.cjs"),
      ...t.slice(1)
    ]) : o = ["npx", "--yes", `create-storybook@${p.storybook}`, ...t.slice(1)];
  } else {
    let r;
    try {
      r = require.resolve("@storybook/cli/package.json");
    } catch {
    }
    r ? JSON.parse((0, i.readFileSync)(r, "utf-8")).version === p["@storybook/cli"] && (o = ["node", (0, b.join)((0, b.dirname)(r), "bin", "\
index.cjs"), ...t]) : o = ["npx", "--yes", `@storybook/cli@${p.storybook}`, ...t];
  }
  o || (console.error("Could not run storybook cli, please report this as a bug"), process.exit(1)), (0, y.spawn)(o[0], o.slice(1), { stdio: "\
inherit", shell: !0 }).on("exit", (r) => {
    r != null && process.exit(r), process.exit(1);
  });
}
