import N, { createContext as vt, useContext as Ct, useEffect as B, useMemo as R, useState as y, useCallback as L, useRef as ge } from "react";
import { useFloating as kt, useTransitionStyles as yt, useDismiss as Cn, useInteractions as kn, offset as oe, flip as he, size as yn } from "@floating-ui/react";
import { formatKeyboardShortcut as be, checkBlockIsDefaultType as St, checkDefaultBlockTypeInSchema as Sn, checkBlockHasDefaultProp as Ee, checkBlockTypeHasDefaultProp as te, getDefaultSlashMenuItems as jn, filterSuggestionItems as Tn, mergeCSSClasses as Pe, BlockNoteEditor as _n, inheritedProps as Hn, camelToDataKebab as jt, createStronglyTypedTiptapNode as Tt, propsToAttributes as _t, getParseRules as wn, getBlockFromPos as Mn, createInternalBlockSpec as Rn, addInlineContentKeyboardShortcuts as En, getInlineContentParseRules as Vn, nodeToCustomInlineContent as st, addInlineContentAttributes as Bn, createInternalInlineContentSpec as Ln, stylePropsToAttributes as Pn, getStyleParseRules as On, addStyleAttributes as In, createInternalStyleSpec as Nn } from "@blocknote/core";
import An from "use-prefers-color-scheme";
import Dn, { flushSync as Ht, createPortal as wt } from "react-dom";
import { NodeViewWrapper as Mt, ReactNodeViewRenderer as Rt, NodeViewContent as Et, Mark as Fn } from "@tiptap/react";
const Vt = vt(void 0);
function G(e) {
  return Ct(Vt);
}
var Ve = { exports: {} }, X = {};
/**
 * @license React
 * react-jsx-runtime.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 ct;
function Zn() {
  if (ct)
    return X;
  ct = 1;
  var e = N, t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, i = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, l = { key: !0, ref: !0, __self: !0, __source: !0 };
  function s(c, d, f) {
    var g, h = {}, b = null, S = null;
    f !== void 0 && (b = "" + f), d.key !== void 0 && (b = "" + d.key), d.ref !== void 0 && (S = d.ref);
    for (g in d)
      o.call(d, g) && !l.hasOwnProperty(g) && (h[g] = d[g]);
    if (c && c.defaultProps)
      for (g in d = c.defaultProps, d)
        h[g] === void 0 && (h[g] = d[g]);
    return { $$typeof: t, type: c, key: b, ref: S, props: h, _owner: i.current };
  }
  return X.Fragment = n, X.jsx = s, X.jsxs = s, X;
}
var ee = {};
/**
 * @license React
 * react-jsx-runtime.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 ut;
function Un() {
  return ut || (ut = 1, process.env.NODE_ENV !== "production" && function() {
    var e = N, t = Symbol.for("react.element"), n = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), l = Symbol.for("react.profiler"), s = Symbol.for("react.provider"), c = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), f = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), S = Symbol.for("react.offscreen"), E = Symbol.iterator, Z = "@@iterator";
    function O(r) {
      if (r === null || typeof r != "object")
        return null;
      var u = E && r[E] || r[Z];
      return typeof u == "function" ? u : null;
    }
    var U = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    function w(r) {
      {
        for (var u = arguments.length, m = new Array(u > 1 ? u - 1 : 0), p = 1; p < u; p++)
          m[p - 1] = arguments[p];
        pe("error", r, m);
      }
    }
    function pe(r, u, m) {
      {
        var p = U.ReactDebugCurrentFrame, k = p.getStackAddendum();
        k !== "" && (u += "%s", m = m.concat([k]));
        var j = m.map(function(v) {
          return String(v);
        });
        j.unshift("Warning: " + u), Function.prototype.apply.call(console[r], console, j);
      }
    }
    var xe = !1, ae = !1, ve = !1, Ce = !1, Gt = !1, Ne;
    Ne = Symbol.for("react.module.reference");
    function $t(r) {
      return !!(typeof r == "string" || typeof r == "function" || r === o || r === l || Gt || r === i || r === f || r === g || Ce || r === S || xe || ae || ve || typeof r == "object" && r !== null && (r.$$typeof === b || r.$$typeof === h || r.$$typeof === s || r.$$typeof === c || r.$$typeof === d || // This needs to include all possible module reference object
      // types supported by any Flight configuration anywhere since
      // we don't know which Flight build this will end up being used
      // with.
      r.$$typeof === Ne || r.getModuleId !== void 0));
    }
    function Wt(r, u, m) {
      var p = r.displayName;
      if (p)
        return p;
      var k = u.displayName || u.name || "";
      return k !== "" ? m + "(" + k + ")" : m;
    }
    function Ae(r) {
      return r.displayName || "Context";
    }
    function A(r) {
      if (r == null)
        return null;
      if (typeof r.tag == "number" && w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof r == "function")
        return r.displayName || r.name || null;
      if (typeof r == "string")
        return r;
      switch (r) {
        case o:
          return "Fragment";
        case n:
          return "Portal";
        case l:
          return "Profiler";
        case i:
          return "StrictMode";
        case f:
          return "Suspense";
        case g:
          return "SuspenseList";
      }
      if (typeof r == "object")
        switch (r.$$typeof) {
          case c:
            var u = r;
            return Ae(u) + ".Consumer";
          case s:
            var m = r;
            return Ae(m._context) + ".Provider";
          case d:
            return Wt(r, r.render, "ForwardRef");
          case h:
            var p = r.displayName || null;
            return p !== null ? p : A(r.type) || "Memo";
          case b: {
            var k = r, j = k._payload, v = k._init;
            try {
              return A(v(j));
            } catch {
              return null;
            }
          }
        }
      return null;
    }
    var W = Object.assign, J = 0, De, Fe, Ze, Ue, ze, Ge, $e;
    function We() {
    }
    We.__reactDisabledLog = !0;
    function qt() {
      {
        if (J === 0) {
          De = console.log, Fe = console.info, Ze = console.warn, Ue = console.error, ze = console.group, Ge = console.groupCollapsed, $e = console.groupEnd;
          var r = {
            configurable: !0,
            enumerable: !0,
            value: We,
            writable: !0
          };
          Object.defineProperties(console, {
            info: r,
            log: r,
            warn: r,
            error: r,
            group: r,
            groupCollapsed: r,
            groupEnd: r
          });
        }
        J++;
      }
    }
    function Yt() {
      {
        if (J--, J === 0) {
          var r = {
            configurable: !0,
            enumerable: !0,
            writable: !0
          };
          Object.defineProperties(console, {
            log: W({}, r, {
              value: De
            }),
            info: W({}, r, {
              value: Fe
            }),
            warn: W({}, r, {
              value: Ze
            }),
            error: W({}, r, {
              value: Ue
            }),
            group: W({}, r, {
              value: ze
            }),
            groupCollapsed: W({}, r, {
              value: Ge
            }),
            groupEnd: W({}, r, {
              value: $e
            })
          });
        }
        J < 0 && w("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
      }
    }
    var ke = U.ReactCurrentDispatcher, ye;
    function ie(r, u, m) {
      {
        if (ye === void 0)
          try {
            throw Error();
          } catch (k) {
            var p = k.stack.trim().match(/\n( *(at )?)/);
            ye = p && p[1] || "";
          }
        return `
` + ye + r;
      }
    }
    var Se = !1, le;
    {
      var Kt = typeof WeakMap == "function" ? WeakMap : Map;
      le = new Kt();
    }
    function qe(r, u) {
      if (!r || Se)
        return "";
      {
        var m = le.get(r);
        if (m !== void 0)
          return m;
      }
      var p;
      Se = !0;
      var k = Error.prepareStackTrace;
      Error.prepareStackTrace = void 0;
      var j;
      j = ke.current, ke.current = null, qt();
      try {
        if (u) {
          var v = function() {
            throw Error();
          };
          if (Object.defineProperty(v.prototype, "props", {
            set: function() {
              throw Error();
            }
          }), typeof Reflect == "object" && Reflect.construct) {
            try {
              Reflect.construct(v, []);
            } catch (D) {
              p = D;
            }
            Reflect.construct(r, [], v);
          } else {
            try {
              v.call();
            } catch (D) {
              p = D;
            }
            r.call(v.prototype);
          }
        } else {
          try {
            throw Error();
          } catch (D) {
            p = D;
          }
          r();
        }
      } catch (D) {
        if (D && p && typeof D.stack == "string") {
          for (var x = D.stack.split(`
`), P = p.stack.split(`
`), M = x.length - 1, V = P.length - 1; M >= 1 && V >= 0 && x[M] !== P[V]; )
            V--;
          for (; M >= 1 && V >= 0; M--, V--)
            if (x[M] !== P[V]) {
              if (M !== 1 || V !== 1)
                do
                  if (M--, V--, V < 0 || x[M] !== P[V]) {
                    var I = `
` + x[M].replace(" at new ", " at ");
                    return r.displayName && I.includes("<anonymous>") && (I = I.replace("<anonymous>", r.displayName)), typeof r == "function" && le.set(r, I), I;
                  }
                while (M >= 1 && V >= 0);
              break;
            }
        }
      } finally {
        Se = !1, ke.current = j, Yt(), Error.prepareStackTrace = k;
      }
      var Y = r ? r.displayName || r.name : "", lt = Y ? ie(Y) : "";
      return typeof r == "function" && le.set(r, lt), lt;
    }
    function Jt(r, u, m) {
      return qe(r, !1);
    }
    function Qt(r) {
      var u = r.prototype;
      return !!(u && u.isReactComponent);
    }
    function se(r, u, m) {
      if (r == null)
        return "";
      if (typeof r == "function")
        return qe(r, Qt(r));
      if (typeof r == "string")
        return ie(r);
      switch (r) {
        case f:
          return ie("Suspense");
        case g:
          return ie("SuspenseList");
      }
      if (typeof r == "object")
        switch (r.$$typeof) {
          case d:
            return Jt(r.render);
          case h:
            return se(r.type, u, m);
          case b: {
            var p = r, k = p._payload, j = p._init;
            try {
              return se(j(k), u, m);
            } catch {
            }
          }
        }
      return "";
    }
    var ce = Object.prototype.hasOwnProperty, Ye = {}, Ke = U.ReactDebugCurrentFrame;
    function ue(r) {
      if (r) {
        var u = r._owner, m = se(r.type, r._source, u ? u.type : null);
        Ke.setExtraStackFrame(m);
      } else
        Ke.setExtraStackFrame(null);
    }
    function Xt(r, u, m, p, k) {
      {
        var j = Function.call.bind(ce);
        for (var v in r)
          if (j(r, v)) {
            var x = void 0;
            try {
              if (typeof r[v] != "function") {
                var P = Error((p || "React class") + ": " + m + " type `" + v + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof r[v] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
                throw P.name = "Invariant Violation", P;
              }
              x = r[v](u, v, p, m, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
            } catch (M) {
              x = M;
            }
            x && !(x instanceof Error) && (ue(k), w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", p || "React class", m, v, typeof x), ue(null)), x instanceof Error && !(x.message in Ye) && (Ye[x.message] = !0, ue(k), w("Failed %s type: %s", m, x.message), ue(null));
          }
      }
    }
    var en = Array.isArray;
    function je(r) {
      return en(r);
    }
    function tn(r) {
      {
        var u = typeof Symbol == "function" && Symbol.toStringTag, m = u && r[Symbol.toStringTag] || r.constructor.name || "Object";
        return m;
      }
    }
    function nn(r) {
      try {
        return Je(r), !1;
      } catch {
        return !0;
      }
    }
    function Je(r) {
      return "" + r;
    }
    function Qe(r) {
      if (nn(r))
        return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", tn(r)), Je(r);
    }
    var Q = U.ReactCurrentOwner, on = {
      key: !0,
      ref: !0,
      __self: !0,
      __source: !0
    }, Xe, et, Te;
    Te = {};
    function rn(r) {
      if (ce.call(r, "ref")) {
        var u = Object.getOwnPropertyDescriptor(r, "ref").get;
        if (u && u.isReactWarning)
          return !1;
      }
      return r.ref !== void 0;
    }
    function an(r) {
      if (ce.call(r, "key")) {
        var u = Object.getOwnPropertyDescriptor(r, "key").get;
        if (u && u.isReactWarning)
          return !1;
      }
      return r.key !== void 0;
    }
    function ln(r, u) {
      if (typeof r.ref == "string" && Q.current && u && Q.current.stateNode !== u) {
        var m = A(Q.current.type);
        Te[m] || (w('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', A(Q.current.type), r.ref), Te[m] = !0);
      }
    }
    function sn(r, u) {
      {
        var m = function() {
          Xe || (Xe = !0, w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u));
        };
        m.isReactWarning = !0, Object.defineProperty(r, "key", {
          get: m,
          configurable: !0
        });
      }
    }
    function cn(r, u) {
      {
        var m = function() {
          et || (et = !0, w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u));
        };
        m.isReactWarning = !0, Object.defineProperty(r, "ref", {
          get: m,
          configurable: !0
        });
      }
    }
    var un = function(r, u, m, p, k, j, v) {
      var x = {
        // This tag allows us to uniquely identify this as a React Element
        $$typeof: t,
        // Built-in properties that belong on the element
        type: r,
        key: u,
        ref: m,
        props: v,
        // Record the component responsible for creating this element.
        _owner: j
      };
      return x._store = {}, Object.defineProperty(x._store, "validated", {
        configurable: !1,
        enumerable: !1,
        writable: !0,
        value: !1
      }), Object.defineProperty(x, "_self", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: p
      }), Object.defineProperty(x, "_source", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: k
      }), Object.freeze && (Object.freeze(x.props), Object.freeze(x)), x;
    };
    function dn(r, u, m, p, k) {
      {
        var j, v = {}, x = null, P = null;
        m !== void 0 && (Qe(m), x = "" + m), an(u) && (Qe(u.key), x = "" + u.key), rn(u) && (P = u.ref, ln(u, k));
        for (j in u)
          ce.call(u, j) && !on.hasOwnProperty(j) && (v[j] = u[j]);
        if (r && r.defaultProps) {
          var M = r.defaultProps;
          for (j in M)
            v[j] === void 0 && (v[j] = M[j]);
        }
        if (x || P) {
          var V = typeof r == "function" ? r.displayName || r.name || "Unknown" : r;
          x && sn(v, V), P && cn(v, V);
        }
        return un(r, x, P, k, p, Q.current, v);
      }
    }
    var _e = U.ReactCurrentOwner, tt = U.ReactDebugCurrentFrame;
    function q(r) {
      if (r) {
        var u = r._owner, m = se(r.type, r._source, u ? u.type : null);
        tt.setExtraStackFrame(m);
      } else
        tt.setExtraStackFrame(null);
    }
    var He;
    He = !1;
    function we(r) {
      return typeof r == "object" && r !== null && r.$$typeof === t;
    }
    function nt() {
      {
        if (_e.current) {
          var r = A(_e.current.type);
          if (r)
            return `

Check the render method of \`` + r + "`.";
        }
        return "";
      }
    }
    function fn(r) {
      {
        if (r !== void 0) {
          var u = r.fileName.replace(/^.*[\\\/]/, ""), m = r.lineNumber;
          return `

Check your code at ` + u + ":" + m + ".";
        }
        return "";
      }
    }
    var ot = {};
    function gn(r) {
      {
        var u = nt();
        if (!u) {
          var m = typeof r == "string" ? r : r.displayName || r.name;
          m && (u = `

Check the top-level render call using <` + m + ">.");
        }
        return u;
      }
    }
    function rt(r, u) {
      {
        if (!r._store || r._store.validated || r.key != null)
          return;
        r._store.validated = !0;
        var m = gn(u);
        if (ot[m])
          return;
        ot[m] = !0;
        var p = "";
        r && r._owner && r._owner !== _e.current && (p = " It was passed a child from " + A(r._owner.type) + "."), q(r), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', m, p), q(null);
      }
    }
    function at(r, u) {
      {
        if (typeof r != "object")
          return;
        if (je(r))
          for (var m = 0; m < r.length; m++) {
            var p = r[m];
            we(p) && rt(p, u);
          }
        else if (we(r))
          r._store && (r._store.validated = !0);
        else if (r) {
          var k = O(r);
          if (typeof k == "function" && k !== r.entries)
            for (var j = k.call(r), v; !(v = j.next()).done; )
              we(v.value) && rt(v.value, u);
        }
      }
    }
    function mn(r) {
      {
        var u = r.type;
        if (u == null || typeof u == "string")
          return;
        var m;
        if (typeof u == "function")
          m = u.propTypes;
        else if (typeof u == "object" && (u.$$typeof === d || // Note: Memo only checks outer props here.
        // Inner props are checked in the reconciler.
        u.$$typeof === h))
          m = u.propTypes;
        else
          return;
        if (m) {
          var p = A(u);
          Xt(m, r.props, "prop", p, r);
        } else if (u.PropTypes !== void 0 && !He) {
          He = !0;
          var k = A(u);
          w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", k || "Unknown");
        }
        typeof u.getDefaultProps == "function" && !u.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
      }
    }
    function hn(r) {
      {
        for (var u = Object.keys(r.props), m = 0; m < u.length; m++) {
          var p = u[m];
          if (p !== "children" && p !== "key") {
            q(r), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", p), q(null);
            break;
          }
        }
        r.ref !== null && (q(r), w("Invalid attribute `ref` supplied to `React.Fragment`."), q(null));
      }
    }
    function it(r, u, m, p, k, j) {
      {
        var v = $t(r);
        if (!v) {
          var x = "";
          (r === void 0 || typeof r == "object" && r !== null && Object.keys(r).length === 0) && (x += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
          var P = fn(k);
          P ? x += P : x += nt();
          var M;
          r === null ? M = "null" : je(r) ? M = "array" : r !== void 0 && r.$$typeof === t ? (M = "<" + (A(r.type) || "Unknown") + " />", x = " Did you accidentally export a JSX literal instead of a component?") : M = typeof r, w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", M, x);
        }
        var V = dn(r, u, m, k, j);
        if (V == null)
          return V;
        if (v) {
          var I = u.children;
          if (I !== void 0)
            if (p)
              if (je(I)) {
                for (var Y = 0; Y < I.length; Y++)
                  at(I[Y], r);
                Object.freeze && Object.freeze(I);
              } else
                w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
            else
              at(I, r);
        }
        return r === o ? hn(V) : mn(V), V;
      }
    }
    function bn(r, u, m) {
      return it(r, u, m, !0);
    }
    function pn(r, u, m) {
      return it(r, u, m, !1);
    }
    var xn = pn, vn = bn;
    ee.Fragment = o, ee.jsx = xn, ee.jsxs = vn;
  }()), ee;
}
process.env.NODE_ENV === "production" ? Ve.exports = Zn() : Ve.exports = Un();
var a = Ve.exports;
function T(e) {
  const t = G();
  if (!(t != null && t.editor))
    throw new Error(
      "useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component"
    );
  return t.editor;
}
function Oe(e, t) {
  const n = G();
  t || (t = n == null ? void 0 : n.editor), B(() => {
    if (!t)
      throw new Error(
        "'editor' is required, either from BlockNoteContext or as a function argument"
      );
    return t.onChange(e);
  }, [e, t]);
}
function Ie(e, t) {
  const n = G();
  t || (t = n == null ? void 0 : n.editor), B(() => {
    if (!t)
      throw new Error(
        "'editor' is required, either from BlockNoteContext or as a function argument"
      );
    return t.onSelectionChange(e);
  }, [e, t]);
}
function $(e, t) {
  Oe(e, t), Ie(e, t);
}
function re(e, t, n, o) {
  const { refs: i, update: l, context: s, floatingStyles: c } = kt({
    open: e,
    ...o
  }), { isMounted: d, styles: f } = yt(s), g = Cn(s), { getReferenceProps: h, getFloatingProps: b } = kn([g]);
  return B(() => {
    l();
  }, [t, l]), B(() => {
    t !== null && i.setReference({
      getBoundingClientRect: () => t
    });
  }, [t, i]), R(
    () => ({
      isMounted: d,
      ref: i.setFloating,
      style: {
        display: "flex",
        ...f,
        ...c,
        zIndex: n
      },
      getFloatingProps: b,
      getReferenceProps: h
    }),
    [
      c,
      d,
      i.setFloating,
      f,
      n,
      b,
      h
    ]
  );
}
function K(e) {
  const [t, n] = y();
  return B(() => e((o) => {
    n({ ...o });
  }), [e]), t;
}
function zn(e) {
  return (t) => {
    e.forEach((n) => {
      typeof n == "function" ? n(t) : n != null && (n.current = t);
    });
  };
}
const Gn = vt(
  void 0
);
function C() {
  return Ct(Gn);
}
var Bt = {
  color: void 0,
  size: void 0,
  className: void 0,
  style: void 0,
  attr: void 0
}, dt = N.createContext && N.createContext(Bt), z = globalThis && globalThis.__assign || function() {
  return z = Object.assign || function(e) {
    for (var t, n = 1, o = arguments.length; n < o; n++) {
      t = arguments[n];
      for (var i in t)
        Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
    }
    return e;
  }, z.apply(this, arguments);
}, $n = globalThis && globalThis.__rest || function(e, t) {
  var n = {};
  for (var o in e)
    Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var i = 0, o = Object.getOwnPropertySymbols(e); i < o.length; i++)
      t.indexOf(o[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[i]) && (n[o[i]] = e[o[i]]);
  return n;
};
function Lt(e) {
  return e && e.map(function(t, n) {
    return N.createElement(t.tag, z({
      key: n
    }, t.attr), Lt(t.child));
  });
}
function _(e) {
  return function(t) {
    return N.createElement(Wn, z({
      attr: z({}, e.attr)
    }, t), Lt(e.child));
  };
}
function Wn(e) {
  var t = function(n) {
    var o = e.attr, i = e.size, l = e.title, s = $n(e, ["attr", "size", "title"]), c = i || n.size || "1em", d;
    return n.className && (d = n.className), e.className && (d = (d ? d + " " : "") + e.className), N.createElement("svg", z({
      stroke: "currentColor",
      fill: "currentColor",
      strokeWidth: "0"
    }, n.attr, o, s, {
      className: d,
      style: z(z({
        color: e.color || n.color
      }, n.style), e.style),
      height: c,
      width: c,
      xmlns: "http://www.w3.org/2000/svg"
    }), l && N.createElement("title", null, l), e.children);
  };
  return dt !== void 0 ? N.createElement(dt.Consumer, null, function(n) {
    return t(n);
  }) : t(Bt);
}
function qn(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M23 11.9998L15.9289 19.0708L14.5147 17.6566L20.1716 11.9998L14.5147 6.34292L15.9289 4.92871L23 11.9998ZM3.82843 11.9998L9.48528 17.6566L8.07107 19.0708L1 11.9998L8.07107 4.92871L9.48528 6.34292L3.82843 11.9998Z" } }] })(e);
}
function Yn(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z" } }] })(e);
}
function Kn(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z" } }] })(e);
}
function Jn(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z" } }] })(e);
}
function Qn(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z" } }] })(e);
}
function Xn(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z" } }] })(e);
}
function Pt(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z" } }] })(e);
}
function Ot(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z" } }] })(e);
}
function It(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z" } }] })(e);
}
function eo(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z" } }] })(e);
}
function to(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z" } }] })(e);
}
function no(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z" } }] })(e);
}
function oo(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z" } }] })(e);
}
function Nt(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M18.3643 15.5353L16.95 14.1211L18.3643 12.7069C20.3169 10.7543 20.3169 7.58847 18.3643 5.63585C16.4116 3.68323 13.2458 3.68323 11.2932 5.63585L9.87898 7.05007L8.46477 5.63585L9.87898 4.22164C12.6127 1.48797 17.0448 1.48797 19.7785 4.22164C22.5121 6.95531 22.5121 11.3875 19.7785 14.1211L18.3643 15.5353ZM15.5358 18.3638L14.1216 19.778C11.388 22.5117 6.9558 22.5117 4.22213 19.778C1.48846 17.0443 1.48846 12.6122 4.22213 9.87849L5.63634 8.46428L7.05055 9.87849L5.63634 11.2927C3.68372 13.2453 3.68372 16.4112 5.63634 18.3638C7.58896 20.3164 10.7548 20.3164 12.7074 18.3638L14.1216 16.9496L15.5358 18.3638ZM14.8287 7.75717L16.2429 9.17139L9.17187 16.2425L7.75766 14.8282L14.8287 7.75717Z" } }] })(e);
}
function At(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" } }] })(e);
}
function Dt(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" } }] })(e);
}
function ro(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z" } }] })(e);
}
function ao(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z" } }] })(e);
}
function ne(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M13 6V21H11V6H5V4H19V6H13Z" } }] })(e);
}
function io(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z" } }] })(e);
}
function lo(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z" } }] })(e);
}
function so(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z" } }] })(e);
}
function co(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z" } }] })(e);
}
function F(e) {
  const t = G();
  if (e || (e = t == null ? void 0 : t.editor), !e)
    throw new Error(
      "'editor' is required, either from BlockNoteContext or as a function argument"
    );
  const n = e, [o, i] = y(() => {
    var l;
    return ((l = n.getSelection()) == null ? void 0 : l.blocks) || [n.getTextCursorPosition().block];
  });
  return $(
    () => {
      var l;
      return i(
        ((l = n.getSelection()) == null ? void 0 : l.blocks) || [n.getTextCursorPosition().block]
      );
    },
    n
  ), o;
}
function H() {
  return G().editor.dictionary;
}
const uo = {
  bold: Xn,
  italic: no,
  underline: io,
  strike: ro,
  code: qn
};
function fo(e, t) {
  return e in t.schema.styleSchema && t.schema.styleSchema[e].type === e && t.schema.styleSchema[e].propSchema === "boolean";
}
const de = (e) => {
  const t = H(), n = C(), o = T(), i = fo(
    e.basicTextStyle,
    o
  ), l = F(o), [s, c] = y(
    e.basicTextStyle in o.getActiveStyles()
  );
  $(() => {
    i && c(e.basicTextStyle in o.getActiveStyles());
  }, o);
  const d = (h) => {
    if (i) {
      if (o.schema.styleSchema[h].propSchema !== "boolean")
        throw new Error("can only toggle boolean styles");
      o.toggleStyles({ [h]: !0 }), setTimeout(() => {
        o.focus();
      });
    }
  };
  if (!R(() => i ? !!l.find((h) => h.content !== void 0) : !1, [i, l]))
    return null;
  const g = uo[e.basicTextStyle];
  return /* @__PURE__ */ a.jsx(
    n.FormattingToolbar.Button,
    {
      className: "bn-button",
      "data-test": e.basicTextStyle,
      onClick: () => d(e.basicTextStyle),
      isSelected: s,
      label: t.formatting_toolbar[e.basicTextStyle].tooltip,
      mainTooltip: t.formatting_toolbar[e.basicTextStyle].tooltip,
      secondaryTooltip: be(
        t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,
        t.generic.ctrl_shortcut
      ),
      icon: /* @__PURE__ */ a.jsx(g, {})
    }
  );
}, Be = (e) => {
  const t = e.textColor || "default", n = e.backgroundColor || "default", o = e.size || 16, i = R(
    () => ({
      pointerEvents: "none",
      fontSize: (o * 0.75).toString() + "px",
      height: o.toString() + "px",
      lineHeight: o.toString() + "px",
      textAlign: "center",
      width: o.toString() + "px"
    }),
    [o]
  );
  return /* @__PURE__ */ a.jsx(
    "div",
    {
      className: "bn-color-icon",
      "data-background-color": n,
      "data-text-color": t,
      style: i,
      children: "A"
    }
  );
}, ft = [
  "default",
  "gray",
  "brown",
  "red",
  "orange",
  "yellow",
  "green",
  "blue",
  "purple",
  "pink"
], Ft = (e) => {
  const t = C(), n = H(), o = () => e.text ? /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    /* @__PURE__ */ a.jsx(t.Generic.Menu.Label, { children: n.color_picker.text_title }),
    ft.map((l) => /* @__PURE__ */ a.jsx(
      t.Generic.Menu.Item,
      {
        onClick: () => {
          e.onClick && e.onClick(), e.text.setColor(l);
        },
        "data-test": "text-color-" + l,
        icon: /* @__PURE__ */ a.jsx(Be, { textColor: l, size: e.iconSize }),
        checked: e.text.color === l,
        children: n.color_picker.colors[l]
      },
      "text-color-" + l
    ))
  ] }) : null, i = () => e.background ? /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    /* @__PURE__ */ a.jsx(t.Generic.Menu.Label, { children: n.color_picker.background_title }),
    ft.map((l) => /* @__PURE__ */ a.jsx(
      t.Generic.Menu.Item,
      {
        onClick: () => {
          e.onClick && e.onClick(), e.background.setColor(l);
        },
        "data-test": "background-color-" + l,
        icon: /* @__PURE__ */ a.jsx(Be, { backgroundColor: l, size: e.iconSize }),
        checked: e.background.color === l,
        children: n.color_picker.colors[l]
      },
      "background-color-" + l
    ))
  ] }) : null;
  return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    /* @__PURE__ */ a.jsx(o, {}),
    /* @__PURE__ */ a.jsx(i, {})
  ] });
};
function gt(e, t) {
  return `${e}Color` in t.schema.styleSchema && t.schema.styleSchema[`${e}Color`].type === `${e}Color` && t.schema.styleSchema[`${e}Color`].propSchema === "string";
}
const go = () => {
  const e = C(), t = H(), n = T(), o = gt("text", n), i = gt("background", n), l = F(n), [s, c] = y(
    o && n.getActiveStyles().textColor || "default"
  ), [d, f] = y(
    i && n.getActiveStyles().backgroundColor || "default"
  );
  $(() => {
    o && c(n.getActiveStyles().textColor || "default"), i && f(
      n.getActiveStyles().backgroundColor || "default"
    );
  }, n);
  const g = L(
    (S) => {
      if (!o)
        throw Error(
          "Tried to set text color, but style does not exist in editor schema."
        );
      S === "default" ? n.removeStyles({ textColor: S }) : n.addStyles({ textColor: S }), setTimeout(() => {
        n.focus();
      });
    },
    [n, o]
  ), h = L(
    (S) => {
      if (!i)
        throw Error(
          "Tried to set background color, but style does not exist in editor schema."
        );
      S === "default" ? n.removeStyles({ backgroundColor: S }) : n.addStyles({ backgroundColor: S }), setTimeout(() => {
        n.focus();
      });
    },
    [i, n]
  );
  return R(() => {
    if (!o && !i)
      return !1;
    for (const S of l)
      if (S.content !== void 0)
        return !0;
    return !1;
  }, [i, l, o]) ? /* @__PURE__ */ a.jsxs(e.Generic.Menu.Root, { children: [
    /* @__PURE__ */ a.jsx(e.Generic.Menu.Trigger, { children: /* @__PURE__ */ a.jsx(
      e.FormattingToolbar.Button,
      {
        className: "bn-button",
        "data-test": "colors",
        label: t.formatting_toolbar.colors.tooltip,
        mainTooltip: t.formatting_toolbar.colors.tooltip,
        icon: /* @__PURE__ */ a.jsx(
          Be,
          {
            textColor: s,
            backgroundColor: d,
            size: 20
          }
        )
      }
    ) }),
    /* @__PURE__ */ a.jsx(
      e.Generic.Menu.Dropdown,
      {
        className: "bn-menu-dropdown bn-color-picker-dropdown",
        children: /* @__PURE__ */ a.jsx(
          Ft,
          {
            text: o ? {
              color: s,
              setColor: g
            } : void 0,
            background: i ? {
              color: d,
              setColor: h
            } : void 0
          }
        )
      }
    )
  ] }) : null;
}, Zt = (e) => {
  const t = C(), n = H(), { url: o, text: i, editLink: l } = e, [s, c] = y(o), [d, f] = y(i);
  B(() => {
    c(o), f(i);
  }, [i, o]);
  const g = L(
    (E) => {
      E.key === "Enter" && (E.preventDefault(), l(s, d));
    },
    [l, s, d]
  ), h = L(
    (E) => c(E.currentTarget.value),
    []
  ), b = L(
    (E) => f(E.currentTarget.value),
    []
  ), S = L(
    () => l(s, d),
    [l, s, d]
  );
  return /* @__PURE__ */ a.jsxs(t.Generic.Form.Root, { children: [
    /* @__PURE__ */ a.jsx(
      t.Generic.Form.TextInput,
      {
        className: "bn-text-input",
        name: "url",
        icon: /* @__PURE__ */ a.jsx(Nt, {}),
        autoFocus: !0,
        placeholder: n.link_toolbar.form.url_placeholder,
        value: s,
        onKeyDown: g,
        onChange: h,
        onSubmit: S
      }
    ),
    /* @__PURE__ */ a.jsx(
      t.Generic.Form.TextInput,
      {
        className: "bn-text-input",
        name: "title",
        icon: /* @__PURE__ */ a.jsx(ne, {}),
        placeholder: n.link_toolbar.form.title_placeholder,
        value: d,
        onKeyDown: g,
        onChange: b,
        onSubmit: S
      }
    )
  ] });
};
function mo(e) {
  return "link" in e.schema.inlineContentSchema && e.schema.inlineContentSchema.link === "link";
}
const ho = () => {
  const e = T(), t = C(), n = H(), o = mo(e), i = F(e), [l, s] = y(e.getSelectedLinkUrl() || ""), [c, d] = y(e.getSelectedText());
  $(() => {
    d(e.getSelectedText() || ""), s(e.getSelectedLinkUrl() || "");
  }, e);
  const f = L(
    (h, b) => {
      e.createLink(h, b), e.focus();
    },
    [e]
  );
  return !R(() => {
    if (!o)
      return !1;
    for (const h of i)
      if (h.content === void 0)
        return !1;
    return !0;
  }, [o, i]) || !("link" in e.schema.inlineContentSchema) ? null : /* @__PURE__ */ a.jsxs(t.Generic.Popover.Root, { children: [
    /* @__PURE__ */ a.jsx(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ a.jsx(
      t.FormattingToolbar.Button,
      {
        className: "bn-button",
        "data-test": "createLink",
        label: n.formatting_toolbar.link.tooltip,
        mainTooltip: n.formatting_toolbar.link.tooltip,
        secondaryTooltip: be(
          n.formatting_toolbar.link.secondary_tooltip,
          n.generic.ctrl_shortcut
        ),
        icon: /* @__PURE__ */ a.jsx(Nt, {})
      }
    ) }),
    /* @__PURE__ */ a.jsx(
      t.Generic.Popover.Content,
      {
        className: "bn-popover-content bn-form-popover",
        variant: "form-popover",
        children: /* @__PURE__ */ a.jsx(Zt, { url: l, text: c, editLink: f })
      }
    )
  ] });
}, bo = () => {
  const e = H(), t = C(), n = T(), [o, i] = y(), l = F(n), s = R(() => {
    if (l.length !== 1)
      return;
    const f = l[0];
    if (St("image", f, n))
      return i(f.props.caption), f;
  }, [n, l]), c = L(
    (f) => {
      s && Sn("image", n) && f.key === "Enter" && (f.preventDefault(), n.updateBlock(s, {
        type: "image",
        props: {
          caption: o
        }
      }));
    },
    [o, n, s]
  ), d = L(
    (f) => i(f.currentTarget.value),
    []
  );
  return s ? /* @__PURE__ */ a.jsxs(t.Generic.Popover.Root, { children: [
    /* @__PURE__ */ a.jsx(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ a.jsx(
      t.FormattingToolbar.Button,
      {
        className: "bn-button",
        label: e.formatting_toolbar.image_caption.tooltip,
        mainTooltip: e.formatting_toolbar.image_caption.tooltip,
        icon: /* @__PURE__ */ a.jsx(ne, {}),
        isSelected: s.props.caption !== ""
      }
    ) }),
    /* @__PURE__ */ a.jsx(
      t.Generic.Popover.Content,
      {
        className: "bn-popover-content bn-form-popover",
        variant: "form-popover",
        children: /* @__PURE__ */ a.jsx(t.Generic.Form.Root, { children: /* @__PURE__ */ a.jsx(
          t.Generic.Form.TextInput,
          {
            name: "image-caption",
            icon: /* @__PURE__ */ a.jsx(ne, {}),
            value: o || "",
            autoFocus: !0,
            placeholder: e.formatting_toolbar.image_caption.input_placeholder,
            onKeyDown: c,
            onChange: d
          }
        ) })
      }
    )
  ] }) : null;
}, po = () => {
  const e = H(), t = C(), n = T(), o = F(n), [i, l] = y(
    () => n.canNestBlock()
  );
  $(() => {
    l(n.canNestBlock());
  }, n);
  const s = L(() => {
    n.focus(), n.nestBlock();
  }, [n]);
  return R(() => !o.find(
    (d) => n.schema.blockSchema[d.type].content !== "inline"
  ), [n.schema.blockSchema, o]) ? /* @__PURE__ */ a.jsx(
    t.FormattingToolbar.Button,
    {
      className: "bn-button",
      "data-test": "nestBlock",
      onClick: s,
      isDisabled: !i,
      label: e.formatting_toolbar.nest.tooltip,
      mainTooltip: e.formatting_toolbar.nest.tooltip,
      secondaryTooltip: be(
        e.formatting_toolbar.nest.secondary_tooltip,
        e.generic.ctrl_shortcut
      ),
      icon: /* @__PURE__ */ a.jsx(to, {})
    }
  ) : null;
}, xo = () => {
  const e = H(), t = C(), n = T(), o = F(n), [i, l] = y(
    () => n.canUnnestBlock()
  );
  $(() => {
    l(n.canUnnestBlock());
  }, n);
  const s = L(() => {
    n.focus(), n.unnestBlock();
  }, [n]);
  return R(() => !o.find(
    (d) => n.schema.blockSchema[d.type].content !== "inline"
  ), [n.schema.blockSchema, o]) ? /* @__PURE__ */ a.jsx(
    t.FormattingToolbar.Button,
    {
      className: "bn-button",
      "data-test": "unnestBlock",
      onClick: s,
      isDisabled: !i,
      label: e.formatting_toolbar.unnest.tooltip,
      mainTooltip: e.formatting_toolbar.unnest.tooltip,
      secondaryTooltip: be(
        e.formatting_toolbar.unnest.secondary_tooltip,
        e.generic.ctrl_shortcut
      ),
      icon: /* @__PURE__ */ a.jsx(eo, {})
    }
  ) : null;
}, vo = (e) => {
  const t = C(), n = H(), { block: o } = e, i = T(), [l, s] = y(""), c = L(
    (g) => {
      s(g.currentTarget.value);
    },
    []
  ), d = L(
    (g) => {
      g.key === "Enter" && (g.preventDefault(), i.updateBlock(o, {
        type: "image",
        props: {
          url: l
        }
      }));
    },
    [i, o, l]
  ), f = L(() => {
    i.updateBlock(o, {
      type: "image",
      props: {
        url: l
      }
    });
  }, [i, o, l]);
  return /* @__PURE__ */ a.jsxs(t.ImagePanel.TabPanel, { className: "bn-tab-panel", children: [
    /* @__PURE__ */ a.jsx(
      t.ImagePanel.TextInput,
      {
        className: "bn-text-input",
        placeholder: n.image_panel.embed.url_placeholder,
        value: l,
        onChange: c,
        onKeyDown: d,
        "data-test": "embed-input"
      }
    ),
    /* @__PURE__ */ a.jsx(
      t.ImagePanel.Button,
      {
        className: "bn-button",
        onClick: f,
        "data-test": "embed-input-button",
        children: n.image_panel.embed.embed_button
      }
    )
  ] });
}, Co = (e) => {
  const t = C(), n = H(), { block: o, setLoading: i } = e, l = T(), [s, c] = y(!1);
  B(() => {
    s && setTimeout(() => {
      c(!1);
    }, 3e3);
  }, [s]);
  const d = L(
    (f) => {
      if (f === null)
        return;
      async function g(h) {
        if (i(!0), l.uploadFile !== void 0)
          try {
            const b = await l.uploadFile(h);
            l.updateBlock(o, {
              type: "image",
              props: {
                url: b
              }
            });
          } catch {
            c(!0);
          } finally {
            i(!1);
          }
      }
      g(f);
    },
    [o, l, i]
  );
  return /* @__PURE__ */ a.jsxs(t.ImagePanel.TabPanel, { className: "bn-tab-panel", children: [
    /* @__PURE__ */ a.jsx(
      t.ImagePanel.FileInput,
      {
        className: "bn-file-input",
        "data-test": "upload-input",
        placeholder: n.image_panel.upload.file_placeholder,
        value: null,
        onChange: d
      }
    ),
    s && /* @__PURE__ */ a.jsx("div", { className: "bn-error-text", children: n.image_panel.upload.upload_error })
  ] });
}, Ut = (e) => {
  const t = C(), n = H(), o = T(), [i, l] = y(!1), s = e.tabs ?? [
    ...o.uploadFile !== void 0 ? [
      {
        name: n.image_panel.upload.title,
        tabPanel: /* @__PURE__ */ a.jsx(Co, { block: e.block, setLoading: l })
      }
    ] : [],
    {
      name: n.image_panel.embed.title,
      tabPanel: /* @__PURE__ */ a.jsx(vo, { block: e.block })
    }
  ], [c, d] = y(
    e.defaultOpenTab || s[0].name
  );
  return /* @__PURE__ */ a.jsx(
    t.ImagePanel.Root,
    {
      className: "bn-panel",
      defaultOpenTab: c,
      openTab: c,
      setOpenTab: d,
      tabs: s,
      loading: i
    }
  );
}, ko = () => {
  const e = H(), t = C(), n = T(), o = F(n), [i, l] = y(!1);
  B(() => {
    l(!1);
  }, [o]);
  const s = o.length === 1 ? o[0] : void 0;
  return s === void 0 || s.type !== "image" || !St("image", s, n) ? null : /* @__PURE__ */ a.jsxs(t.Generic.Popover.Root, { opened: i, position: "bottom", children: [
    /* @__PURE__ */ a.jsx(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ a.jsx(
      t.FormattingToolbar.Button,
      {
        className: "bn-button",
        onClick: () => l(!i),
        isSelected: i,
        mainTooltip: e.formatting_toolbar.image_replace.tooltip,
        label: e.formatting_toolbar.image_replace.tooltip,
        icon: /* @__PURE__ */ a.jsx(so, {})
      }
    ) }),
    /* @__PURE__ */ a.jsx(
      t.Generic.Popover.Content,
      {
        className: "bn-popover-content bn-panel-popover",
        variant: "panel-popover",
        children: /* @__PURE__ */ a.jsx(Ut, { block: s })
      }
    )
  ] });
}, yo = {
  left: Jn,
  center: Yn,
  right: Qn,
  justify: Kn
}, Me = (e) => {
  const t = C(), n = H(), o = T(), i = F(o), l = R(() => {
    const f = i[0];
    if (Ee("textAlignment", f, o))
      return f.props.textAlignment;
  }, [o, i]), s = L(
    (f) => {
      for (const g of i)
        te("textAlignment", g.type, o) && o.updateBlock(g, {
          props: { textAlignment: f }
        });
      setTimeout(() => {
        o.focus();
      });
    },
    [o, i]
  );
  if (!R(() => !!i.find((f) => "textAlignment" in f.props), [i]))
    return null;
  const d = yo[e.textAlignment];
  return /* @__PURE__ */ a.jsx(
    t.FormattingToolbar.Button,
    {
      className: "bn-button",
      "data-test": `alignText${e.textAlignment.slice(0, 1).toUpperCase() + e.textAlignment.slice(1)}`,
      onClick: () => s(e.textAlignment),
      isSelected: l === e.textAlignment,
      label: n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,
      mainTooltip: n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,
      icon: /* @__PURE__ */ a.jsx(d, {})
    }
  );
}, So = (e) => [
  {
    name: e.slash_menu.paragraph.title,
    type: "paragraph",
    icon: ne,
    isSelected: (t) => t.type === "paragraph"
  },
  {
    name: e.slash_menu.heading.title,
    type: "heading",
    props: { level: 1 },
    icon: Pt,
    isSelected: (t) => t.type === "heading" && "level" in t.props && t.props.level === 1
  },
  {
    name: e.slash_menu.heading_2.title,
    type: "heading",
    props: { level: 2 },
    icon: Ot,
    isSelected: (t) => t.type === "heading" && "level" in t.props && t.props.level === 2
  },
  {
    name: e.slash_menu.heading_3.title,
    type: "heading",
    props: { level: 3 },
    icon: It,
    isSelected: (t) => t.type === "heading" && "level" in t.props && t.props.level === 3
  },
  {
    name: e.slash_menu.bullet_list.title,
    type: "bulletListItem",
    icon: Dt,
    isSelected: (t) => t.type === "bulletListItem"
  },
  {
    name: e.slash_menu.numbered_list.title,
    type: "numberedListItem",
    icon: At,
    isSelected: (t) => t.type === "numberedListItem"
  }
], jo = (e) => {
  const t = C(), n = H(), o = T(), i = F(o), [l, s] = y(o.getTextCursorPosition().block), c = R(() => (e.items || So(n)).filter(
    (g) => g.type in o.schema.blockSchema
  ), [o, n, e.items]), d = R(
    () => c.find((g) => g.type === l.type) !== void 0,
    [l.type, c]
  ), f = R(() => {
    const g = (h) => {
      o.focus();
      for (const b of i)
        o.updateBlock(b, {
          type: h.type,
          props: h.props
        });
    };
    return c.map((h) => {
      const b = h.icon;
      return {
        text: h.name,
        icon: /* @__PURE__ */ a.jsx(b, { size: 16 }),
        onClick: () => g(h),
        isSelected: h.isSelected(l)
      };
    });
  }, [l, c, o, i]);
  return $(() => {
    s(o.getTextCursorPosition().block);
  }, o), d ? /* @__PURE__ */ a.jsx(
    t.FormattingToolbar.Select,
    {
      className: "bn-select",
      items: f
    }
  ) : null;
}, To = (e) => [
  /* @__PURE__ */ a.jsx(jo, { items: e }, "blockTypeSelect"),
  /* @__PURE__ */ a.jsx(bo, {}, "imageCaptionButton"),
  /* @__PURE__ */ a.jsx(ko, {}, "replaceImageButton"),
  /* @__PURE__ */ a.jsx(de, { basicTextStyle: "bold" }, "boldStyleButton"),
  /* @__PURE__ */ a.jsx(de, { basicTextStyle: "italic" }, "italicStyleButton"),
  /* @__PURE__ */ a.jsx(
    de,
    {
      basicTextStyle: "underline"
    },
    "underlineStyleButton"
  ),
  /* @__PURE__ */ a.jsx(de, { basicTextStyle: "strike" }, "strikeStyleButton"),
  /* @__PURE__ */ a.jsx(Me, { textAlignment: "left" }, "textAlignLeftButton"),
  /* @__PURE__ */ a.jsx(Me, { textAlignment: "center" }, "textAlignCenterButton"),
  /* @__PURE__ */ a.jsx(Me, { textAlignment: "right" }, "textAlignRightButton"),
  /* @__PURE__ */ a.jsx(go, {}, "colorStyleButton"),
  /* @__PURE__ */ a.jsx(po, {}, "nestBlockButton"),
  /* @__PURE__ */ a.jsx(xo, {}, "unnestBlockButton"),
  /* @__PURE__ */ a.jsx(ho, {}, "createLinkButton")
], _o = (e) => {
  const t = C();
  return /* @__PURE__ */ a.jsx(
    t.FormattingToolbar.Root,
    {
      className: "bn-toolbar bn-formatting-toolbar",
      children: e.children || To(e.blockTypeSelectItems)
    }
  );
}, mt = (e) => {
  switch (e) {
    case "left":
      return "top-start";
    case "center":
      return "top";
    case "right":
      return "top-end";
    default:
      return "top-start";
  }
}, Ho = (e) => {
  const t = ge(null), n = T(), [o, i] = y(
    () => {
      const b = n.getTextCursorPosition().block;
      return "textAlignment" in b.props ? mt(
        b.props.textAlignment
      ) : "top-start";
    }
  );
  $(() => {
    const b = n.getTextCursorPosition().block;
    "textAlignment" in b.props ? i(
      mt(
        b.props.textAlignment
      )
    ) : i("top-start");
  }, n);
  const l = K(
    n.formattingToolbar.onUpdate.bind(n.formattingToolbar)
  ), { isMounted: s, ref: c, style: d, getFloatingProps: f } = re(
    (l == null ? void 0 : l.show) || !1,
    (l == null ? void 0 : l.referencePos) || null,
    3e3,
    {
      placement: o,
      middleware: [oe(10), he()],
      onOpenChange: (b, S) => {
        console.log("change", S), b || (n.formattingToolbar.closeMenu(), n.focus());
      }
    }
  ), g = R(() => zn([t, c]), [t, c]);
  if (!s || !l)
    return null;
  if (!l.show && t.current)
    return /* @__PURE__ */ a.jsx(
      "div",
      {
        ref: g,
        style: d,
        dangerouslySetInnerHTML: { __html: t.current.innerHTML }
      }
    );
  const h = e.formattingToolbar || _o;
  return /* @__PURE__ */ a.jsx("div", { ref: g, style: d, ...f(), children: /* @__PURE__ */ a.jsx(h, {}) });
}, wo = (e) => {
  const t = T();
  if (!t.imagePanel)
    throw new Error(
      "ImageToolbarController can only be used when BlockNote editor schema contains image block"
    );
  const n = K(
    t.imagePanel.onUpdate.bind(t.imagePanel)
  ), { isMounted: o, ref: i, style: l, getFloatingProps: s } = re(
    (n == null ? void 0 : n.show) || !1,
    (n == null ? void 0 : n.referencePos) || null,
    5e3,
    {
      placement: "bottom",
      middleware: [oe(10), he()],
      onOpenChange: (h) => {
        h || (t.imagePanel.closeMenu(), t.focus());
      }
    }
  );
  if (!o || !n)
    return null;
  const { show: c, referencePos: d, ...f } = n, g = e.imageToolbar || Ut;
  return /* @__PURE__ */ a.jsx("div", { ref: i, style: l, ...s(), children: /* @__PURE__ */ a.jsx(g, { ...f }) });
}, Mo = (e) => {
  const t = C(), n = H();
  return /* @__PURE__ */ a.jsx(
    t.LinkToolbar.Button,
    {
      className: "bn-button",
      label: n.link_toolbar.delete.tooltip,
      mainTooltip: n.link_toolbar.delete.tooltip,
      isSelected: !1,
      onClick: e.deleteLink,
      icon: /* @__PURE__ */ a.jsx(oo, {})
    }
  );
}, Ro = (e) => {
  const t = C(), n = H();
  return /* @__PURE__ */ a.jsxs(t.Generic.Popover.Root, { children: [
    /* @__PURE__ */ a.jsx(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ a.jsx(
      t.LinkToolbar.Button,
      {
        className: "bn-button",
        mainTooltip: n.link_toolbar.edit.tooltip,
        isSelected: !1,
        children: n.link_toolbar.edit.text
      }
    ) }),
    /* @__PURE__ */ a.jsx(
      t.Generic.Popover.Content,
      {
        className: "bn-popover-content bn-form-popover",
        variant: "form-popover",
        children: /* @__PURE__ */ a.jsx(Zt, { ...e })
      }
    )
  ] });
}, Eo = (e) => {
  const t = C(), n = H();
  return /* @__PURE__ */ a.jsx(
    t.LinkToolbar.Button,
    {
      className: "bn-button",
      mainTooltip: n.link_toolbar.open.tooltip,
      label: n.link_toolbar.open.tooltip,
      isSelected: !1,
      onClick: () => {
        window.open(e.url, "_blank");
      },
      icon: /* @__PURE__ */ a.jsx(co, {})
    }
  );
}, Vo = (e) => {
  const t = C();
  return e.children ? /* @__PURE__ */ a.jsx(t.LinkToolbar.Root, { className: "bn-toolbar bn-link-toolbar", children: e.children }) : /* @__PURE__ */ a.jsxs(
    t.LinkToolbar.Root,
    {
      className: "bn-toolbar bn-link-toolbar",
      onMouseEnter: e.stopHideTimer,
      onMouseLeave: e.startHideTimer,
      children: [
        /* @__PURE__ */ a.jsx(
          Ro,
          {
            url: e.url,
            text: e.text,
            editLink: e.editLink
          }
        ),
        /* @__PURE__ */ a.jsx(Eo, { url: e.url }),
        /* @__PURE__ */ a.jsx(Mo, { deleteLink: e.deleteLink })
      ]
    }
  );
}, Bo = (e) => {
  const t = T(), n = {
    deleteLink: t.linkToolbar.deleteLink,
    editLink: t.linkToolbar.editLink,
    startHideTimer: t.linkToolbar.startHideTimer,
    stopHideTimer: t.linkToolbar.stopHideTimer
  }, o = K(
    t.linkToolbar.onUpdate.bind(t.linkToolbar)
  ), { isMounted: i, ref: l, style: s, getFloatingProps: c } = re(
    (o == null ? void 0 : o.show) || !1,
    (o == null ? void 0 : o.referencePos) || null,
    4e3,
    {
      placement: "top-start",
      middleware: [oe(10), he()],
      onOpenChange: (b) => {
        b || (t.linkToolbar.closeMenu(), t.focus());
      }
    }
  );
  if (!i || !o)
    return null;
  const { show: d, referencePos: f, ...g } = o, h = e.linkToolbar || Vo;
  return /* @__PURE__ */ a.jsx("div", { ref: l, style: s, ...c(), children: /* @__PURE__ */ a.jsx(h, { ...g, ...n }) });
};
function Lo(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 1024 1024" }, child: [{ tag: "path", attr: { d: "M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z" } }, { tag: "path", attr: { d: "M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z" } }] })(e);
}
const Po = (e) => {
  const t = C(), n = H();
  return /* @__PURE__ */ a.jsx(
    t.SideMenu.Button,
    {
      className: "bn-button",
      label: n.side_menu.add_block_label,
      icon: /* @__PURE__ */ a.jsx(
        Lo,
        {
          size: 24,
          onClick: e.addBlock,
          "data-test": "dragHandleAdd"
        }
      )
    }
  );
};
function zt(e) {
  return _({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0V0z" } }, { tag: "path", attr: { d: "M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" } }] })(e);
}
const Oo = (e) => {
  const t = C(), n = T();
  return !te("textColor", e.block.type, n) && !te("backgroundColor", e.block.type, n) ? null : /* @__PURE__ */ a.jsxs(t.Generic.Menu.Root, { position: "right", sub: !0, children: [
    /* @__PURE__ */ a.jsx(t.Generic.Menu.Trigger, { sub: !0, children: /* @__PURE__ */ a.jsx(
      t.Generic.Menu.Item,
      {
        className: "bn-menu-item",
        subTrigger: !0,
        children: e.children
      }
    ) }),
    /* @__PURE__ */ a.jsx(
      t.Generic.Menu.Dropdown,
      {
        sub: !0,
        className: "bn-menu-dropdown bn-color-picker-dropdown",
        children: /* @__PURE__ */ a.jsx(
          Ft,
          {
            iconSize: 18,
            text: te(
              "textColor",
              e.block.type,
              n
            ) && Ee("textColor", e.block, n) ? {
              color: e.block.props.textColor,
              setColor: (o) => n.updateBlock(e.block, {
                type: e.block.type,
                props: { textColor: o }
              })
            } : void 0,
            background: te(
              "backgroundColor",
              e.block.type,
              n
            ) && Ee("backgroundColor", e.block, n) ? {
              color: e.block.props.backgroundColor,
              setColor: (o) => n.updateBlock(e.block, {
                props: { backgroundColor: o }
              })
            } : void 0
          }
        )
      }
    )
  ] });
}, Io = (e) => {
  const t = C(), n = T();
  return /* @__PURE__ */ a.jsx(
    t.Generic.Menu.Item,
    {
      className: "bn-menu-item",
      onClick: () => n.removeBlocks([e.block]),
      children: e.children
    }
  );
}, No = (e) => {
  const t = C(), n = H();
  return /* @__PURE__ */ a.jsx(
    t.Generic.Menu.Dropdown,
    {
      className: "bn-menu-dropdown bn-drag-handle-menu",
      children: e.children || /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
        /* @__PURE__ */ a.jsx(Io, { ...e, children: n.drag_handle.delete_menuitem }),
        /* @__PURE__ */ a.jsx(Oo, { ...e, children: n.drag_handle.colors_menuitem })
      ] })
    }
  );
}, Ao = (e) => {
  const t = C(), n = H(), o = e.dragHandleMenu || No;
  return /* @__PURE__ */ a.jsxs(
    t.Generic.Menu.Root,
    {
      onOpenChange: (i) => {
        i ? e.freezeMenu() : (e.unfreezeMenu(), e.editor.focus());
      },
      position: "left",
      children: [
        /* @__PURE__ */ a.jsx(t.Generic.Menu.Trigger, { children: /* @__PURE__ */ a.jsx(
          t.SideMenu.Button,
          {
            label: n.side_menu.drag_handle_label,
            draggable: !0,
            onDragStart: e.blockDragStart,
            onDragEnd: e.blockDragEnd,
            className: "bn-button",
            icon: /* @__PURE__ */ a.jsx(zt, { size: 24, "data-test": "dragHandle" })
          }
        ) }),
        /* @__PURE__ */ a.jsx(o, { block: e.block })
      ]
    }
  );
}, Do = (e) => {
  const t = C(), { addBlock: n, ...o } = e;
  return /* @__PURE__ */ a.jsx(t.SideMenu.Root, { className: "bn-side-menu", children: e.children || /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    /* @__PURE__ */ a.jsx(Po, { addBlock: n }),
    /* @__PURE__ */ a.jsx(Ao, { ...o })
  ] }) });
}, Fo = (e) => {
  const t = T(), n = {
    addBlock: t.sideMenu.addBlock,
    blockDragStart: t.sideMenu.blockDragStart,
    blockDragEnd: t.sideMenu.blockDragEnd,
    freezeMenu: t.sideMenu.freezeMenu,
    unfreezeMenu: t.sideMenu.unfreezeMenu
  }, o = K(
    t.sideMenu.onUpdate.bind(t.sideMenu)
  ), { isMounted: i, ref: l, style: s, getFloatingProps: c } = re(
    (o == null ? void 0 : o.show) || !1,
    (o == null ? void 0 : o.referencePos) || null,
    1e3,
    {
      placement: "left"
    }
  );
  if (!i || !o)
    return null;
  const { show: d, referencePos: f, ...g } = o, h = e.sideMenu || Do;
  return /* @__PURE__ */ a.jsx("div", { ref: l, style: s, ...c(), children: /* @__PURE__ */ a.jsx(h, { ...g, ...n, editor: t }) });
};
function Zo(e) {
  const t = C(), n = H(), { items: o, loadingState: i, selectedIndex: l, onItemClick: s } = e, c = i === "loading-initial" || i === "loading" ? /* @__PURE__ */ a.jsx(t.SuggestionMenu.Loader, { className: "bn-suggestion-menu-loader", children: n.suggestion_menu.loading }) : null, d = R(() => {
    let f;
    const g = [];
    for (let h = 0; h < o.length; h++) {
      const b = o[h];
      b.group !== f && (f = b.group, g.push(
        /* @__PURE__ */ a.jsx(
          t.SuggestionMenu.Label,
          {
            className: "bn-suggestion-menu-label",
            children: f
          },
          f
        )
      )), g.push(
        /* @__PURE__ */ a.jsx(
          t.SuggestionMenu.Item,
          {
            className: "bn-suggestion-menu-item",
            item: b,
            id: `bn-suggestion-menu-item-${h}`,
            isSelected: h === l,
            onClick: () => s == null ? void 0 : s(b)
          },
          b.title
        )
      );
    }
    return g;
  }, [t, o, s, l]);
  return /* @__PURE__ */ a.jsxs(
    t.SuggestionMenu.Root,
    {
      id: "bn-suggestion-menu",
      className: "bn-suggestion-menu",
      children: [
        d,
        d.length === 0 && (e.loadingState === "loading" || e.loadingState === "loaded") && /* @__PURE__ */ a.jsx(
          t.SuggestionMenu.EmptyItem,
          {
            className: "bn-suggestion-menu-item",
            children: n.suggestion_menu.no_items_title
          }
        ),
        c
      ]
    }
  );
}
function Uo(e, t, n, o = 3) {
  const i = ge(0);
  B(() => {
    t !== void 0 && (e.length > 0 ? i.current = t.length : t.length - i.current > o && n());
  }, [n, o, e.length, t]);
}
function zo(e, t) {
  const [n, o] = y([]), [i, l] = y(!1), s = ge(), c = ge();
  return B(() => {
    const d = e;
    s.current = e, l(!0), t(e).then((f) => {
      s.current === d && (o(f), l(!1), c.current = d);
    });
  }, [e, t]), {
    items: n || [],
    // The query that was used to retrieve the last set of items may not be the
    // same as the current query as the items from the current query may not
    // have been retrieved yet. This is useful when using the returns of this
    // hook in other hooks.
    usedQuery: c.current,
    loadingState: c.current === void 0 ? "loading-initial" : i ? "loading" : "loaded"
  };
}
function Go(e, t, n, o) {
  const [i, l] = y(0);
  return B(() => {
    const s = (c) => c.key === "ArrowUp" ? (c.preventDefault(), n.length && l((i - 1 + n.length) % n.length), !0) : c.key === "ArrowDown" ? (c.preventDefault(), n.length && l((i + 1) % n.length), !0) : c.key === "Enter" ? (c.preventDefault(), n.length && (o == null || o(n[i])), !0) : !1;
    return e.domElement.addEventListener(
      "keydown",
      s,
      !0
    ), () => {
      e.domElement.removeEventListener(
        "keydown",
        s,
        !0
      );
    };
  }, [e.domElement, n, i, o]), B(() => {
    l(0);
  }, [t]), {
    selectedIndex: n.length === 0 ? void 0 : i
  };
}
function $o(e) {
  const n = G().setContentEditableProps, o = T(), {
    getItems: i,
    suggestionMenuComponent: l,
    query: s,
    clearQuery: c,
    closeMenu: d,
    onItemClick: f
  } = e, g = L(
    (O) => {
      d(), c(), f == null || f(O);
    },
    [f, d, c]
  ), { items: h, usedQuery: b, loadingState: S } = zo(
    s,
    i
  );
  Uo(h, b, d);
  const { selectedIndex: E } = Go(
    o,
    s,
    h,
    g
  );
  B(() => (n((O) => ({
    ...O,
    "aria-expanded": !0,
    "aria-controls": "bn-suggestion-menu"
  })), () => {
    n((O) => ({
      ...O,
      "aria-expanded": !1,
      "aria-controls": void 0
    }));
  }), [n]), B(() => (n((O) => ({
    ...O,
    "aria-activedescendant": E ? "bn-suggestion-menu-item-" + E : void 0
  })), () => {
    n((O) => ({
      ...O,
      "aria-activedescendant": void 0
    }));
  }), [n, E]);
  const Z = l;
  return /* @__PURE__ */ a.jsx(
    Z,
    {
      items: h,
      onItemClick: g,
      loadingState: S,
      selectedIndex: E
    }
  );
}
const Wo = {
  heading: Pt,
  heading_2: Ot,
  heading_3: It,
  numbered_list: At,
  bullet_list: Dt,
  paragraph: ne,
  table: ao,
  image: lo
};
function qo(e) {
  return jn(e).map((t) => {
    const n = Wo[t.key];
    return {
      ...t,
      icon: /* @__PURE__ */ a.jsx(n, { size: 18 })
    };
  });
}
function Yo(e) {
  const t = T(), { triggerCharacter: n, suggestionMenuComponent: o } = e;
  let { onItemClick: i, getItems: l } = e;
  i || (i = (b) => {
    b.onItemClick(t);
  });
  const s = {
    closeMenu: t.suggestionMenus.closeMenu,
    clearQuery: t.suggestionMenus.clearQuery
  }, c = K(
    (b) => t.suggestionMenus.onUpdate.bind(t.suggestionMenus)(
      n,
      b
    )
  ), { isMounted: d, ref: f, style: g, getFloatingProps: h } = re(
    (c == null ? void 0 : c.show) || !1,
    (c == null ? void 0 : c.referencePos) || null,
    2e3,
    {
      placement: "bottom-start",
      middleware: [
        oe(10),
        // Flips the menu placement to maximize the space available, and prevents
        // the menu from being cut off by the confines of the screen.
        he(),
        yn({
          apply({ availableHeight: b, elements: S }) {
            Object.assign(S.floating.style, {
              maxHeight: `${b - 10}px`
            });
          }
        })
      ],
      onOpenChange(b) {
        b || t.suggestionMenus.closeMenu();
      }
    }
  );
  return !d || !c ? null : (l || (l = async (b) => Tn(
    qo(t),
    b
  )), /* @__PURE__ */ a.jsx("div", { ref: f, style: g, ...h(), children: /* @__PURE__ */ a.jsx(
    $o,
    {
      query: c.query,
      closeMenu: s.closeMenu,
      clearQuery: s.clearQuery,
      getItems: l,
      suggestionMenuComponent: o || Zo,
      onItemClick: i
    }
  ) }));
}
const Ko = (e) => {
  const t = C(), n = H(), o = T();
  return /* @__PURE__ */ a.jsx(
    t.Generic.Menu.Item,
    {
      onClick: () => {
        const i = e.block.content.rows[e.index].cells.map(
          () => []
        ), l = [...e.block.content.rows];
        l.splice(e.index + (e.side === "below" ? 1 : 0), 0, {
          cells: i
        }), o.updateBlock(e.block, {
          type: "table",
          content: {
            type: "tableContent",
            rows: l
          }
        });
      },
      children: n.table_handle[`add_${e.side}_menuitem`]
    }
  );
}, Jo = (e) => {
  const t = C(), n = H(), o = T();
  return /* @__PURE__ */ a.jsx(
    t.Generic.Menu.Item,
    {
      onClick: () => {
        const i = {
          type: "tableContent",
          rows: e.block.content.rows.map((l) => {
            const s = [...l.cells];
            return s.splice(e.index + (e.side === "right" ? 1 : 0), 0, []), { cells: s };
          })
        };
        o.updateBlock(e.block, {
          type: "table",
          content: i
        });
      },
      children: n.table_handle[`add_${e.side}_menuitem`]
    }
  );
}, ht = (e) => e.orientation === "row" ? /* @__PURE__ */ a.jsx(Ko, { ...e, side: e.side }) : /* @__PURE__ */ a.jsx(Jo, { ...e, side: e.side }), Qo = (e) => {
  const t = C(), n = H(), o = T();
  return /* @__PURE__ */ a.jsx(
    t.Generic.Menu.Item,
    {
      onClick: () => {
        const i = {
          type: "tableContent",
          rows: e.block.content.rows.filter(
            (l, s) => s !== e.index
          )
        };
        o.updateBlock(e.block, {
          type: "table",
          content: i
        });
      },
      children: n.table_handle.delete_row_menuitem
    }
  );
}, Xo = (e) => {
  const t = C(), n = H(), o = T();
  return /* @__PURE__ */ a.jsx(
    t.Generic.Menu.Item,
    {
      onClick: () => {
        const i = {
          type: "tableContent",
          rows: e.block.content.rows.map((l) => ({
            cells: l.cells.filter((s, c) => c !== e.index)
          }))
        };
        o.updateBlock(e.block, {
          type: "table",
          content: i
        });
      },
      children: n.table_handle.delete_column_menuitem
    }
  );
}, er = (e) => e.orientation === "row" ? /* @__PURE__ */ a.jsx(Qo, { ...e }) : /* @__PURE__ */ a.jsx(Xo, { ...e }), tr = (e) => {
  const t = C();
  return /* @__PURE__ */ a.jsx(t.Generic.Menu.Dropdown, { className: "bn-table-handle-menu", children: e.children || /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    /* @__PURE__ */ a.jsx(
      er,
      {
        orientation: e.orientation,
        block: e.block,
        index: e.index
      }
    ),
    /* @__PURE__ */ a.jsx(
      ht,
      {
        orientation: e.orientation,
        block: e.block,
        index: e.index,
        side: e.orientation === "row" ? "above" : "left"
      }
    ),
    /* @__PURE__ */ a.jsx(
      ht,
      {
        orientation: e.orientation,
        block: e.block,
        index: e.index,
        side: e.orientation === "row" ? "below" : "right"
      }
    )
  ] }) });
}, nr = (e) => {
  const t = C(), [n, o] = y(!1), i = e.tableHandleMenu || tr;
  return /* @__PURE__ */ a.jsxs(
    t.Generic.Menu.Root,
    {
      onOpenChange: (l) => {
        l ? (e.freezeHandles(), e.hideOtherSide()) : (e.unfreezeHandles(), e.showOtherSide(), e.editor.focus());
      },
      position: "right",
      children: [
        /* @__PURE__ */ a.jsx(t.Generic.Menu.Trigger, { children: /* @__PURE__ */ a.jsx(
          t.TableHandle.Root,
          {
            className: Pe(
              "bn-table-handle",
              n ? "bn-table-handle-dragging" : ""
            ),
            draggable: !0,
            onDragStart: (l) => {
              o(!0), e.dragStart(l);
            },
            onDragEnd: () => {
              e.dragEnd(), o(!1);
            },
            style: e.orientation === "column" ? { transform: "rotate(0.25turn)" } : void 0,
            children: e.children || /* @__PURE__ */ a.jsx(zt, { size: 24, "data-test": "tableHandle" })
          }
        ) }),
        /* @__PURE__ */ a.jsx(
          i,
          {
            orientation: e.orientation,
            block: e.block,
            index: e.index
          }
        )
      ]
    }
  );
};
function or(e, t, n) {
  return n && n.draggedCellOrientation === "row" ? new DOMRect(
    t.x,
    n.mousePos,
    t.width,
    0
  ) : new DOMRect(
    t.x,
    e.y,
    t.width,
    e.height
  );
}
function rr(e, t, n) {
  return n && n.draggedCellOrientation === "col" ? new DOMRect(
    n.mousePos,
    t.y,
    0,
    t.height
  ) : new DOMRect(
    e.x,
    t.y,
    e.width,
    t.height
  );
}
function bt(e, t, n, o, i) {
  const { refs: l, update: s, context: c, floatingStyles: d } = kt({
    open: t,
    placement: e === "row" ? "left" : "top",
    middleware: [oe(e === "row" ? -10 : -12)]
  }), { isMounted: f, styles: g } = yt(c);
  return B(() => {
    s();
  }, [n, o, s]), B(() => {
    n === null || o === null || l.setReference({
      getBoundingClientRect: () => (e === "row" ? or : rr)(n, o, i)
    });
  }, [i, e, n, o, l]), R(
    () => ({
      isMounted: f,
      ref: l.setFloating,
      style: {
        display: "flex",
        ...g,
        ...d,
        zIndex: 1e4
      }
    }),
    [d, f, l.setFloating, g]
  );
}
function ar(e, t, n, o) {
  const i = bt(
    "row",
    e,
    t,
    n,
    o
  ), l = bt(
    "col",
    e,
    t,
    n,
    o
  );
  return R(
    () => ({
      rowHandle: i,
      colHandle: l
    }),
    [l, i]
  );
}
const ir = (e) => {
  var b, S;
  const t = T();
  if (!t.tableHandles)
    throw new Error(
      "TableHandlesController can only be used when BlockNote editor schema contains table block"
    );
  const n = {
    rowDragStart: t.tableHandles.rowDragStart,
    colDragStart: t.tableHandles.colDragStart,
    dragEnd: t.tableHandles.dragEnd,
    freezeHandles: t.tableHandles.freezeHandles,
    unfreezeHandles: t.tableHandles.unfreezeHandles
  }, o = K(
    t.tableHandles.onUpdate.bind(t.tableHandles)
  ), i = R(() => {
    var E, Z;
    return o != null && o.draggingState ? {
      draggedCellOrientation: (E = o == null ? void 0 : o.draggingState) == null ? void 0 : E.draggedCellOrientation,
      mousePos: (Z = o == null ? void 0 : o.draggingState) == null ? void 0 : Z.mousePos
    } : void 0;
  }, [
    o == null ? void 0 : o.draggingState,
    (b = o == null ? void 0 : o.draggingState) == null ? void 0 : b.draggedCellOrientation,
    (S = o == null ? void 0 : o.draggingState) == null ? void 0 : S.mousePos
  ]), { rowHandle: l, colHandle: s } = ar(
    (o == null ? void 0 : o.show) || !1,
    (o == null ? void 0 : o.referencePosCell) || null,
    (o == null ? void 0 : o.referencePosTable) || null,
    i
  ), [c, d] = y(!1), [f, g] = y(!1);
  if (!l.isMounted || !s.isMounted || !o)
    return null;
  const h = e.tableHandle || nr;
  return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    !c && /* @__PURE__ */ a.jsx("div", { ref: l.ref, style: l.style, children: /* @__PURE__ */ a.jsx(
      h,
      {
        editor: t,
        orientation: "row",
        showOtherSide: () => g(!1),
        hideOtherSide: () => g(!0),
        index: o.rowIndex,
        block: o.block,
        dragStart: n.rowDragStart,
        dragEnd: n.dragEnd,
        freezeHandles: n.freezeHandles,
        unfreezeHandles: n.unfreezeHandles
      }
    ) }),
    !f && /* @__PURE__ */ a.jsx("div", { ref: s.ref, style: s.style, children: /* @__PURE__ */ a.jsx(
      h,
      {
        editor: t,
        orientation: "column",
        showOtherSide: () => d(!1),
        hideOtherSide: () => d(!0),
        index: o.colIndex,
        block: o.block,
        dragStart: n.colDragStart,
        dragEnd: n.dragEnd,
        freezeHandles: n.freezeHandles,
        unfreezeHandles: n.unfreezeHandles
      }
    ) })
  ] });
};
function lr(e) {
  const t = T();
  if (!t)
    throw new Error(
      "BlockNoteDefaultUI must be used within a BlockNoteContext.Provider"
    );
  return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    e.formattingToolbar !== !1 && /* @__PURE__ */ a.jsx(Ho, {}),
    e.linkToolbar !== !1 && /* @__PURE__ */ a.jsx(Bo, {}),
    e.slashMenu !== !1 && /* @__PURE__ */ a.jsx(Yo, { triggerCharacter: "/" }),
    e.sideMenu !== !1 && /* @__PURE__ */ a.jsx(Fo, {}),
    t.imagePanel && e.imageToolbar !== !1 && /* @__PURE__ */ a.jsx(wo, {}),
    t.tableHandles && e.tableHandles !== !1 && /* @__PURE__ */ a.jsx(ir, {})
  ] });
}
const sr = ({
  renderers: e
}) => /* @__PURE__ */ a.jsx(a.Fragment, { children: Object.entries(e).map(([t, n]) => wt(n.reactElement, n.element, t)) });
function cr(e) {
  const [t, n] = y({}), [o, i] = y();
  return B(() => (e.editor._tiptapEditor.contentComponent = {
    /**
     * Used by TipTap
     */
    setRenderer(l, s) {
      n((c) => ({ ...c, [l]: s }));
    },
    /**
     * Used by TipTap
     */
    removeRenderer(l) {
      n((s) => {
        const c = { ...s };
        return delete c[l], c;
      });
    },
    /**
     * Render a single node to a container within the React context (used by BlockNote renderToDOMSpec)
     */
    renderToElement(l, s) {
      Ht(() => {
        i({ node: l, container: s });
      }), i(void 0);
    }
  }, queueMicrotask(() => {
    e.editor._tiptapEditor.createNodeViews();
  }), () => {
    e.editor._tiptapEditor.contentComponent = null;
  }), [e.editor._tiptapEditor]), /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    /* @__PURE__ */ a.jsx(sr, { renderers: t }),
    o && wt(o.node, o.container),
    e.children
  ] });
}
const pt = () => {
};
function ur(e, t) {
  const {
    editor: n,
    className: o,
    theme: i,
    children: l,
    editable: s,
    onSelectionChange: c,
    onChange: d,
    formattingToolbar: f,
    linkToolbar: g,
    slashMenu: h,
    sideMenu: b,
    imageToolbar: S,
    tableHandles: E,
    ...Z
  } = e, [O, U] = y(), w = G(), pe = An(), xe = (w == null ? void 0 : w.colorSchemePreference) || pe, ae = i || (xe === "dark" ? "dark" : "light");
  Oe(d || pt, n), Ie(c || pt, n), B(() => {
    n.isEditable = s !== !1;
  }, [s, n]);
  const ve = R(() => /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
    l,
    /* @__PURE__ */ a.jsx(
      lr,
      {
        formattingToolbar: f,
        linkToolbar: g,
        slashMenu: h,
        sideMenu: b,
        imageToolbar: S,
        tableHandles: E
      }
    )
  ] }), [
    l,
    f,
    g,
    S,
    b,
    h,
    E
  ]), Ce = R(() => ({
    ...w,
    editor: n,
    setContentEditableProps: U
  }), [w, n]);
  return /* @__PURE__ */ a.jsx(Vt.Provider, { value: Ce, children: /* @__PURE__ */ a.jsx(cr, { editor: n, children: /* @__PURE__ */ a.jsxs(
    "div",
    {
      className: Pe(
        "bn-container",
        ae || "",
        o || ""
      ),
      "data-color-scheme": ae,
      ...Z,
      ref: t,
      children: [
        /* @__PURE__ */ a.jsx(
          "div",
          {
            "aria-autocomplete": "list",
            "aria-haspopup": "listbox",
            ref: n._tiptapEditor.mount,
            ...O
          }
        ),
        ve
      ]
    }
  ) }) });
}
const Cr = N.forwardRef(ur);
function kr(e) {
  const t = G();
  if (e || (e = t == null ? void 0 : t.editor), !e)
    throw new Error(
      "'editor' is required, either from BlockNoteContext or as a function argument"
    );
  const n = e, [o, i] = y(() => n.getActiveStyles());
  return Oe(() => {
    i(n.getActiveStyles());
  }, n), Ie(() => {
    i(n.getActiveStyles());
  }, n), o;
}
const dr = (e = {}, t = []) => R(() => {
  const n = _n.create(e);
  return window && (window.ProseMirror = n._tiptapEditor), n;
}, t), yr = dr;
function fr() {
  const [, e] = y(0);
  return () => e((t) => t + 1);
}
const Sr = (e) => {
  const t = fr();
  B(() => {
    const n = () => {
      requestAnimationFrame(() => {
        requestAnimationFrame(() => {
          t();
        });
      });
    };
    return e.on("transaction", n), () => {
      e.off("transaction", n);
    };
  }, [e]);
};
var Le, fe = Dn;
if (process.env.NODE_ENV === "production")
  Le = fe.createRoot, fe.hydrateRoot;
else {
  var xt = fe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  Le = function(e, t) {
    xt.usingClientEntryPoint = !0;
    try {
      return fe.createRoot(e, t);
    } finally {
      xt.usingClientEntryPoint = !1;
    }
  };
}
function me(e, t) {
  let n;
  const o = document.createElement("div");
  let i;
  if (t ? t._tiptapEditor.contentComponent.renderToElement(
    e((d) => n = d || void 0),
    o
  ) : (i = Le(o), Ht(() => {
    i.render(e((d) => n = d || void 0));
  })), !o.childElementCount)
    return console.warn("ReactInlineContentSpec: renderHTML() failed"), {
      dom: document.createElement("span")
    };
  n == null || n.setAttribute("data-tmp-find", "true");
  const l = o.cloneNode(!0), s = l.firstElementChild, c = l.querySelector(
    "[data-tmp-find]"
  );
  return c == null || c.removeAttribute("data-tmp-find"), i == null || i.unmount(), {
    dom: s,
    contentDOM: c || void 0
  };
}
function Re(e) {
  var t;
  return (
    // Creates `blockContent` element
    /* @__PURE__ */ a.jsx(
      Mt,
      {
        ...Object.fromEntries(
          Object.entries(e.domAttributes || {}).filter(
            ([n]) => n !== "class"
          )
        ),
        className: Pe(
          "bn-block-content",
          ((t = e.domAttributes) == null ? void 0 : t.class) || ""
        ),
        "data-content-type": e.blockType,
        ...Object.fromEntries(
          Object.entries(e.blockProps).filter(
            ([n, o]) => !Hn.includes(n) && o !== e.propSchema[n].default
          ).map(([n, o]) => [jt(n), o])
        ),
        children: e.children
      }
    )
  );
}
function jr(e, t) {
  const n = Tt({
    name: e.type,
    content: e.content === "inline" ? "inline*" : "",
    group: "blockContent",
    selectable: !0,
    addAttributes() {
      return _t(e.propSchema);
    },
    parseHTML() {
      return wn(e, t.parse);
    },
    renderHTML() {
      const o = document.createElement("div");
      return o.setAttribute("data-tmp-placeholder", "true"), {
        dom: o
      };
    },
    addNodeView() {
      return (o) => Rt(
        (i) => {
          var g;
          const l = this.options.editor, s = Mn(
            i.getPos,
            l,
            this.editor,
            e.type
          ), c = ((g = this.options.domAttributes) == null ? void 0 : g.blockContent) || {}, d = Et({}).ref, f = t.render;
          return /* @__PURE__ */ a.jsx(
            Re,
            {
              blockType: s.type,
              blockProps: s.props,
              propSchema: e.propSchema,
              domAttributes: c,
              children: /* @__PURE__ */ a.jsx(
                f,
                {
                  block: s,
                  editor: l,
                  contentRef: d
                }
              )
            }
          );
        },
        {
          className: "bn-react-node-view-renderer"
        }
      )(o);
    }
  });
  return Rn(e, {
    node: n,
    toInternalHTML: (o, i) => {
      var d, f;
      const l = ((d = n.options.domAttributes) == null ? void 0 : d.blockContent) || {}, s = t.render, c = me(
        (g) => /* @__PURE__ */ a.jsx(
          Re,
          {
            blockType: o.type,
            blockProps: o.props,
            propSchema: e.propSchema,
            domAttributes: l,
            children: /* @__PURE__ */ a.jsx(
              s,
              {
                block: o,
                editor: i,
                contentRef: g
              }
            )
          }
        ),
        i
      );
      return (f = c.contentDOM) == null || f.setAttribute("data-editable", ""), c;
    },
    toExternalHTML: (o, i) => {
      var d, f;
      const l = ((d = n.options.domAttributes) == null ? void 0 : d.blockContent) || {}, s = t.toExternalHTML || t.render, c = me((g) => /* @__PURE__ */ a.jsx(
        Re,
        {
          blockType: o.type,
          blockProps: o.props,
          propSchema: e.propSchema,
          domAttributes: l,
          children: /* @__PURE__ */ a.jsx(
            s,
            {
              block: o,
              editor: i,
              contentRef: g
            }
          )
        }
      ), i);
      return (f = c.contentDOM) == null || f.setAttribute("data-editable", ""), c;
    }
  });
}
function gr(e) {
  return (
    // Creates inline content section element
    /* @__PURE__ */ a.jsx(
      Mt,
      {
        as: "span",
        className: "bn-inline-content-section",
        "data-inline-content-type": e.inlineContentType,
        ...Object.fromEntries(
          Object.entries(e.inlineContentProps).filter(([t, n]) => n !== e.propSchema[t].default).map(([t, n]) => [jt(t), n])
        ),
        children: e.children
      }
    )
  );
}
function Tr(e, t) {
  const n = Tt({
    name: e.type,
    inline: !0,
    group: "inline",
    selectable: e.content === "styled",
    atom: e.content === "none",
    content: e.content === "styled" ? "inline*" : "",
    addAttributes() {
      return _t(e.propSchema);
    },
    addKeyboardShortcuts() {
      return En(e);
    },
    parseHTML() {
      return Vn(e);
    },
    renderHTML({ node: o }) {
      const i = this.options.editor, l = st(
        o,
        i.schema.inlineContentSchema,
        i.schema.styleSchema
      ), s = t.render, c = me(
        (d) => /* @__PURE__ */ a.jsx(s, { inlineContent: l, contentRef: d }),
        i
      );
      return Bn(
        c,
        e.type,
        o.attrs,
        e.propSchema
      );
    },
    // TODO: needed?
    addNodeView() {
      const o = this.options.editor;
      return (i) => Rt(
        (l) => {
          const s = Et({}).ref, c = t.render;
          return /* @__PURE__ */ a.jsx(
            gr,
            {
              inlineContentProps: l.node.attrs,
              inlineContentType: e.type,
              propSchema: e.propSchema,
              children: /* @__PURE__ */ a.jsx(
                c,
                {
                  contentRef: s,
                  inlineContent: st(
                    l.node,
                    o.schema.inlineContentSchema,
                    o.schema.styleSchema
                  )
                }
              )
            }
          );
        },
        {
          className: "bn-ic-react-node-view-renderer",
          as: "span"
          // contentDOMElementTag: "span", (requires tt upgrade)
        }
      )(i);
    }
  });
  return Ln(e, {
    node: n
  });
}
function _r(e, t) {
  const n = Fn.create({
    name: e.type,
    addAttributes() {
      return Pn(e.propSchema);
    },
    parseHTML() {
      return On(e);
    },
    renderHTML({ mark: o }) {
      const i = {};
      e.propSchema === "string" && (i.value = o.attrs.stringValue);
      const l = t.render, s = me(
        (c) => /* @__PURE__ */ a.jsx(l, { ...i, contentRef: c }),
        void 0
      );
      return In(
        s,
        e.type,
        o.attrs.stringValue,
        e.propSchema
      );
    }
  });
  return Nn(e, {
    mark: n
  });
}
export {
  Po as AddBlockButton,
  ht as AddButton,
  Jo as AddColumnButton,
  Ko as AddRowButton,
  de as BasicTextStyleButton,
  Oo as BlockColorsItem,
  Re as BlockContentWrapper,
  Vt as BlockNoteContext,
  lr as BlockNoteDefaultUI,
  Cr as BlockNoteViewRaw,
  jo as BlockTypeSelect,
  go as ColorStyleButton,
  Gn as ComponentsContext,
  ho as CreateLinkButton,
  er as DeleteButton,
  Xo as DeleteColumnButton,
  Mo as DeleteLinkButton,
  Qo as DeleteRowButton,
  Ao as DragHandleButton,
  No as DragHandleMenu,
  Ro as EditLinkButton,
  Zt as EditLinkMenuItems,
  vo as EmbedTab,
  _o as FormattingToolbar,
  Ho as FormattingToolbarController,
  bo as ImageCaptionButton,
  Ut as ImagePanel,
  wo as ImagePanelController,
  gr as InlineContentWrapper,
  Vo as LinkToolbar,
  Bo as LinkToolbarController,
  po as NestBlockButton,
  Eo as OpenLinkButton,
  Io as RemoveBlockItem,
  ko as ReplaceImageButton,
  Do as SideMenu,
  Fo as SideMenuController,
  Yo as SuggestionMenuController,
  $o as SuggestionMenuWrapper,
  nr as TableHandle,
  tr as TableHandleMenu,
  ir as TableHandlesController,
  Me as TextAlignButton,
  xo as UnnestBlockButton,
  Co as UploadTab,
  So as blockTypeSelectItems,
  jr as createReactBlockSpec,
  Tr as createReactInlineContentSpec,
  _r as createReactStyleSpec,
  qo as getDefaultReactSlashMenuItems,
  To as getFormattingToolbarItems,
  kr as useActiveStyles,
  yr as useBlockNote,
  G as useBlockNoteContext,
  T as useBlockNoteEditor,
  Uo as useCloseSuggestionMenuNoItems,
  C as useComponentsContext,
  dr as useCreateBlockNote,
  H as useDictionary,
  Oe as useEditorChange,
  $ as useEditorContentOrSelectionChange,
  Sr as useEditorForceUpdate,
  Ie as useEditorSelectionChange,
  zo as useLoadSuggestionMenuItems,
  F as useSelectedBlocks,
  Go as useSuggestionMenuKeyboardNavigation,
  ar as useTableHandlesPositioning
};
//# sourceMappingURL=blocknote-react.js.map
