import {
  d as l
} from "../_browser-chunks/chunk-5IQN7XXU.js";
import {
  a as m
} from "../_browser-chunks/chunk-IXWND6JI.js";
import {
  a as n
} from "../_browser-chunks/chunk-IO47FP3U.js";

// src/actions/decorator.ts
import { makeDecorator as d, useEffect as f } from "storybook/preview-api";
var h = /^(\S+)\s*(.*)$/, u = Element != null && !Element.prototype.matches, E = u ? "msMatchesSelector" : "matches", p = /* @__PURE__ */ n((e, r) => {
  if (e[E](r))
    return !0;
  let t = e.parentElement;
  return t ? p(t, r) : !1;
}, "hasMatchInAncestry"), b = /* @__PURE__ */ n((e, ...r) => {
  let t = e(...r);
  return Object.entries(t).map(([a, o]) => {
    let [s, y, c] = a.match(h) || [];
    return {
      eventName: y,
      handler: /* @__PURE__ */ n((i) => {
        (!c || p(i.target, c)) && o(i);
      }, "handler")
    };
  });
}, "createHandlers"), g = /* @__PURE__ */ n((e, ...r) => {
  let t = typeof globalThis.document < "u" && globalThis.document.getElementById("storybook-root");
  f(() => {
    if (t) {
      let a = b(e, ...r);
      return a.forEach(({ eventName: o, handler: s }) => t.addEventListener(o, s)), () => a.forEach(({ eventName: o, handler: s }) => t.removeEventListener(o, s));
    }
  }, [t, e, r]);
}, "applyEventHandlers"), T = d({
  name: "withActions",
  parameterName: m,
  skipIfNoParametersOrOptions: !0,
  wrapper: /* @__PURE__ */ n((e, r, { parameters: t }) => (t?.handles && g(l, ...t.handles), e(r)), "wrapper")
});
export {
  T as withActions
};
