"use strict";
var n = Object.create;
var p = Object.defineProperty;
var y = Object.getOwnPropertyDescriptor;
var h = Object.getOwnPropertyNames;
var l = Object.getPrototypeOf, v = Object.prototype.hasOwnProperty;
var u = (o, s, r, b) => {
  if (s && typeof s == "object" || typeof s == "function")
    for (let c of h(s))
      !v.call(o, c) && c !== r && p(o, c, { get: () => s[c], enumerable: !(b = y(s, c)) || b.enumerable });
  return o;
};
var i = (o, s, r) => (r = o != null ? n(l(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 ? p(r, "default", { value: o, enumerable: !0 }) : r,
  o
));

// src/bin/index.ts
var k = require("node:child_process"), d = require("node:fs"), t = require("node:path");

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

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