import { __exports as a } from "./index-LexicalText.prod2.js";
import { __require as p } from "./index-Lexical.js";
var N;
function v() {
  if (N) return a;
  N = 1;
  var l = p();
  function c(n, s = !0) {
    return n ? !1 : (n = C(), s && (n = n.trim()), n === "");
  }
  function C() {
    return l.$getRoot().getTextContent();
  }
  function $(n) {
    if (!c(n, !1)) return !1;
    n = l.$getRoot().getChildren();
    let s = n.length;
    if (1 < s) return !1;
    for (let i = 0; i < s; i++) {
      var t = n[i];
      if (l.$isDecoratorNode(t)) return !1;
      if (l.$isElementNode(t)) {
        if (!l.$isParagraphNode(t) || t.__indent !== 0) return !1;
        t = t.getChildren();
        let g = t.length;
        for (let d = 0; d < g; d++) if (!l.$isTextNode(t[i])) return !1;
      }
    }
    return !0;
  }
  return a.$canShowPlaceholder = $, a.$canShowPlaceholderCurry = function(n) {
    return () => $(n);
  }, a.$findTextIntersectionFromCharacters = function(n, s) {
    var t = n.getFirstChild();
    n = 0;
    e: for (; t !== null; ) {
      if (l.$isElementNode(t)) {
        var i = t.getFirstChild();
        if (i !== null) {
          t = i;
          continue;
        }
      } else if (l.$isTextNode(t)) {
        if (i = t.getTextContentSize(), n + i > s) return { node: t, offset: s - n };
        n += i;
      }
      if (i = t.getNextSibling(), i !== null) t = i;
      else {
        for (t = t.getParent(); t !== null; ) {
          if (i = t.getNextSibling(), i !== null) {
            t = i;
            continue e;
          }
          t = t.getParent();
        }
        break;
      }
    }
    return null;
  }, a.$isRootTextContentEmpty = c, a.$isRootTextContentEmptyCurry = function(n, s) {
    return () => c(n, s);
  }, a.$rootTextContent = C, a.registerLexicalTextEntity = function(n, s, t, i) {
    let g = (e) => {
      const r = l.$createTextNode(e.getTextContent());
      r.setFormat(e.getFormat()), e.replace(r);
    }, d = n.registerNodeTransform(l.TextNode, (e) => {
      if (e.isSimpleText()) {
        var r = e.getPreviousSibling(), x = e.getTextContent(), f = e;
        if (l.$isTextNode(r)) {
          var u = r.getTextContent(), o = s(u + x);
          if (r instanceof t) {
            if (o === null || r.getLatest().__mode !== 0) {
              g(r);
              return;
            }
            if (o = o.end - u.length, 0 < o) {
              f = x.slice(0, o), f = u + f, r.select(), r.setTextContent(f), o === x.length ? e.remove() : (r = x.slice(o), e.setTextContent(r));
              return;
            }
          } else if (o === null || o.start < u.length) return;
        }
        for (; ; ) {
          if (e = s(x), x = o = e === null ? "" : x.slice(e.end), o === "") {
            if (u = f.getNextSibling(), l.$isTextNode(u)) {
              if (o = f.getTextContent() + u.getTextContent(), o = s(o), o === null) {
                u instanceof t ? g(u) : u.markDirty();
                break;
              } else if (o.start !== 0) break;
            }
          } else if (u = s(o), u !== null && u.start === 0) break;
          if (e === null) break;
          if (e.start === 0 && l.$isTextNode(r) && r.isTextEntity()) continue;
          let T;
          if (e.start === 0 ? [T, f] = f.splitText(e.end) : [, T, f] = f.splitText(e.start, e.end), e = i(T), e.setFormat(T.getFormat()), T.replace(e), f == null) break;
        }
      }
    });
    return n = n.registerNodeTransform(t, (e) => {
      var r = e.getTextContent();
      const x = s(r);
      x === null || x.start !== 0 ? g(e) : r.length > x.end ? e.splitText(x.end) : (r = e.getPreviousSibling(), l.$isTextNode(r) && r.isTextEntity() && (g(r), g(e)), r = e.getNextSibling(), l.$isTextNode(r) && r.isTextEntity() && (g(r), e instanceof t && g(e)));
    }), [d, n];
  }, a;
}
export {
  v as __require
};
