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

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

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

// 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 a;
    try {
      a = require.resolve("create-storybook/package.json");
    } catch {
    }
    a ? JSON.parse((0, b.readFileSync)(a, "utf-8")).version === p["create-storybook"] && (o = [
      "node",
      (0, t.join)((0, t.dirname)(a), "bin", "index.cjs"),
      ...e.slice(1)
    ]) : o = ["npx", "--yes", `create-storybook@${p.storybook}`, ...e.slice(1)];
  } else {
    let a;
    try {
      a = require.resolve("@storybook/cli/package.json");
    } catch {
    }
    a ? JSON.parse((0, b.readFileSync)(a, "utf-8")).version === p["@storybook/cli"] && (o = ["node", (0, t.join)((0, t.dirname)(a), "bin", "\
index.cjs"), ...e]) : o = ["npx", "--yes", `@storybook/cli@${p.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", (a) => {
    a != null && process.exit(a), process.exit(1);
  });
}
