@meowdown/core 0.51.0 → 0.52.1
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.
- package/dist/index.d.ts +8 -3
- package/dist/index.js +20 -20
- package/dist/katex-chunk-Ch7kgbXr.js +1 -0
- package/dist/style.css +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ import { VirtualElement } from "@floating-ui/dom";
|
|
|
15
15
|
* - `exact`: byte-identical (modulo the trailing newline).
|
|
16
16
|
* - `normalizing`: bytes differ, but only as layout the parser collapses back -
|
|
17
17
|
* no non-blank line content is lost and re-parsing the output yields the same
|
|
18
|
-
* doc (e.g. a lazy continuation re-indented to its canonical column
|
|
18
|
+
* doc (e.g. a lazy continuation re-indented to its canonical column, or a
|
|
19
|
+
* table delimiter row rewritten to canonical dashes).
|
|
19
20
|
* - `lossy`: content changed - a non-blank line differs, or the re-parsed doc does.
|
|
20
21
|
*/
|
|
21
22
|
type RoundTripFidelity = 'exact' | 'normalizing' | 'lossy';
|
|
@@ -1002,8 +1003,10 @@ declare function defineImage(options?: ImageOptions): PlainExtension;
|
|
|
1002
1003
|
/** Inline math rendering: a KaTeX preview on the `mdMath` mark. */
|
|
1003
1004
|
declare function defineMath(): PlainExtension;
|
|
1004
1005
|
//#endregion
|
|
1005
|
-
//#region src/utils/katex.d.ts
|
|
1006
|
+
//#region src/utils/katex-chunk.d.ts
|
|
1006
1007
|
type KaTeXRender = typeof render;
|
|
1008
|
+
//#endregion
|
|
1009
|
+
//#region src/utils/katex.d.ts
|
|
1007
1010
|
/**
|
|
1008
1011
|
* Load KaTeX's render function on first use and cache it. Most documents
|
|
1009
1012
|
* contain no math, so the library stays out of the initial bundle.
|
|
@@ -1077,6 +1080,7 @@ declare function defineLinkPaste(): PlainExtension;
|
|
|
1077
1080
|
//#region src/extensions/mark-names.d.ts
|
|
1078
1081
|
declare const MARK_NAMES: readonly ["mdWikilink", "mdImage", "mdFile", "mdMath", "mdMark", "mdEm", "mdStrong", "mdCode", "mdLinkText", "mdLinkUri", "mdLinkTitle", "mdDel", "mdHighlight", "mdTag", "mdPack"];
|
|
1079
1082
|
type MarkName = (typeof MARK_NAMES)[number];
|
|
1083
|
+
declare function isMarkOfType(mark: Mark, name: MarkName): boolean;
|
|
1080
1084
|
//#endregion
|
|
1081
1085
|
//#region src/extensions/node-names.d.ts
|
|
1082
1086
|
/**
|
|
@@ -1084,6 +1088,7 @@ type MarkName = (typeof MARK_NAMES)[number];
|
|
|
1084
1088
|
*/
|
|
1085
1089
|
declare const NODE_NAMES: readonly ["doc", "text", "paragraph", "heading", "blockquote", "list", "codeBlock", "horizontalRule", "htmlComment", "table", "tableRow", "tableCell", "tableHeaderCell"];
|
|
1086
1090
|
type NodeName = (typeof NODE_NAMES)[number];
|
|
1091
|
+
declare function isNodeOfType(node: ProseMirrorNode, name: NodeName): boolean;
|
|
1087
1092
|
//#endregion
|
|
1088
1093
|
//#region src/extensions/substitution.d.ts
|
|
1089
1094
|
/** Apply the editor's automatic plain-text substitutions. */
|
|
@@ -1157,4 +1162,4 @@ declare function defineSpellCheckPlugin(spellCheck: boolean): import("@prosekit/
|
|
|
1157
1162
|
*/
|
|
1158
1163
|
declare function formatFileSize(bytes: number): string;
|
|
1159
1164
|
//#endregion
|
|
1160
|
-
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EditorExtensionOptions, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type RoundTripFidelity, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, insertLink, isCodeBlockPreviewHiddenDecoration, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
|
|
1165
|
+
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EditorExtensionOptions, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type RoundTripFidelity, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, insertLink, isCodeBlockPreviewHiddenDecoration, isMarkOfType, isNodeOfType, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineClipboardSerializer as o,defineCommands as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as h,getMarkType as ee,getNodeType as te,isAllSelection as ne,isApple as re,isAtBlockStart as ie,isNodeSelection as ae,isTextSelection as g,setBlockType as oe,toggleNode as se,union as _,unsetBlockType as ce,withPriority as le,withPriority as v,withSkipCodeBlock as ue}from"@prosekit/core";import{defineCodeBlock as de,defineCodeBlockHighlight as fe,defineCodeBlockPreviewPlugin as pe,isCodeBlockPreviewHiddenDecoration as me}from"@prosekit/extensions/code-block";import{definePlaceholder as he}from"@prosekit/extensions/placeholder";import{defineReadonly as ge}from"@prosekit/extensions/readonly";import{isElementLike as _e,isHTMLElement as ve,isObject as ye,once as be}from"@ocavue/utils";import{defineBlockquote as xe}from"@prosekit/extensions/blockquote";import{defineDoc as Se}from"@prosekit/extensions/doc";import{defineGapCursor as Ce}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as we}from"@prosekit/extensions/mod-click-prevention";import{defineText as Te}from"@prosekit/extensions/text";import{defineVirtualSelection as Ee}from"@prosekit/extensions/virtual-selection";import{NodeSelection as De,Plugin as y,PluginKey as b,Selection as x,TextSelection as S}from"@prosekit/pm/state";import{Decoration as Oe,DecorationSet as C}from"@prosekit/pm/view";import ke from"rehype-parse";import Ae from"rehype-remark";import je from"remark-gfm";import Me from"remark-stringify";import{unified as Ne}from"unified";import{DOMParser as Pe,DOMSerializer as Fe,Fragment as w,Mark as Ie,Slice as T}from"@prosekit/pm/model";import{defineHeadingCommands as Le,defineHeadingInputRule as Re,defineHeadingSpec as ze}from"@prosekit/extensions/heading";import{defineParagraphCommands as Be,defineParagraphKeymap as Ve}from"@prosekit/extensions/paragraph";import{LanguageDescription as He}from"@codemirror/language";import{languages as Ue}from"@codemirror/language-data";import{classHighlighter as We,highlightTree as Ge}from"@lezer/highlight";import{createParser as Ke}from"prosemirror-highlight/lezer";import{defineEnterRule as qe,defineTextBlockEnterRule as Je}from"@prosekit/extensions/enter-rule";import{defineInputRule as Ye,defineTextBlockInputRule as Xe}from"@prosekit/extensions/input-rule";import{triggerAutocomplete as Ze}from"@prosekit/extensions/autocomplete";import{defineListCommands as Qe,defineListDropIndicator as $e,defineListKeymap as et,defineListSpec as tt,moveList as nt,toggleList as rt,unwrapList as it,wrapInList as E}from"@prosekit/extensions/list";import{chainCommands as at,lift as ot}from"@prosekit/pm/commands";import{defineHorizontalRule as st}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as ct,AddNodeMarkStep as lt,RemoveMarkStep as ut,RemoveNodeMarkStep as dt,ReplaceStep as ft,Step as pt,StepResult as mt,Transform as ht}from"@prosekit/pm/transform";import{GFM as gt,parser as _t}from"@lezer/markdown";import{createListRenderingPlugin as vt,createSafariInputMethodWorkaroundPlugin as yt,createToggleCollapsedCommand as bt,defaultAttributesGetter as xt,findCheckboxInListItem as St,handleListMarkerMouseDown as Ct,joinListElements as wt,listToDOM as Tt,unwrapListSlice as Et,wrappingListInputRule as Dt}from"prosemirror-flat-list";import{defineTableCellSpec as Ot,defineTableCommands as kt,defineTableDropIndicator as At,defineTableEditingPlugin as jt,defineTableHeaderCellSpec as Mt,defineTableRowSpec as Nt,defineTableSpec as Pt,deleteTable as Ft,isCellSelection as It}from"@prosekit/extensions/table";import{closeHistory as Lt}from"@prosekit/pm/history";import{registerResizableHandleElement as Rt,registerResizableRootElement as zt}from"@prosekit/web/resizable";import{InputRule as Bt}from"@prosekit/pm/inputrules";function D(e,t,n,r){let i=e.doc.content.size;if(t<0||t>i)return;let a=e.doc.resolve(t);if(!(!a.parent.isTextblock||a.parent.type.spec.code))return h(a,n,r)}const O=new b(`mark-mode`);function Vt(e){return O.getState(e)}function Ht(e){return new y({key:O,state:{init:()=>e,apply:(e,t)=>e.getMeta(O)??t},props:{attributes:t=>({"data-mark-mode":Vt(t)??e}),decorations:e=>{let t=Vt(e);if(t===`focus`)return Gt(e);if(t===`hide`)return Kt(e)}}})}function Ut(e){return(t,n)=>k(t)===e?!1:(n?.(t.tr.setMeta(O,e)),!0)}function Wt(e){return _(m(Ht(e)),s({setMarkMode:Ut}))}function k(e){return O.getState(e)}function Gt(e){return qt(e,void 0)}function Kt(e){return qt(e,{key:`math`})}function qt(e,t){let{selection:n}=e;if(!n.empty)return C.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return C.empty;let a=h(r,ee(e.schema,`mdPack`),t);return a?C.create(e.doc,[Oe.inline(a.from,a.to,{class:`show`})]):C.empty}const Jt=[`mdImage`,`mdWikilink`,`mdFile`];function A(e,t){let n=k(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function Yt(e,t,n){for(let r of n){let n=D(e,t,r);if(n)return n}}function j(e,t,n){let r=Yt(e,t,n);return r&&r.to===t?r:void 0}function M(e,t,n){let r=Yt(e,t,n);return r&&r.from===t?r:void 0}function Xt(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=Yt(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function Zt(e,t){return S.create(e.doc,t.from,t.to)}function Qt(e,t,n,r){let i=e.doc.resolve(t);if(!(r===-1?i.parentOffset===0:i.parentOffset===i.parent.content.size)||i.depth===0)return;let a=r===-1?M(e,t,n):j(e,t,n),o=r===-1?i.before():i.after(),s=x.findFrom(e.doc.resolve(o),r);if(!s)return;let c=g(s)?r===-1?j(e,s.head,n):M(e,s.head,n):void 0;if(!(a==null&&c==null))return s}function $t(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=M(t,i.from,r);if(e)return n?.(t.tr.setSelection(Zt(t,e))),!0;if(j(t,i.from,r)&&i.from<t.doc.resolve(i.from).end())return n?.(t.tr.setSelection(S.create(t.doc,i.from+1))),!0;let a=Qt(t,i.from,r,1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=Xt(t,r);return a?(n?.(t.tr.setSelection(S.create(t.doc,a.to))),!0):!1}}function en(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=j(t,i.from,r);if(e)return n?.(t.tr.setSelection(Zt(t,e))),!0;let a=Qt(t,i.from,r,-1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=Xt(t,r);return a?(n?.(t.tr.setSelection(S.create(t.doc,a.from))),!0):!1}}function tn(e,t){return(n,r)=>{let i=A(e,n);if(i.length===0||!g(n.selection))return!1;let{anchor:a,head:o}=n.selection,s=t===-1?j(n,o,i):M(n,o,i);if(s){let e=t===-1?s.from:s.to;return r?.(n.tr.setSelection(S.create(n.doc,a,e)).scrollIntoView()),!0}let c=Qt(n,o,i,t);return!c||!g(c)?!1:(r?.(n.tr.setSelection(S.create(n.doc,a,c.head)).scrollIntoView()),!0)}}function nn(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=j(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!M(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function rn(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=M(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!j(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const an=`md-atom-selected`;function on(e){return new y({key:new b(`atom-mark-selection`),props:{decorations:t=>{let n=A(e,t);if(n.length===0||ae(t.selection))return;let r=Xt(t,n);if(r)return C.create(t.doc,[Oe.inline(r.from,r.to,{class:an})]);let{from:i,to:a,empty:o}=t.selection;if(o)return null;let s=[];return t.doc.nodesBetween(i,a,(e,t)=>{e.marks.some(e=>n.includes(e.type.name))&&s.push(Oe.inline(t,t+e.nodeSize,{class:an}))}),C.create(t.doc,s)}}})}function sn({marks:e}){return _(v(l({ArrowRight:$t(e),ArrowLeft:en(e),"Shift-ArrowRight":tn(e,1),"Shift-ArrowLeft":tn(e,-1),Backspace:nn(e),Delete:rn(e)}),t.high),m(on(e)))}const cn=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},ln=(e,t,n,r)=>{let i=e,a=n.createTracker(r),o=a.move(`==`);return o+=a.move(n.containerPhrasing(i,{...a.current(),before:o,after:`=`})),o+=a.move(`==`),o};function un(){return Ne().use(ke).use(Ae,{handlers:{mark:cn}}).use(je).use(Me,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:ln}}).freeze()}const dn=be(un);function fn(e){return String(dn().processSync(e))}function pn(e){if(e==null)return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)?t:void 0}function N(e){let t=pn(e);return t!=null&&t>0?t:void 0}const mn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),hn=new Set([`mdWikilink`,`mdImage`,`mdFile`,`mdMath`]);function gn(e){return e.find(e=>hn.has(e.type.name))}function _n(e){return e.some(e=>mn.has(e.type.name))}function vn(e){let t=[];return e.forEach(e=>{if(!e.isText||!e.text)return;let n=gn(e.marks),r=t.at(-1);if(n!=null&&r!=null&&r.atom===n){r.text+=e.text,r.children.push(e);return}t.push({atom:n,text:e.text,children:[e]})}),t}const yn={mdStrong:`strong`,mdEm:`em`,mdCode:`code`,mdDel:`del`,mdHighlight:`mark`,mdLinkText:`a`};function bn(e,t,n={}){let r=document.createElement(e);r.setAttribute(`data-md`,t.textContent);for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return Sn(t,r),r}function xn(e,t,n){return{tag:`${e}[data-md]`,node:t,priority:100,getAttrs:n,getContent:(e,t)=>{let n=(ve(e)?e:void 0)?.getAttribute(`data-md`)??``;return n?w.from(t.text(n)):w.empty}}}function Sn(e,t){let n=[];for(let r of vn(e)){if(r.atom!=null){n.length=0,t.append(Tn(r.atom,r.text));continue}for(let e of r.children)_n(e.marks)||(Cn(n,e.marks.filter(e=>yn[e.type.name]),t),wn(n.at(-1)?.element??t,e.text??``))}}function Cn(e,t,n){let r=0;for(;r<e.length&&r<t.length&&t[r].eq(e[r].mark);)r++;e.length=r;for(let i=r;i<t.length;i++){let r=t[i],a=document.createElement(yn[r.type.name]??`span`);r.type.name===`mdLinkText`&&a.setAttribute(`href`,r.attrs.href),(e.at(-1)?.element??n).append(a),e.push({mark:r,element:a})}}function wn(e,t){let n=t.split(`
|
|
2
|
-
`);for(let[t,r]of n.entries())t>0&&e.append(document.createElement(`br`)),r&&e.append(document.createTextNode(r))}function
|
|
3
|
-
`).replace(/^\n+/,``).replace(/\n+$/,``);if(!n)return T.empty;let r=te(e,`paragraph`),i=[],a=n.split(/(\n{2,})/);for(let t=0;t<a.length;t++){let n=a[t];if(t%2==0)i.push(r.create(null,n?e.text(n):void 0));else{let e=n.length-1;for(let t=1;t<e;t++)i.push(r.create())}}return T.maxOpen(w.from(i))}function
|
|
1
|
+
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineClipboardSerializer as o,defineCommands as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as h,getMarkType as ee,getNodeType as te,isAllSelection as ne,isApple as re,isAtBlockStart as ie,isNodeSelection as ae,isTextSelection as g,setBlockType as oe,toggleNode as se,union as _,unsetBlockType as ce,withPriority as le,withPriority as v,withSkipCodeBlock as ue}from"@prosekit/core";import{defineCodeBlock as de,defineCodeBlockHighlight as fe,defineCodeBlockPreviewPlugin as pe,isCodeBlockPreviewHiddenDecoration as me}from"@prosekit/extensions/code-block";import{definePlaceholder as he}from"@prosekit/extensions/placeholder";import{defineReadonly as ge}from"@prosekit/extensions/readonly";import{isElementLike as _e,isHTMLElement as ve,isObject as ye,once as be}from"@ocavue/utils";import{defineBlockquote as xe}from"@prosekit/extensions/blockquote";import{defineDoc as Se}from"@prosekit/extensions/doc";import{defineGapCursor as Ce}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as we}from"@prosekit/extensions/mod-click-prevention";import{defineText as Te}from"@prosekit/extensions/text";import{defineVirtualSelection as Ee}from"@prosekit/extensions/virtual-selection";import{NodeSelection as De,Plugin as y,PluginKey as b,Selection as Oe,TextSelection as x}from"@prosekit/pm/state";import{Decoration as ke,DecorationSet as S}from"@prosekit/pm/view";import Ae from"rehype-parse";import je from"rehype-remark";import Me from"remark-gfm";import Ne from"remark-stringify";import{unified as Pe}from"unified";import{DOMParser as Fe,DOMSerializer as C,Fragment as w,Mark as Ie,Slice as T}from"@prosekit/pm/model";import{defineHeadingCommands as Le,defineHeadingInputRule as Re,defineHeadingSpec as ze}from"@prosekit/extensions/heading";import{defineParagraphCommands as Be,defineParagraphKeymap as Ve}from"@prosekit/extensions/paragraph";import{LanguageDescription as He}from"@codemirror/language";import{languages as Ue}from"@codemirror/language-data";import{classHighlighter as We,highlightTree as Ge}from"@lezer/highlight";import{createParser as Ke}from"prosemirror-highlight/lezer";import{defineEnterRule as qe,defineTextBlockEnterRule as Je}from"@prosekit/extensions/enter-rule";import{defineInputRule as Ye,defineTextBlockInputRule as Xe}from"@prosekit/extensions/input-rule";import{triggerAutocomplete as Ze}from"@prosekit/extensions/autocomplete";import{defineListCommands as Qe,defineListDropIndicator as $e,defineListKeymap as et,defineListSpec as tt,moveList as nt,toggleList as rt,unwrapList as it,wrapInList as E}from"@prosekit/extensions/list";import{chainCommands as at,lift as ot}from"@prosekit/pm/commands";import{defineHorizontalRule as st}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as ct,AddNodeMarkStep as lt,RemoveMarkStep as ut,RemoveNodeMarkStep as dt,ReplaceStep as ft,Step as pt,StepResult as mt,Transform as ht}from"@prosekit/pm/transform";import{GFM as gt,parser as _t}from"@lezer/markdown";import{createListRenderingPlugin as vt,createSafariInputMethodWorkaroundPlugin as yt,createToggleCollapsedCommand as bt,defaultAttributesGetter as xt,findCheckboxInListItem as St,handleListMarkerMouseDown as Ct,joinListElements as wt,listToDOM as Tt,unwrapListSlice as Et,wrappingListInputRule as D}from"prosemirror-flat-list";import{defineTableCellSpec as Dt,defineTableCommands as Ot,defineTableDropIndicator as kt,defineTableEditingPlugin as At,defineTableHeaderCellSpec as jt,defineTableRowSpec as Mt,defineTableSpec as Nt,deleteTable as Pt,isCellSelection as Ft}from"@prosekit/extensions/table";import{closeHistory as It}from"@prosekit/pm/history";import{registerResizableHandleElement as Lt,registerResizableRootElement as Rt}from"@prosekit/web/resizable";import{InputRule as zt}from"@prosekit/pm/inputrules";function O(e,t,n,r){let i=e.doc.content.size;if(t<0||t>i)return;let a=e.doc.resolve(t);if(!(!a.parent.isTextblock||a.parent.type.spec.code))return h(a,n,r)}const k=new b(`mark-mode`);function Bt(e){return k.getState(e)}function Vt(e){return new y({key:k,state:{init:()=>e,apply:(e,t)=>e.getMeta(k)??t},props:{attributes:t=>({"data-mark-mode":Bt(t)??e}),decorations:e=>{let t=Bt(e);if(t===`focus`)return Wt(e);if(t===`hide`)return Gt(e)}}})}function Ht(e){return(t,n)=>A(t)===e?!1:(n?.(t.tr.setMeta(k,e)),!0)}function Ut(e){return _(m(Vt(e)),s({setMarkMode:Ht}))}function A(e){return k.getState(e)}function Wt(e){return Kt(e,void 0)}function Gt(e){return Kt(e,{key:`math`})}function Kt(e,t){let{selection:n}=e;if(!n.empty)return S.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return S.empty;let a=h(r,ee(e.schema,`mdPack`),t);return a?S.create(e.doc,[ke.inline(a.from,a.to,{class:`show`})]):S.empty}const qt=[`mdImage`,`mdWikilink`,`mdFile`];function j(e,t){let n=A(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function Jt(e,t,n){for(let r of n){let n=O(e,t,r);if(n)return n}}function M(e,t,n){let r=Jt(e,t,n);return r&&r.to===t?r:void 0}function N(e,t,n){let r=Jt(e,t,n);return r&&r.from===t?r:void 0}function Yt(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=Jt(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function Xt(e,t){return x.create(e.doc,t.from,t.to)}function Zt(e,t,n,r){let i=e.doc.resolve(t);if(!(r===-1?i.parentOffset===0:i.parentOffset===i.parent.content.size)||i.depth===0)return;let a=r===-1?N(e,t,n):M(e,t,n),o=r===-1?i.before():i.after(),s=Oe.findFrom(e.doc.resolve(o),r);if(!s)return;let c=g(s)?r===-1?M(e,s.head,n):N(e,s.head,n):void 0;if(!(a==null&&c==null))return s}function Qt(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=N(t,i.from,r);if(e)return n?.(t.tr.setSelection(Xt(t,e))),!0;if(M(t,i.from,r)&&i.from<t.doc.resolve(i.from).end())return n?.(t.tr.setSelection(x.create(t.doc,i.from+1))),!0;let a=Zt(t,i.from,r,1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=Yt(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.to))),!0):!1}}function $t(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=M(t,i.from,r);if(e)return n?.(t.tr.setSelection(Xt(t,e))),!0;let a=Zt(t,i.from,r,-1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=Yt(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.from))),!0):!1}}function en(e,t){return(n,r)=>{let i=j(e,n);if(i.length===0||!g(n.selection))return!1;let{anchor:a,head:o}=n.selection,s=t===-1?M(n,o,i):N(n,o,i);if(s){let e=t===-1?s.from:s.to;return r?.(n.tr.setSelection(x.create(n.doc,a,e)).scrollIntoView()),!0}let c=Zt(n,o,i,t);return!c||!g(c)?!1:(r?.(n.tr.setSelection(x.create(n.doc,a,c.head)).scrollIntoView()),!0)}}function tn(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=M(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!N(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function nn(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=N(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!M(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const rn=`md-atom-selected`;function an(e){return new y({key:new b(`atom-mark-selection`),props:{decorations:t=>{let n=j(e,t);if(n.length===0||ae(t.selection))return;let r=Yt(t,n);if(r)return S.create(t.doc,[ke.inline(r.from,r.to,{class:rn})]);let{from:i,to:a,empty:o}=t.selection;if(o)return null;let s=[];return t.doc.nodesBetween(i,a,(e,t)=>{e.marks.some(e=>n.includes(e.type.name))&&s.push(ke.inline(t,t+e.nodeSize,{class:rn}))}),S.create(t.doc,s)}}})}function on({marks:e}){return _(v(l({ArrowRight:Qt(e),ArrowLeft:$t(e),"Shift-ArrowRight":en(e,1),"Shift-ArrowLeft":en(e,-1),Backspace:tn(e),Delete:nn(e)}),t.high),m(an(e)))}const sn=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},cn=(e,t,n,r)=>{let i=e,a=n.createTracker(r),o=a.move(`==`);return o+=a.move(n.containerPhrasing(i,{...a.current(),before:o,after:`=`})),o+=a.move(`==`),o};function ln(){return Pe().use(Ae).use(je,{handlers:{mark:sn}}).use(Me).use(Ne,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:cn}}).freeze()}const un=be(ln);function dn(e){return String(un().processSync(e))}function fn(e){if(e==null)return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)?t:void 0}function pn(e){let t=fn(e);return t!=null&&t>0?t:void 0}function mn(e,t){return e.type.name===t}const hn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),gn=new Set([`mdWikilink`,`mdImage`,`mdFile`,`mdMath`]);function _n(e){return e.find(e=>gn.has(e.type.name))}function vn(e){return e.some(e=>hn.has(e.type.name))}function yn(e){let t=[];return e.forEach(e=>{if(!e.isText||!e.text)return;let n=_n(e.marks),r=t.at(-1);if(n!=null&&r!=null&&r.atom===n){r.text+=e.text,r.children.push(e);return}t.push({atom:n,text:e.text,children:[e]})}),t}const bn={mdStrong:`strong`,mdEm:`em`,mdCode:`code`,mdDel:`del`,mdHighlight:`mark`,mdLinkText:`a`};function xn(e,t,n={}){let r=document.createElement(e);r.setAttribute(`data-md`,t.textContent);for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return Cn(t,r),r}function Sn(e,t,n){return{tag:`${e}[data-md]`,node:t,priority:100,getAttrs:n,getContent:(e,t)=>{let n=(ve(e)?e:void 0)?.getAttribute(`data-md`)??``;return n?w.from(t.text(n)):w.empty}}}function Cn(e,t){let n=[];for(let r of yn(e)){if(r.atom!=null){n.length=0,t.append(En(r.atom,r.text));continue}for(let e of r.children)vn(e.marks)||(wn(n,e.marks.filter(e=>bn[e.type.name]),t),Tn(n.at(-1)?.element??t,e.text??``))}}function wn(e,t,n){let r=0;for(;r<e.length&&r<t.length&&t[r].eq(e[r].mark);)r++;e.length=r;for(let i=r;i<t.length;i++){let r=t[i],a=document.createElement(bn[r.type.name]??`span`);mn(r,`mdLinkText`)&&a.setAttribute(`href`,r.attrs.href),(e.at(-1)?.element??n).append(a),e.push({mark:r,element:a})}}function Tn(e,t){let n=t.split(`
|
|
2
|
+
`);for(let[t,r]of n.entries())t>0&&e.append(document.createElement(`br`)),r&&e.append(document.createTextNode(r))}function En(e,t){switch(e.type.name){case`mdImage`:{let t=e.attrs,n=document.createElement(`img`);return n.setAttribute(`src`,t.src),t.alt&&n.setAttribute(`alt`,t.alt),t.title&&n.setAttribute(`title`,t.title),t.width!=null&&n.setAttribute(`width`,String(t.width)),t.height!=null&&n.setAttribute(`height`,String(t.height)),n}case`mdWikilink`:{let t=e.attrs;return document.createTextNode(t.display||t.target)}case`mdFile`:{let t=e.attrs,n=document.createElement(`a`);return n.setAttribute(`href`,t.href),n.append(document.createTextNode(t.name||t.href)),n}default:return document.createTextNode(t)}}function P(e,t){return e.type.name===t}function Dn(){return p({name:`heading`,whitespace:`pre`})}function On(e){let t=e.attrs;return xn(`h${t.level}`,e,{"data-setext-underline":t.setextUnderline==null?void 0:String(t.setextUnderline),"data-closing-hashes":t.closingHashes==null?void 0:String(t.closingHashes)})}function kn(){return[1,2,3,4,5,6].map(e=>Sn(`h${e}`,`heading`,t=>({level:e,setextUnderline:pn(t.getAttribute(`data-setext-underline`))??null,closingHashes:pn(t.getAttribute(`data-closing-hashes`))??null})))}function An(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>pn(e.getAttribute(`data-setext-underline`))??null})}function jn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>pn(e.getAttribute(`data-closing-hashes`))??null})}function F(e){return ue(se({type:`heading`,attrs:{level:e}}))}const Mn=(e,t,n)=>{let r=ie(e,n);return r!=null&&P(r.parent,`heading`)?ce()(e,t,n):!1};function Nn(){return l({"Mod-1":F(1),"Mod-2":F(2),"Mod-3":F(3),"Mod-4":F(4),"Mod-5":F(5),"Mod-6":F(6),Backspace:Mn})}function Pn(){return _(ze(),Dn(),An(),jn(),Re(),Le(),Nn())}function Fn(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function In(e){return xn(`p`,e)}function Ln(){return[Sn(`p`,`paragraph`)]}function Rn(){return _(v(Fn(),t.highest),Be(),Ve())}function zn(e){return{...e,paragraph:e=>({dom:In(e)}),heading:e=>({dom:On(e)})}}function Bn(){return o({serializeFragmentWrapper:e=>(...t)=>{let n=e(...t);for(let e of n.children)e.setAttribute(`data-meowdown`,``);return n},nodesFromSchemaWrapper:e=>(...t)=>zn(e(...t))})}const Vn=new WeakMap;function Hn(e){let t=Vn.get(e);return t??(t=new C(zn(C.nodesFromSchema(e)),C.marksFromSchema(e)),Vn.set(e,t)),t}const Un=new b(`meowdown-html-paste`);function Wn(e){return e.includes(`data-meowdown`)?!0:e.includes(`data-pm-slice`)&&e.includes(`md-mark`)}function Gn(){return m(new y({key:Un,props:{transformPastedHTML:(e,t)=>{if(Wn(e))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=dn(e);if(!r.trim())return e;let i=X(r,{nodes:_c(t.state.schema)}),a=Hn(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}function Kn(e){return new Fe(e,[...Ln(),...kn(),...Fe.fromSchema(e).rules])}const qn=new b(`meowdown-clipboard-parser`);function Jn(){return m(({schema:e})=>new y({key:qn,props:{clipboardParser:Kn(e)}}))}function Yn(e,t){let n=t.replaceAll(/\r\n?/g,`
|
|
3
|
+
`).replace(/^\n+/,``).replace(/\n+$/,``);if(!n)return T.empty;let r=te(e,`paragraph`),i=[],a=n.split(/(\n{2,})/);for(let t=0;t<a.length;t++){let n=a[t];if(t%2==0)i.push(r.create(null,n?e.text(n):void 0));else{let e=n.length-1;for(let t=1;t<e;t++)i.push(r.create())}}return T.maxOpen(w.from(i))}function Xn(e,t,n){let r=n.marks(),i=C.fromSchema(e),a=document.createElement(`div`);for(let n of t.split(/(?:\r\n?|\n)+/)){let t=a.appendChild(document.createElement(`p`));n&&t.appendChild(i.serializeNode(e.text(n,r)))}return Fe.fromSchema(e).parseSlice(a,{preserveWhitespace:!0,context:n})}function Zn(){return m(new y({key:new b(`meowdown-plain-paste`),props:{clipboardTextParser:(e,t,n,r)=>{let{schema:i}=r.state;return n?Xn(i,e,t):Yn(i,e)}}}))}function I(e){return e===32||e===9||e===10||e===13}function Qn(e,t,n=0){let r=n,i=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)===t?(i++,i>r&&(r=i)):i=0;return r}function $n(e,t=0){return Qn(e,96,t)}function er(e,t={}){let n=new ir;return t.frontmatter&&tr(e.attrs.frontmatter,n),ar(e,n),n.finish()}function tr(e,t){e!==null&&(t.write(`---`),t.write(`
|
|
4
4
|
`),e!==``&&(t.write(e),t.write(`
|
|
5
|
-
`)),t.write(`---`),t.closeBlock())}const
|
|
6
|
-
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(
|
|
5
|
+
`)),t.write(`---`),t.closeBlock())}const nr=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function rr(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){lr(e,t);let i=n.level===1?`=`:`-`;t.write(`
|
|
6
|
+
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(nr[n.level]??`# `),lr(e,t);let i=n.closingHashes;i!=null&&i>0&&t.write(` `+`#`.repeat(i)),t.closeBlock()}var ir=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
|
|
7
7
|
`)){this.parts.push(e);return}let t=e.split(`
|
|
8
8
|
`);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
|
|
9
9
|
`,this.linePrefix),t[e]!==``&&this.parts.push(t[e])}closeEmptyBlock(){if(!this.atLineStart||this.pendingFirst!==null){this.closeBlock();return}this.parts.length!==0&&(this.emitDeferredBlankLine(),this.deferredBlankPrefix=this.linePrefix)}closeBlock(){this.atLineStart&&this.pendingFirst!==null&&(this.emitDeferredBlankLine(),this.parts.push(this.pendingFirst.trimEnd()),this.pendingFirst=null,this.atLineStart=!1),this.atLineStart||this.parts.push(`
|
|
10
10
|
`),this.atLineStart=!0,this.deferredBlankPrefix=this.linePrefix}suppressBlank(){this.deferredBlankPrefix=null}withPrefix(e,t,n){let r=this.linePrefix,i=this.pendingFirst;if(this.linePrefix=r+e,t!==null){let e=i??r;this.pendingFirst=e+t}n(),this.linePrefix=r,this.pendingFirst=t===null?i:null}finish(){return this.parts.join(``).replace(/\s+$/,``)+`
|
|
11
11
|
`}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
|
|
12
|
-
`),this.deferredBlankPrefix=null)}};function
|
|
12
|
+
`),this.deferredBlankPrefix=null)}};function ar(e,t){switch(e.type.name){case`doc`:or(e,t);return;case`paragraph`:if(e.childCount===0){t.closeEmptyBlock();return}lr(e,t),t.closeBlock();return;case`heading`:rr(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>or(e,t)),t.closeBlock();return;case`list`:ur(e,t,cr(e));return;case`codeBlock`:dr(e,t);return;case`horizontalRule`:{let{marker:n}=e.attrs;t.write(n||`---`),t.closeBlock();return}case`htmlComment`:{let{content:n}=e.attrs;t.write(n),t.closeBlock();return}case`table`:mr(e,t);return;case`text`:e.text&&t.write(e.text);return}}function or(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(!P(a,`list`)){n&&i>0&&t.suppressBlank(),ar(a,t),i++;continue}let o=i+1;for(;o<r&&P(e.child(o),`list`);)o++;let s=sr(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),ur(e.child(r),t,s);i=o}}function sr(e,t,n){for(let r=t;r<n;r++)if(!cr(e.child(r)))return!1;return!0}function cr(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n).type.name;if(t!==`list`&&!(t===`paragraph`&&n===0))return!1}return!0}function lr(e,t){let n=e.childCount;for(let r=0;r<n;r++){let n=e.child(r);n.isText&&n.text&&t.write(n.text)}}function ur(e,t,n){let{kind:r,marker:i,order:a,taskMarker:o,collapsed:s,markerGap:c,checked:l}=e.attrs,u=r===`task`?i===`+`?`+`:i===`*`?`*`:`-`:s?`+`:i===`*`?`*`:`-`,d=i===`)`?`)`:`.`,f=o===`X`?`X`:`x`,p=Math.min(Math.max(c??1,1),4),m=`${r===`ordered`?`${a??1}${d}`:u}${` `.repeat(p)}`,h=r===`task`?`${m}[${l?f:` `}] `:m,ee=` `.repeat(m.length);t.withPrefix(ee,h,()=>or(e,t,n)),t.closeBlock()}function dr(e,t){let n=e.attrs,r=n.language||``,i=e.textContent;if(n.fenceStyle===`indented`&&!r){let e=fr(i);if(e!=null){t.write(e),t.closeBlock();return}}if(n.fenceStyle===`dollar`&&r===`math`&&!pr(i)){t.write(`$$`),t.write(`
|
|
13
13
|
`),i&&(t.write(i),t.write(`
|
|
14
|
-
`)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=
|
|
14
|
+
`)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=Qn(i,a?126:96,2)+1,s=(a?`~`:"`").repeat(Math.max(n.fenceLength??0,o));t.write(s),r&&t.write(r),t.write(`
|
|
15
15
|
`),i&&(t.write(i),t.write(`
|
|
16
|
-
`)),t.write(s),t.closeBlock()}function
|
|
16
|
+
`)),t.write(s),t.closeBlock()}function fr(e){if(e===``)return;let t=e.split(`
|
|
17
17
|
`);if(!(t[0]===``||t[t.length-1]===``)){for(let e=0;e<t.length;e++)t[e]!==``&&(t[e]=` ${t[e]}`);return t.join(`
|
|
18
|
-
`)}}function
|
|
19
|
-
`).some(e=>e.trim()===`$$`)}function
|
|
18
|
+
`)}}function pr(e){return e.split(`
|
|
19
|
+
`).some(e=>e.trim()===`$$`)}function mr(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);P(t,`tableHeaderCell`)&&(s=!0),o.push(_r(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=e.child(a>=0?a:0),s=[];for(let e=0;e<i;e++){let t=e<o.childCount?o.child(e):void 0,n=t?t.attrs.align:void 0;s.push(hr(n))}let c=`| `+s.join(` | `)+` |`,l=a>=0?r[a]:Array(i).fill(``);t.write(gr(l,i)),t.write(`
|
|
20
20
|
`),t.write(c);for(let e=0;e<n;e++)e!==a&&(t.write(`
|
|
21
|
-
`),t.write(
|
|
21
|
+
`),t.write(gr(r[e],i)));t.closeBlock()}function hr(e){switch(e){case`left`:return`:--`;case`center`:return`:-:`;case`right`:return`--:`;default:return`---`}}function gr(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function _r(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
|
|
22
22
|
`)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
|
|
23
|
-
`,` `)}function
|
|
23
|
+
`,` `)}function vr(e,t){let n=t.content,r;try{r=e.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?er(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
|
|
24
24
|
`,`
|
|
25
|
-
`)}function _r(){return m(new y({key:new b(`meowdown-plain-text-copy`),props:{clipboardTextSerializer:(e,t)=>{let n=k(t.state)===`hide`?vr(e):e;return gr(t.state.schema,n)}}}))}function vr(e){return new T(yr(e.content),e.openStart,e.openEnd)}function yr(e){let t=[];return e.forEach(e=>{t.push(e.isTextblock?xr(e):br(e))}),w.from(t)}function br(e){return e.childCount>0?e.copy(yr(e.content)):e}function xr(e){let t=e.type.schema,n=[];for(let r of vn(e)){let e=r.atom;if(e!=null){if(e.type.name===`mdWikilink`){let r=e.attrs,i=r.display||r.target;i&&n.push(t.text(i))}else n.push(...r.children);continue}for(let e of r.children)_n(e.marks)||n.push(e)}return e.copy(w.from(n))}function Sr(){return _(zn(),_r(),qn(),Wn(),Xn())}const L=new Map,Cr=new Map,wr={math:`latex`};async function Tr(e){let t=L.get(e);if(t!==void 0)return t;let n=He.matchLanguageName(Ue,wr[e]??e,!0);if(!n)return L.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),L.set(e,null),null}return L.set(e,r),r}function Er(e,t){let n=Cr.get(e);if(n)return n;let r=Ke({parse:e=>t.language.parser.parse(e.content),highlighter:We});return Cr.set(e,r),r}const Dr=e=>{let t=e.language?.trim();if(!t)return[];let n=L.get(t);return n===null?[]:n?Er(t,n)(e):Tr(t).then(()=>void 0)};function Or(){return fe({parser:Dr,nodeTypes:[`codeBlock`]})}function kr(e,t){let n=t.language.parser.parse(e),r=[];return Ge(n,We,(e,t,n)=>{r.push([e,t,n])}),r}function Ar(e,t){let n=t.trim();if(!n)return[];let r=L.get(n);return r===null?[]:r?kr(e,r):Tr(n).then(t=>t?kr(e,t):[])}function jr(){return f({type:`codeBlock`,attr:`fenceStyle`,default:null,toDOM:e=>e==null?null:[`data-fence-style`,e],parseDOM:e=>{let t=e.getAttribute(`data-fence-style`);return t===`tilde`||t===`indented`||t===`dollar`?t:null}})}function Mr(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=pn(e.getAttribute(`data-fence-length`));return t!=null&&t>3?t:null}})}function Nr(e){return{language:e[1]||``,fenceStyle:`tilde`}}function Pr(){return Xe({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:Nr})}function Fr(){return Je({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:Nr})}function Ir(){return Je({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function Lr(){return _(de(),jr(),Mr(),Pr(),Fr(),Ir())}function Rr(e,t){return(n,r)=>{if(r){let i=S.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function zr(e,t,n){return(r,i)=>{if(i){let a=S.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function Br(e){return(t,n)=>{if(!e.trim())return!1;let r=X(e,{nodes:hc(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&r.child(0).type.name===`paragraph`?new T(r,1,1):new T(r,0,T.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!g(r)||!r.empty)&&e.setSelection(S.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function Vr(e){return(t,n)=>{if(!e)return!1;let r=t.selection.$from;if(r.parent.type.spec.code)return!1;if(n){let i=r.parentOffset,a=i===0?``:r.parent.textBetween(i-1,i),o=a!==``&&!/\s/u.test(a),s=t.tr.insertText(o?` ${e}`:e);Ze(s),n(s.scrollIntoView())}return!0}}function Hr(){return at(oe({type:`paragraph`}),it(),ot)}function Ur(){return(e,t)=>(t&&t(e.tr.scrollIntoView()),!0)}function Wr(){return s({insertMarkdown:Br,insertTrigger:Vr,scrollIntoView:Ur,selectText:Rr,selectTextBetween:zr,turnIntoText:Hr})}const Gr=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(S.near(r.$head))),!0)};function Kr(){return v(l({Escape:Gr}),t.low)}function qr(){return f({type:`doc`,attr:`frontmatter`,default:null})}function Jr(e,t){return t(e.state,e.dispatch,e)}function Yr(e,t){if(t<0||t+1>e.doc.content.size)return;let n=e.doc.resolve(t),r=n.parent.maybeChild(n.index());if(!(r==null||!r.isText))return r.marks}function R(e,t){let n=Yr(e,t);return n!=null&&n.some(e=>mn.has(e.type.name))}function Xr(e,t){if(t<0||t>e.doc.content.size)return!1;let n=e.doc.resolve(t);return n.parent.isTextblock&&!n.parent.type.spec.code}function z(e,t){if(!Xr(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&R(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function B(e,t){if(!Xr(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&R(e,r);)r++;return r>t?{from:t,to:r}:void 0}function Zr(e,t){return R(e,t-1)&&R(e,t)}function Qr(e,t){if(!Zr(e,t))return;let n=z(e,t);if(!n)return;let r=B(e,t);if(r)return{from:n.from,to:r.to}}function $r(e,t,n){let r=Yr(e,t);return r!=null&&n.isInSet(r)}function ei(e,t){let n=Yr(e,t);if(n==null)return;let r=ee(e.schema,`mdPack`),i=n.filter(e=>e.type===r);if(i.length===0)return;let a=e.doc.resolve(t),o=a.start(),s=a.end(),c;for(let n of i){let r=t;for(;r>o&&$r(e,r-1,n);)r--;let i=t+1;for(;i<s&&$r(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function ti(e,t,n){let r=ei(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function ni(e,t,n){let r=ti(e,t,`from`),i=ti(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function ri(e,t,n,r){if(!Xr(e,n))return n;let i=Qr(e,n);if(i!=null)return r?ni(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=z(e,n);if(a!=null&&ti(e,a,`from`))return a.from;let o=B(e,n);return o!=null&&ti(e,o,`to`)?o.to:n}function ii(e,t){if(!Xr(e,t))return;let n=R(e,t-1),r=R(e,t);if(n!==r)return r?`left`:`right`}function ai(e,t){let n=ei(e,t);if(n==null)return[];let r=B(e,n.from),i=z(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const oi=new b(`meowdown-hidden-run-snap`),si=new b(`meowdown-hidden-run-beforeinput`);function ci(){let e=!1;return new y({key:oi,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||k(r)!==`hide`)return null;let i=r.selection;if(!g(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=ri(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(S.create(r.doc,e))}let o=Qr(r,i.from)?.from??i.from,s=Qr(r,i.to)?.to??i.to;if(o===i.from&&s===i.to)return null;let c=i.anchor===i.from?o:s,l=i.head===i.from?o:s;return r.tr.setSelection(S.create(r.doc,c,l))}})}const li=(e,t)=>{if(k(e)!==`hide`)return!1;let n=e.selection;if(!g(n)||!n.empty)return!1;let r=ri(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(S.create(e.doc,r))),!1};function ui(e){return(t,n)=>{if(k(t)!==`hide`)return!1;let r=t.selection;if(!g(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?z(t,r.head):B(t,r.head);if(a==null)return!1;let o=ai(t,e===-1?a.to-1:a.from),s=t.tr;if(o.length===0)s.delete(a.from,a.to);else for(let e of o)s.delete(e.from,e.to);return n?.(s),!0}}const di=ui(-1),fi=ui(1);function pi(){return new y({key:si,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?di:t.inputType===`deleteContentForward`?fi:void 0;return n==null||!Jr(e,n)?!1:(t.preventDefault(),!0)}}}})}function mi(){return _(m(ci()),m(pi()),v(l({Enter:li,Backspace:di,Delete:fi}),t.highest))}function hi(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function gi(){return _(st(),hi())}function _i(){return p({name:`htmlComment`,group:`block`,atom:!0,selectable:!1,attrs:{content:{default:``}},toDOM:e=>[`div`,{"data-html-comment":e.attrs.content,style:`display: none`}],parseDOM:[{tag:`div[data-html-comment]`,getAttrs:e=>({content:e.getAttribute(`data-html-comment`)??``})}]})}function vi(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function yi(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Ie.fromJSON(e,t))]}function bi(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}var xi=class e extends pt{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return mt.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));if(o>=s)continue;let c=Ie.setFrom(a);e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),a=Math.min(s,r+t.nodeSize);if(i>=a)return!1;let l=t.marks;if(bi(l,c))return!1;n??=new ht(e);for(let e of l)n.removeMark(i,a,e);for(let e of c)n.addMark(i,a,e);return!1})}return mt.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Si;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new ft(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(vi)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>yi(t,e)))}};pt.jsonID(`batchSetMark`,xi);const Si=new xi([]),Ci=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),wi=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function Ti(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function Ei(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!Ci.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!wi.test(e))return!1;return!0}function Di(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||Ei(Ti(e)))return`https://${e}`}const Oi=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,ki=/[\s(*_~]/;function Ai(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function ji(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Mi(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&ji(e,t,`)`)>ji(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const Ni={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!Ai(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!ki.test(r))return-1;let i=Oi.exec(e.slice(n,e.end));if(!i)return-1;let a=Mi(i[0]);return a===0||!Ei(Ti(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function Pi(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function Fi(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const Ii={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!Pi(t))break;i||=Fi(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},Li={resolve:`Highlight`,mark:`HighlightMark`},Ri=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,zi={defineNodes:[{name:`Highlight`},{name:`HighlightMark`}],parseInline:[{name:`Highlight`,after:`Emphasis`,parse(e,t,n){if(t!==61||e.char(n+1)!==61||e.char(n+2)===61)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=Ri.test(r),c=Ri.test(i);return e.addDelimiter(Li,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]};function Bi(e){return e>=48&&e<=57}function Vi(e){return e.next!==36||e.text.charCodeAt(e.pos+1)!==36||e.text.charCodeAt(e.pos+2)===36?!1:e.skipSpace(e.pos+2)===e.text.length}function Hi(e){let t=e.depth;return typeof t==`number`?t:2**53-1}const Ui={defineNodes:[{name:`InlineMath`},{name:`InlineMathMark`},{name:`BlockMath`,block:!0},{name:`BlockMathMark`}],parseBlock:[{name:`BlockMath`,before:`FencedCode`,parse(e,t){if(!Vi(t))return!1;let n=e.lineStart+t.pos,r=[e.elt(`BlockMathMark`,n,n+2)];for(let n=!0,i=!0,a=!1;!(!e.nextLine()||Hi(t)<e.depth);n=!1){if(Vi(t)){i&&a&&r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),r.push(e.elt(`BlockMathMark`,e.lineStart+t.pos,e.lineStart+t.pos+2)),e.nextLine();break}a=!0,n||(r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),i=!1);let o=e.lineStart+t.basePos,s=e.lineStart+t.text.length;o<s&&(r.push(e.elt(`CodeText`,o,s)),i=!1)}return e.addElement(e.elt(`BlockMath`,n,e.prevLineEnd(),r)),!0},endLeaf(e,t){return Vi(t)}}],parseInline:[{name:`InlineMath`,after:`InlineCode`,parse(e,t,n){if(t!==36||e.char(n-1)===36)return-1;let r=e.char(n+1)===36?2:1;if(e.char(n+r)===36)return-1;let i=n+r;if(F(e.char(i)))return-1;for(let t=i;t<e.end;t++){let a=e.char(t);if(a===10)return-1;if(a===92){t++;continue}if(a!==36)continue;let o=1;for(;e.char(t+o)===36;)o++;if(o!==r||F(e.char(t-1))||Bi(e.char(t+o)))return-1;let s=t+o;return e.addElement(e.elt(`InlineMath`,n,s,[e.elt(`InlineMathMark`,n,i),e.elt(`InlineMathMark`,t,s)]))}return-1}}]},Wi=/^[a-z][a-z0-9+.-]*:\/\/[^\s<]+/i;function Gi(e){return e>=65&&e<=90||e>=97&&e<=122}const Ki={parseInline:[{name:`SchemeAutolink`,after:`Autolink`,parse(e,t,n){if(!Gi(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!ki.test(r))return-1;let i=Wi.exec(e.slice(n,e.end));if(!i)return-1;let a=Mi(i[0]);return a<=i[0].indexOf(`://`)+3?-1:e.addElement(e.elt(`URL`,n,n+a))}}]},qi={defineNodes:[{name:`WikiEmbed`},{name:`WikiEmbedMark`}],parseInline:[{name:`WikiEmbed`,before:`Link`,parse(e,t,n){if(t!==33||e.char(n+1)!==91||e.char(n+2)!==91)return-1;let r=!1;for(let t=n+3;t<e.end-1;t++){let i=e.char(t);if(i===93){if(!r||e.char(t+1)!==93)return-1;let i=t+2;return e.addElement(e.elt(`WikiEmbed`,n,i,[e.elt(`WikiEmbedMark`,n,n+3),e.elt(`WikiEmbedMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]},Ji={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(!r||e.char(t+1)!==93)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function Yi(e){return e.end}const Xi=_t.configure([gt,Ii,qi,Ji,Ni,Ki,zi,Ui]),Zi=Xi.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:Yi}]});function Qi(e){return Xi.parseInline(e,0)}function $i(e,t,n=[]){for(let r of e)t(r)&&n.push(r),$i(r.children,t,n);return n}function ea(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const V=ea(Xi),ta=/^<!--\s*(\{[^}]*\})\s*-->$/,na=/<!--\s*\{[^}]*\}\s*-->$/;function ra(e){let t=ta.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(!ye(n))return;let r=ia(n);return Object.keys(r).length>0?r:void 0}function ia(e){let t={},{width:n,height:r}=e;return typeof n==`number`&&Number.isFinite(n)&&n>0&&(t.width=Math.round(n)),typeof r==`number`&&Number.isFinite(r)&&r>0&&(t.height=Math.round(r)),t}function aa(e){return`<!-- ${JSON.stringify(e)} -->`}function oa(e){return e.replace(na,``)}const sa=/^(\d+)(?:x(\d+))?$/i;function ca(e){if(!e)return null;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t>0?t:null}function la(e){let t=e.replace(/^!\[\[/,``).replace(/\]\]$/,``),n=t.lastIndexOf(`|`);if(n<0)return{target:t.trim(),display:``,width:null,height:null};let r=t.slice(0,n).trim(),i=t.slice(n+1).trim(),a=sa.exec(i);if(!a)return{target:r,display:i,width:null,height:null};let o=ca(a[1]),s=ca(a[2]);return o==null||a[2]&&s==null?{target:r,display:i,width:null,height:null}:{target:r,display:``,width:o,height:s}}function ua(e,t,n){return`![[${e}|${Math.round(t)}x${Math.round(n)}]]`}function da(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function fa(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function pa(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view md-atom-view`;let r=document.createElement(`span`);r.className=`md-wikilink-view-preview md-atom-view-preview`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,n.appendChild(r);let i=document.createElement(`span`);i.className=`md-wikilink-view-label`,i.contentEditable=`false`,i.textContent=t.display||t.target,r.appendChild(i);let a=document.createElement(`span`);return a.className=`md-wikilink-view-content md-atom-view-content`,n.appendChild(a),{dom:n,contentDOM:a,ignoreMutation:e=>!a.contains(e.target)}}}function ma(){return d({name:`mdWikilink`,constructor:pa()})}const ha=new Map([[V.Emphasis,`mdEm`],[V.StrongEmphasis,`mdStrong`],[V.InlineCode,`mdCode`],[V.Strikethrough,`mdDel`],[V.Highlight,`mdHighlight`],[V.EmphasisMark,`mdMark`],[V.CodeMark,`mdMark`],[V.LinkMark,`mdMark`],[V.StrikethroughMark,`mdMark`],[V.HighlightMark,`mdMark`],[V.URL,`mdLinkUri`],[V.LinkTitle,`mdLinkTitle`],[V.Hashtag,`mdTag`],[V.WikilinkMark,`mdMark`]]);function ga(e,t,n){let r=Qi(t),i=[];return va(r,[],0,t.length,t,e,i,n),i}function _a(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function va(e,t,n,r,i,a,o,s){let c=n;for(let n=0;n<e.length;n++){let r=e[n];r.from>c&&H(o,c,r.from,t);let l=r.type;if(l===V.Link){let e=xa(r,t,i,a,s);e?H(o,r.from,r.to,e):Sa(r,t,i,a,o,s)}else if(l===V.Image){let s=Ca(r,e[n+1],i);wa(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===V.Wikilink)Ea(r,t,i,a,o);else if(l===V.WikiEmbed)Da(r,t,i,a,o,s);else if(l===V.InlineMath)Ta(r,t,i,a,o);else if(l===V.URL){let e=Di(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();H(o,r.from,r.to,[...t,n])}else{let e;l===V.Emphasis?e=`italic`:l===V.StrongEmphasis?e=`bold`:l===V.InlineCode?e=`code`:l===V.Strikethrough?e=`strike`:l===V.Highlight?e=`highlight`:l===V.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=ha.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?H(o,r.from,r.to,u):va(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&H(o,c,r,t)}function ya(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children){let e=o.type;e===V.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):r==null&&e===V.URL?r=o:i==null&&e===V.LinkTitle&&(i=o)}return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function ba(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function xa(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=ya(e);if(o<0||s<0||!c)return;let u=n.slice(c.from,c.to);if(!u)return;let d=n.slice(o,s),f=l?_a(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||ba(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function Sa(e,t,n,r,i,a){let{labelTo:o,urlNode:s,titleNode:c}=ya(e),l=s?n.slice(s.from,s.to):``,u=c?_a(n.slice(c.from,c.to)):``,d=l?r.mdLinkText.create({href:l}):null,f=e=>o>=0&&e<o&&d!==null,p=r.mdPack.create({key:`link`,data:{href:l,title:u}}),m=[...t,p],h=e.from;for(let t of e.children){if(t.from>h){let e=f(h)?[...m,d]:m;H(i,h,t.from,e)}let e=f(t.from)?[...m,d]:m;if(t.type===V.Wikilink){Ea(t,e,n,r,i),h=t.to;continue}if(t.type===V.WikiEmbed){Da(t,e,n,r,i,a),h=t.to;continue}let o=ha.get(t.type),s=o?[...e,r[o].create()]:e;t.children.length===0?H(i,t.from,t.to,s):va(t.children,s,t.from,t.to,n,r,i,a),h=t.to}h<e.to&&H(i,h,e.to,m)}function Ca(e,t,n){if(!t||t.type!==V.Comment||t.from!==e.to)return;let r=ra(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function wa(e,t,n,r,i,a){let o=e.children.find(e=>e.type===V.URL);if(!o){Sa(e,t,n,r,i,void 0);return}let s=e.children.filter(e=>e.type===V.LinkMark),c=e.children.find(e=>e.type===V.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?_a(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;H(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p,syntax:null,wikiTarget:null})])}function Ta(e,t,n,r,i){let a=e.children.filter(e=>e.type===V.InlineMathMark);if(a.length<2){H(i,e.from,e.to,t);return}let o=n.slice(a[0].to,a[1].from),s=[...t,r.mdPack.create({key:`math`}),r.mdMath.create({formula:o})];H(i,e.from,a[0].to,[...s,r.mdMark.create()]),H(i,a[0].to,a[1].from,s),H(i,a[1].from,e.to,[...s,r.mdMark.create()])}function Ea(e,t,n,r,i){let{target:a,display:o}=fa(n.slice(e.from,e.to));H(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function Da(e,t,n,r,i,a){let o=la(n.slice(e.from,e.to)),s=a?.resolveWikiEmbed?.(o);if(!s){H(i,e.from,e.to,t);return}if(s.kind===`image`){let n=s.src??o.target,a=(s.alt??o.display)||da(o.target);H(i,e.from,e.to,[...t,r.mdImage.create({src:n,alt:a,title:``,width:o.width,height:o.height,syntax:`wikiEmbed`,wikiTarget:o.target})]);return}if(s.kind===`file`){let n=s.href??o.target,a=(s.name??o.display)||da(o.target);H(i,e.from,e.to,[...t,r.mdFile.create({href:n,name:a,title:s.title??``})]);return}let c=s.target??o.target,l=s.display??o.display;H(i,e.from,e.to,[...t,r.mdWikilink.create({target:c,display:l})])}function H(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&bi(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const Oa=`inline-marks-applied`;let ka=0,Aa=0;function ja(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function Ma(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?Aa++:(ka++,a=ga(pc(i),n.textContent,e),t.set(n,a)),r===0)return a;let o=[];for(let[e,t,n]of a)o.push([e+r,t+r,n]);return o}function r(e,t){let r=[];return e.doc.nodesBetween(t.from,t.to,(t,i)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let a=n(t,i+1,e.schema);return a.length>0&&r.push(...a),!1}),r}return new y({key:new b(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(Oa))return null;let i=r(n,ja(e,n));if(i.length===0)return null;let a=n.tr.step(new xi(i));return a.setMeta(Oa,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(Na(e.state)),{}}})}function Na(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Pa(e){return m(Ma(e))}function Fa(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null},syntax:{default:null},wikiTarget:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function Ia(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function La(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Ra(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function za(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Ba(){return u({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function Va(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function Ha(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function Ua(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Wa(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function Ga(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Ka(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function qa(){return u({name:`mdFile`,inclusive:!1,attrs:{href:{default:``},name:{default:``},title:{default:``}},toDOM:()=>[`span`,{class:`md-file`},0],parseDOM:[{tag:`span.md-file`}]})}function Ja(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function Ya(){return u({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{},data:{default:null}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function Xa(){return _(Ia(),La(),Ra(),za(),Ba(),Va(),Ha(),Ua(),Wa(),Ga(),Ka(),Fa(),qa(),Ja(),Ya())}const U={em:{node:V.Emphasis,delim:`*`},strong:{node:V.StrongEmphasis,delim:`**`},code:{node:V.InlineCode,delim:"`"},del:{node:V.Strikethrough,delim:`~~`},highlight:{node:V.Highlight,delim:`==`}},Za=new Set([V.EmphasisMark,V.CodeMark,V.LinkMark,V.StrikethroughMark,V.HighlightMark]);function Qa(e){return[e.children[0],e.children.at(-1)]}function $a(e){let{type:t,children:n}=e;if(t===V.Emphasis||t===V.StrongEmphasis||t===V.Strikethrough||t===V.Highlight)return[n[0].to,n.at(-1).from];if(t===V.Link||t===V.Image){let e=n.find((e,t)=>t>0&&e.type===V.LinkMark);return e?[n[0].to,e.from]:null}return null}function eo(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=$a(r);return i&&i[0]<=t&&n<=i[1]?eo(r.children,t,n):eo(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function to(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return to(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function no(e,t,n){for(;t<n&&F(e.charCodeAt(t));)t++;for(;n>t&&F(e.charCodeAt(n-1));)n--;return[t,n]}function ro(e,t,n,r){let i=$i(Qi(e),e=>e.type===r.node||Za.has(e.type));for(let r=t;r<n;r++)if(!F(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function io(e,t,n,r,i){let a=Qi(e),o=$i(a,e=>e.type===r.node);return i?so(e,o,t,n):ao(e,a,o,t,n,r)}function ao(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=eo(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=Qa(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=oo(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function oo(e,t,n,r,i){if(i.node!==V.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(Qn(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function so(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=Qa(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=to(a.children.slice(1,-1),s,c);s>t.to&&F(e.charCodeAt(s-1));)s--;for(;c<o.from&&F(e.charCodeAt(c));)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function co(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=Qi(e),o=$i(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=Qa(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return lo(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function lo(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=$a(n);return!e||t<e[0]||t>e[1]||lo(n.children,t)}return!1}function W(e){return(t,n)=>{if(t.selection.empty)return uo(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=no(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:ro(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>io(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(S.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function uo(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=co(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(S.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(S.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function fo(){return s({toggleEm:()=>W(U.em),toggleStrong:()=>W(U.strong),toggleCode:()=>W(U.code),toggleDel:()=>W(U.del),toggleHighlight:()=>W(U.highlight)})}function po(){return l({"Mod-b":W(U.strong),"Mod-i":W(U.em),"Mod-e":W(U.code),"Mod-Shift-x":W(U.del),"Mod-Shift-h":W(U.highlight)})}function mo(){return _(fo(),po())}function ho(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>e.type.name===n)&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function G(e,t){let n=D(e,t,`mdLinkText`),r=D(e,t,`mdPack`,{key:`link`})??D(e,t,`mdPack`,{key:`autolink`}),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`){let t={from:i.from,to:i.to};return{unit:t,text:a?.key===`autolink`?ho(e,t,`mdLinkText`)??{from:i.from+1,to:i.to-1}:t,href:o,title:``}}let s=ho(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1,u={from:i.from+1,to:c};return{unit:{from:i.from,to:i.to},text:u,label:u,dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function go(e){let t=e.trim();return t?Di(t)??t:``}function _o(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function vo(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!g(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=no(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function yo({href:e,title:t,wrapText:n=!0}={}){return(r,i)=>{let a=vo(r);if(!a)return!1;if(i){let{from:o,to:s}=a,c=r.tr,l=`](${_o(go(e??``),t??``)})`;c.insertText(l,s).insertText(`[`,o);let u=s+1+l.length;c.setSelection(n?S.create(c.doc,o,u):S.create(c.doc,u)),c.scrollIntoView(),i(c)}return!0}}function bo(e){return(t,n)=>{let r=G(t,t.selection.from);if(!r?.dest)return!1;let i=_o(go(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function xo(){return(e,t)=>{let n=G(e,e.selection.from);return n?.label?(t&&t(e.tr.delete(n.label.to,n.unit.to).delete(n.unit.from,n.label.from).scrollIntoView()),!0):!1}}function So(){return s({insertLink:yo,updateLink:bo,removeLink:xo})}function Co(e){return(t,n,r)=>{let i=G(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(S.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=vo(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(S.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function wo(e){return l({"Mod-k":Co(e)})}function To(e){return e===`)`||e===`*`||e===`+`?e:void 0}function Eo(e){return e===`X`?e:void 0}function Do(e){return Ao(e)?String(e):void 0}function Oo(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>{let t=To(e);return t==null?null:[`data-list-marker`,t]},parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function ko(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>{let t=Eo(e);return t==null?null:[`data-list-task-marker`,t]},parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function Ao(e){return e===2||e===3||e===4}function jo(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>{let t=Do(e);return t==null?null:[`data-list-marker-gap`,t]},parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return Ao(t)?t:1}})}function Mo(e){let t=e.attrs;return{...xt(e),"data-list-marker":To(t.marker),"data-list-task-marker":Eo(t.taskMarker),"data-list-marker-gap":Do(t.markerGap)}}function No(){return o({serializeFragmentWrapper:e=>(...t)=>Po(wt(e(...t))),serializeNodeWrapper:e=>(...t)=>{let n=e(...t);return _e(n)?Po(wt(n)):n},nodesFromSchemaWrapper:e=>(...t)=>({...e(...t),list:e=>Tt({node:e,nativeList:!0,getAttributes:Mo})})})}function Po(e){_e(e)&&Fo(e);for(let t of e.children)Po(t);return e}function Fo(e){if(!e.classList.contains(`prosemirror-flat-list`)||e.getAttribute(`data-list-kind`)!==`task`||e.children.length!==2)return;let t=e.children.item(0);if(!t||!t.classList.contains(`list-marker`))return;let n=St(t);if(!n)return;let r=e.children.item(1);if(!r||!r.classList.contains(`list-content`))return;let i=r.children.item(0);!i||![`P`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`].includes(i.tagName)||(e.replaceChildren(...r.children),i.prepend(n))}const Io=[Dt(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),Dt(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),Dt(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),Dt(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function Lo(){return _(Io.map(Ye))}function Ro(){return E({kind:`task`,marker:`+`})}function zo(){return E({kind:`task`,marker:null})}function Bo(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===`list`)return n.attrs}return null}function Vo(){return(e,t,n)=>{let r=Bo(e);return(r?.kind===`task`?r.marker===`+`?zo():Ro():E({kind:`task`,marker:null,checked:!1}))(e,t,n)}}function Ho(){return s({cycleCheckableList:Vo,wrapInCircleTask:Ro,wrapInSquareTask:zo})}function Uo(){return(e,t,n)=>{let r=Bo(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},E(a)(e,t,n)}}function Wo(){return(e,t,n)=>{let r=Bo(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},E(a)(e,t,n)}}function Go(e){return e.type.name===`list`&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const Ko=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:Go(e)?{...t,collapsed:!t.collapsed}:t};function qo(){return m(()=>[new y({props:{handleDOMEvents:{mousedown:(e,t)=>Ct({view:e,event:t,onListClick:Ko})}}}),vt(),new y({props:{transformCopied:Et}}),yt()])}function Jo(){return s({toggleListCollapsed:()=>bt({isToggleable:Go})})}function Yo(){return l({"Mod-Enter":Uo(),"Mod-Shift-Enter":Wo(),"Mod-.":bt({isToggleable:Go}),"Mod-Shift-7":rt({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":rt({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":rt({kind:`task`,checked:!1,collapsed:!1})})}function Xo(){return _(tt(),qo(),et(),Qe(),No(),$e(),Lo(),Yo(),Oo(),ko(),jo(),Ho(),Jo())}let Zo;function Qo(){return Zo??=import(`katex`).then(e=>e.render),Zo}function $o(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var es=class{#e;#t;#n;#r;constructor(e,t){this.#r=e.attrs.formula,this.#e=document.createElement(`span`),this.#e.className=`md-math-view`,this.#n=document.createElement(`span`),this.#n.className=`md-math-view-preview`,this.#n.dataset.testid=`math-preview`,this.#n.contentEditable=`false`,this.#n.addEventListener(`mousedown`,e=>{e.preventDefault();let n=t.posAtDOM(this.#t,0);if(n<0)return;let r=S.near(t.state.doc.resolve(n),1);t.dispatch(t.state.tr.setSelection(r)),t.focus()}),this.#t=document.createElement(`span`),this.#t.className=`md-math-view-content`,this.#e.appendChild(this.#n),this.#e.appendChild(this.#t),this.#i()}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs.formula;return t!==this.#r&&(this.#r=t,this.#i()),!0}ignoreMutation(e){return!this.#t.contains(e.target)}#i(){let e=this.#r;Qo().then(t=>{e===this.#r&&$o(t,this.#n,e,!1)})}};function ts(){return d({name:`mdMath`,constructor:(e,t)=>new es(e,t)})}function ns(e){return e===`left`||e===`center`||e===`right`?e:null}function rs(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>ns(e.getAttribute(`data-align`))})}function is(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>ns(e.getAttribute(`data-align`))})}function as(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(n.child(e).type.name===`tableHeaderCell`)return t}return 0}function os(e){return e.child(as(e))}function ss(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function cs(e,t,n){if(e.childCount===0)return;let r=os(e),i=t+1;for(let t=0;t<e.childCount;t++){let a=e.child(t),o=i+1;for(let e=0;e<a.childCount;e++){let t=a.child(e),i=ss(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function ls(e){let t,n;for(let r of e){if(!r.docChanged)continue;t!=null&&n!=null&&(t=r.mapping.map(t,-1),n=r.mapping.map(n,1));let e=r.mapping;for(let[r,i]of e.maps.entries()){let a=e.slice(r+1);i.forEach((e,r,i,o)=>{let s=a.map(i,-1),c=a.map(o,1);t=t==null?s:Math.min(t,s),n=n==null?c:Math.max(n,c)})}}if(!(t==null||n==null))return{from:t,to:n}}function us(){return new y({key:new b(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=ls(e);if(!r)return;let i=n.doc,a=Math.max(0,Math.min(r.from,i.content.size)),o=Math.max(a,Math.min(r.to,i.content.size)),s;return i.nodesBetween(a,o,(e,t)=>e.type.name===`table`?(s??=n.tr,cs(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function ds(){return m(us())}function fs(e){let{selection:t}=e;if(It(t)){let{$anchorCell:e,$headCell:n}=t,r=e.depth-1,i=e.index(),a=n.index();return{table:e.node(r),tablePos:e.before(r),firstColumn:Math.min(i,a),lastColumn:Math.max(i,a)}}let{$from:n}=t;for(let e=n.depth;e>2;e--){let t=n.node(e).type.name;if(t===`tableCell`||t===`tableHeaderCell`){let t=n.index(e-1);return{table:n.node(e-2),tablePos:n.before(e-2),firstColumn:t,lastColumn:t}}}}function ps(e){return(t,n)=>{let r=fs(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=as(i),l=a+1;for(let e=0;e<c;e++)l+=i.child(e).nodeSize;let u=i.child(c),d=t.tr,f=l+1;for(let t=0;t<u.childCount;t++){let n=u.child(t);t>=o&&t<=s&&(n.attrs.align??null)!==e&&d.setNodeMarkup(f,void 0,{...n.attrs,align:e}),f+=n.nodeSize}n(d)}return!0}}function ms(e){let t=fs(e);if(!(!t||t.table.childCount===0))return ss(os(t.table),t.lastColumn)??void 0}function hs(){return s({setTableColumnAlign:ps})}function gs(){return _(rs(),is(),ds(),hs())}function _s(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e).type.name;if(n===`tableCell`||n===`tableHeaderCell`)return!0}return!1}const vs=`paragraph`;function ys(){return _(p({name:`tableCell`,content:vs}),p({name:`tableHeaderCell`,content:vs}))}const bs=(e,t)=>{let{selection:n}=e;return!It(n)||!n.isColSelection()||!n.isRowSelection()?!1:Ft(e,t)};function xs(){return v(l({Backspace:bs,Delete:bs}),t.high)}function Ss(){return _(Pt(),Nt(),Ot(),Mt(),ys(),gs(),jt({allowTableNodeSelection:!0}),kt(),At(),xs())}function Cs(e){let{selection:t}=e,{$from:n,$to:r}=t;if(ae(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function ws(e){return(t,n)=>{if(_s(t))return!1;let r=Cs(t);if(r==null)return!1;let i=r+e;if(i<0||i>=t.doc.childCount)return!1;if(n){let{selection:a}=t,o=Math.min(r,i),s=a.$from.posAtIndex(o,0),c=t.doc.child(o),l=t.doc.child(o+1),u=t.tr.replaceWith(s,s+c.nodeSize+l.nodeSize,[l,c]),d=e===-1?-c.nodeSize:l.nodeSize,f=ae(a)?De.create(u.doc,a.from+d):S.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function Ts(e){return(t,n,r)=>nt(e)(t,n,r)||ws(e===`up`?-1:1)(t,n,r)}function Es(){return l({"Alt-ArrowUp":Ts(`up`),"Alt-ArrowDown":Ts(`down`)})}const K=new b(`meowdownPendingReplacement`);function q(e){return K.getState(e)?.pending??null}function Ds(e,t){switch(e.type){case`start`:return{pending:{from:e.from,to:e.to,mode:e.mode,text:``}};case`append`:return t.pending?{pending:{...t.pending,text:t.pending.text+e.text}}:t;case`accept`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`accepted`}}:t;case`discard`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:t}}const Os=new y({key:K,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(K);if(n)return Ds(n,t);if(e.docChanged&&t.pending){let n=e.mapping.mapResult(t.pending.from,1),r=e.mapping.mapResult(t.pending.to,-1),i=Math.min(n.pos,r.pos),a=Math.max(n.pos,r.pos);return(n.deletedAfter&&r.deletedBefore||i>=a)&&t.pending.mode===`replace`?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:{pending:{...t.pending,from:i,to:a}}}return t}},props:{decorations:e=>{let t=q(e);return!t||t.from>=t.to?null:C.create(e.doc,[Oe.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function ks(e){return(t,n)=>{let{from:r,to:i,mode:a}=e;return r<0||i>t.doc.content.size||r>i||r===i&&a===`replace`?!1:(n?.(t.tr.setMeta(K,{type:`start`,from:r,to:i,mode:a})),!0)}}function As(e){return(t,n)=>q(t)?(n?.(t.tr.setMeta(K,{type:`append`,text:e})),!0):!1}function js(){return(e,t)=>q(e)?(t?.(e.tr.setMeta(K,{type:`discard`})),!0):!1}function Ms(e={}){return(t,n)=>{let r=q(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=hc(t.schema),o=X(r.text,{nodes:a}),s=t.tr;if(s.setMeta(K,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(S.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i?.type.name===`paragraph`&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(S.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new T(o.content,0,0)),s.setSelection(S.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function Ns(){return s({startPendingReplacement:ks,appendPendingReplacementText:As,acceptPendingReplacement:Ms,discardPendingReplacement:js})}function Ps(){return l({"Mod-Enter":Ms(),Escape:js()})}function Fs(){return _(m(Os),Ns(),Ps())}function Is(e){return m(new y({view:()=>({update:(t,n)=>{let r=K.getState(n),i=K.getState(t.state);!i||r===i||(i.pending?i.pending!==r?.pending&&e({type:`update`,pending:i.pending}):i.ended&&i.ended!==r?.ended&&e({type:`ended`,pending:i.ended.pending,outcome:i.ended.outcome}))}})}))}function Ls(e){return e.left===e.right&&e.top===e.bottom}function J(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return Ls(r)?void 0:r}function Rs(e){let t=e.dom.ownerDocument.getSelection();if(t==null||t.rangeCount===0||!e.dom.contains(t.anchorNode))return;let n=t.getRangeAt(0).cloneRange();n.collapse(!0);let r=Array.from(n.getClientRects()).filter(e=>e.height>0);if(r.length===0)return;let i=r[r.length-1];return{left:i.left,top:i.top,height:i.height}}function zs(e){let t=e.state,n=t.selection.head,r=z(t,n),i=B(t,n),a=r==null,o=[[n,a],[n,!a]];r!=null&&o.push([r.from,!0]),i!=null&&o.push([i.to,!1]);for(let[t,n]of o){let r=J(e,t,n?-1:1);if(r!=null&&r.bottom>r.top)return{left:r.left,top:r.top,height:r.bottom-r.top}}}function Bs(e){let t=e.state,n=t.selection.head;for(let r of Jt){let i=D(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=Hs(e,i.from+1);if(a==null)continue;let o=Array.from(a.getClientRects()).filter(e=>e.height>0);if(o.length===0)continue;let s=i.to===n,c=s?o[o.length-1]:o[0];return{left:s?c.right:c.left,top:c.top,height:c.height}}}function Vs(e,t,n){let r=e.state;for(let i of Jt){let a=D(r,t,i);if(a==null)continue;let o=Hs(e,a.from+1);if(o==null)continue;let s=Array.from(o.getClientRects()).filter(e=>e.height>0);if(s.length!==0)return n===1?s[0]:s[s.length-1]}}function Hs(e,t){let{node:n}=e.domAtPos(t,0);return(n instanceof Element?n:n.parentElement)?.closest(`.md-atom-view`)?.querySelector(`.md-atom-view-preview`)??void 0}function Us(e){return zs(e)??Bs(e)}const Ws=new b(`meowdown-scroll-to-selection`);function Gs(e){let t=e.state.selection;if(!g(t)||J(e,t.head,1)!=null)return!1;let n=Us(e);if(n==null)return!1;let r=e.domAtPos(t.head).node;return Ys(e,{left:n.left,right:n.left,top:n.top,bottom:n.top+n.height},r),!0}function Y(e,t){return typeof e==`number`?e:e[t]}function Ks(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11?t.host:t}function qs(e){let t=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 Js(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 Ys(e,t,n){let r=e.someProp(`scrollThreshold`)??0,i=e.someProp(`scrollMargin`)??5,a=e.dom.ownerDocument;for(let e=n;e;){if(e.nodeType!==1){e=Ks(e);continue}let n=e,o=n===a.body,s=o?qs(a):Js(n),c=0,l=0;if(t.top<s.top+Y(r,`top`)?l=-(s.top-t.top+Y(i,`top`)):t.bottom>s.bottom-Y(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+Y(i,`top`)-s.top:t.bottom-s.bottom+Y(i,`bottom`)),t.left<s.left+Y(r,`left`)?c=-(s.left-t.left+Y(i,`left`)):t.right>s.right-Y(r,`right`)&&(c=t.right-s.right+Y(i,`right`)),c||l)if(o)a.defaultView?.scrollBy(c,l);else{let e=n.scrollLeft,r=n.scrollTop;l&&(n.scrollTop+=l),c&&(n.scrollLeft+=c);let i=n.scrollLeft-e,a=n.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=o?`fixed`:getComputedStyle(n).position;if(/^(?:fixed|sticky)$/.test(u))break;e=u===`absolute`?n.offsetParent:Ks(n)}}function Xs(){return m(new y({key:Ws,props:{handleScrollToSelection:Gs}}))}function Zs(e,t){return(n,r)=>{let i=e<0?x.atStart(n.doc):x.atEnd(n.doc),a=t?S.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function Qs(){return l({"Meta-ArrowUp":Zs(-1,!1),"Meta-ArrowDown":Zs(1,!1),"Shift-Meta-ArrowUp":Zs(-1,!0),"Shift-Meta-ArrowDown":Zs(1,!0)})}function $s(e){e.offsetWidth}const ec=new b(`meowdown-virtual-caret`),tc=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`];function nc(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function rc(e){let t=Rs(e)??zs(e);return t==null?Bs(e):nc(t)}function ic(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var ac=class{#e;#t;#n;#r;#i;#a;#o;#s=0;constructor(e){this.#e=e,this.#r=e.dom.ownerDocument,this.#t=this.#r.createElement(`div`),this.#t.className=`md-virtual-caret-layer`,this.#n=this.#t.appendChild(this.#r.createElement(`div`)),this.#n.className=`md-virtual-caret`,this.#n.dataset.testid=`virtual-caret`,e.dom.insertAdjacentElement(`afterend`,this.#t),this.#r.addEventListener(`selectionchange`,this.#l),typeof ResizeObserver<`u`&&(this.#i=new ResizeObserver(this.#l),this.#i.observe(e.dom)),this.#l()}update(e,t){e.state.selection.eq(t.selection)||this.#c(),this.#l()}destroy(){this.#r.removeEventListener(`selectionchange`,this.#l),this.#i?.disconnect(),this.#t.remove()}#c(){this.#s=1-this.#s,this.#n.style.animationName=tc[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=g(n)&&n.empty?rc(e):void 0,i=r!=null&&k(t)===`hide`?ii(t,n.head):void 0;if(ic(r,this.#a)&&i===this.#o)return;let a=this.#a==null;if(this.#a=r,this.#o=i,i==null?delete this.#n.dataset.tail:this.#n.dataset.tail=i,r==null){this.#n.style.visibility=`hidden`;return}let o=this.#t.getBoundingClientRect();a&&(this.#n.style.transitionProperty=`none`),this.#n.style.visibility=``,this.#n.style.left=`${r.left-o.left}px`,this.#n.style.top=`${r.top-o.top}px`,this.#n.style.height=`${r.height}px`,a&&($s(this.#n),this.#n.style.transitionProperty=``)}};function oc(){return m(new y({key:ec,view:e=>new ac(e)}))}function sc(e){return _(Ln(),Se(),qr(),Te(),xe(),Xo(),Nn(),Ss(),Lr(),gi(),_i(),Xa(),Or(),Kr(),Es(),Qs(),Pa(e),mo(),So(),ma(),ts(),Wt(e.markMode??`focus`),Sr(),oc(),Xs(),mi(),sn({marks:Jt.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),Ce(),Ee(),we(),Wr(),Fs())}function cc(e={}){return sc(e)}const lc=be(()=>{let e=cc().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),uc=be(()=>r(lc())),dc=be(()=>n(lc())),fc=`meowdown_mark_builders`;function pc(e){let t=e.cached[fc];if(t)return t;let r=n(e);return e.cached[fc]=r,r}const mc=`meowdown_node_builders`;function hc(e){let t=e.cached[mc];if(t)return t;let n=r(e);return e.cached[mc]=n,n}function X(e,t={}){let{nodes:n=uc(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=_c(e);i=t,n&&(a=e.slice(n))}let o=vc(n,Zi.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const gc=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function _c(e){let t=gc.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function vc(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&yc(r,e,n,i,t.from),i=t.to,r.push(...bc(e,t,n));while(t.nextSibling());return t.parent(),r}function yc(e,t,n,r,i){let a=0;for(let e=r;e<i;e++)n.charCodeAt(e)===10&&a++;for(let n=2;n<a;n++)e.push(t.paragraph())}function bc(e,t,n){switch(t.type.id){case V.ATXHeading1:return[Z(e,t,n,1,!1)];case V.ATXHeading2:return[Z(e,t,n,2,!1)];case V.ATXHeading3:return[Z(e,t,n,3,!1)];case V.ATXHeading4:return[Z(e,t,n,4,!1)];case V.ATXHeading5:return[Z(e,t,n,5,!1)];case V.ATXHeading6:return[Z(e,t,n,6,!1)];case V.SetextHeading1:return[Z(e,t,n,1,!0)];case V.SetextHeading2:return[Z(e,t,n,2,!0)];case V.Paragraph:return[Ec(e,t,n)];case V.CommentBlock:return[Dc(e,t,n)];case V.HTMLBlock:case V.ProcessingInstructionBlock:return[Ec(e,t,n)];case V.Blockquote:return[Oc(e,t,n)];case V.BulletList:return kc(e,t,n,`bullet`);case V.OrderedList:return kc(e,t,n,`ordered`);case V.FencedCode:case V.CodeBlock:return[jc(e,t,n)];case V.BlockMath:return[Mc(e,t,n)];case V.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case V.Table:return[Nc(e,t,n)];case V.Task:return[Ec(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[Ec(e,t,n)])}}function Z(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===V.HeaderMark&&t.from===a&&(o=t.to);let e=-1,n=-1,r=-1;do e=t.type.id,n=t.from,r=t.to;while(t.nextSibling());e===V.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=wc(n.slice(o,s),Q(n,o)).trim(),d=i?xc(n,c,l)||1:null,f=!i&&c>=0&&Sc(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function xc(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++){let t=e.charCodeAt(i);(t===61||t===45)&&r++}return r}function Sc(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++)e.charCodeAt(i)===35&&r++;return r}function Q(e,t){let n=e.lastIndexOf(`
|
|
26
|
-
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function
|
|
25
|
+
`)}function yr(){return m(new y({key:new b(`meowdown-plain-text-copy`),props:{clipboardTextSerializer:(e,t)=>{let n=A(t.state)===`hide`?br(e):e;return vr(t.state.schema,n)}}}))}function br(e){return new T(xr(e.content),e.openStart,e.openEnd)}function xr(e){let t=[];return e.forEach(e=>{t.push(e.isTextblock?Cr(e):Sr(e))}),w.from(t)}function Sr(e){return e.childCount>0?e.copy(xr(e.content)):e}function Cr(e){let t=e.type.schema,n=[];for(let r of yn(e)){let e=r.atom;if(e!=null){if(mn(e,`mdWikilink`)){let r=e.attrs,i=r.display||r.target;i&&n.push(t.text(i))}else n.push(...r.children);continue}for(let e of r.children)vn(e.marks)||n.push(e)}return e.copy(w.from(n))}function wr(){return _(Bn(),yr(),Jn(),Gn(),Zn())}const L=new Map,Tr=new Map,Er={math:`latex`};async function Dr(e){let t=L.get(e);if(t!==void 0)return t;let n=He.matchLanguageName(Ue,Er[e]??e,!0);if(!n)return L.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),L.set(e,null),null}return L.set(e,r),r}function Or(e,t){let n=Tr.get(e);if(n)return n;let r=Ke({parse:e=>t.language.parser.parse(e.content),highlighter:We});return Tr.set(e,r),r}const kr=e=>{let t=e.language?.trim();if(!t)return[];let n=L.get(t);return n===null?[]:n?Or(t,n)(e):Dr(t).then(()=>void 0)};function Ar(){return fe({parser:kr,nodeTypes:[`codeBlock`]})}function jr(e,t){let n=t.language.parser.parse(e),r=[];return Ge(n,We,(e,t,n)=>{r.push([e,t,n])}),r}function Mr(e,t){let n=t.trim();if(!n)return[];let r=L.get(n);return r===null?[]:r?jr(e,r):Dr(n).then(t=>t?jr(e,t):[])}function Nr(){return f({type:`codeBlock`,attr:`fenceStyle`,default:null,toDOM:e=>e==null?null:[`data-fence-style`,e],parseDOM:e=>{let t=e.getAttribute(`data-fence-style`);return t===`tilde`||t===`indented`||t===`dollar`?t:null}})}function Pr(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=fn(e.getAttribute(`data-fence-length`));return t!=null&&t>3?t:null}})}function Fr(e){return{language:e[1]||``,fenceStyle:`tilde`}}function Ir(){return Xe({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:Fr})}function Lr(){return Je({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:Fr})}function Rr(){return Je({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function zr(){return _(de(),Nr(),Pr(),Ir(),Lr(),Rr())}function Br(e,t){return(n,r)=>{if(r){let i=x.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function Vr(e,t,n){return(r,i)=>{if(i){let a=x.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function Hr(e){return(t,n)=>{if(!e.trim())return!1;let r=X(e,{nodes:_c(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&P(r.child(0),`paragraph`)?new T(r,1,1):new T(r,0,T.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!g(r)||!r.empty)&&e.setSelection(x.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function Ur(e){return(t,n)=>{if(!e)return!1;let r=t.selection.$from;if(r.parent.type.spec.code)return!1;if(n){let i=r.parentOffset,a=i===0?``:r.parent.textBetween(i-1,i),o=a!==``&&!/\s/u.test(a),s=t.tr.insertText(o?` ${e}`:e);Ze(s),n(s.scrollIntoView())}return!0}}function Wr(){return at(oe({type:`paragraph`}),it(),ot)}function Gr(){return(e,t)=>(t&&t(e.tr.scrollIntoView()),!0)}function Kr(){return s({insertMarkdown:Hr,insertTrigger:Ur,scrollIntoView:Gr,selectText:Br,selectTextBetween:Vr,turnIntoText:Wr})}const qr=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(x.near(r.$head))),!0)};function Jr(){return v(l({Escape:qr}),t.low)}function Yr(){return f({type:`doc`,attr:`frontmatter`,default:null})}function Xr(e,t){return t(e.state,e.dispatch,e)}function Zr(e,t){if(t<0||t+1>e.doc.content.size)return;let n=e.doc.resolve(t),r=n.parent.maybeChild(n.index());if(!(r==null||!r.isText))return r.marks}function R(e,t){let n=Zr(e,t);return n!=null&&n.some(e=>hn.has(e.type.name))}function Qr(e,t){if(t<0||t>e.doc.content.size)return!1;let n=e.doc.resolve(t);return n.parent.isTextblock&&!n.parent.type.spec.code}function z(e,t){if(!Qr(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&R(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function B(e,t){if(!Qr(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&R(e,r);)r++;return r>t?{from:t,to:r}:void 0}function $r(e,t){return R(e,t-1)&&R(e,t)}function ei(e,t){if(!$r(e,t))return;let n=z(e,t);if(!n)return;let r=B(e,t);if(r)return{from:n.from,to:r.to}}function ti(e,t,n){let r=Zr(e,t);return r!=null&&n.isInSet(r)}function ni(e,t){let n=Zr(e,t);if(n==null)return;let r=ee(e.schema,`mdPack`),i=n.filter(e=>e.type===r);if(i.length===0)return;let a=e.doc.resolve(t),o=a.start(),s=a.end(),c;for(let n of i){let r=t;for(;r>o&&ti(e,r-1,n);)r--;let i=t+1;for(;i<s&&ti(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function ri(e,t,n){let r=ni(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function ii(e,t,n){let r=ri(e,t,`from`),i=ri(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function ai(e,t,n,r){if(!Qr(e,n))return n;let i=ei(e,n);if(i!=null)return r?ii(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=z(e,n);if(a!=null&&ri(e,a,`from`))return a.from;let o=B(e,n);return o!=null&&ri(e,o,`to`)?o.to:n}function oi(e,t){if(!Qr(e,t))return;let n=R(e,t-1),r=R(e,t);if(n!==r)return r?`left`:`right`}function si(e,t){let n=ni(e,t);if(n==null)return[];let r=B(e,n.from),i=z(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const ci=new b(`meowdown-hidden-run-snap`),li=new b(`meowdown-hidden-run-beforeinput`);function ui(){let e=!1;return new y({key:ci,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||A(r)!==`hide`)return null;let i=r.selection;if(!g(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=ai(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(x.create(r.doc,e))}let o=ei(r,i.from)?.from??i.from,s=ei(r,i.to)?.to??i.to;if(o===i.from&&s===i.to)return null;let c=i.anchor===i.from?o:s,l=i.head===i.from?o:s;return r.tr.setSelection(x.create(r.doc,c,l))}})}const di=(e,t)=>{if(A(e)!==`hide`)return!1;let n=e.selection;if(!g(n)||!n.empty)return!1;let r=ai(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(x.create(e.doc,r))),!1};function fi(e){return(t,n)=>{if(A(t)!==`hide`)return!1;let r=t.selection;if(!g(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?z(t,r.head):B(t,r.head);if(a==null)return!1;let o=si(t,e===-1?a.to-1:a.from),s=t.tr;if(o.length===0)s.delete(a.from,a.to);else for(let e of o)s.delete(e.from,e.to);return n?.(s),!0}}const pi=fi(-1),mi=fi(1);function hi(){return new y({key:li,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?pi:t.inputType===`deleteContentForward`?mi:void 0;return n==null||!Xr(e,n)?!1:(t.preventDefault(),!0)}}}})}function gi(){return _(m(ui()),m(hi()),v(l({Enter:di,Backspace:pi,Delete:mi}),t.highest))}function _i(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function vi(){return _(st(),_i())}function yi(){return p({name:`htmlComment`,group:`block`,atom:!0,selectable:!1,attrs:{content:{default:``}},toDOM:e=>[`div`,{"data-html-comment":e.attrs.content,style:`display: none`}],parseDOM:[{tag:`div[data-html-comment]`,getAttrs:e=>({content:e.getAttribute(`data-html-comment`)??``})}]})}function bi(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function xi(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Ie.fromJSON(e,t))]}function Si(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}var Ci=class e extends pt{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return mt.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));if(o>=s)continue;let c=Ie.setFrom(a);e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),a=Math.min(s,r+t.nodeSize);if(i>=a)return!1;let l=t.marks;if(Si(l,c))return!1;n??=new ht(e);for(let e of l)n.removeMark(i,a,e);for(let e of c)n.addMark(i,a,e);return!1})}return mt.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return wi;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new ft(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(bi)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>xi(t,e)))}};pt.jsonID(`batchSetMark`,Ci);const wi=new Ci([]),Ti=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),Ei=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function Di(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function Oi(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!Ti.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!Ei.test(e))return!1;return!0}function ki(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||Oi(Di(e)))return`https://${e}`}const Ai=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,ji=/[\s(*_~]/;function Mi(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function Ni(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Pi(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&Ni(e,t,`)`)>Ni(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const Fi={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!Mi(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!ji.test(r))return-1;let i=Ai.exec(e.slice(n,e.end));if(!i)return-1;let a=Pi(i[0]);return a===0||!Oi(Di(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function Ii(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function Li(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const Ri={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!Ii(t))break;i||=Li(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},zi={resolve:`Highlight`,mark:`HighlightMark`},Bi=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,Vi={defineNodes:[{name:`Highlight`},{name:`HighlightMark`}],parseInline:[{name:`Highlight`,after:`Emphasis`,parse(e,t,n){if(t!==61||e.char(n+1)!==61||e.char(n+2)===61)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=Bi.test(r),c=Bi.test(i);return e.addDelimiter(zi,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]};function Hi(e){return e>=48&&e<=57}function Ui(e){return e.next!==36||e.text.charCodeAt(e.pos+1)!==36||e.text.charCodeAt(e.pos+2)===36?!1:e.skipSpace(e.pos+2)===e.text.length}function Wi(e){let t=e.depth;return typeof t==`number`?t:2**53-1}const Gi={defineNodes:[{name:`InlineMath`},{name:`InlineMathMark`},{name:`BlockMath`,block:!0},{name:`BlockMathMark`}],parseBlock:[{name:`BlockMath`,before:`FencedCode`,parse(e,t){if(!Ui(t))return!1;let n=e.lineStart+t.pos,r=[e.elt(`BlockMathMark`,n,n+2)];for(let n=!0,i=!0,a=!1;!(!e.nextLine()||Wi(t)<e.depth);n=!1){if(Ui(t)){i&&a&&r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),r.push(e.elt(`BlockMathMark`,e.lineStart+t.pos,e.lineStart+t.pos+2)),e.nextLine();break}a=!0,n||(r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),i=!1);let o=e.lineStart+t.basePos,s=e.lineStart+t.text.length;o<s&&(r.push(e.elt(`CodeText`,o,s)),i=!1)}return e.addElement(e.elt(`BlockMath`,n,e.prevLineEnd(),r)),!0},endLeaf(e,t){return Ui(t)}}],parseInline:[{name:`InlineMath`,after:`InlineCode`,parse(e,t,n){if(t!==36||e.char(n-1)===36)return-1;let r=e.char(n+1)===36?2:1;if(e.char(n+r)===36)return-1;let i=n+r;if(I(e.char(i)))return-1;for(let t=i;t<e.end;t++){let a=e.char(t);if(a===10)return-1;if(a===92){t++;continue}if(a!==36)continue;let o=1;for(;e.char(t+o)===36;)o++;if(o!==r||I(e.char(t-1))||Hi(e.char(t+o)))return-1;let s=t+o;return e.addElement(e.elt(`InlineMath`,n,s,[e.elt(`InlineMathMark`,n,i),e.elt(`InlineMathMark`,t,s)]))}return-1}}]},Ki=/^[a-z][a-z0-9+.-]*:\/\/[^\s<]+/i;function qi(e){return e>=65&&e<=90||e>=97&&e<=122}const Ji={parseInline:[{name:`SchemeAutolink`,after:`Autolink`,parse(e,t,n){if(!qi(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!ji.test(r))return-1;let i=Ki.exec(e.slice(n,e.end));if(!i)return-1;let a=Pi(i[0]);return a<=i[0].indexOf(`://`)+3?-1:e.addElement(e.elt(`URL`,n,n+a))}}]},Yi={defineNodes:[{name:`WikiEmbed`},{name:`WikiEmbedMark`}],parseInline:[{name:`WikiEmbed`,before:`Link`,parse(e,t,n){if(t!==33||e.char(n+1)!==91||e.char(n+2)!==91)return-1;let r=!1;for(let t=n+3;t<e.end-1;t++){let i=e.char(t);if(i===93){if(!r||e.char(t+1)!==93)return-1;let i=t+2;return e.addElement(e.elt(`WikiEmbed`,n,i,[e.elt(`WikiEmbedMark`,n,n+3),e.elt(`WikiEmbedMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]},Xi={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(!r||e.char(t+1)!==93)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function Zi(e){return e.end}const Qi=_t.configure([gt,Ri,Yi,Xi,Fi,Ji,Vi,Gi]),$i=Qi.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:Zi}]});function ea(e){return Qi.parseInline(e,0)}function ta(e,t,n=[]){for(let r of e)t(r)&&n.push(r),ta(r.children,t,n);return n}function na(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const V=na(Qi),ra=/^<!--\s*(\{[^}]*\})\s*-->$/,ia=/<!--\s*\{[^}]*\}\s*-->$/;function aa(e){let t=ra.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(!ye(n))return;let r=oa(n);return Object.keys(r).length>0?r:void 0}function oa(e){let t={},{width:n,height:r}=e;return typeof n==`number`&&Number.isFinite(n)&&n>0&&(t.width=Math.round(n)),typeof r==`number`&&Number.isFinite(r)&&r>0&&(t.height=Math.round(r)),t}function sa(e){return`<!-- ${JSON.stringify(e)} -->`}function ca(e){return e.replace(ia,``)}const la=/^(\d+)(?:x(\d+))?$/i;function ua(e){if(!e)return null;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t>0?t:null}function da(e){let t=e.replace(/^!\[\[/,``).replace(/\]\]$/,``),n=t.lastIndexOf(`|`);if(n<0)return{target:t.trim(),display:``,width:null,height:null};let r=t.slice(0,n).trim(),i=t.slice(n+1).trim(),a=la.exec(i);if(!a)return{target:r,display:i,width:null,height:null};let o=ua(a[1]),s=ua(a[2]);return o==null||a[2]&&s==null?{target:r,display:i,width:null,height:null}:{target:r,display:``,width:o,height:s}}function fa(e,t,n){return`![[${e}|${Math.round(t)}x${Math.round(n)}]]`}function pa(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function ma(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function ha(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view md-atom-view`;let r=document.createElement(`span`);r.className=`md-wikilink-view-preview md-atom-view-preview`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,n.appendChild(r);let i=document.createElement(`span`);i.className=`md-wikilink-view-label`,i.contentEditable=`false`,i.textContent=t.display||t.target,r.appendChild(i);let a=document.createElement(`span`);return a.className=`md-wikilink-view-content md-atom-view-content`,n.appendChild(a),{dom:n,contentDOM:a,ignoreMutation:e=>!a.contains(e.target)}}}function ga(){return d({name:`mdWikilink`,constructor:ha()})}const _a=new Map([[V.Emphasis,`mdEm`],[V.StrongEmphasis,`mdStrong`],[V.InlineCode,`mdCode`],[V.Strikethrough,`mdDel`],[V.Highlight,`mdHighlight`],[V.EmphasisMark,`mdMark`],[V.CodeMark,`mdMark`],[V.LinkMark,`mdMark`],[V.StrikethroughMark,`mdMark`],[V.HighlightMark,`mdMark`],[V.URL,`mdLinkUri`],[V.LinkTitle,`mdLinkTitle`],[V.Hashtag,`mdTag`],[V.WikilinkMark,`mdMark`]]);function va(e,t,n){let r=ea(t),i=[];return ba(r,[],0,t.length,t,e,i,n),i}function ya(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function ba(e,t,n,r,i,a,o,s){let c=n;for(let n=0;n<e.length;n++){let r=e[n];r.from>c&&H(o,c,r.from,t);let l=r.type;if(l===V.Link){let e=Ca(r,t,i,a,s);e?H(o,r.from,r.to,e):wa(r,t,i,a,o,s)}else if(l===V.Image){let s=Ta(r,e[n+1],i);Ea(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===V.Wikilink)Oa(r,t,i,a,o);else if(l===V.WikiEmbed)ka(r,t,i,a,o,s);else if(l===V.InlineMath)Da(r,t,i,a,o);else if(l===V.URL){let e=ki(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();H(o,r.from,r.to,[...t,n])}else{let e;l===V.Emphasis?e=`italic`:l===V.StrongEmphasis?e=`bold`:l===V.InlineCode?e=`code`:l===V.Strikethrough?e=`strike`:l===V.Highlight?e=`highlight`:l===V.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=_a.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?H(o,r.from,r.to,u):ba(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&H(o,c,r,t)}function xa(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children){let e=o.type;e===V.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):r==null&&e===V.URL?r=o:i==null&&e===V.LinkTitle&&(i=o)}return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function Sa(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Ca(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=xa(e);if(o<0||s<0||!c)return;let u=n.slice(c.from,c.to);if(!u)return;let d=n.slice(o,s),f=l?ya(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||Sa(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function wa(e,t,n,r,i,a){let{labelTo:o,urlNode:s,titleNode:c}=xa(e),l=s?n.slice(s.from,s.to):``,u=c?ya(n.slice(c.from,c.to)):``,d=l?r.mdLinkText.create({href:l}):null,f=e=>o>=0&&e<o&&d!==null,p=r.mdPack.create({key:`link`,data:{href:l,title:u}}),m=[...t,p],h=e.from;for(let t of e.children){if(t.from>h){let e=f(h)?[...m,d]:m;H(i,h,t.from,e)}let e=f(t.from)?[...m,d]:m;if(t.type===V.Wikilink){Oa(t,e,n,r,i),h=t.to;continue}if(t.type===V.WikiEmbed){ka(t,e,n,r,i,a),h=t.to;continue}let o=_a.get(t.type),s=o?[...e,r[o].create()]:e;t.children.length===0?H(i,t.from,t.to,s):ba(t.children,s,t.from,t.to,n,r,i,a),h=t.to}h<e.to&&H(i,h,e.to,m)}function Ta(e,t,n){if(!t||t.type!==V.Comment||t.from!==e.to)return;let r=aa(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function Ea(e,t,n,r,i,a){let o=e.children.find(e=>e.type===V.URL);if(!o){wa(e,t,n,r,i,void 0);return}let s=e.children.filter(e=>e.type===V.LinkMark),c=e.children.find(e=>e.type===V.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?ya(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;H(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p,syntax:null,wikiTarget:null})])}function Da(e,t,n,r,i){let a=e.children.filter(e=>e.type===V.InlineMathMark);if(a.length<2){H(i,e.from,e.to,t);return}let o=n.slice(a[0].to,a[1].from),s=[...t,r.mdPack.create({key:`math`}),r.mdMath.create({formula:o})];H(i,e.from,a[0].to,[...s,r.mdMark.create()]),H(i,a[0].to,a[1].from,s),H(i,a[1].from,e.to,[...s,r.mdMark.create()])}function Oa(e,t,n,r,i){let{target:a,display:o}=ma(n.slice(e.from,e.to));H(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function ka(e,t,n,r,i,a){let o=da(n.slice(e.from,e.to)),s=a?.resolveWikiEmbed?.(o);if(!s){H(i,e.from,e.to,t);return}if(s.kind===`image`){let n=s.src??o.target,a=(s.alt??o.display)||pa(o.target);H(i,e.from,e.to,[...t,r.mdImage.create({src:n,alt:a,title:``,width:o.width,height:o.height,syntax:`wikiEmbed`,wikiTarget:o.target})]);return}if(s.kind===`file`){let n=s.href??o.target,a=(s.name??o.display)||pa(o.target);H(i,e.from,e.to,[...t,r.mdFile.create({href:n,name:a,title:s.title??``})]);return}let c=s.target??o.target,l=s.display??o.display;H(i,e.from,e.to,[...t,r.mdWikilink.create({target:c,display:l})])}function H(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&Si(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const Aa=`inline-marks-applied`;let ja=0,Ma=0;function Na(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function Pa(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?Ma++:(ja++,a=va(hc(i),n.textContent,e),t.set(n,a)),r===0)return a;let o=[];for(let[e,t,n]of a)o.push([e+r,t+r,n]);return o}function r(e,t){let r=[];return e.doc.nodesBetween(t.from,t.to,(t,i)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let a=n(t,i+1,e.schema);return a.length>0&&r.push(...a),!1}),r}return new y({key:new b(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(Aa))return null;let i=r(n,Na(e,n));if(i.length===0)return null;let a=n.tr.step(new Ci(i));return a.setMeta(Aa,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(Fa(e.state)),{}}})}function Fa(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Ia(e){return m(Pa(e))}function La(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null},syntax:{default:null},wikiTarget:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function Ra(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function za(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Ba(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Va(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Ha(){return u({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function Ua(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function Wa(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function Ga(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Ka(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function qa(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Ja(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function Ya(){return u({name:`mdFile`,inclusive:!1,attrs:{href:{default:``},name:{default:``},title:{default:``}},toDOM:()=>[`span`,{class:`md-file`},0],parseDOM:[{tag:`span.md-file`}]})}function Xa(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function Za(){return u({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{},data:{default:null}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function Qa(){return _(Ra(),za(),Ba(),Va(),Ha(),Ua(),Wa(),Ga(),Ka(),qa(),Ja(),La(),Ya(),Xa(),Za())}const U={em:{node:V.Emphasis,delim:`*`},strong:{node:V.StrongEmphasis,delim:`**`},code:{node:V.InlineCode,delim:"`"},del:{node:V.Strikethrough,delim:`~~`},highlight:{node:V.Highlight,delim:`==`}},$a=new Set([V.EmphasisMark,V.CodeMark,V.LinkMark,V.StrikethroughMark,V.HighlightMark]);function eo(e){return[e.children[0],e.children.at(-1)]}function to(e){let{type:t,children:n}=e;if(t===V.Emphasis||t===V.StrongEmphasis||t===V.Strikethrough||t===V.Highlight)return[n[0].to,n.at(-1).from];if(t===V.Link||t===V.Image){let e=n.find((e,t)=>t>0&&e.type===V.LinkMark);return e?[n[0].to,e.from]:null}return null}function no(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=to(r);return i&&i[0]<=t&&n<=i[1]?no(r.children,t,n):no(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function ro(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return ro(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function io(e,t,n){for(;t<n&&I(e.charCodeAt(t));)t++;for(;n>t&&I(e.charCodeAt(n-1));)n--;return[t,n]}function ao(e,t,n,r){let i=ta(ea(e),e=>e.type===r.node||$a.has(e.type));for(let r=t;r<n;r++)if(!I(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function oo(e,t,n,r,i){let a=ea(e),o=ta(a,e=>e.type===r.node);return i?lo(e,o,t,n):so(e,a,o,t,n,r)}function so(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=no(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=eo(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=co(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function co(e,t,n,r,i){if(i.node!==V.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat($n(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function lo(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=eo(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=ro(a.children.slice(1,-1),s,c);s>t.to&&I(e.charCodeAt(s-1));)s--;for(;c<o.from&&I(e.charCodeAt(c));)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function uo(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=ea(e),o=ta(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=eo(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return fo(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function fo(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=to(n);return!e||t<e[0]||t>e[1]||fo(n.children,t)}return!1}function W(e){return(t,n)=>{if(t.selection.empty)return po(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=io(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:ao(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>oo(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(x.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function po(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=uo(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(x.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(x.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function mo(){return s({toggleEm:()=>W(U.em),toggleStrong:()=>W(U.strong),toggleCode:()=>W(U.code),toggleDel:()=>W(U.del),toggleHighlight:()=>W(U.highlight)})}function ho(){return l({"Mod-b":W(U.strong),"Mod-i":W(U.em),"Mod-e":W(U.code),"Mod-Shift-x":W(U.del),"Mod-Shift-h":W(U.highlight)})}function go(){return _(mo(),ho())}function _o(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>mn(e,n))&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function G(e,t){let n=O(e,t,`mdLinkText`),r=O(e,t,`mdPack`,{key:`link`})??O(e,t,`mdPack`,{key:`autolink`}),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`){let t={from:i.from,to:i.to};return{unit:t,text:a?.key===`autolink`?_o(e,t,`mdLinkText`)??{from:i.from+1,to:i.to-1}:t,href:o,title:``}}let s=_o(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1,u={from:i.from+1,to:c};return{unit:{from:i.from,to:i.to},text:u,label:u,dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function vo(e){let t=e.trim();return t?ki(t)??t:``}function yo(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function bo(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!g(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=io(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function xo({href:e,title:t,wrapText:n=!0}={}){return(r,i)=>{let a=bo(r);if(!a)return!1;if(i){let{from:o,to:s}=a,c=r.tr,l=`](${yo(vo(e??``),t??``)})`;c.insertText(l,s).insertText(`[`,o);let u=s+1+l.length;c.setSelection(n?x.create(c.doc,o,u):x.create(c.doc,u)),c.scrollIntoView(),i(c)}return!0}}function So(e){return(t,n)=>{let r=G(t,t.selection.from);if(!r?.dest)return!1;let i=yo(vo(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function Co(){return(e,t)=>{let n=G(e,e.selection.from);return n?.label?(t&&t(e.tr.delete(n.label.to,n.unit.to).delete(n.unit.from,n.label.from).scrollIntoView()),!0):!1}}function wo(){return s({insertLink:xo,updateLink:So,removeLink:Co})}function To(e){return(t,n,r)=>{let i=G(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(x.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=bo(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(x.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function Eo(e){return l({"Mod-k":To(e)})}function Do(e){return e===`)`||e===`*`||e===`+`?e:void 0}function Oo(e){return e===`X`?e:void 0}function ko(e){return Mo(e)?String(e):void 0}function Ao(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>{let t=Do(e);return t==null?null:[`data-list-marker`,t]},parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function jo(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>{let t=Oo(e);return t==null?null:[`data-list-task-marker`,t]},parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function Mo(e){return e===2||e===3||e===4}function No(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>{let t=ko(e);return t==null?null:[`data-list-marker-gap`,t]},parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return Mo(t)?t:1}})}function Po(e){let t=e.attrs;return{...xt(e),"data-list-marker":Do(t.marker),"data-list-task-marker":Oo(t.taskMarker),"data-list-marker-gap":ko(t.markerGap)}}function Fo(){return o({serializeFragmentWrapper:e=>(...t)=>Io(wt(e(...t))),serializeNodeWrapper:e=>(...t)=>{let n=e(...t);return _e(n)?Io(wt(n)):n},nodesFromSchemaWrapper:e=>(...t)=>({...e(...t),list:e=>Tt({node:e,nativeList:!0,getAttributes:Po})})})}function Io(e){_e(e)&&Lo(e);for(let t of e.children)Io(t);return e}function Lo(e){if(!e.classList.contains(`prosemirror-flat-list`)||e.getAttribute(`data-list-kind`)!==`task`||e.children.length!==2)return;let t=e.children.item(0);if(!t||!t.classList.contains(`list-marker`))return;let n=St(t);if(!n)return;let r=e.children.item(1);if(!r||!r.classList.contains(`list-content`))return;let i=r.children.item(0);!i||![`P`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`].includes(i.tagName)||(e.replaceChildren(...r.children),i.prepend(n))}const Ro=[D(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),D(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),D(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),D(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function zo(){return _(Ro.map(Ye))}function Bo(){return E({kind:`task`,marker:`+`})}function Vo(){return E({kind:`task`,marker:null})}function Ho(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(P(n,`list`))return n.attrs}return null}function Uo(){return(e,t,n)=>{let r=Ho(e);return(r?.kind===`task`?r.marker===`+`?Vo():Bo():E({kind:`task`,marker:null,checked:!1}))(e,t,n)}}function Wo(){return s({cycleCheckableList:Uo,wrapInCircleTask:Bo,wrapInSquareTask:Vo})}function Go(){return(e,t,n)=>{let r=Ho(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},E(a)(e,t,n)}}function Ko(){return(e,t,n)=>{let r=Ho(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},E(a)(e,t,n)}}function qo(e){return P(e,`list`)&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const Jo=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:qo(e)?{...t,collapsed:!t.collapsed}:t};function Yo(){return m(()=>[new y({props:{handleDOMEvents:{mousedown:(e,t)=>Ct({view:e,event:t,onListClick:Jo})}}}),vt(),new y({props:{transformCopied:Et}}),yt()])}function Xo(){return s({toggleListCollapsed:()=>bt({isToggleable:qo})})}function Zo(){return l({"Mod-Enter":Go(),"Mod-Shift-Enter":Ko(),"Mod-.":bt({isToggleable:qo}),"Mod-Shift-7":rt({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":rt({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":rt({kind:`task`,checked:!1,collapsed:!1})})}function Qo(){return _(tt(),Yo(),et(),Qe(),Fo(),$e(),zo(),Zo(),Ao(),jo(),No(),Wo(),Xo())}let $o;function es(){return $o??=import(`./katex-chunk-Ch7kgbXr.js`).then(e=>e.render),$o}function ts(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var ns=class{#e;#t;#n;#r;constructor(e,t){this.#r=e.attrs.formula,this.#e=document.createElement(`span`),this.#e.className=`md-math-view`,this.#n=document.createElement(`span`),this.#n.className=`md-math-view-preview`,this.#n.dataset.testid=`math-preview`,this.#n.contentEditable=`false`,this.#n.addEventListener(`mousedown`,e=>{e.preventDefault();let n=t.posAtDOM(this.#t,0);if(n<0)return;let r=x.near(t.state.doc.resolve(n),1);t.dispatch(t.state.tr.setSelection(r)),t.focus()}),this.#t=document.createElement(`span`),this.#t.className=`md-math-view-content`,this.#e.appendChild(this.#n),this.#e.appendChild(this.#t),this.#i()}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs.formula;return t!==this.#r&&(this.#r=t,this.#i()),!0}ignoreMutation(e){return!this.#t.contains(e.target)}#i(){let e=this.#r;es().then(t=>{e===this.#r&&ts(t,this.#n,e,!1)})}};function rs(){return d({name:`mdMath`,constructor:(e,t)=>new ns(e,t)})}function is(e){return e===`left`||e===`center`||e===`right`?e:null}function as(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>is(e.getAttribute(`data-align`))})}function os(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>is(e.getAttribute(`data-align`))})}function ss(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(P(n.child(e),`tableHeaderCell`))return t}return 0}function cs(e){return e.child(ss(e))}function ls(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function us(e,t,n){if(e.childCount===0)return;let r=cs(e),i=t+1;for(let t=0;t<e.childCount;t++){let a=e.child(t),o=i+1;for(let e=0;e<a.childCount;e++){let t=a.child(e),i=ls(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function ds(e){let t,n;for(let r of e){if(!r.docChanged)continue;t!=null&&n!=null&&(t=r.mapping.map(t,-1),n=r.mapping.map(n,1));let e=r.mapping;for(let[r,i]of e.maps.entries()){let a=e.slice(r+1);i.forEach((e,r,i,o)=>{let s=a.map(i,-1),c=a.map(o,1);t=t==null?s:Math.min(t,s),n=n==null?c:Math.max(n,c)})}}if(!(t==null||n==null))return{from:t,to:n}}function fs(){return new y({key:new b(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=ds(e);if(!r)return;let i=n.doc,a=Math.max(0,Math.min(r.from,i.content.size)),o=Math.max(a,Math.min(r.to,i.content.size)),s;return i.nodesBetween(a,o,(e,t)=>P(e,`table`)?(s??=n.tr,us(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function ps(){return m(fs())}function ms(e){let{selection:t}=e;if(Ft(t)){let{$anchorCell:e,$headCell:n}=t,r=e.depth-1,i=e.index(),a=n.index();return{table:e.node(r),tablePos:e.before(r),firstColumn:Math.min(i,a),lastColumn:Math.max(i,a)}}let{$from:n}=t;for(let e=n.depth;e>2;e--){let t=n.node(e).type.name;if(t===`tableCell`||t===`tableHeaderCell`){let t=n.index(e-1);return{table:n.node(e-2),tablePos:n.before(e-2),firstColumn:t,lastColumn:t}}}}function hs(e){return(t,n)=>{let r=ms(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=ss(i),l=a+1;for(let e=0;e<c;e++)l+=i.child(e).nodeSize;let u=i.child(c),d=t.tr,f=l+1;for(let t=0;t<u.childCount;t++){let n=u.child(t);t>=o&&t<=s&&(n.attrs.align??null)!==e&&d.setNodeMarkup(f,void 0,{...n.attrs,align:e}),f+=n.nodeSize}n(d)}return!0}}function gs(e){let t=ms(e);if(!(!t||t.table.childCount===0))return ls(cs(t.table),t.lastColumn)??void 0}function _s(){return s({setTableColumnAlign:hs})}function vs(){return _(as(),os(),ps(),_s())}function ys(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e).type.name;if(n===`tableCell`||n===`tableHeaderCell`)return!0}return!1}const bs=`paragraph`;function xs(){return _(p({name:`tableCell`,content:bs}),p({name:`tableHeaderCell`,content:bs}))}const Ss=(e,t)=>{let{selection:n}=e;return!Ft(n)||!n.isColSelection()||!n.isRowSelection()?!1:Pt(e,t)};function Cs(){return v(l({Backspace:Ss,Delete:Ss}),t.high)}function ws(){return _(Nt(),Mt(),Dt(),jt(),xs(),vs(),At({allowTableNodeSelection:!0}),Ot(),kt(),Cs())}function Ts(e){let{selection:t}=e,{$from:n,$to:r}=t;if(ae(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function Es(e){return(t,n)=>{if(ys(t))return!1;let r=Ts(t);if(r==null)return!1;let i=r+e;if(i<0||i>=t.doc.childCount)return!1;if(n){let{selection:a}=t,o=Math.min(r,i),s=a.$from.posAtIndex(o,0),c=t.doc.child(o),l=t.doc.child(o+1),u=t.tr.replaceWith(s,s+c.nodeSize+l.nodeSize,[l,c]),d=e===-1?-c.nodeSize:l.nodeSize,f=ae(a)?De.create(u.doc,a.from+d):x.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function Ds(e){return(t,n,r)=>nt(e)(t,n,r)||Es(e===`up`?-1:1)(t,n,r)}function Os(){return l({"Alt-ArrowUp":Ds(`up`),"Alt-ArrowDown":Ds(`down`)})}const K=new b(`meowdownPendingReplacement`);function q(e){return K.getState(e)?.pending??null}function ks(e,t){switch(e.type){case`start`:return{pending:{from:e.from,to:e.to,mode:e.mode,text:``}};case`append`:return t.pending?{pending:{...t.pending,text:t.pending.text+e.text}}:t;case`accept`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`accepted`}}:t;case`discard`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:t}}const As=new y({key:K,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(K);if(n)return ks(n,t);if(e.docChanged&&t.pending){let n=e.mapping.mapResult(t.pending.from,1),r=e.mapping.mapResult(t.pending.to,-1),i=Math.min(n.pos,r.pos),a=Math.max(n.pos,r.pos);return(n.deletedAfter&&r.deletedBefore||i>=a)&&t.pending.mode===`replace`?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:{pending:{...t.pending,from:i,to:a}}}return t}},props:{decorations:e=>{let t=q(e);return!t||t.from>=t.to?null:S.create(e.doc,[ke.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function js(e){return(t,n)=>{let{from:r,to:i,mode:a}=e;return r<0||i>t.doc.content.size||r>i||r===i&&a===`replace`?!1:(n?.(t.tr.setMeta(K,{type:`start`,from:r,to:i,mode:a})),!0)}}function Ms(e){return(t,n)=>q(t)?(n?.(t.tr.setMeta(K,{type:`append`,text:e})),!0):!1}function Ns(){return(e,t)=>q(e)?(t?.(e.tr.setMeta(K,{type:`discard`})),!0):!1}function Ps(e={}){return(t,n)=>{let r=q(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=_c(t.schema),o=X(r.text,{nodes:a}),s=t.tr;if(s.setMeta(K,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(x.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i!=null&&P(i,`paragraph`)&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(x.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new T(o.content,0,0)),s.setSelection(x.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function Fs(){return s({startPendingReplacement:js,appendPendingReplacementText:Ms,acceptPendingReplacement:Ps,discardPendingReplacement:Ns})}function Is(){return l({"Mod-Enter":Ps(),Escape:Ns()})}function Ls(){return _(m(As),Fs(),Is())}function Rs(e){return m(new y({view:()=>({update:(t,n)=>{let r=K.getState(n),i=K.getState(t.state);!i||r===i||(i.pending?i.pending!==r?.pending&&e({type:`update`,pending:i.pending}):i.ended&&i.ended!==r?.ended&&e({type:`ended`,pending:i.ended.pending,outcome:i.ended.outcome}))}})}))}function zs(e){return e.left===e.right&&e.top===e.bottom}function J(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return zs(r)?void 0:r}function Bs(e){let t=e.dom.ownerDocument.getSelection();if(t==null||t.rangeCount===0||!e.dom.contains(t.anchorNode))return;let n=t.getRangeAt(0).cloneRange();n.collapse(!0);let r=Array.from(n.getClientRects()).filter(e=>e.height>0);if(r.length===0)return;let i=r[r.length-1];return{left:i.left,top:i.top,height:i.height}}function Vs(e){let t=e.state,n=t.selection.head,r=z(t,n),i=B(t,n),a=r==null,o=[[n,a],[n,!a]];r!=null&&o.push([r.from,!0]),i!=null&&o.push([i.to,!1]);for(let[t,n]of o){let r=J(e,t,n?-1:1);if(r!=null&&r.bottom>r.top)return{left:r.left,top:r.top,height:r.bottom-r.top}}}function Hs(e){let t=e.state,n=t.selection.head;for(let r of qt){let i=O(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=Ws(e,i.from+1);if(a==null)continue;let o=Array.from(a.getClientRects()).filter(e=>e.height>0);if(o.length===0)continue;let s=i.to===n,c=s?o[o.length-1]:o[0];return{left:s?c.right:c.left,top:c.top,height:c.height}}}function Us(e,t,n){let r=e.state;for(let i of qt){let a=O(r,t,i);if(a==null)continue;let o=Ws(e,a.from+1);if(o==null)continue;let s=Array.from(o.getClientRects()).filter(e=>e.height>0);if(s.length!==0)return n===1?s[0]:s[s.length-1]}}function Ws(e,t){let{node:n}=e.domAtPos(t,0);return(n instanceof Element?n:n.parentElement)?.closest(`.md-atom-view`)?.querySelector(`.md-atom-view-preview`)??void 0}function Gs(e){return Vs(e)??Hs(e)}const Ks=new b(`meowdown-scroll-to-selection`);function qs(e){let t=e.state.selection;if(!g(t)||J(e,t.head,1)!=null)return!1;let n=Gs(e);if(n==null)return!1;let r=e.domAtPos(t.head).node;return Zs(e,{left:n.left,right:n.left,top:n.top,bottom:n.top+n.height},r),!0}function Y(e,t){return typeof e==`number`?e:e[t]}function Js(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11?t.host:t}function Ys(e){let t=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 Xs(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 Zs(e,t,n){let r=e.someProp(`scrollThreshold`)??0,i=e.someProp(`scrollMargin`)??5,a=e.dom.ownerDocument;for(let e=n;e;){if(e.nodeType!==1){e=Js(e);continue}let n=e,o=n===a.body,s=o?Ys(a):Xs(n),c=0,l=0;if(t.top<s.top+Y(r,`top`)?l=-(s.top-t.top+Y(i,`top`)):t.bottom>s.bottom-Y(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+Y(i,`top`)-s.top:t.bottom-s.bottom+Y(i,`bottom`)),t.left<s.left+Y(r,`left`)?c=-(s.left-t.left+Y(i,`left`)):t.right>s.right-Y(r,`right`)&&(c=t.right-s.right+Y(i,`right`)),c||l)if(o)a.defaultView?.scrollBy(c,l);else{let e=n.scrollLeft,r=n.scrollTop;l&&(n.scrollTop+=l),c&&(n.scrollLeft+=c);let i=n.scrollLeft-e,a=n.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=o?`fixed`:getComputedStyle(n).position;if(/^(?:fixed|sticky)$/.test(u))break;e=u===`absolute`?n.offsetParent:Js(n)}}function Qs(){return m(new y({key:Ks,props:{handleScrollToSelection:qs}}))}function $s(e,t){return(n,r)=>{let i=e<0?Oe.atStart(n.doc):Oe.atEnd(n.doc),a=t?x.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function ec(){return l({"Meta-ArrowUp":$s(-1,!1),"Meta-ArrowDown":$s(1,!1),"Shift-Meta-ArrowUp":$s(-1,!0),"Shift-Meta-ArrowDown":$s(1,!0)})}function tc(e){e.offsetWidth}const nc=new b(`meowdown-virtual-caret`),rc=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`];function ic(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function ac(e){let t=Bs(e)??Vs(e);return t==null?Hs(e):ic(t)}function oc(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var sc=class{#e;#t;#n;#r;#i;#a;#o;#s=0;constructor(e){this.#e=e,this.#r=e.dom.ownerDocument,this.#t=this.#r.createElement(`div`),this.#t.className=`md-virtual-caret-layer`,this.#n=this.#t.appendChild(this.#r.createElement(`div`)),this.#n.className=`md-virtual-caret`,this.#n.dataset.testid=`virtual-caret`,e.dom.insertAdjacentElement(`afterend`,this.#t),this.#r.addEventListener(`selectionchange`,this.#l),typeof ResizeObserver<`u`&&(this.#i=new ResizeObserver(this.#l),this.#i.observe(e.dom)),this.#l()}update(e,t){e.state.selection.eq(t.selection)||this.#c(),this.#l()}destroy(){this.#r.removeEventListener(`selectionchange`,this.#l),this.#i?.disconnect(),this.#t.remove()}#c(){this.#s=1-this.#s,this.#n.style.animationName=rc[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=g(n)&&n.empty?ac(e):void 0,i=r!=null&&A(t)===`hide`?oi(t,n.head):void 0;if(oc(r,this.#a)&&i===this.#o)return;let a=this.#a==null;if(this.#a=r,this.#o=i,i==null?delete this.#n.dataset.tail:this.#n.dataset.tail=i,r==null){this.#n.style.visibility=`hidden`;return}let o=this.#t.getBoundingClientRect();a&&(this.#n.style.transitionProperty=`none`),this.#n.style.visibility=``,this.#n.style.left=`${r.left-o.left}px`,this.#n.style.top=`${r.top-o.top}px`,this.#n.style.height=`${r.height}px`,a&&(tc(this.#n),this.#n.style.transitionProperty=``)}};function cc(){return m(new y({key:nc,view:e=>new sc(e)}))}function lc(e){return _(Rn(),Se(),Yr(),Te(),xe(),Qo(),Pn(),ws(),zr(),vi(),yi(),Qa(),Ar(),Jr(),Os(),ec(),Ia(e),go(),wo(),ga(),rs(),Ut(e.markMode??`focus`),wr(),cc(),Qs(),gi(),on({marks:qt.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),Ce(),Ee(),we(),Kr(),Ls())}function uc(e={}){return lc(e)}const dc=be(()=>{let e=uc().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),fc=be(()=>r(dc())),pc=be(()=>n(dc())),mc=`meowdown_mark_builders`;function hc(e){let t=e.cached[mc];if(t)return t;let r=n(e);return e.cached[mc]=r,r}const gc=`meowdown_node_builders`;function _c(e){let t=e.cached[gc];if(t)return t;let n=r(e);return e.cached[gc]=n,n}function X(e,t={}){let{nodes:n=fc(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=yc(e);i=t,n&&(a=e.slice(n))}let o=bc(n,$i.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const vc=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function yc(e){let t=vc.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function bc(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&xc(r,e,n,i,t.from),i=t.to,r.push(...Sc(e,t,n));while(t.nextSibling());return t.parent(),r}function xc(e,t,n,r,i){let a=0;for(let e=r;e<i;e++)n.charCodeAt(e)===10&&a++;for(let n=2;n<a;n++)e.push(t.paragraph())}function Sc(e,t,n){switch(t.type.id){case V.ATXHeading1:return[Z(e,t,n,1,!1)];case V.ATXHeading2:return[Z(e,t,n,2,!1)];case V.ATXHeading3:return[Z(e,t,n,3,!1)];case V.ATXHeading4:return[Z(e,t,n,4,!1)];case V.ATXHeading5:return[Z(e,t,n,5,!1)];case V.ATXHeading6:return[Z(e,t,n,6,!1)];case V.SetextHeading1:return[Z(e,t,n,1,!0)];case V.SetextHeading2:return[Z(e,t,n,2,!0)];case V.Paragraph:return[Oc(e,t,n)];case V.CommentBlock:return[kc(e,t,n)];case V.HTMLBlock:case V.ProcessingInstructionBlock:return[Oc(e,t,n)];case V.Blockquote:return[Ac(e,t,n)];case V.BulletList:return jc(e,t,n,`bullet`);case V.OrderedList:return jc(e,t,n,`ordered`);case V.FencedCode:case V.CodeBlock:return[Nc(e,t,n)];case V.BlockMath:return[Pc(e,t,n)];case V.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case V.Table:return[Fc(e,t,n)];case V.Task:return[Oc(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[Oc(e,t,n)])}}function Z(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===V.HeaderMark&&t.from===a&&(o=t.to);let e=-1,n=-1,r=-1;do e=t.type.id,n=t.from,r=t.to;while(t.nextSibling());e===V.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=Ec(n.slice(o,s),Q(n,o)).trim(),d=i?Cc(n,c,l)||1:null,f=!i&&c>=0&&wc(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function Cc(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++){let t=e.charCodeAt(i);(t===61||t===45)&&r++}return r}function wc(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++)e.charCodeAt(i)===35&&r++;return r}function Q(e,t){let n=e.lastIndexOf(`
|
|
26
|
+
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function Tc(e,t){let n=0,r=0;for(;r<e.length&&n<t;){let t=e.charCodeAt(r);if(t===32)n+=1;else if(t===9)n+=4-n%4;else break;r++}return e.slice(r)}function Ec(e,t){return t===0||!e.includes(`
|
|
27
27
|
`)?e:e.split(`
|
|
28
|
-
`).map((e,n)=>n===0?e:
|
|
29
|
-
`)}function
|
|
30
|
-
`).filter(e=>!
|
|
31
|
-
`)}const al=new b(`meowdown-embed-paste`);function ol(e){let t=e.trim();if(!(!t||/\s/.test(t)))return rl(t)?t:void 0}function sl(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(Lt(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(``,n,n+t.length);e.dispatch(Lt(i))}function cl(){return m(new y({key:al,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=il(t,n);if(!i)return!1;let a=ol(i);return a?(sl(e,a),!0):!1}}}))}const ll=new b(`meowdown-exit-boundary`);function ul(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):void 0:i;return!!(a&&x.findFrom(a,t))}function dl(e,t){let{state:n}=e,{selection:r}=n;return g(r)&&!r.empty||ne(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:ul(n,t)}function fl(e){return new y({key:ll,props:{handleKeyDown:(t,n)=>{if(n.shiftKey||n.altKey||n.ctrlKey||n.metaKey)return!1;let r=n.key===`ArrowUp`?-1:n.key===`ArrowDown`?1:void 0;return!(!r||dl(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function pl(e){return v(m(fl(e)),t.low)}const ml=new Set([`avif`,`bmp`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]);function hl(e){if(e.type?.startsWith(`image/`))return!0;let t=e.name.lastIndexOf(`.`);if(t===-1)return!1;let n=e.name.slice(t+1).toLowerCase();return ml.has(n)}function gl(e,t){return hl(e)?``:`[${yl(e.name)}](${t})`}function _l(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const vl=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function yl(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function bl(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??vl,o=r,s=!1;for(let n of t){let t;try{t=await i(n)}catch(e){a(e,n);continue}if(!t||e.isDestroyed)continue;let r=gl(n,t),c=s?`\n${r}`:r,l=o==null?e.state.tr.insertText(c):e.state.tr.insertText(c,o);e.dispatch(l),s=!0,o!=null&&(o+=c.length)}}function xl(e){return new y({key:new b(`file-paste`),props:{handlePaste:(t,n)=>{let r=_l(n.clipboardData,e);return r.length===0?!1:(bl(t,r,e),!0)},handleDrop:(t,n)=>{let r=_l(n.dataTransfer,e);return r.length===0?!1:(bl(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function Sl(e={}){return v(m(xl(e)),t.high)}const Cl=new b(`meowdown-file-click`);function wl(e,t){let n=D(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function Tl(e){return m(new y({key:Cl,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-file-view-preview`);if(!i)return!1;let a=i.closest(`.md-file-view`)?.querySelector(`.md-file-view-content`);if(!a)return!1;let o=wl(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const El=[`KB`,`MB`,`GB`,`TB`];function Dl(e){let t=e,n=`B`;for(let e of El){if(t<999.5)break;t/=1e3,n=e}return n===`B`?`${Math.round(t)} B`:`${t<9.95?Math.round(t*10)/10:Math.round(t)} ${n}`}const Ol=new Map([[`pdf`,`pdf`],[`zip`,`archive`],[`tar`,`archive`],[`gz`,`archive`],[`tgz`,`archive`],[`rar`,`archive`],[`7z`,`archive`],[`doc`,`doc`],[`docx`,`doc`],[`pages`,`doc`],[`xls`,`sheet`],[`xlsx`,`sheet`],[`csv`,`sheet`],[`numbers`,`sheet`],[`ppt`,`slides`],[`pptx`,`slides`],[`key`,`slides`],[`mp3`,`audio`],[`wav`,`audio`],[`m4a`,`audio`],[`flac`,`audio`],[`ogg`,`audio`],[`mp4`,`video`],[`mov`,`video`],[`mkv`,`video`],[`webm`,`video`],[`txt`,`text`],[`md`,`text`]]);function kl(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return Ol.get(r)??`generic`}const Al=`http://www.w3.org/2000/svg`;function jl(){let e=document.createElementNS(Al,`svg`);e.setAttribute(`class`,`md-file-view-icon`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`aria-hidden`,`true`);for(let t of[`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,`M14 2v4a2 2 0 0 0 2 2h4`]){let n=document.createElementNS(Al,`path`);n.setAttribute(`d`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}return e}var Ml=class{#e;#t;#n;#r;#i;#a;#o=!1;constructor(e,t){this.#a=e.attrs,this.#e=document.createElement(`span`),this.#e.className=`md-file-view md-atom-view`,this.#n=document.createElement(`span`),this.#n.className=`md-file-view-preview md-atom-view-preview`,this.#n.contentEditable=`false`,this.#n.dataset.testid=`file-pill`,this.#n.dataset.fileKind=kl(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(jl()),this.#r=document.createElement(`span`),this.#r.className=`md-file-view-name`,this.#r.textContent=this.#a.name,this.#n.appendChild(this.#r),this.#i=document.createElement(`span`),this.#i.className=`md-file-view-size`,this.#i.dataset.testid=`file-pill-size`,this.#n.appendChild(this.#i),this.#t=document.createElement(`span`),this.#t.className=`md-file-view-content md-atom-view-content`,this.#e.appendChild(this.#t),this.#s(t.resolveFileInfo)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#a;return t.href===n.href?(this.#a=t,t.name!==n.name&&(this.#r.textContent=t.name,this.#n.title=t.name),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}destroy(){this.#o=!0}async#s(e){if(!e)return;let t;try{t=await e(this.#a.href)}catch(e){console.error(`[meowdown] resolveFileInfo failed:`,e);return}if(this.#o||!t)return;let{size:n}=t;n==null||!Number.isFinite(n)||n<0||(this.#i.textContent=Dl(n))}};function Nl(e={}){return d({name:`mdFile`,constructor:t=>new Ml(t,e)})}function Pl(e){return m(new y({key:e.key,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(e.selector);if(!i)return!1;let a=e.findPayloadForElement?e.findPayloadForElement(t,i):e.findPayloadAt(t.state,n);return a==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(a,r),!0)}}}))}const Fl=new b(`meowdown-tag-click`);function Il(e,t){let n=D(e,t,`mdTag`);if(!n)return;let r=e.doc.textBetween(n.from,n.to),i=r.startsWith(`#`)?r.slice(1):r;return{from:n.from,to:n.to,tag:i}}function Ll(e){return Pl({key:Fl,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>Il(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const Rl=new b(`meowdown-wikilink-click`);function zl(e,t){let n=D(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Bl(e,t){let n=t.closest(`.md-wikilink-view`)?.querySelector(`.md-wikilink-view-content`);if(n)return zl(e.state,e.posAtDOM(n,0))}function Vl(e){return Pl({key:Rl,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>zl(e,t)?.target,findPayloadForElement:(e,t)=>Bl(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const Hl=new b(`meowdown-follow-link`);function Ul(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:re?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Wl(e){return new y({key:Hl,props:{handleKeyDown:(t,n)=>{if(!Ul(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&zl(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&Il(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&wl(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&G(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Gl(e){return v(m(Wl(e)),t.high)}const Kl=new b(`meowdown-image-click`);function ql(e){return e instanceof HTMLElement&&e.closest(`.md-image-view-preview`)}function Jl(e,t){let n=D(e,t,`mdImage`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function Yl(e,t){let n=t.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(n)return Jl(e.state,e.posAtDOM(n,0))}function Xl(e,t){return Array.from(e).find(e=>e.identifier===t)}function Zl(e,t){return Math.abs(t.clientX-e.clientX)<=10&&Math.abs(t.clientY-e.clientY)<=10}function Ql(e){let t=new WeakMap;return m(new y({key:Kl,props:{handleDOMEvents:{pointerdown:(e,t)=>(ql(t.target)&&t.pointerType!==`mouse`&&t.preventDefault(),!1),touchstart:(e,n)=>{if(t.delete(e),n.touches.length!==1||!ql(n.target)||n.target instanceof HTMLElement&&n.target.closest(`.md-image-resize-handle`))return!1;let r=n.changedTouches[0];return r&&t.set(e,{identifier:r.identifier,clientX:r.clientX,clientY:r.clientY}),!1},touchmove:(e,n)=>{let r=t.get(e);if(!r)return!1;let i=Xl(n.changedTouches,r.identifier);return i&&!Zl(r,i)&&t.delete(e),!1},touchcancel:e=>(t.delete(e),!1),touchend:(n,r)=>{let i=t.get(n);if(t.delete(n),!i||r.touches.length>0)return!1;let a=Xl(r.changedTouches,i.identifier);if(!a||!Zl(i,a))return!1;let o=ql(r.target);if(!o)return!1;r.preventDefault();let s=Yl(n,o);return s&&e({src:s.src,alt:s.alt,event:r}),!0}},handleClick:(t,n,r)=>{let i=ql(r.target);if(!i)return!1;let a=Yl(t,i);return a?(e({src:a.src,alt:a.alt,event:r}),!0):!1}}}))}function $l(e){return/^https?:\/\//i.test(e)?e:void 0}function eu(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&Xc(t),t}function tu(e,t,n,r){if(n!=null&&r!=null){e.setAttribute(`data-width`,String(n)),e.setAttribute(`data-height`,String(r));return}let i=t.naturalWidth/t.naturalHeight;if(!Number.isFinite(i)||i<=0){n!=null&&e.setAttribute(`data-width`,String(n)),r!=null&&e.setAttribute(`data-height`,String(r));return}let a=n==null?Math.min(t.naturalHeight,500):n/i,o=n??a*i;e.setAttribute(`data-width`,String(Math.round(o))),e.setAttribute(`data-height`,String(Math.round(a)))}function nu(e,t,n,r){let i=e.posAtDOM(t,0),a=D(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=a.mark.attrs;if(s.syntax===`wikiEmbed`){let t=s.wikiTarget||la(o).target;if(!t)return;let i=ua(t,n,r);i!==o&&e.dispatch(e.state.tr.insertText(i,a.from,a.to));return}let c=oa(o),l=a.from+c.length,u=o.slice(c.length),d=aa({...ra(u)??{},width:Math.round(n),height:Math.round(r)});d!==u&&e.dispatch(e.state.tr.insertText(d,l,a.to))}var ru=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n){this.#i=e.attrs,this.#n=n,this.#r=t,this.#e=document.createElement(`span`),this.#e.className=`md-image-view md-atom-view`,this.#t=document.createElement(`span`),this.#t.className=`md-image-view-content md-atom-view-content`;let r=this.#s();r&&(r.contentEditable=`false`,this.#e.appendChild(r)),this.#e.appendChild(this.#t)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#i;return t.src===n.src?(this.#i=t,this.#o&&t.alt!==n.alt&&(this.#o.alt=t.alt),this.#a&&this.#o&&(t.width!==n.width||t.height!==n.height)&&tu(this.#a,this.#o,t.width,t.height),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}#s(){let{src:e}=this.#i,t=rl(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(eu(t)),e}let n=(this.#n.resolveImageUrl??$l)(e);if(!n)return;let r=document.createElement(`span`);return r.className=`md-image-view-preview md-atom-view-preview`,r.dataset.testid=`image-preview`,r.appendChild(this.#c(n)),r}#c(e){zt(),Rt();let t=document.createElement(`prosekit-resizable-root`);t.className=`md-image-resizable`,t.dataset.testid=`image-resizable`,t.setAttribute(`data-loading`,``);let n=document.createElement(`img`);n.src=e,n.alt=this.#i.alt,n.draggable=!1,tu(t,n,this.#i.width,this.#i.height),n.addEventListener(`load`,()=>{t.removeAttribute(`data-loading`);let e=n.naturalWidth/n.naturalHeight;!Number.isFinite(e)||e<=0||(t.setAttribute(`data-aspect-ratio`,String(e)),tu(t,n,this.#i.width,this.#i.height))}),n.addEventListener(`error`,()=>{t.removeAttribute(`data-loading`)}),t.appendChild(n);let r=document.createElement(`prosekit-resizable-handle`);return r.className=`md-image-resize-handle`,r.setAttribute(`position`,`bottom-right`),r.addEventListener(`click`,e=>e.stopPropagation()),t.appendChild(r),t.addEventListener(`resizeEnd`,e=>{let{width:t,height:n}=e.detail;nu(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function iu(e={}){return d({name:`mdImage`,constructor:(t,n)=>new ru(t,n,e)})}const au={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-k":`Link`,"Mod-Shift-k":`Insert a wikilink`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`,"Mod-.":`Fold or unfold a bullet`,"Mod-Enter":`Follow the link under the caret, or cycle a checkbox task`,"Mod-Shift-Enter":`Cycle a circle checkbox task`,"Mod-Shift-7":`Ordered list`,"Mod-Shift-8":`Bullet list`,"Mod-Shift-9":`Checkbox task list`,"Alt-ArrowUp":`Move the block or list item up`,"Alt-ArrowDown":`Move the block or list item down`,"Meta-ArrowUp":`Move the caret to the document start`,"Meta-ArrowDown":`Move the caret to the document end`,"Shift-Meta-ArrowUp":`Select to the document start`,"Shift-Meta-ArrowDown":`Select to the document end`,Escape:`Collapse the selection`},ou=new b(`meowdown-link-click`);function su(e){return Pl({key:ou,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>G(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function cu(e){let t,n=(t,n)=>e.findPayloadForElement?e.findPayloadForElement(t,n):e.findPayloadAt(t.state,t.posAtDOM(n,0)),r=()=>{t&&(t=void 0,e.onHoverChange(void 0))},i=(i,a)=>{let o=a.target;if(!o||!_e(o))return;let s=o.closest(e.selector);if(!s||!i.dom.contains(s)||s===t?.element)return;r();let c=n(i,s);c!=null&&(t={payload:c,element:s},e.onHoverChange(t))},a=e=>{if(!t)return;let n=e.relatedTarget;n instanceof Node&&t.element.contains(n)||r()};return m(new y({key:e.key,props:{handleDOMEvents:{mouseover:(e,t)=>(i(e,t),!1),mouseout:(e,t)=>(a(t),!1)}},view:()=>({update:i=>{if(!t)return;if(!t.element.isConnected||!i.dom.contains(t.element)){r();return}let a=n(i,t.element);if(a==null||!e.isSamePayload(t.payload,a)){r();return}t={...t,payload:a}},destroy:r})}))}const lu=new b(`meowdown-link-hover`);function uu(e){return cu({key:lu,selector:`.md-link`,findPayloadAt:(e,t)=>G(e,t),isSamePayload:(e,t)=>e.href===t.href&&e.title===t.title,onHoverChange:e})}const du=new b(`meowdown-link-paste`);function fu(e){let t=e.trim();if(!(!t||/\s/.test(t)))return Di(t)}function pu(){return v(m(new y({key:du,props:{handlePaste:(e,t,n)=>{let r=il(t,n);if(!r)return!1;let i=fu(r);return i?Jr(e,yo({href:i,wrapText:!1})):!1}}})),t.high)}const mu=[[/<-/,`←`],[/(?<!-)->/,`→`],[/\(c\)/,`©`],[/\(r\)/,`®`],[/1\/2/,`½`],[/\+\/-/,`±`],[/!=/,`≠`],[/<</,`«`],[/>>/,`»`],[/(?<!<!)(?<!^(?:-[ \t]*)+)--/,`—`]],$=new b(`meowdown-substitution-undo`);function hu(e,t,n){let r=ee(e.schema,`mdCode`);return e.doc.rangeHasMark(t,n,r)}function gu(e,t,n,r,i){if(hu(e,t,n))return null;let[,a]=r,o=i==null?a:`${a} `,s=e.tr.replaceWith(t,n,e.schema.text(o));return i!=null&&s.setMeta($,{from:t,to:t+o.length,before:i,after:o}),s}function _u(){return _(mu.map(e=>Ye(new Bt(new RegExp(String.raw`(?:${e[0].source})\s$`),(t,n,r,i)=>gu(t,r,i,e,n[0])))))}function vu(){return m(new y({key:$,state:{init:()=>null,apply:(e,t)=>{let n=e.getMeta($);if(n!==void 0)return n;if(!t)return null;let r=e.mapping.map(t.from),i=e.mapping.map(t.to);return e.selection.empty&&e.selection.from===i&&e.doc.textBetween(r,i)===t.after?{...t,from:r,to:i}:null}}}))}function yu(){return v(l({Backspace:(e,t)=>{let n=$.getState(e);return n?(t?.(e.tr.replaceWith(n.from,n.to,e.schema.text(n.before)).setMeta($,null)),!0):!1}}),t.highest)}function bu(){return _(vu(),yu())}function xu(){return _(mu.map(e=>qe({regex:RegExp(`(?:${e[0].source})$`),handler:({state:t,from:n,to:r})=>gu(t,n,r,e)})))}function Su(){return _(_u(),bu(),xu())}const Cu=new b(`meowdown-wikilink-hover`);function wu(e){return cu({key:Cu,selector:`.md-wikilink-view-preview`,findPayloadAt:zl,findPayloadForElement:Bl,isSamePayload:(e,t)=>e.target===t.target,onHoverChange:t=>{e(t?{...t.payload,element:t.element}:void 0)}})}function Tu(e,t={}){let n=[];return e.content.forEach(e=>{let r=[];e.descendants(e=>{if(!e.isText||!e.text)return!0;let n=e.marks.map(e=>e.type.name);return n.some(e=>mn.has(e))&&!(t.preserveMathSource&&n.includes(`mdMath`))||r.push(e.text),!1}),n.push(r.join(``))}),n.join(`
|
|
32
|
-
`)}function
|
|
28
|
+
`).map((e,n)=>n===0?e:Tc(e,t)).join(`
|
|
29
|
+
`)}function Dc(e,t,n){return e.paragraph(Ec(t,n))}function Oc(e,t,n){let r=t.from,i=t.to,a=Q(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===V.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,I(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),Dc(e,o,a)}return Dc(e,n.slice(r,i),a)}function kc(e,t,n){let r=Q(n,t.from),i=Ec(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function Ac(e,t,n){let r=[];if(t.firstChild()){let i;do{if(t.type.id===V.QuoteMark)continue;i!=null&&xc(r,e,n,i,t.from),i=t.to,r.push(...Sc(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function jc(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===V.ListItem&&i.push(Mc(e,t,n,r));while(t.nextSibling());t.parent()}return i}function Mc(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==V.ListMark&&u==null&&(u=Q(n,t.from)),t.type.id===V.ListMark){if(r===`ordered`){let e=n.charCodeAt(t.to-1);e===41?c=`)`:e===46&&(c=`.`);let r=Number.parseInt(n.slice(t.from,t.to),10);s=Number.isFinite(r)?r:1}else{let e=n.charCodeAt(t.from);c=e===42?`*`:e===43?`+`:`-`}l=Q(n,t.to);continue}if(r===`bullet`&&t.type.id===V.Task){let r=t.from,s=t.to;if(a=!1,t.firstChild()){if(t.type.id===V.TaskMarker){let e=n.charCodeAt(t.from+1);e===120?(a=!0,o=`x`):e===88&&(a=!0,o=`X`),r=t.to}t.parent()}I(n.charCodeAt(r))&&(r+=1);let c=n.slice(r,s);i.push(Dc(e,c,Q(n,r)));continue}i.push(...Sc(e,t,n))}while(t.nextSibling());t.parent()}let d=u!=null&&l!=null?u-l:1,f=a!=null,p=!f&&r===`bullet`&&c===`+`;return e.list({kind:f?`task`:r,order:r===`ordered`?s??1:null,checked:a??!1,collapsed:p,marker:p?null:c,taskMarker:o,markerGap:d>=2&&d<=4?d:1},i)}function Nc(e,t,n){let r=t.type.id===V.CodeBlock,i=``,a=``,o=r?`indented`:null,s=null,c=!1;if(t.firstChild()){do switch(t.type.id){case V.CodeMark:{if(c)break;c=!0,n.charCodeAt(t.from)===126&&(o=`tilde`);let e=t.to-t.from;e>3&&(s=e);break}case V.CodeInfo:i=n.slice(t.from,t.to);break;case V.CodeText:a+=n.slice(t.from,t.to);break}while(t.nextSibling());t.parent()}return e.codeBlock({language:i,fenceStyle:o,fenceLength:s},a)}function Pc(e,t,n){let r=``;if(t.firstChild()){do t.type.id===V.CodeText&&(r+=n.slice(t.from,t.to));while(t.nextSibling());t.parent()}return e.codeBlock({language:`math`,fenceStyle:`dollar`,fenceLength:null},r)}function Fc(e,t,n){let r=[];if(t.firstChild()){do t.type.id===V.TableDelimiter&&(r=Ic(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===V.TableHeader?i.push(Lc(e,t,n,!0,r)):a===V.TableRow&&i.push(Lc(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function Ic(e){return e.split(`|`).map(e=>e.trim()).filter(e=>e!==``).map(e=>{let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:t?`left`:n?`right`:null})}function Lc(e,t,n,r,i){let a=i.length,o=Array(a).fill(``);if(t.firstChild()){let e=t.type.id===V.TableDelimiter,r=0;do if(t.type.id===V.TableDelimiter)r++;else if(t.type.id===V.TableCell){let i=r-+!!e;i>=0&&i<a&&(o[i]=n.slice(t.from,t.to).trim().replaceAll(String.raw`\|`,`|`))}while(t.nextSibling());t.parent()}let s=o.map((t,n)=>{let a=e.paragraph(t),o={align:i[n]};return r?e.tableHeaderCell(o,a):e.tableCell(o,a)});return e.tableRow(s)}function Rc(e){return e.replace(/\n+$/u,``)}function zc(e){return/^[\s>]*$/u.test(e)}function Bc(e){return e.split(`
|
|
30
|
+
`).filter(e=>!zc(e))}function Vc(e){return e.trim().replaceAll(/\s+/gu,` `)}const Hc=/^:?-+:?$/u;function Uc(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`:-:`:t?`:--`:n?`--:`:`---`}function Wc(e){if(!e.includes(`|`))return;let t=/^[\s>]*/u.exec(e)?.[0]??``,n=e.slice(t.length).trim().replace(/^\|/u,``).replace(/\|$/u,``).split(`|`).map(e=>Vc(e));return Vc(`${t} | ${(n.every(e=>Hc.test(e))?n.map(Uc):n).join(` | `)} |`)}function Gc(e){return Wc(e)??Vc(e)}function Kc(e,t={}){let n=er(X(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(Rc(n)===Rc(e))return`exact`;let r=Bc(e),i=Bc(n);return r.length===i.length&&r.every((e,t)=>Gc(e)===Gc(i[t]))?`normalizing`:`lossy`}const qc=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||!P(n.parent,`heading`)||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=te(e.schema,`list`),i=te(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(x.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function Jc(){return v(l({Enter:qc}),t.high)}const Yc=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`,`Mathematica`]),Xc=Ue.map(e=>({label:e.name,value:e.name.toLowerCase()})).filter(e=>!Yc.has(e.label)).concat([{label:`Plain text`,value:``},{label:`Math`,value:`math`},{label:`Mermaid`,value:`mermaid`}]).sort((e,t)=>e.label.localeCompare(t.label));function Zc(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const Qc=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,$c=/\/status(?:es)?\/(\d+)/;function el(e){let t;try{t=new URL(e)}catch{return}if(Qc.test(t.hostname))return $c.exec(t.pathname)?.[1]}const tl=e=>{let t=el(e);if(!t)return;let n=Zc()?`dark`:`light`;return{kind:`tweet`,key:`tweet:${t}`,src:`https://platform.twitter.com/embed/Tweet.html?id=${t}&theme=${n}&dnt=true`,title:`Tweet`,className:`md-embed md-embed-tweet`,testid:`tweet-embed`}};function nl(e){let t=t=>{if(t.source===e.contentWindow)try{let n=t.data?.[`twttr.embed`]?.params?.[0]?.height;typeof n==`number`&&(e.style.height=`${n}px`)}catch(e){console.warn(`[meowdown] failed to parse tweet resize message:`,e)}};window.addEventListener(`message`,t);let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`message`,t),i.disconnect())},i=new MutationObserver(()=>{e.isConnected||r()});return i.observe(document.body,{childList:!0,subtree:!0}),r}const rl=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,il=/^(?:www\.)?youtu\.be$/i,al=/^[\w-]{11}$/;function ol(e){let t;try{t=new URL(e)}catch{return}let n=null;if(il.test(t.hostname))n=t.pathname.slice(1);else if(rl.test(t.hostname)){let[,e,r]=t.pathname.split(`/`);t.pathname===`/watch`?n=t.searchParams.get(`v`):(e===`shorts`||e===`embed`||e===`live`)&&(n=r??null)}if(!n||!al.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?sl(r):void 0;return{videoId:n,startSeconds:i}}function sl(e){if(/^\d+$/.test(e))return Number(e);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);if(!(!t||!t[1]&&!t[2]&&!t[3]))return Number(t[1]??0)*3600+Number(t[2]??0)*60+Number(t[3]??0)}const cl=[e=>{let t=ol(e);if(!t)return;let n=t.startSeconds?`?start=${t.startSeconds}`:``;return{kind:`youtube`,key:`youtube:${t.videoId}:${t.startSeconds??0}`,src:`https://www.youtube-nocookie.com/embed/${t.videoId}${n}`,title:`YouTube video`,className:`md-embed md-embed-youtube`,testid:`youtube-embed`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen`,allowFullscreen:!0}},tl];function ll(e){for(let t of cl){let n=t(e);if(n)return n}}function ul(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
|
|
31
|
+
`)}const dl=new b(`meowdown-embed-paste`);function fl(e){let t=e.trim();if(!(!t||/\s/.test(t)))return ll(t)?t:void 0}function pl(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(It(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(``,n,n+t.length);e.dispatch(It(i))}function ml(){return m(new y({key:dl,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=ul(t,n);if(!i)return!1;let a=fl(i);return a?(pl(e,a),!0):!1}}}))}const hl=new b(`meowdown-exit-boundary`);function gl(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):void 0:i;return!!(a&&Oe.findFrom(a,t))}function _l(e,t){let{state:n}=e,{selection:r}=n;return g(r)&&!r.empty||ne(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:gl(n,t)}function vl(e){return new y({key:hl,props:{handleKeyDown:(t,n)=>{if(n.shiftKey||n.altKey||n.ctrlKey||n.metaKey)return!1;let r=n.key===`ArrowUp`?-1:n.key===`ArrowDown`?1:void 0;return!(!r||_l(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function yl(e){return v(m(vl(e)),t.low)}const bl=new Set([`avif`,`bmp`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]);function xl(e){if(e.type?.startsWith(`image/`))return!0;let t=e.name.lastIndexOf(`.`);if(t===-1)return!1;let n=e.name.slice(t+1).toLowerCase();return bl.has(n)}function Sl(e,t){return xl(e)?``:`[${Tl(e.name)}](${t})`}function Cl(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const wl=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function Tl(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function El(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??wl,o=r,s=!1;for(let n of t){let t;try{t=await i(n)}catch(e){a(e,n);continue}if(!t||e.isDestroyed)continue;let r=Sl(n,t),c=s?`\n${r}`:r,l=o==null?e.state.tr.insertText(c):e.state.tr.insertText(c,o);e.dispatch(l),s=!0,o!=null&&(o+=c.length)}}function Dl(e){return new y({key:new b(`file-paste`),props:{handlePaste:(t,n)=>{let r=Cl(n.clipboardData,e);return r.length===0?!1:(El(t,r,e),!0)},handleDrop:(t,n)=>{let r=Cl(n.dataTransfer,e);return r.length===0?!1:(El(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function Ol(e={}){return v(m(Dl(e)),t.high)}const kl=new b(`meowdown-file-click`);function Al(e,t){let n=O(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function jl(e){return m(new y({key:kl,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-file-view-preview`);if(!i)return!1;let a=i.closest(`.md-file-view`)?.querySelector(`.md-file-view-content`);if(!a)return!1;let o=Al(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const Ml=[`KB`,`MB`,`GB`,`TB`];function Nl(e){let t=e,n=`B`;for(let e of Ml){if(t<999.5)break;t/=1e3,n=e}return n===`B`?`${Math.round(t)} B`:`${t<9.95?Math.round(t*10)/10:Math.round(t)} ${n}`}const Pl=new Map([[`pdf`,`pdf`],[`zip`,`archive`],[`tar`,`archive`],[`gz`,`archive`],[`tgz`,`archive`],[`rar`,`archive`],[`7z`,`archive`],[`doc`,`doc`],[`docx`,`doc`],[`pages`,`doc`],[`xls`,`sheet`],[`xlsx`,`sheet`],[`csv`,`sheet`],[`numbers`,`sheet`],[`ppt`,`slides`],[`pptx`,`slides`],[`key`,`slides`],[`mp3`,`audio`],[`wav`,`audio`],[`m4a`,`audio`],[`flac`,`audio`],[`ogg`,`audio`],[`mp4`,`video`],[`mov`,`video`],[`mkv`,`video`],[`webm`,`video`],[`txt`,`text`],[`md`,`text`]]);function Fl(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return Pl.get(r)??`generic`}const Il=`http://www.w3.org/2000/svg`;function Ll(){let e=document.createElementNS(Il,`svg`);e.setAttribute(`class`,`md-file-view-icon`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`aria-hidden`,`true`);for(let t of[`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,`M14 2v4a2 2 0 0 0 2 2h4`]){let n=document.createElementNS(Il,`path`);n.setAttribute(`d`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}return e}var Rl=class{#e;#t;#n;#r;#i;#a;#o=!1;constructor(e,t){this.#a=e.attrs,this.#e=document.createElement(`span`),this.#e.className=`md-file-view md-atom-view`,this.#n=document.createElement(`span`),this.#n.className=`md-file-view-preview md-atom-view-preview`,this.#n.contentEditable=`false`,this.#n.dataset.testid=`file-pill`,this.#n.dataset.fileKind=Fl(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(Ll()),this.#r=document.createElement(`span`),this.#r.className=`md-file-view-name`,this.#r.textContent=this.#a.name,this.#n.appendChild(this.#r),this.#i=document.createElement(`span`),this.#i.className=`md-file-view-size`,this.#i.dataset.testid=`file-pill-size`,this.#n.appendChild(this.#i),this.#t=document.createElement(`span`),this.#t.className=`md-file-view-content md-atom-view-content`,this.#e.appendChild(this.#t),this.#s(t.resolveFileInfo)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#a;return t.href===n.href?(this.#a=t,t.name!==n.name&&(this.#r.textContent=t.name,this.#n.title=t.name),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}destroy(){this.#o=!0}async#s(e){if(!e)return;let t;try{t=await e(this.#a.href)}catch(e){console.error(`[meowdown] resolveFileInfo failed:`,e);return}if(this.#o||!t)return;let{size:n}=t;n==null||!Number.isFinite(n)||n<0||(this.#i.textContent=Nl(n))}};function zl(e={}){return d({name:`mdFile`,constructor:t=>new Rl(t,e)})}function Bl(e){return m(new y({key:e.key,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(e.selector);if(!i)return!1;let a=e.findPayloadForElement?e.findPayloadForElement(t,i):e.findPayloadAt(t.state,n);return a==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(a,r),!0)}}}))}const Vl=new b(`meowdown-tag-click`);function Hl(e,t){let n=O(e,t,`mdTag`);if(!n)return;let r=e.doc.textBetween(n.from,n.to),i=r.startsWith(`#`)?r.slice(1):r;return{from:n.from,to:n.to,tag:i}}function Ul(e){return Bl({key:Vl,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>Hl(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const Wl=new b(`meowdown-wikilink-click`);function Gl(e,t){let n=O(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Kl(e,t){let n=t.closest(`.md-wikilink-view`)?.querySelector(`.md-wikilink-view-content`);if(n)return Gl(e.state,e.posAtDOM(n,0))}function ql(e){return Bl({key:Wl,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>Gl(e,t)?.target,findPayloadForElement:(e,t)=>Kl(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const Jl=new b(`meowdown-follow-link`);function Yl(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:re?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Xl(e){return new y({key:Jl,props:{handleKeyDown:(t,n)=>{if(!Yl(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&Gl(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&Hl(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&Al(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&G(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Zl(e){return v(m(Xl(e)),t.high)}const Ql=new b(`meowdown-image-click`);function $l(e){return e instanceof HTMLElement&&e.closest(`.md-image-view-preview`)}function eu(e,t){let n=O(e,t,`mdImage`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function tu(e,t){let n=t.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(n)return eu(e.state,e.posAtDOM(n,0))}function nu(e,t){return Array.from(e).find(e=>e.identifier===t)}function ru(e,t){return Math.abs(t.clientX-e.clientX)<=10&&Math.abs(t.clientY-e.clientY)<=10}function iu(e){let t=new WeakMap;return m(new y({key:Ql,props:{handleDOMEvents:{pointerdown:(e,t)=>($l(t.target)&&t.pointerType!==`mouse`&&t.preventDefault(),!1),touchstart:(e,n)=>{if(t.delete(e),n.touches.length!==1||!$l(n.target)||n.target instanceof HTMLElement&&n.target.closest(`.md-image-resize-handle`))return!1;let r=n.changedTouches[0];return r&&t.set(e,{identifier:r.identifier,clientX:r.clientX,clientY:r.clientY}),!1},touchmove:(e,n)=>{let r=t.get(e);if(!r)return!1;let i=nu(n.changedTouches,r.identifier);return i&&!ru(r,i)&&t.delete(e),!1},touchcancel:e=>(t.delete(e),!1),touchend:(n,r)=>{let i=t.get(n);if(t.delete(n),!i||r.touches.length>0)return!1;let a=nu(r.changedTouches,i.identifier);if(!a||!ru(i,a))return!1;let o=$l(r.target);if(!o)return!1;r.preventDefault();let s=tu(n,o);return s&&e({src:s.src,alt:s.alt,event:r}),!0}},handleClick:(t,n,r)=>{let i=$l(r.target);if(!i)return!1;let a=tu(t,i);return a?(e({src:a.src,alt:a.alt,event:r}),!0):!1}}}))}function au(e){return/^https?:\/\//i.test(e)?e:void 0}function ou(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&nl(t),t}function su(e,t,n,r){if(n!=null&&r!=null){e.setAttribute(`data-width`,String(n)),e.setAttribute(`data-height`,String(r));return}let i=t.naturalWidth/t.naturalHeight;if(!Number.isFinite(i)||i<=0){n!=null&&e.setAttribute(`data-width`,String(n)),r!=null&&e.setAttribute(`data-height`,String(r));return}let a=n==null?Math.min(t.naturalHeight,500):n/i,o=n??a*i;e.setAttribute(`data-width`,String(Math.round(o))),e.setAttribute(`data-height`,String(Math.round(a)))}function cu(e,t,n,r){let i=e.posAtDOM(t,0),a=O(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=a.mark.attrs;if(s.syntax===`wikiEmbed`){let t=s.wikiTarget||da(o).target;if(!t)return;let i=fa(t,n,r);i!==o&&e.dispatch(e.state.tr.insertText(i,a.from,a.to));return}let c=ca(o),l=a.from+c.length,u=o.slice(c.length),d=sa({...aa(u)??{},width:Math.round(n),height:Math.round(r)});d!==u&&e.dispatch(e.state.tr.insertText(d,l,a.to))}var lu=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n){this.#i=e.attrs,this.#n=n,this.#r=t,this.#e=document.createElement(`span`),this.#e.className=`md-image-view md-atom-view`,this.#t=document.createElement(`span`),this.#t.className=`md-image-view-content md-atom-view-content`;let r=this.#s();r&&(r.contentEditable=`false`,this.#e.appendChild(r)),this.#e.appendChild(this.#t)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#i;return t.src===n.src?(this.#i=t,this.#o&&t.alt!==n.alt&&(this.#o.alt=t.alt),this.#a&&this.#o&&(t.width!==n.width||t.height!==n.height)&&su(this.#a,this.#o,t.width,t.height),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}#s(){let{src:e}=this.#i,t=ll(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(ou(t)),e}let n=(this.#n.resolveImageUrl??au)(e);if(!n)return;let r=document.createElement(`span`);return r.className=`md-image-view-preview md-atom-view-preview`,r.dataset.testid=`image-preview`,r.appendChild(this.#c(n)),r}#c(e){Rt(),Lt();let t=document.createElement(`prosekit-resizable-root`);t.className=`md-image-resizable`,t.dataset.testid=`image-resizable`,t.setAttribute(`data-loading`,``);let n=document.createElement(`img`);n.src=e,n.alt=this.#i.alt,n.draggable=!1,su(t,n,this.#i.width,this.#i.height),n.addEventListener(`load`,()=>{t.removeAttribute(`data-loading`);let e=n.naturalWidth/n.naturalHeight;!Number.isFinite(e)||e<=0||(t.setAttribute(`data-aspect-ratio`,String(e)),su(t,n,this.#i.width,this.#i.height))}),n.addEventListener(`error`,()=>{t.removeAttribute(`data-loading`)}),t.appendChild(n);let r=document.createElement(`prosekit-resizable-handle`);return r.className=`md-image-resize-handle`,r.setAttribute(`position`,`bottom-right`),r.addEventListener(`click`,e=>e.stopPropagation()),t.appendChild(r),t.addEventListener(`resizeEnd`,e=>{let{width:t,height:n}=e.detail;cu(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function uu(e={}){return d({name:`mdImage`,constructor:(t,n)=>new lu(t,n,e)})}const du={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-k":`Link`,"Mod-Shift-k":`Insert a wikilink`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`,"Mod-.":`Fold or unfold a bullet`,"Mod-Enter":`Follow the link under the caret, or cycle a checkbox task`,"Mod-Shift-Enter":`Cycle a circle checkbox task`,"Mod-Shift-7":`Ordered list`,"Mod-Shift-8":`Bullet list`,"Mod-Shift-9":`Checkbox task list`,"Alt-ArrowUp":`Move the block or list item up`,"Alt-ArrowDown":`Move the block or list item down`,"Meta-ArrowUp":`Move the caret to the document start`,"Meta-ArrowDown":`Move the caret to the document end`,"Shift-Meta-ArrowUp":`Select to the document start`,"Shift-Meta-ArrowDown":`Select to the document end`,Escape:`Collapse the selection`},fu=new b(`meowdown-link-click`);function pu(e){return Bl({key:fu,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>G(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function mu(e){let t,n=(t,n)=>e.findPayloadForElement?e.findPayloadForElement(t,n):e.findPayloadAt(t.state,t.posAtDOM(n,0)),r=()=>{t&&(t=void 0,e.onHoverChange(void 0))},i=(i,a)=>{let o=a.target;if(!o||!_e(o))return;let s=o.closest(e.selector);if(!s||!i.dom.contains(s)||s===t?.element)return;r();let c=n(i,s);c!=null&&(t={payload:c,element:s},e.onHoverChange(t))},a=e=>{if(!t)return;let n=e.relatedTarget;n instanceof Node&&t.element.contains(n)||r()};return m(new y({key:e.key,props:{handleDOMEvents:{mouseover:(e,t)=>(i(e,t),!1),mouseout:(e,t)=>(a(t),!1)}},view:()=>({update:i=>{if(!t)return;if(!t.element.isConnected||!i.dom.contains(t.element)){r();return}let a=n(i,t.element);if(a==null||!e.isSamePayload(t.payload,a)){r();return}t={...t,payload:a}},destroy:r})}))}const hu=new b(`meowdown-link-hover`);function gu(e){return mu({key:hu,selector:`.md-link`,findPayloadAt:(e,t)=>G(e,t),isSamePayload:(e,t)=>e.href===t.href&&e.title===t.title,onHoverChange:e})}const _u=new b(`meowdown-link-paste`);function vu(e){let t=e.trim();if(!(!t||/\s/.test(t)))return ki(t)}function yu(){return v(m(new y({key:_u,props:{handlePaste:(e,t,n)=>{let r=ul(t,n);if(!r)return!1;let i=vu(r);return i?Xr(e,xo({href:i,wrapText:!1})):!1}}})),t.high)}const bu=[[/<-/,`←`],[/(?<!-)->/,`→`],[/\(c\)/,`©`],[/\(r\)/,`®`],[/1\/2/,`½`],[/\+\/-/,`±`],[/!=/,`≠`],[/<</,`«`],[/>>/,`»`],[/(?<!<!)(?<!^(?:-[ \t]*)+)--/,`—`]],$=new b(`meowdown-substitution-undo`);function xu(e,t,n){let r=ee(e.schema,`mdCode`);return e.doc.rangeHasMark(t,n,r)}function Su(e,t,n,r,i){if(xu(e,t,n))return null;let[,a]=r,o=i==null?a:`${a} `,s=e.tr.replaceWith(t,n,e.schema.text(o));return i!=null&&s.setMeta($,{from:t,to:t+o.length,before:i,after:o}),s}function Cu(){return _(bu.map(e=>Ye(new zt(new RegExp(String.raw`(?:${e[0].source})\s$`),(t,n,r,i)=>Su(t,r,i,e,n[0])))))}function wu(){return m(new y({key:$,state:{init:()=>null,apply:(e,t)=>{let n=e.getMeta($);if(n!==void 0)return n;if(!t)return null;let r=e.mapping.map(t.from),i=e.mapping.map(t.to);return e.selection.empty&&e.selection.from===i&&e.doc.textBetween(r,i)===t.after?{...t,from:r,to:i}:null}}}))}function Tu(){return v(l({Backspace:(e,t)=>{let n=$.getState(e);return n?(t?.(e.tr.replaceWith(n.from,n.to,e.schema.text(n.before)).setMeta($,null)),!0):!1}}),t.highest)}function Eu(){return _(wu(),Tu())}function Du(){return _(bu.map(e=>qe({regex:RegExp(`(?:${e[0].source})$`),handler:({state:t,from:n,to:r})=>Su(t,n,r,e)})))}function Ou(){return _(Cu(),Eu(),Du())}const ku=new b(`meowdown-wikilink-hover`);function Au(e){return mu({key:ku,selector:`.md-wikilink-view-preview`,findPayloadAt:Gl,findPayloadForElement:Kl,isSamePayload:(e,t)=>e.target===t.target,onHoverChange:t=>{e(t?{...t.payload,element:t.element}:void 0)}})}function ju(e,t={}){let n=[];return e.content.forEach(e=>{let r=[];e.descendants(e=>{if(!e.isText||!e.text)return!0;let n=e.marks.map(e=>e.type.name);return n.some(e=>hn.has(e))&&!(t.preserveMathSource&&n.includes(`mdMath`))||r.push(e.text),!1}),n.push(r.join(``))}),n.join(`
|
|
32
|
+
`)}function Mu({allowEmpty:e}){return(t,n)=>{let{selection:r}=t;if(!g(r)||!e&&r.empty||!r.$head.sameParent(r.$anchor)||r.$head.parent.type.spec.code)return!1;let i=ju(r.content());if(i.startsWith(`[[`))return!1;i.startsWith(`[`)&&(i=i.slice(1));let a=`[[`+i;if(n){let e=t.tr.insertText(a,r.from,r.to);e.setSelection(x.create(e.doc,r.from+a.length)),Ze(e),n(e.scrollIntoView())}return!0}}function Nu(){return l({"Mod-Shift-k":Mu({allowEmpty:!0}),"[":Mu({allowEmpty:!1})})}function Pu(e){switch(e.type.name){case`mdWikilink`:{let t=e.attrs;return t.display||t.target}case`mdImage`:return e.attrs.alt;case`mdFile`:return e.attrs.name;case`mdMath`:return e.attrs.formula;default:return``}}function Fu(e){let t=``;for(let n of yn(e)){if(n.atom!=null){t+=Pu(n.atom);continue}for(let e of n.children)vn(e.marks)||(t+=e.text??``)}return t}function Iu(e){let{selection:t,schema:n}=e;if(t.empty)return``;let r=t.content().content;try{return er(n.topNodeType.create(null,r)).replace(/\n+$/,``)}catch{return e.doc.textBetween(t.from,t.to,`
|
|
33
33
|
|
|
34
|
-
`)}}function
|
|
34
|
+
`)}}function Lu(e,t,n){if(n===1){let r=B(e.state,t);return r&&J(e,r.to,n)}else{let n=z(e.state,t);return n&&J(e,n.from,-1)}}function Ru(e,t){let n=new DOMRect(0,0,0,0),r=()=>{if(e.isDestroyed)return n;let r=J(e,t.from,1)??Us(e,t.from,1)??Lu(e,t.from,1)??J(e,t.from,-1);if(r==null)return n;let i=J(e,t.to,-1)??Us(e,t.to,-1)??Lu(e,t.to,-1)??J(e,t.to,1);if(i==null)return n;let a=Math.min(r.left,i.left),o=Math.max(r.right,i.right),s=Math.min(r.top,i.top),c=Math.max(r.bottom,i.bottom);return n=new DOMRect(a,s,o-a,c-s),n};return{getBoundingClientRect:r,getClientRects:()=>[r()]}}function zu(e){return e instanceof ct||e instanceof lt||e instanceof ut||e instanceof dt||e instanceof Ci}function Bu(e){for(let t of e)for(let e of t.steps)if(!zu(e))return!0;return!1}function Vu(e){let t,n,r=!1,i,a=()=>{let n=t&&!t.isDestroyed&&t.dom;if(!n)return;let a=e&&!r;a!==i&&(i=a,n.spellcheck=a)},o=()=>{n&&clearTimeout(n),r=!0,a(),n=setTimeout(()=>{r=!1,a()},1200)};return{pause:o,apply(e){Bu(e)&&o()},view(e){return t=e,{destroy(){t=void 0}}}}}function Hu(e){let t=new b(`spell-check`);return new y({key:t,state:{init:()=>Vu(e),apply:(e,t)=>t},view(e){return t.getState(e.state)?.view(e)||{}},props:{handleDOMEvents:{beforeinput:e=>{t.getState(e.state)?.pause()}}},appendTransaction(e,n){t.getState(n)?.apply(e)}})}function Uu(e){return m(Hu(e))}export{du as EDITOR_KEY_BINDINGS,e as Priority,Sl as buildFileMarkdown,Kc as checkRoundTrip,Xc as codeBlockLanguages,au as defaultResolveImageUrl,Jc as defineBulletAfterHeading,pe as defineCodeBlockPreviewPlugin,Ar as defineCodeBlockSyntaxHighlight,uc as defineEditorExtension,ml as defineEmbedPaste,yl as defineExitBoundaryHandler,jl as defineFileClickHandler,Ol as defineFilePaste,zl as defineFileView,Zl as defineFollowLinkHandler,yi as defineHTMLComment,uu as defineImage,iu as defineImageClickHandler,pu as defineLinkClickHandler,wo as defineLinkCommands,Eo as defineLinkEditKeymap,gu as defineLinkHoverHandler,yu as defineLinkPaste,rs as defineMath,Rs as definePendingReplacementHandler,he as definePlaceholder,ge as defineReadonly,Uu as defineSpellCheckPlugin,Ou as defineSubstitution,Ul as defineTagClickHandler,ql as defineWikilinkClickHandler,Au as defineWikilinkHoverHandler,Nu as defineWikilinkTrigger,er as docToMarkdown,Nl as formatFileSize,fa as formatSizedWikiEmbed,Mr as getCodeTokens,Fl as getFileKind,G as getLinkUnitAt,pc as getMarkBuilders,q as getPendingReplacement,Iu as getSelectedText,gs as getTableColumnAlign,Fu as getTextblockDisplayText,Ru as getVirtualElementFromRange,va as inlineTextToMarkChunks,xo as insertLink,me as isCodeBlockPreviewHiddenDecoration,mn as isMarkOfType,P as isNodeOfType,ys as isSelectionInTableCell,nl as listenForTweetHeight,es as loadKaTeX,X as markdownToDoc,ll as matchEmbed,da as parseWikiEmbed,Co as removeLink,ts as renderMathInto,So as updateLink,pa as wikiEmbedBasename,le as withPriority};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{render as e}from"katex";export{e as render};
|
package/dist/style.css
CHANGED
|
@@ -162,6 +162,9 @@
|
|
|
162
162
|
--meowdown-border: light-dark(oklch(92% .004 286), oklch(37% .012 286));
|
|
163
163
|
--meowdown-blockquote-border: color-mix(in oklab, var(--meowdown-accent) 35%, transparent);
|
|
164
164
|
--meowdown-code-bg: light-dark(oklch(96.7% 0 0), oklch(21% .006 286));
|
|
165
|
+
--meowdown-mermaid-bg: var(--meowdown-code-bg);
|
|
166
|
+
--meowdown-mermaid-fg: var(--meowdown-text);
|
|
167
|
+
--meowdown-mermaid-error: var(--meowdown-danger);
|
|
165
168
|
--meowdown-image-loading-bg: light-dark(oklch(96.7% 0 0), oklch(27.4% .005 286));
|
|
166
169
|
--meowdown-image-radius: .5rem;
|
|
167
170
|
--meowdown-file-pill-bg: light-dark(oklch(98.5% 0 0), oklch(21% .006 286));
|