@omegagrid/milkdown-kit 0.4.20 → 0.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- 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:()=>GT,core:()=>s,ctx:()=>e,plugins:()=>XT,presets:()=>YT,prose:()=>ZT,transformer:()=>o,utils:()=>d});var e={};n.r(e),n.d(e,{Clock:()=>ye,Container:()=>Z,Ctx:()=>ge,Inspector:()=>me,Slice:()=>Q,SliceType:()=>ee,Timer:()=>Se,TimerType:()=>Me,createSlice:()=>te,createTimer:()=>Ne});var t={};n.r(t),n.d(t,{attentionMarkers:()=>vr,contentInitial:()=>fr,disable:()=>br,document:()=>pr,flow:()=>gr,flowInitial:()=>mr,insideSpan:()=>kr,string:()=>yr,text:()=>wr});var o={};n.r(o),n.d(o,{ParserState:()=>Ei,SerializerState:()=>Ui,Stack:()=>Ti,StackElement:()=>Ni});var i={};n.r(i),n.d(i,{browser:()=>Rl,calculateNodePosition:()=>Ul,calculateTextPosition:()=>Jl,cloneTr:()=>Xl,customInputRules:()=>$l,customInputRulesKey:()=>Pl,equalNodeType:()=>Zl,findChildren:()=>ea,findChildrenByMark:()=>ta,findParent:()=>na,findParentNode:()=>la,findParentNodeClosestToPos:()=>sa,findParentNodeType:()=>ra,findSelectedNodeOfType:()=>aa,flatten:()=>Ql,getMarkFromSchema:()=>ia,getNodeFromSchema:()=>oa,markRule:()=>Ll,nodeRule:()=>Bl,posToDOMRect:()=>Gl});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:()=>Bh,SchemaReady:()=>xh,SerializerReady:()=>Wh,commands:()=>Lh,commandsCtx:()=>Dh,commandsTimerCtx:()=>Ph,config:()=>kh,createCmdKey:()=>Rh,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:()=>Js,EditorState:()=>rl,NodeSelection:()=>Ks,Plugin:()=>il,PluginKey:()=>al,Selection:()=>js,SelectionRange:()=>_s,TextSelection:()=>Hs,Transaction:()=>Zs});var a={};n.r(a),n.d(a,{ContentMatch:()=>ot,DOMParser:()=>xt,DOMSerializer:()=>Rt,Fragment:()=>Ie,Mark:()=>$e,MarkType:()=>kt,Node:()=>tt,NodeRange:()=>Qe,NodeType:()=>yt,ReplaceError:()=>Le,ResolvedPos:()=>Ye,Schema:()=>vt,Slice:()=>Be});var c={};n.r(c),n.d(c,{AddMarkStep:()=>is,AddNodeMarkStep:()=>ls,AttrStep:()=>$s,DocAttrStep:()=>Ls,MapResult:()=>Xi,Mapping:()=>Qi,RemoveMarkStep:()=>ss,RemoveNodeMarkStep:()=>as,ReplaceAroundStep:()=>us,ReplaceStep:()=>cs,Step:()=>ts,StepMap:()=>Zi,StepResult:()=>ns,Transform:()=>zs,TransformError:()=>Bs,canJoin:()=>vs,canSplit:()=>ks,dropPoint:()=>Ss,findWrapping:()=>ms,insertPoint:()=>Cs,joinPoint:()=>xs,liftTarget:()=>fs,replaceStep:()=>Ms});var u={};n.r(u),n.d(u,{Decoration:()=>wd,DecorationSet:()=>bd,EditorView:()=>Jd,__endComposition:()=>Ud,__parseFromClipboard:()=>Kd,__serializeForClipboard:()=>qd});var d={};n.r(d),n.d(d,{$command:()=>Ep,$commandAsync:()=>Ip,$ctx:()=>Hp,$inputRule:()=>Rp,$inputRuleAsync:()=>Dp,$mark:()=>Pp,$markAsync:()=>$p,$markAttr:()=>Yp,$markSchema:()=>Kp,$node:()=>Lp,$nodeAsync:()=>Bp,$nodeAttr:()=>Jp,$nodeSchema:()=>qp,$prose:()=>zp,$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:()=>Bm,htmlSchema:()=>zm,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:()=>Rm,linkAttr:()=>Rf,linkSchema:()=>Df,listItemAttr:()=>Am,listItemKeymap:()=>$m,listItemSchema:()=>Em,markInputRules:()=>_m,orderedListAttr:()=>Sm,orderedListKeymap:()=>Om,orderedListSchema:()=>Mm,paragraphAttr:()=>Bf,paragraphKeymap:()=>jf,paragraphSchema:()=>zf,plugins:()=>tg,remarkAddOrderInListPlugin:()=>Hm,remarkHtmlTransformer:()=>Um,remarkInlineLinkPlugin:()=>Km,remarkLineBreak:()=>qm,remarkMarker:()=>Jm,schema:()=>Fm,sinkListItemCommand:()=>Im,splitListItemCommand:()=>Dm,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:()=>Dk,getAllCellsInTable:()=>Zw,getCellsInCol:()=>Gw,getCellsInRow:()=>Xw,gfm:()=>Jk,goToNextTableCellCommand:()=>pk,goToPrevTableCellCommand:()=>hk,inputRules:()=>Bk,insertTableCommand:()=>mk,insertTableInputRule:()=>Tk,keepTableAlignPlugin:()=>Hk,keymap:()=>Lk,markInputRules:()=>zk,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:()=>Bw,strikethroughInputRule:()=>jw,strikethroughKeymap:()=>_w,strikethroughSchema:()=>zw,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:()=>Dv,useEvent:()=>_v,useHook:()=>rv,useHost:()=>iv,useId:()=>lv,useInsertionEffect:()=>Pv,useLayoutEffect:()=>Rv,useMemo:()=>Bv,usePromise:()=>yb,useProp:()=>jv,useProvider:()=>cb,useReducer:()=>zv,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:()=>GS,linkEditTooltip:()=>QC,linkPreviewTooltip:()=>ZC,linkTooltipAPI:()=>GC,linkTooltipConfig:()=>XC,linkTooltipPlugin:()=>XS,linkTooltipState:()=>YC});var k={};n.r(k),n.d(k,{ListItemElement:()=>sM,defaultListItemBlockConfig:()=>lM,listItemBlockComponent:()=>uM,listItemBlockConfig:()=>aM,listItemBlockView:()=>cM,listItemComponent:()=>iM});var v={};n.r(v),n.d(v,{TableNodeView:()=>BM,tableBlock:()=>FM,tableBlockConfig:()=>SM,tableBlockView:()=>zM});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,{cursor:()=>HN,dropCursorConfig:()=>_N,dropCursorPlugin:()=>WN,gapCursorPlugin:()=>VN});var C={};n.r(C),n.d(C,{history:()=>gT,historyKeymap:()=>mT,historyProviderConfig:()=>pT,historyProviderPlugin:()=>fT,redoCommand:()=>hT,undoCommand:()=>dT});var S={};n.r(S),n.d(S,{indent:()=>kT,indentConfig:()=>yT,indentPlugin:()=>wT});var M={};n.r(M),n.d(M,{ListenerManager:()=>vT,key:()=>xT,listener:()=>CT,listenerCtx:()=>bT});var N={};n.r(N),n.d(N,{SlashProvider:()=>jT,slashFactory:()=>FT});var T={};n.r(T),n.d(T,{trailing:()=>VT,trailingConfig:()=>_T,trailingPlugin:()=>WT});var O={};n.r(O),n.d(O,{defaultUploader:()=>qT,readImageAsBase64:()=>HT,upload:()=>JT,uploadConfig:()=>KT,uploadPlugin:()=>UT});var A=(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))(A||{});class E extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}const I=(e,t)=>"function"==typeof t?"[Function]":t,R=e=>JSON.stringify(e,I);function D(e){return new E(A.docTypeError,`Doc type error, unsupported type: ${R(e)}`)}function P(){return new E(A.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function $(...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 E(A.createNodeInParserFail,t)}function L(){return new E(A.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function B(e){return new E(A.parserMatchError,`Cannot match target parser for node: ${R(e)}.`)}function z(e){return new E(A.serializerMatchError,`Cannot match target serializer for node: ${R(e)}.`)}function F(e,t){return new E(A.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}function j(e){return new E(A.expectDomTypeError,`Expect to be a dom, but get: ${R(e)}.`)}function _(){return new E(A.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 W(e){return new E(A.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function V(e){return new E(A.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}var H,q,K,U=e=>{throw TypeError(e)},J=(e,t,n)=>t.has(e)||U("Cannot "+n),Y=(e,t,n)=>(J(e,t,"read from private field"),n?n.call(e):t.get(e)),G=(e,t,n)=>t.has(e)?U("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),X=(e,t,n,r)=>(J(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Z{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 E(A.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 Q{constructor(e,t,n){G(this,H),G(this,q),G(this,K),X(this,H,[]),X(this,K,(()=>{Y(this,H).forEach((e=>e(Y(this,q))))})),this.set=e=>{X(this,q,e),Y(this,K).call(this)},this.get=()=>Y(this,q),this.update=e=>{X(this,q,e(Y(this,q))),Y(this,K).call(this)},this.type=n,X(this,q,t),e.set(n.id,this)}on(e){return Y(this,H).push(e),()=>{X(this,H,Y(this,H).filter((t=>t!==e)))}}once(e){const t=this.on((n=>{e(n),t()}));return t}off(e){X(this,H,Y(this,H).filter((t=>t!==e)))}offAll(){X(this,H,[])}}H=new WeakMap,q=new WeakMap,K=new WeakMap;class ee{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw P()}}create(e,t=this._defaultValue){return new Q(e,t,this)}}const te=(e,t)=>new ee(e,t);var ne,re,oe,ie,se,le,ae,ce,ue,de,he,pe,fe;class me{constructor(e,t,n){G(this,ne),G(this,re),G(this,oe),G(this,ie),G(this,se),G(this,le),G(this,ae),G(this,ce),G(this,ue),X(this,ie,new Set),X(this,se,new Set),X(this,le,new Map),X(this,ae,new Map),this.read=()=>({metadata:Y(this,ne),injectedSlices:[...Y(this,ie)].map((e=>({name:"string"==typeof e?e:e.name,value:Y(this,ce).call(this,e)}))),consumedSlices:[...Y(this,se)].map((e=>({name:"string"==typeof e?e:e.name,value:Y(this,ce).call(this,e)}))),recordedTimers:[...Y(this,le)].map((([e,{duration:t}])=>({name:e.name,duration:t,status:Y(this,ue).call(this,e)}))),waitTimers:[...Y(this,ae)].map((([e,{duration:t}])=>({name:e.name,duration:t,status:Y(this,ue).call(this,e)})))}),this.onRecord=e=>{Y(this,le).set(e,{start:Date.now(),duration:0})},this.onClear=e=>{Y(this,le).delete(e)},this.onDone=e=>{const t=Y(this,le).get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{const n=Date.now();t.finally((()=>{Y(this,ae).set(e,{duration:Date.now()-n})}))},this.onInject=e=>{Y(this,ie).add(e)},this.onRemove=e=>{Y(this,ie).delete(e)},this.onUse=e=>{Y(this,se).add(e)},X(this,ce,(e=>Y(this,re).get(e).get())),X(this,ue,(e=>Y(this,oe).get(e).status)),X(this,re,e),X(this,oe,t),X(this,ne,n)}}ne=new WeakMap,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;let ge=class e{constructor(t,n,r){G(this,de),G(this,he),G(this,pe),G(this,fe),this.produce=t=>t&&Object.keys(t).length?new e(Y(this,de),Y(this,he),{...t}):this,this.inject=(e,t)=>{var n;const r=e.create(Y(this,de).sliceMap);return null!=t&&r.set(t),null==(n=Y(this,fe))||n.onInject(e),this},this.remove=e=>{var t;return Y(this,de).remove(e),null==(t=Y(this,fe))||t.onRemove(e),this},this.record=e=>{var t;return e.create(Y(this,he).store),null==(t=Y(this,fe))||t.onRecord(e),this},this.clearTimer=e=>{var t;return Y(this,he).remove(e),null==(t=Y(this,fe))||t.onClear(e),this},this.isInjected=e=>Y(this,de).has(e),this.isRecorded=e=>Y(this,he).has(e),this.use=e=>{var t;return null==(t=Y(this,fe))||t.onUse(e),Y(this,de).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=>Y(this,he).get(e),this.done=e=>{var t;this.timer(e).done(),null==(t=Y(this,fe))||t.onDone(e)},this.wait=e=>{var t;const n=this.timer(e).start();return null==(t=Y(this,fe))||t.onWait(e,n),n},this.waitTimers=async e=>{await Promise.all(this.get(e).map((e=>this.wait(e))))},X(this,de,t),X(this,he,n),X(this,pe,r),r&&X(this,fe,new me(t,n,r))}get meta(){return Y(this,pe)}get inspector(){return Y(this,fe)}};class ye{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw function(e){return new E(A.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 we,ke,ve,be,xe,Ce;class Se{constructor(e,t){G(this,we),G(this,ke),G(this,ve),G(this,be),G(this,xe),G(this,Ce),X(this,we,null),X(this,ke,null),X(this,be,"pending"),this.start=()=>(Y(this,we)??X(this,we,new Promise(((e,t)=>{X(this,ke,(t=>{t instanceof CustomEvent&&t.detail.id===Y(this,ve)&&(X(this,be,"resolved"),Y(this,xe).call(this),t.stopImmediatePropagation(),e())})),Y(this,Ce).call(this,(()=>{"pending"===Y(this,be)&&X(this,be,"rejected"),Y(this,xe).call(this),t(new Error(`Timing ${this.type.name} timeout.`))})),X(this,be,"pending"),addEventListener(this.type.name,Y(this,ke))}))),Y(this,we)),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:Y(this,ve)}});dispatchEvent(e)},X(this,xe,(()=>{Y(this,ke)&&removeEventListener(this.type.name,Y(this,ke))})),X(this,Ce,(e=>{setTimeout((()=>{e()}),this.type.timeout)})),X(this,ve,Symbol(t.name)),this.type=t,e.set(t.id,this)}get status(){return Y(this,be)}}we=new WeakMap,ke=new WeakMap,ve=new WeakMap,be=new WeakMap,xe=new WeakMap,Ce=new WeakMap;class Me{constructor(e,t=3e3){this.create=e=>new Se(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}}const Ne=(e,t=3e3)=>new Me(e,t);function Te(e){this.content=e}Te.prototype={constructor:Te,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 Te(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 Te(n)},addToStart:function(e,t){return new Te([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Te(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 Te(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=Te.from(e)).size?new Te(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Te.from(e)).size?new Te(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Te.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}},Te.from=function(e){if(e instanceof Te)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Te(t)};const Oe=Te;function Ae(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=Ae(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function Ee(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=Ee(s.content,l.content,n-1,r-1);if(e)return e}n-=a,r-=a}else n-=a,r-=a}}class Ie{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 Ie(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 Ie(n,r)}cutByIndex(e,t){return e==t?Ie.empty:0==e&&t==this.content.length?this:new Ie(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 Ie(r,o)}addToStart(e){return new Ie([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ie(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 Ae(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ee(this,e,t,n)}findIndex(e,t=-1){if(0==e)return De(0,e);if(e==this.size)return De(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?De(n+1,o):De(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 Ie.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ie(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ie.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 Ie(t||e,n)}static from(e){if(!e)return Ie.empty;if(e instanceof Ie)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Ie([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Ie.empty=new Ie([],0);const Re={index:0,offset:0};function De(e,t){return Re.index=e,Re.offset=t,Re}function Pe(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(!Pe(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Pe(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class $e{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&&Pe(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 $e.none;if(e instanceof $e)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}$e.none=[];class Le 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=Fe(this.content,e+this.openStart,t);return n&&new Be(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Be(ze(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(Ie.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 ze(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(ze(i.content,t-o-1,n-o-1)))}function Fe(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=Fe(s.content,t-i-1,n);return l&&e.replaceChild(o,s.copy(l))}function je(e,t,n){if(n.openStart>e.depth)throw new Le("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Le("Inconsistent open depths");return _e(e,t,n,0)}function _e(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=_e(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(Ie.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return Ke(i,Ue(e,o,s,t,r))}{let r=e.parent,o=r.content;return Ke(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return Ke(i,Je(e,t,r))}function We(e,t){if(!t.type.compatibleContent(e.type))throw new Le("Cannot join "+t.type.name+" onto "+e.type.name)}function Ve(e,t,n){let r=e.node(n);return We(r,t.node(n)),r}function He(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 qe(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&&(He(e.nodeAfter,r),i++));for(let e=i;e<s;e++)He(o.child(e),r);t&&t.depth==n&&t.textOffset&&He(t.nodeBefore,r)}function Ke(e,t){return e.type.checkContent(t),e.copy(t)}function Ue(e,t,n,r,o){let i=e.depth>o&&Ve(e,t,o+1),s=r.depth>o&&Ve(n,r,o+1),l=[];return qe(null,e,o,l),i&&s&&t.index(o)==n.index(o)?(We(i,s),He(Ke(i,Ue(e,t,n,r,o+1)),l)):(i&&He(Ke(i,Je(e,t,o+1)),l),qe(t,n,o,l),s&&He(Ke(s,Je(n,r,o+1)),l)),qe(r,null,o,l),new Ie(l)}function Je(e,t,n){let r=[];return qe(null,e,n,r),e.depth>n&&He(Ke(Ve(e,t,n+1),Je(e,t,n+1)),r),qe(t,null,n,r),new Ie(r)}Be.empty=new Be(Ie.empty,0,0);class Ye{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 $e.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 Qe(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 Ye(t,n,o)}static resolveCached(e,t){let n=Ze.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 Ze.set(e,n=new Ge);let r=n.elts[n.i]=Ye.resolve(e,t);return n.i=(n.i+1)%Xe,r}}class Ge{constructor(){this.elts=[],this.i=0}}const Xe=12,Ze=new WeakMap;class Qe{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 et=Object.create(null);class tt{constructor(e,t,n,r=$e.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Ie.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&&Pe(this.attrs,t||e.defaultAttrs||et)&&$e.sameSet(this.marks,n||$e.none)}copy(e=null){return e==this.content?this:new tt(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new tt(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 je(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 Ye.resolveCached(this,e)}resolveNoCache(e){return Ye.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()+")"),rt(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=Ie.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=$e.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(!$e.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=Ie.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,r,n);return o.type.checkAttrs(o.attrs),o}}tt.prototype.text=void 0;class nt extends tt{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):rt(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 nt(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new nt(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 rt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ot{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new it(e,t);if(null==n.next)return ot.empty;let r=st(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]);ht(e,n).forEach((e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)}))}))}));let i=t[r.join(",")]=new ot(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(dt);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}(ht(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 Ie.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")}}ot.empty=new ot(!0);class it{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 st(e){let t=[];do{t.push(lt(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function lt(e){let t=[];do{t.push(at(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function at(e){let t=function(e){if(e.eat("(")){let t=st(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=ut(e,t)}return t}function ct(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function ut(e,t){let n=ct(e),r=n;return e.eat(",")&&(r="}"!=e.next?ct(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function dt(e,t){return t-e}function ht(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(dt)}function pt(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 ft(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 mt(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 gt(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new wt(e,r,t[r]);return n}class yt{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=gt(e,n.attrs),this.defaultAttrs=pt(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==ot.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}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ft(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new tt(this,this.computeAttrs(e),Ie.from(t),$e.setFrom(n))}createChecked(e=null,t,n){return t=Ie.from(t),this.checkContent(t),new tt(this,this.computeAttrs(e),t,$e.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Ie.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(Ie.empty,!0);return o?new tt(this,e,t.append(o),$e.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){mt(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:$e.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,r)=>n[e]=new yt(e,t,r)));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class wt{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class kt{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=gt(e,r.attrs),this.excluded=null;let o=pt(this.attrs);this.instance=o?new $e(this,o):null}create(e=null){return!e&&this.instance?this.instance:new $e(this,ft(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach(((e,o)=>n[e]=new kt(e,r++,t,o))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){mt(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class vt{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=Oe.from(e.nodes),t.marks=Oe.from(e.marks||{}),this.nodes=yt.compile(this.spec.nodes,this),this.marks=kt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=ot.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?bt(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:bt(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof yt))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new nt(n,n.defaultAttrs,e,$e.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return tt.fromJSON(this,e)}markFromJSON(e){return $e.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function bt(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class xt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new Ot(this,t,!1);return n.addAll(e,$e.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Ot(this,t,!0);return n.addAll(e,$e.none,t.from,t.to),Be.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(At(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Et(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Et(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new xt(e,xt.schemaRules(e)))}}const Ct={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},St={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Mt={ol:!0,ul:!0};function Nt(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class Tt{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=$e.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Ie.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Ie.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Ie.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ct.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ot{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=Nt(null,t.preserveWhitespace,0)|(n?4:0);r=o?new Tt(o.type,o.attrs,$e.none,!0,t.topMatch||o.type.contentMatch,i):new Tt(n?null:e.schema.topNodeType,null,$e.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)n="full"!==o?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Mt.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Mt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:St.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(Ct.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter((e=>!n.clearMark(e))):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(o=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,n)));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t){let n,r;for(let t=this.open;t>=0;t--){let o=this.nodes[t],i=o.findWrapping(e);if(i&&(!n||n.length>i.length)&&(n=i,r=o,!i.length))break;if(o.solid)break}if(!n)return null;this.sync(r);for(let e=0;e<n.length;e++)t=this.enterInner(n[e],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let n=this.findPlace(e,t);if(n){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let r=$e.none;for(let o of n.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):It(o.type,e.type))&&(r=o.addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=Nt(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=$e.none;return n=n.filter((t=>!(i.type?i.type.allowsMarkType(t.type):It(t.type,e))||(l=t.addToSet(l),!1))),this.nodes.push(new Tt(e,t,l,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function At(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Et(e){let t={};for(let n in e)t[n]=e[n];return t}function It(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class Rt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Pt(t).createDocumentFragment());let r=n,o=[];return e.forEach((e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Lt(Pt(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Lt(Pt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Lt(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Rt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Dt(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Dt(e.marks)}}function Dt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Pt(e){return e.document||window.document}const $t=new WeakMap;function Lt(e,t,n,r){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=function(e){let t=$t.get(e);return void 0===t&&$t.set(e,t=function(e){let t=null;return function e(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])t||(t=[]),t.push(n);else for(let t=0;t<n.length;t++)e(n[t]);else for(let t in n)e(n[t])}(e),t}(e)),t}(r))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],u=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){u=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):a.setAttribute(e,c[e])}}for(let o=u;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:o}=Lt(e,i,n,r);if(a.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:a,contentDOM:s}}const Bt={};function zt(e,t){const n=t||Bt;return Ft(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function Ft(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return jt(e.children,t,n)}return Array.isArray(e)?jt(e,t,n):""}function jt(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=Ft(e[o],t,n);return r.join("")}function _t(e,t,n,r){const o=e.length;let i,s=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);s<r.length;)i=r.slice(s,s+1e4),i.unshift(t,0),e.splice(...i),s+=1e4,t+=1e4}function Wt(e,t){return e.length>0?(_t(e,e.length,0,t),e):t}class Vt{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const r=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&Ht(this.left,n),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Ht(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Ht(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);Ht(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Ht(this.left,t.reverse())}}}function Ht(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function qt(e){const t={};let n,r,o,i,s,l,a,c=-1;const u=new Vt(e);for(;++c<u.length;){for(;c in t;)c=t[c];if(n=u.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&(l=n[1]._tokenizer.events,o=0,o<l.length&&"lineEndingBlank"===l[o][1].type&&(o+=2),o<l.length&&"content"===l[o][1].type))for(;++o<l.length&&"content"!==l[o][1].type;)"chunkText"===l[o][1].type&&(l[o][1]._isInFirstContentOfListItem=!0,o++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,Kt(u,c)),c=t[c],a=!0);else if(n[1]._container){for(o=c,r=void 0;o--&&(i=u.get(o),"lineEnding"===i[1].type||"lineEndingBlank"===i[1].type);)"enter"===i[0]&&(r&&(u.get(r)[1].type="lineEndingBlank"),i[1].type="lineEnding",r=o);r&&(n[1].end={...u.get(r)[1].start},s=u.slice(r,c),s.unshift(n),u.splice(r,c-r+1,s))}}return _t(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!a}function Kt(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const i=[],s=n._tokenizer||r.parser[n.contentType](n.start),l=s.events,a=[],c={};let u,d,h=-1,p=n,f=0,m=0;const g=[m];for(;p;){for(;e.get(++o)[1]!==p;);i.push(o),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<l.length;)"exit"===l[h][0]&&"enter"===l[h-1][0]&&l[h][1].type===l[h-1][1].type&&l[h][1].start.line!==l[h][1].end.line&&(m=h+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),h=g.length;h--;){const t=l.slice(g[h],g[h+1]),n=i.pop();a.push([n,n+t.length-1]),e.splice(n,2,t)}for(a.reverse(),h=-1;++h<a.length;)c[f+a[h][0]]=f+a[h][1],f+=a[h][1]-a[h][0]-1;return c}const Ut={}.hasOwnProperty;function Jt(e){const t={};let n=-1;for(;++n<e.length;)Yt(t,e[n]);return t}function Yt(e,t){let n;for(n in t){const r=(Ut.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let i;if(o)for(i in o){Ut.call(r,i)||(r[i]=[]);const e=o[i];Gt(r[i],Array.isArray(e)?e:e?[e]:[])}}}function Gt(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);_t(e,0,0,r)}const Xt=un(/[A-Za-z]/),Zt=un(/[\dA-Za-z]/),Qt=un(/[#-'*+\--9=?A-Z^-~]/);function en(e){return null!==e&&(e<32||127===e)}const tn=un(/\d/),nn=un(/[\dA-Fa-f]/),rn=un(/[!-/:-@[-`{-~]/);function on(e){return null!==e&&e<-2}function sn(e){return null!==e&&(e<0||32===e)}function ln(e){return-2===e||-1===e||32===e}const an=un(/\p{P}|\p{S}/u),cn=un(/\s/);function un(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function dn(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let i=0;return function(r){return ln(r)?(e.enter(n),s(r)):t(r)};function s(r){return ln(r)&&i++<o?(e.consume(r),s):(e.exit(n),t(r))}}const hn={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,(function(n){if(null!==n)return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),dn(e,t,"linePrefix");e.consume(n)}),(function(t){return e.enter("paragraph"),r(t)}));let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):on(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),o)}}},pn={tokenize:function(e){const t=this,n=[];let r,o,i,s=0;return l;function l(r){if(s<n.length){const o=n[s];return t.containerState=o[1],e.attempt(o[0].continuation,a,c)(r)}return c(r)}function a(e){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&w();const n=t.events.length;let o,i=n;for(;i--;)if("exit"===t.events[i][0]&&"chunkFlow"===t.events[i][1].type){o=t.events[i][1].end;break}y(s);let l=n;for(;l<t.events.length;)t.events[l][1].end={...o},l++;return _t(t.events,i+1,0,t.events.slice(n)),t.events.length=l,c(e)}return l(e)}function c(o){if(s===n.length){if(!r)return h(o);if(r.currentConstruct&&r.currentConstruct.concrete)return f(o);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fn,u,d)(o)}function u(e){return r&&w(),y(s),h(e)}function d(e){return t.parser.lazy[t.now().line]=s!==n.length,i=t.now().offset,f(e)}function h(n){return t.containerState={},e.attempt(fn,p,f)(n)}function p(e){return s++,n.push([t.currentConstruct,t.containerState]),h(e)}function f(n){return null===n?(r&&w(),y(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:o}),m(n))}function m(n){return null===n?(g(e.exit("chunkFlow"),!0),y(0),void e.consume(n)):on(n)?(e.consume(n),g(e.exit("chunkFlow")),s=0,t.interrupt=void 0,l):(e.consume(n),m)}function g(e,n){const l=t.sliceStream(e);if(n&&l.push(null),e.previous=o,o&&(o.next=e),o=e,r.defineSkip(e.start),r.write(l),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<i&&(!r.events[e][1].end||r.events[e][1].end.offset>i))return;const n=t.events.length;let o,l,a=n;for(;a--;)if("exit"===t.events[a][0]&&"chunkFlow"===t.events[a][1].type){if(o){l=t.events[a][1].end;break}o=!0}for(y(s),e=n;e<t.events.length;)t.events[e][1].end={...l},e++;_t(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function y(r){let o=n.length;for(;o-- >r;){const r=n[o];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function w(){r.write([null]),o=void 0,r=void 0,t.containerState._closeFlow=void 0}}},fn={tokenize:function(e,t,n){return dn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},mn={partial:!0,tokenize:function(e,t,n){return function(t){return ln(t)?dn(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||on(e)?t(e):n(e)}}},gn={resolve:function(e){return qt(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?o(t):on(t)?e.check(yn,i,o)(t):(e.consume(t),r)}function o(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function i(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},yn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),dn(e,o,"linePrefix")};function o(o){if(null===o||on(o))return n(o);const i=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}},wn={tokenize:function(e){const t=this,n=e.attempt(mn,(function(r){if(null!==r)return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n;e.consume(r)}),e.attempt(this.parser.constructs.flowInitial,r,dn(e,e.attempt(this.parser.constructs.flow,r,e.attempt(gn,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}},kn={resolveAll:Cn()},vn=xn("string"),bn=xn("text");function xn(e){return{resolveAll:Cn("text"===e?Sn:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],o=t.attempt(r,i,s);return i;function i(e){return a(e)?o(e):s(e)}function s(e){if(null!==e)return t.enter("data"),t.consume(e),l;t.consume(e)}function l(e){return a(e)?(t.exit("data"),o(e)):(t.consume(e),l)}function a(e){if(null===e)return!0;const t=r[e];let o=-1;if(t)for(;++o<t.length;){const e=t[o];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function Cn(e){return function(t,n){let r,o=-1;for(;++o<=t.length;)void 0===r?t[o]&&"data"===t[o][1].type&&(r=o,o++):t[o]&&"data"===t[o][1].type||(o!==r+2&&(t[r][1].end=t[o-1][1].end,t.splice(r+2,o-r-2),o=r+2),r=void 0);return e?e(t,n):t}}function Sn(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const r=e[n-1][1],o=t.sliceStream(r);let i,s=o.length,l=-1,a=0;for(;s--;){const e=o[s];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)a++,l--;if(l)break;l=-1}else if(-2===e)i=!0,a++;else if(-1!==e){s++;break}}if(a){const o={type:n===e.length||i||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?l:r.start._bufferIndex+l,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...o.start},r.start.offset===r.end.offset?Object.assign(r,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}const Mn={name:"thematicBreak",tokenize:function(e,t,n){let r,o=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,i(e)}(t)};function i(i){return i===r?(e.enter("thematicBreakSequence"),s(i)):o>=3&&(null===i||on(i))?(e.exit("thematicBreak"),t(i)):n(i)}function s(t){return t===r?(e.consume(t),o++,s):(e.exit("thematicBreakSequence"),ln(t)?dn(e,i,"whitespace")(t):i(t))}}},Nn={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(mn,(function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,dn(e,t,"listItemIndent",r.containerState.size+1)(n)}),(function(n){return r.containerState.furtherBlankLines||!ln(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(On,t,o)(n))}));function o(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,dn(e,e.attempt(Nn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,o=r.events[r.events.length-1];let i=o&&"linePrefix"===o[1].type?o[2].sliceSerialize(o[1],!0).length:0,s=0;return function(t){const o=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===o?!r.containerState.marker||t===r.containerState.marker:tn(t)){if(r.containerState.type||(r.containerState.type=o,e.enter(o,{_container:!0})),"listUnordered"===o)return e.enter("listItemPrefix"),42===t||45===t?e.check(Mn,n,a)(t):a(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(t)}return n(t)};function l(t){return tn(t)&&++s<10?(e.consume(t),l):(!r.interrupt||s<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),a(t)):n(t)}function a(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(mn,r.interrupt?n:c,e.attempt(Tn,d,u))}function c(e){return r.containerState.initialBlankLine=!0,i++,d(e)}function u(t){return ln(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Tn={partial:!0,tokenize:function(e,t,n){const r=this;return dn(e,(function(e){const o=r.events[r.events.length-1];return!ln(e)&&o&&"listItemPrefixWhitespace"===o[1].type?t(e):n(e)}),"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},On={partial:!0,tokenize:function(e,t,n){const r=this;return dn(e,(function(e){const o=r.events[r.events.length-1];return o&&"listItemIndent"===o[1].type&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(e):n(e)}),"listItemIndent",r.containerState.size+1)}},An={continuation:{tokenize:function(e,t,n){const r=this;return function(t){return ln(t)?dn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)};function o(r){return e.attempt(An,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return n(t)};function o(n){return ln(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};function En(e,t,n,r,o,i,s,l,a){const c=a||Number.POSITIVE_INFINITY;let u=0;return function(t){return 60===t?(e.enter(r),e.enter(o),e.enter(i),e.consume(t),e.exit(i),d):null===t||32===t||41===t||en(t)?n(t):(e.enter(r),e.enter(s),e.enter(l),e.enter("chunkString",{contentType:"string"}),f(t))};function d(n){return 62===n?(e.enter(i),e.consume(n),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(l),d(t)):null===t||60===t||on(t)?n(t):(e.consume(t),92===t?p:h)}function p(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function f(o){return u||null!==o&&41!==o&&!sn(o)?u<c&&40===o?(e.consume(o),u++,f):41===o?(e.consume(o),u--,f):null===o||32===o||40===o||en(o)?n(o):(e.consume(o),92===o?m:f):(e.exit("chunkString"),e.exit(l),e.exit(s),e.exit(r),t(o))}function m(t){return 40===t||41===t||92===t?(e.consume(t),f):f(t)}}function In(e,t,n,r,o,i){const s=this;let l,a=0;return function(t){return e.enter(r),e.enter(o),e.consume(t),e.exit(o),e.enter(i),c};function c(d){return a>999||null===d||91===d||93===d&&!l||94===d&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(i),e.enter(o),e.consume(d),e.exit(o),e.exit(r),t):on(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||on(t)||a++>999?(e.exit("chunkString"),c(t)):(e.consume(t),l||(l=!ln(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),a++,u):u(t)}}function Rn(e,t,n,r,o,i){let s;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(o),e.consume(t),e.exit(o),s=40===t?41:t,l):n(t)};function l(n){return n===s?(e.enter(o),e.consume(n),e.exit(o),e.exit(r),t):(e.enter(i),a(n))}function a(t){return t===s?(e.exit(i),l(s)):null===t?n(t):on(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),dn(e,a,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===s||null===t||on(t)?(e.exit("chunkString"),a(t)):(e.consume(t),92===t?u:c)}function u(t){return t===s||92===t?(e.consume(t),c):c(t)}}function Dn(e,t){let n;return function r(o){return on(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):ln(o)?dn(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}function Pn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $n={name:"definition",tokenize:function(e,t,n){const r=this;let o;return function(t){return e.enter("definition"),function(t){return In.call(r,e,i,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function i(t){return o=Pn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return sn(t)?Dn(e,l)(t):l(t)}function l(t){return En(e,a,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function a(t){return e.attempt(Ln,c,c)(t)}function c(t){return ln(t)?dn(e,u,"whitespace")(t):u(t)}function u(i){return null===i||on(i)?(e.exit("definition"),r.parser.defined.push(o),t(i)):n(i)}}},Ln={partial:!0,tokenize:function(e,t,n){return function(t){return sn(t)?Dn(e,r)(t):n(t)};function r(t){return Rn(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return ln(t)?dn(e,i,"whitespace")(t):i(t)}function i(e){return null===e||on(e)?t(e):n(e)}}},Bn={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),dn(e,o,"linePrefix",5)(t)};function o(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?i(e):n(e)}function i(t){return null===t?l(t):on(t)?e.attempt(zn,i,l)(t):(e.enter("codeFlowValue"),s(t))}function s(t){return null===t||on(t)?(e.exit("codeFlowValue"),i(t)):(e.consume(t),s)}function l(n){return e.exit("codeIndented"),t(n)}}},zn={partial:!0,tokenize:function(e,t,n){const r=this;return o;function o(t){return r.parser.lazy[r.now().line]?n(t):on(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):dn(e,i,"linePrefix",5)(t)}function i(e){const i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(e):on(e)?o(e):n(e)}}},Fn={name:"headingAtx",resolve:function(e,t){let n,r,o=e.length-2,i=3;return"whitespace"===e[i][1].type&&(i+=2),o-2>i&&"whitespace"===e[o][1].type&&(o-=2),"atxHeadingSequence"===e[o][1].type&&(i===o-1||o-4>i&&"whitespace"===e[o-2][1].type)&&(o-=i+1===o?2:4),o>i&&(n={type:"atxHeadingText",start:e[i][1].start,end:e[o][1].end},r={type:"chunkText",start:e[i][1].start,end:e[o][1].end,contentType:"text"},_t(e,i,o-i+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),o(t)}(t)};function o(t){return 35===t&&r++<6?(e.consume(t),o):null===t||sn(t)?(e.exit("atxHeadingSequence"),i(t)):n(t)}function i(n){return 35===n?(e.enter("atxHeadingSequence"),s(n)):null===n||on(n)?(e.exit("atxHeading"),t(n)):ln(n)?dn(e,i,"whitespace")(n):(e.enter("atxHeadingText"),l(n))}function s(t){return 35===t?(e.consume(t),s):(e.exit("atxHeadingSequence"),i(t))}function l(t){return null===t||35===t||sn(t)?(e.exit("atxHeadingText"),i(t)):(e.consume(t),l)}}},jn={name:"setextUnderline",resolveTo:function(e,t){let n,r,o,i=e.length;for(;i--;)if("enter"===e[i][0]){if("content"===e[i][1].type){n=i;break}"paragraph"===e[i][1].type&&(r=i)}else"content"===e[i][1].type&&e.splice(i,1),o||"definition"!==e[i][1].type||(o=i);const s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",o?(e.splice(r,0,["enter",s,t]),e.splice(o+1,0,["exit",e[n][1],t]),e[n][1].end={...e[o][1].end}):e[n][1]=s,e.push(["exit",s,t]),e},tokenize:function(e,t,n){const r=this;let o;return function(t){let s,l=r.events.length;for(;l--;)if("lineEnding"!==r.events[l][1].type&&"linePrefix"!==r.events[l][1].type&&"content"!==r.events[l][1].type){s="paragraph"===r.events[l][1].type;break}return r.parser.lazy[r.now().line]||!r.interrupt&&!s?n(t):(e.enter("setextHeadingLine"),o=t,function(t){return e.enter("setextHeadingLineSequence"),i(t)}(t))};function i(t){return t===o?(e.consume(t),i):(e.exit("setextHeadingLineSequence"),ln(t)?dn(e,s,"lineSuffix")(t):s(t))}function s(r){return null===r||on(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}},_n=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Wn=["pre","script","style","textarea"],Vn={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){const r=this;let o,i,s,l,a;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(l){return 33===l?(e.consume(l),u):47===l?(e.consume(l),i=!0,p):63===l?(e.consume(l),o=3,r.interrupt?t:P):Xt(l)?(e.consume(l),s=String.fromCharCode(l),f):n(l)}function u(i){return 45===i?(e.consume(i),o=2,d):91===i?(e.consume(i),o=5,l=0,h):Xt(i)?(e.consume(i),o=4,r.interrupt?t:P):n(i)}function d(o){return 45===o?(e.consume(o),r.interrupt?t:P):n(o)}function h(o){return o==="CDATA[".charCodeAt(l++)?(e.consume(o),6===l?r.interrupt?t:N:h):n(o)}function p(t){return Xt(t)?(e.consume(t),s=String.fromCharCode(t),f):n(t)}function f(l){if(null===l||47===l||62===l||sn(l)){const a=47===l,c=s.toLowerCase();return a||i||!Wn.includes(c)?_n.includes(s.toLowerCase())?(o=6,a?(e.consume(l),m):r.interrupt?t(l):N(l)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(l):i?g(l):y(l)):(o=1,r.interrupt?t(l):N(l))}return 45===l||Zt(l)?(e.consume(l),s+=String.fromCharCode(l),f):n(l)}function m(o){return 62===o?(e.consume(o),r.interrupt?t:N):n(o)}function g(t){return ln(t)?(e.consume(t),g):S(t)}function y(t){return 47===t?(e.consume(t),S):58===t||95===t||Xt(t)?(e.consume(t),w):ln(t)?(e.consume(t),y):S(t)}function w(t){return 45===t||46===t||58===t||95===t||Zt(t)?(e.consume(t),w):k(t)}function k(t){return 61===t?(e.consume(t),v):ln(t)?(e.consume(t),k):y(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,b):ln(t)?(e.consume(t),v):x(t)}function b(t){return t===a?(e.consume(t),a=null,C):null===t||on(t)?n(t):(e.consume(t),b)}function x(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||sn(t)?k(t):(e.consume(t),x)}function C(e){return 47===e||62===e||ln(e)?y(e):n(e)}function S(t){return 62===t?(e.consume(t),M):n(t)}function M(t){return null===t||on(t)?N(t):ln(t)?(e.consume(t),M):n(t)}function N(t){return 45===t&&2===o?(e.consume(t),E):60===t&&1===o?(e.consume(t),I):62===t&&4===o?(e.consume(t),$):63===t&&3===o?(e.consume(t),P):93===t&&5===o?(e.consume(t),D):!on(t)||6!==o&&7!==o?null===t||on(t)?(e.exit("htmlFlowData"),T(t)):(e.consume(t),N):(e.exit("htmlFlowData"),e.check(Hn,L,T)(t))}function T(t){return e.check(qn,O,L)(t)}function O(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),A}function A(t){return null===t||on(t)?T(t):(e.enter("htmlFlowData"),N(t))}function E(t){return 45===t?(e.consume(t),P):N(t)}function I(t){return 47===t?(e.consume(t),s="",R):N(t)}function R(t){if(62===t){const n=s.toLowerCase();return Wn.includes(n)?(e.consume(t),$):N(t)}return Xt(t)&&s.length<8?(e.consume(t),s+=String.fromCharCode(t),R):N(t)}function D(t){return 93===t?(e.consume(t),P):N(t)}function P(t){return 62===t?(e.consume(t),$):45===t&&2===o?(e.consume(t),P):N(t)}function $(t){return null===t||on(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),$)}function L(n){return e.exit("htmlFlow"),t(n)}}},Hn={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(mn,t,n)}}},qn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return on(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):n(t)};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Kn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o)};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Un={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s};function s(t){return e.enter("codeFencedFence"),ln(t)?dn(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):a(t)}function a(t){return t===i?(e.enter("codeFencedFenceSequence"),c(t)):n(t)}function c(t){return t===i?(o++,e.consume(t),c):o>=l?(e.exit("codeFencedFenceSequence"),ln(t)?dn(e,u,"whitespace")(t):u(t)):n(t)}function u(r){return null===r||on(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let i,s=0,l=0;return function(t){return function(t){const n=r.events[r.events.length-1];return s=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,i=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),a(t)}(t)};function a(t){return t===i?(l++,e.consume(t),a):l<3?n(t):(e.exit("codeFencedFenceSequence"),ln(t)?dn(e,c,"whitespace")(t):c(t))}function c(n){return null===n||on(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(Kn,p,w)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||on(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):ln(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),dn(e,d,"whitespace")(t)):96===t&&t===i?n(t):(e.consume(t),u)}function d(t){return null===t||on(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||on(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===i?n(t):(e.consume(t),h)}function p(t){return e.attempt(o,w,f)(t)}function f(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),m}function m(t){return s>0&&ln(t)?dn(e,g,"linePrefix",s+1)(t):g(t)}function g(t){return null===t||on(t)?e.check(Kn,p,w)(t):(e.enter("codeFlowValue"),y(t))}function y(t){return null===t||on(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),y)}function w(n){return e.exit("codeFenced"),t(n)}}},Jn=document.createElement("i");function Yn(e){const t="&"+e+";";Jn.innerHTML=t;const n=Jn.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}const Gn={name:"characterReference",tokenize:function(e,t,n){const r=this;let o,i,s=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),l};function l(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),a):(e.enter("characterReferenceValue"),o=31,i=Zt,c(t))}function a(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=nn,c):(e.enter("characterReferenceValue"),o=7,i=tn,c(t))}function c(l){if(59===l&&s){const o=e.exit("characterReferenceValue");return i!==Zt||Yn(r.sliceSerialize(o))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return i(l)&&s++<o?(e.consume(l),c):n(l)}}},Xn={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return rn(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},Zn={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),dn(e,t,"linePrefix")}}};function Qn(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const er={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&_t(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,o,i,s=e.length,l=0;for(;s--;)if(n=e[s][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[s][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(o){if("enter"===e[s][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=s,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(o=s);const a={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[o-2][1].start}};return i=[["enter",a,t],["enter",c,t]],i=Wt(i,e.slice(r+1,r+l+3)),i=Wt(i,[["enter",u,t]]),i=Wt(i,Qn(t.parser.constructs.insideSpan.null,e.slice(r+l+4,o-3),t)),i=Wt(i,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),i=Wt(i,e.slice(o+1)),i=Wt(i,[["exit",a,t]]),_t(e,r,e.length,i),e},tokenize:function(e,t,n){const r=this;let o,i,s=r.events.length;for(;s--;)if(("labelImage"===r.events[s][1].type||"labelLink"===r.events[s][1].type)&&!r.events[s][1]._balanced){o=r.events[s][1];break}return function(t){return o?o._inactive?u(t):(i=r.parser.defined.includes(Pn(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),l):n(t)};function l(t){return 40===t?e.attempt(tr,c,i?c:u)(t):91===t?e.attempt(nr,c,i?a:u)(t):i?c(t):u(t)}function a(t){return e.attempt(rr,c,u)(t)}function c(e){return t(e)}function u(e){return o._balanced=!0,n(e)}}},tr={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return sn(t)?Dn(e,o)(t):o(t)}function o(t){return 41===t?c(t):En(e,i,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function i(t){return sn(t)?Dn(e,l)(t):c(t)}function s(e){return n(e)}function l(t){return 34===t||39===t||40===t?Rn(e,a,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function a(t){return sn(t)?Dn(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},nr={tokenize:function(e,t,n){const r=this;return function(t){return In.call(r,e,o,i,"reference","referenceMarker","referenceString")(t)};function o(e){return r.parser.defined.includes(Pn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function i(e){return n(e)}}},rr={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},or={name:"labelStartImage",resolveAll:er.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),o};function o(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),i):n(t)}function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};function ir(e){return null===e||sn(e)||cn(e)?1:an(e)?2:void 0}const sr={name:"attention",resolveAll:function(e,t){let n,r,o,i,s,l,a,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[n][1].end},h={...e[u][1].start};lr(d,-l),lr(h,l),i={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},o={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:l>1?"strong":"emphasis",start:{...i.start},end:{...s.end}},e[n][1].end={...i.start},e[u][1].start={...s.end},a=[],e[n][1].end.offset-e[n][1].start.offset&&(a=Wt(a,[["enter",e[n][1],t],["exit",e[n][1],t]])),a=Wt(a,[["enter",r,t],["enter",i,t],["exit",i,t],["enter",o,t]]),a=Wt(a,Qn(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),a=Wt(a,[["exit",o,t],["enter",s,t],["exit",s,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,a=Wt(a,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,_t(e,n-1,u-n+3,a),u=n+a.length-c-2;break}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=ir(r);let i;return function(t){return i=t,e.enter("attentionSequence"),s(t)};function s(l){if(l===i)return e.consume(l),s;const a=e.exit("attentionSequence"),c=ir(l),u=!c||2===c&&o||n.includes(l),d=!o||2===o&&c||n.includes(r);return a._open=Boolean(42===i?u:u&&(o||!d)),a._close=Boolean(42===i?d:d&&(c||!u)),t(l)}}};function lr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ar={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o};function o(t){return Xt(t)?(e.consume(t),i):64===t?n(t):a(t)}function i(e){return 43===e||45===e||46===e||Zt(e)?(r=1,s(e)):a(e)}function s(t){return 58===t?(e.consume(t),r=0,l):(43===t||45===t||46===t||Zt(t))&&r++<32?(e.consume(t),s):(r=0,a(t))}function l(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||en(r)?n(r):(e.consume(r),l)}function a(t){return 64===t?(e.consume(t),c):Qt(t)?(e.consume(t),a):n(t)}function c(e){return Zt(e)?u(e):n(e)}function u(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):d(n)}function d(t){if((45===t||Zt(t))&&r++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}},cr={name:"htmlText",tokenize:function(e,t,n){const r=this;let o,i,s;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),l};function l(t){return 33===t?(e.consume(t),a):47===t?(e.consume(t),v):63===t?(e.consume(t),w):Xt(t)?(e.consume(t),C):n(t)}function a(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,p):Xt(t)?(e.consume(t),y):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):on(t)?(s=u,R(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?I(e):45===e?d(e):u(e)}function p(t){return t==="CDATA[".charCodeAt(i++)?(e.consume(t),6===i?f:p):n(t)}function f(t){return null===t?n(t):93===t?(e.consume(t),m):on(t)?(s=f,R(t)):(e.consume(t),f)}function m(t){return 93===t?(e.consume(t),g):f(t)}function g(t){return 62===t?I(t):93===t?(e.consume(t),g):f(t)}function y(t){return null===t||62===t?I(t):on(t)?(s=y,R(t)):(e.consume(t),y)}function w(t){return null===t?n(t):63===t?(e.consume(t),k):on(t)?(s=w,R(t)):(e.consume(t),w)}function k(e){return 62===e?I(e):w(e)}function v(t){return Xt(t)?(e.consume(t),b):n(t)}function b(t){return 45===t||Zt(t)?(e.consume(t),b):x(t)}function x(t){return on(t)?(s=x,R(t)):ln(t)?(e.consume(t),x):I(t)}function C(t){return 45===t||Zt(t)?(e.consume(t),C):47===t||62===t||sn(t)?S(t):n(t)}function S(t){return 47===t?(e.consume(t),I):58===t||95===t||Xt(t)?(e.consume(t),M):on(t)?(s=S,R(t)):ln(t)?(e.consume(t),S):I(t)}function M(t){return 45===t||46===t||58===t||95===t||Zt(t)?(e.consume(t),M):N(t)}function N(t){return 61===t?(e.consume(t),T):on(t)?(s=N,R(t)):ln(t)?(e.consume(t),N):S(t)}function T(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),o=t,O):on(t)?(s=T,R(t)):ln(t)?(e.consume(t),T):(e.consume(t),A)}function O(t){return t===o?(e.consume(t),o=void 0,E):null===t?n(t):on(t)?(s=O,R(t)):(e.consume(t),O)}function A(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||sn(t)?S(t):(e.consume(t),A)}function E(e){return 47===e||62===e||sn(e)?S(e):n(e)}function I(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function R(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),D}function D(t){return ln(t)?dn(e,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):P(t)}function P(t){return e.enter("htmlTextData"),s(t)}}},ur={name:"labelStartLink",resolveAll:er.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),o};function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},dr={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return on(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},hr={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,o=3;if(!("lineEnding"!==e[o][1].type&&"space"!==e[o][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=o;++t<r;)if("codeTextData"===e[t][1].type){e[o][1].type="codeTextPadding",e[r][1].type="codeTextPadding",o+=2,r-=2;break}for(t=o-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,o,i=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),s(t)};function s(t){return 96===t?(e.consume(t),i++,s):(e.exit("codeTextSequence"),l(t))}function l(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),l):96===t?(o=e.enter("codeTextSequence"),r=0,c(t)):on(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l):(e.enter("codeTextData"),a(t))}function a(t){return null===t||32===t||96===t||on(t)?(e.exit("codeTextData"),l(t)):(e.consume(t),a)}function c(n){return 96===n?(e.consume(n),r++,c):r===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(o.type="codeTextData",a(n))}}},pr={42:Nn,43:Nn,45:Nn,48:Nn,49:Nn,50:Nn,51:Nn,52:Nn,53:Nn,54:Nn,55:Nn,56:Nn,57:Nn,62:An},fr={91:$n},mr={[-2]:Bn,[-1]:Bn,32:Bn},gr={35:Fn,42:Mn,45:[jn,Mn],60:Vn,61:jn,95:Mn,96:Un,126:Un},yr={38:Gn,92:Xn},wr={[-5]:Zn,[-4]:Zn,[-3]:Zn,33:or,38:Gn,42:sr,60:[ar,cr],91:ur,92:[dr,Xn],93:er,95:sr,96:hr},kr={null:[sr,kn]},vr={null:[42,95]},br={null:[]};function xr(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},i=[];let s=[],l=[],a=!0;const c={attempt:y((function(e,t){w(e,t.from)})),check:y(g),consume:function(e){on(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,k()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=e,a=!0},enter:function(e,t){const n=t||{};return n.type=e,n.start=f(),u.events.push(["enter",n,u]),l.push(n),n},exit:function(e){const t=l.pop();return t.end=f(),u.events.push(["exit",t,u]),t},interrupt:y(g,{interrupt:!0})},u={code:null,containerState:{},defineSkip:function(e){o[e.line]=e.column,k()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const i=e[n];let s;if("string"==typeof i)s=i;else switch(i){case-5:s="\r";break;case-4:s="\n";break;case-3:s="\r\n";break;case-2:s=t?" ":"\t";break;case-1:if(!t&&o)continue;s=" ";break;default:s=String.fromCharCode(i)}o=-2===i,r.push(s)}return r.join("")}(p(e),t)},sliceStream:p,write:function(e){return s=Wt(s,e),function(){let e;for(;r._index<s.length;){const t=s[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)m(t.charCodeAt(r._bufferIndex));else m(t)}}(),null!==s[s.length-1]?[]:(w(t,0),u.events=Qn(i,u.events,u),u.events)}};let d,h=t.tokenize.call(u,c);return t.resolveAll&&i.push(t),u;function p(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex;let s;if(n===o)s=[e[n].slice(r,i)];else{if(s=e.slice(n,o),r>-1){const e=s[0];"string"==typeof e?s[0]=e.slice(r):s.shift()}i>0&&s.push(e[o].slice(0,i))}return s}(s,e)}function f(){const{_bufferIndex:e,_index:t,line:n,column:o,offset:i}=r;return{_bufferIndex:e,_index:t,line:n,column:o,offset:i}}function m(e){a=void 0,d=e,h=h(e)}function g(e,t){t.restore()}function y(e,t){return function(n,o,i){let s,d,h,p;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):function(e){return function(t){const n=null!==t&&e[t],r=null!==t&&e.null;return m([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function m(e){return s=e,d=0,0===e.length?i:g(e[d])}function g(e){return function(n){return p=function(){const e=f(),t=u.previous,n=u.currentConstruct,o=u.events.length,i=Array.from(l);return{from:o,restore:function(){r=e,u.previous=t,u.currentConstruct=n,u.events.length=o,l=i,k()}}}(),h=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name)?w():e.tokenize.call(t?Object.assign(Object.create(u),t):u,c,y,w)(n)}}function y(t){return a=!0,e(h,p),o}function w(e){return a=!0,p.restore(),++d<s.length?g(s[d]):i}}}function w(e,t){e.resolveAll&&!i.includes(e)&&i.push(e),e.resolve&&_t(u.events,t,u.events.length-t,e.resolve(u.events.slice(t),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function k(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}const Cr=/[\0\t\n\r]/g;function Sr(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}const Mr=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Nr(e){return e.replace(Mr,Tr)}function Tr(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Sr(n.slice(t?2:1),t?16:10)}return Yn(n)||e}function Or(e){return e&&"object"==typeof e?"position"in e||"type"in e?Er(e.position):"start"in e||"end"in e?Er(e):"line"in e||"column"in e?Ar(e):"":""}function Ar(e){return Ir(e&&e.line)+":"+Ir(e&&e.column)}function Er(e){return Ar(e&&e.start)+"-"+Ar(e&&e.end)}function Ir(e){return e&&"number"==typeof e?e:1}const Rr={}.hasOwnProperty;function Dr(e,n,r){return"string"!=typeof n&&(r=n,n=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(w),autolinkProtocol:u,autolinkEmail:u,atxHeading:o(m),blockQuote:o((function(){return{type:"blockquote",children:[]}})),characterEscape:u,characterReference:u,codeFenced:o(f),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:o(f,i),codeText:o((function(){return{type:"inlineCode",value:""}}),i),codeTextData:u,data:u,codeFlowValue:u,definition:o((function(){return{type:"definition",identifier:"",label:null,title:null,url:""}})),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:o((function(){return{type:"emphasis",children:[]}})),hardBreakEscape:o(g),hardBreakTrailing:o(g),htmlFlow:o(y,i),htmlFlowData:u,htmlText:o(y,i),htmlTextData:u,image:o((function(){return{type:"image",title:null,url:"",alt:null}})),label:i,link:o(w),listItem:o((function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}})),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:o(k,(function(){this.data.expectingFirstListItemValue=!0})),listUnordered:o(k),paragraph:o((function(){return{type:"paragraph",children:[]}})),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:o(m),strong:o((function(){return{type:"strong",children:[]}})),thematicBreak:o((function(){return{type:"thematicBreak"}}))},exit:{atxHeading:l(),atxHeadingSequence:function(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}},autolink:l(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:l(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;n?(r=Sr(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0):r=Yn(t);this.stack[this.stack.length-1].value+=r},characterReference:function(e){this.stack.pop().position.end=Pr(e.end)},codeFenced:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0})),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){const e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){const e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")})),codeText:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),codeTextData:d,data:d,definition:l(),definitionDestinationString:function(){const e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Pn(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){const e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:l(),hardBreakEscape:l(h),hardBreakTrailing:l(h),htmlFlow:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),htmlFlowData:d,htmlText:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),htmlTextData:d,image:l((function(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0})),label:function(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t},labelText:function(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Nr(t),n.identifier=Pn(t).toLowerCase()},lineEnding:function(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak)return n.children[n.children.length-1].position.end=Pr(e.end),void(this.data.atHardBreak=void 0);!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(u.call(this,e),d.call(this,e))},link:l((function(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0})),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:function(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Pn(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){const e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){const e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:l((function(){this.data.setextHeadingSlurpLineEnding=void 0})),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:l(),thematicBreak:l()}};$r(t,(e||{}).mdastExtensions||[]);const n={};return function(e){let o={type:"root",children:[]};const l={stack:[o],tokenStack:[],config:t,enter:s,exit:a,buffer:i,resume:c,data:n},u=[];let d=-1;for(;++d<e.length;)"listOrdered"!==e[d][1].type&&"listUnordered"!==e[d][1].type||("enter"===e[d][0]?u.push(d):d=r(e,u.pop(),d));for(d=-1;++d<e.length;){const n=t[e[d][0]];Rr.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},l),e[d][1])}if(l.tokenStack.length>0){const e=l.tokenStack[l.tokenStack.length-1];(e[1]||Br).call(l,void 0,e[0])}for(o.position={start:Pr(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Pr(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)o=t.transforms[d](o)||o;return o};function r(e,t,n){let r,o,i,s,l=t-1,a=-1,c=!1;for(;++l<=n;){const t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?a++:a--,s=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||s||a||i||(i=l),s=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:s=void 0}if(!a&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===a&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let s=l;for(o=void 0;s--;){const t=e[s];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;o&&(e[o][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",o=s}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}i&&(!o||i<o)&&(r._spread=!0),r.end=Object.assign({},o?e[o][1].start:t[1].end),e.splice(o||l,0,["exit",r,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){const o={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=o,e.splice(l,0,["enter",o,t[2]]),l++,n++,i=void 0,s=!0}}}return e[t][1]._spread=c,n}function o(e,t){return function(n){s.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Pr(t.start),end:void 0}}function l(e){return function(t){e&&e.call(this,t),a.call(this,t)}}function a(e,t){const n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+Or({start:e.start,end:e.end})+"): it’s not open");r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Br).call(this,e,r[0])),n.position.end=Pr(e.end)}function c(){return zt(this.stack.pop())}function u(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n={type:"text",value:""},n.position={start:Pr(e.start),end:void 0},t.push(n)),this.stack.push(n)}function d(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Pr(e.end)}function h(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function f(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function g(){return{type:"break"}}function y(){return{type:"html",value:""}}function w(){return{type:"link",title:null,url:"",children:[]}}function k(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}}(r)(function(e){for(;!qt(e););return e}(function(e){const n={constructs:Jt([t,...(e||{}).extensions||[]]),content:r(hn),defined:[],document:r(pn),flow:r(wn),lazy:{},string:r(vn),text:r(bn)};return n;function r(e){return function(t){return xr(n,e,t)}}}(r).document().write(function(){let e,t=1,n="",r=!0;return function(o,i,s){const l=[];let a,c,u,d,h;for(o=n+("string"==typeof o?o.toString():new TextDecoder(i||void 0).decode(o)),u=0,n="",r&&(65279===o.charCodeAt(0)&&u++,r=void 0);u<o.length;){if(Cr.lastIndex=u,a=Cr.exec(o),d=a&&void 0!==a.index?a.index:o.length,h=o.charCodeAt(d),!a){n=o.slice(u);break}if(10===h&&u===d&&e)l.push(-3),e=void 0;else switch(e&&(l.push(-5),e=void 0),u<d&&(l.push(o.slice(u,d)),t+=d-u),h){case 0:l.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),l.push(-2);t++<c;)l.push(-1);break;case 10:l.push(-4),t=1;break;default:e=!0,t=1}u=d+1}return s&&(e&&l.push(-5),n&&l.push(n),l.push(null)),l}}()(e,n,!0))))}function Pr(e){return{line:e.line,column:e.column,offset:e.offset}}function $r(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?$r(e,r):Lr(e,r)}}function Lr(e,t){let n;for(n in t)if(Rr.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Br(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Or({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Or({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Or({start:t.start,end:t.end})+") is still open")}function zr(e){const t=this;t.parser=function(n){return Dr(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}const Fr={}.hasOwnProperty,jr={}.hasOwnProperty;function _r(e,t){let n,r=-1;if(t.extensions)for(;++r<t.extensions.length;)_r(e,t.extensions[r]);for(n in t)if(jr.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":o=e[n],(i=t[n])&&o.push(...i);break;case"handlers":Wr(e[n],t[n]);break;default:e.options[n]=t[n]}var o,i;return e}function Wr(e,t){t&&Object.assign(e,t)}function Vr(e,t,n){return">"+(n?"":" ")+e}function Hr(e,t){return qr(e,t.inConstruct,!0)&&!qr(e,t.notInConstruct,!1)}function qr(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Kr(e,t,n,r){let o=-1;for(;++o<n.unsafe.length;)if("\n"===n.unsafe[o].character&&Hr(n.stack,n.unsafe[o]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function Ur(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Jr(e,t,n){return(n?"":" ")+e}function Yr(e){const t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Gr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Xr(e,t,n){const r=ir(e),o=ir(t);return void 0===r?void 0===o?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===o?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===o?{inside:!1,outside:!1}:1===o?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===o?{inside:!1,outside:!1}:1===o?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Zr(e,t,n,r){const o=function(e){const t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),i=n.enter("emphasis"),s=n.createTracker(r),l=s.move(o);let a=s.move(n.containerPhrasing(e,{after:o,before:l,...s.current()}));const c=a.charCodeAt(0),u=Xr(r.before.charCodeAt(r.before.length-1),c,o);u.inside&&(a=Gr(c)+a.slice(1));const d=a.charCodeAt(a.length-1),h=Xr(r.after.charCodeAt(0),d,o);h.inside&&(a=a.slice(0,-1)+Gr(d));const p=s.move(o);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},l+a+p}Zr.peek=function(e,t,n){return n.options.emphasis||"*"};const Qr=function(e){if(null==e)return to;if("function"==typeof e)return eo(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Qr(e[n]);return eo((function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}))}(e):function(e){const t=e;return eo((function(n){const r=n;let o;for(o in e)if(r[o]!==t[o])return!1;return!0}))}(e);if("string"==typeof e)return t=e,eo((function(e){return e&&e.type===t}));var t;throw new Error("Expected function, string, or object as test")};function eo(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function to(){return!0}const no=[],ro=!0,oo=!1,io="skip";function so(e,t,n,r){let o;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):o=t;const i=Qr(o),s=r?-1:1;!function e(o,l,a){const c=o&&"object"==typeof o?o:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+o.type+(e?"<"+e+">":"")+")"})}return u;function u(){let c,u,d,h=no;if((!t||i(o,l,a[a.length-1]||void 0))&&(h=function(e){return Array.isArray(e)?e:"number"==typeof e?[ro,e]:null==e?no:[e]}(n(o,a)),h[0]===oo))return h;if("children"in o&&o.children){const t=o;if(t.children&&h[0]!==io)for(u=(r?t.children.length:-1)+s,d=a.concat(t);u>-1&&u<t.children.length;){const n=t.children[u];if(c=e(n,u,d)(),c[0]===oo)return c;u="number"==typeof c[1]?c[1]:u+s}}return h}}(e,void 0,[])()}function lo(e,t,n,r){let o,i,s;"function"==typeof t&&"function"!=typeof n?(i=void 0,s=t,o=n):(i=t,s=n,o=r),so(e,i,(function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return s(e,r,n)}),o)}function ao(e,t){let n=!1;return lo(e,(function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,oo})),Boolean((!e.depth||e.depth<3)&&zt(e)&&(t.options.setext||n))}function co(e){return e.value||""}function uo(e,t,n,r){const o=Yr(n),i='"'===o?"Quote":"Apostrophe",s=n.enter("image");let l=n.enter("label");const a=n.createTracker(r);let c=a.move("![");return c+=a.move(n.safe(e.alt,{before:c,after:"]",...a.current()})),c+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${i}`),c+=a.move(" "+o),c+=a.move(n.safe(e.title,{before:c,after:o,...a.current()})),c+=a.move(o),l()),c+=a.move(")"),s(),c}function ho(e,t,n,r){const o=e.referenceType,i=n.enter("imageReference");let s=n.enter("label");const l=n.createTracker(r);let a=l.move("![");const c=n.safe(e.alt,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(e),{before:a,after:"]",...l.current()});return s(),n.stack=u,i(),"full"!==o&&c&&c===d?"shortcut"===o?a=a.slice(0,-1):a+=l.move("]"):a+=l.move(d+"]"),a}function po(e,t,n){let r=e.value||"",o="`",i=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++i<n.unsafe.length;){const e=n.unsafe[i],t=n.compilePattern(e);let o;if(e.atBreak)for(;o=t.exec(r);){let e=o.index;10===r.charCodeAt(e)&&13===r.charCodeAt(e-1)&&e--,r=r.slice(0,e)+" "+r.slice(o.index+1)}}return o+r+o}function fo(e,t){const n=zt(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function mo(e,t,n,r){const o=Yr(n),i='"'===o?"Quote":"Apostrophe",s=n.createTracker(r);let l,a;if(fo(e,n)){const t=n.stack;n.stack=[],l=n.enter("autolink");let r=s.move("<");return r+=s.move(n.containerPhrasing(e,{before:r,after:">",...s.current()})),r+=s.move(">"),l(),n.stack=t,r}l=n.enter("link"),a=n.enter("label");let c=s.move("[");return c+=s.move(n.containerPhrasing(e,{before:c,after:"](",...s.current()})),c+=s.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(n.safe(e.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(a=n.enter("destinationRaw"),c+=s.move(n.safe(e.url,{before:c,after:e.title?" ":")",...s.current()}))),a(),e.title&&(a=n.enter(`title${i}`),c+=s.move(" "+o),c+=s.move(n.safe(e.title,{before:c,after:o,...s.current()})),c+=s.move(o),a()),c+=s.move(")"),l(),c}function go(e,t,n,r){const o=e.referenceType,i=n.enter("linkReference");let s=n.enter("label");const l=n.createTracker(r);let a=l.move("[");const c=n.containerPhrasing(e,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(e),{before:a,after:"]",...l.current()});return s(),n.stack=u,i(),"full"!==o&&c&&c===d?"shortcut"===o?a=a.slice(0,-1):a+=l.move("]"):a+=l.move(d+"]"),a}function yo(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function wo(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}co.peek=function(){return"<"},uo.peek=function(){return"!"},ho.peek=function(){return"!"},po.peek=function(){return"`"},mo.peek=function(e,t,n){return fo(e,n)?"<":"["},go.peek=function(){return"["};const ko=Qr(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function vo(e,t,n,r){const o=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),i=n.enter("strong"),s=n.createTracker(r),l=s.move(o+o);let a=s.move(n.containerPhrasing(e,{after:o,before:l,...s.current()}));const c=a.charCodeAt(0),u=Xr(r.before.charCodeAt(r.before.length-1),c,o);u.inside&&(a=Gr(c)+a.slice(1));const d=a.charCodeAt(a.length-1),h=Xr(r.after.charCodeAt(0),d,o);h.inside&&(a=a.slice(0,-1)+Gr(d));const p=s.move(o+o);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},l+a+p}vo.peek=function(e,t,n){return n.options.strong||"*"};const bo={blockquote:function(e,t,n,r){const o=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const s=n.indentLines(n.containerFlow(e,i.current()),Vr);return o(),s},break:Kr,code:function(e,t,n,r){const o=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),i=e.value||"",s="`"===o?"GraveAccent":"Tilde";if(Ur(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(i,Jr);return e(),t}const l=n.createTracker(r),a=o.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),o=r,i=0,s=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===o?++i>s&&(s=i):i=1,o=r+t.length,r=n.indexOf(t,o);return s}(i,o)+1,3)),c=n.enter("codeFenced");let u=l.move(a);if(e.lang){const t=n.enter(`codeFencedLang${s}`);u+=l.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...l.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${s}`);u+=l.move(" "),u+=l.move(n.safe(e.meta,{before:u,after:"\n",encode:["`"],...l.current()})),t()}return u+=l.move("\n"),i&&(u+=l.move(i+"\n")),u+=l.move(a),c(),u},definition:function(e,t,n,r){const o=Yr(n),i='"'===o?"Quote":"Apostrophe",s=n.enter("definition");let l=n.enter("label");const a=n.createTracker(r);let c=a.move("[");return c+=a.move(n.safe(n.associationId(e),{before:c,after:"]",...a.current()})),c+=a.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...a.current()}))),l(),e.title&&(l=n.enter(`title${i}`),c+=a.move(" "+o),c+=a.move(n.safe(e.title,{before:c,after:o,...a.current()})),c+=a.move(o),l()),s(),c},emphasis:Zr,hardBreak:Kr,heading:function(e,t,n,r){const o=Math.max(Math.min(6,e.depth||1),1),i=n.createTracker(r);if(ao(e,n)){const t=n.enter("headingSetext"),r=n.enter("phrasing"),s=n.containerPhrasing(e,{...i.current(),before:"\n",after:"\n"});return r(),t(),s+"\n"+(1===o?"=":"-").repeat(s.length-(Math.max(s.lastIndexOf("\r"),s.lastIndexOf("\n"))+1))}const s="#".repeat(o),l=n.enter("headingAtx"),a=n.enter("phrasing");i.move(s+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...i.current()});return/^[\t ]/.test(c)&&(c=Gr(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),a(),l(),c},html:co,image:uo,imageReference:ho,inlineCode:po,link:mo,linkReference:go,list:function(e,t,n,r){const o=n.enter("list"),i=n.bulletCurrent;let s=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):yo(n);const l=e.ordered?"."===s?")":".":function(e){const t=yo(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let a=!(!t||!n.bulletLastUsed)&&s===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==s&&"-"!==s||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(a=!0),wo(n)===s&&t){let t=-1;for(;++t<e.children.length;){const n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){a=!0;break}}}}a&&(s=l),n.bulletCurrent=s;const c=n.containerFlow(e,r);return n.bulletLastUsed=s,n.bulletCurrent=i,o(),c},listItem:function(e,t,n,r){const o=function(e){const t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n);let i=n.bulletCurrent||yo(n);t&&"list"===t.type&&t.ordered&&(i=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+i);let s=i.length+1;("tab"===o||"mixed"===o&&(t&&"list"===t.type&&t.spread||e.spread))&&(s=4*Math.ceil(s/4));const l=n.createTracker(r);l.move(i+" ".repeat(s-i.length)),l.shift(s);const a=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,l.current()),(function(e,t,n){return t?(n?"":" ".repeat(s))+e:(n?i:i+" ".repeat(s-i.length))+e}));return a(),c},paragraph:function(e,t,n,r){const o=n.enter("paragraph"),i=n.enter("phrasing"),s=n.containerPhrasing(e,r);return i(),o(),s},root:function(e,t,n,r){return(e.children.some((function(e){return ko(e)}))?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:vo,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(wo(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}},xo=[function(e,t,n,r){if("code"===t.type&&Ur(t,r)&&("list"===e.type||e.type===t.type&&Ur(e,r)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&ao(t,r)))return;return n.spread?1:0}}],Co=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],So=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:Co},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:Co},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:Co},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:Co},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:Co},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:Co},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:Co},{atBreak:!0,character:"~"}];function Mo(e){return e.label||!e.identifier?e.label||"":Nr(e.identifier)}function No(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function To(e,t,n,r){let o=r.join.length;for(;o--;){const i=r.join[o](e,t,n,r);if(!0===i||1===i)break;if("number"==typeof i)return"\n".repeat(1+i);if(!1===i)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const Oo=/\r?\n|\r/g;function Ao(e,t){const n=[];let r,o=0,i=0;for(;r=Oo.exec(e);)s(e.slice(o,r.index)),n.push(r[0]),o=r.index+r[0].length,i++;return s(e.slice(o)),n.join("");function s(e){n.push(t(e,i,!e))}}function Eo(e,t){return e-t}function Io(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],o=[],i=e+t;let s,l=-1,a=0;for(;s=n.exec(i);)r.push(s.index);for(;++l<r.length;)a!==r[l]&&o.push(e.slice(a,r[l])),o.push("\\"),a=r[l];return o.push(e.slice(a)),o.join("")}function Ro(e){const t=e||{},n=t.now||{};let r=t.lineShift||0,o=n.line||1,i=n.column||1;return{move:function(e){const t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return o+=n.length-1,i=1===n.length?i+s.length:1+s.length+r,t},current:function(){return{now:{line:o,column:i},lineShift:r}},shift:function(e){r+=e}}}function Do(e,t){const n=t||{},r={associationId:Mo,containerPhrasing:Bo,containerFlow:zo,createTracker:Ro,compilePattern:No,enter:function(e){return r.stack.push(e),function(){r.stack.pop()}},handlers:{...bo},handle:void 0,indentLines:Ao,indexStack:[],join:[...xo],options:{},safe:Fo,stack:[],unsafe:[...So]};_r(r,n),r.options.tightDefinitions&&r.join.push(Lo),r.handle=function(e,t){const n=t||{};function r(t,...n){let o=r.invalid;const i=r.handlers;if(t&&Fr.call(t,e)){const n=String(t[e]);o=Fr.call(i,n)?i[n]:r.unknown}if(o)return o.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}("type",{invalid:Po,unknown:$o,handlers:r.handlers});let o=r.handle(e,void 0,r,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return o&&10!==o.charCodeAt(o.length-1)&&13!==o.charCodeAt(o.length-1)&&(o+="\n"),o}function Po(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function $o(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function Lo(e,t){if("definition"===e.type&&e.type===t.type)return 0}function Bo(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=[];let s,l=-1,a=n.before;r.push(-1);let c=t.createTracker(n);for(;++l<o.length;){const u=o[l];let d;if(r[r.length-1]=l,l+1<o.length){let n=t.handle.handlers[o[l+1].type];n&&n.peek&&(n=n.peek),d=n?n(o[l+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else d=n.after;i.length>0&&("\r"===a||"\n"===a)&&"html"===u.type&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),a=" ",c=t.createTracker(n),c.move(i.join("")));let h=t.handle(u,e,t,{...c.current(),after:d,before:a});s&&s===h.slice(0,1)&&(h=Gr(s.charCodeAt(0))+h.slice(1));const p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,p&&(i.length>0&&p.before&&a===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+Gr(a.charCodeAt(0))),p.after&&(s=d)),c.move(h),i.push(h),a=h.slice(-1)}return r.pop(),i.join("")}(e,this,t)}function zo(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=t.createTracker(n),s=[];let l=-1;for(r.push(-1);++l<o.length;){const n=o[l];r[r.length-1]=l,s.push(i.move(t.handle(n,e,t,{before:"\n",after:"\n",...i.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),l<o.length-1&&s.push(i.move(To(n,o[l+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function Fo(e,t){return function(e,t,n){const r=(n.before||"")+(t||"")+(n.after||""),o=[],i=[],s={};let l=-1;for(;++l<e.unsafe.length;){const t=e.unsafe[l];if(!Hr(e.stack,t))continue;const n=e.compilePattern(t);let i;for(;i=n.exec(r);){const e="before"in t||Boolean(t.atBreak),n="after"in t,r=i.index+(e?i[1].length:0);o.includes(r)?(s[r].before&&!e&&(s[r].before=!1),s[r].after&&!n&&(s[r].after=!1)):(o.push(r),s[r]={before:e,after:n})}}o.sort(Eo);let a=n.before?n.before.length:0;const c=r.length-(n.after?n.after.length:0);for(l=-1;++l<o.length;){const e=o[l];e<a||e>=c||e+1<c&&o[l+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||o[l-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(a!==e&&i.push(Io(r.slice(a,e),"\\")),a=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(i.push(Gr(r.charCodeAt(e))),a++):i.push("\\"))}return i.push(Io(r.slice(a,c),n.after)),i.join("")}(this,e,t)}function jo(e){const t=this;t.compiler=function(n){return Do(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function _o(e){if(e)throw e}var Wo=n(411);function Vo(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}class Ho extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",o={},i=!1;if(t&&(o="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!o.cause&&e&&(i=!0,r=e.message,o.cause=e),!o.ruleId&&!o.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?o.ruleId=n:(o.source=n.slice(0,e),o.ruleId=n.slice(e+1))}if(!o.place&&o.ancestors&&o.ancestors){const e=o.ancestors[o.ancestors.length-1];e&&(o.place=e.position)}const s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=s?s.line:void 0,this.name=Or(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&"string"==typeof o.cause.stack?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}Ho.prototype.file="",Ho.prototype.name="",Ho.prototype.reason="",Ho.prototype.message="",Ho.prototype.stack="",Ho.prototype.column=void 0,Ho.prototype.line=void 0,Ho.prototype.ancestors=void 0,Ho.prototype.cause=void 0,Ho.prototype.fatal=void 0,Ho.prototype.place=void 0,Ho.prototype.ruleId=void 0,Ho.prototype.source=void 0;const qo=function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');Go(e);let n,r=0,o=-1,i=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else o<0&&(n=!0,o=i+1);return o<0?"":e.slice(r,o)}if(t===e)return"";let s=-1,l=t.length-1;for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else s<0&&(n=!0,s=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(o=i):(l=-1,o=s));return r===o?o=s:o<0&&(o=e.length),e.slice(r,o)},Ko=function(e){if(Go(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},Uo=function(e){Go(e);let t,n=e.length,r=-1,o=0,i=-1,s=0;for(;n--;){const l=e.codePointAt(n);if(47!==l)r<0&&(t=!0,r=n+1),46===l?i<0?i=n:1!==s&&(s=1):i>-1&&(s=-1);else if(t){o=n+1;break}}return i<0||r<0||0===s||1===s&&i===r-1&&i===o+1?"":e.slice(i,r)},Jo=function(...e){let t,n=-1;for(;++n<e.length;)Go(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){Go(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,o="",i=0,s=-1,l=0,a=-1;for(;++a<=e.length;){if(a<e.length)n=e.codePointAt(a);else{if(47===n)break;n=47}if(47===n){if(s===a-1||1===l);else if(s!==a-1&&2===l){if(o.length<2||2!==i||46!==o.codePointAt(o.length-1)||46!==o.codePointAt(o.length-2))if(o.length>2){if(r=o.lastIndexOf("/"),r!==o.length-1){r<0?(o="",i=0):(o=o.slice(0,r),i=o.length-1-o.lastIndexOf("/")),s=a,l=0;continue}}else if(o.length>0){o="",i=0,s=a,l=0;continue}t&&(o=o.length>0?o+"/..":"..",i=2)}else o.length>0?o+="/"+e.slice(s+1,a):o=e.slice(s+1,a),i=a-s-1;s=a,l=0}else 46===n&&l>-1?l++:l=-1}return o}(e,!t);return 0!==n.length||t||(n="."),n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/"),t?"/"+n:n}(t)},Yo="/";function Go(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Xo=function(){return"/"};function Zo(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}const Qo=["history","path","basename","stem","extname","dirname"];class ei{constructor(e){let t;t=e?Zo(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":Xo(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<Qo.length;){const e=Qo[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Qo.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?qo(this.path):void 0}set basename(e){ni(e,"basename"),ti(e,"basename"),this.path=Jo(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?Ko(this.path):void 0}set dirname(e){ri(this.basename,"dirname"),this.path=Jo(e||"",this.basename)}get extname(){return"string"==typeof this.path?Uo(this.path):void 0}set extname(e){if(ti(e,"extname"),ri(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Jo(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Zo(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!Zo(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),ni(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?qo(this.path,this.extname):void 0}set stem(e){ni(e,"stem"),ti(e,"stem"),this.path=Jo(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new Ho(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function ti(e,t){if(e&&e.includes(Yo))throw new Error("`"+t+"` cannot be a path: did not expect `"+Yo+"`")}function ni(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ri(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const oi=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},ii={}.hasOwnProperty;class si extends oi{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function o(i,...s){const l=e[++n];let a=-1;if(i)r(i);else{for(;++a<t.length;)null!==s[a]&&void 0!==s[a]||(s[a]=t[a]);t=s,l?function(e,t){let n;return function(...t){const i=e.length>t.length;let s;i&&t.push(r);try{s=e.apply(this,t)}catch(e){if(i&&n)throw e;return r(e)}i||(s&&s.then&&"function"==typeof s.then?s.then(o,r):s instanceof Error?r(s):o(s))};function r(e,...r){n||(n=!0,t(e,...r))}function o(e){r(null,e)}}(l,o)(...s):r(null,...s)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){const e=new si;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(Wo(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(ui("data",this.frozen),this.namespace[e]=t,this):ii.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ui("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=pi(e),n=this.parser||this.Parser;return ai("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),ai("process",this.parser||this.Parser),ci("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,o){const i=pi(e),s=n.parse(i);function l(e,n){e||!n?o(e):r?r(n):t(void 0,n)}n.run(s,i,(function(e,t,r){if(e||!t||!r)return l(e);const o=t,i=n.stringify(o,r);var s;"string"==typeof(s=i)||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(s)?r.value=i:r.result=i,l(e,r)}))}}processSync(e){let t,n=!1;return this.freeze(),ai("processSync",this.parser||this.Parser),ci("processSync",this.compiler||this.Compiler),this.process(e,(function(e,r){n=!0,_o(e),t=r})),hi("processSync","process",n),t}run(e,t,n){di(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?o(void 0,n):new Promise(o);function o(o,i){const s=pi(t);r.run(e,s,(function(t,r,s){const l=r||e;t?i(t):o?o(l):n(void 0,l,s)}))}}runSync(e,t){let n,r=!1;return this.run(e,t,(function(e,t){_o(e),n=t,r=!0})),hi("runSync","run",r),n}stringify(e,t){this.freeze();const n=pi(t),r=this.compiler||this.Compiler;return ci("stringify",r),di(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(ui("use",this.frozen),null==e);else if("function"==typeof e)l(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?s(e):i(e)}return this;function o(e){if("function"==typeof e)l(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;l(t,n)}else i(e)}}function i(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(e.plugins),e.settings&&(r.settings=Wo(!0,r.settings,e.settings))}function s(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;)o(e[t])}}function l(e,t){let r=-1,o=-1;for(;++r<n.length;)if(n[r][0]===e){o=r;break}if(-1===o)n.push([e,...t]);else if(t.length>0){let[r,...i]=t;const s=n[o][1];Vo(s)&&Vo(r)&&(r=Wo(!0,s,r)),n[o]=[e,r,...i]}}}}const li=(new si).freeze();function ai(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function ci(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function ui(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function di(e){if(!Vo(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function hi(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function pi(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new ei(e)}var fi,mi,gi,yi,wi,ki,vi,bi=e=>{throw TypeError(e)},xi=(e,t,n)=>t.has(e)||bi("Cannot "+n),Ci=(e,t,n)=>(xi(e,t,"read from private field"),n?n.call(e):t.get(e)),Si=(e,t,n)=>t.has(e)?bi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Mi=(e,t,n,r)=>(xi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Ni{}class Ti{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{var t;null==(t=this.top())||t.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw L();return e}}}class Oi extends Ni{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,n){return new Oi(e,t,n)}}const Ai=class extends Ti{constructor(e){super(),Si(this,fi),Si(this,mi),Si(this,gi),Si(this,yi),Si(this,wi),Si(this,ki),Si(this,vi),Mi(this,fi,$e.none),Mi(this,mi,(e=>e.isText)),Mi(this,gi,((e,t)=>{if(Ci(this,mi).call(this,e)&&Ci(this,mi).call(this,t)&&$e.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)})),Mi(this,yi,(e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find((t=>t.spec.parseMarkdown.match(e)));if(!t)throw B(e);return t})),Mi(this,wi,(e=>{const t=Ci(this,yi).call(this,e);t.spec.parseMarkdown.runner(this,e,t)})),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Oi.create(e,[],t)),this),Mi(this,ki,(()=>{Mi(this,fi,$e.none);const e=this.close();return Ci(this,vi).call(this,e.type,e.attrs,e.content)})),this.closeNode=()=>(Ci(this,ki).call(this),this),Mi(this,vi,((e,t,n)=>{const r=e.createAndFill(t,n,Ci(this,fi));if(!r)throw $(e,t,n);return this.push(r),r})),this.addNode=(e,t,n)=>(Ci(this,vi).call(this,e,t,n),this),this.openMark=(e,t)=>{const n=e.create(t);return Mi(this,fi,n.addToSet(Ci(this,fi))),this},this.closeMark=e=>(Mi(this,fi,e.removeFromSet(Ci(this,fi))),this),this.addText=e=>{const t=this.top();if(!t)throw L();const n=t.pop(),r=this.schema.text(e,Ci(this,fi));if(!n)return t.push(r),this;const o=Ci(this,gi).call(this,n,r);return o?(t.push(o),this):(t.push(n,r),this)},this.build=()=>{let e;do{e=Ci(this,ki).call(this)}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach((e=>Ci(this,wi).call(this,e))),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{const n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}};fi=new WeakMap,mi=new WeakMap,gi=new WeakMap,yi=new WeakMap,wi=new WeakMap,ki=new WeakMap,vi=new WeakMap,Ai.create=(e,t)=>{const n=new Ai(e);return e=>(n.run(t,e),n.toDoc())};let Ei=Ai;const Ii=class extends Ni{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>{var e;return null==(e=this.children)?void 0:e.pop()}}};Ii.create=(e,t,n,r={})=>new Ii(e,t,n,r);let Ri=Ii;var Di,Pi,$i,Li,Bi,zi,Fi,ji,_i,Wi,Vi,Hi,qi;const Ki=class extends Ti{constructor(e){super(),Si(this,Di),Si(this,Pi),Si(this,$i),Si(this,Li),Si(this,Bi),Si(this,zi),Si(this,Fi),Si(this,ji),Si(this,_i),Si(this,Wi),Si(this,Vi),Si(this,Hi),Si(this,qi),Mi(this,Di,$e.none),Mi(this,Pi,(e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find((t=>t.spec.toMarkdown.match(e)));if(!t)throw z(e.type);return t})),Mi(this,$i,(e=>Ci(this,Pi).call(this,e).spec.toMarkdown.runner(this,e))),Mi(this,Li,((e,t)=>Ci(this,Pi).call(this,e).spec.toMarkdown.runner(this,e,t))),Mi(this,Bi,(e=>{const{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort(((e,t)=>n(e)-n(t))).every((t=>!Ci(this,Li).call(this,t,e)))&&Ci(this,$i).call(this,e),t.forEach((e=>Ci(this,qi).call(this,e)))})),Mi(this,zi,((e,t)=>{var n;if(e.type===t||1!==(null==(n=e.children)?void 0:n.length))return e;const r=e=>{var n;if(e.type===t)return e;if(1!==(null==(n=e.children)?void 0:n.length))return null;const[o]=e.children;return o?r(o):null},o=r(e);if(!o)return e;const i=o.children?[...o.children]:void 0,s={...e,children:i};return s.children=i,o.children=[s],o})),Mi(this,Fi,(e=>{const{children:t}=e;return t&&(e.children=t.reduce(((e,t,n)=>{if(0===n)return[t];const r=e.at(-1);if(r&&r.isMark&&t.isMark){t=Ci(this,zi).call(this,t,r.type);const{children:n,...o}=t,{children:i,...s}=r;if(t.type===r.type&&n&&i&&JSON.stringify(o)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(Ci(this,Fi).call(this,t))}}return e.concat(t)}),[])),e})),Mi(this,ji,(e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t})),this.openNode=(e,t,n)=>(this.open(Ri.create(e,void 0,t,n)),this),Mi(this,_i,((e,t)=>{let n="",r="";const o=e.children;let i=-1,s=-1;if(o){(e=>{e&&e.forEach(((e,t)=>{"text"===e.type&&e.value&&(i<0&&(i=t),s=t)}))})(o);const e=null==o?void 0:o[s],t=null==o?void 0:o[i];e&&e.value.endsWith(" ")&&(r=e.value.match(/ +$/)[0],e.value=e.value.trimEnd()),t&&t.value.startsWith(" ")&&(n=t.value.match(/^ +/)[0],t.value=t.value.trimStart())}n.length&&Ci(this,Vi).call(this,"text",void 0,n);const l=t();return r.length&&Ci(this,Vi).call(this,"text",void 0,r),l})),Mi(this,Wi,((e=!1)=>{const t=this.close(),n=()=>Ci(this,Vi).call(this,t.type,t.children,t.value,t.props);return e?Ci(this,_i).call(this,t,n):n()})),this.closeNode=()=>(Ci(this,Wi).call(this),this),Mi(this,Vi,((e,t,n,r)=>{const o=Ri.create(e,t,n,r),i=Ci(this,Fi).call(this,Ci(this,ji).call(this,o));return this.push(i),i})),this.addNode=(e,t,n,r)=>(Ci(this,Vi).call(this,e,t,n,r),this),Mi(this,Hi,((e,t,n,r)=>e.isInSet(Ci(this,Di))?this:(Mi(this,Di,e.addToSet(Ci(this,Di))),this.openNode(t,n,{...r,isMark:!0})))),Mi(this,qi,(e=>{e.isInSet(Ci(this,Di))&&(Mi(this,Di,e.type.removeFromSet(Ci(this,Di))),Ci(this,Wi).call(this,!0))})),this.withMark=(e,t,n,r)=>(Ci(this,Hi).call(this,e,t,n,r),this),this.closeMark=e=>(Ci(this,qi).call(this,e),this),this.build=()=>{let e=null;do{e=Ci(this,Wi).call(this)}while(this.size());return e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach((e=>{Ci(this,Bi).call(this,e)})),this):(Ci(this,Bi).call(this,e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}};Di=new WeakMap,Pi=new WeakMap,$i=new WeakMap,Li=new WeakMap,Bi=new WeakMap,zi=new WeakMap,Fi=new WeakMap,ji=new WeakMap,_i=new WeakMap,Wi=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,qi=new WeakMap,Ki.create=(e,t)=>{const n=new Ki(e);return e=>(n.run(e),n.toString(t))};let Ui=Ki;const Ji=Math.pow(2,16);function Yi(e,t){return e+t*Ji}function Gi(e){return 65535&e}class Xi{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Zi{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Zi.empty)return Zi.empty}recover(e){let t=0,n=Gi(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Ji}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[s+o],c=this.ranges[s+i],u=l+a;if(e<=u){let o=l+r+((a?e==l?-1:e==u?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?l:u)?null:Yi(s/3,e-l),d=e==l?2:e==u?1:4;return(t<0?e!=l:e!=u)&&(d|=8),new Xi(o,d,i)}r+=c-a}return n?e+r:new Xi(e+r,0,null)}touches(e,t){let n=0,r=Gi(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+o];if(e<=s+l&&t==3*r)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),l=i+(this.inverted?0:o),a=this.ranges[r+t],c=this.ranges[r+n];e(s,s+a,l,l+c),o+=c-a}}invert(){return new Zi(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?Zi.empty:new Zi(e<0?[0,-e,0]:[0,0,e])}}Zi.empty=new Zi([]);class Qi{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new Qi(this.maps,this.mirror,e,t)}copy(){return new Qi(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new Qi;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this.maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new Xi(e,r,null)}}const es=Object.create(null);class ts{getMap(){return Zi.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=es[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in es)throw new RangeError("Duplicate use of step JSON ID "+e);return es[e]=t,t.prototype.jsonID=e,t}}class ns{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ns(e,null)}static fail(e){return new ns(null,e)}static fromReplace(e,t,n,r){try{return ns.ok(e.replace(t,n,r))}catch(e){if(e instanceof Le)return ns.fail(e.message);throw e}}}function rs(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(rs(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return Ie.fromArray(r)}class is extends ts{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new Be(rs(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),r),t.openStart,t.openEnd);return ns.fromReplace(e,this.from,this.to,o)}invert(){return new ss(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new is(t.pos,n.pos,this.mark)}merge(e){return e instanceof is&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new is(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new is(t.from,t.to,e.markFromJSON(t.mark))}}ts.jsonID("addMark",is);class ss extends ts{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Be(rs(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return ns.fromReplace(e,this.from,this.to,n)}invert(){return new is(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ss(t.pos,n.pos,this.mark)}merge(e){return e instanceof ss&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ss(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ss(t.from,t.to,e.markFromJSON(t.mark))}}ts.jsonID("removeMark",ss);class ls extends ts{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ns.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ns.fromReplace(e,this.pos,this.pos+1,new Be(Ie.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new ls(this.pos,t.marks[n]);return new ls(this.pos,this.mark)}}return new as(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ls(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ls(t.pos,e.markFromJSON(t.mark))}}ts.jsonID("addNodeMark",ls);class as extends ts{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ns.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ns.fromReplace(e,this.pos,this.pos+1,new Be(Ie.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ls(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new as(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new as(t.pos,e.markFromJSON(t.mark))}}ts.jsonID("removeNodeMark",as);class cs extends ts{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&ds(e,this.from,this.to)?ns.fail("Structure replace would overwrite content"):ns.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Zi([this.from,this.to-this.from,this.slice.size])}invert(e){return new cs(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new cs(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof cs)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Be.empty:new Be(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new cs(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Be.empty:new Be(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new cs(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new cs(t.from,t.to,Be.fromJSON(e,t.slice),!!t.structure)}}ts.jsonID("replace",cs);class us extends ts{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(ds(e,this.from,this.gapFrom)||ds(e,this.gapTo,this.to)))return ns.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ns.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ns.fromReplace(e,this.from,this.to,n):ns.fail("Content does not fit in gap")}getMap(){return new Zi([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new us(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new us(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new us(t.from,t.to,t.gapFrom,t.gapTo,Be.fromJSON(e,t.slice),t.insert,!!t.structure)}}function ds(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function hs(e,t,n,r=n.contentMatch,o=!0){let i=e.doc.nodeAt(t),s=[],l=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),c=l+a.nodeSize,u=r.matchType(a.type);if(u){r=u;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new ss(l,c,a.marks[t]));if(o&&a.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(a.text);)t||(t=new Be(Ie.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new cs(l+e.index,l+e.index+e[0].length,t))}}else s.push(new cs(l,c,Be.empty));l=c}if(!r.validEnd){let t=r.fillBefore(Ie.empty,!0);e.replace(l,l,new Be(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function ps(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function fs(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!ps(r,o,i))break}return null}function ms(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;l&&e<o;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(r,t);return i?o.map(gs).concat({type:t,attrs:n}).concat(i.map(gs)):null}function gs(e){return{type:e,attrs:null}}function ys(e,t,n,r){t.forEach(((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}}))}function ws(e,t,n,r){t.forEach(((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}}))}function ks(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=r&&r[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function vs(e,t){let n=e.resolve(t),r=n.index();return bs(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function bs(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function xs(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let o,i,s=r.index(e);if(e==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(e+1),s++,i=r.node(e).maybeChild(s)):(o=r.node(e).maybeChild(s-1),i=r.node(e+1)),o&&!o.isTextblock&&bs(o,i)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function Cs(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function Ss(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),l=!1;if(1==e)l=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Ms(e,t,n=t,r=Be.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Ns(o,i,r)?new cs(t,n,r):new Ts(o,i,r).fit()}function Ns(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ts.jsonID("replaceAround",us);class Ts{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Ie.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Ie.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let l=new Be(o,i,s);return e>-1?new us(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new cs(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Es(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:l}=this.frontier[e],a=null;if(1==t&&(o?l.matchType(o.type)||(a=l.fillBefore(Ie.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:a};if(2==t&&o&&(i=l.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&l.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Es(e,t);return!(!r.childCount||r.firstChild.isLeaf||(this.unplaced=new Be(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),0))}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Es(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Be(Os(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Be(Os(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let i=this.unplaced,s=n?n.content:i.content,l=i.openStart-e,a=0,c=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));u=u.matchFragment(r)}let h=s.size+e-(i.content.size-i.openEnd);for(;a<s.childCount;){let e=s.child(a),t=u.matchType(e.type);if(!t)break;a++,(a>1||0==l||e.content.size)&&(u=t,c.push(Is(e.mark(d.allowedMarks(e.marks)),1==a?l:0,a==s.childCount?h:-1)))}let p=a==s.childCount;p||(h=-1),this.placed=As(this.placed,t,Ie.from(c)),this.frontier[t].match=u,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Be.empty:new Be(Os(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Be(Os(i.content,e,a),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Rs(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Rs(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Rs(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=As(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=As(this.placed,this.depth,Ie.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Ie.empty,!0);e.childCount&&(this.placed=As(this.placed,this.frontier.length,e))}}function Os(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Os(e.firstChild.content,t-1,n)))}function As(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(As(e.lastChild.content,t-1,n)))}function Es(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Is(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Is(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Ie.empty,!0)))),e.copy(r)}function Rs(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?l:null}function Ds(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(Ds(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Ie.empty,!0))}return e}function Ps(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class $s extends ts{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return ns.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return ns.fromReplace(e,this.pos,this.pos+1,new Be(Ie.from(r),0,t.isLeaf?0:1))}getMap(){return Zi.empty}invert(e){return new $s(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new $s(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new $s(t.pos,t.attr,t.value)}}ts.jsonID("attr",$s);class Ls extends ts{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return ns.ok(n)}getMap(){return Zi.empty}invert(e){return new Ls(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ls(t.attr,t.value)}}ts.jsonID("docAttr",Ls);let Bs=class extends Error{};Bs=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Bs.prototype=Object.create(Error.prototype),Bs.prototype.constructor=Bs,Bs.prototype.name="TransformError";class zs{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Qi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Bs(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Be.empty){let r=Ms(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Be(Ie.from(n),0,0))}delete(e,t){return this.replace(e,t,Be.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Ns(o,i,r))return e.step(new cs(t,n,r));let s=Ps(o,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:o.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=c[e],n=(d=t.type).spec.defining||d.spec.definingForContent;if(n&&!t.sameMarkup(o.node(Math.abs(l)-1)))u=e;else if(n||!t.type.isTextblock)break}var d;for(let t=r.openStart;t>=0;t--){let l=(t+u+1)%(r.openStart+1),d=c[l];if(d)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],u=!0;c<0&&(u=!1,c=-c);let h=o.node(c-1),p=o.index(c-1);if(h.canReplaceWith(p,p,d.type,d.marks))return e.replace(o.before(c),u?i.after(c):n,new Be(Ds(r.content,0,r.openStart,l),l,r.openEnd))}}let h=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,r),!(e.steps.length>h));l--){let e=s[l];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=Cs(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Be(Ie.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n),i=Ps(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=Ie.empty,d=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=Ie.from(r.node(e).copy(u)),d++):a--;let h=Ie.empty,p=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,h=Ie.from(o.node(e).copy(h)),p++):c++;e.step(new us(a,c,s,l,new Be(u.append(h),d,p),u.size-d,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let l=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);ws(e,r.node(),r.before(),l)}s.inlineContent&&hs(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new cs(c,a.map(t+n,-1),Be.empty,!0)),!0===r){let t=e.doc.resolve(c);ys(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=Ie.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Ie.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new us(o,i,o,i,new Be(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{let s="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&ws(e,t,n,i),hs(e,e.mapping.slice(i).map(n,1),r,void 0,null===o);let l=e.mapping.slice(i),a=l.map(n,1),c=l.map(n+t.nodeSize,1);return e.step(new us(a,c,a+1,c-1,new Be(Ie.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===o&&ys(e,t,n,i),!1}}))}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new us(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Be(Ie.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new $s(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ls(e,t)),this}addNodeMark(e,t){return this.step(new ls(e,t)),this}removeNodeMark(e,t){if(!(t instanceof $e)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new as(e,t)),this}split(e,t=1,n){return function(e,t,n=1,r){let o=e.doc.resolve(t),i=Ie.empty,s=Ie.empty;for(let e=o.depth,t=o.depth-n,l=n-1;e>t;e--,l--){i=Ie.from(o.node(e).copy(i));let t=r&&r[l];s=Ie.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new cs(t,t,new Be(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],l=[];e.doc.nodesBetween(t,n,((e,a,c)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,t),d=Math.min(a+e.nodeSize,n),h=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(u[e])?o.to=d:s.push(o=new ss(c,d,u[e])));i&&i.to==c?i.to=d:l.push(i=new is(c,d,r))}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(r instanceof kt){let t,n=e.marks;for(;t=r.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(l=[r]):l=e.marks;if(l&&l.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&a.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:a,from:Math.max(s,t),to:r,step:i})}}})),o.forEach((t=>e.step(new ss(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return hs(this,e,t,n),this}}const Fs=Object.create(null);class js{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new _s(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Be.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(o);e.replaceRange(c.map(l.pos),c.map(a.pos),s?Be.empty:t),0==s&&Xs(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);o?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),Xs(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Hs(e):Gs(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?Gs(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Gs(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Js(e.node(0))}static atStart(e){return Gs(e,e,0,0,1)||new Js(e)}static atEnd(e){return Gs(e,e,e.content.size,e.childCount,-1)||new Js(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Fs[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Fs)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fs[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Hs.between(this.$anchor,this.$head).getBookmark()}}js.prototype.visible=!0;class _s{constructor(e,t){this.$from=e,this.$to=t}}let Ws=!1;function Vs(e){Ws||e.parent.inlineContent||(Ws=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Hs extends js{constructor(e,t=e){Vs(e),Vs(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return js.near(n);let r=e.resolve(t.map(this.anchor));return new Hs(r.parent.inlineContent?r:n,n)}replace(e,t=Be.empty){if(super.replace(e,t),t==Be.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Hs&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new qs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Hs(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=js.findFrom(t,n,!0)||js.findFrom(t,-n,!0);if(!e)return js.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(js.findFrom(e,-n,!0)||js.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new Hs(e,t)}}js.jsonID("text",Hs);class qs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new qs(e.map(this.anchor),e.map(this.head))}resolve(e){return Hs.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ks extends js{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?js.near(o):new Ks(o)}content(){return new Be(Ie.from(this.node),0,0)}eq(e){return e instanceof Ks&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Us(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ks(e.resolve(t.anchor))}static create(e,t){return new Ks(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Ks.prototype.visible=!1,js.jsonID("node",Ks);class Us{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new qs(n,n):new Us(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Ks.isSelectable(n)?new Ks(t):js.near(t)}}class Js extends js{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Be.empty){if(t==Be.empty){e.delete(0,e.doc.content.size);let t=js.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Js(e)}map(e){return new Js(e)}eq(e){return e instanceof Js}getBookmark(){return Ys}}js.jsonID("all",Js);const Ys={map(){return this},resolve:e=>new Js(e)};function Gs(e,t,n,r,o,i=!1){if(t.inlineContent)return Hs.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Ks.isSelectable(r))return Ks.create(e,n-(o<0?r.nodeSize:0))}else{let t=Gs(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Xs(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof cs||i instanceof us)&&(e.mapping.maps[r].forEach(((e,t,n,r)=>{null==o&&(o=r)})),e.setSelection(js.near(e.doc.resolve(o),n)))}class Zs extends zs{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return $e.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||$e.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(js.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Qs(e,t){return t&&e?e.bind(t):e}class el{constructor(e,t,n){this.name=e,this.init=Qs(t.init,n),this.apply=Qs(t.apply,n)}}const tl=[new el("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new el("selection",{init:(e,t)=>e.selection||js.atStart(t.doc),apply:e=>e.selection}),new el("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new el("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class nl{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=tl.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new el(e.key,e.spec.state,e))}))}}class rl{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=r?r[i].n:0,a=r?r[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new rl(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Zs(this)}static create(e){let t=new nl(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new rl(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new nl(this.schema,e.plugins),n=t.fields,r=new rl(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new nl(e.schema,e.plugins),o=new rl(r);return r.fields.forEach((r=>{if("doc"==r.name)o.doc=tt.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=js.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=l.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}})),o}}function ol(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=ol(o,t,{})),n[r]=o}return n}class il{constructor(e){this.spec=e,this.props={},e.props&&ol(e.props,this,this.props),this.key=e.key?e.key.key:ll("plugin")}getState(e){return e[this.key]}}const sl=Object.create(null);function ll(e){return e in sl?e+"$"+ ++sl[e]:(sl[e]=0,e+"$")}class al{constructor(e="key"){this.key=ll(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}class cl{constructor(e,t,n={}){this.match=e,this.match=e,this.handler="string"==typeof t?function(e){return function(t,n,r,o){let i=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);i+=n[0].slice(e+n[1].length);let t=(r+=e)-o;t>0&&(i=n[0].slice(e-t,e)+i,r=o)}return t.tr.insertText(i,r,o)}}(t):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1}}const ul=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function dl(e,t,n=null,r){return new cl(e,((e,o,i,s)=>{let l=n instanceof Function?n(o):n,a=e.tr.delete(i,s),c=a.doc.resolve(i).blockRange(),u=c&&ms(c,t,l);if(!u)return null;a.wrap(c,u);let d=a.doc.resolve(i-1).nodeBefore;return d&&d.type==t&&vs(a.doc,i-1)&&(!r||r(o,d))&&a.join(i-1),a}))}function hl(e,t,n=null){return new cl(e,((e,r,o,i)=>{let s=e.doc.resolve(o),l=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,l):null}))}new cl(/--$/,"—"),new cl(/\.\.\.$/,"…"),new cl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new cl(/"$/,"”"),new cl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new cl(/'$/,"’");const pl="undefined"!=typeof navigator?navigator:null,fl="undefined"!=typeof document?document:null,ml=pl&&pl.userAgent||"",gl=/Edge\/(\d+)/.exec(ml),yl=/MSIE \d/.exec(ml),wl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ml),kl=!!(yl||wl||gl),vl=yl?document.documentMode:wl?+wl[1]:gl?+gl[1]:0,bl=!kl&&/gecko\/(\d+)/i.test(ml),xl=bl&&+(/Firefox\/(\d+)/.exec(ml)||[0,0])[1],Cl=!kl&&/Chrome\/(\d+)/.exec(ml),Sl=!!Cl,Ml=Cl?+Cl[1]:0,Nl=!kl&&!!pl&&/Apple Computer/.test(pl.vendor),Tl=Nl&&(/Mobile\/\w+/.test(ml)||!!pl&&pl.maxTouchPoints>2),Ol=Tl||!!pl&&/Mac/.test(pl.platform),Al=/Android \d/.test(ml),El=!!fl&&"webkitFontSmoothing"in fl.documentElement.style,Il=El?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var Rl=Object.freeze({__proto__:null,android:Al,chrome:Sl,chrome_version:Ml,gecko:bl,gecko_version:xl,ie:kl,ie_version:vl,ios:Tl,mac:Ol,safari:Nl,webkit:El,webkit_version:Il});function Dl(e,t,n,r,o,i){var s;if(e.composing)return!1;const l=e.state,a=l.doc.resolve(t);if(a.parent.type.spec.code)return!1;const c=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a=0;a<o.length;a++){const u=o[a].match.exec(c),d=u&&u[0]&&o[a].handler(l,u,t-(u[0].length-r.length),n);if(d)return!1!==(null==(s=o[a])?void 0:s.undoable)&&d.setMeta(i,{transform:d,from:t,to:n,text:r}),e.dispatch(d),!0}return!1}const Pl=new al("MILKDOWN_CUSTOM_INPUTRULES");function $l({rules:e}){const t=new il({key:Pl,isInputRules:!0,state:{init:()=>null,apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>Dl(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout((()=>{const{$cursor:r}=n.state.selection;r&&Dl(n,r.pos,r.pos,"",e,t)})),!1)},handleKeyDown(n,r){if("Enter"!==r.key)return!1;const{$cursor:o}=n.state.selection;return!!o&&Dl(n,o.pos,o.pos,"\n",e,t)}}});return t}function Ll(e,t,n={}){return new cl(e,((e,r,o,i)=>{var s,l,a,c;const{tr:u}=e;let d=r[r.length-1],h=r[0],p=[],f=i;const m={group:d,fullMatch:h,start:o,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:d,fullMatch:h,start:o,end:i}=m),null===h)return null;if(""===(null==d?void 0:d.trim()))return null;if(d){const e=h.search(/\S/),s=o+h.indexOf(d),m=s+d.length;p=null!=(l=u.storedMarks)?l:[],m<i&&u.delete(m,i),s>o&&u.delete(o+e,s),f=o+e+d.length;const g=null==(a=n.getAttr)?void 0:a.call(n,r);u.addMark(o,f,t.create(g)),u.setStoredMarks(p),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:o,end:i,tr:u})}return u}))}function Bl(e,t,n={}){return new cl(e,((e,r,o,i)=>{var s,l,a;const{tr:c}=e;let u=r[1],d=r[0];const h={group:u,fullMatch:d,start:o,end:i},p=null==(s=n.updateCaptured)?void 0:s.call(n,h);if(Object.assign(h,p),({group:u,fullMatch:d,start:o,end:i}=h),null===d)return null;if(!u||""===u.trim())return null;const f=null==(l=n.getAttr)?void 0:l.call(n,r),m=t.createAndFill(f);return m&&(c.replaceRangeWith(t.isBlock?c.doc.resolve(o).before():o,i,m),null==(a=n.beforeDispatch)||a.call(n,{match:[d,null!=u?u:""],start:o,end:i,tr:c})),c}))}var zl=Object.defineProperty,Fl=Object.defineProperties,jl=Object.getOwnPropertyDescriptors,_l=Object.getOwnPropertySymbols,Wl=Object.prototype.hasOwnProperty,Vl=Object.prototype.propertyIsEnumerable,Hl=(e,t,n)=>t in e?zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ql=(e,t)=>{for(var n in t||(t={}))Wl.call(t,n)&&Hl(e,n,t[n]);if(_l)for(var n of _l(t))Vl.call(t,n)&&Hl(e,n,t[n]);return e},Kl=(e,t)=>Fl(e,jl(t));function Ul(e,t,n){const r=e.state,{from:o}=r.selection,{node:i}=e.domAtPos(o),s=i instanceof Text?i.parentElement:i;if(!(s instanceof HTMLElement))throw j(s);const l=s.getBoundingClientRect(),a=t.getBoundingClientRect(),c=t.parentElement;if(!c)throw j(c);const u=c.getBoundingClientRect(),[d,h]=n(l,a,u);t.style.top=`${d}px`,t.style.left=`${h}px`}function Jl(e,t,n){const r=e.state,{from:o,to:i}=r.selection,s=e.coordsAtPos(o),l=e.coordsAtPos(i),a=t.getBoundingClientRect(),c=t.parentElement;if(!c)throw new E(A.missingRootElement,"Missing root element, milkdown cannot find root element of the editor.");const u=c.getBoundingClientRect(),[d,h]=n(s,l,a,u);t.style.top=`${d}px`,t.style.left=`${h}px`}function Yl(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Gl(e,t,n){const r=e.state.doc.content.size,o=Yl(t,0,r),i=Yl(n,0,r),s=e.coordsAtPos(o),l=e.coordsAtPos(i,-1),a=Math.min(s.top,l.top),c=Math.max(s.bottom,l.bottom),u=Math.min(s.left,l.left),d=Math.max(s.right,l.right),h={top:a,bottom:c,left:u,right:d,width:d-u,height:c-a,x:u,y:a};return Kl(ql({},h),{toJSON:()=>h})}function Xl(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function Zl(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}function Ql(e,t=!0){const n=[];return e.descendants(((e,r)=>{if(n.push({node:e,pos:r}),!t)return!1})),n}function ea(e){return(t,n)=>Ql(t,n).filter((t=>e(t.node)))}function ta(e,t,n){return ea((e=>Boolean(t.isInSet(e.marks))))(e,n)}function na(e){return t=>{for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{from:t.before(n),to:t.after(n),node:r}}}}function ra(e,t){return na((e=>e.type===t))(e)}function oa(e,t){const n=t.nodes[e];if(!n)throw F("node",e);return n}function ia(e,t){const n=t.marks[e];if(!n)throw F("mark",e);return n}function sa(e){return t=>{for(let n=t.depth;n>0;n--){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}}function la(e){return t=>sa(e)(t.$from)}function aa(e,t){if(!(e instanceof Ks))return;const{node:n,$from:r}=e;return Zl(t,n)?{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}:void 0}const ca=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);const ua=(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}(e,n);if(!r)return!1;let o=pa(r);if(!o){let n=r.blockRange(),o=n&&fs(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(ya(e,o,t,-1))return!0;if(0==r.parent.content.size&&(da(i,"end")||Ks.isSelectable(i)))for(let n=r.depth;;n--){let s=Ms(e.doc,r.before(n),r.after(n),Be.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(da(i,"end")?js.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Ks.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),0))};function da(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const ha=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=pa(r)}let s=i&&i.nodeBefore;return!(!s||!Ks.isSelectable(s)||(t&&t(e.tr.setSelection(Ks.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function pa(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fa(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function ma(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var ga;function ya(e,t,n,r){let o,i,s=t.nodeBefore,l=t.nodeAfter,a=s.type.spec.isolating||l.type.spec.isolating;if(!a&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!vs(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!a&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(l.type))&&i.matchType(o[0]||l.type).validEnd){if(n){let r=t.pos+l.nodeSize,i=Ie.empty;for(let e=o.length-1;e>=0;e--)i=Ie.from(o[e].create(null,i));i=Ie.from(s.copy(i));let a=e.tr.step(new us(t.pos-1,r,t.pos,r,new Be(i,1,0),o.length,!0)),c=a.doc.resolve(r+2*o.length);c.nodeAfter&&c.nodeAfter.type==s.type&&vs(a.doc,c.pos)&&a.join(c.pos),n(a.scrollIntoView())}return!0}let u=l.type.spec.isolating||r>0&&a?null:js.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),h=d&&fs(d);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(d,h).scrollIntoView()),!0;if(c&&da(l,"start",!0)&&da(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=l,a=1;for(;!i.isTextblock;i=i.firstChild)a++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=Ie.empty;for(let e=o.length-1;e>=0;e--)r=Ie.from(o[e].copy(r));n(e.tr.step(new us(t.pos-o.length,t.pos+l.nodeSize,t.pos+a,t.pos+l.nodeSize-a,new Be(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function wa(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(Hs.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const ka=wa(-1),va=wa(1);function ba(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&ms(s,e,t);return!!l&&(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0)}}function xa(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,((r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}}))}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function Ca(e,t=null,n){let r=!1!==(n&&n.removeWhenPresent),o=!1!==(n&&n.enterInlineAtoms);return function(n,i){let{empty:s,$cursor:l,ranges:a}=n.selection;if(s&&!l||!function(e,t,n,r){for(let o=0;o<t.length;o++){let{$from:i,$to:s}=t[o],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,((e,t)=>{if(l||!r&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return!0}return!1}(n.doc,a,e,o))return!1;if(i)if(l)e.isInSet(n.storedMarks||l.marks())?i(n.tr.removeStoredMark(e)):i(n.tr.addStoredMark(e.create(t)));else{let s,l=n.tr;o||(a=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:o}=e[n];r.doc.nodesBetween(r.pos,o.pos,((e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=o.pos)return n+1>r.pos&&t.push(new _s(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1})),r.pos<o.pos&&t.push(new _s(r,o))}return t}(a)),s=r?!a.some((t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e))):!a.every((t=>{let n=!1;return l.doc.nodesBetween(t.$from.pos,t.$to.pos,((r,o,i)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!i&&i.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-o),Math.min(r.nodeSize,t.$to.pos-o))))})),!n}));for(let n=0;n<a.length;n++){let{$from:r,$to:o}=a[n];if(s){let n=r.pos,i=o.pos,s=r.nodeAfter,a=o.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,u=a&&a.isText?/\s*$/.exec(a.text)[0].length:0;n+c<i&&(n+=c,i-=u),l.addMark(n,i,e.create(t))}else l.removeMark(r.pos,o.pos,e)}i(l.scrollIntoView())}return!0}}function Sa(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let Ma=Sa(ca,ua,ha),Na=Sa(ca,((e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!r)return!1;let o=fa(r);if(!o)return!1;let i=o.nodeAfter;if(ya(e,o,t,1))return!0;if(0==r.parent.content.size&&(da(i,"start")||Ks.isSelectable(i))){let n=Ms(e.doc,r.before(),r.after(),Be.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(da(i,"start")?js.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Ks.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))}),((e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=fa(r)}let s=i&&i.nodeAfter;return!(!s||!Ks.isSelectable(s)||(t&&t(e.tr.setSelection(Ks.create(e.doc,i.pos)).scrollIntoView()),0))}));const Ta={Enter:Sa(((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))}),((e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Js||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=ma(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(Hs.create(s.doc,n+1)),t(s.scrollIntoView())}return!0}),((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(ks(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&fs(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)}),((e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Ks&&e.selection.node.isBlock)return!(!n.parentOffset||!ks(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let o,i,s=[],l=!1,a=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){l=n.end(e)==n.pos+(n.depth-e),a=n.start(e)==n.pos-(n.depth-e),i=ma(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));let t=ga;s.unshift(t||(l&&i?{type:i}:null)),o=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof Hs||e.selection instanceof Js)&&c.deleteSelection();let u=c.mapping.map(n.pos),d=ks(c.doc,u,s.length,s);if(d||(s[0]=i?{type:i}:null,d=ks(c.doc,u,s.length,s)),c.split(u,s.length,s),!l&&a&&n.node(o).type!=i){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);i&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(o)),i)}return t&&t(c.scrollIntoView()),!0})),"Mod-Enter":(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=ma(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(js.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},Backspace:Ma,"Mod-Backspace":Ma,"Shift-Backspace":Ma,Delete:Na,"Mod-Delete":Na,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Js(e.doc))),!0)},Oa={"Ctrl-h":Ta.Backspace,"Alt-Backspace":Ta["Mod-Backspace"],"Ctrl-d":Ta.Delete,"Ctrl-Alt-Backspace":Ta["Mod-Delete"],"Alt-Delete":Ta["Mod-Delete"],"Alt-d":Ta["Mod-Delete"],"Ctrl-a":ka,"Ctrl-e":va};for(let e in Ta)Oa[e]=Ta[e];const Aa=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?Oa:Ta;for(var Ea={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ia={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ra="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Da="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Pa=0;Pa<10;Pa++)Ea[48+Pa]=Ea[96+Pa]=String(Pa);for(Pa=1;Pa<=24;Pa++)Ea[Pa+111]="F"+Pa;for(Pa=65;Pa<=90;Pa++)Ea[Pa]=String.fromCharCode(Pa+32),Ia[Pa]=String.fromCharCode(Pa);for(var $a in Ea)Ia.hasOwnProperty($a)||(Ia[$a]=Ea[$a]);const La="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Ba(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);La?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function za(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Fa(e){return new il({props:{handleKeyDown:ja(e)}})}function ja(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Ba(n)]=e[n];return t}(e);return function(e,n){let r,o=function(e){var t=!(Ra&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Da&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Ia:Ea)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[za(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=t[za(o,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=Ea[n.keyCode])&&r!=o){let o=t[za(r,n)];if(o&&o(e.state,e.dispatch,e))return!0}}return!1}}const _a=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Wa=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Va=null;const Ha=function(e,t,n){let r=Va||(Va=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},qa=function(e,t,n,r){return n&&(Ua(e,t,n,r,-1)||Ua(e,t,n,r,1))},Ka=/^(img|br|input|textarea|hr)$/i;function Ua(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Ja(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Ya(e)||Ka.test(e.nodeName)||"false"==e.contentEditable)return!1;t=_a(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?Ja(e):0}}}function Ja(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ya(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Ga=function(e){return e.focusNode&&qa(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Xa(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Za="undefined"!=typeof navigator?navigator:null,Qa="undefined"!=typeof document?document:null,ec=Za&&Za.userAgent||"",tc=/Edge\/(\d+)/.exec(ec),nc=/MSIE \d/.exec(ec),rc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ec),oc=!!(nc||rc||tc),ic=nc?document.documentMode:rc?+rc[1]:tc?+tc[1]:0,sc=!oc&&/gecko\/(\d+)/i.test(ec);sc&&(/Firefox\/(\d+)/.exec(ec)||[0,0])[1];const lc=!oc&&/Chrome\/(\d+)/.exec(ec),ac=!!lc,cc=lc?+lc[1]:0,uc=!oc&&!!Za&&/Apple Computer/.test(Za.vendor),dc=uc&&(/Mobile\/\w+/.test(ec)||!!Za&&Za.maxTouchPoints>2),hc=dc||!!Za&&/Mac/.test(Za.platform),pc=!!Za&&/Win/.test(Za.platform),fc=/Android \d/.test(ec),mc=!!Qa&&"webkitFontSmoothing"in Qa.documentElement.style,gc=mc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yc(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function wc(e,t){return"number"==typeof e?e:e[t]}function kc(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function vc(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=Wa(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,l=n?yc(i):kc(e),a=0,c=0;if(t.top<l.top+wc(r,"top")?c=-(l.top-t.top+wc(o,"top")):t.bottom>l.bottom-wc(r,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+wc(o,"top")-l.top:t.bottom-l.bottom+wc(o,"bottom")),t.left<l.left+wc(r,"left")?a=-(l.left-t.left+wc(o,"left")):t.right>l.right-wc(r,"right")&&(a=t.right-l.right+wc(o,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function bc(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Wa(r));return t}function xc(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Cc=null;function Sc(e,t){let n,r,o,i,s=2e8,l=0,a=t.top,c=t.top;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(1==u.nodeType)e=u.getClientRects();else{if(3!=u.nodeType)continue;e=Ha(u).getClientRects()}for(let h=0;h<e.length;h++){let p=e[h];if(p.top<=a&&p.bottom>=c){a=Math.max(p.bottom,a),c=Math.min(p.top,c);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=u,s=e,r=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==u.nodeType&&e&&(l=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=u,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(l=d+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=Ac(r,1);if(n.top!=n.bottom&&Mc(t,n))return{node:e,offset:o+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:l}:Sc(n,r)}function Mc(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Nc(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(Mc(t,o))return Nc(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function Tc(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ja(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ja(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,l=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Mc(t,n))return null;if(l=Nc(e.dom,t,n),!l)return null}if(uc)for(let e=l;n&&e;e=Wa(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(sc&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;mc&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&(!i&&t.left>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=Sc(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Oc(e){return e.top<e.bottom||e.left<e.right}function Ac(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Oc(e))return e}return Array.prototype.find.call(n,Oc)||e.getBoundingClientRect()}const Ec=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ic(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=mc||sc;if(3==r.nodeType){if(!s||!Ec.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,Rc(Ac(Ha(r,e,t),i),i<0)}{let e=Ac(Ha(r,o,o),n);if(sc&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Ac(Ha(r,o-1,o-1),-1);if(t.top==e.top){let n=Ac(Ha(r,o,o+1),-1);if(n.top!=e.top)return Rc(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==Ja(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Dc(e.getBoundingClientRect(),!1)}if(null==i&&o<Ja(r)){let e=r.childNodes[o];if(1==e.nodeType)return Dc(e.getBoundingClientRect(),!0)}return Dc(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==Ja(r))){let e=r.childNodes[o-1],t=3==e.nodeType?Ha(e,Ja(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Rc(Ac(t,1),!1)}if(null==i&&o<Ja(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Ha(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Rc(Ac(t,-1),!0)}return Rc(Ac(3==r.nodeType?Ha(r):r,-n),n>=0)}function Rc(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Dc(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Pc(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const $c=/[\u0590-\u08ac]/;let Lc=null,Bc=null,zc=!1;class Fc{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>_a(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=this.children[n],i=t+o.size;if(i>e||o instanceof Kc){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof jc&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?_a(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?_a(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==r&&e<=l){let o=i+n.border;if(e>=o&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=_a(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=_a(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(o>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,r);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),u=!1;if((sc||uc)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(u=!(!t||"\n"!=e.nodeValue[t-1]),u&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:_a(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(sc&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||u&&uc)&&qa(s.node,s.offset,c.anchorNode,c.anchorOffset)&&qa(l.node,l.offset,c.focusNode,c.focusOffset))return;let d=!1;if((a.extend||e==t)&&!u){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),d=!0}catch(e){}}if(!d){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class jc extends Fc{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class _c extends Fc{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Wc extends Fc{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=Rt.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Wc(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Wc.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=iu(o,t,i,n)),e>0&&(o=iu(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Vc extends Fc{constructor(e,t,n,r,o,i,s,l,a){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,l=o.nodeViews[t.type.name],a=l&&l(t,o,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,r),c=a&&a.dom,u=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Rt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:u}=e)}u||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=eu(c,n,t),a?s=new Uc(e,t,n,r,c,u||null,d,a,o,i+1):t.isText?new qc(e,t,n,r,c,d,o):new Vc(e,t,n,r,c,u||null,d,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ie.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&tu(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,l=new ru(this,i&&i.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d,h,p;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(u?(d||(d=[u])).push(e):u=e)}if(u)if(d){d.sort(ou);for(let e=0;e<d.length;e++)n(d[e],c,!!a)}else n(u,c,!!a);if(a)p=-1,h=a,a=null;else{if(!(c<e.childCount))break;p=c,h=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=h.cut(e-i),h=h.cut(0,e-i),f=e,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(h,h.isInline&&!h.isLeaf?l.filter((e=>!e.inline)):l.slice(),t.forChild(i,h),p),i=f}}(this.node,this.innerDeco,((t,o,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&l.syncToMarks(o==this.node.childCount?$e.none:this.node.child(o).marks,n,e),l.placeWidget(t,e,r)}),((t,i,a,c)=>{let u;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(t,i,a,u,e)||l.updateNextNode(t,i,a,e,c,r)||l.addNode(t,i,a,e,r),r+=t.nodeSize})),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Jc(this.contentDOM,this.children,e),dc&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Hs)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new _c(this,o,t,r);e.input.compositionNodes.push(i),this.children=iu(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,r),0))}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(tu(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Zc(this.dom,this.nodeDOM,Xc(this.outerDeco,this.node,t),Xc(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Hc(e,t,n,r,o){eu(r,t,e);let i=new Vc(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class qc extends Vc{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,0))}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new qc(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Kc extends Fc{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Uc extends Vc{constructor(e,t,n,r,o,i,s,l,a,c){super(e,t,n,r,o,i,s,a,c),this.spec=l}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Jc(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=nu(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Wc){let t=r?r.previousSibling:e.lastChild;Jc(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=nu(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const Yc=function(e){e&&(this.nodeName=e)};Yc.prototype=Object.create(null);const Gc=[new Yc];function Xc(e,t,n){if(0==e.length)return Gc;let r=n?Gc[0]:new Yc,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Yc(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new Yc(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Zc(e,t,n,r){if(n==Gc&&r==Gc)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=Gc[0]),o=t}Qc(o,s||Gc[0],i)}return o}function Qc(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function eu(e,t,n){return Zc(e,e,Gc,Xc(t,n,1!=e.nodeType))}function tu(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function nu(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ru{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Wc)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let r=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Wc.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Vc){let a=this.preMatch.matched.get(l);if(null!=a&&a!=o)return!1;let c,u=l.dom,d=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&tu(t,l.outerDeco));if(!d&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(l,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!tu(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=Vc.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=Vc.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new jc(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Wc;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof qc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((uc||ac)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Kc(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function ou(e,t){return e.type.side-t.type.side}function iu(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,u=l+=a.size;c>=n||u<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function su(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=r.resolve(s);if(Ga(n)){for(l=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&Ks.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==Ja(e);r||o;){if(e==n)return!0;let t=_a(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Ja(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;a=new Ks(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);return a||(a=mu(e,u,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),a}function lu(e){return e.editable?e.hasFocus():yu(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function au(e,t=!1){let n=e.state.selection;if(pu(e,n),lu(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&ac){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&qa(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange();if(!t)return;let r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setStart(r.parentNode,_a(r)+1):n.setStart(r,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&oc&&ic<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!cu||n instanceof Hs||(n.$from.parent.inlineContent||(r=uu(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=uu(e,n.to))),e.docView.setSelection(i,s,e,t),cu&&(r&&hu(r),o&&hu(o)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{lu(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const cu=uc||ac&&cc<63;function uu(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(uc&&o&&"false"==o.contentEditable)return du(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return du(o);if(i)return du(i)}}function du(e){return e.contentEditable="true",uc&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function hu(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function pu(e,t){if(t instanceof Ks){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(fu(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else fu(e)}function fu(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function mu(e,t,n,r){return e.someProp("createSelectionBetween",(r=>r(e,t,n)))||Hs.between(t,n,r)}function gu(e){return!(e.editable&&!e.hasFocus())&&yu(e)}function yu(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function wu(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&js.findFrom(i,t)}function ku(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function vu(e,t,n){let r=e.state.selection;if(!(r instanceof Hs)){if(r instanceof Ks&&r.node.isInline)return ku(e,new Hs(t>0?r.$to:r.$from));{let n=wu(e.state,t);return!!n&&ku(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return ku(e,new Hs(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=wu(e.state,t);return!!(n&&n instanceof Ks)&&ku(e,n)}if(!(hc&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Ks.isSelectable(i)?ku(e,new Ks(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!mc&&ku(e,new Hs(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function bu(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function xu(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Cu(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(sc&&1==n.nodeType&&r<bu(n)&&xu(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(xu(e,-1))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Su(n))break;{let t=n.previousSibling;for(;t&&xu(t,-1);)o=n.parentNode,i=_a(t),t=t.previousSibling;if(t)n=t,r=bu(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Mu(e,n,r):o&&Mu(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=bu(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!xu(n.childNodes[r],1))break;o=n,i=++r}else{if(Su(n))break;{let t=n.nextSibling;for(;t&&xu(t,1);)o=t.parentNode,i=_a(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=bu(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&Mu(e,o,i)}(e)}function Su(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Mu(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Ya(e);)t=_a(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Ya(e);)t=_a(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Ga(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout((()=>{e.state==o&&au(e)}),50)}function Nu(e,t){let n=e.state.doc.resolve(t);if(!ac&&!pc&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Tu(e,t,n){let r=e.state.selection;if(r instanceof Hs&&!r.empty||n.indexOf("s")>-1)return!1;if(hc&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=wu(e.state,t);if(n&&n instanceof Ks)return ku(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Js?js.near(n,t):js.findFrom(n,t);return!!s&&ku(e,s)}return!1}function Ou(e,t){if(!(e.state.selection instanceof Hs))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Au(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Eu(e,t){e.someProp("transformCopied",(n=>{t=n(t,e)}));let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||Rt.fromSchema(e.state.schema),l=ju(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c,u=a.firstChild,d=0;for(;u&&1==u.nodeType&&(c=zu[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),d++}u=a.firstChild}return u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Iu(e,t,n,r,o){let i,s,l=o.parent.type.spec.code;if(!n&&!t)return null;let a=t&&(r||l||!n);if(a){if(e.someProp("transformPastedText",(n=>{t=n(t,l||r,e)})),l)return t?new Be(Ie.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):Be.empty;let n=e.someProp("clipboardTextParser",(n=>n(t,o,r,e)));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=Rt.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))}))}}else e.someProp("transformPastedHTML",(t=>{n=t(n,e)})),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=ju().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);if((n=o&&zu[o[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join("")),r.innerHTML=function(e){let t=window.trustedTypes;return t?(_u||(_u=t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),_u.createHTML(e)):e}(e),n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),mc&&function(e){let t=e.querySelectorAll(ac?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||xt.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!a&&!u),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ru.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=Ie.from(t.create(n[e+1],o)),i++,s++}return new Be(o,i,s)}(Bu(s,+u[1],+u[2]),u[4]);else if(s=Be.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach((e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&Pu(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=$u(i[i.length-1],r.length));let t=Du(e,n);i.push(t),o=o.matchType(t.type),r=n}})),i)return Ie.from(i)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=Bu(s,e,t)}return e.someProp("transformPasted",(t=>{s=t(s,e)})),s}const Ru=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Du(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Ie.from(e));return e}function Pu(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Pu(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(Ie.from(Du(n,e,o+1))))}}function $u(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,$u(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Ie.empty,!0);return e.copy(n.append(r))}function Lu(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,l=s.content;return e.childCount>1&&(i=0),o<r-1&&(l=Lu(l,t,n,r,o+1,i)),o>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(Ie.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function Bu(e,t,n){return t<e.openStart&&(e=new Be(Lu(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Be(Lu(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const zu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Fu=null;function ju(){return Fu||(Fu=document.implementation.createHTMLDocument("title"))}let _u=null;const Wu={},Vu={},Hu={touchstart:!0,touchmove:!0};class qu{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ku(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Uu(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Ju(e,t))}))}function Ju(e,t){return e.someProp("handleDOMEvents",(n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function Yu(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Gu(e){return{left:e.clientX,top:e.clientY}}function Xu(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,(t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1))))return!0;return!1}function Zu(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function Qu(e,t,n,r){return Xu(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(n=>n(e,t,r)))}function ed(e,t,n,r){return Xu(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(n=>n(e,t,r)))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Zu(e,Hs.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),i=o.before(t);if(n.inlineContent)Zu(e,Hs.create(r,i+1,i+1+n.content.size),"pointer");else{if(!Ks.isSelectable(n))continue;Zu(e,Ks.create(r,i),"pointer")}return!0}}(e,n,r)}function td(e){return ad(e)}Vu.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!od(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!fc||!ac||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!dc||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||function(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||hc&&72==n&&"c"==r)return Ou(e,-1)||Cu(e,-1);if(46==n&&!t.shiftKey||hc&&68==n&&"c"==r)return Ou(e,1)||Cu(e,1);if(13==n||27==n)return!0;if(37==n||hc&&66==n&&"c"==r){let t=37==n?"ltr"==Nu(e,e.state.selection.from)?-1:1:-1;return vu(e,t,r)||Cu(e,t)}if(39==n||hc&&70==n&&"c"==r){let t=39==n?"ltr"==Nu(e,e.state.selection.from)?1:-1:1;return vu(e,t,r)||Cu(e,t)}return 38==n||hc&&80==n&&"c"==r?Tu(e,-1,r)||Cu(e,-1):40==n||hc&&78==n&&"c"==r?function(e){if(!uc||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Au(e,n,"true"),setTimeout((()=>Au(e,n,"false")),20)}return!1}(e)||Tu(e,1,r)||Cu(e,1):r==(hc?"m":"c")&&(66==n||73==n||89==n||90==n)}(e,n)?n.preventDefault():Ku(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,Xa(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},Vu.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Vu.keypress=(e,t)=>{let n=t;if(od(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||hc&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Hs&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode);/[\r\n]/.test(t)||e.someProp("handleTextInput",(n=>n(e,r.$from.pos,r.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const nd=hc?"metaKey":"ctrlKey";Wu.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=td(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[nd]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(Gu(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new rd(e,s,n,!!r)):("doubleClick"==i?Qu:ed)(e,s.pos,s.inside,n)?n.preventDefault():Ku(e,"pointer"))};class rd{constructor(e,t,n,r){let o,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[nd],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:a}=e.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||a instanceof Ks&&a.from<=i&&a.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!sc||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ku(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>au(this.view))),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Gu(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ku(this.view,"pointer"):function(e,t,n,r,o){return Xu(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(n=>n(e,t,r)))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Ks&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(Ks.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Zu(e,Ks.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Ks.isSelectable(r))&&(Zu(e,new Ks(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||uc&&this.mightDrag&&!this.mightDrag.node.isAtom||ac&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Zu(this.view,js.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ku(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ku(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function od(e,t){return!!e.composing||!!(uc&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Wu.touchstart=e=>{e.input.lastTouch=Date.now(),td(e),Ku(e,"pointer")},Wu.touchmove=e=>{e.input.lastTouch=Date.now(),Ku(e,"pointer")},Wu.contextmenu=e=>td(e);const id=fc?5e3:-1;function sd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>ad(e)),t))}function ld(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ad(e,t=!1){if(!(fc&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ld(e),t||e.docView&&e.docView.dirty){let n=su(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||e.state.selection.empty?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Vu.compositionstart=Vu.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Hs&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),ad(e,!0),e.markCursor=null;else if(ad(e,!t.selection.empty),sc&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}sd(e,id)},Vu.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,sd(e,20))};const cd=oc&&ic<15||dc&&gc<604;function ud(e,t,n,r,o){let i=Iu(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,o,i||Be.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function dd(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Wu.copy=Vu.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=cd?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Eu(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Vu.paste=(e,t)=>{let n=t;if(e.composing&&!fc)return;let r=cd?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ud(e,dd(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ud(e,r.value,null,o,t):ud(e,r.textContent,r.innerHTML,o,t)}),50)}(e,n)};class hd{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const pd=hc?"altKey":"ctrlKey";Wu.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Gu(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Ks?i.to-1:i.to));else if(r&&r.mightDrag)o=Ks.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Ks.create(e.state.doc,t.posBefore))}let l=(o||e.state.selection).content(),{dom:a,text:c,slice:u}=Eu(e,l);(!n.dataTransfer.files.length||!ac||cc>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(cd?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",cd||n.dataTransfer.setData("text/plain",c),e.dragging=new hd(u,!n[pd],o)},Wu.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},Vu.dragover=Vu.dragenter=(e,t)=>t.preventDefault(),Vu.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let o=e.posAtCoords(Gu(n));if(!o)return;let i=e.state.doc.resolve(o.pos),s=r&&r.slice;s?e.someProp("transformPasted",(t=>{s=t(s,e)})):s=Iu(e,dd(n.dataTransfer),cd?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!r||n[pd]);if(e.someProp("handleDrop",(t=>t(e,n,s||Be.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?Ss(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=e.state.tr;if(l){let{node:e}=r;e?e.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,h=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(h))return;let p=c.doc.resolve(u);if(d&&Ks.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Ks(p));else{let t=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,r,o)=>t=o)),c.setSelection(mu(e,p,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Wu.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&au(e)}),20))},Wu.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Wu.beforeinput=(e,t)=>{if(ac&&fc&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,Xa(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in Vu)Wu[e]=Vu[e];function fd(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class md{constructor(e,t){this.toDOM=e,this.spec=t||vd,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new wd(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof md&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&fd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class gd{constructor(e,t){this.attrs=e,this.spec=t||vd}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new wd(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof gd&&fd(this.attrs,e.attrs)&&fd(this.spec,e.spec)}static is(e){return e.type instanceof gd}destroy(){}}class yd{constructor(e,t){this.attrs=e,this.spec=t||vd}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new wd(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof yd&&fd(this.attrs,e.attrs)&&fd(this.spec,e.spec)}destroy(){}}class wd{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new wd(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new wd(e,e,new md(t,n))}static inline(e,t,n,r){return new wd(e,t,new gd(n,r))}static node(e,t,n,r){return new wd(e,t,new yd(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof gd}get widget(){return this.type instanceof md}}const kd=[],vd={};class bd{constructor(e,t){this.local=e.length?e:kd,this.children=t.length?t:kd}static create(e,t){return t.length?Td(t,e,0,vd):xd}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==xd||0==e.maps.length?this:this.mapInner(e,t,0,0,n||vd)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,r);l&&l.type.valid(t,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach(((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<l.length;o+=3){let i=l[o+1];if(i<0||e>i+t-r)continue;let a=l[o]+t-r;n>=a?l[o+1]=e<=a?-2:-1:e>=t&&s&&(l[o]+=s,l[o+1]+=s)}r+=s})),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),u=c-o;if(u<0||u>=r.content.size){a=!0;continue}let d=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(u),f=r.maybeChild(h);if(f&&p==u&&p+f.nodeSize==d){let r=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=xd?(l[t]=u,l[t+1]=d,l[t+2]=r):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,r,o,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,o,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,o,i,s),c=Td(a,r,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new bd(t.sort(Od),l)}(this.children,i||[],e,t,n,r,o):i?new bd(i.sort(Od),kd):xd}add(e,t){return t.length?this==xd?bd.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach(((e,i)=>{let s,l=i+n;if(s=Md(t,e,l)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,l+1):r.splice(o,0,i,i+e.nodeSize,Td(s,e,l+1,vd)),o+=3}}));let i=Sd(o?Nd(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new bd(i.length?this.local.concat(i).sort(Od):this.local,r||this.children)}remove(e){return 0==e.length||this==xd?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(o,i+1);l!=xd?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new bd(r,n):xd}forChild(e,t){if(this==xd)return this;if(t.isLeaf)return bd.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof gd){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new bd(r.sort(Od),kd);return n?new Cd([e,n]):e}return n||xd}eq(e){if(this==e)return!0;if(!(e instanceof bd)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ad(this.localsInner(e))}localsInner(e){if(this==xd)return kd;if(e.inlineContent||!this.local.some(gd.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof gd||t.push(this.local[e]);return t}forEachSet(e){e(this)}}bd.empty=new bd([],[]),bd.removeOverlap=Ad;const xd=bd.empty;class Cd{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,vd)));return Cd.from(n)}forChild(e,t){if(t.isLeaf)return bd.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=xd&&(o instanceof Cd?n=n.concat(o.members):n.push(o))}return Cd.from(n)}eq(e){if(!(e instanceof Cd)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Ad(n?t:t.sort(Od)):kd}static from(e){switch(e.length){case 0:return xd;case 1:return e[0];default:return new Cd(e.every((e=>e instanceof bd))?e:e.reduce(((e,t)=>e.concat(t instanceof bd?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Sd(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new wd(o.from+t,o.to+t,o.type))}return n}function Md(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Nd(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Td(e,t,n,r){let o=[],i=!1;t.forEach(((t,s)=>{let l=Md(e,t,s+n);if(l){i=!0;let e=Td(l,t,n+s+1,r);e!=xd&&o.push(s,s+t.nodeSize,e)}}));let s=Sd(i?Nd(e):e,-n).sort(Od);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new bd(s,o):xd}function Od(e,t){return e.from-t.from||e.to-t.to}function Ad(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Ed(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Ed(t,o+1,i.copy(r.to,i.to)))}}return t}function Ed(e,t,n){for(;t<e.length&&Od(n,e[t])>0;)t++;e.splice(t,0,n)}function Id(e){let t=[];return e.someProp("decorations",(n=>{let r=n(e.state);r&&r!=xd&&t.push(r)})),e.cursorWrapper&&t.push(bd.create(e.state.doc,[e.cursorWrapper.deco])),Cd.from(t)}const Rd={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dd=oc&&ic<=11;class Pd{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class $d{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Pd,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);oc&&ic<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Dd&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Rd)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(gu(this.view)){if(this.suppressingSelectionUpdates)return au(this.view);if(oc&&ic<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qa(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=Wa(t))n.add(t);for(let r=e.anchorNode;r;r=Wa(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&gu(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(sc&&l.length){let t=l.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&Fd(e,n)==t||r.remove()}}}let a=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ga(n)&&(a=su(e))&&a.eq(js.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,au(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(!Ld.has(e)&&(Ld.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=sc,Bd)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Bd=!0}}(e)),this.handleDOMChange(o,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||au(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(oc&&ic<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?_a(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=o&&o.parentNode==e.target?_a(o):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ld=new WeakMap,Bd=!1;function zd(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return qa(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Fd(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function jd(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(uc&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||uc&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const _d=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Wd(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:mu(e,t.resolve(n.anchor),t.resolve(n.head))}function Vd(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}function Hd(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}const qd=Eu,Kd=Iu,Ud=ad;class Jd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new qu,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Qd),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Xd(this),Gd(this),this.nodeViews=Zd(this),this.docView=Hc(this.state.doc,Yd(this),Id(this),this.dom,this),this.domObserver=new $d(this,((e,t,n,r)=>function(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=su(e,t);if(n&&!e.state.selection.eq(n)){if(ac&&fc&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,Xa(13,"Enter")))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}return}let s=e.state.doc.resolve(t),l=s.sharedDepth(n);t=s.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a,c,u=e.state.selection,d=function(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(r=[{node:u,offset:c.anchorOffset}],Ga(c)||r.push({node:c.focusNode,offset:c.focusOffset})),ac&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let d=e.state.doc,h=e.someProp("domParser")||xt.fromSchema(e.state.schema),p=d.resolve(l),f=null,m=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:jd,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),h=e.state.doc,p=h.slice(d.from,d.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,c="end"):(a=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,r,o){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==o&&(r-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&e.size<t.size){let e=r<=i&&r>=s?i-r:0;i-=e,i&&i<t.size&&Hd(t.textBetween(i-1,i+1))&&(i+=e?1:-1),l=i+(l-s),s=i}else if(l<i){let t=r<=i&&r>=l?i-r:0;i-=t,i&&i<e.size&&Hd(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(p.content,d.doc.content,d.from,a,c);if(f&&e.input.domChangeCount++,(dc&&e.input.lastIOSEnter>Date.now()-225||fc)&&o.some((e=>1==e.nodeType&&!_d.test(e.nodeName)))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",(t=>t(e,Xa(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&u instanceof Hs&&!u.empty&&u.$head.sameParent(u.$anchor))||e.composing||d.sel&&d.sel.anchor!=d.sel.head){if(d.sel){let t=Wd(e,e.state.doc,d.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:u.from,endA:u.to,endB:u.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof Hs&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=d.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=d.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),oc&&ic<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>d.from&&"  "==d.doc.textBetween(f.start-d.from-1,f.start-d.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=d.doc.resolveNoCache(f.start-d.from),y=d.doc.resolveNoCache(f.endB-d.from),w=h.resolve(f.start),k=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=f.endA;if((dc&&e.input.lastIOSEnter>Date.now()-225&&(!k||o.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!k&&g.pos<d.doc.content.size&&!g.sameParent(y)&&(m=js.findFrom(d.doc.resolve(g.pos+1),1,!0))&&m.head==y.pos)&&e.someProp("handleKeyDown",(t=>t(e,Xa(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||Vd(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Vd(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Vd(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(h,f.start,f.endA,g,y)&&e.someProp("handleKeyDown",(t=>t(e,Xa(8,"Backspace")))))return void(fc&&ac&&e.domObserver.suppressSelectionUpdates());ac&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),fc&&!k&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==f.endA&&(f.endB-=2,y=d.doc.resolveNoCache(f.endB-d.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,Xa(13,"Enter"))}))}),20));let v,b,x,C=f.start,S=f.endA;if(k)if(g.pos==y.pos)oc&&ic<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>au(e)),20)),v=e.state.tr.delete(C,S),b=h.resolve(f.start).marksAcross(h.resolve(f.endA));else if(f.endA==f.endB&&(x=function(e,t){let n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,l=i,a=s;for(let e=0;e<s.length;e++)l=s[e].removeFromSet(l);for(let e=0;e<i.length;e++)a=i[e].removeFromSet(a);if(1==l.length&&0==a.length)r=l[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=l.length||1!=a.length)return null;r=a[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if(Ie.from(c).eq(e))return{mark:r,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,f.endA-w.start()))))v=e.state.tr,"add"==x.type?v.addMark(C,S,x.mark):v.removeMark(C,S,x.mark);else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let t=g.parent.textBetween(g.parentOffset,y.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,C,S,t))))return;v=e.state.tr.insertText(t,C,S)}if(v||(v=e.state.tr.replace(C,S,d.doc.slice(f.start-d.from,f.endB-d.from))),d.sel){let t=Wd(e,v.doc,d.sel);t&&!(ac&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==C||t.head==v.mapping.map(S)-1)||oc&&t.empty&&t.head==C)&&v.setSelection(t)}b&&v.ensureMarks(b),i&&v.setMeta("composition",i),e.dispatch(v.scrollIntoView())}(this,e,t,n,r))),this.domObserver.start(),function(e){for(let t in Wu){let n=Wu[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Yu(e,t)||Ju(e,t)||!e.editable&&t.type in Vu||n(e,t)},Hu[t]?{passive:!0}:void 0)}uc&&e.dom.addEventListener("input",(()=>null)),Uu(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Uu(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(ld(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Zd(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Uu(this),this.editable=Xd(this),Gd(this);let l=Id(this),a=Yd(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",u=o||!this.docView.matchesNode(e.doc,a,l);!u&&e.selection.eq(r.selection)||(i=!0);let d="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=o-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:bc(e.dom)}}(this);if(i){this.domObserver.stop();let t=u&&(oc||ac)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(u){let n=ac?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Ja(e=e.childNodes[t-1])}else{if(!e.parentNode||Ya(e))return null;t=_a(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Ya(e))return null;t=_a(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}(this)),!o&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Hc(e.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return qa(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?au(this,t):(pu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():d&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;xc(n,0==r?0:r-t)}(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof Ks){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&vc(this,t.getBoundingClientRect(),e)}else vc(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new hd(e.slice,e.move,r<0?void 0:Ks.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(oc){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Cc)return e.focus(Cc);let t=bc(e);e.focus(null==Cc?{get preventScroll(){return Cc={preventScroll:!0},!0}}:void 0),Cc||(Cc=!1,xc(t,0))}(this.dom),au(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Tc(this,e)}coordsAtPos(e,t=1){return Ic(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return function(e,t,n){return Lc==t&&Bc==n?zc:(Lc=t,Bc=n,zc="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Pc(e,t,(()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Ic(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Ha(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?$c.test(r.parent.textContent)&&l.modify?Pc(e,t,(()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),h=u&&!c.contains(1==u.nodeType?u:u.parentNode)||t==u&&o==d;try{l.collapse(i,s),t&&(t!=i||o!=s)&&l.extend&&l.extend(t,o)}catch(e){}return null!=a&&(l.caretBidiLevel=a),h})):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return ud(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ud(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Id(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Va=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Ju(e,t)||!Wu[t.type]||!e.editable&&t.type in Vu||Wu[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?uc&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return zd(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?zd(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Yd(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),t.translate||(t.translate="no"),[wd.node(0,e.state.doc.content.size,t)]}function Gd(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:wd.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Xd(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function Zd(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Qd(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var eh=e=>{throw TypeError(e)},th=(e,t,n)=>t.has(e)||eh("Cannot "+n),nh=(e,t,n)=>(th(e,t,"read from private field"),n?n.call(e):t.get(e)),rh=(e,t,n)=>t.has(e)?eh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),oh=(e,t,n,r)=>(th(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function ih(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}const sh={strong:(e,t,n,r)=>{const o=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(r);let l=s.move(o+o);return l+=s.move(n.containerPhrasing(e,{before:l,after:o,...s.current()})),l+=s.move(o+o),i(),l},emphasis:(e,t,n,r)=>{const o=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(r);let l=s.move(o);return l+=s.move(n.containerPhrasing(e,{before:l,after:o,...s.current()})),l+=s.move(o),i(),l}},lh=te({},"editorView"),ah=te({},"editorState"),ch=te([],"initTimer"),uh=te({},"editor"),dh=te([],"inputRules"),hh=te([],"prosePlugins"),ph=te([],"remarkPlugins"),fh=te([],"nodeView"),mh=te([],"markView"),gh=te(li().use(zr).use(jo),"remark"),yh=te({handlers:sh},"remarkStringifyOptions"),wh=Ne("ConfigReady");function kh(e){const t=t=>(t.record(wh),async()=>(await e(t),t.done(wh),()=>{t.clearTimer(wh)}));return ih(t,{displayName:"Config"}),t}const vh=Ne("InitReady");function bh(e){const t=t=>(t.inject(uh,e).inject(hh,[]).inject(ph,[]).inject(dh,[]).inject(fh,[]).inject(mh,[]).inject(yh,{handlers:sh}).inject(gh,li().use(zr).use(jo)).inject(ch,[wh]).record(vh),async()=>{await t.waitTimers(ch);const e=t.get(yh);return t.set(gh,li().use(zr).use(jo,e)),t.done(vh),()=>{t.remove(uh).remove(hh).remove(ph).remove(dh).remove(fh).remove(mh).remove(yh).remove(gh).remove(ch).clearTimer(vh)}});return ih(t,{displayName:"Init"}),t}const xh=Ne("SchemaReady"),Ch=te([],"schemaTimer"),Sh=te({},"schema"),Mh=te([],"nodes"),Nh=te([],"marks");function Th(e){var t;return{...e,parseDOM:null==(t=e.parseDOM)?void 0:t.map((t=>({priority:e.priority,...t})))}}const Oh=e=>(e.inject(Sh,{}).inject(Mh,[]).inject(Nh,[]).inject(Ch,[vh]).record(xh),async()=>{await e.waitTimers(Ch);const t=e.get(gh),n=e.get(ph).reduce(((e,t)=>e.use(t.plugin,t.options)),t);e.set(gh,n);const r=Object.fromEntries(e.get(Mh).map((([e,t])=>[e,Th(t)]))),o=Object.fromEntries(e.get(Nh).map((([e,t])=>[e,Th(t)]))),i=new vt({nodes:r,marks:o});return e.set(Sh,i),e.done(xh),()=>{e.remove(Sh).remove(Mh).remove(Nh).remove(Ch).clearTimer(xh)}});var Ah,Eh;ih(Oh,{displayName:"Schema"});class Ih{constructor(){rh(this,Ah),rh(this,Eh),oh(this,Ah,new Z),oh(this,Eh,null),this.setCtx=e=>{oh(this,Eh,e)}}get ctx(){return nh(this,Eh)}create(e,t){const n=e.create(nh(this,Ah).sliceMap);return n.set(t),n}get(e){return nh(this,Ah).get(e).get()}remove(e){return nh(this,Ah).remove(e)}call(e,t){if(null==nh(this,Eh))throw _();const n=this.get(e)(t),r=nh(this,Eh).get(lh);return n(r.state,r.dispatch,r)}}function Rh(e="cmdKey"){return te((()=>()=>!1),e)}Ah=new WeakMap,Eh=new WeakMap;const Dh=te(new Ih,"commands"),Ph=te([xh],"commandsTimer"),$h=Ne("CommandsReady"),Lh=e=>{const t=new Ih;return t.setCtx(e),e.inject(Dh,t).inject(Ph,[xh]).record($h),async()=>(await e.waitTimers(Ph),e.done($h),()=>{e.remove(Dh).remove(Ph).clearTimer($h)})};ih(Lh,{displayName:"Commands"});const Bh=Ne("ParserReady"),zh=()=>{throw P()},Fh=te(zh,"parser"),jh=te([],"parserTimer"),_h=e=>(e.inject(Fh,zh).inject(jh,[xh]).record(Bh),async()=>{await e.waitTimers(jh);const t=e.get(gh),n=e.get(Sh);return e.set(Fh,Ei.create(n,t)),e.done(Bh),()=>{e.remove(Fh).remove(jh).clearTimer(Bh)}});ih(_h,{displayName:"Parser"});const Wh=Ne("SerializerReady"),Vh=te([],"serializerTimer"),Hh=()=>{throw P()},qh=te(Hh,"serializer"),Kh=e=>(e.inject(qh,Hh).inject(Vh,[xh]).record(Wh),async()=>{await e.waitTimers(Vh);const t=e.get(gh),n=e.get(Sh);return e.set(qh,Ui.create(n,t)),e.done(Wh),()=>{e.remove(qh).remove(Vh).clearTimer(Wh)}});ih(Kh,{displayName:"Serializer"});const Uh=te("","defaultValue"),Jh=te((e=>e),"stateOptions"),Yh=te([],"editorStateTimer"),Gh=Ne("EditorStateReady");function Xh(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return xt.fromSchema(n).parse(e.dom);if("json"===e.type)return tt.fromJSON(n,e.value);throw D(e)}const Zh=new al("MILKDOWN_STATE_TRACKER");function Qh(e){const t=Sa(ul,ca,ua,ha);return e.Backspace=t,e}const ep=e=>(e.inject(Uh,"").inject(ah,{}).inject(Jh,(e=>e)).inject(Yh,[Bh,Wh,$h]).record(Gh),async()=>{await e.waitTimers(Yh);const t=e.get(Sh),n=e.get(Fh),r=e.get(dh),o=e.get(Jh),i=e.get(hh),s=Xh(e.get(Uh),n,t),l=[...i,new il({key:Zh,state:{init:()=>{},apply:(t,n,r,o)=>{e.set(ah,o)}}}),$l({rules:r}),Fa(Qh(Aa))];e.set(hh,l);const a=o({schema:t,doc:s,plugins:l}),c=rl.create(a);return e.set(ah,c),e.done(Gh),()=>{e.remove(Uh).remove(ah).remove(Jh).remove(Yh).clearTimer(Gh)}});ih(ep,{displayName:"EditorState"});const tp=Ne("EditorViewReady"),np=te([],"editorViewTimer"),rp=te({},"editorViewOptions"),op=te(null,"root"),ip=te(null,"rootDOM"),sp=te({},"rootAttrs"),lp=new al("MILKDOWN_VIEW_CLEAR"),ap=e=>(e.inject(op,document.body).inject(lh,{}).inject(rp,{}).inject(ip,null).inject(sp,{}).inject(np,[Gh]).record(tp),async()=>{await e.wait(vh);const t=e.get(op)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(hh,(t=>[new il({key:lp,view:t=>{const r=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(ip,n);const r=t.get(sp);return Object.entries(r).forEach((([e,t])=>n.setAttribute(e,t))),n}(n,e):void 0;return(()=>{if(r&&n){const e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{null!=r&&r.parentNode&&(null==r||r.parentNode.replaceChild(t.dom,r)),null==r||r.remove()}}}}),...t])),await e.waitTimers(np);const r=e.get(ah),o=e.get(rp),i=Object.fromEntries(e.get(fh)),s=Object.fromEntries(e.get(mh)),l=new Jd(n,{state:r,nodeViews:i,markViews:s,...o});return function(e){e.classList.add("editor"),e.setAttribute("role","textbox")}(l.dom),e.set(lh,l),e.done(tp),()=>{null==l||l.destroy(),e.remove(op).remove(lh).remove(rp).remove(ip).remove(sp).remove(np).clearTimer(tp)}});ih(ap,{displayName:"EditorView"});var cp,up,dp,hp,pp,fp,mp,gp,yp,wp,kp,vp,bp,xp,Cp,Sp=(e=>(e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e))(Sp||{});cp=new WeakMap,up=new WeakMap,dp=new WeakMap,hp=new WeakMap,pp=new WeakMap,fp=new WeakMap,mp=new WeakMap,gp=new WeakMap,yp=new WeakMap,wp=new WeakMap,kp=new WeakMap,vp=new WeakMap,bp=new WeakMap,xp=new WeakMap,Cp=new WeakMap;let Mp=class e{constructor(){rh(this,cp),rh(this,up),rh(this,dp),rh(this,hp),rh(this,pp),rh(this,fp),rh(this,mp),rh(this,gp),rh(this,yp),rh(this,wp),rh(this,kp),rh(this,vp),rh(this,bp),rh(this,xp),rh(this,Cp),oh(this,cp,!1),oh(this,up,"Idle"),oh(this,dp,[]),oh(this,hp,(()=>{})),oh(this,pp,new Z),oh(this,fp,new ye),oh(this,mp,new Map),oh(this,gp,new Map),oh(this,yp,new ge(nh(this,pp),nh(this,fp))),oh(this,wp,(()=>{const e=kh((async e=>{await Promise.all(nh(this,dp).map((t=>t(e))))})),t=[Oh,_h,Kh,Lh,ep,ap,bh(this),e];nh(this,kp).call(this,t,nh(this,gp))})),oh(this,kp,((e,t)=>{e.forEach((e=>{const n=nh(this,yp).produce(nh(this,cp)?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})}))})),oh(this,vp,((e,t=!1)=>Promise.all([e].flat().map((e=>{const n=nh(this,mp).get(e),r=null==n?void 0:n.cleanup;return t?nh(this,mp).delete(e):nh(this,mp).set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof r?r():r}))))),oh(this,bp,(async()=>{await Promise.all([...nh(this,gp).entries()].map((([e,{cleanup:t}])=>"function"==typeof t?t():t))),nh(this,gp).clear()})),oh(this,xp,(e=>{oh(this,up,e),nh(this,hp).call(this,e)})),oh(this,Cp,(e=>[...e.entries()].map((async([t,n])=>{const{ctx:r,handler:o}=n;if(!o)return;const i=await o();e.set(t,{ctx:r,handler:o,cleanup:i})})))),this.enableInspector=(e=!0)=>(oh(this,cp,e),this),this.onStatusChange=e=>(oh(this,hp,e),this),this.config=e=>(nh(this,dp).push(e),this),this.removeConfig=e=>(oh(this,dp,nh(this,dp).filter((t=>t!==e))),this),this.use=e=>{const t=[e].flat();return t.flat().forEach((e=>{nh(this,mp).set(e,{ctx:void 0,handler:void 0,cleanup:void 0})})),"Created"===nh(this,up)&&nh(this,kp).call(this,t,nh(this,mp)),this},this.remove=async e=>"OnCreate"===nh(this,up)?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise((t=>{setTimeout((()=>{t(this.remove(e))}),50)}))):(await nh(this,vp).call(this,[e].flat(),!0),this),this.create=async()=>("OnCreate"===nh(this,up)||("Created"===nh(this,up)&&await this.destroy(),nh(this,xp).call(this,"OnCreate"),nh(this,wp).call(this),nh(this,kp).call(this,[...nh(this,mp).keys()],nh(this,mp)),await Promise.all([nh(this,Cp).call(this,nh(this,gp)),nh(this,Cp).call(this,nh(this,mp))].flat()),nh(this,xp).call(this,"Created")),this),this.destroy=async(e=!1)=>"Destroyed"===nh(this,up)||"OnDestroy"===nh(this,up)?this:"OnCreate"===nh(this,up)?new Promise((t=>{setTimeout((()=>{t(this.destroy(e))}),50)})):(e&&oh(this,dp,[]),nh(this,xp).call(this,"OnDestroy"),await nh(this,vp).call(this,[...nh(this,mp).keys()],e),await nh(this,bp).call(this),nh(this,xp).call(this,"Destroyed"),this),this.action=e=>e(nh(this,yp)),this.inspect=()=>nh(this,cp)?[...nh(this,gp).values(),...nh(this,mp).values()].map((({ctx:e})=>{var t;return null==(t=null==e?void 0:e.inspector)?void 0:t.read()})).filter((e=>!!e)):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}get ctx(){return nh(this,yp)}get status(){return nh(this,up)}},Np=e=>crypto.getRandomValues(new Uint8Array(e)),Tp=(e,t=21)=>((e,t,n)=>{let r=(2<<Math.log2(e.length-1))-1,o=-~(1.6*r*t/e.length);return(i=t)=>{let s="";for(;;){let t=n(o),l=0|o;for(;l--;)if(s+=e[t[l]&r]||"",s.length>=i)return s}}})(e,0|t,Np);const Op=Tp("abcedfghicklmn",10);function Ap(e,t,n){const r=Ne(n||Op());let o=!1;const i=n=>(n.record(r),n.update(t,(e=>e.concat(r))),async()=>{const s=await e(n,i,(()=>{n.done(r),o=!0}));return o||n.done(r),()=>{n.update(t,(e=>e.filter((e=>e!==r)))),n.clearTimer(r),null==s||s()}});return i.timer=r,i}function Ep(e,t){const n=Rh(e),r=o=>async()=>{r.key=n,await o.wait($h);const i=t(o);return o.get(Dh).create(n,i),r.run=t=>o.get(Dh).call(e,t),()=>{o.get(Dh).remove(n)}};return r}function Ip(e,t,n){const r=Rh(e);return Ap((async(n,o)=>{await n.wait($h);const i=await t(n);return n.get(Dh).create(r,i),o.run=t=>n.get(Dh).call(e,t),o.key=r,()=>{n.get(Dh).remove(r)}}),Ph,n)}function Rp(e){const t=n=>async()=>{await n.wait(xh);const r=e(n);return n.update(dh,(e=>[...e,r])),t.inputRule=r,()=>{n.update(dh,(e=>e.filter((e=>e!==r))))}};return t}function Dp(e,t){return Ap((async(t,n)=>{await t.wait(xh);const r=await e(t);return t.update(dh,(e=>[...e,r])),n.inputRule=r,()=>{t.update(dh,(e=>e.filter((e=>e!==r))))}}),Yh,t)}function Pp(e,t){const n=r=>async()=>{const o=t(r);return r.update(Nh,(t=>[...t.filter((t=>t[0]!==e)),[e,o]])),n.id=e,n.schema=o,()=>{r.update(Nh,(t=>t.filter((([t])=>t!==e))))}};return n.type=t=>{const n=t.get(Sh).marks[e];if(!n)throw V(e);return n},n}function $p(e,t,n){const r=Ap((async(n,r,o)=>{const i=await t(n);return n.update(Nh,(t=>[...t.filter((t=>t[0]!==e)),[e,i]])),r.id=e,r.schema=i,o(),()=>{n.update(Nh,(t=>t.filter((([t])=>t!==e))))}}),Ch,n);return r.type=t=>{const n=t.get(Sh).marks[e];if(!n)throw V(e);return n},r}function Lp(e,t){const n=r=>async()=>{const o=t(r);return r.update(Mh,(t=>[...t.filter((t=>t[0]!==e)),[e,o]])),n.id=e,n.schema=o,()=>{r.update(Mh,(t=>t.filter((([t])=>t!==e))))}};return n.type=t=>{const n=t.get(Sh).nodes[e];if(!n)throw W(e);return n},n}function Bp(e,t,n){const r=Ap((async(n,r,o)=>{const i=await t(n);return n.update(Mh,(t=>[...t.filter((t=>t[0]!==e)),[e,i]])),r.id=e,r.schema=i,o(),()=>{n.update(Mh,(t=>t.filter((([t])=>t!==e))))}}),Ch,n);return r.type=t=>{const n=t.get(Sh).nodes[e];if(!n)throw W(e);return n},r}function zp(e){let t;const n=n=>async()=>(await n.wait(xh),t=e(n),n.update(hh,(e=>[...e,t])),()=>{n.update(hh,(e=>e.filter((e=>e!==t))))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function Fp(e,t){let n;const r=Ap((async t=>(await t.wait(xh),n=await e(t),t.update(hh,(e=>[...e,n])),()=>{t.update(hh,(e=>e.filter((e=>e!==n))))})),Yh,t);return r.plugin=()=>n,r.key=()=>n.spec.key,r}function jp(e){const t=n=>async()=>{await n.wait(xh);const r=e(n),o=Fa(r);return n.update(hh,(e=>[...e,o])),t.keymap=r,()=>{n.update(hh,(e=>e.filter((e=>e!==o))))}};return t}function _p(e,t){return Ap((async(t,n)=>{await t.wait(xh);const r=await e(t),o=Fa(r);return t.update(hh,(e=>[...e,o])),n.keymap=r,()=>{t.update(hh,(e=>e.filter((e=>e!==o))))}}),Yh,t)}function Wp(e,t){const n=r=>async()=>{await r.wait(xh);const o=t(r);return e.type(r)instanceof yt?r.update(fh,(t=>[...t,[e.id,o]])):r.update(mh,(t=>[...t,[e.id,o]])),n.view=o,n.type=e,()=>{e.type(r)instanceof yt?r.update(fh,(t=>t.filter((t=>t[0]!==e.id)))):r.update(mh,(t=>t.filter((t=>t[0]!==e.id))))}};return n}function Vp(e,t,n){return Ap((async(n,r)=>{await n.wait(xh);const o=await t(n);return e.type(n)instanceof yt?n.update(fh,(t=>[...t,[e.id,o]])):n.update(mh,(t=>[...t,[e.id,o]])),r.view=o,r.type=e,()=>{e.type(n)instanceof yt?n.update(fh,(t=>t.filter((t=>t[0]!==e.id)))):n.update(mh,(t=>t.filter((t=>t[0]!==e.id))))}}),np,n)}function Hp(e,t){const n=te(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function qp(e,t){const n=Hp(t,e),r=Lp(e,(e=>e.get(n.key)(e))),o=[n,r];return o.id=r.id,o.node=r,o.type=e=>r.type(e),o.schema=r.schema,o.ctx=n,o.key=n.key,o.extendSchema=t=>r=>()=>{const i=r.get(n.key),s=t(i)(r);r.update(Mh,(t=>[...t.filter((t=>t[0]!==e)),[e,s]])),o.schema=s},o}function Kp(e,t){const n=Hp(t,e),r=Pp(e,(e=>e.get(n.key)(e))),o=[n,r];return o.id=r.id,o.mark=r,o.type=r.type,o.schema=r.schema,o.ctx=n,o.key=n.key,o.extendSchema=t=>r=>()=>{const i=r.get(n.key),s=t(i)(r);r.update(Nh,(t=>[...t.filter((t=>t[0]!==e)),[e,s]])),o.schema=s},o}function Up(e,t){const n=Object.fromEntries(Object.entries(t).map((([e,{shortcuts:t}])=>[e,t]))),r=Hp(n,`${e}Keymap`),o=jp((e=>{const n=e.get(r.key),o=Object.entries(t).flatMap((([t,{command:r}])=>[n[t]].flat().map((t=>[t,r(e)]))));return Object.fromEntries(o)})),i=[r,o];return i.ctx=r,i.shortcuts=o,i.key=r.key,i.keymap=o.keymap,i}const Jp=(e,t=(()=>({})))=>Hp(t,`${e}Attr`),Yp=(e,t=(()=>({})))=>Hp(t,`${e}Attr`);function Gp(e,t,n){const r=Hp(n??{},e),o=e=>async()=>{await e.wait(vh);const n={plugin:t(e),options:e.get(r.key)};return e.update(ph,(e=>[...e,n])),()=>{e.update(ph,(e=>e.filter((e=>e!==n))))}},i=[r,o];return i.id=e,i.plugin=o,i.options=r,i}function Xp(e,t){return n=>n.get(Dh).call(e,t)}function Zp(){return e=>{const t=e.get(lh),{tr:n}=t.state,r=Object.assign(Object.create(n),n).setTime(Date.now());return t.dispatch(r)}}function Qp(){return e=>{const t=document.createElement("div"),n=e.get(Sh),r=e.get(lh),o=Rt.fromSchema(n).serializeFragment(r.state.doc.content);return t.appendChild(o),t.innerHTML}}function ef(){return e=>{const t=e.get(lh);return e.get(qh)(t.state.doc)}}function tf(e){return t=>{const n=t.get(lh),r=t.get(Fh)(e);if(!r)return;const o=n.state.selection.content();return n.dispatch(n.state.tr.replaceSelection(new Be(r.content,o.openStart,o.openEnd)).scrollIntoView())}}function nf(){return e=>{const t=e.get(lh),n=[];return t.state.doc.descendants((e=>{"heading"===e.type.name&&e.attrs.level&&n.push({text:e.textContent,level:e.attrs.level,id:e.attrs.id})})),n}}function rf(e,t=!1){return n=>{const r=n.get(lh),o=n.get(Fh)(e);if(!o)return;if(!t){const{state:e}=r;return r.dispatch(e.tr.replace(0,e.doc.content.size,new Be(o.content,0,0)))}const i=n.get(Sh),s=n.get(Jh),l=n.get(hh),a=rl.create({schema:i,doc:o,plugins:l,...s});r.updateState(a)}}function of(e,t){return n=>{const r=n.get(lh),{tr:o}=r.state,i=o.doc.nodeAt(e);if(!i)return;const s=t(i.attrs);return r.dispatch(o.setNodeMarkup(e,void 0,s))}}const sf=(...e)=>{const t=e.length;let n=t;for(;n--;)if("function"!=typeof e[n])throw new TypeError("Expected a function");return(...n)=>{let r=0,o=t?e[r](...n):n[0];for(;++r<t;)o=e[r](o);return o}};function lf(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const af=[["ß","ss"],["ẞ","Ss"],["ä","ae"],["Ä","Ae"],["ö","oe"],["Ö","Oe"],["ü","ue"],["Ü","Ue"],["À","A"],["Á","A"],["Â","A"],["Ã","A"],["Ä","Ae"],["Å","A"],["Æ","AE"],["Ç","C"],["È","E"],["É","E"],["Ê","E"],["Ë","E"],["Ì","I"],["Í","I"],["Î","I"],["Ï","I"],["Ð","D"],["Ñ","N"],["Ò","O"],["Ó","O"],["Ô","O"],["Õ","O"],["Ö","Oe"],["Ő","O"],["Ø","O"],["Ù","U"],["Ú","U"],["Û","U"],["Ü","Ue"],["Ű","U"],["Ý","Y"],["Þ","TH"],["ß","ss"],["à","a"],["á","a"],["â","a"],["ã","a"],["ä","ae"],["å","a"],["æ","ae"],["ç","c"],["è","e"],["é","e"],["ê","e"],["ë","e"],["ì","i"],["í","i"],["î","i"],["ï","i"],["ð","d"],["ñ","n"],["ò","o"],["ó","o"],["ô","o"],["õ","o"],["ö","oe"],["ő","o"],["ø","o"],["ù","u"],["ú","u"],["û","u"],["ü","ue"],["ű","u"],["ý","y"],["þ","th"],["ÿ","y"],["ẞ","SS"],["à","a"],["À","A"],["á","a"],["Á","A"],["â","a"],["Â","A"],["ã","a"],["Ã","A"],["è","e"],["È","E"],["é","e"],["É","E"],["ê","e"],["Ê","E"],["ì","i"],["Ì","I"],["í","i"],["Í","I"],["ò","o"],["Ò","O"],["ó","o"],["Ó","O"],["ô","o"],["Ô","O"],["õ","o"],["Õ","O"],["ù","u"],["Ù","U"],["ú","u"],["Ú","U"],["ý","y"],["Ý","Y"],["ă","a"],["Ă","A"],["Đ","D"],["đ","d"],["ĩ","i"],["Ĩ","I"],["ũ","u"],["Ũ","U"],["ơ","o"],["Ơ","O"],["ư","u"],["Ư","U"],["ạ","a"],["Ạ","A"],["ả","a"],["Ả","A"],["ấ","a"],["Ấ","A"],["ầ","a"],["Ầ","A"],["ẩ","a"],["Ẩ","A"],["ẫ","a"],["Ẫ","A"],["ậ","a"],["Ậ","A"],["ắ","a"],["Ắ","A"],["ằ","a"],["Ằ","A"],["ẳ","a"],["Ẳ","A"],["ẵ","a"],["Ẵ","A"],["ặ","a"],["Ặ","A"],["ẹ","e"],["Ẹ","E"],["ẻ","e"],["Ẻ","E"],["ẽ","e"],["Ẽ","E"],["ế","e"],["Ế","E"],["ề","e"],["Ề","E"],["ể","e"],["Ể","E"],["ễ","e"],["Ễ","E"],["ệ","e"],["Ệ","E"],["ỉ","i"],["Ỉ","I"],["ị","i"],["Ị","I"],["ọ","o"],["Ọ","O"],["ỏ","o"],["Ỏ","O"],["ố","o"],["Ố","O"],["ồ","o"],["Ồ","O"],["ổ","o"],["Ổ","O"],["ỗ","o"],["Ỗ","O"],["ộ","o"],["Ộ","O"],["ớ","o"],["Ớ","O"],["ờ","o"],["Ờ","O"],["ở","o"],["Ở","O"],["ỡ","o"],["Ỡ","O"],["ợ","o"],["Ợ","O"],["ụ","u"],["Ụ","U"],["ủ","u"],["Ủ","U"],["ứ","u"],["Ứ","U"],["ừ","u"],["Ừ","U"],["ử","u"],["Ử","U"],["ữ","u"],["Ữ","U"],["ự","u"],["Ự","U"],["ỳ","y"],["Ỳ","Y"],["ỵ","y"],["Ỵ","Y"],["ỷ","y"],["Ỷ","Y"],["ỹ","y"],["Ỹ","Y"],["ء","e"],["آ","a"],["أ","a"],["ؤ","w"],["إ","i"],["ئ","y"],["ا","a"],["ب","b"],["ة","t"],["ت","t"],["ث","th"],["ج","j"],["ح","h"],["خ","kh"],["د","d"],["ذ","dh"],["ر","r"],["ز","z"],["س","s"],["ش","sh"],["ص","s"],["ض","d"],["ط","t"],["ظ","z"],["ع","e"],["غ","gh"],["ـ","_"],["ف","f"],["ق","q"],["ك","k"],["ل","l"],["م","m"],["ن","n"],["ه","h"],["و","w"],["ى","a"],["ي","y"],["َ‎","a"],["ُ","u"],["ِ‎","i"],["٠","0"],["١","1"],["٢","2"],["٣","3"],["٤","4"],["٥","5"],["٦","6"],["٧","7"],["٨","8"],["٩","9"],["چ","ch"],["ک","k"],["گ","g"],["پ","p"],["ژ","zh"],["ی","y"],["۰","0"],["۱","1"],["۲","2"],["۳","3"],["۴","4"],["۵","5"],["۶","6"],["۷","7"],["۸","8"],["۹","9"],["ټ","p"],["ځ","z"],["څ","c"],["ډ","d"],["ﺫ","d"],["ﺭ","r"],["ړ","r"],["ﺯ","z"],["ږ","g"],["ښ","x"],["ګ","g"],["ڼ","n"],["ۀ","e"],["ې","e"],["ۍ","ai"],["ٹ","t"],["ڈ","d"],["ڑ","r"],["ں","n"],["ہ","h"],["ھ","h"],["ے","e"],["А","A"],["а","a"],["Б","B"],["б","b"],["В","V"],["в","v"],["Г","G"],["г","g"],["Д","D"],["д","d"],["ъе","ye"],["Ъе","Ye"],["ъЕ","yE"],["ЪЕ","YE"],["Е","E"],["е","e"],["Ё","Yo"],["ё","yo"],["Ж","Zh"],["ж","zh"],["З","Z"],["з","z"],["И","I"],["и","i"],["ый","iy"],["Ый","Iy"],["ЫЙ","IY"],["ыЙ","iY"],["Й","Y"],["й","y"],["К","K"],["к","k"],["Л","L"],["л","l"],["М","M"],["м","m"],["Н","N"],["н","n"],["О","O"],["о","o"],["П","P"],["п","p"],["Р","R"],["р","r"],["С","S"],["с","s"],["Т","T"],["т","t"],["У","U"],["у","u"],["Ф","F"],["ф","f"],["Х","Kh"],["х","kh"],["Ц","Ts"],["ц","ts"],["Ч","Ch"],["ч","ch"],["Ш","Sh"],["ш","sh"],["Щ","Sch"],["щ","sch"],["Ъ",""],["ъ",""],["Ы","Y"],["ы","y"],["Ь",""],["ь",""],["Э","E"],["э","e"],["Ю","Yu"],["ю","yu"],["Я","Ya"],["я","ya"],["ă","a"],["Ă","A"],["ș","s"],["Ș","S"],["ț","t"],["Ț","T"],["ţ","t"],["Ţ","T"],["ş","s"],["Ş","S"],["ç","c"],["Ç","C"],["ğ","g"],["Ğ","G"],["ı","i"],["İ","I"],["ա","a"],["Ա","A"],["բ","b"],["Բ","B"],["գ","g"],["Գ","G"],["դ","d"],["Դ","D"],["ե","ye"],["Ե","Ye"],["զ","z"],["Զ","Z"],["է","e"],["Է","E"],["ը","y"],["Ը","Y"],["թ","t"],["Թ","T"],["ժ","zh"],["Ժ","Zh"],["ի","i"],["Ի","I"],["լ","l"],["Լ","L"],["խ","kh"],["Խ","Kh"],["ծ","ts"],["Ծ","Ts"],["կ","k"],["Կ","K"],["հ","h"],["Հ","H"],["ձ","dz"],["Ձ","Dz"],["ղ","gh"],["Ղ","Gh"],["ճ","tch"],["Ճ","Tch"],["մ","m"],["Մ","M"],["յ","y"],["Յ","Y"],["ն","n"],["Ն","N"],["շ","sh"],["Շ","Sh"],["ո","vo"],["Ո","Vo"],["չ","ch"],["Չ","Ch"],["պ","p"],["Պ","P"],["ջ","j"],["Ջ","J"],["ռ","r"],["Ռ","R"],["ս","s"],["Ս","S"],["վ","v"],["Վ","V"],["տ","t"],["Տ","T"],["ր","r"],["Ր","R"],["ց","c"],["Ց","C"],["ու","u"],["ՈՒ","U"],["Ու","U"],["փ","p"],["Փ","P"],["ք","q"],["Ք","Q"],["օ","o"],["Օ","O"],["ֆ","f"],["Ֆ","F"],["և","yev"],["ა","a"],["ბ","b"],["გ","g"],["დ","d"],["ე","e"],["ვ","v"],["ზ","z"],["თ","t"],["ი","i"],["კ","k"],["ლ","l"],["მ","m"],["ნ","n"],["ო","o"],["პ","p"],["ჟ","zh"],["რ","r"],["ს","s"],["ტ","t"],["უ","u"],["ფ","ph"],["ქ","q"],["ღ","gh"],["ყ","k"],["შ","sh"],["ჩ","ch"],["ც","ts"],["ძ","dz"],["წ","ts"],["ჭ","tch"],["ხ","kh"],["ჯ","j"],["ჰ","h"],["č","c"],["ď","d"],["ě","e"],["ň","n"],["ř","r"],["š","s"],["ť","t"],["ů","u"],["ž","z"],["Č","C"],["Ď","D"],["Ě","E"],["Ň","N"],["Ř","R"],["Š","S"],["Ť","T"],["Ů","U"],["Ž","Z"],["ހ","h"],["ށ","sh"],["ނ","n"],["ރ","r"],["ބ","b"],["ޅ","lh"],["ކ","k"],["އ","a"],["ވ","v"],["މ","m"],["ފ","f"],["ދ","dh"],["ތ","th"],["ލ","l"],["ގ","g"],["ޏ","gn"],["ސ","s"],["ޑ","d"],["ޒ","z"],["ޓ","t"],["ޔ","y"],["ޕ","p"],["ޖ","j"],["ޗ","ch"],["ޘ","tt"],["ޙ","hh"],["ޚ","kh"],["ޛ","th"],["ޜ","z"],["ޝ","sh"],["ޞ","s"],["ޟ","d"],["ޠ","t"],["ޡ","z"],["ޢ","a"],["ޣ","gh"],["ޤ","q"],["ޥ","w"],["ަ","a"],["ާ","aa"],["ި","i"],["ީ","ee"],["ު","u"],["ޫ","oo"],["ެ","e"],["ޭ","ey"],["ޮ","o"],["ޯ","oa"],["ް",""],["α","a"],["β","v"],["γ","g"],["δ","d"],["ε","e"],["ζ","z"],["η","i"],["θ","th"],["ι","i"],["κ","k"],["λ","l"],["μ","m"],["ν","n"],["ξ","ks"],["ο","o"],["π","p"],["ρ","r"],["σ","s"],["τ","t"],["υ","y"],["φ","f"],["χ","x"],["ψ","ps"],["ω","o"],["ά","a"],["έ","e"],["ί","i"],["ό","o"],["ύ","y"],["ή","i"],["ώ","o"],["ς","s"],["ϊ","i"],["ΰ","y"],["ϋ","y"],["ΐ","i"],["Α","A"],["Β","B"],["Γ","G"],["Δ","D"],["Ε","E"],["Ζ","Z"],["Η","I"],["Θ","TH"],["Ι","I"],["Κ","K"],["Λ","L"],["Μ","M"],["Ν","N"],["Ξ","KS"],["Ο","O"],["Π","P"],["Ρ","R"],["Σ","S"],["Τ","T"],["Υ","Y"],["Φ","F"],["Χ","X"],["Ψ","PS"],["Ω","O"],["Ά","A"],["Έ","E"],["Ί","I"],["Ό","O"],["Ύ","Y"],["Ή","I"],["Ώ","O"],["Ϊ","I"],["Ϋ","Y"],["ā","a"],["ē","e"],["ģ","g"],["ī","i"],["ķ","k"],["ļ","l"],["ņ","n"],["ū","u"],["Ā","A"],["Ē","E"],["Ģ","G"],["Ī","I"],["Ķ","K"],["Ļ","L"],["Ņ","N"],["Ū","U"],["č","c"],["š","s"],["ž","z"],["Č","C"],["Š","S"],["Ž","Z"],["ą","a"],["č","c"],["ę","e"],["ė","e"],["į","i"],["š","s"],["ų","u"],["ū","u"],["ž","z"],["Ą","A"],["Č","C"],["Ę","E"],["Ė","E"],["Į","I"],["Š","S"],["Ų","U"],["Ū","U"],["Ќ","Kj"],["ќ","kj"],["Љ","Lj"],["љ","lj"],["Њ","Nj"],["њ","nj"],["Тс","Ts"],["тс","ts"],["ą","a"],["ć","c"],["ę","e"],["ł","l"],["ń","n"],["ś","s"],["ź","z"],["ż","z"],["Ą","A"],["Ć","C"],["Ę","E"],["Ł","L"],["Ń","N"],["Ś","S"],["Ź","Z"],["Ż","Z"],["Є","Ye"],["І","I"],["Ї","Yi"],["Ґ","G"],["є","ye"],["і","i"],["ї","yi"],["ґ","g"],["IJ","IJ"],["ij","ij"],["¢","c"],["¥","Y"],["߿","b"],["৳","t"],["૱","Bo"],["฿","B"],["₠","CE"],["₡","C"],["₢","Cr"],["₣","F"],["₥","m"],["₦","N"],["₧","Pt"],["₨","Rs"],["₩","W"],["₫","s"],["€","E"],["₭","K"],["₮","T"],["₯","Dp"],["₰","S"],["₱","P"],["₲","G"],["₳","A"],["₴","S"],["₵","C"],["₶","tt"],["₷","S"],["₸","T"],["₹","R"],["₺","L"],["₽","P"],["₿","B"],["﹩","$"],["¢","c"],["¥","Y"],["₩","W"],["𝐀","A"],["𝐁","B"],["𝐂","C"],["𝐃","D"],["𝐄","E"],["𝐅","F"],["𝐆","G"],["𝐇","H"],["𝐈","I"],["𝐉","J"],["𝐊","K"],["𝐋","L"],["𝐌","M"],["𝐍","N"],["𝐎","O"],["𝐏","P"],["𝐐","Q"],["𝐑","R"],["𝐒","S"],["𝐓","T"],["𝐔","U"],["𝐕","V"],["𝐖","W"],["𝐗","X"],["𝐘","Y"],["𝐙","Z"],["𝐚","a"],["𝐛","b"],["𝐜","c"],["𝐝","d"],["𝐞","e"],["𝐟","f"],["𝐠","g"],["𝐡","h"],["𝐢","i"],["𝐣","j"],["𝐤","k"],["𝐥","l"],["𝐦","m"],["𝐧","n"],["𝐨","o"],["𝐩","p"],["𝐪","q"],["𝐫","r"],["𝐬","s"],["𝐭","t"],["𝐮","u"],["𝐯","v"],["𝐰","w"],["𝐱","x"],["𝐲","y"],["𝐳","z"],["𝐴","A"],["𝐵","B"],["𝐶","C"],["𝐷","D"],["𝐸","E"],["𝐹","F"],["𝐺","G"],["𝐻","H"],["𝐼","I"],["𝐽","J"],["𝐾","K"],["𝐿","L"],["𝑀","M"],["𝑁","N"],["𝑂","O"],["𝑃","P"],["𝑄","Q"],["𝑅","R"],["𝑆","S"],["𝑇","T"],["𝑈","U"],["𝑉","V"],["𝑊","W"],["𝑋","X"],["𝑌","Y"],["𝑍","Z"],["𝑎","a"],["𝑏","b"],["𝑐","c"],["𝑑","d"],["𝑒","e"],["𝑓","f"],["𝑔","g"],["𝑖","i"],["𝑗","j"],["𝑘","k"],["𝑙","l"],["𝑚","m"],["𝑛","n"],["𝑜","o"],["𝑝","p"],["𝑞","q"],["𝑟","r"],["𝑠","s"],["𝑡","t"],["𝑢","u"],["𝑣","v"],["𝑤","w"],["𝑥","x"],["𝑦","y"],["𝑧","z"],["𝑨","A"],["𝑩","B"],["𝑪","C"],["𝑫","D"],["𝑬","E"],["𝑭","F"],["𝑮","G"],["𝑯","H"],["𝑰","I"],["𝑱","J"],["𝑲","K"],["𝑳","L"],["𝑴","M"],["𝑵","N"],["𝑶","O"],["𝑷","P"],["𝑸","Q"],["𝑹","R"],["𝑺","S"],["𝑻","T"],["𝑼","U"],["𝑽","V"],["𝑾","W"],["𝑿","X"],["𝒀","Y"],["𝒁","Z"],["𝒂","a"],["𝒃","b"],["𝒄","c"],["𝒅","d"],["𝒆","e"],["𝒇","f"],["𝒈","g"],["𝒉","h"],["𝒊","i"],["𝒋","j"],["𝒌","k"],["𝒍","l"],["𝒎","m"],["𝒏","n"],["𝒐","o"],["𝒑","p"],["𝒒","q"],["𝒓","r"],["𝒔","s"],["𝒕","t"],["𝒖","u"],["𝒗","v"],["𝒘","w"],["𝒙","x"],["𝒚","y"],["𝒛","z"],["𝒜","A"],["𝒞","C"],["𝒟","D"],["𝒢","g"],["𝒥","J"],["𝒦","K"],["𝒩","N"],["𝒪","O"],["𝒫","P"],["𝒬","Q"],["𝒮","S"],["𝒯","T"],["𝒰","U"],["𝒱","V"],["𝒲","W"],["𝒳","X"],["𝒴","Y"],["𝒵","Z"],["𝒶","a"],["𝒷","b"],["𝒸","c"],["𝒹","d"],["𝒻","f"],["𝒽","h"],["𝒾","i"],["𝒿","j"],["𝓀","h"],["𝓁","l"],["𝓂","m"],["𝓃","n"],["𝓅","p"],["𝓆","q"],["𝓇","r"],["𝓈","s"],["𝓉","t"],["𝓊","u"],["𝓋","v"],["𝓌","w"],["𝓍","x"],["𝓎","y"],["𝓏","z"],["𝓐","A"],["𝓑","B"],["𝓒","C"],["𝓓","D"],["𝓔","E"],["𝓕","F"],["𝓖","G"],["𝓗","H"],["𝓘","I"],["𝓙","J"],["𝓚","K"],["𝓛","L"],["𝓜","M"],["𝓝","N"],["𝓞","O"],["𝓟","P"],["𝓠","Q"],["𝓡","R"],["𝓢","S"],["𝓣","T"],["𝓤","U"],["𝓥","V"],["𝓦","W"],["𝓧","X"],["𝓨","Y"],["𝓩","Z"],["𝓪","a"],["𝓫","b"],["𝓬","c"],["𝓭","d"],["𝓮","e"],["𝓯","f"],["𝓰","g"],["𝓱","h"],["𝓲","i"],["𝓳","j"],["𝓴","k"],["𝓵","l"],["𝓶","m"],["𝓷","n"],["𝓸","o"],["𝓹","p"],["𝓺","q"],["𝓻","r"],["𝓼","s"],["𝓽","t"],["𝓾","u"],["𝓿","v"],["𝔀","w"],["𝔁","x"],["𝔂","y"],["𝔃","z"],["𝔄","A"],["𝔅","B"],["𝔇","D"],["𝔈","E"],["𝔉","F"],["𝔊","G"],["𝔍","J"],["𝔎","K"],["𝔏","L"],["𝔐","M"],["𝔑","N"],["𝔒","O"],["𝔓","P"],["𝔔","Q"],["𝔖","S"],["𝔗","T"],["𝔘","U"],["𝔙","V"],["𝔚","W"],["𝔛","X"],["𝔜","Y"],["𝔞","a"],["𝔟","b"],["𝔠","c"],["𝔡","d"],["𝔢","e"],["𝔣","f"],["𝔤","g"],["𝔥","h"],["𝔦","i"],["𝔧","j"],["𝔨","k"],["𝔩","l"],["𝔪","m"],["𝔫","n"],["𝔬","o"],["𝔭","p"],["𝔮","q"],["𝔯","r"],["𝔰","s"],["𝔱","t"],["𝔲","u"],["𝔳","v"],["𝔴","w"],["𝔵","x"],["𝔶","y"],["𝔷","z"],["𝔸","A"],["𝔹","B"],["𝔻","D"],["𝔼","E"],["𝔽","F"],["𝔾","G"],["𝕀","I"],["𝕁","J"],["𝕂","K"],["𝕃","L"],["𝕄","M"],["𝕆","N"],["𝕊","S"],["𝕋","T"],["𝕌","U"],["𝕍","V"],["𝕎","W"],["𝕏","X"],["𝕐","Y"],["𝕒","a"],["𝕓","b"],["𝕔","c"],["𝕕","d"],["𝕖","e"],["𝕗","f"],["𝕘","g"],["𝕙","h"],["𝕚","i"],["𝕛","j"],["𝕜","k"],["𝕝","l"],["𝕞","m"],["𝕟","n"],["𝕠","o"],["𝕡","p"],["𝕢","q"],["𝕣","r"],["𝕤","s"],["𝕥","t"],["𝕦","u"],["𝕧","v"],["𝕨","w"],["𝕩","x"],["𝕪","y"],["𝕫","z"],["𝕬","A"],["𝕭","B"],["𝕮","C"],["𝕯","D"],["𝕰","E"],["𝕱","F"],["𝕲","G"],["𝕳","H"],["𝕴","I"],["𝕵","J"],["𝕶","K"],["𝕷","L"],["𝕸","M"],["𝕹","N"],["𝕺","O"],["𝕻","P"],["𝕼","Q"],["𝕽","R"],["𝕾","S"],["𝕿","T"],["𝖀","U"],["𝖁","V"],["𝖂","W"],["𝖃","X"],["𝖄","Y"],["𝖅","Z"],["𝖆","a"],["𝖇","b"],["𝖈","c"],["𝖉","d"],["𝖊","e"],["𝖋","f"],["𝖌","g"],["𝖍","h"],["𝖎","i"],["𝖏","j"],["𝖐","k"],["𝖑","l"],["𝖒","m"],["𝖓","n"],["𝖔","o"],["𝖕","p"],["𝖖","q"],["𝖗","r"],["𝖘","s"],["𝖙","t"],["𝖚","u"],["𝖛","v"],["𝖜","w"],["𝖝","x"],["𝖞","y"],["𝖟","z"],["𝖠","A"],["𝖡","B"],["𝖢","C"],["𝖣","D"],["𝖤","E"],["𝖥","F"],["𝖦","G"],["𝖧","H"],["𝖨","I"],["𝖩","J"],["𝖪","K"],["𝖫","L"],["𝖬","M"],["𝖭","N"],["𝖮","O"],["𝖯","P"],["𝖰","Q"],["𝖱","R"],["𝖲","S"],["𝖳","T"],["𝖴","U"],["𝖵","V"],["𝖶","W"],["𝖷","X"],["𝖸","Y"],["𝖹","Z"],["𝖺","a"],["𝖻","b"],["𝖼","c"],["𝖽","d"],["𝖾","e"],["𝖿","f"],["𝗀","g"],["𝗁","h"],["𝗂","i"],["𝗃","j"],["𝗄","k"],["𝗅","l"],["𝗆","m"],["𝗇","n"],["𝗈","o"],["𝗉","p"],["𝗊","q"],["𝗋","r"],["𝗌","s"],["𝗍","t"],["𝗎","u"],["𝗏","v"],["𝗐","w"],["𝗑","x"],["𝗒","y"],["𝗓","z"],["𝗔","A"],["𝗕","B"],["𝗖","C"],["𝗗","D"],["𝗘","E"],["𝗙","F"],["𝗚","G"],["𝗛","H"],["𝗜","I"],["𝗝","J"],["𝗞","K"],["𝗟","L"],["𝗠","M"],["𝗡","N"],["𝗢","O"],["𝗣","P"],["𝗤","Q"],["𝗥","R"],["𝗦","S"],["𝗧","T"],["𝗨","U"],["𝗩","V"],["𝗪","W"],["𝗫","X"],["𝗬","Y"],["𝗭","Z"],["𝗮","a"],["𝗯","b"],["𝗰","c"],["𝗱","d"],["𝗲","e"],["𝗳","f"],["𝗴","g"],["𝗵","h"],["𝗶","i"],["𝗷","j"],["𝗸","k"],["𝗹","l"],["𝗺","m"],["𝗻","n"],["𝗼","o"],["𝗽","p"],["𝗾","q"],["𝗿","r"],["𝘀","s"],["𝘁","t"],["𝘂","u"],["𝘃","v"],["𝘄","w"],["𝘅","x"],["𝘆","y"],["𝘇","z"],["𝘈","A"],["𝘉","B"],["𝘊","C"],["𝘋","D"],["𝘌","E"],["𝘍","F"],["𝘎","G"],["𝘏","H"],["𝘐","I"],["𝘑","J"],["𝘒","K"],["𝘓","L"],["𝘔","M"],["𝘕","N"],["𝘖","O"],["𝘗","P"],["𝘘","Q"],["𝘙","R"],["𝘚","S"],["𝘛","T"],["𝘜","U"],["𝘝","V"],["𝘞","W"],["𝘟","X"],["𝘠","Y"],["𝘡","Z"],["𝘢","a"],["𝘣","b"],["𝘤","c"],["𝘥","d"],["𝘦","e"],["𝘧","f"],["𝘨","g"],["𝘩","h"],["𝘪","i"],["𝘫","j"],["𝘬","k"],["𝘭","l"],["𝘮","m"],["𝘯","n"],["𝘰","o"],["𝘱","p"],["𝘲","q"],["𝘳","r"],["𝘴","s"],["𝘵","t"],["𝘶","u"],["𝘷","v"],["𝘸","w"],["𝘹","x"],["𝘺","y"],["𝘻","z"],["𝘼","A"],["𝘽","B"],["𝘾","C"],["𝘿","D"],["𝙀","E"],["𝙁","F"],["𝙂","G"],["𝙃","H"],["𝙄","I"],["𝙅","J"],["𝙆","K"],["𝙇","L"],["𝙈","M"],["𝙉","N"],["𝙊","O"],["𝙋","P"],["𝙌","Q"],["𝙍","R"],["𝙎","S"],["𝙏","T"],["𝙐","U"],["𝙑","V"],["𝙒","W"],["𝙓","X"],["𝙔","Y"],["𝙕","Z"],["𝙖","a"],["𝙗","b"],["𝙘","c"],["𝙙","d"],["𝙚","e"],["𝙛","f"],["𝙜","g"],["𝙝","h"],["𝙞","i"],["𝙟","j"],["𝙠","k"],["𝙡","l"],["𝙢","m"],["𝙣","n"],["𝙤","o"],["𝙥","p"],["𝙦","q"],["𝙧","r"],["𝙨","s"],["𝙩","t"],["𝙪","u"],["𝙫","v"],["𝙬","w"],["𝙭","x"],["𝙮","y"],["𝙯","z"],["𝙰","A"],["𝙱","B"],["𝙲","C"],["𝙳","D"],["𝙴","E"],["𝙵","F"],["𝙶","G"],["𝙷","H"],["𝙸","I"],["𝙹","J"],["𝙺","K"],["𝙻","L"],["𝙼","M"],["𝙽","N"],["𝙾","O"],["𝙿","P"],["𝚀","Q"],["𝚁","R"],["𝚂","S"],["𝚃","T"],["𝚄","U"],["𝚅","V"],["𝚆","W"],["𝚇","X"],["𝚈","Y"],["𝚉","Z"],["𝚊","a"],["𝚋","b"],["𝚌","c"],["𝚍","d"],["𝚎","e"],["𝚏","f"],["𝚐","g"],["𝚑","h"],["𝚒","i"],["𝚓","j"],["𝚔","k"],["𝚕","l"],["𝚖","m"],["𝚗","n"],["𝚘","o"],["𝚙","p"],["𝚚","q"],["𝚛","r"],["𝚜","s"],["𝚝","t"],["𝚞","u"],["𝚟","v"],["𝚠","w"],["𝚡","x"],["𝚢","y"],["𝚣","z"],["𝚤","l"],["𝚥","j"],["𝛢","A"],["𝛣","B"],["𝛤","G"],["𝛥","D"],["𝛦","E"],["𝛧","Z"],["𝛨","I"],["𝛩","TH"],["𝛪","I"],["𝛫","K"],["𝛬","L"],["𝛭","M"],["𝛮","N"],["𝛯","KS"],["𝛰","O"],["𝛱","P"],["𝛲","R"],["𝛳","TH"],["𝛴","S"],["𝛵","T"],["𝛶","Y"],["𝛷","F"],["𝛸","x"],["𝛹","PS"],["𝛺","O"],["𝛻","D"],["𝛼","a"],["𝛽","b"],["𝛾","g"],["𝛿","d"],["𝜀","e"],["𝜁","z"],["𝜂","i"],["𝜃","th"],["𝜄","i"],["𝜅","k"],["𝜆","l"],["𝜇","m"],["𝜈","n"],["𝜉","ks"],["𝜊","o"],["𝜋","p"],["𝜌","r"],["𝜍","s"],["𝜎","s"],["𝜏","t"],["𝜐","y"],["𝜑","f"],["𝜒","x"],["𝜓","ps"],["𝜔","o"],["𝜕","d"],["𝜖","E"],["𝜗","TH"],["𝜘","K"],["𝜙","f"],["𝜚","r"],["𝜛","p"],["𝜜","A"],["𝜝","V"],["𝜞","G"],["𝜟","D"],["𝜠","E"],["𝜡","Z"],["𝜢","I"],["𝜣","TH"],["𝜤","I"],["𝜥","K"],["𝜦","L"],["𝜧","M"],["𝜨","N"],["𝜩","KS"],["𝜪","O"],["𝜫","P"],["𝜬","S"],["𝜭","TH"],["𝜮","S"],["𝜯","T"],["𝜰","Y"],["𝜱","F"],["𝜲","X"],["𝜳","PS"],["𝜴","O"],["𝜵","D"],["𝜶","a"],["𝜷","v"],["𝜸","g"],["𝜹","d"],["𝜺","e"],["𝜻","z"],["𝜼","i"],["𝜽","th"],["𝜾","i"],["𝜿","k"],["𝝀","l"],["𝝁","m"],["𝝂","n"],["𝝃","ks"],["𝝄","o"],["𝝅","p"],["𝝆","r"],["𝝇","s"],["𝝈","s"],["𝝉","t"],["𝝊","y"],["𝝋","f"],["𝝌","x"],["𝝍","ps"],["𝝎","o"],["𝝏","a"],["𝝐","e"],["𝝑","i"],["𝝒","k"],["𝝓","f"],["𝝔","r"],["𝝕","p"],["𝝖","A"],["𝝗","B"],["𝝘","G"],["𝝙","D"],["𝝚","E"],["𝝛","Z"],["𝝜","I"],["𝝝","TH"],["𝝞","I"],["𝝟","K"],["𝝠","L"],["𝝡","M"],["𝝢","N"],["𝝣","KS"],["𝝤","O"],["𝝥","P"],["𝝦","R"],["𝝧","TH"],["𝝨","S"],["𝝩","T"],["𝝪","Y"],["𝝫","F"],["𝝬","X"],["𝝭","PS"],["𝝮","O"],["𝝯","D"],["𝝰","a"],["𝝱","v"],["𝝲","g"],["𝝳","d"],["𝝴","e"],["𝝵","z"],["𝝶","i"],["𝝷","th"],["𝝸","i"],["𝝹","k"],["𝝺","l"],["𝝻","m"],["𝝼","n"],["𝝽","ks"],["𝝾","o"],["𝝿","p"],["𝞀","r"],["𝞁","s"],["𝞂","s"],["𝞃","t"],["𝞄","y"],["𝞅","f"],["𝞆","x"],["𝞇","ps"],["𝞈","o"],["𝞉","a"],["𝞊","e"],["𝞋","i"],["𝞌","k"],["𝞍","f"],["𝞎","r"],["𝞏","p"],["𝞐","A"],["𝞑","V"],["𝞒","G"],["𝞓","D"],["𝞔","E"],["𝞕","Z"],["𝞖","I"],["𝞗","TH"],["𝞘","I"],["𝞙","K"],["𝞚","L"],["𝞛","M"],["𝞜","N"],["𝞝","KS"],["𝞞","O"],["𝞟","P"],["𝞠","S"],["𝞡","TH"],["𝞢","S"],["𝞣","T"],["𝞤","Y"],["𝞥","F"],["𝞦","X"],["𝞧","PS"],["𝞨","O"],["𝞩","D"],["𝞪","av"],["𝞫","g"],["𝞬","d"],["𝞭","e"],["𝞮","z"],["𝞯","i"],["𝞰","i"],["𝞱","th"],["𝞲","i"],["𝞳","k"],["𝞴","l"],["𝞵","m"],["𝞶","n"],["𝞷","ks"],["𝞸","o"],["𝞹","p"],["𝞺","r"],["𝞻","s"],["𝞼","s"],["𝞽","t"],["𝞾","y"],["𝞿","f"],["𝟀","x"],["𝟁","ps"],["𝟂","o"],["𝟃","a"],["𝟄","e"],["𝟅","i"],["𝟆","k"],["𝟇","f"],["𝟈","r"],["𝟉","p"],["𝟊","F"],["𝟋","f"],["⒜","(a)"],["⒝","(b)"],["⒞","(c)"],["⒟","(d)"],["⒠","(e)"],["⒡","(f)"],["⒢","(g)"],["⒣","(h)"],["⒤","(i)"],["⒥","(j)"],["⒦","(k)"],["⒧","(l)"],["⒨","(m)"],["⒩","(n)"],["⒪","(o)"],["⒫","(p)"],["⒬","(q)"],["⒭","(r)"],["⒮","(s)"],["⒯","(t)"],["⒰","(u)"],["⒱","(v)"],["⒲","(w)"],["⒳","(x)"],["⒴","(y)"],["⒵","(z)"],["Ⓐ","(A)"],["Ⓑ","(B)"],["Ⓒ","(C)"],["Ⓓ","(D)"],["Ⓔ","(E)"],["Ⓕ","(F)"],["Ⓖ","(G)"],["Ⓗ","(H)"],["Ⓘ","(I)"],["Ⓙ","(J)"],["Ⓚ","(K)"],["Ⓛ","(L)"],["Ⓝ","(N)"],["Ⓞ","(O)"],["Ⓟ","(P)"],["Ⓠ","(Q)"],["Ⓡ","(R)"],["Ⓢ","(S)"],["Ⓣ","(T)"],["Ⓤ","(U)"],["Ⓥ","(V)"],["Ⓦ","(W)"],["Ⓧ","(X)"],["Ⓨ","(Y)"],["Ⓩ","(Z)"],["ⓐ","(a)"],["ⓑ","(b)"],["ⓒ","(b)"],["ⓓ","(c)"],["ⓔ","(e)"],["ⓕ","(f)"],["ⓖ","(g)"],["ⓗ","(h)"],["ⓘ","(i)"],["ⓙ","(j)"],["ⓚ","(k)"],["ⓛ","(l)"],["ⓜ","(m)"],["ⓝ","(n)"],["ⓞ","(o)"],["ⓟ","(p)"],["ⓠ","(q)"],["ⓡ","(r)"],["ⓢ","(s)"],["ⓣ","(t)"],["ⓤ","(u)"],["ⓥ","(v)"],["ⓦ","(w)"],["ⓧ","(x)"],["ⓨ","(y)"],["ⓩ","(z)"],["Ċ","C"],["ċ","c"],["Ġ","G"],["ġ","g"],["Ħ","H"],["ħ","h"],["Ż","Z"],["ż","z"],["𝟎","0"],["𝟏","1"],["𝟐","2"],["𝟑","3"],["𝟒","4"],["𝟓","5"],["𝟔","6"],["𝟕","7"],["𝟖","8"],["𝟗","9"],["𝟘","0"],["𝟙","1"],["𝟚","2"],["𝟛","3"],["𝟜","4"],["𝟝","5"],["𝟞","6"],["𝟟","7"],["𝟠","8"],["𝟡","9"],["𝟢","0"],["𝟣","1"],["𝟤","2"],["𝟥","3"],["𝟦","4"],["𝟧","5"],["𝟨","6"],["𝟩","7"],["𝟪","8"],["𝟫","9"],["𝟬","0"],["𝟭","1"],["𝟮","2"],["𝟯","3"],["𝟰","4"],["𝟱","5"],["𝟲","6"],["𝟳","7"],["𝟴","8"],["𝟵","9"],["𝟶","0"],["𝟷","1"],["𝟸","2"],["𝟹","3"],["𝟺","4"],["𝟻","5"],["𝟼","6"],["𝟽","7"],["𝟾","8"],["𝟿","9"],["①","1"],["②","2"],["③","3"],["④","4"],["⑤","5"],["⑥","6"],["⑦","7"],["⑧","8"],["⑨","9"],["⑩","10"],["⑪","11"],["⑫","12"],["⑬","13"],["⑭","14"],["⑮","15"],["⑯","16"],["⑰","17"],["⑱","18"],["⑲","19"],["⑳","20"],["⑴","1"],["⑵","2"],["⑶","3"],["⑷","4"],["⑸","5"],["⑹","6"],["⑺","7"],["⑻","8"],["⑼","9"],["⑽","10"],["⑾","11"],["⑿","12"],["⒀","13"],["⒁","14"],["⒂","15"],["⒃","16"],["⒄","17"],["⒅","18"],["⒆","19"],["⒇","20"],["⒈","1."],["⒉","2."],["⒊","3."],["⒋","4."],["⒌","5."],["⒍","6."],["⒎","7."],["⒏","8."],["⒐","9."],["⒑","10."],["⒒","11."],["⒓","12."],["⒔","13."],["⒕","14."],["⒖","15."],["⒗","16."],["⒘","17."],["⒙","18."],["⒚","19."],["⒛","20."],["⓪","0"],["⓫","11"],["⓬","12"],["⓭","13"],["⓮","14"],["⓯","15"],["⓰","16"],["⓱","17"],["⓲","18"],["⓳","19"],["⓴","20"],["⓵","1"],["⓶","2"],["⓷","3"],["⓸","4"],["⓹","5"],["⓺","6"],["⓻","7"],["⓼","8"],["⓽","9"],["⓾","10"],["⓿","0"],["🙰","&"],["🙱","&"],["🙲","&"],["🙳","&"],["🙴","&"],["🙵","&"],["🙶",'"'],["🙷",'"'],["🙸",'"'],["‽","?!"],["🙹","?!"],["🙺","?!"],["🙻","?!"],["🙼","/"],["🙽","\\"],["🜇","AR"],["🜈","V"],["🜉","V"],["🜆","VR"],["🜅","VF"],["🜩","2"],["🜪","5"],["🝡","f"],["🝢","W"],["🝣","U"],["🝧","V"],["🝨","T"],["🝪","V"],["🝫","MB"],["🝬","VB"],["🝲","3B"],["🝳","3B"],["💯","100"],["🔙","BACK"],["🔚","END"],["🔛","ON!"],["🔜","SOON"],["🔝","TOP"],["🔞","18"],["🔤","abc"],["🔠","ABCD"],["🔡","abcd"],["🔢","1234"],["🔣","T&@%"],["#️⃣","#"],["*️⃣","*"],["0️⃣","0"],["1️⃣","1"],["2️⃣","2"],["3️⃣","3"],["4️⃣","4"],["5️⃣","5"],["6️⃣","6"],["7️⃣","7"],["8️⃣","8"],["9️⃣","9"],["🔟","10"],["🅰️","A"],["🅱️","B"],["🆎","AB"],["🆑","CL"],["🅾️","O"],["🅿","P"],["🆘","SOS"],["🅲","C"],["🅳","D"],["🅴","E"],["🅵","F"],["🅶","G"],["🅷","H"],["🅸","I"],["🅹","J"],["🅺","K"],["🅻","L"],["🅼","M"],["🅽","N"],["🆀","Q"],["🆁","R"],["🆂","S"],["🆃","T"],["🆄","U"],["🆅","V"],["🆆","W"],["🆇","X"],["🆈","Y"],["🆉","Z"]],cf=[["&"," and "],["🦄"," unicorn "],["♥"," love "]];function uf(e,t){if("string"!=typeof e)throw new TypeError(`Expected a string, got \`${typeof e}\``);const n=(t={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],...t}).preserveLeadingUnderscore&&e.startsWith("_"),r=t.preserveTrailingDash&&e.endsWith("-");e=function(e,t){if("string"!=typeof e)throw new TypeError(`Expected a string, got \`${typeof e}\``);t={customReplacements:[],...t};const n=new Map([...af,...t.customReplacements]);return(e=((e,t)=>{for(const[n,r]of t)e=e.replace(new RegExp(lf(n),"g"),r);return e})(e=e.normalize(),n)).normalize("NFD").replace(/\p{Diacritic}/gu,"").normalize()}(e,{customReplacements:new Map([...cf,...t.customReplacements])}),t.decamelize&&(e=(e=>e.replace(/([A-Z]{2,})(\d+)/g,"$1 $2").replace(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"))(e));const o=(e=>{let t="a-z\\d";if(t+=e.lowercase?"":"A-Z",e.preserveCharacters.length>0)for(const n of e.preserveCharacters){if(n===e.separator)throw new Error(`The separator character \`${e.separator}\` cannot be included in preserved characters: ${e.preserveCharacters}`);t+=lf(n)}return new RegExp(`[^${t}]+`,"g")})(t);return t.lowercase&&(e=e.toLowerCase()),e=(e=(e=e.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g,"$1$2$3")).replace(o,t.separator)).replace(/\\/g,""),t.separator&&(e=((e,t)=>{const n=lf(t);return e.replace(new RegExp(`${n}{2,}`,"g"),t).replace(new RegExp(`^${n}|${n}$`,"g"),"")})(e,t.separator)),n&&(e=`_${e}`),r&&(e=`${e}-`),e}function df(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,(t=>t.childCount>0&&t.firstChild.type==e));return!!i&&(!n||(r.node(i.depth-1).type==e?function(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new us(i-1,s,i,s,new Be(Ie.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Qe(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const l=fs(r);if(null==l)return!1;o.lift(r,l);let a=o.mapping.map(i,-1)-1;return vs(o.doc,a)&&o.join(a),t(o.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?Ie.empty:Ie.from(o))))return!1;let d=i.pos,h=d+s.nodeSize;return r.step(new us(d-(l?1:0),h+(a?1:0),d+1,h-1,new Be((l?Ie.empty:Ie.from(o.copy(Ie.empty))).append(a?Ie.empty:Ie.from(o.copy(Ie.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}(t,n,i)))}}function hf(e){return String(e||"").toUpperCase()}function pf(){return function(e){const t=function(e){const t=new Map;if(!e||!e.type)throw new Error("mdast-util-definitions expected node");return lo(e,"definition",(function(e){const n=hf(e.identifier);n&&!t.get(n)&&t.set(n,e)})),function(e){const n=hf(e);return t.get(n)}}(e);lo(e,(function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[io,n];if("imageReference"===e.type||"linkReference"===e.type){const o=t(e.identifier);if(o&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:o.url,title:o.title,alt:e.alt}:{type:"link",url:o.url,title:o.title,children:e.children},[io,n]}}))}}function ff(e,t){var n;if(!(t.childCount>=1&&"hardbreak"===(null==(n=t.lastChild)?void 0:n.type.name)))return void e.next(t.content);const r=[];t.content.forEach(((e,n,o)=>{o!==t.childCount-1&&r.push(e)})),e.next(Ie.fromArray(r))}function mf(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}const gf=Yp("emphasis");mf(gf,{displayName:"Attr<emphasis>",group:"Emphasis"});const yf=Kp("emphasis",(e=>({attrs:{marker:{default:e.get(yh).emphasis||"*"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(gf.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}})));mf(yf.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),mf(yf.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});const wf=Ep("ToggleEmphasis",(e=>()=>Ca(yf.type(e))));mf(wf,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});const kf=Rp((e=>Ll(/(?:^|[^*])\*([^*]+)\*$/,yf.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}})));mf(kf,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});const vf=Rp((e=>Ll(/(?:^|[^_])_([^_]+)_$/,yf.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}})));mf(vf,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});const bf=Up("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(Dh);return()=>t.call(wf.key)}}});mf(bf.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),mf(bf.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});const xf=Yp("strong");mf(xf,{displayName:"Attr<strong>",group:"Strong"});const Cf=Kp("strong",(e=>({attrs:{marker:{default:e.get(yh).strong||"*"}},parseDOM:[{tag:"b"},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e}],toDOM:t=>["strong",e.get(xf.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}})));mf(Cf.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),mf(Cf.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});const Sf=Ep("ToggleStrong",(e=>()=>Ca(Cf.type(e))));mf(Sf,{displayName:"Command<toggleStrongCommand>",group:"Strong"});const Mf=Rp((e=>Ll(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/,Cf.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})})));mf(Mf,{displayName:"InputRule<strong>",group:"Strong"});const Nf=Up("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(Dh);return()=>t.call(Sf.key)}}});mf(Nf.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),mf(Nf.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});const Tf=Yp("inlineCode");mf(Tf,{displayName:"Attr<inlineCode>",group:"InlineCode"});const Of=Kp("inlineCode",(e=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(Tf.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>{e.withMark(t,"inlineCode",n.text||"")}}})));mf(Of.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),mf(Of.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});const Af=Ep("ToggleInlineCode",(e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(r.empty)return!1;const{from:i,to:s}=r;return t.doc.rangeHasMark(i,s,Of.type(e))?(null==n||n(o.removeMark(i,s,Of.type(e))),!0):(Object.keys(t.schema.marks).filter((e=>e!==Of.type.name)).map((e=>t.schema.marks[e])).forEach((e=>{o.removeMark(i,s,e)})),null==n||n(o.addMark(i,s,Of.type(e).create())),!0)}));mf(Af,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});const Ef=Rp((e=>Ll(/(?:`)([^`]+)(?:`)$/,Of.type(e))));mf(Ef,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});const If=Up("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(Dh);return()=>t.call(Af.key)}}});mf(If.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),mf(If.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});const Rf=Yp("link");mf(Rf,{displayName:"Attr<link>",group:"Link"});const Df=Kp("link",(e=>({attrs:{href:{},title:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(Rf.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const r=t.url,o=t.title;e.openMark(n,{href:r,title:o}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}})));mf(Df.mark,{displayName:"MarkSchema<link>",group:"Link"});const Pf=Ep("ToggleLink",(e=>(t={})=>Ca(Df.type(e),t)));mf(Pf,{displayName:"Command<toggleLinkCommand>",group:"Link"});const $f=Ep("UpdateLink",(e=>(t={})=>(n,r)=>{if(!r)return!1;let o,i=-1;const{selection:s}=n,{from:l,to:a}=s;if(n.doc.nodesBetween(l,l===a?a+1:a,((t,n)=>{if(Df.type(e).isInSet(t.marks))return o=t,i=n,!1})),!o)return!1;const c=o.marks.find((({type:t})=>t===Df.type(e)));if(!c)return!1;const u=i,d=i+o.nodeSize,{tr:h}=n,p=Df.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(u,d,c).addMark(u,d,p).setSelection(new Hs(h.selection.$anchor)).scrollIntoView()),!0)}));mf($f,{displayName:"Command<updateLinkCommand>",group:"Link"});const Lf=Lp("doc",(()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}})));mf(Lf,{displayName:"NodeSchema<doc>",group:"Doc"});const Bf=Jp("paragraph");mf(Bf,{displayName:"Attr<paragraph>",group:"Paragraph"});const zf=qp("paragraph",(e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(Bf.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(e,t)=>{e.openNode("paragraph"),ff(e,t),e.closeNode()}}})));mf(zf.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),mf(zf.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});const Ff=Ep("TurnIntoText",(e=>()=>xa(zf.type(e))));mf(Ff,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});const jf=Up("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(Dh);return()=>t.call(Ff.key)}}});mf(jf.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),mf(jf.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});const _f=Array(6).fill(0).map(((e,t)=>t+1)),Wf=Hp((function(e){return uf(e.textContent)}),"headingIdGenerator");mf(Wf,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});const Vf=Jp("heading");mf(Vf,{displayName:"Attr<heading>",group:"Heading"});const Hf=qp("heading",(e=>{const t=e.get(Wf.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:""},level:{default:1}},parseDOM:_f.map((e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw j(t);return{level:e,id:t.id}}}))),toDOM:n=>[`h${n.attrs.level}`,{...e.get(Vf.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),ff(e,t),e.closeNode()}}}}));mf(Hf.node,{displayName:"NodeSchema<heading>",group:"Heading"}),mf(Hf.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});const qf=Rp((e=>hl(/^(?<hashes>#+)\s$/,Hf.type(e),(t=>{var n,r;const o=(null==(r=null==(n=t.groups)?void 0:n.hashes)?void 0:r.length)||0,i=e.get(lh),{$from:s}=i.state.selection,l=s.node();if("heading"===l.type.name){let e=Number(l.attrs.level)+Number(o);return e>6&&(e=6),{level:e}}return{level:o}}))));mf(qf,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});const Kf=Ep("WrapInHeading",(e=>t=>(t??(t=1),t<1?xa(zf.type(e)):xa(Hf.type(e),{level:t}))));mf(Kf,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});const Uf=Ep("DowngradeHeading",(e=>()=>(t,n,r)=>{const{$from:o}=t.selection,i=o.node();if(i.type!==Hf.type(e)||!t.selection.empty||0!==o.parentOffset)return!1;const s=i.attrs.level-1;return s?(null==n||n(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...i.attrs,level:s})),!0):xa(zf.type(e))(t,n,r)}));mf(Uf,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});const Jf=Up("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(Dh);return()=>t.call(Kf.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(Dh);return()=>t.call(Kf.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(Dh);return()=>t.call(Kf.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(Dh);return()=>t.call(Kf.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(Dh);return()=>t.call(Kf.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(Dh);return()=>t.call(Kf.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(Dh);return()=>t.call(Uf.key)}}});mf(Jf.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),mf(Jf.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});const Yf=Jp("blockquote");mf(Yf,{displayName:"Attr<blockquote>",group:"Blockquote"});const Gf=qp("blockquote",(e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(Yf.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}})));mf(Gf.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),mf(Gf.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});const Xf=Rp((e=>dl(/^\s*>\s$/,Gf.type(e))));mf(Xf,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});const Zf=Ep("WrapInBlockquote",(e=>()=>ba(Gf.type(e))));mf(Zf,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});const Qf=Up("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(Dh);return()=>t.call(Zf.key)}}});mf(Qf.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),mf(Qf.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});const em=Jp("codeBlock",(()=>({pre:{},code:{}})));mf(em,{displayName:"Attr<codeBlock>",group:"CodeBlock"});const tm=qp("code_block",(e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(em.key)(t);return["pre",{...n.pre,"data-language":t.attrs.language},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const r=t.lang,o=t.value;e.openNode(n,{language:r}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{var n;e.addNode("code",void 0,(null==(n=t.content.firstChild)?void 0:n.text)||"",{lang:t.attrs.language})}}})));mf(tm.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),mf(tm.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});const nm=Rp((e=>hl(/^```(?<language>[a-z]*)?[\s\n]$/,tm.type(e),(e=>{var t;return{language:(null==(t=e.groups)?void 0:t.language)??""}}))));mf(nm,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});const rm=Ep("CreateCodeBlock",(e=>(t="")=>xa(tm.type(e),{language:t})));mf(rm,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});const om=Ep("UpdateCodeBlockLanguage",(()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(null==r||r(n.tr.setNodeAttribute(e,"language",t)),!0)));mf(om,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});const im=Up("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(Dh);return()=>t.call(rm.key)}}});mf(im.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),mf(im.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});const sm=Jp("image");mf(sm,{displayName:"Attr<image>",group:"Image"});const lm=qp("image",(e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:""},alt:{default:""},title:{default:""}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(sm.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const r=t.url,o=t.alt,i=t.title;e.addNode(n,{src:r,alt:o,title:i})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}})));mf(lm.node,{displayName:"NodeSchema<image>",group:"Image"}),mf(lm.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});const am=Ep("InsertImage",(e=>(t={})=>(n,r)=>{if(!r)return!0;const{src:o="",alt:i="",title:s=""}=t,l=lm.type(e).create({src:o,alt:i,title:s});return l&&r(n.tr.replaceSelectionWith(l).scrollIntoView()),!0}));mf(am,{displayName:"Command<insertImageCommand>",group:"Image"});const cm=Ep("UpdateImage",(e=>(t={})=>(n,r)=>{const o=aa(n.selection,lm.type(e));if(!o)return!1;const{node:i,pos:s}=o,l={...i.attrs},{src:a,alt:c,title:u}=t;return void 0!==a&&(l.src=a),void 0!==c&&(l.alt=c),void 0!==u&&(l.title=u),null==r||r(n.tr.setNodeMarkup(s,void 0,l).scrollIntoView()),!0}));mf(cm,{displayName:"Command<updateImageCommand>",group:"Image"});const um=Rp((e=>new cl(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,((t,n,r,o)=>{const[i,s,l="",a]=n;return i?t.tr.replaceWith(r,o,lm.type(e).create({src:l,alt:s,title:a})):null}))));mf(um,{displayName:"InputRule<insertImageInputRule>",group:"Image"});const dm=Jp("hardbreak",(e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline})));mf(dm,{displayName:"Attr<hardbreak>",group:"Hardbreak"});const hm=qp("hardbreak",(e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(dm.key)(t)," "]:["br",e.get(dm.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{var r;e.addNode(n,{isInline:!(null==(r=t.data)||!r.isInline)})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}})));mf(hm.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),mf(hm.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});const pm=Ep("InsertHardbreak",(e=>()=>(t,n)=>{var r;const{selection:o,tr:i}=t;if(!(o instanceof Hs))return!1;if(o.empty){const e=o.$from.node();if(e.childCount>0&&"hardbreak"===(null==(r=e.lastChild)?void 0:r.type.name))return null==n||n(i.replaceRangeWith(o.to-1,o.to,t.schema.node("paragraph")).setSelection(js.near(i.doc.resolve(o.to))).scrollIntoView()),!0}return null==n||n(i.setMeta("hardbreak",!0).replaceSelectionWith(hm.type(e).create()).scrollIntoView()),!0}));mf(pm,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});const fm=Up("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(Dh);return()=>t.call(pm.key)}}});mf(fm.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),mf(fm.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});const mm=Jp("hr");mf(mm,{displayName:"Attr<hr>",group:"Hr"});const gm=qp("hr",(e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(mm.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}})));mf(gm.node,{displayName:"NodeSchema<hr>",group:"Hr"}),mf(gm.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});const ym=Rp((e=>new cl(/^(?:---|___\s|\*\*\*\s)$/,((t,n,r,o)=>{const{tr:i}=t;return n[0]&&i.replaceWith(r-1,o,gm.type(e).create()),i}))));mf(ym,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});const wm=Ep("InsertHr",(e=>()=>(t,n)=>{if(!n)return!0;const r=zf.node.type(e).create(),{tr:o,selection:i}=t,{from:s}=i,l=gm.type(e).create();if(!l)return!0;const a=o.replaceSelectionWith(l).insert(s,r),c=js.findFrom(a.doc.resolve(s),1,!0);return c&&n(a.setSelection(c).scrollIntoView()),!0}));mf(wm,{displayName:"Command<insertHrCommand>",group:"Hr"});const km=Jp("bulletList");mf(km,{displayName:"Attr<bulletList>",group:"BulletList"});const vm=qp("bullet_list",(e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{spread:e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(km.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:"true"===t.attrs.spread}).next(t.content).closeNode()}}})));mf(vm.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),mf(vm.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});const bm=Rp((e=>dl(/^\s*([-+*])\s$/,vm.type(e))));mf(bm,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});const xm=Ep("WrapInBulletList",(e=>()=>ba(vm.type(e))));mf(xm,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});const Cm=Up("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(Dh);return()=>t.call(xm.key)}}});mf(Cm.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),mf(Cm.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});const Sm=Jp("orderedList");mf(Sm,{displayName:"Attr<orderedList>",group:"OrderedList"});const Mm=qp("ordered_list",(e=>({content:"listItem+",group:"block",attrs:{order:{default:1},spread:{default:!1}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(Sm.key)(t),...1===t.attrs.order?{}:t.attrs.order,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}})));mf(Mm.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),mf(Mm.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});const Nm=Rp((e=>dl(/^\s*(\d+)\.\s$/,Mm.type(e),(e=>({order:Number(e[1])})),((e,t)=>t.childCount+t.attrs.order===Number(e[1])))));mf(Nm,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});const Tm=Ep("WrapInOrderedList",(e=>()=>ba(Mm.type(e))));mf(Tm,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});const Om=Up("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(Dh);return()=>t.call(Tm.key)}}});mf(Om.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),mf(Om.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});const Am=Jp("listItem");mf(Am,{displayName:"Attr<listItem>",group:"ListItem"});const Em=qp("list_item",(e=>({group:"listItem",content:"(paragraph|blockquote) block*",attrs:{label:{default:"•"},listType:{default:"bullet"},spread:{default:"true"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread}}}],toDOM:t=>["li",{...e.get(Am.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{const r=null!=t.label?`${t.label}.`:"•",o=null!=t.label?"ordered":"bullet",i=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:r,listType:o,spread:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}})));mf(Em.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),mf(Em.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});const Im=Ep("SinkListItem",(e=>()=>{return t=Em.type(e),function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let r=a.lastChild&&a.lastChild.type==l.type,o=Ie.from(r?t.create():null),s=new Be(Ie.from(t.create(null,Ie.from(l.type.create(null,o)))),r?3:1,0),c=i.start,u=i.end;n(e.tr.step(new us(c-(r?3:1),u,c,u,s,1,!0)).scrollIntoView())}return!0};var t}));mf(Im,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});const Rm=Ep("LiftListItem",(e=>()=>df(Em.type(e))));mf(Rm,{displayName:"Command<liftListItemCommand>",group:"ListItem"});const Dm=Ep("SplitListItem",(e=>()=>{return t=Em.type(e),function(e,r){let{$from:o,$to:i,node:s}=e.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(l.type!=t)return!1;if(0==o.parent.content.size&&o.node(-1).childCount==o.indexAfter(-1)){if(3==o.depth||o.node(-3).type!=t||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let n=Ie.empty,i=o.index(-1)?1:o.index(-2)?2:3;for(let e=o.depth-i;e>=o.depth-3;e--)n=Ie.from(o.node(e).copy(n));let s=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;n=n.append(Ie.from(t.createAndFill()));let l=o.before(o.depth-(i-1)),a=e.tr.replace(l,o.after(-s),new Be(n,4-i,0)),c=-1;a.doc.nodesBetween(l,a.doc.content.size,((e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)})),c>-1&&a.setSelection(js.near(a.doc.resolve(c))),r(a.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=e.tr.delete(o.pos,i.pos),u=a?[n?{type:t,attrs:n}:null,{type:a}]:void 0;return!!ks(c.doc,o.pos,2,u)&&(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0)};var t,n}));mf(Dm,{displayName:"Command<splitListItemCommand>",group:"ListItem"});const Pm=Ep("LiftFirstListItem",(e=>()=>function(e){return(t,n,r)=>{const{selection:o}=t;if(!(o instanceof Hs))return!1;const{empty:i,$from:s}=o;if(!i||0!==s.parentOffset)return!1;const l=s.node(-1);return!(l.type!==Em.type(e)||l.firstChild!==s.node()||s.node(-2).childCount>1)&&df(Em.type(e))(t,n,r)}}(e)));mf(Pm,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});const $m=Up("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(Dh);return()=>t.call(Dm.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(Dh);return()=>t.call(Im.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(Dh);return()=>t.call(Rm.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(Dh);return()=>t.call(Pm.key)}}});mf($m.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),mf($m.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});const Lm=Lp("text",(()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}})));mf(Lm,{displayName:"NodeSchema<text>",group:"Text"});const Bm=Jp("html");mf(Bm,{displayName:"Attr<html>",group:"Html"});const zm=qp("html",(e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:""}},toDOM:t=>{const n=document.createElement("span"),r={...e.get(Bm.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>"html"===e,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}})));mf(zm.node,{displayName:"NodeSchema<html>",group:"Html"}),mf(zm.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});const Fm=[Lf,Bf,zf,Wf,Vf,Hf,dm,hm,Yf,Gf,em,tm,mm,gm,sm,lm,km,vm,Sm,Mm,Am,Em,gf,yf,xf,Cf,Tf,Of,Rf,Df,Bm,zm,Lm].flat(),jm=[Xf,bm,Nm,nm,ym,qf].flat(),_m=[kf,vf,Ef,Mf],Wm=[Ff,Zf,Kf,Uf,rm,pm,wm,am,cm,Tm,xm,Im,Dm,Rm,Pm,wf,Af,Sf,Pf,$f],Vm=[Qf,im,fm,Jf,$m,Om,Cm,jf,bf,If,Nf].flat(),Hm=Gp("remarkAddOrderInList",(()=>()=>e=>{lo(e,"list",(e=>{if(e.ordered){const t=e.start??1;e.children.forEach(((e,n)=>{e.label=n+t}))}}))}));mf(Hm.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),mf(Hm.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});const qm=Gp("remarkLineBreak",(()=>()=>e=>{const t=/[\t ]*(?:\r?\n|\r)/g;lo(e,"text",((e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;const o=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&o.push({type:"text",value:e.value.slice(i,n)}),o.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return o.length>0&&r&&"number"==typeof n?(i<e.value.length&&o.push({type:"text",value:e.value.slice(i)}),r.children.splice(n,1,...o),n+o.length):void 0}))}));mf(qm.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),mf(qm.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});const Km=Gp("remarkInlineLink",(()=>pf));mf(Km.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),mf(Km.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});const Um=Gp("remarkHTMLTransformer",(()=>()=>e=>{!function(e,t){(function e(t,n,r){if((e=>!!e.children)(t)){const n=[];for(let r=0,o=t.children.length;r<o;r++){const o=t.children[r];if(o){const i=e(o,r,t);if(i)for(let e=0,t=i.length;e<t;e++){const t=i[e];t&&n.push(t)}}}t.children=n}return((e,t,n)=>(e=>"html"===e.type)(e)?("root"===(null==n?void 0:n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])(t,0,r)})(e,0,null)[0]}(e)}));mf(Um.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),mf(Um.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});const Jm=Gp("remarkMarker",(()=>()=>(e,t)=>{lo(e,(e=>["strong","emphasis"].includes(e.type)),(e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)}))}));mf(Jm.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),mf(Jm.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});const Ym=zp((()=>{let e=!1;const t=new al("MILKDOWN_INLINE_NODES_CURSOR"),n=new il({key:t,state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!(!(n&&r&&n.isInline&&!n.isText&&r.isInline)||r.isText)}},props:{handleDOMEvents:{compositionend:(t,r)=>!!e&&(e=!1,requestAnimationFrame((()=>{if(n.getState(t.state)){const e=t.state.selection.from;r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e))}})),!0),compositionstart:t=>(n.getState(t.state)&&(e=!0),!1),beforeinput:(t,r)=>{if(n.getState(t.state)&&r instanceof InputEvent&&r.data&&!e){const e=t.state.selection.from;return r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(n.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),r=wd.widget(t,n,{side:-1}),o=document.createElement("span"),i=wd.widget(t,o);return setTimeout((()=>{n.contentEditable="true",o.contentEditable="true"})),bd.create(e.doc,[r,i])}return bd.empty}}});return n}));mf(Ym,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});const Gm=zp((e=>new il({key:new al("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;const[o]=t;if(!o)return;const[i]=o.steps;if(o.getMeta("hardbreak")){if(!(i instanceof cs))return;const{from:t}=i;return r.tr.setNodeMarkup(t,hm.type(e),void 0,[])}if(i instanceof is){let t=r.tr;const{from:n,to:o}=i;return r.doc.nodesBetween(n,o,((n,r)=>{n.type===hm.type(e)&&(t=t.setNodeMarkup(r,hm.type(e),void 0,[]))})),t}}})));mf(Gm,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});const Xm=Hp(["table","code_block"],"hardbreakFilterNodes");mf(Xm,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});const Zm=zp((e=>{const t=e.get(Xm.key);return new il({key:new al("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const r=e.getMeta("hardbreak"),[o]=e.steps;if(r&&o){const{from:e}=o,r=n.doc.resolve(e);let i=r.depth,s=!0;for(;i>0;)t.includes(r.node(i).type.name)&&(s=!1),i--;return s}return!0}})}));mf(Zm,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});const Qm=zp((e=>{const t=new al("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const r=e.get(Wf.key),o=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants(((n,l)=>{if(n.type===Hf.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let a=r(n);s[a]?(s[a]+=1,a+=`-#${s[a]}`):s[a]=1,e.id!==a&&(i=!0,o.setMeta(t,!0).setNodeMarkup(l,void 0,{...e,id:a}))}})),i&&n.dispatch(o)};return new il({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})}));mf(Qm,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});const eg=zp((e=>{const t=t=>{if(t.composing||!t.editable)return;const n=Mm.type(e),r=vm.type(e),o=Em.type(e),i=t.state,s=(e,t)=>{let n=!1;const r=`${t+1}.`;return e.label!==r&&(e.label=r,n=!0),n};let l=i.tr,a=!1;i.doc.descendants(((e,t,i,c)=>{if(e.type===r){const r=e.maybeChild(0);(null==r?void 0:r.type)===o&&"ordered"===r.attrs.listType&&(a=!0,l.setNodeMarkup(t,n,{spread:"true"}),e.descendants(((e,t,n,r)=>{if(e.type===o){const n={...e.attrs};s(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1})))}else if(e.type===o&&(null==i?void 0:i.type)===n){const n={...e.attrs};let r=!1;"ordered"!==n.listType&&(n.listType="ordered",r=!0),(null==i?void 0:i.maybeChild(0))&&(r=s(n,c)),r&&(l=l.setNodeMarkup(t,void 0,n),a=!0)}})),a&&t.dispatch(l.setMeta("addToHistory",!1))};return new il({key:new al("MILKDOWN_KEEP_LIST_ORDER"),view:e=>(t(e),{update:e=>{t(e)}})})}));mf(eg,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});const tg=[Gm,Xm,Zm,Ym,Hm,Km,qm,Um,Jm,Qm,eg].flat(),ng=[Fm,jm,_m,Wm,Vm,tg].flat();var rg,og;if("undefined"!=typeof WeakMap){let e=new WeakMap;rg=t=>e.get(t),og=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;rg=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},og=(r,o)=>(n==t&&(n=0),e[n++]=r,e[n++]=o)}var ig=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,o=t/this.width|0;let i=r+1,s=o+1;for(let e=1;i<this.width&&this.map[t+e]==n;e++)i++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==r:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?0==i:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:r,top:o,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==e){let n=t+e*this.width;const r=(e+1)*this.width;for(;n<r&&this.map[n]<o;)n++;return n==r?i-1:this.map[n]}o=i}}static get(e){return rg(e)||og(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const o=e.child(r);let i=0;if(n)for(let t=0;t<r;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const o=n.child(e);t+o.attrs.rowspan>r&&(i+=o.attrs.colspan)}}for(let e=0;e<o.childCount;e++){const t=o.child(e);i+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,r=[];let o=0,i=null;const s=[];for(let e=0,o=t*n;e<o;e++)r[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;o<r.length&&0!=r[o];)o++;if(e==c.childCount)break;const u=c.child(e),{colspan:d,rowspan:h,colwidth:p}=u.attrs;for(let e=0;e<h;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:h-e});break}const c=o+e*t;for(let e=0;e<d;e++){0==r[c+e]?r[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:d-e});const n=p&&p[e];if(n){const r=(c+e)%t*2,o=s[r];null==o||o!=n&&1==s[r+1]?(s[r]=n,s[r+1]=1):o==n&&s[r+1]++}}}o+=d,a+=u.nodeSize}const u=(l+1)*t;let d=0;for(;o<u;)0==r[o++]&&d++;d&&(i||(i=[])).push({type:"missing",row:l,n:d}),a++}const l=new ig(t,n,r,i);let a=!1;for(let e=0;!a&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(a=!0);return a&&function(e,t,n){e.problems||(e.problems=[]);const r={};for(let o=0;o<e.map.length;o++){const i=e.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const r=t[(o+n)%e.width*2];null==r||a.colwidth&&a.colwidth[n]==r||((l||(l=sg(a)))[n]=r)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e),l}(e))}};function sg(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function lg(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map((e=>Number(e))):null,o=Number(e.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const n in t){const r=t[n].getFromDOM,o=r&&r(e);null!=o&&(i[n]=o)}return i}function ag(e,t){const n={};1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(const r in t){const o=t[r].setDOMAttr;o&&o(e.attrs[r],n)}return n}function cg(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}var ug=new al("selectingCells");function dg(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function hg(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function pg(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=dg(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function fg(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function mg(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function gg(e,t,n){const r=e.node(-1),o=ig.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function yg(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some((e=>e>0))||(r.colwidth=null)),r}function wg(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}var kg=class e extends js{constructor(e,t=e){const n=e.node(-1),r=ig.get(n),o=e.start(-1),i=r.rectBetween(e.pos-o,t.pos-o),s=e.node(0),l=r.cellsInRect(i).filter((e=>e!=t.pos-o));l.unshift(t.pos-o);const a=l.map((e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const r=o+e+1;return new _s(s.resolve(r),s.resolve(r+t.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=t}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),o=t.resolve(n.map(this.$headCell.pos));if(fg(r)&&fg(o)&&mg(r,o)){const t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,o):t&&this.isColSelection()?e.colSelection(r,o):new e(r,o)}return Hs.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=ig.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[];for(let n=r.top;n<r.bottom;n++){const s=[];for(let i=n*t.width+r.left,l=r.left;l<r.right;l++,i++){const n=t.map[i];if(o[n])continue;o[n]=!0;const l=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=r.left-l.left,u=l.right-r.right;if(c>0||u>0){let e=a.attrs;if(c>0&&(e=yg(e,0,c)),u>0&&(e=yg(e,e.colspan-u,u)),l.left<r.left){if(a=a.type.createAndFill(e),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else a=a.type.create(e,a.content)}if(l.top<r.top||l.bottom>r.bottom){const e={...a.attrs,rowspan:Math.min(l.bottom,r.bottom)-Math.max(l.top,r.top)};a=l.top<r.top?a.type.createAndFill(e):a.type.create(e,a.content)}s.push(a)}i.push(e.child(n).copy(Ie.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?e:i;return new Be(Ie.from(s),1,1)}replace(e,t=Be.empty){const n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){const{$from:i,$to:s}=r[o],l=e.mapping.slice(n);e.replace(l.map(i.pos),l.map(s.pos),o?Be.empty:t)}const o=js.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new Be(Ie.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=ig.get(t),r=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<o.length;n++)e(t.nodeAt(o[n]),r+o[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),o=ig.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=ig.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(r,o)>0)return!1;const i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),o=ig.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(t=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new vg(this.$anchorCell.pos,this.$headCell.pos)}};kg.prototype.visible=!1,js.jsonID("cell",kg);var vg=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&mg(t,n)?new kg(t,n):js.near(n,1)}};function bg(e){if(!(e.selection instanceof kg))return null;const t=[];return e.selection.forEachCell(((e,n)=>{t.push(wd.node(n,n+e.nodeSize,{class:"selectedCell"}))})),bd.create(e.doc,t)}var xg=new al("fix-tables");function Cg(e,t,n,r){const o=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){const i=t.child(s);for(let t=l,r=Math.min(o,s+3);t<r;t++)if(e.child(t)==i){l=t+1,n+=i.nodeSize;continue e}r(i,n),l<o&&e.child(l).sameMarkup(i)?Cg(e.child(l),i,n+1,r):i.nodesBetween(0,i.content.size,r,n+1),n+=i.nodeSize}}function Sg(e,t){let n;const r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){const o=ig.get(t);if(!o.problems)return r;r||(r=e.tr);const i=[];for(let e=0;e<o.height;e++)i.push(0);for(let e=0;e<o.problems.length;e++){const s=o.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const o=e.attrs;for(let e=0;e<o.rowspan;e++)i[s.row+e]+=s.n;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,yg(o,o.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}}let s,l;for(let e=0;e<i.length;e++)i[e]&&(null==s&&(s=e),l=e);for(let a=0,c=n+1;a<o.height;a++){const n=t.child(a),o=c+n.nodeSize,u=i[a];if(u>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<u;n++){const n=cg(e.schema)[t].createAndFill();n&&i.push(n)}const d=0!=a&&s!=a-1||l!=a?o-1:c+1;r.insert(r.mapping.map(d),i)}c=o}return r.setMeta(xg,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&Cg(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Mg(e){const t=e.selection,n=pg(e),r=n.node(-1),o=n.start(-1),i=ig.get(r);return{...t instanceof kg?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Ng(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;(function(e,t,n){const r=cg(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0})(t,r,o+i)&&(i=0==o||o==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=r.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,wg(a.attrs,o-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?cg(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,c=t.positionAt(s,o,r);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function Tg(e,t){if(!hg(e))return!1;if(t){const n=Mg(e);t(Ng(e.tr,n,n.left))}return!0}function Og(e,t){if(!hg(e))return!1;if(t){const n=Mg(e);t(Ng(e.tr,n,n.right))}return!0}function Ag(e,{map:t,table:n,tableStart:r},o){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+o,a=t.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,yg(u,o-t.colCount(a)));else{const t=e.mapping.slice(i).map(r+a);e.delete(t,t+c.nodeSize)}s+=u.rowspan}}function Eg(e,{map:t,table:n,tableStart:r},o){let i=0;for(let e=0;e<o;e++)i+=n.child(e).nodeSize;const s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);const a=new Set;for(let i=0,s=o*t.width;i<t.width;i++,s++){const c=t.map[s];if(!a.has(c))if(a.add(c),o>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(l).map(c+r),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(o<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),a=s.attrs,u=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),d=t.positionAt(o+1,i,n);e.insert(e.mapping.slice(l).map(r+d),u),i+=a.colspan-1}}}function Ig(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<r.length;e++){const o=t.table.nodeAt(r[e]);if(o&&o.type!==n.header_cell)return!1}return!0}function Rg(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!hg(t))return!1;if(n){const r=cg(t.schema),o=Mg(t),i=t.tr,s=o.map.cellsInRect("column"==e?{left:o.left,top:0,right:o.right,bottom:o.map.height}:"row"==e?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map((e=>o.table.nodeAt(e)));for(let e=0;e<s.length;e++)l[e].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[e],r.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(o.tableStart+s[e],r.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!hg(t))return!1;if(n){const r=cg(t.schema),o=Mg(t),i=t.tr,s=Ig("row",o,r),l=Ig("column",o,r),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:o.map.height}:"row"==e?{left:a,top:0,right:o.map.width,bottom:1}:o,u="column"==e?l?r.cell:r.header_cell:"row"==e?s?r.cell:r.header_cell:r.cell;o.map.cellsInRect(c).forEach((e=>{const t=e+o.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,u,n.attrs)})),n(i)}return!0}}function Dg(e){return function(t,n){if(!hg(t))return!1;const r=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const r=e.node(-1).child(t),o=r.lastChild;if(o)return n-1-o.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}(pg(t),e);if(null==r)return!1;if(n){const e=t.doc.resolve(r);n(t.tr.setSelection(Hs.between(e,(o=e,o.node(0).resolve(o.pos+o.nodeAfter.nodeSize)))).scrollIntoView())}var o;return!0}}function Pg(e,t){const n=e.selection;if(!(n instanceof kg))return!1;if(t){const r=e.tr,o=cg(e.schema).cell.createAndFill().content;n.forEachCell(((e,t)=>{e.content.eq(o)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new Be(o,0,0))})),r.docChanged&&t(r)}return!0}function $g(e,t){const n=e.createAndFill();return new zs(n).replace(0,n.content.size,t).doc}function Lg(e,t,n,r,o,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=o;c<i;c++){const o=s*t.width+c,i=t.map[o];if(t.map[o-t.width]==i){a=!0;const o=n.nodeAt(i),{top:u,left:d}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+r),null,{...o.attrs,rowspan:s-u}),e.insert(e.mapping.slice(l).map(t.positionAt(s,d,n)),o.type.createAndFill({...o.attrs,rowspan:u+o.attrs.rowspan-s})),c+=o.attrs.colspan-1}}return a}function Bg(e,t,n,r,o,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=o;c<i;c++){const o=c*t.width+s,i=t.map[o];if(t.map[o-1]==i){a=!0;const o=n.nodeAt(i),u=t.colCount(i),d=e.mapping.slice(l).map(i+r);e.setNodeMarkup(d,null,yg(o.attrs,s-u,o.attrs.colspan-(s-u))),e.insert(d+o.nodeSize,o.type.createAndFill(yg(o.attrs,0,s-u))),c+=o.attrs.rowspan-1}}return a}function zg(e,t,n,r,o){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let s=ig.get(i);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=e.tr;let h=0;function p(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");s=ig.get(i),h=d.mapping.maps.length}(function(e,t,n,r,o,i,s){const l=cg(e.doc.type.schema);let a,c;if(o>t.width)for(let i=0,u=0;i<t.height;i++){const d=n.child(i);u+=d.nodeSize;const h=[];let p;p=null==d.lastChild||d.lastChild.type==l.cell?a||(a=l.cell.createAndFill()):c||(c=l.header_cell.createAndFill());for(let e=t.width;e<o;e++)h.push(p);e.insert(e.mapping.slice(s).map(u-1+r),h)}if(i>t.height){const u=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,o);e++){const o=!(e>=t.width)&&n.nodeAt(t.map[r+e]).type==l.header_cell;u.push(o?c||(c=l.header_cell.createAndFill()):a||(a=l.cell.createAndFill()))}const d=l.row.create(null,Ie.from(u)),h=[];for(let e=t.height;e<i;e++)h.push(d);e.insert(e.mapping.slice(s).map(r+n.nodeSize-2),h)}return!(!a&&!c)})(d,s,i,n,c,u,h)&&p(),Lg(d,s,i,n,a,c,l,h)&&p(),Lg(d,s,i,n,a,c,u,h)&&p(),Bg(d,s,i,n,l,u,a,h)&&p(),Bg(d,s,i,n,l,u,c,h)&&p();for(let e=l;e<u;e++){const t=s.positionAt(e,a,i),r=s.positionAt(e,c,i);d.replace(d.mapping.slice(h).map(t+n),d.mapping.slice(h).map(r+n),new Be(o.rows[e-l],0,0))}p(),d.setSelection(new kg(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(u-1,c-1,i)))),t(d)}Rg("row",{useDeprecatedLogic:!0}),Rg("column",{useDeprecatedLogic:!0}),Rg("cell",{useDeprecatedLogic:!0});var Fg=ja({ArrowLeft:_g("horiz",-1),ArrowRight:_g("horiz",1),ArrowUp:_g("vert",-1),ArrowDown:_g("vert",1),"Shift-ArrowLeft":Wg("horiz",-1),"Shift-ArrowRight":Wg("horiz",1),"Shift-ArrowUp":Wg("vert",-1),"Shift-ArrowDown":Wg("vert",1),Backspace:Pg,"Mod-Backspace":Pg,Delete:Pg,"Mod-Delete":Pg});function jg(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function _g(e,t){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof kg)return jg(n,r,js.near(i.$headCell,t));if("horiz"!=e&&!i.empty)return!1;const s=Kg(o,e,t);if(null==s)return!1;if("horiz"==e)return jg(n,r,js.near(n.doc.resolve(i.head+t),t));{const o=n.doc.resolve(s),i=gg(o,e,t);let l;return l=i?js.near(i,1):t<0?js.near(n.doc.resolve(o.before(-1)),-1):js.near(n.doc.resolve(o.after(-1)),1),jg(n,r,l)}}}function Wg(e,t){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof kg)s=i;else{const r=Kg(o,e,t);if(null==r)return!1;s=new kg(n.doc.resolve(r))}const l=gg(s.$headCell,e,t);return!!l&&jg(n,r,new kg(s.$anchorCell,l))}}function Vg(e,t){const n=dg(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new kg(n))),!0)}function Hg(e,t,n){if(!hg(e.state))return!1;let r=function(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;1==t.childCount&&(n>0&&r>0||"table"==t.child(0).type.spec.tableRole);)n--,r--,t=t.child(0).content;const o=t.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if("row"==i)for(let e=0;e<t.childCount;e++){let o=t.child(e).content;const i=e?0:Math.max(0,n-1),a=e<t.childCount-1?0:Math.max(0,r-1);(i||a)&&(o=$g(cg(s).row,new Be(o,i,a)).content),l.push(o)}else{if("cell"!=i&&"header_cell"!=i)return null;l.push(n||r?$g(cg(s).row,new Be(t,n,r)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const r=t[e];for(let t=r.childCount-1;t>=0;t--){const{rowspan:o,colspan:i}=r.child(t).attrs;for(let t=e;t<e+o;t++)n[t]=(n[t]||0)+i}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(Ie.empty),n[o]<r){const i=cg(e).cell.createAndFill(),s=[];for(let e=n[o];e<r;e++)s.push(i);t[o]=t[o].append(Ie.from(s))}return{height:t.length,width:r,rows:t}}(s,l)}(n);const o=e.state.selection;if(o instanceof kg){r||(r={width:1,height:1,rows:[Ie.from($g(cg(e.state.schema).cell,n))]});const t=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),s=ig.get(t).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=function({width:e,height:t,rows:n},r,o){if(e!=r){const t=[],o=[];for(let e=0;e<n.length;e++){const i=n[e],s=[];for(let n=t[e]||0,o=0;n<r;o++){let l=i.child(o%i.childCount);n+l.attrs.colspan>r&&(l=l.type.createChecked(yg(l.attrs,l.attrs.colspan,n+l.attrs.colspan-r),l.content)),s.push(l),n+=l.attrs.colspan;for(let n=1;n<l.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+l.attrs.colspan}o.push(Ie.from(s))}n=o,e=r}if(t!=o){const e=[];for(let r=0,i=0;r<o;r++,i++){const s=[],l=n[i%t];for(let e=0;e<l.childCount;e++){let t=l.child(e);r+t.attrs.rowspan>o&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,o-t.attrs.rowspan)},t.content)),s.push(t)}e.push(Ie.from(s))}n=e,t=o}return{width:e,height:t,rows:n}}(r,s.right-s.left,s.bottom-s.top),zg(e.state,e.dispatch,i,s,r),!0}if(r){const t=pg(e.state),n=t.start(-1);return zg(e.state,e.dispatch,n,ig.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function qg(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=Ug(e,t.target);let o;if(t.shiftKey&&e.state.selection instanceof kg)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(o=dg(e.state.selection.$anchor))&&(null==(n=Jg(e,t))?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(t,n){let r=Jg(e,n);const o=null==ug.getState(e.state);if(!r||!mg(t,r)){if(!o)return;r=t}const i=new kg(t,r);if(o||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);o&&n.setMeta(ug,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=ug.getState(e.state)&&e.dispatch(e.state.tr.setMeta(ug,-1))}function l(n){const o=n,l=ug.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(Ug(e,o.target)!=r&&(a=Jg(e,t),!a))return s();a&&i(a,o)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function Kg(e,t,n){if(!(e.state.selection instanceof Hs))return null;const{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=r.before(o),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function Ug(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function Jg(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?dg(e.state.doc.resolve(n.pos)):null}var Yg=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Gg(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Gg(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Gg(e,t,n,r,o,i){var s;let l=0,a=!0,c=t.firstChild;const u=e.firstChild;if(u){for(let e=0,n=0;e<u.childCount;e++){const{colspan:s,colwidth:d}=u.child(e).attrs;for(let e=0;e<s;e++,n++){const s=o==n?i:d&&d[e],u=s?s+"px":"";if(l+=s||r,s||(a=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{const e=document.createElement("col");e.style.width=u,t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Xg=new al("tableColumnResizing");var Zg=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,r=t.getMeta(Xg);if(r&&null!=r.setHandle)return new e(r.setHandle,!1);if(r&&void 0!==r.setDragging)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return fg(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function Qg(e,t,n,r){const o="right"==n?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=dg(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=ig.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function ey(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function ty(e,t){e.dispatch(e.state.tr.setMeta(Xg,{setHandle:t}))}function ny(e,t,n,r){const o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=ig.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=e.domAtPos(o.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Gg(i,a.firstChild,a,r,l,n)}function ry(e){return Array(e).fill(0)}var oy="undefined"!=typeof navigator?navigator:null,iy=oy&&oy.userAgent||"",sy=/Edge\/(\d+)/.exec(iy),ly=/MSIE \d/.exec(iy),ay=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(iy),cy=!(ly||ay||sy)&&!!oy&&/Apple Computer/.test(oy.vendor),uy=new al("safari-ime-span"),dy=!1;function hy(e){const t=e.dom.ownerDocument.createElement("span");return t.className="ProseMirror-safari-ime-span",t}var py=new il(cy?{key:uy,props:{decorations:function(e){const{$from:t,$to:n,to:r}=e.selection;if(dy&&t.sameParent(n)){const t=wd.widget(r,hy,{ignoreSelection:!0,key:"safari-ime-span"});return bd.create(e.doc,[t])}},handleDOMEvents:{compositionstart:()=>{dy=!0},compositionend:()=>{dy=!1}}}}:{key:uy});function fy(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;-1!==o;)r++,o=n.indexOf(t,o+t.length);return r}function my(e){return"function"==typeof e?e:function(){return e}}const gy="phrasing",yy=["autolink","link","image","label"];function wy(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ky(e){this.config.enter.autolinkProtocol.call(this,e)}function vy(e){this.config.exit.autolinkProtocol.call(this,e)}function by(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function xy(e){this.config.exit.autolinkEmail.call(this,e)}function Cy(e){this.exit(e)}function Sy(e){!function(e,t,n){const r=Qr((n||{}).ignore||[]),o=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const e=n[r];t.push([(o=e[0],"string"==typeof o?new RegExp(lf(o),"g"):o),my(e[1])])}var o;return t}(t);let i=-1;for(;++i<o.length;)so(e,"text",s);function s(e,t){let n,s=-1;for(;++s<t.length;){const e=t[s],o=n?n.children:void 0;if(r(e,o?o.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){const n=t[t.length-1],r=o[i][0],s=o[i][1];let l=0;const a=n.children.indexOf(e);let c=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){const n=d.index,o={index:d.index,input:d.input,stack:[...t,e]};let i=s(...d,o);if("string"==typeof i&&(i=i.length>0?{type:"text",value:i}:void 0),!1===i?r.lastIndex=n+1:(l!==n&&u.push({type:"text",value:e.value.slice(l,n)}),Array.isArray(i)?u.push(...i):i&&u.push(i),l=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}return c?(l<e.value.length&&u.push({type:"text",value:e.value.slice(l)}),n.children.splice(a,1,...u)):u=[e],a+u.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,My],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Ny]],{ignore:["link","linkReference"]})}function My(e,t,n,r,o){let i="";if(!Ty(o))return!1;if(/^w/i.test(t)&&(n=t+n,t="",i="http://"),!function(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}(n))return!1;const s=function(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const o=fy(e,"(");let i=fy(e,")");for(;-1!==r&&o>i;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[e,n]}(n+r);if(!s[0])return!1;const l={type:"link",title:null,url:i+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[l,{type:"text",value:s[1]}]:l}function Ny(e,t,n,r){return!(!Ty(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Ty(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||cn(n)||an(n))&&(!t||47!==n)}function Oy(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Ay(){this.buffer()}function Ey(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Pn(this.sliceSerialize(e)).toLowerCase()}function Iy(e){this.exit(e)}function Ry(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Dy(){this.buffer()}function Py(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Pn(this.sliceSerialize(e)).toLowerCase()}function $y(e){this.exit(e)}function Ly(e,t,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteReference"),l=n.enter("reference");return i+=o.move(n.safe(n.associationId(e),{...o.current(),before:i,after:"]"})),l(),s(),i+=o.move("]"),i}function By(e,t,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteDefinition"),l=n.enter("label");return i+=o.move(n.safe(n.associationId(e),{...o.current(),before:i,after:"]"})),l(),i+=o.move("]:"+(e.children&&e.children.length>0?" ":"")),o.shift(4),i+=o.move(n.indentLines(n.containerFlow(e,o.current()),zy)),s(),i}function zy(e,t,n){return 0===t?e:(n?"":" ")+e}Ly.peek=function(){return"["};const Fy=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function jy(e){this.enter({type:"delete",children:[]},e)}function _y(e){this.exit(e)}function Wy(e,t,n,r){const o=n.createTracker(r),i=n.enter("strikethrough");let s=o.move("~~");return s+=n.containerPhrasing(e,{...o.current(),before:s,after:"~"}),s+=o.move("~~"),i(),s}function Vy(e){return e.length}function Hy(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function qy(e){const t=e._align;this.enter({type:"table",align:t.map((function(e){return"none"===e?null:e})),children:[]},e),this.data.inTable=!0}function Ky(e){this.exit(e),this.data.inTable=void 0}function Uy(e){this.enter({type:"tableRow",children:[]},e)}function Jy(e){this.exit(e)}function Yy(e){this.enter({type:"tableCell",children:[]},e)}function Gy(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Xy));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Xy(e,t){return"|"===t?t:e}function Zy(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=bo.inlineCode(e,t,n);return n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&")),r},table:function(e,t,n,r){return l(function(e,t,n){const r=e.children;let o=-1;const i=[],s=t.enter("table");for(;++o<r.length;)i[o]=a(r[o],t,n);return s(),i}(e,n,r),e.align)},tableCell:s,tableRow:function(e,t,n,r){const o=l([a(e,n,r)]);return o.slice(0,o.indexOf("\n"))}}};function s(e,t,n,r){const o=n.enter("tableCell"),s=n.enter("phrasing"),l=n.containerPhrasing(e,{...r,before:i,after:i});return s(),o(),l}function l(e,t){return function(e,t){const n=t||{},r=(n.align||[]).concat(),o=n.stringLength||Vy,i=[],s=[],l=[],a=[];let c=0,u=-1;for(;++u<e.length;){const t=[],r=[];let i=-1;for(e[u].length>c&&(c=e[u].length);++i<e[u].length;){const s=null==(d=e[u][i])?"":String(d);if(!1!==n.alignDelimiters){const e=o(s);r[i]=e,(void 0===a[i]||e>a[i])&&(a[i]=e)}t.push(s)}s[u]=t,l[u]=r}var d;let h=-1;if("object"==typeof r&&"length"in r)for(;++h<c;)i[h]=Hy(r[h]);else{const e=Hy(r);for(;++h<c;)i[h]=e}h=-1;const p=[],f=[];for(;++h<c;){const e=i[h];let t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let o=!1===n.alignDelimiters?1:Math.max(1,a[h]-t.length-r.length);const s=t+"-".repeat(o)+r;!1!==n.alignDelimiters&&(o=t.length+o+r.length,o>a[h]&&(a[h]=o),f[h]=o),p[h]=s}s.splice(1,0,p),l.splice(1,0,f),u=-1;const m=[];for(;++u<s.length;){const e=s[u],t=l[u];h=-1;const r=[];for(;++h<c;){const o=e[h]||"";let s="",l="";if(!1!==n.alignDelimiters){const e=a[h]-(t[h]||0),n=i[h];114===n?s=" ".repeat(e):99===n?e%2?(s=" ".repeat(e/2+.5),l=" ".repeat(e/2-.5)):(s=" ".repeat(e/2),l=s):l=" ".repeat(e)}!1===n.delimiterStart||h||r.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===o||!1===n.delimiterStart&&!h||r.push(" "),!1!==n.alignDelimiters&&r.push(s),r.push(o),!1!==n.alignDelimiters&&r.push(l),!1!==n.padding&&r.push(" "),!1===n.delimiterEnd&&h===c-1||r.push("|")}m.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return m.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:o})}function a(e,t,n){const r=e.children;let o=-1;const i=[],l=t.enter("tableRow");for(;++o<r.length;)i[o]=s(r[o],0,t,n);return l(),i}}function Qy(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function ew(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const r=t.children;let o,i=-1;for(;++i<r.length;){const e=r[i];if("paragraph"===e.type){o=e;break}}o===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function tw(e,t,n,r){const o=e.children[0],i="boolean"==typeof e.checked&&o&&"paragraph"===o.type,s="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);i&&l.move(s);let a=bo.listItem(e,t,n,{...r,...l.current()});return i&&(a=a.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,(function(e){return e+s}))),a}Wy.peek=function(){return"~"};const nw={tokenize:function(e,t,n){let r=0;return function t(i){return(87===i||119===i)&&r<3?(r++,e.consume(i),t):46===i&&3===r?(e.consume(i),o):n(i)};function o(e){return null===e?n(e):t(e)}},partial:!0},rw={tokenize:function(e,t,n){let r,o,i;return s;function s(t){return 46===t||95===t?e.check(iw,a,l)(t):null===t||sn(t)||cn(t)||45!==t&&an(t)?a(t):(i=!0,e.consume(t),s)}function l(t){return 95===t?r=!0:(o=r,r=void 0),e.consume(t),s}function a(e){return o||r||!i?n(e):t(e)}},partial:!0},ow={tokenize:function(e,t){let n=0,r=0;return o;function o(s){return 40===s?(n++,e.consume(s),o):41===s&&r<n?i(s):33===s||34===s||38===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||60===s||63===s||93===s||95===s||126===s?e.check(iw,t,i)(s):null===s||sn(s)||cn(s)?t(s):(e.consume(s),o)}function i(t){return 41===t&&r++,e.consume(t),o}},partial:!0},iw={tokenize:function(e,t,n){return r;function r(s){return 33===s||34===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||63===s||95===s||126===s?(e.consume(s),r):38===s?(e.consume(s),i):93===s?(e.consume(s),o):60===s||null===s||sn(s)||cn(s)?t(s):n(s)}function o(e){return null===e||40===e||91===e||sn(e)||cn(e)?t(e):r(e)}function i(e){return Xt(e)?s(e):n(e)}function s(t){return 59===t?(e.consume(t),r):Xt(t)?(e.consume(t),s):n(t)}},partial:!0},sw={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Zt(e)?n(e):t(e)}},partial:!0},lw={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){return 87!==t&&119!==t||!hw.call(r,r.previous)||gw(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(nw,e.attempt(rw,e.attempt(ow,o),n),n)(t))};function o(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:hw},aw={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let o="",i=!1;return function(t){return 72!==t&&104!==t||!pw.call(r,r.previous)||gw(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(t),e.consume(t),s)};function s(t){if(Xt(t)&&o.length<5)return o+=String.fromCodePoint(t),e.consume(t),s;if(58===t){const n=o.toLowerCase();if("http"===n||"https"===n)return e.consume(t),l}return n(t)}function l(t){return 47===t?(e.consume(t),i?a:(i=!0,l)):n(t)}function a(t){return null===t||en(t)||sn(t)||cn(t)||an(t)?n(t):e.attempt(rw,e.attempt(ow,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:pw},cw={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let o,i;return function(t){return mw(t)&&fw.call(r,r.previous)&&!gw(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(t)):n(t)};function s(t){return mw(t)?(e.consume(t),s):64===t?(e.consume(t),l):n(t)}function l(t){return 46===t?e.check(sw,c,a)(t):45===t||95===t||Zt(t)?(i=!0,e.consume(t),l):c(t)}function a(t){return e.consume(t),o=!0,l}function c(s){return i&&o&&Xt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(s)):n(s)}},previous:fw},uw={};let dw=48;for(;dw<123;)uw[dw]=cw,dw++,58===dw?dw=65:91===dw&&(dw=97);function hw(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||sn(e)}function pw(e){return!Xt(e)}function fw(e){return!(47===e||mw(e))}function mw(e){return 43===e||45===e||46===e||95===e||Zt(e)}function gw(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}uw[43]=cw,uw[45]=cw,uw[46]=cw,uw[95]=cw,uw[72]=[cw,aw],uw[104]=[cw,aw],uw[87]=[cw,lw],uw[119]=[cw,lw];const yw={tokenize:function(e,t,n){const r=this;return dn(e,(function(e){const o=r.events[r.events.length-1];return o&&"gfmFootnoteDefinitionIndent"===o[1].type&&4===o[2].sliceSerialize(o[1],!0).length?t(e):n(e)}),"gfmFootnoteDefinitionIndent",5)},partial:!0};function ww(e,t,n){const r=this;let o=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;o--;){const e=r.events[o][1];if("labelImage"===e.type){s=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(o){if(!s||!s._balanced)return n(o);const l=Pn(r.sliceSerialize({start:s.end,end:r.now()}));return 94===l.codePointAt(0)&&i.includes(l.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),t(o)):n(o)}}function kw(e,t){let n,r=e.length;for(;r--;)if("labelImage"===e[r][1].type&&"enter"===e[r][0]){n=e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const o={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[r+1],e[r+2],["enter",o,t],e[r+3],e[r+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",o,t]];return e.splice(r,e.length-r+1,...a),e}function vw(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,s=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),l};function l(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",a)}function a(l){if(s>999||93===l&&!i||null===l||91===l||sn(l))return n(l);if(93===l){e.exit("chunkString");const i=e.exit("gfmFootnoteCallString");return o.includes(Pn(r.sliceSerialize(i)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(l)}return sn(l)||(i=!0),s++,e.consume(l),92===l?c:a}function c(t){return 91===t||92===t||93===t?(e.consume(t),s++,a):a(t)}}function bw(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,s,l=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),a};function a(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(l>999||93===t&&!s||null===t||91===t||sn(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return i=Pn(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return sn(t)||(s=!0),l++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o.includes(i)||o.push(i),dn(e,h,"gfmFootnoteDefinitionWhitespace")):n(t)}function h(e){return t(e)}}function xw(e,t,n){return e.check(mn,t,e.attempt(yw,t,n))}function Cw(e){e.exit("gfmFootnoteDefinition")}function Sw(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,r){const o=this.previous,i=this.events;let s=0;return function(t){return 126===o&&"characterEscape"!==i[i.length-1][1].type?r(t):(e.enter("strikethroughSequenceTemporary"),l(t))};function l(i){const a=ir(o);if(126===i)return s>1?r(i):(e.consume(i),s++,l);if(s<2&&!t)return r(i);const c=e.exit("strikethroughSequenceTemporary"),u=ir(i);return c._open=!u||2===u&&Boolean(a),c._close=!a||2===a&&Boolean(u),n(i)}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";const o={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},i={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},s=[["enter",o,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",i,t]],l=t.parser.constructs.insideSpan.null;l&&_t(s,s.length,0,Qn(l,e.slice(r+1,n),t)),_t(s,s.length,0,[["exit",i,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",o,t]]),_t(e,r-1,n-r+3,s),n=r+s.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}};return null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class Mw{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let o=0;if(0!==n||0!==r.length){for(;o<e.map.length;){if(e.map[o][0]===t)return e.map[o][1]+=n,void e.map[o][2].push(...r);o+=1}e.map.push([t,n,r])}}(this,e,t,n)}consume(e){if(this.map.sort((function(e,t){return e[0]-t[0]})),0===this.map.length)return;let t=this.map.length;const n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push([...e]),e.length=0;let r=n.pop();for(;r;)e.push(...r),r=n.pop();this.map.length=0}}function Nw(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if("enter"===o[0])"tableContent"===o[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===o[1].type){if("tableDelimiterMarker"===e[t-1][1].type){const e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===o[1].type)break}else"enter"===o[0]&&"tableDelimiterRow"===o[1].type&&(n=!0);t+=1}return r}function Tw(e,t,n){const r=this;let o,i=0,s=0;return function(e){let t=r.events.length-1;for(;t>-1;){const e=r.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const o=t>-1?r.events[t][1].type:null,i="tableHead"===o||"tableRow"===o?v:l;return i===v&&r.parser.lazy[r.now().line]?n(e):i(e)};function l(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){return 124===e||(o=!0,s+=1),a(e)}(t)}function a(t){return null===t?n(t):on(t)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):ln(t)?dn(e,a,"whitespace")(t):(s+=1,o&&(o=!1,i+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),o=!0,a):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||sn(t)?(e.exit("data"),a(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),o=!1,ln(t)?dn(e,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):h(t))}function h(t){return 45===t||58===t?f(t):124===t?(o=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),p):k(t)}function p(t){return ln(t)?dn(e,f,"whitespace")(t):f(t)}function f(t){return 58===t?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),m):45===t?(s+=1,m(t)):null===t||on(t)?w(t):k(t)}function m(t){return 45===t?(e.enter("tableDelimiterFiller"),g(t)):k(t)}function g(t){return 45===t?(e.consume(t),g):58===t?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(t))}function y(t){return ln(t)?dn(e,w,"whitespace")(t):w(t)}function w(n){return 124===n?h(n):(null===n||on(n))&&o&&i===s?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):k(n)}function k(e){return n(e)}function v(t){return e.enter("tableRow"),b(t)}function b(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),b):null===n||on(n)?(e.exit("tableRow"),t(n)):ln(n)?dn(e,b,"whitespace")(n):(e.enter("data"),x(n))}function x(t){return null===t||124===t||sn(t)?(e.exit("data"),b(t)):(e.consume(t),92===t?C:x)}function C(t){return 92===t||124===t?(e.consume(t),x):x(t)}}function Ow(e,t){let n,r,o,i=-1,s=!0,l=0,a=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const h=new Mw;for(;++i<e.length;){const p=e[i],f=p[1];"enter"===p[0]?"tableHead"===f.type?(u=!1,0!==d&&(Ew(h,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},f.start),end:Object.assign({},f.end)},h.add(i,0,[["enter",n,t]])):"tableRow"===f.type||"tableDelimiterRow"===f.type?(s=!0,o=void 0,a=[0,0,0,0],c=[0,i+1,0,0],u&&(u=!1,r={type:"tableBody",start:Object.assign({},f.start),end:Object.assign({},f.end)},h.add(i,0,[["enter",r,t]])),l="tableDelimiterRow"===f.type?2:r?3:1):!l||"data"!==f.type&&"tableDelimiterMarker"!==f.type&&"tableDelimiterFiller"!==f.type?"tableCellDivider"===f.type&&(s?s=!1:(0!==a[1]&&(c[0]=c[1],o=Aw(h,t,a,l,void 0,o)),a=c,c=[a[1],i,0,0])):(s=!1,0===c[2]&&(0!==a[1]&&(c[0]=c[1],o=Aw(h,t,a,l,void 0,o),a=[0,0,0,0]),c[2]=i)):"tableHead"===f.type?(u=!0,d=i):"tableRow"===f.type||"tableDelimiterRow"===f.type?(d=i,0!==a[1]?(c[0]=c[1],o=Aw(h,t,a,l,i,o)):0!==c[1]&&(o=Aw(h,t,c,l,i,o)),l=0):!l||"data"!==f.type&&"tableDelimiterMarker"!==f.type&&"tableDelimiterFiller"!==f.type||(c[3]=i)}for(0!==d&&Ew(h,t,d,n,r),h.consume(t.events),i=-1;++i<t.events.length;){const e=t.events[i];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=Nw(t.events,i))}return e}function Aw(e,t,n,r,o,i){const s=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(i.end=Object.assign({},Iw(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=Iw(t.events,n[1]);if(i={type:s,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",i,t]]),0!==n[2]){const o=Iw(t.events,n[2]),i=Iw(t.events,n[3]),s={type:"tableContent",start:Object.assign({},o),end:Object.assign({},i)};if(e.add(n[2],0,[["enter",s,t]]),2!==r){const r=t.events[n[2]],o=t.events[n[3]];if(r[1].end=Object.assign({},o[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){const t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",s,t]])}return void 0!==o&&(i.end=Object.assign({},Iw(t.events,o)),e.add(o,0,[["exit",i,t]]),i=void 0),i}function Ew(e,t,n,r,o){const i=[],s=Iw(t.events,n);o&&(o.end=Object.assign({},s),i.push(["exit",o,t])),r.end=Object.assign({},s),i.push(["exit",r,t]),e.add(n+1,0,i)}function Iw(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const Rw={name:"tasklistCheck",tokenize:function(e,t,n){const r=this;return function(t){return null===r.previous&&r._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),o):n(t)};function o(t){return sn(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),i):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),i):n(t)}function i(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(t)}function s(r){return on(r)?t(r):ln(r)?e.check({tokenize:Dw},t,n)(r):n(r)}}};function Dw(e,t,n){return dn(e,(function(e){return null===e?n(e):t(e)}),"whitespace")}const Pw={};function $w(e){const t=e||Pw,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),i=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return Jt([{text:uw},{document:{91:{name:"gfmFootnoteDefinition",tokenize:bw,continuation:{tokenize:xw},exit:Cw}},text:{91:{name:"gfmFootnoteCall",tokenize:vw},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ww,resolveTo:kw}}},Sw(e),{flow:{null:{name:"table",tokenize:Tw,resolveAll:Ow}}},{text:{91:Rw}}])}(t)),o.push([{transforms:[Sy],enter:{literalAutolink:wy,literalAutolinkEmail:ky,literalAutolinkHttp:ky,literalAutolinkWww:ky},exit:{literalAutolink:Cy,literalAutolinkEmail:xy,literalAutolinkHttp:vy,literalAutolinkWww:by}},{enter:{gfmFootnoteDefinition:Oy,gfmFootnoteDefinitionLabelString:Ay,gfmFootnoteCall:Ry,gfmFootnoteCallString:Dy},exit:{gfmFootnoteDefinition:Iy,gfmFootnoteDefinitionLabelString:Ey,gfmFootnoteCall:$y,gfmFootnoteCallString:Py}},{canContainEols:["delete"],enter:{strikethrough:jy},exit:{strikethrough:_y}},{enter:{table:qy,tableData:Yy,tableHeader:Yy,tableRow:Uy},exit:{codeText:Gy,table:Ky,tableData:Jy,tableHeader:Jy,tableRow:Jy}},{exit:{taskListCheckValueChecked:Qy,taskListCheckValueUnchecked:Qy,paragraph:ew}}]),i.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:gy,notInConstruct:yy},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:gy,notInConstruct:yy},{character:":",before:"[ps]",after:"\\/",inConstruct:gy,notInConstruct:yy}]},{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:By,footnoteReference:Ly}},{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Fy}],handlers:{delete:Wy}},Zy(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:tw}}]}}(t))}function Lw(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-gfm",...t}}),e}const Bw=Yp("strike_through");Lw(Bw,{displayName:"Attr<strikethrough>",group:"Strikethrough"});const zw=Kp("strike_through",(e=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>"line-through"===e}],toDOM:t=>["del",e.get(Bw.key)(t)],parseMarkdown:{match:e=>"delete"===e.type,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strike_through"===e.type.name,runner:(e,t)=>{e.withMark(t,"delete")}}})));Lw(zw.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"}),Lw(zw.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});const Fw=Ep("ToggleStrikeThrough",(e=>()=>Ca(zw.type(e))));Lw(Fw,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});const jw=Rp((e=>Ll(/~([^~]+)~$/,zw.type(e))));Lw(jw,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});const _w=Up("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:e=>{const t=e.get(Dh);return()=>t.call(Fw.key)}}});Lw(_w.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"}),Lw(_w.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});const Ww=function(e){const t=e.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const e in t)n[e]={default:t[e].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:e=>lg(e,t)}],toDOM:e=>["td",ag(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>lg(e,t)}],toDOM:e=>["th",ag(e,t),0]}}}({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:e=>e.style.textAlign||"left",setDOMAttr:(e,t)=>{t.style=`text-align: ${e||"left"}`}}}}),Vw=qp("table",(()=>({...Ww.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:e=>"table"===e.type,runner:(e,t,n)=>{const r=t.align,o=t.children.map(((e,t)=>({...e,align:r,isHeader:0===t})));e.openNode(n),e.next(o),e.closeNode()}},toMarkdown:{match:e=>"table"===e.type.name,runner:(e,t)=>{var n;const r=null==(n=t.content.firstChild)?void 0:n.content;if(!r)return;const o=[];r.forEach((e=>{o.push(e.attrs.alignment)})),e.openNode("table",void 0,{align:o}),e.next(t.content),e.closeNode()}}})));Lw(Vw.node,{displayName:"NodeSchema<table>",group:"Table"}),Lw(Vw.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});const Hw=qp("table_header_row",(()=>({...Ww.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"}],toDOM:()=>["tr",{"data-is-header":!0},0],parseMarkdown:{match:e=>!("tableRow"!==e.type||!e.isHeader),runner:(e,t,n)=>{const r=t.align,o=t.children.map(((e,n)=>({...e,align:r[n],isHeader:t.isHeader})));e.openNode(n),e.next(o),e.closeNode()}},toMarkdown:{match:e=>"table_header_row"===e.type.name,runner:(e,t)=>{e.openNode("tableRow",void 0,{isHeader:!0}),e.next(t.content),e.closeNode()}}})));Lw(Hw.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"}),Lw(Hw.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});const qw=qp("table_row",(()=>({...Ww.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:e=>"tableRow"===e.type,runner:(e,t,n)=>{const r=t.align,o=t.children.map(((e,t)=>({...e,align:r[t]})));e.openNode(n),e.next(o),e.closeNode()}},toMarkdown:{match:e=>"table_row"===e.type.name,runner:(e,t)=>{e.openNode("tableRow"),e.next(t.content),e.closeNode()}}})));Lw(qw.node,{displayName:"NodeSchema<tableRow>",group:"Table"}),Lw(qw.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});const Kw=qp("table_cell",(()=>({...Ww.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>"tableCell"===e.type&&!e.isHeader,runner:(e,t,n)=>{const r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>"table_cell"===e.type.name,runner:(e,t)=>{e.openNode("tableCell").next(t.content).closeNode()}}})));Lw(Kw.node,{displayName:"NodeSchema<tableCell>",group:"Table"}),Lw(Kw.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});const Uw=qp("table_header",(()=>({...Ww.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>"tableCell"===e.type&&!!e.isHeader,runner:(e,t,n)=>{const r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>"table_header"===e.type.name,runner:(e,t)=>{e.openNode("tableCell"),e.next(t.content),e.closeNode()}}})));function Jw(e,t=3,n=3){const r=Array(n).fill(0).map((()=>Kw.type(e).createAndFill())),o=Array(n).fill(0).map((()=>Uw.type(e).createAndFill())),i=Array(t).fill(0).map(((t,n)=>0===n?Hw.type(e).create(null,o):qw.type(e).create(null,r)));return Vw.type(e).create(null,i)}function Yw(e){return sa((e=>"table"===e.type.spec.tableRole))(e)}function Gw(e,t){const n=Yw(t.$from);if(!n)return;const r=ig.get(n.node);return e<0||e>=r.width?void 0:r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map((e=>{const t=n.node.nodeAt(e);if(!t)return;const r=e+n.start;return{pos:r,start:r+1,node:t}})).filter((e=>null!=e))}function Xw(e,t){const n=Yw(t.$from);if(!n)return;const r=ig.get(n.node);return e<0||e>=r.height?void 0:r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map((e=>{const t=n.node.nodeAt(e);if(!t)return;const r=e+n.start;return{pos:r,start:r+1,node:t}})).filter((e=>null!=e))}function Zw(e){const t=Yw(e.$from);if(!t)return;const n=ig.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map((e=>{const n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}}))}function Qw(e){const t=Zw(e.selection);if(t&&t[0]){const n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){const t=e.doc.resolve(r.pos);return Xl(e.setSelection(new kg(t,n)))}}return e}function ek(e,t,{map:n,tableStart:r,table:o},i){const s=Array(i).fill(0).reduce(((e,t,n)=>e+o.child(n).nodeSize),r),l=Array(n.width).fill(0).map(((t,r)=>{const i=o.nodeAt(n.map[r]);return Kw.type(e).createAndFill({alignment:null==i?void 0:i.attrs.alignment})}));return t.insert(s,qw.type(e).create(null,l)),t}function tk(e){return(t,n)=>r=>{n=n??r.selection.from;const o=r.doc.resolve(n),i=sa((e=>"table"===e.type.name))(o),s=i?{node:i.node,from:i.start}:void 0,l="row"===e;if(s){const e=ig.get(s.node);if(t>=0&&t<(l?e.height:e.width)){const n=e.positionAt(l?t:e.height-1,l?e.width-1:t,s.node),o=r.doc.resolve(s.from+n),i=l?kg.rowSelection:kg.colSelection,a=e.positionAt(l?t:0,l?0:t,s.node),c=r.doc.resolve(s.from+a);return Xl(r.setSelection(i(o,c)))}}return r}}Lw(Uw.node,{displayName:"NodeSchema<tableHeader>",group:"Table"}),Lw(Uw.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});const nk=tk("row"),rk=tk("col");function ok(e){return e[0].map(((t,n)=>e.map((e=>e[n]))))}function ik(e,t){const n=[],r=ig.get(e);for(let o=0;o<r.height;o++){const i=e.child(o),s=[];for(let n=0;n<r.width;n++){if(!t[o][n])continue;const i=r.map[o*r.width+n],l=t[o][n],a=e.nodeAt(i).type.createChecked(Object.assign({},l.attrs),l.content,l.marks);s.push(a)}n.push(i.type.createChecked(i.attrs,s,i.marks))}return e.type.createChecked(e.attrs,n,e.marks)}function sk(e){const t=ig.get(e),n=[];for(let r=0;r<t.height;r++){const o=[],i={};for(let n=0;n<t.width;n++){const s=t.map[r*t.width+n],l=e.nodeAt(s),a=t.findCell(s);i[s]||a.top!==r?o.push(null):(i[s]=!0,o.push(l))}n.push(o)}return n}function lk(e,t,n,r){const o=t[0]>n[0]?-1:1,i=e.splice(t[0],t.length),s=i.length%2==0?1:0;let l;return l=-1===o?n[0]:n[n.length-1]-s,e.splice(l,0,...i),e}function ak(e,t){let n=e,r=e;for(let o=e;o>=0;o--){const e=Gw(o,t.selection);e&&e.forEach((e=>{const t=e.node.attrs.colspan+o-1;t>=n&&(n=o),t>r&&(r=t)}))}for(let n=e;n<=r;n++){const e=Gw(n,t.selection);e&&e.forEach((e=>{const t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>r&&(r=t)}))}const o=[];for(let e=n;e<=r;e++){const n=Gw(e,t.selection);n&&n.length&&o.push(e)}n=o[0],r=o[o.length-1];const i=Gw(n,t.selection),s=Xw(0,t.selection),l=t.doc.resolve(i[i.length-1].pos);let a;for(let e=r;e>=n;e--){const n=Gw(e,t.selection);if(n&&n.length){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){a=n[0];break}if(a)break}}return{$anchor:l,$head:t.doc.resolve(a.pos),indexes:o}}function ck(e,t){let n=e,r=e;for(let o=e;o>=0;o--)Xw(o,t.selection).forEach((e=>{const t=e.node.attrs.rowspan+o-1;t>=n&&(n=o),t>r&&(r=t)}));for(let n=e;n<=r;n++)Xw(n,t.selection).forEach((e=>{const t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>r&&(r=t)}));const o=[];for(let e=n;e<=r;e++){const n=Xw(e,t.selection);n&&n.length&&o.push(e)}n=o[0],r=o[o.length-1];const i=Xw(n,t.selection),s=Gw(0,t.selection),l=t.doc.resolve(i[i.length-1].pos);let a;for(let e=r;e>=n;e--){const n=Xw(e,t.selection);if(n&&n.length){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){a=n[0];break}if(a)break}}return{$anchor:l,$head:t.doc.resolve(a.pos),indexes:o}}function uk(e){const{tr:t,origin:n,target:r,select:o=!0,pos:i}=e,s=Yw(null!=i?t.doc.resolve(i):t.selection.$from);if(!s)return t;const{indexes:l}=ak(n,t),{indexes:a}=ak(r,t);if(l.includes(r))return t;const c=function(e,t,n,r){let o=ok(sk(e.node));return o=lk(o,t,n),o=ok(o),ik(e.node,o)}(s,l,a),u=Xl(t).replaceWith(s.pos,s.pos+s.node.nodeSize,c);if(!o)return u;const d=ig.get(c),h=s.start,p=r,f=d.positionAt(d.height-1,p,c),m=u.doc.resolve(h+f),g=kg.colSelection,y=d.positionAt(0,p,c),w=u.doc.resolve(h+y);return u.setSelection(g(m,w))}function dk(e){const{tr:t,origin:n,target:r,select:o=!0,pos:i}=e,s=Yw(null!=i?t.doc.resolve(i):t.selection.$from);if(!s)return t;const{indexes:l}=ck(n,t),{indexes:a}=ck(r,t);if(l.includes(r))return t;const c=function(e,t,n,r){let o=sk(e.node);return o=lk(o,t,n),ik(e.node,o)}(s,l,a),u=Xl(t).replaceWith(s.pos,s.pos+s.node.nodeSize,c);if(!o)return u;const d=ig.get(c),h=s.start,p=r,f=d.positionAt(p,d.width-1,c),m=u.doc.resolve(h+f),g=kg.rowSelection,y=d.positionAt(p,0,c),w=u.doc.resolve(h+y);return u.setSelection(g(m,w))}const hk=Ep("GoToPrevTableCell",(()=>()=>Dg(-1)));Lw(hk,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});const pk=Ep("GoToNextTableCell",(()=>()=>Dg(1)));Lw(pk,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});const fk=Ep("ExitTable",(e=>()=>(t,n)=>{if(!hg(t))return!1;const{$head:r}=t.selection,o=ra(r,Vw.type(e));if(!o)return!1;const{to:i}=o,s=t.tr.replaceWith(i,i,zf.type(e).createAndFill());return s.setSelection(js.near(s.doc.resolve(i),1)).scrollIntoView(),null==n||n(s),!0}));Lw(fk,{displayName:"Command<breakTableCommand>",group:"Table"});const mk=Ep("InsertTable",(e=>({row:t,col:n}={})=>(r,o)=>{const{selection:i,tr:s}=r,{from:l}=i,a=Jw(e,t,n),c=s.replaceSelectionWith(a),u=js.findFrom(c.doc.resolve(l),1,!0);return u&&c.setSelection(u),null==o||o(c),!0}));Lw(mk,{displayName:"Command<insertTableCommand>",group:"Table"});const gk=Ep("MoveRow",(()=>({from:e,to:t,pos:n}={})=>(r,o)=>{const{tr:i}=r;return!!(null==o?void 0:o(dk({tr:i,origin:e??0,target:t??0,pos:n,select:!0})))}));Lw(gk,{displayName:"Command<moveRowCommand>",group:"Table"});const yk=Ep("MoveCol",(()=>({from:e,to:t,pos:n}={})=>(r,o)=>{const{tr:i}=r;return!!(null==o?void 0:o(uk({tr:i,origin:e??0,target:t??0,pos:n,select:!0})))}));Lw(yk,{displayName:"Command<moveColCommand>",group:"Table"});const wk=Ep("SelectRow",(()=>(e={index:0})=>(t,n)=>{const{tr:r}=t;return!!(null==n?void 0:n(nk(e.index,e.pos)(r)))}));Lw(wk,{displayName:"Command<selectRowCommand>",group:"Table"});const kk=Ep("SelectCol",(()=>(e={index:0})=>(t,n)=>{const{tr:r}=t;return!!(null==n?void 0:n(rk(e.index,e.pos)(r)))}));Lw(kk,{displayName:"Command<selectColCommand>",group:"Table"});const vk=Ep("SelectTable",(()=>()=>(e,t)=>{const{tr:n}=e;return!!(null==t?void 0:t(Qw(n)))}));Lw(vk,{displayName:"Command<selectTableCommand>",group:"Table"});const bk=Ep("DeleteSelectedCells",(()=>()=>(e,t)=>{const{selection:n}=e;if(!(n instanceof kg))return!1;const r=n.isRowSelection(),o=n.isColSelection();return r&&o?function(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}(e,t):o?function(e,t){if(!hg(e))return!1;if(t){const n=Mg(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;Ag(r,n,e),e!=n.left;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=ig.get(e)}t(r)}return!0}(e,t):function(e,t){if(!hg(e))return!1;if(t){const n=Mg(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Eg(r,n,e),e!=n.top;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=ig.get(n.table)}t(r)}return!0}(e,t)}));Lw(bk,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});const xk=Ep("AddColBefore",(()=>()=>Tg));Lw(xk,{displayName:"Command<addColBeforeCommand>",group:"Table"});const Ck=Ep("AddColAfter",(()=>()=>Og));Lw(Ck,{displayName:"Command<addColAfterCommand>",group:"Table"});const Sk=Ep("AddRowBefore",(e=>()=>(t,n)=>{if(!hg(t))return!1;if(n){const r=Mg(t);n(ek(e,t.tr,r,r.top))}return!0}));Lw(Sk,{displayName:"Command<addRowBeforeCommand>",group:"Table"});const Mk=Ep("AddRowAfter",(e=>()=>(t,n)=>{if(!hg(t))return!1;if(n){const r=Mg(t);n(ek(e,t.tr,r,r.bottom))}return!0}));Lw(Mk,{displayName:"Command<addRowAfterCommand>",group:"Table"});const Nk=Ep("SetAlign",(()=>(e="left")=>{return t="alignment",n=e,function(e,r){if(!hg(e))return!1;const o=pg(e);if(o.nodeAfter.attrs[t]===n)return!1;if(r){const i=e.tr;e.selection instanceof kg?e.selection.forEachCell(((e,r)=>{e.attrs[t]!==n&&i.setNodeMarkup(r,null,{...e.attrs,[t]:n})})):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:n}),r(i)}return!0};var t,n}));Lw(Nk,{displayName:"Command<setAlignCommand>",group:"Table"});const Tk=Rp((e=>new cl(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,((t,n,r,o)=>{var i,s;const l=t.doc.resolve(r);if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),Vw.type(e)))return null;const a=Jw(e,Number(null==(i=n.groups)?void 0:i.row),Number(null==(s=n.groups)?void 0:s.col)),c=t.tr.replaceRangeWith(r,o,a);return c.setSelection(Hs.create(c.doc,r+3)).scrollIntoView()}))));Lw(Tk,{displayName:"InputRule<insertTableInputRule>",group:"Table"});const Ok=Up("tableKeymap",{NextCell:{shortcuts:["Mod-]","Tab"],command:e=>{const t=e.get(Dh);return()=>t.call(pk.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:e=>{const t=e.get(Dh);return()=>t.call(hk.key)}},ExitTable:{shortcuts:["Mod-Enter"],command:e=>{const t=e.get(Dh);return()=>t.call(fk.key)}}});Lw(Ok.ctx,{displayName:"KeymapCtx<table>",group:"Table"}),Lw(Ok.shortcuts,{displayName:"Keymap<table>",group:"Table"});const Ak="footnote_definition",Ek="footnoteDefinition",Ik=qp("footnote_definition",(()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:""}},parseDOM:[{tag:`dl[data-type="${Ak}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{label:e.dataset.label}},contentElement:"dd"}],toDOM:e=>{const t=e.attrs.label;return["dl",{"data-label":t,"data-type":Ak},["dt",t],["dd",0]]},parseMarkdown:{match:({type:e})=>e===Ek,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===Ak,runner:(e,t)=>{e.openNode(Ek,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}})));Lw(Ik.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"}),Lw(Ik.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});const Rk="footnote_reference",Dk=qp("footnote_reference",(()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:""}},parseDOM:[{tag:`sup[data-type="${Rk}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{label:e.dataset.label}}}],toDOM:e=>{const t=e.attrs.label;return["sup",{"data-label":t,"data-type":Rk},t]},parseMarkdown:{match:({type:e})=>"footnoteReference"===e,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===Rk,runner:(e,t)=>{e.addNode("footnoteReference",void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}})));Lw(Dk.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"}),Lw(Dk.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});const Pk=Em.extendSchema((e=>t=>{const n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:e=>{if(!(e instanceof HTMLElement))throw j(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?"true"===e.dataset.checked:null}}},...(null==n?void 0:n.parseDOM)||[]],toDOM:e=>n.toDOM&&null==e.attrs.checked?n.toDOM(e):["li",{"data-item-type":"task","data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,r)=>{if(null==t.checked)return void n.parseMarkdown.runner(e,t,r);const o=null!=t.label?`${t.label}.`:"•",i=null!=t.checked?!!t.checked:null,s=null!=t.label?"ordered":"bullet",l=null!=t.spread?`${t.spread}`:"true";e.openNode(r,{label:o,listType:s,spread:l,checked:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{if(null==t.attrs.checked)return void n.toMarkdown.runner(e,t);const r=t.attrs.label,o=t.attrs.listType,i="true"===t.attrs.spread,s=t.attrs.checked;e.openNode("listItem",void 0,{label:r,listType:o,spread:i,checked:s}),e.next(t.content),e.closeNode()}}}}));Lw(Pk,{displayName:"NodeSchema<listItem>",group:"ListItem"});const $k=Rp((()=>new cl(/^\[(?<checked>\s|x)\]\s$/,((e,t,n,r)=>{var o;const i=e.doc.resolve(n);let s=0,l=i.node(s);for(;l&&"list_item"!==l.type.name;)s--,l=i.node(s);if(!l||null!=l.attrs.checked)return null;const a="x"===(null==(o=t.groups)?void 0:o.checked),c=i.before(s),u=e.tr;return u.deleteRange(n,r).setNodeMarkup(c,void 0,{...l.attrs,checked:a}),u}))));Lw($k,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});const Lk=[_w,Ok].flat(),Bk=[Tk,$k],zk=[jw],Fk=zp((()=>py));Lw(Fk,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});const jk=zp((()=>function({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Yg,lastColumnResizable:o=!0}={}){const i=new il({key:Xg,state:{init(e,t){var o,s;const l=null==(s=null==(o=i.spec)?void 0:o.props)?void 0:s.nodeViews,a=cg(t.schema).table.name;return r&&l&&(l[a]=(e,t)=>new r(e,n,t)),new Zg(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=Xg.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,r){const o=Xg.getState(e.state);if(o&&!o.dragging){const i=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(i){const{left:r,right:o}=i.getBoundingClientRect();t.clientX-r<=n?s=Qg(e,t,"left",n):o-t.clientX<=n&&(s=Qg(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),r=ig.get(n),o=t.start(-1);if(r.colCount(t.pos-o)+t.nodeAfter.attrs.colspan-1==r.width-1)return}ty(e,s)}}}(t,n,e,o)},mouseleave:e=>{!function(e){const t=Xg.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&ty(e,-1)}(e)},mousedown:(e,r)=>{!function(e,t,n,r){var o;const i=null!=(o=e.dom.ownerDocument.defaultView)?o:window,s=Xg.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=e.state.doc.nodeAt(s.activeHandle),a=function(e,t,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let e=0;e<n;e++)r[e]&&(s-=r[e],l--);return s/l}(e,s.activeHandle,l.attrs);function c(t){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const r=Xg.getState(e.state);(null==r?void 0:r.dragging)&&(function(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),i=ig.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let e=0;e<i.height;e++){const t=e*i.width+l;if(e&&i.map[t]==i.map[t-i.width])continue;const r=i.map[t],c=o.nodeAt(r).attrs,u=1==c.colspan?0:l-i.colCount(r);if(c.colwidth&&c.colwidth[u]==n)continue;const d=c.colwidth?c.colwidth.slice():ry(c.colspan);d[u]=n,a.setNodeMarkup(s+r,null,{...c,colwidth:d})}a.docChanged&&e.dispatch(a)}(e,r.activeHandle,ey(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Xg,{setDragging:null})))}function u(t){if(!t.which)return c(t);const o=Xg.getState(e.state);if(o&&o.dragging){const i=ey(o.dragging,t,n);ny(e,o.activeHandle,i,r)}}e.dispatch(e.state.tr.setMeta(Xg,{setDragging:{startX:t.clientX,startWidth:a}})),ny(e,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),t.preventDefault()}(e,r,t,n)}},decorations:e=>{const t=Xg.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;const r=[],o=e.doc.resolve(t),i=o.node(-1);if(!i)return bd.empty;const s=ig.get(i),l=o.start(-1),a=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){const o=a+t*s.width;if(!(a!=s.width-1&&s.map[o]==s.map[o+1]||0!=t&&s.map[o]==s.map[o-s.width])){const t=s.map[o],a=l+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=Xg.getState(e))?void 0:n.dragging)&&r.push(wd.node(l+t,l+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),r.push(wd.widget(a,c))}}return bd.create(e.doc,r)}(e,t.activeHandle)},nodeViews:{}}});return i}({})));Lw(jk,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});const _k=zp((()=>function({allowTableNodeSelection:e=!1}={}){return new il({key:ug,state:{init:()=>null,apply(e,t){const n=e.getMeta(ug);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:r,pos:o}=e.mapping.mapResult(t);return r?null:o}},props:{decorations:bg,handleDOMEvents:{mousedown:qg},createSelectionBetween:e=>null!=ug.getState(e.state)?e.state.selection:null,handleTripleClick:Vg,handleKeyDown:Fg,handlePaste:Hg},appendTransaction:(t,n,r)=>function(e,t,n){const r=(t||e).selection,o=(t||e).doc;let i,s;if(r instanceof Ks&&(s=r.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=kg.create(o,r.from);else if("row"==s){const e=o.resolve(r.from+1);i=kg.rowSelection(e,e)}else if(!n){const e=ig.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];i=kg.create(o,t+1,n)}}else r instanceof Hs&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}(r)?i=Hs.create(o,r.from):r instanceof Hs&&function({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){r=n;break}}return n!==r&&0===t.parentOffset}(r)&&(i=Hs.create(o,r.$from.start(),r.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}(r,Sg(r,n),e)})}({allowTableNodeSelection:!0})));Lw(_k,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});const Wk=Gp("remarkGFM",(()=>$w));Lw(Wk.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"}),Lw(Wk.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});const Vk=new al("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN"),Hk=zp((()=>new il({key:Vk,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants(((e,t)=>{if(r||(r=n.tr),"table_cell"!==e.type.name)return;const o=n.doc.resolve(t),i=o.node(o.depth),s=o.node(o.depth-1).firstChild;if(!s)return;const l=function(e,t){let n=0;return t.forEach(((t,r,o)=>{t===e&&(n=o)})),n}(e,i),a=s.maybeChild(l);if(!a)return;const c=a.attrs.alignment;c!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:c})})),r}})));Lw(Hk,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});const qk=[Hk,Fk,Wk,_k].flat(),Kk=[Pk,Vw,Hw,qw,Uw,Kw,Ik,Dk,Bw,zw].flat(),Uk=[pk,hk,fk,mk,gk,yk,wk,kk,vk,bk,Sk,Mk,xk,Ck,Nk,Fw],Jk=[Kk,Bk,zk,Lk,Uk,qk].flat();class Yk{#e;#t=new Set;constructor(e){this.#e=e}get current(){return this.#e}set current(e){this.#e!=e&&(this.#e=e,this.#t.forEach((t=>t(e))))}on(e){return this.#t.add(e),()=>this.#t.delete(e)}}const Gk=e=>new Yk(e),Xk=Symbol.for("atomico.hooks");globalThis[Xk]=globalThis[Xk]||{};let Zk=globalThis[Xk];const Qk=Symbol.for("Atomico.suspense"),ev=Symbol.for("Atomico.effect"),tv=Symbol.for("Atomico.layoutEffect"),nv=Symbol.for("Atomico.insertionEffect"),rv=(e,t,n)=>{const{i:r,hooks:o}=Zk.c,i=o[r]=o[r]||{};return i.value=e(i.value),i.effect=t,i.tag=n,Zk.c.i++,o[r].value},ov=e=>rv(((t=Gk(e))=>t)),iv=()=>rv(((e=Gk(Zk.c.host))=>e)),sv=()=>Zk.c.update,lv=()=>rv((()=>Zk.c.id+"-"+Zk.c.i)),av=Symbol.for;function cv(e,t){const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const uv=e=>"function"==typeof e,dv=e=>"object"==typeof e,{isArray:hv}=Array,pv=(e,t)=>(!t||e instanceof HTMLStyleElement)&&"hydrate"in(e?.dataset||{});function fv(e,t){let n;const r=e=>{let{length:o}=e;for(let i=0;i<o;i++){const o=e[i];if(o&&Array.isArray(o))r(o);else{const e=typeof o;if(null==o||"function"===e||"boolean"===e)continue;"string"===e||"number"===e?(null==n&&(n=""),n+=o):(null!=n&&(t(n),n=null),t(o))}}};r(e),null!=n&&t(n)}const mv=(e,t,n)=>(e.addEventListener(t,n),()=>e.removeEventListener(t,n));class gv{constructor(e,t,n){this.message=t,this.target=e,this.value=n}}class yv extends gv{}class wv extends gv{}const kv="Custom",vv=null,bv={true:1,"":1,1:1};function xv(e,t,n,r,o){const{type:i,reflect:s,event:l,value:a,attr:c=Sv(t)}=n?.name!=kv&&dv(n)&&n!=vv?n:{type:n},u=i?.name===kv&&i.map,d=null!=a?i!=Function&&uv(a)?a:()=>a:null;Object.defineProperty(e,t,{configurable:!0,set(e){const n=this[t];d&&i!=Boolean&&null==e&&(e=d());const{error:r,value:o}=(u?Nv:Tv)(i,e);if(r&&null!=o)throw new yv(this,`The value defined for prop '${t}' must be of type '${i.name}'`,o);n!=o&&(this._props[t]=null==o?void 0:o,this.update(),l&&Cv(this,l),this.updated.then((()=>{s&&(this._ignoreAttr=c,Mv(this,i,c,this[t]),this._ignoreAttr=null)})))},get(){return this._props[t]}}),d&&(o[t]=d()),r[c]={prop:t,type:i}}const Cv=(e,{type:t,base:n=CustomEvent,...r})=>e.dispatchEvent(new n(t,r)),Sv=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),Mv=(e,t,n,r)=>null==r||t==Boolean&&!r?e.removeAttribute(n):e.setAttribute(n,t?.name===kv&&t?.serialize?t?.serialize(r):dv(r)?JSON.stringify(r):t==Boolean?"":r),Nv=({map:e},t)=>{try{return{value:e(t),error:!1}}catch{return{value:t,error:!0}}},Tv=(e,t)=>null==e||null==t?{value:t,error:!1}:e!=String&&""===t?{value:void 0,error:!1}:e==Object||e==Array||e==Symbol?{value:t,error:{}.toString.call(t)!==`[object ${e.name}]`}:t instanceof e?{value:t,error:e==Number&&Number.isNaN(t.valueOf())}:e==String||e==Number||e==Boolean?{value:t,error:e==Number?"number"!=typeof t||Number.isNaN(t):e==String?"string"!=typeof t:"boolean"!=typeof t}:{value:t,error:!0},Ov=(e,t)=>({name:kv,map:e,serialize:t});let Av=0;const Ev=(e,t=HTMLElement)=>{const n={},r={},o="prototype"in t&&t.prototype instanceof Element,i=o?t:"base"in t?t.base:HTMLElement,{props:s,styles:l}=o?e:t;return class extends i{constructor(){super(),this._setup(),this._render=()=>e({...this._props});for(const e in r)this[e]=r[e]}static get styles(){return[super.styles,l]}async _setup(){if(this._props)return;let e,t;this._props={},this.mounted=new Promise((n=>this.mount=()=>{n(),e!=this.parentNode&&(t!=e?this.unmounted.then(this.update):this.update()),e=this.parentNode})),this.unmounted=new Promise((r=>this.unmount=()=>{r(),e==this.parentNode&&this.isConnected||(n.cleanEffects(!0)()(),t=this.parentNode,e=null)})),this.symbolId=this.symbolId||Symbol(),this.symbolIdParent=Symbol();const n=((e,t,n=0)=>{let r={},o=!1;const i=(e,t)=>{for(const n in r){const o=r[n];o.effect&&o.tag===e&&(o.value=o.effect(o.value,t))}};return{load:i=>{let s;Zk.c={host:t,hooks:r,update:e,i:0,id:n};try{o=!1,s=i()}catch(e){if(e!==Qk)throw e;o=!0}finally{Zk.c=null}return s},cleanEffects:e=>(i(nv,e),()=>(i(tv,e),()=>{i(ev,e)})),isSuspense:()=>o}})((()=>this.update()),this,(r=this,(r?.dataset||{})?.hydrate||"c"+Av++));var r;let o,i=!0;const s=pv(this);this.update=()=>(o||(o=!0,this.updated=(this.updated||this.mounted).then((()=>{try{const e=n.load(this._render),t=n.cleanEffects();return e&&e.render(this,this.symbolId,s),o=!1,i&&!n.isSuspense()&&(i=!1,!s&&function(e){const{styles:t}=e.constructor,{shadowRoot:n}=e;if(n&&t.length){const e=[];fv(t,(t=>{t&&(t instanceof Element?n.appendChild(t.cloneNode(!0)):e.push(t))})),e.length&&(n.adoptedStyleSheets=e)}}(this)),t()}finally{o=!1}})).then((e=>{e&&e()}))),this.updated),this.update()}connectedCallback(){this.mount(),super.connectedCallback&&super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),this.unmount()}attributeChangedCallback(e,t,r){if(n[e]){if(e===this._ignoreAttr||t===r)return;const{prop:o,type:i}=n[e];try{this[o]=((e,t)=>e==Boolean?!!bv[t]:e==Number?Number(t):e==String?t:e==Array||e==Object?JSON.parse(t):e.name==kv?t:new e(t))(i,r)}catch(t){throw new wv(this,`The value defined as attr '${e}' cannot be parsed by type '${i.name}'`,r)}}else super.attributeChangedCallback(e,t,r)}static get props(){return{...super.props,...s}}static get observedAttributes(){const e=super.observedAttributes||[];for(const e in s)xv(this.prototype,e,s[e],n,r);return Object.keys(n).concat(e)}}},Iv=e=>(t,n)=>{rv((([e,t]=[])=>(!t&&t||(t&&cv(t,n)?e=e||!0:(uv(e)&&e(),e=null)),[e,n])),(([e,n],r)=>r?(uv(e)&&e(),[]):[e||t(),n]),e)},Rv=Iv(tv),Dv=Iv(ev),Pv=Iv(nv);class $v extends Array{constructor(e,t){let n=!0;const r=e=>{try{t(e,this,n)}finally{n=!1}};super(void 0,r,t),r(e)}}const Lv=e=>{const t=sv();return rv(((n=new $v(e,((e,n,r)=>{(e=uv(e)?e(n[0]):e)!==n[0]&&(n[0]=e,r||t())})))=>n))},Bv=(e,t)=>{const[n]=rv((([n,r,o=0]=[])=>((!r||r&&!cv(r,t))&&(n=e()),[n,t,o])));return n},zv=(e,t,n)=>{const r=sv();return rv(((o=[])=>(o[1]||(o[0]=void 0!==n?n(t):t,o[1]=t=>{const n=e(o[0],t);n!=o[0]&&(o[0]=n,r())}),o)))},Fv=(e,t)=>Bv((()=>e),t),jv=e=>{const{current:t}=iv();if(!(e in t))throw new yv(t,`For useProp("${e}"), the prop does not exist on the host.`,e);return rv(((n=new $v(t[e],((n,r)=>{n=uv(n)?n(t[e]):n,t[e]=n})))=>(n[0]=t[e],n)))},_v=(e,t={})=>{const n=iv();return n[e]||(n[e]=(r=t.detail)=>Cv(n.current,{type:e,...t,detail:r})),n[e]},Wv=av("atomico/options");globalThis[Wv]=globalThis[Wv]||{sheet:!!document.adoptedStyleSheets};const Vv=globalThis[Wv],Hv=new Promise((e=>{Vv.ssr||("loading"===document.readyState?mv(document,"DOMContentLoaded",e):e())})),qv={checked:1,value:1,selected:1},Kv={list:1,type:1,size:1,form:1,width:1,height:1,src:1,href:1,slot:1},Uv={shadowDom:1,staticNode:1,cloneNode:1,children:1,key:1},Jv={},Yv=[];class Gv extends Text{}const Xv=av("atomico/id"),Zv=av("atomico/type"),Qv=av("atomico/ref"),eb=av("atomico/vnode"),tb=()=>{};function nb(e,t,n){return ob(this,e,t,n)}const rb=(e,t,...n)=>{const r=t||Jv;let{children:o}=r;if(o=null!=o?o:n.length?n:Yv,e===tb)return o;const i=e?e instanceof Node?1:e.prototype instanceof HTMLElement&&2:0;if(!1===i&&e instanceof Function)return e(o!=Yv?{children:o,...r}:r);const s=Vv.render||nb;return{[Zv]:eb,type:e,props:r,children:o,key:r.key,shadow:r.shadowDom,static:r.staticNode,raw:i,is:r.is,clone:r.cloneNode,render:s}};function ob(e,t,n=Xv,r,o){let i;if(t&&t[n]&&t[n].vnode==e||e[Zv]!=eb)return t;!e&&t||(o=o||"svg"==e.type,i="host"!=e.type&&(1==e.raw?(t&&e.clone?t[Qv]:t)!=e.type:2==e.raw?!(t instanceof e.type):t?t[Qv]||t.localName!=e.type:!t),i&&null!=e.type&&(1==e.raw&&e.clone?(r=!0,(t=e.type.cloneNode(!0))[Qv]=e.type):t=1==e.raw?e.type:2==e.raw?new e.type:o?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type,e.is?{is:e.is}:void 0)));const s=t[n]?t[n]:Jv,{vnode:l=Jv,cycle:a=0}=s;let{fragment:c,handlers:u}=s;const{children:d=Yv,props:h=Jv}=l;if(u=i?{}:u||{},e.static&&!i)return t;if(e.shadow&&!t.shadowRoot&&t.attachShadow({mode:"open",...e.shadow}),e.props!=h&&function(e,t,n,r,o){for(const i in t)!(i in n)&&ib(e,i,t[i],null,o,r);for(const i in n)ib(e,i,t[i],n[i],o,r)}(t,h,e.props,u,o),e.children!==d){const i=e.shadow?t.shadowRoot:t;c=function(e,t,n,r,o,i){e=null==e?null:hv(e)?e:[e];const s=t||function(e,t){const n=new Gv(""),r=new Gv("");let o;if(e[t?"prepend":"append"](n),t){let{lastElementChild:t}=e;for(;t;){const{previousElementSibling:e}=t;if(pv(t,!0)&&!pv(e,!0)){o=t;break}t=e}}return o?o.before(r):e.append(r),{markStart:n,markEnd:r}}(n,o),{markStart:l,markEnd:a,keyes:c}=s;let u;const d=c&&new Set;let h=l;if(e&&fv(e,(e=>{if("object"==typeof e&&!e[Zv])return;const t=e[Zv]&&e.key,s=c&&null!=t&&c.get(t);h!=a&&h===s?d.delete(h):h=h==a?a:h.nextSibling;const l=c?s:h;let p=l;if(e[Zv])p=ob(e,l,r,o,i);else{const t=e+"";!(p instanceof Text)||p instanceof Gv?p=new Text(t):p.data!=t&&(p.data=t)}p!=h&&(c&&d.delete(p),!l||c?(n.insertBefore(p,h),c&&h!=a&&d.add(h)):l==a?n.insertBefore(p,a):(n.replaceChild(p,l),h=p)),null!=t&&(u=u||new Map,u.set(t,p))})),h=h==a?a:h.nextSibling,t&&h!=a)for(;h!=a;){const e=h;h=h.nextSibling,e.remove()}return d&&d.forEach((e=>e.remove())),s.keyes=u,s}(e.children,c,i,n,!a&&r,(!o||"foreignObject"!=e.type)&&o)}return t[n]={vnode:e,handlers:u,fragment:c,cycle:a+1},t}function ib(e,t,n,r,o,i){if(n=null==n?null:n,r=null==r?null:r,(t="class"!=t||o?t:"className")in e&&qv[t]&&(n=e[t]),r!==n&&!Uv[t]&&"_"!=t[0])if("slot"===e.localName&&"assignNode"===t&&"assign"in e)e.assign(r);else if("o"==t[0]&&"n"==t[1]&&(uv(r)||uv(n)))!function(e,t,n,r){if(r.handleEvent||(r.handleEvent=t=>r[t.type].call(e,t)),n){if(!r[t]){const o=n.capture||n.once||n.passive?Object.assign({},n):null;e.addEventListener(t,r,o)}r[t]=n}else r[t]&&(e.removeEventListener(t,r),delete r[t])}(e,t.slice(2),r,i);else if("ref"==t)r&&(uv(r)?r(e):r.current=e);else if("style"==t){const{style:t}=e;r=r||"";const o=dv(n=n||""),i=dv(r);if(o)for(const e in n){if(!i)break;!(e in r)&&sb(t,e,null)}if(i)for(const e in r){const i=r[e];o&&n[e]===i||sb(t,e,i)}else t.cssText=r}else{const i="$"==t[0]?t.slice(1):t;i===t&&(!o&&!Kv[t]&&t in e||uv(r)||uv(n))?e[t]=null==r?"":r:null==r?e.removeAttribute(i):e.setAttribute(i,dv(r)?JSON.stringify(r):r)}}function sb(e,t,n){let r="setProperty";null==n&&(r="removeProperty",n=null),~t.indexOf("-")?e[r](t,n):e[t]=n}const lb=rb("host",{style:"display: contents"}),ab="value",cb=(e,t)=>{const n=iv(),r=ov();Pv((()=>mv(n.current,"ConnectContext",(t=>{t.composedPath().at(0)!==t.currentTarget&&e===t.detail.id&&(t.stopPropagation(),t.detail.connect(r))}))),[e]),r.current=t},ub=e=>{const t=_v("ConnectContext",{bubbles:!0,composed:!0}),[n,r]=Lv((()=>{if(Vv.ssr)return;let n;return t({id:e,connect(e){n=e}}),n})),o=sv();return Dv((()=>{Hv.then((()=>t({id:e,connect:r})))}),[e]),Dv((()=>{if(n)return n.on(o)}),[n]),n?.current||e[ab]},db=e=>{const t=Ev((({value:e})=>(cb(t,e),lb)),{props:{value:{type:Object,value:()=>e}}});return t[ab]=e,t},hb="PendingSuspense",pb="FulfilledSuspense",fb="AbortedSuspense",mb=db({dispatch(e,t){}}),gb=(e=8)=>{const[t,n]=Lv({pending:!0}),r=(e,t)=>requestAnimationFrame((()=>t?r(e,--t):e())),o=Bv((()=>{const t=new Set;let o=!1,i=!1,s=!1;const l=()=>{o||(o=!0,r((()=>{o=!1,n((e=>t.size?e.pending?e:{pending:!0}:s?e.aborted?e:{aborted:s}:i?e.rejected?e:{rejected:i}:e.fulfilled?e:{fulfilled:!0}))}),e))};return{dispatch:(e,n)=>{e===hb?(t.add(n),l()):t.has(n)&&(t.delete(n),e===pb||(e===fb?s=!0:i=!0),l())}}}),[]);return cb(mb,o),t},yb=(e,t,n=!0)=>{const r=lv(),{dispatch:o}=ub(mb),[i,s]=Lv(n?{pending:n}:{}),l=t||[];return Dv((()=>{if(n){let t;return s(i.pending?i:{pending:!0}),e(...l).then((e=>{!t&&s({result:e,fulfilled:!0})}),(e=>{!t&&s("AbortError"===e?.name?{result:e,aborted:!0}:{result:e,rejected:!0})})),()=>t=!0}s((e=>Object.keys(e).length?{}:e))}),[n,...l]),Rv((()=>{i.pending?o(hb,r):i.rejected?o("RejectedSuspense",r):i.aborted?o(fb,r):o(pb,r)}),[o,i]),Dv((()=>()=>{o(pb,r)}),[o]),i},wb=e=>{const t=Bv((()=>new AbortController),e);return Dv((()=>()=>t.abort()),[t]),t},kb=(e,t)=>{const n=iv();Pv((()=>{let r,o=!1,i=()=>{r&&r(),r=null};const s=async()=>{o||(o=!0,await n.current.updated,i(),o=!1,r=e())},l=t.map((e=>e?.on(s)));return n.once||(n.once=!0,s()),()=>{l.map((e=>e&&e())),i()}}),t)},vb=(e,t)=>{const n=yb(e,t);if(n.pending)throw Qk;return n.result},bb=(e,t=!Vv.ssr&&document.createElement("template").content)=>t?ob(rb("host",null,e),t).children[0]:e,xb={};function Cb(e,...t){const n=(e.raw||e).reduce(((e,n,r)=>e+n+(t[r]||"")),"");return xb[n]=xb[n]||function(e){if(Vv.sheet){const t=new CSSStyleSheet;return t.replaceSync(e),t}{const t=document.createElement("style");return t.textContent=e,t}}(n)}const Sb=(e,t,n,r)=>{let o;t[0]=0;for(let i=1;i<t.length;i++){const s=t[i++],l=t[i]?(t[0]|=s?1:2,n[t[i++]]):t[++i];3===s?r[0]=l:4===s?r[1]=Object.assign(r[1]||{},l):5===s?(r[1]=r[1]||{})[t[++i]]=l:6===s?r[1][t[++i]]+=l+"":s?(o=e.apply(l,Sb(e,l,n,["",null])),r.push(o),l[0]?t[0]|=2:(t[i-2]=0,t[i]=o)):r.push(l)}return r},Mb=function(e){let t,n,r=1,o="",i="",s=[0];const l=e=>{1===r&&(e||(o=o.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(0,e,o):3===r&&(e||o)?(s.push(3,e,o),r=2):2===r&&"..."===o&&e?s.push(4,e,0):2===r&&o&&!e?s.push(5,0,!0,o):r>=5&&((o||!e&&5===r)&&(s.push(r,0,o,n),r=6),e&&(s.push(r,e,0,n),r=6)),o=""};for(let a=0;a<e.length;a++){a&&(1===r&&l(),l(a));for(let c=0;c<e[a].length;c++)t=e[a][c],1===r?"<"===t?(l(),s=[s],r=3):o+=t:4===r?"--"===o&&">"===t?(r=1,o=""):o=t+o[0]:i?t===i?i="":o+=t:'"'===t||"'"===t?i=t:">"===t?(l(),r=1):r&&("="===t?(r=5,n=o,o=""):"/"===t&&(r<5||">"===e[a][c+1])?(l(),3===r&&(s=s[0]),r=s,(s=s[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(l(),r=2):o+=t),3===r&&"!--"===o&&(r=4,s=s[0])}return l(),s},Nb=new Map;function Tb(e){let t=Nb;return t=Sb(rb,t.get(e)||(t.set(e,t=Mb(e)),t),arguments,[]),t.length>1?t:t[0]}function Ob(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Ob(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}const Ab=function(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Ob(e))&&(r&&(r+=" "),r+=t);return r};var Eb=Object.defineProperty,Ib=Object.getOwnPropertySymbols,Rb=Object.prototype.hasOwnProperty,Db=Object.prototype.propertyIsEnumerable,Pb=(e,t,n)=>t in e?Eb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$b=(e,t)=>{for(var n in t||(t={}))Rb.call(t,n)&&Pb(e,n,t[n]);if(Ib)for(var n of Ib(t))Db.call(t,n)&&Pb(e,n,t[n]);return e};function Lb(e,t){return Object.assign(e,{meta:$b({package:"@milkdown/components"},t)}),e}var Bb=Object.defineProperty,zb=Object.getOwnPropertySymbols,Fb=Object.prototype.hasOwnProperty,jb=Object.prototype.propertyIsEnumerable,_b=(e,t,n)=>t in e?Bb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wb=(e,t)=>{for(var n in t||(t={}))Fb.call(t,n)&&_b(e,n,t[n]);if(zb)for(var n of zb(t))jb.call(t,n)&&_b(e,n,t[n]);return e};const Vb="image-block",Hb=qp("image-block",(()=>({inline:!1,group:"block",selectable:!0,draggable:!0,isolating:!0,marks:"",atom:!0,priority:100,attrs:{src:{default:""},caption:{default:""},ratio:{default:1}},parseDOM:[{tag:`img[data-type="${Vb}"]`,getAttrs:e=>{var t;if(!(e instanceof HTMLElement))throw j(e);return{src:e.getAttribute("src")||"",caption:e.getAttribute("caption")||"",ratio:Number(null!=(t=e.getAttribute("ratio"))?t:1)}}}],toDOM:e=>["img",Wb({"data-type":Vb},e.attrs)],parseMarkdown:{match:({type:e})=>"image-block"===e,runner:(e,t,n)=>{const r=t.url,o=t.title;let i=Number(t.alt||1);(Number.isNaN(i)||0===i)&&(i=1),e.addNode(n,{src:r,caption:o,ratio:i})}},toMarkdown:{match:e=>"image-block"===e.type.name,runner:(e,t)=>{e.openNode("paragraph"),e.addNode("image",void 0,void 0,{title:t.attrs.caption,url:t.attrs.src,alt:`${Number.parseFloat(t.attrs.ratio).toFixed(2)}`}),e.closeNode()}}})));function qb(e){return lo(e,"paragraph",((e,t,n)=>{var r,o;if(1!==(null==(r=e.children)?void 0:r.length))return;const i=null==(o=e.children)?void 0:o[0];if(!i||"image"!==i.type)return;const{url:s,alt:l,title:a}=i,c={type:"image-block",url:s,alt:l,title:a};n.children.splice(t,1,c)}))}Lb(Hb.node,{displayName:"NodeSchema<image-block>",group:"ImageBlock"});const Kb=Gp("remark-image-block",(()=>()=>qb));Lb(Kb.plugin,{displayName:"Remark<remarkImageBlock>",group:"ImageBlock"}),Lb(Kb.options,{displayName:"RemarkConfig<remarkImageBlock>",group:"ImageBlock"});const Ub={imageIcon:()=>"🌌",captionIcon:()=>"💬",uploadButton:()=>Tb`Upload file`,confirmButton:()=>Tb`Confirm ⏎`,uploadPlaceholderText:"or paste the image link ...",captionPlaceholderText:"Image caption",onUpload:e=>Promise.resolve(URL.createObjectURL(e))},Jb=Hp(Ub,"imageBlockConfigCtx");Lb(Jb,{displayName:"Config<image-block>",group:"ImageBlock"});let Yb=0;const Gb=({src:e="",caption:t="",ratio:n=1,selected:r=!1,readonly:o=!1,setAttr:i,config:s})=>{const l=ov(),a=ov(),c=ov(),[u,d]=Lv(t.length>0),[h,p]=Lv(0!==e.length),[f]=Lv(crypto.randomUUID()),[m,g]=Lv(!1),[y,w]=Lv(e);!function({image:e,resizeHandle:t,ratio:n,setRatio:r,src:o}){const i=iv(),s=Bv((()=>i.current.getRootNode()),[i]);Dv((()=>{const t=e.current;t&&(delete t.dataset.origin,delete t.dataset.height,t.style.height="")}),[o]),Dv((()=>{const o=t.current,l=e.current;if(!o||!l)return;const a=e=>{e.preventDefault();const t=l.getBoundingClientRect().top,n=e.clientY-t,r=Number(n<100?100:n).toFixed(2);l.dataset.height=r,l.style.height=`${r}px`},c=()=>{s.removeEventListener("pointermove",a),s.removeEventListener("pointerup",c);const e=Number(l.dataset.origin),t=Number(l.dataset.height),n=Number.parseFloat(Number(t/e).toFixed(2));Number.isNaN(n)||r(n)},u=e=>{e.preventDefault(),s.addEventListener("pointermove",a),s.addEventListener("pointerup",c)},d=e=>{const t=i.current.getBoundingClientRect().width;if(!t)return;const r=e.target,o=r.height,s=r.width,a=s<t?o:t*(o/s),c=(a*n).toFixed(2);l.dataset.origin=a.toFixed(2),l.dataset.height=c,l.style.height=`${c}px`};return l.addEventListener("load",d),o.addEventListener("pointerdown",u),()=>{l.removeEventListener("load",d),o.removeEventListener("pointerdown",u)}}),[])}({image:l,resizeHandle:a,ratio:n,setRatio:e=>null==i?void 0:i("ratio",e),src:e}),Dv((()=>{r||d(t.length>0)}),[r]);const k=()=>{var e,t;null==i||i("src",null!=(t=null==(e=c.current)?void 0:e.value)?t:"")},v=e=>{e.preventDefault(),e.stopPropagation()};return Tb`<host class=${Ab(r&&"selected")}>
1
+ 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}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:mt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new nt(this,this.computeAttrs(e),De.from(t),Le.setFrom(n))}createChecked(e=null,t,n){return t=De.from(t),this.checkContent(t),new nt(this,this.computeAttrs(e),t,Le.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=De.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(De.empty,!0);return o?new nt(this,e,t.append(o),Le.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){gt(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Le.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,r)=>n[e]=new wt(e,t,r)));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class kt{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class vt{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=yt(e,r.attrs),this.excluded=null;let o=ft(this.attrs);this.instance=o?new Le(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Le(this,mt(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach(((e,o)=>n[e]=new vt(e,r++,t,o))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){gt(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class bt{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=Ae.from(e.nodes),t.marks=Ae.from(e.marks||{}),this.nodes=wt.compile(this.spec.nodes,this),this.marks=vt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=it.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?xt(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:xt(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof wt))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new rt(n,n.defaultAttrs,e,Le.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return nt.fromJSON(this,e)}markFromJSON(e){return Le.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function xt(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Ct{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new At(this,t,!1);return n.addAll(e,Le.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new At(this,t,!0);return n.addAll(e,Le.none,t.from,t.to),Be.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Et(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach((e=>{n(e=It(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach((e=>{n(e=It(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ct(e,Ct.schemaRules(e)))}}const St={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Mt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Nt={ol:!0,ul:!0};function Tt(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class Ot{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=Le.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(De.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=De.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(De.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!St.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class At{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=Tt(null,t.preserveWhitespace,0)|(n?4:0);r=o?new Ot(o.type,o.attrs,Le.none,!0,t.topMatch||o.type.contentMatch,i):new Ot(n?null:e.schema.topNodeType,null,Le.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)n="full"!==o?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Nt.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Nt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Mt.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(St.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter((e=>!n.clearMark(e))):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(o=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,n)));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t){let n,r;for(let t=this.open;t>=0;t--){let o=this.nodes[t],i=o.findWrapping(e);if(i&&(!n||n.length>i.length)&&(n=i,r=o,!i.length))break;if(o.solid)break}if(!n)return null;this.sync(r);for(let e=0;e<n.length;e++)t=this.enterInner(n[e],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let n=this.findPlace(e,t);if(n){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let r=Le.none;for(let o of n.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):Dt(o.type,e.type))&&(r=o.addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=Tt(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=Le.none;return n=n.filter((t=>!(i.type?i.type.allowsMarkType(t.type):Dt(t.type,e))||(l=t.addToSet(l),!1))),this.nodes.push(new Ot(e,t,l,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function Et(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function It(e){let t={};for(let n in e)t[n]=e[n];return t}function Dt(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class Rt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=$t(t).createDocumentFragment());let r=n,o=[];return e.forEach((e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=zt($t(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&zt($t(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return zt(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Rt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Pt(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Pt(e.marks)}}function Pt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function $t(e){return e.document||window.document}const Lt=new WeakMap;function zt(e,t,n,r){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=function(e){let t=Lt.get(e);return void 0===t&&Lt.set(e,t=function(e){let t=null;return function e(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])t||(t=[]),t.push(n);else for(let t=0;t<n.length;t++)e(n[t]);else for(let t in n)e(n[t])}(e),t}(e)),t}(r))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],u=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){u=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):a.setAttribute(e,c[e])}}for(let o=u;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:o}=zt(e,i,n,r);if(a.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:a,contentDOM:s}}const Bt={};function Ft(e,t){const n=t||Bt;return jt(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function jt(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return _t(e.children,t,n)}return Array.isArray(e)?_t(e,t,n):""}function _t(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=jt(e[o],t,n);return r.join("")}function Wt(e,t,n,r){const o=e.length;let i,s=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);s<r.length;)i=r.slice(s,s+1e4),i.unshift(t,0),e.splice(...i),s+=1e4,t+=1e4}function Vt(e,t){return e.length>0?(Wt(e,e.length,0,t),e):t}class Ht{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const r=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&qt(this.left,n),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),qt(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),qt(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);qt(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);qt(this.left,t.reverse())}}}function qt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Kt(e){const t={};let n,r,o,i,s,l,a,c=-1;const u=new Ht(e);for(;++c<u.length;){for(;c in t;)c=t[c];if(n=u.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&(l=n[1]._tokenizer.events,o=0,o<l.length&&"lineEndingBlank"===l[o][1].type&&(o+=2),o<l.length&&"content"===l[o][1].type))for(;++o<l.length&&"content"!==l[o][1].type;)"chunkText"===l[o][1].type&&(l[o][1]._isInFirstContentOfListItem=!0,o++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,Ut(u,c)),c=t[c],a=!0);else if(n[1]._container){for(o=c,r=void 0;o--&&(i=u.get(o),"lineEnding"===i[1].type||"lineEndingBlank"===i[1].type);)"enter"===i[0]&&(r&&(u.get(r)[1].type="lineEndingBlank"),i[1].type="lineEnding",r=o);r&&(n[1].end={...u.get(r)[1].start},s=u.slice(r,c),s.unshift(n),u.splice(r,c-r+1,s))}}return Wt(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!a}function Ut(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const i=[],s=n._tokenizer||r.parser[n.contentType](n.start),l=s.events,a=[],c={};let u,d,h=-1,p=n,f=0,m=0;const g=[m];for(;p;){for(;e.get(++o)[1]!==p;);i.push(o),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<l.length;)"exit"===l[h][0]&&"enter"===l[h-1][0]&&l[h][1].type===l[h-1][1].type&&l[h][1].start.line!==l[h][1].end.line&&(m=h+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),h=g.length;h--;){const t=l.slice(g[h],g[h+1]),n=i.pop();a.push([n,n+t.length-1]),e.splice(n,2,t)}for(a.reverse(),h=-1;++h<a.length;)c[f+a[h][0]]=f+a[h][1],f+=a[h][1]-a[h][0]-1;return c}const Jt={}.hasOwnProperty;function Yt(e){const t={};let n=-1;for(;++n<e.length;)Gt(t,e[n]);return t}function Gt(e,t){let n;for(n in t){const r=(Jt.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let i;if(o)for(i in o){Jt.call(r,i)||(r[i]=[]);const e=o[i];Xt(r[i],Array.isArray(e)?e:e?[e]:[])}}}function Xt(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);Wt(e,0,0,r)}const Zt=dn(/[A-Za-z]/),Qt=dn(/[\dA-Za-z]/),en=dn(/[#-'*+\--9=?A-Z^-~]/);function tn(e){return null!==e&&(e<32||127===e)}const nn=dn(/\d/),rn=dn(/[\dA-Fa-f]/),on=dn(/[!-/:-@[-`{-~]/);function sn(e){return null!==e&&e<-2}function ln(e){return null!==e&&(e<0||32===e)}function an(e){return-2===e||-1===e||32===e}const cn=dn(/\p{P}|\p{S}/u),un=dn(/\s/);function dn(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function hn(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let i=0;return function(r){return an(r)?(e.enter(n),s(r)):t(r)};function s(r){return an(r)&&i++<o?(e.consume(r),s):(e.exit(n),t(r))}}const pn={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,(function(n){if(null!==n)return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),hn(e,t,"linePrefix");e.consume(n)}),(function(t){return e.enter("paragraph"),r(t)}));let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):sn(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),o)}}},fn={tokenize:function(e){const t=this,n=[];let r,o,i,s=0;return l;function l(r){if(s<n.length){const o=n[s];return t.containerState=o[1],e.attempt(o[0].continuation,a,c)(r)}return c(r)}function a(e){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&w();const n=t.events.length;let o,i=n;for(;i--;)if("exit"===t.events[i][0]&&"chunkFlow"===t.events[i][1].type){o=t.events[i][1].end;break}y(s);let l=n;for(;l<t.events.length;)t.events[l][1].end={...o},l++;return Wt(t.events,i+1,0,t.events.slice(n)),t.events.length=l,c(e)}return l(e)}function c(o){if(s===n.length){if(!r)return h(o);if(r.currentConstruct&&r.currentConstruct.concrete)return f(o);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(mn,u,d)(o)}function u(e){return r&&w(),y(s),h(e)}function d(e){return t.parser.lazy[t.now().line]=s!==n.length,i=t.now().offset,f(e)}function h(n){return t.containerState={},e.attempt(mn,p,f)(n)}function p(e){return s++,n.push([t.currentConstruct,t.containerState]),h(e)}function f(n){return null===n?(r&&w(),y(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:o}),m(n))}function m(n){return null===n?(g(e.exit("chunkFlow"),!0),y(0),void e.consume(n)):sn(n)?(e.consume(n),g(e.exit("chunkFlow")),s=0,t.interrupt=void 0,l):(e.consume(n),m)}function g(e,n){const l=t.sliceStream(e);if(n&&l.push(null),e.previous=o,o&&(o.next=e),o=e,r.defineSkip(e.start),r.write(l),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<i&&(!r.events[e][1].end||r.events[e][1].end.offset>i))return;const n=t.events.length;let o,l,a=n;for(;a--;)if("exit"===t.events[a][0]&&"chunkFlow"===t.events[a][1].type){if(o){l=t.events[a][1].end;break}o=!0}for(y(s),e=n;e<t.events.length;)t.events[e][1].end={...l},e++;Wt(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function y(r){let o=n.length;for(;o-- >r;){const r=n[o];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function w(){r.write([null]),o=void 0,r=void 0,t.containerState._closeFlow=void 0}}},mn={tokenize:function(e,t,n){return hn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},gn={partial:!0,tokenize:function(e,t,n){return function(t){return an(t)?hn(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||sn(e)?t(e):n(e)}}},yn={resolve:function(e){return Kt(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?o(t):sn(t)?e.check(wn,i,o)(t):(e.consume(t),r)}function o(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function i(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},wn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),hn(e,o,"linePrefix")};function o(o){if(null===o||sn(o))return n(o);const i=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}},kn={tokenize:function(e){const t=this,n=e.attempt(gn,(function(r){if(null!==r)return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n;e.consume(r)}),e.attempt(this.parser.constructs.flowInitial,r,hn(e,e.attempt(this.parser.constructs.flow,r,e.attempt(yn,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}},vn={resolveAll:Sn()},bn=Cn("string"),xn=Cn("text");function Cn(e){return{resolveAll:Sn("text"===e?Mn:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],o=t.attempt(r,i,s);return i;function i(e){return a(e)?o(e):s(e)}function s(e){if(null!==e)return t.enter("data"),t.consume(e),l;t.consume(e)}function l(e){return a(e)?(t.exit("data"),o(e)):(t.consume(e),l)}function a(e){if(null===e)return!0;const t=r[e];let o=-1;if(t)for(;++o<t.length;){const e=t[o];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function Sn(e){return function(t,n){let r,o=-1;for(;++o<=t.length;)void 0===r?t[o]&&"data"===t[o][1].type&&(r=o,o++):t[o]&&"data"===t[o][1].type||(o!==r+2&&(t[r][1].end=t[o-1][1].end,t.splice(r+2,o-r-2),o=r+2),r=void 0);return e?e(t,n):t}}function Mn(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const r=e[n-1][1],o=t.sliceStream(r);let i,s=o.length,l=-1,a=0;for(;s--;){const e=o[s];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)a++,l--;if(l)break;l=-1}else if(-2===e)i=!0,a++;else if(-1!==e){s++;break}}if(a){const o={type:n===e.length||i||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?l:r.start._bufferIndex+l,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...o.start},r.start.offset===r.end.offset?Object.assign(r,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}const Nn={name:"thematicBreak",tokenize:function(e,t,n){let r,o=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,i(e)}(t)};function i(i){return i===r?(e.enter("thematicBreakSequence"),s(i)):o>=3&&(null===i||sn(i))?(e.exit("thematicBreak"),t(i)):n(i)}function s(t){return t===r?(e.consume(t),o++,s):(e.exit("thematicBreakSequence"),an(t)?hn(e,i,"whitespace")(t):i(t))}}},Tn={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(gn,(function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,hn(e,t,"listItemIndent",r.containerState.size+1)(n)}),(function(n){return r.containerState.furtherBlankLines||!an(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(An,t,o)(n))}));function o(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,hn(e,e.attempt(Tn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,o=r.events[r.events.length-1];let i=o&&"linePrefix"===o[1].type?o[2].sliceSerialize(o[1],!0).length:0,s=0;return function(t){const o=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===o?!r.containerState.marker||t===r.containerState.marker:nn(t)){if(r.containerState.type||(r.containerState.type=o,e.enter(o,{_container:!0})),"listUnordered"===o)return e.enter("listItemPrefix"),42===t||45===t?e.check(Nn,n,a)(t):a(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(t)}return n(t)};function l(t){return nn(t)&&++s<10?(e.consume(t),l):(!r.interrupt||s<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),a(t)):n(t)}function a(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(gn,r.interrupt?n:c,e.attempt(On,d,u))}function c(e){return r.containerState.initialBlankLine=!0,i++,d(e)}function u(t){return an(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},On={partial:!0,tokenize:function(e,t,n){const r=this;return hn(e,(function(e){const o=r.events[r.events.length-1];return!an(e)&&o&&"listItemPrefixWhitespace"===o[1].type?t(e):n(e)}),"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},An={partial:!0,tokenize:function(e,t,n){const r=this;return hn(e,(function(e){const o=r.events[r.events.length-1];return o&&"listItemIndent"===o[1].type&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(e):n(e)}),"listItemIndent",r.containerState.size+1)}},En={continuation:{tokenize:function(e,t,n){const r=this;return function(t){return an(t)?hn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)};function o(r){return e.attempt(En,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return n(t)};function o(n){return an(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};function In(e,t,n,r,o,i,s,l,a){const c=a||Number.POSITIVE_INFINITY;let u=0;return function(t){return 60===t?(e.enter(r),e.enter(o),e.enter(i),e.consume(t),e.exit(i),d):null===t||32===t||41===t||tn(t)?n(t):(e.enter(r),e.enter(s),e.enter(l),e.enter("chunkString",{contentType:"string"}),f(t))};function d(n){return 62===n?(e.enter(i),e.consume(n),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(l),d(t)):null===t||60===t||sn(t)?n(t):(e.consume(t),92===t?p:h)}function p(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function f(o){return u||null!==o&&41!==o&&!ln(o)?u<c&&40===o?(e.consume(o),u++,f):41===o?(e.consume(o),u--,f):null===o||32===o||40===o||tn(o)?n(o):(e.consume(o),92===o?m:f):(e.exit("chunkString"),e.exit(l),e.exit(s),e.exit(r),t(o))}function m(t){return 40===t||41===t||92===t?(e.consume(t),f):f(t)}}function Dn(e,t,n,r,o,i){const s=this;let l,a=0;return function(t){return e.enter(r),e.enter(o),e.consume(t),e.exit(o),e.enter(i),c};function c(d){return a>999||null===d||91===d||93===d&&!l||94===d&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(i),e.enter(o),e.consume(d),e.exit(o),e.exit(r),t):sn(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||sn(t)||a++>999?(e.exit("chunkString"),c(t)):(e.consume(t),l||(l=!an(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),a++,u):u(t)}}function Rn(e,t,n,r,o,i){let s;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(o),e.consume(t),e.exit(o),s=40===t?41:t,l):n(t)};function l(n){return n===s?(e.enter(o),e.consume(n),e.exit(o),e.exit(r),t):(e.enter(i),a(n))}function a(t){return t===s?(e.exit(i),l(s)):null===t?n(t):sn(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),hn(e,a,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===s||null===t||sn(t)?(e.exit("chunkString"),a(t)):(e.consume(t),92===t?u:c)}function u(t){return t===s||92===t?(e.consume(t),c):c(t)}}function Pn(e,t){let n;return function r(o){return sn(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):an(o)?hn(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}function $n(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ln={name:"definition",tokenize:function(e,t,n){const r=this;let o;return function(t){return e.enter("definition"),function(t){return Dn.call(r,e,i,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function i(t){return o=$n(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return ln(t)?Pn(e,l)(t):l(t)}function l(t){return In(e,a,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function a(t){return e.attempt(zn,c,c)(t)}function c(t){return an(t)?hn(e,u,"whitespace")(t):u(t)}function u(i){return null===i||sn(i)?(e.exit("definition"),r.parser.defined.push(o),t(i)):n(i)}}},zn={partial:!0,tokenize:function(e,t,n){return function(t){return ln(t)?Pn(e,r)(t):n(t)};function r(t){return Rn(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return an(t)?hn(e,i,"whitespace")(t):i(t)}function i(e){return null===e||sn(e)?t(e):n(e)}}},Bn={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),hn(e,o,"linePrefix",5)(t)};function o(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?i(e):n(e)}function i(t){return null===t?l(t):sn(t)?e.attempt(Fn,i,l)(t):(e.enter("codeFlowValue"),s(t))}function s(t){return null===t||sn(t)?(e.exit("codeFlowValue"),i(t)):(e.consume(t),s)}function l(n){return e.exit("codeIndented"),t(n)}}},Fn={partial:!0,tokenize:function(e,t,n){const r=this;return o;function o(t){return r.parser.lazy[r.now().line]?n(t):sn(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):hn(e,i,"linePrefix",5)(t)}function i(e){const i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(e):sn(e)?o(e):n(e)}}},jn={name:"headingAtx",resolve:function(e,t){let n,r,o=e.length-2,i=3;return"whitespace"===e[i][1].type&&(i+=2),o-2>i&&"whitespace"===e[o][1].type&&(o-=2),"atxHeadingSequence"===e[o][1].type&&(i===o-1||o-4>i&&"whitespace"===e[o-2][1].type)&&(o-=i+1===o?2:4),o>i&&(n={type:"atxHeadingText",start:e[i][1].start,end:e[o][1].end},r={type:"chunkText",start:e[i][1].start,end:e[o][1].end,contentType:"text"},Wt(e,i,o-i+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),o(t)}(t)};function o(t){return 35===t&&r++<6?(e.consume(t),o):null===t||ln(t)?(e.exit("atxHeadingSequence"),i(t)):n(t)}function i(n){return 35===n?(e.enter("atxHeadingSequence"),s(n)):null===n||sn(n)?(e.exit("atxHeading"),t(n)):an(n)?hn(e,i,"whitespace")(n):(e.enter("atxHeadingText"),l(n))}function s(t){return 35===t?(e.consume(t),s):(e.exit("atxHeadingSequence"),i(t))}function l(t){return null===t||35===t||ln(t)?(e.exit("atxHeadingText"),i(t)):(e.consume(t),l)}}},_n={name:"setextUnderline",resolveTo:function(e,t){let n,r,o,i=e.length;for(;i--;)if("enter"===e[i][0]){if("content"===e[i][1].type){n=i;break}"paragraph"===e[i][1].type&&(r=i)}else"content"===e[i][1].type&&e.splice(i,1),o||"definition"!==e[i][1].type||(o=i);const s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",o?(e.splice(r,0,["enter",s,t]),e.splice(o+1,0,["exit",e[n][1],t]),e[n][1].end={...e[o][1].end}):e[n][1]=s,e.push(["exit",s,t]),e},tokenize:function(e,t,n){const r=this;let o;return function(t){let s,l=r.events.length;for(;l--;)if("lineEnding"!==r.events[l][1].type&&"linePrefix"!==r.events[l][1].type&&"content"!==r.events[l][1].type){s="paragraph"===r.events[l][1].type;break}return r.parser.lazy[r.now().line]||!r.interrupt&&!s?n(t):(e.enter("setextHeadingLine"),o=t,function(t){return e.enter("setextHeadingLineSequence"),i(t)}(t))};function i(t){return t===o?(e.consume(t),i):(e.exit("setextHeadingLineSequence"),an(t)?hn(e,s,"lineSuffix")(t):s(t))}function s(r){return null===r||sn(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}},Wn=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Vn=["pre","script","style","textarea"],Hn={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){const r=this;let o,i,s,l,a;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(l){return 33===l?(e.consume(l),u):47===l?(e.consume(l),i=!0,p):63===l?(e.consume(l),o=3,r.interrupt?t:P):Zt(l)?(e.consume(l),s=String.fromCharCode(l),f):n(l)}function u(i){return 45===i?(e.consume(i),o=2,d):91===i?(e.consume(i),o=5,l=0,h):Zt(i)?(e.consume(i),o=4,r.interrupt?t:P):n(i)}function d(o){return 45===o?(e.consume(o),r.interrupt?t:P):n(o)}function h(o){return o==="CDATA[".charCodeAt(l++)?(e.consume(o),6===l?r.interrupt?t:N:h):n(o)}function p(t){return Zt(t)?(e.consume(t),s=String.fromCharCode(t),f):n(t)}function f(l){if(null===l||47===l||62===l||ln(l)){const a=47===l,c=s.toLowerCase();return a||i||!Vn.includes(c)?Wn.includes(s.toLowerCase())?(o=6,a?(e.consume(l),m):r.interrupt?t(l):N(l)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(l):i?g(l):y(l)):(o=1,r.interrupt?t(l):N(l))}return 45===l||Qt(l)?(e.consume(l),s+=String.fromCharCode(l),f):n(l)}function m(o){return 62===o?(e.consume(o),r.interrupt?t:N):n(o)}function g(t){return an(t)?(e.consume(t),g):S(t)}function y(t){return 47===t?(e.consume(t),S):58===t||95===t||Zt(t)?(e.consume(t),w):an(t)?(e.consume(t),y):S(t)}function w(t){return 45===t||46===t||58===t||95===t||Qt(t)?(e.consume(t),w):k(t)}function k(t){return 61===t?(e.consume(t),v):an(t)?(e.consume(t),k):y(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,b):an(t)?(e.consume(t),v):x(t)}function b(t){return t===a?(e.consume(t),a=null,C):null===t||sn(t)?n(t):(e.consume(t),b)}function x(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||ln(t)?k(t):(e.consume(t),x)}function C(e){return 47===e||62===e||an(e)?y(e):n(e)}function S(t){return 62===t?(e.consume(t),M):n(t)}function M(t){return null===t||sn(t)?N(t):an(t)?(e.consume(t),M):n(t)}function N(t){return 45===t&&2===o?(e.consume(t),E):60===t&&1===o?(e.consume(t),I):62===t&&4===o?(e.consume(t),$):63===t&&3===o?(e.consume(t),P):93===t&&5===o?(e.consume(t),R):!sn(t)||6!==o&&7!==o?null===t||sn(t)?(e.exit("htmlFlowData"),T(t)):(e.consume(t),N):(e.exit("htmlFlowData"),e.check(qn,L,T)(t))}function T(t){return e.check(Kn,O,L)(t)}function O(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),A}function A(t){return null===t||sn(t)?T(t):(e.enter("htmlFlowData"),N(t))}function E(t){return 45===t?(e.consume(t),P):N(t)}function I(t){return 47===t?(e.consume(t),s="",D):N(t)}function D(t){if(62===t){const n=s.toLowerCase();return Vn.includes(n)?(e.consume(t),$):N(t)}return Zt(t)&&s.length<8?(e.consume(t),s+=String.fromCharCode(t),D):N(t)}function R(t){return 93===t?(e.consume(t),P):N(t)}function P(t){return 62===t?(e.consume(t),$):45===t&&2===o?(e.consume(t),P):N(t)}function $(t){return null===t||sn(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),$)}function L(n){return e.exit("htmlFlow"),t(n)}}},qn={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(gn,t,n)}}},Kn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return sn(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):n(t)};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Un={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o)};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Jn={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s};function s(t){return e.enter("codeFencedFence"),an(t)?hn(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):a(t)}function a(t){return t===i?(e.enter("codeFencedFenceSequence"),c(t)):n(t)}function c(t){return t===i?(o++,e.consume(t),c):o>=l?(e.exit("codeFencedFenceSequence"),an(t)?hn(e,u,"whitespace")(t):u(t)):n(t)}function u(r){return null===r||sn(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let i,s=0,l=0;return function(t){return function(t){const n=r.events[r.events.length-1];return s=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,i=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),a(t)}(t)};function a(t){return t===i?(l++,e.consume(t),a):l<3?n(t):(e.exit("codeFencedFenceSequence"),an(t)?hn(e,c,"whitespace")(t):c(t))}function c(n){return null===n||sn(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(Un,p,w)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||sn(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):an(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),hn(e,d,"whitespace")(t)):96===t&&t===i?n(t):(e.consume(t),u)}function d(t){return null===t||sn(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||sn(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===i?n(t):(e.consume(t),h)}function p(t){return e.attempt(o,w,f)(t)}function f(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),m}function m(t){return s>0&&an(t)?hn(e,g,"linePrefix",s+1)(t):g(t)}function g(t){return null===t||sn(t)?e.check(Un,p,w)(t):(e.enter("codeFlowValue"),y(t))}function y(t){return null===t||sn(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),y)}function w(n){return e.exit("codeFenced"),t(n)}}},Yn=document.createElement("i");function Gn(e){const t="&"+e+";";Yn.innerHTML=t;const n=Yn.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}const Xn={name:"characterReference",tokenize:function(e,t,n){const r=this;let o,i,s=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),l};function l(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),a):(e.enter("characterReferenceValue"),o=31,i=Qt,c(t))}function a(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=rn,c):(e.enter("characterReferenceValue"),o=7,i=nn,c(t))}function c(l){if(59===l&&s){const o=e.exit("characterReferenceValue");return i!==Qt||Gn(r.sliceSerialize(o))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return i(l)&&s++<o?(e.consume(l),c):n(l)}}},Zn={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return on(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},Qn={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),hn(e,t,"linePrefix")}}};function er(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const tr={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&Wt(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,o,i,s=e.length,l=0;for(;s--;)if(n=e[s][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[s][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(o){if("enter"===e[s][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=s,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(o=s);const a={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[o-2][1].start}};return i=[["enter",a,t],["enter",c,t]],i=Vt(i,e.slice(r+1,r+l+3)),i=Vt(i,[["enter",u,t]]),i=Vt(i,er(t.parser.constructs.insideSpan.null,e.slice(r+l+4,o-3),t)),i=Vt(i,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),i=Vt(i,e.slice(o+1)),i=Vt(i,[["exit",a,t]]),Wt(e,r,e.length,i),e},tokenize:function(e,t,n){const r=this;let o,i,s=r.events.length;for(;s--;)if(("labelImage"===r.events[s][1].type||"labelLink"===r.events[s][1].type)&&!r.events[s][1]._balanced){o=r.events[s][1];break}return function(t){return o?o._inactive?u(t):(i=r.parser.defined.includes($n(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),l):n(t)};function l(t){return 40===t?e.attempt(nr,c,i?c:u)(t):91===t?e.attempt(rr,c,i?a:u)(t):i?c(t):u(t)}function a(t){return e.attempt(or,c,u)(t)}function c(e){return t(e)}function u(e){return o._balanced=!0,n(e)}}},nr={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return ln(t)?Pn(e,o)(t):o(t)}function o(t){return 41===t?c(t):In(e,i,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function i(t){return ln(t)?Pn(e,l)(t):c(t)}function s(e){return n(e)}function l(t){return 34===t||39===t||40===t?Rn(e,a,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function a(t){return ln(t)?Pn(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},rr={tokenize:function(e,t,n){const r=this;return function(t){return Dn.call(r,e,o,i,"reference","referenceMarker","referenceString")(t)};function o(e){return r.parser.defined.includes($n(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function i(e){return n(e)}}},or={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},ir={name:"labelStartImage",resolveAll:tr.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),o};function o(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),i):n(t)}function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};function sr(e){return null===e||ln(e)||un(e)?1:cn(e)?2:void 0}const lr={name:"attention",resolveAll:function(e,t){let n,r,o,i,s,l,a,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[n][1].end},h={...e[u][1].start};ar(d,-l),ar(h,l),i={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},o={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:l>1?"strong":"emphasis",start:{...i.start},end:{...s.end}},e[n][1].end={...i.start},e[u][1].start={...s.end},a=[],e[n][1].end.offset-e[n][1].start.offset&&(a=Vt(a,[["enter",e[n][1],t],["exit",e[n][1],t]])),a=Vt(a,[["enter",r,t],["enter",i,t],["exit",i,t],["enter",o,t]]),a=Vt(a,er(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),a=Vt(a,[["exit",o,t],["enter",s,t],["exit",s,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,a=Vt(a,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,Wt(e,n-1,u-n+3,a),u=n+a.length-c-2;break}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=sr(r);let i;return function(t){return i=t,e.enter("attentionSequence"),s(t)};function s(l){if(l===i)return e.consume(l),s;const a=e.exit("attentionSequence"),c=sr(l),u=!c||2===c&&o||n.includes(l),d=!o||2===o&&c||n.includes(r);return a._open=Boolean(42===i?u:u&&(o||!d)),a._close=Boolean(42===i?d:d&&(c||!u)),t(l)}}};function ar(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const cr={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o};function o(t){return Zt(t)?(e.consume(t),i):64===t?n(t):a(t)}function i(e){return 43===e||45===e||46===e||Qt(e)?(r=1,s(e)):a(e)}function s(t){return 58===t?(e.consume(t),r=0,l):(43===t||45===t||46===t||Qt(t))&&r++<32?(e.consume(t),s):(r=0,a(t))}function l(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||tn(r)?n(r):(e.consume(r),l)}function a(t){return 64===t?(e.consume(t),c):en(t)?(e.consume(t),a):n(t)}function c(e){return Qt(e)?u(e):n(e)}function u(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):d(n)}function d(t){if((45===t||Qt(t))&&r++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}},ur={name:"htmlText",tokenize:function(e,t,n){const r=this;let o,i,s;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),l};function l(t){return 33===t?(e.consume(t),a):47===t?(e.consume(t),v):63===t?(e.consume(t),w):Zt(t)?(e.consume(t),C):n(t)}function a(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,p):Zt(t)?(e.consume(t),y):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):sn(t)?(s=u,D(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?I(e):45===e?d(e):u(e)}function p(t){return t==="CDATA[".charCodeAt(i++)?(e.consume(t),6===i?f:p):n(t)}function f(t){return null===t?n(t):93===t?(e.consume(t),m):sn(t)?(s=f,D(t)):(e.consume(t),f)}function m(t){return 93===t?(e.consume(t),g):f(t)}function g(t){return 62===t?I(t):93===t?(e.consume(t),g):f(t)}function y(t){return null===t||62===t?I(t):sn(t)?(s=y,D(t)):(e.consume(t),y)}function w(t){return null===t?n(t):63===t?(e.consume(t),k):sn(t)?(s=w,D(t)):(e.consume(t),w)}function k(e){return 62===e?I(e):w(e)}function v(t){return Zt(t)?(e.consume(t),b):n(t)}function b(t){return 45===t||Qt(t)?(e.consume(t),b):x(t)}function x(t){return sn(t)?(s=x,D(t)):an(t)?(e.consume(t),x):I(t)}function C(t){return 45===t||Qt(t)?(e.consume(t),C):47===t||62===t||ln(t)?S(t):n(t)}function S(t){return 47===t?(e.consume(t),I):58===t||95===t||Zt(t)?(e.consume(t),M):sn(t)?(s=S,D(t)):an(t)?(e.consume(t),S):I(t)}function M(t){return 45===t||46===t||58===t||95===t||Qt(t)?(e.consume(t),M):N(t)}function N(t){return 61===t?(e.consume(t),T):sn(t)?(s=N,D(t)):an(t)?(e.consume(t),N):S(t)}function T(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),o=t,O):sn(t)?(s=T,D(t)):an(t)?(e.consume(t),T):(e.consume(t),A)}function O(t){return t===o?(e.consume(t),o=void 0,E):null===t?n(t):sn(t)?(s=O,D(t)):(e.consume(t),O)}function A(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||ln(t)?S(t):(e.consume(t),A)}function E(e){return 47===e||62===e||ln(e)?S(e):n(e)}function I(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function D(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return an(t)?hn(e,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):P(t)}function P(t){return e.enter("htmlTextData"),s(t)}}},dr={name:"labelStartLink",resolveAll:tr.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),o};function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},hr={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return sn(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},pr={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,o=3;if(!("lineEnding"!==e[o][1].type&&"space"!==e[o][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=o;++t<r;)if("codeTextData"===e[t][1].type){e[o][1].type="codeTextPadding",e[r][1].type="codeTextPadding",o+=2,r-=2;break}for(t=o-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,o,i=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),s(t)};function s(t){return 96===t?(e.consume(t),i++,s):(e.exit("codeTextSequence"),l(t))}function l(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),l):96===t?(o=e.enter("codeTextSequence"),r=0,c(t)):sn(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l):(e.enter("codeTextData"),a(t))}function a(t){return null===t||32===t||96===t||sn(t)?(e.exit("codeTextData"),l(t)):(e.consume(t),a)}function c(n){return 96===n?(e.consume(n),r++,c):r===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(o.type="codeTextData",a(n))}}},fr={42:Tn,43:Tn,45:Tn,48:Tn,49:Tn,50:Tn,51:Tn,52:Tn,53:Tn,54:Tn,55:Tn,56:Tn,57:Tn,62:En},mr={91:Ln},gr={[-2]:Bn,[-1]:Bn,32:Bn},yr={35:jn,42:Nn,45:[_n,Nn],60:Hn,61:_n,95:Nn,96:Jn,126:Jn},wr={38:Xn,92:Zn},kr={[-5]:Qn,[-4]:Qn,[-3]:Qn,33:ir,38:Xn,42:lr,60:[cr,ur],91:dr,92:[hr,Zn],93:tr,95:lr,96:pr},vr={null:[lr,vn]},br={null:[42,95]},xr={null:[]};function Cr(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},i=[];let s=[],l=[],a=!0;const c={attempt:y((function(e,t){w(e,t.from)})),check:y(g),consume:function(e){sn(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,k()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=e,a=!0},enter:function(e,t){const n=t||{};return n.type=e,n.start=f(),u.events.push(["enter",n,u]),l.push(n),n},exit:function(e){const t=l.pop();return t.end=f(),u.events.push(["exit",t,u]),t},interrupt:y(g,{interrupt:!0})},u={code:null,containerState:{},defineSkip:function(e){o[e.line]=e.column,k()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const i=e[n];let s;if("string"==typeof i)s=i;else switch(i){case-5:s="\r";break;case-4:s="\n";break;case-3:s="\r\n";break;case-2:s=t?" ":"\t";break;case-1:if(!t&&o)continue;s=" ";break;default:s=String.fromCharCode(i)}o=-2===i,r.push(s)}return r.join("")}(p(e),t)},sliceStream:p,write:function(e){return s=Vt(s,e),function(){let e;for(;r._index<s.length;){const t=s[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)m(t.charCodeAt(r._bufferIndex));else m(t)}}(),null!==s[s.length-1]?[]:(w(t,0),u.events=er(i,u.events,u),u.events)}};let d,h=t.tokenize.call(u,c);return t.resolveAll&&i.push(t),u;function p(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex;let s;if(n===o)s=[e[n].slice(r,i)];else{if(s=e.slice(n,o),r>-1){const e=s[0];"string"==typeof e?s[0]=e.slice(r):s.shift()}i>0&&s.push(e[o].slice(0,i))}return s}(s,e)}function f(){const{_bufferIndex:e,_index:t,line:n,column:o,offset:i}=r;return{_bufferIndex:e,_index:t,line:n,column:o,offset:i}}function m(e){a=void 0,d=e,h=h(e)}function g(e,t){t.restore()}function y(e,t){return function(n,o,i){let s,d,h,p;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):function(e){return function(t){const n=null!==t&&e[t],r=null!==t&&e.null;return m([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function m(e){return s=e,d=0,0===e.length?i:g(e[d])}function g(e){return function(n){return p=function(){const e=f(),t=u.previous,n=u.currentConstruct,o=u.events.length,i=Array.from(l);return{from:o,restore:function(){r=e,u.previous=t,u.currentConstruct=n,u.events.length=o,l=i,k()}}}(),h=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name)?w():e.tokenize.call(t?Object.assign(Object.create(u),t):u,c,y,w)(n)}}function y(t){return a=!0,e(h,p),o}function w(e){return a=!0,p.restore(),++d<s.length?g(s[d]):i}}}function w(e,t){e.resolveAll&&!i.includes(e)&&i.push(e),e.resolve&&Wt(u.events,t,u.events.length-t,e.resolve(u.events.slice(t),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function k(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}const Sr=/[\0\t\n\r]/g;function Mr(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}const Nr=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Tr(e){return e.replace(Nr,Or)}function Or(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Mr(n.slice(t?2:1),t?16:10)}return Gn(n)||e}function Ar(e){return e&&"object"==typeof e?"position"in e||"type"in e?Ir(e.position):"start"in e||"end"in e?Ir(e):"line"in e||"column"in e?Er(e):"":""}function Er(e){return Dr(e&&e.line)+":"+Dr(e&&e.column)}function Ir(e){return Er(e&&e.start)+"-"+Er(e&&e.end)}function Dr(e){return e&&"number"==typeof e?e:1}const Rr={}.hasOwnProperty;function Pr(e,n,r){return"string"!=typeof n&&(r=n,n=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(w),autolinkProtocol:u,autolinkEmail:u,atxHeading:o(m),blockQuote:o((function(){return{type:"blockquote",children:[]}})),characterEscape:u,characterReference:u,codeFenced:o(f),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:o(f,i),codeText:o((function(){return{type:"inlineCode",value:""}}),i),codeTextData:u,data:u,codeFlowValue:u,definition:o((function(){return{type:"definition",identifier:"",label:null,title:null,url:""}})),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:o((function(){return{type:"emphasis",children:[]}})),hardBreakEscape:o(g),hardBreakTrailing:o(g),htmlFlow:o(y,i),htmlFlowData:u,htmlText:o(y,i),htmlTextData:u,image:o((function(){return{type:"image",title:null,url:"",alt:null}})),label:i,link:o(w),listItem:o((function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}})),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:o(k,(function(){this.data.expectingFirstListItemValue=!0})),listUnordered:o(k),paragraph:o((function(){return{type:"paragraph",children:[]}})),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:o(m),strong:o((function(){return{type:"strong",children:[]}})),thematicBreak:o((function(){return{type:"thematicBreak"}}))},exit:{atxHeading:l(),atxHeadingSequence:function(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}},autolink:l(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:l(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;n?(r=Mr(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0):r=Gn(t);this.stack[this.stack.length-1].value+=r},characterReference:function(e){this.stack.pop().position.end=$r(e.end)},codeFenced:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0})),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){const e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){const e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")})),codeText:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),codeTextData:d,data:d,definition:l(),definitionDestinationString:function(){const e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=$n(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){const e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:l(),hardBreakEscape:l(h),hardBreakTrailing:l(h),htmlFlow:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),htmlFlowData:d,htmlText:l((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),htmlTextData:d,image:l((function(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0})),label:function(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t},labelText:function(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Tr(t),n.identifier=$n(t).toLowerCase()},lineEnding:function(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak)return n.children[n.children.length-1].position.end=$r(e.end),void(this.data.atHardBreak=void 0);!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(u.call(this,e),d.call(this,e))},link:l((function(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0})),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:function(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=$n(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){const e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){const e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:l((function(){this.data.setextHeadingSlurpLineEnding=void 0})),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:l(),thematicBreak:l()}};Lr(t,(e||{}).mdastExtensions||[]);const n={};return function(e){let o={type:"root",children:[]};const l={stack:[o],tokenStack:[],config:t,enter:s,exit:a,buffer:i,resume:c,data:n},u=[];let d=-1;for(;++d<e.length;)"listOrdered"!==e[d][1].type&&"listUnordered"!==e[d][1].type||("enter"===e[d][0]?u.push(d):d=r(e,u.pop(),d));for(d=-1;++d<e.length;){const n=t[e[d][0]];Rr.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},l),e[d][1])}if(l.tokenStack.length>0){const e=l.tokenStack[l.tokenStack.length-1];(e[1]||Br).call(l,void 0,e[0])}for(o.position={start:$r(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:$r(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)o=t.transforms[d](o)||o;return o};function r(e,t,n){let r,o,i,s,l=t-1,a=-1,c=!1;for(;++l<=n;){const t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?a++:a--,s=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||s||a||i||(i=l),s=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:s=void 0}if(!a&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===a&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let s=l;for(o=void 0;s--;){const t=e[s];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;o&&(e[o][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",o=s}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}i&&(!o||i<o)&&(r._spread=!0),r.end=Object.assign({},o?e[o][1].start:t[1].end),e.splice(o||l,0,["exit",r,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){const o={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=o,e.splice(l,0,["enter",o,t[2]]),l++,n++,i=void 0,s=!0}}}return e[t][1]._spread=c,n}function o(e,t){return function(n){s.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:$r(t.start),end:void 0}}function l(e){return function(t){e&&e.call(this,t),a.call(this,t)}}function a(e,t){const n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+Ar({start:e.start,end:e.end})+"): it’s not open");r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Br).call(this,e,r[0])),n.position.end=$r(e.end)}function c(){return Ft(this.stack.pop())}function u(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n={type:"text",value:""},n.position={start:$r(e.start),end:void 0},t.push(n)),this.stack.push(n)}function d(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=$r(e.end)}function h(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function f(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function g(){return{type:"break"}}function y(){return{type:"html",value:""}}function w(){return{type:"link",title:null,url:"",children:[]}}function k(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}}(r)(function(e){for(;!Kt(e););return e}(function(e){const n={constructs:Yt([t,...(e||{}).extensions||[]]),content:r(pn),defined:[],document:r(fn),flow:r(kn),lazy:{},string:r(bn),text:r(xn)};return n;function r(e){return function(t){return Cr(n,e,t)}}}(r).document().write(function(){let e,t=1,n="",r=!0;return function(o,i,s){const l=[];let a,c,u,d,h;for(o=n+("string"==typeof o?o.toString():new TextDecoder(i||void 0).decode(o)),u=0,n="",r&&(65279===o.charCodeAt(0)&&u++,r=void 0);u<o.length;){if(Sr.lastIndex=u,a=Sr.exec(o),d=a&&void 0!==a.index?a.index:o.length,h=o.charCodeAt(d),!a){n=o.slice(u);break}if(10===h&&u===d&&e)l.push(-3),e=void 0;else switch(e&&(l.push(-5),e=void 0),u<d&&(l.push(o.slice(u,d)),t+=d-u),h){case 0:l.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),l.push(-2);t++<c;)l.push(-1);break;case 10:l.push(-4),t=1;break;default:e=!0,t=1}u=d+1}return s&&(e&&l.push(-5),n&&l.push(n),l.push(null)),l}}()(e,n,!0))))}function $r(e){return{line:e.line,column:e.column,offset:e.offset}}function Lr(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Lr(e,r):zr(e,r)}}function zr(e,t){let n;for(n in t)if(Rr.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Br(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ar({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ar({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ar({start:t.start,end:t.end})+") is still open")}function Fr(e){const t=this;t.parser=function(n){return Pr(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}const jr={}.hasOwnProperty,_r={}.hasOwnProperty;function Wr(e,t){let n,r=-1;if(t.extensions)for(;++r<t.extensions.length;)Wr(e,t.extensions[r]);for(n in t)if(_r.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":o=e[n],(i=t[n])&&o.push(...i);break;case"handlers":Vr(e[n],t[n]);break;default:e.options[n]=t[n]}var o,i;return e}function Vr(e,t){t&&Object.assign(e,t)}function Hr(e,t,n){return">"+(n?"":" ")+e}function qr(e,t){return Kr(e,t.inConstruct,!0)&&!Kr(e,t.notInConstruct,!1)}function Kr(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ur(e,t,n,r){let o=-1;for(;++o<n.unsafe.length;)if("\n"===n.unsafe[o].character&&qr(n.stack,n.unsafe[o]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function Jr(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Yr(e,t,n){return(n?"":" ")+e}function Gr(e){const t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Xr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Zr(e,t,n){const r=sr(e),o=sr(t);return void 0===r?void 0===o?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===o?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===o?{inside:!1,outside:!1}:1===o?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===o?{inside:!1,outside:!1}:1===o?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Qr(e,t,n,r){const o=function(e){const t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),i=n.enter("emphasis"),s=n.createTracker(r),l=s.move(o);let a=s.move(n.containerPhrasing(e,{after:o,before:l,...s.current()}));const c=a.charCodeAt(0),u=Zr(r.before.charCodeAt(r.before.length-1),c,o);u.inside&&(a=Xr(c)+a.slice(1));const d=a.charCodeAt(a.length-1),h=Zr(r.after.charCodeAt(0),d,o);h.inside&&(a=a.slice(0,-1)+Xr(d));const p=s.move(o);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},l+a+p}Qr.peek=function(e,t,n){return n.options.emphasis||"*"};const eo=function(e){if(null==e)return no;if("function"==typeof e)return to(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=eo(e[n]);return to((function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}))}(e):function(e){const t=e;return to((function(n){const r=n;let o;for(o in e)if(r[o]!==t[o])return!1;return!0}))}(e);if("string"==typeof e)return t=e,to((function(e){return e&&e.type===t}));var t;throw new Error("Expected function, string, or object as test")};function to(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function no(){return!0}const ro=[],oo=!0,io=!1,so="skip";function lo(e,t,n,r){let o;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):o=t;const i=eo(o),s=r?-1:1;!function e(o,l,a){const c=o&&"object"==typeof o?o:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+o.type+(e?"<"+e+">":"")+")"})}return u;function u(){let c,u,d,h=ro;if((!t||i(o,l,a[a.length-1]||void 0))&&(h=function(e){return Array.isArray(e)?e:"number"==typeof e?[oo,e]:null==e?ro:[e]}(n(o,a)),h[0]===io))return h;if("children"in o&&o.children){const t=o;if(t.children&&h[0]!==so)for(u=(r?t.children.length:-1)+s,d=a.concat(t);u>-1&&u<t.children.length;){const n=t.children[u];if(c=e(n,u,d)(),c[0]===io)return c;u="number"==typeof c[1]?c[1]:u+s}}return h}}(e,void 0,[])()}function ao(e,t,n,r){let o,i,s;"function"==typeof t&&"function"!=typeof n?(i=void 0,s=t,o=n):(i=t,s=n,o=r),lo(e,i,(function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return s(e,r,n)}),o)}function co(e,t){let n=!1;return ao(e,(function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,io})),Boolean((!e.depth||e.depth<3)&&Ft(e)&&(t.options.setext||n))}function uo(e){return e.value||""}function ho(e,t,n,r){const o=Gr(n),i='"'===o?"Quote":"Apostrophe",s=n.enter("image");let l=n.enter("label");const a=n.createTracker(r);let c=a.move("![");return c+=a.move(n.safe(e.alt,{before:c,after:"]",...a.current()})),c+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${i}`),c+=a.move(" "+o),c+=a.move(n.safe(e.title,{before:c,after:o,...a.current()})),c+=a.move(o),l()),c+=a.move(")"),s(),c}function po(e,t,n,r){const o=e.referenceType,i=n.enter("imageReference");let s=n.enter("label");const l=n.createTracker(r);let a=l.move("![");const c=n.safe(e.alt,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(e),{before:a,after:"]",...l.current()});return s(),n.stack=u,i(),"full"!==o&&c&&c===d?"shortcut"===o?a=a.slice(0,-1):a+=l.move("]"):a+=l.move(d+"]"),a}function fo(e,t,n){let r=e.value||"",o="`",i=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++i<n.unsafe.length;){const e=n.unsafe[i],t=n.compilePattern(e);let o;if(e.atBreak)for(;o=t.exec(r);){let e=o.index;10===r.charCodeAt(e)&&13===r.charCodeAt(e-1)&&e--,r=r.slice(0,e)+" "+r.slice(o.index+1)}}return o+r+o}function mo(e,t){const n=Ft(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function go(e,t,n,r){const o=Gr(n),i='"'===o?"Quote":"Apostrophe",s=n.createTracker(r);let l,a;if(mo(e,n)){const t=n.stack;n.stack=[],l=n.enter("autolink");let r=s.move("<");return r+=s.move(n.containerPhrasing(e,{before:r,after:">",...s.current()})),r+=s.move(">"),l(),n.stack=t,r}l=n.enter("link"),a=n.enter("label");let c=s.move("[");return c+=s.move(n.containerPhrasing(e,{before:c,after:"](",...s.current()})),c+=s.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(n.safe(e.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(a=n.enter("destinationRaw"),c+=s.move(n.safe(e.url,{before:c,after:e.title?" ":")",...s.current()}))),a(),e.title&&(a=n.enter(`title${i}`),c+=s.move(" "+o),c+=s.move(n.safe(e.title,{before:c,after:o,...s.current()})),c+=s.move(o),a()),c+=s.move(")"),l(),c}function yo(e,t,n,r){const o=e.referenceType,i=n.enter("linkReference");let s=n.enter("label");const l=n.createTracker(r);let a=l.move("[");const c=n.containerPhrasing(e,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(e),{before:a,after:"]",...l.current()});return s(),n.stack=u,i(),"full"!==o&&c&&c===d?"shortcut"===o?a=a.slice(0,-1):a+=l.move("]"):a+=l.move(d+"]"),a}function wo(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ko(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}uo.peek=function(){return"<"},ho.peek=function(){return"!"},po.peek=function(){return"!"},fo.peek=function(){return"`"},go.peek=function(e,t,n){return mo(e,n)?"<":"["},yo.peek=function(){return"["};const vo=eo(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function bo(e,t,n,r){const o=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),i=n.enter("strong"),s=n.createTracker(r),l=s.move(o+o);let a=s.move(n.containerPhrasing(e,{after:o,before:l,...s.current()}));const c=a.charCodeAt(0),u=Zr(r.before.charCodeAt(r.before.length-1),c,o);u.inside&&(a=Xr(c)+a.slice(1));const d=a.charCodeAt(a.length-1),h=Zr(r.after.charCodeAt(0),d,o);h.inside&&(a=a.slice(0,-1)+Xr(d));const p=s.move(o+o);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},l+a+p}bo.peek=function(e,t,n){return n.options.strong||"*"};const xo={blockquote:function(e,t,n,r){const o=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const s=n.indentLines(n.containerFlow(e,i.current()),Hr);return o(),s},break:Ur,code:function(e,t,n,r){const o=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),i=e.value||"",s="`"===o?"GraveAccent":"Tilde";if(Jr(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(i,Yr);return e(),t}const l=n.createTracker(r),a=o.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),o=r,i=0,s=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===o?++i>s&&(s=i):i=1,o=r+t.length,r=n.indexOf(t,o);return s}(i,o)+1,3)),c=n.enter("codeFenced");let u=l.move(a);if(e.lang){const t=n.enter(`codeFencedLang${s}`);u+=l.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...l.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${s}`);u+=l.move(" "),u+=l.move(n.safe(e.meta,{before:u,after:"\n",encode:["`"],...l.current()})),t()}return u+=l.move("\n"),i&&(u+=l.move(i+"\n")),u+=l.move(a),c(),u},definition:function(e,t,n,r){const o=Gr(n),i='"'===o?"Quote":"Apostrophe",s=n.enter("definition");let l=n.enter("label");const a=n.createTracker(r);let c=a.move("[");return c+=a.move(n.safe(n.associationId(e),{before:c,after:"]",...a.current()})),c+=a.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...a.current()}))),l(),e.title&&(l=n.enter(`title${i}`),c+=a.move(" "+o),c+=a.move(n.safe(e.title,{before:c,after:o,...a.current()})),c+=a.move(o),l()),s(),c},emphasis:Qr,hardBreak:Ur,heading:function(e,t,n,r){const o=Math.max(Math.min(6,e.depth||1),1),i=n.createTracker(r);if(co(e,n)){const t=n.enter("headingSetext"),r=n.enter("phrasing"),s=n.containerPhrasing(e,{...i.current(),before:"\n",after:"\n"});return r(),t(),s+"\n"+(1===o?"=":"-").repeat(s.length-(Math.max(s.lastIndexOf("\r"),s.lastIndexOf("\n"))+1))}const s="#".repeat(o),l=n.enter("headingAtx"),a=n.enter("phrasing");i.move(s+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...i.current()});return/^[\t ]/.test(c)&&(c=Xr(c.charCodeAt(0))+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),a(),l(),c},html:uo,image:ho,imageReference:po,inlineCode:fo,link:go,linkReference:yo,list:function(e,t,n,r){const o=n.enter("list"),i=n.bulletCurrent;let s=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):wo(n);const l=e.ordered?"."===s?")":".":function(e){const t=wo(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let a=!(!t||!n.bulletLastUsed)&&s===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==s&&"-"!==s||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(a=!0),ko(n)===s&&t){let t=-1;for(;++t<e.children.length;){const n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){a=!0;break}}}}a&&(s=l),n.bulletCurrent=s;const c=n.containerFlow(e,r);return n.bulletLastUsed=s,n.bulletCurrent=i,o(),c},listItem:function(e,t,n,r){const o=function(e){const t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n);let i=n.bulletCurrent||wo(n);t&&"list"===t.type&&t.ordered&&(i=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+i);let s=i.length+1;("tab"===o||"mixed"===o&&(t&&"list"===t.type&&t.spread||e.spread))&&(s=4*Math.ceil(s/4));const l=n.createTracker(r);l.move(i+" ".repeat(s-i.length)),l.shift(s);const a=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,l.current()),(function(e,t,n){return t?(n?"":" ".repeat(s))+e:(n?i:i+" ".repeat(s-i.length))+e}));return a(),c},paragraph:function(e,t,n,r){const o=n.enter("paragraph"),i=n.enter("phrasing"),s=n.containerPhrasing(e,r);return i(),o(),s},root:function(e,t,n,r){return(e.children.some((function(e){return vo(e)}))?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:bo,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(ko(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}},Co=[function(e,t,n,r){if("code"===t.type&&Jr(t,r)&&("list"===e.type||e.type===t.type&&Jr(e,r)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&co(t,r)))return;return n.spread?1:0}}],So=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Mo=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:So},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:So},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:So},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:So},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:So},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:So},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:So},{atBreak:!0,character:"~"}];function No(e){return e.label||!e.identifier?e.label||"":Tr(e.identifier)}function To(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function Oo(e,t,n,r){let o=r.join.length;for(;o--;){const i=r.join[o](e,t,n,r);if(!0===i||1===i)break;if("number"==typeof i)return"\n".repeat(1+i);if(!1===i)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const Ao=/\r?\n|\r/g;function Eo(e,t){const n=[];let r,o=0,i=0;for(;r=Ao.exec(e);)s(e.slice(o,r.index)),n.push(r[0]),o=r.index+r[0].length,i++;return s(e.slice(o)),n.join("");function s(e){n.push(t(e,i,!e))}}function Io(e,t){return e-t}function Do(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],o=[],i=e+t;let s,l=-1,a=0;for(;s=n.exec(i);)r.push(s.index);for(;++l<r.length;)a!==r[l]&&o.push(e.slice(a,r[l])),o.push("\\"),a=r[l];return o.push(e.slice(a)),o.join("")}function Ro(e){const t=e||{},n=t.now||{};let r=t.lineShift||0,o=n.line||1,i=n.column||1;return{move:function(e){const t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return o+=n.length-1,i=1===n.length?i+s.length:1+s.length+r,t},current:function(){return{now:{line:o,column:i},lineShift:r}},shift:function(e){r+=e}}}function Po(e,t){const n=t||{},r={associationId:No,containerPhrasing:Bo,containerFlow:Fo,createTracker:Ro,compilePattern:To,enter:function(e){return r.stack.push(e),function(){r.stack.pop()}},handlers:{...xo},handle:void 0,indentLines:Eo,indexStack:[],join:[...Co],options:{},safe:jo,stack:[],unsafe:[...Mo]};Wr(r,n),r.options.tightDefinitions&&r.join.push(zo),r.handle=function(e,t){const n=t||{};function r(t,...n){let o=r.invalid;const i=r.handlers;if(t&&jr.call(t,e)){const n=String(t[e]);o=jr.call(i,n)?i[n]:r.unknown}if(o)return o.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}("type",{invalid:$o,unknown:Lo,handlers:r.handlers});let o=r.handle(e,void 0,r,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return o&&10!==o.charCodeAt(o.length-1)&&13!==o.charCodeAt(o.length-1)&&(o+="\n"),o}function $o(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function Lo(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function zo(e,t){if("definition"===e.type&&e.type===t.type)return 0}function Bo(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=[];let s,l=-1,a=n.before;r.push(-1);let c=t.createTracker(n);for(;++l<o.length;){const u=o[l];let d;if(r[r.length-1]=l,l+1<o.length){let n=t.handle.handlers[o[l+1].type];n&&n.peek&&(n=n.peek),d=n?n(o[l+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else d=n.after;i.length>0&&("\r"===a||"\n"===a)&&"html"===u.type&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),a=" ",c=t.createTracker(n),c.move(i.join("")));let h=t.handle(u,e,t,{...c.current(),after:d,before:a});s&&s===h.slice(0,1)&&(h=Xr(s.charCodeAt(0))+h.slice(1));const p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,p&&(i.length>0&&p.before&&a===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+Xr(a.charCodeAt(0))),p.after&&(s=d)),c.move(h),i.push(h),a=h.slice(-1)}return r.pop(),i.join("")}(e,this,t)}function Fo(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=t.createTracker(n),s=[];let l=-1;for(r.push(-1);++l<o.length;){const n=o[l];r[r.length-1]=l,s.push(i.move(t.handle(n,e,t,{before:"\n",after:"\n",...i.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),l<o.length-1&&s.push(i.move(Oo(n,o[l+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function jo(e,t){return function(e,t,n){const r=(n.before||"")+(t||"")+(n.after||""),o=[],i=[],s={};let l=-1;for(;++l<e.unsafe.length;){const t=e.unsafe[l];if(!qr(e.stack,t))continue;const n=e.compilePattern(t);let i;for(;i=n.exec(r);){const e="before"in t||Boolean(t.atBreak),n="after"in t,r=i.index+(e?i[1].length:0);o.includes(r)?(s[r].before&&!e&&(s[r].before=!1),s[r].after&&!n&&(s[r].after=!1)):(o.push(r),s[r]={before:e,after:n})}}o.sort(Io);let a=n.before?n.before.length:0;const c=r.length-(n.after?n.after.length:0);for(l=-1;++l<o.length;){const e=o[l];e<a||e>=c||e+1<c&&o[l+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||o[l-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(a!==e&&i.push(Do(r.slice(a,e),"\\")),a=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(i.push(Xr(r.charCodeAt(e))),a++):i.push("\\"))}return i.push(Do(r.slice(a,c),n.after)),i.join("")}(this,e,t)}function _o(e){const t=this;t.compiler=function(n){return Po(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function Wo(e){if(e)throw e}var Vo=n(411);function Ho(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}class qo extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",o={},i=!1;if(t&&(o="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!o.cause&&e&&(i=!0,r=e.message,o.cause=e),!o.ruleId&&!o.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?o.ruleId=n:(o.source=n.slice(0,e),o.ruleId=n.slice(e+1))}if(!o.place&&o.ancestors&&o.ancestors){const e=o.ancestors[o.ancestors.length-1];e&&(o.place=e.position)}const s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=s?s.line:void 0,this.name=Ar(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&"string"==typeof o.cause.stack?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}qo.prototype.file="",qo.prototype.name="",qo.prototype.reason="",qo.prototype.message="",qo.prototype.stack="",qo.prototype.column=void 0,qo.prototype.line=void 0,qo.prototype.ancestors=void 0,qo.prototype.cause=void 0,qo.prototype.fatal=void 0,qo.prototype.place=void 0,qo.prototype.ruleId=void 0,qo.prototype.source=void 0;const Ko=function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');Xo(e);let n,r=0,o=-1,i=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else o<0&&(n=!0,o=i+1);return o<0?"":e.slice(r,o)}if(t===e)return"";let s=-1,l=t.length-1;for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else s<0&&(n=!0,s=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(o=i):(l=-1,o=s));return r===o?o=s:o<0&&(o=e.length),e.slice(r,o)},Uo=function(e){if(Xo(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},Jo=function(e){Xo(e);let t,n=e.length,r=-1,o=0,i=-1,s=0;for(;n--;){const l=e.codePointAt(n);if(47!==l)r<0&&(t=!0,r=n+1),46===l?i<0?i=n:1!==s&&(s=1):i>-1&&(s=-1);else if(t){o=n+1;break}}return i<0||r<0||0===s||1===s&&i===r-1&&i===o+1?"":e.slice(i,r)},Yo=function(...e){let t,n=-1;for(;++n<e.length;)Xo(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){Xo(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,o="",i=0,s=-1,l=0,a=-1;for(;++a<=e.length;){if(a<e.length)n=e.codePointAt(a);else{if(47===n)break;n=47}if(47===n){if(s===a-1||1===l);else if(s!==a-1&&2===l){if(o.length<2||2!==i||46!==o.codePointAt(o.length-1)||46!==o.codePointAt(o.length-2))if(o.length>2){if(r=o.lastIndexOf("/"),r!==o.length-1){r<0?(o="",i=0):(o=o.slice(0,r),i=o.length-1-o.lastIndexOf("/")),s=a,l=0;continue}}else if(o.length>0){o="",i=0,s=a,l=0;continue}t&&(o=o.length>0?o+"/..":"..",i=2)}else o.length>0?o+="/"+e.slice(s+1,a):o=e.slice(s+1,a),i=a-s-1;s=a,l=0}else 46===n&&l>-1?l++:l=-1}return o}(e,!t);return 0!==n.length||t||(n="."),n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/"),t?"/"+n:n}(t)},Go="/";function Xo(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Zo=function(){return"/"};function Qo(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}const ei=["history","path","basename","stem","extname","dirname"];class ti{constructor(e){let t;t=e?Qo(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":Zo(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<ei.length;){const e=ei[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)ei.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?Ko(this.path):void 0}set basename(e){ri(e,"basename"),ni(e,"basename"),this.path=Yo(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?Uo(this.path):void 0}set dirname(e){oi(this.basename,"dirname"),this.path=Yo(e||"",this.basename)}get extname(){return"string"==typeof this.path?Jo(this.path):void 0}set extname(e){if(ni(e,"extname"),oi(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Yo(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Qo(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!Qo(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),ri(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?Ko(this.path,this.extname):void 0}set stem(e){ri(e,"stem"),ni(e,"stem"),this.path=Yo(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new qo(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function ni(e,t){if(e&&e.includes(Go))throw new Error("`"+t+"` cannot be a path: did not expect `"+Go+"`")}function ri(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function oi(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const ii=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},si={}.hasOwnProperty;class li extends ii{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function o(i,...s){const l=e[++n];let a=-1;if(i)r(i);else{for(;++a<t.length;)null!==s[a]&&void 0!==s[a]||(s[a]=t[a]);t=s,l?function(e,t){let n;return function(...t){const i=e.length>t.length;let s;i&&t.push(r);try{s=e.apply(this,t)}catch(e){if(i&&n)throw e;return r(e)}i||(s&&s.then&&"function"==typeof s.then?s.then(o,r):s instanceof Error?r(s):o(s))};function r(e,...r){n||(n=!0,t(e,...r))}function o(e){r(null,e)}}(l,o)(...s):r(null,...s)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){const e=new li;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(Vo(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(di("data",this.frozen),this.namespace[e]=t,this):si.call(this.namespace,e)&&this.namespace[e]||void 0:e?(di("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=fi(e),n=this.parser||this.Parser;return ci("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),ci("process",this.parser||this.Parser),ui("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,o){const i=fi(e),s=n.parse(i);function l(e,n){e||!n?o(e):r?r(n):t(void 0,n)}n.run(s,i,(function(e,t,r){if(e||!t||!r)return l(e);const o=t,i=n.stringify(o,r);var s;"string"==typeof(s=i)||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(s)?r.value=i:r.result=i,l(e,r)}))}}processSync(e){let t,n=!1;return this.freeze(),ci("processSync",this.parser||this.Parser),ui("processSync",this.compiler||this.Compiler),this.process(e,(function(e,r){n=!0,Wo(e),t=r})),pi("processSync","process",n),t}run(e,t,n){hi(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?o(void 0,n):new Promise(o);function o(o,i){const s=fi(t);r.run(e,s,(function(t,r,s){const l=r||e;t?i(t):o?o(l):n(void 0,l,s)}))}}runSync(e,t){let n,r=!1;return this.run(e,t,(function(e,t){Wo(e),n=t,r=!0})),pi("runSync","run",r),n}stringify(e,t){this.freeze();const n=fi(t),r=this.compiler||this.Compiler;return ui("stringify",r),hi(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(di("use",this.frozen),null==e);else if("function"==typeof e)l(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?s(e):i(e)}return this;function o(e){if("function"==typeof e)l(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;l(t,n)}else i(e)}}function i(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(e.plugins),e.settings&&(r.settings=Vo(!0,r.settings,e.settings))}function s(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;)o(e[t])}}function l(e,t){let r=-1,o=-1;for(;++r<n.length;)if(n[r][0]===e){o=r;break}if(-1===o)n.push([e,...t]);else if(t.length>0){let[r,...i]=t;const s=n[o][1];Ho(s)&&Ho(r)&&(r=Vo(!0,s,r)),n[o]=[e,r,...i]}}}}const ai=(new li).freeze();function ci(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function ui(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function di(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function hi(e){if(!Ho(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function pi(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function fi(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new ti(e)}var mi,gi,yi,wi,ki,vi,bi,xi=e=>{throw TypeError(e)},Ci=(e,t,n)=>t.has(e)||xi("Cannot "+n),Si=(e,t,n)=>(Ci(e,t,"read from private field"),n?n.call(e):t.get(e)),Mi=(e,t,n)=>t.has(e)?xi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ni=(e,t,n,r)=>(Ci(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Ti{}class Oi{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{var t;null==(t=this.top())||t.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw z();return e}}}class Ai extends Ti{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,n){return new Ai(e,t,n)}}const Ei=class extends Oi{constructor(e){super(),Mi(this,mi),Mi(this,gi),Mi(this,yi),Mi(this,wi),Mi(this,ki),Mi(this,vi),Mi(this,bi),Ni(this,mi,Le.none),Ni(this,gi,(e=>e.isText)),Ni(this,yi,((e,t)=>{if(Si(this,gi).call(this,e)&&Si(this,gi).call(this,t)&&Le.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)})),Ni(this,wi,(e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find((t=>t.spec.parseMarkdown.match(e)));if(!t)throw B(e);return t})),Ni(this,ki,(e=>{const t=Si(this,wi).call(this,e);t.spec.parseMarkdown.runner(this,e,t)})),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Ai.create(e,[],t)),this),Ni(this,vi,(()=>{Ni(this,mi,Le.none);const e=this.close();return Si(this,bi).call(this,e.type,e.attrs,e.content)})),this.closeNode=()=>(Si(this,vi).call(this),this),Ni(this,bi,((e,t,n)=>{const r=e.createAndFill(t,n,Si(this,mi));if(!r)throw L(e,t,n);return this.push(r),r})),this.addNode=(e,t,n)=>(Si(this,bi).call(this,e,t,n),this),this.openMark=(e,t)=>{const n=e.create(t);return Ni(this,mi,n.addToSet(Si(this,mi))),this},this.closeMark=e=>(Ni(this,mi,e.removeFromSet(Si(this,mi))),this),this.addText=e=>{const t=this.top();if(!t)throw z();const n=t.pop(),r=this.schema.text(e,Si(this,mi));if(!n)return t.push(r),this;const o=Si(this,yi).call(this,n,r);return o?(t.push(o),this):(t.push(n,r),this)},this.build=()=>{let e;do{e=Si(this,vi).call(this)}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach((e=>Si(this,ki).call(this,e))),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{const n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}};mi=new WeakMap,gi=new WeakMap,yi=new WeakMap,wi=new WeakMap,ki=new WeakMap,vi=new WeakMap,bi=new WeakMap,Ei.create=(e,t)=>{const n=new Ei(e);return e=>(n.run(t,e),n.toDoc())};let Ii=Ei;const Di=class extends Ti{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>{var e;return null==(e=this.children)?void 0:e.pop()}}};Di.create=(e,t,n,r={})=>new Di(e,t,n,r);let Ri=Di;var Pi,$i,Li,zi,Bi,Fi,ji,_i,Wi,Vi,Hi,qi,Ki;const Ui=class extends Oi{constructor(e){super(),Mi(this,Pi),Mi(this,$i),Mi(this,Li),Mi(this,zi),Mi(this,Bi),Mi(this,Fi),Mi(this,ji),Mi(this,_i),Mi(this,Wi),Mi(this,Vi),Mi(this,Hi),Mi(this,qi),Mi(this,Ki),Ni(this,Pi,Le.none),Ni(this,$i,(e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find((t=>t.spec.toMarkdown.match(e)));if(!t)throw F(e.type);return t})),Ni(this,Li,(e=>Si(this,$i).call(this,e).spec.toMarkdown.runner(this,e))),Ni(this,zi,((e,t)=>Si(this,$i).call(this,e).spec.toMarkdown.runner(this,e,t))),Ni(this,Bi,(e=>{const{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort(((e,t)=>n(e)-n(t))).every((t=>!Si(this,zi).call(this,t,e)))&&Si(this,Li).call(this,e),t.forEach((e=>Si(this,Ki).call(this,e)))})),Ni(this,Fi,((e,t)=>{var n;if(e.type===t||1!==(null==(n=e.children)?void 0:n.length))return e;const r=e=>{var n;if(e.type===t)return e;if(1!==(null==(n=e.children)?void 0:n.length))return null;const[o]=e.children;return o?r(o):null},o=r(e);if(!o)return e;const i=o.children?[...o.children]:void 0,s={...e,children:i};return s.children=i,o.children=[s],o})),Ni(this,ji,(e=>{const{children:t}=e;return t&&(e.children=t.reduce(((e,t,n)=>{if(0===n)return[t];const r=e.at(-1);if(r&&r.isMark&&t.isMark){t=Si(this,Fi).call(this,t,r.type);const{children:n,...o}=t,{children:i,...s}=r;if(t.type===r.type&&n&&i&&JSON.stringify(o)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(Si(this,ji).call(this,t))}}return e.concat(t)}),[])),e})),Ni(this,_i,(e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t})),this.openNode=(e,t,n)=>(this.open(Ri.create(e,void 0,t,n)),this),Ni(this,Wi,((e,t)=>{let n="",r="";const o=e.children;let i=-1,s=-1;if(o){(e=>{e&&e.forEach(((e,t)=>{"text"===e.type&&e.value&&(i<0&&(i=t),s=t)}))})(o);const e=null==o?void 0:o[s],t=null==o?void 0:o[i];e&&e.value.endsWith(" ")&&(r=e.value.match(/ +$/)[0],e.value=e.value.trimEnd()),t&&t.value.startsWith(" ")&&(n=t.value.match(/^ +/)[0],t.value=t.value.trimStart())}n.length&&Si(this,Hi).call(this,"text",void 0,n);const l=t();return r.length&&Si(this,Hi).call(this,"text",void 0,r),l})),Ni(this,Vi,((e=!1)=>{const t=this.close(),n=()=>Si(this,Hi).call(this,t.type,t.children,t.value,t.props);return e?Si(this,Wi).call(this,t,n):n()})),this.closeNode=()=>(Si(this,Vi).call(this),this),Ni(this,Hi,((e,t,n,r)=>{const o=Ri.create(e,t,n,r),i=Si(this,ji).call(this,Si(this,_i).call(this,o));return this.push(i),i})),this.addNode=(e,t,n,r)=>(Si(this,Hi).call(this,e,t,n,r),this),Ni(this,qi,((e,t,n,r)=>e.isInSet(Si(this,Pi))?this:(Ni(this,Pi,e.addToSet(Si(this,Pi))),this.openNode(t,n,{...r,isMark:!0})))),Ni(this,Ki,(e=>{e.isInSet(Si(this,Pi))&&(Ni(this,Pi,e.type.removeFromSet(Si(this,Pi))),Si(this,Vi).call(this,!0))})),this.withMark=(e,t,n,r)=>(Si(this,qi).call(this,e,t,n,r),this),this.closeMark=e=>(Si(this,Ki).call(this,e),this),this.build=()=>{let e=null;do{e=Si(this,Vi).call(this)}while(this.size());return e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach((e=>{Si(this,Bi).call(this,e)})),this):(Si(this,Bi).call(this,e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}};Pi=new WeakMap,$i=new WeakMap,Li=new WeakMap,zi=new WeakMap,Bi=new WeakMap,Fi=new WeakMap,ji=new WeakMap,_i=new WeakMap,Wi=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,qi=new WeakMap,Ki=new WeakMap,Ui.create=(e,t)=>{const n=new Ui(e);return e=>(n.run(e),n.toString(t))};let Ji=Ui;const Yi=Math.pow(2,16);function Gi(e,t){return e+t*Yi}function Xi(e){return 65535&e}class Zi{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Qi{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Qi.empty)return Qi.empty}recover(e){let t=0,n=Xi(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Yi}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[s+o],c=this.ranges[s+i],u=l+a;if(e<=u){let o=l+r+((a?e==l?-1:e==u?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?l:u)?null:Gi(s/3,e-l),d=e==l?2:e==u?1:4;return(t<0?e!=l:e!=u)&&(d|=8),new Zi(o,d,i)}r+=c-a}return n?e+r:new Zi(e+r,0,null)}touches(e,t){let n=0,r=Xi(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+o];if(e<=s+l&&t==3*r)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),l=i+(this.inverted?0:o),a=this.ranges[r+t],c=this.ranges[r+n];e(s,s+a,l,l+c),o+=c-a}}invert(){return new Qi(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?Qi.empty:new Qi(e<0?[0,-e,0]:[0,0,e])}}Qi.empty=new Qi([]);class es{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new es(this.maps,this.mirror,e,t)}copy(){return new es(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new es;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this.maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new Zi(e,r,null)}}const ts=Object.create(null);class ns{getMap(){return Qi.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ts[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ts)throw new RangeError("Duplicate use of step JSON ID "+e);return ts[e]=t,t.prototype.jsonID=e,t}}class rs{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new rs(e,null)}static fail(e){return new rs(null,e)}static fromReplace(e,t,n,r){try{return rs.ok(e.replace(t,n,r))}catch(e){if(e instanceof ze)return rs.fail(e.message);throw e}}}function is(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(is(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return De.fromArray(r)}class ss extends ns{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new Be(is(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),r),t.openStart,t.openEnd);return rs.fromReplace(e,this.from,this.to,o)}invert(){return new ls(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ss(t.pos,n.pos,this.mark)}merge(e){return e instanceof ss&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ss(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ss(t.from,t.to,e.markFromJSON(t.mark))}}ns.jsonID("addMark",ss);class ls extends ns{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Be(is(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return rs.fromReplace(e,this.from,this.to,n)}invert(){return new ss(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ls(t.pos,n.pos,this.mark)}merge(e){return e instanceof ls&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ls(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ls(t.from,t.to,e.markFromJSON(t.mark))}}ns.jsonID("removeMark",ls);class as extends ns{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return rs.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return rs.fromReplace(e,this.pos,this.pos+1,new Be(De.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new as(this.pos,t.marks[n]);return new as(this.pos,this.mark)}}return new cs(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new as(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new as(t.pos,e.markFromJSON(t.mark))}}ns.jsonID("addNodeMark",as);class cs extends ns{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return rs.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return rs.fromReplace(e,this.pos,this.pos+1,new Be(De.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new as(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new cs(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new cs(t.pos,e.markFromJSON(t.mark))}}ns.jsonID("removeNodeMark",cs);class us extends ns{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&hs(e,this.from,this.to)?rs.fail("Structure replace would overwrite content"):rs.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Qi([this.from,this.to-this.from,this.slice.size])}invert(e){return new us(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new us(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof us)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Be.empty:new Be(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new us(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Be.empty:new Be(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new us(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new us(t.from,t.to,Be.fromJSON(e,t.slice),!!t.structure)}}ns.jsonID("replace",us);class ds extends ns{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(hs(e,this.from,this.gapFrom)||hs(e,this.gapTo,this.to)))return rs.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return rs.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?rs.fromReplace(e,this.from,this.to,n):rs.fail("Content does not fit in gap")}getMap(){return new Qi([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ds(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new ds(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ds(t.from,t.to,t.gapFrom,t.gapTo,Be.fromJSON(e,t.slice),t.insert,!!t.structure)}}function hs(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function ps(e,t,n,r=n.contentMatch,o=!0){let i=e.doc.nodeAt(t),s=[],l=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),c=l+a.nodeSize,u=r.matchType(a.type);if(u){r=u;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new ls(l,c,a.marks[t]));if(o&&a.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(a.text);)t||(t=new Be(De.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new us(l+e.index,l+e.index+e[0].length,t))}}else s.push(new us(l,c,Be.empty));l=c}if(!r.validEnd){let t=r.fillBefore(De.empty,!0);e.replace(l,l,new Be(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function fs(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function ms(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!fs(r,o,i))break}return null}function gs(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;l&&e<o;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(r,t);return i?o.map(ys).concat({type:t,attrs:n}).concat(i.map(ys)):null}function ys(e){return{type:e,attrs:null}}function ws(e,t,n,r){t.forEach(((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}}))}function ks(e,t,n,r){t.forEach(((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}}))}function vs(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=r&&r[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function bs(e,t){let n=e.resolve(t),r=n.index();return xs(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function xs(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function Cs(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let o,i,s=r.index(e);if(e==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(e+1),s++,i=r.node(e).maybeChild(s)):(o=r.node(e).maybeChild(s-1),i=r.node(e+1)),o&&!o.isTextblock&&xs(o,i)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function Ss(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function Ms(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),l=!1;if(1==e)l=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Ns(e,t,n=t,r=Be.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Ts(o,i,r)?new us(t,n,r):new Os(o,i,r).fit()}function Ts(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ns.jsonID("replaceAround",ds);class Os{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=De.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=De.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let l=new Be(o,i,s);return e>-1?new ds(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new us(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Is(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:l}=this.frontier[e],a=null;if(1==t&&(o?l.matchType(o.type)||(a=l.fillBefore(De.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:a};if(2==t&&o&&(i=l.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&l.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Is(e,t);return!(!r.childCount||r.firstChild.isLeaf||(this.unplaced=new Be(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),0))}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Is(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Be(As(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Be(As(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let i=this.unplaced,s=n?n.content:i.content,l=i.openStart-e,a=0,c=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));u=u.matchFragment(r)}let h=s.size+e-(i.content.size-i.openEnd);for(;a<s.childCount;){let e=s.child(a),t=u.matchType(e.type);if(!t)break;a++,(a>1||0==l||e.content.size)&&(u=t,c.push(Ds(e.mark(d.allowedMarks(e.marks)),1==a?l:0,a==s.childCount?h:-1)))}let p=a==s.childCount;p||(h=-1),this.placed=Es(this.placed,t,De.from(c)),this.frontier[t].match=u,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Be.empty:new Be(As(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Be(As(i.content,e,a),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Rs(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Rs(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Rs(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Es(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Es(this.placed,this.depth,De.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(De.empty,!0);e.childCount&&(this.placed=Es(this.placed,this.frontier.length,e))}}function As(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(As(e.firstChild.content,t-1,n)))}function Es(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Es(e.lastChild.content,t-1,n)))}function Is(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ds(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ds(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(De.empty,!0)))),e.copy(r)}function Rs(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?l:null}function Ps(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(Ps(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(De.empty,!0))}return e}function $s(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class Ls extends ns{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return rs.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return rs.fromReplace(e,this.pos,this.pos+1,new Be(De.from(r),0,t.isLeaf?0:1))}getMap(){return Qi.empty}invert(e){return new Ls(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ls(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ls(t.pos,t.attr,t.value)}}ns.jsonID("attr",Ls);class zs extends ns{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return rs.ok(n)}getMap(){return Qi.empty}invert(e){return new zs(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new zs(t.attr,t.value)}}ns.jsonID("docAttr",zs);let Bs=class extends Error{};Bs=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Bs.prototype=Object.create(Error.prototype),Bs.prototype.constructor=Bs,Bs.prototype.name="TransformError";class Fs{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new es}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Bs(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Be.empty){let r=Ns(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Be(De.from(n),0,0))}delete(e,t){return this.replace(e,t,Be.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Ts(o,i,r))return e.step(new us(t,n,r));let s=$s(o,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:o.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=c[e],n=(d=t.type).spec.defining||d.spec.definingForContent;if(n&&!t.sameMarkup(o.node(Math.abs(l)-1)))u=e;else if(n||!t.type.isTextblock)break}var d;for(let t=r.openStart;t>=0;t--){let l=(t+u+1)%(r.openStart+1),d=c[l];if(d)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],u=!0;c<0&&(u=!1,c=-c);let h=o.node(c-1),p=o.index(c-1);if(h.canReplaceWith(p,p,d.type,d.marks))return e.replace(o.before(c),u?i.after(c):n,new Be(Ps(r.content,0,r.openStart,l),l,r.openEnd))}}let h=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,r),!(e.steps.length>h));l--){let e=s[l];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=Ss(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Be(De.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n),i=$s(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=De.empty,d=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=De.from(r.node(e).copy(u)),d++):a--;let h=De.empty,p=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,h=De.from(o.node(e).copy(h)),p++):c++;e.step(new ds(a,c,s,l,new Be(u.append(h),d,p),u.size-d,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let l=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);ks(e,r.node(),r.before(),l)}s.inlineContent&&ps(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new us(c,a.map(t+n,-1),Be.empty,!0)),!0===r){let t=e.doc.resolve(c);ws(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=De.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=De.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new ds(o,i,o,i,new Be(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{let s="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&ks(e,t,n,i),ps(e,e.mapping.slice(i).map(n,1),r,void 0,null===o);let l=e.mapping.slice(i),a=l.map(n,1),c=l.map(n+t.nodeSize,1);return e.step(new ds(a,c,a+1,c-1,new Be(De.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===o&&ws(e,t,n,i),!1}}))}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ds(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Be(De.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Ls(e,t,n)),this}setDocAttribute(e,t){return this.step(new zs(e,t)),this}addNodeMark(e,t){return this.step(new as(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Le)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new cs(e,t)),this}split(e,t=1,n){return function(e,t,n=1,r){let o=e.doc.resolve(t),i=De.empty,s=De.empty;for(let e=o.depth,t=o.depth-n,l=n-1;e>t;e--,l--){i=De.from(o.node(e).copy(i));let t=r&&r[l];s=De.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new us(t,t,new Be(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],l=[];e.doc.nodesBetween(t,n,((e,a,c)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,t),d=Math.min(a+e.nodeSize,n),h=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(u[e])?o.to=d:s.push(o=new ls(c,d,u[e])));i&&i.to==c?i.to=d:l.push(i=new ss(c,d,r))}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(r instanceof vt){let t,n=e.marks;for(;t=r.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(l=[r]):l=e.marks;if(l&&l.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&a.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:a,from:Math.max(s,t),to:r,step:i})}}})),o.forEach((t=>e.step(new ls(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return ps(this,e,t,n),this}}const js=Object.create(null);class _s{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Ws(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Be.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(o);e.replaceRange(c.map(l.pos),c.map(a.pos),s?Be.empty:t),0==s&&Zs(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);o?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),Zs(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new qs(e):Xs(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?Xs(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Xs(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ys(e.node(0))}static atStart(e){return Xs(e,e,0,0,1)||new Ys(e)}static atEnd(e){return Xs(e,e,e.content.size,e.childCount,-1)||new Ys(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=js[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in js)throw new RangeError("Duplicate use of selection JSON ID "+e);return js[e]=t,t.prototype.jsonID=e,t}getBookmark(){return qs.between(this.$anchor,this.$head).getBookmark()}}_s.prototype.visible=!0;class Ws{constructor(e,t){this.$from=e,this.$to=t}}let Vs=!1;function Hs(e){Vs||e.parent.inlineContent||(Vs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class qs extends _s{constructor(e,t=e){Hs(e),Hs(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return _s.near(n);let r=e.resolve(t.map(this.anchor));return new qs(r.parent.inlineContent?r:n,n)}replace(e,t=Be.empty){if(super.replace(e,t),t==Be.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof qs&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ks(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new qs(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=_s.findFrom(t,n,!0)||_s.findFrom(t,-n,!0);if(!e)return _s.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(_s.findFrom(e,-n,!0)||_s.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new qs(e,t)}}_s.jsonID("text",qs);class Ks{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ks(e.map(this.anchor),e.map(this.head))}resolve(e){return qs.between(e.resolve(this.anchor),e.resolve(this.head))}}class Us extends _s{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?_s.near(o):new Us(o)}content(){return new Be(De.from(this.node),0,0)}eq(e){return e instanceof Us&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Js(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Us(e.resolve(t.anchor))}static create(e,t){return new Us(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Us.prototype.visible=!1,_s.jsonID("node",Us);class Js{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Ks(n,n):new Js(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Us.isSelectable(n)?new Us(t):_s.near(t)}}class Ys extends _s{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Be.empty){if(t==Be.empty){e.delete(0,e.doc.content.size);let t=_s.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ys(e)}map(e){return new Ys(e)}eq(e){return e instanceof Ys}getBookmark(){return Gs}}_s.jsonID("all",Ys);const Gs={map(){return this},resolve:e=>new Ys(e)};function Xs(e,t,n,r,o,i=!1){if(t.inlineContent)return qs.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Us.isSelectable(r))return Us.create(e,n-(o<0?r.nodeSize:0))}else{let t=Xs(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Zs(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof us||i instanceof ds)&&(e.mapping.maps[r].forEach(((e,t,n,r)=>{null==o&&(o=r)})),e.setSelection(_s.near(e.doc.resolve(o),n)))}class Qs extends Fs{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Le.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Le.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(_s.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function el(e,t){return t&&e?e.bind(t):e}class tl{constructor(e,t,n){this.name=e,this.init=el(t.init,n),this.apply=el(t.apply,n)}}const nl=[new tl("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new tl("selection",{init:(e,t)=>e.selection||_s.atStart(t.doc),apply:e=>e.selection}),new tl("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new tl("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class rl{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=nl.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new tl(e.key,e.spec.state,e))}))}}class ol{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=r?r[i].n:0,a=r?r[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ol(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Qs(this)}static create(e){let t=new rl(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new ol(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new rl(this.schema,e.plugins),n=t.fields,r=new ol(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new rl(e.schema,e.plugins),o=new ol(r);return r.fields.forEach((r=>{if("doc"==r.name)o.doc=nt.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=_s.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=l.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}})),o}}function il(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=il(o,t,{})),n[r]=o}return n}class sl{constructor(e){this.spec=e,this.props={},e.props&&il(e.props,this,this.props),this.key=e.key?e.key.key:al("plugin")}getState(e){return e[this.key]}}const ll=Object.create(null);function al(e){return e in ll?e+"$"+ ++ll[e]:(ll[e]=0,e+"$")}class cl{constructor(e="key"){this.key=al(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}class ul{constructor(e,t,n={}){this.match=e,this.match=e,this.handler="string"==typeof t?function(e){return function(t,n,r,o){let i=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);i+=n[0].slice(e+n[1].length);let t=(r+=e)-o;t>0&&(i=n[0].slice(e-t,e)+i,r=o)}return t.tr.insertText(i,r,o)}}(t):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1}}const dl=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function hl(e,t,n=null,r){return new ul(e,((e,o,i,s)=>{let l=n instanceof Function?n(o):n,a=e.tr.delete(i,s),c=a.doc.resolve(i).blockRange(),u=c&&gs(c,t,l);if(!u)return null;a.wrap(c,u);let d=a.doc.resolve(i-1).nodeBefore;return d&&d.type==t&&bs(a.doc,i-1)&&(!r||r(o,d))&&a.join(i-1),a}))}function pl(e,t,n=null){return new ul(e,((e,r,o,i)=>{let s=e.doc.resolve(o),l=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,l):null}))}new ul(/--$/,"—"),new ul(/\.\.\.$/,"…"),new ul(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new ul(/"$/,"”"),new ul(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new ul(/'$/,"’");const fl="undefined"!=typeof navigator?navigator:null,ml="undefined"!=typeof document?document:null,gl=fl&&fl.userAgent||"",yl=/Edge\/(\d+)/.exec(gl),wl=/MSIE \d/.exec(gl),kl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(gl),vl=!!(wl||kl||yl),bl=wl?document.documentMode:kl?+kl[1]:yl?+yl[1]:0,xl=!vl&&/gecko\/(\d+)/i.test(gl),Cl=xl&&+(/Firefox\/(\d+)/.exec(gl)||[0,0])[1],Sl=!vl&&/Chrome\/(\d+)/.exec(gl),Ml=!!Sl,Nl=Sl?+Sl[1]:0,Tl=!vl&&!!fl&&/Apple Computer/.test(fl.vendor),Ol=Tl&&(/Mobile\/\w+/.test(gl)||!!fl&&fl.maxTouchPoints>2),Al=Ol||!!fl&&/Mac/.test(fl.platform),El=/Android \d/.test(gl),Il=!!ml&&"webkitFontSmoothing"in ml.documentElement.style,Dl=Il?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var Rl=Object.freeze({__proto__:null,android:El,chrome:Ml,chrome_version:Nl,gecko:xl,gecko_version:Cl,ie:vl,ie_version:bl,ios:Ol,mac:Al,safari:Tl,webkit:Il,webkit_version:Dl});function Pl(e,t,n,r,o,i){var s;if(e.composing)return!1;const l=e.state,a=l.doc.resolve(t);if(a.parent.type.spec.code)return!1;const c=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a=0;a<o.length;a++){const u=o[a].match.exec(c),d=u&&u[0]&&o[a].handler(l,u,t-(u[0].length-r.length),n);if(d)return!1!==(null==(s=o[a])?void 0:s.undoable)&&d.setMeta(i,{transform:d,from:t,to:n,text:r}),e.dispatch(d),!0}return!1}const $l=new cl("MILKDOWN_CUSTOM_INPUTRULES");function Ll({rules:e}){const t=new sl({key:$l,isInputRules:!0,state:{init:()=>null,apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>Pl(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout((()=>{const{$cursor:r}=n.state.selection;r&&Pl(n,r.pos,r.pos,"",e,t)})),!1)},handleKeyDown(n,r){if("Enter"!==r.key)return!1;const{$cursor:o}=n.state.selection;return!!o&&Pl(n,o.pos,o.pos,"\n",e,t)}}});return t}function zl(e,t,n={}){return new ul(e,((e,r,o,i)=>{var s,l,a,c;const{tr:u}=e;let d=r[r.length-1],h=r[0],p=[],f=i;const m={group:d,fullMatch:h,start:o,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:d,fullMatch:h,start:o,end:i}=m),null===h)return null;if(""===(null==d?void 0:d.trim()))return null;if(d){const e=h.search(/\S/),s=o+h.indexOf(d),m=s+d.length;p=null!=(l=u.storedMarks)?l:[],m<i&&u.delete(m,i),s>o&&u.delete(o+e,s),f=o+e+d.length;const g=null==(a=n.getAttr)?void 0:a.call(n,r);u.addMark(o,f,t.create(g)),u.setStoredMarks(p),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:o,end:i,tr:u})}return u}))}function Bl(e,t,n={}){return new ul(e,((e,r,o,i)=>{var s,l,a;const{tr:c}=e;let u=r[1],d=r[0];const h={group:u,fullMatch:d,start:o,end:i},p=null==(s=n.updateCaptured)?void 0:s.call(n,h);if(Object.assign(h,p),({group:u,fullMatch:d,start:o,end:i}=h),null===d)return null;if(!u||""===u.trim())return null;const f=null==(l=n.getAttr)?void 0:l.call(n,r),m=t.createAndFill(f);return m&&(c.replaceRangeWith(t.isBlock?c.doc.resolve(o).before():o,i,m),null==(a=n.beforeDispatch)||a.call(n,{match:[d,null!=u?u:""],start:o,end:i,tr:c})),c}))}var Fl=Object.defineProperty,jl=Object.defineProperties,_l=Object.getOwnPropertyDescriptors,Wl=Object.getOwnPropertySymbols,Vl=Object.prototype.hasOwnProperty,Hl=Object.prototype.propertyIsEnumerable,ql=(e,t,n)=>t in e?Fl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kl=(e,t)=>{for(var n in t)Vl.call(t,n)&&ql(e,n,t[n]);if(Wl)for(var n of Wl(t))Hl.call(t,n)&&ql(e,n,t[n]);return e},Ul=(e,t)=>jl(e,_l(t));function Jl(e,t,n){const r=e.state,{from:o}=r.selection,{node:i}=e.domAtPos(o),s=i instanceof Text?i.parentElement:i;if(!(s instanceof HTMLElement))throw _(s);const l=s.getBoundingClientRect(),a=t.getBoundingClientRect(),c=t.parentElement;if(!c)throw _(c);const u=c.getBoundingClientRect(),[d,h]=n(l,a,u);t.style.top=`${d}px`,t.style.left=`${h}px`}function Yl(e,t,n){const r=e.state,{from:o,to:i}=r.selection,s=e.coordsAtPos(o),l=e.coordsAtPos(i),a=t.getBoundingClientRect(),c=t.parentElement;if(!c)throw new I(E.missingRootElement,"Missing root element, milkdown cannot find root element of the editor.");const u=c.getBoundingClientRect(),[d,h]=n(s,l,a,u);t.style.top=`${d}px`,t.style.left=`${h}px`}function Gl(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Xl(e,t,n){const r=e.state.doc.content.size,o=Gl(t,0,r),i=Gl(n,0,r),s=e.coordsAtPos(o),l=e.coordsAtPos(i,-1),a=Math.min(s.top,l.top),c=Math.max(s.bottom,l.bottom),u=Math.min(s.left,l.left),d=Math.max(s.right,l.right),h={top:a,bottom:c,left:u,right:d,width:d-u,height:c-a,x:u,y:a};return Ul(Kl({},h),{toJSON:()=>h})}function Zl(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function Ql(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}function ea(e,t=!0){const n=[];return e.descendants(((e,r)=>{if(n.push({node:e,pos:r}),!t)return!1})),n}function ta(e){return(t,n)=>ea(t,n).filter((t=>e(t.node)))}function na(e,t,n){return ta((e=>Boolean(t.isInSet(e.marks))))(e,n)}function ra(e){return t=>{for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{from:t.before(n),to:t.after(n),node:r}}}}function oa(e,t){return ra((e=>e.type===t))(e)}function ia(e,t){const n=t.nodes[e];if(!n)throw j("node",e);return n}function sa(e,t){const n=t.marks[e];if(!n)throw j("mark",e);return n}function la(e){return t=>{for(let n=t.depth;n>0;n--){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}}function aa(e){return t=>la(e)(t.$from)}function ca(e,t){if(!(e instanceof Us))return;const{node:n,$from:r}=e;return Ql(t,n)?{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}:void 0}const ua=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);const da=(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}(e,n);if(!r)return!1;let o=fa(r);if(!o){let n=r.blockRange(),o=n&&ms(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(wa(e,o,t,-1))return!0;if(0==r.parent.content.size&&(ha(i,"end")||Us.isSelectable(i)))for(let n=r.depth;;n--){let s=Ns(e.doc,r.before(n),r.after(n),Be.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ha(i,"end")?_s.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Us.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),0))};function ha(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const pa=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=fa(r)}let s=i&&i.nodeBefore;return!(!s||!Us.isSelectable(s)||(t&&t(e.tr.setSelection(Us.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function fa(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ma(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function ga(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var ya;function wa(e,t,n,r){let o,i,s=t.nodeBefore,l=t.nodeAfter,a=s.type.spec.isolating||l.type.spec.isolating;if(!a&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!bs(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!a&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(l.type))&&i.matchType(o[0]||l.type).validEnd){if(n){let r=t.pos+l.nodeSize,i=De.empty;for(let e=o.length-1;e>=0;e--)i=De.from(o[e].create(null,i));i=De.from(s.copy(i));let a=e.tr.step(new ds(t.pos-1,r,t.pos,r,new Be(i,1,0),o.length,!0)),c=a.doc.resolve(r+2*o.length);c.nodeAfter&&c.nodeAfter.type==s.type&&bs(a.doc,c.pos)&&a.join(c.pos),n(a.scrollIntoView())}return!0}let u=l.type.spec.isolating||r>0&&a?null:_s.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),h=d&&ms(d);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(d,h).scrollIntoView()),!0;if(c&&ha(l,"start",!0)&&ha(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=l,a=1;for(;!i.isTextblock;i=i.firstChild)a++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=De.empty;for(let e=o.length-1;e>=0;e--)r=De.from(o[e].copy(r));n(e.tr.step(new ds(t.pos-o.length,t.pos+l.nodeSize,t.pos+a,t.pos+l.nodeSize-a,new Be(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ka(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(qs.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const va=ka(-1),ba=ka(1);function xa(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&gs(s,e,t);return!!l&&(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0)}}function Ca(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,((r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}}))}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function Sa(e,t=null,n){let r=!1!==(n&&n.removeWhenPresent),o=!1!==(n&&n.enterInlineAtoms);return function(n,i){let{empty:s,$cursor:l,ranges:a}=n.selection;if(s&&!l||!function(e,t,n,r){for(let o=0;o<t.length;o++){let{$from:i,$to:s}=t[o],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,((e,t)=>{if(l||!r&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return!0}return!1}(n.doc,a,e,o))return!1;if(i)if(l)e.isInSet(n.storedMarks||l.marks())?i(n.tr.removeStoredMark(e)):i(n.tr.addStoredMark(e.create(t)));else{let s,l=n.tr;o||(a=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:o}=e[n];r.doc.nodesBetween(r.pos,o.pos,((e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=o.pos)return n+1>r.pos&&t.push(new Ws(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1})),r.pos<o.pos&&t.push(new Ws(r,o))}return t}(a)),s=r?!a.some((t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e))):!a.every((t=>{let n=!1;return l.doc.nodesBetween(t.$from.pos,t.$to.pos,((r,o,i)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!i&&i.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-o),Math.min(r.nodeSize,t.$to.pos-o))))})),!n}));for(let n=0;n<a.length;n++){let{$from:r,$to:o}=a[n];if(s){let n=r.pos,i=o.pos,s=r.nodeAfter,a=o.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,u=a&&a.isText?/\s*$/.exec(a.text)[0].length:0;n+c<i&&(n+=c,i-=u),l.addMark(n,i,e.create(t))}else l.removeMark(r.pos,o.pos,e)}i(l.scrollIntoView())}return!0}}function Ma(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let Na=Ma(ua,da,pa),Ta=Ma(ua,((e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!r)return!1;let o=ma(r);if(!o)return!1;let i=o.nodeAfter;if(wa(e,o,t,1))return!0;if(0==r.parent.content.size&&(ha(i,"start")||Us.isSelectable(i))){let n=Ns(e.doc,r.before(),r.after(),Be.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(ha(i,"start")?_s.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Us.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))}),((e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=ma(r)}let s=i&&i.nodeAfter;return!(!s||!Us.isSelectable(s)||(t&&t(e.tr.setSelection(Us.create(e.doc,i.pos)).scrollIntoView()),0))}));const Oa={Enter:Ma(((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))}),((e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Ys||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=ga(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(qs.create(s.doc,n+1)),t(s.scrollIntoView())}return!0}),((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(vs(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&ms(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)}),((e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Us&&e.selection.node.isBlock)return!(!n.parentOffset||!vs(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let o,i,s=[],l=!1,a=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){l=n.end(e)==n.pos+(n.depth-e),a=n.start(e)==n.pos-(n.depth-e),i=ga(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));let t=ya;s.unshift(t||(l&&i?{type:i}:null)),o=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof qs||e.selection instanceof Ys)&&c.deleteSelection();let u=c.mapping.map(n.pos),d=vs(c.doc,u,s.length,s);if(d||(s[0]=i?{type:i}:null,d=vs(c.doc,u,s.length,s)),c.split(u,s.length,s),!l&&a&&n.node(o).type!=i){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);i&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(o)),i)}return t&&t(c.scrollIntoView()),!0})),"Mod-Enter":(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=ga(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(_s.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},Backspace:Na,"Mod-Backspace":Na,"Shift-Backspace":Na,Delete:Ta,"Mod-Delete":Ta,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Ys(e.doc))),!0)},Aa={"Ctrl-h":Oa.Backspace,"Alt-Backspace":Oa["Mod-Backspace"],"Ctrl-d":Oa.Delete,"Ctrl-Alt-Backspace":Oa["Mod-Delete"],"Alt-Delete":Oa["Mod-Delete"],"Alt-d":Oa["Mod-Delete"],"Ctrl-a":va,"Ctrl-e":ba};for(let e in Oa)Aa[e]=Oa[e];const Ea=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?Aa:Oa;for(var Ia={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Da={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ra="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Pa="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),$a=0;$a<10;$a++)Ia[48+$a]=Ia[96+$a]=String($a);for($a=1;$a<=24;$a++)Ia[$a+111]="F"+$a;for($a=65;$a<=90;$a++)Ia[$a]=String.fromCharCode($a+32),Da[$a]=String.fromCharCode($a);for(var La in Ia)Da.hasOwnProperty(La)||(Da[La]=Ia[La]);const za="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Ba(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);za?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Fa(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function ja(e){return new sl({props:{handleKeyDown:_a(e)}})}function _a(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Ba(n)]=e[n];return t}(e);return function(e,n){let r,o=function(e){var t=!(Ra&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Pa&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Da:Ia)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[Fa(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=t[Fa(o,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=Ia[n.keyCode])&&r!=o){let o=t[Fa(r,n)];if(o&&o(e.state,e.dispatch,e))return!0}}return!1}}const Wa=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Va=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Ha=null;const qa=function(e,t,n){let r=Ha||(Ha=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Ka=function(e,t,n,r){return n&&(Ja(e,t,n,r,-1)||Ja(e,t,n,r,1))},Ua=/^(img|br|input|textarea|hr)$/i;function Ja(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Ya(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Ga(e)||Ua.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Wa(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?Ya(e):0}}}function Ya(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ga(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Xa=function(e){return e.focusNode&&Ka(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Za(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Qa="undefined"!=typeof navigator?navigator:null,ec="undefined"!=typeof document?document:null,tc=Qa&&Qa.userAgent||"",nc=/Edge\/(\d+)/.exec(tc),rc=/MSIE \d/.exec(tc),oc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tc),ic=!!(rc||oc||nc),sc=rc?document.documentMode:oc?+oc[1]:nc?+nc[1]:0,lc=!ic&&/gecko\/(\d+)/i.test(tc);lc&&(/Firefox\/(\d+)/.exec(tc)||[0,0])[1];const ac=!ic&&/Chrome\/(\d+)/.exec(tc),cc=!!ac,uc=ac?+ac[1]:0,dc=!ic&&!!Qa&&/Apple Computer/.test(Qa.vendor),hc=dc&&(/Mobile\/\w+/.test(tc)||!!Qa&&Qa.maxTouchPoints>2),pc=hc||!!Qa&&/Mac/.test(Qa.platform),fc=!!Qa&&/Win/.test(Qa.platform),mc=/Android \d/.test(tc),gc=!!ec&&"webkitFontSmoothing"in ec.documentElement.style,yc=gc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function wc(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function kc(e,t){return"number"==typeof e?e:e[t]}function vc(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function bc(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=Va(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,l=n?wc(i):vc(e),a=0,c=0;if(t.top<l.top+kc(r,"top")?c=-(l.top-t.top+kc(o,"top")):t.bottom>l.bottom-kc(r,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+kc(o,"top")-l.top:t.bottom-l.bottom+kc(o,"bottom")),t.left<l.left+kc(r,"left")?a=-(l.left-t.left+kc(o,"left")):t.right>l.right-kc(r,"right")&&(a=t.right-l.right+kc(o,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function xc(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Va(r));return t}function Cc(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Sc=null;function Mc(e,t){let n,r,o,i,s=2e8,l=0,a=t.top,c=t.top;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(1==u.nodeType)e=u.getClientRects();else{if(3!=u.nodeType)continue;e=qa(u).getClientRects()}for(let h=0;h<e.length;h++){let p=e[h];if(p.top<=a&&p.bottom>=c){a=Math.max(p.bottom,a),c=Math.min(p.top,c);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=u,s=e,r=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==u.nodeType&&e&&(l=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=u,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(l=d+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=Ec(r,1);if(n.top!=n.bottom&&Nc(t,n))return{node:e,offset:o+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:l}:Mc(n,r)}function Nc(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Tc(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(Nc(t,o))return Tc(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function Oc(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ya(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ya(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,l=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Nc(t,n))return null;if(l=Tc(e.dom,t,n),!l)return null}if(dc)for(let e=l;n&&e;e=Va(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(lc&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;gc&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&(!i&&t.left>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=Mc(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Ac(e){return e.top<e.bottom||e.left<e.right}function Ec(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Ac(e))return e}return Array.prototype.find.call(n,Ac)||e.getBoundingClientRect()}const Ic=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Dc(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=gc||lc;if(3==r.nodeType){if(!s||!Ic.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,Rc(Ec(qa(r,e,t),i),i<0)}{let e=Ec(qa(r,o,o),n);if(lc&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Ec(qa(r,o-1,o-1),-1);if(t.top==e.top){let n=Ec(qa(r,o,o+1),-1);if(n.top!=e.top)return Rc(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==Ya(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Pc(e.getBoundingClientRect(),!1)}if(null==i&&o<Ya(r)){let e=r.childNodes[o];if(1==e.nodeType)return Pc(e.getBoundingClientRect(),!0)}return Pc(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==Ya(r))){let e=r.childNodes[o-1],t=3==e.nodeType?qa(e,Ya(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Rc(Ec(t,1),!1)}if(null==i&&o<Ya(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?qa(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Rc(Ec(t,-1),!0)}return Rc(Ec(3==r.nodeType?qa(r):r,-n),n>=0)}function Rc(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Pc(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function $c(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Lc=/[\u0590-\u08ac]/;let zc=null,Bc=null,Fc=!1;class jc{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Wa(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=this.children[n],i=t+o.size;if(i>e||o instanceof Uc){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof _c&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Wa(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Wa(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==r&&e<=l){let o=i+n.border;if(e>=o&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Wa(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=Wa(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(o>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,r);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),u=!1;if((lc||dc)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(u=!(!t||"\n"!=e.nodeValue[t-1]),u&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:Wa(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(lc&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||u&&dc)&&Ka(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Ka(l.node,l.offset,c.focusNode,c.focusOffset))return;let d=!1;if((a.extend||e==t)&&!u){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),d=!0}catch(e){}}if(!d){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class _c extends jc{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Wc extends jc{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Vc extends jc{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=Rt.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Vc(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Vc.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=su(o,t,i,n)),e>0&&(o=su(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Hc extends jc{constructor(e,t,n,r,o,i,s,l,a){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,l=o.nodeViews[t.type.name],a=l&&l(t,o,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,r),c=a&&a.dom,u=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Rt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:u}=e)}u||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=tu(c,n,t),a?s=new Jc(e,t,n,r,c,u||null,d,a,o,i+1):t.isText?new Kc(e,t,n,r,c,d,o):new Hc(e,t,n,r,c,u||null,d,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>De.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&nu(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,l=new ou(this,i&&i.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d,h,p;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(u?(d||(d=[u])).push(e):u=e)}if(u)if(d){d.sort(iu);for(let e=0;e<d.length;e++)n(d[e],c,!!a)}else n(u,c,!!a);if(a)p=-1,h=a,a=null;else{if(!(c<e.childCount))break;p=c,h=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=h.cut(e-i),h=h.cut(0,e-i),f=e,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(h,h.isInline&&!h.isLeaf?l.filter((e=>!e.inline)):l.slice(),t.forChild(i,h),p),i=f}}(this.node,this.innerDeco,((t,o,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&l.syncToMarks(o==this.node.childCount?Le.none:this.node.child(o).marks,n,e),l.placeWidget(t,e,r)}),((t,i,a,c)=>{let u;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(t,i,a,u,e)||l.updateNextNode(t,i,a,e,c,r)||l.addNode(t,i,a,e,r),r+=t.nodeSize})),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Yc(this.contentDOM,this.children,e),hc&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof qs)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Wc(this,o,t,r);e.input.compositionNodes.push(i),this.children=su(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,r),0))}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(nu(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Qc(this.dom,this.nodeDOM,Zc(this.outerDeco,this.node,t),Zc(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function qc(e,t,n,r,o){tu(r,t,e);let i=new Hc(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Kc extends Hc{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,0))}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new Kc(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Uc extends jc{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Jc extends Hc{constructor(e,t,n,r,o,i,s,l,a,c){super(e,t,n,r,o,i,s,a,c),this.spec=l}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Yc(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=ru(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Vc){let t=r?r.previousSibling:e.lastChild;Yc(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=ru(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const Gc=function(e){e&&(this.nodeName=e)};Gc.prototype=Object.create(null);const Xc=[new Gc];function Zc(e,t,n){if(0==e.length)return Xc;let r=n?Xc[0]:new Gc,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Gc(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new Gc(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Qc(e,t,n,r){if(n==Xc&&r==Xc)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=Xc[0]),o=t}eu(o,s||Xc[0],i)}return o}function eu(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function tu(e,t,n){return Qc(e,e,Xc,Zc(t,n,1!=e.nodeType))}function nu(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ru(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ou{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Vc)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let r=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Vc.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Hc){let a=this.preMatch.matched.get(l);if(null!=a&&a!=o)return!1;let c,u=l.dom,d=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&nu(t,l.outerDeco));if(!d&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(l,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!nu(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=Hc.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=Hc.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new _c(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Vc;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Kc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((dc||cc)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Uc(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function iu(e,t){return e.type.side-t.type.side}function su(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,u=l+=a.size;c>=n||u<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function lu(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=r.resolve(s);if(Xa(n)){for(l=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&Us.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==Ya(e);r||o;){if(e==n)return!0;let t=Wa(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Ya(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;a=new Us(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);return a||(a=gu(e,u,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),a}function au(e){return e.editable?e.hasFocus():wu(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function cu(e,t=!1){let n=e.state.selection;if(fu(e,n),au(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&cc){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Ka(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange();if(!t)return;let r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setStart(r.parentNode,Wa(r)+1):n.setStart(r,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&ic&&sc<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!uu||n instanceof qs||(n.$from.parent.inlineContent||(r=du(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=du(e,n.to))),e.docView.setSelection(i,s,e,t),uu&&(r&&pu(r),o&&pu(o)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{au(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const uu=dc||cc&&uc<63;function du(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(dc&&o&&"false"==o.contentEditable)return hu(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return hu(o);if(i)return hu(i)}}function hu(e){return e.contentEditable="true",dc&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function pu(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function fu(e,t){if(t instanceof Us){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(mu(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else mu(e)}function mu(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function gu(e,t,n,r){return e.someProp("createSelectionBetween",(r=>r(e,t,n)))||qs.between(t,n,r)}function yu(e){return!(e.editable&&!e.hasFocus())&&wu(e)}function wu(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function ku(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&_s.findFrom(i,t)}function vu(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function bu(e,t,n){let r=e.state.selection;if(!(r instanceof qs)){if(r instanceof Us&&r.node.isInline)return vu(e,new qs(t>0?r.$to:r.$from));{let n=ku(e.state,t);return!!n&&vu(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return vu(e,new qs(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=ku(e.state,t);return!!(n&&n instanceof Us)&&vu(e,n)}if(!(pc&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Us.isSelectable(i)?vu(e,new Us(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!gc&&vu(e,new qs(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function xu(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Cu(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Su(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(lc&&1==n.nodeType&&r<xu(n)&&Cu(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Cu(e,-1))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Mu(n))break;{let t=n.previousSibling;for(;t&&Cu(t,-1);)o=n.parentNode,i=Wa(t),t=t.previousSibling;if(t)n=t,r=xu(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Nu(e,n,r):o&&Nu(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=xu(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!Cu(n.childNodes[r],1))break;o=n,i=++r}else{if(Mu(n))break;{let t=n.nextSibling;for(;t&&Cu(t,1);)o=t.parentNode,i=Wa(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=xu(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&Nu(e,o,i)}(e)}function Mu(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Nu(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Ga(e);)t=Wa(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Ga(e);)t=Wa(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Xa(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout((()=>{e.state==o&&cu(e)}),50)}function Tu(e,t){let n=e.state.doc.resolve(t);if(!cc&&!fc&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Ou(e,t,n){let r=e.state.selection;if(r instanceof qs&&!r.empty||n.indexOf("s")>-1)return!1;if(pc&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=ku(e.state,t);if(n&&n instanceof Us)return vu(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Ys?_s.near(n,t):_s.findFrom(n,t);return!!s&&vu(e,s)}return!1}function Au(e,t){if(!(e.state.selection instanceof qs))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Eu(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Iu(e,t){e.someProp("transformCopied",(n=>{t=n(t,e)}));let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||Rt.fromSchema(e.state.schema),l=_u(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c,u=a.firstChild,d=0;for(;u&&1==u.nodeType&&(c=Fu[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),d++}u=a.firstChild}return u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Du(e,t,n,r,o){let i,s,l=o.parent.type.spec.code;if(!n&&!t)return null;let a=t&&(r||l||!n);if(a){if(e.someProp("transformPastedText",(n=>{t=n(t,l||r,e)})),l)return t?new Be(De.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):Be.empty;let n=e.someProp("clipboardTextParser",(n=>n(t,o,r,e)));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=Rt.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))}))}}else e.someProp("transformPastedHTML",(t=>{n=t(n,e)})),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=_u().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);if((n=o&&Fu[o[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join("")),r.innerHTML=function(e){let t=window.trustedTypes;return t?(Wu||(Wu=t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),Wu.createHTML(e)):e}(e),n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),gc&&function(e){let t=e.querySelectorAll(cc?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Ct.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!a&&!u),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ru.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=De.from(t.create(n[e+1],o)),i++,s++}return new Be(o,i,s)}(Bu(s,+u[1],+u[2]),u[4]);else if(s=Be.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach((e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&$u(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Lu(i[i.length-1],r.length));let t=Pu(e,n);i.push(t),o=o.matchType(t.type),r=n}})),i)return De.from(i)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=Bu(s,e,t)}return e.someProp("transformPasted",(t=>{s=t(s,e)})),s}const Ru=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Pu(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,De.from(e));return e}function $u(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=$u(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(De.from(Pu(n,e,o+1))))}}function Lu(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Lu(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(De.empty,!0);return e.copy(n.append(r))}function zu(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,l=s.content;return e.childCount>1&&(i=0),o<r-1&&(l=zu(l,t,n,r,o+1,i)),o>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(De.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function Bu(e,t,n){return t<e.openStart&&(e=new Be(zu(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Be(zu(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Fu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ju=null;function _u(){return ju||(ju=document.implementation.createHTMLDocument("title"))}let Wu=null;const Vu={},Hu={},qu={touchstart:!0,touchmove:!0};class Ku{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Uu(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Ju(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Yu(e,t))}))}function Yu(e,t){return e.someProp("handleDOMEvents",(n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function Gu(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Xu(e){return{left:e.clientX,top:e.clientY}}function Zu(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,(t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1))))return!0;return!1}function Qu(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function ed(e,t,n,r){return Zu(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(n=>n(e,t,r)))}function td(e,t,n,r){return Zu(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(n=>n(e,t,r)))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Qu(e,qs.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),i=o.before(t);if(n.inlineContent)Qu(e,qs.create(r,i+1,i+1+n.content.size),"pointer");else{if(!Us.isSelectable(n))continue;Qu(e,Us.create(r,i),"pointer")}return!0}}(e,n,r)}function nd(e){return cd(e)}Hu.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!id(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!mc||!cc||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!hc||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||function(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||pc&&72==n&&"c"==r)return Au(e,-1)||Su(e,-1);if(46==n&&!t.shiftKey||pc&&68==n&&"c"==r)return Au(e,1)||Su(e,1);if(13==n||27==n)return!0;if(37==n||pc&&66==n&&"c"==r){let t=37==n?"ltr"==Tu(e,e.state.selection.from)?-1:1:-1;return bu(e,t,r)||Su(e,t)}if(39==n||pc&&70==n&&"c"==r){let t=39==n?"ltr"==Tu(e,e.state.selection.from)?1:-1:1;return bu(e,t,r)||Su(e,t)}return 38==n||pc&&80==n&&"c"==r?Ou(e,-1,r)||Su(e,-1):40==n||pc&&78==n&&"c"==r?function(e){if(!dc||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Eu(e,n,"true"),setTimeout((()=>Eu(e,n,"false")),20)}return!1}(e)||Ou(e,1,r)||Su(e,1):r==(pc?"m":"c")&&(66==n||73==n||89==n||90==n)}(e,n)?n.preventDefault():Uu(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,Za(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},Hu.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Hu.keypress=(e,t)=>{let n=t;if(id(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||pc&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof qs&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode);/[\r\n]/.test(t)||e.someProp("handleTextInput",(n=>n(e,r.$from.pos,r.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const rd=pc?"metaKey":"ctrlKey";Vu.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=nd(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[rd]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(Xu(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new od(e,s,n,!!r)):("doubleClick"==i?ed:td)(e,s.pos,s.inside,n)?n.preventDefault():Uu(e,"pointer"))};class od{constructor(e,t,n,r){let o,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[rd],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:a}=e.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||a instanceof Us&&a.from<=i&&a.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!lc||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Uu(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>cu(this.view))),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Xu(e))),this.updateAllowDefault(e),this.allowDefault||!t?Uu(this.view,"pointer"):function(e,t,n,r,o){return Zu(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(n=>n(e,t,r)))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Us&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(Us.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Qu(e,Us.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Us.isSelectable(r))&&(Qu(e,new Us(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||dc&&this.mightDrag&&!this.mightDrag.node.isAtom||cc&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Qu(this.view,_s.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Uu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Uu(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function id(e,t){return!!e.composing||!!(dc&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Vu.touchstart=e=>{e.input.lastTouch=Date.now(),nd(e),Uu(e,"pointer")},Vu.touchmove=e=>{e.input.lastTouch=Date.now(),Uu(e,"pointer")},Vu.contextmenu=e=>nd(e);const sd=mc?5e3:-1;function ld(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>cd(e)),t))}function ad(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function cd(e,t=!1){if(!(mc&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ad(e),t||e.docView&&e.docView.dirty){let n=lu(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||e.state.selection.empty?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Hu.compositionstart=Hu.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof qs&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),cd(e,!0),e.markCursor=null;else if(cd(e,!t.selection.empty),lc&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}ld(e,sd)},Hu.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,ld(e,20))};const ud=ic&&sc<15||hc&&yc<604;function dd(e,t,n,r,o){let i=Du(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,o,i||Be.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function hd(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Vu.copy=Hu.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=ud?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Iu(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Hu.paste=(e,t)=>{let n=t;if(e.composing&&!mc)return;let r=ud?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&dd(e,hd(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?dd(e,r.value,null,o,t):dd(e,r.textContent,r.innerHTML,o,t)}),50)}(e,n)};class pd{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const fd=pc?"altKey":"ctrlKey";Vu.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Xu(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Us?i.to-1:i.to));else if(r&&r.mightDrag)o=Us.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Us.create(e.state.doc,t.posBefore))}let l=(o||e.state.selection).content(),{dom:a,text:c,slice:u}=Iu(e,l);(!n.dataTransfer.files.length||!cc||uc>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ud?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",ud||n.dataTransfer.setData("text/plain",c),e.dragging=new pd(u,!n[fd],o)},Vu.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},Hu.dragover=Hu.dragenter=(e,t)=>t.preventDefault(),Hu.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let o=e.posAtCoords(Xu(n));if(!o)return;let i=e.state.doc.resolve(o.pos),s=r&&r.slice;s?e.someProp("transformPasted",(t=>{s=t(s,e)})):s=Du(e,hd(n.dataTransfer),ud?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!r||n[fd]);if(e.someProp("handleDrop",(t=>t(e,n,s||Be.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?Ms(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=e.state.tr;if(l){let{node:e}=r;e?e.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,h=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(h))return;let p=c.doc.resolve(u);if(d&&Us.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Us(p));else{let t=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,r,o)=>t=o)),c.setSelection(gu(e,p,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Vu.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&cu(e)}),20))},Vu.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Vu.beforeinput=(e,t)=>{if(cc&&mc&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,Za(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in Hu)Vu[e]=Hu[e];function md(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class gd{constructor(e,t){this.toDOM=e,this.spec=t||bd,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new kd(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof gd&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&md(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class yd{constructor(e,t){this.attrs=e,this.spec=t||bd}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new kd(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof yd&&md(this.attrs,e.attrs)&&md(this.spec,e.spec)}static is(e){return e.type instanceof yd}destroy(){}}class wd{constructor(e,t){this.attrs=e,this.spec=t||bd}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new kd(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof wd&&md(this.attrs,e.attrs)&&md(this.spec,e.spec)}destroy(){}}class kd{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new kd(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new kd(e,e,new gd(t,n))}static inline(e,t,n,r){return new kd(e,t,new yd(n,r))}static node(e,t,n,r){return new kd(e,t,new wd(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof yd}get widget(){return this.type instanceof gd}}const vd=[],bd={};class xd{constructor(e,t){this.local=e.length?e:vd,this.children=t.length?t:vd}static create(e,t){return t.length?Od(t,e,0,bd):Cd}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==Cd||0==e.maps.length?this:this.mapInner(e,t,0,0,n||bd)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,r);l&&l.type.valid(t,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach(((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<l.length;o+=3){let i=l[o+1];if(i<0||e>i+t-r)continue;let a=l[o]+t-r;n>=a?l[o+1]=e<=a?-2:-1:e>=t&&s&&(l[o]+=s,l[o+1]+=s)}r+=s})),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),u=c-o;if(u<0||u>=r.content.size){a=!0;continue}let d=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(u),f=r.maybeChild(h);if(f&&p==u&&p+f.nodeSize==d){let r=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=Cd?(l[t]=u,l[t+1]=d,l[t+2]=r):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,r,o,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,o,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,o,i,s),c=Od(a,r,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new xd(t.sort(Ad),l)}(this.children,i||[],e,t,n,r,o):i?new xd(i.sort(Ad),vd):Cd}add(e,t){return t.length?this==Cd?xd.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach(((e,i)=>{let s,l=i+n;if(s=Nd(t,e,l)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,l+1):r.splice(o,0,i,i+e.nodeSize,Od(s,e,l+1,bd)),o+=3}}));let i=Md(o?Td(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new xd(i.length?this.local.concat(i).sort(Ad):this.local,r||this.children)}remove(e){return 0==e.length||this==Cd?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(o,i+1);l!=Cd?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new xd(r,n):Cd}forChild(e,t){if(this==Cd)return this;if(t.isLeaf)return xd.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof yd){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new xd(r.sort(Ad),vd);return n?new Sd([e,n]):e}return n||Cd}eq(e){if(this==e)return!0;if(!(e instanceof xd)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ed(this.localsInner(e))}localsInner(e){if(this==Cd)return vd;if(e.inlineContent||!this.local.some(yd.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof yd||t.push(this.local[e]);return t}forEachSet(e){e(this)}}xd.empty=new xd([],[]),xd.removeOverlap=Ed;const Cd=xd.empty;class Sd{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,bd)));return Sd.from(n)}forChild(e,t){if(t.isLeaf)return xd.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=Cd&&(o instanceof Sd?n=n.concat(o.members):n.push(o))}return Sd.from(n)}eq(e){if(!(e instanceof Sd)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Ed(n?t:t.sort(Ad)):vd}static from(e){switch(e.length){case 0:return Cd;case 1:return e[0];default:return new Sd(e.every((e=>e instanceof xd))?e:e.reduce(((e,t)=>e.concat(t instanceof xd?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Md(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new kd(o.from+t,o.to+t,o.type))}return n}function Nd(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Td(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Od(e,t,n,r){let o=[],i=!1;t.forEach(((t,s)=>{let l=Nd(e,t,s+n);if(l){i=!0;let e=Od(l,t,n+s+1,r);e!=Cd&&o.push(s,s+t.nodeSize,e)}}));let s=Md(i?Td(e):e,-n).sort(Ad);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new xd(s,o):Cd}function Ad(e,t){return e.from-t.from||e.to-t.to}function Ed(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Id(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Id(t,o+1,i.copy(r.to,i.to)))}}return t}function Id(e,t,n){for(;t<e.length&&Ad(n,e[t])>0;)t++;e.splice(t,0,n)}function Dd(e){let t=[];return e.someProp("decorations",(n=>{let r=n(e.state);r&&r!=Cd&&t.push(r)})),e.cursorWrapper&&t.push(xd.create(e.state.doc,[e.cursorWrapper.deco])),Sd.from(t)}const Rd={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Pd=ic&&sc<=11;class $d{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Ld{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $d,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);ic&&sc<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Pd&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Rd)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(yu(this.view)){if(this.suppressingSelectionUpdates)return cu(this.view);if(ic&&sc<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ka(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=Va(t))n.add(t);for(let r=e.anchorNode;r;r=Va(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&yu(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(lc&&l.length){let t=l.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&jd(e,n)==t||r.remove()}}}let a=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Xa(n)&&(a=lu(e))&&a.eq(_s.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,cu(e),this.currentSelection.set(n)):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(!zd.has(e)&&(zd.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=lc,Bd)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Bd=!0}}(e)),this.handleDOMChange(o,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||cu(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(ic&&sc<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?Wa(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=o&&o.parentNode==e.target?Wa(o):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let zd=new WeakMap,Bd=!1;function Fd(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Ka(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function jd(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function _d(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(dc&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||dc&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Wd=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Vd(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:gu(e,t.resolve(n.anchor),t.resolve(n.head))}function Hd(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}function qd(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}const Kd=Du,Ud=cd;class Jd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ku,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Qd),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Xd(this),Gd(this),this.nodeViews=Zd(this),this.docView=qc(this.state.doc,Yd(this),Dd(this),this.dom,this),this.domObserver=new Ld(this,((e,t,n,r)=>function(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=lu(e,t);if(n&&!e.state.selection.eq(n)){if(cc&&mc&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,Za(13,"Enter")))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}return}let s=e.state.doc.resolve(t),l=s.sharedDepth(n);t=s.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a,c,u=e.state.selection,d=function(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(r=[{node:u,offset:c.anchorOffset}],Xa(c)||r.push({node:c.focusNode,offset:c.focusOffset})),cc&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let d=e.state.doc,h=e.someProp("domParser")||Ct.fromSchema(e.state.schema),p=d.resolve(l),f=null,m=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:_d,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),h=e.state.doc,p=h.slice(d.from,d.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,c="end"):(a=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,r,o){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==o&&(r-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&e.size<t.size){let e=r<=i&&r>=s?i-r:0;i-=e,i&&i<t.size&&qd(t.textBetween(i-1,i+1))&&(i+=e?1:-1),l=i+(l-s),s=i}else if(l<i){let t=r<=i&&r>=l?i-r:0;i-=t,i&&i<e.size&&qd(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(p.content,d.doc.content,d.from,a,c);if(f&&e.input.domChangeCount++,(hc&&e.input.lastIOSEnter>Date.now()-225||mc)&&o.some((e=>1==e.nodeType&&!Wd.test(e.nodeName)))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",(t=>t(e,Za(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&u instanceof qs&&!u.empty&&u.$head.sameParent(u.$anchor))||e.composing||d.sel&&d.sel.anchor!=d.sel.head){if(d.sel){let t=Vd(e,e.state.doc,d.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:u.from,endA:u.to,endB:u.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof qs&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=d.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=d.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),ic&&sc<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>d.from&&"  "==d.doc.textBetween(f.start-d.from-1,f.start-d.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=d.doc.resolveNoCache(f.start-d.from),y=d.doc.resolveNoCache(f.endB-d.from),w=h.resolve(f.start),k=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=f.endA;if((hc&&e.input.lastIOSEnter>Date.now()-225&&(!k||o.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!k&&g.pos<d.doc.content.size&&!g.sameParent(y)&&(m=_s.findFrom(d.doc.resolve(g.pos+1),1,!0))&&m.head==y.pos)&&e.someProp("handleKeyDown",(t=>t(e,Za(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||Hd(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Hd(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Hd(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(h,f.start,f.endA,g,y)&&e.someProp("handleKeyDown",(t=>t(e,Za(8,"Backspace")))))return void(mc&&cc&&e.domObserver.suppressSelectionUpdates());cc&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),mc&&!k&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==f.endA&&(f.endB-=2,y=d.doc.resolveNoCache(f.endB-d.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,Za(13,"Enter"))}))}),20));let v,b,x,C=f.start,S=f.endA;if(k)if(g.pos==y.pos)ic&&sc<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>cu(e)),20)),v=e.state.tr.delete(C,S),b=h.resolve(f.start).marksAcross(h.resolve(f.endA));else if(f.endA==f.endB&&(x=function(e,t){let n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,l=i,a=s;for(let e=0;e<s.length;e++)l=s[e].removeFromSet(l);for(let e=0;e<i.length;e++)a=i[e].removeFromSet(a);if(1==l.length&&0==a.length)r=l[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=l.length||1!=a.length)return null;r=a[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if(De.from(c).eq(e))return{mark:r,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,f.endA-w.start()))))v=e.state.tr,"add"==x.type?v.addMark(C,S,x.mark):v.removeMark(C,S,x.mark);else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let t=g.parent.textBetween(g.parentOffset,y.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,C,S,t))))return;v=e.state.tr.insertText(t,C,S)}if(v||(v=e.state.tr.replace(C,S,d.doc.slice(f.start-d.from,f.endB-d.from))),d.sel){let t=Vd(e,v.doc,d.sel);t&&!(cc&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==C||t.head==v.mapping.map(S)-1)||ic&&t.empty&&t.head==C)&&v.setSelection(t)}b&&v.ensureMarks(b),i&&v.setMeta("composition",i),e.dispatch(v.scrollIntoView())}(this,e,t,n,r))),this.domObserver.start(),function(e){for(let t in Vu){let n=Vu[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Gu(e,t)||Yu(e,t)||!e.editable&&t.type in Hu||n(e,t)},qu[t]?{passive:!0}:void 0)}dc&&e.dom.addEventListener("input",(()=>null)),Ju(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ju(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(ad(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Zd(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ju(this),this.editable=Xd(this),Gd(this);let l=Dd(this),a=Yd(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",u=o||!this.docView.matchesNode(e.doc,a,l);!u&&e.selection.eq(r.selection)||(i=!0);let d="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=o-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:xc(e.dom)}}(this);if(i){this.domObserver.stop();let t=u&&(ic||cc)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(u){let n=cc?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Ya(e=e.childNodes[t-1])}else{if(!e.parentNode||Ga(e))return null;t=Wa(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Ga(e))return null;t=Wa(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}(this)),!o&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=qc(e.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Ka(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?cu(this,t):(fu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():d&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Cc(n,0==r?0:r-t)}(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof Us){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&bc(this,t.getBoundingClientRect(),e)}else bc(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new pd(e.slice,e.move,r<0?void 0:Us.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(ic){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Sc)return e.focus(Sc);let t=xc(e);e.focus(null==Sc?{get preventScroll(){return Sc={preventScroll:!0},!0}}:void 0),Sc||(Sc=!1,Cc(t,0))}(this.dom),cu(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Oc(this,e)}coordsAtPos(e,t=1){return Dc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return function(e,t,n){return zc==t&&Bc==n?Fc:(zc=t,Bc=n,Fc="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return $c(e,t,(()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Dc(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=qa(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?Lc.test(r.parent.textContent)&&l.modify?$c(e,t,(()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),h=u&&!c.contains(1==u.nodeType?u:u.parentNode)||t==u&&o==d;try{l.collapse(i,s),t&&(t!=i||o!=s)&&l.extend&&l.extend(t,o)}catch(e){}return null!=a&&(l.caretBidiLevel=a),h})):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return dd(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return dd(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Iu(this,e)}destroy(){this.docView&&(function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Dd(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ha=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Yu(e,t)||!Vu[t.type]||!e.editable&&t.type in Hu||Vu[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?dc&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Fd(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Fd(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Yd(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),t.translate||(t.translate="no"),[kd.node(0,e.state.doc.content.size,t)]}function Gd(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:kd.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Xd(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function Zd(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Qd(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var eh=e=>{throw TypeError(e)},th=(e,t,n)=>t.has(e)||eh("Cannot "+n),nh=(e,t,n)=>(th(e,t,"read from private field"),n?n.call(e):t.get(e)),rh=(e,t,n)=>t.has(e)?eh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),oh=(e,t,n,r)=>(th(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function ih(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}const sh={strong:(e,t,n,r)=>{const o=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(r);let l=s.move(o+o);return l+=s.move(n.containerPhrasing(e,{before:l,after:o,...s.current()})),l+=s.move(o+o),i(),l},emphasis:(e,t,n,r)=>{const o=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(r);let l=s.move(o);return l+=s.move(n.containerPhrasing(e,{before:l,after:o,...s.current()})),l+=s.move(o),i(),l}},lh=ne({},"editorView"),ah=ne({},"editorState"),ch=ne([],"initTimer"),uh=ne({},"editor"),dh=ne([],"inputRules"),hh=ne([],"prosePlugins"),ph=ne([],"remarkPlugins"),fh=ne([],"nodeView"),mh=ne([],"markView"),gh=ne(ai().use(Fr).use(_o),"remark"),yh=ne({handlers:sh},"remarkStringifyOptions"),wh=Te("ConfigReady");function kh(e){const t=t=>(t.record(wh),async()=>(await e(t),t.done(wh),()=>{t.clearTimer(wh)}));return ih(t,{displayName:"Config"}),t}const vh=Te("InitReady");function bh(e){const t=t=>(t.inject(uh,e).inject(hh,[]).inject(ph,[]).inject(dh,[]).inject(fh,[]).inject(mh,[]).inject(yh,{handlers:sh}).inject(gh,ai().use(Fr).use(_o)).inject(ch,[wh]).record(vh),async()=>{await t.waitTimers(ch);const e=t.get(yh);return t.set(gh,ai().use(Fr).use(_o,e)),t.done(vh),()=>{t.remove(uh).remove(hh).remove(ph).remove(dh).remove(fh).remove(mh).remove(yh).remove(gh).remove(ch).clearTimer(vh)}});return ih(t,{displayName:"Init"}),t}const xh=Te("SchemaReady"),Ch=ne([],"schemaTimer"),Sh=ne({},"schema"),Mh=ne([],"nodes"),Nh=ne([],"marks");function Th(e){var t;return{...e,parseDOM:null==(t=e.parseDOM)?void 0:t.map((t=>({priority:e.priority,...t})))}}const Oh=e=>(e.inject(Sh,{}).inject(Mh,[]).inject(Nh,[]).inject(Ch,[vh]).record(xh),async()=>{await e.waitTimers(Ch);const t=e.get(gh),n=e.get(ph).reduce(((e,t)=>e.use(t.plugin,t.options)),t);e.set(gh,n);const r=Object.fromEntries(e.get(Mh).map((([e,t])=>[e,Th(t)]))),o=Object.fromEntries(e.get(Nh).map((([e,t])=>[e,Th(t)]))),i=new bt({nodes:r,marks:o});return e.set(Sh,i),e.done(xh),()=>{e.remove(Sh).remove(Mh).remove(Nh).remove(Ch).clearTimer(xh)}});var Ah,Eh;ih(Oh,{displayName:"Schema"});class Ih{constructor(){rh(this,Ah),rh(this,Eh),oh(this,Ah,new Q),oh(this,Eh,null),this.setCtx=e=>{oh(this,Eh,e)}}get ctx(){return nh(this,Eh)}create(e,t){const n=e.create(nh(this,Ah).sliceMap);return n.set(t),n}get(e){return nh(this,Ah).get(e).get()}remove(e){return nh(this,Ah).remove(e)}call(e,t){if(null==nh(this,Eh))throw W();const n=this.get(e)(t),r=nh(this,Eh).get(lh);return n(r.state,r.dispatch,r)}}function Dh(e="cmdKey"){return ne((()=>()=>!1),e)}Ah=new WeakMap,Eh=new WeakMap;const Rh=ne(new Ih,"commands"),Ph=ne([xh],"commandsTimer"),$h=Te("CommandsReady"),Lh=e=>{const t=new Ih;return t.setCtx(e),e.inject(Rh,t).inject(Ph,[xh]).record($h),async()=>(await e.waitTimers(Ph),e.done($h),()=>{e.remove(Rh).remove(Ph).clearTimer($h)})};ih(Lh,{displayName:"Commands"});const zh=Te("ParserReady"),Bh=()=>{throw $()},Fh=ne(Bh,"parser"),jh=ne([],"parserTimer"),_h=e=>(e.inject(Fh,Bh).inject(jh,[xh]).record(zh),async()=>{await e.waitTimers(jh);const t=e.get(gh),n=e.get(Sh);return e.set(Fh,Ii.create(n,t)),e.done(zh),()=>{e.remove(Fh).remove(jh).clearTimer(zh)}});ih(_h,{displayName:"Parser"});const Wh=Te("SerializerReady"),Vh=ne([],"serializerTimer"),Hh=()=>{throw $()},qh=ne(Hh,"serializer"),Kh=e=>(e.inject(qh,Hh).inject(Vh,[xh]).record(Wh),async()=>{await e.waitTimers(Vh);const t=e.get(gh),n=e.get(Sh);return e.set(qh,Ji.create(n,t)),e.done(Wh),()=>{e.remove(qh).remove(Vh).clearTimer(Wh)}});ih(Kh,{displayName:"Serializer"});const Uh=ne("","defaultValue"),Jh=ne((e=>e),"stateOptions"),Yh=ne([],"editorStateTimer"),Gh=Te("EditorStateReady");function Xh(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return Ct.fromSchema(n).parse(e.dom);if("json"===e.type)return nt.fromJSON(n,e.value);throw P(e)}const Zh=new cl("MILKDOWN_STATE_TRACKER");function Qh(e){const t=Ma(dl,ua,da,pa);return e.Backspace=t,e}const ep=e=>(e.inject(Uh,"").inject(ah,{}).inject(Jh,(e=>e)).inject(Yh,[zh,Wh,$h]).record(Gh),async()=>{await e.waitTimers(Yh);const t=e.get(Sh),n=e.get(Fh),r=e.get(dh),o=e.get(Jh),i=e.get(hh),s=Xh(e.get(Uh),n,t),l=[...i,new sl({key:Zh,state:{init:()=>{},apply:(t,n,r,o)=>{e.set(ah,o)}}}),Ll({rules:r}),ja(Qh(Ea))];e.set(hh,l);const a=o({schema:t,doc:s,plugins:l}),c=ol.create(a);return e.set(ah,c),e.done(Gh),()=>{e.remove(Uh).remove(ah).remove(Jh).remove(Yh).clearTimer(Gh)}});ih(ep,{displayName:"EditorState"});const tp=Te("EditorViewReady"),np=ne([],"editorViewTimer"),rp=ne({},"editorViewOptions"),op=ne(null,"root"),ip=ne(null,"rootDOM"),sp=ne({},"rootAttrs"),lp=new cl("MILKDOWN_VIEW_CLEAR"),ap=e=>(e.inject(op,document.body).inject(lh,{}).inject(rp,{}).inject(ip,null).inject(sp,{}).inject(np,[Gh]).record(tp),async()=>{await e.wait(vh);const t=e.get(op)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(hh,(t=>[new sl({key:lp,view:t=>{const r=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(ip,n);const r=t.get(sp);return Object.entries(r).forEach((([e,t])=>n.setAttribute(e,t))),n}(n,e):void 0;return(()=>{if(r&&n){const e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{null!=r&&r.parentNode&&(null==r||r.parentNode.replaceChild(t.dom,r)),null==r||r.remove()}}}}),...t])),await e.waitTimers(np);const r=e.get(ah),o=e.get(rp),i=Object.fromEntries(e.get(fh)),s=Object.fromEntries(e.get(mh)),l=new Jd(n,{state:r,nodeViews:i,markViews:s,...o});return function(e){e.classList.add("editor"),e.setAttribute("role","textbox")}(l.dom),e.set(lh,l),e.done(tp),()=>{null==l||l.destroy(),e.remove(op).remove(lh).remove(rp).remove(ip).remove(sp).remove(np).clearTimer(tp)}});ih(ap,{displayName:"EditorView"});var cp,up,dp,hp,pp,fp,mp,gp,yp,wp,kp,vp,bp,xp,Cp,Sp=(e=>(e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e))(Sp||{});cp=new WeakMap,up=new WeakMap,dp=new WeakMap,hp=new WeakMap,pp=new WeakMap,fp=new WeakMap,mp=new WeakMap,gp=new WeakMap,yp=new WeakMap,wp=new WeakMap,kp=new WeakMap,vp=new WeakMap,bp=new WeakMap,xp=new WeakMap,Cp=new WeakMap;let Mp=class e{constructor(){rh(this,cp),rh(this,up),rh(this,dp),rh(this,hp),rh(this,pp),rh(this,fp),rh(this,mp),rh(this,gp),rh(this,yp),rh(this,wp),rh(this,kp),rh(this,vp),rh(this,bp),rh(this,xp),rh(this,Cp),oh(this,cp,!1),oh(this,up,"Idle"),oh(this,dp,[]),oh(this,hp,(()=>{})),oh(this,pp,new Q),oh(this,fp,new we),oh(this,mp,new Map),oh(this,gp,new Map),oh(this,yp,new ye(nh(this,pp),nh(this,fp))),oh(this,wp,(()=>{const e=kh((async e=>{await Promise.all(nh(this,dp).map((t=>t(e))))})),t=[Oh,_h,Kh,Lh,ep,ap,bh(this),e];nh(this,kp).call(this,t,nh(this,gp))})),oh(this,kp,((e,t)=>{e.forEach((e=>{const n=nh(this,yp).produce(nh(this,cp)?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})}))})),oh(this,vp,((e,t=!1)=>Promise.all([e].flat().map((e=>{const n=nh(this,mp).get(e),r=null==n?void 0:n.cleanup;return t?nh(this,mp).delete(e):nh(this,mp).set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof r?r():r}))))),oh(this,bp,(async()=>{await Promise.all([...nh(this,gp).entries()].map((([e,{cleanup:t}])=>"function"==typeof t?t():t))),nh(this,gp).clear()})),oh(this,xp,(e=>{oh(this,up,e),nh(this,hp).call(this,e)})),oh(this,Cp,(e=>[...e.entries()].map((async([t,n])=>{const{ctx:r,handler:o}=n;if(!o)return;const i=await o();e.set(t,{ctx:r,handler:o,cleanup:i})})))),this.enableInspector=(e=!0)=>(oh(this,cp,e),this),this.onStatusChange=e=>(oh(this,hp,e),this),this.config=e=>(nh(this,dp).push(e),this),this.removeConfig=e=>(oh(this,dp,nh(this,dp).filter((t=>t!==e))),this),this.use=e=>{const t=[e].flat();return t.flat().forEach((e=>{nh(this,mp).set(e,{ctx:void 0,handler:void 0,cleanup:void 0})})),"Created"===nh(this,up)&&nh(this,kp).call(this,t,nh(this,mp)),this},this.remove=async e=>"OnCreate"===nh(this,up)?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise((t=>{setTimeout((()=>{t(this.remove(e))}),50)}))):(await nh(this,vp).call(this,[e].flat(),!0),this),this.create=async()=>("OnCreate"===nh(this,up)||("Created"===nh(this,up)&&await this.destroy(),nh(this,xp).call(this,"OnCreate"),nh(this,wp).call(this),nh(this,kp).call(this,[...nh(this,mp).keys()],nh(this,mp)),await Promise.all([nh(this,Cp).call(this,nh(this,gp)),nh(this,Cp).call(this,nh(this,mp))].flat()),nh(this,xp).call(this,"Created")),this),this.destroy=async(e=!1)=>"Destroyed"===nh(this,up)||"OnDestroy"===nh(this,up)?this:"OnCreate"===nh(this,up)?new Promise((t=>{setTimeout((()=>{t(this.destroy(e))}),50)})):(e&&oh(this,dp,[]),nh(this,xp).call(this,"OnDestroy"),await nh(this,vp).call(this,[...nh(this,mp).keys()],e),await nh(this,bp).call(this),nh(this,xp).call(this,"Destroyed"),this),this.action=e=>e(nh(this,yp)),this.inspect=()=>nh(this,cp)?[...nh(this,gp).values(),...nh(this,mp).values()].map((({ctx:e})=>{var t;return null==(t=null==e?void 0:e.inspector)?void 0:t.read()})).filter((e=>!!e)):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}get ctx(){return nh(this,yp)}get status(){return nh(this,up)}},Np=e=>crypto.getRandomValues(new Uint8Array(e)),Tp=(e,t=21)=>((e,t,n)=>{let r=(2<<Math.log2(e.length-1))-1,o=-~(1.6*r*t/e.length);return(i=t)=>{let s="";for(;;){let t=n(o),l=0|o;for(;l--;)if(s+=e[t[l]&r]||"",s.length>=i)return s}}})(e,0|t,Np);const Op=Tp("abcedfghicklmn",10);function Ap(e,t,n){const r=Te(n||Op());let o=!1;const i=n=>(n.record(r),n.update(t,(e=>e.concat(r))),async()=>{const s=await e(n,i,(()=>{n.done(r),o=!0}));return o||n.done(r),()=>{n.update(t,(e=>e.filter((e=>e!==r)))),n.clearTimer(r),null==s||s()}});return i.timer=r,i}function Ep(e,t){const n=Dh(e),r=o=>async()=>{r.key=n,await o.wait($h);const i=t(o);return o.get(Rh).create(n,i),r.run=t=>o.get(Rh).call(e,t),()=>{o.get(Rh).remove(n)}};return r}function Ip(e,t,n){const r=Dh(e);return Ap((async(n,o)=>{await n.wait($h);const i=await t(n);return n.get(Rh).create(r,i),o.run=t=>n.get(Rh).call(e,t),o.key=r,()=>{n.get(Rh).remove(r)}}),Ph,n)}function Dp(e){const t=n=>async()=>{await n.wait(xh);const r=e(n);return n.update(dh,(e=>[...e,r])),t.inputRule=r,()=>{n.update(dh,(e=>e.filter((e=>e!==r))))}};return t}function Rp(e,t){return Ap((async(t,n)=>{await t.wait(xh);const r=await e(t);return t.update(dh,(e=>[...e,r])),n.inputRule=r,()=>{t.update(dh,(e=>e.filter((e=>e!==r))))}}),Yh,t)}function Pp(e,t){const n=r=>async()=>{const o=t(r);return r.update(Nh,(t=>[...t.filter((t=>t[0]!==e)),[e,o]])),n.id=e,n.schema=o,()=>{r.update(Nh,(t=>t.filter((([t])=>t!==e))))}};return n.type=t=>{const n=t.get(Sh).marks[e];if(!n)throw H(e);return n},n}function $p(e,t,n){const r=Ap((async(n,r,o)=>{const i=await t(n);return n.update(Nh,(t=>[...t.filter((t=>t[0]!==e)),[e,i]])),r.id=e,r.schema=i,o(),()=>{n.update(Nh,(t=>t.filter((([t])=>t!==e))))}}),Ch,n);return r.type=t=>{const n=t.get(Sh).marks[e];if(!n)throw H(e);return n},r}function Lp(e,t){const n=r=>async()=>{const o=t(r);return r.update(Mh,(t=>[...t.filter((t=>t[0]!==e)),[e,o]])),n.id=e,n.schema=o,()=>{r.update(Mh,(t=>t.filter((([t])=>t!==e))))}};return n.type=t=>{const n=t.get(Sh).nodes[e];if(!n)throw V(e);return n},n}function zp(e,t,n){const r=Ap((async(n,r,o)=>{const i=await t(n);return n.update(Mh,(t=>[...t.filter((t=>t[0]!==e)),[e,i]])),r.id=e,r.schema=i,o(),()=>{n.update(Mh,(t=>t.filter((([t])=>t!==e))))}}),Ch,n);return r.type=t=>{const n=t.get(Sh).nodes[e];if(!n)throw V(e);return n},r}function Bp(e){let t;const n=n=>async()=>(await n.wait(xh),t=e(n),n.update(hh,(e=>[...e,t])),()=>{n.update(hh,(e=>e.filter((e=>e!==t))))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function Fp(e,t){let n;const r=Ap((async t=>(await t.wait(xh),n=await e(t),t.update(hh,(e=>[...e,n])),()=>{t.update(hh,(e=>e.filter((e=>e!==n))))})),Yh,t);return r.plugin=()=>n,r.key=()=>n.spec.key,r}function jp(e){const t=n=>async()=>{await n.wait(xh);const r=e(n),o=ja(r);return n.update(hh,(e=>[...e,o])),t.keymap=r,()=>{n.update(hh,(e=>e.filter((e=>e!==o))))}};return t}function _p(e,t){return Ap((async(t,n)=>{await t.wait(xh);const r=await e(t),o=ja(r);return t.update(hh,(e=>[...e,o])),n.keymap=r,()=>{t.update(hh,(e=>e.filter((e=>e!==o))))}}),Yh,t)}function Wp(e,t){const n=r=>async()=>{await r.wait(xh);const o=t(r);return e.type(r)instanceof wt?r.update(fh,(t=>[...t,[e.id,o]])):r.update(mh,(t=>[...t,[e.id,o]])),n.view=o,n.type=e,()=>{e.type(r)instanceof wt?r.update(fh,(t=>t.filter((t=>t[0]!==e.id)))):r.update(mh,(t=>t.filter((t=>t[0]!==e.id))))}};return n}function Vp(e,t,n){return Ap((async(n,r)=>{await n.wait(xh);const o=await t(n);return e.type(n)instanceof wt?n.update(fh,(t=>[...t,[e.id,o]])):n.update(mh,(t=>[...t,[e.id,o]])),r.view=o,r.type=e,()=>{e.type(n)instanceof wt?n.update(fh,(t=>t.filter((t=>t[0]!==e.id)))):n.update(mh,(t=>t.filter((t=>t[0]!==e.id))))}}),np,n)}function Hp(e,t){const n=ne(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function qp(e,t){const n=Hp(t,e),r=Lp(e,(e=>e.get(n.key)(e))),o=[n,r];return o.id=r.id,o.node=r,o.type=e=>r.type(e),o.schema=r.schema,o.ctx=n,o.key=n.key,o.extendSchema=t=>r=>()=>{const i=r.get(n.key),s=t(i)(r);r.update(Mh,(t=>[...t.filter((t=>t[0]!==e)),[e,s]])),o.schema=s},o}function Kp(e,t){const n=Hp(t,e),r=Pp(e,(e=>e.get(n.key)(e))),o=[n,r];return o.id=r.id,o.mark=r,o.type=r.type,o.schema=r.schema,o.ctx=n,o.key=n.key,o.extendSchema=t=>r=>()=>{const i=r.get(n.key),s=t(i)(r);r.update(Nh,(t=>[...t.filter((t=>t[0]!==e)),[e,s]])),o.schema=s},o}function Up(e,t){const n=Object.fromEntries(Object.entries(t).map((([e,{shortcuts:t}])=>[e,t]))),r=Hp(n,`${e}Keymap`),o=jp((e=>{const n=e.get(r.key),o=Object.entries(t).flatMap((([t,{command:r}])=>[n[t]].flat().map((t=>[t,r(e)]))));return Object.fromEntries(o)})),i=[r,o];return i.ctx=r,i.shortcuts=o,i.key=r.key,i.keymap=o.keymap,i}const Jp=(e,t=(()=>({})))=>Hp(t,`${e}Attr`),Yp=(e,t=(()=>({})))=>Hp(t,`${e}Attr`);function Gp(e,t,n){const r=Hp(n??{},e),o=e=>async()=>{await e.wait(vh);const n={plugin:t(e),options:e.get(r.key)};return e.update(ph,(e=>[...e,n])),()=>{e.update(ph,(e=>e.filter((e=>e!==n))))}},i=[r,o];return i.id=e,i.plugin=o,i.options=r,i}function Xp(e,t){return n=>n.get(Rh).call(e,t)}function Zp(){return e=>{const t=e.get(lh),{tr:n}=t.state,r=Object.assign(Object.create(n),n).setTime(Date.now());return t.dispatch(r)}}function Qp(){return e=>{const t=document.createElement("div"),n=e.get(Sh),r=e.get(lh),o=Rt.fromSchema(n).serializeFragment(r.state.doc.content);return t.appendChild(o),t.innerHTML}}function ef(){return e=>{const t=e.get(lh);return e.get(qh)(t.state.doc)}}function tf(e){return t=>{const n=t.get(lh),r=t.get(Fh)(e);if(!r)return;const o=n.state.selection.content();return n.dispatch(n.state.tr.replaceSelection(new Be(r.content,o.openStart,o.openEnd)).scrollIntoView())}}function nf(){return e=>{const t=e.get(lh),n=[];return t.state.doc.descendants((e=>{"heading"===e.type.name&&e.attrs.level&&n.push({text:e.textContent,level:e.attrs.level,id:e.attrs.id})})),n}}function rf(e,t=!1){return n=>{const r=n.get(lh),o=n.get(Fh)(e);if(!o)return;if(!t){const{state:e}=r;return r.dispatch(e.tr.replace(0,e.doc.content.size,new Be(o.content,0,0)))}const i=n.get(Sh),s=n.get(Jh),l=n.get(hh),a=ol.create({schema:i,doc:o,plugins:l,...s});r.updateState(a)}}function of(e,t){return n=>{const r=n.get(lh),{tr:o}=r.state,i=o.doc.nodeAt(e);if(!i)return;const s=t(i.attrs);return r.dispatch(o.setNodeMarkup(e,void 0,s))}}const sf=(...e)=>{const t=e.length;let n=t;for(;n--;)if("function"!=typeof e[n])throw new TypeError("Expected a function");return(...n)=>{let r=0,o=t?e[r](...n):n[0];for(;++r<t;)o=e[r](o);return o}};function lf(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const af=[["ß","ss"],["ẞ","Ss"],["ä","ae"],["Ä","Ae"],["ö","oe"],["Ö","Oe"],["ü","ue"],["Ü","Ue"],["À","A"],["Á","A"],["Â","A"],["Ã","A"],["Ä","Ae"],["Å","A"],["Æ","AE"],["Ç","C"],["È","E"],["É","E"],["Ê","E"],["Ë","E"],["Ì","I"],["Í","I"],["Î","I"],["Ï","I"],["Ð","D"],["Ñ","N"],["Ò","O"],["Ó","O"],["Ô","O"],["Õ","O"],["Ö","Oe"],["Ő","O"],["Ø","O"],["Ù","U"],["Ú","U"],["Û","U"],["Ü","Ue"],["Ű","U"],["Ý","Y"],["Þ","TH"],["ß","ss"],["à","a"],["á","a"],["â","a"],["ã","a"],["ä","ae"],["å","a"],["æ","ae"],["ç","c"],["è","e"],["é","e"],["ê","e"],["ë","e"],["ì","i"],["í","i"],["î","i"],["ï","i"],["ð","d"],["ñ","n"],["ò","o"],["ó","o"],["ô","o"],["õ","o"],["ö","oe"],["ő","o"],["ø","o"],["ù","u"],["ú","u"],["û","u"],["ü","ue"],["ű","u"],["ý","y"],["þ","th"],["ÿ","y"],["ẞ","SS"],["à","a"],["À","A"],["á","a"],["Á","A"],["â","a"],["Â","A"],["ã","a"],["Ã","A"],["è","e"],["È","E"],["é","e"],["É","E"],["ê","e"],["Ê","E"],["ì","i"],["Ì","I"],["í","i"],["Í","I"],["ò","o"],["Ò","O"],["ó","o"],["Ó","O"],["ô","o"],["Ô","O"],["õ","o"],["Õ","O"],["ù","u"],["Ù","U"],["ú","u"],["Ú","U"],["ý","y"],["Ý","Y"],["ă","a"],["Ă","A"],["Đ","D"],["đ","d"],["ĩ","i"],["Ĩ","I"],["ũ","u"],["Ũ","U"],["ơ","o"],["Ơ","O"],["ư","u"],["Ư","U"],["ạ","a"],["Ạ","A"],["ả","a"],["Ả","A"],["ấ","a"],["Ấ","A"],["ầ","a"],["Ầ","A"],["ẩ","a"],["Ẩ","A"],["ẫ","a"],["Ẫ","A"],["ậ","a"],["Ậ","A"],["ắ","a"],["Ắ","A"],["ằ","a"],["Ằ","A"],["ẳ","a"],["Ẳ","A"],["ẵ","a"],["Ẵ","A"],["ặ","a"],["Ặ","A"],["ẹ","e"],["Ẹ","E"],["ẻ","e"],["Ẻ","E"],["ẽ","e"],["Ẽ","E"],["ế","e"],["Ế","E"],["ề","e"],["Ề","E"],["ể","e"],["Ể","E"],["ễ","e"],["Ễ","E"],["ệ","e"],["Ệ","E"],["ỉ","i"],["Ỉ","I"],["ị","i"],["Ị","I"],["ọ","o"],["Ọ","O"],["ỏ","o"],["Ỏ","O"],["ố","o"],["Ố","O"],["ồ","o"],["Ồ","O"],["ổ","o"],["Ổ","O"],["ỗ","o"],["Ỗ","O"],["ộ","o"],["Ộ","O"],["ớ","o"],["Ớ","O"],["ờ","o"],["Ờ","O"],["ở","o"],["Ở","O"],["ỡ","o"],["Ỡ","O"],["ợ","o"],["Ợ","O"],["ụ","u"],["Ụ","U"],["ủ","u"],["Ủ","U"],["ứ","u"],["Ứ","U"],["ừ","u"],["Ừ","U"],["ử","u"],["Ử","U"],["ữ","u"],["Ữ","U"],["ự","u"],["Ự","U"],["ỳ","y"],["Ỳ","Y"],["ỵ","y"],["Ỵ","Y"],["ỷ","y"],["Ỷ","Y"],["ỹ","y"],["Ỹ","Y"],["ء","e"],["آ","a"],["أ","a"],["ؤ","w"],["إ","i"],["ئ","y"],["ا","a"],["ب","b"],["ة","t"],["ت","t"],["ث","th"],["ج","j"],["ح","h"],["خ","kh"],["د","d"],["ذ","dh"],["ر","r"],["ز","z"],["س","s"],["ش","sh"],["ص","s"],["ض","d"],["ط","t"],["ظ","z"],["ع","e"],["غ","gh"],["ـ","_"],["ف","f"],["ق","q"],["ك","k"],["ل","l"],["م","m"],["ن","n"],["ه","h"],["و","w"],["ى","a"],["ي","y"],["َ‎","a"],["ُ","u"],["ِ‎","i"],["٠","0"],["١","1"],["٢","2"],["٣","3"],["٤","4"],["٥","5"],["٦","6"],["٧","7"],["٨","8"],["٩","9"],["چ","ch"],["ک","k"],["گ","g"],["پ","p"],["ژ","zh"],["ی","y"],["۰","0"],["۱","1"],["۲","2"],["۳","3"],["۴","4"],["۵","5"],["۶","6"],["۷","7"],["۸","8"],["۹","9"],["ټ","p"],["ځ","z"],["څ","c"],["ډ","d"],["ﺫ","d"],["ﺭ","r"],["ړ","r"],["ﺯ","z"],["ږ","g"],["ښ","x"],["ګ","g"],["ڼ","n"],["ۀ","e"],["ې","e"],["ۍ","ai"],["ٹ","t"],["ڈ","d"],["ڑ","r"],["ں","n"],["ہ","h"],["ھ","h"],["ے","e"],["А","A"],["а","a"],["Б","B"],["б","b"],["В","V"],["в","v"],["Г","G"],["г","g"],["Д","D"],["д","d"],["ъе","ye"],["Ъе","Ye"],["ъЕ","yE"],["ЪЕ","YE"],["Е","E"],["е","e"],["Ё","Yo"],["ё","yo"],["Ж","Zh"],["ж","zh"],["З","Z"],["з","z"],["И","I"],["и","i"],["ый","iy"],["Ый","Iy"],["ЫЙ","IY"],["ыЙ","iY"],["Й","Y"],["й","y"],["К","K"],["к","k"],["Л","L"],["л","l"],["М","M"],["м","m"],["Н","N"],["н","n"],["О","O"],["о","o"],["П","P"],["п","p"],["Р","R"],["р","r"],["С","S"],["с","s"],["Т","T"],["т","t"],["У","U"],["у","u"],["Ф","F"],["ф","f"],["Х","Kh"],["х","kh"],["Ц","Ts"],["ц","ts"],["Ч","Ch"],["ч","ch"],["Ш","Sh"],["ш","sh"],["Щ","Sch"],["щ","sch"],["Ъ",""],["ъ",""],["Ы","Y"],["ы","y"],["Ь",""],["ь",""],["Э","E"],["э","e"],["Ю","Yu"],["ю","yu"],["Я","Ya"],["я","ya"],["ă","a"],["Ă","A"],["ș","s"],["Ș","S"],["ț","t"],["Ț","T"],["ţ","t"],["Ţ","T"],["ş","s"],["Ş","S"],["ç","c"],["Ç","C"],["ğ","g"],["Ğ","G"],["ı","i"],["İ","I"],["ա","a"],["Ա","A"],["բ","b"],["Բ","B"],["գ","g"],["Գ","G"],["դ","d"],["Դ","D"],["ե","ye"],["Ե","Ye"],["զ","z"],["Զ","Z"],["է","e"],["Է","E"],["ը","y"],["Ը","Y"],["թ","t"],["Թ","T"],["ժ","zh"],["Ժ","Zh"],["ի","i"],["Ի","I"],["լ","l"],["Լ","L"],["խ","kh"],["Խ","Kh"],["ծ","ts"],["Ծ","Ts"],["կ","k"],["Կ","K"],["հ","h"],["Հ","H"],["ձ","dz"],["Ձ","Dz"],["ղ","gh"],["Ղ","Gh"],["ճ","tch"],["Ճ","Tch"],["մ","m"],["Մ","M"],["յ","y"],["Յ","Y"],["ն","n"],["Ն","N"],["շ","sh"],["Շ","Sh"],["ո","vo"],["Ո","Vo"],["չ","ch"],["Չ","Ch"],["պ","p"],["Պ","P"],["ջ","j"],["Ջ","J"],["ռ","r"],["Ռ","R"],["ս","s"],["Ս","S"],["վ","v"],["Վ","V"],["տ","t"],["Տ","T"],["ր","r"],["Ր","R"],["ց","c"],["Ց","C"],["ու","u"],["ՈՒ","U"],["Ու","U"],["փ","p"],["Փ","P"],["ք","q"],["Ք","Q"],["օ","o"],["Օ","O"],["ֆ","f"],["Ֆ","F"],["և","yev"],["ა","a"],["ბ","b"],["გ","g"],["დ","d"],["ე","e"],["ვ","v"],["ზ","z"],["თ","t"],["ი","i"],["კ","k"],["ლ","l"],["მ","m"],["ნ","n"],["ო","o"],["პ","p"],["ჟ","zh"],["რ","r"],["ს","s"],["ტ","t"],["უ","u"],["ფ","ph"],["ქ","q"],["ღ","gh"],["ყ","k"],["შ","sh"],["ჩ","ch"],["ც","ts"],["ძ","dz"],["წ","ts"],["ჭ","tch"],["ხ","kh"],["ჯ","j"],["ჰ","h"],["č","c"],["ď","d"],["ě","e"],["ň","n"],["ř","r"],["š","s"],["ť","t"],["ů","u"],["ž","z"],["Č","C"],["Ď","D"],["Ě","E"],["Ň","N"],["Ř","R"],["Š","S"],["Ť","T"],["Ů","U"],["Ž","Z"],["ހ","h"],["ށ","sh"],["ނ","n"],["ރ","r"],["ބ","b"],["ޅ","lh"],["ކ","k"],["އ","a"],["ވ","v"],["މ","m"],["ފ","f"],["ދ","dh"],["ތ","th"],["ލ","l"],["ގ","g"],["ޏ","gn"],["ސ","s"],["ޑ","d"],["ޒ","z"],["ޓ","t"],["ޔ","y"],["ޕ","p"],["ޖ","j"],["ޗ","ch"],["ޘ","tt"],["ޙ","hh"],["ޚ","kh"],["ޛ","th"],["ޜ","z"],["ޝ","sh"],["ޞ","s"],["ޟ","d"],["ޠ","t"],["ޡ","z"],["ޢ","a"],["ޣ","gh"],["ޤ","q"],["ޥ","w"],["ަ","a"],["ާ","aa"],["ި","i"],["ީ","ee"],["ު","u"],["ޫ","oo"],["ެ","e"],["ޭ","ey"],["ޮ","o"],["ޯ","oa"],["ް",""],["α","a"],["β","v"],["γ","g"],["δ","d"],["ε","e"],["ζ","z"],["η","i"],["θ","th"],["ι","i"],["κ","k"],["λ","l"],["μ","m"],["ν","n"],["ξ","ks"],["ο","o"],["π","p"],["ρ","r"],["σ","s"],["τ","t"],["υ","y"],["φ","f"],["χ","x"],["ψ","ps"],["ω","o"],["ά","a"],["έ","e"],["ί","i"],["ό","o"],["ύ","y"],["ή","i"],["ώ","o"],["ς","s"],["ϊ","i"],["ΰ","y"],["ϋ","y"],["ΐ","i"],["Α","A"],["Β","B"],["Γ","G"],["Δ","D"],["Ε","E"],["Ζ","Z"],["Η","I"],["Θ","TH"],["Ι","I"],["Κ","K"],["Λ","L"],["Μ","M"],["Ν","N"],["Ξ","KS"],["Ο","O"],["Π","P"],["Ρ","R"],["Σ","S"],["Τ","T"],["Υ","Y"],["Φ","F"],["Χ","X"],["Ψ","PS"],["Ω","O"],["Ά","A"],["Έ","E"],["Ί","I"],["Ό","O"],["Ύ","Y"],["Ή","I"],["Ώ","O"],["Ϊ","I"],["Ϋ","Y"],["ā","a"],["ē","e"],["ģ","g"],["ī","i"],["ķ","k"],["ļ","l"],["ņ","n"],["ū","u"],["Ā","A"],["Ē","E"],["Ģ","G"],["Ī","I"],["Ķ","K"],["Ļ","L"],["Ņ","N"],["Ū","U"],["č","c"],["š","s"],["ž","z"],["Č","C"],["Š","S"],["Ž","Z"],["ą","a"],["č","c"],["ę","e"],["ė","e"],["į","i"],["š","s"],["ų","u"],["ū","u"],["ž","z"],["Ą","A"],["Č","C"],["Ę","E"],["Ė","E"],["Į","I"],["Š","S"],["Ų","U"],["Ū","U"],["Ќ","Kj"],["ќ","kj"],["Љ","Lj"],["љ","lj"],["Њ","Nj"],["њ","nj"],["Тс","Ts"],["тс","ts"],["ą","a"],["ć","c"],["ę","e"],["ł","l"],["ń","n"],["ś","s"],["ź","z"],["ż","z"],["Ą","A"],["Ć","C"],["Ę","E"],["Ł","L"],["Ń","N"],["Ś","S"],["Ź","Z"],["Ż","Z"],["Є","Ye"],["І","I"],["Ї","Yi"],["Ґ","G"],["є","ye"],["і","i"],["ї","yi"],["ґ","g"],["IJ","IJ"],["ij","ij"],["¢","c"],["¥","Y"],["߿","b"],["৳","t"],["૱","Bo"],["฿","B"],["₠","CE"],["₡","C"],["₢","Cr"],["₣","F"],["₥","m"],["₦","N"],["₧","Pt"],["₨","Rs"],["₩","W"],["₫","s"],["€","E"],["₭","K"],["₮","T"],["₯","Dp"],["₰","S"],["₱","P"],["₲","G"],["₳","A"],["₴","S"],["₵","C"],["₶","tt"],["₷","S"],["₸","T"],["₹","R"],["₺","L"],["₽","P"],["₿","B"],["﹩","$"],["¢","c"],["¥","Y"],["₩","W"],["𝐀","A"],["𝐁","B"],["𝐂","C"],["𝐃","D"],["𝐄","E"],["𝐅","F"],["𝐆","G"],["𝐇","H"],["𝐈","I"],["𝐉","J"],["𝐊","K"],["𝐋","L"],["𝐌","M"],["𝐍","N"],["𝐎","O"],["𝐏","P"],["𝐐","Q"],["𝐑","R"],["𝐒","S"],["𝐓","T"],["𝐔","U"],["𝐕","V"],["𝐖","W"],["𝐗","X"],["𝐘","Y"],["𝐙","Z"],["𝐚","a"],["𝐛","b"],["𝐜","c"],["𝐝","d"],["𝐞","e"],["𝐟","f"],["𝐠","g"],["𝐡","h"],["𝐢","i"],["𝐣","j"],["𝐤","k"],["𝐥","l"],["𝐦","m"],["𝐧","n"],["𝐨","o"],["𝐩","p"],["𝐪","q"],["𝐫","r"],["𝐬","s"],["𝐭","t"],["𝐮","u"],["𝐯","v"],["𝐰","w"],["𝐱","x"],["𝐲","y"],["𝐳","z"],["𝐴","A"],["𝐵","B"],["𝐶","C"],["𝐷","D"],["𝐸","E"],["𝐹","F"],["𝐺","G"],["𝐻","H"],["𝐼","I"],["𝐽","J"],["𝐾","K"],["𝐿","L"],["𝑀","M"],["𝑁","N"],["𝑂","O"],["𝑃","P"],["𝑄","Q"],["𝑅","R"],["𝑆","S"],["𝑇","T"],["𝑈","U"],["𝑉","V"],["𝑊","W"],["𝑋","X"],["𝑌","Y"],["𝑍","Z"],["𝑎","a"],["𝑏","b"],["𝑐","c"],["𝑑","d"],["𝑒","e"],["𝑓","f"],["𝑔","g"],["𝑖","i"],["𝑗","j"],["𝑘","k"],["𝑙","l"],["𝑚","m"],["𝑛","n"],["𝑜","o"],["𝑝","p"],["𝑞","q"],["𝑟","r"],["𝑠","s"],["𝑡","t"],["𝑢","u"],["𝑣","v"],["𝑤","w"],["𝑥","x"],["𝑦","y"],["𝑧","z"],["𝑨","A"],["𝑩","B"],["𝑪","C"],["𝑫","D"],["𝑬","E"],["𝑭","F"],["𝑮","G"],["𝑯","H"],["𝑰","I"],["𝑱","J"],["𝑲","K"],["𝑳","L"],["𝑴","M"],["𝑵","N"],["𝑶","O"],["𝑷","P"],["𝑸","Q"],["𝑹","R"],["𝑺","S"],["𝑻","T"],["𝑼","U"],["𝑽","V"],["𝑾","W"],["𝑿","X"],["𝒀","Y"],["𝒁","Z"],["𝒂","a"],["𝒃","b"],["𝒄","c"],["𝒅","d"],["𝒆","e"],["𝒇","f"],["𝒈","g"],["𝒉","h"],["𝒊","i"],["𝒋","j"],["𝒌","k"],["𝒍","l"],["𝒎","m"],["𝒏","n"],["𝒐","o"],["𝒑","p"],["𝒒","q"],["𝒓","r"],["𝒔","s"],["𝒕","t"],["𝒖","u"],["𝒗","v"],["𝒘","w"],["𝒙","x"],["𝒚","y"],["𝒛","z"],["𝒜","A"],["𝒞","C"],["𝒟","D"],["𝒢","g"],["𝒥","J"],["𝒦","K"],["𝒩","N"],["𝒪","O"],["𝒫","P"],["𝒬","Q"],["𝒮","S"],["𝒯","T"],["𝒰","U"],["𝒱","V"],["𝒲","W"],["𝒳","X"],["𝒴","Y"],["𝒵","Z"],["𝒶","a"],["𝒷","b"],["𝒸","c"],["𝒹","d"],["𝒻","f"],["𝒽","h"],["𝒾","i"],["𝒿","j"],["𝓀","h"],["𝓁","l"],["𝓂","m"],["𝓃","n"],["𝓅","p"],["𝓆","q"],["𝓇","r"],["𝓈","s"],["𝓉","t"],["𝓊","u"],["𝓋","v"],["𝓌","w"],["𝓍","x"],["𝓎","y"],["𝓏","z"],["𝓐","A"],["𝓑","B"],["𝓒","C"],["𝓓","D"],["𝓔","E"],["𝓕","F"],["𝓖","G"],["𝓗","H"],["𝓘","I"],["𝓙","J"],["𝓚","K"],["𝓛","L"],["𝓜","M"],["𝓝","N"],["𝓞","O"],["𝓟","P"],["𝓠","Q"],["𝓡","R"],["𝓢","S"],["𝓣","T"],["𝓤","U"],["𝓥","V"],["𝓦","W"],["𝓧","X"],["𝓨","Y"],["𝓩","Z"],["𝓪","a"],["𝓫","b"],["𝓬","c"],["𝓭","d"],["𝓮","e"],["𝓯","f"],["𝓰","g"],["𝓱","h"],["𝓲","i"],["𝓳","j"],["𝓴","k"],["𝓵","l"],["𝓶","m"],["𝓷","n"],["𝓸","o"],["𝓹","p"],["𝓺","q"],["𝓻","r"],["𝓼","s"],["𝓽","t"],["𝓾","u"],["𝓿","v"],["𝔀","w"],["𝔁","x"],["𝔂","y"],["𝔃","z"],["𝔄","A"],["𝔅","B"],["𝔇","D"],["𝔈","E"],["𝔉","F"],["𝔊","G"],["𝔍","J"],["𝔎","K"],["𝔏","L"],["𝔐","M"],["𝔑","N"],["𝔒","O"],["𝔓","P"],["𝔔","Q"],["𝔖","S"],["𝔗","T"],["𝔘","U"],["𝔙","V"],["𝔚","W"],["𝔛","X"],["𝔜","Y"],["𝔞","a"],["𝔟","b"],["𝔠","c"],["𝔡","d"],["𝔢","e"],["𝔣","f"],["𝔤","g"],["𝔥","h"],["𝔦","i"],["𝔧","j"],["𝔨","k"],["𝔩","l"],["𝔪","m"],["𝔫","n"],["𝔬","o"],["𝔭","p"],["𝔮","q"],["𝔯","r"],["𝔰","s"],["𝔱","t"],["𝔲","u"],["𝔳","v"],["𝔴","w"],["𝔵","x"],["𝔶","y"],["𝔷","z"],["𝔸","A"],["𝔹","B"],["𝔻","D"],["𝔼","E"],["𝔽","F"],["𝔾","G"],["𝕀","I"],["𝕁","J"],["𝕂","K"],["𝕃","L"],["𝕄","M"],["𝕆","N"],["𝕊","S"],["𝕋","T"],["𝕌","U"],["𝕍","V"],["𝕎","W"],["𝕏","X"],["𝕐","Y"],["𝕒","a"],["𝕓","b"],["𝕔","c"],["𝕕","d"],["𝕖","e"],["𝕗","f"],["𝕘","g"],["𝕙","h"],["𝕚","i"],["𝕛","j"],["𝕜","k"],["𝕝","l"],["𝕞","m"],["𝕟","n"],["𝕠","o"],["𝕡","p"],["𝕢","q"],["𝕣","r"],["𝕤","s"],["𝕥","t"],["𝕦","u"],["𝕧","v"],["𝕨","w"],["𝕩","x"],["𝕪","y"],["𝕫","z"],["𝕬","A"],["𝕭","B"],["𝕮","C"],["𝕯","D"],["𝕰","E"],["𝕱","F"],["𝕲","G"],["𝕳","H"],["𝕴","I"],["𝕵","J"],["𝕶","K"],["𝕷","L"],["𝕸","M"],["𝕹","N"],["𝕺","O"],["𝕻","P"],["𝕼","Q"],["𝕽","R"],["𝕾","S"],["𝕿","T"],["𝖀","U"],["𝖁","V"],["𝖂","W"],["𝖃","X"],["𝖄","Y"],["𝖅","Z"],["𝖆","a"],["𝖇","b"],["𝖈","c"],["𝖉","d"],["𝖊","e"],["𝖋","f"],["𝖌","g"],["𝖍","h"],["𝖎","i"],["𝖏","j"],["𝖐","k"],["𝖑","l"],["𝖒","m"],["𝖓","n"],["𝖔","o"],["𝖕","p"],["𝖖","q"],["𝖗","r"],["𝖘","s"],["𝖙","t"],["𝖚","u"],["𝖛","v"],["𝖜","w"],["𝖝","x"],["𝖞","y"],["𝖟","z"],["𝖠","A"],["𝖡","B"],["𝖢","C"],["𝖣","D"],["𝖤","E"],["𝖥","F"],["𝖦","G"],["𝖧","H"],["𝖨","I"],["𝖩","J"],["𝖪","K"],["𝖫","L"],["𝖬","M"],["𝖭","N"],["𝖮","O"],["𝖯","P"],["𝖰","Q"],["𝖱","R"],["𝖲","S"],["𝖳","T"],["𝖴","U"],["𝖵","V"],["𝖶","W"],["𝖷","X"],["𝖸","Y"],["𝖹","Z"],["𝖺","a"],["𝖻","b"],["𝖼","c"],["𝖽","d"],["𝖾","e"],["𝖿","f"],["𝗀","g"],["𝗁","h"],["𝗂","i"],["𝗃","j"],["𝗄","k"],["𝗅","l"],["𝗆","m"],["𝗇","n"],["𝗈","o"],["𝗉","p"],["𝗊","q"],["𝗋","r"],["𝗌","s"],["𝗍","t"],["𝗎","u"],["𝗏","v"],["𝗐","w"],["𝗑","x"],["𝗒","y"],["𝗓","z"],["𝗔","A"],["𝗕","B"],["𝗖","C"],["𝗗","D"],["𝗘","E"],["𝗙","F"],["𝗚","G"],["𝗛","H"],["𝗜","I"],["𝗝","J"],["𝗞","K"],["𝗟","L"],["𝗠","M"],["𝗡","N"],["𝗢","O"],["𝗣","P"],["𝗤","Q"],["𝗥","R"],["𝗦","S"],["𝗧","T"],["𝗨","U"],["𝗩","V"],["𝗪","W"],["𝗫","X"],["𝗬","Y"],["𝗭","Z"],["𝗮","a"],["𝗯","b"],["𝗰","c"],["𝗱","d"],["𝗲","e"],["𝗳","f"],["𝗴","g"],["𝗵","h"],["𝗶","i"],["𝗷","j"],["𝗸","k"],["𝗹","l"],["𝗺","m"],["𝗻","n"],["𝗼","o"],["𝗽","p"],["𝗾","q"],["𝗿","r"],["𝘀","s"],["𝘁","t"],["𝘂","u"],["𝘃","v"],["𝘄","w"],["𝘅","x"],["𝘆","y"],["𝘇","z"],["𝘈","A"],["𝘉","B"],["𝘊","C"],["𝘋","D"],["𝘌","E"],["𝘍","F"],["𝘎","G"],["𝘏","H"],["𝘐","I"],["𝘑","J"],["𝘒","K"],["𝘓","L"],["𝘔","M"],["𝘕","N"],["𝘖","O"],["𝘗","P"],["𝘘","Q"],["𝘙","R"],["𝘚","S"],["𝘛","T"],["𝘜","U"],["𝘝","V"],["𝘞","W"],["𝘟","X"],["𝘠","Y"],["𝘡","Z"],["𝘢","a"],["𝘣","b"],["𝘤","c"],["𝘥","d"],["𝘦","e"],["𝘧","f"],["𝘨","g"],["𝘩","h"],["𝘪","i"],["𝘫","j"],["𝘬","k"],["𝘭","l"],["𝘮","m"],["𝘯","n"],["𝘰","o"],["𝘱","p"],["𝘲","q"],["𝘳","r"],["𝘴","s"],["𝘵","t"],["𝘶","u"],["𝘷","v"],["𝘸","w"],["𝘹","x"],["𝘺","y"],["𝘻","z"],["𝘼","A"],["𝘽","B"],["𝘾","C"],["𝘿","D"],["𝙀","E"],["𝙁","F"],["𝙂","G"],["𝙃","H"],["𝙄","I"],["𝙅","J"],["𝙆","K"],["𝙇","L"],["𝙈","M"],["𝙉","N"],["𝙊","O"],["𝙋","P"],["𝙌","Q"],["𝙍","R"],["𝙎","S"],["𝙏","T"],["𝙐","U"],["𝙑","V"],["𝙒","W"],["𝙓","X"],["𝙔","Y"],["𝙕","Z"],["𝙖","a"],["𝙗","b"],["𝙘","c"],["𝙙","d"],["𝙚","e"],["𝙛","f"],["𝙜","g"],["𝙝","h"],["𝙞","i"],["𝙟","j"],["𝙠","k"],["𝙡","l"],["𝙢","m"],["𝙣","n"],["𝙤","o"],["𝙥","p"],["𝙦","q"],["𝙧","r"],["𝙨","s"],["𝙩","t"],["𝙪","u"],["𝙫","v"],["𝙬","w"],["𝙭","x"],["𝙮","y"],["𝙯","z"],["𝙰","A"],["𝙱","B"],["𝙲","C"],["𝙳","D"],["𝙴","E"],["𝙵","F"],["𝙶","G"],["𝙷","H"],["𝙸","I"],["𝙹","J"],["𝙺","K"],["𝙻","L"],["𝙼","M"],["𝙽","N"],["𝙾","O"],["𝙿","P"],["𝚀","Q"],["𝚁","R"],["𝚂","S"],["𝚃","T"],["𝚄","U"],["𝚅","V"],["𝚆","W"],["𝚇","X"],["𝚈","Y"],["𝚉","Z"],["𝚊","a"],["𝚋","b"],["𝚌","c"],["𝚍","d"],["𝚎","e"],["𝚏","f"],["𝚐","g"],["𝚑","h"],["𝚒","i"],["𝚓","j"],["𝚔","k"],["𝚕","l"],["𝚖","m"],["𝚗","n"],["𝚘","o"],["𝚙","p"],["𝚚","q"],["𝚛","r"],["𝚜","s"],["𝚝","t"],["𝚞","u"],["𝚟","v"],["𝚠","w"],["𝚡","x"],["𝚢","y"],["𝚣","z"],["𝚤","l"],["𝚥","j"],["𝛢","A"],["𝛣","B"],["𝛤","G"],["𝛥","D"],["𝛦","E"],["𝛧","Z"],["𝛨","I"],["𝛩","TH"],["𝛪","I"],["𝛫","K"],["𝛬","L"],["𝛭","M"],["𝛮","N"],["𝛯","KS"],["𝛰","O"],["𝛱","P"],["𝛲","R"],["𝛳","TH"],["𝛴","S"],["𝛵","T"],["𝛶","Y"],["𝛷","F"],["𝛸","x"],["𝛹","PS"],["𝛺","O"],["𝛻","D"],["𝛼","a"],["𝛽","b"],["𝛾","g"],["𝛿","d"],["𝜀","e"],["𝜁","z"],["𝜂","i"],["𝜃","th"],["𝜄","i"],["𝜅","k"],["𝜆","l"],["𝜇","m"],["𝜈","n"],["𝜉","ks"],["𝜊","o"],["𝜋","p"],["𝜌","r"],["𝜍","s"],["𝜎","s"],["𝜏","t"],["𝜐","y"],["𝜑","f"],["𝜒","x"],["𝜓","ps"],["𝜔","o"],["𝜕","d"],["𝜖","E"],["𝜗","TH"],["𝜘","K"],["𝜙","f"],["𝜚","r"],["𝜛","p"],["𝜜","A"],["𝜝","V"],["𝜞","G"],["𝜟","D"],["𝜠","E"],["𝜡","Z"],["𝜢","I"],["𝜣","TH"],["𝜤","I"],["𝜥","K"],["𝜦","L"],["𝜧","M"],["𝜨","N"],["𝜩","KS"],["𝜪","O"],["𝜫","P"],["𝜬","S"],["𝜭","TH"],["𝜮","S"],["𝜯","T"],["𝜰","Y"],["𝜱","F"],["𝜲","X"],["𝜳","PS"],["𝜴","O"],["𝜵","D"],["𝜶","a"],["𝜷","v"],["𝜸","g"],["𝜹","d"],["𝜺","e"],["𝜻","z"],["𝜼","i"],["𝜽","th"],["𝜾","i"],["𝜿","k"],["𝝀","l"],["𝝁","m"],["𝝂","n"],["𝝃","ks"],["𝝄","o"],["𝝅","p"],["𝝆","r"],["𝝇","s"],["𝝈","s"],["𝝉","t"],["𝝊","y"],["𝝋","f"],["𝝌","x"],["𝝍","ps"],["𝝎","o"],["𝝏","a"],["𝝐","e"],["𝝑","i"],["𝝒","k"],["𝝓","f"],["𝝔","r"],["𝝕","p"],["𝝖","A"],["𝝗","B"],["𝝘","G"],["𝝙","D"],["𝝚","E"],["𝝛","Z"],["𝝜","I"],["𝝝","TH"],["𝝞","I"],["𝝟","K"],["𝝠","L"],["𝝡","M"],["𝝢","N"],["𝝣","KS"],["𝝤","O"],["𝝥","P"],["𝝦","R"],["𝝧","TH"],["𝝨","S"],["𝝩","T"],["𝝪","Y"],["𝝫","F"],["𝝬","X"],["𝝭","PS"],["𝝮","O"],["𝝯","D"],["𝝰","a"],["𝝱","v"],["𝝲","g"],["𝝳","d"],["𝝴","e"],["𝝵","z"],["𝝶","i"],["𝝷","th"],["𝝸","i"],["𝝹","k"],["𝝺","l"],["𝝻","m"],["𝝼","n"],["𝝽","ks"],["𝝾","o"],["𝝿","p"],["𝞀","r"],["𝞁","s"],["𝞂","s"],["𝞃","t"],["𝞄","y"],["𝞅","f"],["𝞆","x"],["𝞇","ps"],["𝞈","o"],["𝞉","a"],["𝞊","e"],["𝞋","i"],["𝞌","k"],["𝞍","f"],["𝞎","r"],["𝞏","p"],["𝞐","A"],["𝞑","V"],["𝞒","G"],["𝞓","D"],["𝞔","E"],["𝞕","Z"],["𝞖","I"],["𝞗","TH"],["𝞘","I"],["𝞙","K"],["𝞚","L"],["𝞛","M"],["𝞜","N"],["𝞝","KS"],["𝞞","O"],["𝞟","P"],["𝞠","S"],["𝞡","TH"],["𝞢","S"],["𝞣","T"],["𝞤","Y"],["𝞥","F"],["𝞦","X"],["𝞧","PS"],["𝞨","O"],["𝞩","D"],["𝞪","av"],["𝞫","g"],["𝞬","d"],["𝞭","e"],["𝞮","z"],["𝞯","i"],["𝞰","i"],["𝞱","th"],["𝞲","i"],["𝞳","k"],["𝞴","l"],["𝞵","m"],["𝞶","n"],["𝞷","ks"],["𝞸","o"],["𝞹","p"],["𝞺","r"],["𝞻","s"],["𝞼","s"],["𝞽","t"],["𝞾","y"],["𝞿","f"],["𝟀","x"],["𝟁","ps"],["𝟂","o"],["𝟃","a"],["𝟄","e"],["𝟅","i"],["𝟆","k"],["𝟇","f"],["𝟈","r"],["𝟉","p"],["𝟊","F"],["𝟋","f"],["⒜","(a)"],["⒝","(b)"],["⒞","(c)"],["⒟","(d)"],["⒠","(e)"],["⒡","(f)"],["⒢","(g)"],["⒣","(h)"],["⒤","(i)"],["⒥","(j)"],["⒦","(k)"],["⒧","(l)"],["⒨","(m)"],["⒩","(n)"],["⒪","(o)"],["⒫","(p)"],["⒬","(q)"],["⒭","(r)"],["⒮","(s)"],["⒯","(t)"],["⒰","(u)"],["⒱","(v)"],["⒲","(w)"],["⒳","(x)"],["⒴","(y)"],["⒵","(z)"],["Ⓐ","(A)"],["Ⓑ","(B)"],["Ⓒ","(C)"],["Ⓓ","(D)"],["Ⓔ","(E)"],["Ⓕ","(F)"],["Ⓖ","(G)"],["Ⓗ","(H)"],["Ⓘ","(I)"],["Ⓙ","(J)"],["Ⓚ","(K)"],["Ⓛ","(L)"],["Ⓝ","(N)"],["Ⓞ","(O)"],["Ⓟ","(P)"],["Ⓠ","(Q)"],["Ⓡ","(R)"],["Ⓢ","(S)"],["Ⓣ","(T)"],["Ⓤ","(U)"],["Ⓥ","(V)"],["Ⓦ","(W)"],["Ⓧ","(X)"],["Ⓨ","(Y)"],["Ⓩ","(Z)"],["ⓐ","(a)"],["ⓑ","(b)"],["ⓒ","(b)"],["ⓓ","(c)"],["ⓔ","(e)"],["ⓕ","(f)"],["ⓖ","(g)"],["ⓗ","(h)"],["ⓘ","(i)"],["ⓙ","(j)"],["ⓚ","(k)"],["ⓛ","(l)"],["ⓜ","(m)"],["ⓝ","(n)"],["ⓞ","(o)"],["ⓟ","(p)"],["ⓠ","(q)"],["ⓡ","(r)"],["ⓢ","(s)"],["ⓣ","(t)"],["ⓤ","(u)"],["ⓥ","(v)"],["ⓦ","(w)"],["ⓧ","(x)"],["ⓨ","(y)"],["ⓩ","(z)"],["Ċ","C"],["ċ","c"],["Ġ","G"],["ġ","g"],["Ħ","H"],["ħ","h"],["Ż","Z"],["ż","z"],["𝟎","0"],["𝟏","1"],["𝟐","2"],["𝟑","3"],["𝟒","4"],["𝟓","5"],["𝟔","6"],["𝟕","7"],["𝟖","8"],["𝟗","9"],["𝟘","0"],["𝟙","1"],["𝟚","2"],["𝟛","3"],["𝟜","4"],["𝟝","5"],["𝟞","6"],["𝟟","7"],["𝟠","8"],["𝟡","9"],["𝟢","0"],["𝟣","1"],["𝟤","2"],["𝟥","3"],["𝟦","4"],["𝟧","5"],["𝟨","6"],["𝟩","7"],["𝟪","8"],["𝟫","9"],["𝟬","0"],["𝟭","1"],["𝟮","2"],["𝟯","3"],["𝟰","4"],["𝟱","5"],["𝟲","6"],["𝟳","7"],["𝟴","8"],["𝟵","9"],["𝟶","0"],["𝟷","1"],["𝟸","2"],["𝟹","3"],["𝟺","4"],["𝟻","5"],["𝟼","6"],["𝟽","7"],["𝟾","8"],["𝟿","9"],["①","1"],["②","2"],["③","3"],["④","4"],["⑤","5"],["⑥","6"],["⑦","7"],["⑧","8"],["⑨","9"],["⑩","10"],["⑪","11"],["⑫","12"],["⑬","13"],["⑭","14"],["⑮","15"],["⑯","16"],["⑰","17"],["⑱","18"],["⑲","19"],["⑳","20"],["⑴","1"],["⑵","2"],["⑶","3"],["⑷","4"],["⑸","5"],["⑹","6"],["⑺","7"],["⑻","8"],["⑼","9"],["⑽","10"],["⑾","11"],["⑿","12"],["⒀","13"],["⒁","14"],["⒂","15"],["⒃","16"],["⒄","17"],["⒅","18"],["⒆","19"],["⒇","20"],["⒈","1."],["⒉","2."],["⒊","3."],["⒋","4."],["⒌","5."],["⒍","6."],["⒎","7."],["⒏","8."],["⒐","9."],["⒑","10."],["⒒","11."],["⒓","12."],["⒔","13."],["⒕","14."],["⒖","15."],["⒗","16."],["⒘","17."],["⒙","18."],["⒚","19."],["⒛","20."],["⓪","0"],["⓫","11"],["⓬","12"],["⓭","13"],["⓮","14"],["⓯","15"],["⓰","16"],["⓱","17"],["⓲","18"],["⓳","19"],["⓴","20"],["⓵","1"],["⓶","2"],["⓷","3"],["⓸","4"],["⓹","5"],["⓺","6"],["⓻","7"],["⓼","8"],["⓽","9"],["⓾","10"],["⓿","0"],["🙰","&"],["🙱","&"],["🙲","&"],["🙳","&"],["🙴","&"],["🙵","&"],["🙶",'"'],["🙷",'"'],["🙸",'"'],["‽","?!"],["🙹","?!"],["🙺","?!"],["🙻","?!"],["🙼","/"],["🙽","\\"],["🜇","AR"],["🜈","V"],["🜉","V"],["🜆","VR"],["🜅","VF"],["🜩","2"],["🜪","5"],["🝡","f"],["🝢","W"],["🝣","U"],["🝧","V"],["🝨","T"],["🝪","V"],["🝫","MB"],["🝬","VB"],["🝲","3B"],["🝳","3B"],["💯","100"],["🔙","BACK"],["🔚","END"],["🔛","ON!"],["🔜","SOON"],["🔝","TOP"],["🔞","18"],["🔤","abc"],["🔠","ABCD"],["🔡","abcd"],["🔢","1234"],["🔣","T&@%"],["#️⃣","#"],["*️⃣","*"],["0️⃣","0"],["1️⃣","1"],["2️⃣","2"],["3️⃣","3"],["4️⃣","4"],["5️⃣","5"],["6️⃣","6"],["7️⃣","7"],["8️⃣","8"],["9️⃣","9"],["🔟","10"],["🅰️","A"],["🅱️","B"],["🆎","AB"],["🆑","CL"],["🅾️","O"],["🅿","P"],["🆘","SOS"],["🅲","C"],["🅳","D"],["🅴","E"],["🅵","F"],["🅶","G"],["🅷","H"],["🅸","I"],["🅹","J"],["🅺","K"],["🅻","L"],["🅼","M"],["🅽","N"],["🆀","Q"],["🆁","R"],["🆂","S"],["🆃","T"],["🆄","U"],["🆅","V"],["🆆","W"],["🆇","X"],["🆈","Y"],["🆉","Z"]],cf=[["&"," and "],["🦄"," unicorn "],["♥"," love "]];function uf(e,t){if("string"!=typeof e)throw new TypeError(`Expected a string, got \`${typeof e}\``);const n=(t={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],...t}).preserveLeadingUnderscore&&e.startsWith("_"),r=t.preserveTrailingDash&&e.endsWith("-");e=function(e,t){if("string"!=typeof e)throw new TypeError(`Expected a string, got \`${typeof e}\``);t={customReplacements:[],...t};const n=new Map([...af,...t.customReplacements]);return(e=((e,t)=>{for(const[n,r]of t)e=e.replace(new RegExp(lf(n),"g"),r);return e})(e=e.normalize(),n)).normalize("NFD").replace(/\p{Diacritic}/gu,"").normalize()}(e,{customReplacements:new Map([...cf,...t.customReplacements])}),t.decamelize&&(e=(e=>e.replace(/([A-Z]{2,})(\d+)/g,"$1 $2").replace(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"))(e));const o=(e=>{let t="a-z\\d";if(t+=e.lowercase?"":"A-Z",e.preserveCharacters.length>0)for(const n of e.preserveCharacters){if(n===e.separator)throw new Error(`The separator character \`${e.separator}\` cannot be included in preserved characters: ${e.preserveCharacters}`);t+=lf(n)}return new RegExp(`[^${t}]+`,"g")})(t);return t.lowercase&&(e=e.toLowerCase()),e=(e=(e=e.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g,"$1$2$3")).replace(o,t.separator)).replace(/\\/g,""),t.separator&&(e=((e,t)=>{const n=lf(t);return e.replace(new RegExp(`${n}{2,}`,"g"),t).replace(new RegExp(`^${n}|${n}$`,"g"),"")})(e,t.separator)),n&&(e=`_${e}`),r&&(e=`${e}-`),e}function df(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,(t=>t.childCount>0&&t.firstChild.type==e));return!!i&&(!n||(r.node(i.depth-1).type==e?function(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new ds(i-1,s,i,s,new Be(De.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new et(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const l=ms(r);if(null==l)return!1;o.lift(r,l);let a=o.mapping.map(i,-1)-1;return bs(o.doc,a)&&o.join(a),t(o.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?De.empty:De.from(o))))return!1;let d=i.pos,h=d+s.nodeSize;return r.step(new ds(d-(l?1:0),h+(a?1:0),d+1,h-1,new Be((l?De.empty:De.from(o.copy(De.empty))).append(a?De.empty:De.from(o.copy(De.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}(t,n,i)))}}function hf(e){return String(e||"").toUpperCase()}function pf(){return function(e){const t=function(e){const t=new Map;if(!e||!e.type)throw new Error("mdast-util-definitions expected node");return ao(e,"definition",(function(e){const n=hf(e.identifier);n&&!t.get(n)&&t.set(n,e)})),function(e){const n=hf(e);return t.get(n)}}(e);ao(e,(function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[so,n];if("imageReference"===e.type||"linkReference"===e.type){const o=t(e.identifier);if(o&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:o.url,title:o.title,alt:e.alt}:{type:"link",url:o.url,title:o.title,children:e.children},[so,n]}}))}}function ff(e,t){var n;if(!(t.childCount>=1&&"hardbreak"===(null==(n=t.lastChild)?void 0:n.type.name)))return void e.next(t.content);const r=[];t.content.forEach(((e,n,o)=>{o!==t.childCount-1&&r.push(e)})),e.next(De.fromArray(r))}function mf(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}const gf=Yp("emphasis");mf(gf,{displayName:"Attr<emphasis>",group:"Emphasis"});const yf=Kp("emphasis",(e=>({attrs:{marker:{default:e.get(yh).emphasis||"*"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(gf.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}})));mf(yf.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),mf(yf.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});const wf=Ep("ToggleEmphasis",(e=>()=>Sa(yf.type(e))));mf(wf,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});const kf=Dp((e=>zl(/(?:^|[^*])\*([^*]+)\*$/,yf.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}})));mf(kf,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});const vf=Dp((e=>zl(/(?:^|[^_])_([^_]+)_$/,yf.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}})));mf(vf,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});const bf=Up("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(Rh);return()=>t.call(wf.key)}}});mf(bf.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),mf(bf.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});const xf=Yp("strong");mf(xf,{displayName:"Attr<strong>",group:"Strong"});const Cf=Kp("strong",(e=>({attrs:{marker:{default:e.get(yh).strong||"*"}},parseDOM:[{tag:"b"},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e}],toDOM:t=>["strong",e.get(xf.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}})));mf(Cf.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),mf(Cf.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});const Sf=Ep("ToggleStrong",(e=>()=>Sa(Cf.type(e))));mf(Sf,{displayName:"Command<toggleStrongCommand>",group:"Strong"});const Mf=Dp((e=>zl(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/,Cf.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})})));mf(Mf,{displayName:"InputRule<strong>",group:"Strong"});const Nf=Up("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(Rh);return()=>t.call(Sf.key)}}});mf(Nf.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),mf(Nf.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});const Tf=Yp("inlineCode");mf(Tf,{displayName:"Attr<inlineCode>",group:"InlineCode"});const Of=Kp("inlineCode",(e=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(Tf.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>{e.withMark(t,"inlineCode",n.text||"")}}})));mf(Of.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),mf(Of.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});const Af=Ep("ToggleInlineCode",(e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(r.empty)return!1;const{from:i,to:s}=r;return t.doc.rangeHasMark(i,s,Of.type(e))?(null==n||n(o.removeMark(i,s,Of.type(e))),!0):(Object.keys(t.schema.marks).filter((e=>e!==Of.type.name)).map((e=>t.schema.marks[e])).forEach((e=>{o.removeMark(i,s,e)})),null==n||n(o.addMark(i,s,Of.type(e).create())),!0)}));mf(Af,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});const Ef=Dp((e=>zl(/(?:`)([^`]+)(?:`)$/,Of.type(e))));mf(Ef,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});const If=Up("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(Rh);return()=>t.call(Af.key)}}});mf(If.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),mf(If.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});const Df=Yp("link");mf(Df,{displayName:"Attr<link>",group:"Link"});const Rf=Kp("link",(e=>({attrs:{href:{},title:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(Df.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const r=t.url,o=t.title;e.openMark(n,{href:r,title:o}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}})));mf(Rf.mark,{displayName:"MarkSchema<link>",group:"Link"});const Pf=Ep("ToggleLink",(e=>(t={})=>Sa(Rf.type(e),t)));mf(Pf,{displayName:"Command<toggleLinkCommand>",group:"Link"});const $f=Ep("UpdateLink",(e=>(t={})=>(n,r)=>{if(!r)return!1;let o,i=-1;const{selection:s}=n,{from:l,to:a}=s;if(n.doc.nodesBetween(l,l===a?a+1:a,((t,n)=>{if(Rf.type(e).isInSet(t.marks))return o=t,i=n,!1})),!o)return!1;const c=o.marks.find((({type:t})=>t===Rf.type(e)));if(!c)return!1;const u=i,d=i+o.nodeSize,{tr:h}=n,p=Rf.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(u,d,c).addMark(u,d,p).setSelection(new qs(h.selection.$anchor)).scrollIntoView()),!0)}));mf($f,{displayName:"Command<updateLinkCommand>",group:"Link"});const Lf=Lp("doc",(()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}})));mf(Lf,{displayName:"NodeSchema<doc>",group:"Doc"});const zf=Jp("paragraph");mf(zf,{displayName:"Attr<paragraph>",group:"Paragraph"});const Bf=qp("paragraph",(e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(zf.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(e,t)=>{e.openNode("paragraph"),ff(e,t),e.closeNode()}}})));mf(Bf.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),mf(Bf.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});const Ff=Ep("TurnIntoText",(e=>()=>Ca(Bf.type(e))));mf(Ff,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});const jf=Up("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(Rh);return()=>t.call(Ff.key)}}});mf(jf.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),mf(jf.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});const _f=Array(6).fill(0).map(((e,t)=>t+1)),Wf=Hp((function(e){return uf(e.textContent)}),"headingIdGenerator");mf(Wf,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});const Vf=Jp("heading");mf(Vf,{displayName:"Attr<heading>",group:"Heading"});const Hf=qp("heading",(e=>{const t=e.get(Wf.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:""},level:{default:1}},parseDOM:_f.map((e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw _(t);return{level:e,id:t.id}}}))),toDOM:n=>[`h${n.attrs.level}`,{...e.get(Vf.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),ff(e,t),e.closeNode()}}}}));mf(Hf.node,{displayName:"NodeSchema<heading>",group:"Heading"}),mf(Hf.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});const qf=Dp((e=>pl(/^(?<hashes>#+)\s$/,Hf.type(e),(t=>{var n,r;const o=(null==(r=null==(n=t.groups)?void 0:n.hashes)?void 0:r.length)||0,i=e.get(lh),{$from:s}=i.state.selection,l=s.node();if("heading"===l.type.name){let e=Number(l.attrs.level)+Number(o);return e>6&&(e=6),{level:e}}return{level:o}}))));mf(qf,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});const Kf=Ep("WrapInHeading",(e=>t=>(t??(t=1),t<1?Ca(Bf.type(e)):Ca(Hf.type(e),{level:t}))));mf(Kf,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});const Uf=Ep("DowngradeHeading",(e=>()=>(t,n,r)=>{const{$from:o}=t.selection,i=o.node();if(i.type!==Hf.type(e)||!t.selection.empty||0!==o.parentOffset)return!1;const s=i.attrs.level-1;return s?(null==n||n(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...i.attrs,level:s})),!0):Ca(Bf.type(e))(t,n,r)}));mf(Uf,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});const Jf=Up("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(Rh);return()=>t.call(Kf.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(Rh);return()=>t.call(Kf.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(Rh);return()=>t.call(Kf.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(Rh);return()=>t.call(Kf.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(Rh);return()=>t.call(Kf.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(Rh);return()=>t.call(Kf.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(Rh);return()=>t.call(Uf.key)}}});mf(Jf.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),mf(Jf.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});const Yf=Jp("blockquote");mf(Yf,{displayName:"Attr<blockquote>",group:"Blockquote"});const Gf=qp("blockquote",(e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(Yf.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}})));mf(Gf.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),mf(Gf.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});const Xf=Dp((e=>hl(/^\s*>\s$/,Gf.type(e))));mf(Xf,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});const Zf=Ep("WrapInBlockquote",(e=>()=>xa(Gf.type(e))));mf(Zf,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});const Qf=Up("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(Rh);return()=>t.call(Zf.key)}}});mf(Qf.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),mf(Qf.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});const em=Jp("codeBlock",(()=>({pre:{},code:{}})));mf(em,{displayName:"Attr<codeBlock>",group:"CodeBlock"});const tm=qp("code_block",(e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(em.key)(t);return["pre",{...n.pre,"data-language":t.attrs.language},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const r=t.lang,o=t.value;e.openNode(n,{language:r}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{var n;e.addNode("code",void 0,(null==(n=t.content.firstChild)?void 0:n.text)||"",{lang:t.attrs.language})}}})));mf(tm.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),mf(tm.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});const nm=Dp((e=>pl(/^```(?<language>[a-z]*)?[\s\n]$/,tm.type(e),(e=>{var t;return{language:(null==(t=e.groups)?void 0:t.language)??""}}))));mf(nm,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});const rm=Ep("CreateCodeBlock",(e=>(t="")=>Ca(tm.type(e),{language:t})));mf(rm,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});const om=Ep("UpdateCodeBlockLanguage",(()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(null==r||r(n.tr.setNodeAttribute(e,"language",t)),!0)));mf(om,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});const im=Up("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(Rh);return()=>t.call(rm.key)}}});mf(im.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),mf(im.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});const sm=Jp("image");mf(sm,{displayName:"Attr<image>",group:"Image"});const lm=qp("image",(e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:""},alt:{default:""},title:{default:""}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(sm.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const r=t.url,o=t.alt,i=t.title;e.addNode(n,{src:r,alt:o,title:i})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}})));mf(lm.node,{displayName:"NodeSchema<image>",group:"Image"}),mf(lm.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});const am=Ep("InsertImage",(e=>(t={})=>(n,r)=>{if(!r)return!0;const{src:o="",alt:i="",title:s=""}=t,l=lm.type(e).create({src:o,alt:i,title:s});return l&&r(n.tr.replaceSelectionWith(l).scrollIntoView()),!0}));mf(am,{displayName:"Command<insertImageCommand>",group:"Image"});const cm=Ep("UpdateImage",(e=>(t={})=>(n,r)=>{const o=ca(n.selection,lm.type(e));if(!o)return!1;const{node:i,pos:s}=o,l={...i.attrs},{src:a,alt:c,title:u}=t;return void 0!==a&&(l.src=a),void 0!==c&&(l.alt=c),void 0!==u&&(l.title=u),null==r||r(n.tr.setNodeMarkup(s,void 0,l).scrollIntoView()),!0}));mf(cm,{displayName:"Command<updateImageCommand>",group:"Image"});const um=Dp((e=>new ul(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,((t,n,r,o)=>{const[i,s,l="",a]=n;return i?t.tr.replaceWith(r,o,lm.type(e).create({src:l,alt:s,title:a})):null}))));mf(um,{displayName:"InputRule<insertImageInputRule>",group:"Image"});const dm=Jp("hardbreak",(e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline})));mf(dm,{displayName:"Attr<hardbreak>",group:"Hardbreak"});const hm=qp("hardbreak",(e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(dm.key)(t)," "]:["br",e.get(dm.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{var r;e.addNode(n,{isInline:!(null==(r=t.data)||!r.isInline)})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}})));mf(hm.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),mf(hm.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});const pm=Ep("InsertHardbreak",(e=>()=>(t,n)=>{var r;const{selection:o,tr:i}=t;if(!(o instanceof qs))return!1;if(o.empty){const e=o.$from.node();if(e.childCount>0&&"hardbreak"===(null==(r=e.lastChild)?void 0:r.type.name))return null==n||n(i.replaceRangeWith(o.to-1,o.to,t.schema.node("paragraph")).setSelection(_s.near(i.doc.resolve(o.to))).scrollIntoView()),!0}return null==n||n(i.setMeta("hardbreak",!0).replaceSelectionWith(hm.type(e).create()).scrollIntoView()),!0}));mf(pm,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});const fm=Up("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(Rh);return()=>t.call(pm.key)}}});mf(fm.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),mf(fm.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});const mm=Jp("hr");mf(mm,{displayName:"Attr<hr>",group:"Hr"});const gm=qp("hr",(e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(mm.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}})));mf(gm.node,{displayName:"NodeSchema<hr>",group:"Hr"}),mf(gm.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});const ym=Dp((e=>new ul(/^(?:---|___\s|\*\*\*\s)$/,((t,n,r,o)=>{const{tr:i}=t;return n[0]&&i.replaceWith(r-1,o,gm.type(e).create()),i}))));mf(ym,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});const wm=Ep("InsertHr",(e=>()=>(t,n)=>{if(!n)return!0;const r=Bf.node.type(e).create(),{tr:o,selection:i}=t,{from:s}=i,l=gm.type(e).create();if(!l)return!0;const a=o.replaceSelectionWith(l).insert(s,r),c=_s.findFrom(a.doc.resolve(s),1,!0);return c&&n(a.setSelection(c).scrollIntoView()),!0}));mf(wm,{displayName:"Command<insertHrCommand>",group:"Hr"});const km=Jp("bulletList");mf(km,{displayName:"Attr<bulletList>",group:"BulletList"});const vm=qp("bullet_list",(e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{spread:e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(km.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:"true"===t.attrs.spread}).next(t.content).closeNode()}}})));mf(vm.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),mf(vm.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});const bm=Dp((e=>hl(/^\s*([-+*])\s$/,vm.type(e))));mf(bm,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});const xm=Ep("WrapInBulletList",(e=>()=>xa(vm.type(e))));mf(xm,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});const Cm=Up("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(Rh);return()=>t.call(xm.key)}}});mf(Cm.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),mf(Cm.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});const Sm=Jp("orderedList");mf(Sm,{displayName:"Attr<orderedList>",group:"OrderedList"});const Mm=qp("ordered_list",(e=>({content:"listItem+",group:"block",attrs:{order:{default:1},spread:{default:!1}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(Sm.key)(t),...1===t.attrs.order?{}:t.attrs.order,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}})));mf(Mm.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),mf(Mm.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});const Nm=Dp((e=>hl(/^\s*(\d+)\.\s$/,Mm.type(e),(e=>({order:Number(e[1])})),((e,t)=>t.childCount+t.attrs.order===Number(e[1])))));mf(Nm,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});const Tm=Ep("WrapInOrderedList",(e=>()=>xa(Mm.type(e))));mf(Tm,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});const Om=Up("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(Rh);return()=>t.call(Tm.key)}}});mf(Om.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),mf(Om.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});const Am=Jp("listItem");mf(Am,{displayName:"Attr<listItem>",group:"ListItem"});const Em=qp("list_item",(e=>({group:"listItem",content:"(paragraph|blockquote) block*",attrs:{label:{default:"•"},listType:{default:"bullet"},spread:{default:"true"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread}}}],toDOM:t=>["li",{...e.get(Am.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{const r=null!=t.label?`${t.label}.`:"•",o=null!=t.label?"ordered":"bullet",i=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:r,listType:o,spread:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}})));mf(Em.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),mf(Em.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});const Im=Ep("SinkListItem",(e=>()=>{return t=Em.type(e),function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let r=a.lastChild&&a.lastChild.type==l.type,o=De.from(r?t.create():null),s=new Be(De.from(t.create(null,De.from(l.type.create(null,o)))),r?3:1,0),c=i.start,u=i.end;n(e.tr.step(new ds(c-(r?3:1),u,c,u,s,1,!0)).scrollIntoView())}return!0};var t}));mf(Im,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});const Dm=Ep("LiftListItem",(e=>()=>df(Em.type(e))));mf(Dm,{displayName:"Command<liftListItemCommand>",group:"ListItem"});const Rm=Ep("SplitListItem",(e=>()=>{return t=Em.type(e),function(e,r){let{$from:o,$to:i,node:s}=e.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(l.type!=t)return!1;if(0==o.parent.content.size&&o.node(-1).childCount==o.indexAfter(-1)){if(3==o.depth||o.node(-3).type!=t||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let n=De.empty,i=o.index(-1)?1:o.index(-2)?2:3;for(let e=o.depth-i;e>=o.depth-3;e--)n=De.from(o.node(e).copy(n));let s=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;n=n.append(De.from(t.createAndFill()));let l=o.before(o.depth-(i-1)),a=e.tr.replace(l,o.after(-s),new Be(n,4-i,0)),c=-1;a.doc.nodesBetween(l,a.doc.content.size,((e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)})),c>-1&&a.setSelection(_s.near(a.doc.resolve(c))),r(a.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=e.tr.delete(o.pos,i.pos),u=a?[n?{type:t,attrs:n}:null,{type:a}]:void 0;return!!vs(c.doc,o.pos,2,u)&&(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0)};var t,n}));mf(Rm,{displayName:"Command<splitListItemCommand>",group:"ListItem"});const Pm=Ep("LiftFirstListItem",(e=>()=>function(e){return(t,n,r)=>{const{selection:o}=t;if(!(o instanceof qs))return!1;const{empty:i,$from:s}=o;if(!i||0!==s.parentOffset)return!1;const l=s.node(-1);return!(l.type!==Em.type(e)||l.firstChild!==s.node()||s.node(-2).childCount>1)&&df(Em.type(e))(t,n,r)}}(e)));mf(Pm,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});const $m=Up("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(Rh);return()=>t.call(Rm.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(Rh);return()=>t.call(Im.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(Rh);return()=>t.call(Dm.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(Rh);return()=>t.call(Pm.key)}}});mf($m.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),mf($m.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});const Lm=Lp("text",(()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}})));mf(Lm,{displayName:"NodeSchema<text>",group:"Text"});const zm=Jp("html");mf(zm,{displayName:"Attr<html>",group:"Html"});const Bm=qp("html",(e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:""}},toDOM:t=>{const n=document.createElement("span"),r={...e.get(zm.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>"html"===e,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}})));mf(Bm.node,{displayName:"NodeSchema<html>",group:"Html"}),mf(Bm.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});const Fm=[Lf,zf,Bf,Wf,Vf,Hf,dm,hm,Yf,Gf,em,tm,mm,gm,sm,lm,km,vm,Sm,Mm,Am,Em,gf,yf,xf,Cf,Tf,Of,Df,Rf,zm,Bm,Lm].flat(),jm=[Xf,bm,Nm,nm,ym,qf].flat(),_m=[kf,vf,Ef,Mf],Wm=[Ff,Zf,Kf,Uf,rm,pm,wm,am,cm,Tm,xm,Im,Rm,Dm,Pm,wf,Af,Sf,Pf,$f],Vm=[Qf,im,fm,Jf,$m,Om,Cm,jf,bf,If,Nf].flat(),Hm=Gp("remarkAddOrderInList",(()=>()=>e=>{ao(e,"list",(e=>{if(e.ordered){const t=e.start??1;e.children.forEach(((e,n)=>{e.label=n+t}))}}))}));mf(Hm.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),mf(Hm.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});const qm=Gp("remarkLineBreak",(()=>()=>e=>{const t=/[\t ]*(?:\r?\n|\r)/g;ao(e,"text",((e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;const o=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&o.push({type:"text",value:e.value.slice(i,n)}),o.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return o.length>0&&r&&"number"==typeof n?(i<e.value.length&&o.push({type:"text",value:e.value.slice(i)}),r.children.splice(n,1,...o),n+o.length):void 0}))}));mf(qm.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),mf(qm.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});const Km=Gp("remarkInlineLink",(()=>pf));mf(Km.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),mf(Km.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});const Um=Gp("remarkHTMLTransformer",(()=>()=>e=>{!function(e,t){(function e(t,n,r){if((e=>!!e.children)(t)){const n=[];for(let r=0,o=t.children.length;r<o;r++){const o=t.children[r];if(o){const i=e(o,r,t);if(i)for(let e=0,t=i.length;e<t;e++){const t=i[e];t&&n.push(t)}}}t.children=n}return((e,t,n)=>(e=>"html"===e.type)(e)?("root"===(null==n?void 0:n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])(t,0,r)})(e,0,null)[0]}(e)}));mf(Um.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),mf(Um.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});const Jm=Gp("remarkMarker",(()=>()=>(e,t)=>{ao(e,(e=>["strong","emphasis"].includes(e.type)),(e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)}))}));mf(Jm.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),mf(Jm.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});const Ym=Bp((()=>{let e=!1;const t=new cl("MILKDOWN_INLINE_NODES_CURSOR"),n=new sl({key:t,state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!(!(n&&r&&n.isInline&&!n.isText&&r.isInline)||r.isText)}},props:{handleDOMEvents:{compositionend:(t,r)=>!!e&&(e=!1,requestAnimationFrame((()=>{if(n.getState(t.state)){const e=t.state.selection.from;r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e))}})),!0),compositionstart:t=>(n.getState(t.state)&&(e=!0),!1),beforeinput:(t,r)=>{if(n.getState(t.state)&&r instanceof InputEvent&&r.data&&!e){const e=t.state.selection.from;return r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(n.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),r=kd.widget(t,n,{side:-1}),o=document.createElement("span"),i=kd.widget(t,o);return setTimeout((()=>{n.contentEditable="true",o.contentEditable="true"})),xd.create(e.doc,[r,i])}return xd.empty}}});return n}));mf(Ym,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});const Gm=Bp((e=>new sl({key:new cl("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;const[o]=t;if(!o)return;const[i]=o.steps;if(o.getMeta("hardbreak")){if(!(i instanceof us))return;const{from:t}=i;return r.tr.setNodeMarkup(t,hm.type(e),void 0,[])}if(i instanceof ss){let t=r.tr;const{from:n,to:o}=i;return r.doc.nodesBetween(n,o,((n,r)=>{n.type===hm.type(e)&&(t=t.setNodeMarkup(r,hm.type(e),void 0,[]))})),t}}})));mf(Gm,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});const Xm=Hp(["table","code_block"],"hardbreakFilterNodes");mf(Xm,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});const Zm=Bp((e=>{const t=e.get(Xm.key);return new sl({key:new cl("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const r=e.getMeta("hardbreak"),[o]=e.steps;if(r&&o){const{from:e}=o,r=n.doc.resolve(e);let i=r.depth,s=!0;for(;i>0;)t.includes(r.node(i).type.name)&&(s=!1),i--;return s}return!0}})}));mf(Zm,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});const Qm=Bp((e=>{const t=new cl("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const r=e.get(Wf.key),o=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants(((n,l)=>{if(n.type===Hf.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let a=r(n);s[a]?(s[a]+=1,a+=`-#${s[a]}`):s[a]=1,e.id!==a&&(i=!0,o.setMeta(t,!0).setNodeMarkup(l,void 0,{...e,id:a}))}})),i&&n.dispatch(o)};return new sl({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})}));mf(Qm,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});const eg=Bp((e=>{const t=t=>{if(t.composing||!t.editable)return;const n=Mm.type(e),r=vm.type(e),o=Em.type(e),i=t.state,s=(e,t)=>{let n=!1;const r=`${t+1}.`;return e.label!==r&&(e.label=r,n=!0),n};let l=i.tr,a=!1;i.doc.descendants(((e,t,i,c)=>{if(e.type===r){const r=e.maybeChild(0);(null==r?void 0:r.type)===o&&"ordered"===r.attrs.listType&&(a=!0,l.setNodeMarkup(t,n,{spread:"true"}),e.descendants(((e,t,n,r)=>{if(e.type===o){const n={...e.attrs};s(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1})))}else if(e.type===o&&(null==i?void 0:i.type)===n){const n={...e.attrs};let r=!1;"ordered"!==n.listType&&(n.listType="ordered",r=!0),(null==i?void 0:i.maybeChild(0))&&(r=s(n,c)),r&&(l=l.setNodeMarkup(t,void 0,n),a=!0)}})),a&&t.dispatch(l.setMeta("addToHistory",!1))};return new sl({key:new cl("MILKDOWN_KEEP_LIST_ORDER"),view:e=>(t(e),{update:e=>{t(e)}})})}));mf(eg,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});const tg=[Gm,Xm,Zm,Ym,Hm,Km,qm,Um,Jm,Qm,eg].flat(),ng=[Fm,jm,_m,Wm,Vm,tg].flat();var rg,og;if("undefined"!=typeof WeakMap){let e=new WeakMap;rg=t=>e.get(t),og=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;rg=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},og=(r,o)=>(n==t&&(n=0),e[n++]=r,e[n++]=o)}var ig=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,o=t/this.width|0;let i=r+1,s=o+1;for(let e=1;i<this.width&&this.map[t+e]==n;e++)i++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==r:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?0==i:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:r,top:o,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==e){let n=t+e*this.width;const r=(e+1)*this.width;for(;n<r&&this.map[n]<o;)n++;return n==r?i-1:this.map[n]}o=i}}static get(e){return rg(e)||og(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const o=e.child(r);let i=0;if(n)for(let t=0;t<r;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const o=n.child(e);t+o.attrs.rowspan>r&&(i+=o.attrs.colspan)}}for(let e=0;e<o.childCount;e++){const t=o.child(e);i+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,r=[];let o=0,i=null;const s=[];for(let e=0,o=t*n;e<o;e++)r[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;o<r.length&&0!=r[o];)o++;if(e==c.childCount)break;const u=c.child(e),{colspan:d,rowspan:h,colwidth:p}=u.attrs;for(let e=0;e<h;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:h-e});break}const c=o+e*t;for(let e=0;e<d;e++){0==r[c+e]?r[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:d-e});const n=p&&p[e];if(n){const r=(c+e)%t*2,o=s[r];null==o||o!=n&&1==s[r+1]?(s[r]=n,s[r+1]=1):o==n&&s[r+1]++}}}o+=d,a+=u.nodeSize}const u=(l+1)*t;let d=0;for(;o<u;)0==r[o++]&&d++;d&&(i||(i=[])).push({type:"missing",row:l,n:d}),a++}0!==t&&0!==n||(i||(i=[])).push({type:"zero_sized"});const l=new ig(t,n,r,i);let a=!1;for(let e=0;!a&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(a=!0);return a&&function(e,t,n){e.problems||(e.problems=[]);const r={};for(let o=0;o<e.map.length;o++){const i=e.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const r=t[(o+n)%e.width*2];null==r||a.colwidth&&a.colwidth[n]==r||((l||(l=sg(a)))[n]=r)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e),l}(e))}};function sg(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function lg(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map((e=>Number(e))):null,o=Number(e.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const n in t){const r=t[n].getFromDOM,o=r&&r(e);null!=o&&(i[n]=o)}return i}function ag(e,t){const n={};1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(const r in t){const o=t[r].setDOMAttr;o&&o(e.attrs[r],n)}return n}function cg(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}var ug=new cl("selectingCells");function dg(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function hg(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function pg(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=dg(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function fg(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function mg(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function gg(e,t,n){const r=e.node(-1),o=ig.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function yg(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some((e=>e>0))||(r.colwidth=null)),r}function wg(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}var kg=class e extends _s{constructor(e,t=e){const n=e.node(-1),r=ig.get(n),o=e.start(-1),i=r.rectBetween(e.pos-o,t.pos-o),s=e.node(0),l=r.cellsInRect(i).filter((e=>e!=t.pos-o));l.unshift(t.pos-o);const a=l.map((e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const r=o+e+1;return new Ws(s.resolve(r),s.resolve(r+t.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=t}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),o=t.resolve(n.map(this.$headCell.pos));if(fg(r)&&fg(o)&&mg(r,o)){const t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,o):t&&this.isColSelection()?e.colSelection(r,o):new e(r,o)}return qs.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=ig.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[];for(let n=r.top;n<r.bottom;n++){const s=[];for(let i=n*t.width+r.left,l=r.left;l<r.right;l++,i++){const n=t.map[i];if(o[n])continue;o[n]=!0;const l=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=r.left-l.left,u=l.right-r.right;if(c>0||u>0){let e=a.attrs;if(c>0&&(e=yg(e,0,c)),u>0&&(e=yg(e,e.colspan-u,u)),l.left<r.left){if(a=a.type.createAndFill(e),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else a=a.type.create(e,a.content)}if(l.top<r.top||l.bottom>r.bottom){const e={...a.attrs,rowspan:Math.min(l.bottom,r.bottom)-Math.max(l.top,r.top)};a=l.top<r.top?a.type.createAndFill(e):a.type.create(e,a.content)}s.push(a)}i.push(e.child(n).copy(De.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?e:i;return new Be(De.from(s),1,1)}replace(e,t=Be.empty){const n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){const{$from:i,$to:s}=r[o],l=e.mapping.slice(n);e.replace(l.map(i.pos),l.map(s.pos),o?Be.empty:t)}const o=_s.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new Be(De.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=ig.get(t),r=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<o.length;n++)e(t.nodeAt(o[n]),r+o[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),o=ig.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=ig.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(r,o)>0)return!1;const i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),o=ig.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(t=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new vg(this.$anchorCell.pos,this.$headCell.pos)}};kg.prototype.visible=!1,_s.jsonID("cell",kg);var vg=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&mg(t,n)?new kg(t,n):_s.near(n,1)}};function bg(e){if(!(e.selection instanceof kg))return null;const t=[];return e.selection.forEachCell(((e,n)=>{t.push(kd.node(n,n+e.nodeSize,{class:"selectedCell"}))})),xd.create(e.doc,t)}var xg=new cl("fix-tables");function Cg(e,t,n,r){const o=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){const i=t.child(s);for(let t=l,r=Math.min(o,s+3);t<r;t++)if(e.child(t)==i){l=t+1,n+=i.nodeSize;continue e}r(i,n),l<o&&e.child(l).sameMarkup(i)?Cg(e.child(l),i,n+1,r):i.nodesBetween(0,i.content.size,r,n+1),n+=i.nodeSize}}function Sg(e,t){let n;const r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){const o=ig.get(t);if(!o.problems)return r;r||(r=e.tr);const i=[];for(let e=0;e<o.height;e++)i.push(0);for(let e=0;e<o.problems.length;e++){const s=o.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const o=e.attrs;for(let e=0;e<o.rowspan;e++)i[s.row+e]+=s.n;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,yg(o,o.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let s,l;for(let e=0;e<i.length;e++)i[e]&&(null==s&&(s=e),l=e);for(let a=0,c=n+1;a<o.height;a++){const n=t.child(a),o=c+n.nodeSize,u=i[a];if(u>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<u;n++){const n=cg(e.schema)[t].createAndFill();n&&i.push(n)}const d=0!=a&&s!=a-1||l!=a?o-1:c+1;r.insert(r.mapping.map(d),i)}c=o}return r.setMeta(xg,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&Cg(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Mg(e){const t=e.selection,n=pg(e),r=n.node(-1),o=n.start(-1),i=ig.get(r);return{...t instanceof kg?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Ng(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;(function(e,t,n){const r=cg(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0})(t,r,o+i)&&(i=0==o||o==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=r.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,wg(a.attrs,o-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?cg(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,c=t.positionAt(s,o,r);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function Tg(e,t){if(!hg(e))return!1;if(t){const n=Mg(e);t(Ng(e.tr,n,n.left))}return!0}function Og(e,t){if(!hg(e))return!1;if(t){const n=Mg(e);t(Ng(e.tr,n,n.right))}return!0}function Ag(e,{map:t,table:n,tableStart:r},o){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+o,a=t.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,yg(u,o-t.colCount(a)));else{const t=e.mapping.slice(i).map(r+a);e.delete(t,t+c.nodeSize)}s+=u.rowspan}}function Eg(e,{map:t,table:n,tableStart:r},o){let i=0;for(let e=0;e<o;e++)i+=n.child(e).nodeSize;const s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);const a=new Set;for(let i=0,s=o*t.width;i<t.width;i++,s++){const c=t.map[s];if(!a.has(c))if(a.add(c),o>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(l).map(c+r),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(o<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),a=s.attrs,u=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),d=t.positionAt(o+1,i,n);e.insert(e.mapping.slice(l).map(r+d),u),i+=a.colspan-1}}}function Ig(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<r.length;e++){const o=t.table.nodeAt(r[e]);if(o&&o.type!==n.header_cell)return!1}return!0}function Dg(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!hg(t))return!1;if(n){const r=cg(t.schema),o=Mg(t),i=t.tr,s=o.map.cellsInRect("column"==e?{left:o.left,top:0,right:o.right,bottom:o.map.height}:"row"==e?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map((e=>o.table.nodeAt(e)));for(let e=0;e<s.length;e++)l[e].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[e],r.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(o.tableStart+s[e],r.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!hg(t))return!1;if(n){const r=cg(t.schema),o=Mg(t),i=t.tr,s=Ig("row",o,r),l=Ig("column",o,r),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:o.map.height}:"row"==e?{left:a,top:0,right:o.map.width,bottom:1}:o,u="column"==e?l?r.cell:r.header_cell:"row"==e?s?r.cell:r.header_cell:r.cell;o.map.cellsInRect(c).forEach((e=>{const t=e+o.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,u,n.attrs)})),n(i)}return!0}}function Rg(e){return function(t,n){if(!hg(t))return!1;const r=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const r=e.node(-1).child(t),o=r.lastChild;if(o)return n-1-o.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}(pg(t),e);if(null==r)return!1;if(n){const e=t.doc.resolve(r);n(t.tr.setSelection(qs.between(e,(o=e,o.node(0).resolve(o.pos+o.nodeAfter.nodeSize)))).scrollIntoView())}var o;return!0}}function Pg(e,t){const n=e.selection;if(!(n instanceof kg))return!1;if(t){const r=e.tr,o=cg(e.schema).cell.createAndFill().content;n.forEachCell(((e,t)=>{e.content.eq(o)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new Be(o,0,0))})),r.docChanged&&t(r)}return!0}function $g(e,t){const n=e.createAndFill();return new Fs(n).replace(0,n.content.size,t).doc}function Lg(e,t,n,r,o,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=o;c<i;c++){const o=s*t.width+c,i=t.map[o];if(t.map[o-t.width]==i){a=!0;const o=n.nodeAt(i),{top:u,left:d}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+r),null,{...o.attrs,rowspan:s-u}),e.insert(e.mapping.slice(l).map(t.positionAt(s,d,n)),o.type.createAndFill({...o.attrs,rowspan:u+o.attrs.rowspan-s})),c+=o.attrs.colspan-1}}return a}function zg(e,t,n,r,o,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=o;c<i;c++){const o=c*t.width+s,i=t.map[o];if(t.map[o-1]==i){a=!0;const o=n.nodeAt(i),u=t.colCount(i),d=e.mapping.slice(l).map(i+r);e.setNodeMarkup(d,null,yg(o.attrs,s-u,o.attrs.colspan-(s-u))),e.insert(d+o.nodeSize,o.type.createAndFill(yg(o.attrs,0,s-u))),c+=o.attrs.rowspan-1}}return a}function Bg(e,t,n,r,o){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let s=ig.get(i);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=e.tr;let h=0;function p(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");s=ig.get(i),h=d.mapping.maps.length}(function(e,t,n,r,o,i,s){const l=cg(e.doc.type.schema);let a,c;if(o>t.width)for(let i=0,u=0;i<t.height;i++){const d=n.child(i);u+=d.nodeSize;const h=[];let p;p=null==d.lastChild||d.lastChild.type==l.cell?a||(a=l.cell.createAndFill()):c||(c=l.header_cell.createAndFill());for(let e=t.width;e<o;e++)h.push(p);e.insert(e.mapping.slice(s).map(u-1+r),h)}if(i>t.height){const u=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,o);e++){const o=!(e>=t.width)&&n.nodeAt(t.map[r+e]).type==l.header_cell;u.push(o?c||(c=l.header_cell.createAndFill()):a||(a=l.cell.createAndFill()))}const d=l.row.create(null,De.from(u)),h=[];for(let e=t.height;e<i;e++)h.push(d);e.insert(e.mapping.slice(s).map(r+n.nodeSize-2),h)}return!(!a&&!c)})(d,s,i,n,c,u,h)&&p(),Lg(d,s,i,n,a,c,l,h)&&p(),Lg(d,s,i,n,a,c,u,h)&&p(),zg(d,s,i,n,l,u,a,h)&&p(),zg(d,s,i,n,l,u,c,h)&&p();for(let e=l;e<u;e++){const t=s.positionAt(e,a,i),r=s.positionAt(e,c,i);d.replace(d.mapping.slice(h).map(t+n),d.mapping.slice(h).map(r+n),new Be(o.rows[e-l],0,0))}p(),d.setSelection(new kg(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(u-1,c-1,i)))),t(d)}Dg("row",{useDeprecatedLogic:!0}),Dg("column",{useDeprecatedLogic:!0}),Dg("cell",{useDeprecatedLogic:!0});var Fg=_a({ArrowLeft:_g("horiz",-1),ArrowRight:_g("horiz",1),ArrowUp:_g("vert",-1),ArrowDown:_g("vert",1),"Shift-ArrowLeft":Wg("horiz",-1),"Shift-ArrowRight":Wg("horiz",1),"Shift-ArrowUp":Wg("vert",-1),"Shift-ArrowDown":Wg("vert",1),Backspace:Pg,"Mod-Backspace":Pg,Delete:Pg,"Mod-Delete":Pg});function jg(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function _g(e,t){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof kg)return jg(n,r,_s.near(i.$headCell,t));if("horiz"!=e&&!i.empty)return!1;const s=Kg(o,e,t);if(null==s)return!1;if("horiz"==e)return jg(n,r,_s.near(n.doc.resolve(i.head+t),t));{const o=n.doc.resolve(s),i=gg(o,e,t);let l;return l=i?_s.near(i,1):t<0?_s.near(n.doc.resolve(o.before(-1)),-1):_s.near(n.doc.resolve(o.after(-1)),1),jg(n,r,l)}}}function Wg(e,t){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof kg)s=i;else{const r=Kg(o,e,t);if(null==r)return!1;s=new kg(n.doc.resolve(r))}const l=gg(s.$headCell,e,t);return!!l&&jg(n,r,new kg(s.$anchorCell,l))}}function Vg(e,t){const n=dg(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new kg(n))),!0)}function Hg(e,t,n){if(!hg(e.state))return!1;let r=function(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;1==t.childCount&&(n>0&&r>0||"table"==t.child(0).type.spec.tableRole);)n--,r--,t=t.child(0).content;const o=t.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if("row"==i)for(let e=0;e<t.childCount;e++){let o=t.child(e).content;const i=e?0:Math.max(0,n-1),a=e<t.childCount-1?0:Math.max(0,r-1);(i||a)&&(o=$g(cg(s).row,new Be(o,i,a)).content),l.push(o)}else{if("cell"!=i&&"header_cell"!=i)return null;l.push(n||r?$g(cg(s).row,new Be(t,n,r)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const r=t[e];for(let t=r.childCount-1;t>=0;t--){const{rowspan:o,colspan:i}=r.child(t).attrs;for(let t=e;t<e+o;t++)n[t]=(n[t]||0)+i}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(De.empty),n[o]<r){const i=cg(e).cell.createAndFill(),s=[];for(let e=n[o];e<r;e++)s.push(i);t[o]=t[o].append(De.from(s))}return{height:t.length,width:r,rows:t}}(s,l)}(n);const o=e.state.selection;if(o instanceof kg){r||(r={width:1,height:1,rows:[De.from($g(cg(e.state.schema).cell,n))]});const t=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),s=ig.get(t).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=function({width:e,height:t,rows:n},r,o){if(e!=r){const t=[],o=[];for(let e=0;e<n.length;e++){const i=n[e],s=[];for(let n=t[e]||0,o=0;n<r;o++){let l=i.child(o%i.childCount);n+l.attrs.colspan>r&&(l=l.type.createChecked(yg(l.attrs,l.attrs.colspan,n+l.attrs.colspan-r),l.content)),s.push(l),n+=l.attrs.colspan;for(let n=1;n<l.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+l.attrs.colspan}o.push(De.from(s))}n=o,e=r}if(t!=o){const e=[];for(let r=0,i=0;r<o;r++,i++){const s=[],l=n[i%t];for(let e=0;e<l.childCount;e++){let t=l.child(e);r+t.attrs.rowspan>o&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,o-t.attrs.rowspan)},t.content)),s.push(t)}e.push(De.from(s))}n=e,t=o}return{width:e,height:t,rows:n}}(r,s.right-s.left,s.bottom-s.top),Bg(e.state,e.dispatch,i,s,r),!0}if(r){const t=pg(e.state),n=t.start(-1);return Bg(e.state,e.dispatch,n,ig.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function qg(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=Ug(e,t.target);let o;if(t.shiftKey&&e.state.selection instanceof kg)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(o=dg(e.state.selection.$anchor))&&(null==(n=Jg(e,t))?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(t,n){let r=Jg(e,n);const o=null==ug.getState(e.state);if(!r||!mg(t,r)){if(!o)return;r=t}const i=new kg(t,r);if(o||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);o&&n.setMeta(ug,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=ug.getState(e.state)&&e.dispatch(e.state.tr.setMeta(ug,-1))}function l(n){const o=n,l=ug.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(Ug(e,o.target)!=r&&(a=Jg(e,t),!a))return s();a&&i(a,o)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function Kg(e,t,n){if(!(e.state.selection instanceof qs))return null;const{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=r.before(o),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function Ug(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function Jg(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?dg(e.state.doc.resolve(n.pos)):null}var Yg=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Gg(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Gg(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Gg(e,t,n,r,o,i){var s;let l=0,a=!0,c=t.firstChild;const u=e.firstChild;if(u){for(let e=0,n=0;e<u.childCount;e++){const{colspan:s,colwidth:d}=u.child(e).attrs;for(let e=0;e<s;e++,n++){const s=o==n?i:d&&d[e],u=s?s+"px":"";if(l+=s||r,s||(a=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{const e=document.createElement("col");e.style.width=u,t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Xg=new cl("tableColumnResizing");var Zg=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,r=t.getMeta(Xg);if(r&&null!=r.setHandle)return new e(r.setHandle,!1);if(r&&void 0!==r.setDragging)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return fg(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function Qg(e,t,n,r){const o="right"==n?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=dg(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=ig.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function ey(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function ty(e,t){e.dispatch(e.state.tr.setMeta(Xg,{setHandle:t}))}function ny(e,t,n,r){const o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=ig.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=e.domAtPos(o.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Gg(i,a.firstChild,a,r,l,n)}function ry(e){return Array(e).fill(0)}var oy="undefined"!=typeof navigator?navigator:null,iy=oy&&oy.userAgent||"",sy=/Edge\/(\d+)/.exec(iy),ly=/MSIE \d/.exec(iy),ay=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(iy),cy=!(ly||ay||sy)&&!!oy&&/Apple Computer/.test(oy.vendor),uy=new cl("safari-ime-span"),dy=!1;function hy(e){const t=e.dom.ownerDocument.createElement("span");return t.className="ProseMirror-safari-ime-span",t}var py=new sl(cy?{key:uy,props:{decorations:function(e){const{$from:t,$to:n,to:r}=e.selection;if(dy&&t.sameParent(n)){const t=kd.widget(r,hy,{ignoreSelection:!0,key:"safari-ime-span"});return xd.create(e.doc,[t])}},handleDOMEvents:{compositionstart:()=>{dy=!0},compositionend:()=>{dy=!1}}}}:{key:uy});function fy(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;-1!==o;)r++,o=n.indexOf(t,o+t.length);return r}function my(e){return"function"==typeof e?e:function(){return e}}const gy="phrasing",yy=["autolink","link","image","label"];function wy(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ky(e){this.config.enter.autolinkProtocol.call(this,e)}function vy(e){this.config.exit.autolinkProtocol.call(this,e)}function by(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function xy(e){this.config.exit.autolinkEmail.call(this,e)}function Cy(e){this.exit(e)}function Sy(e){!function(e,t,n){const r=eo((n||{}).ignore||[]),o=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const e=n[r];t.push([(o=e[0],"string"==typeof o?new RegExp(lf(o),"g"):o),my(e[1])])}var o;return t}(t);let i=-1;for(;++i<o.length;)lo(e,"text",s);function s(e,t){let n,s=-1;for(;++s<t.length;){const e=t[s],o=n?n.children:void 0;if(r(e,o?o.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){const n=t[t.length-1],r=o[i][0],s=o[i][1];let l=0;const a=n.children.indexOf(e);let c=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){const n=d.index,o={index:d.index,input:d.input,stack:[...t,e]};let i=s(...d,o);if("string"==typeof i&&(i=i.length>0?{type:"text",value:i}:void 0),!1===i?r.lastIndex=n+1:(l!==n&&u.push({type:"text",value:e.value.slice(l,n)}),Array.isArray(i)?u.push(...i):i&&u.push(i),l=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}return c?(l<e.value.length&&u.push({type:"text",value:e.value.slice(l)}),n.children.splice(a,1,...u)):u=[e],a+u.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,My],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Ny]],{ignore:["link","linkReference"]})}function My(e,t,n,r,o){let i="";if(!Ty(o))return!1;if(/^w/i.test(t)&&(n=t+n,t="",i="http://"),!function(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}(n))return!1;const s=function(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const o=fy(e,"(");let i=fy(e,")");for(;-1!==r&&o>i;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[e,n]}(n+r);if(!s[0])return!1;const l={type:"link",title:null,url:i+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[l,{type:"text",value:s[1]}]:l}function Ny(e,t,n,r){return!(!Ty(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Ty(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||un(n)||cn(n))&&(!t||47!==n)}function Oy(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Ay(){this.buffer()}function Ey(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=$n(this.sliceSerialize(e)).toLowerCase()}function Iy(e){this.exit(e)}function Dy(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Ry(){this.buffer()}function Py(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=$n(this.sliceSerialize(e)).toLowerCase()}function $y(e){this.exit(e)}function Ly(e,t,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteReference"),l=n.enter("reference");return i+=o.move(n.safe(n.associationId(e),{...o.current(),before:i,after:"]"})),l(),s(),i+=o.move("]"),i}function zy(e,t,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteDefinition"),l=n.enter("label");return i+=o.move(n.safe(n.associationId(e),{...o.current(),before:i,after:"]"})),l(),i+=o.move("]:"+(e.children&&e.children.length>0?" ":"")),o.shift(4),i+=o.move(n.indentLines(n.containerFlow(e,o.current()),By)),s(),i}function By(e,t,n){return 0===t?e:(n?"":" ")+e}Ly.peek=function(){return"["};const Fy=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function jy(e){this.enter({type:"delete",children:[]},e)}function _y(e){this.exit(e)}function Wy(e,t,n,r){const o=n.createTracker(r),i=n.enter("strikethrough");let s=o.move("~~");return s+=n.containerPhrasing(e,{...o.current(),before:s,after:"~"}),s+=o.move("~~"),i(),s}function Vy(e){return e.length}function Hy(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function qy(e){const t=e._align;this.enter({type:"table",align:t.map((function(e){return"none"===e?null:e})),children:[]},e),this.data.inTable=!0}function Ky(e){this.exit(e),this.data.inTable=void 0}function Uy(e){this.enter({type:"tableRow",children:[]},e)}function Jy(e){this.exit(e)}function Yy(e){this.enter({type:"tableCell",children:[]},e)}function Gy(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Xy));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Xy(e,t){return"|"===t?t:e}function Zy(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=xo.inlineCode(e,t,n);return n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&")),r},table:function(e,t,n,r){return l(function(e,t,n){const r=e.children;let o=-1;const i=[],s=t.enter("table");for(;++o<r.length;)i[o]=a(r[o],t,n);return s(),i}(e,n,r),e.align)},tableCell:s,tableRow:function(e,t,n,r){const o=l([a(e,n,r)]);return o.slice(0,o.indexOf("\n"))}}};function s(e,t,n,r){const o=n.enter("tableCell"),s=n.enter("phrasing"),l=n.containerPhrasing(e,{...r,before:i,after:i});return s(),o(),l}function l(e,t){return function(e,t){const n=t||{},r=(n.align||[]).concat(),o=n.stringLength||Vy,i=[],s=[],l=[],a=[];let c=0,u=-1;for(;++u<e.length;){const t=[],r=[];let i=-1;for(e[u].length>c&&(c=e[u].length);++i<e[u].length;){const s=null==(d=e[u][i])?"":String(d);if(!1!==n.alignDelimiters){const e=o(s);r[i]=e,(void 0===a[i]||e>a[i])&&(a[i]=e)}t.push(s)}s[u]=t,l[u]=r}var d;let h=-1;if("object"==typeof r&&"length"in r)for(;++h<c;)i[h]=Hy(r[h]);else{const e=Hy(r);for(;++h<c;)i[h]=e}h=-1;const p=[],f=[];for(;++h<c;){const e=i[h];let t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let o=!1===n.alignDelimiters?1:Math.max(1,a[h]-t.length-r.length);const s=t+"-".repeat(o)+r;!1!==n.alignDelimiters&&(o=t.length+o+r.length,o>a[h]&&(a[h]=o),f[h]=o),p[h]=s}s.splice(1,0,p),l.splice(1,0,f),u=-1;const m=[];for(;++u<s.length;){const e=s[u],t=l[u];h=-1;const r=[];for(;++h<c;){const o=e[h]||"";let s="",l="";if(!1!==n.alignDelimiters){const e=a[h]-(t[h]||0),n=i[h];114===n?s=" ".repeat(e):99===n?e%2?(s=" ".repeat(e/2+.5),l=" ".repeat(e/2-.5)):(s=" ".repeat(e/2),l=s):l=" ".repeat(e)}!1===n.delimiterStart||h||r.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===o||!1===n.delimiterStart&&!h||r.push(" "),!1!==n.alignDelimiters&&r.push(s),r.push(o),!1!==n.alignDelimiters&&r.push(l),!1!==n.padding&&r.push(" "),!1===n.delimiterEnd&&h===c-1||r.push("|")}m.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return m.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:o})}function a(e,t,n){const r=e.children;let o=-1;const i=[],l=t.enter("tableRow");for(;++o<r.length;)i[o]=s(r[o],0,t,n);return l(),i}}function Qy(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function ew(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const r=t.children;let o,i=-1;for(;++i<r.length;){const e=r[i];if("paragraph"===e.type){o=e;break}}o===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function tw(e,t,n,r){const o=e.children[0],i="boolean"==typeof e.checked&&o&&"paragraph"===o.type,s="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);i&&l.move(s);let a=xo.listItem(e,t,n,{...r,...l.current()});return i&&(a=a.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,(function(e){return e+s}))),a}Wy.peek=function(){return"~"};const nw={tokenize:function(e,t,n){let r=0;return function t(i){return(87===i||119===i)&&r<3?(r++,e.consume(i),t):46===i&&3===r?(e.consume(i),o):n(i)};function o(e){return null===e?n(e):t(e)}},partial:!0},rw={tokenize:function(e,t,n){let r,o,i;return s;function s(t){return 46===t||95===t?e.check(iw,a,l)(t):null===t||ln(t)||un(t)||45!==t&&cn(t)?a(t):(i=!0,e.consume(t),s)}function l(t){return 95===t?r=!0:(o=r,r=void 0),e.consume(t),s}function a(e){return o||r||!i?n(e):t(e)}},partial:!0},ow={tokenize:function(e,t){let n=0,r=0;return o;function o(s){return 40===s?(n++,e.consume(s),o):41===s&&r<n?i(s):33===s||34===s||38===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||60===s||63===s||93===s||95===s||126===s?e.check(iw,t,i)(s):null===s||ln(s)||un(s)?t(s):(e.consume(s),o)}function i(t){return 41===t&&r++,e.consume(t),o}},partial:!0},iw={tokenize:function(e,t,n){return r;function r(s){return 33===s||34===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||63===s||95===s||126===s?(e.consume(s),r):38===s?(e.consume(s),i):93===s?(e.consume(s),o):60===s||null===s||ln(s)||un(s)?t(s):n(s)}function o(e){return null===e||40===e||91===e||ln(e)||un(e)?t(e):r(e)}function i(e){return Zt(e)?s(e):n(e)}function s(t){return 59===t?(e.consume(t),r):Zt(t)?(e.consume(t),s):n(t)}},partial:!0},sw={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Qt(e)?n(e):t(e)}},partial:!0},lw={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){return 87!==t&&119!==t||!hw.call(r,r.previous)||gw(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(nw,e.attempt(rw,e.attempt(ow,o),n),n)(t))};function o(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:hw},aw={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let o="",i=!1;return function(t){return 72!==t&&104!==t||!pw.call(r,r.previous)||gw(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(t),e.consume(t),s)};function s(t){if(Zt(t)&&o.length<5)return o+=String.fromCodePoint(t),e.consume(t),s;if(58===t){const n=o.toLowerCase();if("http"===n||"https"===n)return e.consume(t),l}return n(t)}function l(t){return 47===t?(e.consume(t),i?a:(i=!0,l)):n(t)}function a(t){return null===t||tn(t)||ln(t)||un(t)||cn(t)?n(t):e.attempt(rw,e.attempt(ow,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:pw},cw={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let o,i;return function(t){return mw(t)&&fw.call(r,r.previous)&&!gw(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(t)):n(t)};function s(t){return mw(t)?(e.consume(t),s):64===t?(e.consume(t),l):n(t)}function l(t){return 46===t?e.check(sw,c,a)(t):45===t||95===t||Qt(t)?(i=!0,e.consume(t),l):c(t)}function a(t){return e.consume(t),o=!0,l}function c(s){return i&&o&&Zt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(s)):n(s)}},previous:fw},uw={};let dw=48;for(;dw<123;)uw[dw]=cw,dw++,58===dw?dw=65:91===dw&&(dw=97);function hw(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||ln(e)}function pw(e){return!Zt(e)}function fw(e){return!(47===e||mw(e))}function mw(e){return 43===e||45===e||46===e||95===e||Qt(e)}function gw(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}uw[43]=cw,uw[45]=cw,uw[46]=cw,uw[95]=cw,uw[72]=[cw,aw],uw[104]=[cw,aw],uw[87]=[cw,lw],uw[119]=[cw,lw];const yw={tokenize:function(e,t,n){const r=this;return hn(e,(function(e){const o=r.events[r.events.length-1];return o&&"gfmFootnoteDefinitionIndent"===o[1].type&&4===o[2].sliceSerialize(o[1],!0).length?t(e):n(e)}),"gfmFootnoteDefinitionIndent",5)},partial:!0};function ww(e,t,n){const r=this;let o=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;o--;){const e=r.events[o][1];if("labelImage"===e.type){s=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(o){if(!s||!s._balanced)return n(o);const l=$n(r.sliceSerialize({start:s.end,end:r.now()}));return 94===l.codePointAt(0)&&i.includes(l.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),t(o)):n(o)}}function kw(e,t){let n,r=e.length;for(;r--;)if("labelImage"===e[r][1].type&&"enter"===e[r][0]){n=e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const o={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[r+1],e[r+2],["enter",o,t],e[r+3],e[r+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",o,t]];return e.splice(r,e.length-r+1,...a),e}function vw(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,s=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),l};function l(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",a)}function a(l){if(s>999||93===l&&!i||null===l||91===l||ln(l))return n(l);if(93===l){e.exit("chunkString");const i=e.exit("gfmFootnoteCallString");return o.includes($n(r.sliceSerialize(i)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(l)}return ln(l)||(i=!0),s++,e.consume(l),92===l?c:a}function c(t){return 91===t||92===t||93===t?(e.consume(t),s++,a):a(t)}}function bw(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,s,l=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),a};function a(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(l>999||93===t&&!s||null===t||91===t||ln(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return i=$n(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return ln(t)||(s=!0),l++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o.includes(i)||o.push(i),hn(e,h,"gfmFootnoteDefinitionWhitespace")):n(t)}function h(e){return t(e)}}function xw(e,t,n){return e.check(gn,t,e.attempt(yw,t,n))}function Cw(e){e.exit("gfmFootnoteDefinition")}function Sw(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,r){const o=this.previous,i=this.events;let s=0;return function(t){return 126===o&&"characterEscape"!==i[i.length-1][1].type?r(t):(e.enter("strikethroughSequenceTemporary"),l(t))};function l(i){const a=sr(o);if(126===i)return s>1?r(i):(e.consume(i),s++,l);if(s<2&&!t)return r(i);const c=e.exit("strikethroughSequenceTemporary"),u=sr(i);return c._open=!u||2===u&&Boolean(a),c._close=!a||2===a&&Boolean(u),n(i)}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";const o={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},i={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},s=[["enter",o,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",i,t]],l=t.parser.constructs.insideSpan.null;l&&Wt(s,s.length,0,er(l,e.slice(r+1,n),t)),Wt(s,s.length,0,[["exit",i,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",o,t]]),Wt(e,r-1,n-r+3,s),n=r+s.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}};return null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class Mw{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let o=0;if(0!==n||0!==r.length){for(;o<e.map.length;){if(e.map[o][0]===t)return e.map[o][1]+=n,void e.map[o][2].push(...r);o+=1}e.map.push([t,n,r])}}(this,e,t,n)}consume(e){if(this.map.sort((function(e,t){return e[0]-t[0]})),0===this.map.length)return;let t=this.map.length;const n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push([...e]),e.length=0;let r=n.pop();for(;r;)e.push(...r),r=n.pop();this.map.length=0}}function Nw(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if("enter"===o[0])"tableContent"===o[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===o[1].type){if("tableDelimiterMarker"===e[t-1][1].type){const e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===o[1].type)break}else"enter"===o[0]&&"tableDelimiterRow"===o[1].type&&(n=!0);t+=1}return r}function Tw(e,t,n){const r=this;let o,i=0,s=0;return function(e){let t=r.events.length-1;for(;t>-1;){const e=r.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const o=t>-1?r.events[t][1].type:null,i="tableHead"===o||"tableRow"===o?v:l;return i===v&&r.parser.lazy[r.now().line]?n(e):i(e)};function l(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){return 124===e||(o=!0,s+=1),a(e)}(t)}function a(t){return null===t?n(t):sn(t)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):an(t)?hn(e,a,"whitespace")(t):(s+=1,o&&(o=!1,i+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),o=!0,a):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||ln(t)?(e.exit("data"),a(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),o=!1,an(t)?hn(e,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):h(t))}function h(t){return 45===t||58===t?f(t):124===t?(o=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),p):k(t)}function p(t){return an(t)?hn(e,f,"whitespace")(t):f(t)}function f(t){return 58===t?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),m):45===t?(s+=1,m(t)):null===t||sn(t)?w(t):k(t)}function m(t){return 45===t?(e.enter("tableDelimiterFiller"),g(t)):k(t)}function g(t){return 45===t?(e.consume(t),g):58===t?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(t))}function y(t){return an(t)?hn(e,w,"whitespace")(t):w(t)}function w(n){return 124===n?h(n):(null===n||sn(n))&&o&&i===s?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):k(n)}function k(e){return n(e)}function v(t){return e.enter("tableRow"),b(t)}function b(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),b):null===n||sn(n)?(e.exit("tableRow"),t(n)):an(n)?hn(e,b,"whitespace")(n):(e.enter("data"),x(n))}function x(t){return null===t||124===t||ln(t)?(e.exit("data"),b(t)):(e.consume(t),92===t?C:x)}function C(t){return 92===t||124===t?(e.consume(t),x):x(t)}}function Ow(e,t){let n,r,o,i=-1,s=!0,l=0,a=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const h=new Mw;for(;++i<e.length;){const p=e[i],f=p[1];"enter"===p[0]?"tableHead"===f.type?(u=!1,0!==d&&(Ew(h,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},f.start),end:Object.assign({},f.end)},h.add(i,0,[["enter",n,t]])):"tableRow"===f.type||"tableDelimiterRow"===f.type?(s=!0,o=void 0,a=[0,0,0,0],c=[0,i+1,0,0],u&&(u=!1,r={type:"tableBody",start:Object.assign({},f.start),end:Object.assign({},f.end)},h.add(i,0,[["enter",r,t]])),l="tableDelimiterRow"===f.type?2:r?3:1):!l||"data"!==f.type&&"tableDelimiterMarker"!==f.type&&"tableDelimiterFiller"!==f.type?"tableCellDivider"===f.type&&(s?s=!1:(0!==a[1]&&(c[0]=c[1],o=Aw(h,t,a,l,void 0,o)),a=c,c=[a[1],i,0,0])):(s=!1,0===c[2]&&(0!==a[1]&&(c[0]=c[1],o=Aw(h,t,a,l,void 0,o),a=[0,0,0,0]),c[2]=i)):"tableHead"===f.type?(u=!0,d=i):"tableRow"===f.type||"tableDelimiterRow"===f.type?(d=i,0!==a[1]?(c[0]=c[1],o=Aw(h,t,a,l,i,o)):0!==c[1]&&(o=Aw(h,t,c,l,i,o)),l=0):!l||"data"!==f.type&&"tableDelimiterMarker"!==f.type&&"tableDelimiterFiller"!==f.type||(c[3]=i)}for(0!==d&&Ew(h,t,d,n,r),h.consume(t.events),i=-1;++i<t.events.length;){const e=t.events[i];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=Nw(t.events,i))}return e}function Aw(e,t,n,r,o,i){const s=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(i.end=Object.assign({},Iw(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=Iw(t.events,n[1]);if(i={type:s,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",i,t]]),0!==n[2]){const o=Iw(t.events,n[2]),i=Iw(t.events,n[3]),s={type:"tableContent",start:Object.assign({},o),end:Object.assign({},i)};if(e.add(n[2],0,[["enter",s,t]]),2!==r){const r=t.events[n[2]],o=t.events[n[3]];if(r[1].end=Object.assign({},o[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){const t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",s,t]])}return void 0!==o&&(i.end=Object.assign({},Iw(t.events,o)),e.add(o,0,[["exit",i,t]]),i=void 0),i}function Ew(e,t,n,r,o){const i=[],s=Iw(t.events,n);o&&(o.end=Object.assign({},s),i.push(["exit",o,t])),r.end=Object.assign({},s),i.push(["exit",r,t]),e.add(n+1,0,i)}function Iw(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const Dw={name:"tasklistCheck",tokenize:function(e,t,n){const r=this;return function(t){return null===r.previous&&r._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),o):n(t)};function o(t){return ln(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),i):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),i):n(t)}function i(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(t)}function s(r){return sn(r)?t(r):an(r)?e.check({tokenize:Rw},t,n)(r):n(r)}}};function Rw(e,t,n){return hn(e,(function(e){return null===e?n(e):t(e)}),"whitespace")}const Pw={};function $w(e){const t=e||Pw,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),i=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return Yt([{text:uw},{document:{91:{name:"gfmFootnoteDefinition",tokenize:bw,continuation:{tokenize:xw},exit:Cw}},text:{91:{name:"gfmFootnoteCall",tokenize:vw},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ww,resolveTo:kw}}},Sw(e),{flow:{null:{name:"table",tokenize:Tw,resolveAll:Ow}}},{text:{91:Dw}}])}(t)),o.push([{transforms:[Sy],enter:{literalAutolink:wy,literalAutolinkEmail:ky,literalAutolinkHttp:ky,literalAutolinkWww:ky},exit:{literalAutolink:Cy,literalAutolinkEmail:xy,literalAutolinkHttp:vy,literalAutolinkWww:by}},{enter:{gfmFootnoteDefinition:Oy,gfmFootnoteDefinitionLabelString:Ay,gfmFootnoteCall:Dy,gfmFootnoteCallString:Ry},exit:{gfmFootnoteDefinition:Iy,gfmFootnoteDefinitionLabelString:Ey,gfmFootnoteCall:$y,gfmFootnoteCallString:Py}},{canContainEols:["delete"],enter:{strikethrough:jy},exit:{strikethrough:_y}},{enter:{table:qy,tableData:Yy,tableHeader:Yy,tableRow:Uy},exit:{codeText:Gy,table:Ky,tableData:Jy,tableHeader:Jy,tableRow:Jy}},{exit:{taskListCheckValueChecked:Qy,taskListCheckValueUnchecked:Qy,paragraph:ew}}]),i.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:gy,notInConstruct:yy},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:gy,notInConstruct:yy},{character:":",before:"[ps]",after:"\\/",inConstruct:gy,notInConstruct:yy}]},{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:zy,footnoteReference:Ly}},{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Fy}],handlers:{delete:Wy}},Zy(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:tw}}]}}(t))}function Lw(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-gfm",...t}}),e}const zw=Yp("strike_through");Lw(zw,{displayName:"Attr<strikethrough>",group:"Strikethrough"});const Bw=Kp("strike_through",(e=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>"line-through"===e}],toDOM:t=>["del",e.get(zw.key)(t)],parseMarkdown:{match:e=>"delete"===e.type,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strike_through"===e.type.name,runner:(e,t)=>{e.withMark(t,"delete")}}})));Lw(Bw.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"}),Lw(Bw.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});const Fw=Ep("ToggleStrikeThrough",(e=>()=>Sa(Bw.type(e))));Lw(Fw,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});const jw=Dp((e=>zl(/~([^~]+)~$/,Bw.type(e))));Lw(jw,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});const _w=Up("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:e=>{const t=e.get(Rh);return()=>t.call(Fw.key)}}});Lw(_w.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"}),Lw(_w.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});const Ww=function(e){const t=e.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const e in t)n[e]={default:t[e].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:e=>lg(e,t)}],toDOM:e=>["td",ag(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>lg(e,t)}],toDOM:e=>["th",ag(e,t),0]}}}({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:e=>e.style.textAlign||"left",setDOMAttr:(e,t)=>{t.style=`text-align: ${e||"left"}`}}}}),Vw=qp("table",(()=>({...Ww.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:e=>"table"===e.type,runner:(e,t,n)=>{const r=t.align,o=t.children.map(((e,t)=>({...e,align:r,isHeader:0===t})));e.openNode(n),e.next(o),e.closeNode()}},toMarkdown:{match:e=>"table"===e.type.name,runner:(e,t)=>{var n;const r=null==(n=t.content.firstChild)?void 0:n.content;if(!r)return;const o=[];r.forEach((e=>{o.push(e.attrs.alignment)})),e.openNode("table",void 0,{align:o}),e.next(t.content),e.closeNode()}}})));Lw(Vw.node,{displayName:"NodeSchema<table>",group:"Table"}),Lw(Vw.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});const Hw=qp("table_header_row",(()=>({...Ww.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"}],toDOM:()=>["tr",{"data-is-header":!0},0],parseMarkdown:{match:e=>!("tableRow"!==e.type||!e.isHeader),runner:(e,t,n)=>{const r=t.align,o=t.children.map(((e,n)=>({...e,align:r[n],isHeader:t.isHeader})));e.openNode(n),e.next(o),e.closeNode()}},toMarkdown:{match:e=>"table_header_row"===e.type.name,runner:(e,t)=>{e.openNode("tableRow",void 0,{isHeader:!0}),e.next(t.content),e.closeNode()}}})));Lw(Hw.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"}),Lw(Hw.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});const qw=qp("table_row",(()=>({...Ww.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:e=>"tableRow"===e.type,runner:(e,t,n)=>{const r=t.align,o=t.children.map(((e,t)=>({...e,align:r[t]})));e.openNode(n),e.next(o),e.closeNode()}},toMarkdown:{match:e=>"table_row"===e.type.name,runner:(e,t)=>{e.openNode("tableRow"),e.next(t.content),e.closeNode()}}})));Lw(qw.node,{displayName:"NodeSchema<tableRow>",group:"Table"}),Lw(qw.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});const Kw=qp("table_cell",(()=>({...Ww.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>"tableCell"===e.type&&!e.isHeader,runner:(e,t,n)=>{const r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>"table_cell"===e.type.name,runner:(e,t)=>{e.openNode("tableCell").next(t.content).closeNode()}}})));Lw(Kw.node,{displayName:"NodeSchema<tableCell>",group:"Table"}),Lw(Kw.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});const Uw=qp("table_header",(()=>({...Ww.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>"tableCell"===e.type&&!!e.isHeader,runner:(e,t,n)=>{const r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>"table_header"===e.type.name,runner:(e,t)=>{e.openNode("tableCell"),e.next(t.content),e.closeNode()}}})));function Jw(e,t=3,n=3){const r=Array(n).fill(0).map((()=>Kw.type(e).createAndFill())),o=Array(n).fill(0).map((()=>Uw.type(e).createAndFill())),i=Array(t).fill(0).map(((t,n)=>0===n?Hw.type(e).create(null,o):qw.type(e).create(null,r)));return Vw.type(e).create(null,i)}function Yw(e){return la((e=>"table"===e.type.spec.tableRole))(e)}function Gw(e,t){const n=Yw(t.$from);if(!n)return;const r=ig.get(n.node);return e<0||e>=r.width?void 0:r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map((e=>{const t=n.node.nodeAt(e);if(!t)return;const r=e+n.start;return{pos:r,start:r+1,node:t}})).filter((e=>null!=e))}function Xw(e,t){const n=Yw(t.$from);if(!n)return;const r=ig.get(n.node);return e<0||e>=r.height?void 0:r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map((e=>{const t=n.node.nodeAt(e);if(!t)return;const r=e+n.start;return{pos:r,start:r+1,node:t}})).filter((e=>null!=e))}function Zw(e){const t=Yw(e.$from);if(!t)return;const n=ig.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map((e=>{const n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}}))}function Qw(e){const t=Zw(e.selection);if(t&&t[0]){const n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){const t=e.doc.resolve(r.pos);return Zl(e.setSelection(new kg(t,n)))}}return e}function ek(e,t,{map:n,tableStart:r,table:o},i){const s=Array(i).fill(0).reduce(((e,t,n)=>e+o.child(n).nodeSize),r),l=Array(n.width).fill(0).map(((t,r)=>{const i=o.nodeAt(n.map[r]);return Kw.type(e).createAndFill({alignment:null==i?void 0:i.attrs.alignment})}));return t.insert(s,qw.type(e).create(null,l)),t}function tk(e){return(t,n)=>r=>{n=n??r.selection.from;const o=r.doc.resolve(n),i=la((e=>"table"===e.type.name))(o),s=i?{node:i.node,from:i.start}:void 0,l="row"===e;if(s){const e=ig.get(s.node);if(t>=0&&t<(l?e.height:e.width)){const n=e.positionAt(l?t:e.height-1,l?e.width-1:t,s.node),o=r.doc.resolve(s.from+n),i=l?kg.rowSelection:kg.colSelection,a=e.positionAt(l?t:0,l?0:t,s.node),c=r.doc.resolve(s.from+a);return Zl(r.setSelection(i(o,c)))}}return r}}Lw(Uw.node,{displayName:"NodeSchema<tableHeader>",group:"Table"}),Lw(Uw.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});const nk=tk("row"),rk=tk("col");function ok(e){return e[0].map(((t,n)=>e.map((e=>e[n]))))}function ik(e,t){const n=[],r=ig.get(e);for(let o=0;o<r.height;o++){const i=e.child(o),s=[];for(let n=0;n<r.width;n++){if(!t[o][n])continue;const i=r.map[o*r.width+n],l=t[o][n],a=e.nodeAt(i).type.createChecked(Object.assign({},l.attrs),l.content,l.marks);s.push(a)}n.push(i.type.createChecked(i.attrs,s,i.marks))}return e.type.createChecked(e.attrs,n,e.marks)}function sk(e){const t=ig.get(e),n=[];for(let r=0;r<t.height;r++){const o=[],i={};for(let n=0;n<t.width;n++){const s=t.map[r*t.width+n],l=e.nodeAt(s),a=t.findCell(s);i[s]||a.top!==r?o.push(null):(i[s]=!0,o.push(l))}n.push(o)}return n}function lk(e,t,n,r){const o=t[0]>n[0]?-1:1,i=e.splice(t[0],t.length),s=i.length%2==0?1:0;let l;return l=-1===o?n[0]:n[n.length-1]-s,e.splice(l,0,...i),e}function ak(e,t){let n=e,r=e;for(let o=e;o>=0;o--){const e=Gw(o,t.selection);e&&e.forEach((e=>{const t=e.node.attrs.colspan+o-1;t>=n&&(n=o),t>r&&(r=t)}))}for(let n=e;n<=r;n++){const e=Gw(n,t.selection);e&&e.forEach((e=>{const t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>r&&(r=t)}))}const o=[];for(let e=n;e<=r;e++){const n=Gw(e,t.selection);n&&n.length&&o.push(e)}n=o[0],r=o[o.length-1];const i=Gw(n,t.selection),s=Xw(0,t.selection),l=t.doc.resolve(i[i.length-1].pos);let a;for(let e=r;e>=n;e--){const n=Gw(e,t.selection);if(n&&n.length){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){a=n[0];break}if(a)break}}return{$anchor:l,$head:t.doc.resolve(a.pos),indexes:o}}function ck(e,t){let n=e,r=e;for(let o=e;o>=0;o--)Xw(o,t.selection).forEach((e=>{const t=e.node.attrs.rowspan+o-1;t>=n&&(n=o),t>r&&(r=t)}));for(let n=e;n<=r;n++)Xw(n,t.selection).forEach((e=>{const t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>r&&(r=t)}));const o=[];for(let e=n;e<=r;e++){const n=Xw(e,t.selection);n&&n.length&&o.push(e)}n=o[0],r=o[o.length-1];const i=Xw(n,t.selection),s=Gw(0,t.selection),l=t.doc.resolve(i[i.length-1].pos);let a;for(let e=r;e>=n;e--){const n=Xw(e,t.selection);if(n&&n.length){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){a=n[0];break}if(a)break}}return{$anchor:l,$head:t.doc.resolve(a.pos),indexes:o}}function uk(e){const{tr:t,origin:n,target:r,select:o=!0,pos:i}=e,s=Yw(null!=i?t.doc.resolve(i):t.selection.$from);if(!s)return t;const{indexes:l}=ak(n,t),{indexes:a}=ak(r,t);if(l.includes(r))return t;const c=function(e,t,n,r){let o=ok(sk(e.node));return o=lk(o,t,n),o=ok(o),ik(e.node,o)}(s,l,a),u=Zl(t).replaceWith(s.pos,s.pos+s.node.nodeSize,c);if(!o)return u;const d=ig.get(c),h=s.start,p=r,f=d.positionAt(d.height-1,p,c),m=u.doc.resolve(h+f),g=kg.colSelection,y=d.positionAt(0,p,c),w=u.doc.resolve(h+y);return u.setSelection(g(m,w))}function dk(e){const{tr:t,origin:n,target:r,select:o=!0,pos:i}=e,s=Yw(null!=i?t.doc.resolve(i):t.selection.$from);if(!s)return t;const{indexes:l}=ck(n,t),{indexes:a}=ck(r,t);if(l.includes(r))return t;const c=function(e,t,n,r){let o=sk(e.node);return o=lk(o,t,n),ik(e.node,o)}(s,l,a),u=Zl(t).replaceWith(s.pos,s.pos+s.node.nodeSize,c);if(!o)return u;const d=ig.get(c),h=s.start,p=r,f=d.positionAt(p,d.width-1,c),m=u.doc.resolve(h+f),g=kg.rowSelection,y=d.positionAt(p,0,c),w=u.doc.resolve(h+y);return u.setSelection(g(m,w))}const hk=Ep("GoToPrevTableCell",(()=>()=>Rg(-1)));Lw(hk,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});const pk=Ep("GoToNextTableCell",(()=>()=>Rg(1)));Lw(pk,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});const fk=Ep("ExitTable",(e=>()=>(t,n)=>{if(!hg(t))return!1;const{$head:r}=t.selection,o=oa(r,Vw.type(e));if(!o)return!1;const{to:i}=o,s=t.tr.replaceWith(i,i,Bf.type(e).createAndFill());return s.setSelection(_s.near(s.doc.resolve(i),1)).scrollIntoView(),null==n||n(s),!0}));Lw(fk,{displayName:"Command<breakTableCommand>",group:"Table"});const mk=Ep("InsertTable",(e=>({row:t,col:n}={})=>(r,o)=>{const{selection:i,tr:s}=r,{from:l}=i,a=Jw(e,t,n),c=s.replaceSelectionWith(a),u=_s.findFrom(c.doc.resolve(l),1,!0);return u&&c.setSelection(u),null==o||o(c),!0}));Lw(mk,{displayName:"Command<insertTableCommand>",group:"Table"});const gk=Ep("MoveRow",(()=>({from:e,to:t,pos:n}={})=>(r,o)=>{const{tr:i}=r;return!!(null==o?void 0:o(dk({tr:i,origin:e??0,target:t??0,pos:n,select:!0})))}));Lw(gk,{displayName:"Command<moveRowCommand>",group:"Table"});const yk=Ep("MoveCol",(()=>({from:e,to:t,pos:n}={})=>(r,o)=>{const{tr:i}=r;return!!(null==o?void 0:o(uk({tr:i,origin:e??0,target:t??0,pos:n,select:!0})))}));Lw(yk,{displayName:"Command<moveColCommand>",group:"Table"});const wk=Ep("SelectRow",(()=>(e={index:0})=>(t,n)=>{const{tr:r}=t;return!!(null==n?void 0:n(nk(e.index,e.pos)(r)))}));Lw(wk,{displayName:"Command<selectRowCommand>",group:"Table"});const kk=Ep("SelectCol",(()=>(e={index:0})=>(t,n)=>{const{tr:r}=t;return!!(null==n?void 0:n(rk(e.index,e.pos)(r)))}));Lw(kk,{displayName:"Command<selectColCommand>",group:"Table"});const vk=Ep("SelectTable",(()=>()=>(e,t)=>{const{tr:n}=e;return!!(null==t?void 0:t(Qw(n)))}));Lw(vk,{displayName:"Command<selectTableCommand>",group:"Table"});const bk=Ep("DeleteSelectedCells",(()=>()=>(e,t)=>{const{selection:n}=e;if(!(n instanceof kg))return!1;const r=n.isRowSelection(),o=n.isColSelection();return r&&o?function(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}(e,t):o?function(e,t){if(!hg(e))return!1;if(t){const n=Mg(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;Ag(r,n,e),e!=n.left;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=ig.get(e)}t(r)}return!0}(e,t):function(e,t){if(!hg(e))return!1;if(t){const n=Mg(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Eg(r,n,e),e!=n.top;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=ig.get(n.table)}t(r)}return!0}(e,t)}));Lw(bk,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});const xk=Ep("AddColBefore",(()=>()=>Tg));Lw(xk,{displayName:"Command<addColBeforeCommand>",group:"Table"});const Ck=Ep("AddColAfter",(()=>()=>Og));Lw(Ck,{displayName:"Command<addColAfterCommand>",group:"Table"});const Sk=Ep("AddRowBefore",(e=>()=>(t,n)=>{if(!hg(t))return!1;if(n){const r=Mg(t);n(ek(e,t.tr,r,r.top))}return!0}));Lw(Sk,{displayName:"Command<addRowBeforeCommand>",group:"Table"});const Mk=Ep("AddRowAfter",(e=>()=>(t,n)=>{if(!hg(t))return!1;if(n){const r=Mg(t);n(ek(e,t.tr,r,r.bottom))}return!0}));Lw(Mk,{displayName:"Command<addRowAfterCommand>",group:"Table"});const Nk=Ep("SetAlign",(()=>(e="left")=>{return t="alignment",n=e,function(e,r){if(!hg(e))return!1;const o=pg(e);if(o.nodeAfter.attrs[t]===n)return!1;if(r){const i=e.tr;e.selection instanceof kg?e.selection.forEachCell(((e,r)=>{e.attrs[t]!==n&&i.setNodeMarkup(r,null,{...e.attrs,[t]:n})})):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:n}),r(i)}return!0};var t,n}));Lw(Nk,{displayName:"Command<setAlignCommand>",group:"Table"});const Tk=Dp((e=>new ul(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,((t,n,r,o)=>{var i,s;const l=t.doc.resolve(r);if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),Vw.type(e)))return null;const a=Jw(e,Number(null==(i=n.groups)?void 0:i.row),Number(null==(s=n.groups)?void 0:s.col)),c=t.tr.replaceRangeWith(r,o,a);return c.setSelection(qs.create(c.doc,r+3)).scrollIntoView()}))));Lw(Tk,{displayName:"InputRule<insertTableInputRule>",group:"Table"});const Ok=Up("tableKeymap",{NextCell:{shortcuts:["Mod-]","Tab"],command:e=>{const t=e.get(Rh);return()=>t.call(pk.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:e=>{const t=e.get(Rh);return()=>t.call(hk.key)}},ExitTable:{shortcuts:["Mod-Enter"],command:e=>{const t=e.get(Rh);return()=>t.call(fk.key)}}});Lw(Ok.ctx,{displayName:"KeymapCtx<table>",group:"Table"}),Lw(Ok.shortcuts,{displayName:"Keymap<table>",group:"Table"});const Ak="footnote_definition",Ek="footnoteDefinition",Ik=qp("footnote_definition",(()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:""}},parseDOM:[{tag:`dl[data-type="${Ak}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{label:e.dataset.label}},contentElement:"dd"}],toDOM:e=>{const t=e.attrs.label;return["dl",{"data-label":t,"data-type":Ak},["dt",t],["dd",0]]},parseMarkdown:{match:({type:e})=>e===Ek,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===Ak,runner:(e,t)=>{e.openNode(Ek,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}})));Lw(Ik.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"}),Lw(Ik.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});const Dk="footnote_reference",Rk=qp("footnote_reference",(()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:""}},parseDOM:[{tag:`sup[data-type="${Dk}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{label:e.dataset.label}}}],toDOM:e=>{const t=e.attrs.label;return["sup",{"data-label":t,"data-type":Dk},t]},parseMarkdown:{match:({type:e})=>"footnoteReference"===e,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===Dk,runner:(e,t)=>{e.addNode("footnoteReference",void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}})));Lw(Rk.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"}),Lw(Rk.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});const Pk=Em.extendSchema((e=>t=>{const n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?"true"===e.dataset.checked:null}}},...(null==n?void 0:n.parseDOM)||[]],toDOM:e=>n.toDOM&&null==e.attrs.checked?n.toDOM(e):["li",{"data-item-type":"task","data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,r)=>{if(null==t.checked)return void n.parseMarkdown.runner(e,t,r);const o=null!=t.label?`${t.label}.`:"•",i=null!=t.checked?!!t.checked:null,s=null!=t.label?"ordered":"bullet",l=null!=t.spread?`${t.spread}`:"true";e.openNode(r,{label:o,listType:s,spread:l,checked:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{if(null==t.attrs.checked)return void n.toMarkdown.runner(e,t);const r=t.attrs.label,o=t.attrs.listType,i="true"===t.attrs.spread,s=t.attrs.checked;e.openNode("listItem",void 0,{label:r,listType:o,spread:i,checked:s}),e.next(t.content),e.closeNode()}}}}));Lw(Pk,{displayName:"NodeSchema<listItem>",group:"ListItem"});const $k=Dp((()=>new ul(/^\[(?<checked>\s|x)\]\s$/,((e,t,n,r)=>{var o;const i=e.doc.resolve(n);let s=0,l=i.node(s);for(;l&&"list_item"!==l.type.name;)s--,l=i.node(s);if(!l||null!=l.attrs.checked)return null;const a="x"===(null==(o=t.groups)?void 0:o.checked),c=i.before(s),u=e.tr;return u.deleteRange(n,r).setNodeMarkup(c,void 0,{...l.attrs,checked:a}),u}))));Lw($k,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});const Lk=[_w,Ok].flat(),zk=[Tk,$k],Bk=[jw],Fk=Bp((()=>py));Lw(Fk,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});const jk=Bp((()=>function({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Yg,lastColumnResizable:o=!0}={}){const i=new sl({key:Xg,state:{init(e,t){var o,s;const l=null==(s=null==(o=i.spec)?void 0:o.props)?void 0:s.nodeViews,a=cg(t.schema).table.name;return r&&l&&(l[a]=(e,t)=>new r(e,n,t)),new Zg(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=Xg.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,r){if(!e.editable)return;const o=Xg.getState(e.state);if(o&&!o.dragging){const i=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(i){const{left:r,right:o}=i.getBoundingClientRect();t.clientX-r<=n?s=Qg(e,t,"left",n):o-t.clientX<=n&&(s=Qg(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),r=ig.get(n),o=t.start(-1);if(r.colCount(t.pos-o)+t.nodeAfter.attrs.colspan-1==r.width-1)return}ty(e,s)}}}(t,n,e,o)},mouseleave:e=>{!function(e){if(!e.editable)return;const t=Xg.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&ty(e,-1)}(e)},mousedown:(e,r)=>{!function(e,t,n,r){var o;if(!e.editable)return!1;const i=null!=(o=e.dom.ownerDocument.defaultView)?o:window,s=Xg.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=e.state.doc.nodeAt(s.activeHandle),a=function(e,t,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let e=0;e<n;e++)r[e]&&(s-=r[e],l--);return s/l}(e,s.activeHandle,l.attrs);function c(t){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const r=Xg.getState(e.state);(null==r?void 0:r.dragging)&&(function(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),i=ig.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let e=0;e<i.height;e++){const t=e*i.width+l;if(e&&i.map[t]==i.map[t-i.width])continue;const r=i.map[t],c=o.nodeAt(r).attrs,u=1==c.colspan?0:l-i.colCount(r);if(c.colwidth&&c.colwidth[u]==n)continue;const d=c.colwidth?c.colwidth.slice():ry(c.colspan);d[u]=n,a.setNodeMarkup(s+r,null,{...c,colwidth:d})}a.docChanged&&e.dispatch(a)}(e,r.activeHandle,ey(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Xg,{setDragging:null})))}function u(t){if(!t.which)return c(t);const o=Xg.getState(e.state);if(o&&o.dragging){const i=ey(o.dragging,t,n);ny(e,o.activeHandle,i,r)}}e.dispatch(e.state.tr.setMeta(Xg,{setDragging:{startX:t.clientX,startWidth:a}})),ny(e,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),t.preventDefault()}(e,r,t,n)}},decorations:e=>{const t=Xg.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;const r=[],o=e.doc.resolve(t),i=o.node(-1);if(!i)return xd.empty;const s=ig.get(i),l=o.start(-1),a=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){const o=a+t*s.width;if(!(a!=s.width-1&&s.map[o]==s.map[o+1]||0!=t&&s.map[o]==s.map[o-s.width])){const t=s.map[o],a=l+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=Xg.getState(e))?void 0:n.dragging)&&r.push(kd.node(l+t,l+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),r.push(kd.widget(a,c))}}return xd.create(e.doc,r)}(e,t.activeHandle)},nodeViews:{}}});return i}({})));Lw(jk,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});const _k=Bp((()=>function({allowTableNodeSelection:e=!1}={}){return new sl({key:ug,state:{init:()=>null,apply(e,t){const n=e.getMeta(ug);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:r,pos:o}=e.mapping.mapResult(t);return r?null:o}},props:{decorations:bg,handleDOMEvents:{mousedown:qg},createSelectionBetween:e=>null!=ug.getState(e.state)?e.state.selection:null,handleTripleClick:Vg,handleKeyDown:Fg,handlePaste:Hg},appendTransaction:(t,n,r)=>function(e,t,n){const r=(t||e).selection,o=(t||e).doc;let i,s;if(r instanceof Us&&(s=r.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=kg.create(o,r.from);else if("row"==s){const e=o.resolve(r.from+1);i=kg.rowSelection(e,e)}else if(!n){const e=ig.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];i=kg.create(o,t+1,n)}}else r instanceof qs&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}(r)?i=qs.create(o,r.from):r instanceof qs&&function({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){r=n;break}}return n!==r&&0===t.parentOffset}(r)&&(i=qs.create(o,r.$from.start(),r.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}(r,Sg(r,n),e)})}({allowTableNodeSelection:!0})));Lw(_k,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});const Wk=Gp("remarkGFM",(()=>$w));Lw(Wk.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"}),Lw(Wk.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});const Vk=new cl("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN"),Hk=Bp((()=>new sl({key:Vk,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants(((e,t)=>{if(r||(r=n.tr),"table_cell"!==e.type.name)return;const o=n.doc.resolve(t),i=o.node(o.depth),s=o.node(o.depth-1).firstChild;if(!s)return;const l=function(e,t){let n=0;return t.forEach(((t,r,o)=>{t===e&&(n=o)})),n}(e,i),a=s.maybeChild(l);if(!a)return;const c=a.attrs.alignment;c!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:c})})),r}})));Lw(Hk,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});const qk=[Hk,Fk,Wk,_k].flat(),Kk=[Pk,Vw,Hw,qw,Uw,Kw,Ik,Rk,zw,Bw].flat(),Uk=[pk,hk,fk,mk,gk,yk,wk,kk,vk,bk,Sk,Mk,xk,Ck,Nk,Fw],Jk=[Kk,zk,Bk,Lk,Uk,qk].flat();class Yk{#e;#t=new Set;constructor(e){this.#e=e}get current(){return this.#e}set current(e){this.#e!=e&&(this.#e=e,this.#t.forEach((t=>t(e))))}on(e){return this.#t.add(e),()=>this.#t.delete(e)}}const Gk=e=>new Yk(e),Xk=Symbol.for("atomico.hooks");globalThis[Xk]=globalThis[Xk]||{};let Zk=globalThis[Xk];const Qk=Symbol.for("Atomico.suspense"),ev=Symbol.for("Atomico.effect"),tv=Symbol.for("Atomico.layoutEffect"),nv=Symbol.for("Atomico.insertionEffect"),rv=(e,t,n)=>{const{i:r,hooks:o}=Zk.c,i=o[r]=o[r]||{};return i.value=e(i.value),i.effect=t,i.tag=n,Zk.c.i++,o[r].value},ov=e=>rv(((t=Gk(e))=>t)),iv=()=>rv(((e=Gk(Zk.c.host))=>e)),sv=()=>Zk.c.update,lv=()=>rv((()=>Zk.c.id+"-"+Zk.c.i)),av=Symbol.for;function cv(e,t){const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const uv=e=>"function"==typeof e,dv=e=>"object"==typeof e,{isArray:hv}=Array,pv=(e,t)=>(!t||e instanceof HTMLStyleElement)&&"hydrate"in(e?.dataset||{});function fv(e,t){let n;const r=e=>{let{length:o}=e;for(let i=0;i<o;i++){const o=e[i];if(o&&Array.isArray(o))r(o);else{const e=typeof o;if(null==o||"function"===e||"boolean"===e)continue;"string"===e||"number"===e?(null==n&&(n=""),n+=o):(null!=n&&(t(n),n=null),t(o))}}};r(e),null!=n&&t(n)}const mv=(e,t,n)=>(e.addEventListener(t,n),()=>e.removeEventListener(t,n));class gv{constructor(e,t,n){this.message=t,this.target=e,this.value=n}}class yv extends gv{}class wv extends gv{}const kv="Custom",vv=null,bv={true:1,"":1,1:1};function xv(e,t,n,r,o){const{type:i,reflect:s,event:l,value:a,attr:c=Sv(t)}=n?.name!=kv&&dv(n)&&n!=vv?n:{type:n},u=i?.name===kv&&i.map,d=null!=a?i!=Function&&uv(a)?a:()=>a:null;Object.defineProperty(e,t,{configurable:!0,set(e){const n=this[t];d&&i!=Boolean&&null==e&&(e=d());const{error:r,value:o}=(u?Nv:Tv)(i,e);if(r&&null!=o)throw new yv(this,`The value defined for prop '${t}' must be of type '${i.name}'`,o);n!=o&&(this._props[t]=null==o?void 0:o,this.update(),l&&Cv(this,l),this.updated.then((()=>{s&&(this._ignoreAttr=c,Mv(this,i,c,this[t]),this._ignoreAttr=null)})))},get(){return this._props[t]}}),d&&(o[t]=d()),r[c]={prop:t,type:i}}const Cv=(e,{type:t,base:n=CustomEvent,...r})=>e.dispatchEvent(new n(t,r)),Sv=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),Mv=(e,t,n,r)=>null==r||t==Boolean&&!r?e.removeAttribute(n):e.setAttribute(n,t?.name===kv&&t?.serialize?t?.serialize(r):dv(r)?JSON.stringify(r):t==Boolean?"":r),Nv=({map:e},t)=>{try{return{value:e(t),error:!1}}catch{return{value:t,error:!0}}},Tv=(e,t)=>null==e||null==t?{value:t,error:!1}:e!=String&&""===t?{value:void 0,error:!1}:e==Object||e==Array||e==Symbol?{value:t,error:{}.toString.call(t)!==`[object ${e.name}]`}:t instanceof e?{value:t,error:e==Number&&Number.isNaN(t.valueOf())}:e==String||e==Number||e==Boolean?{value:t,error:e==Number?"number"!=typeof t||Number.isNaN(t):e==String?"string"!=typeof t:"boolean"!=typeof t}:{value:t,error:!0},Ov=(e,t)=>({name:kv,map:e,serialize:t});let Av=0;const Ev=(e,t=HTMLElement)=>{const n={},r={},o="prototype"in t&&t.prototype instanceof Element,i=o?t:"base"in t?t.base:HTMLElement,{props:s,styles:l}=o?e:t;return class extends i{constructor(){super(),this._setup(),this._render=()=>e({...this._props});for(const e in r)this[e]=r[e]}static get styles(){return[super.styles,l]}async _setup(){if(this._props)return;let e,t;this._props={},this.mounted=new Promise((n=>this.mount=()=>{n(),e!=this.parentNode&&(t!=e?this.unmounted.then(this.update):this.update()),e=this.parentNode})),this.unmounted=new Promise((r=>this.unmount=()=>{r(),e==this.parentNode&&this.isConnected||(n.cleanEffects(!0)()(),t=this.parentNode,e=null)})),this.symbolId=this.symbolId||Symbol(),this.symbolIdParent=Symbol();const n=((e,t,n=0)=>{let r={},o=!1;const i=(e,t)=>{for(const n in r){const o=r[n];o.effect&&o.tag===e&&(o.value=o.effect(o.value,t))}};return{load:i=>{let s;Zk.c={host:t,hooks:r,update:e,i:0,id:n};try{o=!1,s=i()}catch(e){if(e!==Qk)throw e;o=!0}finally{Zk.c=null}return s},cleanEffects:e=>(i(nv,e),()=>(i(tv,e),()=>{i(ev,e)})),isSuspense:()=>o}})((()=>this.update()),this,(r=this,(r?.dataset||{})?.hydrate||"c"+Av++));var r;let o,i=!0;const s=pv(this);this.update=()=>(o||(o=!0,this.updated=(this.updated||this.mounted).then((()=>{try{const e=n.load(this._render),t=n.cleanEffects();return e&&e.render(this,this.symbolId,s),o=!1,i&&!n.isSuspense()&&(i=!1,!s&&function(e){const{styles:t}=e.constructor,{shadowRoot:n}=e;if(n&&t.length){const e=[];fv(t,(t=>{t&&(t instanceof Element?n.appendChild(t.cloneNode(!0)):e.push(t))})),e.length&&(n.adoptedStyleSheets=e)}}(this)),t()}finally{o=!1}})).then((e=>{e&&e()}))),this.updated),this.update()}connectedCallback(){this.mount(),super.connectedCallback&&super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),this.unmount()}attributeChangedCallback(e,t,r){if(n[e]){if(e===this._ignoreAttr||t===r)return;const{prop:o,type:i}=n[e];try{this[o]=((e,t)=>e==Boolean?!!bv[t]:e==Number?Number(t):e==String?t:e==Array||e==Object?JSON.parse(t):e.name==kv?t:new e(t))(i,r)}catch(t){throw new wv(this,`The value defined as attr '${e}' cannot be parsed by type '${i.name}'`,r)}}else super.attributeChangedCallback(e,t,r)}static get props(){return{...super.props,...s}}static get observedAttributes(){const e=super.observedAttributes||[];for(const e in s)xv(this.prototype,e,s[e],n,r);return Object.keys(n).concat(e)}}},Iv=e=>(t,n)=>{rv((([e,t]=[])=>(!t&&t||(t&&cv(t,n)?e=e||!0:(uv(e)&&e(),e=null)),[e,n])),(([e,n],r)=>r?(uv(e)&&e(),[]):[e||t(),n]),e)},Dv=Iv(tv),Rv=Iv(ev),Pv=Iv(nv);class $v extends Array{constructor(e,t){let n=!0;const r=e=>{try{t(e,this,n)}finally{n=!1}};super(void 0,r,t),r(e)}}const Lv=e=>{const t=sv();return rv(((n=new $v(e,((e,n,r)=>{(e=uv(e)?e(n[0]):e)!==n[0]&&(n[0]=e,r||t())})))=>n))},zv=(e,t)=>{const[n]=rv((([n,r,o=0]=[])=>((!r||r&&!cv(r,t))&&(n=e()),[n,t,o])));return n},Bv=(e,t,n)=>{const r=sv();return rv(((o=[])=>(o[1]||(o[0]=void 0!==n?n(t):t,o[1]=t=>{const n=e(o[0],t);n!=o[0]&&(o[0]=n,r())}),o)))},Fv=(e,t)=>zv((()=>e),t),jv=e=>{const{current:t}=iv();if(!(e in t))throw new yv(t,`For useProp("${e}"), the prop does not exist on the host.`,e);return rv(((n=new $v(t[e],((n,r)=>{n=uv(n)?n(t[e]):n,t[e]=n})))=>(n[0]=t[e],n)))},_v=(e,t={})=>{const n=iv();return n[e]||(n[e]=(r=t.detail)=>Cv(n.current,{type:e,...t,detail:r})),n[e]},Wv=av("atomico/options");globalThis[Wv]=globalThis[Wv]||{sheet:!!document.adoptedStyleSheets};const Vv=globalThis[Wv],Hv=new Promise((e=>{Vv.ssr||("loading"===document.readyState?mv(document,"DOMContentLoaded",e):e())})),qv={checked:1,value:1,selected:1},Kv={list:1,type:1,size:1,form:1,width:1,height:1,src:1,href:1,slot:1},Uv={shadowDom:1,staticNode:1,cloneNode:1,children:1,key:1},Jv={},Yv=[];class Gv extends Text{}const Xv=av("atomico/id"),Zv=av("atomico/type"),Qv=av("atomico/ref"),eb=av("atomico/vnode"),tb=()=>{};function nb(e,t,n){return ob(this,e,t,n)}const rb=(e,t,...n)=>{const r=t||Jv;let{children:o}=r;if(o=null!=o?o:n.length?n:Yv,e===tb)return o;const i=e?e instanceof Node?1:e.prototype instanceof HTMLElement&&2:0;if(!1===i&&e instanceof Function)return e(o!=Yv?{children:o,...r}:r);const s=Vv.render||nb;return{[Zv]:eb,type:e,props:r,children:o,key:r.key,shadow:r.shadowDom,static:r.staticNode,raw:i,is:r.is,clone:r.cloneNode,render:s}};function ob(e,t,n=Xv,r,o){let i;if(t&&t[n]&&t[n].vnode==e||e[Zv]!=eb)return t;!e&&t||(o=o||"svg"==e.type,i="host"!=e.type&&(1==e.raw?(t&&e.clone?t[Qv]:t)!=e.type:2==e.raw?!(t instanceof e.type):t?t[Qv]||t.localName!=e.type:!t),i&&null!=e.type&&(1==e.raw&&e.clone?(r=!0,(t=e.type.cloneNode(!0))[Qv]=e.type):t=1==e.raw?e.type:2==e.raw?new e.type:o?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type,e.is?{is:e.is}:void 0)));const s=t[n]?t[n]:Jv,{vnode:l=Jv,cycle:a=0}=s;let{fragment:c,handlers:u}=s;const{children:d=Yv,props:h=Jv}=l;if(u=i?{}:u||{},e.static&&!i)return t;if(e.shadow&&!t.shadowRoot&&t.attachShadow({mode:"open",...e.shadow}),e.props!=h&&function(e,t,n,r,o){for(const i in t)!(i in n)&&ib(e,i,t[i],null,o,r);for(const i in n)ib(e,i,t[i],n[i],o,r)}(t,h,e.props,u,o),e.children!==d){const i=e.shadow?t.shadowRoot:t;c=function(e,t,n,r,o,i){e=null==e?null:hv(e)?e:[e];const s=t||function(e,t){const n=new Gv(""),r=new Gv("");let o;if(e[t?"prepend":"append"](n),t){let{lastElementChild:t}=e;for(;t;){const{previousElementSibling:e}=t;if(pv(t,!0)&&!pv(e,!0)){o=t;break}t=e}}return o?o.before(r):e.append(r),{markStart:n,markEnd:r}}(n,o),{markStart:l,markEnd:a,keyes:c}=s;let u;const d=c&&new Set;let h=l;if(e&&fv(e,(e=>{if("object"==typeof e&&!e[Zv])return;const t=e[Zv]&&e.key,s=c&&null!=t&&c.get(t);h!=a&&h===s?d.delete(h):h=h==a?a:h.nextSibling;const l=c?s:h;let p=l;if(e[Zv])p=ob(e,l,r,o,i);else{const t=e+"";!(p instanceof Text)||p instanceof Gv?p=new Text(t):p.data!=t&&(p.data=t)}p!=h&&(c&&d.delete(p),!l||c?(n.insertBefore(p,h),c&&h!=a&&d.add(h)):l==a?n.insertBefore(p,a):(n.replaceChild(p,l),h=p)),null!=t&&(u=u||new Map,u.set(t,p))})),h=h==a?a:h.nextSibling,t&&h!=a)for(;h!=a;){const e=h;h=h.nextSibling,e.remove()}return d&&d.forEach((e=>e.remove())),s.keyes=u,s}(e.children,c,i,n,!a&&r,(!o||"foreignObject"!=e.type)&&o)}return t[n]={vnode:e,handlers:u,fragment:c,cycle:a+1},t}function ib(e,t,n,r,o,i){if(n=null==n?null:n,r=null==r?null:r,(t="class"!=t||o?t:"className")in e&&qv[t]&&(n=e[t]),r!==n&&!Uv[t]&&"_"!=t[0])if("slot"===e.localName&&"assignNode"===t&&"assign"in e)e.assign(r);else if("o"==t[0]&&"n"==t[1]&&(uv(r)||uv(n)))!function(e,t,n,r){if(r.handleEvent||(r.handleEvent=t=>r[t.type].call(e,t)),n){if(!r[t]){const o=n.capture||n.once||n.passive?Object.assign({},n):null;e.addEventListener(t,r,o)}r[t]=n}else r[t]&&(e.removeEventListener(t,r),delete r[t])}(e,t.slice(2),r,i);else if("ref"==t)r&&(uv(r)?r(e):r.current=e);else if("style"==t){const{style:t}=e;r=r||"";const o=dv(n=n||""),i=dv(r);if(o)for(const e in n){if(!i)break;!(e in r)&&sb(t,e,null)}if(i)for(const e in r){const i=r[e];o&&n[e]===i||sb(t,e,i)}else t.cssText=r}else{const i="$"==t[0]?t.slice(1):t;i===t&&(!o&&!Kv[t]&&t in e||uv(r)||uv(n))?e[t]=null==r?"":r:null==r?e.removeAttribute(i):e.setAttribute(i,dv(r)?JSON.stringify(r):r)}}function sb(e,t,n){let r="setProperty";null==n&&(r="removeProperty",n=null),~t.indexOf("-")?e[r](t,n):e[t]=n}const lb=rb("host",{style:"display: contents"}),ab="value",cb=(e,t)=>{const n=iv(),r=ov();Pv((()=>mv(n.current,"ConnectContext",(t=>{t.composedPath().at(0)!==t.currentTarget&&e===t.detail.id&&(t.stopPropagation(),t.detail.connect(r))}))),[e]),r.current=t},ub=e=>{const t=_v("ConnectContext",{bubbles:!0,composed:!0}),[n,r]=Lv((()=>{if(Vv.ssr)return;let n;return t({id:e,connect(e){n=e}}),n})),o=sv();return Rv((()=>{Hv.then((()=>t({id:e,connect:r})))}),[e]),Rv((()=>{if(n)return n.on(o)}),[n]),n?.current||e[ab]},db=e=>{const t=Ev((({value:e})=>(cb(t,e),lb)),{props:{value:{type:Object,value:()=>e}}});return t[ab]=e,t},hb="PendingSuspense",pb="FulfilledSuspense",fb="AbortedSuspense",mb=db({dispatch(e,t){}}),gb=(e=8)=>{const[t,n]=Lv({pending:!0}),r=(e,t)=>requestAnimationFrame((()=>t?r(e,--t):e())),o=zv((()=>{const t=new Set;let o=!1,i=!1,s=!1;const l=()=>{o||(o=!0,r((()=>{o=!1,n((e=>t.size?e.pending?e:{pending:!0}:s?e.aborted?e:{aborted:s}:i?e.rejected?e:{rejected:i}:e.fulfilled?e:{fulfilled:!0}))}),e))};return{dispatch:(e,n)=>{e===hb?(t.add(n),l()):t.has(n)&&(t.delete(n),e===pb||(e===fb?s=!0:i=!0),l())}}}),[]);return cb(mb,o),t},yb=(e,t,n=!0)=>{const r=lv(),{dispatch:o}=ub(mb),[i,s]=Lv(n?{pending:n}:{}),l=t||[];return Rv((()=>{if(n){let t;return s(i.pending?i:{pending:!0}),e(...l).then((e=>{!t&&s({result:e,fulfilled:!0})}),(e=>{!t&&s("AbortError"===e?.name?{result:e,aborted:!0}:{result:e,rejected:!0})})),()=>t=!0}s((e=>Object.keys(e).length?{}:e))}),[n,...l]),Dv((()=>{i.pending?o(hb,r):i.rejected?o("RejectedSuspense",r):i.aborted?o(fb,r):o(pb,r)}),[o,i]),Rv((()=>()=>{o(pb,r)}),[o]),i},wb=e=>{const t=zv((()=>new AbortController),e);return Rv((()=>()=>t.abort()),[t]),t},kb=(e,t)=>{const n=iv();Pv((()=>{let r,o=!1,i=()=>{r&&r(),r=null};const s=async()=>{o||(o=!0,await n.current.updated,i(),o=!1,r=e())},l=t.map((e=>e?.on(s)));return n.once||(n.once=!0,s()),()=>{l.map((e=>e&&e())),i()}}),t)},vb=(e,t)=>{const n=yb(e,t);if(n.pending)throw Qk;return n.result},bb=(e,t=!Vv.ssr&&document.createElement("template").content)=>t?ob(rb("host",null,e),t).children[0]:e,xb={};function Cb(e,...t){const n=(e.raw||e).reduce(((e,n,r)=>e+n+(t[r]||"")),"");return xb[n]=xb[n]||function(e){if(Vv.sheet){const t=new CSSStyleSheet;return t.replaceSync(e),t}{const t=document.createElement("style");return t.textContent=e,t}}(n)}const Sb=(e,t,n,r)=>{let o;t[0]=0;for(let i=1;i<t.length;i++){const s=t[i++],l=t[i]?(t[0]|=s?1:2,n[t[i++]]):t[++i];3===s?r[0]=l:4===s?r[1]=Object.assign(r[1]||{},l):5===s?(r[1]=r[1]||{})[t[++i]]=l:6===s?r[1][t[++i]]+=l+"":s?(o=e.apply(l,Sb(e,l,n,["",null])),r.push(o),l[0]?t[0]|=2:(t[i-2]=0,t[i]=o)):r.push(l)}return r},Mb=function(e){let t,n,r=1,o="",i="",s=[0];const l=e=>{1===r&&(e||(o=o.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(0,e,o):3===r&&(e||o)?(s.push(3,e,o),r=2):2===r&&"..."===o&&e?s.push(4,e,0):2===r&&o&&!e?s.push(5,0,!0,o):r>=5&&((o||!e&&5===r)&&(s.push(r,0,o,n),r=6),e&&(s.push(r,e,0,n),r=6)),o=""};for(let a=0;a<e.length;a++){a&&(1===r&&l(),l(a));for(let c=0;c<e[a].length;c++)t=e[a][c],1===r?"<"===t?(l(),s=[s],r=3):o+=t:4===r?"--"===o&&">"===t?(r=1,o=""):o=t+o[0]:i?t===i?i="":o+=t:'"'===t||"'"===t?i=t:">"===t?(l(),r=1):r&&("="===t?(r=5,n=o,o=""):"/"===t&&(r<5||">"===e[a][c+1])?(l(),3===r&&(s=s[0]),r=s,(s=s[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(l(),r=2):o+=t),3===r&&"!--"===o&&(r=4,s=s[0])}return l(),s},Nb=new Map;function Tb(e){let t=Nb;return t=Sb(rb,t.get(e)||(t.set(e,t=Mb(e)),t),arguments,[]),t.length>1?t:t[0]}function Ob(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Ob(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}const Ab=function(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Ob(e))&&(r&&(r+=" "),r+=t);return r};var Eb=Object.defineProperty,Ib=Object.getOwnPropertySymbols,Db=Object.prototype.hasOwnProperty,Rb=Object.prototype.propertyIsEnumerable,Pb=(e,t,n)=>t in e?Eb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$b=(e,t)=>{for(var n in t||(t={}))Db.call(t,n)&&Pb(e,n,t[n]);if(Ib)for(var n of Ib(t))Rb.call(t,n)&&Pb(e,n,t[n]);return e};function Lb(e,t){return Object.assign(e,{meta:$b({package:"@milkdown/components"},t)}),e}var zb=Object.defineProperty,Bb=Object.getOwnPropertySymbols,Fb=Object.prototype.hasOwnProperty,jb=Object.prototype.propertyIsEnumerable,_b=(e,t,n)=>t in e?zb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wb=(e,t)=>{for(var n in t||(t={}))Fb.call(t,n)&&_b(e,n,t[n]);if(Bb)for(var n of Bb(t))jb.call(t,n)&&_b(e,n,t[n]);return e};const Vb="image-block",Hb=qp("image-block",(()=>({inline:!1,group:"block",selectable:!0,draggable:!0,isolating:!0,marks:"",atom:!0,priority:100,attrs:{src:{default:""},caption:{default:""},ratio:{default:1}},parseDOM:[{tag:`img[data-type="${Vb}"]`,getAttrs:e=>{var t;if(!(e instanceof HTMLElement))throw _(e);return{src:e.getAttribute("src")||"",caption:e.getAttribute("caption")||"",ratio:Number(null!=(t=e.getAttribute("ratio"))?t:1)}}}],toDOM:e=>["img",Wb({"data-type":Vb},e.attrs)],parseMarkdown:{match:({type:e})=>"image-block"===e,runner:(e,t,n)=>{const r=t.url,o=t.title;let i=Number(t.alt||1);(Number.isNaN(i)||0===i)&&(i=1),e.addNode(n,{src:r,caption:o,ratio:i})}},toMarkdown:{match:e=>"image-block"===e.type.name,runner:(e,t)=>{e.openNode("paragraph"),e.addNode("image",void 0,void 0,{title:t.attrs.caption,url:t.attrs.src,alt:`${Number.parseFloat(t.attrs.ratio).toFixed(2)}`}),e.closeNode()}}})));function qb(e){return ao(e,"paragraph",((e,t,n)=>{var r,o;if(1!==(null==(r=e.children)?void 0:r.length))return;const i=null==(o=e.children)?void 0:o[0];if(!i||"image"!==i.type)return;const{url:s,alt:l,title:a}=i,c={type:"image-block",url:s,alt:l,title:a};n.children.splice(t,1,c)}))}Lb(Hb.node,{displayName:"NodeSchema<image-block>",group:"ImageBlock"});const Kb=Gp("remark-image-block",(()=>()=>qb));Lb(Kb.plugin,{displayName:"Remark<remarkImageBlock>",group:"ImageBlock"}),Lb(Kb.options,{displayName:"RemarkConfig<remarkImageBlock>",group:"ImageBlock"});const Ub={imageIcon:()=>"🌌",captionIcon:()=>"💬",uploadButton:()=>Tb`Upload file`,confirmButton:()=>Tb`Confirm ⏎`,uploadPlaceholderText:"or paste the image link ...",captionPlaceholderText:"Image caption",onUpload:e=>Promise.resolve(URL.createObjectURL(e))},Jb=Hp(Ub,"imageBlockConfigCtx");Lb(Jb,{displayName:"Config<image-block>",group:"ImageBlock"});let Yb=0;const Gb=({src:e="",caption:t="",ratio:n=1,selected:r=!1,readonly:o=!1,setAttr:i,config:s})=>{const l=ov(),a=ov(),c=ov(),[u,d]=Lv(t.length>0),[h,p]=Lv(0!==e.length),[f]=Lv(crypto.randomUUID()),[m,g]=Lv(!1),[y,w]=Lv(e);!function({image:e,resizeHandle:t,ratio:n,setRatio:r,src:o}){const i=iv(),s=zv((()=>i.current.getRootNode()),[i]);Rv((()=>{const t=e.current;t&&(delete t.dataset.origin,delete t.dataset.height,t.style.height="")}),[o]),Rv((()=>{const o=t.current,l=e.current;if(!o||!l)return;const a=e=>{e.preventDefault();const t=l.getBoundingClientRect().top,n=e.clientY-t,r=Number(n<100?100:n).toFixed(2);l.dataset.height=r,l.style.height=`${r}px`},c=()=>{s.removeEventListener("pointermove",a),s.removeEventListener("pointerup",c);const e=Number(l.dataset.origin),t=Number(l.dataset.height),n=Number.parseFloat(Number(t/e).toFixed(2));Number.isNaN(n)||r(n)},u=e=>{e.preventDefault(),s.addEventListener("pointermove",a),s.addEventListener("pointerup",c)},d=e=>{const t=i.current.getBoundingClientRect().width;if(!t)return;const r=e.target,o=r.height,s=r.width,a=s<t?o:t*(o/s),c=(a*n).toFixed(2);l.dataset.origin=a.toFixed(2),l.dataset.height=c,l.style.height=`${c}px`};return l.addEventListener("load",d),o.addEventListener("pointerdown",u),()=>{l.removeEventListener("load",d),o.removeEventListener("pointerdown",u)}}),[])}({image:l,resizeHandle:a,ratio:n,setRatio:e=>null==i?void 0:i("ratio",e),src:e}),Rv((()=>{r||d(t.length>0)}),[r]);const k=()=>{var e,t;null==i||i("src",null!=(t=null==(e=c.current)?void 0:e.value)?t:"")},v=e=>{e.preventDefault(),e.stopPropagation()};return Tb`<host class=${Ab(r&&"selected")}>
2
2
  <div class=${Ab("image-edit",e.length>0&&"hidden")}>
3
3
  <div class="image-icon">${null==s?void 0:s.imageIcon()}</div>
4
4
  <div class=${Ab("link-importer",m&&"focus")}>
@@ -104,7 +104,7 @@ var e={411:e=>{var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString
104
104
  ${null==i?void 0:i.confirmButton()}
105
105
  </div>
106
106
  </div>`}
107
- </host>`};ax.props={src:String,alt:String,title:String,selected:Boolean,setAttr:Function,config:Object},function(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}("milkdown-image-inline",Ev(ax));const cx=Wp(lm.node,(e=>(t,n,r)=>{const o=document.createElement("milkdown-image-inline"),i=e.get(lx.key),s=i.proxyDomURL,l=e=>{if(s){const t=s(e.attrs.src);"string"==typeof t?o.src=t:t.then((e=>{o.src=e}))}else o.src=e.attrs.src;o.alt=e.attrs.alt,o.title=e.attrs.title};return l(t),o.selected=!1,o.setAttr=(e,t)=>{const o=r();null!=o&&n.dispatch(n.state.tr.setNodeAttribute(o,e,t))},o.config=i,{dom:o,update:e=>e.type===t.type&&(l(e),!0),stopEvent:e=>!!(o.selected&&e.target instanceof HTMLInputElement),selectNode:()=>{o.selected=!0},deselectNode:()=>{o.selected=!1},destroy:()=>{o.remove()}}}));ix(cx,{displayName:"NodeView<image-inline>",group:"ImageInline"});const ux=[lx,cx];var dx=n(437);const hx=Math.min,px=Math.max,fx=Math.round,mx=(Math.floor,e=>({x:e,y:e})),gx={left:"right",right:"left",bottom:"top",top:"bottom"},yx={start:"end",end:"start"};function wx(e,t,n){return px(e,hx(t,n))}function kx(e,t){return"function"==typeof e?e(t):e}function vx(e){return e.split("-")[0]}function bx(e){return e.split("-")[1]}function xx(e){return"x"===e?"y":"x"}function Cx(e){return"y"===e?"height":"width"}function Sx(e){return["top","bottom"].includes(vx(e))?"y":"x"}function Mx(e){return xx(Sx(e))}function Nx(e){return e.replace(/start|end/g,(e=>yx[e]))}function Tx(e){return e.replace(/left|right|bottom|top/g,(e=>gx[e]))}function Ox(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ax(e,t,n){let{reference:r,floating:o}=e;const i=Sx(t),s=Mx(t),l=Cx(s),a=vx(t),c="y"===i,u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;let p;switch(a){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(bx(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1)}return p}async function Ex(e,t){var n;void 0===t&&(t={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:a}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=kx(t,e),f=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(p),m=l[h?"floating"===d?"reference":"floating":d],g=Ox(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(m)))||n?m:m.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),y="floating"===d?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,w=await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),k=await(null==i.isElement?void 0:i.isElement(w))&&await(null==i.getScale?void 0:i.getScale(w))||{x:1,y:1},v=Ox(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:w,strategy:a}):y);return{top:(g.top-v.top+f.top)/k.y,bottom:(v.bottom-g.bottom+f.bottom)/k.y,left:(g.left-v.left+f.left)/k.x,right:(v.right-g.right+f.right)/k.x}}function Ix(){return"undefined"!=typeof window}function Rx(e){return $x(e)?(e.nodeName||"").toLowerCase():"#document"}function Dx(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Px(e){var t;return null==(t=($x(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function $x(e){return!!Ix()&&(e instanceof Node||e instanceof Dx(e).Node)}function Lx(e){return!!Ix()&&(e instanceof Element||e instanceof Dx(e).Element)}function Bx(e){return!!Ix()&&(e instanceof HTMLElement||e instanceof Dx(e).HTMLElement)}function zx(e){return!(!Ix()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Dx(e).ShadowRoot)}function Fx(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qx(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function jx(e){return["table","td","th"].includes(Rx(e))}function _x(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function Wx(e){const t=Vx(),n=Lx(e)?qx(e):e;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function Vx(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Hx(e){return["html","body","#document"].includes(Rx(e))}function qx(e){return Dx(e).getComputedStyle(e)}function Kx(e){return Lx(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ux(e){if("html"===Rx(e))return e;const t=e.assignedSlot||e.parentNode||zx(e)&&e.host||Px(e);return zx(t)?t.host:t}function Jx(e){const t=Ux(e);return Hx(t)?e.ownerDocument?e.ownerDocument.body:e.body:Bx(t)&&Fx(t)?t:Jx(t)}function Yx(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const o=Jx(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),s=Dx(o);if(i){const e=Gx(s);return t.concat(s,s.visualViewport||[],Fx(o)?o:[],e&&n?Yx(e):[])}return t.concat(o,Yx(o,[],n))}function Gx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Xx(e){const t=qx(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Bx(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,l=fx(n)!==i||fx(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Zx(e){return Lx(e)?e:e.contextElement}function Qx(e){const t=Zx(e);if(!Bx(t))return mx(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=Xx(t);let s=(i?fx(n.width):n.width)/r,l=(i?fx(n.height):n.height)/o;return s&&Number.isFinite(s)||(s=1),l&&Number.isFinite(l)||(l=1),{x:s,y:l}}const eC=mx(0);function tC(e){const t=Dx(e);return Vx()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:eC}function nC(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const o=e.getBoundingClientRect(),i=Zx(e);let s=mx(1);t&&(r?Lx(r)&&(s=Qx(r)):s=Qx(e));const l=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Dx(e))&&t}(i,n,r)?tC(i):mx(0);let a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const e=Dx(i),t=r&&Lx(r)?Dx(r):r;let n=e,o=Gx(n);for(;o&&r&&t!==n;){const e=Qx(o),t=o.getBoundingClientRect(),r=qx(o),i=t.left+(o.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(o.clientTop+parseFloat(r.paddingTop))*e.y;a*=e.x,c*=e.y,u*=e.x,d*=e.y,a+=i,c+=s,n=Dx(o),o=Gx(n)}}return Ox({width:u,height:d,x:a,y:c})}function rC(e,t){const n=Kx(e).scrollLeft;return t?t.left+n:nC(Px(e)).left+n}function oC(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:rC(e,r)),y:r.top+t.scrollTop}}function iC(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Dx(e),r=Px(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;const e=Vx();(!e||e&&"fixed"===t)&&(l=o.offsetLeft,a=o.offsetTop)}return{width:i,height:s,x:l,y:a}}(e,n);else if("document"===t)r=function(e){const t=Px(e),n=Kx(e),r=e.ownerDocument.body,o=px(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=px(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+rC(e);const l=-n.scrollTop;return"rtl"===qx(r).direction&&(s+=px(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}(Px(e));else if(Lx(t))r=function(e,t){const n=nC(e,!0,"fixed"===t),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Bx(e)?Qx(e):mx(1);return{width:e.clientWidth*i.x,height:e.clientHeight*i.y,x:o*i.x,y:r*i.y}}(t,n);else{const n=tC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ox(r)}function sC(e,t){const n=Ux(e);return!(n===t||!Lx(n)||Hx(n))&&("fixed"===qx(n).position||sC(n,t))}function lC(e,t,n){const r=Bx(t),o=Px(t),i="fixed"===n,s=nC(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const a=mx(0);if(r||!r&&!i)if(("body"!==Rx(t)||Fx(o))&&(l=Kx(t)),r){const e=nC(t,!0,i,t);a.x=e.x+t.clientLeft,a.y=e.y+t.clientTop}else o&&(a.x=rC(o));const c=!o||r||i?mx(0):oC(o,l);return{x:s.left+l.scrollLeft-a.x-c.x,y:s.top+l.scrollTop-a.y-c.y,width:s.width,height:s.height}}function aC(e){return"static"===qx(e).position}function cC(e,t){if(!Bx(e)||"fixed"===qx(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Px(e)===n&&(n=n.ownerDocument.body),n}function uC(e,t){const n=Dx(e);if(_x(e))return n;if(!Bx(e)){let t=Ux(e);for(;t&&!Hx(t);){if(Lx(t)&&!aC(t))return t;t=Ux(t)}return n}let r=cC(e,t);for(;r&&jx(r)&&aC(r);)r=cC(r,t);return r&&Hx(r)&&aC(r)&&!Wx(r)?n:r||function(e){let t=Ux(e);for(;Bx(t)&&!Hx(t);){if(Wx(t))return t;if(_x(t))return null;t=Ux(t)}return null}(e)||n}const dC={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i="fixed"===o,s=Px(r),l=!!t&&_x(t.floating);if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=mx(1);const u=mx(0),d=Bx(r);if((d||!d&&!i)&&(("body"!==Rx(r)||Fx(s))&&(a=Kx(r)),Bx(r))){const e=nC(r);c=Qx(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const h=!s||d||i?mx(0):oC(s,a,!0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-a.scrollTop*c.y+u.y+h.y}},getDocumentElement:Px,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i="clippingAncestors"===n?_x(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=Yx(e,[],!1).filter((e=>Lx(e)&&"body"!==Rx(e))),o=null;const i="fixed"===qx(e).position;let s=i?Ux(e):e;for(;Lx(s)&&!Hx(s);){const t=qx(s),n=Wx(s);n||"fixed"!==t.position||(o=null),(i?!n&&!o:!n&&"static"===t.position&&o&&["absolute","fixed"].includes(o.position)||Fx(s)&&!n&&sC(e,s))?r=r.filter((e=>e!==s)):o=t,s=Ux(s)}return t.set(e,r),r}(t,this._c):[].concat(n),s=[...i,r],l=s[0],a=s.reduce(((e,n)=>{const r=iC(t,n,o);return e.top=px(r.top,e.top),e.right=hx(r.right,e.right),e.bottom=hx(r.bottom,e.bottom),e.left=px(r.left,e.left),e}),iC(t,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:uC,getElementRects:async function(e){const t=this.getOffsetParent||uC,n=this.getDimensions,r=await n(e.floating);return{reference:lC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Xx(e);return{width:t,height:n}},getScale:Qx,isElement:Lx,isRTL:function(e){return"rtl"===qx(e).direction}},hC=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=t,a=await async function(e,t){const{placement:n,platform:r,elements:o}=e,i=await(null==r.isRTL?void 0:r.isRTL(o.floating)),s=vx(n),l=bx(n),a="y"===Sx(n),c=["left","top"].includes(s)?-1:1,u=i&&a?-1:1,d=kx(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:f}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&"number"==typeof f&&(p="end"===l?-1*f:f),a?{x:p*u,y:h*c}:{x:h*c,y:p*u}}(t,e);return s===(null==(n=l.offset)?void 0:n.placement)&&null!=(r=l.arrow)&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},pC=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...a}=kx(e,t),c={x:n,y:r},u=await Ex(t,a),d=Sx(vx(o)),h=xx(d);let p=c[h],f=c[d];if(i){const e="y"===h?"bottom":"right";p=wx(p+u["y"===h?"top":"left"],p,p-u[e])}if(s){const e="y"===d?"bottom":"right";f=wx(f+u["y"===d?"top":"left"],f,f-u[e])}const m=l.fn({...t,[h]:p,[d]:f});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:i,[d]:s}}}}}},fC=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...g}=kx(e,t);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const y=vx(o),w=Sx(l),k=vx(l)===l,v=await(null==a.isRTL?void 0:a.isRTL(c.floating)),b=h||(k||!m?[Tx(l)]:function(e){const t=Tx(e);return[Nx(e),t,Nx(t)]}(l)),x="none"!==f;!h&&x&&b.push(...function(e,t,n,r){const o=bx(e);let i=function(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}(vx(e),"start"===n,r);return o&&(i=i.map((e=>e+"-"+o)),t&&(i=i.concat(i.map(Nx)))),i}(l,m,f,v));const C=[l,...b],S=await Ex(t,g),M=[];let N=(null==(r=i.flip)?void 0:r.overflows)||[];if(u&&M.push(S[y]),d){const e=function(e,t,n){void 0===n&&(n=!1);const r=bx(e),o=Mx(e),i=Cx(o);let s="x"===o?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Tx(s)),[s,Tx(s)]}(o,s,v);M.push(S[e[0]],S[e[1]])}if(N=[...N,{placement:o,overflows:M}],!M.every((e=>e<=0))){var T,O;const e=((null==(T=i.flip)?void 0:T.index)||0)+1,t=C[e];if(t)return{data:{index:e,overflows:N},reset:{placement:t}};let n=null==(O=N.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:O.placement;if(!n)switch(p){case"bestFit":{var A;const e=null==(A=N.filter((e=>{if(x){const t=Sx(e.placement);return t===w||"y"===t}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)])).sort(((e,t)=>e[1]-t[1]))[0])?void 0:A[0];e&&(n=e);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},mC=(e,t,n)=>{const r=new Map,o={platform:dC,...n},i={...o.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),a=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=Ax(c,r,a),h=r,p={},f=0;for(let n=0;n<l.length;n++){const{name:i,fn:m}=l[n],{x:g,y,data:w,reset:k}=await m({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:s,elements:{reference:e,floating:t}});u=null!=g?g:u,d=null!=y?y:d,p={...p,[i]:{...p[i],...w}},k&&f<=50&&(f++,"object"==typeof k&&(k.placement&&(h=k.placement),k.rects&&(c=!0===k.rects?await s.getElementRects({reference:e,floating:t,strategy:o}):k.rects),({x:u,y:d}=Ax(c,h,a))),n=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}})(e,t,{...o,platform:i})};function gC(e,t){const n=Rh(e),r=o=>async()=>{r.key=n,await o.wait($h);const i=t(o);return o.get(Dh).create(n,i),r.run=t=>o.get(Dh).call(e,t),()=>{o.get(Dh).remove(n)}};return r}function yC(e){let t;const n=n=>async()=>(await n.wait(xh),t=e(n),n.update(hh,(e=>[...e,t])),()=>{n.update(hh,(e=>e.filter((e=>e!==t))))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function wC(e){const t=n=>async()=>{await n.wait(xh);const r=e(n),o=Fa(r);return n.update(hh,(e=>[...e,o])),t.keymap=r,()=>{n.update(hh,(e=>e.filter((e=>e!==o))))}};return t}function kC(e,t){const n=te(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}Tp("abcedfghicklmn",10);var vC,bC,xC,CC,SC,MC,NC,TC,OC,AC=e=>{throw TypeError(e)},EC=(e,t,n)=>t.has(e)||AC("Cannot "+n),IC=(e,t,n)=>(EC(e,t,"read from private field"),n?n.call(e):t.get(e)),RC=(e,t,n)=>t.has(e)?AC("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),DC=(e,t,n,r)=>(EC(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class PC{constructor(e){RC(this,TC),RC(this,vC),RC(this,bC),RC(this,xC),RC(this,CC),RC(this,SC),RC(this,MC),RC(this,NC),DC(this,SC,!1),this.onShow=()=>{},this.onHide=()=>{},DC(this,NC,((e,t)=>{var n;const{state:r,composing:o}=e,{selection:i,doc:s}=r,{ranges:l}=i,a=Math.min(...l.map((e=>e.$from.pos))),c=Math.max(...l.map((e=>e.$to.pos))),u=t&&t.doc.eq(s)&&t.selection.eq(i);IC(this,SC)||(null==(n=e.dom.parentElement)||n.appendChild(this.element),DC(this,SC,!0)),o||u||(IC(this,bC).call(this,e,t)?(mC({getBoundingClientRect:()=>Gl(e,a,c)},this.element,{placement:"top",middleware:[fC(),hC(IC(this,MC)),pC(),...IC(this,xC)]}).then((({x:e,y:t})=>{Object.assign(this.element.style,{left:`${e}px`,top:`${t}px`})})),this.show()):this.hide())})),this.update=(e,t)=>{dx(IC(this,NC),IC(this,vC))(e,t)},this.destroy=()=>{},this.show=e=>{this.element.dataset.show="true",e&&mC(e,this.element,{placement:"top",middleware:[fC(),hC(IC(this,MC))],...IC(this,CC)}).then((({x:e,y:t})=>{Object.assign(this.element.style,{left:`${e}px`,top:`${t}px`})})),this.onShow()},this.hide=()=>{"false"!==this.element.dataset.show&&(this.element.dataset.show="false",this.onHide())},this.element=e.content,DC(this,vC,e.debounce??200),DC(this,bC,e.shouldShow??((e,t,n)=>(EC(this,t,"access private method"),n))(0,TC,OC)),DC(this,MC,e.offset),DC(this,xC,e.middleware??[]),DC(this,CC,e.floatingUIOptions??{}),this.element.dataset.show="false"}}function $C(e){const t=kC({},`${e}_TOOLTIP_SPEC`),n=yC((n=>{const r=n.get(t.key);return new il({key:new al(`${e}_TOOLTIP`),...r})})),r=[t,n];return r.key=t.key,r.pluginKey=n.key,t.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${e}`},n.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${e}`},r}vC=new WeakMap,bC=new WeakMap,xC=new WeakMap,CC=new WeakMap,SC=new WeakMap,MC=new WeakMap,NC=new WeakMap,TC=new WeakSet,OC=function(e){const{doc:t,selection:n}=e.state,{empty:r,from:o,to:i}=n,s=!t.textBetween(o,i).length&&e.state.selection instanceof Hs,l=this.element.contains(document.activeElement),a=!e.hasFocus()&&!l,c=!e.editable;return!(a||r||s||c)};var LC=Object.defineProperty,BC=Object.getOwnPropertySymbols,zC=Object.prototype.hasOwnProperty,FC=Object.prototype.propertyIsEnumerable,jC=(e,t,n)=>t in e?LC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_C=(e,t)=>{for(var n in t||(t={}))zC.call(t,n)&&jC(e,n,t[n]);if(BC)for(var n of BC(t))FC.call(t,n)&&jC(e,n,t[n]);return e};function WC(e,t){return Object.assign(e,{meta:_C({package:"@milkdown/components"},t)}),e}var VC=Object.defineProperty,HC=Object.getOwnPropertySymbols,qC=Object.prototype.hasOwnProperty,KC=Object.prototype.propertyIsEnumerable,UC=(e,t,n)=>t in e?VC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,JC=(e,t)=>{for(var n in t||(t={}))qC.call(t,n)&&UC(e,n,t[n]);if(HC)for(var n of HC(t))KC.call(t,n)&&UC(e,n,t[n]);return e};const YC=Hp(JC({},{mode:"preview"}),"linkTooltipStateCtx");WC(YC,{displayName:"State<link-tooltip>",group:"LinkTooltip"});const GC=Hp(JC({},{addLink:()=>{},editLink:()=>{},removeLink:()=>{}}),"linkTooltipAPICtx");WC(YC,{displayName:"API<link-tooltip>",group:"LinkTooltip"});const XC=Hp(JC({},{linkIcon:()=>"🔗",editButton:()=>"✎",removeButton:()=>"⌫",confirmButton:()=>Tb`Confirm ⏎`,onCopyLink:()=>{},inputPlaceholder:"Paste link..."}),"linkTooltipConfigCtx");WC(YC,{displayName:"Config<link-tooltip>",group:"LinkTooltip"});const ZC=$C("LINK_PREVIEW");WC(ZC[0],{displayName:"PreviewTooltipSpec<link-tooltip>",group:"LinkTooltip"}),WC(ZC[1],{displayName:"PreviewTooltipPlugin<link-tooltip>",group:"LinkTooltip"});const QC=$C("LINK_EDIT");function eS(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}WC(QC[0],{displayName:"EditTooltipSpec<link-tooltip>",group:"LinkTooltip"}),WC(QC[1],{displayName:"EditTooltipPlugin<link-tooltip>",group:"LinkTooltip"});const tS=({config:e,src:t,onEdit:n,onRemove:r})=>Tb`
107
+ </host>`};ax.props={src:String,alt:String,title:String,selected:Boolean,setAttr:Function,config:Object},function(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}("milkdown-image-inline",Ev(ax));const cx=Wp(lm.node,(e=>(t,n,r)=>{const o=document.createElement("milkdown-image-inline"),i=e.get(lx.key),s=i.proxyDomURL,l=e=>{if(s){const t=s(e.attrs.src);"string"==typeof t?o.src=t:t.then((e=>{o.src=e}))}else o.src=e.attrs.src;o.alt=e.attrs.alt,o.title=e.attrs.title};return l(t),o.selected=!1,o.setAttr=(e,t)=>{const o=r();null!=o&&n.dispatch(n.state.tr.setNodeAttribute(o,e,t))},o.config=i,{dom:o,update:e=>e.type===t.type&&(l(e),!0),stopEvent:e=>!!(o.selected&&e.target instanceof HTMLInputElement),selectNode:()=>{o.selected=!0},deselectNode:()=>{o.selected=!1},destroy:()=>{o.remove()}}}));ix(cx,{displayName:"NodeView<image-inline>",group:"ImageInline"});const ux=[lx,cx];var dx=n(176);const hx=Math.min,px=Math.max,fx=Math.round,mx=(Math.floor,e=>({x:e,y:e})),gx={left:"right",right:"left",bottom:"top",top:"bottom"},yx={start:"end",end:"start"};function wx(e,t,n){return px(e,hx(t,n))}function kx(e,t){return"function"==typeof e?e(t):e}function vx(e){return e.split("-")[0]}function bx(e){return e.split("-")[1]}function xx(e){return"x"===e?"y":"x"}function Cx(e){return"y"===e?"height":"width"}function Sx(e){return["top","bottom"].includes(vx(e))?"y":"x"}function Mx(e){return xx(Sx(e))}function Nx(e){return e.replace(/start|end/g,(e=>yx[e]))}function Tx(e){return e.replace(/left|right|bottom|top/g,(e=>gx[e]))}function Ox(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ax(e,t,n){let{reference:r,floating:o}=e;const i=Sx(t),s=Mx(t),l=Cx(s),a=vx(t),c="y"===i,u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;let p;switch(a){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(bx(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1)}return p}async function Ex(e,t){var n;void 0===t&&(t={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:a}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=kx(t,e),f=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(p),m=l[h?"floating"===d?"reference":"floating":d],g=Ox(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(m)))||n?m:m.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),y="floating"===d?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,w=await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),k=await(null==i.isElement?void 0:i.isElement(w))&&await(null==i.getScale?void 0:i.getScale(w))||{x:1,y:1},v=Ox(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:w,strategy:a}):y);return{top:(g.top-v.top+f.top)/k.y,bottom:(v.bottom-g.bottom+f.bottom)/k.y,left:(g.left-v.left+f.left)/k.x,right:(v.right-g.right+f.right)/k.x}}function Ix(){return"undefined"!=typeof window}function Dx(e){return $x(e)?(e.nodeName||"").toLowerCase():"#document"}function Rx(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Px(e){var t;return null==(t=($x(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function $x(e){return!!Ix()&&(e instanceof Node||e instanceof Rx(e).Node)}function Lx(e){return!!Ix()&&(e instanceof Element||e instanceof Rx(e).Element)}function zx(e){return!!Ix()&&(e instanceof HTMLElement||e instanceof Rx(e).HTMLElement)}function Bx(e){return!(!Ix()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Rx(e).ShadowRoot)}function Fx(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qx(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function jx(e){return["table","td","th"].includes(Dx(e))}function _x(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function Wx(e){const t=Vx(),n=Lx(e)?qx(e):e;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function Vx(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Hx(e){return["html","body","#document"].includes(Dx(e))}function qx(e){return Rx(e).getComputedStyle(e)}function Kx(e){return Lx(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ux(e){if("html"===Dx(e))return e;const t=e.assignedSlot||e.parentNode||Bx(e)&&e.host||Px(e);return Bx(t)?t.host:t}function Jx(e){const t=Ux(e);return Hx(t)?e.ownerDocument?e.ownerDocument.body:e.body:zx(t)&&Fx(t)?t:Jx(t)}function Yx(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const o=Jx(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),s=Rx(o);if(i){const e=Gx(s);return t.concat(s,s.visualViewport||[],Fx(o)?o:[],e&&n?Yx(e):[])}return t.concat(o,Yx(o,[],n))}function Gx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Xx(e){const t=qx(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=zx(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,l=fx(n)!==i||fx(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Zx(e){return Lx(e)?e:e.contextElement}function Qx(e){const t=Zx(e);if(!zx(t))return mx(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=Xx(t);let s=(i?fx(n.width):n.width)/r,l=(i?fx(n.height):n.height)/o;return s&&Number.isFinite(s)||(s=1),l&&Number.isFinite(l)||(l=1),{x:s,y:l}}const eC=mx(0);function tC(e){const t=Rx(e);return Vx()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:eC}function nC(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const o=e.getBoundingClientRect(),i=Zx(e);let s=mx(1);t&&(r?Lx(r)&&(s=Qx(r)):s=Qx(e));const l=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Rx(e))&&t}(i,n,r)?tC(i):mx(0);let a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const e=Rx(i),t=r&&Lx(r)?Rx(r):r;let n=e,o=Gx(n);for(;o&&r&&t!==n;){const e=Qx(o),t=o.getBoundingClientRect(),r=qx(o),i=t.left+(o.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(o.clientTop+parseFloat(r.paddingTop))*e.y;a*=e.x,c*=e.y,u*=e.x,d*=e.y,a+=i,c+=s,n=Rx(o),o=Gx(n)}}return Ox({width:u,height:d,x:a,y:c})}function rC(e,t){const n=Kx(e).scrollLeft;return t?t.left+n:nC(Px(e)).left+n}function oC(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:rC(e,r)),y:r.top+t.scrollTop}}function iC(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Rx(e),r=Px(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;const e=Vx();(!e||e&&"fixed"===t)&&(l=o.offsetLeft,a=o.offsetTop)}return{width:i,height:s,x:l,y:a}}(e,n);else if("document"===t)r=function(e){const t=Px(e),n=Kx(e),r=e.ownerDocument.body,o=px(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=px(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+rC(e);const l=-n.scrollTop;return"rtl"===qx(r).direction&&(s+=px(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}(Px(e));else if(Lx(t))r=function(e,t){const n=nC(e,!0,"fixed"===t),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=zx(e)?Qx(e):mx(1);return{width:e.clientWidth*i.x,height:e.clientHeight*i.y,x:o*i.x,y:r*i.y}}(t,n);else{const n=tC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ox(r)}function sC(e,t){const n=Ux(e);return!(n===t||!Lx(n)||Hx(n))&&("fixed"===qx(n).position||sC(n,t))}function lC(e,t,n){const r=zx(t),o=Px(t),i="fixed"===n,s=nC(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const a=mx(0);if(r||!r&&!i)if(("body"!==Dx(t)||Fx(o))&&(l=Kx(t)),r){const e=nC(t,!0,i,t);a.x=e.x+t.clientLeft,a.y=e.y+t.clientTop}else o&&(a.x=rC(o));const c=!o||r||i?mx(0):oC(o,l);return{x:s.left+l.scrollLeft-a.x-c.x,y:s.top+l.scrollTop-a.y-c.y,width:s.width,height:s.height}}function aC(e){return"static"===qx(e).position}function cC(e,t){if(!zx(e)||"fixed"===qx(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Px(e)===n&&(n=n.ownerDocument.body),n}function uC(e,t){const n=Rx(e);if(_x(e))return n;if(!zx(e)){let t=Ux(e);for(;t&&!Hx(t);){if(Lx(t)&&!aC(t))return t;t=Ux(t)}return n}let r=cC(e,t);for(;r&&jx(r)&&aC(r);)r=cC(r,t);return r&&Hx(r)&&aC(r)&&!Wx(r)?n:r||function(e){let t=Ux(e);for(;zx(t)&&!Hx(t);){if(Wx(t))return t;if(_x(t))return null;t=Ux(t)}return null}(e)||n}const dC={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i="fixed"===o,s=Px(r),l=!!t&&_x(t.floating);if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=mx(1);const u=mx(0),d=zx(r);if((d||!d&&!i)&&(("body"!==Dx(r)||Fx(s))&&(a=Kx(r)),zx(r))){const e=nC(r);c=Qx(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const h=!s||d||i?mx(0):oC(s,a,!0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-a.scrollTop*c.y+u.y+h.y}},getDocumentElement:Px,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i="clippingAncestors"===n?_x(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=Yx(e,[],!1).filter((e=>Lx(e)&&"body"!==Dx(e))),o=null;const i="fixed"===qx(e).position;let s=i?Ux(e):e;for(;Lx(s)&&!Hx(s);){const t=qx(s),n=Wx(s);n||"fixed"!==t.position||(o=null),(i?!n&&!o:!n&&"static"===t.position&&o&&["absolute","fixed"].includes(o.position)||Fx(s)&&!n&&sC(e,s))?r=r.filter((e=>e!==s)):o=t,s=Ux(s)}return t.set(e,r),r}(t,this._c):[].concat(n),s=[...i,r],l=s[0],a=s.reduce(((e,n)=>{const r=iC(t,n,o);return e.top=px(r.top,e.top),e.right=hx(r.right,e.right),e.bottom=hx(r.bottom,e.bottom),e.left=px(r.left,e.left),e}),iC(t,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:uC,getElementRects:async function(e){const t=this.getOffsetParent||uC,n=this.getDimensions,r=await n(e.floating);return{reference:lC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Xx(e);return{width:t,height:n}},getScale:Qx,isElement:Lx,isRTL:function(e){return"rtl"===qx(e).direction}},hC=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=t,a=await async function(e,t){const{placement:n,platform:r,elements:o}=e,i=await(null==r.isRTL?void 0:r.isRTL(o.floating)),s=vx(n),l=bx(n),a="y"===Sx(n),c=["left","top"].includes(s)?-1:1,u=i&&a?-1:1,d=kx(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:f}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&"number"==typeof f&&(p="end"===l?-1*f:f),a?{x:p*u,y:h*c}:{x:h*c,y:p*u}}(t,e);return s===(null==(n=l.offset)?void 0:n.placement)&&null!=(r=l.arrow)&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},pC=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...a}=kx(e,t),c={x:n,y:r},u=await Ex(t,a),d=Sx(vx(o)),h=xx(d);let p=c[h],f=c[d];if(i){const e="y"===h?"bottom":"right";p=wx(p+u["y"===h?"top":"left"],p,p-u[e])}if(s){const e="y"===d?"bottom":"right";f=wx(f+u["y"===d?"top":"left"],f,f-u[e])}const m=l.fn({...t,[h]:p,[d]:f});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:i,[d]:s}}}}}},fC=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...g}=kx(e,t);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const y=vx(o),w=Sx(l),k=vx(l)===l,v=await(null==a.isRTL?void 0:a.isRTL(c.floating)),b=h||(k||!m?[Tx(l)]:function(e){const t=Tx(e);return[Nx(e),t,Nx(t)]}(l)),x="none"!==f;!h&&x&&b.push(...function(e,t,n,r){const o=bx(e);let i=function(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}(vx(e),"start"===n,r);return o&&(i=i.map((e=>e+"-"+o)),t&&(i=i.concat(i.map(Nx)))),i}(l,m,f,v));const C=[l,...b],S=await Ex(t,g),M=[];let N=(null==(r=i.flip)?void 0:r.overflows)||[];if(u&&M.push(S[y]),d){const e=function(e,t,n){void 0===n&&(n=!1);const r=bx(e),o=Mx(e),i=Cx(o);let s="x"===o?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Tx(s)),[s,Tx(s)]}(o,s,v);M.push(S[e[0]],S[e[1]])}if(N=[...N,{placement:o,overflows:M}],!M.every((e=>e<=0))){var T,O;const e=((null==(T=i.flip)?void 0:T.index)||0)+1,t=C[e];if(t)return{data:{index:e,overflows:N},reset:{placement:t}};let n=null==(O=N.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:O.placement;if(!n)switch(p){case"bestFit":{var A;const e=null==(A=N.filter((e=>{if(x){const t=Sx(e.placement);return t===w||"y"===t}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)])).sort(((e,t)=>e[1]-t[1]))[0])?void 0:A[0];e&&(n=e);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},mC=(e,t,n)=>{const r=new Map,o={platform:dC,...n},i={...o.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),a=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=Ax(c,r,a),h=r,p={},f=0;for(let n=0;n<l.length;n++){const{name:i,fn:m}=l[n],{x:g,y,data:w,reset:k}=await m({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:s,elements:{reference:e,floating:t}});u=null!=g?g:u,d=null!=y?y:d,p={...p,[i]:{...p[i],...w}},k&&f<=50&&(f++,"object"==typeof k&&(k.placement&&(h=k.placement),k.rects&&(c=!0===k.rects?await s.getElementRects({reference:e,floating:t,strategy:o}):k.rects),({x:u,y:d}=Ax(c,h,a))),n=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}})(e,t,{...o,platform:i})};function gC(e,t){const n=Dh(e),r=o=>async()=>{r.key=n,await o.wait($h);const i=t(o);return o.get(Rh).create(n,i),r.run=t=>o.get(Rh).call(e,t),()=>{o.get(Rh).remove(n)}};return r}function yC(e){let t;const n=n=>async()=>(await n.wait(xh),t=e(n),n.update(hh,(e=>[...e,t])),()=>{n.update(hh,(e=>e.filter((e=>e!==t))))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function wC(e){const t=n=>async()=>{await n.wait(xh);const r=e(n),o=ja(r);return n.update(hh,(e=>[...e,o])),t.keymap=r,()=>{n.update(hh,(e=>e.filter((e=>e!==o))))}};return t}function kC(e,t){const n=ne(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}Tp("abcedfghicklmn",10);var vC,bC,xC,CC,SC,MC,NC,TC,OC,AC=e=>{throw TypeError(e)},EC=(e,t,n)=>t.has(e)||AC("Cannot "+n),IC=(e,t,n)=>(EC(e,t,"read from private field"),n?n.call(e):t.get(e)),DC=(e,t,n)=>t.has(e)?AC("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),RC=(e,t,n,r)=>(EC(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class PC{constructor(e){DC(this,TC),DC(this,vC),DC(this,bC),DC(this,xC),DC(this,CC),DC(this,SC),DC(this,MC),DC(this,NC),RC(this,SC,!1),this.onShow=()=>{},this.onHide=()=>{},RC(this,NC,((e,t)=>{var n;const{state:r,composing:o}=e,{selection:i,doc:s}=r,{ranges:l}=i,a=Math.min(...l.map((e=>e.$from.pos))),c=Math.max(...l.map((e=>e.$to.pos))),u=t&&t.doc.eq(s)&&t.selection.eq(i);IC(this,SC)||(null==(n=e.dom.parentElement)||n.appendChild(this.element),RC(this,SC,!0)),o||u||(IC(this,bC).call(this,e,t)?(mC({getBoundingClientRect:()=>Xl(e,a,c)},this.element,{placement:IC(this,CC).placement??"top",middleware:[fC(),hC(IC(this,MC)),pC(),...IC(this,xC)]}).then((({x:e,y:t})=>{Object.assign(this.element.style,{left:`${e}px`,top:`${t}px`})})),this.show()):this.hide())})),this.update=(e,t)=>{dx(IC(this,NC),IC(this,vC))(e,t)},this.destroy=()=>{},this.show=e=>{this.element.dataset.show="true",e&&mC(e,this.element,{placement:"top",middleware:[fC(),hC(IC(this,MC))],...IC(this,CC)}).then((({x:e,y:t})=>{Object.assign(this.element.style,{left:`${e}px`,top:`${t}px`})})),this.onShow()},this.hide=()=>{"false"!==this.element.dataset.show&&(this.element.dataset.show="false",this.onHide())},this.element=e.content,RC(this,vC,e.debounce??200),RC(this,bC,e.shouldShow??((e,t,n)=>(EC(this,t,"access private method"),n))(0,TC,OC)),RC(this,MC,e.offset),RC(this,xC,e.middleware??[]),RC(this,CC,e.floatingUIOptions??{}),this.element.dataset.show="false"}}function $C(e){const t=kC({},`${e}_TOOLTIP_SPEC`),n=yC((n=>{const r=n.get(t.key);return new sl({key:new cl(`${e}_TOOLTIP`),...r})})),r=[t,n];return r.key=t.key,r.pluginKey=n.key,t.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${e}`},n.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${e}`},r}vC=new WeakMap,bC=new WeakMap,xC=new WeakMap,CC=new WeakMap,SC=new WeakMap,MC=new WeakMap,NC=new WeakMap,TC=new WeakSet,OC=function(e){const{doc:t,selection:n}=e.state,{empty:r,from:o,to:i}=n,s=!t.textBetween(o,i).length&&e.state.selection instanceof qs,l=this.element.contains(document.activeElement),a=!e.hasFocus()&&!l,c=!e.editable;return!(a||r||s||c)};var LC=n(437),zC=Object.defineProperty,BC=Object.getOwnPropertySymbols,FC=Object.prototype.hasOwnProperty,jC=Object.prototype.propertyIsEnumerable,_C=(e,t,n)=>t in e?zC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,WC=(e,t)=>{for(var n in t||(t={}))FC.call(t,n)&&_C(e,n,t[n]);if(BC)for(var n of BC(t))jC.call(t,n)&&_C(e,n,t[n]);return e};function VC(e,t){return Object.assign(e,{meta:WC({package:"@milkdown/components"},t)}),e}var HC=Object.defineProperty,qC=Object.getOwnPropertySymbols,KC=Object.prototype.hasOwnProperty,UC=Object.prototype.propertyIsEnumerable,JC=(e,t,n)=>t in e?HC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,YC=(e,t)=>{for(var n in t||(t={}))KC.call(t,n)&&JC(e,n,t[n]);if(qC)for(var n of qC(t))UC.call(t,n)&&JC(e,n,t[n]);return e};const GC=Hp(YC({},{mode:"preview"}),"linkTooltipStateCtx");VC(GC,{displayName:"State<link-tooltip>",group:"LinkTooltip"});const XC=Hp(YC({},{addLink:()=>{},editLink:()=>{},removeLink:()=>{}}),"linkTooltipAPICtx");VC(GC,{displayName:"API<link-tooltip>",group:"LinkTooltip"});const ZC=Hp(YC({},{linkIcon:()=>"🔗",editButton:()=>"✎",removeButton:()=>"⌫",confirmButton:()=>Tb`Confirm ⏎`,onCopyLink:()=>{},inputPlaceholder:"Paste link..."}),"linkTooltipConfigCtx");VC(GC,{displayName:"Config<link-tooltip>",group:"LinkTooltip"});const QC=$C("LINK_PREVIEW");VC(QC[0],{displayName:"PreviewTooltipSpec<link-tooltip>",group:"LinkTooltip"}),VC(QC[1],{displayName:"PreviewTooltipPlugin<link-tooltip>",group:"LinkTooltip"});const eS=$C("LINK_EDIT");function tS(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}VC(eS[0],{displayName:"EditTooltipSpec<link-tooltip>",group:"LinkTooltip"}),VC(eS[1],{displayName:"EditTooltipPlugin<link-tooltip>",group:"LinkTooltip"});const nS=({config:e,src:t,onEdit:n,onRemove:r})=>Tb`
108
108
  <host>
109
109
  <div class="link-preview" onmousedown=${n=>{n.preventDefault(),navigator.clipboard&&t&&navigator.clipboard.writeText(t).then((()=>{null==e||e.onCopyLink(t)})).catch((e=>{throw e}))}}>
110
110
  <span class="link-icon"> ${null==e?void 0:e.linkIcon()} </span>
@@ -120,7 +120,7 @@ var e={411:e=>{var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString
120
120
  </span>
121
121
  </div>
122
122
  </host>
123
- `;tS.props={config:Object,src:String,onEdit:Function,onRemove:Function};const nS=Ev(tS);var rS,oS,iS,sS,lS,aS,cS,uS,dS=e=>{throw TypeError(e)},hS=(e,t,n)=>t.has(e)||dS("Cannot "+n),pS=(e,t,n)=>(hS(e,t,"read from private field"),n?n.call(e):t.get(e)),fS=(e,t,n)=>t.has(e)?dS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),mS=(e,t,n,r)=>(hS(e,t,"write to private field"),t.set(e,n),n);class gS{constructor(e,t){this.ctx=e,fS(this,rS,new nS),fS(this,oS),fS(this,iS,this.ctx.use(YC.key)),fS(this,sS,!1),fS(this,lS,(({mode:e})=>{"edit"===e&&pS(this,uS).call(this)})),fS(this,aS,(()=>{mS(this,sS,!0)})),fS(this,cS,(()=>{mS(this,sS,!1)})),fS(this,uS,(()=>{pS(this,oS).hide(),pS(this,oS).element.removeEventListener("mouseenter",pS(this,aS)),pS(this,oS).element.removeEventListener("mouseleave",pS(this,cS))})),this.show=(e,t,n,r)=>{pS(this,rS).config=this.ctx.get(XC.key),pS(this,rS).src=e.attrs.href,pS(this,rS).onEdit=()=>{this.ctx.get(GC.key).editLink(e,t,n)},pS(this,rS).onRemove=()=>{this.ctx.get(GC.key).removeLink(t,n),pS(this,uS).call(this)},pS(this,oS).show({getBoundingClientRect:()=>r}),pS(this,oS).element.addEventListener("mouseenter",pS(this,aS)),pS(this,oS).element.addEventListener("mouseleave",pS(this,cS))},this.hide=()=>{pS(this,sS)||pS(this,uS).call(this)},this.update=()=>{},this.destroy=()=>{pS(this,iS).off(pS(this,lS)),pS(this,oS).destroy(),pS(this,rS).remove()},mS(this,oS,new PC({debounce:0,content:pS(this,rS),shouldShow:()=>!1})),pS(this,oS).update(t),mS(this,iS,e.use(YC.key)),pS(this,iS).on(pS(this,lS))}}rS=new WeakMap,oS=new WeakMap,iS=new WeakMap,sS=new WeakMap,lS=new WeakMap,aS=new WeakMap,cS=new WeakMap,uS=new WeakMap,eS("milkdown-link-preview",nS);const yS=({src:e,onConfirm:t,onCancel:n,config:r})=>{const o=ov(),[i,s]=Lv(e);return Dv((()=>{s(null!=e?e:"")}),[e]),Tb`
123
+ `;nS.props={config:Object,src:String,onEdit:Function,onRemove:Function};const rS=Ev(nS);var oS,iS,sS,lS,aS,cS,uS,dS,hS=e=>{throw TypeError(e)},pS=(e,t,n)=>t.has(e)||hS("Cannot "+n),fS=(e,t,n)=>(pS(e,t,"read from private field"),n?n.call(e):t.get(e)),mS=(e,t,n)=>t.has(e)?hS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),gS=(e,t,n,r)=>(pS(e,t,"write to private field"),t.set(e,n),n);class yS{constructor(e,t){this.ctx=e,mS(this,oS,new rS),mS(this,iS),mS(this,sS,this.ctx.use(GC.key)),mS(this,lS,!1),mS(this,aS,(({mode:e})=>{"edit"===e&&fS(this,dS).call(this)})),mS(this,cS,(()=>{gS(this,lS,!0)})),mS(this,uS,(()=>{gS(this,lS,!1)})),mS(this,dS,(()=>{fS(this,iS).hide(),fS(this,iS).element.removeEventListener("mouseenter",fS(this,cS)),fS(this,iS).element.removeEventListener("mouseleave",fS(this,uS))})),this.show=(e,t,n,r)=>{fS(this,oS).config=this.ctx.get(ZC.key),fS(this,oS).src=e.attrs.href,fS(this,oS).onEdit=()=>{this.ctx.get(XC.key).editLink(e,t,n)},fS(this,oS).onRemove=()=>{this.ctx.get(XC.key).removeLink(t,n),fS(this,dS).call(this)},fS(this,iS).show({getBoundingClientRect:()=>r}),fS(this,iS).element.addEventListener("mouseenter",fS(this,cS)),fS(this,iS).element.addEventListener("mouseleave",fS(this,uS))},this.hide=()=>{fS(this,lS)||fS(this,dS).call(this)},this.update=()=>{},this.destroy=()=>{fS(this,sS).off(fS(this,aS)),fS(this,iS).destroy(),fS(this,oS).remove()},gS(this,iS,new PC({debounce:0,content:fS(this,oS),shouldShow:()=>!1})),fS(this,iS).update(t),gS(this,sS,e.use(GC.key)),fS(this,sS).on(fS(this,aS))}}oS=new WeakMap,iS=new WeakMap,sS=new WeakMap,lS=new WeakMap,aS=new WeakMap,cS=new WeakMap,uS=new WeakMap,dS=new WeakMap,tS("milkdown-link-preview",rS);const wS=({src:e,onConfirm:t,onCancel:n,config:r})=>{const o=ov(),[i,s]=Lv(e);return Rv((()=>{s(null!=e?e:"")}),[e]),Tb`
124
124
  <host>
125
125
  <div class="link-edit">
126
126
  <input
@@ -139,7 +139,7 @@ var e={411:e=>{var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString
139
139
  </span>
140
140
  </div>
141
141
  </host>
142
- `};yS.props={config:Object,src:String,onConfirm:Function,onCancel:Function};const wS=Ev(yS);var kS,vS,bS,xS,CS,SS,MS=Object.defineProperty,NS=Object.defineProperties,TS=Object.getOwnPropertyDescriptors,OS=Object.getOwnPropertySymbols,AS=Object.prototype.hasOwnProperty,ES=Object.prototype.propertyIsEnumerable,IS=e=>{throw TypeError(e)},RS=(e,t,n)=>t in e?MS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,DS=(e,t)=>{for(var n in t||(t={}))AS.call(t,n)&&RS(e,n,t[n]);if(OS)for(var n of OS(t))ES.call(t,n)&&RS(e,n,t[n]);return e},PS=(e,t)=>NS(e,TS(t)),$S=(e,t,n)=>t.has(e)||IS("Cannot "+n),LS=(e,t,n)=>($S(e,t,"read from private field"),n?n.call(e):t.get(e)),BS=(e,t,n)=>t.has(e)?IS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zS=(e,t,n,r)=>($S(e,t,"write to private field"),t.set(e,n),n);const FS={from:-1,to:-1,mark:null};class jS{constructor(e,t){this.ctx=e,BS(this,kS,new wS),BS(this,vS),BS(this,bS,DS({},FS)),BS(this,xS,(()=>{LS(this,vS).hide(),this.ctx.update(YC.key,(e=>PS(DS({},e),{mode:"preview"}))),zS(this,bS,DS({},FS))})),BS(this,CS,(e=>{const t=this.ctx.get(lh),{from:n,to:r,mark:o}=LS(this,bS),i=Df.type(this.ctx);if(o&&o.attrs.href===e)return void LS(this,xS).call(this);const s=t.state.tr;o&&s.removeMark(n,r,o),s.addMark(n,r,i.create({href:e})),t.dispatch(s),LS(this,xS).call(this)})),BS(this,SS,((e,t,n)=>{const r=this.ctx.get(XC.key);LS(this,kS).config=r,LS(this,kS).src=e,this.ctx.update(YC.key,(e=>PS(DS({},e),{mode:"edit"})));const o=this.ctx.get(lh);o.dispatch(o.state.tr.setSelection(Hs.create(o.state.doc,t,n))),LS(this,vS).show({getBoundingClientRect:()=>Gl(o,t,n)}),requestAnimationFrame((()=>{var e;null==(e=LS(this,kS).querySelector("input"))||e.focus()}))})),this.update=e=>{const{state:t}=e,{selection:n}=t;if(!(n instanceof Hs))return;const{from:r,to:o}=n;r===LS(this,bS).from&&o===LS(this,bS).to||LS(this,xS).call(this)},this.destroy=()=>{LS(this,vS).destroy(),LS(this,kS).remove()},this.addLink=(e,t)=>{zS(this,bS,{from:e,to:t,mark:null}),LS(this,SS).call(this,"",e,t)},this.editLink=(e,t,n)=>{zS(this,bS,{from:t,to:n,mark:e}),LS(this,SS).call(this,e.attrs.href,t,n)},this.removeLink=(e,t)=>{const n=this.ctx.get(lh),r=n.state.tr;r.removeMark(e,t,Df.type(this.ctx)),n.dispatch(r),LS(this,xS).call(this)},zS(this,vS,new PC({content:LS(this,kS),debounce:0,shouldShow:()=>!1})),LS(this,vS).onHide=()=>{LS(this,kS).update().catch((e=>{throw e})),t.dom.focus({preventScroll:!0})},LS(this,vS).update(t),LS(this,kS).onConfirm=LS(this,CS),LS(this,kS).onCancel=LS(this,xS)}}kS=new WeakMap,vS=new WeakMap,bS=new WeakMap,xS=new WeakMap,CS=new WeakMap,SS=new WeakMap;var _S=Object.defineProperty,WS=Object.defineProperties,VS=Object.getOwnPropertyDescriptors,HS=Object.getOwnPropertySymbols,qS=Object.prototype.hasOwnProperty,KS=Object.prototype.propertyIsEnumerable,US=(e,t,n)=>t in e?_S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,JS=(e,t)=>{for(var n in t||(t={}))qS.call(t,n)&&US(e,n,t[n]);if(HS)for(var n of HS(t))KS.call(t,n)&&US(e,n,t[n]);return e},YS=(e,t)=>WS(e,VS(t));function GS(e){(function(e){let t;const n=dx(((n,r)=>{if(!t)return;if(!n.hasFocus())return;if("edit"===e.get(YC.key).mode)return;const o=function(e,t,n){const r=t.posAtCoords({left:n.clientX,top:n.clientY});if(!r)return;const{pos:o}=r,i=t.state.doc.nodeAt(o);if(!i)return;const s=i.marks.find((t=>t.type===Df.mark.type(e)));return s&&ZC.pluginKey()?{show:!0,pos:o,node:i,mark:s}:void 0}(e,n,r);if(o){const e=n.state.doc.resolve(o.pos),r=function(e,t,n,r,o){let i={start:-1,end:-1};return n.nodesBetween(r,o,((n,r)=>{if(i.start>-1)return!1;-1===i.start&&e.isInSet(n.marks)&&t===n&&(i={start:r,end:r+Math.max(n.textContent.length,1)})})),i}(o.mark,o.node,n.state.doc,e.before(),e.after()),i=r.start,s=r.end;t.show(o.mark,i,s,Gl(n,i,s))}else t.hide()}),200);e.set(ZC.key,{props:{handleDOMEvents:{mousemove:n,mouseleave:()=>{setTimeout((()=>{null==t||t.hide()}),200)}}},view:n=>(t=new gS(e,n),t)})})(e),function(e){let t;e.update(GC.key,(e=>YS(JS({},e),{addLink:(e,n)=>{null==t||t.addLink(e,n)},editLink:(e,n,r)=>{null==t||t.editLink(e,n,r)},removeLink:(e,n)=>{null==t||t.removeLink(e,n)}}))),e.set(QC.key,{view:n=>(t=new jS(e,n),t)})}(e)}eS("milkdown-link-edit",wS);const XS=[YC,GC,XC,ZC,QC].flat();var ZS=Object.defineProperty,QS=Object.getOwnPropertySymbols,eM=Object.prototype.hasOwnProperty,tM=Object.prototype.propertyIsEnumerable,nM=(e,t,n)=>t in e?ZS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rM=(e,t)=>{for(var n in t||(t={}))eM.call(t,n)&&nM(e,n,t[n]);if(QS)for(var n of QS(t))tM.call(t,n)&&nM(e,n,t[n]);return e};function oM(e,t){return Object.assign(e,{meta:rM({package:"@milkdown/components"},t)}),e}const iM=({selected:e,label:t="",listType:n="",checked:r,onMount:o,setAttr:i,config:s,readonly:l})=>{const a=iv(),c=ov();Rv((()=>{const e=c.current;if(!e)return;const t=a.current.querySelector("[data-content-dom]");t&&(e.appendChild(t),null==o||o())}),[]);const u={label:t,listType:n,checked:r,readonly:l};return Tb`<host class=${e&&"ProseMirror-selectednode"}>
142
+ `};wS.props={config:Object,src:String,onConfirm:Function,onCancel:Function};const kS=Ev(wS);var vS,bS,xS,CS,SS,MS,NS=Object.defineProperty,TS=Object.defineProperties,OS=Object.getOwnPropertyDescriptors,AS=Object.getOwnPropertySymbols,ES=Object.prototype.hasOwnProperty,IS=Object.prototype.propertyIsEnumerable,DS=e=>{throw TypeError(e)},RS=(e,t,n)=>t in e?NS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,PS=(e,t)=>{for(var n in t||(t={}))ES.call(t,n)&&RS(e,n,t[n]);if(AS)for(var n of AS(t))IS.call(t,n)&&RS(e,n,t[n]);return e},$S=(e,t)=>TS(e,OS(t)),LS=(e,t,n)=>t.has(e)||DS("Cannot "+n),zS=(e,t,n)=>(LS(e,t,"read from private field"),n?n.call(e):t.get(e)),BS=(e,t,n)=>t.has(e)?DS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),FS=(e,t,n,r)=>(LS(e,t,"write to private field"),t.set(e,n),n);const jS={from:-1,to:-1,mark:null};class _S{constructor(e,t){this.ctx=e,BS(this,vS,new kS),BS(this,bS),BS(this,xS,PS({},jS)),BS(this,CS,(()=>{zS(this,bS).hide(),this.ctx.update(GC.key,(e=>$S(PS({},e),{mode:"preview"}))),FS(this,xS,PS({},jS))})),BS(this,SS,(e=>{const t=this.ctx.get(lh),{from:n,to:r,mark:o}=zS(this,xS),i=Rf.type(this.ctx);if(o&&o.attrs.href===e)return void zS(this,CS).call(this);const s=t.state.tr;o&&s.removeMark(n,r,o),s.addMark(n,r,i.create({href:e})),t.dispatch(s),zS(this,CS).call(this)})),BS(this,MS,((e,t,n)=>{const r=this.ctx.get(ZC.key);zS(this,vS).config=r,zS(this,vS).src=e,this.ctx.update(GC.key,(e=>$S(PS({},e),{mode:"edit"})));const o=this.ctx.get(lh);o.dispatch(o.state.tr.setSelection(qs.create(o.state.doc,t,n))),zS(this,bS).show({getBoundingClientRect:()=>Xl(o,t,n)}),requestAnimationFrame((()=>{var e;null==(e=zS(this,vS).querySelector("input"))||e.focus()}))})),this.update=e=>{const{state:t}=e,{selection:n}=t;if(!(n instanceof qs))return;const{from:r,to:o}=n;r===zS(this,xS).from&&o===zS(this,xS).to||zS(this,CS).call(this)},this.destroy=()=>{zS(this,bS).destroy(),zS(this,vS).remove()},this.addLink=(e,t)=>{FS(this,xS,{from:e,to:t,mark:null}),zS(this,MS).call(this,"",e,t)},this.editLink=(e,t,n)=>{FS(this,xS,{from:t,to:n,mark:e}),zS(this,MS).call(this,e.attrs.href,t,n)},this.removeLink=(e,t)=>{const n=this.ctx.get(lh),r=n.state.tr;r.removeMark(e,t,Rf.type(this.ctx)),n.dispatch(r),zS(this,CS).call(this)},FS(this,bS,new PC({content:zS(this,vS),debounce:0,shouldShow:()=>!1})),zS(this,bS).onHide=()=>{zS(this,vS).update().catch((e=>{throw e})),t.dom.focus({preventScroll:!0})},zS(this,bS).update(t),zS(this,vS).onConfirm=zS(this,SS),zS(this,vS).onCancel=zS(this,CS)}}vS=new WeakMap,bS=new WeakMap,xS=new WeakMap,CS=new WeakMap,SS=new WeakMap,MS=new WeakMap;var WS=Object.defineProperty,VS=Object.defineProperties,HS=Object.getOwnPropertyDescriptors,qS=Object.getOwnPropertySymbols,KS=Object.prototype.hasOwnProperty,US=Object.prototype.propertyIsEnumerable,JS=(e,t,n)=>t in e?WS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,YS=(e,t)=>{for(var n in t||(t={}))KS.call(t,n)&&JS(e,n,t[n]);if(qS)for(var n of qS(t))US.call(t,n)&&JS(e,n,t[n]);return e},GS=(e,t)=>VS(e,HS(t));function XS(e){(function(e){let t;const n=LC(((n,r)=>{if(!t)return;if(!n.hasFocus())return;if("edit"===e.get(GC.key).mode)return;const o=function(e,t,n){const r=t.posAtCoords({left:n.clientX,top:n.clientY});if(!r)return;const{pos:o}=r,i=t.state.doc.nodeAt(o);if(!i)return;const s=i.marks.find((t=>t.type===Rf.mark.type(e)));return s&&QC.pluginKey()?{show:!0,pos:o,node:i,mark:s}:void 0}(e,n,r);if(o){const e=n.state.doc.resolve(o.pos),r=function(e,t,n,r,o){let i={start:-1,end:-1};return n.nodesBetween(r,o,((n,r)=>{if(i.start>-1)return!1;-1===i.start&&e.isInSet(n.marks)&&t===n&&(i={start:r,end:r+Math.max(n.textContent.length,1)})})),i}(o.mark,o.node,n.state.doc,e.before(),e.after()),i=r.start,s=r.end;t.show(o.mark,i,s,Xl(n,i,s))}else t.hide()}),200);e.set(QC.key,{props:{handleDOMEvents:{mousemove:n,mouseleave:()=>{setTimeout((()=>{null==t||t.hide()}),200)}}},view:n=>(t=new yS(e,n),t)})})(e),function(e){let t;e.update(XC.key,(e=>GS(YS({},e),{addLink:(e,n)=>{null==t||t.addLink(e,n)},editLink:(e,n,r)=>{null==t||t.editLink(e,n,r)},removeLink:(e,n)=>{null==t||t.removeLink(e,n)}}))),e.set(eS.key,{view:n=>(t=new _S(e,n),t)})}(e)}tS("milkdown-link-edit",kS);const ZS=[GC,XC,ZC,QC,eS].flat();var QS=Object.defineProperty,eM=Object.getOwnPropertySymbols,tM=Object.prototype.hasOwnProperty,nM=Object.prototype.propertyIsEnumerable,rM=(e,t,n)=>t in e?QS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oM=(e,t)=>{for(var n in t||(t={}))tM.call(t,n)&&rM(e,n,t[n]);if(eM)for(var n of eM(t))nM.call(t,n)&&rM(e,n,t[n]);return e};function iM(e,t){return Object.assign(e,{meta:oM({package:"@milkdown/components"},t)}),e}const sM=({selected:e,label:t="",listType:n="",checked:r,onMount:o,setAttr:i,config:s,readonly:l})=>{const a=iv(),c=ov();Dv((()=>{const e=c.current;if(!e)return;const t=a.current.querySelector("[data-content-dom]");t&&(e.appendChild(t),null==o||o())}),[]);const u={label:t,listType:n,checked:r,readonly:l};return Tb`<host class=${e&&"ProseMirror-selectednode"}>
143
143
  <li class="list-item">
144
144
  <div
145
145
  class="label-wrapper"
@@ -150,14 +150,14 @@ var e={411:e=>{var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString
150
150
  </div>
151
151
  <div class="children" ref=${c}></div>
152
152
  </li>
153
- </host>`};iM.props={label:String,checked:Boolean,readonly:Boolean,listType:String,config:Object,selected:Boolean,setAttr:Function,onMount:Function};const sM=Ev(iM),lM={renderLabel:({label:e,listType:t,checked:n,readonly:r})=>null==n?Tb`<span class="label"
153
+ </host>`};sM.props={label:String,checked:Boolean,readonly:Boolean,listType:String,config:Object,selected:Boolean,setAttr:Function,onMount:Function};const lM=Ev(sM),aM={renderLabel:({label:e,listType:t,checked:n,readonly:r})=>null==n?Tb`<span class="label"
154
154
  >${"bullet"===t?"⦿":e}</span
155
155
  >`:Tb`<input
156
156
  disabled=${r}
157
157
  class="label"
158
158
  type="checkbox"
159
159
  checked=${n}
160
- />`},aM=Hp(lM,"listItemBlockConfigCtx");oM(aM,{displayName:"Config<list-item-block>",group:"ListItemBlock"}),function(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}("milkdown-list-item-block",sM);const cM=Wp(Em.node,(e=>(t,n,r)=>{const o=document.createElement("milkdown-list-item-block"),i=document.createElement("div");i.setAttribute("data-content-dom","true"),i.classList.add("content-dom");const s=e.get(aM.key),l=e=>{o.listType=e.attrs.listType,o.label=e.attrs.label,o.checked=e.attrs.checked,o.readonly=!n.editable};l(t),o.appendChild(i),o.selected=!1,o.setAttr=(e,t)=>{const o=r();null!=o&&n.dispatch(n.state.tr.setNodeAttribute(o,e,t))},o.onMount=()=>{const{anchor:e,head:t}=n.state.selection;n.hasFocus()&&Promise.resolve().then((()=>{const r=n.state.doc.resolve(e),o=n.state.doc.resolve(t);n.dispatch(n.state.tr.setSelection(new Hs(r,o)))}))};let a=t;return o.config=s,{dom:o,contentDOM:i,update:e=>e.type===t.type&&(e.sameMarkup(a)&&e.content.eq(a.content)||(a=e,l(e)),!0),ignoreMutation:e=>!o||!i||"selection"!==e.type&&(i===e.target&&"attributes"===e.type||!i.contains(e.target)),selectNode:()=>{o.selected=!0},deselectNode:()=>{o.selected=!1},destroy:()=>{o.remove(),i.remove()}}}));oM(cM,{displayName:"NodeView<list-item-block>",group:"ListItemBlock"});const uM=[aM,cM];var dM=n(176),hM=Object.defineProperty,pM=Object.getOwnPropertySymbols,fM=Object.prototype.hasOwnProperty,mM=Object.prototype.propertyIsEnumerable,gM=(e,t,n)=>t in e?hM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yM=(e,t)=>{for(var n in t||(t={}))fM.call(t,n)&&gM(e,n,t[n]);if(pM)for(var n of pM(t))mM.call(t,n)&&gM(e,n,t[n]);return e};function wM(e,t){return Object.assign(e,{meta:yM({package:"@milkdown/components"},t)}),e}var kM=Object.defineProperty,vM=Object.getOwnPropertySymbols,bM=Object.prototype.hasOwnProperty,xM=Object.prototype.propertyIsEnumerable,CM=(e,t,n)=>t in e?kM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const SM=Hp(((e,t)=>{for(var n in t||(t={}))bM.call(t,n)&&CM(e,n,t[n]);if(vM)for(var n of vM(t))xM.call(t,n)&&CM(e,n,t[n]);return e})({},{renderButton:e=>{switch(e){case"add_row":case"add_col":return"+";case"delete_row":case"delete_col":return"-";case"align_col_left":return"left";case"align_col_center":return"center";case"align_col_right":return"right";case"col_drag_handle":case"row_drag_handle":return"="}}}),"tableBlockConfigCtx");function MM(e,t){for(let n=0;n<e.childCount;n++)if(e.child(n)===t)return n;return-1}function NM(e,[t,n]){const r=e.current;if(!r)return;const o=r.querySelectorAll("tr"),i=o[t];if(!i)return;const s=o[0];if(!s)return;const l=s.children[n];if(!l)return;const a=i.children[n];return a?{row:i,col:a,headerCol:l}:void 0}function TM({refs:e,index:t,before:n,after:r}){const{contentWrapperRef:o,colHandleRef:i,hoverIndex:s}=e,l=i.current;if(!l)return;s.current=t;const a=NM(o,t);if(!a)return;const{headerCol:c}=a;l.dataset.show="true",n&&n(l),mC(c,l,{placement:"top"}).then((({x:e,y:t})=>{Object.assign(l.style,{left:`${e}px`,top:`${t}px`}),r&&r(l)}))}function OM({refs:e,index:t,before:n,after:r}){const{contentWrapperRef:o,rowHandleRef:i,hoverIndex:s}=e,l=i.current;if(!l)return;s.current=t;const a=NM(o,t);if(!a)return;const{row:c}=a;l.dataset.show="true",n&&n(l),mC(c,l,{placement:"left"}).then((({x:e,y:t})=>{Object.assign(l.style,{left:`${e}px`,top:`${t}px`}),r&&r(l)}))}function AM(e){const{dragPreviewRef:t,tableWrapperRef:n,contentWrapperRef:r,yLineHandleRef:o,xLineHandleRef:i,colHandleRef:s,rowHandleRef:l}=e,a=t.current;if(!a)return;const c=n.current;if(!c)return;const u=r.current;if(!u)return;const d=u.querySelector("tbody");if(!d)return;const h=a.querySelector("tbody");if(!h)return;const p=o.current;if(!p)return;const f=i.current;if(!f)return;const m=s.current;if(!m)return;const g=l.current;return g?{preview:a,wrapper:c,content:u,contentRoot:d,previewRoot:h,yHandle:p,xHandle:f,colHandle:m,rowHandle:g}:void 0}function EM(e,t,n,r){const o=null==n?void 0:n.get(lh);if(!(null==o?void 0:o.editable))return;t.stopPropagation(),t.dataTransfer&&(t.dataTransfer.effectAllowed="move");const i=AM(e);i&&requestAnimationFrame((()=>{r(i)}))}function IM(e,t){const n=Bv((()=>function(e,t){return dM((n=>{if(!(null==t?void 0:t.editable))return;const{contentWrapperRef:r,yLineHandleRef:o,xLineHandleRef:i,colHandleRef:s,rowHandleRef:l,hoverIndex:a,lineHoverIndex:c}=e,u=o.current;if(!u)return;const d=i.current;if(!d)return;const h=r.current;if(!h)return;const p=l.current;if(!p)return;const f=s.current;if(!f)return;const m=function(e,t){var n,r,o;if(t)try{const i=t.posAtCoords({left:e.clientX,top:e.clientY});if(!i)return;const s=null==i?void 0:i.inside;if(null==s||s<0)return;const l=t.state.doc.resolve(s),a=t.state.doc.nodeAt(s);if(!a)return;const c=["table_cell","table_header"],u=["table_row","table_header_row"],d=c.includes(a.type.name)?a:null==(n=na((e=>c.includes(e.type.name)))(l))?void 0:n.node,h=null==(r=na((e=>u.includes(e.type.name)))(l))?void 0:r.node,p=null==(o=na((e=>"table"===e.type.name))(l))?void 0:o.node;if(!d||!h||!p)return;const f=MM(h,d);return[MM(p,h),f]}catch(e){return}}(n,t);if(!m)return;const g=NM(r,m);if(!g)return;const[y,w]=m,k=g.col.getBoundingClientRect(),v=Math.abs(n.clientX-k.left)<8,b=Math.abs(k.right-n.clientX)<8,x=Math.abs(n.clientY-k.top)<8,C=Math.abs(k.bottom-n.clientY)<8,S=v||b||x||C,M=p.querySelector(".button-group"),N=f.querySelector(".button-group");if(M&&(M.dataset.show="false"),N&&(N.dataset.show="false"),S){const e=h.getBoundingClientRect();p.dataset.show="false",f.dataset.show="false",d.dataset.displayType="tool",u.dataset.displayType="tool";const t=u.getBoundingClientRect().width,n=d.getBoundingClientRect().height;return v||b?(c.current[1]=v?w:w+1,mC(g.col,u,{placement:v?"left":"right",middleware:[hC(v?-1*t:0)]}).then((({x:t})=>{u.dataset.show="true",Object.assign(u.style,{height:`${e.height}px`,left:`${t}px`})}))):u.dataset.show="false",void(0!==m[0]&&(x||C)?(c.current[0]=x?y:y+1,mC(g.row,d,{placement:x?"top":"bottom",middleware:[hC(x?-1*n:0)]}).then((({y:t})=>{d.dataset.show="true",Object.assign(d.style,{width:`${e.width}px`,top:`${t}px`})}))):d.dataset.show="false")}c.current=[-1,-1],u.dataset.show="false",d.dataset.show="false",p.dataset.show="true",f.dataset.show="true",OM({refs:e,index:m}),TM({refs:e,index:m}),a.current=m}),20)}(e,t)),[]),r=Bv((()=>function(e){return()=>{const{rowHandleRef:t,colHandleRef:n,yLineHandleRef:r,xLineHandleRef:o}=e;setTimeout((()=>{const e=t.current;if(!e)return;const i=n.current;if(!i)return;const s=r.current;if(!s)return;const l=o.current;l&&(e.dataset.show="false",i.dataset.show="false",s.dataset.show="false",l.dataset.show="false")}),200)}}(e)),[]);return{pointerMove:n,pointerLeave:r}}wM(SM,{displayName:"Config<table-block>",group:"TableBlock"});const RM=({view:e,ctx:t,getPos:n,node:r,config:o})=>{const i=iv(),s=ov(),l=ov(),a=ov(),c=ov(),u=ov(),d=ov(),h=ov(),p=ov([0,0]),f=ov([-1,-1]),m=ov(),g=Bv((()=>({dragPreviewRef:h,tableWrapperRef:d,contentWrapperRef:s,yLineHandleRef:u,xLineHandleRef:c,colHandleRef:l,rowHandleRef:a,hoverIndex:p,lineHoverIndex:f,dragInfo:m})),[]);Rv((()=>{const n=s.current;if(!n)return;const o=i.current.querySelector("[data-content-dom]");o&&n.appendChild(o),(null==e?void 0:e.editable)&&function(e,t,n){if(!t)return;if(!n)return;const{selection:r}=t.get(lh).state;if(!(r instanceof kg))return;const{$from:o}=r,i=Yw(o);if(i&&i.node===n)if(r.isColSelection()){const{$head:t}=r;TM({refs:e,index:[0,t.index(t.depth-1)],before:e=>{var t;null==(t=e.querySelector(".button-group"))||t.setAttribute("data-show","true")}})}else if(r.isRowSelection()){const{$head:t}=r,n=na((e=>"table_row"===e.type.name||"table_header_row"===e.type.name))(t);if(!n)return;const o=MM(i.node,n.node);OM({refs:e,index:[o,0],before:e=>{var t;o>0&&(null==(t=e.querySelector(".button-group"))||t.setAttribute("data-show","true"))}})}}(g,t,r)}),[]);const{pointerLeave:y,pointerMove:w}=IM(g,e),{dragRow:k,dragCol:v}=function(e,t,n){const{dragPreviewRef:r,yLineHandleRef:o,xLineHandleRef:i,dragInfo:s}=e,l=iv(),a=Bv((()=>l.current.getRootNode()),[l]),c=Bv((()=>function(e,t){return n=>{EM(e,n,t,(({preview:t,content:r,previewRoot:o,yHandle:i,xHandle:s,colHandle:l,rowHandle:a})=>{var c;const{hoverIndex:u,dragInfo:d}=e;s.dataset.displayType="indicator",i.dataset.show="false",l.dataset.show="false",null==(c=a.querySelector(".button-group"))||c.setAttribute("data-show","false");const[h]=u.current;d.current={startCoords:[n.clientX,n.clientY],startIndex:h,endIndex:h,type:"row"},t.dataset.direction="vertical";const p=r.querySelectorAll("tr");for(;o.firstChild;)o.removeChild(o.firstChild);const f=p[h];if(!f)return;o.appendChild(f.cloneNode(!0));const m=f.getBoundingClientRect().height,{width:g}=r.querySelector("tbody").getBoundingClientRect();Object.assign(t.style,{width:`${g}px`,height:`${m}px`}),t.dataset.show="true"}))}}(e,t)),[e]),u=Bv((()=>function(e,t){return n=>{EM(e,n,t,(({preview:t,content:r,previewRoot:o,yHandle:i,xHandle:s,colHandle:l,rowHandle:a})=>{var c;const{hoverIndex:u,dragInfo:d}=e;s.dataset.show="false",i.dataset.displayType="indicator",a.dataset.show="false",null==(c=l.querySelector(".button-group"))||c.setAttribute("data-show","false");const[h,p]=u.current;d.current={startCoords:[n.clientX,n.clientY],startIndex:p,endIndex:p,type:"col"},t.dataset.direction="horizontal";const f=r.querySelectorAll("tr");for(;o.firstChild;)o.removeChild(o.firstChild);let m;Array.from(f).forEach((e=>{const t=e.children[p];if(!t)return;void 0===m&&(m=t.getBoundingClientRect().width);const n=t.parentElement.cloneNode(!1),r=t.cloneNode(!0);n.appendChild(r),o.appendChild(n)}));const{height:g}=r.querySelector("tbody").getBoundingClientRect();Object.assign(t.style,{width:`${m}px`,height:`${g}px`}),t.dataset.show="true"}))}}(e,t)),[e]);return Dv((()=>{const l=()=>{const e=r.current;if(!e)return;if("false"===e.dataset.show)return;const t=null==e?void 0:e.querySelector("tbody");for(;null==t?void 0:t.firstChild;)null==t||t.removeChild(t.firstChild);e&&(e.dataset.show="false")},c=()=>{var l;const a=r.current;if(!a)return;const c=o.current;if(!c)return;const u=i.current;if(!u)return;const d=s.current;if(!d)return;if(!t)return;if("false"===a.dataset.show)return;if(!e.colHandleRef.current)return;if(!e.rowHandleRef.current)return;if(c.dataset.show="false",u.dataset.show="false",d.startIndex===d.endIndex)return;const h=t.get(Dh),p={from:d.startIndex,to:d.endIndex,pos:(null!=(l=null==n?void 0:n())?l:0)+1};if("col"===d.type){h.call(kk.key,{pos:p.pos,index:d.startIndex}),h.call(yk.key,p);const t=[0,d.endIndex];TM({refs:e,index:t})}else{h.call(wk.key,{pos:p.pos,index:d.startIndex}),h.call(gk.key,p);const t=[d.endIndex,0];OM({refs:e,index:t})}requestAnimationFrame((()=>{t.get(lh).focus()}))},u=function(e){return dM((t=>{const n=AM(e);if(!n)return;const{preview:r,content:o,contentRoot:i,xHandle:s,yHandle:l}=n,{dragInfo:a,hoverIndex:c}=e;if("false"===r.dataset.show)return;const u=NM(e.contentWrapperRef,c.current);if(!u)return;const d=i.querySelector("tr");if(!d)return;const h=a.current;if(!h)return;const p=i.offsetParent.offsetTop,f=i.offsetParent.offsetLeft;if("col"===h.type){const e=u.col.getBoundingClientRect().width,{left:n,width:s}=i.getBoundingClientRect(),a=f-n,c=t.clientX+a-e/2,m=t.clientX+a+e/2,[g]=h.startCoords,y=g<t.clientX?"right":"left";r.style.top=`${p}px`;const w=c<n+a-20?n+a-20:c>n+s+a-e+20?n+s+a-e+20:c;r.style.left=`${w}px`;const k=Array.from(d.children),v=k.find(((e,t)=>{const r=e.getBoundingClientRect();let o=r.left+f-n,i=r.right+f-n;if("right"===y){if(o+=r.width/2,i+=r.width/2,o<=m&&i>=m)return!0;if(t===d.children.length-1&&m>i)return!0}else{if(o-=r.width/2,i-=r.width/2,o<=c&&i>=c)return!0;if(0===t&&c<o)return!0}return!1}));if(v){const e=l.getBoundingClientRect().width,t=o.getBoundingClientRect(),n=k.indexOf(v);h.endIndex=n,mC(v,l,{placement:"left"===y?"left":"right",middleware:[hC("left"===y?-1*e:0)]}).then((({x:e})=>{l.dataset.show="true",Object.assign(l.style,{height:`${t.height}px`,left:`${e}px`,top:`${p}px`})}))}}else if("row"===h.type){const e=u.row.getBoundingClientRect().height,{top:n,height:l}=i.getBoundingClientRect(),a=p-n,c=t.clientY+a-e/2,d=t.clientY+a+e/2,[m,g]=h.startCoords,y=g<t.clientY?"down":"up",w=c<n+a-20?n+a-20:c>n+l+a-e+20?n+l+a-e+20:c;r.style.top=`${w}px`,r.style.left=`${f}px`;const k=Array.from(i.querySelectorAll("tr")),v=k.find(((e,t)=>{const r=e.getBoundingClientRect();let o=r.top+p-n,i=r.bottom+p-n;if("down"===y){if(o+=r.height/2,i+=r.height/2,o<=d&&i>=d)return!0;if(t===k.length-1&&d>i)return!0}else{if(o-=r.height/2,i-=r.height/2,o<=c&&i>=c)return!0;if(0===t&&c<o)return!0}return!1}));if(v){const e=s.getBoundingClientRect().height,t=o.getBoundingClientRect(),n=k.indexOf(v);h.endIndex=n,mC(v,s,{placement:"up"===y?"top":"bottom",middleware:[hC("up"===y?-1*e:0)]}).then((({y:e})=>{s.dataset.show="true",Object.assign(s.style,{width:`${t.width}px`,top:`${e}px`})}))}}}),20)}(e);return a.addEventListener("dragover",u),a.addEventListener("dragend",l),a.addEventListener("drop",c),()=>{a.removeEventListener("dragover",u),a.removeEventListener("dragend",l),a.removeEventListener("drop",c)}}),[]),{dragRow:c,dragCol:u}}(g,t,n),{onAddRow:b,onAddCol:x,selectCol:C,selectRow:S,deleteSelected:M,onAlign:N}=function(e,t,n){const{xLineHandleRef:r,contentWrapperRef:o,colHandleRef:i,rowHandleRef:s,hoverIndex:l,lineHoverIndex:a}=e,c=Fv((()=>{var e,i,s;if(!t)return;const l=r.current;if(!l)return;const[c]=a.current;if(c<0)return;if(!t.get(lh).editable)return;const u=Array.from(null!=(i=null==(e=o.current)?void 0:e.querySelectorAll("tr"))?i:[]),d=t.get(Dh),h=(null!=(s=null==n?void 0:n())?s:0)+1;u.length===c?(d.call(wk.key,{pos:h,index:c-1}),d.call(Mk.key)):(d.call(wk.key,{pos:h,index:c}),d.call(Sk.key)),d.call(wk.key,{pos:h,index:c}),l.dataset.show="false"}),[]),u=Fv((()=>{var e,i,s,l;if(!t)return;if(!r.current)return;const[c,u]=a.current;if(u<0)return;if(!t.get(lh).editable)return;const d=Array.from(null!=(s=null==(i=null==(e=o.current)?void 0:e.querySelector("tr"))?void 0:i.children)?s:[]),h=t.get(Dh),p=(null!=(l=null==n?void 0:n())?l:0)+1;d.length===u?(h.call(kk.key,{pos:p,index:u-1}),h.call(Ck.key)):(h.call(kk.key,{pos:p,index:u}),h.call(xk.key)),h.call(kk.key,{pos:p,index:u})}),[]),d=Fv((()=>{var e,r;if(!t)return;const[o,s]=l.current,a=t.get(Dh),c=(null!=(e=null==n?void 0:n())?e:0)+1;a.call(kk.key,{pos:c,index:s});const u=null==(r=i.current)?void 0:r.querySelector(".button-group");u&&(u.dataset.show="true"===u.dataset.show?"false":"true")}),[]),h=Fv((()=>{var e,r;if(!t)return;const[o,i]=l.current,a=t.get(Dh),c=(null!=(e=null==n?void 0:n())?e:0)+1;a.call(wk.key,{pos:c,index:o});const u=null==(r=s.current)?void 0:r.querySelector(".button-group");u&&o>0&&(u.dataset.show="true"===u.dataset.show?"false":"true")}),[]),p=Fv((e=>{t&&t.get(lh).editable&&(e.preventDefault(),e.stopPropagation(),t.get(Dh).call(bk.key),requestAnimationFrame((()=>{t.get(lh).focus()})))}),[]),f=Fv((e=>n=>{t&&t.get(lh).editable&&(n.preventDefault(),n.stopPropagation(),t.get(Dh).call(Nk.key,e),requestAnimationFrame((()=>{t.get(lh).focus()})))}),[]);return{onAddRow:c,onAddCol:u,selectCol:d,selectRow:h,deleteSelected:p,onAlign:f}}(g,t,n);return Tb`
160
+ />`},cM=Hp(aM,"listItemBlockConfigCtx");iM(cM,{displayName:"Config<list-item-block>",group:"ListItemBlock"}),function(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}("milkdown-list-item-block",lM);const uM=Wp(Em.node,(e=>(t,n,r)=>{const o=document.createElement("milkdown-list-item-block"),i=document.createElement("div");i.setAttribute("data-content-dom","true"),i.classList.add("content-dom");const s=e.get(cM.key),l=e=>{o.listType=e.attrs.listType,o.label=e.attrs.label,o.checked=e.attrs.checked,o.readonly=!n.editable};l(t),o.appendChild(i),o.selected=!1,o.setAttr=(e,t)=>{const o=r();null!=o&&n.dispatch(n.state.tr.setNodeAttribute(o,e,t))},o.onMount=()=>{const{anchor:e,head:t}=n.state.selection;n.hasFocus()&&setTimeout((()=>{const r=n.state.doc.resolve(e),o=n.state.doc.resolve(t);n.dispatch(n.state.tr.setSelection(new qs(r,o)))}))};let a=t;return o.config=s,{dom:o,contentDOM:i,update:e=>e.type===t.type&&(e.sameMarkup(a)&&e.content.eq(a.content)||(a=e,l(e)),!0),ignoreMutation:e=>!o||!i||"selection"!==e.type&&(i===e.target&&"attributes"===e.type||!i.contains(e.target)),selectNode:()=>{o.selected=!0},deselectNode:()=>{o.selected=!1},destroy:()=>{o.remove(),i.remove()}}}));iM(uM,{displayName:"NodeView<list-item-block>",group:"ListItemBlock"});const dM=[cM,uM];var hM=Object.defineProperty,pM=Object.getOwnPropertySymbols,fM=Object.prototype.hasOwnProperty,mM=Object.prototype.propertyIsEnumerable,gM=(e,t,n)=>t in e?hM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yM=(e,t)=>{for(var n in t||(t={}))fM.call(t,n)&&gM(e,n,t[n]);if(pM)for(var n of pM(t))mM.call(t,n)&&gM(e,n,t[n]);return e};function wM(e,t){return Object.assign(e,{meta:yM({package:"@milkdown/components"},t)}),e}var kM=Object.defineProperty,vM=Object.getOwnPropertySymbols,bM=Object.prototype.hasOwnProperty,xM=Object.prototype.propertyIsEnumerable,CM=(e,t,n)=>t in e?kM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const SM=Hp(((e,t)=>{for(var n in t)bM.call(t,n)&&CM(e,n,t[n]);if(vM)for(var n of vM(t))xM.call(t,n)&&CM(e,n,t[n]);return e})({},{renderButton:e=>{switch(e){case"add_row":case"add_col":return"+";case"delete_row":case"delete_col":return"-";case"align_col_left":return"left";case"align_col_center":return"center";case"align_col_right":return"right";case"col_drag_handle":case"row_drag_handle":return"="}}}),"tableBlockConfigCtx");function MM(e,t){for(let n=0;n<e.childCount;n++)if(e.child(n)===t)return n;return-1}function NM(e,[t,n]){const r=e.current;if(!r)return;const o=r.querySelectorAll("tr"),i=o[t];if(!i)return;const s=o[0];if(!s)return;const l=s.children[n];if(!l)return;const a=i.children[n];return a?{row:i,col:a,headerCol:l}:void 0}function TM({refs:e,index:t,before:n,after:r}){const{contentWrapperRef:o,colHandleRef:i,hoverIndex:s}=e,l=i.current;if(!l)return;s.current=t;const a=NM(o,t);if(!a)return;const{headerCol:c}=a;l.dataset.show="true",n&&n(l),mC(c,l,{placement:"top"}).then((({x:e,y:t})=>{Object.assign(l.style,{left:`${e}px`,top:`${t}px`}),r&&r(l)}))}function OM({refs:e,index:t,before:n,after:r}){const{contentWrapperRef:o,rowHandleRef:i,hoverIndex:s}=e,l=i.current;if(!l)return;s.current=t;const a=NM(o,t);if(!a)return;const{row:c}=a;l.dataset.show="true",n&&n(l),mC(c,l,{placement:"left"}).then((({x:e,y:t})=>{Object.assign(l.style,{left:`${e}px`,top:`${t}px`}),r&&r(l)}))}function AM(e){const{dragPreviewRef:t,tableWrapperRef:n,contentWrapperRef:r,yLineHandleRef:o,xLineHandleRef:i,colHandleRef:s,rowHandleRef:l}=e,a=t.current;if(!a)return;const c=n.current;if(!c)return;const u=r.current;if(!u)return;const d=u.querySelector("tbody");if(!d)return;const h=a.querySelector("tbody");if(!h)return;const p=o.current;if(!p)return;const f=i.current;if(!f)return;const m=s.current;if(!m)return;const g=l.current;return g?{preview:a,wrapper:c,content:u,contentRoot:d,previewRoot:h,yHandle:p,xHandle:f,colHandle:m,rowHandle:g}:void 0}function EM(e,t,n,r){const o=null==n?void 0:n.get(lh);if(!(null==o?void 0:o.editable))return;t.stopPropagation(),t.dataTransfer&&(t.dataTransfer.effectAllowed="move");const i=AM(e);i&&requestAnimationFrame((()=>{r(i)}))}function IM(e,t){const n=zv((()=>function(e,t){return dx((n=>{if(!(null==t?void 0:t.editable))return;const{contentWrapperRef:r,yLineHandleRef:o,xLineHandleRef:i,colHandleRef:s,rowHandleRef:l,hoverIndex:a,lineHoverIndex:c}=e,u=o.current;if(!u)return;const d=i.current;if(!d)return;const h=r.current;if(!h)return;const p=l.current;if(!p)return;const f=s.current;if(!f)return;const m=function(e,t){var n,r,o;if(t)try{const i=t.posAtCoords({left:e.clientX,top:e.clientY});if(!i)return;const s=null==i?void 0:i.inside;if(null==s||s<0)return;const l=t.state.doc.resolve(s),a=t.state.doc.nodeAt(s);if(!a)return;const c=["table_cell","table_header"],u=["table_row","table_header_row"],d=c.includes(a.type.name)?a:null==(n=ra((e=>c.includes(e.type.name)))(l))?void 0:n.node,h=null==(r=ra((e=>u.includes(e.type.name)))(l))?void 0:r.node,p=null==(o=ra((e=>"table"===e.type.name))(l))?void 0:o.node;if(!d||!h||!p)return;const f=MM(h,d);return[MM(p,h),f]}catch(e){return}}(n,t);if(!m)return;const g=NM(r,m);if(!g)return;const[y,w]=m,k=g.col.getBoundingClientRect(),v=Math.abs(n.clientX-k.left)<8,b=Math.abs(k.right-n.clientX)<8,x=Math.abs(n.clientY-k.top)<8,C=Math.abs(k.bottom-n.clientY)<8,S=v||b||x||C,M=p.querySelector(".button-group"),N=f.querySelector(".button-group");if(M&&(M.dataset.show="false"),N&&(N.dataset.show="false"),S){const e=h.getBoundingClientRect();p.dataset.show="false",f.dataset.show="false",d.dataset.displayType="tool",u.dataset.displayType="tool";const t=u.getBoundingClientRect().width,n=d.getBoundingClientRect().height;return v||b?(c.current[1]=v?w:w+1,mC(g.col,u,{placement:v?"left":"right",middleware:[hC(v?-1*t:0)]}).then((({x:t})=>{u.dataset.show="true",Object.assign(u.style,{height:`${e.height}px`,left:`${t}px`})}))):u.dataset.show="false",void(0!==m[0]&&(x||C)?(c.current[0]=x?y:y+1,mC(g.row,d,{placement:x?"top":"bottom",middleware:[hC(x?-1*n:0)]}).then((({y:t})=>{d.dataset.show="true",Object.assign(d.style,{width:`${e.width}px`,top:`${t}px`})}))):d.dataset.show="false")}c.current=[-1,-1],u.dataset.show="false",d.dataset.show="false",p.dataset.show="true",f.dataset.show="true",OM({refs:e,index:m}),TM({refs:e,index:m}),a.current=m}),20)}(e,t)),[]),r=zv((()=>function(e){return()=>{const{rowHandleRef:t,colHandleRef:n,yLineHandleRef:r,xLineHandleRef:o}=e;setTimeout((()=>{const e=t.current;if(!e)return;const i=n.current;if(!i)return;const s=r.current;if(!s)return;const l=o.current;l&&(e.dataset.show="false",i.dataset.show="false",s.dataset.show="false",l.dataset.show="false")}),200)}}(e)),[]);return{pointerMove:n,pointerLeave:r}}wM(SM,{displayName:"Config<table-block>",group:"TableBlock"});const DM=({view:e,ctx:t,getPos:n,node:r,config:o})=>{const i=iv(),s=ov(),l=ov(),a=ov(),c=ov(),u=ov(),d=ov(),h=ov(),p=ov([0,0]),f=ov([-1,-1]),m=ov(),g=zv((()=>({dragPreviewRef:h,tableWrapperRef:d,contentWrapperRef:s,yLineHandleRef:u,xLineHandleRef:c,colHandleRef:l,rowHandleRef:a,hoverIndex:p,lineHoverIndex:f,dragInfo:m})),[]);Dv((()=>{const n=s.current;if(!n)return;const o=i.current.querySelector("[data-content-dom]");o&&n.appendChild(o),(null==e?void 0:e.editable)&&function(e,t,n){if(!t)return;if(!n)return;const{selection:r}=t.get(lh).state;if(!(r instanceof kg))return;const{$from:o}=r,i=Yw(o);if(i&&i.node===n)if(r.isColSelection()){const{$head:t}=r;TM({refs:e,index:[0,t.index(t.depth-1)],before:e=>{var t;null==(t=e.querySelector(".button-group"))||t.setAttribute("data-show","true")}})}else if(r.isRowSelection()){const{$head:t}=r,n=ra((e=>"table_row"===e.type.name||"table_header_row"===e.type.name))(t);if(!n)return;const o=MM(i.node,n.node);OM({refs:e,index:[o,0],before:e=>{var t;o>0&&(null==(t=e.querySelector(".button-group"))||t.setAttribute("data-show","true"))}})}}(g,t,r)}),[]);const{pointerLeave:y,pointerMove:w}=IM(g,e),{dragRow:k,dragCol:v}=function(e,t,n){const{dragPreviewRef:r,yLineHandleRef:o,xLineHandleRef:i,dragInfo:s}=e,l=iv(),a=zv((()=>l.current.getRootNode()),[l]),c=zv((()=>function(e,t){return n=>{EM(e,n,t,(({preview:t,content:r,previewRoot:o,yHandle:i,xHandle:s,colHandle:l,rowHandle:a})=>{var c;const{hoverIndex:u,dragInfo:d}=e;s.dataset.displayType="indicator",i.dataset.show="false",l.dataset.show="false",null==(c=a.querySelector(".button-group"))||c.setAttribute("data-show","false");const[h]=u.current;d.current={startCoords:[n.clientX,n.clientY],startIndex:h,endIndex:h,type:"row"},t.dataset.direction="vertical";const p=r.querySelectorAll("tr");for(;o.firstChild;)o.removeChild(o.firstChild);const f=p[h];if(!f)return;o.appendChild(f.cloneNode(!0));const m=f.getBoundingClientRect().height,{width:g}=r.querySelector("tbody").getBoundingClientRect();Object.assign(t.style,{width:`${g}px`,height:`${m}px`}),t.dataset.show="true"}))}}(e,t)),[e]),u=zv((()=>function(e,t){return n=>{EM(e,n,t,(({preview:t,content:r,previewRoot:o,yHandle:i,xHandle:s,colHandle:l,rowHandle:a})=>{var c;const{hoverIndex:u,dragInfo:d}=e;s.dataset.show="false",i.dataset.displayType="indicator",a.dataset.show="false",null==(c=l.querySelector(".button-group"))||c.setAttribute("data-show","false");const[h,p]=u.current;d.current={startCoords:[n.clientX,n.clientY],startIndex:p,endIndex:p,type:"col"},t.dataset.direction="horizontal";const f=r.querySelectorAll("tr");for(;o.firstChild;)o.removeChild(o.firstChild);let m;Array.from(f).forEach((e=>{const t=e.children[p];if(!t)return;void 0===m&&(m=t.getBoundingClientRect().width);const n=t.parentElement.cloneNode(!1),r=t.cloneNode(!0);n.appendChild(r),o.appendChild(n)}));const{height:g}=r.querySelector("tbody").getBoundingClientRect();Object.assign(t.style,{width:`${m}px`,height:`${g}px`}),t.dataset.show="true"}))}}(e,t)),[e]);return Rv((()=>{const l=()=>{const e=r.current;if(!e)return;if("false"===e.dataset.show)return;const t=null==e?void 0:e.querySelector("tbody");for(;null==t?void 0:t.firstChild;)null==t||t.removeChild(t.firstChild);e&&(e.dataset.show="false")},c=()=>{var l;const a=r.current;if(!a)return;const c=o.current;if(!c)return;const u=i.current;if(!u)return;const d=s.current;if(!d)return;if(!t)return;if("false"===a.dataset.show)return;if(!e.colHandleRef.current)return;if(!e.rowHandleRef.current)return;if(c.dataset.show="false",u.dataset.show="false",d.startIndex===d.endIndex)return;const h=t.get(Rh),p={from:d.startIndex,to:d.endIndex,pos:(null!=(l=null==n?void 0:n())?l:0)+1};if("col"===d.type){h.call(kk.key,{pos:p.pos,index:d.startIndex}),h.call(yk.key,p);const t=[0,d.endIndex];TM({refs:e,index:t})}else{h.call(wk.key,{pos:p.pos,index:d.startIndex}),h.call(gk.key,p);const t=[d.endIndex,0];OM({refs:e,index:t})}requestAnimationFrame((()=>{t.get(lh).focus()}))},u=function(e){return dx((t=>{const n=AM(e);if(!n)return;const{preview:r,content:o,contentRoot:i,xHandle:s,yHandle:l}=n,{dragInfo:a,hoverIndex:c}=e;if("false"===r.dataset.show)return;const u=NM(e.contentWrapperRef,c.current);if(!u)return;const d=i.querySelector("tr");if(!d)return;const h=a.current;if(!h)return;if(!i.offsetParent)return;const p=i.offsetParent.offsetTop,f=i.offsetParent.offsetLeft;if("col"===h.type){const e=u.col.getBoundingClientRect().width,{left:n,width:s}=i.getBoundingClientRect(),a=f-n,c=t.clientX+a-e/2,m=t.clientX+a+e/2,[g]=h.startCoords,y=g<t.clientX?"right":"left";r.style.top=`${p}px`;const w=c<n+a-20?n+a-20:c>n+s+a-e+20?n+s+a-e+20:c;r.style.left=`${w}px`;const k=Array.from(d.children),v=k.find(((e,t)=>{const r=e.getBoundingClientRect();let o=r.left+f-n,i=r.right+f-n;if("right"===y){if(o+=r.width/2,i+=r.width/2,o<=m&&i>=m)return!0;if(t===d.children.length-1&&m>i)return!0}else{if(o-=r.width/2,i-=r.width/2,o<=c&&i>=c)return!0;if(0===t&&c<o)return!0}return!1}));if(v){const e=l.getBoundingClientRect().width,t=o.getBoundingClientRect(),n=k.indexOf(v);h.endIndex=n,mC(v,l,{placement:"left"===y?"left":"right",middleware:[hC("left"===y?-1*e:0)]}).then((({x:e})=>{l.dataset.show="true",Object.assign(l.style,{height:`${t.height}px`,left:`${e}px`,top:`${p}px`})}))}}else if("row"===h.type){const e=u.row.getBoundingClientRect().height,{top:n,height:l}=i.getBoundingClientRect(),a=p-n,c=t.clientY+a-e/2,d=t.clientY+a+e/2,[m,g]=h.startCoords,y=g<t.clientY?"down":"up",w=c<n+a-20?n+a-20:c>n+l+a-e+20?n+l+a-e+20:c;r.style.top=`${w}px`,r.style.left=`${f}px`;const k=Array.from(i.querySelectorAll("tr")),v=k.find(((e,t)=>{const r=e.getBoundingClientRect();let o=r.top+p-n,i=r.bottom+p-n;if("down"===y){if(o+=r.height/2,i+=r.height/2,o<=d&&i>=d)return!0;if(t===k.length-1&&d>i)return!0}else{if(o-=r.height/2,i-=r.height/2,o<=c&&i>=c)return!0;if(0===t&&c<o)return!0}return!1}));if(v){const e=s.getBoundingClientRect().height,t=o.getBoundingClientRect(),n=k.indexOf(v);h.endIndex=n,mC(v,s,{placement:"up"===y?"top":"bottom",middleware:[hC("up"===y?-1*e:0)]}).then((({y:e})=>{s.dataset.show="true",Object.assign(s.style,{width:`${t.width}px`,top:`${e}px`})}))}}}),20)}(e);return a.addEventListener("dragover",u),a.addEventListener("dragend",l),a.addEventListener("drop",c),()=>{a.removeEventListener("dragover",u),a.removeEventListener("dragend",l),a.removeEventListener("drop",c)}}),[]),{dragRow:c,dragCol:u}}(g,t,n),{onAddRow:b,onAddCol:x,selectCol:C,selectRow:S,deleteSelected:M,onAlign:N}=function(e,t,n){const{xLineHandleRef:r,contentWrapperRef:o,colHandleRef:i,rowHandleRef:s,hoverIndex:l,lineHoverIndex:a}=e,c=Fv((()=>{var e,i,s;if(!t)return;const l=r.current;if(!l)return;const[c]=a.current;if(c<0)return;if(!t.get(lh).editable)return;const u=Array.from(null!=(i=null==(e=o.current)?void 0:e.querySelectorAll("tr"))?i:[]),d=t.get(Rh),h=(null!=(s=null==n?void 0:n())?s:0)+1;u.length===c?(d.call(wk.key,{pos:h,index:c-1}),d.call(Mk.key)):(d.call(wk.key,{pos:h,index:c}),d.call(Sk.key)),d.call(wk.key,{pos:h,index:c}),l.dataset.show="false"}),[]),u=Fv((()=>{var e,i,s,l;if(!t)return;if(!r.current)return;const[c,u]=a.current;if(u<0)return;if(!t.get(lh).editable)return;const d=Array.from(null!=(s=null==(i=null==(e=o.current)?void 0:e.querySelector("tr"))?void 0:i.children)?s:[]),h=t.get(Rh),p=(null!=(l=null==n?void 0:n())?l:0)+1;d.length===u?(h.call(kk.key,{pos:p,index:u-1}),h.call(Ck.key)):(h.call(kk.key,{pos:p,index:u}),h.call(xk.key)),h.call(kk.key,{pos:p,index:u})}),[]),d=Fv((()=>{var e,r;if(!t)return;const[o,s]=l.current,a=t.get(Rh),c=(null!=(e=null==n?void 0:n())?e:0)+1;a.call(kk.key,{pos:c,index:s});const u=null==(r=i.current)?void 0:r.querySelector(".button-group");u&&(u.dataset.show="true"===u.dataset.show?"false":"true")}),[]),h=Fv((()=>{var e,r;if(!t)return;const[o,i]=l.current,a=t.get(Rh),c=(null!=(e=null==n?void 0:n())?e:0)+1;a.call(wk.key,{pos:c,index:o});const u=null==(r=s.current)?void 0:r.querySelector(".button-group");u&&o>0&&(u.dataset.show="true"===u.dataset.show?"false":"true")}),[]),p=Fv((e=>{t&&t.get(lh).editable&&(e.preventDefault(),e.stopPropagation(),t.get(Rh).call(bk.key),requestAnimationFrame((()=>{t.get(lh).focus()})))}),[]),f=Fv((e=>n=>{t&&t.get(lh).editable&&(n.preventDefault(),n.stopPropagation(),t.get(Rh).call(Nk.key,e),requestAnimationFrame((()=>{t.get(lh).focus()})))}),[]);return{onAddRow:c,onAddCol:u,selectCol:d,selectRow:h,deleteSelected:p,onAlign:f}}(g,t,n);return Tb`
161
161
  <host
162
162
  class=${Ab(!(null==e?void 0:e.editable)&&"readonly")}
163
163
  ondragstart=${e=>e.preventDefault()}
@@ -263,4 +263,4 @@ var e={411:e=>{var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString
263
263
  <table ref=${s} class="children"></table>
264
264
  </div>
265
265
  </host>
266
- `};RM.props={getPos:Function,view:Object,ctx:Object,node:Object,config:Object};const DM=Ev(RM);var PM,$M,LM=e=>{throw TypeError(e)};class BM{constructor(e,t,n,r){var o,i;this.ctx=e,this.node=t,this.view=n,this.getPos=r,o=this,(i=PM).has(o)?LM("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(o):i.set(o,undefined);const s=document.createElement("milkdown-table-block");this.dom=s,s.view=n,s.ctx=e,s.getPos=r,s.node=t,s.config=e.get(SM.key);const l=document.createElement("tbody");this.contentDOM=l,l.setAttribute("data-content-dom","true"),l.classList.add("content-dom"),s.appendChild(l)}update(e){return!(e.type!==this.node.type||e.sameMarkup(this.node)&&e.content.eq(this.node.content)||(this.node=e,this.dom.node=e,0))}stopEvent(e){if("drop"===e.type||e.type.startsWith("drag"))return!0;if("mousedown"===e.type){if(e.target instanceof HTMLButtonElement)return!0;const o=e.target;if(o instanceof HTMLElement&&(o.closest("th")||o.closest("td"))){const o=e;return(t=this,n=PM,r=$M,((e,t,n)=>{t.has(e)||LM("Cannot access private method")})(t,n),r).call(this,o)}}var t,n,r;return!1}ignoreMutation(e){return!this.dom||!this.contentDOM||"selection"!==e.type&&(this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target))}}PM=new WeakSet,$M=function(e){const t=this.view;if(!t.editable)return!1;const{state:n,dispatch:r}=t,o=t.posAtCoords({left:e.clientX,top:e.clientY});if(!o)return!1;const i=n.doc.resolve(o.inside),s=na((e=>"table_cell"===e.type.name||"table_header"===e.type.name))(i);if(!s)return!1;const{from:l}=s,a=Ks.create(n.doc,l+1);return!n.selection.eq(a)&&(n.selection instanceof kg?setTimeout((()=>{r(n.tr.setSelection(a).scrollIntoView())}),20):requestAnimationFrame((()=>{r(n.tr.setSelection(a).scrollIntoView())})),!0)},function(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}("milkdown-table-block",DM);const zM=Wp(Vw.node,(e=>(t,n,r)=>new BM(e,t,n,r)));wM(zM,{displayName:"NodeView<table-block>",group:"TableBlock"});const FM=[SM,zM];var jM=e=>{throw TypeError(e)},_M=(e,t,n)=>t.has(e)||jM("Cannot "+n),WM=(e,t,n)=>(_M(e,t,"read from private field"),n?n.call(e):t.get(e)),VM=(e,t,n)=>t.has(e)?jM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),HM=(e,t,n,r)=>(_M(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function qM(e,t){return Object.assign(e,{meta:{package:"@milkdown/plugin-block",...t}}),e}const KM=e=>!na((e=>"table"===e.type.name))(e),UM=kC({filterNodes:KM},"blockConfig");qM(UM,{displayName:"Ctx<blockConfig>"});let JM=null;const YM={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};const GM=Rl.ie&&Rl.ie_version<15||Rl.ios&&Rl.webkit_version<604;var XM,ZM,QM,eN,tN,nN,rN,oN,iN,sN,lN,aN,cN,uN,dN,hN,pN;class fN{constructor(){VM(this,rN),VM(this,XM),VM(this,ZM),VM(this,QM),VM(this,eN),VM(this,tN),VM(this,nN),VM(this,sN),VM(this,lN),VM(this,aN),VM(this,cN),VM(this,uN),VM(this,dN),VM(this,hN),VM(this,pN),HM(this,ZM,(()=>{if(!WM(this,eN))return null;const e=WM(this,eN),t=WM(this,rN,iN);if(t&&Ks.isSelectable(e.node)){const n=Ks.create(t.state.doc,e.$pos.pos);return t.dispatch(t.state.tr.setSelection(n)),t.focus(),HM(this,QM,n),n}return null})),HM(this,QM,null),HM(this,eN,null),HM(this,tN,void 0),HM(this,nN,!1),HM(this,lN,(()=>{var e;null==(e=WM(this,sN))||e.call(this,{type:"hide"}),HM(this,eN,null)})),HM(this,aN,(e=>{var t;HM(this,eN,e),null==(t=WM(this,sN))||t.call(this,{type:"show",active:e})})),this.bind=(e,t)=>{HM(this,XM,e),HM(this,sN,t)},this.addEvent=e=>{e.addEventListener("mousedown",WM(this,cN)),e.addEventListener("mouseup",WM(this,uN)),e.addEventListener("dragstart",WM(this,dN))},this.removeEvent=e=>{e.removeEventListener("mousedown",WM(this,cN)),e.removeEventListener("mouseup",WM(this,uN)),e.removeEventListener("dragstart",WM(this,dN))},this.unBind=()=>{HM(this,sN,void 0)},HM(this,cN,(()=>{var e;HM(this,tN,null==(e=WM(this,eN))?void 0:e.el.getBoundingClientRect()),WM(this,ZM).call(this)})),HM(this,uN,(()=>{WM(this,nN)?(HM(this,nN,!1),HM(this,QM,null)):requestAnimationFrame((()=>{var e;WM(this,tN)&&(null==(e=WM(this,rN,iN))||e.focus())}))})),HM(this,dN,(e=>{var t;HM(this,nN,!0);const n=WM(this,rN,iN);if(!n)return;n.dom.dataset.dragging="true";const r=WM(this,QM);if(e.dataTransfer&&r){const o=r.content();e.dataTransfer.effectAllowed="copyMove";const{dom:i,text:s}=function(e,t){const n=[];let{openStart:r,openEnd:o,content:i}=t;for(;r>1&&o>1&&1===i.childCount&&1===i.firstChild.childCount;){r-=1,o-=1;const e=i.firstChild;n.push(e.type.name,e.attrs!==e.type.defaultAttrs?e.attrs:null),i=e.content}const s=e.someProp("clipboardSerializer")||Rt.fromSchema(e.state.schema),l=JM||(JM=document.implementation.createHTMLDocument("title")),a=l.createElement("div");a.appendChild(s.serializeFragment(i,{document:l}));let c,u=a.firstChild,d=0;for(;u&&1===u.nodeType&&(c=YM[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){const t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),d++}u=a.firstChild}return u&&1===u.nodeType&&u.setAttribute("data-pm-slice",`${r} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n")}}(n,o);e.dataTransfer.clearData(),e.dataTransfer.setData(GM?"Text":"text/html",i.innerHTML),GM||e.dataTransfer.setData("text/plain",s);const l=null==(t=WM(this,eN))?void 0:t.el;l&&e.dataTransfer.setDragImage(l,0,0),n.dragging={slice:o,move:!0}}})),this.keydownCallback=e=>(WM(this,lN).call(this),HM(this,nN,!1),e.dom.dataset.dragging="false",!1),HM(this,hN,dM(((e,t)=>{if(!e.editable)return;const n=e.dom.getBoundingClientRect(),r=n.left+n.width/2;if(!(e.root.elementFromPoint(r,t.clientY)instanceof Element))return void WM(this,lN).call(this);const o=WM(this,rN,oN);if(!o)return;const i=function(e,t,n){var r;if(!e.dom.parentElement)return null;try{const o=null==(r=e.posAtCoords({left:t.x,top:t.y}))?void 0:r.inside;if(null==o||o<0)return null;let i=e.state.doc.resolve(o),s=e.state.doc.nodeAt(o),l=e.nodeDOM(o);const a=t=>{const r=i.depth>=1&&0===i.index(i.depth);if(!t&&!r)return;const o=i.before(i.depth);s=e.state.doc.nodeAt(o),l=e.nodeDOM(o),i=e.state.doc.resolve(o),n(i,s)||a(!0)},c=n(i,s);return a(!c),l&&s?{node:s,$pos:i,el:l}:null}catch{return null}}(e,{x:r,y:t.clientY},o);i?WM(this,aN).call(this,i):WM(this,lN).call(this)}),200)),this.mousemoveCallback=(e,t)=>(e.composing||!e.editable||WM(this,hN).call(this,e,t),!1),this.dragoverCallback=(e,t)=>{var n;if(WM(this,nN)){const r=null==(n=WM(this,rN,iN))?void 0:n.dom.parentElement;if(!r)return!1;const o=r.scrollHeight>r.clientHeight,i=r.getBoundingClientRect();if(o){if(r.scrollTop>0&&Math.abs(t.y-i.y)<20){const e=r.scrollTop>10?r.scrollTop-10:0;return r.scrollTop=e,!1}const n=Math.round(e.dom.getBoundingClientRect().height);if(Math.round(r.scrollTop+i.height)<n&&Math.abs(t.y-(i.height+i.y))<20){const e=r.scrollTop+10;return r.scrollTop=e,!1}}}return!1},this.dragenterCallback=e=>{e.dragging&&(HM(this,nN,!0),e.dom.dataset.dragging="true")},this.dragleaveCallback=(e,t)=>{const n=t.clientX,r=t.clientY;(n<0||r<0||n>window.innerWidth||r>window.innerHeight)&&(HM(this,eN,null),WM(this,pN).call(this,e))},this.dropCallback=e=>(WM(this,pN).call(this,e),!1),this.dragendCallback=e=>{WM(this,pN).call(this,e)},HM(this,pN,(e=>{HM(this,nN,!1),e.dom.dataset.dragging="false"}))}}XM=new WeakMap,ZM=new WeakMap,QM=new WeakMap,eN=new WeakMap,tN=new WeakMap,nN=new WeakMap,rN=new WeakSet,oN=function(){var e;return null==(e=WM(this,XM))?void 0:e.get(UM.key).filterNodes},iN=function(){var e;return null==(e=WM(this,XM))?void 0:e.get(lh)},sN=new WeakMap,lN=new WeakMap,aN=new WeakMap,cN=new WeakMap,uN=new WeakMap,dN=new WeakMap,hN=new WeakMap,pN=new WeakMap;const mN=kC(new fN,"blockService");qM(UM,{displayName:"Ctx<blockService>"});const gN=kC({},"blockSpec");qM(UM,{displayName:"Ctx<blockSpec>"});const yN=yC((e=>{const t=new al("MILKDOWN_BLOCK"),n=e.get(mN.key),r=e.get(gN.key);return new il({key:t,...r,props:{...r.props,handleDOMEvents:{drop:e=>n.dropCallback(e),pointermove:(e,t)=>n.mousemoveCallback(e,t),keydown:e=>n.keydownCallback(e),dragover:(e,t)=>n.dragoverCallback(e,t),dragleave:(e,t)=>n.dragleaveCallback(e,t),dragenter:e=>n.dragenterCallback(e),dragend:e=>n.dragendCallback(e)}}})}));var wN,kN,vN,bN,xN,CN,SN,MN,NN,TN,ON,AN;qM(yN,{displayName:"Prose<block>"});class EN{constructor(e){VM(this,ON),VM(this,wN),VM(this,kN),VM(this,vN),VM(this,bN),VM(this,xN),VM(this,CN),VM(this,SN),VM(this,MN),VM(this,NN),VM(this,TN),HM(this,bN,null),HM(this,xN,!1),this.update=()=>{requestAnimationFrame((()=>{if(!WM(this,xN))try{((e,t,n)=>(_M(this,t,"access private method"),n))(0,ON,AN).call(this),HM(this,xN,!0)}catch{}}))},this.destroy=()=>{var e,t;null==(e=WM(this,vN))||e.unBind(),null==(t=WM(this,vN))||t.removeEvent(WM(this,wN)),WM(this,wN).remove()},this.show=e=>{const t=e.el,n=WM(this,kN).get(lh).dom,r={ctx:WM(this,kN),active:e,editorDom:n,blockDom:WM(this,wN)},o={contextElement:t,getBoundingClientRect:()=>WM(this,NN)?WM(this,NN).call(this,r):t.getBoundingClientRect()},i=[fC()];if(WM(this,MN)){const e=WM(this,MN).call(this,r),t=hC(e);i.push(t)}mC(o,WM(this,wN),{placement:WM(this,TN)?WM(this,TN).call(this,r):"left",middleware:[...i,...WM(this,CN)],...WM(this,SN)}).then((({x:e,y:t})=>{Object.assign(WM(this,wN).style,{left:`${e}px`,top:`${t}px`}),WM(this,wN).dataset.show="true"}))},this.hide=()=>{WM(this,wN).dataset.show="false"},HM(this,kN,e.ctx),HM(this,wN,e.content),HM(this,MN,e.getOffset),HM(this,NN,e.getPosition),HM(this,TN,e.getPlacement),HM(this,CN,e.middleware??[]),HM(this,SN,e.floatingUIOptions??{}),this.hide()}get active(){return WM(this,bN)}}wN=new WeakMap,kN=new WeakMap,vN=new WeakMap,bN=new WeakMap,xN=new WeakMap,CN=new WeakMap,SN=new WeakMap,MN=new WeakMap,NN=new WeakMap,TN=new WeakMap,ON=new WeakSet,AN=function(){var e;null==(e=WM(this,kN).get(lh).dom.parentElement)||e.appendChild(WM(this,wN));const t=WM(this,kN).get(mN.key);t.bind(WM(this,kN),(e=>{"hide"===e.type?(this.hide(),HM(this,bN,null)):"show"===e.type&&(this.show(e.active),HM(this,bN,e.active))})),HM(this,vN,t),WM(this,vN).addEvent(WM(this,wN)),WM(this,wN).draggable=!0};const IN=[gN,UM,mN,yN];IN.key=gN.key,IN.pluginKey=yN.key;class RN{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let o=t.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:o.left,right:o.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let r,o,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!i||i==document.body&&"static"==getComputedStyle(i).position)r=-pageXOffset,o=-pageYOffset;else{let e=i.getBoundingClientRect();r=e.left-i.scrollLeft,o=e.top-i.scrollTop}this.element.style.left=e.left-r+"px",this.element.style.top=e.top-o+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,o="function"==typeof r?r(this.editorView,t,e):r;if(t&&!o){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Ss(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class DN extends js{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return DN.valid(n)?new DN(n):js.near(n)}content(){return Be.empty}eq(e){return e instanceof DN&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new DN(e.resolve(t.pos))}getBookmark(){return new PN(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&DN.valid(e))return e;let r=e.pos,o=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){o=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(DN.valid(s))return s}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!Ks.isSelectable(o)){e=e.doc.resolve(r+o.nodeSize*t),n=!1;continue e}break}o=i,r+=t;let s=e.doc.resolve(r);if(DN.valid(s))return s}return null}}}DN.prototype.visible=!1,DN.findFrom=DN.findGapCursorFrom,js.jsonID("gapcursor",DN);class PN{constructor(e){this.pos=e}map(e){return new PN(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return DN.valid(t)?new DN(t):js.near(t)}}const $N=ja({ArrowLeft:LN("horiz",-1),ArrowRight:LN("horiz",1),ArrowUp:LN("vert",-1),ArrowDown:LN("vert",1)});function LN(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,o){let i=e.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof Hs){if(!o.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=e.doc.resolve(t>0?s.after():s.before())}let a=DN.findGapCursorFrom(s,t,l);return!!a&&(r&&r(e.tr.setSelection(new DN(a))),!0)}}function BN(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!DN.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return!(o&&o.inside>-1&&Ks.isSelectable(e.state.doc.nodeAt(o.inside))||(e.dispatch(e.state.tr.setSelection(new DN(r))),0))}function zN(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof DN))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=Ie.empty;for(let e=r.length-1;e>=0;e--)o=Ie.from(r[e].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new Be(o,0,0));return i.setSelection(Hs.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function FN(e){if(!(e.selection instanceof DN))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",bd.create(e.doc,[wd.widget(e.selection.head,t,{key:"gapcursor"})])}function jN(e,t){return Object.assign(e,{meta:{package:"@milkdown/plugin-cursor",...t}}),e}const _N=kC({},"dropCursorConfig");jN(_N,{displayName:"Ctx<dropCursor>"});const WN=yC((e=>function(e={}){return new il({view:t=>new RN(t,e)})}(e.get(_N.key))));jN(WN,{displayName:"Prose<dropCursor>"});const VN=yC((()=>new il({props:{decorations:FN,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&DN.valid(n)?new DN(n):null,handleClick:BN,handleKeyDown:$N,handleDOMEvents:{beforeinput:zN}}})));jN(VN,{displayName:"Prose<gapCursor>"});const HN=[_N,WN,VN];var qN=200,KN=function(){};KN.prototype.append=function(e){return e.length?(e=KN.from(e),!this.length&&e||e.length<qN&&this.leafAppend(e)||this.length<qN&&e.leafPrepend(this)||this.appendInner(e)):this},KN.prototype.prepend=function(e){return e.length?KN.from(e).append(this):this},KN.prototype.appendInner=function(e){return new JN(this,e)},KN.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?KN.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},KN.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},KN.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},KN.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},KN.from=function(e){return e instanceof KN?e:e&&e.length?new UN(e):KN.empty};var UN=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=qN)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=qN)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(KN);KN.empty=new UN([]);var JN=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(KN);const YN=KN;class GN{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new XN(e.map));let t,o=e.step.map(n.slice(r));o&&l.maybeStep(o).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new XN(t,void 0,void 0,a.length+c.length))),r--,t&&n.appendMap(t,r)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new GN(this.items.slice(0,o).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,l=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),u=new XN(e.mapping.maps[n],c,t);(a=l&&l.merge(u))&&(u=a,n?o.pop():s=s.slice(0,s.length-1)),o.push(u),t&&(i++,t=void 0),r||(l=u)}let a=i-n.depth;return a>QN&&(s=function(e,t){let n;return e.forEach(((e,r)=>{if(e.selection&&0==t--)return n=r,!1})),e.slice(n)}(s,a),i-=a),new GN(s.append(o),i)}remapping(e,t){let n=new Qi;return this.items.forEach(((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new GN(this.items.append(e.map((e=>new XN(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),r);let l=t;this.items.forEach((t=>{let r=o.getMirror(--l);if(null==r)return;i=Math.min(i,r);let a=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(l+1,r));c&&s++,n.push(new XN(a,i,c))}else n.push(new XN(a))}),r);let a=[];for(let e=t;e<i;e++)a.push(new XN(o.maps[e]));let c=this.items.slice(0,r).append(a).append(n),u=new GN(c,s);return u.emptyItemCount()>500&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach(((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&o++;let a,c=new XN(s.invert(),e,l),u=r.length-1;(a=r.length&&r[u].merge(c))?r[u]=a:r.push(c)}}else i.map&&n--}),this.items.length,0),new GN(YN.from(r.reverse()),o)}}GN.empty=new GN(YN.empty,0);class XN{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new XN(t.getMap().invert(),t,this.selection)}}}class ZN{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const QN=20;function eT(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(((e,n,r,o)=>t.push(r,o)));return t}function tT(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let nT=!1,rT=null;function oT(e){let t=e.plugins;if(rT!=t){nT=!1,rT=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){nT=!0;break}}return nT}const iT=new al("history"),sT=new al("closeHistory");function lT(e,t){return(n,r)=>{let o=iT.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=oT(t),o=iT.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),a=new ZN(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(iT,{redo:n,historyState:a})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const aT=lT(!1,!0),cT=lT(!0,!0);function uT(e,t){return Object.assign(e,{meta:{package:"@milkdown/plugin-history",...t}}),e}lT(!1,!1),lT(!0,!1);const dT=gC("Undo",(()=>()=>aT));uT(dT,{displayName:"Command<undo>"});const hT=gC("Redo",(()=>()=>cT));uT(hT,{displayName:"Command<redo>"});const pT=kC({},"historyProviderConfig");uT(pT,{displayName:"Ctx<historyProviderConfig>"});const fT=yC((e=>function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new il({key:iT,state:{init:()=>new ZN(GN.empty,GN.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(iT);if(i)return i.historyState;n.getMeta(sT)&&(e=new ZN(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(iT))return s.getMeta(iT).redo?new ZN(e.done.addTransform(n,void 0,r,oT(t)),e.undone,eT(n.mapping.maps),e.prevTime,e.prevComposition):new ZN(e.done,e.undone.addTransform(n,void 0,r,oT(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new ZN(e.done.rebased(n,o),e.undone.rebased(n,o),tT(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new ZN(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),tT(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)})),n}(n,e.prevRanges)),l=s?tT(e.prevRanges,n.mapping):eT(n.mapping.maps);return new ZN(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,oT(t)),GN.empty,l,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?aT:"historyRedo"==n?cT:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}(e.get(pT.key))));uT(fT,{displayName:"Ctx<historyProviderPlugin>"});const mT=function(e,t){const n=Object.fromEntries(Object.entries(t).map((([e,{shortcuts:t}])=>[e,t]))),r=kC(n,"historyKeymapKeymap"),o=wC((e=>{const n=e.get(r.key),o=Object.entries(t).flatMap((([t,{command:r}])=>[n[t]].flat().map((t=>[t,r(e)]))));return Object.fromEntries(o)})),i=[r,o];return i.ctx=r,i.shortcuts=o,i.key=r.key,i.keymap=o.keymap,i}(0,{Undo:{shortcuts:"Mod-z",command:e=>{const t=e.get(Dh);return()=>t.call(dT.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:e=>{const t=e.get(Dh);return()=>t.call(hT.key)}}});uT(mT.ctx,{displayName:"KeymapCtx<history>"}),uT(mT.shortcuts,{displayName:"Keymap<history>"});const gT=[pT,fT,mT,dT,hT].flat(),yT=kC({type:"space",size:2},"indentConfig");yT.meta={package:"@milkdown/plugin-indent",displayName:"Ctx<indentConfig>"};const wT=wC((e=>({Tab:(t,n)=>{const r=e.get(yT.key),{tr:o}=t,i=function(e,t){const{doc:n,selection:r}=e;if(!n||!r||!(r instanceof Hs||r instanceof Js))return e;const{to:o}=r,i="space"===t.type?Array(t.size).fill(" ").join(""):"\t";return e.insertText(i,o)}(o,r);return!!i.docChanged&&(null==n||n(i),!0)}})));wT.meta={package:"@milkdown/plugin-indent",displayName:"Shortcut<indent>"};const kT=[yT,wT];class vT{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}}const bT=te(new vT,"listener"),xT=new al("MILKDOWN_LISTENER"),CT=e=>(e.inject(bT,new vT),async()=>{await e.wait(vh);const t=e.get(bT),{listeners:n}=t;n.beforeMount.forEach((t=>t(e))),await e.wait(Wh);const r=e.get(qh);let o=null,i=null;const s=new il({key:xT,view:()=>({destroy:()=>{n.destroy.forEach((t=>t(e)))}}),props:{handleDOMEvents:{focus:()=>(n.focus.forEach((t=>t(e))),!1),blur:()=>(n.blur.forEach((t=>t(e))),!1)}},state:{init:(e,t)=>{o=t.doc,i=r(t.doc)},apply:t=>t.docChanged&&!1!==t.getMeta("addToHistory")?dx((()=>{const{doc:s}=t;if(n.updated.length>0&&o&&!o.eq(s)&&n.updated.forEach((t=>{t(e,s,o)})),n.markdownUpdated.length>0&&o&&!o.eq(s)){const t=r(s);n.markdownUpdated.forEach((n=>{n(e,t,i)})),i=t}o=s}),200)():void 0}});e.update(hh,(e=>e.concat(s))),await e.wait(tp),n.mounted.forEach((t=>t(e)))});CT.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};var ST,MT,NT,TT,OT,AT,ET,IT,RT,DT,PT=e=>{throw TypeError(e)},$T=(e,t,n)=>t.has(e)||PT("Cannot "+n),LT=(e,t,n)=>($T(e,t,"read from private field"),n?n.call(e):t.get(e)),BT=(e,t,n)=>t.has(e)?PT("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zT=(e,t,n,r)=>($T(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function FT(e){const t=kC({},`${e}_SLASH_SPEC`),n=yC((n=>{const r=n.get(t.key);return new il({key:new al(`${e}_SLASH`),...r})})),r=[t,n];return r.key=t.key,r.pluginKey=n.key,t.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${e}`},n.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${e}`},r}class jT{constructor(e){BT(this,RT),BT(this,ST),BT(this,MT),BT(this,NT),BT(this,TT),BT(this,OT),BT(this,AT),BT(this,ET),BT(this,IT),zT(this,ST,!1),this.onShow=()=>{},this.onHide=()=>{},zT(this,IT,((e,t)=>{var n;const{state:r,composing:o}=e,{selection:i,doc:s}=r,{ranges:l}=i,a=Math.min(...l.map((e=>e.$from.pos))),c=Math.max(...l.map((e=>e.$to.pos))),u=t&&t.doc.eq(s)&&t.selection.eq(i);LT(this,ST)||(null==(n=e.dom.parentElement)||n.appendChild(this.element),zT(this,ST,!0)),o||u||(LT(this,AT).call(this,e,t)?(mC({getBoundingClientRect:()=>Gl(e,a,c)},this.element,{placement:"bottom-start",middleware:[fC(),hC(LT(this,ET)),...LT(this,MT)],...LT(this,NT)}).then((({x:e,y:t})=>{Object.assign(this.element.style,{left:`${e}px`,top:`${t}px`})})),this.show()):this.hide())})),this.update=(e,t)=>{dx(LT(this,IT),LT(this,TT))(e,t)},this.getContent=(e,t=(e=>"paragraph"===e.type.name))=>{const{selection:n}=e.state,{empty:r,$from:o}=n,i=e.state.selection instanceof Hs,s=this.element.contains(document.activeElement),l=!e.hasFocus()&&!s,a=!e.editable,c=!la(t)(e.state.selection);if(!l&&!a&&r&&i&&!c)return o.parent.textBetween(Math.max(0,o.parentOffset-500),o.parentOffset,void 0,"")},this.destroy=()=>{},this.show=()=>{this.element.dataset.show="true",this.onShow()},this.hide=()=>{this.element.dataset.show="false",this.onHide()},this.element=e.content,zT(this,TT,e.debounce??200),zT(this,AT,e.shouldShow??((e,t,n)=>($T(this,t,"access private method"),n))(0,RT,DT)),zT(this,OT,e.trigger??"/"),zT(this,ET,e.offset),zT(this,MT,e.middleware??[]),zT(this,NT,e.floatingUIOptions??{})}}ST=new WeakMap,MT=new WeakMap,NT=new WeakMap,TT=new WeakMap,OT=new WeakMap,AT=new WeakMap,ET=new WeakMap,IT=new WeakMap,RT=new WeakSet,DT=function(e){const t=this.getContent(e);if(!t)return!1;const n=t.at(-1);return!!n&&(Array.isArray(LT(this,OT))?LT(this,OT).includes(n):LT(this,OT)===n)};const _T=kC({shouldAppend:e=>!(!e||["heading","paragraph"].includes(e.type.name)),getNode:e=>e.schema.nodes.paragraph.create()},"trailingConfig");_T.meta={package:"@milkdown/plugin-trailing",displayName:"Ctx<trailingConfig>"};const WT=yC((e=>{const t=new al("MILKDOWN_TRAILING"),{shouldAppend:n,getNode:r}=e.get(_T.key),o=new il({key:t,state:{init:(e,t)=>{const r=t.tr.doc.lastChild;return n(r,t)},apply:(e,t,r,o)=>{if(!e.docChanged)return t;const i=e.doc.lastChild;return n(i,o)}},appendTransaction:(e,t,n)=>{const{doc:i,tr:s}=n,l=null==r?void 0:r(n),a=o.getState(n),c=i.content.size;if(a&&l)return s.insert(c,l)}});return o}));WT.meta={package:"@milkdown/plugin-trailing",displayName:"Prose<trailing>"};const VT=[_T,WT];function HT(e){return new Promise((t=>{const n=new FileReader;n.addEventListener("load",(()=>{t({alt:e.name,src:n.result})}),!1),n.readAsDataURL(e)}))}const qT=async(e,t)=>{const n=[];for(let t=0;t<e.length;t++){const r=e.item(t);r&&r.type.includes("image")&&n.push(r)}const{image:r}=t.nodes;if(!r)throw W("image");return(await Promise.all(n.map((e=>HT(e))))).map((({alt:e,src:t})=>r.createAndFill({src:t,alt:e})))},KT=kC({uploader:qT,enableHtmlFileUploader:!1,uploadWidgetFactory:(e,t)=>{const n=document.createElement("span");return n.textContent="Upload in progress...",wd.widget(e,n,t)}},"uploadConfig");KT.meta={package:"@milkdown/plugin-upload",displayName:"Ctx<uploadConfig>"};const UT=yC((e=>{const t=new al("MILKDOWN_UPLOAD"),n=(n,r,o)=>{var i;if(!o||o.length<=0)return!1;const s=Symbol("upload symbol"),l=e.get(Sh),{tr:a}=n.state,c=r instanceof DragEvent?(null==(i=n.posAtCoords({left:r.clientX,top:r.clientY}))?void 0:i.pos)??a.selection.from:a.selection.from;n.dispatch(a.setMeta(t,{add:{id:s,pos:c}}));const{uploader:u}=e.get(KT.key);return u(o,l).then((e=>{const r=((e,n)=>{var r;const o=t.getState(e);if(!o)return-1;const i=o.find(void 0,void 0,(e=>e.id===n));return i.length?(null==(r=i[0])?void 0:r.from)??-1:-1})(n.state,s);r<0||n.dispatch(n.state.tr.replaceWith(r,r,e).setMeta(t,{remove:{id:s}}))})).catch((e=>{console.error(e)})),!0};return new il({key:t,state:{init:()=>bd.empty,apply(t,n){const r=n.map(t.mapping,t.doc),o=t.getMeta(this);if(!o)return r;if(o.add){const{uploadWidgetFactory:n}=e.get(KT.key),i=n(o.add.pos,{id:o.add.id});return r.add(t.doc,[i])}if(o.remove){const e=r.find(void 0,void 0,(e=>e.id===o.remove.id));return r.remove(e)}return r}},props:{decorations(e){return this.getState(e)},handlePaste:(t,r)=>{var o,i;const{enableHtmlFileUploader:s}=e.get(KT.key);return!(!(r instanceof ClipboardEvent)||!s&&null!=(o=r.clipboardData)&&o.getData("text/html"))&&n(t,r,null==(i=r.clipboardData)?void 0:i.files)},handleDrop:(e,t)=>{var r;return t instanceof DragEvent&&n(e,t,null==(r=t.dataTransfer)?void 0:r.files)}}})}));UT.meta={package:"@milkdown/plugin-upload",displayName:"Prose<upload>"};const JT=[KT,UT],YT={commonmark:h,gfm:p},GT={imageBlock:m,imageInline:g,linkTooltip:w,listItemBlock:k,tableBlock:v},XT={block:b,cursor:x,history:C,indent:S,listener:M,slash:N,tooltip:y,trailing:T,upload:O},ZT={...i,state:l,transform:c,view:u,model:a}})(),window.Milkdown=r;
266
+ `};DM.props={getPos:Function,view:Object,ctx:Object,node:Object,config:Object};const RM=Ev(DM);var PM,$M,LM=e=>{throw TypeError(e)};class zM{constructor(e,t,n,r){var o,i;this.ctx=e,this.node=t,this.view=n,this.getPos=r,o=this,(i=PM).has(o)?LM("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(o):i.set(o,undefined);const s=document.createElement("milkdown-table-block");this.dom=s,s.view=n,s.ctx=e,s.getPos=r,s.node=t,s.config=e.get(SM.key);const l=document.createElement("tbody");this.contentDOM=l,l.setAttribute("data-content-dom","true"),l.classList.add("content-dom"),s.appendChild(l)}update(e){return!(e.type!==this.node.type||e.sameMarkup(this.node)&&e.content.eq(this.node.content)||(this.node=e,this.dom.node=e,0))}stopEvent(e){if("drop"===e.type||e.type.startsWith("drag"))return!0;if("mousedown"===e.type){if(e.target instanceof HTMLButtonElement)return!0;const o=e.target;if(o instanceof HTMLElement&&(o.closest("th")||o.closest("td"))){const o=e;return(t=this,n=PM,r=$M,((e,t,n)=>{t.has(e)||LM("Cannot access private method")})(t,n),r).call(this,o)}}var t,n,r;return!1}ignoreMutation(e){return!this.dom||!this.contentDOM||"selection"!==e.type&&(this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target))}}PM=new WeakSet,$M=function(e){const t=this.view;if(!t.editable)return!1;const{state:n,dispatch:r}=t,o=t.posAtCoords({left:e.clientX,top:e.clientY});if(!o)return!1;const i=n.doc.resolve(o.inside),s=ra((e=>"table_cell"===e.type.name||"table_header"===e.type.name))(i);if(!s)return!1;const{from:l}=s,a=Us.create(n.doc,l+1);return!n.selection.eq(a)&&(n.selection instanceof kg?setTimeout((()=>{r(n.tr.setSelection(a).scrollIntoView())}),20):requestAnimationFrame((()=>{r(n.tr.setSelection(a).scrollIntoView())})),!0)},function(e,t){const n=customElements.get(e);null!=n?n!==t&&console.warn(`Custom element ${e} has been defined before.`):customElements.define(e,t)}("milkdown-table-block",RM);const BM=Wp(Vw.node,(e=>(t,n,r)=>new zM(e,t,n,r)));wM(BM,{displayName:"NodeView<table-block>",group:"TableBlock"});const FM=[SM,BM];var jM=e=>{throw TypeError(e)},_M=(e,t,n)=>t.has(e)||jM("Cannot "+n),WM=(e,t,n)=>(_M(e,t,"read from private field"),n?n.call(e):t.get(e)),VM=(e,t,n)=>t.has(e)?jM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),HM=(e,t,n,r)=>(_M(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function qM(e,t){return Object.assign(e,{meta:{package:"@milkdown/plugin-block",...t}}),e}const KM=e=>!ra((e=>"table"===e.type.name))(e),UM=kC({filterNodes:KM},"blockConfig");qM(UM,{displayName:"Ctx<blockConfig>"});let JM=null;const YM={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};const GM=Rl.ie&&Rl.ie_version<15||Rl.ios&&Rl.webkit_version<604;var XM,ZM,QM,eN,tN,nN,rN,oN,iN,sN,lN,aN,cN,uN,dN,hN,pN;class fN{constructor(){VM(this,rN),VM(this,XM),VM(this,ZM),VM(this,QM),VM(this,eN),VM(this,tN),VM(this,nN),VM(this,sN),VM(this,lN),VM(this,aN),VM(this,cN),VM(this,uN),VM(this,dN),VM(this,hN),VM(this,pN),HM(this,ZM,(()=>{if(!WM(this,eN))return null;const e=WM(this,eN),t=WM(this,rN,iN);if(t&&Us.isSelectable(e.node)){const n=Us.create(t.state.doc,e.$pos.pos);return t.dispatch(t.state.tr.setSelection(n)),t.focus(),HM(this,QM,n),n}return null})),HM(this,QM,null),HM(this,eN,null),HM(this,tN,void 0),HM(this,nN,!1),HM(this,lN,(()=>{var e;null==(e=WM(this,sN))||e.call(this,{type:"hide"}),HM(this,eN,null)})),HM(this,aN,(e=>{var t;HM(this,eN,e),null==(t=WM(this,sN))||t.call(this,{type:"show",active:e})})),this.bind=(e,t)=>{HM(this,XM,e),HM(this,sN,t)},this.addEvent=e=>{e.addEventListener("mousedown",WM(this,cN)),e.addEventListener("mouseup",WM(this,uN)),e.addEventListener("dragstart",WM(this,dN))},this.removeEvent=e=>{e.removeEventListener("mousedown",WM(this,cN)),e.removeEventListener("mouseup",WM(this,uN)),e.removeEventListener("dragstart",WM(this,dN))},this.unBind=()=>{HM(this,sN,void 0)},HM(this,cN,(()=>{var e;HM(this,tN,null==(e=WM(this,eN))?void 0:e.el.getBoundingClientRect()),WM(this,ZM).call(this)})),HM(this,uN,(()=>{WM(this,nN)?(HM(this,nN,!1),HM(this,QM,null)):requestAnimationFrame((()=>{var e;WM(this,tN)&&(null==(e=WM(this,rN,iN))||e.focus())}))})),HM(this,dN,(e=>{var t;HM(this,nN,!0);const n=WM(this,rN,iN);if(!n)return;n.dom.dataset.dragging="true";const r=WM(this,QM);if(e.dataTransfer&&r){const o=r.content();e.dataTransfer.effectAllowed="copyMove";const{dom:i,text:s}=function(e,t){const n=[];let{openStart:r,openEnd:o,content:i}=t;for(;r>1&&o>1&&1===i.childCount&&1===i.firstChild.childCount;){r-=1,o-=1;const e=i.firstChild;n.push(e.type.name,e.attrs!==e.type.defaultAttrs?e.attrs:null),i=e.content}const s=e.someProp("clipboardSerializer")||Rt.fromSchema(e.state.schema),l=JM||(JM=document.implementation.createHTMLDocument("title")),a=l.createElement("div");a.appendChild(s.serializeFragment(i,{document:l}));let c,u=a.firstChild,d=0;for(;u&&1===u.nodeType&&(c=YM[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){const t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),d++}u=a.firstChild}return u&&1===u.nodeType&&u.setAttribute("data-pm-slice",`${r} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n")}}(n,o);e.dataTransfer.clearData(),e.dataTransfer.setData(GM?"Text":"text/html",i.innerHTML),GM||e.dataTransfer.setData("text/plain",s);const l=null==(t=WM(this,eN))?void 0:t.el;l&&e.dataTransfer.setDragImage(l,0,0),n.dragging={slice:o,move:!0}}})),this.keydownCallback=e=>(WM(this,lN).call(this),HM(this,nN,!1),e.dom.dataset.dragging="false",!1),HM(this,hN,dx(((e,t)=>{if(!e.editable)return;const n=e.dom.getBoundingClientRect(),r=n.left+n.width/2;if(!(e.root.elementFromPoint(r,t.clientY)instanceof Element))return void WM(this,lN).call(this);const o=WM(this,rN,oN);if(!o)return;const i=function(e,t,n){var r;if(!e.dom.parentElement)return null;try{const o=null==(r=e.posAtCoords({left:t.x,top:t.y}))?void 0:r.inside;if(null==o||o<0)return null;let i=e.state.doc.resolve(o),s=e.state.doc.nodeAt(o),l=e.nodeDOM(o);const a=t=>{const r=i.depth>=1&&0===i.index(i.depth);if(!t&&!r)return;const o=i.before(i.depth);s=e.state.doc.nodeAt(o),l=e.nodeDOM(o),i=e.state.doc.resolve(o),n(i,s)||a(!0)},c=n(i,s);return a(!c),l&&s?{node:s,$pos:i,el:l}:null}catch{return null}}(e,{x:r,y:t.clientY},o);i?WM(this,aN).call(this,i):WM(this,lN).call(this)}),200)),this.mousemoveCallback=(e,t)=>(e.composing||!e.editable||WM(this,hN).call(this,e,t),!1),this.dragoverCallback=(e,t)=>{var n;if(WM(this,nN)){const r=null==(n=WM(this,rN,iN))?void 0:n.dom.parentElement;if(!r)return!1;const o=r.scrollHeight>r.clientHeight,i=r.getBoundingClientRect();if(o){if(r.scrollTop>0&&Math.abs(t.y-i.y)<20){const e=r.scrollTop>10?r.scrollTop-10:0;return r.scrollTop=e,!1}const n=Math.round(e.dom.getBoundingClientRect().height);if(Math.round(r.scrollTop+i.height)<n&&Math.abs(t.y-(i.height+i.y))<20){const e=r.scrollTop+10;return r.scrollTop=e,!1}}}return!1},this.dragenterCallback=e=>{e.dragging&&(HM(this,nN,!0),e.dom.dataset.dragging="true")},this.dragleaveCallback=(e,t)=>{const n=t.clientX,r=t.clientY;(n<0||r<0||n>window.innerWidth||r>window.innerHeight)&&(HM(this,eN,null),WM(this,pN).call(this,e))},this.dropCallback=e=>(WM(this,pN).call(this,e),!1),this.dragendCallback=e=>{WM(this,pN).call(this,e)},HM(this,pN,(e=>{HM(this,nN,!1),e.dom.dataset.dragging="false"}))}}XM=new WeakMap,ZM=new WeakMap,QM=new WeakMap,eN=new WeakMap,tN=new WeakMap,nN=new WeakMap,rN=new WeakSet,oN=function(){var e;return null==(e=WM(this,XM))?void 0:e.get(UM.key).filterNodes},iN=function(){var e;return null==(e=WM(this,XM))?void 0:e.get(lh)},sN=new WeakMap,lN=new WeakMap,aN=new WeakMap,cN=new WeakMap,uN=new WeakMap,dN=new WeakMap,hN=new WeakMap,pN=new WeakMap;const mN=kC(new fN,"blockService");qM(UM,{displayName:"Ctx<blockService>"});const gN=kC({},"blockSpec");qM(UM,{displayName:"Ctx<blockSpec>"});const yN=yC((e=>{const t=new cl("MILKDOWN_BLOCK"),n=e.get(mN.key),r=e.get(gN.key);return new sl({key:t,...r,props:{...r.props,handleDOMEvents:{drop:e=>n.dropCallback(e),pointermove:(e,t)=>n.mousemoveCallback(e,t),keydown:e=>n.keydownCallback(e),dragover:(e,t)=>n.dragoverCallback(e,t),dragleave:(e,t)=>n.dragleaveCallback(e,t),dragenter:e=>n.dragenterCallback(e),dragend:e=>n.dragendCallback(e)}}})}));var wN,kN,vN,bN,xN,CN,SN,MN,NN,TN,ON,AN;qM(yN,{displayName:"Prose<block>"});class EN{constructor(e){VM(this,ON),VM(this,wN),VM(this,kN),VM(this,vN),VM(this,bN),VM(this,xN),VM(this,CN),VM(this,SN),VM(this,MN),VM(this,NN),VM(this,TN),HM(this,bN,null),HM(this,xN,!1),this.update=()=>{requestAnimationFrame((()=>{if(!WM(this,xN))try{((e,t,n)=>(_M(this,t,"access private method"),n))(0,ON,AN).call(this),HM(this,xN,!0)}catch{}}))},this.destroy=()=>{var e,t;null==(e=WM(this,vN))||e.unBind(),null==(t=WM(this,vN))||t.removeEvent(WM(this,wN)),WM(this,wN).remove()},this.show=e=>{const t=e.el,n=WM(this,kN).get(lh).dom,r={ctx:WM(this,kN),active:e,editorDom:n,blockDom:WM(this,wN)},o={contextElement:t,getBoundingClientRect:()=>WM(this,NN)?WM(this,NN).call(this,r):t.getBoundingClientRect()},i=[fC()];if(WM(this,MN)){const e=WM(this,MN).call(this,r),t=hC(e);i.push(t)}mC(o,WM(this,wN),{placement:WM(this,TN)?WM(this,TN).call(this,r):"left",middleware:[...i,...WM(this,CN)],...WM(this,SN)}).then((({x:e,y:t})=>{Object.assign(WM(this,wN).style,{left:`${e}px`,top:`${t}px`}),WM(this,wN).dataset.show="true"}))},this.hide=()=>{WM(this,wN).dataset.show="false"},HM(this,kN,e.ctx),HM(this,wN,e.content),HM(this,MN,e.getOffset),HM(this,NN,e.getPosition),HM(this,TN,e.getPlacement),HM(this,CN,e.middleware??[]),HM(this,SN,e.floatingUIOptions??{}),this.hide()}get active(){return WM(this,bN)}}wN=new WeakMap,kN=new WeakMap,vN=new WeakMap,bN=new WeakMap,xN=new WeakMap,CN=new WeakMap,SN=new WeakMap,MN=new WeakMap,NN=new WeakMap,TN=new WeakMap,ON=new WeakSet,AN=function(){var e;null==(e=WM(this,kN).get(lh).dom.parentElement)||e.appendChild(WM(this,wN));const t=WM(this,kN).get(mN.key);t.bind(WM(this,kN),(e=>{"hide"===e.type?(this.hide(),HM(this,bN,null)):"show"===e.type&&(this.show(e.active),HM(this,bN,e.active))})),HM(this,vN,t),WM(this,vN).addEvent(WM(this,wN)),WM(this,wN).draggable=!0};const IN=[gN,UM,mN,yN];function DN(e){if(!e)return!1;if(Array.isArray(e))return!(e.length>1)&&DN(e[0]);const t=e.content;return t?DN(t):"text"===e.type}IN.key=gN.key,IN.pluginKey=yN.key;const RN=yC((e=>{const t=e.get(Sh);e.update(rp,(e=>({...e,editable:e.editable??(()=>!0)})));const n=new cl("MILKDOWN_CLIPBOARD");return new sl({key:n,props:{handlePaste:(n,r)=>{var o,i;const s=e.get(Fh),l=null==(i=(o=n.props).editable)?void 0:i.call(o,n.state),{clipboardData:a}=r;if(!l||!a||n.state.selection.$from.node().type.spec.code)return!1;const c=a.getData("text/plain"),u=a.getData("vscode-editor-data");if(u){const e=JSON.parse(u),r=null==e?void 0:e.mode;if(c&&r){const{tr:e}=n.state,o=ia("code_block",t);return e.replaceSelectionWith(o.create({language:r})).setSelection(qs.near(e.doc.resolve(Math.max(0,e.selection.from-2)))).insertText(c.replace(/\r\n?/g,"\n")),n.dispatch(e),!0}}const d=a.getData("text/html");if(0===d.length&&0===c.length)return!1;const h=Ct.fromSchema(t);let p;if(0===d.length){const e=s(c);if(!e||"string"==typeof e)return!1;p=Rt.fromSchema(t).serializeFragment(e.content)}else{const e=document.createElement("template");e.innerHTML=d,p=e.content.cloneNode(!0),e.remove()}const f=h.parseSlice(p),m=function(e){if(1===e.content.childCount){const t=e.content.firstChild;if("text"===(null==t?void 0:t.type.name)&&0===t.marks.length)return t;if("paragraph"===(null==t?void 0:t.type.name)&&1===t.childCount){const e=t.firstChild;if("text"===(null==e?void 0:e.type.name)&&0===e.marks.length)return e}}return!1}(f);return m?(n.dispatch(n.state.tr.replaceSelectionWith(m,!0)),!0):(n.dispatch(n.state.tr.replaceSelection(f)),!0)},clipboardTextSerializer:n=>{const r=e.get(qh);if(DN(n.content.toJSON()))return n.content.textBetween(0,n.content.size,"\n\n");const o=t.topNodeType.createAndFill(void 0,n.content);return o?r(o):""}}})}));RN.meta={displayName:"Prose<clipboard>",package:"@milkdown/plugin-clipboard"};class PN{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let o=t.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:o.left,right:o.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let r,o,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!i||i==document.body&&"static"==getComputedStyle(i).position)r=-pageXOffset,o=-pageYOffset;else{let e=i.getBoundingClientRect();r=e.left-i.scrollLeft,o=e.top-i.scrollTop}this.element.style.left=e.left-r+"px",this.element.style.top=e.top-o+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,o="function"==typeof r?r(this.editorView,t,e):r;if(t&&!o){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Ms(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class $N extends _s{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return $N.valid(n)?new $N(n):_s.near(n)}content(){return Be.empty}eq(e){return e instanceof $N&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new $N(e.resolve(t.pos))}getBookmark(){return new LN(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&$N.valid(e))return e;let r=e.pos,o=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){o=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if($N.valid(s))return s}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!Us.isSelectable(o)){e=e.doc.resolve(r+o.nodeSize*t),n=!1;continue e}break}o=i,r+=t;let s=e.doc.resolve(r);if($N.valid(s))return s}return null}}}$N.prototype.visible=!1,$N.findFrom=$N.findGapCursorFrom,_s.jsonID("gapcursor",$N);class LN{constructor(e){this.pos=e}map(e){return new LN(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $N.valid(t)?new $N(t):_s.near(t)}}const zN=_a({ArrowLeft:BN("horiz",-1),ArrowRight:BN("horiz",1),ArrowUp:BN("vert",-1),ArrowDown:BN("vert",1)});function BN(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,o){let i=e.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof qs){if(!o.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=e.doc.resolve(t>0?s.after():s.before())}let a=$N.findGapCursorFrom(s,t,l);return!!a&&(r&&r(e.tr.setSelection(new $N(a))),!0)}}function FN(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!$N.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return!(o&&o.inside>-1&&Us.isSelectable(e.state.doc.nodeAt(o.inside))||(e.dispatch(e.state.tr.setSelection(new $N(r))),0))}function jN(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof $N))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=De.empty;for(let e=r.length-1;e>=0;e--)o=De.from(r[e].createAndFill(null,o));let i=e.state.tr.replace(n.pos,n.pos,new Be(o,0,0));return i.setSelection(qs.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function _N(e){if(!(e.selection instanceof $N))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",xd.create(e.doc,[kd.widget(e.selection.head,t,{key:"gapcursor"})])}function WN(e,t){return Object.assign(e,{meta:{package:"@milkdown/plugin-cursor",...t}}),e}const VN=kC({},"dropCursorConfig");WN(VN,{displayName:"Ctx<dropCursor>"});const HN=yC((e=>function(e={}){return new sl({view:t=>new PN(t,e)})}(e.get(VN.key))));WN(HN,{displayName:"Prose<dropCursor>"});const qN=yC((()=>new sl({props:{decorations:_N,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&$N.valid(n)?new $N(n):null,handleClick:FN,handleKeyDown:zN,handleDOMEvents:{beforeinput:jN}}})));WN(qN,{displayName:"Prose<gapCursor>"});const KN=[VN,HN,qN];var UN=200,JN=function(){};JN.prototype.append=function(e){return e.length?(e=JN.from(e),!this.length&&e||e.length<UN&&this.leafAppend(e)||this.length<UN&&e.leafPrepend(this)||this.appendInner(e)):this},JN.prototype.prepend=function(e){return e.length?JN.from(e).append(this):this},JN.prototype.appendInner=function(e){return new GN(this,e)},JN.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?JN.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},JN.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},JN.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},JN.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},JN.from=function(e){return e instanceof JN?e:e&&e.length?new YN(e):JN.empty};var YN=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=UN)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=UN)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(JN);JN.empty=new YN([]);var GN=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(JN);const XN=JN;class ZN{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new QN(e.map));let t,o=e.step.map(n.slice(r));o&&l.maybeStep(o).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new QN(t,void 0,void 0,a.length+c.length))),r--,t&&n.appendMap(t,r)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new ZN(this.items.slice(0,o).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,l=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),u=new QN(e.mapping.maps[n],c,t);(a=l&&l.merge(u))&&(u=a,n?o.pop():s=s.slice(0,s.length-1)),o.push(u),t&&(i++,t=void 0),r||(l=u)}let a=i-n.depth;return a>tT&&(s=function(e,t){let n;return e.forEach(((e,r)=>{if(e.selection&&0==t--)return n=r,!1})),e.slice(n)}(s,a),i-=a),new ZN(s.append(o),i)}remapping(e,t){let n=new es;return this.items.forEach(((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new ZN(this.items.append(e.map((e=>new QN(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),r);let l=t;this.items.forEach((t=>{let r=o.getMirror(--l);if(null==r)return;i=Math.min(i,r);let a=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(l+1,r));c&&s++,n.push(new QN(a,i,c))}else n.push(new QN(a))}),r);let a=[];for(let e=t;e<i;e++)a.push(new QN(o.maps[e]));let c=this.items.slice(0,r).append(a).append(n),u=new ZN(c,s);return u.emptyItemCount()>500&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach(((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&o++;let a,c=new QN(s.invert(),e,l),u=r.length-1;(a=r.length&&r[u].merge(c))?r[u]=a:r.push(c)}}else i.map&&n--}),this.items.length,0),new ZN(XN.from(r.reverse()),o)}}ZN.empty=new ZN(XN.empty,0);class QN{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new QN(t.getMap().invert(),t,this.selection)}}}class eT{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const tT=20;function nT(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(((e,n,r,o)=>t.push(r,o)));return t}function rT(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let oT=!1,iT=null;function sT(e){let t=e.plugins;if(iT!=t){oT=!1,iT=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){oT=!0;break}}return oT}const lT=new cl("history"),aT=new cl("closeHistory");function cT(e,t){return(n,r)=>{let o=lT.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=sT(t),o=lT.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),a=new eT(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(lT,{redo:n,historyState:a})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const uT=cT(!1,!0),dT=cT(!0,!0);function hT(e,t){return Object.assign(e,{meta:{package:"@milkdown/plugin-history",...t}}),e}cT(!1,!1),cT(!0,!1);const pT=gC("Undo",(()=>()=>uT));hT(pT,{displayName:"Command<undo>"});const fT=gC("Redo",(()=>()=>dT));hT(fT,{displayName:"Command<redo>"});const mT=kC({},"historyProviderConfig");hT(mT,{displayName:"Ctx<historyProviderConfig>"});const gT=yC((e=>function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new sl({key:lT,state:{init:()=>new eT(ZN.empty,ZN.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(lT);if(i)return i.historyState;n.getMeta(aT)&&(e=new eT(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(lT))return s.getMeta(lT).redo?new eT(e.done.addTransform(n,void 0,r,sT(t)),e.undone,nT(n.mapping.maps),e.prevTime,e.prevComposition):new eT(e.done,e.undone.addTransform(n,void 0,r,sT(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new eT(e.done.rebased(n,o),e.undone.rebased(n,o),rT(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new eT(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),rT(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)})),n}(n,e.prevRanges)),l=s?rT(e.prevRanges,n.mapping):nT(n.mapping.maps);return new eT(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,sT(t)),ZN.empty,l,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?uT:"historyRedo"==n?dT:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}(e.get(mT.key))));hT(gT,{displayName:"Ctx<historyProviderPlugin>"});const yT=function(e,t){const n=Object.fromEntries(Object.entries(t).map((([e,{shortcuts:t}])=>[e,t]))),r=kC(n,"historyKeymapKeymap"),o=wC((e=>{const n=e.get(r.key),o=Object.entries(t).flatMap((([t,{command:r}])=>[n[t]].flat().map((t=>[t,r(e)]))));return Object.fromEntries(o)})),i=[r,o];return i.ctx=r,i.shortcuts=o,i.key=r.key,i.keymap=o.keymap,i}(0,{Undo:{shortcuts:"Mod-z",command:e=>{const t=e.get(Rh);return()=>t.call(pT.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:e=>{const t=e.get(Rh);return()=>t.call(fT.key)}}});hT(yT.ctx,{displayName:"KeymapCtx<history>"}),hT(yT.shortcuts,{displayName:"Keymap<history>"});const wT=[mT,gT,yT,pT,fT].flat(),kT=kC({type:"space",size:2},"indentConfig");kT.meta={package:"@milkdown/plugin-indent",displayName:"Ctx<indentConfig>"};const vT=wC((e=>({Tab:(t,n)=>{const r=e.get(kT.key),{tr:o}=t,i=function(e,t){const{doc:n,selection:r}=e;if(!n||!r||!(r instanceof qs||r instanceof Ys))return e;const{to:o}=r,i="space"===t.type?Array(t.size).fill(" ").join(""):"\t";return e.insertText(i,o)}(o,r);return!!i.docChanged&&(null==n||n(i),!0)}})));vT.meta={package:"@milkdown/plugin-indent",displayName:"Shortcut<indent>"};const bT=[kT,vT];class xT{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}}const CT=ne(new xT,"listener"),ST=new cl("MILKDOWN_LISTENER"),MT=e=>(e.inject(CT,new xT),async()=>{await e.wait(vh);const t=e.get(CT),{listeners:n}=t;n.beforeMount.forEach((t=>t(e))),await e.wait(Wh);const r=e.get(qh);let o=null,i=null;const s=new sl({key:ST,view:()=>({destroy:()=>{n.destroy.forEach((t=>t(e)))}}),props:{handleDOMEvents:{focus:()=>(n.focus.forEach((t=>t(e))),!1),blur:()=>(n.blur.forEach((t=>t(e))),!1)}},state:{init:(e,t)=>{o=t.doc,i=r(t.doc)},apply:t=>t.docChanged&&!1!==t.getMeta("addToHistory")?LC((()=>{const{doc:s}=t;if(n.updated.length>0&&o&&!o.eq(s)&&n.updated.forEach((t=>{t(e,s,o)})),n.markdownUpdated.length>0&&o&&!o.eq(s)){const t=r(s);n.markdownUpdated.forEach((n=>{n(e,t,i)})),i=t}o=s}),200)():void 0}});e.update(hh,(e=>e.concat(s))),await e.wait(tp),n.mounted.forEach((t=>t(e)))});MT.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};var NT,TT,OT,AT,ET,IT,DT,RT,PT,$T,LT=e=>{throw TypeError(e)},zT=(e,t,n)=>t.has(e)||LT("Cannot "+n),BT=(e,t,n)=>(zT(e,t,"read from private field"),n?n.call(e):t.get(e)),FT=(e,t,n)=>t.has(e)?LT("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),jT=(e,t,n,r)=>(zT(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function _T(e){const t=kC({},`${e}_SLASH_SPEC`),n=yC((n=>{const r=n.get(t.key);return new sl({key:new cl(`${e}_SLASH`),...r})})),r=[t,n];return r.key=t.key,r.pluginKey=n.key,t.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${e}`},n.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${e}`},r}class WT{constructor(e){FT(this,PT),FT(this,NT),FT(this,TT),FT(this,OT),FT(this,AT),FT(this,ET),FT(this,IT),FT(this,DT),FT(this,RT),jT(this,NT,!1),this.onShow=()=>{},this.onHide=()=>{},jT(this,RT,((e,t)=>{var n;const{state:r,composing:o}=e,{selection:i,doc:s}=r,{ranges:l}=i,a=Math.min(...l.map((e=>e.$from.pos))),c=Math.max(...l.map((e=>e.$to.pos))),u=t&&t.doc.eq(s)&&t.selection.eq(i);BT(this,NT)||(null==(n=e.dom.parentElement)||n.appendChild(this.element),jT(this,NT,!0)),o||u||(BT(this,IT).call(this,e,t)?(mC({getBoundingClientRect:()=>Xl(e,a,c)},this.element,{placement:"bottom-start",middleware:[fC(),hC(BT(this,DT)),...BT(this,TT)],...BT(this,OT)}).then((({x:e,y:t})=>{Object.assign(this.element.style,{left:`${e}px`,top:`${t}px`})})),this.show()):this.hide())})),this.update=(e,t)=>{LC(BT(this,RT),BT(this,AT))(e,t)},this.getContent=(e,t=(e=>"paragraph"===e.type.name))=>{const{selection:n}=e.state,{empty:r,$from:o}=n,i=e.state.selection instanceof qs,s=this.element.contains(document.activeElement),l=!e.hasFocus()&&!s,a=!e.editable,c=!aa(t)(e.state.selection);if(!l&&!a&&r&&i&&!c)return o.parent.textBetween(Math.max(0,o.parentOffset-500),o.parentOffset,void 0,"")},this.destroy=()=>{},this.show=()=>{this.element.dataset.show="true",this.onShow()},this.hide=()=>{this.element.dataset.show="false",this.onHide()},this.element=e.content,jT(this,AT,e.debounce??200),jT(this,IT,e.shouldShow??((e,t,n)=>(zT(this,t,"access private method"),n))(0,PT,$T)),jT(this,ET,e.trigger??"/"),jT(this,DT,e.offset),jT(this,TT,e.middleware??[]),jT(this,OT,e.floatingUIOptions??{})}}NT=new WeakMap,TT=new WeakMap,OT=new WeakMap,AT=new WeakMap,ET=new WeakMap,IT=new WeakMap,DT=new WeakMap,RT=new WeakMap,PT=new WeakSet,$T=function(e){const t=this.getContent(e);if(!t)return!1;const n=t.at(-1);return!!n&&(Array.isArray(BT(this,ET))?BT(this,ET).includes(n):BT(this,ET)===n)};const VT=kC({shouldAppend:e=>!(!e||["heading","paragraph"].includes(e.type.name)),getNode:e=>e.schema.nodes.paragraph.create()},"trailingConfig");VT.meta={package:"@milkdown/plugin-trailing",displayName:"Ctx<trailingConfig>"};const HT=yC((e=>{const t=new cl("MILKDOWN_TRAILING"),{shouldAppend:n,getNode:r}=e.get(VT.key),o=new sl({key:t,state:{init:(e,t)=>{const r=t.tr.doc.lastChild;return n(r,t)},apply:(e,t,r,o)=>{if(!e.docChanged)return t;const i=e.doc.lastChild;return n(i,o)}},appendTransaction:(e,t,n)=>{const{doc:i,tr:s}=n,l=null==r?void 0:r(n),a=o.getState(n),c=i.content.size;if(a&&l)return s.insert(c,l)}});return o}));HT.meta={package:"@milkdown/plugin-trailing",displayName:"Prose<trailing>"};const qT=[VT,HT];function KT(e){return new Promise((t=>{const n=new FileReader;n.addEventListener("load",(()=>{t({alt:e.name,src:n.result})}),!1),n.readAsDataURL(e)}))}const UT=async(e,t)=>{const n=[];for(let t=0;t<e.length;t++){const r=e.item(t);r&&r.type.includes("image")&&n.push(r)}const{image:r}=t.nodes;if(!r)throw V("image");return(await Promise.all(n.map((e=>KT(e))))).map((({alt:e,src:t})=>r.createAndFill({src:t,alt:e})))},JT=kC({uploader:UT,enableHtmlFileUploader:!1,uploadWidgetFactory:(e,t)=>{const n=document.createElement("span");return n.textContent="Upload in progress...",kd.widget(e,n,t)}},"uploadConfig");JT.meta={package:"@milkdown/plugin-upload",displayName:"Ctx<uploadConfig>"};const YT=yC((e=>{const t=new cl("MILKDOWN_UPLOAD"),n=(n,r,o)=>{var i;if(!o||o.length<=0)return!1;const s=Symbol("upload symbol"),l=e.get(Sh),{tr:a}=n.state,c=r instanceof DragEvent?(null==(i=n.posAtCoords({left:r.clientX,top:r.clientY}))?void 0:i.pos)??a.selection.from:a.selection.from;n.dispatch(a.setMeta(t,{add:{id:s,pos:c}}));const{uploader:u}=e.get(JT.key);return u(o,l).then((e=>{const r=((e,n)=>{var r;const o=t.getState(e);if(!o)return-1;const i=o.find(void 0,void 0,(e=>e.id===n));return i.length?(null==(r=i[0])?void 0:r.from)??-1:-1})(n.state,s);r<0||n.dispatch(n.state.tr.replaceWith(r,r,e).setMeta(t,{remove:{id:s}}))})).catch((e=>{console.error(e)})),!0};return new sl({key:t,state:{init:()=>xd.empty,apply(t,n){const r=n.map(t.mapping,t.doc),o=t.getMeta(this);if(!o)return r;if(o.add){const{uploadWidgetFactory:n}=e.get(JT.key),i=n(o.add.pos,{id:o.add.id});return r.add(t.doc,[i])}if(o.remove){const e=r.find(void 0,void 0,(e=>e.id===o.remove.id));return r.remove(e)}return r}},props:{decorations(e){return this.getState(e)},handlePaste:(t,r)=>{var o,i;const{enableHtmlFileUploader:s}=e.get(JT.key);return!(!(r instanceof ClipboardEvent)||!s&&null!=(o=r.clipboardData)&&o.getData("text/html"))&&n(t,r,null==(i=r.clipboardData)?void 0:i.files)},handleDrop:(e,t)=>{var r;return t instanceof DragEvent&&n(e,t,null==(r=t.dataTransfer)?void 0:r.files)}}})}));YT.meta={package:"@milkdown/plugin-upload",displayName:"Prose<upload>"};const GT=[JT,YT],XT={commonmark:h,gfm:p},ZT={imageBlock:m,imageInline:g,linkTooltip:w,listItemBlock:k,tableBlock:v},QT={block:b,cursor:C,history:S,indent:M,listener:N,slash:T,tooltip:y,trailing:O,upload:A,clipboard:x},eO={...i,state:l,transform:c,view:u,model:a}})(),window.Milkdown=r;