/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../prosemirror-transform/dist/index.js"),e=require("../../../prosemirror-commands/dist/index.js"),n=require("../../../prosemirror-state/dist/index.js"),o=require("../../../prosemirror-model/dist/index.js"),s=require("../../../prosemirror-schema-list/dist/index.js"),r=require("../../../prosemirror-view/dist/index.js"),i=require("../../../prosemirror-keymap/dist/index.js");var a=Object.defineProperty,c=(t,e)=>{for(var n in e)a(t,n,{get:e[n],enumerable:!0})};function l(t){const{state:e,transaction:n}=t;let{selection:o}=n,{doc:s}=n,{storedMarks:r}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return r},get selection(){return o},get doc(){return s},get tr(){return o=n.selection,s=n.doc,r=n.storedMarks,n}}}var d=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:o}=e,{tr:s}=n,r=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,(...t)=>{const n=e(...t)(r);return s.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(s),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:o,state:s}=this,{view:r}=o,i=[],a=!!t,c=t||s.tr,l={...Object.fromEntries(Object.entries(n).map(([t,n])=>[t,(...t)=>{const o=this.buildProps(c,e),s=n(...t)(o);return i.push(s),l}])),run:()=>(a||!e||c.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(c),i.every(t=>!0===t))};return l}createCan(t){const{rawCommands:e,state:n}=this,o=!1,s=t||n.tr,r=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(e).map(([t,e])=>[t,(...t)=>e(...t)({...r,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}buildProps(t,e=!0){const{rawCommands:n,editor:o,state:s}=this,{view:r}=o,i={tr:t,editor:o,view:r,state:l({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([t,e])=>[t,(...t)=>e(...t)(i)]))}};return i}},p={};c(p,{blur:()=>u,clearContent:()=>h,clearNodes:()=>m,command:()=>f,createParagraphNear:()=>g,cut:()=>v,deleteCurrentNode:()=>x,deleteNode:()=>b,deleteRange:()=>k,deleteSelection:()=>w,enter:()=>M,exitCode:()=>S,extendMarkRange:()=>$,first:()=>R,focus:()=>H,forEach:()=>L,insertContent:()=>V,insertContentAt:()=>_,joinBackward:()=>Y,joinDown:()=>J,joinForward:()=>X,joinItemBackward:()=>Z,joinItemForward:()=>Q,joinTextblockBackward:()=>G,joinTextblockForward:()=>tt,joinUp:()=>q,keyboardShortcut:()=>nt,lift:()=>st,liftEmptyBlock:()=>rt,liftListItem:()=>it,newlineInCode:()=>at,resetAttributes:()=>dt,scrollIntoView:()=>pt,selectAll:()=>ut,selectNodeBackward:()=>ht,selectNodeForward:()=>mt,selectParentNode:()=>ft,selectTextblockEnd:()=>gt,selectTextblockStart:()=>vt,setContent:()=>yt,setMark:()=>ce,setMeta:()=>le,setNode:()=>de,setNodeSelection:()=>pe,setTextDirection:()=>ue,setTextSelection:()=>he,sinkListItem:()=>me,splitBlock:()=>ge,splitListItem:()=>ve,toggleList:()=>be,toggleMark:()=>ke,toggleNode:()=>we,toggleWrap:()=>Me,undoInputRule:()=>Se,unsetAllMarks:()=>Ee,unsetMark:()=>Te,unsetTextDirection:()=>Ce,updateAttributes:()=>Pe,wrapIn:()=>Ae,wrapInList:()=>Oe});var u=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),h=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),m=()=>({state:e,tr:n,dispatch:o})=>{const{selection:s}=n,{ranges:r}=s;return!o||(r.forEach(({$from:o,$to:s})=>{e.doc.nodesBetween(o.pos,s.pos,(e,o)=>{if(e.type.isText)return;const{doc:s,mapping:r}=n,i=s.resolve(r.map(o)),a=s.resolve(r.map(o+e.nodeSize)),c=i.blockRange(a);if(!c)return;const l=t.liftTarget(c);if(e.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());n.setNodeMarkup(c.start,t)}(l||0===l)&&n.lift(c,l)})}),!0)},f=t=>e=>t(e),g=()=>({state:t,dispatch:n})=>e.createParagraphNear(t,n),v=(t,e)=>({editor:o,tr:s})=>{const{state:r}=o,i=r.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const a=s.mapping.map(e);return s.insert(a,i.content),s.setSelection(new n.TextSelection(s.doc.resolve(Math.max(a-1,0)))),!0},x=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,o=n.$anchor.node();if(o.content.size>0)return!1;const s=t.selection.$anchor;for(let r=s.depth;r>0;r-=1){if(s.node(r).type===o.type){if(e){const e=s.before(r),n=s.after(r);t.delete(e,n).scrollIntoView()}return!0}}return!1};function y(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var b=t=>({tr:e,state:n,dispatch:o})=>{const s=y(t,n.schema),r=e.selection.$anchor;for(let t=r.depth;t>0;t-=1){if(r.node(t).type===s){if(o){const n=r.before(t),o=r.after(t);e.delete(n,o).scrollIntoView()}return!0}}return!1},k=t=>({tr:e,dispatch:n})=>{const{from:o,to:s}=t;return n&&e.delete(o,s),!0},w=()=>({state:t,dispatch:n})=>e.deleteSelection(t,n),M=()=>({commands:t})=>t.keyboardShortcut("Enter"),S=()=>({state:t,dispatch:n})=>e.exitCode(t,n);function E(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function T(t,e,n={strict:!0}){const o=Object.keys(e);return!o.length||o.every(o=>n.strict?e[o]===t[o]:E(e[o])?e[o].test(t[o]):e[o]===t[o])}function C(t,e,n={}){return t.find(t=>t.type===e&&T(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function P(t,e,n={}){return!!C(t,e,n)}function A(t,e,n){var o;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if(s.node&&s.node.marks.some(t=>t.type===e)||(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(t=>t.type===e))return;n=n||(null==(o=s.node.marks[0])?void 0:o.attrs);if(!C([...s.node.marks],e,n))return;let r=s.index,i=t.start()+s.offset,a=r+1,c=i+s.node.nodeSize;for(;r>0&&P([...t.parent.child(r-1).marks],e,n);)r-=1,i-=t.parent.child(r).nodeSize;for(;a<t.parent.childCount&&P([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:i,to:c}}function O(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var $=(t,e={})=>({tr:o,state:s,dispatch:r})=>{const i=O(t,s.schema),{doc:a,selection:c}=o,{$from:l,from:d,to:p}=c;if(r){const t=A(l,i,e);if(t&&t.from<=d&&t.to>=p){const e=n.TextSelection.create(a,t.from,t.to);o.setSelection(e)}}return!0},R=t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1};function N(t){return t instanceof n.TextSelection}function z(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function j(t,e=null){if(!e)return null;const o=n.Selection.atStart(t),s=n.Selection.atEnd(t);if("start"===e||!0===e)return o;if("end"===e)return s;const r=o.from,i=s.to;return"all"===e?n.TextSelection.create(t,z(0,r,i),z(t.content.size,r,i)):n.TextSelection.create(t,z(e,r,i),z(e,r,i))}function I(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function D(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function B(){return"undefined"!=typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var H=(t=null,e={})=>({editor:n,view:o,tr:s,dispatch:r})=>{e={scrollIntoView:!0,...e};const i=()=>{(D()||I())&&o.dom.focus(),!B()||D()||I()||o.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(o.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())})};try{if(o.hasFocus()&&null===t||!1===t)return!0}catch{return!1}if(r&&null===t&&!N(n.state.selection))return i(),!0;const a=j(s.doc,t)||n.state.selection,c=n.state.selection.eq(a);return r&&(c||s.setSelection(a),c&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},L=(t,e)=>n=>t.every((t,o)=>e(t,{...n,index:o})),V=(t,e)=>({tr:n,commands:o})=>o.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),F=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const o=e[n];3===o.nodeType&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?t.removeChild(o):1===o.nodeType&&F(o)}return t};function W(t){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return F(n)}function U(t,e,n){if(t instanceof o.Node||t instanceof o.Fragment)return t;n={slice:!0,parseOptions:{},...n};const s="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return o.Fragment.fromArray(t.map(t=>e.nodeFromJSON(t)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),U("",e,n)}if(s){if(n.errorOnInvalidContent){let s=!1,r="";const i=new o.Schema({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(s=!0,r="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?o.DOMParser.fromSchema(i).parseSlice(W(t),n.parseOptions):o.DOMParser.fromSchema(i).parse(W(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${r}`)})}const s=o.DOMParser.fromSchema(e);return n.slice?s.parseSlice(W(t),n.parseOptions).content:s.parse(W(t),n.parseOptions)}return U("",e,n)}function K(e,o,s){const r=e.steps.length-1;if(r<o)return;const i=e.steps[r];if(!(i instanceof t.ReplaceStep||i instanceof t.ReplaceAroundStep))return;const a=e.mapping.maps[r];let c=0;a.forEach((t,e,n,o)=>{0===c&&(c=o)}),e.setSelection(n.Selection.near(e.doc.resolve(c),s))}var _=(t,e,n)=>({tr:s,dispatch:r,editor:i})=>{var a;if(r){let r;const l=t=>{i.emit("contentError",{editor:i,error:t,disableCollaboration:()=>{"collaboration"in i.storage&&"object"==typeof i.storage.collaboration&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...(n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{U(e,i.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(c){l(c)}try{r=U(e,i.schema,{parseOptions:d,errorOnInvalidContent:null!=(a=n.errorOnInvalidContent)?a:i.options.enableContentCheck})}catch(c){return l(c),!1}let{from:p,to:u}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},h=!0,m=!0;if(("type"in r?[r]:r).forEach(t=>{t.check(),h=!!h&&(t.isText&&0===t.marks.length),m=!!m&&t.isBlock}),p===u&&m){const{parent:t}=s.doc.resolve(p);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(p-=1,u+=1)}let f;if(h){if(Array.isArray(e))f=e.map(t=>t.text||"").join("");else if(e instanceof o.Fragment){let t="";e.forEach(e=>{e.text&&(t+=e.text)}),f=t}else f="object"==typeof e&&e&&e.text?e.text:e;s.insertText(f,p,u)}else{f=r;const t=s.doc.resolve(p),e=t.node(),n=0===t.parentOffset,o=e.isText||e.isTextblock,i=e.content.size>0;n&&o&&i&&(p=Math.max(0,p-1)),s.replaceWith(p,u,f)}n.updateSelection&&K(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:p,text:f}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:p,text:f})}return!0},q=()=>({state:t,dispatch:n})=>e.joinUp(t,n),J=()=>({state:t,dispatch:n})=>e.joinDown(t,n),Y=()=>({state:t,dispatch:n})=>e.joinBackward(t,n),X=()=>({state:t,dispatch:n})=>e.joinForward(t,n),Z=()=>({state:e,dispatch:n,tr:o})=>{try{const s=t.joinPoint(e.doc,e.selection.$from.pos,-1);return null!=s&&(o.join(s,2),n&&n(o),!0)}catch{return!1}},Q=()=>({state:e,dispatch:n,tr:o})=>{try{const s=t.joinPoint(e.doc,e.selection.$from.pos,1);return null!=s&&(o.join(s,2),n&&n(o),!0)}catch{return!1}},G=()=>({state:t,dispatch:n})=>e.joinTextblockBackward(t,n),tt=()=>({state:t,dispatch:n})=>e.joinTextblockForward(t,n);function et(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var nt=t=>({editor:e,view:n,tr:o,dispatch:s})=>{const r=function(t){const e=t.split(/-(?!$)/);let n,o,s,r,i=e[e.length-1];"Space"===i&&(i=" ");for(let a=0;a<e.length-1;a+=1){const t=e[a];if(/^(cmd|meta|m)$/i.test(t))r=!0;else if(/^a(lt)?$/i.test(t))n=!0;else if(/^(c|ctrl|control)$/i.test(t))o=!0;else if(/^s(hift)?$/i.test(t))s=!0;else{if(!/^mod$/i.test(t))throw new Error(`Unrecognized modifier name: ${t}`);D()||et()?r=!0:o=!0}}return n&&(i=`Alt-${i}`),o&&(i=`Ctrl-${i}`),r&&(i=`Meta-${i}`),s&&(i=`Shift-${i}`),i}(t).split(/-(?!$)/),i=r.find(t=>!["Alt","Ctrl","Meta","Shift"].includes(t)),a=new KeyboardEvent("keydown",{key:"Space"===i?" ":i,altKey:r.includes("Alt"),ctrlKey:r.includes("Ctrl"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",t=>t(n,a))});return null==c||c.steps.forEach(t=>{const e=t.map(o.mapping);e&&s&&o.maybeStep(e)}),!0};function ot(t,e,n={}){const{from:o,to:s,empty:r}=t.selection,i=e?y(e,t.schema):null,a=[];t.doc.nodesBetween(o,s,(t,e)=>{if(t.isText)return;const n=Math.max(o,e),r=Math.min(s,e+t.nodeSize);a.push({node:t,from:n,to:r})});const c=s-o,l=a.filter(t=>!i||i.name===t.node.type.name).filter(t=>T(t.node.attrs,n,{strict:!1}));if(r)return!!l.length;return l.reduce((t,e)=>t+e.to-e.from,0)>=c}var st=(t,n={})=>({state:o,dispatch:s})=>!!ot(o,y(t,o.schema),n)&&e.lift(o,s),rt=()=>({state:t,dispatch:n})=>e.liftEmptyBlock(t,n),it=t=>({state:e,dispatch:n})=>{const o=y(t,e.schema);return s.liftListItem(o)(e,n)},at=()=>({state:t,dispatch:n})=>e.newlineInCode(t,n);function ct(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function lt(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce((e,o)=>(n.includes(o)||(e[o]=t[o]),e),{})}var dt=(t,e)=>({tr:n,state:o,dispatch:s})=>{let r=null,i=null;const a=ct("string"==typeof t?t:t.name,o.schema);if(!a)return!1;"node"===a&&(r=y(t,o.schema)),"mark"===a&&(i=O(t,o.schema));let c=!1;return n.selection.ranges.forEach(t=>{o.doc.nodesBetween(t.$from.pos,t.$to.pos,(t,o)=>{r&&r===t.type&&(c=!0,s&&n.setNodeMarkup(o,void 0,lt(t.attrs,e))),i&&t.marks.length&&t.marks.forEach(r=>{i===r.type&&(c=!0,s&&n.addMark(o,o+t.nodeSize,i.create(lt(r.attrs,e))))})})}),c},pt=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),ut=()=>({tr:t,dispatch:e})=>{if(e){const e=new n.AllSelection(t.doc);t.setSelection(e)}return!0},ht=()=>({state:t,dispatch:n})=>e.selectNodeBackward(t,n),mt=()=>({state:t,dispatch:n})=>e.selectNodeForward(t,n),ft=()=>({state:t,dispatch:n})=>e.selectParentNode(t,n),gt=()=>({state:t,dispatch:n})=>e.selectTextblockEnd(t,n),vt=()=>({state:t,dispatch:n})=>e.selectTextblockStart(t,n);function xt(t,e,n={},o={}){return U(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:o.errorOnInvalidContent})}var yt=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:o={}}={})=>({editor:s,tr:r,dispatch:i,commands:a})=>{const{doc:c}=r;if("full"!==o.preserveWhitespace){const a=xt(t,s.schema,o,{errorOnInvalidContent:null!=e?e:s.options.enableContentCheck});return i&&r.replaceWith(0,c.content.size,a).setMeta("preventUpdate",!n),!0}return i&&r.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:c.content.size},t,{parseOptions:o,errorOnInvalidContent:null!=e?e:s.options.enableContentCheck})};function bt(t,e){const n=O(e,t.schema),{from:o,to:s,empty:r}=t.selection,i=[];r?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(o,s,t=>{i.push(...t.marks)});const a=i.find(t=>t.type.name===n.name);return a?{...a.attrs}:{}}function kt(e,n){const o=new t.Transform(e);return n.forEach(t=>{t.steps.forEach(t=>{o.step(t)})}),o}function wt(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Mt(t,e){for(let n=t.depth;n>0;n-=1){const o=t.node(n);if(e(o))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:o}}}function St(t){return e=>Mt(e.$from,t)}function Et(t,e,n){if(void 0===t.config[e]&&t.parent)return Et(t.parent,e,n);if("function"==typeof t.config[e]){return t.config[e].bind({...n,parent:t.parent?Et(t.parent,e,n):null})}return t.config[e]}function Tt(t){return t.map(t=>{const e=Et(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...Tt(e())]:t}).flat(10)}function Ct(t,e){const n=o.DOMSerializer.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Pt(t){return"function"==typeof t}function At(t,e=void 0,...n){return Pt(t)?e?t.bind(e)(...n):t(...n):t}function Ot(t={}){return 0===Object.keys(t).length&&t.constructor===Object}function $t(t){return{baseExtensions:t.filter(t=>"extension"===t.type),nodeExtensions:t.filter(t=>"node"===t.type),markExtensions:t.filter(t=>"mark"===t.type)}}function Rt(t){const e=[],{nodeExtensions:n,markExtensions:o}=$t(t),s=[...n,...o],r={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=n.filter(t=>"text"!==t.name).map(t=>t.name),a=o.map(t=>t.name),c=[...i,...a];return t.forEach(t=>{const n=Et(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:s});if(!n)return;n().forEach(t=>{let n;n=Array.isArray(t.types)?t.types:"*"===t.types?c:"nodes"===t.types?i:"marks"===t.types?a:[],n.forEach(n=>{Object.entries(t.attributes).forEach(([t,o])=>{e.push({type:n,name:t,attribute:{...r,...o}})})})})}),s.forEach(t=>{const n={name:t.name,options:t.options,storage:t.storage},o=Et(t,"addAttributes",n);if(!o)return;const s=o();Object.entries(s).forEach(([n,o])=>{const s={...r,...o};"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,e.push({type:t.name,name:n,attribute:s})})}),e}function Nt(...t){return t.filter(t=>!!t).reduce((t,e)=>{const n={...t};return Object.entries(e).forEach(([t,e])=>{if(n[t])if("class"===t){const o=e?String(e).split(" "):[],s=n[t]?n[t].split(" "):[],r=o.filter(t=>!s.includes(t));n[t]=[...s,...r].join(" ")}else if("style"===t){const o=e?e.split(";").map(t=>t.trim()).filter(Boolean):[],s=n[t]?n[t].split(";").map(t=>t.trim()).filter(Boolean):[],r=new Map;s.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());r.set(e,n)}),o.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());r.set(e,n)}),n[t]=Array.from(r.entries()).map(([t,e])=>`${t}: ${e}`).join("; ")}else n[t]=e;else n[t]=e}),n},{})}function zt(t,e){return e.filter(e=>e.type===t.type.name).filter(t=>t.attribute.rendered).map(e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]}).reduce((t,e)=>Nt(t,e),{})}function jt(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}function It(t,e){return"style"in t?t:{...t,getAttrs:n=>{const o=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===o)return!1;const s=e.reduce((t,e)=>{const o=e.attribute.parseHTML?e.attribute.parseHTML(n):jt(n.getAttribute(e.name));return null==o?t:{...t,[e.name]:o}},{});return{...o,...s}}}}function Dt(t){return Object.fromEntries(Object.entries(t).filter(([t,e])=>("attrs"!==t||!Ot(e))&&null!=e))}function Bt(t){var e,n;const o={};return!(null==(e=null==t?void 0:t.attribute)?void 0:e.isRequired)&&"default"in((null==t?void 0:t.attribute)||{})&&(o.default=t.attribute.default),void 0!==(null==(n=null==t?void 0:t.attribute)?void 0:n.validate)&&(o.validate=t.attribute.validate),[t.name,o]}function Ht(t,e){var n;const s=Rt(t),{nodeExtensions:r,markExtensions:i}=$t(t),a=null==(n=r.find(t=>Et(t,"topNode")))?void 0:n.name,c=Object.fromEntries(r.map(n=>{const o=s.filter(t=>t.type===n.name),r={name:n.name,options:n.options,storage:n.storage,editor:e},i=Dt({...t.reduce((t,e)=>{const o=Et(e,"extendNodeSchema",r);return{...t,...o?o(n):{}}},{}),content:At(Et(n,"content",r)),marks:At(Et(n,"marks",r)),group:At(Et(n,"group",r)),inline:At(Et(n,"inline",r)),atom:At(Et(n,"atom",r)),selectable:At(Et(n,"selectable",r)),draggable:At(Et(n,"draggable",r)),code:At(Et(n,"code",r)),whitespace:At(Et(n,"whitespace",r)),linebreakReplacement:At(Et(n,"linebreakReplacement",r)),defining:At(Et(n,"defining",r)),isolating:At(Et(n,"isolating",r)),attrs:Object.fromEntries(o.map(Bt))}),a=At(Et(n,"parseHTML",r));a&&(i.parseDOM=a.map(t=>It(t,o)));const c=Et(n,"renderHTML",r);c&&(i.toDOM=t=>c({node:t,HTMLAttributes:zt(t,o)}));const l=Et(n,"renderText",r);return l&&(i.toText=l),[n.name,i]})),l=Object.fromEntries(i.map(n=>{const o=s.filter(t=>t.type===n.name),r={name:n.name,options:n.options,storage:n.storage,editor:e},i=Dt({...t.reduce((t,e)=>{const o=Et(e,"extendMarkSchema",r);return{...t,...o?o(n):{}}},{}),inclusive:At(Et(n,"inclusive",r)),excludes:At(Et(n,"excludes",r)),group:At(Et(n,"group",r)),spanning:At(Et(n,"spanning",r)),code:At(Et(n,"code",r)),attrs:Object.fromEntries(o.map(Bt))}),a=At(Et(n,"parseHTML",r));a&&(i.parseDOM=a.map(t=>It(t,o)));const c=Et(n,"renderHTML",r);return c&&(i.toDOM=t=>c({mark:t,HTMLAttributes:zt(t,o)})),[n.name,i]}));return new o.Schema({topNode:a,nodes:c,marks:l})}function Lt(t){const e=t.filter((e,n)=>t.indexOf(e)!==n);return Array.from(new Set(e))}function Vt(t){return t.sort((t,e)=>{const n=Et(t,"priority")||100,o=Et(e,"priority")||100;return n>o?-1:n<o?1:0})}function Ft(t){const e=Vt(Tt(t)),n=Lt(e.map(t=>t.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(t=>`'${t}'`).join(", ")}]. This can lead to issues.`),e}function Wt(t,e,n){const{from:o,to:s}=e,{blockSeparator:r="\n\n",textSerializers:i={}}=n||{};let a="";return t.nodesBetween(o,s,(t,n,c,l)=>{var d;t.isBlock&&n>o&&(a+=r);const p=null==i?void 0:i[t.type.name];if(p)return c&&(a+=p({node:t,pos:n,parent:c,index:l,range:e})),!1;t.isText&&(a+=null==(d=null==t?void 0:t.text)?void 0:d.slice(Math.max(o,n)-n,s-n))}),a}function Ut(t,e){return Wt(t,{from:0,to:t.content.size},e)}function Kt(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,t])=>t.spec.toText).map(([t,e])=>[t,e.spec.toText]))}function _t(t,e){const n=y(e,t.schema),{from:o,to:s}=t.selection,r=[];t.doc.nodesBetween(o,s,t=>{r.push(t)});const i=r.reverse().find(t=>t.type.name===n.name);return i?{...i.attrs}:{}}function qt(t,e){const n=ct("string"==typeof e?e:e.name,t.schema);return"node"===n?_t(t,e):"mark"===n?bt(t,e):{}}function Jt(t,e=JSON.stringify){const n={};return t.filter(t=>{const o=e(t);return!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=!0)})}function Yt(t){const{mapping:e,steps:n}=t,o=[];return e.maps.forEach((t,s)=>{const r=[];if(t.ranges.length)t.forEach((t,e)=>{r.push({from:t,to:e})});else{const{from:t,to:e}=n[s];if(void 0===t||void 0===e)return;r.push({from:t,to:e})}r.forEach(({from:t,to:n})=>{const r=e.slice(s).map(t,-1),i=e.slice(s).map(n),a=e.invert().map(r,-1),c=e.invert().map(i);o.push({oldRange:{from:a,to:c},newRange:{from:r,to:i}})})}),function(t){const e=Jt(t);return 1===e.length?e:e.filter((t,n)=>!e.filter((t,e)=>e!==n).some(e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}(o)}function Xt(t,e,n){const o=[];return t===e?n.resolve(t).marks().forEach(e=>{const s=A(n.resolve(t),e.type);s&&o.push({mark:e,...s})}):n.nodesBetween(t,e,(t,e)=>{t&&void 0!==(null==t?void 0:t.nodeSize)&&o.push(...t.marks.map(n=>({from:e,to:e+t.nodeSize,mark:n})))}),o}function Zt(t,e){return e.nodes[t]||e.marks[t]||null}function Qt(t,e,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const o=t.find(t=>t.type===e&&t.name===n);return!!o&&o.attribute.keepOnSplit}))}var Gt=(t,e=500)=>{let n="";const o=t.parentOffset;return t.parent.nodesBetween(Math.max(0,o-e),o,(t,e,s,r)=>{var i,a;const c=(null==(a=(i=t.type.spec).toText)?void 0:a.call(i,{node:t,pos:e,parent:s,index:r}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?c:c.slice(0,Math.max(0,o-e))}),n};function te(t,e,n={}){const{empty:o,ranges:s}=t.selection,r=e?O(e,t.schema):null;if(o)return!!(t.storedMarks||t.selection.$from.marks()).filter(t=>!r||r.name===t.type.name).find(t=>T(t.attrs,n,{strict:!1}));let i=0;const a=[];if(s.forEach(({$from:e,$to:n})=>{const o=e.pos,s=n.pos;t.doc.nodesBetween(o,s,(t,e)=>{if(r&&t.inlineContent&&!t.type.allowsMarkType(r))return!1;if(!t.isText&&!t.marks.length)return;const n=Math.max(o,e),c=Math.min(s,e+t.nodeSize);i+=c-n,a.push(...t.marks.map(t=>({mark:t,from:n,to:c})))})}),0===i)return!1;const c=a.filter(t=>!r||r.name===t.mark.type.name).filter(t=>T(t.mark.attrs,n,{strict:!1})).reduce((t,e)=>t+e.to-e.from,0),l=a.filter(t=>!r||t.mark.type!==r&&t.mark.type.excludes(r)).reduce((t,e)=>t+e.to-e.from,0);return(c>0?c+l:c)>=i}function ee(t,e,n={}){if(!e)return ot(t,null,n)||te(t,null,n);const o=ct(e,t.schema);return"node"===o?ot(t,e,n):"mark"===o&&te(t,e,n)}function ne(t,e){return Array.isArray(e)?e.some(e=>("string"==typeof e?e:e.name)===t.name):e}function oe(t,e){const{nodeExtensions:n}=$t(e),o=n.find(e=>e.name===t);if(!o)return!1;const s=At(Et(o,"group",{name:o.name,options:o.options,storage:o.storage}));return"string"==typeof s&&s.split(" ").includes("list")}function se(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var o;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!=(o=t.text)?o:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let o=!0;return t.content.forEach(t=>{!1!==o&&(se(t,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}var re=class t{constructor(t){this.position=t}static fromJSON(e){return new t(e.position)}toJSON(){return{position:this.position}}};function ie(t,e){const n=e.mapping.mapResult(t.position);return{position:new re(n.pos),mapResult:n}}function ae(t){return new re(t)}var ce=(t,e={})=>({tr:n,state:o,dispatch:s})=>{const{selection:r}=n,{empty:i,ranges:a}=r,c=O(t,o.schema);if(s)if(i){const t=bt(o,c);n.addStoredMark(c.create({...t,...e}))}else a.forEach(t=>{const s=t.$from.pos,r=t.$to.pos;o.doc.nodesBetween(s,r,(t,o)=>{const i=Math.max(o,s),a=Math.min(o+t.nodeSize,r);t.marks.find(t=>t.type===c)?t.marks.forEach(t=>{c===t.type&&n.addMark(i,a,c.create({...t.attrs,...e}))}):n.addMark(i,a,c.create(e))})});return function(t,e,n){var o;const{selection:s}=e;let r=null;if(N(s)&&(r=s.$cursor),r){const e=null!=(o=t.storedMarks)?o:r.marks();return r.parent.type.allowsMarkType(n)&&(!!n.isInSet(e)||!e.some(t=>t.type.excludes(n)))}const{ranges:i}=s;return i.some(({$from:e,$to:o})=>{let s=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,o.pos,(t,e,o)=>{if(s)return!1;if(t.isInline){const e=!o||o.type.allowsMarkType(n),r=!!n.isInSet(t.marks)||!t.marks.some(t=>t.type.excludes(n));s=e&&r}return!s}),s})}(o,n,c)},le=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),de=(t,n={})=>({state:o,dispatch:s,chain:r})=>{const i=y(t,o.schema);let a;return o.selection.$anchor.sameParent(o.selection.$head)&&(a=o.selection.$anchor.parent.attrs),i.isTextblock?r().command(({commands:t})=>!!e.setBlockType(i,{...a,...n})(o)||t.clearNodes()).command(({state:t})=>e.setBlockType(i,{...a,...n})(t,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},pe=t=>({tr:e,dispatch:o})=>{if(o){const{doc:o}=e,s=z(t,0,o.content.size),r=n.NodeSelection.create(o,s);e.setSelection(r)}return!0},ue=(t,e)=>({tr:n,state:o,dispatch:s})=>{const{selection:r}=o;let i,a;return"number"==typeof e?(i=e,a=e):e&&"from"in e&&"to"in e?(i=e.from,a=e.to):(i=r.from,a=r.to),s&&n.doc.nodesBetween(i,a,(e,o)=>{e.isText||n.setNodeMarkup(o,void 0,{...e.attrs,dir:t})}),!0},he=t=>({tr:e,dispatch:o})=>{if(o){const{doc:o}=e,{from:s,to:r}="number"==typeof t?{from:t,to:t}:t,i=n.TextSelection.atStart(o).from,a=n.TextSelection.atEnd(o).to,c=z(s,i,a),l=z(r,i,a),d=n.TextSelection.create(o,c,l);e.setSelection(d)}return!0},me=t=>({state:e,dispatch:n})=>{const o=y(t,e.schema);return s.sinkListItem(o)(e,n)};function fe(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const o=n.filter(t=>null==e?void 0:e.includes(t.type.name));t.tr.ensureMarks(o)}}var ge=({keepMarks:e=!0}={})=>({tr:o,state:s,dispatch:r,editor:i})=>{const{selection:a,doc:c}=o,{$from:l,$to:d}=a,p=Qt(i.extensionManager.attributes,l.node().type.name,l.node().attrs);if(a instanceof n.NodeSelection&&a.node.isBlock)return!(!l.parentOffset||!t.canSplit(c,l.pos))&&(r&&(e&&fe(s,i.extensionManager.splittableMarks),o.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=d.parentOffset===d.parent.content.size,h=0===l.depth?void 0:wt(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=u&&h?[{type:h,attrs:p}]:void 0,f=t.canSplit(o.doc,o.mapping.map(l.pos),1,m);if(m||f||!t.canSplit(o.doc,o.mapping.map(l.pos),1,h?[{type:h}]:void 0)||(f=!0,m=h?[{type:h,attrs:p}]:void 0),r){if(f&&(a instanceof n.TextSelection&&o.deleteSelection(),o.split(o.mapping.map(l.pos),1,m),h&&!u&&!l.parentOffset&&l.parent.type!==h)){const t=o.mapping.map(l.before()),e=o.doc.resolve(t);l.node(-1).canReplaceWith(e.index(),e.index()+1,h)&&o.setNodeMarkup(o.mapping.map(l.before()),h)}e&&fe(s,i.extensionManager.splittableMarks),o.scrollIntoView()}return f},ve=(e,s={})=>({tr:r,state:i,dispatch:a,editor:c})=>{var l;const d=y(e,i.schema),{$from:p,$to:u}=i.selection,h=i.selection.node;if(h&&h.isBlock||p.depth<2||!p.sameParent(u))return!1;const m=p.node(-1);if(m.type!==d)return!1;const f=c.extensionManager.attributes;if(0===p.parent.content.size&&p.node(-1).childCount===p.indexAfter(-1)){if(2===p.depth||p.node(-3).type!==d||p.index(-2)!==p.node(-2).childCount-1)return!1;if(a){let t=o.Fragment.empty;const e=p.index(-1)?1:p.index(-2)?2:3;for(let n=p.depth-e;n>=p.depth-3;n-=1)t=o.Fragment.from(p.node(n).copy(t));const i=p.indexAfter(-1)<p.node(-2).childCount?1:p.indexAfter(-2)<p.node(-3).childCount?2:3,a={...Qt(f,p.node().type.name,p.node().attrs),...s},c=(null==(l=d.contentMatch.defaultType)?void 0:l.createAndFill(a))||void 0;t=t.append(o.Fragment.from(d.createAndFill(null,c)||void 0));const u=p.before(p.depth-(e-1));r.replace(u,p.after(-i),new o.Slice(t,4-e,0));let h=-1;r.doc.nodesBetween(u,r.doc.content.size,(t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)}),h>-1&&r.setSelection(n.TextSelection.near(r.doc.resolve(h))),r.scrollIntoView()}return!0}const g=u.pos===p.end()?m.contentMatchAt(0).defaultType:null,v={...Qt(f,m.type.name,m.attrs),...s},x={...Qt(f,p.node().type.name,p.node().attrs),...s};r.delete(p.pos,u.pos);const b=g?[{type:d,attrs:v},{type:g,attrs:x}]:[{type:d,attrs:v}];if(!t.canSplit(r.doc,p.pos,2))return!1;if(a){const{selection:t,storedMarks:e}=i,{splittableMarks:n}=c.extensionManager,o=e||t.$to.parentOffset&&t.$from.marks();if(r.split(p.pos,2,b).scrollIntoView(),!o||!a)return!0;const s=o.filter(t=>n.includes(t.type.name));r.ensureMarks(s)}return!0},xe=(e,n)=>{const o=St(t=>t.type===n)(e.selection);if(!o)return!0;const s=e.doc.resolve(Math.max(0,o.pos-1)).before(o.depth);if(void 0===s)return!0;const r=e.doc.nodeAt(s);return o.node.type!==(null==r?void 0:r.type)||!t.canJoin(e.doc,o.pos)||(e.join(o.pos),!0)},ye=(e,n)=>{const o=St(t=>t.type===n)(e.selection);if(!o)return!0;const s=e.doc.resolve(o.start).after(o.depth);if(void 0===s)return!0;const r=e.doc.nodeAt(s);return o.node.type!==(null==r?void 0:r.type)||!t.canJoin(e.doc,s)||(e.join(s),!0)},be=(t,e,n,o={})=>({editor:s,tr:r,state:i,dispatch:a,chain:c,commands:l,can:d})=>{const{extensions:p,splittableMarks:u}=s.extensionManager,h=y(t,i.schema),m=y(e,i.schema),{selection:f,storedMarks:g}=i,{$from:v,$to:x}=f,b=v.blockRange(x),k=g||f.$to.parentOffset&&f.$from.marks();if(!b)return!1;const w=St(t=>oe(t.type.name,p))(f);if(b.depth>=1&&w&&b.depth-w.depth<=1){if(w.node.type===h)return l.liftListItem(m);if(oe(w.node.type.name,p)&&h.validContent(w.node.content)&&a)return c().command(()=>(r.setNodeMarkup(w.pos,h),!0)).command(()=>xe(r,h)).command(()=>ye(r,h)).run()}return n&&k&&a?c().command(()=>{const t=d().wrapInList(h,o),e=k.filter(t=>u.includes(t.type.name));return r.ensureMarks(e),!!t||l.clearNodes()}).wrapInList(h,o).command(()=>xe(r,h)).command(()=>ye(r,h)).run():c().command(()=>!!d().wrapInList(h,o)||l.clearNodes()).wrapInList(h,o).command(()=>xe(r,h)).command(()=>ye(r,h)).run()},ke=(t,e={},n={})=>({state:o,commands:s})=>{const{extendEmptyMarkRange:r=!1}=n,i=O(t,o.schema);return te(o,i,e)?s.unsetMark(i,{extendEmptyMarkRange:r}):s.setMark(i,e)},we=(t,e,n={})=>({state:o,commands:s})=>{const r=y(t,o.schema),i=y(e,o.schema),a=ot(o,r,n);let c;return o.selection.$anchor.sameParent(o.selection.$head)&&(c=o.selection.$anchor.parent.attrs),a?s.setNode(i,c):s.setNode(r,{...c,...n})},Me=(t,e={})=>({state:n,commands:o})=>{const s=y(t,n.schema);return ot(n,s,e)?o.lift(s):o.wrapIn(s,e)},Se=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let o=0;o<n.length;o+=1){const s=n[o];let r;if(s.spec.isInputRules&&(r=s.getState(t))){if(e){const e=t.tr,n=r.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(r.text){const n=e.doc.resolve(r.from).marks();e.replaceWith(r.from,r.to,t.schema.text(r.text,n))}else e.delete(r.from,r.to)}return!0}}return!1},Ee=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:o,ranges:s}=n;return o||e&&s.forEach(e=>{t.removeMark(e.$from.pos,e.$to.pos)}),!0},Te=(t,e={})=>({tr:n,state:o,dispatch:s})=>{var r;const{extendEmptyMarkRange:i=!1}=e,{selection:a}=n,c=O(t,o.schema),{$from:l,empty:d,ranges:p}=a;if(!s)return!0;if(d&&i){let{from:t,to:e}=a;const o=null==(r=l.marks().find(t=>t.type===c))?void 0:r.attrs,s=A(l,c,o);s&&(t=s.from,e=s.to),n.removeMark(t,e,c)}else p.forEach(t=>{n.removeMark(t.$from.pos,t.$to.pos,c)});return n.removeStoredMark(c),!0},Ce=t=>({tr:e,state:n,dispatch:o})=>{const{selection:s}=n;let r,i;return"number"==typeof t?(r=t,i=t):t&&"from"in t&&"to"in t?(r=t.from,i=t.to):(r=s.from,i=s.to),o&&e.doc.nodesBetween(r,i,(t,n)=>{if(t.isText)return;const o={...t.attrs};delete o.dir,e.setNodeMarkup(n,void 0,o)}),!0},Pe=(t,e={})=>({tr:n,state:o,dispatch:s})=>{let r=null,i=null;const a=ct("string"==typeof t?t:t.name,o.schema);if(!a)return!1;"node"===a&&(r=y(t,o.schema)),"mark"===a&&(i=O(t,o.schema));let c=!1;return n.selection.ranges.forEach(t=>{const a=t.$from.pos,l=t.$to.pos;let d,p,u,h;n.selection.empty?o.doc.nodesBetween(a,l,(t,e)=>{r&&r===t.type&&(c=!0,u=Math.max(e,a),h=Math.min(e+t.nodeSize,l),d=e,p=t)}):o.doc.nodesBetween(a,l,(t,o)=>{o<a&&r&&r===t.type&&(c=!0,u=Math.max(o,a),h=Math.min(o+t.nodeSize,l),d=o,p=t),o>=a&&o<=l&&(r&&r===t.type&&(c=!0,s&&n.setNodeMarkup(o,void 0,{...t.attrs,...e})),i&&t.marks.length&&t.marks.forEach(r=>{if(i===r.type&&(c=!0,s)){const s=Math.max(o,a),c=Math.min(o+t.nodeSize,l);n.addMark(s,c,i.create({...r.attrs,...e}))}}))}),p&&(void 0!==d&&s&&n.setNodeMarkup(d,void 0,{...p.attrs,...e}),i&&p.marks.length&&p.marks.forEach(t=>{i===t.type&&s&&n.addMark(u,h,i.create({...t.attrs,...e}))}))}),c},Ae=(t,n={})=>({state:o,dispatch:s})=>{const r=y(t,o.schema);return e.wrapIn(r,n)(o,s)},Oe=(t,e={})=>({state:n,dispatch:o})=>{const r=y(t,n.schema);return s.wrapInList(r,e)(n,o)},$e=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(t=>t.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(t=>t!==e):delete this.callbacks[t]),this}once(t,e){const n=(...o)=>{this.off(t,n),e.apply(this,o)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Re=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=null==(e=t.undoable)||e}};function Ne(t){var e;const{editor:n,from:o,to:s,text:r,rules:i,plugin:a}=t,{view:c}=n;if(c.composing)return!1;const p=c.state.doc.resolve(o);if(p.parent.type.spec.code||(null==(e=p.nodeBefore||p.nodeAfter)?void 0:e.marks.find(t=>t.type.spec.code)))return!1;let u=!1;const h=Gt(p)+r;return i.forEach(t=>{if(u)return;const e=((t,e)=>{if(E(e))return e.exec(t);const n=e(t);if(!n)return null;const o=[n.text];return o.index=n.index,o.input=t,o.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(n.replaceWith)),o})(h,t.find);if(!e)return;const i=c.state.tr,p=l({state:c.state,transaction:i}),m={from:o-(e[0].length-r.length),to:s},{commands:f,chain:g,can:v}=new d({editor:n,state:p});null!==t.handler({state:p,range:m,match:e,commands:f,chain:g,can:v})&&i.steps.length&&(t.undoable&&i.setMeta(a,{transform:i,from:o,to:s,text:r}),c.dispatch(i),u=!0)}),u}function ze(t){const{editor:e,rules:s}=t,r=new n.Plugin({state:{init:()=>null,apply(t,n,i){const a=t.getMeta(r);if(a)return a;const c=t.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:t}=c;"string"==typeof t||(t=Ct(o.Fragment.from(t),i.schema));const{from:n}=c,a=n+t.length;Ne({editor:e,from:n,to:a,text:t,rules:s,plugin:r})}),t.selectionSet||t.docChanged?null:n}},props:{handleTextInput:(t,n,o,i)=>Ne({editor:e,from:n,to:o,text:i,rules:s,plugin:r}),handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:n}=t.state.selection;n&&Ne({editor:e,from:n.pos,to:n.pos,text:"",rules:s,plugin:r})}),!1)},handleKeyDown(t,n){if("Enter"!==n.key)return!1;const{$cursor:o}=t.state.selection;return!!o&&Ne({editor:e,from:o.pos,to:o.pos,text:"\n",rules:s,plugin:r})}},isInputRules:!0});return r}function je(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function Ie(t,e){const n={...t};return je(t)&&je(e)&&Object.keys(e).forEach(o=>{je(e[o])&&je(t[o])?n[o]=Ie(t[o],e[o]):n[o]=e[o]}),n}var De=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...At(Et(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...At(Et(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Ie(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Be=class t extends De{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const s=o.marks();if(!!!s.find(t=>(null==t?void 0:t.type.name)===e.name))return!1;const r=s.find(t=>(null==t?void 0:t.type.name)===e.name);return r&&n.removeStoredMark(r),n.insertText(" ",o.pos),t.view.dispatch(n),!0}return!1}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}};function He(t){return"number"==typeof t}var Le=class{constructor(t){this.find=t.find,this.handler=t.handler}};function Ve(t){const{editor:e,state:n,from:o,to:s,rule:r,pasteEvent:i,dropEvent:a}=t,{commands:c,chain:l,can:p}=new d({editor:e,state:n}),u=[];n.doc.nodesBetween(o,s,(t,e)=>{var d,h,m,f,g;if((null==(h=null==(d=t.type)?void 0:d.spec)?void 0:h.code)||!(t.isText||t.isTextblock||t.isInline))return;const v=null!=(g=null!=(f=null==(m=t.content)?void 0:m.size)?f:t.nodeSize)?g:0,x=Math.max(o,e),y=Math.min(s,e+v);if(x>=y)return;((t,e,n)=>{if(E(e))return[...t.matchAll(e)];const o=e(t,n);return o?o.map(e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n}):[]})(t.isText?t.text||"":t.textBetween(x-e,y-e,void 0,"￼"),r.find,i).forEach(t=>{if(void 0===t.index)return;const e=x+t.index+1,o=e+t[0].length,s={from:n.tr.mapping.map(e),to:n.tr.mapping.map(o)},d=r.handler({state:n,range:s,match:t,commands:c,chain:l,can:p,pasteEvent:i,dropEvent:a});u.push(d)})});return u.every(t=>null!==t)}var Fe=null;function We(t){const{editor:e,rules:s}=t;let r,i=null,a=!1,c=!1,d="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}const p=({state:t,from:n,to:o,rule:s,pasteEvt:i})=>{const a=t.tr,c=l({state:t,transaction:a});if(Ve({editor:e,state:c,from:Math.max(n-1,0),to:o.b-1,rule:s,pasteEvent:i,dropEvent:r})&&a.steps.length){try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}return d="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a}};return s.map(t=>new n.Plugin({view(t){const n=n=>{var o;i=(null==(o=t.dom.parentElement)?void 0:o.contains(n.target))?t.dom.parentElement:null,i&&(Fe=e)},o=()=>{Fe&&(Fe=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",o),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",o)}}},props:{handleDOMEvents:{drop:(t,e)=>{if(c=i===t.dom.parentElement,r=e,!c){const t=Fe;(null==t?void 0:t.isEditable)&&setTimeout(()=>{const e=t.state.selection;e&&t.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:(t,e)=>{var n;const o=null==(n=e.clipboardData)?void 0:n.getData("text/html");return d=e,a=!!(null==o?void 0:o.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,s)=>{const r=e[0],i="paste"===r.getMeta("uiEvent")&&!a,l="drop"===r.getMeta("uiEvent")&&!c,u=r.getMeta("applyPasteRules"),h=!!u;if(!i&&!l&&!h)return;if(h){let{text:e}=u;"string"==typeof e||(e=Ct(o.Fragment.from(e),s.schema));const{from:n}=u,r=n+e.length,i=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(e=n.clipboardData)||e.setData("text/html",t),n})(e);return p({rule:t,state:s,from:n,to:{b:r},pasteEvt:i})}const m=n.doc.content.findDiffStart(s.doc.content),f=n.doc.content.findDiffEnd(s.doc.content);return He(m)&&f&&m!==f.b?p({rule:t,state:s,from:m,to:f,pasteEvt:d}):void 0}}))}var Ue=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Ft(t),this.schema=Ht(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n=Et(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Zt(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this;return Vt([...this.extensions].reverse()).flatMap(e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Zt(e.name,this.schema)},o=[],s=Et(e,"addKeyboardShortcuts",n);let r={};if("mark"===e.type&&Et(e,"exitable",n)&&(r.ArrowRight=()=>Be.handleExit({editor:t,mark:e})),s){const e=Object.fromEntries(Object.entries(s()).map(([e,n])=>[e,()=>n({editor:t})]));r={...r,...e}}const a=i.keymap(r);o.push(a);const c=Et(e,"addInputRules",n);if(ne(e,t.options.enableInputRules)&&c){const e=c();if(e&&e.length){const n=ze({editor:t,rules:e}),s=Array.isArray(n)?n:[n];o.push(...s)}}const l=Et(e,"addPasteRules",n);if(ne(e,t.options.enablePasteRules)&&l){const e=l();if(e&&e.length){const n=We({editor:t,rules:e});o.push(...n)}}const d=Et(e,"addProseMirrorPlugins",n);if(d){const t=d();o.push(...t)}return o})}get attributes(){return Rt(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=$t(this.extensions);return Object.fromEntries(e.filter(t=>!!Et(t,"addNodeView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:y(e.name,this.schema)},s=Et(e,"addNodeView",o);if(!s)return[];const r=s();if(!r)return[];return[e.name,(o,s,i,a,c)=>{const l=zt(o,n);return r({node:o,view:s,getPos:i,decorations:a,innerDecorations:c,editor:t,extension:e,HTMLAttributes:l})}]}))}dispatchTransaction(t){const{editor:e}=this;return Vt([...this.extensions].reverse()).reduceRight((t,n)=>{const o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Zt(n.name,this.schema)},s=Et(n,"dispatchTransaction",o);return s?e=>{s.call(o,{transaction:e,next:t})}:t},t)}transformPastedHTML(t){const{editor:e}=this;return Vt([...this.extensions]).reduce((t,n)=>{const o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Zt(n.name,this.schema)},s=Et(n,"transformPastedHTML",o);return s?(e,n)=>{const r=t(e,n);return s.call(o,r)}:t},t||(t=>t))}get markViews(){const{editor:t}=this,{markExtensions:e}=$t(this.extensions);return Object.fromEntries(e.filter(t=>!!Et(t,"addMarkView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:O(e.name,this.schema)},s=Et(e,"addMarkView",o);if(!s)return[];return[e.name,(o,r,i)=>{const a=zt(o,n);return s()({mark:o,view:r,inline:i,editor:t,extension:e,HTMLAttributes:a,updateAttributes:e=>{vn(o,t,e)}})}]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(t=>[t.name,t.storage])),t.forEach(t=>{var e;const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Zt(t.name,this.schema)};if("mark"===t.type){(null==(e=At(Et(t,"keepOnSplit",n)))||e)&&this.splittableMarks.push(t.name)}const o=Et(t,"onBeforeCreate",n),s=Et(t,"onCreate",n),r=Et(t,"onUpdate",n),i=Et(t,"onSelectionUpdate",n),a=Et(t,"onTransaction",n),c=Et(t,"onFocus",n),l=Et(t,"onBlur",n),d=Et(t,"onDestroy",n);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),r&&this.editor.on("update",r),i&&this.editor.on("selectionUpdate",i),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),l&&this.editor.on("blur",l),d&&this.editor.on("destroy",d)})}};Ue.resolve=Ft,Ue.sort=Vt,Ue.flatten=Tt;var Ke={};c(Ke,{ClipboardTextSerializer:()=>qe,Commands:()=>Je,Delete:()=>Ye,Drop:()=>Xe,Editable:()=>Ze,FocusEvents:()=>Ge,Keymap:()=>tn,Paste:()=>en,Tabindex:()=>nn,TextDirection:()=>on,focusEventsPluginKey:()=>Qe});var _e=class t extends De{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},qe=_e.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new n.Plugin({key:new n.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:o,selection:s}=e,{ranges:r}=s,i=Math.min(...r.map(t=>t.$from.pos)),a=Math.max(...r.map(t=>t.$to.pos)),c=Kt(n);return Wt(o,{from:i,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Je=_e.create({name:"commands",addCommands:()=>({...p})}),Ye=_e.create({name:"delete",onUpdate({transaction:e,appendedTransactions:n}){var o,s,r;const i=()=>{var o,s,r,i;if(null!=(i=null==(r=null==(s=null==(o=this.editor.options.coreExtensionOptions)?void 0:o.delete)?void 0:s.filterTransaction)?void 0:r.call(s,e))?i:e.getMeta("y-sync$"))return;const a=kt(e.before,[e,...n]);Yt(a).forEach(t=>{a.mapping.mapResult(t.oldRange.from).deletedAfter&&a.mapping.mapResult(t.oldRange.to).deletedBefore&&a.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,o)=>{const s=o+n.nodeSize-2,r=t.oldRange.from<=o&&s<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:o,to:s,newFrom:a.mapping.map(o),newTo:a.mapping.map(s),deletedRange:t.oldRange,newRange:t.newRange,partial:!r,editor:this.editor,transaction:e,combinedTransform:a})})});const c=a.mapping;a.steps.forEach((n,o)=>{var s,r;if(n instanceof t.RemoveMarkStep){const t=c.slice(o).map(n.from,-1),i=c.slice(o).map(n.to),l=c.invert().map(t,-1),d=c.invert().map(i),p=null==(s=a.doc.nodeAt(t-1))?void 0:s.marks.some(t=>t.eq(n.mark)),u=null==(r=a.doc.nodeAt(i))?void 0:r.marks.some(t=>t.eq(n.mark));this.editor.emit("delete",{type:"mark",mark:n.mark,from:n.from,to:n.to,deletedRange:{from:l,to:d},newRange:{from:t,to:i},partial:Boolean(u||p),editor:this.editor,transaction:e,combinedTransform:a})}})};null==(r=null==(s=null==(o=this.editor.options.coreExtensionOptions)?void 0:o.delete)?void 0:s.async)||r?setTimeout(i,0):i()}}),Xe=_e.create({name:"drop",addProseMirrorPlugins(){return[new n.Plugin({key:new n.PluginKey("tiptapDrop"),props:{handleDrop:(t,e,n,o)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:o})}}})]}}),Ze=_e.create({name:"editable",addProseMirrorPlugins(){return[new n.Plugin({key:new n.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Qe=new n.PluginKey("focusEvents"),Ge=_e.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new n.Plugin({key:Qe,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const o=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1},blur:(e,n)=>{t.isFocused=!1;const o=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1}}}})]}}),tn=_e.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:t})=>[()=>t.undoInputRule(),()=>t.command(({tr:e})=>{const{selection:o,doc:s}=e,{empty:r,$anchor:i}=o,{pos:a,parent:c}=i,l=i.parent.isTextblock&&a>0?e.doc.resolve(a-1):i,d=l.parent.type.spec.isolating,p=i.pos-i.parentOffset,u=d&&1===l.parent.childCount?p===i.pos:n.Selection.atStart(s).from===a;return!(!r||!c.type.isTextblock||c.textContent.length||!u||u&&"paragraph"===i.parent.type.name)&&t.clearNodes()}),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]),o={Enter:()=>this.editor.commands.first(({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...o},r={...o,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return D()||et()?r:s},addProseMirrorPlugins(){return[new n.Plugin({key:new n.PluginKey("clearDocument"),appendTransaction:(t,e,o)=>{if(t.some(t=>t.getMeta("composition")))return;const s=t.some(t=>t.docChanged)&&!e.doc.eq(o.doc),r=t.some(t=>t.getMeta("preventClearDocument"));if(!s||r)return;const{empty:i,from:a,to:c}=e.selection,p=n.Selection.atStart(e.doc).from,u=n.Selection.atEnd(e.doc).to;if(i||!(a===p&&c===u))return;if(!se(o.doc))return;const h=o.tr,m=l({state:o,transaction:h}),{commands:f}=new d({editor:this.editor,state:m});return f.clearNodes(),h.steps.length?h:void 0}})]}}),en=_e.create({name:"paste",addProseMirrorPlugins(){return[new n.Plugin({key:new n.PluginKey("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),nn=_e.create({name:"tabindex",addProseMirrorPlugins(){return[new n.Plugin({key:new n.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),on=_e.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=$t(this.extensions);return[{types:t.filter(t=>"text"!==t.name).map(t=>t.name),attributes:{dir:{default:this.options.direction,parseHTML:t=>{const e=t.getAttribute("dir");return!e||"ltr"!==e&&"rtl"!==e&&"auto"!==e?this.options.direction:e},renderHTML:t=>t.dir?{dir:t.dir}:{}}}}]},addProseMirrorPlugins(){return[new n.Plugin({key:new n.PluginKey("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),sn=class t{constructor(t,e,n=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!=(t=this.actualDepth)?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new t(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new t(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,o)=>{const s=n.isBlock&&!n.isTextblock,r=n.isAtom&&!n.isText,i=n.isInline,a=this.pos+o+(r?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(a);if(!s&&!i&&c.depth<=this.depth)return;const l=new t(c,this.editor,s,s||i?n:null);s&&(l.actualDepth=this.depth+1),e.push(l)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,o=this.parent;for(;o&&!n;){if(o.node.type.name===t)if(Object.keys(e).length>0){const t=o.node.attrs,n=Object.keys(e);for(let o=0;o<n.length;o+=1){const s=n[o];if(t[s]!==e[s])break}}else n=o;o=o.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let o=[];if(!this.children||0===this.children.length)return o;const s=Object.keys(e);return this.children.forEach(r=>{if(!(n&&o.length>0)){if(r.node.type.name===t){s.every(t=>e[t]===r.node.attrs[t])&&o.push(r)}n&&o.length>0||(o=o.concat(r.querySelectorAll(t,e,n)))}}),o}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}};function rn(t,e,n){const o=document.querySelector("style[data-tiptap-style]");if(null!==o)return o;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var an={};function cn(t){if(!(null==t?void 0:t.trim()))return{};const e={},n=[],o=t.replace(/["']([^"']*)["']/g,t=>(n.push(t),`__QUOTED_${n.length-1}__`)),s=o.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const t=s.map(t=>t.trim().slice(1));e.class=t.join(" ")}const r=o.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);r&&(e.id=r[1]);Array.from(o.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,t,o])=>{var s;const r=parseInt((null==(s=o.match(/__QUOTED_(\d+)__/))?void 0:s[1])||"0",10),i=n[r];i&&(e[t]=i.slice(1,-1))});const i=o.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();if(i){i.split(/\s+/).filter(Boolean).forEach(t=>{t.match(/^[a-zA-Z][\w-]*$/)&&(e[t]=!0)})}return e}function ln(t){if(!t||0===Object.keys(t).length)return"";const e=[];if(t.class){String(t.class).split(/\s+/).filter(Boolean).forEach(t=>e.push(`.${t}`))}return t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([t,n])=>{"class"!==t&&"id"!==t&&(!0===n?e.push(t):!1!==n&&null!=n&&e.push(`${t}="${String(n)}"`))}),e.join(" ")}function dn(t){const{nodeName:e,name:n,parseAttributes:o=cn,serializeAttributes:s=ln,defaultAttributes:r={},requiredAttributes:i=[],allowedAttributes:a}=t,c=n||e;return{parseMarkdown:(t,n)=>{const o={...r,...t.attributes};return n.createNode(e,o,[])},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${c}(?:\\s|$)`,"m"),o=null==(e=t.match(n))?void 0:e.index;return void 0!==o?o:-1},tokenize(t,n,s){const r=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),a=t.match(r);if(!a)return;const l=a[1]||"",d=o(l);return i.find(t=>!(t in d))?void 0:{type:e,raw:a[0],attributes:d}}},renderMarkdown:t=>{const e=(t=>{if(!a)return t;const e={};return a.forEach(n=>{n in t&&(e[n]=t[n])}),e})(t.attrs||{}),n=s(e);return`:::${c}${n?` {${n}}`:""} :::`}}}function pn(t){const{nodeName:e,name:n,getContent:o,parseAttributes:s=cn,serializeAttributes:r=ln,defaultAttributes:i={},content:a="block",allowedAttributes:c}=t,l=n||e;return{parseMarkdown:(t,n)=>{let s;if(o){const e=o(t);s="string"==typeof e?[{type:"text",text:e}]:e}else s="block"===a?n.parseChildren(t.tokens||[]):n.parseInline(t.tokens||[]);const r={...i,...t.attributes};return n.createNode(e,r,s)},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${l}`,"m"),o=null==(e=t.match(n))?void 0:e.index;return void 0!==o?o:-1},tokenize(t,n,o){var r;const i=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),c=t.match(i);if(!c)return;const[d,p=""]=c,u=s(p);let h=1;const m=d.length;let f="";const g=/^:::([\w-]*)(\s.*)?/gm,v=t.slice(m);for(g.lastIndex=0;;){const n=g.exec(v);if(null===n)break;const s=n.index,i=n[1];if(!(null==(r=n[2])?void 0:r.endsWith(":::")))if(i)h+=1;else if(h-=1,0===h){const r=v.slice(0,s);f=r.trim();const i=t.slice(0,m+s+n[0].length);let c=[];if(f)if("block"===a)for(c=o.blockTokens(r),c.forEach(t=>{!t.text||t.tokens&&0!==t.tokens.length||(t.tokens=o.inlineTokens(t.text))});c.length>0;){const t=c[c.length-1];if("paragraph"!==t.type||t.text&&""!==t.text.trim())break;c.pop()}else c=o.inlineTokens(f);return{type:e,raw:i,attributes:u,content:f,tokens:c}}}}},renderMarkdown:(t,e)=>{const n=(t=>{if(!c)return t;const e={};return c.forEach(n=>{n in t&&(e[n]=t[n])}),e})(t.attrs||{}),o=r(n),s=o?` {${o}}`:"",i=e.renderChildren(t.content||[],"\n\n");return`:::${l}${s}\n\n${i}\n\n:::`}}}function un(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let o=n.exec(t);for(;null!==o;){const[,s,r,i]=o;e[s]=r||i,o=n.exec(t)}return e}function hn(t){return Object.entries(t).filter(([,t])=>null!=t).map(([t,e])=>`${t}="${e}"`).join(" ")}function mn(t){const{nodeName:e,name:n,getContent:o,parseAttributes:s=un,serializeAttributes:r=hn,defaultAttributes:i={},selfClosing:a=!1,allowedAttributes:c}=t,l=n||e,d=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(t,n)=>{const s={...i,...t.attributes};if(a)return n.createNode(e,s);const r=o?o(t):t.content||"";return r?n.createNode(e,s,[n.createTextNode(r)]):n.createNode(e,s,[])},markdownTokenizer:{name:e,level:"inline",start(t){const e=a?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=t.match(e),o=null==n?void 0:n.index;return void 0!==o?o:-1},tokenize(t,n,o){const r=a?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),i=t.match(r);if(!i)return;let c="",l="";if(a){const[,t]=i;l=t}else{const[,t,e]=i;l=t,c=e||""}const p=s(l.trim());return{type:e,raw:i[0],content:c.trim(),attributes:p}}},renderMarkdown:t=>{let e="";o?e=o(t):t.content&&t.content.length>0&&(e=t.content.filter(t=>"text"===t.type).map(t=>t.text).join(""));const n=(t=>{if(!c)return t;const e={};return c.forEach(n=>{const o="string"==typeof n?n:n.name,s="string"==typeof n?void 0:n.skipIfDefault;if(o in t){const n=t[o];if(void 0!==s&&n===s)return;e[o]=n}}),e})(t.attrs||{}),s=r(n),i=s?` ${s}`:"";return a?`[${l}${i}]`:`[${l}${i}]${e}[/${l}]`}}}function fn(t,e,n){var o,s,r,i;const a=t.split("\n"),c=[];let l="",d=0;const p=e.baseIndentSize||2;for(;d<a.length;){const t=a[d],u=t.match(e.itemPattern);if(!u){if(c.length>0)break;if(""===t.trim()){d+=1,l=`${l}${t}\n`;continue}return}const h=e.extractItemData(u),{indentLevel:m,mainContent:f}=h;l=`${l}${t}\n`;const g=[f];for(d+=1;d<a.length;){const t=a[d];if(""===t.trim()){const e=a.slice(d+1).findIndex(t=>""!==t.trim());if(-1===e)break;if(((null==(s=null==(o=a[d+1+e].match(/^(\s*)/))?void 0:o[1])?void 0:s.length)||0)>m){g.push(t),l=`${l}${t}\n`,d+=1;continue}break}if(!(((null==(i=null==(r=t.match(/^(\s*)/))?void 0:r[1])?void 0:i.length)||0)>m))break;g.push(t),l=`${l}${t}\n`,d+=1}let v;const x=g.slice(1);if(x.length>0){const t=x.map(t=>t.slice(m+p)).join("\n");t.trim()&&(v=e.customNestedParser?e.customNestedParser(t):n.blockTokens(t))}const y=e.createToken(h,v);c.push(y)}if(0!==c.length)return{items:c,raw:l}}function gn(t,e,n,o){if(!t||!Array.isArray(t.content))return"";const s="function"==typeof n?n(o):n,[r,...i]=t.content,a=[`${s}${e.renderChildren([r])}`];return i&&i.length>0&&i.forEach(t=>{const n=e.renderChildren([t]);if(n){const t=n.split("\n").map(t=>t?e.indent(t):"").join("\n");a.push(t)}}),a.join("\n")}function vn(t,e,n={}){const{state:o}=e,{doc:s,tr:r}=o,i=t;s.descendants((e,o)=>{const s=r.mapping.map(o),a=r.mapping.map(o)+e.nodeSize;let c=null;if(e.marks.forEach(t=>{if(t!==i)return!1;c=t}),!c)return;let l=!1;if(Object.keys(n).forEach(t=>{n[t]!==c.attrs[t]&&(l=!0)}),l){const e=t.type.create({...t.attrs,...n});r.removeMark(s,a,t.type),r.addMark(s,a,e)}}),r.docChanged&&e.view.dispatch(r)}c(an,{createAtomBlockMarkdownSpec:()=>dn,createBlockMarkdownSpec:()=>pn,createInlineMarkdownSpec:()=>mn,parseAttributes:()=>cn,parseIndentedBlocks:()=>fn,renderNestedMarkdownContent:()=>gn,serializeAttributes:()=>ln});exports.CommandManager=d,exports.Editor=class extends $e{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?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:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:ie,createMappablePosition:ae},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:t,slice:e,moved:n})=>this.options.onDrop(t,e,n)),this.on("paste",({event:t,slice:e})=>this.options.onPaste(t,e)),this.on("delete",this.options.onDelete);const e=this.createDoc(),o=j(e,this.options.autofocus);this.editorState=n.EditorState.create({doc:e,schema:this.schema,selection:o||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if("undefined"==typeof document)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||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;(null==t?void 0:t.editor)&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?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.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=rn('.ProseMirror {\n  position: relative;\n}\n\n.ProseMirror {\n  word-wrap: break-word;\n  white-space: pre-wrap;\n  white-space: break-spaces;\n  -webkit-font-variant-ligatures: none;\n  font-variant-ligatures: none;\n  font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n  white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n  white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n  white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n  display: inline !important;\n  border: none !important;\n  margin: 0 !important;\n  width: 0 !important;\n  height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n  display: none;\n  pointer-events: none;\n  position: absolute;\n  margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n  content: "";\n  display: block;\n  position: absolute;\n  top: -2px;\n  width: 20px;\n  border-top: 1px solid black;\n  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n  to {\n    visibility: hidden;\n  }\n}\n\n.ProseMirror-hideselection *::selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection * {\n  caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n  display: block;\n}',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),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("state"===e)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 this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Pt(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(t=>{const e="string"==typeof t?`${t}$`:t.key;n=n.filter(t=>!t.key.startsWith(e))}),e.length===n.length)return;const o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[Ze,qe.configure({blockSeparator:null==(e=null==(t=this.options.coreExtensionOptions)?void 0:t.clipboardTextSerializer)?void 0:e.blockSeparator}),Je,Ge,tn,nn,Xe,en,Ye,on.configure({direction:this.options.textDirection})].filter(t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name]):[],...this.options.extensions].filter(t=>["extension","node","mark"].includes(null==t?void 0:t.type));this.extensionManager=new Ue(n,this)}createCommandManager(){this.commandManager=new d({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=xt(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;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>"collaboration"!==t.name),this.createExtensionManager()}}),t=xt(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,o=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(o):o,i=e.transformPastedHTML,a=this.extensionManager.transformPastedHTML(i);this.editorView=new r.EditorView(t,{...e,attributes:{role:"textbox",...null==e?void 0:e.attributes},dispatchTransaction:s,transformPastedHTML:a,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();this.view.dom.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;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach(t=>{var e;return null==(e=this.capturedTransaction)?void 0:e.step(t)}):void(this.capturedTransaction=t);const{state:e,transactions:n}=this.state.applyTransaction(t),o=!this.state.selection.eq(e.selection),s=n.includes(t),r=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),o&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=n.findLast(t=>t.getMeta("focus")||t.getMeta("blur")),a=null==i?void 0:i.getMeta("focus"),c=null==i?void 0:i.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:i}),c&&this.emit("blur",{editor:this,event:c.event,transaction:i}),t.getMeta("preventUpdate")||!n.some(t=>t.docChanged)||r.doc.eq(e.doc)||this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return qt(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,o="string"==typeof t?e:t;return ee(this.state,n,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ct(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return Ut(this.state.doc,{blockSeparator:e,textSerializers:{...Kt(this.schema),...n}})}get isEmpty(){return se(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return null==(e=null==(t=this.editorView)?void 0:t.isDestroyed)||e}$node(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new sn(e,this)}get $doc(){return this.$pos(0)}},exports.Extendable=De,exports.Extension=_e,exports.InputRule=Re,exports.MappablePosition=re,exports.Mark=Be,exports.Node=class t extends De{constructor(){super(...arguments),this.type="node"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},exports.NodePos=sn,exports.PasteRule=Le,exports.ResizableNodeView=class{constructor(t){var e,n,o,s,r,i;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=t=>{if(!this.isResizing||!this.activeHandle)return;const e=t.clientX-this.startX,n=t.clientY-this.startY;this.handleResize(e,n)},this.handleTouchMove=t=>{if(!this.isResizing||!this.activeHandle)return;const e=t.touches[0];if(!e)return;const n=e.clientX-this.startX,o=e.clientY-this.startY;this.handleResize(n,o)},this.handleMouseUp=()=>{if(!this.isResizing)return;const t=this.element.offsetWidth,e=this.element.offsetHeight;this.onCommit(t,e),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=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(e=t.options)?void 0:e.min)&&(this.minSize={...this.minSize,...t.options.min}),(null==(n=t.options)?void 0:n.max)&&(this.maxSize=t.options.max),(null==(o=null==t?void 0:t.options)?void 0:o.directions)&&(this.directions=t.options.directions),(null==(s=t.options)?void 0:s.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(r=t.options)?void 0:r.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(null==(i=t.options)?void 0:i.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 null!=(t=this.contentElement)?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&0===this.handleMap.size&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type===this.node.type&&(this.node=t,!this.onUpdate||this.onUpdate(t,e,n))}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(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const 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){const 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){const n=e.includes("top"),o=e.includes("bottom"),s=e.includes("left"),r=e.includes("right");n&&(t.style.top="0"),o&&(t.style.bottom="0"),s&&(t.style.left="0"),r&&(t.style.right="0"),"top"!==e&&"bottom"!==e||(t.style.left="0",t.style.right="0"),"left"!==e&&"right"!==e||(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;e=this.createCustomHandle?this.createCustomHandle(t):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",e=>this.handleResizeStart(e,t)),e.addEventListener("touchstart",e=>this.handleResizeStart(e,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const 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,"touches"in 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;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:o,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),r=this.applyConstraints(o,s,n);this.element.style.width=`${r.width}px`,this.element.style.height=`${r.height}px`,this.onResize&&this.onResize(r.width,r.height)}calculateNewDimensions(t,e,n){let o=this.startWidth,s=this.startHeight;const r=t.includes("right"),i=t.includes("left"),a=t.includes("bottom"),c=t.includes("top");r?o=this.startWidth+e:i&&(o=this.startWidth-e),a?s=this.startHeight+n:c&&(s=this.startHeight-n),"right"!==t&&"left"!==t||(o=this.startWidth+(r?e:-e)),"top"!==t&&"bottom"!==t||(s=this.startHeight+(a?n:-n));return this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(o,s,t):{width:o,height:s}}applyConstraints(t,e,n){var o,s,r,i;if(!n){let n=Math.max(this.minSize.width,t),r=Math.max(this.minSize.height,e);return(null==(o=this.maxSize)?void 0:o.width)&&(n=Math.min(this.maxSize.width,n)),(null==(s=this.maxSize)?void 0:s.height)&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let a=t,c=e;return a<this.minSize.width&&(a=this.minSize.width,c=a/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,a=c*this.aspectRatio),(null==(r=this.maxSize)?void 0:r.width)&&a>this.maxSize.width&&(a=this.maxSize.width,c=a/this.aspectRatio),(null==(i=this.maxSize)?void 0:i.height)&&c>this.maxSize.height&&(c=this.maxSize.height,a=c*this.aspectRatio),{width:a,height:c}}applyAspectRatio(t,e,n){const o="top"===n||"bottom"===n;return"left"===n||"right"===n?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}},exports.callOrReturn=At,exports.canInsertNode=function(t,e){const{selection:o}=t,{$from:s}=o;if(o instanceof n.NodeSelection){const t=s.index();return s.parent.canReplaceWith(t,t+1,e)}let r=s.depth;for(;r>=0;){const t=s.index(r);if(s.node(r).contentMatchAt(t).matchType(e))return!0;r-=1}return!1},exports.combineTransactionSteps=kt,exports.commands=p,exports.createAtomBlockMarkdownSpec=dn,exports.createBlockMarkdownSpec=pn,exports.createChainableState=l,exports.createDocument=xt,exports.createInlineMarkdownSpec=mn,exports.createMappablePosition=ae,exports.createNodeFromContent=U,exports.createStyleTag=rn,exports.defaultBlockAt=wt,exports.deleteProps=lt,exports.elementFromString=W,exports.extensions=Ke,exports.findChildrenInRange=function(t,e,n){const o=[];return t.nodesBetween(e.from,e.to,(t,e)=>{n(t)&&o.push({node:t,pos:e})}),o},exports.findDuplicates=Lt,exports.findParentNode=St,exports.findParentNodeClosestToPos=Mt,exports.flattenExtensions=Tt,exports.fromString=jt,exports.getAttributes=qt,exports.getAttributesFromExtensions=Rt,exports.getChangedRanges=Yt,exports.getExtensionField=Et,exports.getHTMLFromFragment=Ct,exports.getMarkAttributes=bt,exports.getMarkRange=A,exports.getMarkType=O,exports.getMarksBetween=Xt,exports.getNodeAtPosition=(t,e,n,o=20)=>{const s=t.doc.resolve(n);let r=o,i=null;for(;r>0&&null===i;){const t=s.node(r);(null==t?void 0:t.type.name)===e?i=t:r-=1}return[i,r]},exports.getNodeAttributes=_t,exports.getNodeType=y,exports.getRenderedAttributes=zt,exports.getSchemaByResolvedExtensions=Ht,exports.getSchemaTypeByName=Zt,exports.getSchemaTypeNameByName=ct,exports.getSplittedAttributes=Qt,exports.getText=Ut,exports.getTextBetween=Wt,exports.getTextContentFromNodes=Gt,exports.getTextSerializersFromSchema=Kt,exports.getUpdatedPosition=ie,exports.injectExtensionAttributesToParseRule=It,exports.inputRulesPlugin=ze,exports.isActive=ee,exports.isAndroid=I,exports.isAtEndOfNode=(t,e)=>{const{$from:n,$to:o,$anchor:s}=t.selection;if(e){const n=St(t=>t.type.name===e)(t.selection);if(!n)return!1;const o=t.doc.resolve(n.pos+1);return s.pos+1===o.end()}return!(o.parentOffset<o.parent.nodeSize-2||n.pos!==o.pos)},exports.isAtStartOfNode=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)},exports.isEmptyObject=Ot,exports.isExtensionRulesEnabled=ne,exports.isFunction=Pt,exports.isList=oe,exports.isMacOS=et,exports.isMarkActive=te,exports.isNodeActive=ot,exports.isNodeEmpty=se,exports.isNodeSelection=function(t){return t instanceof n.NodeSelection},exports.isNumber=He,exports.isPlainObject=je,exports.isRegExp=E,exports.isSafari=B,exports.isTextSelection=N,exports.isiOS=D,exports.markInputRule=function(t){return new Re({find:t.find,handler:({state:e,range:n,match:o})=>{const s=At(t.getAttributes,void 0,o);if(!1===s||null===s)return null;const{tr:r}=e,i=o[o.length-1],a=o[0];if(i){const o=a.search(/\S/),c=n.from+a.indexOf(i),l=c+i.length;if(Xt(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>c).length)return null;l<n.to&&r.delete(l,n.to),c>n.from&&r.delete(n.from+o,c);const d=n.from+o+i.length;r.addMark(n.from+o,d,t.type.create(s||{})),r.removeStoredMark(t.type)}},undoable:t.undoable})},exports.markPasteRule=function(t){return new Le({find:t.find,handler:({state:e,range:n,match:o,pasteEvent:s})=>{const r=At(t.getAttributes,void 0,o,s);if(!1===r||null===r)return null;const{tr:i}=e,a=o[o.length-1],c=o[0];let l=n.to;if(a){const o=c.search(/\S/),s=n.from+c.indexOf(a),d=s+a.length;if(Xt(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>s).length)return null;d<n.to&&i.delete(d,n.to),s>n.from&&i.delete(n.from+o,s),l=n.from+o+a.length,i.addMark(n.from+o,l,t.type.create(r||{})),i.removeStoredMark(t.type)}}})},exports.markdown=an,exports.mergeAttributes=Nt,exports.mergeDeep=Ie,exports.minMax=z,exports.nodeInputRule=function(t){return new Re({find:t.find,handler:({state:e,range:n,match:o})=>{const s=At(t.getAttributes,void 0,o)||{},{tr:r}=e,i=n.from;let a=n.to;const c=t.type.create(s);if(o[1]){let t=i+o[0].lastIndexOf(o[1]);t>a?t=a:a=t+o[1].length;const e=o[0][o[0].length-1];r.insertText(e,i+o[0].length-1),r.replaceWith(t,a,c)}else if(o[0]){const e=t.type.isInline?i:i-1;r.insert(e,t.type.create(s)).delete(r.mapping.map(i),r.mapping.map(a))}r.scrollIntoView()},undoable:t.undoable})},exports.objectIncludes=T,exports.parseAttributes=cn,exports.parseIndentedBlocks=fn,exports.pasteRulesPlugin=We,exports.removeDuplicates=Jt,exports.renderNestedMarkdownContent=gn,exports.resolveExtensions=Ft,exports.resolveFocusPosition=j,exports.selectionToInsertionEnd=K,exports.serializeAttributes=ln,exports.sortExtensions=Vt,exports.splitExtensions=$t,exports.textblockTypeInputRule=function(t){return new Re({find:t.find,handler:({state:e,range:n,match:o})=>{const s=e.doc.resolve(n.from),r=At(t.getAttributes,void 0,o)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,r)},undoable:t.undoable})},exports.updateMarkViewAttributes=vn,exports.wrappingInputRule=function(e){return new Re({find:e.find,handler:({state:n,range:o,match:s,chain:r})=>{const i=At(e.getAttributes,void 0,s)||{},a=n.tr.delete(o.from,o.to),c=a.doc.resolve(o.from).blockRange(),l=c&&t.findWrapping(c,e.type,i);if(!l)return null;if(a.wrap(c,l),e.keepMarks&&e.editor){const{selection:t,storedMarks:o}=n,{splittableMarks:s}=e.editor.extensionManager,r=o||t.$to.parentOffset&&t.$from.marks();if(r){const t=r.filter(t=>s.includes(t.type.name));a.ensureMarks(t)}}if(e.keepAttributes){const t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";r().updateAttributes(t,i).run()}const d=a.doc.resolve(o.from-1).nodeBefore;d&&d.type===e.type&&t.canJoin(a.doc,o.from-1)&&(!e.joinPredicate||e.joinPredicate(s,d))&&a.join(o.from-1)},undoable:e.undoable})};