import Y, { useEffect as R, forwardRef as fe, useMemo as A, useRef as D, useState as b, useCallback as L } from "react";
import { mergeCSSClasses as ge, formatKeyboardShortcut as z, getDefaultSlashMenuItems as Rn, defaultBlockSchema as Mn, BlockNoteEditor as En, getBlockSchemaFromSpecs as Vn, defaultBlockSpecs as Ln, inheritedProps as Bn, camelToDataKebab as wt, createStronglyTypedTiptapNode as Tt, propsToAttributes as pt, getParseRules as Pn, getBlockFromPos as _n, createInternalBlockSpec as Dn, addInlineContentKeyboardShortcuts as In, getInlineContentParseRules as On, nodeToCustomInlineContent as bt, addInlineContentAttributes as An, createInternalInlineContentSpec as Fn, stylePropsToAttributes as zn, getStyleParseRules as Nn, addStyleAttributes as Zn, createInternalStyleSpec as Un } from "@blocknote/core";
import { Group as Ne, Box as Rt, Menu as w, Stack as Ze, Text as de, Tooltip as $n, Button as Ue, ActionIcon as Mt, Popover as oe, TextInput as Et, FileInput as Vt, Tabs as re, LoadingOverlay as Wn, Badge as Yn, MantineProvider as qn } from "@mantine/core";
import { EditorContent as Kn, NodeViewWrapper as Lt, ReactNodeViewRenderer as Bt, NodeViewContent as Pt, Mark as Gn } from "@tiptap/react";
import Jn from "use-prefers-color-scheme";
import { useFloating as X, offset as ie, flip as we, useTransitionStyles as Q, size as Xn } from "@floating-ui/react";
import Qn from "lodash.foreach";
import er from "lodash.groupby";
import tr, { flushSync as nr } from "react-dom";
const _t = (e, r, o = !1) => {
  const i = [];
  function a(l, u = "--bn") {
    for (const d in l) {
      const s = d.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), h = `${u}-${s}`;
      typeof l[d] != "object" ? (typeof l[d] == "number" && (l[d] = `${l[d]}px`), o ? r.style.removeProperty(h) : r.style.setProperty(h, l[d].toString())) : a(l[d], h);
    }
  }
  return a(e), i;
}, xt = (e, r) => _t(e, r), rr = {
  colors: {
    editor: {
      text: void 0,
      background: void 0
    },
    menu: {
      text: void 0,
      background: void 0
    },
    tooltip: {
      text: void 0,
      background: void 0
    },
    hovered: {
      text: void 0,
      background: void 0
    },
    selected: {
      text: void 0,
      background: void 0
    },
    disabled: {
      text: void 0,
      background: void 0
    },
    shadow: void 0,
    border: void 0,
    sideMenu: void 0,
    highlights: {
      gray: {
        text: void 0,
        background: void 0
      },
      brown: {
        text: void 0,
        background: void 0
      },
      red: {
        text: void 0,
        background: void 0
      },
      orange: {
        text: void 0,
        background: void 0
      },
      yellow: {
        text: void 0,
        background: void 0
      },
      green: {
        text: void 0,
        background: void 0
      },
      blue: {
        text: void 0,
        background: void 0
      },
      purple: {
        text: void 0,
        background: void 0
      },
      pink: {
        text: void 0,
        background: void 0
      }
    }
  },
  borderRadius: void 0,
  fontFamily: void 0
}, or = (e) => _t(rr, e, !0);
var Ie = { exports: {} }, ce = {};
/**
 * @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 vt;
function ir() {
  if (vt)
    return ce;
  vt = 1;
  var e = Y, r = Symbol.for("react.element"), o = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, a = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, l = { key: !0, ref: !0, __self: !0, __source: !0 };
  function u(d, s, h) {
    var x, k = {}, T = null, m = null;
    h !== void 0 && (T = "" + h), s.key !== void 0 && (T = "" + s.key), s.ref !== void 0 && (m = s.ref);
    for (x in s)
      i.call(s, x) && !l.hasOwnProperty(x) && (k[x] = s[x]);
    if (d && d.defaultProps)
      for (x in s = d.defaultProps, s)
        k[x] === void 0 && (k[x] = s[x]);
    return { $$typeof: r, type: d, key: T, ref: m, props: k, _owner: a.current };
  }
  return ce.Fragment = o, ce.jsx = u, ce.jsxs = u, ce;
}
var se = {};
/**
 * @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 kt;
function ar() {
  return kt || (kt = 1, process.env.NODE_ENV !== "production" && function() {
    var e = Y, r = Symbol.for("react.element"), o = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), a = Symbol.for("react.strict_mode"), l = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), d = Symbol.for("react.context"), s = Symbol.for("react.forward_ref"), h = Symbol.for("react.suspense"), x = Symbol.for("react.suspense_list"), k = Symbol.for("react.memo"), T = Symbol.for("react.lazy"), m = Symbol.for("react.offscreen"), I = Symbol.iterator, p = "@@iterator";
    function N(t) {
      if (t === null || typeof t != "object")
        return null;
      var c = I && t[I] || t[p];
      return typeof c == "function" ? c : null;
    }
    var q = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    function M(t) {
      {
        for (var c = arguments.length, f = new Array(c > 1 ? c - 1 : 0), g = 1; g < c; g++)
          f[g - 1] = arguments[g];
        O("error", t, f);
      }
    }
    function O(t, c, f) {
      {
        var g = q.ReactDebugCurrentFrame, C = g.getStackAddendum();
        C !== "" && (c += "%s", f = f.concat([C]));
        var H = f.map(function(y) {
          return String(y);
        });
        H.unshift("Warning: " + c), Function.prototype.apply.call(console[t], console, H);
      }
    }
    var Z = !1, U = !1, he = !1, me = !1, be = !1, P;
    P = Symbol.for("react.module.reference");
    function en(t) {
      return !!(typeof t == "string" || typeof t == "function" || t === i || t === l || be || t === a || t === h || t === x || me || t === m || Z || U || he || typeof t == "object" && t !== null && (t.$$typeof === T || t.$$typeof === k || t.$$typeof === u || t.$$typeof === d || t.$$typeof === s || // 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.
      t.$$typeof === P || t.getModuleId !== void 0));
    }
    function tn(t, c, f) {
      var g = t.displayName;
      if (g)
        return g;
      var C = c.displayName || c.name || "";
      return C !== "" ? f + "(" + C + ")" : f;
    }
    function Ye(t) {
      return t.displayName || "Context";
    }
    function $(t) {
      if (t == null)
        return null;
      if (typeof t.tag == "number" && M("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
        return t.displayName || t.name || null;
      if (typeof t == "string")
        return t;
      switch (t) {
        case i:
          return "Fragment";
        case o:
          return "Portal";
        case l:
          return "Profiler";
        case a:
          return "StrictMode";
        case h:
          return "Suspense";
        case x:
          return "SuspenseList";
      }
      if (typeof t == "object")
        switch (t.$$typeof) {
          case d:
            var c = t;
            return Ye(c) + ".Consumer";
          case u:
            var f = t;
            return Ye(f._context) + ".Provider";
          case s:
            return tn(t, t.render, "ForwardRef");
          case k:
            var g = t.displayName || null;
            return g !== null ? g : $(t.type) || "Memo";
          case T: {
            var C = t, H = C._payload, y = C._init;
            try {
              return $(y(H));
            } catch {
              return null;
            }
          }
        }
      return null;
    }
    var J = Object.assign, ae = 0, qe, Ke, Ge, Je, Xe, Qe, et;
    function tt() {
    }
    tt.__reactDisabledLog = !0;
    function nn() {
      {
        if (ae === 0) {
          qe = console.log, Ke = console.info, Ge = console.warn, Je = console.error, Xe = console.group, Qe = console.groupCollapsed, et = console.groupEnd;
          var t = {
            configurable: !0,
            enumerable: !0,
            value: tt,
            writable: !0
          };
          Object.defineProperties(console, {
            info: t,
            log: t,
            warn: t,
            error: t,
            group: t,
            groupCollapsed: t,
            groupEnd: t
          });
        }
        ae++;
      }
    }
    function rn() {
      {
        if (ae--, ae === 0) {
          var t = {
            configurable: !0,
            enumerable: !0,
            writable: !0
          };
          Object.defineProperties(console, {
            log: J({}, t, {
              value: qe
            }),
            info: J({}, t, {
              value: Ke
            }),
            warn: J({}, t, {
              value: Ge
            }),
            error: J({}, t, {
              value: Je
            }),
            group: J({}, t, {
              value: Xe
            }),
            groupCollapsed: J({}, t, {
              value: Qe
            }),
            groupEnd: J({}, t, {
              value: et
            })
          });
        }
        ae < 0 && M("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
      }
    }
    var pe = q.ReactCurrentDispatcher, Re;
    function xe(t, c, f) {
      {
        if (Re === void 0)
          try {
            throw Error();
          } catch (C) {
            var g = C.stack.trim().match(/\n( *(at )?)/);
            Re = g && g[1] || "";
          }
        return `
` + Re + t;
      }
    }
    var Me = !1, ve;
    {
      var on = typeof WeakMap == "function" ? WeakMap : Map;
      ve = new on();
    }
    function nt(t, c) {
      if (!t || Me)
        return "";
      {
        var f = ve.get(t);
        if (f !== void 0)
          return f;
      }
      var g;
      Me = !0;
      var C = Error.prepareStackTrace;
      Error.prepareStackTrace = void 0;
      var H;
      H = pe.current, pe.current = null, nn();
      try {
        if (c) {
          var y = function() {
            throw Error();
          };
          if (Object.defineProperty(y.prototype, "props", {
            set: function() {
              throw Error();
            }
          }), typeof Reflect == "object" && Reflect.construct) {
            try {
              Reflect.construct(y, []);
            } catch (W) {
              g = W;
            }
            Reflect.construct(t, [], y);
          } else {
            try {
              y.call();
            } catch (W) {
              g = W;
            }
            t.call(y.prototype);
          }
        } else {
          try {
            throw Error();
          } catch (W) {
            g = W;
          }
          t();
        }
      } catch (W) {
        if (W && g && typeof W.stack == "string") {
          for (var v = W.stack.split(`
`), B = g.stack.split(`
`), E = v.length - 1, V = B.length - 1; E >= 1 && V >= 0 && v[E] !== B[V]; )
            V--;
          for (; E >= 1 && V >= 0; E--, V--)
            if (v[E] !== B[V]) {
              if (E !== 1 || V !== 1)
                do
                  if (E--, V--, V < 0 || v[E] !== B[V]) {
                    var _ = `
` + v[E].replace(" at new ", " at ");
                    return t.displayName && _.includes("<anonymous>") && (_ = _.replace("<anonymous>", t.displayName)), typeof t == "function" && ve.set(t, _), _;
                  }
                while (E >= 1 && V >= 0);
              break;
            }
        }
      } finally {
        Me = !1, pe.current = H, rn(), Error.prepareStackTrace = C;
      }
      var ne = t ? t.displayName || t.name : "", mt = ne ? xe(ne) : "";
      return typeof t == "function" && ve.set(t, mt), mt;
    }
    function an(t, c, f) {
      return nt(t, !1);
    }
    function ln(t) {
      var c = t.prototype;
      return !!(c && c.isReactComponent);
    }
    function ke(t, c, f) {
      if (t == null)
        return "";
      if (typeof t == "function")
        return nt(t, ln(t));
      if (typeof t == "string")
        return xe(t);
      switch (t) {
        case h:
          return xe("Suspense");
        case x:
          return xe("SuspenseList");
      }
      if (typeof t == "object")
        switch (t.$$typeof) {
          case s:
            return an(t.render);
          case k:
            return ke(t.type, c, f);
          case T: {
            var g = t, C = g._payload, H = g._init;
            try {
              return ke(H(C), c, f);
            } catch {
            }
          }
        }
      return "";
    }
    var ye = Object.prototype.hasOwnProperty, rt = {}, ot = q.ReactDebugCurrentFrame;
    function Ce(t) {
      if (t) {
        var c = t._owner, f = ke(t.type, t._source, c ? c.type : null);
        ot.setExtraStackFrame(f);
      } else
        ot.setExtraStackFrame(null);
    }
    function cn(t, c, f, g, C) {
      {
        var H = Function.call.bind(ye);
        for (var y in t)
          if (H(t, y)) {
            var v = void 0;
            try {
              if (typeof t[y] != "function") {
                var B = Error((g || "React class") + ": " + f + " type `" + y + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof t[y] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
                throw B.name = "Invariant Violation", B;
              }
              v = t[y](c, y, g, f, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
            } catch (E) {
              v = E;
            }
            v && !(v instanceof Error) && (Ce(C), M("%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).", g || "React class", f, y, typeof v), Ce(null)), v instanceof Error && !(v.message in rt) && (rt[v.message] = !0, Ce(C), M("Failed %s type: %s", f, v.message), Ce(null));
          }
      }
    }
    var sn = Array.isArray;
    function Ee(t) {
      return sn(t);
    }
    function dn(t) {
      {
        var c = typeof Symbol == "function" && Symbol.toStringTag, f = c && t[Symbol.toStringTag] || t.constructor.name || "Object";
        return f;
      }
    }
    function un(t) {
      try {
        return it(t), !1;
      } catch {
        return !0;
      }
    }
    function it(t) {
      return "" + t;
    }
    function at(t) {
      if (un(t))
        return M("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", dn(t)), it(t);
    }
    var le = q.ReactCurrentOwner, fn = {
      key: !0,
      ref: !0,
      __self: !0,
      __source: !0
    }, lt, ct, Ve;
    Ve = {};
    function gn(t) {
      if (ye.call(t, "ref")) {
        var c = Object.getOwnPropertyDescriptor(t, "ref").get;
        if (c && c.isReactWarning)
          return !1;
      }
      return t.ref !== void 0;
    }
    function hn(t) {
      if (ye.call(t, "key")) {
        var c = Object.getOwnPropertyDescriptor(t, "key").get;
        if (c && c.isReactWarning)
          return !1;
      }
      return t.key !== void 0;
    }
    function mn(t, c) {
      if (typeof t.ref == "string" && le.current && c && le.current.stateNode !== c) {
        var f = $(le.current.type);
        Ve[f] || (M('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', $(le.current.type), t.ref), Ve[f] = !0);
      }
    }
    function bn(t, c) {
      {
        var f = function() {
          lt || (lt = !0, M("%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)", c));
        };
        f.isReactWarning = !0, Object.defineProperty(t, "key", {
          get: f,
          configurable: !0
        });
      }
    }
    function xn(t, c) {
      {
        var f = function() {
          ct || (ct = !0, M("%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)", c));
        };
        f.isReactWarning = !0, Object.defineProperty(t, "ref", {
          get: f,
          configurable: !0
        });
      }
    }
    var vn = function(t, c, f, g, C, H, y) {
      var v = {
        // This tag allows us to uniquely identify this as a React Element
        $$typeof: r,
        // Built-in properties that belong on the element
        type: t,
        key: c,
        ref: f,
        props: y,
        // Record the component responsible for creating this element.
        _owner: H
      };
      return v._store = {}, Object.defineProperty(v._store, "validated", {
        configurable: !1,
        enumerable: !1,
        writable: !0,
        value: !1
      }), Object.defineProperty(v, "_self", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: g
      }), Object.defineProperty(v, "_source", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: C
      }), Object.freeze && (Object.freeze(v.props), Object.freeze(v)), v;
    };
    function kn(t, c, f, g, C) {
      {
        var H, y = {}, v = null, B = null;
        f !== void 0 && (at(f), v = "" + f), hn(c) && (at(c.key), v = "" + c.key), gn(c) && (B = c.ref, mn(c, C));
        for (H in c)
          ye.call(c, H) && !fn.hasOwnProperty(H) && (y[H] = c[H]);
        if (t && t.defaultProps) {
          var E = t.defaultProps;
          for (H in E)
            y[H] === void 0 && (y[H] = E[H]);
        }
        if (v || B) {
          var V = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
          v && bn(y, V), B && xn(y, V);
        }
        return vn(t, v, B, C, g, le.current, y);
      }
    }
    var Le = q.ReactCurrentOwner, st = q.ReactDebugCurrentFrame;
    function te(t) {
      if (t) {
        var c = t._owner, f = ke(t.type, t._source, c ? c.type : null);
        st.setExtraStackFrame(f);
      } else
        st.setExtraStackFrame(null);
    }
    var Be;
    Be = !1;
    function Pe(t) {
      return typeof t == "object" && t !== null && t.$$typeof === r;
    }
    function dt() {
      {
        if (Le.current) {
          var t = $(Le.current.type);
          if (t)
            return `

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

Check your code at ` + c + ":" + f + ".";
        }
        return "";
      }
    }
    var ut = {};
    function Cn(t) {
      {
        var c = dt();
        if (!c) {
          var f = typeof t == "string" ? t : t.displayName || t.name;
          f && (c = `

Check the top-level render call using <` + f + ">.");
        }
        return c;
      }
    }
    function ft(t, c) {
      {
        if (!t._store || t._store.validated || t.key != null)
          return;
        t._store.validated = !0;
        var f = Cn(c);
        if (ut[f])
          return;
        ut[f] = !0;
        var g = "";
        t && t._owner && t._owner !== Le.current && (g = " It was passed a child from " + $(t._owner.type) + "."), te(t), M('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', f, g), te(null);
      }
    }
    function gt(t, c) {
      {
        if (typeof t != "object")
          return;
        if (Ee(t))
          for (var f = 0; f < t.length; f++) {
            var g = t[f];
            Pe(g) && ft(g, c);
          }
        else if (Pe(t))
          t._store && (t._store.validated = !0);
        else if (t) {
          var C = N(t);
          if (typeof C == "function" && C !== t.entries)
            for (var H = C.call(t), y; !(y = H.next()).done; )
              Pe(y.value) && ft(y.value, c);
        }
      }
    }
    function jn(t) {
      {
        var c = t.type;
        if (c == null || typeof c == "string")
          return;
        var f;
        if (typeof c == "function")
          f = c.propTypes;
        else if (typeof c == "object" && (c.$$typeof === s || // Note: Memo only checks outer props here.
        // Inner props are checked in the reconciler.
        c.$$typeof === k))
          f = c.propTypes;
        else
          return;
        if (f) {
          var g = $(c);
          cn(f, t.props, "prop", g, t);
        } else if (c.PropTypes !== void 0 && !Be) {
          Be = !0;
          var C = $(c);
          M("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", C || "Unknown");
        }
        typeof c.getDefaultProps == "function" && !c.getDefaultProps.isReactClassApproved && M("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
      }
    }
    function Sn(t) {
      {
        for (var c = Object.keys(t.props), f = 0; f < c.length; f++) {
          var g = c[f];
          if (g !== "children" && g !== "key") {
            te(t), M("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", g), te(null);
            break;
          }
        }
        t.ref !== null && (te(t), M("Invalid attribute `ref` supplied to `React.Fragment`."), te(null));
      }
    }
    function ht(t, c, f, g, C, H) {
      {
        var y = en(t);
        if (!y) {
          var v = "";
          (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (v += " 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 B = yn(C);
          B ? v += B : v += dt();
          var E;
          t === null ? E = "null" : Ee(t) ? E = "array" : t !== void 0 && t.$$typeof === r ? (E = "<" + ($(t.type) || "Unknown") + " />", v = " Did you accidentally export a JSX literal instead of a component?") : E = typeof t, M("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", E, v);
        }
        var V = kn(t, c, f, C, H);
        if (V == null)
          return V;
        if (y) {
          var _ = c.children;
          if (_ !== void 0)
            if (g)
              if (Ee(_)) {
                for (var ne = 0; ne < _.length; ne++)
                  gt(_[ne], t);
                Object.freeze && Object.freeze(_);
              } else
                M("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
              gt(_, t);
        }
        return t === i ? Sn(V) : jn(V), V;
      }
    }
    function Hn(t, c, f) {
      return ht(t, c, f, !0);
    }
    function wn(t, c, f) {
      return ht(t, c, f, !1);
    }
    var Tn = wn, pn = Hn;
    se.Fragment = i, se.jsx = Tn, se.jsxs = pn;
  }()), se;
}
process.env.NODE_ENV === "production" ? Ie.exports = ir() : Ie.exports = ar();
var n = Ie.exports;
function Dt(e, r) {
  R(() => (e._tiptapEditor.on("update", r), () => {
    e._tiptapEditor.off("update", r);
  }), [r, e._tiptapEditor]);
}
function It(e, r) {
  R(() => (e._tiptapEditor.on("selectionUpdate", r), () => {
    e._tiptapEditor.off("selectionUpdate", r);
  }), [r, e._tiptapEditor]);
}
function G(e, r) {
  Dt(e, r), It(e, r);
}
const $e = fe((e, r) => {
  const { className: o, children: i, ...a } = e;
  return /* @__PURE__ */ n.jsx(
    Ne,
    {
      className: ge("bn-toolbar", o || ""),
      ref: r,
      ...a,
      children: i
    }
  );
}), Oe = (e) => {
  const r = e.textColor || "default", o = e.backgroundColor || "default", i = e.size || 16, a = A(
    () => ({
      pointerEvents: "none",
      fontSize: (i * 0.75).toString() + "px",
      height: i.toString() + "px",
      lineHeight: i.toString() + "px",
      textAlign: "center",
      width: i.toString() + "px"
    }),
    [i]
  );
  return /* @__PURE__ */ n.jsx(
    Rt,
    {
      className: "bn-color-icon",
      "data-background-color": o,
      "data-text-color": r,
      style: a,
      children: "A"
    }
  );
};
var Ot = {
  color: void 0,
  size: void 0,
  className: void 0,
  style: void 0,
  attr: void 0
}, yt = Y.createContext && Y.createContext(Ot), K = globalThis && globalThis.__assign || function() {
  return K = Object.assign || function(e) {
    for (var r, o = 1, i = arguments.length; o < i; o++) {
      r = arguments[o];
      for (var a in r)
        Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
    }
    return e;
  }, K.apply(this, arguments);
}, lr = globalThis && globalThis.__rest || function(e, r) {
  var o = {};
  for (var i in e)
    Object.prototype.hasOwnProperty.call(e, i) && r.indexOf(i) < 0 && (o[i] = e[i]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var a = 0, i = Object.getOwnPropertySymbols(e); a < i.length; a++)
      r.indexOf(i[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, i[a]) && (o[i[a]] = e[i[a]]);
  return o;
};
function At(e) {
  return e && e.map(function(r, o) {
    return Y.createElement(r.tag, K({
      key: o
    }, r.attr), At(r.child));
  });
}
function S(e) {
  return function(r) {
    return Y.createElement(cr, K({
      attr: K({}, e.attr)
    }, r), At(e.child));
  };
}
function cr(e) {
  var r = function(o) {
    var i = e.attr, a = e.size, l = e.title, u = lr(e, ["attr", "size", "title"]), d = a || o.size || "1em", s;
    return o.className && (s = o.className), e.className && (s = (s ? s + " " : "") + e.className), Y.createElement("svg", K({
      stroke: "currentColor",
      fill: "currentColor",
      strokeWidth: "0"
    }, o.attr, i, u, {
      className: s,
      style: K(K({
        color: e.color || o.color
      }, o.style), e.style),
      height: d,
      width: d,
      xmlns: "http://www.w3.org/2000/svg"
    }), l && Y.createElement("title", null, l), e.children);
  };
  return yt !== void 0 ? Y.createElement(yt.Consumer, null, function(o) {
    return r(o);
  }) : r(Ot);
}
function Ae(e) {
  return S({ tag: "svg", attr: { version: "1.2", baseProfile: "tiny", viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M16.972 6.251c-.967-.538-2.185-.188-2.72.777l-3.713 6.682-2.125-2.125c-.781-.781-2.047-.781-2.828 0-.781.781-.781 2.047 0 2.828l4 4c.378.379.888.587 1.414.587l.277-.02c.621-.087 1.166-.46 1.471-1.009l5-9c.537-.966.189-2.183-.776-2.72z" } }] })(e);
}
const Ft = (e) => {
  const r = () => e.text ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
    /* @__PURE__ */ n.jsx(w.Label, { children: "Text" }),
    [
      "default",
      "gray",
      "brown",
      "red",
      "orange",
      "yellow",
      "green",
      "blue",
      "purple",
      "pink"
    ].map((i) => /* @__PURE__ */ n.jsx(
      w.Item,
      {
        onClick: () => {
          e.onClick && e.onClick(), e.text.setColor(i);
        },
        component: "div",
        "data-test": "text-color-" + i,
        leftSection: /* @__PURE__ */ n.jsx(Oe, { textColor: i, size: e.iconSize }),
        rightSection: e.text.color === i ? /* @__PURE__ */ n.jsx(Ae, { size: 20, className: "bn-tick-icon" }) : /* @__PURE__ */ n.jsx("div", { className: "bn-tick-space" }),
        children: i.charAt(0).toUpperCase() + i.slice(1)
      },
      "text-color-" + i
    ))
  ] }) : null, o = () => e.background ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
    /* @__PURE__ */ n.jsx(w.Label, { children: "Background" }),
    [
      "default",
      "gray",
      "brown",
      "red",
      "orange",
      "yellow",
      "green",
      "blue",
      "purple",
      "pink"
    ].map((i) => /* @__PURE__ */ n.jsx(
      w.Item,
      {
        onClick: () => {
          e.onClick && e.onClick(), e.background.setColor(i);
        },
        component: "div",
        "data-test": "background-color-" + i,
        leftSection: /* @__PURE__ */ n.jsx(Oe, { backgroundColor: i, size: e.iconSize }),
        rightSection: e.background.color === i ? /* @__PURE__ */ n.jsx(Ae, { size: 20, className: "bn-tick-icon" }) : /* @__PURE__ */ n.jsx("div", { className: "bn-tick-space" }),
        children: i.charAt(0).toUpperCase() + i.slice(1)
      },
      "background-color-" + i
    ))
  ] }) : null;
  return /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
    /* @__PURE__ */ n.jsx(r, {}),
    /* @__PURE__ */ n.jsx(o, {})
  ] });
}, sr = (e) => /* @__PURE__ */ n.jsxs(Ze, { gap: 0, className: "bn-tooltip", children: [
  /* @__PURE__ */ n.jsx(de, { size: "sm", children: e.mainTooltip }),
  e.secondaryTooltip && /* @__PURE__ */ n.jsx(de, { size: "xs", children: e.secondaryTooltip })
] }), F = fe(
  (e, r) => {
    const o = e.icon;
    return /* @__PURE__ */ n.jsx(
      $n,
      {
        withinPortal: !1,
        label: /* @__PURE__ */ n.jsx(
          sr,
          {
            mainTooltip: e.mainTooltip,
            secondaryTooltip: e.secondaryTooltip
          }
        ),
        children: e.children ? /* @__PURE__ */ n.jsxs(
          Ue,
          {
            onClick: e.onClick,
            "data-selected": e.isSelected ? "true" : void 0,
            "data-test": e.mainTooltip.slice(0, 1).toLowerCase() + e.mainTooltip.replace(/\s+/g, "").slice(1),
            size: "xs",
            disabled: e.isDisabled || !1,
            ref: r,
            children: [
              o && /* @__PURE__ */ n.jsx(o, {}),
              e.children
            ]
          }
        ) : /* @__PURE__ */ n.jsx(
          Mt,
          {
            onClick: e.onClick,
            "data-selected": e.isSelected ? "true" : void 0,
            "data-test": e.mainTooltip.slice(0, 1).toLowerCase() + e.mainTooltip.replace(/\s+/g, "").slice(1),
            size: 30,
            disabled: e.isDisabled || !1,
            ref: r,
            children: o && /* @__PURE__ */ n.jsx(o, {})
          }
        )
      }
    );
  }
);
function We() {
  const e = D(null);
  return {
    ref: e,
    updateMaxHeight: () => {
      setTimeout(() => {
        if (e.current && e.current.childElementCount > 0) {
          e.current.firstElementChild.style.maxHeight = "none";
          const r = e.current.firstElementChild.getBoundingClientRect();
          e.current.firstElementChild.style.maxHeight = `${Math.min(
            r.top >= 0 ? window.innerHeight - r.top - 20 : r.bottom - 20
          )}px`;
        }
      }, 10);
    }
  };
}
function ee(e) {
  const [r, o] = b(
    () => {
      var i;
      return ((i = e.getSelection()) == null ? void 0 : i.blocks) || [e.getTextCursorPosition().block];
    }
  );
  return G(
    e,
    () => {
      var i;
      return o(
        ((i = e.getSelection()) == null ? void 0 : i.blocks) || [e.getTextCursorPosition().block]
      );
    }
  ), r;
}
const dr = (e) => {
  const r = ee(e.editor), [o, i] = b(
    e.editor.getActiveStyles().textColor || "default"
  ), [a, l] = b(
    e.editor.getActiveStyles().backgroundColor || "default"
  );
  G(e.editor, () => {
    i(e.editor.getActiveStyles().textColor || "default"), l(
      e.editor.getActiveStyles().backgroundColor || "default"
    );
  });
  const { ref: u, updateMaxHeight: d } = We(), s = L(
    (k) => {
      e.editor.focus(), k === "default" ? e.editor.removeStyles({ textColor: k }) : e.editor.addStyles({ textColor: k });
    },
    [e.editor]
  ), h = L(
    (k) => {
      e.editor.focus(), k === "default" ? e.editor.removeStyles({ backgroundColor: k }) : e.editor.addStyles({ backgroundColor: k });
    },
    [e.editor]
  );
  return A(() => {
    for (const k of r)
      if (k.content !== void 0)
        return !0;
    return !1;
  }, [r]) ? /* @__PURE__ */ n.jsxs(w, { withinPortal: !1, onOpen: d, children: [
    /* @__PURE__ */ n.jsx(w.Target, { children: /* @__PURE__ */ n.jsx(
      F,
      {
        mainTooltip: "Colors",
        icon: () => /* @__PURE__ */ n.jsx(
          Oe,
          {
            textColor: o,
            backgroundColor: a,
            size: 20
          }
        )
      }
    ) }),
    /* @__PURE__ */ n.jsx("div", { ref: u, children: /* @__PURE__ */ n.jsx(w.Dropdown, { children: /* @__PURE__ */ n.jsx(
      Ft,
      {
        text: {
          color: o,
          setColor: s
        },
        background: {
          color: a,
          setColor: h
        }
      }
    ) }) })
  ] }) : null;
};
function ur(e) {
  return S({ 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 fr(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z" } }] })(e);
}
function gr(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z" } }] })(e);
}
function hr(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z" } }] })(e);
}
function mr(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z" } }] })(e);
}
function br(e) {
  return S({ 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 zt(e) {
  return S({ 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 Nt(e) {
  return S({ 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 Zt(e) {
  return S({ 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 xr(e) {
  return S({ 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 vr(e) {
  return S({ 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 kr(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z" } }] })(e);
}
function yr(e) {
  return S({ 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 Ut(e) {
  return S({ 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 $t(e) {
  return S({ 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 Wt(e) {
  return S({ 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 Cr(e) {
  return S({ 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 jr(e) {
  return S({ 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 ue(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M13 6V21H11V6H5V4H19V6H13Z" } }] })(e);
}
function Sr(e) {
  return S({ 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 Hr(e) {
  return S({ 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 wr(e) {
  return S({ 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 Tr(e) {
  return S({ 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);
}
const Yt = (e) => {
  const [r, o] = b(!1), i = L(() => {
    o(!1);
  }, []), a = L(() => {
    o(!0);
  }, []);
  return /* @__PURE__ */ n.jsxs(
    oe,
    {
      withinPortal: !1,
      onOpen: () => {
        a();
      },
      onClose: () => {
        i();
      },
      zIndex: 1e4,
      ...e,
      children: [
        /* @__PURE__ */ n.jsx(oe.Target, { children: e.target }),
        /* @__PURE__ */ n.jsx(oe.Dropdown, { children: r ? e.dropdown : null })
      ]
    }
  );
}, qt = fe(({ className: e, ...r }, o) => /* @__PURE__ */ n.jsx(
  Ze,
  {
    ...r,
    className: ge("bn-toolbar-input-dropdown", e || ""),
    ref: o,
    children: r.children
  }
)), pr = {
  text: Et,
  file: Vt
}, Fe = (e) => {
  const r = e.icon, o = pr[e.type];
  return /* @__PURE__ */ n.jsx(Ne, { children: /* @__PURE__ */ n.jsx(o, { size: "xs", icon: /* @__PURE__ */ n.jsx(r, {}), ...e.inputProps }) });
}, Kt = fe(({ url: e, text: r, update: o, ...i }, a) => {
  const [l, u] = b(e), [d, s] = b(r);
  R(() => {
    u(e), s(r);
  }, [r, e]);
  const h = L(
    (m) => {
      m.key === "Enter" && (m.preventDefault(), o(l, d));
    },
    [o, l, d]
  ), x = L(
    (m) => u(m.currentTarget.value),
    []
  ), k = L(
    (m) => s(m.currentTarget.value),
    []
  ), T = L(
    () => o(l, d),
    [o, l, d]
  );
  return /* @__PURE__ */ n.jsxs(qt, { ...i, ref: a, children: [
    /* @__PURE__ */ n.jsx(
      Fe,
      {
        type: "text",
        icon: Ut,
        inputProps: {
          autoFocus: !0,
          placeholder: "Edit URL",
          value: l,
          onKeyDown: h,
          onChange: x,
          onSubmit: T
        }
      }
    ),
    /* @__PURE__ */ n.jsx(
      Fe,
      {
        type: "text",
        icon: ue,
        inputProps: {
          placeholder: "Edit Title",
          value: d,
          onKeyDown: h,
          onChange: k,
          onSubmit: T
        }
      }
    )
  ] });
}), Rr = (e) => {
  const r = ee(e.editor), [o, i] = b(
    e.editor.getSelectedLinkUrl() || ""
  ), [a, l] = b(e.editor.getSelectedText());
  G(e.editor, () => {
    l(e.editor.getSelectedText() || ""), i(e.editor.getSelectedLinkUrl() || "");
  });
  const u = L(
    (s, h) => {
      e.editor.createLink(s, h), e.editor.focus();
    },
    [e.editor]
  );
  return A(() => {
    for (const s of r)
      if (s.content === void 0)
        return !1;
    return !0;
  }, [r]) ? /* @__PURE__ */ n.jsx(
    Yt,
    {
      target: /* @__PURE__ */ n.jsx(
        F,
        {
          mainTooltip: "Create Link",
          secondaryTooltip: z("Mod+K"),
          icon: Ut
        }
      ),
      dropdown: /* @__PURE__ */ n.jsx(Kt, { url: o, text: a, update: u })
    }
  ) : null;
}, Mr = (e) => {
  const r = ee(e.editor), o = A(
    () => (
      // Checks if only one block is selected.
      r.length === 1 && // Checks if the selected block is an image.
      r[0].type === "image" && // Checks if the block has a `caption` prop which can take any string
      // value.
      "caption" in e.editor.blockSchema.image.propSchema && typeof e.editor.blockSchema.image.propSchema.caption.default == "string" && e.editor.blockSchema.image.propSchema.caption.values === void 0 && // Checks if the block has a `url` prop which can take any string value.
      "url" in e.editor.blockSchema.image.propSchema && typeof e.editor.blockSchema.image.propSchema.url.default == "string" && e.editor.blockSchema.image.propSchema.url.values === void 0 && // Checks if the `url` prop is not set to an empty string.
      r[0].props.url !== ""
    ),
    [e.editor.blockSchema, r]
  ), [i, a] = b(
    o ? r[0].props.caption : ""
  );
  R(
    () => a(
      o ? r[0].props.caption : ""
    ),
    [r, o]
  );
  const l = L(
    (d) => {
      d.key === "Enter" && (d.preventDefault(), e.editor.updateBlock(r[0], {
        type: "image",
        props: {
          caption: i
        }
      }));
    },
    [i, e.editor, r]
  ), u = L(
    (d) => a(d.currentTarget.value),
    []
  );
  return o ? /* @__PURE__ */ n.jsx(
    Yt,
    {
      target: /* @__PURE__ */ n.jsx(
        F,
        {
          mainTooltip: "Edit Caption",
          icon: ue,
          isSelected: r[0].props.caption !== ""
        }
      ),
      dropdown: /* @__PURE__ */ n.jsx(qt, { children: /* @__PURE__ */ n.jsx(
        Fe,
        {
          type: "text",
          icon: ue,
          inputProps: {
            autoFocus: !0,
            placeholder: "Edit Caption",
            value: i,
            onKeyDown: l,
            onChange: u
          }
        }
      ) })
    }
  ) : null;
}, Er = (e) => {
  const [r, o] = b(
    () => e.editor.canNestBlock()
  );
  G(e.editor, () => {
    e.editor.canNestBlock(), o(e.editor.canNestBlock());
  });
  const i = L(() => {
    e.editor.focus(), e.editor.nestBlock();
  }, [e.editor]);
  return /* @__PURE__ */ n.jsx(
    F,
    {
      onClick: i,
      isDisabled: !r,
      mainTooltip: "Nest Block",
      secondaryTooltip: z("Tab"),
      icon: vr
    }
  );
}, Vr = (e) => {
  const [r, o] = b(
    () => e.editor.canUnnestBlock()
  );
  G(e.editor, () => {
    o(e.editor.canUnnestBlock());
  });
  const i = L(() => {
    e.editor.focus(), e.editor.unnestBlock();
  }, [e]);
  return /* @__PURE__ */ n.jsx(
    F,
    {
      onClick: i,
      isDisabled: !r,
      mainTooltip: "Unnest Block",
      secondaryTooltip: z("Shift+Tab"),
      icon: xr
    }
  );
}, Gt = (e) => {
  const [r, o] = b(
    e.editor.uploadFile !== void 0 ? "upload" : "embed"
  ), [i, a] = b(!1), [l, u] = b(!1);
  R(() => {
    l && setTimeout(() => {
      u(!1);
    }, 3e3);
  }, [l]);
  const d = L(
    (m) => {
      if (m === null)
        return;
      async function I(p) {
        if (a(!0), e.editor.uploadFile !== void 0)
          try {
            const N = await e.editor.uploadFile(p);
            e.editor.updateBlock(e.block, {
              type: "image",
              props: {
                url: N
              }
            });
          } catch {
            u(!0);
          } finally {
            a(!1);
          }
      }
      I(m);
    },
    [e.block, e.editor]
  ), [s, h] = b(""), x = L(
    (m) => {
      h(m.currentTarget.value);
    },
    []
  ), k = L(
    (m) => {
      m.key === "Enter" && (m.preventDefault(), e.editor.updateBlock(e.block, {
        type: "image",
        props: {
          url: s
        }
      }));
    },
    [s, e.block, e.editor]
  ), T = L(() => {
    e.editor.updateBlock(e.block, {
      type: "image",
      props: {
        url: s
      }
    });
  }, [s, e.block, e.editor]);
  return /* @__PURE__ */ n.jsx($e, { className: "bn-image-toolbar", children: /* @__PURE__ */ n.jsxs(re, { value: r, onChange: o, children: [
    i && /* @__PURE__ */ n.jsx(Wn, { visible: i }),
    /* @__PURE__ */ n.jsxs(re.List, { children: [
      e.editor.uploadFile !== void 0 && /* @__PURE__ */ n.jsx(re.Tab, { value: "upload", "data-test": "upload-tab", children: "Upload" }),
      /* @__PURE__ */ n.jsx(re.Tab, { value: "embed", "data-test": "embed-tab", children: "Embed" })
    ] }),
    e.editor.uploadFile !== void 0 && /* @__PURE__ */ n.jsx(re.Panel, { className: "bn-upload-image-panel", value: "upload", children: /* @__PURE__ */ n.jsxs("div", { children: [
      /* @__PURE__ */ n.jsx(
        Vt,
        {
          placeholder: "Upload Image",
          size: "xs",
          value: null,
          onChange: d,
          "data-test": "upload-input"
        }
      ),
      l && /* @__PURE__ */ n.jsx(de, { c: "red", size: "12px", children: "Error: Upload failed" })
    ] }) }),
    /* @__PURE__ */ n.jsx(re.Panel, { className: "bn-embed-image-panel", value: "embed", children: /* @__PURE__ */ n.jsxs("div", { children: [
      /* @__PURE__ */ n.jsx(
        Et,
        {
          size: "xs",
          placeholder: "Enter URL",
          value: s,
          onChange: x,
          onKeyDown: k,
          "data-test": "embed-input"
        }
      ),
      /* @__PURE__ */ n.jsx(
        Ue,
        {
          className: "bn-embed-image-button",
          onClick: T,
          size: "xs",
          "data-test": "embed-input-button",
          children: "Embed Image"
        }
      )
    ] }) })
  ] }) });
}, Lr = (e) => {
  const r = ee(e.editor), [o, i] = b(!1);
  return R(() => {
    i(!1);
  }, [r]), // Checks if only one block is selected.
  r.length === 1 && // Checks if the selected block is an image.
  r[0].type === "image" ? /* @__PURE__ */ n.jsxs(oe, { withinPortal: !1, opened: o, position: "bottom", children: [
    /* @__PURE__ */ n.jsx(oe.Target, { children: /* @__PURE__ */ n.jsx(
      F,
      {
        onClick: () => i(!o),
        isSelected: o,
        mainTooltip: "Replace Image",
        icon: wr
      }
    ) }),
    /* @__PURE__ */ n.jsx(oe.Dropdown, { children: /* @__PURE__ */ n.jsx(
      Gt,
      {
        block: r[0],
        editor: e.editor
      }
    ) })
  ] }) : null;
}, Br = {
  left: hr,
  center: fr,
  right: mr,
  justify: gr
}, _e = (e) => {
  const r = ee(e.editor), o = A(() => {
    const l = r[0];
    if ("textAlignment" in l.props)
      return l.props.textAlignment;
  }, [r]), i = L(
    (l) => {
      e.editor.focus();
      for (const u of r)
        e.editor.updateBlock(u, {
          props: { textAlignment: l }
        });
    },
    [e.editor, r]
  );
  return A(() => !!r.find((l) => "textAlignment" in l.props), [r]) ? /* @__PURE__ */ n.jsx(
    F,
    {
      onClick: () => i(e.textAlignment),
      isSelected: o === e.textAlignment,
      mainTooltip: e.textAlignment === "justify" ? "Justify Text" : "Align Text " + e.textAlignment.slice(0, 1).toUpperCase() + e.textAlignment.slice(1),
      icon: Br[e.textAlignment]
    }
  ) : null;
}, Pr = {
  bold: "Mod+B",
  italic: "Mod+I",
  underline: "Mod+U",
  strike: "Mod+Shift+X",
  code: ""
}, _r = {
  bold: br,
  italic: kr,
  underline: Sr,
  strike: Cr,
  code: ur
}, je = (e) => {
  const r = ee(e.editor), [o, i] = b(
    e.toggledStyle in e.editor.getActiveStyles()
  );
  G(e.editor, () => {
    i(e.toggledStyle in e.editor.getActiveStyles());
  });
  const a = (u) => {
    if (e.editor.focus(), e.editor.styleSchema[u].propSchema !== "boolean")
      throw new Error("can only toggle boolean styles");
    e.editor.toggleStyles({ [u]: !0 });
  };
  return A(() => !!r.find((u) => u.content !== void 0), [r]) ? /* @__PURE__ */ n.jsx(
    F,
    {
      onClick: () => a(e.toggledStyle),
      isSelected: o,
      mainTooltip: e.toggledStyle.slice(0, 1).toUpperCase() + e.toggledStyle.slice(1),
      secondaryTooltip: z(Pr[e.toggledStyle]),
      icon: _r[e.toggledStyle]
    }
  ) : null;
};
function Dr(e) {
  const r = e.icon;
  return /* @__PURE__ */ n.jsx(
    w.Item,
    {
      onClick: e.onClick,
      leftSection: r && /* @__PURE__ */ n.jsx(r, { size: 16 }),
      rightSection: e.isSelected ? /* @__PURE__ */ n.jsx(Ae, { size: 20, className: "bn-tick-icon" }) : (
        // Ensures space for tick even if item isn't currently selected.
        /* @__PURE__ */ n.jsx("div", { className: "bn-tick-space" })
      ),
      disabled: e.isDisabled,
      children: e.text
    },
    e.text
  );
}
function Ir(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, child: [{ tag: "path", attr: { fillRule: "evenodd", d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z", clipRule: "evenodd" } }] })(e);
}
function Or(e) {
  return S({ tag: "svg", attr: { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, child: [{ tag: "path", attr: { fillRule: "evenodd", d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", clipRule: "evenodd" } }] })(e);
}
const Ar = fe((e, r) => {
  const o = e.icon;
  return /* @__PURE__ */ n.jsx(
    Ue,
    {
      leftSection: o && /* @__PURE__ */ n.jsx(o, { size: 16 }),
      rightSection: /* @__PURE__ */ n.jsx(Ir, {}),
      size: "xs",
      variant: "subtle",
      disabled: e.isDisabled,
      onClick: e.onClick,
      ref: r,
      children: e.text
    }
  );
});
function Fr(e) {
  const r = e.items.filter((a) => a.isSelected)[0], { ref: o, updateMaxHeight: i } = We();
  return r ? /* @__PURE__ */ n.jsxs(
    w,
    {
      withinPortal: !1,
      transitionProps: {
        exitDuration: 0
      },
      disabled: e.isDisabled,
      onOpen: i,
      children: [
        /* @__PURE__ */ n.jsx(w.Target, { children: /* @__PURE__ */ n.jsx(
          Ar,
          {
            text: r.text,
            icon: r.icon,
            isDisabled: r.isDisabled
          }
        ) }),
        /* @__PURE__ */ n.jsx("div", { ref: o, children: /* @__PURE__ */ n.jsx(w.Dropdown, { children: e.items.map((a) => /* @__PURE__ */ n.jsx(Dr, { ...a }, a.text)) }) })
      ]
    }
  ) : null;
}
const zr = [
  {
    name: "Paragraph",
    type: "paragraph",
    icon: ue,
    isSelected: (e) => e.type === "paragraph"
  },
  {
    name: "Heading 1",
    type: "heading",
    props: { level: 1 },
    icon: zt,
    isSelected: (e) => e.type === "heading" && "level" in e.props && e.props.level === 1
  },
  {
    name: "Heading 2",
    type: "heading",
    props: { level: 2 },
    icon: Nt,
    isSelected: (e) => e.type === "heading" && "level" in e.props && e.props.level === 2
  },
  {
    name: "Heading 3",
    type: "heading",
    props: { level: 3 },
    icon: Zt,
    isSelected: (e) => e.type === "heading" && "level" in e.props && e.props.level === 3
  },
  {
    name: "Bullet List",
    type: "bulletListItem",
    icon: Wt,
    isSelected: (e) => e.type === "bulletListItem"
  },
  {
    name: "Numbered List",
    type: "numberedListItem",
    icon: $t,
    isSelected: (e) => e.type === "numberedListItem"
  }
], Nr = (e) => {
  const r = ee(e.editor), [o, i] = b(
    e.editor.getTextCursorPosition().block
  ), a = A(() => (e.items || zr).filter((d) => {
    if (!(d.type in e.editor.blockSchema))
      return !1;
    for (const [s, h] of Object.entries(d.props || {})) {
      const x = e.editor.blockSchema[d.type].propSchema;
      if (!(s in x) || x[s].values !== void 0 && !x[s].values.includes(h))
        return !1;
    }
    return !0;
  }), [e.editor, e.items]), l = A(
    () => a.find((d) => d.type === o.type) !== void 0,
    [o.type, a]
  ), u = A(() => {
    const d = (s) => {
      e.editor.focus();
      for (const h of r)
        e.editor.updateBlock(h, {
          type: s.type,
          props: s.props
        });
    };
    return a.map((s) => ({
      text: s.name,
      icon: s.icon,
      onClick: () => d(s),
      isSelected: s.isSelected(o)
    }));
  }, [o, a, e.editor, r]);
  return G(e.editor, () => {
    i(e.editor.getTextCursorPosition().block);
  }), l ? /* @__PURE__ */ n.jsx(Fr, { items: u }) : null;
}, Zr = (e) => /* @__PURE__ */ n.jsxs($e, { children: [
  /* @__PURE__ */ n.jsx(Nr, { ...e, items: e.blockTypeDropdownItems }),
  /* @__PURE__ */ n.jsx(Mr, { editor: e.editor }),
  /* @__PURE__ */ n.jsx(Lr, { editor: e.editor }),
  /* @__PURE__ */ n.jsx(je, { editor: e.editor, toggledStyle: "bold" }),
  /* @__PURE__ */ n.jsx(je, { editor: e.editor, toggledStyle: "italic" }),
  /* @__PURE__ */ n.jsx(je, { editor: e.editor, toggledStyle: "underline" }),
  /* @__PURE__ */ n.jsx(je, { editor: e.editor, toggledStyle: "strike" }),
  /* @__PURE__ */ n.jsx(_e, { editor: e.editor, textAlignment: "left" }),
  /* @__PURE__ */ n.jsx(_e, { editor: e.editor, textAlignment: "center" }),
  /* @__PURE__ */ n.jsx(_e, { editor: e.editor, textAlignment: "right" }),
  /* @__PURE__ */ n.jsx(dr, { editor: e.editor }),
  /* @__PURE__ */ n.jsx(Er, { editor: e.editor }),
  /* @__PURE__ */ n.jsx(Vr, { editor: e.editor }),
  /* @__PURE__ */ n.jsx(Rr, { editor: e.editor })
] }), Ct = (e) => {
  switch (e) {
    case "left":
      return "top-start";
    case "center":
      return "top";
    case "right":
      return "top-end";
    default:
      return "top-start";
  }
}, Ur = (e) => {
  const [r, o] = b(!1), [i, a] = b(
    () => {
      const m = e.editor.getTextCursorPosition().block;
      return "textAlignment" in m.props ? Ct(
        m.props.textAlignment
      ) : "top-start";
    }
  ), l = D(), { refs: u, update: d, context: s, floatingStyles: h } = X({
    open: r,
    placement: i,
    middleware: [ie(10), we()]
  }), { isMounted: x, styles: k } = Q(s);
  R(() => e.editor.formattingToolbar.onUpdate((m) => {
    o(m.show), l.current = m.referencePos, d();
  }), [e.editor, d]), G(e.editor, () => {
    const m = e.editor.getTextCursorPosition().block;
    "textAlignment" in m.props ? a(
      Ct(
        m.props.textAlignment
      )
    ) : a("top-start");
  }), R(() => {
    u.setReference({
      getBoundingClientRect: () => l.current
    });
  }, [u]);
  const T = e.formattingToolbar || Zr;
  return x ? /* @__PURE__ */ n.jsx(
    "div",
    {
      ref: u.setFloating,
      style: { ...k, ...h, zIndex: 3e3 },
      children: /* @__PURE__ */ n.jsx(T, { editor: e.editor })
    }
  ) : null;
}, $r = (e) => {
  const [r, o] = b(!1), i = D(null);
  return r ? /* @__PURE__ */ n.jsx(
    Kt,
    {
      url: e.url,
      text: e.text,
      update: e.editHyperlink,
      onBlur: (a) => setTimeout(() => {
        var l;
        (l = i.current) != null && l.contains(a.relatedTarget) || o(!1);
      }, 500),
      ref: i
    }
  ) : /* @__PURE__ */ n.jsxs(
    $e,
    {
      onMouseEnter: e.stopHideTimer,
      onMouseLeave: e.startHideTimer,
      children: [
        /* @__PURE__ */ n.jsx(
          F,
          {
            mainTooltip: "Edit",
            isSelected: !1,
            onClick: () => o(!0),
            children: "Edit Link"
          }
        ),
        /* @__PURE__ */ n.jsx(
          F,
          {
            mainTooltip: "Open in new tab",
            isSelected: !1,
            onClick: () => {
              window.open(e.url, "_blank");
            },
            icon: Tr
          }
        ),
        /* @__PURE__ */ n.jsx(
          F,
          {
            mainTooltip: "Remove link",
            isSelected: !1,
            onClick: e.deleteHyperlink,
            icon: yr
          }
        )
      ]
    }
  );
}, Wr = (e) => {
  const [r, o] = b(!1), [i, a] = b(), [l, u] = b(), d = D(), { refs: s, update: h, context: x, floatingStyles: k } = X({
    open: r,
    placement: "top-start",
    middleware: [ie(10), we()]
  }), { isMounted: T, styles: m } = Q(x);
  if (R(() => e.editor.hyperlinkToolbar.on(
    "update",
    (p) => {
      o(p.show), a(p.url), u(p.text), d.current = p.referencePos, h();
    }
  ), [e.editor, h]), R(() => {
    s.setReference({
      getBoundingClientRect: () => d.current
    });
  }, [s]), !i || !l || !T)
    return null;
  const I = e.hyperlinkToolbar || $r;
  return /* @__PURE__ */ n.jsx(
    "div",
    {
      ref: s.setFloating,
      style: { ...m, ...k, zIndex: 4e3 },
      children: /* @__PURE__ */ n.jsx(
        I,
        {
          url: i,
          text: l,
          editHyperlink: e.editor.hyperlinkToolbar.editHyperlink,
          deleteHyperlink: e.editor.hyperlinkToolbar.deleteHyperlink,
          startHideTimer: e.editor.hyperlinkToolbar.startHideTimer,
          stopHideTimer: e.editor.hyperlinkToolbar.stopHideTimer
        }
      )
    }
  );
}, Yr = (e) => {
  const [r, o] = b(!1), [i, a] = b(), l = D(), { refs: u, update: d, context: s, floatingStyles: h } = X({
    open: r,
    placement: "bottom",
    middleware: [ie(10), we()]
  }), { isMounted: x, styles: k } = Q(s);
  R(() => e.editor.imageToolbar.onUpdate((m) => {
    o(m.show), a(m.block), l.current = m.referencePos, d();
  }), [e.editor, d]), R(() => {
    u.setReference({
      getBoundingClientRect: () => l.current
    });
  }, [u]);
  const T = e.imageToolbar || Gt;
  return x ? /* @__PURE__ */ n.jsx(
    "div",
    {
      ref: u.setFloating,
      style: { ...k, ...h, zIndex: 5e3 },
      children: /* @__PURE__ */ n.jsx(T, { editor: e.editor, block: i })
    }
  ) : null;
};
function qr(e) {
  return S({ 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 Jt = (e) => /* @__PURE__ */ n.jsx(Mt, { size: 24, children: e.children }), Kr = (e) => /* @__PURE__ */ n.jsx(Jt, { children: /* @__PURE__ */ n.jsx(
  qr,
  {
    size: 24,
    onClick: e.addBlock,
    "data-test": "dragHandleAdd"
  }
) });
function Xt(e) {
  return S({ 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 Qt = (e) => {
  const { children: r, ...o } = e;
  return /* @__PURE__ */ n.jsx(w.Item, { ...o, children: r });
}, Gr = (e) => {
  const [r, o] = b(!1), { ref: i, updateMaxHeight: a } = We(), l = D(), u = L(() => {
    l.current && clearTimeout(l.current), l.current = setTimeout(() => {
      o(!1);
    }, 250);
  }, []), d = L(() => {
    l.current && clearTimeout(l.current), r || a(), o(!0);
  }, [r, a]);
  return !("textColor" in e.block.props) && !("backgroundColor" in e.block.props) ? null : /* @__PURE__ */ n.jsx(
    Qt,
    {
      onMouseLeave: u,
      onMouseOver: d,
      children: /* @__PURE__ */ n.jsxs(w, { withinPortal: !1, opened: r, position: "right", children: [
        /* @__PURE__ */ n.jsx(w.Target, { children: /* @__PURE__ */ n.jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [
          /* @__PURE__ */ n.jsx("div", { style: { flex: 1 }, children: e.children }),
          /* @__PURE__ */ n.jsx(Rt, { style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ n.jsx(Or, { size: 15 }) })
        ] }) }),
        /* @__PURE__ */ n.jsx("div", { ref: i, children: /* @__PURE__ */ n.jsx(
          w.Dropdown,
          {
            onMouseLeave: u,
            onMouseOver: d,
            style: { marginLeft: "5px" },
            children: /* @__PURE__ */ n.jsx(
              Ft,
              {
                iconSize: 18,
                text: "textColor" in e.block.props && typeof e.block.props.textColor == "string" ? {
                  color: e.block.props.textColor,
                  setColor: (s) => e.editor.updateBlock(e.block, {
                    props: { textColor: s }
                  })
                } : void 0,
                background: "backgroundColor" in e.block.props && typeof e.block.props.backgroundColor == "string" ? {
                  color: e.block.props.backgroundColor,
                  setColor: (s) => e.editor.updateBlock(e.block, {
                    props: { backgroundColor: s }
                  })
                } : void 0
              }
            )
          }
        ) })
      ] })
    }
  );
}, Jr = (e) => /* @__PURE__ */ n.jsx(
  Qt,
  {
    onClick: () => e.editor.removeBlocks([e.block]),
    children: e.children
  }
), Xr = (e) => /* @__PURE__ */ n.jsx(w.Dropdown, { className: "bn-drag-handle-menu", children: e.children }), Qr = (e) => /* @__PURE__ */ n.jsxs(Xr, { children: [
  /* @__PURE__ */ n.jsx(Jr, { ...e, children: "Delete" }),
  /* @__PURE__ */ n.jsx(Gr, { ...e, children: "Colors" })
] }), eo = (e) => {
  const r = e.dragHandleMenu || Qr;
  return /* @__PURE__ */ n.jsxs(
    w,
    {
      withinPortal: !1,
      trigger: "click",
      onOpen: e.freezeMenu,
      onClose: e.unfreezeMenu,
      width: 100,
      position: "left",
      children: [
        /* @__PURE__ */ n.jsx(w.Target, { children: /* @__PURE__ */ n.jsx(
          "div",
          {
            className: "bn-drag-handle",
            draggable: "true",
            onDragStart: e.blockDragStart,
            onDragEnd: e.blockDragEnd,
            children: /* @__PURE__ */ n.jsx(Jt, { children: /* @__PURE__ */ n.jsx(Xt, { size: 24, "data-test": "dragHandle" }) })
          }
        ) }),
        /* @__PURE__ */ n.jsx(r, { editor: e.editor, block: e.block })
      ]
    }
  );
}, to = (e) => /* @__PURE__ */ n.jsx(Ne, { className: "bn-side-menu", gap: 0, children: e.children }), no = (e) => /* @__PURE__ */ n.jsxs(to, { children: [
  /* @__PURE__ */ n.jsx(Kr, { ...e }),
  /* @__PURE__ */ n.jsx(eo, { ...e })
] }), ro = (e) => {
  const [r, o] = b(!1), [i, a] = b(), l = D(), { refs: u, update: d, context: s, floatingStyles: h } = X({
    open: r,
    placement: "left"
  }), { isMounted: x, styles: k } = Q(s);
  if (R(() => e.editor.sideMenu.onUpdate((m) => {
    o(m.show), a(m.block), l.current = m.referencePos, d();
  }), [e.editor, d]), R(() => {
    u.setReference({
      getBoundingClientRect: () => l.current
    });
  }, [u]), !i || !x)
    return null;
  const T = e.sideMenu || no;
  return /* @__PURE__ */ n.jsx(
    "div",
    {
      ref: u.setFloating,
      style: { ...k, ...h, zIndex: 1e3 },
      children: /* @__PURE__ */ n.jsx(
        T,
        {
          block: i,
          editor: e.editor,
          blockDragStart: e.editor.sideMenu.blockDragStart,
          blockDragEnd: e.editor.sideMenu.blockDragEnd,
          addBlock: e.editor.sideMenu.addBlock,
          freezeMenu: e.editor.sideMenu.freezeMenu,
          unfreezeMenu: e.editor.sideMenu.unfreezeMenu
        }
      )
    }
  );
}, oo = 5;
function io(e) {
  const r = D(null);
  function o() {
    var u;
    const a = e.isSelected, l = (u = r.current) == null ? void 0 : u.matches(":hover");
    return a || l;
  }
  function i() {
    var a, l;
    o() ? (a = r.current) == null || a.setAttribute("data-hovered", "true") : (l = r.current) == null || l.removeAttribute("data-hovered");
  }
  return R(() => {
    i(), o() && r.current && r.current.getBoundingClientRect().left > oo && r.current.scrollIntoView({
      behavior: "smooth",
      block: "nearest"
    });
  }), /* @__PURE__ */ n.jsx(
    w.Item,
    {
      className: "bn-slash-menu-item",
      onClick: e.set,
      closeMenuOnClick: !1,
      onMouseLeave: () => {
        setTimeout(() => {
          i();
        }, 1);
      },
      leftSection: e.icon,
      rightSection: e.shortcut && /* @__PURE__ */ n.jsx(Yn, { size: "xs", children: e.shortcut }),
      ref: r,
      children: /* @__PURE__ */ n.jsxs(Ze, { children: [
        /* @__PURE__ */ n.jsx(de, { lh: "20px", size: "14px", fw: 500, children: e.name }),
        /* @__PURE__ */ n.jsx(de, { lh: "16px", size: "10px", children: e.hint })
      ] })
    }
  );
}
function ao(e) {
  const r = [];
  let o = 0;
  const i = er(e.filteredItems, (a) => a.group);
  return Qn(i, (a) => {
    r.push(
      /* @__PURE__ */ n.jsx(w.Label, { children: a[0].group }, a[0].group)
    );
    for (const l of a)
      r.push(
        /* @__PURE__ */ n.jsx(
          io,
          {
            name: l.name,
            icon: l.icon,
            hint: l.hint,
            shortcut: l.shortcut,
            isSelected: e.keyboardHoveredItemIndex === o,
            set: () => e.itemCallback(l)
          },
          l.name
        )
      ), o++;
  }), /* @__PURE__ */ n.jsx(
    w,
    {
      withinPortal: !1,
      trapFocus: !1,
      defaultOpened: !0,
      trigger: "hover",
      closeDelay: 1e7,
      children: /* @__PURE__ */ n.jsx(
        w.Dropdown,
        {
          onMouseDown: (a) => a.preventDefault(),
          className: "bn-slash-menu",
          children: r.length > 0 ? r : /* @__PURE__ */ n.jsx(w.Item, { children: "No match found" })
        }
      )
    }
  );
}
const lo = (e) => {
  const [r, o] = b(!1), [i, a] = b(), [l, u] = b(), d = D(), { refs: s, update: h, context: x, floatingStyles: k } = X({
    open: r,
    placement: "bottom-start",
    middleware: [
      ie(10),
      // Flips the slash menu placement to maximize the space available, and
      // prevents the menu from being cut off by the confines of the screen.
      we(),
      Xn({
        apply({ availableHeight: p, elements: N }) {
          Object.assign(N.floating.style, {
            maxHeight: `${p - 10}px`
          });
        }
      })
    ]
  }), { isMounted: T, styles: m } = Q(x);
  if (R(() => e.editor.slashMenu.onUpdate((p) => {
    o(p.show), a(p.filteredItems), u(p.keyboardHoveredItemIndex), d.current = p.referencePos, h();
  }), [e.editor, r, h]), R(() => {
    s.setReference({
      getBoundingClientRect: () => d.current
    });
  }, [s]), !T || !i || l === void 0)
    return null;
  const I = e.slashMenu || ao;
  return /* @__PURE__ */ n.jsx(
    "div",
    {
      ref: s.setFloating,
      style: {
        display: "flex",
        ...m,
        ...k,
        zIndex: 2e3
      },
      children: /* @__PURE__ */ n.jsx(
        I,
        {
          filteredItems: i,
          itemCallback: (p) => e.editor.slashMenu.itemCallback(p),
          keyboardHoveredItemIndex: l
        }
      )
    }
  );
}, co = (e) => /* @__PURE__ */ n.jsx(w.Dropdown, { className: "bn-table-handle-menu", children: e.children }), Te = (e) => {
  const { children: r, ...o } = e;
  return /* @__PURE__ */ n.jsx(w.Item, { ...o, children: r });
}, so = (e) => /* @__PURE__ */ n.jsx(
  Te,
  {
    onClick: () => {
      const r = e.block.content.rows[e.index].cells.map(
        () => []
      ), o = [...e.block.content.rows];
      o.splice(e.index + (e.side === "below" ? 1 : 0), 0, {
        cells: r
      }), e.editor.updateBlock(e.block, {
        type: "table",
        content: {
          type: "tableContent",
          rows: o
        }
      });
    },
    children: `Add row ${e.side}`
  }
), uo = (e) => /* @__PURE__ */ n.jsx(
  Te,
  {
    onClick: () => {
      const r = {
        type: "tableContent",
        rows: e.block.content.rows.map((o) => {
          const i = [...o.cells];
          return i.splice(e.index + (e.side === "right" ? 1 : 0), 0, []), { cells: i };
        })
      };
      e.editor.updateBlock(e.block, {
        type: "table",
        content: r
      });
    },
    children: `Add column ${e.side}`
  }
), jt = (e) => e.orientation === "row" ? /* @__PURE__ */ n.jsx(so, { ...e, side: e.side }) : /* @__PURE__ */ n.jsx(uo, { ...e, side: e.side }), fo = (e) => /* @__PURE__ */ n.jsx(
  Te,
  {
    onClick: () => {
      const r = {
        type: "tableContent",
        rows: e.block.content.rows.filter(
          (o, i) => i !== e.index
        )
      };
      e.editor.updateBlock(e.block, {
        type: "table",
        content: r
      });
    },
    children: "Delete row"
  }
), go = (e) => /* @__PURE__ */ n.jsx(
  Te,
  {
    onClick: () => {
      const r = {
        type: "tableContent",
        rows: e.block.content.rows.map((o) => ({
          cells: o.cells.filter((i, a) => a !== e.index)
        }))
      };
      e.editor.updateBlock(e.block, {
        type: "table",
        content: r
      });
    },
    children: "Delete column"
  }
), ho = (e) => e.orientation === "row" ? /* @__PURE__ */ n.jsx(fo, { ...e }) : /* @__PURE__ */ n.jsx(go, { ...e }), mo = (e) => /* @__PURE__ */ n.jsxs(co, { children: [
  /* @__PURE__ */ n.jsx(
    ho,
    {
      orientation: e.orientation,
      editor: e.editor,
      block: e.block,
      index: e.index
    }
  ),
  /* @__PURE__ */ n.jsx(
    jt,
    {
      orientation: e.orientation,
      editor: e.editor,
      block: e.block,
      index: e.index,
      side: e.orientation === "row" ? "above" : "left"
    }
  ),
  /* @__PURE__ */ n.jsx(
    jt,
    {
      orientation: e.orientation,
      editor: e.editor,
      block: e.block,
      index: e.index,
      side: e.orientation === "row" ? "below" : "right"
    }
  )
] }), bo = (e) => {
  const r = e.tableHandleMenu || mo, [o, i] = b(!1);
  return /* @__PURE__ */ n.jsxs(
    w,
    {
      withinPortal: !1,
      trigger: "click",
      onOpen: () => {
        e.freezeHandles(), e.hideOtherSide();
      },
      onClose: () => {
        e.unfreezeHandles(), e.showOtherSide();
      },
      position: "right",
      children: [
        /* @__PURE__ */ n.jsx(w.Target, { children: /* @__PURE__ */ n.jsx(
          "div",
          {
            className: ge(
              "bn-table-handle",
              o ? "bn-table-handle-dragging" : ""
            ),
            draggable: "true",
            onDragStart: (a) => {
              i(!0), e.dragStart(a);
            },
            onDragEnd: () => {
              e.dragEnd(), i(!1);
            },
            style: e.orientation === "column" ? { transform: "rotate(0.25turn)" } : void 0,
            children: e.children
          }
        ) }),
        /* @__PURE__ */ n.jsx(
          r,
          {
            orientation: e.orientation,
            editor: e.editor,
            block: e.block,
            index: e.index
          }
        )
      ]
    }
  );
}, xo = (e) => /* @__PURE__ */ n.jsx(bo, { ...e, children: /* @__PURE__ */ n.jsx(Xt, { size: 24, "data-test": "tableHandle" }) }), vo = (e) => {
  const [r, o] = b(!1), [i, a] = b(!1), [l, u] = b(!1), [d, s] = b(), [h, x] = b(), [k, T] = b(), [m, I] = b(void 0), [p, N] = b(), [, q] = b(0), M = D(), O = D(), Z = X({
    open: r,
    placement: "left",
    middleware: [ie(-10)]
  }), U = X({
    open: r,
    placement: "top",
    middleware: [ie(-12)]
  }), he = Q(Z.context), me = Q(U.context);
  R(() => e.editor.tableHandles.onUpdate((P) => {
    o(P.show), s(P.block), x(P.rowIndex), T(P.colIndex), P.draggingState ? (I(P.draggingState.draggedCellOrientation), N(P.draggingState.mousePos)) : (I(void 0), N(void 0)), q(Math.random()), M.current = P.referencePosCell, O.current = P.referencePosTable, Z.update(), U.update();
  }), [U, e.editor, Z]), R(() => {
    Z.refs.setReference({
      getBoundingClientRect: () => m === "row" ? new DOMRect(
        O.current.x,
        p,
        O.current.width,
        0
      ) : new DOMRect(
        O.current.x,
        M.current.y,
        O.current.width,
        M.current.height
      )
    });
  }, [m, p, Z.refs]), R(() => {
    U.refs.setReference({
      getBoundingClientRect: () => m === "col" ? new DOMRect(
        p,
        O.current.y,
        0,
        O.current.height
      ) : new DOMRect(
        M.current.x,
        O.current.y,
        M.current.width,
        O.current.height
      )
    });
  }, [U.refs, m, p]);
  const be = e.tableHandle || xo;
  return !he.isMounted || !me.isMounted || i && l ? null : /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
    !i && /* @__PURE__ */ n.jsx(
      "div",
      {
        ref: Z.refs.setFloating,
        style: {
          ...he.styles,
          ...Z.floatingStyles,
          zIndex: 1e4
        },
        children: /* @__PURE__ */ n.jsx(
          be,
          {
            orientation: "row",
            editor: e.editor,
            index: h,
            block: d,
            dragStart: e.editor.tableHandles.rowDragStart,
            dragEnd: e.editor.tableHandles.dragEnd,
            freezeHandles: e.editor.tableHandles.freezeHandles,
            unfreezeHandles: e.editor.tableHandles.unfreezeHandles,
            showOtherSide: () => u(!1),
            hideOtherSide: () => u(!0)
          }
        )
      }
    ),
    !l && /* @__PURE__ */ n.jsx(
      "div",
      {
        ref: U.refs.setFloating,
        style: {
          ...me.styles,
          ...U.floatingStyles,
          zIndex: 1e4
        },
        children: /* @__PURE__ */ n.jsx(
          be,
          {
            orientation: "column",
            editor: e.editor,
            index: k,
            block: d,
            dragStart: e.editor.tableHandles.colDragStart,
            dragEnd: e.editor.tableHandles.dragEnd,
            freezeHandles: e.editor.tableHandles.freezeHandles,
            unfreezeHandles: e.editor.tableHandles.unfreezeHandles,
            showOtherSide: () => a(!1),
            hideOtherSide: () => a(!0)
          }
        )
      }
    )
  ] });
};
const ko = {
  // Removes button press effect
  activeClassName: ""
};
function Po(e) {
  const { editor: r, className: o, theme: i, children: a, ...l } = e, u = Jn(), [d, s] = b(void 0);
  return R(() => {
    if (or(r.domElement.parentElement), i === "light") {
      s("light");
      return;
    }
    if (i === "dark") {
      s("dark");
      return;
    }
    if (typeof i == "object") {
      if ("light" in i && "dark" in i) {
        xt(
          i[u === "dark" ? "dark" : "light"],
          r.domElement.parentElement
        ), s(u === "dark" ? "dark" : "light");
        return;
      }
      xt(
        i,
        r.domElement.parentElement
      ), s(void 0);
      return;
    }
    s(u === "dark" ? "dark" : "light");
  }, [u, r.domElement, i]), /* @__PURE__ */ n.jsx(qn, { theme: ko, children: /* @__PURE__ */ n.jsx(
    Kn,
    {
      editor: r._tiptapEditor,
      className: ge("bn-container", o || ""),
      "data-color-scheme": d,
      ...l,
      children: a || /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
        /* @__PURE__ */ n.jsx(Ur, { editor: r }),
        /* @__PURE__ */ n.jsx(Wr, { editor: r }),
        /* @__PURE__ */ n.jsx(lo, { editor: r }),
        /* @__PURE__ */ n.jsx(ro, { editor: r }),
        /* @__PURE__ */ n.jsx(Yr, { editor: r }),
        r.blockSchema.table && /* @__PURE__ */ n.jsx(vo, { editor: r })
      ] })
    }
  ) });
}
const j = [
  "#FFFFFF",
  "#EFEFEF",
  "#CFCFCF",
  "#AFAFAF",
  "#7F7F7F",
  "#3F3F3F",
  "#1F1F1F",
  "#161616",
  "#0F0F0F",
  "#000000"
], St = {
  colors: {
    editor: {
      text: j[5],
      background: j[0]
    },
    menu: {
      text: j[5],
      background: j[0]
    },
    tooltip: {
      text: j[5],
      background: j[1]
    },
    hovered: {
      text: j[5],
      background: j[1]
    },
    selected: {
      text: j[0],
      background: j[5]
    },
    disabled: {
      text: j[3],
      background: j[1]
    },
    shadow: j[2],
    border: j[1],
    sideMenu: j[2],
    highlights: {
      gray: {
        text: "#9b9a97",
        background: "#ebeced"
      },
      brown: {
        text: "#64473a",
        background: "#e9e5e3"
      },
      red: {
        text: "#e03e3e",
        background: "#fbe4e4"
      },
      orange: {
        text: "#d9730d",
        background: "#f6e9d9"
      },
      yellow: {
        text: "#dfab01",
        background: "#fbf3db"
      },
      green: {
        text: "#4d6461",
        background: "#ddedea"
      },
      blue: {
        text: "#0b6e99",
        background: "#ddebf1"
      },
      purple: {
        text: "#6940a5",
        background: "#eae4f2"
      },
      pink: {
        text: "#ad1a72",
        background: "#f4dfeb"
      }
    }
  },
  borderRadius: 6,
  fontFamily: '"Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif'
}, _o = {
  colors: {
    editor: {
      text: j[2],
      background: j[6]
    },
    menu: {
      text: j[2],
      background: j[6]
    },
    tooltip: {
      text: j[2],
      background: j[7]
    },
    hovered: {
      text: j[2],
      background: j[7]
    },
    selected: {
      text: j[2],
      background: j[8]
    },
    disabled: {
      text: j[5],
      background: j[7]
    },
    shadow: j[8],
    border: j[7],
    sideMenu: j[4],
    highlights: {
      gray: {
        text: "#bebdb8",
        background: "#9b9a97"
      },
      brown: {
        text: "#8e6552",
        background: "#64473a"
      },
      red: {
        text: "#ec4040",
        background: "#be3434"
      },
      orange: {
        text: "#e3790d",
        background: "#b7600a"
      },
      yellow: {
        text: "#dfab01",
        background: "#b58b00"
      },
      green: {
        text: "#6b8b87",
        background: "#4d6461"
      },
      blue: {
        text: "#0e87bc",
        background: "#0b6e99"
      },
      purple: {
        text: "#8552d7",
        background: "#6940a5"
      },
      pink: {
        text: "#da208f",
        background: "#ad1a72"
      }
    }
  },
  borderRadius: St.borderRadius,
  fontFamily: St.fontFamily
}, yo = {
  Heading: {
    group: "Headings",
    icon: /* @__PURE__ */ n.jsx(zt, { size: 18 }),
    hint: "Used for a top-level heading",
    shortcut: z("Mod-Alt-1")
  },
  "Heading 2": {
    group: "Headings",
    icon: /* @__PURE__ */ n.jsx(Nt, { size: 18 }),
    hint: "Used for key sections",
    shortcut: z("Mod-Alt-2")
  },
  "Heading 3": {
    group: "Headings",
    icon: /* @__PURE__ */ n.jsx(Zt, { size: 18 }),
    hint: "Used for subsections and group headings",
    shortcut: z("Mod-Alt-3")
  },
  "Numbered List": {
    group: "Basic blocks",
    icon: /* @__PURE__ */ n.jsx($t, { size: 18 }),
    hint: "Used to display a numbered list",
    shortcut: z("Mod-Alt-7")
  },
  "Bullet List": {
    group: "Basic blocks",
    icon: /* @__PURE__ */ n.jsx(Wt, { size: 18 }),
    hint: "Used to display an unordered list",
    shortcut: z("Mod-Alt-9")
  },
  Paragraph: {
    group: "Basic blocks",
    icon: /* @__PURE__ */ n.jsx(ue, { size: 18 }),
    hint: "Used for the body of your document",
    shortcut: z("Mod-Alt-0")
  },
  Table: {
    group: "Advanced",
    icon: /* @__PURE__ */ n.jsx(jr, { size: 18 }),
    hint: "Used for for tables"
    // shortcut: formatKeyboardShortcut("Mod-Alt-0"),
  },
  Image: {
    group: "Media",
    icon: /* @__PURE__ */ n.jsx(Hr, {}),
    hint: "Insert an image"
  }
};
function Co(e = Mn) {
  return Rn(e).map((o) => ({
    ...o,
    ...yo[o.name]
  }));
}
function Do(e) {
  const [r, o] = b(() => e.getActiveStyles());
  return Dt(e, () => {
    o(e.getActiveStyles());
  }), It(e, () => {
    o(e.getActiveStyles());
  }), r;
}
const jo = (e) => En.create({
  slashMenuItems: Co(
    Vn(e.blockSpecs || Ln)
  ),
  ...e
}), Io = (e = {}, r = []) => {
  const o = D();
  return A(() => (o.current && o.current._tiptapEditor.destroy(), o.current = jo(e), o.current), r);
};
function So() {
  const [, e] = b(0);
  return () => e((r) => r + 1);
}
const Oo = (e) => {
  const r = So();
  R(() => {
    const o = () => {
      requestAnimationFrame(() => {
        requestAnimationFrame(() => {
          r();
        });
      });
    };
    return e.on("transaction", o), () => {
      e.off("transaction", o);
    };
  }, [e]);
};
var ze, Se = tr;
if (process.env.NODE_ENV === "production")
  ze = Se.createRoot, Se.hydrateRoot;
else {
  var Ht = Se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  ze = function(e, r) {
    Ht.usingClientEntryPoint = !0;
    try {
      return Se.createRoot(e, r);
    } finally {
      Ht.usingClientEntryPoint = !1;
    }
  };
}
function He(e) {
  let r;
  const o = document.createElement("div"), i = ze(o);
  if (nr(() => {
    i.render(e((d) => r = d || void 0));
  }), !o.childElementCount)
    return console.warn("ReactInlineContentSpec: renderHTML() failed"), {
      dom: document.createElement("span")
    };
  r == null || r.setAttribute("data-tmp-find", "true");
  const a = o.cloneNode(!0), l = a.firstElementChild, u = a.querySelector(
    "[data-tmp-find]"
  );
  return u == null || u.removeAttribute("data-tmp-find"), i.unmount(), {
    dom: l,
    contentDOM: u || void 0
  };
}
function De(e) {
  var r;
  return (
    // Creates `blockContent` element
    /* @__PURE__ */ n.jsx(
      Lt,
      {
        ...Object.fromEntries(
          Object.entries(e.domAttributes || {}).filter(
            ([o]) => o !== "class"
          )
        ),
        className: ge(
          "bn-block-content",
          ((r = e.domAttributes) == null ? void 0 : r.class) || ""
        ),
        "data-content-type": e.blockType,
        ...Object.fromEntries(
          Object.entries(e.blockProps).filter(
            ([o, i]) => !Bn.includes(o) && i !== e.propSchema[o].default
          ).map(([o, i]) => [wt(o), i])
        ),
        children: e.children
      }
    )
  );
}
function Ao(e, r) {
  const o = Tt({
    name: e.type,
    content: e.content === "inline" ? "inline*" : "",
    group: "blockContent",
    selectable: !0,
    addAttributes() {
      return pt(e.propSchema);
    },
    parseHTML() {
      return Pn(e, r.parse);
    },
    renderHTML() {
      const i = document.createElement("div");
      return i.setAttribute("data-tmp-placeholder", "true"), {
        dom: i
      };
    },
    addNodeView() {
      return (i) => Bt(
        (a) => {
          var x;
          const l = this.options.editor, u = _n(
            a.getPos,
            l,
            this.editor,
            e.type
          ), d = ((x = this.options.domAttributes) == null ? void 0 : x.blockContent) || {}, s = Pt({}).ref, h = r.render;
          return /* @__PURE__ */ n.jsx(
            De,
            {
              blockType: u.type,
              blockProps: u.props,
              propSchema: e.propSchema,
              domAttributes: d,
              children: /* @__PURE__ */ n.jsx(
                h,
                {
                  block: u,
                  editor: l,
                  contentRef: s
                }
              )
            }
          );
        },
        {
          className: "bn-react-node-view-renderer"
        }
      )(i);
    }
  });
  return Dn(e, {
    node: o,
    toInternalHTML: (i, a) => {
      var s, h;
      const l = ((s = o.options.domAttributes) == null ? void 0 : s.blockContent) || {}, u = r.render, d = He((x) => /* @__PURE__ */ n.jsx(
        De,
        {
          blockType: i.type,
          blockProps: i.props,
          propSchema: e.propSchema,
          domAttributes: l,
          children: /* @__PURE__ */ n.jsx(
            u,
            {
              block: i,
              editor: a,
              contentRef: x
            }
          )
        }
      ));
      return (h = d.contentDOM) == null || h.setAttribute("data-editable", ""), d;
    },
    toExternalHTML: (i, a) => {
      var s, h;
      const l = ((s = o.options.domAttributes) == null ? void 0 : s.blockContent) || {}, u = r.toExternalHTML || r.render, d = He((x) => /* @__PURE__ */ n.jsx(
        De,
        {
          blockType: i.type,
          blockProps: i.props,
          propSchema: e.propSchema,
          domAttributes: l,
          children: /* @__PURE__ */ n.jsx(
            u,
            {
              block: i,
              editor: a,
              contentRef: x
            }
          )
        }
      ));
      return (h = d.contentDOM) == null || h.setAttribute("data-editable", ""), d;
    }
  });
}
function Ho(e, r, o, i) {
  return () => (
    // Creates inline content section element
    /* @__PURE__ */ n.jsx(
      Lt,
      {
        as: "span",
        className: "bn-inline-content-section",
        "data-inline-content-type": r,
        ...Object.fromEntries(
          Object.entries(o).filter(([a, l]) => l !== i[a].default).map(([a, l]) => [wt(a), l])
        ),
        children: e
      }
    )
  );
}
function Fo(e, r) {
  const o = Tt({
    name: e.type,
    inline: !0,
    group: "inline",
    selectable: e.content === "styled",
    atom: e.content === "none",
    content: e.content === "styled" ? "inline*" : "",
    addAttributes() {
      return pt(e.propSchema);
    },
    addKeyboardShortcuts() {
      return In(e);
    },
    parseHTML() {
      return On(e);
    },
    renderHTML({ node: i }) {
      const a = this.options.editor, l = bt(
        i,
        a.inlineContentSchema,
        a.styleSchema
      ), u = r.render, d = He((s) => /* @__PURE__ */ n.jsx(u, { inlineContent: l, contentRef: s }));
      return An(
        d,
        e.type,
        i.attrs,
        e.propSchema
      );
    },
    // TODO: needed?
    addNodeView() {
      const i = this.options.editor;
      return (a) => Bt(
        (l) => {
          const u = Pt({}).ref, d = r.render, s = Ho(
            /* @__PURE__ */ n.jsx(
              d,
              {
                contentRef: u,
                inlineContent: bt(
                  l.node,
                  i.inlineContentSchema,
                  i.styleSchema
                )
              }
            ),
            e.type,
            l.node.attrs,
            e.propSchema
          );
          return /* @__PURE__ */ n.jsx(s, {});
        },
        {
          className: "bn-ic-react-node-view-renderer",
          as: "span"
          // contentDOMElementTag: "span", (requires tt upgrade)
        }
      )(a);
    }
  });
  return Fn(e, {
    node: o
  });
}
function zo(e, r) {
  const o = Gn.create({
    name: e.type,
    addAttributes() {
      return zn(e.propSchema);
    },
    parseHTML() {
      return Nn(e);
    },
    renderHTML({ mark: i }) {
      const a = {};
      e.propSchema === "string" && (a.value = i.attrs.stringValue);
      const l = r.render, u = He((d) => /* @__PURE__ */ n.jsx(l, { ...a, contentRef: d }));
      return Zn(
        u,
        e.type,
        i.attrs.stringValue,
        e.propSchema
      );
    }
  });
  return Un(e, {
    mark: o
  });
}
export {
  Kr as AddBlockButton,
  Gr as BlockColorsButton,
  De as BlockContentWrapper,
  Po as BlockNoteView,
  Nr as BlockTypeDropdown,
  dr as ColorStyleButton,
  Rr as CreateLinkButton,
  Qr as DefaultDragHandleMenu,
  Zr as DefaultFormattingToolbar,
  Gt as DefaultImageToolbar,
  no as DefaultSideMenu,
  ao as DefaultSlashMenu,
  xo as DefaultTableHandle,
  eo as DragHandle,
  Xr as DragHandleMenu,
  Qt as DragHandleMenuItem,
  Ur as FormattingToolbarPositioner,
  Wr as HyperlinkToolbarPositioner,
  Mr as ImageCaptionButton,
  Yr as ImageToolbarPositioner,
  Er as NestBlockButton,
  Jr as RemoveBlockButton,
  Lr as ReplaceImageButton,
  to as SideMenu,
  Jt as SideMenuButton,
  ro as SideMenuPositioner,
  io as SlashMenuItem,
  lo as SlashMenuPositioner,
  vo as TableHandlesPositioner,
  _e as TextAlignButton,
  je as ToggledStyleButton,
  $e as Toolbar,
  F as ToolbarButton,
  Fr as ToolbarDropdown,
  Vr as UnnestBlockButton,
  xt as applyBlockNoteCSSVariablesFromTheme,
  Ao as createReactBlockSpec,
  Fo as createReactInlineContentSpec,
  zo as createReactStyleSpec,
  _o as darkDefaultTheme,
  zr as defaultBlockTypeDropdownItems,
  j as defaultColorScheme,
  Co as getDefaultReactSlashMenuItems,
  St as lightDefaultTheme,
  Ho as reactWrapInInlineContentStructure,
  or as removeBlockNoteCSSVariables,
  Do as useActiveStyles,
  Io as useBlockNote,
  G as useEditorChange,
  Dt as useEditorContentChange,
  Oo as useEditorForceUpdate,
  It as useEditorSelectionChange,
  ee as useSelectedBlocks
};
//# sourceMappingURL=blocknote-react.js.map
