var v = Object.defineProperty;
var r = (o, n) => v(o, "name", { value: n, configurable: !0 });

// src/actions/constants.ts
var S = "actions", a = "storybook/actions", T = `${a}/panel`, l = `${a}/action-event`, k = `${a}/action-clear`, C = "$___storybook.isCyclic";

// src/actions/runtime/action.ts
import { ImplicitActionsDuringRendering as w } from "storybook/internal/preview-errors";
import { global as u } from "@storybook/global";
import { addons as _ } from "storybook/preview-api";
import { v4 as D } from "uuid";

// src/actions/runtime/configureActions.ts
var c = {
  depth: 10,
  clearOnStoryChange: !0,
  limit: 50
}, V = /* @__PURE__ */ r((o = {}) => {
  Object.assign(c, o);
}, "configureActions");

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

// src/actions/runtime/actions.ts
var G = /* @__PURE__ */ r((...o) => {
  let n = c, t = o;
  t.length === 1 && Array.isArray(t[0]) && ([t] = t), t.length !== 1 && typeof t[t.length - 1] != "string" && (n = {
    ...c,
    ...t.pop()
  });
  let e = t[0];
  (t.length !== 1 || typeof e == "string") && (e = {}, t.forEach((i) => {
    e[i] = i;
  }));
  let p = {};
  return Object.keys(e).forEach((i) => {
    p[i] = g(e[i], n);
  }), p;
}, "actions");
export {
  a as ADDON_ID,
  k as CLEAR_ID,
  C as CYCLIC_KEY,
  l as EVENT_ID,
  T as PANEL_ID,
  S as PARAM_KEY,
  g as action,
  G as actions,
  c as config,
  V as configureActions
};
