import m, { useRef as ee, useState as Y, useDebugValue as J, useEffect as Q, forwardRef as te, useLayoutEffect as re, version as G, createContext as X, useContext as ne } from "react";
import oe, { flushSync as ie } from "react-dom";
import { Editor as se } from "../../../../../@tiptap_core@2.14.0_@tiptap_pm@2.14.0/node_modules/@tiptap/core/dist/index.js";
import { CommandManager as Be, Extension as Pe, InputRule as Ue, Mark as ze, Node as We, NodePos as Ge, PasteRule as He, callOrReturn as Ke, createChainableState as qe, createDocument as $e, createNodeFromContent as ke, createStyleTag as Ye, defaultBlockAt as Je, deleteProps as Qe, elementFromString as Xe, escapeForRegEx as Ze, findDuplicates as et, findParentNode as tt, findParentNodeClosestToPos as rt, fromString as nt, getAttributes as ot, getAttributesFromExtensions as it, getExtensionField as st, getHTMLFromFragment as ut, getMarkAttributes as at, getMarkRange as ct, getMarkType as lt, getMarksBetween as dt, getNodeAttributes as ft, getNodeType as ht, getRenderedAttributes as pt, getSchemaByResolvedExtensions as vt, getSchemaTypeByName as mt, getSchemaTypeNameByName as St, getSplittedAttributes as Et, getText as _t, getTextBetween as yt, getTextContentFromNodes as Ot, getTextSerializersFromSchema as gt, injectExtensionAttributesToParseRule as Rt, inputRulesPlugin as bt, isActive as Ct, isEmptyObject as wt, isExtensionRulesEnabled as Tt, isFunction as Dt, isList as xt, isMacOS as At, isMarkActive as Lt, isNodeActive as It, isNodeEmpty as Nt, isNodeSelection as Mt, isNumber as Vt, isPlainObject as Ft, isRegExp as jt, isTextSelection as Bt, isiOS as Pt, markInputRule as Ut, markPasteRule as zt, mergeAttributes as Wt, mergeDeep as Gt, minMax as Ht, nodeInputRule as Kt, objectIncludes as qt, pasteRulesPlugin as $t, resolveFocusPosition as kt, selectionToInsertionEnd as Yt, splitExtensions as Jt, textblockTypeInputRule as Qt, wrappingInputRule as Xt } from "../../../../../@tiptap_core@2.14.0_@tiptap_pm@2.14.0/node_modules/@tiptap/core/dist/index.js";
function ue(n) {
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
}
var P = { exports: {} }, V = {};
/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var H;
function ae() {
  if (H) return V;
  H = 1;
  var n = m;
  function e(u, c) {
    return u === c && (u !== 0 || 1 / u === 1 / c) || u !== u && c !== c;
  }
  var t = typeof Object.is == "function" ? Object.is : e, o = n.useState, r = n.useEffect, i = n.useLayoutEffect, S = n.useDebugValue;
  function b(u, c) {
    var d = c(), p = o({ inst: { value: d, getSnapshot: c } }), f = p[0].inst, v = p[1];
    return i(function() {
      f.value = d, f.getSnapshot = c, O(f) && v({ inst: f });
    }, [u, d, c]), r(function() {
      return O(f) && v({ inst: f }), u(function() {
        O(f) && v({ inst: f });
      });
    }, [u]), S(d), d;
  }
  function O(u) {
    var c = u.getSnapshot;
    u = u.value;
    try {
      var d = c();
      return !t(u, d);
    } catch {
      return !0;
    }
  }
  function E(u, c) {
    return c();
  }
  var h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? E : b;
  return V.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : h, V;
}
var F = {};
/**
 * @license React
 * use-sync-external-store-shim.development.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var K;
function ce() {
  return K || (K = 1, process.env.NODE_ENV !== "production" && function() {
    typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
    var n = m, e = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    function t(l) {
      {
        for (var s = arguments.length, y = new Array(s > 1 ? s - 1 : 0), a = 1; a < s; a++)
          y[a - 1] = arguments[a];
        o("error", l, y);
      }
    }
    function o(l, s, y) {
      {
        var a = e.ReactDebugCurrentFrame, _ = a.getStackAddendum();
        _ !== "" && (s += "%s", y = y.concat([_]));
        var R = y.map(function(g) {
          return String(g);
        });
        R.unshift("Warning: " + s), Function.prototype.apply.call(console[l], console, R);
      }
    }
    function r(l, s) {
      return l === s && (l !== 0 || 1 / l === 1 / s) || l !== l && s !== s;
    }
    var i = typeof Object.is == "function" ? Object.is : r, S = n.useState, b = n.useEffect, O = n.useLayoutEffect, E = n.useDebugValue, h = !1, u = !1;
    function c(l, s, y) {
      h || n.startTransition !== void 0 && (h = !0, t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
      var a = s();
      if (!u) {
        var _ = s();
        i(a, _) || (t("The result of getSnapshot should be cached to avoid an infinite loop"), u = !0);
      }
      var R = S({
        inst: {
          value: a,
          getSnapshot: s
        }
      }), g = R[0].inst, T = R[1];
      return O(function() {
        g.value = a, g.getSnapshot = s, d(g) && T({
          inst: g
        });
      }, [l, a, s]), b(function() {
        d(g) && T({
          inst: g
        });
        var A = function() {
          d(g) && T({
            inst: g
          });
        };
        return l(A);
      }, [l]), E(a), a;
    }
    function d(l) {
      var s = l.getSnapshot, y = l.value;
      try {
        var a = s();
        return !i(y, a);
      } catch {
        return !0;
      }
    }
    function p(l, s, y) {
      return s();
    }
    var f = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", v = !f, C = v ? p : c, w = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : C;
    F.useSyncExternalStore = w, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
  }()), F;
}
process.env.NODE_ENV === "production" ? P.exports = ae() : P.exports = ce();
var x = P.exports;
const le = (...n) => (e) => {
  n.forEach((t) => {
    typeof t == "function" ? t(e) : t && (t.current = e);
  });
}, de = ({ contentComponent: n }) => {
  const e = x.useSyncExternalStore(n.subscribe, n.getSnapshot, n.getServerSnapshot);
  return m.createElement(m.Fragment, null, Object.values(e));
};
function fe() {
  const n = /* @__PURE__ */ new Set();
  let e = {};
  return {
    /**
     * Subscribe to the editor instance's changes.
     */
    subscribe(t) {
      return n.add(t), () => {
        n.delete(t);
      };
    },
    getSnapshot() {
      return e;
    },
    getServerSnapshot() {
      return e;
    },
    /**
     * Adds a new NodeView Renderer to the editor.
     */
    setRenderer(t, o) {
      e = {
        ...e,
        [t]: oe.createPortal(o.reactElement, o.element, t)
      }, n.forEach((r) => r());
    },
    /**
     * Removes a NodeView Renderer from the editor.
     */
    removeRenderer(t) {
      const o = { ...e };
      delete o[t], e = o, n.forEach((r) => r());
    }
  };
}
class he extends m.Component {
  constructor(e) {
    var t;
    super(e), this.editorContentRef = m.createRef(), this.initialized = !1, this.state = {
      hasContentComponentInitialized: !!(!((t = e.editor) === null || t === void 0) && t.contentComponent)
    };
  }
  componentDidMount() {
    this.init();
  }
  componentDidUpdate() {
    this.init();
  }
  init() {
    const e = this.props.editor;
    if (e && !e.isDestroyed && e.options.element) {
      if (e.contentComponent)
        return;
      const t = this.editorContentRef.current;
      t.append(...e.options.element.childNodes), e.setOptions({
        element: t
      }), e.contentComponent = fe(), this.state.hasContentComponentInitialized || (this.unsubscribeToContentComponent = e.contentComponent.subscribe(() => {
        this.setState((o) => o.hasContentComponentInitialized ? o : {
          hasContentComponentInitialized: !0
        }), this.unsubscribeToContentComponent && this.unsubscribeToContentComponent();
      })), e.createNodeViews(), this.initialized = !0;
    }
  }
  componentWillUnmount() {
    const e = this.props.editor;
    if (!e || (this.initialized = !1, e.isDestroyed || e.view.setProps({
      nodeViews: {}
    }), this.unsubscribeToContentComponent && this.unsubscribeToContentComponent(), e.contentComponent = null, !e.options.element.firstChild))
      return;
    const t = document.createElement("div");
    t.append(...e.options.element.childNodes), e.setOptions({
      element: t
    });
  }
  render() {
    const { editor: e, innerRef: t, ...o } = this.props;
    return m.createElement(
      m.Fragment,
      null,
      m.createElement("div", { ref: le(t, this.editorContentRef), ...o }),
      e?.contentComponent && m.createElement(de, { contentComponent: e.contentComponent })
    );
  }
}
const pe = te((n, e) => {
  const t = m.useMemo(() => Math.floor(Math.random() * 4294967295).toString(), [n.editor]);
  return m.createElement(he, {
    key: t,
    innerRef: e,
    ...n
  });
}), Ne = m.memo(pe);
var ve = function n(e, t) {
  if (e === t) return !0;
  if (e && t && typeof e == "object" && typeof t == "object") {
    if (e.constructor !== t.constructor) return !1;
    var o, r, i;
    if (Array.isArray(e)) {
      if (o = e.length, o != t.length) return !1;
      for (r = o; r-- !== 0; )
        if (!n(e[r], t[r])) return !1;
      return !0;
    }
    if (e instanceof Map && t instanceof Map) {
      if (e.size !== t.size) return !1;
      for (r of e.entries())
        if (!t.has(r[0])) return !1;
      for (r of e.entries())
        if (!n(r[1], t.get(r[0]))) return !1;
      return !0;
    }
    if (e instanceof Set && t instanceof Set) {
      if (e.size !== t.size) return !1;
      for (r of e.entries())
        if (!t.has(r[0])) return !1;
      return !0;
    }
    if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
      if (o = e.length, o != t.length) return !1;
      for (r = o; r-- !== 0; )
        if (e[r] !== t[r]) return !1;
      return !0;
    }
    if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
    if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
    if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
    if (i = Object.keys(e), o = i.length, o !== Object.keys(t).length) return !1;
    for (r = o; r-- !== 0; )
      if (!Object.prototype.hasOwnProperty.call(t, i[r])) return !1;
    for (r = o; r-- !== 0; ) {
      var S = i[r];
      if (!(S === "_owner" && e.$$typeof) && !n(e[S], t[S]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}, me = /* @__PURE__ */ ue(ve), U = { exports: {} }, j = {};
/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var q;
function Se() {
  if (q) return j;
  q = 1;
  var n = m, e = x;
  function t(E, h) {
    return E === h && (E !== 0 || 1 / E === 1 / h) || E !== E && h !== h;
  }
  var o = typeof Object.is == "function" ? Object.is : t, r = e.useSyncExternalStore, i = n.useRef, S = n.useEffect, b = n.useMemo, O = n.useDebugValue;
  return j.useSyncExternalStoreWithSelector = function(E, h, u, c, d) {
    var p = i(null);
    if (p.current === null) {
      var f = { hasValue: !1, value: null };
      p.current = f;
    } else f = p.current;
    p = b(function() {
      function C(a) {
        if (!w) {
          if (w = !0, l = a, a = c(a), d !== void 0 && f.hasValue) {
            var _ = f.value;
            if (d(_, a)) return s = _;
          }
          return s = a;
        }
        if (_ = s, o(l, a)) return _;
        var R = c(a);
        return d !== void 0 && d(_, R) ? _ : (l = a, s = R);
      }
      var w = !1, l, s, y = u === void 0 ? null : u;
      return [function() {
        return C(h());
      }, y === null ? void 0 : function() {
        return C(y());
      }];
    }, [h, u, c, d]);
    var v = r(E, p[0], p[1]);
    return S(function() {
      f.hasValue = !0, f.value = v;
    }, [v]), O(v), v;
  }, j;
}
var B = {};
/**
 * @license React
 * use-sync-external-store-shim/with-selector.development.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var $;
function Ee() {
  return $ || ($ = 1, process.env.NODE_ENV !== "production" && function() {
    typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
    var n = m, e = x;
    function t(h, u) {
      return h === u && (h !== 0 || 1 / h === 1 / u) || h !== h && u !== u;
    }
    var o = typeof Object.is == "function" ? Object.is : t, r = e.useSyncExternalStore, i = n.useRef, S = n.useEffect, b = n.useMemo, O = n.useDebugValue;
    function E(h, u, c, d, p) {
      var f = i(null), v;
      f.current === null ? (v = {
        hasValue: !1,
        value: null
      }, f.current = v) : v = f.current;
      var C = b(function() {
        var y = !1, a, _, R = function(D) {
          if (!y) {
            y = !0, a = D;
            var L = d(D);
            if (p !== void 0 && v.hasValue) {
              var I = v.value;
              if (p(I, L))
                return _ = I, I;
            }
            return _ = L, L;
          }
          var Z = a, N = _;
          if (o(Z, D))
            return N;
          var M = d(D);
          return p !== void 0 && p(N, M) ? N : (a = D, _ = M, M);
        }, g = c === void 0 ? null : c, T = function() {
          return R(u());
        }, A = g === null ? void 0 : function() {
          return R(g());
        };
        return [T, A];
      }, [u, c, d, p]), w = C[0], l = C[1], s = r(h, w, l);
      return S(function() {
        v.hasValue = !0, v.value = s;
      }, [s]), O(s), s;
    }
    B.useSyncExternalStoreWithSelector = E, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
  }()), B;
}
process.env.NODE_ENV === "production" ? U.exports = Se() : U.exports = Ee();
var _e = U.exports;
const ye = typeof window < "u" ? re : Q;
class Oe {
  constructor(e) {
    this.transactionNumber = 0, this.lastTransactionNumber = 0, this.subscribers = /* @__PURE__ */ new Set(), this.editor = e, this.lastSnapshot = { editor: e, transactionNumber: 0 }, this.getSnapshot = this.getSnapshot.bind(this), this.getServerSnapshot = this.getServerSnapshot.bind(this), this.watch = this.watch.bind(this), this.subscribe = this.subscribe.bind(this);
  }
  /**
   * Get the current editor instance.
   */
  getSnapshot() {
    return this.transactionNumber === this.lastTransactionNumber ? this.lastSnapshot : (this.lastTransactionNumber = this.transactionNumber, this.lastSnapshot = { editor: this.editor, transactionNumber: this.transactionNumber }, this.lastSnapshot);
  }
  /**
   * Always disable the editor on the server-side.
   */
  getServerSnapshot() {
    return { editor: null, transactionNumber: 0 };
  }
  /**
   * Subscribe to the editor instance's changes.
   */
  subscribe(e) {
    return this.subscribers.add(e), () => {
      this.subscribers.delete(e);
    };
  }
  /**
   * Watch the editor instance for changes.
   */
  watch(e) {
    if (this.editor = e, this.editor) {
      const t = () => {
        this.transactionNumber += 1, this.subscribers.forEach((r) => r());
      }, o = this.editor;
      return o.on("transaction", t), () => {
        o.off("transaction", t);
      };
    }
  }
}
function ge(n) {
  var e;
  const [t] = Y(() => new Oe(n.editor)), o = _e.useSyncExternalStoreWithSelector(t.subscribe, t.getSnapshot, t.getServerSnapshot, n.selector, (e = n.equalityFn) !== null && e !== void 0 ? e : me);
  return ye(() => t.watch(n.editor), [n.editor, t]), J(o), o;
}
const k = process.env.NODE_ENV !== "production", z = typeof window > "u", Re = z || !!(typeof window < "u" && window.next);
class W {
  constructor(e) {
    this.editor = null, this.subscriptions = /* @__PURE__ */ new Set(), this.isComponentMounted = !1, this.previousDeps = null, this.instanceId = "", this.options = e, this.subscriptions = /* @__PURE__ */ new Set(), this.setEditor(this.getInitialEditor()), this.scheduleDestroy(), this.getEditor = this.getEditor.bind(this), this.getServerSnapshot = this.getServerSnapshot.bind(this), this.subscribe = this.subscribe.bind(this), this.refreshEditorInstance = this.refreshEditorInstance.bind(this), this.scheduleDestroy = this.scheduleDestroy.bind(this), this.onRender = this.onRender.bind(this), this.createEditor = this.createEditor.bind(this);
  }
  setEditor(e) {
    this.editor = e, this.instanceId = Math.random().toString(36).slice(2, 9), this.subscriptions.forEach((t) => t());
  }
  getInitialEditor() {
    if (this.options.current.immediatelyRender === void 0)
      return z || Re ? (k && console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."), null) : this.createEditor();
    if (this.options.current.immediatelyRender && z && k)
      throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");
    return this.options.current.immediatelyRender ? this.createEditor() : null;
  }
  /**
   * Create a new editor instance. And attach event listeners.
   */
  createEditor() {
    const e = {
      ...this.options.current,
      // Always call the most recent version of the callback function by default
      onBeforeCreate: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onBeforeCreate) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onBlur: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onBlur) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onCreate: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onCreate) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onDestroy: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onDestroy) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onFocus: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onFocus) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onSelectionUpdate: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onSelectionUpdate) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onTransaction: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onTransaction) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onUpdate: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onUpdate) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onContentError: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onContentError) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onDrop: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onDrop) === null || i === void 0 ? void 0 : i.call(r, ...o);
      },
      onPaste: (...o) => {
        var r, i;
        return (i = (r = this.options.current).onPaste) === null || i === void 0 ? void 0 : i.call(r, ...o);
      }
    };
    return new se(e);
  }
  /**
   * Get the current editor instance.
   */
  getEditor() {
    return this.editor;
  }
  /**
   * Always disable the editor on the server-side.
   */
  getServerSnapshot() {
    return null;
  }
  /**
   * Subscribe to the editor instance's changes.
   */
  subscribe(e) {
    return this.subscriptions.add(e), () => {
      this.subscriptions.delete(e);
    };
  }
  static compareOptions(e, t) {
    return Object.keys(e).every((o) => ["onCreate", "onBeforeCreate", "onDestroy", "onUpdate", "onTransaction", "onFocus", "onBlur", "onSelectionUpdate", "onContentError", "onDrop", "onPaste"].includes(o) ? !0 : o === "extensions" && e.extensions && t.extensions ? e.extensions.length !== t.extensions.length ? !1 : e.extensions.every((r, i) => {
      var S;
      return r === ((S = t.extensions) === null || S === void 0 ? void 0 : S[i]);
    }) : e[o] === t[o]);
  }
  /**
   * On each render, we will create, update, or destroy the editor instance.
   * @param deps The dependencies to watch for changes
   * @returns A cleanup function
   */
  onRender(e) {
    return () => (this.isComponentMounted = !0, clearTimeout(this.scheduledDestructionTimeout), this.editor && !this.editor.isDestroyed && e.length === 0 ? W.compareOptions(this.options.current, this.editor.options) || this.editor.setOptions({
      ...this.options.current,
      editable: this.editor.isEditable
    }) : this.refreshEditorInstance(e), () => {
      this.isComponentMounted = !1, this.scheduleDestroy();
    });
  }
  /**
   * Recreate the editor instance if the dependencies have changed.
   */
  refreshEditorInstance(e) {
    if (this.editor && !this.editor.isDestroyed) {
      if (this.previousDeps === null) {
        this.previousDeps = e;
        return;
      }
      if (this.previousDeps.length === e.length && this.previousDeps.every((o, r) => o === e[r]))
        return;
    }
    this.editor && !this.editor.isDestroyed && this.editor.destroy(), this.setEditor(this.createEditor()), this.previousDeps = e;
  }
  /**
   * Schedule the destruction of the editor instance.
   * This will only destroy the editor if it was not mounted on the next tick.
   * This is to avoid destroying the editor instance when it's actually still mounted.
   */
  scheduleDestroy() {
    const e = this.instanceId, t = this.editor;
    this.scheduledDestructionTimeout = setTimeout(() => {
      if (this.isComponentMounted && this.instanceId === e) {
        t && t.setOptions(this.options.current);
        return;
      }
      t && !t.isDestroyed && (t.destroy(), this.instanceId === e && this.setEditor(null));
    }, 1);
  }
}
function Me(n = {}, e = []) {
  const t = ee(n);
  t.current = n;
  const [o] = Y(() => new W(t)), r = x.useSyncExternalStore(o.subscribe, o.getEditor, o.getServerSnapshot);
  return J(r), Q(o.onRender(e)), ge({
    editor: r,
    selector: ({ transactionNumber: i }) => n.shouldRerenderOnTransaction === !1 ? null : n.immediatelyRender && i === 0 ? 0 : i + 1
  }), r;
}
const be = X({
  editor: null
});
be.Consumer;
const Ce = X({
  onDragStart: void 0
}), we = () => ne(Ce);
m.forwardRef((n, e) => {
  const { onDragStart: t } = we(), o = n.as || "div";
  return (
    // @ts-ignore
    m.createElement(o, { ...n, ref: e, "data-node-view-wrapper": "", onDragStart: t, style: {
      whiteSpace: "normal",
      ...n.style
    } })
  );
});
function Te(n) {
  return !!(typeof n == "function" && n.prototype && n.prototype.isReactComponent);
}
function De(n) {
  var e;
  return typeof n == "object" && ((e = n.$$typeof) === null || e === void 0 ? void 0 : e.toString()) === "Symbol(react.forward_ref)";
}
function xe() {
  try {
    if (G)
      return parseInt(G.split(".")[0], 10) >= 19;
  } catch {
  }
  return !1;
}
class Ve {
  /**
   * Immediately creates element and renders the provided React component.
   */
  constructor(e, { editor: t, props: o = {}, as: r = "div", className: i = "" }) {
    this.ref = null, this.id = Math.floor(Math.random() * 4294967295).toString(), this.component = e, this.editor = t, this.props = o, this.element = document.createElement(r), this.element.classList.add("react-renderer"), i && this.element.classList.add(...i.split(" ")), this.editor.isInitialized ? ie(() => {
      this.render();
    }) : this.render();
  }
  /**
   * Render the React component.
   */
  render() {
    var e;
    const t = this.component, o = this.props, r = this.editor, i = xe(), S = Te(t), b = De(t), O = { ...o };
    O.ref || (i ? O.ref = (E) => {
      this.ref = E;
    } : (S || b) && (O.ref = (E) => {
      this.ref = E;
    })), this.reactElement = m.createElement(t, { ...O }), (e = r?.contentComponent) === null || e === void 0 || e.setRenderer(this.id, this);
  }
  /**
   * Re-renders the React component with new props.
   */
  updateProps(e = {}) {
    this.props = {
      ...this.props,
      ...e
    }, this.render();
  }
  /**
   * Destroy the React component.
   */
  destroy() {
    var e;
    const t = this.editor;
    (e = t?.contentComponent) === null || e === void 0 || e.removeRenderer(this.id);
  }
  /**
   * Update the attributes of the element that holds the React component.
   */
  updateAttributes(e) {
    Object.keys(e).forEach((t) => {
      this.element.setAttribute(t, e[t]);
    });
  }
}
export {
  Be as CommandManager,
  se as Editor,
  Ne as EditorContent,
  be as EditorContext,
  Pe as Extension,
  Ue as InputRule,
  ze as Mark,
  We as Node,
  Ge as NodePos,
  He as PasteRule,
  he as PureEditorContent,
  Ce as ReactNodeViewContext,
  Ve as ReactRenderer,
  Ke as callOrReturn,
  qe as createChainableState,
  $e as createDocument,
  ke as createNodeFromContent,
  Ye as createStyleTag,
  Je as defaultBlockAt,
  Qe as deleteProps,
  Xe as elementFromString,
  Ze as escapeForRegEx,
  et as findDuplicates,
  tt as findParentNode,
  rt as findParentNodeClosestToPos,
  nt as fromString,
  ot as getAttributes,
  it as getAttributesFromExtensions,
  st as getExtensionField,
  ut as getHTMLFromFragment,
  at as getMarkAttributes,
  ct as getMarkRange,
  lt as getMarkType,
  dt as getMarksBetween,
  ft as getNodeAttributes,
  ht as getNodeType,
  pt as getRenderedAttributes,
  vt as getSchemaByResolvedExtensions,
  mt as getSchemaTypeByName,
  St as getSchemaTypeNameByName,
  Et as getSplittedAttributes,
  _t as getText,
  yt as getTextBetween,
  Ot as getTextContentFromNodes,
  gt as getTextSerializersFromSchema,
  Rt as injectExtensionAttributesToParseRule,
  bt as inputRulesPlugin,
  Ct as isActive,
  wt as isEmptyObject,
  Tt as isExtensionRulesEnabled,
  Dt as isFunction,
  xt as isList,
  At as isMacOS,
  Lt as isMarkActive,
  It as isNodeActive,
  Nt as isNodeEmpty,
  Mt as isNodeSelection,
  Vt as isNumber,
  Ft as isPlainObject,
  jt as isRegExp,
  Bt as isTextSelection,
  Pt as isiOS,
  Ut as markInputRule,
  zt as markPasteRule,
  Wt as mergeAttributes,
  Gt as mergeDeep,
  Ht as minMax,
  Kt as nodeInputRule,
  qt as objectIncludes,
  $t as pasteRulesPlugin,
  kt as resolveFocusPosition,
  Yt as selectionToInsertionEnd,
  Jt as splitExtensions,
  Qt as textblockTypeInputRule,
  Me as useEditor,
  ge as useEditorState,
  we as useReactNodeView,
  Xt as wrappingInputRule
};
//# sourceMappingURL=index.js.map
