(function(h,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react"),require("@blocknote/core"),require("@mantine/core"),require("@tiptap/react"),require("use-prefers-color-scheme"),require("@floating-ui/react"),require("lodash.foreach"),require("lodash.groupby"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@blocknote/core","@mantine/core","@tiptap/react","use-prefers-color-scheme","@floating-ui/react","lodash.foreach","lodash.groupby","react-dom"],a):(h=typeof globalThis<"u"?globalThis:h||self,a(h["blocknote-react"]={},h.React,h.core$1,h.core,h.react$1,h.usePrefersColorScheme,h.react,h.foreach,h.groupBy,h.ReactDOM))})(this,function(h,a,C,b,K,dn,E,cn,un,ze){"use strict";const ee=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},R=ee(a),fn=ee(dn),gn=ee(cn),hn=ee(un),bn=ee(ze),Ze=(e,r,o=!1)=>{const i=[];function l(s,f="--bn"){for(const u in s){const c=u.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),v=`${f}-${c}`;typeof s[u]!="object"?(typeof s[u]=="number"&&(s[u]=`${s[u]}px`),o?r.style.removeProperty(v):r.style.setProperty(v,s[u].toString())):l(s[u],v)}}return l(e),i},ye=(e,r)=>Ze(e,r),mn={colors:{editor:{text:void 0,background:void 0},menu:{text:void 0,background:void 0},tooltip:{text:void 0,background:void 0},hovered:{text:void 0,background:void 0},selected:{text:void 0,background:void 0},disabled:{text:void 0,background:void 0},shadow:void 0,border:void 0,sideMenu:void 0,highlights:{gray:{text:void 0,background:void 0},brown:{text:void 0,background:void 0},red:{text:void 0,background:void 0},orange:{text:void 0,background:void 0},yellow:{text:void 0,background:void 0},green:{text:void 0,background:void 0},blue:{text:void 0,background:void 0},purple:{text:void 0,background:void 0},pink:{text:void 0,background:void 0}}},borderRadius:void 0,fontFamily:void 0},Ue=e=>Ze(mn,e,!0);var Se={exports:{}},te={};/**
 * @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 We;function vn(){if(We)return te;We=1;var e=R.default,r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function f(u,c,v){var k,S={},p=null,x=null;v!==void 0&&(p=""+v),c.key!==void 0&&(p=""+c.key),c.ref!==void 0&&(x=c.ref);for(k in c)i.call(c,k)&&!s.hasOwnProperty(k)&&(S[k]=c[k]);if(u&&u.defaultProps)for(k in c=u.defaultProps,c)S[k]===void 0&&(S[k]=c[k]);return{$$typeof:r,type:u,key:p,ref:x,props:S,_owner:l.current}}return te.Fragment=o,te.jsx=f,te.jsxs=f,te}var ne={};/**
 * @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 qe;function xn(){return qe||(qe=1,process.env.NODE_ENV!=="production"&&function(){var e=R.default,r=Symbol.for("react.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),A=Symbol.iterator,V="@@iterator";function z(t){if(t===null||typeof t!="object")return null;var d=A&&t[A]||t[V];return typeof d=="function"?d:null}var J=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function B(t){{for(var d=arguments.length,g=new Array(d>1?d-1:0),m=1;m<d;m++)g[m-1]=arguments[m];F("error",t,g)}}function F(t,d,g){{var m=J.ReactDebugCurrentFrame,H=m.getStackAddendum();H!==""&&(d+="%s",g=g.concat([H]));var M=g.map(function(T){return String(T)});M.unshift("Warning: "+d),Function.prototype.apply.call(console[t],console,M)}}var Z=!1,U=!1,ge=!1,he=!1,be=!1,_;_=Symbol.for("react.module.reference");function br(t){return!!(typeof t=="string"||typeof t=="function"||t===i||t===s||be||t===l||t===v||t===k||he||t===x||Z||U||ge||typeof t=="object"&&t!==null&&(t.$$typeof===p||t.$$typeof===S||t.$$typeof===f||t.$$typeof===u||t.$$typeof===c||t.$$typeof===_||t.getModuleId!==void 0))}function mr(t,d,g){var m=t.displayName;if(m)return m;var H=d.displayName||d.name||"";return H!==""?g+"("+H+")":g}function Ft(t){return t.displayName||"Context"}function W(t){if(t==null)return null;if(typeof t.tag=="number"&&B("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case i:return"Fragment";case o:return"Portal";case s:return"Profiler";case l:return"StrictMode";case v:return"Suspense";case k:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case u:var d=t;return Ft(d)+".Consumer";case f:var g=t;return Ft(g._context)+".Provider";case c:return mr(t,t.render,"ForwardRef");case S:var m=t.displayName||null;return m!==null?m:W(t.type)||"Memo";case p:{var H=t,M=H._payload,T=H._init;try{return W(T(M))}catch{return null}}}return null}var X=Object.assign,ie=0,Rt,Nt,zt,Zt,Ut,Wt,qt;function Kt(){}Kt.__reactDisabledLog=!0;function vr(){{if(ie===0){Rt=console.log,Nt=console.info,zt=console.warn,Zt=console.error,Ut=console.group,Wt=console.groupCollapsed,qt=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Kt,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}ie++}}function xr(){{if(ie--,ie===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:X({},t,{value:Rt}),info:X({},t,{value:Nt}),warn:X({},t,{value:zt}),error:X({},t,{value:Zt}),group:X({},t,{value:Ut}),groupCollapsed:X({},t,{value:Wt}),groupEnd:X({},t,{value:qt})})}ie<0&&B("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Pe=J.ReactCurrentDispatcher,Ie;function me(t,d,g){{if(Ie===void 0)try{throw Error()}catch(H){var m=H.stack.trim().match(/\n( *(at )?)/);Ie=m&&m[1]||""}return`
`+Ie+t}}var _e=!1,ve;{var kr=typeof WeakMap=="function"?WeakMap:Map;ve=new kr}function Yt(t,d){if(!t||_e)return"";{var g=ve.get(t);if(g!==void 0)return g}var m;_e=!0;var H=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var M;M=Pe.current,Pe.current=null,vr();try{if(d){var T=function(){throw Error()};if(Object.defineProperty(T.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(T,[])}catch(q){m=q}Reflect.construct(t,[],T)}else{try{T.call()}catch(q){m=q}t.call(T.prototype)}}else{try{throw Error()}catch(q){m=q}t()}}catch(q){if(q&&m&&typeof q.stack=="string"){for(var y=q.stack.split(`
`),P=m.stack.split(`
`),L=y.length-1,D=P.length-1;L>=1&&D>=0&&y[L]!==P[D];)D--;for(;L>=1&&D>=0;L--,D--)if(y[L]!==P[D]){if(L!==1||D!==1)do if(L--,D--,D<0||y[L]!==P[D]){var O=`
`+y[L].replace(" at new "," at ");return t.displayName&&O.includes("<anonymous>")&&(O=O.replace("<anonymous>",t.displayName)),typeof t=="function"&&ve.set(t,O),O}while(L>=1&&D>=0);break}}}finally{_e=!1,Pe.current=M,xr(),Error.prepareStackTrace=H}var $=t?t.displayName||t.name:"",sn=$?me($):"";return typeof t=="function"&&ve.set(t,sn),sn}function Cr(t,d,g){return Yt(t,!1)}function yr(t){var d=t.prototype;return!!(d&&d.isReactComponent)}function xe(t,d,g){if(t==null)return"";if(typeof t=="function")return Yt(t,yr(t));if(typeof t=="string")return me(t);switch(t){case v:return me("Suspense");case k:return me("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case c:return Cr(t.render);case S:return xe(t.type,d,g);case p:{var m=t,H=m._payload,M=m._init;try{return xe(M(H),d,g)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,Gt={},Jt=J.ReactDebugCurrentFrame;function Ce(t){if(t){var d=t._owner,g=xe(t.type,t._source,d?d.type:null);Jt.setExtraStackFrame(g)}else Jt.setExtraStackFrame(null)}function Sr(t,d,g,m,H){{var M=Function.call.bind(ke);for(var T in t)if(M(t,T)){var y=void 0;try{if(typeof t[T]!="function"){var P=Error((m||"React class")+": "+g+" type `"+T+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[T]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw P.name="Invariant Violation",P}y=t[T](d,T,m,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(L){y=L}y&&!(y instanceof Error)&&(Ce(H),B("%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).",m||"React class",g,T,typeof y),Ce(null)),y instanceof Error&&!(y.message in Gt)&&(Gt[y.message]=!0,Ce(H),B("Failed %s type: %s",g,y.message),Ce(null))}}}var Tr=Array.isArray;function Oe(t){return Tr(t)}function jr(t){{var d=typeof Symbol=="function"&&Symbol.toStringTag,g=d&&t[Symbol.toStringTag]||t.constructor.name||"Object";return g}}function Hr(t){try{return Xt(t),!1}catch{return!0}}function Xt(t){return""+t}function Qt(t){if(Hr(t))return B("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",jr(t)),Xt(t)}var ae=J.ReactCurrentOwner,wr={key:!0,ref:!0,__self:!0,__source:!0},$t,en,Ae;Ae={};function Mr(t){if(ke.call(t,"ref")){var d=Object.getOwnPropertyDescriptor(t,"ref").get;if(d&&d.isReactWarning)return!1}return t.ref!==void 0}function Er(t){if(ke.call(t,"key")){var d=Object.getOwnPropertyDescriptor(t,"key").get;if(d&&d.isReactWarning)return!1}return t.key!==void 0}function pr(t,d){if(typeof t.ref=="string"&&ae.current&&d&&ae.current.stateNode!==d){var g=W(ae.current.type);Ae[g]||(B('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',W(ae.current.type),t.ref),Ae[g]=!0)}}function Vr(t,d){{var g=function(){$t||($t=!0,B("%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))};g.isReactWarning=!0,Object.defineProperty(t,"key",{get:g,configurable:!0})}}function Br(t,d){{var g=function(){en||(en=!0,B("%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))};g.isReactWarning=!0,Object.defineProperty(t,"ref",{get:g,configurable:!0})}}var Lr=function(t,d,g,m,H,M,T){var y={$$typeof:r,type:t,key:d,ref:g,props:T,_owner:M};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:H}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function Dr(t,d,g,m,H){{var M,T={},y=null,P=null;g!==void 0&&(Qt(g),y=""+g),Er(d)&&(Qt(d.key),y=""+d.key),Mr(d)&&(P=d.ref,pr(d,H));for(M in d)ke.call(d,M)&&!wr.hasOwnProperty(M)&&(T[M]=d[M]);if(t&&t.defaultProps){var L=t.defaultProps;for(M in L)T[M]===void 0&&(T[M]=L[M])}if(y||P){var D=typeof t=="function"?t.displayName||t.name||"Unknown":t;y&&Vr(T,D),P&&Br(T,D)}return Lr(t,y,P,H,m,ae.current,T)}}var Fe=J.ReactCurrentOwner,tn=J.ReactDebugCurrentFrame;function Q(t){if(t){var d=t._owner,g=xe(t.type,t._source,d?d.type:null);tn.setExtraStackFrame(g)}else tn.setExtraStackFrame(null)}var Re;Re=!1;function Ne(t){return typeof t=="object"&&t!==null&&t.$$typeof===r}function nn(){{if(Fe.current){var t=W(Fe.current.type);if(t)return`

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

Check your code at `+d+":"+g+"."}return""}}var rn={};function Ir(t){{var d=nn();if(!d){var g=typeof t=="string"?t:t.displayName||t.name;g&&(d=`

Check the top-level render call using <`+g+">.")}return d}}function on(t,d){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var g=Ir(d);if(rn[g])return;rn[g]=!0;var m="";t&&t._owner&&t._owner!==Fe.current&&(m=" It was passed a child from "+W(t._owner.type)+"."),Q(t),B('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,m),Q(null)}}function an(t,d){{if(typeof t!="object")return;if(Oe(t))for(var g=0;g<t.length;g++){var m=t[g];Ne(m)&&on(m,d)}else if(Ne(t))t._store&&(t._store.validated=!0);else if(t){var H=z(t);if(typeof H=="function"&&H!==t.entries)for(var M=H.call(t),T;!(T=M.next()).done;)Ne(T.value)&&on(T.value,d)}}}function _r(t){{var d=t.type;if(d==null||typeof d=="string")return;var g;if(typeof d=="function")g=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===c||d.$$typeof===S))g=d.propTypes;else return;if(g){var m=W(d);Sr(g,t.props,"prop",m,t)}else if(d.PropTypes!==void 0&&!Re){Re=!0;var H=W(d);B("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",H||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&B("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Or(t){{for(var d=Object.keys(t.props),g=0;g<d.length;g++){var m=d[g];if(m!=="children"&&m!=="key"){Q(t),B("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",m),Q(null);break}}t.ref!==null&&(Q(t),B("Invalid attribute `ref` supplied to `React.Fragment`."),Q(null))}}function ln(t,d,g,m,H,M){{var T=br(t);if(!T){var y="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var P=Pr(H);P?y+=P:y+=nn();var L;t===null?L="null":Oe(t)?L="array":t!==void 0&&t.$$typeof===r?(L="<"+(W(t.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):L=typeof t,B("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",L,y)}var D=Dr(t,d,g,H,M);if(D==null)return D;if(T){var O=d.children;if(O!==void 0)if(m)if(Oe(O)){for(var $=0;$<O.length;$++)an(O[$],t);Object.freeze&&Object.freeze(O)}else B("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 an(O,t)}return t===i?Or(D):_r(D),D}}function Ar(t,d,g){return ln(t,d,g,!0)}function Fr(t,d,g){return ln(t,d,g,!1)}var Rr=Fr,Nr=Ar;ne.Fragment=i,ne.jsx=Rr,ne.jsxs=Nr}()),ne}process.env.NODE_ENV==="production"?Se.exports=vn():Se.exports=xn();var n=Se.exports;function Te(e,r){a.useEffect(()=>(e._tiptapEditor.on("update",r),()=>{e._tiptapEditor.off("update",r)}),[r,e._tiptapEditor])}function je(e,r){a.useEffect(()=>(e._tiptapEditor.on("selectionUpdate",r),()=>{e._tiptapEditor.off("selectionUpdate",r)}),[r,e._tiptapEditor])}function N(e,r){Te(e,r),je(e,r)}const le=a.forwardRef((e,r)=>{const{className:o,children:i,...l}=e;return n.jsx(b.Group,{className:C.mergeCSSClasses("bn-toolbar",o||""),ref:r,...l,children:i})}),He=e=>{const r=e.textColor||"default",o=e.backgroundColor||"default",i=e.size||16,l=a.useMemo(()=>({pointerEvents:"none",fontSize:(i*.75).toString()+"px",height:i.toString()+"px",lineHeight:i.toString()+"px",textAlign:"center",width:i.toString()+"px"}),[i]);return n.jsx(b.Box,{className:"bn-color-icon","data-background-color":o,"data-text-color":r,style:l,children:"A"})};var Ke={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ye=R.default.createContext&&R.default.createContext(Ke),Y=globalThis&&globalThis.__assign||function(){return Y=Object.assign||function(e){for(var r,o=1,i=arguments.length;o<i;o++){r=arguments[o];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e},Y.apply(this,arguments)},kn=globalThis&&globalThis.__rest||function(e,r){var o={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&r.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,i=Object.getOwnPropertySymbols(e);l<i.length;l++)r.indexOf(i[l])<0&&Object.prototype.propertyIsEnumerable.call(e,i[l])&&(o[i[l]]=e[i[l]]);return o};function Ge(e){return e&&e.map(function(r,o){return R.default.createElement(r.tag,Y({key:o},r.attr),Ge(r.child))})}function w(e){return function(r){return R.default.createElement(Cn,Y({attr:Y({},e.attr)},r),Ge(e.child))}}function Cn(e){var r=function(o){var i=e.attr,l=e.size,s=e.title,f=kn(e,["attr","size","title"]),u=l||o.size||"1em",c;return o.className&&(c=o.className),e.className&&(c=(c?c+" ":"")+e.className),R.default.createElement("svg",Y({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},o.attr,i,f,{className:c,style:Y(Y({color:e.color||o.color},o.style),e.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),s&&R.default.createElement("title",null,s),e.children)};return Ye!==void 0?R.default.createElement(Ye.Consumer,null,function(o){return r(o)}):r(Ke)}function we(e){return w({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M16.972 6.251c-.967-.538-2.185-.188-2.72.777l-3.713 6.682-2.125-2.125c-.781-.781-2.047-.781-2.828 0-.781.781-.781 2.047 0 2.828l4 4c.378.379.888.587 1.414.587l.277-.02c.621-.087 1.166-.46 1.471-1.009l5-9c.537-.966.189-2.183-.776-2.72z"}}]})(e)}const Je=e=>{const r=()=>e.text?n.jsxs(n.Fragment,{children:[n.jsx(b.Menu.Label,{children:"Text"}),["default","gray","brown","red","orange","yellow","green","blue","purple","pink"].map(i=>n.jsx(b.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.text.setColor(i)},component:"div","data-test":"text-color-"+i,leftSection:n.jsx(He,{textColor:i,size:e.iconSize}),rightSection:e.text.color===i?n.jsx(we,{size:20,className:"bn-tick-icon"}):n.jsx("div",{className:"bn-tick-space"}),children:i.charAt(0).toUpperCase()+i.slice(1)},"text-color-"+i))]}):null,o=()=>e.background?n.jsxs(n.Fragment,{children:[n.jsx(b.Menu.Label,{children:"Background"}),["default","gray","brown","red","orange","yellow","green","blue","purple","pink"].map(i=>n.jsx(b.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.background.setColor(i)},component:"div","data-test":"background-color-"+i,leftSection:n.jsx(He,{backgroundColor:i,size:e.iconSize}),rightSection:e.background.color===i?n.jsx(we,{size:20,className:"bn-tick-icon"}):n.jsx("div",{className:"bn-tick-space"}),children:i.charAt(0).toUpperCase()+i.slice(1)},"background-color-"+i))]}):null;return n.jsxs(n.Fragment,{children:[n.jsx(r,{}),n.jsx(o,{})]})},yn=e=>n.jsxs(b.Stack,{gap:0,className:"bn-tooltip",children:[n.jsx(b.Text,{size:"sm",children:e.mainTooltip}),e.secondaryTooltip&&n.jsx(b.Text,{size:"xs",children:e.secondaryTooltip})]}),I=a.forwardRef((e,r)=>{const o=e.icon;return n.jsx(b.Tooltip,{withinPortal:!1,label:n.jsx(yn,{mainTooltip:e.mainTooltip,secondaryTooltip:e.secondaryTooltip}),children:e.children?n.jsxs(b.Button,{onClick:e.onClick,"data-selected":e.isSelected?"true":void 0,"data-test":e.mainTooltip.slice(0,1).toLowerCase()+e.mainTooltip.replace(/\s+/g,"").slice(1),size:"xs",disabled:e.isDisabled||!1,ref:r,children:[o&&n.jsx(o,{}),e.children]}):n.jsx(b.ActionIcon,{onClick:e.onClick,"data-selected":e.isSelected?"true":void 0,"data-test":e.mainTooltip.slice(0,1).toLowerCase()+e.mainTooltip.replace(/\s+/g,"").slice(1),size:30,disabled:e.isDisabled||!1,ref:r,children:o&&n.jsx(o,{})})})});function Me(){const e=a.useRef(null);return{ref:e,updateMaxHeight:()=>{setTimeout(()=>{if(e.current&&e.current.childElementCount>0){e.current.firstElementChild.style.maxHeight="none";const r=e.current.firstElementChild.getBoundingClientRect();e.current.firstElementChild.style.maxHeight=`${Math.min(r.top>=0?window.innerHeight-r.top-20:r.bottom-20)}px`}},10)}}}function G(e){const[r,o]=a.useState(()=>{var i;return((i=e.getSelection())==null?void 0:i.blocks)||[e.getTextCursorPosition().block]});return N(e,()=>{var i;return o(((i=e.getSelection())==null?void 0:i.blocks)||[e.getTextCursorPosition().block])}),r}const Xe=e=>{const r=G(e.editor),[o,i]=a.useState(e.editor.getActiveStyles().textColor||"default"),[l,s]=a.useState(e.editor.getActiveStyles().backgroundColor||"default");N(e.editor,()=>{i(e.editor.getActiveStyles().textColor||"default"),s(e.editor.getActiveStyles().backgroundColor||"default")});const{ref:f,updateMaxHeight:u}=Me(),c=a.useCallback(S=>{e.editor.focus(),S==="default"?e.editor.removeStyles({textColor:S}):e.editor.addStyles({textColor:S})},[e.editor]),v=a.useCallback(S=>{e.editor.focus(),S==="default"?e.editor.removeStyles({backgroundColor:S}):e.editor.addStyles({backgroundColor:S})},[e.editor]);return a.useMemo(()=>{for(const S of r)if(S.content!==void 0)return!0;return!1},[r])?n.jsxs(b.Menu,{withinPortal:!1,onOpen:u,children:[n.jsx(b.Menu.Target,{children:n.jsx(I,{mainTooltip:"Colors",icon:()=>n.jsx(He,{textColor:o,backgroundColor:l,size:20})})}),n.jsx("div",{ref:f,children:n.jsx(b.Menu.Dropdown,{children:n.jsx(Je,{text:{color:o,setColor:c},background:{color:l,setColor:v}})})})]}):null};function Sn(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 Tn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z"}}]})(e)}function jn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z"}}]})(e)}function Hn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z"}}]})(e)}function wn(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z"}}]})(e)}function Mn(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 Qe(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 $e(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 et(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 En(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 pn(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 Vn(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 Bn(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 tt(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 nt(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 rt(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 Ln(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 Dn(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 re(e){return w({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"}}]})(e)}function Pn(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 In(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 _n(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 On(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)}const ot=e=>{const[r,o]=a.useState(!1),i=a.useCallback(()=>{o(!1)},[]),l=a.useCallback(()=>{o(!0)},[]);return n.jsxs(b.Popover,{withinPortal:!1,onOpen:()=>{l()},onClose:()=>{i()},zIndex:1e4,...e,children:[n.jsx(b.Popover.Target,{children:e.target}),n.jsx(b.Popover.Dropdown,{children:r?e.dropdown:null})]})},it=a.forwardRef(({className:e,...r},o)=>n.jsx(b.Stack,{...r,className:C.mergeCSSClasses("bn-toolbar-input-dropdown",e||""),ref:o,children:r.children})),An={text:b.TextInput,file:b.FileInput},Ee=e=>{const r=e.icon,o=An[e.type];return n.jsx(b.Group,{children:n.jsx(o,{size:"xs",icon:n.jsx(r,{}),...e.inputProps})})},at=a.forwardRef(({url:e,text:r,update:o,...i},l)=>{const[s,f]=a.useState(e),[u,c]=a.useState(r);a.useEffect(()=>{f(e),c(r)},[r,e]);const v=a.useCallback(x=>{x.key==="Enter"&&(x.preventDefault(),o(s,u))},[o,s,u]),k=a.useCallback(x=>f(x.currentTarget.value),[]),S=a.useCallback(x=>c(x.currentTarget.value),[]),p=a.useCallback(()=>o(s,u),[o,s,u]);return n.jsxs(it,{...i,ref:l,children:[n.jsx(Ee,{type:"text",icon:tt,inputProps:{autoFocus:!0,placeholder:"Edit URL",value:s,onKeyDown:v,onChange:k,onSubmit:p}}),n.jsx(Ee,{type:"text",icon:re,inputProps:{placeholder:"Edit Title",value:u,onKeyDown:v,onChange:S,onSubmit:p}})]})}),lt=e=>{const r=G(e.editor),[o,i]=a.useState(e.editor.getSelectedLinkUrl()||""),[l,s]=a.useState(e.editor.getSelectedText());N(e.editor,()=>{s(e.editor.getSelectedText()||""),i(e.editor.getSelectedLinkUrl()||"")});const f=a.useCallback((c,v)=>{e.editor.createLink(c,v),e.editor.focus()},[e.editor]);return a.useMemo(()=>{for(const c of r)if(c.content===void 0)return!1;return!0},[r])?n.jsx(ot,{target:n.jsx(I,{mainTooltip:"Create Link",secondaryTooltip:C.formatKeyboardShortcut("Mod+K"),icon:tt}),dropdown:n.jsx(at,{url:o,text:l,update:f})}):null},st=e=>{const r=G(e.editor),o=a.useMemo(()=>r.length===1&&r[0].type==="image"&&"caption"in e.editor.blockSchema.image.propSchema&&typeof e.editor.blockSchema.image.propSchema.caption.default=="string"&&e.editor.blockSchema.image.propSchema.caption.values===void 0&&"url"in e.editor.blockSchema.image.propSchema&&typeof e.editor.blockSchema.image.propSchema.url.default=="string"&&e.editor.blockSchema.image.propSchema.url.values===void 0&&r[0].props.url!=="",[e.editor.blockSchema,r]),[i,l]=a.useState(o?r[0].props.caption:"");a.useEffect(()=>l(o?r[0].props.caption:""),[r,o]);const s=a.useCallback(u=>{u.key==="Enter"&&(u.preventDefault(),e.editor.updateBlock(r[0],{type:"image",props:{caption:i}}))},[i,e.editor,r]),f=a.useCallback(u=>l(u.currentTarget.value),[]);return o?n.jsx(ot,{target:n.jsx(I,{mainTooltip:"Edit Caption",icon:re,isSelected:r[0].props.caption!==""}),dropdown:n.jsx(it,{children:n.jsx(Ee,{type:"text",icon:re,inputProps:{autoFocus:!0,placeholder:"Edit Caption",value:i,onKeyDown:s,onChange:f}})})}):null},dt=e=>{const[r,o]=a.useState(()=>e.editor.canNestBlock());N(e.editor,()=>{e.editor.canNestBlock(),o(e.editor.canNestBlock())});const i=a.useCallback(()=>{e.editor.focus(),e.editor.nestBlock()},[e.editor]);return n.jsx(I,{onClick:i,isDisabled:!r,mainTooltip:"Nest Block",secondaryTooltip:C.formatKeyboardShortcut("Tab"),icon:pn})},ct=e=>{const[r,o]=a.useState(()=>e.editor.canUnnestBlock());N(e.editor,()=>{o(e.editor.canUnnestBlock())});const i=a.useCallback(()=>{e.editor.focus(),e.editor.unnestBlock()},[e]);return n.jsx(I,{onClick:i,isDisabled:!r,mainTooltip:"Unnest Block",secondaryTooltip:C.formatKeyboardShortcut("Shift+Tab"),icon:En})},pe=e=>{const[r,o]=a.useState(e.editor.uploadFile!==void 0?"upload":"embed"),[i,l]=a.useState(!1),[s,f]=a.useState(!1);a.useEffect(()=>{s&&setTimeout(()=>{f(!1)},3e3)},[s]);const u=a.useCallback(x=>{if(x===null)return;async function A(V){if(l(!0),e.editor.uploadFile!==void 0)try{const z=await e.editor.uploadFile(V);e.editor.updateBlock(e.block,{type:"image",props:{url:z}})}catch{f(!0)}finally{l(!1)}}A(x)},[e.block,e.editor]),[c,v]=a.useState(""),k=a.useCallback(x=>{v(x.currentTarget.value)},[]),S=a.useCallback(x=>{x.key==="Enter"&&(x.preventDefault(),e.editor.updateBlock(e.block,{type:"image",props:{url:c}}))},[c,e.block,e.editor]),p=a.useCallback(()=>{e.editor.updateBlock(e.block,{type:"image",props:{url:c}})},[c,e.block,e.editor]);return n.jsx(le,{className:"bn-image-toolbar",children:n.jsxs(b.Tabs,{value:r,onChange:o,children:[i&&n.jsx(b.LoadingOverlay,{visible:i}),n.jsxs(b.Tabs.List,{children:[e.editor.uploadFile!==void 0&&n.jsx(b.Tabs.Tab,{value:"upload","data-test":"upload-tab",children:"Upload"}),n.jsx(b.Tabs.Tab,{value:"embed","data-test":"embed-tab",children:"Embed"})]}),e.editor.uploadFile!==void 0&&n.jsx(b.Tabs.Panel,{className:"bn-upload-image-panel",value:"upload",children:n.jsxs("div",{children:[n.jsx(b.FileInput,{placeholder:"Upload Image",size:"xs",value:null,onChange:u,"data-test":"upload-input"}),s&&n.jsx(b.Text,{c:"red",size:"12px",children:"Error: Upload failed"})]})}),n.jsx(b.Tabs.Panel,{className:"bn-embed-image-panel",value:"embed",children:n.jsxs("div",{children:[n.jsx(b.TextInput,{size:"xs",placeholder:"Enter URL",value:c,onChange:k,onKeyDown:S,"data-test":"embed-input"}),n.jsx(b.Button,{className:"bn-embed-image-button",onClick:p,size:"xs","data-test":"embed-input-button",children:"Embed Image"})]})})]})})},ut=e=>{const r=G(e.editor),[o,i]=a.useState(!1);return a.useEffect(()=>{i(!1)},[r]),r.length===1&&r[0].type==="image"?n.jsxs(b.Popover,{withinPortal:!1,opened:o,position:"bottom",children:[n.jsx(b.Popover.Target,{children:n.jsx(I,{onClick:()=>i(!o),isSelected:o,mainTooltip:"Replace Image",icon:_n})}),n.jsx(b.Popover.Dropdown,{children:n.jsx(pe,{block:r[0],editor:e.editor})})]}):null},Fn={left:Hn,center:Tn,right:wn,justify:jn},se=e=>{const r=G(e.editor),o=a.useMemo(()=>{const s=r[0];if("textAlignment"in s.props)return s.props.textAlignment},[r]),i=a.useCallback(s=>{e.editor.focus();for(const f of r)e.editor.updateBlock(f,{props:{textAlignment:s}})},[e.editor,r]);return a.useMemo(()=>!!r.find(s=>"textAlignment"in s.props),[r])?n.jsx(I,{onClick:()=>i(e.textAlignment),isSelected:o===e.textAlignment,mainTooltip:e.textAlignment==="justify"?"Justify Text":"Align Text "+e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1),icon:Fn[e.textAlignment]}):null},Rn={bold:"Mod+B",italic:"Mod+I",underline:"Mod+U",strike:"Mod+Shift+X",code:""},Nn={bold:Mn,italic:Vn,underline:Pn,strike:Ln,code:Sn},oe=e=>{const r=G(e.editor),[o,i]=a.useState(e.toggledStyle in e.editor.getActiveStyles());N(e.editor,()=>{i(e.toggledStyle in e.editor.getActiveStyles())});const l=f=>{if(e.editor.focus(),e.editor.styleSchema[f].propSchema!=="boolean")throw new Error("can only toggle boolean styles");e.editor.toggleStyles({[f]:!0})};return a.useMemo(()=>!!r.find(f=>f.content!==void 0),[r])?n.jsx(I,{onClick:()=>l(e.toggledStyle),isSelected:o,mainTooltip:e.toggledStyle.slice(0,1).toUpperCase()+e.toggledStyle.slice(1),secondaryTooltip:C.formatKeyboardShortcut(Rn[e.toggledStyle]),icon:Nn[e.toggledStyle]}):null};function zn(e){const r=e.icon;return n.jsx(b.Menu.Item,{onClick:e.onClick,leftSection:r&&n.jsx(r,{size:16}),rightSection:e.isSelected?n.jsx(we,{size:20,className:"bn-tick-icon"}):n.jsx("div",{className:"bn-tick-space"}),disabled:e.isDisabled,children:e.text},e.text)}function Zn(e){return w({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"}}]})(e)}function Un(e){return w({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"}}]})(e)}const Wn=a.forwardRef((e,r)=>{const o=e.icon;return n.jsx(b.Button,{leftSection:o&&n.jsx(o,{size:16}),rightSection:n.jsx(Zn,{}),size:"xs",variant:"subtle",disabled:e.isDisabled,onClick:e.onClick,ref:r,children:e.text})});function ft(e){const r=e.items.filter(l=>l.isSelected)[0],{ref:o,updateMaxHeight:i}=Me();return r?n.jsxs(b.Menu,{withinPortal:!1,transitionProps:{exitDuration:0},disabled:e.isDisabled,onOpen:i,children:[n.jsx(b.Menu.Target,{children:n.jsx(Wn,{text:r.text,icon:r.icon,isDisabled:r.isDisabled})}),n.jsx("div",{ref:o,children:n.jsx(b.Menu.Dropdown,{children:e.items.map(l=>n.jsx(zn,{...l},l.text))})})]}):null}const gt=[{name:"Paragraph",type:"paragraph",icon:re,isSelected:e=>e.type==="paragraph"},{name:"Heading 1",type:"heading",props:{level:1},icon:Qe,isSelected:e=>e.type==="heading"&&"level"in e.props&&e.props.level===1},{name:"Heading 2",type:"heading",props:{level:2},icon:$e,isSelected:e=>e.type==="heading"&&"level"in e.props&&e.props.level===2},{name:"Heading 3",type:"heading",props:{level:3},icon:et,isSelected:e=>e.type==="heading"&&"level"in e.props&&e.props.level===3},{name:"Bullet List",type:"bulletListItem",icon:rt,isSelected:e=>e.type==="bulletListItem"},{name:"Numbered List",type:"numberedListItem",icon:nt,isSelected:e=>e.type==="numberedListItem"}],ht=e=>{const r=G(e.editor),[o,i]=a.useState(e.editor.getTextCursorPosition().block),l=a.useMemo(()=>(e.items||gt).filter(u=>{if(!(u.type in e.editor.blockSchema))return!1;for(const[c,v]of Object.entries(u.props||{})){const k=e.editor.blockSchema[u.type].propSchema;if(!(c in k)||k[c].values!==void 0&&!k[c].values.includes(v))return!1}return!0}),[e.editor,e.items]),s=a.useMemo(()=>l.find(u=>u.type===o.type)!==void 0,[o.type,l]),f=a.useMemo(()=>{const u=c=>{e.editor.focus();for(const v of r)e.editor.updateBlock(v,{type:c.type,props:c.props})};return l.map(c=>({text:c.name,icon:c.icon,onClick:()=>u(c),isSelected:c.isSelected(o)}))},[o,l,e.editor,r]);return N(e.editor,()=>{i(e.editor.getTextCursorPosition().block)}),s?n.jsx(ft,{items:f}):null},bt=e=>n.jsxs(le,{children:[n.jsx(ht,{...e,items:e.blockTypeDropdownItems}),n.jsx(st,{editor:e.editor}),n.jsx(ut,{editor:e.editor}),n.jsx(oe,{editor:e.editor,toggledStyle:"bold"}),n.jsx(oe,{editor:e.editor,toggledStyle:"italic"}),n.jsx(oe,{editor:e.editor,toggledStyle:"underline"}),n.jsx(oe,{editor:e.editor,toggledStyle:"strike"}),n.jsx(se,{editor:e.editor,textAlignment:"left"}),n.jsx(se,{editor:e.editor,textAlignment:"center"}),n.jsx(se,{editor:e.editor,textAlignment:"right"}),n.jsx(Xe,{editor:e.editor}),n.jsx(dt,{editor:e.editor}),n.jsx(ct,{editor:e.editor}),n.jsx(lt,{editor:e.editor})]}),mt=e=>{switch(e){case"left":return"top-start";case"center":return"top";case"right":return"top-end";default:return"top-start"}},vt=e=>{const[r,o]=a.useState(!1),[i,l]=a.useState(()=>{const x=e.editor.getTextCursorPosition().block;return"textAlignment"in x.props?mt(x.props.textAlignment):"top-start"}),s=a.useRef(),{refs:f,update:u,context:c,floatingStyles:v}=E.useFloating({open:r,placement:i,middleware:[E.offset(10),E.flip()]}),{isMounted:k,styles:S}=E.useTransitionStyles(c);a.useEffect(()=>e.editor.formattingToolbar.onUpdate(x=>{o(x.show),s.current=x.referencePos,u()}),[e.editor,u]),N(e.editor,()=>{const x=e.editor.getTextCursorPosition().block;"textAlignment"in x.props?l(mt(x.props.textAlignment)):l("top-start")}),a.useEffect(()=>{f.setReference({getBoundingClientRect:()=>s.current})},[f]);const p=e.formattingToolbar||bt;return k?n.jsx("div",{ref:f.setFloating,style:{...S,...v,zIndex:3e3},children:n.jsx(p,{editor:e.editor})}):null},qn=e=>{const[r,o]=a.useState(!1),i=a.useRef(null);return r?n.jsx(at,{url:e.url,text:e.text,update:e.editHyperlink,onBlur:l=>setTimeout(()=>{var s;(s=i.current)!=null&&s.contains(l.relatedTarget)||o(!1)},500),ref:i}):n.jsxs(le,{onMouseEnter:e.stopHideTimer,onMouseLeave:e.startHideTimer,children:[n.jsx(I,{mainTooltip:"Edit",isSelected:!1,onClick:()=>o(!0),children:"Edit Link"}),n.jsx(I,{mainTooltip:"Open in new tab",isSelected:!1,onClick:()=>{window.open(e.url,"_blank")},icon:On}),n.jsx(I,{mainTooltip:"Remove link",isSelected:!1,onClick:e.deleteHyperlink,icon:Bn})]})},xt=e=>{const[r,o]=a.useState(!1),[i,l]=a.useState(),[s,f]=a.useState(),u=a.useRef(),{refs:c,update:v,context:k,floatingStyles:S}=E.useFloating({open:r,placement:"top-start",middleware:[E.offset(10),E.flip()]}),{isMounted:p,styles:x}=E.useTransitionStyles(k);if(a.useEffect(()=>e.editor.hyperlinkToolbar.on("update",V=>{o(V.show),l(V.url),f(V.text),u.current=V.referencePos,v()}),[e.editor,v]),a.useEffect(()=>{c.setReference({getBoundingClientRect:()=>u.current})},[c]),!i||!s||!p)return null;const A=e.hyperlinkToolbar||qn;return n.jsx("div",{ref:c.setFloating,style:{...x,...S,zIndex:4e3},children:n.jsx(A,{url:i,text:s,editHyperlink:e.editor.hyperlinkToolbar.editHyperlink,deleteHyperlink:e.editor.hyperlinkToolbar.deleteHyperlink,startHideTimer:e.editor.hyperlinkToolbar.startHideTimer,stopHideTimer:e.editor.hyperlinkToolbar.stopHideTimer})})},kt=e=>{const[r,o]=a.useState(!1),[i,l]=a.useState(),s=a.useRef(),{refs:f,update:u,context:c,floatingStyles:v}=E.useFloating({open:r,placement:"bottom",middleware:[E.offset(10),E.flip()]}),{isMounted:k,styles:S}=E.useTransitionStyles(c);a.useEffect(()=>e.editor.imageToolbar.onUpdate(x=>{o(x.show),l(x.block),s.current=x.referencePos,u()}),[e.editor,u]),a.useEffect(()=>{f.setReference({getBoundingClientRect:()=>s.current})},[f]);const p=e.imageToolbar||pe;return k?n.jsx("div",{ref:f.setFloating,style:{...S,...v,zIndex:5e3},children:n.jsx(p,{editor:e.editor,block:i})}):null};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 Ve=e=>n.jsx(b.ActionIcon,{size:24,children:e.children}),Ct=e=>n.jsx(Ve,{children:n.jsx(Kn,{size:24,onClick:e.addBlock,"data-test":"dragHandleAdd"})});function yt(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 Be=e=>{const{children:r,...o}=e;return n.jsx(b.Menu.Item,{...o,children:r})},St=e=>{const[r,o]=a.useState(!1),{ref:i,updateMaxHeight:l}=Me(),s=a.useRef(),f=a.useCallback(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o(!1)},250)},[]),u=a.useCallback(()=>{s.current&&clearTimeout(s.current),r||l(),o(!0)},[r,l]);return!("textColor"in e.block.props)&&!("backgroundColor"in e.block.props)?null:n.jsx(Be,{onMouseLeave:f,onMouseOver:u,children:n.jsxs(b.Menu,{withinPortal:!1,opened:r,position:"right",children:[n.jsx(b.Menu.Target,{children:n.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[n.jsx("div",{style:{flex:1},children:e.children}),n.jsx(b.Box,{style:{display:"flex",alignItems:"center"},children:n.jsx(Un,{size:15})})]})}),n.jsx("div",{ref:i,children:n.jsx(b.Menu.Dropdown,{onMouseLeave:f,onMouseOver:u,style:{marginLeft:"5px"},children:n.jsx(Je,{iconSize:18,text:"textColor"in e.block.props&&typeof e.block.props.textColor=="string"?{color:e.block.props.textColor,setColor:c=>e.editor.updateBlock(e.block,{props:{textColor:c}})}:void 0,background:"backgroundColor"in e.block.props&&typeof e.block.props.backgroundColor=="string"?{color:e.block.props.backgroundColor,setColor:c=>e.editor.updateBlock(e.block,{props:{backgroundColor:c}})}:void 0})})})]})})},Tt=e=>n.jsx(Be,{onClick:()=>e.editor.removeBlocks([e.block]),children:e.children}),jt=e=>n.jsx(b.Menu.Dropdown,{className:"bn-drag-handle-menu",children:e.children}),Ht=e=>n.jsxs(jt,{children:[n.jsx(Tt,{...e,children:"Delete"}),n.jsx(St,{...e,children:"Colors"})]}),wt=e=>{const r=e.dragHandleMenu||Ht;return n.jsxs(b.Menu,{withinPortal:!1,trigger:"click",onOpen:e.freezeMenu,onClose:e.unfreezeMenu,width:100,position:"left",children:[n.jsx(b.Menu.Target,{children:n.jsx("div",{className:"bn-drag-handle",draggable:"true",onDragStart:e.blockDragStart,onDragEnd:e.blockDragEnd,children:n.jsx(Ve,{children:n.jsx(yt,{size:24,"data-test":"dragHandle"})})})}),n.jsx(r,{editor:e.editor,block:e.block})]})},Mt=e=>n.jsx(b.Group,{className:"bn-side-menu",gap:0,children:e.children}),Et=e=>n.jsxs(Mt,{children:[n.jsx(Ct,{...e}),n.jsx(wt,{...e})]}),pt=e=>{const[r,o]=a.useState(!1),[i,l]=a.useState(),s=a.useRef(),{refs:f,update:u,context:c,floatingStyles:v}=E.useFloating({open:r,placement:"left"}),{isMounted:k,styles:S}=E.useTransitionStyles(c);if(a.useEffect(()=>e.editor.sideMenu.onUpdate(x=>{o(x.show),l(x.block),s.current=x.referencePos,u()}),[e.editor,u]),a.useEffect(()=>{f.setReference({getBoundingClientRect:()=>s.current})},[f]),!i||!k)return null;const p=e.sideMenu||Et;return n.jsx("div",{ref:f.setFloating,style:{...S,...v,zIndex:1e3},children:n.jsx(p,{block:i,editor:e.editor,blockDragStart:e.editor.sideMenu.blockDragStart,blockDragEnd:e.editor.sideMenu.blockDragEnd,addBlock:e.editor.sideMenu.addBlock,freezeMenu:e.editor.sideMenu.freezeMenu,unfreezeMenu:e.editor.sideMenu.unfreezeMenu})})},Yn=5;function Vt(e){const r=a.useRef(null);function o(){var f;const l=e.isSelected,s=(f=r.current)==null?void 0:f.matches(":hover");return l||s}function i(){var l,s;o()?(l=r.current)==null||l.setAttribute("data-hovered","true"):(s=r.current)==null||s.removeAttribute("data-hovered")}return a.useEffect(()=>{i(),o()&&r.current&&r.current.getBoundingClientRect().left>Yn&&r.current.scrollIntoView({behavior:"smooth",block:"nearest"})}),n.jsx(b.Menu.Item,{className:"bn-slash-menu-item",onClick:e.set,closeMenuOnClick:!1,onMouseLeave:()=>{setTimeout(()=>{i()},1)},leftSection:e.icon,rightSection:e.shortcut&&n.jsx(b.Badge,{size:"xs",children:e.shortcut}),ref:r,children:n.jsxs(b.Stack,{children:[n.jsx(b.Text,{lh:"20px",size:"14px",fw:500,children:e.name}),n.jsx(b.Text,{lh:"16px",size:"10px",children:e.hint})]})})}function Bt(e){const r=[];let o=0;const i=hn.default(e.filteredItems,l=>l.group);return gn.default(i,l=>{r.push(n.jsx(b.Menu.Label,{children:l[0].group},l[0].group));for(const s of l)r.push(n.jsx(Vt,{name:s.name,icon:s.icon,hint:s.hint,shortcut:s.shortcut,isSelected:e.keyboardHoveredItemIndex===o,set:()=>e.itemCallback(s)},s.name)),o++}),n.jsx(b.Menu,{withinPortal:!1,trapFocus:!1,defaultOpened:!0,trigger:"hover",closeDelay:1e7,children:n.jsx(b.Menu.Dropdown,{onMouseDown:l=>l.preventDefault(),className:"bn-slash-menu",children:r.length>0?r:n.jsx(b.Menu.Item,{children:"No match found"})})})}const Lt=e=>{const[r,o]=a.useState(!1),[i,l]=a.useState(),[s,f]=a.useState(),u=a.useRef(),{refs:c,update:v,context:k,floatingStyles:S}=E.useFloating({open:r,placement:"bottom-start",middleware:[E.offset(10),E.flip(),E.size({apply({availableHeight:V,elements:z}){Object.assign(z.floating.style,{maxHeight:`${V-10}px`})}})]}),{isMounted:p,styles:x}=E.useTransitionStyles(k);if(a.useEffect(()=>e.editor.slashMenu.onUpdate(V=>{o(V.show),l(V.filteredItems),f(V.keyboardHoveredItemIndex),u.current=V.referencePos,v()}),[e.editor,r,v]),a.useEffect(()=>{c.setReference({getBoundingClientRect:()=>u.current})},[c]),!p||!i||s===void 0)return null;const A=e.slashMenu||Bt;return n.jsx("div",{ref:c.setFloating,style:{display:"flex",...x,...S,zIndex:2e3},children:n.jsx(A,{filteredItems:i,itemCallback:V=>e.editor.slashMenu.itemCallback(V),keyboardHoveredItemIndex:s})})},Gn=e=>n.jsx(b.Menu.Dropdown,{className:"bn-table-handle-menu",children:e.children}),de=e=>{const{children:r,...o}=e;return n.jsx(b.Menu.Item,{...o,children:r})},Jn=e=>n.jsx(de,{onClick:()=>{const r=e.block.content.rows[e.index].cells.map(()=>[]),o=[...e.block.content.rows];o.splice(e.index+(e.side==="below"?1:0),0,{cells:r}),e.editor.updateBlock(e.block,{type:"table",content:{type:"tableContent",rows:o}})},children:`Add row ${e.side}`}),Xn=e=>n.jsx(de,{onClick:()=>{const r={type:"tableContent",rows:e.block.content.rows.map(o=>{const i=[...o.cells];return i.splice(e.index+(e.side==="right"?1:0),0,[]),{cells:i}})};e.editor.updateBlock(e.block,{type:"table",content:r})},children:`Add column ${e.side}`}),Dt=e=>e.orientation==="row"?n.jsx(Jn,{...e,side:e.side}):n.jsx(Xn,{...e,side:e.side}),Qn=e=>n.jsx(de,{onClick:()=>{const r={type:"tableContent",rows:e.block.content.rows.filter((o,i)=>i!==e.index)};e.editor.updateBlock(e.block,{type:"table",content:r})},children:"Delete row"}),$n=e=>n.jsx(de,{onClick:()=>{const r={type:"tableContent",rows:e.block.content.rows.map(o=>({cells:o.cells.filter((i,l)=>l!==e.index)}))};e.editor.updateBlock(e.block,{type:"table",content:r})},children:"Delete column"}),er=e=>e.orientation==="row"?n.jsx(Qn,{...e}):n.jsx($n,{...e}),tr=e=>n.jsxs(Gn,{children:[n.jsx(er,{orientation:e.orientation,editor:e.editor,block:e.block,index:e.index}),n.jsx(Dt,{orientation:e.orientation,editor:e.editor,block:e.block,index:e.index,side:e.orientation==="row"?"above":"left"}),n.jsx(Dt,{orientation:e.orientation,editor:e.editor,block:e.block,index:e.index,side:e.orientation==="row"?"below":"right"})]}),nr=e=>{const r=e.tableHandleMenu||tr,[o,i]=a.useState(!1);return n.jsxs(b.Menu,{withinPortal:!1,trigger:"click",onOpen:()=>{e.freezeHandles(),e.hideOtherSide()},onClose:()=>{e.unfreezeHandles(),e.showOtherSide()},position:"right",children:[n.jsx(b.Menu.Target,{children:n.jsx("div",{className:C.mergeCSSClasses("bn-table-handle",o?"bn-table-handle-dragging":""),draggable:"true",onDragStart:l=>{i(!0),e.dragStart(l)},onDragEnd:()=>{e.dragEnd(),i(!1)},style:e.orientation==="column"?{transform:"rotate(0.25turn)"}:void 0,children:e.children})}),n.jsx(r,{orientation:e.orientation,editor:e.editor,block:e.block,index:e.index})]})},Pt=e=>n.jsx(nr,{...e,children:n.jsx(yt,{size:24,"data-test":"tableHandle"})}),It=e=>{const[r,o]=a.useState(!1),[i,l]=a.useState(!1),[s,f]=a.useState(!1),[u,c]=a.useState(),[v,k]=a.useState(),[S,p]=a.useState(),[x,A]=a.useState(void 0),[V,z]=a.useState(),[,J]=a.useState(0),B=a.useRef(),F=a.useRef(),Z=E.useFloating({open:r,placement:"left",middleware:[E.offset(-10)]}),U=E.useFloating({open:r,placement:"top",middleware:[E.offset(-12)]}),ge=E.useTransitionStyles(Z.context),he=E.useTransitionStyles(U.context);a.useEffect(()=>e.editor.tableHandles.onUpdate(_=>{o(_.show),c(_.block),k(_.rowIndex),p(_.colIndex),_.draggingState?(A(_.draggingState.draggedCellOrientation),z(_.draggingState.mousePos)):(A(void 0),z(void 0)),J(Math.random()),B.current=_.referencePosCell,F.current=_.referencePosTable,Z.update(),U.update()}),[U,e.editor,Z]),a.useEffect(()=>{Z.refs.setReference({getBoundingClientRect:()=>x==="row"?new DOMRect(F.current.x,V,F.current.width,0):new DOMRect(F.current.x,B.current.y,F.current.width,B.current.height)})},[x,V,Z.refs]),a.useEffect(()=>{U.refs.setReference({getBoundingClientRect:()=>x==="col"?new DOMRect(V,F.current.y,0,F.current.height):new DOMRect(B.current.x,F.current.y,B.current.width,F.current.height)})},[U.refs,x,V]);const be=e.tableHandle||Pt;return!ge.isMounted||!he.isMounted||i&&s?null:n.jsxs(n.Fragment,{children:[!i&&n.jsx("div",{ref:Z.refs.setFloating,style:{...ge.styles,...Z.floatingStyles,zIndex:1e4},children:n.jsx(be,{orientation:"row",editor:e.editor,index:v,block:u,dragStart:e.editor.tableHandles.rowDragStart,dragEnd:e.editor.tableHandles.dragEnd,freezeHandles:e.editor.tableHandles.freezeHandles,unfreezeHandles:e.editor.tableHandles.unfreezeHandles,showOtherSide:()=>f(!1),hideOtherSide:()=>f(!0)})}),!s&&n.jsx("div",{ref:U.refs.setFloating,style:{...he.styles,...U.floatingStyles,zIndex:1e4},children:n.jsx(be,{orientation:"column",editor:e.editor,index:S,block:u,dragStart:e.editor.tableHandles.colDragStart,dragEnd:e.editor.tableHandles.dragEnd,freezeHandles:e.editor.tableHandles.freezeHandles,unfreezeHandles:e.editor.tableHandles.unfreezeHandles,showOtherSide:()=>l(!1),hideOtherSide:()=>l(!0)})})]})},zr="",rr={activeClassName:""};function or(e){const{editor:r,className:o,theme:i,children:l,...s}=e,f=fn.default(),[u,c]=a.useState(void 0);return a.useEffect(()=>{if(Ue(r.domElement.parentElement),i==="light"){c("light");return}if(i==="dark"){c("dark");return}if(typeof i=="object"){if("light"in i&&"dark"in i){ye(i[f==="dark"?"dark":"light"],r.domElement.parentElement),c(f==="dark"?"dark":"light");return}ye(i,r.domElement.parentElement),c(void 0);return}c(f==="dark"?"dark":"light")},[f,r.domElement,i]),n.jsx(b.MantineProvider,{theme:rr,children:n.jsx(K.EditorContent,{editor:r._tiptapEditor,className:C.mergeCSSClasses("bn-container",o||""),"data-color-scheme":u,...s,children:l||n.jsxs(n.Fragment,{children:[n.jsx(vt,{editor:r}),n.jsx(xt,{editor:r}),n.jsx(Lt,{editor:r}),n.jsx(pt,{editor:r}),n.jsx(kt,{editor:r}),r.blockSchema.table&&n.jsx(It,{editor:r})]})})})}const j=["#FFFFFF","#EFEFEF","#CFCFCF","#AFAFAF","#7F7F7F","#3F3F3F","#1F1F1F","#161616","#0F0F0F","#000000"],Le={colors:{editor:{text:j[5],background:j[0]},menu:{text:j[5],background:j[0]},tooltip:{text:j[5],background:j[1]},hovered:{text:j[5],background:j[1]},selected:{text:j[0],background:j[5]},disabled:{text:j[3],background:j[1]},shadow:j[2],border:j[1],sideMenu:j[2],highlights:{gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}}},borderRadius:6,fontFamily:'"Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif'},ir={colors:{editor:{text:j[2],background:j[6]},menu:{text:j[2],background:j[6]},tooltip:{text:j[2],background:j[7]},hovered:{text:j[2],background:j[7]},selected:{text:j[2],background:j[8]},disabled:{text:j[5],background:j[7]},shadow:j[8],border:j[7],sideMenu:j[4],highlights:{gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}}},borderRadius:Le.borderRadius,fontFamily:Le.fontFamily},ar={Heading:{group:"Headings",icon:n.jsx(Qe,{size:18}),hint:"Used for a top-level heading",shortcut:C.formatKeyboardShortcut("Mod-Alt-1")},"Heading 2":{group:"Headings",icon:n.jsx($e,{size:18}),hint:"Used for key sections",shortcut:C.formatKeyboardShortcut("Mod-Alt-2")},"Heading 3":{group:"Headings",icon:n.jsx(et,{size:18}),hint:"Used for subsections and group headings",shortcut:C.formatKeyboardShortcut("Mod-Alt-3")},"Numbered List":{group:"Basic blocks",icon:n.jsx(nt,{size:18}),hint:"Used to display a numbered list",shortcut:C.formatKeyboardShortcut("Mod-Alt-7")},"Bullet List":{group:"Basic blocks",icon:n.jsx(rt,{size:18}),hint:"Used to display an unordered list",shortcut:C.formatKeyboardShortcut("Mod-Alt-9")},Paragraph:{group:"Basic blocks",icon:n.jsx(re,{size:18}),hint:"Used for the body of your document",shortcut:C.formatKeyboardShortcut("Mod-Alt-0")},Table:{group:"Advanced",icon:n.jsx(Dn,{size:18}),hint:"Used for for tables"},Image:{group:"Media",icon:n.jsx(In,{}),hint:"Insert an image"}};function _t(e=C.defaultBlockSchema){return C.getDefaultSlashMenuItems(e).map(o=>({...o,...ar[o.name]}))}function lr(e){const[r,o]=a.useState(()=>e.getActiveStyles());return Te(e,()=>{o(e.getActiveStyles())}),je(e,()=>{o(e.getActiveStyles())}),r}const sr=e=>C.BlockNoteEditor.create({slashMenuItems:_t(C.getBlockSchemaFromSpecs(e.blockSpecs||C.defaultBlockSpecs)),...e}),dr=(e={},r=[])=>{const o=a.useRef();return a.useMemo(()=>(o.current&&o.current._tiptapEditor.destroy(),o.current=sr(e),o.current),r)};function cr(){const[,e]=a.useState(0);return()=>e(r=>r+1)}const ur=e=>{const r=cr();a.useEffect(()=>{const o=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r()})})};return e.on("transaction",o),()=>{e.off("transaction",o)}},[e])};var De,ce=bn.default;if(process.env.NODE_ENV==="production")De=ce.createRoot,ce.hydrateRoot;else{var Ot=ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;De=function(e,r){Ot.usingClientEntryPoint=!0;try{return ce.createRoot(e,r)}finally{Ot.usingClientEntryPoint=!1}}}function ue(e){let r;const o=document.createElement("div"),i=De(o);if(ze.flushSync(()=>{i.render(e(u=>r=u||void 0))}),!o.childElementCount)return console.warn("ReactInlineContentSpec: renderHTML() failed"),{dom:document.createElement("span")};r==null||r.setAttribute("data-tmp-find","true");const l=o.cloneNode(!0),s=l.firstElementChild,f=l.querySelector("[data-tmp-find]");return f==null||f.removeAttribute("data-tmp-find"),i.unmount(),{dom:s,contentDOM:f||void 0}}function fe(e){var r;return n.jsx(K.NodeViewWrapper,{...Object.fromEntries(Object.entries(e.domAttributes||{}).filter(([o])=>o!=="class")),className:C.mergeCSSClasses("bn-block-content",((r=e.domAttributes)==null?void 0:r.class)||""),"data-content-type":e.blockType,...Object.fromEntries(Object.entries(e.blockProps).filter(([o,i])=>!C.inheritedProps.includes(o)&&i!==e.propSchema[o].default).map(([o,i])=>[C.camelToDataKebab(o),i])),children:e.children})}function fr(e,r){const o=C.createStronglyTypedTiptapNode({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:!0,addAttributes(){return C.propsToAttributes(e.propSchema)},parseHTML(){return C.getParseRules(e,r.parse)},renderHTML(){const i=document.createElement("div");return i.setAttribute("data-tmp-placeholder","true"),{dom:i}},addNodeView(){return i=>K.ReactNodeViewRenderer(l=>{var k;const s=this.options.editor,f=C.getBlockFromPos(l.getPos,s,this.editor,e.type),u=((k=this.options.domAttributes)==null?void 0:k.blockContent)||{},c=K.NodeViewContent({}).ref,v=r.render;return n.jsx(fe,{blockType:f.type,blockProps:f.props,propSchema:e.propSchema,domAttributes:u,children:n.jsx(v,{block:f,editor:s,contentRef:c})})},{className:"bn-react-node-view-renderer"})(i)}});return C.createInternalBlockSpec(e,{node:o,toInternalHTML:(i,l)=>{var c,v;const s=((c=o.options.domAttributes)==null?void 0:c.blockContent)||{},f=r.render,u=ue(k=>n.jsx(fe,{blockType:i.type,blockProps:i.props,propSchema:e.propSchema,domAttributes:s,children:n.jsx(f,{block:i,editor:l,contentRef:k})}));return(v=u.contentDOM)==null||v.setAttribute("data-editable",""),u},toExternalHTML:(i,l)=>{var c,v;const s=((c=o.options.domAttributes)==null?void 0:c.blockContent)||{},f=r.toExternalHTML||r.render,u=ue(k=>n.jsx(fe,{blockType:i.type,blockProps:i.props,propSchema:e.propSchema,domAttributes:s,children:n.jsx(f,{block:i,editor:l,contentRef:k})}));return(v=u.contentDOM)==null||v.setAttribute("data-editable",""),u}})}function At(e,r,o,i){return()=>n.jsx(K.NodeViewWrapper,{as:"span",className:"bn-inline-content-section","data-inline-content-type":r,...Object.fromEntries(Object.entries(o).filter(([l,s])=>s!==i[l].default).map(([l,s])=>[C.camelToDataKebab(l),s])),children:e})}function gr(e,r){const o=C.createStronglyTypedTiptapNode({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return C.propsToAttributes(e.propSchema)},addKeyboardShortcuts(){return C.addInlineContentKeyboardShortcuts(e)},parseHTML(){return C.getInlineContentParseRules(e)},renderHTML({node:i}){const l=this.options.editor,s=C.nodeToCustomInlineContent(i,l.inlineContentSchema,l.styleSchema),f=r.render,u=ue(c=>n.jsx(f,{inlineContent:s,contentRef:c}));return C.addInlineContentAttributes(u,e.type,i.attrs,e.propSchema)},addNodeView(){const i=this.options.editor;return l=>K.ReactNodeViewRenderer(s=>{const f=K.NodeViewContent({}).ref,u=r.render,c=At(n.jsx(u,{contentRef:f,inlineContent:C.nodeToCustomInlineContent(s.node,i.inlineContentSchema,i.styleSchema)}),e.type,s.node.attrs,e.propSchema);return n.jsx(c,{})},{className:"bn-ic-react-node-view-renderer",as:"span"})(l)}});return C.createInternalInlineContentSpec(e,{node:o})}function hr(e,r){const o=K.Mark.create({name:e.type,addAttributes(){return C.stylePropsToAttributes(e.propSchema)},parseHTML(){return C.getStyleParseRules(e)},renderHTML({mark:i}){const l={};e.propSchema==="string"&&(l.value=i.attrs.stringValue);const s=r.render,f=ue(u=>n.jsx(s,{...l,contentRef:u}));return C.addStyleAttributes(f,e.type,i.attrs.stringValue,e.propSchema)}});return C.createInternalStyleSpec(e,{mark:o})}h.AddBlockButton=Ct,h.BlockColorsButton=St,h.BlockContentWrapper=fe,h.BlockNoteView=or,h.BlockTypeDropdown=ht,h.ColorStyleButton=Xe,h.CreateLinkButton=lt,h.DefaultDragHandleMenu=Ht,h.DefaultFormattingToolbar=bt,h.DefaultImageToolbar=pe,h.DefaultSideMenu=Et,h.DefaultSlashMenu=Bt,h.DefaultTableHandle=Pt,h.DragHandle=wt,h.DragHandleMenu=jt,h.DragHandleMenuItem=Be,h.FormattingToolbarPositioner=vt,h.HyperlinkToolbarPositioner=xt,h.ImageCaptionButton=st,h.ImageToolbarPositioner=kt,h.NestBlockButton=dt,h.RemoveBlockButton=Tt,h.ReplaceImageButton=ut,h.SideMenu=Mt,h.SideMenuButton=Ve,h.SideMenuPositioner=pt,h.SlashMenuItem=Vt,h.SlashMenuPositioner=Lt,h.TableHandlesPositioner=It,h.TextAlignButton=se,h.ToggledStyleButton=oe,h.Toolbar=le,h.ToolbarButton=I,h.ToolbarDropdown=ft,h.UnnestBlockButton=ct,h.applyBlockNoteCSSVariablesFromTheme=ye,h.createReactBlockSpec=fr,h.createReactInlineContentSpec=gr,h.createReactStyleSpec=hr,h.darkDefaultTheme=ir,h.defaultBlockTypeDropdownItems=gt,h.defaultColorScheme=j,h.getDefaultReactSlashMenuItems=_t,h.lightDefaultTheme=Le,h.reactWrapInInlineContentStructure=At,h.removeBlockNoteCSSVariables=Ue,h.useActiveStyles=lr,h.useBlockNote=dr,h.useEditorChange=N,h.useEditorContentChange=Te,h.useEditorForceUpdate=ur,h.useEditorSelectionChange=je,h.useSelectedBlocks=G,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=blocknote-react.umd.cjs.map
