import { fS as i, fT as p, fU as u, em as d, fV as h, fW as C } from "./56c67d3b.js";
import { useEffect as k } from "react";
const E = "cm-click-comp-name", S = i.mark({
  class: E
}), g = p.define(), a = u.define({
  create() {
    return i.none;
  },
  update(t, c) {
    t = t.map(c.changes);
    const n = c.effects.filter((f) => f.is(g));
    return n.length > 0 ? n[0].value : t;
  },
  provide: (t) => d.decorations.from(t)
});
function m(t, c) {
  if (!t || !c)
    return [];
  const n = [];
  let f = 0;
  return t.replace(/[a-zA-Z_$][\w$]*/g, (r) => {
    const e = t.indexOf(r, f);
    return e >= 0 && (c.hasOwnProperty(r) && (e === 0 || t[e - 1] !== ".") && n.push([e, e + r.length]), f = e + r.length), r;
  }), n;
}
function N(t, c, n) {
  if (!t || !n)
    return [];
  if (c === "Function")
    return m(t, n);
  const f = [];
  let r = 0;
  for (const e of h(t)) {
    if (C(e)) {
      const o = r + 2;
      m(e.slice(2, -2), n).forEach(([s, l]) => f.push([s + o, l + o]));
    }
    r += e.length;
  }
  return f;
}
function O(t, c, n, f) {
  k(() => {
    if (!t || c !== t.state.doc.toString())
      return;
    const r = N(c, n, f).map(([o, s]) => S.range(o, s)), e = [g.of(i.set(r))];
    t.state.field(a, !1) || e.push(p.appendConfig.of([a])), t.dispatch({
      effects: e
    });
  }, [t, c, n, f]);
}
export {
  E as c,
  O as u
};
