react-latex-editor
Version:
A powerful React rich text editor with mathematical equation support, built on TipTap with MathLive integration
30 lines (28 loc) • 68.5 kB
JavaScript
"use strict";var Nt=Object.create;var He=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var It=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty;var Ht=(t,r,n,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Pt(r))!Bt.call(t,o)&&o!==n&&He(t,o,{get:()=>r[o],enumerable:!(l=_t(r,o))||l.enumerable});return t};var Fe=(t,r,n)=>(n=t!=null?Nt(It(t)):{},Ht(r||!t||!t.__esModule?He(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),B=require("@tiptap/react"),Ft=require("@tiptap/starter-kit"),Dt=require("@tiptap/extension-table"),qt=require("@tiptap/extension-table-row"),$t=require("@tiptap/extension-table-cell"),zt=require("@tiptap/extension-table-header"),Wt=require("@tiptap/extension-link"),Ot=require("@tiptap/extension-text-align"),Vt=require("@tiptap/extension-highlight"),Yt=require("@tiptap/extension-underline"),Gt=require("@tiptap/extension-subscript"),Ut=require("@tiptap/extension-superscript"),Kt=require("@tiptap/extension-code-block-lowlight"),De=require("lowlight"),Jt=require("@tiptap/extension-strike"),Xt=require("@tiptap/extension-color"),Zt=require("@tiptap/extension-blockquote"),Qt=require("@tiptap/extension-horizontal-rule"),ei=require("@tiptap/extension-hard-break"),ti=require("@tiptap/extension-task-list"),ii=require("@tiptap/extension-task-item"),ri=require("@tiptap/extension-placeholder"),ni=require("@tiptap/extension-character-count"),si=require("@tiptap/extension-floating-menu"),q=require("@tiptap/core"),ai=require("@tiptap/extension-image"),li=require("@tiptap/extension-youtube"),oi=require("@tiptap/extension-text-style");require("mathlive");var re={exports:{}},J={};/**
* @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 qe;function ci(){if(qe)return J;qe=1;var t=u,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,k={key:!0,ref:!0,__self:!0,__source:!0};function b(v,p,w){var x,f={},h=null,L=null;w!==void 0&&(h=""+w),p.key!==void 0&&(h=""+p.key),p.ref!==void 0&&(L=p.ref);for(x in p)l.call(p,x)&&!k.hasOwnProperty(x)&&(f[x]=p[x]);if(v&&v.defaultProps)for(x in p=v.defaultProps,p)f[x]===void 0&&(f[x]=p[x]);return{$$typeof:r,type:v,key:h,ref:L,props:f,_owner:o.current}}return J.Fragment=n,J.jsx=b,J.jsxs=b,J}var X={};/**
* @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 $e;function ui(){return $e||($e=1,process.env.NODE_ENV!=="production"&&function(){var t=u,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),v=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),L=Symbol.for("react.offscreen"),A=Symbol.iterator,d="@@iterator";function _(i){if(i===null||typeof i!="object")return null;var s=A&&i[A]||i[d];return typeof s=="function"?s:null}var S=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(i){{for(var s=arguments.length,a=new Array(s>1?s-1:0),c=1;c<s;c++)a[c-1]=arguments[c];E("error",i,a)}}function E(i,s,a){{var c=S.ReactDebugCurrentFrame,j=c.getStackAddendum();j!==""&&(s+="%s",a=a.concat([j]));var C=a.map(function(g){return String(g)});C.unshift("Warning: "+s),Function.prototype.apply.call(console[i],console,C)}}var H=!1,V=!1,$=!1,z=!1,F=!1,Z;Z=Symbol.for("react.module.reference");function rt(i){return!!(typeof i=="string"||typeof i=="function"||i===l||i===k||F||i===o||i===w||i===x||z||i===L||H||V||$||typeof i=="object"&&i!==null&&(i.$$typeof===h||i.$$typeof===f||i.$$typeof===b||i.$$typeof===v||i.$$typeof===p||i.$$typeof===Z||i.getModuleId!==void 0))}function nt(i,s,a){var c=i.displayName;if(c)return c;var j=s.displayName||s.name||"";return j!==""?a+"("+j+")":a}function pe(i){return i.displayName||"Context"}function D(i){if(i==null)return null;if(typeof i.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case l:return"Fragment";case n:return"Portal";case k:return"Profiler";case o:return"StrictMode";case w:return"Suspense";case x:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case v:var s=i;return pe(s)+".Consumer";case b:var a=i;return pe(a._context)+".Provider";case p:return nt(i,i.render,"ForwardRef");case f:var c=i.displayName||null;return c!==null?c:D(i.type)||"Memo";case h:{var j=i,C=j._payload,g=j._init;try{return D(g(C))}catch{return null}}}return null}var W=Object.assign,U=0,fe,me,xe,ge,ye,be,ve;function je(){}je.__reactDisabledLog=!0;function st(){{if(U===0){fe=console.log,me=console.info,xe=console.warn,ge=console.error,ye=console.group,be=console.groupCollapsed,ve=console.groupEnd;var i={configurable:!0,enumerable:!0,value:je,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}U++}}function at(){{if(U--,U===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},i,{value:fe}),info:W({},i,{value:me}),warn:W({},i,{value:xe}),error:W({},i,{value:ge}),group:W({},i,{value:ye}),groupCollapsed:W({},i,{value:be}),groupEnd:W({},i,{value:ve})})}U<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ne=S.ReactCurrentDispatcher,se;function Q(i,s,a){{if(se===void 0)try{throw Error()}catch(j){var c=j.stack.trim().match(/\n( *(at )?)/);se=c&&c[1]||""}return`
`+se+i}}var ae=!1,ee;{var lt=typeof WeakMap=="function"?WeakMap:Map;ee=new lt}function ke(i,s){if(!i||ae)return"";{var a=ee.get(i);if(a!==void 0)return a}var c;ae=!0;var j=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var C;C=ne.current,ne.current=null,st();try{if(s){var g=function(){throw Error()};if(Object.defineProperty(g.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(g,[])}catch(P){c=P}Reflect.construct(i,[],g)}else{try{g.call()}catch(P){c=P}i.call(g.prototype)}}else{try{throw Error()}catch(P){c=P}i()}}catch(P){if(P&&c&&typeof P.stack=="string"){for(var m=P.stack.split(`
`),N=c.stack.split(`
`),M=m.length-1,T=N.length-1;M>=1&&T>=0&&m[M]!==N[T];)T--;for(;M>=1&&T>=0;M--,T--)if(m[M]!==N[T]){if(M!==1||T!==1)do if(M--,T--,T<0||m[M]!==N[T]){var I=`
`+m[M].replace(" at new "," at ");return i.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",i.displayName)),typeof i=="function"&&ee.set(i,I),I}while(M>=1&&T>=0);break}}}finally{ae=!1,ne.current=C,at(),Error.prepareStackTrace=j}var G=i?i.displayName||i.name:"",O=G?Q(G):"";return typeof i=="function"&&ee.set(i,O),O}function ot(i,s,a){return ke(i,!1)}function ct(i){var s=i.prototype;return!!(s&&s.isReactComponent)}function te(i,s,a){if(i==null)return"";if(typeof i=="function")return ke(i,ct(i));if(typeof i=="string")return Q(i);switch(i){case w:return Q("Suspense");case x:return Q("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case p:return ot(i.render);case f:return te(i.type,s,a);case h:{var c=i,j=c._payload,C=c._init;try{return te(C(j),s,a)}catch{}}}return""}var K=Object.prototype.hasOwnProperty,we={},Ce=S.ReactDebugCurrentFrame;function ie(i){if(i){var s=i._owner,a=te(i.type,i._source,s?s.type:null);Ce.setExtraStackFrame(a)}else Ce.setExtraStackFrame(null)}function ut(i,s,a,c,j){{var C=Function.call.bind(K);for(var g in i)if(C(i,g)){var m=void 0;try{if(typeof i[g]!="function"){var N=Error((c||"React class")+": "+a+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}m=i[g](s,g,c,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(M){m=M}m&&!(m instanceof Error)&&(ie(j),R("%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).",c||"React class",a,g,typeof m),ie(null)),m instanceof Error&&!(m.message in we)&&(we[m.message]=!0,ie(j),R("Failed %s type: %s",a,m.message),ie(null))}}}var dt=Array.isArray;function le(i){return dt(i)}function ht(i){{var s=typeof Symbol=="function"&&Symbol.toStringTag,a=s&&i[Symbol.toStringTag]||i.constructor.name||"Object";return a}}function pt(i){try{return Re(i),!1}catch{return!0}}function Re(i){return""+i}function Ee(i){if(pt(i))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ht(i)),Re(i)}var Ae=S.ReactCurrentOwner,ft={key:!0,ref:!0,__self:!0,__source:!0},Me,Te;function mt(i){if(K.call(i,"ref")){var s=Object.getOwnPropertyDescriptor(i,"ref").get;if(s&&s.isReactWarning)return!1}return i.ref!==void 0}function xt(i){if(K.call(i,"key")){var s=Object.getOwnPropertyDescriptor(i,"key").get;if(s&&s.isReactWarning)return!1}return i.key!==void 0}function gt(i,s){typeof i.ref=="string"&&Ae.current}function yt(i,s){{var a=function(){Me||(Me=!0,R("%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)",s))};a.isReactWarning=!0,Object.defineProperty(i,"key",{get:a,configurable:!0})}}function bt(i,s){{var a=function(){Te||(Te=!0,R("%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)",s))};a.isReactWarning=!0,Object.defineProperty(i,"ref",{get:a,configurable:!0})}}var vt=function(i,s,a,c,j,C,g){var m={$$typeof:r,type:i,key:s,ref:a,props:g,_owner:C};return m._store={},Object.defineProperty(m._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(m,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(m,"_source",{configurable:!1,enumerable:!1,writable:!1,value:j}),Object.freeze&&(Object.freeze(m.props),Object.freeze(m)),m};function jt(i,s,a,c,j){{var C,g={},m=null,N=null;a!==void 0&&(Ee(a),m=""+a),xt(s)&&(Ee(s.key),m=""+s.key),mt(s)&&(N=s.ref,gt(s,j));for(C in s)K.call(s,C)&&!ft.hasOwnProperty(C)&&(g[C]=s[C]);if(i&&i.defaultProps){var M=i.defaultProps;for(C in M)g[C]===void 0&&(g[C]=M[C])}if(m||N){var T=typeof i=="function"?i.displayName||i.name||"Unknown":i;m&&yt(g,T),N&&bt(g,T)}return vt(i,m,N,j,c,Ae.current,g)}}var oe=S.ReactCurrentOwner,Le=S.ReactDebugCurrentFrame;function Y(i){if(i){var s=i._owner,a=te(i.type,i._source,s?s.type:null);Le.setExtraStackFrame(a)}else Le.setExtraStackFrame(null)}var ce;ce=!1;function ue(i){return typeof i=="object"&&i!==null&&i.$$typeof===r}function Se(){{if(oe.current){var i=D(oe.current.type);if(i)return`
Check the render method of \``+i+"`."}return""}}function kt(i){return""}var Ne={};function wt(i){{var s=Se();if(!s){var a=typeof i=="string"?i:i.displayName||i.name;a&&(s=`
Check the top-level render call using <`+a+">.")}return s}}function _e(i,s){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var a=wt(s);if(Ne[a])return;Ne[a]=!0;var c="";i&&i._owner&&i._owner!==oe.current&&(c=" It was passed a child from "+D(i._owner.type)+"."),Y(i),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,c),Y(null)}}function Pe(i,s){{if(typeof i!="object")return;if(le(i))for(var a=0;a<i.length;a++){var c=i[a];ue(c)&&_e(c,s)}else if(ue(i))i._store&&(i._store.validated=!0);else if(i){var j=_(i);if(typeof j=="function"&&j!==i.entries)for(var C=j.call(i),g;!(g=C.next()).done;)ue(g.value)&&_e(g.value,s)}}}function Ct(i){{var s=i.type;if(s==null||typeof s=="string")return;var a;if(typeof s=="function")a=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===p||s.$$typeof===f))a=s.propTypes;else return;if(a){var c=D(s);ut(a,i.props,"prop",c,i)}else if(s.PropTypes!==void 0&&!ce){ce=!0;var j=D(s);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",j||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Rt(i){{for(var s=Object.keys(i.props),a=0;a<s.length;a++){var c=s[a];if(c!=="children"&&c!=="key"){Y(i),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),Y(null);break}}i.ref!==null&&(Y(i),R("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}var Ie={};function Be(i,s,a,c,j,C){{var g=rt(i);if(!g){var m="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(m+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var N=kt();N?m+=N:m+=Se();var M;i===null?M="null":le(i)?M="array":i!==void 0&&i.$$typeof===r?(M="<"+(D(i.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):M=typeof i,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",M,m)}var T=jt(i,s,a,j,C);if(T==null)return T;if(g){var I=s.children;if(I!==void 0)if(c)if(le(I)){for(var G=0;G<I.length;G++)Pe(I[G],i);Object.freeze&&Object.freeze(I)}else R("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 Pe(I,i)}if(K.call(s,"key")){var O=D(i),P=Object.keys(s).filter(function(St){return St!=="key"}),de=P.length>0?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}";if(!Ie[O+de]){var Lt=P.length>0?"{"+P.join(": ..., ")+": ...}":"{}";R(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,de,O,Lt,O),Ie[O+de]=!0}}return i===l?Rt(T):Ct(T),T}}function Et(i,s,a){return Be(i,s,a,!0)}function At(i,s,a){return Be(i,s,a,!1)}var Mt=At,Tt=Et;X.Fragment=l,X.jsx=Mt,X.jsxs=Tt}()),X}var ze;function di(){return ze||(ze=1,process.env.NODE_ENV==="production"?re.exports=ci():re.exports=ui()),re.exports}var e=di();class hi extends u.Component{mathFieldRef;cleanup;constructor(r){super(r),this.mathFieldRef=u.createRef()}async componentDidMount(){if(typeof window<"u"){const r=await import("mathlive");customElements.get("math-field")||customElements.define("math-field",r.MathfieldElement),r.MathfieldElement&&(r.MathfieldElement.fontsDirectory=null)}this.setupMathField()}componentDidUpdate(r){r.node.attrs.latex!==this.props.node.attrs.latex&&this.updateMathField()}componentWillUnmount(){this.cleanupMathField()}setupMathField(){const r=this.mathFieldRef.current;if(!r)return;const n=()=>{const l=r.value;l!==this.props.node.attrs.latex&&this.props.updateAttributes({latex:l})};setTimeout(()=>{r&&r.isConnected&&(r.addEventListener("input",n),r.value=this.props.node.attrs.latex||"")},0),this.cleanup=()=>{r&&r.isConnected&&(r.removeEventListener("input",n),r.menuItems=[])}}updateMathField(){this.mathFieldRef.current&&(this.mathFieldRef.current.value=this.props.node.attrs.latex||"")}cleanupMathField(){this.cleanup&&this.cleanup()}render(){const{node:r}=this.props,{displayMode:n}=r.attrs;return e.jsx(B.NodeViewWrapper,{className:n?"math-node-wrapper-block":"math-node-wrapper-inline",children:u.createElement("math-field",{ref:this.mathFieldRef,className:"test-math-background",readonly:!0})})}}const We=q.Node.create({name:"math",group:"inline",inline:!0,atom:!0,addAttributes(){return{latex:{default:"",parseHTML:t=>t.getAttribute("data-latex"),renderHTML:t=>({"data-latex":t.latex})},displayMode:{default:!1,parseHTML:t=>t.hasAttribute("data-display-mode"),renderHTML:t=>t.displayMode?{"data-display-mode":""}:{}}}},parseHTML(){return[{tag:'span[data-type="math"]'}]},renderHTML({HTMLAttributes:t,node:r}){return["span",{...t,"data-type":"math","data-latex":r?.attrs?.latex||""},r?.attrs?.latex||""]},addNodeView(){return B.ReactNodeViewRenderer(hi)}}),Oe=q.Extension.create({name:"inlineMath",addOptions(){return{inlineDelimiter:"$",blockDelimiter:"$$"}},addProseMirrorPlugins(){return[]},addCommands(){return{insertInlineMath:t=>({commands:r})=>r.insertContent({type:"math",attrs:{latex:t}})}},addInputRules(){const t=this.options.inlineDelimiter.replace(/[-\/\\^$*+?.()|\[\]{}]/g,"\\$&"),r=this.options.blockDelimiter.replace(/[-\/\\^$*+?.()|\[\]{}]/g,"\\$&");return[new B.InputRule({find:new RegExp(`${t}(.*?)${t}$`),handler:({state:n,range:l,match:o})=>{const[,k]=o,{from:b,to:v}=l;n.tr.replaceWith(b,v,n.schema.nodes.math.create({latex:k}))}}),new B.InputRule({find:new RegExp(`${r}(.*?)${r}$`),handler:({state:n,range:l,match:o})=>{const[,k]=o,{from:b,to:v}=l;n.tr.replaceWith(b,v,n.schema.nodes.math.create({latex:k,displayMode:!0}))}}),new B.InputRule({find:new RegExp(`${t}(.*?)${t}$`),handler:({state:n,range:l,match:o})=>{const[,k]=o,{from:b,to:v}=l;n.tr.replaceWith(b,v,n.schema.nodes.math.create({latex:k}))}})]}}),pi=({node:t,updateAttributes:r})=>{const n=u.useRef(null),{width:l,align:o}=t.attrs,k=u.useCallback(b=>{b.preventDefault();const v=b.pageX,p=n.current.clientWidth,w=f=>{const h=p+(f.pageX-v);r({width:`${Math.max(50,h)}px`})},x=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",x)},[r]);return e.jsxs(B.NodeViewWrapper,{className:`resizable-image-container align-${o}`,style:{width:l},ref:n,children:[e.jsx("img",{src:t.attrs.src,alt:t.attrs.alt,title:t.attrs.title,className:"editor-image",draggable:"true"}),e.jsx("div",{className:"resize-handle-left",onMouseDown:k}),e.jsx("div",{className:"resize-handle-right",onMouseDown:k})]})},Ve=ai.extend({addAttributes(){return{...this.parent?.(),width:{default:"500px",renderHTML:t=>({width:t.width})},height:{default:"auto",renderHTML:t=>({height:t.height})},align:{default:"left",renderHTML:t=>({"data-align":t.align}),parseHTML:t=>t.getAttribute("data-align")||"left"}}},addNodeView(){return B.ReactNodeViewRenderer(pi)}}),Ye=q.Node.create({name:"imageGroup",group:"block",content:"image+",addAttributes(){return{align:{default:"left"}}},renderHTML({node:t,HTMLAttributes:r}){const n=t.attrs.align||"left",o={left:"flex-start",center:"center",right:"flex-end"}[n]||"flex-start";return["div",q.mergeAttributes(r,{"data-type":"image-group",style:`justify-content: ${o}`}),0]},parseHTML(){return[{tag:'div[data-type="image-group"]',getAttrs:t=>{const r=t.style.justifyContent;return r==="center"||r==="flex-end"?{align:r==="center"?"center":"right"}:{align:"left"}}}]}}),Ge=q.Mark.create({name:"customTextStyle",addAttributes(){return{fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(" !important","")||null,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize} !important;`}:{}},color:{default:null,parseHTML:t=>t.style.color||null,renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}},fontFamily:{default:null,parseHTML:t=>t.style.fontFamily||null,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily} !important;`}:{}}}},parseHTML(){return[{tag:"span",getAttrs:t=>{const r=t.style.fontSize,n=t.style.color,l=t.style.fontFamily;return r||n||l?{fontSize:r?r.replace(" !important",""):null,color:n||null,fontFamily:l?l.replace(" !important",""):null}:!1}}]},renderHTML({HTMLAttributes:t}){return["span",q.mergeAttributes(t),0]}}),Ue=q.Mark.create({name:"backgroundColor",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{backgroundColor:{default:null,parseHTML:t=>t.style.backgroundColor||null,renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}},parseHTML(){return[{style:"background-color"}]},renderHTML({HTMLAttributes:t}){return["span",q.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBackgroundColor:t=>({commands:r})=>r.setMark(this.name,{backgroundColor:t}),unsetBackgroundColor:()=>({commands:t})=>t.unsetMark(this.name)}}}),fi=({node:t,updateAttributes:r,selected:n})=>{const[l,o]=u.useState(!1),[k,b]=u.useState(0),[v,p]=u.useState(0),[w,x]=u.useState(0),[f,h]=u.useState(0),L=u.useCallback((d,_)=>{d.preventDefault(),o(!0),b(d.clientX),p(d.clientY),x(parseInt(t.attrs.width)),h(parseInt(t.attrs.height));const S=E=>{if(!l)return;const H=E.clientX-k,V=E.clientY-v;let $=w,z=f;_.includes("right")&&($=Math.max(200,w+H)),_.includes("left")&&($=Math.max(200,w-H)),_.includes("bottom")&&(z=Math.max(150,f+V)),_.includes("top")&&(z=Math.max(150,f-V)),r({width:`${$}px`,height:`${z}px`})},R=()=>{o(!1),document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",R)},[l,k,v,w,f,t.attrs.width,t.attrs.height,r]),A=d=>{r({align:d})};return e.jsx(B.NodeViewWrapper,{className:`resizable-youtube-wrapper ${n?"ProseMirror-selectednode":""}`,style:{textAlign:t.attrs.align,position:"relative",display:"inline-block"},children:e.jsxs("div",{className:"resizable-youtube-container",style:{position:"relative",display:"inline-block",width:t.attrs.width,height:t.attrs.height},children:[e.jsx("iframe",{src:t.attrs.src,width:t.attrs.width,height:t.attrs.height,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,style:{display:"block",width:"100%",height:"100%"}}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"resize-handle resize-handle-bottom-right",onMouseDown:d=>L(d,"bottom-right"),style:{position:"absolute",bottom:"-5px",right:"-5px",width:"10px",height:"10px",backgroundColor:"#007acc",cursor:"nw-resize",borderRadius:"2px"}}),e.jsx("div",{className:"resize-handle resize-handle-bottom-left",onMouseDown:d=>L(d,"bottom-left"),style:{position:"absolute",bottom:"-5px",left:"-5px",width:"10px",height:"10px",backgroundColor:"#007acc",cursor:"ne-resize",borderRadius:"2px"}}),e.jsx("div",{className:"resize-handle resize-handle-top-right",onMouseDown:d=>L(d,"top-right"),style:{position:"absolute",top:"-5px",right:"-5px",width:"10px",height:"10px",backgroundColor:"#007acc",cursor:"ne-resize",borderRadius:"2px"}}),e.jsx("div",{className:"resize-handle resize-handle-top-left",onMouseDown:d=>L(d,"top-left"),style:{position:"absolute",top:"-5px",left:"-5px",width:"10px",height:"10px",backgroundColor:"#007acc",cursor:"nw-resize",borderRadius:"2px"}}),e.jsxs("div",{className:"alignment-controls",style:{position:"absolute",top:"-30px",left:"0",display:"flex",gap:"5px",backgroundColor:"white",border:"1px solid #ccc",borderRadius:"4px",padding:"2px"},children:[e.jsx("button",{onClick:()=>A("left"),style:{padding:"2px 6px",border:"none",backgroundColor:t.attrs.align==="left"?"#007acc":"transparent",color:t.attrs.align==="left"?"white":"black",cursor:"pointer",borderRadius:"2px"},type:"button",children:"←"}),e.jsx("button",{onClick:()=>A("center"),style:{padding:"2px 6px",border:"none",backgroundColor:t.attrs.align==="center"?"#007acc":"transparent",color:t.attrs.align==="center"?"white":"black",cursor:"pointer",borderRadius:"2px"},type:"button",children:"⟷"}),e.jsx("button",{onClick:()=>A("right"),style:{padding:"2px 6px",border:"none",backgroundColor:t.attrs.align==="right"?"#007acc":"transparent",color:t.attrs.align==="right"?"white":"black",cursor:"pointer",borderRadius:"2px"},type:"button",children:"→"})]})]})]})})},Ke=li.extend({addAttributes(){return{...this.parent?.(),width:{default:"640px",renderHTML:t=>({width:t.width})},height:{default:"360px",renderHTML:t=>({height:t.height})},align:{default:"center",renderHTML:t=>({"data-align":t.align}),parseHTML:t=>t.getAttribute("data-align")||"center"}}},addNodeView(){return B.ReactNodeViewRenderer(fi)}}),mi=De.createLowlight(De.common);function Je(){return[Ft.configure({heading:{levels:[1,2,3,4,5,6]},codeBlock:!1,blockquote:!1,horizontalRule:!1,hardBreak:!1,strike:!1}),We,Oe,Ve.configure({allowBase64:!0}),Ye,oi,Xt,Ue,ti,ii,Dt.configure({resizable:!0,HTMLAttributes:{class:"editor-table"}}),qt,$t,zt,Wt.configure({openOnClick:!1,HTMLAttributes:{class:"editor-link",rel:"noopener noreferrer"}}),Ot.configure({types:["heading","paragraph"]}),Vt,Yt,Gt,Ut,Kt.CodeBlockLowlight.configure({lowlight:mi,HTMLAttributes:{class:"editor-code-block"}}),Ke.configure({controls:!0,nocookie:!1}),ri.configure({placeholder:"Start typing..."}),ni,si,Zt.configure({HTMLAttributes:{class:"editor-blockquote"}}),Qt,ei,Jt,Ge.configure({HTMLAttributes:{class:"editor-text-style"}})]}function Xe({className:t="",placeholder:r="Start typing..."}){return{attributes:{class:`prose focus:outline-none ${t} ${r?"has-placeholder":""}`,"aria-label":"Rich text editor","aria-placeholder":r}}}function xi(t,r){t.chain().focus().setMark("customTextStyle",{fontSize:r}).run()}function gi(t,r){t.chain().focus().setBackgroundColor(r).run()}function yi(t,r){!r||r===""?t.chain().focus().unsetMark("customTextStyle",{fontFamily:null}).run():t.chain().focus().setMark("customTextStyle",{fontFamily:r}).run()}function bi(t){t&&t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}function he(t,r){if(Array.isArray(r))if(r.length>1){const l=[{type:"imageGroup",content:r.map(o=>({type:"image",attrs:{src:o,width:"250px"}}))}];t.chain().focus().insertContent(l).run()}else r.length===1&&t.chain().focus().setImage({src:r[0],width:"500px"}).run();else typeof r=="string"&&t.chain().focus().setImage({src:r,width:"500px"}).run()}function Ze(t,r){try{t&&t.chain().focus().insertContent({type:"math",attrs:{latex:r}}).run()}catch(n){throw console.error("Math insertion error:",n),new Error("Error inserting math equation")}}const y=u.memo(u.forwardRef(({onClick:t,isActive:r,title:n,children:l,shortcut:o,disabled:k},b)=>{const v=u.useRef(null),p=u.useRef(null),w=u.useCallback(()=>{if(!v.current||!p.current)return;const x=p.current.getBoundingClientRect(),f=v.current;f.style.left=`${x.left+x.width/2}px`,f.style.top=`${x.top-8}px`;const h=f.getBoundingClientRect();h.left<0&&(f.style.left="0px",f.style.transform="none"),h.right>window.innerWidth&&(f.style.left=`${window.innerWidth}px`,f.style.transform="translateX(-100%)")},[]);return u.useEffect(()=>{const x=()=>{w()},f=()=>{w()};return window.addEventListener("scroll",x,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",f)}},[w]),e.jsxs("div",{className:"tooltip-container",onMouseEnter:w,children:[e.jsx("button",{ref:x=>{p.current=x,typeof b=="function"?b(x):b&&(b.current=x)},onClick:t,className:`toolbar-button ${r?"is-active":""} ${k?"is-disabled":""}`,"aria-label":n,"aria-pressed":r,disabled:k,type:"button",children:l}),e.jsxs("div",{ref:v,className:"tooltip",children:[n,o&&e.jsx("span",{className:"tooltip-shortcut",children:o})]})]})}));y.displayName="ToolbarButton";const vi=({editor:t,readOnly:r})=>e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Text alignment",children:[e.jsx(y,{onClick:()=>t?.chain().focus().setTextAlign("left").run(),isActive:t?.isActive({textAlign:"left"}),title:"Align Left",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"4",y1:"12",x2:"14",y2:"12"}),e.jsx("line",{x1:"4",y1:"18",x2:"18",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().setTextAlign("center").run(),isActive:t?.isActive({textAlign:"center"}),title:"Align Center",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"6"}),e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"8",y1:"18",x2:"16",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().setTextAlign("right").run(),isActive:t?.isActive({textAlign:"right"}),title:"Align Right",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"6",y1:"18",x2:"20",y2:"18"})]})})]}),ji=({editor:t,readOnly:r})=>e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Blocks",children:[e.jsx(y,{onClick:()=>t?.chain().focus().toggleBlockquote().run(),isActive:t?.isActive("blockquote"),title:"Blockquote",disabled:!t||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"}),e.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",disabled:!t||r,children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),e.jsx(y,{onClick:()=>t?.chain().focus().setHardBreak().run(),title:"Line Break",disabled:!t||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 8H3M21 8L17 4M21 8L17 12"}),e.jsx("path",{d:"M3 16H15M3 16L7 12M3 16L7 20"})]})})]}),ki=["12px","14px","16px","18px","20px","24px","28px","32px","36px","48px"],wi=[{name:"Default",value:""},{name:"Arial",value:"Arial, Helvetica, sans-serif"},{name:"Times New Roman",value:"'Times New Roman', Times, serif"},{name:"Georgia",value:"Georgia, serif"},{name:"Courier New",value:"'Courier New', Courier, monospace"},{name:"Verdana",value:"Verdana, Geneva, sans-serif"},{name:"Tahoma",value:"Tahoma, Geneva, sans-serif"},{name:"Trebuchet MS",value:"'Trebuchet MS', Helvetica, sans-serif"},{name:"Roboto",value:"Roboto, Arial, sans-serif"},{name:"Open Sans",value:"'Open Sans', Arial, sans-serif"},{name:"Noto Sans Bengali",value:"'Noto Sans Bengali', 'Noto Sans Bengali UI', 'Noto Sans', sans-serif"},{name:"SolaimanLipi",value:"'SolaimanLipi', 'Noto Sans Bengali', 'Noto Sans', sans-serif"},{name:"Siyam Rupali",value:"'Siyam Rupali', 'Noto Sans Bengali', 'Noto Sans', sans-serif"},{name:"Kalpurush",value:"'Kalpurush', 'Noto Sans Bengali', 'Noto Sans', sans-serif"},{name:"Nikosh",value:"'Nikosh', 'Noto Sans Bengali', 'Noto Sans', sans-serif"}],Ci=[1,2,3,4,5,6],Ri=({editor:t,readOnly:r})=>e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Font style",children:[e.jsxs("div",{className:"tooltip-container",children:[e.jsxs("select",{onChange:n=>yi(t,n.target.value),disabled:!t||r,defaultValue:"",style:{height:36,marginRight:4,minWidth:110,fontSize:"12px"},"aria-label":"Font family",children:[e.jsx("option",{value:"",children:"Font"}),wi.map(n=>e.jsx("option",{value:n.value,children:n.name},n.value))]}),e.jsx("div",{className:"tooltip",children:"Select Font Family"})]}),e.jsxs("div",{className:"tooltip-container",children:[e.jsxs("select",{onChange:n=>xi(t,n.target.value),disabled:!t||r,defaultValue:"",style:{height:36,marginRight:4,minWidth:65,fontSize:"12px"},"aria-label":"Font size",children:[e.jsx("option",{value:"",children:"Size"}),ki.map(n=>e.jsx("option",{value:n,children:n},n))]}),e.jsx("div",{className:"tooltip",children:"Select Font Size"})]}),e.jsxs("div",{className:"tooltip-container",style:{position:"relative"},children:[e.jsx("input",{type:"color","aria-label":"Text Color",disabled:!t||r,onChange:n=>t?.chain().focus().setColor(n.target.value).run(),style:{width:36,height:36,border:"2px solid rgba(226, 232, 240, 0.8)",borderRadius:"0.375rem",background:"none",cursor:"pointer",marginRight:4}}),e.jsx("div",{className:"tooltip",children:"Text Color"})]}),e.jsxs("div",{className:"tooltip-container",style:{position:"relative"},children:[e.jsx("input",{type:"color","aria-label":"Background Color",disabled:!t||r,onChange:n=>gi(t,n.target.value),style:{width:36,height:36,border:"2px solid rgba(226, 232, 240, 0.8)",borderRadius:"0.375rem",background:"none",cursor:"pointer",marginRight:4}}),e.jsx("div",{className:"tooltip",children:"Background Color"})]})]}),Ei=({editor:t,readOnly:r})=>e.jsx("div",{className:"toolbar-group",role:"group","aria-label":"Headings",children:Ci.map(n=>e.jsxs(y,{onClick:()=>t?.chain().focus().toggleHeading({level:n}).run(),isActive:t?.isActive("heading",{level:n}),title:`Heading ${n}`,disabled:!t||r,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"icon icon-tabler icons-tabler-outline icon-tabler-heading",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M7 12h10"}),e.jsx("path",{d:"M7 5v14"}),e.jsx("path",{d:"M17 5v14"}),e.jsx("path",{d:"M15 19h4"}),e.jsx("path",{d:"M15 5h4"}),e.jsx("path",{d:"M5 19h4"}),e.jsx("path",{d:"M5 5h4"})]}),n]},n))}),Ai=({editor:t,readOnly:r})=>!t?.isActive("image")||t?.isActive("imageGroup")?null:e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Image alignment",children:[e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("image",{align:"left"}).run(),isActive:t?.isActive("image",{align:"left"}),title:"Align Image Left",disabled:!t?.isActive("image")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("image",{align:"center"}).run(),isActive:t?.isActive("image",{align:"center"}),title:"Align Image Center",disabled:!t?.isActive("image")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("image",{align:"right"}).run(),isActive:t?.isActive("image",{align:"right"}),title:"Align Image Right",disabled:!t?.isActive("image")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]})})]}),Mi=({editor:t,readOnly:r})=>t?.isActive("imageGroup")?e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Image group alignment",children:[e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("imageGroup",{align:"left"}).run(),isActive:t?.isActive("imageGroup",{align:"left"}),title:"Align Group Left",disabled:!t?.isActive("imageGroup")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("imageGroup",{align:"center"}).run(),isActive:t?.isActive("imageGroup",{align:"center"}),title:"Align Group Center",disabled:!t?.isActive("imageGroup")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("imageGroup",{align:"right"}).run(),isActive:t?.isActive("imageGroup",{align:"right"}),title:"Align Group Right",disabled:!t?.isActive("imageGroup")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]})})]}):null,Ti=({editor:t,readOnly:r})=>e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Lists",children:[e.jsx(y,{onClick:()=>t?.chain().focus().toggleBulletList().run(),isActive:t?.isActive("bulletList"),title:"Bullet List",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"}),e.jsx("circle",{cx:"5",cy:"6",r:"1"}),e.jsx("circle",{cx:"5",cy:"12",r:"1"}),e.jsx("circle",{cx:"5",cy:"18",r:"1"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleOrderedList().run(),isActive:t?.isActive("orderedList"),title:"Numbered List",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"11",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"11",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"11",y1:"18",x2:"20",y2:"18"}),e.jsx("text",{x:"5",y:"8",fontSize:"4",children:"1"}),e.jsx("text",{x:"5",y:"14",fontSize:"4",children:"2"}),e.jsx("text",{x:"5",y:"20",fontSize:"4",children:"3"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleTaskList().run(),isActive:t?.isActive("taskList"),title:"Task List",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),e.jsx("path",{d:"M9 12l2 2l4 -4"})]})})]}),Li=({editor:t,readOnly:r,onMathDialogOpen:n,onImagePicker:l})=>e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Special features",children:[e.jsx(y,{onClick:n,title:"Insert Math Equation",disabled:!t||r,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"icon icon-tabler icons-tabler-outline icon-tabler-math",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M19 5h-7l-4 14l-3 -6h-2"}),e.jsx("path",{d:"M14 13l6 6"}),e.jsx("path",{d:"M14 19l6 -6"})]})}),e.jsx(y,{onClick:l,title:"Insert Image",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),e.jsx(y,{onClick:()=>bi(t),title:"Insert Table",disabled:!t||r,children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 3h18v18H3zM12 3v18M3 12h18M3 8h18M3 16h18"})})}),e.jsx(y,{onClick:()=>{const o=window.prompt("Enter YouTube video URL:");o&&t.chain().focus().setYoutubeVideo({src:o}).run()},title:"Insert YouTube Video",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"3"}),e.jsx("polygon",{points:"10,9 16,12 10,15",fill:"currentColor"})]})})]}),Si=({editor:t,readOnly:r})=>e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Text formatting",children:[e.jsx(y,{onClick:()=>{if(!t)return;const n=t.getAttributes("link").href||"",l=window.prompt("Enter URL:",n);if(l!==null){if(l===""){t.chain().focus().unsetLink().run();return}t.chain().focus().setLink({href:l}).run()}},isActive:t?.isActive("link"),title:"Insert/Edit Link",shortcut:"Ctrl+K",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().unsetLink().run(),isActive:!1,title:"Remove Link",disabled:!t||r||!t?.isActive("link"),children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),e.jsx("line",{x1:"17",y1:"7",x2:"7",y2:"17"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleBold().run(),isActive:t?.isActive("bold"),title:"Bold",shortcut:"Ctrl+B",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 5h6a3 3 0 0 1 0 6H7z"}),e.jsx("path",{d:"M7 11h8a3 3 0 0 1 0 6H7z"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleItalic().run(),isActive:t?.isActive("italic"),title:"Italic",shortcut:"Ctrl+I",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),e.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),e.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleUnderline().run(),isActive:t?.isActive("underline"),title:"Underline",shortcut:"Ctrl+U",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),e.jsx("line",{x1:"4",y1:"20",x2:"20",y2:"20"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleStrike().run(),isActive:t?.isActive("strike"),title:"Strike-through",shortcut:"Ctrl+Shift+S",disabled:!t||r,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"icon icon-tabler icons-tabler-outline icon-tabler-strikethrough",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M5 12l14 0"}),e.jsx("path",{d:"M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleHighlight().run(),isActive:t?.isActive("highlight"),title:"Highlight",disabled:!t||r,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"icon icon-tabler icons-tabler-outline icon-tabler-highlight",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),e.jsx("path",{d:"M12.5 5.5l4 4"}),e.jsx("path",{d:"M4.5 13.5l4 4"}),e.jsx("path",{d:"M21 15v4h-8l4 -4z"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleSubscript().run(),isActive:t?.isActive("subscript"),title:"Subscript",disabled:!t||r,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"icon icon-tabler icons-tabler-outline icon-tabler-subscript",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M5 7l8 10m-8 0l8 -10"}),e.jsx("path",{d:"M21 20h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().toggleSuperscript().run(),isActive:t?.isActive("superscript"),title:"Superscript",disabled:!t||r,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"icon icon-tabler icons-tabler-outline icon-tabler-superscript",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M5 7l8 10m-8 0l8 -10"}),e.jsx("path",{d:"M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().unsetAllMarks().run(),title:"Clear Formatting",disabled:!t||r,children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17 17L7 7"}),e.jsx("path",{d:"M7 17l10-10"})]})})]}),Ni=({editor:t,readOnly:r})=>t?.isActive("youtube")?e.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"YouTube controls",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("youtube",{align:"left"}).run(),isActive:t?.isActive("youtube",{align:"left"}),title:"Align YouTube Left",disabled:!t?.isActive("youtube")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("youtube",{align:"center"}).run(),isActive:t?.isActive("youtube",{align:"center"}),title:"Align YouTube Center",disabled:!t?.isActive("youtube")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),e.jsx(y,{onClick:()=>t?.chain().focus().updateAttributes("youtube",{align:"right"}).run(),isActive:t?.isActive("youtube",{align:"right"}),title:"Align YouTube Right",disabled:!t?.isActive("youtube")||r,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]})}),e.jsx("input",{type:"number",min:100,max:1920,step:10,value:parseInt(t.getAttributes("youtube").width||640,10),onChange:n=>t.chain().focus().updateAttributes("youtube",{width:`${n.target.value}px`}).run(),style:{width:60,marginLeft:8,marginRight:2,fontSize:14,padding:"2px 4px"},"aria-label":"YouTube width",disabled:!t?.isActive("youtube")||r,title:"YouTube Width"}),e.jsx("span",{style:{fontSize:14},children:"×"}),e.jsx("input",{type:"number",min:56,max:1080,step:10,value:parseInt(t.getAttributes("youtube").height||360,10),onChange:n=>t.chain().focus().updateAttributes("youtube",{height:`${n.target.value}px`}).run(),style:{width:60,marginLeft:2,fontSize:14,padding:"2px 4px"},"aria-label":"YouTube height",disabled:!t?.isActive("youtube")||r,title:"YouTube Height"})]}):null,_i=t=>{const{editor:r,readOnly:n,onMathDialogOpen:l,onImagePicker:o}=t;return e.jsx("div",{className:"toolbar",role:"toolbar","aria-label":"Editor toolbar",children:e.jsxs("div",{className:"toolbar-content",children:[e.jsx(Ri,{editor:r,readOnly:n}),e.jsx("div",{className:"toolbar-divider"}),e.jsx(Si,{editor:r,readOnly:n}),e.jsx("div",{className:"toolbar-divider"}),e.jsx(Ei,{editor:r,readOnly:n}),e.jsx("div",{className:"toolbar-divider"}),e.jsx(Ti,{editor:r,readOnly:n}),e.jsx("div",{className:"toolbar-divider"}),e.jsx(vi,{editor:r,readOnly:n}),e.jsx("div",{className:"toolbar-divider"}),e.jsx(ji,{editor:r,readOnly:n}),e.jsx("div",{className:"toolbar-divider"}),e.jsxs("div",{className:"toolbar-media-group",style:{alignItems:"center",display:"flex"},children:[e.jsx(Ai,{editor:r,readOnly:n}),e.jsx(Mi,{editor:r,readOnly:n}),e.jsx(Ni,{editor:r,readOnly:n})]}),e.jsx(Li,{editor:r,readOnly:n,onMathDialogOpen:l||(()=>{}),onImagePicker:o||(()=>{})})]})})},Pi=({isLoading:t})=>e.jsx("div",{children:t&&e.jsx("div",{className:"loading-overlay",children:e.jsx("div",{className:"spinner"})})}),Qe=()=>typeof window>"u"?Promise.resolve():import("mathlive").then(()=>{});Qe();const et=u.forwardRef(({onClose:t,onInsert:r,initialValue:n=""},l)=>{const[o,k]=u.useState(n),[b,v]=u.useState("bas