var m = Object.defineProperty;
var s = (t, o) => m(t, "name", { value: o, configurable: !0 });
import { pickedCompletion as c, insertCompletionText as u } from "../../../../../../@codemirror_autocomplete@6.18.6/node_modules/@codemirror/autocomplete/dist/index.js";
import { defaultAutocompleteRenderer as d } from "./renderAutocomplete.js";
function T(t, o) {
  return t && {
    from: t.from,
    options: t.options.map((n) => h(n, o))
  };
}
s(T, "deserializeCompletions");
function h(t, o) {
  const { codeActions: n, label: i, type: r } = t;
  return {
    label: i,
    type: r,
    apply: n ? g(n) : t.label,
    info: (o?.renderAutocomplete ?? d)(t)
  };
}
s(h, "deserializeCompletion");
function g(t) {
  return (o, n, i, r) => {
    const p = {
      ...u(o.state, n.label, i, r),
      annotations: c.of(n)
    }, a = [];
    for (const f of t)
      for (const l of f.changes)
        for (const e of l.textChanges)
          a.push({
            changes: [
              {
                from: e.span.start,
                to: e.span.start + e.span.length,
                insert: e.newText
              }
            ],
            annotations: c.of(n)
          });
    o.dispatch(p, ...a);
  };
}
s(g, "codeActionToApplyFunction");
export {
  g as codeActionToApplyFunction,
  T as deserializeCompletions
};
