var H = Object.defineProperty;
var l = (s, e) => H(s, "name", { value: e, configurable: !0 });

// src/highlight/preview.ts
import { STORY_CHANGED as I } from "storybook/internal/core-events";
import { global as p } from "@storybook/global";
import { addons as a, definePreview as E } from "storybook/preview-api";

// src/highlight/constants.ts
var h = "storybook/highlight", d = `${h}/add`, u = `${h}/reset`, f = `${h}/scroll-into-view`;

// src/highlight/preview.ts
var { document: g } = p, S = /* @__PURE__ */ l((s, {
  color: e = "#FF4785",
  style: n = "solid",
  width: o = "1px",
  offset: m = "2px",
  fadeOut: $ = 0,
  pulseOut: t = 0
}) => {
  let i = Math.random().toString(36).substring(2, 15), r = "";
  return t ? r = `@keyframes ${i} {
      0% { outline: ${o} ${n} ${e}; }
      20% { outline: ${o} ${n} ${e}00; }
      40% { outline: ${o} ${n} ${e}; }
      60% { outline: ${o} ${n} ${e}00; }
      80% { outline: ${o} ${n} ${e}; }
      100% { outline: ${o} ${n} ${e}00; }
    }
` : $ && (r = `@keyframes ${i} {
      0% { outline: ${o} ${n} ${e}; }
      100% { outline: ${o} ${n} ${e}00; }
    }
`), `${r}${s.join(", ")} {
    outline: ${o} ${n} ${e};
    outline-offset: ${m};
    ${t || $ ? `animation: ${i} ${t || $}ms linear forwards;` : ""}
  }`;
}, "highlightStyle");
a && a.ready && a.ready().then(() => {
  let s = a.getChannel(), e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ l((t) => {
    let i = Math.random().toString(36).substring(2, 15);
    e.add(i);
    let r = g.createElement("style");
    r.innerHTML = S(Array.from(new Set(t.elements)), t), r.setAttribute("id", i), g.head.appendChild(r);
    let c = t.pulseOut || t.fadeOut;
    c && setTimeout(() => o(i), c + 500);
  }, "highlight"), o = /* @__PURE__ */ l((t) => {
    let i = g.getElementById(t);
    i?.parentNode?.removeChild(i), e.delete(t);
  }, "removeHighlight"), m = /* @__PURE__ */ l(() => {
    e.forEach(o);
  }, "resetHighlight"), $ = /* @__PURE__ */ l((t, i) => {
    g.querySelector(t)?.scrollIntoView({ behavior: "smooth", block: "center", ...i }), n({
      elements: [t],
      color: "#1EA7FD",
      width: "2px",
      offset: "2px",
      pulseOut: 3e3
    });
  }, "scrollIntoView");
  s.on(I, m), s.on(f, $), s.on(u, m), s.on(d, n);
});
var _ = /* @__PURE__ */ l(() => E({}), "default");
export {
  _ as default
};
