UNPKG

@omegagrid/milkdown-kit

Version:

Milkdown editor bundle for @omegagrid/markdown

1 lines 582 kB
var e={411:e=>{var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},s=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var r,o=t.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!o&&!i)return!1;for(r in e);return void 0===r||t.call(e,r)},l=function(e,t){r&&"__proto__"===t.name?r(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},a=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;if(o)return o(e,n).value}return e[n]};e.exports=function e(){var t,n,r,o,c,u,d=arguments[0],h=1,p=arguments.length,f=!1;for("boolean"==typeof d&&(f=d,d=arguments[1]||{},h=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});h<p;++h)if(null!=(t=arguments[h]))for(n in t)r=a(d,n),d!==(o=a(t,n))&&(f&&o&&(s(o)||(c=i(o)))?(c?(c=!1,u=r&&i(r)?r:[]):u=r&&s(r)?r:{},l(d,{name:n,newValue:e(f,u,o)})):void 0!==o&&l(d,{name:n,newValue:o}));return d}},437:(e,t,n)=>{var r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,a="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,c="object"==typeof self&&self&&self.Object===Object&&self,u=a||c||Function("return this")(),d=Object.prototype.toString,h=Math.max,p=Math.min,f=function(){return u.Date.now()};function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==d.call(e)}(e))return NaN;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var n=i.test(e);return n||s.test(e)?l(e.slice(2),n?2:8):o.test(e)?NaN:+e}e.exports=function(e,t,n){var r,o,i,s,l,a,c=0,u=!1,d=!1,y=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var n=r,i=o;return r=o=void 0,c=t,s=e.apply(i,n)}function k(e){var n=e-a;return void 0===a||n>=t||n<0||d&&e-c>=i}function v(){var e=f();if(k(e))return b(e);l=setTimeout(v,function(e){var n=t-(e-a);return d?p(n,i-(e-c)):n}(e))}function b(e){return l=void 0,y&&r?w(e):(r=o=void 0,s)}function x(){var e=f(),n=k(e);if(r=arguments,o=this,a=e,n){if(void 0===l)return function(e){return c=e,l=setTimeout(v,t),u?w(e):s}(a);if(d)return l=setTimeout(v,t),w(a)}return void 0===l&&(l=setTimeout(v,t)),s}return t=g(t)||0,m(n)&&(u=!!n.leading,i=(d="maxWait"in n)?h(g(n.maxWait)||0,t):i,y="trailing"in n?!!n.trailing:y),x.cancel=function(){void 0!==l&&clearTimeout(l),c=0,r=a=o=l=void 0},x.flush=function(){return void 0===l?s:b(f())},x}},176:(e,t,n)=>{var r="Expected a function",o=NaN,i="[object Symbol]",s=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt,d="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,h="object"==typeof self&&self&&self.Object===Object&&self,p=d||h||Function("return this")(),f=Object.prototype.toString,m=Math.max,g=Math.min,y=function(){return p.Date.now()};function w(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function k(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&f.call(e)==i}(e))return o;if(w(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=w(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(s,"");var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):l.test(e)?o:+e}e.exports=function(e,t,n){var o=!0,i=!0;if("function"!=typeof e)throw new TypeError(r);return w(n)&&(o="leading"in n?!!n.leading:o,i="trailing"in n?!!n.trailing:i),function(e,t,n){var o,i,s,l,a,c,u=0,d=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError(r);function f(t){var n=o,r=i;return o=i=void 0,u=t,l=e.apply(r,n)}function v(e){var n=e-c;return void 0===c||n>=t||n<0||h&&e-u>=s}function b(){var e=y();if(v(e))return x(e);a=setTimeout(b,function(e){var n=t-(e-c);return h?g(n,s-(e-u)):n}(e))}function x(e){return a=void 0,p&&o?f(e):(o=i=void 0,l)}function C(){var e=y(),n=v(e);if(o=arguments,i=this,c=e,n){if(void 0===a)return function(e){return u=e,a=setTimeout(b,t),d?f(e):l}(c);if(h)return a=setTimeout(b,t),f(c)}return void 0===a&&(a=setTimeout(b,t)),l}return t=k(t)||0,w(n)&&(d=!!n.leading,s=(h="maxWait"in n)?m(k(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p),C.cancel=function(){void 0!==a&&clearTimeout(a),u=0,o=c=i=a=void 0},C.flush=function(){return void 0===a?l:x(y())},C}(e,t,{leading:o,maxWait:t,trailing:i})}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{n.r(r),n.d(r,{atomico:()=>f,components:()=>ZT,core:()=>s,ctx:()=>e,plugins:()=>QT,presets:()=>XT,prose:()=>eO,transformer:()=>o,utils:()=>d});var e={};n.r(e),n.d(e,{Clock:()=>we,Container:()=>Q,Ctx:()=>ye,Inspector:()=>ge,Slice:()=>ee,SliceType:()=>te,Timer:()=>Me,TimerType:()=>Ne,createSlice:()=>ne,createTimer:()=>Te});var t={};n.r(t),n.d(t,{attentionMarkers:()=>br,contentInitial:()=>mr,disable:()=>xr,document:()=>fr,flow:()=>yr,flowInitial:()=>gr,insideSpan:()=>vr,string:()=>wr,text:()=>kr});var o={};n.r(o),n.d(o,{ParserState:()=>Ii,SerializerState:()=>Ji,Stack:()=>Oi,StackElement:()=>Ti});var i={};n.r(i),n.d(i,{browser:()=>Rl,calculateNodePosition:()=>Jl,calculateTextPosition:()=>Yl,cloneTr:()=>Zl,customInputRules:()=>Ll,customInputRulesKey:()=>$l,equalNodeType:()=>Ql,findChildren:()=>ta,findChildrenByMark:()=>na,findParent:()=>ra,findParentNode:()=>aa,findParentNodeClosestToPos:()=>la,findParentNodeType:()=>oa,findSelectedNodeOfType:()=>ca,flatten:()=>ea,getMarkFromSchema:()=>sa,getNodeFromSchema:()=>ia,markRule:()=>zl,nodeRule:()=>Bl,posToDOMRect:()=>Xl});var s={};n.r(s),n.d(s,{CommandManager:()=>Ih,CommandsReady:()=>$h,ConfigReady:()=>wh,Editor:()=>Mp,EditorStateReady:()=>Gh,EditorStatus:()=>Sp,EditorViewReady:()=>tp,InitReady:()=>vh,ParserReady:()=>zh,SchemaReady:()=>xh,SerializerReady:()=>Wh,commands:()=>Lh,commandsCtx:()=>Rh,commandsTimerCtx:()=>Ph,config:()=>kh,createCmdKey:()=>Dh,defaultValueCtx:()=>Uh,editorCtx:()=>uh,editorState:()=>ep,editorStateCtx:()=>ah,editorStateOptionsCtx:()=>Jh,editorStateTimerCtx:()=>Yh,editorView:()=>ap,editorViewCtx:()=>lh,editorViewOptionsCtx:()=>rp,editorViewTimerCtx:()=>np,getDoc:()=>Xh,init:()=>bh,initTimerCtx:()=>ch,inputRulesCtx:()=>dh,markViewCtx:()=>mh,marksCtx:()=>Nh,nodeViewCtx:()=>fh,nodesCtx:()=>Mh,parser:()=>_h,parserCtx:()=>Fh,parserTimerCtx:()=>jh,prosePluginsCtx:()=>hh,remarkCtx:()=>gh,remarkPluginsCtx:()=>ph,remarkStringifyOptionsCtx:()=>yh,rootAttrsCtx:()=>sp,rootCtx:()=>op,rootDOMCtx:()=>ip,schema:()=>Oh,schemaCtx:()=>Sh,schemaTimerCtx:()=>Ch,serializer:()=>Kh,serializerCtx:()=>qh,serializerTimerCtx:()=>Vh});var l={};n.r(l),n.d(l,{AllSelection:()=>Ys,EditorState:()=>ol,NodeSelection:()=>Us,Plugin:()=>sl,PluginKey:()=>cl,Selection:()=>_s,SelectionRange:()=>Ws,TextSelection:()=>qs,Transaction:()=>Qs});var a={};n.r(a),n.d(a,{ContentMatch:()=>it,DOMParser:()=>Ct,DOMSerializer:()=>Rt,Fragment:()=>De,Mark:()=>Le,MarkType:()=>vt,Node:()=>nt,NodeRange:()=>et,NodeType:()=>wt,ReplaceError:()=>ze,ResolvedPos:()=>Ge,Schema:()=>bt,Slice:()=>Be});var c={};n.r(c),n.d(c,{AddMarkStep:()=>ss,AddNodeMarkStep:()=>as,AttrStep:()=>Ls,DocAttrStep:()=>zs,MapResult:()=>Zi,Mapping:()=>es,RemoveMarkStep:()=>ls,RemoveNodeMarkStep:()=>cs,ReplaceAroundStep:()=>ds,ReplaceStep:()=>us,Step:()=>ns,StepMap:()=>Qi,StepResult:()=>rs,Transform:()=>Fs,TransformError:()=>Bs,canJoin:()=>bs,canSplit:()=>vs,dropPoint:()=>Ms,findWrapping:()=>gs,insertPoint:()=>Ss,joinPoint:()=>Cs,liftTarget:()=>ms,replaceStep:()=>Ns});var u={};n.r(u),n.d(u,{Decoration:()=>kd,DecorationSet:()=>xd,EditorView:()=>Jd,__endComposition:()=>Ud,__parseFromClipboard:()=>Kd});var d={};n.r(d),n.d(d,{$command:()=>Ep,$commandAsync:()=>Ip,$ctx:()=>Hp,$inputRule:()=>Dp,$inputRuleAsync:()=>Rp,$mark:()=>Pp,$markAsync:()=>$p,$markAttr:()=>Yp,$markSchema:()=>Kp,$node:()=>Lp,$nodeAsync:()=>zp,$nodeAttr:()=>Jp,$nodeSchema:()=>qp,$prose:()=>Bp,$proseAsync:()=>Fp,$remark:()=>Gp,$shortcut:()=>jp,$shortcutAsync:()=>_p,$useKeymap:()=>Up,$view:()=>Wp,$viewAsync:()=>Vp,addTimer:()=>Ap,callCommand:()=>Xp,forceUpdate:()=>Zp,getHTML:()=>Qp,getMarkdown:()=>ef,insert:()=>tf,nanoid:()=>Op,outline:()=>nf,pipe:()=>sf,replaceAll:()=>rf,setAttr:()=>of});var h={};n.r(h),n.d(h,{blockquoteAttr:()=>Yf,blockquoteKeymap:()=>Qf,blockquoteSchema:()=>Gf,bulletListAttr:()=>km,bulletListKeymap:()=>Cm,bulletListSchema:()=>vm,codeBlockAttr:()=>em,codeBlockKeymap:()=>im,codeBlockSchema:()=>tm,commands:()=>Wm,commonmark:()=>ng,createCodeBlockCommand:()=>rm,createCodeBlockInputRule:()=>nm,docSchema:()=>Lf,downgradeHeadingCommand:()=>Uf,emphasisAttr:()=>gf,emphasisKeymap:()=>bf,emphasisSchema:()=>yf,emphasisStarInputRule:()=>kf,emphasisUnderscoreInputRule:()=>vf,hardbreakAttr:()=>dm,hardbreakClearMarkPlugin:()=>Gm,hardbreakFilterNodes:()=>Xm,hardbreakFilterPlugin:()=>Zm,hardbreakKeymap:()=>fm,hardbreakSchema:()=>hm,headingAttr:()=>Vf,headingIdGenerator:()=>Wf,headingKeymap:()=>Jf,headingSchema:()=>Hf,hrAttr:()=>mm,hrSchema:()=>gm,htmlAttr:()=>zm,htmlSchema:()=>Bm,imageAttr:()=>sm,imageSchema:()=>lm,inlineCodeAttr:()=>Tf,inlineCodeInputRule:()=>Ef,inlineCodeKeymap:()=>If,inlineCodeSchema:()=>Of,inlineNodesCursorPlugin:()=>Ym,inputRules:()=>jm,insertHardbreakCommand:()=>pm,insertHrCommand:()=>wm,insertHrInputRule:()=>ym,insertImageCommand:()=>am,insertImageInputRule:()=>um,keymap:()=>Vm,liftFirstListItemCommand:()=>Pm,liftListItemCommand:()=>Dm,linkAttr:()=>Df,linkSchema:()=>Rf,listItemAttr:()=>Am,listItemKeymap:()=>$m,listItemSchema:()=>Em,markInputRules:()=>_m,orderedListAttr:()=>Sm,orderedListKeymap:()=>Om,orderedListSchema:()=>Mm,paragraphAttr:()=>zf,paragraphKeymap:()=>jf,paragraphSchema:()=>Bf,plugins:()=>tg,remarkAddOrderInListPlugin:()=>Hm,remarkHtmlTransformer:()=>Um,remarkInlineLinkPlugin:()=>Km,remarkLineBreak:()=>qm,remarkMarker:()=>Jm,schema:()=>Fm,sinkListItemCommand:()=>Im,splitListItemCommand:()=>Rm,strongAttr:()=>xf,strongInputRule:()=>Mf,strongKeymap:()=>Nf,strongSchema:()=>Cf,syncHeadingIdPlugin:()=>Qm,syncListOrderPlugin:()=>eg,textSchema:()=>Lm,toggleEmphasisCommand:()=>wf,toggleInlineCodeCommand:()=>Af,toggleLinkCommand:()=>Pf,toggleStrongCommand:()=>Sf,turnIntoTextCommand:()=>Ff,updateCodeBlockLanguageCommand:()=>om,updateImageCommand:()=>cm,updateLinkCommand:()=>$f,wrapInBlockquoteCommand:()=>Zf,wrapInBlockquoteInputRule:()=>Xf,wrapInBulletListCommand:()=>xm,wrapInBulletListInputRule:()=>bm,wrapInHeadingCommand:()=>Kf,wrapInHeadingInputRule:()=>qf,wrapInOrderedListCommand:()=>Tm,wrapInOrderedListInputRule:()=>Nm});var p={};n.r(p),n.d(p,{addColAfterCommand:()=>Ck,addColBeforeCommand:()=>xk,addRowAfterCommand:()=>Mk,addRowBeforeCommand:()=>Sk,addRowWithAlignment:()=>ek,autoInsertSpanPlugin:()=>Fk,columnResizingPlugin:()=>jk,commands:()=>Uk,createTable:()=>Jw,deleteSelectedCellsCommand:()=>bk,exitTable:()=>fk,extendListItemSchemaForTask:()=>Pk,findTable:()=>Yw,footnoteDefinitionSchema:()=>Ik,footnoteReferenceSchema:()=>Rk,getAllCellsInTable:()=>Zw,getCellsInCol:()=>Gw,getCellsInRow:()=>Xw,gfm:()=>Jk,goToNextTableCellCommand:()=>pk,goToPrevTableCellCommand:()=>hk,inputRules:()=>zk,insertTableCommand:()=>mk,insertTableInputRule:()=>Tk,keepTableAlignPlugin:()=>Hk,keymap:()=>Lk,markInputRules:()=>Bk,moveCol:()=>uk,moveColCommand:()=>yk,moveRow:()=>dk,moveRowCommand:()=>gk,plugins:()=>qk,remarkGFMPlugin:()=>Wk,schema:()=>Kk,selectCol:()=>rk,selectColCommand:()=>kk,selectLine:()=>tk,selectRow:()=>nk,selectRowCommand:()=>wk,selectTable:()=>Qw,selectTableCommand:()=>vk,setAlignCommand:()=>Nk,strikethroughAttr:()=>zw,strikethroughInputRule:()=>jw,strikethroughKeymap:()=>_w,strikethroughSchema:()=>Bw,tableCellSchema:()=>Kw,tableEditingPlugin:()=>_k,tableHeaderRowSchema:()=>Hw,tableHeaderSchema:()=>Uw,tableKeymap:()=>Ok,tableRowSchema:()=>qw,tableSchema:()=>Vw,toggleStrikethroughCommand:()=>Fw,wrapInTaskListInputRule:()=>$k});var f={};n.r(f),n.d(f,{Any:()=>vv,Error:()=>gv,Fragment:()=>tb,Mark:()=>Gv,ParseError:()=>wv,PropError:()=>yv,Ref:()=>Yk,c:()=>Ev,createContext:()=>db,createElement:()=>rb,createRef:()=>Gk,createType:()=>Ov,css:()=>Cb,h:()=>rb,html:()=>Tb,options:()=>Vv,render:()=>ob,template:()=>bb,useAbortController:()=>wb,useAsync:()=>vb,useCallback:()=>Fv,useContext:()=>ub,useEffect:()=>Rv,useEvent:()=>_v,useHook:()=>rv,useHost:()=>iv,useId:()=>lv,useInsertionEffect:()=>Pv,useLayoutEffect:()=>Dv,useMemo:()=>zv,usePromise:()=>yb,useProp:()=>jv,useProvider:()=>cb,useReducer:()=>Bv,useRef:()=>ov,useRefEffect:()=>kb,useState:()=>Lv,useSuspense:()=>gb,useUpdate:()=>sv});var m={};n.r(m),n.d(m,{IMAGE_DATA_TYPE:()=>Vb,defaultImageBlockConfig:()=>Ub,imageBlockComponent:()=>Zb,imageBlockConfig:()=>Jb,imageBlockSchema:()=>Hb,imageBlockView:()=>Xb,remarkImageBlockPlugin:()=>Kb});var g={};n.r(g),n.d(g,{defaultInlineImageConfig:()=>sx,imageInlineComponent:()=>ux,inlineImageConfig:()=>lx,inlineImageView:()=>cx});var y={};n.r(y),n.d(y,{TooltipProvider:()=>PC,tooltipFactory:()=>$C});var w={};n.r(w),n.d(w,{configureLinkTooltip:()=>XS,linkEditTooltip:()=>eS,linkPreviewTooltip:()=>QC,linkTooltipAPI:()=>XC,linkTooltipConfig:()=>ZC,linkTooltipPlugin:()=>ZS,linkTooltipState:()=>GC});var k={};n.r(k),n.d(k,{ListItemElement:()=>lM,defaultListItemBlockConfig:()=>aM,listItemBlockComponent:()=>dM,listItemBlockConfig:()=>cM,listItemBlockView:()=>uM,listItemComponent:()=>sM});var v={};n.r(v),n.d(v,{TableNodeView:()=>zM,tableBlock:()=>FM,tableBlockConfig:()=>SM,tableBlockView:()=>BM});var b={};n.r(b),n.d(b,{BlockProvider:()=>EN,BlockService:()=>fN,block:()=>IN,blockConfig:()=>UM,blockPlugin:()=>yN,blockService:()=>mN,blockSpec:()=>gN,defaultNodeFilter:()=>KM});var x={};n.r(x),n.d(x,{clipboard:()=>RN});var C={};n.r(C),n.d(C,{cursor:()=>KN,dropCursorConfig:()=>VN,dropCursorPlugin:()=>HN,gapCursorPlugin:()=>qN});var S={};n.r(S),n.d(S,{history:()=>wT,historyKeymap:()=>yT,historyProviderConfig:()=>mT,historyProviderPlugin:()=>gT,redoCommand:()=>fT,undoCommand:()=>pT});var M={};n.r(M),n.d(M,{indent:()=>bT,indentConfig:()=>kT,indentPlugin:()=>vT});var N={};n.r(N),n.d(N,{ListenerManager:()=>xT,key:()=>ST,listener:()=>MT,listenerCtx:()=>CT});var T={};n.r(T),n.d(T,{SlashProvider:()=>WT,slashFactory:()=>_T});var O={};n.r(O),n.d(O,{trailing:()=>qT,trailingConfig:()=>VT,trailingPlugin:()=>HT});var A={};n.r(A),n.d(A,{defaultUploader:()=>UT,readImageAsBase64:()=>KT,upload:()=>GT,uploadConfig:()=>JT,uploadPlugin:()=>YT});var E=(e=>(e.docTypeError="docTypeError",e.contextNotFound="contextNotFound",e.timerNotFound="timerNotFound",e.ctxCallOutOfScope="ctxCallOutOfScope",e.createNodeInParserFail="createNodeInParserFail",e.stackOverFlow="stackOverFlow",e.parserMatchError="parserMatchError",e.serializerMatchError="serializerMatchError",e.getAtomFromSchemaFail="getAtomFromSchemaFail",e.expectDomTypeError="expectDomTypeError",e.callCommandBeforeEditorView="callCommandBeforeEditorView",e.missingRootElement="missingRootElement",e.missingNodeInSchema="missingNodeInSchema",e.missingMarkInSchema="missingMarkInSchema",e.ctxNotBind="ctxNotBind",e.missingYjsDoc="missingYjsDoc",e))(E||{});class I extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}const D=(e,t)=>"function"==typeof t?"[Function]":t,R=e=>JSON.stringify(e,D);function P(e){return new I(E.docTypeError,`Doc type error, unsupported type: ${R(e)}`)}function $(){return new I(E.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function L(...e){const t=e.reduce(((e,t)=>{if(!t)return e;const n=e=>Array.isArray(e)?e.map((e=>n(e))).join(", "):e.toJSON?R(e.toJSON()):e.spec?R(e.spec):e.toString();return`${e}, ${n(t)}`}),"Create prosemirror node from remark failed in parser");return new I(E.createNodeInParserFail,t)}function z(){return new I(E.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function B(e){return new I(E.parserMatchError,`Cannot match target parser for node: ${R(e)}.`)}function F(e){return new I(E.serializerMatchError,`Cannot match target serializer for node: ${R(e)}.`)}function j(e,t){return new I(E.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}function _(e){return new I(E.expectDomTypeError,`Expect to be a dom, but get: ${R(e)}.`)}function W(){return new I(E.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function V(e){return new I(E.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function H(e){return new I(E.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}var q,K,U,J=e=>{throw TypeError(e)},Y=(e,t,n)=>t.has(e)||J("Cannot "+n),G=(e,t,n)=>(Y(e,t,"read from private field"),n?n.call(e):t.get(e)),X=(e,t,n)=>t.has(e)?J("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Z=(e,t,n,r)=>(Y(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Q{constructor(){this.sliceMap=new Map,this.get=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find((t=>t.type.name===e)):this.sliceMap.get(e.id);if(!t)throw function(e){return new I(E.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}("string"==typeof e?e:e.name);return t},this.remove=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find((t=>t.type.name===e)):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some((t=>t.type.name===e)):this.sliceMap.has(e.id)}}class ee{constructor(e,t,n){X(this,q),X(this,K),X(this,U),Z(this,q,[]),Z(this,U,(()=>{G(this,q).forEach((e=>e(G(this,K))))})),this.set=e=>{Z(this,K,e),G(this,U).call(this)},this.get=()=>G(this,K),this.update=e=>{Z(this,K,e(G(this,K))),G(this,U).call(this)},this.type=n,Z(this,K,t),e.set(n.id,this)}on(e){return G(this,q).push(e),()=>{Z(this,q,G(this,q).filter((t=>t!==e)))}}once(e){const t=this.on((n=>{e(n),t()}));return t}off(e){Z(this,q,G(this,q).filter((t=>t!==e)))}offAll(){Z(this,q,[])}}q=new WeakMap,K=new WeakMap,U=new WeakMap;class te{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw $()}}create(e,t=this._defaultValue){return new ee(e,t,this)}}const ne=(e,t)=>new te(e,t);var re,oe,ie,se,le,ae,ce,ue,de,he,pe,fe,me;class ge{constructor(e,t,n){X(this,re),X(this,oe),X(this,ie),X(this,se),X(this,le),X(this,ae),X(this,ce),X(this,ue),X(this,de),Z(this,se,new Set),Z(this,le,new Set),Z(this,ae,new Map),Z(this,ce,new Map),this.read=()=>({metadata:G(this,re),injectedSlices:[...G(this,se)].map((e=>({name:"string"==typeof e?e:e.name,value:G(this,ue).call(this,e)}))),consumedSlices:[...G(this,le)].map((e=>({name:"string"==typeof e?e:e.name,value:G(this,ue).call(this,e)}))),recordedTimers:[...G(this,ae)].map((([e,{duration:t}])=>({name:e.name,duration:t,status:G(this,de).call(this,e)}))),waitTimers:[...G(this,ce)].map((([e,{duration:t}])=>({name:e.name,duration:t,status:G(this,de).call(this,e)})))}),this.onRecord=e=>{G(this,ae).set(e,{start:Date.now(),duration:0})},this.onClear=e=>{G(this,ae).delete(e)},this.onDone=e=>{const t=G(this,ae).get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{const n=Date.now();t.finally((()=>{G(this,ce).set(e,{duration:Date.now()-n})}))},this.onInject=e=>{G(this,se).add(e)},this.onRemove=e=>{G(this,se).delete(e)},this.onUse=e=>{G(this,le).add(e)},Z(this,ue,(e=>G(this,oe).get(e).get())),Z(this,de,(e=>G(this,ie).get(e).status)),Z(this,oe,e),Z(this,ie,t),Z(this,re,n)}}re=new WeakMap,oe=new WeakMap,ie=new WeakMap,se=new WeakMap,le=new WeakMap,ae=new WeakMap,ce=new WeakMap,ue=new WeakMap,de=new WeakMap,he=new WeakMap,pe=new WeakMap,fe=new WeakMap,me=new WeakMap;let ye=class e{constructor(t,n,r){X(this,he),X(this,pe),X(this,fe),X(this,me),this.produce=t=>t&&Object.keys(t).length?new e(G(this,he),G(this,pe),{...t}):this,this.inject=(e,t)=>{var n;const r=e.create(G(this,he).sliceMap);return null!=t&&r.set(t),null==(n=G(this,me))||n.onInject(e),this},this.remove=e=>{var t;return G(this,he).remove(e),null==(t=G(this,me))||t.onRemove(e),this},this.record=e=>{var t;return e.create(G(this,pe).store),null==(t=G(this,me))||t.onRecord(e),this},this.clearTimer=e=>{var t;return G(this,pe).remove(e),null==(t=G(this,me))||t.onClear(e),this},this.isInjected=e=>G(this,he).has(e),this.isRecorded=e=>G(this,pe).has(e),this.use=e=>{var t;return null==(t=G(this,me))||t.onUse(e),G(this,he).get(e)},this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>G(this,pe).get(e),this.done=e=>{var t;this.timer(e).done(),null==(t=G(this,me))||t.onDone(e)},this.wait=e=>{var t;const n=this.timer(e).start();return null==(t=G(this,me))||t.onWait(e,n),n},this.waitTimers=async e=>{await Promise.all(this.get(e).map((e=>this.wait(e))))},Z(this,he,t),Z(this,pe,n),Z(this,fe,r),r&&Z(this,me,new ge(t,n,r))}get meta(){return G(this,fe)}get inspector(){return G(this,me)}};class we{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw function(e){return new I(E.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}}var ke,ve,be,xe,Ce,Se;class Me{constructor(e,t){X(this,ke),X(this,ve),X(this,be),X(this,xe),X(this,Ce),X(this,Se),Z(this,ke,null),Z(this,ve,null),Z(this,xe,"pending"),this.start=()=>(G(this,ke)??Z(this,ke,new Promise(((e,t)=>{Z(this,ve,(t=>{t instanceof CustomEvent&&t.detail.id===G(this,be)&&(Z(this,xe,"resolved"),G(this,Ce).call(this),t.stopImmediatePropagation(),e())})),G(this,Se).call(this,(()=>{"pending"===G(this,xe)&&Z(this,xe,"rejected"),G(this,Ce).call(this),t(new Error(`Timing ${this.type.name} timeout.`))})),Z(this,xe,"pending"),addEventListener(this.type.name,G(this,ve))}))),G(this,ke)),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:G(this,be)}});dispatchEvent(e)},Z(this,Ce,(()=>{G(this,ve)&&removeEventListener(this.type.name,G(this,ve))})),Z(this,Se,(e=>{setTimeout((()=>{e()}),this.type.timeout)})),Z(this,be,Symbol(t.name)),this.type=t,e.set(t.id,this)}get status(){return G(this,xe)}}ke=new WeakMap,ve=new WeakMap,be=new WeakMap,xe=new WeakMap,Ce=new WeakMap,Se=new WeakMap;class Ne{constructor(e,t=3e3){this.create=e=>new Me(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}}const Te=(e,t=3e3)=>new Ne(e,t);function Oe(e){this.content=e}Oe.prototype={constructor:Oe,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new Oe(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Oe(n)},addToStart:function(e,t){return new Oe([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Oe(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new Oe(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Oe.from(e)).size?new Oe(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Oe.from(e)).size?new Oe(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Oe.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},Oe.from=function(e){if(e instanceof Oe)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Oe(t)};const Ae=Oe;function Ee(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let e=0;o.text[e]==i.text[e];e++)n++;return n}if(o.content.size||i.content.size){let e=Ee(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function Ie(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),l=t.child(--i),a=s.nodeSize;if(s!=l){if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let e=0,t=Math.min(s.text.length,l.text.length);for(;e<t&&s.text[s.text.length-e-1]==l.text[l.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let e=Ie(s.content,l.content,n-1,r-1);if(e)return e}n-=a,r-=a}else n-=a,r-=a}}class De{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,o){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,r+s,o||null,i)&&l.content.size){let o=s+1;l.nodesBetween(Math.max(0,e-o),Math.min(l.content.size,t-o),n,r+o)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,((s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=a}),0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new De(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,i=0;i<t;o++){let s=this.content[o],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),r+=s.nodeSize),i=l}return new De(n,r)}cutByIndex(e,t){return e==t?De.empty:0==e&&t==this.content.length?this:new De(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new De(r,o)}addToStart(e){return new De([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new De(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ee(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ie(this,e,t,n)}findIndex(e,t=-1){if(0==e)return Pe(0,e);if(e==this.size)return Pe(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?Pe(n+1,o):Pe(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return De.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new De(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return De.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new De(t||e,n)}static from(e){if(!e)return De.empty;if(e instanceof De)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new De([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}De.empty=new De([],0);const Re={index:0,offset:0};function Pe(e,t){return Re.index=e,Re.offset=t,Re}function $e(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!$e(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!$e(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Le{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&$e(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Le.none;if(e instanceof Le)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}Le.none=[];class ze extends Error{}class Be{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=je(this.content,e+this.openStart,t);return n&&new Be(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Be(Fe(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Be.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Be(De.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Be(e,n,r)}}function Fe(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:l}=e.findIndex(n);if(o==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Fe(i.content,t-o-1,n-o-1)))}function je(e,t,n,r){let{index:o,offset:i}=e.findIndex(t),s=e.maybeChild(o);if(i==t||s.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=je(s.content,t-i-1,n);return l&&e.replaceChild(o,s.copy(l))}function _e(e,t,n){if(n.openStart>e.depth)throw new ze("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ze("Inconsistent open depths");return We(e,t,n,0)}function We(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=We(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(De.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return Ue(i,Je(e,o,s,t,r))}{let r=e.parent,o=r.content;return Ue(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return Ue(i,Ye(e,t,r))}function Ve(e,t){if(!t.type.compatibleContent(e.type))throw new ze("Cannot join "+t.type.name+" onto "+e.type.name)}function He(e,t,n){let r=e.node(n);return Ve(r,t.node(n)),r}function qe(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ke(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(qe(e.nodeAfter,r),i++));for(let e=i;e<s;e++)qe(o.child(e),r);t&&t.depth==n&&t.textOffset&&qe(t.nodeBefore,r)}function Ue(e,t){return e.type.checkContent(t),e.copy(t)}function Je(e,t,n,r,o){let i=e.depth>o&&He(e,t,o+1),s=r.depth>o&&He(n,r,o+1),l=[];return Ke(null,e,o,l),i&&s&&t.index(o)==n.index(o)?(Ve(i,s),qe(Ue(i,Je(e,t,n,r,o+1)),l)):(i&&qe(Ue(i,Ye(e,t,o+1)),l),Ke(t,n,o,l),s&&qe(Ue(s,Ye(n,r,o+1)),l)),Ke(r,null,o,l),new De(l)}function Ye(e,t,n){let r=[];return Ke(null,e,n,r),e.depth>n&&qe(Ue(He(e,t,n+1),Ye(e,t,n+1)),r),Ke(t,null,n,r),new De(r)}Be.empty=new Be(De.empty,0,0);class Ge{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Le.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new et(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new Ge(t,n,o)}static resolveCached(e,t){let n=Qe.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else Qe.set(e,n=new Xe);let r=n.elts[n.i]=Ge.resolve(e,t);return n.i=(n.i+1)%Ze,r}}class Xe{constructor(){this.elts=[],this.i=0}}const Ze=12,Qe=new WeakMap;class et{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const tt=Object.create(null);class nt{constructor(e,t,n,r=Le.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||De.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&$e(this.attrs,t||e.defaultAttrs||tt)&&Le.sameSet(this.marks,n||Le.none)}copy(e=null){return e==this.content?this:new nt(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new nt(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Be.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),l=r.node(i).content.cut(r.pos-s,o.pos-s);return new Be(l,r.depth-i,o.depth-i)}replace(e,t,n){return _e(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ge.resolveCached(this,e)}resolveNoCache(e){return Ge.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ot(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=De.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Le.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=De.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,r,n);return o.type.checkAttrs(o.attrs),o}}nt.prototype.text=void 0;class rt extends nt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ot(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new rt(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new rt(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ot(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class it{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new st(e,t);if(null==n.next)return it.empty;let r=lt(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return function n(r){let o=[];r.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);pt(e,n).forEach((e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)}))}))}));let i=t[r.join(",")]=new it(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(ht);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}(pt(e,0))}(function(e){let t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(e(n,i))),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(i,s),o(e(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(e(t.expr,i),s),o(e(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){let s=i;for(let r=0;r<t.min;r++){let r=n();o(e(t.expr,s),r),s=r}if(-1==t.max)o(e(t.expr,s),s);else for(let i=t.min;i<t.max;i++){let i=n();r(s,i),o(e(t.expr,s),i),s=i}return[r(s)]}if("name"==t.type)return[r(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=e(t.exprs[r],i);if(r==t.exprs.length-1)return s;o(s,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach((e=>e.to=t))}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function o(i,s){let l=i.matchFragment(e,n);if(l&&(!t||l.validEnd))return De.from(s.map((e=>e.createAndFill())));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=o(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r})).join("\n")}}it.empty=new it(!0);class st{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function lt(e){let t=[];do{t.push(at(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function at(e){let t=[];do{t.push(ct(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function ct(e){let t=function(e){if(e.eat("(")){let t=lt(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}return 0==o.length&&e.err("No node type or group '"+t+"' found"),o}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=dt(e,t)}return t}function ut(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function dt(e,t){let n=ut(e),r=n;return e.eat(",")&&(r="}"!=e.next?ut(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function ht(e,t){return t-e}function pt(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(ht)}function ft(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function mt(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function gt(e,t,n,r){for(let r in t)if(!(r in e))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function yt(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new kt(e,r,t[r]);return n}class wt{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=yt(e,n.attrs),this.defaultAttrs=ft(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==it.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}comp