import * as a from "monaco-editor/esm/vs/editor/editor.api.js";
import { ref as m, onMounted as l, onBeforeUnmount as M, watch as g, toValue as d } from "vue";
const f = (o) => {
  const e = m([]);
  let s = null;
  const i = [], t = () => {
    const n = d(o)?.getModel()?.uri;
    if (!n) {
      e.value = [];
      return;
    }
    e.value = a.editor.getModelMarkers({}).filter((c) => c.resource.toString() === n.toString());
  }, r = () => {
    i.push(setTimeout(t, 0), setTimeout(t, 80), setTimeout(t, 220));
  };
  return l(() => {
    s = a.editor.onDidChangeMarkers(() => {
      r();
    }), r();
  }), M(() => {
    s?.dispose(), i.forEach((u) => clearTimeout(u));
  }), g(
    () => d(o)?.getModel()?.uri?.toString(),
    () => {
      r();
    },
    { immediate: !0 }
  ), {
    markers: e
  };
};
export {
  f as useEditorMarkers
};
