"use strict";
var y = Object.defineProperty;
var C = Object.getOwnPropertyDescriptor;
var W = Object.getOwnPropertyNames;
var M = Object.prototype.hasOwnProperty;
var i = (e, t) => y(e, "name", { value: t, configurable: !0 });
var l = (e, t) => {
  for (var o in t)
    y(e, o, { get: t[o], enumerable: !0 });
}, L = (e, t, o, r) => {
  if (t && typeof t == "object" || typeof t == "function")
    for (let n of W(t))
      !M.call(e, n) && n !== o && y(e, n, { get: () => t[n], enumerable: !(r = C(t, n)) || r.enumerable });
  return e;
};
var V = (e) => L(y({}, "__esModule", { value: !0 }), e);

// src/actions/preview.ts
var U = {};
l(U, {
  default: () => H
});
module.exports = V(U);
var P = require("storybook/preview-api");

// src/actions/addArgs.ts
var A = {};
l(A, {
  argsEnhancers: () => B
});

// src/actions/runtime/action.ts
var O = require("storybook/internal/preview-errors"), u = require("@storybook/global"), v = require("storybook/preview-api"), w = require("uuid");

// src/actions/constants.ts
var f = "storybook/actions", J = `${f}/panel`, E = `${f}/action-event`, Q = `${f}/action-clear`;

// src/actions/runtime/configureActions.ts
var R = {
  depth: 10,
  clearOnStoryChange: !0,
  limit: 50
};

// src/actions/runtime/action.ts
var T = /* @__PURE__ */ i((e, t) => {
  let o = Object.getPrototypeOf(e);
  return !o || t(o) ? o : T(o, t);
}, "findProto"), N = /* @__PURE__ */ i((e) => !!(typeof e == "object" && e && T(e, (t) => /^Synthetic(?:Base)?Event$/.test(t.constructor.name)) &&
typeof e.persist == "function"), "isReactSyntheticEvent"), Y = /* @__PURE__ */ i((e) => {
  if (N(e)) {
    let t = Object.create(
      e.constructor.prototype,
      Object.getOwnPropertyDescriptors(e)
    );
    t.persist();
    let o = Object.getOwnPropertyDescriptor(t, "view"), r = o?.value;
    return typeof r == "object" && r?.constructor.name === "Window" && Object.defineProperty(t, "view", {
      ...o,
      value: Object.create(r.constructor.prototype)
    }), t;
  }
  return e;
}, "serializeArg"), $ = /* @__PURE__ */ i(() => typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? (0, w.v4)() : (
  // pseudo random id, example response lo1e7zm4832bkr7yfl7
  Date.now().toString(36) + Math.random().toString(36).substring(2)
), "generateId");
function g(e, t = {}) {
  let o = {
    ...R,
    ...t
  }, r = /* @__PURE__ */ i(function(...s) {
    if (t.implicit) {
      let x = ("__STORYBOOK_PREVIEW__" in u.global ? (
        // eslint-disable-next-line no-underscore-dangle
        u.global.__STORYBOOK_PREVIEW__
      ) : void 0)?.storyRenders.find(
        (d) => d.phase === "playing" || d.phase === "rendering"
      );
      if (x) {
        let d = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, b = new O.ImplicitActionsDuringRendering({
          phase: x.phase,
          name: e,
          deprecated: d
        });
        if (d)
          console.warn(b);
        else
          throw b;
      }
    }
    let a = v.addons.getChannel(), c = $(), p = 5, m = s.map(Y), S = s.length > 1 ? m : m[0], F = {
      id: c,
      count: 0,
      data: { name: e, args: S },
      options: {
        ...o,
        maxDepth: p + (o.depth || 3)
      }
    };
    a.emit(E, F);
  }, "actionHandler");
  return r.isAction = !0, r.implicit = t.implicit, r;
}
i(g, "action");

// src/actions/addArgsHelpers.ts
var _ = /* @__PURE__ */ i((e, t) => typeof t[e] > "u" && !(e in t), "isInInitialArgs"), D = /* @__PURE__ */ i((e) => {
  let {
    initialArgs: t,
    argTypes: o,
    id: r,
    parameters: { actions: n }
  } = e;
  if (!n || n.disable || !n.argTypesRegex || !o)
    return {};
  let s = new RegExp(n.argTypesRegex);
  return Object.entries(o).filter(
    ([c]) => !!s.test(c)
  ).reduce((c, [p, m]) => (_(p, t) && (c[p] = g(p, { implicit: !0, id: r })), c), {});
}, "inferActionsFromArgTypesRegex"), k = /* @__PURE__ */ i((e) => {
  let {
    initialArgs: t,
    argTypes: o,
    parameters: { actions: r }
  } = e;
  return r?.disable || !o ? {} : Object.entries(o).filter(([s, a]) => !!a.action).reduce((s, [a, c]) => (_(a, t) && (s[a] = g(typeof c.action ==
  "string" ? c.action : a)), s), {});
}, "addActionsFromArgTypes");

// src/actions/addArgs.ts
var B = [
  k,
  D
];

// src/actions/loaders.ts
var h = {};
l(h, {
  loaders: () => z
});
var j = require("storybook/test/spy");
var I = !1, K = /* @__PURE__ */ i((e) => {
  let { parameters: t } = e;
  t?.actions?.disable || I || ((0, j.onMockCall)((o, r) => {
    let n = o.getMockName();
    n !== "spy" && (!/^next\/.*::/.test(n) || [
      "next/router::useRouter()",
      "next/navigation::useRouter()",
      "next/navigation::redirect",
      "next/cache::",
      "next/headers::cookies().set",
      "next/headers::cookies().delete",
      "next/headers::headers().set",
      "next/headers::headers().delete"
    ].some((s) => n.startsWith(s))) && g(n)(r);
  }), I = !0);
}, "logActionsWhenMockCalled"), z = [K];

// src/actions/preview.ts
var H = /* @__PURE__ */ i(() => (0, P.definePreview)({
  ...A,
  ...h
}), "default");
