(function(m,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("@floating-ui/react"),require("@blocknote/core"),require("use-prefers-color-scheme"),require("react-dom"),require("@tiptap/react")):typeof define=="function"&&define.amd?define(["exports","react","@floating-ui/react","@blocknote/core","use-prefers-color-scheme","react-dom","@tiptap/react"],u):(m=typeof globalThis<"u"?globalThis:m||self,u(m["blocknote-react"]={},m.React,m.react,m.core,m.usePrefersColorScheme,m.ReactDOM,m.react$1))})(this,function(m,u,P,v,Sn,Q,q){"use strict";const xe=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},R=xe(u),Tn=xe(Sn),jn=xe(Q),ye=u.createContext(void 0);function A(e){return u.useContext(ye)}var Se={exports:{}},X={};/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ze;function Mn(){if(Ze)return X;Ze=1;var e=R.default,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(c,f,g){var h,p={},C=null,j=null;g!==void 0&&(C=""+g),f.key!==void 0&&(C=""+f.key),f.ref!==void 0&&(j=f.ref);for(h in f)o.call(f,h)&&!i.hasOwnProperty(h)&&(p[h]=f[h]);if(c&&c.defaultProps)for(h in f=c.defaultProps,f)p[h]===void 0&&(p[h]=f[h]);return{$$typeof:t,type:c,key:C,ref:j,props:p,_owner:l.current}}return X.Fragment=n,X.jsx=s,X.jsxs=s,X}var ee={};/**
 * @license React
 * react-jsx-runtime.development.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ue;function _n(){return Ue||(Ue=1,process.env.NODE_ENV!=="production"&&function(){var e=R.default,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),V=Symbol.iterator,G="@@iterator";function N(r){if(r===null||typeof r!="object")return null;var d=V&&r[V]||r[G];return typeof d=="function"?d:null}var W=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(r){{for(var d=arguments.length,b=new Array(d>1?d-1:0),k=1;k<d;k++)b[k-1]=arguments[k];we("error",r,b)}}function we(r,d,b){{var k=W.ReactDebugCurrentFrame,T=k.getStackAddendum();T!==""&&(d+="%s",b=b.concat([T]));var _=b.map(function(y){return String(y)});_.unshift("Warning: "+d),Function.prototype.apply.call(console[r],console,_)}}var fe=!1,me=!1,Ee=!1,ge=!1,Be=!1,he;he=Symbol.for("react.module.reference");function Ve(r){return!!(typeof r=="string"||typeof r=="function"||r===o||r===i||Be||r===l||r===g||r===h||ge||r===j||fe||me||Ee||typeof r=="object"&&r!==null&&(r.$$typeof===C||r.$$typeof===p||r.$$typeof===s||r.$$typeof===c||r.$$typeof===f||r.$$typeof===he||r.getModuleId!==void 0))}function Le(r,d,b){var k=r.displayName;if(k)return k;var T=d.displayName||d.name||"";return T!==""?b+"("+T+")":b}function Xt(r){return r.displayName||"Context"}function Z(r){if(r==null)return null;if(typeof r.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case o:return"Fragment";case n:return"Portal";case i:return"Profiler";case l:return"StrictMode";case g:return"Suspense";case h:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case c:var d=r;return Xt(d)+".Consumer";case s:var b=r;return Xt(b._context)+".Provider";case f:return Le(r,r.render,"ForwardRef");case p:var k=r.displayName||null;return k!==null?k:Z(r.type)||"Memo";case C:{var T=r,_=T._payload,y=T._init;try{return Z(y(_))}catch{return null}}}return null}var $=Object.assign,re=0,en,tn,nn,on,rn,an,ln;function sn(){}sn.__reactDisabledLog=!0;function mo(){{if(re===0){en=console.log,tn=console.info,nn=console.warn,on=console.error,rn=console.group,an=console.groupCollapsed,ln=console.groupEnd;var r={configurable:!0,enumerable:!0,value:sn,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}re++}}function go(){{if(re--,re===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:$({},r,{value:en}),info:$({},r,{value:tn}),warn:$({},r,{value:nn}),error:$({},r,{value:on}),group:$({},r,{value:rn}),groupCollapsed:$({},r,{value:an}),groupEnd:$({},r,{value:ln})})}re<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Pe=W.ReactCurrentDispatcher,Ie;function be(r,d,b){{if(Ie===void 0)try{throw Error()}catch(T){var k=T.stack.trim().match(/\n( *(at )?)/);Ie=k&&k[1]||""}return`
`+Ie+r}}var Ne=!1,pe;{var ho=typeof WeakMap=="function"?WeakMap:Map;pe=new ho}function cn(r,d){if(!r||Ne)return"";{var b=pe.get(r);if(b!==void 0)return b}var k;Ne=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var _;_=Pe.current,Pe.current=null,mo();try{if(d){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(U){k=U}Reflect.construct(r,[],y)}else{try{y.call()}catch(U){k=U}r.call(y.prototype)}}else{try{throw Error()}catch(U){k=U}r()}}catch(U){if(U&&k&&typeof U.stack=="string"){for(var x=U.stack.split(`
`),I=k.stack.split(`
`),B=x.length-1,L=I.length-1;B>=1&&L>=0&&x[B]!==I[L];)L--;for(;B>=1&&L>=0;B--,L--)if(x[B]!==I[L]){if(B!==1||L!==1)do if(B--,L--,L<0||x[B]!==I[L]){var O=`
`+x[B].replace(" at new "," at ");return r.displayName&&O.includes("<anonymous>")&&(O=O.replace("<anonymous>",r.displayName)),typeof r=="function"&&pe.set(r,O),O}while(B>=1&&L>=0);break}}}finally{Ne=!1,Pe.current=_,go(),Error.prepareStackTrace=T}var J=r?r.displayName||r.name:"",yn=J?be(J):"";return typeof r=="function"&&pe.set(r,yn),yn}function bo(r,d,b){return cn(r,!1)}function po(r){var d=r.prototype;return!!(d&&d.isReactComponent)}function Ce(r,d,b){if(r==null)return"";if(typeof r=="function")return cn(r,po(r));if(typeof r=="string")return be(r);switch(r){case g:return be("Suspense");case h:return be("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case f:return bo(r.render);case p:return Ce(r.type,d,b);case C:{var k=r,T=k._payload,_=k._init;try{return Ce(_(T),d,b)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,un={},dn=W.ReactDebugCurrentFrame;function ve(r){if(r){var d=r._owner,b=Ce(r.type,r._source,d?d.type:null);dn.setExtraStackFrame(b)}else dn.setExtraStackFrame(null)}function Co(r,d,b,k,T){{var _=Function.call.bind(ke);for(var y in r)if(_(r,y)){var x=void 0;try{if(typeof r[y]!="function"){var I=Error((k||"React class")+": "+b+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw I.name="Invariant Violation",I}x=r[y](d,y,k,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(B){x=B}x&&!(x instanceof Error)&&(ve(T),E("%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).",k||"React class",b,y,typeof x),ve(null)),x instanceof Error&&!(x.message in un)&&(un[x.message]=!0,ve(T),E("Failed %s type: %s",b,x.message),ve(null))}}}var ko=Array.isArray;function Oe(r){return ko(r)}function vo(r){{var d=typeof Symbol=="function"&&Symbol.toStringTag,b=d&&r[Symbol.toStringTag]||r.constructor.name||"Object";return b}}function xo(r){try{return fn(r),!1}catch{return!0}}function fn(r){return""+r}function mn(r){if(xo(r))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",vo(r)),fn(r)}var ae=W.ReactCurrentOwner,yo={key:!0,ref:!0,__self:!0,__source:!0},gn,hn,Re;Re={};function So(r){if(ke.call(r,"ref")){var d=Object.getOwnPropertyDescriptor(r,"ref").get;if(d&&d.isReactWarning)return!1}return r.ref!==void 0}function To(r){if(ke.call(r,"key")){var d=Object.getOwnPropertyDescriptor(r,"key").get;if(d&&d.isReactWarning)return!1}return r.key!==void 0}function jo(r,d){if(typeof r.ref=="string"&&ae.current&&d&&ae.current.stateNode!==d){var b=Z(ae.current.type);Re[b]||(E('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',Z(ae.current.type),r.ref),Re[b]=!0)}}function Mo(r,d){{var b=function(){gn||(gn=!0,E("%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)",d))};b.isReactWarning=!0,Object.defineProperty(r,"key",{get:b,configurable:!0})}}function _o(r,d){{var b=function(){hn||(hn=!0,E("%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)",d))};b.isReactWarning=!0,Object.defineProperty(r,"ref",{get:b,configurable:!0})}}var Ho=function(r,d,b,k,T,_,y){var x={$$typeof:t,type:r,key:d,ref:b,props:y,_owner:_};return x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(x,"_self",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.defineProperty(x,"_source",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x};function wo(r,d,b,k,T){{var _,y={},x=null,I=null;b!==void 0&&(mn(b),x=""+b),To(d)&&(mn(d.key),x=""+d.key),So(d)&&(I=d.ref,jo(d,T));for(_ in d)ke.call(d,_)&&!yo.hasOwnProperty(_)&&(y[_]=d[_]);if(r&&r.defaultProps){var B=r.defaultProps;for(_ in B)y[_]===void 0&&(y[_]=B[_])}if(x||I){var L=typeof r=="function"?r.displayName||r.name||"Unknown":r;x&&Mo(y,L),I&&_o(y,L)}return Ho(r,x,I,T,k,ae.current,y)}}var De=W.ReactCurrentOwner,bn=W.ReactDebugCurrentFrame;function K(r){if(r){var d=r._owner,b=Ce(r.type,r._source,d?d.type:null);bn.setExtraStackFrame(b)}else bn.setExtraStackFrame(null)}var Ae;Ae=!1;function Fe(r){return typeof r=="object"&&r!==null&&r.$$typeof===t}function pn(){{if(De.current){var r=Z(De.current.type);if(r)return`

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

Check your code at `+d+":"+b+"."}return""}}var Cn={};function Bo(r){{var d=pn();if(!d){var b=typeof r=="string"?r:r.displayName||r.name;b&&(d=`

Check the top-level render call using <`+b+">.")}return d}}function kn(r,d){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var b=Bo(d);if(Cn[b])return;Cn[b]=!0;var k="";r&&r._owner&&r._owner!==De.current&&(k=" It was passed a child from "+Z(r._owner.type)+"."),K(r),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,k),K(null)}}function vn(r,d){{if(typeof r!="object")return;if(Oe(r))for(var b=0;b<r.length;b++){var k=r[b];Fe(k)&&kn(k,d)}else if(Fe(r))r._store&&(r._store.validated=!0);else if(r){var T=N(r);if(typeof T=="function"&&T!==r.entries)for(var _=T.call(r),y;!(y=_.next()).done;)Fe(y.value)&&kn(y.value,d)}}}function Vo(r){{var d=r.type;if(d==null||typeof d=="string")return;var b;if(typeof d=="function")b=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===f||d.$$typeof===p))b=d.propTypes;else return;if(b){var k=Z(d);Co(b,r.props,"prop",k,r)}else if(d.PropTypes!==void 0&&!Ae){Ae=!0;var T=Z(d);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Lo(r){{for(var d=Object.keys(r.props),b=0;b<d.length;b++){var k=d[b];if(k!=="children"&&k!=="key"){K(r),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",k),K(null);break}}r.ref!==null&&(K(r),E("Invalid attribute `ref` supplied to `React.Fragment`."),K(null))}}function xn(r,d,b,k,T,_){{var y=Ve(r);if(!y){var x="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(x+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var I=Eo(T);I?x+=I:x+=pn();var B;r===null?B="null":Oe(r)?B="array":r!==void 0&&r.$$typeof===t?(B="<"+(Z(r.type)||"Unknown")+" />",x=" Did you accidentally export a JSX literal instead of a component?"):B=typeof r,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",B,x)}var L=wo(r,d,b,T,_);if(L==null)return L;if(y){var O=d.children;if(O!==void 0)if(k)if(Oe(O)){for(var J=0;J<O.length;J++)vn(O[J],r);Object.freeze&&Object.freeze(O)}else E("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 vn(O,r)}return r===o?Lo(L):Vo(L),L}}function Po(r,d,b){return xn(r,d,b,!0)}function Io(r,d,b){return xn(r,d,b,!1)}var No=Io,Oo=Po;ee.Fragment=o,ee.jsx=No,ee.jsxs=Oo}()),ee}process.env.NODE_ENV==="production"?Se.exports=Mn():Se.exports=_n();var a=Se.exports;function M(e){const t=A();if(!(t!=null&&t.editor))throw new Error("useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component");return t.editor}function le(e,t){const n=A();t||(t=n==null?void 0:n.editor),u.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onChange(e)},[e,t])}function ie(e,t){const n=A();t||(t=n==null?void 0:n.editor),u.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onSelectionChange(e)},[e,t])}function F(e,t){le(e,t),ie(e,t)}function te(e,t,n,o){const{refs:l,update:i,context:s,floatingStyles:c}=P.useFloating({open:e,...o}),{isMounted:f,styles:g}=P.useTransitionStyles(s),h=P.useDismiss(s),{getReferenceProps:p,getFloatingProps:C}=P.useInteractions([h]);return u.useEffect(()=>{i()},[t,i]),u.useEffect(()=>{t!==null&&l.setReference({getBoundingClientRect:()=>t})},[t,l]),u.useMemo(()=>({isMounted:f,ref:l.setFloating,style:{display:"flex",...g,...c,zIndex:n},getFloatingProps:C,getReferenceProps:p}),[c,f,l.setFloating,g,n,C,p])}function Y(e){const[t,n]=u.useState();return u.useEffect(()=>e(o=>{n({...o})}),[e]),t}function ze(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}const Ge=u.createContext(void 0);function S(){return u.useContext(Ge)}var We={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},qe=R.default.createContext&&R.default.createContext(We),z=globalThis&&globalThis.__assign||function(){return z=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},z.apply(this,arguments)},Hn=globalThis&&globalThis.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,o=Object.getOwnPropertySymbols(e);l<o.length;l++)t.indexOf(o[l])<0&&Object.prototype.propertyIsEnumerable.call(e,o[l])&&(n[o[l]]=e[o[l]]);return n};function $e(e){return e&&e.map(function(t,n){return R.default.createElement(t.tag,z({key:n},t.attr),$e(t.child))})}function w(e){return function(t){return R.default.createElement(wn,z({attr:z({},e.attr)},t),$e(e.child))}}function wn(e){var t=function(n){var o=e.attr,l=e.size,i=e.title,s=Hn(e,["attr","size","title"]),c=l||n.size||"1em",f;return n.className&&(f=n.className),e.className&&(f=(f?f+" ":"")+e.className),R.default.createElement("svg",z({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,o,s,{className:f,style:z(z({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),i&&R.default.createElement("title",null,i),e.children)};return qe!==void 0?R.default.createElement(qe.Consumer,null,function(n){return t(n)}):t(We)}function En(e){return w({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 Bn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z"}}]})(e)}function Vn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z"}}]})(e)}function Ln(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z"}}]})(e)}function Pn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z"}}]})(e)}function In(e){return w({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 Ye(e){return w({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 Ke(e){return w({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 Je(e){return w({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 Nn(e){return w({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 On(e){return w({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 Rn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z"}}]})(e)}function Dn(e){return w({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 Qe(e){return w({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 Xe(e){return w({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 et(e){return w({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 An(e){return w({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 Fn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z"}}]})(e)}function ne(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"}}]})(e)}function Zn(e){return w({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 Un(e){return w({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 zn(e){return w({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 Gn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z"}}]})(e)}function D(e){const t=A();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,l]=u.useState(()=>{var i;return((i=n.getSelection())==null?void 0:i.blocks)||[n.getTextCursorPosition().block]});return F(()=>{var i;return l(((i=n.getSelection())==null?void 0:i.blocks)||[n.getTextCursorPosition().block])},n),o}function H(){return A().editor.dictionary}const Wn={bold:In,italic:Rn,underline:Zn,strike:An,code:En};function qn(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema==="boolean"}const oe=e=>{const t=H(),n=S(),o=M(),l=qn(e.basicTextStyle,o),i=D(o),[s,c]=u.useState(e.basicTextStyle in o.getActiveStyles());F(()=>{l&&c(e.basicTextStyle in o.getActiveStyles())},o);const f=p=>{if(l){if(o.schema.styleSchema[p].propSchema!=="boolean")throw new Error("can only toggle boolean styles");o.toggleStyles({[p]:!0}),setTimeout(()=>{o.focus()})}};if(!u.useMemo(()=>l?!!i.find(p=>p.content!==void 0):!1,[l,i]))return null;const h=Wn[e.basicTextStyle];return a.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:v.formatKeyboardShortcut(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,t.generic.ctrl_shortcut),icon:a.jsx(h,{})})},Te=e=>{const t=e.textColor||"default",n=e.backgroundColor||"default",o=e.size||16,l=u.useMemo(()=>({pointerEvents:"none",fontSize:(o*.75).toString()+"px",height:o.toString()+"px",lineHeight:o.toString()+"px",textAlign:"center",width:o.toString()+"px"}),[o]);return a.jsx("div",{className:"bn-color-icon","data-background-color":n,"data-text-color":t,style:l,children:"A"})},tt=["default","gray","brown","red","orange","yellow","green","blue","purple","pink"],nt=e=>{const t=S(),n=H(),o=()=>e.text?a.jsxs(a.Fragment,{children:[a.jsx(t.Generic.Menu.Label,{children:n.color_picker.text_title}),tt.map(i=>a.jsx(t.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.text.setColor(i)},"data-test":"text-color-"+i,icon:a.jsx(Te,{textColor:i,size:e.iconSize}),checked:e.text.color===i,children:n.color_picker.colors[i]},"text-color-"+i))]}):null,l=()=>e.background?a.jsxs(a.Fragment,{children:[a.jsx(t.Generic.Menu.Label,{children:n.color_picker.background_title}),tt.map(i=>a.jsx(t.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.background.setColor(i)},"data-test":"background-color-"+i,icon:a.jsx(Te,{backgroundColor:i,size:e.iconSize}),checked:e.background.color===i,children:n.color_picker.colors[i]},"background-color-"+i))]}):null;return a.jsxs(a.Fragment,{children:[a.jsx(o,{}),a.jsx(l,{})]})};function ot(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 rt=()=>{const e=S(),t=H(),n=M(),o=ot("text",n),l=ot("background",n),i=D(n),[s,c]=u.useState(o&&n.getActiveStyles().textColor||"default"),[f,g]=u.useState(l&&n.getActiveStyles().backgroundColor||"default");F(()=>{o&&c(n.getActiveStyles().textColor||"default"),l&&g(n.getActiveStyles().backgroundColor||"default")},n);const h=u.useCallback(j=>{if(!o)throw Error("Tried to set text color, but style does not exist in editor schema.");j==="default"?n.removeStyles({textColor:j}):n.addStyles({textColor:j}),setTimeout(()=>{n.focus()})},[n,o]),p=u.useCallback(j=>{if(!l)throw Error("Tried to set background color, but style does not exist in editor schema.");j==="default"?n.removeStyles({backgroundColor:j}):n.addStyles({backgroundColor:j}),setTimeout(()=>{n.focus()})},[l,n]);return u.useMemo(()=>{if(!o&&!l)return!1;for(const j of i)if(j.content!==void 0)return!0;return!1},[l,i,o])?a.jsxs(e.Generic.Menu.Root,{children:[a.jsx(e.Generic.Menu.Trigger,{children:a.jsx(e.FormattingToolbar.Button,{className:"bn-button","data-test":"colors",label:t.formatting_toolbar.colors.tooltip,mainTooltip:t.formatting_toolbar.colors.tooltip,icon:a.jsx(Te,{textColor:s,backgroundColor:f,size:20})})}),a.jsx(e.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-color-picker-dropdown",children:a.jsx(nt,{text:o?{color:s,setColor:h}:void 0,background:l?{color:f,setColor:p}:void 0})})]}):null},je=e=>{const t=S(),n=H(),{url:o,text:l,editLink:i}=e,[s,c]=u.useState(o),[f,g]=u.useState(l);u.useEffect(()=>{c(o),g(l)},[l,o]);const h=u.useCallback(V=>{V.key==="Enter"&&(V.preventDefault(),i(s,f))},[i,s,f]),p=u.useCallback(V=>c(V.currentTarget.value),[]),C=u.useCallback(V=>g(V.currentTarget.value),[]),j=u.useCallback(()=>i(s,f),[i,s,f]);return a.jsxs(t.Generic.Form.Root,{children:[a.jsx(t.Generic.Form.TextInput,{className:"bn-text-input",name:"url",icon:a.jsx(Qe,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:s,onKeyDown:h,onChange:p,onSubmit:j}),a.jsx(t.Generic.Form.TextInput,{className:"bn-text-input",name:"title",icon:a.jsx(ne,{}),placeholder:n.link_toolbar.form.title_placeholder,value:f,onKeyDown:h,onChange:C,onSubmit:j})]})};function $n(e){return"link"in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link==="link"}const at=()=>{const e=M(),t=S(),n=H(),o=$n(e),l=D(e),[i,s]=u.useState(e.getSelectedLinkUrl()||""),[c,f]=u.useState(e.getSelectedText());F(()=>{f(e.getSelectedText()||""),s(e.getSelectedLinkUrl()||"")},e);const g=u.useCallback((p,C)=>{e.createLink(p,C),e.focus()},[e]);return!u.useMemo(()=>{if(!o)return!1;for(const p of l)if(p.content===void 0)return!1;return!0},[o,l])||!("link"in e.schema.inlineContentSchema)?null:a.jsxs(t.Generic.Popover.Root,{children:[a.jsx(t.Generic.Popover.Trigger,{children:a.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"createLink",label:n.formatting_toolbar.link.tooltip,mainTooltip:n.formatting_toolbar.link.tooltip,secondaryTooltip:v.formatKeyboardShortcut(n.formatting_toolbar.link.secondary_tooltip,n.generic.ctrl_shortcut),icon:a.jsx(Qe,{})})}),a.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:a.jsx(je,{url:i,text:c,editLink:g})})]})},lt=()=>{const e=H(),t=S(),n=M(),[o,l]=u.useState(),i=D(n),s=u.useMemo(()=>{if(i.length!==1)return;const g=i[0];if(v.checkBlockIsDefaultType("image",g,n))return l(g.props.caption),g},[n,i]),c=u.useCallback(g=>{s&&v.checkDefaultBlockTypeInSchema("image",n)&&g.key==="Enter"&&(g.preventDefault(),n.updateBlock(s,{type:"image",props:{caption:o}}))},[o,n,s]),f=u.useCallback(g=>l(g.currentTarget.value),[]);return s?a.jsxs(t.Generic.Popover.Root,{children:[a.jsx(t.Generic.Popover.Trigger,{children:a.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.image_caption.tooltip,mainTooltip:e.formatting_toolbar.image_caption.tooltip,icon:a.jsx(ne,{}),isSelected:s.props.caption!==""})}),a.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:a.jsx(t.Generic.Form.Root,{children:a.jsx(t.Generic.Form.TextInput,{name:"image-caption",icon:a.jsx(ne,{}),value:o||"",autoFocus:!0,placeholder:e.formatting_toolbar.image_caption.input_placeholder,onKeyDown:c,onChange:f})})})]}):null},it=()=>{const e=H(),t=S(),n=M(),o=D(n),[l,i]=u.useState(()=>n.canNestBlock());F(()=>{i(n.canNestBlock())},n);const s=u.useCallback(()=>{n.focus(),n.nestBlock()},[n]);return u.useMemo(()=>!o.find(f=>n.schema.blockSchema[f.type].content!=="inline"),[n.schema.blockSchema,o])?a.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"nestBlock",onClick:s,isDisabled:!l,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:v.formatKeyboardShortcut(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:a.jsx(On,{})}):null},st=()=>{const e=H(),t=S(),n=M(),o=D(n),[l,i]=u.useState(()=>n.canUnnestBlock());F(()=>{i(n.canUnnestBlock())},n);const s=u.useCallback(()=>{n.focus(),n.unnestBlock()},[n]);return u.useMemo(()=>!o.find(f=>n.schema.blockSchema[f.type].content!=="inline"),[n.schema.blockSchema,o])?a.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"unnestBlock",onClick:s,isDisabled:!l,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:v.formatKeyboardShortcut(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:a.jsx(Nn,{})}):null},ct=e=>{const t=S(),n=H(),{block:o}=e,l=M(),[i,s]=u.useState(""),c=u.useCallback(h=>{s(h.currentTarget.value)},[]),f=u.useCallback(h=>{h.key==="Enter"&&(h.preventDefault(),l.updateBlock(o,{type:"image",props:{url:i}}))},[l,o,i]),g=u.useCallback(()=>{l.updateBlock(o,{type:"image",props:{url:i}})},[l,o,i]);return a.jsxs(t.ImagePanel.TabPanel,{className:"bn-tab-panel",children:[a.jsx(t.ImagePanel.TextInput,{className:"bn-text-input",placeholder:n.image_panel.embed.url_placeholder,value:i,onChange:c,onKeyDown:f,"data-test":"embed-input"}),a.jsx(t.ImagePanel.Button,{className:"bn-button",onClick:g,"data-test":"embed-input-button",children:n.image_panel.embed.embed_button})]})},ut=e=>{const t=S(),n=H(),{block:o,setLoading:l}=e,i=M(),[s,c]=u.useState(!1);u.useEffect(()=>{s&&setTimeout(()=>{c(!1)},3e3)},[s]);const f=u.useCallback(g=>{if(g===null)return;async function h(p){if(l(!0),i.uploadFile!==void 0)try{const C=await i.uploadFile(p);i.updateBlock(o,{type:"image",props:{url:C}})}catch{c(!0)}finally{l(!1)}}h(g)},[o,i,l]);return a.jsxs(t.ImagePanel.TabPanel,{className:"bn-tab-panel",children:[a.jsx(t.ImagePanel.FileInput,{className:"bn-file-input","data-test":"upload-input",placeholder:n.image_panel.upload.file_placeholder,value:null,onChange:f}),s&&a.jsx("div",{className:"bn-error-text",children:n.image_panel.upload.upload_error})]})},Me=e=>{const t=S(),n=H(),o=M(),[l,i]=u.useState(!1),s=e.tabs??[...o.uploadFile!==void 0?[{name:n.image_panel.upload.title,tabPanel:a.jsx(ut,{block:e.block,setLoading:i})}]:[],{name:n.image_panel.embed.title,tabPanel:a.jsx(ct,{block:e.block})}],[c,f]=u.useState(e.defaultOpenTab||s[0].name);return a.jsx(t.ImagePanel.Root,{className:"bn-panel",defaultOpenTab:c,openTab:c,setOpenTab:f,tabs:s,loading:l})},dt=()=>{const e=H(),t=S(),n=M(),o=D(n),[l,i]=u.useState(!1);u.useEffect(()=>{i(!1)},[o]);const s=o.length===1?o[0]:void 0;return s===void 0||s.type!=="image"||!v.checkBlockIsDefaultType("image",s,n)?null:a.jsxs(t.Generic.Popover.Root,{opened:l,position:"bottom",children:[a.jsx(t.Generic.Popover.Trigger,{children:a.jsx(t.FormattingToolbar.Button,{className:"bn-button",onClick:()=>i(!l),isSelected:l,mainTooltip:e.formatting_toolbar.image_replace.tooltip,label:e.formatting_toolbar.image_replace.tooltip,icon:a.jsx(zn,{})})}),a.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-panel-popover",variant:"panel-popover",children:a.jsx(Me,{block:s})})]})},Yn={left:Ln,center:Bn,right:Pn,justify:Vn},se=e=>{const t=S(),n=H(),o=M(),l=D(o),i=u.useMemo(()=>{const g=l[0];if(v.checkBlockHasDefaultProp("textAlignment",g,o))return g.props.textAlignment},[o,l]),s=u.useCallback(g=>{for(const h of l)v.checkBlockTypeHasDefaultProp("textAlignment",h.type,o)&&o.updateBlock(h,{props:{textAlignment:g}});setTimeout(()=>{o.focus()})},[o,l]);if(!u.useMemo(()=>!!l.find(g=>"textAlignment"in g.props),[l]))return null;const f=Yn[e.textAlignment];return a.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>s(e.textAlignment),isSelected:i===e.textAlignment,label:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:a.jsx(f,{})})},ft=e=>[{name:e.slash_menu.paragraph.title,type:"paragraph",icon:ne,isSelected:t=>t.type==="paragraph"},{name:e.slash_menu.heading.title,type:"heading",props:{level:1},icon:Ye,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:Ke,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:Je,isSelected:t=>t.type==="heading"&&"level"in t.props&&t.props.level===3},{name:e.slash_menu.bullet_list.title,type:"bulletListItem",icon:et,isSelected:t=>t.type==="bulletListItem"},{name:e.slash_menu.numbered_list.title,type:"numberedListItem",icon:Xe,isSelected:t=>t.type==="numberedListItem"}],mt=e=>{const t=S(),n=H(),o=M(),l=D(o),[i,s]=u.useState(o.getTextCursorPosition().block),c=u.useMemo(()=>(e.items||ft(n)).filter(h=>h.type in o.schema.blockSchema),[o,n,e.items]),f=u.useMemo(()=>c.find(h=>h.type===i.type)!==void 0,[i.type,c]),g=u.useMemo(()=>{const h=p=>{o.focus();for(const C of l)o.updateBlock(C,{type:p.type,props:p.props})};return c.map(p=>{const C=p.icon;return{text:p.name,icon:a.jsx(C,{size:16}),onClick:()=>h(p),isSelected:p.isSelected(i)}})},[i,c,o,l]);return F(()=>{s(o.getTextCursorPosition().block)},o),f?a.jsx(t.FormattingToolbar.Select,{className:"bn-select",items:g}):null},gt=e=>[a.jsx(mt,{items:e},"blockTypeSelect"),a.jsx(lt,{},"imageCaptionButton"),a.jsx(dt,{},"replaceImageButton"),a.jsx(oe,{basicTextStyle:"bold"},"boldStyleButton"),a.jsx(oe,{basicTextStyle:"italic"},"italicStyleButton"),a.jsx(oe,{basicTextStyle:"underline"},"underlineStyleButton"),a.jsx(oe,{basicTextStyle:"strike"},"strikeStyleButton"),a.jsx(se,{textAlignment:"left"},"textAlignLeftButton"),a.jsx(se,{textAlignment:"center"},"textAlignCenterButton"),a.jsx(se,{textAlignment:"right"},"textAlignRightButton"),a.jsx(rt,{},"colorStyleButton"),a.jsx(it,{},"nestBlockButton"),a.jsx(st,{},"unnestBlockButton"),a.jsx(at,{},"createLinkButton")],ht=e=>{const t=S();return a.jsx(t.FormattingToolbar.Root,{className:"bn-toolbar bn-formatting-toolbar",children:e.children||gt(e.blockTypeSelectItems)})},bt=e=>{switch(e){case"left":return"top-start";case"center":return"top";case"right":return"top-end";default:return"top-start"}},pt=e=>{const t=u.useRef(null),n=M(),[o,l]=u.useState(()=>{const C=n.getTextCursorPosition().block;return"textAlignment"in C.props?bt(C.props.textAlignment):"top-start"});F(()=>{const C=n.getTextCursorPosition().block;"textAlignment"in C.props?l(bt(C.props.textAlignment)):l("top-start")},n);const i=Y(n.formattingToolbar.onUpdate.bind(n.formattingToolbar)),{isMounted:s,ref:c,style:f,getFloatingProps:g}=te((i==null?void 0:i.show)||!1,(i==null?void 0:i.referencePos)||null,3e3,{placement:o,middleware:[P.offset(10),P.flip()],onOpenChange:(C,j)=>{console.log("change",j),C||(n.formattingToolbar.closeMenu(),n.focus())}}),h=u.useMemo(()=>ze([t,c]),[t,c]);if(!s||!i)return null;if(!i.show&&t.current)return a.jsx("div",{ref:h,style:f,dangerouslySetInnerHTML:{__html:t.current.innerHTML}});const p=e.formattingToolbar||ht;return a.jsx("div",{ref:h,style:f,...g(),children:a.jsx(p,{})})},Ct=e=>{const t=M();if(!t.imagePanel)throw new Error("ImageToolbarController can only be used when BlockNote editor schema contains image block");const n=Y(t.imagePanel.onUpdate.bind(t.imagePanel)),{isMounted:o,ref:l,style:i,getFloatingProps:s}=te((n==null?void 0:n.show)||!1,(n==null?void 0:n.referencePos)||null,5e3,{placement:"bottom",middleware:[P.offset(10),P.flip()],onOpenChange:p=>{p||(t.imagePanel.closeMenu(),t.focus())}});if(!o||!n)return null;const{show:c,referencePos:f,...g}=n,h=e.imageToolbar||Me;return a.jsx("div",{ref:l,style:i,...s(),children:a.jsx(h,{...g})})},kt=e=>{const t=S(),n=H();return a.jsx(t.LinkToolbar.Button,{className:"bn-button",label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:e.deleteLink,icon:a.jsx(Dn,{})})},vt=e=>{const t=S(),n=H();return a.jsxs(t.Generic.Popover.Root,{children:[a.jsx(t.Generic.Popover.Trigger,{children:a.jsx(t.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.edit.tooltip,isSelected:!1,children:n.link_toolbar.edit.text})}),a.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:a.jsx(je,{...e})})]})},xt=e=>{const t=S(),n=H();return a.jsx(t.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(e.url,"_blank")},icon:a.jsx(Gn,{})})},yt=e=>{const t=S();return e.children?a.jsx(t.LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",children:e.children}):a.jsxs(t.LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",onMouseEnter:e.stopHideTimer,onMouseLeave:e.startHideTimer,children:[a.jsx(vt,{url:e.url,text:e.text,editLink:e.editLink}),a.jsx(xt,{url:e.url}),a.jsx(kt,{deleteLink:e.deleteLink})]})},St=e=>{const t=M(),n={deleteLink:t.linkToolbar.deleteLink,editLink:t.linkToolbar.editLink,startHideTimer:t.linkToolbar.startHideTimer,stopHideTimer:t.linkToolbar.stopHideTimer},o=Y(t.linkToolbar.onUpdate.bind(t.linkToolbar)),{isMounted:l,ref:i,style:s,getFloatingProps:c}=te((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,4e3,{placement:"top-start",middleware:[P.offset(10),P.flip()],onOpenChange:C=>{C||(t.linkToolbar.closeMenu(),t.focus())}});if(!l||!o)return null;const{show:f,referencePos:g,...h}=o,p=e.linkToolbar||yt;return a.jsx("div",{ref:i,style:s,...c(),children:a.jsx(p,{...h,...n})})};function Kn(e){return w({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 Tt=e=>{const t=S(),n=H();return a.jsx(t.SideMenu.Button,{className:"bn-button",label:n.side_menu.add_block_label,icon:a.jsx(Kn,{size:24,onClick:e.addBlock,"data-test":"dragHandleAdd"})})};function jt(e){return w({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 Mt=e=>{const t=S(),n=M();return!v.checkBlockTypeHasDefaultProp("textColor",e.block.type,n)&&!v.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,n)?null:a.jsxs(t.Generic.Menu.Root,{position:"right",sub:!0,children:[a.jsx(t.Generic.Menu.Trigger,{sub:!0,children:a.jsx(t.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:e.children})}),a.jsx(t.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:a.jsx(nt,{iconSize:18,text:v.checkBlockTypeHasDefaultProp("textColor",e.block.type,n)&&v.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:v.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,n)&&v.checkBlockHasDefaultProp("backgroundColor",e.block,n)?{color:e.block.props.backgroundColor,setColor:o=>n.updateBlock(e.block,{props:{backgroundColor:o}})}:void 0})})]})},_t=e=>{const t=S(),n=M();return a.jsx(t.Generic.Menu.Item,{className:"bn-menu-item",onClick:()=>n.removeBlocks([e.block]),children:e.children})},Ht=e=>{const t=S(),n=H();return a.jsx(t.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-drag-handle-menu",children:e.children||a.jsxs(a.Fragment,{children:[a.jsx(_t,{...e,children:n.drag_handle.delete_menuitem}),a.jsx(Mt,{...e,children:n.drag_handle.colors_menuitem})]})})},wt=e=>{const t=S(),n=H(),o=e.dragHandleMenu||Ht;return a.jsxs(t.Generic.Menu.Root,{onOpenChange:l=>{l?e.freezeMenu():(e.unfreezeMenu(),e.editor.focus())},position:"left",children:[a.jsx(t.Generic.Menu.Trigger,{children:a.jsx(t.SideMenu.Button,{label:n.side_menu.drag_handle_label,draggable:!0,onDragStart:e.blockDragStart,onDragEnd:e.blockDragEnd,className:"bn-button",icon:a.jsx(jt,{size:24,"data-test":"dragHandle"})})}),a.jsx(o,{block:e.block})]})},Et=e=>{const t=S(),{addBlock:n,...o}=e;return a.jsx(t.SideMenu.Root,{className:"bn-side-menu",children:e.children||a.jsxs(a.Fragment,{children:[a.jsx(Tt,{addBlock:n}),a.jsx(wt,{...o})]})})},Bt=e=>{const t=M(),n={addBlock:t.sideMenu.addBlock,blockDragStart:t.sideMenu.blockDragStart,blockDragEnd:t.sideMenu.blockDragEnd,freezeMenu:t.sideMenu.freezeMenu,unfreezeMenu:t.sideMenu.unfreezeMenu},o=Y(t.sideMenu.onUpdate.bind(t.sideMenu)),{isMounted:l,ref:i,style:s,getFloatingProps:c}=te((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,1e3,{placement:"left"});if(!l||!o)return null;const{show:f,referencePos:g,...h}=o,p=e.sideMenu||Et;return a.jsx("div",{ref:i,style:s,...c(),children:a.jsx(p,{...h,...n,editor:t})})};function Jn(e){const t=S(),n=H(),{items:o,loadingState:l,selectedIndex:i,onItemClick:s}=e,c=l==="loading-initial"||l==="loading"?a.jsx(t.SuggestionMenu.Loader,{className:"bn-suggestion-menu-loader",children:n.suggestion_menu.loading}):null,f=u.useMemo(()=>{let g;const h=[];for(let p=0;p<o.length;p++){const C=o[p];C.group!==g&&(g=C.group,h.push(a.jsx(t.SuggestionMenu.Label,{className:"bn-suggestion-menu-label",children:g},g))),h.push(a.jsx(t.SuggestionMenu.Item,{className:"bn-suggestion-menu-item",item:C,id:`bn-suggestion-menu-item-${p}`,isSelected:p===i,onClick:()=>s==null?void 0:s(C)},C.title))}return h},[t,o,s,i]);return a.jsxs(t.SuggestionMenu.Root,{id:"bn-suggestion-menu",className:"bn-suggestion-menu",children:[f,f.length===0&&(e.loadingState==="loading"||e.loadingState==="loaded")&&a.jsx(t.SuggestionMenu.EmptyItem,{className:"bn-suggestion-menu-item",children:n.suggestion_menu.no_items_title}),c]})}function Vt(e,t,n,o=3){const l=u.useRef(0);u.useEffect(()=>{t!==void 0&&(e.length>0?l.current=t.length:t.length-l.current>o&&n())},[n,o,e.length,t])}function Lt(e,t){const[n,o]=u.useState([]),[l,i]=u.useState(!1),s=u.useRef(),c=u.useRef();return u.useEffect(()=>{const f=e;s.current=e,i(!0),t(e).then(g=>{s.current===f&&(o(g),i(!1),c.current=f)})},[e,t]),{items:n||[],usedQuery:c.current,loadingState:c.current===void 0?"loading-initial":l?"loading":"loaded"}}function Pt(e,t,n,o){const[l,i]=u.useState(0);return u.useEffect(()=>{const s=c=>c.key==="ArrowUp"?(c.preventDefault(),n.length&&i((l-1+n.length)%n.length),!0):c.key==="ArrowDown"?(c.preventDefault(),n.length&&i((l+1)%n.length),!0):c.key==="Enter"?(c.preventDefault(),n.length&&(o==null||o(n[l])),!0):!1;return e.domElement.addEventListener("keydown",s,!0),()=>{e.domElement.removeEventListener("keydown",s,!0)}},[e.domElement,n,l,o]),u.useEffect(()=>{i(0)},[t]),{selectedIndex:n.length===0?void 0:l}}function It(e){const n=A().setContentEditableProps,o=M(),{getItems:l,suggestionMenuComponent:i,query:s,clearQuery:c,closeMenu:f,onItemClick:g}=e,h=u.useCallback(N=>{f(),c(),g==null||g(N)},[g,f,c]),{items:p,usedQuery:C,loadingState:j}=Lt(s,l);Vt(p,C,f);const{selectedIndex:V}=Pt(o,s,p,h);u.useEffect(()=>(n(N=>({...N,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{n(N=>({...N,"aria-expanded":!1,"aria-controls":void 0}))}),[n]),u.useEffect(()=>(n(N=>({...N,"aria-activedescendant":V?"bn-suggestion-menu-item-"+V:void 0})),()=>{n(N=>({...N,"aria-activedescendant":void 0}))}),[n,V]);const G=i;return a.jsx(G,{items:p,onItemClick:h,loadingState:j,selectedIndex:V})}const Qn={heading:Ye,heading_2:Ke,heading_3:Je,numbered_list:Xe,bullet_list:et,paragraph:ne,table:Fn,image:Un};function Nt(e){return v.getDefaultSlashMenuItems(e).map(t=>{const n=Qn[t.key];return{...t,icon:a.jsx(n,{size:18})}})}function Ot(e){const t=M(),{triggerCharacter:n,suggestionMenuComponent:o}=e;let{onItemClick:l,getItems:i}=e;l||(l=C=>{C.onItemClick(t)});const s={closeMenu:t.suggestionMenus.closeMenu,clearQuery:t.suggestionMenus.clearQuery},c=Y(C=>t.suggestionMenus.onUpdate.bind(t.suggestionMenus)(n,C)),{isMounted:f,ref:g,style:h,getFloatingProps:p}=te((c==null?void 0:c.show)||!1,(c==null?void 0:c.referencePos)||null,2e3,{placement:"bottom-start",middleware:[P.offset(10),P.flip(),P.size({apply({availableHeight:C,elements:j}){Object.assign(j.floating.style,{maxHeight:`${C-10}px`})}})],onOpenChange(C){C||t.suggestionMenus.closeMenu()}});return!f||!c?null:(i||(i=async C=>v.filterSuggestionItems(Nt(t),C)),a.jsx("div",{ref:g,style:h,...p(),children:a.jsx(It,{query:c.query,closeMenu:s.closeMenu,clearQuery:s.clearQuery,getItems:i,suggestionMenuComponent:o||Jn,onItemClick:l})}))}const Rt=e=>{const t=S(),n=H(),o=M();return a.jsx(t.Generic.Menu.Item,{onClick:()=>{const l=e.block.content.rows[e.index].cells.map(()=>[]),i=[...e.block.content.rows];i.splice(e.index+(e.side==="below"?1:0),0,{cells:l}),o.updateBlock(e.block,{type:"table",content:{type:"tableContent",rows:i}})},children:n.table_handle[`add_${e.side}_menuitem`]})},Dt=e=>{const t=S(),n=H(),o=M();return a.jsx(t.Generic.Menu.Item,{onClick:()=>{const l={type:"tableContent",rows:e.block.content.rows.map(i=>{const s=[...i.cells];return s.splice(e.index+(e.side==="right"?1:0),0,[]),{cells:s}})};o.updateBlock(e.block,{type:"table",content:l})},children:n.table_handle[`add_${e.side}_menuitem`]})},_e=e=>e.orientation==="row"?a.jsx(Rt,{...e,side:e.side}):a.jsx(Dt,{...e,side:e.side}),At=e=>{const t=S(),n=H(),o=M();return a.jsx(t.Generic.Menu.Item,{onClick:()=>{const l={type:"tableContent",rows:e.block.content.rows.filter((i,s)=>s!==e.index)};o.updateBlock(e.block,{type:"table",content:l})},children:n.table_handle.delete_row_menuitem})},Ft=e=>{const t=S(),n=H(),o=M();return a.jsx(t.Generic.Menu.Item,{onClick:()=>{const l={type:"tableContent",rows:e.block.content.rows.map(i=>({cells:i.cells.filter((s,c)=>c!==e.index)}))};o.updateBlock(e.block,{type:"table",content:l})},children:n.table_handle.delete_column_menuitem})},Zt=e=>e.orientation==="row"?a.jsx(At,{...e}):a.jsx(Ft,{...e}),Ut=e=>{const t=S();return a.jsx(t.Generic.Menu.Dropdown,{className:"bn-table-handle-menu",children:e.children||a.jsxs(a.Fragment,{children:[a.jsx(Zt,{orientation:e.orientation,block:e.block,index:e.index}),a.jsx(_e,{orientation:e.orientation,block:e.block,index:e.index,side:e.orientation==="row"?"above":"left"}),a.jsx(_e,{orientation:e.orientation,block:e.block,index:e.index,side:e.orientation==="row"?"below":"right"})]})})},zt=e=>{const t=S(),[n,o]=u.useState(!1),l=e.tableHandleMenu||Ut;return a.jsxs(t.Generic.Menu.Root,{onOpenChange:i=>{i?(e.freezeHandles(),e.hideOtherSide()):(e.unfreezeHandles(),e.showOtherSide(),e.editor.focus())},position:"right",children:[a.jsx(t.Generic.Menu.Trigger,{children:a.jsx(t.TableHandle.Root,{className:v.mergeCSSClasses("bn-table-handle",n?"bn-table-handle-dragging":""),draggable:!0,onDragStart:i=>{o(!0),e.dragStart(i)},onDragEnd:()=>{e.dragEnd(),o(!1)},style:e.orientation==="column"?{transform:"rotate(0.25turn)"}:void 0,children:e.children||a.jsx(jt,{size:24,"data-test":"tableHandle"})})}),a.jsx(l,{orientation:e.orientation,block:e.block,index:e.index})]})};function Xn(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 eo(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 Gt(e,t,n,o,l){const{refs:i,update:s,context:c,floatingStyles:f}=P.useFloating({open:t,placement:e==="row"?"left":"top",middleware:[P.offset(e==="row"?-10:-12)]}),{isMounted:g,styles:h}=P.useTransitionStyles(c);return u.useEffect(()=>{s()},[n,o,s]),u.useEffect(()=>{n===null||o===null||i.setReference({getBoundingClientRect:()=>(e==="row"?Xn:eo)(n,o,l)})},[l,e,n,o,i]),u.useMemo(()=>({isMounted:g,ref:i.setFloating,style:{display:"flex",...h,...f,zIndex:1e4}}),[f,g,i.setFloating,h])}function Wt(e,t,n,o){const l=Gt("row",e,t,n,o),i=Gt("col",e,t,n,o);return u.useMemo(()=>({rowHandle:l,colHandle:i}),[i,l])}const qt=e=>{var C,j;const t=M();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=Y(t.tableHandles.onUpdate.bind(t.tableHandles)),l=u.useMemo(()=>{var V,G;return o!=null&&o.draggingState?{draggedCellOrientation:(V=o==null?void 0:o.draggingState)==null?void 0:V.draggedCellOrientation,mousePos:(G=o==null?void 0:o.draggingState)==null?void 0:G.mousePos}:void 0},[o==null?void 0:o.draggingState,(C=o==null?void 0:o.draggingState)==null?void 0:C.draggedCellOrientation,(j=o==null?void 0:o.draggingState)==null?void 0:j.mousePos]),{rowHandle:i,colHandle:s}=Wt((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePosCell)||null,(o==null?void 0:o.referencePosTable)||null,l),[c,f]=u.useState(!1),[g,h]=u.useState(!1);if(!i.isMounted||!s.isMounted||!o)return null;const p=e.tableHandle||zt;return a.jsxs(a.Fragment,{children:[!c&&a.jsx("div",{ref:i.ref,style:i.style,children:a.jsx(p,{editor:t,orientation:"row",showOtherSide:()=>h(!1),hideOtherSide:()=>h(!0),index:o.rowIndex,block:o.block,dragStart:n.rowDragStart,dragEnd:n.dragEnd,freezeHandles:n.freezeHandles,unfreezeHandles:n.unfreezeHandles})}),!g&&a.jsx("div",{ref:s.ref,style:s.style,children:a.jsx(p,{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 $t(e){const t=M();if(!t)throw new Error("BlockNoteDefaultUI must be used within a BlockNoteContext.Provider");return a.jsxs(a.Fragment,{children:[e.formattingToolbar!==!1&&a.jsx(pt,{}),e.linkToolbar!==!1&&a.jsx(St,{}),e.slashMenu!==!1&&a.jsx(Ot,{triggerCharacter:"/"}),e.sideMenu!==!1&&a.jsx(Bt,{}),t.imagePanel&&e.imageToolbar!==!1&&a.jsx(Ct,{}),t.tableHandles&&e.tableHandles!==!1&&a.jsx(qt,{})]})}const to=({renderers:e})=>a.jsx(a.Fragment,{children:Object.entries(e).map(([t,n])=>Q.createPortal(n.reactElement,n.element,t))});function no(e){const[t,n]=u.useState({}),[o,l]=u.useState();return u.useEffect(()=>(e.editor._tiptapEditor.contentComponent={setRenderer(i,s){n(c=>({...c,[i]:s}))},removeRenderer(i){n(s=>{const c={...s};return delete c[i],c})},renderToElement(i,s){Q.flushSync(()=>{l({node:i,container:s})}),l(void 0)}},queueMicrotask(()=>{e.editor._tiptapEditor.createNodeViews()}),()=>{e.editor._tiptapEditor.contentComponent=null}),[e.editor._tiptapEditor]),a.jsxs(a.Fragment,{children:[a.jsx(to,{renderers:t}),o&&Q.createPortal(o.node,o.container),e.children]})}const Ro="",Yt=()=>{};function oo(e,t){const{editor:n,className:o,theme:l,children:i,editable:s,onSelectionChange:c,onChange:f,formattingToolbar:g,linkToolbar:h,slashMenu:p,sideMenu:C,imageToolbar:j,tableHandles:V,...G}=e,[N,W]=u.useState(),E=A(),we=Tn.default(),fe=(E==null?void 0:E.colorSchemePreference)||we,[me,Ee]=u.useState(void 0),ge=u.useCallback(Le=>{Le&&Ee(l||fe==="dark"?"dark":"light")},[fe,l]);le(f||Yt,n),ie(c||Yt,n),u.useEffect(()=>{n.isEditable=s!==!1},[s,n]);const Be=u.useMemo(()=>a.jsxs(a.Fragment,{children:[i,a.jsx($t,{formattingToolbar:g,linkToolbar:h,slashMenu:p,sideMenu:C,imageToolbar:j,tableHandles:V})]}),[i,g,h,j,C,p,V]),he=u.useMemo(()=>({...E,editor:n,setContentEditableProps:W}),[E,n]),Ve=u.useMemo(()=>ze([ge,t]),[ge,t]);return a.jsx(ye.Provider,{value:he,children:a.jsx(no,{editor:n,children:a.jsxs("div",{className:v.mergeCSSClasses("bn-container",me||"",o||""),"data-color-scheme":me,...G,ref:Ve,children:[a.jsx("div",{"aria-autocomplete":"list","aria-haspopup":"listbox",ref:n._tiptapEditor.mount,...N}),Be]})})})}const ro=R.default.forwardRef(oo);function ao(e){const t=A();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,l]=u.useState(()=>n.getActiveStyles());return le(()=>{l(n.getActiveStyles())},n),ie(()=>{l(n.getActiveStyles())},n),o}const Kt=(e={},t=[])=>u.useMemo(()=>{const n=v.BlockNoteEditor.create(e);return window&&(window.ProseMirror=n._tiptapEditor),n},t),lo=Kt;function io(){const[,e]=u.useState(0);return()=>e(t=>t+1)}const so=e=>{const t=io();u.useEffect(()=>{const n=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})};return e.on("transaction",n),()=>{e.off("transaction",n)}},[e])};var He,ce=jn.default;if(process.env.NODE_ENV==="production")He=ce.createRoot,ce.hydrateRoot;else{var Jt=ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;He=function(e,t){Jt.usingClientEntryPoint=!0;try{return ce.createRoot(e,t)}finally{Jt.usingClientEntryPoint=!1}}}function ue(e,t){let n;const o=document.createElement("div");let l;if(t?t._tiptapEditor.contentComponent.renderToElement(e(f=>n=f||void 0),o):(l=He(o),Q.flushSync(()=>{l.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 i=o.cloneNode(!0),s=i.firstElementChild,c=i.querySelector("[data-tmp-find]");return c==null||c.removeAttribute("data-tmp-find"),l==null||l.unmount(),{dom:s,contentDOM:c||void 0}}function de(e){var t;return a.jsx(q.NodeViewWrapper,{...Object.fromEntries(Object.entries(e.domAttributes||{}).filter(([n])=>n!=="class")),className:v.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])=>!v.inheritedProps.includes(n)&&o!==e.propSchema[n].default).map(([n,o])=>[v.camelToDataKebab(n),o])),children:e.children})}function co(e,t){const n=v.createStronglyTypedTiptapNode({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:!0,addAttributes(){return v.propsToAttributes(e.propSchema)},parseHTML(){return v.getParseRules(e,t.parse)},renderHTML(){const o=document.createElement("div");return o.setAttribute("data-tmp-placeholder","true"),{dom:o}},addNodeView(){return o=>q.ReactNodeViewRenderer(l=>{var h;const i=this.options.editor,s=v.getBlockFromPos(l.getPos,i,this.editor,e.type),c=((h=this.options.domAttributes)==null?void 0:h.blockContent)||{},f=q.NodeViewContent({}).ref,g=t.render;return a.jsx(de,{blockType:s.type,blockProps:s.props,propSchema:e.propSchema,domAttributes:c,children:a.jsx(g,{block:s,editor:i,contentRef:f})})},{className:"bn-react-node-view-renderer"})(o)}});return v.createInternalBlockSpec(e,{node:n,toInternalHTML:(o,l)=>{var f,g;const i=((f=n.options.domAttributes)==null?void 0:f.blockContent)||{},s=t.render,c=ue(h=>a.jsx(de,{blockType:o.type,blockProps:o.props,propSchema:e.propSchema,domAttributes:i,children:a.jsx(s,{block:o,editor:l,contentRef:h})}),l);return(g=c.contentDOM)==null||g.setAttribute("data-editable",""),c},toExternalHTML:(o,l)=>{var f,g;const i=((f=n.options.domAttributes)==null?void 0:f.blockContent)||{},s=t.toExternalHTML||t.render,c=ue(h=>a.jsx(de,{blockType:o.type,blockProps:o.props,propSchema:e.propSchema,domAttributes:i,children:a.jsx(s,{block:o,editor:l,contentRef:h})}),l);return(g=c.contentDOM)==null||g.setAttribute("data-editable",""),c}})}function Qt(e){return a.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])=>[v.camelToDataKebab(t),n])),children:e.children})}function uo(e,t){const n=v.createStronglyTypedTiptapNode({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return v.propsToAttributes(e.propSchema)},addKeyboardShortcuts(){return v.addInlineContentKeyboardShortcuts(e)},parseHTML(){return v.getInlineContentParseRules(e)},renderHTML({node:o}){const l=this.options.editor,i=v.nodeToCustomInlineContent(o,l.schema.inlineContentSchema,l.schema.styleSchema),s=t.render,c=ue(f=>a.jsx(s,{inlineContent:i,contentRef:f}),l);return v.addInlineContentAttributes(c,e.type,o.attrs,e.propSchema)},addNodeView(){const o=this.options.editor;return l=>q.ReactNodeViewRenderer(i=>{const s=q.NodeViewContent({}).ref,c=t.render;return a.jsx(Qt,{inlineContentProps:i.node.attrs,inlineContentType:e.type,propSchema:e.propSchema,children:a.jsx(c,{contentRef:s,inlineContent:v.nodeToCustomInlineContent(i.node,o.schema.inlineContentSchema,o.schema.styleSchema)})})},{className:"bn-ic-react-node-view-renderer",as:"span"})(l)}});return v.createInternalInlineContentSpec(e,{node:n})}function fo(e,t){const n=q.Mark.create({name:e.type,addAttributes(){return v.stylePropsToAttributes(e.propSchema)},parseHTML(){return v.getStyleParseRules(e)},renderHTML({mark:o}){const l={};e.propSchema==="string"&&(l.value=o.attrs.stringValue);const i=t.render,s=ue(c=>a.jsx(i,{...l,contentRef:c}),void 0);return v.addStyleAttributes(s,e.type,o.attrs.stringValue,e.propSchema)}});return v.createInternalStyleSpec(e,{mark:n})}m.AddBlockButton=Tt,m.AddButton=_e,m.AddColumnButton=Dt,m.AddRowButton=Rt,m.BasicTextStyleButton=oe,m.BlockColorsItem=Mt,m.BlockContentWrapper=de,m.BlockNoteContext=ye,m.BlockNoteDefaultUI=$t,m.BlockNoteViewRaw=ro,m.BlockTypeSelect=mt,m.ColorStyleButton=rt,m.ComponentsContext=Ge,m.CreateLinkButton=at,m.DeleteButton=Zt,m.DeleteColumnButton=Ft,m.DeleteLinkButton=kt,m.DeleteRowButton=At,m.DragHandleButton=wt,m.DragHandleMenu=Ht,m.EditLinkButton=vt,m.EditLinkMenuItems=je,m.EmbedTab=ct,m.FormattingToolbar=ht,m.FormattingToolbarController=pt,m.ImageCaptionButton=lt,m.ImagePanel=Me,m.ImagePanelController=Ct,m.InlineContentWrapper=Qt,m.LinkToolbar=yt,m.LinkToolbarController=St,m.NestBlockButton=it,m.OpenLinkButton=xt,m.RemoveBlockItem=_t,m.ReplaceImageButton=dt,m.SideMenu=Et,m.SideMenuController=Bt,m.SuggestionMenuController=Ot,m.SuggestionMenuWrapper=It,m.TableHandle=zt,m.TableHandleMenu=Ut,m.TableHandlesController=qt,m.TextAlignButton=se,m.UnnestBlockButton=st,m.UploadTab=ut,m.blockTypeSelectItems=ft,m.createReactBlockSpec=co,m.createReactInlineContentSpec=uo,m.createReactStyleSpec=fo,m.getDefaultReactSlashMenuItems=Nt,m.getFormattingToolbarItems=gt,m.useActiveStyles=ao,m.useBlockNote=lo,m.useBlockNoteContext=A,m.useBlockNoteEditor=M,m.useCloseSuggestionMenuNoItems=Vt,m.useComponentsContext=S,m.useCreateBlockNote=Kt,m.useDictionary=H,m.useEditorChange=le,m.useEditorContentOrSelectionChange=F,m.useEditorForceUpdate=so,m.useEditorSelectionChange=ie,m.useLoadSuggestionMenuItems=Lt,m.useSelectedBlocks=D,m.useSuggestionMenuKeyboardNavigation=Pt,m.useTableHandlesPositioning=Wt,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=blocknote-react.umd.cjs.map
