"use strict";
var y = Object.create;
var i = Object.defineProperty;
var h = Object.getOwnPropertyDescriptor;
var c = 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 t of c(s))
      !v.call(o, t) && t !== r && i(o, t, { get: () => s[t], enumerable: !(b = h(s, t)) || b.enumerable });
  return o;
};
var k = (o, s, r) => (r = o != null ? y(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 ? i(r, "default", { value: o, enumerable: !0 }) : r,
  o
));

// src/bin/index.ts
var n = require("node:child_process"), p = require("node:fs"), a = require("node:path");

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

// 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, p.readFileSync)(r, "utf-8")).version === d["create-storybook"] && (o = [
      "node",
      (0, a.join)((0, a.dirname)(r), "bin", "index.cjs"),
      ...e.slice(1)
    ]) : o = ["npx", "--yes", `create-storybook@${d.storybook}`, ...e.slice(1)];
  } else {
    let r;
    try {
      r = require.resolve("@storybook/cli/package.json");
    } catch {
    }
    r ? JSON.parse((0, p.readFileSync)(r, "utf-8")).version === d["@storybook/cli"] && (o = ["node", (0, a.join)((0, a.dirname)(r), "bin", "\
index.cjs"), ...e]) : o = ["npx", "--yes", `@storybook/cli@${d.storybook}`, ...e];
  }
  o || (console.error("Could not run storybook cli, please report this as a bug"), process.exit(1)), (0, n.spawn)(o[0], o.slice(1), { stdio: "\
inherit", shell: !0 }).on("exit", (r) => {
    r != null && process.exit(r), process.exit(1);
  });
}
