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

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

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

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