import { ay as u, az as y, l as k } from "./DSD.DRGuMxXd.js";
import { useRef as E, useContext as O, useMemo as D, useEffect as h } from "react";
import { jsx as K } from "react/jsx-runtime";
function C(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var T = C(function(e) {
  const r = new URLSearchParams();
  r.append("code", e);
  for (let n = 1; n < arguments.length; n++) r.append("v", arguments[n]);
  throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${r} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
});
function m(e) {
  const r = e.transform();
  return r !== null ? /* @__PURE__ */ new Set([r]) : /* @__PURE__ */ new Set();
}
function S({ initialEditor: e, children: r, initialNodes: n, initialTheme: g, skipCollabChecks: _ }) {
  const d = E(!1), i = O(u);
  i == null && T(9);
  const [l, { getTheme: v }] = i, w = D(() => {
    const a = g || v() || void 0, b = y(i, a);
    if (a !== void 0 && (e._config.theme = a), e._parentEditor = l, n) for (let t of n) {
      let s = null, o = null;
      if (typeof t != "function") {
        const p = t;
        t = p.replace, s = p.with, o = p.withKlass || null;
      }
      const f = e._nodes.get(t.getType());
      e._nodes.set(t.getType(), { exportDOM: f ? f.exportDOM : void 0, klass: t, replace: s, replaceWithKlass: o, transforms: m(t) });
    }
    else {
      const t = e._nodes = new Map(l._nodes);
      for (const [s, o] of t) e._nodes.set(s, { exportDOM: o.exportDOM, klass: o.klass, replace: o.replace, replaceWithKlass: o.replaceWithKlass, transforms: m(o.klass) });
    }
    return e._config.namespace = l._config.namespace, e._editable = l._editable, [e, b];
  }, []), { isCollabActive: x, yjsDocMap: M } = k(), c = _ || d.current || M.has(e.getKey());
  return h(() => {
    c && (d.current = !0);
  }, [c]), h(() => l.registerEditableListener((a) => {
    e.setEditable(a);
  }), [e, l]), K(u.Provider, { value: w, children: !x || c ? r : null });
}
export {
  S as d
};
