import { F as i, S as p, G as u, H as d, I as h, J as C } from "./684d2f28.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((r) => r.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 r = 0;
  return t.replace(/[a-zA-Z_$][\w$]*/g, (o) => {
    const e = t.indexOf(o, r);
    return e >= 0 && (c.hasOwnProperty(o) && (e === 0 || t[e - 1] !== ".") && n.push([e, e + o.length]), r = e + o.length), o;
  }), n;
}
function F(t, c, n) {
  if (!t || !n)
    return [];
  if (c === "Function")
    return m(t, n);
  const r = [];
  let o = 0;
  for (const e of h(t)) {
    if (C(e)) {
      const f = o + 2;
      m(e.slice(2, -2), n).forEach(([s, l]) => r.push([s + f, l + f]));
    }
    o += e.length;
  }
  return r;
}
function J(t, c, n, r) {
  k(() => {
    if (!t || c !== t.state.doc.toString())
      return;
    const o = F(c, n, r).map(([f, s]) => S.range(f, s)), e = [g.of(i.set(o))];
    t.state.field(a, !1) || e.push(p.appendConfig.of([a])), t.dispatch({
      effects: e
    });
  }, [t, c, n, r]);
}
export {
  E as c,
  J as u
};
