"use strict";
var Ko = Object.create;
var G = Object.defineProperty;
var Xo = Object.getOwnPropertyDescriptor;
var Qo = Object.getOwnPropertyNames;
var Zo = Object.getPrototypeOf, es = Object.prototype.hasOwnProperty;
var o = (e, t) => G(e, "name", { value: t, configurable: !0 });
var ts = (e, t) => () => (e && (t = e(e = 0)), t);
var S = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), rs = (e, t) => {
  for (var r in t)
    G(e, r, { get: t[r], enumerable: !0 });
}, Ut = (e, t, r, n) => {
  if (t && typeof t == "object" || typeof t == "function")
    for (let s of Qo(t))
      !es.call(e, s) && s !== r && G(e, s, { get: () => t[s], enumerable: !(n = Xo(t, s)) || n.enumerable });
  return e;
};
var d = (e, t, r) => (r = e != null ? Ko(Zo(e)) : {}, Ut(
  // 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.
  t || !e || !e.__esModule ? G(r, "default", { value: e, enumerable: !0 }) : r,
  e
)), ns = (e) => Ut(G({}, "__esModule", { value: !0 }), e);

// ../node_modules/picocolors/picocolors.js
var Ht = S((Ta, De) => {
  var ne = process || {}, $t = ne.argv || [], re = ne.env || {}, os = !(re.NO_COLOR || $t.includes("--no-color")) && (!!re.FORCE_COLOR || $t.
  includes("--color") || ne.platform === "win32" || (ne.stdout || {}).isTTY && re.TERM !== "dumb" || !!re.CI), ss = /* @__PURE__ */ o((e, t, r = e) => (n) => {
    let s = "" + n, i = s.indexOf(t, e.length);
    return ~i ? e + is(s, t, r, i) + t : e + s + t;
  }, "formatter"), is = /* @__PURE__ */ o((e, t, r, n) => {
    let s = "", i = 0;
    do
      s += e.substring(i, n) + r, i = n + t.length, n = e.indexOf(t, i);
    while (~n);
    return s + e.substring(i);
  }, "replaceClose"), Wt = /* @__PURE__ */ o((e = os) => {
    let t = e ? ss : () => String;
    return {
      isColorSupported: e,
      reset: t("\x1B[0m", "\x1B[0m"),
      bold: t("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
      dim: t("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
      italic: t("\x1B[3m", "\x1B[23m"),
      underline: t("\x1B[4m", "\x1B[24m"),
      inverse: t("\x1B[7m", "\x1B[27m"),
      hidden: t("\x1B[8m", "\x1B[28m"),
      strikethrough: t("\x1B[9m", "\x1B[29m"),
      black: t("\x1B[30m", "\x1B[39m"),
      red: t("\x1B[31m", "\x1B[39m"),
      green: t("\x1B[32m", "\x1B[39m"),
      yellow: t("\x1B[33m", "\x1B[39m"),
      blue: t("\x1B[34m", "\x1B[39m"),
      magenta: t("\x1B[35m", "\x1B[39m"),
      cyan: t("\x1B[36m", "\x1B[39m"),
      white: t("\x1B[37m", "\x1B[39m"),
      gray: t("\x1B[90m", "\x1B[39m"),
      bgBlack: t("\x1B[40m", "\x1B[49m"),
      bgRed: t("\x1B[41m", "\x1B[49m"),
      bgGreen: t("\x1B[42m", "\x1B[49m"),
      bgYellow: t("\x1B[43m", "\x1B[49m"),
      bgBlue: t("\x1B[44m", "\x1B[49m"),
      bgMagenta: t("\x1B[45m", "\x1B[49m"),
      bgCyan: t("\x1B[46m", "\x1B[49m"),
      bgWhite: t("\x1B[47m", "\x1B[49m"),
      blackBright: t("\x1B[90m", "\x1B[39m"),
      redBright: t("\x1B[91m", "\x1B[39m"),
      greenBright: t("\x1B[92m", "\x1B[39m"),
      yellowBright: t("\x1B[93m", "\x1B[39m"),
      blueBright: t("\x1B[94m", "\x1B[39m"),
      magentaBright: t("\x1B[95m", "\x1B[39m"),
      cyanBright: t("\x1B[96m", "\x1B[39m"),
      whiteBright: t("\x1B[97m", "\x1B[39m"),
      bgBlackBright: t("\x1B[100m", "\x1B[49m"),
      bgRedBright: t("\x1B[101m", "\x1B[49m"),
      bgGreenBright: t("\x1B[102m", "\x1B[49m"),
      bgYellowBright: t("\x1B[103m", "\x1B[49m"),
      bgBlueBright: t("\x1B[104m", "\x1B[49m"),
      bgMagentaBright: t("\x1B[105m", "\x1B[49m"),
      bgCyanBright: t("\x1B[106m", "\x1B[49m"),
      bgWhiteBright: t("\x1B[107m", "\x1B[49m")
    };
  }, "createColors");
  De.exports = Wt();
  De.exports.createColors = Wt;
});

// ../node_modules/walk-up-path/dist/cjs/index.js
var Yt = S((se) => {
  "use strict";
  Object.defineProperty(se, "__esModule", { value: !0 });
  se.walkUp = void 0;
  var zt = require("path"), as = /* @__PURE__ */ o(function* (e) {
    for (e = (0, zt.resolve)(e); e; ) {
      yield e;
      let t = (0, zt.dirname)(e);
      if (t === e)
        break;
      e = t;
    }
  }, "walkUp");
  se.walkUp = as;
});

// ../node_modules/isexe/windows.js
var ar = S((Va, ir) => {
  ir.exports = sr;
  sr.sync = ds;
  var nr = require("fs");
  function ms(e, t) {
    var r = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
    if (!r || (r = r.split(";"), r.indexOf("") !== -1))
      return !0;
    for (var n = 0; n < r.length; n++) {
      var s = r[n].toLowerCase();
      if (s && e.substr(-s.length).toLowerCase() === s)
        return !0;
    }
    return !1;
  }
  o(ms, "checkPathExt");
  function or(e, t, r) {
    return !e.isSymbolicLink() && !e.isFile() ? !1 : ms(t, r);
  }
  o(or, "checkStat");
  function sr(e, t, r) {
    nr.stat(e, function(n, s) {
      r(n, n ? !1 : or(s, e, t));
    });
  }
  o(sr, "isexe");
  function ds(e, t) {
    return or(nr.statSync(e), e, t);
  }
  o(ds, "sync");
});

// ../node_modules/isexe/mode.js
var pr = S((za, lr) => {
  lr.exports = ur;
  ur.sync = ys;
  var cr = require("fs");
  function ur(e, t, r) {
    cr.stat(e, function(n, s) {
      r(n, n ? !1 : fr(s, t));
    });
  }
  o(ur, "isexe");
  function ys(e, t) {
    return fr(cr.statSync(e), t);
  }
  o(ys, "sync");
  function fr(e, t) {
    return e.isFile() && hs(e, t);
  }
  o(fr, "checkStat");
  function hs(e, t) {
    var r = e.mode, n = e.uid, s = e.gid, i = t.uid !== void 0 ? t.uid : process.getuid && process.getuid(), a = t.gid !== void 0 ? t.gid : process.
    getgid && process.getgid(), c = parseInt("100", 8), u = parseInt("010", 8), f = parseInt("001", 8), l = c | u, y = r & f || r & u && s ===
    a || r & c && n === i || r & l && i === 0;
    return y;
  }
  o(hs, "checkMode");
});

// ../node_modules/isexe/index.js
var dr = S((Xa, mr) => {
  var Ka = require("fs"), ae;
  process.platform === "win32" || global.TESTING_WINDOWS ? ae = ar() : ae = pr();
  mr.exports = He;
  He.sync = gs;
  function He(e, t, r) {
    if (typeof t == "function" && (r = t, t = {}), !r) {
      if (typeof Promise != "function")
        throw new TypeError("callback not provided");
      return new Promise(function(n, s) {
        He(e, t || {}, function(i, a) {
          i ? s(i) : n(a);
        });
      });
    }
    ae(e, t || {}, function(n, s) {
      n && (n.code === "EACCES" || t && t.ignoreErrors) && (n = null, s = !1), r(n, s);
    });
  }
  o(He, "isexe");
  function gs(e, t) {
    try {
      return ae.sync(e, t || {});
    } catch (r) {
      if (t && t.ignoreErrors || r.code === "EACCES")
        return !1;
      throw r;
    }
  }
  o(gs, "sync");
});

// ../node_modules/which/which.js
var wr = S((Za, Sr) => {
  var D = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", yr = require("path"), bs = D ? "\
;" : ":", hr = dr(), gr = /* @__PURE__ */ o((e) => Object.assign(new Error(`not found: ${e}`), { code: "ENOENT" }), "getNotFoundError"), br = /* @__PURE__ */ o(
  (e, t) => {
    let r = t.colon || bs, n = e.match(/\//) || D && e.match(/\\/) ? [""] : [
      // windows always checks the cwd first
      ...D ? [process.cwd()] : [],
      ...(t.path || process.env.PATH || /* istanbul ignore next: very unusual */
      "").split(r)
    ], s = D ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", i = D ? s.split(r) : [""];
    return D && e.indexOf(".") !== -1 && i[0] !== "" && i.unshift(""), {
      pathEnv: n,
      pathExt: i,
      pathExtExe: s
    };
  }, "getPathInfo"), xr = /* @__PURE__ */ o((e, t, r) => {
    typeof t == "function" && (r = t, t = {}), t || (t = {});
    let { pathEnv: n, pathExt: s, pathExtExe: i } = br(e, t), a = [], c = /* @__PURE__ */ o((f) => new Promise((l, y) => {
      if (f === n.length)
        return t.all && a.length ? l(a) : y(gr(e));
      let g = n[f], h = /^".*"$/.test(g) ? g.slice(1, -1) : g, b = yr.join(h, e), m = !h && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + b : b;
      l(u(m, f, 0));
    }), "step"), u = /* @__PURE__ */ o((f, l, y) => new Promise((g, h) => {
      if (y === s.length)
        return g(c(l + 1));
      let b = s[y];
      hr(f + b, { pathExt: i }, (m, x) => {
        if (!m && x)
          if (t.all)
            a.push(f + b);
          else
            return g(f + b);
        return g(u(f, l, y + 1));
      });
    }), "subStep");
    return r ? c(0).then((f) => r(null, f), r) : c(0);
  }, "which"), xs = /* @__PURE__ */ o((e, t) => {
    t = t || {};
    let { pathEnv: r, pathExt: n, pathExtExe: s } = br(e, t), i = [];
    for (let a = 0; a < r.length; a++) {
      let c = r[a], u = /^".*"$/.test(c) ? c.slice(1, -1) : c, f = yr.join(u, e), l = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + f : f;
      for (let y = 0; y < n.length; y++) {
        let g = l + n[y];
        try {
          if (hr.sync(g, { pathExt: s }))
            if (t.all)
              i.push(g);
            else
              return g;
        } catch {
        }
      }
    }
    if (t.all && i.length)
      return i;
    if (t.nothrow)
      return null;
    throw gr(e);
  }, "whichSync");
  Sr.exports = xr;
  xr.sync = xs;
});

// ../node_modules/path-key/index.js
var Er = S((tc, Je) => {
  "use strict";
  var kr = /* @__PURE__ */ o((e = {}) => {
    let t = e.env || process.env;
    return (e.platform || process.platform) !== "win32" ? "PATH" : Object.keys(t).reverse().find((n) => n.toUpperCase() === "PATH") || "Path";
  }, "pathKey");
  Je.exports = kr;
  Je.exports.default = kr;
});

// ../node_modules/cross-spawn/lib/util/resolveCommand.js
var Cr = S((nc, Tr) => {
  "use strict";
  var Pr = require("path"), Ss = wr(), ws = Er();
  function vr(e, t) {
    let r = e.options.env || process.env, n = process.cwd(), s = e.options.cwd != null, i = s && process.chdir !== void 0 && !process.chdir.
    disabled;
    if (i)
      try {
        process.chdir(e.options.cwd);
      } catch {
      }
    let a;
    try {
      a = Ss.sync(e.command, {
        path: r[ws({ env: r })],
        pathExt: t ? Pr.delimiter : void 0
      });
    } catch {
    } finally {
      i && process.chdir(n);
    }
    return a && (a = Pr.resolve(s ? e.options.cwd : "", a)), a;
  }
  o(vr, "resolveCommandAttempt");
  function ks(e) {
    return vr(e) || vr(e, !0);
  }
  o(ks, "resolveCommand");
  Tr.exports = ks;
});

// ../node_modules/cross-spawn/lib/util/escape.js
var Ir = S((sc, qe) => {
  "use strict";
  var Ve = /([()\][%!^"`<>&|;, *?])/g;
  function Es(e) {
    return e = e.replace(Ve, "^$1"), e;
  }
  o(Es, "escapeCommand");
  function Ps(e, t) {
    return e = `${e}`, e = e.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"'), e = e.replace(/(?=(\\+?)?)\1$/, "$1$1"), e = `"${e}"`, e = e.replace(Ve,
    "^$1"), t && (e = e.replace(Ve, "^$1")), e;
  }
  o(Ps, "escapeArgument");
  qe.exports.command = Es;
  qe.exports.argument = Ps;
});

// ../node_modules/shebang-regex/index.js
var Or = S((ac, Ar) => {
  "use strict";
  Ar.exports = /^#!(.*)/;
});

// ../node_modules/shebang-command/index.js
var Rr = S((cc, jr) => {
  "use strict";
  var vs = Or();
  jr.exports = (e = "") => {
    let t = e.match(vs);
    if (!t)
      return null;
    let [r, n] = t[0].replace(/#! ?/, "").split(" "), s = r.split("/").pop();
    return s === "env" ? n : n ? `${s} ${n}` : s;
  };
});

// ../node_modules/cross-spawn/lib/util/readShebang.js
var Dr = S((uc, Nr) => {
  "use strict";
  var ze = require("fs"), Ts = Rr();
  function Cs(e) {
    let r = Buffer.alloc(150), n;
    try {
      n = ze.openSync(e, "r"), ze.readSync(n, r, 0, 150, 0), ze.closeSync(n);
    } catch {
    }
    return Ts(r.toString());
  }
  o(Cs, "readShebang");
  Nr.exports = Cs;
});

// ../node_modules/cross-spawn/lib/parse.js
var Fr = S((lc, Lr) => {
  "use strict";
  var Is = require("path"), _r = Cr(), Mr = Ir(), As = Dr(), Os = process.platform === "win32", js = /\.(?:com|exe)$/i, Rs = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
  function Ns(e) {
    e.file = _r(e);
    let t = e.file && As(e.file);
    return t ? (e.args.unshift(e.file), e.command = t, _r(e)) : e.file;
  }
  o(Ns, "detectShebang");
  function Ds(e) {
    if (!Os)
      return e;
    let t = Ns(e), r = !js.test(t);
    if (e.options.forceShell || r) {
      let n = Rs.test(t);
      e.command = Is.normalize(e.command), e.command = Mr.command(e.command), e.args = e.args.map((i) => Mr.argument(i, n));
      let s = [e.command].concat(e.args).join(" ");
      e.args = ["/d", "/s", "/c", `"${s}"`], e.command = process.env.comspec || "cmd.exe", e.options.windowsVerbatimArguments = !0;
    }
    return e;
  }
  o(Ds, "parseNonShell");
  function _s(e, t, r) {
    t && !Array.isArray(t) && (r = t, t = null), t = t ? t.slice(0) : [], r = Object.assign({}, r);
    let n = {
      command: e,
      args: t,
      options: r,
      file: void 0,
      original: {
        command: e,
        args: t
      }
    };
    return r.shell ? n : Ds(n);
  }
  o(_s, "parse");
  Lr.exports = _s;
});

// ../node_modules/cross-spawn/lib/enoent.js
var Ur = S((mc, Gr) => {
  "use strict";
  var Ye = process.platform === "win32";
  function Ke(e, t) {
    return Object.assign(new Error(`${t} ${e.command} ENOENT`), {
      code: "ENOENT",
      errno: "ENOENT",
      syscall: `${t} ${e.command}`,
      path: e.command,
      spawnargs: e.args
    });
  }
  o(Ke, "notFoundError");
  function Ms(e, t) {
    if (!Ye)
      return;
    let r = e.emit;
    e.emit = function(n, s) {
      if (n === "exit") {
        let i = Br(s, t);
        if (i)
          return r.call(e, "error", i);
      }
      return r.apply(e, arguments);
    };
  }
  o(Ms, "hookChildProcess");
  function Br(e, t) {
    return Ye && e === 1 && !t.file ? Ke(t.original, "spawn") : null;
  }
  o(Br, "verifyENOENT");
  function Ls(e, t) {
    return Ye && e === 1 && !t.file ? Ke(t.original, "spawnSync") : null;
  }
  o(Ls, "verifyENOENTSync");
  Gr.exports = {
    hookChildProcess: Ms,
    verifyENOENT: Br,
    verifyENOENTSync: Ls,
    notFoundError: Ke
  };
});

// ../node_modules/cross-spawn/index.js
var Hr = S((yc, _) => {
  "use strict";
  var $r = require("child_process"), Xe = Fr(), Qe = Ur();
  function Wr(e, t, r) {
    let n = Xe(e, t, r), s = $r.spawn(n.command, n.args, n.options);
    return Qe.hookChildProcess(s, n), s;
  }
  o(Wr, "spawn");
  function Fs(e, t, r) {
    let n = Xe(e, t, r), s = $r.spawnSync(n.command, n.args, n.options);
    return s.error = s.error || Qe.verifyENOENTSync(s.status, n), s;
  }
  o(Fs, "spawnSync");
  _.exports = Wr;
  _.exports.spawn = Wr;
  _.exports.sync = Fs;
  _.exports._parse = Xe;
  _.exports._enoent = Qe;
});

// ../node_modules/merge-stream/index.js
var En = S((Ru, kn) => {
  "use strict";
  var { PassThrough: Oi } = require("stream");
  kn.exports = function() {
    var e = [], t = new Oi({ objectMode: !0 });
    return t.setMaxListeners(0), t.add = r, t.isEmpty = n, t.on("unpipe", s), Array.prototype.slice.call(arguments).forEach(r), t;
    function r(i) {
      return Array.isArray(i) ? (i.forEach(r), this) : (e.push(i), i.once("end", s.bind(null, i)), i.once("error", t.emit.bind(t, "error")),
      i.pipe(t, { end: !1 }), this);
    }
    o(r, "add");
    function n() {
      return e.length == 0;
    }
    o(n, "isEmpty");
    function s(i) {
      e = e.filter(function(a) {
        return a !== i;
      }), !e.length && t.readable && t.end();
    }
    o(s, "remove");
  };
});

// ../node_modules/slash/index.js
function Pt(e) {
  return e.startsWith("\\\\?\\") ? e : e.replace(/\\/g, "/");
}
var Xn = ts(() => {
  o(Pt, "slash");
});

// ../node_modules/common-path-prefix/index.js
var eo = S((mf, Zn) => {
  "use strict";
  var { sep: Hi } = require("path"), Ji = /* @__PURE__ */ o((e) => {
    for (let t of e) {
      let r = /(\/|\\)/.exec(t);
      if (r !== null) return r[0];
    }
    return Hi;
  }, "determineSeparator");
  Zn.exports = /* @__PURE__ */ o(function(t, r = Ji(t)) {
    let [n = "", ...s] = t;
    if (n === "" || s.length === 0) return "";
    let i = n.split(r), a = i.length;
    for (let u of s) {
      let f = u.split(r);
      for (let l = 0; l < a; l++)
        f[l] !== i[l] && (a = l);
      if (a === 0) return "";
    }
    let c = i.slice(0, a).join(r);
    return c.endsWith(r) ? c : c + r;
  }, "commonPathPrefix");
});

// ../node_modules/fetch-retry/index.js
var _o = S((hp, Do) => {
  "use strict";
  Do.exports = function(e, t) {
    if (t = t || {}, typeof e != "function")
      throw new C("fetch must be a function");
    if (typeof t != "object")
      throw new C("defaults must be an object");
    if (t.retries !== void 0 && !Ae(t.retries))
      throw new C("retries must be a positive integer");
    if (t.retryDelay !== void 0 && !Ae(t.retryDelay) && typeof t.retryDelay != "function")
      throw new C("retryDelay must be a positive integer or a function returning a positive integer");
    if (t.retryOn !== void 0 && !Array.isArray(t.retryOn) && typeof t.retryOn != "function")
      throw new C("retryOn property expects an array or function");
    var r = {
      retries: 3,
      retryDelay: 1e3,
      retryOn: []
    };
    return t = Object.assign(r, t), /* @__PURE__ */ o(function(s, i) {
      var a = t.retries, c = t.retryDelay, u = t.retryOn;
      if (i && i.retries !== void 0)
        if (Ae(i.retries))
          a = i.retries;
        else
          throw new C("retries must be a positive integer");
      if (i && i.retryDelay !== void 0)
        if (Ae(i.retryDelay) || typeof i.retryDelay == "function")
          c = i.retryDelay;
        else
          throw new C("retryDelay must be a positive integer or a function returning a positive integer");
      if (i && i.retryOn)
        if (Array.isArray(i.retryOn) || typeof i.retryOn == "function")
          u = i.retryOn;
        else
          throw new C("retryOn property expects an array or function");
      return new Promise(function(f, l) {
        var y = /* @__PURE__ */ o(function(h) {
          var b = typeof Request < "u" && s instanceof Request ? s.clone() : s;
          e(b, i).then(function(m) {
            if (Array.isArray(u) && u.indexOf(m.status) === -1)
              f(m);
            else if (typeof u == "function")
              try {
                return Promise.resolve(u(h, null, m)).then(function(x) {
                  x ? g(h, null, m) : f(m);
                }).catch(l);
              } catch (x) {
                l(x);
              }
            else
              h < a ? g(h, null, m) : f(m);
          }).catch(function(m) {
            if (typeof u == "function")
              try {
                Promise.resolve(u(h, m, null)).then(function(x) {
                  x ? g(h, m, null) : l(m);
                }).catch(function(x) {
                  l(x);
                });
              } catch (x) {
                l(x);
              }
            else h < a ? g(h, m, null) : l(m);
          });
        }, "wrappedFetch");
        function g(h, b, m) {
          var x = typeof c == "function" ? c(h, b, m) : c;
          setTimeout(function() {
            y(++h);
          }, x);
        }
        o(g, "retry"), y(0);
      });
    }, "fetchRetry");
  };
  function Ae(e) {
    return Number.isInteger(e) && e >= 0;
  }
  o(Ae, "isPositiveInteger");
  function C(e) {
    this.name = "ArgumentError", this.message = e;
  }
  o(C, "ArgumentError");
});

// src/telemetry/index.ts
var Pa = {};
rs(Pa, {
  addToGlobalContext: () => zo,
  cleanPaths: () => N,
  computeStorybookMetadata: () => No,
  getPrecedingUpgrade: () => Ho,
  getStorybookMetadata: () => Dt,
  isExampleStoryId: () => ka,
  metaFrameworks: () => Rt,
  oneWayHash: () => Oe,
  removeAnsiEscapeCodes: () => Me,
  sanitizeAddonName: () => Nt,
  sanitizeError: () => U,
  telemetry: () => Ea
});
module.exports = ns(Pa);
var Gt = require("storybook/internal/node-logger");

// src/telemetry/notify.ts
var _e = require("storybook/internal/common"), oe = d(Ht(), 1);
var Jt = "telemetry-notification-date", R = console, Vt = /* @__PURE__ */ o(async () => {
  await _e.cache.get(Jt, null) || (_e.cache.set(Jt, Date.now()), R.log(), R.log(
    `${oe.default.magenta(
      oe.default.bold("attention")
    )} => Storybook now collects completely anonymous telemetry regarding usage.`
  ), R.log("This information is used to shape Storybook's roadmap and prioritize features."), R.log(
    "You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:"
  ), R.log(oe.default.cyan("https://storybook.js.org/telemetry")), R.log());
}, "notify");

// src/telemetry/sanitize.ts
var Le = d(require("node:path"), 1);
function qt(e) {
  return e.replace(/[-[/{}()*+?.\\^$|]/g, "\\$&");
}
o(qt, "regexpEscape");
function Me(e = "") {
  return e.replace(/\u001B\[[0-9;]*m/g, "");
}
o(Me, "removeAnsiEscapeCodes");
function N(e, t = Le.default.sep) {
  if (!e)
    return e;
  let r = process.cwd().split(t);
  for (; r.length > 1; ) {
    let n = r.join(t), s = new RegExp(qt(n), "gi");
    e = e.replace(s, "$SNIP");
    let i = r.join(t + t), a = new RegExp(qt(i), "gi");
    e = e.replace(a, "$SNIP"), r.pop();
  }
  return e;
}
o(N, "cleanPaths");
function U(e, t = Le.default.sep) {
  try {
    e = {
      ...JSON.parse(JSON.stringify(e)),
      message: Me(e.message),
      stack: Me(e.stack),
      cause: e.cause,
      name: e.name
    };
    let r = N(JSON.stringify(e), t);
    return JSON.parse(r);
  } catch (r) {
    return `Sanitization error: ${r?.message}`;
  }
}
o(U, "sanitizeError");

// src/telemetry/storybook-metadata.ts
var jo = require("node:path"), P = require("storybook/internal/common"), Ro = require("storybook/internal/csf-tools");

// ../node_modules/fd-package-json/dist/esm/main.js
var Kt = d(Yt(), 1), Xt = require("node:path"), ie = require("node:fs/promises"), Qt = require("node:fs");
async function cs(e) {
  try {
    return (await (0, ie.stat)(e)).isFile();
  } catch {
    return !1;
  }
}
o(cs, "fileExists");
async function Fe(e) {
  for (let t of (0, Kt.walkUp)(e)) {
    let r = (0, Xt.resolve)(t, "package.json");
    if (await cs(r))
      return r;
  }
  return null;
}
o(Fe, "findPackagePath");
async function Zt(e) {
  let t = await Fe(e);
  if (!t)
    return null;
  try {
    let r = await (0, ie.readFile)(t, { encoding: "utf8" });
    return JSON.parse(r);
  } catch {
    return null;
  }
}
o(Zt, "findPackage");

// ../node_modules/package-manager-detector/dist/constants.mjs
var er = [
  "npm",
  "yarn",
  "yarn@berry",
  "pnpm",
  "pnpm@6",
  "bun",
  "deno"
], Be = {
  "bun.lock": "bun",
  "bun.lockb": "bun",
  "deno.lock": "deno",
  "pnpm-lock.yaml": "pnpm",
  "pnpm-workspace.yaml": "pnpm",
  "yarn.lock": "yarn",
  "package-lock.json": "npm",
  "npm-shrinkwrap.json": "npm"
}, Ge = {
  "node_modules/.deno/": "deno",
  "node_modules/.pnpm/": "pnpm",
  "node_modules/.yarn-state.yml": "yarn",
  // yarn v2+ (node-modules)
  "node_modules/.yarn_integrity": "yarn",
  // yarn v1
  "node_modules/.package-lock.json": "npm",
  ".pnp.cjs": "yarn",
  // yarn v3+ (pnp)
  ".pnp.js": "yarn",
  // yarn v2 (pnp)
  "bun.lock": "bun",
  "bun.lockb": "bun"
};

// ../node_modules/package-manager-detector/dist/detect.mjs
var $e = d(require("node:fs/promises"), 1), T = d(require("node:path"), 1), rr = d(require("node:process"), 1);
async function Ue(e, t) {
  try {
    let r = await $e.default.stat(e);
    return t === "file" ? r.isFile() : r.isDirectory();
  } catch {
    return !1;
  }
}
o(Ue, "pathExists");
function* us(e = rr.default.cwd()) {
  let t = T.default.resolve(e), { root: r } = T.default.parse(t);
  for (; t && t !== r; )
    yield t, t = T.default.dirname(t);
}
o(us, "lookup");
async function tr(e, t) {
  return !e || !Ue(e, "file") ? null : await ls(e, t);
}
o(tr, "parsePackageJson");
async function We(e = {}) {
  let { cwd: t, strategies: r = ["lockfile", "packageManager-field", "devEngines-field"], onUnknown: n } = e;
  for (let s of us(t))
    for (let i of r)
      switch (i) {
        case "lockfile": {
          for (let a of Object.keys(Be))
            if (await Ue(T.default.join(s, a), "file")) {
              let c = Be[a], u = await tr(T.default.join(s, "package.json"), n);
              return u || { name: c, agent: c };
            }
          break;
        }
        case "packageManager-field":
        case "devEngines-field": {
          let a = await tr(T.default.join(s, "package.json"), n);
          if (a)
            return a;
          break;
        }
        case "install-metadata": {
          for (let a of Object.keys(Ge)) {
            let c = a.endsWith("/") ? "dir" : "file";
            if (await Ue(T.default.join(s, a), c)) {
              let u = Ge[a], f = u === "yarn" ? ps(a) ? "yarn" : "yarn@berry" : u;
              return { name: u, agent: f };
            }
          }
          break;
        }
      }
  return null;
}
o(We, "detect");
function fs(e) {
  let t = /* @__PURE__ */ o((r) => r?.match(/\d+(\.\d+){0,2}/)?.[0] ?? r, "handelVer");
  if (typeof e.packageManager == "string") {
    let [r, n] = e.packageManager.replace(/^\^/, "").split("@");
    return { name: r, ver: t(n) };
  }
  if (typeof e.devEngines?.packageManager?.name == "string")
    return {
      name: e.devEngines.packageManager.name,
      ver: t(e.devEngines.packageManager.version)
    };
}
o(fs, "getNameAndVer");
async function ls(e, t) {
  try {
    let r = JSON.parse(await $e.default.readFile(e, "utf8")), n, s = fs(r);
    if (s) {
      let i = s.name, a = s.ver, c = a;
      return i === "yarn" && a && Number.parseInt(a) > 1 ? (n = "yarn@berry", c = "berry", { name: i, agent: n, version: c }) : i === "pnpm" &&
      a && Number.parseInt(a) < 7 ? (n = "pnpm@6", { name: i, agent: n, version: c }) : er.includes(i) ? (n = i, { name: i, agent: n, version: c }) :
      t?.(r.packageManager) ?? null;
    }
  } catch {
  }
  return null;
}
o(ls, "handlePackageManager");
function ps(e) {
  return e.endsWith(".yarn_integrity");
}
o(ps, "isMetadataYarnClassic");

// ../node_modules/package-manager-detector/dist/index.mjs
var Ua = require("node:fs/promises"), $a = require("node:path"), Wa = require("node:process");

// src/telemetry/get-application-file-count.ts
var go = require("node:path");

// src/telemetry/exec-command-count-lines.ts
var Kn = require("node:readline");

// node_modules/execa/index.js
var Wn = require("node:buffer"), Hn = d(require("node:path"), 1), we = d(require("node:child_process"), 1), J = d(require("node:process"), 1),
Jn = d(Hr(), 1);

// ../node_modules/strip-final-newline/index.js
function Ze(e) {
  let t = typeof e == "string" ? `
` : 10, r = typeof e == "string" ? "\r" : 13;
  return e[e.length - 1] === t && (e = e.slice(0, -1)), e[e.length - 1] === r && (e = e.slice(0, -1)), e;
}
o(Ze, "stripFinalNewline");

// node_modules/npm-run-path/index.js
var $ = d(require("node:process"), 1), M = d(require("node:path"), 1), et = require("node:url");

// node_modules/path-key/index.js
function ce(e = {}) {
  let {
    env: t = process.env,
    platform: r = process.platform
  } = e;
  return r !== "win32" ? "PATH" : Object.keys(t).reverse().find((n) => n.toUpperCase() === "PATH") || "Path";
}
o(ce, "pathKey");

// node_modules/npm-run-path/index.js
var Bs = /* @__PURE__ */ o(({
  cwd: e = $.default.cwd(),
  path: t = $.default.env[ce()],
  preferLocal: r = !0,
  execPath: n = $.default.execPath,
  addExecPath: s = !0
} = {}) => {
  let i = e instanceof URL ? (0, et.fileURLToPath)(e) : e, a = M.default.resolve(i), c = [];
  return r && Gs(c, a), s && Us(c, n, a), [...c, t].join(M.default.delimiter);
}, "npmRunPath"), Gs = /* @__PURE__ */ o((e, t) => {
  let r;
  for (; r !== t; )
    e.push(M.default.join(t, "node_modules/.bin")), r = t, t = M.default.resolve(t, "..");
}, "applyPreferLocal"), Us = /* @__PURE__ */ o((e, t, r) => {
  let n = t instanceof URL ? (0, et.fileURLToPath)(t) : t;
  e.push(M.default.resolve(r, n, ".."));
}, "applyExecPath"), Jr = /* @__PURE__ */ o(({ env: e = $.default.env, ...t } = {}) => {
  e = { ...e };
  let r = ce({ env: e });
  return t.path = e[r], e[r] = Bs(t), e;
}, "npmRunPathEnv");

// node_modules/mimic-fn/index.js
var $s = /* @__PURE__ */ o((e, t, r, n) => {
  if (r === "length" || r === "prototype" || r === "arguments" || r === "caller")
    return;
  let s = Object.getOwnPropertyDescriptor(e, r), i = Object.getOwnPropertyDescriptor(t, r);
  !Ws(s, i) && n || Object.defineProperty(e, r, i);
}, "copyProperty"), Ws = /* @__PURE__ */ o(function(e, t) {
  return e === void 0 || e.configurable || e.writable === t.writable && e.enumerable === t.enumerable && e.configurable === t.configurable &&
  (e.writable || e.value === t.value);
}, "canCopyProperty"), Hs = /* @__PURE__ */ o((e, t) => {
  let r = Object.getPrototypeOf(t);
  r !== Object.getPrototypeOf(e) && Object.setPrototypeOf(e, r);
}, "changePrototype"), Js = /* @__PURE__ */ o((e, t) => `/* Wrapped ${e}*/
${t}`, "wrappedToString"), Vs = Object.getOwnPropertyDescriptor(Function.prototype, "toString"), qs = Object.getOwnPropertyDescriptor(Function.
prototype.toString, "name"), zs = /* @__PURE__ */ o((e, t, r) => {
  let n = r === "" ? "" : `with ${r.trim()}() `, s = Js.bind(null, n, t.toString());
  Object.defineProperty(s, "name", qs), Object.defineProperty(e, "toString", { ...Vs, value: s });
}, "changeToString");
function tt(e, t, { ignoreNonConfigurable: r = !1 } = {}) {
  let { name: n } = e;
  for (let s of Reflect.ownKeys(t))
    $s(e, t, s, r);
  return Hs(e, t), zs(e, t, n), e;
}
o(tt, "mimicFunction");

// node_modules/onetime/index.js
var ue = /* @__PURE__ */ new WeakMap(), Vr = /* @__PURE__ */ o((e, t = {}) => {
  if (typeof e != "function")
    throw new TypeError("Expected a function");
  let r, n = 0, s = e.displayName || e.name || "<anonymous>", i = /* @__PURE__ */ o(function(...a) {
    if (ue.set(i, ++n), n === 1)
      r = e.apply(this, a), e = null;
    else if (t.throw === !0)
      throw new Error(`Function \`${s}\` can only be called once`);
    return r;
  }, "onetime");
  return tt(i, e), ue.set(i, n), i;
}, "onetime");
Vr.callCount = (e) => {
  if (!ue.has(e))
    throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);
  return ue.get(e);
};
var qr = Vr;

// node_modules/execa/lib/error.js
var en = d(require("node:process"), 1);

// node_modules/human-signals/build/src/main.js
var Qr = require("node:os");

// node_modules/human-signals/build/src/realtime.js
var zr = /* @__PURE__ */ o(() => {
  let e = rt - Yr + 1;
  return Array.from({ length: e }, Ys);
}, "getRealtimeSignals"), Ys = /* @__PURE__ */ o((e, t) => ({
  name: `SIGRT${t + 1}`,
  number: Yr + t,
  action: "terminate",
  description: "Application-specific signal (realtime)",
  standard: "posix"
}), "getRealtimeSignal"), Yr = 34, rt = 64;

// node_modules/human-signals/build/src/signals.js
var Xr = require("node:os");

// node_modules/human-signals/build/src/core.js
var Kr = [
  {
    name: "SIGHUP",
    number: 1,
    action: "terminate",
    description: "Terminal closed",
    standard: "posix"
  },
  {
    name: "SIGINT",
    number: 2,
    action: "terminate",
    description: "User interruption with CTRL-C",
    standard: "ansi"
  },
  {
    name: "SIGQUIT",
    number: 3,
    action: "core",
    description: "User interruption with CTRL-\\",
    standard: "posix"
  },
  {
    name: "SIGILL",
    number: 4,
    action: "core",
    description: "Invalid machine instruction",
    standard: "ansi"
  },
  {
    name: "SIGTRAP",
    number: 5,
    action: "core",
    description: "Debugger breakpoint",
    standard: "posix"
  },
  {
    name: "SIGABRT",
    number: 6,
    action: "core",
    description: "Aborted",
    standard: "ansi"
  },
  {
    name: "SIGIOT",
    number: 6,
    action: "core",
    description: "Aborted",
    standard: "bsd"
  },
  {
    name: "SIGBUS",
    number: 7,
    action: "core",
    description: "Bus error due to misaligned, non-existing address or paging error",
    standard: "bsd"
  },
  {
    name: "SIGEMT",
    number: 7,
    action: "terminate",
    description: "Command should be emulated but is not implemented",
    standard: "other"
  },
  {
    name: "SIGFPE",
    number: 8,
    action: "core",
    description: "Floating point arithmetic error",
    standard: "ansi"
  },
  {
    name: "SIGKILL",
    number: 9,
    action: "terminate",
    description: "Forced termination",
    standard: "posix",
    forced: !0
  },
  {
    name: "SIGUSR1",
    number: 10,
    action: "terminate",
    description: "Application-specific signal",
    standard: "posix"
  },
  {
    name: "SIGSEGV",
    number: 11,
    action: "core",
    description: "Segmentation fault",
    standard: "ansi"
  },
  {
    name: "SIGUSR2",
    number: 12,
    action: "terminate",
    description: "Application-specific signal",
    standard: "posix"
  },
  {
    name: "SIGPIPE",
    number: 13,
    action: "terminate",
    description: "Broken pipe or socket",
    standard: "posix"
  },
  {
    name: "SIGALRM",
    number: 14,
    action: "terminate",
    description: "Timeout or timer",
    standard: "posix"
  },
  {
    name: "SIGTERM",
    number: 15,
    action: "terminate",
    description: "Termination",
    standard: "ansi"
  },
  {
    name: "SIGSTKFLT",
    number: 16,
    action: "terminate",
    description: "Stack is empty or overflowed",
    standard: "other"
  },
  {
    name: "SIGCHLD",
    number: 17,
    action: "ignore",
    description: "Child process terminated, paused or unpaused",
    standard: "posix"
  },
  {
    name: "SIGCLD",
    number: 17,
    action: "ignore",
    description: "Child process terminated, paused or unpaused",
    standard: "other"
  },
  {
    name: "SIGCONT",
    number: 18,
    action: "unpause",
    description: "Unpaused",
    standard: "posix",
    forced: !0
  },
  {
    name: "SIGSTOP",
    number: 19,
    action: "pause",
    description: "Paused",
    standard: "posix",
    forced: !0
  },
  {
    name: "SIGTSTP",
    number: 20,
    action: "pause",
    description: 'Paused using CTRL-Z or "suspend"',
    standard: "posix"
  },
  {
    name: "SIGTTIN",
    number: 21,
    action: "pause",
    description: "Background process cannot read terminal input",
    standard: "posix"
  },
  {
    name: "SIGBREAK",
    number: 21,
    action: "terminate",
    description: "User interruption with CTRL-BREAK",
    standard: "other"
  },
  {
    name: "SIGTTOU",
    number: 22,
    action: "pause",
    description: "Background process cannot write to terminal output",
    standard: "posix"
  },
  {
    name: "SIGURG",
    number: 23,
    action: "ignore",
    description: "Socket received out-of-band data",
    standard: "bsd"
  },
  {
    name: "SIGXCPU",
    number: 24,
    action: "core",
    description: "Process timed out",
    standard: "bsd"
  },
  {
    name: "SIGXFSZ",
    number: 25,
    action: "core",
    description: "File too big",
    standard: "bsd"
  },
  {
    name: "SIGVTALRM",
    number: 26,
    action: "terminate",
    description: "Timeout or timer",
    standard: "bsd"
  },
  {
    name: "SIGPROF",
    number: 27,
    action: "terminate",
    description: "Timeout or timer",
    standard: "bsd"
  },
  {
    name: "SIGWINCH",
    number: 28,
    action: "ignore",
    description: "Terminal window size changed",
    standard: "bsd"
  },
  {
    name: "SIGIO",
    number: 29,
    action: "terminate",
    description: "I/O is available",
    standard: "other"
  },
  {
    name: "SIGPOLL",
    number: 29,
    action: "terminate",
    description: "Watched event",
    standard: "other"
  },
  {
    name: "SIGINFO",
    number: 29,
    action: "ignore",
    description: "Request for process information",
    standard: "other"
  },
  {
    name: "SIGPWR",
    number: 30,
    action: "terminate",
    description: "Device running out of power",
    standard: "systemv"
  },
  {
    name: "SIGSYS",
    number: 31,
    action: "core",
    description: "Invalid system call",
    standard: "other"
  },
  {
    name: "SIGUNUSED",
    number: 31,
    action: "terminate",
    description: "Invalid system call",
    standard: "other"
  }
];

// node_modules/human-signals/build/src/signals.js
var nt = /* @__PURE__ */ o(() => {
  let e = zr();
  return [...Kr, ...e].map(Ks);
}, "getSignals"), Ks = /* @__PURE__ */ o(({
  name: e,
  number: t,
  description: r,
  action: n,
  forced: s = !1,
  standard: i
}) => {
  let {
    signals: { [e]: a }
  } = Xr.constants, c = a !== void 0;
  return { name: e, number: c ? a : t, description: r, supported: c, action: n, forced: s, standard: i };
}, "normalizeSignal");

// node_modules/human-signals/build/src/main.js
var Xs = /* @__PURE__ */ o(() => {
  let e = nt();
  return Object.fromEntries(e.map(Qs));
}, "getSignalsByName"), Qs = /* @__PURE__ */ o(({
  name: e,
  number: t,
  description: r,
  supported: n,
  action: s,
  forced: i,
  standard: a
}) => [e, { name: e, number: t, description: r, supported: n, action: s, forced: i, standard: a }], "getSignalByName"), Zr = Xs(), Zs = /* @__PURE__ */ o(
() => {
  let e = nt(), t = rt + 1, r = Array.from(
    { length: t },
    (n, s) => ei(s, e)
  );
  return Object.assign({}, ...r);
}, "getSignalsByNumber"), ei = /* @__PURE__ */ o((e, t) => {
  let r = ti(e, t);
  if (r === void 0)
    return {};
  let { name: n, description: s, supported: i, action: a, forced: c, standard: u } = r;
  return {
    [e]: {
      name: n,
      number: e,
      description: s,
      supported: i,
      action: a,
      forced: c,
      standard: u
    }
  };
}, "getSignalByNumber"), ti = /* @__PURE__ */ o((e, t) => {
  let r = t.find(({ name: n }) => Qr.constants.signals[n] === e);
  return r !== void 0 ? r : t.find((n) => n.number === e);
}, "findSignalByNumber"), Fc = Zs();

// node_modules/execa/lib/error.js
var ri = /* @__PURE__ */ o(({ timedOut: e, timeout: t, errorCode: r, signal: n, signalDescription: s, exitCode: i, isCanceled: a }) => e ? `\
timed out after ${t} milliseconds` : a ? "was canceled" : r !== void 0 ? `failed with ${r}` : n !== void 0 ? `was killed with ${n} (${s})` :
i !== void 0 ? `failed with exit code ${i}` : "failed", "getErrorPrefix"), W = /* @__PURE__ */ o(({
  stdout: e,
  stderr: t,
  all: r,
  error: n,
  signal: s,
  exitCode: i,
  command: a,
  escapedCommand: c,
  timedOut: u,
  isCanceled: f,
  killed: l,
  parsed: { options: { timeout: y, cwd: g = en.default.cwd() } }
}) => {
  i = i === null ? void 0 : i, s = s === null ? void 0 : s;
  let h = s === void 0 ? void 0 : Zr[s].description, b = n && n.code, x = `Command ${ri({ timedOut: u, timeout: y, errorCode: b, signal: s, signalDescription: h,
  exitCode: i, isCanceled: f })}: ${a}`, O = Object.prototype.toString.call(n) === "[object Error]", v = O ? `${x}
${n.message}` : x, j = [v, t, e].filter(Boolean).join(`
`);
  return O ? (n.originalMessage = n.message, n.message = j) : n = new Error(j), n.shortMessage = v, n.command = a, n.escapedCommand = c, n.exitCode =
  i, n.signal = s, n.signalDescription = h, n.stdout = e, n.stderr = t, n.cwd = g, r !== void 0 && (n.all = r), "bufferedData" in n && delete n.
  bufferedData, n.failed = !0, n.timedOut = !!u, n.isCanceled = f, n.killed = l && !u, n;
}, "makeError");

// node_modules/execa/lib/stdio.js
var fe = ["stdin", "stdout", "stderr"], ni = /* @__PURE__ */ o((e) => fe.some((t) => e[t] !== void 0), "hasAlias"), tn = /* @__PURE__ */ o((e) => {
  if (!e)
    return;
  let { stdio: t } = e;
  if (t === void 0)
    return fe.map((n) => e[n]);
  if (ni(e))
    throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${fe.map((n) => `\`${n}\``).join(", ")}`);
  if (typeof t == "string")
    return t;
  if (!Array.isArray(t))
    throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);
  let r = Math.max(t.length, fe.length);
  return Array.from({ length: r }, (n, s) => t[s]);
}, "normalizeStdio");

// node_modules/execa/lib/kill.js
var nn = d(require("node:os"), 1);

// node_modules/signal-exit/dist/mjs/signals.js
var I = [];
I.push("SIGHUP", "SIGINT", "SIGTERM");
process.platform !== "win32" && I.push(
  "SIGALRM",
  "SIGABRT",
  "SIGVTALRM",
  "SIGXCPU",
  "SIGXFSZ",
  "SIGUSR2",
  "SIGTRAP",
  "SIGSYS",
  "SIGQUIT",
  "SIGIOT"
  // should detect profiler and enable/disable accordingly.
  // see #21
  // 'SIGPROF'
);
process.platform === "linux" && I.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");

// node_modules/signal-exit/dist/mjs/index.js
var le = /* @__PURE__ */ o((e) => !!e && typeof e == "object" && typeof e.removeListener == "function" && typeof e.emit == "function" && typeof e.
reallyExit == "function" && typeof e.listeners == "function" && typeof e.kill == "function" && typeof e.pid == "number" && typeof e.on == "f\
unction", "processOk"), ot = Symbol.for("signal-exit emitter"), st = globalThis, oi = Object.defineProperty.bind(Object), it = class {
  static {
    o(this, "Emitter");
  }
  emitted = {
    afterExit: !1,
    exit: !1
  };
  listeners = {
    afterExit: [],
    exit: []
  };
  count = 0;
  id = Math.random();
  constructor() {
    if (st[ot])
      return st[ot];
    oi(st, ot, {
      value: this,
      writable: !1,
      enumerable: !1,
      configurable: !1
    });
  }
  on(t, r) {
    this.listeners[t].push(r);
  }
  removeListener(t, r) {
    let n = this.listeners[t], s = n.indexOf(r);
    s !== -1 && (s === 0 && n.length === 1 ? n.length = 0 : n.splice(s, 1));
  }
  emit(t, r, n) {
    if (this.emitted[t])
      return !1;
    this.emitted[t] = !0;
    let s = !1;
    for (let i of this.listeners[t])
      s = i(r, n) === !0 || s;
    return t === "exit" && (s = this.emit("afterExit", r, n) || s), s;
  }
}, pe = class {
  static {
    o(this, "SignalExitBase");
  }
}, si = /* @__PURE__ */ o((e) => ({
  onExit(t, r) {
    return e.onExit(t, r);
  },
  load() {
    return e.load();
  },
  unload() {
    return e.unload();
  }
}), "signalExitWrap"), at = class extends pe {
  static {
    o(this, "SignalExitFallback");
  }
  onExit() {
    return () => {
    };
  }
  load() {
  }
  unload() {
  }
}, ct = class extends pe {
  static {
    o(this, "SignalExit");
  }
  // "SIGHUP" throws an `ENOSYS` error on Windows,
  // so use a supported signal instead
  /* c8 ignore start */
  #i = ut.platform === "win32" ? "SIGINT" : "SIGHUP";
  /* c8 ignore stop */
  #t = new it();
  #e;
  #o;
  #s;
  #n = {};
  #r = !1;
  constructor(t) {
    super(), this.#e = t, this.#n = {};
    for (let r of I)
      this.#n[r] = () => {
        let n = this.#e.listeners(r), { count: s } = this.#t, i = t;
        if (typeof i.__signal_exit_emitter__ == "object" && typeof i.__signal_exit_emitter__.count == "number" && (s += i.__signal_exit_emitter__.
        count), n.length === s) {
          this.unload();
          let a = this.#t.emit("exit", null, r), c = r === "SIGHUP" ? this.#i : r;
          a || t.kill(t.pid, c);
        }
      };
    this.#s = t.reallyExit, this.#o = t.emit;
  }
  onExit(t, r) {
    if (!le(this.#e))
      return () => {
      };
    this.#r === !1 && this.load();
    let n = r?.alwaysLast ? "afterExit" : "exit";
    return this.#t.on(n, t), () => {
      this.#t.removeListener(n, t), this.#t.listeners.exit.length === 0 && this.#t.listeners.afterExit.length === 0 && this.unload();
    };
  }
  load() {
    if (!this.#r) {
      this.#r = !0, this.#t.count += 1;
      for (let t of I)
        try {
          let r = this.#n[t];
          r && this.#e.on(t, r);
        } catch {
        }
      this.#e.emit = (t, ...r) => this.#c(t, ...r), this.#e.reallyExit = (t) => this.#a(t);
    }
  }
  unload() {
    this.#r && (this.#r = !1, I.forEach((t) => {
      let r = this.#n[t];
      if (!r)
        throw new Error("Listener not defined for signal: " + t);
      try {
        this.#e.removeListener(t, r);
      } catch {
      }
    }), this.#e.emit = this.#o, this.#e.reallyExit = this.#s, this.#t.count -= 1);
  }
  #a(t) {
    return le(this.#e) ? (this.#e.exitCode = t || 0, this.#t.emit("exit", this.#e.exitCode, null), this.#s.call(this.#e, this.#e.exitCode)) :
    0;
  }
  #c(t, ...r) {
    let n = this.#o;
    if (t === "exit" && le(this.#e)) {
      typeof r[0] == "number" && (this.#e.exitCode = r[0]);
      let s = n.call(this.#e, t, ...r);
      return this.#t.emit("exit", this.#e.exitCode, null), s;
    } else
      return n.call(this.#e, t, ...r);
  }
}, ut = globalThis.process, {
  /**
   * Called when the process is exiting, whether via signal, explicit
   * exit, or running out of stuff to do.
   *
   * If the global process object is not suitable for instrumentation,
   * then this will be a no-op.
   *
   * Returns a function that may be used to unload signal-exit.
   */
  onExit: rn,
  /**
   * Load the listeners.  Likely you never need to call this, unless
   * doing a rather deep integration with signal-exit functionality.
   * Mostly exposed for the benefit of testing.
   *
   * @internal
   */
  load: zc,
  /**
   * Unload the listeners.  Likely you never need to call this, unless
   * doing a rather deep integration with signal-exit functionality.
   * Mostly exposed for the benefit of testing.
   *
   * @internal
   */
  unload: Yc
} = si(le(ut) ? new ct(ut) : new at());

// node_modules/execa/lib/kill.js
var ii = 1e3 * 5, on = /* @__PURE__ */ o((e, t = "SIGTERM", r = {}) => {
  let n = e(t);
  return ai(e, t, r, n), n;
}, "spawnedKill"), ai = /* @__PURE__ */ o((e, t, r, n) => {
  if (!ci(t, r, n))
    return;
  let s = fi(r), i = setTimeout(() => {
    e("SIGKILL");
  }, s);
  i.unref && i.unref();
}, "setKillTimeout"), ci = /* @__PURE__ */ o((e, { forceKillAfterTimeout: t }, r) => ui(e) && t !== !1 && r, "shouldForceKill"), ui = /* @__PURE__ */ o(
(e) => e === nn.default.constants.signals.SIGTERM || typeof e == "string" && e.toUpperCase() === "SIGTERM", "isSigterm"), fi = /* @__PURE__ */ o(
({ forceKillAfterTimeout: e = !0 }) => {
  if (e === !0)
    return ii;
  if (!Number.isFinite(e) || e < 0)
    throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);
  return e;
}, "getForceKillAfterTimeout"), sn = /* @__PURE__ */ o((e, t) => {
  e.kill() && (t.isCanceled = !0);
}, "spawnedCancel"), li = /* @__PURE__ */ o((e, t, r) => {
  e.kill(t), r(Object.assign(new Error("Timed out"), { timedOut: !0, signal: t }));
}, "timeoutKill"), an = /* @__PURE__ */ o((e, { timeout: t, killSignal: r = "SIGTERM" }, n) => {
  if (t === 0 || t === void 0)
    return n;
  let s, i = new Promise((c, u) => {
    s = setTimeout(() => {
      li(e, r, u);
    }, t);
  }), a = n.finally(() => {
    clearTimeout(s);
  });
  return Promise.race([i, a]);
}, "setupTimeout"), cn = /* @__PURE__ */ o(({ timeout: e }) => {
  if (e !== void 0 && (!Number.isFinite(e) || e < 0))
    throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);
}, "validateTimeout"), un = /* @__PURE__ */ o(async (e, { cleanup: t, detached: r }, n) => {
  if (!t || r)
    return n;
  let s = rn(() => {
    e.kill();
  });
  return n.finally(() => {
    s();
  });
}, "setExitHandler");

// node_modules/execa/lib/pipe.js
var fn = require("node:fs"), ln = require("node:child_process");

// node_modules/is-stream/index.js
function me(e) {
  return e !== null && typeof e == "object" && typeof e.pipe == "function";
}
o(me, "isStream");
function ft(e) {
  return me(e) && e.writable !== !1 && typeof e._write == "function" && typeof e._writableState == "object";
}
o(ft, "isWritableStream");

// node_modules/execa/lib/pipe.js
var pi = /* @__PURE__ */ o((e) => e instanceof ln.ChildProcess && typeof e.then == "function", "isExecaChildProcess"), lt = /* @__PURE__ */ o(
(e, t, r) => {
  if (typeof r == "string")
    return e[t].pipe((0, fn.createWriteStream)(r)), e;
  if (ft(r))
    return e[t].pipe(r), e;
  if (!pi(r))
    throw new TypeError("The second argument must be a string, a stream or an Execa child process.");
  if (!ft(r.stdin))
    throw new TypeError("The target child process's stdin must be available.");
  return e[t].pipe(r.stdin), r;
}, "pipeToTarget"), pn = /* @__PURE__ */ o((e) => {
  e.stdout !== null && (e.pipeStdout = lt.bind(void 0, e, "stdout")), e.stderr !== null && (e.pipeStderr = lt.bind(void 0, e, "stderr")), e.
  all !== void 0 && (e.pipeAll = lt.bind(void 0, e, "all"));
}, "addPipeMethods");

// node_modules/execa/lib/stream.js
var xe = require("node:fs"), Pn = require("node:timers/promises");

// node_modules/get-stream/source/contents.js
var H = /* @__PURE__ */ o(async (e, { init: t, convertChunk: r, getSize: n, truncateChunk: s, addChunk: i, getFinalChunk: a, finalize: c }, {
maxBuffer: u = Number.POSITIVE_INFINITY } = {}) => {
  if (!di(e))
    throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");
  let f = t();
  f.length = 0;
  try {
    for await (let l of e) {
      let y = yi(l), g = r[y](l, f);
      yn({ convertedChunk: g, state: f, getSize: n, truncateChunk: s, addChunk: i, maxBuffer: u });
    }
    return mi({ state: f, convertChunk: r, getSize: n, truncateChunk: s, addChunk: i, getFinalChunk: a, maxBuffer: u }), c(f);
  } catch (l) {
    throw l.bufferedData = c(f), l;
  }
}, "getStreamContents"), mi = /* @__PURE__ */ o(({ state: e, getSize: t, truncateChunk: r, addChunk: n, getFinalChunk: s, maxBuffer: i }) => {
  let a = s(e);
  a !== void 0 && yn({ convertedChunk: a, state: e, getSize: t, truncateChunk: r, addChunk: n, maxBuffer: i });
}, "appendFinalChunk"), yn = /* @__PURE__ */ o(({ convertedChunk: e, state: t, getSize: r, truncateChunk: n, addChunk: s, maxBuffer: i }) => {
  let a = r(e), c = t.length + a;
  if (c <= i) {
    mn(e, t, s, c);
    return;
  }
  let u = n(e, i - t.length);
  throw u !== void 0 && mn(u, t, s, i), new de();
}, "appendChunk"), mn = /* @__PURE__ */ o((e, t, r, n) => {
  t.contents = r(e, t, n), t.length = n;
}, "addNewChunk"), di = /* @__PURE__ */ o((e) => typeof e == "object" && e !== null && typeof e[Symbol.asyncIterator] == "function", "isAsyn\
cIterable"), yi = /* @__PURE__ */ o((e) => {
  let t = typeof e;
  if (t === "string")
    return "string";
  if (t !== "object" || e === null)
    return "others";
  if (globalThis.Buffer?.isBuffer(e))
    return "buffer";
  let r = dn.call(e);
  return r === "[object ArrayBuffer]" ? "arrayBuffer" : r === "[object DataView]" ? "dataView" : Number.isInteger(e.byteLength) && Number.isInteger(
  e.byteOffset) && dn.call(e.buffer) === "[object ArrayBuffer]" ? "typedArray" : "others";
}, "getChunkType"), { toString: dn } = Object.prototype, de = class extends Error {
  static {
    o(this, "MaxBufferError");
  }
  name = "MaxBufferError";
  constructor() {
    super("maxBuffer exceeded");
  }
};

// node_modules/get-stream/source/utils.js
var pt = /* @__PURE__ */ o((e) => e, "identity"), mt = /* @__PURE__ */ o(() => {
}, "noop"), dt = /* @__PURE__ */ o(({ contents: e }) => e, "getContentsProp"), ye = /* @__PURE__ */ o((e) => {
  throw new Error(`Streams in object mode are not supported: ${String(e)}`);
}, "throwObjectStream"), he = /* @__PURE__ */ o((e) => e.length, "getLengthProp");

// node_modules/get-stream/source/array-buffer.js
async function yt(e, t) {
  return H(e, Pi, t);
}
o(yt, "getStreamAsArrayBuffer");
var hi = /* @__PURE__ */ o(() => ({ contents: new ArrayBuffer(0) }), "initArrayBuffer"), gi = /* @__PURE__ */ o((e) => bi.encode(e), "useTex\
tEncoder"), bi = new TextEncoder(), hn = /* @__PURE__ */ o((e) => new Uint8Array(e), "useUint8Array"), gn = /* @__PURE__ */ o((e) => new Uint8Array(
e.buffer, e.byteOffset, e.byteLength), "useUint8ArrayWithOffset"), xi = /* @__PURE__ */ o((e, t) => e.slice(0, t), "truncateArrayBufferChunk"),
Si = /* @__PURE__ */ o((e, { contents: t, length: r }, n) => {
  let s = Sn() ? ki(t, n) : wi(t, n);
  return new Uint8Array(s).set(e, r), s;
}, "addArrayBufferChunk"), wi = /* @__PURE__ */ o((e, t) => {
  if (t <= e.byteLength)
    return e;
  let r = new ArrayBuffer(xn(t));
  return new Uint8Array(r).set(new Uint8Array(e), 0), r;
}, "resizeArrayBufferSlow"), ki = /* @__PURE__ */ o((e, t) => {
  if (t <= e.maxByteLength)
    return e.resize(t), e;
  let r = new ArrayBuffer(t, { maxByteLength: xn(t) });
  return new Uint8Array(r).set(new Uint8Array(e), 0), r;
}, "resizeArrayBuffer"), xn = /* @__PURE__ */ o((e) => bn ** Math.ceil(Math.log(e) / Math.log(bn)), "getNewContentsLength"), bn = 2, Ei = /* @__PURE__ */ o(
({ contents: e, length: t }) => Sn() ? e : e.slice(0, t), "finalizeArrayBuffer"), Sn = /* @__PURE__ */ o(() => "resize" in ArrayBuffer.prototype,
"hasArrayBufferResize"), Pi = {
  init: hi,
  convertChunk: {
    string: gi,
    buffer: hn,
    arrayBuffer: hn,
    dataView: gn,
    typedArray: gn,
    others: ye
  },
  getSize: he,
  truncateChunk: xi,
  addChunk: Si,
  getFinalChunk: mt,
  finalize: Ei
};

// node_modules/get-stream/source/buffer.js
async function ge(e, t) {
  if (!("Buffer" in globalThis))
    throw new Error("getStreamAsBuffer() is only supported in Node.js");
  try {
    return wn(await yt(e, t));
  } catch (r) {
    throw r.bufferedData !== void 0 && (r.bufferedData = wn(r.bufferedData)), r;
  }
}
o(ge, "getStreamAsBuffer");
var wn = /* @__PURE__ */ o((e) => globalThis.Buffer.from(e), "arrayBufferToNodeBuffer");

// node_modules/get-stream/source/string.js
async function ht(e, t) {
  return H(e, Ai, t);
}
o(ht, "getStreamAsString");
var vi = /* @__PURE__ */ o(() => ({ contents: "", textDecoder: new TextDecoder() }), "initString"), be = /* @__PURE__ */ o((e, { textDecoder: t }) => t.
decode(e, { stream: !0 }), "useTextDecoder"), Ti = /* @__PURE__ */ o((e, { contents: t }) => t + e, "addStringChunk"), Ci = /* @__PURE__ */ o(
(e, t) => e.slice(0, t), "truncateStringChunk"), Ii = /* @__PURE__ */ o(({ textDecoder: e }) => {
  let t = e.decode();
  return t === "" ? void 0 : t;
}, "getFinalStringChunk"), Ai = {
  init: vi,
  convertChunk: {
    string: pt,
    buffer: be,
    arrayBuffer: be,
    dataView: be,
    typedArray: be,
    others: ye
  },
  getSize: he,
  truncateChunk: Ci,
  addChunk: Ti,
  getFinalChunk: Ii,
  finalize: dt
};

// node_modules/execa/lib/stream.js
var vn = d(En(), 1);
var Tn = /* @__PURE__ */ o((e) => {
  if (e !== void 0)
    throw new TypeError("The `input` and `inputFile` options cannot be both set.");
}, "validateInputOptions"), ji = /* @__PURE__ */ o(({ input: e, inputFile: t }) => typeof t != "string" ? e : (Tn(e), (0, xe.readFileSync)(t)),
"getInputSync"), Cn = /* @__PURE__ */ o((e) => {
  let t = ji(e);
  if (me(t))
    throw new TypeError("The `input` option cannot be a stream in sync mode");
  return t;
}, "handleInputSync"), Ri = /* @__PURE__ */ o(({ input: e, inputFile: t }) => typeof t != "string" ? e : (Tn(e), (0, xe.createReadStream)(t)),
"getInput"), In = /* @__PURE__ */ o((e, t) => {
  let r = Ri(t);
  r !== void 0 && (me(r) ? r.pipe(e.stdin) : e.stdin.end(r));
}, "handleInput"), An = /* @__PURE__ */ o((e, { all: t }) => {
  if (!t || !e.stdout && !e.stderr)
    return;
  let r = (0, vn.default)();
  return e.stdout && r.add(e.stdout), e.stderr && r.add(e.stderr), r;
}, "makeAllStream"), gt = /* @__PURE__ */ o(async (e, t) => {
  if (!(!e || t === void 0)) {
    await (0, Pn.setTimeout)(0), e.destroy();
    try {
      return await t;
    } catch (r) {
      return r.bufferedData;
    }
  }
}, "getBufferedData"), bt = /* @__PURE__ */ o((e, { encoding: t, buffer: r, maxBuffer: n }) => {
  if (!(!e || !r))
    return t === "utf8" || t === "utf-8" ? ht(e, { maxBuffer: n }) : t === null || t === "buffer" ? ge(e, { maxBuffer: n }) : Ni(e, n, t);
}, "getStreamPromise"), Ni = /* @__PURE__ */ o(async (e, t, r) => (await ge(e, { maxBuffer: t })).toString(r), "applyEncoding"), On = /* @__PURE__ */ o(
async ({ stdout: e, stderr: t, all: r }, { encoding: n, buffer: s, maxBuffer: i }, a) => {
  let c = bt(e, { encoding: n, buffer: s, maxBuffer: i }), u = bt(t, { encoding: n, buffer: s, maxBuffer: i }), f = bt(r, { encoding: n, buffer: s,
  maxBuffer: i * 2 });
  try {
    return await Promise.all([a, c, u, f]);
  } catch (l) {
    return Promise.all([
      { error: l, signal: l.signal, timedOut: l.timedOut },
      gt(e, c),
      gt(t, u),
      gt(r, f)
    ]);
  }
}, "getSpawnedResult");

// node_modules/execa/lib/promise.js
var Di = (async () => {
})().constructor.prototype, _i = ["then", "catch", "finally"].map((e) => [
  e,
  Reflect.getOwnPropertyDescriptor(Di, e)
]), xt = /* @__PURE__ */ o((e, t) => {
  for (let [r, n] of _i) {
    let s = typeof t == "function" ? (...i) => Reflect.apply(n.value, t(), i) : n.value.bind(t);
    Reflect.defineProperty(e, r, { ...n, value: s });
  }
}, "mergePromise"), jn = /* @__PURE__ */ o((e) => new Promise((t, r) => {
  e.on("exit", (n, s) => {
    t({ exitCode: n, signal: s });
  }), e.on("error", (n) => {
    r(n);
  }), e.stdin && e.stdin.on("error", (n) => {
    r(n);
  });
}), "getSpawnedPromise");

// node_modules/execa/lib/command.js
var Dn = require("node:buffer"), _n = require("node:child_process");
var Mn = /* @__PURE__ */ o((e, t = []) => Array.isArray(t) ? [e, ...t] : [e], "normalizeArgs"), Mi = /^[\w.-]+$/, Li = /* @__PURE__ */ o((e) => typeof e !=
"string" || Mi.test(e) ? e : `"${e.replaceAll('"', '\\"')}"`, "escapeArg"), St = /* @__PURE__ */ o((e, t) => Mn(e, t).join(" "), "joinComman\
d"), wt = /* @__PURE__ */ o((e, t) => Mn(e, t).map((r) => Li(r)).join(" "), "getEscapedCommand"), Ln = / +/g, Fn = /* @__PURE__ */ o((e) => {
  let t = [];
  for (let r of e.trim().split(Ln)) {
    let n = t.at(-1);
    n && n.endsWith("\\") ? t[t.length - 1] = `${n.slice(0, -1)} ${r}` : t.push(r);
  }
  return t;
}, "parseCommand"), Rn = /* @__PURE__ */ o((e) => {
  let t = typeof e;
  if (t === "string")
    return e;
  if (t === "number")
    return String(e);
  if (t === "object" && e !== null && !(e instanceof _n.ChildProcess) && "stdout" in e) {
    let r = typeof e.stdout;
    if (r === "string")
      return e.stdout;
    if (Dn.Buffer.isBuffer(e.stdout))
      return e.stdout.toString();
    throw new TypeError(`Unexpected "${r}" stdout in template expression`);
  }
  throw new TypeError(`Unexpected "${t}" in template expression`);
}, "parseExpression"), Nn = /* @__PURE__ */ o((e, t, r) => r || e.length === 0 || t.length === 0 ? [...e, ...t] : [
  ...e.slice(0, -1),
  `${e.at(-1)}${t[0]}`,
  ...t.slice(1)
], "concatTokens"), Fi = /* @__PURE__ */ o(({ templates: e, expressions: t, tokens: r, index: n, template: s }) => {
  let i = s ?? e.raw[n], a = i.split(Ln).filter(Boolean), c = Nn(
    r,
    a,
    i.startsWith(" ")
  );
  if (n === t.length)
    return c;
  let u = t[n], f = Array.isArray(u) ? u.map((l) => Rn(l)) : [Rn(u)];
  return Nn(
    c,
    f,
    i.endsWith(" ")
  );
}, "parseTemplate"), kt = /* @__PURE__ */ o((e, t) => {
  let r = [];
  for (let [n, s] of e.entries())
    r = Fi({ templates: e, expressions: t, tokens: r, index: n, template: s });
  return r;
}, "parseTemplates");

// node_modules/execa/lib/verbose.js
var Bn = require("node:util"), Gn = d(require("node:process"), 1);
var Un = (0, Bn.debuglog)("execa").enabled, Se = /* @__PURE__ */ o((e, t) => String(e).padStart(t, "0"), "padField"), Bi = /* @__PURE__ */ o(
() => {
  let e = /* @__PURE__ */ new Date();
  return `${Se(e.getHours(), 2)}:${Se(e.getMinutes(), 2)}:${Se(e.getSeconds(), 2)}.${Se(e.getMilliseconds(), 3)}`;
}, "getTimestamp"), Et = /* @__PURE__ */ o((e, { verbose: t }) => {
  t && Gn.default.stderr.write(`[${Bi()}] ${e}
`);
}, "logCommand");

// node_modules/execa/index.js
var Gi = 1e3 * 1e3 * 100, Ui = /* @__PURE__ */ o(({ env: e, extendEnv: t, preferLocal: r, localDir: n, execPath: s }) => {
  let i = t ? { ...J.default.env, ...e } : e;
  return r ? Jr({ env: i, cwd: n, execPath: s }) : i;
}, "getEnv"), Vn = /* @__PURE__ */ o((e, t, r = {}) => {
  let n = Jn.default._parse(e, t, r);
  return e = n.command, t = n.args, r = n.options, r = {
    maxBuffer: Gi,
    buffer: !0,
    stripFinalNewline: !0,
    extendEnv: !0,
    preferLocal: !1,
    localDir: r.cwd || J.default.cwd(),
    execPath: J.default.execPath,
    encoding: "utf8",
    reject: !0,
    cleanup: !0,
    all: !1,
    windowsHide: !0,
    verbose: Un,
    ...r
  }, r.env = Ui(r), r.stdio = tn(r), J.default.platform === "win32" && Hn.default.basename(e, ".exe") === "cmd" && t.unshift("/q"), { file: e,
  args: t, options: r, parsed: n };
}, "handleArguments"), V = /* @__PURE__ */ o((e, t, r) => typeof t != "string" && !Wn.Buffer.isBuffer(t) ? r === void 0 ? void 0 : "" : e.stripFinalNewline ?
Ze(t) : t, "handleOutput");
function qn(e, t, r) {
  let n = Vn(e, t, r), s = St(e, t), i = wt(e, t);
  Et(i, n.options), cn(n.options);
  let a;
  try {
    a = we.default.spawn(n.file, n.args, n.options);
  } catch (h) {
    let b = new we.default.ChildProcess(), m = Promise.reject(W({
      error: h,
      stdout: "",
      stderr: "",
      all: "",
      command: s,
      escapedCommand: i,
      parsed: n,
      timedOut: !1,
      isCanceled: !1,
      killed: !1
    }));
    return xt(b, m), b;
  }
  let c = jn(a), u = an(a, n.options, c), f = un(a, n.options, u), l = { isCanceled: !1 };
  a.kill = on.bind(null, a.kill.bind(a)), a.cancel = sn.bind(null, a, l);
  let g = qr(/* @__PURE__ */ o(async () => {
    let [{ error: h, exitCode: b, signal: m, timedOut: x }, O, v, j] = await On(a, n.options, f), Z = V(n.options, O), ee = V(n.options, v),
    p = V(n.options, j);
    if (h || b !== 0 || m !== null) {
      let w = W({
        error: h,
        exitCode: b,
        signal: m,
        stdout: Z,
        stderr: ee,
        all: p,
        command: s,
        escapedCommand: i,
        parsed: n,
        timedOut: x,
        isCanceled: l.isCanceled || (n.options.signal ? n.options.signal.aborted : !1),
        killed: a.killed
      });
      if (!n.options.reject)
        return w;
      throw w;
    }
    return {
      command: s,
      escapedCommand: i,
      exitCode: 0,
      stdout: Z,
      stderr: ee,
      all: p,
      failed: !1,
      timedOut: !1,
      isCanceled: !1,
      killed: !1
    };
  }, "handlePromise"));
  return In(a, n.options), a.all = An(a, n.options), pn(a), xt(a, g), a;
}
o(qn, "execa");
function $i(e, t, r) {
  let n = Vn(e, t, r), s = St(e, t), i = wt(e, t);
  Et(i, n.options);
  let a = Cn(n.options), c;
  try {
    c = we.default.spawnSync(n.file, n.args, { ...n.options, input: a });
  } catch (l) {
    throw W({
      error: l,
      stdout: "",
      stderr: "",
      all: "",
      command: s,
      escapedCommand: i,
      parsed: n,
      timedOut: !1,
      isCanceled: !1,
      killed: !1
    });
  }
  let u = V(n.options, c.stdout, c.error), f = V(n.options, c.stderr, c.error);
  if (c.error || c.status !== 0 || c.signal !== null) {
    let l = W({
      stdout: u,
      stderr: f,
      error: c.error,
      signal: c.signal,
      exitCode: c.status,
      command: s,
      escapedCommand: i,
      parsed: n,
      timedOut: c.error && c.error.code === "ETIMEDOUT",
      isCanceled: !1,
      killed: c.signal !== null
    });
    if (!n.options.reject)
      return l;
    throw l;
  }
  return {
    command: s,
    escapedCommand: i,
    exitCode: 0,
    stdout: u,
    stderr: f,
    failed: !1,
    timedOut: !1,
    isCanceled: !1,
    killed: !1
  };
}
o($i, "execaSync");
var Wi = /* @__PURE__ */ o(({ input: e, inputFile: t, stdio: r }) => e === void 0 && t === void 0 && r === void 0 ? { stdin: "inherit" } : {},
"normalizeScriptStdin"), $n = /* @__PURE__ */ o((e = {}) => ({
  preferLocal: !0,
  ...Wi(e),
  ...e
}), "normalizeScriptOptions");
function zn(e) {
  function t(r, ...n) {
    if (!Array.isArray(r))
      return zn({ ...e, ...r });
    let [s, ...i] = kt(r, n);
    return qn(s, i, $n(e));
  }
  return o(t, "$"), t.sync = (r, ...n) => {
    if (!Array.isArray(r))
      throw new TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");
    let [s, ...i] = kt(r, n);
    return $i(s, i, $n(e));
  }, t;
}
o(zn, "create$");
var rf = zn();
function Yn(e, t) {
  let [r, ...n] = Fn(e);
  return qn(r, n, t);
}
o(Yn, "execaCommand");

// src/telemetry/exec-command-count-lines.ts
async function ke(e, t) {
  let r = Yn(e, { shell: !0, buffer: !1, ...t });
  if (!r.stdout)
    throw new Error("Unexpected missing stdout");
  let n = 0, s = (0, Kn.createInterface)(r.stdout);
  return s.on("line", () => {
    n += 1;
  }), await r, s.close(), n;
}
o(ke, "execCommandCountLines");

// src/common/utils/file-cache.ts
var q = require("node:crypto"), k = require("node:fs"), E = require("node:fs/promises"), Qn = require("node:os"), L = require("node:path");
var Ee = class {
  static {
    o(this, "FileSystemCache");
  }
  constructor(t = {}) {
    this.prefix = (t.ns || t.prefix || "") + "-", this.hash_alg = t.hash_alg || "md5", this.cache_dir = t.basePath || (0, L.join)((0, Qn.tmpdir)(),
    (0, q.randomBytes)(15).toString("base64").replace(/\//g, "-")), this.ttl = t.ttl || 0, (0, q.createHash)(this.hash_alg), (0, k.mkdirSync)(
    this.cache_dir, { recursive: !0 });
  }
  generateHash(t) {
    return (0, L.join)(this.cache_dir, this.prefix + (0, q.createHash)(this.hash_alg).update(t).digest("hex"));
  }
  isExpired(t, r) {
    return t.ttl != null && r > t.ttl;
  }
  parseCacheData(t, r) {
    let n = JSON.parse(t);
    return this.isExpired(n, Date.now()) ? r : n.content;
  }
  parseSetData(t, r, n = {}) {
    let s = n.ttl ?? this.ttl;
    return JSON.stringify({ key: t, content: r, ...s && { ttl: Date.now() + s * 1e3 } });
  }
  async get(t, r) {
    try {
      let n = await (0, E.readFile)(this.generateHash(t), "utf8");
      return this.parseCacheData(n, r);
    } catch {
      return r;
    }
  }
  getSync(t, r) {
    try {
      let n = (0, k.readFileSync)(this.generateHash(t), "utf8");
      return this.parseCacheData(n, r);
    } catch {
      return r;
    }
  }
  async set(t, r, n = {}) {
    let s = typeof n == "number" ? { ttl: n } : n;
    (0, k.mkdirSync)(this.cache_dir, { recursive: !0 }), await (0, E.writeFile)(this.generateHash(t), this.parseSetData(t, r, s), {
      encoding: s.encoding || "utf8"
    });
  }
  setSync(t, r, n = {}) {
    let s = typeof n == "number" ? { ttl: n } : n;
    (0, k.mkdirSync)(this.cache_dir, { recursive: !0 }), (0, k.writeFileSync)(this.generateHash(t), this.parseSetData(t, r, s), {
      encoding: s.encoding || "utf8"
    });
  }
  async setMany(t, r) {
    await Promise.all(t.map((n) => this.set(n.key, n.content ?? n.value, r)));
  }
  setManySync(t, r) {
    t.forEach((n) => this.setSync(n.key, n.content ?? n.value, r));
  }
  async remove(t) {
    await (0, E.rm)(this.generateHash(t), { force: !0 });
  }
  removeSync(t) {
    (0, k.rmSync)(this.generateHash(t), { force: !0 });
  }
  async clear() {
    let t = await (0, E.readdir)(this.cache_dir);
    await Promise.all(
      t.filter((r) => r.startsWith(this.prefix)).map((r) => (0, E.rm)((0, L.join)(this.cache_dir, r), { force: !0 }))
    );
  }
  clearSync() {
    (0, k.readdirSync)(this.cache_dir).filter((t) => t.startsWith(this.prefix)).forEach((t) => (0, k.rmSync)((0, L.join)(this.cache_dir, t),
    { force: !0 }));
  }
  async getAll() {
    let t = Date.now(), r = await (0, E.readdir)(this.cache_dir);
    return (await Promise.all(
      r.filter((s) => s.startsWith(this.prefix)).map((s) => (0, E.readFile)((0, L.join)(this.cache_dir, s), "utf8"))
    )).map((s) => JSON.parse(s)).filter((s) => s.content && !this.isExpired(s, t));
  }
  async load() {
    return {
      files: (await this.getAll()).map((r) => ({
        path: this.generateHash(r.key),
        value: r.content,
        key: r.key
      }))
    };
  }
};
function vt(e) {
  return new Ee(e);
}
o(vt, "createFileSystemCache");

// src/common/utils/resolve-path-in-sb-cache.ts
var At = require("node:path");

// node_modules/find-cache-dir/index.js
var po = d(require("node:process"), 1), F = d(require("node:path"), 1), Y = d(require("node:fs"), 1), mo = d(eo(), 1);

// ../node_modules/pkg-dir/index.js
var co = d(require("node:path"), 1);

// ../node_modules/pkg-dir/node_modules/find-up/index.js
var z = d(require("node:path"), 1), io = require("node:url");

// ../node_modules/locate-path/index.js
var to = d(require("node:process"), 1), ro = d(require("node:path"), 1), Pe = d(require("node:fs"), 1), no = require("node:url");
var oo = {
  directory: "isDirectory",
  file: "isFile"
};
function Vi(e) {
  if (!Object.hasOwnProperty.call(oo, e))
    throw new Error(`Invalid type specified: ${e}`);
}
o(Vi, "checkType");
var qi = /* @__PURE__ */ o((e, t) => t[oo[e]](), "matchType"), zi = /* @__PURE__ */ o((e) => e instanceof URL ? (0, no.fileURLToPath)(e) : e,
"toPath");
function Tt(e, {
  cwd: t = to.default.cwd(),
  type: r = "file",
  allowSymlinks: n = !0
} = {}) {
  Vi(r), t = zi(t);
  let s = n ? Pe.default.statSync : Pe.default.lstatSync;
  for (let i of e)
    try {
      let a = s(ro.default.resolve(t, i), {
        throwIfNoEntry: !1
      });
      if (!a)
        continue;
      if (qi(r, a))
        return i;
    } catch {
    }
}
o(Tt, "locatePathSync");

// ../node_modules/pkg-dir/node_modules/path-exists/index.js
var so = d(require("node:fs"), 1);

// ../node_modules/pkg-dir/node_modules/find-up/index.js
var Yi = /* @__PURE__ */ o((e) => e instanceof URL ? (0, io.fileURLToPath)(e) : e, "toPath"), Ki = Symbol("findUpStop");
function Xi(e, t = {}) {
  let r = z.default.resolve(Yi(t.cwd) || ""), { root: n } = z.default.parse(r), s = t.stopAt || n, i = t.limit || Number.POSITIVE_INFINITY, a = [
  e].flat(), c = /* @__PURE__ */ o((f) => {
    if (typeof e != "function")
      return Tt(a, f);
    let l = e(f.cwd);
    return typeof l == "string" ? Tt([l], f) : l;
  }, "runMatcher"), u = [];
  for (; ; ) {
    let f = c({ ...t, cwd: r });
    if (f === Ki || (f && u.push(z.default.resolve(r, f)), r === s || u.length >= i))
      break;
    r = z.default.dirname(r);
  }
  return u;
}
o(Xi, "findUpMultipleSync");
function ao(e, t = {}) {
  return Xi(e, { ...t, limit: 1 })[0];
}
o(ao, "findUpSync");

// ../node_modules/pkg-dir/index.js
function uo({ cwd: e } = {}) {
  let t = ao("package.json", { cwd: e });
  return t && co.default.dirname(t);
}
o(uo, "packageDirectorySync");

// node_modules/find-cache-dir/index.js
var { env: Ct, cwd: Qi } = po.default, fo = /* @__PURE__ */ o((e) => {
  try {
    return Y.default.accessSync(e, Y.default.constants.W_OK), !0;
  } catch {
    return !1;
  }
}, "isWritable");
function lo(e, t) {
  return t.create && Y.default.mkdirSync(e, { recursive: !0 }), e;
}
o(lo, "useDirectory");
function Zi(e) {
  let t = F.default.join(e, "node_modules");
  if (!(!fo(t) && (Y.default.existsSync(t) || !fo(F.default.join(e)))))
    return t;
}
o(Zi, "getNodeModuleDirectory");
function It(e = {}) {
  if (Ct.CACHE_DIR && !["true", "false", "1", "0"].includes(Ct.CACHE_DIR))
    return lo(F.default.join(Ct.CACHE_DIR, e.name), e);
  let { cwd: t = Qi(), files: r } = e;
  if (r) {
    if (!Array.isArray(r))
      throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof r}\`.`);
    t = (0, mo.default)(r.map((s) => F.default.resolve(t, s)));
  }
  if (t = uo({ cwd: t }), !(!t || !Zi(t)))
    return lo(F.default.join(t, "node_modules", ".cache", e.name), e);
}
o(It, "findCacheDirectory");

// src/common/utils/resolve-path-in-sb-cache.ts
function yo(e, t = "default") {
  let r = It({ name: "storybook" });
  return r ||= (0, At.join)(process.cwd(), "node_modules", ".cache", "storybook"), (0, At.join)(r, t, e);
}
o(yo, "resolvePathInStorybookCache");

// src/telemetry/run-telemetry-operation.ts
var ho = vt({
  basePath: yo("telemetry"),
  ns: "storybook",
  ttl: 24 * 60 * 60 * 1e3
  // 24h
}), ve = /* @__PURE__ */ o(async (e, t) => {
  let r = await ho.get(e);
  return r === void 0 && (r = await t(), r !== void 0 && await ho.set(e, r)), r;
}, "runTelemetryOperation");

// src/telemetry/get-application-file-count.ts
var ea = ["page", "screen"], ta = ["js", "jsx", "ts", "tsx"], ra = /* @__PURE__ */ o(async (e) => {
  let r = ea.flatMap((n) => [
    n,
    [n[0].toUpperCase(), ...n.slice(1)].join("")
  ]).flatMap(
    (n) => ta.map((s) => `"${e}${go.sep}*${n}*.${s}"`)
  );
  try {
    let n = `git ls-files -- ${r.join(" ")}`;
    return await ke(n);
  } catch {
    return;
  }
}, "getApplicationFilesCountUncached"), bo = /* @__PURE__ */ o(async (e) => ve(
  "applicationFiles",
  async () => ra(e)
), "getApplicationFileCount");

// src/telemetry/get-chromatic-version.ts
function xo(e) {
  let t = e.dependencies?.chromatic || e.devDependencies?.chromatic || e.peerDependencies?.chromatic;
  return t || (e.scripts && Object.values(e.scripts).find((r) => r?.match(/chromatic/)) ? "latest" : void 0);
}
o(xo, "getChromaticVersionSpecifier");

// src/telemetry/get-framework-info.ts
var Eo = require("node:path"), Po = require("storybook/internal/common");

// src/telemetry/package-json.ts
var So = require("node:fs/promises"), wo = require("node:path");
var Ot = /* @__PURE__ */ o(async (e) => {
  let t = Object.keys(e);
  return Promise.all(t.map(Te));
}, "getActualPackageVersions"), Te = /* @__PURE__ */ o(async (e) => {
  try {
    let t = await jt(e);
    return {
      name: e,
      version: t.version
    };
  } catch {
    return { name: e, version: null };
  }
}, "getActualPackageVersion"), jt = /* @__PURE__ */ o(async (e) => {
  let t = require.resolve((0, wo.join)(e, "package.json"), {
    paths: [process.cwd()]
  });
  return JSON.parse(await (0, So.readFile)(t, { encoding: "utf8" }));
}, "getActualPackageJson");

// src/telemetry/get-framework-info.ts
var na = [
  "html",
  "react",
  "svelte",
  "vue3",
  "preact",
  "server",
  "vue",
  "web-components",
  "angular",
  "ember"
], oa = ["builder-webpack5", "builder-vite"];
function ko(e, t) {
  let { name: r = "", version: n, dependencies: s, devDependencies: i, peerDependencies: a } = e, c = {
    // We include the framework itself because it may be a renderer too (e.g. angular)
    [r]: n,
    ...s,
    ...i,
    ...a
  };
  return t.map((u) => `@storybook/${u}`).find((u) => c[u]);
}
o(ko, "findMatchingPackage");
var sa = /* @__PURE__ */ o((e) => {
  let t = (0, Eo.normalize)(e).replace(new RegExp(/\\/, "g"), "/");
  return Object.keys(Po.frameworkPackages).find((n) => t.endsWith(n)) || N(e).replace(/.*node_modules[\\/]/, "");
}, "getFrameworkPackageName");
async function vo(e) {
  if (!e?.framework)
    return {};
  let t = typeof e.framework == "string" ? e.framework : e.framework?.name;
  if (!t)
    return {};
  let r = await jt(t);
  if (!r)
    return {};
  let n = ko(r, oa), s = ko(r, na), i = sa(t), a = typeof e.framework == "object" ? e.framework.options : {};
  return {
    framework: {
      name: i,
      options: a
    },
    builder: n,
    renderer: s
  };
}
o(vo, "getFrameworkInfo");

// src/telemetry/get-has-router-package.ts
var ia = /* @__PURE__ */ new Set([
  "react-router",
  "react-router-dom",
  "remix",
  "@tanstack/react-router",
  "expo-router",
  "@reach/router",
  "react-easy-router",
  "@remix-run/router",
  "wouter",
  "wouter-preact",
  "preact-router",
  "vue-router",
  "unplugin-vue-router",
  "@angular/router",
  "@solidjs/router",
  // metaframeworks that imply routing
  "next",
  "react-scripts",
  "gatsby",
  "nuxt",
  "@sveltejs/kit"
]);
function To(e) {
  return Object.keys(e?.dependencies ?? {}).some(
    (t) => ia.has(t)
  );
}
o(To, "getHasRouterPackage");

// src/telemetry/get-monorepo-type.ts
var K = require("node:fs"), Ce = require("node:path"), Io = require("storybook/internal/common");
var Co = {
  Nx: "nx.json",
  Turborepo: "turbo.json",
  Lerna: "lerna.json",
  Rush: "rush.json",
  Lage: "lage.config.json"
}, Ao = /* @__PURE__ */ o(() => {
  let e = (0, Io.getProjectRoot)();
  if (!e)
    return;
  let r = Object.keys(Co).find((s) => {
    let i = (0, Ce.join)(e, Co[s]);
    return (0, K.existsSync)(i);
  });
  if (r)
    return r;
  if (!(0, K.existsSync)((0, Ce.join)(e, "package.json")))
    return;
  if (JSON.parse(
    (0, K.readFileSync)((0, Ce.join)(e, "package.json"), { encoding: "utf8" })
  )?.workspaces)
    return "Workspaces";
}, "getMonorepoType");

// src/telemetry/get-portable-stories-usage.ts
var aa = /* @__PURE__ */ o(async (e) => {
  try {
    let t = "git grep -l composeStor" + (e ? ` -- ${e}` : "");
    return await ke(t);
  } catch (t) {
    return t.exitCode === 1 ? 0 : void 0;
  }
}, "getPortableStoriesFileCountUncached"), Oo = /* @__PURE__ */ o(async (e) => ve(
  "portableStories",
  async () => aa(e)
), "getPortableStoriesFileCount");

// src/telemetry/storybook-metadata.ts
var Rt = {
  next: "Next",
  "react-scripts": "CRA",
  gatsby: "Gatsby",
  "@nuxtjs/storybook": "nuxt",
  "@nrwl/storybook": "nx",
  "@vue/cli-service": "vue-cli",
  "@sveltejs/kit": "sveltekit"
}, Nt = /* @__PURE__ */ o((e) => N(e).replace(/\/dist\/.*/, "").replace(/\.[mc]?[tj]?s[x]?$/, "").replace(/\/register$/, "").replace(/\/manager$/,
"").replace(/\/preset$/, ""), "sanitizeAddonName"), No = /* @__PURE__ */ o(async ({
  packageJsonPath: e,
  packageJson: t,
  mainConfig: r
}) => {
  let n = {
    generatedAt: (/* @__PURE__ */ new Date()).getTime(),
    hasCustomBabel: !1,
    hasCustomWebpack: !1,
    hasStaticDirs: !1,
    hasStorybookEslint: !1,
    refCount: 0
  }, s = {
    ...t?.dependencies,
    ...t?.devDependencies,
    ...t?.peerDependencies
  }, i = Object.keys(s).find((p) => !!Rt[p]);
  if (i) {
    let { version: p } = await Te(i);
    n.metaFramework = {
      name: Rt[i],
      packageName: i,
      version: p
    };
  }
  let a = [
    "playwright",
    "vitest",
    "jest",
    "cypress",
    "nightwatch",
    "webdriver",
    "@web/test-runner",
    "puppeteer",
    "karma",
    "jasmine",
    "chai",
    "testing-library",
    "@ngneat/spectator",
    "wdio",
    "msw",
    "miragejs",
    "sinon"
  ], c = Object.keys(s).filter(
    (p) => a.find((w) => p.includes(w))
  );
  n.testPackages = Object.fromEntries(
    await Promise.all(
      c.map(async (p) => [p, (await Te(p))?.version])
    )
  ), n.hasRouterPackage = To(t);
  let u = Ao();
  u && (n.monorepo = u);
  try {
    let p = await We({ cwd: (0, P.getProjectRoot)() });
    p && (n.packageManager = {
      type: p.name,
      version: p.version,
      agent: p.agent
    });
  } catch {
  }
  let f = s.typescript ? "typescript" : "javascript";
  if (!r)
    return {
      ...n,
      storybookVersionSpecifier: P.versions.storybook,
      language: f
    };
  n.hasCustomBabel = !!r.babel, n.hasCustomWebpack = !!r.webpackFinal, n.hasStaticDirs = !!r.staticDirs, typeof r.typescript == "object" && (n.
  typescriptOptions = r.typescript);
  let l = await vo(r);
  typeof r.refs == "object" && (n.refCount = Object.keys(r.refs).length), typeof r.features == "object" && (n.features = r.features);
  let y = {};
  r.addons && r.addons.forEach((p) => {
    let w, te;
    typeof p == "string" ? w = Nt(p) : (p.name.includes("addon-essentials") && (te = p.options), w = Nt(p.name)), y[w] = {
      options: te,
      version: void 0
    };
  });
  let g = xo(t);
  g && (y.chromatic = {
    version: void 0,
    versionSpecifier: g,
    options: void 0
  }), (await Ot(y)).forEach(({ name: p, version: w }) => {
    y[p].version = w;
  });
  let b = Object.keys(y), m = Object.keys(s).filter((p) => p.includes("storybook") && !b.includes(p)).reduce((p, w) => ({
    ...p,
    [w]: { version: void 0 }
  }), {});
  (await Ot(m)).forEach(({ name: p, version: w }) => {
    m[p].version = w;
  });
  let O = !!s["eslint-plugin-storybook"], v = (0, P.getStorybookInfo)(t);
  try {
    let { previewConfig: p } = v;
    if (p) {
      let w = await (0, Ro.readConfig)(p), te = !!(w.getFieldNode(["globals"]) || w.getFieldNode(["globalTypes"]));
      n.preview = { ...n.preview, usesGlobals: te };
    }
  } catch {
  }
  let j = m[v.frameworkPackage]?.version, Z = await Oo(), ee = await bo((0, jo.dirname)(e));
  return {
    ...n,
    ...l,
    portableStoriesFileCount: Z,
    applicationFileCount: ee,
    storybookVersion: j,
    storybookVersionSpecifier: v.version,
    language: f,
    storybookPackages: m,
    addons: y,
    hasStorybookEslint: O
  };
}, "computeStorybookMetadata");
async function ca() {
  let e = await Fe(process.cwd());
  return e ? {
    packageJsonPath: e,
    packageJson: await Zt(e) || {}
  } : {
    packageJsonPath: process.cwd(),
    packageJson: {}
  };
}
o(ca, "getPackageJsonDetails");
var Ie, Dt = /* @__PURE__ */ o(async (e) => {
  if (Ie)
    return Ie;
  let { packageJson: t, packageJsonPath: r } = await ca(), n = (e || (0, P.getStorybookConfiguration)(
    String(t?.scripts?.storybook || ""),
    "-c",
    "--config-dir"
  )) ?? ".storybook", s = await (0, P.loadMainConfig)({ configDir: n }).catch(() => {
  });
  return Ie = await No({ mainConfig: s, packageJson: t, packageJsonPath: r }), Ie;
}, "getStorybookMetadata");

// src/telemetry/telemetry.ts
var Vo = d(require("node:os"), 1), qo = d(_o(), 1);

// ../node_modules/nanoid/index.js
var _t = require("crypto");

// ../node_modules/nanoid/url-alphabet/index.js
var Mo = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";

// ../node_modules/nanoid/index.js
var ua = 128, A, B, fa = /* @__PURE__ */ o((e) => {
  !A || A.length < e ? (A = Buffer.allocUnsafe(e * ua), (0, _t.randomFillSync)(A), B = 0) : B + e > A.length && ((0, _t.randomFillSync)(A), B =
  0), B += e;
}, "fillPool");
var X = /* @__PURE__ */ o((e = 21) => {
  fa(e -= 0);
  let t = "";
  for (let r = B - e; r < B; r++)
    t += Mo[A[r] & 63];
  return t;
}, "nanoid");

// src/telemetry/anonymous-id.ts
var Fo = require("node:path"), Bo = require("storybook/internal/common"), Go = require("child_process");
Xn();

// src/telemetry/one-way-hash.ts
var Lo = require("crypto");
var Oe = /* @__PURE__ */ o((e) => {
  let t = (0, Lo.createHash)("sha256");
  return t.update("storybook-telemetry-salt"), t.update(e), t.digest("hex");
}, "oneWayHash");

// src/telemetry/anonymous-id.ts
function la(e) {
  let n = e.trim().replace(/#.*$/, "").replace(/^.*@/, "").replace(/^.*\/\//, "");
  return (n.endsWith(".git") ? n : `${n}.git`).replace(":", "/");
}
o(la, "normalizeGitUrl");
function pa(e, t) {
  return `${la(e)}${Pt(t)}`;
}
o(pa, "unhashedProjectId");
var je, Uo = /* @__PURE__ */ o(() => {
  if (je)
    return je;
  try {
    let e = (0, Bo.getProjectRoot)(), t = (0, Fo.relative)(e, process.cwd()), r = (0, Go.execSync)("git config --local --get remote.origin.u\
rl", {
      timeout: 1e3,
      stdio: "pipe"
    });
    je = Oe(pa(String(r), t));
  } catch {
  }
  return je;
}, "getAnonymousProjectId");

// src/telemetry/event-cache.ts
var Re = require("storybook/internal/common");
var Mt = Promise.resolve(), ma = /* @__PURE__ */ o(async (e, t) => {
  let r = await Re.cache.get("lastEvents") || {};
  r[e] = { body: t, timestamp: Date.now() }, await Re.cache.set("lastEvents", r);
}, "setHelper"), Wo = /* @__PURE__ */ o(async (e, t) => (await Mt, Mt = ma(e, t), Mt), "set");
var da = /* @__PURE__ */ o((e) => {
  let { body: t, timestamp: r } = e;
  return {
    timestamp: r,
    eventType: t?.eventType,
    eventId: t?.eventId,
    sessionId: t?.sessionId
  };
}, "upgradeFields"), ya = ["init", "upgrade"], ha = ["build", "dev", "error"], $o = /* @__PURE__ */ o((e, t) => {
  let r = t.map((n) => e?.[n]).filter(Boolean).sort((n, s) => s.timestamp - n.timestamp);
  return r.length > 0 ? r[0] : void 0;
}, "lastEvent"), Ho = /* @__PURE__ */ o(async (e = void 0) => {
  let t = e || await Re.cache.get("lastEvents") || {}, r = $o(t, ya), n = $o(t, ha);
  if (r)
    return !n?.timestamp || r.timestamp > n.timestamp ? da(r) : void 0;
}, "getPrecedingUpgrade");

// src/telemetry/fetch.ts
var Jo = global.fetch;

// src/telemetry/session-id.ts
var Lt = require("storybook/internal/common");
var ga = 1e3 * 60 * 60 * 2, Q;
var Ft = /* @__PURE__ */ o(async () => {
  let e = Date.now();
  if (!Q) {
    let t = await Lt.cache.get("session");
    t && t.lastUsed >= e - ga ? Q = t.id : Q = X();
  }
  return await Lt.cache.set("session", { id: Q, lastUsed: e }), Q;
}, "getSessionId");

// src/telemetry/telemetry.ts
var ba = (0, qo.default)(Jo), xa = process.env.STORYBOOK_TELEMETRY_URL || "https://storybook.js.org/event-log", Ne = [], zo = /* @__PURE__ */ o(
(e, t) => {
  Bt[e] = t;
}, "addToGlobalContext"), Sa = /* @__PURE__ */ o(() => {
  try {
    let e = Vo.platform();
    return e === "win32" ? "Windows" : e === "darwin" ? "macOS" : e === "linux" ? "Linux" : `Other: ${e}`;
  } catch {
    return "Unknown";
  }
}, "getOperatingSystem"), Bt = {
  inCI: !!process.env.CI,
  isTTY: process.stdout.isTTY,
  platform: Sa(),
  nodeVersion: process.versions.node
}, wa = /* @__PURE__ */ o(async (e, t, r) => {
  let { eventType: n, payload: s, metadata: i, ...a } = e, c = await Ft(), u = X(), f = { ...a, eventType: n, eventId: u, sessionId: c, metadata: i,
  payload: s, context: t };
  return ba(xa, {
    method: "post",
    body: JSON.stringify(f),
    headers: { "Content-Type": "application/json" },
    retries: 3,
    retryOn: [503, 504],
    retryDelay: /* @__PURE__ */ o((l) => 2 ** l * (typeof r?.retryDelay == "number" && !Number.isNaN(r?.retryDelay) ? r.retryDelay : 1e3), "\
retryDelay")
  });
}, "prepareRequest");
async function Yo(e, t = { retryDelay: 1e3, immediate: !1 }) {
  let { eventType: r, payload: n, metadata: s, ...i } = e, a = t.stripMetadata ? Bt : {
    ...Bt,
    anonymousId: Uo()
  }, c;
  try {
    c = wa(e, a, t), Ne.push(c), t.immediate ? await Promise.all(Ne) : await c;
    let u = await Ft(), f = X(), l = { ...i, eventType: r, eventId: f, sessionId: u, metadata: s, payload: n, context: a };
    await Wo(r, l);
  } catch {
  } finally {
    Ne = Ne.filter((u) => u !== c);
  }
}
o(Yo, "sendTelemetry");

// src/telemetry/index.ts
var ka = /* @__PURE__ */ o((e) => e.startsWith("example-button--") || e.startsWith("example-header--") || e.startsWith("example-page--"), "i\
sExampleStoryId"), Ea = /* @__PURE__ */ o(async (e, t = {}, r = {}) => {
  e !== "boot" && r.notify !== !1 && await Vt();
  let n = {
    eventType: e,
    payload: t
  };
  try {
    r?.stripMetadata || (n.metadata = await Dt(r?.configDir));
  } catch (s) {
    n.payload.metadataErrorMessage = U(s).message, r?.enableCrashReports && (n.payload.metadataError = U(s));
  } finally {
    let { error: s } = n.payload;
    s && (n.payload.error = U(s)), (!n.payload.error || r?.enableCrashReports) && (process.env?.STORYBOOK_TELEMETRY_DEBUG && (Gt.logger.info(
    `
[telemetry]`), Gt.logger.info(JSON.stringify(n, null, 2))), await Yo(n, r));
  }
}, "telemetry");
