import { watch as p, toValue as n, onScopeDispose as c } from "vue";
import { ensureJsonPointerLinkSupport as l } from "../helpers/json/json-pointer-links.js";
import { parseJsonPointerPath as f } from "../helpers/json/json-pointer-path.js";
const g = "json", I = (o, e) => {
  let t = null;
  const i = () => {
    const s = n(o), r = n(e);
    if (t && (t(), t = null), !s?.focusPath || !r || r.model.getLanguageId() !== g)
      return;
    t = l(async (u) => {
      const a = f(u);
      a && await s.focusPath(a.map(String));
    }).dispose;
  };
  p(
    () => [n(o), n(e)],
    () => {
      i();
    },
    { immediate: !0 }
  ), c(() => {
    t && (t(), t = null);
  });
};
export {
  I as useJsonPointerLinkSupport
};
