(function(g,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("@floating-ui/react"),require("@blocknote/core"),require("react-dom"),require("@tiptap/react")):typeof define=="function"&&define.amd?define(["exports","react","@floating-ui/react","@blocknote/core","react-dom","@tiptap/react"],c):(g=typeof globalThis<"u"?globalThis:g||self,c(g["blocknote-react"]={},g.React,g.react,g.core,g.ReactDOM,g.react$1))})(this,function(g,c,D,p,te,q){"use strict";const et=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},Z=et(c),Jn=et(te),_e=c.createContext(void 0);function W(e){return c.useContext(_e)}var Be={exports:{}},ne={};/**
 * @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 tt;function Qn(){if(tt)return ne;tt=1;var e=Z.default,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(d,f,u){var b,h={},k=null,y=null;u!==void 0&&(k=""+u),f.key!==void 0&&(k=""+f.key),f.ref!==void 0&&(y=f.ref);for(b in f)o.call(f,b)&&!a.hasOwnProperty(b)&&(h[b]=f[b]);if(d&&d.defaultProps)for(b in f=d.defaultProps,f)h[b]===void 0&&(h[b]=f[b]);return{$$typeof:t,type:d,key:k,ref:y,props:h,_owner:i.current}}return ne.Fragment=n,ne.jsx=s,ne.jsxs=s,ne}var oe={};/**
 * @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 nt;function eo(){return nt||(nt=1,process.env.NODE_ENV!=="production"&&function(){var e=Z.default,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),B=Symbol.iterator,L="@@iterator";function T(l){if(l===null||typeof l!="object")return null;var m=B&&l[B]||l[L];return typeof m=="function"?m:null}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function F(l){{for(var m=arguments.length,C=new Array(m>1?m-1:0),v=1;v<m;v++)C[v-1]=arguments[v];$("error",l,C)}}function $(l,m,C){{var v=E.ReactDebugCurrentFrame,_=v.getStackAddendum();_!==""&&(m+="%s",C=C.concat([_]));var V=C.map(function(M){return String(M)});V.unshift("Warning: "+m),Function.prototype.apply.call(console[l],console,V)}}var Ae=!1,Re=!1,Se=!1,Ze=!1,We=!1,we;we=Symbol.for("react.module.reference");function Ue(l){return!!(typeof l=="string"||typeof l=="function"||l===o||l===a||We||l===i||l===u||l===b||Ze||l===y||Ae||Re||Se||typeof l=="object"&&l!==null&&(l.$$typeof===k||l.$$typeof===h||l.$$typeof===s||l.$$typeof===d||l.$$typeof===f||l.$$typeof===we||l.getModuleId!==void 0))}function ir(l,m,C){var v=l.displayName;if(v)return v;var _=m.displayName||m.name||"";return _!==""?C+"("+_+")":C}function _n(l){return l.displayName||"Context"}function U(l){if(l==null)return null;if(typeof l.tag=="number"&&F("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case o:return"Fragment";case n:return"Portal";case a:return"Profiler";case i:return"StrictMode";case u:return"Suspense";case b:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case d:var m=l;return _n(m)+".Consumer";case s:var C=l;return _n(C._context)+".Provider";case f:return ir(l,l.render,"ForwardRef");case h:var v=l.displayName||null;return v!==null?v:U(l.type)||"Memo";case k:{var _=l,V=_._payload,M=_._init;try{return U(M(V))}catch{return null}}}return null}var Y=Object.assign,ce=0,Bn,Tn,Vn,Ln,Pn,Fn,In;function Dn(){}Dn.__reactDisabledLog=!0;function ar(){{if(ce===0){Bn=console.log,Tn=console.info,Vn=console.warn,Ln=console.error,Pn=console.group,Fn=console.groupCollapsed,In=console.groupEnd;var l={configurable:!0,enumerable:!0,value:Dn,writable:!0};Object.defineProperties(console,{info:l,log:l,warn:l,error:l,group:l,groupCollapsed:l,groupEnd:l})}ce++}}function sr(){{if(ce--,ce===0){var l={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Y({},l,{value:Bn}),info:Y({},l,{value:Tn}),warn:Y({},l,{value:Vn}),error:Y({},l,{value:Ln}),group:Y({},l,{value:Pn}),groupCollapsed:Y({},l,{value:Fn}),groupEnd:Y({},l,{value:In})})}ce<0&&F("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ze=E.ReactCurrentDispatcher,Ge;function je(l,m,C){{if(Ge===void 0)try{throw Error()}catch(_){var v=_.stack.trim().match(/\n( *(at )?)/);Ge=v&&v[1]||""}return`
`+Ge+l}}var qe=!1,Me;{var cr=typeof WeakMap=="function"?WeakMap:Map;Me=new cr}function Nn(l,m){if(!l||qe)return"";{var C=Me.get(l);if(C!==void 0)return C}var v;qe=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var V;V=ze.current,ze.current=null,ar();try{if(m){var M=function(){throw Error()};if(Object.defineProperty(M.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(M,[])}catch(A){v=A}Reflect.construct(l,[],M)}else{try{M.call()}catch(A){v=A}l.call(M.prototype)}}else{try{throw Error()}catch(A){v=A}l()}}catch(A){if(A&&v&&typeof A.stack=="string"){for(var w=A.stack.split(`
`),N=v.stack.split(`
`),P=w.length-1,I=N.length-1;P>=1&&I>=0&&w[P]!==N[I];)I--;for(;P>=1&&I>=0;P--,I--)if(w[P]!==N[I]){if(P!==1||I!==1)do if(P--,I--,I<0||w[P]!==N[I]){var R=`
`+w[P].replace(" at new "," at ");return l.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",l.displayName)),typeof l=="function"&&Me.set(l,R),R}while(P>=1&&I>=0);break}}}finally{qe=!1,ze.current=V,sr(),Error.prepareStackTrace=_}var ee=l?l.displayName||l.name:"",X=ee?je(ee):"";return typeof l=="function"&&Me.set(l,X),X}function ur(l,m,C){return Nn(l,!1)}function dr(l){var m=l.prototype;return!!(m&&m.isReactComponent)}function He(l,m,C){if(l==null)return"";if(typeof l=="function")return Nn(l,dr(l));if(typeof l=="string")return je(l);switch(l){case u:return je("Suspense");case b:return je("SuspenseList")}if(typeof l=="object")switch(l.$$typeof){case f:return ur(l.render);case h:return He(l.type,m,C);case k:{var v=l,_=v._payload,V=v._init;try{return He(V(_),m,C)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,On={},An=E.ReactDebugCurrentFrame;function Ee(l){if(l){var m=l._owner,C=He(l.type,l._source,m?m.type:null);An.setExtraStackFrame(C)}else An.setExtraStackFrame(null)}function fr(l,m,C,v,_){{var V=Function.call.bind(ue);for(var M in l)if(V(l,M)){var w=void 0;try{if(typeof l[M]!="function"){var N=Error((v||"React class")+": "+C+" type `"+M+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[M]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}w=l[M](m,M,v,C,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(P){w=P}w&&!(w instanceof Error)&&(Ee(_),F("%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).",v||"React class",C,M,typeof w),Ee(null)),w instanceof Error&&!(w.message in On)&&(On[w.message]=!0,Ee(_),F("Failed %s type: %s",C,w.message),Ee(null))}}}var gr=Array.isArray;function Ke(l){return gr(l)}function mr(l){{var m=typeof Symbol=="function"&&Symbol.toStringTag,C=m&&l[Symbol.toStringTag]||l.constructor.name||"Object";return C}}function hr(l){try{return Rn(l),!1}catch{return!0}}function Rn(l){return""+l}function Zn(l){if(hr(l))return F("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",mr(l)),Rn(l)}var de=E.ReactCurrentOwner,br={key:!0,ref:!0,__self:!0,__source:!0},Wn,Un,$e;$e={};function kr(l){if(ue.call(l,"ref")){var m=Object.getOwnPropertyDescriptor(l,"ref").get;if(m&&m.isReactWarning)return!1}return l.ref!==void 0}function Cr(l){if(ue.call(l,"key")){var m=Object.getOwnPropertyDescriptor(l,"key").get;if(m&&m.isReactWarning)return!1}return l.key!==void 0}function pr(l,m){if(typeof l.ref=="string"&&de.current&&m&&de.current.stateNode!==m){var C=U(de.current.type);$e[C]||(F('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',U(de.current.type),l.ref),$e[C]=!0)}}function vr(l,m){{var C=function(){Wn||(Wn=!0,F("%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)",m))};C.isReactWarning=!0,Object.defineProperty(l,"key",{get:C,configurable:!0})}}function xr(l,m){{var C=function(){Un||(Un=!0,F("%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)",m))};C.isReactWarning=!0,Object.defineProperty(l,"ref",{get:C,configurable:!0})}}var yr=function(l,m,C,v,_,V,M){var w={$$typeof:t,type:l,key:m,ref:C,props:M,_owner:V};return w._store={},Object.defineProperty(w._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(w,"_self",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.defineProperty(w,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_}),Object.freeze&&(Object.freeze(w.props),Object.freeze(w)),w};function Sr(l,m,C,v,_){{var V,M={},w=null,N=null;C!==void 0&&(Zn(C),w=""+C),Cr(m)&&(Zn(m.key),w=""+m.key),kr(m)&&(N=m.ref,pr(m,_));for(V in m)ue.call(m,V)&&!br.hasOwnProperty(V)&&(M[V]=m[V]);if(l&&l.defaultProps){var P=l.defaultProps;for(V in P)M[V]===void 0&&(M[V]=P[V])}if(w||N){var I=typeof l=="function"?l.displayName||l.name||"Unknown":l;w&&vr(M,I),N&&xr(M,I)}return yr(l,w,N,_,v,de.current,M)}}var Ye=E.ReactCurrentOwner,zn=E.ReactDebugCurrentFrame;function Q(l){if(l){var m=l._owner,C=He(l.type,l._source,m?m.type:null);zn.setExtraStackFrame(C)}else zn.setExtraStackFrame(null)}var Xe;Xe=!1;function Je(l){return typeof l=="object"&&l!==null&&l.$$typeof===t}function Gn(){{if(Ye.current){var l=U(Ye.current.type);if(l)return`

Check the render method of \``+l+"`."}return""}}function wr(l){return""}var qn={};function jr(l){{var m=Gn();if(!m){var C=typeof l=="string"?l:l.displayName||l.name;C&&(m=`

Check the top-level render call using <`+C+">.")}return m}}function Kn(l,m){{if(!l._store||l._store.validated||l.key!=null)return;l._store.validated=!0;var C=jr(m);if(qn[C])return;qn[C]=!0;var v="";l&&l._owner&&l._owner!==Ye.current&&(v=" It was passed a child from "+U(l._owner.type)+"."),Q(l),F('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',C,v),Q(null)}}function $n(l,m){{if(typeof l!="object")return;if(Ke(l))for(var C=0;C<l.length;C++){var v=l[C];Je(v)&&Kn(v,m)}else if(Je(l))l._store&&(l._store.validated=!0);else if(l){var _=T(l);if(typeof _=="function"&&_!==l.entries)for(var V=_.call(l),M;!(M=V.next()).done;)Je(M.value)&&Kn(M.value,m)}}}function Mr(l){{var m=l.type;if(m==null||typeof m=="string")return;var C;if(typeof m=="function")C=m.propTypes;else if(typeof m=="object"&&(m.$$typeof===f||m.$$typeof===h))C=m.propTypes;else return;if(C){var v=U(m);fr(C,l.props,"prop",v,l)}else if(m.PropTypes!==void 0&&!Xe){Xe=!0;var _=U(m);F("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_||"Unknown")}typeof m.getDefaultProps=="function"&&!m.getDefaultProps.isReactClassApproved&&F("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Hr(l){{for(var m=Object.keys(l.props),C=0;C<m.length;C++){var v=m[C];if(v!=="children"&&v!=="key"){Q(l),F("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),Q(null);break}}l.ref!==null&&(Q(l),F("Invalid attribute `ref` supplied to `React.Fragment`."),Q(null))}}var Yn={};function Xn(l,m,C,v,_,V){{var M=Ue(l);if(!M){var w="";(l===void 0||typeof l=="object"&&l!==null&&Object.keys(l).length===0)&&(w+=" 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 N=wr();N?w+=N:w+=Gn();var P;l===null?P="null":Ke(l)?P="array":l!==void 0&&l.$$typeof===t?(P="<"+(U(l.type)||"Unknown")+" />",w=" Did you accidentally export a JSX literal instead of a component?"):P=typeof l,F("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",P,w)}var I=Sr(l,m,C,_,V);if(I==null)return I;if(M){var R=m.children;if(R!==void 0)if(v)if(Ke(R)){for(var ee=0;ee<R.length;ee++)$n(R[ee],l);Object.freeze&&Object.freeze(R)}else F("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 $n(R,l)}if(ue.call(m,"key")){var X=U(l),A=Object.keys(m).filter(function(Lr){return Lr!=="key"}),Qe=A.length>0?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}";if(!Yn[X+Qe]){var Vr=A.length>0?"{"+A.join(": ..., ")+": ...}":"{}";F(`A props object containing a "key" prop is being spread into JSX:
  let props = %s;
  <%s {...props} />
React keys must be passed directly to JSX without using spread:
  let props = %s;
  <%s key={someKey} {...props} />`,Qe,X,Vr,X),Yn[X+Qe]=!0}}return l===o?Hr(I):Mr(I),I}}function Er(l,m,C){return Xn(l,m,C,!0)}function _r(l,m,C){return Xn(l,m,C,!1)}var Br=_r,Tr=Er;oe.Fragment=o,oe.jsx=Br,oe.jsxs=Tr}()),oe}process.env.NODE_ENV==="production"?Be.exports=Qn():Be.exports=eo();var r=Be.exports;function j(e){const t=W();if(!(t!=null&&t.editor))throw new Error("useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component");return t.editor}function fe(e,t){const n=W();t||(t=n==null?void 0:n.editor),c.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onChange(e)},[e,t])}function ge(e,t){const n=W();t||(t=n==null?void 0:n.editor),c.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onSelectionChange(e)},[e,t])}function z(e,t){fe(e,t),ge(e,t)}function J(e,t,n,o){const{refs:i,update:a,context:s,floatingStyles:d}=D.useFloating({open:e,...o}),{isMounted:f,styles:u}=D.useTransitionStyles(s),b=D.useDismiss(s),{getReferenceProps:h,getFloatingProps:k}=D.useInteractions([b]);return c.useEffect(()=>{a()},[t,a]),c.useEffect(()=>{t!==null&&i.setReference({getBoundingClientRect:()=>t})},[t,i]),c.useMemo(()=>({isMounted:f,ref:i.setFloating,style:{display:"flex",...u,...d,zIndex:n},getFloatingProps:k,getReferenceProps:h}),[d,f,i.setFloating,u,n,k,h])}function K(e){const[t,n]=c.useState();return c.useEffect(()=>e(o=>{n({...o})}),[e]),t}function ot(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}const rt=c.createContext(void 0);function x(){return c.useContext(rt)}var lt={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},it=Z.default.createContext&&Z.default.createContext(lt),to=["attr","size","title"];function no(e,t){if(e==null)return{};var n=oo(e,t),o,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)o=a[i],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}function oo(e,t){if(e==null)return{};var n={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){if(t.indexOf(o)>=0)continue;n[o]=e[o]}return n}function me(){return me=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},me.apply(this,arguments)}function at(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,o)}return n}function he(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?at(Object(n),!0).forEach(function(o){ro(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):at(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function ro(e,t,n){return t=lo(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lo(e){var t=io(e,"string");return typeof t=="symbol"?t:t+""}function io(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var o=n.call(e,t||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function st(e){return e&&e.map((t,n)=>Z.default.createElement(t.tag,he({key:n},t.attr),st(t.child)))}function S(e){return t=>Z.default.createElement(ao,me({attr:he({},e.attr)},t),st(e.child))}function ao(e){var t=n=>{var{attr:o,size:i,title:a}=e,s=no(e,to),d=i||n.size||"1em",f;return n.className&&(f=n.className),e.className&&(f=(f?f+" ":"")+e.className),Z.default.createElement("svg",me({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,o,s,{className:f,style:he(he({color:e.color||n.color},n.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),a&&Z.default.createElement("title",null,a),e.children)};return it!==void 0?Z.default.createElement(it.Consumer,null,n=>t(n)):t(lt)}function so(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z"},child:[]}]})(e)}function be(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"},child:[]}]})(e)}function co(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z"},child:[]}]})(e)}function uo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z"},child:[]}]})(e)}function fo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z"},child:[]}]})(e)}function go(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z"},child:[]}]})(e)}function mo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function ct(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z"},child:[]}]})(e)}function ut(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z"},child:[]}]})(e)}function dt(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function ft(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function ho(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z"},child:[]}]})(e)}function bo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z"},child:[]}]})(e)}function gt(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z"},child:[]}]})(e)}function ko(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z"},child:[]}]})(e)}function Co(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function mt(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z"},child:[]}]})(e)}function ht(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z"},child:[]}]})(e)}function bt(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z"},child:[]}]})(e)}function kt(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function po(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function vo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function Te(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"},child:[]}]})(e)}function xo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function yo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"},child:[]}]})(e)}function Ct(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function So(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z"},child:[]}]})(e)}function wo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function jo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 3.9934C3 3.44476 3.44495 3 3.9934 3H20.0066C20.5552 3 21 3.44495 21 3.9934V20.0066C21 20.5552 20.5551 21 20.0066 21H3.9934C3.44476 21 3 20.5551 3 20.0066V3.9934ZM10.6219 8.41459C10.5562 8.37078 10.479 8.34741 10.4 8.34741C10.1791 8.34741 10 8.52649 10 8.74741V15.2526C10 15.3316 10.0234 15.4088 10.0672 15.4745C10.1897 15.6583 10.4381 15.708 10.6219 15.5854L15.5008 12.3328C15.5447 12.3035 15.5824 12.2658 15.6117 12.2219C15.7343 12.0381 15.6846 11.7897 15.5008 11.6672L10.6219 8.41459Z"},child:[]}]})(e)}function pt(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"},child:[]}]})(e)}function Mo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z"},child:[]}]})(e)}function Ho(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z"},child:[]}]})(e)}function Eo(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},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"},child:[]}]})(e)}function _o(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z"},child:[]}]})(e)}function O(e){const t=W();if(e||(e=t==null?void 0:t.editor),!e)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");const n=e,[o,i]=c.useState(()=>{var a;return((a=n.getSelection())==null?void 0:a.blocks)||[n.getTextCursorPosition().block]});return z(()=>{var a;return i(((a=n.getSelection())==null?void 0:a.blocks)||[n.getTextCursorPosition().block])},n),o}function H(){return W().editor.dictionary}const Bo={bold:mo,italic:ko,underline:xo,strike:po,code:so};function To(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema==="boolean"}const re=e=>{const t=H(),n=x(),o=j(),i=To(e.basicTextStyle,o),a=O(o),[s,d]=c.useState(e.basicTextStyle in o.getActiveStyles());z(()=>{i&&d(e.basicTextStyle in o.getActiveStyles())},o);const f=h=>{if(o.focus(),!!i){if(o.schema.styleSchema[h].propSchema!=="boolean")throw new Error("can only toggle boolean styles");o.toggleStyles({[h]:!0})}};if(!c.useMemo(()=>i?!!a.find(h=>h.content!==void 0):!1,[i,a])||!o.isEditable)return null;const b=Bo[e.basicTextStyle];return r.jsx(n.FormattingToolbar.Button,{className:"bn-button","data-test":e.basicTextStyle,onClick:()=>f(e.basicTextStyle),isSelected:s,label:t.formatting_toolbar[e.basicTextStyle].tooltip,mainTooltip:t.formatting_toolbar[e.basicTextStyle].tooltip,secondaryTooltip:p.formatKeyboardShortcut(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,t.generic.ctrl_shortcut),icon:r.jsx(b,{})})},Ve=e=>{const t=e.textColor||"default",n=e.backgroundColor||"default",o=e.size||16,i=c.useMemo(()=>({pointerEvents:"none",fontSize:(o*.75).toString()+"px",height:o.toString()+"px",lineHeight:o.toString()+"px",textAlign:"center",width:o.toString()+"px"}),[o]);return r.jsx("div",{className:"bn-color-icon","data-background-color":n,"data-text-color":t,style:i,children:"A"})},vt=["default","gray","brown","red","orange","yellow","green","blue","purple","pink"],xt=e=>{const t=x(),n=H(),o=()=>e.text?r.jsxs(r.Fragment,{children:[r.jsx(t.Generic.Menu.Label,{children:n.color_picker.text_title}),vt.map(a=>r.jsx(t.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.text.setColor(a)},"data-test":"text-color-"+a,icon:r.jsx(Ve,{textColor:a,size:e.iconSize}),checked:e.text.color===a,children:n.color_picker.colors[a]},"text-color-"+a))]}):null,i=()=>e.background?r.jsxs(r.Fragment,{children:[r.jsx(t.Generic.Menu.Label,{children:n.color_picker.background_title}),vt.map(a=>r.jsx(t.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.background.setColor(a)},"data-test":"background-color-"+a,icon:r.jsx(Ve,{backgroundColor:a,size:e.iconSize}),checked:e.background.color===a,children:n.color_picker.colors[a]},"background-color-"+a))]}):null;return r.jsxs(r.Fragment,{children:[r.jsx(o,{}),r.jsx(i,{})]})};function yt(e,t){return`${e}Color`in t.schema.styleSchema&&t.schema.styleSchema[`${e}Color`].type===`${e}Color`&&t.schema.styleSchema[`${e}Color`].propSchema==="string"}const St=()=>{const e=x(),t=H(),n=j(),o=yt("text",n),i=yt("background",n),a=O(n),[s,d]=c.useState(o&&n.getActiveStyles().textColor||"default"),[f,u]=c.useState(i&&n.getActiveStyles().backgroundColor||"default");z(()=>{o&&d(n.getActiveStyles().textColor||"default"),i&&u(n.getActiveStyles().backgroundColor||"default")},n);const b=c.useCallback(y=>{if(!o)throw Error("Tried to set text color, but style does not exist in editor schema.");y==="default"?n.removeStyles({textColor:y}):n.addStyles({textColor:y}),setTimeout(()=>{n.focus()})},[n,o]),h=c.useCallback(y=>{if(!i)throw Error("Tried to set background color, but style does not exist in editor schema.");y==="default"?n.removeStyles({backgroundColor:y}):n.addStyles({backgroundColor:y}),setTimeout(()=>{n.focus()})},[i,n]);return!c.useMemo(()=>{if(!o&&!i)return!1;for(const y of a)if(y.content!==void 0)return!0;return!1},[i,a,o])||!n.isEditable?null:r.jsxs(e.Generic.Menu.Root,{children:[r.jsx(e.Generic.Menu.Trigger,{children:r.jsx(e.FormattingToolbar.Button,{className:"bn-button","data-test":"colors",label:t.formatting_toolbar.colors.tooltip,mainTooltip:t.formatting_toolbar.colors.tooltip,icon:r.jsx(Ve,{textColor:s,backgroundColor:f,size:20})})}),r.jsx(e.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-color-picker-dropdown",children:r.jsx(xt,{text:o?{color:s,setColor:b}:void 0,background:i?{color:f,setColor:h}:void 0})})]})},Le=e=>{const t=x(),n=H(),{url:o,text:i,editLink:a}=e,[s,d]=c.useState(o),[f,u]=c.useState(i);c.useEffect(()=>{d(o),u(i)},[i,o]);const b=c.useCallback(B=>{B.key==="Enter"&&(B.preventDefault(),a(s,f))},[a,s,f]),h=c.useCallback(B=>d(B.currentTarget.value),[]),k=c.useCallback(B=>u(B.currentTarget.value),[]),y=c.useCallback(()=>a(s,f),[a,s,f]);return r.jsxs(t.Generic.Form.Root,{children:[r.jsx(t.Generic.Form.TextInput,{className:"bn-text-input",name:"url",icon:r.jsx(mt,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:s,onKeyDown:b,onChange:h,onSubmit:y}),r.jsx(t.Generic.Form.TextInput,{className:"bn-text-input",name:"title",icon:r.jsx(Te,{}),placeholder:n.link_toolbar.form.title_placeholder,value:f,onKeyDown:b,onChange:k,onSubmit:y})]})};function Vo(e){return"link"in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link==="link"}const wt=()=>{const e=j(),t=x(),n=H(),o=Vo(e),i=O(e),[a,s]=c.useState(e.getSelectedLinkUrl()||""),[d,f]=c.useState(e.getSelectedText());z(()=>{f(e.getSelectedText()||""),s(e.getSelectedLinkUrl()||"")},e);const u=c.useCallback((h,k)=>{e.createLink(h,k),e.focus()},[e]);return!c.useMemo(()=>{if(!o)return!1;for(const h of i)if(h.content===void 0)return!1;return!0},[o,i])||!("link"in e.schema.inlineContentSchema)||!e.isEditable?null:r.jsxs(t.Generic.Popover.Root,{children:[r.jsx(t.Generic.Popover.Trigger,{children:r.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"createLink",label:n.formatting_toolbar.link.tooltip,mainTooltip:n.formatting_toolbar.link.tooltip,secondaryTooltip:p.formatKeyboardShortcut(n.formatting_toolbar.link.secondary_tooltip,n.generic.ctrl_shortcut),icon:r.jsx(mt,{})})}),r.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(Le,{url:a,text:d,editLink:u})})]})},jt=()=>{const e=H(),t=x(),n=j(),[o,i]=c.useState(),a=O(n),s=c.useMemo(()=>{if(a.length!==1)return;const u=a[0];if(p.checkBlockIsFileBlock(u,n))return i(u.props.caption),u},[n,a]),d=c.useCallback(u=>{s&&u.key==="Enter"&&(u.preventDefault(),n.updateBlock(s,{props:{caption:o}}))},[o,n,s]),f=c.useCallback(u=>i(u.currentTarget.value),[]);return!s||p.checkBlockIsFileBlockWithPlaceholder(s,n)||!n.isEditable?null:r.jsxs(t.Generic.Popover.Root,{children:[r.jsx(t.Generic.Popover.Trigger,{children:r.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_caption.tooltip,mainTooltip:e.formatting_toolbar.file_caption.tooltip,icon:r.jsx(gt,{}),isSelected:s.props.caption!==""})}),r.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(t.Generic.Form.Root,{children:r.jsx(t.Generic.Form.TextInput,{name:"file-caption",icon:r.jsx(gt,{}),value:o||"",autoFocus:!0,placeholder:e.formatting_toolbar.file_caption.input_placeholder,onKeyDown:d,onChange:f})})})]})},Mt=()=>{const e=H(),t=x(),n=j(),o=O(n),[i,a]=c.useState(()=>n.canNestBlock());z(()=>{a(n.canNestBlock())},n);const s=c.useCallback(()=>{n.focus(),n.nestBlock()},[n]);return!c.useMemo(()=>!o.find(f=>n.schema.blockSchema[f.type].content!=="inline"),[n.schema.blockSchema,o])||!n.isEditable?null:r.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"nestBlock",onClick:s,isDisabled:!i,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:p.formatKeyboardShortcut(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:r.jsx(bo,{})})},Ht=()=>{const e=H(),t=x(),n=j(),o=O(n),[i,a]=c.useState(()=>n.canUnnestBlock());z(()=>{a(n.canUnnestBlock())},n);const s=c.useCallback(()=>{n.focus(),n.unnestBlock()},[n]);return!c.useMemo(()=>!o.find(f=>n.schema.blockSchema[f.type].content!=="inline"),[n.schema.blockSchema,o])||!n.isEditable?null:r.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"unnestBlock",onClick:s,isDisabled:!i,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:p.formatKeyboardShortcut(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:r.jsx(ho,{})})},Et=e=>{const t=x(),n=H(),{block:o}=e,i=j(),[a,s]=c.useState(""),d=c.useCallback(b=>{s(b.currentTarget.value)},[]),f=c.useCallback(b=>{b.key==="Enter"&&(b.preventDefault(),i.updateBlock(o,{props:{name:p.filenameFromURL(a),url:a}}))},[i,o,a]),u=c.useCallback(()=>{i.updateBlock(o,{props:{name:p.filenameFromURL(a),url:a}})},[i,o,a]);return r.jsxs(t.FilePanel.TabPanel,{className:"bn-tab-panel",children:[r.jsx(t.FilePanel.TextInput,{className:"bn-text-input",placeholder:n.file_panel.embed.url_placeholder,value:a,onChange:d,onKeyDown:f,"data-test":"embed-input"}),r.jsx(t.FilePanel.Button,{className:"bn-button",onClick:u,"data-test":"embed-input-button",children:n.file_panel.embed.embed_button[o.type]||n.file_panel.embed.embed_button.file})]})},_t=e=>{var h;const t=x(),n=H(),{block:o,setLoading:i}=e,a=j(),[s,d]=c.useState(!1);c.useEffect(()=>{s&&setTimeout(()=>{d(!1)},3e3)},[s]);const f=c.useCallback(k=>{if(k===null)return;async function y(B){if(i(!0),a.uploadFile!==void 0)try{let L=await a.uploadFile(B);typeof L=="string"&&(L={props:{name:B.name,url:L}}),a.updateBlock(o,L)}catch{d(!0)}finally{i(!1)}}y(k)},[o,a,i]),u=a.schema.blockSchema[o.type],b=u.isFileBlock&&((h=u.fileBlockAcceptMimeTypes)!=null&&h.length)?u.fileBlockAcceptMimeTypes.join(","):"*/*";return r.jsxs(t.FilePanel.TabPanel,{className:"bn-tab-panel",children:[r.jsx(t.FilePanel.FileInput,{className:"bn-file-input","data-test":"upload-input",accept:b,placeholder:n.file_panel.upload.file_placeholder[o.type]||n.file_panel.upload.file_placeholder.file,value:null,onChange:f}),s&&r.jsx("div",{className:"bn-error-text",children:n.file_panel.upload.upload_error})]})},Pe=e=>{const t=x(),n=H(),o=j(),[i,a]=c.useState(!1),s=e.tabs??[...o.uploadFile!==void 0?[{name:n.file_panel.upload.title,tabPanel:r.jsx(_t,{block:e.block,setLoading:a})}]:[],{name:n.file_panel.embed.title,tabPanel:r.jsx(Et,{block:e.block})}],[d,f]=c.useState(e.defaultOpenTab||s[0].name);return r.jsx(t.FilePanel.Root,{className:"bn-panel",defaultOpenTab:d,openTab:d,setOpenTab:f,tabs:s,loading:i})},Bt=()=>{const e=H(),t=x(),n=j(),o=O(n),[i,a]=c.useState(!1);c.useEffect(()=>{a(!1)},[o]);const s=o.length===1?o[0]:void 0;return s===void 0||!p.checkBlockIsFileBlock(s,n)||!n.isEditable?null:r.jsxs(t.Generic.Popover.Root,{opened:i,position:"bottom",children:[r.jsx(t.Generic.Popover.Trigger,{children:r.jsx(t.FormattingToolbar.Button,{className:"bn-button",onClick:()=>a(!i),isSelected:i,mainTooltip:e.formatting_toolbar.file_replace.tooltip[s.type]||e.formatting_toolbar.file_replace.tooltip.file,label:e.formatting_toolbar.file_replace.tooltip[s.type]||e.formatting_toolbar.file_replace.tooltip.file,icon:r.jsx(wo,{})})}),r.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-panel-popover",variant:"panel-popover",children:r.jsx(Pe,{block:s})})]})},Lo={left:fo,center:co,right:go,justify:uo},ke=e=>{const t=x(),n=H(),o=j(),i=O(o),a=c.useMemo(()=>{const u=i[0];if(p.checkBlockHasDefaultProp("textAlignment",u,o))return u.props.textAlignment},[o,i]),s=c.useCallback(u=>{o.focus();for(const b of i)p.checkBlockTypeHasDefaultProp("textAlignment",b.type,o)&&o.updateBlock(b,{props:{textAlignment:u}})},[o,i]);if(!c.useMemo(()=>!!i.find(u=>"textAlignment"in u.props),[i])||!o.isEditable)return null;const f=Lo[e.textAlignment];return r.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>s(e.textAlignment),isSelected:a===e.textAlignment,label:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:r.jsx(f,{})})},Tt=e=>[{name:e.slash_menu.paragraph.title,type:"paragraph",icon:Te,isSelected:t=>t.type==="paragraph"},{name:e.slash_menu.heading.title,type:"heading",props:{level:1},icon:ut,isSelected:t=>t.type==="heading"&&"level"in t.props&&t.props.level===1},{name:e.slash_menu.heading_2.title,type:"heading",props:{level:2},icon:dt,isSelected:t=>t.type==="heading"&&"level"in t.props&&t.props.level===2},{name:e.slash_menu.heading_3.title,type:"heading",props:{level:3},icon:ft,isSelected:t=>t.type==="heading"&&"level"in t.props&&t.props.level===3},{name:e.slash_menu.bullet_list.title,type:"bulletListItem",icon:kt,isSelected:t=>t.type==="bulletListItem"},{name:e.slash_menu.numbered_list.title,type:"numberedListItem",icon:bt,isSelected:t=>t.type==="numberedListItem"},{name:e.slash_menu.check_list.title,type:"checkListItem",icon:ht,isSelected:t=>t.type==="checkListItem"}],Vt=e=>{const t=x(),n=H(),o=j(),i=O(o),[a,s]=c.useState(o.getTextCursorPosition().block),d=c.useMemo(()=>(e.items||Tt(n)).filter(b=>b.type in o.schema.blockSchema),[o,n,e.items]),f=c.useMemo(()=>d.find(b=>b.type===a.type)!==void 0,[a.type,d]),u=c.useMemo(()=>{const b=h=>{o.focus();for(const k of i)o.updateBlock(k,{type:h.type,props:h.props})};return d.map(h=>{const k=h.icon;return{text:h.name,icon:r.jsx(k,{size:16}),onClick:()=>b(h),isSelected:h.isSelected(a)}})},[a,d,o,i]);return z(()=>{s(o.getTextCursorPosition().block)},o),!f||!o.isEditable?null:r.jsx(t.FormattingToolbar.Select,{className:"bn-select",items:u})},Po=()=>{const e=H(),t=x(),n=j(),[o,i]=c.useState(),a=O(n),s=c.useMemo(()=>{if(a.length!==1)return;const u=a[0];if(p.checkBlockIsFileBlock(u,n))return i(u.props.name),u},[n,a]),d=c.useCallback(u=>{s&&u.key==="Enter"&&(u.preventDefault(),n.updateBlock(s,{props:{name:o}}))},[o,n,s]),f=c.useCallback(u=>i(u.currentTarget.value),[]);return!s||p.checkBlockIsFileBlockWithPlaceholder(s,n)||!n.isEditable?null:r.jsxs(t.Generic.Popover.Root,{children:[r.jsx(t.Generic.Popover.Trigger,{children:r.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_rename.tooltip[s.type]||e.formatting_toolbar.file_rename.tooltip.file,mainTooltip:e.formatting_toolbar.file_rename.tooltip[s.type]||e.formatting_toolbar.file_rename.tooltip.file,icon:r.jsx(ct,{})})}),r.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(t.Generic.Form.Root,{children:r.jsx(t.Generic.Form.TextInput,{name:"file-name",icon:r.jsx(ct,{}),value:o||"",autoFocus:!0,placeholder:e.formatting_toolbar.file_rename.input_placeholder[s.type]||e.formatting_toolbar.file_rename.input_placeholder.file,onKeyDown:d,onChange:f})})})]})},Fo=()=>{const e=H(),t=x(),n=j(),o=O(n),i=c.useMemo(()=>{if(o.length!==1)return;const s=o[0];if(p.checkBlockIsFileBlock(s,n))return s},[n,o]),a=c.useCallback(()=>{i&&i.props.url&&(n.focus(),n.resolveFileUrl(i.props.url).then(s=>window.open(s)))},[n,i]);return!i||p.checkBlockIsFileBlockWithPlaceholder(i,n)?null:r.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_download.tooltip[i.type]||e.formatting_toolbar.file_download.tooltip.file,mainTooltip:e.formatting_toolbar.file_download.tooltip[i.type]||e.formatting_toolbar.file_download.tooltip.file,icon:r.jsx(Ho,{}),onClick:a})},Io=()=>{const e=H(),t=x(),n=j(),o=O(n),i=c.useMemo(()=>{if(o.length!==1)return;const s=o[0];if(p.checkBlockIsFileBlockWithPreview(s,n))return s},[n,o]),a=c.useCallback(()=>{i&&n.updateBlock(i,{props:{showPreview:!i.props.showPreview}})},[n,i]);return!i||p.checkBlockIsFileBlockWithPlaceholder(i,n)||!n.isEditable?null:r.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:"Toggle preview",mainTooltip:e.formatting_toolbar.file_preview_toggle.tooltip,icon:r.jsx(So,{}),isSelected:i.props.showPreview,onClick:a})},Do=()=>{const e=H(),t=x(),n=j(),o=O(n),i=c.useMemo(()=>{if(o.length!==1)return;const s=o[0];if(p.checkBlockIsFileBlock(s,n))return s},[n,o]),a=c.useCallback(()=>{n.focus(),n.removeBlocks([i])},[n,i]);return!i||p.checkBlockIsFileBlockWithPlaceholder(i,n)||!n.isEditable?null:r.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_delete.tooltip[i.type]||e.formatting_toolbar.file_delete.tooltip.file,mainTooltip:e.formatting_toolbar.file_delete.tooltip[i.type]||e.formatting_toolbar.file_delete.tooltip.file,icon:r.jsx(Mo,{}),onClick:a})},Lt=e=>[r.jsx(Vt,{items:e},"blockTypeSelect"),r.jsx(jt,{},"fileCaptionButton"),r.jsx(Bt,{},"replaceFileButton"),r.jsx(Po,{},"fileRenameButton"),r.jsx(Do,{},"fileDeleteButton"),r.jsx(Fo,{},"fileDownloadButton"),r.jsx(Io,{},"filePreviewButton"),r.jsx(re,{basicTextStyle:"bold"},"boldStyleButton"),r.jsx(re,{basicTextStyle:"italic"},"italicStyleButton"),r.jsx(re,{basicTextStyle:"underline"},"underlineStyleButton"),r.jsx(re,{basicTextStyle:"strike"},"strikeStyleButton"),r.jsx(ke,{textAlignment:"left"},"textAlignLeftButton"),r.jsx(ke,{textAlignment:"center"},"textAlignCenterButton"),r.jsx(ke,{textAlignment:"right"},"textAlignRightButton"),r.jsx(St,{},"colorStyleButton"),r.jsx(Mt,{},"nestBlockButton"),r.jsx(Ht,{},"unnestBlockButton"),r.jsx(wt,{},"createLinkButton")],Pt=e=>{const t=x();return r.jsx(t.FormattingToolbar.Root,{className:"bn-toolbar bn-formatting-toolbar",children:e.children||Lt(e.blockTypeSelectItems)})},Ft=e=>{switch(e){case"left":return"top-start";case"center":return"top";case"right":return"top-end";default:return"top-start"}},It=e=>{const t=c.useRef(null),n=j(),[o,i]=c.useState(()=>{const k=n.getTextCursorPosition().block;return"textAlignment"in k.props?Ft(k.props.textAlignment):"top-start"});z(()=>{const k=n.getTextCursorPosition().block;"textAlignment"in k.props?i(Ft(k.props.textAlignment)):i("top-start")},n);const a=K(n.formattingToolbar.onUpdate.bind(n.formattingToolbar)),{isMounted:s,ref:d,style:f,getFloatingProps:u}=J((a==null?void 0:a.show)||!1,(a==null?void 0:a.referencePos)||null,3e3,{placement:o,middleware:[D.offset(10),D.flip()],onOpenChange:(k,y)=>{k||(n.formattingToolbar.closeMenu(),n.focus())}}),b=c.useMemo(()=>ot([t,d]),[t,d]);if(!s||!a)return null;if(!a.show&&t.current)return r.jsx("div",{ref:b,style:f,dangerouslySetInnerHTML:{__html:t.current.innerHTML}});const h=e.formattingToolbar||Pt;return r.jsx("div",{ref:b,style:f,...u(),children:r.jsx(h,{})})},Dt=e=>{const t=x(),n=H();return r.jsx(t.LinkToolbar.Button,{className:"bn-button",label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:e.deleteLink,icon:r.jsx(Co,{})})},Nt=e=>{const t=x(),n=H();return r.jsxs(t.Generic.Popover.Root,{children:[r.jsx(t.Generic.Popover.Trigger,{children:r.jsx(t.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.edit.tooltip,isSelected:!1,children:n.link_toolbar.edit.text})}),r.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(Le,{...e})})]})},Ot=e=>{const t=x(),n=H();return r.jsx(t.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(e.url,"_blank")},icon:r.jsx(Eo,{})})},At=e=>{const t=x();return e.children?r.jsx(t.LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",children:e.children}):r.jsxs(t.LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",onMouseEnter:e.stopHideTimer,onMouseLeave:e.startHideTimer,children:[r.jsx(Nt,{url:e.url,text:e.text,editLink:e.editLink}),r.jsx(Ot,{url:e.url}),r.jsx(Dt,{deleteLink:e.deleteLink})]})},Rt=e=>{const t=j(),n={deleteLink:t.linkToolbar.deleteLink,editLink:t.linkToolbar.editLink,startHideTimer:t.linkToolbar.startHideTimer,stopHideTimer:t.linkToolbar.stopHideTimer},o=K(t.linkToolbar.onUpdate.bind(t.linkToolbar)),{isMounted:i,ref:a,style:s,getFloatingProps:d}=J((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,4e3,{placement:"top-start",middleware:[D.offset(10),D.flip()],onOpenChange:k=>{k||(t.linkToolbar.closeMenu(),t.focus())}});if(!i||!o)return null;const{show:f,referencePos:u,...b}=o,h=e.linkToolbar||At;return r.jsx("div",{ref:a,style:s,...d(),children:r.jsx(h,{...b,...n})})},Zt=e=>{const t=j();if(!t.filePanel)throw new Error("FileToolbarController can only be used when BlockNote editor schema contains file block");const n=K(t.filePanel.onUpdate.bind(t.filePanel)),{isMounted:o,ref:i,style:a,getFloatingProps:s}=J((n==null?void 0:n.show)||!1,(n==null?void 0:n.referencePos)||null,5e3,{placement:"bottom",middleware:[D.offset(10),D.flip()],onOpenChange:h=>{h||(t.filePanel.closeMenu(),t.focus())}});if(!o||!n)return null;const{show:d,referencePos:f,...u}=n,b=e.filePanel||Pe;return r.jsx("div",{ref:i,style:a,...s(),children:r.jsx(b,{...u})})};function No(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"},child:[]},{tag:"path",attr:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z"},child:[]}]})(e)}const Wt=e=>{const t=x(),n=H();return r.jsx(t.SideMenu.Button,{className:"bn-button",label:n.side_menu.add_block_label,icon:r.jsx(No,{size:24,onClick:e.addBlock,"data-test":"dragHandleAdd"})})};function Ut(e){return S({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{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"},child:[]}]})(e)}const zt=e=>{const t=x(),n=j();return!p.checkBlockTypeHasDefaultProp("textColor",e.block.type,n)&&!p.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,n)?null:r.jsxs(t.Generic.Menu.Root,{position:"right",sub:!0,children:[r.jsx(t.Generic.Menu.Trigger,{sub:!0,children:r.jsx(t.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:e.children})}),r.jsx(t.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:r.jsx(xt,{iconSize:18,text:p.checkBlockTypeHasDefaultProp("textColor",e.block.type,n)&&p.checkBlockHasDefaultProp("textColor",e.block,n)?{color:e.block.props.textColor,setColor:o=>n.updateBlock(e.block,{type:e.block.type,props:{textColor:o}})}:void 0,background:p.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,n)&&p.checkBlockHasDefaultProp("backgroundColor",e.block,n)?{color:e.block.props.backgroundColor,setColor:o=>n.updateBlock(e.block,{props:{backgroundColor:o}})}:void 0})})]})},Gt=e=>{const t=x(),n=j();return r.jsx(t.Generic.Menu.Item,{className:"bn-menu-item",onClick:()=>n.removeBlocks([e.block]),children:e.children})},qt=e=>{const t=x(),n=H();return r.jsx(t.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-drag-handle-menu",children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(Gt,{...e,children:n.drag_handle.delete_menuitem}),r.jsx(zt,{...e,children:n.drag_handle.colors_menuitem})]})})},Kt=e=>{const t=x(),n=H(),o=e.dragHandleMenu||qt;return r.jsxs(t.Generic.Menu.Root,{onOpenChange:i=>{i?e.freezeMenu():(e.unfreezeMenu(),e.editor.focus())},position:"left",children:[r.jsx(t.Generic.Menu.Trigger,{children:r.jsx(t.SideMenu.Button,{label:n.side_menu.drag_handle_label,draggable:!0,onDragStart:e.blockDragStart,onDragEnd:e.blockDragEnd,className:"bn-button",icon:r.jsx(Ut,{size:24,"data-test":"dragHandle"})})}),r.jsx(o,{block:e.block})]})},$t=e=>{const t=x(),{addBlock:n,...o}=e,i=c.useMemo(()=>{const a={"data-block-type":e.block.type};return e.block.type==="heading"&&(a["data-level"]=e.block.props.level.toString()),e.editor.schema.blockSchema[e.block.type].isFileBlock&&(e.block.props.url?a["data-url"]="true":a["data-url"]="false"),a},[e.block,e.editor.schema.blockSchema]);return r.jsx(t.SideMenu.Root,{className:"bn-side-menu",...i,children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(Wt,{addBlock:n}),r.jsx(Kt,{...o})]})})},Yt=e=>{const t=j(),n={addBlock:t.sideMenu.addBlock,blockDragStart:t.sideMenu.blockDragStart,blockDragEnd:t.sideMenu.blockDragEnd,freezeMenu:t.sideMenu.freezeMenu,unfreezeMenu:t.sideMenu.unfreezeMenu},o=K(t.sideMenu.onUpdate.bind(t.sideMenu)),{isMounted:i,ref:a,style:s,getFloatingProps:d}=J((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,1e3,{placement:"left-start"});if(!i||!o)return null;const{show:f,referencePos:u,...b}=o,h=e.sideMenu||$t;return r.jsx("div",{ref:a,style:s,...d(),children:r.jsx(h,{...b,...n,editor:t})})};function Oo(e){const t=x(),n=H(),{items:o,loadingState:i,selectedIndex:a,onItemClick:s}=e,d=i==="loading-initial"||i==="loading"?r.jsx(t.SuggestionMenu.Loader,{className:"bn-suggestion-menu-loader",children:n.suggestion_menu.loading}):null,f=c.useMemo(()=>{let u;const b=[];for(let h=0;h<o.length;h++){const k=o[h];k.group!==u&&(u=k.group,b.push(r.jsx(t.SuggestionMenu.Label,{className:"bn-suggestion-menu-label",children:u},u))),b.push(r.jsx(t.SuggestionMenu.Item,{className:"bn-suggestion-menu-item",item:k,id:`bn-suggestion-menu-item-${h}`,isSelected:h===a,onClick:()=>s==null?void 0:s(k)},k.title))}return b},[t,o,s,a]);return r.jsxs(t.SuggestionMenu.Root,{id:"bn-suggestion-menu",className:"bn-suggestion-menu",children:[f,f.length===0&&(e.loadingState==="loading"||e.loadingState==="loaded")&&r.jsx(t.SuggestionMenu.EmptyItem,{className:"bn-suggestion-menu-item",children:n.suggestion_menu.no_items_title}),d]})}function Fe(e,t,n,o=3){const i=c.useRef(0);c.useEffect(()=>{t!==void 0&&(e.length>0?i.current=t.length:t.length-i.current>o&&n())},[n,o,e.length,t])}function Ie(e,t){const[n,o]=c.useState([]),[i,a]=c.useState(!1),s=c.useRef(),d=c.useRef();return c.useEffect(()=>{const f=e;s.current=e,a(!0),t(e).then(u=>{s.current===f&&(o(u),a(!1),d.current=f)})},[e,t]),{items:n||[],usedQuery:d.current,loadingState:d.current===void 0?"loading-initial":i?"loading":"loaded"}}function Xt(e,t,n,o){const[i,a]=c.useState(0);return c.useEffect(()=>{const s=d=>d.key==="ArrowUp"?(d.preventDefault(),n.length&&a((i-1+n.length)%n.length),!0):d.key==="ArrowDown"?(d.preventDefault(),n.length&&a((i+1)%n.length),!0):d.key==="Enter"?(d.preventDefault(),n.length&&(o==null||o(n[i])),!0):!1;return e.domElement.addEventListener("keydown",s,!0),()=>{e.domElement.removeEventListener("keydown",s,!0)}},[e.domElement,n,i,o]),c.useEffect(()=>{a(0)},[t]),{selectedIndex:n.length===0?void 0:i}}function Jt(e){const n=W().setContentEditableProps,o=j(),{getItems:i,suggestionMenuComponent:a,query:s,clearQuery:d,closeMenu:f,onItemClick:u}=e,b=c.useCallback(T=>{f(),d(),u==null||u(T)},[u,f,d]),{items:h,usedQuery:k,loadingState:y}=Ie(s,i);Fe(h,k,f);const{selectedIndex:B}=Xt(o,s,h,b);c.useEffect(()=>(n(T=>({...T,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{n(T=>({...T,"aria-expanded":!1,"aria-controls":void 0}))}),[n]),c.useEffect(()=>(n(T=>({...T,"aria-activedescendant":B?"bn-suggestion-menu-item-"+B:void 0})),()=>{n(T=>({...T,"aria-activedescendant":void 0}))}),[n,B]);const L=a;return r.jsx(L,{items:h,onItemClick:b,loadingState:y,selectedIndex:B})}const Ao={heading:ut,heading_2:dt,heading_3:ft,numbered_list:bt,bullet_list:kt,check_list:ht,paragraph:Te,table:vo,image:Ct,video:yo,audio:pt,file:be,emoji:_o};function Qt(e){return p.getDefaultSlashMenuItems(e).map(t=>{const n=Ao[t.key];return{...t,icon:r.jsx(n,{size:18})}})}function en(e){const t=j(),{triggerCharacter:n,suggestionMenuComponent:o,minQueryLength:i,onItemClick:a,getItems:s}=e,d=c.useMemo(()=>a||(T=>{T.onItemClick(t)}),[t,a]),f=c.useMemo(()=>s||(async T=>p.filterSuggestionItems(Qt(t),T)),[t,s]),u={closeMenu:t.suggestionMenus.closeMenu,clearQuery:t.suggestionMenus.clearQuery},b=c.useCallback(T=>t.suggestionMenus.onUpdate(n,T),[t.suggestionMenus,n]),h=K(b),{isMounted:k,ref:y,style:B,getFloatingProps:L}=J((h==null?void 0:h.show)||!1,(h==null?void 0:h.referencePos)||null,2e3,{placement:"bottom-start",middleware:[D.offset(10),D.flip(),D.size({apply({availableHeight:T,elements:E}){Object.assign(E.floating.style,{height:`${T-10}px`})}})],onOpenChange(T){T||t.suggestionMenus.closeMenu()}});return!k||!h||i&&(h.query.startsWith(" ")||h.query.length<i)?null:r.jsx("div",{ref:y,style:B,...L(),children:r.jsx(Jt,{query:h.query,closeMenu:u.closeMenu,clearQuery:u.clearQuery,getItems:f,suggestionMenuComponent:o||Oo,onItemClick:d})})}async function tn(e,t){return(await p.getDefaultEmojiPickerItems(e,t)).map(({id:n,onItemClick:o})=>({id:n,onItemClick:o,icon:n}))}function Ro(e){const t=x(),n=H(),{items:o,loadingState:i,selectedIndex:a,onItemClick:s,columns:d}=e,f=i==="loading-initial"||i==="loading"?r.jsx(t.GridSuggestionMenu.Loader,{className:"bn-grid-suggestion-menu-loader",columns:d,children:n.suggestion_menu.loading}):null,u=c.useMemo(()=>{const b=[];for(let h=0;h<o.length;h++){const k=o[h];b.push(r.jsx(t.GridSuggestionMenu.Item,{className:"bn-grid-suggestion-menu-item",item:k,id:`bn-grid-suggestion-menu-item-${h}`,isSelected:h===a,onClick:()=>s==null?void 0:s(k)},k.id))}return b},[t,o,s,a]);return r.jsxs(t.GridSuggestionMenu.Root,{id:"bn-grid-suggestion-menu",columns:d,className:"bn-grid-suggestion-menu",children:[f,u,u.length===0&&e.loadingState==="loaded"&&r.jsx(t.GridSuggestionMenu.EmptyItem,{className:"bn-grid-suggestion-menu-empty-item",columns:d,children:n.suggestion_menu.no_items_title})]})}function nn(e,t,n,o,i){const[a,s]=c.useState(0),d=o!==void 0&&o>1;return c.useEffect(()=>{const f=u=>(u.key==="ArrowLeft"&&(u.preventDefault(),n.length&&s((a-1+n.length)%n.length)),u.key==="ArrowRight"&&(u.preventDefault(),n.length&&s((a+1+n.length)%n.length)),u.key==="ArrowUp"?(u.preventDefault(),n.length&&s((a-o+n.length)%n.length),!0):u.key==="ArrowDown"?(u.preventDefault(),n.length&&s((a+o)%n.length),!0):u.key==="Enter"?(u.preventDefault(),n.length&&(i==null||i(n[a])),!0):!1);return e.domElement.addEventListener("keydown",f,!0),()=>{e.domElement.removeEventListener("keydown",f,!0)}},[e.domElement,n,a,i,o,d]),c.useEffect(()=>{s(0)},[t]),{selectedIndex:n.length===0?void 0:a}}function on(e){const n=W().setContentEditableProps,o=j(),{getItems:i,gridSuggestionMenuComponent:a,query:s,clearQuery:d,closeMenu:f,onItemClick:u,columns:b}=e,h=c.useCallback(E=>{f(),d(),u==null||u(E)},[u,f,d]),{items:k,usedQuery:y,loadingState:B}=Ie(s,i);Fe(k,y,f);const{selectedIndex:L}=nn(o,s,k,b,h);c.useEffect(()=>(n(E=>({...E,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{n(E=>({...E,"aria-expanded":!1,"aria-controls":void 0}))}),[n]),c.useEffect(()=>(n(E=>({...E,"aria-activedescendant":L?"bn-suggestion-menu-item-"+L:void 0})),()=>{n(E=>({...E,"aria-activedescendant":void 0}))}),[n,L]);const T=a;return r.jsx(T,{items:k,onItemClick:h,loadingState:B,selectedIndex:L,columns:b})}function rn(e){const t=j(),{triggerCharacter:n,gridSuggestionMenuComponent:o,columns:i,minQueryLength:a,onItemClick:s,getItems:d}=e,f=c.useMemo(()=>s||(E=>{E.onItemClick(t)}),[t,s]),u=c.useMemo(()=>d||(async E=>await tn(t,E)),[t,d]),b={closeMenu:t.suggestionMenus.closeMenu,clearQuery:t.suggestionMenus.clearQuery},h=c.useCallback(E=>t.suggestionMenus.onUpdate(n,E),[t.suggestionMenus,n]),k=K(h),{isMounted:y,ref:B,style:L,getFloatingProps:T}=J((k==null?void 0:k.show)||!1,(k==null?void 0:k.referencePos)||null,2e3,{placement:"bottom-start",middleware:[D.offset(10),D.flip(),D.size({apply({availableHeight:E,elements:F}){Object.assign(F.floating.style,{height:`${E-10}px`})}})],onOpenChange(E){E||t.suggestionMenus.closeMenu()}});return!y||!k||a&&(k.query.startsWith(" ")||k.query.length<a)?null:r.jsx("div",{ref:B,style:L,...T(),children:r.jsx(on,{query:k.query,closeMenu:b.closeMenu,clearQuery:b.clearQuery,getItems:u,columns:i,gridSuggestionMenuComponent:o||Ro,onItemClick:f})})}const ln=e=>{const t=x(),n=H(),o=j();return r.jsx(t.Generic.Menu.Item,{onClick:()=>{const i=e.block.content.rows[e.index].cells.map(()=>[]),a=[...e.block.content.rows];a.splice(e.index+(e.side==="below"?1:0),0,{cells:i}),o.updateBlock(e.block,{type:"table",content:{type:"tableContent",rows:a}})},children:n.table_handle[`add_${e.side}_menuitem`]})},an=e=>{const t=x(),n=H(),o=j();return r.jsx(t.Generic.Menu.Item,{onClick:()=>{const i={type:"tableContent",rows:e.block.content.rows.map(a=>{const s=[...a.cells];return s.splice(e.index+(e.side==="right"?1:0),0,[]),{cells:s}})};o.updateBlock(e.block,{type:"table",content:i})},children:n.table_handle[`add_${e.side}_menuitem`]})},De=e=>e.orientation==="row"?r.jsx(ln,{...e,side:e.side}):r.jsx(an,{...e,side:e.side}),sn=e=>{const t=x(),n=H(),o=j();return r.jsx(t.Generic.Menu.Item,{onClick:()=>{const i={type:"tableContent",rows:e.block.content.rows.filter((a,s)=>s!==e.index)};o.updateBlock(e.block,{type:"table",content:i})},children:n.table_handle.delete_row_menuitem})},cn=e=>{const t=x(),n=H(),o=j();return r.jsx(t.Generic.Menu.Item,{onClick:()=>{const i={type:"tableContent",rows:e.block.content.rows.map(a=>({cells:a.cells.filter((s,d)=>d!==e.index)}))};o.updateBlock(e.block,{type:"table",content:i})},children:n.table_handle.delete_column_menuitem})},un=e=>e.orientation==="row"?r.jsx(sn,{...e}):r.jsx(cn,{...e}),dn=e=>{const t=x();return r.jsx(t.Generic.Menu.Dropdown,{className:"bn-table-handle-menu",children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(un,{orientation:e.orientation,block:e.block,index:e.index}),r.jsx(De,{orientation:e.orientation,block:e.block,index:e.index,side:e.orientation==="row"?"above":"left"}),r.jsx(De,{orientation:e.orientation,block:e.block,index:e.index,side:e.orientation==="row"?"below":"right"})]})})},fn=e=>{const t=x(),[n,o]=c.useState(!1),i=e.tableHandleMenu||dn;return r.jsxs(t.Generic.Menu.Root,{onOpenChange:a=>{a?(e.freezeHandles(),e.hideOtherSide()):(e.unfreezeHandles(),e.showOtherSide(),e.editor.focus())},position:"right",children:[r.jsx(t.Generic.Menu.Trigger,{children:r.jsx(t.TableHandle.Root,{className:p.mergeCSSClasses("bn-table-handle",n?"bn-table-handle-dragging":""),draggable:!0,onDragStart:a=>{o(!0),e.dragStart(a)},onDragEnd:()=>{e.dragEnd(),o(!1)},style:e.orientation==="column"?{transform:"rotate(0.25turn)"}:void 0,children:e.children||r.jsx(Ut,{size:24,"data-test":"tableHandle"})})}),r.jsx(i,{orientation:e.orientation,block:e.block,index:e.index})]})};function Zo(e,t,n){return n&&n.draggedCellOrientation==="row"?new DOMRect(t.x,n.mousePos,t.width,0):new DOMRect(t.x,e.y,t.width,e.height)}function Wo(e,t,n){return n&&n.draggedCellOrientation==="col"?new DOMRect(n.mousePos,t.y,0,t.height):new DOMRect(e.x,t.y,e.width,t.height)}function gn(e,t,n,o,i){const{refs:a,update:s,context:d,floatingStyles:f}=D.useFloating({open:t,placement:e==="row"?"left":"top",middleware:[D.offset(e==="row"?-10:-12)]}),{isMounted:u,styles:b}=D.useTransitionStyles(d);return c.useEffect(()=>{s()},[n,o,s]),c.useEffect(()=>{n===null||o===null||a.setReference({getBoundingClientRect:()=>(e==="row"?Zo:Wo)(n,o,i)})},[i,e,n,o,a]),c.useMemo(()=>({isMounted:u,ref:a.setFloating,style:{display:"flex",...b,...f,zIndex:1e4}}),[f,u,a.setFloating,b])}function mn(e,t,n,o){const i=gn("row",e,t,n,o),a=gn("col",e,t,n,o);return c.useMemo(()=>({rowHandle:i,colHandle:a}),[a,i])}const hn=e=>{var k,y;const t=j();if(!t.tableHandles)throw new Error("TableHandlesController can only be used when BlockNote editor schema contains table block");const n={rowDragStart:t.tableHandles.rowDragStart,colDragStart:t.tableHandles.colDragStart,dragEnd:t.tableHandles.dragEnd,freezeHandles:t.tableHandles.freezeHandles,unfreezeHandles:t.tableHandles.unfreezeHandles},o=K(t.tableHandles.onUpdate.bind(t.tableHandles)),i=c.useMemo(()=>{var B,L;return o!=null&&o.draggingState?{draggedCellOrientation:(B=o==null?void 0:o.draggingState)==null?void 0:B.draggedCellOrientation,mousePos:(L=o==null?void 0:o.draggingState)==null?void 0:L.mousePos}:void 0},[o==null?void 0:o.draggingState,(k=o==null?void 0:o.draggingState)==null?void 0:k.draggedCellOrientation,(y=o==null?void 0:o.draggingState)==null?void 0:y.mousePos]),{rowHandle:a,colHandle:s}=mn((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePosCell)||null,(o==null?void 0:o.referencePosTable)||null,i),[d,f]=c.useState(!1),[u,b]=c.useState(!1);if(!a.isMounted||!s.isMounted||!o)return null;const h=e.tableHandle||fn;return r.jsxs(r.Fragment,{children:[!d&&r.jsx("div",{ref:a.ref,style:a.style,children:r.jsx(h,{editor:t,orientation:"row",showOtherSide:()=>b(!1),hideOtherSide:()=>b(!0),index:o.rowIndex,block:o.block,dragStart:n.rowDragStart,dragEnd:n.dragEnd,freezeHandles:n.freezeHandles,unfreezeHandles:n.unfreezeHandles})}),!u&&r.jsx("div",{ref:s.ref,style:s.style,children:r.jsx(h,{editor:t,orientation:"column",showOtherSide:()=>f(!1),hideOtherSide:()=>f(!0),index:o.colIndex,block:o.block,dragStart:n.colDragStart,dragEnd:n.dragEnd,freezeHandles:n.freezeHandles,unfreezeHandles:n.unfreezeHandles})})]})};function bn(e){const t=j();if(!t)throw new Error("BlockNoteDefaultUI must be used within a BlockNoteContext.Provider");return r.jsxs(r.Fragment,{children:[e.formattingToolbar!==!1&&r.jsx(It,{}),e.linkToolbar!==!1&&r.jsx(Rt,{}),e.slashMenu!==!1&&r.jsx(en,{triggerCharacter:"/"}),e.emojiPicker!==!1&&r.jsx(rn,{triggerCharacter:":",columns:10,minQueryLength:2}),e.sideMenu!==!1&&r.jsx(Yt,{}),t.filePanel&&e.filePanel!==!1&&r.jsx(Zt,{}),t.tableHandles&&e.tableHandles!==!1&&r.jsx(hn,{})]})}const kn=()=>{const e=c.useMemo(()=>{var s;return(s=window.matchMedia)==null?void 0:s.call(window,"(prefers-color-scheme: dark)")},[]),t=c.useMemo(()=>{var s;return(s=window.matchMedia)==null?void 0:s.call(window,"(prefers-color-scheme: light)")},[]),n=e==null?void 0:e.matches,o=t==null?void 0:t.matches,[i,a]=c.useState(n?"dark":o?"light":"no-preference");return c.useEffect(()=>{a(n?"dark":o?"light":"no-preference")},[n,o]),c.useEffect(()=>{if(typeof(e==null?void 0:e.addEventListener)=="function"){const s=({matches:f})=>f&&a("dark"),d=({matches:f})=>f&&a("light");return e==null||e.addEventListener("change",s),t==null||t.addEventListener("change",d),()=>{e==null||e.removeEventListener("change",s),t==null||t.removeEventListener("change",d)}}else{const s=()=>a(e.matches?"dark":t.matches?"light":"no-preference");return e==null||e.addEventListener("change",s),t==null||t.addEventListener("change",s),()=>{e==null||e.removeEventListener("change",s),t==null||t.removeEventListener("change",s)}}},[e,t]),typeof window.matchMedia!="function",i},Uo=({renderers:e})=>r.jsx(r.Fragment,{children:Object.entries(e).map(([t,n])=>te.createPortal(n.reactElement,n.element,t))});function zo(e){const[t,n]=c.useState({});return c.useEffect(()=>(e.editor._tiptapEditor.contentComponent={setRenderer(o,i){n(a=>({...a,[o]:i}))},removeRenderer(o){n(i=>{const a={...i};return delete a[o],a})}},queueMicrotask(()=>{e.editor._tiptapEditor.createNodeViews()}),()=>{e.editor._tiptapEditor.contentComponent=null}),[e.editor._tiptapEditor]),r.jsxs(r.Fragment,{children:[r.jsx(Uo,{renderers:t}),e.children]})}const Go=c.forwardRef((e,t)=>{const[n,o]=c.useState();return c.useImperativeHandle(t,()=>(i,a)=>{te.flushSync(()=>{o({node:i,container:a})}),o(void 0)},[]),r.jsx(r.Fragment,{children:n&&te.createPortal(n.node,n.container)})}),Cn=()=>{};function qo(e,t){const{editor:n,className:o,theme:i,children:a,editable:s,onSelectionChange:d,onChange:f,formattingToolbar:u,linkToolbar:b,slashMenu:h,emojiPicker:k,sideMenu:y,filePanel:B,tableHandles:L,...T}=e,[E,F]=c.useState(),$=W(),Ae=kn(),Re=($==null?void 0:$.colorSchemePreference)||Ae,Se=i||(Re==="dark"?"dark":"light");fe(f||Cn,n),ge(d||Cn,n),c.useEffect(()=>{n.isEditable=s!==!1},[s,n]);const Ze=c.useMemo(()=>r.jsxs(r.Fragment,{children:[a,r.jsx(bn,{formattingToolbar:u,linkToolbar:b,slashMenu:h,emojiPicker:k,sideMenu:y,filePanel:B,tableHandles:L})]}),[a,u,b,h,k,y,B,L]),We=c.useMemo(()=>({...$,editor:n,setContentEditableProps:F}),[$,n]),we=c.useCallback(Ue=>{n.elementRenderer=Ue},[n]);return r.jsxs(_e.Provider,{value:We,children:[r.jsx(Go,{ref:we}),!n.headless&&r.jsx(zo,{editor:n,children:r.jsxs("div",{className:p.mergeCSSClasses("bn-container",Se||"",o||""),"data-color-scheme":Se,...T,ref:t,children:[r.jsx("div",{"aria-autocomplete":"list","aria-haspopup":"listbox",ref:n.mount,...E}),Ze]})})]})}const Ko=Z.default.forwardRef(qo);var Ne,Ce=Jn.default;if(process.env.NODE_ENV==="production")Ne=Ce.createRoot,Ce.hydrateRoot;else{var pn=Ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Ne=function(e,t){pn.usingClientEntryPoint=!0;try{return Ce.createRoot(e,t)}finally{pn.usingClientEntryPoint=!1}}}function pe(e,t){let n;const o=document.createElement("div");let i;if(t!=null&&t.elementRenderer?t.elementRenderer(e(f=>n=f||void 0),o):(i=Ne(o),te.flushSync(()=>{i.render(e(f=>n=f||void 0))})),!o.childElementCount)return console.warn("ReactInlineContentSpec: renderHTML() failed"),{dom:document.createElement("span")};n==null||n.setAttribute("data-tmp-find","true");const a=o.cloneNode(!0),s=a.firstElementChild,d=a.querySelector("[data-tmp-find]");return d==null||d.removeAttribute("data-tmp-find"),i==null||i.unmount(),{dom:s,contentDOM:d||void 0}}function ve(e){var t;return r.jsx(q.NodeViewWrapper,{...Object.fromEntries(Object.entries(e.domAttributes||{}).filter(([n])=>n!=="class")),className:p.mergeCSSClasses("bn-block-content",((t=e.domAttributes)==null?void 0:t.class)||""),"data-content-type":e.blockType,...Object.fromEntries(Object.entries(e.blockProps).filter(([n,o])=>!p.inheritedProps.includes(n)&&o!==e.propSchema[n].default).map(([n,o])=>[p.camelToDataKebab(n),o])),"data-file-block":e.isFileBlock===!0||void 0,children:e.children})}function le(e,t){const n=p.createStronglyTypedTiptapNode({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:!0,addAttributes(){return p.propsToAttributes(e.propSchema)},parseHTML(){return p.getParseRules(e,t.parse)},renderHTML(){const o=document.createElement("div");return o.setAttribute("data-tmp-placeholder","true"),{dom:o}},addNodeView(){return o=>q.ReactNodeViewRenderer(i=>{var b;const a=this.options.editor,s=p.getBlockFromPos(i.getPos,a,this.editor,e.type),d=((b=this.options.domAttributes)==null?void 0:b.blockContent)||{},f=q.NodeViewContent({}).ref,u=t.render;return r.jsx(ve,{blockType:s.type,blockProps:s.props,propSchema:e.propSchema,isFileBlock:e.isFileBlock,domAttributes:d,children:r.jsx(u,{block:s,editor:a,contentRef:f})})},{className:"bn-react-node-view-renderer"})(o)}});return p.createInternalBlockSpec(e,{node:n,toInternalHTML:(o,i)=>{var f,u;const a=((f=n.options.domAttributes)==null?void 0:f.blockContent)||{},s=t.render,d=pe(b=>r.jsx(ve,{blockType:o.type,blockProps:o.props,propSchema:e.propSchema,domAttributes:a,children:r.jsx(s,{block:o,editor:i,contentRef:b})}),i);return(u=d.contentDOM)==null||u.setAttribute("data-editable",""),d},toExternalHTML:(o,i)=>{var f,u;const a=((f=n.options.domAttributes)==null?void 0:f.blockContent)||{},s=t.toExternalHTML||t.render,d=pe(b=>r.jsx(ve,{blockType:o.type,blockProps:o.props,propSchema:e.propSchema,domAttributes:a,children:r.jsx(s,{block:o,editor:i,contentRef:b})}),i);return(u=d.contentDOM)==null||u.setAttribute("data-editable",""),d}})}const ie=e=>r.jsxs("div",{className:"bn-file-default-preview",contentEditable:!1,draggable:!1,children:[r.jsx("div",{className:"bn-file-default-preview-icon",children:r.jsx(be,{size:24})}),r.jsx("p",{className:"bn-file-default-preview-name",children:e.block.props.name})]}),G=e=>r.jsxs("div",{className:"bn-file-and-caption-wrapper",children:[e.children,e.block.props.caption&&r.jsx("p",{className:"bn-file-caption",children:e.block.props.caption})]}),ae=e=>{const t=c.useCallback(o=>{o.preventDefault()},[]),n=c.useCallback(()=>{e.editor.dispatch(e.editor._tiptapEditor.state.tr.setMeta(e.editor.filePanel.plugin,{block:e.block}))},[e.block,e.editor]);return r.jsxs("div",{className:"bn-add-file-button",onMouseDown:t,onClick:n,children:[r.jsx("div",{className:"bn-add-file-button-icon",children:e.buttonIcon||r.jsx(be,{size:24})}),r.jsx("div",{className:"bn-add-file-button-text",children:e.buttonText})]})},se=e=>r.jsxs("div",{children:[e.children,r.jsx("p",{children:e.caption})]}),xe=e=>r.jsxs("figure",{children:[e.children,r.jsx("figcaption",{children:e.caption})]}),Oe=e=>{const[t,n]=c.useState(!1),[o,i]=c.useState(void 0);c.useEffect(()=>{const u=h=>{let k;e.block.props.textAlignment==="center"?o.handleUsed==="left"?k=o.initialWidth+(o.initialClientX-h.clientX)*2:k=o.initialWidth+(h.clientX-o.initialClientX)*2:o.handleUsed==="left"?k=o.initialWidth+o.initialClientX-h.clientX:k=o.initialWidth+h.clientX-o.initialClientX;const y=64;k<y?e.setWidth(y):k>e.editor.domElement.firstElementChild.clientWidth?e.setWidth(e.editor.domElement.firstElementChild.clientWidth):e.setWidth(k)},b=()=>{i(void 0),e.editor.updateBlock(e.block,{props:{previewWidth:e.width}})};return o&&(window.addEventListener("mousemove",u),window.addEventListener("mouseup",b)),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",b)}},[e,o]);const a=c.useCallback(()=>{e.editor.isEditable&&n(!0)},[e.editor.isEditable]),s=c.useCallback(()=>{n(!1)},[]),d=c.useCallback(u=>{u.preventDefault(),i({handleUsed:"left",initialWidth:e.width,initialClientX:u.clientX})},[e.width]),f=c.useCallback(u=>{u.preventDefault(),i({handleUsed:"right",initialWidth:e.width,initialClientX:u.clientX})},[e.width]);return r.jsxs("div",{className:"bn-visual-media-wrapper",onMouseEnter:a,onMouseLeave:s,children:[e.children,(t||o)&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"bn-visual-media-resize-handle",style:{left:"4px"},onMouseDown:d}),r.jsx("div",{className:"bn-visual-media-resize-handle",style:{right:"4px"},onMouseDown:f})]})]})};function ye(e){const t=j(),[n,o]=c.useState("loading"),[i,a]=c.useState();if(c.useEffect(()=>{let s=!0;return(async()=>{let d="";o("loading");try{d=await t.resolveFileUrl(e)}catch{o("error");return}s&&(o("loaded"),a(d))})(),()=>{s=!1}},[t,e]),n!=="loaded")return{loadingState:n};if(!i)throw new Error("Finished fetching file but did not get download URL.");return{loadingState:n,downloadUrl:i}}const vn=e=>{const t=ye(e.block.props.url);return t.loadingState==="loading"?null:r.jsx("audio",{className:"bn-audio",src:t.downloadUrl,controls:!0,contentEditable:!1,draggable:!1})},xn=e=>{if(!e.block.props.url)return r.jsx("p",{children:"Add audio"});const t=e.block.props.showPreview?r.jsx("audio",{src:e.block.props.url}):r.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?e.block.props.showPreview?r.jsx(xe,{caption:e.block.props.caption,children:t}):r.jsx(se,{caption:e.block.props.caption,children:t}):t},$o=le(p.audioBlockConfig,{render:e=>r.jsx("div",{className:"bn-file-block-content-wrapper",children:e.block.props.url===""?r.jsx(ae,{...e,editor:e.editor,buttonText:e.editor.dictionary.file_blocks.audio.add_button_text,buttonIcon:r.jsx(pt,{size:24})}):e.block.props.showPreview?r.jsx(G,{block:e.block,editor:e.editor,children:r.jsx(vn,{block:e.block,editor:e.editor})}):r.jsx(G,{block:e.block,editor:e.editor,children:r.jsx(ie,{block:e.block,editor:e.editor})})}),parse:p.audioParse,toExternalHTML:e=>r.jsx(xn,{...e})}),yn=e=>{if(!e.block.props.url)return r.jsx("p",{children:"Add file"});const t=r.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?r.jsx(se,{caption:e.block.props.caption,children:t}):t},Yo=le(p.fileBlockConfig,{render:e=>r.jsx("div",{className:"bn-file-block-content-wrapper",children:e.block.props.url===""?r.jsx(ae,{block:e.block,editor:e.editor,buttonIcon:r.jsx(be,{size:24}),buttonText:e.editor.dictionary.file_blocks.file.add_button_text}):r.jsx(G,{block:e.block,editor:e.editor,children:r.jsx(ie,{block:e.block,editor:e.editor})})}),parse:p.fileParse,toExternalHTML:e=>r.jsx(yn,{...e})}),Sn=e=>{const[t,n]=c.useState(Math.min(e.block.props.previewWidth,e.editor.domElement.firstElementChild.clientWidth)),o=ye(e.block.props.url);return o.loadingState==="loading"?null:r.jsx(Oe,{...e,width:t,setWidth:n,children:r.jsx("img",{className:"bn-visual-media",src:o.downloadUrl,alt:e.block.props.caption||"BlockNote image",contentEditable:!1,draggable:!1,width:t})})},wn=e=>{if(!e.block.props.url)return r.jsx("p",{children:"Add image"});const t=e.block.props.showPreview?r.jsx("img",{src:e.block.props.url,alt:e.block.props.name||e.block.props.caption||"BlockNote image",width:e.block.props.previewWidth}):r.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?e.block.props.showPreview?r.jsx(xe,{caption:e.block.props.caption,children:t}):r.jsx(se,{caption:e.block.props.caption,children:t}):t},Xo=le(p.imageBlockConfig,{render:e=>r.jsx("div",{className:"bn-file-block-content-wrapper",children:e.block.props.url===""?r.jsx(ae,{...e,editor:e.editor,buttonText:e.editor.dictionary.file_blocks.image.add_button_text,buttonIcon:r.jsx(Ct,{size:24})}):e.block.props.showPreview?r.jsx(G,{block:e.block,editor:e.editor,children:r.jsx(Sn,{block:e.block,editor:e.editor})}):r.jsx(G,{block:e.block,editor:e.editor,children:r.jsx(ie,{block:e.block,editor:e.editor})})}),parse:p.imageParse,toExternalHTML:e=>r.jsx(wn,{...e})}),jn=e=>{const[t,n]=c.useState(Math.min(e.block.props.previewWidth,e.editor.domElement.firstElementChild.clientWidth)),o=ye(e.block.props.url);return o.loadingState==="loading"?null:r.jsx(Oe,{...e,width:t,setWidth:n,children:r.jsx("video",{className:"bn-visual-media",src:o.downloadUrl,controls:!0,contentEditable:!1,draggable:!1,width:t})})},Mn=e=>{if(!e.block.props.url)return r.jsx("p",{children:"Add video"});const t=e.block.props.showPreview?r.jsx("video",{src:e.block.props.url}):r.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?e.block.props.showPreview?r.jsx(xe,{caption:e.block.props.caption,children:t}):r.jsx(se,{caption:e.block.props.caption,children:t}):t},Jo=le(p.videoBlockConfig,{render:e=>r.jsx("div",{className:"bn-file-block-content-wrapper",children:e.block.props.url===""?r.jsx(ae,{...e,editor:e.editor,buttonText:e.editor.dictionary.file_blocks.video.add_button_text,buttonIcon:r.jsx(jo,{size:24})}):e.block.props.showPreview?r.jsx(G,{block:e.block,editor:e.editor,children:r.jsx(jn,{block:e.block,editor:e.editor})}):r.jsx(G,{block:e.block,editor:e.editor,children:r.jsx(ie,{block:e.block,editor:e.editor})})}),parse:p.videoParse,toExternalHTML:e=>r.jsx(Mn,{...e})});function Qo(e){const t=W();if(e||(e=t==null?void 0:t.editor),!e)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");const n=e,[o,i]=c.useState(()=>n.getActiveStyles());return fe(()=>{i(n.getActiveStyles())},n),ge(()=>{i(n.getActiveStyles())},n),o}const Hn=(e={},t=[])=>c.useMemo(()=>{const n=p.BlockNoteEditor.create(e);return window&&(window.ProseMirror=n._tiptapEditor),n},t),er=Hn;function tr(){const[,e]=c.useState(0);return()=>e(t=>t+1)}const nr=e=>{const t=tr();c.useEffect(()=>{const n=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})};return e.on("transaction",n),()=>{e.off("transaction",n)}},[e])};function En(e){return r.jsx(q.NodeViewWrapper,{as:"span",className:"bn-inline-content-section","data-inline-content-type":e.inlineContentType,...Object.fromEntries(Object.entries(e.inlineContentProps).filter(([t,n])=>n!==e.propSchema[t].default).map(([t,n])=>[p.camelToDataKebab(t),n])),children:e.children})}function or(e,t){const n=p.createStronglyTypedTiptapNode({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return p.propsToAttributes(e.propSchema)},addKeyboardShortcuts(){return p.addInlineContentKeyboardShortcuts(e)},parseHTML(){return p.getInlineContentParseRules(e)},renderHTML({node:o}){const i=this.options.editor,a=p.nodeToCustomInlineContent(o,i.schema.inlineContentSchema,i.schema.styleSchema),s=t.render,d=pe(f=>r.jsx(s,{inlineContent:a,contentRef:f}),i);return p.addInlineContentAttributes(d,e.type,o.attrs,e.propSchema)},addNodeView(){const o=this.options.editor;return i=>q.ReactNodeViewRenderer(a=>{const s=q.NodeViewContent({}).ref,d=t.render;return r.jsx(En,{inlineContentProps:a.node.attrs,inlineContentType:e.type,propSchema:e.propSchema,children:r.jsx(d,{contentRef:s,inlineContent:p.nodeToCustomInlineContent(a.node,o.schema.inlineContentSchema,o.schema.styleSchema)})})},{className:"bn-ic-react-node-view-renderer",as:"span"})(i)}});return p.createInternalInlineContentSpec(e,{node:n})}function rr(e,t){const n=q.Mark.create({name:e.type,addAttributes(){return p.stylePropsToAttributes(e.propSchema)},parseHTML(){return p.getStyleParseRules(e)},renderHTML({mark:o}){const i={};e.propSchema==="string"&&(i.value=o.attrs.stringValue);const a=t.render,s=pe(d=>r.jsx(a,{...i,contentRef:d}),void 0);return p.addStyleAttributes(s,e.type,o.attrs.stringValue,e.propSchema)}});return p.createInternalStyleSpec(e,{mark:n})}function lr(e){if(!e.parentElement)return"none";const t=e.getBoundingClientRect(),n=e.parentElement.getBoundingClientRect(),o=t.top<n.top,i=t.bottom>n.bottom;return o&&i?"both":o?"top":i?"bottom":"none"}g.AddBlockButton=Wt,g.AddButton=De,g.AddColumnButton=an,g.AddFileButton=ae,g.AddRowButton=ln,g.AudioPreview=vn,g.AudioToExternalHTML=xn,g.BasicTextStyleButton=re,g.BlockColorsItem=zt,g.BlockContentWrapper=ve,g.BlockNoteContext=_e,g.BlockNoteDefaultUI=bn,g.BlockNoteViewRaw=Ko,g.BlockTypeSelect=Vt,g.ColorStyleButton=St,g.ComponentsContext=rt,g.CreateLinkButton=wt,g.DefaultFilePreview=ie,g.DeleteButton=un,g.DeleteColumnButton=cn,g.DeleteLinkButton=Dt,g.DeleteRowButton=sn,g.DragHandleButton=Kt,g.DragHandleMenu=qt,g.EditLinkButton=Nt,g.EditLinkMenuItems=Le,g.EmbedTab=Et,g.FigureWithCaption=xe,g.FileAndCaptionWrapper=G,g.FileCaptionButton=jt,g.FilePanel=Pe,g.FilePanelController=Zt,g.FileReplaceButton=Bt,g.FileToExternalHTML=yn,g.FormattingToolbar=Pt,g.FormattingToolbarController=It,g.GridSuggestionMenuController=rn,g.GridSuggestionMenuWrapper=on,g.ImagePreview=Sn,g.ImageToExternalHTML=wn,g.InlineContentWrapper=En,g.LinkToolbar=At,g.LinkToolbarController=Rt,g.LinkWithCaption=se,g.NestBlockButton=Mt,g.OpenLinkButton=Ot,g.ReactAudioBlock=$o,g.ReactFileBlock=Yo,g.ReactImageBlock=Xo,g.ReactVideoBlock=Jo,g.RemoveBlockItem=Gt,g.ResizeHandlesWrapper=Oe,g.SideMenu=$t,g.SideMenuController=Yt,g.SuggestionMenuController=en,g.SuggestionMenuWrapper=Jt,g.TableHandle=fn,g.TableHandleMenu=dn,g.TableHandlesController=hn,g.TextAlignButton=ke,g.UnnestBlockButton=Ht,g.UploadTab=_t,g.VideoPreview=jn,g.VideoToExternalHTML=Mn,g.blockTypeSelectItems=Tt,g.createReactBlockSpec=le,g.createReactInlineContentSpec=or,g.createReactStyleSpec=rr,g.elementOverflow=lr,g.getDefaultReactEmojiPickerItems=tn,g.getDefaultReactSlashMenuItems=Qt,g.getFormattingToolbarItems=Lt,g.mergeRefs=ot,g.useActiveStyles=Qo,g.useBlockNote=er,g.useBlockNoteContext=W,g.useBlockNoteEditor=j,g.useCloseSuggestionMenuNoItems=Fe,g.useComponentsContext=x,g.useCreateBlockNote=Hn,g.useDictionary=H,g.useEditorChange=fe,g.useEditorContentOrSelectionChange=z,g.useEditorForceUpdate=nr,g.useEditorSelectionChange=ge,g.useGridSuggestionMenuKeyboardNavigation=nn,g.useLoadSuggestionMenuItems=Ie,g.usePrefersColorScheme=kn,g.useResolveUrl=ye,g.useSelectedBlocks=O,g.useSuggestionMenuKeyboardNavigation=Xt,g.useTableHandlesPositioning=mn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=blocknote-react.umd.cjs.map
