showai-reader 0.9.0-reader.pjpbghtw → 0.9.0-reader.q4iwifrc

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.
@@ -95,11 +95,11 @@ img.ProseMirror-separator {
95
95
  display: block;
96
96
  }`,xa=class extends gw{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Wk,createMappablePosition:_k},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let n=aa(e,this.options.autofocus);this.editorState=gn.create({doc:e,schema:this.schema,selection:n||void 0})}Zw(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():ir.createFakeChain()}can(){return this.commandManager?this.commandManager.can():ir.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Nw(tS,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return $h&&!this.hasWarnedStaleDecorationRead&&mw(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=ua(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let n=[...this.options.enableCoreExtensions?[Uw,Ww.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),_w,Jw,Gw,Yw.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),Kw,Xw,jw,Qw.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new mi(n,this)}createCommandManager(){this.commandManager=new ir({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=ca(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;let n=ca(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=gn.create({doc:n,schema:this.schema,selection:aa(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}getEditorViewAttributes(){var t;let e=(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes;return ua(e)?n=>({role:"textbox",...e(n)}):{role:"textbox",...e}}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new jr(t,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return ya(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Vk(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ga(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=`
97
97
 
98
- `,textSerializers:n={}}=t||{};return zk(this.state.doc,{blockSeparator:e,textSerializers:{...Nh(this.schema),...n}})}get isEmpty(){return ur(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new eS(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Ke(t){return new fr({find:t.find,handler:({state:e,range:n,match:r})=>{let o=Y(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=n.from+l.indexOf(s),u=c+s.length;if(Qr(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);let d=n.from+a+s.length;i.addMark(n.from+a,d,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function gi(t){return new fr({find:t.find,handler:({state:e,range:n,match:r})=>{let o=Y(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=s+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(c,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Zr(t){return new fr({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=Y(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Qt(t){return new fr({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=Y(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&jn(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:f}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let p=h.filter(g=>f.includes(g.type.name));s.ensureMarks(p)}}if(t.keepAttributes){let u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&it(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)},undoable:t.undoable})}var nS=t=>"touches"in t,Jh=class{constructor(t){var e,n,r,o,i,s;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,!((e=t.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...t.options.min}),!((n=t.options)===null||n===void 0)&&n.max&&(this.maxSize=t.options.max),!(t==null||(r=t.options)===null||r===void 0)&&r.directions&&(this.directions=t.options.directions),!((o=t.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),!((i=t.options)===null||i===void 0)&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),!((s=t.options)===null||s===void 0)&&s.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!==null&&t!==void 0?t:null}handleEditorUpdate(){let t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){let t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){let e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){let n=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),o&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){let t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,nS(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,o,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,o=this.startHeight,i=t.includes("right"),s=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return i?r=this.startWidth+e:s&&(r=this.startWidth-e),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,t):{width:r,height:o}}applyConstraints(t,e,n){var r,o;if(!n){var i,s;let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(c=Math.min(this.maxSize.width,c)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};var X=class Gh extends wa{constructor(...e){super(...e),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new Gh(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Xh=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=()=>{try{return e.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n;let{view:r}=this.editor,o=t.target,i=o.nodeType===3?(e=o.parentElement)===null||e===void 0?void 0:e.closest("[data-drag-handle]"):o.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(o)||!i)return;let s=0,l=0;if(this.dom!==i){var a,c,u,d;let S=this.dom.getBoundingClientRect(),v=i.getBoundingClientRect(),M=(a=t.offsetX)!==null&&a!==void 0?a:(c=t.nativeEvent)===null||c===void 0?void 0:c.offsetX,E=(u=t.offsetY)!==null&&u!==void 0?u:(d=t.nativeEvent)===null||d===void 0?void 0:d.offsetY;s=v.x-S.x+M,l=v.y-S.y+E}let f=this.dom.cloneNode(!0);try{let S=this.dom.getBoundingClientRect();f.style.width=`${Math.round(S.width)}px`,f.style.height=`${Math.round(S.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let h=null;try{var p;h=document.createElement("div"),h.style.position="absolute",h.style.top="-9999px",h.style.left="-9999px",h.style.pointerEvents="none",h.appendChild(f),document.body.appendChild(h),(p=t.dataTransfer)===null||p===void 0||p.setDragImage(f,s,l)}finally{h&&setTimeout(()=>{try{h?.remove()}catch{}},0)}let g=this.getPos();if(typeof g!="number")return;let m=D.create(r.state.doc,g),y=r.state.tr.setSelection(m);r.dispatch(y)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});let n=t.target;if(!(this.dom.contains(n)&&!(!((e=this.contentDOM)===null||e===void 0)&&e.contains(n))))return!1;let r=t.type.startsWith("drag"),o=t.type==="dragover"||t.type==="dragenter",i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:l}=this,a=!!this.node.type.spec.draggable,c=D.isSelectable(this.node),u=t.type==="copy",d=t.type==="paste",f=t.type==="cut",h=t.type==="mousedown";if(!a&&c&&r&&t.target===this.dom&&t.preventDefault(),a&&r&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(a&&s&&!l&&h){let p=n.closest("[data-drag-handle]");p&&(this.dom===p||this.dom.contains(p))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||o||i||u||d||f||h&&c)}ignoreMutation(t){return this.dom?this.contentDOM?typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.contentDOM.contains(t.target)&&t.type==="childList"&&(Nn()||Yr())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target):t.type!=="selection":!0}updateAttributes(t){this.editor.commands.command(({tr:e})=>{let n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){let t=this.getPos();if(typeof t!="number")return;let e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function He(t){return new Sa({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=Y(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Qr(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===t.type&&p!==h.mark.type)).filter(h=>h.to>d).length)return null;f<n.to&&s.delete(f,n.to),d>n.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}var Ie=me(kt(),1);var{getOwnPropertyNames:rS,getOwnPropertySymbols:oS}=Object,{hasOwnProperty:iS}=Object.prototype;function eo(t,e){return function(r,o,i){return t(r,o,i)&&e(r,o,i)}}function to(t){return function(n,r,o){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,o);let{cache:i}=o,s=i.get(n),l=i.get(r);if(s&&l)return s===r&&l===n;i.set(n,r),i.set(r,n);let a=t(n,r,o);return i.delete(n),i.delete(r),a}}function sS(t){return t?.[Symbol.toStringTag]}function Yh(t){return rS(t).concat(oS(t))}var lS=Object.hasOwn||((t,e)=>iS.call(t,e));function On(t,e){return t===e||!t&&!e&&t!==t&&e!==e}var aS="__v",cS="__o",uS="_owner",dS=typeof Float16Array<"u",{getOwnPropertyDescriptor:Qh,keys:Zh}=Object;function fS(t,e){return t.byteLength===e.byteLength&&yi(new Uint8Array(t),new Uint8Array(e))}function hS(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function pS(t,e){return t.byteLength===e.byteLength&&yi(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function mS(t,e){return On(t.getTime(),e.getTime())}function ep(t,e,n){return t.name===e.name&&t.message===e.message&&t.stack===e.stack&&n.equals(t.cause,e.cause,"cause","cause",t,e,n)}function gS(t,e){return t===e}function tp(t,e,n){let r=t.size;if(r!==e.size)return!1;if(!r)return!0;let o=new Array(r),i=t.entries(),s,l,a=0;for(;(s=i.next())&&!s.done;){let c=e.entries(),u=!1,d=0;for(;(l=c.next())&&!l.done;){if(o[d]){d++;continue}let f=s.value,h=l.value;if(n.equals(f[0],h[0],a,d,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){u=o[d]=!0;break}d++}if(!u)return!1;a++}return!0}var yS=On;function np(t,e,n){let r=Zh(t),o=r.length;if(Zh(e).length!==o)return!1;for(;o-- >0;)if(!ip(t,e,n,r[o]))return!1;return!0}function hr(t,e,n){let r=Yh(t),o=r.length;if(Yh(e).length!==o)return!1;let i,s,l;for(;o-- >0;)if(i=r[o],!ip(t,e,n,i)||(s=Qh(t,i),l=Qh(e,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function bS(t,e){return On(t.valueOf(),e.valueOf())}function kS(t,e){return t.source===e.source&&t.flags===e.flags}function rp(t,e,n){let r=t.size;if(r!==e.size)return!1;if(!r)return!0;let o=new Array(r),i=t.values(),s,l;for(;(s=i.next())&&!s.done;){let a=e.values(),c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!o[u]&&n.equals(s.value,l.value,s.value,l.value,t,e,n)){c=o[u]=!0;break}u++}if(!c)return!1}return!0}function yi(t,e){let n=t.length;if(e.length!==n||t.byteOffset!==e.byteOffset)return!1;if(t instanceof Float64Array||t instanceof Float32Array||dS&&t instanceof Float16Array){for(;n-- >0;)if(t[n]!==e[n]&&(t[n]===t[n]||e[n]===e[n]))return!1;return!0}for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function wS(t,e){return t.href===e.href?!0:t.protocol===e.protocol&&t.username===e.username&&t.password===e.password&&t.host===e.host&&t.pathname===e.pathname&&t.hash===e.hash&&SS(t.searchParams,e.searchParams)}function SS(t,e){let n=t.toString(),r=e.toString();return n===r||op(n)===op(r)}function op(t){return t.split("&").sort().join("&")}function ip(t,e,n,r){return(r===uS||r===cS||r===aS)&&(t.$$typeof||e.$$typeof)?!0:lS(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}var xS="[object ArrayBuffer]",vS="[object Arguments]",CS="[object Boolean]",MS="[object DataView]",ES="[object Date]",TS="[object Error]",AS="[object Map]",NS="[object Number]",OS="[object Object]",RS="[object RegExp]",DS="[object Set]",IS="[object String]",PS={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},LS="[object URL]",zS=Object.prototype.toString;function $S({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:o,areFunctionsEqual:i,areMapsEqual:s,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(m,y,S){if(m===y)return!0;if(m==null||y==null)return!1;let v=typeof m;if(v!==typeof y)return!1;if(v!=="object")return v==="number"?l(m,y,S):v==="function"?i(m,y,S):!1;let M=m.constructor;if(M!==y.constructor)return!1;if(M===Object)return a(m,y,S);if(Array.isArray(m))return e(m,y,S);if(M===Date)return r(m,y,S);if(M===RegExp)return u(m,y,S);if(M===Map)return s(m,y,S);if(M===Set)return d(m,y,S);if(M==null)return a(m,y,S);let E=zS.call(m);if(E===ES)return r(m,y,S);if(E===RS)return u(m,y,S);if(E===AS)return s(m,y,S);if(E===DS)return d(m,y,S);if(E===OS)return typeof m.then!="function"&&typeof y.then!="function"&&a(m,y,S);if(E===LS)return h(m,y,S);if(E===TS)return o(m,y,S);if(E===vS)return a(m,y,S);if(PS[E])return f(m,y,S);if(E===xS)return t(m,y,S);if(E===MS)return n(m,y,S);if(E===CS||E===NS||E===IS)return c(m,y,S);if(p){let L=p[E];if(!L){let N=sS(m);N&&(L=p[N])}if(L)return L(m,y,S)}return!1}}function BS({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:fS,areArraysEqual:n?hr:hS,areDataViewsEqual:pS,areDatesEqual:mS,areErrorsEqual:n?eo(ep,hr):eo(ep,np),areFunctionsEqual:gS,areMapsEqual:n?eo(tp,hr):tp,areNumbersEqual:yS,areObjectsEqual:n?hr:np,arePrimitiveWrappersEqual:bS,areRegExpsEqual:kS,areSetsEqual:n?eo(rp,hr):rp,areTypedArraysEqual:n?eo(yi,hr):yi,areUrlsEqual:wS,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){let o=to(r.areArraysEqual),i=to(r.areErrorsEqual),s=to(r.areMapsEqual),l=to(r.areObjectsEqual),a=to(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:o,areErrorsEqual:i,areMapsEqual:s,areObjectsEqual:l,areSetsEqual:a})}return r}function HS(t){return function(e,n,r,o,i,s,l){return t(e,n,l)}}function FS({circular:t,comparator:e,createState:n,equals:r,strict:o}){if(n)return function(l,a){let{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:o})};if(t)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:o})};let i={cache:void 0,equals:r,meta:void 0,strict:o};return function(l,a){return e(l,a,i)}}var sp=Zt(),FM=Zt({strict:!0}),VM=Zt({circular:!0}),WM=Zt({circular:!0,strict:!0}),_M=Zt({createInternalComparator:()=>On}),jM=Zt({strict:!0,createInternalComparator:()=>On}),KM=Zt({circular:!0,createInternalComparator:()=>On}),UM=Zt({circular:!0,createInternalComparator:()=>On,strict:!0});function Zt(t={}){let{circular:e=!1,createInternalComparator:n,createState:r,strict:o=!1}=t,i=BS(t),s=$S(i),l=n?n(s):HS(s);return FS({circular:e,comparator:s,createState:r,equals:l,strict:o})}var hp=me(Zg(),1);function VS(t,e){var n,r;if(t.isDestroyed||e.defaultPrevented||!e.cancelable||!t.isEditable||e.inputType!=="insertParagraph"&&e.inputType!=="insertLineBreak"||!Nn()&&!Yr())return;let o=t.view,i=o.root,s=(n=(r=i.getSelection)===null||r===void 0?void 0:r.call(i))!==null&&n!==void 0?n:o.dom.ownerDocument.getSelection(),l=s?.anchorNode,a=l?.nodeType===1?l:l?.parentElement,c=a?.closest("[data-node-view-content-react]");if(!c||!o.dom.contains(c))return;let u=o.input.lastKeyCode;u===13&&(o.input.lastKeyCode=null),o.domObserver.forceFlush(),o.domObserver.flush();let d=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,shiftKey:e.inputType==="insertLineBreak",bubbles:!0,cancelable:!0});o.someProp("handleKeyDown",f=>f(o,d))?(e.preventDefault(),o.input.lastIOSEnter=0,clearTimeout(o.input.lastIOSEnterFallbackTimeout)):u===13&&(o.input.lastKeyCode=u)}var lp=new U("reactMobileEnter"),WS=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},_S=({contentComponent:t})=>{let e=(0,fp.useSyncExternalStore)(t.subscribe,t.getSnapshot,t.getServerSnapshot);return(0,Ie.jsx)(Ie.Fragment,{children:Object.values(e)})};function jS(){let t=new Set,e={},n=!1,r=()=>{n||!t.size||(n=!0,queueMicrotask(()=>{n=!1,t.forEach(o=>o())}))};return{subscribe(o){return t.add(o),()=>{t.delete(o)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(o,i){e={...e,[o]:bi.default.createPortal(i.reactElement,i.element,o)},r()},removeRenderer(o){let i={...e};delete i[o],e=i,r()}}}var KS=class extends K.default.Component{constructor(t){super(t),this.editorContentRef=K.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;let e=this.props.editor;if(e&&!e.isDestroyed&&(!((t=e.view.dom)===null||t===void 0)&&t.parentNode)){if(e.contentComponent)return;let n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=jS(),e.createNodeViews(),e.registerPlugin(new B({key:lp,props:{handleDOMEvents:{beforeinput:(r,o)=>VS(e,o)}}})),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let t=this.props.editor;if(t){t.isEditorContentInitialized=!1,t.isDestroyed||(t.unregisterPlugin(lp),t.view.setProps({nodeViews:{}})),t.contentComponent=null;try{var e;if(!(!((e=t.view.dom)===null||e===void 0)&&e.parentNode))return;let n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){let{editor:t,innerRef:e,...n}=this.props;return(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)("div",{ref:WS(e,this.editorContentRef),...n}),t?.contentComponent&&(0,Ie.jsx)(_S,{contentComponent:t.contentComponent})]})}},US=(0,K.forwardRef)((t,e)=>{let n=K.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return K.default.createElement(KS,{key:n,innerRef:e,...t})}),va=K.default.memo(US),qS=typeof window<"u"?K.useLayoutEffect:K.useEffect,JS=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){let e,n=o=>{o?.transaction!==void 0&&o.transaction===e||(e=o?.transaction,this.transactionNumber+=1,this.subscribers.forEach(i=>i()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function ki(t){var e;let[n]=(0,K.useState)(()=>new JS(t.editor)),r=(0,hp.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:sp);return qS(()=>n.watch(t.editor),[t.editor,n]),(0,K.useDebugValue)(r),r}var GS=typeof window>"u",ZM=GS||!!(typeof window<"u"&&window.next);var pp=(0,K.createContext)({editor:null}),eE=pp.Consumer;var mp=(0,K.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});var gp=()=>(0,K.useContext)(mp);function Ca({as:t="div",...e}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=gp();return(0,Ie.jsx)(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var no=K.default.forwardRef((t,e)=>{let{onDragStart:n}=gp(),r=t.as||"div";return(0,Ie.jsx)(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function ap(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function cp(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function XS(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function YS(t){if(ap(t)||cp(t))return!0;if(XS(t)){let e=t.type;if(e)return ap(e)||cp(e)}return!1}function QS(){try{if(K.version)return parseInt(K.version.split(".")[0],10)>=19}catch{}return!1}var ZS=class{constructor(t,{editor:e,props:n={},as:r="div",className:o=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isEditorContentInitialized?(0,bi.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;let e=this.component,n=this.props,r=this.editor,o=QS(),i=YS(e),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=(0,Ie.jsx)(e,{...s}),r==null||(t=r.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let o=n[r];if(t[o]!==this.props[o]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;let e=this.editor;e==null||(t=e.contentComponent)===null||t===void 0||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}},tE=K.default.createContext({markViewContentRef:()=>{}});function e1(t){var e;let n=t.getRootNode(),r=typeof n.getSelection=="function"?n.getSelection():(e=t.ownerDocument)===null||e===void 0||(e=e.defaultView)===null||e===void 0?void 0:e.getSelection();if(!r||r.rangeCount===0)return null;let{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=r;return!o||!s||!t.contains(o)||!t.contains(s)?null:()=>{try{r.setBaseAndExtent(o,i,s,l)}catch{}}}function t1(t,e,n){return t.node(n)===e.node(n)&&t.before(n)===e.before(n)}function yp(t){if(!di(t))return[];let{$from:e,$to:n}=t,r=[],o=Math.min(e.depth,n.depth);for(let i=1;i<=o&&t1(e,n,i);i+=1)r.push(e.before(i));return r}var n1=class{constructor(t){this.views=new WeakMap,this.viewCount=0,this.insideViews=new Set,this.syncQueued=!1,this.scheduleSync=()=>{this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.sync()}))},this.handleTransaction=()=>this.scheduleSync(),this.editor=t}register(t){this.viewCount===0&&this.editor.on("transaction",this.handleTransaction),this.views.set(t.dom,t),this.viewCount+=1,this.scheduleSync()}unregister(t){this.views.delete(t.dom),this.viewCount-=1,this.insideViews.delete(t),this.viewCount===0&&this.editor.off("transaction",this.handleTransaction)}sync(){if(this.viewCount===0||this.editor.isDestroyed)return;let t=this.findInsideViews();this.updateViews(this.insideViews,t,!1),this.updateViews(t,this.insideViews,!0),this.insideViews=t}updateViews(t,e,n){for(let r of t)e.has(r)||r.setSelectionInside(n)}findInsideViews(){let t=new Set;for(let e of yp(this.editor.state.selection)){let n=this.editor.view.nodeDOM(e),r=n?this.views.get(n):void 0;r&&t.add(r)}return t}},up=new WeakMap;function dp(t){let e=up.get(t);return e||(e=new n1(t),up.set(t,e)),e}var r1=class extends Xh{constructor(t,e,n){if(super(t,e,n),this.nodeSelected=!1,this.handlePositionUpdate=()=>{let r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";let r=this.dom.querySelector("[data-node-view-content]");r?r.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,o){if(r==="storage"){var i;return(i=t.storage[e.name])!==null&&i!==void 0?i:{}}return Reflect.get(n,r,o)}})}return this.cachedExtensionWithSyncedStorage}mount(){let t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,selectionInside:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:(0,K.createRef)()};if(!this.component.displayName){let a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}let r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{if(a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement){a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper");let c=e1(this.contentDOMElement);a.appendChild(this.contentDOMElement),c?.()}}},o=this.component,i=(0,K.memo)(a=>(0,Ie.jsx)(mp.Provider,{value:r,children:(0,K.createElement)(o,a)}));i.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);let{className:l=""}=this.options;this.renderer=new ZS(i,{editor:this.editor,props:t,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),dp(this.editor).register(this),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!(!((t=this.renderer.element.firstElementChild)===null||t===void 0)&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}update(t,e,n){let r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){let s=this.node,l=this.decorations,a=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:s,oldDecorations:l,newNode:t,newDecorations:e,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(t===this.node)return this.node=t,this.decorations=e,this.innerDecorations=n,!0;let o=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=o;let i={node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(i.getPos=()=>this.getPos()),r(i),!0}selectNode(){this.nodeSelected=!0,this.updateSelectedState(!0)}deselectNode(){this.nodeSelected=!1,this.updateSelectedState(this.options.selectedOnTextSelection===!0&&this.isTextSelectionInside())}setSelectionInside(t){let e=this.nodeSelected||this.options.selectedOnTextSelection===!0&&t;this.renderer.updateProps({selectionInside:t,selected:e}),this.renderer.element.classList.toggle("ProseMirror-selectednode",e)}updateSelectedState(t){this.renderer.updateProps({selected:t}),this.renderer.element.classList.toggle("ProseMirror-selectednode",t)}isTextSelectionInside(){let t=this.getPos();return typeof t=="number"&&yp(this.editor.state.selection).includes(t)}destroy(){this.renderer.destroy(),dp(this.editor).unregister(this),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){let e=this.editor.extensionManager.attributes,n=pt(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function ro(t,e){return n=>n.editor.contentComponent?new r1(t,n,e):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var Ma=(0,K.createContext)({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Ma.displayName="TiptapContext";var o1=()=>(0,K.useContext)(Ma);function bp({children:t,...e}){let n="editor"in e?e.editor:e.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,K.useMemo)(()=>({editor:n}),[n]),o=(0,K.useMemo)(()=>({editor:n}),[n]);return(0,Ie.jsx)(pp.Provider,{value:o,children:(0,Ie.jsx)(Ma.Provider,{value:r,children:t})})}bp.displayName="Tiptap";function kp({...t}){let{editor:e}=o1();return(0,Ie.jsx)(va,{editor:e,...t})}kp.displayName="Tiptap.Content";var nE=Object.assign(bp,{Content:kp});var Fe=me(vr(),1);var i1=new WeakSet,wp=t=>i1.has(t);var s1=(0,Fe.createContext)(null);function Sp(t){let e=(0,Fe.useContext)(s1),n=(0,Fe.useId)(),r=(0,Fe.useRef)(t.retentionKey??n).current,o=(0,Fe.useRef)(t);o.current=t;let i=(0,Fe.useRef)(e?.find(r)??null),[s,l]=(0,Fe.useState)(i.current),a=(0,Fe.useRef)(void 0);return(0,Fe.useLayoutEffect)(()=>{clearTimeout(a.current);let c=()=>{let{retentionKey:d,immediatelyRender:f,shouldRerenderOnTransaction:h,...p}=o.current;return new xa({...p,onUpdate:g=>o.current.onUpdate?.(g),editorProps:{...p.editorProps,handleKeyDown:(g,m)=>o.current.editorProps?.handleKeyDown?.(g,m)??!1,handleClick:(g,m,y)=>o.current.editorProps?.handleClick?.(g,m,y)??!1,handlePaste:(g,m,y)=>o.current.editorProps?.handlePaste?.(g,m,y)??!1}})},u=e?e.get(r,c):i.current&&!i.current.isDestroyed?i.current:c();return i.current=u,u.setEditable(o.current.editable!==!1,!1),l(u),()=>{u.isDestroyed||u.setEditable(!1,!1),!e&&(a.current=setTimeout(()=>{i.current===u&&!u.isDestroyed&&u.destroy()},1))}},[e,r]),s}var Ea=new WeakMap;function Ta(t){let e=Ea.get(t);if(e)return e;let n={type:t.type.name};return Object.keys(t.attrs).length&&(n.attrs=t.attrs),t.content.size&&(n.content=[],t.content.forEach(r=>n.content.push(Ta(r)))),t.marks.length&&(n.marks=t.marks.map(r=>r.toJSON())),t.isText&&(n.text=t.text),Ea.set(t,n),n}function xp(t,e){let n=Ea.get(t);if(n===e)return!0;if(!n||n.type!==e.type||n.text!==e.text||n.attrs!==e.attrs&&JSON.stringify(n.attrs)!==JSON.stringify(e.attrs)||n.marks!==e.marks&&JSON.stringify(n.marks)!==JSON.stringify(e.marks)||t.childCount!==(e.content?.length??0))return!1;for(let r=0;r<t.childCount;r++)if(!xp(t.child(r),e.content[r]))return!1;return!0}function vp(t,e){if(e.type!==t.type.name||t.childCount!==(e.content?.length??0))return!1;for(let n=0;n<t.childCount;n++)if(!xp(t.child(n),e.content[n]))return!1;return!0}var be=class t extends R{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):R.near(r)}content(){return A.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Aa(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!l1(e)||!a1(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!D.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};be.prototype.visible=!1;be.findFrom=be.findGapCursorFrom;R.jsonID("gapcursor",be);var Aa=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return be.valid(n)?new be(n):R.near(n)}};function Cp(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function l1(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Cp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function a1(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Cp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Mp(){return new B({props:{decorations:f1,createSelectionBetween(t,e,n){return e.pos==n.pos&&be.valid(n)?new be(n):null},handleClick:u1,handleKeyDown:c1,handleDOMEvents:{beforeinput:d1}}})}var c1=Jr({ArrowLeft:wi("horiz",-1),ArrowRight:wi("horiz",1),ArrowUp:wi("vert",-1),ArrowDown:wi("vert",1)});function wi(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof O){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=be.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new be(c))),!0):!1}}function u1(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!be.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&D.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new be(r))),!0)}function d1(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof be))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=x.empty;for(let s=r.length-1;s>=0;s--)o=x.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new A(o,0,0));return i.setSelection(O.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function f1(t){if(!(t.selection instanceof be))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Z.create(t.doc,[ye.widget(t.selection.head,e,{key:"gapcursor"})])}function Si(t){let e=t.selection;if(!(e instanceof D)||e.node.type.name!=="widget")return null;let n=R.findFrom(e.$to,1,!0)??R.findFrom(e.$from,-1,!0),r=n?null:new be(t.doc.resolve(t.doc.content.size)).map(t.doc,new pn),o=n??(r instanceof be?r:null);return o?t.tr.setSelection(o).setMeta("addToHistory",!1):null}function Ep(t,e){if(vp(t.doc,e))return null;let n=t.schema.nodeFromJSON(e),r=t.doc.content.findDiffStart(n.content);if(r===null)return null;let o=t.doc.content.findDiffEnd(n.content),i=o.a,s=o.b,l=r-Math.min(i,s);return l>0&&(i+=l,s+=l),t.tr.replace(r,i,n.slice(r,s)).setMeta("addToHistory",!1).setMeta("preventUpdate",!0)}var Oa,Ra;if(typeof WeakMap<"u"){let t=new WeakMap;Oa=e=>t.get(e),Ra=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Oa=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Ra=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var ne=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,o=e/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){let{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){let{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width,l=(t+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(t){return Oa(t)||Ra(t,h1(t))}};function h1(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=p1(t),n=t.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;let g=d.child(p),{colspan:m,rowspan:y,colwidth:S}=g.attrs;for(let v=0;v<y;v++){if(v+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-v});break}let M=o+v*e;for(let E=0;E<m;E++){r[M+E]==0?r[M+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:m-E});let L=S&&S[E];if(L){let N=(M+E)%e*2,_=s[N];_==null||_!=L&&s[N+1]==1?(s[N]=L,s[N+1]=1):_==L&&s[N+1]++}}}o+=m,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new ne(e,n,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&m1(l,s,t),l}function p1(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let o=t.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=t.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function m1(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o<t.map.length;o++){let i=t.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let u=e[(o+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=g1(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function g1(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Pe(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var en=new U("selectingCells");function It(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function y1(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function lt(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Ti(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=It(e.$head)||b1(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function b1(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Da(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function k1(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function La(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function zp(t,e,n){let r=t.node(-1),o=ne.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Rn(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function $p(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function w1(t,e,n){let r=Pe(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var q=class Dt extends R{constructor(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new qn(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(Da(r)&&Da(o)&&La(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Dt.rowSelection(r,o):i&&this.isColSelection()?Dt.colSelection(r,o):new Dt(r,o)}return O.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=ne.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*n.width+o.left,d=o.left;d<o.right;d++,u++){let f=n.map[u];if(i[f])continue;i[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let g=o.left-h.left,m=h.right-o.right;if(g>0||m>0){let y=p.attrs;if(g>0&&(y=Rn(y,0,g)),m>0&&(y=Rn(y,y.colspan-m,m)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(x.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new A(x.from(l),1,1)}replace(e,n=A.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?A.empty:n)}let i=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new A(x.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=ne.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Dt(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=ne.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof Dt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new Dt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Dt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Dt(e.resolve(n),e.resolve(r))}getBookmark(){return new S1(this.$anchorCell.pos,this.$headCell.pos)}};q.prototype.visible=!1;R.jsonID("cell",q);var S1=class Bp{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Bp(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&La(n,r)?new q(n,r):R.near(r,1)}};function x1(t){if(!(t.selection instanceof q))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ye.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Z.create(t.doc,e)}function v1({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function C1({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function M1(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof D&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=q.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=q.rowSelection(l,l)}else if(!n){let l=ne.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=q.create(o,a+1,c)}}else r instanceof O&&v1(r)?i=O.create(o,r.from):r instanceof O&&C1(r)&&(i=O.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var E1=new U("fix-tables");function Hp(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&t.child(l).sameMarkup(a)?Hp(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function za(t,e){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=T1(t,o,i,n))};return e?e.doc!=t.doc&&Hp(e.doc,t.doc,0,r):t.doc.descendants(r),n}function T1(t,e,n,r){let o=ne.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Rn(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let m=0;m<f;m++){let y=Pe(t.schema)[h].createAndFill();y&&p.push(y)}let g=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(E1,{fixTables:!0})}function mt(t){let e=t.selection,n=Ti(t),r=n.node(-1),o=n.start(-1),i=ne.get(r);return{...e instanceof q?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Fp(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;w1(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,$p(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?Pe(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function Vp(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(Fp(t.tr,n,n.left))}return!0}function Wp(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(Fp(t.tr,n,n.right))}return!0}function A1(t,{map:e,table:n,tableStart:r},o){let i=t.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Rn(u,o-e.colCount(a)));else{let d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}s+=u.rowspan}}function _p(t,e){if(!lt(t))return!1;if(e){let n=mt(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;A1(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ne.get(i)}e(r)}return!0}function N1(t,e,n){var r;let o=Pe(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function jp(t,{map:e,tableStart:n,table:r},o){let i=n;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;N1(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?Pe(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&s.push(f)}return t.insert(i,Pe(r.type.schema).row.create(null,s)),t}function Kp(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(jp(t.tr,n,n.top))}return!0}function Up(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(jp(t.tr,n,n.bottom))}return!0}function O1(t,{map:e,table:n,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=n.child(c).nodeSize;let s=i+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(i+r,s+r);let a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){let f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=h.colspan-1}}}}function qp(t,e){if(!lt(t))return!1;if(e){let n=mt(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;O1(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ne.get(n.table)}e(r)}return!0}function Tp(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function R1({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function $a(t,e){let n=t.selection;if(!(n instanceof q)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=mt(t),{map:o}=r;if(R1(o,r))return!1;if(e){let i=t.tr,s={},l=x.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,a==null)a=f,c=h;else{Tp(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...$p(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=Tp(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new q(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Ba(t,e){let n=Pe(t.schema);return D1(({node:r})=>n[r.type.spec.tableRole])(t,e)}function D1(t){return(e,n)=>{let r=e.selection,o,i;if(r instanceof q){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=y1(r.$from),!o)return!1;i=(s=It(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=mt(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=o.nodeSize);for(let g=u.left,m=0;g<u.right;g++,m++)g==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:o,row:h,col:g}).createAndFill(a[m]))}d.setNodeMarkup(i,t({node:o,row:u.top,col:u.left}),a[0]),r instanceof q&&d.setSelection(new q(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function Jp(t,e){return function(n,r){if(!lt(n))return!1;let o=Ti(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){let i=n.tr;n.selection instanceof q?n.selection.forEachCell((s,l)=>{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function I1(t){return function(e,n){if(!lt(e))return!1;if(n){let r=Pe(e.schema),o=mt(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Ap(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){let i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function pr(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?I1(t):function(n,r){if(!lt(n))return!1;if(r){let o=Pe(n.schema),i=mt(n),s=n.tr,l=Ap("row",i,o),a=Ap("column",i,o),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?o.cell:o.header_cell:t=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(f=>{let h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,d,p.attrs)}),r(s)}return!0}}var DE=pr("row",{useDeprecatedLogic:!0}),IE=pr("column",{useDeprecatedLogic:!0}),Gp=pr("cell",{useDeprecatedLogic:!0});function P1(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function Ha(t){return function(e,n){if(!lt(e))return!1;let r=P1(Ti(e),t);if(r==null)return!1;if(n){let o=e.doc.resolve(r);n(e.tr.setSelection(O.between(o,k1(o))).scrollIntoView())}return!0}}function Xp(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function xi(t,e){let n=t.selection;if(!(n instanceof q))return!1;if(e){let r=t.tr,o=Pe(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new A(o,0,0))}),r.docChanged&&e(r)}return!0}function L1(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Ia(Pe(s).row,new A(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Ia(Pe(s).row,new A(e,n,r)).content:e);else return null;return z1(s,l)}function z1(t,e){let n=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(x.empty),n[o]<r){let i=Pe(t).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);e[o]=e[o].append(x.from(s))}return{height:e.length,width:r,rows:e}}function Ia(t,e){let n=t.createAndFill();return new jt(n).replace(0,n.content.size,e).doc}function $1({width:t,height:e,rows:n},r,o){if(t!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Rn(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(x.from(c))}n=s,t=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(x.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function B1(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=Pe(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let m=e.width;m<o;m++)p.push(g);t.insert(t.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let m=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(m?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,x.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),h)}return!!(c||u)}function Np(t,e,n,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function Op(t,e,n,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Rn(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Rn(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Rp(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=ne.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=t.tr,f=0;function h(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");s=ne.get(i),f=d.mapping.maps.length}B1(d,s,i,n,c,u,f)&&h(),Np(d,s,i,n,a,c,l,f)&&h(),Np(d,s,i,n,a,c,u,f)&&h(),Op(d,s,i,n,l,u,a,f)&&h(),Op(d,s,i,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=s.positionAt(p,a,i),m=s.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(m+n),new A(o.rows[p-l],0,0))}h(),d.setSelection(new q(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(u-1,c-1,i)))),e(d)}var H1=Jr({ArrowLeft:vi("horiz",-1),ArrowRight:vi("horiz",1),ArrowUp:vi("vert",-1),ArrowDown:vi("vert",1),"Shift-ArrowLeft":Ci("horiz",-1),"Shift-ArrowRight":Ci("horiz",1),"Shift-ArrowUp":Ci("vert",-1),"Shift-ArrowDown":Ci("vert",1),Backspace:xi,"Mod-Backspace":xi,Delete:xi,"Mod-Delete":xi});function Mi(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function vi(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof q)return Mi(n,r,R.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let s=Yp(o,t,e);if(s==null)return!1;if(t=="horiz")return Mi(n,r,R.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=zp(l,t,e),c;return a?c=R.near(a,1):e<0?c=R.near(n.doc.resolve(l.before(-1)),-1):c=R.near(n.doc.resolve(l.after(-1)),1),Mi(n,r,c)}}}function Ci(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof q)s=i;else{let a=Yp(o,t,e);if(a==null)return!1;s=new q(n.doc.resolve(a))}let l=zp(s.$headCell,t,e);return l?Mi(n,r,new q(s.$anchorCell,l)):!1}}function F1(t,e){let n=t.state.doc,r=It(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new q(r))),!0):!1}function V1(t,e,n){if(!lt(t.state))return!1;let r=L1(n),o=t.state.selection;if(o instanceof q){r||(r={width:1,height:1,rows:[x.from(Ia(Pe(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ne.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=$1(r,l.right-l.left,l.bottom-l.top),Rp(t.state,t.dispatch,s,l,r),!0}else if(r){let i=Ti(t.state),s=i.start(-1);return Rp(t.state,t.dispatch,s,ne.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function W1(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Dp(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof q)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=It(t.state.selection.$anchor))!=null&&((n=Na(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let u=Na(t,c),d=en.getState(t.state)==null;if(!u||!La(a,u))if(d)u=a;else return;let f=new q(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(en,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),en.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(en,-1))}function l(a){let c=a,u=en.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(Dp(t,c.target)!=r&&(d=Na(t,e),!d))return s();d&&i(d,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Yp(t,e,n){if(!(t.state.selection instanceof O))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function Dp(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Na(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&It(t.state.doc.resolve(r))||It(t.state.doc.resolve(o))}var _1=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Pa(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Pa(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Pa(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g++,f++){let m=o==f?i:p&&p[g],y=m?m+"px":"";if(s+=m||r,m||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let S=document.createElement("col");S.style.width=y,e.appendChild(S)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var Je=new U("tableColumnResizing");function Qp({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=_1,lastColumnResizable:o=!0}={}){let i=new B({key:Je,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=Pe(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new j1(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Je.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{K1(s,l,t,o)},mouseleave:s=>{U1(s)},mousedown:(s,l)=>{q1(s,l,e,n)}},decorations:s=>{let l=Je.getState(s);if(l&&l.activeHandle>-1)return Q1(s,l.activeHandle)},nodeViews:{}}});return i}var j1=class Ei{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Je);if(r&&r.setHandle!=null)return new Ei(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ei(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return Da(e.doc.resolve(o))||(o=-1),new Ei(o,n.dragging)}return n}};function K1(t,e,n,r){if(!t.editable)return;let o=Je.getState(t.state);if(o&&!o.dragging){let i=G1(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=Ip(t,e,"left",n):a-e.clientX<=n&&(s=Ip(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=ne.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Zp(t,s)}}}function U1(t){if(!t.editable)return;let e=Je.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Zp(t,-1)}function q1(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Je.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=J1(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Je,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);let f=Je.getState(t.state);f?.dragging&&(X1(t,f.activeHandle,Pp(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Je,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Je.getState(t.state);if(f&&f.dragging){let h=Pp(f.dragging,d,n);Lp(t,f.activeHandle,h,r)}}return Lp(t,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function J1(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function G1(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Ip(t,e,n,r){let o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=It(t.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=ne.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Pp(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Zp(t,e){t.dispatch(t.state.tr.setMeta(Je,{setHandle:e}))}function X1(t,e,n){let r=t.state.doc.resolve(e),o=r.node(-1),i=ne.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],f=o.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():Y1(f.colspan);p[h]=n,a.setNodeMarkup(s+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function Lp(t,e,n,r){let o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=ne.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Pa(i,a.firstChild,a,r,l,n)}function Y1(t){return Array(t).fill(0)}function Q1(t,e){let n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Z.empty;let i=ne.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let d=i.map[u],f=s+d+o.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Je.getState(t))===null||a===void 0)&&a.dragging&&n.push(ye.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(ye.widget(f,h))}}return Z.create(t.doc,n)}function em({allowTableNodeSelection:t=!1}={}){return new B({key:en,state:{init(){return null},apply(e,n){let r=e.getMeta(en);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:x1,handleDOMEvents:{mousedown:W1},createSelectionBetween(e){return en.getState(e.state)!=null?e.state.selection:null},handleTripleClick:F1,handleKeyDown:H1,handlePaste:V1},appendTransaction(e,n,r){return M1(r,za(r,n),t)}})}var Dn="showaiTableAction";function tm(t,e,n){let r=t.doc.nodeAt(e);if(r?.type.name!=="table")return null;let o=t.selection instanceof q?t.selection.$headCell:It(t.selection.$head),i=o&&o.before(-1)===e?o:t.doc.resolve(e+1+ne.get(r).map[0]),s=n==="row"?q.rowSelection(i):n==="column"?q.colSelection(i):new q(i);return t.tr.setSelection(s)}function oo(t){let e=t.selection;if(!(e instanceof q))return null;let n=e.$anchorCell.node(-1),r=e.$anchorCell.start(-1),o=ne.get(n).rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r);return{tablePosition:r-1,rows:o.bottom-o.top,columns:o.right-o.left}}function nm(t,e){let n=e.$anchorCell.nodeAfter?.attrs.id,r=e.$headCell.nodeAfter?.attrs.id;if(!n||!r)return null;let o,i;if(t.descendants((a,c)=>{["tableCell","tableHeader"].includes(a.type.name)&&(a.attrs.id===n&&(o=c),a.attrs.id===r&&(i=c))}),o===void 0&&i===void 0||(o??=i,i??=o,o===void 0||i===void 0))return null;let s=t.resolve(o),l=t.resolve(i);return s.node(-1)!==l.node(-1)?null:new q(s,l)}var Ge=me(kt(),1);function Ai({editor:t,context:e=!1,onAction:n}){let r=ct(Le),o=oo(t.state);if(!o&&!e&&!t.can().splitCell())return null;let i=s=>{t.view.dispatch(er(t.state.tr)),t.chain().setMeta(Dn,!0).focus()[s]().run(),n?.()};return(0,Ge.jsxs)(Ge.Fragment,{children:[!e&&(0,Ge.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,Ge.jsxs)("div",{className:"editor-table-actions",role:"group","aria-label":r("table.cellActions"),children:[o&&(0,Ge.jsx)("span",{className:"editor-menu-status",role:"status",children:o.rows===1&&o.columns===1?r("table.shiftClickHint"):r("table.selectedCells",{rows:o.rows,columns:o.columns})}),[["mergeCells",r("table.mergeCells"),su],["splitCell",r("table.splitCell"),lu]].map(([s,l,a])=>(0,Ge.jsxs)("button",{type:"button",className:"editor-tool",role:e?"menuitem":void 0,"aria-label":l,title:l,disabled:!t.can()[s](),onMouseDown:c=>c.preventDefault(),onClick:()=>i(s),children:[(0,Ge.jsx)(a,{size:16}),e&&(0,Ge.jsx)("span",{children:l})]},s)),!e&&o&&(0,Ge.jsx)("button",{type:"button",className:"editor-tool","aria-label":r("table.clearSelection"),title:r("table.clearSelection"),onMouseDown:s=>s.preventDefault(),onClick:()=>{t.view.dispatch(t.state.tr.setSelection(O.near(t.state.selection.$from))),t.view.focus()},children:(0,Ge.jsx)(Cr,{size:16})})]})]})}var io=me(vr(),1),lm=me($s(),1);var rm=Fn(Le),om=G.create({name:"tableAlignment",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textAlign:{default:null,parseHTML:t=>["left","center","right"].includes(t.style.textAlign)?t.style.textAlign:null,renderHTML:t=>["left","center","right"].includes(String(t.textAlign))?{style:`text-align: ${t.textAlign}`}:{}}}}]},addProseMirrorPlugins(){let t=this.editor;return[new B({appendTransaction(e,n,r){if(!t.isEditable||!e.some(i=>i.docChanged))return null;let o=r.tr;return r.doc.descendants((i,s)=>{if(i.type.name!=="table")return;let l=ne.get(i),a=Array.from({length:l.width},(c,u)=>{let d=new Set(Array.from({length:l.height},(f,h)=>i.nodeAt(l.map[h*l.width+u])?.attrs.textAlign).filter(Boolean));return d.size===1?[...d][0]:i.attrs.textAlign});Z1(i,s,(c,u)=>{if(c.attrs.textAlign)return;let d=l.findCell(u-s-1),f=new Set(a.slice(d.left,d.right)),h=f.size===1?[...f][0]:i.attrs.textAlign;h&&o.setNodeAttribute(u,"textAlign",h)})}),o.docChanged?o.setMeta("addToHistory",!1):null}})]}});function Z1(t,e,n){t.forEach((r,o)=>r.forEach((i,s)=>n(i,e+2+o+s)))}function Fa(t,e){let r=im(t,e).map(o=>t.nodeAt(o)?.attrs.textAlign??t.attrs.textAlign??"left");return r.every(o=>o===r[0])?r[0]??"left":null}function im(t,e){let n=ne.get(t);if(e!==null&&(!Number.isInteger(e)||e<0||e>=n.width))throw new Error(rm("table.columnOutOfRange"));return[...new Set(e===null?n.map:Array.from({length:n.height},(r,o)=>n.map[o*n.width+e]))]}function sm(t,e,n,r){let o=t.doc.nodeAt(e);if(!o||o.type.name!=="table")throw new Error(rm("table.notATable"));let i=t.tr;n===null&&i.setNodeAttribute(e,"textAlign",r);for(let s of im(o,n)){let l=e+1+s,a=t.doc.nodeAt(l);i.setNodeAttribute(l,"textAlign",r),a.descendants((c,u)=>{if(c.type.name==="table")return!1;["paragraph","heading"].includes(c.type.name)&&c.attrs.textAlign&&i.setNodeAttribute(l+1+u,"textAlign",null)})}return i}var ee=me(kt(),1),ex=t=>!t.closest(".document-widget");function am({editor:t}){let e=ct(Le),[,n]=(0,io.useState)(0),[r,o]=(0,io.useState)(!1),i=oo(t.state),{target:s,setTarget:l,owner:a}=yu(t.view.dom,{keepOpen:r,accept:ex,onDismiss:()=>o(!1)});if((0,io.useEffect)(()=>{let E=()=>n(N=>N+1),L=N=>{N.key!=="Escape"||!oo(t.state)||!t.view.hasFocus()&&document.activeElement?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")!==a||(t.view.dispatch(t.state.tr.setSelection(O.near(t.state.selection.$from))),o(!1),t.view.focus())};return t.on("transaction",E),document.addEventListener("keydown",L),()=>{t.off("transaction",E),document.removeEventListener("keydown",L)}},[t,a]),!s||!s.table.isConnected||!t.isEditable||!s.context&&(i||t.isFocused&&t.state.selection instanceof O&&!t.state.selection.empty))return null;let c=t.state.doc.resolve(t.view.posAtDOM(s.table,0)),u=c.depth;for(;u>0&&c.node(u).type.name!=="table";)u--;if(!u)return null;let d=c.node(u),f=c.before(u),h=null;if(s.cell?.isConnected){let E=t.view.posAtDOM(s.cell,0),L=t.state.doc.resolve(E),N=L.depth;for(;N>u&&!["tableCell","tableHeader"].includes(L.node(N).type.name);)N--;N>u&&(h=ne.get(d).findCell(L.before(N)-f-1).left)}let p=bu(s,128),g=p.global.top>window.innerHeight/2,m=()=>{let{$from:E}=t.state.selection;Array.from({length:E.depth},(N,_)=>_+1).some(N=>E.node(N).type.name==="table"&&E.before(N)===f)||t.view.dispatch(t.state.tr.setSelection(O.near(t.state.doc.resolve(f+3))))},y=E=>{m(),t.view.dispatch(er(t.state.tr)),E(),o(!1)},S=()=>t.chain().setMeta(Dn,!0).focus(),v=E=>y(()=>{let L=tm(t.state,f,E);L&&t.view.dispatch(L),t.view.focus()}),M=(E,L)=>{t.view.dispatch(sm(t.state,f,E,L).setMeta(Dn,!0)),s.context&&(l(null),t.view.focus())};return(0,lm.createPortal)((0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("div",{className:"document-table-controls table-global-alignment","data-editor-menu-trigger":s.context?"context":"hover",role:s.context?"dialog":void 0,"aria-label":e("table.alignment"),"data-table-controls-owner":a,style:p.global,children:[(0,ee.jsx)(Fs,{scope:"table",value:Fa(d,null),onChange:E=>M(null,E)}),!s.context&&(0,ee.jsx)("button",{className:"document-table-menu-trigger",type:"button","aria-label":e("table.actions"),title:e("table.actions"),"aria-expanded":r,"aria-haspopup":"menu",onMouseDown:E=>E.preventDefault(),onClick:()=>{m(),o(!r)},children:(0,ee.jsx)(Kc,{size:16})}),(r||s.context)&&(0,ee.jsxs)("div",{className:"document-table-menu",role:"menu","aria-label":e("table.actionsMenu"),style:{...g?{top:"auto",bottom:"calc(100% + 4px)"}:{},maxHeight:Math.max(120,g?p.global.top-12:window.innerHeight-p.global.top-46),overflowY:"auto"},onMouseDown:E=>E.preventDefault(),children:[(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().addRowAfter().run()}),children:[(0,ee.jsx)(Wt,{size:14}),e("table.addRow")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().addColumnAfter().run()}),children:[(0,ee.jsx)(Wt,{size:14}),e("table.addColumn")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().toggleHeaderRow().run()}),children:[(0,ee.jsx)(au,{size:14,"aria-hidden":"true"}),e("table.toggleHeader")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>v("cell"),children:[(0,ee.jsx)(ou,{size:14,"aria-hidden":"true"}),e("table.selectCells")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>v("row"),children:[(0,ee.jsx)(Is,{size:14,"aria-hidden":"true"}),e("table.selectRow")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>v("column"),children:[(0,ee.jsx)(Ds,{size:14,"aria-hidden":"true"}),e("table.selectColumn")]}),s.context&&(0,ee.jsx)(Ai,{editor:t,context:!0,onAction:()=>{l(null),o(!1)}}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().deleteRow().run()}),children:[(0,ee.jsx)(Is,{size:14,"aria-hidden":"true"}),e("table.deleteRow")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().deleteColumn().run()}),children:[(0,ee.jsx)(Ds,{size:14,"aria-hidden":"true"}),e("table.deleteColumn")]}),(0,ee.jsxs)("button",{role:"menuitem",className:"danger",onClick:()=>y(()=>{S().deleteTable().run(),l(null)}),children:[(0,ee.jsx)(Eo,{size:14}),e("table.deleteTable")]})]})]}),h!==null&&!s.context&&(0,ee.jsx)("div",{className:"document-table-controls table-column-alignment","data-table-controls-owner":a,style:p.column,children:(0,ee.jsx)(Fs,{scope:h,value:Fa(d,h),onChange:E=>M(h,E)})})]}),document.body)}var cm=new WeakSet,um=new WeakSet;function In(t){let e=t;return cm.add(e),e}function Va(t){return Array.isArray(t)&&cm.has(t)}function dm(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&um.has(e)&&!Va(e)?dm(e):[e])}function tx(t,e){if(t==="slot")return 0;if(t instanceof Function){let o=t(e);return Array.isArray(o)&&!Va(o)&&!um.has(o)?In(o):o}let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(Va(n))return In([t,r,n]);if(n.length===0)return In([t,r]);let o=dm(n);return o.length===0?In([t,r]):In([t,r,...o])}return n!=null?In([t,r,n]):In([t,r])}var mr=(t,e)=>tx(t,e);var nx=(t,e)=>{var n;let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0)return!1;let s=i.depth-1;if(s<0)return!1;let l=i.node(s),a=i.index(s);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let u=i.before()-1-1;return t.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;let h=i.parent.content,p=new A(h,0,0);return d.replace(u,i.after(),p),d.setSelection(O.create(d.doc,u+h.size)),d.scrollIntoView(),f(d),!0})},rx=/^\s*>\s$/,fm=X.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return mr("blockquote",{...H(this.options.HTMLAttributes,t),children:mr("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((o,i)=>{var s,l;let a=((s=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,o,i))!==null&&s!==void 0?s:e.renderChildren([o])).split(`
98
+ `,textSerializers:n={}}=t||{};return zk(this.state.doc,{blockSeparator:e,textSerializers:{...Nh(this.schema),...n}})}get isEmpty(){return ur(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new eS(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Ke(t){return new fr({find:t.find,handler:({state:e,range:n,match:r})=>{let o=Y(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=n.from+l.indexOf(s),u=c+s.length;if(Qr(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);let d=n.from+a+s.length;i.addMark(n.from+a,d,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function gi(t){return new fr({find:t.find,handler:({state:e,range:n,match:r})=>{let o=Y(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=s+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(c,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Zr(t){return new fr({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=Y(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Qt(t){return new fr({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=Y(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&jn(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:f}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let p=h.filter(g=>f.includes(g.type.name));s.ensureMarks(p)}}if(t.keepAttributes){let u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&it(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)},undoable:t.undoable})}var nS=t=>"touches"in t,Jh=class{constructor(t){var e,n,r,o,i,s;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,!((e=t.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...t.options.min}),!((n=t.options)===null||n===void 0)&&n.max&&(this.maxSize=t.options.max),!(t==null||(r=t.options)===null||r===void 0)&&r.directions&&(this.directions=t.options.directions),!((o=t.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),!((i=t.options)===null||i===void 0)&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),!((s=t.options)===null||s===void 0)&&s.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!==null&&t!==void 0?t:null}handleEditorUpdate(){let t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){let t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){let e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){let n=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),o&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){let t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,nS(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,o,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,o=this.startHeight,i=t.includes("right"),s=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return i?r=this.startWidth+e:s&&(r=this.startWidth-e),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,t):{width:r,height:o}}applyConstraints(t,e,n){var r,o;if(!n){var i,s;let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(c=Math.min(this.maxSize.width,c)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};var X=class Gh extends wa{constructor(...e){super(...e),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new Gh(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Xh=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=()=>{try{return e.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n;let{view:r}=this.editor,o=t.target,i=o.nodeType===3?(e=o.parentElement)===null||e===void 0?void 0:e.closest("[data-drag-handle]"):o.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(o)||!i)return;let s=0,l=0;if(this.dom!==i){var a,c,u,d;let S=this.dom.getBoundingClientRect(),v=i.getBoundingClientRect(),M=(a=t.offsetX)!==null&&a!==void 0?a:(c=t.nativeEvent)===null||c===void 0?void 0:c.offsetX,E=(u=t.offsetY)!==null&&u!==void 0?u:(d=t.nativeEvent)===null||d===void 0?void 0:d.offsetY;s=v.x-S.x+M,l=v.y-S.y+E}let f=this.dom.cloneNode(!0);try{let S=this.dom.getBoundingClientRect();f.style.width=`${Math.round(S.width)}px`,f.style.height=`${Math.round(S.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let h=null;try{var p;h=document.createElement("div"),h.style.position="absolute",h.style.top="-9999px",h.style.left="-9999px",h.style.pointerEvents="none",h.appendChild(f),document.body.appendChild(h),(p=t.dataTransfer)===null||p===void 0||p.setDragImage(f,s,l)}finally{h&&setTimeout(()=>{try{h?.remove()}catch{}},0)}let g=this.getPos();if(typeof g!="number")return;let m=D.create(r.state.doc,g),y=r.state.tr.setSelection(m);r.dispatch(y)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});let n=t.target;if(!(this.dom.contains(n)&&!(!((e=this.contentDOM)===null||e===void 0)&&e.contains(n))))return!1;let r=t.type.startsWith("drag"),o=t.type==="dragover"||t.type==="dragenter",i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:l}=this,a=!!this.node.type.spec.draggable,c=D.isSelectable(this.node),u=t.type==="copy",d=t.type==="paste",f=t.type==="cut",h=t.type==="mousedown";if(!a&&c&&r&&t.target===this.dom&&t.preventDefault(),a&&r&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(a&&s&&!l&&h){let p=n.closest("[data-drag-handle]");p&&(this.dom===p||this.dom.contains(p))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||o||i||u||d||f||h&&c)}ignoreMutation(t){return this.dom?this.contentDOM?typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.contentDOM.contains(t.target)&&t.type==="childList"&&(Nn()||Yr())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target):t.type!=="selection":!0}updateAttributes(t){this.editor.commands.command(({tr:e})=>{let n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){let t=this.getPos();if(typeof t!="number")return;let e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function He(t){return new Sa({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=Y(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Qr(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===t.type&&p!==h.mark.type)).filter(h=>h.to>d).length)return null;f<n.to&&s.delete(f,n.to),d>n.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}var Ie=me(kt(),1);var{getOwnPropertyNames:rS,getOwnPropertySymbols:oS}=Object,{hasOwnProperty:iS}=Object.prototype;function eo(t,e){return function(r,o,i){return t(r,o,i)&&e(r,o,i)}}function to(t){return function(n,r,o){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,o);let{cache:i}=o,s=i.get(n),l=i.get(r);if(s&&l)return s===r&&l===n;i.set(n,r),i.set(r,n);let a=t(n,r,o);return i.delete(n),i.delete(r),a}}function sS(t){return t?.[Symbol.toStringTag]}function Yh(t){return rS(t).concat(oS(t))}var lS=Object.hasOwn||((t,e)=>iS.call(t,e));function On(t,e){return t===e||!t&&!e&&t!==t&&e!==e}var aS="__v",cS="__o",uS="_owner",dS=typeof Float16Array<"u",{getOwnPropertyDescriptor:Qh,keys:Zh}=Object;function fS(t,e){return t.byteLength===e.byteLength&&yi(new Uint8Array(t),new Uint8Array(e))}function hS(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function pS(t,e){return t.byteLength===e.byteLength&&yi(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function mS(t,e){return On(t.getTime(),e.getTime())}function ep(t,e,n){return t.name===e.name&&t.message===e.message&&t.stack===e.stack&&n.equals(t.cause,e.cause,"cause","cause",t,e,n)}function gS(t,e){return t===e}function tp(t,e,n){let r=t.size;if(r!==e.size)return!1;if(!r)return!0;let o=new Array(r),i=t.entries(),s,l,a=0;for(;(s=i.next())&&!s.done;){let c=e.entries(),u=!1,d=0;for(;(l=c.next())&&!l.done;){if(o[d]){d++;continue}let f=s.value,h=l.value;if(n.equals(f[0],h[0],a,d,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){u=o[d]=!0;break}d++}if(!u)return!1;a++}return!0}var yS=On;function np(t,e,n){let r=Zh(t),o=r.length;if(Zh(e).length!==o)return!1;for(;o-- >0;)if(!ip(t,e,n,r[o]))return!1;return!0}function hr(t,e,n){let r=Yh(t),o=r.length;if(Yh(e).length!==o)return!1;let i,s,l;for(;o-- >0;)if(i=r[o],!ip(t,e,n,i)||(s=Qh(t,i),l=Qh(e,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function bS(t,e){return On(t.valueOf(),e.valueOf())}function kS(t,e){return t.source===e.source&&t.flags===e.flags}function rp(t,e,n){let r=t.size;if(r!==e.size)return!1;if(!r)return!0;let o=new Array(r),i=t.values(),s,l;for(;(s=i.next())&&!s.done;){let a=e.values(),c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!o[u]&&n.equals(s.value,l.value,s.value,l.value,t,e,n)){c=o[u]=!0;break}u++}if(!c)return!1}return!0}function yi(t,e){let n=t.length;if(e.length!==n||t.byteOffset!==e.byteOffset)return!1;if(t instanceof Float64Array||t instanceof Float32Array||dS&&t instanceof Float16Array){for(;n-- >0;)if(t[n]!==e[n]&&(t[n]===t[n]||e[n]===e[n]))return!1;return!0}for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function wS(t,e){return t.href===e.href?!0:t.protocol===e.protocol&&t.username===e.username&&t.password===e.password&&t.host===e.host&&t.pathname===e.pathname&&t.hash===e.hash&&SS(t.searchParams,e.searchParams)}function SS(t,e){let n=t.toString(),r=e.toString();return n===r||op(n)===op(r)}function op(t){return t.split("&").sort().join("&")}function ip(t,e,n,r){return(r===uS||r===cS||r===aS)&&(t.$$typeof||e.$$typeof)?!0:lS(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}var xS="[object ArrayBuffer]",vS="[object Arguments]",CS="[object Boolean]",MS="[object DataView]",ES="[object Date]",TS="[object Error]",AS="[object Map]",NS="[object Number]",OS="[object Object]",RS="[object RegExp]",DS="[object Set]",IS="[object String]",PS={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},LS="[object URL]",zS=Object.prototype.toString;function $S({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:o,areFunctionsEqual:i,areMapsEqual:s,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(m,y,S){if(m===y)return!0;if(m==null||y==null)return!1;let v=typeof m;if(v!==typeof y)return!1;if(v!=="object")return v==="number"?l(m,y,S):v==="function"?i(m,y,S):!1;let M=m.constructor;if(M!==y.constructor)return!1;if(M===Object)return a(m,y,S);if(Array.isArray(m))return e(m,y,S);if(M===Date)return r(m,y,S);if(M===RegExp)return u(m,y,S);if(M===Map)return s(m,y,S);if(M===Set)return d(m,y,S);if(M==null)return a(m,y,S);let E=zS.call(m);if(E===ES)return r(m,y,S);if(E===RS)return u(m,y,S);if(E===AS)return s(m,y,S);if(E===DS)return d(m,y,S);if(E===OS)return typeof m.then!="function"&&typeof y.then!="function"&&a(m,y,S);if(E===LS)return h(m,y,S);if(E===TS)return o(m,y,S);if(E===vS)return a(m,y,S);if(PS[E])return f(m,y,S);if(E===xS)return t(m,y,S);if(E===MS)return n(m,y,S);if(E===CS||E===NS||E===IS)return c(m,y,S);if(p){let L=p[E];if(!L){let N=sS(m);N&&(L=p[N])}if(L)return L(m,y,S)}return!1}}function BS({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:fS,areArraysEqual:n?hr:hS,areDataViewsEqual:pS,areDatesEqual:mS,areErrorsEqual:n?eo(ep,hr):eo(ep,np),areFunctionsEqual:gS,areMapsEqual:n?eo(tp,hr):tp,areNumbersEqual:yS,areObjectsEqual:n?hr:np,arePrimitiveWrappersEqual:bS,areRegExpsEqual:kS,areSetsEqual:n?eo(rp,hr):rp,areTypedArraysEqual:n?eo(yi,hr):yi,areUrlsEqual:wS,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){let o=to(r.areArraysEqual),i=to(r.areErrorsEqual),s=to(r.areMapsEqual),l=to(r.areObjectsEqual),a=to(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:o,areErrorsEqual:i,areMapsEqual:s,areObjectsEqual:l,areSetsEqual:a})}return r}function HS(t){return function(e,n,r,o,i,s,l){return t(e,n,l)}}function FS({circular:t,comparator:e,createState:n,equals:r,strict:o}){if(n)return function(l,a){let{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:o})};if(t)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:o})};let i={cache:void 0,equals:r,meta:void 0,strict:o};return function(l,a){return e(l,a,i)}}var sp=Zt(),FM=Zt({strict:!0}),VM=Zt({circular:!0}),WM=Zt({circular:!0,strict:!0}),_M=Zt({createInternalComparator:()=>On}),jM=Zt({strict:!0,createInternalComparator:()=>On}),KM=Zt({circular:!0,createInternalComparator:()=>On}),UM=Zt({circular:!0,createInternalComparator:()=>On,strict:!0});function Zt(t={}){let{circular:e=!1,createInternalComparator:n,createState:r,strict:o=!1}=t,i=BS(t),s=$S(i),l=n?n(s):HS(s);return FS({circular:e,comparator:s,createState:r,equals:l,strict:o})}var hp=me(Zg(),1);function VS(t,e){var n,r;if(t.isDestroyed||e.defaultPrevented||!e.cancelable||!t.isEditable||e.inputType!=="insertParagraph"&&e.inputType!=="insertLineBreak"||!Nn()&&!Yr())return;let o=t.view,i=o.root,s=(n=(r=i.getSelection)===null||r===void 0?void 0:r.call(i))!==null&&n!==void 0?n:o.dom.ownerDocument.getSelection(),l=s?.anchorNode,a=l?.nodeType===1?l:l?.parentElement,c=a?.closest("[data-node-view-content-react]");if(!c||!o.dom.contains(c))return;let u=o.input.lastKeyCode;u===13&&(o.input.lastKeyCode=null),o.domObserver.forceFlush(),o.domObserver.flush();let d=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",keyCode:13,shiftKey:e.inputType==="insertLineBreak",bubbles:!0,cancelable:!0});o.someProp("handleKeyDown",f=>f(o,d))?(e.preventDefault(),o.input.lastIOSEnter=0,clearTimeout(o.input.lastIOSEnterFallbackTimeout)):u===13&&(o.input.lastKeyCode=u)}var lp=new U("reactMobileEnter"),WS=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},_S=({contentComponent:t})=>{let e=(0,fp.useSyncExternalStore)(t.subscribe,t.getSnapshot,t.getServerSnapshot);return(0,Ie.jsx)(Ie.Fragment,{children:Object.values(e)})};function jS(){let t=new Set,e={},n=!1,r=()=>{n||!t.size||(n=!0,queueMicrotask(()=>{n=!1,t.forEach(o=>o())}))};return{subscribe(o){return t.add(o),()=>{t.delete(o)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(o,i){e={...e,[o]:bi.default.createPortal(i.reactElement,i.element,o)},r()},removeRenderer(o){let i={...e};delete i[o],e=i,r()}}}var KS=class extends K.default.Component{constructor(t){super(t),this.editorContentRef=K.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;let e=this.props.editor;if(e&&!e.isDestroyed&&(!((t=e.view.dom)===null||t===void 0)&&t.parentNode)){if(e.contentComponent)return;let n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=jS(),e.createNodeViews(),e.registerPlugin(new B({key:lp,props:{handleDOMEvents:{beforeinput:(r,o)=>VS(e,o)}}})),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let t=this.props.editor;if(t){t.isEditorContentInitialized=!1,t.isDestroyed||(t.unregisterPlugin(lp),t.view.setProps({nodeViews:{}})),t.contentComponent=null;try{var e;if(!(!((e=t.view.dom)===null||e===void 0)&&e.parentNode))return;let n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){let{editor:t,innerRef:e,...n}=this.props;return(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)("div",{ref:WS(e,this.editorContentRef),...n}),t?.contentComponent&&(0,Ie.jsx)(_S,{contentComponent:t.contentComponent})]})}},US=(0,K.forwardRef)((t,e)=>{let n=K.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return K.default.createElement(KS,{key:n,innerRef:e,...t})}),va=K.default.memo(US),qS=typeof window<"u"?K.useLayoutEffect:K.useEffect,JS=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){let e,n=o=>{o?.transaction!==void 0&&o.transaction===e||(e=o?.transaction,this.transactionNumber+=1,this.subscribers.forEach(i=>i()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function ki(t){var e;let[n]=(0,K.useState)(()=>new JS(t.editor)),r=(0,hp.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:sp);return qS(()=>n.watch(t.editor),[t.editor,n]),(0,K.useDebugValue)(r),r}var GS=typeof window>"u",ZM=GS||!!(typeof window<"u"&&window.next);var pp=(0,K.createContext)({editor:null}),eE=pp.Consumer;var mp=(0,K.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});var gp=()=>(0,K.useContext)(mp);function Ca({as:t="div",...e}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=gp();return(0,Ie.jsx)(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var no=K.default.forwardRef((t,e)=>{let{onDragStart:n}=gp(),r=t.as||"div";return(0,Ie.jsx)(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function ap(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function cp(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function XS(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function YS(t){if(ap(t)||cp(t))return!0;if(XS(t)){let e=t.type;if(e)return ap(e)||cp(e)}return!1}function QS(){try{if(K.version)return parseInt(K.version.split(".")[0],10)>=19}catch{}return!1}var ZS=class{constructor(t,{editor:e,props:n={},as:r="div",className:o=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isEditorContentInitialized?(0,bi.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;let e=this.component,n=this.props,r=this.editor,o=QS(),i=YS(e),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=(0,Ie.jsx)(e,{...s}),r==null||(t=r.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let o=n[r];if(t[o]!==this.props[o]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;let e=this.editor;e==null||(t=e.contentComponent)===null||t===void 0||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}},tE=K.default.createContext({markViewContentRef:()=>{}});function e1(t){var e;let n=t.getRootNode(),r=typeof n.getSelection=="function"?n.getSelection():(e=t.ownerDocument)===null||e===void 0||(e=e.defaultView)===null||e===void 0?void 0:e.getSelection();if(!r||r.rangeCount===0)return null;let{anchorNode:o,anchorOffset:i,focusNode:s,focusOffset:l}=r;return!o||!s||!t.contains(o)||!t.contains(s)?null:()=>{try{r.setBaseAndExtent(o,i,s,l)}catch{}}}function t1(t,e,n){return t.node(n)===e.node(n)&&t.before(n)===e.before(n)}function yp(t){if(!di(t))return[];let{$from:e,$to:n}=t,r=[],o=Math.min(e.depth,n.depth);for(let i=1;i<=o&&t1(e,n,i);i+=1)r.push(e.before(i));return r}var n1=class{constructor(t){this.views=new WeakMap,this.viewCount=0,this.insideViews=new Set,this.syncQueued=!1,this.scheduleSync=()=>{this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.sync()}))},this.handleTransaction=()=>this.scheduleSync(),this.editor=t}register(t){this.viewCount===0&&this.editor.on("transaction",this.handleTransaction),this.views.set(t.dom,t),this.viewCount+=1,this.scheduleSync()}unregister(t){this.views.delete(t.dom),this.viewCount-=1,this.insideViews.delete(t),this.viewCount===0&&this.editor.off("transaction",this.handleTransaction)}sync(){if(this.viewCount===0||this.editor.isDestroyed)return;let t=this.findInsideViews();this.updateViews(this.insideViews,t,!1),this.updateViews(t,this.insideViews,!0),this.insideViews=t}updateViews(t,e,n){for(let r of t)e.has(r)||r.setSelectionInside(n)}findInsideViews(){let t=new Set;for(let e of yp(this.editor.state.selection)){let n=this.editor.view.nodeDOM(e),r=n?this.views.get(n):void 0;r&&t.add(r)}return t}},up=new WeakMap;function dp(t){let e=up.get(t);return e||(e=new n1(t),up.set(t,e)),e}var r1=class extends Xh{constructor(t,e,n){if(super(t,e,n),this.nodeSelected=!1,this.handlePositionUpdate=()=>{let r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";let r=this.dom.querySelector("[data-node-view-content]");r?r.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,o){if(r==="storage"){var i;return(i=t.storage[e.name])!==null&&i!==void 0?i:{}}return Reflect.get(n,r,o)}})}return this.cachedExtensionWithSyncedStorage}mount(){let t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,selectionInside:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:(0,K.createRef)()};if(!this.component.displayName){let a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}let r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{if(a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement){a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper");let c=e1(this.contentDOMElement);a.appendChild(this.contentDOMElement),c?.()}}},o=this.component,i=(0,K.memo)(a=>(0,Ie.jsx)(mp.Provider,{value:r,children:(0,K.createElement)(o,a)}));i.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);let{className:l=""}=this.options;this.renderer=new ZS(i,{editor:this.editor,props:t,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),dp(this.editor).register(this),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!(!((t=this.renderer.element.firstElementChild)===null||t===void 0)&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}update(t,e,n){let r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){let s=this.node,l=this.decorations,a=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:s,oldDecorations:l,newNode:t,newDecorations:e,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(t===this.node)return this.node=t,this.decorations=e,this.innerDecorations=n,!0;let o=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=o;let i={node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(i.getPos=()=>this.getPos()),r(i),!0}selectNode(){this.nodeSelected=!0,this.updateSelectedState(!0)}deselectNode(){this.nodeSelected=!1,this.updateSelectedState(this.options.selectedOnTextSelection===!0&&this.isTextSelectionInside())}setSelectionInside(t){let e=this.nodeSelected||this.options.selectedOnTextSelection===!0&&t;this.renderer.updateProps({selectionInside:t,selected:e}),this.renderer.element.classList.toggle("ProseMirror-selectednode",e)}updateSelectedState(t){this.renderer.updateProps({selected:t}),this.renderer.element.classList.toggle("ProseMirror-selectednode",t)}isTextSelectionInside(){let t=this.getPos();return typeof t=="number"&&yp(this.editor.state.selection).includes(t)}destroy(){this.renderer.destroy(),dp(this.editor).unregister(this),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){let e=this.editor.extensionManager.attributes,n=pt(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function ro(t,e){return n=>n.editor.contentComponent?new r1(t,n,e):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var Ma=(0,K.createContext)({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Ma.displayName="TiptapContext";var o1=()=>(0,K.useContext)(Ma);function bp({children:t,...e}){let n="editor"in e?e.editor:e.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,K.useMemo)(()=>({editor:n}),[n]),o=(0,K.useMemo)(()=>({editor:n}),[n]);return(0,Ie.jsx)(pp.Provider,{value:o,children:(0,Ie.jsx)(Ma.Provider,{value:r,children:t})})}bp.displayName="Tiptap";function kp({...t}){let{editor:e}=o1();return(0,Ie.jsx)(va,{editor:e,...t})}kp.displayName="Tiptap.Content";var nE=Object.assign(bp,{Content:kp});var Fe=me(vr(),1);var i1=new WeakSet,wp=t=>i1.has(t);var s1=(0,Fe.createContext)(null);function Sp(t){let e=(0,Fe.useContext)(s1),n=(0,Fe.useId)(),r=(0,Fe.useRef)(t.retentionKey??n).current,o=(0,Fe.useRef)(t);o.current=t;let i=(0,Fe.useRef)(e?.find(r)??null),[s,l]=(0,Fe.useState)(i.current),a=(0,Fe.useRef)(void 0);return(0,Fe.useLayoutEffect)(()=>{clearTimeout(a.current);let c=()=>{let{retentionKey:d,immediatelyRender:f,shouldRerenderOnTransaction:h,...p}=o.current;return new xa({...p,onUpdate:g=>o.current.onUpdate?.(g),editorProps:{...p.editorProps,handleKeyDown:(g,m)=>o.current.editorProps?.handleKeyDown?.(g,m)??!1,handleClick:(g,m,y)=>o.current.editorProps?.handleClick?.(g,m,y)??!1,handlePaste:(g,m,y)=>o.current.editorProps?.handlePaste?.(g,m,y)??!1}})},u=e?e.get(r,c):i.current&&!i.current.isDestroyed?i.current:c();return i.current=u,u.setEditable(o.current.editable!==!1,!1),l(u),()=>{u.isDestroyed||u.setEditable(!1,!1),!e&&(a.current=setTimeout(()=>{i.current===u&&!u.isDestroyed&&u.destroy()},1))}},[e,r]),s}var Ea=new WeakMap;function Ta(t){let e=Ea.get(t);if(e)return e;let n={type:t.type.name};return Object.keys(t.attrs).length&&(n.attrs=t.attrs),t.content.size&&(n.content=[],t.content.forEach(r=>n.content.push(Ta(r)))),t.marks.length&&(n.marks=t.marks.map(r=>r.toJSON())),t.isText&&(n.text=t.text),Ea.set(t,n),n}function xp(t,e){let n=Ea.get(t);if(n===e)return!0;if(!n||n.type!==e.type||n.text!==e.text||n.attrs!==e.attrs&&JSON.stringify(n.attrs)!==JSON.stringify(e.attrs)||n.marks!==e.marks&&JSON.stringify(n.marks)!==JSON.stringify(e.marks)||t.childCount!==(e.content?.length??0))return!1;for(let r=0;r<t.childCount;r++)if(!xp(t.child(r),e.content[r]))return!1;return!0}function vp(t,e){if(e.type!==t.type.name||t.childCount!==(e.content?.length??0))return!1;for(let n=0;n<t.childCount;n++)if(!xp(t.child(n),e.content[n]))return!1;return!0}function Cp(t,e,n){let r=[],o=[];return t.nodesBetween(e,n,(i,s,l)=>{let a=i.attrs?.id;if(!(typeof a!="string"||a.startsWith("page-tail-")))if(i.isTextblock){let c=s+1,u=c+i.content.size;(Math.max(e,c)<Math.min(n,u)||i.content.size===0&&e<=s&&n>=s+i.nodeSize)&&r.push(a)}else l===t&&o.push(a)}),[...new Set(r.length?r:o)].slice(0,100)}var be=class t extends R{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):R.near(r)}content(){return A.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Aa(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!l1(e)||!a1(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!D.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};be.prototype.visible=!1;be.findFrom=be.findGapCursorFrom;R.jsonID("gapcursor",be);var Aa=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return be.valid(n)?new be(n):R.near(n)}};function Mp(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function l1(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Mp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function a1(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Mp(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Ep(){return new B({props:{decorations:f1,createSelectionBetween(t,e,n){return e.pos==n.pos&&be.valid(n)?new be(n):null},handleClick:u1,handleKeyDown:c1,handleDOMEvents:{beforeinput:d1}}})}var c1=Jr({ArrowLeft:wi("horiz",-1),ArrowRight:wi("horiz",1),ArrowUp:wi("vert",-1),ArrowDown:wi("vert",1)});function wi(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof O){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=be.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new be(c))),!0):!1}}function u1(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!be.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&D.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new be(r))),!0)}function d1(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof be))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=x.empty;for(let s=r.length-1;s>=0;s--)o=x.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new A(o,0,0));return i.setSelection(O.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function f1(t){if(!(t.selection instanceof be))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Z.create(t.doc,[ye.widget(t.selection.head,e,{key:"gapcursor"})])}function Si(t){let e=t.selection;if(!(e instanceof D)||e.node.type.name!=="widget")return null;let n=R.findFrom(e.$to,1,!0)??R.findFrom(e.$from,-1,!0),r=n?null:new be(t.doc.resolve(t.doc.content.size)).map(t.doc,new pn),o=n??(r instanceof be?r:null);return o?t.tr.setSelection(o).setMeta("addToHistory",!1):null}function Tp(t,e){if(vp(t.doc,e))return null;let n=t.schema.nodeFromJSON(e),r=t.doc.content.findDiffStart(n.content);if(r===null)return null;let o=t.doc.content.findDiffEnd(n.content),i=o.a,s=o.b,l=r-Math.min(i,s);return l>0&&(i+=l,s+=l),t.tr.replace(r,i,n.slice(r,s)).setMeta("addToHistory",!1).setMeta("preventUpdate",!0)}var Oa,Ra;if(typeof WeakMap<"u"){let t=new WeakMap;Oa=e=>t.get(e),Ra=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Oa=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Ra=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var ne=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,o=e/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){let{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){let{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width,l=(t+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(t){return Oa(t)||Ra(t,h1(t))}};function h1(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=p1(t),n=t.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;let g=d.child(p),{colspan:m,rowspan:y,colwidth:S}=g.attrs;for(let v=0;v<y;v++){if(v+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-v});break}let M=o+v*e;for(let E=0;E<m;E++){r[M+E]==0?r[M+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:m-E});let L=S&&S[E];if(L){let N=(M+E)%e*2,_=s[N];_==null||_!=L&&s[N+1]==1?(s[N]=L,s[N+1]=1):_==L&&s[N+1]++}}}o+=m,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new ne(e,n,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&m1(l,s,t),l}function p1(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let o=t.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=t.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function m1(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o<t.map.length;o++){let i=t.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let u=e[(o+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=g1(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function g1(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Pe(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var en=new U("selectingCells");function It(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function y1(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function lt(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Ti(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=It(e.$head)||b1(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function b1(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Da(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function k1(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function La(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function $p(t,e,n){let r=t.node(-1),o=ne.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Rn(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Bp(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function w1(t,e,n){let r=Pe(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var q=class Dt extends R{constructor(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new qn(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(Da(r)&&Da(o)&&La(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Dt.rowSelection(r,o):i&&this.isColSelection()?Dt.colSelection(r,o):new Dt(r,o)}return O.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=ne.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*n.width+o.left,d=o.left;d<o.right;d++,u++){let f=n.map[u];if(i[f])continue;i[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let g=o.left-h.left,m=h.right-o.right;if(g>0||m>0){let y=p.attrs;if(g>0&&(y=Rn(y,0,g)),m>0&&(y=Rn(y,y.colspan-m,m)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(x.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new A(x.from(l),1,1)}replace(e,n=A.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?A.empty:n)}let i=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new A(x.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=ne.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Dt(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=ne.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof Dt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new Dt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Dt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Dt(e.resolve(n),e.resolve(r))}getBookmark(){return new S1(this.$anchorCell.pos,this.$headCell.pos)}};q.prototype.visible=!1;R.jsonID("cell",q);var S1=class Hp{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Hp(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&La(n,r)?new q(n,r):R.near(r,1)}};function x1(t){if(!(t.selection instanceof q))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ye.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Z.create(t.doc,e)}function v1({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function C1({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function M1(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof D&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=q.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=q.rowSelection(l,l)}else if(!n){let l=ne.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=q.create(o,a+1,c)}}else r instanceof O&&v1(r)?i=O.create(o,r.from):r instanceof O&&C1(r)&&(i=O.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var E1=new U("fix-tables");function Fp(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&t.child(l).sameMarkup(a)?Fp(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function za(t,e){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=T1(t,o,i,n))};return e?e.doc!=t.doc&&Fp(e.doc,t.doc,0,r):t.doc.descendants(r),n}function T1(t,e,n,r){let o=ne.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Rn(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let m=0;m<f;m++){let y=Pe(t.schema)[h].createAndFill();y&&p.push(y)}let g=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(E1,{fixTables:!0})}function mt(t){let e=t.selection,n=Ti(t),r=n.node(-1),o=n.start(-1),i=ne.get(r);return{...e instanceof q?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Vp(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;w1(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,Bp(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?Pe(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function Wp(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(Vp(t.tr,n,n.left))}return!0}function _p(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(Vp(t.tr,n,n.right))}return!0}function A1(t,{map:e,table:n,tableStart:r},o){let i=t.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Rn(u,o-e.colCount(a)));else{let d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}s+=u.rowspan}}function jp(t,e){if(!lt(t))return!1;if(e){let n=mt(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;A1(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ne.get(i)}e(r)}return!0}function N1(t,e,n){var r;let o=Pe(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function Kp(t,{map:e,tableStart:n,table:r},o){let i=n;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;N1(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?Pe(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&s.push(f)}return t.insert(i,Pe(r.type.schema).row.create(null,s)),t}function Up(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(Kp(t.tr,n,n.top))}return!0}function qp(t,e){if(!lt(t))return!1;if(e){let n=mt(t);e(Kp(t.tr,n,n.bottom))}return!0}function O1(t,{map:e,table:n,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=n.child(c).nodeSize;let s=i+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(i+r,s+r);let a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){let f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=h.colspan-1}}}}function Jp(t,e){if(!lt(t))return!1;if(e){let n=mt(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;O1(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ne.get(n.table)}e(r)}return!0}function Ap(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function R1({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function $a(t,e){let n=t.selection;if(!(n instanceof q)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=mt(t),{map:o}=r;if(R1(o,r))return!1;if(e){let i=t.tr,s={},l=x.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,a==null)a=f,c=h;else{Ap(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Bp(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=Ap(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new q(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Ba(t,e){let n=Pe(t.schema);return D1(({node:r})=>n[r.type.spec.tableRole])(t,e)}function D1(t){return(e,n)=>{let r=e.selection,o,i;if(r instanceof q){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=y1(r.$from),!o)return!1;i=(s=It(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=mt(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=o.nodeSize);for(let g=u.left,m=0;g<u.right;g++,m++)g==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:o,row:h,col:g}).createAndFill(a[m]))}d.setNodeMarkup(i,t({node:o,row:u.top,col:u.left}),a[0]),r instanceof q&&d.setSelection(new q(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function Gp(t,e){return function(n,r){if(!lt(n))return!1;let o=Ti(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){let i=n.tr;n.selection instanceof q?n.selection.forEachCell((s,l)=>{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function I1(t){return function(e,n){if(!lt(e))return!1;if(n){let r=Pe(e.schema),o=mt(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Np(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){let i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function pr(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?I1(t):function(n,r){if(!lt(n))return!1;if(r){let o=Pe(n.schema),i=mt(n),s=n.tr,l=Np("row",i,o),a=Np("column",i,o),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?o.cell:o.header_cell:t=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(f=>{let h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,d,p.attrs)}),r(s)}return!0}}var IE=pr("row",{useDeprecatedLogic:!0}),PE=pr("column",{useDeprecatedLogic:!0}),Xp=pr("cell",{useDeprecatedLogic:!0});function P1(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function Ha(t){return function(e,n){if(!lt(e))return!1;let r=P1(Ti(e),t);if(r==null)return!1;if(n){let o=e.doc.resolve(r);n(e.tr.setSelection(O.between(o,k1(o))).scrollIntoView())}return!0}}function Yp(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function xi(t,e){let n=t.selection;if(!(n instanceof q))return!1;if(e){let r=t.tr,o=Pe(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new A(o,0,0))}),r.docChanged&&e(r)}return!0}function L1(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Ia(Pe(s).row,new A(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Ia(Pe(s).row,new A(e,n,r)).content:e);else return null;return z1(s,l)}function z1(t,e){let n=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(x.empty),n[o]<r){let i=Pe(t).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);e[o]=e[o].append(x.from(s))}return{height:e.length,width:r,rows:e}}function Ia(t,e){let n=t.createAndFill();return new jt(n).replace(0,n.content.size,e).doc}function $1({width:t,height:e,rows:n},r,o){if(t!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Rn(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(x.from(c))}n=s,t=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(x.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function B1(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=Pe(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let m=e.width;m<o;m++)p.push(g);t.insert(t.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let m=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(m?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,x.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),h)}return!!(c||u)}function Op(t,e,n,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function Rp(t,e,n,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Rn(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Rn(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Dp(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=ne.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=t.tr,f=0;function h(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");s=ne.get(i),f=d.mapping.maps.length}B1(d,s,i,n,c,u,f)&&h(),Op(d,s,i,n,a,c,l,f)&&h(),Op(d,s,i,n,a,c,u,f)&&h(),Rp(d,s,i,n,l,u,a,f)&&h(),Rp(d,s,i,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=s.positionAt(p,a,i),m=s.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(m+n),new A(o.rows[p-l],0,0))}h(),d.setSelection(new q(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(u-1,c-1,i)))),e(d)}var H1=Jr({ArrowLeft:vi("horiz",-1),ArrowRight:vi("horiz",1),ArrowUp:vi("vert",-1),ArrowDown:vi("vert",1),"Shift-ArrowLeft":Ci("horiz",-1),"Shift-ArrowRight":Ci("horiz",1),"Shift-ArrowUp":Ci("vert",-1),"Shift-ArrowDown":Ci("vert",1),Backspace:xi,"Mod-Backspace":xi,Delete:xi,"Mod-Delete":xi});function Mi(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function vi(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof q)return Mi(n,r,R.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let s=Qp(o,t,e);if(s==null)return!1;if(t=="horiz")return Mi(n,r,R.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=$p(l,t,e),c;return a?c=R.near(a,1):e<0?c=R.near(n.doc.resolve(l.before(-1)),-1):c=R.near(n.doc.resolve(l.after(-1)),1),Mi(n,r,c)}}}function Ci(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof q)s=i;else{let a=Qp(o,t,e);if(a==null)return!1;s=new q(n.doc.resolve(a))}let l=$p(s.$headCell,t,e);return l?Mi(n,r,new q(s.$anchorCell,l)):!1}}function F1(t,e){let n=t.state.doc,r=It(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new q(r))),!0):!1}function V1(t,e,n){if(!lt(t.state))return!1;let r=L1(n),o=t.state.selection;if(o instanceof q){r||(r={width:1,height:1,rows:[x.from(Ia(Pe(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ne.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=$1(r,l.right-l.left,l.bottom-l.top),Dp(t.state,t.dispatch,s,l,r),!0}else if(r){let i=Ti(t.state),s=i.start(-1);return Dp(t.state,t.dispatch,s,ne.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function W1(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Ip(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof q)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=It(t.state.selection.$anchor))!=null&&((n=Na(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let u=Na(t,c),d=en.getState(t.state)==null;if(!u||!La(a,u))if(d)u=a;else return;let f=new q(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(en,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),en.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(en,-1))}function l(a){let c=a,u=en.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(Ip(t,c.target)!=r&&(d=Na(t,e),!d))return s();d&&i(d,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Qp(t,e,n){if(!(t.state.selection instanceof O))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function Ip(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Na(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&It(t.state.doc.resolve(r))||It(t.state.doc.resolve(o))}var _1=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Pa(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Pa(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Pa(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g++,f++){let m=o==f?i:p&&p[g],y=m?m+"px":"";if(s+=m||r,m||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let S=document.createElement("col");S.style.width=y,e.appendChild(S)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var Je=new U("tableColumnResizing");function Zp({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=_1,lastColumnResizable:o=!0}={}){let i=new B({key:Je,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=Pe(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new j1(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Je.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{K1(s,l,t,o)},mouseleave:s=>{U1(s)},mousedown:(s,l)=>{q1(s,l,e,n)}},decorations:s=>{let l=Je.getState(s);if(l&&l.activeHandle>-1)return Q1(s,l.activeHandle)},nodeViews:{}}});return i}var j1=class Ei{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Je);if(r&&r.setHandle!=null)return new Ei(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ei(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return Da(e.doc.resolve(o))||(o=-1),new Ei(o,n.dragging)}return n}};function K1(t,e,n,r){if(!t.editable)return;let o=Je.getState(t.state);if(o&&!o.dragging){let i=G1(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=Pp(t,e,"left",n):a-e.clientX<=n&&(s=Pp(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=ne.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}em(t,s)}}}function U1(t){if(!t.editable)return;let e=Je.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&em(t,-1)}function q1(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Je.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=J1(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Je,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);let f=Je.getState(t.state);f?.dragging&&(X1(t,f.activeHandle,Lp(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Je,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Je.getState(t.state);if(f&&f.dragging){let h=Lp(f.dragging,d,n);zp(t,f.activeHandle,h,r)}}return zp(t,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function J1(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function G1(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Pp(t,e,n,r){let o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=It(t.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=ne.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Lp(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function em(t,e){t.dispatch(t.state.tr.setMeta(Je,{setHandle:e}))}function X1(t,e,n){let r=t.state.doc.resolve(e),o=r.node(-1),i=ne.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],f=o.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():Y1(f.colspan);p[h]=n,a.setNodeMarkup(s+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function zp(t,e,n,r){let o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=ne.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Pa(i,a.firstChild,a,r,l,n)}function Y1(t){return Array(t).fill(0)}function Q1(t,e){let n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Z.empty;let i=ne.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let d=i.map[u],f=s+d+o.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Je.getState(t))===null||a===void 0)&&a.dragging&&n.push(ye.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(ye.widget(f,h))}}return Z.create(t.doc,n)}function tm({allowTableNodeSelection:t=!1}={}){return new B({key:en,state:{init(){return null},apply(e,n){let r=e.getMeta(en);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:x1,handleDOMEvents:{mousedown:W1},createSelectionBetween(e){return en.getState(e.state)!=null?e.state.selection:null},handleTripleClick:F1,handleKeyDown:H1,handlePaste:V1},appendTransaction(e,n,r){return M1(r,za(r,n),t)}})}var Dn="showaiTableAction";function nm(t,e,n){let r=t.doc.nodeAt(e);if(r?.type.name!=="table")return null;let o=t.selection instanceof q?t.selection.$headCell:It(t.selection.$head),i=o&&o.before(-1)===e?o:t.doc.resolve(e+1+ne.get(r).map[0]),s=n==="row"?q.rowSelection(i):n==="column"?q.colSelection(i):new q(i);return t.tr.setSelection(s)}function oo(t){let e=t.selection;if(!(e instanceof q))return null;let n=e.$anchorCell.node(-1),r=e.$anchorCell.start(-1),o=ne.get(n).rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r);return{tablePosition:r-1,rows:o.bottom-o.top,columns:o.right-o.left}}function rm(t,e){let n=e.$anchorCell.nodeAfter?.attrs.id,r=e.$headCell.nodeAfter?.attrs.id;if(!n||!r)return null;let o,i;if(t.descendants((a,c)=>{["tableCell","tableHeader"].includes(a.type.name)&&(a.attrs.id===n&&(o=c),a.attrs.id===r&&(i=c))}),o===void 0&&i===void 0||(o??=i,i??=o,o===void 0||i===void 0))return null;let s=t.resolve(o),l=t.resolve(i);return s.node(-1)!==l.node(-1)?null:new q(s,l)}var Ge=me(kt(),1);function Ai({editor:t,context:e=!1,onAction:n}){let r=ct(Le),o=oo(t.state);if(!o&&!e&&!t.can().splitCell())return null;let i=s=>{t.view.dispatch(er(t.state.tr)),t.chain().setMeta(Dn,!0).focus()[s]().run(),n?.()};return(0,Ge.jsxs)(Ge.Fragment,{children:[!e&&(0,Ge.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,Ge.jsxs)("div",{className:"editor-table-actions",role:"group","aria-label":r("table.cellActions"),children:[o&&(0,Ge.jsx)("span",{className:"editor-menu-status",role:"status",children:o.rows===1&&o.columns===1?r("table.shiftClickHint"):r("table.selectedCells",{rows:o.rows,columns:o.columns})}),[["mergeCells",r("table.mergeCells"),su],["splitCell",r("table.splitCell"),lu]].map(([s,l,a])=>(0,Ge.jsxs)("button",{type:"button",className:"editor-tool",role:e?"menuitem":void 0,"aria-label":l,title:l,disabled:!t.can()[s](),onMouseDown:c=>c.preventDefault(),onClick:()=>i(s),children:[(0,Ge.jsx)(a,{size:16}),e&&(0,Ge.jsx)("span",{children:l})]},s)),!e&&o&&(0,Ge.jsx)("button",{type:"button",className:"editor-tool","aria-label":r("table.clearSelection"),title:r("table.clearSelection"),onMouseDown:s=>s.preventDefault(),onClick:()=>{t.view.dispatch(t.state.tr.setSelection(O.near(t.state.selection.$from))),t.view.focus()},children:(0,Ge.jsx)(Cr,{size:16})})]})]})}var io=me(vr(),1),am=me($s(),1);var om=Fn(Le),im=G.create({name:"tableAlignment",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textAlign:{default:null,parseHTML:t=>["left","center","right"].includes(t.style.textAlign)?t.style.textAlign:null,renderHTML:t=>["left","center","right"].includes(String(t.textAlign))?{style:`text-align: ${t.textAlign}`}:{}}}}]},addProseMirrorPlugins(){let t=this.editor;return[new B({appendTransaction(e,n,r){if(!t.isEditable||!e.some(i=>i.docChanged))return null;let o=r.tr;return r.doc.descendants((i,s)=>{if(i.type.name!=="table")return;let l=ne.get(i),a=Array.from({length:l.width},(c,u)=>{let d=new Set(Array.from({length:l.height},(f,h)=>i.nodeAt(l.map[h*l.width+u])?.attrs.textAlign).filter(Boolean));return d.size===1?[...d][0]:i.attrs.textAlign});Z1(i,s,(c,u)=>{if(c.attrs.textAlign)return;let d=l.findCell(u-s-1),f=new Set(a.slice(d.left,d.right)),h=f.size===1?[...f][0]:i.attrs.textAlign;h&&o.setNodeAttribute(u,"textAlign",h)})}),o.docChanged?o.setMeta("addToHistory",!1):null}})]}});function Z1(t,e,n){t.forEach((r,o)=>r.forEach((i,s)=>n(i,e+2+o+s)))}function Fa(t,e){let r=sm(t,e).map(o=>t.nodeAt(o)?.attrs.textAlign??t.attrs.textAlign??"left");return r.every(o=>o===r[0])?r[0]??"left":null}function sm(t,e){let n=ne.get(t);if(e!==null&&(!Number.isInteger(e)||e<0||e>=n.width))throw new Error(om("table.columnOutOfRange"));return[...new Set(e===null?n.map:Array.from({length:n.height},(r,o)=>n.map[o*n.width+e]))]}function lm(t,e,n,r){let o=t.doc.nodeAt(e);if(!o||o.type.name!=="table")throw new Error(om("table.notATable"));let i=t.tr;n===null&&i.setNodeAttribute(e,"textAlign",r);for(let s of sm(o,n)){let l=e+1+s,a=t.doc.nodeAt(l);i.setNodeAttribute(l,"textAlign",r),a.descendants((c,u)=>{if(c.type.name==="table")return!1;["paragraph","heading"].includes(c.type.name)&&c.attrs.textAlign&&i.setNodeAttribute(l+1+u,"textAlign",null)})}return i}var ee=me(kt(),1),ex=t=>!t.closest(".document-widget");function cm({editor:t}){let e=ct(Le),[,n]=(0,io.useState)(0),[r,o]=(0,io.useState)(!1),i=oo(t.state),{target:s,setTarget:l,owner:a}=yu(t.view.dom,{keepOpen:r,accept:ex,onDismiss:()=>o(!1)});if((0,io.useEffect)(()=>{let E=()=>n(N=>N+1),L=N=>{N.key!=="Escape"||!oo(t.state)||!t.view.hasFocus()&&document.activeElement?.closest("[data-table-controls-owner]")?.getAttribute("data-table-controls-owner")!==a||(t.view.dispatch(t.state.tr.setSelection(O.near(t.state.selection.$from))),o(!1),t.view.focus())};return t.on("transaction",E),document.addEventListener("keydown",L),()=>{t.off("transaction",E),document.removeEventListener("keydown",L)}},[t,a]),!s||!s.table.isConnected||!t.isEditable||!s.context&&(i||t.isFocused&&t.state.selection instanceof O&&!t.state.selection.empty))return null;let c=t.state.doc.resolve(t.view.posAtDOM(s.table,0)),u=c.depth;for(;u>0&&c.node(u).type.name!=="table";)u--;if(!u)return null;let d=c.node(u),f=c.before(u),h=null;if(s.cell?.isConnected){let E=t.view.posAtDOM(s.cell,0),L=t.state.doc.resolve(E),N=L.depth;for(;N>u&&!["tableCell","tableHeader"].includes(L.node(N).type.name);)N--;N>u&&(h=ne.get(d).findCell(L.before(N)-f-1).left)}let p=bu(s,128),g=p.global.top>window.innerHeight/2,m=()=>{let{$from:E}=t.state.selection;Array.from({length:E.depth},(N,_)=>_+1).some(N=>E.node(N).type.name==="table"&&E.before(N)===f)||t.view.dispatch(t.state.tr.setSelection(O.near(t.state.doc.resolve(f+3))))},y=E=>{m(),t.view.dispatch(er(t.state.tr)),E(),o(!1)},S=()=>t.chain().setMeta(Dn,!0).focus(),v=E=>y(()=>{let L=nm(t.state,f,E);L&&t.view.dispatch(L),t.view.focus()}),M=(E,L)=>{t.view.dispatch(lm(t.state,f,E,L).setMeta(Dn,!0)),s.context&&(l(null),t.view.focus())};return(0,am.createPortal)((0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("div",{className:"document-table-controls table-global-alignment","data-editor-menu-trigger":s.context?"context":"hover",role:s.context?"dialog":void 0,"aria-label":e("table.alignment"),"data-table-controls-owner":a,style:p.global,children:[(0,ee.jsx)(Fs,{scope:"table",value:Fa(d,null),onChange:E=>M(null,E)}),!s.context&&(0,ee.jsx)("button",{className:"document-table-menu-trigger",type:"button","aria-label":e("table.actions"),title:e("table.actions"),"aria-expanded":r,"aria-haspopup":"menu",onMouseDown:E=>E.preventDefault(),onClick:()=>{m(),o(!r)},children:(0,ee.jsx)(Kc,{size:16})}),(r||s.context)&&(0,ee.jsxs)("div",{className:"document-table-menu",role:"menu","aria-label":e("table.actionsMenu"),style:{...g?{top:"auto",bottom:"calc(100% + 4px)"}:{},maxHeight:Math.max(120,g?p.global.top-12:window.innerHeight-p.global.top-46),overflowY:"auto"},onMouseDown:E=>E.preventDefault(),children:[(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().addRowAfter().run()}),children:[(0,ee.jsx)(Wt,{size:14}),e("table.addRow")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().addColumnAfter().run()}),children:[(0,ee.jsx)(Wt,{size:14}),e("table.addColumn")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().toggleHeaderRow().run()}),children:[(0,ee.jsx)(au,{size:14,"aria-hidden":"true"}),e("table.toggleHeader")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>v("cell"),children:[(0,ee.jsx)(ou,{size:14,"aria-hidden":"true"}),e("table.selectCells")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>v("row"),children:[(0,ee.jsx)(Is,{size:14,"aria-hidden":"true"}),e("table.selectRow")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>v("column"),children:[(0,ee.jsx)(Ds,{size:14,"aria-hidden":"true"}),e("table.selectColumn")]}),s.context&&(0,ee.jsx)(Ai,{editor:t,context:!0,onAction:()=>{l(null),o(!1)}}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().deleteRow().run()}),children:[(0,ee.jsx)(Is,{size:14,"aria-hidden":"true"}),e("table.deleteRow")]}),(0,ee.jsxs)("button",{role:"menuitem",onClick:()=>y(()=>{S().deleteColumn().run()}),children:[(0,ee.jsx)(Ds,{size:14,"aria-hidden":"true"}),e("table.deleteColumn")]}),(0,ee.jsxs)("button",{role:"menuitem",className:"danger",onClick:()=>y(()=>{S().deleteTable().run(),l(null)}),children:[(0,ee.jsx)(Eo,{size:14}),e("table.deleteTable")]})]})]}),h!==null&&!s.context&&(0,ee.jsx)("div",{className:"document-table-controls table-column-alignment","data-table-controls-owner":a,style:p.column,children:(0,ee.jsx)(Fs,{scope:h,value:Fa(d,h),onChange:E=>M(h,E)})})]}),document.body)}var um=new WeakSet,dm=new WeakSet;function In(t){let e=t;return um.add(e),e}function Va(t){return Array.isArray(t)&&um.has(t)}function fm(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&dm.has(e)&&!Va(e)?fm(e):[e])}function tx(t,e){if(t==="slot")return 0;if(t instanceof Function){let o=t(e);return Array.isArray(o)&&!Va(o)&&!dm.has(o)?In(o):o}let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(Va(n))return In([t,r,n]);if(n.length===0)return In([t,r]);let o=fm(n);return o.length===0?In([t,r]):In([t,r,...o])}return n!=null?In([t,r,n]):In([t,r])}var mr=(t,e)=>tx(t,e);var nx=(t,e)=>{var n;let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0)return!1;let s=i.depth-1;if(s<0)return!1;let l=i.node(s),a=i.index(s);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let u=i.before()-1-1;return t.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;let h=i.parent.content,p=new A(h,0,0);return d.replace(u,i.after(),p),d.setSelection(O.create(d.doc,u+h.size)),d.scrollIntoView(),f(d),!0})},rx=/^\s*>\s$/,hm=X.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return mr("blockquote",{...H(this.options.HTMLAttributes,t),children:mr("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((o,i)=>{var s,l;let a=((s=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,o,i))!==null&&s!==void 0?s:e.renderChildren([o])).split(`
99
99
  `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
100
100
  `))}),r.join(`
101
101
  ${n}
102
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>nx(this.editor,this.type)}},addInputRules(){return[Qt({find:rx,type:this.type})]}});var ox=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,ix=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,sx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,lx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,hm=Te.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return mr("strong",{...H(this.options.HTMLAttributes,t),children:mr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ke({find:ox,type:this.type}),Ke({find:sx,type:this.type})]},addPasteRules(){return[He({find:ix,type:this.type}),He({find:lx,type:this.type})]}});var ax=t=>{let e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},cx=t=>{let e=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function ux(t){let e=new Set((t.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;e.has(n);)n+=1;return n}var pm=Te.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return"";let o=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",i="`".repeat(ux(o)),s=o.startsWith("`")||o.endsWith("`")?" ":"";return`${i}${s}${e.renderChildren(t.content)}${s}${i}`},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ke({find:ax,type:this.type})]},addPasteRules(){return[He({find:cx,type:this.type})]}});var Wa=4,dx=/^```([a-z]+)?[\s\n]$/,fx=/^~~~([a-z]+)?[\s\n]$/,mm=X.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Wa,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",H(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="",o=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(`
102
+ `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>nx(this.editor,this.type)}},addInputRules(){return[Qt({find:rx,type:this.type})]}});var ox=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,ix=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,sx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,lx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,pm=Te.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return mr("strong",{...H(this.options.HTMLAttributes,t),children:mr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ke({find:ox,type:this.type}),Ke({find:sx,type:this.type})]},addPasteRules(){return[He({find:ix,type:this.type}),He({find:lx,type:this.type})]}});var ax=t=>{let e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},cx=t=>{let e=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function ux(t){let e=new Set((t.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;e.has(n);)n+=1;return n}var mm=Te.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return"";let o=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",i="`".repeat(ux(o)),s=o.startsWith("`")||o.endsWith("`")?" ":"";return`${i}${s}${e.renderChildren(t.content)}${s}${i}`},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ke({find:ax,type:this.type})]},addPasteRules(){return[He({find:cx,type:this.type})]}});var Wa=4,dx=/^```([a-z]+)?[\s\n]$/,fx=/^~~~([a-z]+)?[\s\n]$/,gm=X.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Wa,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",H(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="",o=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(`
103
103
  `):r=`\`\`\`${o}
104
104
 
105
105
  \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:Wa,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;let l=" ".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:a})=>{let{from:c,to:u}=o,d=r.doc.textBetween(c,u,`
@@ -116,41 +116,41 @@ ${n}
116
116
  `);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
117
117
 
118
118
  `);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let s=o.after();return s===void 0?!1:r.nodeAt(s)?t.commands.command(({tr:l})=>(l.setSelection(R.near(r.resolve(s))),!0)):t.commands.exitCode()}}},addInputRules(){return[Zr({find:dx,type:this.type,getAttributes:t=>({language:t[1]})}),Zr({find:fx,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new B({key:new U("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
119
- `));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(O.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}});var gm=X.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
119
+ `));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(O.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}});var ym=X.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
120
120
 
121
- `):""});var ym=X.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",H(this.options.HTMLAttributes,t)]},renderText(){return`
121
+ `):""});var bm=X.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",H(this.options.HTMLAttributes,t)]},renderText(){return`
122
122
  `},renderMarkdown:()=>`
123
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var bm=X.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,H(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Zr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var km=X.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",H(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!_h(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,o=t();return pi(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){let{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(O.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(D.create(s.doc,a.pos)):s.setSelection(O.create(s.doc,a.pos));else{let u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(s.insert(c,d),s.setSelection(O.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[gi({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var hx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,px=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,mx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,gx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,wm=Te.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ke({find:hx,type:this.type}),Ke({find:mx,type:this.type})]},addPasteRules(){return[He({find:px,type:this.type}),He({find:gx,type:this.type})]}});var yx="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",bx="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Ga="numeric",Xa="ascii",Ya="alpha",ao="asciinumeric",lo="alphanumeric",Qa="domain",Em="emoji",kx="scheme",wx="slashscheme",_a="whitespace";function Sx(t,e){return t in e||(e[t]=[]),e[t]}function Pn(t,e,n){e[Ga]&&(e[ao]=!0,e[lo]=!0),e[Xa]&&(e[ao]=!0,e[Ya]=!0),e[ao]&&(e[lo]=!0),e[Ya]&&(e[lo]=!0),e[lo]&&(e[Qa]=!0),e[Em]&&(e[Qa]=!0);for(let r in e){let o=Sx(r,n);o.indexOf(t)<0&&o.push(t)}}function xx(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ue(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ue.groups={};Ue.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||Ue.groups;let o;return e&&e.j?o=e:(o=new Ue(e),n&&r&&Pn(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this,i=t.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(t[s]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Ue.groups;let o=this;if(e&&e.j)return o.j[t]=e,e;let i=e,s,l=o.go(t);if(l?(s=new Ue,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Ue,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(xx(s.t,r),n);Pn(i,a,r)}else n&&Pn(i,n,r);s.t=i}return o.j[t]=s,s}};var W=(t,e,n,r,o)=>t.ta(e,n,r,o),ce=(t,e,n,r,o)=>t.tr(e,n,r,o),Sm=(t,e,n,r,o)=>t.ts(e,n,r,o),T=(t,e,n,r,o)=>t.tt(e,n,r,o),zt="WORD",Za="UWORD",Tm="ASCIINUMERICAL",Am="ALPHANUMERICAL",mo="LOCALHOST",ec="TLD",tc="UTLD",Di="SCHEME",gr="SLASH_SCHEME",rc="NUM",nc="WS",oc="NL",co="OPENBRACE",uo="CLOSEBRACE",Ii="OPENBRACKET",Pi="CLOSEBRACKET",Li="OPENPAREN",zi="CLOSEPAREN",$i="OPENANGLEBRACKET",Bi="CLOSEANGLEBRACKET",Hi="FULLWIDTHLEFTPAREN",Fi="FULLWIDTHRIGHTPAREN",Vi="LEFTCORNERBRACKET",Wi="RIGHTCORNERBRACKET",_i="LEFTWHITECORNERBRACKET",ji="RIGHTWHITECORNERBRACKET",Ki="FULLWIDTHLESSTHAN",Ui="FULLWIDTHGREATERTHAN",qi="AMPERSAND",Ji="APOSTROPHE",Gi="ASTERISK",nn="AT",Xi="BACKSLASH",Yi="BACKTICK",Qi="CARET",Ln="COLON",ic="COMMA",Zi="DOLLAR",gt="DOT",es="EQUALS",sc="EXCLAMATION",nt="HYPHEN",fo="PERCENT",ts="PIPE",ns="PLUS",rs="POUND",ho="QUERY",lc="QUOTE",Nm="FULLWIDTHMIDDLEDOT",ac="SEMI",yt="SLASH",po="TILDE",is="UNDERSCORE",Om="EMOJI",ss="SYM",Rm=Object.freeze({__proto__:null,ALPHANUMERICAL:Am,AMPERSAND:qi,APOSTROPHE:Ji,ASCIINUMERICAL:Tm,ASTERISK:Gi,AT:nn,BACKSLASH:Xi,BACKTICK:Yi,CARET:Qi,CLOSEANGLEBRACKET:Bi,CLOSEBRACE:uo,CLOSEBRACKET:Pi,CLOSEPAREN:zi,COLON:Ln,COMMA:ic,DOLLAR:Zi,DOT:gt,EMOJI:Om,EQUALS:es,EXCLAMATION:sc,FULLWIDTHGREATERTHAN:Ui,FULLWIDTHLEFTPAREN:Hi,FULLWIDTHLESSTHAN:Ki,FULLWIDTHMIDDLEDOT:Nm,FULLWIDTHRIGHTPAREN:Fi,HYPHEN:nt,LEFTCORNERBRACKET:Vi,LEFTWHITECORNERBRACKET:_i,LOCALHOST:mo,NL:oc,NUM:rc,OPENANGLEBRACKET:$i,OPENBRACE:co,OPENBRACKET:Ii,OPENPAREN:Li,PERCENT:fo,PIPE:ts,PLUS:ns,POUND:rs,QUERY:ho,QUOTE:lc,RIGHTCORNERBRACKET:Wi,RIGHTWHITECORNERBRACKET:ji,SCHEME:Di,SEMI:ac,SLASH:yt,SLASH_SCHEME:gr,SYM:ss,TILDE:po,TLD:ec,UNDERSCORE:is,UTLD:tc,UWORD:Za,WORD:zt,WS:nc}),Pt=/[a-z]/,so=/\p{L}/u,ja=/\p{Emoji}/u;var Lt=/\d/,Ka=/\s/;var xm="\r",Ua=`
124
- `,vx="\uFE0F",Cx="\u200D",qa="\uFFFC",Ni=null,Oi=null;function Mx(t=[]){let e={};Ue.groups=e;let n=new Ue;Ni==null&&(Ni=vm(yx)),Oi==null&&(Oi=vm(bx)),T(n,"'",Ji),T(n,"{",co),T(n,"}",uo),T(n,"[",Ii),T(n,"]",Pi),T(n,"(",Li),T(n,")",zi),T(n,"<",$i),T(n,">",Bi),T(n,"\uFF08",Hi),T(n,"\uFF09",Fi),T(n,"\u300C",Vi),T(n,"\u300D",Wi),T(n,"\u300E",_i),T(n,"\u300F",ji),T(n,"\uFF1C",Ki),T(n,"\uFF1E",Ui),T(n,"&",qi),T(n,"*",Gi),T(n,"@",nn),T(n,"`",Yi),T(n,"^",Qi),T(n,":",Ln),T(n,",",ic),T(n,"$",Zi),T(n,".",gt),T(n,"=",es),T(n,"!",sc),T(n,"-",nt),T(n,"%",fo),T(n,"|",ts),T(n,"+",ns),T(n,"#",rs),T(n,"?",ho),T(n,'"',lc),T(n,"/",yt),T(n,";",ac),T(n,"~",po),T(n,"_",is),T(n,"\\",Xi),T(n,"\u30FB",Nm);let r=ce(n,Lt,rc,{[Ga]:!0});ce(r,Lt,r);let o=ce(r,Pt,Tm,{[ao]:!0}),i=ce(r,so,Am,{[lo]:!0}),s=ce(n,Pt,zt,{[Xa]:!0});ce(s,Lt,o),ce(s,Pt,s),ce(o,Lt,o),ce(o,Pt,o);let l=ce(n,so,Za,{[Ya]:!0});ce(l,Pt),ce(l,Lt,i),ce(l,so,l),ce(i,Lt,i),ce(i,Pt),ce(i,so,i);let a=T(n,Ua,oc,{[_a]:!0}),c=T(n,xm,nc,{[_a]:!0}),u=ce(n,Ka,nc,{[_a]:!0});T(n,qa,u),T(c,Ua,a),T(c,qa,u),ce(c,Ka,u),T(u,xm),T(u,Ua),ce(u,Ka,u),T(u,qa,u);let d=ce(n,ja,Om,{[Em]:!0});T(d,"#"),ce(d,ja,d),T(d,vx,d);let f=T(d,Cx);T(f,"#"),ce(f,ja,d);let h=[[Pt,s],[Lt,o]],p=[[Pt,null],[so,l],[Lt,i]];for(let g=0;g<Ni.length;g++)tn(n,Ni[g],ec,zt,h);for(let g=0;g<Oi.length;g++)tn(n,Oi[g],tc,Za,p);Pn(ec,{tld:!0,ascii:!0},e),Pn(tc,{utld:!0,alpha:!0},e),tn(n,"file",Di,zt,h),tn(n,"mailto",Di,zt,h),tn(n,"http",gr,zt,h),tn(n,"https",gr,zt,h),tn(n,"ftp",gr,zt,h),tn(n,"ftps",gr,zt,h),Pn(Di,{scheme:!0,ascii:!0},e),Pn(gr,{slashscheme:!0,ascii:!0},e),t=t.sort((g,m)=>g[0]>m[0]?1:-1);for(let g=0;g<t.length;g++){let m=t[g][0],S=t[g][1]?{[kx]:!0}:{[wx]:!0};m.indexOf("-")>=0?S[Qa]=!0:Pt.test(m)?Lt.test(m)?S[ao]=!0:S[Xa]=!0:S[Ga]=!0,Sm(n,m,m,S)}return Sm(n,"localhost",mo,{ascii:!0}),n.jd=new Ue(ss),{start:n,tokens:Object.assign({groups:e},Rm)}}function Dm(t,e){let n=Ex(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=d,s-=f,c-=d,o.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function Ex(t){let e=[],n=t.length,r=0;for(;r<n;){let o=t.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function tn(t,e,n,r,o){let i,s=e.length;for(let l=0;l<s-1;l++){let a=e[l];t.j[a]?i=t.j[a]:(i=new Ue(r),i.jr=o.slice(),t.j[a]=i),t=i}return i=new Ue(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function vm(t){let e=[],n=[],r=0,o="0123456789";for(;r<t.length;){let i=0;for(;o.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var go={defaultProtocol:"http",events:null,format:Cm,formatHref:Cm,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function cc(t,e=null){let n=Object.assign({},go);t&&(n=Object.assign(n,t instanceof cc?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}cc.prototype={o:go,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){let r=e!=null,o=this.o[t];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:go[t],typeof o=="function"&&r&&(o=o(e,n))):typeof o=="function"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){let e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Cm(t){return t}function Im(t,e){this.t="token",this.v=t,this.tk=e}Im.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){let e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=go.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:d}}};function ls(t,e){class n extends Im{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var Tx=ls("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Mm=ls("text"),Ax=ls("nl"),Ri=ls("url",{isLink:!0,toHref(t=go.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==mo&&t[1].t===Ln}});var tt=t=>new Ue(t);function Nx({groups:t}){let e=t.domain.concat([qi,Gi,nn,Xi,Yi,Qi,Zi,es,nt,rc,fo,ts,ns,rs,yt,ss,po,is]),n=[Ji,Ln,ic,gt,sc,fo,ho,lc,ac,$i,Bi,co,uo,Pi,Ii,Li,zi,Hi,Fi,Vi,Wi,_i,ji,Ki,Ui],r=[qi,Ji,Gi,Xi,Yi,Qi,Zi,es,nt,co,uo,fo,ts,ns,rs,ho,yt,ss,po,is],o=tt(),i=T(o,po);W(i,r,i),W(i,t.domain,i);let s=tt(),l=tt(),a=tt();W(o,t.domain,s),W(o,t.scheme,l),W(o,t.slashscheme,a),W(s,r,i),W(s,t.domain,s);let c=T(s,nn);T(i,nn,c),T(l,nn,c),T(a,nn,c);let u=T(i,gt);W(u,r,i),W(u,t.domain,i);let d=tt();W(c,t.domain,d),W(d,t.domain,d);let f=T(d,gt);W(f,t.domain,d);let h=tt(Tx);W(f,t.tld,h),W(f,t.utld,h),T(c,mo,h);let p=T(d,nt);T(p,nt,p),W(p,t.domain,d),W(h,t.domain,d),T(h,gt,f),T(h,nt,p);let g=T(s,nt),m=T(s,gt);T(g,nt,g),W(g,t.domain,s),W(m,r,i),W(m,t.domain,s);let y=tt(Ri);W(m,t.tld,y),W(m,t.utld,y),W(y,t.domain,s),W(y,r,i),T(y,gt,m),T(y,nt,g),T(y,nn,c);let S=T(y,Ln),v=tt(Ri);W(S,t.numeric,v);let M=tt(Ri),E=tt();W(M,e,M),W(M,n,E),W(E,e,M),W(E,n,E),T(y,yt,M),T(v,yt,M);let L=T(l,Ln),N=T(a,Ln),_=T(N,yt),te=T(_,yt);W(l,t.domain,s),T(l,gt,m),T(l,nt,g),W(a,t.domain,s),T(a,gt,m),T(a,nt,g),W(L,t.domain,M),T(L,yt,M),T(L,ho,M),W(te,t.domain,M),W(te,e,M),T(te,yt,M);let ae=[[co,uo],[Ii,Pi],[Li,zi],[$i,Bi],[Hi,Fi],[Vi,Wi],[_i,ji],[Ki,Ui]];for(let le=0;le<ae.length;le++){let[rt,Ve]=ae[le],We=T(M,rt);T(E,rt,We);let we=tt(Ri);W(We,e,we);let Xe=tt();W(We,n,Xe),T(We,Ve,M),W(we,e,we),W(we,n,Xe),W(Xe,e,we),W(Xe,n,Xe),T(we,Ve,M),T(Xe,Ve,M)}return T(o,mo,y),T(o,oc,Ax),{start:o,tokens:Rm}}function Ox(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let l=t,a=null,c=null,u=0,d=null,f=-1;for(;o<r&&!(a=l.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=a||l.go(n[o].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,o++,u++;if(f<0)o-=u,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Ja(Mm,e,s)),s=[]),o-=f,u-=f;let h=d.t,p=n.slice(o-u,o);i.push(Ja(h,e,p))}}return s.length>0&&i.push(Ja(Mm,e,s)),i}function Ja(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var Rx=typeof console<"u"&&console&&console.warn||(()=>{}),Dx="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",se={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Pm(){return Ue.groups={},se.scanner=null,se.parser=null,se.tokenQueue=[],se.pluginQueue=[],se.customSchemes=[],se.initialized=!1,se}function uc(t,e=!1){if(se.initialized&&Rx(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Dx}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
123
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var km=X.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,H(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Zr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var wm=X.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",H(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!_h(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,o=t();return pi(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){let{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(O.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(D.create(s.doc,a.pos)):s.setSelection(O.create(s.doc,a.pos));else{let u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(s.insert(c,d),s.setSelection(O.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[gi({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var hx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,px=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,mx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,gx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Sm=Te.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ke({find:hx,type:this.type}),Ke({find:mx,type:this.type})]},addPasteRules(){return[He({find:px,type:this.type}),He({find:gx,type:this.type})]}});var yx="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",bx="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Ga="numeric",Xa="ascii",Ya="alpha",ao="asciinumeric",lo="alphanumeric",Qa="domain",Tm="emoji",kx="scheme",wx="slashscheme",_a="whitespace";function Sx(t,e){return t in e||(e[t]=[]),e[t]}function Pn(t,e,n){e[Ga]&&(e[ao]=!0,e[lo]=!0),e[Xa]&&(e[ao]=!0,e[Ya]=!0),e[ao]&&(e[lo]=!0),e[Ya]&&(e[lo]=!0),e[lo]&&(e[Qa]=!0),e[Tm]&&(e[Qa]=!0);for(let r in e){let o=Sx(r,n);o.indexOf(t)<0&&o.push(t)}}function xx(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ue(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ue.groups={};Ue.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||Ue.groups;let o;return e&&e.j?o=e:(o=new Ue(e),n&&r&&Pn(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this,i=t.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(t[s]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Ue.groups;let o=this;if(e&&e.j)return o.j[t]=e,e;let i=e,s,l=o.go(t);if(l?(s=new Ue,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Ue,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(xx(s.t,r),n);Pn(i,a,r)}else n&&Pn(i,n,r);s.t=i}return o.j[t]=s,s}};var W=(t,e,n,r,o)=>t.ta(e,n,r,o),ce=(t,e,n,r,o)=>t.tr(e,n,r,o),xm=(t,e,n,r,o)=>t.ts(e,n,r,o),T=(t,e,n,r,o)=>t.tt(e,n,r,o),zt="WORD",Za="UWORD",Am="ASCIINUMERICAL",Nm="ALPHANUMERICAL",mo="LOCALHOST",ec="TLD",tc="UTLD",Di="SCHEME",gr="SLASH_SCHEME",rc="NUM",nc="WS",oc="NL",co="OPENBRACE",uo="CLOSEBRACE",Ii="OPENBRACKET",Pi="CLOSEBRACKET",Li="OPENPAREN",zi="CLOSEPAREN",$i="OPENANGLEBRACKET",Bi="CLOSEANGLEBRACKET",Hi="FULLWIDTHLEFTPAREN",Fi="FULLWIDTHRIGHTPAREN",Vi="LEFTCORNERBRACKET",Wi="RIGHTCORNERBRACKET",_i="LEFTWHITECORNERBRACKET",ji="RIGHTWHITECORNERBRACKET",Ki="FULLWIDTHLESSTHAN",Ui="FULLWIDTHGREATERTHAN",qi="AMPERSAND",Ji="APOSTROPHE",Gi="ASTERISK",nn="AT",Xi="BACKSLASH",Yi="BACKTICK",Qi="CARET",Ln="COLON",ic="COMMA",Zi="DOLLAR",gt="DOT",es="EQUALS",sc="EXCLAMATION",nt="HYPHEN",fo="PERCENT",ts="PIPE",ns="PLUS",rs="POUND",ho="QUERY",lc="QUOTE",Om="FULLWIDTHMIDDLEDOT",ac="SEMI",yt="SLASH",po="TILDE",is="UNDERSCORE",Rm="EMOJI",ss="SYM",Dm=Object.freeze({__proto__:null,ALPHANUMERICAL:Nm,AMPERSAND:qi,APOSTROPHE:Ji,ASCIINUMERICAL:Am,ASTERISK:Gi,AT:nn,BACKSLASH:Xi,BACKTICK:Yi,CARET:Qi,CLOSEANGLEBRACKET:Bi,CLOSEBRACE:uo,CLOSEBRACKET:Pi,CLOSEPAREN:zi,COLON:Ln,COMMA:ic,DOLLAR:Zi,DOT:gt,EMOJI:Rm,EQUALS:es,EXCLAMATION:sc,FULLWIDTHGREATERTHAN:Ui,FULLWIDTHLEFTPAREN:Hi,FULLWIDTHLESSTHAN:Ki,FULLWIDTHMIDDLEDOT:Om,FULLWIDTHRIGHTPAREN:Fi,HYPHEN:nt,LEFTCORNERBRACKET:Vi,LEFTWHITECORNERBRACKET:_i,LOCALHOST:mo,NL:oc,NUM:rc,OPENANGLEBRACKET:$i,OPENBRACE:co,OPENBRACKET:Ii,OPENPAREN:Li,PERCENT:fo,PIPE:ts,PLUS:ns,POUND:rs,QUERY:ho,QUOTE:lc,RIGHTCORNERBRACKET:Wi,RIGHTWHITECORNERBRACKET:ji,SCHEME:Di,SEMI:ac,SLASH:yt,SLASH_SCHEME:gr,SYM:ss,TILDE:po,TLD:ec,UNDERSCORE:is,UTLD:tc,UWORD:Za,WORD:zt,WS:nc}),Pt=/[a-z]/,so=/\p{L}/u,ja=/\p{Emoji}/u;var Lt=/\d/,Ka=/\s/;var vm="\r",Ua=`
124
+ `,vx="\uFE0F",Cx="\u200D",qa="\uFFFC",Ni=null,Oi=null;function Mx(t=[]){let e={};Ue.groups=e;let n=new Ue;Ni==null&&(Ni=Cm(yx)),Oi==null&&(Oi=Cm(bx)),T(n,"'",Ji),T(n,"{",co),T(n,"}",uo),T(n,"[",Ii),T(n,"]",Pi),T(n,"(",Li),T(n,")",zi),T(n,"<",$i),T(n,">",Bi),T(n,"\uFF08",Hi),T(n,"\uFF09",Fi),T(n,"\u300C",Vi),T(n,"\u300D",Wi),T(n,"\u300E",_i),T(n,"\u300F",ji),T(n,"\uFF1C",Ki),T(n,"\uFF1E",Ui),T(n,"&",qi),T(n,"*",Gi),T(n,"@",nn),T(n,"`",Yi),T(n,"^",Qi),T(n,":",Ln),T(n,",",ic),T(n,"$",Zi),T(n,".",gt),T(n,"=",es),T(n,"!",sc),T(n,"-",nt),T(n,"%",fo),T(n,"|",ts),T(n,"+",ns),T(n,"#",rs),T(n,"?",ho),T(n,'"',lc),T(n,"/",yt),T(n,";",ac),T(n,"~",po),T(n,"_",is),T(n,"\\",Xi),T(n,"\u30FB",Om);let r=ce(n,Lt,rc,{[Ga]:!0});ce(r,Lt,r);let o=ce(r,Pt,Am,{[ao]:!0}),i=ce(r,so,Nm,{[lo]:!0}),s=ce(n,Pt,zt,{[Xa]:!0});ce(s,Lt,o),ce(s,Pt,s),ce(o,Lt,o),ce(o,Pt,o);let l=ce(n,so,Za,{[Ya]:!0});ce(l,Pt),ce(l,Lt,i),ce(l,so,l),ce(i,Lt,i),ce(i,Pt),ce(i,so,i);let a=T(n,Ua,oc,{[_a]:!0}),c=T(n,vm,nc,{[_a]:!0}),u=ce(n,Ka,nc,{[_a]:!0});T(n,qa,u),T(c,Ua,a),T(c,qa,u),ce(c,Ka,u),T(u,vm),T(u,Ua),ce(u,Ka,u),T(u,qa,u);let d=ce(n,ja,Rm,{[Tm]:!0});T(d,"#"),ce(d,ja,d),T(d,vx,d);let f=T(d,Cx);T(f,"#"),ce(f,ja,d);let h=[[Pt,s],[Lt,o]],p=[[Pt,null],[so,l],[Lt,i]];for(let g=0;g<Ni.length;g++)tn(n,Ni[g],ec,zt,h);for(let g=0;g<Oi.length;g++)tn(n,Oi[g],tc,Za,p);Pn(ec,{tld:!0,ascii:!0},e),Pn(tc,{utld:!0,alpha:!0},e),tn(n,"file",Di,zt,h),tn(n,"mailto",Di,zt,h),tn(n,"http",gr,zt,h),tn(n,"https",gr,zt,h),tn(n,"ftp",gr,zt,h),tn(n,"ftps",gr,zt,h),Pn(Di,{scheme:!0,ascii:!0},e),Pn(gr,{slashscheme:!0,ascii:!0},e),t=t.sort((g,m)=>g[0]>m[0]?1:-1);for(let g=0;g<t.length;g++){let m=t[g][0],S=t[g][1]?{[kx]:!0}:{[wx]:!0};m.indexOf("-")>=0?S[Qa]=!0:Pt.test(m)?Lt.test(m)?S[ao]=!0:S[Xa]=!0:S[Ga]=!0,xm(n,m,m,S)}return xm(n,"localhost",mo,{ascii:!0}),n.jd=new Ue(ss),{start:n,tokens:Object.assign({groups:e},Dm)}}function Im(t,e){let n=Ex(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=d,s-=f,c-=d,o.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function Ex(t){let e=[],n=t.length,r=0;for(;r<n;){let o=t.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function tn(t,e,n,r,o){let i,s=e.length;for(let l=0;l<s-1;l++){let a=e[l];t.j[a]?i=t.j[a]:(i=new Ue(r),i.jr=o.slice(),t.j[a]=i),t=i}return i=new Ue(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function Cm(t){let e=[],n=[],r=0,o="0123456789";for(;r<t.length;){let i=0;for(;o.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var go={defaultProtocol:"http",events:null,format:Mm,formatHref:Mm,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function cc(t,e=null){let n=Object.assign({},go);t&&(n=Object.assign(n,t instanceof cc?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}cc.prototype={o:go,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){let r=e!=null,o=this.o[t];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:go[t],typeof o=="function"&&r&&(o=o(e,n))):typeof o=="function"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){let e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Mm(t){return t}function Pm(t,e){this.t="token",this.v=t,this.tk=e}Pm.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){let e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=go.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:d}}};function ls(t,e){class n extends Pm{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var Tx=ls("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Em=ls("text"),Ax=ls("nl"),Ri=ls("url",{isLink:!0,toHref(t=go.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==mo&&t[1].t===Ln}});var tt=t=>new Ue(t);function Nx({groups:t}){let e=t.domain.concat([qi,Gi,nn,Xi,Yi,Qi,Zi,es,nt,rc,fo,ts,ns,rs,yt,ss,po,is]),n=[Ji,Ln,ic,gt,sc,fo,ho,lc,ac,$i,Bi,co,uo,Pi,Ii,Li,zi,Hi,Fi,Vi,Wi,_i,ji,Ki,Ui],r=[qi,Ji,Gi,Xi,Yi,Qi,Zi,es,nt,co,uo,fo,ts,ns,rs,ho,yt,ss,po,is],o=tt(),i=T(o,po);W(i,r,i),W(i,t.domain,i);let s=tt(),l=tt(),a=tt();W(o,t.domain,s),W(o,t.scheme,l),W(o,t.slashscheme,a),W(s,r,i),W(s,t.domain,s);let c=T(s,nn);T(i,nn,c),T(l,nn,c),T(a,nn,c);let u=T(i,gt);W(u,r,i),W(u,t.domain,i);let d=tt();W(c,t.domain,d),W(d,t.domain,d);let f=T(d,gt);W(f,t.domain,d);let h=tt(Tx);W(f,t.tld,h),W(f,t.utld,h),T(c,mo,h);let p=T(d,nt);T(p,nt,p),W(p,t.domain,d),W(h,t.domain,d),T(h,gt,f),T(h,nt,p);let g=T(s,nt),m=T(s,gt);T(g,nt,g),W(g,t.domain,s),W(m,r,i),W(m,t.domain,s);let y=tt(Ri);W(m,t.tld,y),W(m,t.utld,y),W(y,t.domain,s),W(y,r,i),T(y,gt,m),T(y,nt,g),T(y,nn,c);let S=T(y,Ln),v=tt(Ri);W(S,t.numeric,v);let M=tt(Ri),E=tt();W(M,e,M),W(M,n,E),W(E,e,M),W(E,n,E),T(y,yt,M),T(v,yt,M);let L=T(l,Ln),N=T(a,Ln),_=T(N,yt),te=T(_,yt);W(l,t.domain,s),T(l,gt,m),T(l,nt,g),W(a,t.domain,s),T(a,gt,m),T(a,nt,g),W(L,t.domain,M),T(L,yt,M),T(L,ho,M),W(te,t.domain,M),W(te,e,M),T(te,yt,M);let ae=[[co,uo],[Ii,Pi],[Li,zi],[$i,Bi],[Hi,Fi],[Vi,Wi],[_i,ji],[Ki,Ui]];for(let le=0;le<ae.length;le++){let[rt,Ve]=ae[le],We=T(M,rt);T(E,rt,We);let we=tt(Ri);W(We,e,we);let Xe=tt();W(We,n,Xe),T(We,Ve,M),W(we,e,we),W(we,n,Xe),W(Xe,e,we),W(Xe,n,Xe),T(we,Ve,M),T(Xe,Ve,M)}return T(o,mo,y),T(o,oc,Ax),{start:o,tokens:Dm}}function Ox(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let l=t,a=null,c=null,u=0,d=null,f=-1;for(;o<r&&!(a=l.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=a||l.go(n[o].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,o++,u++;if(f<0)o-=u,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Ja(Em,e,s)),s=[]),o-=f,u-=f;let h=d.t,p=n.slice(o-u,o);i.push(Ja(h,e,p))}}return s.length>0&&i.push(Ja(Em,e,s)),i}function Ja(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var Rx=typeof console<"u"&&console&&console.warn||(()=>{}),Dx="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",se={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Lm(){return Ue.groups={},se.scanner=null,se.parser=null,se.tokenQueue=[],se.pluginQueue=[],se.customSchemes=[],se.initialized=!1,se}function uc(t,e=!1){if(se.initialized&&Rx(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Dx}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
125
125
  1. Must only contain digits, lowercase ASCII letters or "-"
126
126
  2. Cannot start or end with "-"
127
- 3. "-" cannot repeat`);se.customSchemes.push([t,e])}function Ix(){se.scanner=Mx(se.customSchemes);for(let t=0;t<se.tokenQueue.length;t++)se.tokenQueue[t][1]({scanner:se.scanner});se.parser=Nx(se.scanner.tokens);for(let t=0;t<se.pluginQueue.length;t++)se.pluginQueue[t][1]({scanner:se.scanner,parser:se.parser});return se.initialized=!0,se}function as(t){return se.initialized||Ix(),Ox(se.parser.start,t,Dm(se.scanner.start,t))}as.scan=Dm;function dc(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new cc(n),o=as(t),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var cs="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",Px=new RegExp(cs),Lx=new RegExp(`${cs}$`),zx=new RegExp(`${cs}+$`),$x=new RegExp(cs,"g");function Bx(t,e,n){var r,o;let i=t.doc.resolve(e.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let s=(o=t.doc.textBetween(e.from,e.to,"\uFFFC","\uFFFC").match(zx))===null||o===void 0?void 0:o[0];if(!s)return;let l=e.to-s.length,a=Qr(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:c}=i;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;let u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function Hx(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Fx(t){return new B({key:new U("autolink"),appendTransaction:(e,n,r)=>{let o=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=e.some(a=>a.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=pa(n.doc,[...e]);if(!e.some(Zf)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof de)||!c.slice.size)return;let d=l.mapping.slice(u+1),f=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);f<h&&a.push({from:f,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Bx(s,c,t.type))}if(cr(l).forEach(({newRange:a})=>{let c=Mh(r.doc,a,f=>f.isTextblock),u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!Lx.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){let f=d.split(Px).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=u.pos+d.lastIndexOf(h);if(!h)return!1;let g=as(h).map(m=>m.toObject(t.defaultProtocol));if(!Hx(g))return!1;g.filter(m=>m.isLink).map(m=>({...m,from:p+m.start+1,to:p+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>t.validate(m.value)).filter(m=>t.shouldAutoLink(m.value)).forEach(m=>{Qr(m.from,m.to,r.doc).some(y=>y.mark.type===t.type)||s.addMark(m.from,m.to,t.type.create({href:m.href}))})}}),!!s.steps.length)return s}})}function Vx(t){return new B({key:new U("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var s,l;let a=ya(e.state,t.type.name),c=(s=o.href)!==null&&s!==void 0?s:a.href,u=(l=o.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),i=!0)}return i}}})}var Wx=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,_x=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Lm(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function jx(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&Lm(t,r)){r+=1;continue}let o=0;for(;r<e&&t[r]==="`";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function zm(t,e,n){var r,o;let[,i,s]=e;return(e.index?t[e.index-1]:void 0)==="!"||Lm(t,(r=e.index)!==null&&r!==void 0?r:0)||jx(t,(o=e.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function $m(t){var e,n;let[r,o,i,,s,l,a]=t,c=(e=s??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:c||null,markdown:!0}}}function Kx(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function Bm(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function Ux(t){let e=Ke({find:n=>{let r=Wx.exec(n);return!r||!zm(n,r,t.isAllowedHref)?null:$m(r)},type:t.type,getAttributes:Bm});return new fr({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function qx(t){let e=He({find:n=>{var r,o;let i=[];for(let l of n.matchAll(_x))zm(n,l,t.isAllowedHref)&&i.push($m(l));let s=((r=(o=t.findPlainUrls)===null||o===void 0?void 0:o.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>Kx(a,l)));return[...i,...s]},type:t.type,getAttributes:Bm});return new Sa({find:e.find,handler:n=>{var r;let o=e.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),o}})}function Jx(t){return new B({key:new U("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});let c=dc(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function $t(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace($x,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var Hm=Te.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){uc(t);return}uc(t.scheme,t.optionalSlashes)})},onDestroy(){Pm()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!$t(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!$t(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!$t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",H(this.options.HTMLAttributes,t),0]:["a",H(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,o,i;let s=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(o=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:"",a=e.renderChildren(t);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[Ux({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!$t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:o}=this.options;dc(e).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!$t(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[qx({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!$t(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[He({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Fx({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!$t(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Vx({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Jx({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var Gx="listItem",Fm="textStyle",Vm=/^\s*([-+*])\s$/,fc=X.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
128
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Gx,this.editor.getAttributes(Fm)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Qt({find:Vm,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Qt({find:Vm,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Fm),editor:this.editor})),[t]}}),Xx=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){i=h;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(o.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:o.after(),insertPos:o.after(i),items:f}},Yx=(t,e,n,r)=>{let o=Xx(t,n,r);if(!o)return!1;let{selection:i}=t,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=o,u=t.tr;u.delete(l,l+s.nodeSize);let d=u.mapping.map(a);return u.insert(d,x.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},Qx=(t,e,n)=>Yx(t.state,t.view.dispatch,e,n),Gm=(t,e)=>G.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>Qx(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),Xm=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],us="abcdefghijklmnopqrstuvwxyz",Ym=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function hs(t){let e=t,n="";for(let[r,o]of Xm)for(;e>=r;)n+=o,e-=r;return n}function hc(t){return hs(t).toUpperCase()}function Qm(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let o=!1;for(let[i,s]of Xm)if(e.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function Zx(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=Qm(t);return e<=0?!1:(t===t.toLowerCase()?hs(e):hc(e))===t}function ev(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function ds(t){if(t<=26)return us[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?us[n]:us[e]+us[n]}function ps(t){if(!(!t||/^\d+$/.test(t))){if(Zx(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function pc(t){if(/^\d+$/.test(t))return parseInt(t,10);let e=ps(t);if(e==="i"||e==="I")return Qm(t);if(e==="a"||e==="A"){let r=ev(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function tv(t,e){if(t==="numeric")return String(e);switch(t){case"a":return ds(e);case"A":return ds(e).toUpperCase();case"i":return hs(e);case"I":return hc(e);default:return String(e)}}function nv(t){var e;if(t.length===0)return!1;let n=(e=ps(t[0]))!==null&&e!==void 0?e:"numeric",r=pc(t[0]);if(r<1)return!1;for(let o=0;o<t.length;o++){let i=tv(n,r+o);if(t[o]!==i)return!1}return!0}function rv(t){return{type:ps(t),start:pc(t)}}function ov(t){let{type:e,start:n}=rv(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function iv(t,e,n=". "){let r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${ds(r)}${n}`;case"A":return`${ds(r).toUpperCase()}${n}`;case"i":return`${hs(r)}${n}`;case"I":return`${hc(r)}${n}`;default:return`${r}${n}`}}function sv(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function lv(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var mc=X.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,o=[];if(t.tokens&&t.tokens.length>0){if(sv(t))return{type:"listItem",content:[{type:"paragraph",content:lv(t.text||"",e)}]};if(t.tokens.some(i=>i.type==="paragraph"))o=r(t.tokens);else{let i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){let s=r(t.tokens.slice(1));o.push(...s)}}else o=r(t.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(t,e,n)=>ka(t,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var o,i;let s=((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.start)||1;return iv((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.type,s-1+(r.index||0),". ")}return"- "},n,{alignNestedToPrefix:n?.parentType==="orderedList"}),addExtensions(){return[Gm(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),gc=(t,e)=>{let{$from:n}=e.selection,r=pe(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},Zm=(t,e)=>{let n=gc(t,e);if(!n)return!1;let[,r]=Oh(e,t,n.$pos.pos+4);return r},av=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},Wm=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ht(t.state,e)&&av(t.state,e,n)){let{$anchor:i}=t.state.selection,s=t.state.doc.resolve(i.before()-1),l=[];s.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(s.start()+a.pos+1);return t.chain().cut({from:i.start()-1,to:i.end()+1},c.end()).joinForward().run()}if(!ht(t.state,e)||!Ih(t.state))return!1;let{$from:r}=t.state.selection,o=r.depth-1;return r.node(o).type!==t.schema.nodes[e]||r.index(o)!==0?!1:t.chain().liftListItem(e).run()},cv=(t,e)=>{let n=Zm(t,e),r=gc(t,e);return!r||!n?!1:n>r.depth},uv=(t,e)=>{let n=Zm(t,e),r=gc(t,e);return!r||!n?!1:n<r.depth},_m=(t,e)=>{if(!ht(t.state,e)||!Dh(t.state,e))return!1;let{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:cv(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():uv(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},dv=(t,e,n)=>{let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||ht(r,e))return!1;let s=Rh(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,x.from(a)))return!1;let c=i.before(),u=i.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,x.from(a)),f.setSelection(O.create(f.doc,d+1)),f.scrollIntoView()),!0))};var yc=G.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&_m(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&_m(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Wm(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Wm(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&dv(t,e,n))return!0;return!1}}}}),fs=new RegExp(`^(\\s*)(${Ym})([.)])\\s+(.*)$`),fv=/^\s/,yr={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function hv(t){return fs.test(t.trimStart())}function pv(t){let e=t.trimStart();return yr.bulletItem.test(e)||hv(e)||yr.heading.test(e)||yr.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||yr.codeFence.test(e)||yr.blockMath.test(e)}function mv(t){return Object.values(yr).some(e=>e.test(t))}function gv(t){let e=[],n=[],r=!1;return t.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(e.length>0&&pv(o)){r=!0,n.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:n}}function jm(t){let e=[],n=0,r=0;for(;n<t.length;){let o=t[n],i=o.match(fs);if(!i)break;let[,s,l,a,c]=i,u=s.length,d=parseInt(l,10),f=isNaN(d)?ps(l):void 0,h=isNaN(d)?pc(l):d,p=[c],g=n+1,m=[o],y=!1;for(;g<t.length;){let S=t[g];if(S.match(fs))break;if(S.trim()==="")m.push(S),p.push(""),y=!0,g+=1;else if(S.match(fv)){let v=S.length-S.trimStart().length,M=u+l.length+1;m.push(S),p.push(S.slice(Math.min(v,M))),g+=1}else{if(y||mv(S))break;m.push(S),p.push(S),g+=1}}e.push({indent:u,number:h,type:f,content:p.join(`
127
+ 3. "-" cannot repeat`);se.customSchemes.push([t,e])}function Ix(){se.scanner=Mx(se.customSchemes);for(let t=0;t<se.tokenQueue.length;t++)se.tokenQueue[t][1]({scanner:se.scanner});se.parser=Nx(se.scanner.tokens);for(let t=0;t<se.pluginQueue.length;t++)se.pluginQueue[t][1]({scanner:se.scanner,parser:se.parser});return se.initialized=!0,se}function as(t){return se.initialized||Ix(),Ox(se.parser.start,t,Im(se.scanner.start,t))}as.scan=Im;function dc(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new cc(n),o=as(t),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var cs="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",Px=new RegExp(cs),Lx=new RegExp(`${cs}$`),zx=new RegExp(`${cs}+$`),$x=new RegExp(cs,"g");function Bx(t,e,n){var r,o;let i=t.doc.resolve(e.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let s=(o=t.doc.textBetween(e.from,e.to,"\uFFFC","\uFFFC").match(zx))===null||o===void 0?void 0:o[0];if(!s)return;let l=e.to-s.length,a=Qr(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:c}=i;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;let u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function Hx(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Fx(t){return new B({key:new U("autolink"),appendTransaction:(e,n,r)=>{let o=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=e.some(a=>a.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=pa(n.doc,[...e]);if(!e.some(Zf)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof de)||!c.slice.size)return;let d=l.mapping.slice(u+1),f=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);f<h&&a.push({from:f,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Bx(s,c,t.type))}if(cr(l).forEach(({newRange:a})=>{let c=Mh(r.doc,a,f=>f.isTextblock),u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!Lx.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){let f=d.split(Px).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=u.pos+d.lastIndexOf(h);if(!h)return!1;let g=as(h).map(m=>m.toObject(t.defaultProtocol));if(!Hx(g))return!1;g.filter(m=>m.isLink).map(m=>({...m,from:p+m.start+1,to:p+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>t.validate(m.value)).filter(m=>t.shouldAutoLink(m.value)).forEach(m=>{Qr(m.from,m.to,r.doc).some(y=>y.mark.type===t.type)||s.addMark(m.from,m.to,t.type.create({href:m.href}))})}}),!!s.steps.length)return s}})}function Vx(t){return new B({key:new U("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var s,l;let a=ya(e.state,t.type.name),c=(s=o.href)!==null&&s!==void 0?s:a.href,u=(l=o.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),i=!0)}return i}}})}var Wx=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,_x=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function zm(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function jx(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&zm(t,r)){r+=1;continue}let o=0;for(;r<e&&t[r]==="`";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function $m(t,e,n){var r,o;let[,i,s]=e;return(e.index?t[e.index-1]:void 0)==="!"||zm(t,(r=e.index)!==null&&r!==void 0?r:0)||jx(t,(o=e.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function Bm(t){var e,n;let[r,o,i,,s,l,a]=t,c=(e=s??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:c||null,markdown:!0}}}function Kx(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function Hm(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function Ux(t){let e=Ke({find:n=>{let r=Wx.exec(n);return!r||!$m(n,r,t.isAllowedHref)?null:Bm(r)},type:t.type,getAttributes:Hm});return new fr({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function qx(t){let e=He({find:n=>{var r,o;let i=[];for(let l of n.matchAll(_x))$m(n,l,t.isAllowedHref)&&i.push(Bm(l));let s=((r=(o=t.findPlainUrls)===null||o===void 0?void 0:o.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>Kx(a,l)));return[...i,...s]},type:t.type,getAttributes:Hm});return new Sa({find:e.find,handler:n=>{var r;let o=e.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),o}})}function Jx(t){return new B({key:new U("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});let c=dc(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function $t(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace($x,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var Fm=Te.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){uc(t);return}uc(t.scheme,t.optionalSlashes)})},onDestroy(){Lm()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!$t(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!$t(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!$t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",H(this.options.HTMLAttributes,t),0]:["a",H(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,o,i;let s=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(o=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:"",a=e.renderChildren(t);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[Ux({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!$t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:o}=this.options;dc(e).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!$t(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[qx({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!$t(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[He({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Fx({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!$t(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Vx({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Jx({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var Gx="listItem",Vm="textStyle",Wm=/^\s*([-+*])\s$/,fc=X.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
128
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Gx,this.editor.getAttributes(Vm)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Qt({find:Wm,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Qt({find:Wm,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vm),editor:this.editor})),[t]}}),Xx=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){i=h;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(o.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:o.after(),insertPos:o.after(i),items:f}},Yx=(t,e,n,r)=>{let o=Xx(t,n,r);if(!o)return!1;let{selection:i}=t,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=o,u=t.tr;u.delete(l,l+s.nodeSize);let d=u.mapping.map(a);return u.insert(d,x.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},Qx=(t,e,n)=>Yx(t.state,t.view.dispatch,e,n),Xm=(t,e)=>G.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>Qx(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),Ym=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],us="abcdefghijklmnopqrstuvwxyz",Qm=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function hs(t){let e=t,n="";for(let[r,o]of Ym)for(;e>=r;)n+=o,e-=r;return n}function hc(t){return hs(t).toUpperCase()}function Zm(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let o=!1;for(let[i,s]of Ym)if(e.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function Zx(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=Zm(t);return e<=0?!1:(t===t.toLowerCase()?hs(e):hc(e))===t}function ev(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function ds(t){if(t<=26)return us[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?us[n]:us[e]+us[n]}function ps(t){if(!(!t||/^\d+$/.test(t))){if(Zx(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function pc(t){if(/^\d+$/.test(t))return parseInt(t,10);let e=ps(t);if(e==="i"||e==="I")return Zm(t);if(e==="a"||e==="A"){let r=ev(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function tv(t,e){if(t==="numeric")return String(e);switch(t){case"a":return ds(e);case"A":return ds(e).toUpperCase();case"i":return hs(e);case"I":return hc(e);default:return String(e)}}function nv(t){var e;if(t.length===0)return!1;let n=(e=ps(t[0]))!==null&&e!==void 0?e:"numeric",r=pc(t[0]);if(r<1)return!1;for(let o=0;o<t.length;o++){let i=tv(n,r+o);if(t[o]!==i)return!1}return!0}function rv(t){return{type:ps(t),start:pc(t)}}function ov(t){let{type:e,start:n}=rv(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function iv(t,e,n=". "){let r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${ds(r)}${n}`;case"A":return`${ds(r).toUpperCase()}${n}`;case"i":return`${hs(r)}${n}`;case"I":return`${hc(r)}${n}`;default:return`${r}${n}`}}function sv(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function lv(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var mc=X.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,o=[];if(t.tokens&&t.tokens.length>0){if(sv(t))return{type:"listItem",content:[{type:"paragraph",content:lv(t.text||"",e)}]};if(t.tokens.some(i=>i.type==="paragraph"))o=r(t.tokens);else{let i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){let s=r(t.tokens.slice(1));o.push(...s)}}else o=r(t.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(t,e,n)=>ka(t,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var o,i;let s=((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.start)||1;return iv((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.type,s-1+(r.index||0),". ")}return"- "},n,{alignNestedToPrefix:n?.parentType==="orderedList"}),addExtensions(){return[Xm(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),gc=(t,e)=>{let{$from:n}=e.selection,r=pe(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},eg=(t,e)=>{let n=gc(t,e);if(!n)return!1;let[,r]=Oh(e,t,n.$pos.pos+4);return r},av=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},_m=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ht(t.state,e)&&av(t.state,e,n)){let{$anchor:i}=t.state.selection,s=t.state.doc.resolve(i.before()-1),l=[];s.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(s.start()+a.pos+1);return t.chain().cut({from:i.start()-1,to:i.end()+1},c.end()).joinForward().run()}if(!ht(t.state,e)||!Ih(t.state))return!1;let{$from:r}=t.state.selection,o=r.depth-1;return r.node(o).type!==t.schema.nodes[e]||r.index(o)!==0?!1:t.chain().liftListItem(e).run()},cv=(t,e)=>{let n=eg(t,e),r=gc(t,e);return!r||!n?!1:n>r.depth},uv=(t,e)=>{let n=eg(t,e),r=gc(t,e);return!r||!n?!1:n<r.depth},jm=(t,e)=>{if(!ht(t.state,e)||!Dh(t.state,e))return!1;let{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:cv(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():uv(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},dv=(t,e,n)=>{let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||ht(r,e))return!1;let s=Rh(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,x.from(a)))return!1;let c=i.before(),u=i.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,x.from(a)),f.setSelection(O.create(f.doc,d+1)),f.scrollIntoView()),!0))};var yc=G.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&jm(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&jm(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&_m(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&_m(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&dv(t,e,n))return!0;return!1}}}}),fs=new RegExp(`^(\\s*)(${Qm})([.)])\\s+(.*)$`),fv=/^\s/,yr={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function hv(t){return fs.test(t.trimStart())}function pv(t){let e=t.trimStart();return yr.bulletItem.test(e)||hv(e)||yr.heading.test(e)||yr.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||yr.codeFence.test(e)||yr.blockMath.test(e)}function mv(t){return Object.values(yr).some(e=>e.test(t))}function gv(t){let e=[],n=[],r=!1;return t.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(e.length>0&&pv(o)){r=!0,n.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:n}}function Km(t){let e=[],n=0,r=0;for(;n<t.length;){let o=t[n],i=o.match(fs);if(!i)break;let[,s,l,a,c]=i,u=s.length,d=parseInt(l,10),f=isNaN(d)?ps(l):void 0,h=isNaN(d)?pc(l):d,p=[c],g=n+1,m=[o],y=!1;for(;g<t.length;){let S=t[g];if(S.match(fs))break;if(S.trim()==="")m.push(S),p.push(""),y=!0,g+=1;else if(S.match(fv)){let v=S.length-S.trimStart().length,M=u+l.length+1;m.push(S),p.push(S.slice(Math.min(v,M))),g+=1}else{if(y||mv(S))break;m.push(S),p.push(S),g+=1}}e.push({indent:u,number:h,type:f,content:p.join(`
129
129
  `).trim(),contentLines:p,raw:m.join(`
130
- `)}),r=g,n=g}return[e,r]}var yv=new RegExp(`^(${Ym})([.)])\\s+(.+)$`);function bv(t){let e=t.split(`
131
- `).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let o=r.trim().match(yv);if(!o)return null;n.push({marker:o[1],content:o[3]})}return nv(n.map(r=>r.marker))?{type:"orderedList",attrs:ov(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function eg(t,e,n){let r=[],o=0;for(;o<t.length;){let i=t[o];if(i.indent===e){let{paragraphLines:s,blockLines:l}=gv(i.contentLines),a=s.join(`
130
+ `)}),r=g,n=g}return[e,r]}var yv=new RegExp(`^(${Qm})([.)])\\s+(.+)$`);function bv(t){let e=t.split(`
131
+ `).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let o=r.trim().match(yv);if(!o)return null;n.push({marker:o[1],content:o[3]})}return nv(n.map(r=>r.marker))?{type:"orderedList",attrs:ov(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function tg(t,e,n){let r=[],o=0;for(;o<t.length;){let i=t[o];if(i.indent===e){let{paragraphLines:s,blockLines:l}=gv(i.contentLines),a=s.join(`
132
132
  `).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});let u=l.join(`
133
- `).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=o+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=eg(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
134
- `)})}r.push({type:"list_item",raw:i.raw,tokens:c}),o=d}else o+=1}return r}function kv(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){let i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{let i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var wv=64;function Km(t,e){let n=[],r=0;for(;n.length<e;){let o=t.indexOf(`
133
+ `).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=o+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=tg(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
134
+ `)})}r.push({type:"list_item",raw:i.raw,tokens:c}),o=d}else o+=1}return r}function kv(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){let i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{let i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var wv=64;function Um(t,e){let n=[],r=0;for(;n.length<e;){let o=t.indexOf(`
135
135
  `,r);if(o===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,o)),r=o+1}return n}function Sv(t){let e=t.indexOf(`
136
- `),n=e===-1?t:t.slice(0,e);if(!fs.test(n))return[[],0,[]];let r=wv,o=Km(t,r),i=jm(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=Km(t,r),i=jm(o);return[i[0],i[1],o]}var xv="listItem",Um="textStyle",qm=/^(\d+)\.\s$/;function Jm(t){let e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var bc=X.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute("type");if(e)return e;let n=t.getAttribute("style");if(n){let o=Jm(n);if(o)return o}let r=t.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let i=Jm(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,o=H(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),n&&n!=="1"&&(o.type=n),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,o=t.items?kv(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:o}:{type:"orderedList",content:o}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
137
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,o;let[i,s,l]=Sv(t);if(i.length===0)return;let a=eg(i,i[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=i[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,s).join(`
138
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(xv,this.editor.getAttributes(Um)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new B({props:{handlePaste:(t,e)=>{var n,r;let o=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(o?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let s=bv(i);if(!s)return!1;try{let l=t.state.schema.nodeFromJSON(s),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],e=Qt({find:qm,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Qt({find:qm,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Um)}),joinPredicate:t,editor:this.editor})),[e]}}),vv=/^\s*(\[([( |x])?\])\s$/,Cv="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",Mv=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},ms=X.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",H(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return ka(t,e,r)},addExtensions(){return this.options.nested?[Gm(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");s.style.cssText=Cv;let c=d=>{let f=Mv(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),s.textContent=f};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let g=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([d,f])=>{o.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=pt(d,f),p=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(m=>{p.has(m)||(m in g?o.setAttribute(m,g[m]):o.removeAttribute(m))}),Object.entries(h).forEach(([m,y])=>{y==null?m in g?o.setAttribute(m,g[m]):o.removeAttribute(m):o.setAttribute(m,y)}),u=p,!0}}}},addInputRules(){return[Qt({find:vv,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),gs=X.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",H(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
139
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let s=ba(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(s){let l={type:"taskList",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=ba(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),XT=G.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(fc.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(mc.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(yc.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(bc.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(ms.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(gs.configure(this.options.taskList)),t}});var ys="&nbsp;",kc="\xA0",tg=X.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",H(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===ys||n[0].text===ys||n[0].raw===kc||n[0].text===kc)&&r.length===1&&r[0].type==="text"&&(r[0].text===ys||r[0].text===kc)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&s.length===0?ys:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Ev=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Tv=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ng=Te.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ke({find:Ev,type:this.type})]},addPasteRules(){return[He({find:Tv,type:this.type})]}});var rg=X.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var og=Te.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",H(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;let o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function ig(t={}){return new B({view(e){return new wc(e,t)}})}var wc=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:p.left,right:p.right,top:g-m,bottom:g+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(!n||i)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ho(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var yA=G.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new B({key:new U("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){t=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;let s=e.selection.$head.pos,l=s-(i-r),a=s;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),ag=G.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ig(this.options)]}}),bA=G.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new B({key:new U("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return Z.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(ye.node(c,c+a.nodeSize,{class:this.options.className}))}),Z.create(t,i)}}})]}}),cg=G.create({name:"gapCursor",addProseMirrorPlugins(){return[Mp()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Y(P(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),ug="placeholder",sg=new U("tiptap__placeholder");function dg(t){let{editor:e,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return s&&u.push(c),ye.node(o,o+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:o,hasAnchor:l}):n})}function fg(t,e){return typeof t=="function"?t(e):t}function hg({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],c=t.isEmpty;return r.nodesBetween(i,s,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&ur(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(dg({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:fg(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function pg({editor:t,options:e,dataAttribute:n,doc:r,selection:o}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&ur(c)){let d=i>=u&&i<=u+c.nodeSize;s.push(dg({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:fg(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else s.push(...hg({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return Z.create(r,s)}function yo(t,e){let n=t.resolve(e);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:e,to:e};let s=n.nodeAfter?e:e-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function bo(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function Av(t,e,n){let r=[];return t.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,c=l+1;a<n&&c>e&&r.push({from:s,to:l})}),r}function Nv(t){if(t.length===0)return[];let e=[...t].sort((r,o)=>r.from-o.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let o=n[n.length-1],i=e[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function Ov(t,e){let n=Av(t,e.from,e.to);return n.push(bo(t,yo(t,e.from))),e.to>e.from?n.push(bo(t,yo(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(bo(t,yo(t,Math.min(e.from+1,t.content.size)))),n}function Rv(t,e,n){let r=[];if(t.docChanged){let o=cr(t);for(let i of o)r.push(...Ov(n.doc,i.newRange))}return t.selectionSet&&(r.push(bo(n.doc,yo(n.doc,t.mapping.map(e.selection.anchor)))),r.push(bo(n.doc,yo(n.doc,n.selection.anchor)))),Nv(r)}function Dv(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function Iv({decorations:t,ranges:e,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=t;for(let a of e){let{from:c,to:u}=Dv(a.from,a.to,i),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=hg({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:c,to:u});f.length&&(l=l.add(i,f))}return l}function Pv({editor:t,options:e,dataAttribute:n}){return{init(r,o){let i=pg({editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection});return i??Z.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:Iv({decorations:o.map(r.mapping,r.doc),ranges:Rv(r,i,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function Lv(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function zv({editor:t,options:e}){let n=e.dataAttribute?`data-${Lv(e.dataAttribute)}`:`data-${ug}`,r=e.showOnlyCurrent&&!e.includeChildren;return new B({key:sg,...r?{}:{state:Pv({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>pg({editor:t,options:e,dataAttribute:n,doc:o,selection:i}):o=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?Z.empty:(i=sg.getState(o))!==null&&i!==void 0?i:Z.empty}}})}var xc=G.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:ug,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[zv({editor:this.editor,options:this.options})]}});function Sc(t,e){return!t.selection.empty&&!pi(t.selection)&&e.isEditable}function $v(t,e){return Sc(t,e)&&!e.isFocused&&!e.view.dragging}function Bv(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function Hv(t){t.focus()}var kA=G.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new B({key:new U("selection"),props:{decorations(n){return $v(n,t)?Z.create(n.doc,[ye.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Sc(n.state,t)&&Bv(),!1},focus(n){return Sc(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&Hv(n)}),!1}}}})]}});function lg({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var mg=G.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new U(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new B({key:e,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,f=c.nodes[n];if(!o.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!lg({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!lg({node:s,types:r})}}})]}}),gg=G.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ra(t,e),redo:()=>({state:t,dispatch:e})=>oa(t,e)}},addProseMirrorPlugins(){return[Qf(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Fv=G.create({name:"starterKit",addExtensions(){let t=[];if(this.options.bold!==!1&&t.push(hm.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(fm.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(fc.configure(this.options.bulletList)),this.options.code!==!1&&t.push(pm.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(mm.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(gm.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(ag.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(cg.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(ym.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(bm.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(gg.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(km.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(wm.configure(this.options.italic)),this.options.listItem!==!1&&t.push(mc.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(yc.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(Hm.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(bc.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(tg.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(ng.configure(this.options.strike)),this.options.text!==!1&&t.push(rg.configure(this.options.text)),this.options.underline!==!1){var r;t.push(og.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;t.push(mg.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return t}}),yg=Fv;var bg=xc;var Vv=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Wv=X.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",H(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,o,i,s;let l=(e=(n=t.attrs)===null||n===void 0?void 0:n.src)!==null&&e!==void 0?e:"",a=(r=(o=t.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:"",c=(i=(s=t.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let c=document.createElement("img");c.draggable=!1;let u=H(this.options.HTMLAttributes,l);Object.entries(u).forEach(([y,S])=>{if(S!=null)switch(y){case"src":case"width":case"height":break;default:c.setAttribute(y,S)}}),u.src!==null&&(c.src=u.src);let d={...l},f=y=>{if(typeof y=="string"&&y!==""){c.getAttribute("src")!==y&&(c.src=y);return}c.hasAttribute("src")&&c.removeAttribute("src"),c.src!==""&&(c.src="")};f(l.src);let h=y=>{if(y.type!==i.type)return!1;let S=a.extensionManager.attributes.filter(M=>M.type===y.type.name),v=pt(y,S);return Object.keys(d).forEach(M=>{!o.has(M)&&!(M in v)&&c.removeAttribute(M)}),Object.entries(v).forEach(([M,E])=>{o.has(M)||(E!=null?c.setAttribute(M,E):c.removeAttribute(M))}),f(v.src),d=v,!0},p=new Jh({element:c,editor:a,node:i,getPos:s,onResize:(y,S)=>{c.style.width=`${y}px`,c.style.height=`${S}px`},onCommit:(y,S)=>{let v=s();v!==void 0&&this.editor.chain().setNodeSelection(v).updateAttributes(this.name,{width:y,height:S}).run()},onUpdate:h,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),g=p.dom,m=()=>{g.style.visibility="",g.style.pointerEvents=""};return g.style.visibility="hidden",g.style.pointerEvents="none",c.complete&&c.naturalWidth>0?m():(c.onload=m,c.onerror=m),p}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[gi({find:Vv,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),kg=Wv;function ko(t){return t==="left"||t==="right"||t==="center"?t:null}function _v(t){let e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return ko(e||n)}function jv(t){return ko(t?.align)}function Cg(){return{default:null,parseHTML:t=>_v(t),renderHTML:t=>{let e=ko(t.align);return dr(e)?{style:`text-align: ${e}`}:{}}}}function Kv(t){var e;let n=t.parentElement,r=t.closest("table");if(!n||!r)return null;let o=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll("colgroup > col")[o])===null||e===void 0?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function Mg(t){let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):Kv(t)}var Uv=/[ \t\r\n\f]+/g;function Eg(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:"").replace(Uv,"")===""}function Tg(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}function ks(t,e,n){if(!(n in e))return;let r=e[n];(r===1||r==="1"||r===null||r===void 0)&&delete t[n]}var qv=X.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Mg},align:Cg()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>Eg(t)?{}:!1,getContent:(t,e)=>Tg(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){let e=H(this.options.HTMLAttributes,t);return ks(e,t,"colspan"),ks(e,t,"rowspan"),["td",e,0]}}),Jv=X.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Mg},align:Cg()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>Eg(t)?{}:!1,getContent:(t,e)=>Tg(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){let e=H(this.options.HTMLAttributes,t);return ks(e,t,"colspan"),ks(e,t,"rowspan"),["th",e,0]}}),Gv=X.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",H(this.options.HTMLAttributes,t),0]}});function vc(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function wg(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:g}=c.child(f).attrs;for(let m=0;m<p;m+=1,h+=1){let y=o===h?i:g&&g[m],S=y?`${y}px`:"";if(s+=y||r,y||(l=!1),a){if(a.style.width!==S){let[v,M]=vc(r,y);a.style.setProperty(v,M)}a=a.nextSibling}else{let v=document.createElement("col"),[M,E]=vc(r,y);v.style.setProperty(M,E),e.appendChild(v)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}let d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var Xv=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),wg(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,wg(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function Yv(t,e,n,r){let o=0,i=!0,s=[],l=t.firstChild;if(!l)return{};for(let u=0,d=0;u<l.childCount;u+=1){let{colspan:f,colwidth:h}=l.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){let g=n===d?r:h&&h[p];o+=g||e,g||(i=!1);let[m,y]=vc(e,g);s.push(["col",{style:`${m}: ${y}`}])}}let a=i?`${o}px`:"",c=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:c}}function Sg(t,e){return e?t.createChecked(null,e):t.createAndFill()}function Qv(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function Zv(t,e,n,r,o){let i=Qv(t),s=[],l=[];for(let c=0;c<n;c+=1){let u=Sg(i.cell,o);if(u&&l.push(u),r){let d=Sg(i.header_cell,o);d&&s.push(d)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function Ag(t){return t instanceof q}var bs=({editor:t})=>{let{selection:e}=t.state;if(!Ag(e))return!1;let n=0,r=ar(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function xg(t,e){let n=t.mapping.map(e),r=ar(t.selection.$from,s=>s.type.name==="table");if(r?.pos===n)return;let o=t.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;t.setSelection(O.near(t.doc.resolve(i),-1))}function eC(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!=="`"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]==="`";)r+=1;let o=n+r,i=!1;for(;o<t.length;){if(t[o]!=="`"){o+=1;continue}let s=0;for(;o+s<t.length&&t[o+s]==="`";)s+=1;if(s===r){let l=t.slice(n+r,o);e+=t.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+t.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(e+=t.slice(n,n+r),n+=r)}return e}function tC(t){return t.split(`
136
+ `),n=e===-1?t:t.slice(0,e);if(!fs.test(n))return[[],0,[]];let r=wv,o=Um(t,r),i=Km(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=Um(t,r),i=Km(o);return[i[0],i[1],o]}var xv="listItem",qm="textStyle",Jm=/^(\d+)\.\s$/;function Gm(t){let e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var bc=X.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute("type");if(e)return e;let n=t.getAttribute("style");if(n){let o=Gm(n);if(o)return o}let r=t.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let i=Gm(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,o=H(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),n&&n!=="1"&&(o.type=n),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,o=t.items?kv(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:o}:{type:"orderedList",content:o}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
137
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,o;let[i,s,l]=Sv(t);if(i.length===0)return;let a=tg(i,i[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=i[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,s).join(`
138
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(xv,this.editor.getAttributes(qm)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new B({props:{handlePaste:(t,e)=>{var n,r;let o=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(o?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let s=bv(i);if(!s)return!1;try{let l=t.state.schema.nodeFromJSON(s),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],e=Qt({find:Jm,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Qt({find:Jm,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(qm)}),joinPredicate:t,editor:this.editor})),[e]}}),vv=/^\s*(\[([( |x])?\])\s$/,Cv="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",Mv=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},ms=X.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",H(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return ka(t,e,r)},addExtensions(){return this.options.nested?[Xm(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");s.style.cssText=Cv;let c=d=>{let f=Mv(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),s.textContent=f};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let g=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([d,f])=>{o.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=pt(d,f),p=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(m=>{p.has(m)||(m in g?o.setAttribute(m,g[m]):o.removeAttribute(m))}),Object.entries(h).forEach(([m,y])=>{y==null?m in g?o.setAttribute(m,g[m]):o.removeAttribute(m):o.setAttribute(m,y)}),u=p,!0}}}},addInputRules(){return[Qt({find:vv,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),gs=X.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",H(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
139
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let s=ba(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(s){let l={type:"taskList",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=ba(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),YT=G.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(fc.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(mc.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(yc.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(bc.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(ms.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(gs.configure(this.options.taskList)),t}});var ys="&nbsp;",kc="\xA0",ng=X.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",H(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===ys||n[0].text===ys||n[0].raw===kc||n[0].text===kc)&&r.length===1&&r[0].type==="text"&&(r[0].text===ys||r[0].text===kc)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&s.length===0?ys:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Ev=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Tv=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,rg=Te.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ke({find:Ev,type:this.type})]},addPasteRules(){return[He({find:Tv,type:this.type})]}});var og=X.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var ig=Te.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",H(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;let o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function sg(t={}){return new B({view(e){return new wc(e,t)}})}var wc=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:p.left,right:p.right,top:g-m,bottom:g+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(!n||i)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ho(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var bA=G.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new B({key:new U("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){t=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;let s=e.selection.$head.pos,l=s-(i-r),a=s;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),cg=G.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[sg(this.options)]}}),kA=G.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new B({key:new U("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return Z.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(ye.node(c,c+a.nodeSize,{class:this.options.className}))}),Z.create(t,i)}}})]}}),ug=G.create({name:"gapCursor",addProseMirrorPlugins(){return[Ep()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Y(P(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),dg="placeholder",lg=new U("tiptap__placeholder");function fg(t){let{editor:e,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return s&&u.push(c),ye.node(o,o+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:o,hasAnchor:l}):n})}function hg(t,e){return typeof t=="function"?t(e):t}function pg({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],c=t.isEmpty;return r.nodesBetween(i,s,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&ur(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(fg({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:hg(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function mg({editor:t,options:e,dataAttribute:n,doc:r,selection:o}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&ur(c)){let d=i>=u&&i<=u+c.nodeSize;s.push(fg({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:hg(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else s.push(...pg({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return Z.create(r,s)}function yo(t,e){let n=t.resolve(e);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:e,to:e};let s=n.nodeAfter?e:e-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function bo(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function Av(t,e,n){let r=[];return t.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,c=l+1;a<n&&c>e&&r.push({from:s,to:l})}),r}function Nv(t){if(t.length===0)return[];let e=[...t].sort((r,o)=>r.from-o.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let o=n[n.length-1],i=e[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function Ov(t,e){let n=Av(t,e.from,e.to);return n.push(bo(t,yo(t,e.from))),e.to>e.from?n.push(bo(t,yo(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(bo(t,yo(t,Math.min(e.from+1,t.content.size)))),n}function Rv(t,e,n){let r=[];if(t.docChanged){let o=cr(t);for(let i of o)r.push(...Ov(n.doc,i.newRange))}return t.selectionSet&&(r.push(bo(n.doc,yo(n.doc,t.mapping.map(e.selection.anchor)))),r.push(bo(n.doc,yo(n.doc,n.selection.anchor)))),Nv(r)}function Dv(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function Iv({decorations:t,ranges:e,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=t;for(let a of e){let{from:c,to:u}=Dv(a.from,a.to,i),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=pg({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:c,to:u});f.length&&(l=l.add(i,f))}return l}function Pv({editor:t,options:e,dataAttribute:n}){return{init(r,o){let i=mg({editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection});return i??Z.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:Iv({decorations:o.map(r.mapping,r.doc),ranges:Rv(r,i,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function Lv(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function zv({editor:t,options:e}){let n=e.dataAttribute?`data-${Lv(e.dataAttribute)}`:`data-${dg}`,r=e.showOnlyCurrent&&!e.includeChildren;return new B({key:lg,...r?{}:{state:Pv({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>mg({editor:t,options:e,dataAttribute:n,doc:o,selection:i}):o=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?Z.empty:(i=lg.getState(o))!==null&&i!==void 0?i:Z.empty}}})}var xc=G.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:dg,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[zv({editor:this.editor,options:this.options})]}});function Sc(t,e){return!t.selection.empty&&!pi(t.selection)&&e.isEditable}function $v(t,e){return Sc(t,e)&&!e.isFocused&&!e.view.dragging}function Bv(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function Hv(t){t.focus()}var wA=G.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new B({key:new U("selection"),props:{decorations(n){return $v(n,t)?Z.create(n.doc,[ye.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Sc(n.state,t)&&Bv(),!1},focus(n){return Sc(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&Hv(n)}),!1}}}})]}});function ag({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var gg=G.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new U(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new B({key:e,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,f=c.nodes[n];if(!o.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!ag({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!ag({node:s,types:r})}}})]}}),yg=G.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ra(t,e),redo:()=>({state:t,dispatch:e})=>oa(t,e)}},addProseMirrorPlugins(){return[Qf(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Fv=G.create({name:"starterKit",addExtensions(){let t=[];if(this.options.bold!==!1&&t.push(pm.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(hm.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(fc.configure(this.options.bulletList)),this.options.code!==!1&&t.push(mm.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(gm.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(ym.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(cg.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(ug.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(bm.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(km.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(yg.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(wm.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Sm.configure(this.options.italic)),this.options.listItem!==!1&&t.push(mc.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(yc.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(Fm.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(bc.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(ng.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(rg.configure(this.options.strike)),this.options.text!==!1&&t.push(og.configure(this.options.text)),this.options.underline!==!1){var r;t.push(ig.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;t.push(gg.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return t}}),bg=Fv;var kg=xc;var Vv=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Wv=X.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",H(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,o,i,s;let l=(e=(n=t.attrs)===null||n===void 0?void 0:n.src)!==null&&e!==void 0?e:"",a=(r=(o=t.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:"",c=(i=(s=t.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let c=document.createElement("img");c.draggable=!1;let u=H(this.options.HTMLAttributes,l);Object.entries(u).forEach(([y,S])=>{if(S!=null)switch(y){case"src":case"width":case"height":break;default:c.setAttribute(y,S)}}),u.src!==null&&(c.src=u.src);let d={...l},f=y=>{if(typeof y=="string"&&y!==""){c.getAttribute("src")!==y&&(c.src=y);return}c.hasAttribute("src")&&c.removeAttribute("src"),c.src!==""&&(c.src="")};f(l.src);let h=y=>{if(y.type!==i.type)return!1;let S=a.extensionManager.attributes.filter(M=>M.type===y.type.name),v=pt(y,S);return Object.keys(d).forEach(M=>{!o.has(M)&&!(M in v)&&c.removeAttribute(M)}),Object.entries(v).forEach(([M,E])=>{o.has(M)||(E!=null?c.setAttribute(M,E):c.removeAttribute(M))}),f(v.src),d=v,!0},p=new Jh({element:c,editor:a,node:i,getPos:s,onResize:(y,S)=>{c.style.width=`${y}px`,c.style.height=`${S}px`},onCommit:(y,S)=>{let v=s();v!==void 0&&this.editor.chain().setNodeSelection(v).updateAttributes(this.name,{width:y,height:S}).run()},onUpdate:h,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),g=p.dom,m=()=>{g.style.visibility="",g.style.pointerEvents=""};return g.style.visibility="hidden",g.style.pointerEvents="none",c.complete&&c.naturalWidth>0?m():(c.onload=m,c.onerror=m),p}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[gi({find:Vv,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),wg=Wv;function ko(t){return t==="left"||t==="right"||t==="center"?t:null}function _v(t){let e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return ko(e||n)}function jv(t){return ko(t?.align)}function Mg(){return{default:null,parseHTML:t=>_v(t),renderHTML:t=>{let e=ko(t.align);return dr(e)?{style:`text-align: ${e}`}:{}}}}function Kv(t){var e;let n=t.parentElement,r=t.closest("table");if(!n||!r)return null;let o=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll("colgroup > col")[o])===null||e===void 0?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function Eg(t){let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):Kv(t)}var Uv=/[ \t\r\n\f]+/g;function Tg(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:"").replace(Uv,"")===""}function Ag(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}function ks(t,e,n){if(!(n in e))return;let r=e[n];(r===1||r==="1"||r===null||r===void 0)&&delete t[n]}var qv=X.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Eg},align:Mg()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>Tg(t)?{}:!1,getContent:(t,e)=>Ag(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){let e=H(this.options.HTMLAttributes,t);return ks(e,t,"colspan"),ks(e,t,"rowspan"),["td",e,0]}}),Jv=X.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Eg},align:Mg()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>Tg(t)?{}:!1,getContent:(t,e)=>Ag(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){let e=H(this.options.HTMLAttributes,t);return ks(e,t,"colspan"),ks(e,t,"rowspan"),["th",e,0]}}),Gv=X.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",H(this.options.HTMLAttributes,t),0]}});function vc(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Sg(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:g}=c.child(f).attrs;for(let m=0;m<p;m+=1,h+=1){let y=o===h?i:g&&g[m],S=y?`${y}px`:"";if(s+=y||r,y||(l=!1),a){if(a.style.width!==S){let[v,M]=vc(r,y);a.style.setProperty(v,M)}a=a.nextSibling}else{let v=document.createElement("col"),[M,E]=vc(r,y);v.style.setProperty(M,E),e.appendChild(v)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}let d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var Xv=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sg(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,Sg(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function Yv(t,e,n,r){let o=0,i=!0,s=[],l=t.firstChild;if(!l)return{};for(let u=0,d=0;u<l.childCount;u+=1){let{colspan:f,colwidth:h}=l.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){let g=n===d?r:h&&h[p];o+=g||e,g||(i=!1);let[m,y]=vc(e,g);s.push(["col",{style:`${m}: ${y}`}])}}let a=i?`${o}px`:"",c=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:c}}function xg(t,e){return e?t.createChecked(null,e):t.createAndFill()}function Qv(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function Zv(t,e,n,r,o){let i=Qv(t),s=[],l=[];for(let c=0;c<n;c+=1){let u=xg(i.cell,o);if(u&&l.push(u),r){let d=xg(i.header_cell,o);d&&s.push(d)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function Ng(t){return t instanceof q}var bs=({editor:t})=>{let{selection:e}=t.state;if(!Ng(e))return!1;let n=0,r=ar(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function vg(t,e){let n=t.mapping.map(e),r=ar(t.selection.$from,s=>s.type.name==="table");if(r?.pos===n)return;let o=t.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;t.setSelection(O.near(t.doc.resolve(i),-1))}function eC(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!=="`"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]==="`";)r+=1;let o=n+r,i=!1;for(;o<t.length;){if(t[o]!=="`"){o+=1;continue}let s=0;for(;o+s<t.length&&t[o+s]==="`";)s+=1;if(s===r){let l=t.slice(n+r,o);e+=t.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+t.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(e+=t.slice(n,n+r),n+=r)}return e}function tC(t){return t.split(`
140
140
  `).map(e=>!e.includes("|")||!e.includes("`")?e:eC(e)).join(`
141
- `)}function nC(t){return(t||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function vg(t,e){return e?t.split(e).join(`
142
- `):t}function rC(t){return t.replace(/\\.|\|/g,e=>e==="|"?"\\|":e)}function oC(t,e,n={}){if(!t||!t.content||t.content.length===0)return"";let r=[];t.content.forEach(f=>{let h=[];f.content&&f.content.forEach(p=>{let g="";p.content&&Array.isArray(p.content)&&p.content.length>1?g=p.content.map(v=>vg(e.renderChildren(v),n.cellLineSeparator)).join(`
143
- `):g=vg(p.content?e.renderChildren(p.content):"",n.cellLineSeparator);let m=rC(nC(g.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),y=p.type==="tableHeader",S=jv(p.attrs);h.push({text:m,isHeader:y,align:S})}),r.push(h)});let o=r.reduce((f,h)=>Math.max(f,h.length),0);if(o===0)return"";let i=Array.from({length:o}).fill(0);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;let g=(((h=f[p])===null||h===void 0?void 0:h.text)||"").length;g>i[p]&&(i[p]=g),i[p]<3&&(i[p]=3)}});let s=(f,h)=>f+" ".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:o}).fill(null);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;!c[p]&&(!((h=f[p])===null||h===void 0)&&h.align)&&(c[p]=f[p].align)}});let u=`
141
+ `)}function nC(t){return(t||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function Cg(t,e){return e?t.split(e).join(`
142
+ `):t}function rC(t){return t.replace(/\\.|\|/g,e=>e==="|"?"\\|":e)}function oC(t,e,n={}){if(!t||!t.content||t.content.length===0)return"";let r=[];t.content.forEach(f=>{let h=[];f.content&&f.content.forEach(p=>{let g="";p.content&&Array.isArray(p.content)&&p.content.length>1?g=p.content.map(v=>Cg(e.renderChildren(v),n.cellLineSeparator)).join(`
143
+ `):g=Cg(p.content?e.renderChildren(p.content):"",n.cellLineSeparator);let m=rC(nC(g.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),y=p.type==="tableHeader",S=jv(p.attrs);h.push({text:m,isHeader:y,align:S})}),r.push(h)});let o=r.reduce((f,h)=>Math.max(f,h.length),0);if(o===0)return"";let i=Array.from({length:o}).fill(0);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;let g=(((h=f[p])===null||h===void 0?void 0:h.text)||"").length;g>i[p]&&(i[p]=g),i[p]<3&&(i[p]=3)}});let s=(f,h)=>f+" ".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:o}).fill(null);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;!c[p]&&(!((h=f[p])===null||h===void 0)&&h.align)&&(c[p]=f[p].align)}});let u=`
144
144
  `,d=Array.from({length:o}).map((f,h)=>a&&l[h]&&l[h].text||"");return u+=`| ${d.map((f,h)=>s(f,i[h])).join(" | ")} |
145
145
  `,u+=`| ${i.map((f,h)=>{let p=Math.max(3,f),g=c[h];return g==="left"?`:${"-".repeat(p)}`:g==="right"?`${"-".repeat(p)}:`:g==="center"?`:${"-".repeat(p)}:`:"-".repeat(p)}).join(" | ")} |
146
146
  `,(a?r.slice(1):r).forEach(f=>{u+=`| ${Array.from({length:o}).fill(0).map((h,p)=>s(f[p]&&f[p].text||"",i[p])).join(" | ")} |
147
- `}),u}var iC=new U("preserveCellSelectionOnContextMenu");function sC(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n)return n.pos;if(!(e.target instanceof Node))return null;try{return t.posAtDOM(e.target,0)}catch{return null}}function lC(t,e){let n=!1;return t.forEachCell((r,o)=>{e>=o&&e<o+r.nodeSize&&(n=!0)}),n}function aC(){return new B({key:iC,props:{handleDOMEvents:{mousedown(t,e){if(e.button!==2)return!1;let{selection:n}=t.state;if(!Ag(n)||n.ranges.length<2)return!1;let r=sC(t,e);return r==null||!lC(n,r)?!1:(e.preventDefault(),!0)}}}})}var cC=X.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Xv,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=Yv(t,this.options.cellMinWidth),i=e.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",H(this.options.HTMLAttributes,e,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let o=[];t.header.forEach((i,s)=>{var l;let a=ko((l=r[s])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};o.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},o))}return t.rows&&t.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=ko((a=r[l])!==null&&a!==void 0?a:s.align),u=c?{align:c}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>oC(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{let e=t.split(`
147
+ `}),u}var iC=new U("preserveCellSelectionOnContextMenu");function sC(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n)return n.pos;if(!(e.target instanceof Node))return null;try{return t.posAtDOM(e.target,0)}catch{return null}}function lC(t,e){let n=!1;return t.forEachCell((r,o)=>{e>=o&&e<o+r.nodeSize&&(n=!0)}),n}function aC(){return new B({key:iC,props:{handleDOMEvents:{mousedown(t,e){if(e.button!==2)return!1;let{selection:n}=t.state;if(!Ng(n)||n.ranges.length<2)return!1;let r=sC(t,e);return r==null||!lC(n,r)?!1:(e.preventDefault(),!0)}}}})}var cC=X.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Xv,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=Yv(t,this.options.cellMinWidth),i=e.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",H(this.options.HTMLAttributes,e,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let o=[];t.header.forEach((i,s)=>{var l;let a=ko((l=r[s])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};o.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},o))}return t.rows&&t.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=ko((a=r[l])!==null&&a!==void 0?a:s.align),u=c?{align:c}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>oC(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{let e=t.split(`
148
148
  `);if(e.length<2)return-1;let n=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(t,e,n){let r=t.indexOf(`
149
149
 
150
150
  `),o=r>=0?t.slice(0,r):t,i=o.split(`
151
151
  `);if(i.length<2)return;let s=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(s)||!s.includes("|"))return;let l=tC(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let c=a.raw.split(`
152
152
  `).length,u=t.split(`
153
153
  `).slice(0,c).join(`
154
- `);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=Zv(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(O.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Vp(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Wp(t,e),deleteColumn:()=>({state:t,dispatch:e})=>{let n=ar(t.selection.$from,r=>r.type.name==="table");return _p(t,e&&(r=>{n&&xg(r,n.pos),e(r)}))},addRowBefore:()=>({state:t,dispatch:e})=>Kp(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Up(t,e),deleteRow:()=>({state:t,dispatch:e})=>{let n=ar(t.selection.$from,r=>r.type.name==="table");return qp(t,e&&(r=>{n&&xg(r,n.pos),e(r)}))},deleteTable:()=>({state:t,dispatch:e})=>Xp(t,e),mergeCells:()=>({state:t,dispatch:e})=>$a(t,e),splitCell:()=>({state:t,dispatch:e})=>Ba(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>pr("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>pr("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Gp(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>$a(t,e)?!0:Ba(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>Jp(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Ha(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Ha(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&za(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=q.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:bs,"Mod-Backspace":bs,Delete:bs,"Mod-Delete":bs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Qp({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],em({allowTableNodeSelection:this.options.allowTableNodeSelection}),aC()]},addNodeView(){let t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r,HTMLAttributes:o})=>{let i=H(this.options.HTMLAttributes,o);return new e(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Y(P(t,"tableRole",e))}}}),Ng=G.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(cC.configure(this.options.table)),this.options.tableCell!==!1&&t.push(qv.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Jv.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Gv.configure(this.options.tableRow)),t}});var Og=gs;var Rg=ms;var uC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,dC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,fC=Te.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||jh(t,"background-color")||t.style.backgroundColor,renderHTML:t=>dr(t.color)?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",H(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){let r=/^(==)([^=]+)(==)/.exec(t);if(r){let o=r[2].trim(),i=n.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:i}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ke({find:uC,type:this.type})]},addPasteRules(){return[He({find:dC,type:this.type})]}}),Dg=fC;var Ig=Dg.extend({addAttributes(){let t=this.parent?.()??{};return this.options.multicolor?{...t,color:{...t.color,renderHTML:({color:e})=>e?{"data-color":e,style:`--showai-highlight-color: ${e}`}:{}}}:t}});var hC=G.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{let e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>!dr(t.textAlign)||!this.options.alignments.includes(t.textAlign)?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Pg=hC;var Lg=G.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new B({view(t){let e=t.dom.ownerDocument,n=e.defaultView,r=()=>{let o=e.createEvent("Event");o.initEvent("dragleave",!1,!1),t.dom.dispatchEvent(o)};return e.addEventListener("drop",r,!0),e.addEventListener("dragend",r,!0),n?.addEventListener("blur",r),{destroy(){e.removeEventListener("drop",r,!0),e.removeEventListener("dragend",r,!0),n?.removeEventListener("blur",r)}}}})]}});var br=me(vr(),1);var ke=me(kt(),1);function zg({node:t,updateAttributes:e,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,br.useContext)(To),s=ki({editor:n,selector:({editor:l})=>l.isEditable});return(0,ke.jsx)(no,{className:`document-widget${r&&s?" is-selected":""}`,"data-widget-kind":t.attrs.kind,"data-block-id":t.attrs.id??void 0,onPointerDownCapture:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;let a=o();!r&&typeof a=="number"&&n.commands.setNodeSelection(a)},onClick:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;let a=o();typeof a=="number"&&(n.commands.setNodeSelection(a),l.stopPropagation())},children:i({kind:t.attrs.kind,data:t.attrs.data,onChange:l=>{n.isEditable&&e({data:l})},readOnly:!s})})}var Cc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],Mc=["sage","sand","blue","rose"];function $g({node:t,updateAttributes:e,editor:n}){let r=ct(Le),o=ki({editor:n,selector:({editor:i})=>i.isEditable});return(0,ke.jsxs)(no,{className:`document-callout tone-${t.attrs.tone}`,"data-block-id":t.attrs.id??void 0,children:[(0,ke.jsxs)("div",{className:"callout-decoration",contentEditable:!1,children:[(0,ke.jsx)("button",{className:"callout-icon",disabled:!o,title:r("callout.changeIcon"),"aria-label":r("callout.changeIconLabel"),onClick:()=>e({icon:Cc[(Cc.indexOf(t.attrs.icon)+1)%Cc.length]}),children:t.attrs.icon}),o&&(0,ke.jsx)("button",{className:"callout-color",title:r("callout.changeColor"),"aria-label":r("callout.changeColorLabel"),onClick:()=>e({tone:Mc[(Mc.indexOf(t.attrs.tone)+1)%Mc.length]})})]}),(0,ke.jsx)(Ca,{className:"callout-content"})]})}function Bg({node:t,updateAttributes:e,editor:n}){let r=ct(Le),o=ki({editor:n,selector:({editor:l})=>l.isEditable}),[i,s]=(0,br.useState)(!!t.attrs.open);return(0,br.useEffect)(()=>s(!!t.attrs.open),[t.attrs.open]),(0,ke.jsxs)(no,{className:`document-toggle${i?" is-open":""}`,"data-block-id":t.attrs.id??void 0,children:[(0,ke.jsxs)("div",{className:"toggle-heading",contentEditable:!1,children:[(0,ke.jsx)("button",{"aria-label":r(i?"toggle.collapse":"toggle.expand"),"aria-expanded":i,onClick:()=>{s(!i),n.isEditable&&e({open:!i})},children:(0,ke.jsx)(Co,{size:16})}),o?(0,ke.jsx)("input",{"aria-label":r("toggle.titleLabel"),value:t.attrs.title,onChange:l=>e({title:l.target.value}),placeholder:r("toggle.titlePlaceholder")}):(0,ke.jsx)("span",{children:t.attrs.title})]}),(0,ke.jsx)("div",{className:"toggle-body",hidden:!i,children:(0,ke.jsx)(Ca,{})})]})}function Hg({node:t,updateAttributes:e,editor:n,selected:r}){let o=ct(Le),i=t.type.name==="mathBlock"||t.attrs.display;return(0,ke.jsxs)(no,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,ke.jsx)("span",{dangerouslySetInnerHTML:{__html:hu(t.attrs.latex,i)}}),r&&n.isEditable&&(0,ke.jsx)("input",{"aria-label":o("math.source"),value:t.attrs.latex,onChange:s=>e({latex:s.target.value}),onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),n.commands.focus())}})]})}var Wg=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","widget","mathInline","mathBlock"],ws=new U("showaiBlockIds");function pC(t){let e=new Set([...Wg,"region","richText","pageModule"]);return new B({key:ws,appendTransaction(n,r,o){if(!t()||!n.some(l=>l.docChanged||l.getMeta(ws)||l.getMeta("editableChanged")))return null;let i=new Set,s=o.tr;return o.doc.descendants((l,a)=>{if(!e.has(l.type.name))return;let c=l.attrs.id;if(typeof c=="string"&&c.trim()&&!i.has(c)){i.add(c);return}let u;do u=globalThis.crypto.randomUUID();while(i.has(u));i.add(u),s.setNodeAttribute(a,"id",u)}),s.docChanged?s.setMeta(ws,!0).setMeta("addToHistory",!1):null}})}var mC=G.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[...Wg,"region","richText","pageModule"],attributes:{id:{default:null,parseHTML:t=>t.getAttribute("data-block-id"),renderHTML:t=>typeof t.id=="string"&&t.id.trim()?{"data-block-id":t.id}:{}}}}]},addProseMirrorPlugins(){return[pC(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta(ws,!0).setMeta("addToHistory",!1))}}),gC=X.create({name:"widget",group:"block",atom:!0,draggable:!0,addAttributes(){return{kind:{default:"chart"},data:{default:{},parseHTML:t=>{let e=t.getAttribute("data-widget-content");if(!e)return{};try{return JSON.parse(e)}catch{return{}}},renderHTML:t=>({"data-widget-content":JSON.stringify(t.data)})}}},parseHTML:()=>[{tag:"div[data-showai-widget]"}],renderHTML:({HTMLAttributes:t})=>["div",H(t,{"data-showai-widget":""})],addNodeView:()=>ro(zg)}),yC=X.create({name:"callout",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({icon:{default:"\u{1F4A1}"},tone:{default:"sage"}}),parseHTML:()=>[{tag:"aside[data-callout]"}],renderHTML:({HTMLAttributes:t})=>["aside",H(t,{"data-callout":""}),0],addNodeView:()=>ro($g)}),bC=X.create({name:"toggle",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({title:{default:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A"},open:{default:!0}}),parseHTML:()=>[{tag:"section[data-toggle]"}],renderHTML:({HTMLAttributes:t})=>["section",H(t,{"data-toggle":""}),0],addNodeView:()=>ro(Bg)}),kC=X.create({name:"richText",priority:50,group:"block",content:"block*",defining:!0,addAttributes:()=>({id:{default:null},name:{default:"\u5BCC\u6587\u672C"},data:{default:{},parseHTML:t=>JSON.parse(t.getAttribute("data-rich-text-settings")||"{}"),renderHTML:()=>({})}}),parseHTML:()=>[{tag:'div[data-component-kind="text"]'},{tag:'div[data-page-flow="richText"]'}],renderHTML:({node:t,HTMLAttributes:e})=>["div",H(e,{"data-component-kind":"text","data-rich-text-settings":JSON.stringify(t.attrs.data),class:"page-document-flow rich-text-component",style:Object.entries(mu(t.attrs.data)).filter(([,n])=>n!==void 0).map(([n,r])=>`${n.replace(/[A-Z]/g,o=>"-"+o.toLowerCase())}:${typeof r=="number"?`${r}px`:r}`).join(";")}),0]}),wC=Te.create({name:"textStyle",addAttributes:()=>Object.fromEntries(["color","fontFamily","fontSize"].map(t=>[t,{default:null,parseHTML:e=>e.style[t],renderHTML:e=>e[t]?{style:`${t.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}: ${e[t]}`}:{}}])),parseHTML:()=>[{tag:"span[style]"}],renderHTML:({HTMLAttributes:t})=>["span",H(t),0]}),Fg=t=>X.create({name:t?"mathInline":"mathBlock",group:t?"inline":"block",inline:t,atom:!0,addAttributes:()=>({latex:{default:""},display:{default:!t}}),parseHTML:()=>[{tag:t?"span[data-math]":"div[data-math]"}],renderHTML:({node:e,HTMLAttributes:n})=>[t?"span":"div",{...n,"data-math":e.attrs.latex}],addNodeView:()=>ro(Hg)}),Vg=Fn(Le);function _g(t={}){return[kC,wC,Fg(!0),Fg(!1),mC.configure({readOnly:t.readOnly??!1}),Lg,yg.configure({trailingNode:t.trailingNode===!1?!1:{},heading:{levels:[1,2,3,4,5,6]},link:{openOnClick:t.readOnly??!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}},codeBlock:{HTMLAttributes:{class:"code-block"}}}),bg.configure({placeholder:({node:e})=>e.type.name==="heading"?Vg("placeholderHeading"):typeof t.placeholder=="function"?t.placeholder():t.placeholder??Vg("placeholderDefault"),includeChildren:!1}),kg.configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),Ng.configure({table:{resizable:!0}}),om,Og,Rg.configure({nested:!0}),Ig.configure({multicolor:!0}),Pg.configure({types:["heading","paragraph"]}),yC,bC,gC]}var w=me(kt(),1),jg=new WeakSet,Kg=Fn(Le),SC={"":"format.fontDefault","sans-serif":"format.fontSans",serif:"format.fontSerif",monospace:"format.fontMono"};function Ae({label:t,children:e,onClick:n,active:r,disabled:o}){return(0,w.jsx)("button",{type:"button",className:`editor-tool${r?" is-active":""}`,"aria-label":t,title:t,"aria-pressed":r,disabled:o,onMouseDown:i=>i.preventDefault(),onClick:n,children:e})}function xC(t){return/^https?:\/\//i.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(t)}function Ug(t){return/^(https?:\/\/|mailto:|tel:|#)/i.test(t)}function qg(t){return t.startsWith("page-tail-")}function vC(t,e,n){let r=[],o=[];return t.state.doc.nodesBetween(e,n,(i,s,l)=>{let a=i.attrs?.id;typeof a!="string"||qg(a)||(i.isTextblock?r.push(a):l===t.state.doc&&o.push(a))}),[...new Set(r.length?r:o)].slice(0,100)}function Ec(t,e){let n=t.view.coordsAtPos(Math.min(e,t.state.doc.content.size));return{left:Math.max(12,Math.min(n.left,window.innerWidth-340)),top:Math.max(70,Math.min(n.bottom+8,window.innerHeight-370))}}function CC({content:t,onChange:e,readOnly:n=!1,minimal:r=!0,onEditorReady:o,onInsertNative:i,onDetachBlock:s,additionalExtensions:l,trailingNode:a=!0,retentionKey:c}){let u=ct(Le),d=(0,z.useRef)(e),f=(0,z.useId)();d.current=e;let h=(0,z.useRef)(null),p=(0,z.useRef)(null),g=(0,z.useRef)(null),m=(0,z.useRef)(null),y=(0,z.useRef)(null),S=(0,z.useRef)([]),v=(0,z.useRef)(()=>{}),M=(0,z.useRef)(0),E=(0,z.useRef)(null),[L,N]=(0,z.useState)(null),{useCatalog:_,registerComponent:te,assistant:ae}=(0,z.useContext)(To),le=_(!!L),[rt,Ve]=(0,z.useState)(!1),We=(0,z.useRef)(0);(0,z.useEffect)(()=>()=>{We.current++},[]);let[we,Xe]=(0,z.useState)(0),[ie,Bt]=(0,z.useState)(null),[rn,_e]=(0,z.useState)(!1),zn=(0,z.useRef)(null),Ac=(0,z.useRef)(rn);Ac.current=rn;let wo=(0,z.useRef)(0),Nc=(0,z.useRef)(0);(0,z.useEffect)(()=>()=>cancelAnimationFrame(wo.current),[]);let Ht=(0,z.useCallback)(()=>{zn.current!==null&&(clearTimeout(zn.current),zn.current=null)},[]),Oc=(0,z.useCallback)(()=>{zn.current===null&&(zn.current=setTimeout(()=>{zn.current=null;let b=h.current?.querySelector(".block-handle");Ac.current||E.current!==null||b?.contains(document.activeElement)||Bt(null)},450))},[]);(0,z.useEffect)(()=>Ht,[Ht]);let[kr,$n]=(0,z.useState)(!1),[wr,at]=(0,z.useState)(!1),[ue,Ye]=(0,z.useState)(null),[Rc,So]=(0,z.useState)(""),[xo,Bn]=(0,z.useState)(""),[vo,bt]=(0,z.useState)(null),Hn=(0,z.useRef)(null),Ft=(0,z.useRef)(!1),[,Dc]=(0,z.useState)(0),Sr=(0,z.useRef)(null);m.current=L,M.current=we;let Jg=(0,z.useMemo)(()=>[..._g({placeholder:()=>Kg("placeholder"),trailingNode:a}),...l??[]],[l,a]),k=Sp({retentionKey:c,extensions:Jg,content:t,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":Kg("documentContent"),spellcheck:"false"},handleKeyDown:(b,C)=>{if(C.isComposing)return!1;if(C.key==="Escape"&&!m.current&&!b.state.selection.empty)return Hn.current=`${b.state.selection.from}:${b.state.selection.to}`,bt(null),C.preventDefault(),!0;if(!m.current)return!1;if(C.key==="Escape")return Ss(),!0;if(C.key==="ArrowDown"||C.key==="ArrowUp"){C.preventDefault();let I=S.current.length;return Xe(V=>I?(V+(C.key==="ArrowDown"?1:-1)+I)%I:0),!0}return C.key==="Enter"&&S.current.length?(v.current(M.current),!0):!1},handleClick:(b,C,I)=>{let V=I.target.closest?.("a[href]");if(!V||!n&&!I.metaKey&&!I.ctrlKey)return!1;let F=V.getAttribute("href")??"";return Ug(F)&&(F.startsWith("#")?document.getElementById(F.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):window.open(F,"_blank","noopener,noreferrer")),!0},handlePaste:(b,C)=>{let I=[...C.clipboardData?.files??[]].filter(V=>V.type.startsWith("image/"));return I.length?(C.preventDefault(),xs(I),!0):!1}},onUpdate:({editor:b,transaction:C})=>d.current(Ta(b.state.doc),{separateHistory:!!C.getMeta(Dn)})});(0,z.useEffect)(()=>{k&&o?.(k)},[k,o]),(0,z.useEffect)(()=>{k&&k.isEditable===n&&(k.setEditable(!n,!1),k.view.dispatch(k.state.tr.setMeta("editableChanged",!0))),Dc(b=>b+1),n&&(N(null),Bt(null),_e(!1),$n(!1),at(!1),Ye(null),bt(null))},[k,n]),(0,z.useLayoutEffect)(()=>{if(!k)return;let b,C=()=>{if(k.isDestroyed)return;if(k.view.composing){b=setTimeout(C,25);return}let V=Ep(k.state,t);if(!V)return;let F=k.state.selection instanceof D&&k.state.selection.node.type.name==="widget"?k.state.selection.node.attrs.id:null,J=k.state.selection instanceof q?k.state.selection:null;if(k.view.dispatch(V),J){let oe=nm(k.state.doc,J);oe&&k.view.dispatch(k.state.tr.setSelection(oe))}if(F){let oe;if(k.state.doc.descendants((re,j)=>{re.type.name==="widget"&&re.attrs.id===F&&(oe=j)}),oe!==void 0)k.commands.setNodeSelection(oe);else{let re=Si(k.state);re&&k.view.dispatch(re)}}},I=()=>{b=setTimeout(C,25)};return k.view.composing?k.view.dom.addEventListener("compositionend",I):C(),()=>{b&&clearTimeout(b),k.view.dom.removeEventListener("compositionend",I)}},[t,k]),(0,z.useEffect)(()=>{if(!ue)return;let b=requestAnimationFrame(()=>document.querySelector(".editor-modal input")?.focus()),C=I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),Ye(null),k?.commands.focus()),I.key!=="Tab")return;let V=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled)")),F=V[0],J=V[V.length-1];I.shiftKey&&document.activeElement===F?(I.preventDefault(),J?.focus()):!I.shiftKey&&document.activeElement===J&&(I.preventDefault(),F?.focus())};return document.addEventListener("keydown",C,!0),()=>{cancelAnimationFrame(b),document.removeEventListener("keydown",C,!0)}},[!!ue,k]),(0,z.useEffect)(()=>{if(!k||n)return;let b=()=>{let I=Si(k.state);I&&k.view.dispatch(I)};!jg.has(k)&&!wp(k)&&(jg.add(k),k.isInitialized?b():k.on("create",b));let C=I=>{if(I.button!==0||!(I.target instanceof Element))return;let V=I.target,F=V.closest(".document-widget");if(F&&k.view.dom.contains(F)||!F&&V.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let J=Si(k.state);if(!J)return;let oe=document.activeElement;oe instanceof HTMLElement&&k.view.dom.contains(oe)&&oe.blur(),k.view.dispatch(J),k.view.dom.contains(V)&&!V.closest("[data-block-id]")&&I.preventDefault()};return document.addEventListener("pointerdown",C,!0),()=>{k.off("create",b),document.removeEventListener("pointerdown",C,!0)}},[k,n]),(0,z.useEffect)(()=>{if(!L?.manual)return;let b=requestAnimationFrame(()=>g.current?.focus());return()=>cancelAnimationFrame(b)},[L?.manual]),(0,z.useEffect)(()=>{if(!kr&&!wr&&!rn)return;let b=C=>{C.key==="Escape"&&(C.preventDefault(),$n(!1),at(!1),_e(!1),k?.commands.focus())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[kr,wr,rn,k]),(0,z.useEffect)(()=>{if(!xo)return;let b=window.setTimeout(()=>Bn(""),4500);return()=>window.clearTimeout(b)},[xo]),(0,z.useEffect)(()=>{if(!k)return;let b=()=>{if((!r||!k.state.selection.empty)&&Dc(an=>an+1),!k.isEditable)return;let{selection:j}=k.state,{$from:Se,from:sn,to:Vt,empty:ln}=j;if((ln||Hn.current&&Hn.current!==`${sn}:${Vt}`)&&(Hn.current=null),!m.current?.manual){let an=Se.parent.isTextblock?Se.parent.textBetween(0,Se.parentOffset,`
155
- `):"",cn=ln&&an.match(/^\/([^\n/]*)$/);if(cn){let zc=sn-cn[0].length;y.current!==`${zc}:${Vt}:${cn[1]}`&&(y.current=null,N({from:zc,to:Vt,query:cn[1],...Ec(k,sn)}))}else N(null),y.current=null}if(!ln&&Hn.current!==`${sn}:${Vt}`&&(k.isFocused||Ft.current)&&!k.isActive("codeBlock")&&!k.isActive("widget")&&!k.isActive("pageModule")){let an=k.view.coordsAtPos(sn),cn=k.view.coordsAtPos(Vt);bt({left:(an.left+cn.right)/2,top:an.top,bottom:Math.max(an.bottom,cn.bottom)})}else bt(null)},C=j=>j instanceof Element&&j.closest(".editor-bubble")?.id===f,I=j=>{C(j.relatedTarget)&&(Ft.current=!0)},V=()=>{Ft.current=!1,bt(null)},F=j=>{Ft.current=C(j.target),!Ft.current&&(!(j.target instanceof Node)||!k.view.dom.contains(j.target))&&V()},J=({event:j})=>{!Ft.current&&!C(j.relatedTarget)&&V()},oe=j=>{C(j.target)||V()},re=j=>{!(j.target instanceof Element)||!j.target.contains(k.view.dom)||(bt(null),N(null),_e(!1),Bt(null))};return k.on("transaction",b),k.on("focus",b),k.on("blur",J),k.view.dom.addEventListener("blur",I,!0),document.addEventListener("pointerdown",F,!0),document.addEventListener("focusin",F,!0),k.view.dom.addEventListener("contextmenu",V),window.addEventListener("scroll",oe,!0),window.addEventListener("resize",b),window.addEventListener("showai:viewport-change",re),()=>{k.off("transaction",b),k.off("focus",b),k.off("blur",J),k.view.dom.removeEventListener("blur",I,!0),document.removeEventListener("pointerdown",F,!0),document.removeEventListener("focusin",F,!0),k.view.dom.removeEventListener("contextmenu",V),window.removeEventListener("scroll",oe,!0),window.removeEventListener("resize",b),window.removeEventListener("showai:viewport-change",re)}},[k,f,r]),(0,z.useEffect)(()=>Xe(0),[L?.query]),(0,z.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[we]);function Ss(){let b=m.current;b&&!b.manual&&(y.current=`${b.from}:${b.to}:${b.query}`),m.current=null,N(null)}let xr=(0,z.useCallback)(b=>{k&&(Sr.current={from:k.state.selection.from,to:k.state.selection.to},Ye({type:b,value:b==="link"?k.getAttributes("link").href??"":"",alt:""}),So(""),at(!1),bt(null))},[k]);async function xs(b,C=!1){if(!k||!k.isEditable)return;C&&Sr.current&&k.commands.setTextSelection(Sr.current);let I=k.state.selection.getBookmark(),V=({transaction:F})=>{I=I.map(F.mapping)};k.on("transaction",V);for(let F of b){if(!/^image\/(png|jpeg|gif|webp|avif)$/.test(F.type)){Bn(u("notice.imageTypes"));continue}if(F.size>Bs.resourceBytes){Bn(u("notice.imageTooLarge",{name:F.name,size:Hs(F.size),limit:Hs(Bs.resourceBytes)}));continue}let J;try{J=await new Promise((re,j)=>{let Se=new FileReader;Se.onload=()=>re(String(Se.result)),Se.onerror=()=>j(Se.error),Se.onabort=()=>j(new Error(u("notice.readCancelled"))),Se.readAsDataURL(F)})}catch{Bn(u("notice.imageUnreadable",{name:F.name}));continue}if(k.isDestroyed||!k.isEditable)break;let oe=I.resolve(k.state.doc);k.view.dispatch(k.state.tr.setSelection(oe)),k.chain().focus().setImage({src:J,alt:F.name}).run(),I=k.state.selection.getBookmark()}k.off("transaction",V),Ye(null)}let vs=(0,z.useMemo)(()=>[{id:"text",title:u("block.text"),keywords:`text paragraph ${u("block.textKeywords")}`,icon:(0,w.jsx)(cu,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().setParagraph().run()}},...[1,2,3,4,5,6].map(b=>({id:`heading-${b}`,title:u("block.heading",{level:b}),keywords:`heading h${b} ${u("block.headingKeywords")}`,icon:b===1?(0,w.jsx)(Gc,{size:20}):b===2?(0,w.jsx)(Xc,{size:20}):(0,w.jsx)(Yc,{size:20}),group:u("group.basic"),run:C=>{C.chain().focus().setHeading({level:b}).run()}})),{id:"bullet",title:u("block.bullet"),keywords:`bullet list ${u("block.bulletKeywords")}`,icon:(0,w.jsx)(Ts,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleBulletList().run()}},{id:"ordered",title:u("block.ordered"),keywords:`ordered numbered list ${u("block.orderedKeywords")}`,icon:(0,w.jsx)(Es,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleOrderedList().run()}},{id:"todo",title:u("block.todo"),keywords:`todo task check ${u("block.todoKeywords")}`,icon:(0,w.jsx)(Os,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleTaskList().run()}},{id:"quote",title:u("block.quote"),keywords:`blockquote quote ${u("block.quoteKeywords")}`,icon:(0,w.jsx)(As,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleBlockquote().run()}},{id:"callout",title:u("block.callout"),keywords:`callout note ${u("block.calloutKeywords")}`,icon:(0,w.jsx)(eu,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().insertContent({type:"callout",attrs:{icon:"\u{1F4A1}",tone:"sage"},content:[{type:"paragraph",content:[{type:"text",text:"\u5728\u8FD9\u91CC\u8BB0\u5F55\u4E00\u4E2A\u503C\u5F97\u6CE8\u610F\u7684\u53D1\u73B0\u3002"}]}]}).run()}},{id:"toggle",title:u("block.toggle"),keywords:`toggle details ${u("block.toggleKeywords")}`,icon:(0,w.jsx)(Co,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().insertContent({type:"toggle",attrs:{title:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A",open:!0},content:[{type:"paragraph"}]}).run()}},{id:"divider",title:u("block.divider"),keywords:`divider hr ${u("block.dividerKeywords")}`,icon:(0,w.jsx)(tu,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().setHorizontalRule().run()}},{id:"image",title:u("block.image"),keywords:`image photo ${u("block.imageKeywords")}`,icon:(0,w.jsx)(Mo,{size:20}),group:u("group.rich"),run:()=>xr("image")},{id:"code",title:u("block.code"),keywords:`code snippet ${u("block.codeKeywords")}`,icon:(0,w.jsx)(Wc,{size:20}),group:u("group.rich"),run:b=>{b.chain().focus().toggleCodeBlock().run()}},{id:"table",title:u("block.table"),keywords:`table ${u("block.tableKeywords")}`,icon:(0,w.jsx)(Rs,{size:20}),group:u("group.rich"),run:b=>{b.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...le.items.filter(b=>!("kind"in b&&b.insertion)||!!i).map(b=>({id:"catalog:"+("kind"in b?b.kind:`${b.id}@${b.version}#${b.integrity}`),title:le.displayName(b),keywords:`${"kind"in b?b.kind:b.id} ${b.name} ${b.description} ${le.displayDescription(b)}`,icon:(0,w.jsx)(nu,{size:20}),group:u("group.components"),component:b,run:()=>{}}))],[xr,i,le.items,le.displayName,le.displayDescription,u]),on=vs.filter(b=>`${b.title} ${b.keywords}`.toLowerCase().includes(L?.query.toLowerCase()??""));S.current=on;let Cs=async b=>{let C=m.current,I=S.current[b];if(!(!k||!C||!I||rt)){if(I.component){let V=k.state.doc,F=++We.current;Ve(!0);try{let J=await le.resolve(I.component);if(F!==We.current||k.isDestroyed||m.current!==C||!k.state.doc.eq(V))return;if(N(null),m.current=null,J.component&&te(J.component),J.native&&i){let oe=k.state.tr.delete(C.from,C.to);i(J.kind,J.data,wu(oe.doc,C.from))}else k.chain().focus().deleteRange({from:C.from,to:C.to}).insertContent({type:"widget",attrs:{kind:J.kind,data:J.data}}).run()}catch(J){Bn(J.message)}finally{F===We.current&&Ve(!1)}return}N(null),m.current=null,C.from!==C.to?k.chain().focus().deleteRange({from:C.from,to:C.to}).run():k.commands.focus(),I.run(k)}};v.current=Cs;let Ic=()=>{if(!k)return;y.current=null;let{from:b,to:C}=k.state.selection;N({from:b,to:C,query:"",manual:!0,...Ec(k,b)}),Xe(0),at(!1)},Gg=()=>{if(!k||!ie)return;let b=ie.pos+ie.size;k.chain().focus().insertContentAt(b,{type:"paragraph"}).setTextSelection(b+1).run(),N({from:b+1,to:b+1,query:"",manual:!0,...Ec(k,b+1)}),_e(!1)};function Pc(b,C){if(!k)return;let I=[];k.state.doc.forEach((j,Se)=>I.push({pos:Se,size:j.nodeSize}));let V=I.findIndex(j=>j.pos===b),F=I[V+C],J=k.state.doc.nodeAt(b);if(!F||!J)return;let oe=C===-1?F.pos:F.pos+F.size-J.nodeSize,re=k.state.tr.delete(b,b+J.nodeSize).insert(oe,J);re.setSelection(R.near(re.doc.resolve(oe+1))),k.view.dispatch(re),k.view.focus(),_e(!1),Bt(null)}function Xg(b){if(!k||!k.isEditable)return;let C=E.current;if(C!==null){b.preventDefault(),b.stopPropagation(),E.current=null,Bt(null);let V=k.state.doc.nodeAt(C);if(!V)return;let F=k.state.doc.content.size,J=!1;if(k.state.doc.forEach((oe,re)=>{let j=k.view.nodeDOM(re);if(!(j instanceof HTMLElement)||J)return;let Se=j.getBoundingClientRect();b.clientY<Se.top+Se.height/2&&(F=re,J=!0)}),F!==C&&F!==C+V.nodeSize){let oe=F>C?F-V.nodeSize:F,re=k.state.tr.delete(C,C+V.nodeSize).insert(oe,V);re.setSelection(R.near(re.doc.resolve(oe+1))),k.view.dispatch(re)}return}let I=[...b.dataTransfer.files].filter(V=>V.type.startsWith("image/"));if(I.length){b.preventDefault(),b.stopPropagation();let V=k.view.posAtCoords({left:b.clientX,top:b.clientY});V&&k.commands.setTextSelection(V.pos),xs(I)}}if(!k)return(0,w.jsx)("div",{className:"editor-loading","aria-label":u("openingDocument")});let Yg=k.isActive("heading")?u("block.heading",{level:k.getAttributes("heading").level}):u("block.text"),Lc=(!r||vo)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("select",{"aria-label":u("format.textStyle"),value:k.isActive("heading")?String(k.getAttributes("heading").level):"paragraph",onChange:b=>{let C=b.target.value;C==="paragraph"?k.chain().focus().setParagraph().run():k.chain().focus().setHeading({level:Number(C)}).run()},children:[(0,w.jsx)("option",{value:"paragraph",children:u("block.text")}),[1,2,3,4,5,6].map(b=>(0,w.jsx)("option",{value:b,children:u("block.heading",{level:b})},b))]}),(0,w.jsx)("select",{"aria-label":u("format.font"),value:k.getAttributes("textStyle").fontFamily??"",onChange:b=>k.chain().focus().setMark("textStyle",{fontFamily:b.target.value||null}).run(),children:pu.map(b=>(0,w.jsx)("option",{value:b.value,children:u(SC[b.value]??"format.fontDefault")},b.value))}),(0,w.jsxs)("select",{"aria-label":u("format.fontSize"),value:k.getAttributes("textStyle").fontSize??"",onChange:b=>k.chain().focus().setMark("textStyle",{fontSize:b.target.value||null}).run(),children:[(0,w.jsx)("option",{value:"",children:u("format.fontSizeDefault")}),[12,14,16,18,20,24,28,32,40,48].map(b=>(0,w.jsx)("option",{value:`${b}px`,children:b},b))]}),(0,w.jsx)(Ae,{label:u("format.bold"),active:k.isActive("bold"),onClick:()=>k.chain().focus().toggleBold().run(),children:(0,w.jsx)(Hc,{size:16})}),(0,w.jsx)(Ae,{label:u("format.italic"),active:k.isActive("italic"),onClick:()=>k.chain().focus().toggleItalic().run(),children:(0,w.jsx)(Zc,{size:16})}),(0,w.jsx)(Ae,{label:u("format.underline"),active:k.isActive("underline"),onClick:()=>k.chain().focus().toggleUnderline().run(),children:(0,w.jsx)(uu,{size:16})}),(0,w.jsx)(Ae,{label:u("format.strike"),active:k.isActive("strike"),onClick:()=>k.chain().focus().toggleStrike().run(),children:(0,w.jsx)(iu,{size:16})}),(0,w.jsx)(Ae,{label:u("format.highlight"),active:k.isActive("highlight"),onClick:()=>k.chain().focus().toggleHighlight({color:"#e8eed0"}).run(),children:(0,w.jsx)(Qc,{size:16})}),(0,w.jsx)(Ae,{label:u("format.inlineCode"),active:k.isActive("code"),onClick:()=>k.chain().focus().toggleCode().run(),children:(0,w.jsx)(_c,{size:16})}),(0,w.jsxs)("label",{className:"rich-text-color",title:u("format.textColor"),children:[u("format.textColorShort"),(0,w.jsx)("input",{type:"color","aria-label":u("format.textColor"),value:k.getAttributes("textStyle").color??"#292733",onChange:b=>k.chain().setMark("textStyle",{color:b.target.value}).run()})]}),(0,w.jsxs)("label",{className:"rich-text-color",title:u("format.highlightColor"),children:[u("format.highlightColorShort"),(0,w.jsx)("input",{type:"color","aria-label":u("format.highlightColor"),value:k.getAttributes("highlight").color??"#e8eed0",onChange:b=>k.chain().setMark("highlight",{color:b.target.value}).run()})]}),(0,w.jsxs)("select",{"aria-label":u("format.alignment"),value:k.getAttributes(k.isActive("heading")?"heading":"paragraph").textAlign??"left",onChange:b=>k.chain().focus().setTextAlign(b.target.value).run(),children:[(0,w.jsx)("option",{value:"left",children:u("format.alignLeft")}),(0,w.jsx)("option",{value:"center",children:u("format.alignCenter")}),(0,w.jsx)("option",{value:"right",children:u("format.alignRight")}),(0,w.jsx)("option",{value:"justify",children:u("format.alignJustify")})]}),(0,w.jsx)(Ae,{label:u("format.addLink"),active:k.isActive("link"),onClick:()=>xr("link"),children:(0,w.jsx)(Ms,{size:16})})]});return(0,w.jsxs)("div",{className:`document-editor${n?" is-readonly":""}${r?" is-minimal":""}`,children:[!n&&!r&&(0,w.jsxs)("div",{className:"editor-toolbar",role:"toolbar","aria-label":u("format.toolbar"),children:[(0,w.jsxs)("div",{className:"toolbar-style",children:[(0,w.jsxs)("button",{className:"text-style-button",onMouseDown:b=>b.preventDefault(),onClick:()=>{$n(!kr),at(!1)},"aria-expanded":kr,children:[Yg,(0,w.jsx)(Vc,{size:13})]}),kr&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>$n(!1)}),(0,w.jsx)("div",{className:"editor-small-menu style-menu",children:vs.slice(0,7).map(b=>(0,w.jsxs)("button",{onMouseDown:C=>C.preventDefault(),onClick:()=>{b.run(k),$n(!1)},children:[b.icon,(0,w.jsx)("span",{children:b.title})]},b.id))})]})]}),(0,w.jsx)("span",{className:"toolbar-divider"}),Lc,(0,w.jsx)("span",{className:"toolbar-divider"}),(0,w.jsx)(Ae,{label:u("block.bullet"),active:k.isActive("bulletList"),onClick:()=>k.chain().focus().toggleBulletList().run(),children:(0,w.jsx)(Ts,{size:17})}),(0,w.jsx)(Ae,{label:u("block.todo"),active:k.isActive("taskList"),onClick:()=>k.chain().focus().toggleTaskList().run(),children:(0,w.jsx)(Os,{size:16})}),(0,w.jsxs)("div",{className:"toolbar-insert",children:[(0,w.jsx)(Ae,{label:u("format.more"),active:wr,onClick:()=>{at(!wr),$n(!1)},children:(0,w.jsx)(Wt,{size:17})}),wr&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>at(!1)}),(0,w.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,w.jsxs)("button",{onClick:Ic,children:[(0,w.jsx)(Wt,{size:16}),u("insert.content"),(0,w.jsx)("span",{className:"menu-key",children:"/"})]}),(0,w.jsxs)("button",{onClick:()=>{k.chain().focus().toggleOrderedList().run(),at(!1)},children:[(0,w.jsx)(Es,{size:16}),u("block.ordered")]}),(0,w.jsxs)("button",{onClick:()=>{k.chain().focus().toggleBlockquote().run(),at(!1)},children:[(0,w.jsx)(As,{size:16}),u("block.quote")]}),(0,w.jsxs)("button",{onClick:()=>xr("image"),children:[(0,w.jsx)(Mo,{size:16}),u("insert.image")]}),(0,w.jsxs)("button",{onClick:()=>{k.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),at(!1)},children:[(0,w.jsx)(Rs,{size:16}),u("insert.table")]}),(0,w.jsx)("div",{className:"menu-rule"}),(0,w.jsxs)("div",{className:"align-tools",children:[(0,w.jsx)(Ae,{label:u("format.alignLeft"),active:k.isActive({textAlign:"left"}),onClick:()=>k.chain().focus().setTextAlign("left").run(),children:(0,w.jsx)(zs,{size:17})}),(0,w.jsx)(Ae,{label:u("format.alignCenter"),active:k.isActive({textAlign:"center"}),onClick:()=>k.chain().focus().setTextAlign("center").run(),children:(0,w.jsx)(Ps,{size:17})}),(0,w.jsx)(Ae,{label:u("format.alignRight"),active:k.isActive({textAlign:"right"}),onClick:()=>k.chain().focus().setTextAlign("right").run(),children:(0,w.jsx)(Ls,{size:17})})]})]})]})]}),(0,w.jsx)("div",{className:"toolbar-spacer"}),(0,w.jsx)(Ae,{label:u("format.undo"),disabled:!k.can().undo(),onClick:()=>k.chain().focus().undo().run(),children:(0,w.jsx)(du,{size:16})}),(0,w.jsx)(Ae,{label:u("format.redo"),disabled:!k.can().redo(),onClick:()=>k.chain().focus().redo().run(),children:(0,w.jsx)(ru,{size:16})})]}),(0,w.jsxs)("div",{className:"editor-canvas",ref:h,onKeyDown:b=>{(b.metaKey||b.ctrlKey)&&b.shiftKey&&b.key.toLowerCase()==="k"&&!n&&(b.preventDefault(),b.stopPropagation(),xr("link"))},onMouseEnter:Ht,onMouseMove:b=>{if(n||rn||E.current!==null)return;if(b.target.closest(".block-handle")){Ht();return}let C=h.current;C&&b.target.closest(".document-editor")===C.closest(".document-editor")&&(Nc.current=b.clientY,!wo.current&&(wo.current=requestAnimationFrame(()=>{wo.current=0;let I=h.current;if(!I||E.current!==null||k.isDestroyed)return;let V=Nc.current,F=I.getBoundingClientRect(),J=F.width/I.offsetWidth||1,oe=null;k.state.doc.forEach((j,Se,sn)=>{let Vt=k.view.nodeDOM(Se);if(!(Vt instanceof HTMLElement))return;let ln=Vt.getBoundingClientRect();V>=ln.top-3&&V<=ln.bottom+3&&(oe={pos:Se,size:j.nodeSize,index:sn,top:(ln.top-F.top)/J})});let re=oe;re?(Ht(),Bt(j=>j&&j.pos===re.pos&&j.size===re.size&&j.index===re.index&&Math.abs(j.top-re.top)<.5?j:re)):Oc()})))},onMouseLeave:Oc,onDragOver:b=>{(E.current!==null||[...b.dataTransfer.types].includes("Files"))&&b.preventDefault()},onDropCapture:Xg,children:[(0,w.jsx)(va,{editor:k}),!n&&(0,w.jsx)(am,{editor:k}),!n&&ie&&(0,w.jsxs)("div",{className:"block-handle",style:{top:ie.top},onMouseEnter:Ht,onFocus:Ht,children:[(0,w.jsx)("button",{"aria-label":u("insert.addBelow"),title:u("insert.addContent"),onMouseDown:b=>b.preventDefault(),onClick:Gg,children:(0,w.jsx)(Wt,{size:15})}),(0,w.jsx)("button",{"aria-label":u("block.handle"),title:u("block.handleTitle"),draggable:!0,onDragStart:b=>{Ht(),E.current=ie.pos,b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("application/x-showai-block",String(ie.pos));let C=k.view.nodeDOM(ie.pos);C instanceof HTMLElement&&b.dataTransfer.setDragImage(C,0,0),_e(!1)},onDragEnd:()=>{E.current=null},onClick:()=>_e(!rn),children:(0,w.jsx)(Jc,{size:15})}),rn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>_e(!1)}),(0,w.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(k.state.doc.nodeAt(ie.pos)?.type.name??"")&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"align-tools",role:"group","aria-label":u("block.style"),children:vs.slice(0,7).map((b,C)=>(0,w.jsx)(Ae,{label:b.title,active:C===0?k.state.doc.nodeAt(ie.pos)?.type.name==="paragraph":k.state.doc.nodeAt(ie.pos)?.attrs.level===C,onClick:()=>{k.chain().focus().setTextSelection(ie.pos+1).run(),b.run(k),_e(!1)},children:b.icon},b.id))}),(0,w.jsx)("div",{className:"align-tools",children:[["left",u("format.alignLeft"),(0,w.jsx)(zs,{size:16},"left")],["center",u("format.alignCenter"),(0,w.jsx)(Ps,{size:16},"center")],["right",u("format.alignRight"),(0,w.jsx)(Ls,{size:16},"right")]].map(([b,C,I])=>(0,w.jsx)(Ae,{label:C,active:k.state.doc.nodeAt(ie.pos)?.attrs.textAlign===b,onClick:()=>{k.chain().focus().setTextSelection(ie.pos+1).setTextAlign(b).run(),_e(!1)},children:I},b))}),(0,w.jsx)("div",{className:"menu-rule"})]}),s&&(0,w.jsxs)("button",{onClick:()=>{let b=k.state.doc.nodeAt(ie.pos);b&&s(b.toJSON()),_e(!1),Bt(null)},children:[(0,w.jsx)(Uc,{size:15}),u("block.detach")]}),(0,w.jsxs)("button",{disabled:ie.index===0,onClick:()=>Pc(ie.pos,-1),children:[(0,w.jsx)(Bc,{size:15}),u("block.moveUp")]}),(0,w.jsxs)("button",{disabled:ie.index===k.state.doc.childCount-1,onClick:()=>Pc(ie.pos,1),children:[(0,w.jsx)($c,{size:15}),u("block.moveDown")]}),(0,w.jsxs)("button",{onClick:()=>{let b=k.state.doc.nodeAt(ie.pos);b&&k.chain().focus().insertContentAt(ie.pos+b.nodeSize,b.toJSON()).run(),_e(!1)},children:[(0,w.jsx)(jc,{size:15}),u("block.duplicate")]}),ae&&(0,w.jsxs)("button",{onClick:b=>{let C=k.state.doc.nodeAt(ie.pos)?.attrs.id,I=b.currentTarget.closest(".block-handle").getBoundingClientRect();_e(!1),typeof C=="string"&&!qg(C)&&ae.open({kind:"blocks",blockIds:[C],anchor:{left:I.right+160,top:I.top,bottom:I.bottom}})},children:[(0,w.jsx)(Ns,{size:15}),u("assistant.askBlock")]}),(0,w.jsx)("div",{className:"menu-rule"}),(0,w.jsxs)("button",{className:"danger",onClick:()=>{k.chain().focus().deleteRange({from:ie.pos,to:ie.pos+ie.size}).run(),_e(!1),Bt(null)},children:[(0,w.jsx)(Eo,{size:15}),u("block.delete")]})]})]})]})]}),!n&&!r&&(0,w.jsxs)("button",{className:"document-add-block",onClick:()=>{k.chain().focus("end").run(),(k.state.selection.$from.parent.type.name!=="paragraph"||k.state.selection.$from.parent.content.size)&&k.chain().insertContentAt(k.state.doc.content.size,{type:"paragraph"}).focus("end").run(),Ic()},children:[(0,w.jsx)(Wt,{size:15}),(0,w.jsx)("span",{children:u("insert.addContent")}),(0,w.jsx)("kbd",{children:"/"})]}),(0,w.jsx)("input",{ref:p,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"editor-hidden-input",onChange:b=>{let C=b.target.files?.[0];C&&xs([C],!0),b.target.value=""}}),xo&&(0,w.jsxs)("div",{className:"editor-notice",role:"status",children:[xo,(0,w.jsx)("button",{"aria-label":u("dismissNotice"),onClick:()=>Bn(""),children:(0,w.jsx)(Cr,{size:14})})]}),vo&&!n&&(0,w.jsxs)(ku,{id:f,anchor:vo,viewportTop:(h.current?.closest(".studio")?.querySelector(".studio-window-topbar")?.getBoundingClientRect().bottom??0)+8,onEscape:()=>{Ft.current=!1,Hn.current=`${k.state.selection.from}:${k.state.selection.to}`,k.state.selection instanceof q&&k.view.dispatch(k.state.tr.setSelection(O.near(k.state.selection.$from))),bt(null),k.view.focus()},children:[Lc,(0,w.jsx)(Ai,{editor:k}),ae&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,w.jsxs)("button",{type:"button",className:"editor-bubble-assistant","aria-label":u("assistant.ask"),title:u("assistant.ask"),onClick:()=>{let{from:b,to:C}=k.state.selection,I=vo;Ft.current=!1,bt(null),ae.open({kind:"text",blockIds:vC(k,b,C),text:k.state.doc.textBetween(b,C,`
156
- `),anchor:I})},children:[(0,w.jsx)(Ns,{size:15}),(0,w.jsx)("span",{children:"AI"})]})]})]}),L&&!n&&(0,Tc.createPortal)((0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"slash-dismiss",onClick:()=>{Ss(),k.commands.focus()}}),(0,w.jsxs)("div",{className:`slash-menu${r?" is-minimal":""}`,role:"dialog","aria-label":u("insert.content"),style:{left:L.left,top:L.top},children:[(0,w.jsxs)("div",{className:"slash-search",children:[L.manual?(0,w.jsx)(gu,{label:u("insert.search"),placeholder:u("insert.searchPlaceholder"),defaultExpanded:!0,inputRef:g,value:L.query,onChange:b=>N({...L,query:b}),onKeyDown:b=>{b.key==="Escape"&&(Ss(),k.commands.focus()),b.key==="Enter"&&(b.preventDefault(),Cs(we)),(b.key==="ArrowDown"||b.key==="ArrowUp")&&(b.preventDefault(),Xe(C=>on.length?(C+(b.key==="ArrowDown"?1:-1)+on.length)%on.length:0))}}):(0,w.jsx)("span",{children:L.query||u("insert.addToDocument")}),(0,w.jsx)("kbd",{children:"esc"})]}),(0,w.jsxs)("div",{className:"slash-items",role:"listbox","aria-label":u("insert.blockTypes"),"aria-busy":rt||le.loading,children:[le.error&&(0,w.jsx)("p",{role:"alert",className:"slash-empty",children:le.error}),on.length===0&&(0,w.jsx)("div",{className:"slash-empty",children:u("insert.noResults")}),on.map((b,C)=>(0,w.jsxs)("div",{children:[(C===0||on[C-1].group!==b.group)&&(0,w.jsx)("div",{className:"slash-group",children:b.group}),(0,w.jsxs)("button",{role:"option",disabled:rt,"aria-selected":C===we,className:`slash-item${C===we?" is-selected":""}`,onMouseEnter:()=>Xe(C),onMouseDown:I=>I.preventDefault(),onClick:()=>Cs(C),children:[(0,w.jsx)("span",{className:"slash-item-icon",children:b.icon}),(0,w.jsx)("span",{children:(0,w.jsx)("strong",{children:b.title})}),C===we&&(0,w.jsx)("span",{className:"slash-enter",children:"\u21B5"})]})]},b.id))]})]})]}),document.body),ue&&(0,Tc.createPortal)((0,w.jsx)("div",{className:"editor-modal-backdrop",onMouseDown:b=>{b.target===b.currentTarget&&Ye(null)},children:(0,w.jsxs)("form",{className:"editor-modal",role:"dialog","aria-modal":"true","aria-labelledby":"editor-dialog-title",onKeyDown:b=>{b.key==="Escape"&&Ye(null)},onSubmit:b=>{b.preventDefault();let C=ue.value.trim();if(ue.type==="image"&&!xC(C)){So(u("dialog.invalidImageUrl"));return}if(ue.type==="link"&&C&&!Ug(C)){So(u("dialog.invalidLinkUrl"));return}Sr.current&&k.commands.setTextSelection(Sr.current),ue.type==="image"?k.chain().focus().setImage({src:C,alt:ue.alt}).run():C?k.state.selection.empty&&!k.isActive("link")?k.chain().focus().insertContent({type:"text",text:C,marks:[{type:"link",attrs:{href:C}}]}).run():k.chain().focus().extendMarkRange("link").setLink({href:C}).run():k.chain().focus().extendMarkRange("link").unsetLink().run(),Ye(null)},children:[(0,w.jsxs)("div",{className:"editor-modal-heading",children:[(0,w.jsx)("div",{className:"editor-modal-symbol",children:ue.type==="image"?(0,w.jsx)(Mo,{size:21}):(0,w.jsx)(Ms,{size:21})}),(0,w.jsx)("h3",{id:"editor-dialog-title",children:ue.type==="image"?u("insert.image"):u("dialog.addLink")}),(0,w.jsx)("button",{type:"button","aria-label":u("dialog.close"),onClick:()=>Ye(null),children:(0,w.jsx)(Cr,{size:18})})]}),ue.type==="image"&&(0,w.jsxs)("button",{className:"image-upload-area",type:"button",onClick:()=>p.current?.click(),children:[(0,w.jsx)(fu,{size:23}),(0,w.jsx)("strong",{children:u("dialog.chooseImage")}),(0,w.jsx)("span",{children:u("dialog.imageFormats")})]}),(0,w.jsxs)("label",{className:"editor-field",children:[(0,w.jsx)("span",{children:ue.type==="image"?u("dialog.imageUrl"):u("dialog.linkUrl")}),(0,w.jsx)("input",{autoFocus:!0,type:"text",placeholder:"https://",value:ue.value,onChange:b=>{Ye({...ue,value:b.target.value}),So("")}})]}),ue.type==="image"&&(0,w.jsxs)("label",{className:"editor-field",children:[(0,w.jsxs)("span",{children:[u("dialog.imageAlt")," ",(0,w.jsx)("small",{children:u("dialog.optional")})]}),(0,w.jsx)("input",{placeholder:u("dialog.imageAltPlaceholder"),value:ue.alt,onChange:b=>Ye({...ue,alt:b.target.value})})]}),Rc&&(0,w.jsx)("p",{className:"editor-field-error",role:"alert",children:Rc}),(0,w.jsxs)("div",{className:"editor-modal-actions",children:[ue.type==="link"&&k.isActive("link")&&(0,w.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{k.chain().focus().extendMarkRange("link").unsetLink().run(),Ye(null)},children:u("dialog.removeLink")}),(0,w.jsx)("button",{type:"button",className:"editor-secondary",onClick:()=>Ye(null),children:u("dialog.cancel")}),(0,w.jsxs)("button",{type:"submit",className:"editor-primary",disabled:ue.type==="image"&&!ue.value.trim(),children:[(0,w.jsx)(Fc,{size:15}),ue.type==="image"?u("insert.image"):u("dialog.confirm")]})]})]})}),document.body),n&&(0,w.jsxs)("span",{className:"editor-readonly-note",children:[(0,w.jsx)(qc,{size:12}),u("readOnlyNote")]})]})}export{CC as default};
154
+ `);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=Zv(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(O.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Wp(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>_p(t,e),deleteColumn:()=>({state:t,dispatch:e})=>{let n=ar(t.selection.$from,r=>r.type.name==="table");return jp(t,e&&(r=>{n&&vg(r,n.pos),e(r)}))},addRowBefore:()=>({state:t,dispatch:e})=>Up(t,e),addRowAfter:()=>({state:t,dispatch:e})=>qp(t,e),deleteRow:()=>({state:t,dispatch:e})=>{let n=ar(t.selection.$from,r=>r.type.name==="table");return Jp(t,e&&(r=>{n&&vg(r,n.pos),e(r)}))},deleteTable:()=>({state:t,dispatch:e})=>Yp(t,e),mergeCells:()=>({state:t,dispatch:e})=>$a(t,e),splitCell:()=>({state:t,dispatch:e})=>Ba(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>pr("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>pr("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Xp(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>$a(t,e)?!0:Ba(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>Gp(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Ha(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Ha(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&za(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=q.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:bs,"Mod-Backspace":bs,Delete:bs,"Mod-Delete":bs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Zp({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],tm({allowTableNodeSelection:this.options.allowTableNodeSelection}),aC()]},addNodeView(){let t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r,HTMLAttributes:o})=>{let i=H(this.options.HTMLAttributes,o);return new e(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Y(P(t,"tableRole",e))}}}),Og=G.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(cC.configure(this.options.table)),this.options.tableCell!==!1&&t.push(qv.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Jv.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Gv.configure(this.options.tableRow)),t}});var Rg=gs;var Dg=ms;var uC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,dC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,fC=Te.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||jh(t,"background-color")||t.style.backgroundColor,renderHTML:t=>dr(t.color)?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",H(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){let r=/^(==)([^=]+)(==)/.exec(t);if(r){let o=r[2].trim(),i=n.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:i}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ke({find:uC,type:this.type})]},addPasteRules(){return[He({find:dC,type:this.type})]}}),Ig=fC;var Pg=Ig.extend({addAttributes(){let t=this.parent?.()??{};return this.options.multicolor?{...t,color:{...t.color,renderHTML:({color:e})=>e?{"data-color":e,style:`--showai-highlight-color: ${e}`}:{}}}:t}});var hC=G.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{let e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>!dr(t.textAlign)||!this.options.alignments.includes(t.textAlign)?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Lg=hC;var zg=G.create({name:"dropCursorCleanup",addProseMirrorPlugins(){return[new B({view(t){let e=t.dom.ownerDocument,n=e.defaultView,r=()=>{let o=e.createEvent("Event");o.initEvent("dragleave",!1,!1),t.dom.dispatchEvent(o)};return e.addEventListener("drop",r,!0),e.addEventListener("dragend",r,!0),n?.addEventListener("blur",r),{destroy(){e.removeEventListener("drop",r,!0),e.removeEventListener("dragend",r,!0),n?.removeEventListener("blur",r)}}}})]}});var br=me(vr(),1);var ke=me(kt(),1);function $g({node:t,updateAttributes:e,editor:n,selected:r,getPos:o}){let{renderWidget:i}=(0,br.useContext)(To),s=ki({editor:n,selector:({editor:l})=>l.isEditable});return(0,ke.jsx)(no,{className:`document-widget${r&&s?" is-selected":""}`,"data-widget-kind":t.attrs.kind,"data-block-id":t.attrs.id??void 0,onPointerDownCapture:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;let a=o();!r&&typeof a=="number"&&n.commands.setNodeSelection(a)},onClick:l=>{if(!s||l.button!==0||l.shiftKey||l.metaKey||l.ctrlKey)return;let a=o();typeof a=="number"&&(n.commands.setNodeSelection(a),l.stopPropagation())},children:i({kind:t.attrs.kind,data:t.attrs.data,onChange:l=>{n.isEditable&&e({data:l})},readOnly:!s})})}var Cc=["\u{1F4A1}","\u{1F331}","\u{1F4CC}","\u2728","\u26A0\uFE0F","\u{1F50E}"],Mc=["sage","sand","blue","rose"];function Bg({node:t,updateAttributes:e,editor:n}){let r=ct(Le),o=ki({editor:n,selector:({editor:i})=>i.isEditable});return(0,ke.jsxs)(no,{className:`document-callout tone-${t.attrs.tone}`,"data-block-id":t.attrs.id??void 0,children:[(0,ke.jsxs)("div",{className:"callout-decoration",contentEditable:!1,children:[(0,ke.jsx)("button",{className:"callout-icon",disabled:!o,title:r("callout.changeIcon"),"aria-label":r("callout.changeIconLabel"),onClick:()=>e({icon:Cc[(Cc.indexOf(t.attrs.icon)+1)%Cc.length]}),children:t.attrs.icon}),o&&(0,ke.jsx)("button",{className:"callout-color",title:r("callout.changeColor"),"aria-label":r("callout.changeColorLabel"),onClick:()=>e({tone:Mc[(Mc.indexOf(t.attrs.tone)+1)%Mc.length]})})]}),(0,ke.jsx)(Ca,{className:"callout-content"})]})}function Hg({node:t,updateAttributes:e,editor:n}){let r=ct(Le),o=ki({editor:n,selector:({editor:l})=>l.isEditable}),[i,s]=(0,br.useState)(!!t.attrs.open);return(0,br.useEffect)(()=>s(!!t.attrs.open),[t.attrs.open]),(0,ke.jsxs)(no,{className:`document-toggle${i?" is-open":""}`,"data-block-id":t.attrs.id??void 0,children:[(0,ke.jsxs)("div",{className:"toggle-heading",contentEditable:!1,children:[(0,ke.jsx)("button",{"aria-label":r(i?"toggle.collapse":"toggle.expand"),"aria-expanded":i,onClick:()=>{s(!i),n.isEditable&&e({open:!i})},children:(0,ke.jsx)(Co,{size:16})}),o?(0,ke.jsx)("input",{"aria-label":r("toggle.titleLabel"),value:t.attrs.title,onChange:l=>e({title:l.target.value}),placeholder:r("toggle.titlePlaceholder")}):(0,ke.jsx)("span",{children:t.attrs.title})]}),(0,ke.jsx)("div",{className:"toggle-body",hidden:!i,children:(0,ke.jsx)(Ca,{})})]})}function Fg({node:t,updateAttributes:e,editor:n,selected:r}){let o=ct(Le),i=t.type.name==="mathBlock"||t.attrs.display;return(0,ke.jsxs)(no,{as:i?"div":"span",className:i?"sb-math-display":"sb-math-inline",contentEditable:!1,children:[(0,ke.jsx)("span",{dangerouslySetInnerHTML:{__html:hu(t.attrs.latex,i)}}),r&&n.isEditable&&(0,ke.jsx)("input",{"aria-label":o("math.source"),value:t.attrs.latex,onChange:s=>e({latex:s.target.value}),onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),n.commands.focus())}})]})}var _g=["paragraph","heading","blockquote","bulletList","orderedList","listItem","taskList","taskItem","codeBlock","hardBreak","horizontalRule","image","table","tableRow","tableCell","tableHeader","callout","toggle","widget","mathInline","mathBlock"],ws=new U("showaiBlockIds");function pC(t){let e=new Set([..._g,"region","richText","pageModule"]);return new B({key:ws,appendTransaction(n,r,o){if(!t()||!n.some(l=>l.docChanged||l.getMeta(ws)||l.getMeta("editableChanged")))return null;let i=new Set,s=o.tr;return o.doc.descendants((l,a)=>{if(!e.has(l.type.name))return;let c=l.attrs.id;if(typeof c=="string"&&c.trim()&&!i.has(c)){i.add(c);return}let u;do u=globalThis.crypto.randomUUID();while(i.has(u));i.add(u),s.setNodeAttribute(a,"id",u)}),s.docChanged?s.setMeta(ws,!0).setMeta("addToHistory",!1):null}})}var mC=G.create({name:"showaiStableBlockIds",addOptions:()=>({readOnly:!1}),addGlobalAttributes(){return[{types:[..._g,"region","richText","pageModule"],attributes:{id:{default:null,parseHTML:t=>t.getAttribute("data-block-id"),renderHTML:t=>typeof t.id=="string"&&t.id.trim()?{"data-block-id":t.id}:{}}}}]},addProseMirrorPlugins(){return[pC(()=>!this.options.readOnly&&this.editor.isEditable)]},onCreate(){!this.options.readOnly&&this.editor.isEditable&&this.editor.view.dispatch(this.editor.state.tr.setMeta(ws,!0).setMeta("addToHistory",!1))}}),gC=X.create({name:"widget",group:"block",atom:!0,draggable:!0,addAttributes(){return{kind:{default:"chart"},data:{default:{},parseHTML:t=>{let e=t.getAttribute("data-widget-content");if(!e)return{};try{return JSON.parse(e)}catch{return{}}},renderHTML:t=>({"data-widget-content":JSON.stringify(t.data)})}}},parseHTML:()=>[{tag:"div[data-showai-widget]"}],renderHTML:({HTMLAttributes:t})=>["div",H(t,{"data-showai-widget":""})],addNodeView:()=>ro($g)}),yC=X.create({name:"callout",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({icon:{default:"\u{1F4A1}"},tone:{default:"sage"}}),parseHTML:()=>[{tag:"aside[data-callout]"}],renderHTML:({HTMLAttributes:t})=>["aside",H(t,{"data-callout":""}),0],addNodeView:()=>ro(Bg)}),bC=X.create({name:"toggle",group:"block",content:"block+",defining:!0,draggable:!0,addAttributes:()=>({title:{default:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A"},open:{default:!0}}),parseHTML:()=>[{tag:"section[data-toggle]"}],renderHTML:({HTMLAttributes:t})=>["section",H(t,{"data-toggle":""}),0],addNodeView:()=>ro(Hg)}),kC=X.create({name:"richText",priority:50,group:"block",content:"block*",defining:!0,addAttributes:()=>({id:{default:null},name:{default:"\u5BCC\u6587\u672C"},data:{default:{},parseHTML:t=>JSON.parse(t.getAttribute("data-rich-text-settings")||"{}"),renderHTML:()=>({})}}),parseHTML:()=>[{tag:'div[data-component-kind="text"]'},{tag:'div[data-page-flow="richText"]'}],renderHTML:({node:t,HTMLAttributes:e})=>["div",H(e,{"data-component-kind":"text","data-rich-text-settings":JSON.stringify(t.attrs.data),class:"page-document-flow rich-text-component",style:Object.entries(mu(t.attrs.data)).filter(([,n])=>n!==void 0).map(([n,r])=>`${n.replace(/[A-Z]/g,o=>"-"+o.toLowerCase())}:${typeof r=="number"?`${r}px`:r}`).join(";")}),0]}),wC=Te.create({name:"textStyle",addAttributes:()=>Object.fromEntries(["color","fontFamily","fontSize"].map(t=>[t,{default:null,parseHTML:e=>e.style[t],renderHTML:e=>e[t]?{style:`${t.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}: ${e[t]}`}:{}}])),parseHTML:()=>[{tag:"span[style]"}],renderHTML:({HTMLAttributes:t})=>["span",H(t),0]}),Vg=t=>X.create({name:t?"mathInline":"mathBlock",group:t?"inline":"block",inline:t,atom:!0,addAttributes:()=>({latex:{default:""},display:{default:!t}}),parseHTML:()=>[{tag:t?"span[data-math]":"div[data-math]"}],renderHTML:({node:e,HTMLAttributes:n})=>[t?"span":"div",{...n,"data-math":e.attrs.latex}],addNodeView:()=>ro(Fg)}),Wg=Fn(Le);function jg(t={}){return[kC,wC,Vg(!0),Vg(!1),mC.configure({readOnly:t.readOnly??!1}),zg,bg.configure({trailingNode:t.trailingNode===!1?!1:{},heading:{levels:[1,2,3,4,5,6]},link:{openOnClick:t.readOnly??!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}},codeBlock:{HTMLAttributes:{class:"code-block"}}}),kg.configure({placeholder:({node:e})=>e.type.name==="heading"?Wg("placeholderHeading"):typeof t.placeholder=="function"?t.placeholder():t.placeholder??Wg("placeholderDefault"),includeChildren:!1}),wg.configure({allowBase64:!0,HTMLAttributes:{class:"document-image"}}),Og.configure({table:{resizable:!0}}),im,Rg,Dg.configure({nested:!0}),Pg.configure({multicolor:!0}),Lg.configure({types:["heading","paragraph"]}),yC,bC,gC]}var w=me(kt(),1),Kg=new WeakSet,Ug=Fn(Le),SC={"":"format.fontDefault","sans-serif":"format.fontSans",serif:"format.fontSerif",monospace:"format.fontMono"};function Ae({label:t,children:e,onClick:n,active:r,disabled:o}){return(0,w.jsx)("button",{type:"button",className:`editor-tool${r?" is-active":""}`,"aria-label":t,title:t,"aria-pressed":r,disabled:o,onMouseDown:i=>i.preventDefault(),onClick:n,children:e})}function xC(t){return/^https?:\/\//i.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);base64,/i.test(t)}function qg(t){return/^(https?:\/\/|mailto:|tel:|#)/i.test(t)}function vC(t){return t.startsWith("page-tail-")}function Ec(t,e){let n=t.view.coordsAtPos(Math.min(e,t.state.doc.content.size));return{left:Math.max(12,Math.min(n.left,window.innerWidth-340)),top:Math.max(70,Math.min(n.bottom+8,window.innerHeight-370))}}function CC({content:t,onChange:e,readOnly:n=!1,minimal:r=!0,onEditorReady:o,onInsertNative:i,onDetachBlock:s,additionalExtensions:l,trailingNode:a=!0,retentionKey:c}){let u=ct(Le),d=(0,z.useRef)(e),f=(0,z.useId)();d.current=e;let h=(0,z.useRef)(null),p=(0,z.useRef)(null),g=(0,z.useRef)(null),m=(0,z.useRef)(null),y=(0,z.useRef)(null),S=(0,z.useRef)([]),v=(0,z.useRef)(()=>{}),M=(0,z.useRef)(0),E=(0,z.useRef)(null),[L,N]=(0,z.useState)(null),{useCatalog:_,registerComponent:te,assistant:ae}=(0,z.useContext)(To),le=_(!!L),[rt,Ve]=(0,z.useState)(!1),We=(0,z.useRef)(0);(0,z.useEffect)(()=>()=>{We.current++},[]);let[we,Xe]=(0,z.useState)(0),[ie,Bt]=(0,z.useState)(null),[rn,_e]=(0,z.useState)(!1),zn=(0,z.useRef)(null),Ac=(0,z.useRef)(rn);Ac.current=rn;let wo=(0,z.useRef)(0),Nc=(0,z.useRef)(0);(0,z.useEffect)(()=>()=>cancelAnimationFrame(wo.current),[]);let Ht=(0,z.useCallback)(()=>{zn.current!==null&&(clearTimeout(zn.current),zn.current=null)},[]),Oc=(0,z.useCallback)(()=>{zn.current===null&&(zn.current=setTimeout(()=>{zn.current=null;let b=h.current?.querySelector(".block-handle");Ac.current||E.current!==null||b?.contains(document.activeElement)||Bt(null)},450))},[]);(0,z.useEffect)(()=>Ht,[Ht]);let[kr,$n]=(0,z.useState)(!1),[wr,at]=(0,z.useState)(!1),[ue,Ye]=(0,z.useState)(null),[Rc,So]=(0,z.useState)(""),[xo,Bn]=(0,z.useState)(""),[vo,bt]=(0,z.useState)(null),Hn=(0,z.useRef)(null),Ft=(0,z.useRef)(!1),[,Dc]=(0,z.useState)(0),Sr=(0,z.useRef)(null);m.current=L,M.current=we;let Jg=(0,z.useMemo)(()=>[...jg({placeholder:()=>Ug("placeholder"),trailingNode:a}),...l??[]],[l,a]),k=Sp({retentionKey:c,extensions:Jg,content:t,editable:!n,immediatelyRender:!1,shouldRerenderOnTransaction:!1,editorProps:{attributes:{class:"document-content","aria-label":Ug("documentContent"),spellcheck:"false"},handleKeyDown:(b,C)=>{if(C.isComposing)return!1;if(C.key==="Escape"&&!m.current&&!b.state.selection.empty)return Hn.current=`${b.state.selection.from}:${b.state.selection.to}`,bt(null),C.preventDefault(),!0;if(!m.current)return!1;if(C.key==="Escape")return Ss(),!0;if(C.key==="ArrowDown"||C.key==="ArrowUp"){C.preventDefault();let I=S.current.length;return Xe(V=>I?(V+(C.key==="ArrowDown"?1:-1)+I)%I:0),!0}return C.key==="Enter"&&S.current.length?(v.current(M.current),!0):!1},handleClick:(b,C,I)=>{let V=I.target.closest?.("a[href]");if(!V||!n&&!I.metaKey&&!I.ctrlKey)return!1;let F=V.getAttribute("href")??"";return qg(F)&&(F.startsWith("#")?document.getElementById(F.slice(1))?.scrollIntoView({behavior:"smooth",block:"start"}):window.open(F,"_blank","noopener,noreferrer")),!0},handlePaste:(b,C)=>{let I=[...C.clipboardData?.files??[]].filter(V=>V.type.startsWith("image/"));return I.length?(C.preventDefault(),xs(I),!0):!1}},onUpdate:({editor:b,transaction:C})=>d.current(Ta(b.state.doc),{separateHistory:!!C.getMeta(Dn)})});(0,z.useEffect)(()=>{k&&o?.(k)},[k,o]),(0,z.useEffect)(()=>{k&&k.isEditable===n&&(k.setEditable(!n,!1),k.view.dispatch(k.state.tr.setMeta("editableChanged",!0))),Dc(b=>b+1),n&&(N(null),Bt(null),_e(!1),$n(!1),at(!1),Ye(null),bt(null))},[k,n]),(0,z.useLayoutEffect)(()=>{if(!k)return;let b,C=()=>{if(k.isDestroyed)return;if(k.view.composing){b=setTimeout(C,25);return}let V=Tp(k.state,t);if(!V)return;let F=k.state.selection instanceof D&&k.state.selection.node.type.name==="widget"?k.state.selection.node.attrs.id:null,J=k.state.selection instanceof q?k.state.selection:null;if(k.view.dispatch(V),J){let oe=rm(k.state.doc,J);oe&&k.view.dispatch(k.state.tr.setSelection(oe))}if(F){let oe;if(k.state.doc.descendants((re,j)=>{re.type.name==="widget"&&re.attrs.id===F&&(oe=j)}),oe!==void 0)k.commands.setNodeSelection(oe);else{let re=Si(k.state);re&&k.view.dispatch(re)}}},I=()=>{b=setTimeout(C,25)};return k.view.composing?k.view.dom.addEventListener("compositionend",I):C(),()=>{b&&clearTimeout(b),k.view.dom.removeEventListener("compositionend",I)}},[t,k]),(0,z.useEffect)(()=>{if(!ue)return;let b=requestAnimationFrame(()=>document.querySelector(".editor-modal input")?.focus()),C=I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),Ye(null),k?.commands.focus()),I.key!=="Tab")return;let V=Array.from(document.querySelectorAll(".editor-modal button:not(:disabled), .editor-modal input:not(:disabled)")),F=V[0],J=V[V.length-1];I.shiftKey&&document.activeElement===F?(I.preventDefault(),J?.focus()):!I.shiftKey&&document.activeElement===J&&(I.preventDefault(),F?.focus())};return document.addEventListener("keydown",C,!0),()=>{cancelAnimationFrame(b),document.removeEventListener("keydown",C,!0)}},[!!ue,k]),(0,z.useEffect)(()=>{if(!k||n)return;let b=()=>{let I=Si(k.state);I&&k.view.dispatch(I)};!Kg.has(k)&&!wp(k)&&(Kg.add(k),k.isInitialized?b():k.on("create",b));let C=I=>{if(I.button!==0||!(I.target instanceof Element))return;let V=I.target,F=V.closest(".document-widget");if(F&&k.view.dom.contains(F)||!F&&V.closest('button, input, textarea, select, a, summary, [role="button"], [role="dialog"], .block-handle, .editor-toolbar, .editor-bubble, .editor-small-menu, .editor-modal'))return;let J=Si(k.state);if(!J)return;let oe=document.activeElement;oe instanceof HTMLElement&&k.view.dom.contains(oe)&&oe.blur(),k.view.dispatch(J),k.view.dom.contains(V)&&!V.closest("[data-block-id]")&&I.preventDefault()};return document.addEventListener("pointerdown",C,!0),()=>{k.off("create",b),document.removeEventListener("pointerdown",C,!0)}},[k,n]),(0,z.useEffect)(()=>{if(!L?.manual)return;let b=requestAnimationFrame(()=>g.current?.focus());return()=>cancelAnimationFrame(b)},[L?.manual]),(0,z.useEffect)(()=>{if(!kr&&!wr&&!rn)return;let b=C=>{C.key==="Escape"&&(C.preventDefault(),$n(!1),at(!1),_e(!1),k?.commands.focus())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[kr,wr,rn,k]),(0,z.useEffect)(()=>{if(!xo)return;let b=window.setTimeout(()=>Bn(""),4500);return()=>window.clearTimeout(b)},[xo]),(0,z.useEffect)(()=>{if(!k)return;let b=()=>{if((!r||!k.state.selection.empty)&&Dc(an=>an+1),!k.isEditable)return;let{selection:j}=k.state,{$from:Se,from:sn,to:Vt,empty:ln}=j;if((ln||Hn.current&&Hn.current!==`${sn}:${Vt}`)&&(Hn.current=null),!m.current?.manual){let an=Se.parent.isTextblock?Se.parent.textBetween(0,Se.parentOffset,`
155
+ `):"",cn=ln&&an.match(/^\/([^\n/]*)$/);if(cn){let zc=sn-cn[0].length;y.current!==`${zc}:${Vt}:${cn[1]}`&&(y.current=null,N({from:zc,to:Vt,query:cn[1],...Ec(k,sn)}))}else N(null),y.current=null}if(!ln&&Hn.current!==`${sn}:${Vt}`&&(k.isFocused||Ft.current)&&!k.isActive("codeBlock")&&!k.isActive("widget")&&!k.isActive("pageModule")){let an=k.view.coordsAtPos(sn),cn=k.view.coordsAtPos(Vt);bt({left:(an.left+cn.right)/2,top:an.top,bottom:Math.max(an.bottom,cn.bottom)})}else bt(null)},C=j=>j instanceof Element&&j.closest(".editor-bubble")?.id===f,I=j=>{C(j.relatedTarget)&&(Ft.current=!0)},V=()=>{Ft.current=!1,bt(null)},F=j=>{Ft.current=C(j.target),!Ft.current&&(!(j.target instanceof Node)||!k.view.dom.contains(j.target))&&V()},J=({event:j})=>{!Ft.current&&!C(j.relatedTarget)&&V()},oe=j=>{C(j.target)||V()},re=j=>{!(j.target instanceof Element)||!j.target.contains(k.view.dom)||(bt(null),N(null),_e(!1),Bt(null))};return k.on("transaction",b),k.on("focus",b),k.on("blur",J),k.view.dom.addEventListener("blur",I,!0),document.addEventListener("pointerdown",F,!0),document.addEventListener("focusin",F,!0),k.view.dom.addEventListener("contextmenu",V),window.addEventListener("scroll",oe,!0),window.addEventListener("resize",b),window.addEventListener("showai:viewport-change",re),()=>{k.off("transaction",b),k.off("focus",b),k.off("blur",J),k.view.dom.removeEventListener("blur",I,!0),document.removeEventListener("pointerdown",F,!0),document.removeEventListener("focusin",F,!0),k.view.dom.removeEventListener("contextmenu",V),window.removeEventListener("scroll",oe,!0),window.removeEventListener("resize",b),window.removeEventListener("showai:viewport-change",re)}},[k,f,r]),(0,z.useEffect)(()=>Xe(0),[L?.query]),(0,z.useEffect)(()=>{document.querySelector(".slash-menu .slash-item.is-selected")?.scrollIntoView({block:"nearest"})},[we]);function Ss(){let b=m.current;b&&!b.manual&&(y.current=`${b.from}:${b.to}:${b.query}`),m.current=null,N(null)}let xr=(0,z.useCallback)(b=>{k&&(Sr.current={from:k.state.selection.from,to:k.state.selection.to},Ye({type:b,value:b==="link"?k.getAttributes("link").href??"":"",alt:""}),So(""),at(!1),bt(null))},[k]);async function xs(b,C=!1){if(!k||!k.isEditable)return;C&&Sr.current&&k.commands.setTextSelection(Sr.current);let I=k.state.selection.getBookmark(),V=({transaction:F})=>{I=I.map(F.mapping)};k.on("transaction",V);for(let F of b){if(!/^image\/(png|jpeg|gif|webp|avif)$/.test(F.type)){Bn(u("notice.imageTypes"));continue}if(F.size>Bs.resourceBytes){Bn(u("notice.imageTooLarge",{name:F.name,size:Hs(F.size),limit:Hs(Bs.resourceBytes)}));continue}let J;try{J=await new Promise((re,j)=>{let Se=new FileReader;Se.onload=()=>re(String(Se.result)),Se.onerror=()=>j(Se.error),Se.onabort=()=>j(new Error(u("notice.readCancelled"))),Se.readAsDataURL(F)})}catch{Bn(u("notice.imageUnreadable",{name:F.name}));continue}if(k.isDestroyed||!k.isEditable)break;let oe=I.resolve(k.state.doc);k.view.dispatch(k.state.tr.setSelection(oe)),k.chain().focus().setImage({src:J,alt:F.name}).run(),I=k.state.selection.getBookmark()}k.off("transaction",V),Ye(null)}let vs=(0,z.useMemo)(()=>[{id:"text",title:u("block.text"),keywords:`text paragraph ${u("block.textKeywords")}`,icon:(0,w.jsx)(cu,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().setParagraph().run()}},...[1,2,3,4,5,6].map(b=>({id:`heading-${b}`,title:u("block.heading",{level:b}),keywords:`heading h${b} ${u("block.headingKeywords")}`,icon:b===1?(0,w.jsx)(Gc,{size:20}):b===2?(0,w.jsx)(Xc,{size:20}):(0,w.jsx)(Yc,{size:20}),group:u("group.basic"),run:C=>{C.chain().focus().setHeading({level:b}).run()}})),{id:"bullet",title:u("block.bullet"),keywords:`bullet list ${u("block.bulletKeywords")}`,icon:(0,w.jsx)(Ts,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleBulletList().run()}},{id:"ordered",title:u("block.ordered"),keywords:`ordered numbered list ${u("block.orderedKeywords")}`,icon:(0,w.jsx)(Es,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleOrderedList().run()}},{id:"todo",title:u("block.todo"),keywords:`todo task check ${u("block.todoKeywords")}`,icon:(0,w.jsx)(Os,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleTaskList().run()}},{id:"quote",title:u("block.quote"),keywords:`blockquote quote ${u("block.quoteKeywords")}`,icon:(0,w.jsx)(As,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().toggleBlockquote().run()}},{id:"callout",title:u("block.callout"),keywords:`callout note ${u("block.calloutKeywords")}`,icon:(0,w.jsx)(eu,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().insertContent({type:"callout",attrs:{icon:"\u{1F4A1}",tone:"sage"},content:[{type:"paragraph",content:[{type:"text",text:"\u5728\u8FD9\u91CC\u8BB0\u5F55\u4E00\u4E2A\u503C\u5F97\u6CE8\u610F\u7684\u53D1\u73B0\u3002"}]}]}).run()}},{id:"toggle",title:u("block.toggle"),keywords:`toggle details ${u("block.toggleKeywords")}`,icon:(0,w.jsx)(Co,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().insertContent({type:"toggle",attrs:{title:"\u5C55\u5F00\u4E86\u89E3\u66F4\u591A",open:!0},content:[{type:"paragraph"}]}).run()}},{id:"divider",title:u("block.divider"),keywords:`divider hr ${u("block.dividerKeywords")}`,icon:(0,w.jsx)(tu,{size:20}),group:u("group.basic"),run:b=>{b.chain().focus().setHorizontalRule().run()}},{id:"image",title:u("block.image"),keywords:`image photo ${u("block.imageKeywords")}`,icon:(0,w.jsx)(Mo,{size:20}),group:u("group.rich"),run:()=>xr("image")},{id:"code",title:u("block.code"),keywords:`code snippet ${u("block.codeKeywords")}`,icon:(0,w.jsx)(Wc,{size:20}),group:u("group.rich"),run:b=>{b.chain().focus().toggleCodeBlock().run()}},{id:"table",title:u("block.table"),keywords:`table ${u("block.tableKeywords")}`,icon:(0,w.jsx)(Rs,{size:20}),group:u("group.rich"),run:b=>{b.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},...le.items.filter(b=>!("kind"in b&&b.insertion)||!!i).map(b=>({id:"catalog:"+("kind"in b?b.kind:`${b.id}@${b.version}#${b.integrity}`),title:le.displayName(b),keywords:`${"kind"in b?b.kind:b.id} ${b.name} ${b.description} ${le.displayDescription(b)}`,icon:(0,w.jsx)(nu,{size:20}),group:u("group.components"),component:b,run:()=>{}}))],[xr,i,le.items,le.displayName,le.displayDescription,u]),on=vs.filter(b=>`${b.title} ${b.keywords}`.toLowerCase().includes(L?.query.toLowerCase()??""));S.current=on;let Cs=async b=>{let C=m.current,I=S.current[b];if(!(!k||!C||!I||rt)){if(I.component){let V=k.state.doc,F=++We.current;Ve(!0);try{let J=await le.resolve(I.component);if(F!==We.current||k.isDestroyed||m.current!==C||!k.state.doc.eq(V))return;if(N(null),m.current=null,J.component&&te(J.component),J.native&&i){let oe=k.state.tr.delete(C.from,C.to);i(J.kind,J.data,wu(oe.doc,C.from))}else k.chain().focus().deleteRange({from:C.from,to:C.to}).insertContent({type:"widget",attrs:{kind:J.kind,data:J.data}}).run()}catch(J){Bn(J.message)}finally{F===We.current&&Ve(!1)}return}N(null),m.current=null,C.from!==C.to?k.chain().focus().deleteRange({from:C.from,to:C.to}).run():k.commands.focus(),I.run(k)}};v.current=Cs;let Ic=()=>{if(!k)return;y.current=null;let{from:b,to:C}=k.state.selection;N({from:b,to:C,query:"",manual:!0,...Ec(k,b)}),Xe(0),at(!1)},Gg=()=>{if(!k||!ie)return;let b=ie.pos+ie.size;k.chain().focus().insertContentAt(b,{type:"paragraph"}).setTextSelection(b+1).run(),N({from:b+1,to:b+1,query:"",manual:!0,...Ec(k,b+1)}),_e(!1)};function Pc(b,C){if(!k)return;let I=[];k.state.doc.forEach((j,Se)=>I.push({pos:Se,size:j.nodeSize}));let V=I.findIndex(j=>j.pos===b),F=I[V+C],J=k.state.doc.nodeAt(b);if(!F||!J)return;let oe=C===-1?F.pos:F.pos+F.size-J.nodeSize,re=k.state.tr.delete(b,b+J.nodeSize).insert(oe,J);re.setSelection(R.near(re.doc.resolve(oe+1))),k.view.dispatch(re),k.view.focus(),_e(!1),Bt(null)}function Xg(b){if(!k||!k.isEditable)return;let C=E.current;if(C!==null){b.preventDefault(),b.stopPropagation(),E.current=null,Bt(null);let V=k.state.doc.nodeAt(C);if(!V)return;let F=k.state.doc.content.size,J=!1;if(k.state.doc.forEach((oe,re)=>{let j=k.view.nodeDOM(re);if(!(j instanceof HTMLElement)||J)return;let Se=j.getBoundingClientRect();b.clientY<Se.top+Se.height/2&&(F=re,J=!0)}),F!==C&&F!==C+V.nodeSize){let oe=F>C?F-V.nodeSize:F,re=k.state.tr.delete(C,C+V.nodeSize).insert(oe,V);re.setSelection(R.near(re.doc.resolve(oe+1))),k.view.dispatch(re)}return}let I=[...b.dataTransfer.files].filter(V=>V.type.startsWith("image/"));if(I.length){b.preventDefault(),b.stopPropagation();let V=k.view.posAtCoords({left:b.clientX,top:b.clientY});V&&k.commands.setTextSelection(V.pos),xs(I)}}if(!k)return(0,w.jsx)("div",{className:"editor-loading","aria-label":u("openingDocument")});let Yg=k.isActive("heading")?u("block.heading",{level:k.getAttributes("heading").level}):u("block.text"),Lc=(!r||vo)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("select",{"aria-label":u("format.textStyle"),value:k.isActive("heading")?String(k.getAttributes("heading").level):"paragraph",onChange:b=>{let C=b.target.value;C==="paragraph"?k.chain().focus().setParagraph().run():k.chain().focus().setHeading({level:Number(C)}).run()},children:[(0,w.jsx)("option",{value:"paragraph",children:u("block.text")}),[1,2,3,4,5,6].map(b=>(0,w.jsx)("option",{value:b,children:u("block.heading",{level:b})},b))]}),(0,w.jsx)("select",{"aria-label":u("format.font"),value:k.getAttributes("textStyle").fontFamily??"",onChange:b=>k.chain().focus().setMark("textStyle",{fontFamily:b.target.value||null}).run(),children:pu.map(b=>(0,w.jsx)("option",{value:b.value,children:u(SC[b.value]??"format.fontDefault")},b.value))}),(0,w.jsxs)("select",{"aria-label":u("format.fontSize"),value:k.getAttributes("textStyle").fontSize??"",onChange:b=>k.chain().focus().setMark("textStyle",{fontSize:b.target.value||null}).run(),children:[(0,w.jsx)("option",{value:"",children:u("format.fontSizeDefault")}),[12,14,16,18,20,24,28,32,40,48].map(b=>(0,w.jsx)("option",{value:`${b}px`,children:b},b))]}),(0,w.jsx)(Ae,{label:u("format.bold"),active:k.isActive("bold"),onClick:()=>k.chain().focus().toggleBold().run(),children:(0,w.jsx)(Hc,{size:16})}),(0,w.jsx)(Ae,{label:u("format.italic"),active:k.isActive("italic"),onClick:()=>k.chain().focus().toggleItalic().run(),children:(0,w.jsx)(Zc,{size:16})}),(0,w.jsx)(Ae,{label:u("format.underline"),active:k.isActive("underline"),onClick:()=>k.chain().focus().toggleUnderline().run(),children:(0,w.jsx)(uu,{size:16})}),(0,w.jsx)(Ae,{label:u("format.strike"),active:k.isActive("strike"),onClick:()=>k.chain().focus().toggleStrike().run(),children:(0,w.jsx)(iu,{size:16})}),(0,w.jsx)(Ae,{label:u("format.highlight"),active:k.isActive("highlight"),onClick:()=>k.chain().focus().toggleHighlight({color:"#e8eed0"}).run(),children:(0,w.jsx)(Qc,{size:16})}),(0,w.jsx)(Ae,{label:u("format.inlineCode"),active:k.isActive("code"),onClick:()=>k.chain().focus().toggleCode().run(),children:(0,w.jsx)(_c,{size:16})}),(0,w.jsxs)("label",{className:"rich-text-color",title:u("format.textColor"),children:[u("format.textColorShort"),(0,w.jsx)("input",{type:"color","aria-label":u("format.textColor"),value:k.getAttributes("textStyle").color??"#292733",onChange:b=>k.chain().setMark("textStyle",{color:b.target.value}).run()})]}),(0,w.jsxs)("label",{className:"rich-text-color",title:u("format.highlightColor"),children:[u("format.highlightColorShort"),(0,w.jsx)("input",{type:"color","aria-label":u("format.highlightColor"),value:k.getAttributes("highlight").color??"#e8eed0",onChange:b=>k.chain().setMark("highlight",{color:b.target.value}).run()})]}),(0,w.jsxs)("select",{"aria-label":u("format.alignment"),value:k.getAttributes(k.isActive("heading")?"heading":"paragraph").textAlign??"left",onChange:b=>k.chain().focus().setTextAlign(b.target.value).run(),children:[(0,w.jsx)("option",{value:"left",children:u("format.alignLeft")}),(0,w.jsx)("option",{value:"center",children:u("format.alignCenter")}),(0,w.jsx)("option",{value:"right",children:u("format.alignRight")}),(0,w.jsx)("option",{value:"justify",children:u("format.alignJustify")})]}),(0,w.jsx)(Ae,{label:u("format.addLink"),active:k.isActive("link"),onClick:()=>xr("link"),children:(0,w.jsx)(Ms,{size:16})})]});return(0,w.jsxs)("div",{className:`document-editor${n?" is-readonly":""}${r?" is-minimal":""}`,children:[!n&&!r&&(0,w.jsxs)("div",{className:"editor-toolbar",role:"toolbar","aria-label":u("format.toolbar"),children:[(0,w.jsxs)("div",{className:"toolbar-style",children:[(0,w.jsxs)("button",{className:"text-style-button",onMouseDown:b=>b.preventDefault(),onClick:()=>{$n(!kr),at(!1)},"aria-expanded":kr,children:[Yg,(0,w.jsx)(Vc,{size:13})]}),kr&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>$n(!1)}),(0,w.jsx)("div",{className:"editor-small-menu style-menu",children:vs.slice(0,7).map(b=>(0,w.jsxs)("button",{onMouseDown:C=>C.preventDefault(),onClick:()=>{b.run(k),$n(!1)},children:[b.icon,(0,w.jsx)("span",{children:b.title})]},b.id))})]})]}),(0,w.jsx)("span",{className:"toolbar-divider"}),Lc,(0,w.jsx)("span",{className:"toolbar-divider"}),(0,w.jsx)(Ae,{label:u("block.bullet"),active:k.isActive("bulletList"),onClick:()=>k.chain().focus().toggleBulletList().run(),children:(0,w.jsx)(Ts,{size:17})}),(0,w.jsx)(Ae,{label:u("block.todo"),active:k.isActive("taskList"),onClick:()=>k.chain().focus().toggleTaskList().run(),children:(0,w.jsx)(Os,{size:16})}),(0,w.jsxs)("div",{className:"toolbar-insert",children:[(0,w.jsx)(Ae,{label:u("format.more"),active:wr,onClick:()=>{at(!wr),$n(!1)},children:(0,w.jsx)(Wt,{size:17})}),wr&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>at(!1)}),(0,w.jsxs)("div",{className:"editor-small-menu insert-menu",children:[(0,w.jsxs)("button",{onClick:Ic,children:[(0,w.jsx)(Wt,{size:16}),u("insert.content"),(0,w.jsx)("span",{className:"menu-key",children:"/"})]}),(0,w.jsxs)("button",{onClick:()=>{k.chain().focus().toggleOrderedList().run(),at(!1)},children:[(0,w.jsx)(Es,{size:16}),u("block.ordered")]}),(0,w.jsxs)("button",{onClick:()=>{k.chain().focus().toggleBlockquote().run(),at(!1)},children:[(0,w.jsx)(As,{size:16}),u("block.quote")]}),(0,w.jsxs)("button",{onClick:()=>xr("image"),children:[(0,w.jsx)(Mo,{size:16}),u("insert.image")]}),(0,w.jsxs)("button",{onClick:()=>{k.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),at(!1)},children:[(0,w.jsx)(Rs,{size:16}),u("insert.table")]}),(0,w.jsx)("div",{className:"menu-rule"}),(0,w.jsxs)("div",{className:"align-tools",children:[(0,w.jsx)(Ae,{label:u("format.alignLeft"),active:k.isActive({textAlign:"left"}),onClick:()=>k.chain().focus().setTextAlign("left").run(),children:(0,w.jsx)(zs,{size:17})}),(0,w.jsx)(Ae,{label:u("format.alignCenter"),active:k.isActive({textAlign:"center"}),onClick:()=>k.chain().focus().setTextAlign("center").run(),children:(0,w.jsx)(Ps,{size:17})}),(0,w.jsx)(Ae,{label:u("format.alignRight"),active:k.isActive({textAlign:"right"}),onClick:()=>k.chain().focus().setTextAlign("right").run(),children:(0,w.jsx)(Ls,{size:17})})]})]})]})]}),(0,w.jsx)("div",{className:"toolbar-spacer"}),(0,w.jsx)(Ae,{label:u("format.undo"),disabled:!k.can().undo(),onClick:()=>k.chain().focus().undo().run(),children:(0,w.jsx)(du,{size:16})}),(0,w.jsx)(Ae,{label:u("format.redo"),disabled:!k.can().redo(),onClick:()=>k.chain().focus().redo().run(),children:(0,w.jsx)(ru,{size:16})})]}),(0,w.jsxs)("div",{className:"editor-canvas",ref:h,onKeyDown:b=>{(b.metaKey||b.ctrlKey)&&b.shiftKey&&b.key.toLowerCase()==="k"&&!n&&(b.preventDefault(),b.stopPropagation(),xr("link"))},onMouseEnter:Ht,onMouseMove:b=>{if(n||rn||E.current!==null)return;if(b.target.closest(".block-handle")){Ht();return}let C=h.current;C&&b.target.closest(".document-editor")===C.closest(".document-editor")&&(Nc.current=b.clientY,!wo.current&&(wo.current=requestAnimationFrame(()=>{wo.current=0;let I=h.current;if(!I||E.current!==null||k.isDestroyed)return;let V=Nc.current,F=I.getBoundingClientRect(),J=F.width/I.offsetWidth||1,oe=null;k.state.doc.forEach((j,Se,sn)=>{let Vt=k.view.nodeDOM(Se);if(!(Vt instanceof HTMLElement))return;let ln=Vt.getBoundingClientRect();V>=ln.top-3&&V<=ln.bottom+3&&(oe={pos:Se,size:j.nodeSize,index:sn,top:(ln.top-F.top)/J})});let re=oe;re?(Ht(),Bt(j=>j&&j.pos===re.pos&&j.size===re.size&&j.index===re.index&&Math.abs(j.top-re.top)<.5?j:re)):Oc()})))},onMouseLeave:Oc,onDragOver:b=>{(E.current!==null||[...b.dataTransfer.types].includes("Files"))&&b.preventDefault()},onDropCapture:Xg,children:[(0,w.jsx)(va,{editor:k}),!n&&(0,w.jsx)(cm,{editor:k}),!n&&ie&&(0,w.jsxs)("div",{className:"block-handle",style:{top:ie.top},onMouseEnter:Ht,onFocus:Ht,children:[(0,w.jsx)("button",{"aria-label":u("insert.addBelow"),title:u("insert.addContent"),onMouseDown:b=>b.preventDefault(),onClick:Gg,children:(0,w.jsx)(Wt,{size:15})}),(0,w.jsx)("button",{"aria-label":u("block.handle"),title:u("block.handleTitle"),draggable:!0,onDragStart:b=>{Ht(),E.current=ie.pos,b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("application/x-showai-block",String(ie.pos));let C=k.view.nodeDOM(ie.pos);C instanceof HTMLElement&&b.dataTransfer.setDragImage(C,0,0),_e(!1)},onDragEnd:()=>{E.current=null},onClick:()=>_e(!rn),children:(0,w.jsx)(Jc,{size:15})}),rn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"editor-menu-dismiss",onClick:()=>_e(!1)}),(0,w.jsxs)("div",{className:"editor-small-menu block-menu",children:[r&&["paragraph","heading"].includes(k.state.doc.nodeAt(ie.pos)?.type.name??"")&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"align-tools",role:"group","aria-label":u("block.style"),children:vs.slice(0,7).map((b,C)=>(0,w.jsx)(Ae,{label:b.title,active:C===0?k.state.doc.nodeAt(ie.pos)?.type.name==="paragraph":k.state.doc.nodeAt(ie.pos)?.attrs.level===C,onClick:()=>{k.chain().focus().setTextSelection(ie.pos+1).run(),b.run(k),_e(!1)},children:b.icon},b.id))}),(0,w.jsx)("div",{className:"align-tools",children:[["left",u("format.alignLeft"),(0,w.jsx)(zs,{size:16},"left")],["center",u("format.alignCenter"),(0,w.jsx)(Ps,{size:16},"center")],["right",u("format.alignRight"),(0,w.jsx)(Ls,{size:16},"right")]].map(([b,C,I])=>(0,w.jsx)(Ae,{label:C,active:k.state.doc.nodeAt(ie.pos)?.attrs.textAlign===b,onClick:()=>{k.chain().focus().setTextSelection(ie.pos+1).setTextAlign(b).run(),_e(!1)},children:I},b))}),(0,w.jsx)("div",{className:"menu-rule"})]}),s&&(0,w.jsxs)("button",{onClick:()=>{let b=k.state.doc.nodeAt(ie.pos);b&&s(b.toJSON()),_e(!1),Bt(null)},children:[(0,w.jsx)(Uc,{size:15}),u("block.detach")]}),(0,w.jsxs)("button",{disabled:ie.index===0,onClick:()=>Pc(ie.pos,-1),children:[(0,w.jsx)(Bc,{size:15}),u("block.moveUp")]}),(0,w.jsxs)("button",{disabled:ie.index===k.state.doc.childCount-1,onClick:()=>Pc(ie.pos,1),children:[(0,w.jsx)($c,{size:15}),u("block.moveDown")]}),(0,w.jsxs)("button",{onClick:()=>{let b=k.state.doc.nodeAt(ie.pos);b&&k.chain().focus().insertContentAt(ie.pos+b.nodeSize,b.toJSON()).run(),_e(!1)},children:[(0,w.jsx)(jc,{size:15}),u("block.duplicate")]}),ae&&(0,w.jsxs)("button",{onClick:b=>{let C=k.state.doc.nodeAt(ie.pos)?.attrs.id,I=b.currentTarget.closest(".block-handle").getBoundingClientRect();_e(!1),typeof C=="string"&&!vC(C)&&ae.open({kind:"blocks",blockIds:[C],anchor:{left:I.right+160,top:I.top,bottom:I.bottom}})},children:[(0,w.jsx)(Ns,{size:15}),u("assistant.askBlock")]}),(0,w.jsx)("div",{className:"menu-rule"}),(0,w.jsxs)("button",{className:"danger",onClick:()=>{k.chain().focus().deleteRange({from:ie.pos,to:ie.pos+ie.size}).run(),_e(!1),Bt(null)},children:[(0,w.jsx)(Eo,{size:15}),u("block.delete")]})]})]})]})]}),!n&&!r&&(0,w.jsxs)("button",{className:"document-add-block",onClick:()=>{k.chain().focus("end").run(),(k.state.selection.$from.parent.type.name!=="paragraph"||k.state.selection.$from.parent.content.size)&&k.chain().insertContentAt(k.state.doc.content.size,{type:"paragraph"}).focus("end").run(),Ic()},children:[(0,w.jsx)(Wt,{size:15}),(0,w.jsx)("span",{children:u("insert.addContent")}),(0,w.jsx)("kbd",{children:"/"})]}),(0,w.jsx)("input",{ref:p,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"editor-hidden-input",onChange:b=>{let C=b.target.files?.[0];C&&xs([C],!0),b.target.value=""}}),xo&&(0,w.jsxs)("div",{className:"editor-notice",role:"status",children:[xo,(0,w.jsx)("button",{"aria-label":u("dismissNotice"),onClick:()=>Bn(""),children:(0,w.jsx)(Cr,{size:14})})]}),vo&&!n&&(0,w.jsxs)(ku,{id:f,anchor:vo,viewportTop:(h.current?.closest(".studio")?.querySelector(".studio-window-topbar")?.getBoundingClientRect().bottom??0)+8,onEscape:()=>{Ft.current=!1,Hn.current=`${k.state.selection.from}:${k.state.selection.to}`,k.state.selection instanceof q&&k.view.dispatch(k.state.tr.setSelection(O.near(k.state.selection.$from))),bt(null),k.view.focus()},children:[Lc,(0,w.jsx)(Ai,{editor:k}),ae&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("span",{className:"toolbar-divider","aria-hidden":"true"}),(0,w.jsxs)("button",{type:"button",className:"editor-bubble-assistant","aria-label":u("assistant.ask"),title:u("assistant.ask"),onClick:()=>{let{from:b,to:C}=k.state.selection,I=vo;Ft.current=!1,bt(null),ae.open({kind:"text",blockIds:Cp(k.state.doc,b,C),text:k.state.doc.textBetween(b,C,`
156
+ `),anchor:I})},children:[(0,w.jsx)(Ns,{size:15}),(0,w.jsx)("span",{children:"AI"})]})]})]}),L&&!n&&(0,Tc.createPortal)((0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"slash-dismiss",onClick:()=>{Ss(),k.commands.focus()}}),(0,w.jsxs)("div",{className:`slash-menu${r?" is-minimal":""}`,role:"dialog","aria-label":u("insert.content"),style:{left:L.left,top:L.top},children:[(0,w.jsxs)("div",{className:"slash-search",children:[L.manual?(0,w.jsx)(gu,{label:u("insert.search"),placeholder:u("insert.searchPlaceholder"),defaultExpanded:!0,inputRef:g,value:L.query,onChange:b=>N({...L,query:b}),onKeyDown:b=>{b.key==="Escape"&&(Ss(),k.commands.focus()),b.key==="Enter"&&(b.preventDefault(),Cs(we)),(b.key==="ArrowDown"||b.key==="ArrowUp")&&(b.preventDefault(),Xe(C=>on.length?(C+(b.key==="ArrowDown"?1:-1)+on.length)%on.length:0))}}):(0,w.jsx)("span",{children:L.query||u("insert.addToDocument")}),(0,w.jsx)("kbd",{children:"esc"})]}),(0,w.jsxs)("div",{className:"slash-items",role:"listbox","aria-label":u("insert.blockTypes"),"aria-busy":rt||le.loading,children:[le.error&&(0,w.jsx)("p",{role:"alert",className:"slash-empty",children:le.error}),on.length===0&&(0,w.jsx)("div",{className:"slash-empty",children:u("insert.noResults")}),on.map((b,C)=>(0,w.jsxs)("div",{children:[(C===0||on[C-1].group!==b.group)&&(0,w.jsx)("div",{className:"slash-group",children:b.group}),(0,w.jsxs)("button",{role:"option",disabled:rt,"aria-selected":C===we,className:`slash-item${C===we?" is-selected":""}`,onMouseEnter:()=>Xe(C),onMouseDown:I=>I.preventDefault(),onClick:()=>Cs(C),children:[(0,w.jsx)("span",{className:"slash-item-icon",children:b.icon}),(0,w.jsx)("span",{children:(0,w.jsx)("strong",{children:b.title})}),C===we&&(0,w.jsx)("span",{className:"slash-enter",children:"\u21B5"})]})]},b.id))]})]})]}),document.body),ue&&(0,Tc.createPortal)((0,w.jsx)("div",{className:"editor-modal-backdrop",onMouseDown:b=>{b.target===b.currentTarget&&Ye(null)},children:(0,w.jsxs)("form",{className:"editor-modal",role:"dialog","aria-modal":"true","aria-labelledby":"editor-dialog-title",onKeyDown:b=>{b.key==="Escape"&&Ye(null)},onSubmit:b=>{b.preventDefault();let C=ue.value.trim();if(ue.type==="image"&&!xC(C)){So(u("dialog.invalidImageUrl"));return}if(ue.type==="link"&&C&&!qg(C)){So(u("dialog.invalidLinkUrl"));return}Sr.current&&k.commands.setTextSelection(Sr.current),ue.type==="image"?k.chain().focus().setImage({src:C,alt:ue.alt}).run():C?k.state.selection.empty&&!k.isActive("link")?k.chain().focus().insertContent({type:"text",text:C,marks:[{type:"link",attrs:{href:C}}]}).run():k.chain().focus().extendMarkRange("link").setLink({href:C}).run():k.chain().focus().extendMarkRange("link").unsetLink().run(),Ye(null)},children:[(0,w.jsxs)("div",{className:"editor-modal-heading",children:[(0,w.jsx)("div",{className:"editor-modal-symbol",children:ue.type==="image"?(0,w.jsx)(Mo,{size:21}):(0,w.jsx)(Ms,{size:21})}),(0,w.jsx)("h3",{id:"editor-dialog-title",children:ue.type==="image"?u("insert.image"):u("dialog.addLink")}),(0,w.jsx)("button",{type:"button","aria-label":u("dialog.close"),onClick:()=>Ye(null),children:(0,w.jsx)(Cr,{size:18})})]}),ue.type==="image"&&(0,w.jsxs)("button",{className:"image-upload-area",type:"button",onClick:()=>p.current?.click(),children:[(0,w.jsx)(fu,{size:23}),(0,w.jsx)("strong",{children:u("dialog.chooseImage")}),(0,w.jsx)("span",{children:u("dialog.imageFormats")})]}),(0,w.jsxs)("label",{className:"editor-field",children:[(0,w.jsx)("span",{children:ue.type==="image"?u("dialog.imageUrl"):u("dialog.linkUrl")}),(0,w.jsx)("input",{autoFocus:!0,type:"text",placeholder:"https://",value:ue.value,onChange:b=>{Ye({...ue,value:b.target.value}),So("")}})]}),ue.type==="image"&&(0,w.jsxs)("label",{className:"editor-field",children:[(0,w.jsxs)("span",{children:[u("dialog.imageAlt")," ",(0,w.jsx)("small",{children:u("dialog.optional")})]}),(0,w.jsx)("input",{placeholder:u("dialog.imageAltPlaceholder"),value:ue.alt,onChange:b=>Ye({...ue,alt:b.target.value})})]}),Rc&&(0,w.jsx)("p",{className:"editor-field-error",role:"alert",children:Rc}),(0,w.jsxs)("div",{className:"editor-modal-actions",children:[ue.type==="link"&&k.isActive("link")&&(0,w.jsx)("button",{type:"button",className:"editor-text-action",onClick:()=>{k.chain().focus().extendMarkRange("link").unsetLink().run(),Ye(null)},children:u("dialog.removeLink")}),(0,w.jsx)("button",{type:"button",className:"editor-secondary",onClick:()=>Ye(null),children:u("dialog.cancel")}),(0,w.jsxs)("button",{type:"submit",className:"editor-primary",disabled:ue.type==="image"&&!ue.value.trim(),children:[(0,w.jsx)(Fc,{size:15}),ue.type==="image"?u("insert.image"):u("dialog.confirm")]})]})]})}),document.body),n&&(0,w.jsxs)("span",{className:"editor-readonly-note",children:[(0,w.jsx)(qc,{size:12}),u("readOnlyNote")]})]})}export{CC as default};