CI / test-parser (push) Successful in 9m25s
CI / test-core (push) Successful in 9m33s
CI / test-rest (push) Successful in 9m27s
CI / e2e (push) Successful in 9m43s
CI / verify (18.x) (push) Successful in 9m52s
CI / verify (20.x) (push) Successful in 9m52s
CI / verify (24.x) (push) Successful in 9m45s
2 lines
146 KiB
JavaScript
2 lines
146 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MeEditor={})}(this,function(e){"use strict";const t=e=>{const t=String(null==e?"":e);if("undefined"==typeof document)return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");const n=document.createElement("div");return n.textContent=t,n.innerHTML},n=e=>String(null==e?"":e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),r={bold:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/></svg>',italic:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>',underline:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>',strikethrough:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M17.3 19c.6-1.2 1-2.5 1-3.8 0-4.3-3.5-7.2-7.3-7.2-3.8 0-7.3 2.9-7.3 7.2 0 1.3.4 2.6 1 3.8"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',h1:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M17 12l3-2v8"/></svg>',h2:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M19 12v4"/><path d="M22 12h-4"/></svg>',h3:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M21 18h-4c0-2 1-3 3-3s2 1 2 3"/></svg>',quote:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>',code:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',link:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>',image:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',table:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',ul:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>',ol:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 14h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>',indent:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 8 7 12 3 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/></svg>',outdent:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="7 8 3 12 7 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/></svg>',hr:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="12" x2="21" y2="12"/></svg>',undo:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',redo:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg>',preview:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',split:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/></svg>',edit:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',fullscreen:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>',theme:'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>'},i={"zh-CN":{bold:"粗体",italic:"斜体",underline:"下划线",strikethrough:"删除线",h1:"标题1",h2:"标题2",h3:"标题3",quote:"引用",code:"代码",link:"链接",image:"图片",table:"表格",ul:"无序列表",ol:"有序列表",indent:"增加缩进",outdent:"减少缩进",hr:"分隔线",undo:"撤销",redo:"重做",edit:"编辑",split:"分屏",preview:"预览",fullscreen:"全屏",fullscreenExit:"退出全屏",theme:"主题",light:"亮色",dark:"暗色",auto:"自动",warm:"暖色",wordCount:"字数统计",characters:"字符",words:"词数",lines:"行数",readingTime:"阅读",minutes:"分钟",placeholder:"开始输入 Markdown...",empty:"暂无内容",copied:"已复制",copyContent:"复制内容",copyHTML:"复制 HTML",copySuccess:"复制成功",copyFailed:"复制失败",clearContent:"清空内容",clearConfirm:"确定要清空所有内容吗?",linkPlaceholder:"请输入链接地址",imagePlaceholder:"请输入图片地址",altPlaceholder:"请输入替代文本",tableRows:"行数",tableCols:"列数",confirm:"确认",cancel:"取消",exportMarkdown:"导出 Markdown",exportHTML:"导出 HTML",search:"搜索",replace:"替换",replaceAll:"全部替换",searchPlaceholder:"查找内容",replacePlaceholder:"替换为",findNext:"查找下一个",findPrev:"查找上一个",matchCase:"区分大小写",wholeWord:"全字匹配",close:"关闭",open:"打开",save:"保存",saved:"已保存",saving:"保存中...",delete:"删除",confirmDelete:"确定要删除吗?",unsavedChanges:"有未保存的更改",error:"错误",success:"成功",warning:"警告",info:"信息",loading:"加载中...",retry:"重试",renderError:"渲染失败",outline:"大纲",cut:"剪切",copy:"复制",paste:"粘贴",selectAll:"全选",regex:"正则表达式",shortcuts:"快捷键",imageTooLarge:"图片过大({size}KB > {max}KB)",formatToolbar:"格式化选区",pasteBlocked:"无法直接粘贴,请使用 Ctrl+V"},"en-US":{bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",quote:"Quote",code:"Code",link:"Link",image:"Image",table:"Table",ul:"Bullet List",ol:"Numbered List",indent:"Indent",outdent:"Outdent",hr:"Horizontal Rule",undo:"Undo",redo:"Redo",edit:"Edit",split:"Split",preview:"Preview",fullscreen:"Fullscreen",fullscreenExit:"Exit Fullscreen",theme:"Theme",light:"Light",dark:"Dark",auto:"Auto",warm:"Warm",wordCount:"Word Count",characters:"Characters",words:"Words",lines:"Lines",readingTime:"Reading",minutes:"min",placeholder:"Start typing Markdown...",empty:"No content",copied:"Copied",copyContent:"Copy Content",copyHTML:"Copy HTML",copySuccess:"Copied successfully",copyFailed:"Copy failed",clearContent:"Clear Content",clearConfirm:"Clear all content?",linkPlaceholder:"Enter link URL",imagePlaceholder:"Enter image URL",altPlaceholder:"Enter alt text",tableRows:"Rows",tableCols:"Columns",confirm:"Confirm",cancel:"Cancel",exportMarkdown:"Export Markdown",exportHTML:"Export HTML",search:"Search",replace:"Replace",replaceAll:"Replace All",searchPlaceholder:"Find",replacePlaceholder:"Replace with",findNext:"Find Next",findPrev:"Find Previous",matchCase:"Match Case",wholeWord:"Whole Word",close:"Close",open:"Open",save:"Save",saved:"Saved",saving:"Saving...",delete:"Delete",confirmDelete:"Are you sure you want to delete?",unsavedChanges:"You have unsaved changes",error:"Error",success:"Success",warning:"Warning",info:"Info",loading:"Loading...",retry:"Retry",renderError:"Render failed",outline:"Outline",cut:"Cut",copy:"Copy",paste:"Paste",selectAll:"Select All",regex:"Regex",shortcuts:"Shortcuts",imageTooLarge:"Image too large ({size}KB > {max}KB)",formatToolbar:"Format selection",pasteBlocked:"Cannot paste directly, use Ctrl+V"},ja:{bold:"太字",italic:"斜体",underline:"下線",strikethrough:"打ち消し線",h1:"見出し1",h2:"見出し2",h3:"見出し3",quote:"引用",code:"コード",link:"リンク",image:"画像",table:"表",ul:"箇条書き",ol:"番号付きリスト",indent:"インデント",outdent:"インデント解除",hr:"水平線",undo:"元に戻す",redo:"やり直し",edit:"編集",split:"分割",preview:"プレビュー",fullscreen:"全画面",fullscreenExit:"全画面解除",theme:"テーマ",light:"ライト",dark:"ダーク",auto:"自動",warm:"ウォーム",wordCount:"文字数",characters:"文字",words:"単語",lines:"行",readingTime:"読了時間",minutes:"分",placeholder:"Markdownを入力...",empty:"内容なし",copied:"コピー済み",copyContent:"内容をコピー",copyHTML:"HTMLをコピー",copySuccess:"コピー成功",copyFailed:"コピー失敗",clearContent:"内容をクリア",clearConfirm:"すべての内容をクリアしますか?",linkPlaceholder:"リンクURLを入力",imagePlaceholder:"画像URLを入力",altPlaceholder:"代替テキストを入力",tableRows:"行",tableCols:"列",confirm:"確認",cancel:"キャンセル",exportMarkdown:"Markdownエクスポート",exportHTML:"HTMLエクスポート",search:"検索",replace:"置換",replaceAll:"すべて置換",searchPlaceholder:"検索",replacePlaceholder:"置換後",findNext:"次を検索",findPrev:"前を検索",matchCase:"大文字小文字",wholeWord:"単語単位",close:"閉じる",open:"開く",save:"保存",saved:"保存済み",saving:"保存中...",delete:"削除",confirmDelete:"削除してもよろしいですか?",unsavedChanges:"未保存の変更があります",error:"エラー",success:"成功",warning:"警告",info:"情報",loading:"読み込み中...",retry:"再試行",renderError:"レンダリング失敗",outline:"アウトライン",cut:"切り取り",copy:"コピー",paste:"貼り付け",selectAll:"すべて選択",regex:"正規表現",shortcuts:"ショートカット",imageTooLarge:"画像が大きすぎます({size}KB > {max}KB)",formatToolbar:"選択範囲を整形",pasteBlocked:"直接貼り付けできません。Ctrl+V を使用してください"},ko:{bold:"굵게",italic:"기울임",underline:"밑줄",strikethrough:"취소선",h1:"제목1",h2:"제목2",h3:"제목3",quote:"인용",code:"코드",link:"링크",image:"이미지",table:"표",ul:"순서 없는 목록",ol:"순서 있는 목록",indent:"들여쓰기",outdent:"내어쓰기",hr:"수평선",undo:"실행 취소",redo:"다시 실행",edit:"편집",split:"분할",preview:"미리보기",fullscreen:"전체 화면",fullscreenExit:"전체 화면 종료",theme:"테마",light:"라이트",dark:"다크",auto:"자동",warm:"웜",wordCount:"글자 수",characters:"글자",words:"단어",lines:"줄",readingTime:"읽기 시간",minutes:"분",placeholder:"Markdown 입력...",empty:"내용 없음",copied:"복사됨",copyContent:"내용 복사",copyHTML:"HTML 복사",copySuccess:"복사 성공",copyFailed:"복사 실패",clearContent:"내용 지우기",clearConfirm:"모든 내용을 지우시겠습니까?",linkPlaceholder:"링크 URL 입력",imagePlaceholder:"이미지 URL 입력",altPlaceholder:"대체 텍스트 입력",tableRows:"행",tableCols:"열",confirm:"확인",cancel:"취소",exportMarkdown:"Markdown 내보내기",exportHTML:"HTML 내보내기",search:"검색",replace:"바꾸기",replaceAll:"모두 바꾸기",searchPlaceholder:"찾기",replacePlaceholder:"바꿀 내용",findNext:"다음 찾기",findPrev:"이전 찾기",matchCase:"대소문자 구분",wholeWord:"단어 단위",close:"닫기",open:"열기",save:"저장",saved:"저장됨",saving:"저장 중...",delete:"삭제",confirmDelete:"삭제하시겠습니까?",unsavedChanges:"저장되지 않은 변경 사항이 있습니다",error:"오류",success:"성공",warning:"경고",info:"정보",loading:"로딩 중...",retry:"재시도",renderError:"렌더링 실패",outline:"개요",cut:"잘라내기",copy:"복사",paste:"붙여넣기",selectAll:"전체 선택",regex:"정규식",shortcuts:"단축키",imageTooLarge:"이미지가 너무 큽니다 ({size}KB > {max}KB)",formatToolbar:"선택 영역 서식",pasteBlocked:"직접 붙여넣을 수 없습니다. Ctrl+V를 사용하세요"},fr:{bold:"Gras",italic:"Italique",underline:"Souligné",strikethrough:"Barré",h1:"Titre 1",h2:"Titre 2",h3:"Titre 3",quote:"Citation",code:"Code",link:"Lien",image:"Image",table:"Tableau",ul:"Liste à puces",ol:"Liste numérotée",indent:"Indenter",outdent:"Désindenter",hr:"Ligne horizontale",undo:"Annuler",redo:"Rétablir",edit:"Éditer",split:"Fractionné",preview:"Aperçu",fullscreen:"Plein écran",fullscreenExit:"Quitter plein écran",theme:"Thème",light:"Clair",dark:"Sombre",auto:"Auto",warm:"Chaud",wordCount:"Nombre de mots",characters:"Caractères",words:"Mots",lines:"Lignes",readingTime:"Lecture",minutes:"min",placeholder:"Commencez à taper Markdown...",empty:"Aucun contenu",copied:"Copié",copyContent:"Copier le contenu",copyHTML:"Copier HTML",copySuccess:"Copié avec succès",copyFailed:"Échec de la copie",clearContent:"Effacer le contenu",clearConfirm:"Effacer tout le contenu ?",linkPlaceholder:"Entrez l'URL du lien",imagePlaceholder:"Entrez l'URL de l'image",altPlaceholder:"Entrez le texte alternatif",tableRows:"Lignes",tableCols:"Colonnes",confirm:"Confirmer",cancel:"Annuler",exportMarkdown:"Exporter Markdown",exportHTML:"Exporter HTML",search:"Rechercher",replace:"Remplacer",replaceAll:"Tout remplacer",searchPlaceholder:"Rechercher",replacePlaceholder:"Remplacer par",findNext:"Suivant",findPrev:"Précédent",matchCase:"Respecter la casse",wholeWord:"Mot entier",close:"Fermer",open:"Ouvrir",save:"Enregistrer",saved:"Enregistré",saving:"Enregistrement...",delete:"Supprimer",confirmDelete:"Confirmer la suppression ?",unsavedChanges:"Modifications non enregistrées",error:"Erreur",success:"Succès",warning:"Avertissement",info:"Info",loading:"Chargement...",retry:"Réessayer",renderError:"Échec du rendu",outline:"Plan",cut:"Couper",copy:"Copier",paste:"Coller",selectAll:"Tout sélectionner",regex:"Regex",shortcuts:"Raccourcis",imageTooLarge:"Image trop grande ({size}Ko > {max}Ko)",formatToolbar:"Formater la sélection",pasteBlocked:"Impossible de coller directement, utilisez Ctrl+V"},de:{bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",strikethrough:"Durchgestrichen",h1:"Überschrift 1",h2:"Überschrift 2",h3:"Überschrift 3",quote:"Zitat",code:"Code",link:"Link",image:"Bild",table:"Tabelle",ul:"Aufzählung",ol:"Nummerierte Liste",indent:"Einrücken",outdent:"Ausrücken",hr:"Trennlinie",undo:"Rückgängig",redo:"Wiederholen",edit:"Bearbeiten",split:"Geteilt",preview:"Vorschau",fullscreen:"Vollbild",fullscreenExit:"Vollbild beenden",theme:"Design",light:"Hell",dark:"Dunkel",auto:"Auto",warm:"Warm",wordCount:"Wörter",characters:"Zeichen",words:"Wörter",lines:"Zeilen",readingTime:"Lesezeit",minutes:"min",placeholder:"Markdown eingeben...",empty:"Kein Inhalt",copied:"Kopiert",copyContent:"Inhalt kopieren",copyHTML:"HTML kopieren",copySuccess:"Erfolgreich kopiert",copyFailed:"Kopieren fehlgeschlagen",clearContent:"Inhalt löschen",clearConfirm:"Gesamten Inhalt löschen?",linkPlaceholder:"Link-URL eingeben",imagePlaceholder:"Bild-URL eingeben",altPlaceholder:"Alternativtext eingeben",tableRows:"Zeilen",tableCols:"Spalten",confirm:"Bestätigen",cancel:"Abbrechen",exportMarkdown:"Markdown exportieren",exportHTML:"HTML exportieren",search:"Suchen",replace:"Ersetzen",replaceAll:"Alle ersetzen",searchPlaceholder:"Suchen",replacePlaceholder:"Ersetzen mit",findNext:"Nächstes",findPrev:"Vorheriges",matchCase:"Groß-/Kleinschreibung",wholeWord:"Ganzes Wort",close:"Schließen",open:"Öffnen",save:"Speichern",saved:"Gespeichert",saving:"Speichern...",delete:"Löschen",confirmDelete:"Wirklich löschen?",unsavedChanges:"Ungespeicherte Änderungen",error:"Fehler",success:"Erfolg",warning:"Warnung",info:"Info",loading:"Laden...",retry:"Wiederholen",renderError:"Rendern fehlgeschlagen",outline:"Gliederung",cut:"Ausschneiden",copy:"Kopieren",paste:"Einfügen",selectAll:"Alles auswählen",regex:"Regex",shortcuts:"Tastenkürzel",imageTooLarge:"Bild zu groß ({size}KB > {max}KB)",formatToolbar:"Auswahl formatieren",pasteBlocked:"Direktes Einfügen nicht möglich, verwenden Sie Strg+V"}},o=["bold","italic","strikethrough","code","|","h1","h2","h3","|","quote","ul","ol","|","link","image","table","hr","|","undo","redo","|","edit","split","preview","fullscreen"],s=Object.freeze({value:"",placeholder:"",mode:"split",height:400,toolbar:o,wordCount:!0,autofocus:!1,spellcheck:!1,historyLimit:100,historyDebounce:400,syncScroll:!0,tabSize:2,readOnly:!1,lineNumbers:!0,outline:!1,autoBrackets:!0,zenMode:!1,zenMaxWidth:960,wordWrap:!0,maxLength:0,theme:"auto",locale:"zh-CN",render:null,highlight:null,sanitize:null,className:"",style:{},plugins:[],onChange:null,onInput:null,onFocus:null,onBlur:null,onSave:null,onModeChange:null,onFullscreen:null,onCreate:null,onDestroy:null,onLinkClick:null,floatingToolbar:!0}),a={light:{bg:"rgba(255, 255, 255, 0.96)",text:"#1f2937",border:"rgba(0, 0, 0, 0.08)",shadow:"0 10px 36px -10px rgba(0, 0, 0, 0.18), 0 4px 14px -4px rgba(0, 0, 0, 0.08)",hoverShadow:"0 14px 48px -10px rgba(0, 0, 0, 0.22), 0 6px 18px -4px rgba(0, 0, 0, 0.10)",toolbarBg:"rgba(248, 249, 250, 0.92)",textareaBg:"#ffffff",previewBg:"#ffffff",codeBg:"rgba(243, 244, 246, 1)",codeText:"#1f2937",accent:"#3b82f6",muted:"#6b7280"},dark:{bg:"rgba(28, 32, 40, 0.94)",text:"#e6e8eb",border:"rgba(255, 255, 255, 0.1)",shadow:"0 10px 36px -10px rgba(0, 0, 0, 0.6), 0 4px 14px -4px rgba(0, 0, 0, 0.4)",hoverShadow:"0 14px 48px -8px rgba(0, 0, 0, 0.6), 0 6px 18px -4px rgba(0, 0, 0, 0.4)",toolbarBg:"rgba(22, 26, 33, 0.92)",textareaBg:"#1c2028",previewBg:"#1c2028",codeBg:"rgba(15, 18, 24, 1)",codeText:"#e6e8eb",accent:"#60a5fa",muted:"#9ca3af"},auto:"auto",warm:{bg:"rgba(255, 251, 235, 0.96)",text:"#78350f",border:"rgba(245, 158, 11, 0.2)",shadow:"0 10px 36px -10px rgba(245, 158, 11, 0.18), 0 4px 14px -4px rgba(245, 158, 11, 0.08)",hoverShadow:"0 14px 48px -10px rgba(245, 158, 11, 0.22), 0 6px 18px -4px rgba(245, 158, 11, 0.10)",toolbarBg:"rgba(254, 243, 199, 0.92)",textareaBg:"#fffbeb",previewBg:"#fffbeb",codeBg:"rgba(254, 215, 170, 0.6)",codeText:"#78350f",accent:"#d97706",muted:"#a16207",progressBg:"rgba(217, 119, 6, 0.15)",closeHoverBg:"rgba(217, 119, 6, 0.2)"}},l={slide:{enter:{transform:"translateX(80px)",opacity:"0"},leave:{transform:"translateX(120%)",opacity:"0"},duration:400,easing:"cubic-bezier(0.25, 0.46, 0.45, 0.94)"},fade:{enter:{opacity:"0",filter:"blur(3px)"},leave:{opacity:"0",filter:"blur(3px)"},duration:500,easing:"ease"},scale:{enter:{transform:"scale(0.55)",opacity:"0"},leave:{transform:"scale(0.55)",opacity:"0"},duration:450,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)"},bounce:{enter:{transform:"translateY(-80px)",opacity:"0"},leave:{transform:"translateY(20px)",opacity:"0"},duration:650,easing:"ease"},flip:{enter:{transform:"perspective(500px) rotateX(-90deg)",opacity:"0"},leave:{transform:"perspective(500px) rotateX(90deg)",opacity:"0"},duration:500,easing:"cubic-bezier(0.25, 0.46, 0.45, 0.94)"},rotate:{enter:{transform:"rotate(-25deg) scale(0.6)",opacity:"0"},leave:{transform:"rotate(25deg) scale(0.6)",opacity:"0"},duration:500,easing:"cubic-bezier(0.25, 0.46, 0.45, 0.94)"},zoom:{enter:{transform:"scale(0.1)",opacity:"0"},leave:{transform:"scale(0.1)",opacity:"0"},duration:500,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)"}},c=["edit","split","preview"],h=["bold","italic","strikethrough","underline","code","h1","h2","h3","quote","ul","ol","indent","outdent","hr","link","image","table","undo","redo","edit","split","preview","fullscreen"];let d=null,u="zh-CN",p=new Set,m="zh-CN";const g={zh:()=>"other",en:e=>1===e?"one":"other",ru:e=>{const t=e%10,n=e%100;return 1===t&&11!==n?"one":t>=2&&t<=4&&!(n>=12&&n<=14)?"few":0===t||t>=5&&t<=9||n>=11&&n<=14?"many":"other"}},f=(e,t)=>{const n=e.split("-")[0].toLowerCase();return(g[n]||g.en)(Math.abs(t))},v=()=>u,b=e=>{let t=e;i[t]||(t=m),u=t,L(t),T(t)},y=(e,t={},n)=>{const r=n||u;let i=x(r,e);if(i&&"object"==typeof i&&void 0!==t.count&&(i=i[f(r,t.count)]||i.other||e),"string"==typeof i)return w(i,t);if(r!==m){let n=x(m,e);if(n&&"object"==typeof n&&void 0!==t.count&&(n=n[f(m,t.count)]||n.other),"string"==typeof n)return w(n,t)}return e},x=(e,t)=>{const n=i[e];if(!n)return;const r=t.split(".");let o=n;for(const e of r){if(!o||"object"!=typeof o||!(e in o))return;o=o[e]}return o},w=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>void 0!==t[n]?String(t[n]):e),_=(e,t)=>{i[e]||(i[e]={}),C(i[e],t)},k=async(e,t)=>{try{const n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}`);const r=await n.json();return _(t,r),!0}catch(e){return!1}},C=(e,t)=>{for(const n in t)t[n]instanceof Object&&n in e&&e[n]instanceof Object&&!Array.isArray(t[n])?C(e[n],t[n]):e[n]=t[n];return e},E=e=>e in i,S=e=>{const t=e.split("-")[0].toLowerCase();return["ar","he","fa","ur","yi","ps","sd","ug","dv","ku","syr"].includes(t)?"rtl":"ltr"},L=e=>{p.forEach(t=>{try{t(e)}catch(e){}})},T=e=>{if("undefined"!=typeof localStorage)try{localStorage.setItem("metona-editor-locale",e)}catch(e){}},M=()=>{if("undefined"!=typeof localStorage)try{return localStorage.getItem("metona-editor-locale")||$()}catch(e){}return $()},$=()=>{if("undefined"!=typeof navigator){const e=navigator.language||navigator.userLanguage;if(e&&E(e))return e;const t=e?.split("-")[0];if(t&&E(t))return t}return m},z=e=>{let t=e.config?.locale||u||"zh-CN";const n=(e,n={})=>y(e,n,t);return{set:r=>{if(!r||t===r)return t;if(t=r,e.el&&(e.el.setAttribute("lang",r),e.el.setAttribute("dir",S(r))),e.textarea&&(e.textarea.placeholder=n("placeholder")||"",e.textarea.setAttribute("aria-label",n("edit")||""),e.textarea.setAttribute("dir",S(r))),"function"==typeof e._emit&&e._emit("localeChange",{locale:r,direction:S(r)}),e.toolbarEl&&e.toolbarEl.querySelectorAll(".me-btn").forEach(e=>{const t=e.dataset.action||e.dataset.mode;if(t){const r=n(t);r&&r!==t&&(e.title=r,e.setAttribute("aria-label",r))}}),"function"==typeof e._updateWordCount)try{e._updateWordCount()}catch(e){}if(e.el&&"function"==typeof e.el.querySelector){const t=e.el.querySelector(".me-outline-title");t&&(t.textContent=n("outline")||"Outline")}return t},get:()=>t,getDirection:()=>S(t),t:n,formatNumber:(e,n)=>{try{return new Intl.NumberFormat(t,n).format(e)}catch(t){return String(e)}},formatDate:(e,n)=>{try{return new Intl.DateTimeFormat(t,n).format(e instanceof Date?e:new Date(e))}catch(t){return String(e)}}}};i["zh-CN"],i["en-US"],i.ja,i.ko,i.fr,i.de;const A={t:y,getCurrentLocale:v,setCurrentLocale:b,switchLocale:e=>{b(e)},getFallbackLocale:()=>m,setFallbackLocale:e=>{m=e},hasTranslation:e=>void 0!==x(u,e)||void 0!==x(m,e),getTranslations:e=>i[e]||{},addTranslations:_,loadRemote:k,getSupportedLocales:()=>Object.keys(i),isLocaleSupported:E,getLocaleName:e=>({"zh-CN":"简体中文","zh-TW":"繁體中文","en-US":"English (US)","en-GB":"English (UK)",ja:"日本語",ko:"한국어",fr:"Français",de:"Deutsch",es:"Español",pt:"Português",ru:"Русский",ar:"العربية",hi:"हिन्दी",th:"ไทย",vi:"Tiếng Việt",id:"Bahasa Indonesia",tr:"Türkçe",it:"Italiano",nl:"Nederlands",pl:"Polski"}[e]||e),getLocaleDirection:S,formatNumber:(e,t={})=>{try{return new Intl.NumberFormat(u,t).format(e)}catch(t){return String(e)}},formatCurrency:(e,t="USD",n={})=>{try{return new Intl.NumberFormat(u,{style:"currency",currency:t,...n}).format(e)}catch(t){return String(e)}},formatDate:(e,t={})=>{try{const n=e instanceof Date?e:new Date(e);return new Intl.DateTimeFormat(u,t).format(n)}catch(t){return String(e)}},addLocaleListener:e=>(p.add(e),()=>{p.delete(e)}),removeLocaleListener:e=>{p.delete(e)},clearLocaleListeners:()=>{p.clear()},initI18n:()=>{const e=M();b(e)},saveLocale:T,loadLocale:M,getDefaultLocale:$,createInstanceI18n:z},B=/^\s*$/,P=/^(#{1,6})\s+(.+?)(?:\s+#{1,6})?\s*$/,H=/^={3,}\s*$/,I=/^-{3,}\s*$/,R=/^(\s{0,3})(`{3,}|~{3,})\s*([\w+#.-]*)(\s+[^\n]*?)?\s*$/,j=/^\s{0,3}([-*_])(\s*\1){2,}\s*$/,F=/^\s{0,3}>\s?/,O=/^(\s*)([-*+])\s/,W=/^(\s*)(\d+)\.\s/,D=/^\[([ xX])\]\s+(.*)$/,N=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/,q=/^( {4}|\t)/,K=/^:\s+/,V=/^\[\^([^\]]+)\]:\s*/,U={smile:"😊",grinning:"😀",joy:"😂",rofl:"🤣",wink:"😉",blush:"😊",innocent:"😇",heart_eyes:"😍",kissing_heart:"😘",yum:"😋",stuck_out_tongue:"😛",sunglasses:"😎",smirk:"😏",unamused:"😒",disappointed:"😞",worried:"😟",confused:"😕",cry:"😢",sob:"😭",scream:"😱",angry:"😠",rage:"💢",triumph:"😤",sleepy:"😪",dizzy_face:"😵",zipper_mouth:"🤐",nerd:"🤓",thinking:"🤔",rolling_eyes:"🙄",expressionless:"😑",thumbsup:"👍",thumbsdown:"👎",clap:"👏",pray:"🙏",muscle:"💪",ok:"👌",point_up:"👆",point_down:"👇",point_left:"👈",point_right:"👉",raised_hands:"🙌",wave:"👋",punch:"👊",crossed_fingers:"🤞",heart:"❤️",broken_heart:"💔",star:"⭐",star2:"🌟",fire:"🔥",rocket:"🚀",check:"✅",cross:"❌",warning:"⚠️",info:"ℹ️",question:"❓",exclamation:"❗",bangbang:"‼️",grey_exclamation:"❕",bulb:"💡",book:"📖",memo:"📝",pin:"📌",link:"🔗",lock:"🔒",unlock:"🔓",key:"🔑",hammer:"🔨",wrench:"🔧",gear:"⚙️",tools:"🛠️",magnet:"🧲",zap:"⚡",cloud:"☁️",sun:"☀️",moon:"🌙",rain:"🌧️",snow:"❄️",umbrella:"☂️",rainbow:"🌈",tornado:"🌪️",fog:"🌫️",droplet:"💧",coffee:"☕",pizza:"🍕",cake:"🎂",beer:"🍺",wine:"🍷",hamburger:"🍔",fries:"🍟",apple:"🍎",banana:"🍌",grapes:"🍇",watermelon:"🍉",strawberry:"🍓",peach:"🍑",cherry:"🍒",taco:"🌮",tada:"🎉",gift:"🎁",crown:"👑",gem:"💎",ring:"💍",confetti:"🎊",balloon:"🎈",ribbon:"🎀",medal:"🏅",trophy:"🏆",eye:"👁️",ear:"👂",nose:"👃",tongue:"👅",lips:"👄",brain:"🧠",speech:"💬",thought:"💭",anger:"💢",sweat:"💦",one:"1️⃣",two:"2️⃣",three:"3️⃣",four:"4️⃣",five:"5️⃣",six:"6️⃣",seven:"7️⃣",eight:"8️⃣",nine:"9️⃣",zero:"0️⃣",arrow_up:"⬆️",arrow_down:"⬇️",arrow_left:"⬅️",arrow_right:"➡️",arrow_upper_right:"↗️",arrow_lower_right:"↘️",arrow_lower_left:"↙️",arrow_upper_left:"↖️",computer:"💻",phone:"📱",battery:"🔋",electric_plug:"🔌",copyright:"©️",registered:"®️",tm:"™️",hundred:"💯",boom:"💥",dash:"💨",hole:"🕳️",bomb:"💣",email:"📧",phone2:"📞",clock:"🕐",hourglass:"⏳",calendar:"📅",money:"💰",shopping:"🛒",package:"📦",mailbox:"📫",art:"🎨",music:"🎵",movie:"🎬",game:"🎮",sport:"⚽",earth:"🌍",house:"🏠",car:"🚗",airplane:"✈️",ship:"🚢"},Z=new Map,Y=(e,t)=>{if(!e)return"";if(!t.highlight&&e.length<600){const n=(e=>{let t=e._refsFp;return void 0===t&&(t=(e.refs?Object.keys(e.refs):[]).length>0?JSON.stringify(e.refs):""),t||""})(t),r=n?e+""+n:e,i=Z.get(r);if(void 0!==i)return i;const o=me(e,t);if(Z.size>=300){const e=Z.keys().next().value;Z.delete(e)}return Z.set(r,o),o}return me(e,t)},G=()=>{Z.clear()},Q=e=>{if(!e)return"";const t=String(e).trim();if(/^(javascript|vbscript|file):/i.test(t))return"";if(/^data:/i.test(t)){if(!/^data:image\//i.test(t))return"";if(t.length>5e5)return""}return t},X=e=>String(e).normalize("NFKC").toLowerCase().replace(/[^\w\u4e00-\u9fff\u3400-\u4dbf\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"heading",J=e=>e.replace(/"/g,""").replace(/\r?\n/g," "),ee=e=>{return e?` title="${(t=e,t.replace(/\\([!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])/g,"$1")).replace(/"/g,""").replace(/\r?\n/g," ")}"`:"";var t},te=[],ne=e=>{te.push(e),te.sort((e,t)=>e.priority-t.priority)},re=e=>!!(B.test(e)||R.test(e)||P.test(e)||j.test(e)||F.test(e)||O.test(e)||W.test(e)||V.test(e)||K.test(e)||/^\$\$/.test(e));ne({name:"refDef",priority:.1,test:e=>{if(/^\[\^/.test(e))return null;return e.match(/^\[([^\]]+)\]:\s*(?:<(\S+)>|(\S+))(?:\s+['"\(](.*?)['"\)])?\s*$/)||null},parse:(e,t,n,r,i,o)=>{const s=n[1].toLowerCase(),a=n[2]||n[3]||"",l=n[4]||"";return a&&o&&(o[s]=JSON.stringify({url:a,title:l})),{token:null,newIndex:t+1}}}),ne({name:"blank",priority:0,test:e=>!!B.test(e)||null,parse:(e,t)=>({token:null,newIndex:t+1})}),ne({name:"fencedCode",priority:1,test:e=>{const t=e.match(R);return t?(t[4]||"").includes("`")?null:t:null},parse:(e,t,n)=>{const r=n[2][0],i=n[2].length,o=n[3]||"",s=(n[4]||"").trim(),a=s?s.split(/\s+/).filter(Boolean):[],l={};for(let e=0;e<a.length;e++){const t=a[e].split("=");2===t.length?l[t[0]]=t[1]:l[a[e]]="true"}const c=[];let h=t+1;for(;h<e.length;){const t=e[h].match(/^(\s{0,3})(`{3,}|~{3,})\s*$/);if(t&&t[2][0]===r&&t[2].length>=i)break;c.push(e[h]),h++}return h<e.length&&h++,{token:{type:"code",lang:o,content:c.join("\n"),attrs:l},newIndex:h}}}),ne({name:"indentedCode",priority:2,test:e=>q.test(e)&&!(P.test(e)||F.test(e)||O.test(e)||W.test(e))||null,parse:(e,t)=>{const n=[];for(;t<e.length&&q.test(e[t]);)n.push(e[t].replace(/^( {4}|\t)/,"")),t++;return n.length?{token:{type:"code",lang:"",content:n.join("\n"),indent:!0},newIndex:t}:{token:null,newIndex:t}}}),ne({name:"atxHeading",priority:3,test:e=>e.match(P),parse:(e,t,n)=>({token:{type:"heading",level:n[1].length,text:n[2]},newIndex:t+1})}),ne({name:"setextH1",priority:4,test:(e,t,n)=>n+1>=t.length?null:H.test(t[n+1])&&!(B.test(e)||O.test(e)||W.test(e)||F.test(e)||/^\s*`{3,}/.test(e))||null,parse:(e,t)=>({token:{type:"heading",level:1,text:e[t]},newIndex:t+2})}),ne({name:"setextH2",priority:5,test:(e,t,n)=>n+1>=t.length?null:I.test(t[n+1])&&!(B.test(e)||O.test(e)||W.test(e)||F.test(e)||/^\s*`{3,}/.test(e))||null,parse:(e,t)=>({token:{type:"heading",level:2,text:e[t]},newIndex:t+2})}),ne({name:"hr",priority:6,test:e=>!!j.test(e)||null,parse:(e,t)=>({token:{type:"hr"},newIndex:t+1})}),ne({name:"blockquote",priority:7,test:e=>!!F.test(e)||null,parse:(e,t)=>{const n=[];for(;t<e.length&&F.test(e[t]);)n.push(e[t].replace(F,"")),t++;return{token:{type:"quote",content:n.join("\n")},newIndex:t}}}),ne({name:"table",priority:8,test:(e,t,n)=>!/\|/.test(e)||n+1>=t.length?null:le(t[n+1])?{header:e,align:ce(t[n+1])}:null,parse:(e,t,n)=>{let r=t+2;const i=[];for(;r<e.length&&/\|/.test(e[r])&&!B.test(e[r]);)i.push(e[r]),r++;return{token:{type:"table",header:n.header,rows:i,align:n.align},newIndex:r}}}),ne({name:"ul",priority:9,test:e=>e.match(O),parse:(e,t,n)=>{const{items:r,endIdx:i}=ae(e,t,n[2],n[1].length,!1);return{token:{type:"ul",items:r},newIndex:i}}}),ne({name:"ol",priority:10,test:e=>e.match(W),parse:(e,t,n)=>{const r=parseInt(n[2],10),{items:i,endIdx:o}=ae(e,t,n[2],n[1].length,!0);return{token:{type:"ol",items:i,start:r},newIndex:o}}}),ne({name:"footnoteDef",priority:11,test:e=>e.match(V),parse:(e,t,n,r,i)=>{const o=n[1],s=[e[t].slice(n[0].length)];let a=t+1;for(;a<e.length&&!B.test(e[a])&&!re(e[a]);)s.push(e[a]),a++;return i[o]=s.join(" "),{token:null,newIndex:a}}}),ne({name:"defList",priority:12,test:e=>!!K.test(e)||null,parse:(e,t,n,r)=>{const i=r.length>0&&"paragraph"===r[r.length-1].type?r.pop().text:"",o=[e[t].replace(K,"")];let s=t+1;for(;s<e.length&&K.test(e[s]);)o.push(e[s].replace(K,"")),s++;return{token:{type:"defList",term:i,defs:o},newIndex:s}}}),ne({name:"mathBlock",priority:13,test:e=>!!/^\$\$/.test(e)||null,parse:(e,t)=>{const n=e[t].match(/^\$\$([\s\S]+?)\$\$\s*$/);if(n)return{token:{type:"mathBlock",content:n[1]},newIndex:t+1};const r=[e[t].replace(/^\$\$/,"")];let i=t+1;for(;i<e.length&&!/\$\$/.test(e[i]);)r.push(e[i]),i++;return i<e.length&&(r.push(e[i].replace(/\$\$\s*$/,"")),i++),{token:{type:"mathBlock",content:r.join("\n")},newIndex:i}}});const ie=e=>{if(null==e)return{tokens:[],footnotes:{},refs:{}};const t=String(e).replace(/\r\n?/g,"\n").split("\n"),n=[],r={},i={};let o=0;for(;o<t.length;){const e=t[o];let s=!1;for(const a of te){const l=a.test(e,t,o);if(null!==l&&!1!==l){const e=a.parse(t,o,l,n,r,i);e.token&&n.push(e.token),o=e.newIndex,s=!0;break}}if(s)continue;const a=[];for(;o<t.length;){const e=t[o];if(B.test(e))break;if(re(e)){if(0===a.length&&R.test(e)&&e.includes("`")){a.push(e),o++;continue}break}if(o+1<t.length&&(H.test(t[o+1])||I.test(t[o+1])))break;if(/\|/.test(e)&&o+1<t.length&&le(t[o+1]))break;a.push(e),o++}a.length?n.push({type:"paragraph",text:a.join("\n")}):o<t.length&&!B.test(t[o])&&o++}return{tokens:n,footnotes:r,refs:i}},oe=(e,t={},n={})=>{let r=e.map(e=>he(e,t)).join("\n");const i=Object.keys(n);return i.length&&(r+='\n<div class="me-footnotes"><hr/><ol>',i.forEach(e=>{const i=J(e);r+=`<li id="fn-${i}" class="me-footnote-item"><a href="#fnref-${i}" class="me-footnote-backref">↩</a> ${Y(n[e],t)}</li>`}),r+="</ol></div>"),r},se=(e,t={})=>{const{tokens:n,footnotes:r,refs:i}=ie(e),o={...t,refs:i};return i&&Object.keys(i).length>0&&(o._refsFp=JSON.stringify(i)),oe(n,o,r)},ae=(e,t,n,r,i,o)=>{const s=[];let a=t;const l=r+(i?String(n).length+2:2);for(;a<e.length;){const t=e[a];let n;if(i){if(n=t.match(new RegExp(`^(\\s{${r}})\\d+\\.\\s`)),!n)break}else if(n=t.match(new RegExp(`^(\\s{${r}})[-*+]\\s`)),!n)break;let o=t.slice(n[0].length);const c=o.match(D);let h=c?c[2]:o;const d=!!c&&"x"===c[1].toLowerCase(),u=!!c;a++;const p=[],m=[];for(;a<e.length;){const t=e[a];if(B.test(t)){let t=a+1;for(;t<e.length&&B.test(e[t]);)t++;if(t<e.length){const n=e[t];if(!(n.length>l&&" "!==n[l])&&new RegExp(`^\\s{${l},}`).test(n)){p.push(""),a++;continue}}break}if(i){if(new RegExp(`^(\\s{0,${r}})\\d+\\.\\s`).test(t))break}else if(new RegExp(`^(\\s{0,${r}})[-*+]\\s`).test(t))break;if(F.test(t)||P.test(t)||j.test(t)||V.test(t))break;const n=t.match(new RegExp(`^(\\s{${l},})([-*+])\\s`)),o=t.match(new RegExp(`^(\\s{${l},})(\\d+)\\.\\s`));if(n||o){const t=!!o,r=t?o[2]:n[2],i=t?o[1].length:n[1].length,s=t?parseInt(o[2],10):void 0,l=ae(e,a,r,i,t);m.push({type:t?"ol":"ul",items:l.items,start:s}),a=l.endIdx;continue}t.length>l&&""===t.slice(0,l).trim()?p.push(t.slice(l)):p.push(t),a++}p.length&&(h=h?h+"\n"+p.join("\n"):p.join("\n")),s.push({type:"listItem",text:h,checked:d,task:u,subTokens:m.length?m:void 0})}return{items:s,endIdx:a}},le=e=>N.test(e)&&/-/.test(e),ce=e=>e.replace(/^\s*\|?\s*|\s*\|?\s*$/g,"").split(/\s*\|\s*/).map(e=>/^:/.test(e)&&/:$/.test(e)?"center":/:$/.test(e)?"right":(/^:/.test(e),"left")),he=(e,n,r)=>{switch(e.type){case"heading":{const t=X(e.text);return`<h${e.level} id="${t}">${Y(e.text,n)}</h${e.level}>`}case"paragraph":return`<p>${Y(e.text,n)}</p>`;case"hr":return"<hr/>";case"quote":return`<blockquote>${se(e.content,n)}</blockquote>`;case"code":return ue(e.content,e.lang,n,e.attrs);case"ul":return`<ul>${e.items.map(e=>de(e,n)).join("")}</ul>`;case"ol":{const t=e.start||1;return`<ol${t>1?` start="${t}"`:""}>${e.items.map((e,r)=>de(e,n,t>1?r+t:void 0)).join("")}</ol>`}case"table":return pe(e,n);case"defList":{let t="<dl>";return t+=`<dt>${Y(e.term,n)}</dt>`,e.defs.forEach(e=>{t+=`<dd>${Y(e,n)}</dd>`}),t+"</dl>"}case"mathBlock":return`<div class="me-math-block">${t(e.content)}</div>`;default:return`<div class="me-block-${e.type}">${e.content?"string"==typeof e.content?Y(e.content,n):t(String(e.content)):""}</div>`}},de=(e,t,n)=>{if(e.task){let n=`<li class="me-task-item"><input type="checkbox" disabled${e.checked?" checked":""}/> ${Y(e.text,t)}`;return e.subTokens&&(n+="\n"+e.subTokens.map(e=>he(e,t)).join("\n")),n+"</li>"}let r=null!=n?`<li value="${n}">`:"<li>";return r+=Y(e.text,t),e.subTokens&&(r+="\n"+e.subTokens.map(e=>he(e,t)).join("\n")),r+"</li>"},ue=(e,r,i,o)=>{if("mermaid"===r)return`<div class="me-mermaid"><pre class="mermaid">${t(e)}</pre></div>`;const s=r?` class="language-${n(r)}"`:"",a=o?.title?`<div class="me-code-title">${n(o.title)}</div>`:"";if(i.highlight&&"function"==typeof i.highlight&&r)try{const t=i.highlight(e,r);if("string"==typeof t)return`${a}<pre><code${s}>${t}</code></pre>`}catch(e){}return`${a}<pre><code${s}>${t(e)}</code></pre>`},pe=(e,t)=>{const n=e=>{const t=[];let n="",r=!1;for(let i=0;i<e.length;i++){const o=e[i];r?(n+=o,r=!1):"\\"===o?r=!0:"|"===o?(t.push(n.trim()),n=""):n+=o}return t.push(n.trim()),t.length>0&&""===t[0]&&t.shift(),t.length>0&&""===t[t.length-1]&&t.pop(),t},r=n(e.header),i=e.align||[],o=e=>i[e]&&"left"!==i[e]?` style="text-align:${i[e]}"`:"";let s='<div class="me-table-wrap"><table><thead><tr>';return s+=r.map((e,n)=>`<th${o(n)}>${Y(e,t)}</th>`).join(""),s+="</tr></thead><tbody>",s+=e.rows.map(e=>`<tr>${n(e).map((e,n)=>`<td${o(n)}>${Y(e,t)}</td>`).join("")}</tr>`).join(""),s+"</tbody></table></div>"},me=(e,n)=>{if(!e)return"";const r=[];let i=ge(e,r);const o=[];return i=i.replace(/&(?:[a-zA-Z][a-zA-Z0-9]{1,31}|#\d{1,7}|#x[0-9a-fA-F]{1,6});/g,e=>(o.push(e),`${o.length-1}`)),i=i.replace(/<!--[\s\S]*?-->/g,e=>(o.push(e),`${o.length-1}`)),i=i.replace(/<\/?u\s*>/gi,e=>(o.push(e),`${o.length-1}`)),i=t(i),i=i.replace(/\u0005(\d+)\u0005/g,(e,t)=>o[+t]||e),i=ve(i,r,n),i=i.replace(/\u0000(\d+)\u0000/g,(e,n)=>{const i=r[+n];return i?`<code>${t(i.content)}</code>`:e}),i=i.replace(/:([\w+-]+):/g,(e,t)=>U[t]||e),i=i.replace(/ \n/g,"<br/>\n"),i=i.replace(/\n/g,"<br/>"),i},ge=(e,t)=>{let n="",r=0;for(;r<e.length;)if("`"===e[r]){let i=1;for(;r+i<e.length&&"`"===e[r+i];)i++;let o=r+i,s=!1;for(;o<e.length;){const a=e.indexOf("`",o);if(-1===a)break;let l=1;for(;a+l<e.length&&"`"===e[a+l];)l++;if(l===i){const o=e.slice(r+i,a);t.push({content:o,len:i}),n+=`\0${t.length-1}\0`,r=a+l,s=!0;break}o=a+l}s||(n+=e.slice(r,r+i),r+=i)}else n+=e[r],r++;return n},fe=new RegExp(["(\\*\\*\\*[^*\\n][^*\\n]*?\\*\\*\\*)","|(___[^_\\n][^_\\n]*?___)","|(!\\[[^\\]]*\\]\\([^)]+\\))","|(?<!!)(\\[[^\\]]+\\]\\([^)]+\\))","|(!\\[[^\\]]*\\]\\[[^\\]]*\\])","|(?<!!)(\\[[^\\]]+\\]\\[[^\\]]*\\])","|(<https?:\\/\\/[^\\s&]+>)","|(\\*\\*[^*\\n][^*\\n]*?\\*\\*)","|(__[^_\\n][^_\\n]*?__)","|(~~[^\\n]+?~~)","|(==[^\\n]+?==)","|((?<=^|[^*])\\*(?!\\*)([^*\\n]+?)\\*(?!\\*))","|((?<=^|[^_])_(?!_)([^_\\n]+?)_(?!_))","|(\\^[^\\s^][^\\s^]*?\\^)","|(~[^\\s~][^\\s~]*?~)","|(?<!\\$)(\\$(?!\\$)[^\\n]+?\\$(?!\\$))","|(\\[\\^[^\\]]+\\])","|(\\\\.)"].join(""),"g"),ve=(e,n,r)=>{const i=new Map;return(e=(e=e.replace(/\u0000\d+\u0000/g,e=>{const t=`${i.size}`;return i.set(t,e),t})).replace(fe,e=>{const n=e;if(n.startsWith("***"))return`<em><strong>${n.slice(3,-3)}</strong></em>`;if(n.startsWith("___"))return`<em><strong>${n.slice(3,-3)}</strong></em>`;if(n.startsWith("){const e=n.match(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+['"](.+?)['"])?\s*\)/);if(!e)return n;const r=Q(e[2]);return r?`<img src="${J(r)}" alt="${J(e[1])}"${ee(e[3])} loading="lazy"/>`:t(n)}if(n.startsWith("![")&&n.includes("][")){const e=n.match(/!\[([^\]]*)\]\[([^\]]*)\]/);if(!e)return n;const i=(e[2]||e[1]).toLowerCase();if(r.refs&&r.refs[i])try{const o=JSON.parse(r.refs[i]),s=Q(o.url);return s?`<img src="${J(s)}" alt="${J(e[1])}"${ee(t(o.title))} loading="lazy"/>`:t(n)}catch(t){return`<img src="" alt="${J(e[1])}" class="me-img-ref"/>`}return`<img src="" alt="${J(e[1])}" class="me-img-ref"/>`}if(n.startsWith("[")&&n.includes("](")){const e=n.match(/\[([^\]]+)\]\(([^)\s]+)(?:\s+['"](.+?)['"])?\s*\)/);if(!e)return n;const t=Q(e[2]);if(!t)return n;const i=me(e[1],r);return`<a href="${J(t)}"${ee(e[3])} target="_blank" rel="noopener noreferrer">${i}</a>`}if(n.startsWith("[")&&n.includes("][")){const e=n.match(/\[([^\]]+)\]\[([^\]]*)\]/);if(!e)return n;const i=(e[2]||e[1]).toLowerCase();if(r.refs&&r.refs[i])try{const o=JSON.parse(r.refs[i]),s=Q(o.url);return s?`<a href="${J(s)}"${ee(t(o.title))} target="_blank" rel="noopener noreferrer">${e[1]}</a>`:t(n)}catch(e){return t(n)}return t(n)}if(n.startsWith("<http")){const e=n.slice(4,-4),t=Q(e);return`<a href="${J(t)}" target="_blank" rel="noopener noreferrer">${e}</a>`}if(n.startsWith("**"))return`<strong>${n.slice(2,-2)}</strong>`;if(n.startsWith("__"))return`<strong>${n.slice(2,-2)}</strong>`;if(n.startsWith("~~"))return`<del>${n.slice(2,-2)}</del>`;if(n.startsWith("=="))return`<mark>${n.slice(2,-2)}</mark>`;if(n.startsWith("*")&&!n.startsWith("**")&&!n.startsWith("***"))return`<em>${n.slice(1,-1)}</em>`;if(n.startsWith("_")&&!n.startsWith("__")&&!n.startsWith("___"))return`<em>${n.slice(1,-1)}</em>`;if(n.startsWith("^")&&!n.startsWith("^^"))return`<sup>${n.slice(1,-1)}</sup>`;if(n.startsWith("~")&&!n.startsWith("~~"))return`<sub>${n.slice(1,-1)}</sub>`;if(n.startsWith("$")&&!n.startsWith("$$"))return`<span class="me-math-inline">${t(n.slice(1,-1))}</span>`;if(/^\[\^/.test(n)){const e=n.slice(2,-1),t=J(e);return`<sup class="me-footnote-ref"><a href="#fn-${t}" id="fnref-${t}">[${t}]</a></sup>`}if(n.startsWith("\\")&&2===n.length){const e=n[1];return/[!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~]/.test(e)?e:n}return n})).replace(/\u0003(\d+)\u0003/g,e=>i.get(e)||e)},be=Symbol("me-plugin:autoSave"),ye=Symbol("me-plugin:searchReplace"),xe=Symbol("me-plugin:imagePaste"),we=Symbol("me-plugin:shortcutHelp"),_e=Symbol("me-plugin:fileSystem"),ke=(e,t)=>e[t],Ce=(e,t,n)=>{e[t]=n},Ee=(e,t)=>{delete e[t]};class Se{constructor(){this.plugins=new Map}register(e,t){return this.plugins.has(e)?this:t&&"object"==typeof t&&(t.name||e)?(this.plugins.set(e,{version:t.version||"0.0.0",description:t.description||"",depends:t.depends||[],priority:t.priority||0,...t,name:e,enabled:!0}),this):this}unregister(e){return this.plugins.delete(e),this}get(e){return this.plugins.get(e)||null}has(e){return this.plugins.has(e)}getAll(){return Array.from(this.plugins.values())}getNames(){return Array.from(this.plugins.keys())}enable(e){const t=this.plugins.get(e);return t&&(t.enabled=!0),this}disable(e){const t=this.plugins.get(e);return t&&(t.enabled=!1),this}isEnabled(e){const t=this.plugins.get(e);return!!t&&t.enabled}destroy(){this.plugins.clear()}}const Le=new Se,Te=e=>{const t=new Map;e.forEach(e=>t.set(e.name,e));const n=new Map,r=new Map;e.forEach(e=>{n.set(e.name,0),r.set(e.name,[])}),e.forEach(e=>{(e.depends||[]).forEach(i=>{t.has(i)&&(r.get(i).push(e.name),n.set(e.name,(n.get(e.name)||0)+1))})});const i=[];n.forEach((e,t)=>{0===e&&i.push(t)});const o=[];for(;i.length;){i.sort((e,n)=>(t.get(n).priority||0)-(t.get(e).priority||0));const e=i.shift();o.push(t.get(e)),(r.get(e)||[]).forEach(e=>{n.set(e,n.get(e)-1),0===n.get(e)&&i.push(e)})}return o.length!==e.length?e:o},Me=(e={},t={})=>{const n=[],r={...t};for(const[i,o]of Object.entries(e)){const e=t[i];if(o.required&&null==e)n.push(`"${i}" is required`);else if(void 0!==e||void 0===o.default){if(void 0!==e&&o.type){const t=Array.isArray(e)?"array":typeof e;t!==o.type&&n.push(`"${i}" expected ${o.type}, got ${t}`)}if(void 0!==e&&o.enum&&!o.enum.includes(e)&&n.push(`"${i}" must be one of [${o.enum.join(", ")}]`),void 0!==e&&"function"==typeof o.validator)try{const t=o.validator(e);!0!==t&&n.push(`"${i}": ${t}`)}catch(e){n.push(`"${i}": ${e.message}`)}}else r[i]=o.default}return{valid:0===n.length,errors:n,patched:r}},$e=e=>(t,n)=>"function"==typeof e.t?e.t(t,n):y(t,n),ze={autoSave:{name:"autoSave",version:"0.1.1",description:"Auto-save to localStorage",priority:100,install(e,t){if(!e||"function"!=typeof e.getValue)return;const n=t||this,r=n.key||"me-draft-"+(e.id||""),i=n.delay||1e3,o={_timer:null},s=()=>{o._timer&&(clearTimeout(o._timer),o._timer=null);try{localStorage.setItem(r,e.getValue()),"function"==typeof e._emit&&e._emit("autosave",{key:r,value:e.getValue()})}catch(e){}},a=()=>{o._timer&&clearTimeout(o._timer),o._timer=setTimeout(s,i)},l=s,c=s;"function"==typeof e.on&&(e.on("change",a),e.on("blur",l),e.on("save",c)),e.restoreDraft=()=>{try{const t=localStorage.getItem(r);return null!=t&&"function"==typeof e.setValue&&e.setValue(t),t}catch(e){return null}},e.clearDraft=()=>{try{localStorage.removeItem(r)}catch(e){}return e},e.getDraftKey=()=>r,Ce(e,be,{state:o,_onInput:a,_onBlur:l,_onSave:c,save:s})},destroy(e){const t=ke(e,be);t&&(t.state._timer&&(clearTimeout(t.state._timer),t.state._timer=null),e&&"function"==typeof e.off&&(t._onInput&&e.off("change",t._onInput),t._onBlur&&e.off("blur",t._onBlur),t._onSave&&e.off("save",t._onSave)),Ee(e,be))}},exportTool:{name:"exportTool",version:"0.1.0",description:"Export Markdown/HTML",priority:50,install(e){if(!e||"function"!=typeof e.getValue)return;const t=(e,t,n)=>{if("undefined"==typeof document)return;const r=new Blob([t],{type:n+";charset=utf-8"}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(i),0)},n=()=>{const e=new Date,t=e=>String(e).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}`},r=e,i=(t={})=>{const n=t.title||"Document",r=t.css||"",i="function"==typeof e.getHTML?e.getHTML():"",o=!1!==t.embedCSS?'<style>\nbody{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC",sans-serif;font-size:14px;line-height:1.6;color:#1f2937;max-width:860px;margin:0 auto;padding:20px}\nh1,h2,h3,h4,h5,h6{margin:1.4em 0 .6em;font-weight:650;line-height:1.3}\nh1{font-size:1.9em;padding-bottom:.3em;border-bottom:1px solid #e5e7eb}\nh2{font-size:1.55em;padding-bottom:.3em;border-bottom:1px solid #e5e7eb}\nh3{font-size:1.3em}h4{font-size:1.12em}h5{font-size:1em}h6{font-size:.9em;color:#6b7280}\np{margin:.7em 0}a{color:#3b82f6;text-decoration:none}a:hover{text-decoration:underline}\nstrong{font-weight:650}em{font-style:italic}del{text-decoration:line-through;opacity:.75}\nul,ol{margin:.6em 0;padding-left:1.6em}li{margin:.25em 0}\nli.me-task-item{list-style:none;margin-left:-1.4em}\nli.me-task-item input{margin-right:.5em;vertical-align:middle}\nblockquote{margin:.8em 0;padding:.4em 1em;border-left:3px solid #3b82f6;background:#f3f4f6;border-radius:0 6px 6px 0}\nhr{border:0;height:1px;background:#e5e7eb;margin:1.6em 0}\ncode{font-family:"SF Mono",Consolas,monospace;font-size:.88em;padding:.15em .4em;background:#f3f4f6;border-radius:4px}\npre{margin:.9em 0;padding:14px 16px;background:#f3f4f6;border-radius:8px;overflow-x:auto;border:1px solid #e5e7eb}\npre code{padding:0;background:transparent;font-size:.9em;line-height:1.6;border-radius:0}\nimg{max-width:100%;height:auto;border-radius:6px}\ntable{border-collapse:collapse;width:100%;font-size:.93em;display:block;overflow-x:auto}\nth,td{border:1px solid #e5e7eb;padding:7px 12px;text-align:left}\nth{background:#f3f4f6;font-weight:600}\ntr:nth-child(even) td{background:#f9fafb}\nmark{background:rgba(250,204,21,.3);color:inherit;padding:.1em .2em;border-radius:3px}\nsup{font-size:.75em}sub{font-size:.75em}\n.me-math-block{display:block;margin:1.2em 0;padding:12px 16px;background:#f3f4f6;border-radius:8px;overflow-x:auto;font-family:monospace;text-align:center}\n.me-math-inline{font-family:monospace}\ndl{margin:.8em 0}dt{font-weight:650;margin:.6em 0 .2em}dd{margin:0 0 .3em 1.6em;color:#4b5563}\n.me-footnote-ref a{font-size:.75em;vertical-align:super;text-decoration:none;color:#3b82f6}\n.me-footnotes{margin-top:2em;border-top:1px solid #e5e7eb;padding-top:.8em;font-size:.9em;color:#6b7280}\n.me-footnotes hr{display:none}\n.me-footnotes ol{padding-left:1.2em}\n.me-footnote-item{margin:.3em 0}\n.me-footnote-backref{text-decoration:none;color:#3b82f6;margin-right:.4em}\n.me-table-wrap{overflow-x:auto;margin:.9em 0}\n</style>':"";return`<!DOCTYPE html>\n<html lang="${t.lang||"zh-CN"}">\n<head>\n<meta charset="utf-8"/>\n<meta name="viewport" content="width=device-width, initial-scale=1"/>\n<title>${n}</title>\n${r?`<style>${r}</style>`:""}${o}\n</head>\n<body>\n${i}\n</body>\n</html>`};r.exportMarkdown=r=>(t(r||`metona-${n()}.md`,e.getValue(),"text/markdown"),e),r.exportHTML=(r,o={})=>(t(r||`metona-${n()}.html`,i(o),"text/html"),e),r.exportPDF=(t={})=>{if("undefined"==typeof document||!e.el)return e;const n=document.createElement("iframe");n.style.position="fixed",n.style.right="0",n.style.bottom="0",n.style.width="0",n.style.height="0",n.style.border="0",document.body.appendChild(n);const r=n.contentDocument;return r?(r.open(),r.write(i(t)),r.close(),setTimeout(()=>{try{n.contentWindow?.print()}catch(e){}setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n)},1e3)},50),e):(n.remove(),e)}},destroy(e){e&&(delete e.exportMarkdown,delete e.exportHTML,delete e.exportPDF)}},searchReplace:{name:"searchReplace",version:"0.2.1",description:"Search & Replace (Ctrl+F/H)",priority:80,install(e){if(!e||!e.textarea||"undefined"==typeof document)return;const t=$e(e);if(!document.getElementById("me-search-style")){const e=document.createElement("style");e.id="me-search-style",e.textContent=".me-search{position:absolute;top:10px;right:16px;z-index:20;display:flex;flex-direction:column;gap:8px;padding:12px;background:var(--md-bg,#1c2029);border:1px solid var(--md-border,rgba(255,255,255,0.12));border-radius:10px;box-shadow:0 12px 40px -8px rgba(0,0,0,0.4),0 0 0 1px rgba(255,255,255,0.05);font-size:13px;min-width:300px;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);animation:meSearchIn .18s ease-out}@keyframes meSearchIn{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.me-search-row{display:flex;gap:6px;align-items:center}.me-search-row+.me-search-row{margin-top:2px}.me-search input{flex:1;min-width:0;padding:7px 10px;border:1px solid var(--md-border,rgba(255,255,255,0.12));border-radius:6px;background:var(--md-textarea-bg,rgba(255,255,255,0.04));color:var(--md-text,#e6e8eb);font-size:13px;outline:none;transition:border-color .15s,box-shadow .15s}.me-search input::placeholder{color:var(--md-muted,#6b7280)}.me-search input:focus{border-color:var(--md-accent,#3b82f6);box-shadow:0 0 0 3px rgba(59,130,246,0.15)}.me-search .me-search-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid rgba(255,255,255,0.08);border-radius:5px;background:rgba(255,255,255,0.04);color:var(--md-muted,#9ca3af);cursor:pointer;transition:all .12s;flex-shrink:0}.me-search .me-search-btn:hover{background:var(--md-accent,#3b82f6);color:#fff;border-color:var(--md-accent,#3b82f6)}.me-search .me-search-btn:active{transform:scale(.92)}.me-search .me-search-btn.me-active{background:var(--md-accent,#3b82f6);color:#fff;border-color:var(--md-accent,#3b82f6)}.me-search .me-search-btn svg{width:14px;height:14px}.me-search .me-search-count{color:var(--md-muted,#9ca3af);font-size:11.5px;min-width:28px;text-align:center;font-variant-numeric:tabular-nums}.me-search .me-search-close{margin-left:2px;font-size:16px;line-height:1}.me-search .me-search-close:hover{background:#ef4444;border-color:#ef4444}.me-search .me-search-replace-one,.me-search .me-search-replace-all{width:auto;padding:5px 10px;font-size:12px;font-weight:500;letter-spacing:.01em}.me-search .me-search-replace-all{background:rgba(59,130,246,0.12);border-color:rgba(59,130,246,0.3);color:var(--md-accent,#60a5fa)}.me-search .me-search-replace-all:hover{background:var(--md-accent,#3b82f6);color:#fff}",document.head.appendChild(e)}const n={_panel:null,_regexMode:!1,_matchCase:!0,_wholeWord:!1,_cleanup:null},r="[\\w\\u4e00-\\u9fff]",i=e=>{if(!e)return null;let t=n._regexMode?e:e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n._wholeWord&&(t=`(?<!${r})(?:${t})(?!${r})`);const i="g"+(n._matchCase?"":"i");try{return new RegExp(t,i)}catch(e){return null}},o=(e,t,n)=>{const r=e=>!!e&&/[\w\u4e00-\u9fff]/.test(e);return!r(e[t-1])&&!r(e[t+n])},s=()=>{if(!n._panel)return;const e="1"===n._panel.dataset.replace,t=n._panel.querySelector(".me-search-replace-row");t&&(t.style.display=e?"flex":"none")},a=()=>{n._cleanup&&(n._cleanup(),n._cleanup=null),n._panel=null,e&&e.textarea&&e.textarea.focus()},l=r=>{if(n._panel){n._panel.dataset.replace=r?"1":"0",s();const e=n._panel.querySelector(".me-search-find");return void(e&&(e.focus(),e.select()))}const l=e.textarea.value.substring(e.textarea.selectionStart,e.textarea.selectionEnd),c=document.createElement("div");var h;c.className="me-search",c.dataset.replace=r?"1":"0",c.innerHTML=`<div class="me-search-row"><input type="text" class="me-search-find" placeholder="${t("searchPlaceholder")||"Find"}" value="${h=l,String(null==h?"":h).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}"/><button class="me-search-btn me-search-prev" title="${t("findPrev")||"Previous"}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"/></svg></button><button class="me-search-btn me-search-next" title="${t("findNext")||"Next"}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></button><span class="me-search-count"></span><button class="me-search-btn me-search-case me-active" title="${t("matchCase")||"Match Case"}">Aa</button><button class="me-search-btn me-search-word" title="${t("wholeWord")||"Whole Word"}">ab</button><button class="me-search-btn me-search-regex" title="${t("regex")||"Regex"}">.*</button><button class="me-search-btn me-search-close" title="${t("close")||"Close"}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button></div><div class="me-search-row me-search-replace-row"><input type="text" class="me-search-replace" placeholder="${t("replacePlaceholder")||"Replace"}"/><button class="me-search-btn me-search-replace-one">${t("replace")||"Replace"}</button><button class="me-search-btn me-search-replace-all">${t("replaceAll")||"All"}</button></div>`,e.el.appendChild(c),n._panel=c,s(),n._regexMode=!1,n._matchCase=!0,n._wholeWord=!1;const d=c.querySelector(".me-search-find"),u=c.querySelector(".me-search-replace"),p=c.querySelector(".me-search-count"),m=c.querySelector(".me-search-regex"),g=c.querySelector(".me-search-case"),f=c.querySelector(".me-search-word");m.addEventListener("click",()=>{n._regexMode=!n._regexMode,m.classList.toggle("me-active",n._regexMode),b=v()}),g.addEventListener("click",()=>{n._matchCase=!n._matchCase,g.classList.toggle("me-active",n._matchCase),b=v()}),f.addEventListener("click",()=>{n._wholeWord=!n._wholeWord,f.classList.toggle("me-active",n._wholeWord),b=v()});const v=()=>{const t=d.value;if(!t)return p.textContent="",[];const n=[],r=i(t);if(!r)return p.textContent="err",[];let o;for(;null!==(o=r.exec(e.textarea.value));)n.push(o.index),0===o[0].length&&r.lastIndex++;return p.textContent=n.length?`${n.length}`:"0",n};let b=[];const y=(t,n)=>{e.textarea.focus(),e.textarea.setSelectionRange(t,t+(n||d.value.length))},x=t=>{const r=e.textarea.value,s=d.value;if(!s)return 0;if(!n._regexMode)return n._matchCase&&r.slice(t,t+s.length)!==s?0:n._matchCase||r.slice(t,t+s.length).toLowerCase()===s.toLowerCase()?n._wholeWord&&!o(r,t,s.length)?0:s.length:0;const a=i(s);if(!a)return 0;a.lastIndex=t;const l=a.exec(r);return l&&l.index===t?l[0].length:0},w=()=>{if(b=v(),!b.length)return;const t=e.textarea.selectionEnd;let n=b.find(e=>e>=t);null==n&&(n=b[0]),y(n,x(n)||d.value.length)},_=()=>{if(b=v(),!b.length)return;const t=e.textarea.selectionStart;let n=-1;for(let e=b.length-1;e>=0;e--)if(b[e]<t){n=b[e];break}-1===n&&(n=b[b.length-1]),y(n,x(n)||d.value.length)},k=()=>{const t=d.value,r=u.value;if(!t)return;const s=e.textarea,a=s.selectionStart,l=s.selectionEnd,c=s.value.substring(a,l);let h=!1;if(n._regexMode){const e=i(t);if(e){e.lastIndex=a;const t=e.exec(s.value);h=!(!t||t.index!==a)}}else h=(n._matchCase?c===t:c.toLowerCase()===t.toLowerCase())&&(!n._wholeWord||o(s.value,a,t.length));h&&(s.value=s.value.substring(0,a)+r+s.value.substring(l),s.setSelectionRange(a,a+r.length));const p=e._value||"";e._value=s.value,"function"==typeof e._afterProgrammaticEdit?e._afterProgrammaticEdit(p):("function"==typeof e._pushHistory&&e._pushHistory(),"function"==typeof e._render&&e._render(),"function"==typeof e._updateWordCount&&e._updateWordCount(),"function"==typeof e._emit&&e._emit("change",e._value)),w()};d.addEventListener("input",()=>{b=v()}),d.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?_():w()),"Escape"===e.key&&(e.preventDefault(),a())}),u.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),k()),"Escape"===e.key&&(e.preventDefault(),a())}),c.querySelector(".me-search-next").addEventListener("click",w),c.querySelector(".me-search-prev").addEventListener("click",_),c.querySelector(".me-search-close").addEventListener("click",()=>a()),c.querySelector(".me-search-replace-one").addEventListener("click",k),c.querySelector(".me-search-replace-all").addEventListener("click",()=>{const t=d.value,n=u.value;if(!t)return;const r=e.textarea,o=i(t);if(!o)return;const s=e._value||"";r.value=r.value.replace(o,()=>n),r.setSelectionRange(0,0),e._value=r.value,"function"==typeof e._afterProgrammaticEdit?e._afterProgrammaticEdit(s):("function"==typeof e._pushHistory&&e._pushHistory(),"function"==typeof e._render&&e._render(),"function"==typeof e._updateWordCount&&e._updateWordCount(),"function"==typeof e._emit&&e._emit("change",e._value)),v()}),d.focus(),d.select(),n._cleanup=()=>{c.parentNode&&c.parentNode.removeChild(c)}},c=e=>{if(!e.ctrlKey&&!e.metaKey)return;const t=e.key.toLowerCase();"f"===t?(e.preventDefault(),l(!1)):"h"===t?(e.preventDefault(),l(!0)):"escape"===t&&n._panel&&a()};e.textarea.addEventListener("keydown",c),Ce(e,ye,{state:n,_open:l,_close:a,_onKeydown:c})},destroy(e){const t=ke(e,ye);if(t){const n=t.state;n&&(n._cleanup&&(n._cleanup(),n._cleanup=null),n._panel=null),t._onKeydown&&e&&e.textarea&&e.textarea.removeEventListener("keydown",t._onKeydown),Ee(e,ye)}}},imagePaste:{name:"imagePaste",version:"0.2.1",description:"Paste image as base64",priority:60,install(e,t={}){if(!e||!e.textarea||"undefined"==typeof document)return;const n=$e(e),r=t.maxSizeKB||500,i=t=>{const i=t.clipboardData?.items;if(i)for(const o of i)if(o.type?.startsWith("image/")){const i=o.getAsFile();if(!i)continue;const s=i.size/1024;if(r>0&&s>r){t.preventDefault(),"function"==typeof e.toast&&e.toast(n("imageTooLarge",{size:s.toFixed(0),max:r})||`Image too large (${s.toFixed(0)}KB > ${r}KB)`,{type:"warning"});break}t.preventDefault();const a=new FileReader;a.onload=()=>{"function"==typeof e.insert&&e.insert(`\n`)},a.readAsDataURL(i);break}};e.textarea.addEventListener("paste",i),Ce(e,xe,i)},destroy(e){const t=ke(e,xe);t&&e?.textarea&&e.textarea.removeEventListener("paste",t),Ee(e,xe)}},shortcutHelp:{name:"shortcutHelp",version:"0.2.0",description:"Press ? to show shortcuts",priority:200,install(e){if(!e||!e.textarea||"undefined"==typeof document)return;const t=$e(e);if(!document.getElementById("me-shortcut-style")){const e=document.createElement("style");e.id="me-shortcut-style",e.textContent=".me-shortcut-overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:50;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center}.me-shortcut-panel{background:var(--md-bg,#fff);border-radius:12px;padding:24px;max-width:560px;width:90%;max-height:80vh;overflow-y:auto;box-shadow:0 12px 40px rgba(0,0,0,0.3)}.me-shortcut-panel h3{font-size:16px;margin:0 0 16px;color:var(--md-text)}.me-shortcut-panel table{width:100%;border-collapse:collapse;font-size:13px}.me-shortcut-panel td{padding:6px 10px;border-bottom:1px solid var(--md-border)}.me-shortcut-panel td:first-child{font-family:var(--md-mono);font-size:12px;color:var(--md-accent);white-space:nowrap;width:40%}.me-shortcut-panel .me-shortcut-close{position:absolute;top:16px;right:20px;background:none;border:none;font-size:20px;cursor:pointer;color:var(--md-muted)}",document.head.appendChild(e)}const n={panel:null},r=()=>{n.panel&&(n.panel.remove(),n.panel=null)},i=()=>{if(n.panel)return void r();const e=[["Ctrl+B",t("bold")||"Bold"],["Ctrl+I",t("italic")||"Italic"],["Ctrl+U",t("underline")||"Underline"],["Ctrl+K",t("link")||"Link"],["Ctrl+E",t("code")||"Code"],["Ctrl+1/2/3",t("h1")||"Heading"],["Ctrl+Q",t("quote")||"Quote"],["Ctrl+Z",t("undo")||"Undo"],["Ctrl+Y",t("redo")||"Redo"],["Ctrl+S",t("save")||"Save"],["Ctrl+F",t("search")||"Search"],["Ctrl+H",t("replace")||"Replace"],["Tab",t("indent")||"Indent"],["Shift+Tab",t("outdent")||"Outdent"],["?",t("shortcuts")||"Shortcuts"]];let i="";e.forEach(([e,t])=>{i+=`<tr><td>${e}</td><td>${t}</td></tr>`});const o=document.createElement("div");o.className="me-shortcut-overlay",o.innerHTML=`<div class="me-shortcut-panel"><h3>⌨️ ${t("shortcuts")||"Shortcuts"}</h3><button class="me-shortcut-close">×</button><table>${i}</table></div>`,o.addEventListener("click",e=>{(e.target===o||e.target.classList.contains("me-shortcut-close"))&&r()}),document.body.appendChild(o),n.panel=o},o=e=>{"?"!==e.key||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i()),"Escape"===e.key&&n.panel&&r()};e.textarea.addEventListener("keydown",o),Ce(e,we,{state:n,_open:i,_close:r,_onKeydown:o})},destroy(e){const t=ke(e,we);t&&t.state&&t.state.panel&&(t.state.panel.remove(),t.state.panel=null);const n=t?._onKeydown;n&&e?.textarea&&e.textarea.removeEventListener("keydown",n),Ee(e,we)}},fileSystem:{name:"fileSystem",version:"0.2.0",description:"File System Access API",priority:90,install(e){if(!e||"function"!=typeof e.getValue)return;const t="undefined"!=typeof window&&"function"==typeof window.showOpenFilePicker;let n=null;e.openFile=async(r={})=>{if(!t)return"function"==typeof e.toast&&e.toast?.("File System Access API not supported",{type:"warning"}),null;try{const[t]=await window.showOpenFilePicker({types:[{accept:{"text/markdown":[".md",".txt",".markdown"]}}],...r});n=t;const i=await t.getFile(),o=await i.text();return"function"==typeof e.setValue&&e.setValue(o),e._emit?.("fileOpened",{name:i.name,handle:t}),{name:i.name,content:o,handle:t}}catch(e){return e.name,null}},e.saveFile=async(r={})=>{let i=n;if(!i||r.saveAs){if(!t)return"function"==typeof e.toast&&e.toast?.("File System Access API not supported",{type:"warning"}),!1;try{i=await window.showSaveFilePicker({types:[{accept:{"text/markdown":[".md"]}}],suggestedName:r.name||"document.md"}),n=i}catch(e){return e.name,!1}}try{const t=await i.createWritable();return await t.write(e.getValue()),await t.close(),e._emit?.("fileSaved",{handle:i}),!0}catch(t){return n=null,!r.saveAs&&e.saveFile({...r,saveAs:!0})}},e.saveFileAs=t=>e.saveFile({saveAs:!0,name:t}),e.getFileHandle=()=>n,Ce(e,_e,{getHandle:()=>n})},destroy(e){e&&(delete e.openFile,delete e.saveFile,delete e.saveFileAs,delete e.getFileHandle),Ee(e,_e)}}},Ae={createManager:()=>new Se,manager:Le,register:(e,t)=>Le.register(e,t),unregister:e=>Le.unregister(e),get:e=>Le.get(e),has:e=>Le.has(e),getAll:()=>Le.getAll(),getNames:()=>Le.getNames(),enable:e=>Le.enable(e),disable:e=>Le.disable(e),isEnabled:e=>Le.isEnabled(e),getPreset:e=>ze[e]?{...ze[e]}:null,getAllPresets:()=>Object.keys(ze).reduce((e,t)=>(e[t]={...ze[t]},e),{}),createPlugin:(e={})=>{const t={name:e.name||"custom",version:e.version||"0.0.0",description:e.description||"",depends:e.depends||[],priority:e.priority||0,install:()=>{},destroy:()=>{},...e};return"function"!=typeof t.install&&(t.install=()=>{}),"function"!=typeof t.destroy&&(t.destroy=()=>{}),t},validatePlugin:e=>{const t=[];return e&&"object"==typeof e||t.push("plugin must be an object"),e&&!e.name&&t.push("plugin must have a name"),e&&e.install&&"function"!=typeof e.install&&t.push("install must be a function"),{valid:0===t.length,errors:t}},topologicalSort:Te,validateConfig:Me};let Be="auto",Pe=new Set,He=null;const Ie=()=>"undefined"==typeof window?"light":"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Re=()=>{"undefined"!=typeof window&&window.matchMedia&&(He&&(He(),He=null),He=(()=>{if("undefined"==typeof window||!window.matchMedia)return()=>{};const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>(e.matches,void("auto"===Be&&Ne("auto")));return e.addEventListener("change",t),()=>e.removeEventListener("change",t)})())},je=e=>e&&"auto"!==e?e:Ie(),Fe=e=>{const t=je(e),n=a[t];return n&&"object"==typeof n?n:a.light},Oe=(e,t)=>{if("undefined"==typeof document||!e||"object"!=typeof e)return;const n=t||document.documentElement,r={"--md-bg":e.bg,"--md-text":e.text,"--md-border":e.border,"--md-shadow":e.shadow,"--md-hover-shadow":e.hoverShadow,"--md-toolbar-bg":e.toolbarBg||e.bg,"--md-textarea-bg":e.textareaBg||e.bg,"--md-preview-bg":e.previewBg||e.bg,"--md-code-bg":e.codeBg||"rgba(127,127,127,0.1)","--md-code-text":e.codeText||e.text,"--md-accent":e.accent||"#3b82f6","--md-muted":e.muted||"#9ca3af"};for(const[e,t]of Object.entries(r))null!=t&&n.style.setProperty(e,String(t));e.progressBg&&n.style.setProperty("--md-progress-bg",e.progressBg),e.closeHoverBg&&n.style.setProperty("--md-close-hover-bg",e.closeHoverBg)},We=e=>{const t=e||document.documentElement;if("undefined"==typeof document)return{};const n=getComputedStyle(t),r={};return["--md-bg","--md-text","--md-border","--md-shadow","--md-hover-shadow","--md-toolbar-bg","--md-textarea-bg","--md-preview-bg","--md-code-bg","--md-code-text","--md-accent","--md-muted"].forEach(e=>{const t=n.getPropertyValue(e).trim();t&&(r[e]=t)}),r},De=(e,t)=>{const n=t||document.documentElement;if("undefined"==typeof document)return"";const r=e.startsWith("--")?e:`--md-${e}`;return getComputedStyle(n).getPropertyValue(r).trim()},Ne=e=>{Be=e;const t=je(e);"undefined"!=typeof document&&(document.documentElement.setAttribute("data-md-theme",t),document.documentElement.classList.remove("md-theme-light","md-theme-dark","md-theme-auto","md-theme-warm"),document.documentElement.classList.add(`md-theme-${t}`),Oe(Fe(e))),Ze(e,t)},qe=e=>{Ne(e),Ve(e)},Ke=()=>je(Be),Ve=e=>{if("undefined"!=typeof localStorage)try{localStorage.setItem("metona-editor-theme",e)}catch(e){}},Ue=()=>{if("undefined"!=typeof localStorage)try{return localStorage.getItem("metona-editor-theme")||"auto"}catch(e){}return"auto"},Ze=(e,t)=>{Pe.forEach(n=>{try{n(e,t)}catch(e){}})},Ye=(e,t)=>{if("undefined"==typeof document||"undefined"==typeof MutationObserver)return()=>{};const{element:n=document.documentElement,attr:r="data-theme",classMap:i=null,callback:o=null}=e,s=()=>{if("function"==typeof o)return o(n);const e=n.getAttribute(r);if(e)return e;if(i)for(const[e,t]of Object.entries(i))if(n.classList.contains(e))return t;return n.getAttribute("data-md-theme")||null};let a=s();a&&t(a);const l=new MutationObserver(()=>{const e=s();e&&e!==a&&(a=e,t(e))});return l.observe(n,{attributes:!0,attributeFilter:[r,"class","data-md-theme"]}),()=>l.disconnect()},Ge=(e,t)=>{if("undefined"==typeof document||!e)return()=>{};const n=()=>{let t=e.parentElement;for(;t;){const e=t.getAttribute("data-md-theme");if(e)return e;if(t.classList.contains("theme-dark")||t.classList.contains("dark"))return"dark";if(t.classList.contains("theme-light")||t.classList.contains("light"))return"light";t=t.parentElement}if(e.parentElement){const t=getComputedStyle(e.parentElement).getPropertyValue("--md-bg").trim()||getComputedStyle(e.parentElement).backgroundColor;if(t){const e=t.match(/\d+/g);if(e&&e.length>=3)return(299*parseInt(e[0])+587*parseInt(e[1])+114*parseInt(e[2]))/1e3<128?"dark":"light"}}return null},r=n();r&&t(r);const i=new MutationObserver(()=>{const e=n();e&&t(e)});let o=e.parentElement;for(;o&&(i.observe(o,{attributes:!0,attributeFilter:["class","data-md-theme","data-theme"]}),o=o.parentElement,o!==document.documentElement););return()=>i.disconnect()},Qe=(e,t)=>{if("function"==typeof e){const n=()=>{try{const n=e();n&&t(n)}catch(e){}};n();const r=setInterval(n,500);return()=>clearInterval(r)}if("string"==typeof e&&"undefined"!=typeof document){const n=document.querySelector(e);return n?Ye({element:n,attr:"data-theme"},t):()=>{}}return()=>{}},Xe=e=>{let t=e.config?.theme||Be||"auto";const n=[],r=n=>{t=n;const r=je(n),i=Fe(n);return e.el&&(["me-theme-light","me-theme-dark","me-theme-warm"].forEach(t=>e.el.classList.remove(t)),"auto"!==r&&e.el.classList.add(`me-theme-${r}`),e.el.setAttribute("data-md-theme",r),Oe(i,e.el)),"function"==typeof e._emit&&e._emit("themeChange",{theme:n,resolved:r,config:i}),"function"==typeof e.refresh&&e.refresh(),t};return r(t),{apply:r,get:()=>t,set:e=>r(e),toggle:()=>{const e=je(t);return r("dark"===e?"light":"dark")},getResolved:()=>je(t),getConfig:()=>Fe(t),getVars:()=>e.el?We(e.el):{},syncWithElement:(e,t={})=>{const i=Ye({element:e,attr:t.attr||"data-theme",classMap:t.classMap,callback:t.callback},e=>r(e));return n.push(i),i},adopt:()=>{const t=e.container?Ge(e.container,e=>r(e)):()=>{};return n.push(t),t},watch:e=>{const t=Qe(e,e=>r(e));return n.push(t),t},dispose:()=>{n.forEach(e=>{try{e()}catch(e){}}),n.length=0}}},Je={light:{name:"浅色",description:"明亮清晰",config:a.light},dark:{name:"深色",description:"护眼暗色",config:a.dark},auto:{name:"自动",description:"跟随系统",config:"auto"},warm:{name:"暖色",description:"温馨暖色",config:a.warm}};for(const[e,t]of Object.entries(Je))"auto"!==e&&"auto"!==t.config&&(a[e]=t.config);const et={getSystemTheme:Ie,resolveTheme:je,getThemeConfig:Fe,watchSystemTheme:Re,unwatchSystemTheme:()=>{He&&(He(),He=null)},applyTheme:Ne,getCurrentTheme:()=>Be,getResolvedTheme:Ke,switchTheme:qe,toggleTheme:()=>{const e=Ke();qe("dark"===e?"light":"dark")},resetToAuto:()=>{qe("auto")},initTheme:()=>{Ne(Ue()),Re()},saveTheme:Ve,loadTheme:Ue,addThemeListener:e=>(Pe.add(e),()=>{Pe.delete(e)}),removeThemeListener:e=>{Pe.delete(e)},clearThemeListeners:()=>{Pe.clear()},registerTheme:(e,t={})=>{const n=t.extends||"light",r=a[n]||a.light;a[e]={bg:t.bg||r.bg,text:t.text||r.text,border:t.border||r.border,shadow:t.shadow||r.shadow,hoverShadow:t.hoverShadow||r.hoverShadow,toolbarBg:t.toolbarBg||r.toolbarBg||r.bg,textareaBg:t.textareaBg||r.textareaBg||r.bg,previewBg:t.previewBg||r.previewBg||r.bg,codeBg:t.codeBg||r.codeBg,codeText:t.codeText||r.codeText,accent:t.accent||r.accent,muted:t.muted||r.muted,progressBg:t.progressBg||r.progressBg,closeHoverBg:t.closeHoverBg||r.closeHoverBg}},unregisterTheme:e=>{"light"!==e&&"dark"!==e&&"auto"!==e&&"warm"!==e&&delete a[e]},getAllThemes:()=>({...a}),getThemeNames:()=>Object.keys(a),hasTheme:e=>e in a,setThemeVariables:Oe,exportCSSVars:We,getCSSVariable:De,applyThemeToElement:(e,t)=>{if(!t||"undefined"==typeof document)return;const n=je(e);t.setAttribute("data-md-theme",n),t.classList.remove("md-theme-light","md-theme-dark","md-theme-auto","md-theme-warm"),"auto"!==n&&t.classList.add(`md-theme-${n}`),Oe(Fe(e),t)},followExternalTheme:Ye,adoptFromParent:Ge,watch:Qe,createInstanceTheme:Xe};function tt(e){const t=this.textarea,n=t.selectionStart,r=t.value.slice(0,n),i=(r&&!r.endsWith("\n")?"\n":"")+e;t.value=t.value.slice(0,n)+i+t.value.slice(t.selectionEnd),t.focus();const o=n+i.length;t.selectionStart=t.selectionEnd=o;const s=this._value;this._value=t.value,this._pushHistory(),this._afterProgrammaticEdit(s)}function nt(){if("undefined"==typeof document)return;if(!document.getElementById("me-float-style")){const e=document.createElement("style");e.id="me-float-style",e.textContent=".me-float-toolbar{position:absolute;z-index:25;display:flex;gap:4px;padding:4px 6px;background:var(--md-toolbar-bg,#f8f9fa);border:1px solid var(--md-border,rgba(0,0,0,0.1));border-radius:8px;box-shadow:0 8px 24px -8px rgba(0,0,0,0.2);opacity:0;visibility:hidden;transform:translateY(4px);transition:opacity .15s,transform .15s,visibility .15s;pointer-events:none}.me-float-toolbar.me-visible{opacity:1;visibility:visible;transform:translateY(0);pointer-events:auto}.me-float-toolbar .me-btn{width:28px;height:28px}.me-float-mirror{position:absolute;top:0;left:0;visibility:hidden;pointer-events:none;z-index:-1;border:0;margin:0}",document.head.appendChild(e)}const e=this.textarea,t=()=>{if(this._destroyed||this.config.readOnly||!this._floatingEnabled)return;if(e.selectionStart===e.selectionEnd)return void this._hideFloatingToolbar();this._floatingToolbar&&this._floatingToolbar.parentNode||this._buildFloatingToolbar();const t=this._measureSelectionAnchor();if(!t)return void this._hideFloatingToolbar();if(t.y<-parseFloat(getComputedStyle(e).lineHeight||"22")||t.y>e.clientHeight)return void this._hideFloatingToolbar();const n=this._floatingToolbar,r=n.getBoundingClientRect(),i=r.width||170,o=r.height||38,s=getComputedStyle(e),a=parseFloat(s.lineHeight)||22,l=this.editorPane.getBoundingClientRect().width;let c=t.y-o-6;c<6&&(c=t.y+a+6);let h=t.x-i/2;h=Math.max(4,Math.min(h,l-i-4)),h<4&&(h=4),n.style.top=c+"px",n.style.left=h+"px",n.classList.add("me-visible")},n=()=>{this._hideFloatingToolbar()};let r=!1;const i=()=>setTimeout(t,0),o=()=>{e.selectionStart!==e.selectionEnd?setTimeout(t,0):setTimeout(n,0)},s=()=>setTimeout(()=>{document.activeElement!==e&&n()},300),a=()=>{e.selectionStart===e.selectionEnd&&n()},l=()=>{r||(r=!0,requestAnimationFrame(()=>{r=!1,t()}))},c=()=>n();e.addEventListener("mouseup",i),e.addEventListener("keyup",o),e.addEventListener("blur",s),e.addEventListener("click",a),e.addEventListener("scroll",l),window.addEventListener("resize",c),this._cleanups.push(()=>{e.removeEventListener("mouseup",i),e.removeEventListener("keyup",o),e.removeEventListener("blur",s),e.removeEventListener("click",a),e.removeEventListener("scroll",l),window.removeEventListener("resize",c)})}function rt(){const e=this.textarea;if(!e||!this.editorPane)return null;const t=e.selectionStart,n=e.selectionEnd;if(t===n)return null;const r=Math.floor((t+n)/2);let i=this._floatMirror;i&&i.parentNode||(i=document.createElement("div"),i.className="me-float-mirror",this.editorPane.appendChild(i),this._floatMirror=i);const o=getComputedStyle(e);[["fontFamily",o.fontFamily],["fontSize",o.fontSize],["fontWeight",o.fontWeight],["fontStyle",o.fontStyle],["letterSpacing",o.letterSpacing],["lineHeight",o.lineHeight],["paddingTop",o.paddingTop],["paddingRight",o.paddingRight],["paddingBottom",o.paddingBottom],["paddingLeft",o.paddingLeft],["whiteSpace",o.whiteSpace],["overflowWrap",o.overflowWrap],["wordBreak",o.wordBreak],["tabSize",o.tabSize],["boxSizing","border-box"]].forEach(([e,t])=>{i.style[e]=t}),i.style.width=e.clientWidth+"px",i.textContent="",i.appendChild(document.createTextNode(e.value.slice(0,r)));const s=document.createElement("span");s.textContent="",i.appendChild(s);const a=s.offsetLeft-e.scrollLeft,l=s.offsetTop-e.scrollTop,c=e.getBoundingClientRect(),h=this.editorPane.getBoundingClientRect();return{x:a+c.left-h.left,y:l+c.top-h.top}}function it(){return this._floatingEnabled=!this._floatingEnabled,this._floatingEnabled||this._floatingToolbar&&(this._floatingToolbar.parentNode&&this._floatingToolbar.parentNode.removeChild(this._floatingToolbar),this._floatingToolbar=null),this}function ot(){return this._floatingEnabled}function st(){const e=document.createElement("div");e.className="me-float-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label",this.t("formatToolbar")||"格式化选区"),["bold","italic","code","link","strikethrough"].forEach(t=>{const n=this._createBtn(t);n.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation()}),n.addEventListener("click",()=>{this.exec(t),this._hideFloatingToolbar(),setTimeout(()=>{!this._destroyed&&this.textarea&&this.textarea.focus()},0)}),e.appendChild(n)}),this.editorPane.appendChild(e),this._floatingToolbar=e}function at(){this._floatingToolbar&&this._floatingToolbar.classList.remove("me-visible")}function lt(e=[]){return this._contextMenuItems=e,this}function ct(){if(!this.el)return;const e=e=>{const t=document.querySelector(".me-context-menu");t&&t.remove(),this._showContextMenu(e)};this.el.addEventListener("contextmenu",e),this._cleanups.push(()=>this.el.removeEventListener("contextmenu",e))}function ht(e){e.preventDefault();const n=this.textarea,r=n&&n.selectionStart!==n.selectionEnd,i=[{label:this.t("undo")||"Undo",action:"undo",shortcut:"Ctrl+Z",disabled:!this.canUndo()},{label:this.t("redo")||"Redo",action:"redo",shortcut:"Ctrl+Y",disabled:!this.canRedo()},{sep:!0},{label:this.t("cut")||"Cut",action:"cut",shortcut:"Ctrl+X",disabled:!r},{label:this.t("copy")||"Copy",action:"copy",shortcut:"Ctrl+C",disabled:!r},{label:this.t("paste")||"Paste",action:"paste",shortcut:"Ctrl+V",disabled:!!this.config.readOnly},{label:this.t("selectAll")||"Select All",action:"selectAll",shortcut:"Ctrl+A"}];this._contextMenuItems.length&&(i.push({sep:!0}),this._contextMenuItems.forEach(e=>i.push(e)));const o=document.createElement("div");o.className="me-context-menu",o.style.left=e.clientX+"px",o.style.top=e.clientY+"px",requestAnimationFrame(()=>{const t=o.getBoundingClientRect();t.right>window.innerWidth&&(o.style.left=e.clientX-t.width+"px"),t.bottom>window.innerHeight&&(o.style.top=e.clientY-t.height+"px")}),i.forEach(e=>{if(e.sep){const e=document.createElement("div");return e.className="me-context-menu-sep",void o.appendChild(e)}const n=document.createElement("div");n.className="me-context-menu-item",e.disabled&&n.classList.add("me-disabled"),n.innerHTML=`<span>${t(e.label)}</span>${e.shortcut?`<span class="me-context-menu-shortcut">${t(e.shortcut)}</span>`:""}`,n.addEventListener("click",t=>{t.stopPropagation(),e.disabled||(e.onClick?e.onClick():e.action&&this._execContextAction(e.action),this._hideContextMenu())}),o.appendChild(n)}),document.body.appendChild(o),document.addEventListener("click",e=>{o.contains(e.target)||this._hideContextMenu()},{once:!0}),document.addEventListener("keydown",e=>{"Escape"===e.key&&this._hideContextMenu()},{once:!0})}function dt(){const e=document.querySelector(".me-context-menu");e&&e.remove()}function ut(e){const t=this.textarea;if(t)switch(e){case"undo":this.undo();break;case"redo":this.redo();break;case"cut":document.execCommand("cut");break;case"copy":document.execCommand("copy");break;case"paste":document.execCommand("paste")||this.toast(this.t("pasteBlocked")||"无法直接粘贴,请使用 Ctrl+V",{type:"info"});break;case"selectAll":t.focus(),t.select();break;default:this.exec(e)}}function pt(){if(!this.config.outline||!this.previewEl)return;const e=this.el.querySelector(".me-outline");e&&e.remove();const n=[],r=/<h([1-6])\s+id="([^"]+)"[^>]*>(.+?)<\/h\1>/gi;let i;for(;null!==(i=r.exec(this.previewEl.innerHTML));)n.push({level:parseInt(i[1],10),id:i[2],text:i[3].replace(/<[^>]+>/g,""),srcLine:-1});if(!n.length)return;const o=[],s=this._value.split("\n");let a=!1,l="";const c=e=>/\S/.test(e)&&!/^\s{0,3}([-*+]|\d+\.)\s/.test(e)&&!/^\s{0,3}>/.test(e)&&!/^\s{0,3}(#{1,6}\s|`{3,}|~{3,})/.test(e);for(let e=0;e<s.length;e++){const t=s[e],n=t.match(/^\s{0,3}(`{3,}|~{3,})/);if(n){a?n[1][0]===l&&(a=!1):(a=!0,l=n[1][0]);continue}if(a)continue;if(/^ {0,3}(?:>\s*)*#{1,6}\s+\S/.test(t)){o.push(e);continue}const r=s[e+1]||"";e+1<s.length&&/^ {0,3}(={3,}|-{3,})\s*$/.test(r)&&c(t)&&o.push(e)}n.forEach((e,t)=>{e.srcLine=t<o.length?o[t]:-1});const h=document.createElement("div");h.className="me-outline",h.innerHTML=`<div class="me-outline-title">${this.t("outline")||"大纲"}</div>`,h.innerHTML+=(e=>{let n="";const r=[],i=e=>{for(;r.length&&r[r.length-1]>=e;)n+="</li></ul>",r.pop()};for(const o of e)o.level<1||(i(o.level),n+="<ul>",n+=`<li class="me-outline-l${o.level}"><a href="#${o.id}" data-line="${o.srcLine>=0?o.srcLine+1:""}">${t(o.text)}</a>`,r.push(o.level));return i(-1),n})(n),this.el.appendChild(h),h.addEventListener("click",e=>{const t=e.target.closest("a");if(!t)return;e.preventDefault();const r=t.getAttribute("href").slice(1),i=this.previewEl.querySelector("#"+(e=>"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_\u00A0-\uFFFF-]/g,"\\$&"))(r));i&&i.scrollIntoView({behavior:"smooth",block:"start"});const o=Array.prototype.indexOf.call(h.querySelectorAll("a"),t),a=o>-1&&o<n.length?n[o].srcLine:-1;if(a>=0){const e=s[a]||"",t=(e.match(/^ {0,3}(?:>\s*)*#{1,6}\s+/)||e.match(/^ {0,3}/)||[""])[0].length;this.setCursorPosition(a+1,t)}else{const e=this._value.indexOf(i?.textContent||"");-1!==e&&(this.textarea.focus(),this.textarea.setSelectionRange(e,e))}})}function mt(){this.config.outline&&(this._outlineTimer&&clearTimeout(this._outlineTimer),this._outlineTimer=setTimeout(()=>this._buildOutline(),300))}function gt(){if(!this.config.outline||!this.previewPane)return;if(this._outlineScrollBound)return;this._outlineScrollBound=!0;let e=!1;const t=()=>{e||(e=!0,requestAnimationFrame(()=>{if(e=!1,!this.el)return;const t=this.el.querySelector(".me-outline");if(!t)return;const n=this.previewEl.querySelectorAll("h1, h2, h3, h4, h5, h6");let r="";const i=this.previewPane.scrollTop+80;n.forEach(e=>{e.offsetTop<=i&&(r=e.id)}),t.querySelectorAll("a").forEach(e=>{e.classList.toggle("me-outline-active",e.getAttribute("href")==="#"+r)})}))};this.previewPane.addEventListener("scroll",t,{passive:!0}),this._cleanups.push(()=>this.previewPane.removeEventListener("scroll",t))}const ft=["edit","split","preview"],vt={success:"✓",error:"✗",warning:"⚠",info:"ℹ"},bt={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`","*":"*",_:"_"};class yt{static on(e,t){return this._hooks.has(e)||this._hooks.set(e,[]),this._hooks.get(e).push(t),()=>this.off(e,t)}static off(e,t){const n=this._hooks.get(e);n&&this._hooks.set(e,n.filter(e=>e!==t))}static trigger(e,t){const n=this._hooks.get(e);n&&n.forEach(e=>{try{e(t)}catch(e){}})}constructor(e,t={}){if(this._statsCache=null,this._pendingCursor=null,this._lastSelStart=0,this._lastSelEnd=0,"undefined"==typeof window||"undefined"==typeof document)return this._destroyed=!0,this._value=t.value||"",this;if(this.id=t.id||"me-"+Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,8),this.container="string"==typeof e?document.querySelector(e):e,!this.container)return this._destroyed=!0,this;this.config={...s,...t},t.style&&"object"==typeof t.style&&(this.config.style={...s.style,...t.style}),this._value=this.config.value||"",this._mode=ft.includes(this.config.mode)?this.config.mode:"split",this._history=[],this._historyIndex=-1,this._cleanups=[],this._plugins=[],this._listeners={},this._renderRaf=null,this._historyTimer=null,this._fullscreen=!1,this._destroyed=!1,this._lastRenderedValue=null,this._shortcuts=[],this._contextMenuItems=[],this._customActions={},this._outlineTimer=null,this._zenMode=!0===this.config.zenMode,this._wordWrap=!1!==this.config.wordWrap,this._syncing=!1,this._zenMouseHandler=null,this._floatingToolbar=null,this._floatingEnabled=!1!==this.config.floatingToolbar,this._floatMirror=null,this._renderFn="function"==typeof this.config.render?this.config.render:se,this._highlightFn="function"==typeof this.config.highlight?this.config.highlight:null,yt.trigger("beforeCreate",this),"undefined"!=typeof document&&(d&&document.getElementById("metona-editor-styles")||(d=document.createElement("style"),d.id="metona-editor-styles",d.textContent=':root{--md-bg:#ffffff;--md-text:#1f2937;--md-border:rgba(0,0,0,0.08);--md-shadow:0 10px 36px -10px rgba(0,0,0,0.18),0 4px 14px -4px rgba(0,0,0,0.08);--md-hover-shadow:0 14px 48px -10px rgba(0,0,0,0.22),0 6px 18px -4px rgba(0,0,0,0.10);--md-toolbar-bg:rgba(248,249,250,0.92);--md-textarea-bg:#ffffff;--md-preview-bg:#ffffff;--md-code-bg:rgba(243,244,246,1);--md-code-text:#1f2937;--md-accent:#3b82f6;--md-muted:#6b7280;--md-radius:10px;--md-font:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei","Hiragino Sans GB",sans-serif;--md-mono:"SF Mono","Cascadia Code","Consolas","Liberation Mono","Courier New",monospace}\n.me-wrapper{display:flex;flex-direction:column;box-sizing:border-box;border:1px solid var(--md-border);border-radius:var(--md-radius);overflow:hidden;background:var(--md-bg);color:var(--md-text);box-shadow:var(--md-shadow);font-family:var(--md-font);font-size:14px;line-height:1.6;position:relative;transition:box-shadow .25s,border-color .25s;width:100%}\n.me-wrapper:hover{box-shadow:var(--md-hover-shadow)}\n.me-wrapper.me-disabled{opacity:.6;pointer-events:none}\n.me-wrapper *{box-sizing:border-box}\n.me-wrapper.me-fullscreen{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;z-index:9999;border-radius:0;border:0}\n.me-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:2px;padding:6px 8px;background:var(--md-toolbar-bg);border-bottom:1px solid var(--md-border);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);min-height:40px}\n.me-btn{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:0;border-radius:6px;background:transparent;color:var(--md-text);cursor:pointer;transition:background .15s,color .15s,transform .1s;flex-shrink:0}\n.me-btn:hover{background:var(--md-code-bg);color:var(--md-accent)}\n.me-btn:active{transform:scale(.92)}\n.me-btn.me-active{background:var(--md-accent);color:#fff}\n.me-btn:disabled{opacity:.35;cursor:not-allowed;pointer-events:none}\n.me-btn:focus-visible{outline:2px solid var(--md-accent);outline-offset:2px}\n.me-btn:focus:not(:focus-visible){outline:none}\n.me-btn svg{width:17px;height:17px;display:block}\n.me-btn span{font-size:12px;font-weight:500}\n.me-toolbar-sep{display:inline-block;width:1px;height:20px;background:var(--md-border);margin:0 4px;flex-shrink:0}\n.me-toolbar-group{display:inline-flex;gap:2px;margin-left:auto;padding-left:6px;border-left:1px solid var(--md-border)}\n.me-toolbar-group .me-btn{width:auto;padding:0 8px}\n.me-body{display:flex;flex:1;min-height:0;position:relative}\n.me-editor-pane,.me-preview-pane{flex:1 1 50%;min-width:0;overflow:hidden;position:relative}\n.me-editor-inner{display:flex;height:100%;overflow:hidden;position:relative}\n.me-gutter{flex:0 0 auto;min-width:36px;padding:16px 8px 16px 6px;overflow:hidden;background:var(--md-code-bg);border-right:1px solid var(--md-border);color:var(--md-muted);font-family:var(--md-mono);font-size:13.5px;line-height:1.7;text-align:right;user-select:none;white-space:pre}\n.me-gutter-line{padding-right:4px}\n.me-gutter-active{color:var(--md-accent);font-weight:600;background:rgba(59,130,246,.08);border-radius:3px}\n.me-divider{flex:0 0 1px;background:var(--md-border);cursor:col-resize;position:relative}\n.me-divider::after{content:\'\';position:absolute;top:0;bottom:0;left:-3px;right:-3px}\n.me-divider:hover{background:var(--md-accent)}\n.me-textarea{width:100%;height:100%;padding:16px 18px;border:0;outline:0;resize:none;background:var(--md-textarea-bg);color:var(--md-text);font-family:var(--md-mono);font-size:13.5px;line-height:1.7;display:block;white-space:pre-wrap;word-wrap:break-word;position:relative;z-index:1}\n.me-textarea::placeholder{color:var(--md-muted);opacity:.7}\n.me-textarea:focus{outline:0}\n.me-preview-pane{overflow:auto;background:var(--md-preview-bg)}\n.me-preview{padding:18px 22px;max-width:100%;word-wrap:break-word;overflow-wrap:break-word}\n.me-body.me-mode-edit .me-preview-pane,.me-body.me-mode-edit .me-divider{display:none}\n.me-body.me-mode-edit .me-editor-pane{flex:1 1 100%}\n.me-body.me-mode-preview .me-editor-pane,.me-body.me-mode-preview .me-divider{display:none}\n.me-body.me-mode-preview .me-preview-pane{flex:1 1 100%}\n.me-preview>:first-child{margin-top:0}\n.me-preview>:last-child{margin-bottom:0}\n.me-preview h1,.me-preview h2,.me-preview h3,.me-preview h4,.me-preview h5,.me-preview h6{margin:1.4em 0 .6em;font-weight:650;line-height:1.3}\n.me-preview h1{font-size:1.9em;padding-bottom:.3em;border-bottom:1px solid var(--md-border)}\n.me-preview h2{font-size:1.55em;padding-bottom:.3em;border-bottom:1px solid var(--md-border)}\n.me-preview h3{font-size:1.3em}\n.me-preview h4{font-size:1.12em}\n.me-preview h5{font-size:1em}\n.me-preview h6{font-size:.9em;color:var(--md-muted)}\n.me-preview p{margin:.7em 0}\n.me-preview a{color:var(--md-accent);text-decoration:none}\n.me-preview a:hover{text-decoration:underline}\n.me-preview strong{font-weight:650}\n.me-preview em{font-style:italic}\n.me-preview del{text-decoration:line-through;opacity:.75}\n.me-preview ul,.me-preview ol{margin:.6em 0;padding-left:1.6em}\n.me-preview li{margin:.25em 0}\n.me-preview li.me-task-item{list-style:none;margin-left:-1.4em}\n.me-preview li.me-task-item input{margin-right:.5em;vertical-align:middle}\n.me-preview blockquote{margin:.8em 0;padding:.4em 1em;border-left:3px solid var(--md-accent);background:var(--md-code-bg);border-radius:0 6px 6px 0;color:var(--md-text)}\n.me-preview blockquote>:first-child{margin-top:0}\n.me-preview blockquote>:last-child{margin-bottom:0}\n.me-preview hr{border:0;height:1px;background:var(--md-border);margin:1.6em 0}\n.me-preview code{font-family:var(--md-mono);font-size:.88em;padding:.15em .4em;background:var(--md-code-bg);color:var(--md-code-text);border-radius:4px}\n.me-preview pre{margin:.9em 0;padding:14px 16px;background:var(--md-code-bg);border-radius:8px;overflow-x:auto;border:1px solid var(--md-border)}\n.me-code-title{font-family:var(--md-mono);font-size:.85em;padding:8px 14px;background:var(--md-border);border-radius:8px 8px 0 0;color:var(--md-text);margin:.9em 0 -0.9em;font-weight:600}\n.me-code-title+pre{margin-top:0;border-radius:0 0 8px 8px;border-top:none}\n.me-preview pre code{padding:0;background:transparent;color:var(--md-code-text);font-size:.9em;line-height:1.6;border-radius:0}\n.me-hl-keyword{color:#c678dd}\n.me-hl-string{color:#98c379}\n.me-hl-comment{color:#7f848e;font-style:italic}\n.me-hl-number{color:#d19a66}\n.me-hl-builtin{color:#e5c07b}\n.me-hl-function{color:#61afef}\n.me-theme-light .me-hl-keyword{color:#9c4cc0}\n.me-theme-light .me-hl-string{color:#4f9d4f}\n.me-theme-light .me-hl-comment{color:#8b8b8b}\n.me-theme-light .me-hl-number{color:#b06a22}\n.me-theme-light .me-hl-builtin{color:#9a7d0f}\n.me-theme-light .me-hl-function{color:#2a7fd4}\n.me-preview img{max-width:100%;height:auto;border-radius:6px;vertical-align:middle}\n.me-table-wrap{overflow-x:auto;margin:.9em 0}\n.me-preview table{border-collapse:collapse;width:100%;font-size:.93em;display:block}\n.me-preview th,.me-preview td{border:1px solid var(--md-border);padding:7px 12px;text-align:left}\n.me-preview th{background:var(--md-code-bg);font-weight:600}\n.me-preview tr:nth-child(even) td{background:var(--md-code-bg)}\n.me-statusbar{display:flex;align-items:center;justify-content:flex-end;gap:14px;padding:4px 12px;border-top:1px solid var(--md-border);background:var(--md-toolbar-bg);color:var(--md-muted);font-size:12px;min-height:26px}\n.me-statusbar:empty{display:none}\n.me-wrapper:focus-within{border-color:var(--md-accent)}\n.me-textarea:focus-visible{outline:0}\n@media(prefers-reduced-motion:reduce){.me-wrapper,.me-btn,.me-textarea{transition:none!important}}\n.me-wrapper.me-fullscreen .me-preview,.me-wrapper.me-fullscreen .me-textarea{font-size:15px}\n.me-wrapper.me-readonly .me-textarea{background:var(--md-code-bg);cursor:default;opacity:.88}\n.me-wrapper.me-readonly .me-toolbar{opacity:.75}\n.me-wrapper.me-readonly .me-btn:disabled{opacity:.3;cursor:not-allowed;pointer-events:none}\n.me-preview mark{background:rgba(250,204,21,.3);color:inherit;padding:.1em .2em;border-radius:3px}\n.me-preview sup{font-size:.75em;vertical-align:super;line-height:1}\n.me-preview sub{font-size:.75em;vertical-align:sub;line-height:1}\n.me-preview .me-math-block{display:block;margin:1.2em 0;padding:12px 16px;background:var(--md-code-bg);border-radius:8px;overflow-x:auto;font-family:var(--md-mono);font-size:.95em;text-align:center}\n.me-preview .me-math-inline{font-family:var(--md-mono);font-size:.95em;padding:.05em .2em}\n.me-preview dl{margin:.8em 0}\n.me-preview dt{font-weight:650;margin:.6em 0 .2em}\n.me-preview dd{margin:0 0 .3em 1.6em;color:var(--md-text)}\n.me-preview .me-footnote-ref a{font-size:.75em;vertical-align:super;text-decoration:none;color:var(--md-accent)}\n.me-preview .me-footnotes{margin-top:2em;border-top:1px solid var(--md-border);padding-top:.8em;font-size:.9em;color:var(--md-muted)}\n.me-preview .me-footnotes hr{display:none}\n.me-preview .me-footnotes ol{padding-left:1.2em}\n.me-preview .me-footnote-item{margin:.3em 0}\n.me-preview .me-footnote-backref{text-decoration:none;color:var(--md-accent);margin-right:.4em}\n.me-toast{position:absolute;bottom:16px;right:16px;z-index:30;display:flex;align-items:center;gap:8px;padding:10px 16px;border-radius:8px;font-size:13px;pointer-events:auto;cursor:pointer;opacity:0;transform:translateY(12px);transition:opacity .3s,transform .3s;box-shadow:0 6px 20px rgba(0,0,0,.15);max-width:360px}\n.me-toast.me-toast-enter{opacity:1;transform:translateY(0)}\n.me-toast.me-toast-leave{opacity:0;transform:translateY(12px)}\n.me-toast-success{background:#10b981;color:#fff}\n.me-toast-error{background:#ef4444;color:#fff}\n.me-toast-warning{background:#f59e0b;color:#fff}\n.me-toast-info{background:var(--md-accent,#3b82f6);color:#fff}\n.me-toast-icon{font-weight:700;font-size:16px;flex-shrink:0}\n.me-toast-msg{line-height:1.4}\n.me-context-menu{position:fixed;z-index:40;min-width:180px;padding:4px 0;background:var(--md-bg);border:1px solid var(--md-border);border-radius:8px;box-shadow:0 8px 28px rgba(0,0,0,.18);font-size:13px}\n.me-context-menu-item{display:flex;align-items:center;justify-content:space-between;padding:6px 14px;cursor:pointer;color:var(--md-text);transition:background .1s}\n.me-context-menu-item:hover{background:var(--md-code-bg);color:var(--md-accent)}\n.me-context-menu-sep{height:1px;background:var(--md-border);margin:4px 0}\n.me-context-menu-shortcut{color:var(--md-muted);font-size:11px;margin-left:24px}\n.me-context-menu-item.me-disabled{opacity:.4;cursor:not-allowed;pointer-events:none}\n.me-outline{position:absolute;top:0;right:0;width:220px;height:100%;overflow-y:auto;background:var(--md-preview-bg);border-left:1px solid var(--md-border);padding:12px 14px;font-size:13px;z-index:15}\n.me-outline-title{font-weight:650;margin-bottom:8px;padding-bottom:6px;border-bottom:1px solid var(--md-border);color:var(--md-text)}\n.me-outline ul{list-style:none;padding:0;margin:0}\n.me-outline li{margin:2px 0}\n.me-outline a{color:var(--md-muted);text-decoration:none;display:block;padding:2px 6px;border-radius:4px;transition:background .1s,color .1s}\n.me-outline a:hover{background:var(--md-code-bg);color:var(--md-accent)}\n.me-outline a.me-outline-active{background:var(--md-accent);color:#fff;font-weight:600}\n.me-outline-l1 a{font-weight:600;color:var(--md-text)}\n.me-outline-l2 a{padding-left:12px}\n.me-outline-l3 a{padding-left:20px;font-size:12px}\n.me-outline-l4 a{padding-left:28px;font-size:12px}\n.me-wrapper.me-zen .me-body{max-width:var(--md-zen-max-width,960px);margin:0 auto}\n.me-wrapper.me-zen .me-textarea{font-size:15px;line-height:1.8}\n.me-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n@media print{.me-wrapper{border:0!important;box-shadow:none!important}\n.me-toolbar,.me-statusbar,.me-divider{display:none!important}\n.me-body.me-mode-split .me-editor-pane{display:none}\n.me-body.me-mode-split .me-preview-pane{flex:1 1 100%!important}\n.me-preview{padding:0!important;font-size:11pt}\n.me-wrapper.me-fullscreen{position:static!important;width:auto!important;height:auto!important}}\n[dir=rtl] .me-gutter{border-right:none;border-left:1px solid var(--md-border);text-align:left}\n[dir=rtl] .me-gutter-line{padding-right:0;padding-left:4px}\n[dir=rtl] .me-toolbar-group{margin-left:0;margin-right:auto;padding-left:0;padding-right:6px;border-left:none;border-right:1px solid var(--md-border)}\n[dir=rtl] .me-outline{right:auto;left:0;border-left:none;border-right:1px solid var(--md-border)}\n[dir=rtl] .me-outline-l2 a{padding-left:0;padding-right:12px}\n[dir=rtl] .me-outline-l3 a{padding-left:0;padding-right:20px}\n[dir=rtl] .me-outline-l4 a{padding-left:0;padding-right:28px}\n[dir=rtl] .me-preview blockquote{border-left:none;border-right:3px solid var(--md-accent);border-radius:6px 0 0 6px}\n[dir=rtl] .me-preview ul,[dir=rtl] .me-preview ol{padding-left:0;padding-right:1.6em}\n[dir=rtl] .me-preview li.me-task-item{margin-left:0;margin-right:-1.4em}\n[dir=rtl] .me-preview dd{margin-left:0;margin-right:1.6em}\n[dir=rtl] .me-preview .me-footnotes ol{padding-left:0;padding-right:1.2em}\n[dir=rtl] .me-preview .me-footnote-backref{margin-right:0;margin-left:.4em}\n[dir=rtl] .me-search{right:auto;left:12px}\n[dir=rtl] .me-toast{right:auto;left:16px}\n[dir=rtl] .me-context-menu-shortcut{margin-left:0;margin-right:24px}\n[dir=rtl] .me-statusbar{justify-content:flex-start}',document.head.appendChild(d))),this._i18nCtx=z(this),this._buildDOM(),this._applyZenWidth(),this._themeCtx=Xe(this),t.theme&&"undefined"!=typeof document&&document.documentElement.setAttribute("data-md-theme",je(t.theme));const n=Fe(this.config.theme);if(Oe(n,this.el),this._buildToolbar(),this._updateModeButtons(),this._bindToolbarKeyboard(),this._initAriaLive(),this._bindEvents(),this._bindContextMenu(),this._trackOutlineScroll(),this._initFloatingToolbar(),this.textarea.value=this._value,this._wordWrap||(this.textarea.style.whiteSpace="pre"),this._pushHistory(),this._render(),this._updateWordCount(),this._buildOutline(),this._zenMode&&this._setZen(!0),Array.isArray(this.config.plugins)){const e=this.config.plugins.map(e=>"string"==typeof e?{...ze[e],_isStringRef:!0}:e).filter(Boolean);Te(e).forEach(e=>this.use(e))}if(this.config.autofocus&&!this.config.readOnly&&this.focus(),"function"==typeof this.config.onCreate)try{this.config.onCreate(this)}catch(e){}yt.trigger("afterCreate",this)}_buildDOM(){const e=document.createElement("div");var t;e.className=`me-wrapper me-theme-${t=this.config.theme,t&&"auto"!==t?t:je("auto")}`,this.config.readOnly&&e.classList.add("me-readonly"),e.dataset.id=this.id,e.setAttribute("role","application"),e.setAttribute("aria-label",this.t("edit")),this.config.className&&this.config.className.split(/\s+/).filter(Boolean).forEach(t=>e.classList.add(t));const n=this.config.height;e.style.height="number"==typeof n?`${n}px`:n||"400px",this.config.style&&"object"==typeof this.config.style&&Object.entries(this.config.style).forEach(([t,n])=>{n&&(e.style[t]=n)});const r=document.createElement("div");r.className="me-toolbar",r.setAttribute("role","toolbar");const i=document.createElement("div");i.className=`me-body me-mode-${this._mode}`;const o=document.createElement("div");o.className="me-editor-pane";const s=document.createElement("div");s.className="me-editor-inner";const a=document.createElement("div");a.className="me-gutter",this.config.lineNumbers||(a.style.display="none"),s.appendChild(a);const l=document.createElement("textarea");l.className="me-textarea",l.spellcheck=!!this.config.spellcheck,l.readOnly=!!this.config.readOnly,this.config.maxLength&&this.config.maxLength>0&&(l.maxLength=this.config.maxLength),l.style.tabSize=String(this.config.tabSize||2),l.placeholder=this.config.placeholder||this.t("placeholder"),l.setAttribute("aria-label",this.t("edit")),s.appendChild(l),o.appendChild(s);const c=document.createElement("div");c.className="me-divider",c.setAttribute("role","separator");const h=document.createElement("div");h.className="me-preview-pane",h.setAttribute("role","region"),h.setAttribute("aria-label",this.t("preview"));const d=document.createElement("div");d.className="me-preview",h.appendChild(d),i.appendChild(o),i.appendChild(c),i.appendChild(h),e.appendChild(r),e.appendChild(i);let u=null;this.config.wordCount&&(u=document.createElement("div"),u.className="me-statusbar",e.appendChild(u)),this.container.appendChild(e),this.el=e,this.toolbarEl=r,this.bodyEl=i,this.editorPane=o,this.editorInner=s,this.gutter=a,this.previewPane=h,this.dividerEl=c,this.textarea=l,this.previewEl=d,this.statusEl=u,this._restoreDividerPosition()}_buildToolbar(){const e=this.config.toolbar;if(!e||!Array.isArray(e)||0===e.length)return;const t=[];if(e.forEach(e=>{if("|"===e){const e=document.createElement("span");return e.className="me-toolbar-sep",void this.toolbarEl.appendChild(e)}"edit"!==e&&"split"!==e&&"preview"!==e&&"fullscreen"!==e?this.toolbarEl.appendChild(this._createBtn(e)):t.push(e)}),t.length){const e=document.createElement("div");e.className="me-toolbar-group",t.forEach(t=>{const n=this._createBtn(t);"edit"!==t&&"split"!==t&&"preview"!==t||(n.dataset.mode=t,t===this._mode&&n.classList.add("me-active")),e.appendChild(n)}),this.toolbarEl.appendChild(e)}}_createBtn(e){const n=document.createElement("button");n.type="button",n.className=`me-btn me-btn-${e}`,n.dataset.action=e;const i=this.t(e)||e;return n.title=i,n.setAttribute("aria-label",i),n.innerHTML=r[e]||`<span>${t(e)}</span>`,n}_bindEvents(){const e=this.textarea,t=()=>{const t=this._value;if(this._value=e.value,yt.trigger("beforeChange",this),this._emit("beforeChange",t,this._value),this._scheduleRender(),this._scheduleHistory(),this._updateWordCount(),this._renderGutter(),this._updateOutline(),this._emit("input",this._value),this._emit("change",this._value),"function"==typeof this.config.onInput)try{this.config.onInput(this._value,this)}catch(e){}if("function"==typeof this.config.onChange)try{this.config.onChange(this._value,this)}catch(e){}this._emit("afterChange",this._value),yt.trigger("afterChange",this)};e.addEventListener("input",t);const n=e=>{"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||this._handleSmartEnter(e),this._handleKeydown(e)};e.addEventListener("keydown",n);const r=e=>this._handleBracketAutoClose(e);e.addEventListener("keypress",r);const i=()=>{this._updateCurrentLine(),this._emitCursorEvents()};e.addEventListener("click",i),e.addEventListener("keyup",i);const o=()=>{this._syncScroll()};e.addEventListener("scroll",o);const s=()=>{if(!this.config.syncScroll||"split"!==this._mode)return;if(this._syncing)return;this._syncing=!0;const t=this.previewPane.scrollHeight-this.previewPane.clientHeight;if(t<=0)return void(this._syncing=!1);const n=this.previewPane.scrollTop/t,r=e.scrollHeight-e.clientHeight;if(e.scrollTop=n*r,this.gutter){const e=this.gutter.scrollHeight-this.gutter.clientHeight;this.gutter.scrollTop=e>0?n*e:n*r}requestAnimationFrame(()=>{this._syncing=!1})};this.previewPane.addEventListener("scroll",s);const a=()=>{if(this._emit("focus"),"function"==typeof this.config.onFocus)try{this.config.onFocus(this)}catch(e){}},l=()=>{if(this._emit("blur"),"function"==typeof this.config.onBlur)try{this.config.onBlur(this)}catch(e){}};e.addEventListener("focus",a),e.addEventListener("blur",l),this.previewEl.addEventListener("click",e=>{const t=e.target.closest("a");if(!t)return;const n=t.getAttribute("href");if(n&&!n.startsWith("#"))if(e.preventDefault(),this._emit("linkClick",{href:n,text:t.textContent}),"function"!=typeof this.config.onLinkClick)window.open(n,"_blank","noopener");else try{this.config.onLinkClick(n,t.textContent,this)}catch(e){}});const c=e=>{const t=e.target.closest(".me-btn");if(!t)return;const n=t.dataset.mode;if(n)return void this.setMode(n);const r=t.dataset.action;r&&this.exec(r)};this.toolbarEl.addEventListener("click",c);const h=e=>this._bindDividerDrag(e);this.dividerEl.addEventListener("pointerdown",h);const d=e=>{"Escape"===e.key&&this._fullscreen&&this.exitFullscreen()};document.addEventListener("keydown",d),this._bindDragDrop(),this._cleanups.push(()=>{e.removeEventListener("input",t),e.removeEventListener("keydown",n),e.removeEventListener("keypress",r),e.removeEventListener("scroll",o),this.previewPane.removeEventListener("scroll",s),e.removeEventListener("click",i),e.removeEventListener("keyup",i),e.removeEventListener("focus",a),e.removeEventListener("blur",l),this.toolbarEl.removeEventListener("click",c),this.dividerEl.removeEventListener("pointerdown",h),document.removeEventListener("keydown",d)})}_handleKeydown(e){if("Tab"===e.key)return e.preventDefault(),void this._handleTab(e.shiftKey);if(this._shortcuts.length)for(const t of this._shortcuts){const n=t.ctrl?e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey,r=t.shift?e.shiftKey:!e.shiftKey,i=t.alt?e.altKey:!e.altKey;if(e.key.toLowerCase()===t.key&&n&&r&&i){if(e.preventDefault(),"string"==typeof t.handler)this.exec(t.handler);else if("function"==typeof t.handler)try{t.handler(this)}catch(e){}return}}if(!e.ctrlKey&&!e.metaKey)return;const t=e.key.toLowerCase(),n={b:"bold",i:"italic",k:"link",u:"underline",e:"code",1:"h1",2:"h2",3:"h3",q:"quote"};if("z"!==t||e.shiftKey)if("z"===t&&e.shiftKey||"y"===t)e.preventDefault(),this.redo();else if("s"===t){if(e.preventDefault(),this._emit("save",this._value),"function"==typeof this.config.onSave)try{this.config.onSave(this._value,this)}catch(e){}}else n[t]&&(e.preventDefault(),this.exec(n[t]));else e.preventDefault(),this.undo()}_handleTab(e){const t=this.textarea,n=t.selectionStart,r=t.selectionEnd,i=this.config.tabSize||0,o=i>0?" ".repeat(i):"\t";if(n===r)t.value=t.value.slice(0,n)+o+t.value.slice(r),t.selectionStart=t.selectionEnd=n+o.length;else{const i=t.value.lastIndexOf("\n",n-1)+1,s=t.value.slice(i,r).split("\n");let a;a=e?s.map(e=>e.replace(/^(\t| {1,4})/,"")).join("\n"):s.map(e=>o+e).join("\n"),t.value=t.value.slice(0,i)+a+t.value.slice(r),t.selectionStart=i,t.selectionEnd=i+a.length}const s=this._value;this._value=t.value,this._pushHistory(),this._afterProgrammaticEdit(s)}_bindDividerDrag(e){if("split"!==this._mode)return;e.preventDefault();const t=e.clientX,n=this.editorPane.getBoundingClientRect().width,r=this.bodyEl.getBoundingClientRect().width;if(r<=0)return;const i=this.dividerEl,o=e=>{const o=e.clientX-t;let s=n+o;const a=r-80-i.offsetWidth;s=Math.max(80,Math.min(a,s));const l=s/r*100;this.editorPane.style.flex=`0 0 ${l}%`,this.previewPane.style.flex=`1 1 ${100-l}%`},s=()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",s),this._saveDividerPosition(),this._hideFloatingToolbar()};window.addEventListener("pointermove",o),window.addEventListener("pointerup",s)}_saveDividerPosition(){try{const e=this.editorPane.style.flex;e&&localStorage.setItem(`metona-editor-divider-${this.id}`,e)}catch(e){}}_restoreDividerPosition(){try{const e=localStorage.getItem(`metona-editor-divider-${this.id}`);e&&"split"===this._mode&&(this.editorPane.style.flex=e,this.previewPane.style.flex="1 1 auto")}catch(e){}}_scheduleRender(){this._renderRaf||(this._renderRaf=requestAnimationFrame(()=>{this._renderRaf=null,this._render()}))}_render(){if("edit"===this._mode)return void this._renderGutter();if(this._lastRenderedValue===this._value)return;let e;this._lastRenderedValue=this._value,yt.trigger("beforeRender",this),this._emit("beforeRender",this);try{e=this._renderFn(this._value,{highlight:this._highlightFn||void 0,locale:this.getLocale()})}catch(n){e=`<p style="color:#ef4444">${this.t("renderError")}: ${t(n.message)}</p>`}if("function"==typeof this.config.sanitize)try{e=this.config.sanitize(e)}catch(e){}this.previewEl.innerHTML=e,this._renderGutter(),yt.trigger("afterRender",this),this._emit("afterRender",this)}_renderGutter(){if(!this.config.lineNumbers||!this.gutter)return;const e=this.getStats(),t=e.lines>0?e.lines:1,n=this.gutter.children.length;if(n!==t)if(n<t){let e="";for(let r=n+1;r<=t;r++)e+=`<div class="me-gutter-line">${r}</div>`;this.gutter.insertAdjacentHTML("beforeend",e)}else for(;this.gutter.children.length>t;)this.gutter.removeChild(this.gutter.lastChild)}_updateCurrentLine(){if(!this.gutter)return;const e=this.textarea.selectionStart,t=this._value.substring(0,e).split("\n").length,n=this.gutter.querySelector(".me-gutter-active");n&&n.classList.remove("me-gutter-active");const r=this.gutter.children[t-1];r&&r.classList.add("me-gutter-active")}_emitCursorEvents(){if(!this.textarea)return;const e=this.textarea.selectionStart,t=this.textarea.selectionEnd;e===this._lastSelStart&&t===this._lastSelEnd||(this._lastSelStart=e,this._lastSelEnd=t,this._emit("selectionChange",{start:e,end:t,text:this._value.slice(e,t)})),this._emit("cursorMove",this.getCursorPosition())}_handleSmartEnter(e){const t=this.textarea,n=t.selectionStart,r=t.value,i=r.lastIndexOf("\n",n-1)+1,o=r.slice(i,n),s=o.match(/^(\s*)([-*+]|\d+\.)\s(.*)/);if(s){const o=s[1],a=s[2];if(!s[3].trim()){e.preventDefault();const o=this._value;return t.value=r.slice(0,i)+"\n"+r.slice(n),t.selectionStart=t.selectionEnd=i,this._value=t.value,this._pushHistory(),void this._afterProgrammaticEdit(o)}let l=a;if(/^\d+\.$/.test(a)){const e=parseInt(a,10);isNaN(e)||(l=e+1+".")}e.preventDefault();const c="\n"+o+l+" ";t.value=r.slice(0,n)+c+r.slice(t.selectionEnd),t.selectionStart=t.selectionEnd=n+c.length;const h=this._value;return this._value=t.value,this._pushHistory(),void this._afterProgrammaticEdit(h)}const a=o.match(/^(\s*>+\s?)(.*)/);if(a){const o=a[1];if(!a[2].trim()){e.preventDefault();const o=this._value;return t.value=r.slice(0,i)+"\n"+r.slice(n),t.selectionStart=t.selectionEnd=i,this._value=t.value,this._pushHistory(),void this._afterProgrammaticEdit(o)}e.preventDefault();const s="\n"+o;t.value=r.slice(0,n)+s+r.slice(t.selectionEnd),t.selectionStart=t.selectionEnd=n+s.length;const l=this._value;this._value=t.value,this._pushHistory(),this._afterProgrammaticEdit(l)}}_handleBracketAutoClose(e){if(!this.config.autoBrackets)return;const t=this.textarea,n=e.key,r=bt[n];if(!r)return;const i=t.selectionStart,o=t.selectionEnd;if(i!==o){e.preventDefault();const s=this._value,a=t.value.slice(i,o),l=n+a+r;return t.value=t.value.slice(0,i)+l+t.value.slice(o),t.selectionStart=i+1,t.selectionEnd=i+1+a.length,this._value=t.value,this._pushHistory(),void this._afterProgrammaticEdit(s)}const s=t.value[i]||"";if(n===r){if(s===r)return e.preventDefault(),void(t.selectionStart=t.selectionEnd=i+1);if(/\w/.test(s))return}e.preventDefault();const a=this._value,l=n+r;t.value=t.value.slice(0,i)+l+t.value.slice(o),t.selectionStart=t.selectionEnd=i+1,this._value=t.value,this._pushHistory(),this._afterProgrammaticEdit(a)}_bindDragDrop(){const e=this.textarea;if(!e)return;const t=e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},n=e=>{e.preventDefault();const t=e.dataTransfer?.files;if(t&&t.length)return void Array.from(t).forEach(e=>{if(e.type.startsWith("image/")){const t=e.size/1024;if(t>500)return void this.toast(this.t("imageTooLarge",{size:t.toFixed(0),max:500})||`Image too large (${t.toFixed(0)}KB > 500KB)`,{type:"warning"});const n=new FileReader;n.onload=()=>{this.insert(`\n`)},n.readAsDataURL(e)}else if(e.type.startsWith("text/")||/\.(md|txt|js|ts|json|css|html|xml|yml|yaml)$/i.test(e.name)){const t=new FileReader;t.onload=()=>this.insert(t.result),t.readAsText(e)}});const n=e.dataTransfer?.getData("text/plain");n&&this.insert(n)};e.addEventListener("dragover",t),e.addEventListener("drop",n),this._cleanups.push(()=>{e.removeEventListener("dragover",t),e.removeEventListener("drop",n)})}_scheduleHistory(){this._historyTimer&&clearTimeout(this._historyTimer),this._historyTimer=setTimeout(()=>this._pushHistory(),this.config.historyDebounce||400)}_afterProgrammaticEdit(e){if(yt.trigger("beforeChange",this),this._emit("beforeChange",e,this._value),this._render(),this._renderGutter(),this._updateWordCount(),this._updateOutline(),this._emit("input",this._value),this._emit("change",this._value),"function"==typeof this.config.onInput)try{this.config.onInput(this._value,this)}catch(e){}if("function"==typeof this.config.onChange)try{this.config.onChange(this._value,this)}catch(e){}this._emit("afterChange",this._value),yt.trigger("afterChange",this)}_pushHistory(){if(this.config.maxLength&&this.config.maxLength>0&&this._value.length>this.config.maxLength&&(this._value=this._value.slice(0,this.config.maxLength),this.textarea&&(this.textarea.value=this._value)),this._history[this._historyIndex]===this._value)return;this._history=this._history.slice(0,this._historyIndex+1),this._history.push(this._value);const e=this.config.historyLimit>0?this.config.historyLimit:100;for(;this._history.length>e;)this._history.shift();this._historyIndex=this._history.length-1}undo(){return this._historyIndex<=0||(this._captureCursor(),this._historyIndex--,this._applyHistory(),this._restoreCapturedCursor()),this}redo(){return this._historyIndex>=this._history.length-1||(this._captureCursor(),this._historyIndex++,this._applyHistory(),this._restoreCapturedCursor()),this}canUndo(){return this._historyIndex>0}canRedo(){return this._historyIndex<this._history.length-1}_applyHistory(){const e=this.previewPane,t=e?e.scrollHeight-e.clientHeight:0,n=t>0?e.scrollTop/t:null,r=this._value;if(this._value=this._history[this._historyIndex],this.textarea.value=this._value,this._afterProgrammaticEdit(r),this.gutter&&(this.gutter.scrollTop=this.textarea.scrollTop),e&&null!=n){const t=e.scrollHeight-e.clientHeight;t>0&&(e.scrollTop=n*t)}}_captureCursor(){this.textarea&&(this._pendingCursor={start:this.textarea.selectionStart,end:this.textarea.selectionEnd})}_restoreCapturedCursor(){if(!this._pendingCursor||!this.textarea)return;const e=this._value.length,t=Math.min(this._pendingCursor.start,e),n=Math.min(this._pendingCursor.end,e);try{this.textarea.setSelectionRange(t,n)}catch{}this._pendingCursor=null}exec(e,...t){const n={bold:()=>this._wrapSelection("**","**"),italic:()=>this._wrapSelection("*","*"),strikethrough:()=>this._wrapSelection("~~","~~"),underline:()=>this._wrapSelection("<u>","</u>"),code:()=>this._wrapSelection("`","`"),h1:()=>this._toggleLinePrefix("# "),h2:()=>this._toggleLinePrefix("## "),h3:()=>this._toggleLinePrefix("### "),quote:()=>this._toggleLinePrefix("> "),ul:()=>this._toggleLinePrefix("- "),ol:()=>this._toggleLinePrefix("1. "),indent:()=>this._handleTab(!1),outdent:()=>this._handleTab(!0),hr:()=>this._insertBlock("\n---\n"),link:()=>this._insertLink(),image:()=>this._insertImage(),table:()=>this._insertTable(),undo:()=>this.undo(),redo:()=>this.redo(),edit:()=>this.setMode("edit"),split:()=>this.setMode("split"),preview:()=>this.setMode("preview"),fullscreen:()=>this.toggleFullscreen(),zen:()=>this.toggleZen(),wordwrap:()=>this.toggleWordWrap(),formatTable:()=>this._formatTable()}[e];if(n)return n.apply(this,t),this;if(this._customActions&&"function"==typeof this._customActions[e])try{this._customActions[e].apply(this,t)}catch(e){}return this}setMode(e){if(!ft.includes(e)||e===this._mode)return this;const t=this.textarea.scrollTop,n=this.previewPane.scrollTop;if(this._mode=e,this.bodyEl.className=`me-body me-mode-${e}`,this._updateModeButtons(),"edit"!==e&&(this._render(),this._buildOutline()),this.textarea.scrollTop=t,this.previewPane.scrollTop=n,this._emit("modeChange",e),this._announce(`${this.t(e)||e} mode`),"function"==typeof this.config.onModeChange)try{this.config.onModeChange(e,this)}catch(e){}return this}getMode(){return this._mode}_updateModeButtons(){const e="preview"===this._mode,t=this.config.readOnly;this.toolbarEl.querySelectorAll(".me-btn").forEach(n=>{const r=n,i=r.dataset.mode,o=r.dataset.action;if(i)return r.classList.toggle("me-active",i===this._mode),void(r.disabled=!1);r.disabled="fullscreen"!==o&&(t||!!e)&&!("undo"===o||"redo"===o)})}toggleFullscreen(){this._fullscreen=!this._fullscreen,this.el.classList.toggle("me-fullscreen",this._fullscreen);const e=this.toolbarEl.querySelector(".me-btn-fullscreen");if(e&&(e.title=this._fullscreen?this.t("fullscreenExit")||"退出全屏":this.t("fullscreen")||"全屏"),this._emit("fullscreen",this._fullscreen),"function"==typeof this.config.onFullscreen)try{this.config.onFullscreen(this._fullscreen,this)}catch(e){}return this}isFullscreen(){return this._fullscreen}exitFullscreen(){return this._fullscreen&&this.toggleFullscreen(),this}toggleZen(){return this._setZen(!this._zenMode),this}_setZen(e){this._zenMode=!!e,this.el&&(this.el.classList.toggle("me-zen",this._zenMode),this._applyZenWidth(),this._zenMode&&this.toolbarEl?(this._zenMouseHandler||(this._zenMouseHandler=e=>{this.toolbarEl.style.opacity=e.clientY<40?"1":"0",this.toolbarEl.style.pointerEvents=e.clientY<40?"auto":"none"},document.addEventListener("mousemove",this._zenMouseHandler)),this.toolbarEl.style.transition="opacity 0.2s",this.toolbarEl.style.opacity="0",this.toolbarEl.style.pointerEvents="none",this.statusEl&&(this.statusEl.style.display="none")):(this._zenMouseHandler&&(document.removeEventListener("mousemove",this._zenMouseHandler),this._zenMouseHandler=null),this.toolbarEl&&(this.toolbarEl.style.opacity="",this.toolbarEl.style.pointerEvents="",this.toolbarEl.style.transition=""),this.statusEl&&(this.statusEl.style.display="")),this._emit("zenChange",this._zenMode))}isZen(){return this._zenMode}_applyZenWidth(){if(!this.el)return;const e=this.config.zenMaxWidth;null==e||!1===e||""===e?this.el.style.removeProperty("--md-zen-max-width"):this.el.style.setProperty("--md-zen-max-width","number"==typeof e?`${e}px`:String(e))}setZenMaxWidth(e){return this.config.zenMaxWidth=e,this._applyZenWidth(),this}getZenMaxWidth(){return this.config.zenMaxWidth??960}toggleWordWrap(){return this._wordWrap=!this._wordWrap,this.textarea&&(this.textarea.style.whiteSpace=this._wordWrap?"pre-wrap":"pre"),this}setWordWrap(e){return this._wordWrap=!!e,this.textarea&&(this.textarea.style.whiteSpace=this._wordWrap?"pre-wrap":"pre"),this}isWordWrap(){return this._wordWrap}setOutline(e){if(this.config.outline=!!e,this._destroyed||!this.el)return this;if(this.config.outline)this._buildOutline(),this._trackOutlineScroll();else{const e=this.el.querySelector(".me-outline");e&&e.remove()}return this}isOutline(){return!!this.config.outline}_bindToolbarKeyboard(){if(!this.toolbarEl)return;const e=e=>{const t=[...this.toolbarEl.querySelectorAll(".me-btn:not(:disabled)")];if(!t.length)return;const n=t.indexOf(document.activeElement);-1!==n&&("ArrowRight"===e.key?(e.preventDefault(),t[(n+1)%t.length].focus()):"ArrowLeft"===e.key?(e.preventDefault(),t[(n-1+t.length)%t.length].focus()):"Home"===e.key?(e.preventDefault(),t[0].focus()):"End"===e.key&&(e.preventDefault(),t[t.length-1].focus()))};this.toolbarEl.addEventListener("keydown",e),this._cleanups.push(()=>this.toolbarEl.removeEventListener("keydown",e))}_initAriaLive(){if(!this.el)return;const e=document.createElement("div");e.className="me-sr-only",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.el.appendChild(e),this._ariaLive=e}_announce(e){this._ariaLive&&(this._ariaLive.textContent="",requestAnimationFrame(()=>{this._ariaLive.textContent=e}))}_syncScroll(){if(this._syncing)return;this._syncing=!0;const e=this.textarea;if(!e)return void(this._syncing=!1);const t=e.scrollHeight-e.clientHeight;if(t<=0)return void(this._syncing=!1);const n=e.scrollTop/t;if(this.gutter){const t=this.gutter.scrollHeight-this.gutter.clientHeight;this.gutter.scrollTop=t>0?n*t:e.scrollTop}if(this.config.syncScroll&&"split"===this._mode&&this.previewPane){const e=this.previewPane.scrollHeight-this.previewPane.clientHeight;e>0&&(this.previewPane.scrollTop=n*e)}requestAnimationFrame(()=>{this._syncing=!1})}_updateWordCount(){if(!this.config.wordCount||!this.statusEl)return;const e=this.getStats();this.statusEl.textContent=[`${this.t("characters")}: ${e.characters}`,`${this.t("words")}: ${e.words}`,`${this.t("lines")}: ${e.lines}`,`${this.t("readingTime")}: ${e.readingTime} ${this.t("minutes")}`].join(" · ")}getStats(){const e=this._value||"";if(this._statsCache&&this._statsCache.value===e)return this._statsCache.stats;const t=this._computeStats(e);return this._statsCache={value:e,stats:t},t}_computeStats(e){const t=this._statsCache;if(!t){const t=(e.match(/[\u4e00-\u9fa5]/g)||[]).length,n=(e.replace(/[\u4e00-\u9fa5]/g," ").match(/[a-zA-Z0-9]+/g)||[]).length,r=t+n,i=e?e.split("\n").length:0;return{characters:e.length,words:r,chineseChars:t,englishWords:n,lines:i,readingTime:Math.max(1,Math.ceil(r/300))}}const n=t.value,r=t.stats,i=e=>!!e&&/[\w\u4e00-\u9fff]/.test(e);let o=0;const s=Math.min(n.length,e.length);for(;o<s&&n[o]===e[o];)o++;let a=0;const l=s-o;for(;a<l&&n[n.length-1-a]===e[e.length-1-a];)a++;if(o===n.length&&o===e.length)return r;let c=o;for(;c>0&&(i(n[c-1])||i(e[c-1]));)c--;let h=n.length-a,d=e.length-a;for(;h<n.length&&i(n[h]);)h++;for(;d<e.length&&i(e[d]);)d++;const u=n.slice(c,h),p=e.slice(c,d),m=(p.match(/[\u4e00-\u9fa5]/g)||[]).length-(u.match(/[\u4e00-\u9fa5]/g)||[]).length,g=(p.replace(/[\u4e00-\u9fa5]/g," ").match(/[a-zA-Z0-9]+/g)||[]).length-(u.replace(/[\u4e00-\u9fa5]/g," ").match(/[a-zA-Z0-9]+/g)||[]).length,f=(p.match(/\n/g)||[]).length-(u.match(/\n/g)||[]).length,v=r.chineseChars+m,b=Math.max(0,r.englishWords+g),y=n?1:0,x=(e?1:0)+(r.lines-y)+f,w=v+b;return{characters:e.length,words:w,chineseChars:v,englishWords:b,lines:x,readingTime:Math.max(1,Math.ceil(w/300))}}getSelectedText(){return this.textarea?this._value.slice(this.textarea.selectionStart,this.textarea.selectionEnd):""}getCursorPosition(){if(!this.textarea)return{line:1,column:0};const e=this.textarea.selectionStart,t=this._value.substring(0,e),n=t.split("\n").length,r=e-t.lastIndexOf("\n")-1;return{line:n,column:r<0?0:r}}setCursorPosition(e,t=0){if(!this.textarea)return this;const n=this._value.split("\n"),r=Math.max(1,Math.min(e,n.length));let i=0;for(let e=0;e<r-1;e++)i+=n[e].length+1;return i+=Math.min(t,n[r-1]?.length||0),this.textarea.focus(),this.textarea.setSelectionRange(i,i),this}scrollToLine(e){if(!this.textarea)return this;const t=this._value.split("\n"),n=Math.max(1,Math.min(e,t.length)),r=getComputedStyle(this.textarea),i=parseFloat(r.lineHeight)||22;return this.textarea.scrollTop=(n-1)*i,this.gutter&&(this.gutter.scrollTop=this.textarea.scrollTop),this}selectLine(e){if(!this.textarea)return this;const t=this._value.split("\n"),n=Math.max(1,Math.min(e,t.length));let r=0;for(let e=0;e<n-1;e++)r+=t[e].length+1;const i=r+t[n-1].length;return this.textarea.focus(),this.textarea.setSelectionRange(r,i),this}selectAll(){return this.textarea&&(this.textarea.focus(),this.textarea.select()),this}replaceAll(e,t,n=!0){if(!e)return 0;const r=n?"g":"gi",i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(i,r),s=this._value.match(o);if(!s)return 0;const a=this._value;return this._value=this._limitLength(this._value.replace(o,()=>t)),this.textarea.value=this._value,this._pushHistory(),this._afterProgrammaticEdit(a),s.length}replaceAllRegex(e,t){if(!e)return 0;const n=new RegExp(e,e.flags.includes("g")?e.flags:e.flags+"g"),r=this._value.match(n);if(!r)return 0;const i=this._value;return this._value=this._limitLength(this._value.replace(n,t)),this.textarea.value=this._value,this._pushHistory(),this._afterProgrammaticEdit(i),r.length}lineCount(){return this._value?this._value.split("\n").length:0}getLine(e){const t=this._value.split("\n"),n=e-1;return n<0||n>=t.length?"":t[n]}_limitLength(e){const t=this.config.maxLength;return t&&t>0?e.slice(0,t):e}getValue(){return this._destroyed?"":this._value}setValue(e,t={}){if(this._destroyed)return this;if(e=this._limitLength(e||""),yt.trigger("beforeChange",this),this._emit("beforeChange",this._value,e),this._value=e||"",this.textarea.value=this._value,t.silent||this._pushHistory(),this._render(),this._renderGutter(),this._updateWordCount(),this._updateOutline(),this.gutter&&(this.gutter.scrollTop=0),this.textarea.scrollTop=0,!t.silent&&(this._emit("change",this._value),"function"==typeof this.config.onChange))try{this.config.onChange(this._value,this)}catch(e){}return this._emit("afterChange",this._value),yt.trigger("afterChange",this),this}getHTML(){yt.trigger("beforeRender",this),this._emit("beforeRender",this);let e=this._renderFn(this._value,{highlight:this._highlightFn||void 0,locale:this.getLocale()});if("function"==typeof this.config.sanitize)try{e=this.config.sanitize(e)}catch(e){}return yt.trigger("afterRender",this),this._emit("afterRender",this),e}refresh(){return this._lastRenderedValue=null,this._render(),this}copyAsMarkdown(){return"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(this._value).then(()=>this._emit("copy",{type:"markdown"})).catch(()=>{}),this}copyAsHTML(){const e=this.getHTML();if("undefined"!=typeof navigator&&navigator.clipboard){if("undefined"!=typeof ClipboardItem)try{const t=new Blob([e],{type:"text/html"}),n=new ClipboardItem({"text/html":t,"text/plain":new Blob([this._value],{type:"text/plain"})});return navigator.clipboard.write([n]).then(()=>this._emit("copy",{type:"html"})).catch(()=>{}),this}catch(e){}navigator.clipboard.writeText(this._value).then(()=>this._emit("copy",{type:"html"})).catch(()=>{})}return this}insert(e,t={}){const n=this.textarea,r=n.selectionStart,i=n.selectionEnd,o=this._limitLength(n.value.slice(0,r)+e+n.value.slice(t.replace?i:r));n.value=o,n.focus(),n.selectionStart=n.selectionEnd=Math.min(r+e.length,o.length);const s=this._value;return this._value=n.value,this._pushHistory(),this._afterProgrammaticEdit(s),this}wrap(e,t){return this._wrapSelection(e,t||e),this}focus(){return this.textarea&&this.textarea.focus(),this}blur(){return this.textarea&&this.textarea.blur(),this}enable(){return this.textarea&&(this.textarea.disabled=!1),this.el&&this.el.classList.remove("me-disabled"),this}disable(){return this.textarea&&(this.textarea.disabled=!0),this.el&&this.el.classList.add("me-disabled"),this}isDisabled(){return!!this.textarea&&this.textarea.disabled}setReadOnly(e){return this.config.readOnly=!!e,this.textarea&&(this.textarea.readOnly=!!e),this.el&&this.el.classList.toggle("me-readonly",!!e),this._updateModeButtons(),this}isReadOnly(){return!!this.config.readOnly}on(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),()=>this.off(e,t)}off(e,t){const n=this._listeners[e];return n&&(this._listeners[e]=n.filter(e=>e!==t)),this}_emit(e,...t){const n=this._listeners[e];n&&n.forEach(e=>{try{e(...t,this)}catch(e){}})}use(e,t={}){let n=e;if("string"==typeof e&&(n=ze[e],!n))return this;if(!n||"object"!=typeof n)return this;const r={...n,...t};if(this._plugins.some(e=>e.name===r.name))return this;if("function"==typeof r.install)try{const e=r.install(this,t);e&&"function"==typeof e.then&&e.catch(e=>{})}catch(e){}return this._plugins.push(r),this}unuse(e){const t=this._plugins.findIndex(t=>t.name===e);if(-1===t)return this;const n=this._plugins[t];if("function"==typeof n.destroy)try{n.destroy(this)}catch(e){}return this._plugins.splice(t,1),this}getPlugins(){return[...this._plugins]}addToolbarButton(e){if(!e||!e.action)return this;const n=document.createElement("button");return n.type="button",n.className=`me-btn me-btn-custom-${e.action}`,n.title=e.title||e.action,n.setAttribute("aria-label",e.title||e.action),n.innerHTML=e.icon||`<span>${t(e.text||e.action)}</span>`,"function"==typeof e.onClick?n.addEventListener("click",t=>{t.stopPropagation(),e.onClick(this)}):e.action&&(n.dataset.action=e.action,this._customActions=this._customActions||{},this._customActions[e.action]=e.handler),this.toolbarEl.insertBefore(n,this.toolbarEl.querySelector(".me-toolbar-group")||null),this}registerShortcut(e,t,n=""){if(!e)return this;const r=e.toLowerCase().split("+"),i=r.pop(),o=r.includes("ctrl")||r.includes("cmd"),s=r.includes("shift"),a=r.includes("alt"),l=r.includes("meta");return this._shortcuts.push({combo:e,key:i,ctrl:o,shift:s,alt:a,meta:l,handler:t,description:n}),this}unregisterShortcut(e){return this._shortcuts=this._shortcuts.filter(t=>t.combo.toLowerCase()!==e.toLowerCase()),this}getShortcuts(){return[...this._shortcuts]}configureToolbar(e){return this.toolbarEl?(this.config.toolbar=e,this.toolbarEl.innerHTML="",this._buildToolbar(),this):this}removeToolbarButton(e){if(!this.toolbarEl)return this;const t=this.toolbarEl.querySelector(`.me-btn[data-action="${e}"], .me-btn[data-mode="${e}"]`);return t&&t.remove(),this}toast(e,n={}){if(!this.el||"undefined"==typeof document)return this;const{type:r="info",duration:i=3e3,animation:o="fade"}=n,s=l[o]||l.fade,a=document.createElement("div");a.className=`me-toast me-toast-${r} me-toast-${o}`,a.innerHTML=`<span class="me-toast-icon">${vt[r]||""}</span><span class="me-toast-msg">${t(String(e))}</span>`,a.style.transition=`opacity ${s.duration}ms ${s.easing}, transform ${s.duration}ms ${s.easing}, filter ${s.duration}ms ${s.easing}`;for(const[e,t]of Object.entries(s.enter))a.style[e]=t;this.el.appendChild(a),requestAnimationFrame(()=>{requestAnimationFrame(()=>{for(const e of Object.keys(s.enter))a.style[e]=""})});const c=()=>{for(const[e,t]of Object.entries(s.leave))a.style[e]=t;setTimeout(()=>{a.parentNode&&a.parentNode.removeChild(a)},s.duration)};return i>0&&setTimeout(c,i),a.addEventListener("click",c),this}setLocale(e){return this._i18nCtx&&this._i18nCtx.set(e),this}getLocale(){return this._i18nCtx?this._i18nCtx.get():v()}t(e,t){return this._i18nCtx?this._i18nCtx.t(e,t):y(e,t)}setTheme(e){return e?(this.config.theme=e,this._themeCtx&&this._themeCtx.set(e),this):this}getTheme(){return this._themeCtx?this._themeCtx.get():this.config.theme||"auto"}getThemeContext(){return this._themeCtx||null}getStatus(){return{id:this.id,mode:this._mode,theme:this.getTheme(),locale:this.getLocale(),fullscreen:this._fullscreen,readOnly:this.config.readOnly||!1,disabled:!!this.textarea&&this.textarea.disabled,destroyed:this._destroyed,plugins:this._plugins.map(e=>e.name||"custom")}}destroy(){if(!this._destroyed){if(yt.trigger("beforeDestroy",this),this._renderRaf&&cancelAnimationFrame(this._renderRaf),this._historyTimer&&clearTimeout(this._historyTimer),this._outlineTimer&&clearTimeout(this._outlineTimer),this._cleanups.forEach(e=>{try{e()}catch(e){}}),this._cleanups=[],this._zenMouseHandler&&(document.removeEventListener("mousemove",this._zenMouseHandler),this._zenMouseHandler=null),this._themeCtx&&"function"==typeof this._themeCtx.dispose)try{this._themeCtx.dispose()}catch(e){}if(this._shortcuts=[],this._contextMenuItems=[],this._customActions={},this._floatingToolbar&&this._floatingToolbar.parentNode&&this._floatingToolbar.parentNode.removeChild(this._floatingToolbar),this._floatingToolbar=null,this._floatMirror&&this._floatMirror.parentNode&&this._floatMirror.parentNode.removeChild(this._floatMirror),this._floatMirror=null,this.el&&this.el.querySelectorAll(".me-toast").forEach(e=>e.remove()),this._plugins.forEach(e=>{if("function"==typeof e.destroy)try{e.destroy(this)}catch(e){}}),this._plugins=[],this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=null,this.textarea=null,this.previewEl=null,this._destroyed=!0,"function"==typeof this.config.onDestroy)try{this.config.onDestroy(this)}catch(e){}this._emit("destroy"),this._listeners={},yt.trigger("afterDestroy",this)}}isDestroyed(){return this._destroyed}}var xt;yt._hooks=new Map,(xt=yt.prototype)._wrapSelection=function(e,t){const n=this.textarea,r=n.selectionStart,i=n.selectionEnd,o=n.value.slice(r,i),s=o||"text",a=e+s+t;n.value=n.value.slice(0,r)+a+n.value.slice(i),n.focus(),o?(n.selectionStart=r+e.length,n.selectionEnd=r+e.length+s.length):n.selectionStart=n.selectionEnd=r+e.length;const l=this._value;this._value=n.value,this._pushHistory(),this._afterProgrammaticEdit(l)},xt._toggleLinePrefix=function(e){const t=this.textarea,n=t.selectionStart,r=t.value.lastIndexOf("\n",n-1)+1,i=t.value.indexOf("\n",n),o=-1===i?t.value.length:i,s=t.value.slice(r,o),a=s.match(/^(#{1,6}\s*|>\s*|[-*+]\s*|\d+\.\s*)/);let l;l=a&&a[0]===e?s.slice(e.length):a?e+s.slice(a[0].length):e+s,t.value=t.value.slice(0,r)+l+t.value.slice(o),t.focus(),t.selectionStart=t.selectionEnd=r+l.length;const c=this._value;this._value=t.value,this._pushHistory(),this._afterProgrammaticEdit(c)},xt._insertBlock=tt,xt._insertLink=function(){const e=this.textarea,t=e.selectionStart,n=e.selectionEnd,r=e.value.slice(t,n)||this.t("link")||"link",i=`[${r}](https://)`;e.value=e.value.slice(0,t)+i+e.value.slice(n),e.focus(),e.selectionStart=t+r.length+3,e.selectionEnd=e.selectionStart+8;const o=this._value;this._value=e.value,this._pushHistory(),this._afterProgrammaticEdit(o)},xt._insertImage=function(){const e=this.textarea,t=e.selectionStart,n=e.selectionEnd,r=e.value.slice(t,n)||this.t("image")||"image",i=``;e.value=e.value.slice(0,t)+i+e.value.slice(n),e.focus(),e.selectionStart=t+r.length+4,e.selectionEnd=e.selectionStart+8;const o=this._value;this._value=e.value,this._pushHistory(),this._afterProgrammaticEdit(o)},xt._insertTable=function(e=3,t=3){let n=`| ${Array.from({length:t},(e,t)=>`${this.t("tableCols")||"列"}${t+1}`).join(" | ")} |\n| ${Array.from({length:t},()=>"---").join(" | ")} |\n`;for(let r=1;r<e;r++)n+=`| ${Array.from({length:t},()=>" ").join(" | ")} |\n`;tt.call(this,"\n"+n)},xt._formatTable=function(){const e=this.textarea,t=e.selectionStart,n=e.value.substring(0,t),r=e.value.substring(t),i=n.lastIndexOf("\n\n"),o=r.indexOf("\n\n"),s=-1===i?0:i+2,a=-1===o?e.value.length:t+o,l=e.value.substring(s,a).split("\n").filter(e=>e.includes("|"));if(l.length<2)return;const c=l.map(e=>e.replace(/^\s*\|?\s*|\s*\|?\s*$/g,"").split(/\s*\|\s*/)),h=Math.max(...c.map(e=>e.length)),d=Array(h).fill(3);c.forEach(e=>{e.forEach((e,t)=>{d[t]=Math.max(d[t],e.trim().length)})});const u=(e,t)=>{const n=t-e.length;return e+" ".repeat(Math.max(0,n))},p=c.map(e=>{const t=[];for(let n=0;n<h;n++)t.push(u((e[n]||"").trim(),d[n]));return"| "+t.join(" | ")+" |"});e.value=e.value.substring(0,s)+p.join("\n")+e.value.substring(a);const m=this._value;this._value=e.value,this._pushHistory(),this._afterProgrammaticEdit(m)},(e=>{e._initFloatingToolbar=nt,e.toggleFloatingToolbar=it,e.isFloatingToolbar=ot,e._buildFloatingToolbar=st,e._hideFloatingToolbar=at,e._measureSelectionAnchor=rt})(yt.prototype),(e=>{e.registerContextMenu=lt,e._bindContextMenu=ct,e._showContextMenu=ht,e._hideContextMenu=dt,e._execContextAction=ut})(yt.prototype),(e=>{e._buildOutline=pt,e._updateOutline=mt,e._trackOutlineScroll=gt})(yt.prototype);const wt=new Map;for(const[e,t]of Object.entries(l))wt.set(e,t);const _t={register(e,t){wt.set(e,{name:e,enter:t.enter||{},leave:t.leave||{},duration:t.duration||300,easing:t.easing||"cubic-bezier(0.4, 0, 0.2, 1)"})},unregister(e){wt.delete(e)},get:e=>wt.get(e)||l[e]||null,getAnimationNames:()=>Array.from(wt.keys()),getActiveCount:()=>0,cancelAll(){},reset(){wt.clear();for(const[e,t]of Object.entries(l))wt.set(e,t)},destroy(){wt.clear()}},kt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ct=new Map,Et={javascript:{keywords:["async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","from","function","get","if","import","in","instanceof","let","new","of","return","set","static","super","switch","this","throw","try","typeof","var","void","while","with","yield"],builtins:["console","document","window","globalThis","Math","JSON","Promise","Object","Array","String","Number","Boolean","Map","Set","Symbol","RegExp","Date","Error","parseInt","parseFloat","isNaN","setTimeout","setInterval","fetch","require","module","exports","process","Buffer"],hasBlocks:!0,hasTemplateStrings:!0},typescript:{keywords:["abstract","any","as","async","await","boolean","break","case","catch","class","const","continue","debugger","declare","default","delete","do","else","enum","export","extends","finally","for","from","function","get","if","implements","import","in","infer","instanceof","interface","is","keyof","let","namespace","never","new","of","override","private","protected","public","readonly","return","satisfies","set","static","string","super","switch","symbol","this","throw","try","type","typeof","undefined","unique","unknown","var","void","while","with","yield"],builtins:["console","document","window","globalThis","Math","JSON","Promise","Object","Array","String","Number","Boolean","Map","Set","Symbol","RegExp","Date","Error","parseInt","parseFloat","setTimeout","setInterval","fetch","require","module","exports","process","Buffer"],hasBlocks:!0,hasTemplateStrings:!0},jsx:{keywords:["async","await","break","case","catch","class","const","continue","default","do","else","export","extends","finally","for","from","function","if","import","in","instanceof","let","new","of","return","static","super","switch","this","throw","try","typeof","var","void","while","with","yield","useState","useEffect","useRef","useMemo","useCallback"],builtins:["console","document","window","Math","JSON","Promise","Object","Array","String","Number","Map","Set","React"],hasBlocks:!0,hasTemplateStrings:!0},tsx:{keywords:["abstract","any","as","async","await","boolean","break","case","catch","class","const","continue","default","declare","do","else","enum","export","extends","finally","for","from","function","if","implements","import","in","infer","instanceof","interface","is","keyof","let","namespace","never","new","of","override","private","protected","public","readonly","return","static","string","super","switch","symbol","this","throw","try","type","typeof","undefined","unknown","var","void","while","with","yield","useState","useEffect","useRef"],builtins:["console","document","window","Math","JSON","Promise","Object","Array","String","Number","Map","Set","React"],hasBlocks:!0,hasTemplateStrings:!0},python:{keywords:["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","False","finally","for","from","global","if","import","in","is","lambda","None","nonlocal","not","or","pass","raise","return","True","try","while","with","yield"],builtins:["print","len","range","type","str","int","float","list","dict","set","tuple","bool","enumerate","zip","map","filter","sum","min","max","abs","round","open","input","repr","sorted","object","super","self"],hasHashComments:!0},bash:{keywords:["if","then","else","elif","fi","for","while","until","do","done","case","esac","function","in","return","break","continue","export","local","readonly","set","unset","shift","source","alias","declare","echo","exit"],builtins:["echo","printf","cd","pwd","ls","mkdir","rm","cp","mv","cat","grep","sed","awk","curl","wget","npm","node","git","docker","sudo","find","xargs","tar","zip","unzip","chmod","chown","touch","head","tail","wc","sort","uniq","cut","tee","ps","kill","top","clear","history","man","which"],hasHashComments:!0,singleQuoteStrings:!1},shell:{hasHashComments:!0,keywords:["if","then","else","elif","fi","for","while","do","done","case","in","function","return","break","continue","export","local","echo","exit"],builtins:["echo","cd","pwd","ls","rm","cp","mv","cat","grep","sed","awk","curl","wget","git","sudo","find","chmod","chown","touch","head","tail","wc","sort","tee","ps","kill","clear","man","which"],singleQuoteStrings:!1},css:{keywords:["important","inherit","initial","unset","none","auto","absolute","relative","fixed","static","sticky","flex","grid","block","inline","inline-block","hidden","visible","bold","normal","italic","solid","dashed","dotted","transparent","center","left","right","top","bottom","wrap","nowrap","repeat","cover","contain","pointer","auto"],builtins:["var","calc","min","max","clamp","rgb","rgba","hsl","hsla","url","linear-gradient","radial-gradient","translate","scale","rotate","repeat","minmax","fit-content","attr","counter"],hasBlocks:!0,singleQuoteStrings:!1},html:{keywords:["html","head","body","div","span","p","a","img","ul","ol","li","table","thead","tbody","tr","th","td","h1","h2","h3","h4","h5","h6","section","article","nav","header","footer","main","aside","form","input","button","select","option","textarea","label","script","style","link","meta","title","iframe","video","audio","canvas","svg","strong","em","code","pre","blockquote","br","hr","template"],builtins:[],singleQuoteStrings:!1},json:{keywords:["true","false","null"],builtins:[],singleQuoteStrings:!1},yaml:{keywords:["true","false","null","yes","no","on","off"],builtins:[],hasHashComments:!0,singleQuoteStrings:!1},markdown:{keywords:[],builtins:[],hasHashComments:!0,singleQuoteStrings:!1},md:{keywords:[],builtins:[],hasHashComments:!0,singleQuoteStrings:!1},java:{keywords:["abstract","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while","var"],builtins:["System","String","Integer","Double","Math","Object","Class","Exception","Thread","Arrays","List","ArrayList","Map","HashMap","Set","HashSet","Optional","Stream","Collectors","Objects"],hasBlocks:!0},go:{keywords:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],builtins:["fmt","len","cap","make","new","append","copy","panic","recover","error","string","int","int64","uint","bool","byte","rune","float64","nil","print","println","Close","Error"],hasBlocks:!0,singleQuoteStrings:!1},rust:{keywords:["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","unsafe","use","where","while"],builtins:["println","print","eprintln","format","vec","String","str","Option","Result","Some","None","Ok","Err","Vec","Box","Rc","Arc","HashMap","Iterator","match"],hasBlocks:!0,singleQuoteStrings:!1}},St={js:"javascript",ts:"typescript",tsx:"tsx",jsx:"jsx",py:"python",sh:"bash",shell:"shell",zsh:"bash",yml:"yaml",mjs:"javascript",cjs:"javascript",md:"markdown",htm:"html",c:"go",cpp:"go",cs:"java"},Lt=e=>{const t=(e||"").trim().toLowerCase();return t?St[t]||(Et[t]?t:""):""},Tt=(e,t)=>{const n=Lt(t),r=Et[n],i=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return r?((e,t)=>{let n="",r=0;const i=e.length;for(;r<i;){let i=!1;for(const o of t){o.re.lastIndex=r;const t=o.re.exec(e);if(t&&t.index===r&&t[0].length>0){n+=`<span class="${o.cls}">${t[0]}</span>`,r+=t[0].length,i=!0;break}}i||(n+=e[r],r++)}return n})(i,(e=>{let t=Ct.get(e);if(!t){const n=Et[e];t=n?(e=>{const t=[];e.hasHashComments?t.push({cls:"me-hl-comment",re:/#[^\n]*/y}):t.push({cls:"me-hl-comment",re:/\/\/[^\n]*/y}),e.hasBlocks&&t.push({cls:"me-hl-comment",re:/\/\*[\s\S]*?\*\//y});const n=!1===e.singleQuoteStrings?/"(?:\\.|[^"\\\n])*"/y:/"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'/y;return t.push({cls:"me-hl-string",re:n}),e.hasTemplateStrings&&t.push({cls:"me-hl-string",re:/`(?:\\.|[^`\\])*`/y}),t.push({cls:"me-hl-number",re:/\b0x[\da-fA-F_]+\b|\b\d[\d_]*(?:\.\d+)?(?:e[+-]?\d+)?\b/y}),e.keywords.length&&t.push({cls:"me-hl-keyword",re:new RegExp(`\\b(?:${e.keywords.map(kt).join("|")})\\b`,"y")}),e.builtins.length&&t.push({cls:"me-hl-builtin",re:new RegExp(`\\b(?:${e.builtins.map(kt).join("|")})\\b`,"y")}),t.push({cls:"me-hl-function",re:/[A-Za-z_$][\w$]*(?=\s*\()/y}),t})(n):[],Ct.set(e,t)}return t})(n)):i},Mt=(e,t)=>{Et[e.toLowerCase()]=t,Ct.delete(e.toLowerCase())},$t=()=>Object.keys(Et),zt="0.4.3",At=[],Bt=e=>{e&&!e.isDestroyed()&&At.forEach(t=>{try{e.use(t)}catch(e){}})};function Pt(e,t={}){return new yt(e,t)}function Ht(e,t={}){let n=e;if("string"==typeof e&&(n=ze[e],!n))return Dt;if(!n||"object"!=typeof n)return Dt;const r=t&&"object"==typeof t&&Object.keys(t).length>0?{...n,...t}:n;return At.push(r),Dt}function It(e,t){return yt.on(e,t)}function Rt(e,t){return yt.off(e,t),Dt}function jt(e,t){return et&&"function"==typeof et.switchTheme&&et.switchTheme(e),Dt}function Ft(e){return A&&"function"==typeof A.setCurrentLocale&&A.setCurrentLocale(e),Dt}function Ot(){if(et){try{et.clearThemeListeners()}catch(e){}try{et.unwatchSystemTheme()}catch(e){}}if(A)try{A.clearLocaleListeners()}catch(e){}if(_t)try{_t.cancelAll()}catch(e){}At.length=0;try{yt._hooks.clear()}catch(e){}yt.on("afterCreate",Bt)}function Wt(){return{version:zt,theme:et&&"function"==typeof et.getCurrentTheme?et.getCurrentTheme():"auto",locale:A&&"function"==typeof A.getCurrentLocale?A.getCurrentLocale():"zh-CN",globalPlugins:At.map(e=>e.name||"custom"),presetPlugins:Object.keys(ze||{})}}yt.on("afterCreate",Bt);try{"function"==typeof et.initTheme&&et.initTheme(),"function"==typeof A.initI18n&&A.initI18n()}catch(e){}const Dt={VERSION:zt,version:zt,MarkdownEditor:yt,Editor:yt,create:Pt,use:Ht,on:It,off:Rt,setTheme:jt,setLocale:Ft,destroy:Ot,getStatus:Wt,parseMarkdown:se,parseTokens:ie,renderTokens:oe,safeUrl:Q,slugify:X,clearRenderCache:G,registerBlockHandler:ne,highlight:Tt,normalizeLanguage:Lt,registerLanguage:Mt,getSupportedLanguages:$t,themes:et,i18n:A,animations:_t,plugins:Ae,presetPlugins:ze,topologicalSort:Te,validateConfig:Me,createInstanceI18n:z,loadRemote:k,exportCSSVars:We,getCSSVariable:De,followExternalTheme:Ye,adoptFromParent:Ge,createInstanceTheme:Xe,DEFAULTS:s,ICONS:r,THEMES:a,EDIT_MODES:c,DEFAULT_TOOLBAR:o,TOOLBAR_ACTIONS:h};"undefined"!=typeof window&&(window.MeEditor=Dt),e.DEFAULTS=s,e.DEFAULT_TOOLBAR=o,e.EDIT_MODES=c,e.Editor=yt,e.ICONS=r,e.MarkdownEditor=yt,e.MeEditor=Dt,e.THEMES=a,e.TOOLBAR_ACTIONS=h,e.VERSION=zt,e.adoptFromParent=Ge,e.animationUtils=_t,e.api=Dt,e.clearRenderCache=G,e.create=Pt,e.createInstanceI18n=z,e.createInstanceTheme=Xe,e.default=Dt,e.destroy=Ot,e.exportCSSVars=We,e.followExternalTheme=Ye,e.getCSSVariable=De,e.getStatus=Wt,e.getSupportedLanguages=$t,e.highlight=Tt,e.i18nUtils=A,e.loadRemote=k,e.meEditor=Dt,e.normalizeLanguage=Lt,e.off=Rt,e.on=It,e.parseMarkdown=se,e.parseTokens=ie,e.pluginUtils=Ae,e.presetPlugins=ze,e.registerBlockHandler=ne,e.registerLanguage=Mt,e.renderTokens=oe,e.safeUrl=Q,e.setLocale=Ft,e.setTheme=jt,e.slugify=X,e.themeUtils=et,e.topologicalSort=Te,e.use=Ht,e.validateConfig=Me,Object.defineProperty(e,"__esModule",{value:!0})});
|