cvnert-editor 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- (function(H,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("react"),require("@tiptap/react"),require("react-dom"),require("@tiptap/starter-kit"),require("@tiptap/extension-mention"),require("@tiptap/extension-list"),require("@tiptap/extension-text-style"),require("@tiptap/extensions"),require("@tiptap/extension-typography"),require("@tiptap/extension-highlight"),require("@tiptap/extension-superscript"),require("@tiptap/extension-subscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-mathematics"),require("@tiptap/extension-unique-id"),require("@tiptap/extension-emoji"),require("@tiptap/extension-table-of-contents"),require("@tiptap/core"),require("clsx"),require("@tiptap/pm/state"),require("@tiptap/pm/tables"),require("@tiptap/extension-horizontal-rule"),require("@tiptap/extension-image"),require("@tiptap/extension-code-block"),require("echarts"),require("mermaid"),require("@floating-ui/react"),require("@tiptap/extension-table/table"),require("@tiptap/extension-table"),require("@tiptap/pm/transform"),require("@tiptap/pm/view"),require("@ariakit/react"),require("class-variance-authority"),require("react-hotkeys-hook"),require("@radix-ui/react-popover"),require("@base-ui/react/merge-props"),require("@base-ui/react/use-render"),require("@tiptap/suggestion"),require("@tiptap/extension-drag-handle-react"),require("@tiptap/pm/model"),require("lodash.throttle"),require("@radix-ui/react-dropdown-menu")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tiptap/react","react-dom","@tiptap/starter-kit","@tiptap/extension-mention","@tiptap/extension-list","@tiptap/extension-text-style","@tiptap/extensions","@tiptap/extension-typography","@tiptap/extension-highlight","@tiptap/extension-superscript","@tiptap/extension-subscript","@tiptap/extension-text-align","@tiptap/extension-mathematics","@tiptap/extension-unique-id","@tiptap/extension-emoji","@tiptap/extension-table-of-contents","@tiptap/core","clsx","@tiptap/pm/state","@tiptap/pm/tables","@tiptap/extension-horizontal-rule","@tiptap/extension-image","@tiptap/extension-code-block","echarts","mermaid","@floating-ui/react","@tiptap/extension-table/table","@tiptap/extension-table","@tiptap/pm/transform","@tiptap/pm/view","@ariakit/react","class-variance-authority","react-hotkeys-hook","@radix-ui/react-popover","@base-ui/react/merge-props","@base-ui/react/use-render","@tiptap/suggestion","@tiptap/extension-drag-handle-react","@tiptap/pm/model","lodash.throttle","@radix-ui/react-dropdown-menu"],r):(H=typeof globalThis<"u"?globalThis:H||self,r(H.CvnertEditor={},H.jsxRuntime,H.React,H.tiptapReact,H.ReactDOM,H.tiptapStarterKit,H.tiptapExtensionMention,H.tiptapExtensionList,H.tiptapExtensionTextStyle,H.tiptapExtensions,H.tiptapExtensionTypography,H.tiptapExtensionHighlight,H.tiptapExtensionSuperscript,H.tiptapExtensionSubscript,H.tiptapExtensionTextAlign,H.tiptapExtensionMathematics,H.tiptapExtensionUniqueId,H.tiptapExtensionEmoji,H.tiptapExtensionTableOfContents,H.tiptapCore,H.clsx,H.tiptapPmState,H.tiptapPmTables,H.tiptapExtensionHorizontalRule,H.tiptapExtensionImage,H.tiptapExtensionCodeBlock,H.echarts,H.mermaid,H.floatingUiReact,H.tiptapExtensionTableTable,H.tiptapExtensionTable,H.tiptapPmTransform,H.tiptapPmView,H.ariakitReact,H.classVarianceAuthority,H.reactHotkeysHook,H.radixUiReactPopover,H.baseUiReactMergeProps,H.baseUiReactUseRender,H.tiptapSuggestion,H.tiptapExtensionDragHandleReact,H.tiptapPmModel,H.lodash.throttle,H.radixUiReactDropdownMenu))})(this,(function(H,r,u,P,Ba,Da,Ua,Zo,Fo,$o,Oa,Pa,Za,Fa,$a,za,Wa,zo,Wo,be,_a,M,I,qa,Ka,Ga,Ya,Xa,D,ja,qt,_o,We,Qa,Kt,ie,Ja,c4,d4,qo,Ra,Ko,ei,ti){"use strict";function Qe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ht=Qe(u),ni=Qe(Ya),se=Qe(Qa),pt=Qe(Ja),ge=Qe(ti),Ae={commentInputVisible:!1,lockDragHandle:!1,isDragging:!1},oi=be.Extension.create({name:"uiState",addStorage(){return{uiState:{...Ae}}},addCommands(){const e=n=>o=>()=>(this.storage[n]=o,!0),t=(n,o)=>()=>()=>(this.storage[n]=o,!0);return{commentInputShow:t("commentInputVisible",!0),commentInputHide:t("commentInputVisible",!1),setLockDragHandle:e("lockDragHandle"),setIsDragging:e("isDragging"),resetUiState:()=>()=>(Object.assign(this.storage,{...Ae}),!0)}},onCreate(){this.storage={...Ae}}});function Gt(e){return P.useEditorState({editor:e,selector:({editor:t})=>{if(!t)return Ae;const n=t.storage.uiState;return n?{...Ae,...n}:(console.warn("Editor storage uiState is not initialized. Ensure you have the uiState extension added to your editor."),Ae)}})??Ae}function ri(e){const n=e.storage.pages;return!n||!("activeEditor"in n)?null:n.activeEditor??null}function S(e){const{editor:t}=P.useCurrentEditor(),n=e??t,[o,l]=u.useState(null);return u.useEffect(()=>{if(!n){l(null);return}const a=()=>l(ri(n));return a(),n.on("update",a),n.on("selectionUpdate",a),()=>{n.off("update",a),n.off("selectionUpdate",a)}},[n]),u.useEffect(()=>{if(!o)return;const a=()=>l(null);return o.on("destroy",a),()=>{o.off("destroy",a)}},[o]),P.useEditorState({editor:o??n,selector(a){return a.editor?{editor:a.editor,editorState:a.editor.state,canCommand:a.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})??{editor:null}}const Yt=5*1024*1024,li={mod:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",shift:"⇧",backspace:"Del",delete:"⌦",enter:"⏎",escape:"⎋",capslock:"⇪"},Xt={position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:0};function U(...e){return _a.clsx(e)}function si(){return typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac")}const ai=(e,t,n=!0)=>{if(t){const o=e.toLowerCase();return li[o]||(n?e.toUpperCase():e)}return n?e.charAt(0).toUpperCase()+e.slice(1):e},G=e=>{const{shortcutKeys:t,delimiter:n="+",capitalize:o=!0}=e;return t?t.split(n).map(l=>l.trim()).map(l=>ai(l,si(),o)):[]},xe=(e,t)=>t?.schema?t.schema.spec.marks.get(e)!==void 0:!1,Q=(e,t)=>t?.schema?t.schema.spec.nodes.get(e)!==void 0:!1;function ii(e){const{state:t,view:n}=e,{doc:o,selection:l}=t,s=M.Selection.findFrom(l.$to,1,!0);if(s)return n.dispatch(t.tr.setSelection(s).scrollIntoView()),!0;const a=t.schema.nodes.paragraph;if(!a)return console.warn("No paragraph node type found in schema."),!1;const i=o.content.size,c=a.create();let d=t.tr.insert(i,c);const f=d.doc.resolve(i+1);return d=d.setSelection(M.TextSelection.near(f)).scrollIntoView(),n.dispatch(d),!0}function K(e){return typeof e=="number"&&e>=0}function V(e,t){if(!e)return!1;const n=Array.isArray(t)?t:[t],o=n.some(l=>e.extensionManager.extensions.some(s=>s.name===l));return o||console.warn(`None of the extensions [${n.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`),o}function ci(e,t){try{const n=e.state.doc.nodeAt(t);return n||(console.warn(`No node found at position ${t}`),null)}catch(n){return console.error(`Error getting node at position ${t}:`,n),null}}function Ce(e){const{editor:t,node:n,nodePos:o}=e;if(!t||!t.state?.doc)return null;const l=n!=null,s=K(o);if(!l&&!s)return null;if(l){let a=-1,i=null;if(t.state.doc.descendants((c,d)=>c===n?(a=d,i=c,!1):!0),a!==-1&&i!==null)return{pos:a,node:i}}if(s){const a=ci(t,o);if(a)return{pos:o,node:a}}return null}function re(e,t=[],n=!1){if(!e||!e.state.selection)return!1;const{selection:o}=e.state;if(o.empty)return!1;if(o instanceof M.NodeSelection){const l=o.node;return l?t.includes(l.type.name):!1}if(n){const{$from:l}=o;for(let s=l.depth;s>0;s--){const a=l.node(s);if(t.includes(a.type.name))return!0}}return!1}function we(e,t=[]){if(!e||t.length===0)return!1;const{state:n}=e,{selection:o}=n,l=new Set(t);if(o instanceof M.NodeSelection){const s=o.node?.type?.name;return!!s&&l.has(s)}if(o instanceof M.TextSelection||o instanceof M.AllSelection){let s=!0;return n.doc.nodesBetween(o.from,o.to,a=>a.isTextblock&&!l.has(a.type.name)?(s=!1,!1):s),s}return!1}const di=async(e,t,n)=>{if(!e)throw new Error("No file provided");if(e.size>Yt)throw new Error(`File size exceeds maximum allowed (${Yt/(1024*1024)}MB)`);for(let o=0;o<=100;o+=10){if(n?.aborted)throw new Error("Upload cancelled");await new Promise(l=>setTimeout(l,500)),t?.({progress:o})}return"/images/tiptap-ui-placeholder-image.jpg"},ui=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function fi(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!e||e.replace(ui,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function jt(e,t,n){try{const o=new URL(e,t);if(fi(o.href,n))return o.href}catch{}return"#"}function Qt(e,t,n,o){if(!t.length)return!1;let l=!1;for(const{pos:s}of t){const a=e.doc.nodeAt(s);if(!a)continue;const i=a.attrs[n],c=typeof o=="function"?o(i):o;if(i===c)continue;const d={...a.attrs};c===void 0?delete d[n]:d[n]=c,e.setNodeMarkup(s,void 0,d),l=!0}return l}function hi(e){const{selection:t,doc:n}=e.state;if(!t.empty)return;const o=t.$from;let l=null,s=-1;for(let a=o.depth;a>=0;a--){const i=o.node(a),c=o.start(a);if(i.isBlock&&i.textContent.trim()){l=i,s=c;break}}if(l&&s>=0){const a=s,i=s+l.nodeSize-2;if(a<i){const c=n.resolve(a),d=n.resolve(i),f=M.TextSelection.between(c,d,1);f&&!t.eq(f)&&e.view.dispatch(e.state.tr.setSelection(f))}}}function Je(e,t){const n=[],o=new Set(t);if(e instanceof I.CellSelection)return e.forEachCell((i,c)=>{o.has(i.type.name)&&n.push({node:i,pos:c})}),n;if(e instanceof M.NodeSelection){const{node:i,from:c}=e;return i&&o.has(i.type.name)&&n.push({node:i,pos:c}),n}const{$anchor:l}=e,s=I.cellAround(l);if(s){const i=e.$anchor.doc.nodeAt(s.pos);if(i&&o.has(i.type.name))return n.push({node:i,pos:s.pos}),n}const a=P.findParentNodeClosestToPos(l,i=>o.has(i.type.name));return a&&n.push({node:a.node,pos:a.pos}),n}function Jt(e,t,n){return Math.max(t,Math.min(e,n))}function Re(e){const{doc:t}=e.state,{from:n,to:o}=e.state.selection,l=[],s=new Set;return t.nodesBetween(n,o,(a,i)=>{if(a.isBlock)return s.has(i)||(s.add(i),l.push(a)),!1}),l}function Go(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,o)=>e.slice(o*t,o*t+t))}function Yo(e,t){if(!e)return null;const{state:n}=e,{from:o,to:l,empty:s,$from:a}=n.selection;if(s)return a.marks().find(f=>f.type.name===t)?.attrs??null;const i=new Set;let c=null;return n.doc.nodesBetween(o,l,d=>{if(d.isText)for(const f of d.marks)f.type.name===t&&!i.has(f.type.name)&&(i.add(f.type.name),c=f.attrs)}),c}function et(e,t=!0){if(!e)return null;const{state:n}=e,{selection:o}=n;if(o instanceof M.NodeSelection){const c=o.node,d=o.from;if(c&&K(d))return{node:c,pos:d}}if(o.empty&&!t)return null;const l=o.$anchor,s=1,a=l.node(s),i=l.before(s);return{node:a,pos:i}}function Xo(e,t){if(!e)return null;const n=e.extensionManager.extensions.find(o=>o.name===t);return n||(console.warn(`Extension "${t}" not found in the editor schema. Ensure it is included in the editor configuration.`),null)}const jo="hideFloatingToolbar";function pi(e){const{editor:t,isSelectionValid:n,extraHideWhen:o=!1}=e,[l,s]=u.useState(!1),a=u.useRef(!1);return u.useEffect(()=>{if(!t)return;const i=({transaction:c})=>{c.getMeta(jo)?a.current=!0:c.selectionSet&&(a.current=!1)};return t.on("transaction",i),()=>{t.off("transaction",i)}},[t]),u.useEffect(()=>{if(!t)return;const i=t.view.dom,c=d=>{const f=t.state.selection;if(!(f instanceof M.NodeSelection))return;const h=t.view.nodeDOM(f.from);if(h&&h.contains(d.target)){a.current=!1;const p=n(t,f);s(p&&!o)}};return i.addEventListener("pointerdown",c,{capture:!0}),()=>i.removeEventListener("pointerdown",c,{capture:!0})},[t,o,n]),u.useEffect(()=>{if(!t)return;const i=()=>{const{selection:c}=t.state,d=n(t,c);if(o||P.isNodeSelection(c)&&a.current){s(!1);return}s(d)};return i(),t.on("selectionUpdate",i),()=>{t.off("selectionUpdate",i)}},[t,o,n]),{shouldShow:l}}const Rt=(e,t)=>{if(!e)return;const{state:n,view:o}=e;o.dispatch(n.tr.setSelection(M.NodeSelection.create(n.doc,t)).setMeta(jo,!0))};function Ci(e={}){const{editor:t,onTargetFound:n=()=>{},onTargetNotFound:o=()=>{}}=e,{editor:l}=S(t),s=u.useRef(null),a=u.useRef(n),i=u.useRef(o);a.current=n,i.current=o;const c=u.useCallback(f=>{if(!l)return!1;const h=Xo(l,"uniqueID")?.options?.attributeName??"data-id";let p=null;return l.state.doc.descendants((C,b)=>C.attrs?.[h]===f?(p=b,!1):!0),p===null?!1:(Rt(l,p),setTimeout(()=>{const C=l.view.nodeDOM(p);C&&C.scrollIntoView({behavior:"smooth",block:"center"})},0),!0)},[l]),d=u.useCallback((f=0)=>{const h=window.location.hash?.substring(1);h&&h!==s.current&&setTimeout(()=>{c(h)?(s.current=h,a.current(h)):i.current(h)},f)},[c]);return u.useEffect(()=>{l&&d(500)},[l,d]),u.useEffect(()=>{const f=()=>d(),h=()=>d(500);return window.addEventListener("hashchange",f),window.addEventListener("pageshow",h),window.addEventListener("popstate",f),()=>{window.removeEventListener("hashchange",f),window.removeEventListener("pageshow",h),window.removeEventListener("popstate",f)}},[d]),{scrollToHash:c}}const gi=qa.extend({renderHTML(){return["div",P.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}});function bi(e){const{editor:t,node:n,updateAttributes:o,getPos:l}=e,s=n.content.size>0;return r.jsx(wi,{src:n.attrs.src,alt:n.attrs.alt||"",editor:t,align:n.attrs["data-align"],initialWidth:n.attrs.width,showCaption:n.attrs.showCaption,hasContent:s,nodeSize:n.nodeSize,onImageResize:a=>o({width:a}),onUpdateAttributes:o,getPos:l})}const wi=({src:e,alt:t="",editor:n,minWidth:o=96,maxWidth:l=800,align:s="left",initialWidth:a,showCaption:i=!1,hasContent:c=!1,nodeSize:d,onImageResize:f,onUpdateAttributes:h,getPos:p})=>{const[C,b]=u.useState(),[g,w]=u.useState(a),[v,m]=u.useState(!1),x=u.useRef(!1),y=u.useRef(!0),T=u.useRef(null),E=u.useRef(null),L=u.useRef(null),N=u.useRef(null);u.useEffect(()=>{if(!n||!i)return;const B=()=>{const j=p();if(!K(j)||!d)return;const{from:Ee,to:$e}=n.state.selection,ze=j,ye=j+d;($e<ze||Ee>ye)&&!c&&h&&h({showCaption:!1})};return n.on("selectionUpdate",B),()=>{n.off("selectionUpdate",B)}},[n,i,c,p,d,h]);const te=u.useCallback(B=>{if(!n||!p||C)return;B.preventDefault(),B.stopPropagation();const j=p();K(j)&&n.chain().focus().setNodeSelection(j).run()},[n,p,C]),O=u.useCallback(B=>{if(!C||!n||!y.current)return;const j="touches"in B?B.touches[0]?.clientX??0:B.clientX,Ee=C.handleUsed==="left",$e=s==="center"?2:1,ze=Ee?(C.initialClientX-j)*$e:(j-C.initialClientX)*$e,ye=C.initialWidth+ze,Le=n.view.dom?.firstElementChild?.clientWidth||l,je=Math.min(Math.max(ye,o),Le);w(je),T.current&&(T.current.style.width=`${je}px`)},[n,s,l,o,C]),_=u.useCallback(B=>{if(!n||!y.current)return;const j="touches"in B?document.elementFromPoint(B.changedTouches[0]?.clientX??0,B.changedTouches[0]?.clientY??0):B.target;if((!(j&&T.current?.contains(j))||!n.isEditable)&&v&&y.current&&m(!1),!C)return;const $e=n.state.selection instanceof M.NodeSelection&&n.state.selection.node.type.name==="image";y.current&&b(void 0),f?.(g);const ze=p();K(ze)&&$e&&y.current&&n.chain().focus().setNodeSelection(ze).run(),x.current=!1},[n,p,f,C,v,g]),$=u.useCallback((B,j)=>{b({handleUsed:B,initialWidth:T.current?.clientWidth??o,initialClientX:j}),x.current=!0},[o]),z=B=>{B.preventDefault(),B.stopPropagation(),$("left",B.clientX)},oe=B=>{B.preventDefault();const j=B.touches[0];j&&$("left",j.clientX)},Z=B=>{B.preventDefault(),B.stopPropagation(),$("right",B.clientX)},A=B=>{B.preventDefault();const j=B.touches[0];j&&$("right",j.clientX)},F=()=>{n?.isEditable&&y.current&&m(!0)},q=B=>{y.current&&(B.relatedTarget===E.current||B.relatedTarget===L.current||C||n?.isEditable&&m(!1))},ne=()=>{n?.isEditable&&y.current&&m(!0)};u.useEffect(()=>(window.addEventListener("mousemove",O),window.addEventListener("mouseup",_),window.addEventListener("touchmove",O,{passive:!1}),window.addEventListener("touchend",_),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",_),window.removeEventListener("touchmove",O),window.removeEventListener("touchend",_)}),[O,_]),u.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const pe=i||c;return r.jsx(P.NodeViewWrapper,{onMouseEnter:F,onMouseLeave:q,onTouchStart:ne,"data-align":s,"data-width":g,className:"tiptap-image",children:r.jsxs("div",{ref:T,className:"tiptap-image-container",style:{width:g?`${g}px`:"fit-content"},children:[r.jsxs("div",{className:"tiptap-image-content",children:[r.jsx("img",{ref:N,src:e,alt:t,className:"tiptap-image-img",contentEditable:!1,draggable:!1,onClick:te,style:{cursor:n?.isEditable?"pointer":"default"}}),v&&n?.isEditable&&r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:E,className:"tiptap-image-handle tiptap-image-handle-left",onMouseDown:z,onTouchStart:oe}),r.jsx("div",{ref:L,className:"tiptap-image-handle tiptap-image-handle-right",onMouseDown:Z,onTouchStart:A})]})]}),n?.isEditable&&pe&&r.jsx(P.NodeViewContent,{as:"div",className:"tiptap-image-caption","data-placeholder":"Add a caption..."})]})})},Qo=e=>({src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:e.getAttribute("width"),height:e.getAttribute("height")});function vi(e){const t={src:e.src||""};return e.alt&&(t.alt=e.alt),e.title&&(t.title=e.title),e.width&&(t.width=e.width),e.height&&(t.height=e.height),t}const mi=Ka.Image.extend({content:"inline*",addAttributes(){return{...this.parent?.(),"data-align":{default:null},showCaption:{default:!1,parseHTML:e=>e.tagName==="FIGURE"||e.getAttribute("data-show-caption")==="true",renderHTML:e=>e.showCaption?{"data-show-caption":"true"}:{}}}},parseHTML(){return[{tag:"figure",getAttrs:e=>{const t=e.querySelector("img");return t?{...Qo(t),"data-align":e.getAttribute("data-align"),showCaption:!0}:!1},contentElement:"figcaption"},{tag:"img[src]",getAttrs:e=>e.closest("figure")?!1:{...Qo(e),"data-align":e.getAttribute("data-align"),showCaption:!1}}]},renderHTML({node:e}){const{src:t,alt:n,title:o,width:l,height:s,showCaption:a}=e.attrs,i=e.attrs["data-align"],c=vi({src:t,alt:n,title:o,width:l,height:s}),d=e.content.size>0;if(a||d){const f={"data-url":t||""};return a&&(f["data-show-caption"]="true"),i&&(f["data-align"]=i),["figure",f,["img",c],["figcaption",{},0]]}return i&&(c["data-align"]=i),["img",c]},addKeyboardShortcuts(){const e=(t,n)=>{if(t instanceof M.NodeSelection&&t.node.type===n)return{imageNode:t.node,imagePos:t.from,atStart:!0,atEnd:!0};if(t.empty&&t.$from.parent.type===n){const{$from:o}=t;return{imageNode:o.parent,imagePos:o.before(),atStart:o.parentOffset===0,atEnd:o.parentOffset===o.parent.content.size}}return null};return{"Mod-a":({editor:t})=>{const{state:n,view:o}=t,{selection:l}=n,{$from:s}=l;let a=null,i=null;for(let p=s.depth;p>=0;p--){const C=s.node(p);if(C.type===this.type){i=C,a=p===0?0:s.before(p);break}}if(!i||a==null||i.content.size===0||i.textContent.length===0)return!1;const d=a+1,f=a+i.nodeSize-1,h=n.tr.setSelection(M.TextSelection.create(n.doc,d,f));return o.dispatch(h),!0},ArrowUp:({editor:t})=>{const{state:n}=t,o=e(n.selection,this.type);return!o||!o.atStart||o.imagePos!==0?!1:t.chain().insertContentAt(0,{type:"paragraph"}).setTextSelection(1).run()}}},addNodeView(){return P.ReactNodeViewRenderer(bi)}});function yi(e,t){if(e.length===0)return null;for(const n of e)if((n.node.attrs?.backgroundColor??null)!==t)return t;return null}const xi=be.Extension.create({name:"nodeBackground",addOptions(){return{types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader"],useStyle:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{const t=e.style?.backgroundColor;return t||e.getAttribute("data-background-color")||null},renderHTML:e=>{const t=e.backgroundColor;return t?this.options.useStyle?{style:`background-color: ${t}`}:{"data-background-color":t}:{}}}}}]},addCommands(){const e=t=>n=>({state:o,tr:l})=>{const s=Je(o.selection,this.options.types);if(s.length===0)return!1;const a=t(s,n);return Qt(l,s,"backgroundColor",a)};return{setNodeBackgroundColor:e((t,n)=>n||null),unsetNodeBackgroundColor:e(()=>null),toggleNodeBackgroundColor:e((t,n)=>yi(t,n||""))}}});function Jo(e,t,n){if(e.length===0)return null;for(const o of e)if((o.node.attrs?.[t]??null)!==n)return n;return null}const Si=be.Extension.create({name:"nodeAlignment",addOptions(){return{types:["paragraph","heading","blockquote","tableCell","tableHeader"],useStyle:!0,textAlignValues:["left","center","right","justify"],verticalAlignValues:["top","middle","bottom"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{nodeTextAlign:{default:null,parseHTML:e=>{const t=e.style?.textAlign;if(t&&this.options.textAlignValues.includes(t))return t;const n=e.getAttribute("data-node-text-align");return n&&this.options.textAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeTextAlign;return!t||!this.options.textAlignValues.includes(t)?{}:this.options.useStyle?{style:`text-align: ${t}`}:{"data-node-text-align":t}}},nodeVerticalAlign:{default:null,parseHTML:e=>{const t=e.style?.verticalAlign;if(t&&this.options.verticalAlignValues.includes(t))return t;const n=e.getAttribute("data-node-vertical-align");return n&&this.options.verticalAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeVerticalAlign;return!t||!this.options.verticalAlignValues.includes(t)?{}:this.options.useStyle?{style:`vertical-align: ${t}`}:{"data-node-vertical-align":t}}}}}]},addCommands(){const e=(t,n)=>o=>({state:l,tr:s})=>{const a=Je(l.selection,this.options.types);if(a.length===0)return!1;const i=n(a,o);return Qt(s,a,t,i)};return{setNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:n),unsetNodeTextAlign:e("nodeTextAlign",()=>null),toggleNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:Jo(t,"nodeTextAlign",n)),setNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:n),unsetNodeVAlign:e("nodeVerticalAlign",()=>null),toggleNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:Jo(t,"nodeVerticalAlign",n)),setNodeAlignment:(t,n)=>({state:o,tr:l})=>{const s=Je(o.selection,this.options.types);if(s.length===0)return!1;let a=!1;for(const{node:i,pos:c}of s){const d={...i.attrs};t&&this.options.textAlignValues.includes(t)&&(d.nodeTextAlign=t,a=!0),n&&this.options.verticalAlignValues.includes(n)&&(d.nodeVerticalAlign=n,a=!0),a&&l.setNodeMarkup(c,void 0,d)}return a},unsetNodeAlignment:()=>({state:t,tr:n})=>{const o=Je(t.selection,this.options.types);if(o.length===0)return!1;let l=!1;for(const{node:s,pos:a}of o){const i=s.attrs?.nodeTextAlign??null,c=s.attrs?.nodeVerticalAlign??null;if(i||c){const d={...s.attrs,nodeTextAlign:null,nodeVerticalAlign:null};n.setNodeMarkup(a,void 0,d),l=!0}}return l}}}}),Ro=u.createContext(void 0);function Ti(e){if(e.length===0)return[];const t=e.map(i=>i.originalLevel??i.level??1),n=t.filter(i=>i>0),o=n.includes(1)?1:Math.min(...n),l=t.map(i=>Math.max(1,i-(o-1))),s=[],a=[];for(let i=0;i<l.length;i++){const c=l[i]??1;for(;a.length>0&&a[a.length-1].level>=c;)a.pop();const d=a.length===0?1:a[a.length-1].depth+1;s.push(d),a.push({level:c,depth:d})}return s}const er=e=>{let t=e.parentElement;for(;t;){const{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return window},Ii=(e,t)=>{const n=e.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight;return n.top>=t&&n.bottom>t&&n.top<o},Mi=(e,t,n="smooth")=>{if(!(!e.dom||typeof window>"u")){if(!Ii(e.dom,t)){const o=er(e.dom);if(o instanceof Window){const s=e.dom.getBoundingClientRect().top+window.scrollY-t;window.scrollTo({top:s,behavior:n})}else{const l=e.dom.getBoundingClientRect(),s=o.getBoundingClientRect(),a=l.top-s.top+o.scrollTop-t;o.scrollTo({top:a,behavior:n})}}if(e.editor&&typeof e.pos=="number"&&Rt(e.editor,e.pos),e.id){const o=new URL(window.location.href);o.hash=e.id,window.history.replaceState(null,"",o.toString())}}},ki=({children:e})=>{const[t,n]=u.useState(null),o=u.useCallback((l,s)=>{const a=s?.topOffset??0,i=s?.behavior??"smooth";Mi(l,a,i)},[]);return r.jsx(Ro.Provider,{value:{tocContent:t,setTocContent:n,navigateToHeading:o,normalizeHeadingDepths:Ti},children:e})},en=()=>{const e=u.useContext(Ro);if(!e)throw new Error("useToc must be used inside <TocProvider>");return e};function Ei(e){const{node:t,extension:n}=e,{tocContent:o,navigateToHeading:l,normalizeHeadingDepths:s}=en(),{topOffset:a=0,maxShowCount:i=20,showTitle:c=!0}=n.options,d=t.attrs??{},{backgroundColor:f}=d,h=d.topOffset??a,p=d.maxShowCount??i,C=d.showTitle??c,b=u.useMemo(()=>o??[],[o]),g=u.useMemo(()=>b.slice(0,p),[b,p]),w=u.useMemo(()=>s(g),[g,s]),v=u.useMemo(()=>g.map((T,E)=>({item:T,depth:w[E]??1})),[g,w]),m=u.useCallback((T,E)=>{T.preventDefault(),T.stopPropagation(),l(E,{topOffset:h})},[l,h]),x={...e.HTMLAttributes};delete x.style;const y={className:"tiptap-table-of-contents-node",style:{backgroundColor:f||void 0},...x};return g.length?r.jsxs(P.NodeViewWrapper,{...y,children:[C&&r.jsx("div",{className:"tiptap-table-of-contents-title",children:"Table of contents"}),r.jsx("nav",{"aria-label":"Table of contents",className:"tiptap-table-of-contents-list",children:v.map((T,E)=>r.jsx("a",{href:`#${T.item.id}`,rel:"noopener noreferrer",className:"tiptap-table-of-contents-item notranslate","data-depth":T.depth,style:{"--toc-depth":T.depth},onClick:L=>m(L,T.item),children:T.item.textContent},T.item.id??`${E}-${T.item.textContent}`))})]}):r.jsx(P.NodeViewWrapper,{...y,children:r.jsx("div",{className:"tiptap-table-of-contents-empty",children:"Add headings to create a table of contents."})})}const Li=be.Node.create({name:"tocNode",group:"block customNode",draggable:!0,selectable:!0,atom:!0,addOptions(){return{topOffset:0,maxShowCount:20,showTitle:!0,HTMLAttributes:{}}},addAttributes(){return{topOffset:{default:null,parseHTML:e=>{const t=e.getAttribute("data-top-offset"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.topOffset==null?{}:{"data-top-offset":e.topOffset}},maxShowCount:{default:null,parseHTML:e=>{const t=e.getAttribute("data-max-show-count"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.maxShowCount==null?{}:{"data-max-show-count":e.maxShowCount}},showTitle:{default:!0,parseHTML:e=>{const t=e.getAttribute("data-show-title");return t==="false"?!1:t==="true"?!0:null},renderHTML:e=>e.showTitle==null?{}:{"data-show-title":String(e.showTitle)}}}},parseHTML(){return[{tag:'div[data-type="toc-node"]'}]},renderHTML({HTMLAttributes:e}){return["div",be.mergeAttributes(this.options.HTMLAttributes,e,{"data-type":"toc-node"})]},addNodeView(){return P.ReactNodeViewRenderer(Ei,{stopEvent:({event:e})=>{if(!(e instanceof MouseEvent))return!1;const t=e.target;return t?!!t.closest(".tiptap-table-of-contents-item"):!1}})},addCommands(){return{insertTocNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),Ai=new Set(["flowchart","mermaid","mindmap"]);function Hi(e){return Ai.has(e.trim().toLowerCase())}function tr(e){const t=e.trim().toLowerCase();return t==="echarts"?"echarts":Hi(t)?"mermaid":null}function nr(e){return e.replace(/\\r\\n/g,`
1
+ (function(H,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("react"),require("@tiptap/react"),require("react-dom"),require("@tiptap/starter-kit"),require("@tiptap/extension-mention"),require("@tiptap/extension-list"),require("@tiptap/extension-text-style"),require("@tiptap/extensions"),require("@tiptap/extension-typography"),require("@tiptap/extension-highlight"),require("@tiptap/extension-superscript"),require("@tiptap/extension-subscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-mathematics"),require("@tiptap/extension-unique-id"),require("@tiptap/extension-emoji"),require("@tiptap/extension-table-of-contents"),require("@tiptap/core"),require("clsx"),require("@tiptap/pm/state"),require("@tiptap/pm/tables"),require("@tiptap/extension-horizontal-rule"),require("@tiptap/extension-image"),require("@tiptap/extension-code-block"),require("echarts"),require("mermaid"),require("@floating-ui/react"),require("@tiptap/extension-table/table"),require("@tiptap/extension-table"),require("@tiptap/pm/transform"),require("@tiptap/pm/view"),require("@ariakit/react"),require("class-variance-authority"),require("react-hotkeys-hook"),require("@radix-ui/react-popover"),require("@base-ui/react/merge-props"),require("@base-ui/react/use-render"),require("@tiptap/suggestion"),require("@tiptap/extension-drag-handle-react"),require("@tiptap/pm/model"),require("lodash.throttle"),require("@radix-ui/react-dropdown-menu")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tiptap/react","react-dom","@tiptap/starter-kit","@tiptap/extension-mention","@tiptap/extension-list","@tiptap/extension-text-style","@tiptap/extensions","@tiptap/extension-typography","@tiptap/extension-highlight","@tiptap/extension-superscript","@tiptap/extension-subscript","@tiptap/extension-text-align","@tiptap/extension-mathematics","@tiptap/extension-unique-id","@tiptap/extension-emoji","@tiptap/extension-table-of-contents","@tiptap/core","clsx","@tiptap/pm/state","@tiptap/pm/tables","@tiptap/extension-horizontal-rule","@tiptap/extension-image","@tiptap/extension-code-block","echarts","mermaid","@floating-ui/react","@tiptap/extension-table/table","@tiptap/extension-table","@tiptap/pm/transform","@tiptap/pm/view","@ariakit/react","class-variance-authority","react-hotkeys-hook","@radix-ui/react-popover","@base-ui/react/merge-props","@base-ui/react/use-render","@tiptap/suggestion","@tiptap/extension-drag-handle-react","@tiptap/pm/model","lodash.throttle","@radix-ui/react-dropdown-menu"],r):(H=typeof globalThis<"u"?globalThis:H||self,r(H.CvnertEditor={},H.jsxRuntime,H.React,H.tiptapReact,H.ReactDOM,H.tiptapStarterKit,H.tiptapExtensionMention,H.tiptapExtensionList,H.tiptapExtensionTextStyle,H.tiptapExtensions,H.tiptapExtensionTypography,H.tiptapExtensionHighlight,H.tiptapExtensionSuperscript,H.tiptapExtensionSubscript,H.tiptapExtensionTextAlign,H.tiptapExtensionMathematics,H.tiptapExtensionUniqueId,H.tiptapExtensionEmoji,H.tiptapExtensionTableOfContents,H.tiptapCore,H.clsx,H.tiptapPmState,H.tiptapPmTables,H.tiptapExtensionHorizontalRule,H.tiptapExtensionImage,H.tiptapExtensionCodeBlock,H.echarts,H.mermaid,H.floatingUiReact,H.tiptapExtensionTableTable,H.tiptapExtensionTable,H.tiptapPmTransform,H.tiptapPmView,H.ariakitReact,H.classVarianceAuthority,H.reactHotkeysHook,H.radixUiReactPopover,H.baseUiReactMergeProps,H.baseUiReactUseRender,H.tiptapSuggestion,H.tiptapExtensionDragHandleReact,H.tiptapPmModel,H.lodash.throttle,H.radixUiReactDropdownMenu))})(this,(function(H,r,u,P,Pa,Za,Fa,$o,zo,Wo,$a,za,Wa,_a,qa,Ka,Ga,_o,qo,be,Ya,M,I,Xa,ja,Qa,Ja,Ra,D,ei,Gt,Ko,We,ti,Yt,ie,ni,w4,v4,Go,oi,Yo,ri,li){"use strict";function Je(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const pt=Je(u),si=Je(Ja),se=Je(ti),Ct=Je(ni),ge=Je(li),Ae={commentInputVisible:!1,lockDragHandle:!1,isDragging:!1},ai=be.Extension.create({name:"uiState",addStorage(){return{uiState:{...Ae}}},addCommands(){const e=n=>o=>()=>(this.storage[n]=o,!0),t=(n,o)=>()=>()=>(this.storage[n]=o,!0);return{commentInputShow:t("commentInputVisible",!0),commentInputHide:t("commentInputVisible",!1),setLockDragHandle:e("lockDragHandle"),setIsDragging:e("isDragging"),resetUiState:()=>()=>(Object.assign(this.storage,{...Ae}),!0)}},onCreate(){this.storage={...Ae}}});function Xt(e){return P.useEditorState({editor:e,selector:({editor:t})=>{if(!t)return Ae;const n=t.storage.uiState;return n?{...Ae,...n}:(console.warn("Editor storage uiState is not initialized. Ensure you have the uiState extension added to your editor."),Ae)}})??Ae}function ii(e){const n=e.storage.pages;return!n||!("activeEditor"in n)?null:n.activeEditor??null}function S(e){const{editor:t}=P.useCurrentEditor(),n=e??t,[o,l]=u.useState(null);return u.useEffect(()=>{if(!n){l(null);return}const a=()=>l(ii(n));return a(),n.on("update",a),n.on("selectionUpdate",a),()=>{n.off("update",a),n.off("selectionUpdate",a)}},[n]),u.useEffect(()=>{if(!o)return;const a=()=>l(null);return o.on("destroy",a),()=>{o.off("destroy",a)}},[o]),P.useEditorState({editor:o??n,selector(a){return a.editor?{editor:a.editor,editorState:a.editor.state,canCommand:a.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})??{editor:null}}const jt=5*1024*1024,ci={mod:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",shift:"⇧",backspace:"Del",delete:"⌦",enter:"⏎",escape:"⎋",capslock:"⇪"},Qt={position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:0};function U(...e){return Ya.clsx(e)}function di(){return typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac")}const ui=(e,t,n=!0)=>{if(t){const o=e.toLowerCase();return ci[o]||(n?e.toUpperCase():e)}return n?e.charAt(0).toUpperCase()+e.slice(1):e},G=e=>{const{shortcutKeys:t,delimiter:n="+",capitalize:o=!0}=e;return t?t.split(n).map(l=>l.trim()).map(l=>ui(l,di(),o)):[]},xe=(e,t)=>t?.schema?t.schema.spec.marks.get(e)!==void 0:!1,Q=(e,t)=>t?.schema?t.schema.spec.nodes.get(e)!==void 0:!1;function fi(e){const{state:t,view:n}=e,{doc:o,selection:l}=t,s=M.Selection.findFrom(l.$to,1,!0);if(s)return n.dispatch(t.tr.setSelection(s).scrollIntoView()),!0;const a=t.schema.nodes.paragraph;if(!a)return console.warn("No paragraph node type found in schema."),!1;const i=o.content.size,c=a.create();let d=t.tr.insert(i,c);const f=d.doc.resolve(i+1);return d=d.setSelection(M.TextSelection.near(f)).scrollIntoView(),n.dispatch(d),!0}function K(e){return typeof e=="number"&&e>=0}function V(e,t){if(!e)return!1;const n=Array.isArray(t)?t:[t],o=n.some(l=>e.extensionManager.extensions.some(s=>s.name===l));return o||console.warn(`None of the extensions [${n.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`),o}function hi(e,t){try{const n=e.state.doc.nodeAt(t);return n||(console.warn(`No node found at position ${t}`),null)}catch(n){return console.error(`Error getting node at position ${t}:`,n),null}}function Ce(e){const{editor:t,node:n,nodePos:o}=e;if(!t||!t.state?.doc)return null;const l=n!=null,s=K(o);if(!l&&!s)return null;if(l){let a=-1,i=null;if(t.state.doc.descendants((c,d)=>c===n?(a=d,i=c,!1):!0),a!==-1&&i!==null)return{pos:a,node:i}}if(s){const a=hi(t,o);if(a)return{pos:o,node:a}}return null}function re(e,t=[],n=!1){if(!e||!e.state.selection)return!1;const{selection:o}=e.state;if(o.empty)return!1;if(o instanceof M.NodeSelection){const l=o.node;return l?t.includes(l.type.name):!1}if(n){const{$from:l}=o;for(let s=l.depth;s>0;s--){const a=l.node(s);if(t.includes(a.type.name))return!0}}return!1}function we(e,t=[]){if(!e||t.length===0)return!1;const{state:n}=e,{selection:o}=n,l=new Set(t);if(o instanceof M.NodeSelection){const s=o.node?.type?.name;return!!s&&l.has(s)}if(o instanceof M.TextSelection||o instanceof M.AllSelection){let s=!0;return n.doc.nodesBetween(o.from,o.to,a=>a.isTextblock&&!l.has(a.type.name)?(s=!1,!1):s),s}return!1}const pi=async(e,t,n)=>{if(!e)throw new Error("No file provided");if(e.size>jt)throw new Error(`File size exceeds maximum allowed (${jt/(1024*1024)}MB)`);for(let o=0;o<=100;o+=10){if(n?.aborted)throw new Error("Upload cancelled");await new Promise(l=>setTimeout(l,500)),t?.({progress:o})}return"/images/tiptap-ui-placeholder-image.jpg"},Ci=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function gi(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!e||e.replace(Ci,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function Jt(e,t,n){try{const o=new URL(e,t);if(gi(o.href,n))return o.href}catch{}return"#"}function Rt(e,t,n,o){if(!t.length)return!1;let l=!1;for(const{pos:s}of t){const a=e.doc.nodeAt(s);if(!a)continue;const i=a.attrs[n],c=typeof o=="function"?o(i):o;if(i===c)continue;const d={...a.attrs};c===void 0?delete d[n]:d[n]=c,e.setNodeMarkup(s,void 0,d),l=!0}return l}function bi(e){const{selection:t,doc:n}=e.state;if(!t.empty)return;const o=t.$from;let l=null,s=-1;for(let a=o.depth;a>=0;a--){const i=o.node(a),c=o.start(a);if(i.isBlock&&i.textContent.trim()){l=i,s=c;break}}if(l&&s>=0){const a=s,i=s+l.nodeSize-2;if(a<i){const c=n.resolve(a),d=n.resolve(i),f=M.TextSelection.between(c,d,1);f&&!t.eq(f)&&e.view.dispatch(e.state.tr.setSelection(f))}}}function Re(e,t){const n=[],o=new Set(t);if(e instanceof I.CellSelection)return e.forEachCell((i,c)=>{o.has(i.type.name)&&n.push({node:i,pos:c})}),n;if(e instanceof M.NodeSelection){const{node:i,from:c}=e;return i&&o.has(i.type.name)&&n.push({node:i,pos:c}),n}const{$anchor:l}=e,s=I.cellAround(l);if(s){const i=e.$anchor.doc.nodeAt(s.pos);if(i&&o.has(i.type.name))return n.push({node:i,pos:s.pos}),n}const a=P.findParentNodeClosestToPos(l,i=>o.has(i.type.name));return a&&n.push({node:a.node,pos:a.pos}),n}function en(e,t,n){return Math.max(t,Math.min(e,n))}function et(e){const{doc:t}=e.state,{from:n,to:o}=e.state.selection,l=[],s=new Set;return t.nodesBetween(n,o,(a,i)=>{if(a.isBlock)return s.has(i)||(s.add(i),l.push(a)),!1}),l}function Xo(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,o)=>e.slice(o*t,o*t+t))}function jo(e,t){if(!e)return null;const{state:n}=e,{from:o,to:l,empty:s,$from:a}=n.selection;if(s)return a.marks().find(f=>f.type.name===t)?.attrs??null;const i=new Set;let c=null;return n.doc.nodesBetween(o,l,d=>{if(d.isText)for(const f of d.marks)f.type.name===t&&!i.has(f.type.name)&&(i.add(f.type.name),c=f.attrs)}),c}function tt(e,t=!0){if(!e)return null;const{state:n}=e,{selection:o}=n;if(o instanceof M.NodeSelection){const c=o.node,d=o.from;if(c&&K(d))return{node:c,pos:d}}if(o.empty&&!t)return null;const l=o.$anchor,s=1,a=l.node(s),i=l.before(s);return{node:a,pos:i}}function Qo(e,t){if(!e)return null;const n=e.extensionManager.extensions.find(o=>o.name===t);return n||(console.warn(`Extension "${t}" not found in the editor schema. Ensure it is included in the editor configuration.`),null)}const Jo="hideFloatingToolbar";function wi(e){const{editor:t,isSelectionValid:n,extraHideWhen:o=!1}=e,[l,s]=u.useState(!1),a=u.useRef(!1);return u.useEffect(()=>{if(!t)return;const i=({transaction:c})=>{c.getMeta(Jo)?a.current=!0:c.selectionSet&&(a.current=!1)};return t.on("transaction",i),()=>{t.off("transaction",i)}},[t]),u.useEffect(()=>{if(!t)return;const i=t.view.dom,c=d=>{const f=t.state.selection;if(!(f instanceof M.NodeSelection))return;const h=t.view.nodeDOM(f.from);if(h&&h.contains(d.target)){a.current=!1;const p=n(t,f);s(p&&!o)}};return i.addEventListener("pointerdown",c,{capture:!0}),()=>i.removeEventListener("pointerdown",c,{capture:!0})},[t,o,n]),u.useEffect(()=>{if(!t)return;const i=()=>{const{selection:c}=t.state,d=n(t,c);if(o||P.isNodeSelection(c)&&a.current){s(!1);return}s(d)};return i(),t.on("selectionUpdate",i),()=>{t.off("selectionUpdate",i)}},[t,o,n]),{shouldShow:l}}const tn=(e,t)=>{if(!e)return;const{state:n,view:o}=e;o.dispatch(n.tr.setSelection(M.NodeSelection.create(n.doc,t)).setMeta(Jo,!0))};function vi(e={}){const{editor:t,onTargetFound:n=()=>{},onTargetNotFound:o=()=>{}}=e,{editor:l}=S(t),s=u.useRef(null),a=u.useRef(n),i=u.useRef(o);a.current=n,i.current=o;const c=u.useCallback(f=>{if(!l)return!1;const h=Qo(l,"uniqueID")?.options?.attributeName??"data-id";let p=null;return l.state.doc.descendants((C,b)=>C.attrs?.[h]===f?(p=b,!1):!0),p===null?!1:(tn(l,p),setTimeout(()=>{const C=l.view.nodeDOM(p);C&&C.scrollIntoView({behavior:"smooth",block:"center"})},0),!0)},[l]),d=u.useCallback((f=0)=>{const h=window.location.hash?.substring(1);h&&h!==s.current&&setTimeout(()=>{c(h)?(s.current=h,a.current(h)):i.current(h)},f)},[c]);return u.useEffect(()=>{l&&d(500)},[l,d]),u.useEffect(()=>{const f=()=>d(),h=()=>d(500);return window.addEventListener("hashchange",f),window.addEventListener("pageshow",h),window.addEventListener("popstate",f),()=>{window.removeEventListener("hashchange",f),window.removeEventListener("pageshow",h),window.removeEventListener("popstate",f)}},[d]),{scrollToHash:c}}const mi=Xa.extend({renderHTML(){return["div",P.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}});function yi(e){const{editor:t,node:n,updateAttributes:o,getPos:l}=e,s=n.content.size>0;return r.jsx(xi,{src:n.attrs.src,alt:n.attrs.alt||"",editor:t,align:n.attrs["data-align"],initialWidth:n.attrs.width,showCaption:n.attrs.showCaption,hasContent:s,nodeSize:n.nodeSize,onImageResize:a=>o({width:a}),onUpdateAttributes:o,getPos:l})}const xi=({src:e,alt:t="",editor:n,minWidth:o=96,maxWidth:l=800,align:s="left",initialWidth:a,showCaption:i=!1,hasContent:c=!1,nodeSize:d,onImageResize:f,onUpdateAttributes:h,getPos:p})=>{const[C,b]=u.useState(),[g,w]=u.useState(a),[v,m]=u.useState(!1),x=u.useRef(!1),y=u.useRef(!0),T=u.useRef(null),E=u.useRef(null),L=u.useRef(null),N=u.useRef(null);u.useEffect(()=>{if(!n||!i)return;const B=()=>{const j=p();if(!K(j)||!d)return;const{from:Ee,to:$e}=n.state.selection,ze=j,ye=j+d;($e<ze||Ee>ye)&&!c&&h&&h({showCaption:!1})};return n.on("selectionUpdate",B),()=>{n.off("selectionUpdate",B)}},[n,i,c,p,d,h]);const te=u.useCallback(B=>{if(!n||!p||C)return;B.preventDefault(),B.stopPropagation();const j=p();K(j)&&n.chain().focus().setNodeSelection(j).run()},[n,p,C]),O=u.useCallback(B=>{if(!C||!n||!y.current)return;const j="touches"in B?B.touches[0]?.clientX??0:B.clientX,Ee=C.handleUsed==="left",$e=s==="center"?2:1,ze=Ee?(C.initialClientX-j)*$e:(j-C.initialClientX)*$e,ye=C.initialWidth+ze,Le=n.view.dom?.firstElementChild?.clientWidth||l,Qe=Math.min(Math.max(ye,o),Le);w(Qe),T.current&&(T.current.style.width=`${Qe}px`)},[n,s,l,o,C]),_=u.useCallback(B=>{if(!n||!y.current)return;const j="touches"in B?document.elementFromPoint(B.changedTouches[0]?.clientX??0,B.changedTouches[0]?.clientY??0):B.target;if((!(j&&T.current?.contains(j))||!n.isEditable)&&v&&y.current&&m(!1),!C)return;const $e=n.state.selection instanceof M.NodeSelection&&n.state.selection.node.type.name==="image";y.current&&b(void 0),f?.(g);const ze=p();K(ze)&&$e&&y.current&&n.chain().focus().setNodeSelection(ze).run(),x.current=!1},[n,p,f,C,v,g]),$=u.useCallback((B,j)=>{b({handleUsed:B,initialWidth:T.current?.clientWidth??o,initialClientX:j}),x.current=!0},[o]),z=B=>{B.preventDefault(),B.stopPropagation(),$("left",B.clientX)},oe=B=>{B.preventDefault();const j=B.touches[0];j&&$("left",j.clientX)},Z=B=>{B.preventDefault(),B.stopPropagation(),$("right",B.clientX)},A=B=>{B.preventDefault();const j=B.touches[0];j&&$("right",j.clientX)},F=()=>{n?.isEditable&&y.current&&m(!0)},q=B=>{y.current&&(B.relatedTarget===E.current||B.relatedTarget===L.current||C||n?.isEditable&&m(!1))},ne=()=>{n?.isEditable&&y.current&&m(!0)};u.useEffect(()=>(window.addEventListener("mousemove",O),window.addEventListener("mouseup",_),window.addEventListener("touchmove",O,{passive:!1}),window.addEventListener("touchend",_),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",_),window.removeEventListener("touchmove",O),window.removeEventListener("touchend",_)}),[O,_]),u.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const pe=i||c;return r.jsx(P.NodeViewWrapper,{onMouseEnter:F,onMouseLeave:q,onTouchStart:ne,"data-align":s,"data-width":g,className:"tiptap-image",children:r.jsxs("div",{ref:T,className:"tiptap-image-container",style:{width:g?`${g}px`:"fit-content"},children:[r.jsxs("div",{className:"tiptap-image-content",children:[r.jsx("img",{ref:N,src:e,alt:t,className:"tiptap-image-img",contentEditable:!1,draggable:!1,onClick:te,style:{cursor:n?.isEditable?"pointer":"default"}}),v&&n?.isEditable&&r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:E,className:"tiptap-image-handle tiptap-image-handle-left",onMouseDown:z,onTouchStart:oe}),r.jsx("div",{ref:L,className:"tiptap-image-handle tiptap-image-handle-right",onMouseDown:Z,onTouchStart:A})]})]}),n?.isEditable&&pe&&r.jsx(P.NodeViewContent,{as:"div",className:"tiptap-image-caption","data-placeholder":"Add a caption..."})]})})},Ro=e=>({src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:e.getAttribute("width"),height:e.getAttribute("height")});function Si(e){const t={src:e.src||""};return e.alt&&(t.alt=e.alt),e.title&&(t.title=e.title),e.width&&(t.width=e.width),e.height&&(t.height=e.height),t}const Ti=ja.Image.extend({content:"inline*",addAttributes(){return{...this.parent?.(),"data-align":{default:null},showCaption:{default:!1,parseHTML:e=>e.tagName==="FIGURE"||e.getAttribute("data-show-caption")==="true",renderHTML:e=>e.showCaption?{"data-show-caption":"true"}:{}}}},parseHTML(){return[{tag:"figure",getAttrs:e=>{const t=e.querySelector("img");return t?{...Ro(t),"data-align":e.getAttribute("data-align"),showCaption:!0}:!1},contentElement:"figcaption"},{tag:"img[src]",getAttrs:e=>e.closest("figure")?!1:{...Ro(e),"data-align":e.getAttribute("data-align"),showCaption:!1}}]},renderHTML({node:e}){const{src:t,alt:n,title:o,width:l,height:s,showCaption:a}=e.attrs,i=e.attrs["data-align"],c=Si({src:t,alt:n,title:o,width:l,height:s}),d=e.content.size>0;if(a||d){const f={"data-url":t||""};return a&&(f["data-show-caption"]="true"),i&&(f["data-align"]=i),["figure",f,["img",c],["figcaption",{},0]]}return i&&(c["data-align"]=i),["img",c]},addKeyboardShortcuts(){const e=(t,n)=>{if(t instanceof M.NodeSelection&&t.node.type===n)return{imageNode:t.node,imagePos:t.from,atStart:!0,atEnd:!0};if(t.empty&&t.$from.parent.type===n){const{$from:o}=t;return{imageNode:o.parent,imagePos:o.before(),atStart:o.parentOffset===0,atEnd:o.parentOffset===o.parent.content.size}}return null};return{"Mod-a":({editor:t})=>{const{state:n,view:o}=t,{selection:l}=n,{$from:s}=l;let a=null,i=null;for(let p=s.depth;p>=0;p--){const C=s.node(p);if(C.type===this.type){i=C,a=p===0?0:s.before(p);break}}if(!i||a==null||i.content.size===0||i.textContent.length===0)return!1;const d=a+1,f=a+i.nodeSize-1,h=n.tr.setSelection(M.TextSelection.create(n.doc,d,f));return o.dispatch(h),!0},ArrowUp:({editor:t})=>{const{state:n}=t,o=e(n.selection,this.type);return!o||!o.atStart||o.imagePos!==0?!1:t.chain().insertContentAt(0,{type:"paragraph"}).setTextSelection(1).run()}}},addNodeView(){return P.ReactNodeViewRenderer(yi)}});function Ii(e,t){if(e.length===0)return null;for(const n of e)if((n.node.attrs?.backgroundColor??null)!==t)return t;return null}const Mi=be.Extension.create({name:"nodeBackground",addOptions(){return{types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader"],useStyle:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{const t=e.style?.backgroundColor;return t||e.getAttribute("data-background-color")||null},renderHTML:e=>{const t=e.backgroundColor;return t?this.options.useStyle?{style:`background-color: ${t}`}:{"data-background-color":t}:{}}}}}]},addCommands(){const e=t=>n=>({state:o,tr:l})=>{const s=Re(o.selection,this.options.types);if(s.length===0)return!1;const a=t(s,n);return Rt(l,s,"backgroundColor",a)};return{setNodeBackgroundColor:e((t,n)=>n||null),unsetNodeBackgroundColor:e(()=>null),toggleNodeBackgroundColor:e((t,n)=>Ii(t,n||""))}}});function er(e,t,n){if(e.length===0)return null;for(const o of e)if((o.node.attrs?.[t]??null)!==n)return n;return null}const ki=be.Extension.create({name:"nodeAlignment",addOptions(){return{types:["paragraph","heading","blockquote","tableCell","tableHeader"],useStyle:!0,textAlignValues:["left","center","right","justify"],verticalAlignValues:["top","middle","bottom"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{nodeTextAlign:{default:null,parseHTML:e=>{const t=e.style?.textAlign;if(t&&this.options.textAlignValues.includes(t))return t;const n=e.getAttribute("data-node-text-align");return n&&this.options.textAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeTextAlign;return!t||!this.options.textAlignValues.includes(t)?{}:this.options.useStyle?{style:`text-align: ${t}`}:{"data-node-text-align":t}}},nodeVerticalAlign:{default:null,parseHTML:e=>{const t=e.style?.verticalAlign;if(t&&this.options.verticalAlignValues.includes(t))return t;const n=e.getAttribute("data-node-vertical-align");return n&&this.options.verticalAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeVerticalAlign;return!t||!this.options.verticalAlignValues.includes(t)?{}:this.options.useStyle?{style:`vertical-align: ${t}`}:{"data-node-vertical-align":t}}}}}]},addCommands(){const e=(t,n)=>o=>({state:l,tr:s})=>{const a=Re(l.selection,this.options.types);if(a.length===0)return!1;const i=n(a,o);return Rt(s,a,t,i)};return{setNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:n),unsetNodeTextAlign:e("nodeTextAlign",()=>null),toggleNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:er(t,"nodeTextAlign",n)),setNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:n),unsetNodeVAlign:e("nodeVerticalAlign",()=>null),toggleNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:er(t,"nodeVerticalAlign",n)),setNodeAlignment:(t,n)=>({state:o,tr:l})=>{const s=Re(o.selection,this.options.types);if(s.length===0)return!1;let a=!1;for(const{node:i,pos:c}of s){const d={...i.attrs};t&&this.options.textAlignValues.includes(t)&&(d.nodeTextAlign=t,a=!0),n&&this.options.verticalAlignValues.includes(n)&&(d.nodeVerticalAlign=n,a=!0),a&&l.setNodeMarkup(c,void 0,d)}return a},unsetNodeAlignment:()=>({state:t,tr:n})=>{const o=Re(t.selection,this.options.types);if(o.length===0)return!1;let l=!1;for(const{node:s,pos:a}of o){const i=s.attrs?.nodeTextAlign??null,c=s.attrs?.nodeVerticalAlign??null;if(i||c){const d={...s.attrs,nodeTextAlign:null,nodeVerticalAlign:null};n.setNodeMarkup(a,void 0,d),l=!0}}return l}}}}),tr=u.createContext(void 0);function Ei(e){if(e.length===0)return[];const t=e.map(i=>i.originalLevel??i.level??1),n=t.filter(i=>i>0),o=n.includes(1)?1:Math.min(...n),l=t.map(i=>Math.max(1,i-(o-1))),s=[],a=[];for(let i=0;i<l.length;i++){const c=l[i]??1;for(;a.length>0&&a[a.length-1].level>=c;)a.pop();const d=a.length===0?1:a[a.length-1].depth+1;s.push(d),a.push({level:c,depth:d})}return s}const nr=e=>{let t=e.parentElement;for(;t;){const{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return window},Li=(e,t)=>{const n=e.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight;return n.top>=t&&n.bottom>t&&n.top<o},Ai=(e,t,n="smooth")=>{if(!(!e.dom||typeof window>"u")){if(!Li(e.dom,t)){const o=nr(e.dom);if(o instanceof Window){const s=e.dom.getBoundingClientRect().top+window.scrollY-t;window.scrollTo({top:s,behavior:n})}else{const l=e.dom.getBoundingClientRect(),s=o.getBoundingClientRect(),a=l.top-s.top+o.scrollTop-t;o.scrollTo({top:a,behavior:n})}}if(e.editor&&typeof e.pos=="number"&&tn(e.editor,e.pos),e.id){const o=new URL(window.location.href);o.hash=e.id,window.history.replaceState(null,"",o.toString())}}},Hi=({children:e})=>{const[t,n]=u.useState(null),o=u.useCallback((l,s)=>{const a=s?.topOffset??0,i=s?.behavior??"smooth";Ai(l,a,i)},[]);return r.jsx(tr.Provider,{value:{tocContent:t,setTocContent:n,navigateToHeading:o,normalizeHeadingDepths:Ei},children:e})},nn=()=>{const e=u.useContext(tr);if(!e)throw new Error("useToc must be used inside <TocProvider>");return e};function Ni(e){const{node:t,extension:n}=e,{tocContent:o,navigateToHeading:l,normalizeHeadingDepths:s}=nn(),{topOffset:a=0,maxShowCount:i=20,showTitle:c=!0}=n.options,d=t.attrs??{},{backgroundColor:f}=d,h=d.topOffset??a,p=d.maxShowCount??i,C=d.showTitle??c,b=u.useMemo(()=>o??[],[o]),g=u.useMemo(()=>b.slice(0,p),[b,p]),w=u.useMemo(()=>s(g),[g,s]),v=u.useMemo(()=>g.map((T,E)=>({item:T,depth:w[E]??1})),[g,w]),m=u.useCallback((T,E)=>{T.preventDefault(),T.stopPropagation(),l(E,{topOffset:h})},[l,h]),x={...e.HTMLAttributes};delete x.style;const y={className:"tiptap-table-of-contents-node",style:{backgroundColor:f||void 0},...x};return g.length?r.jsxs(P.NodeViewWrapper,{...y,children:[C&&r.jsx("div",{className:"tiptap-table-of-contents-title",children:"Table of contents"}),r.jsx("nav",{"aria-label":"Table of contents",className:"tiptap-table-of-contents-list",children:v.map((T,E)=>r.jsx("a",{href:`#${T.item.id}`,rel:"noopener noreferrer",className:"tiptap-table-of-contents-item notranslate","data-depth":T.depth,style:{"--toc-depth":T.depth},onClick:L=>m(L,T.item),children:T.item.textContent},T.item.id??`${E}-${T.item.textContent}`))})]}):r.jsx(P.NodeViewWrapper,{...y,children:r.jsx("div",{className:"tiptap-table-of-contents-empty",children:"Add headings to create a table of contents."})})}const Vi=be.Node.create({name:"tocNode",group:"block customNode",draggable:!0,selectable:!0,atom:!0,addOptions(){return{topOffset:0,maxShowCount:20,showTitle:!0,HTMLAttributes:{}}},addAttributes(){return{topOffset:{default:null,parseHTML:e=>{const t=e.getAttribute("data-top-offset"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.topOffset==null?{}:{"data-top-offset":e.topOffset}},maxShowCount:{default:null,parseHTML:e=>{const t=e.getAttribute("data-max-show-count"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.maxShowCount==null?{}:{"data-max-show-count":e.maxShowCount}},showTitle:{default:!0,parseHTML:e=>{const t=e.getAttribute("data-show-title");return t==="false"?!1:t==="true"?!0:null},renderHTML:e=>e.showTitle==null?{}:{"data-show-title":String(e.showTitle)}}}},parseHTML(){return[{tag:'div[data-type="toc-node"]'}]},renderHTML({HTMLAttributes:e}){return["div",be.mergeAttributes(this.options.HTMLAttributes,e,{"data-type":"toc-node"})]},addNodeView(){return P.ReactNodeViewRenderer(Ni,{stopEvent:({event:e})=>{if(!(e instanceof MouseEvent))return!1;const t=e.target;return t?!!t.closest(".tiptap-table-of-contents-item"):!1}})},addCommands(){return{insertTocNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),Bi=new Set(["flowchart","mermaid","mindmap"]);function Di(e){return Bi.has(e.trim().toLowerCase())}function or(e){const t=e.trim().toLowerCase();return t==="echarts"?"echarts":Di(t)?"mermaid":null}function rr(e){return e.replace(/\\r\\n/g,`
2
2
  `).replace(/\\n/g,`
3
3
  `).replace(/\\r/g,`
4
- `).replace(/\\t/g," ").replace(/\\(["'`{}\[\](),:])/g,"$1").trim()}function Ni(e){const t=nr(e);try{return JSON.parse(t)}catch{return Function(`"use strict";return (${t})`)()}}function Vi(e){return typeof e!="string"||!e.trim()?"Code":e.trim()}function Bi({code:e}){const t=u.useRef(null),[n,o]=u.useState(null);return u.useEffect(()=>{const l=t.current;if(!l)return;let s=null,a=null;try{const i=Ni(e);s=ni.init(l),s.setOption(i),o(null),a=new ResizeObserver(()=>s?.resize()),a.observe(l)}catch(i){o(i instanceof Error?i.message:"Failed to render chart")}return()=>{a?.disconnect(),s?.dispose()}},[e]),r.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[r.jsx("div",{className:"code-block-node__echarts",ref:t}),n?r.jsx("div",{className:"code-block-node__diagram-error",children:n}):null]})}function Di({code:e,language:t}){const n=tr(t);return n==="echarts"?r.jsx(Bi,{code:e}):n==="mermaid"?r.jsx(Ui,{code:e}):null}function Ui({code:e}){const t=u.useId(),[n,o]=u.useState(""),[l,s]=u.useState(null);return u.useEffect(()=>{let a=!1;async function i(){try{const c=await Xa.render(`code-block-diagram-${t.replace(/:/g,"")}`,nr(e));a||(o(c.svg),s(null))}catch(c){a||(o(""),s(c instanceof Error?c.message:"Failed to render diagram"))}}return i(),()=>{a=!0}},[e,t]),r.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[n?r.jsx("div",{className:"code-block-node__mermaid",dangerouslySetInnerHTML:{__html:n}}):null,l?r.jsx("div",{className:"code-block-node__diagram-error",children:l}):null]})}function Oi(e){const t=Vi(e.node.attrs.language),o=!!tr(t),[l,s]=u.useState(o),a=e.node.textContent,i=o&&e.editor.isEditable;return u.useEffect(()=>{s(o)},[o,t]),r.jsxs(P.NodeViewWrapper,{className:"code-block-node","data-collapsed":l?"true":"false","data-diagram":o?"true":"false","data-language":t,children:[r.jsxs("div",{className:"code-block-node__header",contentEditable:!1,children:[r.jsx("span",{className:"code-block-node__language",children:t}),i?r.jsx("button",{type:"button",className:"code-block-node__toggle","aria-expanded":!l,onClick:()=>s(c=>!c),children:l?"Show source":"Hide source"}):null]}),o?r.jsx(Di,{code:a,language:t}):null,r.jsx("pre",{className:"code-block-node__pre",children:r.jsx(P.NodeViewContent,{className:"code-block-node__content"})})]})}const Pi=Ga.CodeBlock.extend({addNodeView(){return P.ReactNodeViewRenderer(Oi)}});function Zi({initialOpen:e=!1,placement:t="top",open:n,onOpenChange:o,delay:l=600,closeDelay:s=0}={}){const[a,i]=u.useState(e),c=n??a,d=o??i,f=D.useFloating({placement:t,open:c,onOpenChange:d,whileElementsMounted:D.autoUpdate,middleware:[D.offset(4),D.flip({crossAxis:t.includes("-"),fallbackAxisSideDirection:"start",padding:4}),D.shift({padding:4})]}),h=f.context,p=D.useHover(h,{mouseOnly:!0,move:!1,restMs:l,enabled:n==null,delay:{close:s}}),C=D.useFocus(h,{enabled:n==null}),b=D.useDismiss(h),g=D.useRole(h,{role:"tooltip"}),w=D.useInteractions([p,C,b,g]);return u.useMemo(()=>({open:c,setOpen:d,...w,...f}),[c,d,w,f])}const tn=u.createContext(null);function or(){const e=u.useContext(tn);if(e==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return e}function rr({children:e,...t}){const n=Zi(t);return t.useDelayGroup?r.jsx(D.FloatingDelayGroup,{delay:{open:t.delay??0,close:t.closeDelay??0},timeoutMs:t.timeout,children:r.jsx(tn.Provider,{value:n,children:e})}):r.jsx(tn.Provider,{value:n,children:e})}const lr=u.forwardRef(function({children:t,asChild:n=!1,...o},l){const s=or(),a=u.isValidElement(t)?parseInt(u.version,10)>=19?t.props.ref:t.ref:void 0,i=D.useMergeRefs([s.refs.setReference,l,a]);if(n&&u.isValidElement(t)){const c={"data-tooltip-state":s.open?"open":"closed"};return u.cloneElement(t,s.getReferenceProps({ref:i,...o,...typeof t.props=="object"?t.props:{},...c}))}return r.jsx("button",{ref:i,"data-tooltip-state":s.open?"open":"closed",...s.getReferenceProps(o),children:t})}),sr=u.forwardRef(function({style:t,children:n,portal:o=!0,portalProps:l={},...s},a){const i=or(),c=D.useMergeRefs([i.refs.setFloating,a]);if(!i.open)return null;const d=r.jsx("div",{ref:c,style:{...i.floatingStyles,...t},...i.getFloatingProps(s),className:"tiptap-tooltip",children:n});return o?r.jsx(D.FloatingPortal,{...l,children:d}):d});rr.displayName="Tooltip",lr.displayName="TooltipTrigger",sr.displayName="TooltipContent";const Fi=({shortcuts:e})=>e.length===0?null:r.jsx("div",{children:e.map((t,n)=>r.jsxs(u.Fragment,{children:[n>0&&r.jsx("kbd",{children:"+"}),r.jsx("kbd",{children:t})]},n))}),k=u.forwardRef(({className:e,children:t,tooltip:n,showTooltip:o=!0,shortcutKeys:l,variant:s,size:a,...i},c)=>{const d=u.useMemo(()=>G({shortcutKeys:l}),[l]);return!n||!o?r.jsx("button",{"data-slot":"tiptap-button",className:U("tiptap-button",e),ref:c,"data-style":s,"data-size":a,...i,children:t}):r.jsxs(rr,{delay:200,children:[r.jsx(lr,{"data-slot":"tiptap-button",className:U("tiptap-button",e),ref:c,"data-style":s,"data-size":a,...i,children:t}),r.jsxs(sr,{children:[n,r.jsx(Fi,{shortcuts:d})]})]})});k.displayName="Button";const ar=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));ar.displayName="CloseIcon";function $i(e){const[t,n]=u.useState([]),o=async i=>{if(i.size>e.maxSize){const h=new Error(`File size exceeds maximum allowed (${e.maxSize/1024/1024}MB)`);return e.onError?.(h),null}const c=new AbortController,d=crypto.randomUUID(),f={id:d,file:i,progress:0,status:"uploading",abortController:c};n(h=>[...h,f]);try{if(!e.upload)throw new Error("Upload function is not defined");const h=await e.upload(i,p=>{n(C=>C.map(b=>b.id===d?{...b,progress:p.progress}:b))},c.signal);if(!h)throw new Error("Upload failed: No URL returned");return c.signal.aborted?null:(n(p=>p.map(C=>C.id===d?{...C,status:"success",url:h,progress:100}:C)),e.onSuccess?.(h),h)}catch(h){return c.signal.aborted||(n(p=>p.map(C=>C.id===d?{...C,status:"error",progress:0}:C)),e.onError?.(h instanceof Error?h:new Error("Upload failed"))),null}};return{fileItems:t,uploadFiles:async i=>{if(!i||i.length===0)return e.onError?.(new Error("No files to upload")),[];if(e.limit&&i.length>e.limit)return e.onError?.(new Error(`Maximum ${e.limit} file${e.limit===1?"":"s"} allowed`)),[];const c=i.map(f=>o(f));return(await Promise.all(c)).filter(f=>f!==null)},removeFileItem:i=>{n(c=>{const d=c.find(f=>f.id===i);return d?.abortController&&d.abortController.abort(),d?.url&&URL.revokeObjectURL(d.url),c.filter(f=>f.id!==i)})},clearAllFiles:()=>{t.forEach(i=>{i.abortController&&i.abortController.abort(),i.url&&URL.revokeObjectURL(i.url)}),n([])}}}const ir=()=>r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"tiptap-image-upload-icon",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M11.1953 4.41771C10.3478 4.08499 9.43578 3.94949 8.5282 4.02147C7.62062 4.09345 6.74133 4.37102 5.95691 4.83316C5.1725 5.2953 4.50354 5.92989 4.00071 6.68886C3.49788 7.44783 3.17436 8.31128 3.05465 9.2138C2.93495 10.1163 3.0222 11.0343 3.3098 11.8981C3.5974 12.7619 4.07781 13.5489 4.71463 14.1995C5.10094 14.5942 5.09414 15.2274 4.69945 15.6137C4.30476 16 3.67163 15.9932 3.28532 15.5985C2.43622 14.731 1.79568 13.6816 1.41221 12.5299C1.02875 11.3781 0.91241 10.1542 1.07201 8.95084C1.23162 7.74748 1.66298 6.59621 2.33343 5.58425C3.00387 4.57229 3.89581 3.72617 4.9417 3.10998C5.98758 2.4938 7.15998 2.1237 8.37008 2.02773C9.58018 1.93176 10.7963 2.11243 11.9262 2.55605C13.0561 2.99968 14.0703 3.69462 14.8919 4.58825C15.5423 5.29573 16.0585 6.11304 16.4177 7.00002H17.4999C18.6799 6.99991 19.8288 7.37933 20.7766 8.08222C21.7245 8.78515 22.4212 9.7743 22.7637 10.9036C23.1062 12.0328 23.0765 13.2423 22.6788 14.3534C22.2812 15.4644 21.5367 16.4181 20.5554 17.0736C20.0962 17.3803 19.4752 17.2567 19.1684 16.7975C18.8617 16.3382 18.9853 15.7172 19.4445 15.4105C20.069 14.9934 20.5427 14.3865 20.7958 13.6794C21.0488 12.9724 21.0678 12.2027 20.8498 11.4841C20.6318 10.7655 20.1885 10.136 19.5853 9.6887C18.9821 9.24138 18.251 8.99993 17.5001 9.00002H15.71C15.2679 9.00002 14.8783 8.70973 14.7518 8.28611C14.4913 7.41374 14.0357 6.61208 13.4195 5.94186C12.8034 5.27164 12.0427 4.75043 11.1953 4.41771Z",fill:"currentColor"}),r.jsx("path",{d:"M11 14.4142V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V14.4142L15.2929 16.7071C15.6834 17.0976 16.3166 17.0976 16.7071 16.7071C17.0976 16.3166 17.0976 15.6834 16.7071 15.2929L12.7078 11.2936C12.7054 11.2912 12.703 11.2888 12.7005 11.2864C12.5208 11.1099 12.2746 11.0008 12.003 11L12 11L11.997 11C11.8625 11.0004 11.7343 11.0273 11.6172 11.0759C11.502 11.1236 11.3938 11.1937 11.2995 11.2864C11.297 11.2888 11.2946 11.2912 11.2922 11.2936L7.29289 15.2929C6.90237 15.6834 6.90237 16.3166 7.29289 16.7071C7.68342 17.0976 8.31658 17.0976 8.70711 16.7071L11 14.4142Z",fill:"currentColor"})]}),zi=()=>r.jsx("svg",{width:"43",height:"57",viewBox:"0 0 43 57",fill:"currentColor",className:"tiptap-image-upload-dropzone-rect-primary",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M0.75 10.75C0.75 5.64137 4.89137 1.5 10 1.5H32.3431C33.2051 1.5 34.0317 1.84241 34.6412 2.4519L40.2981 8.10876C40.9076 8.71825 41.25 9.5449 41.25 10.4069V46.75C41.25 51.8586 37.1086 56 32 56H10C4.89137 56 0.75 51.8586 0.75 46.75V10.75Z",fill:"currentColor",fillOpacity:"0.11",stroke:"currentColor",strokeWidth:"1.5"})}),Wi=()=>r.jsx("svg",{width:"10",height:"10",className:"tiptap-image-upload-dropzone-rect-secondary",viewBox:"0 0 10 10",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M0 0.75H0.343146C1.40401 0.75 2.42143 1.17143 3.17157 1.92157L8.82843 7.57843C9.57857 8.32857 10 9.34599 10 10.4069V10.75H4C1.79086 10.75 0 8.95914 0 6.75V0.75Z",fill:"currentColor"})}),_i=({onFile:e,children:t})=>{const[n,o]=u.useState(!1),[l,s]=u.useState(!1),a=f=>{f.preventDefault(),f.stopPropagation(),s(!0)},i=f=>{f.preventDefault(),f.stopPropagation(),f.currentTarget.contains(f.relatedTarget)||(s(!1),o(!1))},c=f=>{f.preventDefault(),f.stopPropagation(),o(!0)},d=f=>{f.preventDefault(),f.stopPropagation(),s(!1),o(!1);const h=Array.from(f.dataTransfer.files);h.length>0&&e(h)};return r.jsx("div",{className:`tiptap-image-upload-drag-area ${l?"drag-active":""} ${n?"drag-over":""}`,onDragEnter:a,onDragLeave:i,onDragOver:c,onDrop:d,children:t})},qi=({fileItem:e,onRemove:t})=>{const n=o=>{if(o===0)return"0 Bytes";const l=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(o)/Math.log(l));return`${parseFloat((o/Math.pow(l,a)).toFixed(2))} ${s[a]}`};return r.jsxs("div",{className:"tiptap-image-upload-preview",children:[e.status==="uploading"&&r.jsx("div",{className:"tiptap-image-upload-progress",style:{width:`${e.progress}%`}}),r.jsxs("div",{className:"tiptap-image-upload-preview-content",children:[r.jsxs("div",{className:"tiptap-image-upload-file-info",children:[r.jsx("div",{className:"tiptap-image-upload-file-icon",children:r.jsx(ir,{})}),r.jsxs("div",{className:"tiptap-image-upload-details",children:[r.jsx("span",{className:"tiptap-image-upload-text",children:e.file.name}),r.jsx("span",{className:"tiptap-image-upload-subtext",children:n(e.file.size)})]})]}),r.jsxs("div",{className:"tiptap-image-upload-actions",children:[e.status==="uploading"&&r.jsxs("span",{className:"tiptap-image-upload-progress-text",children:[e.progress,"%"]}),r.jsx(k,{type:"button",variant:"ghost",onClick:o=>{o.stopPropagation(),t()},children:r.jsx(ar,{className:"tiptap-button-icon"})})]})]})]})},Ki=({maxSize:e,limit:t})=>r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"tiptap-image-upload-dropzone",children:[r.jsx(zi,{}),r.jsx(Wi,{}),r.jsx("div",{className:"tiptap-image-upload-icon-container",children:r.jsx(ir,{})})]}),r.jsxs("div",{className:"tiptap-image-upload-content",children:[r.jsxs("span",{className:"tiptap-image-upload-text",children:[r.jsx("em",{children:"Click to upload"})," or drag and drop"]}),r.jsxs("span",{className:"tiptap-image-upload-subtext",children:["Maximum ",t," file",t===1?"":"s",", ",e/1024/1024,"MB each."]})]})]}),Gi=e=>{const{accept:t,limit:n,maxSize:o}=e.node.attrs,l=u.useRef(null),s=e.extension,a={maxSize:o,limit:n,accept:t,upload:s.options.upload,onSuccess:s.options.onSuccess,onError:s.options.onError},{fileItems:i,uploadFiles:c,removeFileItem:d,clearAllFiles:f}=$i(a),h=async g=>{const w=await c(g);if(w.length>0){const v=e.getPos();if(K(v)){const m=w.map((x,y)=>{const T=g[y]?.name.replace(/\.[^/.]+$/,"")||"unknown";return{type:s.options.type,attrs:{...s.options,src:x,alt:T,title:T}}});e.editor.chain().focus().deleteRange({from:v,to:v+e.node.nodeSize}).insertContentAt(v,m).run(),ii(e.editor)}}},p=g=>{const w=g.target.files;if(!w||w.length===0){s.options.onError?.(new Error("No file selected"));return}h(Array.from(w))},C=()=>{l.current&&i.length===0&&(l.current.value="",l.current.click())},b=i.length>0;return r.jsxs(P.NodeViewWrapper,{className:"tiptap-image-upload",tabIndex:0,onClick:C,children:[!b&&r.jsx(_i,{onFile:h,children:r.jsx(Ki,{maxSize:o,limit:n})}),b&&r.jsxs("div",{className:"tiptap-image-upload-previews",children:[i.length>1&&r.jsxs("div",{className:"tiptap-image-upload-header",children:[r.jsxs("span",{children:["Uploading ",i.length," files"]}),r.jsx(k,{type:"button",variant:"ghost",onClick:g=>{g.stopPropagation(),f()},children:"Clear All"})]}),i.map(g=>r.jsx(qi,{fileItem:g,onRemove:()=>d(g.id)},g.id))]}),r.jsx("input",{ref:l,name:"file",accept:t,type:"file",multiple:n>1,onChange:p,onClick:g=>g.stopPropagation()})]})},Yi=P.Node.create({name:"imageUpload",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:void 0,onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:e}){return["div",P.mergeAttributes({"data-type":"image-upload"},e)]},addNodeView(){return P.ReactNodeViewRenderer(Gi)},addCommands(){return{setImageUploadNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{const{selection:t}=e.state,{nodeAfter:n}=t.$from;if(n&&n.type.name==="imageUpload"&&e.isActive("imageUpload")){const o=e.view.nodeDOM(t.$from.pos);if(o&&o instanceof HTMLElement){const l=o.firstChild;if(l&&l instanceof HTMLElement)return l.click(),!0}}return!1}}}}),cr=35,tt=120,Xi=40,Ct={cells:[],mergedCells:[]};function nn(e){return e instanceof HTMLElement}function dr(e,t){return e?.closest?.(t)??null}function ur(e){let t=e;for(;t&&t.tagName!=="TD"&&t.tagName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;t=nn(t.parentNode)?t.parentNode:null}if(t)return t.tagName==="TD"||t.tagName==="TH"?{type:"cell",domNode:t,tbodyNode:dr(t,"tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function He(e,t,n){return Math.max(t,Math.min(e,n))}function fr(e,t,n){return e>=0&&e<n.height&&t>=0&&t<n.width}function ji(e,t,n,o){if(typeof o=="number")return o;if(e.selection instanceof I.CellSelection){const i=I.selectedRect(e);return n==="row"?i.top:i.left}const l=I.cellAround(e.selection.$anchor)??I.selectionCell(e);if(!l)return null;const s=l.pos-t.start,a=t.map.findCell(s);return n==="row"?a.top:a.left}function Qi(e,t,n,o){return{row:e,column:t,pos:n,node:o,start:n+1,depth:o?o.content.size:0}}function Ji(e){if(!e)return!1;const t=e.attrs.colspan??1,n=e.attrs.rowspan??1;return t>1||n>1}function on(e,t,n,o){if(!e)return Ct;const{state:l}=e,s=J(e,o);if(!s)return Ct;const a=s.start,i=s.node,c=s.map,d=ji(l,s,t,n);if(d===null)return Ct;const f=t==="row"?c.height:c.width;if(d<0||d>=f)return Ct;const h=[],p=[],C=new Set,b=t==="row"?c.width:c.height;for(let g=0;g<b;g++){const w=t==="row"?d:g,v=t==="row"?g:d,m=w*c.width+v,x=c.map[m];if(x===void 0)continue;const y=a+x,T=i.nodeAt(x);if(!T)continue;const E=Qi(w,v,y,T);Ji(T)&&(C.has(y)||(p.push(E),C.add(y))),h.push(E)}return{cells:h,mergedCells:p}}function hr(e,t,n){const o=J(e,t);if(!o)return 0;const{doc:l}=e.state,s=n==="row"?o.map.height:o.map.width;let a=0;for(let i=s-1;i>=0;i--){const c=new Set;let d=!0;const f=n==="row"?o.map.width:o.map.height;for(let h=0;h<f;h++){const p=n==="row"?i:h,C=n==="row"?h:i,b=o.map.positionAt(p,C,o.node);if(c.has(b))continue;c.add(b);const g=t+1+b,w=l.nodeAt(g);if(w&&!Ne(w)){d=!1;break}}if(d)a++;else break}return a}function J(e,t){if(!e)return null;let n=null;if(typeof t=="number"){const l=e.state.doc.nodeAt(t);l?.type.name==="table"&&(n={node:l,pos:t,start:t+1,depth:e.state.doc.resolve(t).depth})}if(!n){const{state:l}=e,s=l.doc.resolve(l.selection.from);n=I.findTable(s)}if(!n)return null;const o=I.TableMap.get(n.node);return o?{...n,map:o}:null}function pr({width:e,height:t,map:n},o){let l=o.top*e+o.left,s=l,a=(o.bottom-1)*e+o.left,i=l+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[s]==n[s-1]||o.right<e&&n[i]==n[i+1])return!0;s+=e,i+=e}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[l]==n[l-e]||o.bottom<t&&n[a]==n[a+e])return!0;l++,a++}return!1}function rn(e,t){const n=e.view,o=n.state.selection,l=o.getBookmark(),s=new _o.Mapping,a=n.dispatch;n.dispatch=i=>{s.appendMapping(i.mapping),a(i)};try{t()}finally{n.dispatch=a}try{const i=l.map(s).resolve(n.state.doc);return n.dispatch(n.state.tr.setSelection(i)),!0}catch{const i=s.map(o.from,-1),c=He(i,0,n.state.doc.content.size),d=M.Selection.near(n.state.doc.resolve(c),-1);return n.dispatch(n.state.tr.setSelection(d)),!1}}function Ne(e){if(e.childCount===0)return!0;let t=!0;return e.descendants(n=>n.isText&&n.text?.trim()||n.isLeaf&&!n.isText?(t=!1,!1):!0),t}function Y(e,t,n,o){if(typeof t=="number"&&n)return{orientation:n,index:t};if(!e)return null;const{state:l}=e;if(!J(e,o))return null;if(l.selection instanceof I.CellSelection){const a=I.selectedRect(l),i=a.right-a.left,c=a.bottom-a.top;return c===1&&i>=1?{orientation:"row",index:a.top}:i===1&&c>=1?{orientation:"column",index:a.left}:null}return null}function he(e,t,n,o){const l={cells:[],mergedCells:[],index:void 0,orientation:void 0,tablePos:void 0};if(!e||typeof t!="number"&&!(e.state.selection instanceof I.CellSelection))return l;let s=t,a=n;if(typeof s!="number"||!a||!["row","column"].includes(a)){const c=Y(e);if(!c)return l;s=c.index,a=c.orientation}return{...on(e,a,s,o),index:s,orientation:a}}function Cr(e,t,n){return on(e,"row",t,n)}function gr(e,t,n){return on(e,"column",t,n)}function ln(e,t,n,o){try{const l=J(e,o);if(!l)return;const{state:s}=e,{map:a}=l;if(t==="row"){if(n>=0&&n<a.height){const c=a.width-1,d=l.start+a.positionAt(n,0,l.node),f=l.start+a.positionAt(n,c,l.node),h=s.doc.resolve(d),p=s.doc.resolve(f),C=I.CellSelection.create(s.doc,h.pos,p.pos),b=s.tr.setSelection(C);e.view.dispatch(b)}}else if(t==="column"&&n>=0&&n<a.width){const c=a.height-1,d=l.start+a.positionAt(0,n,l.node),f=l.start+a.positionAt(c,n,l.node),h=s.doc.resolve(d),p=s.doc.resolve(f),C=I.CellSelection.create(s.doc,h.pos,p.pos),b=s.tr.setSelection(C);e.view.dispatch(b)}}catch(l){console.warn("Failed to update selection after move:",l)}}function Ri(e,t){return function(n,o){if(!I.isInTable(n))return!1;const l=I.selectionCell(n),s=typeof e=="string"?{[e]:t}:e;if(o){const a=n.tr;n.selection instanceof I.CellSelection?n.selection.forEachCell((i,c)=>{Object.entries(s).some(([f,h])=>i.attrs[f]!==h)&&a.setNodeMarkup(c,null,{...i.attrs,...s})}):Object.entries(s).some(([c,d])=>l.nodeAfter.attrs[c]!==d)&&a.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,...s}),o(a)}return!0}}function e1(e,t){return hr(e,t,"row")}function t1(e,t){return hr(e,t,"column")}function n1(e,t=.3){const n=Math.floor(e),o=Math.ceil(e),l=n+t,s=o-t;return e<l?n:e>s?o:Math.round(e)}function br(e,t){return!e&&!t?!0:!e||!t?!1:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function o1(e,t,n){switch(n.mode??"state"){case"dispatch":{const l=n;typeof l.dispatch=="function"&&l.dispatch(t);return}case"transaction":return t;default:return e.apply(t)}}function ve(e,t,n,o={mode:"state"}){if(!e)return;const l=J(e,t);if(!l)return;const{state:s}=e,a=l.map,i=n.map(v=>({row:He(v.row,0,a.height-1),col:He(v.col,0,a.width-1)})).filter(v=>fr(v.row,v.col,a));if(i.length===0)return;const c=i.map(v=>v.row),d=Math.min(...c),f=Math.max(...c),h=i.map(v=>v.col),p=Math.min(...h),C=Math.max(...h),b=(v,m)=>{const x=a.map[v*a.width+m];return x===void 0?null:t+1+x},g=b(d,p);if(g===null)return;let w=b(f,C);if(w!==null){if(w===g){let v=!1;for(let m=f;m>=d&&!v;m--)for(let x=C;x>=p&&!v;x--){const y=b(m,x);y!==null&&y!==g&&(w=y,v=!0)}}try{const v=s.doc.resolve(g),m=s.doc.resolve(w),x=new I.CellSelection(v,m),y=s.tr.setSelection(x);return o1(s,y,o)}catch(v){console.error("Failed to create cell selection:",v);return}}}function r1({editor:e,row:t,col:n,tablePos:o,dispatch:l}){if(!e)return!1;const{state:s,view:a}=e,i=J(e,o);if(!i||!fr(t,n,i.map))return!1;const c=i.map.positionAt(t,n,i.node),d=i.start+c,f=s.doc.resolve(d),h=I.cellAround(f),p=h?h.pos:d,C=I.CellSelection.create(s.doc,p),b=l??a?.dispatch;return b?(b(s.tr.setSelection(C)),!0):!1}function sn(e,t,n,o){const l=I.TableMap.get(t),s=o==="row",a=s?l.height-1:0,i=s?0:l.width-1,c=a*l.width+i,d=l.map[c];if(!d&&d!==0)return console.warn("selectLastCell: cell position not found in map",{index:c,row:a,col:i,map:l}),!1;const f=l.map.indexOf(d),h=f>=0?Math.floor(f/l.width):0,p=f>=0?f%l.width:0;return r1({editor:e,row:h,col:p,tablePos:n,dispatch:e.view.dispatch.bind(e.view)})}function Ve({editor:e,index:t,orientation:n,tablePos:o}){if(!e)return null;const l=J(e,o);if(!l)return null;const{map:s}=l,{width:a,height:i}=s;return t<0||n==="row"&&t>=i||n==="column"&&t>=a?null:n==="row"?Array.from({length:s.width},(c,d)=>({row:t,col:d})):Array.from({length:s.height},(c,d)=>({row:d,col:t}))}function wr(e,t,n){if(!t)return null;try{const o=n.view.posAtDOM(e,0),l=n.view.state.doc.resolve(o);for(let s=l.depth;s>0;s--){const a=l.node(s);if(a.type.name==="tableCell"||a.type.name==="tableHeader"){const i=I.TableMap.get(t),c=l.before(s),d=l.start(s-2),f=c-d,h=i.map.indexOf(f);return{rowIndex:Math.floor(h/i.width),colIndex:h%i.width}}}}catch(o){console.warn("Could not get cell position:",o)}return null}function l1(e,t){try{const n=t.view.posAtDOM(e,0),o=t.view.state.doc.resolve(n);for(let l=o.depth;l>=0;l--){const s=o.node(l);if(vr(s))return{node:s,pos:l===0?0:o.before(l)}}}catch(n){console.warn("Could not get table from DOM:",n)}return null}function vr(e){return!!e&&(e.type.name==="table"||e.type.spec.tableRole==="table")}const s1=ja.Table.extend({addProseMirrorPlugins(){const e=this.options.resizable&&this.editor.isEditable,t=this.options.cellMinWidth<tt?tt:this.options.cellMinWidth;return[...e?[I.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:cr,defaultCellMinWidth:t,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],I.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){return({node:e,HTMLAttributes:t})=>{class n extends I.TableView{blockContainer;innerTableContainer;widgetsContainer;overlayContainer;containerAttributes;constructor(s,a,i){super(s,a),this.containerAttributes=i??{},this.blockContainer=this.createBlockContainer(),this.innerTableContainer=this.createInnerTableContainer(),this.widgetsContainer=this.createWidgetsContainer(),this.overlayContainer=this.createOverlayContainer(),this.setupDOMStructure()}createBlockContainer(){const s=document.createElement("div");return s.setAttribute("data-content-type","table"),this.applyContainerAttributes(s),s}createInnerTableContainer(){const s=document.createElement("div");return s.className="table-container",s}createWidgetsContainer(){const s=document.createElement("div");return s.className="table-controls",s.style.position="relative",s}createOverlayContainer(){const s=document.createElement("div");return s.className="table-selection-overlay-container",s}applyContainerAttributes(s){Object.entries(this.containerAttributes).forEach(([a,i])=>{a!=="class"&&s.setAttribute(a,i)})}setupDOMStructure(){const s=this.dom,a=s.firstChild;this.innerTableContainer.appendChild(a),s.appendChild(this.innerTableContainer),s.appendChild(this.widgetsContainer),s.appendChild(this.overlayContainer),this.blockContainer.appendChild(s),this.dom=this.blockContainer}ignoreMutation(s){return!s.target.closest(".table-container")||super.ignoreMutation(s)}}const o=this.options.cellMinWidth<tt?tt:this.options.cellMinWidth;return new n(e,o,t)}}}),a1=qt.TableCell.extend({addKeyboardShortcuts(){return{...this.parent?.(),"Mod-a":()=>{const{state:e,view:t}=this.editor,{selection:n,doc:o}=e,l=n.$anchor,s=I.cellAround(l);if(!s)return!1;const a=o.nodeAt(s.pos);if(!a||!a.textContent)return!1;const i=s.pos+1,c=s.pos+a.nodeSize-1;if(i>=c)return!0;const d=o.resolve(i),f=o.resolve(c),h=M.TextSelection.between(d,f,1);return!h||e.selection.eq(h)||t.dispatch(e.tr.setSelection(h)),!0}}}}),i1=be.Extension.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(s1.configure(this.options.table)),this.options.tableCell!==!1&&e.push(a1.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(qt.TableHeader.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(qt.TableRow.configure(this.options.tableRow)),e}}),c1=["boxSizing","backgroundColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","color","font","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textTransform","textDecoration","textAlign","verticalAlign","whiteSpace","width","minWidth","maxWidth","height","minHeight","maxHeight","backgroundClip"],mr=e=>e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase());function d1(e,t){const n=getComputedStyle(e);for(const o of c1){const l=String(o),s=n.getPropertyValue(mr(l));s&&t.style.setProperty(mr(l),s)}t.style.overflow="hidden",t.style.textOverflow="ellipsis",(n.whiteSpace===""||n.whiteSpace==="normal")&&(t.style.whiteSpace="nowrap")}function yr(e){const t=e.cloneNode(!0),n=[{src:e,dst:t}];for(;n.length;){const{src:o,dst:l}=n.shift();o instanceof HTMLElement&&l instanceof HTMLElement&&d1(o,l);const s=Array.from(o.children),a=Array.from(l.children),i=Math.min(s.length,a.length);for(let c=0;c<i;c++){const d=s[c],f=a[c];d&&f&&n.push({src:d,dst:f})}}return t}function u1(e,t){Object.assign(e.style,{position:"fixed",top:"-10000px",left:"-10000px",pointerEvents:"none",zIndex:"2147483647",maxWidth:`${t}px`,borderRadius:"12px",background:"transparent",filter:"drop-shadow(0 8px 24px rgba(0,0,0,0.18)) drop-shadow(0 2px 8px rgba(0,0,0,0.10))",overflow:"hidden"})}function f1(e,t){e.isConnected||document.body.appendChild(e);const n=e.getBoundingClientRect();if(n.width>t&&n.width>0){const o=t/n.width;e.style.transformOrigin="top left",e.style.transform=`scale(${o})`}}function xr(e,t){const n=getComputedStyle(e);t.style.borderCollapse=n.borderCollapse,t.style.borderSpacing=n.borderSpacing,t.style.tableLayout="fixed",t.className=e.className}function Sr(e,t){const n=e.getBoundingClientRect();n.width>0&&(t.style.width=`${n.width}px`,t.style.maxWidth=`${n.width}px`)}function h1(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=n.rows?.[t];if(!o)return null;const l=document.createElement("table"),s=document.createElement("tbody"),a=yr(o);xr(e,l);for(let i=0;i<o.cells.length;i++){const c=o.cells[i],d=a.cells[i];d&&Sr(c,d)}return s.appendChild(a),l.appendChild(s),l}function p1(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=document.createElement("table"),l=document.createElement("tbody");xr(e,o);let s=0;for(let a=0;a<n.rows.length;a++){const i=n.rows[a];if(!i)continue;const c=i.cells?.[t];if(!c)continue;const d=document.createElement("tr"),f=yr(c),h=c.getBoundingClientRect();!s&&h.width>0&&(s=h.width),Sr(c,f),d.appendChild(f),l.appendChild(d)}return s>0&&(o.style.width=`${s}px`,o.style.maxWidth=`${s}px`),o.appendChild(l),o}function C1(e,t,n,o){const l=e.view.dom.getBoundingClientRect(),s=Math.max(0,l.width),a=document.createElement("div");u1(a,s);const i=e.view.nodeDOM(o);if(!i)return document.body.appendChild(a),a;const c=i.getBoundingClientRect(),d=Math.min(c.width,l.width);a.style.width=`${d}px`;const f=t==="row"?h1(i,n):p1(i,n);if(f){const h=document.createElement("div");Object.assign(h.style,{background:"var(--drag-image-bg, transparent)",overflow:"hidden"}),h.appendChild(f),a.appendChild(h)}return f1(a,s),a}function g1(e,t){t.querySelectorAll(e).forEach(n=>{n.style.visibility="hidden"})}const Se=new M.PluginKey("tableHandlePlugin");class b1{editor;editorView;state=void 0;menuFrozen=!1;mouseState="up";tableId;tablePos;tableElement;emitUpdate;constructor(t,n,o){this.editor=t,this.editorView=n,this.emitUpdate=()=>this.state&&o(this.state),this.editorView.dom.addEventListener("mousemove",this.mouseMoveHandler),this.editorView.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),this.editorView.root.addEventListener("dragover",this.dragOverHandler),this.editorView.root.addEventListener("drop",this.dropHandler)}viewMousedownHandler=t=>{this.mouseState="down";const{state:n,view:o}=this.editor;if(!(n.selection instanceof I.CellSelection)||this.editor.isFocused)return;const l=o.posAtCoords({left:t.clientX,top:t.clientY});if(!l)return;const s=n.doc.resolve(l.pos),{nodes:a}=n.schema;let i=-1,c=!1;for(let p=s.depth;p>=0;p--){const C=s.node(p);if(!c&&(C.type===a.tableCell||C.type===a.tableHeader)&&(c=!0),i===-1&&C.type===a.paragraph&&(i=p),c&&i!==-1)break}if(!c||i===-1)return;const d=s.start(i),f=s.end(i),h=M.TextSelection.create(n.doc,d,f);n.selection.eq(h)||(o.dispatch(n.tr.setSelection(h)),o.focus())};mouseUpHandler=t=>{this.mouseState="up",this.mouseMoveHandler(t)};mouseMoveHandler=t=>{if(this.menuFrozen||this.mouseState==="selecting")return;const n=t.target;!nn(n)||!this.editorView.dom.contains(n)||this._handleMouseMoveNow(t)};hideHandles(){this.state?.show&&(this.state={...this.state,show:!1,showAddOrRemoveRowsButton:!1,showAddOrRemoveColumnsButton:!1,colIndex:void 0,rowIndex:void 0,referencePosCell:void 0},this.emitUpdate())}_handleMouseMoveNow(t){const n=ur(t.target);if(n?.type==="cell"&&this.mouseState==="down"&&!this.state?.draggingState){this.mouseState="selecting",this.hideHandles();return}if(!n||!this.editor.isEditable){this.hideHandles();return}const o=n.tbodyNode;if(!o)return;const l=o.getBoundingClientRect(),s=this.editor.view.posAtCoords({left:t.clientX,top:t.clientY});if(!s)return;const a=this.editor.view.state.doc.resolve(s.pos);let i;for(let f=a.depth;f>=0;f--){const h=a.node(f);if(vr(h)){i={node:h,pos:f===0?0:a.before(f)};break}}if(!i||i.node.type.name!=="table")return;this.tableElement=this.editor.view.nodeDOM(i.pos),this.tablePos=i.pos,this.tableId=i.node.attrs.id;const d=dr(n.domNode,".tableWrapper")?.querySelector(".table-controls");if(n.type==="wrapper"){const f=t.clientY>=l.bottom-1&&t.clientY<l.bottom+20,h=t.clientX>=l.right-1&&t.clientX<l.right+20,p=t.clientX>l.right||t.clientY>l.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:f,showAddOrRemoveColumnsButton:h,referencePosTable:l,block:i.node,blockPos:i.pos,widgetContainer:d,colIndex:p?void 0:this.state?.colIndex,rowIndex:p?void 0:this.state?.rowIndex,referencePosCell:p?void 0:this.state?.referencePosCell}}else{const f=wr(n.domNode,i.node,this.editor);if(!f)return;const{rowIndex:h,colIndex:p}=f,C=n.domNode.getBoundingClientRect(),b=i.node.content.childCount-1,g=(i.node.content.firstChild?.content.childCount??0)-1;if(this.state?.show&&this.tableId===i.node.attrs.id&&this.state.rowIndex===h&&this.state.colIndex===p)return;this.state={show:!0,showAddOrRemoveColumnsButton:p===g,showAddOrRemoveRowsButton:h===b,referencePosTable:l,block:i.node,blockPos:i.pos,draggingState:void 0,referencePosCell:C,colIndex:p,rowIndex:h,widgetContainer:d}}return this.emitUpdate(),!1}dragOverHandler=t=>{if(this.state?.draggingState===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",g1(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.editorView.root);const{left:n,right:o,top:l,bottom:s}=this.state.referencePosTable,a={left:He(t.clientX,n+1,o-1),top:He(t.clientY,l+1,s-1)},i=this.editorView.root.elementsFromPoint(a.left,a.top).filter(m=>m.tagName==="TD"||m.tagName==="TH");if(i.length===0)return;const c=i[0];if(!nn(c))return;const d=wr(c,this.state.block,this.editor);if(!d)return;const{rowIndex:f,colIndex:h}=d,p=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,b=(this.state.draggingState.draggedCellOrientation==="row"?f:h)!==p,g=this.state.draggingState.draggedCellOrientation==="row"?a.top:a.left,w=this.state.rowIndex!==f||this.state.colIndex!==h,v=this.state.draggingState.mousePos!==g;(w||v)&&(this.state={...this.state,rowIndex:f,colIndex:h,referencePosCell:c.getBoundingClientRect(),draggingState:{...this.state.draggingState,mousePos:g}},this.emitUpdate()),b&&this.editor.view.dispatch(this.editor.state.tr.setMeta(Se,!0))};dropHandler=()=>{this.mouseState="up";const t=this.state;if(!t?.draggingState)return!1;const{draggingState:n,rowIndex:o,colIndex:l,blockPos:s}=t;if(!K(s))return!1;if(n.draggedCellOrientation==="row"&&o===void 0||n.draggedCellOrientation==="col"&&l===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");const a=n.draggedCellOrientation==="row",i=a?"row":"column",c=a?o:l,d=Ve({editor:this.editor,index:n.originalIndex,orientation:i,tablePos:s});if(!d)return!1;const f=ve(this.editor,s,d,{mode:"state"});if(!f)return!1;const h=p=>this.editor.view.dispatch(p);return a?I.moveTableRow({from:n.originalIndex,to:c,select:!0,pos:s+1})(f,h):I.moveTableColumn({from:n.originalIndex,to:c,select:!0,pos:s+1})(f,h),this.state={...t,draggingState:void 0},this.emitUpdate(),this.editor.view.dispatch(this.editor.state.tr.setMeta(Se,null)),!0};update(t){const n=Se.getState(t.state);if(n!==void 0&&n!==this.menuFrozen&&(this.menuFrozen=n),!this.state?.show)return;if(!this.tableElement?.isConnected){this.hideHandles();return}const o=l1(this.tableElement,this.editor);if(!o){this.hideHandles();return}const l=this.state.block!==o.node||this.state.blockPos!==o.pos;if(!o.node||o.node.type.name!=="table"||!this.tableElement?.isConnected){this.hideHandles();return}const{height:s,width:a}=I.TableMap.get(o.node);let i=this.state.rowIndex,c=this.state.colIndex;i!==void 0&&i>=s&&(i=s?s-1:void 0),c!==void 0&&c>=a&&(c=a?a-1:void 0);const d=this.tableElement.querySelector("tbody");if(!d)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");let f=this.state.referencePosCell;if(i!==void 0&&c!==void 0){const g=d.children[i]?.children[c];g?f=g.getBoundingClientRect():(i=void 0,c=void 0,f=void 0)}const h=d.getBoundingClientRect(),p=i!==this.state.rowIndex||c!==this.state.colIndex,C=f!==this.state.referencePosCell||h!==this.state.referencePosTable;(l||p||C)&&(this.state={...this.state,block:o.node,blockPos:o.pos,rowIndex:i,colIndex:c,referencePosCell:f,referencePosTable:h},this.emitUpdate())}destroy(){this.editorView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.editorView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.editorView.root.removeEventListener("dragover",this.dragOverHandler),this.editorView.root.removeEventListener("drop",this.dropHandler)}}let W=null;function w1(e,t){return new M.Plugin({key:Se,state:{init:()=>!1,apply:(n,o)=>{const l=n.getMeta(Se);return l!==void 0?l:o}},view:n=>(W=new b1(e,n,t),W),props:{decorations:n=>{if(!W)return null;if(W===void 0||W.state===void 0||W.state.draggingState===void 0||W.tablePos===void 0)return;const o=W.state.draggingState.draggedCellOrientation==="row"?W.state.rowIndex:W.state.colIndex;if(o===void 0)return;const l=[],{draggingState:s}=W.state,{originalIndex:a}=s;return W.state.draggingState.draggedCellOrientation==="row"?Cr(e,a,W.state.blockPos).cells.forEach(c=>{c.node&&l.push(We.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}):gr(e,a,W.state.blockPos).cells.forEach(c=>{c.node&&l.push(We.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}),o===a||!e||(W.state.draggingState.draggedCellOrientation==="row"?Cr(e,o,W.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const f=c.pos+(o>a?d.nodeSize-2:2);l.push(We.Decoration.widget(f,()=>{const h=document.createElement("div");return h.className="tiptap-table-dropcursor",h.style.left="0",h.style.right="0",o>a?h.style.bottom="-1px":h.style.top="-1px",h.style.height="3px",h}))}):gr(e,o,W.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const f=c.pos+(o>a?d.nodeSize-2:2);l.push(We.Decoration.widget(f,()=>{const h=document.createElement("div");return h.className="tiptap-table-dropcursor",h.style.top="0",h.style.bottom="0",o>a?h.style.right="-1px":h.style.left="-1px",h.style.width="3px",h}))})),We.DecorationSet.create(n.doc,l)}}})}const Tr=(e,t)=>{if(!W?.state)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{state:n,editor:o}=W,l=e==="col"?n.colIndex:n.rowIndex;if(l===void 0)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{blockPos:s,referencePosCell:a}=n,i=e==="col"?t.clientX:t.clientY;if(o.state.selection instanceof I.CellSelection){const h=M.TextSelection.near(o.state.doc.resolve(s),1);o.view.dispatch(o.state.tr.setSelection(h))}const c=C1(o,e,l,s);if(t.dataTransfer){const h=t.currentTarget.getBoundingClientRect(),p=e==="col"?{x:h.width/2,y:0}:{x:0,y:h.height/2};t.dataTransfer.effectAllowed=e==="col"?"move":"copyMove",t.dataTransfer.setDragImage(c,p.x,p.y)}const d=()=>c.parentNode?.removeChild(c);document.addEventListener("drop",d,{once:!0}),document.addEventListener("dragend",d,{once:!0});const f=a?(e==="col"?a.left:a.top)-i:0;W.state={...n,draggingState:{draggedCellOrientation:e,originalIndex:l,mousePos:i,initialOffset:f}},W.emitUpdate(),o.view.dispatch(o.state.tr.setMeta(Se,!0))},v1=e=>Tr("col",{...e,clientY:0}),m1=e=>Tr("row",{...e,clientX:0}),y1=()=>{if(!W||W.state===void 0)return;W.state={...W.state,draggingState:void 0},W.emitUpdate();const e=W.editor;e.view.dispatch(e.state.tr.setMeta(Se,null))},x1=be.Extension.create({name:"tableHandleExtension",addCommands(){return{freezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(Se,!0),!0),unfreezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(Se,!1),!0)}},addProseMirrorPlugins(){const{editor:e}=this;return[w1(e,t=>{this.editor.emit("tableHandleState",t)})]}});function S1(e,t,n){if(n?.draggedCellOrientation==="row"){const o=n.mousePos+(n.initialOffset??0),l=He(o,t.y,t.bottom-e.height);return new DOMRect(t.x,l,t.width,e.height)}return new DOMRect(t.x,e.y,t.width,e.height)}function T1(e,t,n){if(n?.draggedCellOrientation==="col"){const o=n.mousePos+(n.initialOffset??0),l=He(o,t.x,t.right-e.width);return new DOMRect(l,t.y,e.width,t.height)}return new DOMRect(e.x,t.y,e.width,t.height)}function I1(e){return new DOMRect(e.x,e.y,e.width,0)}function M1(e){switch(e){case"row":return"left";case"col":return"top";default:return"bottom-end"}}function k1(e){switch(e){case"row":return 4;case"col":return 4;default:return{mainAxis:1,crossAxis:-1}}}function E1(e,t,n,o){switch(e){case"row":return S1(t,n,o);case"col":return T1(t,n,o);default:return I1(t)}}function an(e,t,n,o,l){const s=u.useMemo(()=>M1(e),[e]),a=u.useMemo(()=>k1(e),[e]),{refs:i,update:c,context:d,floatingStyles:f}=D.useFloating({open:t,placement:s,middleware:[D.offset(a),D.size({apply({rects:C,elements:b}){if(!b.floating)return;const g=(e==="col"?n?.width??o?.width:o?.width)??C.reference.width,w=(e==="row"?n?.height??o?.height:o?.height)??C.reference.height;b.floating.style.setProperty("--table-handle-ref-width",`${g}px`),b.floating.style.setProperty("--table-handle-ref-height",`${w}px`);const v=e==="row"?w:g;b.floating.style.setProperty("--table-handle-available-size",`${v}px`)}})]}),{isMounted:h,styles:p}=D.useTransitionStyles(d);return u.useEffect(()=>{c()},[c,t,e,n,o,l]),u.useEffect(()=>{!n||!o||l&&e==="cell"||i.setReference({getBoundingClientRect:()=>E1(e,n,o,l)})},[i,e,n,o,l]),u.useMemo(()=>({isMounted:h,ref:i.setFloating,style:{display:"flex",...p,...f}}),[h,i.setFloating,p,f])}function L1(e,t,n,o){const l=an("row",e,t,n,o),s=an("col",e,t,n,o),a=an("cell",e,t,n,o);return u.useMemo(()=>({rowHandle:l,colHandle:s,cellHandle:a}),[l,s,a])}function cn(e={}){const{editor:t,initialState:n=null,watchFields:o,onStateChange:l}=e,{editor:s}=S(t),[a,i]=u.useState(n),c=u.useRef(n),d=u.useCallback(f=>{o&&c.current&&!o.some(p=>c.current[p]!==f[p])||(i(f),c.current=f,l?.(f))},[o,l]);return u.useEffect(()=>{if(!s){i(null),c.current=null,l?.(null);return}return s.on("tableHandleState",d),()=>{s.off("tableHandleState",d)}},[s,l,d]),a}const gt=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 5C10 3.89543 10.8954 3 12 3C13.1046 3 14 3.89543 14 5C14 6.10457 13.1046 7 12 7C10.8954 7 10 6.10457 10 5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 19C10 17.8954 10.8954 17 12 17C13.1046 17 14 17.8954 14 19C14 20.1046 13.1046 21 12 21C10.8954 21 10 20.1046 10 19Z",fill:"currentColor"})]}));gt.displayName="MoreVerticalIcon";function A1({className:e,type:t,...n}){return r.jsx("input",{type:t,"data-slot":"tiptap-input",className:U("tiptap-input",e),...n})}Kt.cva("tiptap-input-group-addon",{variants:{align:{"inline-start":"tiptap-input-group-addon--inline-start","inline-end":"tiptap-input-group-addon--inline-end","block-start":"tiptap-input-group-addon--block-start","block-end":"tiptap-input-group-addon--block-end"}},defaultVariants:{align:"inline-start"}}),Kt.cva("tiptap-input-group-button",{variants:{size:{xs:"tiptap-input-group-button--xs",sm:"tiptap-input-group-button--sm","icon-xs":"tiptap-input-group-button--icon-xs","icon-sm":"tiptap-input-group-button--icon-sm"}},defaultVariants:{size:"xs"}});function H1({...e}){return r.jsx(se.ComboboxProvider,{includesBaseElement:!1,resetValueOnHide:!0,...e})}function dn({className:e,...t}){return r.jsx(se.Combobox,{autoSelect:!0,...t,className:U("tiptap-combobox",e)})}function _e({className:e,...t}){return r.jsx(se.ComboboxList,{"data-slot":"tiptap-combobox-list",className:U("tiptap-combobox-list",e),...t})}function N1({className:e,...t}){return r.jsx(se.ComboboxItem,{"data-slot":"tiptap-combobox-item",className:U("tiptap-combobox-item",e),...t})}const V1=typeof window<"u"?u.useLayoutEffect:u.useEffect;function B1(e,t,n,o){const l=u.useRef(t);V1(()=>{l.current=t},[t]),u.useEffect(()=>{const s=window;if(!(s&&s.addEventListener))return;const a=i=>{l.current(i)};return s.addEventListener(e,a,o),()=>{s.removeEventListener(e,a,o)}},[e,n,o])}function D1(e,t,n="mousedown",o={}){B1(n,l=>{const s=l.target;if(!s||!s.isConnected)return;(Array.isArray(e)?e.filter(i=>!!i.current).every(i=>i.current&&!i.current.contains(s)):e.current&&!e.current.contains(s))&&t(l)},void 0,o)}const Ir=(e,t)=>{typeof e=="function"?e(t):e&&typeof e=="object"&&"current"in e&&(e.current=t)},Mr=(e,t)=>{const n=u.useRef(null);return u.useCallback(o=>{e&&"current"in e&&(e.current=o),n.current&&Ir(n.current,null),n.current=t,t&&Ir(t,o)},[e,t])};function qe({children:e,trigger:t,value:n,onOpenChange:o,onValueChange:l,onValuesChange:s,...a}){const i=!se.useMenuContext(),[c,d]=u.useState(!1),f=!!s||i,h=u.useCallback(b=>{a.open===void 0&&d(b),o?.(b)},[a.open,o]),p=u.useMemo(()=>({isRootMenu:i,open:a.open??c}),[i,a.open,c]),C=r.jsxs(se.MenuProvider,{open:c,setOpen:h,setValues:s,showTimeout:100,...a,children:[t,r.jsx(Er.Provider,{value:p,children:r.jsx(kr.Provider,{value:f,children:e})})]});return f?r.jsx(H1,{value:n,setValue:l,children:C}):C}function Ke({children:e,className:t,ref:n,onClickOutside:o,...l}){const s=u.useRef(null),{open:a}=Z1(),i=F1();return D1(s,o||(()=>{})),r.jsx(se.Menu,{ref:Mr(s,n),className:U("tiptap-menu-content",t),"data-side":i,"data-state":a?"open":"closed",gutter:4,flip:!0,unmountOnHide:!0,...l,children:e})}function Ge({className:e,...t}){return r.jsx(se.MenuButton,{...t,className:U("tiptap-menu-button",e)})}function U1({className:e,...t}){return r.jsx(se.MenuButtonArrow,{...t,className:U("tiptap-menu-button-arrow",e)})}function ae({className:e,...t}){return r.jsx(se.MenuGroup,{...t,className:U("tiptap-menu-group",e)})}function nt({className:e,...t}){return r.jsx(se.MenuGroupLabel,{...t,className:U("tiptap-menu-group-label",e)})}function O1({className:e,...t}){return r.jsx(se.MenuItemRadio,{...t,className:U("tiptap-menu-item-radio",e)})}function Te({name:e,value:t,preventClose:n,className:o,...l}){const s=se.useMenuContext(),a=P1(),i=$1(s,n),c={blurOnHoverEnd:!1,focusOnHover:!0,className:U("tiptap-menu-item",o),...l};return a?r.jsx(N1,{...c,hideOnClick:i}):e&&t?r.jsx(O1,{...c,hideOnClick:!0,name:e,value:t}):r.jsx(se.MenuItem,{...c})}const kr=u.createContext(!1),Er=u.createContext({isRootMenu:!1,open:!1}),P1=()=>u.useContext(kr),Z1=()=>u.useContext(Er);function F1(){const e=se.useMenuStore();return se.useStoreState(e,n=>n.currentPlacement?.split("-")[0]||"bottom")}function $1(e,t){return u.useCallback(n=>(n.currentTarget.hasAttribute("aria-expanded")||t||e?.hideAll(),!1),[e,t])}function R({decorative:e,orientation:t="vertical",className:n,...o}){const s=e?{role:"none"}:{"aria-orientation":t==="vertical"?t:void 0,role:"separator"};return r.jsx("div",{className:U("tiptap-separator",n),"data-orientation":t,...s,...o})}const z1=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l=!1,onDuplicated:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleDuplicate:C,label:b,canDuplicateRowColumn:g,Icon:w}=Ar({editor:h,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l,onDuplicated:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});z1.displayName="TableDuplicateRowColumnButton";const un=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 9C9.44772 9 9 9.44772 9 10V20C9 20.5523 9.44772 21 10 21H20C20.5523 21 21 20.5523 21 20V10C21 9.44772 20.5523 9 20 9H10ZM7 10C7 8.34315 8.34315 7 10 7H20C21.6569 7 23 8.34315 23 10V20C23 21.6569 21.6569 23 20 23H10C8.34315 23 7 21.6569 7 20V10Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C3.45228 3 3 3.45228 3 4V14C3 14.5477 3.45228 15 4 15C4.55228 15 5 15.4477 5 16C5 16.5523 4.55228 17 4 17C2.34772 17 1 15.6523 1 14V4C1 2.34772 2.34772 1 4 1H14C15.6523 1 17 2.34772 17 4C17 4.55228 16.5523 5 16 5C15.4477 5 15 4.55228 15 4C15 3.45228 14.5477 3 14 3H4Z",fill:"currentColor"})]}));un.displayName="CopyIcon";const Lr=["tableHandleExtension"],W1={row:"Duplicate row",column:"Duplicate column"};function fn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,Lr))return!1;try{if(!J(e,o))return!1;const s=he(e,t,n,o);return s.mergedCells.length>0?!1:s.cells.length>0}catch{return!1}}function _1({editor:e,index:t,tablePos:n}){try{const o=he(e,t,"row",n);if(o.cells.length===0)return!1;let l=!1;if(e.state.selection instanceof I.CellSelection)l=e.chain().focus().addRowAfter().run();else{if(!n)return!1;const h=Ve({editor:e,index:t,orientation:"row",tablePos:n});if(!h)return!1;const p=ve(e,n,h,{mode:"state"});l=I.addRowAfter(p,e.view.dispatch)}if(!l)return!1;const s=he(e,t+1,"row",n);if(s.cells.length===0)return!1;const{state:a,view:i}=e,c=a.tr,d=[...s.cells].reverse(),f=[...o.cells].reverse();return d.forEach((h,p)=>{const C=f[p];if(h.node&&C?.node){const b=h.node.type.create({...C.node.attrs},C.node.content,C.node.marks),g=h.pos+h.node.nodeSize;c.replaceWith(h.pos,g,b)}}),c.docChanged?(i.dispatch(c),ln(e,"row",t+1,n),!0):!1}catch(o){return console.error("Error duplicating row:",o),!1}}function q1({editor:e,index:t,tablePos:n}){try{const o=he(e,t,"column",n);if(o.cells.length===0)return!1;let l=!1;if(e.state.selection instanceof I.CellSelection)l=e.chain().focus().addColumnAfter().run();else{if(!n)return!1;const h=Ve({editor:e,index:t,orientation:"column",tablePos:n});if(!h)return!1;const p=ve(e,n,h,{mode:"state"});l=I.addColumnAfter(p,e.view.dispatch)}if(!l)return!1;const s=he(e,t+1,"column",n);if(s.cells.length===0)return!1;const{state:a,view:i}=e,c=a.tr,d=[...s.cells].reverse(),f=[...o.cells].reverse();return d.forEach((h,p)=>{const C=f[p];if(h.node&&C?.node){const b=h.node.type.create({...C.node.attrs},C.node.content,C.node.marks),g=h.pos+h.node.nodeSize;c.replaceWith(h.pos,g,b)}}),c.docChanged?(i.dispatch(c),ln(e,"column",t+1,n),!0):!1}catch(o){return console.error("Error duplicating column:",o),!1}}function K1({editor:e,index:t,orientation:n,tablePos:o}){if(!fn({editor:e,index:t,orientation:n,tablePos:o})||!e||!J(e,o))return!1;const s=Y(e,t,n,o);if(!s)return!1;try{return s.orientation==="row"?_1({editor:e,index:s.index,tablePos:o}):s.orientation==="column"?q1({editor:e,index:s.index,tablePos:o}):!1}catch(a){return console.error("Error duplicating row/column:",a),!1}}function G1({editor:e,index:t,orientation:n,hideWhenUnavailable:o}){return!e||!e.isEditable||!V(e,Lr)?!1:o?fn({editor:e,index:t,orientation:n}):!0}function Ar(e){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,onDuplicated:a}=e,{editor:i}=S(t),c=Y(i,n,o),d=G1({editor:i,index:n,orientation:o,hideWhenUnavailable:s}),f=fn({editor:i,index:n,tablePos:l,orientation:o}),h=u.useCallback(()=>{const b=K1({editor:i,index:n,orientation:o,tablePos:l});return b&&a?.(),b},[i,n,o,l,a]),p=u.useMemo(()=>W1[c?.orientation||"row"],[c]);return{isVisible:d,canDuplicateRowColumn:f,handleDuplicate:h,label:p,Icon:un}}const Y1=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:l=!1,onMoved:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleMove:C,label:b,canMoveRowColumn:g,Icon:w}=ot({editor:h,index:t,orientation:n,direction:o,hideWhenUnavailable:l,onMoved:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});Y1.displayName="TableMoveRowColumnButton";const hn=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));hn.displayName="ArrowLeftIcon";const Hr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289C10.9024 4.68342 10.9024 5.31658 11.2929 5.70711L16.5858 11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H16.5858L11.2929 18.2929C10.9024 18.6834 10.9024 19.3166 11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071L19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));Hr.displayName="ArrowRightIcon";const Nr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071C4.68342 13.0976 5.31658 13.0976 5.70711 12.7071L11 7.41421V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V7.41421L18.2929 12.7071C18.6834 13.0976 19.3166 13.0976 19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));Nr.displayName="ArrowUpIcon";const Vr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M12.707 19.707C12.3165 20.0976 11.6835 20.0976 11.293 19.707L4.29297 12.707C3.90245 12.3165 3.90245 11.6835 4.29297 11.293C4.68349 10.9024 5.31651 10.9024 5.70703 11.293L11 16.5859L11 5C11 4.44771 11.4477 4 12 4C12.5523 4 13 4.44771 13 5L13 16.5859L18.293 11.293C18.6835 10.9024 19.3165 10.9024 19.707 11.293C20.0976 11.6835 20.0976 12.3165 19.707 12.707L12.707 19.707Z",fill:"currentColor"})}));Vr.displayName="ArrowDownIcon";const Br=["tableHandleExtension"],X1={row:{up:"Move row up",down:"Move row down",left:"Move row left",right:"Move row right"},column:{up:"Move column up",down:"Move column down",left:"Move column left",right:"Move column right"}},j1={up:Nr,down:Vr,left:hn,right:Hr};function Q1(e,t,n){try{return I.columnIsHeader(e,t,n)}catch{return!1}}function J1(e,t,n){try{return I.rowIsHeader(e,t,n)}catch{return!1}}function pn(e,t){return e==="row"?t==="up"||t==="down":e==="column"?t==="left"||t==="right":!1}function Cn({editor:e,index:t,orientation:n,direction:o,tablePos:l}){if(!e||!e.isEditable||!V(e,Br))return!1;try{const s=J(e,l);if(!s)return!1;const a=Y(e,t,n);if(!a)return!1;const{orientation:i,index:c}=a;if(!pn(i,o)||i==="row"&&J1(s.map,s.node,c)||i==="column"&&Q1(s.map,s.node,c))return!1;const{width:d,height:f}=s.map,h=i==="row"?o==="up"?c-1:c+1:o==="left"?c-1:c+1,p=i==="row"?f:d;if(h<0||h>=p)return!1;const C=Ve({editor:e,index:c,orientation:i,tablePos:l}),b=Ve({editor:e,index:h,orientation:i,tablePos:l});if(!C||!b)return!1;const g=ve(e,s.pos,C,{mode:"state"});if(!g)return!1;const w=I.selectedRect(g),v=ve(e,s.pos,b,{mode:"state"});if(!v)return!1;const m=I.selectedRect(v);return pr(s.map,w)&&pr(s.map,m)?!1:i==="row"?o==="up"?c>0:c<f-1:o==="left"?c>0:c<d-1}catch{return!1}}function R1({editor:e,index:t,orientation:n,direction:o,tablePos:l}){if(!Cn({editor:e,index:t,orientation:n,direction:o,tablePos:l})||!e)return!1;try{const s=J(e,l);if(!s)return!1;const a=Y(e,t,n);if(!a)return!1;const{orientation:i,index:c}=a;if(!pn(i,o))return!1;const f=c+{up:-1,down:1,left:-1,right:1}[o],h=i==="row"?I.moveTableRow:I.moveTableColumn,p=C=>e.view.dispatch(C);if(e.state.selection instanceof I.CellSelection)return h({from:c,to:f,select:!0,pos:s.start})(e.state,p);{const C=Ve({editor:e,index:c,orientation:i,tablePos:l});if(!C)return!1;const b=ve(e,s.pos,C,{mode:"state"});return b?h({from:c,to:f,select:!0,pos:s.start})(b,p):!1}}catch(s){return console.error("Error moving table row/column:",s),!1}}function ec({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:l,tablePos:s}){if(!e||!e.isEditable||!V(e,Br))return!1;const a=Y(e,t,n);return!a||!pn(a.orientation,o)?!1:l?Cn({editor:e,index:t,orientation:n,direction:o,tablePos:s}):!0}function ot(e){const{editor:t,index:n,orientation:o,tablePos:l,direction:s,hideWhenUnavailable:a=!1,onMoved:i}=e,{editor:c}=S(t),d=Y(c,n,o),f=ec({editor:c,index:n,orientation:o,direction:s,hideWhenUnavailable:a,tablePos:l}),h=Cn({editor:c,index:n,orientation:o,direction:s,tablePos:l}),p=u.useCallback(()=>{const g=R1({editor:c,index:n,orientation:o,direction:s,tablePos:l});return g&&i?.(),g},[c,n,o,s,l,i]),C=u.useMemo(()=>X1[d?.orientation||"row"][s]||`Move ${d?.orientation} ${s}`,[d,s]),b=u.useMemo(()=>j1[s],[s]);return{isVisible:f,canMoveRowColumn:h,handleMove:p,label:C,Icon:b}}const tc=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,resetAttrs:l=!1,onCleared:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleClear:C,label:b,canClearRowColumnContent:g,Icon:w}=bt({editor:h,index:t,orientation:n,hideWhenUnavailable:o,resetAttrs:l,onCleared:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});tc.displayName="TableClearRowColumnContentButton";const Dr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V5C20 4.44772 19.5523 4 19 4H5ZM2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM15.7071 8.29289C16.0976 8.68342 16.0976 9.31658 15.7071 9.70711L13.4142 12L15.7071 14.2929C16.0976 14.6834 16.0976 15.3166 15.7071 15.7071C15.3166 16.0976 14.6834 16.0976 14.2929 15.7071L12 13.4142L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L10.5858 12L8.29289 9.70711C7.90237 9.31658 7.90237 8.68342 8.29289 8.29289C8.68342 7.90237 9.31658 7.90237 9.70711 8.29289L12 10.5858L14.2929 8.29289C14.6834 7.90237 15.3166 7.90237 15.7071 8.29289Z",fill:"currentColor"})}));Dr.displayName="SquareXIcon";const Ur=["table"],nc={row:"Clear row contents",column:"Clear column contents"},Or={backgroundColor:null,nodeVerticalAlign:null,nodeTextAlign:null};function Pr(e){try{return Ri(Or)(e.state,e.view.dispatch)}catch(t){return console.error("Error resetting cell attributes:",t),!1}}function gn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,Ur))return!1;try{if(!J(e,o))return!1;const s=Y(e,t,n,o);if(s){const a=he(e,s.index,s.orientation,o);return a.cells.length===0?!1:a.cells.some(i=>i.node&&!Ne(i.node))}else{const{selection:a}=e.state;if(a instanceof I.CellSelection){let f=!1;return a.forEachCell(h=>{Ne(h)||(f=!0)}),f}const{$anchor:i}=a,c=I.cellAround(i);if(!c)return!1;const d=e.state.doc.nodeAt(c.pos);return d?!Ne(d):!1}}catch{return!1}}function oc(e,t=!1){try{const{selection:n}=e.state;if(n instanceof I.CellSelection)return t&&Pr(e),I.deleteCellSelection(e.state,e.view.dispatch),!0;const{$anchor:o}=n,l=I.cellAround(o);if(!l)return!1;const s=e.state.doc.nodeAt(l.pos);if(!s)return!1;const a=l.pos+1,i=l.pos+s.nodeSize-1;return a>=i?!1:(t&&Pr(e),e.view.dispatch(e.state.tr.delete(a,i)),!0)}catch(n){return console.error("Error clearing selected cells:",n),!1}}function rc({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:l=!1}){try{const{state:s,view:a}=e,i=s.tr,c=he(e,t,n,o);return c.cells.length===0?!1:([...c.cells].reverse().forEach(f=>{if(f.node&&!Ne(f.node)){const h=f.pos+1,p=f.pos+f.node.nodeSize-1;h<p&&i.delete(h,p),l&&i.setNodeMarkup(f.pos,null,{...f.node.attrs,...Or})}}),i.docChanged?(a.dispatch(i),!0):!1)}catch(s){return console.error(`Error clearing ${n} content:`,s),!1}}function lc({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:l=!1}){if(!gn({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const s=Y(e,t,n,o);return s?rc({editor:e,index:s.index,orientation:s.orientation,resetAttrs:l,tablePos:o}):oc(e,l)}catch(s){return console.error("Error clearing table content:",s),!1}}function sc({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l}){if(!e||!e.isEditable||!V(e,Ur)||!J(e,o))return!1;const a=Y(e,t,n,o),{selection:i}=e.state,c=i instanceof I.CellSelection||I.cellAround(i.$anchor);return!a&&!c?!1:l?gn({editor:e,index:t,orientation:n,tablePos:o}):!0}function bt(e={}){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,resetAttrs:a=!1,onCleared:i}=e,{editor:c}=S(t),d=Y(c,n,o,l),f=sc({editor:c,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s}),h=gn({editor:c,index:n,orientation:o,tablePos:l}),p=u.useCallback(()=>{const g=lc({editor:c,index:n,orientation:o,tablePos:l,resetAttrs:a});return g&&i?.(),g},[c,n,o,l,a,i]),C=u.useMemo(()=>d?nc[d.orientation]:"Clear contents",[d]);return{isVisible:f,canClearRowColumnContent:h,handleClear:p,label:C,Icon:Dr}}const ac=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,onToggled:l,text:s,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleToggle:p,label:C,canToggleHeader:b,Icon:g,isActive:w}=zr({editor:f,index:t,orientation:n,hideWhenUnavailable:o,onToggled:l}),v=u.useCallback(m=>{a?.(m),!m.defaultPrevented&&p()},[p,a]);return h?r.jsx(k,{type:"button",disabled:!b,variant:"ghost","data-active-state":w?"on":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":w,tooltip:C,onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"tiptap-button-icon"}),s&&r.jsx("span",{className:"tiptap-button-text",children:s})]})}):null});ac.displayName="TableHeaderRowColumnButton";const Zr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5V7V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19V7V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5ZM20 19V8H16V20H19C19.5523 20 20 19.5523 20 19ZM14 20L14 8H10L10 20H14ZM8 20L8 8H4V19C4 19.5523 4.44772 20 5 20H8Z",fill:"currentColor"})}));Zr.displayName="TableHeaderRowIcon";const Fr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19ZM8 20V16H20V19C20 19.5523 19.5523 20 19 20H8ZM8 14L20 14V10L8 10V14ZM20 8L8 8V4H19C19.5523 4 20 4.44772 20 5V8Z",fill:"currentColor"})}));Fr.displayName="TableHeaderColumnIcon";const $r=["table"],ic={row:"Header row",column:"Header column"},cc={row:Zr,column:Fr};function bn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,$r))return!1;const l=Y(e,t,n,o);return l?l.index===0:!1}function dc({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!bn({editor:e,index:t,orientation:n,tablePos:o}))return!1;try{const l=Y(e,t,n,o);if(!l)return!1;const s=l.orientation==="row";if(e.state.selection instanceof I.CellSelection)return s?e.commands.toggleHeaderRow():e.commands.toggleHeaderColumn();if(!K(o))return!1;const a=Ve({editor:e,index:l.index,orientation:l.orientation,tablePos:o});if(!a)return!1;const i=ve(e,o,a,{mode:"state"});if(!i)return!1;const c=d=>e.view.dispatch(d);return s?I.toggleHeader("row")(i,c):I.toggleHeader("column")(i,c)}catch{return!1}}function uc({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:l}){return!e||!e.isEditable||!V(e,$r)?!1:o?bn({editor:e,index:t,orientation:n,tablePos:l}):!!Y(e,t,n)}function zr(e){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,onToggled:a}=e,{editor:i}=S(t),c=Y(i,n,o),d=uc({editor:i,index:n,orientation:o,hideWhenUnavailable:s,tablePos:l}),f=bn({editor:i,index:n,orientation:o,tablePos:l});let h=!1;if(i?.state.selection instanceof I.CellSelection)h=i?.isActive("tableHeader")||!1;else{const g=he(i,n,c?.orientation,l);if(g){const w=g.cells.length>1?1:0;h=g.cells[w]?.node?.type.name==="tableHeader"||!1}}const p=u.useCallback(()=>{const g=dc({editor:i,index:n,orientation:o,tablePos:l});return g&&a?.(),g},[i,n,o,l,a]),C=ic[c?.orientation||"row"],b=cc[c?.orientation||"row"];return{isVisible:d,canToggleHeader:f,handleToggle:p,label:C,Icon:b,isActive:h}}const fc=u.forwardRef(({editor:e,index:t,orientation:n,side:o,tablePos:l,hideWhenUnavailable:s=!1,onAdded:a,text:i,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,handleAdd:b,label:g,canAddRowColumn:w,Icon:v}=rt({editor:p,index:t,orientation:n,side:o,tablePos:l,hideWhenUnavailable:s,onAdded:a}),m=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?r.jsx(k,{type:"button",disabled:!w,variant:"ghost","data-active-state":"off","data-disabled":!w,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:m,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),i&&r.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});fc.displayName="TableAddRowColumnButton";const Wr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H15C13.3431 22 12 20.6569 12 19V5C12 3.34315 13.3431 2 15 2H19ZM14 19C14 19.5523 14.4477 20 15 20H19C19.5523 20 20 19.5523 20 19V13H14V19ZM15 4C14.4477 4 14 4.44772 14 5V11H20V5C20 4.44772 19.5523 4 19 4H15Z",fill:"currentColor"}),r.jsx("path",{d:"M6 8C6.55228 8 7 8.44772 7 9V11H9C9.55228 11 10 11.4477 10 12C10 12.5523 9.55228 13 9 13H7V15C7 15.5523 6.55228 16 6 16C5.44772 16 5 15.5523 5 15V13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H5V9C5 8.44772 5.44772 8 6 8Z",fill:"currentColor"})]}));Wr.displayName="AddColLeftIcon";const _r=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 2C10.6569 2 12 3.34315 12 5V19C12 20.6569 10.6569 22 9 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H9ZM4 19C4 19.5523 4.44772 20 5 20H9C9.55228 20 10 19.5523 10 19V13H4V19ZM5 4C4.44772 4 4 4.44772 4 5V11H10V5C10 4.44772 9.55228 4 9 4H5Z",fill:"currentColor"}),r.jsx("path",{d:"M18 8C18.5523 8 19 8.44772 19 9V11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H19V15C19 15.5523 18.5523 16 18 16C17.4477 16 17 15.5523 17 15V13H15C14.4477 13 14 12.5523 14 12C14 11.4477 14.4477 11 15 11H17V9C17 8.44772 17.4477 8 18 8Z",fill:"currentColor"})]}));_r.displayName="AddColRightIcon";const qr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 14C12.5523 14 13 14.4477 13 15V17H15C15.5523 17 16 17.4477 16 18C16 18.5523 15.5523 19 15 19H13V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V19H9C8.44772 19 8 18.5523 8 18C8 17.4477 8.44772 17 9 17H11V15C11 14.4477 11.4477 14 12 14Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V9C22 10.6569 20.6569 12 19 12H5C3.34315 12 2 10.6569 2 9V5C2 3.34315 3.34315 2 5 2H19ZM5 4C4.44772 4 4 4.44772 4 5V9C4 9.55228 4.44772 10 5 10H11V4H5ZM13 10H19C19.5523 10 20 9.55228 20 9V5C20 4.44772 19.5523 4 19 4H13V10Z",fill:"currentColor"})]}));qr.displayName="AddRowBottomIcon";const Kr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 12C20.6569 12 22 13.3431 22 15V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V15C2 13.3431 3.34315 12 5 12H19ZM5 14C4.44772 14 4 14.4477 4 15V19C4 19.5523 4.44772 20 5 20H11V14H5ZM13 20H19C19.5523 20 20 19.5523 20 19V15C20 14.4477 19.5523 14 19 14H13V20Z",fill:"currentColor"}),r.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V5H15C15.5523 5 16 5.44772 16 6C16 6.55228 15.5523 7 15 7H13V9C13 9.55228 12.5523 10 12 10C11.4477 10 11 9.55228 11 9V7H9C8.44772 7 8 6.55228 8 6C8 5.44772 8.44772 5 9 5H11V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"})]}));Kr.displayName="AddRowTopIcon";const Gr=["table"],Yr={row:{above:"Insert row above",below:"Insert row below"},column:{left:"Insert column left",right:"Insert column right"}};function hc(e,t,n){try{return I.columnIsHeader(e,t,n)}catch{return!1}}function pc(e,t,n){try{return I.rowIsHeader(e,t,n)}catch{return!1}}function wn({editor:e,index:t,orientation:n,tablePos:o,side:l}){if(!e||!e.isEditable||!V(e,Gr))return!1;const s=J(e,o);if(!s)return!1;const a=Y(e,t,n);if(!a)return!1;const{map:i,node:c}=s,d=a.index,f=a.orientation;return!(typeof d!="number"||d<0||f==="column"&&d>=i.width||f==="row"&&d>=i.height||l==="left"&&f==="column"&&hc(i,c,d)||l==="above"&&f==="row"&&pc(i,c,d))}function Cc(e,t,n){return t==="row"?n==="above"?e:e+1:n==="left"?e:e+1}function gc({editor:e,index:t,orientation:n,side:o,tablePos:l}){if(!wn({editor:e,index:t,orientation:n,tablePos:l,side:o})||!e)return!1;const s=Y(e,t,n);if(!s)return!1;const{orientation:a,index:i}=s,c=a==="row",d=h=>e.view.dispatch(h),f=c?o==="above"?I.addRowBefore:I.addRowAfter:o==="left"?I.addColumnBefore:I.addColumnAfter;try{let h=!1;if(e.state.selection instanceof I.CellSelection)h=f(e.state,d);else{const p=J(e,l);if(!p)return!1;const C=a==="row"?{row:i,col:0}:{row:0,col:i},b=ve(e,p.pos,[C],{mode:"state"});if(!b)return!1;h=f(b,d)}if(h){const p=Cc(i,a,o);ln(e,a,p,l)}return h}catch(h){return console.error("Error adding row/column:",h),!1}}function bc({editor:e,index:t,orientation:n,tablePos:o,side:l,hideWhenUnavailable:s}){return!e||!e.isEditable||!V(e,Gr)?!1:s?wn({editor:e,index:t,orientation:n,tablePos:o,side:l}):!!Y(e,t,n)}function rt(e){const{editor:t,index:n,orientation:o,side:l,tablePos:s,hideWhenUnavailable:a=!1,onAdded:i}=e,{editor:c}=S(t),d=Y(c,n,o),f=bc({editor:c,index:n,orientation:o,tablePos:s,side:l,hideWhenUnavailable:a}),h=wn({editor:c,index:n,orientation:o,tablePos:s,side:l}),p=u.useCallback(()=>{const g=gc({editor:c,index:n,orientation:o,tablePos:s,side:l});return g&&i?.(),g},[c,n,o,s,l,i]),C=d?.orientation==="row"?Yr.row[l]:Yr.column[l],b=d?.orientation==="row"?l==="above"?Kr:qr:l==="left"?Wr:_r;return{isVisible:f,canAddRowColumn:h,handleAdd:p,label:C,Icon:b}}const wc=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l=!1,onDeleted:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleDelete:C,label:b,canDeleteRowColumn:g,Icon:w}=jr({editor:h,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l,onDeleted:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});wc.displayName="TableDeleteRowColumnButton";const wt=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));wt.displayName="TrashIcon";const Xr=["table"],vc={row:"Delete row",column:"Delete column"};function vn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,Xr))return!1;try{return!(!J(e,o)||!Y(e,t,n))}catch{return!1}}function mc({editor:e,index:t,orientation:n,tablePos:o}){if(!vn({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const l=Y(e,t,n);if(!l)return!1;const{orientation:s,index:a}=l,i=s==="row",c=C=>e.view.dispatch(C),d=i?I.deleteRow:I.deleteColumn;if(e.state.selection instanceof I.CellSelection)return d(e.state,c);const f=J(e,o);if(!f)return!1;const h=i?{row:a,col:0}:{row:0,col:a},p=ve(e,f.pos,[h],{mode:"state"});return p?d(p,c):!1}catch(l){return console.error("Error deleting table row/column:",l),!1}}function yc({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:l}){return!e||!e.isEditable||!V(e,Xr)?!1:o?vn({editor:e,index:t,orientation:n,tablePos:l}):!0}function jr(e){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,onDeleted:a}=e,{editor:i}=S(t),c=Y(i,n,o),d=yc({editor:i,index:n,orientation:o,hideWhenUnavailable:s}),f=vn({editor:i,index:n,orientation:o,tablePos:l}),h=u.useCallback(()=>{const C=mc({editor:i,index:n,orientation:o,tablePos:l});return C&&a?.(),C},[i,n,o,l,a]),p=u.useMemo(()=>vc[c?.orientation||"row"],[c]);return{isVisible:d,canDeleteRowColumn:f,handleDelete:h,label:p,Icon:wt}}const xc=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:l=!1,onSorted:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleSort:C,label:b,canSortRowColumn:g,Icon:w}=xn({editor:h,index:t,orientation:n,direction:o,hideWhenUnavailable:l,onSorted:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});xc.displayName="TableSortRowColumnButton";const mn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),r.jsx("path",{d:"M20.1437 13.0107C20.4734 13.0585 20.7615 13.2687 20.9054 13.5762C21.0699 13.9275 21.0171 14.3426 20.7687 14.6406L17.1359 19H20.0002C20.5524 19 21.0002 19.4477 21.0002 20C21.0002 20.5523 20.5524 21 20.0002 21H15.0002C14.6122 21 14.2595 20.7752 14.0949 20.4238C13.9304 20.0725 13.9832 19.6574 14.2316 19.3594L17.8644 15H15.0002C14.4479 15 14.0002 14.5523 14.0002 14C14.0002 13.4477 14.4479 13 15.0002 13H20.0002L20.1437 13.0107Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 3C18.4284 3.00002 19.3184 3.36903 19.9748 4.02539C20.6311 4.68176 21.0002 5.57176 21.0002 6.5V10C21.0002 10.5523 20.5524 11 20.0002 11C19.4479 11 19.0002 10.5523 19.0002 10V9H16.0002V10C16.0002 10.5523 15.5524 11 15.0002 11C14.4479 11 14.0002 10.5523 14.0002 10V6.5C14.0002 5.57174 14.3692 4.68177 15.0256 4.02539C15.6819 3.36904 16.5719 3 17.5002 3ZM17.5002 5C17.1024 5 16.7209 5.15817 16.4396 5.43945C16.1583 5.72076 16.0002 6.10218 16.0002 6.5V7H19.0002V6.5C19.0002 6.10219 18.842 5.72075 18.5607 5.43945C18.2794 5.15817 17.898 5.00002 17.5002 5Z",fill:"currentColor"})]}));mn.displayName="ArrowDownAZIcon";const Qr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 13C18.4284 13 19.3184 13.369 19.9748 14.0254C20.6311 14.6818 21.0002 15.5718 21.0002 16.5V20C21.0002 20.5523 20.5524 21 20.0002 21C19.4479 21 19.0002 20.5523 19.0002 20V19H16.0002V20C16.0002 20.5523 15.5524 21 15.0002 21C14.4479 21 14.0002 20.5523 14.0002 20V16.5C14.0002 15.5717 14.3692 14.6818 15.0256 14.0254C15.6819 13.369 16.5719 13 17.5002 13ZM17.5002 15C17.1024 15 16.7209 15.1582 16.4396 15.4395C16.1583 15.7208 16.0002 16.1022 16.0002 16.5V17H19.0002V16.5C19.0002 16.1022 18.842 15.7208 18.5607 15.4395C18.2794 15.1582 17.898 15 17.5002 15Z",fill:"currentColor"}),r.jsx("path",{d:"M20.1437 3.01074C20.4734 3.05854 20.7615 3.26875 20.9054 3.57617C21.0699 3.9275 21.0171 4.34259 20.7687 4.64062L17.1359 9H20.0002C20.5524 9.00004 21.0002 9.44774 21.0002 10C21.0002 10.5523 20.5524 11 20.0002 11H15.0002C14.6122 11 14.2595 10.7752 14.0949 10.4238C13.9304 10.0725 13.9832 9.65742 14.2316 9.35938L17.8644 5H15.0002C14.4479 5 14.0002 4.55228 14.0002 4C14.0002 3.44772 14.4479 3 15.0002 3H20.0002L20.1437 3.01074Z",fill:"currentColor"})]}));Qr.displayName="ArrowDownZAIcon";const Jr=["tableHandleExtension"],Sc={row:{asc:"Sort row A-Z",desc:"Sort row Z-A"},column:{asc:"Sort column A-Z",desc:"Sort column Z-A"}},Tc={asc:mn,desc:Qr};function Rr(e){return e?e.type.name==="tableHeader"||e.type.name==="table_header"||e.attrs?.header===!0:!1}function Ic(e){if(!e)return"";let t="";return e.descendants(n=>(n.isText&&(t+=n.text||""),!0)),t.trim().toLowerCase()}function yn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,Jr))return!1;try{const l=J(e,o);if(!l)return!1;const s=he(e,t,n,o);if(s.orientation==="row"){if(l.map.width<2)return!1}else if(l.map.height<2)return!1;return!(s.mergedCells.length>0||!s.cells.some(i=>i.node&&!Rr(i.node)&&!Ne(i.node)))}catch{return!1}}function Mc({editor:e,index:t,orientation:n,direction:o,tablePos:l}){if(!yn({editor:e,index:t,orientation:n,tablePos:l})||!e)return!1;try{const{state:s,view:a}=e,i=s.tr,c=he(e,t,n,l);if(c.mergedCells.length>0)return console.warn(`Cannot sort ${n} ${t}: contains merged cells`),!1;if(c.cells.length<2)return!1;const d=c.cells.map((g,w)=>{const v=Rr(g.node),m=g.node?Ne(g.node):!0;return{sortText:Ic(g.node),originalNode:g.node,cellInfo:g,originalIndex:w,isHeader:v,isEmpty:m}}),f=d.filter(g=>!g.isHeader);if(f.length<2)return!1;f.sort((g,w)=>{if(g.isEmpty&&!w.isEmpty)return 1;if(!g.isEmpty&&w.isEmpty)return-1;if(g.isEmpty&&w.isEmpty)return 0;const v=g.sortText.localeCompare(w.sortText,void 0,{sensitivity:"base"});return o==="asc"?v:-v});const h=[];let p=0;for(let g=0;g<d.length;g++){const w=d[g],v=c.cells[g];if(!v||!w)continue;let m=null;if(w.isHeader?m=w.originalNode:(m=f[p]?.originalNode||null,p++),m&&v.node){const y=v.node.type.create(m.attrs,m.content,m.marks);h.push(y)}else h.push(v.node)}const C=[...c.cells].reverse(),b=[...h].reverse();return C.forEach((g,w)=>{const v=b[w];if(v&&g.node){const m=g.pos+g.node.nodeSize;i.replaceWith(g.pos,m,v)}}),i.docChanged?(a.dispatch(i),!0):!1}catch(s){return console.error(`Error sorting table ${n}:`,s),!1}}function kc({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:l}){return!e||!e.isEditable||!V(e,Jr)||!J(e,l)||!Y(e,t,n,l)?!1:o?yn({editor:e,index:t,orientation:n,tablePos:l}):!0}function xn(e={direction:"asc"}){const{editor:t,index:n,orientation:o,tablePos:l,direction:s,hideWhenUnavailable:a=!1,onSorted:i}=e,{editor:c}=S(t),d=Y(c,n,o),f=kc({editor:c,index:n,orientation:o,hideWhenUnavailable:a,tablePos:l}),h=yn({editor:c,index:n,orientation:o,tablePos:l}),p=u.useCallback(()=>{const g=Mc({editor:c,index:n,orientation:o,direction:s,tablePos:l});return g&&i?.(),g},[c,n,o,s,l,i]),C=u.useMemo(()=>Sc[d?.orientation||"row"][s]||`Sort ${d?.orientation} ${s}`,[d,s]),b=u.useMemo(()=>Tc[s]||mn,[s]);return{isVisible:f,canSortRowColumn:h,handleSort:p,label:C,Icon:b}}function lt({orientation:e="horizontal",size:t,style:n={},...o}){const l={...n,...e==="horizontal"&&!t&&{flex:1},...t&&{width:e==="vertical"?"1px":t,height:e==="horizontal"?"1px":t}};return r.jsx("div",{...o,style:l})}const X=u.forwardRef(({variant:e,size:t="default",appearance:n="default",trimText:o=!1,className:l,children:s,...a},i)=>r.jsx("div",{ref:i,className:`tiptap-badge ${l||""}`,"data-style":e,"data-size":t,"data-appearance":n,"data-text-trim":o?"on":"off",...a,children:s}));X.displayName="Badge";function Ec({shortcutKeys:e=Sn}){return r.jsx(X,{children:G({shortcutKeys:e})})}const st=u.forwardRef(({editor:e,textColor:t,text:n,hideWhenUnavailable:o=!1,onApplied:l,showShortcut:s=!1,onClick:a,children:i,style:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,canColorText:C,isActive:b,handleColorText:g,label:w,shortcutKeys:v,Icon:m}=el({editor:h,textColor:t,label:n||`Color text to ${t}`,hideWhenUnavailable:o,onApplied:l}),x=u.useCallback(T=>{a?.(T),!T.defaultPrevented&&g()},[g,a]),y=u.useMemo(()=>({...c,"--color-text-button-color":t}),[t,c]);return p?r.jsx(k,{type:"button",variant:"ghost","data-active-state":b?"on":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":w,"aria-pressed":b,tooltip:w,onClick:x,style:y,...d,ref:f,children:i??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-color-text",style:{color:t},children:r.jsx(m,{className:"tiptap-button-icon",style:{color:t,flexGrow:1}})}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Ec,{shortcutKeys:v})]})}):null});st.displayName="ColorTextButton";function ee(e="max",t=768){const[n,o]=u.useState(void 0);return u.useEffect(()=>{const l=e==="min"?`(min-width: ${t}px)`:`(max-width: ${t-1}px)`,s=window.matchMedia(l),a=i=>o(i.matches);return o(s.matches),s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e,t]),!!n}const vt=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.8944 5.55279C12.725 5.214 12.3787 5 12 5C11.6212 5 11.2749 5.214 11.1055 5.55279L5.10555 17.5528C4.85856 18.0468 5.05878 18.6474 5.55276 18.8944C6.04674 19.1414 6.64741 18.9412 6.8944 18.4472L8.64957 14.9369C8.75862 14.9777 8.87671 15 9 15H15C15.1233 15 15.2413 14.9777 15.3504 14.9369L17.1055 18.4472C17.3525 18.9412 17.9532 19.1414 18.4472 18.8944C18.9412 18.6474 19.1414 18.0468 18.8944 17.5528L12.8944 5.55279ZM14.3819 13L12 8.23607L9.61801 13H14.3819Z",fill:"currentColor"})}));vt.displayName="TextColorSmallIcon";const Sn="mod+shift+t",at=[{label:"Default text",value:"var(--tt-color-text)",border:"var(--tt-color-text-contrast)"},{label:"Gray text",value:"var(--tt-color-text-gray)",border:"var(--tt-color-text-gray-contrast)"},{label:"Brown text",value:"var(--tt-color-text-brown)",border:"var(--tt-color-text-brown-contrast)"},{label:"Orange text",value:"var(--tt-color-text-orange)",border:"var(--tt-color-text-orange-contrast)"},{label:"Yellow text",value:"var(--tt-color-text-yellow)",border:"var(--tt-color-text-yellow-contrast)"},{label:"Green text",value:"var(--tt-color-text-green)",border:"var(--tt-color-text-green-contrast)"},{label:"Blue text",value:"var(--tt-color-text-blue)",border:"var(--tt-color-text-blue-contrast)"},{label:"Purple text",value:"var(--tt-color-text-purple)",border:"var(--tt-color-text-purple-contrast)"},{label:"Pink text",value:"var(--tt-color-text-pink)",border:"var(--tt-color-text-pink-contrast)"},{label:"Red text",value:"var(--tt-color-text-red)",border:"var(--tt-color-text-red-contrast)"}];function mt(e){if(!e||!e.isEditable||!xe("textStyle",e)||re(e,["image"]))return!1;try{return e.can().setMark("textStyle",{color:"currentColor"})}catch{return!1}}function Lc(e,t){return!e||!e.isEditable?!1:e.isActive("textStyle",{color:t})}function Ac(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!xe("textStyle",t)?!1:t.isActive("code")?!0:mt(t):!0:!1}function el(e){const{editor:t,label:n,textColor:o,hideWhenUnavailable:l=!1,onApplied:s}=e,{editor:a}=S(t),i=ee(),[c,d]=u.useState(!0),f=mt(a),h=Lc(a,o);u.useEffect(()=>{if(!a)return;const C=()=>{d(Ac({editor:a,hideWhenUnavailable:l}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,l]);const p=u.useCallback(()=>{if(!a||!f)return!1;if(a.state.storedMarks){const C=a.schema.marks.textStyle;C&&a.view.dispatch(a.state.tr.removeStoredMark(C))}setTimeout(()=>{hi(a);const C=a.chain().focus().toggleMark("textStyle",{color:o}).run();return C&&s?.({color:o,label:n}),C},0)},[a,f,o,s,n]);return ie.useHotkeys(Sn,C=>{C.preventDefault(),p()},{enabled:c&&f,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:c,isActive:h,handleColorText:p,canColorText:f,label:n||`Color text to ${o}`,shortcutKeys:Sn,Icon:vt}}function Hc({shortcutKeys:e=Tn}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Ye=u.forwardRef(({editor:e,highlightColor:t,text:n,hideWhenUnavailable:o=!1,mode:l="mark",onApplied:s,showShortcut:a=!1,onClick:i,children:c,style:d,useColorValue:f=!1,...h},p)=>{const{editor:C}=S(e),{isVisible:b,canColorHighlight:g,isActive:w,handleColorHighlight:v,label:m,shortcutKeys:x}=xt({editor:C,highlightColor:t,useColorValue:f,label:n||`Toggle highlight (${t})`,hideWhenUnavailable:o,mode:l,onApplied:s}),y=u.useCallback(E=>{i?.(E),!E.defaultPrevented&&v()},[v,i]),T=u.useMemo(()=>({...d,"--highlight-color":t}),[t,d]);return b?r.jsx(k,{type:"button",variant:"ghost","data-active-state":w?"on":"off",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,"aria-pressed":w,tooltip:m,onClick:y,style:T,...h,ref:p,children:c??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t}}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),a&&r.jsx(Hc,{shortcutKeys:x})]})}):null});Ye.displayName="ColorHighlightButton";const yt=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));yt.displayName="HighlighterIcon";const Tn="mod+shift+h",Be=[{label:"Default background",value:"var(--tt-bg-color)",colorValue:"#ffffff",border:"var(--tt-bg-color-contrast)"},{label:"Gray background",value:"var(--tt-color-highlight-gray)",colorValue:"#f8f8f7",border:"var(--tt-color-highlight-gray-contrast)"},{label:"Brown background",value:"var(--tt-color-highlight-brown)",colorValue:"#f4eeee",border:"var(--tt-color-highlight-brown-contrast)"},{label:"Orange background",value:"var(--tt-color-highlight-orange)",colorValue:"#fbecdd",border:"var(--tt-color-highlight-orange-contrast)"},{label:"Yellow background",value:"var(--tt-color-highlight-yellow)",colorValue:"#fef9c3",border:"var(--tt-color-highlight-yellow-contrast)"},{label:"Green background",value:"var(--tt-color-highlight-green)",colorValue:"#dcfce7",border:"var(--tt-color-highlight-green-contrast)"},{label:"Blue background",value:"var(--tt-color-highlight-blue)",colorValue:"#e0f2fe",border:"var(--tt-color-highlight-blue-contrast)"},{label:"Purple background",value:"var(--tt-color-highlight-purple)",colorValue:"#f3e8ff",border:"var(--tt-color-highlight-purple-contrast)"},{label:"Pink background",value:"var(--tt-color-highlight-pink)",colorValue:"#fcf1f6",border:"var(--tt-color-highlight-pink-contrast)"},{label:"Red background",value:"var(--tt-color-highlight-red)",colorValue:"#ffe4e6",border:"var(--tt-color-highlight-red-contrast)"}];function tl(e){const t=new Map(Be.map(n=>[n.value,n]));return e.map(n=>t.get(n)).filter(n=>!!n)}function Nc(e,t=!1){return t&&Be.find(o=>o.value===e||o.colorValue===e)?.colorValue||e}function De(e,t="mark"){if(!e||!e.isEditable)return!1;if(t==="mark")return!xe("highlight",e)||re(e,["image"])?!1:e.can().setMark("highlight");if(!V(e,["nodeBackground"]))return!1;try{return e.can().toggleNodeBackgroundColor("test")}catch{return!1}}function Vc(e,t,n="mark"){if(!e||!e.isEditable)return!1;if(n==="mark")return t?e.isActive("highlight",{color:t}):e.isActive("highlight");if(!t)return!1;try{const{state:o}=e,{selection:l}=o,s=l.$anchor;for(let a=s.depth;a>=0;a--){const i=s.node(a);if(i&&i.attrs?.backgroundColor===t)return!0}return!1}catch{return!1}}function Bc(e,t="mark"){return!e||!e.isEditable||!De(e,t)?!1:t==="mark"?e.chain().focus().unsetMark("highlight").run():e.chain().focus().unsetNodeBackgroundColor().run()}function Dc(e){const{editor:t,hideWhenUnavailable:n,mode:o}=e;if(!t)return!1;if(!n)return!0;if(!t.isEditable)return!1;if(o==="mark"){if(!xe("highlight",t))return!1}else if(!V(t,["nodeBackground"]))return!1;return t.isActive("code")?!0:De(t,o)}function xt(e){const{editor:t,label:n,highlightColor:o,hideWhenUnavailable:l=!1,mode:s="mark",useColorValue:a=!1,onApplied:i}=e,{editor:c}=S(t),d=ee(),[f,h]=u.useState(!0),p=De(c,s),C=o&&Nc(o,a),b=Vc(c,C,s);u.useEffect(()=>{if(!c)return;const v=()=>{h(Dc({editor:c,hideWhenUnavailable:l,mode:s}))};return v(),c.on("selectionUpdate",v),()=>{c.off("selectionUpdate",v)}},[c,l,s]);const g=u.useCallback(()=>{if(!c||!p||!C||!n)return!1;if(s==="mark"){if(c.state.storedMarks){const v=c.schema.marks.highlight;v&&c.view.dispatch(c.state.tr.removeStoredMark(v))}return setTimeout(()=>{const v=c.chain().focus().toggleHighlight({color:C}).run();return v&&i?.({color:C,label:n,mode:s}),v},0),!0}else{const v=c.chain().focus().toggleNodeBackgroundColor(C).run();return v&&i?.({color:C,label:n,mode:s}),v}},[p,C,c,n,i,s]),w=u.useCallback(()=>{const v=Bc(c,s);return v&&i?.({color:"",label:"Remove highlight",mode:s}),v},[c,i,s]);return ie.useHotkeys(Tn,v=>{v.preventDefault(),g()},{enabled:f&&p,enableOnContentEditable:!d,enableOnFormTags:!0}),{isVisible:f,isActive:b,handleColorHighlight:g,handleRemoveHighlight:w,canColorHighlight:p,label:n||"Highlight",shortcutKeys:Tn,Icon:yt,mode:s}}function St({editor:e,containerRef:t,query:n,items:o,onSelect:l,onClose:s,orientation:a="vertical",autoSelectFirstItem:i=!0}){const[c,d]=u.useState(i?0:-1);return u.useEffect(()=>{const f=p=>{if(!o.length)return!1;const C=()=>d(g=>g===-1?0:(g+1)%o.length),b=()=>d(g=>g===-1?o.length-1:(g-1+o.length)%o.length);switch(p.key){case"ArrowUp":return a==="horizontal"?!1:(p.preventDefault(),b(),!0);case"ArrowDown":return a==="horizontal"?!1:(p.preventDefault(),C(),!0);case"ArrowLeft":return a==="vertical"?!1:(p.preventDefault(),b(),!0);case"ArrowRight":return a==="vertical"?!1:(p.preventDefault(),C(),!0);case"Tab":return p.preventDefault(),p.shiftKey?b():C(),!0;case"Home":return p.preventDefault(),d(0),!0;case"End":return p.preventDefault(),d(o.length-1),!0;case"Enter":return p.isComposing?!1:(p.preventDefault(),c!==-1&&o[c]&&l?.(o[c]),!0);case"Escape":return p.preventDefault(),s?.(),!0;default:return!1}};let h=null;if(e?h=e.view.dom:t?.current&&(h=t.current),h)return h.addEventListener("keydown",f,!0),()=>{h?.removeEventListener("keydown",f,!0)}},[e,t,o,c,l,s,a]),u.useEffect(()=>{n&&d(i?0:-1)},[n,i]),{selectedIndex:o.length?c:void 0,setSelectedIndex:d}}const In=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));In.displayName="ChevronDownIcon";function Tt({...e}){return r.jsx(pt.Root,{...e})}function It({...e}){return r.jsx(pt.Trigger,{...e})}function Mt({className:e,align:t="center",sideOffset:n=4,...o}){return r.jsx(pt.Portal,{children:r.jsx(pt.Content,{align:t,sideOffset:n,className:U("tiptap-popover",e),...o})})}const Ue=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card",e),...t}));Ue.displayName="Card";const Uc=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-header",e),...t}));Uc.displayName="CardHeader";const Oe=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-body",e),...t}));Oe.displayName="CardBody";const Ie=u.forwardRef(({className:e,orientation:t="vertical",...n},o)=>r.jsx("div",{ref:o,"data-orientation":t,className:U("tiptap-card-item-group",e),...n}));Ie.displayName="CardItemGroup";const it=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-group-label",e),...t}));it.displayName="CardGroupLabel";const Oc=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-footer",e),...t}));Oc.displayName="CardFooter";const Pc=Kt.cva("tiptap-button-group",{variants:{orientation:{horizontal:"tiptap-button-group-horizontal",vertical:"tiptap-button-group-vertical"}},defaultVariants:{orientation:"horizontal"}});function ce({className:e,orientation:t,...n}){return r.jsx("div",{role:"group","data-slot":"tiptap-button-group","data-orientation":t,className:U(Pc({orientation:t}),e),...n})}function Zc({colorObj:e,withLabel:t=!1,onColorChanged:n,editor:o,resolveColorValue:l,...s}){const a=e.type==="text"?at:Be,i=ol(e.value,a),c=i.label===i.value?e.label:i.label,d=l?.({type:e.type,label:c,value:e.value})??e.value,f={tooltip:c,text:t?c:void 0,onApplied:()=>n?.({type:e.type,label:c,value:i.value}),...s};return e.type==="text"?r.jsx(st,{textColor:d,label:c,editor:o,...f}):r.jsx(Ye,{highlightColor:d,label:c,editor:o,...f})}function nl({type:e,colors:t,onColorSelected:n,selectedIndex:o,startIndexOffset:l,editor:s,resolveColorValue:a}){return t.map((i,c)=>r.jsx(ce,{children:i.map((d,f)=>{const h=l+t.slice(0,c).reduce((g,w)=>g+w.length,0)+f,p=o===h,C=a?.({type:e,label:d.label,value:d.value})??d.value,b={tooltip:d.label,onApplied:()=>n({type:e,label:d.label,value:d.value}),tabIndex:p?0:-1,"data-highlighted":p,"aria-label":`${d.label} ${e==="text"?"text":"highlight"} color`};return e==="text"?r.jsx(ce,{children:r.jsx(st,{textColor:C,label:d.label,editor:s,...b})},`${e}-${d.value}-${f}`):r.jsx(ce,{children:r.jsx(Ye,{highlightColor:C,label:d.label,editor:s,...b})},`${e}-${d.value}-${f}`)})},`${e}-group-${c}`))}function Fc({recentColors:e,onColorSelected:t,selectedIndex:n,editor:o,resolveColorValue:l}){return e.length===0?null:r.jsxs(Ie,{children:[r.jsx(it,{children:"Recently used"}),r.jsx(ce,{children:e.map((s,a)=>r.jsx(ce,{children:r.jsx(Zc,{colorObj:s,onColorChanged:t,tabIndex:n===a?0:-1,"data-highlighted":n===a,editor:o,resolveColorValue:l})},`recent-${s.type}-${s.value}`))})]})}function $c({maxColorsPerGroup:e=5,maxRecentColors:t=3,onColorChanged:n,editor:o,resolveColorValue:l}){const{recentColors:s,addRecentColor:a,isInitialized:i}=ct(t),c=u.useRef(null),d=u.useMemo(()=>Go(at,e),[e]),f=u.useMemo(()=>Go(Be,e),[e]),h=u.useMemo(()=>d.flat(),[d]),p=u.useMemo(()=>f.flat(),[f]),C=u.useMemo(()=>i?s.length:0,[i,s.length]),b=u.useMemo(()=>C+h.length,[C,h.length]),g=u.useMemo(()=>{const m=[];return i&&s.length>0&&m.push(...s.map(x=>({type:x.type,value:x.value,label:`Recent ${x.type==="text"?"text":"highlight"} color`,group:"recent"}))),m.push(...h.map(x=>({type:"text",value:x.value,label:x.label,group:"text"}))),m.push(...p.map(x=>({type:"highlight",value:x.value,label:x.label,group:"highlight"}))),m},[i,s,h,p]),w=u.useCallback(({type:m,label:x,value:y})=>{if(!c.current)return!1;c.current.querySelector('[data-highlighted="true"]')?.click(),a({type:m,label:x,value:y}),n?.({type:m,label:x,value:y})},[a,n]),{selectedIndex:v}=St({containerRef:c,items:g,onSelect:m=>{m&&w({type:m.type,label:m.label,value:m.value})},orientation:"both",autoSelectFirstItem:!1});return r.jsx(Ue,{ref:c,tabIndex:0,role:"menu",children:r.jsxs(Oe,{children:[i&&r.jsx(Fc,{recentColors:s,onColorSelected:w,selectedIndex:v,editor:o,resolveColorValue:l}),r.jsxs(Ie,{children:[r.jsx(it,{children:"Text color"}),r.jsx(nl,{type:"text",colors:d,onColorSelected:w,selectedIndex:v,startIndexOffset:C,editor:o,resolveColorValue:l})]}),r.jsxs(Ie,{children:[r.jsx(it,{children:"Highlight color"}),r.jsx(nl,{type:"highlight",colors:f,onColorSelected:w,selectedIndex:v,startIndexOffset:b,editor:o,resolveColorValue:l})]})]})})}function zc({editor:e,hideWhenUnavailable:t=!1,onColorChanged:n,onClick:o,children:l,ref:s,resolveColorValue:a,...i}){const{editor:c}=S(e),[d,f]=u.useState(!1),{isVisible:h,canToggle:p,activeTextStyle:C,activeHighlight:b,handleColorChanged:g,label:w,Icon:v}=_c({editor:c,hideWhenUnavailable:t,onColorChanged:n}),m=u.useCallback(x=>{o?.(x),!x.defaultPrevented&&f(y=>!y)},[o]);return h?r.jsxs(Tt,{open:d,onOpenChange:f,children:[r.jsx(It,{asChild:!0,children:r.jsx(k,{type:"button",variant:"ghost","data-appearance":"default",role:"button","aria-label":w,tooltip:w,disabled:!p,"data-disabled":!p,onClick:m,ref:s,...i,children:l??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-color-text-popover",style:b.color?{"--active-highlight-color":b.color}:{},children:r.jsx(v,{className:"tiptap-button-icon",style:{color:C.color||void 0}})}),r.jsx(In,{className:"tiptap-button-dropdown-small"})]})})}),r.jsx(Mt,{"aria-label":"Text color options",side:"bottom",align:"start",collisionPadding:4,children:r.jsx($c,{onColorChanged:g,editor:c,resolveColorValue:a})})]}):null}function ol(e,t){return t.find(n=>n.value===e)??{value:e,label:e}}function Wc(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:mt(t)||De(t):!1:!0:!1}function ct(e=3){const[t,n]=u.useState([]),[o,l]=u.useState(!1);u.useEffect(()=>{try{const a=localStorage.getItem("tiptapRecentlyUsedColors");if(a){const i=JSON.parse(a);n(i.slice(0,e))}}catch(a){console.error("Failed to load stored colors:",a)}finally{l(!0)}},[e]);const s=u.useCallback(({type:a,label:i,value:c})=>{n(d=>{const f=d.filter(p=>!(p.type===a&&p.value===c)),h=[{type:a,label:i,value:c},...f].slice(0,e);try{localStorage.setItem("tiptapRecentlyUsedColors",JSON.stringify(h))}catch(p){console.error("Failed to store colors:",p)}return h})},[e]);return{recentColors:t,addRecentColor:s,isInitialized:o}}function _c(e){const{editor:t,hideWhenUnavailable:n=!1,onColorChanged:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),i=xe("textStyle",l),c=xe("highlight",l),d=Yo(l,"textStyle")||{},f=Yo(l,"highlight")||{},h=mt(l)||De(l);u.useEffect(()=>{if(!l)return;const C=()=>{a(Wc({editor:l,hideWhenUnavailable:n}))};return C(),l.on("selectionUpdate",C),()=>{l.off("selectionUpdate",C)}},[l,n,c,i]);const p=u.useCallback(({type:C,label:b,value:g})=>{o?.({type:C,label:b,value:g})},[o]);return{isVisible:s,canToggle:h,activeTextStyle:d,activeHighlight:f,handleColorChanged:p,label:"Text color",Icon:vt}}const Mn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 1.29289C5.31658 0.902369 4.68342 0.902369 4.29289 1.29289C3.90237 1.68342 3.90237 2.31658 4.29289 2.70711L7.08575 5.49997L1.69282 10.8929L1.68582 10.9C1.13614 11.4608 0.828247 12.2147 0.828247 13C0.828247 13.7853 1.1361 14.5392 1.68578 15.1L6.89285 20.3071C8.08338 21.4976 9.91654 21.4976 11.1071 20.3071L19.7071 11.7071C20.0976 11.3166 20.0976 10.6834 19.7071 10.2929L11.7071 2.29289C11.3165 1.90237 10.6834 1.90237 10.2929 2.29289L8.49997 4.08576L5.70711 1.29289ZM17.5857 11L16.5857 12H3.41418L8.49998 6.91419L9.29289 7.70711C9.68342 8.09763 10.3166 8.09763 10.7071 7.70711C11.0976 7.31658 11.0976 6.68342 10.7071 6.29289L9.91419 5.49998L11 4.41421L17.5857 11ZM14.5857 14H3.41418L8.30707 18.8929C8.71654 19.3024 9.28338 19.3024 9.69285 18.8929L14.5857 14Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.9829 15.8157C20.8942 15.3427 20.4812 15 20 15C19.5188 15 19.1058 15.3427 19.0171 15.8157C18.9233 16.3161 18.6226 16.706 18.1385 17.3337L18.0955 17.3895C17.6418 17.9781 17 18.8237 17 20C17 20.7957 17.3161 21.5587 17.8787 22.1213C18.4413 22.6839 19.2043 23 20 23C20.7957 23 21.5587 22.6839 22.1213 22.1213C22.6839 21.5587 23 20.7957 23 20C23 18.8237 22.3582 17.9781 21.9045 17.3895L21.8615 17.3337C21.3774 16.706 21.0767 16.3161 20.9829 15.8157ZM19 20C19 19.5763 19.2082 19.2219 19.6795 18.6105C19.714 18.5658 19.7503 18.5192 19.7881 18.4709C19.855 18.3851 19.9265 18.2935 20 18.1963C20.0735 18.2935 20.1449 18.385 20.2119 18.4708C20.2496 18.5192 20.286 18.5658 20.3205 18.6105C20.7918 19.2219 21 19.5763 21 20C21 20.2652 20.8946 20.5196 20.7071 20.7071C20.5196 20.8946 20.2652 21 20 21C19.7348 21 19.4804 20.8946 19.2929 20.7071C19.1054 20.5196 19 20.2652 19 20Z",fill:"currentColor"})]}));Mn.displayName="MoreVerticalIcon";const Xe=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.29289 5.29289C8.68342 4.90237 9.31658 4.90237 9.70711 5.29289L15.7071 11.2929C16.0976 11.6834 16.0976 12.3166 15.7071 12.7071L9.70711 18.7071C9.31658 19.0976 8.68342 19.0976 8.29289 18.7071C7.90237 18.3166 7.90237 17.6834 8.29289 17.2929L13.5858 12L8.29289 6.70711C7.90237 6.31658 7.90237 5.68342 8.29289 5.29289Z",fill:"currentColor"})}));Xe.displayName="ChevronRightIcon";const rl=({editor:e,color:t})=>{const{addRecentColor:n}=ct(),{isActive:o,handleColorText:l,label:s}=el({editor:e,label:t.label,textColor:t.value,onApplied:({color:a,label:i})=>n({type:"text",label:i,value:a})});return r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:l,children:[r.jsx("span",{className:"tiptap-button-color-text",style:{color:t.value},children:r.jsx(vt,{className:"tiptap-button-icon",style:{color:t.value,flexGrow:1}})}),r.jsx("span",{className:"tiptap-button-text",children:s})]})},ll=({editor:e,color:t})=>{const{addRecentColor:n}=ct(),{isActive:o,handleColorHighlight:l,label:s}=xt({editor:e,label:t.label,highlightColor:t.value,mode:"node",onApplied:({color:a,label:i})=>n({type:"highlight",label:i,value:a})});return r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:l,children:[r.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t.value}}),r.jsx("span",{className:"tiptap-button-text",children:s})]})},qc=({editor:e,colorObj:t})=>{const n=t.type==="text"?at:Be,o=ol(t.value,n),l=t.type==="text"?rl:ll;return r.jsx(l,{editor:e,color:o})},kn=({editor:e,trigger:t,label:n="Color",placement:o="right"})=>{const{editor:l}=S(e),{recentColors:s,isInitialized:a}=ct(),i=!!l?.can().setMark("textStyle")||!!l?.can().setMark("highlight")||De(l,"node")||!1;if(!l||!i)return null;const c=r.jsx(Te,{render:r.jsx(Ge,{render:r.jsxs(k,{variant:"ghost",children:[r.jsx(Mn,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:n}),r.jsx(lt,{}),r.jsx(Xe,{className:"tiptap-button-icon"})]})})});return r.jsx(qe,{placement:o,trigger:t||c,children:r.jsx(Ke,{portal:!0,children:r.jsxs(_e,{children:[a&&s.length>0&&r.jsxs(ae,{children:[r.jsx(nt,{children:"Recent colors"}),s.map(d=>r.jsx(qc,{editor:l,colorObj:d},d.value)),r.jsx(R,{orientation:"horizontal"})]}),r.jsxs(ae,{children:[r.jsx(nt,{children:"Text color"}),at.map(d=>r.jsx(rl,{editor:l,color:d},d.value))]}),r.jsx(R,{orientation:"horizontal"}),r.jsxs(ae,{children:[r.jsx(nt,{children:"Background color"}),Be.map(d=>r.jsx(ll,{editor:l,color:d},d.value))]})]})})})},Kc=u.forwardRef(({editor:e,alignmentType:t,alignment:n,index:o,orientation:l,hideWhenUnavailable:s=!1,onAligned:a,text:i,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,handleAlign:b,label:g,canAlignCell:w,Icon:v,isActive:m}=Pe({editor:p,alignmentType:t,alignment:n,index:o,orientation:l,hideWhenUnavailable:s,onAligned:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&b()},[b,c]);return C?r.jsx(k,{type:"button",disabled:!w,variant:"ghost","data-active-state":m?"on":"off","data-disabled":!w,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":m,tooltip:g,onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),i&&r.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});Kc.displayName="TableAlignCellButton";const En=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));En.displayName="AlignLeftIcon";const Ln=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));Ln.displayName="AlignCenterIcon";const An=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));An.displayName="AlignRightIcon";const Hn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Hn.displayName="AlignJustifyIcon";const Nn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M11 11.5858L9.70711 10.2929C9.31658 9.90237 8.68342 9.90237 8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929C15.3166 9.90237 14.6834 9.90237 14.2929 10.2929L13 11.5858V4C13 3.44771 12.5523 3 12 3C11.4477 3 11 3.44771 11 4V11.5858Z",fill:"currentColor"}),r.jsx("path",{d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Nn.displayName="AlignBottomIcon";const Vn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M2 4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4C22 4.55228 21.5523 5 21 5H3C2.44772 5 2 4.55228 2 4Z",fill:"currentColor"}),r.jsx("path",{d:"M13 10.4142L14.2929 11.7071C14.6834 12.0976 15.3166 12.0976 15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929L12.7071 7.29289C12.3166 6.90237 11.6834 6.90237 11.2929 7.29289L8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071C8.68342 12.0976 9.31658 12.0976 9.70711 11.7071L11 10.4142L11 20C11 20.5523 11.4477 21 12 21C12.5523 21 13 20.5523 13 20L13 10.4142Z",fill:"currentColor"})]}));Vn.displayName="AlignTopIcon";const sl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M3 12H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M12 22V16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M12 2L12 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M15 19L12 16L9 19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M9 5L12 8L15 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));sl.displayName="AlignMiddleIcon";const Bn=["table"],al={text:{left:"Align left",center:"Align center",right:"Align right",justify:"Justify"},vertical:{top:"Align top",middle:"Align middle",bottom:"Align bottom"}},il={text:{left:En,center:Ln,right:An,justify:Hn},vertical:{top:Vn,middle:sl,bottom:Nn}};function kt(e){if(!e||!e.isEditable||!V(e,Bn))return!1;try{return e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function Dn({editor:e,index:t,orientation:n}){if(!e||!e.isEditable||!V(e,Bn))return!1;try{return!(!J(e)||he(e,t,n).cells.length===0)}catch{return!1}}function Gc(e,t){if(!kt(e)||!e)return null;try{const{selection:n}=e.state,o=n.$anchor;let l=null;for(let a=o.depth;a>=0;a--){const i=o.node(a);if(i.type.name==="tableCell"||i.type.name==="tableHeader"){l=i;break}}if(!l)return null;const s=l.attrs||{};return t==="text"?s.nodeTextAlign||"left":s.nodeVerticalAlign||"top"}catch{return null}}function Yc(e,t,n,o){if(!e)return null;try{const l=he(e,n,o);if(l.cells.length===0)return null;const s=l.cells[0];if(!s?.node)return null;const a=s.node.attrs||{};return t==="text"?a.nodeTextAlign||"left":a.nodeVerticalAlign||"top"}catch{return null}}function Xc(e,t,n){if(!kt(e)||!e)return!1;try{return t==="text"?e.commands.setCellAttribute("nodeTextAlign",n):e.commands.setCellAttribute("nodeVerticalAlign",n)}catch(o){return console.error("Error setting table cell alignment:",o),!1}}function jc({editor:e,alignmentType:t,alignment:n,index:o,orientation:l}){if(!Dn({editor:e,index:o,orientation:l})||!e)return!1;try{const{state:s,view:a}=e,i=s.tr,c=he(e,o,l);if(c.cells.length===0)return!1;const d=new Map;if(c.cells.forEach(p=>{p.node&&p.pos!==void 0&&d.set(p.pos,p)}),d.size===0)return!1;const f=Array.from(d.values()).sort((p,C)=>C.pos-p.pos),h=t==="text"?"nodeTextAlign":"nodeVerticalAlign";return f.forEach(p=>{if(p.node&&p.pos!==void 0){const b=p.node.type.create({...p.node.attrs,[h]:n},p.node.content,p.node.marks),g=p.pos+p.node.nodeSize;i.replaceWith(p.pos,g,b)}}),i.docChanged?(a.dispatch(i),!0):!1}catch(s){return console.error(`Error aligning table ${l}:`,s),!1}}function Qc({editor:e,alignmentType:t,alignment:n,index:o,orientation:l}){if(!e)return!1;try{return typeof o=="number"&&l?jc({editor:e,alignmentType:t,alignment:n,index:o,orientation:l}):Xc(e,t,n)}catch(s){return console.error("Error aligning table cell:",s),!1}}function Jc({editor:e,hideWhenUnavailable:t,index:n,orientation:o}){return!e||!e.isEditable||!V(e,Bn)?!1:t?typeof n=="number"&&o?Dn({editor:e,index:n,orientation:o}):kt(e):!0}function Pe(e){const{editor:t,alignmentType:n,alignment:o,index:l,orientation:s,hideWhenUnavailable:a=!1,onAligned:i}=e,{editor:c}=S(t),d=Jc({editor:c,hideWhenUnavailable:a,index:l,orientation:s}),f=()=>typeof l=="number"&&s?Dn({editor:c,index:l,orientation:s}):kt(c),h=()=>typeof l=="number"&&s?Yc(c,n,l,s):Gc(c,n),p=h()===o,C=u.useCallback(()=>{const w=Qc({editor:c,alignmentType:n,alignment:o,index:l,orientation:s});return w&&i?.(o),w},[c,n,o,l,s,i]),b=u.useMemo(()=>n==="text"?al.text[o]:al.vertical[o],[n,o]),g=u.useMemo(()=>n==="text"?il.text[o]:il.vertical[o],[n,o]);return{isVisible:d,canAlignCell:f,handleAlign:C,label:b,Icon:g,isActive:p,currentAlignment:h}}const cl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M3 16C3.55228 16 4 16.4477 4 17V19L4.00488 19.0986C4.02757 19.3276 4.12883 19.5429 4.29297 19.707C4.48051 19.8946 4.73478 20 5 20H7C7.55228 20 8 20.4477 8 21C8 21.5523 7.55228 22 7 22H5C4.20435 22 3.44151 21.6837 2.87891 21.1211C2.3163 20.5585 2 19.7957 2 19V17C2 16.4477 2.44772 16 3 16Z",fill:"currentColor"}),r.jsx("path",{d:"M21 16C21.5523 16 22 16.4477 22 17V19C22 19.7957 21.6837 20.5585 21.1211 21.1211C20.5585 21.6837 19.7957 22 19 22H17C16.4477 22 16 21.5523 16 21C16 20.4477 16.4477 20 17 20H19C19.2652 20 19.5195 19.8946 19.707 19.707C19.8946 19.5195 20 19.2652 20 19V17C20 16.4477 20.4477 16 21 16Z",fill:"currentColor"}),r.jsx("path",{d:"M7 16C7.55228 16 8 16.4477 8 17C8 17.5523 7.55228 18 7 18C6.44772 18 6 17.5523 6 17C6 16.4477 6.44772 16 7 16Z",fill:"currentColor"}),r.jsx("path",{d:"M12 16C12.5523 16 13 16.4477 13 17C13 17.5523 12.5523 18 12 18C11.4477 18 11 17.5523 11 17C11 16.4477 11.4477 16 12 16Z",fill:"currentColor"}),r.jsx("path",{d:"M17 16C17.5523 16 18 16.4477 18 17C18 17.5523 17.5523 18 17 18C16.4477 18 16 17.5523 16 17C16 16.4477 16.4477 16 17 16Z",fill:"currentColor"}),r.jsx("path",{d:"M7 11C7.55228 11 8 11.4477 8 12C8 12.5523 7.55228 13 7 13C6.44772 13 6 12.5523 6 12C6 11.4477 6.44772 11 7 11Z",fill:"currentColor"}),r.jsx("path",{d:"M12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13C11.4477 13 11 12.5523 11 12C11 11.4477 11.4477 11 12 11Z",fill:"currentColor"}),r.jsx("path",{d:"M17 11C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13C16.4477 13 16 12.5523 16 12C16 11.4477 16.4477 11 17 11Z",fill:"currentColor"}),r.jsx("path",{d:"M7 2C7.55228 2 8 2.44772 8 3C8 3.55228 7.55228 4 7 4H5C4.73478 4 4.4805 4.10543 4.29297 4.29297C4.10543 4.4805 4 4.73478 4 5V7C4 7.55228 3.55228 8 3 8C2.44772 8 2 7.55228 2 7V5C2 4.20435 2.3163 3.44152 2.87891 2.87891C3.44152 2.3163 4.20435 2 5 2H7Z",fill:"currentColor"}),r.jsx("path",{d:"M7 6C7.55228 6 8 6.44772 8 7C8 7.55228 7.55228 8 7 8C6.44772 8 6 7.55228 6 7C6 6.44772 6.44772 6 7 6Z",fill:"currentColor"}),r.jsx("path",{d:"M12 6C12.5523 6 13 6.44772 13 7C13 7.55228 12.5523 8 12 8C11.4477 8 11 7.55228 11 7C11 6.44772 11.4477 6 12 6Z",fill:"currentColor"}),r.jsx("path",{d:"M17 6C17.5523 6 18 6.44772 18 7C18 7.55228 17.5523 8 17 8C16.4477 8 16 7.55228 16 7C16 6.44772 16.4477 6 17 6Z",fill:"currentColor"}),r.jsx("path",{d:"M19 2C19.7957 2 20.5585 2.3163 21.1211 2.87891C21.6837 3.44151 22 4.20435 22 5V7C22 7.55228 21.5523 8 21 8C20.4477 8 20 7.55228 20 7V5C20 4.73478 19.8946 4.48051 19.707 4.29297C19.5429 4.12883 19.3276 4.02757 19.0986 4.00488L19 4H17C16.4477 4 16 3.55228 16 3C16 2.44772 16.4477 2 17 2H19Z",fill:"currentColor"})]}));cl.displayName="AlignmentIcon";const Un=({index:e,orientation:t})=>{const n={left:Pe({alignmentType:"text",alignment:"left",index:e,orientation:t}),center:Pe({alignmentType:"text",alignment:"center",index:e,orientation:t}),right:Pe({alignmentType:"text",alignment:"right",index:e,orientation:t})},o={top:Pe({alignmentType:"vertical",alignment:"top",index:e,orientation:t}),middle:Pe({alignmentType:"vertical",alignment:"middle",index:e,orientation:t}),bottom:Pe({alignmentType:"vertical",alignment:"bottom",index:e,orientation:t})};return n.left.canAlignCell()?r.jsx(qe,{placement:"right",trigger:r.jsx(Ge,{render:r.jsx(Te,{render:r.jsxs(k,{variant:"ghost",children:[r.jsx(cl,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:"Alignment"}),r.jsx(U1,{render:r.jsx(Xe,{})})]})})}),children:r.jsx(Ke,{portal:!0,children:r.jsx(_e,{children:r.jsxs(ae,{children:[Object.values(n).map((l,s)=>r.jsx(On,{icon:l.Icon,label:l.label,disabled:!l.canAlignCell,isActive:l.isActive,onClick:l.handleAlign},`text-${s}`)),r.jsx(R,{orientation:"horizontal"}),Object.values(o).map((l,s)=>r.jsx(On,{icon:l.Icon,label:l.label,disabled:!l.canAlignCell,isActive:l.isActive,onClick:l.handleAlign},`vertical-${s}`))]})})})}):null},On=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:l=!1,shortcutBadge:s})=>r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:n,disabled:o,children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),s]});On.displayName="ActionItem";const Rc={row:"top-start",column:"bottom-start"},e2={row:"Row actions",column:"Column actions"},dl=u.createContext(null);function Et(){const e=u.useContext(dl);if(!e)throw new Error("useTableHandleContext must be used within TableHandleProvider");return e}function ul(e,t){const{editor:n,orientation:o,index:l,tableNode:s,tablePos:a}=Et(),[i,c]=u.useState(!1),[d,f]=u.useState(!1),h=u.useMemo(()=>Rc[o],[o]),p=u.useCallback(()=>{if(!(!n||!s||!K(a)||!K(l)))try{const{width:g,height:w}=I.TableMap.get(s),v=o==="row"?{row:l,col:0}:{row:0,col:l},m=o==="row"?{row:l,col:g-1}:{row:w-1,col:l};ve(n,a,[v,m],{mode:"dispatch",dispatch:n.view.dispatch.bind(n.view)})}catch(g){console.warn("Failed to select row/column:",g)}},[n,s,a,o,l]),C=u.useCallback(g=>{n&&(c(g),t?.(g),g?(n.commands.freezeHandles(),p(),e?.(!1)):(n.commands.unfreezeHandles(),e?.(!0)))},[n,t,e,p]),b=u.useCallback(()=>{n&&(c(!1),t?.(!1),n.commands.unfreezeHandles(),e?.(!0))},[n,t,e]);return{isMenuOpen:i,isDragging:d,setIsDragging:f,menuPlacement:h,handleMenuToggle:C,resetMenu:b}}function t2(){const{editor:e,index:t,orientation:n,tablePos:o}=Et(),l=jr({editor:e,index:t,orientation:n,tablePos:o}),s=Ar({editor:e,index:t,orientation:n,tablePos:o}),a=xn({editor:e,tablePos:o,index:t,orientation:n,direction:"asc",hideWhenUnavailable:!0}),i=xn({editor:e,tablePos:o,index:t,orientation:n,direction:"desc",hideWhenUnavailable:!0}),c=bt({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:!0,hideWhenUnavailable:!0}),d=zr({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0}),f=ot({editor:e,index:t,tablePos:o,orientation:"row",direction:"up",hideWhenUnavailable:!0}),h=ot({editor:e,index:t,tablePos:o,orientation:"row",direction:"down",hideWhenUnavailable:!0}),p=ot({editor:e,index:t,tablePos:o,orientation:"column",direction:"left",hideWhenUnavailable:!0}),C=ot({editor:e,index:t,tablePos:o,orientation:"column",direction:"right",hideWhenUnavailable:!0}),b=rt({editor:e,index:t,tablePos:o,orientation:"row",side:"above",hideWhenUnavailable:!0}),g=rt({editor:e,index:t,tablePos:o,orientation:"row",side:"below",hideWhenUnavailable:!0}),w=rt({editor:e,index:t,tablePos:o,orientation:"column",side:"left",hideWhenUnavailable:!0}),v=rt({editor:e,index:t,tablePos:o,orientation:"column",side:"right",hideWhenUnavailable:!0}),m=u.useMemo(()=>({moveUp:f,moveDown:h,moveLeft:p,moveRight:C}),[f,h,p,C]),x=u.useMemo(()=>({addAbove:b,addBelow:g,addLeft:w,addRight:v}),[b,g,w,v]),y=u.useMemo(()=>({sortAsc:a,sortDesc:i}),[a,i]),T=u.useCallback(()=>{const N=[];return y.sortAsc.isVisible&&N.push({icon:y.sortAsc.Icon,label:y.sortAsc.label,disabled:!y.sortAsc.canSortRowColumn,onClick:y.sortAsc.handleSort}),y.sortDesc.isVisible&&N.push({icon:y.sortDesc.Icon,label:y.sortDesc.label,disabled:!y.sortDesc.canSortRowColumn,onClick:y.sortDesc.handleSort}),N},[y]),E=u.useCallback(()=>{const N=[];return n==="row"?(x.addAbove.isVisible&&N.push({icon:x.addAbove.Icon,label:x.addAbove.label,disabled:!x.addAbove.canAddRowColumn,onClick:x.addAbove.handleAdd}),x.addBelow.isVisible&&N.push({icon:x.addBelow.Icon,label:x.addBelow.label,disabled:!x.addBelow.canAddRowColumn,onClick:x.addBelow.handleAdd})):(x.addLeft.isVisible&&N.push({icon:x.addLeft.Icon,label:x.addLeft.label,disabled:!x.addLeft.canAddRowColumn,onClick:x.addLeft.handleAdd}),x.addRight.isVisible&&N.push({icon:x.addRight.Icon,label:x.addRight.label,disabled:!x.addRight.canAddRowColumn,onClick:x.addRight.handleAdd})),N},[n,x]),L=u.useCallback(()=>{const N=[];return n==="row"?(m.moveUp.isVisible&&N.push({icon:m.moveUp.Icon,label:m.moveUp.label,disabled:!m.moveUp.canMoveRowColumn,onClick:m.moveUp.handleMove}),m.moveDown.isVisible&&N.push({icon:m.moveDown.Icon,label:m.moveDown.label,disabled:!m.moveDown.canMoveRowColumn,onClick:m.moveDown.handleMove})):(m.moveLeft.isVisible&&N.push({icon:m.moveLeft.Icon,label:m.moveLeft.label,disabled:!m.moveLeft.canMoveRowColumn,onClick:m.moveLeft.handleMove}),m.moveRight.isVisible&&N.push({icon:m.moveRight.Icon,label:m.moveRight.label,disabled:!m.moveRight.canMoveRowColumn,onClick:m.moveRight.handleMove})),N},[n,m]);return{deleteAction:l,duplicateAction:s,clearContentAction:c,headerAction:d,addItems:E(),moveItems:L(),sortItems:T()}}const Ze=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:l=!1,shortcutBadge:s})=>r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:n,disabled:o,children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),s]}),n2=()=>{const{index:e,orientation:t}=Et(),{deleteAction:n,duplicateAction:o,clearContentAction:l,headerAction:s,addItems:a,moveItems:i,sortItems:c}=t2(),d=n.isVisible||o.isVisible||l.isVisible,f=a.length>0,h=i.length>0,p=c.length>0,C=s.isVisible&&e===0;return!d&&!f&&!h&&!p&&!C?null:r.jsxs(r.Fragment,{children:[C&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:r.jsx(Ze,{icon:s.Icon,label:s.label,disabled:!s.canToggleHeader,isActive:s.isActive,onClick:s.handleToggle})}),r.jsx(R,{orientation:"horizontal"})]}),h&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:i.map((b,g)=>r.jsx(Ze,{...b},`move-${g}`))}),r.jsx(R,{orientation:"horizontal"})]}),f&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:a.map((b,g)=>r.jsx(Ze,{...b},`add-${g}`))}),r.jsx(R,{orientation:"horizontal"})]}),p&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:c.map((b,g)=>r.jsx(Ze,{...b},`sort-${g}`))}),r.jsx(R,{orientation:"horizontal"})]}),r.jsxs(r.Fragment,{children:[r.jsxs(ae,{children:[r.jsx(kn,{}),r.jsx(Un,{index:e,orientation:t}),l.isVisible&&r.jsx(Ze,{icon:l.Icon,label:l.label,disabled:!l.canClearRowColumnContent,onClick:l.handleClear})]}),r.jsx(R,{orientation:"horizontal"})]}),d&&r.jsxs(ae,{children:[o.isVisible&&r.jsx(Ze,{icon:o.Icon,label:o.label,disabled:!o.canDuplicateRowColumn,onClick:o.handleDuplicate}),n.isVisible&&r.jsx(Ze,{icon:n.Icon,label:n.label,disabled:!n.canDeleteRowColumn,onClick:n.handleDelete})]})]})},o2=()=>{const{resetMenu:e}=ul();return r.jsxs(Ke,{autoFocusOnShow:!0,autoFocusOnHide:!1,modal:!0,onClose:e,children:[r.jsx(dn,{style:Xt}),r.jsx(_e,{style:{minWidth:"15rem"},children:r.jsx(n2,{})})]})},fl=({editor:e,orientation:t,index:n,tableNode:o,tablePos:l,onToggleOtherHandle:s,onOpenChange:a,dragStart:i})=>{const{editor:c}=S(e),d=u.useMemo(()=>({editor:c,orientation:t,index:n,tableNode:o,tablePos:l}),[c,t,n,o,l]);return r.jsx(dl.Provider,{value:d,children:r.jsx(r2,{onToggleOtherHandle:s,onOpenChange:a,dragStart:i})})},r2=({onToggleOtherHandle:e,onOpenChange:t,dragStart:n})=>{const{orientation:o}=Et(),{isMenuOpen:l,isDragging:s,setIsDragging:a,menuPlacement:i,handleMenuToggle:c}=ul(e,t),d=e2[o],f=u.useCallback(p=>{a(!0),n?.(p)},[n,a]),h=u.useCallback(()=>{a(!1),y1()},[a]);return r.jsx(qe,{open:l,onOpenChange:c,placement:i,trigger:r.jsx(Ge,{className:U("tiptap-table-handle-menu",l&&"menu-opened",s&&"is-dragging",o),draggable:!0,"aria-label":d,"aria-haspopup":"menu","aria-expanded":l,onDragStart:f,onDragEnd:h,children:r.jsx(gt,{className:"tiptap-button-icon"})}),children:r.jsx(o2,{})})};function hl({editor:e,rowButton:t,columnButton:n}){const{editor:o}=S(e),l=cn({editor:o}),[s,a]=u.useState(!0),[i,c]=u.useState(!0),[d,f]=u.useState(null),h=u.useMemo(()=>{if(l?.draggingState)return{draggedCellOrientation:l.draggingState.draggedCellOrientation,mousePos:l.draggingState.mousePos,initialOffset:l.draggingState.initialOffset}},[l?.draggingState]),{rowHandle:p,colHandle:C}=L1(l?.show||!1,l?.referencePosCell||null,l?.referencePosTable||null,h),b=u.useCallback(L=>{a(L)},[]),g=u.useCallback(L=>{c(L)},[]),w=u.useCallback((L,N)=>{f(N?L:null)},[]);if(!o||!l)return null;const v=typeof l.rowIndex=="number",m=typeof l.colIndex=="number",x=s&&p.isMounted&&v||d==="row",y=i&&C.isMounted&&m||d==="column",T=t||fl,E=n||fl;return r.jsxs(D.FloatingPortal,{root:l.widgetContainer,children:[x&&r.jsx("div",{ref:p.ref,style:p.style,children:r.jsx(T,{editor:o,orientation:"row",index:l.rowIndex,tablePos:l.blockPos,tableNode:l.block,onToggleOtherHandle:g,dragStart:m1,onOpenChange:L=>w("row",L)})}),y&&r.jsx("div",{ref:C.ref,style:C.style,children:r.jsx(E,{editor:o,orientation:"column",index:l.colIndex,tablePos:l.blockPos,tableNode:l.block,onToggleOtherHandle:b,dragStart:v1,onOpenChange:L=>w("column",L)})})]})}hl.displayName="TableHandle";function l2(e,t){const n=u.useRef(null),o=u.useCallback(()=>{n.current!=null&&(cancelAnimationFrame(n.current),n.current=null)},[]),l=u.useCallback(()=>{if(n.current!=null)return;const s=()=>{const i=!!I.columnResizingPluginKey.getState(e.state)?.dragging;t(),i?n.current=requestAnimationFrame(s):(o(),t())};n.current=requestAnimationFrame(s)},[e,t,o]);u.useEffect(()=>{if(!e)return;const s=({transaction:a})=>{t();const i=a.getMeta(I.columnResizingPluginKey);i&&(Object.prototype.hasOwnProperty.call(i,"setDragging")&&i.setDragging&&l(),Object.prototype.hasOwnProperty.call(i,"setDragging")&&i.setDragging==null&&(o(),t()),Object.prototype.hasOwnProperty.call(i,"setHandle")&&t())};return e.on("transaction",s),()=>{e.off("transaction",s),o()}},[e,l,o,t])}const s2=5,a2=(e,t,n,o)=>{const l=t.posAtCoords({left:n,top:o})?.pos;if(l==null)return null;const s=e.doc.resolve(l);return I.cellAround(s)},i2=(e,t)=>{if(!(t instanceof I.CellSelection))return null;const n=[];if(t.forEachCell((l,s)=>{const a=e.nodeDOM(s);a&&n.push(a)}),n.length===0)return null;const o={left:1/0,top:1/0,right:-1/0,bottom:-1/0};return n.forEach(l=>{const s=l.getBoundingClientRect();o.left=Math.min(o.left,s.left),o.top=Math.min(o.top,s.top),o.right=Math.max(o.right,s.right),o.bottom=Math.max(o.bottom,s.bottom)}),new DOMRect(o.left,o.top,o.right-o.left,o.bottom-o.top)},c2=(e,t)=>{const n=e.nodeDOM(t);if(!n)return null;const o=n.getBoundingClientRect();return new DOMRect(o.left,o.top,o.width,o.height)},d2=e=>({getBoundingClientRect:()=>e}),u2=(e,t,n)=>{const o={topLeft:null,topRight:null,bottomLeft:null,bottomRight:null},l=(s,a)=>Math.abs(s-a)<s2;return t.forEachCell((s,a)=>{const i=e.nodeDOM(a);if(!i)return;const c=i.getBoundingClientRect();l(c.left,n.left)&&l(c.top,n.top)&&(o.topLeft=a),l(c.right,n.right)&&l(c.top,n.top)&&(o.topRight=a),l(c.left,n.left)&&l(c.bottom,n.bottom)&&(o.bottomLeft=a),l(c.right,n.right)&&l(c.bottom,n.bottom)&&(o.bottomRight=a)}),o},f2=(e,t,n,o)=>{if(!o)return null;const a=u2(e,t,n)[{tl:"bottomRight",tr:"bottomLeft",bl:"topRight",br:"topLeft"}[o]];return a?{pos:a}:null},h2=()=>({position:"absolute",width:15,height:15,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",pointerEvents:"auto",zIndex:10}),Lt=(e,t,n=!1)=>({...h2(),...{tl:{top:-7.5,left:-7.5,cursor:n?"default":"nwse-resize"},tr:{top:-7.5,right:-7.5,cursor:n?"default":"nesw-resize"},bl:{bottom:-7.5,left:-7.5,cursor:n?"default":"nesw-resize"},br:{bottom:-7.5,right:-7.5,cursor:n?"default":"nwse-resize"}}[e],opacity:n?.3:t?1:.5,pointerEvents:n?"none":"auto"}),p2=({editor:e,cellMenu:t,showResizeHandles:n=!0,onMenuOpenChange:o})=>{const{editor:l}=S(e),[s,a]=u.useState(!0),[i,c]=u.useState(null),[d,f]=u.useState(null),[h,p]=u.useState(null),[C,b]=u.useState(!1),g=u.useRef(null),w=u.useRef(null),v=u.useRef(null),{refs:m,floatingStyles:x,update:y}=D.useFloating({placement:"top-start"});u.useEffect(()=>{if(i){const O=d2(i);m.setPositionReference(O)}},[i,m]);const T=u.useCallback(()=>{if(!l)return;const{selection:O}=l.state;if(O instanceof I.CellSelection){const z=i2(l.view,O);if(!z){a(!1),c(oe=>oe&&null);return}c(oe=>br(oe,z)?oe:z),a(!0);return}const{$anchor:_}=O,$=I.cellAround(_);if($){const z=c2(l.view,$.pos);if(z){c(oe=>br(oe,z)?oe:z),a(!0);return}}a(!1),c(z=>z&&null)},[l]);l2(l,T),u.useEffect(()=>{y&&i&&y()},[y,i]);const E=u.useCallback(O=>_=>{if(!l||!O||!i||C||!n)return;_.preventDefault(),_.stopPropagation();const{selection:$}=l.state;let z=null;if($ instanceof I.CellSelection)z=$;else{const{$anchor:F}=$,q=I.cellAround(F);if(q)try{z=I.CellSelection.create(l.state.doc,q.pos,q.pos)}catch(ne){console.warn("Could not create single cell selection for resize:",ne);return}}if(!z)return;const oe=f2(l.view,z,i,O);if(!oe)return;f(O),w.current=O,g.current=oe.pos;const Z=F=>{if(!l||g.current==null)return;const q=ur(F.target);if(!q||q.type!=="cell")return;const ne=a2(l.state,l.view,F.clientX,F.clientY);if(ne)try{const pe=I.CellSelection.create(l.state.doc,g.current,ne.pos),B=l.state.tr.setSelection(pe);l.view.dispatch(B)}catch{return}},A=()=>{f(null),w.current=null,g.current=null,window.removeEventListener("mousemove",Z),window.removeEventListener("mouseup",A)};window.addEventListener("mousemove",Z),window.addEventListener("mouseup",A)},[l,i,C,n]),L=u.useCallback(()=>{if(!l){p(null);return}const O=J(l);if(!O){p(null);return}p(_=>{const $=_,z=l.view.nodeDOM(O.pos);return $===z?$:z})},[l]),N=u.useCallback(O=>{b(O),o?.(O)},[o]);if(u.useEffect(()=>{if(!l)return;const O=()=>{T(),L()};return l.on("selectionUpdate",O),T(),L(),()=>{l.off("selectionUpdate",O)}},[l,T,L]),u.useEffect(()=>{const O=h?.querySelector(".table-selection-overlay-container");v.current=O??null},[h]),!s||!i||!l)return null;const te=()=>t?r.jsx("span",{onMouseDown:O=>O.stopPropagation(),style:{pointerEvents:"auto"},children:r.jsx(t,{onOpenChange:N,editor:l,onResizeStart:E})}):null;return r.jsx(D.FloatingPortal,{root:v.current,children:r.jsx("div",{ref:m.setFloating,style:{...x,pointerEvents:"none",zIndex:10},children:r.jsxs("div",{className:"tiptap-table-selection-overlay",children:[r.jsx("div",{style:{position:"absolute",width:i.width,height:i.height,zIndex:2,borderRadius:2,top:0,left:0}}),r.jsxs("div",{style:{position:"absolute",width:i.width,height:i.height,border:"2px solid var(--tt-brand-color-400)",borderRadius:2,zIndex:3,top:0,left:0},children:[te(),n&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:Lt("tl",!d||d==="tl",C),onMouseDown:E("tl")}),r.jsx("div",{style:Lt("tr",!d||d==="tr",C),onMouseDown:E("tr")}),r.jsx("div",{style:Lt("bl",!d||d==="bl",C),onMouseDown:E("bl")}),r.jsx("div",{style:Lt("br",!d||d==="br",C),onMouseDown:E("br")})]})]})]})})})},C2=u.forwardRef(({editor:e,action:t,hideWhenUnavailable:n=!1,onExecuted:o,text:l,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,handleExecute:h,label:p,canExecute:C,Icon:b}=$n({editor:d,action:t,hideWhenUnavailable:n,onExecuted:o}),g=u.useCallback(w=>{s?.(w),!w.defaultPrevented&&h()},[h,s]);return f?r.jsx(k,{type:"button",disabled:!C,variant:"ghost","data-active-state":"off","data-disabled":!C,role:"button",tabIndex:-1,"aria-label":p,"aria-pressed":!1,tooltip:p,onClick:g,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),l&&r.jsx("span",{className:"tiptap-button-text",children:l})]})}):null});C2.displayName="TableMergeSplitCellButton";const pl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M10 16C10.5177 16 10.9438 16.3933 10.9951 16.8975L11 17V19C11 20.6569 9.65685 22 8 22H4C2.34315 22 1 20.6569 1 19V17C1 16.4477 1.44772 16 2 16C2.55228 16 3 16.4477 3 17V19C3 19.5523 3.44772 20 4 20H8C8.55228 20 9 19.5523 9 19V17L9.00488 16.8975C9.05621 16.3933 9.48232 16 10 16Z",fill:"currentColor"}),r.jsx("path",{d:"M22 16C22.5177 16 22.9438 16.3933 22.9951 16.8975L23 17V19C23 20.6569 21.6569 22 20 22H16C14.3431 22 13 20.6569 13 19V17C13 16.4477 13.4477 16 14 16C14.5523 16 15 16.4477 15 17V19C15 19.5523 15.4477 20 16 20H20C20.5523 20 21 19.5523 21 19V17L21.0049 16.8975C21.0562 16.3933 21.4823 16 22 16Z",fill:"currentColor"}),r.jsx("path",{d:"M5.29297 8.29297C5.68349 7.90244 6.31651 7.90244 6.70703 8.29297L9.70703 11.293L9.77539 11.3691C10.0957 11.7619 10.0731 12.3409 9.70703 12.707L6.70703 15.707C6.31651 16.0975 5.68349 16.0975 5.29297 15.707C4.90245 15.3165 4.90245 14.6835 5.29297 14.293L6.58594 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6.58594L5.29297 9.70703C4.90245 9.31651 4.90245 8.68349 5.29297 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M17.293 8.29297C17.6835 7.90245 18.3165 7.90246 18.707 8.29297C19.0976 8.68349 19.0976 9.31651 18.707 9.70703L17.4141 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H17.4141L18.707 14.293C19.0976 14.6835 19.0976 15.3165 18.707 15.707C18.3165 16.0976 17.6835 16.0976 17.293 15.707L14.293 12.707L14.2246 12.6309C13.9043 12.2381 13.9269 11.6591 14.293 11.293L17.293 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M8 2C9.65685 2 11 3.34315 11 5V7C11 7.55228 10.5523 8 10 8C9.44771 8 9 7.55228 9 7V5C9 4.44772 8.55228 4 8 4H4C3.44772 4 3 4.44772 3 5V7C3 7.55228 2.55228 8 2 8C1.44772 8 1 7.55228 1 7V5C1 3.34315 2.34315 2 4 2H8Z",fill:"currentColor"}),r.jsx("path",{d:"M20 2C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5C13 3.34315 14.3431 2 16 2H20Z",fill:"currentColor"})]}));pl.displayName="TableCellMergeIcon";const Cl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 2C2.34315 2 1 3.34315 1 5V7C1 7.55228 1.44772 8 2 8C2.55228 8 3 7.55228 3 7V5C3 4.44772 3.44772 4 4 4H8C8.55228 4 9 4.44772 9 5V7C9 7.55228 9.44772 8 10 8C10.5523 8 11 7.55228 11 7V5C11 3.34315 9.65685 2 8 2H4Z",fill:"currentColor"}),r.jsx("path",{d:"M20 22C21.6569 22 23 20.6569 23 19V17C23 16.4477 22.5523 16 22 16C21.4477 16 21 16.4477 21 17V19C21 19.5523 20.5523 20 20 20H16C15.4477 20 15 19.5523 15 19V17C15 16.4477 14.5523 16 14 16C13.4477 16 13 16.4477 13 17V19C13 20.6569 14.3431 22 16 22H20Z",fill:"currentColor"}),r.jsx("path",{d:"M13 5C13 3.34315 14.3431 2 16 2H20C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5Z",fill:"currentColor"}),r.jsx("path",{d:"M8 22C9.65685 22 11 20.6569 11 19V17C11 16.4477 10.5523 16 10 16C9.44772 16 9 16.4477 9 17V19C9 19.5523 8.55229 20 8 20H4C3.44772 20 3 19.5523 3 19L3 17C3 16.4477 2.55229 16 2 16C1.44772 16 1 16.4477 1 17V19C1 20.6569 2.34315 22 4 22H8Z",fill:"currentColor"}),r.jsx("path",{d:"M18.7071 15.7071L21.7061 12.7081C21.8877 12.527 22 12.2766 22 12L22 11.997C21.9992 11.7421 21.9016 11.4874 21.7071 11.2929L18.7071 8.29289C18.3166 7.90237 17.6834 7.90237 17.2929 8.29289C16.9024 8.68342 16.9024 9.31658 17.2929 9.70711L18.5858 11H15C14.4477 11 14 11.4477 14 12C14 12.5523 14.4477 13 15 13H18.5858L17.2929 14.2929C16.9024 14.6834 16.9024 15.3166 17.2929 15.7071C17.6834 16.0976 18.3166 16.0976 18.7071 15.7071Z",fill:"currentColor"}),r.jsx("path",{d:"M2.07588 11.6172C2.02699 11.7351 2 11.8644 2 12C2 12.2728 2.10925 12.5201 2.2864 12.7005C2.28879 12.703 2.2912 12.7054 2.29362 12.7078L5.29289 15.7071C5.68342 16.0976 6.31658 16.0976 6.70711 15.7071C7.09763 15.3166 7.09763 14.6834 6.70711 14.2929L5.41421 13L9 13C9.55228 13 10 12.5523 10 12C10 11.4477 9.55229 11 9 11L5.41421 11L6.70711 9.70711C7.09763 9.31658 7.09763 8.68342 6.70711 8.29289C6.31658 7.90237 5.68342 7.90237 5.29289 8.29289L2.29366 11.2921C2.29122 11.2946 2.2888 11.297 2.2864 11.2995C2.19374 11.3938 2.12357 11.502 2.07588 11.6172Z",fill:"currentColor"})]}));Cl.displayName="TableCellSplitIcon";const Pn=["table"],g2={merge:"Merge cells",split:"Split cell"},b2={merge:pl,split:Cl};function Zn(e){if(!e||!e.isEditable||!V(e,Pn))return!1;try{return I.mergeCells(e.state,void 0)}catch{return!1}}function Fn(e){if(!e||!e.isEditable||!V(e,Pn))return!1;try{return I.splitCell(e.state,void 0)}catch{return!1}}function w2(e){if(!Zn(e)||!e)return!1;try{const{state:t,view:n}=e;return I.mergeCells(t,n.dispatch.bind(n))}catch(t){return console.error("Error merging table cells:",t),!1}}function v2(e){if(!Fn(e)||!e)return!1;try{const{state:t,view:n}=e;return I.splitCell(t,n.dispatch.bind(n))}catch(t){return console.error("Error splitting table cell:",t),!1}}function m2({editor:e,action:t}){if(!e)return!1;try{return t==="merge"?w2(e):v2(e)}catch(n){return console.error(`Error ${t}ing table cell:`,n),!1}}function y2({editor:e,action:t,hideWhenUnavailable:n}){return!e||!e.isEditable||!V(e,Pn)?!1:n?t==="merge"?Zn(e):Fn(e):!0}function $n(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:l}=e,{editor:s}=S(t),a=y2({editor:s,action:n,hideWhenUnavailable:o}),i=n==="merge"?Zn(s):Fn(s),c=u.useCallback(()=>{const d=m2({editor:s,action:n});return d&&l?.(n),d},[s,n,l]);return{isVisible:a,canExecute:i,handleExecute:c,label:g2[n],Icon:b2[n]}}const gl=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M8 14C9.10457 14 10 14.8954 10 16C10 17.1046 9.10457 18 8 18C6.89543 18 6 17.1046 6 16C6 14.8954 6.89543 14 8 14ZM16 14C17.1046 14 18 14.8954 18 16C18 17.1046 17.1046 18 16 18C14.8954 18 14 17.1046 14 16C14 14.8954 14.8954 14 16 14ZM8 6C9.10457 6 10 6.89543 10 8C10 9.10457 9.10457 10 8 10C6.89543 10 6 9.10457 6 8C6 6.89543 6.89543 6 8 6ZM16 6C17.1046 6 18 6.89543 18 8C18 9.10457 17.1046 10 16 10C14.8954 10 14 9.10457 14 8C14 6.89543 14.8954 6 16 6Z",fill:"currentColor"})}));gl.displayName="Grip4Icon";function x2(){const e=$n({action:"merge"}),t=$n({action:"split"}),n=bt({resetAttrs:!0}),o={icon:e.Icon,label:e.label,onClick:e.handleExecute,isAvailable:e.canExecute},l={icon:t.Icon,label:t.label,onClick:t.handleExecute,isAvailable:t.canExecute},s={icon:n.Icon,label:n.label,onClick:n.handleClear,isAvailable:n.canClearRowColumnContent};return{mergeAction:o,splitAction:l,clearAction:s}}function S2({editor:e}){const[t,n]=u.useState(!1),o=u.useCallback(()=>{n(!1),e?.commands.unfreezeHandles()},[e]),l=u.useCallback(s=>{n(s),e&&(s?e.commands.freezeHandles():e.commands.unfreezeHandles())},[e]);return{isMenuOpen:t,handleMenuToggle:l,closeMenu:o}}const zn=({action:e})=>{const{icon:t,label:n,onClick:o,isActive:l=!1,shortcutBadge:s}=e;return r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:o,children:[r.jsx(t,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:n}),s]})},T2=({onClose:e})=>{const{mergeAction:t,splitAction:n,clearAction:o}=x2(),l=t.isAvailable||n.isAvailable;return r.jsxs(Ke,{autoFocusOnShow:!0,modal:!0,onClose:e,children:[r.jsx(dn,{style:Xt}),r.jsxs(_e,{style:{minWidth:"15rem"},children:[l&&r.jsxs(ae,{children:[t.isAvailable&&r.jsx(zn,{action:t}),n.isAvailable&&r.jsx(zn,{action:n}),r.jsx(R,{orientation:"horizontal"})]}),r.jsxs(ae,{children:[r.jsx(kn,{}),r.jsx(Un,{}),o.isAvailable&&r.jsx(zn,{action:o})]})]})]})},bl=u.forwardRef(({editor:e,onOpenChange:t,className:n,...o},l)=>{const{editor:s}=S(e),{isMenuOpen:a,handleMenuToggle:i,closeMenu:c}=S2({editor:s});return u.useEffect(()=>{t?.(a)},[a,t]),r.jsx(qe,{open:a,onOpenChange:i,placement:"bottom-start",trigger:r.jsx(Ge,{ref:l,className:U("expandable-menu-button",a&&"menu-opened",n),"aria-label":"Table cells option","aria-haspopup":"menu","aria-expanded":a,...o,children:r.jsx(gl,{className:"tiptap-button-icon"})}),children:r.jsx(T2,{onClose:c})})});bl.displayName="TableCellHandleMenu";const wl=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M13.5 8C13.5 7.17157 12.8284 6.5 12 6.5C11.1716 6.5 10.5 7.17157 10.5 8V10.5H8C7.17157 10.5 6.5 11.1716 6.5 12C6.5 12.8284 7.17157 13.5 8 13.5H10.5V16C10.5 16.8284 11.1716 17.5 12 17.5C12.8284 17.5 13.5 16.8284 13.5 16V13.5H16C16.8284 13.5 17.5 12.8284 17.5 12C17.5 11.1716 16.8284 10.5 16 10.5H13.5V8Z",fill:"currentColor"})}));wl.displayName="PlusSmallIcon";const I2={row:{placement:"bottom",sizeProperty:"width"},column:{placement:"right",sizeProperty:"height"}};function vl(e,t,n){const o=I2[e],{refs:l,update:s,context:a,floatingStyles:i}=D.useFloating({open:t,placement:o.placement,middleware:[D.offset(4),D.size({apply({rects:h,elements:p}){const C=p.floating;if(!C)return;const b=`${h.reference[o.sizeProperty]}px`;C.style[o.sizeProperty]=b}})]}),{isMounted:c,styles:d}=D.useTransitionStyles(a),f=u.useCallback(h=>({getBoundingClientRect:()=>h}),[]);return u.useEffect(()=>{n&&(l.setReference(f(n)),s())},[n,l,s,f]),u.useMemo(()=>({isMounted:c,ref:l.setFloating,style:{display:"flex",...d,...i}}),[i,c,l.setFloating,d])}function M2(e,t,n){const o=vl("row",t,n),l=vl("column",e,n);return u.useMemo(()=>({rowButton:o,columnButton:l}),[o,l])}const ml=({editor:e,onMouseDown:t,onMouseUp:n,orientation:o,children:l})=>{const{editor:s}=S(e),a=cn({editor:s}),i=o==="row",c=u.useRef(!1),[d,f]=u.useState(null),h=u.useCallback(C=>{if(!a)return;const b=I.TableMap.get(a.block);c.current=!1,f({startPos:i?C.clientY:C.clientX,originalHeight:b.height,originalWidth:b.width}),t(),C.preventDefault()},[a,i,t]),p=u.useCallback(()=>{c.current||!s||!a||rn(s,()=>{sn(s,a.block,a.blockPos,o),i?s.commands.addRowAfter():s.commands.addColumnAfter()})},[s,i,o,a]);return u.useEffect(()=>{if(!d||!s||!a)return;const C=g=>{c.current=!0;const v=(i?g.clientY:g.clientX)-d.startPos,m=i?Xi:tt,x=I.TableMap.get(a.block),y=i?x.height:x.width,T=i?d.originalHeight:d.originalWidth,L=Math.max(1,T+n1(v/m,.3))-y;L!==0&&(L>0?rn(s,()=>{sn(s,a.block,a.blockPos,o);for(let N=0;N<L;N++)i?s.commands.addRowAfter():s.commands.addColumnAfter()}):rn(s,()=>{const N=Math.abs(L),te=i?e1(s,a.blockPos):t1(s,a.blockPos),O=Math.min(N,te,y-1);sn(s,a.block,a.blockPos,o);for(let _=0;_<O;_++)i?s.commands.deleteRow():s.commands.deleteColumn()}))},b=()=>{f(null),n()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",b)}},[d,s,i,o,n,a]),s?.isEditable?r.jsx("button",{className:U("tiptap-table-extend-row-column-button",i?"tiptap-table-row-end-add-remove":"tiptap-table-column-end-add-remove",d&&"editing"),onClick:p,onMouseDown:h,type:"button","aria-label":i?"Add or remove rows":"Add or remove columns",children:l??r.jsx(wl,{className:"tiptap-button-icon"})}):null},k2=({editor:e,onMouseDown:t,onMouseUp:n})=>{const{editor:o}=S(e),l=cn({editor:o}),{columnButton:s,rowButton:a}=M2(l?.showAddOrRemoveColumnsButton??!1,l?.showAddOrRemoveRowsButton??!1,l?.referencePosTable??null),i=u.useCallback(()=>{o&&(o.commands.freezeHandles(),t?.())},[o,t]),c=u.useCallback(()=>{o&&(o.commands.unfreezeHandles(),n?.())},[o,n]);return l?r.jsxs(D.FloatingPortal,{root:l.widgetContainer,children:[r.jsx("div",{ref:a.ref,style:a.style,children:r.jsx(ml,{editor:o,orientation:"row",block:l.block,onMouseDown:i,onMouseUp:c})}),r.jsx("div",{ref:s.ref,style:s.style,children:r.jsx(ml,{editor:o,orientation:"column",block:l.block,onMouseDown:i,onMouseUp:c})})]}):null};function yl(e,t,n,o,l){const{dismissOptions:s,...a}=o||{},{refs:i,context:c,floatingStyles:d}=D.useFloating({open:e,whileElementsMounted(g,w,v){return D.autoUpdate(g,w,v,l)},...a}),{isMounted:f,styles:h}=D.useTransitionStyles(c),p=D.useDismiss(c,s),{getReferenceProps:C,getFloatingProps:b}=D.useInteractions([p]);return u.useEffect(()=>{if(t===null){i.setReference(null);return}if(t instanceof HTMLElement){i.setReference(t);return}const g=()=>(typeof t=="function"?t():t)||new DOMRect;i.setReference({getBoundingClientRect:g})},[t,i]),u.useMemo(()=>({isMounted:f,ref:i.setFloating,style:{...h,...d,zIndex:n},getFloatingProps:b,getReferenceProps:C}),[d,f,i.setFloating,h,n,b,C])}function E2(e,t,n){if(!t?.text||!n)return e;const o=t.text,l=o.lastIndexOf(n);if(l===-1)return e;const s=o.substring(l).length;return e-s}function L2(e,t){const n=t.trim().toLowerCase();return n?e.filter(o=>!!(o.title.toLowerCase().includes(n)||o.subtext?.toLowerCase().includes(n)||o.keywords?.some(l=>l.toLowerCase().includes(n)))).sort((o,l)=>{const s=o.title.toLowerCase(),a=l.title.toLowerCase();return s===n&&a!==n?-1:a===n&&s!==n?1:s.startsWith(n)&&!a.startsWith(n)?-1:a.startsWith(n)&&!s.startsWith(n)?1:0}):e}const Wn=({editor:e,floatingOptions:t,selector:n="tiptap-suggestion-menu",children:o,maxHeight:l=384,pluginKey:s=qo.SuggestionPluginKey,...a})=>{const{editor:i}=S(e),[c,d]=u.useState(!1),[f,h]=u.useState(null),[p,C]=u.useState(null),[b,g]=u.useState([]),[w,v]=u.useState(""),[,m]=u.useState(null),{ref:x,style:y,getFloatingProps:T,isMounted:E}=yl(c,f,1e3,{placement:"bottom-start",middleware:[D.offset(10),D.flip({mainAxis:!0,crossAxis:!1}),D.shift(),D.size({apply({availableHeight:_,elements:$}){if($.floating){const z=l?Math.min(l,_):_;$.floating.style.setProperty("--suggestion-menu-max-height",`${z}px`)}}})],onOpenChange(_){_||d(!1)},...t}),L=u.useRef(a);u.useEffect(()=>{L.current=a},[a]);const N=u.useCallback(()=>{d(!1)},[]);u.useEffect(()=>{if(!i||i.isDestroyed)return;i.state.plugins.find(A=>A.spec.key===s)&&i.unregisterPlugin(s);const $=L.current.char??"@",z=i.extensionManager.extensions.find(A=>{if(A.name!=="mention")return!1;const F=A.options?.suggestions;return F?.length?F.some(q=>(q.char??"@")===$):(A.options?.suggestion?.char??"@")===$}),oe={};if(z){let A=null;const F=z.options?.suggestions;if(F?.length?A=F.find(q=>(q.char??"@")===$):z.options?.suggestion&&(A=z.options.suggestion),A){const q=new Set(["pluginKey","editor","render","command","items","allow","char"]);for(const ne of Object.keys(A))q.has(ne)||(oe[ne]=A[ne])}}const Z=qo.Suggestion({...oe,pluginKey:s instanceof M.PluginKey?s:new M.PluginKey(s),editor:i,allow(A){const F=i.state.doc.resolve(A.range.from);for(let q=F.depth;q>0;q--)if(F.node(q).type.name==="image")return!1;return!0},command({editor:A,range:F,props:q}){if(!F)return;const{view:ne,state:pe}=A,{selection:B}=pe;if(!A.extensionManager.extensions.some(ye=>{if(ye.name!=="mention")return!1;const Le=ye.options?.suggestions;return Le?.length?Le.some(je=>(je.char??"@")===L.current.char):(ye.options?.suggestion?.char??"@")===L.current.char})){const ye=B.$from.pos,Le=B.$head?.nodeBefore,je=Le?E2(ye,Le,L.current.char):B.$from.start(),i4=pe.tr.deleteRange(je,ye);ne.dispatch(i4)}const Ee={...F};ne.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(Ee.to+=1),q.onSelect({editor:A,range:Ee,context:q.context})},render:()=>({onStart:A=>{h(A.decorationNode??null),C(()=>A.command),g(A.items),v(A.query),m(A.range),d(!0)},onUpdate:A=>{h(A.decorationNode??null),C(()=>A.command),g(A.items),v(A.query),m(A.range)},onKeyDown:A=>A.event.key==="Escape"?(N(),!0):!1,onExit:()=>{h(null),C(null),g([]),v(""),m(null),d(!1)}}),...L.current});return i.registerPlugin(Z),()=>{i.isDestroyed||i.unregisterPlugin(s)}},[i,s,N]);const te=u.useCallback(_=>{N(),p&&p(_)},[N,p]),{selectedIndex:O}=St({editor:i,query:w,items:b,onSelect:te});return!E||!c||!i?null:r.jsx("div",{ref:x,style:y,...T(),"data-selector":n,className:"tiptap-suggestion-menu",role:"listbox","aria-label":"Suggestions",onPointerDown:_=>_.preventDefault(),children:o({items:b,selectedIndex:O,onSelect:te})})},xl={paragraph:"Text",heading:"Heading",blockquote:"Blockquote",listItem:"List Item",codeBlock:"Code Block",table:"Table",tocNode:"Table of contents"},Sl=e=>{if(!e)return"Node";const{selection:t}=e.state;if(t instanceof M.NodeSelection){const l=t.node.type.name;return xl[l]||l.toLowerCase()}if(t instanceof I.CellSelection)return"Table";const{$anchor:n}=t,o=n.parent.type.name;return xl[o]||o.toLowerCase()};function _n(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),l=n.top<o.top,s=n.bottom>o.bottom;return l&&s?"both":l?"top":s?"bottom":"none"}const Tl=(e,t,n=["imageUpload","horizontalRule"])=>{if(!e)return!1;t||(t=e.state.selection);const{state:o}=e,{doc:l}=o,{empty:s,from:a,to:i}=t,c=!l.textBetween(a,i).length&&P.isTextSelection(t),d=t.$from.parent.type.spec.code||P.isNodeSelection(t)&&t.node.type.spec.code,f=P.isNodeSelection(t)&&n.includes(t.node.type.name),h=t instanceof I.CellSelection;return!s&&!c&&!d&&!f&&!h},A2=e=>{if(!e)return!1;const{state:t}=e,{selection:n}=t;return P.isTextSelection(n)&&!n.empty&&!n.$from.parent.type.spec.code&&!P.isNodeSelection(n)},H2=e=>{const{state:t}=e.view,{selection:n}=t,{ranges:o}=n,l=Math.min(...o.map(a=>a.$from.pos)),s=Math.max(...o.map(a=>a.$to.pos));if(P.isNodeSelection(n)){const a=e.view.nodeDOM(l);if(a)return a.getBoundingClientRect()}return P.posToDOMRect(e.view,l,s)},Il=100,N2=(e,t)=>e.name.localeCompare(t.name),V2=(e,t)=>{const n=e.toLowerCase().trim();return t.name.toLowerCase().includes(n)||t.shortcodes.some(o=>o.toLowerCase().includes(n))||t.tags.some(o=>o.toLowerCase().includes(n))},B2=e=>{const{query:t,emojis:n}=e,o=t.trim();return(o?n.filter(s=>V2(o,s)).slice(0,Il):n.slice(0,Il)).sort(N2)},D2=e=>{const{emoji:t,isSelected:n,onSelect:o,selector:l}=e,s=u.useRef(null);return u.useEffect(()=>{const a=document.querySelector(l);if(!s.current||!n||!a)return;const i=_n(s.current,a);i==="top"?s.current.scrollIntoView(!0):i==="bottom"&&s.current.scrollIntoView(!1)},[n,l]),t?r.jsxs(k,{ref:s,variant:"ghost","data-active-state":n?"on":"off",onClick:()=>o(t),children:[t.fallbackImage?r.jsx("img",{className:"tiptap-button-emoji",src:t.fallbackImage,alt:t.name}):r.jsx("span",{className:"tiptap-button-emoji",children:t.emoji}),r.jsxs("span",{className:"tiptap-button-text",children:[":",t.name,":"]})]}):null},U2=e=>r.jsx(Wn,{char:":",pluginKey:"emojiDropdownMenu",decorationClass:"tiptap-emoji-decoration",selector:"tiptap-emoji-dropdown-menu",items:O2,...e,children:t=>r.jsx(P2,{...t})}),O2=async e=>{const t=e.editor.extensionStorage.emoji.emojis||[];return B2({query:e.query,emojis:t}).map(o=>({title:o.name,subtext:o.shortcodes.join(", "),context:o,onSelect:l=>{!l.editor||!l.range||!l.context||l.editor.chain().focus().setEmoji(l.context.name).run()}}))},P2=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const l=[];return e.forEach((s,a)=>{s.context&&l.push(r.jsx(D2,{emoji:s.context,index:a,isSelected:a===t,onSelect:()=>n(s),selector:"[data-selector='tiptap-emoji-dropdown-menu']"},s.title))}),l},[e,t,n]);return o.length?r.jsx(Ue,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:r.jsx(Oe,{children:r.jsx(Ie,{children:o})})}):null},Ml=u.createContext(void 0),kl=()=>{const e=u.useContext(Ml);if(!e)throw new Error("Avatar components must be used within an Avatar.Root");return e},Z2=(e,t)=>{const n=e?"loading":"error",[o,l]=u.useState(n);return u.useLayoutEffect(()=>{if(!e)return;let s=!0;const a=new window.Image,i=c=>()=>{s&&l(c)};return a.onload=i("loaded"),a.onerror=i("error"),a.src=e,t&&(a.referrerPolicy=t),()=>{s=!1}},[e,t]),o},El=u.forwardRef(({children:e,className:t="",size:n="default",userColor:o,...l},s)=>{const[a,i]=u.useState("idle"),c=u.useCallback(h=>{i(h)},[]),d=u.useMemo(()=>({imageLoadingStatus:a,onImageLoadingStatusChange:c,size:n}),[a,c,n]),f=o?{"--dynamic-user-color":o}:void 0;return r.jsx(Ml.Provider,{value:d,children:r.jsx("span",{...l,ref:s,className:`tiptap-avatar ${t}`,style:f,"data-size":n,children:r.jsx("span",{className:"tiptap-avatar-item",children:e})})})});El.displayName="Avatar";const Ll=u.forwardRef(({onLoadingStatusChange:e,src:t,className:n="",...o},l)=>{const{onImageLoadingStatusChange:s}=kl(),a=Z2(t,o.referrerPolicy);return u.useLayoutEffect(()=>{a!=="idle"&&(e?.(a),s(a))},[a,e,s]),a!=="loaded"?null:r.jsx("img",{alt:"",...o,ref:l,src:t,className:`tiptap-avatar-image ${n}`})});Ll.displayName="AvatarImage";const Al=u.forwardRef(({delayMs:e,className:t="",children:n,...o},l)=>{const s=kl(),[a,i]=u.useState(e===void 0);return u.useEffect(()=>{if(e!==void 0){const c=window.setTimeout(()=>i(!0),e);return()=>window.clearTimeout(c)}},[e]),!a||s.imageLoadingStatus==="loaded"?null:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`tiptap-avatar-bg ${t}`}),r.jsx("span",{...o,ref:l,className:`tiptap-avatar-fallback ${t}`,children:n})]})});Al.displayName="AvatarFallback";const F2=async e=>{const n={users:[["Emily Johnson","Marketing Manager"],["Michael Thompson","Sales Manager"],["Sophia Lee","Product Designer"],["William Davis","IT Project Manager"],["Olivia Wilson","HR Specialist"],["Daniel Taylor","Financial Controller"],["Isabella Anderson","Graphic Designer"],["Jacob Martinez","Sales Representative"],["Ava Hernandez","Marketing Assistant"],["Alexander Diaz","IT Support"],["Emma Ramirez","HR Specialist"],["Ethan Flores","Product Manager"],["Mia Morales","Graphic Designer"],["Noah Reyes","Sales Manager"],["Isabella Castillo","Marketing Manager"],["Liam Gutierrez","IT Project Manager"],["Avery Jimenez","HR Specialist"],["Lucas Vargas","Product Designer"],["Chloe Rojas","Graphic Designer"],["Kai Zhang","Sales Representative"]].map(([o,l],s)=>{const a=s+1,i=a<10?`0${a}`:`${a}`;return{id:a,name:o,position:l,avatarUrl:`/avatars/memoji_${i}.png`}})};return e?n.users.filter(o=>o.name.toLowerCase().includes(e.toLowerCase())||o.position.toLowerCase().includes(e.toLowerCase())):n.users},$2=e=>{const t=o=>{!o.editor||!o.range||!o.context||o.editor.chain().focus().insertContentAt(o.range,[{type:"mention",attrs:{id:o.context.id.toString(),label:o.context.name}},{type:"text",text:" "}]).run()},n=async o=>(await F2(o.query)).map(s=>({title:s.name,subtext:s.position,context:s,onSelect:t}));return r.jsx(Wn,{char:"@",pluginKey:"mentionDropdownMenu",decorationClass:"tiptap-mention-decoration",selector:"tiptap-mention-dropdown-menu",items:n,...e,children:o=>r.jsx(W2,{...o})})},z2=({item:e,isSelected:t,onSelect:n})=>{const o=u.useRef(null);return u.useEffect(()=>{const l=document.querySelector('[data-selector="tiptap-mention-dropdown-menu"]');if(!o.current||!t||!l)return;const s=_n(o.current,l);s==="top"?o.current.scrollIntoView(!0):s==="bottom"&&o.current.scrollIntoView(!1)},[t]),r.jsxs(k,{ref:o,variant:"ghost","data-active-state":t?"on":"off",onClick:n,"data-user-id":e.context?.id,children:[r.jsxs(El,{children:[r.jsx(Ll,{src:e.context?.avatarUrl,alt:e.title}),r.jsx(Al,{children:e.title[0]?.toUpperCase()})]}),r.jsx("span",{className:"tiptap-button-text",children:e.title})]})},W2=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const l=[];return e.forEach((s,a)=>{l.push(r.jsx(z2,{item:s,isSelected:a===t,onSelect:()=>n(s)},s.context?.id||s.title))}),l},[e,t,n]);return o.length?r.jsx(Ue,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:r.jsx(Oe,{children:r.jsx(Ie,{children:o})})}):null},qn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));qn.displayName="CodeBlockIcon";const Kn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));Kn.displayName="HeadingOneIcon";const Gn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));Gn.displayName="HeadingTwoIcon";const Yn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));Yn.displayName="HeadingThreeIcon";const Hl=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V5C20 4.44772 19.5523 4 19 4H5ZM22 14.998V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H5.99781C5.99927 22 6.00073 22 6.00219 22H19C20.6569 22 22 20.6569 22 19V15.002C22 15.0007 22 14.9994 22 14.998ZM20 15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20H19C19.5523 20 20 19.5523 20 19V15.4142ZM9 8C8.44772 8 8 8.44772 8 9C8 9.55228 8.44772 10 9 10C9.55228 10 10 9.55228 10 9C10 8.44772 9.55228 8 9 8ZM6 9C6 7.34315 7.34315 6 9 6C10.6569 6 12 7.34315 12 9C12 10.6569 10.6569 12 9 12C7.34315 12 6 10.6569 6 9Z",fill:"currentColor"})}));Hl.displayName="ImageIcon";const Xn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Xn.displayName="ListIcon";const jn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));jn.displayName="ListOrderedIcon";const Qn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));Qn.displayName="BlockquoteIcon";const Jn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"})]}));Jn.displayName="ListTodoIcon";const Nl=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 12C4 11.4477 4.44772 11 5 11H19C19.5523 11 20 11.4477 20 12C20 12.5523 19.5523 13 19 13H5C4.44772 13 4 12.5523 4 12Z",fill:"currentColor"})}));Nl.displayName="MinusIcon";const Rn=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M3 4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V7C21 7.55228 20.5523 8 20 8C19.4477 8 19 7.55228 19 7V5H13V19H15C15.5523 19 16 19.4477 16 20C16 20.5523 15.5523 21 15 21H9C8.44772 21 8 20.5523 8 20C8 19.4477 8.44772 19 9 19H11V5H5V7C5 7.55228 4.55228 8 4 8C3.44772 8 3 7.55228 3 7V4Z",fill:"currentColor"})}));Rn.displayName="TypeIcon";const eo=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5273 1.29427C12.1156 0.724951 9.58234 0.986597 7.33794 2.03682C5.09354 3.08704 3.26948 4.8643 2.1613 7.08066C1.05312 9.29702 0.725742 11.8226 1.23221 14.2483C1.73868 16.6739 3.04931 18.8575 4.95178 20.4453C6.85424 22.033 9.23706 22.9319 11.7142 22.9963C14.1913 23.0607 16.6176 22.2868 18.6 20.8C19.0418 20.4686 19.1314 19.8418 18.8 19.4C18.4686 18.9582 17.8418 18.8686 17.4 19.2C15.7781 20.4165 13.7929 21.0496 11.7662 20.997C9.73942 20.9443 7.78983 20.2088 6.23327 18.9098C4.67671 17.6107 3.60437 15.8241 3.18999 13.8395C2.77561 11.8549 3.04346 9.78847 3.95015 7.97509C4.85685 6.1617 6.34926 4.70758 8.18559 3.84831C10.0219 2.98904 12.0946 2.77496 14.0678 3.24077C16.041 3.70658 17.7991 4.82497 19.0573 6.41476C20.3155 8.00455 21 9.97258 21 12V13C21 13.5304 20.7893 14.0392 20.4142 14.4142C20.0391 14.7893 19.5304 15 19 15C18.4696 15 17.9609 14.7893 17.5858 14.4142C17.2107 14.0392 17 13.5304 17 13V8.00001C17 7.44772 16.5523 7.00001 16 7.00001C15.4478 7.00001 15.0002 7.44752 15 7.99964C14.1643 7.37195 13.1256 7 12 7C9.23858 7 7 9.23858 7 12C7 14.7614 9.23858 17 12 17C13.4881 17 14.8243 16.3499 15.7403 15.3183C15.8687 15.4989 16.0128 15.6696 16.1716 15.8284C16.9217 16.5786 17.9391 17 19 17C20.0609 17 21.0783 16.5786 21.8284 15.8284C22.5786 15.0783 23 14.0609 23 13V12C23 9.52205 22.1633 7.11667 20.6255 5.17359C19.0878 3.23052 16.939 1.86359 14.5273 1.29427ZM15 11.9958V12.0042C14.9977 13.6591 13.6555 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6555 9 14.9977 10.3409 15 11.9958Z",fill:"currentColor"})}));eo.displayName="AtSignIcon";const to=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.67909 4.05505C9.27254 3.18292 11.0926 2.81337 12.9 2.995C13.4495 3.05022 13.9398 2.64952 13.995 2.1C14.0502 1.55048 13.6495 1.06024 13.1 1.00502C10.8909 0.783033 8.66641 1.2347 6.71886 2.30064C4.7713 3.36659 3.19189 4.99691 2.18824 6.97729C1.1846 8.95767 0.803706 11.1954 1.09564 13.3963C1.38758 15.5972 2.33867 17.6583 3.8239 19.3085C5.30912 20.9588 7.25894 22.121 9.41704 22.6423C11.5751 23.1637 13.8405 23.0198 15.9153 22.2296C17.9901 21.4394 19.7772 20.0398 21.0417 18.2149C22.3062 16.39 22.9889 14.2252 23 12.005L23 12V11C23 10.4477 22.5523 10 22 10C21.4477 10 21 10.4477 21 11V11.9976C20.9904 13.8132 20.4319 15.5834 19.3978 17.0758C18.3632 18.5689 16.901 19.714 15.2034 20.3605C13.5059 21.0071 11.6524 21.1248 9.8867 20.6982C8.12098 20.2717 6.52567 19.3208 5.31048 17.9706C4.0953 16.6204 3.31713 14.9341 3.07828 13.1333C2.83942 11.3326 3.15106 9.50171 3.97222 7.8814C4.79339 6.26109 6.08564 4.92719 7.67909 4.05505ZM7.4 13.2C7.84043 12.8697 8.46468 12.9576 8.79686 13.3958L8.8015 13.4018C8.80745 13.4093 8.81876 13.4234 8.83531 13.4431C8.86846 13.4826 8.92219 13.5442 8.99542 13.6206C9.14272 13.7743 9.36407 13.9828 9.65067 14.1913C10.2277 14.6109 11.0255 15 12 15C12.9745 15 13.7723 14.6109 14.3493 14.1913C14.6359 13.9828 14.8573 13.7743 15.0046 13.6206C15.0778 13.5442 15.1315 13.4826 15.1647 13.4431C15.1812 13.4234 15.1925 13.4093 15.1985 13.4018L15.2031 13.3958C15.5353 12.9576 16.1596 12.8697 16.6 13.2C17.0418 13.5314 17.1314 14.1582 16.8 14.6L16 14C16.8 14.6 16.7998 14.6003 16.7995 14.6006L16.799 14.6013L16.7978 14.6029L16.7951 14.6065L16.7879 14.6159L16.7666 14.6432C16.7493 14.6649 16.726 14.6938 16.6966 14.7288C16.638 14.7987 16.555 14.8933 16.4485 15.0044C16.2365 15.2257 15.9266 15.5172 15.5257 15.8087C14.7277 16.3891 13.5255 17 12 17C10.4745 17 9.27227 16.3891 8.47433 15.8087C8.07343 15.5172 7.76352 15.2257 7.55145 15.0044C7.445 14.8933 7.362 14.7987 7.30336 14.7288C7.274 14.6938 7.25065 14.6649 7.23341 14.6432L7.21211 14.6159L7.2049 14.6065L7.20216 14.6029L7.20101 14.6013L7.20048 14.6006C7.20024 14.6003 7.2 14.6 8 14L7.2 14.6C6.86863 14.1582 6.95817 13.5314 7.4 13.2ZM8 9C8 8.44772 8.44772 8 9 8H9.01C9.56229 8 10.01 8.44772 10.01 9C10.01 9.55229 9.56229 10 9.01 10H9C8.44772 10 8 9.55229 8 9ZM15 8C14.4477 8 14 8.44772 14 9C14 9.55229 14.4477 10 15 10H15.01C15.5623 10 16.01 9.55229 16.01 9C16.01 8.44772 15.5623 8 15.01 8H15ZM15 5C15 4.44772 15.4477 4 16 4H18V2C18 1.44772 18.4477 1 19 1C19.5523 1 20 1.44772 20 2V4H22C22.5523 4 23 4.44772 23 5C23 5.55228 22.5523 6 22 6H20V8C20 8.55228 19.5523 9 19 9C18.4477 9 18 8.55228 18 8V6H16C15.4477 6 15 5.55228 15 5Z",fill:"currentColor"})}));to.displayName="SmilePlusIcon";const Vl=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM4 5C4 4.44772 4.44772 4 5 4H11V8H4V5ZM4 10H11V14H4V10ZM20 14V10H13V14H20ZM13 16H20V19C20 19.5523 19.5523 20 19 20H13V16ZM11 16V20H5C4.44772 20 4 19.5523 4 19V16H11ZM13 8H20V5C20 4.44772 19.5523 4 19 4H13V8Z",fill:"currentColor"})}));Vl.displayName="TableIcon";const no=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 12C11 11.4477 11.4477 11 12 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H12C11.4477 13 11 12.5523 11 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 16.5C3.22386 16.5 3 16.7239 3 17V19C3 19.2761 3.22386 19.5 3.5 19.5H5.5C5.77614 19.5 6 19.2761 6 19V17C6 16.7239 5.77614 16.5 5.5 16.5H3.5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.5 10.5C6.22386 10.5 6 10.7239 6 11V13C6 13.2761 6.22386 13.5 6.5 13.5H8.5C8.77614 13.5 9 13.2761 9 13V11C9 10.7239 8.77614 10.5 8.5 10.5H6.5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 4.5C3.22386 4.5 3 4.72386 3 5V7C3 7.27614 3.22386 7.5 3.5 7.5H5.5C5.77614 7.5 6 7.27614 6 7V5C6 4.72386 5.77614 4.5 5.5 4.5H3.5Z",fill:"currentColor"})]}));no.displayName="ListIndentedIcon";function _2({shortcutKeys:e=oo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const q2=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:l=":",hideWhenUnavailable:s=!1,onTriggerApplied:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,canAddTrigger:b,handleAddTrigger:g,label:w,shortcutKeys:v,Icon:m}=X2({editor:p,node:t,nodePos:n,trigger:l,hideWhenUnavailable:s,onTriggerApplied:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":w,tooltip:"Add emoji",onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o}),i&&r.jsx(_2,{shortcutKeys:v})]})}):null});q2.displayName="EmojiTriggerButton";const oo="mod+shift+e";function ro(e){return!(!e||!e.isEditable||re(e,["image"]))}function K2(e,t,n,o){if(n!=null||K(o)){const s=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const a=s.node.type.name==="paragraph"&&s.node.content.size===0,i=s.pos+s.node.nodeSize;return e.chain().insertContentAt(a?s.pos:i,{type:"paragraph",content:[{type:"text",text:t}]}).focus(a?s.pos+t.length+1:i+t.length+1).run()}const{$from:l}=e.state.selection;return e.chain().insertContentAt(l.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function G2(e,t,n,o){if(n!=null||K(o)){const i=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!i)return!1;const c=i.node.type.name==="paragraph"&&i.node.content.size===0,d=i.pos+i.node.nodeSize;return e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,c?i.pos:d,c?i.pos:d)),e.commands.focus(c?i.pos+2:d+t.length+1),!0}const{$from:l}=e.state.selection,s=l.node(),a=l.parentOffset>0&&s.textContent[l.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:a?` ${t}`:t}).focus().run()}function Bl(e,t=":",n,o){if(!e||!e.isEditable||!ro(e))return!1;try{const{$from:l}=e.state.selection,s=l.node();return s.isBlock&&!s.isTextblock?K2(e,t,n,o):G2(e,t,n,o)}catch{return!1}}function Y2(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:ro(t):!1:!0:!1}function X2(e){const{editor:t,node:n,nodePos:o,trigger:l=":",hideWhenUnavailable:s=!1,onTriggerApplied:a}=e||{},{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=ro(i);u.useEffect(()=>{if(!i)return;const C=()=>{f(Y2({editor:i,hideWhenUnavailable:s}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,s]);const p=u.useCallback(()=>{if(!i)return!1;const C=Bl(i,l,n,o);return C&&a?.(l),C},[i,l,n,o,a]);return ie.useHotkeys(oo,C=>{C.preventDefault(),p()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleAddTrigger:p,canAddTrigger:h,label:"Add emoji",shortcutKeys:oo,trigger:l,Icon:to}}function j2({shortcutKeys:e=lo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Q2=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:l="@",hideWhenUnavailable:s=!1,onTriggered:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,canInsert:b,handleMention:g,label:w,shortcutKeys:v,Icon:m}=td({editor:p,node:t,nodePos:n,trigger:l,hideWhenUnavailable:s,onTriggered:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":w,tooltip:w,onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o}),i&&r.jsx(j2,{shortcutKeys:v})]})}):null});Q2.displayName="MentionTriggerButton";const lo="mod+shift+2";function so(e,t,n){if(!e||!e.isEditable||re(e,["image"]))return!1;if(t||K(n)){if(K(n)&&n>=0)return!0;if(t)return Ce({editor:e,node:t})!==null}return!0}function J2(e,t,n,o){if(n!=null||K(o)){const s=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const a=s.node.type.name==="paragraph"&&s.node.content.size===0,i=a?s.pos:s.pos+s.node.nodeSize,c=t.length+1,d=a?s.pos+c:s.pos+s.node.nodeSize+c;return e.chain().insertContentAt(a?s.pos:i,{type:"paragraph",content:[{type:"text",text:t}]}).focus(d).run()}const{$from:l}=e.state.selection;return e.chain().insertContentAt(l.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function R2(e,t,n,o){if(n!=null||K(o)){const i=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!i)return!1;const c=i.node.type.name==="paragraph"&&i.node.content.size===0,d=c?i.pos:i.pos+i.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,d,d));const f=t.length+1,h=c?i.pos+f:i.pos+i.node.nodeSize+f;return e.commands.focus(h),!0}const{$from:l}=e.state.selection,s=l.node(),a=l.parentOffset>0&&s.textContent[l.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:a?` ${t}`:t}).focus().run()}function Dl(e,t="@",n,o){if(!e||!e.isEditable||!so(e,n,o))return!1;try{const{$from:l}=e.state.selection,s=l.node();return s.isBlock&&!s.isTextblock?J2(e,t,n,o):R2(e,t,n,o)}catch{return!1}}function ed(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:l}=e;return t?n?t.isEditable?t.isActive("code")?!0:so(t,o,l):!1:!0:!1}function td(e){const{editor:t,node:n,nodePos:o,trigger:l="@",hideWhenUnavailable:s=!1,onTriggered:a}=e||{},{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=so(i,n,o);u.useEffect(()=>{if(!i)return;const C=()=>{f(ed({editor:i,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,s,n,o]);const p=u.useCallback(()=>{if(!i)return!1;const C=Dl(i,l,n,o);return C&&a?.(l),C},[i,l,n,o,a]);return ie.useHotkeys(lo,C=>{C.preventDefault(),p()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleMention:p,canInsert:h,label:"Add mention",shortcutKeys:lo,trigger:l,Icon:eo}}const Ul={text:{title:"Text",subtext:"Regular text paragraph",keywords:["p","paragraph","text"],badge:Rn,group:"Style"},heading_1:{title:"Heading 1",subtext:"Top-level heading",keywords:["h","heading1","h1"],badge:Kn,group:"Style"},heading_2:{title:"Heading 2",subtext:"Key section heading",keywords:["h2","heading2","subheading"],badge:Gn,group:"Style"},heading_3:{title:"Heading 3",subtext:"Subsection and group heading",keywords:["h3","heading3","subheading"],badge:Yn,group:"Style"},bullet_list:{title:"Bullet List",subtext:"List with unordered items",keywords:["ul","li","list","bulletlist","bullet list"],badge:Xn,group:"Style"},ordered_list:{title:"Numbered List",subtext:"List with ordered items",keywords:["ol","li","list","numberedlist","numbered list"],badge:jn,group:"Style"},task_list:{title:"To-do list",subtext:"List with tasks",keywords:["tasklist","task list","todo","checklist"],badge:Jn,group:"Style"},quote:{title:"Blockquote",subtext:"Blockquote block",keywords:["quote","blockquote"],badge:Qn,group:"Style"},code_block:{title:"Code Block",subtext:"Code block with syntax highlighting",keywords:["code","pre"],badge:qn,group:"Style"},mention:{title:"Mention",subtext:"Mention a user or item",keywords:["mention","user","item","tag"],badge:eo,group:"Insert"},emoji:{title:"Emoji",subtext:"Insert an emoji",keywords:["emoji","emoticon","smiley"],badge:to,group:"Insert"},table:{title:"Table",subtext:"Insert a table",keywords:["table","insertTable"],badge:Vl,group:"Insert"},divider:{title:"Separator",subtext:"Horizontal line to separate content",keywords:["hr","horizontalRule","line","separator"],badge:Nl,group:"Insert"},toc:{title:"Table of contents",subtext:"Insert a table of contents",keywords:["toc","tableofcontents","table of contents"],badge:no,group:"Insert"},image:{title:"Image",subtext:"Resizable image with caption",keywords:["image","imageUpload","upload","img","picture","media","url"],badge:Hl,group:"Upload"}},nd=()=>({text:{check:e=>Q("paragraph",e),action:({editor:e})=>{e.chain().focus().setParagraph().run()}},heading_1:{check:e=>Q("heading",e),action:({editor:e})=>{e.chain().focus().toggleHeading({level:1}).run()}},heading_2:{check:e=>Q("heading",e),action:({editor:e})=>{e.chain().focus().toggleHeading({level:2}).run()}},heading_3:{check:e=>Q("heading",e),action:({editor:e})=>{e.chain().focus().toggleHeading({level:3}).run()}},bullet_list:{check:e=>Q("bulletList",e),action:({editor:e})=>{e.chain().focus().toggleBulletList().run()}},ordered_list:{check:e=>Q("orderedList",e),action:({editor:e})=>{e.chain().focus().toggleOrderedList().run()}},task_list:{check:e=>Q("taskList",e),action:({editor:e})=>{e.chain().focus().toggleTaskList().run()}},quote:{check:e=>Q("blockquote",e),action:({editor:e})=>{e.chain().focus().toggleBlockquote().run()}},code_block:{check:e=>Q("codeBlock",e),action:({editor:e})=>{e.chain().focus().toggleNode("codeBlock","paragraph").run()}},mention:{check:e=>V(e,["mention","mentionAdvanced"]),action:({editor:e})=>Dl(e)},emoji:{check:e=>V(e,["emoji","emojiPicker"]),action:({editor:e})=>Bl(e)},divider:{check:e=>Q("horizontalRule",e),action:({editor:e})=>{e.chain().focus().setHorizontalRule().run()}},toc:{check:e=>Q("tocNode",e),action:({editor:e})=>{e.chain().focus().insertTocNode().run()}},table:{check:e=>Q("table",e),action:({editor:e})=>{e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},image:{check:e=>Q("image",e),action:({editor:e})=>{e.chain().focus().insertContent({type:"imageUpload"}).run()}}});function od(e,t){if(!t)return e.map(l=>({...l,group:""}));const n={};e.forEach(l=>{const s=l.group||"";n[s]||(n[s]=[]),n[s].push(l)});const o=[];return Object.entries(n).forEach(([,l])=>{o.push(...l)}),o}function rd(e){return{getSlashMenuItems:u.useCallback(n=>{const o=[],l=e?.enabledItems||Object.keys(Ul),s=e?.showGroups!==!1,a=nd();return l.forEach(i=>{const c=a[i],d=Ul[i];if(c&&d&&c.check(n)){const f={onSelect:({editor:h})=>c.action({editor:h}),...d};e?.itemGroups?.[i]?f.group=e.itemGroups[i]:s||(f.group=""),o.push(f)}}),e?.customItems&&o.push(...e.customItems),od(o,s)},[e]),config:e}}const ld=e=>{const{config:t,...n}=e,{getSlashMenuItems:o}=rd(t);return r.jsx(Wn,{char:"/",pluginKey:"slashDropdownMenu",decorationClass:"tiptap-slash-decoration",decorationContent:"Filter...",selector:"tiptap-slash-dropdown-menu",items:({query:l,editor:s})=>L2(o(s),l),...n,children:l=>r.jsx(sd,{...l,config:t})})},Ol=e=>{const{item:t,isSelected:n,onSelect:o}=e,l=u.useRef(null);u.useEffect(()=>{const a=document.querySelector('[data-selector="tiptap-slash-dropdown-menu"]');if(!l.current||!n||!a)return;const i=_n(l.current,a);i==="top"?l.current.scrollIntoView(!0):i==="bottom"&&l.current.scrollIntoView(!1)},[n]);const s=t.badge;return r.jsxs(k,{ref:l,variant:"ghost","data-active-state":n?"on":"off",onClick:o,children:[s&&r.jsx(s,{className:"tiptap-button-icon"}),r.jsx("div",{className:"tiptap-button-text",children:t.title})]})},sd=({items:e,selectedIndex:t,onSelect:n,config:o})=>{const l=u.useMemo(()=>{const s=[];if(!(o?.showGroups!==!1))return e.forEach((c,d)=>{s.push(r.jsx(Ol,{item:c,isSelected:d===t,onSelect:()=>n(c)},`item-${d}-${c.title}`))}),s;const i={};return e.forEach((c,d)=>{const f=c.group||"";i[f]||(i[f]={items:[],indices:[]}),i[f].items.push(c),i[f].indices.push(d)}),Object.entries(i).forEach(([c,d],f)=>{f>0&&s.push(r.jsx(R,{orientation:"horizontal"},`separator-${f}`));const h=d.items.map((p,C)=>{const b=d.indices[C];return r.jsx(Ol,{item:p,isSelected:b===t,onSelect:()=>n(p)},`item-${b}-${p.title}`)});c?s.push(r.jsxs(Ie,{children:[r.jsx(it,{children:c}),h]},`group-${f}-${c}`)):s.push(...h)}),s},[e,t,n,o?.showGroups]);return l.length?r.jsx(Ue,{className:"tiptap-slash-card",style:{maxHeight:"var(--suggestion-menu-max-height)"},children:r.jsx(Oe,{className:"tiptap-slash-card-body",children:l})}):null};function ad({shortcutKeys:e=ao}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Pl=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:l,downloadMethod:s,showShortcut:a=!1,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,canDownload:C,handleDownload:b,label:g,shortcutKeys:w,Icon:v}=_l({editor:h,hideWhenUnavailable:n,onDownloaded:o,resolveFileUrl:l,downloadMethod:s}),m=u.useCallback(async x=>{i?.(x),!x.defaultPrevented&&await b()},[b,i]);return p?r.jsx(k,{type:"button",variant:"ghost","data-active-state":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":g,tooltip:g,onClick:m,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),a&&r.jsx(ad,{shortcutKeys:w})]})}):null});Pl.displayName="ImageDownloadButton";const Zl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V14.5858L17.2929 10.2929C17.6834 9.90237 18.3166 9.90237 18.7071 10.2929C19.0976 10.6834 19.0976 11.3166 18.7071 11.7071L12.7071 17.7071C12.3166 18.0976 11.6834 18.0976 11.2929 17.7071L5.29289 11.7071C4.90237 11.3166 4.90237 10.6834 5.29289 10.2929C5.68342 9.90237 6.31658 9.90237 6.70711 10.2929L11 14.5858V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"}),r.jsx("path",{d:"M5 20C4.44772 20 4 20.4477 4 21C4 21.5523 4.44772 22 5 22H19C19.5523 22 20 21.5523 20 21C20 20.4477 19.5523 20 19 20H5Z",fill:"currentColor"})]}));Zl.displayName="ArrowDownToLineIcon";const ao="mod+shift+d";function Fl(e,t){const n=e.match(/\.([a-zA-Z0-9]+)(?:\?|#|$)/);return n&&n[1]?`.${n[1].toLowerCase()}`:t&&{"image/jpeg":".jpg","image/jpg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp"}[t.toLowerCase()]||".jpg"}function At(e){return!e||!e.isEditable||!V(e,["image"])?!1:re(e,["image"])}function $l(e){if(!e||!At(e))return null;const{selection:t}=e.state;if(t instanceof M.NodeSelection){const n=t.node;if(n.type.name==="image")return{src:n.attrs.src,alt:n.attrs.alt,title:n.attrs.title}}return null}async function zl(e,t){try{const n=await fetch(e);if(!n.ok)return!1;const o=await n.blob(),l=URL.createObjectURL(o),a=/\.[a-zA-Z0-9]+$/.test(t)?t:t+Fl(e,n.headers.get("content-type")||void 0),i=document.createElement("a");return i.href=l,i.download=a,i.style.display="none",document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(l),0),!0}catch(n){return console.warn("Fetch download failed:",n),!1}}function Wl(e,t){try{const o=/\.[a-zA-Z0-9]+$/.test(t)?t:t+Fl(e),l=document.createElement("a");return l.href=e,l.download=o,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),!0}catch(n){return console.warn("Direct download failed:",n),!1}}function Ht(e){try{return window.open(e,"_blank"),!0}catch(t){return console.error("Failed to open image:",t),!1}}async function id(e,t,n,o="auto"){if(!e||!At(e))return!1;const l=$l(e);if(!l?.src)return!1;try{let s=l.src;n&&(s=await n(l.src));const a=window.location.href,i=jt(s,a);if(i==="#")return console.error("Invalid or unsafe URL after sanitization"),!1;const c=t||l.alt||l.title||`image-${Date.now()}`;switch(o){case"open":return Ht(i);case"download":return i.startsWith(window.location.origin)||i.startsWith("data:")?Wl(i,c):await zl(i,c)||Ht(i);default:return i.startsWith("data:")||i.startsWith(window.location.origin)?Wl(i,c):await zl(i,c)?!0:Ht(i)}}catch(s){console.error("Failed to download image:",s);try{const a=window.location.href,i=jt(l.src,a);if(i!=="#")return Ht(i)}catch{}return!1}}function cd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!V(t,["image","imageUpload"])?!1:At(t):!0:!1}function _l(e){const{editor:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:l,downloadMethod:s="auto"}=e||{},{editor:a}=S(t),i=ee(),[c,d]=u.useState(!0),f=At(a);u.useEffect(()=>{if(!a)return;const p=()=>{d(cd({editor:a,hideWhenUnavailable:n}))};return p(),a.on("selectionUpdate",p),()=>{a.off("selectionUpdate",p)}},[a,n]);const h=u.useCallback(async()=>{if(!a)return!1;const p=$l(a),C=p?.alt||p?.title,b=await id(a,C,l,s);return b&&o?.(C),b},[a,o,l,s]);return ie.useHotkeys(ao,p=>{p.preventDefault(),h()},{enabled:c&&f,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:c,canDownload:f,handleDownload:h,label:"Download image",shortcutKeys:ao,Icon:Zl}}function ql({shortcutKeys:e=io}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Kl=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDuplicated:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,handleDuplicate:h,label:p,shortcutKeys:C,Icon:b}=Yl({editor:d,hideWhenUnavailable:n,onDuplicated:o}),g=u.useCallback(w=>{s?.(w),!w.defaultPrevented&&h()},[h,s]);return f?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":p,tooltip:"Duplicate",onClick:g,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(ql,{shortcutKeys:C})]})}):null});Kl.displayName="DuplicateButton";const io="mod+d";function Gl(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof M.NodeSelection)return!!n.node;const o=n.$anchor;for(let l=1;l<=o.depth;l++){const s=o.node(l);if(!(s.type.name==="doc"||!s.type.spec.group))return!0}return!1}catch{return!1}}function dd(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t,o=e.chain().focus();if(n instanceof M.NodeSelection){const s=n.node,a=n.to;return o.insertContentAt(a,s.toJSON()).run(),!0}const l=n.$anchor;for(let s=1;s<=l.depth;s++){const a=l.node(s);if(a.type.name==="doc"||!a.type.spec.group)continue;const i=l.start(s),c=Math.min(i+a.nodeSize,t.doc.content.size);return o.insertContentAt(c,a.toJSON()).run(),!0}return!1}catch{return!1}}function ud(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Gl(t):!1:!0:!1}function Yl(e){const{editor:t,hideWhenUnavailable:n=!1,onDuplicated:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=Gl(l);u.useEffect(()=>{if(!l)return;const f=()=>{i(ud({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=dd(l);return f&&o?.(),f},[l,o]);return ie.useHotkeys(io,f=>{f.preventDefault(),d()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,handleDuplicate:d,canDuplicate:c,label:"Duplicate node",shortcutKeys:io,Icon:un}}function Xl({shortcutKeys:e=co}){return r.jsx(X,{children:G({shortcutKeys:e})})}const jl=u.forwardRef(({editor:e,text:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleCopyToClipboard:p,label:C,shortcutKeys:b,Icon:g}=Rl({editor:f,copyWithFormatting:n,hideWhenUnavailable:o,onCopied:l}),w=u.useCallback(async v=>{a?.(v),!v.defaultPrevented&&await p()},[p,a]);return h?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":C,tooltip:"Copy to clipboard",onClick:w,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),s&&r.jsx(Xl,{shortcutKeys:b})]})}):null});jl.displayName="CopyToClipboardButton";const Ql=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M15 1C16.1046 1 17 1.89543 17 3H18C18.7956 3 19.5585 3.3163 20.1211 3.87891C20.6837 4.44151 21 5.20435 21 6V20C21 20.7957 20.6837 21.5585 20.1211 22.1211C19.5585 22.6837 18.7957 23 18 23H6C5.20435 23 4.44151 22.6837 3.87891 22.1211C3.3163 21.5585 3 20.7957 3 20V6C3 5.20435 3.3163 4.44152 3.87891 3.87891C4.44152 3.3163 5.20435 3 6 3H7C7 1.89543 7.89543 1 9 1H15ZM6 5C5.73478 5 5.4805 5.10543 5.29297 5.29297C5.10543 5.4805 5 5.73478 5 6V20L5.00488 20.0986C5.02757 20.3276 5.12883 20.5429 5.29297 20.707C5.48051 20.8946 5.73478 21 6 21H18C18.2652 21 18.5195 20.8946 18.707 20.707C18.8946 20.5195 19 20.2652 19 20V6C19 5.73478 18.8946 5.48051 18.707 5.29297C18.5429 5.12883 18.3276 5.02757 18.0986 5.00488L18 5H17C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5H6ZM9 5H15V3H9V5Z",fill:"currentColor"})}));Ql.displayName="ClipboardIcon";const co="mod+c";async function fd(e,t){try{if(t&&navigator.clipboard&&"write"in navigator.clipboard){const n=new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})});await navigator.clipboard.write([n])}else await navigator.clipboard.writeText(e)}catch{await navigator.clipboard.writeText(e)}}function hd(e){const{selection:t}=e,{empty:n}=t;return!n}function Jl(e){if(!e||!e.isEditable)return!1;const t=e.state.tr;return hd(t)}function pd(e,t=!0){const{selection:n}=e.state,{$anchor:o}=n;let l=n.content();if(n.empty||n instanceof M.TextSelection){const i=o.node(1);l=new Ko.Slice(Ko.Fragment.from(i),0,0)}const s=l.content.textBetween(0,l.content.size,`
5
- `),a=t?e.view.serializeForClipboard(l).dom.innerHTML:void 0;return{textContent:s,htmlContent:a}}async function Cd(e,t=!0){if(!e||!e.isEditable)return!1;try{const{textContent:n,htmlContent:o}=pd(e,t);return await fd(n,o),!0}catch{return!1}}function gd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Jl(t):!1:!0:!1}function Rl(e){const{editor:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:l}=e||{},{editor:s}=S(t),a=ee(),[i,c]=u.useState(!0),d=Jl(s);u.useEffect(()=>{if(!s)return;const h=()=>{c(gd({editor:s,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o]);const f=u.useCallback(async()=>{if(!s)return!1;const h=await Cd(s,n);return h&&l?.(),h},[s,n,l]);return ie.useHotkeys(co,h=>{h.preventDefault(),f()},{enabled:i&&d,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:i,handleCopyToClipboard:f,canCopyToClipboard:d,label:"Copy to clipboard",shortcutKeys:co,Icon:Ql}}function es({shortcutKeys:e=fo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const uo=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDeleted:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,handleDeleteNode:h,label:p,shortcutKeys:C,Icon:b}=os({editor:d,hideWhenUnavailable:n,onDeleted:o}),g=u.useCallback(w=>{s?.(w),!w.defaultPrevented&&h()},[h,s]);return f?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":p,tooltip:"Delete",onClick:g,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(es,{shortcutKeys:C})]})}):null});uo.displayName="DeleteNodeButton";const fo="backspace";function ts(e){if(!e||!e.isEditable)return!1;const{state:t}=e,{selection:n}=t;if(n instanceof M.NodeSelection)return!0;const o=n.$anchor;for(let l=o.depth;l>0;l--){const s=o.node(l),a=o.before(l);if(t.tr.delete(a,a+s.nodeSize).doc!==t.doc)return!0}return!1}function ns(e,t,n){const o=e.chain().focus();return o.deleteRange({from:t,to:t+n}).run()?!0:o.setNodeSelection(t).deleteSelection().run()}function bd(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof M.NodeSelection){const l=n.from,s=n.node;return s?ns(e,l,s.nodeSize):!1}const o=n.$from;for(let l=o.depth;l>0;l--){const s=n.$from.node(l),a=n.$from.before(l);if(s&&s.isBlock&&s.type.name!=="tableRow"&&s.type.name!=="tableHeader"&&s.type.name!=="tableCell")return ns(e,a,s.nodeSize)}return!1}catch{return!1}}function wd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:ts(t):!1:!0:!1}function os(e){const{editor:t,hideWhenUnavailable:n=!1,onDeleted:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=ts(l);u.useEffect(()=>{if(!l)return;const f=()=>{i(wd({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=bd(l);return f&&o?.(),f},[l,o]);return ie.useHotkeys(fo,f=>{f.preventDefault(),d()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,handleDeleteNode:d,canDeleteNode:c,label:"Delete",shortcutKeys:fo,Icon:wt}}function rs({shortcutKeys:e=ho}){return r.jsx(X,{children:G({shortcutKeys:e})})}const ls=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:l,onCopied:s,showShortcut:a=!1,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleCopyAnchorLink:C,label:b,shortcutKeys:g,Icon:w}=cs({editor:h,hideWhenUnavailable:n,onNodeIdNotFound:o,onExtractedNodeId:l,onCopied:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":b,tooltip:"Copy anchor link",onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),a&&r.jsx(rs,{shortcutKeys:g})]})}):null});ls.displayName="CopyAnchorLinkButton";const dt=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),r.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));dt.displayName="LinkIcon";const ho="mod+ctrl+l";function ss(e){return!!(e&&e.isEditable)}function vd(e){return Xo(e,"uniqueID")?.options?.attributeName||"data-id"}function as(e){if(!ss(e))return null;const t=et(e);if(!t)return null;const n=vd(e),o=md(t.node,n);return{node:t.node,nodeId:o,hasNodeId:o!==null}}function md(e,t){if(!e?.attrs?.[t])return null;try{return e.attrs[t]}catch{return null}}function is(e){return as(e)?.hasNodeId??!1}async function yd(e,t,n){const o=as(e);if(!o)return!1;const{nodeId:l,hasNodeId:s}=o;if(t?.(l),n?.(!s),!s||!l)return!1;try{const a=new URL(window.location.href);return a.searchParams.set("source","copy_link"),a.hash=l,await navigator.clipboard.writeText(a.toString()),!0}catch(a){return console.error("Failed to copy node ID to clipboard:",a),!1}}function xd(e){const{editor:t,hideWhenUnavailable:n}=e;if(!ss(t))return!1;const o=!!et(t);return n?is(t):o}function cs(e){const{editor:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:l,onCopied:s}=e||{},{editor:a}=S(t),i=ee(),[c,d]=u.useState(!0),f=is(a);u.useEffect(()=>{if(!a)return;const p=()=>{d(xd({editor:a,hideWhenUnavailable:n}))};return p(),a.on("selectionUpdate",p),()=>{a.off("selectionUpdate",p)}},[a,n]);const h=u.useCallback(async()=>{const p=await yd(a,l,o);return p&&s?.(),p},[a,l,o,s]);return ie.useHotkeys(ho,p=>{p.preventDefault(),h()},{enabled:c&&f,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:c,handleCopyAnchorLink:h,canCopyAnchorLink:f,label:"Copy anchor link",shortcutKeys:ho,Icon:dt}}function Sd({shortcutKeys:e=po}){return r.jsx(X,{children:G({shortcutKeys:e})})}const ds=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,preserveMarks:o=fs,onResetAllFormatting:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canReset:p,handleResetFormatting:C,label:b,shortcutKeys:g,Icon:w}=ps({editor:f,preserveMarks:o,hideWhenUnavailable:n,onResetAllFormatting:l}),v=u.useCallback(m=>{a?.(m),!m.defaultPrevented&&C()},[C,a]);return h?r.jsx(k,{type:"button",variant:"ghost",disabled:!p,"data-disabled":!p,"data-active-state":"off",role:"button",tabIndex:-1,"aria-label":b,tooltip:"Reset formatting",onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),s&&r.jsx(Sd,{shortcutKeys:g})]})}):null});ds.displayName="ResetAllFormattingButton";const us=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M12 2L11.9962 2.00001C9.22213 2.01045 6.55946 3.0929 4.56496 5.02104L4.55289 5.0329L4 5.58579V3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41422L5.96097 6.45325C7.58329 4.88786 9.7473 4.00897 12.0019 4.00001C13.5835 4.00038 15.1295 4.46955 16.4446 5.34825C17.7602 6.2273 18.7855 7.47673 19.391 8.93854C19.9965 10.4003 20.155 12.0089 19.8463 13.5607C19.5376 15.1126 18.7757 16.538 17.6569 17.6569C16.538 18.7757 15.1126 19.5376 13.5607 19.8463C12.0089 20.155 10.4003 19.9965 8.93853 19.391C7.47672 18.7855 6.22729 17.7602 5.34824 16.4446C4.46919 15.129 4 13.5823 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 13.9778 2.58649 15.9112 3.6853 17.5557C4.78412 19.2002 6.3459 20.4819 8.17317 21.2388C10.0004 21.9957 12.0111 22.1937 13.9509 21.8079C15.8907 21.422 17.6725 20.4696 19.0711 19.0711C20.4696 17.6726 21.422 15.8907 21.8079 13.9509C22.1937 12.0111 21.9957 10.0004 21.2388 8.17317C20.4819 6.34591 19.2002 4.78412 17.5557 3.68531C15.9112 2.5865 13.9778 2.00001 12 2Z",fill:"currentColor"})}));us.displayName="RotateCcwIcon";const po="mod+r",fs=["inlineThread"];function Td(e,t=[]){const{selection:n}=e,{empty:o,ranges:l}=n;return o||l.forEach(s=>{const a=s.$from.pos,i=s.$to.pos;e.doc.nodesBetween(a,i,(c,d)=>(c.isInline&&c.marks.forEach(f=>{t.includes(f.type.name)||e.removeMark(d,d+c.nodeSize,f.type)}),!0))}),e}function Id(e,t=[]){const{selection:n}=e,{empty:o,ranges:l}=n;if(o)return!1;for(const s of l){const a=s.$from.pos,i=s.$to.pos;let c=!1;if(e.doc.nodesBetween(a,i,d=>{if(!d.isInline)return!0;for(const f of d.marks)if(!t.includes(f.type.name))return c=!0,!1;return!0}),c)return!0}return!1}function hs(e,t){if(!e||!e.isEditable)return!1;const n=e.state.tr;return Id(n,t)}function Md(e,t){if(!e||!e.isEditable)return!1;try{const{view:n,state:o}=e,{tr:l}=o,s=Td(l,t);return n.dispatch(s),e.commands.focus(),!0}catch{return!1}}function kd(e){const{editor:t,hideWhenUnavailable:n,preserveMarks:o}=e;return!t||!t.isEditable?!1:n&&!t.isActive("code")?hs(t,o):!0}function ps(e){const{editor:t,preserveMarks:n=fs,hideWhenUnavailable:o=!1,onResetAllFormatting:l}=e||{},{editor:s}=S(t),a=ee(),[i,c]=u.useState(!0),d=hs(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(kd({editor:s,hideWhenUnavailable:o,preserveMarks:n}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const f=u.useCallback(()=>{if(!s)return!1;const h=Md(s,n);return h&&l?.(),h},[s,l,n]);return ie.useHotkeys(po,h=>{h.preventDefault(),f()},{enabled:i&&d,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:i,handleResetFormatting:f,canReset:d,label:"Reset formatting",shortcutKeys:po,Icon:us}}function Ed({shortcutKeys:e=Co}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Cs=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,canToggle:h,isActive:p,handleToggle:C,label:b,shortcutKeys:g,Icon:w}=gs({editor:d,hideWhenUnavailable:n,onToggled:o}),v=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&C()},[C,s]);return f?r.jsx(k,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":p,tooltip:"Text",onClick:v,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(Ed,{shortcutKeys:g})]})}):null});Cs.displayName="TextButton";const Co="mod+alt+0";function go(e,t=!0){return!e||!e.schema.nodes.paragraph?!1:t?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().setNode("paragraph")||e.can().clearNodes():!1:e.can().setNode("paragraph")}function Ld(e){return e?e.isActive("paragraph"):!1}function Ad(e){if(!e||!e.isEditable||!go(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const l=Re(e),s=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&l.length===1;if((n.selection.empty||n.selection instanceof M.TextSelection)&&s){const c=Ce({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!K(c))return!1;o=o.setSelection(M.NodeSelection.create(n.doc,c)),t.dispatch(o),n=t.state}const a=n.selection;let i=e.chain().focus();if(a instanceof M.NodeSelection){const c=a.node.firstChild?.firstChild,d=a.node.lastChild?.lastChild,f=c?a.from+c.nodeSize:a.from+1,h=d?a.to-d.nodeSize:a.to-1,p=n.doc.resolve(f),C=n.doc.resolve(h);i=i.setTextSelection(M.TextSelection.between(p,C)).clearNodes()}return e.isActive("paragraph")||i.setNode("paragraph").run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function Hd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Q("paragraph",t)?!1:t.isActive("code")?!0:go(t):!0:!1}function gs(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=go(l),d=Ld(l);u.useEffect(()=>{if(!l)return;const h=()=>{i(Hd({editor:l,hideWhenUnavailable:n}))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=Ad(l);return h&&o?.(),h},[l,o]);return ie.useHotkeys(Co,h=>{h.preventDefault(),f()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,isActive:d,handleToggle:f,canToggle:c,label:"Text",shortcutKeys:Co,Icon:Rn}}function Nd({level:e,shortcutKeys:t=ys[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const bs=u.forwardRef(({editor:e,level:t,text:n,hideWhenUnavailable:o=!1,onToggled:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canToggle:p,isActive:C,handleToggle:b,label:g,Icon:w,shortcutKeys:v}=Vt({editor:f,level:t,hideWhenUnavailable:o,onToggled:l}),m=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&b()},[b,a]);return h?r.jsx(k,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":g,"aria-pressed":C,tooltip:g,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Nd,{level:t,shortcutKeys:v})]})}):null});bs.displayName="HeadingButton";const ws=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),r.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));ws.displayName="HeadingFourIcon";const vs=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));vs.displayName="HeadingFiveIcon";const ms=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));ms.displayName="HeadingSixIcon";const Vd={1:Kn,2:Gn,3:Yn,4:ws,5:vs,6:ms},ys={1:"ctrl+alt+1",2:"ctrl+alt+2",3:"ctrl+alt+3",4:"ctrl+alt+4",5:"ctrl+alt+5",6:"ctrl+alt+6"};function Nt(e,t,n=!0){return!e||!e.isEditable||!Q("heading",e)||re(e,["image"])?!1:n?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?t?e.can().setNode("heading",{level:t})||e.can().clearNodes():e.can().setNode("heading")||e.can().clearNodes():!1:t?e.can().setNode("heading",{level:t}):e.can().setNode("heading")}function Bd(e,t){return!e||!e.isEditable?!1:Array.isArray(t)?t.some(n=>e.isActive("heading",{level:n})):t?e.isActive("heading",{level:t}):e.isActive("heading")}function Dd(e,t){if(!e||!e.isEditable)return!1;const n=Array.isArray(t)?t:[t],o=n.find(l=>Nt(e,l));if(!o)return!1;try{const l=e.view;let s=l.state,a=s.tr;const i=Re(e),c=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&i.length===1;if((s.selection.empty||s.selection instanceof M.TextSelection)&&c){const C=Ce({editor:e,node:s.selection.$anchor.node(1)})?.pos;if(!K(C))return!1;a=a.setSelection(M.NodeSelection.create(s.doc,C)),l.dispatch(a),s=l.state}const d=s.selection;let f=e.chain().focus();if(d instanceof M.NodeSelection){const C=d.node.firstChild?.firstChild,b=d.node.lastChild?.lastChild,g=C?d.from+C.nodeSize:d.from+1,w=b?d.to-b.nodeSize:d.to-1,v=s.doc.resolve(g),m=s.doc.resolve(w);f=f.setTextSelection(M.TextSelection.between(v,m)).clearNodes()}return(n.some(C=>e.isActive("heading",{level:C}))?f.setNode("paragraph"):f.setNode("heading",{level:o})).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function Ud(e){const{editor:t,level:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!Q("heading",t)?!1:t.isActive("code")?!0:Array.isArray(n)?n.some(l=>Nt(t,l)):Nt(t,n):!0:!1}function Vt(e){const{editor:t,level:n,hideWhenUnavailable:o=!1,onToggled:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Nt(s,n),d=Bd(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(Ud({editor:s,level:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=Dd(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleToggle:f,canToggle:c,label:`Heading ${n}`,shortcutKeys:ys[n],Icon:Vd[n]}}function Od({type:e,shortcutKeys:t=xs[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const Bt=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canToggle:p,isActive:C,handleToggle:b,label:g,shortcutKeys:w,Icon:v}=Dt({editor:f,type:t,hideWhenUnavailable:o,onToggled:l}),m=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&b()},[b,a]);return h?r.jsx(k,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":g,"aria-pressed":C,tooltip:g,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Od,{type:t,shortcutKeys:w})]})}):null});Bt.displayName="ListButton";const Pd={bulletList:Xn,orderedList:jn,taskList:Jn},Zd={bulletList:"Bullet List",orderedList:"Ordered List",taskList:"Task List"},xs={bulletList:"mod+shift+8",orderedList:"mod+shift+7",taskList:"mod+shift+9"};function bo(e,t,n=!0){if(!e||!e.isEditable||!Q(t,e)||re(e,["image"]))return!1;if(!n)switch(t){case"bulletList":return e.can().toggleBulletList();case"orderedList":return e.can().toggleOrderedList();case"taskList":return e.can().toggleList("taskList","taskItem");default:return!1}if(!we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"]))return!1;switch(t){case"bulletList":return e.can().toggleBulletList()||e.can().clearNodes();case"orderedList":return e.can().toggleOrderedList()||e.can().clearNodes();case"taskList":return e.can().toggleList("taskList","taskItem")||e.can().clearNodes();default:return!1}}function Fd(e,t){if(!e||!e.isEditable)return!1;switch(t){case"bulletList":return e.isActive("bulletList");case"orderedList":return e.isActive("orderedList");case"taskList":return e.isActive("taskList");default:return!1}}function $d(e,t){if(!e||!e.isEditable||!bo(e,t))return!1;try{const n=e.view;let o=n.state,l=o.tr;const s=Re(e),a=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&s.length===1;if((o.selection.empty||o.selection instanceof M.TextSelection)&&a){const d=Ce({editor:e,node:o.selection.$anchor.node(1)})?.pos;if(!K(d))return!1;l=l.setSelection(M.NodeSelection.create(o.doc,d)),n.dispatch(l),o=n.state}const i=o.selection;let c=e.chain().focus();if(i instanceof M.NodeSelection){const d=i.node.firstChild?.firstChild,f=i.node.lastChild?.lastChild,h=d?i.from+d.nodeSize:i.from+1,p=f?i.to-f.nodeSize:i.to-1,C=o.doc.resolve(h),b=o.doc.resolve(p);c=c.setTextSelection(M.TextSelection.between(C,b)).clearNodes()}if(e.isActive(t))c.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();else{const f={bulletList:()=>c.toggleBulletList(),orderedList:()=>c.toggleOrderedList(),taskList:()=>c.toggleList("taskList","taskItem")}[t];if(!f)return!1;f().run()}return e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function zd(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!Q(n,t)?!1:t.isActive("code")?!0:bo(t,n):!0:!1}function Dt(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=bo(s,n),d=Fd(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(zd({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=$d(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleToggle:f,canToggle:c,label:Zd[n],shortcutKeys:xs[n],Icon:Pd[n]}}function Wd({shortcutKeys:e=Ts}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Ss=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,canToggle:h,isActive:p,handleToggle:C,label:b,shortcutKeys:g,Icon:w}=Is({editor:d,hideWhenUnavailable:n,onToggled:o}),v=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&C()},[C,s]);return f?r.jsx(k,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":p,tooltip:"Blockquote",onClick:v,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(Wd,{shortcutKeys:g})]})}):null});Ss.displayName="BlockquoteButton";const Ts="mod+shift+b";function wo(e,t=!0){return!e||!e.isEditable||!Q("blockquote",e)||re(e,["image"])?!1:t?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleWrap("blockquote")||e.can().clearNodes():!1:e.can().toggleWrap("blockquote")}function _d(e){if(!e||!e.isEditable||!wo(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const l=Re(e),s=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&l.length===1;if((n.selection.empty||n.selection instanceof M.TextSelection)&&s){const d=Ce({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!K(d))return!1;o=o.setSelection(M.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const a=n.selection;let i=e.chain().focus();if(a instanceof M.NodeSelection){const d=a.node.firstChild?.firstChild,f=a.node.lastChild?.lastChild,h=d?a.from+d.nodeSize:a.from+1,p=f?a.to-f.nodeSize:a.to-1,C=n.doc.resolve(h),b=n.doc.resolve(p);i=i.setTextSelection(M.TextSelection.between(C,b)).clearNodes()}return(e.isActive("blockquote")?i.lift("blockquote"):i.wrapIn("blockquote")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function qd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Q("blockquote",t)?!1:t.isActive("code")?!0:wo(t):!0:!1}function Is(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),i=wo(l),c=l?.isActive("blockquote")||!1;u.useEffect(()=>{if(!l)return;const f=()=>{a(qd({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=_d(l);return f&&o?.(),f},[l,o]);return{isVisible:s,isActive:c,handleToggle:d,canToggle:i,label:"Blockquote",shortcutKeys:Ts,Icon:Qn}}function Kd({shortcutKeys:e=ks}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Ms=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,canToggle:h,isActive:p,handleToggle:C,label:b,shortcutKeys:g,Icon:w}=Es({editor:d,hideWhenUnavailable:n,onToggled:o}),v=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&C()},[C,s]);return f?r.jsx(k,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",disabled:!h,"data-disabled":!h,tabIndex:-1,"aria-label":b,"aria-pressed":p,tooltip:"Code Block",onClick:v,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(Kd,{shortcutKeys:g})]})}):null});Ms.displayName="CodeBlockButton";const ks="mod+alt+c";function vo(e,t=!0){return!e||!e.isEditable||!Q("codeBlock",e)||re(e,["image"])?!1:t?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleNode("codeBlock","paragraph")||e.can().clearNodes():!1:e.can().toggleNode("codeBlock","paragraph")}function Gd(e){if(!e||!e.isEditable||!vo(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const l=Re(e),s=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&l.length===1;if((n.selection.empty||n.selection instanceof M.TextSelection)&&s){const d=Ce({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!K(d))return!1;o=o.setSelection(M.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const a=n.selection;let i=e.chain().focus();if(a instanceof M.NodeSelection){const d=a.node.firstChild?.firstChild,f=a.node.lastChild?.lastChild,h=d?a.from+d.nodeSize:a.from+1,p=f?a.to-f.nodeSize:a.to-1,C=n.doc.resolve(h),b=n.doc.resolve(p);i=i.setTextSelection(M.TextSelection.between(C,b)).clearNodes()}return(e.isActive("codeBlock")?i.setNode("paragraph"):i.toggleNode("codeBlock","paragraph")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function Yd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Q("codeBlock",t)?!1:t.isActive("code")?!0:vo(t):!0:!1}function Es(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),i=vo(l),c=l?.isActive("codeBlock")||!1;u.useEffect(()=>{if(!l)return;const f=()=>{a(Yd({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=Gd(l);return f&&o?.(),f},[l,o]);return{isVisible:s,isActive:c,handleToggle:d,canToggle:i,label:"Code Block",shortcutKeys:ks,Icon:qn}}function Xd({shortcutKeys:e=yo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const mo=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:l="/",hideWhenUnavailable:s=!1,onTriggered:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,canInsert:b,handleSlashCommand:g,label:w,shortcutKeys:v,Icon:m}=Jd({editor:p,node:t,nodePos:n,trigger:l,hideWhenUnavailable:s,onTriggered:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":w,tooltip:w,onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o}),i&&r.jsx(Xd,{shortcutKeys:v})]})}):null});mo.displayName="SlashCommandTriggerButton";const Ls=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z",fill:"currentColor"})}));Ls.displayName="PlusIcon";const yo="mod+/";function xo(e,t,n){if(!e||!e.isEditable||re(e,["image"]))return!1;if(t||K(n)){if(K(n)&&n>=0)return!0;if(t)return Ce({editor:e,node:t})!==null}return!0}function jd(e,t="/",n,o){if(!e||!e.isEditable||!xo(e,n,o))return!1;try{if(n!=null||K(o)){const d=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!d)return!1;const f=d.node.type.name==="paragraph"&&d.node.content.size===0,h=f?d.pos:d.pos+d.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,h,h));const p=t.length+1,C=f?d.pos+p:d.pos+d.node.nodeSize+p;return e.commands.focus(C),!0}const{$from:l}=e.state.selection,a=l.node().textContent.length===0,i=l.parentOffset===0,c=l.depth===0;if(!a||!i){const d=c?e.state.doc.content.size:l.after();return e.chain().insertContentAt(d,{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}return e.chain().insertContent({type:"text",text:t}).focus().run()}catch{return!1}}function Qd(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:l}=e;return t?n?t.isEditable?t.isActive("code")?!0:xo(t,o,l):!1:!0:!1}function Jd(e){const{editor:t,node:n,nodePos:o,trigger:l="/",hideWhenUnavailable:s=!1,onTriggered:a}=e||{},{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=xo(i,n,o);u.useEffect(()=>{if(!i)return;const C=()=>{f(Qd({editor:i,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,s,n,o]);const p=u.useCallback(()=>{if(!i)return!1;const C=jd(i,l,n,o);return C&&a?.(l),C},[i,l,n,o,a]);return ie.useHotkeys(yo,C=>{C.preventDefault(),p()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0},[d,h,p]),{isVisible:d,handleSlashCommand:p,canInsert:h,label:"Insert block",shortcutKeys:yo,trigger:l,Icon:Ls}}const As=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M17.293 7.29303C17.6835 6.90251 18.3165 6.90251 18.707 7.29303L22.707 11.293C22.7548 11.3408 22.7976 11.3936 22.835 11.4503C22.8597 11.4877 22.8812 11.5267 22.9004 11.5665C22.9222 11.6117 22.9412 11.6584 22.9561 11.7071C22.9622 11.7274 22.9668 11.748 22.9717 11.7686C22.9893 11.843 23 11.9203 23 12.0001C23 12.0831 22.9878 12.1632 22.9688 12.2403C22.9646 12.2572 22.9611 12.2743 22.9561 12.2911C22.9421 12.337 22.9244 12.3811 22.9043 12.4239C22.8833 12.4686 22.859 12.5119 22.8311 12.5538C22.8185 12.5726 22.8048 12.5905 22.791 12.6085C22.7649 12.6423 22.738 12.6761 22.707 12.7071L18.707 16.7071C18.3165 17.0976 17.6835 17.0975 17.293 16.7071C16.9024 16.3166 16.9025 15.6836 17.293 15.293L19.5859 13.0001H4.41406L6.70703 15.293C7.09747 15.6836 7.09753 16.3166 6.70703 16.7071C6.31654 17.0976 5.6835 17.0975 5.29297 16.7071L1.29297 12.7071C1.26185 12.676 1.23417 12.6424 1.20801 12.6085C1.19423 12.5906 1.18053 12.5726 1.16797 12.5538C1.14006 12.5119 1.11566 12.4686 1.09473 12.4239C1.07465 12.3811 1.0569 12.3369 1.04297 12.2911C1.0379 12.2743 1.03445 12.2572 1.03027 12.2403C1.01124 12.1633 1.00001 12.083 1 12.0001C1 11.9204 1.00974 11.8429 1.02734 11.7686C1.03221 11.7481 1.03678 11.7274 1.04297 11.7071C1.05787 11.6583 1.07777 11.6117 1.09961 11.5665C1.11877 11.5267 1.1403 11.4877 1.16504 11.4503C1.20242 11.3936 1.24516 11.3408 1.29297 11.293L5.29297 7.29303C5.68349 6.90251 6.31651 6.90251 6.70703 7.29303C7.09747 7.68356 7.09753 8.3166 6.70703 8.70709L4.41406 11.0001H19.5859L17.293 8.70709C16.9024 8.31657 16.9025 7.68356 17.293 7.29303Z",fill:"currentColor"})}));As.displayName="MoveHorizontalIcon";const Hs=["table","tableHandleExtension"];function Ut(e){if(!e||!e.isEditable||!V(e,Hs))return!1;try{return e.isActive("table")||e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function Rd(e){if(!Ut(e)||!e)return!1;try{const t=J(e);if(!t)return!1;const n=e.view.dom,o=getComputedStyle(n),l=parseFloat(o.paddingLeft)||0,s=parseFloat(o.paddingRight)||0,a=n.clientWidth-l-s,i=t.map.width;if(i===0)return!1;let c=0;const d=a-i-8;c=Math.floor(d/i);const f=Math.max(c,cr),h=e.state.tr;return t.node.descendants((p,C)=>{if(p.type.name==="tableCell"||p.type.name==="tableHeader"){const b=t.start+C,g=p.attrs.colspan||1,w=Array(g).fill(f);h.setNodeMarkup(b,void 0,{...p.attrs,colwidth:w})}}),h.docChanged&&e.view.dispatch(h),!0}catch(t){return console.error("Error setting table auto width:",t),!1}}function eu({editor:e}){if(!Ut(e)||!e)return!1;try{return Rd(e)}catch(t){return console.error("Error adjusting table width:",t),!1}}function tu({editor:e,hideWhenUnavailable:t}){return!e||!e.isEditable||!V(e,Hs)?!1:t?Ut(e):!0}function Ns(e={}){const{editor:t,hideWhenUnavailable:n=!1,onWidthAdjusted:o}=e,{editor:l}=S(t),s=tu({editor:l,hideWhenUnavailable:n}),a=Ut(l),i=u.useCallback(()=>{const f=eu({editor:l});return f&&o?.(),f},[l,o]);return{isVisible:s,canFitToWidth:a,handleFitToWidth:i,label:"Fit to width",Icon:As}}const nu=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onWidthAdjusted:n,text:o,onClick:l,children:s,...a},i)=>{const{editor:c}=S(e),{isVisible:d,canFitToWidth:f,label:h,Icon:p,handleFitToWidth:C}=Ns({editor:c,hideWhenUnavailable:t,onWidthAdjusted:n}),b=u.useCallback(g=>{l?.(g),!g.defaultPrevented&&C()},[C,l]);return d?r.jsx(k,{type:"button",disabled:!f,variant:"ghost","data-active-state":"off","data-disabled":!f,role:"button",tabIndex:-1,"aria-label":h,tooltip:h,onClick:b,...a,ref:i,children:s??r.jsxs(r.Fragment,{children:[r.jsx(p,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o})]})}):null});nu.displayName="TableFitToWidthButton";function So(e){return!e||!e.isEditable||!V(e,["tocNode"])?!1:re(e,["tocNode"])}function ou(e){if(!e)return!1;try{const{selection:t}=e.state;return t instanceof M.NodeSelection&&t.node.type.name==="tocNode"?t.node.attrs.showTitle===!0:!1}catch{return!1}}function ru(e){if(!e?.isEditable||!So(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof M.NodeSelection&&t.node.type.name==="tocNode"))return!1;const l=t.node.attrs.showTitle===!0;return e.chain().focus().updateAttributes("tocNode",{showTitle:!l}).run()}catch{return!1}}function lu(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable||!V(t,["tocNode"])?!1:n?So(t):!0}function Vs(e){const{editor:t,hideWhenUnavailable:n=!1,onToggle:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),[i,c]=u.useState(!1),d=So(l);u.useEffect(()=>{if(!l)return;const h=()=>{a(lu({editor:l,hideWhenUnavailable:n})),c(ou(l))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=ru(l);return h&&o?.(),h},[l,o]);return{isVisible:s,isActive:i,canToggle:d,handleToggle:f,label:"Show title",Icon:no}}const su=ht.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggle:o,onClick:l,children:s,...a},i)=>{const{editor:c}=S(e),{isVisible:d,isActive:f,canToggle:h,handleToggle:p,label:C,Icon:b}=Vs({editor:c,hideWhenUnavailable:n,onToggle:o}),g=ht.useCallback(w=>{l?.(w),!w.defaultPrevented&&p()},[p,l]);return d?r.jsx(k,{type:"button",variant:"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":C,tooltip:C,onClick:g,...a,ref:i,children:s??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});su.displayName="TocShowTitleButton";const Bs=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z",fill:"currentColor"}),r.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z",fill:"currentColor"}),r.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z",fill:"currentColor"}),r.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z",fill:"currentColor"}),r.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z",fill:"currentColor"}),r.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z",fill:"currentColor"})]}));Bs.displayName="GripVerticalIcon";const To=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 5.29289C5.31658 4.90237 4.68342 4.90237 4.29289 5.29289L1.29289 8.29289C0.902369 8.68342 0.902369 9.31658 1.29289 9.70711C1.68342 10.0976 2.31658 10.0976 2.70711 9.70711L4 8.41421V16C4 16.7956 4.31607 17.5587 4.87868 18.1213C5.44129 18.6839 6.20435 19 7 19H13C13.5523 19 14 18.5523 14 18C14 17.4477 13.5523 17 13 17H7C6.73478 17 6.48043 16.8946 6.29289 16.7071C6.10536 16.5196 6 16.2652 6 16V8.41421L7.29289 9.70711C7.68342 10.0976 8.31658 10.0976 8.70711 9.70711C9.09763 9.31658 9.09763 8.68342 8.70711 8.29289L5.70711 5.29289ZM15.2929 14.2929C15.6834 13.9024 16.3166 13.9024 16.7071 14.2929L18 15.5858V8C18 7.73478 17.8946 7.48043 17.7071 7.29289C17.5196 7.10536 17.2652 7 17 7H11C10.4477 7 10 6.55228 10 6C10 5.44772 10.4477 5 11 5H17C17.7957 5 18.5587 5.31607 19.1213 5.87868C19.6839 6.44129 20 7.20435 20 8V15.5858L21.2929 14.2929C21.6834 13.9024 22.3166 13.9024 22.7071 14.2929C23.0976 14.6834 23.0976 15.3166 22.7071 15.7071L19.7071 18.7071C19.3166 19.0976 18.6834 19.0976 18.2929 18.7071L15.2929 15.7071C14.9024 15.3166 14.9024 14.6834 15.2929 14.2929Z",fill:"currentColor"})}));To.displayName="Repeat2Icon";const au=()=>{const e=gs(),t=Vt({level:1}),n=Vt({level:2}),o=Vt({level:3}),l=Dt({type:"bulletList"}),s=Dt({type:"orderedList"}),a=Dt({type:"taskList"}),i=Is(),c=Es(),d=p=>({icon:p.Icon,label:p.label,onClick:p.handleToggle,disabled:!p.canToggle,isActive:p.isActive}),f=[d(e),...[t,n,o].map(d),d(l),d(s),d(a),d(i),d(c)];return f.every(p=>p.disabled)?null:f},me=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:l=!1,shortcutBadge:s})=>r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:n,disabled:o,children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),s]}),iu=({icon:e,label:t,children:n})=>r.jsx(qe,{placement:"right",trigger:r.jsx(Te,{render:r.jsx(Ge,{render:r.jsxs(k,{variant:"ghost",children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),r.jsx(lt,{}),r.jsx(Xe,{className:"tiptap-button-icon"})]})})}),children:r.jsx(Ke,{portal:!0,children:r.jsx(_e,{children:n})})}),cu=()=>{const e=au(),{canReset:t,handleResetFormatting:n,label:o,Icon:l}=ps({hideWhenUnavailable:!0,preserveMarks:["inlineThread"]});return!e&&!t?null:r.jsxs(r.Fragment,{children:[e&&r.jsx(iu,{icon:To,label:"Turn Into",children:r.jsxs(ae,{children:[r.jsx(nt,{children:"Turn into"}),e.map(s=>r.jsx(me,{...s},s.label))]})}),t&&r.jsx(me,{icon:l,label:o,disabled:!t,onClick:n})]})},du=()=>{const{canFitToWidth:e,handleFitToWidth:t,label:n,Icon:o}=Ns({hideWhenUnavailable:!0}),l=bt({resetAttrs:!0});return r.jsxs(r.Fragment,{children:[e&&r.jsx(me,{icon:o,label:n,disabled:!e,onClick:t}),l.canClearRowColumnContent&&r.jsx(me,{icon:l.Icon,label:"Clear all contents",disabled:!l.canClearRowColumnContent,onClick:l.handleClear})]})},uu=()=>{const{canToggle:e,handleToggle:t,label:n,Icon:o}=Vs({hideWhenUnavailable:!0});return e?r.jsx(me,{icon:o,label:n,disabled:!e,onClick:t}):null},fu=()=>{const{canDownload:e,handleDownload:t,label:n,Icon:o}=_l({hideWhenUnavailable:!0});return e?r.jsx(me,{icon:o,label:n,disabled:!e,onClick:t}):null},hu=()=>{const{handleDuplicate:e,canDuplicate:t,label:n,Icon:o}=Yl(),{handleCopyToClipboard:l,canCopyToClipboard:s,label:a,Icon:i}=Rl(),{handleCopyAnchorLink:c,canCopyAnchorLink:d,label:f,Icon:h}=cs();return r.jsxs(r.Fragment,{children:[r.jsx(R,{orientation:"horizontal"}),r.jsxs(ae,{children:[r.jsx(me,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:r.jsx(ql,{})}),r.jsx(me,{icon:i,label:a,onClick:l,disabled:!s,shortcutBadge:r.jsx(Xl,{})}),r.jsx(me,{icon:h,label:f,onClick:c,disabled:!d,shortcutBadge:r.jsx(rs,{})})]}),r.jsx(R,{orientation:"horizontal"})]})},pu=()=>{const{handleDeleteNode:e,canDeleteNode:t,label:n,Icon:o}=os();return r.jsx(ae,{children:r.jsx(me,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:r.jsx(es,{})})})},Cu=({editor:e,withSlashCommandTrigger:t=!0,mobileBreakpoint:n=768,...o})=>{const{editor:l}=S(e),{isDragging:s}=Gt(l),a=ee("max",n),[i,c]=u.useState(!1),[d,f]=u.useState(null),[h,p]=u.useState(-1),C=u.useCallback(y=>{y.node&&f(y.node),p(y.pos)},[]);u.useEffect(()=>{l&&(l.commands.setLockDragHandle(i),l.commands.setMeta("lockDragHandle",i))},[l,i]);const b=16,g=u.useMemo(()=>({middleware:[D.offset(y=>{const{rects:T}=y,E=T.reference.height,L=T.floating.height,N=E/2-L/2;return{mainAxis:b,crossAxis:E>40?0:N}})]}),[]),w=u.useCallback(()=>{l&&l.commands.setMeta("hideDragHandle",!0)},[l]),v=u.useCallback(y=>{y.stopPropagation(),l&&l.commands.setIsDragging(!0)},[l]),m=u.useCallback(y=>{y.stopPropagation(),l&&(l.commands.setIsDragging(!1),setTimeout(()=>{l.view.dom.blur(),l.view.focus()},0))},[l]);if(!l)return null;const x=Sl(l);return r.jsx("div",{style:{"--drag-handle-main-axis-offset":`${b}px`},children:r.jsx(Ra.DragHandle,{editor:l,onNodeChange:C,computePositionConfig:g,onElementDragStart:v,onElementDragEnd:m,...o,children:r.jsxs("div",{style:{display:"flex",flexDirection:"row",...a||A2(l)?{opacity:0,pointerEvents:"none"}:{},...s?{opacity:0}:{}},children:[t&&r.jsx(mo,{node:d,nodePos:h,"data-weight":"small"}),r.jsx(qe,{open:i,onOpenChange:c,placement:"left",trigger:r.jsx(Ge,{render:r.jsx(k,{variant:"ghost",tabIndex:-1,tooltip:r.jsxs(r.Fragment,{children:[r.jsx("div",{children:"Click for options"}),r.jsx("div",{children:"Hold for drag"})]}),"data-weight":"small",style:{cursor:"grab",...i?{pointerEvents:"none"}:{}},onMouseDown:()=>Rt(l,h),children:r.jsx(Bs,{className:"tiptap-button-icon"})})}),children:r.jsxs(Ke,{onClose:w,autoFocusOnHide:!1,preventBodyScroll:!0,portal:!0,children:[r.jsx(dn,{style:Xt}),r.jsxs(_e,{style:{minWidth:"15rem"},children:[r.jsx(nt,{children:x}),r.jsxs(ae,{children:[r.jsx(uu,{}),r.jsx(kn,{}),r.jsx(Un,{}),r.jsx(du,{}),r.jsx(cu,{}),r.jsx(fu,{})]}),r.jsx(hu,{}),r.jsx(pu,{})]})]})})]})})})},Ds=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",fill:"currentColor"}),r.jsx("path",{d:"M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",fill:"currentColor"}),r.jsx("path",{d:"M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",fill:"currentColor"}),r.jsx("path",{d:"M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",fill:"currentColor"}),r.jsx("path",{d:"M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",fill:"currentColor"}),r.jsx("path",{d:"M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",fill:"currentColor"}),r.jsx("path",{d:"M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",fill:"currentColor"}),r.jsx("path",{d:"M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",fill:"currentColor"})]}));Ds.displayName="SunIcon";const Us=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C10.0222 2 8.08879 2.58649 6.4443 3.6853C4.79981 4.78412 3.51809 6.3459 2.76121 8.17317C2.00433 10.0004 1.8063 12.0111 2.19215 13.9509C2.578 15.8907 3.53041 17.6725 4.92894 19.0711C6.32746 20.4696 8.10929 21.422 10.0491 21.8079C11.9889 22.1937 13.9996 21.9957 15.8268 21.2388C17.6541 20.4819 19.2159 19.2002 20.3147 17.5557C21.4135 15.9112 22 13.9778 22 12C22 11.5955 21.7564 11.2309 21.3827 11.0761C21.009 10.9213 20.5789 11.0069 20.2929 11.2929C19.287 12.2988 17.9226 12.864 16.5 12.864C15.0774 12.864 13.713 12.2988 12.7071 11.2929C11.7012 10.287 11.136 8.92261 11.136 7.5C11.136 6.07739 11.7012 4.71304 12.7071 3.70711C12.9931 3.42111 13.0787 2.99099 12.9239 2.61732C12.7691 2.24364 12.4045 2 12 2ZM7.55544 5.34824C8.27036 4.87055 9.05353 4.51389 9.87357 4.28778C9.39271 5.27979 9.13604 6.37666 9.13604 7.5C9.13604 9.45304 9.91189 11.3261 11.2929 12.7071C12.6739 14.0881 14.547 14.864 16.5 14.864C17.6233 14.864 18.7202 14.6073 19.7122 14.1264C19.4861 14.9465 19.1295 15.7296 18.6518 16.4446C17.7727 17.7602 16.5233 18.7855 15.0615 19.391C13.5997 19.9965 11.9911 20.155 10.4393 19.8463C8.88743 19.5376 7.46197 18.7757 6.34315 17.6569C5.22433 16.538 4.4624 15.1126 4.15372 13.5607C3.84504 12.0089 4.00347 10.4003 4.60897 8.93853C5.21447 7.47672 6.23985 6.22729 7.55544 5.34824Z",fill:"currentColor"}),r.jsx("path",{d:"M19 2C19.5523 2 20 2.44772 20 3V4H21C21.5523 4 22 4.44772 22 5C22 5.55228 21.5523 6 21 6H20V7C20 7.55228 19.5523 8 19 8C18.4477 8 18 7.55228 18 7V6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H18V3C18 2.44772 18.4477 2 19 2Z",fill:"currentColor"})]}));Us.displayName="MoonStarIcon";function gu(){const{editor:e}=u.useContext(P.EditorContext),[t,n]=u.useState(!1);u.useEffect(()=>{const l=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>n(l.matches);return l.addEventListener("change",s),()=>l.removeEventListener("change",s)},[]),u.useEffect(()=>{const l=!!document.querySelector('meta[name="color-scheme"][content="dark"]')||window.matchMedia("(prefers-color-scheme: dark)").matches;n(l)},[]),u.useEffect(()=>{e?.view.dom.closest(".omnibox-editor-root")?.classList.toggle("dark",t)},[e,t]);const o=()=>n(l=>!l);return r.jsx(k,{onClick:o,"aria-label":`Switch to ${t?"light":"dark"} mode`,variant:"ghost",children:t?r.jsx(Us,{className:"tiptap-button-icon"}):r.jsx(Ds,{className:"tiptap-button-icon"})})}function bu({action:e,shortcutKeys:t=Zs[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const Io=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onExecuted:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleAction:p,label:C,canExecute:b,Icon:g,shortcutKeys:w}=xu({editor:f,action:t,hideWhenUnavailable:o,onExecuted:l}),v=u.useCallback(m=>{a?.(m),!m.defaultPrevented&&p()},[p,a]);return h?r.jsx(k,{type:"button",disabled:!b,variant:"ghost","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":C,tooltip:C,onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(bu,{action:t,shortcutKeys:w})]})}):null});Io.displayName="UndoRedoButton";const Os=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));Os.displayName="Redo2Icon";const Ps=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));Ps.displayName="Undo2Icon";const Zs={undo:"mod+z",redo:"mod+shift+z"},wu={undo:"Undo",redo:"Redo"},vu={undo:Ps,redo:Os};function Mo(e,t){return!e||!e.isEditable||re(e,["image"])?!1:t==="undo"?e.can().undo():e.can().redo()}function mu(e,t){if(!e||!e.isEditable||!Mo(e,t))return!1;const n=e.chain().focus();return t==="undo"?n.undo().run():n.redo().run()}function yu(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:Mo(t,o):!1:!0:!1}function xu(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Mo(s,n);u.useEffect(()=>{if(!s)return;const f=()=>{i(yu({editor:s,hideWhenUnavailable:o,action:n}))};return f(),s.on("transaction",f),()=>{s.off("transaction",f)}},[s,o,n]);const d=u.useCallback(()=>{if(!s)return!1;const f=mu(s,n);return f&&l?.(),f},[s,n,l]);return{isVisible:a,handleAction:d,canExecute:c,label:wu[n],shortcutKeys:Zs[n],Icon:vu[n]}}function Su(){return r.jsxs("header",{className:"omnibox-editor-header",children:[r.jsx(lt,{}),r.jsxs("div",{className:"omnibox-editor-header__actions",children:[r.jsxs(ce,{children:[r.jsx(ce,{children:r.jsx(Io,{action:"undo"})}),r.jsx(ce,{children:r.jsx(Io,{action:"redo"})})]}),r.jsx(R,{}),r.jsx(gu,{})]})]})}const Tu=e=>{const t=u.useRef(e);t.current=e,u.useEffect(()=>()=>{t.current()},[])},Iu={leading:!1,trailing:!0};function Fs(e,t=250,n=[],o=Iu){const l=u.useMemo(()=>ei(e,t,o),n);return Tu(()=>{l.cancel()}),l}function $s(){const[e,t]=u.useState({width:0,height:0,offsetTop:0,offsetLeft:0,scale:0}),n=Fs(()=>{if(typeof window>"u")return;const o=window.visualViewport;if(!o)return;const{width:l=0,height:s=0,offsetTop:a=0,offsetLeft:i=0,scale:c=0}=o;t(d=>l===d.width&&s===d.height&&a===d.offsetTop&&i===d.offsetLeft&&c===d.scale?d:{width:l,height:s,offsetTop:a,offsetLeft:i,scale:c})},200);return u.useEffect(()=>{const o=window.visualViewport;if(o)return o.addEventListener("resize",n),n(),()=>{o.removeEventListener("resize",n)}},[n]),e}const zs=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));zs.displayName="BanIcon";const ko=u.forwardRef(({className:e,children:t,...n},o)=>r.jsx(k,{type:"button",className:e,variant:"ghost","data-appearance":"default",role:"button",tabIndex:-1,"aria-label":"Highlight text",tooltip:"Highlight",ref:o,...n,children:t??r.jsx(yt,{className:"tiptap-button-icon"})}));ko.displayName="ColorHighlightPopoverButton";function Ws({editor:e,colors:t=tl(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),useColorValue:n=!1}){const{handleRemoveHighlight:o}=xt({editor:e}),l=ee(),s=u.useRef(null),a=u.useMemo(()=>[...t,{label:"Remove highlight",value:"none"}],[t]),{selectedIndex:i}=St({containerRef:s,items:a,orientation:"both",onSelect:c=>{if(!s.current)return!1;const d=s.current.querySelector('[data-highlighted="true"]');return d&&d.click(),c.value==="none"&&o(),!0},autoSelectFirstItem:!1});return r.jsx(Ue,{ref:s,tabIndex:0,style:l?{boxShadow:"none",border:0}:{},children:r.jsx(Oe,{style:l?{padding:0}:{},children:r.jsxs(Ie,{orientation:"horizontal",children:[r.jsx(ce,{children:t.map((c,d)=>r.jsx(ce,{children:r.jsx(Ye,{editor:e,highlightColor:n?c.colorValue:c.value,tooltip:c.label,"aria-label":`${c.label} highlight color`,tabIndex:d===i?0:-1,"data-highlighted":i===d,useColorValue:n})},c.value))}),r.jsx(R,{}),r.jsx(ce,{children:r.jsx(k,{onClick:o,"aria-label":"Remove highlight",tooltip:"Remove highlight",tabIndex:i===t.length?0:-1,type:"button",role:"menuitem",variant:"ghost","data-highlighted":i===t.length,children:r.jsx(zs,{className:"tiptap-button-icon"})})})]})})})}function Mu({editor:e,colors:t=tl(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),hideWhenUnavailable:n=!1,useColorValue:o=!1,onApplied:l,...s}){const{editor:a}=S(e),[i,c]=u.useState(!1),{isVisible:d,canColorHighlight:f,isActive:h,label:p,Icon:C}=xt({editor:a,hideWhenUnavailable:n,onApplied:l});return d?r.jsxs(Tt,{open:i,onOpenChange:c,children:[r.jsx(It,{asChild:!0,children:r.jsx(ko,{disabled:!f,"data-active-state":h?"on":"off","data-disabled":!f,"aria-pressed":h,"aria-label":p,tooltip:p,...s,children:r.jsx(C,{className:"tiptap-button-icon"})})}),r.jsx(Mt,{"aria-label":"Highlight colors",children:r.jsx(Ws,{editor:a,colors:t,useColorValue:o})})]}):null}function ku({shortcutKeys:e=Lo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Eo=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onInserted:o,showShortcut:l=!1,onClick:s,icon:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canInsert:p,handleImage:C,label:b,isActive:g,shortcutKeys:w,Icon:v}=Hu({editor:f,hideWhenUnavailable:n,onInserted:o}),m=u.useCallback(y=>{s?.(y),!y.defaultPrevented&&C()},[C,s]);if(!h)return null;const x=a??v;return r.jsx(k,{type:"button",variant:"ghost","data-active-state":g?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":b,"aria-pressed":g,tooltip:b,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(x,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(ku,{shortcutKeys:w})]})})});Eo.displayName="ImageUploadButton";const _s=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"})}));_s.displayName="ImagePlusIcon";const Lo="mod+shift+i";function Ao(e){return!e||!e.isEditable||!V(e,"imageUpload")?!1:e.can().insertContent({type:"imageUpload"})}function Eu(e){return!e||!e.isEditable?!1:e.isActive("imageUpload")}function Lu(e){if(!e||!e.isEditable||!Ao(e))return!1;try{return e.chain().focus().insertContent({type:"imageUpload"}).run()}catch{return!1}}function Au(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable?!1:n?V(t,"imageUpload")?t.isActive("code")?!0:Ao(t):!1:!0}function Hu(e){const{editor:t,hideWhenUnavailable:n=!1,onInserted:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=Ao(l),d=Eu(l);u.useEffect(()=>{if(!l)return;const h=()=>{i(Au({editor:l,hideWhenUnavailable:n}))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=Lu(l);return h&&o?.(),h},[l,o]);return ie.useHotkeys(Lo,h=>{h.preventDefault(),f()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,isActive:d,handleImage:f,canInsert:c,label:"Add image",shortcutKeys:Lo,Icon:_s}}const qs=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));qs.displayName="CornerDownLeftIcon";const Ks=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),r.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));Ks.displayName="ExternalLinkIcon";const Ho=u.forwardRef(({className:e,children:t,...n},o)=>r.jsx(k,{type:"button",className:e,variant:"ghost",role:"button",tabIndex:-1,"aria-label":"Link",tooltip:"Link",ref:o,...n,children:t||r.jsx(dt,{className:"tiptap-button-icon"})}));Ho.displayName="LinkButton";const Gs=({url:e,setUrl:t,setLink:n,removeLink:o,openLink:l,isActive:s})=>{const a=ee(),i=c=>{c.key==="Enter"&&(c.preventDefault(),n())};return r.jsx(Ue,{style:{...a?{boxShadow:"none",border:0}:{}},children:r.jsx(Oe,{style:{...a?{padding:0}:{}},children:r.jsxs(Ie,{orientation:"horizontal",children:[r.jsx(A1,{type:"url",placeholder:"Paste a link...",value:e,onChange:c=>t(c.target.value),onKeyDown:i,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:"tiptap-link-input"}),r.jsx(ce,{children:r.jsx(k,{type:"button",onClick:n,title:"Apply link",disabled:!e&&!s,variant:"ghost",children:r.jsx(qs,{className:"tiptap-button-icon"})})}),r.jsx(R,{}),r.jsxs(ce,{children:[r.jsx(ce,{children:r.jsx(k,{type:"button",onClick:l,title:"Open in new window",disabled:!e&&!s,variant:"ghost",children:r.jsx(Ks,{className:"tiptap-button-icon"})})}),r.jsx(ce,{children:r.jsx(k,{type:"button",onClick:o,title:"Remove link",disabled:!e&&!s,variant:"ghost",children:r.jsx(wt,{className:"tiptap-button-icon"})})})]})]})})})},Nu=({editor:e})=>{const t=Xs({editor:e});return r.jsx(Gs,{...t})},No=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onSetLink:n,onOpenChange:o,autoOpenOnLinkActive:l=!0,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),[f,h]=u.useState(!1),{isVisible:p,canSet:C,isActive:b,url:g,setUrl:w,setLink:v,removeLink:m,openLink:x,label:y,Icon:T}=Xs({editor:d,hideWhenUnavailable:t,onSetLink:n}),E=u.useCallback(te=>{h(te),o?.(te)},[o]),L=u.useCallback(()=>{v(),h(!1)},[v]),N=u.useCallback(te=>{s?.(te),!te.defaultPrevented&&h(!f)},[s,f]);return u.useEffect(()=>{l&&b&&h(!0)},[l,b]),p?r.jsxs(Tt,{open:f,onOpenChange:E,children:[r.jsx(It,{asChild:!0,children:r.jsx(Ho,{disabled:!C,"data-active-state":b?"on":"off","data-disabled":!C,"aria-label":y,"aria-pressed":b,onClick:N,...i,ref:c,children:a??r.jsx(T,{className:"tiptap-button-icon"})})}),r.jsx(Mt,{collisionPadding:4,children:r.jsx(Gs,{url:g,setUrl:w,setLink:L,removeLink:m,openLink:x,isActive:b})})]}):null});No.displayName="LinkPopover";function Vo(e){if(!e||!e.isEditable||re(e,["image"],!0))return!1;try{return e.can().setMark("link")}catch{return!1}}function Ys(e){return!e||!e.isEditable?!1:e.isActive("link")}function Vu(e){const{editor:t,hideWhenUnavailable:n}=e;if(!t||!t.isEditable)return!1;const o=xe("link",t);return n?o?t.isActive("code")?!0:Vo(t):!1:!0}function Bu(e){const{editor:t,onSetLink:n}=e,[o,l]=u.useState(null);u.useEffect(()=>{if(!t)return;const{href:c}=t.getAttributes("link");Ys(t)&&o===null&&l(c||"")},[t,o]),u.useEffect(()=>{if(!t)return;const c=()=>{const{href:d}=t.getAttributes("link");l(d||"")};return t.on("selectionUpdate",c),()=>{t.off("selectionUpdate",c)}},[t]);const s=u.useCallback(()=>{if(!o||!t)return;const{selection:c}=t.state,d=c.empty;let f=t.chain().focus();f=f.extendMarkRange("link").setLink({href:o}),d&&(f=f.insertContent({type:"text",text:o})),f.run(),l(null),n?.()},[t,n,o]),a=u.useCallback(()=>{t&&(t.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),l(""))},[t]),i=u.useCallback((c="_blank",d="noopener,noreferrer")=>{if(!o)return;const f=jt(o,window.location.href);f!=="#"&&window.open(f,c,d)},[o]);return{url:o||"",setUrl:l,setLink:s,removeLink:a,openLink:i}}function Du(e){const{editor:t,hideWhenUnavailable:n=!1}=e,o=Vo(t),l=Ys(t),[s,a]=u.useState(!0);return u.useEffect(()=>{if(!t)return;const i=()=>{a(Vu({editor:t,hideWhenUnavailable:n}))};return i(),t.on("selectionUpdate",i),()=>{t.off("selectionUpdate",i)}},[t,n]),{isVisible:s,canSet:o,isActive:l}}function Xs(e){const{editor:t,hideWhenUnavailable:n=!1,onSetLink:o}=e||{},{editor:l}=S(t),{isVisible:s,canSet:a,isActive:i}=Du({editor:l,hideWhenUnavailable:n}),c=Bu({editor:l,onSetLink:o});return{isVisible:s,canSet:a,isActive:i,label:"Link",Icon:dt,...c}}function Uu({type:e,shortcutKeys:t=oa[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const ue=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleMark:p,label:C,canToggle:b,isActive:g,Icon:w,shortcutKeys:v}=zu({editor:f,type:t,hideWhenUnavailable:o,onToggled:l}),m=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&p()},[p,a]);return h?r.jsx(k,{type:"button",disabled:!b,variant:"ghost","data-active-state":g?"on":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":g,tooltip:C,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Uu,{type:t,shortcutKeys:v})]})}):null});ue.displayName="MarkButton";const js=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));js.displayName="BoldIcon";const Qs=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),r.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),r.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));Qs.displayName="Code2Icon";const Js=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));Js.displayName="ItalicIcon";const Rs=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),r.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));Rs.displayName="StrikeIcon";const ea=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));ea.displayName="SubscriptIcon";const ta=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));ta.displayName="SuperscriptIcon";const na=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));na.displayName="UnderlineIcon";const Ou={bold:js,italic:Js,underline:na,strike:Rs,code:Qs,superscript:ta,subscript:ea},oa={bold:"mod+b",italic:"mod+i",underline:"mod+u",strike:"mod+shift+s",code:"mod+e",superscript:"mod+.",subscript:"mod+,"};function Ot(e,t){return!e||!e.isEditable||!xe(t,e)||re(e,["image"])?!1:e.can().toggleMark(t)}function Pu(e,t){return!e||!e.isEditable?!1:e.isActive(t)}function Zu(e,t){return!e||!e.isEditable||!Ot(e,t)?!1:e.chain().focus().toggleMark(t).run()}function Fu(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!xe(n,t)?!1:t.isActive("code")?!0:Ot(t,n):!0:!1}function $u(e){return e.charAt(0).toUpperCase()+e.slice(1)}function zu(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Ot(s,n),d=Pu(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(Fu({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=Zu(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleMark:f,canToggle:c,label:$u(n),shortcutKeys:oa[n],Icon:Ou[n]}}function Wu({align:e,shortcutKeys:t=ra[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const Me=u.forwardRef(({editor:e,align:t,text:n,hideWhenUnavailable:o=!1,onAligned:l,showShortcut:s=!1,onClick:a,icon:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleTextAlign:C,label:b,canAlign:g,isActive:w,Icon:v,shortcutKeys:m}=ju({editor:h,align:t,hideWhenUnavailable:o,onAligned:l}),x=u.useCallback(T=>{a?.(T),!T.defaultPrevented&&C()},[C,a]);if(!p)return null;const y=i??v;return r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":w?"on":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":w,tooltip:b,onClick:x,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(y,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Wu,{align:t,shortcutKeys:m})]})})});Me.displayName="TextAlignButton";const ra={left:"mod+shift+l",center:"mod+shift+e",right:"mod+shift+r",justify:"mod+shift+j"},_u={left:En,center:Ln,right:An,justify:Hn},qu={left:"Align left",center:"Align center",right:"Align right",justify:"Align justify"};function Pt(e,t){return!e||!e.isEditable||!V(e,"textAlign")||re(e,["image","horizontalRule"])?!1:e.can().setTextAlign(t)}function Ku(e){return"setTextAlign"in e}function Gu(e,t){return!e||!e.isEditable?!1:e.isActive({textAlign:t})}function Yu(e,t){if(!e||!e.isEditable||!Pt(e,t))return!1;const n=e.chain().focus();return Ku(n)?n.setTextAlign(t).run():!1}function Xu(e){const{editor:t,hideWhenUnavailable:n,align:o}=e;return t?n?!t.isEditable||!V(t,"textAlign")?!1:t.isActive("code")?!0:Pt(t,o):!0:!1}function ju(e){const{editor:t,align:n,hideWhenUnavailable:o=!1,onAligned:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Pt(s,n),d=Gu(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(Xu({editor:s,align:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const f=u.useCallback(()=>{if(!s)return!1;const h=Yu(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleTextAlign:f,canAlign:c,label:qu[n],shortcutKeys:ra[n],Icon:_u[n]}}const Qu=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z",fill:"currentColor"})}));Qu.displayName="CheckIcon";function la({...e}){return r.jsx(ge.Root,{"data-slot":"tiptap-dropdown-menu",...e})}function sa({...e}){return r.jsx(ge.Portal,{"data-slot":"tiptap-dropdown-menu-portal",...e})}function aa({...e}){return r.jsx(ge.Trigger,{"data-slot":"tiptap-dropdown-menu-trigger",...e})}function ia({className:e,align:t="start",sideOffset:n=4,...o}){return r.jsx(ge.Portal,{children:r.jsx(ge.Content,{"data-slot":"tiptap-dropdown-menu-content",sideOffset:n,align:t,className:U("tiptap-dropdown-menu-content",e),onCloseAutoFocus:l=>l.preventDefault(),...o})})}function Fe({className:e,...t}){return r.jsx(ge.Group,{"data-slot":"tiptap-dropdown-menu-group",className:U("tiptap-dropdown-menu-group",e),...t})}function de({className:e,inset:t,variant:n="default",...o}){return r.jsx(ge.Item,{"data-slot":"tiptap-dropdown-menu-item","data-inset":t,"data-variant":n,className:U("tiptap-dropdown-menu-item",e),...o})}function ut({className:e,inset:t,...n}){return r.jsx(ge.Label,{"data-slot":"tiptap-dropdown-menu-label","data-inset":t,className:U("tiptap-dropdown-menu-label",e),...n})}function ca({...e}){return r.jsx(ge.Sub,{"data-slot":"tiptap-dropdown-menu-sub",...e})}function da({className:e,inset:t,children:n,...o}){return r.jsx(ge.SubTrigger,{"data-slot":"tiptap-dropdown-menu-sub-trigger","data-inset":t,className:U("tiptap-dropdown-menu-sub-trigger",e),...o,children:n})}function ua({className:e,...t}){return r.jsx(ge.SubContent,{"data-slot":"tiptap-dropdown-menu-sub-content",className:U("tiptap-dropdown-menu-sub-content",e),...t})}function fa({blockTypes:e,editor:t}){const n=Zt(e);return r.jsxs(Fe,{children:[r.jsx(ut,{children:"Turn into"}),n.map((o,l)=>Ju(o,`${o.type}-${o.level??l}`,t))]})}function Ju(e,t,n){switch(e.type){case"paragraph":return r.jsx(de,{asChild:!0,children:r.jsx(Cs,{editor:n,showTooltip:!1,text:e.label})},t);case"heading":return e.level?r.jsx(de,{asChild:!0,children:r.jsx(bs,{editor:n,level:e.level,showTooltip:!1,text:e.label})},t):null;case"bulletList":return r.jsx(de,{asChild:!0,children:r.jsx(Bt,{editor:n,type:"bulletList",showTooltip:!1,text:e.label})},t);case"orderedList":return r.jsx(de,{asChild:!0,children:r.jsx(Bt,{editor:n,type:"orderedList",showTooltip:!1,text:e.label})},t);case"taskList":return r.jsx(de,{asChild:!0,children:r.jsx(Bt,{editor:n,type:"taskList",showTooltip:!1,text:e.label})},t);case"blockquote":return r.jsx(de,{asChild:!0,children:r.jsx(Ss,{editor:n,showTooltip:!1,text:e.label})},t);case"codeBlock":return r.jsx(de,{asChild:!0,children:r.jsx(Ms,{editor:n,showTooltip:!1,text:e.label})},t);default:return null}}const ha=u.forwardRef(function({editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:l,modal:s=!0,children:a,...i},c){const{editor:d}=S(t),{isVisible:f,canToggle:h,isOpen:p,activeBlockType:C,handleOpenChange:b,label:g,Icon:w}=n7({editor:d,hideWhenUnavailable:n,blockTypes:o,onOpenChange:l});return f?r.jsxs(la,{modal:s,open:p,onOpenChange:b,children:[r.jsx(aa,{asChild:!0,children:r.jsx(k,{type:"button",variant:"ghost",disabled:!h,"data-disabled":!h,role:"button",tabIndex:-1,"aria-label":g,tooltip:"Turn into",...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-text",children:C?.label||"Text"}),r.jsx(w,{className:"tiptap-button-dropdown-small"})]})})}),r.jsx(ia,{align:"start",children:r.jsx(fa,{blockTypes:o,editor:d})})]}):null});ha.displayName="TurnIntoDropdown";const Ru=["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"],pa=[{type:"paragraph",label:"Text",isActive:e=>e.isActive("paragraph")&&!e.isActive("heading")&&!e.isActive("bulletList")&&!e.isActive("orderedList")&&!e.isActive("taskList")&&!e.isActive("blockquote")&&!e.isActive("codeBlock")},{type:"heading",label:"Heading 1",level:1,isActive:e=>e.isActive("heading",{level:1})},{type:"heading",label:"Heading 2",level:2,isActive:e=>e.isActive("heading",{level:2})},{type:"heading",label:"Heading 3",level:3,isActive:e=>e.isActive("heading",{level:3})},{type:"bulletList",label:"Bulleted list",isActive:e=>e.isActive("bulletList")},{type:"orderedList",label:"Numbered list",isActive:e=>e.isActive("orderedList")},{type:"taskList",label:"To-do list",isActive:e=>e.isActive("taskList")},{type:"blockquote",label:"Blockquote",isActive:e=>e.isActive("blockquote")},{type:"codeBlock",label:"Code block",isActive:e=>e.isActive("codeBlock")}];function Ca(e,t){if(!e||!e.isEditable)return!1;const n=t||Ru,{selection:o}=e.state;if(o instanceof M.NodeSelection){const a=o.node.type.name;return n.includes(a)}const{$anchor:l}=o,s=l.parent.type.name;return n.includes(s)}function Zt(e){return e?pa.filter(t=>e.includes(t.type)):pa}function e7(e,t){if(!e)return Zt(t)[0];const n=Zt(t);return n.find(l=>l.isActive(e))||n[0]}function t7(e){const{editor:t,hideWhenUnavailable:n,blockTypes:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:Ca(t,o):!1:!0:!1}function n7(e){const{editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:l}=e||{},{editor:s}=S(t),[a,i]=u.useState(!1),[c,d]=u.useState(!0),f=Ca(s,o),h=e7(s,o),p=u.useCallback(C=>{!s||!f||(i(C),l?.(C))},[f,s,l]);return u.useEffect(()=>{if(!s)return;const C=()=>{d(t7({editor:s,hideWhenUnavailable:n,blockTypes:o}))};return C(),s.on("selectionUpdate",C),()=>{s.off("selectionUpdate",C)}},[s,n,o]),{isVisible:c,canToggle:f,isOpen:a,setIsOpen:i,activeBlockType:h,handleOpenChange:p,filteredOptions:Zt(o),label:`Turn into (current: ${h?.label||"Text"})`,Icon:In}}function o7({action:e,shortcutKeys:t=wa[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const ft=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onIndented:l,showShortcut:s=!1,onClick:a,icon:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleIndent:C,label:b,canIndent:g,Icon:w,shortcutKeys:v}=i7({editor:h,action:t,hideWhenUnavailable:o,onIndented:l}),m=u.useCallback(y=>{a?.(y),!y.defaultPrevented&&C()},[C,a]);if(!p)return null;const x=i??w;return r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,tooltip:b,onClick:m,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(x,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(o7,{action:t,shortcutKeys:v})]})})});ft.displayName="IndentButton";const ga=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M17.0002 18.5C17.5524 18.5 18.0002 18.9477 18.0002 19.5C18.0002 20.0523 17.5524 20.5 17.0002 20.5H11.0002C10.4479 20.5 10.0002 20.0523 10.0002 19.5C10.0002 18.9477 10.4479 18.5 11.0002 18.5H17.0002Z",fill:"currentColor"}),r.jsx("path",{d:"M2.29314 8.29297C2.68366 7.90248 3.31669 7.90246 3.7072 8.29297L6.7072 11.293L6.77556 11.3691C7.09586 11.7619 7.07327 12.3409 6.7072 12.707L3.7072 15.707C3.31669 16.0975 2.68367 16.0975 2.29314 15.707C1.90261 15.3165 1.90261 14.6835 2.29314 14.293L4.58611 12L2.29314 9.70703C1.90261 9.31651 1.90261 8.68349 2.29314 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0002 13.5C21.5524 13.5 22.0002 13.9477 22.0002 14.5C22.0002 15.0523 21.5524 15.5 21.0002 15.5H11.0002C10.4479 15.5 10.0002 15.0523 10.0002 14.5C10.0002 13.9477 10.4479 13.5 11.0002 13.5H21.0002Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0002 8.5C21.5524 8.50004 22.0002 8.94774 22.0002 9.5C22.0002 10.0523 21.5524 10.5 21.0002 10.5H11.0002C10.4479 10.5 10.0002 10.0523 10.0002 9.5C10.0002 8.94772 10.4479 8.5 11.0002 8.5H21.0002Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0002 3.5C21.5524 3.50004 22.0002 3.94774 22.0002 4.5C22.0002 5.05226 21.5524 5.49996 21.0002 5.5H11.0002C10.4479 5.5 10.0002 5.05228 10.0002 4.5C10.0002 3.94772 10.4479 3.5 11.0002 3.5H21.0002Z",fill:"currentColor"})]}));ga.displayName="IndentIncreaseIcon";const ba=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M9 18.5C9.55228 18.5 10 18.9477 10 19.5C10 20.0523 9.55228 20.5 9 20.5H3C2.44772 20.5 2 20.0523 2 19.5C2 18.9477 2.44772 18.5 3 18.5H9Z",fill:"currentColor"}),r.jsx("path",{d:"M20.293 8.29297C20.6835 7.90244 21.3165 7.90244 21.707 8.29297C22.0976 8.68349 22.0976 9.31651 21.707 9.70703L19.4141 12L21.707 14.293C22.0976 14.6835 22.0976 15.3165 21.707 15.707C21.3165 16.0976 20.6835 16.0976 20.293 15.707L17.293 12.707L17.2246 12.6309C16.9043 12.2381 16.9269 11.6591 17.293 11.293L20.293 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M13 13.5C13.5523 13.5 14 13.9477 14 14.5C14 15.0523 13.5523 15.5 13 15.5H3C2.44772 15.5 2 15.0523 2 14.5C2 13.9477 2.44772 13.5 3 13.5H13Z",fill:"currentColor"}),r.jsx("path",{d:"M13 8.5C13.5523 8.5 14 8.94772 14 9.5C14 10.0523 13.5523 10.5 13 10.5H3C2.44772 10.5 2 10.0523 2 9.5C2 8.94772 2.44772 8.5 3 8.5H13Z",fill:"currentColor"}),r.jsx("path",{d:"M13 3.5C13.5523 3.5 14 3.94772 14 4.5C14 5.05228 13.5523 5.5 13 5.5H3C2.44772 5.5 2 5.05228 2 4.5C2 3.94772 2.44772 3.5 3 3.5H13Z",fill:"currentColor"})]}));ba.displayName="IndentDecreaseIcon";const wa={indent:"Tab",outdent:"Shift-Tab"},r7={indent:ga,outdent:ba},l7={indent:"Increase indent",outdent:"Decrease indent"};function Bo(e,t){return!e||!e.isEditable||!V(e,"indent")?!1:t==="indent"?e.can().indent():e.can().outdent()}function s7(e,t){return!e||!e.isEditable||!Bo(e,t)?!1:t==="indent"?e.chain().focus().indent().run():e.chain().focus().outdent().run()}function a7(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?!t.isEditable||!V(t,"indent")?!1:Bo(t,o):!0:!1}function i7(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onIndented:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Bo(s,n);u.useEffect(()=>{if(!s)return;const f=()=>{i(a7({editor:s,action:n,hideWhenUnavailable:o}))};return f(),s.on("selectionUpdate",f),s.on("transaction",f),()=>{s.off("selectionUpdate",f),s.off("transaction",f)}},[s,o,n]);const d=u.useCallback(()=>{if(!s)return!1;const f=s7(s,n);return f&&l?.(),f},[s,n,l]);return{isVisible:a,canIndent:c,handleIndent:d,label:l7[n],shortcutKeys:wa[n],Icon:r7[n]}}const c7=e=>{const[t,n]=u.useState([]),o=u.useCallback(()=>e.current?Array.from(e.current.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')):[],[e]);u.useEffect(()=>{const s=e.current;if(!s)return;const a=()=>n(o());a();const i=new MutationObserver(a);return i.observe(s,{childList:!0,subtree:!0}),()=>i.disconnect()},[o,e]);const{selectedIndex:l}=St({containerRef:e,items:t,orientation:"horizontal",onSelect:s=>s.click(),autoSelectFirstItem:!1});u.useEffect(()=>{const s=e.current;if(!s)return;const a=c=>{const d=c.target;s.contains(d)&&d.setAttribute("data-focus-visible","true")},i=c=>{const d=c.target;s.contains(d)&&d.removeAttribute("data-focus-visible")};return s.addEventListener("focus",a,!0),s.addEventListener("blur",i,!0),()=>{s.removeEventListener("focus",a,!0),s.removeEventListener("blur",i,!0)}},[e]),u.useEffect(()=>{l!==void 0&&t[l]&&t[l].focus()},[l,t])},Ft=u.forwardRef(({children:e,className:t,variant:n="fixed",...o},l)=>{const s=u.useRef(null),a=Mr(s,l);return c7(s),r.jsx("div",{ref:a,role:"toolbar","aria-label":"toolbar","data-variant":n,className:U("tiptap-toolbar",t),...o,children:e})});Ft.displayName="Toolbar";const le=u.forwardRef(({children:e,className:t,...n},o)=>r.jsx("div",{ref:o,role:"group",className:U("tiptap-toolbar-group",t),...n,children:e}));le.displayName="ToolbarGroup";const fe=u.forwardRef(({...e},t)=>r.jsx(R,{ref:t,orientation:"vertical",decorative:!0,...e}));fe.displayName="ToolbarSeparator";function d7({shortcutKeys:e}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Do=u.forwardRef(({editor:e,text:t,direction:n,hideWhenUnavailable:o=!1,onMoved:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleMoveNode:p,canMoveNode:C,label:b,shortcutKeys:g,Icon:w}=C7({editor:f,direction:n,hideWhenUnavailable:o,onMoved:l}),v=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&p()},[p,a]);if(!h)return null;const m=n==="up"?"Move Up":"Move Down";return r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":b,tooltip:m,disabled:!C,onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),s&&r.jsx(d7,{shortcutKeys:g})]})})});Do.displayName="MoveNodeButton";const u7="mod+shift+ArrowUp",f7="mod+shift+ArrowDown";function va(e,t){if(!e||!e.isEditable)return!1;const n=et(e);if(!n)return!1;try{const{pos:o}=n,l=e.state.doc.resolve(o),s=l.parent,a=l.index();return t==="up"?a>0:a<s.childCount-1}catch{return!1}}function h7(e,t){if(!e||!e.isEditable)return!1;const n=et(e);if(!n)return!1;try{const{pos:o,node:l}=n,s=e.state.tr,a=s.doc.resolve(o),i=a.parent,c=a.index();if(c<0||c>=i.childCount)return!1;if(t==="up"&&c>0){const f=i.child(c-1).nodeSize,h=l.type.create(l.attrs,l.content,l.marks);s.deleteRange(o,o+l.nodeSize);const p=o-f;s.insert(p,h),s.setSelection(M.TextSelection.near(s.doc.resolve(p)))}else if(t==="down"&&c<i.childCount-1){const f=i.child(c+1).nodeSize,h=l.type.create(l.attrs,l.content,l.marks);s.deleteRange(o,o+l.nodeSize);const p=o+f;s.insert(p,h),s.setSelection(M.TextSelection.near(s.doc.resolve(p)))}else return!1;return e.view.dispatch(s),!0}catch(o){return console.error("Error moving node:",o),!1}}function p7(e){const{editor:t,direction:n,hideWhenUnavailable:o}=e;if(!t)return!1;if(!o)return!0;if(!t.isEditable)return!1;const l=!!et(t),s=va(t,n);return l&&s}function C7(e){const{editor:t,hideWhenUnavailable:n=!1,direction:o,onMoved:l}=e,{editor:s}=S(t),a=ee(),[i,c]=u.useState(!0),[d,f]=u.useState(!1),h=u.useCallback(()=>{if(!d)return!1;const g=h7(s,o);return g&&l?.(o),g},[s,o,l,d]);u.useEffect(()=>{if(!s)return;const g=()=>{c(p7({editor:s,direction:o,hideWhenUnavailable:n})),f(va(s,o))};return g(),s.on("selectionUpdate",g),()=>{s.off("selectionUpdate",g)}},[s,o,n]);const p=o==="up"?u7:f7;return ie.useHotkeys(p,g=>{g.preventDefault(),h()},{enabled:i&&d,enableOnContentEditable:!a,enableOnFormTags:!0},[h,i,d,a]),{isVisible:i,handleMoveNode:h,canMoveNode:d,label:o==="up"?"Move Up":"Move Down",shortcutKeys:p,Icon:o==="up"?Vn:Nn}}const $t={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0},ma=typeof window>"u",g7=!ma&&typeof ResizeObserver<"u",zt=()=>!ma;function b7({element:e,enabled:t=!0,throttleMs:n=100,useResizeObserver:o=!0}={}){const[l,s]=u.useState($t),a=u.useCallback(()=>!t||!zt()?null:e?typeof e=="string"?document.querySelector(e):"current"in e?e.current:e:document.body,[e,t]),i=Fs(()=>{if(!t||!zt())return;const c=a();if(!c){s($t);return}const d=c.getBoundingClientRect();s({x:d.x,y:d.y,width:d.width,height:d.height,top:d.top,right:d.right,bottom:d.bottom,left:d.left})},n,[t,a],{leading:!0,trailing:!0});return u.useEffect(()=>{if(!t||!zt()){s($t);return}const c=a();if(!c)return;i();const d=[];if(o&&g7){const h=new ResizeObserver(()=>{window.requestAnimationFrame(i)});h.observe(c),d.push(()=>h.disconnect())}const f=()=>i();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f,!0),d.push(()=>{window.removeEventListener("scroll",f),window.removeEventListener("resize",f)}),()=>{d.forEach(h=>h()),s($t)}},[t,a,i,o]),l}function w7(e={}){return b7({...e,element:zt()?document.body:null})}function v7({editor:e,overlayHeight:t=0}){const{height:n}=$s(),o=w7({enabled:!0,throttleMs:100,useResizeObserver:!0});return u.useEffect(()=>{(()=>{if(!e)return;const{state:s,view:a}=e;if(!a.hasFocus())return;const{from:i}=s.selection,c=a.coordsAtPos(i);if(n<o.height&&c&&n-c.top<t){const f=Math.max(n/2,t),h=window.scrollY,C=c.top+h-f;window.scrollTo({top:Math.max(0,C),behavior:"smooth"})}})()},[e,t,n,o.height]),o}function m7({align:e,shortcutKeys:t=Uo[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const Wt=u.forwardRef(({editor:e,align:t,text:n,extensionName:o,attributeName:l="data-align",hideWhenUnavailable:s=!1,onAligned:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,handleImageAlign:b,label:g,canAlign:w,isActive:v,Icon:m,shortcutKeys:x}=M7({editor:p,align:t,extensionName:o,attributeName:l,hideWhenUnavailable:s,onAligned:a}),y=u.useCallback(T=>{c?.(T),!T.defaultPrevented&&b()},[b,c]);return C?r.jsx(k,{type:"button",disabled:!w,variant:"ghost","data-active-state":v?"on":"off","data-disabled":!w,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":v,tooltip:g,onClick:y,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),i?r.jsx(m7,{align:t,shortcutKeys:x}):null]})}):null});Wt.displayName="ImageAlignButton";const ya=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V22C13 22.5523 12.5523 23 12 23C11.4477 23 11 22.5523 11 22V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),r.jsx("path",{d:"M2 7C2 5.34315 3.34315 4 5 4H7C7.55228 4 8 4.44772 8 5C8 5.55228 7.55228 6 7 6H5C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H7C7.55228 18 8 18.4477 8 19C8 19.5523 7.55228 20 7 20H5C3.34315 20 2 18.6569 2 17V7Z",fill:"currentColor"}),r.jsx("path",{d:"M19 4C20.6569 4 22 5.34315 22 7V17C22 18.6569 20.6569 20 19 20H17C16.4477 20 16 19.5523 16 19C16 18.4477 16.4477 18 17 18H19C19.5523 18 20 17.5523 20 17V7C20 6.44772 19.5523 6 19 6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H19Z",fill:"currentColor"})]}));ya.displayName="AlignCenterVerticalIcon";const xa=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 1C21.5523 1 22 1.44772 22 2V22C22 22.5523 21.5523 23 21 23C20.4477 23 20 22.5523 20 22V2C20 1.44772 20.4477 1 21 1Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 7C2 5.34315 3.34315 4 5 4H14C15.6569 4 17 5.34315 17 7V17C17 18.6569 15.6569 20 14 20H5C3.34315 20 2 18.6569 2 17V7ZM5 6C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H14C14.5523 18 15 17.5523 15 17V7C15 6.44772 14.5523 6 14 6H5Z",fill:"currentColor"})]}));xa.displayName="AlignEndVerticalIcon";const Sa=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 2C4 1.44772 3.55228 1 3 1C2.44772 1 2 1.44772 2 2V22C2 22.5523 2.44772 23 3 23C3.55228 23 4 22.5523 4 22V2Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 4C8.34315 4 7 5.34315 7 7V17C7 18.6569 8.34315 20 10 20H19C20.6569 20 22 18.6569 22 17V7C22 5.34315 20.6569 4 19 4H10ZM9 7C9 6.44772 9.44772 6 10 6H19C19.5523 6 20 6.44772 20 7V17C20 17.5523 19.5523 18 19 18H10C9.44772 18 9 17.5523 9 17V7Z",fill:"currentColor"})]}));Sa.displayName="AlignStartVerticalIcon";const Uo={left:"alt+shift+l",center:"alt+shift+e",right:"alt+shift+r"},y7={left:Sa,center:ya,right:xa},x7={left:"Image align left",center:"Image align center",right:"Image align right"};function Oo(e,t,n="image",o="data-align"){return!e||!e.isEditable||!V(e,[n])?!1:e.can().updateAttributes(n,{[o]:t})}function S7(e,t,n="image",o="data-align"){return!e||!e.isEditable||!V(e,[n])?!1:(e.getAttributes(n)[o]||"left")===t}function T7(e,t,n="image",o="data-align"){if(!e?.isEditable||!V(e,[n])||!Oo(e,t,n,o))return!1;try{const{selection:l}=e.state,s=l instanceof M.NodeSelection,a=s?l.from:l.$anchor.pos,i=e.chain().focus().updateAttributes(n,{[o]:t}).run();return i&&s&&e.commands.setNodeSelection(a),i}catch{return!1}}function I7(e){const{editor:t,hideWhenUnavailable:n,align:o,extensionName:l="image",attributeName:s="data-align"}=e;return!t||!t.isEditable?!1:n?V(t,[l])?Oo(t,o,l,s):!1:!0}function M7(e){const{editor:t,align:n,extensionName:o="image",attributeName:l="data-align",hideWhenUnavailable:s=!1,onAligned:a}=e,{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=Oo(i,n,o,l),p=S7(i,n,o,l);u.useEffect(()=>{if(!i)return;const b=()=>{f(I7({editor:i,align:n,hideWhenUnavailable:s,extensionName:o,attributeName:l}))};return b(),i.on("selectionUpdate",b),()=>{i.off("selectionUpdate",b)}},[i,s,n,o,l]);const C=u.useCallback(()=>{if(!i)return!1;const b=T7(i,n,o,l);return b&&a?.(),b},[i,n,o,l,a]);return ie.useHotkeys(Uo[n],b=>{b.preventDefault(),C()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,isActive:p,handleImageAlign:C,canAlign:h,label:x7[n],shortcutKeys:Uo[n],Icon:y7[n]}}const Ta=ht.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onSet:o,onClick:l,children:s,...a},i)=>{const{editor:c}=S(e),{isVisible:d,isActive:f,canToggle:h,handleSetCaption:p,label:C,Icon:b}=A7({editor:c,hideWhenUnavailable:n,onSet:o}),g=ht.useCallback(w=>{l?.(w),!w.defaultPrevented&&p()},[p,l]);return d?r.jsx(k,{type:"button",variant:"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":C,tooltip:C,onClick:g,...a,ref:i,children:s??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});Ta.displayName="ImageCaptionButton";const Ia=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 22C7 21.4477 7.44772 21 8 21H16C16.5523 21 17 21.4477 17 22C17 22.5523 16.5523 23 16 23H8C7.44772 23 7 22.5523 7 22Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 18C3 17.4477 3.44772 17 4 17H20C20.5523 17 21 17.4477 21 18C21 18.5523 20.5523 19 20 19H4C3.44772 19 3 18.5523 3 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 5C3 3.34315 4.34315 2 6 2H18C19.6569 2 21 3.34315 21 5V11C21 12.6569 19.6569 14 18 14H6C4.34315 14 3 12.6569 3 11V5ZM6 4C5.44772 4 5 4.44772 5 5V11C5 11.5523 5.44772 12 6 12H18C18.5523 12 19 11.5523 19 11V5C19 4.44772 18.5523 4 18 4H6Z",fill:"currentColor"})]}));Ia.displayName="ImageCaptionIcon";function Po(e){return!e||!e.isEditable||!V(e,["image"])?!1:re(e,["image"])}function k7(e){if(!e)return!1;try{const{selection:t}=e.state;if(!(t instanceof M.NodeSelection&&t.node.type.name==="image"))return!1;const o=t.node;return o.attrs.showCaption===!0||o.content.size>0}catch{return!1}}function E7(e){if(!e?.isEditable||!Po(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof M.NodeSelection&&t.node.type.name==="image")||!e.chain().focus().updateAttributes("image",{showCaption:!0}).run())return!1;const l=t.from;return e.chain().focus(l+1).selectTextblockEnd().run(),!0}catch{return!1}}function L7(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!V(t,["image"])?!1:Po(t):!0:!1}function A7(e){const{editor:t,hideWhenUnavailable:n=!1,onSet:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),[i,c]=u.useState(!1),d=Po(l);u.useEffect(()=>{if(!l)return;const h=()=>{a(L7({editor:l,hideWhenUnavailable:n})),c(k7(l))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=E7(l);return h&&o?.(),h},[l,o]);return{isVisible:s,isActive:i,canToggle:d,handleSetCaption:f,label:"Caption",Icon:Ia}}const Ma=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41416L5.96091 6.45325C7.58323 4.88786 9.74725 4.00897 12.0018 4.00001C14.1229 4.0005 16.1569 4.8433 17.6568 6.34315C19.1571 7.84344 19.9999 9.87827 19.9999 12C19.9999 12.5523 20.4477 13 20.9999 13C21.5522 13 21.9999 12.5523 21.9999 12C21.9999 9.34784 20.9464 6.8043 19.071 4.92894C17.1956 3.05358 14.6521 2.00001 11.9999 2L11.9962 2.00001C9.22207 2.01045 6.5594 3.0929 4.5649 5.02104L4.55283 5.0329L4 5.58573V3Z",fill:"currentColor"}),r.jsx("path",{d:"M3 11C3.55228 11 4 11.4477 4 12C4 14.1217 4.84285 16.1566 6.34315 17.6569C7.84297 19.1567 9.87701 19.9995 11.998 20C14.2526 19.9911 16.4167 19.1122 18.039 17.5468L18.5858 17H16C15.4477 17 15 16.5523 15 16C15 15.4477 15.4477 15 16 15H21C21.5523 15 22 15.4477 22 16V21C22 21.5523 21.5523 22 21 22C20.4477 22 20 21.5523 20 21V18.4142L19.4471 18.9671L19.435 18.979C17.4405 20.9071 14.7779 21.9896 12.0038 22L12 22C9.34784 22 6.8043 20.9464 4.92893 19.0711C3.05357 17.1957 2 14.6522 2 12C2 11.4477 2.44772 11 3 11Z",fill:"currentColor"})]}));Ma.displayName="RefreshCcwIcon";function ka({editor:e}){const{editor:t}=S(e),n=re(t,["image"]);return!t||!n?null:r.jsxs(r.Fragment,{children:[r.jsx(Wt,{align:"left"}),r.jsx(Wt,{align:"center"}),r.jsx(Wt,{align:"right"}),r.jsx(R,{}),r.jsx(Ta,{}),r.jsx(R,{}),r.jsx(Pl,{}),r.jsx(Eo,{icon:Ma,tooltip:"Replace"}),r.jsx(R,{}),r.jsx(uo,{})]})}const ke={MAIN:"main",HIGHLIGHTER:"highlighter",LINK:"link"};function H7(e){const[t,n]=u.useState(ke.MAIN);return u.useEffect(()=>{!e&&t!==ke.MAIN&&n(ke.MAIN)},[e,t]),{viewId:t,setViewId:n,isMainView:t===ke.MAIN,showMainView:()=>n(ke.MAIN),showView:o=>n(o)}}function N7(e){if(!e||!e.isEditable)return!1;const{selection:t}=e.state;return!t.empty}function V7(){return{[ke.HIGHLIGHTER]:{id:ke.HIGHLIGHTER,title:"Text Highlighter",icon:r.jsx(yt,{className:"tiptap-button-icon"}),content:r.jsx(Ws,{}),mobileButton:e=>r.jsx(ko,{onClick:e}),desktopComponent:r.jsx(Mu,{}),shouldShow(e){return De(e)}},[ke.LINK]:{id:ke.LINK,title:"Link Editor",icon:r.jsx(dt,{className:"tiptap-button-icon"}),content:r.jsx(Nu,{}),mobileButton:e=>r.jsx(Ho,{onClick:e}),desktopComponent:r.jsx(No,{}),shouldShow(e){return Vo(e)}}}}function B7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(ft,{action:"outdent",hideWhenUnavailable:!0}),r.jsx(ft,{action:"indent",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function D7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(Me,{align:"left",hideWhenUnavailable:!0}),r.jsx(Me,{align:"center",hideWhenUnavailable:!0}),r.jsx(Me,{align:"right",hideWhenUnavailable:!0}),r.jsx(Me,{align:"justify",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function U7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(ue,{type:"superscript",hideWhenUnavailable:!0}),r.jsx(ue,{type:"subscript",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function O7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(ue,{type:"bold",hideWhenUnavailable:!0}),r.jsx(ue,{type:"italic",hideWhenUnavailable:!0}),r.jsx(ue,{type:"strike",hideWhenUnavailable:!0}),r.jsx(ue,{type:"code",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function P7(){const{recentColors:e,isInitialized:t,addRecentColor:n}=ct(),o=()=>!t||e.length===0?null:r.jsxs(r.Fragment,{children:[r.jsxs(Fe,{children:[r.jsx(ut,{children:"Recent colors"}),e.map(l=>r.jsx(de,{asChild:!0,children:l.type==="text"?r.jsx(st,{textColor:l.value,label:l.label,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"text",label:a,value:s})}):r.jsx(Ye,{highlightColor:l.value,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"highlight",label:a,value:s})})},`${l.type}-${l.value}`))]}),r.jsx(R,{orientation:"horizontal"})]});return r.jsxs(ca,{children:[r.jsx(da,{asChild:!0,children:r.jsxs(k,{variant:"ghost",children:[r.jsx(Mn,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:"Color"}),r.jsx(lt,{}),r.jsx(Xe,{className:"tiptap-button-icon"})]})}),r.jsx(sa,{children:r.jsxs(ua,{children:[o(),r.jsxs(Fe,{children:[r.jsx(ut,{children:"Text color"}),at.map(l=>r.jsx(de,{asChild:!0,children:r.jsx(st,{textColor:l.value,label:l.label,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"text",label:a,value:s})})},l.value))]}),r.jsx(R,{orientation:"horizontal"}),r.jsxs(Fe,{children:[r.jsx(ut,{children:"Highlight color"}),Be.map(l=>r.jsx(de,{asChild:!0,children:r.jsx(Ye,{highlightColor:l.value,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"highlight",label:a,value:s})})},l.value))]})]})})]})}function Z7(){return r.jsxs(ca,{children:[r.jsx(da,{asChild:!0,children:r.jsxs(k,{variant:"ghost",children:[r.jsx(To,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:"Turn into"}),r.jsx(lt,{}),r.jsx(Xe,{className:"tiptap-button-icon"})]})}),r.jsx(sa,{children:r.jsx(ua,{children:r.jsx(fa,{})})})]})}function F7({editor:e}){const t=ee();return r.jsxs(r.Fragment,{children:[r.jsxs(Fe,{children:[r.jsx(ut,{children:Sl(e)}),r.jsx(P7,{}),r.jsx(Z7,{}),r.jsx(de,{asChild:!0,children:r.jsx(ds,{text:"Reset formatting"})})]}),r.jsx(R,{orientation:"horizontal"}),r.jsxs(Fe,{children:[r.jsx(de,{asChild:!0,children:r.jsx(Kl,{text:"Duplicate node",showShortcut:!t})}),r.jsx(de,{asChild:!0,children:r.jsx(jl,{text:"Copy to clipboard",showShortcut:!t})}),r.jsx(de,{asChild:!0,children:r.jsx(ls,{text:"Copy anchor link",showShortcut:!t})})]}),r.jsx(Fe,{children:r.jsx(de,{asChild:!0,children:r.jsx(uo,{text:"Delete",showShortcut:!t})})})]})}function $7({editor:e}){return r.jsxs(la,{children:[r.jsx(aa,{asChild:!0,children:r.jsx(k,{variant:"ghost","data-appearance":"subdued",children:r.jsx(gt,{className:"tiptap-button-icon"})})}),r.jsx(ia,{children:r.jsx(F7,{editor:e})})]})}function z7({view:e,isMobile:t,onViewChange:n}){const o=e.id;return t?e.mobileButton?u.cloneElement(e.mobileButton(()=>n(o)),{key:e.id}):r.jsx(k,{onClick:()=>n(o),children:e.icon},e.id):e.desktopComponent?u.cloneElement(e.desktopComponent,{key:e.id}):null}function W7({toolbarViews:e,isMobile:t,onViewChange:n,editor:o}){const l=Object.values(e).filter(s=>s.shouldShow?s.shouldShow(o):!0);return l.length===0?null:r.jsxs(r.Fragment,{children:[l.map(s=>r.jsx(z7,{view:s,isMobile:t,onViewChange:n},s.id)),r.jsx(fe,{})]})}function _7({editor:e,isMobile:t,toolbarViews:n,onViewChange:o}){const l=N7(e),s=(e?.getText().length??0)>0;return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(mo,{}),r.jsx($7,{editor:e}),r.jsx(fe,{})]}),(l||s)&&r.jsxs(r.Fragment,{children:[r.jsx(O7,{}),r.jsx(W7,{toolbarViews:n,isMobile:t,onViewChange:o,editor:e}),r.jsx(ka,{}),r.jsx(U7,{}),r.jsx(D7,{}),r.jsx(B7,{}),r.jsxs(le,{children:[r.jsx(Eo,{text:"Add"}),r.jsx(fe,{})]})]}),r.jsxs(le,{children:[r.jsx(Do,{direction:"down"}),r.jsx(Do,{direction:"up"})]})]})}function q7({view:e,onBack:t}){return r.jsxs(r.Fragment,{children:[r.jsx(le,{children:r.jsxs(k,{variant:"ghost",onClick:t,children:[r.jsx(hn,{className:"tiptap-button-icon"}),e.icon]})}),r.jsx(fe,{}),e.content]})}function K7({editor:e}){const{editor:t}=S(e),n=ee("max",480),o=u.useRef(null),l=H7(n),s=u.useMemo(()=>V7(),[]),a=l.isMainView?null:s[l.viewId],{height:i}=$s(),c=v7({editor:t,overlayHeight:o.current?.getBoundingClientRect().height??0});return!n||!t||!t.isEditable?null:r.jsx(Ft,{ref:o,style:{...n?{bottom:`calc(100% - ${i-c.y}px)`}:{}},children:l.isMainView?r.jsx(_7,{editor:t,isMobile:n,toolbarViews:s,onViewChange:l.showView}):a&&r.jsx(q7,{view:a,onBack:l.showMainView})})}const Ea=u.forwardRef(({editor:e,shouldShow:t=void 0,floatingOptions:n,zIndex:o=50,onOpenChange:l,referenceElement:s,getBoundingClientRect:a=H2,closeOnEscape:i=!0,resetTextSelectionOnClose:c=!0,children:d,style:f,...h},p)=>{const[C,b]=u.useState(t!==void 0?t:!1),g=u.useRef(null),w=u.useRef(!1),v=u.useRef(!1),m=u.useRef(null),x=u.useRef(a),{editor:y}=S(e);u.useEffect(()=>{m.current=y,x.current=a},[y,a]);const T=u.useCallback(Z=>{l?.(Z),b(Z)},[l]),E=Z=>{if(!Z&&y&&c){const A=y.state.tr.setSelection(M.Selection.near(y.state.doc.resolve(0)));y.view.dispatch(A)}T(Z)},L=u.useMemo(()=>s||(()=>m.current?x.current(m.current):null),[s]),{isMounted:N,ref:te,style:O,getFloatingProps:_}=yl(C,L,o,{placement:"top",middleware:[D.shift(),D.flip(),D.offset(4)],onOpenChange:E,dismissOptions:{enabled:!0,escapeKey:!0,outsidePress(Z){const A=Z.target;return!A||Aa(A)?!1:!La(y,A)}},...n}),$=u.useCallback(()=>{if(!y)return;const Z=a(y);if(Z&&t!==void 0&&!v.current){T(t);return}const A=Tl(y);Z&&!v.current&&(A||w.current)?T(!0):!w.current&&(!A||v.current||!y.isEditable)&&T(!1)},[y,a,T,t]);u.useEffect(()=>{if(!y||!i)return;const Z=A=>A.key==="Escape"&&C?(T(!1),!0):!1;return y.view.dom.addEventListener("keydown",Z),()=>{y.view.dom.removeEventListener("keydown",Z)}},[y,C,i,T]),u.useEffect(()=>{if(!y)return;const Z=A=>{if(w.current){w.current=!1;return}const F=A.relatedTarget;if(!F)return;const q=La(y,F),ne=g.current,pe=ne&&(ne===F||ne.contains(F)),B=Aa(F);!q&&!pe&&!B&&C&&T(!1)};return y.view.dom.addEventListener("blur",Z),()=>{y.view.dom.removeEventListener("blur",Z)}},[y,T,C]),u.useEffect(()=>{if(!y)return;const Z=()=>{C&&T(!1)};return y.view.dom.addEventListener("dragstart",Z),y.view.dom.addEventListener("dragover",Z),()=>{y.view.dom.removeEventListener("dragstart",Z),y.view.dom.removeEventListener("dragover",Z)}},[y,C,T]),u.useEffect(()=>{if(!y)return;const Z=F=>{if(F.button!==0||(v.current=!0,F.detail>1))return;const{state:q,view:ne}=y,pe=ne.posAtCoords({left:F.clientX,top:F.clientY});if(!pe||!K(pe.pos))return;const j=q.doc.resolve(pe.pos).nodeBefore;if(!j||j.isBlock)return;const Ee=q.tr.setSelection(M.Selection.near(q.doc.resolve(pe.pos)));ne.dispatch(Ee)},A=()=>{v.current&&(v.current=!1,$())};return y.view.dom.addEventListener("mousedown",Z),y.view.root.addEventListener("mouseup",A),()=>{y.view.dom.removeEventListener("mousedown",Z),y.view.root.removeEventListener("mouseup",A)}},[y,$]),u.useEffect(()=>{if(y)return y.on("selectionUpdate",$),()=>{y.off("selectionUpdate",$)}},[y,$]),u.useEffect(()=>{y&&$()},[y,$]);const z=u.useMemo(()=>f&&Object.keys(f).length>0?f:O,[f,O]),oe=D.useMergeRefs([te,p,g]);return!y||!N||!C?null:r.jsx("div",{ref:oe,style:z,...h,..._(),children:d})});Ea.displayName="FloatingElement";const La=(e,t)=>{if(!t||!e)return!1;const n=e.view.dom.parentElement,o=e.view.dom;return n?n===t||o===t||n.contains(t):!1},Aa=e=>e instanceof HTMLElement?e.closest(["[data-radix-popper-content-wrapper]","[data-base-ui-portal]"].join(","))!==null:!1;function G7(){const{editor:e}=S(),t=ee("max",480),{lockDragHandle:n,commentInputVisible:o}=Gt(e),{shouldShow:l}=pi({editor:e,isSelectionValid:Tl,extraHideWhen:!!o});return n||t?null:r.jsx(Ea,{shouldShow:l,children:r.jsxs(Ft,{variant:"floating",children:[r.jsx(le,{children:r.jsx(ha,{hideWhenUnavailable:!0})}),r.jsx(fe,{}),r.jsxs(le,{children:[r.jsx(ue,{type:"bold",hideWhenUnavailable:!0}),r.jsx(ue,{type:"italic",hideWhenUnavailable:!0}),r.jsx(ue,{type:"underline",hideWhenUnavailable:!0}),r.jsx(ue,{type:"strike",hideWhenUnavailable:!0}),r.jsx(ue,{type:"code",hideWhenUnavailable:!0})]}),r.jsx(fe,{}),r.jsx(le,{children:r.jsx(ka,{})}),r.jsxs(le,{children:[r.jsx(No,{autoOpenOnLinkActive:!1,hideWhenUnavailable:!0}),r.jsx(zc,{hideWhenUnavailable:!0})]}),r.jsx(j7,{hideWhenUnavailable:!0})]})})}function Y7(e){if(!e)return!1;const t=["left","center","right","justify"].some(o=>Pt(e,o));return["superscript","subscript"].some(o=>Ot(e,o))||t}function X7(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n&&!t.isActive("code")?Y7(t):!!t?.isEditable:!1}function j7({editor:e,hideWhenUnavailable:t=!1,...n}){const{editor:o}=S(e),[l,s]=u.useState(!1);return u.useEffect(()=>{if(!o)return;const a=()=>{s(X7({editor:o,hideWhenUnavailable:t}))};return a(),o.on("selectionUpdate",a),()=>{o.off("selectionUpdate",a)}},[o,t]),!l||!o||!o.isEditable?null:r.jsxs(r.Fragment,{children:[r.jsx(fe,{}),r.jsx(le,{children:r.jsxs(Tt,{children:[r.jsx(It,{asChild:!0,children:r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,tooltip:"More options",...n,children:r.jsx(gt,{className:"tiptap-button-icon"})})}),r.jsx(Mt,{side:"top",align:"end",alignOffset:4,sideOffset:4,asChild:!0,children:r.jsxs(Ft,{variant:"floating",tabIndex:0,children:[r.jsxs(le,{children:[r.jsx(ue,{type:"superscript"}),r.jsx(ue,{type:"subscript"})]}),r.jsx(fe,{}),r.jsxs(le,{children:[r.jsx(Me,{align:"left"}),r.jsx(Me,{align:"center"}),r.jsx(Me,{align:"right"}),r.jsx(Me,{align:"justify"})]}),r.jsx(fe,{}),r.jsxs(le,{children:[r.jsx(ft,{action:"outdent"}),r.jsx(ft,{action:"indent"})]})]})})]})})]})}function Q7({className:e,maxShowCount:t=20,topOffset:n=0,...o}){const{tocContent:l,navigateToHeading:s,normalizeHeadingDepths:a}=en(),i=u.useRef(!1),c=u.useRef(null),[d,f]=u.useState(null),h=u.useMemo(()=>l??[],[l]),p=u.useMemo(()=>h.slice(0,t),[h,t]),C=u.useMemo(()=>a(p),[p,a]),b=u.useMemo(()=>{const E=new Map;return p.forEach((L,N)=>{E.set(L.id,C[N]??1)}),E},[p,C]),g=u.useMemo(()=>[...h].reverse().find(E=>E.isActive)??null,[h]),w=u.useMemo(()=>h.find(E=>E.isActive)?.id??null,[h]),v=u.useMemo(()=>d||(g?.id?g.id:w||h[0]?.id),[d,g,w,h]),m=u.useCallback((E,L)=>{E.preventDefault(),E.stopPropagation(),f(L.id),c.current=Date.now(),s(L,{topOffset:n})},[s,n]);u.useEffect(()=>{if(typeof window>"u"||i.current||!h.length)return;const E=window.location.hash.replace(/^#/,"");if(!E)return;const L=h.find(N=>N.id===E);L&&(f(L.id),i.current=!0)},[h]);const x=u.useRef(null),y=u.useRef(d);y.current=d,u.useEffect(()=>{if(typeof window>"u")return;const E=()=>{const N=Date.now(),te=c.current;te&&N-te<500||y.current!==null&&f(null)},L=x.current?er(x.current):null;return window.addEventListener("scroll",E,{passive:!0}),L&&!(L instanceof Window)&&L.addEventListener("scroll",E,{passive:!0}),()=>{window.removeEventListener("scroll",E),L&&!(L instanceof Window)&&L.removeEventListener("scroll",E)}},[]);const T=h.length>0;return r.jsx("div",{ref:x,className:U("toc-sidebar",e),...o,children:r.jsx("div",{className:"toc-sidebar-wrapper",children:r.jsxs("div",{className:"toc-sidebar-inner",children:[r.jsx("div",{className:"toc-sidebar-progress",children:p.map(E=>{const L=b.get(E.id)??1,N=v===E.id;return r.jsx("div",{className:U("toc-sidebar-progress-line",N&&"toc-sidebar-progress-line--active"),"data-depth":L,style:{"--toc-depth":L}},E.id)})}),r.jsx("nav",{className:U("toc-sidebar-nav",!T&&"toc-sidebar-nav--hidden"),"aria-label":"Table of contents",children:r.jsx("div",{className:"toc-sidebar-popover",children:p.map(E=>{const L=b.get(E.id)??1,N=v===E.id;return r.jsx("a",{href:`#${E.id}`,rel:"noopener noreferrer",className:U("toc-sidebar-item notranslate",N&&"toc-sidebar-item--active"),"data-depth":L,style:{"--toc-depth":L},onClick:te=>m(te,E),"aria-current":N?"location":void 0,children:E.textContent},E.id)})})})]})})})}const J7=be.Extension.create({name:"listNormalization",addKeyboardShortcuts(){const e=["bulletList","orderedList","taskList"];return{Backspace:({editor:n})=>{const{state:o,view:l}=n,{selection:s}=o,{$from:a,empty:i}=s;if(!i||a.parentOffset!==0)return!1;const c=a.parent;if(c.type.name!=="paragraph"||c.content.size>0)return!1;const d=a.depth-1;if(d<0)return!1;const f=a.node(d),h=a.index(d);if(h===0||h>=f.childCount-1)return!1;const p=f.child(h-1),C=f.child(h+1),b=e.includes(p.type.name),g=e.includes(C.type.name);if(!b||!g||p.type.name!==C.type.name)return!1;const w=a.before(d+1),v=a.after(d+1),m=o.doc.resolve(w-1),x=M.TextSelection.findFrom(m,-1,!0);if(!x)return!1;const y=x.from,T=o.tr;T.delete(w,v),_o.canJoin(T.doc,w)&&T.join(w);const E=T.mapping.map(y);return T.setSelection(M.TextSelection.create(T.doc,E)),l.dispatch(T),!0}}}});function R7(e,t,n,o){const l=e.getAttribute("data-indent");if(l){const a=parseInt(l,10);if(!isNaN(a))return Jt(a,t,n)}const s=["marginLeft","paddingLeft","textIndent"];for(const a of s){const i=e.style?.[a];if(i){const c=parseFloat(i);if(!isNaN(c)&&c>0&&o>0){const d=Math.round(c/o);return Jt(d,t,n)}}}return 0}function _t(e,t){const{$from:n}=e.selection;for(let o=n.depth;o>0;o--){const l=n.node(o).type.name;if(t.has(l))return l}return null}function Ha(e,t,n,o){const{selection:l}=e,{$from:s}=l;if(!l.empty||_t(e,n)!==null)return!1;const a=s.parent;return!t.includes(a.type.name)||a.attrs.indent<=0?!1:o.onlyIfEmpty?a.content.size===0:s.parentOffset===0}const e4=new M.PluginKey("indent"),t4=be.Extension.create({name:"indent",addOptions(){return{types:["paragraph","heading","blockquote"],listItemTypes:["listItem","taskItem"],bypassAncestors:["tableCell","tableHeader"],minLevel:0,maxLevel:8,useStyle:!1,indentUnit:24}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>R7(e,this.options.minLevel,this.options.maxLevel,this.options.indentUnit),renderHTML:e=>{const t=Number(e.indent)||0;if(t===0)return{};const n={"data-indent":String(t),style:`--tt-indent-level: ${t}`};return this.options.useStyle&&this.options.indentUnit>0&&(n.style=`--tt-indent-level: ${t}; margin-left: ${t*this.options.indentUnit}px`),n}}}}]},addCommands(){const e=new Set(this.options.listItemTypes),t=({state:n,tr:o},l)=>{const s=Je(n.selection,this.options.types);return s.length===0?!1:Qt(o,s,"indent",a=>Jt(l(Number(a)||0),this.options.minLevel,this.options.maxLevel))};return{indent:()=>n=>{const o=_t(n.state,e);return o&&"sinkListItem"in n.commands?n.commands.sinkListItem(o):t(n,l=>l+1)},outdent:()=>n=>{const o=_t(n.state,e);return o&&"liftListItem"in n.commands?n.commands.liftListItem(o):t(n,l=>l-1)},setIndent:n=>o=>t(o,()=>n),unsetIndent:()=>n=>t(n,()=>0)}},addProseMirrorPlugins(){const e=this.options.types;return[new M.Plugin({key:e4,appendTransaction(t,n,o){if(!t.some(v=>v.getMeta("uiEvent")==="drop"))return null;const{doc:s,selection:a}=o,{$from:i,$to:c}=a,d=i.depth>0?i.depth:1,f=i.before(d),h=s.resolve(f),p=h.node(h.depth),C=h.index(h.depth);let b=0;if(C>0)b=p.child(C-1).attrs.indent||0;else{const v=c.depth>0?c.depth:1,m=c.after(v),x=s.resolve(m),y=x.indexAfter(x.depth),T=x.node(x.depth);y<T.childCount&&(b=T.child(y).attrs.indent||0)}const{tr:g}=o;let w=!1;return s.nodesBetween(i.pos,c.pos,(v,m)=>(!e.includes(v.type.name)||(v.attrs.indent||0)===b||(g.setNodeMarkup(m,void 0,{...v.attrs,indent:b},v.marks),w=!0),!1)),w?g:null}})]},addKeyboardShortcuts(){const e=new Set(this.options.listItemTypes),t=new Set(this.options.bypassAncestors),n=l=>{if(t.size===0)return!1;const{$from:s}=l.selection;for(let a=s.depth;a>0;a--)if(t.has(s.node(a).type.name))return!0;return!1},o=()=>{const l=this.editor.state;if(n(l))return!1;if(_t(l,e)!==null)return!0;const{$from:s}=l.selection;return this.options.types.includes(s.parent.type.name)};return{Tab:()=>o()?(this.editor.commands.indent(),!0):!1,"Shift-Tab":()=>o()?(this.editor.commands.outdent(),!0):!1,Enter:({editor:l})=>Ha(l.state,this.options.types,e,{onlyIfEmpty:!0})?l.commands.outdent():!1,Backspace:({editor:l})=>Ha(l.state,this.options.types,e,{onlyIfEmpty:!1})?l.commands.outdent():!1}}}),n4=be.Extension.create({name:"tripleClickBlockSelection",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tripleClickBlockSelection"),props:{handleTripleClick:(e,t)=>{const{state:n}=e,{doc:o}=n,l=o.resolve(t);let s=l.depth;for(;s>0&&!l.node(s).isTextblock;)s--;if(s===0||l.node(s).type.spec.selectable===!1)return!1;const i=l.before(s);return e.dispatch(n.tr.setSelection(M.NodeSelection.create(o,i))),!0}}})]}}),o4={type:"doc",content:[{type:"heading",attrs:{id:"11111111-1111-4111-8111-111111111111",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"11111111-1111-4111-8111-111111111111",level:1},content:[{type:"text",text:"Local Omnibox editor"}]},{type:"blockquote",attrs:{id:"22222222-2222-4222-8222-222222222222",backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"paragraph",attrs:{id:"33333333-3333-4333-8333-333333333333",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",marks:[{type:"bold"}],text:"A clean base for your own editor package."},{type:"hardBreak"},{type:"text",text:"It keeps the writing, formatting, slash menu, table, and block editing pieces ready for your package work."}]}]},{type:"paragraph",attrs:{id:"44444444-4444-4444-8444-444444444444",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Type "},{type:"text",marks:[{type:"code"}],text:"/"},{type:"text",text:" to open the command menu, select text for the floating toolbar, or drag blocks from the left handle."}]},{type:"heading",attrs:{id:"55555555-5555-4555-8555-555555555555",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"55555555-5555-4555-8555-555555555555",level:2},content:[{type:"text",text:"Writing basics"}]},{type:"codeBlock",attrs:{id:"66666666-6666-4666-8666-666666666666",language:null},content:[{type:"text",text:`# Headings
4
+ `).replace(/\\t/g," ").replace(/\\(["'`{}\[\](),:])/g,"$1").trim()}function Ui(e){const t=rr(e);try{return JSON.parse(t)}catch{return Function(`"use strict";return (${t})`)()}}function gt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function lr(e){return Object.hasOwn(e,"top")||Object.hasOwn(e,"bottom")}function Oi(e){return Object.hasOwn(e,"left")||Object.hasOwn(e,"right")}function _e(e){return Array.isArray(e)?e.length>0:!!e}function sr(e,t,n=!1){const o=l=>{const s={...l};return lr(s)||(s.top=t),n&&!Oi(s)&&(s.left="center"),s};return Array.isArray(e)?e.map(l=>gt(l)?o(l):l):gt(e)?o(e):e}function Pi(e){return _e(e.xAxis)||_e(e.yAxis)}function Zi(e){const t=_e(e.title),n=_e(e.legend);return t&&n?120:t||n?80:null}function Fi(e,t){const n=o=>lr(o)?o:{...o,top:t};return Array.isArray(e)?e.map(o=>gt(o)?n(o):o):gt(e)?n(e):{top:t}}function $i(e){const t={...e},n=_e(e.title),o=_e(e.legend);n&&(t.title=sr(e.title,16,!0)),o&&(t.legend=sr(e.legend,n?64:24,!0));const l=Zi(e);return l!==null&&Pi(e)&&(t.grid=Fi(e.grid,l)),t}function zi(e){return typeof e!="string"||!e.trim()?"Code":e.trim()}function Wi({code:e}){const t=u.useRef(null),[n,o]=u.useState(null);return u.useEffect(()=>{const l=t.current;if(!l)return;let s=null,a=null;try{const i=Ui(e);s=si.init(l),s.setOption($i(i)),o(null),a=new ResizeObserver(()=>s?.resize()),a.observe(l)}catch(i){o(i instanceof Error?i.message:"Failed to render chart")}return()=>{a?.disconnect(),s?.dispose()}},[e]),r.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[r.jsx("div",{className:"code-block-node__echarts",ref:t}),n?r.jsx("div",{className:"code-block-node__diagram-error",children:n}):null]})}function _i({code:e,language:t}){const n=or(t);return n==="echarts"?r.jsx(Wi,{code:e}):n==="mermaid"?r.jsx(qi,{code:e}):null}function qi({code:e}){const t=u.useId(),[n,o]=u.useState(""),[l,s]=u.useState(null);return u.useEffect(()=>{let a=!1;async function i(){try{const c=await Ra.render(`code-block-diagram-${t.replace(/:/g,"")}`,rr(e));a||(o(c.svg),s(null))}catch(c){a||(o(""),s(c instanceof Error?c.message:"Failed to render diagram"))}}return i(),()=>{a=!0}},[e,t]),r.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[n?r.jsx("div",{className:"code-block-node__mermaid",dangerouslySetInnerHTML:{__html:n}}):null,l?r.jsx("div",{className:"code-block-node__diagram-error",children:l}):null]})}function Ki(e){const t=zi(e.node.attrs.language),o=!!or(t),[l,s]=u.useState(o),a=e.node.textContent,i=o&&e.editor.isEditable;return u.useEffect(()=>{s(o)},[o,t]),r.jsxs(P.NodeViewWrapper,{className:"code-block-node","data-collapsed":l?"true":"false","data-diagram":o?"true":"false","data-language":t,children:[r.jsxs("div",{className:"code-block-node__header",contentEditable:!1,children:[r.jsx("span",{className:"code-block-node__language",children:t}),i?r.jsx("button",{type:"button",className:"code-block-node__toggle","aria-expanded":!l,onClick:()=>s(c=>!c),children:l?"Show source":"Hide source"}):null]}),o?r.jsx(_i,{code:a,language:t}):null,r.jsx("pre",{className:"code-block-node__pre",children:r.jsx(P.NodeViewContent,{className:"code-block-node__content"})})]})}const Gi=Qa.CodeBlock.extend({addNodeView(){return P.ReactNodeViewRenderer(Ki)}});function Yi({initialOpen:e=!1,placement:t="top",open:n,onOpenChange:o,delay:l=600,closeDelay:s=0}={}){const[a,i]=u.useState(e),c=n??a,d=o??i,f=D.useFloating({placement:t,open:c,onOpenChange:d,whileElementsMounted:D.autoUpdate,middleware:[D.offset(4),D.flip({crossAxis:t.includes("-"),fallbackAxisSideDirection:"start",padding:4}),D.shift({padding:4})]}),h=f.context,p=D.useHover(h,{mouseOnly:!0,move:!1,restMs:l,enabled:n==null,delay:{close:s}}),C=D.useFocus(h,{enabled:n==null}),b=D.useDismiss(h),g=D.useRole(h,{role:"tooltip"}),w=D.useInteractions([p,C,b,g]);return u.useMemo(()=>({open:c,setOpen:d,...w,...f}),[c,d,w,f])}const on=u.createContext(null);function ar(){const e=u.useContext(on);if(e==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return e}function ir({children:e,...t}){const n=Yi(t);return t.useDelayGroup?r.jsx(D.FloatingDelayGroup,{delay:{open:t.delay??0,close:t.closeDelay??0},timeoutMs:t.timeout,children:r.jsx(on.Provider,{value:n,children:e})}):r.jsx(on.Provider,{value:n,children:e})}const cr=u.forwardRef(function({children:t,asChild:n=!1,...o},l){const s=ar(),a=u.isValidElement(t)?parseInt(u.version,10)>=19?t.props.ref:t.ref:void 0,i=D.useMergeRefs([s.refs.setReference,l,a]);if(n&&u.isValidElement(t)){const c={"data-tooltip-state":s.open?"open":"closed"};return u.cloneElement(t,s.getReferenceProps({ref:i,...o,...typeof t.props=="object"?t.props:{},...c}))}return r.jsx("button",{ref:i,"data-tooltip-state":s.open?"open":"closed",...s.getReferenceProps(o),children:t})}),dr=u.forwardRef(function({style:t,children:n,portal:o=!0,portalProps:l={},...s},a){const i=ar(),c=D.useMergeRefs([i.refs.setFloating,a]);if(!i.open)return null;const d=r.jsx("div",{ref:c,style:{...i.floatingStyles,...t},...i.getFloatingProps(s),className:"tiptap-tooltip",children:n});return o?r.jsx(D.FloatingPortal,{...l,children:d}):d});ir.displayName="Tooltip",cr.displayName="TooltipTrigger",dr.displayName="TooltipContent";const Xi=({shortcuts:e})=>e.length===0?null:r.jsx("div",{children:e.map((t,n)=>r.jsxs(u.Fragment,{children:[n>0&&r.jsx("kbd",{children:"+"}),r.jsx("kbd",{children:t})]},n))}),k=u.forwardRef(({className:e,children:t,tooltip:n,showTooltip:o=!0,shortcutKeys:l,variant:s,size:a,...i},c)=>{const d=u.useMemo(()=>G({shortcutKeys:l}),[l]);return!n||!o?r.jsx("button",{"data-slot":"tiptap-button",className:U("tiptap-button",e),ref:c,"data-style":s,"data-size":a,...i,children:t}):r.jsxs(ir,{delay:200,children:[r.jsx(cr,{"data-slot":"tiptap-button",className:U("tiptap-button",e),ref:c,"data-style":s,"data-size":a,...i,children:t}),r.jsxs(dr,{children:[n,r.jsx(Xi,{shortcuts:d})]})]})});k.displayName="Button";const ur=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));ur.displayName="CloseIcon";function ji(e){const[t,n]=u.useState([]),o=async i=>{if(i.size>e.maxSize){const h=new Error(`File size exceeds maximum allowed (${e.maxSize/1024/1024}MB)`);return e.onError?.(h),null}const c=new AbortController,d=crypto.randomUUID(),f={id:d,file:i,progress:0,status:"uploading",abortController:c};n(h=>[...h,f]);try{if(!e.upload)throw new Error("Upload function is not defined");const h=await e.upload(i,p=>{n(C=>C.map(b=>b.id===d?{...b,progress:p.progress}:b))},c.signal);if(!h)throw new Error("Upload failed: No URL returned");return c.signal.aborted?null:(n(p=>p.map(C=>C.id===d?{...C,status:"success",url:h,progress:100}:C)),e.onSuccess?.(h),h)}catch(h){return c.signal.aborted||(n(p=>p.map(C=>C.id===d?{...C,status:"error",progress:0}:C)),e.onError?.(h instanceof Error?h:new Error("Upload failed"))),null}};return{fileItems:t,uploadFiles:async i=>{if(!i||i.length===0)return e.onError?.(new Error("No files to upload")),[];if(e.limit&&i.length>e.limit)return e.onError?.(new Error(`Maximum ${e.limit} file${e.limit===1?"":"s"} allowed`)),[];const c=i.map(f=>o(f));return(await Promise.all(c)).filter(f=>f!==null)},removeFileItem:i=>{n(c=>{const d=c.find(f=>f.id===i);return d?.abortController&&d.abortController.abort(),d?.url&&URL.revokeObjectURL(d.url),c.filter(f=>f.id!==i)})},clearAllFiles:()=>{t.forEach(i=>{i.abortController&&i.abortController.abort(),i.url&&URL.revokeObjectURL(i.url)}),n([])}}}const fr=()=>r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"tiptap-image-upload-icon",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M11.1953 4.41771C10.3478 4.08499 9.43578 3.94949 8.5282 4.02147C7.62062 4.09345 6.74133 4.37102 5.95691 4.83316C5.1725 5.2953 4.50354 5.92989 4.00071 6.68886C3.49788 7.44783 3.17436 8.31128 3.05465 9.2138C2.93495 10.1163 3.0222 11.0343 3.3098 11.8981C3.5974 12.7619 4.07781 13.5489 4.71463 14.1995C5.10094 14.5942 5.09414 15.2274 4.69945 15.6137C4.30476 16 3.67163 15.9932 3.28532 15.5985C2.43622 14.731 1.79568 13.6816 1.41221 12.5299C1.02875 11.3781 0.91241 10.1542 1.07201 8.95084C1.23162 7.74748 1.66298 6.59621 2.33343 5.58425C3.00387 4.57229 3.89581 3.72617 4.9417 3.10998C5.98758 2.4938 7.15998 2.1237 8.37008 2.02773C9.58018 1.93176 10.7963 2.11243 11.9262 2.55605C13.0561 2.99968 14.0703 3.69462 14.8919 4.58825C15.5423 5.29573 16.0585 6.11304 16.4177 7.00002H17.4999C18.6799 6.99991 19.8288 7.37933 20.7766 8.08222C21.7245 8.78515 22.4212 9.7743 22.7637 10.9036C23.1062 12.0328 23.0765 13.2423 22.6788 14.3534C22.2812 15.4644 21.5367 16.4181 20.5554 17.0736C20.0962 17.3803 19.4752 17.2567 19.1684 16.7975C18.8617 16.3382 18.9853 15.7172 19.4445 15.4105C20.069 14.9934 20.5427 14.3865 20.7958 13.6794C21.0488 12.9724 21.0678 12.2027 20.8498 11.4841C20.6318 10.7655 20.1885 10.136 19.5853 9.6887C18.9821 9.24138 18.251 8.99993 17.5001 9.00002H15.71C15.2679 9.00002 14.8783 8.70973 14.7518 8.28611C14.4913 7.41374 14.0357 6.61208 13.4195 5.94186C12.8034 5.27164 12.0427 4.75043 11.1953 4.41771Z",fill:"currentColor"}),r.jsx("path",{d:"M11 14.4142V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V14.4142L15.2929 16.7071C15.6834 17.0976 16.3166 17.0976 16.7071 16.7071C17.0976 16.3166 17.0976 15.6834 16.7071 15.2929L12.7078 11.2936C12.7054 11.2912 12.703 11.2888 12.7005 11.2864C12.5208 11.1099 12.2746 11.0008 12.003 11L12 11L11.997 11C11.8625 11.0004 11.7343 11.0273 11.6172 11.0759C11.502 11.1236 11.3938 11.1937 11.2995 11.2864C11.297 11.2888 11.2946 11.2912 11.2922 11.2936L7.29289 15.2929C6.90237 15.6834 6.90237 16.3166 7.29289 16.7071C7.68342 17.0976 8.31658 17.0976 8.70711 16.7071L11 14.4142Z",fill:"currentColor"})]}),Qi=()=>r.jsx("svg",{width:"43",height:"57",viewBox:"0 0 43 57",fill:"currentColor",className:"tiptap-image-upload-dropzone-rect-primary",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M0.75 10.75C0.75 5.64137 4.89137 1.5 10 1.5H32.3431C33.2051 1.5 34.0317 1.84241 34.6412 2.4519L40.2981 8.10876C40.9076 8.71825 41.25 9.5449 41.25 10.4069V46.75C41.25 51.8586 37.1086 56 32 56H10C4.89137 56 0.75 51.8586 0.75 46.75V10.75Z",fill:"currentColor",fillOpacity:"0.11",stroke:"currentColor",strokeWidth:"1.5"})}),Ji=()=>r.jsx("svg",{width:"10",height:"10",className:"tiptap-image-upload-dropzone-rect-secondary",viewBox:"0 0 10 10",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M0 0.75H0.343146C1.40401 0.75 2.42143 1.17143 3.17157 1.92157L8.82843 7.57843C9.57857 8.32857 10 9.34599 10 10.4069V10.75H4C1.79086 10.75 0 8.95914 0 6.75V0.75Z",fill:"currentColor"})}),Ri=({onFile:e,children:t})=>{const[n,o]=u.useState(!1),[l,s]=u.useState(!1),a=f=>{f.preventDefault(),f.stopPropagation(),s(!0)},i=f=>{f.preventDefault(),f.stopPropagation(),f.currentTarget.contains(f.relatedTarget)||(s(!1),o(!1))},c=f=>{f.preventDefault(),f.stopPropagation(),o(!0)},d=f=>{f.preventDefault(),f.stopPropagation(),s(!1),o(!1);const h=Array.from(f.dataTransfer.files);h.length>0&&e(h)};return r.jsx("div",{className:`tiptap-image-upload-drag-area ${l?"drag-active":""} ${n?"drag-over":""}`,onDragEnter:a,onDragLeave:i,onDragOver:c,onDrop:d,children:t})},e1=({fileItem:e,onRemove:t})=>{const n=o=>{if(o===0)return"0 Bytes";const l=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(o)/Math.log(l));return`${parseFloat((o/Math.pow(l,a)).toFixed(2))} ${s[a]}`};return r.jsxs("div",{className:"tiptap-image-upload-preview",children:[e.status==="uploading"&&r.jsx("div",{className:"tiptap-image-upload-progress",style:{width:`${e.progress}%`}}),r.jsxs("div",{className:"tiptap-image-upload-preview-content",children:[r.jsxs("div",{className:"tiptap-image-upload-file-info",children:[r.jsx("div",{className:"tiptap-image-upload-file-icon",children:r.jsx(fr,{})}),r.jsxs("div",{className:"tiptap-image-upload-details",children:[r.jsx("span",{className:"tiptap-image-upload-text",children:e.file.name}),r.jsx("span",{className:"tiptap-image-upload-subtext",children:n(e.file.size)})]})]}),r.jsxs("div",{className:"tiptap-image-upload-actions",children:[e.status==="uploading"&&r.jsxs("span",{className:"tiptap-image-upload-progress-text",children:[e.progress,"%"]}),r.jsx(k,{type:"button",variant:"ghost",onClick:o=>{o.stopPropagation(),t()},children:r.jsx(ur,{className:"tiptap-button-icon"})})]})]})]})},t1=({maxSize:e,limit:t})=>r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"tiptap-image-upload-dropzone",children:[r.jsx(Qi,{}),r.jsx(Ji,{}),r.jsx("div",{className:"tiptap-image-upload-icon-container",children:r.jsx(fr,{})})]}),r.jsxs("div",{className:"tiptap-image-upload-content",children:[r.jsxs("span",{className:"tiptap-image-upload-text",children:[r.jsx("em",{children:"Click to upload"})," or drag and drop"]}),r.jsxs("span",{className:"tiptap-image-upload-subtext",children:["Maximum ",t," file",t===1?"":"s",", ",e/1024/1024,"MB each."]})]})]}),n1=e=>{const{accept:t,limit:n,maxSize:o}=e.node.attrs,l=u.useRef(null),s=e.extension,a={maxSize:o,limit:n,accept:t,upload:s.options.upload,onSuccess:s.options.onSuccess,onError:s.options.onError},{fileItems:i,uploadFiles:c,removeFileItem:d,clearAllFiles:f}=ji(a),h=async g=>{const w=await c(g);if(w.length>0){const v=e.getPos();if(K(v)){const m=w.map((x,y)=>{const T=g[y]?.name.replace(/\.[^/.]+$/,"")||"unknown";return{type:s.options.type,attrs:{...s.options,src:x,alt:T,title:T}}});e.editor.chain().focus().deleteRange({from:v,to:v+e.node.nodeSize}).insertContentAt(v,m).run(),fi(e.editor)}}},p=g=>{const w=g.target.files;if(!w||w.length===0){s.options.onError?.(new Error("No file selected"));return}h(Array.from(w))},C=()=>{l.current&&i.length===0&&(l.current.value="",l.current.click())},b=i.length>0;return r.jsxs(P.NodeViewWrapper,{className:"tiptap-image-upload",tabIndex:0,onClick:C,children:[!b&&r.jsx(Ri,{onFile:h,children:r.jsx(t1,{maxSize:o,limit:n})}),b&&r.jsxs("div",{className:"tiptap-image-upload-previews",children:[i.length>1&&r.jsxs("div",{className:"tiptap-image-upload-header",children:[r.jsxs("span",{children:["Uploading ",i.length," files"]}),r.jsx(k,{type:"button",variant:"ghost",onClick:g=>{g.stopPropagation(),f()},children:"Clear All"})]}),i.map(g=>r.jsx(e1,{fileItem:g,onRemove:()=>d(g.id)},g.id))]}),r.jsx("input",{ref:l,name:"file",accept:t,type:"file",multiple:n>1,onChange:p,onClick:g=>g.stopPropagation()})]})},o1=P.Node.create({name:"imageUpload",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:void 0,onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:e}){return["div",P.mergeAttributes({"data-type":"image-upload"},e)]},addNodeView(){return P.ReactNodeViewRenderer(n1)},addCommands(){return{setImageUploadNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{const{selection:t}=e.state,{nodeAfter:n}=t.$from;if(n&&n.type.name==="imageUpload"&&e.isActive("imageUpload")){const o=e.view.nodeDOM(t.$from.pos);if(o&&o instanceof HTMLElement){const l=o.firstChild;if(l&&l instanceof HTMLElement)return l.click(),!0}}return!1}}}}),hr=35,nt=120,r1=40,bt={cells:[],mergedCells:[]};function rn(e){return e instanceof HTMLElement}function pr(e,t){return e?.closest?.(t)??null}function Cr(e){let t=e;for(;t&&t.tagName!=="TD"&&t.tagName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;t=rn(t.parentNode)?t.parentNode:null}if(t)return t.tagName==="TD"||t.tagName==="TH"?{type:"cell",domNode:t,tbodyNode:pr(t,"tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function He(e,t,n){return Math.max(t,Math.min(e,n))}function gr(e,t,n){return e>=0&&e<n.height&&t>=0&&t<n.width}function l1(e,t,n,o){if(typeof o=="number")return o;if(e.selection instanceof I.CellSelection){const i=I.selectedRect(e);return n==="row"?i.top:i.left}const l=I.cellAround(e.selection.$anchor)??I.selectionCell(e);if(!l)return null;const s=l.pos-t.start,a=t.map.findCell(s);return n==="row"?a.top:a.left}function s1(e,t,n,o){return{row:e,column:t,pos:n,node:o,start:n+1,depth:o?o.content.size:0}}function a1(e){if(!e)return!1;const t=e.attrs.colspan??1,n=e.attrs.rowspan??1;return t>1||n>1}function ln(e,t,n,o){if(!e)return bt;const{state:l}=e,s=J(e,o);if(!s)return bt;const a=s.start,i=s.node,c=s.map,d=l1(l,s,t,n);if(d===null)return bt;const f=t==="row"?c.height:c.width;if(d<0||d>=f)return bt;const h=[],p=[],C=new Set,b=t==="row"?c.width:c.height;for(let g=0;g<b;g++){const w=t==="row"?d:g,v=t==="row"?g:d,m=w*c.width+v,x=c.map[m];if(x===void 0)continue;const y=a+x,T=i.nodeAt(x);if(!T)continue;const E=s1(w,v,y,T);a1(T)&&(C.has(y)||(p.push(E),C.add(y))),h.push(E)}return{cells:h,mergedCells:p}}function br(e,t,n){const o=J(e,t);if(!o)return 0;const{doc:l}=e.state,s=n==="row"?o.map.height:o.map.width;let a=0;for(let i=s-1;i>=0;i--){const c=new Set;let d=!0;const f=n==="row"?o.map.width:o.map.height;for(let h=0;h<f;h++){const p=n==="row"?i:h,C=n==="row"?h:i,b=o.map.positionAt(p,C,o.node);if(c.has(b))continue;c.add(b);const g=t+1+b,w=l.nodeAt(g);if(w&&!Ne(w)){d=!1;break}}if(d)a++;else break}return a}function J(e,t){if(!e)return null;let n=null;if(typeof t=="number"){const l=e.state.doc.nodeAt(t);l?.type.name==="table"&&(n={node:l,pos:t,start:t+1,depth:e.state.doc.resolve(t).depth})}if(!n){const{state:l}=e,s=l.doc.resolve(l.selection.from);n=I.findTable(s)}if(!n)return null;const o=I.TableMap.get(n.node);return o?{...n,map:o}:null}function wr({width:e,height:t,map:n},o){let l=o.top*e+o.left,s=l,a=(o.bottom-1)*e+o.left,i=l+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[s]==n[s-1]||o.right<e&&n[i]==n[i+1])return!0;s+=e,i+=e}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[l]==n[l-e]||o.bottom<t&&n[a]==n[a+e])return!0;l++,a++}return!1}function sn(e,t){const n=e.view,o=n.state.selection,l=o.getBookmark(),s=new Ko.Mapping,a=n.dispatch;n.dispatch=i=>{s.appendMapping(i.mapping),a(i)};try{t()}finally{n.dispatch=a}try{const i=l.map(s).resolve(n.state.doc);return n.dispatch(n.state.tr.setSelection(i)),!0}catch{const i=s.map(o.from,-1),c=He(i,0,n.state.doc.content.size),d=M.Selection.near(n.state.doc.resolve(c),-1);return n.dispatch(n.state.tr.setSelection(d)),!1}}function Ne(e){if(e.childCount===0)return!0;let t=!0;return e.descendants(n=>n.isText&&n.text?.trim()||n.isLeaf&&!n.isText?(t=!1,!1):!0),t}function Y(e,t,n,o){if(typeof t=="number"&&n)return{orientation:n,index:t};if(!e)return null;const{state:l}=e;if(!J(e,o))return null;if(l.selection instanceof I.CellSelection){const a=I.selectedRect(l),i=a.right-a.left,c=a.bottom-a.top;return c===1&&i>=1?{orientation:"row",index:a.top}:i===1&&c>=1?{orientation:"column",index:a.left}:null}return null}function he(e,t,n,o){const l={cells:[],mergedCells:[],index:void 0,orientation:void 0,tablePos:void 0};if(!e||typeof t!="number"&&!(e.state.selection instanceof I.CellSelection))return l;let s=t,a=n;if(typeof s!="number"||!a||!["row","column"].includes(a)){const c=Y(e);if(!c)return l;s=c.index,a=c.orientation}return{...ln(e,a,s,o),index:s,orientation:a}}function vr(e,t,n){return ln(e,"row",t,n)}function mr(e,t,n){return ln(e,"column",t,n)}function an(e,t,n,o){try{const l=J(e,o);if(!l)return;const{state:s}=e,{map:a}=l;if(t==="row"){if(n>=0&&n<a.height){const c=a.width-1,d=l.start+a.positionAt(n,0,l.node),f=l.start+a.positionAt(n,c,l.node),h=s.doc.resolve(d),p=s.doc.resolve(f),C=I.CellSelection.create(s.doc,h.pos,p.pos),b=s.tr.setSelection(C);e.view.dispatch(b)}}else if(t==="column"&&n>=0&&n<a.width){const c=a.height-1,d=l.start+a.positionAt(0,n,l.node),f=l.start+a.positionAt(c,n,l.node),h=s.doc.resolve(d),p=s.doc.resolve(f),C=I.CellSelection.create(s.doc,h.pos,p.pos),b=s.tr.setSelection(C);e.view.dispatch(b)}}catch(l){console.warn("Failed to update selection after move:",l)}}function i1(e,t){return function(n,o){if(!I.isInTable(n))return!1;const l=I.selectionCell(n),s=typeof e=="string"?{[e]:t}:e;if(o){const a=n.tr;n.selection instanceof I.CellSelection?n.selection.forEachCell((i,c)=>{Object.entries(s).some(([f,h])=>i.attrs[f]!==h)&&a.setNodeMarkup(c,null,{...i.attrs,...s})}):Object.entries(s).some(([c,d])=>l.nodeAfter.attrs[c]!==d)&&a.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,...s}),o(a)}return!0}}function c1(e,t){return br(e,t,"row")}function d1(e,t){return br(e,t,"column")}function u1(e,t=.3){const n=Math.floor(e),o=Math.ceil(e),l=n+t,s=o-t;return e<l?n:e>s?o:Math.round(e)}function yr(e,t){return!e&&!t?!0:!e||!t?!1:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function f1(e,t,n){switch(n.mode??"state"){case"dispatch":{const l=n;typeof l.dispatch=="function"&&l.dispatch(t);return}case"transaction":return t;default:return e.apply(t)}}function ve(e,t,n,o={mode:"state"}){if(!e)return;const l=J(e,t);if(!l)return;const{state:s}=e,a=l.map,i=n.map(v=>({row:He(v.row,0,a.height-1),col:He(v.col,0,a.width-1)})).filter(v=>gr(v.row,v.col,a));if(i.length===0)return;const c=i.map(v=>v.row),d=Math.min(...c),f=Math.max(...c),h=i.map(v=>v.col),p=Math.min(...h),C=Math.max(...h),b=(v,m)=>{const x=a.map[v*a.width+m];return x===void 0?null:t+1+x},g=b(d,p);if(g===null)return;let w=b(f,C);if(w!==null){if(w===g){let v=!1;for(let m=f;m>=d&&!v;m--)for(let x=C;x>=p&&!v;x--){const y=b(m,x);y!==null&&y!==g&&(w=y,v=!0)}}try{const v=s.doc.resolve(g),m=s.doc.resolve(w),x=new I.CellSelection(v,m),y=s.tr.setSelection(x);return f1(s,y,o)}catch(v){console.error("Failed to create cell selection:",v);return}}}function h1({editor:e,row:t,col:n,tablePos:o,dispatch:l}){if(!e)return!1;const{state:s,view:a}=e,i=J(e,o);if(!i||!gr(t,n,i.map))return!1;const c=i.map.positionAt(t,n,i.node),d=i.start+c,f=s.doc.resolve(d),h=I.cellAround(f),p=h?h.pos:d,C=I.CellSelection.create(s.doc,p),b=l??a?.dispatch;return b?(b(s.tr.setSelection(C)),!0):!1}function cn(e,t,n,o){const l=I.TableMap.get(t),s=o==="row",a=s?l.height-1:0,i=s?0:l.width-1,c=a*l.width+i,d=l.map[c];if(!d&&d!==0)return console.warn("selectLastCell: cell position not found in map",{index:c,row:a,col:i,map:l}),!1;const f=l.map.indexOf(d),h=f>=0?Math.floor(f/l.width):0,p=f>=0?f%l.width:0;return h1({editor:e,row:h,col:p,tablePos:n,dispatch:e.view.dispatch.bind(e.view)})}function Ve({editor:e,index:t,orientation:n,tablePos:o}){if(!e)return null;const l=J(e,o);if(!l)return null;const{map:s}=l,{width:a,height:i}=s;return t<0||n==="row"&&t>=i||n==="column"&&t>=a?null:n==="row"?Array.from({length:s.width},(c,d)=>({row:t,col:d})):Array.from({length:s.height},(c,d)=>({row:d,col:t}))}function xr(e,t,n){if(!t)return null;try{const o=n.view.posAtDOM(e,0),l=n.view.state.doc.resolve(o);for(let s=l.depth;s>0;s--){const a=l.node(s);if(a.type.name==="tableCell"||a.type.name==="tableHeader"){const i=I.TableMap.get(t),c=l.before(s),d=l.start(s-2),f=c-d,h=i.map.indexOf(f);return{rowIndex:Math.floor(h/i.width),colIndex:h%i.width}}}}catch(o){console.warn("Could not get cell position:",o)}return null}function p1(e,t){try{const n=t.view.posAtDOM(e,0),o=t.view.state.doc.resolve(n);for(let l=o.depth;l>=0;l--){const s=o.node(l);if(Sr(s))return{node:s,pos:l===0?0:o.before(l)}}}catch(n){console.warn("Could not get table from DOM:",n)}return null}function Sr(e){return!!e&&(e.type.name==="table"||e.type.spec.tableRole==="table")}const C1=ei.Table.extend({addProseMirrorPlugins(){const e=this.options.resizable&&this.editor.isEditable,t=this.options.cellMinWidth<nt?nt:this.options.cellMinWidth;return[...e?[I.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:hr,defaultCellMinWidth:t,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],I.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){return({node:e,HTMLAttributes:t})=>{class n extends I.TableView{blockContainer;innerTableContainer;widgetsContainer;overlayContainer;containerAttributes;constructor(s,a,i){super(s,a),this.containerAttributes=i??{},this.blockContainer=this.createBlockContainer(),this.innerTableContainer=this.createInnerTableContainer(),this.widgetsContainer=this.createWidgetsContainer(),this.overlayContainer=this.createOverlayContainer(),this.setupDOMStructure()}createBlockContainer(){const s=document.createElement("div");return s.setAttribute("data-content-type","table"),this.applyContainerAttributes(s),s}createInnerTableContainer(){const s=document.createElement("div");return s.className="table-container",s}createWidgetsContainer(){const s=document.createElement("div");return s.className="table-controls",s.style.position="relative",s}createOverlayContainer(){const s=document.createElement("div");return s.className="table-selection-overlay-container",s}applyContainerAttributes(s){Object.entries(this.containerAttributes).forEach(([a,i])=>{a!=="class"&&s.setAttribute(a,i)})}setupDOMStructure(){const s=this.dom,a=s.firstChild;this.innerTableContainer.appendChild(a),s.appendChild(this.innerTableContainer),s.appendChild(this.widgetsContainer),s.appendChild(this.overlayContainer),this.blockContainer.appendChild(s),this.dom=this.blockContainer}ignoreMutation(s){return!s.target.closest(".table-container")||super.ignoreMutation(s)}}const o=this.options.cellMinWidth<nt?nt:this.options.cellMinWidth;return new n(e,o,t)}}}),g1=Gt.TableCell.extend({addKeyboardShortcuts(){return{...this.parent?.(),"Mod-a":()=>{const{state:e,view:t}=this.editor,{selection:n,doc:o}=e,l=n.$anchor,s=I.cellAround(l);if(!s)return!1;const a=o.nodeAt(s.pos);if(!a||!a.textContent)return!1;const i=s.pos+1,c=s.pos+a.nodeSize-1;if(i>=c)return!0;const d=o.resolve(i),f=o.resolve(c),h=M.TextSelection.between(d,f,1);return!h||e.selection.eq(h)||t.dispatch(e.tr.setSelection(h)),!0}}}}),b1=be.Extension.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(C1.configure(this.options.table)),this.options.tableCell!==!1&&e.push(g1.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Gt.TableHeader.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Gt.TableRow.configure(this.options.tableRow)),e}}),w1=["boxSizing","backgroundColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","color","font","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textTransform","textDecoration","textAlign","verticalAlign","whiteSpace","width","minWidth","maxWidth","height","minHeight","maxHeight","backgroundClip"],Tr=e=>e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase());function v1(e,t){const n=getComputedStyle(e);for(const o of w1){const l=String(o),s=n.getPropertyValue(Tr(l));s&&t.style.setProperty(Tr(l),s)}t.style.overflow="hidden",t.style.textOverflow="ellipsis",(n.whiteSpace===""||n.whiteSpace==="normal")&&(t.style.whiteSpace="nowrap")}function Ir(e){const t=e.cloneNode(!0),n=[{src:e,dst:t}];for(;n.length;){const{src:o,dst:l}=n.shift();o instanceof HTMLElement&&l instanceof HTMLElement&&v1(o,l);const s=Array.from(o.children),a=Array.from(l.children),i=Math.min(s.length,a.length);for(let c=0;c<i;c++){const d=s[c],f=a[c];d&&f&&n.push({src:d,dst:f})}}return t}function m1(e,t){Object.assign(e.style,{position:"fixed",top:"-10000px",left:"-10000px",pointerEvents:"none",zIndex:"2147483647",maxWidth:`${t}px`,borderRadius:"12px",background:"transparent",filter:"drop-shadow(0 8px 24px rgba(0,0,0,0.18)) drop-shadow(0 2px 8px rgba(0,0,0,0.10))",overflow:"hidden"})}function y1(e,t){e.isConnected||document.body.appendChild(e);const n=e.getBoundingClientRect();if(n.width>t&&n.width>0){const o=t/n.width;e.style.transformOrigin="top left",e.style.transform=`scale(${o})`}}function Mr(e,t){const n=getComputedStyle(e);t.style.borderCollapse=n.borderCollapse,t.style.borderSpacing=n.borderSpacing,t.style.tableLayout="fixed",t.className=e.className}function kr(e,t){const n=e.getBoundingClientRect();n.width>0&&(t.style.width=`${n.width}px`,t.style.maxWidth=`${n.width}px`)}function x1(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=n.rows?.[t];if(!o)return null;const l=document.createElement("table"),s=document.createElement("tbody"),a=Ir(o);Mr(e,l);for(let i=0;i<o.cells.length;i++){const c=o.cells[i],d=a.cells[i];d&&kr(c,d)}return s.appendChild(a),l.appendChild(s),l}function S1(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=document.createElement("table"),l=document.createElement("tbody");Mr(e,o);let s=0;for(let a=0;a<n.rows.length;a++){const i=n.rows[a];if(!i)continue;const c=i.cells?.[t];if(!c)continue;const d=document.createElement("tr"),f=Ir(c),h=c.getBoundingClientRect();!s&&h.width>0&&(s=h.width),kr(c,f),d.appendChild(f),l.appendChild(d)}return s>0&&(o.style.width=`${s}px`,o.style.maxWidth=`${s}px`),o.appendChild(l),o}function T1(e,t,n,o){const l=e.view.dom.getBoundingClientRect(),s=Math.max(0,l.width),a=document.createElement("div");m1(a,s);const i=e.view.nodeDOM(o);if(!i)return document.body.appendChild(a),a;const c=i.getBoundingClientRect(),d=Math.min(c.width,l.width);a.style.width=`${d}px`;const f=t==="row"?x1(i,n):S1(i,n);if(f){const h=document.createElement("div");Object.assign(h.style,{background:"var(--drag-image-bg, transparent)",overflow:"hidden"}),h.appendChild(f),a.appendChild(h)}return y1(a,s),a}function I1(e,t){t.querySelectorAll(e).forEach(n=>{n.style.visibility="hidden"})}const Se=new M.PluginKey("tableHandlePlugin");class M1{editor;editorView;state=void 0;menuFrozen=!1;mouseState="up";tableId;tablePos;tableElement;emitUpdate;constructor(t,n,o){this.editor=t,this.editorView=n,this.emitUpdate=()=>this.state&&o(this.state),this.editorView.dom.addEventListener("mousemove",this.mouseMoveHandler),this.editorView.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),this.editorView.root.addEventListener("dragover",this.dragOverHandler),this.editorView.root.addEventListener("drop",this.dropHandler)}viewMousedownHandler=t=>{this.mouseState="down";const{state:n,view:o}=this.editor;if(!(n.selection instanceof I.CellSelection)||this.editor.isFocused)return;const l=o.posAtCoords({left:t.clientX,top:t.clientY});if(!l)return;const s=n.doc.resolve(l.pos),{nodes:a}=n.schema;let i=-1,c=!1;for(let p=s.depth;p>=0;p--){const C=s.node(p);if(!c&&(C.type===a.tableCell||C.type===a.tableHeader)&&(c=!0),i===-1&&C.type===a.paragraph&&(i=p),c&&i!==-1)break}if(!c||i===-1)return;const d=s.start(i),f=s.end(i),h=M.TextSelection.create(n.doc,d,f);n.selection.eq(h)||(o.dispatch(n.tr.setSelection(h)),o.focus())};mouseUpHandler=t=>{this.mouseState="up",this.mouseMoveHandler(t)};mouseMoveHandler=t=>{if(this.menuFrozen||this.mouseState==="selecting")return;const n=t.target;!rn(n)||!this.editorView.dom.contains(n)||this._handleMouseMoveNow(t)};hideHandles(){this.state?.show&&(this.state={...this.state,show:!1,showAddOrRemoveRowsButton:!1,showAddOrRemoveColumnsButton:!1,colIndex:void 0,rowIndex:void 0,referencePosCell:void 0},this.emitUpdate())}_handleMouseMoveNow(t){const n=Cr(t.target);if(n?.type==="cell"&&this.mouseState==="down"&&!this.state?.draggingState){this.mouseState="selecting",this.hideHandles();return}if(!n||!this.editor.isEditable){this.hideHandles();return}const o=n.tbodyNode;if(!o)return;const l=o.getBoundingClientRect(),s=this.editor.view.posAtCoords({left:t.clientX,top:t.clientY});if(!s)return;const a=this.editor.view.state.doc.resolve(s.pos);let i;for(let f=a.depth;f>=0;f--){const h=a.node(f);if(Sr(h)){i={node:h,pos:f===0?0:a.before(f)};break}}if(!i||i.node.type.name!=="table")return;this.tableElement=this.editor.view.nodeDOM(i.pos),this.tablePos=i.pos,this.tableId=i.node.attrs.id;const d=pr(n.domNode,".tableWrapper")?.querySelector(".table-controls");if(n.type==="wrapper"){const f=t.clientY>=l.bottom-1&&t.clientY<l.bottom+20,h=t.clientX>=l.right-1&&t.clientX<l.right+20,p=t.clientX>l.right||t.clientY>l.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:f,showAddOrRemoveColumnsButton:h,referencePosTable:l,block:i.node,blockPos:i.pos,widgetContainer:d,colIndex:p?void 0:this.state?.colIndex,rowIndex:p?void 0:this.state?.rowIndex,referencePosCell:p?void 0:this.state?.referencePosCell}}else{const f=xr(n.domNode,i.node,this.editor);if(!f)return;const{rowIndex:h,colIndex:p}=f,C=n.domNode.getBoundingClientRect(),b=i.node.content.childCount-1,g=(i.node.content.firstChild?.content.childCount??0)-1;if(this.state?.show&&this.tableId===i.node.attrs.id&&this.state.rowIndex===h&&this.state.colIndex===p)return;this.state={show:!0,showAddOrRemoveColumnsButton:p===g,showAddOrRemoveRowsButton:h===b,referencePosTable:l,block:i.node,blockPos:i.pos,draggingState:void 0,referencePosCell:C,colIndex:p,rowIndex:h,widgetContainer:d}}return this.emitUpdate(),!1}dragOverHandler=t=>{if(this.state?.draggingState===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",I1(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.editorView.root);const{left:n,right:o,top:l,bottom:s}=this.state.referencePosTable,a={left:He(t.clientX,n+1,o-1),top:He(t.clientY,l+1,s-1)},i=this.editorView.root.elementsFromPoint(a.left,a.top).filter(m=>m.tagName==="TD"||m.tagName==="TH");if(i.length===0)return;const c=i[0];if(!rn(c))return;const d=xr(c,this.state.block,this.editor);if(!d)return;const{rowIndex:f,colIndex:h}=d,p=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,b=(this.state.draggingState.draggedCellOrientation==="row"?f:h)!==p,g=this.state.draggingState.draggedCellOrientation==="row"?a.top:a.left,w=this.state.rowIndex!==f||this.state.colIndex!==h,v=this.state.draggingState.mousePos!==g;(w||v)&&(this.state={...this.state,rowIndex:f,colIndex:h,referencePosCell:c.getBoundingClientRect(),draggingState:{...this.state.draggingState,mousePos:g}},this.emitUpdate()),b&&this.editor.view.dispatch(this.editor.state.tr.setMeta(Se,!0))};dropHandler=()=>{this.mouseState="up";const t=this.state;if(!t?.draggingState)return!1;const{draggingState:n,rowIndex:o,colIndex:l,blockPos:s}=t;if(!K(s))return!1;if(n.draggedCellOrientation==="row"&&o===void 0||n.draggedCellOrientation==="col"&&l===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");const a=n.draggedCellOrientation==="row",i=a?"row":"column",c=a?o:l,d=Ve({editor:this.editor,index:n.originalIndex,orientation:i,tablePos:s});if(!d)return!1;const f=ve(this.editor,s,d,{mode:"state"});if(!f)return!1;const h=p=>this.editor.view.dispatch(p);return a?I.moveTableRow({from:n.originalIndex,to:c,select:!0,pos:s+1})(f,h):I.moveTableColumn({from:n.originalIndex,to:c,select:!0,pos:s+1})(f,h),this.state={...t,draggingState:void 0},this.emitUpdate(),this.editor.view.dispatch(this.editor.state.tr.setMeta(Se,null)),!0};update(t){const n=Se.getState(t.state);if(n!==void 0&&n!==this.menuFrozen&&(this.menuFrozen=n),!this.state?.show)return;if(!this.tableElement?.isConnected){this.hideHandles();return}const o=p1(this.tableElement,this.editor);if(!o){this.hideHandles();return}const l=this.state.block!==o.node||this.state.blockPos!==o.pos;if(!o.node||o.node.type.name!=="table"||!this.tableElement?.isConnected){this.hideHandles();return}const{height:s,width:a}=I.TableMap.get(o.node);let i=this.state.rowIndex,c=this.state.colIndex;i!==void 0&&i>=s&&(i=s?s-1:void 0),c!==void 0&&c>=a&&(c=a?a-1:void 0);const d=this.tableElement.querySelector("tbody");if(!d)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");let f=this.state.referencePosCell;if(i!==void 0&&c!==void 0){const g=d.children[i]?.children[c];g?f=g.getBoundingClientRect():(i=void 0,c=void 0,f=void 0)}const h=d.getBoundingClientRect(),p=i!==this.state.rowIndex||c!==this.state.colIndex,C=f!==this.state.referencePosCell||h!==this.state.referencePosTable;(l||p||C)&&(this.state={...this.state,block:o.node,blockPos:o.pos,rowIndex:i,colIndex:c,referencePosCell:f,referencePosTable:h},this.emitUpdate())}destroy(){this.editorView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.editorView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.editorView.root.removeEventListener("dragover",this.dragOverHandler),this.editorView.root.removeEventListener("drop",this.dropHandler)}}let W=null;function k1(e,t){return new M.Plugin({key:Se,state:{init:()=>!1,apply:(n,o)=>{const l=n.getMeta(Se);return l!==void 0?l:o}},view:n=>(W=new M1(e,n,t),W),props:{decorations:n=>{if(!W)return null;if(W===void 0||W.state===void 0||W.state.draggingState===void 0||W.tablePos===void 0)return;const o=W.state.draggingState.draggedCellOrientation==="row"?W.state.rowIndex:W.state.colIndex;if(o===void 0)return;const l=[],{draggingState:s}=W.state,{originalIndex:a}=s;return W.state.draggingState.draggedCellOrientation==="row"?vr(e,a,W.state.blockPos).cells.forEach(c=>{c.node&&l.push(We.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}):mr(e,a,W.state.blockPos).cells.forEach(c=>{c.node&&l.push(We.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}),o===a||!e||(W.state.draggingState.draggedCellOrientation==="row"?vr(e,o,W.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const f=c.pos+(o>a?d.nodeSize-2:2);l.push(We.Decoration.widget(f,()=>{const h=document.createElement("div");return h.className="tiptap-table-dropcursor",h.style.left="0",h.style.right="0",o>a?h.style.bottom="-1px":h.style.top="-1px",h.style.height="3px",h}))}):mr(e,o,W.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const f=c.pos+(o>a?d.nodeSize-2:2);l.push(We.Decoration.widget(f,()=>{const h=document.createElement("div");return h.className="tiptap-table-dropcursor",h.style.top="0",h.style.bottom="0",o>a?h.style.right="-1px":h.style.left="-1px",h.style.width="3px",h}))})),We.DecorationSet.create(n.doc,l)}}})}const Er=(e,t)=>{if(!W?.state)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{state:n,editor:o}=W,l=e==="col"?n.colIndex:n.rowIndex;if(l===void 0)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{blockPos:s,referencePosCell:a}=n,i=e==="col"?t.clientX:t.clientY;if(o.state.selection instanceof I.CellSelection){const h=M.TextSelection.near(o.state.doc.resolve(s),1);o.view.dispatch(o.state.tr.setSelection(h))}const c=T1(o,e,l,s);if(t.dataTransfer){const h=t.currentTarget.getBoundingClientRect(),p=e==="col"?{x:h.width/2,y:0}:{x:0,y:h.height/2};t.dataTransfer.effectAllowed=e==="col"?"move":"copyMove",t.dataTransfer.setDragImage(c,p.x,p.y)}const d=()=>c.parentNode?.removeChild(c);document.addEventListener("drop",d,{once:!0}),document.addEventListener("dragend",d,{once:!0});const f=a?(e==="col"?a.left:a.top)-i:0;W.state={...n,draggingState:{draggedCellOrientation:e,originalIndex:l,mousePos:i,initialOffset:f}},W.emitUpdate(),o.view.dispatch(o.state.tr.setMeta(Se,!0))},E1=e=>Er("col",{...e,clientY:0}),L1=e=>Er("row",{...e,clientX:0}),A1=()=>{if(!W||W.state===void 0)return;W.state={...W.state,draggingState:void 0},W.emitUpdate();const e=W.editor;e.view.dispatch(e.state.tr.setMeta(Se,null))},H1=be.Extension.create({name:"tableHandleExtension",addCommands(){return{freezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(Se,!0),!0),unfreezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(Se,!1),!0)}},addProseMirrorPlugins(){const{editor:e}=this;return[k1(e,t=>{this.editor.emit("tableHandleState",t)})]}});function N1(e,t,n){if(n?.draggedCellOrientation==="row"){const o=n.mousePos+(n.initialOffset??0),l=He(o,t.y,t.bottom-e.height);return new DOMRect(t.x,l,t.width,e.height)}return new DOMRect(t.x,e.y,t.width,e.height)}function V1(e,t,n){if(n?.draggedCellOrientation==="col"){const o=n.mousePos+(n.initialOffset??0),l=He(o,t.x,t.right-e.width);return new DOMRect(l,t.y,e.width,t.height)}return new DOMRect(e.x,t.y,e.width,t.height)}function B1(e){return new DOMRect(e.x,e.y,e.width,0)}function D1(e){switch(e){case"row":return"left";case"col":return"top";default:return"bottom-end"}}function U1(e){switch(e){case"row":return 4;case"col":return 4;default:return{mainAxis:1,crossAxis:-1}}}function O1(e,t,n,o){switch(e){case"row":return N1(t,n,o);case"col":return V1(t,n,o);default:return B1(t)}}function dn(e,t,n,o,l){const s=u.useMemo(()=>D1(e),[e]),a=u.useMemo(()=>U1(e),[e]),{refs:i,update:c,context:d,floatingStyles:f}=D.useFloating({open:t,placement:s,middleware:[D.offset(a),D.size({apply({rects:C,elements:b}){if(!b.floating)return;const g=(e==="col"?n?.width??o?.width:o?.width)??C.reference.width,w=(e==="row"?n?.height??o?.height:o?.height)??C.reference.height;b.floating.style.setProperty("--table-handle-ref-width",`${g}px`),b.floating.style.setProperty("--table-handle-ref-height",`${w}px`);const v=e==="row"?w:g;b.floating.style.setProperty("--table-handle-available-size",`${v}px`)}})]}),{isMounted:h,styles:p}=D.useTransitionStyles(d);return u.useEffect(()=>{c()},[c,t,e,n,o,l]),u.useEffect(()=>{!n||!o||l&&e==="cell"||i.setReference({getBoundingClientRect:()=>O1(e,n,o,l)})},[i,e,n,o,l]),u.useMemo(()=>({isMounted:h,ref:i.setFloating,style:{display:"flex",...p,...f}}),[h,i.setFloating,p,f])}function P1(e,t,n,o){const l=dn("row",e,t,n,o),s=dn("col",e,t,n,o),a=dn("cell",e,t,n,o);return u.useMemo(()=>({rowHandle:l,colHandle:s,cellHandle:a}),[l,s,a])}function un(e={}){const{editor:t,initialState:n=null,watchFields:o,onStateChange:l}=e,{editor:s}=S(t),[a,i]=u.useState(n),c=u.useRef(n),d=u.useCallback(f=>{o&&c.current&&!o.some(p=>c.current[p]!==f[p])||(i(f),c.current=f,l?.(f))},[o,l]);return u.useEffect(()=>{if(!s){i(null),c.current=null,l?.(null);return}return s.on("tableHandleState",d),()=>{s.off("tableHandleState",d)}},[s,l,d]),a}const wt=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 5C10 3.89543 10.8954 3 12 3C13.1046 3 14 3.89543 14 5C14 6.10457 13.1046 7 12 7C10.8954 7 10 6.10457 10 5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 19C10 17.8954 10.8954 17 12 17C13.1046 17 14 17.8954 14 19C14 20.1046 13.1046 21 12 21C10.8954 21 10 20.1046 10 19Z",fill:"currentColor"})]}));wt.displayName="MoreVerticalIcon";function Z1({className:e,type:t,...n}){return r.jsx("input",{type:t,"data-slot":"tiptap-input",className:U("tiptap-input",e),...n})}Yt.cva("tiptap-input-group-addon",{variants:{align:{"inline-start":"tiptap-input-group-addon--inline-start","inline-end":"tiptap-input-group-addon--inline-end","block-start":"tiptap-input-group-addon--block-start","block-end":"tiptap-input-group-addon--block-end"}},defaultVariants:{align:"inline-start"}}),Yt.cva("tiptap-input-group-button",{variants:{size:{xs:"tiptap-input-group-button--xs",sm:"tiptap-input-group-button--sm","icon-xs":"tiptap-input-group-button--icon-xs","icon-sm":"tiptap-input-group-button--icon-sm"}},defaultVariants:{size:"xs"}});function F1({...e}){return r.jsx(se.ComboboxProvider,{includesBaseElement:!1,resetValueOnHide:!0,...e})}function fn({className:e,...t}){return r.jsx(se.Combobox,{autoSelect:!0,...t,className:U("tiptap-combobox",e)})}function qe({className:e,...t}){return r.jsx(se.ComboboxList,{"data-slot":"tiptap-combobox-list",className:U("tiptap-combobox-list",e),...t})}function $1({className:e,...t}){return r.jsx(se.ComboboxItem,{"data-slot":"tiptap-combobox-item",className:U("tiptap-combobox-item",e),...t})}const z1=typeof window<"u"?u.useLayoutEffect:u.useEffect;function W1(e,t,n,o){const l=u.useRef(t);z1(()=>{l.current=t},[t]),u.useEffect(()=>{const s=window;if(!(s&&s.addEventListener))return;const a=i=>{l.current(i)};return s.addEventListener(e,a,o),()=>{s.removeEventListener(e,a,o)}},[e,n,o])}function _1(e,t,n="mousedown",o={}){W1(n,l=>{const s=l.target;if(!s||!s.isConnected)return;(Array.isArray(e)?e.filter(i=>!!i.current).every(i=>i.current&&!i.current.contains(s)):e.current&&!e.current.contains(s))&&t(l)},void 0,o)}const Lr=(e,t)=>{typeof e=="function"?e(t):e&&typeof e=="object"&&"current"in e&&(e.current=t)},Ar=(e,t)=>{const n=u.useRef(null);return u.useCallback(o=>{e&&"current"in e&&(e.current=o),n.current&&Lr(n.current,null),n.current=t,t&&Lr(t,o)},[e,t])};function Ke({children:e,trigger:t,value:n,onOpenChange:o,onValueChange:l,onValuesChange:s,...a}){const i=!se.useMenuContext(),[c,d]=u.useState(!1),f=!!s||i,h=u.useCallback(b=>{a.open===void 0&&d(b),o?.(b)},[a.open,o]),p=u.useMemo(()=>({isRootMenu:i,open:a.open??c}),[i,a.open,c]),C=r.jsxs(se.MenuProvider,{open:c,setOpen:h,setValues:s,showTimeout:100,...a,children:[t,r.jsx(Nr.Provider,{value:p,children:r.jsx(Hr.Provider,{value:f,children:e})})]});return f?r.jsx(F1,{value:n,setValue:l,children:C}):C}function Ge({children:e,className:t,ref:n,onClickOutside:o,...l}){const s=u.useRef(null),{open:a}=Y1(),i=X1();return _1(s,o||(()=>{})),r.jsx(se.Menu,{ref:Ar(s,n),className:U("tiptap-menu-content",t),"data-side":i,"data-state":a?"open":"closed",gutter:4,flip:!0,unmountOnHide:!0,...l,children:e})}function Ye({className:e,...t}){return r.jsx(se.MenuButton,{...t,className:U("tiptap-menu-button",e)})}function q1({className:e,...t}){return r.jsx(se.MenuButtonArrow,{...t,className:U("tiptap-menu-button-arrow",e)})}function ae({className:e,...t}){return r.jsx(se.MenuGroup,{...t,className:U("tiptap-menu-group",e)})}function ot({className:e,...t}){return r.jsx(se.MenuGroupLabel,{...t,className:U("tiptap-menu-group-label",e)})}function K1({className:e,...t}){return r.jsx(se.MenuItemRadio,{...t,className:U("tiptap-menu-item-radio",e)})}function Te({name:e,value:t,preventClose:n,className:o,...l}){const s=se.useMenuContext(),a=G1(),i=j1(s,n),c={blurOnHoverEnd:!1,focusOnHover:!0,className:U("tiptap-menu-item",o),...l};return a?r.jsx($1,{...c,hideOnClick:i}):e&&t?r.jsx(K1,{...c,hideOnClick:!0,name:e,value:t}):r.jsx(se.MenuItem,{...c})}const Hr=u.createContext(!1),Nr=u.createContext({isRootMenu:!1,open:!1}),G1=()=>u.useContext(Hr),Y1=()=>u.useContext(Nr);function X1(){const e=se.useMenuStore();return se.useStoreState(e,n=>n.currentPlacement?.split("-")[0]||"bottom")}function j1(e,t){return u.useCallback(n=>(n.currentTarget.hasAttribute("aria-expanded")||t||e?.hideAll(),!1),[e,t])}function R({decorative:e,orientation:t="vertical",className:n,...o}){const s=e?{role:"none"}:{"aria-orientation":t==="vertical"?t:void 0,role:"separator"};return r.jsx("div",{className:U("tiptap-separator",n),"data-orientation":t,...s,...o})}const Q1=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l=!1,onDuplicated:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleDuplicate:C,label:b,canDuplicateRowColumn:g,Icon:w}=Br({editor:h,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l,onDuplicated:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});Q1.displayName="TableDuplicateRowColumnButton";const hn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 9C9.44772 9 9 9.44772 9 10V20C9 20.5523 9.44772 21 10 21H20C20.5523 21 21 20.5523 21 20V10C21 9.44772 20.5523 9 20 9H10ZM7 10C7 8.34315 8.34315 7 10 7H20C21.6569 7 23 8.34315 23 10V20C23 21.6569 21.6569 23 20 23H10C8.34315 23 7 21.6569 7 20V10Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C3.45228 3 3 3.45228 3 4V14C3 14.5477 3.45228 15 4 15C4.55228 15 5 15.4477 5 16C5 16.5523 4.55228 17 4 17C2.34772 17 1 15.6523 1 14V4C1 2.34772 2.34772 1 4 1H14C15.6523 1 17 2.34772 17 4C17 4.55228 16.5523 5 16 5C15.4477 5 15 4.55228 15 4C15 3.45228 14.5477 3 14 3H4Z",fill:"currentColor"})]}));hn.displayName="CopyIcon";const Vr=["tableHandleExtension"],J1={row:"Duplicate row",column:"Duplicate column"};function pn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,Vr))return!1;try{if(!J(e,o))return!1;const s=he(e,t,n,o);return s.mergedCells.length>0?!1:s.cells.length>0}catch{return!1}}function R1({editor:e,index:t,tablePos:n}){try{const o=he(e,t,"row",n);if(o.cells.length===0)return!1;let l=!1;if(e.state.selection instanceof I.CellSelection)l=e.chain().focus().addRowAfter().run();else{if(!n)return!1;const h=Ve({editor:e,index:t,orientation:"row",tablePos:n});if(!h)return!1;const p=ve(e,n,h,{mode:"state"});l=I.addRowAfter(p,e.view.dispatch)}if(!l)return!1;const s=he(e,t+1,"row",n);if(s.cells.length===0)return!1;const{state:a,view:i}=e,c=a.tr,d=[...s.cells].reverse(),f=[...o.cells].reverse();return d.forEach((h,p)=>{const C=f[p];if(h.node&&C?.node){const b=h.node.type.create({...C.node.attrs},C.node.content,C.node.marks),g=h.pos+h.node.nodeSize;c.replaceWith(h.pos,g,b)}}),c.docChanged?(i.dispatch(c),an(e,"row",t+1,n),!0):!1}catch(o){return console.error("Error duplicating row:",o),!1}}function ec({editor:e,index:t,tablePos:n}){try{const o=he(e,t,"column",n);if(o.cells.length===0)return!1;let l=!1;if(e.state.selection instanceof I.CellSelection)l=e.chain().focus().addColumnAfter().run();else{if(!n)return!1;const h=Ve({editor:e,index:t,orientation:"column",tablePos:n});if(!h)return!1;const p=ve(e,n,h,{mode:"state"});l=I.addColumnAfter(p,e.view.dispatch)}if(!l)return!1;const s=he(e,t+1,"column",n);if(s.cells.length===0)return!1;const{state:a,view:i}=e,c=a.tr,d=[...s.cells].reverse(),f=[...o.cells].reverse();return d.forEach((h,p)=>{const C=f[p];if(h.node&&C?.node){const b=h.node.type.create({...C.node.attrs},C.node.content,C.node.marks),g=h.pos+h.node.nodeSize;c.replaceWith(h.pos,g,b)}}),c.docChanged?(i.dispatch(c),an(e,"column",t+1,n),!0):!1}catch(o){return console.error("Error duplicating column:",o),!1}}function tc({editor:e,index:t,orientation:n,tablePos:o}){if(!pn({editor:e,index:t,orientation:n,tablePos:o})||!e||!J(e,o))return!1;const s=Y(e,t,n,o);if(!s)return!1;try{return s.orientation==="row"?R1({editor:e,index:s.index,tablePos:o}):s.orientation==="column"?ec({editor:e,index:s.index,tablePos:o}):!1}catch(a){return console.error("Error duplicating row/column:",a),!1}}function nc({editor:e,index:t,orientation:n,hideWhenUnavailable:o}){return!e||!e.isEditable||!V(e,Vr)?!1:o?pn({editor:e,index:t,orientation:n}):!0}function Br(e){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,onDuplicated:a}=e,{editor:i}=S(t),c=Y(i,n,o),d=nc({editor:i,index:n,orientation:o,hideWhenUnavailable:s}),f=pn({editor:i,index:n,tablePos:l,orientation:o}),h=u.useCallback(()=>{const b=tc({editor:i,index:n,orientation:o,tablePos:l});return b&&a?.(),b},[i,n,o,l,a]),p=u.useMemo(()=>J1[c?.orientation||"row"],[c]);return{isVisible:d,canDuplicateRowColumn:f,handleDuplicate:h,label:p,Icon:hn}}const oc=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:l=!1,onMoved:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleMove:C,label:b,canMoveRowColumn:g,Icon:w}=rt({editor:h,index:t,orientation:n,direction:o,hideWhenUnavailable:l,onMoved:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});oc.displayName="TableMoveRowColumnButton";const Cn=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));Cn.displayName="ArrowLeftIcon";const Dr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289C10.9024 4.68342 10.9024 5.31658 11.2929 5.70711L16.5858 11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H16.5858L11.2929 18.2929C10.9024 18.6834 10.9024 19.3166 11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071L19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));Dr.displayName="ArrowRightIcon";const Ur=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071C4.68342 13.0976 5.31658 13.0976 5.70711 12.7071L11 7.41421V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V7.41421L18.2929 12.7071C18.6834 13.0976 19.3166 13.0976 19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));Ur.displayName="ArrowUpIcon";const Or=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M12.707 19.707C12.3165 20.0976 11.6835 20.0976 11.293 19.707L4.29297 12.707C3.90245 12.3165 3.90245 11.6835 4.29297 11.293C4.68349 10.9024 5.31651 10.9024 5.70703 11.293L11 16.5859L11 5C11 4.44771 11.4477 4 12 4C12.5523 4 13 4.44771 13 5L13 16.5859L18.293 11.293C18.6835 10.9024 19.3165 10.9024 19.707 11.293C20.0976 11.6835 20.0976 12.3165 19.707 12.707L12.707 19.707Z",fill:"currentColor"})}));Or.displayName="ArrowDownIcon";const Pr=["tableHandleExtension"],rc={row:{up:"Move row up",down:"Move row down",left:"Move row left",right:"Move row right"},column:{up:"Move column up",down:"Move column down",left:"Move column left",right:"Move column right"}},lc={up:Ur,down:Or,left:Cn,right:Dr};function sc(e,t,n){try{return I.columnIsHeader(e,t,n)}catch{return!1}}function ac(e,t,n){try{return I.rowIsHeader(e,t,n)}catch{return!1}}function gn(e,t){return e==="row"?t==="up"||t==="down":e==="column"?t==="left"||t==="right":!1}function bn({editor:e,index:t,orientation:n,direction:o,tablePos:l}){if(!e||!e.isEditable||!V(e,Pr))return!1;try{const s=J(e,l);if(!s)return!1;const a=Y(e,t,n);if(!a)return!1;const{orientation:i,index:c}=a;if(!gn(i,o)||i==="row"&&ac(s.map,s.node,c)||i==="column"&&sc(s.map,s.node,c))return!1;const{width:d,height:f}=s.map,h=i==="row"?o==="up"?c-1:c+1:o==="left"?c-1:c+1,p=i==="row"?f:d;if(h<0||h>=p)return!1;const C=Ve({editor:e,index:c,orientation:i,tablePos:l}),b=Ve({editor:e,index:h,orientation:i,tablePos:l});if(!C||!b)return!1;const g=ve(e,s.pos,C,{mode:"state"});if(!g)return!1;const w=I.selectedRect(g),v=ve(e,s.pos,b,{mode:"state"});if(!v)return!1;const m=I.selectedRect(v);return wr(s.map,w)&&wr(s.map,m)?!1:i==="row"?o==="up"?c>0:c<f-1:o==="left"?c>0:c<d-1}catch{return!1}}function ic({editor:e,index:t,orientation:n,direction:o,tablePos:l}){if(!bn({editor:e,index:t,orientation:n,direction:o,tablePos:l})||!e)return!1;try{const s=J(e,l);if(!s)return!1;const a=Y(e,t,n);if(!a)return!1;const{orientation:i,index:c}=a;if(!gn(i,o))return!1;const f=c+{up:-1,down:1,left:-1,right:1}[o],h=i==="row"?I.moveTableRow:I.moveTableColumn,p=C=>e.view.dispatch(C);if(e.state.selection instanceof I.CellSelection)return h({from:c,to:f,select:!0,pos:s.start})(e.state,p);{const C=Ve({editor:e,index:c,orientation:i,tablePos:l});if(!C)return!1;const b=ve(e,s.pos,C,{mode:"state"});return b?h({from:c,to:f,select:!0,pos:s.start})(b,p):!1}}catch(s){return console.error("Error moving table row/column:",s),!1}}function cc({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:l,tablePos:s}){if(!e||!e.isEditable||!V(e,Pr))return!1;const a=Y(e,t,n);return!a||!gn(a.orientation,o)?!1:l?bn({editor:e,index:t,orientation:n,direction:o,tablePos:s}):!0}function rt(e){const{editor:t,index:n,orientation:o,tablePos:l,direction:s,hideWhenUnavailable:a=!1,onMoved:i}=e,{editor:c}=S(t),d=Y(c,n,o),f=cc({editor:c,index:n,orientation:o,direction:s,hideWhenUnavailable:a,tablePos:l}),h=bn({editor:c,index:n,orientation:o,direction:s,tablePos:l}),p=u.useCallback(()=>{const g=ic({editor:c,index:n,orientation:o,direction:s,tablePos:l});return g&&i?.(),g},[c,n,o,s,l,i]),C=u.useMemo(()=>rc[d?.orientation||"row"][s]||`Move ${d?.orientation} ${s}`,[d,s]),b=u.useMemo(()=>lc[s],[s]);return{isVisible:f,canMoveRowColumn:h,handleMove:p,label:C,Icon:b}}const dc=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,resetAttrs:l=!1,onCleared:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleClear:C,label:b,canClearRowColumnContent:g,Icon:w}=vt({editor:h,index:t,orientation:n,hideWhenUnavailable:o,resetAttrs:l,onCleared:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});dc.displayName="TableClearRowColumnContentButton";const Zr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V5C20 4.44772 19.5523 4 19 4H5ZM2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM15.7071 8.29289C16.0976 8.68342 16.0976 9.31658 15.7071 9.70711L13.4142 12L15.7071 14.2929C16.0976 14.6834 16.0976 15.3166 15.7071 15.7071C15.3166 16.0976 14.6834 16.0976 14.2929 15.7071L12 13.4142L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L10.5858 12L8.29289 9.70711C7.90237 9.31658 7.90237 8.68342 8.29289 8.29289C8.68342 7.90237 9.31658 7.90237 9.70711 8.29289L12 10.5858L14.2929 8.29289C14.6834 7.90237 15.3166 7.90237 15.7071 8.29289Z",fill:"currentColor"})}));Zr.displayName="SquareXIcon";const Fr=["table"],uc={row:"Clear row contents",column:"Clear column contents"},$r={backgroundColor:null,nodeVerticalAlign:null,nodeTextAlign:null};function zr(e){try{return i1($r)(e.state,e.view.dispatch)}catch(t){return console.error("Error resetting cell attributes:",t),!1}}function wn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,Fr))return!1;try{if(!J(e,o))return!1;const s=Y(e,t,n,o);if(s){const a=he(e,s.index,s.orientation,o);return a.cells.length===0?!1:a.cells.some(i=>i.node&&!Ne(i.node))}else{const{selection:a}=e.state;if(a instanceof I.CellSelection){let f=!1;return a.forEachCell(h=>{Ne(h)||(f=!0)}),f}const{$anchor:i}=a,c=I.cellAround(i);if(!c)return!1;const d=e.state.doc.nodeAt(c.pos);return d?!Ne(d):!1}}catch{return!1}}function fc(e,t=!1){try{const{selection:n}=e.state;if(n instanceof I.CellSelection)return t&&zr(e),I.deleteCellSelection(e.state,e.view.dispatch),!0;const{$anchor:o}=n,l=I.cellAround(o);if(!l)return!1;const s=e.state.doc.nodeAt(l.pos);if(!s)return!1;const a=l.pos+1,i=l.pos+s.nodeSize-1;return a>=i?!1:(t&&zr(e),e.view.dispatch(e.state.tr.delete(a,i)),!0)}catch(n){return console.error("Error clearing selected cells:",n),!1}}function hc({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:l=!1}){try{const{state:s,view:a}=e,i=s.tr,c=he(e,t,n,o);return c.cells.length===0?!1:([...c.cells].reverse().forEach(f=>{if(f.node&&!Ne(f.node)){const h=f.pos+1,p=f.pos+f.node.nodeSize-1;h<p&&i.delete(h,p),l&&i.setNodeMarkup(f.pos,null,{...f.node.attrs,...$r})}}),i.docChanged?(a.dispatch(i),!0):!1)}catch(s){return console.error(`Error clearing ${n} content:`,s),!1}}function pc({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:l=!1}){if(!wn({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const s=Y(e,t,n,o);return s?hc({editor:e,index:s.index,orientation:s.orientation,resetAttrs:l,tablePos:o}):fc(e,l)}catch(s){return console.error("Error clearing table content:",s),!1}}function Cc({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l}){if(!e||!e.isEditable||!V(e,Fr)||!J(e,o))return!1;const a=Y(e,t,n,o),{selection:i}=e.state,c=i instanceof I.CellSelection||I.cellAround(i.$anchor);return!a&&!c?!1:l?wn({editor:e,index:t,orientation:n,tablePos:o}):!0}function vt(e={}){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,resetAttrs:a=!1,onCleared:i}=e,{editor:c}=S(t),d=Y(c,n,o,l),f=Cc({editor:c,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s}),h=wn({editor:c,index:n,orientation:o,tablePos:l}),p=u.useCallback(()=>{const g=pc({editor:c,index:n,orientation:o,tablePos:l,resetAttrs:a});return g&&i?.(),g},[c,n,o,l,a,i]),C=u.useMemo(()=>d?uc[d.orientation]:"Clear contents",[d]);return{isVisible:f,canClearRowColumnContent:h,handleClear:p,label:C,Icon:Zr}}const gc=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,onToggled:l,text:s,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleToggle:p,label:C,canToggleHeader:b,Icon:g,isActive:w}=Kr({editor:f,index:t,orientation:n,hideWhenUnavailable:o,onToggled:l}),v=u.useCallback(m=>{a?.(m),!m.defaultPrevented&&p()},[p,a]);return h?r.jsx(k,{type:"button",disabled:!b,variant:"ghost","data-active-state":w?"on":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":w,tooltip:C,onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"tiptap-button-icon"}),s&&r.jsx("span",{className:"tiptap-button-text",children:s})]})}):null});gc.displayName="TableHeaderRowColumnButton";const Wr=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5V7V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19V7V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5ZM20 19V8H16V20H19C19.5523 20 20 19.5523 20 19ZM14 20L14 8H10L10 20H14ZM8 20L8 8H4V19C4 19.5523 4.44772 20 5 20H8Z",fill:"currentColor"})}));Wr.displayName="TableHeaderRowIcon";const _r=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19ZM8 20V16H20V19C20 19.5523 19.5523 20 19 20H8ZM8 14L20 14V10L8 10V14ZM20 8L8 8V4H19C19.5523 4 20 4.44772 20 5V8Z",fill:"currentColor"})}));_r.displayName="TableHeaderColumnIcon";const qr=["table"],bc={row:"Header row",column:"Header column"},wc={row:Wr,column:_r};function vn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,qr))return!1;const l=Y(e,t,n,o);return l?l.index===0:!1}function vc({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!vn({editor:e,index:t,orientation:n,tablePos:o}))return!1;try{const l=Y(e,t,n,o);if(!l)return!1;const s=l.orientation==="row";if(e.state.selection instanceof I.CellSelection)return s?e.commands.toggleHeaderRow():e.commands.toggleHeaderColumn();if(!K(o))return!1;const a=Ve({editor:e,index:l.index,orientation:l.orientation,tablePos:o});if(!a)return!1;const i=ve(e,o,a,{mode:"state"});if(!i)return!1;const c=d=>e.view.dispatch(d);return s?I.toggleHeader("row")(i,c):I.toggleHeader("column")(i,c)}catch{return!1}}function mc({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:l}){return!e||!e.isEditable||!V(e,qr)?!1:o?vn({editor:e,index:t,orientation:n,tablePos:l}):!!Y(e,t,n)}function Kr(e){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,onToggled:a}=e,{editor:i}=S(t),c=Y(i,n,o),d=mc({editor:i,index:n,orientation:o,hideWhenUnavailable:s,tablePos:l}),f=vn({editor:i,index:n,orientation:o,tablePos:l});let h=!1;if(i?.state.selection instanceof I.CellSelection)h=i?.isActive("tableHeader")||!1;else{const g=he(i,n,c?.orientation,l);if(g){const w=g.cells.length>1?1:0;h=g.cells[w]?.node?.type.name==="tableHeader"||!1}}const p=u.useCallback(()=>{const g=vc({editor:i,index:n,orientation:o,tablePos:l});return g&&a?.(),g},[i,n,o,l,a]),C=bc[c?.orientation||"row"],b=wc[c?.orientation||"row"];return{isVisible:d,canToggleHeader:f,handleToggle:p,label:C,Icon:b,isActive:h}}const yc=u.forwardRef(({editor:e,index:t,orientation:n,side:o,tablePos:l,hideWhenUnavailable:s=!1,onAdded:a,text:i,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,handleAdd:b,label:g,canAddRowColumn:w,Icon:v}=lt({editor:p,index:t,orientation:n,side:o,tablePos:l,hideWhenUnavailable:s,onAdded:a}),m=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?r.jsx(k,{type:"button",disabled:!w,variant:"ghost","data-active-state":"off","data-disabled":!w,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:m,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),i&&r.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});yc.displayName="TableAddRowColumnButton";const Gr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H15C13.3431 22 12 20.6569 12 19V5C12 3.34315 13.3431 2 15 2H19ZM14 19C14 19.5523 14.4477 20 15 20H19C19.5523 20 20 19.5523 20 19V13H14V19ZM15 4C14.4477 4 14 4.44772 14 5V11H20V5C20 4.44772 19.5523 4 19 4H15Z",fill:"currentColor"}),r.jsx("path",{d:"M6 8C6.55228 8 7 8.44772 7 9V11H9C9.55228 11 10 11.4477 10 12C10 12.5523 9.55228 13 9 13H7V15C7 15.5523 6.55228 16 6 16C5.44772 16 5 15.5523 5 15V13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H5V9C5 8.44772 5.44772 8 6 8Z",fill:"currentColor"})]}));Gr.displayName="AddColLeftIcon";const Yr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 2C10.6569 2 12 3.34315 12 5V19C12 20.6569 10.6569 22 9 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H9ZM4 19C4 19.5523 4.44772 20 5 20H9C9.55228 20 10 19.5523 10 19V13H4V19ZM5 4C4.44772 4 4 4.44772 4 5V11H10V5C10 4.44772 9.55228 4 9 4H5Z",fill:"currentColor"}),r.jsx("path",{d:"M18 8C18.5523 8 19 8.44772 19 9V11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H19V15C19 15.5523 18.5523 16 18 16C17.4477 16 17 15.5523 17 15V13H15C14.4477 13 14 12.5523 14 12C14 11.4477 14.4477 11 15 11H17V9C17 8.44772 17.4477 8 18 8Z",fill:"currentColor"})]}));Yr.displayName="AddColRightIcon";const Xr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 14C12.5523 14 13 14.4477 13 15V17H15C15.5523 17 16 17.4477 16 18C16 18.5523 15.5523 19 15 19H13V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V19H9C8.44772 19 8 18.5523 8 18C8 17.4477 8.44772 17 9 17H11V15C11 14.4477 11.4477 14 12 14Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V9C22 10.6569 20.6569 12 19 12H5C3.34315 12 2 10.6569 2 9V5C2 3.34315 3.34315 2 5 2H19ZM5 4C4.44772 4 4 4.44772 4 5V9C4 9.55228 4.44772 10 5 10H11V4H5ZM13 10H19C19.5523 10 20 9.55228 20 9V5C20 4.44772 19.5523 4 19 4H13V10Z",fill:"currentColor"})]}));Xr.displayName="AddRowBottomIcon";const jr=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 12C20.6569 12 22 13.3431 22 15V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V15C2 13.3431 3.34315 12 5 12H19ZM5 14C4.44772 14 4 14.4477 4 15V19C4 19.5523 4.44772 20 5 20H11V14H5ZM13 20H19C19.5523 20 20 19.5523 20 19V15C20 14.4477 19.5523 14 19 14H13V20Z",fill:"currentColor"}),r.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V5H15C15.5523 5 16 5.44772 16 6C16 6.55228 15.5523 7 15 7H13V9C13 9.55228 12.5523 10 12 10C11.4477 10 11 9.55228 11 9V7H9C8.44772 7 8 6.55228 8 6C8 5.44772 8.44772 5 9 5H11V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"})]}));jr.displayName="AddRowTopIcon";const Qr=["table"],Jr={row:{above:"Insert row above",below:"Insert row below"},column:{left:"Insert column left",right:"Insert column right"}};function xc(e,t,n){try{return I.columnIsHeader(e,t,n)}catch{return!1}}function Sc(e,t,n){try{return I.rowIsHeader(e,t,n)}catch{return!1}}function mn({editor:e,index:t,orientation:n,tablePos:o,side:l}){if(!e||!e.isEditable||!V(e,Qr))return!1;const s=J(e,o);if(!s)return!1;const a=Y(e,t,n);if(!a)return!1;const{map:i,node:c}=s,d=a.index,f=a.orientation;return!(typeof d!="number"||d<0||f==="column"&&d>=i.width||f==="row"&&d>=i.height||l==="left"&&f==="column"&&xc(i,c,d)||l==="above"&&f==="row"&&Sc(i,c,d))}function Tc(e,t,n){return t==="row"?n==="above"?e:e+1:n==="left"?e:e+1}function Ic({editor:e,index:t,orientation:n,side:o,tablePos:l}){if(!mn({editor:e,index:t,orientation:n,tablePos:l,side:o})||!e)return!1;const s=Y(e,t,n);if(!s)return!1;const{orientation:a,index:i}=s,c=a==="row",d=h=>e.view.dispatch(h),f=c?o==="above"?I.addRowBefore:I.addRowAfter:o==="left"?I.addColumnBefore:I.addColumnAfter;try{let h=!1;if(e.state.selection instanceof I.CellSelection)h=f(e.state,d);else{const p=J(e,l);if(!p)return!1;const C=a==="row"?{row:i,col:0}:{row:0,col:i},b=ve(e,p.pos,[C],{mode:"state"});if(!b)return!1;h=f(b,d)}if(h){const p=Tc(i,a,o);an(e,a,p,l)}return h}catch(h){return console.error("Error adding row/column:",h),!1}}function Mc({editor:e,index:t,orientation:n,tablePos:o,side:l,hideWhenUnavailable:s}){return!e||!e.isEditable||!V(e,Qr)?!1:s?mn({editor:e,index:t,orientation:n,tablePos:o,side:l}):!!Y(e,t,n)}function lt(e){const{editor:t,index:n,orientation:o,side:l,tablePos:s,hideWhenUnavailable:a=!1,onAdded:i}=e,{editor:c}=S(t),d=Y(c,n,o),f=Mc({editor:c,index:n,orientation:o,tablePos:s,side:l,hideWhenUnavailable:a}),h=mn({editor:c,index:n,orientation:o,tablePos:s,side:l}),p=u.useCallback(()=>{const g=Ic({editor:c,index:n,orientation:o,tablePos:s,side:l});return g&&i?.(),g},[c,n,o,s,l,i]),C=d?.orientation==="row"?Jr.row[l]:Jr.column[l],b=d?.orientation==="row"?l==="above"?jr:Xr:l==="left"?Gr:Yr;return{isVisible:f,canAddRowColumn:h,handleAdd:p,label:C,Icon:b}}const kc=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l=!1,onDeleted:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleDelete:C,label:b,canDeleteRowColumn:g,Icon:w}=el({editor:h,index:t,orientation:n,tablePos:o,hideWhenUnavailable:l,onDeleted:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});kc.displayName="TableDeleteRowColumnButton";const mt=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));mt.displayName="TrashIcon";const Rr=["table"],Ec={row:"Delete row",column:"Delete column"};function yn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,Rr))return!1;try{return!(!J(e,o)||!Y(e,t,n))}catch{return!1}}function Lc({editor:e,index:t,orientation:n,tablePos:o}){if(!yn({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const l=Y(e,t,n);if(!l)return!1;const{orientation:s,index:a}=l,i=s==="row",c=C=>e.view.dispatch(C),d=i?I.deleteRow:I.deleteColumn;if(e.state.selection instanceof I.CellSelection)return d(e.state,c);const f=J(e,o);if(!f)return!1;const h=i?{row:a,col:0}:{row:0,col:a},p=ve(e,f.pos,[h],{mode:"state"});return p?d(p,c):!1}catch(l){return console.error("Error deleting table row/column:",l),!1}}function Ac({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:l}){return!e||!e.isEditable||!V(e,Rr)?!1:o?yn({editor:e,index:t,orientation:n,tablePos:l}):!0}function el(e){const{editor:t,index:n,orientation:o,tablePos:l,hideWhenUnavailable:s=!1,onDeleted:a}=e,{editor:i}=S(t),c=Y(i,n,o),d=Ac({editor:i,index:n,orientation:o,hideWhenUnavailable:s}),f=yn({editor:i,index:n,orientation:o,tablePos:l}),h=u.useCallback(()=>{const C=Lc({editor:i,index:n,orientation:o,tablePos:l});return C&&a?.(),C},[i,n,o,l,a]),p=u.useMemo(()=>Ec[c?.orientation||"row"],[c]);return{isVisible:d,canDeleteRowColumn:f,handleDelete:h,label:p,Icon:mt}}const Hc=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:l=!1,onSorted:s,text:a,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleSort:C,label:b,canSortRowColumn:g,Icon:w}=Tn({editor:h,index:t,orientation:n,direction:o,hideWhenUnavailable:l,onSorted:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),a&&r.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});Hc.displayName="TableSortRowColumnButton";const xn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),r.jsx("path",{d:"M20.1437 13.0107C20.4734 13.0585 20.7615 13.2687 20.9054 13.5762C21.0699 13.9275 21.0171 14.3426 20.7687 14.6406L17.1359 19H20.0002C20.5524 19 21.0002 19.4477 21.0002 20C21.0002 20.5523 20.5524 21 20.0002 21H15.0002C14.6122 21 14.2595 20.7752 14.0949 20.4238C13.9304 20.0725 13.9832 19.6574 14.2316 19.3594L17.8644 15H15.0002C14.4479 15 14.0002 14.5523 14.0002 14C14.0002 13.4477 14.4479 13 15.0002 13H20.0002L20.1437 13.0107Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 3C18.4284 3.00002 19.3184 3.36903 19.9748 4.02539C20.6311 4.68176 21.0002 5.57176 21.0002 6.5V10C21.0002 10.5523 20.5524 11 20.0002 11C19.4479 11 19.0002 10.5523 19.0002 10V9H16.0002V10C16.0002 10.5523 15.5524 11 15.0002 11C14.4479 11 14.0002 10.5523 14.0002 10V6.5C14.0002 5.57174 14.3692 4.68177 15.0256 4.02539C15.6819 3.36904 16.5719 3 17.5002 3ZM17.5002 5C17.1024 5 16.7209 5.15817 16.4396 5.43945C16.1583 5.72076 16.0002 6.10218 16.0002 6.5V7H19.0002V6.5C19.0002 6.10219 18.842 5.72075 18.5607 5.43945C18.2794 5.15817 17.898 5.00002 17.5002 5Z",fill:"currentColor"})]}));xn.displayName="ArrowDownAZIcon";const tl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 13C18.4284 13 19.3184 13.369 19.9748 14.0254C20.6311 14.6818 21.0002 15.5718 21.0002 16.5V20C21.0002 20.5523 20.5524 21 20.0002 21C19.4479 21 19.0002 20.5523 19.0002 20V19H16.0002V20C16.0002 20.5523 15.5524 21 15.0002 21C14.4479 21 14.0002 20.5523 14.0002 20V16.5C14.0002 15.5717 14.3692 14.6818 15.0256 14.0254C15.6819 13.369 16.5719 13 17.5002 13ZM17.5002 15C17.1024 15 16.7209 15.1582 16.4396 15.4395C16.1583 15.7208 16.0002 16.1022 16.0002 16.5V17H19.0002V16.5C19.0002 16.1022 18.842 15.7208 18.5607 15.4395C18.2794 15.1582 17.898 15 17.5002 15Z",fill:"currentColor"}),r.jsx("path",{d:"M20.1437 3.01074C20.4734 3.05854 20.7615 3.26875 20.9054 3.57617C21.0699 3.9275 21.0171 4.34259 20.7687 4.64062L17.1359 9H20.0002C20.5524 9.00004 21.0002 9.44774 21.0002 10C21.0002 10.5523 20.5524 11 20.0002 11H15.0002C14.6122 11 14.2595 10.7752 14.0949 10.4238C13.9304 10.0725 13.9832 9.65742 14.2316 9.35938L17.8644 5H15.0002C14.4479 5 14.0002 4.55228 14.0002 4C14.0002 3.44772 14.4479 3 15.0002 3H20.0002L20.1437 3.01074Z",fill:"currentColor"})]}));tl.displayName="ArrowDownZAIcon";const nl=["tableHandleExtension"],Nc={row:{asc:"Sort row A-Z",desc:"Sort row Z-A"},column:{asc:"Sort column A-Z",desc:"Sort column Z-A"}},Vc={asc:xn,desc:tl};function ol(e){return e?e.type.name==="tableHeader"||e.type.name==="table_header"||e.attrs?.header===!0:!1}function Bc(e){if(!e)return"";let t="";return e.descendants(n=>(n.isText&&(t+=n.text||""),!0)),t.trim().toLowerCase()}function Sn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!V(e,nl))return!1;try{const l=J(e,o);if(!l)return!1;const s=he(e,t,n,o);if(s.orientation==="row"){if(l.map.width<2)return!1}else if(l.map.height<2)return!1;return!(s.mergedCells.length>0||!s.cells.some(i=>i.node&&!ol(i.node)&&!Ne(i.node)))}catch{return!1}}function Dc({editor:e,index:t,orientation:n,direction:o,tablePos:l}){if(!Sn({editor:e,index:t,orientation:n,tablePos:l})||!e)return!1;try{const{state:s,view:a}=e,i=s.tr,c=he(e,t,n,l);if(c.mergedCells.length>0)return console.warn(`Cannot sort ${n} ${t}: contains merged cells`),!1;if(c.cells.length<2)return!1;const d=c.cells.map((g,w)=>{const v=ol(g.node),m=g.node?Ne(g.node):!0;return{sortText:Bc(g.node),originalNode:g.node,cellInfo:g,originalIndex:w,isHeader:v,isEmpty:m}}),f=d.filter(g=>!g.isHeader);if(f.length<2)return!1;f.sort((g,w)=>{if(g.isEmpty&&!w.isEmpty)return 1;if(!g.isEmpty&&w.isEmpty)return-1;if(g.isEmpty&&w.isEmpty)return 0;const v=g.sortText.localeCompare(w.sortText,void 0,{sensitivity:"base"});return o==="asc"?v:-v});const h=[];let p=0;for(let g=0;g<d.length;g++){const w=d[g],v=c.cells[g];if(!v||!w)continue;let m=null;if(w.isHeader?m=w.originalNode:(m=f[p]?.originalNode||null,p++),m&&v.node){const y=v.node.type.create(m.attrs,m.content,m.marks);h.push(y)}else h.push(v.node)}const C=[...c.cells].reverse(),b=[...h].reverse();return C.forEach((g,w)=>{const v=b[w];if(v&&g.node){const m=g.pos+g.node.nodeSize;i.replaceWith(g.pos,m,v)}}),i.docChanged?(a.dispatch(i),!0):!1}catch(s){return console.error(`Error sorting table ${n}:`,s),!1}}function Uc({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:l}){return!e||!e.isEditable||!V(e,nl)||!J(e,l)||!Y(e,t,n,l)?!1:o?Sn({editor:e,index:t,orientation:n,tablePos:l}):!0}function Tn(e={direction:"asc"}){const{editor:t,index:n,orientation:o,tablePos:l,direction:s,hideWhenUnavailable:a=!1,onSorted:i}=e,{editor:c}=S(t),d=Y(c,n,o),f=Uc({editor:c,index:n,orientation:o,hideWhenUnavailable:a,tablePos:l}),h=Sn({editor:c,index:n,orientation:o,tablePos:l}),p=u.useCallback(()=>{const g=Dc({editor:c,index:n,orientation:o,direction:s,tablePos:l});return g&&i?.(),g},[c,n,o,s,l,i]),C=u.useMemo(()=>Nc[d?.orientation||"row"][s]||`Sort ${d?.orientation} ${s}`,[d,s]),b=u.useMemo(()=>Vc[s]||xn,[s]);return{isVisible:f,canSortRowColumn:h,handleSort:p,label:C,Icon:b}}function st({orientation:e="horizontal",size:t,style:n={},...o}){const l={...n,...e==="horizontal"&&!t&&{flex:1},...t&&{width:e==="vertical"?"1px":t,height:e==="horizontal"?"1px":t}};return r.jsx("div",{...o,style:l})}const X=u.forwardRef(({variant:e,size:t="default",appearance:n="default",trimText:o=!1,className:l,children:s,...a},i)=>r.jsx("div",{ref:i,className:`tiptap-badge ${l||""}`,"data-style":e,"data-size":t,"data-appearance":n,"data-text-trim":o?"on":"off",...a,children:s}));X.displayName="Badge";function Oc({shortcutKeys:e=In}){return r.jsx(X,{children:G({shortcutKeys:e})})}const at=u.forwardRef(({editor:e,textColor:t,text:n,hideWhenUnavailable:o=!1,onApplied:l,showShortcut:s=!1,onClick:a,children:i,style:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,canColorText:C,isActive:b,handleColorText:g,label:w,shortcutKeys:v,Icon:m}=rl({editor:h,textColor:t,label:n||`Color text to ${t}`,hideWhenUnavailable:o,onApplied:l}),x=u.useCallback(T=>{a?.(T),!T.defaultPrevented&&g()},[g,a]),y=u.useMemo(()=>({...c,"--color-text-button-color":t}),[t,c]);return p?r.jsx(k,{type:"button",variant:"ghost","data-active-state":b?"on":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":w,"aria-pressed":b,tooltip:w,onClick:x,style:y,...d,ref:f,children:i??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-color-text",style:{color:t},children:r.jsx(m,{className:"tiptap-button-icon",style:{color:t,flexGrow:1}})}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Oc,{shortcutKeys:v})]})}):null});at.displayName="ColorTextButton";function ee(e="max",t=768){const[n,o]=u.useState(void 0);return u.useEffect(()=>{const l=e==="min"?`(min-width: ${t}px)`:`(max-width: ${t-1}px)`,s=window.matchMedia(l),a=i=>o(i.matches);return o(s.matches),s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e,t]),!!n}const yt=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.8944 5.55279C12.725 5.214 12.3787 5 12 5C11.6212 5 11.2749 5.214 11.1055 5.55279L5.10555 17.5528C4.85856 18.0468 5.05878 18.6474 5.55276 18.8944C6.04674 19.1414 6.64741 18.9412 6.8944 18.4472L8.64957 14.9369C8.75862 14.9777 8.87671 15 9 15H15C15.1233 15 15.2413 14.9777 15.3504 14.9369L17.1055 18.4472C17.3525 18.9412 17.9532 19.1414 18.4472 18.8944C18.9412 18.6474 19.1414 18.0468 18.8944 17.5528L12.8944 5.55279ZM14.3819 13L12 8.23607L9.61801 13H14.3819Z",fill:"currentColor"})}));yt.displayName="TextColorSmallIcon";const In="mod+shift+t",it=[{label:"Default text",value:"var(--tt-color-text)",border:"var(--tt-color-text-contrast)"},{label:"Gray text",value:"var(--tt-color-text-gray)",border:"var(--tt-color-text-gray-contrast)"},{label:"Brown text",value:"var(--tt-color-text-brown)",border:"var(--tt-color-text-brown-contrast)"},{label:"Orange text",value:"var(--tt-color-text-orange)",border:"var(--tt-color-text-orange-contrast)"},{label:"Yellow text",value:"var(--tt-color-text-yellow)",border:"var(--tt-color-text-yellow-contrast)"},{label:"Green text",value:"var(--tt-color-text-green)",border:"var(--tt-color-text-green-contrast)"},{label:"Blue text",value:"var(--tt-color-text-blue)",border:"var(--tt-color-text-blue-contrast)"},{label:"Purple text",value:"var(--tt-color-text-purple)",border:"var(--tt-color-text-purple-contrast)"},{label:"Pink text",value:"var(--tt-color-text-pink)",border:"var(--tt-color-text-pink-contrast)"},{label:"Red text",value:"var(--tt-color-text-red)",border:"var(--tt-color-text-red-contrast)"}];function xt(e){if(!e||!e.isEditable||!xe("textStyle",e)||re(e,["image"]))return!1;try{return e.can().setMark("textStyle",{color:"currentColor"})}catch{return!1}}function Pc(e,t){return!e||!e.isEditable?!1:e.isActive("textStyle",{color:t})}function Zc(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!xe("textStyle",t)?!1:t.isActive("code")?!0:xt(t):!0:!1}function rl(e){const{editor:t,label:n,textColor:o,hideWhenUnavailable:l=!1,onApplied:s}=e,{editor:a}=S(t),i=ee(),[c,d]=u.useState(!0),f=xt(a),h=Pc(a,o);u.useEffect(()=>{if(!a)return;const C=()=>{d(Zc({editor:a,hideWhenUnavailable:l}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,l]);const p=u.useCallback(()=>{if(!a||!f)return!1;if(a.state.storedMarks){const C=a.schema.marks.textStyle;C&&a.view.dispatch(a.state.tr.removeStoredMark(C))}setTimeout(()=>{bi(a);const C=a.chain().focus().toggleMark("textStyle",{color:o}).run();return C&&s?.({color:o,label:n}),C},0)},[a,f,o,s,n]);return ie.useHotkeys(In,C=>{C.preventDefault(),p()},{enabled:c&&f,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:c,isActive:h,handleColorText:p,canColorText:f,label:n||`Color text to ${o}`,shortcutKeys:In,Icon:yt}}function Fc({shortcutKeys:e=Mn}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Xe=u.forwardRef(({editor:e,highlightColor:t,text:n,hideWhenUnavailable:o=!1,mode:l="mark",onApplied:s,showShortcut:a=!1,onClick:i,children:c,style:d,useColorValue:f=!1,...h},p)=>{const{editor:C}=S(e),{isVisible:b,canColorHighlight:g,isActive:w,handleColorHighlight:v,label:m,shortcutKeys:x}=Tt({editor:C,highlightColor:t,useColorValue:f,label:n||`Toggle highlight (${t})`,hideWhenUnavailable:o,mode:l,onApplied:s}),y=u.useCallback(E=>{i?.(E),!E.defaultPrevented&&v()},[v,i]),T=u.useMemo(()=>({...d,"--highlight-color":t}),[t,d]);return b?r.jsx(k,{type:"button",variant:"ghost","data-active-state":w?"on":"off",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,"aria-pressed":w,tooltip:m,onClick:y,style:T,...h,ref:p,children:c??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t}}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),a&&r.jsx(Fc,{shortcutKeys:x})]})}):null});Xe.displayName="ColorHighlightButton";const St=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));St.displayName="HighlighterIcon";const Mn="mod+shift+h",Be=[{label:"Default background",value:"var(--tt-bg-color)",colorValue:"#ffffff",border:"var(--tt-bg-color-contrast)"},{label:"Gray background",value:"var(--tt-color-highlight-gray)",colorValue:"#f8f8f7",border:"var(--tt-color-highlight-gray-contrast)"},{label:"Brown background",value:"var(--tt-color-highlight-brown)",colorValue:"#f4eeee",border:"var(--tt-color-highlight-brown-contrast)"},{label:"Orange background",value:"var(--tt-color-highlight-orange)",colorValue:"#fbecdd",border:"var(--tt-color-highlight-orange-contrast)"},{label:"Yellow background",value:"var(--tt-color-highlight-yellow)",colorValue:"#fef9c3",border:"var(--tt-color-highlight-yellow-contrast)"},{label:"Green background",value:"var(--tt-color-highlight-green)",colorValue:"#dcfce7",border:"var(--tt-color-highlight-green-contrast)"},{label:"Blue background",value:"var(--tt-color-highlight-blue)",colorValue:"#e0f2fe",border:"var(--tt-color-highlight-blue-contrast)"},{label:"Purple background",value:"var(--tt-color-highlight-purple)",colorValue:"#f3e8ff",border:"var(--tt-color-highlight-purple-contrast)"},{label:"Pink background",value:"var(--tt-color-highlight-pink)",colorValue:"#fcf1f6",border:"var(--tt-color-highlight-pink-contrast)"},{label:"Red background",value:"var(--tt-color-highlight-red)",colorValue:"#ffe4e6",border:"var(--tt-color-highlight-red-contrast)"}];function ll(e){const t=new Map(Be.map(n=>[n.value,n]));return e.map(n=>t.get(n)).filter(n=>!!n)}function $c(e,t=!1){return t&&Be.find(o=>o.value===e||o.colorValue===e)?.colorValue||e}function De(e,t="mark"){if(!e||!e.isEditable)return!1;if(t==="mark")return!xe("highlight",e)||re(e,["image"])?!1:e.can().setMark("highlight");if(!V(e,["nodeBackground"]))return!1;try{return e.can().toggleNodeBackgroundColor("test")}catch{return!1}}function zc(e,t,n="mark"){if(!e||!e.isEditable)return!1;if(n==="mark")return t?e.isActive("highlight",{color:t}):e.isActive("highlight");if(!t)return!1;try{const{state:o}=e,{selection:l}=o,s=l.$anchor;for(let a=s.depth;a>=0;a--){const i=s.node(a);if(i&&i.attrs?.backgroundColor===t)return!0}return!1}catch{return!1}}function Wc(e,t="mark"){return!e||!e.isEditable||!De(e,t)?!1:t==="mark"?e.chain().focus().unsetMark("highlight").run():e.chain().focus().unsetNodeBackgroundColor().run()}function _c(e){const{editor:t,hideWhenUnavailable:n,mode:o}=e;if(!t)return!1;if(!n)return!0;if(!t.isEditable)return!1;if(o==="mark"){if(!xe("highlight",t))return!1}else if(!V(t,["nodeBackground"]))return!1;return t.isActive("code")?!0:De(t,o)}function Tt(e){const{editor:t,label:n,highlightColor:o,hideWhenUnavailable:l=!1,mode:s="mark",useColorValue:a=!1,onApplied:i}=e,{editor:c}=S(t),d=ee(),[f,h]=u.useState(!0),p=De(c,s),C=o&&$c(o,a),b=zc(c,C,s);u.useEffect(()=>{if(!c)return;const v=()=>{h(_c({editor:c,hideWhenUnavailable:l,mode:s}))};return v(),c.on("selectionUpdate",v),()=>{c.off("selectionUpdate",v)}},[c,l,s]);const g=u.useCallback(()=>{if(!c||!p||!C||!n)return!1;if(s==="mark"){if(c.state.storedMarks){const v=c.schema.marks.highlight;v&&c.view.dispatch(c.state.tr.removeStoredMark(v))}return setTimeout(()=>{const v=c.chain().focus().toggleHighlight({color:C}).run();return v&&i?.({color:C,label:n,mode:s}),v},0),!0}else{const v=c.chain().focus().toggleNodeBackgroundColor(C).run();return v&&i?.({color:C,label:n,mode:s}),v}},[p,C,c,n,i,s]),w=u.useCallback(()=>{const v=Wc(c,s);return v&&i?.({color:"",label:"Remove highlight",mode:s}),v},[c,i,s]);return ie.useHotkeys(Mn,v=>{v.preventDefault(),g()},{enabled:f&&p,enableOnContentEditable:!d,enableOnFormTags:!0}),{isVisible:f,isActive:b,handleColorHighlight:g,handleRemoveHighlight:w,canColorHighlight:p,label:n||"Highlight",shortcutKeys:Mn,Icon:St,mode:s}}function It({editor:e,containerRef:t,query:n,items:o,onSelect:l,onClose:s,orientation:a="vertical",autoSelectFirstItem:i=!0}){const[c,d]=u.useState(i?0:-1);return u.useEffect(()=>{const f=p=>{if(!o.length)return!1;const C=()=>d(g=>g===-1?0:(g+1)%o.length),b=()=>d(g=>g===-1?o.length-1:(g-1+o.length)%o.length);switch(p.key){case"ArrowUp":return a==="horizontal"?!1:(p.preventDefault(),b(),!0);case"ArrowDown":return a==="horizontal"?!1:(p.preventDefault(),C(),!0);case"ArrowLeft":return a==="vertical"?!1:(p.preventDefault(),b(),!0);case"ArrowRight":return a==="vertical"?!1:(p.preventDefault(),C(),!0);case"Tab":return p.preventDefault(),p.shiftKey?b():C(),!0;case"Home":return p.preventDefault(),d(0),!0;case"End":return p.preventDefault(),d(o.length-1),!0;case"Enter":return p.isComposing?!1:(p.preventDefault(),c!==-1&&o[c]&&l?.(o[c]),!0);case"Escape":return p.preventDefault(),s?.(),!0;default:return!1}};let h=null;if(e?h=e.view.dom:t?.current&&(h=t.current),h)return h.addEventListener("keydown",f,!0),()=>{h?.removeEventListener("keydown",f,!0)}},[e,t,o,c,l,s,a]),u.useEffect(()=>{n&&d(i?0:-1)},[n,i]),{selectedIndex:o.length?c:void 0,setSelectedIndex:d}}const kn=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));kn.displayName="ChevronDownIcon";function Mt({...e}){return r.jsx(Ct.Root,{...e})}function kt({...e}){return r.jsx(Ct.Trigger,{...e})}function Et({className:e,align:t="center",sideOffset:n=4,...o}){return r.jsx(Ct.Portal,{children:r.jsx(Ct.Content,{align:t,sideOffset:n,className:U("tiptap-popover",e),...o})})}const Ue=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card",e),...t}));Ue.displayName="Card";const qc=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-header",e),...t}));qc.displayName="CardHeader";const Oe=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-body",e),...t}));Oe.displayName="CardBody";const Ie=u.forwardRef(({className:e,orientation:t="vertical",...n},o)=>r.jsx("div",{ref:o,"data-orientation":t,className:U("tiptap-card-item-group",e),...n}));Ie.displayName="CardItemGroup";const ct=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-group-label",e),...t}));ct.displayName="CardGroupLabel";const Kc=u.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:U("tiptap-card-footer",e),...t}));Kc.displayName="CardFooter";const Gc=Yt.cva("tiptap-button-group",{variants:{orientation:{horizontal:"tiptap-button-group-horizontal",vertical:"tiptap-button-group-vertical"}},defaultVariants:{orientation:"horizontal"}});function ce({className:e,orientation:t,...n}){return r.jsx("div",{role:"group","data-slot":"tiptap-button-group","data-orientation":t,className:U(Gc({orientation:t}),e),...n})}function Yc({colorObj:e,withLabel:t=!1,onColorChanged:n,editor:o,resolveColorValue:l,...s}){const a=e.type==="text"?it:Be,i=al(e.value,a),c=i.label===i.value?e.label:i.label,d=l?.({type:e.type,label:c,value:e.value})??e.value,f={tooltip:c,text:t?c:void 0,onApplied:()=>n?.({type:e.type,label:c,value:i.value}),...s};return e.type==="text"?r.jsx(at,{textColor:d,label:c,editor:o,...f}):r.jsx(Xe,{highlightColor:d,label:c,editor:o,...f})}function sl({type:e,colors:t,onColorSelected:n,selectedIndex:o,startIndexOffset:l,editor:s,resolveColorValue:a}){return t.map((i,c)=>r.jsx(ce,{children:i.map((d,f)=>{const h=l+t.slice(0,c).reduce((g,w)=>g+w.length,0)+f,p=o===h,C=a?.({type:e,label:d.label,value:d.value})??d.value,b={tooltip:d.label,onApplied:()=>n({type:e,label:d.label,value:d.value}),tabIndex:p?0:-1,"data-highlighted":p,"aria-label":`${d.label} ${e==="text"?"text":"highlight"} color`};return e==="text"?r.jsx(ce,{children:r.jsx(at,{textColor:C,label:d.label,editor:s,...b})},`${e}-${d.value}-${f}`):r.jsx(ce,{children:r.jsx(Xe,{highlightColor:C,label:d.label,editor:s,...b})},`${e}-${d.value}-${f}`)})},`${e}-group-${c}`))}function Xc({recentColors:e,onColorSelected:t,selectedIndex:n,editor:o,resolveColorValue:l}){return e.length===0?null:r.jsxs(Ie,{children:[r.jsx(ct,{children:"Recently used"}),r.jsx(ce,{children:e.map((s,a)=>r.jsx(ce,{children:r.jsx(Yc,{colorObj:s,onColorChanged:t,tabIndex:n===a?0:-1,"data-highlighted":n===a,editor:o,resolveColorValue:l})},`recent-${s.type}-${s.value}`))})]})}function jc({maxColorsPerGroup:e=5,maxRecentColors:t=3,onColorChanged:n,editor:o,resolveColorValue:l}){const{recentColors:s,addRecentColor:a,isInitialized:i}=dt(t),c=u.useRef(null),d=u.useMemo(()=>Xo(it,e),[e]),f=u.useMemo(()=>Xo(Be,e),[e]),h=u.useMemo(()=>d.flat(),[d]),p=u.useMemo(()=>f.flat(),[f]),C=u.useMemo(()=>i?s.length:0,[i,s.length]),b=u.useMemo(()=>C+h.length,[C,h.length]),g=u.useMemo(()=>{const m=[];return i&&s.length>0&&m.push(...s.map(x=>({type:x.type,value:x.value,label:`Recent ${x.type==="text"?"text":"highlight"} color`,group:"recent"}))),m.push(...h.map(x=>({type:"text",value:x.value,label:x.label,group:"text"}))),m.push(...p.map(x=>({type:"highlight",value:x.value,label:x.label,group:"highlight"}))),m},[i,s,h,p]),w=u.useCallback(({type:m,label:x,value:y})=>{if(!c.current)return!1;c.current.querySelector('[data-highlighted="true"]')?.click(),a({type:m,label:x,value:y}),n?.({type:m,label:x,value:y})},[a,n]),{selectedIndex:v}=It({containerRef:c,items:g,onSelect:m=>{m&&w({type:m.type,label:m.label,value:m.value})},orientation:"both",autoSelectFirstItem:!1});return r.jsx(Ue,{ref:c,tabIndex:0,role:"menu",children:r.jsxs(Oe,{children:[i&&r.jsx(Xc,{recentColors:s,onColorSelected:w,selectedIndex:v,editor:o,resolveColorValue:l}),r.jsxs(Ie,{children:[r.jsx(ct,{children:"Text color"}),r.jsx(sl,{type:"text",colors:d,onColorSelected:w,selectedIndex:v,startIndexOffset:C,editor:o,resolveColorValue:l})]}),r.jsxs(Ie,{children:[r.jsx(ct,{children:"Highlight color"}),r.jsx(sl,{type:"highlight",colors:f,onColorSelected:w,selectedIndex:v,startIndexOffset:b,editor:o,resolveColorValue:l})]})]})})}function Qc({editor:e,hideWhenUnavailable:t=!1,onColorChanged:n,onClick:o,children:l,ref:s,resolveColorValue:a,...i}){const{editor:c}=S(e),[d,f]=u.useState(!1),{isVisible:h,canToggle:p,activeTextStyle:C,activeHighlight:b,handleColorChanged:g,label:w,Icon:v}=Rc({editor:c,hideWhenUnavailable:t,onColorChanged:n}),m=u.useCallback(x=>{o?.(x),!x.defaultPrevented&&f(y=>!y)},[o]);return h?r.jsxs(Mt,{open:d,onOpenChange:f,children:[r.jsx(kt,{asChild:!0,children:r.jsx(k,{type:"button",variant:"ghost","data-appearance":"default",role:"button","aria-label":w,tooltip:w,disabled:!p,"data-disabled":!p,onClick:m,ref:s,...i,children:l??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-color-text-popover",style:b.color?{"--active-highlight-color":b.color}:{},children:r.jsx(v,{className:"tiptap-button-icon",style:{color:C.color||void 0}})}),r.jsx(kn,{className:"tiptap-button-dropdown-small"})]})})}),r.jsx(Et,{"aria-label":"Text color options",side:"bottom",align:"start",collisionPadding:4,children:r.jsx(jc,{onColorChanged:g,editor:c,resolveColorValue:a})})]}):null}function al(e,t){return t.find(n=>n.value===e)??{value:e,label:e}}function Jc(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:xt(t)||De(t):!1:!0:!1}function dt(e=3){const[t,n]=u.useState([]),[o,l]=u.useState(!1);u.useEffect(()=>{try{const a=localStorage.getItem("tiptapRecentlyUsedColors");if(a){const i=JSON.parse(a);n(i.slice(0,e))}}catch(a){console.error("Failed to load stored colors:",a)}finally{l(!0)}},[e]);const s=u.useCallback(({type:a,label:i,value:c})=>{n(d=>{const f=d.filter(p=>!(p.type===a&&p.value===c)),h=[{type:a,label:i,value:c},...f].slice(0,e);try{localStorage.setItem("tiptapRecentlyUsedColors",JSON.stringify(h))}catch(p){console.error("Failed to store colors:",p)}return h})},[e]);return{recentColors:t,addRecentColor:s,isInitialized:o}}function Rc(e){const{editor:t,hideWhenUnavailable:n=!1,onColorChanged:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),i=xe("textStyle",l),c=xe("highlight",l),d=jo(l,"textStyle")||{},f=jo(l,"highlight")||{},h=xt(l)||De(l);u.useEffect(()=>{if(!l)return;const C=()=>{a(Jc({editor:l,hideWhenUnavailable:n}))};return C(),l.on("selectionUpdate",C),()=>{l.off("selectionUpdate",C)}},[l,n,c,i]);const p=u.useCallback(({type:C,label:b,value:g})=>{o?.({type:C,label:b,value:g})},[o]);return{isVisible:s,canToggle:h,activeTextStyle:d,activeHighlight:f,handleColorChanged:p,label:"Text color",Icon:yt}}const En=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 1.29289C5.31658 0.902369 4.68342 0.902369 4.29289 1.29289C3.90237 1.68342 3.90237 2.31658 4.29289 2.70711L7.08575 5.49997L1.69282 10.8929L1.68582 10.9C1.13614 11.4608 0.828247 12.2147 0.828247 13C0.828247 13.7853 1.1361 14.5392 1.68578 15.1L6.89285 20.3071C8.08338 21.4976 9.91654 21.4976 11.1071 20.3071L19.7071 11.7071C20.0976 11.3166 20.0976 10.6834 19.7071 10.2929L11.7071 2.29289C11.3165 1.90237 10.6834 1.90237 10.2929 2.29289L8.49997 4.08576L5.70711 1.29289ZM17.5857 11L16.5857 12H3.41418L8.49998 6.91419L9.29289 7.70711C9.68342 8.09763 10.3166 8.09763 10.7071 7.70711C11.0976 7.31658 11.0976 6.68342 10.7071 6.29289L9.91419 5.49998L11 4.41421L17.5857 11ZM14.5857 14H3.41418L8.30707 18.8929C8.71654 19.3024 9.28338 19.3024 9.69285 18.8929L14.5857 14Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.9829 15.8157C20.8942 15.3427 20.4812 15 20 15C19.5188 15 19.1058 15.3427 19.0171 15.8157C18.9233 16.3161 18.6226 16.706 18.1385 17.3337L18.0955 17.3895C17.6418 17.9781 17 18.8237 17 20C17 20.7957 17.3161 21.5587 17.8787 22.1213C18.4413 22.6839 19.2043 23 20 23C20.7957 23 21.5587 22.6839 22.1213 22.1213C22.6839 21.5587 23 20.7957 23 20C23 18.8237 22.3582 17.9781 21.9045 17.3895L21.8615 17.3337C21.3774 16.706 21.0767 16.3161 20.9829 15.8157ZM19 20C19 19.5763 19.2082 19.2219 19.6795 18.6105C19.714 18.5658 19.7503 18.5192 19.7881 18.4709C19.855 18.3851 19.9265 18.2935 20 18.1963C20.0735 18.2935 20.1449 18.385 20.2119 18.4708C20.2496 18.5192 20.286 18.5658 20.3205 18.6105C20.7918 19.2219 21 19.5763 21 20C21 20.2652 20.8946 20.5196 20.7071 20.7071C20.5196 20.8946 20.2652 21 20 21C19.7348 21 19.4804 20.8946 19.2929 20.7071C19.1054 20.5196 19 20.2652 19 20Z",fill:"currentColor"})]}));En.displayName="MoreVerticalIcon";const je=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.29289 5.29289C8.68342 4.90237 9.31658 4.90237 9.70711 5.29289L15.7071 11.2929C16.0976 11.6834 16.0976 12.3166 15.7071 12.7071L9.70711 18.7071C9.31658 19.0976 8.68342 19.0976 8.29289 18.7071C7.90237 18.3166 7.90237 17.6834 8.29289 17.2929L13.5858 12L8.29289 6.70711C7.90237 6.31658 7.90237 5.68342 8.29289 5.29289Z",fill:"currentColor"})}));je.displayName="ChevronRightIcon";const il=({editor:e,color:t})=>{const{addRecentColor:n}=dt(),{isActive:o,handleColorText:l,label:s}=rl({editor:e,label:t.label,textColor:t.value,onApplied:({color:a,label:i})=>n({type:"text",label:i,value:a})});return r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:l,children:[r.jsx("span",{className:"tiptap-button-color-text",style:{color:t.value},children:r.jsx(yt,{className:"tiptap-button-icon",style:{color:t.value,flexGrow:1}})}),r.jsx("span",{className:"tiptap-button-text",children:s})]})},cl=({editor:e,color:t})=>{const{addRecentColor:n}=dt(),{isActive:o,handleColorHighlight:l,label:s}=Tt({editor:e,label:t.label,highlightColor:t.value,mode:"node",onApplied:({color:a,label:i})=>n({type:"highlight",label:i,value:a})});return r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:l,children:[r.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t.value}}),r.jsx("span",{className:"tiptap-button-text",children:s})]})},e2=({editor:e,colorObj:t})=>{const n=t.type==="text"?it:Be,o=al(t.value,n),l=t.type==="text"?il:cl;return r.jsx(l,{editor:e,color:o})},Ln=({editor:e,trigger:t,label:n="Color",placement:o="right"})=>{const{editor:l}=S(e),{recentColors:s,isInitialized:a}=dt(),i=!!l?.can().setMark("textStyle")||!!l?.can().setMark("highlight")||De(l,"node")||!1;if(!l||!i)return null;const c=r.jsx(Te,{render:r.jsx(Ye,{render:r.jsxs(k,{variant:"ghost",children:[r.jsx(En,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:n}),r.jsx(st,{}),r.jsx(je,{className:"tiptap-button-icon"})]})})});return r.jsx(Ke,{placement:o,trigger:t||c,children:r.jsx(Ge,{portal:!0,children:r.jsxs(qe,{children:[a&&s.length>0&&r.jsxs(ae,{children:[r.jsx(ot,{children:"Recent colors"}),s.map(d=>r.jsx(e2,{editor:l,colorObj:d},d.value)),r.jsx(R,{orientation:"horizontal"})]}),r.jsxs(ae,{children:[r.jsx(ot,{children:"Text color"}),it.map(d=>r.jsx(il,{editor:l,color:d},d.value))]}),r.jsx(R,{orientation:"horizontal"}),r.jsxs(ae,{children:[r.jsx(ot,{children:"Background color"}),Be.map(d=>r.jsx(cl,{editor:l,color:d},d.value))]})]})})})},t2=u.forwardRef(({editor:e,alignmentType:t,alignment:n,index:o,orientation:l,hideWhenUnavailable:s=!1,onAligned:a,text:i,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,handleAlign:b,label:g,canAlignCell:w,Icon:v,isActive:m}=Pe({editor:p,alignmentType:t,alignment:n,index:o,orientation:l,hideWhenUnavailable:s,onAligned:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&b()},[b,c]);return C?r.jsx(k,{type:"button",disabled:!w,variant:"ghost","data-active-state":m?"on":"off","data-disabled":!w,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":m,tooltip:g,onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),i&&r.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});t2.displayName="TableAlignCellButton";const An=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));An.displayName="AlignLeftIcon";const Hn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));Hn.displayName="AlignCenterIcon";const Nn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));Nn.displayName="AlignRightIcon";const Vn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Vn.displayName="AlignJustifyIcon";const Bn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M11 11.5858L9.70711 10.2929C9.31658 9.90237 8.68342 9.90237 8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929C15.3166 9.90237 14.6834 9.90237 14.2929 10.2929L13 11.5858V4C13 3.44771 12.5523 3 12 3C11.4477 3 11 3.44771 11 4V11.5858Z",fill:"currentColor"}),r.jsx("path",{d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Bn.displayName="AlignBottomIcon";const Dn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M2 4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4C22 4.55228 21.5523 5 21 5H3C2.44772 5 2 4.55228 2 4Z",fill:"currentColor"}),r.jsx("path",{d:"M13 10.4142L14.2929 11.7071C14.6834 12.0976 15.3166 12.0976 15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929L12.7071 7.29289C12.3166 6.90237 11.6834 6.90237 11.2929 7.29289L8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071C8.68342 12.0976 9.31658 12.0976 9.70711 11.7071L11 10.4142L11 20C11 20.5523 11.4477 21 12 21C12.5523 21 13 20.5523 13 20L13 10.4142Z",fill:"currentColor"})]}));Dn.displayName="AlignTopIcon";const dl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M3 12H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M12 22V16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M12 2L12 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M15 19L12 16L9 19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M9 5L12 8L15 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));dl.displayName="AlignMiddleIcon";const Un=["table"],ul={text:{left:"Align left",center:"Align center",right:"Align right",justify:"Justify"},vertical:{top:"Align top",middle:"Align middle",bottom:"Align bottom"}},fl={text:{left:An,center:Hn,right:Nn,justify:Vn},vertical:{top:Dn,middle:dl,bottom:Bn}};function Lt(e){if(!e||!e.isEditable||!V(e,Un))return!1;try{return e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function On({editor:e,index:t,orientation:n}){if(!e||!e.isEditable||!V(e,Un))return!1;try{return!(!J(e)||he(e,t,n).cells.length===0)}catch{return!1}}function n2(e,t){if(!Lt(e)||!e)return null;try{const{selection:n}=e.state,o=n.$anchor;let l=null;for(let a=o.depth;a>=0;a--){const i=o.node(a);if(i.type.name==="tableCell"||i.type.name==="tableHeader"){l=i;break}}if(!l)return null;const s=l.attrs||{};return t==="text"?s.nodeTextAlign||"left":s.nodeVerticalAlign||"top"}catch{return null}}function o2(e,t,n,o){if(!e)return null;try{const l=he(e,n,o);if(l.cells.length===0)return null;const s=l.cells[0];if(!s?.node)return null;const a=s.node.attrs||{};return t==="text"?a.nodeTextAlign||"left":a.nodeVerticalAlign||"top"}catch{return null}}function r2(e,t,n){if(!Lt(e)||!e)return!1;try{return t==="text"?e.commands.setCellAttribute("nodeTextAlign",n):e.commands.setCellAttribute("nodeVerticalAlign",n)}catch(o){return console.error("Error setting table cell alignment:",o),!1}}function l2({editor:e,alignmentType:t,alignment:n,index:o,orientation:l}){if(!On({editor:e,index:o,orientation:l})||!e)return!1;try{const{state:s,view:a}=e,i=s.tr,c=he(e,o,l);if(c.cells.length===0)return!1;const d=new Map;if(c.cells.forEach(p=>{p.node&&p.pos!==void 0&&d.set(p.pos,p)}),d.size===0)return!1;const f=Array.from(d.values()).sort((p,C)=>C.pos-p.pos),h=t==="text"?"nodeTextAlign":"nodeVerticalAlign";return f.forEach(p=>{if(p.node&&p.pos!==void 0){const b=p.node.type.create({...p.node.attrs,[h]:n},p.node.content,p.node.marks),g=p.pos+p.node.nodeSize;i.replaceWith(p.pos,g,b)}}),i.docChanged?(a.dispatch(i),!0):!1}catch(s){return console.error(`Error aligning table ${l}:`,s),!1}}function s2({editor:e,alignmentType:t,alignment:n,index:o,orientation:l}){if(!e)return!1;try{return typeof o=="number"&&l?l2({editor:e,alignmentType:t,alignment:n,index:o,orientation:l}):r2(e,t,n)}catch(s){return console.error("Error aligning table cell:",s),!1}}function a2({editor:e,hideWhenUnavailable:t,index:n,orientation:o}){return!e||!e.isEditable||!V(e,Un)?!1:t?typeof n=="number"&&o?On({editor:e,index:n,orientation:o}):Lt(e):!0}function Pe(e){const{editor:t,alignmentType:n,alignment:o,index:l,orientation:s,hideWhenUnavailable:a=!1,onAligned:i}=e,{editor:c}=S(t),d=a2({editor:c,hideWhenUnavailable:a,index:l,orientation:s}),f=()=>typeof l=="number"&&s?On({editor:c,index:l,orientation:s}):Lt(c),h=()=>typeof l=="number"&&s?o2(c,n,l,s):n2(c,n),p=h()===o,C=u.useCallback(()=>{const w=s2({editor:c,alignmentType:n,alignment:o,index:l,orientation:s});return w&&i?.(o),w},[c,n,o,l,s,i]),b=u.useMemo(()=>n==="text"?ul.text[o]:ul.vertical[o],[n,o]),g=u.useMemo(()=>n==="text"?fl.text[o]:fl.vertical[o],[n,o]);return{isVisible:d,canAlignCell:f,handleAlign:C,label:b,Icon:g,isActive:p,currentAlignment:h}}const hl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M3 16C3.55228 16 4 16.4477 4 17V19L4.00488 19.0986C4.02757 19.3276 4.12883 19.5429 4.29297 19.707C4.48051 19.8946 4.73478 20 5 20H7C7.55228 20 8 20.4477 8 21C8 21.5523 7.55228 22 7 22H5C4.20435 22 3.44151 21.6837 2.87891 21.1211C2.3163 20.5585 2 19.7957 2 19V17C2 16.4477 2.44772 16 3 16Z",fill:"currentColor"}),r.jsx("path",{d:"M21 16C21.5523 16 22 16.4477 22 17V19C22 19.7957 21.6837 20.5585 21.1211 21.1211C20.5585 21.6837 19.7957 22 19 22H17C16.4477 22 16 21.5523 16 21C16 20.4477 16.4477 20 17 20H19C19.2652 20 19.5195 19.8946 19.707 19.707C19.8946 19.5195 20 19.2652 20 19V17C20 16.4477 20.4477 16 21 16Z",fill:"currentColor"}),r.jsx("path",{d:"M7 16C7.55228 16 8 16.4477 8 17C8 17.5523 7.55228 18 7 18C6.44772 18 6 17.5523 6 17C6 16.4477 6.44772 16 7 16Z",fill:"currentColor"}),r.jsx("path",{d:"M12 16C12.5523 16 13 16.4477 13 17C13 17.5523 12.5523 18 12 18C11.4477 18 11 17.5523 11 17C11 16.4477 11.4477 16 12 16Z",fill:"currentColor"}),r.jsx("path",{d:"M17 16C17.5523 16 18 16.4477 18 17C18 17.5523 17.5523 18 17 18C16.4477 18 16 17.5523 16 17C16 16.4477 16.4477 16 17 16Z",fill:"currentColor"}),r.jsx("path",{d:"M7 11C7.55228 11 8 11.4477 8 12C8 12.5523 7.55228 13 7 13C6.44772 13 6 12.5523 6 12C6 11.4477 6.44772 11 7 11Z",fill:"currentColor"}),r.jsx("path",{d:"M12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13C11.4477 13 11 12.5523 11 12C11 11.4477 11.4477 11 12 11Z",fill:"currentColor"}),r.jsx("path",{d:"M17 11C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13C16.4477 13 16 12.5523 16 12C16 11.4477 16.4477 11 17 11Z",fill:"currentColor"}),r.jsx("path",{d:"M7 2C7.55228 2 8 2.44772 8 3C8 3.55228 7.55228 4 7 4H5C4.73478 4 4.4805 4.10543 4.29297 4.29297C4.10543 4.4805 4 4.73478 4 5V7C4 7.55228 3.55228 8 3 8C2.44772 8 2 7.55228 2 7V5C2 4.20435 2.3163 3.44152 2.87891 2.87891C3.44152 2.3163 4.20435 2 5 2H7Z",fill:"currentColor"}),r.jsx("path",{d:"M7 6C7.55228 6 8 6.44772 8 7C8 7.55228 7.55228 8 7 8C6.44772 8 6 7.55228 6 7C6 6.44772 6.44772 6 7 6Z",fill:"currentColor"}),r.jsx("path",{d:"M12 6C12.5523 6 13 6.44772 13 7C13 7.55228 12.5523 8 12 8C11.4477 8 11 7.55228 11 7C11 6.44772 11.4477 6 12 6Z",fill:"currentColor"}),r.jsx("path",{d:"M17 6C17.5523 6 18 6.44772 18 7C18 7.55228 17.5523 8 17 8C16.4477 8 16 7.55228 16 7C16 6.44772 16.4477 6 17 6Z",fill:"currentColor"}),r.jsx("path",{d:"M19 2C19.7957 2 20.5585 2.3163 21.1211 2.87891C21.6837 3.44151 22 4.20435 22 5V7C22 7.55228 21.5523 8 21 8C20.4477 8 20 7.55228 20 7V5C20 4.73478 19.8946 4.48051 19.707 4.29297C19.5429 4.12883 19.3276 4.02757 19.0986 4.00488L19 4H17C16.4477 4 16 3.55228 16 3C16 2.44772 16.4477 2 17 2H19Z",fill:"currentColor"})]}));hl.displayName="AlignmentIcon";const Pn=({index:e,orientation:t})=>{const n={left:Pe({alignmentType:"text",alignment:"left",index:e,orientation:t}),center:Pe({alignmentType:"text",alignment:"center",index:e,orientation:t}),right:Pe({alignmentType:"text",alignment:"right",index:e,orientation:t})},o={top:Pe({alignmentType:"vertical",alignment:"top",index:e,orientation:t}),middle:Pe({alignmentType:"vertical",alignment:"middle",index:e,orientation:t}),bottom:Pe({alignmentType:"vertical",alignment:"bottom",index:e,orientation:t})};return n.left.canAlignCell()?r.jsx(Ke,{placement:"right",trigger:r.jsx(Ye,{render:r.jsx(Te,{render:r.jsxs(k,{variant:"ghost",children:[r.jsx(hl,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:"Alignment"}),r.jsx(q1,{render:r.jsx(je,{})})]})})}),children:r.jsx(Ge,{portal:!0,children:r.jsx(qe,{children:r.jsxs(ae,{children:[Object.values(n).map((l,s)=>r.jsx(Zn,{icon:l.Icon,label:l.label,disabled:!l.canAlignCell,isActive:l.isActive,onClick:l.handleAlign},`text-${s}`)),r.jsx(R,{orientation:"horizontal"}),Object.values(o).map((l,s)=>r.jsx(Zn,{icon:l.Icon,label:l.label,disabled:!l.canAlignCell,isActive:l.isActive,onClick:l.handleAlign},`vertical-${s}`))]})})})}):null},Zn=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:l=!1,shortcutBadge:s})=>r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:n,disabled:o,children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),s]});Zn.displayName="ActionItem";const i2={row:"top-start",column:"bottom-start"},c2={row:"Row actions",column:"Column actions"},pl=u.createContext(null);function At(){const e=u.useContext(pl);if(!e)throw new Error("useTableHandleContext must be used within TableHandleProvider");return e}function Cl(e,t){const{editor:n,orientation:o,index:l,tableNode:s,tablePos:a}=At(),[i,c]=u.useState(!1),[d,f]=u.useState(!1),h=u.useMemo(()=>i2[o],[o]),p=u.useCallback(()=>{if(!(!n||!s||!K(a)||!K(l)))try{const{width:g,height:w}=I.TableMap.get(s),v=o==="row"?{row:l,col:0}:{row:0,col:l},m=o==="row"?{row:l,col:g-1}:{row:w-1,col:l};ve(n,a,[v,m],{mode:"dispatch",dispatch:n.view.dispatch.bind(n.view)})}catch(g){console.warn("Failed to select row/column:",g)}},[n,s,a,o,l]),C=u.useCallback(g=>{n&&(c(g),t?.(g),g?(n.commands.freezeHandles(),p(),e?.(!1)):(n.commands.unfreezeHandles(),e?.(!0)))},[n,t,e,p]),b=u.useCallback(()=>{n&&(c(!1),t?.(!1),n.commands.unfreezeHandles(),e?.(!0))},[n,t,e]);return{isMenuOpen:i,isDragging:d,setIsDragging:f,menuPlacement:h,handleMenuToggle:C,resetMenu:b}}function d2(){const{editor:e,index:t,orientation:n,tablePos:o}=At(),l=el({editor:e,index:t,orientation:n,tablePos:o}),s=Br({editor:e,index:t,orientation:n,tablePos:o}),a=Tn({editor:e,tablePos:o,index:t,orientation:n,direction:"asc",hideWhenUnavailable:!0}),i=Tn({editor:e,tablePos:o,index:t,orientation:n,direction:"desc",hideWhenUnavailable:!0}),c=vt({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:!0,hideWhenUnavailable:!0}),d=Kr({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0}),f=rt({editor:e,index:t,tablePos:o,orientation:"row",direction:"up",hideWhenUnavailable:!0}),h=rt({editor:e,index:t,tablePos:o,orientation:"row",direction:"down",hideWhenUnavailable:!0}),p=rt({editor:e,index:t,tablePos:o,orientation:"column",direction:"left",hideWhenUnavailable:!0}),C=rt({editor:e,index:t,tablePos:o,orientation:"column",direction:"right",hideWhenUnavailable:!0}),b=lt({editor:e,index:t,tablePos:o,orientation:"row",side:"above",hideWhenUnavailable:!0}),g=lt({editor:e,index:t,tablePos:o,orientation:"row",side:"below",hideWhenUnavailable:!0}),w=lt({editor:e,index:t,tablePos:o,orientation:"column",side:"left",hideWhenUnavailable:!0}),v=lt({editor:e,index:t,tablePos:o,orientation:"column",side:"right",hideWhenUnavailable:!0}),m=u.useMemo(()=>({moveUp:f,moveDown:h,moveLeft:p,moveRight:C}),[f,h,p,C]),x=u.useMemo(()=>({addAbove:b,addBelow:g,addLeft:w,addRight:v}),[b,g,w,v]),y=u.useMemo(()=>({sortAsc:a,sortDesc:i}),[a,i]),T=u.useCallback(()=>{const N=[];return y.sortAsc.isVisible&&N.push({icon:y.sortAsc.Icon,label:y.sortAsc.label,disabled:!y.sortAsc.canSortRowColumn,onClick:y.sortAsc.handleSort}),y.sortDesc.isVisible&&N.push({icon:y.sortDesc.Icon,label:y.sortDesc.label,disabled:!y.sortDesc.canSortRowColumn,onClick:y.sortDesc.handleSort}),N},[y]),E=u.useCallback(()=>{const N=[];return n==="row"?(x.addAbove.isVisible&&N.push({icon:x.addAbove.Icon,label:x.addAbove.label,disabled:!x.addAbove.canAddRowColumn,onClick:x.addAbove.handleAdd}),x.addBelow.isVisible&&N.push({icon:x.addBelow.Icon,label:x.addBelow.label,disabled:!x.addBelow.canAddRowColumn,onClick:x.addBelow.handleAdd})):(x.addLeft.isVisible&&N.push({icon:x.addLeft.Icon,label:x.addLeft.label,disabled:!x.addLeft.canAddRowColumn,onClick:x.addLeft.handleAdd}),x.addRight.isVisible&&N.push({icon:x.addRight.Icon,label:x.addRight.label,disabled:!x.addRight.canAddRowColumn,onClick:x.addRight.handleAdd})),N},[n,x]),L=u.useCallback(()=>{const N=[];return n==="row"?(m.moveUp.isVisible&&N.push({icon:m.moveUp.Icon,label:m.moveUp.label,disabled:!m.moveUp.canMoveRowColumn,onClick:m.moveUp.handleMove}),m.moveDown.isVisible&&N.push({icon:m.moveDown.Icon,label:m.moveDown.label,disabled:!m.moveDown.canMoveRowColumn,onClick:m.moveDown.handleMove})):(m.moveLeft.isVisible&&N.push({icon:m.moveLeft.Icon,label:m.moveLeft.label,disabled:!m.moveLeft.canMoveRowColumn,onClick:m.moveLeft.handleMove}),m.moveRight.isVisible&&N.push({icon:m.moveRight.Icon,label:m.moveRight.label,disabled:!m.moveRight.canMoveRowColumn,onClick:m.moveRight.handleMove})),N},[n,m]);return{deleteAction:l,duplicateAction:s,clearContentAction:c,headerAction:d,addItems:E(),moveItems:L(),sortItems:T()}}const Ze=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:l=!1,shortcutBadge:s})=>r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:n,disabled:o,children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),s]}),u2=()=>{const{index:e,orientation:t}=At(),{deleteAction:n,duplicateAction:o,clearContentAction:l,headerAction:s,addItems:a,moveItems:i,sortItems:c}=d2(),d=n.isVisible||o.isVisible||l.isVisible,f=a.length>0,h=i.length>0,p=c.length>0,C=s.isVisible&&e===0;return!d&&!f&&!h&&!p&&!C?null:r.jsxs(r.Fragment,{children:[C&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:r.jsx(Ze,{icon:s.Icon,label:s.label,disabled:!s.canToggleHeader,isActive:s.isActive,onClick:s.handleToggle})}),r.jsx(R,{orientation:"horizontal"})]}),h&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:i.map((b,g)=>r.jsx(Ze,{...b},`move-${g}`))}),r.jsx(R,{orientation:"horizontal"})]}),f&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:a.map((b,g)=>r.jsx(Ze,{...b},`add-${g}`))}),r.jsx(R,{orientation:"horizontal"})]}),p&&r.jsxs(r.Fragment,{children:[r.jsx(ae,{children:c.map((b,g)=>r.jsx(Ze,{...b},`sort-${g}`))}),r.jsx(R,{orientation:"horizontal"})]}),r.jsxs(r.Fragment,{children:[r.jsxs(ae,{children:[r.jsx(Ln,{}),r.jsx(Pn,{index:e,orientation:t}),l.isVisible&&r.jsx(Ze,{icon:l.Icon,label:l.label,disabled:!l.canClearRowColumnContent,onClick:l.handleClear})]}),r.jsx(R,{orientation:"horizontal"})]}),d&&r.jsxs(ae,{children:[o.isVisible&&r.jsx(Ze,{icon:o.Icon,label:o.label,disabled:!o.canDuplicateRowColumn,onClick:o.handleDuplicate}),n.isVisible&&r.jsx(Ze,{icon:n.Icon,label:n.label,disabled:!n.canDeleteRowColumn,onClick:n.handleDelete})]})]})},f2=()=>{const{resetMenu:e}=Cl();return r.jsxs(Ge,{autoFocusOnShow:!0,autoFocusOnHide:!1,modal:!0,onClose:e,children:[r.jsx(fn,{style:Qt}),r.jsx(qe,{style:{minWidth:"15rem"},children:r.jsx(u2,{})})]})},gl=({editor:e,orientation:t,index:n,tableNode:o,tablePos:l,onToggleOtherHandle:s,onOpenChange:a,dragStart:i})=>{const{editor:c}=S(e),d=u.useMemo(()=>({editor:c,orientation:t,index:n,tableNode:o,tablePos:l}),[c,t,n,o,l]);return r.jsx(pl.Provider,{value:d,children:r.jsx(h2,{onToggleOtherHandle:s,onOpenChange:a,dragStart:i})})},h2=({onToggleOtherHandle:e,onOpenChange:t,dragStart:n})=>{const{orientation:o}=At(),{isMenuOpen:l,isDragging:s,setIsDragging:a,menuPlacement:i,handleMenuToggle:c}=Cl(e,t),d=c2[o],f=u.useCallback(p=>{a(!0),n?.(p)},[n,a]),h=u.useCallback(()=>{a(!1),A1()},[a]);return r.jsx(Ke,{open:l,onOpenChange:c,placement:i,trigger:r.jsx(Ye,{className:U("tiptap-table-handle-menu",l&&"menu-opened",s&&"is-dragging",o),draggable:!0,"aria-label":d,"aria-haspopup":"menu","aria-expanded":l,onDragStart:f,onDragEnd:h,children:r.jsx(wt,{className:"tiptap-button-icon"})}),children:r.jsx(f2,{})})};function bl({editor:e,rowButton:t,columnButton:n}){const{editor:o}=S(e),l=un({editor:o}),[s,a]=u.useState(!0),[i,c]=u.useState(!0),[d,f]=u.useState(null),h=u.useMemo(()=>{if(l?.draggingState)return{draggedCellOrientation:l.draggingState.draggedCellOrientation,mousePos:l.draggingState.mousePos,initialOffset:l.draggingState.initialOffset}},[l?.draggingState]),{rowHandle:p,colHandle:C}=P1(l?.show||!1,l?.referencePosCell||null,l?.referencePosTable||null,h),b=u.useCallback(L=>{a(L)},[]),g=u.useCallback(L=>{c(L)},[]),w=u.useCallback((L,N)=>{f(N?L:null)},[]);if(!o||!l)return null;const v=typeof l.rowIndex=="number",m=typeof l.colIndex=="number",x=s&&p.isMounted&&v||d==="row",y=i&&C.isMounted&&m||d==="column",T=t||gl,E=n||gl;return r.jsxs(D.FloatingPortal,{root:l.widgetContainer,children:[x&&r.jsx("div",{ref:p.ref,style:p.style,children:r.jsx(T,{editor:o,orientation:"row",index:l.rowIndex,tablePos:l.blockPos,tableNode:l.block,onToggleOtherHandle:g,dragStart:L1,onOpenChange:L=>w("row",L)})}),y&&r.jsx("div",{ref:C.ref,style:C.style,children:r.jsx(E,{editor:o,orientation:"column",index:l.colIndex,tablePos:l.blockPos,tableNode:l.block,onToggleOtherHandle:b,dragStart:E1,onOpenChange:L=>w("column",L)})})]})}bl.displayName="TableHandle";function p2(e,t){const n=u.useRef(null),o=u.useCallback(()=>{n.current!=null&&(cancelAnimationFrame(n.current),n.current=null)},[]),l=u.useCallback(()=>{if(n.current!=null)return;const s=()=>{const i=!!I.columnResizingPluginKey.getState(e.state)?.dragging;t(),i?n.current=requestAnimationFrame(s):(o(),t())};n.current=requestAnimationFrame(s)},[e,t,o]);u.useEffect(()=>{if(!e)return;const s=({transaction:a})=>{t();const i=a.getMeta(I.columnResizingPluginKey);i&&(Object.prototype.hasOwnProperty.call(i,"setDragging")&&i.setDragging&&l(),Object.prototype.hasOwnProperty.call(i,"setDragging")&&i.setDragging==null&&(o(),t()),Object.prototype.hasOwnProperty.call(i,"setHandle")&&t())};return e.on("transaction",s),()=>{e.off("transaction",s),o()}},[e,l,o,t])}const C2=5,g2=(e,t,n,o)=>{const l=t.posAtCoords({left:n,top:o})?.pos;if(l==null)return null;const s=e.doc.resolve(l);return I.cellAround(s)},b2=(e,t)=>{if(!(t instanceof I.CellSelection))return null;const n=[];if(t.forEachCell((l,s)=>{const a=e.nodeDOM(s);a&&n.push(a)}),n.length===0)return null;const o={left:1/0,top:1/0,right:-1/0,bottom:-1/0};return n.forEach(l=>{const s=l.getBoundingClientRect();o.left=Math.min(o.left,s.left),o.top=Math.min(o.top,s.top),o.right=Math.max(o.right,s.right),o.bottom=Math.max(o.bottom,s.bottom)}),new DOMRect(o.left,o.top,o.right-o.left,o.bottom-o.top)},w2=(e,t)=>{const n=e.nodeDOM(t);if(!n)return null;const o=n.getBoundingClientRect();return new DOMRect(o.left,o.top,o.width,o.height)},v2=e=>({getBoundingClientRect:()=>e}),m2=(e,t,n)=>{const o={topLeft:null,topRight:null,bottomLeft:null,bottomRight:null},l=(s,a)=>Math.abs(s-a)<C2;return t.forEachCell((s,a)=>{const i=e.nodeDOM(a);if(!i)return;const c=i.getBoundingClientRect();l(c.left,n.left)&&l(c.top,n.top)&&(o.topLeft=a),l(c.right,n.right)&&l(c.top,n.top)&&(o.topRight=a),l(c.left,n.left)&&l(c.bottom,n.bottom)&&(o.bottomLeft=a),l(c.right,n.right)&&l(c.bottom,n.bottom)&&(o.bottomRight=a)}),o},y2=(e,t,n,o)=>{if(!o)return null;const a=m2(e,t,n)[{tl:"bottomRight",tr:"bottomLeft",bl:"topRight",br:"topLeft"}[o]];return a?{pos:a}:null},x2=()=>({position:"absolute",width:15,height:15,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",pointerEvents:"auto",zIndex:10}),Ht=(e,t,n=!1)=>({...x2(),...{tl:{top:-7.5,left:-7.5,cursor:n?"default":"nwse-resize"},tr:{top:-7.5,right:-7.5,cursor:n?"default":"nesw-resize"},bl:{bottom:-7.5,left:-7.5,cursor:n?"default":"nesw-resize"},br:{bottom:-7.5,right:-7.5,cursor:n?"default":"nwse-resize"}}[e],opacity:n?.3:t?1:.5,pointerEvents:n?"none":"auto"}),S2=({editor:e,cellMenu:t,showResizeHandles:n=!0,onMenuOpenChange:o})=>{const{editor:l}=S(e),[s,a]=u.useState(!0),[i,c]=u.useState(null),[d,f]=u.useState(null),[h,p]=u.useState(null),[C,b]=u.useState(!1),g=u.useRef(null),w=u.useRef(null),v=u.useRef(null),{refs:m,floatingStyles:x,update:y}=D.useFloating({placement:"top-start"});u.useEffect(()=>{if(i){const O=v2(i);m.setPositionReference(O)}},[i,m]);const T=u.useCallback(()=>{if(!l)return;const{selection:O}=l.state;if(O instanceof I.CellSelection){const z=b2(l.view,O);if(!z){a(!1),c(oe=>oe&&null);return}c(oe=>yr(oe,z)?oe:z),a(!0);return}const{$anchor:_}=O,$=I.cellAround(_);if($){const z=w2(l.view,$.pos);if(z){c(oe=>yr(oe,z)?oe:z),a(!0);return}}a(!1),c(z=>z&&null)},[l]);p2(l,T),u.useEffect(()=>{y&&i&&y()},[y,i]);const E=u.useCallback(O=>_=>{if(!l||!O||!i||C||!n)return;_.preventDefault(),_.stopPropagation();const{selection:$}=l.state;let z=null;if($ instanceof I.CellSelection)z=$;else{const{$anchor:F}=$,q=I.cellAround(F);if(q)try{z=I.CellSelection.create(l.state.doc,q.pos,q.pos)}catch(ne){console.warn("Could not create single cell selection for resize:",ne);return}}if(!z)return;const oe=y2(l.view,z,i,O);if(!oe)return;f(O),w.current=O,g.current=oe.pos;const Z=F=>{if(!l||g.current==null)return;const q=Cr(F.target);if(!q||q.type!=="cell")return;const ne=g2(l.state,l.view,F.clientX,F.clientY);if(ne)try{const pe=I.CellSelection.create(l.state.doc,g.current,ne.pos),B=l.state.tr.setSelection(pe);l.view.dispatch(B)}catch{return}},A=()=>{f(null),w.current=null,g.current=null,window.removeEventListener("mousemove",Z),window.removeEventListener("mouseup",A)};window.addEventListener("mousemove",Z),window.addEventListener("mouseup",A)},[l,i,C,n]),L=u.useCallback(()=>{if(!l){p(null);return}const O=J(l);if(!O){p(null);return}p(_=>{const $=_,z=l.view.nodeDOM(O.pos);return $===z?$:z})},[l]),N=u.useCallback(O=>{b(O),o?.(O)},[o]);if(u.useEffect(()=>{if(!l)return;const O=()=>{T(),L()};return l.on("selectionUpdate",O),T(),L(),()=>{l.off("selectionUpdate",O)}},[l,T,L]),u.useEffect(()=>{const O=h?.querySelector(".table-selection-overlay-container");v.current=O??null},[h]),!s||!i||!l)return null;const te=()=>t?r.jsx("span",{onMouseDown:O=>O.stopPropagation(),style:{pointerEvents:"auto"},children:r.jsx(t,{onOpenChange:N,editor:l,onResizeStart:E})}):null;return r.jsx(D.FloatingPortal,{root:v.current,children:r.jsx("div",{ref:m.setFloating,style:{...x,pointerEvents:"none",zIndex:10},children:r.jsxs("div",{className:"tiptap-table-selection-overlay",children:[r.jsx("div",{style:{position:"absolute",width:i.width,height:i.height,zIndex:2,borderRadius:2,top:0,left:0}}),r.jsxs("div",{style:{position:"absolute",width:i.width,height:i.height,border:"2px solid var(--tt-brand-color-400)",borderRadius:2,zIndex:3,top:0,left:0},children:[te(),n&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:Ht("tl",!d||d==="tl",C),onMouseDown:E("tl")}),r.jsx("div",{style:Ht("tr",!d||d==="tr",C),onMouseDown:E("tr")}),r.jsx("div",{style:Ht("bl",!d||d==="bl",C),onMouseDown:E("bl")}),r.jsx("div",{style:Ht("br",!d||d==="br",C),onMouseDown:E("br")})]})]})]})})})},T2=u.forwardRef(({editor:e,action:t,hideWhenUnavailable:n=!1,onExecuted:o,text:l,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,handleExecute:h,label:p,canExecute:C,Icon:b}=Wn({editor:d,action:t,hideWhenUnavailable:n,onExecuted:o}),g=u.useCallback(w=>{s?.(w),!w.defaultPrevented&&h()},[h,s]);return f?r.jsx(k,{type:"button",disabled:!C,variant:"ghost","data-active-state":"off","data-disabled":!C,role:"button",tabIndex:-1,"aria-label":p,"aria-pressed":!1,tooltip:p,onClick:g,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),l&&r.jsx("span",{className:"tiptap-button-text",children:l})]})}):null});T2.displayName="TableMergeSplitCellButton";const wl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M10 16C10.5177 16 10.9438 16.3933 10.9951 16.8975L11 17V19C11 20.6569 9.65685 22 8 22H4C2.34315 22 1 20.6569 1 19V17C1 16.4477 1.44772 16 2 16C2.55228 16 3 16.4477 3 17V19C3 19.5523 3.44772 20 4 20H8C8.55228 20 9 19.5523 9 19V17L9.00488 16.8975C9.05621 16.3933 9.48232 16 10 16Z",fill:"currentColor"}),r.jsx("path",{d:"M22 16C22.5177 16 22.9438 16.3933 22.9951 16.8975L23 17V19C23 20.6569 21.6569 22 20 22H16C14.3431 22 13 20.6569 13 19V17C13 16.4477 13.4477 16 14 16C14.5523 16 15 16.4477 15 17V19C15 19.5523 15.4477 20 16 20H20C20.5523 20 21 19.5523 21 19V17L21.0049 16.8975C21.0562 16.3933 21.4823 16 22 16Z",fill:"currentColor"}),r.jsx("path",{d:"M5.29297 8.29297C5.68349 7.90244 6.31651 7.90244 6.70703 8.29297L9.70703 11.293L9.77539 11.3691C10.0957 11.7619 10.0731 12.3409 9.70703 12.707L6.70703 15.707C6.31651 16.0975 5.68349 16.0975 5.29297 15.707C4.90245 15.3165 4.90245 14.6835 5.29297 14.293L6.58594 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6.58594L5.29297 9.70703C4.90245 9.31651 4.90245 8.68349 5.29297 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M17.293 8.29297C17.6835 7.90245 18.3165 7.90246 18.707 8.29297C19.0976 8.68349 19.0976 9.31651 18.707 9.70703L17.4141 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H17.4141L18.707 14.293C19.0976 14.6835 19.0976 15.3165 18.707 15.707C18.3165 16.0976 17.6835 16.0976 17.293 15.707L14.293 12.707L14.2246 12.6309C13.9043 12.2381 13.9269 11.6591 14.293 11.293L17.293 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M8 2C9.65685 2 11 3.34315 11 5V7C11 7.55228 10.5523 8 10 8C9.44771 8 9 7.55228 9 7V5C9 4.44772 8.55228 4 8 4H4C3.44772 4 3 4.44772 3 5V7C3 7.55228 2.55228 8 2 8C1.44772 8 1 7.55228 1 7V5C1 3.34315 2.34315 2 4 2H8Z",fill:"currentColor"}),r.jsx("path",{d:"M20 2C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5C13 3.34315 14.3431 2 16 2H20Z",fill:"currentColor"})]}));wl.displayName="TableCellMergeIcon";const vl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 2C2.34315 2 1 3.34315 1 5V7C1 7.55228 1.44772 8 2 8C2.55228 8 3 7.55228 3 7V5C3 4.44772 3.44772 4 4 4H8C8.55228 4 9 4.44772 9 5V7C9 7.55228 9.44772 8 10 8C10.5523 8 11 7.55228 11 7V5C11 3.34315 9.65685 2 8 2H4Z",fill:"currentColor"}),r.jsx("path",{d:"M20 22C21.6569 22 23 20.6569 23 19V17C23 16.4477 22.5523 16 22 16C21.4477 16 21 16.4477 21 17V19C21 19.5523 20.5523 20 20 20H16C15.4477 20 15 19.5523 15 19V17C15 16.4477 14.5523 16 14 16C13.4477 16 13 16.4477 13 17V19C13 20.6569 14.3431 22 16 22H20Z",fill:"currentColor"}),r.jsx("path",{d:"M13 5C13 3.34315 14.3431 2 16 2H20C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5Z",fill:"currentColor"}),r.jsx("path",{d:"M8 22C9.65685 22 11 20.6569 11 19V17C11 16.4477 10.5523 16 10 16C9.44772 16 9 16.4477 9 17V19C9 19.5523 8.55229 20 8 20H4C3.44772 20 3 19.5523 3 19L3 17C3 16.4477 2.55229 16 2 16C1.44772 16 1 16.4477 1 17V19C1 20.6569 2.34315 22 4 22H8Z",fill:"currentColor"}),r.jsx("path",{d:"M18.7071 15.7071L21.7061 12.7081C21.8877 12.527 22 12.2766 22 12L22 11.997C21.9992 11.7421 21.9016 11.4874 21.7071 11.2929L18.7071 8.29289C18.3166 7.90237 17.6834 7.90237 17.2929 8.29289C16.9024 8.68342 16.9024 9.31658 17.2929 9.70711L18.5858 11H15C14.4477 11 14 11.4477 14 12C14 12.5523 14.4477 13 15 13H18.5858L17.2929 14.2929C16.9024 14.6834 16.9024 15.3166 17.2929 15.7071C17.6834 16.0976 18.3166 16.0976 18.7071 15.7071Z",fill:"currentColor"}),r.jsx("path",{d:"M2.07588 11.6172C2.02699 11.7351 2 11.8644 2 12C2 12.2728 2.10925 12.5201 2.2864 12.7005C2.28879 12.703 2.2912 12.7054 2.29362 12.7078L5.29289 15.7071C5.68342 16.0976 6.31658 16.0976 6.70711 15.7071C7.09763 15.3166 7.09763 14.6834 6.70711 14.2929L5.41421 13L9 13C9.55228 13 10 12.5523 10 12C10 11.4477 9.55229 11 9 11L5.41421 11L6.70711 9.70711C7.09763 9.31658 7.09763 8.68342 6.70711 8.29289C6.31658 7.90237 5.68342 7.90237 5.29289 8.29289L2.29366 11.2921C2.29122 11.2946 2.2888 11.297 2.2864 11.2995C2.19374 11.3938 2.12357 11.502 2.07588 11.6172Z",fill:"currentColor"})]}));vl.displayName="TableCellSplitIcon";const Fn=["table"],I2={merge:"Merge cells",split:"Split cell"},M2={merge:wl,split:vl};function $n(e){if(!e||!e.isEditable||!V(e,Fn))return!1;try{return I.mergeCells(e.state,void 0)}catch{return!1}}function zn(e){if(!e||!e.isEditable||!V(e,Fn))return!1;try{return I.splitCell(e.state,void 0)}catch{return!1}}function k2(e){if(!$n(e)||!e)return!1;try{const{state:t,view:n}=e;return I.mergeCells(t,n.dispatch.bind(n))}catch(t){return console.error("Error merging table cells:",t),!1}}function E2(e){if(!zn(e)||!e)return!1;try{const{state:t,view:n}=e;return I.splitCell(t,n.dispatch.bind(n))}catch(t){return console.error("Error splitting table cell:",t),!1}}function L2({editor:e,action:t}){if(!e)return!1;try{return t==="merge"?k2(e):E2(e)}catch(n){return console.error(`Error ${t}ing table cell:`,n),!1}}function A2({editor:e,action:t,hideWhenUnavailable:n}){return!e||!e.isEditable||!V(e,Fn)?!1:n?t==="merge"?$n(e):zn(e):!0}function Wn(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:l}=e,{editor:s}=S(t),a=A2({editor:s,action:n,hideWhenUnavailable:o}),i=n==="merge"?$n(s):zn(s),c=u.useCallback(()=>{const d=L2({editor:s,action:n});return d&&l?.(n),d},[s,n,l]);return{isVisible:a,canExecute:i,handleExecute:c,label:I2[n],Icon:M2[n]}}const ml=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M8 14C9.10457 14 10 14.8954 10 16C10 17.1046 9.10457 18 8 18C6.89543 18 6 17.1046 6 16C6 14.8954 6.89543 14 8 14ZM16 14C17.1046 14 18 14.8954 18 16C18 17.1046 17.1046 18 16 18C14.8954 18 14 17.1046 14 16C14 14.8954 14.8954 14 16 14ZM8 6C9.10457 6 10 6.89543 10 8C10 9.10457 9.10457 10 8 10C6.89543 10 6 9.10457 6 8C6 6.89543 6.89543 6 8 6ZM16 6C17.1046 6 18 6.89543 18 8C18 9.10457 17.1046 10 16 10C14.8954 10 14 9.10457 14 8C14 6.89543 14.8954 6 16 6Z",fill:"currentColor"})}));ml.displayName="Grip4Icon";function H2(){const e=Wn({action:"merge"}),t=Wn({action:"split"}),n=vt({resetAttrs:!0}),o={icon:e.Icon,label:e.label,onClick:e.handleExecute,isAvailable:e.canExecute},l={icon:t.Icon,label:t.label,onClick:t.handleExecute,isAvailable:t.canExecute},s={icon:n.Icon,label:n.label,onClick:n.handleClear,isAvailable:n.canClearRowColumnContent};return{mergeAction:o,splitAction:l,clearAction:s}}function N2({editor:e}){const[t,n]=u.useState(!1),o=u.useCallback(()=>{n(!1),e?.commands.unfreezeHandles()},[e]),l=u.useCallback(s=>{n(s),e&&(s?e.commands.freezeHandles():e.commands.unfreezeHandles())},[e]);return{isMenuOpen:t,handleMenuToggle:l,closeMenu:o}}const _n=({action:e})=>{const{icon:t,label:n,onClick:o,isActive:l=!1,shortcutBadge:s}=e;return r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:o,children:[r.jsx(t,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:n}),s]})},V2=({onClose:e})=>{const{mergeAction:t,splitAction:n,clearAction:o}=H2(),l=t.isAvailable||n.isAvailable;return r.jsxs(Ge,{autoFocusOnShow:!0,modal:!0,onClose:e,children:[r.jsx(fn,{style:Qt}),r.jsxs(qe,{style:{minWidth:"15rem"},children:[l&&r.jsxs(ae,{children:[t.isAvailable&&r.jsx(_n,{action:t}),n.isAvailable&&r.jsx(_n,{action:n}),r.jsx(R,{orientation:"horizontal"})]}),r.jsxs(ae,{children:[r.jsx(Ln,{}),r.jsx(Pn,{}),o.isAvailable&&r.jsx(_n,{action:o})]})]})]})},yl=u.forwardRef(({editor:e,onOpenChange:t,className:n,...o},l)=>{const{editor:s}=S(e),{isMenuOpen:a,handleMenuToggle:i,closeMenu:c}=N2({editor:s});return u.useEffect(()=>{t?.(a)},[a,t]),r.jsx(Ke,{open:a,onOpenChange:i,placement:"bottom-start",trigger:r.jsx(Ye,{ref:l,className:U("expandable-menu-button",a&&"menu-opened",n),"aria-label":"Table cells option","aria-haspopup":"menu","aria-expanded":a,...o,children:r.jsx(ml,{className:"tiptap-button-icon"})}),children:r.jsx(V2,{onClose:c})})});yl.displayName="TableCellHandleMenu";const xl=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M13.5 8C13.5 7.17157 12.8284 6.5 12 6.5C11.1716 6.5 10.5 7.17157 10.5 8V10.5H8C7.17157 10.5 6.5 11.1716 6.5 12C6.5 12.8284 7.17157 13.5 8 13.5H10.5V16C10.5 16.8284 11.1716 17.5 12 17.5C12.8284 17.5 13.5 16.8284 13.5 16V13.5H16C16.8284 13.5 17.5 12.8284 17.5 12C17.5 11.1716 16.8284 10.5 16 10.5H13.5V8Z",fill:"currentColor"})}));xl.displayName="PlusSmallIcon";const B2={row:{placement:"bottom",sizeProperty:"width"},column:{placement:"right",sizeProperty:"height"}};function Sl(e,t,n){const o=B2[e],{refs:l,update:s,context:a,floatingStyles:i}=D.useFloating({open:t,placement:o.placement,middleware:[D.offset(4),D.size({apply({rects:h,elements:p}){const C=p.floating;if(!C)return;const b=`${h.reference[o.sizeProperty]}px`;C.style[o.sizeProperty]=b}})]}),{isMounted:c,styles:d}=D.useTransitionStyles(a),f=u.useCallback(h=>({getBoundingClientRect:()=>h}),[]);return u.useEffect(()=>{n&&(l.setReference(f(n)),s())},[n,l,s,f]),u.useMemo(()=>({isMounted:c,ref:l.setFloating,style:{display:"flex",...d,...i}}),[i,c,l.setFloating,d])}function D2(e,t,n){const o=Sl("row",t,n),l=Sl("column",e,n);return u.useMemo(()=>({rowButton:o,columnButton:l}),[o,l])}const Tl=({editor:e,onMouseDown:t,onMouseUp:n,orientation:o,children:l})=>{const{editor:s}=S(e),a=un({editor:s}),i=o==="row",c=u.useRef(!1),[d,f]=u.useState(null),h=u.useCallback(C=>{if(!a)return;const b=I.TableMap.get(a.block);c.current=!1,f({startPos:i?C.clientY:C.clientX,originalHeight:b.height,originalWidth:b.width}),t(),C.preventDefault()},[a,i,t]),p=u.useCallback(()=>{c.current||!s||!a||sn(s,()=>{cn(s,a.block,a.blockPos,o),i?s.commands.addRowAfter():s.commands.addColumnAfter()})},[s,i,o,a]);return u.useEffect(()=>{if(!d||!s||!a)return;const C=g=>{c.current=!0;const v=(i?g.clientY:g.clientX)-d.startPos,m=i?r1:nt,x=I.TableMap.get(a.block),y=i?x.height:x.width,T=i?d.originalHeight:d.originalWidth,L=Math.max(1,T+u1(v/m,.3))-y;L!==0&&(L>0?sn(s,()=>{cn(s,a.block,a.blockPos,o);for(let N=0;N<L;N++)i?s.commands.addRowAfter():s.commands.addColumnAfter()}):sn(s,()=>{const N=Math.abs(L),te=i?c1(s,a.blockPos):d1(s,a.blockPos),O=Math.min(N,te,y-1);cn(s,a.block,a.blockPos,o);for(let _=0;_<O;_++)i?s.commands.deleteRow():s.commands.deleteColumn()}))},b=()=>{f(null),n()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",b)}},[d,s,i,o,n,a]),s?.isEditable?r.jsx("button",{className:U("tiptap-table-extend-row-column-button",i?"tiptap-table-row-end-add-remove":"tiptap-table-column-end-add-remove",d&&"editing"),onClick:p,onMouseDown:h,type:"button","aria-label":i?"Add or remove rows":"Add or remove columns",children:l??r.jsx(xl,{className:"tiptap-button-icon"})}):null},U2=({editor:e,onMouseDown:t,onMouseUp:n})=>{const{editor:o}=S(e),l=un({editor:o}),{columnButton:s,rowButton:a}=D2(l?.showAddOrRemoveColumnsButton??!1,l?.showAddOrRemoveRowsButton??!1,l?.referencePosTable??null),i=u.useCallback(()=>{o&&(o.commands.freezeHandles(),t?.())},[o,t]),c=u.useCallback(()=>{o&&(o.commands.unfreezeHandles(),n?.())},[o,n]);return l?r.jsxs(D.FloatingPortal,{root:l.widgetContainer,children:[r.jsx("div",{ref:a.ref,style:a.style,children:r.jsx(Tl,{editor:o,orientation:"row",block:l.block,onMouseDown:i,onMouseUp:c})}),r.jsx("div",{ref:s.ref,style:s.style,children:r.jsx(Tl,{editor:o,orientation:"column",block:l.block,onMouseDown:i,onMouseUp:c})})]}):null};function Il(e,t,n,o,l){const{dismissOptions:s,...a}=o||{},{refs:i,context:c,floatingStyles:d}=D.useFloating({open:e,whileElementsMounted(g,w,v){return D.autoUpdate(g,w,v,l)},...a}),{isMounted:f,styles:h}=D.useTransitionStyles(c),p=D.useDismiss(c,s),{getReferenceProps:C,getFloatingProps:b}=D.useInteractions([p]);return u.useEffect(()=>{if(t===null){i.setReference(null);return}if(t instanceof HTMLElement){i.setReference(t);return}const g=()=>(typeof t=="function"?t():t)||new DOMRect;i.setReference({getBoundingClientRect:g})},[t,i]),u.useMemo(()=>({isMounted:f,ref:i.setFloating,style:{...h,...d,zIndex:n},getFloatingProps:b,getReferenceProps:C}),[d,f,i.setFloating,h,n,b,C])}function O2(e,t,n){if(!t?.text||!n)return e;const o=t.text,l=o.lastIndexOf(n);if(l===-1)return e;const s=o.substring(l).length;return e-s}function P2(e,t){const n=t.trim().toLowerCase();return n?e.filter(o=>!!(o.title.toLowerCase().includes(n)||o.subtext?.toLowerCase().includes(n)||o.keywords?.some(l=>l.toLowerCase().includes(n)))).sort((o,l)=>{const s=o.title.toLowerCase(),a=l.title.toLowerCase();return s===n&&a!==n?-1:a===n&&s!==n?1:s.startsWith(n)&&!a.startsWith(n)?-1:a.startsWith(n)&&!s.startsWith(n)?1:0}):e}const qn=({editor:e,floatingOptions:t,selector:n="tiptap-suggestion-menu",children:o,maxHeight:l=384,pluginKey:s=Go.SuggestionPluginKey,...a})=>{const{editor:i}=S(e),[c,d]=u.useState(!1),[f,h]=u.useState(null),[p,C]=u.useState(null),[b,g]=u.useState([]),[w,v]=u.useState(""),[,m]=u.useState(null),{ref:x,style:y,getFloatingProps:T,isMounted:E}=Il(c,f,1e3,{placement:"bottom-start",middleware:[D.offset(10),D.flip({mainAxis:!0,crossAxis:!1}),D.shift(),D.size({apply({availableHeight:_,elements:$}){if($.floating){const z=l?Math.min(l,_):_;$.floating.style.setProperty("--suggestion-menu-max-height",`${z}px`)}}})],onOpenChange(_){_||d(!1)},...t}),L=u.useRef(a);u.useEffect(()=>{L.current=a},[a]);const N=u.useCallback(()=>{d(!1)},[]);u.useEffect(()=>{if(!i||i.isDestroyed)return;i.state.plugins.find(A=>A.spec.key===s)&&i.unregisterPlugin(s);const $=L.current.char??"@",z=i.extensionManager.extensions.find(A=>{if(A.name!=="mention")return!1;const F=A.options?.suggestions;return F?.length?F.some(q=>(q.char??"@")===$):(A.options?.suggestion?.char??"@")===$}),oe={};if(z){let A=null;const F=z.options?.suggestions;if(F?.length?A=F.find(q=>(q.char??"@")===$):z.options?.suggestion&&(A=z.options.suggestion),A){const q=new Set(["pluginKey","editor","render","command","items","allow","char"]);for(const ne of Object.keys(A))q.has(ne)||(oe[ne]=A[ne])}}const Z=Go.Suggestion({...oe,pluginKey:s instanceof M.PluginKey?s:new M.PluginKey(s),editor:i,allow(A){const F=i.state.doc.resolve(A.range.from);for(let q=F.depth;q>0;q--)if(F.node(q).type.name==="image")return!1;return!0},command({editor:A,range:F,props:q}){if(!F)return;const{view:ne,state:pe}=A,{selection:B}=pe;if(!A.extensionManager.extensions.some(ye=>{if(ye.name!=="mention")return!1;const Le=ye.options?.suggestions;return Le?.length?Le.some(Qe=>(Qe.char??"@")===L.current.char):(ye.options?.suggestion?.char??"@")===L.current.char})){const ye=B.$from.pos,Le=B.$head?.nodeBefore,Qe=Le?O2(ye,Le,L.current.char):B.$from.start(),b4=pe.tr.deleteRange(Qe,ye);ne.dispatch(b4)}const Ee={...F};ne.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(Ee.to+=1),q.onSelect({editor:A,range:Ee,context:q.context})},render:()=>({onStart:A=>{h(A.decorationNode??null),C(()=>A.command),g(A.items),v(A.query),m(A.range),d(!0)},onUpdate:A=>{h(A.decorationNode??null),C(()=>A.command),g(A.items),v(A.query),m(A.range)},onKeyDown:A=>A.event.key==="Escape"?(N(),!0):!1,onExit:()=>{h(null),C(null),g([]),v(""),m(null),d(!1)}}),...L.current});return i.registerPlugin(Z),()=>{i.isDestroyed||i.unregisterPlugin(s)}},[i,s,N]);const te=u.useCallback(_=>{N(),p&&p(_)},[N,p]),{selectedIndex:O}=It({editor:i,query:w,items:b,onSelect:te});return!E||!c||!i?null:r.jsx("div",{ref:x,style:y,...T(),"data-selector":n,className:"tiptap-suggestion-menu",role:"listbox","aria-label":"Suggestions",onPointerDown:_=>_.preventDefault(),children:o({items:b,selectedIndex:O,onSelect:te})})},Ml={paragraph:"Text",heading:"Heading",blockquote:"Blockquote",listItem:"List Item",codeBlock:"Code Block",table:"Table",tocNode:"Table of contents"},kl=e=>{if(!e)return"Node";const{selection:t}=e.state;if(t instanceof M.NodeSelection){const l=t.node.type.name;return Ml[l]||l.toLowerCase()}if(t instanceof I.CellSelection)return"Table";const{$anchor:n}=t,o=n.parent.type.name;return Ml[o]||o.toLowerCase()};function Kn(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),l=n.top<o.top,s=n.bottom>o.bottom;return l&&s?"both":l?"top":s?"bottom":"none"}const El=(e,t,n=["imageUpload","horizontalRule"])=>{if(!e)return!1;t||(t=e.state.selection);const{state:o}=e,{doc:l}=o,{empty:s,from:a,to:i}=t,c=!l.textBetween(a,i).length&&P.isTextSelection(t),d=t.$from.parent.type.spec.code||P.isNodeSelection(t)&&t.node.type.spec.code,f=P.isNodeSelection(t)&&n.includes(t.node.type.name),h=t instanceof I.CellSelection;return!s&&!c&&!d&&!f&&!h},Z2=e=>{if(!e)return!1;const{state:t}=e,{selection:n}=t;return P.isTextSelection(n)&&!n.empty&&!n.$from.parent.type.spec.code&&!P.isNodeSelection(n)},F2=e=>{const{state:t}=e.view,{selection:n}=t,{ranges:o}=n,l=Math.min(...o.map(a=>a.$from.pos)),s=Math.max(...o.map(a=>a.$to.pos));if(P.isNodeSelection(n)){const a=e.view.nodeDOM(l);if(a)return a.getBoundingClientRect()}return P.posToDOMRect(e.view,l,s)},Ll=100,$2=(e,t)=>e.name.localeCompare(t.name),z2=(e,t)=>{const n=e.toLowerCase().trim();return t.name.toLowerCase().includes(n)||t.shortcodes.some(o=>o.toLowerCase().includes(n))||t.tags.some(o=>o.toLowerCase().includes(n))},W2=e=>{const{query:t,emojis:n}=e,o=t.trim();return(o?n.filter(s=>z2(o,s)).slice(0,Ll):n.slice(0,Ll)).sort($2)},_2=e=>{const{emoji:t,isSelected:n,onSelect:o,selector:l}=e,s=u.useRef(null);return u.useEffect(()=>{const a=document.querySelector(l);if(!s.current||!n||!a)return;const i=Kn(s.current,a);i==="top"?s.current.scrollIntoView(!0):i==="bottom"&&s.current.scrollIntoView(!1)},[n,l]),t?r.jsxs(k,{ref:s,variant:"ghost","data-active-state":n?"on":"off",onClick:()=>o(t),children:[t.fallbackImage?r.jsx("img",{className:"tiptap-button-emoji",src:t.fallbackImage,alt:t.name}):r.jsx("span",{className:"tiptap-button-emoji",children:t.emoji}),r.jsxs("span",{className:"tiptap-button-text",children:[":",t.name,":"]})]}):null},q2=e=>r.jsx(qn,{char:":",pluginKey:"emojiDropdownMenu",decorationClass:"tiptap-emoji-decoration",selector:"tiptap-emoji-dropdown-menu",items:K2,...e,children:t=>r.jsx(G2,{...t})}),K2=async e=>{const t=e.editor.extensionStorage.emoji.emojis||[];return W2({query:e.query,emojis:t}).map(o=>({title:o.name,subtext:o.shortcodes.join(", "),context:o,onSelect:l=>{!l.editor||!l.range||!l.context||l.editor.chain().focus().setEmoji(l.context.name).run()}}))},G2=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const l=[];return e.forEach((s,a)=>{s.context&&l.push(r.jsx(_2,{emoji:s.context,index:a,isSelected:a===t,onSelect:()=>n(s),selector:"[data-selector='tiptap-emoji-dropdown-menu']"},s.title))}),l},[e,t,n]);return o.length?r.jsx(Ue,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:r.jsx(Oe,{children:r.jsx(Ie,{children:o})})}):null},Al=u.createContext(void 0),Hl=()=>{const e=u.useContext(Al);if(!e)throw new Error("Avatar components must be used within an Avatar.Root");return e},Y2=(e,t)=>{const n=e?"loading":"error",[o,l]=u.useState(n);return u.useLayoutEffect(()=>{if(!e)return;let s=!0;const a=new window.Image,i=c=>()=>{s&&l(c)};return a.onload=i("loaded"),a.onerror=i("error"),a.src=e,t&&(a.referrerPolicy=t),()=>{s=!1}},[e,t]),o},Nl=u.forwardRef(({children:e,className:t="",size:n="default",userColor:o,...l},s)=>{const[a,i]=u.useState("idle"),c=u.useCallback(h=>{i(h)},[]),d=u.useMemo(()=>({imageLoadingStatus:a,onImageLoadingStatusChange:c,size:n}),[a,c,n]),f=o?{"--dynamic-user-color":o}:void 0;return r.jsx(Al.Provider,{value:d,children:r.jsx("span",{...l,ref:s,className:`tiptap-avatar ${t}`,style:f,"data-size":n,children:r.jsx("span",{className:"tiptap-avatar-item",children:e})})})});Nl.displayName="Avatar";const Vl=u.forwardRef(({onLoadingStatusChange:e,src:t,className:n="",...o},l)=>{const{onImageLoadingStatusChange:s}=Hl(),a=Y2(t,o.referrerPolicy);return u.useLayoutEffect(()=>{a!=="idle"&&(e?.(a),s(a))},[a,e,s]),a!=="loaded"?null:r.jsx("img",{alt:"",...o,ref:l,src:t,className:`tiptap-avatar-image ${n}`})});Vl.displayName="AvatarImage";const Bl=u.forwardRef(({delayMs:e,className:t="",children:n,...o},l)=>{const s=Hl(),[a,i]=u.useState(e===void 0);return u.useEffect(()=>{if(e!==void 0){const c=window.setTimeout(()=>i(!0),e);return()=>window.clearTimeout(c)}},[e]),!a||s.imageLoadingStatus==="loaded"?null:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`tiptap-avatar-bg ${t}`}),r.jsx("span",{...o,ref:l,className:`tiptap-avatar-fallback ${t}`,children:n})]})});Bl.displayName="AvatarFallback";const X2=async e=>{const n={users:[["Emily Johnson","Marketing Manager"],["Michael Thompson","Sales Manager"],["Sophia Lee","Product Designer"],["William Davis","IT Project Manager"],["Olivia Wilson","HR Specialist"],["Daniel Taylor","Financial Controller"],["Isabella Anderson","Graphic Designer"],["Jacob Martinez","Sales Representative"],["Ava Hernandez","Marketing Assistant"],["Alexander Diaz","IT Support"],["Emma Ramirez","HR Specialist"],["Ethan Flores","Product Manager"],["Mia Morales","Graphic Designer"],["Noah Reyes","Sales Manager"],["Isabella Castillo","Marketing Manager"],["Liam Gutierrez","IT Project Manager"],["Avery Jimenez","HR Specialist"],["Lucas Vargas","Product Designer"],["Chloe Rojas","Graphic Designer"],["Kai Zhang","Sales Representative"]].map(([o,l],s)=>{const a=s+1,i=a<10?`0${a}`:`${a}`;return{id:a,name:o,position:l,avatarUrl:`/avatars/memoji_${i}.png`}})};return e?n.users.filter(o=>o.name.toLowerCase().includes(e.toLowerCase())||o.position.toLowerCase().includes(e.toLowerCase())):n.users},j2=e=>{const t=o=>{!o.editor||!o.range||!o.context||o.editor.chain().focus().insertContentAt(o.range,[{type:"mention",attrs:{id:o.context.id.toString(),label:o.context.name}},{type:"text",text:" "}]).run()},n=async o=>(await X2(o.query)).map(s=>({title:s.name,subtext:s.position,context:s,onSelect:t}));return r.jsx(qn,{char:"@",pluginKey:"mentionDropdownMenu",decorationClass:"tiptap-mention-decoration",selector:"tiptap-mention-dropdown-menu",items:n,...e,children:o=>r.jsx(J2,{...o})})},Q2=({item:e,isSelected:t,onSelect:n})=>{const o=u.useRef(null);return u.useEffect(()=>{const l=document.querySelector('[data-selector="tiptap-mention-dropdown-menu"]');if(!o.current||!t||!l)return;const s=Kn(o.current,l);s==="top"?o.current.scrollIntoView(!0):s==="bottom"&&o.current.scrollIntoView(!1)},[t]),r.jsxs(k,{ref:o,variant:"ghost","data-active-state":t?"on":"off",onClick:n,"data-user-id":e.context?.id,children:[r.jsxs(Nl,{children:[r.jsx(Vl,{src:e.context?.avatarUrl,alt:e.title}),r.jsx(Bl,{children:e.title[0]?.toUpperCase()})]}),r.jsx("span",{className:"tiptap-button-text",children:e.title})]})},J2=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const l=[];return e.forEach((s,a)=>{l.push(r.jsx(Q2,{item:s,isSelected:a===t,onSelect:()=>n(s)},s.context?.id||s.title))}),l},[e,t,n]);return o.length?r.jsx(Ue,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:r.jsx(Oe,{children:r.jsx(Ie,{children:o})})}):null},Gn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));Gn.displayName="CodeBlockIcon";const Yn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));Yn.displayName="HeadingOneIcon";const Xn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));Xn.displayName="HeadingTwoIcon";const jn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));jn.displayName="HeadingThreeIcon";const Dl=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V5C20 4.44772 19.5523 4 19 4H5ZM22 14.998V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H5.99781C5.99927 22 6.00073 22 6.00219 22H19C20.6569 22 22 20.6569 22 19V15.002C22 15.0007 22 14.9994 22 14.998ZM20 15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20H19C19.5523 20 20 19.5523 20 19V15.4142ZM9 8C8.44772 8 8 8.44772 8 9C8 9.55228 8.44772 10 9 10C9.55228 10 10 9.55228 10 9C10 8.44772 9.55228 8 9 8ZM6 9C6 7.34315 7.34315 6 9 6C10.6569 6 12 7.34315 12 9C12 10.6569 10.6569 12 9 12C7.34315 12 6 10.6569 6 9Z",fill:"currentColor"})}));Dl.displayName="ImageIcon";const Qn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Qn.displayName="ListIcon";const Jn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));Jn.displayName="ListOrderedIcon";const Rn=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));Rn.displayName="BlockquoteIcon";const eo=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"})]}));eo.displayName="ListTodoIcon";const Ul=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 12C4 11.4477 4.44772 11 5 11H19C19.5523 11 20 11.4477 20 12C20 12.5523 19.5523 13 19 13H5C4.44772 13 4 12.5523 4 12Z",fill:"currentColor"})}));Ul.displayName="MinusIcon";const to=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M3 4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V7C21 7.55228 20.5523 8 20 8C19.4477 8 19 7.55228 19 7V5H13V19H15C15.5523 19 16 19.4477 16 20C16 20.5523 15.5523 21 15 21H9C8.44772 21 8 20.5523 8 20C8 19.4477 8.44772 19 9 19H11V5H5V7C5 7.55228 4.55228 8 4 8C3.44772 8 3 7.55228 3 7V4Z",fill:"currentColor"})}));to.displayName="TypeIcon";const no=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5273 1.29427C12.1156 0.724951 9.58234 0.986597 7.33794 2.03682C5.09354 3.08704 3.26948 4.8643 2.1613 7.08066C1.05312 9.29702 0.725742 11.8226 1.23221 14.2483C1.73868 16.6739 3.04931 18.8575 4.95178 20.4453C6.85424 22.033 9.23706 22.9319 11.7142 22.9963C14.1913 23.0607 16.6176 22.2868 18.6 20.8C19.0418 20.4686 19.1314 19.8418 18.8 19.4C18.4686 18.9582 17.8418 18.8686 17.4 19.2C15.7781 20.4165 13.7929 21.0496 11.7662 20.997C9.73942 20.9443 7.78983 20.2088 6.23327 18.9098C4.67671 17.6107 3.60437 15.8241 3.18999 13.8395C2.77561 11.8549 3.04346 9.78847 3.95015 7.97509C4.85685 6.1617 6.34926 4.70758 8.18559 3.84831C10.0219 2.98904 12.0946 2.77496 14.0678 3.24077C16.041 3.70658 17.7991 4.82497 19.0573 6.41476C20.3155 8.00455 21 9.97258 21 12V13C21 13.5304 20.7893 14.0392 20.4142 14.4142C20.0391 14.7893 19.5304 15 19 15C18.4696 15 17.9609 14.7893 17.5858 14.4142C17.2107 14.0392 17 13.5304 17 13V8.00001C17 7.44772 16.5523 7.00001 16 7.00001C15.4478 7.00001 15.0002 7.44752 15 7.99964C14.1643 7.37195 13.1256 7 12 7C9.23858 7 7 9.23858 7 12C7 14.7614 9.23858 17 12 17C13.4881 17 14.8243 16.3499 15.7403 15.3183C15.8687 15.4989 16.0128 15.6696 16.1716 15.8284C16.9217 16.5786 17.9391 17 19 17C20.0609 17 21.0783 16.5786 21.8284 15.8284C22.5786 15.0783 23 14.0609 23 13V12C23 9.52205 22.1633 7.11667 20.6255 5.17359C19.0878 3.23052 16.939 1.86359 14.5273 1.29427ZM15 11.9958V12.0042C14.9977 13.6591 13.6555 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6555 9 14.9977 10.3409 15 11.9958Z",fill:"currentColor"})}));no.displayName="AtSignIcon";const oo=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.67909 4.05505C9.27254 3.18292 11.0926 2.81337 12.9 2.995C13.4495 3.05022 13.9398 2.64952 13.995 2.1C14.0502 1.55048 13.6495 1.06024 13.1 1.00502C10.8909 0.783033 8.66641 1.2347 6.71886 2.30064C4.7713 3.36659 3.19189 4.99691 2.18824 6.97729C1.1846 8.95767 0.803706 11.1954 1.09564 13.3963C1.38758 15.5972 2.33867 17.6583 3.8239 19.3085C5.30912 20.9588 7.25894 22.121 9.41704 22.6423C11.5751 23.1637 13.8405 23.0198 15.9153 22.2296C17.9901 21.4394 19.7772 20.0398 21.0417 18.2149C22.3062 16.39 22.9889 14.2252 23 12.005L23 12V11C23 10.4477 22.5523 10 22 10C21.4477 10 21 10.4477 21 11V11.9976C20.9904 13.8132 20.4319 15.5834 19.3978 17.0758C18.3632 18.5689 16.901 19.714 15.2034 20.3605C13.5059 21.0071 11.6524 21.1248 9.8867 20.6982C8.12098 20.2717 6.52567 19.3208 5.31048 17.9706C4.0953 16.6204 3.31713 14.9341 3.07828 13.1333C2.83942 11.3326 3.15106 9.50171 3.97222 7.8814C4.79339 6.26109 6.08564 4.92719 7.67909 4.05505ZM7.4 13.2C7.84043 12.8697 8.46468 12.9576 8.79686 13.3958L8.8015 13.4018C8.80745 13.4093 8.81876 13.4234 8.83531 13.4431C8.86846 13.4826 8.92219 13.5442 8.99542 13.6206C9.14272 13.7743 9.36407 13.9828 9.65067 14.1913C10.2277 14.6109 11.0255 15 12 15C12.9745 15 13.7723 14.6109 14.3493 14.1913C14.6359 13.9828 14.8573 13.7743 15.0046 13.6206C15.0778 13.5442 15.1315 13.4826 15.1647 13.4431C15.1812 13.4234 15.1925 13.4093 15.1985 13.4018L15.2031 13.3958C15.5353 12.9576 16.1596 12.8697 16.6 13.2C17.0418 13.5314 17.1314 14.1582 16.8 14.6L16 14C16.8 14.6 16.7998 14.6003 16.7995 14.6006L16.799 14.6013L16.7978 14.6029L16.7951 14.6065L16.7879 14.6159L16.7666 14.6432C16.7493 14.6649 16.726 14.6938 16.6966 14.7288C16.638 14.7987 16.555 14.8933 16.4485 15.0044C16.2365 15.2257 15.9266 15.5172 15.5257 15.8087C14.7277 16.3891 13.5255 17 12 17C10.4745 17 9.27227 16.3891 8.47433 15.8087C8.07343 15.5172 7.76352 15.2257 7.55145 15.0044C7.445 14.8933 7.362 14.7987 7.30336 14.7288C7.274 14.6938 7.25065 14.6649 7.23341 14.6432L7.21211 14.6159L7.2049 14.6065L7.20216 14.6029L7.20101 14.6013L7.20048 14.6006C7.20024 14.6003 7.2 14.6 8 14L7.2 14.6C6.86863 14.1582 6.95817 13.5314 7.4 13.2ZM8 9C8 8.44772 8.44772 8 9 8H9.01C9.56229 8 10.01 8.44772 10.01 9C10.01 9.55229 9.56229 10 9.01 10H9C8.44772 10 8 9.55229 8 9ZM15 8C14.4477 8 14 8.44772 14 9C14 9.55229 14.4477 10 15 10H15.01C15.5623 10 16.01 9.55229 16.01 9C16.01 8.44772 15.5623 8 15.01 8H15ZM15 5C15 4.44772 15.4477 4 16 4H18V2C18 1.44772 18.4477 1 19 1C19.5523 1 20 1.44772 20 2V4H22C22.5523 4 23 4.44772 23 5C23 5.55228 22.5523 6 22 6H20V8C20 8.55228 19.5523 9 19 9C18.4477 9 18 8.55228 18 8V6H16C15.4477 6 15 5.55228 15 5Z",fill:"currentColor"})}));oo.displayName="SmilePlusIcon";const Ol=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM4 5C4 4.44772 4.44772 4 5 4H11V8H4V5ZM4 10H11V14H4V10ZM20 14V10H13V14H20ZM13 16H20V19C20 19.5523 19.5523 20 19 20H13V16ZM11 16V20H5C4.44772 20 4 19.5523 4 19V16H11ZM13 8H20V5C20 4.44772 19.5523 4 19 4H13V8Z",fill:"currentColor"})}));Ol.displayName="TableIcon";const ro=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 12C11 11.4477 11.4477 11 12 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H12C11.4477 13 11 12.5523 11 12Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 16.5C3.22386 16.5 3 16.7239 3 17V19C3 19.2761 3.22386 19.5 3.5 19.5H5.5C5.77614 19.5 6 19.2761 6 19V17C6 16.7239 5.77614 16.5 5.5 16.5H3.5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.5 10.5C6.22386 10.5 6 10.7239 6 11V13C6 13.2761 6.22386 13.5 6.5 13.5H8.5C8.77614 13.5 9 13.2761 9 13V11C9 10.7239 8.77614 10.5 8.5 10.5H6.5Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 4.5C3.22386 4.5 3 4.72386 3 5V7C3 7.27614 3.22386 7.5 3.5 7.5H5.5C5.77614 7.5 6 7.27614 6 7V5C6 4.72386 5.77614 4.5 5.5 4.5H3.5Z",fill:"currentColor"})]}));ro.displayName="ListIndentedIcon";function R2({shortcutKeys:e=lo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const ed=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:l=":",hideWhenUnavailable:s=!1,onTriggerApplied:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,canAddTrigger:b,handleAddTrigger:g,label:w,shortcutKeys:v,Icon:m}=rd({editor:p,node:t,nodePos:n,trigger:l,hideWhenUnavailable:s,onTriggerApplied:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":w,tooltip:"Add emoji",onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o}),i&&r.jsx(R2,{shortcutKeys:v})]})}):null});ed.displayName="EmojiTriggerButton";const lo="mod+shift+e";function so(e){return!(!e||!e.isEditable||re(e,["image"]))}function td(e,t,n,o){if(n!=null||K(o)){const s=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const a=s.node.type.name==="paragraph"&&s.node.content.size===0,i=s.pos+s.node.nodeSize;return e.chain().insertContentAt(a?s.pos:i,{type:"paragraph",content:[{type:"text",text:t}]}).focus(a?s.pos+t.length+1:i+t.length+1).run()}const{$from:l}=e.state.selection;return e.chain().insertContentAt(l.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function nd(e,t,n,o){if(n!=null||K(o)){const i=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!i)return!1;const c=i.node.type.name==="paragraph"&&i.node.content.size===0,d=i.pos+i.node.nodeSize;return e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,c?i.pos:d,c?i.pos:d)),e.commands.focus(c?i.pos+2:d+t.length+1),!0}const{$from:l}=e.state.selection,s=l.node(),a=l.parentOffset>0&&s.textContent[l.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:a?` ${t}`:t}).focus().run()}function Pl(e,t=":",n,o){if(!e||!e.isEditable||!so(e))return!1;try{const{$from:l}=e.state.selection,s=l.node();return s.isBlock&&!s.isTextblock?td(e,t,n,o):nd(e,t,n,o)}catch{return!1}}function od(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:so(t):!1:!0:!1}function rd(e){const{editor:t,node:n,nodePos:o,trigger:l=":",hideWhenUnavailable:s=!1,onTriggerApplied:a}=e||{},{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=so(i);u.useEffect(()=>{if(!i)return;const C=()=>{f(od({editor:i,hideWhenUnavailable:s}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,s]);const p=u.useCallback(()=>{if(!i)return!1;const C=Pl(i,l,n,o);return C&&a?.(l),C},[i,l,n,o,a]);return ie.useHotkeys(lo,C=>{C.preventDefault(),p()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleAddTrigger:p,canAddTrigger:h,label:"Add emoji",shortcutKeys:lo,trigger:l,Icon:oo}}function ld({shortcutKeys:e=ao}){return r.jsx(X,{children:G({shortcutKeys:e})})}const sd=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:l="@",hideWhenUnavailable:s=!1,onTriggered:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,canInsert:b,handleMention:g,label:w,shortcutKeys:v,Icon:m}=dd({editor:p,node:t,nodePos:n,trigger:l,hideWhenUnavailable:s,onTriggered:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":w,tooltip:w,onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o}),i&&r.jsx(ld,{shortcutKeys:v})]})}):null});sd.displayName="MentionTriggerButton";const ao="mod+shift+2";function io(e,t,n){if(!e||!e.isEditable||re(e,["image"]))return!1;if(t||K(n)){if(K(n)&&n>=0)return!0;if(t)return Ce({editor:e,node:t})!==null}return!0}function ad(e,t,n,o){if(n!=null||K(o)){const s=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const a=s.node.type.name==="paragraph"&&s.node.content.size===0,i=a?s.pos:s.pos+s.node.nodeSize,c=t.length+1,d=a?s.pos+c:s.pos+s.node.nodeSize+c;return e.chain().insertContentAt(a?s.pos:i,{type:"paragraph",content:[{type:"text",text:t}]}).focus(d).run()}const{$from:l}=e.state.selection;return e.chain().insertContentAt(l.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function id(e,t,n,o){if(n!=null||K(o)){const i=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!i)return!1;const c=i.node.type.name==="paragraph"&&i.node.content.size===0,d=c?i.pos:i.pos+i.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,d,d));const f=t.length+1,h=c?i.pos+f:i.pos+i.node.nodeSize+f;return e.commands.focus(h),!0}const{$from:l}=e.state.selection,s=l.node(),a=l.parentOffset>0&&s.textContent[l.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:a?` ${t}`:t}).focus().run()}function Zl(e,t="@",n,o){if(!e||!e.isEditable||!io(e,n,o))return!1;try{const{$from:l}=e.state.selection,s=l.node();return s.isBlock&&!s.isTextblock?ad(e,t,n,o):id(e,t,n,o)}catch{return!1}}function cd(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:l}=e;return t?n?t.isEditable?t.isActive("code")?!0:io(t,o,l):!1:!0:!1}function dd(e){const{editor:t,node:n,nodePos:o,trigger:l="@",hideWhenUnavailable:s=!1,onTriggered:a}=e||{},{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=io(i,n,o);u.useEffect(()=>{if(!i)return;const C=()=>{f(cd({editor:i,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,s,n,o]);const p=u.useCallback(()=>{if(!i)return!1;const C=Zl(i,l,n,o);return C&&a?.(l),C},[i,l,n,o,a]);return ie.useHotkeys(ao,C=>{C.preventDefault(),p()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleMention:p,canInsert:h,label:"Add mention",shortcutKeys:ao,trigger:l,Icon:no}}const Fl={text:{title:"Text",subtext:"Regular text paragraph",keywords:["p","paragraph","text"],badge:to,group:"Style"},heading_1:{title:"Heading 1",subtext:"Top-level heading",keywords:["h","heading1","h1"],badge:Yn,group:"Style"},heading_2:{title:"Heading 2",subtext:"Key section heading",keywords:["h2","heading2","subheading"],badge:Xn,group:"Style"},heading_3:{title:"Heading 3",subtext:"Subsection and group heading",keywords:["h3","heading3","subheading"],badge:jn,group:"Style"},bullet_list:{title:"Bullet List",subtext:"List with unordered items",keywords:["ul","li","list","bulletlist","bullet list"],badge:Qn,group:"Style"},ordered_list:{title:"Numbered List",subtext:"List with ordered items",keywords:["ol","li","list","numberedlist","numbered list"],badge:Jn,group:"Style"},task_list:{title:"To-do list",subtext:"List with tasks",keywords:["tasklist","task list","todo","checklist"],badge:eo,group:"Style"},quote:{title:"Blockquote",subtext:"Blockquote block",keywords:["quote","blockquote"],badge:Rn,group:"Style"},code_block:{title:"Code Block",subtext:"Code block with syntax highlighting",keywords:["code","pre"],badge:Gn,group:"Style"},mention:{title:"Mention",subtext:"Mention a user or item",keywords:["mention","user","item","tag"],badge:no,group:"Insert"},emoji:{title:"Emoji",subtext:"Insert an emoji",keywords:["emoji","emoticon","smiley"],badge:oo,group:"Insert"},table:{title:"Table",subtext:"Insert a table",keywords:["table","insertTable"],badge:Ol,group:"Insert"},divider:{title:"Separator",subtext:"Horizontal line to separate content",keywords:["hr","horizontalRule","line","separator"],badge:Ul,group:"Insert"},toc:{title:"Table of contents",subtext:"Insert a table of contents",keywords:["toc","tableofcontents","table of contents"],badge:ro,group:"Insert"},image:{title:"Image",subtext:"Resizable image with caption",keywords:["image","imageUpload","upload","img","picture","media","url"],badge:Dl,group:"Upload"}},ud=()=>({text:{check:e=>Q("paragraph",e),action:({editor:e})=>{e.chain().focus().setParagraph().run()}},heading_1:{check:e=>Q("heading",e),action:({editor:e})=>{e.chain().focus().toggleHeading({level:1}).run()}},heading_2:{check:e=>Q("heading",e),action:({editor:e})=>{e.chain().focus().toggleHeading({level:2}).run()}},heading_3:{check:e=>Q("heading",e),action:({editor:e})=>{e.chain().focus().toggleHeading({level:3}).run()}},bullet_list:{check:e=>Q("bulletList",e),action:({editor:e})=>{e.chain().focus().toggleBulletList().run()}},ordered_list:{check:e=>Q("orderedList",e),action:({editor:e})=>{e.chain().focus().toggleOrderedList().run()}},task_list:{check:e=>Q("taskList",e),action:({editor:e})=>{e.chain().focus().toggleTaskList().run()}},quote:{check:e=>Q("blockquote",e),action:({editor:e})=>{e.chain().focus().toggleBlockquote().run()}},code_block:{check:e=>Q("codeBlock",e),action:({editor:e})=>{e.chain().focus().toggleNode("codeBlock","paragraph").run()}},mention:{check:e=>V(e,["mention","mentionAdvanced"]),action:({editor:e})=>Zl(e)},emoji:{check:e=>V(e,["emoji","emojiPicker"]),action:({editor:e})=>Pl(e)},divider:{check:e=>Q("horizontalRule",e),action:({editor:e})=>{e.chain().focus().setHorizontalRule().run()}},toc:{check:e=>Q("tocNode",e),action:({editor:e})=>{e.chain().focus().insertTocNode().run()}},table:{check:e=>Q("table",e),action:({editor:e})=>{e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},image:{check:e=>Q("image",e),action:({editor:e})=>{e.chain().focus().insertContent({type:"imageUpload"}).run()}}});function fd(e,t){if(!t)return e.map(l=>({...l,group:""}));const n={};e.forEach(l=>{const s=l.group||"";n[s]||(n[s]=[]),n[s].push(l)});const o=[];return Object.entries(n).forEach(([,l])=>{o.push(...l)}),o}function hd(e){return{getSlashMenuItems:u.useCallback(n=>{const o=[],l=e?.enabledItems||Object.keys(Fl),s=e?.showGroups!==!1,a=ud();return l.forEach(i=>{const c=a[i],d=Fl[i];if(c&&d&&c.check(n)){const f={onSelect:({editor:h})=>c.action({editor:h}),...d};e?.itemGroups?.[i]?f.group=e.itemGroups[i]:s||(f.group=""),o.push(f)}}),e?.customItems&&o.push(...e.customItems),fd(o,s)},[e]),config:e}}const pd=e=>{const{config:t,...n}=e,{getSlashMenuItems:o}=hd(t);return r.jsx(qn,{char:"/",pluginKey:"slashDropdownMenu",decorationClass:"tiptap-slash-decoration",decorationContent:"Filter...",selector:"tiptap-slash-dropdown-menu",items:({query:l,editor:s})=>P2(o(s),l),...n,children:l=>r.jsx(Cd,{...l,config:t})})},$l=e=>{const{item:t,isSelected:n,onSelect:o}=e,l=u.useRef(null);u.useEffect(()=>{const a=document.querySelector('[data-selector="tiptap-slash-dropdown-menu"]');if(!l.current||!n||!a)return;const i=Kn(l.current,a);i==="top"?l.current.scrollIntoView(!0):i==="bottom"&&l.current.scrollIntoView(!1)},[n]);const s=t.badge;return r.jsxs(k,{ref:l,variant:"ghost","data-active-state":n?"on":"off",onClick:o,children:[s&&r.jsx(s,{className:"tiptap-button-icon"}),r.jsx("div",{className:"tiptap-button-text",children:t.title})]})},Cd=({items:e,selectedIndex:t,onSelect:n,config:o})=>{const l=u.useMemo(()=>{const s=[];if(!(o?.showGroups!==!1))return e.forEach((c,d)=>{s.push(r.jsx($l,{item:c,isSelected:d===t,onSelect:()=>n(c)},`item-${d}-${c.title}`))}),s;const i={};return e.forEach((c,d)=>{const f=c.group||"";i[f]||(i[f]={items:[],indices:[]}),i[f].items.push(c),i[f].indices.push(d)}),Object.entries(i).forEach(([c,d],f)=>{f>0&&s.push(r.jsx(R,{orientation:"horizontal"},`separator-${f}`));const h=d.items.map((p,C)=>{const b=d.indices[C];return r.jsx($l,{item:p,isSelected:b===t,onSelect:()=>n(p)},`item-${b}-${p.title}`)});c?s.push(r.jsxs(Ie,{children:[r.jsx(ct,{children:c}),h]},`group-${f}-${c}`)):s.push(...h)}),s},[e,t,n,o?.showGroups]);return l.length?r.jsx(Ue,{className:"tiptap-slash-card",style:{maxHeight:"var(--suggestion-menu-max-height)"},children:r.jsx(Oe,{className:"tiptap-slash-card-body",children:l})}):null};function gd({shortcutKeys:e=co}){return r.jsx(X,{children:G({shortcutKeys:e})})}const zl=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:l,downloadMethod:s,showShortcut:a=!1,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,canDownload:C,handleDownload:b,label:g,shortcutKeys:w,Icon:v}=Yl({editor:h,hideWhenUnavailable:n,onDownloaded:o,resolveFileUrl:l,downloadMethod:s}),m=u.useCallback(async x=>{i?.(x),!x.defaultPrevented&&await b()},[b,i]);return p?r.jsx(k,{type:"button",variant:"ghost","data-active-state":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":g,tooltip:g,onClick:m,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),a&&r.jsx(gd,{shortcutKeys:w})]})}):null});zl.displayName="ImageDownloadButton";const Wl=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V14.5858L17.2929 10.2929C17.6834 9.90237 18.3166 9.90237 18.7071 10.2929C19.0976 10.6834 19.0976 11.3166 18.7071 11.7071L12.7071 17.7071C12.3166 18.0976 11.6834 18.0976 11.2929 17.7071L5.29289 11.7071C4.90237 11.3166 4.90237 10.6834 5.29289 10.2929C5.68342 9.90237 6.31658 9.90237 6.70711 10.2929L11 14.5858V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"}),r.jsx("path",{d:"M5 20C4.44772 20 4 20.4477 4 21C4 21.5523 4.44772 22 5 22H19C19.5523 22 20 21.5523 20 21C20 20.4477 19.5523 20 19 20H5Z",fill:"currentColor"})]}));Wl.displayName="ArrowDownToLineIcon";const co="mod+shift+d";function _l(e,t){const n=e.match(/\.([a-zA-Z0-9]+)(?:\?|#|$)/);return n&&n[1]?`.${n[1].toLowerCase()}`:t&&{"image/jpeg":".jpg","image/jpg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp"}[t.toLowerCase()]||".jpg"}function Nt(e){return!e||!e.isEditable||!V(e,["image"])?!1:re(e,["image"])}function ql(e){if(!e||!Nt(e))return null;const{selection:t}=e.state;if(t instanceof M.NodeSelection){const n=t.node;if(n.type.name==="image")return{src:n.attrs.src,alt:n.attrs.alt,title:n.attrs.title}}return null}async function Kl(e,t){try{const n=await fetch(e);if(!n.ok)return!1;const o=await n.blob(),l=URL.createObjectURL(o),a=/\.[a-zA-Z0-9]+$/.test(t)?t:t+_l(e,n.headers.get("content-type")||void 0),i=document.createElement("a");return i.href=l,i.download=a,i.style.display="none",document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(l),0),!0}catch(n){return console.warn("Fetch download failed:",n),!1}}function Gl(e,t){try{const o=/\.[a-zA-Z0-9]+$/.test(t)?t:t+_l(e),l=document.createElement("a");return l.href=e,l.download=o,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),!0}catch(n){return console.warn("Direct download failed:",n),!1}}function Vt(e){try{return window.open(e,"_blank"),!0}catch(t){return console.error("Failed to open image:",t),!1}}async function bd(e,t,n,o="auto"){if(!e||!Nt(e))return!1;const l=ql(e);if(!l?.src)return!1;try{let s=l.src;n&&(s=await n(l.src));const a=window.location.href,i=Jt(s,a);if(i==="#")return console.error("Invalid or unsafe URL after sanitization"),!1;const c=t||l.alt||l.title||`image-${Date.now()}`;switch(o){case"open":return Vt(i);case"download":return i.startsWith(window.location.origin)||i.startsWith("data:")?Gl(i,c):await Kl(i,c)||Vt(i);default:return i.startsWith("data:")||i.startsWith(window.location.origin)?Gl(i,c):await Kl(i,c)?!0:Vt(i)}}catch(s){console.error("Failed to download image:",s);try{const a=window.location.href,i=Jt(l.src,a);if(i!=="#")return Vt(i)}catch{}return!1}}function wd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!V(t,["image","imageUpload"])?!1:Nt(t):!0:!1}function Yl(e){const{editor:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:l,downloadMethod:s="auto"}=e||{},{editor:a}=S(t),i=ee(),[c,d]=u.useState(!0),f=Nt(a);u.useEffect(()=>{if(!a)return;const p=()=>{d(wd({editor:a,hideWhenUnavailable:n}))};return p(),a.on("selectionUpdate",p),()=>{a.off("selectionUpdate",p)}},[a,n]);const h=u.useCallback(async()=>{if(!a)return!1;const p=ql(a),C=p?.alt||p?.title,b=await bd(a,C,l,s);return b&&o?.(C),b},[a,o,l,s]);return ie.useHotkeys(co,p=>{p.preventDefault(),h()},{enabled:c&&f,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:c,canDownload:f,handleDownload:h,label:"Download image",shortcutKeys:co,Icon:Wl}}function Xl({shortcutKeys:e=uo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const jl=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDuplicated:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,handleDuplicate:h,label:p,shortcutKeys:C,Icon:b}=Jl({editor:d,hideWhenUnavailable:n,onDuplicated:o}),g=u.useCallback(w=>{s?.(w),!w.defaultPrevented&&h()},[h,s]);return f?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":p,tooltip:"Duplicate",onClick:g,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(Xl,{shortcutKeys:C})]})}):null});jl.displayName="DuplicateButton";const uo="mod+d";function Ql(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof M.NodeSelection)return!!n.node;const o=n.$anchor;for(let l=1;l<=o.depth;l++){const s=o.node(l);if(!(s.type.name==="doc"||!s.type.spec.group))return!0}return!1}catch{return!1}}function vd(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t,o=e.chain().focus();if(n instanceof M.NodeSelection){const s=n.node,a=n.to;return o.insertContentAt(a,s.toJSON()).run(),!0}const l=n.$anchor;for(let s=1;s<=l.depth;s++){const a=l.node(s);if(a.type.name==="doc"||!a.type.spec.group)continue;const i=l.start(s),c=Math.min(i+a.nodeSize,t.doc.content.size);return o.insertContentAt(c,a.toJSON()).run(),!0}return!1}catch{return!1}}function md(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Ql(t):!1:!0:!1}function Jl(e){const{editor:t,hideWhenUnavailable:n=!1,onDuplicated:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=Ql(l);u.useEffect(()=>{if(!l)return;const f=()=>{i(md({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=vd(l);return f&&o?.(),f},[l,o]);return ie.useHotkeys(uo,f=>{f.preventDefault(),d()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,handleDuplicate:d,canDuplicate:c,label:"Duplicate node",shortcutKeys:uo,Icon:hn}}function Rl({shortcutKeys:e=fo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const es=u.forwardRef(({editor:e,text:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleCopyToClipboard:p,label:C,shortcutKeys:b,Icon:g}=os({editor:f,copyWithFormatting:n,hideWhenUnavailable:o,onCopied:l}),w=u.useCallback(async v=>{a?.(v),!v.defaultPrevented&&await p()},[p,a]);return h?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":C,tooltip:"Copy to clipboard",onClick:w,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),s&&r.jsx(Rl,{shortcutKeys:b})]})}):null});es.displayName="CopyToClipboardButton";const ts=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M15 1C16.1046 1 17 1.89543 17 3H18C18.7956 3 19.5585 3.3163 20.1211 3.87891C20.6837 4.44151 21 5.20435 21 6V20C21 20.7957 20.6837 21.5585 20.1211 22.1211C19.5585 22.6837 18.7957 23 18 23H6C5.20435 23 4.44151 22.6837 3.87891 22.1211C3.3163 21.5585 3 20.7957 3 20V6C3 5.20435 3.3163 4.44152 3.87891 3.87891C4.44152 3.3163 5.20435 3 6 3H7C7 1.89543 7.89543 1 9 1H15ZM6 5C5.73478 5 5.4805 5.10543 5.29297 5.29297C5.10543 5.4805 5 5.73478 5 6V20L5.00488 20.0986C5.02757 20.3276 5.12883 20.5429 5.29297 20.707C5.48051 20.8946 5.73478 21 6 21H18C18.2652 21 18.5195 20.8946 18.707 20.707C18.8946 20.5195 19 20.2652 19 20V6C19 5.73478 18.8946 5.48051 18.707 5.29297C18.5429 5.12883 18.3276 5.02757 18.0986 5.00488L18 5H17C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5H6ZM9 5H15V3H9V5Z",fill:"currentColor"})}));ts.displayName="ClipboardIcon";const fo="mod+c";async function yd(e,t){try{if(t&&navigator.clipboard&&"write"in navigator.clipboard){const n=new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})});await navigator.clipboard.write([n])}else await navigator.clipboard.writeText(e)}catch{await navigator.clipboard.writeText(e)}}function xd(e){const{selection:t}=e,{empty:n}=t;return!n}function ns(e){if(!e||!e.isEditable)return!1;const t=e.state.tr;return xd(t)}function Sd(e,t=!0){const{selection:n}=e.state,{$anchor:o}=n;let l=n.content();if(n.empty||n instanceof M.TextSelection){const i=o.node(1);l=new Yo.Slice(Yo.Fragment.from(i),0,0)}const s=l.content.textBetween(0,l.content.size,`
5
+ `),a=t?e.view.serializeForClipboard(l).dom.innerHTML:void 0;return{textContent:s,htmlContent:a}}async function Td(e,t=!0){if(!e||!e.isEditable)return!1;try{const{textContent:n,htmlContent:o}=Sd(e,t);return await yd(n,o),!0}catch{return!1}}function Id(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:ns(t):!1:!0:!1}function os(e){const{editor:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:l}=e||{},{editor:s}=S(t),a=ee(),[i,c]=u.useState(!0),d=ns(s);u.useEffect(()=>{if(!s)return;const h=()=>{c(Id({editor:s,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o]);const f=u.useCallback(async()=>{if(!s)return!1;const h=await Td(s,n);return h&&l?.(),h},[s,n,l]);return ie.useHotkeys(fo,h=>{h.preventDefault(),f()},{enabled:i&&d,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:i,handleCopyToClipboard:f,canCopyToClipboard:d,label:"Copy to clipboard",shortcutKeys:fo,Icon:ts}}function rs({shortcutKeys:e=po}){return r.jsx(X,{children:G({shortcutKeys:e})})}const ho=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDeleted:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,handleDeleteNode:h,label:p,shortcutKeys:C,Icon:b}=as({editor:d,hideWhenUnavailable:n,onDeleted:o}),g=u.useCallback(w=>{s?.(w),!w.defaultPrevented&&h()},[h,s]);return f?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":p,tooltip:"Delete",onClick:g,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(rs,{shortcutKeys:C})]})}):null});ho.displayName="DeleteNodeButton";const po="backspace";function ls(e){if(!e||!e.isEditable)return!1;const{state:t}=e,{selection:n}=t;if(n instanceof M.NodeSelection)return!0;const o=n.$anchor;for(let l=o.depth;l>0;l--){const s=o.node(l),a=o.before(l);if(t.tr.delete(a,a+s.nodeSize).doc!==t.doc)return!0}return!1}function ss(e,t,n){const o=e.chain().focus();return o.deleteRange({from:t,to:t+n}).run()?!0:o.setNodeSelection(t).deleteSelection().run()}function Md(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof M.NodeSelection){const l=n.from,s=n.node;return s?ss(e,l,s.nodeSize):!1}const o=n.$from;for(let l=o.depth;l>0;l--){const s=n.$from.node(l),a=n.$from.before(l);if(s&&s.isBlock&&s.type.name!=="tableRow"&&s.type.name!=="tableHeader"&&s.type.name!=="tableCell")return ss(e,a,s.nodeSize)}return!1}catch{return!1}}function kd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:ls(t):!1:!0:!1}function as(e){const{editor:t,hideWhenUnavailable:n=!1,onDeleted:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=ls(l);u.useEffect(()=>{if(!l)return;const f=()=>{i(kd({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=Md(l);return f&&o?.(),f},[l,o]);return ie.useHotkeys(po,f=>{f.preventDefault(),d()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,handleDeleteNode:d,canDeleteNode:c,label:"Delete",shortcutKeys:po,Icon:mt}}function is({shortcutKeys:e=Co}){return r.jsx(X,{children:G({shortcutKeys:e})})}const cs=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:l,onCopied:s,showShortcut:a=!1,onClick:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleCopyAnchorLink:C,label:b,shortcutKeys:g,Icon:w}=hs({editor:h,hideWhenUnavailable:n,onNodeIdNotFound:o,onExtractedNodeId:l,onCopied:s}),v=u.useCallback(m=>{i?.(m),!m.defaultPrevented&&C()},[C,i]);return p?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":b,tooltip:"Copy anchor link",onClick:v,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),a&&r.jsx(is,{shortcutKeys:g})]})}):null});cs.displayName="CopyAnchorLinkButton";const ut=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),r.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));ut.displayName="LinkIcon";const Co="mod+ctrl+l";function ds(e){return!!(e&&e.isEditable)}function Ed(e){return Qo(e,"uniqueID")?.options?.attributeName||"data-id"}function us(e){if(!ds(e))return null;const t=tt(e);if(!t)return null;const n=Ed(e),o=Ld(t.node,n);return{node:t.node,nodeId:o,hasNodeId:o!==null}}function Ld(e,t){if(!e?.attrs?.[t])return null;try{return e.attrs[t]}catch{return null}}function fs(e){return us(e)?.hasNodeId??!1}async function Ad(e,t,n){const o=us(e);if(!o)return!1;const{nodeId:l,hasNodeId:s}=o;if(t?.(l),n?.(!s),!s||!l)return!1;try{const a=new URL(window.location.href);return a.searchParams.set("source","copy_link"),a.hash=l,await navigator.clipboard.writeText(a.toString()),!0}catch(a){return console.error("Failed to copy node ID to clipboard:",a),!1}}function Hd(e){const{editor:t,hideWhenUnavailable:n}=e;if(!ds(t))return!1;const o=!!tt(t);return n?fs(t):o}function hs(e){const{editor:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:l,onCopied:s}=e||{},{editor:a}=S(t),i=ee(),[c,d]=u.useState(!0),f=fs(a);u.useEffect(()=>{if(!a)return;const p=()=>{d(Hd({editor:a,hideWhenUnavailable:n}))};return p(),a.on("selectionUpdate",p),()=>{a.off("selectionUpdate",p)}},[a,n]);const h=u.useCallback(async()=>{const p=await Ad(a,l,o);return p&&s?.(),p},[a,l,o,s]);return ie.useHotkeys(Co,p=>{p.preventDefault(),h()},{enabled:c&&f,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:c,handleCopyAnchorLink:h,canCopyAnchorLink:f,label:"Copy anchor link",shortcutKeys:Co,Icon:ut}}function Nd({shortcutKeys:e=go}){return r.jsx(X,{children:G({shortcutKeys:e})})}const ps=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,preserveMarks:o=gs,onResetAllFormatting:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canReset:p,handleResetFormatting:C,label:b,shortcutKeys:g,Icon:w}=ws({editor:f,preserveMarks:o,hideWhenUnavailable:n,onResetAllFormatting:l}),v=u.useCallback(m=>{a?.(m),!m.defaultPrevented&&C()},[C,a]);return h?r.jsx(k,{type:"button",variant:"ghost",disabled:!p,"data-disabled":!p,"data-active-state":"off",role:"button",tabIndex:-1,"aria-label":b,tooltip:"Reset formatting",onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),s&&r.jsx(Nd,{shortcutKeys:g})]})}):null});ps.displayName="ResetAllFormattingButton";const Cs=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M12 2L11.9962 2.00001C9.22213 2.01045 6.55946 3.0929 4.56496 5.02104L4.55289 5.0329L4 5.58579V3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41422L5.96097 6.45325C7.58329 4.88786 9.7473 4.00897 12.0019 4.00001C13.5835 4.00038 15.1295 4.46955 16.4446 5.34825C17.7602 6.2273 18.7855 7.47673 19.391 8.93854C19.9965 10.4003 20.155 12.0089 19.8463 13.5607C19.5376 15.1126 18.7757 16.538 17.6569 17.6569C16.538 18.7757 15.1126 19.5376 13.5607 19.8463C12.0089 20.155 10.4003 19.9965 8.93853 19.391C7.47672 18.7855 6.22729 17.7602 5.34824 16.4446C4.46919 15.129 4 13.5823 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 13.9778 2.58649 15.9112 3.6853 17.5557C4.78412 19.2002 6.3459 20.4819 8.17317 21.2388C10.0004 21.9957 12.0111 22.1937 13.9509 21.8079C15.8907 21.422 17.6725 20.4696 19.0711 19.0711C20.4696 17.6726 21.422 15.8907 21.8079 13.9509C22.1937 12.0111 21.9957 10.0004 21.2388 8.17317C20.4819 6.34591 19.2002 4.78412 17.5557 3.68531C15.9112 2.5865 13.9778 2.00001 12 2Z",fill:"currentColor"})}));Cs.displayName="RotateCcwIcon";const go="mod+r",gs=["inlineThread"];function Vd(e,t=[]){const{selection:n}=e,{empty:o,ranges:l}=n;return o||l.forEach(s=>{const a=s.$from.pos,i=s.$to.pos;e.doc.nodesBetween(a,i,(c,d)=>(c.isInline&&c.marks.forEach(f=>{t.includes(f.type.name)||e.removeMark(d,d+c.nodeSize,f.type)}),!0))}),e}function Bd(e,t=[]){const{selection:n}=e,{empty:o,ranges:l}=n;if(o)return!1;for(const s of l){const a=s.$from.pos,i=s.$to.pos;let c=!1;if(e.doc.nodesBetween(a,i,d=>{if(!d.isInline)return!0;for(const f of d.marks)if(!t.includes(f.type.name))return c=!0,!1;return!0}),c)return!0}return!1}function bs(e,t){if(!e||!e.isEditable)return!1;const n=e.state.tr;return Bd(n,t)}function Dd(e,t){if(!e||!e.isEditable)return!1;try{const{view:n,state:o}=e,{tr:l}=o,s=Vd(l,t);return n.dispatch(s),e.commands.focus(),!0}catch{return!1}}function Ud(e){const{editor:t,hideWhenUnavailable:n,preserveMarks:o}=e;return!t||!t.isEditable?!1:n&&!t.isActive("code")?bs(t,o):!0}function ws(e){const{editor:t,preserveMarks:n=gs,hideWhenUnavailable:o=!1,onResetAllFormatting:l}=e||{},{editor:s}=S(t),a=ee(),[i,c]=u.useState(!0),d=bs(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(Ud({editor:s,hideWhenUnavailable:o,preserveMarks:n}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const f=u.useCallback(()=>{if(!s)return!1;const h=Dd(s,n);return h&&l?.(),h},[s,l,n]);return ie.useHotkeys(go,h=>{h.preventDefault(),f()},{enabled:i&&d,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:i,handleResetFormatting:f,canReset:d,label:"Reset formatting",shortcutKeys:go,Icon:Cs}}function Od({shortcutKeys:e=bo}){return r.jsx(X,{children:G({shortcutKeys:e})})}const vs=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,canToggle:h,isActive:p,handleToggle:C,label:b,shortcutKeys:g,Icon:w}=ms({editor:d,hideWhenUnavailable:n,onToggled:o}),v=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&C()},[C,s]);return f?r.jsx(k,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":p,tooltip:"Text",onClick:v,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(Od,{shortcutKeys:g})]})}):null});vs.displayName="TextButton";const bo="mod+alt+0";function wo(e,t=!0){return!e||!e.schema.nodes.paragraph?!1:t?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().setNode("paragraph")||e.can().clearNodes():!1:e.can().setNode("paragraph")}function Pd(e){return e?e.isActive("paragraph"):!1}function Zd(e){if(!e||!e.isEditable||!wo(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const l=et(e),s=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&l.length===1;if((n.selection.empty||n.selection instanceof M.TextSelection)&&s){const c=Ce({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!K(c))return!1;o=o.setSelection(M.NodeSelection.create(n.doc,c)),t.dispatch(o),n=t.state}const a=n.selection;let i=e.chain().focus();if(a instanceof M.NodeSelection){const c=a.node.firstChild?.firstChild,d=a.node.lastChild?.lastChild,f=c?a.from+c.nodeSize:a.from+1,h=d?a.to-d.nodeSize:a.to-1,p=n.doc.resolve(f),C=n.doc.resolve(h);i=i.setTextSelection(M.TextSelection.between(p,C)).clearNodes()}return e.isActive("paragraph")||i.setNode("paragraph").run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function Fd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Q("paragraph",t)?!1:t.isActive("code")?!0:wo(t):!0:!1}function ms(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=wo(l),d=Pd(l);u.useEffect(()=>{if(!l)return;const h=()=>{i(Fd({editor:l,hideWhenUnavailable:n}))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=Zd(l);return h&&o?.(),h},[l,o]);return ie.useHotkeys(bo,h=>{h.preventDefault(),f()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,isActive:d,handleToggle:f,canToggle:c,label:"Text",shortcutKeys:bo,Icon:to}}function $d({level:e,shortcutKeys:t=Is[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const ys=u.forwardRef(({editor:e,level:t,text:n,hideWhenUnavailable:o=!1,onToggled:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canToggle:p,isActive:C,handleToggle:b,label:g,Icon:w,shortcutKeys:v}=Dt({editor:f,level:t,hideWhenUnavailable:o,onToggled:l}),m=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&b()},[b,a]);return h?r.jsx(k,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":g,"aria-pressed":C,tooltip:g,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx($d,{level:t,shortcutKeys:v})]})}):null});ys.displayName="HeadingButton";const xs=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),r.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));xs.displayName="HeadingFourIcon";const Ss=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));Ss.displayName="HeadingFiveIcon";const Ts=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));Ts.displayName="HeadingSixIcon";const zd={1:Yn,2:Xn,3:jn,4:xs,5:Ss,6:Ts},Is={1:"ctrl+alt+1",2:"ctrl+alt+2",3:"ctrl+alt+3",4:"ctrl+alt+4",5:"ctrl+alt+5",6:"ctrl+alt+6"};function Bt(e,t,n=!0){return!e||!e.isEditable||!Q("heading",e)||re(e,["image"])?!1:n?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?t?e.can().setNode("heading",{level:t})||e.can().clearNodes():e.can().setNode("heading")||e.can().clearNodes():!1:t?e.can().setNode("heading",{level:t}):e.can().setNode("heading")}function Wd(e,t){return!e||!e.isEditable?!1:Array.isArray(t)?t.some(n=>e.isActive("heading",{level:n})):t?e.isActive("heading",{level:t}):e.isActive("heading")}function _d(e,t){if(!e||!e.isEditable)return!1;const n=Array.isArray(t)?t:[t],o=n.find(l=>Bt(e,l));if(!o)return!1;try{const l=e.view;let s=l.state,a=s.tr;const i=et(e),c=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&i.length===1;if((s.selection.empty||s.selection instanceof M.TextSelection)&&c){const C=Ce({editor:e,node:s.selection.$anchor.node(1)})?.pos;if(!K(C))return!1;a=a.setSelection(M.NodeSelection.create(s.doc,C)),l.dispatch(a),s=l.state}const d=s.selection;let f=e.chain().focus();if(d instanceof M.NodeSelection){const C=d.node.firstChild?.firstChild,b=d.node.lastChild?.lastChild,g=C?d.from+C.nodeSize:d.from+1,w=b?d.to-b.nodeSize:d.to-1,v=s.doc.resolve(g),m=s.doc.resolve(w);f=f.setTextSelection(M.TextSelection.between(v,m)).clearNodes()}return(n.some(C=>e.isActive("heading",{level:C}))?f.setNode("paragraph"):f.setNode("heading",{level:o})).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function qd(e){const{editor:t,level:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!Q("heading",t)?!1:t.isActive("code")?!0:Array.isArray(n)?n.some(l=>Bt(t,l)):Bt(t,n):!0:!1}function Dt(e){const{editor:t,level:n,hideWhenUnavailable:o=!1,onToggled:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Bt(s,n),d=Wd(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(qd({editor:s,level:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=_d(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleToggle:f,canToggle:c,label:`Heading ${n}`,shortcutKeys:Is[n],Icon:zd[n]}}function Kd({type:e,shortcutKeys:t=Ms[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const Ut=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canToggle:p,isActive:C,handleToggle:b,label:g,shortcutKeys:w,Icon:v}=Ot({editor:f,type:t,hideWhenUnavailable:o,onToggled:l}),m=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&b()},[b,a]);return h?r.jsx(k,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":g,"aria-pressed":C,tooltip:g,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(v,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Kd,{type:t,shortcutKeys:w})]})}):null});Ut.displayName="ListButton";const Gd={bulletList:Qn,orderedList:Jn,taskList:eo},Yd={bulletList:"Bullet List",orderedList:"Ordered List",taskList:"Task List"},Ms={bulletList:"mod+shift+8",orderedList:"mod+shift+7",taskList:"mod+shift+9"};function vo(e,t,n=!0){if(!e||!e.isEditable||!Q(t,e)||re(e,["image"]))return!1;if(!n)switch(t){case"bulletList":return e.can().toggleBulletList();case"orderedList":return e.can().toggleOrderedList();case"taskList":return e.can().toggleList("taskList","taskItem");default:return!1}if(!we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"]))return!1;switch(t){case"bulletList":return e.can().toggleBulletList()||e.can().clearNodes();case"orderedList":return e.can().toggleOrderedList()||e.can().clearNodes();case"taskList":return e.can().toggleList("taskList","taskItem")||e.can().clearNodes();default:return!1}}function Xd(e,t){if(!e||!e.isEditable)return!1;switch(t){case"bulletList":return e.isActive("bulletList");case"orderedList":return e.isActive("orderedList");case"taskList":return e.isActive("taskList");default:return!1}}function jd(e,t){if(!e||!e.isEditable||!vo(e,t))return!1;try{const n=e.view;let o=n.state,l=o.tr;const s=et(e),a=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&s.length===1;if((o.selection.empty||o.selection instanceof M.TextSelection)&&a){const d=Ce({editor:e,node:o.selection.$anchor.node(1)})?.pos;if(!K(d))return!1;l=l.setSelection(M.NodeSelection.create(o.doc,d)),n.dispatch(l),o=n.state}const i=o.selection;let c=e.chain().focus();if(i instanceof M.NodeSelection){const d=i.node.firstChild?.firstChild,f=i.node.lastChild?.lastChild,h=d?i.from+d.nodeSize:i.from+1,p=f?i.to-f.nodeSize:i.to-1,C=o.doc.resolve(h),b=o.doc.resolve(p);c=c.setTextSelection(M.TextSelection.between(C,b)).clearNodes()}if(e.isActive(t))c.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();else{const f={bulletList:()=>c.toggleBulletList(),orderedList:()=>c.toggleOrderedList(),taskList:()=>c.toggleList("taskList","taskItem")}[t];if(!f)return!1;f().run()}return e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function Qd(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!Q(n,t)?!1:t.isActive("code")?!0:vo(t,n):!0:!1}function Ot(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=vo(s,n),d=Xd(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(Qd({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=jd(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleToggle:f,canToggle:c,label:Yd[n],shortcutKeys:Ms[n],Icon:Gd[n]}}function Jd({shortcutKeys:e=Es}){return r.jsx(X,{children:G({shortcutKeys:e})})}const ks=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,canToggle:h,isActive:p,handleToggle:C,label:b,shortcutKeys:g,Icon:w}=Ls({editor:d,hideWhenUnavailable:n,onToggled:o}),v=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&C()},[C,s]);return f?r.jsx(k,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":p,tooltip:"Blockquote",onClick:v,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(Jd,{shortcutKeys:g})]})}):null});ks.displayName="BlockquoteButton";const Es="mod+shift+b";function mo(e,t=!0){return!e||!e.isEditable||!Q("blockquote",e)||re(e,["image"])?!1:t?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleWrap("blockquote")||e.can().clearNodes():!1:e.can().toggleWrap("blockquote")}function Rd(e){if(!e||!e.isEditable||!mo(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const l=et(e),s=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&l.length===1;if((n.selection.empty||n.selection instanceof M.TextSelection)&&s){const d=Ce({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!K(d))return!1;o=o.setSelection(M.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const a=n.selection;let i=e.chain().focus();if(a instanceof M.NodeSelection){const d=a.node.firstChild?.firstChild,f=a.node.lastChild?.lastChild,h=d?a.from+d.nodeSize:a.from+1,p=f?a.to-f.nodeSize:a.to-1,C=n.doc.resolve(h),b=n.doc.resolve(p);i=i.setTextSelection(M.TextSelection.between(C,b)).clearNodes()}return(e.isActive("blockquote")?i.lift("blockquote"):i.wrapIn("blockquote")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function eu(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Q("blockquote",t)?!1:t.isActive("code")?!0:mo(t):!0:!1}function Ls(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),i=mo(l),c=l?.isActive("blockquote")||!1;u.useEffect(()=>{if(!l)return;const f=()=>{a(eu({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=Rd(l);return f&&o?.(),f},[l,o]);return{isVisible:s,isActive:c,handleToggle:d,canToggle:i,label:"Blockquote",shortcutKeys:Es,Icon:Rn}}function tu({shortcutKeys:e=Hs}){return r.jsx(X,{children:G({shortcutKeys:e})})}const As=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:l=!1,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),{isVisible:f,canToggle:h,isActive:p,handleToggle:C,label:b,shortcutKeys:g,Icon:w}=Ns({editor:d,hideWhenUnavailable:n,onToggled:o}),v=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&C()},[C,s]);return f?r.jsx(k,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",disabled:!h,"data-disabled":!h,tabIndex:-1,"aria-label":b,"aria-pressed":p,tooltip:"Code Block",onClick:v,...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(tu,{shortcutKeys:g})]})}):null});As.displayName="CodeBlockButton";const Hs="mod+alt+c";function yo(e,t=!0){return!e||!e.isEditable||!Q("codeBlock",e)||re(e,["image"])?!1:t?we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleNode("codeBlock","paragraph")||e.can().clearNodes():!1:e.can().toggleNode("codeBlock","paragraph")}function nu(e){if(!e||!e.isEditable||!yo(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const l=et(e),s=we(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&l.length===1;if((n.selection.empty||n.selection instanceof M.TextSelection)&&s){const d=Ce({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!K(d))return!1;o=o.setSelection(M.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const a=n.selection;let i=e.chain().focus();if(a instanceof M.NodeSelection){const d=a.node.firstChild?.firstChild,f=a.node.lastChild?.lastChild,h=d?a.from+d.nodeSize:a.from+1,p=f?a.to-f.nodeSize:a.to-1,C=n.doc.resolve(h),b=n.doc.resolve(p);i=i.setTextSelection(M.TextSelection.between(C,b)).clearNodes()}return(e.isActive("codeBlock")?i.setNode("paragraph"):i.toggleNode("codeBlock","paragraph")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function ou(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Q("codeBlock",t)?!1:t.isActive("code")?!0:yo(t):!0:!1}function Ns(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),i=yo(l),c=l?.isActive("codeBlock")||!1;u.useEffect(()=>{if(!l)return;const f=()=>{a(ou({editor:l,hideWhenUnavailable:n}))};return f(),l.on("selectionUpdate",f),()=>{l.off("selectionUpdate",f)}},[l,n]);const d=u.useCallback(()=>{if(!l)return!1;const f=nu(l);return f&&o?.(),f},[l,o]);return{isVisible:s,isActive:c,handleToggle:d,canToggle:i,label:"Code Block",shortcutKeys:Hs,Icon:Gn}}function ru({shortcutKeys:e=So}){return r.jsx(X,{children:G({shortcutKeys:e})})}const xo=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:l="/",hideWhenUnavailable:s=!1,onTriggered:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,canInsert:b,handleSlashCommand:g,label:w,shortcutKeys:v,Icon:m}=au({editor:p,node:t,nodePos:n,trigger:l,hideWhenUnavailable:s,onTriggered:a}),x=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":w,tooltip:w,onClick:x,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o}),i&&r.jsx(ru,{shortcutKeys:v})]})}):null});xo.displayName="SlashCommandTriggerButton";const Vs=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z",fill:"currentColor"})}));Vs.displayName="PlusIcon";const So="mod+/";function To(e,t,n){if(!e||!e.isEditable||re(e,["image"]))return!1;if(t||K(n)){if(K(n)&&n>=0)return!0;if(t)return Ce({editor:e,node:t})!==null}return!0}function lu(e,t="/",n,o){if(!e||!e.isEditable||!To(e,n,o))return!1;try{if(n!=null||K(o)){const d=Ce({editor:e,node:n||void 0,nodePos:o||void 0});if(!d)return!1;const f=d.node.type.name==="paragraph"&&d.node.content.size===0,h=f?d.pos:d.pos+d.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,h,h));const p=t.length+1,C=f?d.pos+p:d.pos+d.node.nodeSize+p;return e.commands.focus(C),!0}const{$from:l}=e.state.selection,a=l.node().textContent.length===0,i=l.parentOffset===0,c=l.depth===0;if(!a||!i){const d=c?e.state.doc.content.size:l.after();return e.chain().insertContentAt(d,{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}return e.chain().insertContent({type:"text",text:t}).focus().run()}catch{return!1}}function su(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:l}=e;return t?n?t.isEditable?t.isActive("code")?!0:To(t,o,l):!1:!0:!1}function au(e){const{editor:t,node:n,nodePos:o,trigger:l="/",hideWhenUnavailable:s=!1,onTriggered:a}=e||{},{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=To(i,n,o);u.useEffect(()=>{if(!i)return;const C=()=>{f(su({editor:i,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,s,n,o]);const p=u.useCallback(()=>{if(!i)return!1;const C=lu(i,l,n,o);return C&&a?.(l),C},[i,l,n,o,a]);return ie.useHotkeys(So,C=>{C.preventDefault(),p()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0},[d,h,p]),{isVisible:d,handleSlashCommand:p,canInsert:h,label:"Insert block",shortcutKeys:So,trigger:l,Icon:Vs}}const Bs=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M17.293 7.29303C17.6835 6.90251 18.3165 6.90251 18.707 7.29303L22.707 11.293C22.7548 11.3408 22.7976 11.3936 22.835 11.4503C22.8597 11.4877 22.8812 11.5267 22.9004 11.5665C22.9222 11.6117 22.9412 11.6584 22.9561 11.7071C22.9622 11.7274 22.9668 11.748 22.9717 11.7686C22.9893 11.843 23 11.9203 23 12.0001C23 12.0831 22.9878 12.1632 22.9688 12.2403C22.9646 12.2572 22.9611 12.2743 22.9561 12.2911C22.9421 12.337 22.9244 12.3811 22.9043 12.4239C22.8833 12.4686 22.859 12.5119 22.8311 12.5538C22.8185 12.5726 22.8048 12.5905 22.791 12.6085C22.7649 12.6423 22.738 12.6761 22.707 12.7071L18.707 16.7071C18.3165 17.0976 17.6835 17.0975 17.293 16.7071C16.9024 16.3166 16.9025 15.6836 17.293 15.293L19.5859 13.0001H4.41406L6.70703 15.293C7.09747 15.6836 7.09753 16.3166 6.70703 16.7071C6.31654 17.0976 5.6835 17.0975 5.29297 16.7071L1.29297 12.7071C1.26185 12.676 1.23417 12.6424 1.20801 12.6085C1.19423 12.5906 1.18053 12.5726 1.16797 12.5538C1.14006 12.5119 1.11566 12.4686 1.09473 12.4239C1.07465 12.3811 1.0569 12.3369 1.04297 12.2911C1.0379 12.2743 1.03445 12.2572 1.03027 12.2403C1.01124 12.1633 1.00001 12.083 1 12.0001C1 11.9204 1.00974 11.8429 1.02734 11.7686C1.03221 11.7481 1.03678 11.7274 1.04297 11.7071C1.05787 11.6583 1.07777 11.6117 1.09961 11.5665C1.11877 11.5267 1.1403 11.4877 1.16504 11.4503C1.20242 11.3936 1.24516 11.3408 1.29297 11.293L5.29297 7.29303C5.68349 6.90251 6.31651 6.90251 6.70703 7.29303C7.09747 7.68356 7.09753 8.3166 6.70703 8.70709L4.41406 11.0001H19.5859L17.293 8.70709C16.9024 8.31657 16.9025 7.68356 17.293 7.29303Z",fill:"currentColor"})}));Bs.displayName="MoveHorizontalIcon";const Ds=["table","tableHandleExtension"];function Pt(e){if(!e||!e.isEditable||!V(e,Ds))return!1;try{return e.isActive("table")||e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function iu(e){if(!Pt(e)||!e)return!1;try{const t=J(e);if(!t)return!1;const n=e.view.dom,o=getComputedStyle(n),l=parseFloat(o.paddingLeft)||0,s=parseFloat(o.paddingRight)||0,a=n.clientWidth-l-s,i=t.map.width;if(i===0)return!1;let c=0;const d=a-i-8;c=Math.floor(d/i);const f=Math.max(c,hr),h=e.state.tr;return t.node.descendants((p,C)=>{if(p.type.name==="tableCell"||p.type.name==="tableHeader"){const b=t.start+C,g=p.attrs.colspan||1,w=Array(g).fill(f);h.setNodeMarkup(b,void 0,{...p.attrs,colwidth:w})}}),h.docChanged&&e.view.dispatch(h),!0}catch(t){return console.error("Error setting table auto width:",t),!1}}function cu({editor:e}){if(!Pt(e)||!e)return!1;try{return iu(e)}catch(t){return console.error("Error adjusting table width:",t),!1}}function du({editor:e,hideWhenUnavailable:t}){return!e||!e.isEditable||!V(e,Ds)?!1:t?Pt(e):!0}function Us(e={}){const{editor:t,hideWhenUnavailable:n=!1,onWidthAdjusted:o}=e,{editor:l}=S(t),s=du({editor:l,hideWhenUnavailable:n}),a=Pt(l),i=u.useCallback(()=>{const f=cu({editor:l});return f&&o?.(),f},[l,o]);return{isVisible:s,canFitToWidth:a,handleFitToWidth:i,label:"Fit to width",Icon:Bs}}const uu=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onWidthAdjusted:n,text:o,onClick:l,children:s,...a},i)=>{const{editor:c}=S(e),{isVisible:d,canFitToWidth:f,label:h,Icon:p,handleFitToWidth:C}=Us({editor:c,hideWhenUnavailable:t,onWidthAdjusted:n}),b=u.useCallback(g=>{l?.(g),!g.defaultPrevented&&C()},[C,l]);return d?r.jsx(k,{type:"button",disabled:!f,variant:"ghost","data-active-state":"off","data-disabled":!f,role:"button",tabIndex:-1,"aria-label":h,tooltip:h,onClick:b,...a,ref:i,children:s??r.jsxs(r.Fragment,{children:[r.jsx(p,{className:"tiptap-button-icon"}),o&&r.jsx("span",{className:"tiptap-button-text",children:o})]})}):null});uu.displayName="TableFitToWidthButton";function Io(e){return!e||!e.isEditable||!V(e,["tocNode"])?!1:re(e,["tocNode"])}function fu(e){if(!e)return!1;try{const{selection:t}=e.state;return t instanceof M.NodeSelection&&t.node.type.name==="tocNode"?t.node.attrs.showTitle===!0:!1}catch{return!1}}function hu(e){if(!e?.isEditable||!Io(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof M.NodeSelection&&t.node.type.name==="tocNode"))return!1;const l=t.node.attrs.showTitle===!0;return e.chain().focus().updateAttributes("tocNode",{showTitle:!l}).run()}catch{return!1}}function pu(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable||!V(t,["tocNode"])?!1:n?Io(t):!0}function Os(e){const{editor:t,hideWhenUnavailable:n=!1,onToggle:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),[i,c]=u.useState(!1),d=Io(l);u.useEffect(()=>{if(!l)return;const h=()=>{a(pu({editor:l,hideWhenUnavailable:n})),c(fu(l))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=hu(l);return h&&o?.(),h},[l,o]);return{isVisible:s,isActive:i,canToggle:d,handleToggle:f,label:"Show title",Icon:ro}}const Cu=pt.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggle:o,onClick:l,children:s,...a},i)=>{const{editor:c}=S(e),{isVisible:d,isActive:f,canToggle:h,handleToggle:p,label:C,Icon:b}=Os({editor:c,hideWhenUnavailable:n,onToggle:o}),g=pt.useCallback(w=>{l?.(w),!w.defaultPrevented&&p()},[p,l]);return d?r.jsx(k,{type:"button",variant:"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":C,tooltip:C,onClick:g,...a,ref:i,children:s??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});Cu.displayName="TocShowTitleButton";const Ps=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z",fill:"currentColor"}),r.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z",fill:"currentColor"}),r.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z",fill:"currentColor"}),r.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z",fill:"currentColor"}),r.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z",fill:"currentColor"}),r.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z",fill:"currentColor"})]}));Ps.displayName="GripVerticalIcon";const Mo=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 5.29289C5.31658 4.90237 4.68342 4.90237 4.29289 5.29289L1.29289 8.29289C0.902369 8.68342 0.902369 9.31658 1.29289 9.70711C1.68342 10.0976 2.31658 10.0976 2.70711 9.70711L4 8.41421V16C4 16.7956 4.31607 17.5587 4.87868 18.1213C5.44129 18.6839 6.20435 19 7 19H13C13.5523 19 14 18.5523 14 18C14 17.4477 13.5523 17 13 17H7C6.73478 17 6.48043 16.8946 6.29289 16.7071C6.10536 16.5196 6 16.2652 6 16V8.41421L7.29289 9.70711C7.68342 10.0976 8.31658 10.0976 8.70711 9.70711C9.09763 9.31658 9.09763 8.68342 8.70711 8.29289L5.70711 5.29289ZM15.2929 14.2929C15.6834 13.9024 16.3166 13.9024 16.7071 14.2929L18 15.5858V8C18 7.73478 17.8946 7.48043 17.7071 7.29289C17.5196 7.10536 17.2652 7 17 7H11C10.4477 7 10 6.55228 10 6C10 5.44772 10.4477 5 11 5H17C17.7957 5 18.5587 5.31607 19.1213 5.87868C19.6839 6.44129 20 7.20435 20 8V15.5858L21.2929 14.2929C21.6834 13.9024 22.3166 13.9024 22.7071 14.2929C23.0976 14.6834 23.0976 15.3166 22.7071 15.7071L19.7071 18.7071C19.3166 19.0976 18.6834 19.0976 18.2929 18.7071L15.2929 15.7071C14.9024 15.3166 14.9024 14.6834 15.2929 14.2929Z",fill:"currentColor"})}));Mo.displayName="Repeat2Icon";const gu=()=>{const e=ms(),t=Dt({level:1}),n=Dt({level:2}),o=Dt({level:3}),l=Ot({type:"bulletList"}),s=Ot({type:"orderedList"}),a=Ot({type:"taskList"}),i=Ls(),c=Ns(),d=p=>({icon:p.Icon,label:p.label,onClick:p.handleToggle,disabled:!p.canToggle,isActive:p.isActive}),f=[d(e),...[t,n,o].map(d),d(l),d(s),d(a),d(i),d(c)];return f.every(p=>p.disabled)?null:f},me=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:l=!1,shortcutBadge:s})=>r.jsxs(Te,{render:r.jsx(k,{variant:"ghost","data-active-state":l?"on":"off"}),onClick:n,disabled:o,children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),s]}),bu=({icon:e,label:t,children:n})=>r.jsx(Ke,{placement:"right",trigger:r.jsx(Te,{render:r.jsx(Ye,{render:r.jsxs(k,{variant:"ghost",children:[r.jsx(e,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:t}),r.jsx(st,{}),r.jsx(je,{className:"tiptap-button-icon"})]})})}),children:r.jsx(Ge,{portal:!0,children:r.jsx(qe,{children:n})})}),wu=()=>{const e=gu(),{canReset:t,handleResetFormatting:n,label:o,Icon:l}=ws({hideWhenUnavailable:!0,preserveMarks:["inlineThread"]});return!e&&!t?null:r.jsxs(r.Fragment,{children:[e&&r.jsx(bu,{icon:Mo,label:"Turn Into",children:r.jsxs(ae,{children:[r.jsx(ot,{children:"Turn into"}),e.map(s=>r.jsx(me,{...s},s.label))]})}),t&&r.jsx(me,{icon:l,label:o,disabled:!t,onClick:n})]})},vu=()=>{const{canFitToWidth:e,handleFitToWidth:t,label:n,Icon:o}=Us({hideWhenUnavailable:!0}),l=vt({resetAttrs:!0});return r.jsxs(r.Fragment,{children:[e&&r.jsx(me,{icon:o,label:n,disabled:!e,onClick:t}),l.canClearRowColumnContent&&r.jsx(me,{icon:l.Icon,label:"Clear all contents",disabled:!l.canClearRowColumnContent,onClick:l.handleClear})]})},mu=()=>{const{canToggle:e,handleToggle:t,label:n,Icon:o}=Os({hideWhenUnavailable:!0});return e?r.jsx(me,{icon:o,label:n,disabled:!e,onClick:t}):null},yu=()=>{const{canDownload:e,handleDownload:t,label:n,Icon:o}=Yl({hideWhenUnavailable:!0});return e?r.jsx(me,{icon:o,label:n,disabled:!e,onClick:t}):null},xu=()=>{const{handleDuplicate:e,canDuplicate:t,label:n,Icon:o}=Jl(),{handleCopyToClipboard:l,canCopyToClipboard:s,label:a,Icon:i}=os(),{handleCopyAnchorLink:c,canCopyAnchorLink:d,label:f,Icon:h}=hs();return r.jsxs(r.Fragment,{children:[r.jsx(R,{orientation:"horizontal"}),r.jsxs(ae,{children:[r.jsx(me,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:r.jsx(Xl,{})}),r.jsx(me,{icon:i,label:a,onClick:l,disabled:!s,shortcutBadge:r.jsx(Rl,{})}),r.jsx(me,{icon:h,label:f,onClick:c,disabled:!d,shortcutBadge:r.jsx(is,{})})]}),r.jsx(R,{orientation:"horizontal"})]})},Su=()=>{const{handleDeleteNode:e,canDeleteNode:t,label:n,Icon:o}=as();return r.jsx(ae,{children:r.jsx(me,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:r.jsx(rs,{})})})},Tu=({editor:e,withSlashCommandTrigger:t=!0,mobileBreakpoint:n=768,...o})=>{const{editor:l}=S(e),{isDragging:s}=Xt(l),a=ee("max",n),[i,c]=u.useState(!1),[d,f]=u.useState(null),[h,p]=u.useState(-1),C=u.useCallback(y=>{y.node&&f(y.node),p(y.pos)},[]);u.useEffect(()=>{l&&(l.commands.setLockDragHandle(i),l.commands.setMeta("lockDragHandle",i))},[l,i]);const b=16,g=u.useMemo(()=>({middleware:[D.offset(y=>{const{rects:T}=y,E=T.reference.height,L=T.floating.height,N=E/2-L/2;return{mainAxis:b,crossAxis:E>40?0:N}})]}),[]),w=u.useCallback(()=>{l&&l.commands.setMeta("hideDragHandle",!0)},[l]),v=u.useCallback(y=>{y.stopPropagation(),l&&l.commands.setIsDragging(!0)},[l]),m=u.useCallback(y=>{y.stopPropagation(),l&&(l.commands.setIsDragging(!1),setTimeout(()=>{l.view.dom.blur(),l.view.focus()},0))},[l]);if(!l)return null;const x=kl(l);return r.jsx("div",{style:{"--drag-handle-main-axis-offset":`${b}px`},children:r.jsx(oi.DragHandle,{editor:l,onNodeChange:C,computePositionConfig:g,onElementDragStart:v,onElementDragEnd:m,...o,children:r.jsxs("div",{style:{display:"flex",flexDirection:"row",...a||Z2(l)?{opacity:0,pointerEvents:"none"}:{},...s?{opacity:0}:{}},children:[t&&r.jsx(xo,{node:d,nodePos:h,"data-weight":"small"}),r.jsx(Ke,{open:i,onOpenChange:c,placement:"left",trigger:r.jsx(Ye,{render:r.jsx(k,{variant:"ghost",tabIndex:-1,tooltip:r.jsxs(r.Fragment,{children:[r.jsx("div",{children:"Click for options"}),r.jsx("div",{children:"Hold for drag"})]}),"data-weight":"small",style:{cursor:"grab",...i?{pointerEvents:"none"}:{}},onMouseDown:()=>tn(l,h),children:r.jsx(Ps,{className:"tiptap-button-icon"})})}),children:r.jsxs(Ge,{onClose:w,autoFocusOnHide:!1,preventBodyScroll:!0,portal:!0,children:[r.jsx(fn,{style:Qt}),r.jsxs(qe,{style:{minWidth:"15rem"},children:[r.jsx(ot,{children:x}),r.jsxs(ae,{children:[r.jsx(mu,{}),r.jsx(Ln,{}),r.jsx(Pn,{}),r.jsx(vu,{}),r.jsx(wu,{}),r.jsx(yu,{})]}),r.jsx(xu,{}),r.jsx(Su,{})]})]})})]})})})},Zs=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",fill:"currentColor"}),r.jsx("path",{d:"M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",fill:"currentColor"}),r.jsx("path",{d:"M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",fill:"currentColor"}),r.jsx("path",{d:"M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",fill:"currentColor"}),r.jsx("path",{d:"M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",fill:"currentColor"}),r.jsx("path",{d:"M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",fill:"currentColor"}),r.jsx("path",{d:"M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",fill:"currentColor"}),r.jsx("path",{d:"M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",fill:"currentColor"})]}));Zs.displayName="SunIcon";const Fs=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C10.0222 2 8.08879 2.58649 6.4443 3.6853C4.79981 4.78412 3.51809 6.3459 2.76121 8.17317C2.00433 10.0004 1.8063 12.0111 2.19215 13.9509C2.578 15.8907 3.53041 17.6725 4.92894 19.0711C6.32746 20.4696 8.10929 21.422 10.0491 21.8079C11.9889 22.1937 13.9996 21.9957 15.8268 21.2388C17.6541 20.4819 19.2159 19.2002 20.3147 17.5557C21.4135 15.9112 22 13.9778 22 12C22 11.5955 21.7564 11.2309 21.3827 11.0761C21.009 10.9213 20.5789 11.0069 20.2929 11.2929C19.287 12.2988 17.9226 12.864 16.5 12.864C15.0774 12.864 13.713 12.2988 12.7071 11.2929C11.7012 10.287 11.136 8.92261 11.136 7.5C11.136 6.07739 11.7012 4.71304 12.7071 3.70711C12.9931 3.42111 13.0787 2.99099 12.9239 2.61732C12.7691 2.24364 12.4045 2 12 2ZM7.55544 5.34824C8.27036 4.87055 9.05353 4.51389 9.87357 4.28778C9.39271 5.27979 9.13604 6.37666 9.13604 7.5C9.13604 9.45304 9.91189 11.3261 11.2929 12.7071C12.6739 14.0881 14.547 14.864 16.5 14.864C17.6233 14.864 18.7202 14.6073 19.7122 14.1264C19.4861 14.9465 19.1295 15.7296 18.6518 16.4446C17.7727 17.7602 16.5233 18.7855 15.0615 19.391C13.5997 19.9965 11.9911 20.155 10.4393 19.8463C8.88743 19.5376 7.46197 18.7757 6.34315 17.6569C5.22433 16.538 4.4624 15.1126 4.15372 13.5607C3.84504 12.0089 4.00347 10.4003 4.60897 8.93853C5.21447 7.47672 6.23985 6.22729 7.55544 5.34824Z",fill:"currentColor"}),r.jsx("path",{d:"M19 2C19.5523 2 20 2.44772 20 3V4H21C21.5523 4 22 4.44772 22 5C22 5.55228 21.5523 6 21 6H20V7C20 7.55228 19.5523 8 19 8C18.4477 8 18 7.55228 18 7V6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H18V3C18 2.44772 18.4477 2 19 2Z",fill:"currentColor"})]}));Fs.displayName="MoonStarIcon";function Iu(){const{editor:e}=u.useContext(P.EditorContext),[t,n]=u.useState(!1);u.useEffect(()=>{const l=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>n(l.matches);return l.addEventListener("change",s),()=>l.removeEventListener("change",s)},[]),u.useEffect(()=>{const l=!!document.querySelector('meta[name="color-scheme"][content="dark"]')||window.matchMedia("(prefers-color-scheme: dark)").matches;n(l)},[]),u.useEffect(()=>{e?.view.dom.closest(".omnibox-editor-root")?.classList.toggle("dark",t)},[e,t]);const o=()=>n(l=>!l);return r.jsx(k,{onClick:o,"aria-label":`Switch to ${t?"light":"dark"} mode`,variant:"ghost",children:t?r.jsx(Fs,{className:"tiptap-button-icon"}):r.jsx(Zs,{className:"tiptap-button-icon"})})}function Mu({action:e,shortcutKeys:t=Ws[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const ko=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onExecuted:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleAction:p,label:C,canExecute:b,Icon:g,shortcutKeys:w}=Hu({editor:f,action:t,hideWhenUnavailable:o,onExecuted:l}),v=u.useCallback(m=>{a?.(m),!m.defaultPrevented&&p()},[p,a]);return h?r.jsx(k,{type:"button",disabled:!b,variant:"ghost","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":C,tooltip:C,onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Mu,{action:t,shortcutKeys:w})]})}):null});ko.displayName="UndoRedoButton";const $s=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));$s.displayName="Redo2Icon";const zs=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));zs.displayName="Undo2Icon";const Ws={undo:"mod+z",redo:"mod+shift+z"},ku={undo:"Undo",redo:"Redo"},Eu={undo:zs,redo:$s};function Eo(e,t){return!e||!e.isEditable||re(e,["image"])?!1:t==="undo"?e.can().undo():e.can().redo()}function Lu(e,t){if(!e||!e.isEditable||!Eo(e,t))return!1;const n=e.chain().focus();return t==="undo"?n.undo().run():n.redo().run()}function Au(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:Eo(t,o):!1:!0:!1}function Hu(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Eo(s,n);u.useEffect(()=>{if(!s)return;const f=()=>{i(Au({editor:s,hideWhenUnavailable:o,action:n}))};return f(),s.on("transaction",f),()=>{s.off("transaction",f)}},[s,o,n]);const d=u.useCallback(()=>{if(!s)return!1;const f=Lu(s,n);return f&&l?.(),f},[s,n,l]);return{isVisible:a,handleAction:d,canExecute:c,label:ku[n],shortcutKeys:Ws[n],Icon:Eu[n]}}function Nu(){return r.jsxs("header",{className:"omnibox-editor-header",children:[r.jsx(st,{}),r.jsxs("div",{className:"omnibox-editor-header__actions",children:[r.jsxs(ce,{children:[r.jsx(ce,{children:r.jsx(ko,{action:"undo"})}),r.jsx(ce,{children:r.jsx(ko,{action:"redo"})})]}),r.jsx(R,{}),r.jsx(Iu,{})]})]})}const Vu=e=>{const t=u.useRef(e);t.current=e,u.useEffect(()=>()=>{t.current()},[])},Bu={leading:!1,trailing:!0};function _s(e,t=250,n=[],o=Bu){const l=u.useMemo(()=>ri(e,t,o),n);return Vu(()=>{l.cancel()}),l}function qs(){const[e,t]=u.useState({width:0,height:0,offsetTop:0,offsetLeft:0,scale:0}),n=_s(()=>{if(typeof window>"u")return;const o=window.visualViewport;if(!o)return;const{width:l=0,height:s=0,offsetTop:a=0,offsetLeft:i=0,scale:c=0}=o;t(d=>l===d.width&&s===d.height&&a===d.offsetTop&&i===d.offsetLeft&&c===d.scale?d:{width:l,height:s,offsetTop:a,offsetLeft:i,scale:c})},200);return u.useEffect(()=>{const o=window.visualViewport;if(o)return o.addEventListener("resize",n),n(),()=>{o.removeEventListener("resize",n)}},[n]),e}const Ks=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));Ks.displayName="BanIcon";const Lo=u.forwardRef(({className:e,children:t,...n},o)=>r.jsx(k,{type:"button",className:e,variant:"ghost","data-appearance":"default",role:"button",tabIndex:-1,"aria-label":"Highlight text",tooltip:"Highlight",ref:o,...n,children:t??r.jsx(St,{className:"tiptap-button-icon"})}));Lo.displayName="ColorHighlightPopoverButton";function Gs({editor:e,colors:t=ll(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),useColorValue:n=!1}){const{handleRemoveHighlight:o}=Tt({editor:e}),l=ee(),s=u.useRef(null),a=u.useMemo(()=>[...t,{label:"Remove highlight",value:"none"}],[t]),{selectedIndex:i}=It({containerRef:s,items:a,orientation:"both",onSelect:c=>{if(!s.current)return!1;const d=s.current.querySelector('[data-highlighted="true"]');return d&&d.click(),c.value==="none"&&o(),!0},autoSelectFirstItem:!1});return r.jsx(Ue,{ref:s,tabIndex:0,style:l?{boxShadow:"none",border:0}:{},children:r.jsx(Oe,{style:l?{padding:0}:{},children:r.jsxs(Ie,{orientation:"horizontal",children:[r.jsx(ce,{children:t.map((c,d)=>r.jsx(ce,{children:r.jsx(Xe,{editor:e,highlightColor:n?c.colorValue:c.value,tooltip:c.label,"aria-label":`${c.label} highlight color`,tabIndex:d===i?0:-1,"data-highlighted":i===d,useColorValue:n})},c.value))}),r.jsx(R,{}),r.jsx(ce,{children:r.jsx(k,{onClick:o,"aria-label":"Remove highlight",tooltip:"Remove highlight",tabIndex:i===t.length?0:-1,type:"button",role:"menuitem",variant:"ghost","data-highlighted":i===t.length,children:r.jsx(Ks,{className:"tiptap-button-icon"})})})]})})})}function Du({editor:e,colors:t=ll(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),hideWhenUnavailable:n=!1,useColorValue:o=!1,onApplied:l,...s}){const{editor:a}=S(e),[i,c]=u.useState(!1),{isVisible:d,canColorHighlight:f,isActive:h,label:p,Icon:C}=Tt({editor:a,hideWhenUnavailable:n,onApplied:l});return d?r.jsxs(Mt,{open:i,onOpenChange:c,children:[r.jsx(kt,{asChild:!0,children:r.jsx(Lo,{disabled:!f,"data-active-state":h?"on":"off","data-disabled":!f,"aria-pressed":h,"aria-label":p,tooltip:p,...s,children:r.jsx(C,{className:"tiptap-button-icon"})})}),r.jsx(Et,{"aria-label":"Highlight colors",children:r.jsx(Gs,{editor:a,colors:t,useColorValue:o})})]}):null}function Uu({shortcutKeys:e=Ho}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Ao=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onInserted:o,showShortcut:l=!1,onClick:s,icon:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,canInsert:p,handleImage:C,label:b,isActive:g,shortcutKeys:w,Icon:v}=Fu({editor:f,hideWhenUnavailable:n,onInserted:o}),m=u.useCallback(y=>{s?.(y),!y.defaultPrevented&&C()},[C,s]);if(!h)return null;const x=a??v;return r.jsx(k,{type:"button",variant:"ghost","data-active-state":g?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":b,"aria-pressed":g,tooltip:b,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(x,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),l&&r.jsx(Uu,{shortcutKeys:w})]})})});Ao.displayName="ImageUploadButton";const Ys=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"})}));Ys.displayName="ImagePlusIcon";const Ho="mod+shift+i";function No(e){return!e||!e.isEditable||!V(e,"imageUpload")?!1:e.can().insertContent({type:"imageUpload"})}function Ou(e){return!e||!e.isEditable?!1:e.isActive("imageUpload")}function Pu(e){if(!e||!e.isEditable||!No(e))return!1;try{return e.chain().focus().insertContent({type:"imageUpload"}).run()}catch{return!1}}function Zu(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable?!1:n?V(t,"imageUpload")?t.isActive("code")?!0:No(t):!1:!0}function Fu(e){const{editor:t,hideWhenUnavailable:n=!1,onInserted:o}=e||{},{editor:l}=S(t),s=ee(),[a,i]=u.useState(!0),c=No(l),d=Ou(l);u.useEffect(()=>{if(!l)return;const h=()=>{i(Zu({editor:l,hideWhenUnavailable:n}))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=Pu(l);return h&&o?.(),h},[l,o]);return ie.useHotkeys(Ho,h=>{h.preventDefault(),f()},{enabled:a&&c,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:a,isActive:d,handleImage:f,canInsert:c,label:"Add image",shortcutKeys:Ho,Icon:Ys}}const Xs=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));Xs.displayName="CornerDownLeftIcon";const js=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),r.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));js.displayName="ExternalLinkIcon";const Vo=u.forwardRef(({className:e,children:t,...n},o)=>r.jsx(k,{type:"button",className:e,variant:"ghost",role:"button",tabIndex:-1,"aria-label":"Link",tooltip:"Link",ref:o,...n,children:t||r.jsx(ut,{className:"tiptap-button-icon"})}));Vo.displayName="LinkButton";const Qs=({url:e,setUrl:t,setLink:n,removeLink:o,openLink:l,isActive:s})=>{const a=ee(),i=c=>{c.key==="Enter"&&(c.preventDefault(),n())};return r.jsx(Ue,{style:{...a?{boxShadow:"none",border:0}:{}},children:r.jsx(Oe,{style:{...a?{padding:0}:{}},children:r.jsxs(Ie,{orientation:"horizontal",children:[r.jsx(Z1,{type:"url",placeholder:"Paste a link...",value:e,onChange:c=>t(c.target.value),onKeyDown:i,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:"tiptap-link-input"}),r.jsx(ce,{children:r.jsx(k,{type:"button",onClick:n,title:"Apply link",disabled:!e&&!s,variant:"ghost",children:r.jsx(Xs,{className:"tiptap-button-icon"})})}),r.jsx(R,{}),r.jsxs(ce,{children:[r.jsx(ce,{children:r.jsx(k,{type:"button",onClick:l,title:"Open in new window",disabled:!e&&!s,variant:"ghost",children:r.jsx(js,{className:"tiptap-button-icon"})})}),r.jsx(ce,{children:r.jsx(k,{type:"button",onClick:o,title:"Remove link",disabled:!e&&!s,variant:"ghost",children:r.jsx(mt,{className:"tiptap-button-icon"})})})]})]})})})},$u=({editor:e})=>{const t=Rs({editor:e});return r.jsx(Qs,{...t})},Bo=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onSetLink:n,onOpenChange:o,autoOpenOnLinkActive:l=!0,onClick:s,children:a,...i},c)=>{const{editor:d}=S(e),[f,h]=u.useState(!1),{isVisible:p,canSet:C,isActive:b,url:g,setUrl:w,setLink:v,removeLink:m,openLink:x,label:y,Icon:T}=Rs({editor:d,hideWhenUnavailable:t,onSetLink:n}),E=u.useCallback(te=>{h(te),o?.(te)},[o]),L=u.useCallback(()=>{v(),h(!1)},[v]),N=u.useCallback(te=>{s?.(te),!te.defaultPrevented&&h(!f)},[s,f]);return u.useEffect(()=>{l&&b&&h(!0)},[l,b]),p?r.jsxs(Mt,{open:f,onOpenChange:E,children:[r.jsx(kt,{asChild:!0,children:r.jsx(Vo,{disabled:!C,"data-active-state":b?"on":"off","data-disabled":!C,"aria-label":y,"aria-pressed":b,onClick:N,...i,ref:c,children:a??r.jsx(T,{className:"tiptap-button-icon"})})}),r.jsx(Et,{collisionPadding:4,children:r.jsx(Qs,{url:g,setUrl:w,setLink:L,removeLink:m,openLink:x,isActive:b})})]}):null});Bo.displayName="LinkPopover";function Do(e){if(!e||!e.isEditable||re(e,["image"],!0))return!1;try{return e.can().setMark("link")}catch{return!1}}function Js(e){return!e||!e.isEditable?!1:e.isActive("link")}function zu(e){const{editor:t,hideWhenUnavailable:n}=e;if(!t||!t.isEditable)return!1;const o=xe("link",t);return n?o?t.isActive("code")?!0:Do(t):!1:!0}function Wu(e){const{editor:t,onSetLink:n}=e,[o,l]=u.useState(null);u.useEffect(()=>{if(!t)return;const{href:c}=t.getAttributes("link");Js(t)&&o===null&&l(c||"")},[t,o]),u.useEffect(()=>{if(!t)return;const c=()=>{const{href:d}=t.getAttributes("link");l(d||"")};return t.on("selectionUpdate",c),()=>{t.off("selectionUpdate",c)}},[t]);const s=u.useCallback(()=>{if(!o||!t)return;const{selection:c}=t.state,d=c.empty;let f=t.chain().focus();f=f.extendMarkRange("link").setLink({href:o}),d&&(f=f.insertContent({type:"text",text:o})),f.run(),l(null),n?.()},[t,n,o]),a=u.useCallback(()=>{t&&(t.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),l(""))},[t]),i=u.useCallback((c="_blank",d="noopener,noreferrer")=>{if(!o)return;const f=Jt(o,window.location.href);f!=="#"&&window.open(f,c,d)},[o]);return{url:o||"",setUrl:l,setLink:s,removeLink:a,openLink:i}}function _u(e){const{editor:t,hideWhenUnavailable:n=!1}=e,o=Do(t),l=Js(t),[s,a]=u.useState(!0);return u.useEffect(()=>{if(!t)return;const i=()=>{a(zu({editor:t,hideWhenUnavailable:n}))};return i(),t.on("selectionUpdate",i),()=>{t.off("selectionUpdate",i)}},[t,n]),{isVisible:s,canSet:o,isActive:l}}function Rs(e){const{editor:t,hideWhenUnavailable:n=!1,onSetLink:o}=e||{},{editor:l}=S(t),{isVisible:s,canSet:a,isActive:i}=_u({editor:l,hideWhenUnavailable:n}),c=Wu({editor:l,onSetLink:o});return{isVisible:s,canSet:a,isActive:i,label:"Link",Icon:ut,...c}}function qu({type:e,shortcutKeys:t=aa[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const ue=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleMark:p,label:C,canToggle:b,isActive:g,Icon:w,shortcutKeys:v}=Qu({editor:f,type:t,hideWhenUnavailable:o,onToggled:l}),m=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&p()},[p,a]);return h?r.jsx(k,{type:"button",disabled:!b,variant:"ghost","data-active-state":g?"on":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":g,tooltip:C,onClick:m,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(qu,{type:t,shortcutKeys:v})]})}):null});ue.displayName="MarkButton";const ea=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));ea.displayName="BoldIcon";const ta=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),r.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),r.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));ta.displayName="Code2Icon";const na=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));na.displayName="ItalicIcon";const oa=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),r.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));oa.displayName="StrikeIcon";const ra=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));ra.displayName="SubscriptIcon";const la=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));la.displayName="SuperscriptIcon";const sa=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));sa.displayName="UnderlineIcon";const Ku={bold:ea,italic:na,underline:sa,strike:oa,code:ta,superscript:la,subscript:ra},aa={bold:"mod+b",italic:"mod+i",underline:"mod+u",strike:"mod+shift+s",code:"mod+e",superscript:"mod+.",subscript:"mod+,"};function Zt(e,t){return!e||!e.isEditable||!xe(t,e)||re(e,["image"])?!1:e.can().toggleMark(t)}function Gu(e,t){return!e||!e.isEditable?!1:e.isActive(t)}function Yu(e,t){return!e||!e.isEditable||!Zt(e,t)?!1:e.chain().focus().toggleMark(t).run()}function Xu(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!xe(n,t)?!1:t.isActive("code")?!0:Zt(t,n):!0:!1}function ju(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qu(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Zt(s,n),d=Gu(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(Xu({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=Yu(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleMark:f,canToggle:c,label:ju(n),shortcutKeys:aa[n],Icon:Ku[n]}}function Ju({align:e,shortcutKeys:t=ia[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const Me=u.forwardRef(({editor:e,align:t,text:n,hideWhenUnavailable:o=!1,onAligned:l,showShortcut:s=!1,onClick:a,icon:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleTextAlign:C,label:b,canAlign:g,isActive:w,Icon:v,shortcutKeys:m}=l7({editor:h,align:t,hideWhenUnavailable:o,onAligned:l}),x=u.useCallback(T=>{a?.(T),!T.defaultPrevented&&C()},[C,a]);if(!p)return null;const y=i??v;return r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-active-state":w?"on":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":w,tooltip:b,onClick:x,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(y,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(Ju,{align:t,shortcutKeys:m})]})})});Me.displayName="TextAlignButton";const ia={left:"mod+shift+l",center:"mod+shift+e",right:"mod+shift+r",justify:"mod+shift+j"},Ru={left:An,center:Hn,right:Nn,justify:Vn},e7={left:"Align left",center:"Align center",right:"Align right",justify:"Align justify"};function Ft(e,t){return!e||!e.isEditable||!V(e,"textAlign")||re(e,["image","horizontalRule"])?!1:e.can().setTextAlign(t)}function t7(e){return"setTextAlign"in e}function n7(e,t){return!e||!e.isEditable?!1:e.isActive({textAlign:t})}function o7(e,t){if(!e||!e.isEditable||!Ft(e,t))return!1;const n=e.chain().focus();return t7(n)?n.setTextAlign(t).run():!1}function r7(e){const{editor:t,hideWhenUnavailable:n,align:o}=e;return t?n?!t.isEditable||!V(t,"textAlign")?!1:t.isActive("code")?!0:Ft(t,o):!0:!1}function l7(e){const{editor:t,align:n,hideWhenUnavailable:o=!1,onAligned:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Ft(s,n),d=n7(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{i(r7({editor:s,align:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const f=u.useCallback(()=>{if(!s)return!1;const h=o7(s,n);return h&&l?.(),h},[s,n,l]);return{isVisible:a,isActive:d,handleTextAlign:f,canAlign:c,label:e7[n],shortcutKeys:ia[n],Icon:Ru[n]}}const s7=u.memo(({className:e,...t})=>r.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z",fill:"currentColor"})}));s7.displayName="CheckIcon";function ca({...e}){return r.jsx(ge.Root,{"data-slot":"tiptap-dropdown-menu",...e})}function da({...e}){return r.jsx(ge.Portal,{"data-slot":"tiptap-dropdown-menu-portal",...e})}function ua({...e}){return r.jsx(ge.Trigger,{"data-slot":"tiptap-dropdown-menu-trigger",...e})}function fa({className:e,align:t="start",sideOffset:n=4,...o}){return r.jsx(ge.Portal,{children:r.jsx(ge.Content,{"data-slot":"tiptap-dropdown-menu-content",sideOffset:n,align:t,className:U("tiptap-dropdown-menu-content",e),onCloseAutoFocus:l=>l.preventDefault(),...o})})}function Fe({className:e,...t}){return r.jsx(ge.Group,{"data-slot":"tiptap-dropdown-menu-group",className:U("tiptap-dropdown-menu-group",e),...t})}function de({className:e,inset:t,variant:n="default",...o}){return r.jsx(ge.Item,{"data-slot":"tiptap-dropdown-menu-item","data-inset":t,"data-variant":n,className:U("tiptap-dropdown-menu-item",e),...o})}function ft({className:e,inset:t,...n}){return r.jsx(ge.Label,{"data-slot":"tiptap-dropdown-menu-label","data-inset":t,className:U("tiptap-dropdown-menu-label",e),...n})}function ha({...e}){return r.jsx(ge.Sub,{"data-slot":"tiptap-dropdown-menu-sub",...e})}function pa({className:e,inset:t,children:n,...o}){return r.jsx(ge.SubTrigger,{"data-slot":"tiptap-dropdown-menu-sub-trigger","data-inset":t,className:U("tiptap-dropdown-menu-sub-trigger",e),...o,children:n})}function Ca({className:e,...t}){return r.jsx(ge.SubContent,{"data-slot":"tiptap-dropdown-menu-sub-content",className:U("tiptap-dropdown-menu-sub-content",e),...t})}function ga({blockTypes:e,editor:t}){const n=$t(e);return r.jsxs(Fe,{children:[r.jsx(ft,{children:"Turn into"}),n.map((o,l)=>a7(o,`${o.type}-${o.level??l}`,t))]})}function a7(e,t,n){switch(e.type){case"paragraph":return r.jsx(de,{asChild:!0,children:r.jsx(vs,{editor:n,showTooltip:!1,text:e.label})},t);case"heading":return e.level?r.jsx(de,{asChild:!0,children:r.jsx(ys,{editor:n,level:e.level,showTooltip:!1,text:e.label})},t):null;case"bulletList":return r.jsx(de,{asChild:!0,children:r.jsx(Ut,{editor:n,type:"bulletList",showTooltip:!1,text:e.label})},t);case"orderedList":return r.jsx(de,{asChild:!0,children:r.jsx(Ut,{editor:n,type:"orderedList",showTooltip:!1,text:e.label})},t);case"taskList":return r.jsx(de,{asChild:!0,children:r.jsx(Ut,{editor:n,type:"taskList",showTooltip:!1,text:e.label})},t);case"blockquote":return r.jsx(de,{asChild:!0,children:r.jsx(ks,{editor:n,showTooltip:!1,text:e.label})},t);case"codeBlock":return r.jsx(de,{asChild:!0,children:r.jsx(As,{editor:n,showTooltip:!1,text:e.label})},t);default:return null}}const ba=u.forwardRef(function({editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:l,modal:s=!0,children:a,...i},c){const{editor:d}=S(t),{isVisible:f,canToggle:h,isOpen:p,activeBlockType:C,handleOpenChange:b,label:g,Icon:w}=u7({editor:d,hideWhenUnavailable:n,blockTypes:o,onOpenChange:l});return f?r.jsxs(ca,{modal:s,open:p,onOpenChange:b,children:[r.jsx(ua,{asChild:!0,children:r.jsx(k,{type:"button",variant:"ghost",disabled:!h,"data-disabled":!h,role:"button",tabIndex:-1,"aria-label":g,tooltip:"Turn into",...i,ref:c,children:a??r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"tiptap-button-text",children:C?.label||"Text"}),r.jsx(w,{className:"tiptap-button-dropdown-small"})]})})}),r.jsx(fa,{align:"start",children:r.jsx(ga,{blockTypes:o,editor:d})})]}):null});ba.displayName="TurnIntoDropdown";const i7=["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"],wa=[{type:"paragraph",label:"Text",isActive:e=>e.isActive("paragraph")&&!e.isActive("heading")&&!e.isActive("bulletList")&&!e.isActive("orderedList")&&!e.isActive("taskList")&&!e.isActive("blockquote")&&!e.isActive("codeBlock")},{type:"heading",label:"Heading 1",level:1,isActive:e=>e.isActive("heading",{level:1})},{type:"heading",label:"Heading 2",level:2,isActive:e=>e.isActive("heading",{level:2})},{type:"heading",label:"Heading 3",level:3,isActive:e=>e.isActive("heading",{level:3})},{type:"bulletList",label:"Bulleted list",isActive:e=>e.isActive("bulletList")},{type:"orderedList",label:"Numbered list",isActive:e=>e.isActive("orderedList")},{type:"taskList",label:"To-do list",isActive:e=>e.isActive("taskList")},{type:"blockquote",label:"Blockquote",isActive:e=>e.isActive("blockquote")},{type:"codeBlock",label:"Code block",isActive:e=>e.isActive("codeBlock")}];function va(e,t){if(!e||!e.isEditable)return!1;const n=t||i7,{selection:o}=e.state;if(o instanceof M.NodeSelection){const a=o.node.type.name;return n.includes(a)}const{$anchor:l}=o,s=l.parent.type.name;return n.includes(s)}function $t(e){return e?wa.filter(t=>e.includes(t.type)):wa}function c7(e,t){if(!e)return $t(t)[0];const n=$t(t);return n.find(l=>l.isActive(e))||n[0]}function d7(e){const{editor:t,hideWhenUnavailable:n,blockTypes:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:va(t,o):!1:!0:!1}function u7(e){const{editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:l}=e||{},{editor:s}=S(t),[a,i]=u.useState(!1),[c,d]=u.useState(!0),f=va(s,o),h=c7(s,o),p=u.useCallback(C=>{!s||!f||(i(C),l?.(C))},[f,s,l]);return u.useEffect(()=>{if(!s)return;const C=()=>{d(d7({editor:s,hideWhenUnavailable:n,blockTypes:o}))};return C(),s.on("selectionUpdate",C),()=>{s.off("selectionUpdate",C)}},[s,n,o]),{isVisible:c,canToggle:f,isOpen:a,setIsOpen:i,activeBlockType:h,handleOpenChange:p,filteredOptions:$t(o),label:`Turn into (current: ${h?.label||"Text"})`,Icon:kn}}function f7({action:e,shortcutKeys:t=xa[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const ht=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onIndented:l,showShortcut:s=!1,onClick:a,icon:i,children:c,...d},f)=>{const{editor:h}=S(e),{isVisible:p,handleIndent:C,label:b,canIndent:g,Icon:w,shortcutKeys:v}=b7({editor:h,action:t,hideWhenUnavailable:o,onIndented:l}),m=u.useCallback(y=>{a?.(y),!y.defaultPrevented&&C()},[C,a]);if(!p)return null;const x=i??w;return r.jsx(k,{type:"button",disabled:!g,variant:"ghost","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":b,tooltip:b,onClick:m,...d,ref:f,children:c??r.jsxs(r.Fragment,{children:[r.jsx(x,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),s&&r.jsx(f7,{action:t,shortcutKeys:v})]})})});ht.displayName="IndentButton";const ma=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M17.0002 18.5C17.5524 18.5 18.0002 18.9477 18.0002 19.5C18.0002 20.0523 17.5524 20.5 17.0002 20.5H11.0002C10.4479 20.5 10.0002 20.0523 10.0002 19.5C10.0002 18.9477 10.4479 18.5 11.0002 18.5H17.0002Z",fill:"currentColor"}),r.jsx("path",{d:"M2.29314 8.29297C2.68366 7.90248 3.31669 7.90246 3.7072 8.29297L6.7072 11.293L6.77556 11.3691C7.09586 11.7619 7.07327 12.3409 6.7072 12.707L3.7072 15.707C3.31669 16.0975 2.68367 16.0975 2.29314 15.707C1.90261 15.3165 1.90261 14.6835 2.29314 14.293L4.58611 12L2.29314 9.70703C1.90261 9.31651 1.90261 8.68349 2.29314 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0002 13.5C21.5524 13.5 22.0002 13.9477 22.0002 14.5C22.0002 15.0523 21.5524 15.5 21.0002 15.5H11.0002C10.4479 15.5 10.0002 15.0523 10.0002 14.5C10.0002 13.9477 10.4479 13.5 11.0002 13.5H21.0002Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0002 8.5C21.5524 8.50004 22.0002 8.94774 22.0002 9.5C22.0002 10.0523 21.5524 10.5 21.0002 10.5H11.0002C10.4479 10.5 10.0002 10.0523 10.0002 9.5C10.0002 8.94772 10.4479 8.5 11.0002 8.5H21.0002Z",fill:"currentColor"}),r.jsx("path",{d:"M21.0002 3.5C21.5524 3.50004 22.0002 3.94774 22.0002 4.5C22.0002 5.05226 21.5524 5.49996 21.0002 5.5H11.0002C10.4479 5.5 10.0002 5.05228 10.0002 4.5C10.0002 3.94772 10.4479 3.5 11.0002 3.5H21.0002Z",fill:"currentColor"})]}));ma.displayName="IndentIncreaseIcon";const ya=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M9 18.5C9.55228 18.5 10 18.9477 10 19.5C10 20.0523 9.55228 20.5 9 20.5H3C2.44772 20.5 2 20.0523 2 19.5C2 18.9477 2.44772 18.5 3 18.5H9Z",fill:"currentColor"}),r.jsx("path",{d:"M20.293 8.29297C20.6835 7.90244 21.3165 7.90244 21.707 8.29297C22.0976 8.68349 22.0976 9.31651 21.707 9.70703L19.4141 12L21.707 14.293C22.0976 14.6835 22.0976 15.3165 21.707 15.707C21.3165 16.0976 20.6835 16.0976 20.293 15.707L17.293 12.707L17.2246 12.6309C16.9043 12.2381 16.9269 11.6591 17.293 11.293L20.293 8.29297Z",fill:"currentColor"}),r.jsx("path",{d:"M13 13.5C13.5523 13.5 14 13.9477 14 14.5C14 15.0523 13.5523 15.5 13 15.5H3C2.44772 15.5 2 15.0523 2 14.5C2 13.9477 2.44772 13.5 3 13.5H13Z",fill:"currentColor"}),r.jsx("path",{d:"M13 8.5C13.5523 8.5 14 8.94772 14 9.5C14 10.0523 13.5523 10.5 13 10.5H3C2.44772 10.5 2 10.0523 2 9.5C2 8.94772 2.44772 8.5 3 8.5H13Z",fill:"currentColor"}),r.jsx("path",{d:"M13 3.5C13.5523 3.5 14 3.94772 14 4.5C14 5.05228 13.5523 5.5 13 5.5H3C2.44772 5.5 2 5.05228 2 4.5C2 3.94772 2.44772 3.5 3 3.5H13Z",fill:"currentColor"})]}));ya.displayName="IndentDecreaseIcon";const xa={indent:"Tab",outdent:"Shift-Tab"},h7={indent:ma,outdent:ya},p7={indent:"Increase indent",outdent:"Decrease indent"};function Uo(e,t){return!e||!e.isEditable||!V(e,"indent")?!1:t==="indent"?e.can().indent():e.can().outdent()}function C7(e,t){return!e||!e.isEditable||!Uo(e,t)?!1:t==="indent"?e.chain().focus().indent().run():e.chain().focus().outdent().run()}function g7(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?!t.isEditable||!V(t,"indent")?!1:Uo(t,o):!0:!1}function b7(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onIndented:l}=e,{editor:s}=S(t),[a,i]=u.useState(!0),c=Uo(s,n);u.useEffect(()=>{if(!s)return;const f=()=>{i(g7({editor:s,action:n,hideWhenUnavailable:o}))};return f(),s.on("selectionUpdate",f),s.on("transaction",f),()=>{s.off("selectionUpdate",f),s.off("transaction",f)}},[s,o,n]);const d=u.useCallback(()=>{if(!s)return!1;const f=C7(s,n);return f&&l?.(),f},[s,n,l]);return{isVisible:a,canIndent:c,handleIndent:d,label:p7[n],shortcutKeys:xa[n],Icon:h7[n]}}const w7=e=>{const[t,n]=u.useState([]),o=u.useCallback(()=>e.current?Array.from(e.current.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')):[],[e]);u.useEffect(()=>{const s=e.current;if(!s)return;const a=()=>n(o());a();const i=new MutationObserver(a);return i.observe(s,{childList:!0,subtree:!0}),()=>i.disconnect()},[o,e]);const{selectedIndex:l}=It({containerRef:e,items:t,orientation:"horizontal",onSelect:s=>s.click(),autoSelectFirstItem:!1});u.useEffect(()=>{const s=e.current;if(!s)return;const a=c=>{const d=c.target;s.contains(d)&&d.setAttribute("data-focus-visible","true")},i=c=>{const d=c.target;s.contains(d)&&d.removeAttribute("data-focus-visible")};return s.addEventListener("focus",a,!0),s.addEventListener("blur",i,!0),()=>{s.removeEventListener("focus",a,!0),s.removeEventListener("blur",i,!0)}},[e]),u.useEffect(()=>{l!==void 0&&t[l]&&t[l].focus()},[l,t])},zt=u.forwardRef(({children:e,className:t,variant:n="fixed",...o},l)=>{const s=u.useRef(null),a=Ar(s,l);return w7(s),r.jsx("div",{ref:a,role:"toolbar","aria-label":"toolbar","data-variant":n,className:U("tiptap-toolbar",t),...o,children:e})});zt.displayName="Toolbar";const le=u.forwardRef(({children:e,className:t,...n},o)=>r.jsx("div",{ref:o,role:"group",className:U("tiptap-toolbar-group",t),...n,children:e}));le.displayName="ToolbarGroup";const fe=u.forwardRef(({...e},t)=>r.jsx(R,{ref:t,orientation:"vertical",decorative:!0,...e}));fe.displayName="ToolbarSeparator";function v7({shortcutKeys:e}){return r.jsx(X,{children:G({shortcutKeys:e})})}const Oo=u.forwardRef(({editor:e,text:t,direction:n,hideWhenUnavailable:o=!1,onMoved:l,showShortcut:s=!1,onClick:a,children:i,...c},d)=>{const{editor:f}=S(e),{isVisible:h,handleMoveNode:p,canMoveNode:C,label:b,shortcutKeys:g,Icon:w}=T7({editor:f,direction:n,hideWhenUnavailable:o,onMoved:l}),v=u.useCallback(x=>{a?.(x),!x.defaultPrevented&&p()},[p,a]);if(!h)return null;const m=n==="up"?"Move Up":"Move Down";return r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":b,tooltip:m,disabled:!C,onClick:v,...c,ref:d,children:i??r.jsxs(r.Fragment,{children:[r.jsx(w,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t}),s&&r.jsx(v7,{shortcutKeys:g})]})})});Oo.displayName="MoveNodeButton";const m7="mod+shift+ArrowUp",y7="mod+shift+ArrowDown";function Sa(e,t){if(!e||!e.isEditable)return!1;const n=tt(e);if(!n)return!1;try{const{pos:o}=n,l=e.state.doc.resolve(o),s=l.parent,a=l.index();return t==="up"?a>0:a<s.childCount-1}catch{return!1}}function x7(e,t){if(!e||!e.isEditable)return!1;const n=tt(e);if(!n)return!1;try{const{pos:o,node:l}=n,s=e.state.tr,a=s.doc.resolve(o),i=a.parent,c=a.index();if(c<0||c>=i.childCount)return!1;if(t==="up"&&c>0){const f=i.child(c-1).nodeSize,h=l.type.create(l.attrs,l.content,l.marks);s.deleteRange(o,o+l.nodeSize);const p=o-f;s.insert(p,h),s.setSelection(M.TextSelection.near(s.doc.resolve(p)))}else if(t==="down"&&c<i.childCount-1){const f=i.child(c+1).nodeSize,h=l.type.create(l.attrs,l.content,l.marks);s.deleteRange(o,o+l.nodeSize);const p=o+f;s.insert(p,h),s.setSelection(M.TextSelection.near(s.doc.resolve(p)))}else return!1;return e.view.dispatch(s),!0}catch(o){return console.error("Error moving node:",o),!1}}function S7(e){const{editor:t,direction:n,hideWhenUnavailable:o}=e;if(!t)return!1;if(!o)return!0;if(!t.isEditable)return!1;const l=!!tt(t),s=Sa(t,n);return l&&s}function T7(e){const{editor:t,hideWhenUnavailable:n=!1,direction:o,onMoved:l}=e,{editor:s}=S(t),a=ee(),[i,c]=u.useState(!0),[d,f]=u.useState(!1),h=u.useCallback(()=>{if(!d)return!1;const g=x7(s,o);return g&&l?.(o),g},[s,o,l,d]);u.useEffect(()=>{if(!s)return;const g=()=>{c(S7({editor:s,direction:o,hideWhenUnavailable:n})),f(Sa(s,o))};return g(),s.on("selectionUpdate",g),()=>{s.off("selectionUpdate",g)}},[s,o,n]);const p=o==="up"?m7:y7;return ie.useHotkeys(p,g=>{g.preventDefault(),h()},{enabled:i&&d,enableOnContentEditable:!a,enableOnFormTags:!0},[h,i,d,a]),{isVisible:i,handleMoveNode:h,canMoveNode:d,label:o==="up"?"Move Up":"Move Down",shortcutKeys:p,Icon:o==="up"?Dn:Bn}}const Wt={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0},Ta=typeof window>"u",I7=!Ta&&typeof ResizeObserver<"u",_t=()=>!Ta;function M7({element:e,enabled:t=!0,throttleMs:n=100,useResizeObserver:o=!0}={}){const[l,s]=u.useState(Wt),a=u.useCallback(()=>!t||!_t()?null:e?typeof e=="string"?document.querySelector(e):"current"in e?e.current:e:document.body,[e,t]),i=_s(()=>{if(!t||!_t())return;const c=a();if(!c){s(Wt);return}const d=c.getBoundingClientRect();s({x:d.x,y:d.y,width:d.width,height:d.height,top:d.top,right:d.right,bottom:d.bottom,left:d.left})},n,[t,a],{leading:!0,trailing:!0});return u.useEffect(()=>{if(!t||!_t()){s(Wt);return}const c=a();if(!c)return;i();const d=[];if(o&&I7){const h=new ResizeObserver(()=>{window.requestAnimationFrame(i)});h.observe(c),d.push(()=>h.disconnect())}const f=()=>i();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f,!0),d.push(()=>{window.removeEventListener("scroll",f),window.removeEventListener("resize",f)}),()=>{d.forEach(h=>h()),s(Wt)}},[t,a,i,o]),l}function k7(e={}){return M7({...e,element:_t()?document.body:null})}function E7({editor:e,overlayHeight:t=0}){const{height:n}=qs(),o=k7({enabled:!0,throttleMs:100,useResizeObserver:!0});return u.useEffect(()=>{(()=>{if(!e)return;const{state:s,view:a}=e;if(!a.hasFocus())return;const{from:i}=s.selection,c=a.coordsAtPos(i);if(n<o.height&&c&&n-c.top<t){const f=Math.max(n/2,t),h=window.scrollY,C=c.top+h-f;window.scrollTo({top:Math.max(0,C),behavior:"smooth"})}})()},[e,t,n,o.height]),o}function L7({align:e,shortcutKeys:t=Po[e]}){return r.jsx(X,{children:G({shortcutKeys:t})})}const qt=u.forwardRef(({editor:e,align:t,text:n,extensionName:o,attributeName:l="data-align",hideWhenUnavailable:s=!1,onAligned:a,showShortcut:i=!1,onClick:c,children:d,...f},h)=>{const{editor:p}=S(e),{isVisible:C,handleImageAlign:b,label:g,canAlign:w,isActive:v,Icon:m,shortcutKeys:x}=D7({editor:p,align:t,extensionName:o,attributeName:l,hideWhenUnavailable:s,onAligned:a}),y=u.useCallback(T=>{c?.(T),!T.defaultPrevented&&b()},[b,c]);return C?r.jsx(k,{type:"button",disabled:!w,variant:"ghost","data-active-state":v?"on":"off","data-disabled":!w,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":v,tooltip:g,onClick:y,...f,ref:h,children:d??r.jsxs(r.Fragment,{children:[r.jsx(m,{className:"tiptap-button-icon"}),n&&r.jsx("span",{className:"tiptap-button-text",children:n}),i?r.jsx(L7,{align:t,shortcutKeys:x}):null]})}):null});qt.displayName="ImageAlignButton";const Ia=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V22C13 22.5523 12.5523 23 12 23C11.4477 23 11 22.5523 11 22V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),r.jsx("path",{d:"M2 7C2 5.34315 3.34315 4 5 4H7C7.55228 4 8 4.44772 8 5C8 5.55228 7.55228 6 7 6H5C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H7C7.55228 18 8 18.4477 8 19C8 19.5523 7.55228 20 7 20H5C3.34315 20 2 18.6569 2 17V7Z",fill:"currentColor"}),r.jsx("path",{d:"M19 4C20.6569 4 22 5.34315 22 7V17C22 18.6569 20.6569 20 19 20H17C16.4477 20 16 19.5523 16 19C16 18.4477 16.4477 18 17 18H19C19.5523 18 20 17.5523 20 17V7C20 6.44772 19.5523 6 19 6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H19Z",fill:"currentColor"})]}));Ia.displayName="AlignCenterVerticalIcon";const Ma=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 1C21.5523 1 22 1.44772 22 2V22C22 22.5523 21.5523 23 21 23C20.4477 23 20 22.5523 20 22V2C20 1.44772 20.4477 1 21 1Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 7C2 5.34315 3.34315 4 5 4H14C15.6569 4 17 5.34315 17 7V17C17 18.6569 15.6569 20 14 20H5C3.34315 20 2 18.6569 2 17V7ZM5 6C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H14C14.5523 18 15 17.5523 15 17V7C15 6.44772 14.5523 6 14 6H5Z",fill:"currentColor"})]}));Ma.displayName="AlignEndVerticalIcon";const ka=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 2C4 1.44772 3.55228 1 3 1C2.44772 1 2 1.44772 2 2V22C2 22.5523 2.44772 23 3 23C3.55228 23 4 22.5523 4 22V2Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 4C8.34315 4 7 5.34315 7 7V17C7 18.6569 8.34315 20 10 20H19C20.6569 20 22 18.6569 22 17V7C22 5.34315 20.6569 4 19 4H10ZM9 7C9 6.44772 9.44772 6 10 6H19C19.5523 6 20 6.44772 20 7V17C20 17.5523 19.5523 18 19 18H10C9.44772 18 9 17.5523 9 17V7Z",fill:"currentColor"})]}));ka.displayName="AlignStartVerticalIcon";const Po={left:"alt+shift+l",center:"alt+shift+e",right:"alt+shift+r"},A7={left:ka,center:Ia,right:Ma},H7={left:"Image align left",center:"Image align center",right:"Image align right"};function Zo(e,t,n="image",o="data-align"){return!e||!e.isEditable||!V(e,[n])?!1:e.can().updateAttributes(n,{[o]:t})}function N7(e,t,n="image",o="data-align"){return!e||!e.isEditable||!V(e,[n])?!1:(e.getAttributes(n)[o]||"left")===t}function V7(e,t,n="image",o="data-align"){if(!e?.isEditable||!V(e,[n])||!Zo(e,t,n,o))return!1;try{const{selection:l}=e.state,s=l instanceof M.NodeSelection,a=s?l.from:l.$anchor.pos,i=e.chain().focus().updateAttributes(n,{[o]:t}).run();return i&&s&&e.commands.setNodeSelection(a),i}catch{return!1}}function B7(e){const{editor:t,hideWhenUnavailable:n,align:o,extensionName:l="image",attributeName:s="data-align"}=e;return!t||!t.isEditable?!1:n?V(t,[l])?Zo(t,o,l,s):!1:!0}function D7(e){const{editor:t,align:n,extensionName:o="image",attributeName:l="data-align",hideWhenUnavailable:s=!1,onAligned:a}=e,{editor:i}=S(t),c=ee(),[d,f]=u.useState(!0),h=Zo(i,n,o,l),p=N7(i,n,o,l);u.useEffect(()=>{if(!i)return;const b=()=>{f(B7({editor:i,align:n,hideWhenUnavailable:s,extensionName:o,attributeName:l}))};return b(),i.on("selectionUpdate",b),()=>{i.off("selectionUpdate",b)}},[i,s,n,o,l]);const C=u.useCallback(()=>{if(!i)return!1;const b=V7(i,n,o,l);return b&&a?.(),b},[i,n,o,l,a]);return ie.useHotkeys(Po[n],b=>{b.preventDefault(),C()},{enabled:d&&h,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,isActive:p,handleImageAlign:C,canAlign:h,label:H7[n],shortcutKeys:Po[n],Icon:A7[n]}}const Ea=pt.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onSet:o,onClick:l,children:s,...a},i)=>{const{editor:c}=S(e),{isVisible:d,isActive:f,canToggle:h,handleSetCaption:p,label:C,Icon:b}=Z7({editor:c,hideWhenUnavailable:n,onSet:o}),g=pt.useCallback(w=>{l?.(w),!w.defaultPrevented&&p()},[p,l]);return d?r.jsx(k,{type:"button",variant:"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":C,tooltip:C,onClick:g,...a,ref:i,children:s??r.jsxs(r.Fragment,{children:[r.jsx(b,{className:"tiptap-button-icon"}),t&&r.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});Ea.displayName="ImageCaptionButton";const La=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 22C7 21.4477 7.44772 21 8 21H16C16.5523 21 17 21.4477 17 22C17 22.5523 16.5523 23 16 23H8C7.44772 23 7 22.5523 7 22Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 18C3 17.4477 3.44772 17 4 17H20C20.5523 17 21 17.4477 21 18C21 18.5523 20.5523 19 20 19H4C3.44772 19 3 18.5523 3 18Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 5C3 3.34315 4.34315 2 6 2H18C19.6569 2 21 3.34315 21 5V11C21 12.6569 19.6569 14 18 14H6C4.34315 14 3 12.6569 3 11V5ZM6 4C5.44772 4 5 4.44772 5 5V11C5 11.5523 5.44772 12 6 12H18C18.5523 12 19 11.5523 19 11V5C19 4.44772 18.5523 4 18 4H6Z",fill:"currentColor"})]}));La.displayName="ImageCaptionIcon";function Fo(e){return!e||!e.isEditable||!V(e,["image"])?!1:re(e,["image"])}function U7(e){if(!e)return!1;try{const{selection:t}=e.state;if(!(t instanceof M.NodeSelection&&t.node.type.name==="image"))return!1;const o=t.node;return o.attrs.showCaption===!0||o.content.size>0}catch{return!1}}function O7(e){if(!e?.isEditable||!Fo(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof M.NodeSelection&&t.node.type.name==="image")||!e.chain().focus().updateAttributes("image",{showCaption:!0}).run())return!1;const l=t.from;return e.chain().focus(l+1).selectTextblockEnd().run(),!0}catch{return!1}}function P7(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!V(t,["image"])?!1:Fo(t):!0:!1}function Z7(e){const{editor:t,hideWhenUnavailable:n=!1,onSet:o}=e||{},{editor:l}=S(t),[s,a]=u.useState(!0),[i,c]=u.useState(!1),d=Fo(l);u.useEffect(()=>{if(!l)return;const h=()=>{a(P7({editor:l,hideWhenUnavailable:n})),c(U7(l))};return h(),l.on("selectionUpdate",h),()=>{l.off("selectionUpdate",h)}},[l,n]);const f=u.useCallback(()=>{if(!l)return!1;const h=O7(l);return h&&o?.(),h},[l,o]);return{isVisible:s,isActive:i,canToggle:d,handleSetCaption:f,label:"Caption",Icon:La}}const Aa=u.memo(({className:e,...t})=>r.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[r.jsx("path",{d:"M4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41416L5.96091 6.45325C7.58323 4.88786 9.74725 4.00897 12.0018 4.00001C14.1229 4.0005 16.1569 4.8433 17.6568 6.34315C19.1571 7.84344 19.9999 9.87827 19.9999 12C19.9999 12.5523 20.4477 13 20.9999 13C21.5522 13 21.9999 12.5523 21.9999 12C21.9999 9.34784 20.9464 6.8043 19.071 4.92894C17.1956 3.05358 14.6521 2.00001 11.9999 2L11.9962 2.00001C9.22207 2.01045 6.5594 3.0929 4.5649 5.02104L4.55283 5.0329L4 5.58573V3Z",fill:"currentColor"}),r.jsx("path",{d:"M3 11C3.55228 11 4 11.4477 4 12C4 14.1217 4.84285 16.1566 6.34315 17.6569C7.84297 19.1567 9.87701 19.9995 11.998 20C14.2526 19.9911 16.4167 19.1122 18.039 17.5468L18.5858 17H16C15.4477 17 15 16.5523 15 16C15 15.4477 15.4477 15 16 15H21C21.5523 15 22 15.4477 22 16V21C22 21.5523 21.5523 22 21 22C20.4477 22 20 21.5523 20 21V18.4142L19.4471 18.9671L19.435 18.979C17.4405 20.9071 14.7779 21.9896 12.0038 22L12 22C9.34784 22 6.8043 20.9464 4.92893 19.0711C3.05357 17.1957 2 14.6522 2 12C2 11.4477 2.44772 11 3 11Z",fill:"currentColor"})]}));Aa.displayName="RefreshCcwIcon";function Ha({editor:e}){const{editor:t}=S(e),n=re(t,["image"]);return!t||!n?null:r.jsxs(r.Fragment,{children:[r.jsx(qt,{align:"left"}),r.jsx(qt,{align:"center"}),r.jsx(qt,{align:"right"}),r.jsx(R,{}),r.jsx(Ea,{}),r.jsx(R,{}),r.jsx(zl,{}),r.jsx(Ao,{icon:Aa,tooltip:"Replace"}),r.jsx(R,{}),r.jsx(ho,{})]})}const ke={MAIN:"main",HIGHLIGHTER:"highlighter",LINK:"link"};function F7(e){const[t,n]=u.useState(ke.MAIN);return u.useEffect(()=>{!e&&t!==ke.MAIN&&n(ke.MAIN)},[e,t]),{viewId:t,setViewId:n,isMainView:t===ke.MAIN,showMainView:()=>n(ke.MAIN),showView:o=>n(o)}}function $7(e){if(!e||!e.isEditable)return!1;const{selection:t}=e.state;return!t.empty}function z7(){return{[ke.HIGHLIGHTER]:{id:ke.HIGHLIGHTER,title:"Text Highlighter",icon:r.jsx(St,{className:"tiptap-button-icon"}),content:r.jsx(Gs,{}),mobileButton:e=>r.jsx(Lo,{onClick:e}),desktopComponent:r.jsx(Du,{}),shouldShow(e){return De(e)}},[ke.LINK]:{id:ke.LINK,title:"Link Editor",icon:r.jsx(ut,{className:"tiptap-button-icon"}),content:r.jsx($u,{}),mobileButton:e=>r.jsx(Vo,{onClick:e}),desktopComponent:r.jsx(Bo,{}),shouldShow(e){return Do(e)}}}}function W7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(ht,{action:"outdent",hideWhenUnavailable:!0}),r.jsx(ht,{action:"indent",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function _7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(Me,{align:"left",hideWhenUnavailable:!0}),r.jsx(Me,{align:"center",hideWhenUnavailable:!0}),r.jsx(Me,{align:"right",hideWhenUnavailable:!0}),r.jsx(Me,{align:"justify",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function q7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(ue,{type:"superscript",hideWhenUnavailable:!0}),r.jsx(ue,{type:"subscript",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function K7(){return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(ue,{type:"bold",hideWhenUnavailable:!0}),r.jsx(ue,{type:"italic",hideWhenUnavailable:!0}),r.jsx(ue,{type:"strike",hideWhenUnavailable:!0}),r.jsx(ue,{type:"code",hideWhenUnavailable:!0})]}),r.jsx(fe,{})]})}function G7(){const{recentColors:e,isInitialized:t,addRecentColor:n}=dt(),o=()=>!t||e.length===0?null:r.jsxs(r.Fragment,{children:[r.jsxs(Fe,{children:[r.jsx(ft,{children:"Recent colors"}),e.map(l=>r.jsx(de,{asChild:!0,children:l.type==="text"?r.jsx(at,{textColor:l.value,label:l.label,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"text",label:a,value:s})}):r.jsx(Xe,{highlightColor:l.value,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"highlight",label:a,value:s})})},`${l.type}-${l.value}`))]}),r.jsx(R,{orientation:"horizontal"})]});return r.jsxs(ha,{children:[r.jsx(pa,{asChild:!0,children:r.jsxs(k,{variant:"ghost",children:[r.jsx(En,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:"Color"}),r.jsx(st,{}),r.jsx(je,{className:"tiptap-button-icon"})]})}),r.jsx(da,{children:r.jsxs(Ca,{children:[o(),r.jsxs(Fe,{children:[r.jsx(ft,{children:"Text color"}),it.map(l=>r.jsx(de,{asChild:!0,children:r.jsx(at,{textColor:l.value,label:l.label,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"text",label:a,value:s})})},l.value))]}),r.jsx(R,{orientation:"horizontal"}),r.jsxs(Fe,{children:[r.jsx(ft,{children:"Highlight color"}),Be.map(l=>r.jsx(de,{asChild:!0,children:r.jsx(Xe,{highlightColor:l.value,text:l.label,tooltip:l.label,onApplied:({color:s,label:a})=>n({type:"highlight",label:a,value:s})})},l.value))]})]})})]})}function Y7(){return r.jsxs(ha,{children:[r.jsx(pa,{asChild:!0,children:r.jsxs(k,{variant:"ghost",children:[r.jsx(Mo,{className:"tiptap-button-icon"}),r.jsx("span",{className:"tiptap-button-text",children:"Turn into"}),r.jsx(st,{}),r.jsx(je,{className:"tiptap-button-icon"})]})}),r.jsx(da,{children:r.jsx(Ca,{children:r.jsx(ga,{})})})]})}function X7({editor:e}){const t=ee();return r.jsxs(r.Fragment,{children:[r.jsxs(Fe,{children:[r.jsx(ft,{children:kl(e)}),r.jsx(G7,{}),r.jsx(Y7,{}),r.jsx(de,{asChild:!0,children:r.jsx(ps,{text:"Reset formatting"})})]}),r.jsx(R,{orientation:"horizontal"}),r.jsxs(Fe,{children:[r.jsx(de,{asChild:!0,children:r.jsx(jl,{text:"Duplicate node",showShortcut:!t})}),r.jsx(de,{asChild:!0,children:r.jsx(es,{text:"Copy to clipboard",showShortcut:!t})}),r.jsx(de,{asChild:!0,children:r.jsx(cs,{text:"Copy anchor link",showShortcut:!t})})]}),r.jsx(Fe,{children:r.jsx(de,{asChild:!0,children:r.jsx(ho,{text:"Delete",showShortcut:!t})})})]})}function j7({editor:e}){return r.jsxs(ca,{children:[r.jsx(ua,{asChild:!0,children:r.jsx(k,{variant:"ghost","data-appearance":"subdued",children:r.jsx(wt,{className:"tiptap-button-icon"})})}),r.jsx(fa,{children:r.jsx(X7,{editor:e})})]})}function Q7({view:e,isMobile:t,onViewChange:n}){const o=e.id;return t?e.mobileButton?u.cloneElement(e.mobileButton(()=>n(o)),{key:e.id}):r.jsx(k,{onClick:()=>n(o),children:e.icon},e.id):e.desktopComponent?u.cloneElement(e.desktopComponent,{key:e.id}):null}function J7({toolbarViews:e,isMobile:t,onViewChange:n,editor:o}){const l=Object.values(e).filter(s=>s.shouldShow?s.shouldShow(o):!0);return l.length===0?null:r.jsxs(r.Fragment,{children:[l.map(s=>r.jsx(Q7,{view:s,isMobile:t,onViewChange:n},s.id)),r.jsx(fe,{})]})}function R7({editor:e,isMobile:t,toolbarViews:n,onViewChange:o}){const l=$7(e),s=(e?.getText().length??0)>0;return r.jsxs(r.Fragment,{children:[r.jsxs(le,{children:[r.jsx(xo,{}),r.jsx(j7,{editor:e}),r.jsx(fe,{})]}),(l||s)&&r.jsxs(r.Fragment,{children:[r.jsx(K7,{}),r.jsx(J7,{toolbarViews:n,isMobile:t,onViewChange:o,editor:e}),r.jsx(Ha,{}),r.jsx(q7,{}),r.jsx(_7,{}),r.jsx(W7,{}),r.jsxs(le,{children:[r.jsx(Ao,{text:"Add"}),r.jsx(fe,{})]})]}),r.jsxs(le,{children:[r.jsx(Oo,{direction:"down"}),r.jsx(Oo,{direction:"up"})]})]})}function e4({view:e,onBack:t}){return r.jsxs(r.Fragment,{children:[r.jsx(le,{children:r.jsxs(k,{variant:"ghost",onClick:t,children:[r.jsx(Cn,{className:"tiptap-button-icon"}),e.icon]})}),r.jsx(fe,{}),e.content]})}function t4({editor:e}){const{editor:t}=S(e),n=ee("max",480),o=u.useRef(null),l=F7(n),s=u.useMemo(()=>z7(),[]),a=l.isMainView?null:s[l.viewId],{height:i}=qs(),c=E7({editor:t,overlayHeight:o.current?.getBoundingClientRect().height??0});return!n||!t||!t.isEditable?null:r.jsx(zt,{ref:o,style:{...n?{bottom:`calc(100% - ${i-c.y}px)`}:{}},children:l.isMainView?r.jsx(R7,{editor:t,isMobile:n,toolbarViews:s,onViewChange:l.showView}):a&&r.jsx(e4,{view:a,onBack:l.showMainView})})}const Na=u.forwardRef(({editor:e,shouldShow:t=void 0,floatingOptions:n,zIndex:o=50,onOpenChange:l,referenceElement:s,getBoundingClientRect:a=F2,closeOnEscape:i=!0,resetTextSelectionOnClose:c=!0,children:d,style:f,...h},p)=>{const[C,b]=u.useState(t!==void 0?t:!1),g=u.useRef(null),w=u.useRef(!1),v=u.useRef(!1),m=u.useRef(null),x=u.useRef(a),{editor:y}=S(e);u.useEffect(()=>{m.current=y,x.current=a},[y,a]);const T=u.useCallback(Z=>{l?.(Z),b(Z)},[l]),E=Z=>{if(!Z&&y&&c){const A=y.state.tr.setSelection(M.Selection.near(y.state.doc.resolve(0)));y.view.dispatch(A)}T(Z)},L=u.useMemo(()=>s||(()=>m.current?x.current(m.current):null),[s]),{isMounted:N,ref:te,style:O,getFloatingProps:_}=Il(C,L,o,{placement:"top",middleware:[D.shift(),D.flip(),D.offset(4)],onOpenChange:E,dismissOptions:{enabled:!0,escapeKey:!0,outsidePress(Z){const A=Z.target;return!A||Ba(A)?!1:!Va(y,A)}},...n}),$=u.useCallback(()=>{if(!y)return;const Z=a(y);if(Z&&t!==void 0&&!v.current){T(t);return}const A=El(y);Z&&!v.current&&(A||w.current)?T(!0):!w.current&&(!A||v.current||!y.isEditable)&&T(!1)},[y,a,T,t]);u.useEffect(()=>{if(!y||!i)return;const Z=A=>A.key==="Escape"&&C?(T(!1),!0):!1;return y.view.dom.addEventListener("keydown",Z),()=>{y.view.dom.removeEventListener("keydown",Z)}},[y,C,i,T]),u.useEffect(()=>{if(!y)return;const Z=A=>{if(w.current){w.current=!1;return}const F=A.relatedTarget;if(!F)return;const q=Va(y,F),ne=g.current,pe=ne&&(ne===F||ne.contains(F)),B=Ba(F);!q&&!pe&&!B&&C&&T(!1)};return y.view.dom.addEventListener("blur",Z),()=>{y.view.dom.removeEventListener("blur",Z)}},[y,T,C]),u.useEffect(()=>{if(!y)return;const Z=()=>{C&&T(!1)};return y.view.dom.addEventListener("dragstart",Z),y.view.dom.addEventListener("dragover",Z),()=>{y.view.dom.removeEventListener("dragstart",Z),y.view.dom.removeEventListener("dragover",Z)}},[y,C,T]),u.useEffect(()=>{if(!y)return;const Z=F=>{if(F.button!==0||(v.current=!0,F.detail>1))return;const{state:q,view:ne}=y,pe=ne.posAtCoords({left:F.clientX,top:F.clientY});if(!pe||!K(pe.pos))return;const j=q.doc.resolve(pe.pos).nodeBefore;if(!j||j.isBlock)return;const Ee=q.tr.setSelection(M.Selection.near(q.doc.resolve(pe.pos)));ne.dispatch(Ee)},A=()=>{v.current&&(v.current=!1,$())};return y.view.dom.addEventListener("mousedown",Z),y.view.root.addEventListener("mouseup",A),()=>{y.view.dom.removeEventListener("mousedown",Z),y.view.root.removeEventListener("mouseup",A)}},[y,$]),u.useEffect(()=>{if(y)return y.on("selectionUpdate",$),()=>{y.off("selectionUpdate",$)}},[y,$]),u.useEffect(()=>{y&&$()},[y,$]);const z=u.useMemo(()=>f&&Object.keys(f).length>0?f:O,[f,O]),oe=D.useMergeRefs([te,p,g]);return!y||!N||!C?null:r.jsx("div",{ref:oe,style:z,...h,..._(),children:d})});Na.displayName="FloatingElement";const Va=(e,t)=>{if(!t||!e)return!1;const n=e.view.dom.parentElement,o=e.view.dom;return n?n===t||o===t||n.contains(t):!1},Ba=e=>e instanceof HTMLElement?e.closest(["[data-radix-popper-content-wrapper]","[data-base-ui-portal]"].join(","))!==null:!1;function n4(){const{editor:e}=S(),t=ee("max",480),{lockDragHandle:n,commentInputVisible:o}=Xt(e),{shouldShow:l}=wi({editor:e,isSelectionValid:El,extraHideWhen:!!o});return n||t?null:r.jsx(Na,{shouldShow:l,children:r.jsxs(zt,{variant:"floating",children:[r.jsx(le,{children:r.jsx(ba,{hideWhenUnavailable:!0})}),r.jsx(fe,{}),r.jsxs(le,{children:[r.jsx(ue,{type:"bold",hideWhenUnavailable:!0}),r.jsx(ue,{type:"italic",hideWhenUnavailable:!0}),r.jsx(ue,{type:"underline",hideWhenUnavailable:!0}),r.jsx(ue,{type:"strike",hideWhenUnavailable:!0}),r.jsx(ue,{type:"code",hideWhenUnavailable:!0})]}),r.jsx(fe,{}),r.jsx(le,{children:r.jsx(Ha,{})}),r.jsxs(le,{children:[r.jsx(Bo,{autoOpenOnLinkActive:!1,hideWhenUnavailable:!0}),r.jsx(Qc,{hideWhenUnavailable:!0})]}),r.jsx(l4,{hideWhenUnavailable:!0})]})})}function o4(e){if(!e)return!1;const t=["left","center","right","justify"].some(o=>Ft(e,o));return["superscript","subscript"].some(o=>Zt(e,o))||t}function r4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n&&!t.isActive("code")?o4(t):!!t?.isEditable:!1}function l4({editor:e,hideWhenUnavailable:t=!1,...n}){const{editor:o}=S(e),[l,s]=u.useState(!1);return u.useEffect(()=>{if(!o)return;const a=()=>{s(r4({editor:o,hideWhenUnavailable:t}))};return a(),o.on("selectionUpdate",a),()=>{o.off("selectionUpdate",a)}},[o,t]),!l||!o||!o.isEditable?null:r.jsxs(r.Fragment,{children:[r.jsx(fe,{}),r.jsx(le,{children:r.jsxs(Mt,{children:[r.jsx(kt,{asChild:!0,children:r.jsx(k,{type:"button",variant:"ghost",role:"button",tabIndex:-1,tooltip:"More options",...n,children:r.jsx(wt,{className:"tiptap-button-icon"})})}),r.jsx(Et,{side:"top",align:"end",alignOffset:4,sideOffset:4,asChild:!0,children:r.jsxs(zt,{variant:"floating",tabIndex:0,children:[r.jsxs(le,{children:[r.jsx(ue,{type:"superscript"}),r.jsx(ue,{type:"subscript"})]}),r.jsx(fe,{}),r.jsxs(le,{children:[r.jsx(Me,{align:"left"}),r.jsx(Me,{align:"center"}),r.jsx(Me,{align:"right"}),r.jsx(Me,{align:"justify"})]}),r.jsx(fe,{}),r.jsxs(le,{children:[r.jsx(ht,{action:"outdent"}),r.jsx(ht,{action:"indent"})]})]})})]})})]})}function s4({className:e,maxShowCount:t=20,topOffset:n=0,...o}){const{tocContent:l,navigateToHeading:s,normalizeHeadingDepths:a}=nn(),i=u.useRef(!1),c=u.useRef(null),[d,f]=u.useState(null),h=u.useMemo(()=>l??[],[l]),p=u.useMemo(()=>h.slice(0,t),[h,t]),C=u.useMemo(()=>a(p),[p,a]),b=u.useMemo(()=>{const E=new Map;return p.forEach((L,N)=>{E.set(L.id,C[N]??1)}),E},[p,C]),g=u.useMemo(()=>[...h].reverse().find(E=>E.isActive)??null,[h]),w=u.useMemo(()=>h.find(E=>E.isActive)?.id??null,[h]),v=u.useMemo(()=>d||(g?.id?g.id:w||h[0]?.id),[d,g,w,h]),m=u.useCallback((E,L)=>{E.preventDefault(),E.stopPropagation(),f(L.id),c.current=Date.now(),s(L,{topOffset:n})},[s,n]);u.useEffect(()=>{if(typeof window>"u"||i.current||!h.length)return;const E=window.location.hash.replace(/^#/,"");if(!E)return;const L=h.find(N=>N.id===E);L&&(f(L.id),i.current=!0)},[h]);const x=u.useRef(null),y=u.useRef(d);y.current=d,u.useEffect(()=>{if(typeof window>"u")return;const E=()=>{const N=Date.now(),te=c.current;te&&N-te<500||y.current!==null&&f(null)},L=x.current?nr(x.current):null;return window.addEventListener("scroll",E,{passive:!0}),L&&!(L instanceof Window)&&L.addEventListener("scroll",E,{passive:!0}),()=>{window.removeEventListener("scroll",E),L&&!(L instanceof Window)&&L.removeEventListener("scroll",E)}},[]);const T=h.length>0;return r.jsx("div",{ref:x,className:U("toc-sidebar",e),...o,children:r.jsx("div",{className:"toc-sidebar-wrapper",children:r.jsxs("div",{className:"toc-sidebar-inner",children:[r.jsx("div",{className:"toc-sidebar-progress",children:p.map(E=>{const L=b.get(E.id)??1,N=v===E.id;return r.jsx("div",{className:U("toc-sidebar-progress-line",N&&"toc-sidebar-progress-line--active"),"data-depth":L,style:{"--toc-depth":L}},E.id)})}),r.jsx("nav",{className:U("toc-sidebar-nav",!T&&"toc-sidebar-nav--hidden"),"aria-label":"Table of contents",children:r.jsx("div",{className:"toc-sidebar-popover",children:p.map(E=>{const L=b.get(E.id)??1,N=v===E.id;return r.jsx("a",{href:`#${E.id}`,rel:"noopener noreferrer",className:U("toc-sidebar-item notranslate",N&&"toc-sidebar-item--active"),"data-depth":L,style:{"--toc-depth":L},onClick:te=>m(te,E),"aria-current":N?"location":void 0,children:E.textContent},E.id)})})})]})})})}const a4=be.Extension.create({name:"listNormalization",addKeyboardShortcuts(){const e=["bulletList","orderedList","taskList"];return{Backspace:({editor:n})=>{const{state:o,view:l}=n,{selection:s}=o,{$from:a,empty:i}=s;if(!i||a.parentOffset!==0)return!1;const c=a.parent;if(c.type.name!=="paragraph"||c.content.size>0)return!1;const d=a.depth-1;if(d<0)return!1;const f=a.node(d),h=a.index(d);if(h===0||h>=f.childCount-1)return!1;const p=f.child(h-1),C=f.child(h+1),b=e.includes(p.type.name),g=e.includes(C.type.name);if(!b||!g||p.type.name!==C.type.name)return!1;const w=a.before(d+1),v=a.after(d+1),m=o.doc.resolve(w-1),x=M.TextSelection.findFrom(m,-1,!0);if(!x)return!1;const y=x.from,T=o.tr;T.delete(w,v),Ko.canJoin(T.doc,w)&&T.join(w);const E=T.mapping.map(y);return T.setSelection(M.TextSelection.create(T.doc,E)),l.dispatch(T),!0}}}});function i4(e,t,n,o){const l=e.getAttribute("data-indent");if(l){const a=parseInt(l,10);if(!isNaN(a))return en(a,t,n)}const s=["marginLeft","paddingLeft","textIndent"];for(const a of s){const i=e.style?.[a];if(i){const c=parseFloat(i);if(!isNaN(c)&&c>0&&o>0){const d=Math.round(c/o);return en(d,t,n)}}}return 0}function Kt(e,t){const{$from:n}=e.selection;for(let o=n.depth;o>0;o--){const l=n.node(o).type.name;if(t.has(l))return l}return null}function Da(e,t,n,o){const{selection:l}=e,{$from:s}=l;if(!l.empty||Kt(e,n)!==null)return!1;const a=s.parent;return!t.includes(a.type.name)||a.attrs.indent<=0?!1:o.onlyIfEmpty?a.content.size===0:s.parentOffset===0}const c4=new M.PluginKey("indent"),d4=be.Extension.create({name:"indent",addOptions(){return{types:["paragraph","heading","blockquote"],listItemTypes:["listItem","taskItem"],bypassAncestors:["tableCell","tableHeader"],minLevel:0,maxLevel:8,useStyle:!1,indentUnit:24}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>i4(e,this.options.minLevel,this.options.maxLevel,this.options.indentUnit),renderHTML:e=>{const t=Number(e.indent)||0;if(t===0)return{};const n={"data-indent":String(t),style:`--tt-indent-level: ${t}`};return this.options.useStyle&&this.options.indentUnit>0&&(n.style=`--tt-indent-level: ${t}; margin-left: ${t*this.options.indentUnit}px`),n}}}}]},addCommands(){const e=new Set(this.options.listItemTypes),t=({state:n,tr:o},l)=>{const s=Re(n.selection,this.options.types);return s.length===0?!1:Rt(o,s,"indent",a=>en(l(Number(a)||0),this.options.minLevel,this.options.maxLevel))};return{indent:()=>n=>{const o=Kt(n.state,e);return o&&"sinkListItem"in n.commands?n.commands.sinkListItem(o):t(n,l=>l+1)},outdent:()=>n=>{const o=Kt(n.state,e);return o&&"liftListItem"in n.commands?n.commands.liftListItem(o):t(n,l=>l-1)},setIndent:n=>o=>t(o,()=>n),unsetIndent:()=>n=>t(n,()=>0)}},addProseMirrorPlugins(){const e=this.options.types;return[new M.Plugin({key:c4,appendTransaction(t,n,o){if(!t.some(v=>v.getMeta("uiEvent")==="drop"))return null;const{doc:s,selection:a}=o,{$from:i,$to:c}=a,d=i.depth>0?i.depth:1,f=i.before(d),h=s.resolve(f),p=h.node(h.depth),C=h.index(h.depth);let b=0;if(C>0)b=p.child(C-1).attrs.indent||0;else{const v=c.depth>0?c.depth:1,m=c.after(v),x=s.resolve(m),y=x.indexAfter(x.depth),T=x.node(x.depth);y<T.childCount&&(b=T.child(y).attrs.indent||0)}const{tr:g}=o;let w=!1;return s.nodesBetween(i.pos,c.pos,(v,m)=>(!e.includes(v.type.name)||(v.attrs.indent||0)===b||(g.setNodeMarkup(m,void 0,{...v.attrs,indent:b},v.marks),w=!0),!1)),w?g:null}})]},addKeyboardShortcuts(){const e=new Set(this.options.listItemTypes),t=new Set(this.options.bypassAncestors),n=l=>{if(t.size===0)return!1;const{$from:s}=l.selection;for(let a=s.depth;a>0;a--)if(t.has(s.node(a).type.name))return!0;return!1},o=()=>{const l=this.editor.state;if(n(l))return!1;if(Kt(l,e)!==null)return!0;const{$from:s}=l.selection;return this.options.types.includes(s.parent.type.name)};return{Tab:()=>o()?(this.editor.commands.indent(),!0):!1,"Shift-Tab":()=>o()?(this.editor.commands.outdent(),!0):!1,Enter:({editor:l})=>Da(l.state,this.options.types,e,{onlyIfEmpty:!0})?l.commands.outdent():!1,Backspace:({editor:l})=>Da(l.state,this.options.types,e,{onlyIfEmpty:!1})?l.commands.outdent():!1}}}),u4=be.Extension.create({name:"tripleClickBlockSelection",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tripleClickBlockSelection"),props:{handleTripleClick:(e,t)=>{const{state:n}=e,{doc:o}=n,l=o.resolve(t);let s=l.depth;for(;s>0&&!l.node(s).isTextblock;)s--;if(s===0||l.node(s).type.spec.selectable===!1)return!1;const i=l.before(s);return e.dispatch(n.tr.setSelection(M.NodeSelection.create(o,i))),!0}}})]}}),f4={type:"doc",content:[{type:"heading",attrs:{id:"11111111-1111-4111-8111-111111111111",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"11111111-1111-4111-8111-111111111111",level:1},content:[{type:"text",text:"Local Omnibox editor"}]},{type:"blockquote",attrs:{id:"22222222-2222-4222-8222-222222222222",backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"paragraph",attrs:{id:"33333333-3333-4333-8333-333333333333",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",marks:[{type:"bold"}],text:"A clean base for your own editor package."},{type:"hardBreak"},{type:"text",text:"It keeps the writing, formatting, slash menu, table, and block editing pieces ready for your package work."}]}]},{type:"paragraph",attrs:{id:"44444444-4444-4444-8444-444444444444",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Type "},{type:"text",marks:[{type:"code"}],text:"/"},{type:"text",text:" to open the command menu, select text for the floating toolbar, or drag blocks from the left handle."}]},{type:"heading",attrs:{id:"55555555-5555-4555-8555-555555555555",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"55555555-5555-4555-8555-555555555555",level:2},content:[{type:"text",text:"Writing basics"}]},{type:"codeBlock",attrs:{id:"66666666-6666-4666-8666-666666666666",language:null},content:[{type:"text",text:`# Headings
6
6
  - Lists
7
7
  > Quotes
8
- \`Inline code\``}]},{type:"bulletList",attrs:{id:"77777777-7777-4777-8777-777777777777",backgroundColor:null},content:[{type:"listItem",content:[{type:"paragraph",attrs:{id:"88888888-8888-4888-8888-888888888888",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Format text with bold, italic, links, colors, and highlights."}]}]},{type:"listItem",content:[{type:"paragraph",attrs:{id:"99999999-9999-4999-8999-999999999999",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Use local undo and redo from the header toolbar."}]}]}]},{type:"heading",attrs:{id:"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",level:2},content:[{type:"text",text:"Checklist"}]},{type:"taskList",attrs:{id:"bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",backgroundColor:null},content:[{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"cccccccc-cccc-4ccc-8ccc-cccccccccccc",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Start from the official Tiptap template"}]}]},{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"dddddddd-dddd-4ddd-8ddd-dddddddddddd",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Trim optional product features from the base template"}]}]},{type:"taskItem",attrs:{checked:!1},content:[{type:"paragraph",attrs:{id:"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Extract the editor into a reusable package"}]}]}]},{type:"heading",attrs:{id:"ffffffff-ffff-4fff-8fff-ffffffffffff",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"ffffffff-ffff-4fff-8fff-ffffffffffff",level:2},content:[{type:"text",text:"Simple table"}]},{type:"table",attrs:{id:"12121212-1212-4121-8121-121212121212"},content:[{type:"tableRow",content:[{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"13131313-1313-4131-8131-131313131313",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Area"}]}]},{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"14141414-1414-4141-8141-141414141414",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Status"}]}]}]},{type:"tableRow",content:[{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"15151515-1515-4151-8151-151515151515",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Local editing"}]}]},{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"16161616-1616-4161-8161-161616161616",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Ready"}]}]}]}]},{type:"heading",attrs:{id:"17171717-1717-4171-8171-171717171717",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"17171717-1717-4171-8171-171717171717",level:2},content:[{type:"text",text:"Table of contents"}]},{type:"tocNode",attrs:{id:"18181818-1818-4181-8181-181818181818",backgroundColor:null,topOffset:null,maxShowCount:null,showTitle:!0}}]};function r4({text:e="Connecting..."}){return r.jsx("div",{className:"omnibox-editor-loading",children:r.jsxs("div",{className:"omnibox-editor-loading__content",children:[r.jsxs("svg",{className:"omnibox-editor-loading__spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"omnibox-editor-loading__spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"omnibox-editor-loading__spinner-path",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),r.jsx("div",{className:"omnibox-editor-loading__text",children:e})]})})}function l4(){const{editor:e}=u.useContext(P.EditorContext),{isDragging:t}=Gt(e);return Ci(),u.useEffect(()=>{if(!e)return;const n=o=>{e.storage.uiState?.isDragging&&o.stopPropagation()};return document.addEventListener("dragenter",n),document.addEventListener("dragover",n),document.addEventListener("dragleave",n),document.addEventListener("drop",n),()=>{document.removeEventListener("dragenter",n),document.removeEventListener("dragover",n),document.removeEventListener("dragleave",n),document.removeEventListener("drop",n)}},[e]),e?r.jsxs(P.EditorContent,{editor:e,role:"presentation",className:"omnibox-editor-content",style:{cursor:t?"grabbing":"auto"},children:[r.jsx(Cu,{}),r.jsx(U2,{}),r.jsx($2,{}),r.jsx(ld,{}),r.jsx(G7,{}),Ba.createPortal(r.jsx(K7,{}),document.body)]}):null}function Na(e,t){return t??e}function s4(e){return typeof e=="number"?`${e}px`:e}function a4(e){const{editable:t=!0,placeholder:n="Start writing...",content:o=o4,onUpdate:l,imageUpload:s=di,imageUploadMaxSize:a=Yt,imageUploadLimit:i=3,onImageUploadError:c=y=>console.error("Upload failed:",y),onImageUploadSuccess:d,contentWidth:f,variant:h="page",showHeader:p,showToc:C}=e,{setTocContent:b}=en(),g=h==="embedded",w=Na(!g,p),v=Na(!g,C),m=s4(f),x=P.useEditor({immediatelyRender:!1,content:o,editable:t,onUpdate:({editor:y})=>{l?.({editor:y,json:y.getJSON(),html:y.getHTML()})},editorProps:{attributes:{class:"omnibox-editor"}},extensions:[Da.StarterKit.configure({codeBlock:!1,horizontalRule:!1,dropcursor:{width:2},link:{openOnClick:!1}}),gi,Pi,$a.TextAlign.configure({types:["heading","paragraph"]}),$o.Placeholder.configure({placeholder:n,emptyNodeClass:"is-empty with-slash"}),Ua.Mention,zo.Emoji.configure({emojis:zo.gitHubEmojis.filter(y=>!y.name.includes("regional")),forceFallbackImages:!0}),i1.configure({table:{resizable:!0,cellMinWidth:120}}),xi.configure({types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader","tocNode"]}),Si,Fo.TextStyle,za.Mathematics,Za.Superscript,Fa.Subscript,t4,Fo.Color,Zo.TaskList,Zo.TaskItem.configure({nested:!0}),Pa.Highlight.configure({multicolor:!0}),$o.Selection,mi,Wo.TableOfContents.configure({getIndex:Wo.getHierarchicalIndexes,onUpdate(y){b(y)}}),x1,J7,n4,Yi.configure({accept:"image/*",maxSize:a,limit:i,upload:s,onError:c,onSuccess:d}),Wa.UniqueID.configure({types:["table","paragraph","bulletList","orderedList","taskList","heading","blockquote","codeBlock","tocNode"]}),Oa.Typography,oi,Li.configure({topOffset:48})]});return x?r.jsx("div",{"data-variant":h,style:m?{"--omnibox-editor-content-width":m}:void 0,className:U("omnibox-editor-root omnibox-editor-wrapper",g?"omnibox-editor-wrapper--embedded":"omnibox-editor-wrapper--page"),children:r.jsxs(P.EditorContext.Provider,{value:{editor:x},children:[w?r.jsx(Su,{}):null,r.jsxs("div",{className:U("omnibox-editor-layout",g&&"omnibox-editor-layout--embedded"),children:[r.jsx(l4,{}),v?r.jsx(Q7,{topOffset:48}):null]}),r.jsx(k2,{}),r.jsx(hl,{}),r.jsx(p2,{showResizeHandles:!0,cellMenu:y=>r.jsx(bl,{editor:y.editor,onMouseDown:T=>y.onResizeStart?.("br")(T)})})]})}):r.jsx(r4,{})}function Va({editable:e=!0,placeholder:t="Start writing...",content:n,contentWidth:o,variant:l,showHeader:s,showToc:a,onUpdate:i,imageUpload:c,imageUploadMaxSize:d,imageUploadLimit:f,onImageUploadError:h,onImageUploadSuccess:p}){return r.jsx(ki,{children:r.jsx(a4,{editable:e,placeholder:t,content:n,contentWidth:o,variant:l,showHeader:s,showToc:a,onUpdate:i,imageUpload:c,imageUploadMaxSize:d,imageUploadLimit:f,onImageUploadError:h,onImageUploadSuccess:p})})}H.CvnertEditor=Va,H.OmniboxEditor=Va,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
8
+ \`Inline code\``}]},{type:"bulletList",attrs:{id:"77777777-7777-4777-8777-777777777777",backgroundColor:null},content:[{type:"listItem",content:[{type:"paragraph",attrs:{id:"88888888-8888-4888-8888-888888888888",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Format text with bold, italic, links, colors, and highlights."}]}]},{type:"listItem",content:[{type:"paragraph",attrs:{id:"99999999-9999-4999-8999-999999999999",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Use local undo and redo from the header toolbar."}]}]}]},{type:"heading",attrs:{id:"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",level:2},content:[{type:"text",text:"Checklist"}]},{type:"taskList",attrs:{id:"bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",backgroundColor:null},content:[{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"cccccccc-cccc-4ccc-8ccc-cccccccccccc",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Start from the official Tiptap template"}]}]},{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"dddddddd-dddd-4ddd-8ddd-dddddddddddd",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Trim optional product features from the base template"}]}]},{type:"taskItem",attrs:{checked:!1},content:[{type:"paragraph",attrs:{id:"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Extract the editor into a reusable package"}]}]}]},{type:"heading",attrs:{id:"ffffffff-ffff-4fff-8fff-ffffffffffff",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"ffffffff-ffff-4fff-8fff-ffffffffffff",level:2},content:[{type:"text",text:"Simple table"}]},{type:"table",attrs:{id:"12121212-1212-4121-8121-121212121212"},content:[{type:"tableRow",content:[{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"13131313-1313-4131-8131-131313131313",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Area"}]}]},{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"14141414-1414-4141-8141-141414141414",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Status"}]}]}]},{type:"tableRow",content:[{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"15151515-1515-4151-8151-151515151515",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Local editing"}]}]},{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"16161616-1616-4161-8161-161616161616",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Ready"}]}]}]}]},{type:"heading",attrs:{id:"17171717-1717-4171-8171-171717171717",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"17171717-1717-4171-8171-171717171717",level:2},content:[{type:"text",text:"Table of contents"}]},{type:"tocNode",attrs:{id:"18181818-1818-4181-8181-181818181818",backgroundColor:null,topOffset:null,maxShowCount:null,showTitle:!0}}]};function h4({text:e="Connecting..."}){return r.jsx("div",{className:"omnibox-editor-loading",children:r.jsxs("div",{className:"omnibox-editor-loading__content",children:[r.jsxs("svg",{className:"omnibox-editor-loading__spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"omnibox-editor-loading__spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"omnibox-editor-loading__spinner-path",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),r.jsx("div",{className:"omnibox-editor-loading__text",children:e})]})})}function p4(){const{editor:e}=u.useContext(P.EditorContext),{isDragging:t}=Xt(e);return vi(),u.useEffect(()=>{if(!e)return;const n=o=>{e.storage.uiState?.isDragging&&o.stopPropagation()};return document.addEventListener("dragenter",n),document.addEventListener("dragover",n),document.addEventListener("dragleave",n),document.addEventListener("drop",n),()=>{document.removeEventListener("dragenter",n),document.removeEventListener("dragover",n),document.removeEventListener("dragleave",n),document.removeEventListener("drop",n)}},[e]),e?r.jsxs(P.EditorContent,{editor:e,role:"presentation",className:"omnibox-editor-content",style:{cursor:t?"grabbing":"auto"},children:[r.jsx(Tu,{}),r.jsx(q2,{}),r.jsx(j2,{}),r.jsx(pd,{}),r.jsx(n4,{}),Pa.createPortal(r.jsx(t4,{}),document.body)]}):null}function Ua(e,t){return t??e}function C4(e){return typeof e=="number"?`${e}px`:e}function g4(e){const{editable:t=!0,placeholder:n="Start writing...",content:o=f4,onUpdate:l,imageUpload:s=pi,imageUploadMaxSize:a=jt,imageUploadLimit:i=3,onImageUploadError:c=y=>console.error("Upload failed:",y),onImageUploadSuccess:d,contentWidth:f,variant:h="page",showHeader:p,showToc:C}=e,{setTocContent:b}=nn(),g=h==="embedded",w=Ua(!g,p),v=Ua(!g,C),m=C4(f),x=P.useEditor({immediatelyRender:!1,content:o,editable:t,onUpdate:({editor:y})=>{l?.({editor:y,json:y.getJSON(),html:y.getHTML()})},editorProps:{attributes:{class:"omnibox-editor"}},extensions:[Za.StarterKit.configure({codeBlock:!1,horizontalRule:!1,dropcursor:{width:2},link:{openOnClick:!1}}),mi,Gi,qa.TextAlign.configure({types:["heading","paragraph"]}),Wo.Placeholder.configure({placeholder:n,emptyNodeClass:"is-empty with-slash"}),Fa.Mention,_o.Emoji.configure({emojis:_o.gitHubEmojis.filter(y=>!y.name.includes("regional")),forceFallbackImages:!0}),b1.configure({table:{resizable:!0,cellMinWidth:120}}),Mi.configure({types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader","tocNode"]}),ki,zo.TextStyle,Ka.Mathematics,Wa.Superscript,_a.Subscript,d4,zo.Color,$o.TaskList,$o.TaskItem.configure({nested:!0}),za.Highlight.configure({multicolor:!0}),Wo.Selection,Ti,qo.TableOfContents.configure({getIndex:qo.getHierarchicalIndexes,onUpdate(y){b(y)}}),H1,a4,u4,o1.configure({accept:"image/*",maxSize:a,limit:i,upload:s,onError:c,onSuccess:d}),Ga.UniqueID.configure({types:["table","paragraph","bulletList","orderedList","taskList","heading","blockquote","codeBlock","tocNode"]}),$a.Typography,ai,Vi.configure({topOffset:48})]});return x?r.jsx("div",{"data-variant":h,style:m?{"--omnibox-editor-content-width":m}:void 0,className:U("omnibox-editor-root omnibox-editor-wrapper",g?"omnibox-editor-wrapper--embedded":"omnibox-editor-wrapper--page"),children:r.jsxs(P.EditorContext.Provider,{value:{editor:x},children:[w?r.jsx(Nu,{}):null,r.jsxs("div",{className:U("omnibox-editor-layout",g&&"omnibox-editor-layout--embedded"),children:[r.jsx(p4,{}),v?r.jsx(s4,{topOffset:48}):null]}),r.jsx(U2,{}),r.jsx(bl,{}),r.jsx(S2,{showResizeHandles:!0,cellMenu:y=>r.jsx(yl,{editor:y.editor,onMouseDown:T=>y.onResizeStart?.("br")(T)})})]})}):r.jsx(h4,{})}function Oa({editable:e=!0,placeholder:t="Start writing...",content:n,contentWidth:o,variant:l,showHeader:s,showToc:a,onUpdate:i,imageUpload:c,imageUploadMaxSize:d,imageUploadLimit:f,onImageUploadError:h,onImageUploadSuccess:p}){return r.jsx(Hi,{children:r.jsx(g4,{editable:e,placeholder:t,content:n,contentWidth:o,variant:l,showHeader:s,showToc:a,onUpdate:i,imageUpload:c,imageUploadMaxSize:d,imageUploadLimit:f,onImageUploadError:h,onImageUploadSuccess:p})})}H.CvnertEditor=Oa,H.OmniboxEditor=Oa,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));