autumnnote 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/autumnnote.cjs +9 -9
- package/dist/autumnnote.core.es.js +47 -42
- package/dist/autumnnote.core.es.js.map +1 -1
- package/dist/autumnnote.es.js +93 -81
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +9 -9
- package/dist/autumnnote.umd.js +9 -9
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/js/core/func.js +10 -4
- package/types/index.d.ts +42 -0
package/dist/autumnnote.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.AutumnNote=t())})(this,function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function r(e,t){let n={};for(let t of Object.keys(e))n[t]=Array.isArray(e[t])?[...e[t]]:e[t];if(i(e)&&i(t))for(let a of Object.keys(t))i(t[a])?n[a]=r(i(e[a])?e[a]:{},t[a]):Array.isArray(t[a])?n[a]=[...t[a]]:n[a]=t[a];return n}function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var a={toolbar:{bold:`Bold (Ctrl+B)`,italic:`Italic (Ctrl+I)`,underline:`Underline (Ctrl+U)`,strikethrough:`Strikethrough`,superscript:`Superscript`,subscript:`Subscript`,alignLeft:`Align Left`,alignCenter:`Align Center`,alignRight:`Align Right`,alignJustify:`Justify`,ul:`Unordered List`,ol:`Ordered List`,checklist:`Checklist`,indent:`Indent`,outdent:`Outdent`,undo:`Undo (Ctrl+Z)`,redo:`Redo (Ctrl+Y)`,hr:`Horizontal Rule`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,emoji:`Insert Emoji`,icon:`Insert FA Icon`,table:`Insert Table`,fontSize:`Font Size`,fontSizePlaceholder:`Size`,removeFormat:`Remove Format`,direction:`Toggle Text Direction (LTR / RTL)`,fontFamily:`Font Family`,paragraphStyle:`Paragraph Style`,paragraphStylePlaceholder:`Style`,lineHeight:`Line Height`,lineHeightPlaceholder:`↕ Line`,codeview:`HTML Code View`,fullscreen:`Fullscreen`,shortcuts:`Keyboard Shortcuts (Ctrl+Shift+/)`,find:`Find (Ctrl+F)`,findReplace:`Find & Replace (Ctrl+H)`,inlineCode:"Inline Code (Ctrl+`)",print:`Print`,foreColor:`Text Color`,backColor:`Highlight Color`,chooseTextColor:`Choose text color`,chooseHighlightColor:`Choose highlight color`,customColor:`Custom color`,insertTableLabel:`Insert Table`,paragraphItems:{p:`Normal`,blockquote:`Quote`,pre:`Code`}},linkDialog:{ariaLabel:`Insert link`,title:`Insert Link`,url:`URL`,urlPlaceholder:`https://`,displayText:`Display Text`,textPlaceholder:`Link text`,openInNewTab:`Open in new tab`,insertBtn:`Insert`,cancelBtn:`Cancel`},imageDialog:{ariaLabel:`Insert image`,title:`Insert Image`,imageUrl:`Image URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt Text`,altPlaceholder:`Describe the image`,alignment:`Alignment`,alignNone:`None`,alignLeft:`Left`,alignCenter:`Center`,alignRight:`Right`,uploadLabel:`Or upload a file`,insertBtn:`Insert`,cancelBtn:`Cancel`},videoDialog:{ariaLabel:`Insert video`,title:`Insert Video`,videoUrl:`Video URL`,urlPlaceholder:`YouTube, Vimeo, or direct .mp4 URL`,widthLabel:`Width (px)`,widthPlaceholder:`560`,insertBtn:`Insert`,cancelBtn:`Cancel`,detected:e=>`Detected: ${e}`,unknownFormat:`Unknown format — will try direct video embed`,invalidUrl:`Invalid URL — please enter a valid video link.`},emojiDialog:{ariaLabel:`Insert emoji`,title:`Insert Emoji`,searchPlaceholder:`Search emojis…`,all:`All`,cancelBtn:`Cancel`,close:`Close`,categories:{smileys:`Smileys`,people:`People`,animals:`Animals`,food:`Food`,travel:`Travel`,objects:`Objects`,symbols:`Symbols`}},iconDialog:{ariaLabel:`Insert FA icon`,title:`Insert FA Icon`,searchPlaceholder:`Search icons…`,all:`All`,style:`Style`,size:`Size`,color:`Color`,useColor:` Use color`,selectHint:`Select an icon`,insertBtn:`Insert FA Icon`,cancelBtn:`Cancel`,close:`Close`,categories:{popular:`Popular`,interface:`Interface`,navigation:`Navigation`,media:`Media`,communication:`Communication`,files:`Files`,people:`People`,objects:`Objects`}},findReplace:{findTitle:`Find`,findReplaceTitle:`Find & Replace`,findPlaceholder:`Find…`,searchAriaLabel:`Search text`,caseSensitive:`\xA0Case sensitive`,wholeWord:`Whole Word`,prevBtn:`← Prev`,nextBtn:`Next →`,replacePlaceholder:`Replace with…`,replaceAriaLabel:`Replace with`,replaceBtn:`Replace`,replaceAllBtn:`Replace All`,noResults:`No results`,useRegex:`Use Regular Expression`,close:`×`},autoSaveRestore:{found:`Draft found. Restore?`,foundAt:`Draft from {date}. Restore?`,restore:`Restore`,discard:`Discard`},shortcutsDialog:{title:`Keyboard Shortcuts`,ariaLabel:`Keyboard Shortcuts`,close:`Close`,shortcuts:[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}]},contextMenu:{cut:`Cut`,copy:`Copy`,paste:`Paste`,bold:`Bold`,italic:`Italic`,underline:`Underline`,textColor:`Text Color`,highlightColor:`Highlight Color`,copyFormat:`Copy Format`,pasteFormat:`Paste Format`,removeFormat:`Remove Format`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,table:`Insert Table`,back:`Back`,noHighlight:`No highlight`,customColor:`Custom color`,customColorLabel:`Custom…`},statusbar:{resizeHandle:`Resize editor`,words:e=>`Words: ${e}`,wordsLimit:(e,t)=>`Words: ${e}/${t}`,chars:e=>`Chars: ${e}`,charsLimit:(e,t)=>`Chars: ${e}/${t}`},tooltips:{link:{ariaLabel:`Link actions`,openLink:`Open link`,copyUrl:`Copy URL`,editLink:`Edit link`,removeLink:`Remove link`},image:{ariaLabel:`Image actions`,label:`Image`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,rotateLeft:`Rotate Left`,rotateRight:`Rotate Right`,cropImage:`Crop Image`,addCaption:`Add / Edit Caption`,deleteImage:`Delete Image`},code:{ariaLabel:`Code block actions`,label:`Code`,syntaxLanguage:`Syntax Language`,syntaxAriaLabel:`Syntax language`,copyCode:`Copy Code`,toggleWordWrap:`Toggle Word Wrap`,enableWordWrap:`Enable Word Wrap`,disableWordWrap:`Disable Word Wrap`,convertToParagraph:`Convert to Paragraph`,deleteCodeBlock:`Delete Code Block`,lineNumbers:`Toggle Line Numbers`},table:{ariaLabel:`Table actions`,label:`Table`,selectCells:`Select Cells`,addRowAbove:`Add Row Above`,addRowBelow:`Add Row Below`,deleteRow:`Delete Row`,addColumnLeft:`Add Column Left`,addColumnRight:`Add Column Right`,deleteColumn:`Delete Column`,mergeCells:`Merge Cells`,unmergeCells:`Unmerge Cells`,columnWidth:`Column Width`,rowHeight:`Row Height`,tableBorderWidth:`Table Border Width`,tableBorderColor:`Table Border Color`,deleteTable:`Delete Table`,cellAlignLeft:`Align Left`,cellAlignCenter:`Align Center`,cellAlignRight:`Align Right`,cellAlignJustify:`Align Justify`,toggleHeaderRow:`Toggle Header Row`,cellBackground:`Cell Background`,noShading:`No Shading`,noBorderColor:`No Border Color`,columnWidthPx:`Column Width (px)`,rowHeightPx:`Row Height (px)`,tableBorderWidthPx:`Table Border Width (px)`,cancelBtn:`Cancel`,applyBtn:`Apply`,sortAsc:`Sort Ascending`,sortDesc:`Sort Descending`,exportCSV:`Export as CSV`,cellPadding:`Cell Padding`,cellPaddingPx:`Cell Padding (px)`},video:{ariaLabel:`Video actions`,label:`Video`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,previewVideo:`Preview Video`,exitPreview:`Exit Preview`,deleteVideo:`Delete Video`}},errors:{imageFormat:e=>`Format "${e}" is not supported for display in web browsers. Please convert to JPEG, PNG, or WebP first.`,imageSize:e=>`Image file is too large. Maximum allowed size is ${e} MB.`},slashMenu:{noResults:`No matching commands`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet List`,numberedList:`Numbered List`,checklist:`Checklist`,blockquote:`Blockquote`,codeBlock:`Code Block`,horizontalRule:`Horizontal Rule`,table:`Table`,image:`Image`}},o={en:a};function s(e,t){if(typeof e!=`string`||!e)throw TypeError(`[AutumnNote] registerLocale: code must be a non-empty string.`);if(!t||typeof t!=`object`)throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);o[e]=t}function c(e){if(!e||e===`en`)return a;if(typeof e==`string`){let t=o[e];return t?r(r({},a),t):(console.warn(`[AutumnNote] Locale "${e}" is not registered, falling back to English. Import it first: import { ${e} } from 'autumnnote/i18n/${e}'; AutumnNote.registerLocale('${e}', ${e});`),a)}return typeof e==`object`?r(r({},a),e):a}s(`vi`,{toolbar:{bold:`Đậm (Ctrl+B)`,italic:`Nghiêng (Ctrl+I)`,underline:`Gạch chân (Ctrl+U)`,strikethrough:`Gạch ngang`,superscript:`Chỉ số trên`,subscript:`Chỉ số dưới`,alignLeft:`Căn trái`,alignCenter:`Căn giữa`,alignRight:`Căn phải`,alignJustify:`Căn đều`,ul:`Danh sách không thứ tự`,ol:`Danh sách có thứ tự`,checklist:`Danh sách kiểm tra`,indent:`Tăng thụt đầu dòng`,outdent:`Giảm thụt đầu dòng`,undo:`Hoàn tác (Ctrl+Z)`,redo:`Làm lại (Ctrl+Y)`,hr:`Đường kẻ ngang`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,emoji:`Chèn biểu tượng cảm xúc`,icon:`Chèn biểu tượng FA`,table:`Chèn bảng`,fontSize:`Cỡ chữ`,fontSizePlaceholder:`Cỡ`,removeFormat:`Xóa định dạng`,direction:`Chuyển hướng văn bản (LTR / RTL)`,fontFamily:`Phông chữ`,paragraphStyle:`Kiểu đoạn văn`,paragraphStylePlaceholder:`Kiểu`,lineHeight:`Khoảng cách dòng`,lineHeightPlaceholder:`↕ Dòng`,codeview:`Xem mã HTML`,fullscreen:`Toàn màn hình`,shortcuts:`Phím tắt (Ctrl+Shift+/)`,find:`Tìm kiếm (Ctrl+F)`,findReplace:`Tìm & Thay thế (Ctrl+H)`,inlineCode:"Mã nội tuyến (Ctrl+`)",print:`In`,foreColor:`Màu chữ`,backColor:`Màu nền chữ`,chooseTextColor:`Chọn màu chữ`,chooseHighlightColor:`Chọn màu nền`,customColor:`Màu tùy chỉnh`,insertTableLabel:`Chèn bảng`,paragraphItems:{p:`Bình thường`,blockquote:`Trích dẫn`,pre:`Mã`}},linkDialog:{ariaLabel:`Chèn liên kết`,title:`Chèn liên kết`,url:`Địa chỉ URL`,urlPlaceholder:`https://`,displayText:`Văn bản hiển thị`,textPlaceholder:`Nội dung liên kết`,openInNewTab:`Mở trong tab mới`,insertBtn:`Chèn`,cancelBtn:`Hủy`},imageDialog:{ariaLabel:`Chèn hình ảnh`,title:`Chèn hình ảnh`,imageUrl:`URL hình ảnh`,urlPlaceholder:`https://example.com/anh.png`,altText:`Văn bản thay thế`,altPlaceholder:`Mô tả hình ảnh`,alignment:`Căn chỉnh`,alignNone:`Không`,alignLeft:`Trái`,alignCenter:`Giữa`,alignRight:`Phải`,uploadLabel:`Hoặc tải lên tệp`,insertBtn:`Chèn`,cancelBtn:`Hủy`},videoDialog:{ariaLabel:`Chèn video`,title:`Chèn video`,videoUrl:`URL video`,urlPlaceholder:`YouTube, Vimeo, hoặc URL .mp4 trực tiếp`,widthLabel:`Chiều rộng (px)`,widthPlaceholder:`560`,insertBtn:`Chèn`,cancelBtn:`Hủy`,detected:e=>`Đã phát hiện: ${e}`,unknownFormat:`Định dạng không xác định — sẽ thử nhúng video trực tiếp`,invalidUrl:`URL không hợp lệ — vui lòng nhập đường dẫn video hợp lệ.`},emojiDialog:{ariaLabel:`Chèn biểu tượng cảm xúc`,title:`Chèn biểu tượng cảm xúc`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,cancelBtn:`Hủy`,close:`Đóng`,categories:{smileys:`Mặt cười`,people:`Con người`,animals:`Động vật`,food:`Thức ăn`,travel:`Du lịch`,objects:`Đồ vật`,symbols:`Ký hiệu`}},iconDialog:{ariaLabel:`Chèn biểu tượng FA`,title:`Chèn biểu tượng FA`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,style:`Kiểu`,size:`Kích thước`,color:`Màu sắc`,useColor:` Dùng màu`,selectHint:`Chọn một biểu tượng`,insertBtn:`Chèn biểu tượng FA`,cancelBtn:`Hủy`,close:`Đóng`,categories:{popular:`Phổ biến`,interface:`Giao diện`,navigation:`Điều hướng`,media:`Phương tiện`,communication:`Liên lạc`,files:`Tệp tin`,people:`Con người`,objects:`Đồ vật`}},findReplace:{findTitle:`Tìm kiếm`,findReplaceTitle:`Tìm & Thay thế`,findPlaceholder:`Tìm…`,searchAriaLabel:`Văn bản tìm kiếm`,caseSensitive:`\xA0Phân biệt hoa thường`,wholeWord:`Toàn bộ từ`,prevBtn:`← Trước`,nextBtn:`Tiếp →`,replacePlaceholder:`Thay thế bằng…`,replaceAriaLabel:`Thay thế bằng`,replaceBtn:`Thay thế`,replaceAllBtn:`Thay thế tất cả`,noResults:`Không có kết quả`,useRegex:`Dùng biểu thức chính quy`,close:`×`},shortcutsDialog:{title:`Phím tắt bàn phím`,ariaLabel:`Phím tắt bàn phím`,close:`Đóng`,shortcuts:[{category:`Định dạng văn bản`,items:[{keys:`Ctrl + B`,action:`Đậm`},{keys:`Ctrl + I`,action:`Nghiêng`},{keys:`Ctrl + U`,action:`Gạch chân`},{keys:`Ctrl + K`,action:`Chèn / sửa liên kết`}]},{category:`Lịch sử`,items:[{keys:`Ctrl + Z`,action:`Hoàn tác`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Làm lại`}]},{category:`Chọn & Điều hướng`,items:[{keys:`Ctrl + A`,action:`Chọn tất cả`},{keys:`Tab`,action:`Tăng thụt đầu dòng / chèn khoảng trắng`},{keys:`Shift + Tab`,action:`Giảm thụt đầu dòng`}]},{category:`Bảng nhớ tạm`,items:[{keys:`Ctrl + Shift + V`,action:`Dán dưới dạng văn bản thuần`}]},{category:`Tìm & Thay thế`,items:[{keys:`Ctrl + F`,action:`Tìm trong tài liệu`},{keys:`Ctrl + H`,action:`Tìm & Thay thế`}]},{category:`Trình soạn thảo`,items:[{keys:`Ctrl + Shift + /`,action:`Hiện hộp thoại phím tắt`}]}]},contextMenu:{cut:`Cắt`,copy:`Sao chép`,paste:`Dán`,bold:`Đậm`,italic:`Nghiêng`,underline:`Gạch chân`,textColor:`Màu chữ`,highlightColor:`Màu nền chữ`,copyFormat:`Sao chép định dạng`,pasteFormat:`Dán định dạng`,removeFormat:`Xóa định dạng`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,table:`Chèn bảng`,back:`Quay lại`,noHighlight:`Không tô màu`,customColor:`Màu tùy chỉnh`,customColorLabel:`Tùy chỉnh…`},statusbar:{resizeHandle:`Kéo để thay đổi kích thước`,words:e=>`Từ: ${e}`,wordsLimit:(e,t)=>`Từ: ${e}/${t}`,chars:e=>`Ký tự: ${e}`,charsLimit:(e,t)=>`Ký tự: ${e}/${t}`},tooltips:{link:{ariaLabel:`Hành động liên kết`,openLink:`Mở liên kết`,copyUrl:`Sao chép URL`,editLink:`Sửa liên kết`,removeLink:`Xóa liên kết`},image:{ariaLabel:`Hành động hình ảnh`,label:`Hình ảnh`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,rotateLeft:`Xoay trái`,rotateRight:`Xoay phải`,cropImage:`Cắt ảnh`,addCaption:`Thêm / Sửa chú thích`,deleteImage:`Xóa hình ảnh`},code:{ariaLabel:`Hành động khối mã`,label:`Mã`,syntaxLanguage:`Ngôn ngữ cú pháp`,syntaxAriaLabel:`Ngôn ngữ cú pháp`,copyCode:`Sao chép mã`,toggleWordWrap:`Chuyển đổi xuống dòng`,enableWordWrap:`Bật xuống dòng`,disableWordWrap:`Tắt xuống dòng`,convertToParagraph:`Chuyển thành đoạn văn`,deleteCodeBlock:`Xóa khối mã`,lineNumbers:`Bật/Tắt số dòng`},table:{ariaLabel:`Hành động bảng`,label:`Bảng`,selectCells:`Chọn ô`,addRowAbove:`Thêm hàng phía trên`,addRowBelow:`Thêm hàng phía dưới`,deleteRow:`Xóa hàng`,addColumnLeft:`Thêm cột bên trái`,addColumnRight:`Thêm cột bên phải`,deleteColumn:`Xóa cột`,mergeCells:`Gộp ô`,unmergeCells:`Tách ô`,columnWidth:`Chiều rộng cột`,rowHeight:`Chiều cao hàng`,tableBorderWidth:`Độ rộng viền bảng`,tableBorderColor:`Màu viền bảng`,deleteTable:`Xóa bảng`,cellAlignLeft:`Căn trái`,cellAlignCenter:`Căn giữa`,cellAlignRight:`Căn phải`,cellAlignJustify:`Căn đều`,toggleHeaderRow:`Bật/tắt hàng tiêu đề`,cellBackground:`Màu Nền Ô`,noShading:`Xóa Màu Nền`,noBorderColor:`Xóa màu viền`,columnWidthPx:`Chiều rộng cột (px)`,rowHeightPx:`Chiều cao hàng (px)`,tableBorderWidthPx:`Độ rộng viền bảng (px)`,cancelBtn:`Hủy`,applyBtn:`Áp dụng`,sortAsc:`Sắp xếp tăng dần`,sortDesc:`Sắp xếp giảm dần`,exportCSV:`Xuất CSV`,cellPadding:`Khoảng đệm ô`,cellPaddingPx:`Khoảng đệm ô (px)`},video:{ariaLabel:`Hành động video`,label:`Video`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,previewVideo:`Xem trước`,exitPreview:`Thoát xem trước`,deleteVideo:`Xóa video`}},errors:{imageFormat:e=>`Định dạng "${e}" không được hỗ trợ hiển thị trên trình duyệt. Vui lòng chuyển đổi sang JPEG, PNG hoặc WebP.`,imageSize:e=>`Tệp hình ảnh quá lớn. Kích thước tối đa cho phép là ${e} MB.`},autoSaveRestore:{found:`Tìm thấy bản nháp. Khôi phục?`,foundAt:`Bản nháp từ {date}. Khôi phục?`,restore:`Khôi phục`,discard:`Bỏ qua`},slashMenu:{noResults:`Không có lệnh phù hợp`,heading1:`Tiêu đề 1`,heading2:`Tiêu đề 2`,heading3:`Tiêu đề 3`,bulletList:`Danh sách không thứ tự`,numberedList:`Danh sách có thứ tự`,checklist:`Danh sách công việc`,blockquote:`Trích dẫn`,codeBlock:`Khối mã`,horizontalRule:`Đường kẻ ngang`,table:`Bảng`,image:`Hình ảnh`}}),s(`ja`,{toolbar:{bold:`太字 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下線 (Ctrl+U)`,strikethrough:`取り消し線`,superscript:`上付き文字`,subscript:`下付き文字`,alignLeft:`左揃え`,alignCenter:`中央揃え`,alignRight:`右揃え`,alignJustify:`両端揃え`,ul:`箇条書きリスト`,ol:`番号付きリスト`,checklist:`チェックリスト`,indent:`インデントを増やす`,outdent:`インデントを減らす`,undo:`元に戻す (Ctrl+Z)`,redo:`やり直す (Ctrl+Y)`,hr:`水平線`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,emoji:`絵文字を挿入`,icon:`FAアイコンを挿入`,table:`テーブルを挿入`,fontSize:`フォントサイズ`,fontSizePlaceholder:`サイズ`,removeFormat:`書式をリセット`,direction:`文字方向を切り替え (LTR / RTL)`,fontFamily:`フォント`,paragraphStyle:`段落スタイル`,paragraphStylePlaceholder:`スタイル`,lineHeight:`行の高さ`,lineHeightPlaceholder:`↕ 行間`,codeview:`HTMLソースを表示`,fullscreen:`全画面表示`,shortcuts:`キーボードショートカット (Ctrl+Shift+/)`,find:`検索 (Ctrl+F)`,findReplace:`検索と置換 (Ctrl+H)`,inlineCode:"インラインコード (Ctrl+`)",print:`印刷`,foreColor:`文字色`,backColor:`ハイライト色`,chooseTextColor:`文字色を選択`,chooseHighlightColor:`ハイライト色を選択`,customColor:`カスタムカラー`,insertTableLabel:`テーブルを挿入`,paragraphItems:{p:`標準`,blockquote:`引用`,pre:`コード`}},linkDialog:{ariaLabel:`リンクを挿入`,title:`リンクを挿入`,url:`URL`,urlPlaceholder:`https://`,displayText:`表示テキスト`,textPlaceholder:`リンクテキスト`,openInNewTab:`新しいタブで開く`,insertBtn:`挿入`,cancelBtn:`キャンセル`},imageDialog:{ariaLabel:`画像を挿入`,title:`画像を挿入`,imageUrl:`画像URL`,urlPlaceholder:`https://example.com/image.png`,altText:`代替テキスト`,altPlaceholder:`画像の説明`,alignment:`配置`,alignNone:`なし`,alignLeft:`左`,alignCenter:`中央`,alignRight:`右`,uploadLabel:`ファイルをアップロード`,insertBtn:`挿入`,cancelBtn:`キャンセル`},videoDialog:{ariaLabel:`動画を挿入`,title:`動画を挿入`,videoUrl:`動画URL`,urlPlaceholder:`YouTube、Vimeo、または直接動画URL`,widthLabel:`幅 (px)`,widthPlaceholder:`560`,insertBtn:`挿入`,cancelBtn:`キャンセル`,detected:e=>`検出: ${e}`,unknownFormat:`不明な形式 — 直接動画埋め込みを試みます`,invalidUrl:`URLが無効です — 有効な動画URLを入力してください。`},emojiDialog:{ariaLabel:`絵文字を挿入`,title:`絵文字を挿入`,searchPlaceholder:`絵文字を検索…`,all:`すべて`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{smileys:`顔文字`,people:`人物`,animals:`動物`,food:`食べ物`,travel:`旅行`,objects:`モノ`,symbols:`記号`}},iconDialog:{ariaLabel:`FAアイコンを挿入`,title:`FAアイコンを挿入`,searchPlaceholder:`アイコンを検索…`,all:`すべて`,style:`スタイル`,size:`サイズ`,color:`カラー`,useColor:` カラーを使用`,selectHint:`アイコンを選択してください`,insertBtn:`FAアイコンを挿入`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{popular:`人気`,interface:`インターフェース`,navigation:`ナビゲーション`,media:`メディア`,communication:`通信`,files:`ファイル`,people:`人物`,objects:`モノ`}},findReplace:{findTitle:`検索`,findReplaceTitle:`検索と置換`,findPlaceholder:`検索…`,searchAriaLabel:`検索テキスト`,caseSensitive:`\xA0大文字/小文字を区別`,wholeWord:`単語単位`,prevBtn:`← 前へ`,nextBtn:`次へ →`,replacePlaceholder:`置換後…`,replaceAriaLabel:`置換後のテキスト`,replaceBtn:`置換`,noResults:`結果なし`,useRegex:`正規表現を使用`,replaceAllBtn:`すべて置換`,close:`×`},shortcutsDialog:{title:`キーボードショートカット`,ariaLabel:`キーボードショートカット`,close:`閉じる`,shortcuts:[{category:`テキスト書式`,items:[{keys:`Ctrl + B`,action:`太字`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下線`},{keys:`Ctrl + K`,action:`リンクの挿入 / 編集`}]},{category:`履歴`,items:[{keys:`Ctrl + Z`,action:`元に戻す`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`やり直す`}]},{category:`選択と移動`,items:[{keys:`Ctrl + A`,action:`すべて選択`},{keys:`Tab`,action:`インデント増加 / スペース挿入`},{keys:`Shift + Tab`,action:`インデント減少`}]},{category:`クリップボード`,items:[{keys:`Ctrl + Shift + V`,action:`プレーンテキストとして貼り付け`}]},{category:`検索と置換`,items:[{keys:`Ctrl + F`,action:`文書内を検索`},{keys:`Ctrl + H`,action:`検索と置換`}]},{category:`エディター`,items:[{keys:`Ctrl + Shift + /`,action:`ショートカットダイアログを表示`}]}]},contextMenu:{cut:`切り取り`,copy:`コピー`,paste:`貼り付け`,bold:`太字`,italic:`斜体`,underline:`下線`,textColor:`文字色`,highlightColor:`ハイライト色`,copyFormat:`書式をコピー`,pasteFormat:`書式を貼り付け`,removeFormat:`書式をリセット`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,table:`テーブルを挿入`,back:`戻る`,noHighlight:`ハイライトなし`,customColor:`カスタムカラー`,customColorLabel:`カスタム…`},statusbar:{resizeHandle:`ドラッグしてリサイズ`,words:e=>`単語数: ${e}`,wordsLimit:(e,t)=>`単語数: ${e}/${t}`,chars:e=>`文字数: ${e}`,charsLimit:(e,t)=>`文字数: ${e}/${t}`},tooltips:{link:{ariaLabel:`リンク操作`,openLink:`リンクを開く`,copyUrl:`URLをコピー`,editLink:`リンクを編集`,removeLink:`リンクを削除`},image:{ariaLabel:`画像操作`,label:`画像`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,rotateLeft:`左に回転`,rotateRight:`右に回転`,cropImage:`画像をトリミング`,addCaption:`キャプションを追加 / 編集`,deleteImage:`画像を削除`},code:{ariaLabel:`コードブロック操作`,label:`コード`,syntaxLanguage:`言語`,syntaxAriaLabel:`構文言語`,copyCode:`コードをコピー`,toggleWordWrap:`折り返しを切り替え`,enableWordWrap:`折り返しを有効にする`,disableWordWrap:`折り返しを無効にする`,convertToParagraph:`段落に変換`,deleteCodeBlock:`コードブロックを削除`,lineNumbers:`行番号を切り替え`},table:{ariaLabel:`テーブル操作`,label:`テーブル`,selectCells:`セルを選択`,addRowAbove:`上に行を追加`,addRowBelow:`下に行を追加`,deleteRow:`行を削除`,addColumnLeft:`左に列を追加`,addColumnRight:`右に列を追加`,deleteColumn:`列を削除`,mergeCells:`セルを結合`,unmergeCells:`セルの結合を解除`,columnWidth:`列幅`,rowHeight:`行の高さ`,tableBorderWidth:`テーブルの枠幅`,tableBorderColor:`テーブルの枠線色`,deleteTable:`テーブルを削除`,cellAlignLeft:`左揃え`,cellAlignCenter:`中央揃え`,cellAlignRight:`右揃え`,cellAlignJustify:`両端揃え`,toggleHeaderRow:`ヘッダー行の切り替え`,cellBackground:`セル背景色`,noShading:`背景色なし`,noBorderColor:`枠線色なし`,columnWidthPx:`列幅 (px)`,rowHeightPx:`行の高さ (px)`,tableBorderWidthPx:`テーブルの枠幅 (px)`,cancelBtn:`キャンセル`,applyBtn:`適用`,sortAsc:`昇順で並べ替え`,sortDesc:`降順で並べ替え`,exportCSV:`CSVとしてエクスポート`,cellPadding:`セルの余白`,cellPaddingPx:`セルの余白 (px)`},video:{ariaLabel:`動画操作`,label:`動画`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,previewVideo:`プレビュー`,exitPreview:`プレビューを終了`,deleteVideo:`動画を削除`}},errors:{imageFormat:e=>`形式 "${e}" はブラウザでの表示をサポートしていません。JPEG、PNG、または WebP に変換してください。`,imageSize:e=>`画像ファイルが大きすぎます。最大許容サイズは ${e} MB です。`},autoSaveRestore:{found:`下書きが見つかりました。復元しますか?`,foundAt:`{date} の下書きが見つかりました。復元しますか?`,restore:`復元`,discard:`破棄`},slashMenu:{noResults:`一致するコマンドがありません`,heading1:`見出し1`,heading2:`見出し2`,heading3:`見出し3`,bulletList:`箇条書きリスト`,numberedList:`番号付きリスト`,checklist:`チェックリスト`,blockquote:`引用`,codeBlock:`コードブロック`,horizontalRule:`水平線`,table:`表`,image:`画像`}}),s(`zh`,{toolbar:{bold:`粗体 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下划线 (Ctrl+U)`,strikethrough:`删除线`,superscript:`上标`,subscript:`下标`,alignLeft:`左对齐`,alignCenter:`居中`,alignRight:`右对齐`,alignJustify:`两端对齐`,ul:`无序列表`,ol:`有序列表`,checklist:`待办列表`,indent:`增加缩进`,outdent:`减少缩进`,undo:`撤销 (Ctrl+Z)`,redo:`重做 (Ctrl+Y)`,hr:`水平分割线`,link:`插入链接`,image:`插入图片`,video:`插入视频`,emoji:`插入表情`,icon:`插入 FA 图标`,table:`插入表格`,fontSize:`字号`,fontSizePlaceholder:`大小`,removeFormat:`清除格式`,direction:`切换文字方向 (LTR / RTL)`,fontFamily:`字体`,paragraphStyle:`段落样式`,paragraphStylePlaceholder:`样式`,lineHeight:`行高`,lineHeightPlaceholder:`↕ 行距`,codeview:`查看 HTML 源码`,fullscreen:`全屏`,shortcuts:`键盘快捷键 (Ctrl+Shift+/)`,find:`搜索 (Ctrl+F)`,findReplace:`查找和替换 (Ctrl+H)`,inlineCode:"行内代码 (Ctrl+`)",print:`打印`,foreColor:`文字颜色`,backColor:`高亮颜色`,chooseTextColor:`选择文字颜色`,chooseHighlightColor:`选择高亮颜色`,customColor:`自定义颜色`,insertTableLabel:`插入表格`,paragraphItems:{p:`正文`,blockquote:`引用`,pre:`代码`}},linkDialog:{ariaLabel:`插入链接`,title:`插入链接`,url:`链接地址`,urlPlaceholder:`https://`,displayText:`显示文字`,textPlaceholder:`链接文字`,openInNewTab:`在新标签页中打开`,insertBtn:`插入`,cancelBtn:`取消`},imageDialog:{ariaLabel:`插入图片`,title:`插入图片`,imageUrl:`图片地址`,urlPlaceholder:`https://example.com/image.png`,altText:`替代文字`,altPlaceholder:`图片描述`,alignment:`对齐方式`,alignNone:`无`,alignLeft:`左`,alignCenter:`居中`,alignRight:`右`,uploadLabel:`或上传文件`,insertBtn:`插入`,cancelBtn:`取消`},videoDialog:{ariaLabel:`插入视频`,title:`插入视频`,videoUrl:`视频地址`,urlPlaceholder:`YouTube、Vimeo 或直接 .mp4 链接`,widthLabel:`宽度 (px)`,widthPlaceholder:`560`,insertBtn:`插入`,cancelBtn:`取消`,detected:e=>`已识别: ${e}`,unknownFormat:`未知格式 — 将尝试直接嵌入视频`,invalidUrl:`URL 无效 — 请输入有效的视频链接。`},emojiDialog:{ariaLabel:`插入表情`,title:`插入表情`,searchPlaceholder:`搜索表情…`,all:`全部`,cancelBtn:`取消`,close:`关闭`,categories:{smileys:`笑脸`,people:`人物`,animals:`动物`,food:`食物`,travel:`旅行`,objects:`物品`,symbols:`符号`}},iconDialog:{ariaLabel:`插入 FA 图标`,title:`插入 FA 图标`,searchPlaceholder:`搜索图标…`,all:`全部`,style:`样式`,size:`大小`,color:`颜色`,useColor:` 使用颜色`,selectHint:`请选择一个图标`,insertBtn:`插入 FA 图标`,cancelBtn:`取消`,close:`关闭`,categories:{popular:`热门`,interface:`界面`,navigation:`导航`,media:`媒体`,communication:`通讯`,files:`文件`,people:`人物`,objects:`物品`}},findReplace:{findTitle:`搜索`,findReplaceTitle:`查找和替换`,findPlaceholder:`查找…`,searchAriaLabel:`搜索文字`,caseSensitive:`\xA0区分大小写`,wholeWord:`全字匹配`,prevBtn:`← 上一个`,nextBtn:`下一个 →`,replacePlaceholder:`替换为…`,replaceAriaLabel:`替换为`,replaceBtn:`替换`,noResults:`没有结果`,useRegex:`使用正则表达式`,replaceAllBtn:`全部替换`,close:`×`},shortcutsDialog:{title:`键盘快捷键`,ariaLabel:`键盘快捷键`,close:`关闭`,shortcuts:[{category:`文字格式`,items:[{keys:`Ctrl + B`,action:`粗体`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下划线`},{keys:`Ctrl + K`,action:`插入 / 编辑链接`}]},{category:`历史记录`,items:[{keys:`Ctrl + Z`,action:`撤销`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`重做`}]},{category:`选择与导航`,items:[{keys:`Ctrl + A`,action:`全选`},{keys:`Tab`,action:`增加缩进 / 插入空格`},{keys:`Shift + Tab`,action:`减少缩进`}]},{category:`剪贴板`,items:[{keys:`Ctrl + Shift + V`,action:`粘贴为纯文本`}]},{category:`查找和替换`,items:[{keys:`Ctrl + F`,action:`在文档中搜索`},{keys:`Ctrl + H`,action:`查找和替换`}]},{category:`编辑器`,items:[{keys:`Ctrl + Shift + /`,action:`显示快捷键对话框`}]}]},contextMenu:{cut:`剪切`,copy:`复制`,paste:`粘贴`,bold:`粗体`,italic:`斜体`,underline:`下划线`,textColor:`文字颜色`,highlightColor:`高亮颜色`,copyFormat:`复制格式`,pasteFormat:`粘贴格式`,removeFormat:`清除格式`,link:`插入链接`,image:`插入图片`,video:`插入视频`,table:`插入表格`,back:`返回`,noHighlight:`无高亮`,customColor:`自定义颜色`,customColorLabel:`自定义…`},statusbar:{resizeHandle:`拖动以调整大小`,words:e=>`字数: ${e}`,wordsLimit:(e,t)=>`字数: ${e}/${t}`,chars:e=>`字符数: ${e}`,charsLimit:(e,t)=>`字符数: ${e}/${t}`},tooltips:{link:{ariaLabel:`链接操作`,openLink:`打开链接`,copyUrl:`复制 URL`,editLink:`编辑链接`,removeLink:`删除链接`},image:{ariaLabel:`图片操作`,label:`图片`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,rotateLeft:`向左旋转`,rotateRight:`向右旋转`,cropImage:`裁剪图片`,addCaption:`添加 / 编辑说明`,deleteImage:`删除图片`},code:{ariaLabel:`代码块操作`,label:`代码`,syntaxLanguage:`语法语言`,syntaxAriaLabel:`语法语言`,copyCode:`复制代码`,toggleWordWrap:`切换自动换行`,enableWordWrap:`启用自动换行`,disableWordWrap:`禁用自动换行`,convertToParagraph:`转换为段落`,deleteCodeBlock:`删除代码块`,lineNumbers:`切换行号`},table:{ariaLabel:`表格操作`,label:`表格`,selectCells:`选择单元格`,addRowAbove:`在上方插入行`,addRowBelow:`在下方插入行`,deleteRow:`删除行`,addColumnLeft:`在左侧插入列`,addColumnRight:`在右侧插入列`,deleteColumn:`删除列`,mergeCells:`合并单元格`,unmergeCells:`拆分单元格`,columnWidth:`列宽`,rowHeight:`行高`,tableBorderWidth:`表格边框宽度`,tableBorderColor:`表格边框颜色`,deleteTable:`删除表格`,cellAlignLeft:`左对齐`,cellAlignCenter:`居中对齐`,cellAlignRight:`右对齐`,cellAlignJustify:`两端对齐`,toggleHeaderRow:`切换标题行`,cellBackground:`单元格背景`,noShading:`无底纹`,noBorderColor:`无边框颜色`,columnWidthPx:`列宽 (px)`,rowHeightPx:`行高 (px)`,tableBorderWidthPx:`表格边框宽度 (px)`,cancelBtn:`取消`,applyBtn:`应用`,sortAsc:`升序排列`,sortDesc:`降序排列`,exportCSV:`导出为 CSV`,cellPadding:`单元格内边距`,cellPaddingPx:`单元格内边距 (px)`},video:{ariaLabel:`视频操作`,label:`视频`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,previewVideo:`预览视频`,exitPreview:`退出预览`,deleteVideo:`删除视频`}},errors:{imageFormat:e=>`格式 "${e}" 不支持在浏览器中显示。请转换为 JPEG、PNG 或 WebP。`,imageSize:e=>`图片文件过大。最大允许大小为 ${e} MB。`},autoSaveRestore:{found:`找到草稿。是否恢复?`,foundAt:`发现 {date} 的草稿。是否恢复?`,restore:`恢复`,discard:`放弃`},slashMenu:{noResults:`没有匹配的命令`,heading1:`标题 1`,heading2:`标题 2`,heading3:`标题 3`,bulletList:`项目符号列表`,numberedList:`编号列表`,checklist:`检查清单`,blockquote:`引用`,codeBlock:`代码块`,horizontalRule:`水平线`,table:`表格`,image:`图片`}}),s(`fr`,{toolbar:{bold:`Gras (Ctrl+B)`,italic:`Italique (Ctrl+I)`,underline:`Souligné (Ctrl+U)`,strikethrough:`Barré`,superscript:`Exposant`,subscript:`Indice`,alignLeft:`Aligner à gauche`,alignCenter:`Centrer`,alignRight:`Aligner à droite`,alignJustify:`Justifier`,ul:`Liste à puces`,ol:`Liste numérotée`,checklist:`Liste de tâches`,indent:`Augmenter le retrait`,outdent:`Diminuer le retrait`,undo:`Annuler (Ctrl+Z)`,redo:`Rétablir (Ctrl+Y)`,hr:`Ligne horizontale`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,emoji:`Insérer un emoji`,icon:`Insérer une icône FA`,table:`Insérer un tableau`,fontSize:`Taille de police`,fontSizePlaceholder:`Taille`,removeFormat:`Effacer la mise en forme`,direction:`Basculer la direction du texte (LTR / RTL)`,fontFamily:`Police`,paragraphStyle:`Style de paragraphe`,paragraphStylePlaceholder:`Style`,lineHeight:`Interligne`,lineHeightPlaceholder:`↕ Ligne`,codeview:`Afficher le code HTML`,fullscreen:`Plein écran`,shortcuts:`Raccourcis clavier (Ctrl+Shift+/)`,find:`Rechercher (Ctrl+F)`,findReplace:`Rechercher et remplacer (Ctrl+H)`,inlineCode:"Code inline (Ctrl+`)",print:`Imprimer`,foreColor:`Couleur du texte`,backColor:`Couleur de surbrillance`,chooseTextColor:`Choisir la couleur du texte`,chooseHighlightColor:`Choisir la couleur de surbrillance`,customColor:`Couleur personnalisée`,insertTableLabel:`Insérer un tableau`,paragraphItems:{p:`Normal`,blockquote:`Citation`,pre:`Code`}},linkDialog:{ariaLabel:`Insérer un lien`,title:`Insérer un lien`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texte affiché`,textPlaceholder:`Texte du lien`,openInNewTab:`Ouvrir dans un nouvel onglet`,insertBtn:`Insérer`,cancelBtn:`Annuler`},imageDialog:{ariaLabel:`Insérer une image`,title:`Insérer une image`,imageUrl:`URL de l'image`,urlPlaceholder:`https://example.com/image.png`,altText:`Texte alternatif`,altPlaceholder:`Description de l'image`,alignment:`Alignement`,alignNone:`Aucun`,alignLeft:`Gauche`,alignCenter:`Centre`,alignRight:`Droite`,uploadLabel:`Ou téléverser un fichier`,insertBtn:`Insérer`,cancelBtn:`Annuler`},videoDialog:{ariaLabel:`Insérer une vidéo`,title:`Insérer une vidéo`,videoUrl:`URL de la vidéo`,urlPlaceholder:`YouTube, Vimeo ou URL .mp4 directe`,widthLabel:`Largeur (px)`,widthPlaceholder:`560`,insertBtn:`Insérer`,cancelBtn:`Annuler`,detected:e=>`Détecté\u00a0: ${e}`,unknownFormat:`Format inconnu — tentative d'intégration directe`,invalidUrl:`URL invalide — veuillez saisir un lien vidéo valide.`},emojiDialog:{ariaLabel:`Insérer un emoji`,title:`Insérer un emoji`,searchPlaceholder:`Rechercher des emojis…`,all:`Tout`,cancelBtn:`Annuler`,close:`Fermer`,categories:{smileys:`Smileys`,people:`Personnes`,animals:`Animaux`,food:`Nourriture`,travel:`Voyage`,objects:`Objets`,symbols:`Symboles`}},iconDialog:{ariaLabel:`Insérer une icône FA`,title:`Insérer une icône FA`,searchPlaceholder:`Rechercher des icônes…`,all:`Tout`,style:`Style`,size:`Taille`,color:`Couleur`,useColor:` Utiliser la couleur`,selectHint:`Sélectionner une icône`,insertBtn:`Insérer une icône FA`,cancelBtn:`Annuler`,close:`Fermer`,categories:{popular:`Populaire`,interface:`Interface`,navigation:`Navigation`,media:`Média`,communication:`Communication`,files:`Fichiers`,people:`Personnes`,objects:`Objets`}},findReplace:{findTitle:`Rechercher`,findReplaceTitle:`Rechercher et remplacer`,findPlaceholder:`Rechercher…`,searchAriaLabel:`Texte à rechercher`,caseSensitive:`\xA0Respecter la casse`,wholeWord:`Mot entier`,prevBtn:`← Préc.`,nextBtn:`Suiv. →`,replacePlaceholder:`Remplacer par…`,replaceAriaLabel:`Remplacer par`,replaceBtn:`Remplacer`,noResults:`Aucun résultat`,useRegex:`Utiliser une expression régulière`,replaceAllBtn:`Tout remplacer`,close:`×`},shortcutsDialog:{title:`Raccourcis clavier`,ariaLabel:`Raccourcis clavier`,close:`Fermer`,shortcuts:[{category:`Mise en forme du texte`,items:[{keys:`Ctrl + B`,action:`Gras`},{keys:`Ctrl + I`,action:`Italique`},{keys:`Ctrl + U`,action:`Souligné`},{keys:`Ctrl + K`,action:`Insérer / modifier un lien`}]},{category:`Historique`,items:[{keys:`Ctrl + Z`,action:`Annuler`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rétablir`}]},{category:`Sélection et navigation`,items:[{keys:`Ctrl + A`,action:`Tout sélectionner`},{keys:`Tab`,action:`Augmenter le retrait / insérer des espaces`},{keys:`Shift + Tab`,action:`Diminuer le retrait`}]},{category:`Presse-papiers`,items:[{keys:`Ctrl + Shift + V`,action:`Coller en texte brut`}]},{category:`Rechercher et remplacer`,items:[{keys:`Ctrl + F`,action:`Rechercher dans le document`},{keys:`Ctrl + H`,action:`Rechercher et remplacer`}]},{category:`Éditeur`,items:[{keys:`Ctrl + Shift + /`,action:`Afficher les raccourcis clavier`}]}]},contextMenu:{cut:`Couper`,copy:`Copier`,paste:`Coller`,bold:`Gras`,italic:`Italique`,underline:`Souligné`,textColor:`Couleur du texte`,highlightColor:`Couleur de surbrillance`,copyFormat:`Copier la mise en forme`,pasteFormat:`Coller la mise en forme`,removeFormat:`Effacer la mise en forme`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,table:`Insérer un tableau`,back:`Retour`,noHighlight:`Sans surbrillance`,customColor:`Couleur personnalisée`,customColorLabel:`Personnaliser…`},statusbar:{resizeHandle:`Faire glisser pour redimensionner`,words:e=>`Mots\u00a0: ${e}`,wordsLimit:(e,t)=>`Mots\u00a0: ${e}/${t}`,chars:e=>`Caractères\u00a0: ${e}`,charsLimit:(e,t)=>`Caractères\u00a0: ${e}/${t}`},tooltips:{link:{ariaLabel:`Actions du lien`,openLink:`Ouvrir le lien`,copyUrl:`Copier l'URL`,editLink:`Modifier le lien`,removeLink:`Supprimer le lien`},image:{ariaLabel:`Actions de l'image`,label:`Image`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,rotateLeft:`Rotation à gauche`,rotateRight:`Rotation à droite`,cropImage:`Recadrer l'image`,addCaption:`Ajouter / modifier la légende`,deleteImage:`Supprimer l'image`},code:{ariaLabel:`Actions du bloc de code`,label:`Code`,syntaxLanguage:`Langage de syntaxe`,syntaxAriaLabel:`Langage de syntaxe`,copyCode:`Copier le code`,toggleWordWrap:`Activer/désactiver le retour à la ligne`,enableWordWrap:`Activer le retour à la ligne`,disableWordWrap:`Désactiver le retour à la ligne`,convertToParagraph:`Convertir en paragraphe`,deleteCodeBlock:`Supprimer le bloc de code`,lineNumbers:`Activer/désactiver les numéros de ligne`},table:{ariaLabel:`Actions du tableau`,label:`Tableau`,selectCells:`Sélectionner des cellules`,addRowAbove:`Ajouter une ligne au-dessus`,addRowBelow:`Ajouter une ligne en-dessous`,deleteRow:`Supprimer la ligne`,addColumnLeft:`Ajouter une colonne à gauche`,addColumnRight:`Ajouter une colonne à droite`,deleteColumn:`Supprimer la colonne`,mergeCells:`Fusionner les cellules`,unmergeCells:`Scinder les cellules`,columnWidth:`Largeur de colonne`,rowHeight:`Hauteur de ligne`,tableBorderWidth:`Épaisseur des bordures`,tableBorderColor:`Couleur de bordure`,deleteTable:`Supprimer le tableau`,cellAlignLeft:`Aligner à gauche`,cellAlignCenter:`Centrer`,cellAlignRight:`Aligner à droite`,cellAlignJustify:`Justifier`,toggleHeaderRow:`Ligne d'en-tête`,cellBackground:`Couleur de fond`,noShading:`Aucun fond`,noBorderColor:`Aucune bordure`,columnWidthPx:`Largeur de colonne (px)`,rowHeightPx:`Hauteur de ligne (px)`,tableBorderWidthPx:`Épaisseur des bordures (px)`,cancelBtn:`Annuler`,applyBtn:`Appliquer`,sortAsc:`Trier par ordre croissant`,sortDesc:`Trier par ordre décroissant`,exportCSV:`Exporter en CSV`,cellPadding:`Rembourrage des cellules`,cellPaddingPx:`Rembourrage des cellules (px)`},video:{ariaLabel:`Actions de la vidéo`,label:`Vidéo`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,previewVideo:`Aperçu`,exitPreview:`Quitter l'aperçu`,deleteVideo:`Supprimer la vidéo`}},errors:{imageFormat:e=>`Le format "${e}" n'est pas pris en charge par le navigateur. Veuillez le convertir en JPEG, PNG ou WebP.`,imageSize:e=>`Le fichier image est trop volumineux. La taille maximale autorisée est de ${e}\u00a0Mo.`},autoSaveRestore:{found:`Brouillon trouvé. Restaurer ?`,foundAt:`Brouillon du {date}. Restaurer ?`,restore:`Restaurer`,discard:`Ignorer`},slashMenu:{noResults:`Aucune commande correspondante`,heading1:`Titre 1`,heading2:`Titre 2`,heading3:`Titre 3`,bulletList:`Liste à puces`,numberedList:`Liste numérotée`,checklist:`Liste de contrôle`,blockquote:`Citation`,codeBlock:`Bloc de code`,horizontalRule:`Ligne horizontale`,table:`Tableau`,image:`Image`}}),s(`de`,{toolbar:{bold:`Fett (Ctrl+B)`,italic:`Kursiv (Ctrl+I)`,underline:`Unterstrichen (Ctrl+U)`,strikethrough:`Durchgestrichen`,superscript:`Hochgestellt`,subscript:`Tiefgestellt`,alignLeft:`Linksbündig`,alignCenter:`Zentriert`,alignRight:`Rechtsbündig`,alignJustify:`Blocksatz`,ul:`Ungeordnete Liste`,ol:`Geordnete Liste`,checklist:`Checkliste`,indent:`Einzug vergrößern`,outdent:`Einzug verkleinern`,undo:`Rückgängig (Ctrl+Z)`,redo:`Wiederholen (Ctrl+Y)`,hr:`Horizontale Linie`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,emoji:`Emoji einfügen`,icon:`FA-Symbol einfügen`,table:`Tabelle einfügen`,fontSize:`Schriftgröße`,fontSizePlaceholder:`Größe`,removeFormat:`Formatierung entfernen`,direction:`Textrichtung umschalten (LTR / RTL)`,fontFamily:`Schriftart`,paragraphStyle:`Absatzstil`,paragraphStylePlaceholder:`Stil`,lineHeight:`Zeilenhöhe`,lineHeightPlaceholder:`↕ Zeile`,codeview:`HTML-Code-Ansicht`,fullscreen:`Vollbild`,shortcuts:`Tastenkürzel (Ctrl+Shift+/)`,find:`Suchen (Ctrl+F)`,findReplace:`Suchen & Ersetzen (Ctrl+H)`,inlineCode:"Inline-Code (Ctrl+`)",print:`Drucken`,foreColor:`Textfarbe`,backColor:`Hervorhebungsfarbe`,chooseTextColor:`Textfarbe auswählen`,chooseHighlightColor:`Hervorhebungsfarbe auswählen`,customColor:`Benutzerdefinierte Farbe`,insertTableLabel:`Tabelle einfügen`,paragraphItems:{p:`Normal`,blockquote:`Zitat`,pre:`Code`}},linkDialog:{ariaLabel:`Link einfügen`,title:`Link einfügen`,url:`URL`,urlPlaceholder:`https://`,displayText:`Anzeigetext`,textPlaceholder:`Linktext`,openInNewTab:`In neuem Tab öffnen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},imageDialog:{ariaLabel:`Bild einfügen`,title:`Bild einfügen`,imageUrl:`Bild-URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt-Text`,altPlaceholder:`Bild beschreiben`,alignment:`Ausrichtung`,alignNone:`Keine`,alignLeft:`Links`,alignCenter:`Mitte`,alignRight:`Rechts`,uploadLabel:`Oder Datei hochladen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},videoDialog:{ariaLabel:`Video einfügen`,title:`Video einfügen`,videoUrl:`Video-URL`,urlPlaceholder:`YouTube, Vimeo oder direkte .mp4-URL`,widthLabel:`Breite (px)`,widthPlaceholder:`560`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`,detected:e=>`Erkannt: ${e}`,unknownFormat:`Unbekanntes Format — direktes Video-Einbetten wird versucht`,invalidUrl:`Ungültige URL — bitte geben Sie einen gültigen Videolink ein.`},emojiDialog:{ariaLabel:`Emoji einfügen`,title:`Emoji einfügen`,searchPlaceholder:`Emojis suchen…`,all:`Alle`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{smileys:`Smileys`,people:`Menschen`,animals:`Tiere`,food:`Essen`,travel:`Reisen`,objects:`Objekte`,symbols:`Symbole`}},iconDialog:{ariaLabel:`FA-Symbol einfügen`,title:`FA-Symbol einfügen`,searchPlaceholder:`Symbole suchen…`,all:`Alle`,style:`Stil`,size:`Größe`,color:`Farbe`,useColor:` Farbe verwenden`,selectHint:`Symbol auswählen`,insertBtn:`FA-Symbol einfügen`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{popular:`Beliebt`,interface:`Benutzeroberfläche`,navigation:`Navigation`,media:`Medien`,communication:`Kommunikation`,files:`Dateien`,people:`Menschen`,objects:`Objekte`}},findReplace:{findTitle:`Suchen`,findReplaceTitle:`Suchen & Ersetzen`,findPlaceholder:`Suchen…`,searchAriaLabel:`Suchtext`,caseSensitive:`\xA0Groß-/Kleinschreibung`,wholeWord:`Ganzes Wort`,prevBtn:`← Zurück`,nextBtn:`Weiter →`,replacePlaceholder:`Ersetzen durch…`,replaceAriaLabel:`Ersetzen durch`,replaceBtn:`Ersetzen`,noResults:`Keine Ergebnisse`,useRegex:`Regulären Ausdruck verwenden`,replaceAllBtn:`Alle ersetzen`,close:`×`},shortcutsDialog:{title:`Tastenkürzel`,ariaLabel:`Tastenkürzel`,close:`Schließen`,shortcuts:[{category:`Textformatierung`,items:[{keys:`Ctrl + B`,action:`Fett`},{keys:`Ctrl + I`,action:`Kursiv`},{keys:`Ctrl + U`,action:`Unterstrichen`},{keys:`Ctrl + K`,action:`Link einfügen / bearbeiten`}]},{category:`Verlauf`,items:[{keys:`Ctrl + Z`,action:`Rückgängig`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Wiederholen`}]},{category:`Auswahl & Navigation`,items:[{keys:`Ctrl + A`,action:`Alles auswählen`},{keys:`Tab`,action:`Listenebene erhöhen / Leerzeichen einfügen`},{keys:`Shift + Tab`,action:`Listenebene verringern`}]},{category:`Zwischenablage`,items:[{keys:`Ctrl + Shift + V`,action:`Als einfachen Text einfügen`}]},{category:`Suchen & Ersetzen`,items:[{keys:`Ctrl + F`,action:`Im Dokument suchen`},{keys:`Ctrl + H`,action:`Suchen & Ersetzen`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Diesen Tastenkürzel-Dialog anzeigen`}]}]},contextMenu:{cut:`Ausschneiden`,copy:`Kopieren`,paste:`Einfügen`,bold:`Fett`,italic:`Kursiv`,underline:`Unterstrichen`,textColor:`Textfarbe`,highlightColor:`Hervorhebungsfarbe`,copyFormat:`Format kopieren`,pasteFormat:`Format einfügen`,removeFormat:`Formatierung entfernen`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,table:`Tabelle einfügen`,back:`Zurück`,noHighlight:`Keine Hervorhebung`,customColor:`Benutzerdefinierte Farbe`,customColorLabel:`Benutzerdefiniert…`},statusbar:{resizeHandle:`Editor-Größe ändern`,words:e=>`Wörter: ${e}`,wordsLimit:(e,t)=>`Wörter: ${e}/${t}`,chars:e=>`Zeichen: ${e}`,charsLimit:(e,t)=>`Zeichen: ${e}/${t}`},tooltips:{link:{ariaLabel:`Link-Aktionen`,openLink:`Link öffnen`,copyUrl:`URL kopieren`,editLink:`Link bearbeiten`,removeLink:`Link entfernen`},image:{ariaLabel:`Bild-Aktionen`,label:`Bild`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,rotateLeft:`Links drehen`,rotateRight:`Rechts drehen`,cropImage:`Bild zuschneiden`,addCaption:`Beschriftung hinzufügen / bearbeiten`,deleteImage:`Bild löschen`},code:{ariaLabel:`Codeblock-Aktionen`,label:`Code`,syntaxLanguage:`Syntaxsprache`,syntaxAriaLabel:`Syntaxsprache`,copyCode:`Code kopieren`,toggleWordWrap:`Zeilenumbruch umschalten`,enableWordWrap:`Zeilenumbruch aktivieren`,disableWordWrap:`Zeilenumbruch deaktivieren`,convertToParagraph:`In Absatz umwandeln`,deleteCodeBlock:`Codeblock löschen`,lineNumbers:`Zeilennummern umschalten`},table:{ariaLabel:`Tabellen-Aktionen`,label:`Tabelle`,selectCells:`Zellen auswählen`,addRowAbove:`Zeile oben hinzufügen`,addRowBelow:`Zeile unten hinzufügen`,deleteRow:`Zeile löschen`,addColumnLeft:`Spalte links hinzufügen`,addColumnRight:`Spalte rechts hinzufügen`,deleteColumn:`Spalte löschen`,mergeCells:`Zellen zusammenführen`,unmergeCells:`Zellen trennen`,columnWidth:`Spaltenbreite`,rowHeight:`Zeilenhöhe`,tableBorderWidth:`Tabellenrahmenbreite`,tableBorderColor:`Tabellenrahmenfarbe`,deleteTable:`Tabelle löschen`,cellAlignLeft:`Linksbündig`,cellAlignCenter:`Zentrieren`,cellAlignRight:`Rechtsbündig`,cellAlignJustify:`Blocksatz`,toggleHeaderRow:`Kopfzeile umschalten`,cellBackground:`Zellhintergrund`,noShading:`Kein Hintergrund`,noBorderColor:`Keine Rahmenfarbe`,columnWidthPx:`Spaltenbreite (px)`,rowHeightPx:`Zeilenhöhe (px)`,tableBorderWidthPx:`Tabellenrahmenbreite (px)`,cancelBtn:`Abbrechen`,applyBtn:`Anwenden`,sortAsc:`Aufsteigend sortieren`,sortDesc:`Absteigend sortieren`,exportCSV:`Als CSV exportieren`,cellPadding:`Zellauffüllung`,cellPaddingPx:`Zellauffüllung (px)`},video:{ariaLabel:`Video-Aktionen`,label:`Video`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,previewVideo:`Video-Vorschau`,exitPreview:`Vorschau beenden`,deleteVideo:`Video löschen`}},errors:{imageFormat:e=>`Das Format „${e}" wird in Webbrowsern nicht unterstützt. Bitte konvertieren Sie es zuerst in JPEG, PNG oder WebP.`,imageSize:e=>`Die Bilddatei ist zu groß. Die maximal zulässige Größe beträgt ${e} MB.`},autoSaveRestore:{found:`Entwurf gefunden. Wiederherstellen?`,foundAt:`Entwurf vom {date}. Wiederherstellen?`,restore:`Wiederherstellen`,discard:`Verwerfen`},slashMenu:{noResults:`Keine passenden Befehle`,heading1:`Überschrift 1`,heading2:`Überschrift 2`,heading3:`Überschrift 3`,bulletList:`Aufzählungsliste`,numberedList:`Nummerierte Liste`,checklist:`Checkliste`,blockquote:`Zitat`,codeBlock:`Codeblock`,horizontalRule:`Horizontale Linie`,table:`Tabelle`,image:`Bild`}}),s(`es`,{toolbar:{bold:`Negrita (Ctrl+B)`,italic:`Cursiva (Ctrl+I)`,underline:`Subrayado (Ctrl+U)`,strikethrough:`Tachado`,superscript:`Superíndice`,subscript:`Subíndice`,alignLeft:`Alinear a la izquierda`,alignCenter:`Centrar`,alignRight:`Alinear a la derecha`,alignJustify:`Justificar`,ul:`Lista sin orden`,ol:`Lista ordenada`,checklist:`Lista de verificación`,indent:`Aumentar sangría`,outdent:`Reducir sangría`,undo:`Deshacer (Ctrl+Z)`,redo:`Rehacer (Ctrl+Y)`,hr:`Línea horizontal`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,emoji:`Insertar emoji`,icon:`Insertar icono FA`,table:`Insertar tabla`,fontSize:`Tamaño de fuente`,fontSizePlaceholder:`Tamaño`,removeFormat:`Eliminar formato`,direction:`Cambiar dirección del texto (LTR / RTL)`,fontFamily:`Fuente`,paragraphStyle:`Estilo de párrafo`,paragraphStylePlaceholder:`Estilo`,lineHeight:`Interlineado`,lineHeightPlaceholder:`↕ Línea`,codeview:`Vista de código HTML`,fullscreen:`Pantalla completa`,shortcuts:`Atajos de teclado (Ctrl+Shift+/)`,find:`Buscar (Ctrl+F)`,findReplace:`Buscar y reemplazar (Ctrl+H)`,inlineCode:"Código en línea (Ctrl+`)",print:`Imprimir`,foreColor:`Color del texto`,backColor:`Color de resaltado`,chooseTextColor:`Elegir color del texto`,chooseHighlightColor:`Elegir color de resaltado`,customColor:`Color personalizado`,insertTableLabel:`Insertar tabla`,paragraphItems:{p:`Normal`,blockquote:`Cita`,pre:`Código`}},linkDialog:{ariaLabel:`Insertar enlace`,title:`Insertar enlace`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texto a mostrar`,textPlaceholder:`Texto del enlace`,openInNewTab:`Abrir en nueva pestaña`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},imageDialog:{ariaLabel:`Insertar imagen`,title:`Insertar imagen`,imageUrl:`URL de imagen`,urlPlaceholder:`https://example.com/image.png`,altText:`Texto alternativo`,altPlaceholder:`Describir la imagen`,alignment:`Alineación`,alignNone:`Ninguna`,alignLeft:`Izquierda`,alignCenter:`Centro`,alignRight:`Derecha`,uploadLabel:`O subir un archivo`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},videoDialog:{ariaLabel:`Insertar vídeo`,title:`Insertar vídeo`,videoUrl:`URL del vídeo`,urlPlaceholder:`YouTube, Vimeo o URL directa .mp4`,widthLabel:`Ancho (px)`,widthPlaceholder:`560`,insertBtn:`Insertar`,cancelBtn:`Cancelar`,detected:e=>`Detectado: ${e}`,unknownFormat:`Formato desconocido — se intentará incrustar el vídeo directamente`,invalidUrl:`URL no válida — introduzca un enlace de vídeo válido.`},emojiDialog:{ariaLabel:`Insertar emoji`,title:`Insertar emoji`,searchPlaceholder:`Buscar emojis…`,all:`Todos`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{smileys:`Caritas`,people:`Personas`,animals:`Animales`,food:`Comida`,travel:`Viajes`,objects:`Objetos`,symbols:`Símbolos`}},iconDialog:{ariaLabel:`Insertar icono FA`,title:`Insertar icono FA`,searchPlaceholder:`Buscar iconos…`,all:`Todos`,style:`Estilo`,size:`Tamaño`,color:`Color`,useColor:` Usar color`,selectHint:`Seleccionar un icono`,insertBtn:`Insertar icono FA`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{popular:`Popular`,interface:`Interfaz`,navigation:`Navegación`,media:`Medios`,communication:`Comunicación`,files:`Archivos`,people:`Personas`,objects:`Objetos`}},findReplace:{findTitle:`Buscar`,findReplaceTitle:`Buscar y reemplazar`,findPlaceholder:`Buscar…`,searchAriaLabel:`Texto de búsqueda`,caseSensitive:`\xA0Distinguir mayúsculas`,wholeWord:`Palabra completa`,prevBtn:`← Anterior`,nextBtn:`Siguiente →`,replacePlaceholder:`Reemplazar con…`,replaceAriaLabel:`Reemplazar con`,replaceBtn:`Reemplazar`,noResults:`Sin resultados`,useRegex:`Usar expresión regular`,replaceAllBtn:`Reemplazar todo`,close:`×`},shortcutsDialog:{title:`Atajos de teclado`,ariaLabel:`Atajos de teclado`,close:`Cerrar`,shortcuts:[{category:`Formato de texto`,items:[{keys:`Ctrl + B`,action:`Negrita`},{keys:`Ctrl + I`,action:`Cursiva`},{keys:`Ctrl + U`,action:`Subrayado`},{keys:`Ctrl + K`,action:`Insertar / editar enlace`}]},{category:`Historial`,items:[{keys:`Ctrl + Z`,action:`Deshacer`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rehacer`}]},{category:`Selección y navegación`,items:[{keys:`Ctrl + A`,action:`Seleccionar todo`},{keys:`Tab`,action:`Aumentar sangría / insertar espacios`},{keys:`Shift + Tab`,action:`Reducir sangría`}]},{category:`Portapapeles`,items:[{keys:`Ctrl + Shift + V`,action:`Pegar como texto plano`}]},{category:`Buscar y reemplazar`,items:[{keys:`Ctrl + F`,action:`Buscar en el documento`},{keys:`Ctrl + H`,action:`Buscar y reemplazar`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Mostrar este diálogo de atajos`}]}]},contextMenu:{cut:`Cortar`,copy:`Copiar`,paste:`Pegar`,bold:`Negrita`,italic:`Cursiva`,underline:`Subrayado`,textColor:`Color del texto`,highlightColor:`Color de resaltado`,copyFormat:`Copiar formato`,pasteFormat:`Pegar formato`,removeFormat:`Eliminar formato`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,table:`Insertar tabla`,back:`Atrás`,noHighlight:`Sin resaltado`,customColor:`Color personalizado`,customColorLabel:`Personalizado…`},statusbar:{resizeHandle:`Redimensionar editor`,words:e=>`Palabras: ${e}`,wordsLimit:(e,t)=>`Palabras: ${e}/${t}`,chars:e=>`Caracteres: ${e}`,charsLimit:(e,t)=>`Caracteres: ${e}/${t}`},tooltips:{link:{ariaLabel:`Acciones de enlace`,openLink:`Abrir enlace`,copyUrl:`Copiar URL`,editLink:`Editar enlace`,removeLink:`Eliminar enlace`},image:{ariaLabel:`Acciones de imagen`,label:`Imagen`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,rotateLeft:`Rotar a la izquierda`,rotateRight:`Rotar a la derecha`,cropImage:`Recortar imagen`,addCaption:`Añadir / editar pie de foto`,deleteImage:`Eliminar imagen`},code:{ariaLabel:`Acciones de bloque de código`,label:`Código`,syntaxLanguage:`Lenguaje de sintaxis`,syntaxAriaLabel:`Lenguaje de sintaxis`,copyCode:`Copiar código`,toggleWordWrap:`Alternar ajuste de línea`,enableWordWrap:`Activar ajuste de línea`,disableWordWrap:`Desactivar ajuste de línea`,convertToParagraph:`Convertir en párrafo`,deleteCodeBlock:`Eliminar bloque de código`,lineNumbers:`Alternar números de línea`},table:{ariaLabel:`Acciones de tabla`,label:`Tabla`,selectCells:`Seleccionar celdas`,addRowAbove:`Añadir fila encima`,addRowBelow:`Añadir fila debajo`,deleteRow:`Eliminar fila`,addColumnLeft:`Añadir columna a la izquierda`,addColumnRight:`Añadir columna a la derecha`,deleteColumn:`Eliminar columna`,mergeCells:`Combinar celdas`,unmergeCells:`Separar celdas`,columnWidth:`Ancho de columna`,rowHeight:`Alto de fila`,tableBorderWidth:`Grosor del borde de la tabla`,tableBorderColor:`Color del borde de la tabla`,deleteTable:`Eliminar tabla`,cellAlignLeft:`Alinear a la izquierda`,cellAlignCenter:`Centrar`,cellAlignRight:`Alinear a la derecha`,cellAlignJustify:`Justificar`,toggleHeaderRow:`Activar fila de encabezado`,cellBackground:`Fondo de celda`,noShading:`Sin fondo`,noBorderColor:`Sin color de borde`,columnWidthPx:`Ancho de columna (px)`,rowHeightPx:`Alto de fila (px)`,tableBorderWidthPx:`Grosor del borde (px)`,cancelBtn:`Cancelar`,applyBtn:`Aplicar`,sortAsc:`Ordenar ascendente`,sortDesc:`Ordenar descendente`,exportCSV:`Exportar como CSV`,cellPadding:`Relleno de celda`,cellPaddingPx:`Relleno de celda (px)`},video:{ariaLabel:`Acciones de vídeo`,label:`Vídeo`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,previewVideo:`Vista previa de vídeo`,exitPreview:`Salir de la vista previa`,deleteVideo:`Eliminar vídeo`}},errors:{imageFormat:e=>`El formato "${e}" no es compatible con los navegadores web. Por favor, conviértalo primero a JPEG, PNG o WebP.`,imageSize:e=>`El archivo de imagen es demasiado grande. El tamaño máximo permitido es ${e} MB.`},autoSaveRestore:{found:`Borrador encontrado. ¿Restaurar?`,foundAt:`Borrador del {date}. ¿Restaurar?`,restore:`Restaurar`,discard:`Descartar`},slashMenu:{noResults:`No hay comandos coincidentes`,heading1:`Encabezado 1`,heading2:`Encabezado 2`,heading3:`Encabezado 3`,bulletList:`Lista con viñetas`,numberedList:`Lista numerada`,checklist:`Lista de verificación`,blockquote:`Cita`,codeBlock:`Bloque de código`,horizontalRule:`Línea horizontal`,table:`Tabla`,image:`Imagen`}}),s(`ko`,{toolbar:{bold:`굵게 (Ctrl+B)`,italic:`기울임꼴 (Ctrl+I)`,underline:`밑줄 (Ctrl+U)`,strikethrough:`취소선`,superscript:`위 첨자`,subscript:`아래 첨자`,alignLeft:`왼쪽 정렬`,alignCenter:`가운데 정렬`,alignRight:`오른쪽 정렬`,alignJustify:`양쪽 정렬`,ul:`순서 없는 목록`,ol:`순서 있는 목록`,checklist:`체크리스트`,indent:`들여쓰기`,outdent:`내어쓰기`,undo:`실행 취소 (Ctrl+Z)`,redo:`다시 실행 (Ctrl+Y)`,hr:`수평선`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,emoji:`이모지 삽입`,icon:`FA 아이콘 삽입`,table:`표 삽입`,fontSize:`글꼴 크기`,fontSizePlaceholder:`크기`,removeFormat:`서식 제거`,direction:`텍스트 방향 전환 (LTR / RTL)`,fontFamily:`글꼴`,paragraphStyle:`단락 스타일`,paragraphStylePlaceholder:`스타일`,lineHeight:`줄 간격`,lineHeightPlaceholder:`↕ 줄`,codeview:`HTML 코드 보기`,fullscreen:`전체 화면`,shortcuts:`키보드 단축키 (Ctrl+Shift+/)`,find:`찾기 (Ctrl+F)`,findReplace:`찾기 및 바꾸기 (Ctrl+H)`,inlineCode:"인라인 코드 (Ctrl+`)",print:`인쇄`,foreColor:`글자 색`,backColor:`강조 색`,chooseTextColor:`글자 색 선택`,chooseHighlightColor:`강조 색 선택`,customColor:`사용자 지정 색`,insertTableLabel:`표 삽입`,paragraphItems:{p:`기본`,blockquote:`인용`,pre:`코드`}},linkDialog:{ariaLabel:`링크 삽입`,title:`링크 삽입`,url:`URL`,urlPlaceholder:`https://`,displayText:`표시 텍스트`,textPlaceholder:`링크 텍스트`,openInNewTab:`새 탭에서 열기`,insertBtn:`삽입`,cancelBtn:`취소`},imageDialog:{ariaLabel:`이미지 삽입`,title:`이미지 삽입`,imageUrl:`이미지 URL`,urlPlaceholder:`https://example.com/image.png`,altText:`대체 텍스트`,altPlaceholder:`이미지 설명`,alignment:`정렬`,alignNone:`없음`,alignLeft:`왼쪽`,alignCenter:`가운데`,alignRight:`오른쪽`,uploadLabel:`또는 파일 업로드`,insertBtn:`삽입`,cancelBtn:`취소`},videoDialog:{ariaLabel:`동영상 삽입`,title:`동영상 삽입`,videoUrl:`동영상 URL`,urlPlaceholder:`YouTube, Vimeo 또는 직접 .mp4 URL`,widthLabel:`너비 (px)`,widthPlaceholder:`560`,insertBtn:`삽입`,cancelBtn:`취소`,detected:e=>`감지됨: ${e}`,unknownFormat:`알 수 없는 형식 — 직접 동영상 임베드를 시도합니다`,invalidUrl:`유효하지 않은 URL — 올바른 동영상 링크를 입력하세요.`},emojiDialog:{ariaLabel:`이모지 삽입`,title:`이모지 삽입`,searchPlaceholder:`이모지 검색…`,all:`전체`,cancelBtn:`취소`,close:`닫기`,categories:{smileys:`스마일`,people:`사람`,animals:`동물`,food:`음식`,travel:`여행`,objects:`사물`,symbols:`기호`}},iconDialog:{ariaLabel:`FA 아이콘 삽입`,title:`FA 아이콘 삽입`,searchPlaceholder:`아이콘 검색…`,all:`전체`,style:`스타일`,size:`크기`,color:`색상`,useColor:` 색상 사용`,selectHint:`아이콘을 선택하세요`,insertBtn:`FA 아이콘 삽입`,cancelBtn:`취소`,close:`닫기`,categories:{popular:`인기`,interface:`인터페이스`,navigation:`탐색`,media:`미디어`,communication:`커뮤니케이션`,files:`파일`,people:`사람`,objects:`사물`}},findReplace:{findTitle:`찾기`,findReplaceTitle:`찾기 및 바꾸기`,findPlaceholder:`찾기…`,searchAriaLabel:`검색 텍스트`,caseSensitive:`\xA0대소문자 구분`,wholeWord:`전체 단어`,prevBtn:`← 이전`,nextBtn:`다음 →`,replacePlaceholder:`바꿀 내용…`,replaceAriaLabel:`바꿀 내용`,replaceBtn:`바꾸기`,noResults:`결과 없음`,useRegex:`정규식 사용`,replaceAllBtn:`모두 바꾸기`,close:`×`},shortcutsDialog:{title:`키보드 단축키`,ariaLabel:`키보드 단축키`,close:`닫기`,shortcuts:[{category:`텍스트 서식`,items:[{keys:`Ctrl + B`,action:`굵게`},{keys:`Ctrl + I`,action:`기울임꼴`},{keys:`Ctrl + U`,action:`밑줄`},{keys:`Ctrl + K`,action:`링크 삽입 / 편집`}]},{category:`실행 기록`,items:[{keys:`Ctrl + Z`,action:`실행 취소`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`다시 실행`}]},{category:`선택 및 탐색`,items:[{keys:`Ctrl + A`,action:`전체 선택`},{keys:`Tab`,action:`목록 들여쓰기 / 공백 삽입`},{keys:`Shift + Tab`,action:`목록 내어쓰기`}]},{category:`클립보드`,items:[{keys:`Ctrl + Shift + V`,action:`일반 텍스트로 붙여넣기`}]},{category:`찾기 및 바꾸기`,items:[{keys:`Ctrl + F`,action:`문서에서 찾기`},{keys:`Ctrl + H`,action:`찾기 및 바꾸기`}]},{category:`편집기`,items:[{keys:`Ctrl + Shift + /`,action:`이 단축키 대화상자 표시`}]}]},contextMenu:{cut:`잘라내기`,copy:`복사`,paste:`붙여넣기`,bold:`굵게`,italic:`기울임꼴`,underline:`밑줄`,textColor:`글자 색`,highlightColor:`강조 색`,copyFormat:`서식 복사`,pasteFormat:`서식 붙여넣기`,removeFormat:`서식 제거`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,table:`표 삽입`,back:`뒤로`,noHighlight:`강조 없음`,customColor:`사용자 지정 색`,customColorLabel:`사용자 지정…`},statusbar:{resizeHandle:`편집기 크기 조정`,words:e=>`단어: ${e}`,wordsLimit:(e,t)=>`단어: ${e}/${t}`,chars:e=>`글자: ${e}`,charsLimit:(e,t)=>`글자: ${e}/${t}`},tooltips:{link:{ariaLabel:`링크 작업`,openLink:`링크 열기`,copyUrl:`URL 복사`,editLink:`링크 편집`,removeLink:`링크 제거`},image:{ariaLabel:`이미지 작업`,label:`이미지`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,rotateLeft:`왼쪽 회전`,rotateRight:`오른쪽 회전`,cropImage:`이미지 자르기`,addCaption:`캡션 추가 / 편집`,deleteImage:`이미지 삭제`},code:{ariaLabel:`코드 블록 작업`,label:`코드`,syntaxLanguage:`구문 언어`,syntaxAriaLabel:`구문 언어`,copyCode:`코드 복사`,toggleWordWrap:`줄 바꿈 전환`,enableWordWrap:`줄 바꿈 사용`,disableWordWrap:`줄 바꿈 해제`,convertToParagraph:`단락으로 변환`,deleteCodeBlock:`코드 블록 삭제`,lineNumbers:`줄 번호 전환`},table:{ariaLabel:`표 작업`,label:`표`,selectCells:`셀 선택`,addRowAbove:`위에 행 추가`,addRowBelow:`아래에 행 추가`,deleteRow:`행 삭제`,addColumnLeft:`왼쪽에 열 추가`,addColumnRight:`오른쪽에 열 추가`,deleteColumn:`열 삭제`,mergeCells:`셀 병합`,unmergeCells:`셀 분할`,columnWidth:`열 너비`,rowHeight:`행 높이`,tableBorderWidth:`표 테두리 너비`,tableBorderColor:`표 테두리 색상`,deleteTable:`표 삭제`,cellAlignLeft:`왼쪽 정렬`,cellAlignCenter:`가운데 정렬`,cellAlignRight:`오른쪽 정렬`,cellAlignJustify:`양쪽 정렬`,toggleHeaderRow:`머리글 행 전환`,cellBackground:`셀 배경색`,noShading:`배경 없음`,noBorderColor:`테두리 색 없음`,columnWidthPx:`열 너비 (px)`,rowHeightPx:`행 높이 (px)`,tableBorderWidthPx:`표 테두리 너비 (px)`,cancelBtn:`취소`,applyBtn:`적용`,sortAsc:`오름차순 정렬`,sortDesc:`내림차순 정렬`,exportCSV:`CSV로 내보내기`,cellPadding:`셀 패딩`,cellPaddingPx:`셀 패딩 (px)`},video:{ariaLabel:`동영상 작업`,label:`동영상`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,previewVideo:`동영상 미리보기`,exitPreview:`미리보기 종료`,deleteVideo:`동영상 삭제`}},errors:{imageFormat:e=>`"${e}" 형식은 웹 브라우저에서 지원되지 않습니다. JPEG, PNG 또는 WebP로 변환해 주세요.`,imageSize:e=>`이미지 파일이 너무 큽니다. 최대 허용 크기는 ${e} MB입니다.`},autoSaveRestore:{found:`초안을 찾았습니다. 복원하시겠습니까?`,foundAt:`{date}의 초안을 찾았습니다. 복원하시겠습니까?`,restore:`복원`,discard:`삭제`},slashMenu:{noResults:`일치하는 명령이 없습니다`,heading1:`제목 1`,heading2:`제목 2`,heading3:`제목 3`,bulletList:`글머리 기호 목록`,numberedList:`번호 매기기 목록`,checklist:`체크리스트`,blockquote:`인용문`,codeBlock:`코드 블록`,horizontalRule:`가로선`,table:`표`,image:`이미지`}});var l=e=>e?.nodeType===1,u=e=>l(e)&&/^(p|div|li|h[1-6]|blockquote|td|th|pre)$/i.test(e.nodeName),d=e=>l(e)&&/^(li)$/i.test(e.nodeName);function f(e,t,n){let r=e;for(;r&&r!==n;){if(t(r))return r;r=r.parentNode}return null}function p(e,t){return f(e,u,t)}function m(e,t={},n=[]){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);for(let e of n)typeof e==`string`?r.appendChild(document.createTextNode(e)):r.appendChild(e);return r}function h(e){let t=document.createRange();t.selectNodeContents(e),t.collapse(!1);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function g(e){if(e?.querySelectorAll)for(let t of e.querySelectorAll(`ul > ul, ul > ol, ol > ul, ol > ol`)){let e=t.previousElementSibling;if(e&&e.nodeName===`LI`)e.appendChild(t);else if(t.parentNode){let e=t.ownerDocument.createElement(`li`);t.parentNode.insertBefore(e,t),e.appendChild(t)}}}function _(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function v(e,t){let n=()=>Array.from(e.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.closest(`[style*="display: none"]`)&&!e.closest(`[style*="display:none"]`)),r=e=>{if(e.key===`Escape`){e.stopPropagation(),t?.();return}if(e.key!==`Tab`)return;let r=n();if(!r.length)return;let i=r[0],a=r.at(-1);e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())};return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)}function ee(e,t){e.style.cursor=`grab`;let n=n=>{if(n.button!==0||n.target.closest(`button, input, select, textarea, a`))return;if(n.preventDefault(),!t.dataset.anDragPinned){let e=t.getBoundingClientRect();t.style.position=`fixed`,t.style.margin=`0`,t.style.left=`${e.left}px`,t.style.top=`${e.top}px`,t.dataset.anDragPinned=`1`}let r=n.clientX-Number.parseFloat(t.style.left),i=n.clientY-Number.parseFloat(t.style.top);e.style.cursor=`grabbing`;let a=e=>{let n=t.offsetWidth,a=t.offsetHeight;t.style.left=`${Math.max(0,Math.min(e.clientX-r,globalThis.innerWidth-n))}px`,t.style.top=`${Math.max(0,Math.min(e.clientY-i,globalThis.innerHeight-a))}px`},o=()=>{e.style.cursor=`grab`,document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o)};document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)};return e.addEventListener(`mousedown`,n),()=>e.removeEventListener(`mousedown`,n)}var y=class{constructor(e,t,n,r){this.sc=e,this.so=t,this.ec=n,this.eo=r}isCollapsed(){return this.sc===this.ec&&this.so===this.eo}toNativeRange(){let e=document.createRange();try{e.setStart(this.sc,this.so),e.setEnd(this.ec,this.eo)}catch{}return e}select(){let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(this.toNativeRange()))}commonAncestor(){let e=this.toNativeRange().commonAncestorContainer;return l(e)?e:e.parentElement}blockNode(e){return f(this.sc,t=>l(t)&&t!==e,e)}toString(){return this.toNativeRange().toString()}getClientRects(){let e=this.toNativeRange().getClientRects();return e.length>0?e[e.length-1]:null}insertNode(e){this.toNativeRange().insertNode(e)}};function b(e){return new y(e.startContainer,e.startOffset,e.endContainer,e.endOffset)}function x(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&!e.contains(n.commonAncestorContainer)?null:b(n)}function S(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0){e(null);return}let n=t.getRangeAt(0).cloneRange();e(b(n)),t.removeAllRanges(),t.addRange(n)}function C(e){let t=e&&e.nodeType===1?e:e?.parentElement;for(;t;){let e=t.getAttribute?.(`contenteditable`)??t.contentEditable;if(e===`false`)return null;if(e!=null&&e!==`inherit`)return t;t=t.parentElement}return null}function w(e){let t=globalThis.getSelection?.();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&e!==document?e.contains(n.commonAncestorContainer)?n:null:C(n.commonAncestorContainer)?n:null}function T(e){let t=globalThis.getSelection?.();if(!t)return;let n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}function E(e,t){let n=w(t);if(!n)return!1;let r=document.createElement(`template`);r.innerHTML=e;let i=r.content,a=i.lastChild;return n.deleteContents(),n.insertNode(i),a&&T(a),!0}function D(e,t){let n=w(t);if(!n)return!1;n.deleteContents();let r=String(e),i=document.createDocumentFragment();!r.includes(`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.AutumnNote=t())})(this,function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function r(e,t){let n={};for(let t of Object.keys(e))n[t]=Array.isArray(e[t])?[...e[t]]:e[t];if(i(e)&&i(t))for(let a of Object.keys(t))n[a]=i(t[a])?r(i(e[a])?e[a]:{},t[a]):Array.isArray(t[a])?[...t[a]]:t[a];return n}function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var a={toolbar:{bold:`Bold (Ctrl+B)`,italic:`Italic (Ctrl+I)`,underline:`Underline (Ctrl+U)`,strikethrough:`Strikethrough`,superscript:`Superscript`,subscript:`Subscript`,alignLeft:`Align Left`,alignCenter:`Align Center`,alignRight:`Align Right`,alignJustify:`Justify`,ul:`Unordered List`,ol:`Ordered List`,checklist:`Checklist`,indent:`Indent`,outdent:`Outdent`,undo:`Undo (Ctrl+Z)`,redo:`Redo (Ctrl+Y)`,hr:`Horizontal Rule`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,emoji:`Insert Emoji`,icon:`Insert FA Icon`,table:`Insert Table`,fontSize:`Font Size`,fontSizePlaceholder:`Size`,removeFormat:`Remove Format`,direction:`Toggle Text Direction (LTR / RTL)`,fontFamily:`Font Family`,paragraphStyle:`Paragraph Style`,paragraphStylePlaceholder:`Style`,lineHeight:`Line Height`,lineHeightPlaceholder:`↕ Line`,codeview:`HTML Code View`,fullscreen:`Fullscreen`,shortcuts:`Keyboard Shortcuts (Ctrl+Shift+/)`,find:`Find (Ctrl+F)`,findReplace:`Find & Replace (Ctrl+H)`,inlineCode:"Inline Code (Ctrl+`)",print:`Print`,foreColor:`Text Color`,backColor:`Highlight Color`,chooseTextColor:`Choose text color`,chooseHighlightColor:`Choose highlight color`,customColor:`Custom color`,insertTableLabel:`Insert Table`,paragraphItems:{p:`Normal`,blockquote:`Quote`,pre:`Code`}},linkDialog:{ariaLabel:`Insert link`,title:`Insert Link`,url:`URL`,urlPlaceholder:`https://`,displayText:`Display Text`,textPlaceholder:`Link text`,openInNewTab:`Open in new tab`,insertBtn:`Insert`,cancelBtn:`Cancel`},imageDialog:{ariaLabel:`Insert image`,title:`Insert Image`,imageUrl:`Image URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt Text`,altPlaceholder:`Describe the image`,alignment:`Alignment`,alignNone:`None`,alignLeft:`Left`,alignCenter:`Center`,alignRight:`Right`,uploadLabel:`Or upload a file`,insertBtn:`Insert`,cancelBtn:`Cancel`},videoDialog:{ariaLabel:`Insert video`,title:`Insert Video`,videoUrl:`Video URL`,urlPlaceholder:`YouTube, Vimeo, or direct .mp4 URL`,widthLabel:`Width (px)`,widthPlaceholder:`560`,insertBtn:`Insert`,cancelBtn:`Cancel`,detected:e=>`Detected: ${e}`,unknownFormat:`Unknown format — will try direct video embed`,invalidUrl:`Invalid URL — please enter a valid video link.`},emojiDialog:{ariaLabel:`Insert emoji`,title:`Insert Emoji`,searchPlaceholder:`Search emojis…`,all:`All`,cancelBtn:`Cancel`,close:`Close`,categories:{smileys:`Smileys`,people:`People`,animals:`Animals`,food:`Food`,travel:`Travel`,objects:`Objects`,symbols:`Symbols`}},iconDialog:{ariaLabel:`Insert FA icon`,title:`Insert FA Icon`,searchPlaceholder:`Search icons…`,all:`All`,style:`Style`,size:`Size`,color:`Color`,useColor:` Use color`,selectHint:`Select an icon`,insertBtn:`Insert FA Icon`,cancelBtn:`Cancel`,close:`Close`,categories:{popular:`Popular`,interface:`Interface`,navigation:`Navigation`,media:`Media`,communication:`Communication`,files:`Files`,people:`People`,objects:`Objects`}},findReplace:{findTitle:`Find`,findReplaceTitle:`Find & Replace`,findPlaceholder:`Find…`,searchAriaLabel:`Search text`,caseSensitive:`\xA0Case sensitive`,wholeWord:`Whole Word`,prevBtn:`← Prev`,nextBtn:`Next →`,replacePlaceholder:`Replace with…`,replaceAriaLabel:`Replace with`,replaceBtn:`Replace`,replaceAllBtn:`Replace All`,noResults:`No results`,useRegex:`Use Regular Expression`,close:`×`},autoSaveRestore:{found:`Draft found. Restore?`,foundAt:`Draft from {date}. Restore?`,restore:`Restore`,discard:`Discard`},shortcutsDialog:{title:`Keyboard Shortcuts`,ariaLabel:`Keyboard Shortcuts`,close:`Close`,shortcuts:[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}]},contextMenu:{cut:`Cut`,copy:`Copy`,paste:`Paste`,bold:`Bold`,italic:`Italic`,underline:`Underline`,textColor:`Text Color`,highlightColor:`Highlight Color`,copyFormat:`Copy Format`,pasteFormat:`Paste Format`,removeFormat:`Remove Format`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,table:`Insert Table`,back:`Back`,noHighlight:`No highlight`,customColor:`Custom color`,customColorLabel:`Custom…`},statusbar:{resizeHandle:`Resize editor`,words:e=>`Words: ${e}`,wordsLimit:(e,t)=>`Words: ${e}/${t}`,chars:e=>`Chars: ${e}`,charsLimit:(e,t)=>`Chars: ${e}/${t}`},tooltips:{link:{ariaLabel:`Link actions`,openLink:`Open link`,copyUrl:`Copy URL`,editLink:`Edit link`,removeLink:`Remove link`},image:{ariaLabel:`Image actions`,label:`Image`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,rotateLeft:`Rotate Left`,rotateRight:`Rotate Right`,cropImage:`Crop Image`,addCaption:`Add / Edit Caption`,deleteImage:`Delete Image`},code:{ariaLabel:`Code block actions`,label:`Code`,syntaxLanguage:`Syntax Language`,syntaxAriaLabel:`Syntax language`,copyCode:`Copy Code`,toggleWordWrap:`Toggle Word Wrap`,enableWordWrap:`Enable Word Wrap`,disableWordWrap:`Disable Word Wrap`,convertToParagraph:`Convert to Paragraph`,deleteCodeBlock:`Delete Code Block`,lineNumbers:`Toggle Line Numbers`},table:{ariaLabel:`Table actions`,label:`Table`,selectCells:`Select Cells`,addRowAbove:`Add Row Above`,addRowBelow:`Add Row Below`,deleteRow:`Delete Row`,addColumnLeft:`Add Column Left`,addColumnRight:`Add Column Right`,deleteColumn:`Delete Column`,mergeCells:`Merge Cells`,unmergeCells:`Unmerge Cells`,columnWidth:`Column Width`,rowHeight:`Row Height`,tableBorderWidth:`Table Border Width`,tableBorderColor:`Table Border Color`,deleteTable:`Delete Table`,cellAlignLeft:`Align Left`,cellAlignCenter:`Align Center`,cellAlignRight:`Align Right`,cellAlignJustify:`Align Justify`,toggleHeaderRow:`Toggle Header Row`,cellBackground:`Cell Background`,noShading:`No Shading`,noBorderColor:`No Border Color`,columnWidthPx:`Column Width (px)`,rowHeightPx:`Row Height (px)`,tableBorderWidthPx:`Table Border Width (px)`,cancelBtn:`Cancel`,applyBtn:`Apply`,sortAsc:`Sort Ascending`,sortDesc:`Sort Descending`,exportCSV:`Export as CSV`,cellPadding:`Cell Padding`,cellPaddingPx:`Cell Padding (px)`},video:{ariaLabel:`Video actions`,label:`Video`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,previewVideo:`Preview Video`,exitPreview:`Exit Preview`,deleteVideo:`Delete Video`}},errors:{imageFormat:e=>`Format "${e}" is not supported for display in web browsers. Please convert to JPEG, PNG, or WebP first.`,imageSize:e=>`Image file is too large. Maximum allowed size is ${e} MB.`},slashMenu:{noResults:`No matching commands`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet List`,numberedList:`Numbered List`,checklist:`Checklist`,blockquote:`Blockquote`,codeBlock:`Code Block`,horizontalRule:`Horizontal Rule`,table:`Table`,image:`Image`}},o={en:a};function s(e,t){if(typeof e!=`string`||!e)throw TypeError(`[AutumnNote] registerLocale: code must be a non-empty string.`);if(!t||typeof t!=`object`)throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);o[e]=t}function c(e){if(!e||e===`en`)return a;if(typeof e==`string`){let t=o[e];return t?r(r({},a),t):(console.warn(`[AutumnNote] Locale "${e}" is not registered, falling back to English. Import it first: import { ${e} } from 'autumnnote/i18n/${e}'; AutumnNote.registerLocale('${e}', ${e});`),a)}return typeof e==`object`?r(r({},a),e):a}s(`vi`,{toolbar:{bold:`Đậm (Ctrl+B)`,italic:`Nghiêng (Ctrl+I)`,underline:`Gạch chân (Ctrl+U)`,strikethrough:`Gạch ngang`,superscript:`Chỉ số trên`,subscript:`Chỉ số dưới`,alignLeft:`Căn trái`,alignCenter:`Căn giữa`,alignRight:`Căn phải`,alignJustify:`Căn đều`,ul:`Danh sách không thứ tự`,ol:`Danh sách có thứ tự`,checklist:`Danh sách kiểm tra`,indent:`Tăng thụt đầu dòng`,outdent:`Giảm thụt đầu dòng`,undo:`Hoàn tác (Ctrl+Z)`,redo:`Làm lại (Ctrl+Y)`,hr:`Đường kẻ ngang`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,emoji:`Chèn biểu tượng cảm xúc`,icon:`Chèn biểu tượng FA`,table:`Chèn bảng`,fontSize:`Cỡ chữ`,fontSizePlaceholder:`Cỡ`,removeFormat:`Xóa định dạng`,direction:`Chuyển hướng văn bản (LTR / RTL)`,fontFamily:`Phông chữ`,paragraphStyle:`Kiểu đoạn văn`,paragraphStylePlaceholder:`Kiểu`,lineHeight:`Khoảng cách dòng`,lineHeightPlaceholder:`↕ Dòng`,codeview:`Xem mã HTML`,fullscreen:`Toàn màn hình`,shortcuts:`Phím tắt (Ctrl+Shift+/)`,find:`Tìm kiếm (Ctrl+F)`,findReplace:`Tìm & Thay thế (Ctrl+H)`,inlineCode:"Mã nội tuyến (Ctrl+`)",print:`In`,foreColor:`Màu chữ`,backColor:`Màu nền chữ`,chooseTextColor:`Chọn màu chữ`,chooseHighlightColor:`Chọn màu nền`,customColor:`Màu tùy chỉnh`,insertTableLabel:`Chèn bảng`,paragraphItems:{p:`Bình thường`,blockquote:`Trích dẫn`,pre:`Mã`}},linkDialog:{ariaLabel:`Chèn liên kết`,title:`Chèn liên kết`,url:`Địa chỉ URL`,urlPlaceholder:`https://`,displayText:`Văn bản hiển thị`,textPlaceholder:`Nội dung liên kết`,openInNewTab:`Mở trong tab mới`,insertBtn:`Chèn`,cancelBtn:`Hủy`},imageDialog:{ariaLabel:`Chèn hình ảnh`,title:`Chèn hình ảnh`,imageUrl:`URL hình ảnh`,urlPlaceholder:`https://example.com/anh.png`,altText:`Văn bản thay thế`,altPlaceholder:`Mô tả hình ảnh`,alignment:`Căn chỉnh`,alignNone:`Không`,alignLeft:`Trái`,alignCenter:`Giữa`,alignRight:`Phải`,uploadLabel:`Hoặc tải lên tệp`,insertBtn:`Chèn`,cancelBtn:`Hủy`},videoDialog:{ariaLabel:`Chèn video`,title:`Chèn video`,videoUrl:`URL video`,urlPlaceholder:`YouTube, Vimeo, hoặc URL .mp4 trực tiếp`,widthLabel:`Chiều rộng (px)`,widthPlaceholder:`560`,insertBtn:`Chèn`,cancelBtn:`Hủy`,detected:e=>`Đã phát hiện: ${e}`,unknownFormat:`Định dạng không xác định — sẽ thử nhúng video trực tiếp`,invalidUrl:`URL không hợp lệ — vui lòng nhập đường dẫn video hợp lệ.`},emojiDialog:{ariaLabel:`Chèn biểu tượng cảm xúc`,title:`Chèn biểu tượng cảm xúc`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,cancelBtn:`Hủy`,close:`Đóng`,categories:{smileys:`Mặt cười`,people:`Con người`,animals:`Động vật`,food:`Thức ăn`,travel:`Du lịch`,objects:`Đồ vật`,symbols:`Ký hiệu`}},iconDialog:{ariaLabel:`Chèn biểu tượng FA`,title:`Chèn biểu tượng FA`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,style:`Kiểu`,size:`Kích thước`,color:`Màu sắc`,useColor:` Dùng màu`,selectHint:`Chọn một biểu tượng`,insertBtn:`Chèn biểu tượng FA`,cancelBtn:`Hủy`,close:`Đóng`,categories:{popular:`Phổ biến`,interface:`Giao diện`,navigation:`Điều hướng`,media:`Phương tiện`,communication:`Liên lạc`,files:`Tệp tin`,people:`Con người`,objects:`Đồ vật`}},findReplace:{findTitle:`Tìm kiếm`,findReplaceTitle:`Tìm & Thay thế`,findPlaceholder:`Tìm…`,searchAriaLabel:`Văn bản tìm kiếm`,caseSensitive:`\xA0Phân biệt hoa thường`,wholeWord:`Toàn bộ từ`,prevBtn:`← Trước`,nextBtn:`Tiếp →`,replacePlaceholder:`Thay thế bằng…`,replaceAriaLabel:`Thay thế bằng`,replaceBtn:`Thay thế`,replaceAllBtn:`Thay thế tất cả`,noResults:`Không có kết quả`,useRegex:`Dùng biểu thức chính quy`,close:`×`},shortcutsDialog:{title:`Phím tắt bàn phím`,ariaLabel:`Phím tắt bàn phím`,close:`Đóng`,shortcuts:[{category:`Định dạng văn bản`,items:[{keys:`Ctrl + B`,action:`Đậm`},{keys:`Ctrl + I`,action:`Nghiêng`},{keys:`Ctrl + U`,action:`Gạch chân`},{keys:`Ctrl + K`,action:`Chèn / sửa liên kết`}]},{category:`Lịch sử`,items:[{keys:`Ctrl + Z`,action:`Hoàn tác`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Làm lại`}]},{category:`Chọn & Điều hướng`,items:[{keys:`Ctrl + A`,action:`Chọn tất cả`},{keys:`Tab`,action:`Tăng thụt đầu dòng / chèn khoảng trắng`},{keys:`Shift + Tab`,action:`Giảm thụt đầu dòng`}]},{category:`Bảng nhớ tạm`,items:[{keys:`Ctrl + Shift + V`,action:`Dán dưới dạng văn bản thuần`}]},{category:`Tìm & Thay thế`,items:[{keys:`Ctrl + F`,action:`Tìm trong tài liệu`},{keys:`Ctrl + H`,action:`Tìm & Thay thế`}]},{category:`Trình soạn thảo`,items:[{keys:`Ctrl + Shift + /`,action:`Hiện hộp thoại phím tắt`}]}]},contextMenu:{cut:`Cắt`,copy:`Sao chép`,paste:`Dán`,bold:`Đậm`,italic:`Nghiêng`,underline:`Gạch chân`,textColor:`Màu chữ`,highlightColor:`Màu nền chữ`,copyFormat:`Sao chép định dạng`,pasteFormat:`Dán định dạng`,removeFormat:`Xóa định dạng`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,table:`Chèn bảng`,back:`Quay lại`,noHighlight:`Không tô màu`,customColor:`Màu tùy chỉnh`,customColorLabel:`Tùy chỉnh…`},statusbar:{resizeHandle:`Kéo để thay đổi kích thước`,words:e=>`Từ: ${e}`,wordsLimit:(e,t)=>`Từ: ${e}/${t}`,chars:e=>`Ký tự: ${e}`,charsLimit:(e,t)=>`Ký tự: ${e}/${t}`},tooltips:{link:{ariaLabel:`Hành động liên kết`,openLink:`Mở liên kết`,copyUrl:`Sao chép URL`,editLink:`Sửa liên kết`,removeLink:`Xóa liên kết`},image:{ariaLabel:`Hành động hình ảnh`,label:`Hình ảnh`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,rotateLeft:`Xoay trái`,rotateRight:`Xoay phải`,cropImage:`Cắt ảnh`,addCaption:`Thêm / Sửa chú thích`,deleteImage:`Xóa hình ảnh`},code:{ariaLabel:`Hành động khối mã`,label:`Mã`,syntaxLanguage:`Ngôn ngữ cú pháp`,syntaxAriaLabel:`Ngôn ngữ cú pháp`,copyCode:`Sao chép mã`,toggleWordWrap:`Chuyển đổi xuống dòng`,enableWordWrap:`Bật xuống dòng`,disableWordWrap:`Tắt xuống dòng`,convertToParagraph:`Chuyển thành đoạn văn`,deleteCodeBlock:`Xóa khối mã`,lineNumbers:`Bật/Tắt số dòng`},table:{ariaLabel:`Hành động bảng`,label:`Bảng`,selectCells:`Chọn ô`,addRowAbove:`Thêm hàng phía trên`,addRowBelow:`Thêm hàng phía dưới`,deleteRow:`Xóa hàng`,addColumnLeft:`Thêm cột bên trái`,addColumnRight:`Thêm cột bên phải`,deleteColumn:`Xóa cột`,mergeCells:`Gộp ô`,unmergeCells:`Tách ô`,columnWidth:`Chiều rộng cột`,rowHeight:`Chiều cao hàng`,tableBorderWidth:`Độ rộng viền bảng`,tableBorderColor:`Màu viền bảng`,deleteTable:`Xóa bảng`,cellAlignLeft:`Căn trái`,cellAlignCenter:`Căn giữa`,cellAlignRight:`Căn phải`,cellAlignJustify:`Căn đều`,toggleHeaderRow:`Bật/tắt hàng tiêu đề`,cellBackground:`Màu Nền Ô`,noShading:`Xóa Màu Nền`,noBorderColor:`Xóa màu viền`,columnWidthPx:`Chiều rộng cột (px)`,rowHeightPx:`Chiều cao hàng (px)`,tableBorderWidthPx:`Độ rộng viền bảng (px)`,cancelBtn:`Hủy`,applyBtn:`Áp dụng`,sortAsc:`Sắp xếp tăng dần`,sortDesc:`Sắp xếp giảm dần`,exportCSV:`Xuất CSV`,cellPadding:`Khoảng đệm ô`,cellPaddingPx:`Khoảng đệm ô (px)`},video:{ariaLabel:`Hành động video`,label:`Video`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,previewVideo:`Xem trước`,exitPreview:`Thoát xem trước`,deleteVideo:`Xóa video`}},errors:{imageFormat:e=>`Định dạng "${e}" không được hỗ trợ hiển thị trên trình duyệt. Vui lòng chuyển đổi sang JPEG, PNG hoặc WebP.`,imageSize:e=>`Tệp hình ảnh quá lớn. Kích thước tối đa cho phép là ${e} MB.`},autoSaveRestore:{found:`Tìm thấy bản nháp. Khôi phục?`,foundAt:`Bản nháp từ {date}. Khôi phục?`,restore:`Khôi phục`,discard:`Bỏ qua`},slashMenu:{noResults:`Không có lệnh phù hợp`,heading1:`Tiêu đề 1`,heading2:`Tiêu đề 2`,heading3:`Tiêu đề 3`,bulletList:`Danh sách không thứ tự`,numberedList:`Danh sách có thứ tự`,checklist:`Danh sách công việc`,blockquote:`Trích dẫn`,codeBlock:`Khối mã`,horizontalRule:`Đường kẻ ngang`,table:`Bảng`,image:`Hình ảnh`}}),s(`ja`,{toolbar:{bold:`太字 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下線 (Ctrl+U)`,strikethrough:`取り消し線`,superscript:`上付き文字`,subscript:`下付き文字`,alignLeft:`左揃え`,alignCenter:`中央揃え`,alignRight:`右揃え`,alignJustify:`両端揃え`,ul:`箇条書きリスト`,ol:`番号付きリスト`,checklist:`チェックリスト`,indent:`インデントを増やす`,outdent:`インデントを減らす`,undo:`元に戻す (Ctrl+Z)`,redo:`やり直す (Ctrl+Y)`,hr:`水平線`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,emoji:`絵文字を挿入`,icon:`FAアイコンを挿入`,table:`テーブルを挿入`,fontSize:`フォントサイズ`,fontSizePlaceholder:`サイズ`,removeFormat:`書式をリセット`,direction:`文字方向を切り替え (LTR / RTL)`,fontFamily:`フォント`,paragraphStyle:`段落スタイル`,paragraphStylePlaceholder:`スタイル`,lineHeight:`行の高さ`,lineHeightPlaceholder:`↕ 行間`,codeview:`HTMLソースを表示`,fullscreen:`全画面表示`,shortcuts:`キーボードショートカット (Ctrl+Shift+/)`,find:`検索 (Ctrl+F)`,findReplace:`検索と置換 (Ctrl+H)`,inlineCode:"インラインコード (Ctrl+`)",print:`印刷`,foreColor:`文字色`,backColor:`ハイライト色`,chooseTextColor:`文字色を選択`,chooseHighlightColor:`ハイライト色を選択`,customColor:`カスタムカラー`,insertTableLabel:`テーブルを挿入`,paragraphItems:{p:`標準`,blockquote:`引用`,pre:`コード`}},linkDialog:{ariaLabel:`リンクを挿入`,title:`リンクを挿入`,url:`URL`,urlPlaceholder:`https://`,displayText:`表示テキスト`,textPlaceholder:`リンクテキスト`,openInNewTab:`新しいタブで開く`,insertBtn:`挿入`,cancelBtn:`キャンセル`},imageDialog:{ariaLabel:`画像を挿入`,title:`画像を挿入`,imageUrl:`画像URL`,urlPlaceholder:`https://example.com/image.png`,altText:`代替テキスト`,altPlaceholder:`画像の説明`,alignment:`配置`,alignNone:`なし`,alignLeft:`左`,alignCenter:`中央`,alignRight:`右`,uploadLabel:`ファイルをアップロード`,insertBtn:`挿入`,cancelBtn:`キャンセル`},videoDialog:{ariaLabel:`動画を挿入`,title:`動画を挿入`,videoUrl:`動画URL`,urlPlaceholder:`YouTube、Vimeo、または直接動画URL`,widthLabel:`幅 (px)`,widthPlaceholder:`560`,insertBtn:`挿入`,cancelBtn:`キャンセル`,detected:e=>`検出: ${e}`,unknownFormat:`不明な形式 — 直接動画埋め込みを試みます`,invalidUrl:`URLが無効です — 有効な動画URLを入力してください。`},emojiDialog:{ariaLabel:`絵文字を挿入`,title:`絵文字を挿入`,searchPlaceholder:`絵文字を検索…`,all:`すべて`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{smileys:`顔文字`,people:`人物`,animals:`動物`,food:`食べ物`,travel:`旅行`,objects:`モノ`,symbols:`記号`}},iconDialog:{ariaLabel:`FAアイコンを挿入`,title:`FAアイコンを挿入`,searchPlaceholder:`アイコンを検索…`,all:`すべて`,style:`スタイル`,size:`サイズ`,color:`カラー`,useColor:` カラーを使用`,selectHint:`アイコンを選択してください`,insertBtn:`FAアイコンを挿入`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{popular:`人気`,interface:`インターフェース`,navigation:`ナビゲーション`,media:`メディア`,communication:`通信`,files:`ファイル`,people:`人物`,objects:`モノ`}},findReplace:{findTitle:`検索`,findReplaceTitle:`検索と置換`,findPlaceholder:`検索…`,searchAriaLabel:`検索テキスト`,caseSensitive:`\xA0大文字/小文字を区別`,wholeWord:`単語単位`,prevBtn:`← 前へ`,nextBtn:`次へ →`,replacePlaceholder:`置換後…`,replaceAriaLabel:`置換後のテキスト`,replaceBtn:`置換`,noResults:`結果なし`,useRegex:`正規表現を使用`,replaceAllBtn:`すべて置換`,close:`×`},shortcutsDialog:{title:`キーボードショートカット`,ariaLabel:`キーボードショートカット`,close:`閉じる`,shortcuts:[{category:`テキスト書式`,items:[{keys:`Ctrl + B`,action:`太字`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下線`},{keys:`Ctrl + K`,action:`リンクの挿入 / 編集`}]},{category:`履歴`,items:[{keys:`Ctrl + Z`,action:`元に戻す`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`やり直す`}]},{category:`選択と移動`,items:[{keys:`Ctrl + A`,action:`すべて選択`},{keys:`Tab`,action:`インデント増加 / スペース挿入`},{keys:`Shift + Tab`,action:`インデント減少`}]},{category:`クリップボード`,items:[{keys:`Ctrl + Shift + V`,action:`プレーンテキストとして貼り付け`}]},{category:`検索と置換`,items:[{keys:`Ctrl + F`,action:`文書内を検索`},{keys:`Ctrl + H`,action:`検索と置換`}]},{category:`エディター`,items:[{keys:`Ctrl + Shift + /`,action:`ショートカットダイアログを表示`}]}]},contextMenu:{cut:`切り取り`,copy:`コピー`,paste:`貼り付け`,bold:`太字`,italic:`斜体`,underline:`下線`,textColor:`文字色`,highlightColor:`ハイライト色`,copyFormat:`書式をコピー`,pasteFormat:`書式を貼り付け`,removeFormat:`書式をリセット`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,table:`テーブルを挿入`,back:`戻る`,noHighlight:`ハイライトなし`,customColor:`カスタムカラー`,customColorLabel:`カスタム…`},statusbar:{resizeHandle:`ドラッグしてリサイズ`,words:e=>`単語数: ${e}`,wordsLimit:(e,t)=>`単語数: ${e}/${t}`,chars:e=>`文字数: ${e}`,charsLimit:(e,t)=>`文字数: ${e}/${t}`},tooltips:{link:{ariaLabel:`リンク操作`,openLink:`リンクを開く`,copyUrl:`URLをコピー`,editLink:`リンクを編集`,removeLink:`リンクを削除`},image:{ariaLabel:`画像操作`,label:`画像`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,rotateLeft:`左に回転`,rotateRight:`右に回転`,cropImage:`画像をトリミング`,addCaption:`キャプションを追加 / 編集`,deleteImage:`画像を削除`},code:{ariaLabel:`コードブロック操作`,label:`コード`,syntaxLanguage:`言語`,syntaxAriaLabel:`構文言語`,copyCode:`コードをコピー`,toggleWordWrap:`折り返しを切り替え`,enableWordWrap:`折り返しを有効にする`,disableWordWrap:`折り返しを無効にする`,convertToParagraph:`段落に変換`,deleteCodeBlock:`コードブロックを削除`,lineNumbers:`行番号を切り替え`},table:{ariaLabel:`テーブル操作`,label:`テーブル`,selectCells:`セルを選択`,addRowAbove:`上に行を追加`,addRowBelow:`下に行を追加`,deleteRow:`行を削除`,addColumnLeft:`左に列を追加`,addColumnRight:`右に列を追加`,deleteColumn:`列を削除`,mergeCells:`セルを結合`,unmergeCells:`セルの結合を解除`,columnWidth:`列幅`,rowHeight:`行の高さ`,tableBorderWidth:`テーブルの枠幅`,tableBorderColor:`テーブルの枠線色`,deleteTable:`テーブルを削除`,cellAlignLeft:`左揃え`,cellAlignCenter:`中央揃え`,cellAlignRight:`右揃え`,cellAlignJustify:`両端揃え`,toggleHeaderRow:`ヘッダー行の切り替え`,cellBackground:`セル背景色`,noShading:`背景色なし`,noBorderColor:`枠線色なし`,columnWidthPx:`列幅 (px)`,rowHeightPx:`行の高さ (px)`,tableBorderWidthPx:`テーブルの枠幅 (px)`,cancelBtn:`キャンセル`,applyBtn:`適用`,sortAsc:`昇順で並べ替え`,sortDesc:`降順で並べ替え`,exportCSV:`CSVとしてエクスポート`,cellPadding:`セルの余白`,cellPaddingPx:`セルの余白 (px)`},video:{ariaLabel:`動画操作`,label:`動画`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,previewVideo:`プレビュー`,exitPreview:`プレビューを終了`,deleteVideo:`動画を削除`}},errors:{imageFormat:e=>`形式 "${e}" はブラウザでの表示をサポートしていません。JPEG、PNG、または WebP に変換してください。`,imageSize:e=>`画像ファイルが大きすぎます。最大許容サイズは ${e} MB です。`},autoSaveRestore:{found:`下書きが見つかりました。復元しますか?`,foundAt:`{date} の下書きが見つかりました。復元しますか?`,restore:`復元`,discard:`破棄`},slashMenu:{noResults:`一致するコマンドがありません`,heading1:`見出し1`,heading2:`見出し2`,heading3:`見出し3`,bulletList:`箇条書きリスト`,numberedList:`番号付きリスト`,checklist:`チェックリスト`,blockquote:`引用`,codeBlock:`コードブロック`,horizontalRule:`水平線`,table:`表`,image:`画像`}}),s(`zh`,{toolbar:{bold:`粗体 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下划线 (Ctrl+U)`,strikethrough:`删除线`,superscript:`上标`,subscript:`下标`,alignLeft:`左对齐`,alignCenter:`居中`,alignRight:`右对齐`,alignJustify:`两端对齐`,ul:`无序列表`,ol:`有序列表`,checklist:`待办列表`,indent:`增加缩进`,outdent:`减少缩进`,undo:`撤销 (Ctrl+Z)`,redo:`重做 (Ctrl+Y)`,hr:`水平分割线`,link:`插入链接`,image:`插入图片`,video:`插入视频`,emoji:`插入表情`,icon:`插入 FA 图标`,table:`插入表格`,fontSize:`字号`,fontSizePlaceholder:`大小`,removeFormat:`清除格式`,direction:`切换文字方向 (LTR / RTL)`,fontFamily:`字体`,paragraphStyle:`段落样式`,paragraphStylePlaceholder:`样式`,lineHeight:`行高`,lineHeightPlaceholder:`↕ 行距`,codeview:`查看 HTML 源码`,fullscreen:`全屏`,shortcuts:`键盘快捷键 (Ctrl+Shift+/)`,find:`搜索 (Ctrl+F)`,findReplace:`查找和替换 (Ctrl+H)`,inlineCode:"行内代码 (Ctrl+`)",print:`打印`,foreColor:`文字颜色`,backColor:`高亮颜色`,chooseTextColor:`选择文字颜色`,chooseHighlightColor:`选择高亮颜色`,customColor:`自定义颜色`,insertTableLabel:`插入表格`,paragraphItems:{p:`正文`,blockquote:`引用`,pre:`代码`}},linkDialog:{ariaLabel:`插入链接`,title:`插入链接`,url:`链接地址`,urlPlaceholder:`https://`,displayText:`显示文字`,textPlaceholder:`链接文字`,openInNewTab:`在新标签页中打开`,insertBtn:`插入`,cancelBtn:`取消`},imageDialog:{ariaLabel:`插入图片`,title:`插入图片`,imageUrl:`图片地址`,urlPlaceholder:`https://example.com/image.png`,altText:`替代文字`,altPlaceholder:`图片描述`,alignment:`对齐方式`,alignNone:`无`,alignLeft:`左`,alignCenter:`居中`,alignRight:`右`,uploadLabel:`或上传文件`,insertBtn:`插入`,cancelBtn:`取消`},videoDialog:{ariaLabel:`插入视频`,title:`插入视频`,videoUrl:`视频地址`,urlPlaceholder:`YouTube、Vimeo 或直接 .mp4 链接`,widthLabel:`宽度 (px)`,widthPlaceholder:`560`,insertBtn:`插入`,cancelBtn:`取消`,detected:e=>`已识别: ${e}`,unknownFormat:`未知格式 — 将尝试直接嵌入视频`,invalidUrl:`URL 无效 — 请输入有效的视频链接。`},emojiDialog:{ariaLabel:`插入表情`,title:`插入表情`,searchPlaceholder:`搜索表情…`,all:`全部`,cancelBtn:`取消`,close:`关闭`,categories:{smileys:`笑脸`,people:`人物`,animals:`动物`,food:`食物`,travel:`旅行`,objects:`物品`,symbols:`符号`}},iconDialog:{ariaLabel:`插入 FA 图标`,title:`插入 FA 图标`,searchPlaceholder:`搜索图标…`,all:`全部`,style:`样式`,size:`大小`,color:`颜色`,useColor:` 使用颜色`,selectHint:`请选择一个图标`,insertBtn:`插入 FA 图标`,cancelBtn:`取消`,close:`关闭`,categories:{popular:`热门`,interface:`界面`,navigation:`导航`,media:`媒体`,communication:`通讯`,files:`文件`,people:`人物`,objects:`物品`}},findReplace:{findTitle:`搜索`,findReplaceTitle:`查找和替换`,findPlaceholder:`查找…`,searchAriaLabel:`搜索文字`,caseSensitive:`\xA0区分大小写`,wholeWord:`全字匹配`,prevBtn:`← 上一个`,nextBtn:`下一个 →`,replacePlaceholder:`替换为…`,replaceAriaLabel:`替换为`,replaceBtn:`替换`,noResults:`没有结果`,useRegex:`使用正则表达式`,replaceAllBtn:`全部替换`,close:`×`},shortcutsDialog:{title:`键盘快捷键`,ariaLabel:`键盘快捷键`,close:`关闭`,shortcuts:[{category:`文字格式`,items:[{keys:`Ctrl + B`,action:`粗体`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下划线`},{keys:`Ctrl + K`,action:`插入 / 编辑链接`}]},{category:`历史记录`,items:[{keys:`Ctrl + Z`,action:`撤销`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`重做`}]},{category:`选择与导航`,items:[{keys:`Ctrl + A`,action:`全选`},{keys:`Tab`,action:`增加缩进 / 插入空格`},{keys:`Shift + Tab`,action:`减少缩进`}]},{category:`剪贴板`,items:[{keys:`Ctrl + Shift + V`,action:`粘贴为纯文本`}]},{category:`查找和替换`,items:[{keys:`Ctrl + F`,action:`在文档中搜索`},{keys:`Ctrl + H`,action:`查找和替换`}]},{category:`编辑器`,items:[{keys:`Ctrl + Shift + /`,action:`显示快捷键对话框`}]}]},contextMenu:{cut:`剪切`,copy:`复制`,paste:`粘贴`,bold:`粗体`,italic:`斜体`,underline:`下划线`,textColor:`文字颜色`,highlightColor:`高亮颜色`,copyFormat:`复制格式`,pasteFormat:`粘贴格式`,removeFormat:`清除格式`,link:`插入链接`,image:`插入图片`,video:`插入视频`,table:`插入表格`,back:`返回`,noHighlight:`无高亮`,customColor:`自定义颜色`,customColorLabel:`自定义…`},statusbar:{resizeHandle:`拖动以调整大小`,words:e=>`字数: ${e}`,wordsLimit:(e,t)=>`字数: ${e}/${t}`,chars:e=>`字符数: ${e}`,charsLimit:(e,t)=>`字符数: ${e}/${t}`},tooltips:{link:{ariaLabel:`链接操作`,openLink:`打开链接`,copyUrl:`复制 URL`,editLink:`编辑链接`,removeLink:`删除链接`},image:{ariaLabel:`图片操作`,label:`图片`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,rotateLeft:`向左旋转`,rotateRight:`向右旋转`,cropImage:`裁剪图片`,addCaption:`添加 / 编辑说明`,deleteImage:`删除图片`},code:{ariaLabel:`代码块操作`,label:`代码`,syntaxLanguage:`语法语言`,syntaxAriaLabel:`语法语言`,copyCode:`复制代码`,toggleWordWrap:`切换自动换行`,enableWordWrap:`启用自动换行`,disableWordWrap:`禁用自动换行`,convertToParagraph:`转换为段落`,deleteCodeBlock:`删除代码块`,lineNumbers:`切换行号`},table:{ariaLabel:`表格操作`,label:`表格`,selectCells:`选择单元格`,addRowAbove:`在上方插入行`,addRowBelow:`在下方插入行`,deleteRow:`删除行`,addColumnLeft:`在左侧插入列`,addColumnRight:`在右侧插入列`,deleteColumn:`删除列`,mergeCells:`合并单元格`,unmergeCells:`拆分单元格`,columnWidth:`列宽`,rowHeight:`行高`,tableBorderWidth:`表格边框宽度`,tableBorderColor:`表格边框颜色`,deleteTable:`删除表格`,cellAlignLeft:`左对齐`,cellAlignCenter:`居中对齐`,cellAlignRight:`右对齐`,cellAlignJustify:`两端对齐`,toggleHeaderRow:`切换标题行`,cellBackground:`单元格背景`,noShading:`无底纹`,noBorderColor:`无边框颜色`,columnWidthPx:`列宽 (px)`,rowHeightPx:`行高 (px)`,tableBorderWidthPx:`表格边框宽度 (px)`,cancelBtn:`取消`,applyBtn:`应用`,sortAsc:`升序排列`,sortDesc:`降序排列`,exportCSV:`导出为 CSV`,cellPadding:`单元格内边距`,cellPaddingPx:`单元格内边距 (px)`},video:{ariaLabel:`视频操作`,label:`视频`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,previewVideo:`预览视频`,exitPreview:`退出预览`,deleteVideo:`删除视频`}},errors:{imageFormat:e=>`格式 "${e}" 不支持在浏览器中显示。请转换为 JPEG、PNG 或 WebP。`,imageSize:e=>`图片文件过大。最大允许大小为 ${e} MB。`},autoSaveRestore:{found:`找到草稿。是否恢复?`,foundAt:`发现 {date} 的草稿。是否恢复?`,restore:`恢复`,discard:`放弃`},slashMenu:{noResults:`没有匹配的命令`,heading1:`标题 1`,heading2:`标题 2`,heading3:`标题 3`,bulletList:`项目符号列表`,numberedList:`编号列表`,checklist:`检查清单`,blockquote:`引用`,codeBlock:`代码块`,horizontalRule:`水平线`,table:`表格`,image:`图片`}}),s(`fr`,{toolbar:{bold:`Gras (Ctrl+B)`,italic:`Italique (Ctrl+I)`,underline:`Souligné (Ctrl+U)`,strikethrough:`Barré`,superscript:`Exposant`,subscript:`Indice`,alignLeft:`Aligner à gauche`,alignCenter:`Centrer`,alignRight:`Aligner à droite`,alignJustify:`Justifier`,ul:`Liste à puces`,ol:`Liste numérotée`,checklist:`Liste de tâches`,indent:`Augmenter le retrait`,outdent:`Diminuer le retrait`,undo:`Annuler (Ctrl+Z)`,redo:`Rétablir (Ctrl+Y)`,hr:`Ligne horizontale`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,emoji:`Insérer un emoji`,icon:`Insérer une icône FA`,table:`Insérer un tableau`,fontSize:`Taille de police`,fontSizePlaceholder:`Taille`,removeFormat:`Effacer la mise en forme`,direction:`Basculer la direction du texte (LTR / RTL)`,fontFamily:`Police`,paragraphStyle:`Style de paragraphe`,paragraphStylePlaceholder:`Style`,lineHeight:`Interligne`,lineHeightPlaceholder:`↕ Ligne`,codeview:`Afficher le code HTML`,fullscreen:`Plein écran`,shortcuts:`Raccourcis clavier (Ctrl+Shift+/)`,find:`Rechercher (Ctrl+F)`,findReplace:`Rechercher et remplacer (Ctrl+H)`,inlineCode:"Code inline (Ctrl+`)",print:`Imprimer`,foreColor:`Couleur du texte`,backColor:`Couleur de surbrillance`,chooseTextColor:`Choisir la couleur du texte`,chooseHighlightColor:`Choisir la couleur de surbrillance`,customColor:`Couleur personnalisée`,insertTableLabel:`Insérer un tableau`,paragraphItems:{p:`Normal`,blockquote:`Citation`,pre:`Code`}},linkDialog:{ariaLabel:`Insérer un lien`,title:`Insérer un lien`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texte affiché`,textPlaceholder:`Texte du lien`,openInNewTab:`Ouvrir dans un nouvel onglet`,insertBtn:`Insérer`,cancelBtn:`Annuler`},imageDialog:{ariaLabel:`Insérer une image`,title:`Insérer une image`,imageUrl:`URL de l'image`,urlPlaceholder:`https://example.com/image.png`,altText:`Texte alternatif`,altPlaceholder:`Description de l'image`,alignment:`Alignement`,alignNone:`Aucun`,alignLeft:`Gauche`,alignCenter:`Centre`,alignRight:`Droite`,uploadLabel:`Ou téléverser un fichier`,insertBtn:`Insérer`,cancelBtn:`Annuler`},videoDialog:{ariaLabel:`Insérer une vidéo`,title:`Insérer une vidéo`,videoUrl:`URL de la vidéo`,urlPlaceholder:`YouTube, Vimeo ou URL .mp4 directe`,widthLabel:`Largeur (px)`,widthPlaceholder:`560`,insertBtn:`Insérer`,cancelBtn:`Annuler`,detected:e=>`Détecté\u00a0: ${e}`,unknownFormat:`Format inconnu — tentative d'intégration directe`,invalidUrl:`URL invalide — veuillez saisir un lien vidéo valide.`},emojiDialog:{ariaLabel:`Insérer un emoji`,title:`Insérer un emoji`,searchPlaceholder:`Rechercher des emojis…`,all:`Tout`,cancelBtn:`Annuler`,close:`Fermer`,categories:{smileys:`Smileys`,people:`Personnes`,animals:`Animaux`,food:`Nourriture`,travel:`Voyage`,objects:`Objets`,symbols:`Symboles`}},iconDialog:{ariaLabel:`Insérer une icône FA`,title:`Insérer une icône FA`,searchPlaceholder:`Rechercher des icônes…`,all:`Tout`,style:`Style`,size:`Taille`,color:`Couleur`,useColor:` Utiliser la couleur`,selectHint:`Sélectionner une icône`,insertBtn:`Insérer une icône FA`,cancelBtn:`Annuler`,close:`Fermer`,categories:{popular:`Populaire`,interface:`Interface`,navigation:`Navigation`,media:`Média`,communication:`Communication`,files:`Fichiers`,people:`Personnes`,objects:`Objets`}},findReplace:{findTitle:`Rechercher`,findReplaceTitle:`Rechercher et remplacer`,findPlaceholder:`Rechercher…`,searchAriaLabel:`Texte à rechercher`,caseSensitive:`\xA0Respecter la casse`,wholeWord:`Mot entier`,prevBtn:`← Préc.`,nextBtn:`Suiv. →`,replacePlaceholder:`Remplacer par…`,replaceAriaLabel:`Remplacer par`,replaceBtn:`Remplacer`,noResults:`Aucun résultat`,useRegex:`Utiliser une expression régulière`,replaceAllBtn:`Tout remplacer`,close:`×`},shortcutsDialog:{title:`Raccourcis clavier`,ariaLabel:`Raccourcis clavier`,close:`Fermer`,shortcuts:[{category:`Mise en forme du texte`,items:[{keys:`Ctrl + B`,action:`Gras`},{keys:`Ctrl + I`,action:`Italique`},{keys:`Ctrl + U`,action:`Souligné`},{keys:`Ctrl + K`,action:`Insérer / modifier un lien`}]},{category:`Historique`,items:[{keys:`Ctrl + Z`,action:`Annuler`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rétablir`}]},{category:`Sélection et navigation`,items:[{keys:`Ctrl + A`,action:`Tout sélectionner`},{keys:`Tab`,action:`Augmenter le retrait / insérer des espaces`},{keys:`Shift + Tab`,action:`Diminuer le retrait`}]},{category:`Presse-papiers`,items:[{keys:`Ctrl + Shift + V`,action:`Coller en texte brut`}]},{category:`Rechercher et remplacer`,items:[{keys:`Ctrl + F`,action:`Rechercher dans le document`},{keys:`Ctrl + H`,action:`Rechercher et remplacer`}]},{category:`Éditeur`,items:[{keys:`Ctrl + Shift + /`,action:`Afficher les raccourcis clavier`}]}]},contextMenu:{cut:`Couper`,copy:`Copier`,paste:`Coller`,bold:`Gras`,italic:`Italique`,underline:`Souligné`,textColor:`Couleur du texte`,highlightColor:`Couleur de surbrillance`,copyFormat:`Copier la mise en forme`,pasteFormat:`Coller la mise en forme`,removeFormat:`Effacer la mise en forme`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,table:`Insérer un tableau`,back:`Retour`,noHighlight:`Sans surbrillance`,customColor:`Couleur personnalisée`,customColorLabel:`Personnaliser…`},statusbar:{resizeHandle:`Faire glisser pour redimensionner`,words:e=>`Mots\u00a0: ${e}`,wordsLimit:(e,t)=>`Mots\u00a0: ${e}/${t}`,chars:e=>`Caractères\u00a0: ${e}`,charsLimit:(e,t)=>`Caractères\u00a0: ${e}/${t}`},tooltips:{link:{ariaLabel:`Actions du lien`,openLink:`Ouvrir le lien`,copyUrl:`Copier l'URL`,editLink:`Modifier le lien`,removeLink:`Supprimer le lien`},image:{ariaLabel:`Actions de l'image`,label:`Image`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,rotateLeft:`Rotation à gauche`,rotateRight:`Rotation à droite`,cropImage:`Recadrer l'image`,addCaption:`Ajouter / modifier la légende`,deleteImage:`Supprimer l'image`},code:{ariaLabel:`Actions du bloc de code`,label:`Code`,syntaxLanguage:`Langage de syntaxe`,syntaxAriaLabel:`Langage de syntaxe`,copyCode:`Copier le code`,toggleWordWrap:`Activer/désactiver le retour à la ligne`,enableWordWrap:`Activer le retour à la ligne`,disableWordWrap:`Désactiver le retour à la ligne`,convertToParagraph:`Convertir en paragraphe`,deleteCodeBlock:`Supprimer le bloc de code`,lineNumbers:`Activer/désactiver les numéros de ligne`},table:{ariaLabel:`Actions du tableau`,label:`Tableau`,selectCells:`Sélectionner des cellules`,addRowAbove:`Ajouter une ligne au-dessus`,addRowBelow:`Ajouter une ligne en-dessous`,deleteRow:`Supprimer la ligne`,addColumnLeft:`Ajouter une colonne à gauche`,addColumnRight:`Ajouter une colonne à droite`,deleteColumn:`Supprimer la colonne`,mergeCells:`Fusionner les cellules`,unmergeCells:`Scinder les cellules`,columnWidth:`Largeur de colonne`,rowHeight:`Hauteur de ligne`,tableBorderWidth:`Épaisseur des bordures`,tableBorderColor:`Couleur de bordure`,deleteTable:`Supprimer le tableau`,cellAlignLeft:`Aligner à gauche`,cellAlignCenter:`Centrer`,cellAlignRight:`Aligner à droite`,cellAlignJustify:`Justifier`,toggleHeaderRow:`Ligne d'en-tête`,cellBackground:`Couleur de fond`,noShading:`Aucun fond`,noBorderColor:`Aucune bordure`,columnWidthPx:`Largeur de colonne (px)`,rowHeightPx:`Hauteur de ligne (px)`,tableBorderWidthPx:`Épaisseur des bordures (px)`,cancelBtn:`Annuler`,applyBtn:`Appliquer`,sortAsc:`Trier par ordre croissant`,sortDesc:`Trier par ordre décroissant`,exportCSV:`Exporter en CSV`,cellPadding:`Rembourrage des cellules`,cellPaddingPx:`Rembourrage des cellules (px)`},video:{ariaLabel:`Actions de la vidéo`,label:`Vidéo`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,previewVideo:`Aperçu`,exitPreview:`Quitter l'aperçu`,deleteVideo:`Supprimer la vidéo`}},errors:{imageFormat:e=>`Le format "${e}" n'est pas pris en charge par le navigateur. Veuillez le convertir en JPEG, PNG ou WebP.`,imageSize:e=>`Le fichier image est trop volumineux. La taille maximale autorisée est de ${e}\u00a0Mo.`},autoSaveRestore:{found:`Brouillon trouvé. Restaurer ?`,foundAt:`Brouillon du {date}. Restaurer ?`,restore:`Restaurer`,discard:`Ignorer`},slashMenu:{noResults:`Aucune commande correspondante`,heading1:`Titre 1`,heading2:`Titre 2`,heading3:`Titre 3`,bulletList:`Liste à puces`,numberedList:`Liste numérotée`,checklist:`Liste de contrôle`,blockquote:`Citation`,codeBlock:`Bloc de code`,horizontalRule:`Ligne horizontale`,table:`Tableau`,image:`Image`}}),s(`de`,{toolbar:{bold:`Fett (Ctrl+B)`,italic:`Kursiv (Ctrl+I)`,underline:`Unterstrichen (Ctrl+U)`,strikethrough:`Durchgestrichen`,superscript:`Hochgestellt`,subscript:`Tiefgestellt`,alignLeft:`Linksbündig`,alignCenter:`Zentriert`,alignRight:`Rechtsbündig`,alignJustify:`Blocksatz`,ul:`Ungeordnete Liste`,ol:`Geordnete Liste`,checklist:`Checkliste`,indent:`Einzug vergrößern`,outdent:`Einzug verkleinern`,undo:`Rückgängig (Ctrl+Z)`,redo:`Wiederholen (Ctrl+Y)`,hr:`Horizontale Linie`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,emoji:`Emoji einfügen`,icon:`FA-Symbol einfügen`,table:`Tabelle einfügen`,fontSize:`Schriftgröße`,fontSizePlaceholder:`Größe`,removeFormat:`Formatierung entfernen`,direction:`Textrichtung umschalten (LTR / RTL)`,fontFamily:`Schriftart`,paragraphStyle:`Absatzstil`,paragraphStylePlaceholder:`Stil`,lineHeight:`Zeilenhöhe`,lineHeightPlaceholder:`↕ Zeile`,codeview:`HTML-Code-Ansicht`,fullscreen:`Vollbild`,shortcuts:`Tastenkürzel (Ctrl+Shift+/)`,find:`Suchen (Ctrl+F)`,findReplace:`Suchen & Ersetzen (Ctrl+H)`,inlineCode:"Inline-Code (Ctrl+`)",print:`Drucken`,foreColor:`Textfarbe`,backColor:`Hervorhebungsfarbe`,chooseTextColor:`Textfarbe auswählen`,chooseHighlightColor:`Hervorhebungsfarbe auswählen`,customColor:`Benutzerdefinierte Farbe`,insertTableLabel:`Tabelle einfügen`,paragraphItems:{p:`Normal`,blockquote:`Zitat`,pre:`Code`}},linkDialog:{ariaLabel:`Link einfügen`,title:`Link einfügen`,url:`URL`,urlPlaceholder:`https://`,displayText:`Anzeigetext`,textPlaceholder:`Linktext`,openInNewTab:`In neuem Tab öffnen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},imageDialog:{ariaLabel:`Bild einfügen`,title:`Bild einfügen`,imageUrl:`Bild-URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt-Text`,altPlaceholder:`Bild beschreiben`,alignment:`Ausrichtung`,alignNone:`Keine`,alignLeft:`Links`,alignCenter:`Mitte`,alignRight:`Rechts`,uploadLabel:`Oder Datei hochladen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},videoDialog:{ariaLabel:`Video einfügen`,title:`Video einfügen`,videoUrl:`Video-URL`,urlPlaceholder:`YouTube, Vimeo oder direkte .mp4-URL`,widthLabel:`Breite (px)`,widthPlaceholder:`560`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`,detected:e=>`Erkannt: ${e}`,unknownFormat:`Unbekanntes Format — direktes Video-Einbetten wird versucht`,invalidUrl:`Ungültige URL — bitte geben Sie einen gültigen Videolink ein.`},emojiDialog:{ariaLabel:`Emoji einfügen`,title:`Emoji einfügen`,searchPlaceholder:`Emojis suchen…`,all:`Alle`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{smileys:`Smileys`,people:`Menschen`,animals:`Tiere`,food:`Essen`,travel:`Reisen`,objects:`Objekte`,symbols:`Symbole`}},iconDialog:{ariaLabel:`FA-Symbol einfügen`,title:`FA-Symbol einfügen`,searchPlaceholder:`Symbole suchen…`,all:`Alle`,style:`Stil`,size:`Größe`,color:`Farbe`,useColor:` Farbe verwenden`,selectHint:`Symbol auswählen`,insertBtn:`FA-Symbol einfügen`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{popular:`Beliebt`,interface:`Benutzeroberfläche`,navigation:`Navigation`,media:`Medien`,communication:`Kommunikation`,files:`Dateien`,people:`Menschen`,objects:`Objekte`}},findReplace:{findTitle:`Suchen`,findReplaceTitle:`Suchen & Ersetzen`,findPlaceholder:`Suchen…`,searchAriaLabel:`Suchtext`,caseSensitive:`\xA0Groß-/Kleinschreibung`,wholeWord:`Ganzes Wort`,prevBtn:`← Zurück`,nextBtn:`Weiter →`,replacePlaceholder:`Ersetzen durch…`,replaceAriaLabel:`Ersetzen durch`,replaceBtn:`Ersetzen`,noResults:`Keine Ergebnisse`,useRegex:`Regulären Ausdruck verwenden`,replaceAllBtn:`Alle ersetzen`,close:`×`},shortcutsDialog:{title:`Tastenkürzel`,ariaLabel:`Tastenkürzel`,close:`Schließen`,shortcuts:[{category:`Textformatierung`,items:[{keys:`Ctrl + B`,action:`Fett`},{keys:`Ctrl + I`,action:`Kursiv`},{keys:`Ctrl + U`,action:`Unterstrichen`},{keys:`Ctrl + K`,action:`Link einfügen / bearbeiten`}]},{category:`Verlauf`,items:[{keys:`Ctrl + Z`,action:`Rückgängig`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Wiederholen`}]},{category:`Auswahl & Navigation`,items:[{keys:`Ctrl + A`,action:`Alles auswählen`},{keys:`Tab`,action:`Listenebene erhöhen / Leerzeichen einfügen`},{keys:`Shift + Tab`,action:`Listenebene verringern`}]},{category:`Zwischenablage`,items:[{keys:`Ctrl + Shift + V`,action:`Als einfachen Text einfügen`}]},{category:`Suchen & Ersetzen`,items:[{keys:`Ctrl + F`,action:`Im Dokument suchen`},{keys:`Ctrl + H`,action:`Suchen & Ersetzen`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Diesen Tastenkürzel-Dialog anzeigen`}]}]},contextMenu:{cut:`Ausschneiden`,copy:`Kopieren`,paste:`Einfügen`,bold:`Fett`,italic:`Kursiv`,underline:`Unterstrichen`,textColor:`Textfarbe`,highlightColor:`Hervorhebungsfarbe`,copyFormat:`Format kopieren`,pasteFormat:`Format einfügen`,removeFormat:`Formatierung entfernen`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,table:`Tabelle einfügen`,back:`Zurück`,noHighlight:`Keine Hervorhebung`,customColor:`Benutzerdefinierte Farbe`,customColorLabel:`Benutzerdefiniert…`},statusbar:{resizeHandle:`Editor-Größe ändern`,words:e=>`Wörter: ${e}`,wordsLimit:(e,t)=>`Wörter: ${e}/${t}`,chars:e=>`Zeichen: ${e}`,charsLimit:(e,t)=>`Zeichen: ${e}/${t}`},tooltips:{link:{ariaLabel:`Link-Aktionen`,openLink:`Link öffnen`,copyUrl:`URL kopieren`,editLink:`Link bearbeiten`,removeLink:`Link entfernen`},image:{ariaLabel:`Bild-Aktionen`,label:`Bild`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,rotateLeft:`Links drehen`,rotateRight:`Rechts drehen`,cropImage:`Bild zuschneiden`,addCaption:`Beschriftung hinzufügen / bearbeiten`,deleteImage:`Bild löschen`},code:{ariaLabel:`Codeblock-Aktionen`,label:`Code`,syntaxLanguage:`Syntaxsprache`,syntaxAriaLabel:`Syntaxsprache`,copyCode:`Code kopieren`,toggleWordWrap:`Zeilenumbruch umschalten`,enableWordWrap:`Zeilenumbruch aktivieren`,disableWordWrap:`Zeilenumbruch deaktivieren`,convertToParagraph:`In Absatz umwandeln`,deleteCodeBlock:`Codeblock löschen`,lineNumbers:`Zeilennummern umschalten`},table:{ariaLabel:`Tabellen-Aktionen`,label:`Tabelle`,selectCells:`Zellen auswählen`,addRowAbove:`Zeile oben hinzufügen`,addRowBelow:`Zeile unten hinzufügen`,deleteRow:`Zeile löschen`,addColumnLeft:`Spalte links hinzufügen`,addColumnRight:`Spalte rechts hinzufügen`,deleteColumn:`Spalte löschen`,mergeCells:`Zellen zusammenführen`,unmergeCells:`Zellen trennen`,columnWidth:`Spaltenbreite`,rowHeight:`Zeilenhöhe`,tableBorderWidth:`Tabellenrahmenbreite`,tableBorderColor:`Tabellenrahmenfarbe`,deleteTable:`Tabelle löschen`,cellAlignLeft:`Linksbündig`,cellAlignCenter:`Zentrieren`,cellAlignRight:`Rechtsbündig`,cellAlignJustify:`Blocksatz`,toggleHeaderRow:`Kopfzeile umschalten`,cellBackground:`Zellhintergrund`,noShading:`Kein Hintergrund`,noBorderColor:`Keine Rahmenfarbe`,columnWidthPx:`Spaltenbreite (px)`,rowHeightPx:`Zeilenhöhe (px)`,tableBorderWidthPx:`Tabellenrahmenbreite (px)`,cancelBtn:`Abbrechen`,applyBtn:`Anwenden`,sortAsc:`Aufsteigend sortieren`,sortDesc:`Absteigend sortieren`,exportCSV:`Als CSV exportieren`,cellPadding:`Zellauffüllung`,cellPaddingPx:`Zellauffüllung (px)`},video:{ariaLabel:`Video-Aktionen`,label:`Video`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,previewVideo:`Video-Vorschau`,exitPreview:`Vorschau beenden`,deleteVideo:`Video löschen`}},errors:{imageFormat:e=>`Das Format „${e}" wird in Webbrowsern nicht unterstützt. Bitte konvertieren Sie es zuerst in JPEG, PNG oder WebP.`,imageSize:e=>`Die Bilddatei ist zu groß. Die maximal zulässige Größe beträgt ${e} MB.`},autoSaveRestore:{found:`Entwurf gefunden. Wiederherstellen?`,foundAt:`Entwurf vom {date}. Wiederherstellen?`,restore:`Wiederherstellen`,discard:`Verwerfen`},slashMenu:{noResults:`Keine passenden Befehle`,heading1:`Überschrift 1`,heading2:`Überschrift 2`,heading3:`Überschrift 3`,bulletList:`Aufzählungsliste`,numberedList:`Nummerierte Liste`,checklist:`Checkliste`,blockquote:`Zitat`,codeBlock:`Codeblock`,horizontalRule:`Horizontale Linie`,table:`Tabelle`,image:`Bild`}}),s(`es`,{toolbar:{bold:`Negrita (Ctrl+B)`,italic:`Cursiva (Ctrl+I)`,underline:`Subrayado (Ctrl+U)`,strikethrough:`Tachado`,superscript:`Superíndice`,subscript:`Subíndice`,alignLeft:`Alinear a la izquierda`,alignCenter:`Centrar`,alignRight:`Alinear a la derecha`,alignJustify:`Justificar`,ul:`Lista sin orden`,ol:`Lista ordenada`,checklist:`Lista de verificación`,indent:`Aumentar sangría`,outdent:`Reducir sangría`,undo:`Deshacer (Ctrl+Z)`,redo:`Rehacer (Ctrl+Y)`,hr:`Línea horizontal`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,emoji:`Insertar emoji`,icon:`Insertar icono FA`,table:`Insertar tabla`,fontSize:`Tamaño de fuente`,fontSizePlaceholder:`Tamaño`,removeFormat:`Eliminar formato`,direction:`Cambiar dirección del texto (LTR / RTL)`,fontFamily:`Fuente`,paragraphStyle:`Estilo de párrafo`,paragraphStylePlaceholder:`Estilo`,lineHeight:`Interlineado`,lineHeightPlaceholder:`↕ Línea`,codeview:`Vista de código HTML`,fullscreen:`Pantalla completa`,shortcuts:`Atajos de teclado (Ctrl+Shift+/)`,find:`Buscar (Ctrl+F)`,findReplace:`Buscar y reemplazar (Ctrl+H)`,inlineCode:"Código en línea (Ctrl+`)",print:`Imprimir`,foreColor:`Color del texto`,backColor:`Color de resaltado`,chooseTextColor:`Elegir color del texto`,chooseHighlightColor:`Elegir color de resaltado`,customColor:`Color personalizado`,insertTableLabel:`Insertar tabla`,paragraphItems:{p:`Normal`,blockquote:`Cita`,pre:`Código`}},linkDialog:{ariaLabel:`Insertar enlace`,title:`Insertar enlace`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texto a mostrar`,textPlaceholder:`Texto del enlace`,openInNewTab:`Abrir en nueva pestaña`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},imageDialog:{ariaLabel:`Insertar imagen`,title:`Insertar imagen`,imageUrl:`URL de imagen`,urlPlaceholder:`https://example.com/image.png`,altText:`Texto alternativo`,altPlaceholder:`Describir la imagen`,alignment:`Alineación`,alignNone:`Ninguna`,alignLeft:`Izquierda`,alignCenter:`Centro`,alignRight:`Derecha`,uploadLabel:`O subir un archivo`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},videoDialog:{ariaLabel:`Insertar vídeo`,title:`Insertar vídeo`,videoUrl:`URL del vídeo`,urlPlaceholder:`YouTube, Vimeo o URL directa .mp4`,widthLabel:`Ancho (px)`,widthPlaceholder:`560`,insertBtn:`Insertar`,cancelBtn:`Cancelar`,detected:e=>`Detectado: ${e}`,unknownFormat:`Formato desconocido — se intentará incrustar el vídeo directamente`,invalidUrl:`URL no válida — introduzca un enlace de vídeo válido.`},emojiDialog:{ariaLabel:`Insertar emoji`,title:`Insertar emoji`,searchPlaceholder:`Buscar emojis…`,all:`Todos`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{smileys:`Caritas`,people:`Personas`,animals:`Animales`,food:`Comida`,travel:`Viajes`,objects:`Objetos`,symbols:`Símbolos`}},iconDialog:{ariaLabel:`Insertar icono FA`,title:`Insertar icono FA`,searchPlaceholder:`Buscar iconos…`,all:`Todos`,style:`Estilo`,size:`Tamaño`,color:`Color`,useColor:` Usar color`,selectHint:`Seleccionar un icono`,insertBtn:`Insertar icono FA`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{popular:`Popular`,interface:`Interfaz`,navigation:`Navegación`,media:`Medios`,communication:`Comunicación`,files:`Archivos`,people:`Personas`,objects:`Objetos`}},findReplace:{findTitle:`Buscar`,findReplaceTitle:`Buscar y reemplazar`,findPlaceholder:`Buscar…`,searchAriaLabel:`Texto de búsqueda`,caseSensitive:`\xA0Distinguir mayúsculas`,wholeWord:`Palabra completa`,prevBtn:`← Anterior`,nextBtn:`Siguiente →`,replacePlaceholder:`Reemplazar con…`,replaceAriaLabel:`Reemplazar con`,replaceBtn:`Reemplazar`,noResults:`Sin resultados`,useRegex:`Usar expresión regular`,replaceAllBtn:`Reemplazar todo`,close:`×`},shortcutsDialog:{title:`Atajos de teclado`,ariaLabel:`Atajos de teclado`,close:`Cerrar`,shortcuts:[{category:`Formato de texto`,items:[{keys:`Ctrl + B`,action:`Negrita`},{keys:`Ctrl + I`,action:`Cursiva`},{keys:`Ctrl + U`,action:`Subrayado`},{keys:`Ctrl + K`,action:`Insertar / editar enlace`}]},{category:`Historial`,items:[{keys:`Ctrl + Z`,action:`Deshacer`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rehacer`}]},{category:`Selección y navegación`,items:[{keys:`Ctrl + A`,action:`Seleccionar todo`},{keys:`Tab`,action:`Aumentar sangría / insertar espacios`},{keys:`Shift + Tab`,action:`Reducir sangría`}]},{category:`Portapapeles`,items:[{keys:`Ctrl + Shift + V`,action:`Pegar como texto plano`}]},{category:`Buscar y reemplazar`,items:[{keys:`Ctrl + F`,action:`Buscar en el documento`},{keys:`Ctrl + H`,action:`Buscar y reemplazar`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Mostrar este diálogo de atajos`}]}]},contextMenu:{cut:`Cortar`,copy:`Copiar`,paste:`Pegar`,bold:`Negrita`,italic:`Cursiva`,underline:`Subrayado`,textColor:`Color del texto`,highlightColor:`Color de resaltado`,copyFormat:`Copiar formato`,pasteFormat:`Pegar formato`,removeFormat:`Eliminar formato`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,table:`Insertar tabla`,back:`Atrás`,noHighlight:`Sin resaltado`,customColor:`Color personalizado`,customColorLabel:`Personalizado…`},statusbar:{resizeHandle:`Redimensionar editor`,words:e=>`Palabras: ${e}`,wordsLimit:(e,t)=>`Palabras: ${e}/${t}`,chars:e=>`Caracteres: ${e}`,charsLimit:(e,t)=>`Caracteres: ${e}/${t}`},tooltips:{link:{ariaLabel:`Acciones de enlace`,openLink:`Abrir enlace`,copyUrl:`Copiar URL`,editLink:`Editar enlace`,removeLink:`Eliminar enlace`},image:{ariaLabel:`Acciones de imagen`,label:`Imagen`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,rotateLeft:`Rotar a la izquierda`,rotateRight:`Rotar a la derecha`,cropImage:`Recortar imagen`,addCaption:`Añadir / editar pie de foto`,deleteImage:`Eliminar imagen`},code:{ariaLabel:`Acciones de bloque de código`,label:`Código`,syntaxLanguage:`Lenguaje de sintaxis`,syntaxAriaLabel:`Lenguaje de sintaxis`,copyCode:`Copiar código`,toggleWordWrap:`Alternar ajuste de línea`,enableWordWrap:`Activar ajuste de línea`,disableWordWrap:`Desactivar ajuste de línea`,convertToParagraph:`Convertir en párrafo`,deleteCodeBlock:`Eliminar bloque de código`,lineNumbers:`Alternar números de línea`},table:{ariaLabel:`Acciones de tabla`,label:`Tabla`,selectCells:`Seleccionar celdas`,addRowAbove:`Añadir fila encima`,addRowBelow:`Añadir fila debajo`,deleteRow:`Eliminar fila`,addColumnLeft:`Añadir columna a la izquierda`,addColumnRight:`Añadir columna a la derecha`,deleteColumn:`Eliminar columna`,mergeCells:`Combinar celdas`,unmergeCells:`Separar celdas`,columnWidth:`Ancho de columna`,rowHeight:`Alto de fila`,tableBorderWidth:`Grosor del borde de la tabla`,tableBorderColor:`Color del borde de la tabla`,deleteTable:`Eliminar tabla`,cellAlignLeft:`Alinear a la izquierda`,cellAlignCenter:`Centrar`,cellAlignRight:`Alinear a la derecha`,cellAlignJustify:`Justificar`,toggleHeaderRow:`Activar fila de encabezado`,cellBackground:`Fondo de celda`,noShading:`Sin fondo`,noBorderColor:`Sin color de borde`,columnWidthPx:`Ancho de columna (px)`,rowHeightPx:`Alto de fila (px)`,tableBorderWidthPx:`Grosor del borde (px)`,cancelBtn:`Cancelar`,applyBtn:`Aplicar`,sortAsc:`Ordenar ascendente`,sortDesc:`Ordenar descendente`,exportCSV:`Exportar como CSV`,cellPadding:`Relleno de celda`,cellPaddingPx:`Relleno de celda (px)`},video:{ariaLabel:`Acciones de vídeo`,label:`Vídeo`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,previewVideo:`Vista previa de vídeo`,exitPreview:`Salir de la vista previa`,deleteVideo:`Eliminar vídeo`}},errors:{imageFormat:e=>`El formato "${e}" no es compatible con los navegadores web. Por favor, conviértalo primero a JPEG, PNG o WebP.`,imageSize:e=>`El archivo de imagen es demasiado grande. El tamaño máximo permitido es ${e} MB.`},autoSaveRestore:{found:`Borrador encontrado. ¿Restaurar?`,foundAt:`Borrador del {date}. ¿Restaurar?`,restore:`Restaurar`,discard:`Descartar`},slashMenu:{noResults:`No hay comandos coincidentes`,heading1:`Encabezado 1`,heading2:`Encabezado 2`,heading3:`Encabezado 3`,bulletList:`Lista con viñetas`,numberedList:`Lista numerada`,checklist:`Lista de verificación`,blockquote:`Cita`,codeBlock:`Bloque de código`,horizontalRule:`Línea horizontal`,table:`Tabla`,image:`Imagen`}}),s(`ko`,{toolbar:{bold:`굵게 (Ctrl+B)`,italic:`기울임꼴 (Ctrl+I)`,underline:`밑줄 (Ctrl+U)`,strikethrough:`취소선`,superscript:`위 첨자`,subscript:`아래 첨자`,alignLeft:`왼쪽 정렬`,alignCenter:`가운데 정렬`,alignRight:`오른쪽 정렬`,alignJustify:`양쪽 정렬`,ul:`순서 없는 목록`,ol:`순서 있는 목록`,checklist:`체크리스트`,indent:`들여쓰기`,outdent:`내어쓰기`,undo:`실행 취소 (Ctrl+Z)`,redo:`다시 실행 (Ctrl+Y)`,hr:`수평선`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,emoji:`이모지 삽입`,icon:`FA 아이콘 삽입`,table:`표 삽입`,fontSize:`글꼴 크기`,fontSizePlaceholder:`크기`,removeFormat:`서식 제거`,direction:`텍스트 방향 전환 (LTR / RTL)`,fontFamily:`글꼴`,paragraphStyle:`단락 스타일`,paragraphStylePlaceholder:`스타일`,lineHeight:`줄 간격`,lineHeightPlaceholder:`↕ 줄`,codeview:`HTML 코드 보기`,fullscreen:`전체 화면`,shortcuts:`키보드 단축키 (Ctrl+Shift+/)`,find:`찾기 (Ctrl+F)`,findReplace:`찾기 및 바꾸기 (Ctrl+H)`,inlineCode:"인라인 코드 (Ctrl+`)",print:`인쇄`,foreColor:`글자 색`,backColor:`강조 색`,chooseTextColor:`글자 색 선택`,chooseHighlightColor:`강조 색 선택`,customColor:`사용자 지정 색`,insertTableLabel:`표 삽입`,paragraphItems:{p:`기본`,blockquote:`인용`,pre:`코드`}},linkDialog:{ariaLabel:`링크 삽입`,title:`링크 삽입`,url:`URL`,urlPlaceholder:`https://`,displayText:`표시 텍스트`,textPlaceholder:`링크 텍스트`,openInNewTab:`새 탭에서 열기`,insertBtn:`삽입`,cancelBtn:`취소`},imageDialog:{ariaLabel:`이미지 삽입`,title:`이미지 삽입`,imageUrl:`이미지 URL`,urlPlaceholder:`https://example.com/image.png`,altText:`대체 텍스트`,altPlaceholder:`이미지 설명`,alignment:`정렬`,alignNone:`없음`,alignLeft:`왼쪽`,alignCenter:`가운데`,alignRight:`오른쪽`,uploadLabel:`또는 파일 업로드`,insertBtn:`삽입`,cancelBtn:`취소`},videoDialog:{ariaLabel:`동영상 삽입`,title:`동영상 삽입`,videoUrl:`동영상 URL`,urlPlaceholder:`YouTube, Vimeo 또는 직접 .mp4 URL`,widthLabel:`너비 (px)`,widthPlaceholder:`560`,insertBtn:`삽입`,cancelBtn:`취소`,detected:e=>`감지됨: ${e}`,unknownFormat:`알 수 없는 형식 — 직접 동영상 임베드를 시도합니다`,invalidUrl:`유효하지 않은 URL — 올바른 동영상 링크를 입력하세요.`},emojiDialog:{ariaLabel:`이모지 삽입`,title:`이모지 삽입`,searchPlaceholder:`이모지 검색…`,all:`전체`,cancelBtn:`취소`,close:`닫기`,categories:{smileys:`스마일`,people:`사람`,animals:`동물`,food:`음식`,travel:`여행`,objects:`사물`,symbols:`기호`}},iconDialog:{ariaLabel:`FA 아이콘 삽입`,title:`FA 아이콘 삽입`,searchPlaceholder:`아이콘 검색…`,all:`전체`,style:`스타일`,size:`크기`,color:`색상`,useColor:` 색상 사용`,selectHint:`아이콘을 선택하세요`,insertBtn:`FA 아이콘 삽입`,cancelBtn:`취소`,close:`닫기`,categories:{popular:`인기`,interface:`인터페이스`,navigation:`탐색`,media:`미디어`,communication:`커뮤니케이션`,files:`파일`,people:`사람`,objects:`사물`}},findReplace:{findTitle:`찾기`,findReplaceTitle:`찾기 및 바꾸기`,findPlaceholder:`찾기…`,searchAriaLabel:`검색 텍스트`,caseSensitive:`\xA0대소문자 구분`,wholeWord:`전체 단어`,prevBtn:`← 이전`,nextBtn:`다음 →`,replacePlaceholder:`바꿀 내용…`,replaceAriaLabel:`바꿀 내용`,replaceBtn:`바꾸기`,noResults:`결과 없음`,useRegex:`정규식 사용`,replaceAllBtn:`모두 바꾸기`,close:`×`},shortcutsDialog:{title:`키보드 단축키`,ariaLabel:`키보드 단축키`,close:`닫기`,shortcuts:[{category:`텍스트 서식`,items:[{keys:`Ctrl + B`,action:`굵게`},{keys:`Ctrl + I`,action:`기울임꼴`},{keys:`Ctrl + U`,action:`밑줄`},{keys:`Ctrl + K`,action:`링크 삽입 / 편집`}]},{category:`실행 기록`,items:[{keys:`Ctrl + Z`,action:`실행 취소`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`다시 실행`}]},{category:`선택 및 탐색`,items:[{keys:`Ctrl + A`,action:`전체 선택`},{keys:`Tab`,action:`목록 들여쓰기 / 공백 삽입`},{keys:`Shift + Tab`,action:`목록 내어쓰기`}]},{category:`클립보드`,items:[{keys:`Ctrl + Shift + V`,action:`일반 텍스트로 붙여넣기`}]},{category:`찾기 및 바꾸기`,items:[{keys:`Ctrl + F`,action:`문서에서 찾기`},{keys:`Ctrl + H`,action:`찾기 및 바꾸기`}]},{category:`편집기`,items:[{keys:`Ctrl + Shift + /`,action:`이 단축키 대화상자 표시`}]}]},contextMenu:{cut:`잘라내기`,copy:`복사`,paste:`붙여넣기`,bold:`굵게`,italic:`기울임꼴`,underline:`밑줄`,textColor:`글자 색`,highlightColor:`강조 색`,copyFormat:`서식 복사`,pasteFormat:`서식 붙여넣기`,removeFormat:`서식 제거`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,table:`표 삽입`,back:`뒤로`,noHighlight:`강조 없음`,customColor:`사용자 지정 색`,customColorLabel:`사용자 지정…`},statusbar:{resizeHandle:`편집기 크기 조정`,words:e=>`단어: ${e}`,wordsLimit:(e,t)=>`단어: ${e}/${t}`,chars:e=>`글자: ${e}`,charsLimit:(e,t)=>`글자: ${e}/${t}`},tooltips:{link:{ariaLabel:`링크 작업`,openLink:`링크 열기`,copyUrl:`URL 복사`,editLink:`링크 편집`,removeLink:`링크 제거`},image:{ariaLabel:`이미지 작업`,label:`이미지`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,rotateLeft:`왼쪽 회전`,rotateRight:`오른쪽 회전`,cropImage:`이미지 자르기`,addCaption:`캡션 추가 / 편집`,deleteImage:`이미지 삭제`},code:{ariaLabel:`코드 블록 작업`,label:`코드`,syntaxLanguage:`구문 언어`,syntaxAriaLabel:`구문 언어`,copyCode:`코드 복사`,toggleWordWrap:`줄 바꿈 전환`,enableWordWrap:`줄 바꿈 사용`,disableWordWrap:`줄 바꿈 해제`,convertToParagraph:`단락으로 변환`,deleteCodeBlock:`코드 블록 삭제`,lineNumbers:`줄 번호 전환`},table:{ariaLabel:`표 작업`,label:`표`,selectCells:`셀 선택`,addRowAbove:`위에 행 추가`,addRowBelow:`아래에 행 추가`,deleteRow:`행 삭제`,addColumnLeft:`왼쪽에 열 추가`,addColumnRight:`오른쪽에 열 추가`,deleteColumn:`열 삭제`,mergeCells:`셀 병합`,unmergeCells:`셀 분할`,columnWidth:`열 너비`,rowHeight:`행 높이`,tableBorderWidth:`표 테두리 너비`,tableBorderColor:`표 테두리 색상`,deleteTable:`표 삭제`,cellAlignLeft:`왼쪽 정렬`,cellAlignCenter:`가운데 정렬`,cellAlignRight:`오른쪽 정렬`,cellAlignJustify:`양쪽 정렬`,toggleHeaderRow:`머리글 행 전환`,cellBackground:`셀 배경색`,noShading:`배경 없음`,noBorderColor:`테두리 색 없음`,columnWidthPx:`열 너비 (px)`,rowHeightPx:`행 높이 (px)`,tableBorderWidthPx:`표 테두리 너비 (px)`,cancelBtn:`취소`,applyBtn:`적용`,sortAsc:`오름차순 정렬`,sortDesc:`내림차순 정렬`,exportCSV:`CSV로 내보내기`,cellPadding:`셀 패딩`,cellPaddingPx:`셀 패딩 (px)`},video:{ariaLabel:`동영상 작업`,label:`동영상`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,previewVideo:`동영상 미리보기`,exitPreview:`미리보기 종료`,deleteVideo:`동영상 삭제`}},errors:{imageFormat:e=>`"${e}" 형식은 웹 브라우저에서 지원되지 않습니다. JPEG, PNG 또는 WebP로 변환해 주세요.`,imageSize:e=>`이미지 파일이 너무 큽니다. 최대 허용 크기는 ${e} MB입니다.`},autoSaveRestore:{found:`초안을 찾았습니다. 복원하시겠습니까?`,foundAt:`{date}의 초안을 찾았습니다. 복원하시겠습니까?`,restore:`복원`,discard:`삭제`},slashMenu:{noResults:`일치하는 명령이 없습니다`,heading1:`제목 1`,heading2:`제목 2`,heading3:`제목 3`,bulletList:`글머리 기호 목록`,numberedList:`번호 매기기 목록`,checklist:`체크리스트`,blockquote:`인용문`,codeBlock:`코드 블록`,horizontalRule:`가로선`,table:`표`,image:`이미지`}});var l=e=>e?.nodeType===1,u=e=>l(e)&&/^(p|div|li|h[1-6]|blockquote|td|th|pre)$/i.test(e.nodeName),d=e=>l(e)&&/^(li)$/i.test(e.nodeName);function f(e,t,n){let r=e;for(;r&&r!==n;){if(t(r))return r;r=r.parentNode}return null}function p(e,t){return f(e,u,t)}function m(e,t={},n=[]){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);for(let e of n)typeof e==`string`?r.appendChild(document.createTextNode(e)):r.appendChild(e);return r}function h(e){let t=document.createRange();t.selectNodeContents(e),t.collapse(!1);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function g(e){if(e?.querySelectorAll)for(let t of e.querySelectorAll(`ul > ul, ul > ol, ol > ul, ol > ol`)){let e=t.previousElementSibling;if(e&&e.nodeName===`LI`)e.appendChild(t);else if(t.parentNode){let e=t.ownerDocument.createElement(`li`);t.parentNode.insertBefore(e,t),e.appendChild(t)}}}function _(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function v(e,t){let n=()=>Array.from(e.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.closest(`[style*="display: none"]`)&&!e.closest(`[style*="display:none"]`)),r=e=>{if(e.key===`Escape`){e.stopPropagation(),t?.();return}if(e.key!==`Tab`)return;let r=n();if(!r.length)return;let i=r[0],a=r.at(-1);e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())};return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)}function ee(e,t){e.style.cursor=`grab`;let n=n=>{if(n.button!==0||n.target.closest(`button, input, select, textarea, a`))return;if(n.preventDefault(),!t.dataset.anDragPinned){let e=t.getBoundingClientRect();t.style.position=`fixed`,t.style.margin=`0`,t.style.left=`${e.left}px`,t.style.top=`${e.top}px`,t.dataset.anDragPinned=`1`}let r=n.clientX-Number.parseFloat(t.style.left),i=n.clientY-Number.parseFloat(t.style.top);e.style.cursor=`grabbing`;let a=e=>{let n=t.offsetWidth,a=t.offsetHeight;t.style.left=`${Math.max(0,Math.min(e.clientX-r,globalThis.innerWidth-n))}px`,t.style.top=`${Math.max(0,Math.min(e.clientY-i,globalThis.innerHeight-a))}px`},o=()=>{e.style.cursor=`grab`,document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o)};document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)};return e.addEventListener(`mousedown`,n),()=>e.removeEventListener(`mousedown`,n)}var y=class{constructor(e,t,n,r){this.sc=e,this.so=t,this.ec=n,this.eo=r}isCollapsed(){return this.sc===this.ec&&this.so===this.eo}toNativeRange(){let e=document.createRange();try{e.setStart(this.sc,this.so),e.setEnd(this.ec,this.eo)}catch{}return e}select(){let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(this.toNativeRange()))}commonAncestor(){let e=this.toNativeRange().commonAncestorContainer;return l(e)?e:e.parentElement}blockNode(e){return f(this.sc,t=>l(t)&&t!==e,e)}toString(){return this.toNativeRange().toString()}getClientRects(){let e=this.toNativeRange().getClientRects();return e.length>0?e[e.length-1]:null}insertNode(e){this.toNativeRange().insertNode(e)}};function b(e){return new y(e.startContainer,e.startOffset,e.endContainer,e.endOffset)}function x(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&!e.contains(n.commonAncestorContainer)?null:b(n)}function S(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0){e(null);return}let n=t.getRangeAt(0).cloneRange();e(b(n)),t.removeAllRanges(),t.addRange(n)}function C(e){let t=e&&e.nodeType===1?e:e?.parentElement;for(;t;){let e=t.getAttribute?.(`contenteditable`)??t.contentEditable;if(e===`false`)return null;if(e!=null&&e!==`inherit`)return t;t=t.parentElement}return null}function w(e){let t=globalThis.getSelection?.();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&e!==document?e.contains(n.commonAncestorContainer)?n:null:C(n.commonAncestorContainer)?n:null}function T(e){let t=globalThis.getSelection?.();if(!t)return;let n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}function E(e,t){let n=w(t);if(!n)return!1;let r=document.createElement(`template`);r.innerHTML=e;let i=r.content,a=i.lastChild;return n.deleteContents(),n.insertNode(i),a&&T(a),!0}function D(e,t){let n=w(t);if(!n)return!1;n.deleteContents();let r=String(e),i=document.createDocumentFragment();!r.includes(`
|
|
2
2
|
`)||ne(n.startContainer,t)?i.appendChild(document.createTextNode(r)):r.split(`
|
|
3
3
|
`).forEach((e,t)=>{t>0&&i.appendChild(document.createElement(`br`)),e&&i.appendChild(document.createTextNode(e))});let a=i.lastChild;return n.insertNode(i),a&&T(a),!0}function te(e){return D(`
|
|
4
|
-
`,e)}function ne(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(n.tagName===`PRE`||n.tagName===`TEXTAREA`)return!0;let e=globalThis.getComputedStyle?.(n)?.whiteSpace;if(e&&e.startsWith(`pre`))return!0;n=n.parentElement}return!1}function re(e){let t=w(e);if(!t)return!1;let n=document.createElement(`hr`);t.deleteContents();let r=ie(t.startContainer,e);r&&r.parentNode?r.parentNode.insertBefore(n,r.nextSibling):t.insertNode(n);let i=n.nextElementSibling;if(!i||i.tagName===`HR`){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),n.parentNode?.insertBefore(e,n.nextSibling),i=e}let a=globalThis.getSelection?.();if(a){let e=document.createRange();e.setStart(i,0),e.collapse(!0),a.removeAllRanges(),a.addRange(e)}return!0}var O=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]);function ie(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(O.has(n.tagName))return n;n=n.parentElement}return null}function k(e,t=null){return e===`insertHTML`&&E(String(t??``))||e===`insertText`&&D(String(t??``))||e===`insertLineBreak`&&te()||e===`insertHorizontalRule`&&re()?!0:document.execCommand(e,!1,t)}var ae=()=>k(`bold`),oe=()=>k(`italic`);function se(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`u`),r=document.queryCommandState(`underline`);if(n&&!r){let e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove();return}k(`underline`)}function ce(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`s`)||t?.closest(`strike`),r=document.queryCommandState(`strikeThrough`);if(n&&!r){let e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove();return}k(`strikeThrough`)}var le=()=>k(`superscript`),ue=()=>k(`subscript`),de=e=>k(`foreColor`,e),fe=e=>k(`hiliteColor`,e),pe=e=>k(`fontName`,e);function me(e,t=document){let n=globalThis.getSelection(),r=!n?.rangeCount||n.getRangeAt(0).collapsed;if(r&&n?.rangeCount>0){try{let t=n.getRangeAt(0),r=document.createElement(`span`);r.style.fontSize=e;let i=document.createTextNode(``);r.appendChild(i),t.insertNode(r);let a=document.createRange();a.setStart(i,i.textContent.length),a.collapse(!0),n.removeAllRanges(),n.addRange(a)}catch{}return}k(`fontSize`,`7`);let i=t instanceof HTMLElement?t:document,a=[];if(i.querySelectorAll(`font[size="7"]`).forEach(t=>{let n=document.createElement(`span`);for(n.style.fontSize=e,t.parentNode.insertBefore(n,t);t.firstChild;)n.appendChild(t.firstChild);t.remove(),a.push(n)}),!r&&n&&a.length>0){let e=a[0],t=a.at(-1);try{let r=document.createRange(),i=e.firstChild||e,a=t.lastChild||t;r.setStart(i,0),r.setEnd(a,a.nodeType===Node.TEXT_NODE?a.textContent.length:a.childNodes.length),n.removeAllRanges(),n.addRange(r)}catch{}}}var he=e=>k(`formatBlock`,`<${e}>`),ge=()=>k(`justifyLeft`),_e=()=>k(`justifyCenter`),ve=()=>k(`justifyRight`),ye=()=>k(`justifyFull`);function be(){k(`indent`),g(xe())}function xe(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=null;for(let e=t;e;e=e.parentElement)(e.nodeName===`UL`||e.nodeName===`OL`)&&(n=e);return n}function Se(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`.an-checklist li`);if(n){we(n);return}}Ce()||k(`outdent`)}function Ce(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest?.(`li`);if(!n)return!1;let r=n.parentElement;if(!r||r.nodeName!==`UL`&&r.nodeName!==`OL`)return!1;let i=r.parentElement;if(!i||i.nodeName!==`LI`||!i.parentNode)return!1;let a=[];for(let e=n.nextElementSibling;e;e=e.nextElementSibling)a.push(e);if(a.length){let e=n.ownerDocument.createElement(r.nodeName.toLowerCase());a.forEach(t=>e.appendChild(t)),n.appendChild(e)}return i.parentNode.insertBefore(n,i.nextSibling),r.children.length||r.remove(),!0}function we(e){let t=e.closest(`.an-checklist`);if(!t)return;let n=Array.from(t.children),r=n.indexOf(e),i=n.slice(r+1),a=document.createElement(`p`);for(let t of e.childNodes)t.nodeType===1&&t.tagName===`INPUT`||a.appendChild(t.cloneNode(!0));if(a.innerHTML=a.innerHTML.replaceAll(``,``),(!a.hasChildNodes()||!a.textContent.trim())&&(a.innerHTML=``,a.appendChild(document.createTextNode(`\xA0`))),i.length>0){let e=document.createElement(`ul`);e.className=`an-checklist`,i.forEach(t=>e.appendChild(t)),t.parentNode.insertBefore(e,t.nextSibling)}t.parentNode.insertBefore(a,t.nextSibling),e.remove(),t.children.length===0&&t.remove();try{let e=document.createRange(),t=a.firstChild;e.setStart(t?.nodeType===3?t:a,0),e.collapse(!0);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}catch{}}function Te(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),t?.closest(`ul, ol`)||null}function Ee(e){e.classList.remove(`an-checklist`),e.querySelectorAll(`input[type="checkbox"]`).forEach(e=>e.remove())}function De(){let e=Te();e?e.classList.contains(`an-checklist`)?(Ee(e),e.tagName===`OL`&&Me(e,`ul`)):e.tagName===`OL`?Me(e,`ul`):k(`insertUnorderedList`):k(`insertUnorderedList`)}function Oe(){let e=Te();e?e.classList.contains(`an-checklist`)?(Ee(e),Me(e,`ol`)):e.tagName===`UL`?Me(e,`ol`):k(`insertOrderedList`):k(`insertOrderedList`)}function ke(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0),r=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),i=e=>{let t=e instanceof Element?e:e.parentElement;for(;t;){if(r.has(t.tagName))return t;t=t.parentElement}return null};if(n.collapsed){let t=i(n.startContainer);t&&(t.style.lineHeight=e);return}let a=new Set,o=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:e=>n.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}),s;for(;s=o.nextNode();){let e=i(s);e&&a.add(e)}if(a.size===0){let e=i(n.commonAncestorContainer);e&&a.add(e)}a.forEach(t=>{t.style.lineHeight=e})}function Ae(e){let t=globalThis.getSelection();if(!t?.rangeCount)return;let n=t.getRangeAt(0),r=n.commonAncestorContainer;r.nodeType===3&&(r=r.parentElement);let i=r?.closest(`code`);if(i&&!i.closest(`pre`)){let e=i.parentNode,n=i.previousSibling,r=Array.from(i.childNodes);for(;i.firstChild;)e.insertBefore(i.firstChild,i);if(i.remove(),e?.normalize(),r.length>0)try{let i=r[0],a=r.at(-1),o=document.createRange(),s=i.parentNode===e?i:n?n.nextSibling:e.firstChild;if(s){o.setStart(s,0);let n=a.parentNode===e?a:s;o.setEnd(n,n.nodeType===Node.TEXT_NODE?n.textContent.length:n.childNodes.length),t.removeAllRanges(),t.addRange(o)}}catch{}}else{if(n.collapsed)return;try{let e=document.createElement(`code`);n.surroundContents(e);let r=document.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}catch{let e=n.extractContents(),r=document.createElement(`code`);r.appendChild(e),n.insertNode(r);let i=document.createRange();i.selectNodeContents(r),t.removeAllRanges(),t.addRange(i)}}}function je(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`code`);return!!(n&&!n.closest(`pre`))}function Me(e,t){let n=document.createElement(t);for(let t of e.attributes)n.setAttribute(t.name,t.value);for(;e.firstChild;)n.appendChild(e.firstChild);return e.parentNode.replaceChild(n,e),n}function Ne(e){e.querySelectorAll(`li`).forEach(e=>{if(!e.querySelector(`input[type="checkbox"]`)){let t=document.createElement(`input`);t.type=`checkbox`,t.contentEditable=`false`,e.insertBefore(t,e.firstChild)}})}function Pe(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=t.commonAncestorContainer;n.nodeType===3&&(n=n.parentElement);let r=n?.closest(`ul, ol`);if(r)if(r.classList.contains(`an-checklist`)){if(r.parentNode){let t=Array.from(r.children),n=null;if(t.forEach(e=>{let t=document.createElement(`p`);for(let n of e.childNodes)n.nodeType===1&&n.tagName===`INPUT`||t.appendChild(n.cloneNode(!0));t.innerHTML=t.innerHTML.replaceAll(``,``).replaceAll(``,``),(!t.hasChildNodes()||!t.textContent.trim())&&(t.innerHTML=``,t.appendChild(document.createTextNode(`\xA0`))),r.before(t),n||=t}),r.remove(),n){let t=document.createRange();t.setStart(n.firstChild||n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}else{let t=Me(r,`ul`);t.classList.add(`an-checklist`),Ne(t);let n=t.querySelector(`li`);if(n){let t=document.createRange();t.selectNodeContents(n),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}else{let r=n?.closest(`[contenteditable="true"]`);if(t.collapsed){let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`]),i=n;for(;i?.parentNode&&i!==r&&!t.has(i.tagName);)i=i.parentNode;i===r&&(i=null);let a=i&&t.has(i.tagName)?Array.from(i.childNodes).map(e=>e.textContent).join(``).replaceAll(`\xA0`,` `):``,o=document.createElement(`ul`);o.className=`an-checklist`;let s=document.createElement(`li`),c=document.createElement(`input`);if(c.type=`checkbox`,c.contentEditable=`false`,s.appendChild(c),s.appendChild(document.createTextNode(a||``)),o.appendChild(s),i&&t.has(i.tagName))i.parentNode.replaceChild(o,i);else{let t=e.getRangeAt(0);t.deleteContents(),t.insertNode(o)}let l=s.lastChild,u=document.createRange(),d=l.nodeType===Node.TEXT_NODE?l.textContent.length:0;u.setStart(l,d),u.collapse(!0),e.removeAllRanges(),e.addRange(u);return}if(!e.toString().replace(/[\u00a0\u200B]/g,` `).trim())return;let i=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]),a=[],o=new Set,s=t.commonAncestorContainer,c=document.createNodeIterator(s.nodeType===Node.TEXT_NODE?s.parentNode:s,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null),l;for(;l=c.nextNode();){if(!t.intersectsNode(l))continue;let e=l.nodeType===Node.TEXT_NODE?l.parentElement:l;for(;e&&e!==r&&!i.has(e.tagName);)e=e.parentElement;e===r&&(e=null),e&&!o.has(e)&&(o.add(e),a.push(e))}if(a.length===0)return;let u=document.createElement(`ul`);u.className=`an-checklist`;let d=null;a.forEach(e=>{let t=document.createElement(`li`),n=document.createElement(`input`);n.type=`checkbox`,n.contentEditable=`false`,t.appendChild(n);let r=Array.from(e.childNodes).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim(),i=document.createTextNode(r||``);t.appendChild(i),u.appendChild(t),d=i});let f=a[0];if(f.parentNode.insertBefore(u,f),a.forEach(e=>e.remove()),d){let t=document.createRange();t.setStart(d,d.textContent.length),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}function Fe(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),!!t?.closest(`.an-checklist li`)}function A(e,t,n,r,i,a){return{name:e,icon:t,tooltip:n,action:r,isActive:i,isDisabled:a}}var Ie=new Map;function Le(e){if(!e||typeof e.name!=`string`){console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");return}Ie.has(e.name)&&console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`),Ie.set(e.name,e)}function Re(e){return Ie.get(e)}var ze=A(`bold`,`bold`,`Bold (Ctrl+B)`,()=>ae(),()=>document.queryCommandState(`bold`)),Be=A(`italic`,`italic`,`Italic (Ctrl+I)`,()=>oe(),()=>document.queryCommandState(`italic`)),Ve=A(`underline`,`underline`,`Underline (Ctrl+U)`,()=>se(),()=>{if(document.queryCommandState(`underline`))return!0;let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;return t.nodeType===3&&(t=t.parentElement),!!t?.closest(`u`)}),He=A(`strikethrough`,`strikethrough`,`Strikethrough`,()=>ce(),()=>document.queryCommandState(`strikeThrough`)),Ue=A(`superscript`,`superscript`,`Superscript`,()=>le(),()=>document.queryCommandState(`superscript`)),We=A(`subscript`,`subscript`,`Subscript`,()=>ue(),()=>document.queryCommandState(`subscript`)),Ge=A(`alignLeft`,`align-left`,`Align Left`,()=>ge()),Ke=A(`alignCenter`,`align-center`,`Align Center`,()=>_e()),qe=A(`alignRight`,`align-right`,`Align Right`,()=>ve()),Je=A(`alignJustify`,`align-justify`,`Justify`,()=>ye()),Ye=A(`ul`,`list-ul`,`Unordered List`,()=>De()),Xe=A(`ol`,`list-ol`,`Ordered List`,()=>Oe()),Ze=A(`indent`,`indent`,`Indent`,()=>be()),Qe=A(`outdent`,`outdent`,`Outdent`,()=>Se()),$e=A(`undo`,`undo`,`Undo (Ctrl+Z)`,e=>e.invoke(`editor.undo`),void 0,e=>!e.invoke(`editor.canUndo`)),et=A(`redo`,`redo`,`Redo (Ctrl+Y)`,e=>e.invoke(`editor.redo`),void 0,e=>!e.invoke(`editor.canRedo`)),tt=A(`hr`,`minus`,`Horizontal Rule`,()=>k(`insertHorizontalRule`)),nt=A(`link`,`link`,`Insert Link`,e=>e.invoke(`linkDialog.show`)),rt=A(`image`,`image`,`Insert Image`,e=>e.invoke(`imageDialog.show`)),it=A(`video`,`video`,`Insert Video`,e=>e.invoke(`videoDialog.show`)),at=A(`emoji`,`emoji`,`Insert Emoji`,e=>e.invoke(`emojiDialog.show`)),ot=A(`icon`,`icon`,`Insert FA Icon`,e=>e.invoke(`iconDialog.show`)),st={name:`table`,type:`grid`,icon:`table`,tooltip:`Insert Table`,action:(e,t,n)=>{e.invoke(`editor.insertTable`,n,t),e.invoke(`editor.afterCommand`)}},ct={name:`fontSize`,type:`select`,tooltip:`Font Size`,placeholder:`Size`,selectClass:`an-select-narrow`,items:[`8px`,`10px`,`11px`,`12px`,`13px`,`14px`,`16px`,`18px`,`20px`,`24px`,`28px`,`32px`,`36px`,`48px`,`72px`],action:(e,t)=>me(t,e.layoutInfo.editable),getValue:e=>{try{let t=globalThis.getSelection();if(t?.rangeCount){let e=t.getRangeAt(0).startContainer;for(e?.nodeType===3&&(e=e.parentElement);e?.nodeType===1&&!e.style.fontSize;)e=e.parentElement;let n=e?.style.fontSize||``;if(n)return n}let n=e?.layoutInfo?.editable;return n&&n.style.fontSize||``}catch{return``}}},lt=A(`removeFormat`,`remove-format`,`Remove Format`,()=>k(`removeFormat`)),ut=A(`direction`,`direction`,`Toggle Text Direction (LTR / RTL)`,e=>{let t=e.layoutInfo.editable,n=(t.getAttribute(`dir`)||`ltr`)===`ltr`?`rtl`:`ltr`;t.setAttribute(`dir`,n),t.style.textAlign=n===`rtl`?`right`:`left`,e.invoke(`editor.afterCommand`)}),dt={name:`fontFamily`,type:`select`,tooltip:`Font Family`,action:(e,t)=>pe(t),getValue:()=>{try{return document.queryCommandValue(`fontName`)||``}catch{return``}}},ft={name:`paragraphStyle`,type:`select`,tooltip:`Paragraph Style`,placeholder:`Style`,selectClass:`an-select-style`,items:[{value:`p`,label:`Normal`},{value:`h1`,label:`H1`},{value:`h2`,label:`H2`},{value:`h3`,label:`H3`},{value:`h4`,label:`H4`},{value:`h5`,label:`H5`},{value:`h6`,label:`H6`},{value:`blockquote`,label:`Quote`},{value:`pre`,label:`Code`}],action:(e,t)=>he(t),getValue:()=>{try{let e=document.queryCommandValue(`formatBlock`).toLowerCase().replace(/[<>]/g,``);return e===`div`?`p`:e||`p`}catch{return``}}},pt={name:`lineHeight`,type:`select`,tooltip:`Line Height`,placeholder:`↕ Line`,selectClass:`an-select-narrow`,items:[`1.0`,`1.15`,`1.5`,`1.75`,`2.0`,`2.5`,`3.0`],action:(e,t)=>ke(t),getValue:()=>{try{let e=globalThis.getSelection();if(!e?.rangeCount)return``;let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),n=e.getRangeAt(0).startContainer;for(n?.nodeType===3&&(n=n.parentElement);n&&!t.has(n.tagName);)n=n.parentElement;return n&&(n.style.lineHeight||getComputedStyle(n).lineHeight)||``}catch{return``}}},mt=A(`codeview`,`code`,`HTML Code View`,e=>e.invoke(`codeview.toggle`),e=>e.invoke(`codeview.isActive`)),ht=A(`fullscreen`,`expand`,`Fullscreen`,e=>e.invoke(`fullscreen.toggle`),e=>e.invoke(`fullscreen.isActive`)),gt=A(`shortcuts`,`keyboard`,`Keyboard Shortcuts (Ctrl+Shift+/)`,e=>e.invoke(`shortcutsDialog.show`)),_t=A(`find`,`search`,`Find (Ctrl+F)`,e=>e.invoke(`findReplace.show`,`find`)),vt=A(`findReplace`,`find-replace`,`Find & Replace (Ctrl+H)`,e=>e.invoke(`findReplace.show`,`replace`)),yt=A(`inlineCode`,`inline-code`,"Inline Code (Ctrl+`)",e=>e.invoke(`editor.inlineCode`),()=>je()),bt=A(`checklist`,`checklist`,`Checklist`,e=>e.invoke(`editor.toggleChecklist`),()=>Fe()),xt=A(`print`,`print`,`Print`,e=>e.invoke(`editor.print`)),St={name:`foreColor`,type:`colorpicker`,icon:`foreColor`,tooltip:`Text Color`,defaultColor:`#e11d48`,action:(e,t)=>de(t)},Ct={name:`backColor`,type:`colorpicker`,icon:`backColor`,tooltip:`Highlight Color`,defaultColor:`#fbbf24`,action:(e,t)=>fe(t)},wt=[[ft,dt,ct,pt],[$e,et],[ze,Be,Ve,He,yt],[Ue,We],[St,Ct],[Ge,Ke,qe,Je],[Ye,Xe,bt,Ze,Qe],[tt,nt,rt,it,st,at,ot],[lt,mt,ht,_t,xt,gt]],Tt={boldBtn:ze,italicBtn:Be,underlineBtn:Ve,strikeBtn:He,superscriptBtn:Ue,subscriptBtn:We,alignLeftBtn:Ge,alignCenterBtn:Ke,alignRightBtn:qe,alignJustifyBtn:Je,ulBtn:Ye,olBtn:Xe,indentBtn:Ze,outdentBtn:Qe,undoBtn:$e,redoBtn:et,hrBtn:tt,linkBtn:nt,imageBtn:rt,videoBtn:it,emojiBtn:at,iconBtn:ot,tableBtn:st,fontSizeBtn:ct,removeFormatBtn:lt,directionBtn:ut,fontFamilyBtn:dt,paragraphStyleBtn:ft,lineHeightBtn:pt,codeviewBtn:mt,fullscreenBtn:ht,shortcutsBtn:gt,findBtn:_t,findReplaceBtn:vt,inlineCodeBtn:yt,checklistBtn:bt,printBtn:xt,foreColorBtn:St,backColorBtn:Ct,defaultToolbar:wt},j={placeholder:``,height:200,minHeight:100,maxHeight:0,focus:!1,resizable:!0,toolbar:wt,useBootstrap:!1,toolbarButtonClass:`btn btn-sm btn-light`,useFontAwesome:!0,fontAwesomeClass:`fas`,fontAwesomeAutoInject:!0,fontAwesomeCDN:`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,pasteAsPlainText:!1,pasteCleanHTML:!0,pasteStripAttributes:!1,allowImageUpload:!0,maxImageSize:5,tabSize:4,onChange:null,onFocus:null,onBlur:null,onInit:null,onImageUpload:null,onImageError:null,stickyToolbar:!1,stickyToolbarOffset:0,theme:`light`,codeHighlight:!0,codeHighlightCDN:`https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0`,cspNonce:``,externalAssetCrossOrigin:`anonymous`,externalAssetReferrerPolicy:`no-referrer`,markdownPaste:!0,historyLimit:100,historyMaxBytes:10*1024*1024,defaultFontFamily:`Arial`,defaultFontSize:`14px`,fontFamilies:[`Arial`,`Arial Black`,`Comic Sans MS`,`Courier New`,`Georgia`,`Impact`,`Tahoma`,`Times New Roman`,`Trebuchet MS`,`Verdana`],readOnly:!1,spellcheck:!0,direction:`ltr`,toolbarOverflow:`wrap`,autoSave:!1,autoSaveKey:`autumnnote-autosave`,autoSaveDelay:400,autoSaveAdapter:null,maxChars:0,maxWords:0,tableHeaderRow:!1,onSelectionChange:null,colorSwatches:[],onPaste:null,onPasteError:null,onDestroy:null,onCharLimitReached:null,onWordLimitReached:null,focusColor:null,lang:`en`,autoSaveRestore:!1,autoSaveRestoreTimeout:7,onAutoSaveRestore:null,markdownShortcuts:!0,slashMenu:!0,slashCommands:[],documentAdapters:{},collaborationAdapter:null,imageProcessor:null,blockIds:!1,maxPasteSize:5*1024*1024,minImageSize:20,bubbleToolbar:!1,bubbleToolbarItems:[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`],mention:null},Et=[`script`,`style`,`iframe`,`object`,`embed`,`form`,`base`,`template`,`link`,`meta`,`noscript`,`portal`,`frame`,`frameset`,`applet`,`animate`,`set`,`animatetransform`,`animatemotion`,`mglyph`,`malignmark`,`annotation-xml`],Dt=new Set([`button`]),Ot=[`href`,`src`,`action`,`formaction`,`xlink:href`,`poster`,`background`,`srcset`],kt=new Set([`poster`,`background`,`srcset`]),At=new Set([`ping`]),jt=new Set([`color`,`background-color`,`font-size`,`line-height`,`text-align`,`vertical-align`,`width`,`min-width`,`height`,`min-height`,`border-width`,`border-style`,`border-color`,`padding`,`white-space`]),Mt=/url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i,Nt=new Set([`www.youtube.com`,`youtube.com`,`m.youtube.com`,`www.youtube-nocookie.com`,`youtube-nocookie.com`,`player.vimeo.com`]),Pt=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Ft=new Set([`http:`,`https:`,`blob:`]),It=/^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i,Lt=`https://autumnnote.invalid/`;function M(e,t){return Rt(e,t).innerHTML}function Rt(e,{allowIframes:t=!1}={}){let n=new DOMParser().parseFromString(`<body>${e||``}</body>`,`text/html`),r=Array.from(n.querySelectorAll(`*`)),i=new Set(t?Et.filter(e=>e!==`iframe`):Et);for(let e of r){let t=e.tagName.toLowerCase();if(Dt.has(t)){e.replaceWith(...e.childNodes);continue}if(i.has(t)){e.remove();continue}if(t===`iframe`){let t=e.getAttribute(`src`);if(!t||!Vt(t)){e.remove();continue}}for(let t of Array.from(e.attributes)){if(t.name.startsWith(`on`)){e.removeAttribute(t.name);continue}if(t.name===`style`){let n=zt(t.value);n?e.setAttribute(`style`,n):e.removeAttribute(`style`);continue}if(At.has(t.name)){e.removeAttribute(t.name);continue}if(Ot.includes(t.name)){let n=t.value.trim(),r=kt.has(t.name)||t.name===`src`&&[`IMG`,`VIDEO`,`AUDIO`,`SOURCE`].includes(e.tagName),i=e.tagName===`IMG`;if(!(t.name===`srcset`?Bt(n,{allowData:i}):Ut(n,{media:r,allowData:i}))){e.removeAttribute(t.name);continue}}if(e.tagName===`IFRAME`){if(t.name===`srcdoc`){e.removeAttribute(t.name);continue}t.name===`src`&&!Vt(t.value)&&e.removeAttribute(t.name)}}if(t===`a`&&e.getAttribute(`target`)===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`),t===`input`)if(!(e.closest(`ul.an-checklist`)!==null&&e.closest(`li`)!==null)||e.getAttribute(`type`)!==`checkbox`)e.remove();else for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}return n.body}function zt(e){let t=[];for(let n of(e||``).split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();!r||!i||jt.has(r)&&(Mt.test(i)||t.push(`${r}: ${i}`))}return t.join(`; `)}function Bt(e,{allowData:t=!1}={}){let n=(e||``).trim().split(/\s+/).filter(Boolean);for(let e of n){if(/^[\d.]+[xw],?$/i.test(e))continue;let n=e.replace(/,+$/,``);if(n&&!Ut(n,{media:!0,allowData:t}))return!1}return!0}function Vt(e){let t=(e||``).trim();if(!t||t.startsWith(`//`)||t.startsWith(`/`))return!1;try{let e=new URL(t);return e.protocol===`https:`&&Nt.has(e.hostname.toLowerCase())}catch{return!1}}function Ht(e,{allowData:t=!1,media:n=t}={}){let r=(e||``).trim();return!r&&e==null?null:Ut(r,{media:n,allowData:t})?e:null}function Ut(e,{media:t=!1,allowData:n=!1}={}){let r=(e||``).trim();if(!r||n&&It.test(r))return!0;try{let e=new URL(r,Lt);return(t?Ft:Pt).has(e.protocol)}catch{return!1}}function Wt(e,t){let n=m(`div`,{class:`an-container`}),r=m(`div`,{class:`an-editable`,contenteditable:t.readOnly?`false`:`true`,spellcheck:String(t.spellcheck!==!1),"aria-multiline":`true`,"aria-label":`Rich text editor`,role:`textbox`}),i=``;if(t.autoSave&&t.autoSaveKey)try{i=localStorage.getItem(t.autoSaveKey)||``}catch{}i||=e.tagName===`TEXTAREA`?(e.value||``).trim():(e.innerHTML||``).trim(),r.innerHTML=M(i,{allowIframes:!0});let a=t.defaultFontFamily||t.fontFamilies?.[0];return a&&(r.style.fontFamily=a),t.defaultFontSize&&(r.style.fontSize=t.defaultFontSize),t.height?r.style.minHeight=`${t.height}px`:t.minHeight&&(r.style.minHeight=`${t.minHeight}px`),t.maxHeight&&(r.style.maxHeight=`${t.maxHeight}px`),n.appendChild(r),t.theme===`dark`?(n.classList.add(`an-theme-dark`),document.body.classList.add(`an-theme-dark`)):t.theme===`auto`&&(n.classList.add(`an-theme-auto`),document.body.classList.add(`an-theme-auto`)),t.readOnly&&(n.classList.add(`an-disabled`),r.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})),t.direction===`rtl`&&(r.setAttribute(`dir`,`rtl`),n.classList.add(`an-dir-rtl`)),t.toolbarOverflow===`scroll`&&n.classList.add(`an-toolbar-overflow-scroll`),t.stickyToolbar&&(n.classList.add(`an-sticky-toolbar`),t.stickyToolbarOffset&&n.style.setProperty(`--an-sticky-top`,`${t.stickyToolbarOffset}px`)),t.focusColor&&n.style.setProperty(`--an-focus-color`,t.focusColor),e.style.display=`none`,e.after(n),{container:n,editable:r}}var Gt=new Map,Kt=[];function qt(e){Kt=Array.isArray(e)?e:[]}var Jt=new Map,Yt=class{constructor(e,t={}){this.targetEl=e,this.options=r(j,t),this.locale=c(this.options.lang),this.layoutInfo={},this._listeners=new Map,this._modules=new Map,this._plugins=new Map,this._disposers=[],this._alive=!1,this._autoSaveTimer=null,this._pendingAutoSave=null,this._suppressedRemoteHTML=null,this._destroyPromise=null,this._releaseInstance=null}initialize(){let{container:e,editable:t}=Wt(this.targetEl,this.options);this.layoutInfo.container=e,this.layoutInfo.editable=t,this._registerModules();let n=this._modules.get(`toolbar`);n?.el&&(e.insertBefore(n.el,t),this.layoutInfo.toolbar=n.el);let r=this._modules.get(`statusbar`);return r?.el&&(e.appendChild(r.el),this.layoutInfo.statusbar=r.el),this._bindEditorEvents(t),this.options.focus&&t.focus(),this._alive=!0,this.invoke(`toolbar.refresh`),this._applyGlobalPlugins(),typeof this.options.onInit==`function`&&this.options.onInit(this),this}_registerModules(){let e=(e,t)=>{let n=new t(this);this._modules.set(e,n),n.initialize()};for(let{name:t,Class:n,enabled:r}of Kt)typeof r==`function`&&!r(this.options)||e(t,n);if(Gt.size>0)for(let[t,n]of Gt)e(t,n)}_syncOptionalModules(){for(let{name:e,Class:t,enabled:n}of Kt){if(typeof n!=`function`)continue;let r=n(this.options);if(r!==this._modules.has(e))if(r){let n=new t(this);this._modules.set(e,n),n.initialize()}else{let t=this._modules.get(e);typeof t?.destroy==`function`&&t.destroy(),this._modules.delete(e)}}}registerModule(e,t){if(this._modules.has(e))return this;let n=new t(this);return n.initialize(),this._modules.set(e,n),this}registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=this.options.slashCommands||(this.options.slashCommands=[]),n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this.invoke(`slashMenu.refresh`),this}use(e,t={}){return Array.isArray(e.buttons)&&e.buttons.forEach(e=>Le(e)),this._installPlugin(e,t),this}getPlugin(e){return this._plugins.get(e)?.publicApi??null}_installPlugin(e,t={}){let{name:n}=e;if(!n||typeof n!=`string`){console.warn("[AutumnNote] Plugin must have a string `name` property.");return}if(this._plugins.has(n)){console.warn(`[AutumnNote] Plugin "${n}" already installed on this instance. Skipping.`);return}let r=typeof e.install==`function`?e.install(this,t)??null:null;this._plugins.set(n,{plugin:e,publicApi:r})}_applyGlobalPlugins(){if(Jt.size!==0)for(let{plugin:e,options:t}of Jt.values())this._installPlugin(e,t)}_bindEditorEvents(e){let t=_(e,`input`,()=>this._syncToTarget()),n=_(e,`focus`,()=>{this.layoutInfo.container.classList.add(`an-focused`),typeof this.options.onFocus==`function`&&this.options.onFocus(this)}),r=_(e,`blur`,()=>{this.layoutInfo.container.classList.remove(`an-focused`),this._syncToTarget(),typeof this.options.onBlur==`function`&&this.options.onBlur(this)}),i=this.on(`change`,e=>this._syncToTarget(e)),a=this.on(`change`,e=>{if(this.options.blockIds&&(this.ensureBlockIds(),e=this.getHTML()),e===this._suppressedRemoteHTML){this._suppressedRemoteHTML=null;return}this.options.collaborationAdapter?.onLocalChange?.(e,this)});if(this._disposers.push(t,n,r,i,a),this.options.autoSave&&this.options.autoSaveKey){let e=this.on(`change`,e=>this._scheduleAutoSave(e));this._disposers.push(e)}}_scheduleAutoSave(e){this._pendingAutoSave=e,clearTimeout(this._autoSaveTimer),this._autoSaveTimer=setTimeout(()=>this.flushAutoSave(),this.options.autoSaveDelay??400)}async flushAutoSave(){if(clearTimeout(this._autoSaveTimer),this._autoSaveTimer=null,this._pendingAutoSave==null)return;let e=this._pendingAutoSave;this._pendingAutoSave=null;let t=this.options.autoSaveKey,n=Date.now();try{let r=this.options.autoSaveAdapter;typeof r?.save==`function`?await r.save({key:t,html:e,savedAt:n,context:this}):(localStorage.setItem(t,e),localStorage.setItem(t+`:asrmeta`,JSON.stringify({savedAt:n}))),this.triggerEvent(`autoSave`,{key:t,html:e,savedAt:n})}catch(e){this.triggerEvent(`autoSaveError`,{key:t,error:e})}}async loadAutoSave(){let e=this.options.autoSaveAdapter;if(typeof e?.load==`function`)return e.load({key:this.options.autoSaveKey,context:this});try{return localStorage.getItem(this.options.autoSaveKey)}catch{return null}}invoke(e,...t){let[n,r]=e.split(`.`),i=this._modules.get(n);if(!i){console.warn(`[AutumnNote] invoke: module "${n}" not found (path: "${e}")`);return}if(typeof i[r]!=`function`){console.warn(`[AutumnNote] invoke: method "${r}" not found on module "${n}" (path: "${e}")`);return}return i[r](...t)}on(e,t){return this._listeners.has(e)||this._listeners.set(e,[]),this._listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return;let r=n.indexOf(t);r!==-1&&n.splice(r,1)}triggerEvent(e,...t){(this._listeners.get(e)||[]).forEach(e=>e(...t));let n=`on`+e.charAt(0).toUpperCase()+e.slice(1);typeof this.options[n]==`function`&&this.options[n](...t)}updateOptions(e={}){let t=r(this.options,e);Object.keys(this.options).forEach(e=>delete this.options[e]),Object.assign(this.options,t);let{container:n,editable:i}=this.layoutInfo;if(Object.hasOwn(e,`readOnly`)&&this.setDisabled(!!this.options.readOnly),Object.hasOwn(e,`spellcheck`)&&(i.spellcheck=this.options.spellcheck!==!1),Object.hasOwn(e,`placeholder`)&&(i.dataset.placeholder=this.options.placeholder||``),Object.hasOwn(e,`direction`)){let e=this.options.direction===`rtl`;i.setAttribute(`dir`,e?`rtl`:`ltr`),n.classList.toggle(`an-dir-rtl`,e)}if(Object.hasOwn(e,`height`)||Object.hasOwn(e,`minHeight`)){let e=this.options.height||this.options.minHeight||0;i.style.minHeight=e?`${e}px`:``}return Object.hasOwn(e,`maxHeight`)&&(i.style.maxHeight=this.options.maxHeight?`${this.options.maxHeight}px`:``),Object.hasOwn(e,`toolbar`)&&this.invoke(`toolbar.rebuild`),this._syncOptionalModules(),this.invoke(`statusbar.update`),this.triggerEvent(`optionsChange`,{...e}),this}getHTML(){let e=this.invoke(`editor.getHTML`);return typeof e==`string`?e.replace(//g,``):e}setHTML(e){this.invoke(`editor.setHTML`,e)}getText(){return this.invoke(`editor.getText`)}setText(e){this.invoke(`editor.setText`,e)}clear(){this.invoke(`editor.clear`)}clearHistory(){this.invoke(`editor.clearHistory`)}getUndoCount(){return this.invoke(`editor.getUndoCount`)??0}getRedoCount(){return this.invoke(`editor.getRedoCount`)??0}isEmpty(){return this.invoke(`editor.isEmpty`)}insertHTML(e){this.invoke(`editor.insertHTML`,e)}insertText(e){this.invoke(`editor.insertText`,e)}setMarkdown(e){this.invoke(`editor.setMarkdown`,e)}getMarkdown(){return this.invoke(`editor.getMarkdown`)}getSelectionBookmark(){return this.invoke(`editor.getSelectionBookmark`)??null}restoreSelectionBookmark(e){return this.invoke(`editor.restoreSelectionBookmark`,e)}async importDocument(e,t){let n=this.options.documentAdapters?.[e],r;if(typeof n?.import==`function`)r=await n.import(t,this);else if(e===`html`)r=String(t??``);else if(e===`markdown`)return this.setMarkdown(String(t??``)),this;else if(e===`text`)return this.setText(String(t??``)),this;else throw Error(`[AutumnNote] No importer registered for "${e}".`);return this.setHTML(r),this}async exportDocument(e){let t=this.options.documentAdapters?.[e];if(typeof t?.export==`function`)return t.export(this,this.getHTML());if(e===`html`)return this.getHTML();if(e===`markdown`)return this.getMarkdown();if(e===`text`)return this.getText();throw Error(`[AutumnNote] No exporter registered for "${e}".`)}ensureBlockIds(){let e=this.layoutInfo.editable.children;for(let t of e)if(!t.hasAttribute(`data-an-block-id`)){let e=globalThis.crypto?.randomUUID?.()||`an-${Date.now()}-${Math.random().toString(36).slice(2)}`;t.setAttribute(`data-an-block-id`,e)}return this}getDocument(){return this.options.blockIds&&this.ensureBlockIds(),{version:1,html:this.getHTML(),markdown:this.getMarkdown()}}loadDocument(e){return this.setHTML(e?.html||``),this.clearHistory(),this}applyRemoteHTML(e){return this.setHTML(e),this._suppressedRemoteHTML=this.getHTML(),this.clearHistory(),this}getWordCount(){return this.invoke(`statusbar.getWordCount`)??0}getCharCount(){return this.invoke(`statusbar.getCharCount`)??0}downloadHTML(e=`document.html`){this._download(this.getHTML(),e,`text/html`)}downloadText(e=`document.txt`){this._download(this.getText(),e,`text/plain`)}downloadMarkdown(e=`document.md`){this._download(this.getMarkdown(),e,`text/markdown`)}_download(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.style.display=`none`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}print(e=``){let t=this.getHTML(),n=`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>${(e||``).replace(/[<>&"']/g,e=>`&#${e.charCodeAt(0)};`)}</title><style>body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;font-size:14px;line-height:1.6;padding:20mm;color:#111827;}ul.an-checklist{list-style:none;padding-left:0;}ul.an-checklist li{padding-left:24px;position:relative;margin:2px 0;}ul.an-checklist li input[type="checkbox"]{position:absolute;left:0;top:3px;}code{background:#f3f4f6;border-radius:3px;padding:.1em .35em;font-family:monospace;}pre{background:#f3f4f6;padding:.75em 1em;border-radius:4px;overflow-x:auto;}table{border-collapse:collapse;}td,th{border:1px solid #d1d5db;padding:4px 8px;}</style></head><body>${t}</body></html>`,r=new Blob([n],{type:`text/html`}),i=URL.createObjectURL(r),a=globalThis.open(i,`_blank`);if(!a){URL.revokeObjectURL(i);return}a.addEventListener(`load`,()=>{a.print(),URL.revokeObjectURL(i)})}getTableOfContents(){return Array.from(this.layoutInfo.editable.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({level:parseInt(e.tagName[1],10),text:e.textContent?.trim()??``,element:e}))}focus(){this.layoutInfo.editable.focus()}blur(){this.layoutInfo.editable.blur()}isFullscreen(){return this.invoke(`fullscreen.isActive`)===!0}setDisabled(e){let t=this.layoutInfo.editable;e?(t.setAttribute(`contenteditable`,`false`),this.layoutInfo.container.classList.add(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})):(t.setAttribute(`contenteditable`,`true`),this.layoutInfo.container.classList.remove(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.removeAttribute(`disabled`)}))}destroy(){if(!this._alive)return this._destroyPromise??Promise.resolve();let e=this._pendingAutoSave==null?null:this.flushAutoSave().catch(()=>{});this._modules.forEach(e=>{typeof e.destroy==`function`&&e.destroy()}),this._modules.clear();for(let{plugin:e}of this._plugins.values())if(typeof e.uninstall==`function`)try{e.uninstall(this)}catch{}this._plugins.clear(),this._disposers.forEach(e=>e()),this._disposers=[];let t=this.layoutInfo.container,n=t?.classList.contains(`an-theme-dark`),r=t?.classList.contains(`an-theme-auto`);return t?.parentNode&&(this.targetEl.style.display=``,t.remove()),n&&!document.querySelector(`.an-container.an-theme-dark`)&&document.body.classList.remove(`an-theme-dark`),r&&!document.querySelector(`.an-container.an-theme-auto`)&&document.body.classList.remove(`an-theme-auto`),typeof this.options.onDestroy==`function`&&this.options.onDestroy(this),this._alive=!1,this._releaseInstance?.(),this._releaseInstance=null,this._destroyPromise=Promise.resolve(e).then(()=>{this._listeners.clear()}),this._destroyPromise}_syncToTarget(e){(this.targetEl.tagName===`TEXTAREA`||this.targetEl.tagName===`INPUT`)&&(this.targetEl.value=typeof e==`string`?e:this.getHTML())}};function Xt(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r}var Zt=class{constructor(e,t=100,n=10*1024*1024){this.editable=e,this._limit=t,this._maxBytes=n,this._bytes=0,this.stack=[],this.stackOffset=-1,this._savePoint()}_entrySize(e){let t=e.html.length;if(e.images)for(let n in e.images)t+=e.images[n].length;return t}_serialize(){return this.editable.innerHTML}_serializeSelection(){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return this.editable.contains(t.startContainer)?{start:this._charOffset(t.startContainer,t.startOffset),end:this._charOffset(t.endContainer,t.endOffset)}:null}_charOffset(e,t){try{let n=document.createRange();return n.selectNodeContents(this.editable),n.setEnd(e,t),n.toString().length}catch{return 0}}_restoreSelection(e){if(!e)return;let t=null,n=0,r=null,i=0,a=0,o=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),s;for(;s=o.nextNode();){let o=s.length;if(!t&&a+o>=e.start&&(t=s,n=e.start-a),!r&&a+o>=e.end){r=s,i=e.end-a;break}a+=o}if(!t){let e=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),a=null;for(;a=e.nextNode();)t=a;n=t?t.length:0,r=t,i=n}r||(r=t,i=n);try{let e=document.createRange();e.setStart(t,n),e.setEnd(r,i);let a=globalThis.getSelection();a.removeAllRanges(),a.addRange(e)}catch{try{let e=document.createRange();e.setStart(this.editable,0),e.collapse(!0);let t=globalThis.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}catch{}}}_savePoint(){if(this.stackOffset<this.stack.length-1){for(let e of this.stack.slice(this.stackOffset+1))this._bytes-=this._entrySize(e);this.stack=this.stack.slice(0,this.stackOffset+1)}let e=this._serialize(),{html:t,images:n}=this._tokenizeImages(e),r={html:t,images:n,sel:this._serializeSelection()};for(this.stack.push(r),this._bytes+=this._entrySize(r);this.stack.length>1&&(this.stack.length>this._limit||this._bytes>this._maxBytes);)this._bytes-=this._entrySize(this.stack.shift());this.stackOffset=this.stack.length-1}_restore(e){if(!e)return;let t=this.editable.textContent||``;this.editable.innerHTML=this._detokenizeImages(e);let n=e.sel;if(!n){let e=Xt(t,this.editable.textContent||``);n={start:e,end:e}}this._restoreSelection(n)}_tokenizeImages(e){if(!e.includes(`data:`))return{html:e,images:{}};let t={},n=0;return{html:e.replace(/data:[^;]+;base64,[^"' >]*/g,e=>{let r=`__asn_img_${n}__`;return t[r]=e,n++,r}),images:t}}_detokenizeImages(e){return!e.images||Object.keys(e.images).length===0?e.html:e.html.replace(/__asn_img_\d+__/g,t=>e.images[t]||t)}recordUndo(){let e=this._serialize(),{html:t}=this._tokenizeImages(e);this.stack[this.stackOffset]?.html!==t&&this._savePoint()}undo(){this.stackOffset<=0||(this.stackOffset--,this._restore(this.stack[this.stackOffset]))}redo(){this.stackOffset>=this.stack.length-1||(this.stackOffset++,this._restore(this.stack[this.stackOffset]))}reset(){this.stack=[],this.stackOffset=-1,this._bytes=0,this._savePoint()}canUndo(){return this.stackOffset>0}canRedo(){return this.stackOffset<this.stack.length-1}getUndoCount(){return Math.max(0,this.stackOffset)}getRedoCount(){return Math.max(0,this.stack.length-1-this.stackOffset)}};function Qt(e,t,n={}){let{headerRow:r=!1}=n,i=m(`table`,{class:`an-table`});if(r&&t>0){let t=m(`thead`),n=m(`tr`);for(let t=0;t<e;t++){let e=m(`th`,{},[document.createElement(`br`)]);n.appendChild(e)}t.appendChild(n),i.appendChild(t)}let a=r?Math.max(t-1,1):t,o=m(`tbody`);i.appendChild(o);for(let t=0;t<a;t++){let t=m(`tr`);for(let n=0;n<e;n++){let e=m(`td`,{},[document.createElement(`br`)]);t.appendChild(e)}o.appendChild(t)}return i}function $t(e,t,n={}){if(e<=0||t<=0)return;let r=Qt(e,t,n),i=globalThis.getSelection();if(!i||i.rangeCount===0)return;let a=i.getRangeAt(0);try{a.deleteContents()}catch{return}let o=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`,`PRE`]),s=a.startContainer;for(s?.nodeType===3&&(s=s.parentElement);s&&!o.has(s.tagName?.toUpperCase())&&s.parentElement;)s=s.parentElement;if(s&&o.has(s.tagName?.toUpperCase())&&s.parentNode){if(s.after(r),!r.nextElementSibling){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),r.after(e)}!s.textContent.trim()&&!s.querySelector(`img, video, table`)&&s.remove()}else try{a.insertNode(r)}catch{return}let c=r.querySelector(`td, th`);if(c){let e=document.createRange();e.setStart(c,0),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}}var N={BACKSPACE:`Backspace`,TAB:`Tab`,ENTER:`Enter`,ESCAPE:`Escape`,SPACE:` `,PAGE_UP:`PageUp`,PAGE_DOWN:`PageDown`,END:`End`,HOME:`Home`,LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,DOWN:`ArrowDown`,DELETE:`Delete`,NUM0:`0`,NUM1:`1`,NUM2:`2`,NUM3:`3`,NUM4:`4`,NUM5:`5`,NUM6:`6`,NUM7:`7`,NUM8:`8`,B:`b`,E:`e`,I:`i`,J:`j`,K:`k`,L:`l`,R:`r`,S:`s`,U:`u`,V:`v`,Y:`y`,Z:`z`,SLASH:`/`,PERIOD:`.`};function P(e,t){return e.key===t||e.key===t.toUpperCase()}function F(e,t){return(e.ctrlKey||e.metaKey)&&P(e,t)}var en=/\bfa-/,I=e=>!!(e?.nodeName===`I`&&en.test(e.className||``)),tn=e=>e?.nodeType===Node.TEXT_NODE&&(e.textContent===``||e.textContent===``);function nn(e,t,n){let r=(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest(`td, th`)??null;if(!r||!t.contains(r))return!1;let i=r.closest(`table`);if(!i||!t.contains(i))return!1;let a=Array.from(i.querySelectorAll(`td, th`)),o=a[a.indexOf(r)+(n?-1:1)];if(o)return h(o),!0;if(n)return!0;let s=rn(r.closest(`tr`))?.firstElementChild??null;return s&&h(s),!0}function rn(e){if(!e?.parentNode)return null;let t=document.createElement(`tr`);for(let n of e.cells){let e=document.createElement(`td`);e.appendChild(document.createElement(`br`)),n.hasAttribute(`style`)&&e.setAttribute(`style`,n.getAttribute(`style`)),t.appendChild(e)}return e.parentNode.insertBefore(t,e.nextSibling),t}function an(e,t){try{let n=document.createRange();return n.setStart(e.startContainer,e.startOffset),n.setEnd(t,t.childNodes.length),n.extractContents()}catch{return document.createDocumentFragment()}}function on(e,t,n={}){let r=e=>{let t=globalThis.getSelection();if(!t)return!1;let n=document.createRange();return e(n),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0};if(P(e,N.BACKSPACE)){let t=globalThis.getSelection();if(t?.rangeCount>0){let n=t.getRangeAt(0);if(n.collapsed&&n.startContainer.nodeType===Node.TEXT_NODE){let r=n.startContainer;if(n.startOffset===0&&I(r.previousSibling))return e.preventDefault(),r.previousSibling.remove(),!0;if(n.startOffset===1&&r.textContent===``&&I(r.previousSibling)){e.preventDefault();let n=r.parentNode,i=r.previousSibling,a=i.previousSibling;i.remove(),r.remove();let o=document.createRange();return a?.nodeType===Node.TEXT_NODE?o.setStart(a,a.textContent.length):a?o.setStartAfter(a):n&&o.setStart(n,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}}return!1}if(P(e,N.LEFT)||P(e,N.RIGHT)){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return!1;let n=t.getRangeAt(0);if(!n.collapsed)return!1;let i=n.startContainer,a=P(e,N.LEFT);if(i.nodeType===Node.TEXT_NODE){let t=i;if(a&&n.startOffset===1&&t.textContent===``&&I(t.previousSibling)||a&&n.startOffset===0&&I(t.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling));if(a&&n.startOffset===0&&tn(t.previousSibling)&&I(t.previousSibling.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling.previousSibling));if(!a&&n.startOffset===t.textContent.length&&I(t.nextSibling)){let n=t.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(``);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}if(!a&&n.startOffset===t.textContent.length&&tn(t.nextSibling)&&I(t.nextSibling.nextSibling)){let n=t.nextSibling.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(``);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}}if(i.nodeType===Node.ELEMENT_NODE){let t=i;if(a&&n.startOffset>0){let i=t.childNodes[n.startOffset-1];if(I(i))return e.preventDefault(),r(e=>e.setStartBefore(i));if(tn(i)&&I(i.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(i.previousSibling))}if(!a&&n.startOffset<t.childNodes.length){let i=t.childNodes[n.startOffset];if(I(i)){let t=i.nextSibling;if(e.preventDefault(),t?.nodeType===Node.TEXT_NODE){let e=+!!(t.textContent||``).startsWith(``);return r(n=>n.setStart(t,Math.min(e,t.textContent.length)))}return r(e=>e.setStartAfter(i))}if(tn(i)&&I(i.nextSibling)){let t=i.nextSibling,n=t.nextSibling;if(e.preventDefault(),n?.nodeType===Node.TEXT_NODE){let e=+!!(n.textContent||``).startsWith(``);return r(t=>t.setStart(n,Math.min(e,n.textContent.length)))}return r(e=>e.setStartAfter(t))}}}}if(P(e,N.TAB)){let r=x(t);if(!r)return!1;if(nn(r.sc,t,e.shiftKey))return e.preventDefault(),!0;let i=p(r.sc,t);if(i&&d(i))return e.preventDefault(),e.shiftKey?Se():be(),!0;if(i?.nodeName.toUpperCase()===`PRE`)return e.shiftKey?!1:(e.preventDefault(),k(`insertText`,` `.repeat(n.tabSize||4)),!0);if(n.tabSize)return e.shiftKey?!1:(e.preventDefault(),k(`insertText`,` `.repeat(n.tabSize)),!0)}if(P(e,N.ENTER)&&e.shiftKey)return e.preventDefault(),k(`insertLineBreak`),!0;if(P(e,N.ENTER)&&!e.shiftKey){let n=x(t);if(!n)return!1;let r=n.sc,i=r.nodeType===3?r.parentElement:r;if(i?.nodeName===`I`&&/\bfa-/.test(i.className||``)){let e=document.createRange();e.setStartAfter(i),e.collapse(!0);let t=globalThis.getSelection();return t&&(t.removeAllRanges(),t.addRange(e)),!1}let a=i?.closest(`.an-video-wrapper`);if(a){e.preventDefault();let t=document.createElement(`p`);t.innerHTML=`\xA0`,a.parentNode.insertBefore(t,a.nextSibling);let n=document.createRange();n.setStart(t,0),n.collapse(!0);let r=globalThis.getSelection();return r.removeAllRanges(),r.addRange(n),!0}let o=i?.closest(`.an-checklist li`);if(o){e.preventDefault();let t=o.closest(`.an-checklist`),n=globalThis.getSelection(),r=n.getRangeAt(0);if(!(e=>Array.from(e.childNodes).filter(e=>!(e.nodeType===1&&e.tagName===`INPUT`)).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim())(o)){let e=document.createElement(`p`);e.innerHTML=`\xA0`,t.parentNode.insertBefore(e,t.nextSibling),o.remove(),t.children.length===0&&t.remove();let r=document.createRange();return r.setStart(e.firstChild,0),r.collapse(!0),n.removeAllRanges(),n.addRange(r),!0}if(!r.collapsed){if(r.deleteContents(),n.rangeCount===0||!o.isConnected)return!0;r=n.getRangeAt(0)}let i=an(r,o),a=document.createElement(`li`),s=document.createElement(`input`);s.type=`checkbox`,s.setAttribute(`contenteditable`,`false`),a.appendChild(s),i.textContent.replace(/[\u00a0\u200B]/g,``).length>0&&a.appendChild(i);let c=a.childNodes[1];c?.nodeType!==Node.TEXT_NODE&&(c=document.createTextNode(``),a.appendChild(c)),o.after(a);let l=document.createRange();return l.setStart(c,0),l.collapse(!0),n.removeAllRanges(),n.addRange(l),!0}let s=p(n.sc,t);if(s?.nodeName.toUpperCase()===`PRE`)return e.preventDefault(),k(`insertText`,`
|
|
4
|
+
`,e)}function ne(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(n.tagName===`PRE`||n.tagName===`TEXTAREA`)return!0;let e=globalThis.getComputedStyle?.(n)?.whiteSpace;if(e&&e.startsWith(`pre`))return!0;n=n.parentElement}return!1}function re(e){let t=w(e);if(!t)return!1;let n=document.createElement(`hr`);t.deleteContents();let r=ie(t.startContainer,e);r&&r.parentNode?r.parentNode.insertBefore(n,r.nextSibling):t.insertNode(n);let i=n.nextElementSibling;if(!i||i.tagName===`HR`){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),n.parentNode?.insertBefore(e,n.nextSibling),i=e}let a=globalThis.getSelection?.();if(a){let e=document.createRange();e.setStart(i,0),e.collapse(!0),a.removeAllRanges(),a.addRange(e)}return!0}var O=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]);function ie(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(O.has(n.tagName))return n;n=n.parentElement}return null}function k(e,t=null){return e===`insertHTML`&&E(String(t??``))||e===`insertText`&&D(String(t??``))||e===`insertLineBreak`&&te()||e===`insertHorizontalRule`&&re()?!0:document.execCommand(e,!1,t)}var ae=()=>k(`bold`),oe=()=>k(`italic`);function se(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`u`),r=document.queryCommandState(`underline`);if(n&&!r){let e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove();return}k(`underline`)}function ce(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`s`)||t?.closest(`strike`),r=document.queryCommandState(`strikeThrough`);if(n&&!r){let e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove();return}k(`strikeThrough`)}var le=()=>k(`superscript`),ue=()=>k(`subscript`),de=e=>k(`foreColor`,e),fe=e=>k(`hiliteColor`,e),pe=e=>k(`fontName`,e);function me(e,t=document){let n=globalThis.getSelection(),r=!n?.rangeCount||n.getRangeAt(0).collapsed;if(r&&n?.rangeCount>0){try{let t=n.getRangeAt(0),r=document.createElement(`span`);r.style.fontSize=e;let i=document.createTextNode(``);r.appendChild(i),t.insertNode(r);let a=document.createRange();a.setStart(i,i.textContent.length),a.collapse(!0),n.removeAllRanges(),n.addRange(a)}catch{}return}k(`fontSize`,`7`);let i=t instanceof HTMLElement?t:document,a=[];if(i.querySelectorAll(`font[size="7"]`).forEach(t=>{let n=document.createElement(`span`);for(n.style.fontSize=e,t.parentNode.insertBefore(n,t);t.firstChild;)n.appendChild(t.firstChild);t.remove(),a.push(n)}),!r&&n&&a.length>0){let e=a[0],t=a.at(-1);try{let r=document.createRange(),i=e.firstChild||e,a=t.lastChild||t;r.setStart(i,0),r.setEnd(a,a.nodeType===Node.TEXT_NODE?a.textContent.length:a.childNodes.length),n.removeAllRanges(),n.addRange(r)}catch{}}}var he=e=>k(`formatBlock`,`<${e}>`),ge=()=>k(`justifyLeft`),_e=()=>k(`justifyCenter`),ve=()=>k(`justifyRight`),ye=()=>k(`justifyFull`);function be(){k(`indent`),g(xe())}function xe(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=null;for(let e=t;e;e=e.parentElement)(e.nodeName===`UL`||e.nodeName===`OL`)&&(n=e);return n}function Se(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`.an-checklist li`);if(n){we(n);return}}Ce()||k(`outdent`)}function Ce(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest?.(`li`);if(!n)return!1;let r=n.parentElement;if(!r||r.nodeName!==`UL`&&r.nodeName!==`OL`)return!1;let i=r.parentElement;if(!i||i.nodeName!==`LI`||!i.parentNode)return!1;let a=[];for(let e=n.nextElementSibling;e;e=e.nextElementSibling)a.push(e);if(a.length){let e=n.ownerDocument.createElement(r.nodeName.toLowerCase());a.forEach(t=>e.appendChild(t)),n.appendChild(e)}return i.parentNode.insertBefore(n,i.nextSibling),r.children.length||r.remove(),!0}function we(e){let t=e.closest(`.an-checklist`);if(!t)return;let n=Array.from(t.children),r=n.indexOf(e),i=n.slice(r+1),a=document.createElement(`p`);for(let t of e.childNodes)(t.nodeType!==1||t.tagName!==`INPUT`)&&a.appendChild(t.cloneNode(!0));if(a.innerHTML=a.innerHTML.replaceAll(``,``),(!a.hasChildNodes()||!a.textContent.trim())&&(a.innerHTML=``,a.appendChild(document.createTextNode(`\xA0`))),i.length>0){let e=document.createElement(`ul`);e.className=`an-checklist`,i.forEach(t=>e.appendChild(t)),t.parentNode.insertBefore(e,t.nextSibling)}t.parentNode.insertBefore(a,t.nextSibling),e.remove(),t.children.length===0&&t.remove();try{let e=document.createRange(),t=a.firstChild;e.setStart(t?.nodeType===3?t:a,0),e.collapse(!0);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}catch{}}function Te(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),t?.closest(`ul, ol`)||null}function Ee(e){e.classList.remove(`an-checklist`),e.querySelectorAll(`input[type="checkbox"]`).forEach(e=>e.remove())}function De(){let e=Te();e?e.classList.contains(`an-checklist`)?(Ee(e),e.tagName===`OL`&&Me(e,`ul`)):e.tagName===`OL`?Me(e,`ul`):k(`insertUnorderedList`):k(`insertUnorderedList`)}function Oe(){let e=Te();e?e.classList.contains(`an-checklist`)?(Ee(e),Me(e,`ol`)):e.tagName===`UL`?Me(e,`ol`):k(`insertOrderedList`):k(`insertOrderedList`)}function ke(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0),r=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),i=e=>{let t=e instanceof Element?e:e.parentElement;for(;t;){if(r.has(t.tagName))return t;t=t.parentElement}return null};if(n.collapsed){let t=i(n.startContainer);t&&(t.style.lineHeight=e);return}let a=new Set,o=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:e=>n.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}),s;for(;s=o.nextNode();){let e=i(s);e&&a.add(e)}if(a.size===0){let e=i(n.commonAncestorContainer);e&&a.add(e)}a.forEach(t=>{t.style.lineHeight=e})}function Ae(e){let t=globalThis.getSelection();if(!t?.rangeCount)return;let n=t.getRangeAt(0),r=n.commonAncestorContainer;r.nodeType===3&&(r=r.parentElement);let i=r?.closest(`code`);if(i&&!i.closest(`pre`)){let e=i.parentNode,n=i.previousSibling,r=Array.from(i.childNodes);for(;i.firstChild;)e.insertBefore(i.firstChild,i);if(i.remove(),e?.normalize(),r.length>0)try{let i=r[0],a=r.at(-1),o=document.createRange(),s=i.parentNode===e?i:n?n.nextSibling:e.firstChild;if(s){o.setStart(s,0);let n=a.parentNode===e?a:s;o.setEnd(n,n.nodeType===Node.TEXT_NODE?n.textContent.length:n.childNodes.length),t.removeAllRanges(),t.addRange(o)}}catch{}}else{if(n.collapsed)return;try{let e=document.createElement(`code`);n.surroundContents(e);let r=document.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}catch{let e=n.extractContents(),r=document.createElement(`code`);r.appendChild(e),n.insertNode(r);let i=document.createRange();i.selectNodeContents(r),t.removeAllRanges(),t.addRange(i)}}}function je(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`code`);return!!(n&&!n.closest(`pre`))}function Me(e,t){let n=document.createElement(t);for(let t of e.attributes)n.setAttribute(t.name,t.value);for(;e.firstChild;)n.appendChild(e.firstChild);return e.parentNode.replaceChild(n,e),n}function Ne(e){e.querySelectorAll(`li`).forEach(e=>{if(!e.querySelector(`input[type="checkbox"]`)){let t=document.createElement(`input`);t.type=`checkbox`,t.contentEditable=`false`,e.insertBefore(t,e.firstChild)}})}function Pe(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=t.commonAncestorContainer;n.nodeType===3&&(n=n.parentElement);let r=n?.closest(`ul, ol`);if(r){if(r.classList.contains(`an-checklist`)){if(r.parentNode){let t=Array.from(r.children),n=null;if(t.forEach(e=>{let t=document.createElement(`p`);for(let n of e.childNodes)(n.nodeType!==1||n.tagName!==`INPUT`)&&t.appendChild(n.cloneNode(!0));t.innerHTML=t.innerHTML.replaceAll(``,``).replaceAll(``,``),(!t.hasChildNodes()||!t.textContent.trim())&&(t.innerHTML=``,t.appendChild(document.createTextNode(`\xA0`))),r.before(t),n||=t}),r.remove(),n){let t=document.createRange();t.setStart(n.firstChild||n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}else{let t=Me(r,`ul`);t.classList.add(`an-checklist`),Ne(t);let n=t.querySelector(`li`);if(n){let t=document.createRange();t.selectNodeContents(n),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}}else{let r=n?.closest(`[contenteditable="true"]`);if(t.collapsed){let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`]),i=n;for(;i?.parentNode&&i!==r&&!t.has(i.tagName);)i=i.parentNode;i===r&&(i=null);let a=i&&t.has(i.tagName)?Array.from(i.childNodes).map(e=>e.textContent).join(``).replaceAll(`\xA0`,` `):``,o=document.createElement(`ul`);o.className=`an-checklist`;let s=document.createElement(`li`),c=document.createElement(`input`);if(c.type=`checkbox`,c.contentEditable=`false`,s.appendChild(c),s.appendChild(document.createTextNode(a||``)),o.appendChild(s),i&&t.has(i.tagName))i.parentNode.replaceChild(o,i);else{let t=e.getRangeAt(0);t.deleteContents(),t.insertNode(o)}let l=s.lastChild,u=document.createRange(),d=l.nodeType===Node.TEXT_NODE?l.textContent.length:0;u.setStart(l,d),u.collapse(!0),e.removeAllRanges(),e.addRange(u);return}if(!e.toString().replace(/[\u00a0\u200B]/g,` `).trim())return;let i=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]),a=[],o=new Set,s=t.commonAncestorContainer,c=document.createNodeIterator(s.nodeType===Node.TEXT_NODE?s.parentNode:s,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null),l;for(;l=c.nextNode();){if(!t.intersectsNode(l))continue;let e=l.nodeType===Node.TEXT_NODE?l.parentElement:l;for(;e&&e!==r&&!i.has(e.tagName);)e=e.parentElement;e===r&&(e=null),e&&!o.has(e)&&(o.add(e),a.push(e))}if(a.length===0)return;let u=document.createElement(`ul`);u.className=`an-checklist`;let d=null;a.forEach(e=>{let t=document.createElement(`li`),n=document.createElement(`input`);n.type=`checkbox`,n.contentEditable=`false`,t.appendChild(n);let r=Array.from(e.childNodes).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim(),i=document.createTextNode(r||``);t.appendChild(i),u.appendChild(t),d=i});let f=a[0];if(f.parentNode.insertBefore(u,f),a.forEach(e=>e.remove()),d){let t=document.createRange();t.setStart(d,d.textContent.length),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}function Fe(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),!!t?.closest(`.an-checklist li`)}function A(e,t,n,r,i,a){return{name:e,icon:t,tooltip:n,action:r,isActive:i,isDisabled:a}}var Ie=new Map;function Le(e){if(!e||typeof e.name!=`string`){console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");return}Ie.has(e.name)&&console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`),Ie.set(e.name,e)}function Re(e){return Ie.get(e)}var ze=A(`bold`,`bold`,`Bold (Ctrl+B)`,()=>ae(),()=>document.queryCommandState(`bold`)),Be=A(`italic`,`italic`,`Italic (Ctrl+I)`,()=>oe(),()=>document.queryCommandState(`italic`)),Ve=A(`underline`,`underline`,`Underline (Ctrl+U)`,()=>se(),()=>{if(document.queryCommandState(`underline`))return!0;let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;return t.nodeType===3&&(t=t.parentElement),!!t?.closest(`u`)}),He=A(`strikethrough`,`strikethrough`,`Strikethrough`,()=>ce(),()=>document.queryCommandState(`strikeThrough`)),Ue=A(`superscript`,`superscript`,`Superscript`,()=>le(),()=>document.queryCommandState(`superscript`)),We=A(`subscript`,`subscript`,`Subscript`,()=>ue(),()=>document.queryCommandState(`subscript`)),Ge=A(`alignLeft`,`align-left`,`Align Left`,()=>ge()),Ke=A(`alignCenter`,`align-center`,`Align Center`,()=>_e()),qe=A(`alignRight`,`align-right`,`Align Right`,()=>ve()),Je=A(`alignJustify`,`align-justify`,`Justify`,()=>ye()),Ye=A(`ul`,`list-ul`,`Unordered List`,()=>De()),Xe=A(`ol`,`list-ol`,`Ordered List`,()=>Oe()),Ze=A(`indent`,`indent`,`Indent`,()=>be()),Qe=A(`outdent`,`outdent`,`Outdent`,()=>Se()),$e=A(`undo`,`undo`,`Undo (Ctrl+Z)`,e=>e.invoke(`editor.undo`),void 0,e=>!e.invoke(`editor.canUndo`)),et=A(`redo`,`redo`,`Redo (Ctrl+Y)`,e=>e.invoke(`editor.redo`),void 0,e=>!e.invoke(`editor.canRedo`)),tt=A(`hr`,`minus`,`Horizontal Rule`,()=>k(`insertHorizontalRule`)),nt=A(`link`,`link`,`Insert Link`,e=>e.invoke(`linkDialog.show`)),rt=A(`image`,`image`,`Insert Image`,e=>e.invoke(`imageDialog.show`)),it=A(`video`,`video`,`Insert Video`,e=>e.invoke(`videoDialog.show`)),at=A(`emoji`,`emoji`,`Insert Emoji`,e=>e.invoke(`emojiDialog.show`)),ot=A(`icon`,`icon`,`Insert FA Icon`,e=>e.invoke(`iconDialog.show`)),st={name:`table`,type:`grid`,icon:`table`,tooltip:`Insert Table`,action:(e,t,n)=>{e.invoke(`editor.insertTable`,n,t),e.invoke(`editor.afterCommand`)}},ct={name:`fontSize`,type:`select`,tooltip:`Font Size`,placeholder:`Size`,selectClass:`an-select-narrow`,items:[`8px`,`10px`,`11px`,`12px`,`13px`,`14px`,`16px`,`18px`,`20px`,`24px`,`28px`,`32px`,`36px`,`48px`,`72px`],action:(e,t)=>me(t,e.layoutInfo.editable),getValue:e=>{try{let t=globalThis.getSelection();if(t?.rangeCount){let e=t.getRangeAt(0).startContainer;for(e?.nodeType===3&&(e=e.parentElement);e?.nodeType===1&&!e.style.fontSize;)e=e.parentElement;let n=e?.style.fontSize||``;if(n)return n}let n=e?.layoutInfo?.editable;return n&&n.style.fontSize||``}catch{return``}}},lt=A(`removeFormat`,`remove-format`,`Remove Format`,()=>k(`removeFormat`)),ut=A(`direction`,`direction`,`Toggle Text Direction (LTR / RTL)`,e=>{let t=e.layoutInfo.editable,n=(t.getAttribute(`dir`)||`ltr`)===`ltr`?`rtl`:`ltr`;t.setAttribute(`dir`,n),t.style.textAlign=n===`rtl`?`right`:`left`,e.invoke(`editor.afterCommand`)}),dt={name:`fontFamily`,type:`select`,tooltip:`Font Family`,action:(e,t)=>pe(t),getValue:()=>{try{return document.queryCommandValue(`fontName`)||``}catch{return``}}},ft={name:`paragraphStyle`,type:`select`,tooltip:`Paragraph Style`,placeholder:`Style`,selectClass:`an-select-style`,items:[{value:`p`,label:`Normal`},{value:`h1`,label:`H1`},{value:`h2`,label:`H2`},{value:`h3`,label:`H3`},{value:`h4`,label:`H4`},{value:`h5`,label:`H5`},{value:`h6`,label:`H6`},{value:`blockquote`,label:`Quote`},{value:`pre`,label:`Code`}],action:(e,t)=>he(t),getValue:()=>{try{let e=document.queryCommandValue(`formatBlock`).toLowerCase().replace(/[<>]/g,``);return e===`div`?`p`:e||`p`}catch{return``}}},pt={name:`lineHeight`,type:`select`,tooltip:`Line Height`,placeholder:`↕ Line`,selectClass:`an-select-narrow`,items:[`1.0`,`1.15`,`1.5`,`1.75`,`2.0`,`2.5`,`3.0`],action:(e,t)=>ke(t),getValue:()=>{try{let e=globalThis.getSelection();if(!e?.rangeCount)return``;let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),n=e.getRangeAt(0).startContainer;for(n?.nodeType===3&&(n=n.parentElement);n&&!t.has(n.tagName);)n=n.parentElement;return n&&(n.style.lineHeight||getComputedStyle(n).lineHeight)||``}catch{return``}}},mt=A(`codeview`,`code`,`HTML Code View`,e=>e.invoke(`codeview.toggle`),e=>e.invoke(`codeview.isActive`)),ht=A(`fullscreen`,`expand`,`Fullscreen`,e=>e.invoke(`fullscreen.toggle`),e=>e.invoke(`fullscreen.isActive`)),gt=A(`shortcuts`,`keyboard`,`Keyboard Shortcuts (Ctrl+Shift+/)`,e=>e.invoke(`shortcutsDialog.show`)),_t=A(`find`,`search`,`Find (Ctrl+F)`,e=>e.invoke(`findReplace.show`,`find`)),vt=A(`findReplace`,`find-replace`,`Find & Replace (Ctrl+H)`,e=>e.invoke(`findReplace.show`,`replace`)),yt=A(`inlineCode`,`inline-code`,"Inline Code (Ctrl+`)",e=>e.invoke(`editor.inlineCode`),()=>je()),bt=A(`checklist`,`checklist`,`Checklist`,e=>e.invoke(`editor.toggleChecklist`),()=>Fe()),xt=A(`print`,`print`,`Print`,e=>e.invoke(`editor.print`)),St={name:`foreColor`,type:`colorpicker`,icon:`foreColor`,tooltip:`Text Color`,defaultColor:`#e11d48`,action:(e,t)=>de(t)},Ct={name:`backColor`,type:`colorpicker`,icon:`backColor`,tooltip:`Highlight Color`,defaultColor:`#fbbf24`,action:(e,t)=>fe(t)},wt=[[ft,dt,ct,pt],[$e,et],[ze,Be,Ve,He,yt],[Ue,We],[St,Ct],[Ge,Ke,qe,Je],[Ye,Xe,bt,Ze,Qe],[tt,nt,rt,it,st,at,ot],[lt,mt,ht,_t,xt,gt]],Tt={boldBtn:ze,italicBtn:Be,underlineBtn:Ve,strikeBtn:He,superscriptBtn:Ue,subscriptBtn:We,alignLeftBtn:Ge,alignCenterBtn:Ke,alignRightBtn:qe,alignJustifyBtn:Je,ulBtn:Ye,olBtn:Xe,indentBtn:Ze,outdentBtn:Qe,undoBtn:$e,redoBtn:et,hrBtn:tt,linkBtn:nt,imageBtn:rt,videoBtn:it,emojiBtn:at,iconBtn:ot,tableBtn:st,fontSizeBtn:ct,removeFormatBtn:lt,directionBtn:ut,fontFamilyBtn:dt,paragraphStyleBtn:ft,lineHeightBtn:pt,codeviewBtn:mt,fullscreenBtn:ht,shortcutsBtn:gt,findBtn:_t,findReplaceBtn:vt,inlineCodeBtn:yt,checklistBtn:bt,printBtn:xt,foreColorBtn:St,backColorBtn:Ct,defaultToolbar:wt},j={placeholder:``,height:200,minHeight:100,maxHeight:0,focus:!1,resizable:!0,toolbar:wt,useBootstrap:!1,toolbarButtonClass:`btn btn-sm btn-light`,useFontAwesome:!0,fontAwesomeClass:`fas`,fontAwesomeAutoInject:!0,fontAwesomeCDN:`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,pasteAsPlainText:!1,pasteCleanHTML:!0,pasteStripAttributes:!1,allowImageUpload:!0,maxImageSize:5,tabSize:4,onChange:null,onFocus:null,onBlur:null,onInit:null,onImageUpload:null,onImageError:null,stickyToolbar:!1,stickyToolbarOffset:0,theme:`light`,codeHighlight:!0,codeHighlightCDN:`https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0`,cspNonce:``,externalAssetCrossOrigin:`anonymous`,externalAssetReferrerPolicy:`no-referrer`,markdownPaste:!0,historyLimit:100,historyMaxBytes:10485760,defaultFontFamily:`Arial`,defaultFontSize:`14px`,fontFamilies:[`Arial`,`Arial Black`,`Comic Sans MS`,`Courier New`,`Georgia`,`Impact`,`Tahoma`,`Times New Roman`,`Trebuchet MS`,`Verdana`],readOnly:!1,spellcheck:!0,direction:`ltr`,toolbarOverflow:`wrap`,autoSave:!1,autoSaveKey:`autumnnote-autosave`,autoSaveDelay:400,autoSaveAdapter:null,maxChars:0,maxWords:0,tableHeaderRow:!1,onSelectionChange:null,colorSwatches:[],onPaste:null,onPasteError:null,onDestroy:null,onCharLimitReached:null,onWordLimitReached:null,focusColor:null,lang:`en`,autoSaveRestore:!1,autoSaveRestoreTimeout:7,onAutoSaveRestore:null,markdownShortcuts:!0,slashMenu:!0,slashCommands:[],documentAdapters:{},collaborationAdapter:null,imageProcessor:null,blockIds:!1,maxPasteSize:5242880,minImageSize:20,bubbleToolbar:!1,bubbleToolbarItems:[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`],mention:null},Et=[`script`,`style`,`iframe`,`object`,`embed`,`form`,`base`,`template`,`link`,`meta`,`noscript`,`portal`,`frame`,`frameset`,`applet`,`animate`,`set`,`animatetransform`,`animatemotion`,`mglyph`,`malignmark`,`annotation-xml`],Dt=new Set([`button`]),Ot=[`href`,`src`,`action`,`formaction`,`xlink:href`,`poster`,`background`,`srcset`],kt=new Set([`poster`,`background`,`srcset`]),At=new Set([`ping`]),jt=new Set([`color`,`background-color`,`font-size`,`line-height`,`text-align`,`vertical-align`,`width`,`min-width`,`height`,`min-height`,`border-width`,`border-style`,`border-color`,`padding`,`white-space`]),Mt=/url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i,Nt=new Set([`www.youtube.com`,`youtube.com`,`m.youtube.com`,`www.youtube-nocookie.com`,`youtube-nocookie.com`,`player.vimeo.com`]),Pt=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Ft=new Set([`http:`,`https:`,`blob:`]),It=/^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i,Lt=`https://autumnnote.invalid/`;function M(e,t){return Rt(e,t).innerHTML}function Rt(e,{allowIframes:t=!1}={}){let n=new DOMParser().parseFromString(`<body>${e||``}</body>`,`text/html`),r=Array.from(n.querySelectorAll(`*`)),i=new Set(t?Et.filter(e=>e!==`iframe`):Et);for(let e of r){let t=e.tagName.toLowerCase();if(Dt.has(t)){e.replaceWith(...e.childNodes);continue}if(i.has(t)){e.remove();continue}if(t===`iframe`){let t=e.getAttribute(`src`);if(!t||!Vt(t)){e.remove();continue}}for(let t of Array.from(e.attributes)){if(t.name.startsWith(`on`)){e.removeAttribute(t.name);continue}if(t.name===`style`){let n=zt(t.value);n?e.setAttribute(`style`,n):e.removeAttribute(`style`);continue}if(At.has(t.name)){e.removeAttribute(t.name);continue}if(Ot.includes(t.name)){let n=t.value.trim(),r=kt.has(t.name)||t.name===`src`&&[`IMG`,`VIDEO`,`AUDIO`,`SOURCE`].includes(e.tagName),i=e.tagName===`IMG`;if(!(t.name===`srcset`?Bt(n,{allowData:i}):Ut(n,{media:r,allowData:i}))){e.removeAttribute(t.name);continue}}if(e.tagName===`IFRAME`){if(t.name===`srcdoc`){e.removeAttribute(t.name);continue}t.name===`src`&&!Vt(t.value)&&e.removeAttribute(t.name)}}if(t===`a`&&e.getAttribute(`target`)===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`),t===`input`){if(e.closest(`ul.an-checklist`)===null||e.closest(`li`)===null||e.getAttribute(`type`)!==`checkbox`)e.remove();else for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}}return n.body}function zt(e){let t=[];for(let n of(e||``).split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();!r||!i||jt.has(r)&&(Mt.test(i)||t.push(`${r}: ${i}`))}return t.join(`; `)}function Bt(e,{allowData:t=!1}={}){let n=(e||``).trim().split(/\s+/).filter(Boolean);for(let e of n){if(/^[\d.]+[xw],?$/i.test(e))continue;let n=e.replace(/,+$/,``);if(n&&!Ut(n,{media:!0,allowData:t}))return!1}return!0}function Vt(e){let t=(e||``).trim();if(!t||t.startsWith(`//`)||t.startsWith(`/`))return!1;try{let e=new URL(t);return e.protocol===`https:`&&Nt.has(e.hostname.toLowerCase())}catch{return!1}}function Ht(e,{allowData:t=!1,media:n=t}={}){let r=(e||``).trim();return!r&&e==null?null:Ut(r,{media:n,allowData:t})?e:null}function Ut(e,{media:t=!1,allowData:n=!1}={}){let r=(e||``).trim();if(!r||n&&It.test(r))return!0;try{let e=new URL(r,Lt);return(t?Ft:Pt).has(e.protocol)}catch{return!1}}function Wt(e,t){let n=m(`div`,{class:`an-container`}),r=m(`div`,{class:`an-editable`,contenteditable:t.readOnly?`false`:`true`,spellcheck:String(t.spellcheck!==!1),"aria-multiline":`true`,"aria-label":`Rich text editor`,role:`textbox`}),i=``;if(t.autoSave&&t.autoSaveKey)try{i=localStorage.getItem(t.autoSaveKey)||``}catch{}i||=e.tagName===`TEXTAREA`?(e.value||``).trim():(e.innerHTML||``).trim(),r.innerHTML=M(i,{allowIframes:!0});let a=t.defaultFontFamily||t.fontFamilies?.[0];return a&&(r.style.fontFamily=a),t.defaultFontSize&&(r.style.fontSize=t.defaultFontSize),t.height?r.style.minHeight=`${t.height}px`:t.minHeight&&(r.style.minHeight=`${t.minHeight}px`),t.maxHeight&&(r.style.maxHeight=`${t.maxHeight}px`),n.appendChild(r),t.theme===`dark`?(n.classList.add(`an-theme-dark`),document.body.classList.add(`an-theme-dark`)):t.theme===`auto`&&(n.classList.add(`an-theme-auto`),document.body.classList.add(`an-theme-auto`)),t.readOnly&&(n.classList.add(`an-disabled`),r.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})),t.direction===`rtl`&&(r.setAttribute(`dir`,`rtl`),n.classList.add(`an-dir-rtl`)),t.toolbarOverflow===`scroll`&&n.classList.add(`an-toolbar-overflow-scroll`),t.stickyToolbar&&(n.classList.add(`an-sticky-toolbar`),t.stickyToolbarOffset&&n.style.setProperty(`--an-sticky-top`,`${t.stickyToolbarOffset}px`)),t.focusColor&&n.style.setProperty(`--an-focus-color`,t.focusColor),e.style.display=`none`,e.after(n),{container:n,editable:r}}var Gt=new Map,Kt=[];function qt(e){Kt=Array.isArray(e)?e:[]}var Jt=new Map,Yt=class{constructor(e,t={}){this.targetEl=e,this.options=r(j,t),this.locale=c(this.options.lang),this.layoutInfo={},this._listeners=new Map,this._modules=new Map,this._plugins=new Map,this._disposers=[],this._alive=!1,this._autoSaveTimer=null,this._pendingAutoSave=null,this._suppressedRemoteHTML=null,this._destroyPromise=null,this._releaseInstance=null}initialize(){let{container:e,editable:t}=Wt(this.targetEl,this.options);this.layoutInfo.container=e,this.layoutInfo.editable=t,this._registerModules();let n=this._modules.get(`toolbar`);n?.el&&(e.insertBefore(n.el,t),this.layoutInfo.toolbar=n.el);let r=this._modules.get(`statusbar`);return r?.el&&(e.appendChild(r.el),this.layoutInfo.statusbar=r.el),this._bindEditorEvents(t),this.options.focus&&t.focus(),this._alive=!0,this.invoke(`toolbar.refresh`),this._applyGlobalPlugins(),typeof this.options.onInit==`function`&&this.options.onInit(this),this}_registerModules(){let e=(e,t)=>{let n=new t(this);this._modules.set(e,n),n.initialize()};for(let{name:t,Class:n,enabled:r}of Kt)typeof r==`function`&&!r(this.options)||e(t,n);if(Gt.size>0)for(let[t,n]of Gt)e(t,n)}_syncOptionalModules(){for(let{name:e,Class:t,enabled:n}of Kt){if(typeof n!=`function`)continue;let r=n(this.options);if(r!==this._modules.has(e)){if(r){let n=new t(this);this._modules.set(e,n),n.initialize()}else{let t=this._modules.get(e);typeof t?.destroy==`function`&&t.destroy(),this._modules.delete(e)}}}}registerModule(e,t){if(this._modules.has(e))return this;let n=new t(this);return n.initialize(),this._modules.set(e,n),this}registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=this.options.slashCommands||(this.options.slashCommands=[]),n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this.invoke(`slashMenu.refresh`),this}use(e,t={}){return Array.isArray(e.buttons)&&e.buttons.forEach(e=>Le(e)),this._installPlugin(e,t),this}getPlugin(e){return this._plugins.get(e)?.publicApi??null}_installPlugin(e,t={}){let{name:n}=e;if(!n||typeof n!=`string`){console.warn("[AutumnNote] Plugin must have a string `name` property.");return}if(this._plugins.has(n)){console.warn(`[AutumnNote] Plugin "${n}" already installed on this instance. Skipping.`);return}let r=typeof e.install==`function`?e.install(this,t)??null:null;this._plugins.set(n,{plugin:e,publicApi:r})}_applyGlobalPlugins(){if(Jt.size!==0)for(let{plugin:e,options:t}of Jt.values())this._installPlugin(e,t)}_bindEditorEvents(e){let t=_(e,`input`,()=>this._syncToTarget()),n=_(e,`focus`,()=>{this.layoutInfo.container.classList.add(`an-focused`),typeof this.options.onFocus==`function`&&this.options.onFocus(this)}),r=_(e,`blur`,()=>{this.layoutInfo.container.classList.remove(`an-focused`),this._syncToTarget(),typeof this.options.onBlur==`function`&&this.options.onBlur(this)}),i=this.on(`change`,e=>this._syncToTarget(e)),a=this.on(`change`,e=>{if(this.options.blockIds&&(this.ensureBlockIds(),e=this.getHTML()),e===this._suppressedRemoteHTML){this._suppressedRemoteHTML=null;return}this.options.collaborationAdapter?.onLocalChange?.(e,this)});if(this._disposers.push(t,n,r,i,a),this.options.autoSave&&this.options.autoSaveKey){let e=this.on(`change`,e=>this._scheduleAutoSave(e));this._disposers.push(e)}}_scheduleAutoSave(e){this._pendingAutoSave=e,clearTimeout(this._autoSaveTimer),this._autoSaveTimer=setTimeout(()=>this.flushAutoSave(),this.options.autoSaveDelay??400)}async flushAutoSave(){if(clearTimeout(this._autoSaveTimer),this._autoSaveTimer=null,this._pendingAutoSave==null)return;let e=this._pendingAutoSave;this._pendingAutoSave=null;let t=this.options.autoSaveKey,n=Date.now();try{let r=this.options.autoSaveAdapter;typeof r?.save==`function`?await r.save({key:t,html:e,savedAt:n,context:this}):(localStorage.setItem(t,e),localStorage.setItem(t+`:asrmeta`,JSON.stringify({savedAt:n}))),this.triggerEvent(`autoSave`,{key:t,html:e,savedAt:n})}catch(e){this.triggerEvent(`autoSaveError`,{key:t,error:e})}}async loadAutoSave(){let e=this.options.autoSaveAdapter;if(typeof e?.load==`function`)return e.load({key:this.options.autoSaveKey,context:this});try{return localStorage.getItem(this.options.autoSaveKey)}catch{return null}}invoke(e,...t){let[n,r]=e.split(`.`),i=this._modules.get(n);if(!i){console.warn(`[AutumnNote] invoke: module "${n}" not found (path: "${e}")`);return}if(typeof i[r]!=`function`){console.warn(`[AutumnNote] invoke: method "${r}" not found on module "${n}" (path: "${e}")`);return}return i[r](...t)}on(e,t){return this._listeners.has(e)||this._listeners.set(e,[]),this._listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return;let r=n.indexOf(t);r!==-1&&n.splice(r,1)}triggerEvent(e,...t){(this._listeners.get(e)||[]).forEach(e=>e(...t));let n=`on`+e.charAt(0).toUpperCase()+e.slice(1);typeof this.options[n]==`function`&&this.options[n](...t)}updateOptions(e={}){let t=r(this.options,e);Object.keys(this.options).forEach(e=>delete this.options[e]),Object.assign(this.options,t);let{container:n,editable:i}=this.layoutInfo;if(Object.hasOwn(e,`readOnly`)&&this.setDisabled(!!this.options.readOnly),Object.hasOwn(e,`spellcheck`)&&(i.spellcheck=this.options.spellcheck!==!1),Object.hasOwn(e,`placeholder`)&&(i.dataset.placeholder=this.options.placeholder||``),Object.hasOwn(e,`direction`)){let e=this.options.direction===`rtl`;i.setAttribute(`dir`,e?`rtl`:`ltr`),n.classList.toggle(`an-dir-rtl`,e)}if(Object.hasOwn(e,`height`)||Object.hasOwn(e,`minHeight`)){let e=this.options.height||this.options.minHeight||0;i.style.minHeight=e?`${e}px`:``}return Object.hasOwn(e,`maxHeight`)&&(i.style.maxHeight=this.options.maxHeight?`${this.options.maxHeight}px`:``),Object.hasOwn(e,`toolbar`)&&this.invoke(`toolbar.rebuild`),this._syncOptionalModules(),this.invoke(`statusbar.update`),this.triggerEvent(`optionsChange`,{...e}),this}getHTML(){let e=this.invoke(`editor.getHTML`);return typeof e==`string`?e.replace(//g,``):e}setHTML(e){this.invoke(`editor.setHTML`,e)}getText(){return this.invoke(`editor.getText`)}setText(e){this.invoke(`editor.setText`,e)}clear(){this.invoke(`editor.clear`)}clearHistory(){this.invoke(`editor.clearHistory`)}getUndoCount(){return this.invoke(`editor.getUndoCount`)??0}getRedoCount(){return this.invoke(`editor.getRedoCount`)??0}isEmpty(){return this.invoke(`editor.isEmpty`)}insertHTML(e){this.invoke(`editor.insertHTML`,e)}insertText(e){this.invoke(`editor.insertText`,e)}setMarkdown(e){this.invoke(`editor.setMarkdown`,e)}getMarkdown(){return this.invoke(`editor.getMarkdown`)}getSelectionBookmark(){return this.invoke(`editor.getSelectionBookmark`)??null}restoreSelectionBookmark(e){return this.invoke(`editor.restoreSelectionBookmark`,e)}async importDocument(e,t){let n=this.options.documentAdapters?.[e],r;if(typeof n?.import==`function`)r=await n.import(t,this);else if(e===`html`)r=String(t??``);else if(e===`markdown`)return this.setMarkdown(String(t??``)),this;else if(e===`text`)return this.setText(String(t??``)),this;else throw Error(`[AutumnNote] No importer registered for "${e}".`);return this.setHTML(r),this}async exportDocument(e){let t=this.options.documentAdapters?.[e];if(typeof t?.export==`function`)return t.export(this,this.getHTML());if(e===`html`)return this.getHTML();if(e===`markdown`)return this.getMarkdown();if(e===`text`)return this.getText();throw Error(`[AutumnNote] No exporter registered for "${e}".`)}ensureBlockIds(){let e=this.layoutInfo.editable.children;for(let t of e)if(!t.hasAttribute(`data-an-block-id`)){let e=globalThis.crypto?.randomUUID?.()||`an-${Date.now()}-${Math.random().toString(36).slice(2)}`;t.setAttribute(`data-an-block-id`,e)}return this}getDocument(){return this.options.blockIds&&this.ensureBlockIds(),{version:1,html:this.getHTML(),markdown:this.getMarkdown()}}loadDocument(e){return this.setHTML(e?.html||``),this.clearHistory(),this}applyRemoteHTML(e){return this.setHTML(e),this._suppressedRemoteHTML=this.getHTML(),this.clearHistory(),this}getWordCount(){return this.invoke(`statusbar.getWordCount`)??0}getCharCount(){return this.invoke(`statusbar.getCharCount`)??0}downloadHTML(e=`document.html`){this._download(this.getHTML(),e,`text/html`)}downloadText(e=`document.txt`){this._download(this.getText(),e,`text/plain`)}downloadMarkdown(e=`document.md`){this._download(this.getMarkdown(),e,`text/markdown`)}_download(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.style.display=`none`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}print(e=``){let t=this.getHTML(),n=`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>${(e||``).replace(/[<>&"']/g,e=>`&#${e.charCodeAt(0)};`)}</title><style>body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;font-size:14px;line-height:1.6;padding:20mm;color:#111827;}ul.an-checklist{list-style:none;padding-left:0;}ul.an-checklist li{padding-left:24px;position:relative;margin:2px 0;}ul.an-checklist li input[type="checkbox"]{position:absolute;left:0;top:3px;}code{background:#f3f4f6;border-radius:3px;padding:.1em .35em;font-family:monospace;}pre{background:#f3f4f6;padding:.75em 1em;border-radius:4px;overflow-x:auto;}table{border-collapse:collapse;}td,th{border:1px solid #d1d5db;padding:4px 8px;}</style></head><body>${t}</body></html>`,r=new Blob([n],{type:`text/html`}),i=URL.createObjectURL(r),a=globalThis.open(i,`_blank`);if(!a){URL.revokeObjectURL(i);return}a.addEventListener(`load`,()=>{a.print(),URL.revokeObjectURL(i)})}getTableOfContents(){return Array.from(this.layoutInfo.editable.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({level:parseInt(e.tagName[1],10),text:e.textContent?.trim()??``,element:e}))}focus(){this.layoutInfo.editable.focus()}blur(){this.layoutInfo.editable.blur()}isFullscreen(){return this.invoke(`fullscreen.isActive`)===!0}setDisabled(e){let t=this.layoutInfo.editable;e?(t.setAttribute(`contenteditable`,`false`),this.layoutInfo.container.classList.add(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})):(t.setAttribute(`contenteditable`,`true`),this.layoutInfo.container.classList.remove(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.removeAttribute(`disabled`)}))}destroy(){if(!this._alive)return this._destroyPromise??Promise.resolve();let e=this._pendingAutoSave==null?null:this.flushAutoSave().catch(()=>{});this._modules.forEach(e=>{typeof e.destroy==`function`&&e.destroy()}),this._modules.clear();for(let{plugin:e}of this._plugins.values())if(typeof e.uninstall==`function`)try{e.uninstall(this)}catch{}this._plugins.clear(),this._disposers.forEach(e=>e()),this._disposers=[];let t=this.layoutInfo.container,n=t?.classList.contains(`an-theme-dark`),r=t?.classList.contains(`an-theme-auto`);return t?.parentNode&&(this.targetEl.style.display=``,t.remove()),n&&!document.querySelector(`.an-container.an-theme-dark`)&&document.body.classList.remove(`an-theme-dark`),r&&!document.querySelector(`.an-container.an-theme-auto`)&&document.body.classList.remove(`an-theme-auto`),typeof this.options.onDestroy==`function`&&this.options.onDestroy(this),this._alive=!1,this._releaseInstance?.(),this._releaseInstance=null,this._destroyPromise=Promise.resolve(e).then(()=>{this._listeners.clear()}),this._destroyPromise}_syncToTarget(e){(this.targetEl.tagName===`TEXTAREA`||this.targetEl.tagName===`INPUT`)&&(this.targetEl.value=typeof e==`string`?e:this.getHTML())}};function Xt(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r}var Zt=class{constructor(e,t=100,n=10485760){this.editable=e,this._limit=t,this._maxBytes=n,this._bytes=0,this.stack=[],this.stackOffset=-1,this._savePoint()}_entrySize(e){let t=e.html.length;if(e.images)for(let n in e.images)t+=e.images[n].length;return t}_serialize(){return this.editable.innerHTML}_serializeSelection(){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return this.editable.contains(t.startContainer)?{start:this._charOffset(t.startContainer,t.startOffset),end:this._charOffset(t.endContainer,t.endOffset)}:null}_charOffset(e,t){try{let n=document.createRange();return n.selectNodeContents(this.editable),n.setEnd(e,t),n.toString().length}catch{return 0}}_restoreSelection(e){if(!e)return;let t=null,n=0,r=null,i=0,a=0,o=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),s;for(;s=o.nextNode();){let o=s.length;if(!t&&a+o>=e.start&&(t=s,n=e.start-a),!r&&a+o>=e.end){r=s,i=e.end-a;break}a+=o}if(!t){let e=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),a=null;for(;a=e.nextNode();)t=a;n=t?t.length:0,r=t,i=n}r||(r=t,i=n);try{let e=document.createRange();e.setStart(t,n),e.setEnd(r,i);let a=globalThis.getSelection();a.removeAllRanges(),a.addRange(e)}catch{try{let e=document.createRange();e.setStart(this.editable,0),e.collapse(!0);let t=globalThis.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}catch{}}}_savePoint(){if(this.stackOffset<this.stack.length-1){for(let e of this.stack.slice(this.stackOffset+1))this._bytes-=this._entrySize(e);this.stack=this.stack.slice(0,this.stackOffset+1)}let e=this._serialize(),{html:t,images:n}=this._tokenizeImages(e),r={html:t,images:n,sel:this._serializeSelection()};for(this.stack.push(r),this._bytes+=this._entrySize(r);this.stack.length>1&&(this.stack.length>this._limit||this._bytes>this._maxBytes);)this._bytes-=this._entrySize(this.stack.shift());this.stackOffset=this.stack.length-1}_restore(e){if(!e)return;let t=this.editable.textContent||``;this.editable.innerHTML=this._detokenizeImages(e);let n=e.sel;if(!n){let e=Xt(t,this.editable.textContent||``);n={start:e,end:e}}this._restoreSelection(n)}_tokenizeImages(e){if(!e.includes(`data:`))return{html:e,images:{}};let t={},n=0;return{html:e.replace(/data:[^;]+;base64,[^"' >]*/g,e=>{let r=`__asn_img_${n}__`;return t[r]=e,n++,r}),images:t}}_detokenizeImages(e){return!e.images||Object.keys(e.images).length===0?e.html:e.html.replace(/__asn_img_\d+__/g,t=>e.images[t]||t)}recordUndo(){let e=this._serialize(),{html:t}=this._tokenizeImages(e);this.stack[this.stackOffset]?.html!==t&&this._savePoint()}undo(){this.stackOffset<=0||(this.stackOffset--,this._restore(this.stack[this.stackOffset]))}redo(){this.stackOffset>=this.stack.length-1||(this.stackOffset++,this._restore(this.stack[this.stackOffset]))}reset(){this.stack=[],this.stackOffset=-1,this._bytes=0,this._savePoint()}canUndo(){return this.stackOffset>0}canRedo(){return this.stackOffset<this.stack.length-1}getUndoCount(){return Math.max(0,this.stackOffset)}getRedoCount(){return Math.max(0,this.stack.length-1-this.stackOffset)}};function Qt(e,t,n={}){let{headerRow:r=!1}=n,i=m(`table`,{class:`an-table`});if(r&&t>0){let t=m(`thead`),n=m(`tr`);for(let t=0;t<e;t++){let e=m(`th`,{},[document.createElement(`br`)]);n.appendChild(e)}t.appendChild(n),i.appendChild(t)}let a=r?Math.max(t-1,1):t,o=m(`tbody`);i.appendChild(o);for(let t=0;t<a;t++){let t=m(`tr`);for(let n=0;n<e;n++){let e=m(`td`,{},[document.createElement(`br`)]);t.appendChild(e)}o.appendChild(t)}return i}function $t(e,t,n={}){if(e<=0||t<=0)return;let r=Qt(e,t,n),i=globalThis.getSelection();if(!i||i.rangeCount===0)return;let a=i.getRangeAt(0);try{a.deleteContents()}catch{return}let o=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`,`PRE`]),s=a.startContainer;for(s?.nodeType===3&&(s=s.parentElement);s&&!o.has(s.tagName?.toUpperCase())&&s.parentElement;)s=s.parentElement;if(s&&o.has(s.tagName?.toUpperCase())&&s.parentNode){if(s.after(r),!r.nextElementSibling){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),r.after(e)}!s.textContent.trim()&&!s.querySelector(`img, video, table`)&&s.remove()}else try{a.insertNode(r)}catch{return}let c=r.querySelector(`td, th`);if(c){let e=document.createRange();e.setStart(c,0),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}}var N={BACKSPACE:`Backspace`,TAB:`Tab`,ENTER:`Enter`,ESCAPE:`Escape`,SPACE:` `,PAGE_UP:`PageUp`,PAGE_DOWN:`PageDown`,END:`End`,HOME:`Home`,LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,DOWN:`ArrowDown`,DELETE:`Delete`,NUM0:`0`,NUM1:`1`,NUM2:`2`,NUM3:`3`,NUM4:`4`,NUM5:`5`,NUM6:`6`,NUM7:`7`,NUM8:`8`,B:`b`,E:`e`,I:`i`,J:`j`,K:`k`,L:`l`,R:`r`,S:`s`,U:`u`,V:`v`,Y:`y`,Z:`z`,SLASH:`/`,PERIOD:`.`};function P(e,t){return e.key===t||e.key===t.toUpperCase()}function F(e,t){return(e.ctrlKey||e.metaKey)&&P(e,t)}var en=/\bfa-/,I=e=>!!(e?.nodeName===`I`&&en.test(e.className||``)),tn=e=>!(e?.nodeType!==Node.TEXT_NODE||e.textContent!==``&&e.textContent!==``);function nn(e,t,n){let r=(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest(`td, th`)??null;if(!r||!t.contains(r))return!1;let i=r.closest(`table`);if(!i||!t.contains(i))return!1;let a=Array.from(i.querySelectorAll(`td, th`)),o=a[a.indexOf(r)+(n?-1:1)];if(o)return h(o),!0;if(n)return!0;let s=rn(r.closest(`tr`))?.firstElementChild??null;return s&&h(s),!0}function rn(e){if(!e?.parentNode)return null;let t=document.createElement(`tr`);for(let n of e.cells){let e=document.createElement(`td`);e.appendChild(document.createElement(`br`)),n.hasAttribute(`style`)&&e.setAttribute(`style`,n.getAttribute(`style`)),t.appendChild(e)}return e.parentNode.insertBefore(t,e.nextSibling),t}function an(e,t){try{let n=document.createRange();return n.setStart(e.startContainer,e.startOffset),n.setEnd(t,t.childNodes.length),n.extractContents()}catch{return document.createDocumentFragment()}}function on(e,t,n={}){let r=e=>{let t=globalThis.getSelection();if(!t)return!1;let n=document.createRange();return e(n),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0};if(P(e,N.BACKSPACE)){let t=globalThis.getSelection();if(t?.rangeCount>0){let n=t.getRangeAt(0);if(n.collapsed&&n.startContainer.nodeType===Node.TEXT_NODE){let r=n.startContainer;if(n.startOffset===0&&I(r.previousSibling))return e.preventDefault(),r.previousSibling.remove(),!0;if(n.startOffset===1&&r.textContent===``&&I(r.previousSibling)){e.preventDefault();let n=r.parentNode,i=r.previousSibling,a=i.previousSibling;i.remove(),r.remove();let o=document.createRange();return a?.nodeType===Node.TEXT_NODE?o.setStart(a,a.textContent.length):a?o.setStartAfter(a):n&&o.setStart(n,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}}return!1}if(P(e,N.LEFT)||P(e,N.RIGHT)){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return!1;let n=t.getRangeAt(0);if(!n.collapsed)return!1;let i=n.startContainer,a=P(e,N.LEFT);if(i.nodeType===Node.TEXT_NODE){let t=i;if(a&&n.startOffset===1&&t.textContent===``&&I(t.previousSibling)||a&&n.startOffset===0&&I(t.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling));if(a&&n.startOffset===0&&tn(t.previousSibling)&&I(t.previousSibling.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling.previousSibling));if(!a&&n.startOffset===t.textContent.length&&I(t.nextSibling)){let n=t.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(``);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}if(!a&&n.startOffset===t.textContent.length&&tn(t.nextSibling)&&I(t.nextSibling.nextSibling)){let n=t.nextSibling.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(``);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}}if(i.nodeType===Node.ELEMENT_NODE){let t=i;if(a&&n.startOffset>0){let i=t.childNodes[n.startOffset-1];if(I(i))return e.preventDefault(),r(e=>e.setStartBefore(i));if(tn(i)&&I(i.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(i.previousSibling))}if(!a&&n.startOffset<t.childNodes.length){let i=t.childNodes[n.startOffset];if(I(i)){let t=i.nextSibling;if(e.preventDefault(),t?.nodeType===Node.TEXT_NODE){let e=+!!(t.textContent||``).startsWith(``);return r(n=>n.setStart(t,Math.min(e,t.textContent.length)))}return r(e=>e.setStartAfter(i))}if(tn(i)&&I(i.nextSibling)){let t=i.nextSibling,n=t.nextSibling;if(e.preventDefault(),n?.nodeType===Node.TEXT_NODE){let e=+!!(n.textContent||``).startsWith(``);return r(t=>t.setStart(n,Math.min(e,n.textContent.length)))}return r(e=>e.setStartAfter(t))}}}}if(P(e,N.TAB)){let r=x(t);if(!r)return!1;if(nn(r.sc,t,e.shiftKey))return e.preventDefault(),!0;let i=p(r.sc,t);if(i&&d(i))return e.preventDefault(),e.shiftKey?Se():be(),!0;if(i?.nodeName.toUpperCase()===`PRE`)return!e.shiftKey&&(e.preventDefault(),k(`insertText`,` `.repeat(n.tabSize||4)),!0);if(n.tabSize)return!e.shiftKey&&(e.preventDefault(),k(`insertText`,` `.repeat(n.tabSize)),!0)}if(P(e,N.ENTER)&&e.shiftKey)return e.preventDefault(),k(`insertLineBreak`),!0;if(P(e,N.ENTER)&&!e.shiftKey){let n=x(t);if(!n)return!1;let r=n.sc,i=r.nodeType===3?r.parentElement:r;if(i?.nodeName===`I`&&/\bfa-/.test(i.className||``)){let e=document.createRange();e.setStartAfter(i),e.collapse(!0);let t=globalThis.getSelection();return t&&(t.removeAllRanges(),t.addRange(e)),!1}let a=i?.closest(`.an-video-wrapper`);if(a){e.preventDefault();let t=document.createElement(`p`);t.innerHTML=`\xA0`,a.parentNode.insertBefore(t,a.nextSibling);let n=document.createRange();n.setStart(t,0),n.collapse(!0);let r=globalThis.getSelection();return r.removeAllRanges(),r.addRange(n),!0}let o=i?.closest(`.an-checklist li`);if(o){e.preventDefault();let t=o.closest(`.an-checklist`),n=globalThis.getSelection(),r=n.getRangeAt(0);if(!(e=>Array.from(e.childNodes).filter(e=>e.nodeType!==1||e.tagName!==`INPUT`).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim())(o)){let e=document.createElement(`p`);e.innerHTML=`\xA0`,t.parentNode.insertBefore(e,t.nextSibling),o.remove(),t.children.length===0&&t.remove();let r=document.createRange();return r.setStart(e.firstChild,0),r.collapse(!0),n.removeAllRanges(),n.addRange(r),!0}if(!r.collapsed){if(r.deleteContents(),n.rangeCount===0||!o.isConnected)return!0;r=n.getRangeAt(0)}let i=an(r,o),a=document.createElement(`li`),s=document.createElement(`input`);s.type=`checkbox`,s.setAttribute(`contenteditable`,`false`),a.appendChild(s),i.textContent.replace(/[\u00a0\u200B]/g,``).length>0&&a.appendChild(i);let c=a.childNodes[1];c?.nodeType!==Node.TEXT_NODE&&(c=document.createTextNode(``),a.appendChild(c)),o.after(a);let l=document.createRange();return l.setStart(c,0),l.collapse(!0),n.removeAllRanges(),n.addRange(l),!0}let s=p(n.sc,t);if(s?.nodeName.toUpperCase()===`PRE`)return e.preventDefault(),k(`insertText`,`
|
|
5
5
|
`),!0;if(s?.nodeName.toUpperCase()===`BLOCKQUOTE`){let t=n.toNativeRange();if(t.setEnd(s,s.childNodes.length),t.toString()===``&&n.isCollapsed())return e.preventDefault(),k(`formatBlock`,`<p>`),!0}}return!1}var sn=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`word`}):null;function cn(e){let t=e.trim();if(!t)return 0;if(sn){let e=0;for(let n of sn.segment(t))n.isWordLike&&e++;return e}return t.split(/\s+/).length}var ln=new Set(`ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.BR.DD.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL`.split(`.`));function un(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)if(r.nodeType===3){let e=r.data;t.push(e),n.push(e)}else if(r.nodeType===1){let e=ln.has(r.tagName);e&&t.push(`
|
|
6
6
|
`),un(r,t,n),e&&t.push(`
|
|
7
7
|
`)}}function dn(e){if(e.nodeType===3){let t=e.data;return{lines:t,flat:t}}let t=[],n=[];return un(e,t,n),{lines:t.join(``),flat:n.join(``)}}var fn=class{constructor(){this._cache=new WeakMap}counts(e){let t=0,n=0,r=[],i=[],a=0;for(let o=e.firstChild;o;o=o.nextSibling){let e=this._cache.get(o);if(e&&e.key===(o.textContent||``)){t+=e.words,n+=e.chars;continue}let{lines:s,flat:c}=dn(o);r.push({node:o,key:c,text:s,start:a}),i.push(s),a+=s.length+1}if(r.length){let e=pn(r,i.join(`
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
`);t=In(t);let n=Ln(t);return t=n.clean,Pn=n.linkDefs,Fn=n.footnoteIds,Nn(t)}function Nn(e){let t=[],n=0;for(;n<e.length;){let r=e[n],i=On(r);if(i){let r=RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`),a=[];for(n++;n<e.length&&!r.test(e[n]);)a.push(or(kn(e[n],i.indent))),n++;let o=i.lang?` class="language-${z(i.lang)}"`:``;t.push(`<pre><code${o}>${a.join(`
|
|
36
36
|
`)}</code></pre>`),n++;continue}if(En.test(r)){let r=[];for(;n<e.length&&(En.test(e[n])||e[n].trim()===``);){if(e[n].trim()===``){let t=n;for(;t<e.length&&e[t].trim()===``;)t++;if(t>=e.length||!En.test(e[t]))break;for(;n<t;n++)r.push(``);continue}r.push(or(kn(e[n],4))),n++}t.push(`<pre><code>${r.join(`
|
|
37
37
|
`)}</code></pre>`);continue}if(r.trim()&&!An.test(r)&&!/^#{1,6} /.test(r)&&n+1<e.length){if(/^=+\s*$/.test(e[n+1])){t.push(`<h1>${R(r.trim())}</h1>`),n+=2;continue}if(/^-{2,}\s*$/.test(e[n+1])){t.push(`<h2>${R(r.trim())}</h2>`),n+=2;continue}}if(An.test(r)){t.push(`<hr>`),n++;continue}let a=/^(#{1,6})[ \t]+(.*)$/.exec(r);if(a){let e=a[1].length,r=a[2].replace(/(?:^|\s)#+\s*$/,``);t.push(`<h${e}>${R(r)}</h${e}>`),n++;continue}if(Tn.test(r)){let r=[];for(;n<e.length&&Tn.test(e[n]);)r.push(Tn.exec(e[n])[2]),n++;t.push(`<blockquote>${Nn(r)}</blockquote>`);continue}if(/^[-*+] /.test(r)){let{html:r,endIdx:i}=Un(e,n);t.push(r),n=i;continue}if(/^\d+[.)] /.test(r)){let{html:r,endIdx:i}=Un(e,n);t.push(r),n=i;continue}if(r.trim()===``){n++;continue}if(Vn(e,n)){let i=Hn(r),a=Hn(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:e.startsWith(`:`)?`left`:null);n+=2;let o=[];for(;n<e.length&&e[n].trim()!==``&&Bn(e[n]);)o.push(Hn(e[n])),n++;let s=(e,t,n)=>`<${e}${n?` style="text-align:${n}"`:``}>${R(t)}</${e}>`,c=`<thead><tr>${i.map((e,t)=>s(`th`,e,a[t])).join(``)}</tr></thead>`,l=o.length?`<tbody>${o.map(e=>`<tr>${e.map((e,t)=>s(`td`,e,a[t])).join(``)}</tr>`).join(``)}</tbody>`:``;t.push(`<table>${c}${l}</table>`);continue}let o=[];for(;n<e.length&&e[n].trim()!==``&&!/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n])&&!On(e[n])&&!Tn.test(e[n])&&!An.test(e[n])&&!Vn(e,n)&&!(n+1<e.length&&/^=+\s*$/.test(e[n+1]))&&!(n+1<e.length&&/^-{2,}\s*$/.test(e[n+1]));)o.push(e[n]),n++;o.length?t.push(`<p>${R(Rn(o)).replaceAll(jn,`<br>`)}</p>`):(t.push(`<p>${R(r)}</p>`),n++)}return t.join(``)}var Pn=new Map,Fn=new Set;function In(e){if((e[0]||``).trim()!==`---`)return e;let t=-1;for(let n=1;n<e.length;n++){let r=e[n].trim();if(r===`---`||r===`...`){t=n;break}}if(t===-1||!e.slice(1,t).every(e=>e.trim()===``||/^[ \t]*[\w$.-]+\s*:(\s|$)/.test(e)||/^[ \t]*-\s+\S/.test(e)||/^[ \t]+\S/.test(e)))return e;let n=t+1;return e[n]!==void 0&&e[n].trim()===``&&n++,e.slice(n)}function Ln(e){let t=new Map,n=new Set,r=[],i=!1,a=/^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/,o=/^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;for(let s of e){if(i){/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s)&&(i=!1),r.push(s);continue}if(On(s)){i=!0,r.push(s);continue}{let e=o.exec(s);if(e){n.add(e[1]);continue}let r=a.exec(s);if(r){t.set(r[1].trim().toLowerCase(),{href:r[2],title:r[3]});continue}}r.push(s)}return{clean:r,linkDefs:t,footnoteIds:n}}function Rn(e){let t=``;for(let n=0;n<e.length;n++){let r=n===e.length-1,i=e[n].replace(/^[ \t]+/,``);if(!r&&/\\$/.test(i)){t+=i.replace(/\\$/,``)+jn;continue}if(!r&&/ {2,}$/.test(i)){t+=i.replace(/ {2,}$/,``)+jn;continue}t+=i+(r?``:` `)}return t}function zn(e){return Hn(e).length}function Bn(e){return e.includes(`|`)?/^\s*\|/.test(e)||zn(e)>1:!1}function Vn(e,t){let n=e[t],r=e[t+1];if(r===void 0||!n.includes(`|`))return!1;if(/^\|.+\|/.test(n))return/^\|[\s|:-]+\|/.test(r);let i=Hn(r);return i.length<2||!i.every(e=>/^:?-+:?$/.test(e))?!1:zn(n)===i.length}function Hn(e){let t=e.replace(/^\|/,``).replace(/\|$/,``),n=[],r=``;for(let e=0;e<t.length;e++){if(t[e]===`\\`&&t[e+1]===`|`){r+=`|`,e++;continue}if(t[e]===`|`){n.push(r),r=``;continue}r+=t[e]}return n.push(r),n.map(e=>e.trim())}function Un(e,t){let n=e[t].match(/^(\s*)/)[1].length,r=/^\s*\d+[.)] /.test(e[t]),i=[],a=null,o=!1,s=!1,c=t;for(;c<e.length;){let t=e[c];if(t.trim()===``){let t=e[c+1],a=t===void 0?-1:t.match(/^(\s*)/)[1].length,l=t!==void 0&&/^\s*(?:[-*+]|\d+[.)]) /.test(t)&&/^\s*\d+[.)] /.test(t)===r&&a===n,u=t!==void 0&&t.trim()!==``&&a>n;if(!i.length||!l&&!u)break;o=!0,s=!0,c++;continue}let l=t.match(/^(\s*)/)[1].length;if(l<n)break;if(l===n){if(!/^\s*(?:[-*+]|\d+[.)]) /.test(t)||/^\s*\d+[.)] /.test(t)!==r)break;let e=r?t.replace(/^\s*\d+[.)] /,``):t.replace(/^\s*[-*+] /,``),n=!r&&/^\[[ xX]\]\s+/.test(e);if(a===null&&(a=n),n!==a)break;let o=n&&e[1].toLowerCase()===`x`,l=n?e.replace(/^\[[ xX]\]\s+/,``):e;i.push({paras:[l],isCB:n,checked:o,sub:``}),s=!1,c++}else{if(!i.length){c++;continue}let n=e=>kn(e,l),r=On(n(t));if(r){let t=RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`),a=[n(e[c])];for(c++;c<e.length&&!t.test(n(e[c]));)a.push(n(e[c])),c++;c<e.length&&(a.push(n(e[c])),c++),i[i.length-1].sub+=Nn(a),s=!1;continue}if(/^\s*(?:[-*+]|\d+[.)]) /.test(t)){let t=Un(e,c);i[i.length-1].sub+=t.html,c=t.endIdx,s=!1}else if(s)i[i.length-1].paras.push(t.trim()),s=!1,c++;else{let e=i[i.length-1].paras;e[e.length-1]+=` `+t.trim(),c++}}}let l=!r&&a===!0,u=r?/^\s*(\d+)[.)] /.exec(e[t]):null,d=u?Number.parseInt(u[1],10):1,f=r?d===1?`<ol>`:`<ol start="${d}">`:l?`<ul class="an-checklist">`:`<ul>`,p=r?`</ol>`:`</ul>`;return{html:`${f}${i.map(({paras:e,isCB:t,checked:n,sub:r})=>{let i=t?`<input type="checkbox" contenteditable="false"${n?` checked`:``}>`:``;return`<li>${o?e.map((e,t)=>`<p>${t===0?i:``}${R(e)}</p>`).join(``):`${i}${R(e[0])}`}${r}</li>`}).join(``)}${p}`,endIdx:c}}var Wn=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,L=`\0`,Gn=``,Kn=/(`+)([^]*?)\1/g;function qn(e){let t=[];return{text:e.replace(Kn,(e,n,r)=>r===``?e:(t.push(r),`${Gn}${t.length-1}${Gn}`)),codes:t}}function Jn(e,t,n){return e.replace(RegExp(`${Gn}(\\d+)${Gn}`,`g`),(e,r)=>{let i=t[Number(r)];return i=i.replace(RegExp(`${L}(\\d+)${L}`,`g`),(e,t)=>`\\${n[Number(t)]}`),i.length>2&&i.startsWith(` `)&&i.endsWith(` `)&&i.trim()!==``&&(i=i.slice(1,-1)),`<code>${or(i)}</code>`})}function Yn(e){let t=[];return{text:e.replace(Wn,(e,n)=>(t.push(n),`${L}${t.length-1}${L}`)),literals:t}}function Xn(e,t){return e.replace(RegExp(`${L}(\\d+)${L}`,`g`),(e,n)=>ar(t[Number(n)]))}var Zn=String.raw`(<.*?>(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`,Qn=new RegExp(String.raw`!\[([^\]]*)\]\(${Zn}\)`,`g`),$n=new RegExp(String.raw`\[([^\]]+)\]\(${Zn}\)`,`g`);function er(e){let t=e.trim(),n=/^<([\s\S]*?)>(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);if(n)return{href:n[1],title:n[2]??n[3]??``};let r=/^(\S+)\s+(?:"([^"]*)"|'([^']*)')\s*$/.exec(t);return r?{href:r[1],title:r[2]??r[3]??``}:{href:t,title:``}}function tr(e){return e=e.replace(Qn,(e,t,n)=>{let{href:r,title:i}=er(n),a=i?` title="${B(i)}"`:``;return`<img src="${B(r)}" alt="${B(t)}"${a} class="an-image">`}),e=e.replace($n,(e,t,n)=>{let{href:r,title:i}=er(n),a=i?` title="${B(i)}"`:``;return`<a href="${B(r)}"${a}>${t}</a>`}),e=e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g,(e,t,n)=>{let r=Pn.get(sr(n||t).trim().toLowerCase());if(!r)return e;let i=r.title?` title="${z(r.title)}"`:``;return`<a href="${z(r.href)}"${i}>${t}</a>`}),e=e.replace(/\[([^\]]+)\]/g,(e,t)=>{let n=Pn.get(sr(t).trim().toLowerCase());if(!n)return e;let r=n.title?` title="${z(n.title)}"`:``;return`<a href="${z(n.href)}"${r}>${t}</a>`}),e=e.replace(/\[\^([^\]]+)\]/g,(e,t)=>Fn.has(sr(t))?`<sup>[${t}]</sup>`:e),e}function nr(e){return e=e.replace(/<(https?:\/\/[^\s&]+?)>/g,(e,t)=>`<a href="${B(t)}">${t}</a>`),e=e.replace(/<([\w.!#$%&'*+/=?^`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)>/g,(e,t)=>`<a href="mailto:${B(t)}">${t}</a>`),e=e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g,(e,t,n)=>{let r=/[.,;:!?)]+$/.exec(n),i=r?n.slice(0,-r[0].length):n;if(!i)return e;let a=r?r[0]:``;return`${t}<a href="${B(i)}">${i}</a>${a}`}),e}function rr(e){return e=e.replace(/\*{3}([^*\n]+?)\*{3}/g,(e,t)=>`<strong><em>${t}</em></strong>`),e=e.replace(/(?<!\w)_{3}([^_\n]+?)_{3}(?!\w)/g,(e,t)=>`<strong><em>${t}</em></strong>`),e=e.replace(/\*{2}([^*\n]+?)\*{2}/g,(e,t)=>`<strong>${t}</strong>`),e=e.replace(/(?<!\w)_{2}([^_\n]+?)_{2}(?!\w)/g,(e,t)=>`<strong>${t}</strong>`),e=e.replace(/\*([^*\n]+?)\*/g,(e,t)=>`<em>${t}</em>`),e=e.replace(/(?<!\w)_([^_\n]+?)_(?!\w)/g,(e,t)=>`<em>${t}</em>`),e=e.replace(/~~([^~\n]+?)~~/g,(e,t)=>`<del>${t}</del>`),e}function R(e){let{text:t,literals:n}=Yn(e),{text:r,codes:i}=qn(t),a=ar(r);return a=tr(a),a=nr(a),a=rr(a),Jn(Xn(a,n),i,n)}var ir=/&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;function ar(e){return String(e).replace(ir,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function or(e){return String(e).replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function z(e){return String(e).replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`'`,`'`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function B(e){return String(e).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function sr(e){return String(e).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`&`,`&`)}var cr=5,lr=2,ur=[[`typescript`,`javascript`],[`scss`,`css`],[`cpp`,`c`]],dr=[{lang:`php`,w:10,re:/<\?php\b|<\?=/},{lang:`bash`,w:10,re:/^#!.*\/(?:ba|z|da|fi|k)?sh\b/m},{lang:`rust`,w:10,re:/\b(?:println!|print!|format!|vec!|panic!)\s*[([]/},{lang:`go`,w:10,re:/\bfmt\.(?:Print|Println|Printf|Sprintf|Errorf|Fprintf)\s*\(/},{lang:`java`,w:10,re:/\bSystem\.out\.(?:print|println)\s*\(/},{lang:`csharp`,w:10,re:/\bConsole\.(?:Write|WriteLine)\s*\(/},{lang:`cpp`,w:10,re:/\b(?:cout|cerr)\s*<<|\bcin\s*>>|\busing\s+namespace\s+std\b|\bstd::\w/},{lang:`python`,w:10,re:/\bdef[ \t]+\w+[ \t]*\([^)]*\)[ \t]*(?:->[^:\n]*)?:|\bif[ \t]+__name__[ \t]*==[ \t]*['"]__main__['"]/},{lang:`html`,w:10,re:/^\s*<!DOCTYPE\s+html/i},{lang:`xml`,w:10,re:/^\s*<\?xml\s/i},{lang:`javascript`,w:6,re:/\bconsole\.(?:log|error|warn|info|debug)\s*\(/},{lang:`javascript`,w:6,re:/\b(?:const|let)\s+\w+\s*=|(?:^|\n)\s*var\s+\w+\s*=/},{lang:`javascript`,w:8,re:/\bexport\s+(?:default|const|function|class|async|\{|\*)|\bmodule\.exports\b|\brequire\s*\(\s*['"]/},{lang:`javascript`,w:5,re:/\bfunction(?:[ \t]+\w+)?[ \t]*\([^)]*\)[ \t]*\{|=>[ \t]*[{([`\w'"]/},{lang:`javascript`,w:5,re:/\bimport\b[^'"\n]*[ \t]from[ \t]*['"]/},{lang:`javascript`,w:4,re:/\.(?:map|filter|forEach|reduce|then|catch|find|some|every)\s*\(/},{lang:`javascript`,w:4,re:/\b(?:document|window|globalThis)\.\w/},{lang:`javascript`,w:4,re:/\baddEventListener\s*\(|\bquerySelector(?:All)?\s*\(|\bgetElementById\s*\(/},{lang:`javascript`,w:3,re:/\.(?:innerHTML|textContent|classList|dataset|style)\b|\bJSON\.(?:parse|stringify)\s*\(/},{lang:`javascript`,w:4,re:/\bawait\s+\w|\basync\s+(?:function|\(|\w+\s*=>)|\bnew\s+Promise\s*\(/},{lang:`javascript`,w:3,re:/\bReact\.|\buseState\s*\(|\buseEffect\s*\(/},{lang:`typescript`,w:8,re:/\binterface\s+\w+(?:<[^>]*>)?\s*(?:extends\s[\w<>, ]+)?\{/},{lang:`typescript`,w:8,re:/\btype\s+\w+(?:<[^>]*>)?\s*=/},{lang:`typescript`,w:7,re:/:\s*(?:string|number|boolean|void|never|any|unknown|object)\b/},{lang:`typescript`,w:6,re:/\benum\s+\w+\s*\{|\breadonly\s+\w|\bimplements\s+\w|\bnamespace\s+\w+\s*\{/},{lang:`typescript`,w:6,re:/\b(?:private|public|protected)\s+(?:readonly\s+)?\w+\s*[:?]/},{lang:`typescript`,w:5,re:/\)\s*:\s*[A-Z]\w*(?:<[^>]*>)?\s*(?:\{|=>)|\)\s*:\s*(?:string|number|boolean|void)\b/},{lang:`typescript`,w:4,re:/\bfunction\s+\w+\s*<[^>]+>\s*\(|\bas\s+(?:const\b|[A-Z]\w*)/},{lang:`typescript`,w:3,re:/\w\?\s*:\s*\w|\bimport\s+type\b|\bsatisfies\b/},{lang:`python`,w:6,re:/(?:^|\n)\s*(?:from\s+[\w.]+\s+import\s|import\s+\w+(?:\s*,\s*\w+)*\s*$)/m},{lang:`python`,w:6,re:/(?:^|\n)\s*class\s+\w+(?:\([\w., ]*\))?\s*:/},{lang:`python`,w:5,re:/(?:^|\n)\s*(?:with|elif|except|finally|async\s+def)\b[^\n]*:/},{lang:`python`,w:5,re:/\bself\.\w|\b__init__\b|\bf["'][^"']*\{/},{lang:`python`,w:4,re:/(?:^|\n)[ \t]*for[ \t]+\w+[ \t]+in[ \t][^\n:]*:|\bfor[ \t]+\w+[ \t]+in[ \t]+range[ \t]*\(/},{lang:`python`,w:4,re:/\bprint\s*\(|\blen\s*\(|\brange\s*\(/},{lang:`python`,w:3,re:/\[[^\]\n]*\bfor\s+\w+\s+in\s[^\]\n]*\]|\bNone\b|\bTrue\b|\bFalse\b/},{lang:`python`,w:3,re:/\*\*\w|\bdict[ \t]*\(|\blambda(?:[ \t]+\w+)?[ \t]*:/},{lang:`go`,w:8,re:/(?:^|\n)\s*package\s+\w+\s*$/m},{lang:`go`,w:6,re:/\btype\s+\w+\s+struct\s*\{|\btype\s+\w+\s+interface\s*\{/},{lang:`go`,w:6,re:/\bfunc(?:[ \t]*\([^)]*\))?(?:[ \t]+\w+)?[ \t]*\([^)]*\)[^\n{]{0,40}\{/},{lang:`go`,w:5,re:/\bif\s+err\s*!=\s*nil\b|\berr\s*:=\s|\bdefer\s+\w/},{lang:`go`,w:4,re:/\w+\s*:=\s*\S|\bchan\s+\w|\bgo\s+func\b|\bnil\b/},{lang:`rust`,w:7,re:/\bfn[ \t]+\w+(?:<[^>]*>)?[ \t]*\([^)]*\)[^\n{]{0,40}\{/},{lang:`rust`,w:7,re:/\blet\s+mut\s+\w|\bpub\s+(?:fn|struct|enum|mod|use)\b|\bimpl\s+\w/},{lang:`rust`,w:5,re:/\buse\s+(?:std|crate|self|super)::|\bmatch\s+\w+\s*\{[^}]*=>/},{lang:`rust`,w:4,re:/\b(?:Option|Result|Vec|Box|Rc|Arc|HashMap)\s*<|&(?:mut\s+)?self\b|\b\w+::<|->\s*Result</},{lang:`rust`,w:3,re:/\b(?:i8|i16|i32|i64|u8|u16|u32|u64|usize|isize|f32|f64)\b|\bunwrap\s*\(\)|\bderive\s*\(/},{lang:`java`,w:7,re:/\b(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)?(?:void|int|long|double|boolean|String|[A-Z]\w*(?:<[^>]*>)?)\s+\w+\s*[({]/},{lang:`java`,w:7,re:/\bimport\s+(?:java|javax|org\.springframework)\.[\w.]+;/},{lang:`java`,w:6,re:/@(?:Override|Autowired|Component|Service|Controller|RestController|Entity|Test|SpringBootApplication)\b/},{lang:`java`,w:5,re:/\bnew\s+(?:ArrayList|HashMap|HashSet|LinkedList|StringBuilder)\s*<[^>]*>\s*\(|\bthrows\s+\w*Exception/},{lang:`java`,w:4,re:/\bpublic\s+(?:class|interface|enum)\s+\w|\bextends\s+\w+\s*\{|\bList<\w|\bMap<\w/},{lang:`csharp`,w:8,re:/\busing\s+System(?:\.[\w.]+)?\s*;|\bnamespace\s+[\w.]+\s*[{;]/},{lang:`csharp`,w:8,re:/\{\s*get;\s*(?:private\s+)?set;\s*\}|\b(?:public|private|protected|internal)\s+(?:static\s+)?async\s+Task(?:<[^>]*>)?\s+\w/},{lang:`csharp`,w:6,re:/\basync\s+Task(?:<[^>]*>)?\s+\w|\bawait\s+\w+\.\w+Async\s*\(/},{lang:`csharp`,w:5,re:/\bIEnumerable<|\bvar\s+\w+\s*=\s*new\s+\w|\bpublic\s+override\b|\[\s*(?:HttpGet|HttpPost|Serializable|Required)\s*\]/},{lang:`csharp`,w:3,re:/\.(?:Select|Where|FirstOrDefault|ToList|Any)\s*\(|\bstring\[\]\s+args\b/},{lang:`kotlin`,w:8,re:/\bfun\s+\w+\s*\([^)]*\)\s*(?::\s*[\w<>?.]+\s*)?[={]|\bdata\s+class\s+\w/},{lang:`kotlin`,w:6,re:/\bval[ \t]+\w+(?:[ \t]*:[ \t]*[\w<>?.]+)?[ \t]*=|\bcompanion[ \t]+object\b|\bsuspend[ \t]+fun\b/},{lang:`kotlin`,w:4,re:/\bprintln\s*\(|\bwhen\s*\([^)]*\)\s*\{|\bobject\s+\w+\s*[:{]|\?:\s*\w/},{lang:`swift`,w:8,re:/\bguard\s+(?:let|var)\s[^\n]*\belse\b|\bfunc\s+\w+\s*\([^)]*\)\s*(?:async\s+)?(?:throws\s+)?->\s*[\w<>?[\]]/},{lang:`swift`,w:6,re:/\bprotocol[ \t]+\w+[^\n{]{0,40}\{|\bextension[ \t]+\w+[^\n{]{0,40}\{|\bimport[ \t]+(?:SwiftUI|UIKit|Foundation)\b/},{lang:`swift`,w:6,re:/\b(?:let|var)\s+\w+\s*:\s*(?:Int|String|Double|Float|Bool|Character|Any|\[[A-Z])|@(?:State|Binding|Published|IBOutlet|objc)\b/},{lang:`swift`,w:4,re:/\\\(\w|\bif[ \t]+let[ \t]+\w|\bstruct[ \t]+\w+[ \t]*:[ \t]*View\b|\bfunc[ \t]+\w+[ \t]*\([^)]*:[ \t]*[A-Z]/},{lang:`swift`,w:3,re:/\?\?\s*\w|\b\w+\?\.\w|\bself\.\w+\s*=/},{lang:`cpp`,w:8,re:/#include\s*<(?:iostream|vector|map|set|algorithm|string|memory|utility)>/},{lang:`cpp`,w:6,re:/\btemplate\s*<\s*(?:typename|class)\b|\bnullptr\b|\bnamespace\s+\w+\s*\{/},{lang:`c`,w:8,re:/#include\s*<(?:stdio|stdlib|string|math|time|ctype|unistd)\.h>/},{lang:`c`,w:6,re:/\b(?:printf|scanf|malloc|calloc|free|memcpy|strlen)\s*\(/},{lang:`c`,w:4,re:/\bint\s+main\s*\(\s*(?:void|int\s+argc|\)\s*\{)/},{lang:`c`,w:3,re:/\btypedef\s+struct\b|\bsizeof\s*\(|\bNULL\b/},{lang:`ruby`,w:8,re:/\bdo[ \t]*\|[ \t]*\w[\w, ]*\|/},{lang:`ruby`,w:7,re:/\battr_(?:accessor|reader|writer)\s+:|\brequire(?:_relative)?\s+['"]|\bputs\s+\S/},{lang:`ruby`,w:4,re:/(?:^|\n)[ \t]*def[ \t]+\w/},{lang:`ruby`,w:4,re:/(?:^|\n)[ \t]*end[ \t]*$/m},{lang:`ruby`,w:4,re:/\bnil\?\b|\b\w+\.new\b|=>\s*['"\w]|\bmodule\s+[A-Z]\w*\s*$/m},{lang:`ruby`,w:3,re:/:\w+[ \t]*=>|\bend[ \t]*$/m},{lang:`php`,w:7,re:/\$this->\w|\bfunction\s+\w+\s*\([^)]*\$\w/},{lang:`php`,w:6,re:/\$\w+\s*=\s*\S|\bforeach\s*\(\s*\$\w+\s+as\s+\$/},{lang:`php`,w:5,re:/\becho[ \t][^;\n]*[$'"]|\bnamespace[ \t]+[\w\\]+;|\buse[ \t]+[\w\\]+\\\w+;/},{lang:`php`,w:8,re:/\b(?:public|private|protected)\s+(?:static\s+)?function\s+\w/},{lang:`php`,w:3,re:/->\w+\s*\(|::\w+\s*\(/},{lang:`html`,w:7,re:/<(?:html|head|body|nav|section|article|header|footer|main|form)\b[^>]*>/i},{lang:`html`,w:5,re:/<(?:div|p|span|a|img|ul|ol|li|table|tr|td|input|button|h[1-6])\b[^>]*>[\s\S]*<\/(?:div|p|span|a|ul|ol|li|table|tr|td|button|h[1-6])>/i},{lang:`html`,w:4,re:/<\w+\s+(?:class|id|href|src|type|style)\s*=\s*["']/i},{lang:`xml`,w:6,re:/\bxmlns(?::\w+)?\s*=\s*["']|<\/\w+:\w+>|<\w+:\w+[\s>]/},{lang:`json`,w:8,re:/^\s*[{[][\s\S]*"[\w-]+"\s*:\s*(?:"[^"]*"|-?\d|\{|\[|true|false|null)/},{lang:`json`,w:3,re:/^\s*\{[\s\S]*\}\s*$|^\s*\[[\s\S]*\]\s*$/},{lang:`yaml`,w:8,re:/^---\s*$/m},{lang:`yaml`,w:6,re:/^[ \t]*-\s+\w+\s*:\s*\S/m},{lang:`yaml`,w:5,re:/^[a-z_][\w-]*[ \t]*:(?:[ \t]*$|[ \t]+(?:[|>][-+]?[ \t]*$|['"\w[{]))/im},{lang:`yaml`,w:4,re:/^[ \t]+[a-z_][\w-]*[ \t]*:[ \t]*\S/im},{lang:`yaml`,w:3,re:/^[ \t]*-\s+\S/m},{lang:`markdown`,w:7,re:/^#{1,6}\s+\S/m},{lang:`markdown`,w:6,re:/^```|^\|[^\n|]+\|[^\n]*\n\s*\|[\s:|-]+\|/m},{lang:`markdown`,w:4,re:/\[[^\]\n]+\]\([^)\n]+\)|!\[[^\]\n]*\]\(/},{lang:`markdown`,w:3,re:/\*\*[^*\n]+\*\*|^>\s+\S|^[-*+]\s+\S/m},{lang:`sql`,w:9,re:/(?:^|\n)\s*(?:SELECT\s+[\w*]|INSERT\s+INTO\s|UPDATE\s+\w+\s+SET\s|DELETE\s+FROM\s)/i},{lang:`sql`,w:8,re:/(?:^|\n)\s*(?:CREATE|ALTER|DROP)\s+(?:TABLE|DATABASE|INDEX|VIEW|SCHEMA)\b/i},{lang:`sql`,w:4,re:/\b(?:INNER|LEFT|RIGHT|FULL)\s+(?:OUTER\s+)?JOIN\b|\bGROUP\s+BY\b|\bORDER\s+BY\b|\bWITH\s+\w+\s+AS\s*\(/i},{lang:`scss`,w:9,re:/^[ \t]*\$[\w-]+[ \t]*:[^;\n]+;|@(?:mixin|include|extend|use|forward)[ \t]+[\w"'-]/m},{lang:`scss`,w:7,re:/^[ \t]*&[\s.:[&>+~]|#\{[^}]*\}/m},{lang:`scss`,w:4,re:/^[ \t]*\/\/[ \t]*\S/m},{lang:`css`,w:6,re:/^[ \t]*(?!(?:export|import|return|function|const|let|var|val|if|else|for|while|switch|case|class|new|public|private|protected|internal|def|func|fun|fn|pub|package|type|interface|enum|struct|impl|trait|mod|use|using|namespace|module|data|object|async|await|guard|extension|protocol|template|typedef)\b)[.#]?[\w-]+[^{}\n]{0,60}\{[^{}:]*:[^{};]+[;}]/m},{lang:`css`,w:5,re:/@(?:media|supports|keyframes|font-face|import|charset)\b/},{lang:`css`,w:4,re:/:\s*(?:#[\da-f]{3,8}|\d+(?:px|rem|em|%|vh|vw)|flex|grid|block|none|absolute|relative)\s*[;}]/i},{lang:`css`,w:3,re:/::?(?:hover|focus|active|before|after|first-child|last-child|nth-child)\b/},{lang:`bash`,w:7,re:/(?:^|\n|&&|\|\|)\s*(?:sudo\s+)?(?:apt(?:-get)?|yum|brew|npm|pnpm|yarn|pip3?|docker|kubectl|git|systemctl|curl|wget|chmod|chown|mkdir|rm|cp|mv|tar|ssh|scp)\s+[\w./-]/},{lang:`bash`,w:6,re:/^\s*(?:export|source|alias)\s+\w+|^\s*\w+=\S+\s*$/m},{lang:`bash`,w:6,re:/\bfi[ \t]*$|(?:^|\n)[ \t]*(?:if|for|while)[ \t][^\n]*;[ \t]*(?:then|do)\b|(?:^|\n)[ \t]*done\b/m},{lang:`bash`,w:5,re:/\$\{?\w+\}?[/:]|"\$\w|\becho\s+["'$]|\$\(\w/},{lang:`bash`,w:4,re:/(?:^|\n|\|)\s*(?:grep|awk|sed|cat|ls|cd|pwd|find|xargs|head|tail|sort|uniq|wc)\s+[-\w$'"./]/},{lang:`bash`,w:3,re:/\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/}],fr=4e3;function pr(e){if(e.length<=fr)return e;let t=e.slice(0,fr),n=t.lastIndexOf(`
|
|
38
|
-
`);return n>0?t.slice(0,n):t}function mr(e){if(!e?.trim())return null;let t=pr(e.trim()),n=new Map;for(let{lang:e,re:r,w:i}of dr)r.test(t)&&n.set(e,(n.get(e)||0)+i);if(n.size===0)return null;for(let[e,t]of ur){let r=n.get(e);r&&n.set(e,r+(n.get(t)||0))}let r=[...n.entries()].sort((e,t)=>t[1]-e[1]),[i,a]=r[0],o=r[1]?.[1]??0;return a<cr||a-o<lr?null:i}var hr=new Set([`PRE`,`BLOCKQUOTE`,`TABLE`,`FIGURE`,`UL`,`OL`,`HR`]),gr=class{constructor(e){this.context=e,this.options=e.options,this._history=null,this._disposers=[],this._snapshotTimer=null,this._limitCounter=null}initialize(){let e=this.context.layoutInfo.editable;return this._history=new Zt(e,this.options.historyLimit||100,this.options.historyMaxBytes||10*1024*1024),this._bindEvents(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._history=null,clearTimeout(this._snapshotTimer),this._snapshotTimer=null}_bindEvents(e){let t=e=>this._onKeydown(e),n=()=>this.afterCommand(),r=e=>this._enforceLimit(e),i=()=>{if(!this.context._alive)return;let t=globalThis.getSelection();t?.rangeCount>0&&e.contains(t.anchorNode)&&(this.context.invoke(`toolbar.refresh`),typeof this.options.onSelectionChange==`function`&&this.options.onSelectionChange(this.context))},a=e=>{e.target.type===`checkbox`&&e.target.closest(`.an-checklist`)&&this.afterCommand()},o=t=>{let n=globalThis.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);if(!r.collapsed)return;let i=r.startContainer;if(i.nodeType!==Node.ELEMENT_NODE)return;let a=i,o=a.matches(`.an-checklist li`)?a:null;if(!o)return;let s=o.querySelector(`input[type="checkbox"]`);if(!s)return;if(t?.type===`mouseup`){let r=null;if(document.caretRangeFromPoint)r=document.caretRangeFromPoint(t.clientX,t.clientY);else if(document.caretPositionFromPoint){let e=document.caretPositionFromPoint(t.clientX,t.clientY);e&&(r=document.createRange(),r.setStart(e.offsetNode,e.offset))}if(r&&e.contains(r.startContainer)&&r.startContainer!==o){r.collapse(!0),n.removeAllRanges(),n.addRange(r);return}}let c=document.createRange(),l=null;for(let e of o.childNodes)if(e!==s&&e.nodeType===Node.TEXT_NODE){l=e;break}l?c.setStart(l,0):c.setStartAfter(s),c.collapse(!0),n.removeAllRanges(),n.addRange(c)},s=()=>this.context.layoutInfo.container.classList.contains(`an-disabled`);this._disposers.push(_(e,`keydown`,t),_(e,`beforeinput`,r),_(e,`input`,n),_(document,`selectionchange`,i),_(e,`click`,a),_(e,`mouseup`,o),_(e,`keyup`,o),_(e,`dragstart`,e=>{if(s()){e.preventDefault();return}let t=e.target;t&&(t.nodeName===`IFRAME`||t.closest(`.an-video-wrapper`))&&e.preventDefault()}),_(e,`drop`,e=>{s()&&e.preventDefault()}));let c=null;this._disposers.push(_(e,`compositionstart`,()=>{let e=globalThis.getSelection();if(!e?.rangeCount){c=null;return}let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),t){let e=t;c=e.closest(`sup`)?`superscript`:e.closest(`sub`)?`subscript`:null}}),_(e,`compositionend`,()=>{let e=c;if(c=null,!e)return;let t=globalThis.getSelection();if(!t?.rangeCount)return;let n=t.getRangeAt(0).startContainer;n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);let r=n;(e===`superscript`?r?.closest(`sup`):r?.closest(`sub`))||document.execCommand(e)}))}_onKeydown(e){let t=this.context.layoutInfo.editable;if(!on(e,t,this.options)){if(F(e,`z`)&&!e.shiftKey){e.preventDefault(),this.undo();return}if(F(e,`z`)&&e.shiftKey||F(e,`y`)){e.preventDefault(),this.redo();return}if(F(e,`b`)){e.preventDefault(),this.bold();return}if(F(e,`i`)){e.preventDefault(),this.italic();return}if(F(e,`u`)){e.preventDefault(),this.underline();return}if(F(e,`k`)){e.preventDefault(),this.context.invoke(`linkDialog.show`);return}if(F(e,`v`)&&e.shiftKey){this.context.invoke(`clipboard.setForcePlain`,!0);return}if(e.key===`/`&&e.shiftKey&&e.ctrlKey&&!e.metaKey){e.preventDefault(),this.context.invoke(`shortcutsDialog.show`);return}if(F(e,`f`)){e.preventDefault(),this.context.invoke(`findReplace.show`,`find`);return}F(e,`h`)&&(e.preventDefault(),this.context.invoke(`findReplace.show`,`replace`)),F(e,"`")&&(e.preventDefault(),this.inlineCode())}}_enforceLimit(e){let t=this.options.maxChars||0,n=this.options.maxWords||0;if(!t&&!n)return;this._limitCounter??=new fn;let r=e.inputType||``;if(r.startsWith(`delete`)||r===`historyUndo`||r===`historyRedo`||r===`insertFromPaste`||r===`insertFromDrop`||!r.startsWith(`insert`))return;let{words:i,chars:a}=this._limitCounter.counts(this.context.layoutInfo.editable);if(t&&a>=t){e.preventDefault(),typeof this.options.onCharLimitReached==`function`&&this.options.onCharLimitReached(this.context);return}n&&(e.data===` `||r===`insertParagraph`||r===`insertLineBreak`)&&i>=n&&(e.preventDefault(),typeof this.options.onWordLimitReached==`function`&&this.options.onWordLimitReached(this.context))}afterCommand(){this._cleanOrphanedFigures(),this._ensureTrailingParagraph(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this._scheduleSnapshot()}_scheduleSnapshot(){clearTimeout(this._snapshotTimer),this._snapshotTimer=setTimeout(()=>{this._snapshotTimer=null,this._history&&this._history.recordUndo(),this.context.triggerEvent(`change`,this.getHTML())},400)}_cleanOrphanedFigures(){this.context.layoutInfo.editable.querySelectorAll(`figure.an-figure`).forEach(e=>{e.querySelector(`img`)||e.remove()})}_ensureTrailingParagraph(){let e=this.context.layoutInfo.editable;if(!e)return;let t=e.lastElementChild;if(t&&hr.has(t.nodeName)){let t=document.createElement(`p`);t.innerHTML=`<br>`,e.appendChild(t)}}focus(){this.context.layoutInfo.editable.focus()}getHTML(){let e=this.context.layoutInfo.editable.innerHTML.replaceAll(``,``);return this.context.invoke(`clipboard.resolveImages`,e)??e}setHTML(e){let t=Rt(e,{allowIframes:!0});this.context.layoutInfo.editable.replaceChildren(...t.childNodes),this._history&&this._history.reset(),this.afterCommand()}getText(){return this.context.layoutInfo.editable.innerText||``}setText(e){this.context.layoutInfo.editable.textContent=e,this._history&&this._history.reset(),this.afterCommand()}clear(){this.setHTML(``)}clearHistory(){this._history&&this._history.reset()}isEmpty(){let e=(this.context.layoutInfo.editable.innerText||``).trim().replaceAll(`\xA0`,``),t=!!this.context.layoutInfo.editable.querySelector(`img, video, iframe, table`);return!e&&!t}insertHTML(e){e&&(k(`insertHTML`,M(e)),this.afterCommand())}insertText(e){e&&(k(`insertText`,e),this.afterCommand())}setMarkdown(e){this.setHTML(Mn(e||``))}getMarkdown(){return mn(this.getHTML())}undo(){this._history&&(this._flushPendingSnapshot(),this._history.undo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}redo(){this._history&&(this._flushPendingSnapshot(),this._history.redo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}_flushPendingSnapshot(){this._snapshotTimer!==null&&(clearTimeout(this._snapshotTimer),this._snapshotTimer=null,this._history?.recordUndo())}canUndo(){return this._history?this._history.canUndo():!1}canRedo(){return this._history?this._history.canRedo():!1}getUndoCount(){return this._history?this._history.getUndoCount():0}getRedoCount(){return this._history?this._history.getRedoCount():0}getSelectionBookmark(){return this._history?._serializeSelection()??null}restoreSelectionBookmark(e){return!e||!this._history?!1:(this._history._restoreSelection(e),!0)}bold(){ae(),this.afterCommand()}italic(){oe(),this.afterCommand()}underline(){se(),this.afterCommand()}strikethrough(){ce(),this.afterCommand()}superscript(){le(),this.afterCommand()}subscript(){ue(),this.afterCommand()}justifyLeft(){ge(),this.afterCommand()}justifyCenter(){_e(),this.afterCommand()}justifyRight(){ve(),this.afterCommand()}justifyFull(){ye(),this.afterCommand()}indent(){be(),this.afterCommand()}outdent(){Se(),this.afterCommand()}insertUL(){De(),this.afterCommand()}insertOL(){Oe(),this.afterCommand()}inlineCode(){Ae(this.context.layoutInfo.editable),this.afterCommand()}toggleChecklist(){Pe(),this.afterCommand()}print(){this.context.print()}formatBlock(e){if(he(e),e===`pre`){let e=globalThis.getSelection();if(e?.rangeCount>0){let t=e.getRangeAt(0).commonAncestorContainer,n=t.nodeType===1?t.closest(`pre`):t.parentElement?.closest(`pre`);if(n&&!n.dataset.language){let e=mr(n.textContent||``);if(e){this.context.invoke(`codeTooltip.applyLanguage`,n,e);return}}}}this.afterCommand()}foreColor(e){de(e),this.afterCommand()}backColor(e){fe(e),this.afterCommand()}fontName(e){pe(e),this.afterCommand()}fontSize(e){me(e,this.context.layoutInfo.editable),this.afterCommand()}insertHr(){k(`insertHorizontalRule`),this.afterCommand()}insertLink(e,t,n=!1){let r=globalThis.getSelection();if(!r||r.rangeCount===0)return;let i=Ht(e);if(i){if(r.toString().trim().length>0){if(k(`createLink`,i),n){let e=this._getClosestAnchor();e&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}}else{let e=this._escapeAttr(t||i);k(`insertHTML`,`<a href="${this._escapeAttr(i)}"${n?` target="_blank" rel="noopener noreferrer"`:``}>${e}</a>`)}this.afterCommand()}}unlink(){k(`unlink`),this.afterCommand()}insertImage(e,t=``,n=``){let r=Ht(e,{allowData:!0});if(!r)return;let i={left:`float:left;margin:0 1em 1em 0`,center:`display:block;margin:0 auto`,right:`float:right;margin:0 0 1em 1em`}[n]||``,a=i?` style="${i}"`:``;k(`insertHTML`,`<img src="${this._escapeAttr(r)}" alt="${this._escapeAttr(t)}" class="an-image"${a}>`),this.afterCommand()}insertVideo(e){e&&(k(`insertHTML`,e),this.afterCommand())}insertTable(e,t){$t(e,t,{headerRow:this.context.options.tableHeaderRow}),this.afterCommand()}_getClosestAnchor(){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).startContainer;for(;t;){if(t.nodeName===`A`)return t;t=t.parentNode}return null}_escapeAttr(e){return String(e??``).replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}},_r=e=>typeof e==`string`?Re(e):e,vr=null,yr=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,V=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${yr} style="display:block">${e}</svg>`,H=new Map([[`bold`,V(`<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"/>`)],[`italic`,V(`<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"/>`)],[`underline`,V(`<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"/>`)],[`strikethrough`,V(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`)],[`superscript`,V(`<path d="m4 19 8-8"/><path d="m12 19-8-8"/><path d="M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7.25C20 6 19 5 17.5 5S15 6 15 7"/>`)],[`subscript`,V(`<path d="m4 5 8 8"/><path d="m12 5-8 8"/><path d="M20 21h-4c0-1.5.44-2 1.5-2.5S20 17.33 20 16.25C20 15 19 14 17.5 14S15 15 15 16"/>`)],[`align-left`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/>`)],[`align-center`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="18" y1="12" x2="6" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`align-right`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/>`)],[`align-justify`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`list-ul`,V(`<line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1" fill="currentColor" stroke="none"/>`)],[`list-ol`,V(`<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 6h1V3"/><path d="M4 10h2l-2 2h2"/><path d="M4 16.5A1.5 1.5 0 0 1 5.5 15a1.5 1.5 0 0 1 0 3H4"/>`)],[`indent`,V(`<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"/>`)],[`outdent`,V(`<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"/>`)],[`undo`,V(`<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>`)],[`redo`,V(`<path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/>`)],[`minus`,V(`<line x1="5" y1="12" x2="19" y2="12"/>`)],[`link`,V(`<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"/>`)],[`image`,V(`<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/>`)],[`video`,V(`<polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/>`)],[`table`,V(`<rect x="3" y="3" width="18" height="18" rx="1"/><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"/>`)],[`emoji`,V(`<circle cx="12" cy="12" r="10"/><path d="M8.5 14.5s1.5 2.5 3.5 2.5 3.5-2.5 3.5-2.5"/><circle cx="9" cy="9" r="1.5" fill="currentColor" stroke="none"/><circle cx="15" cy="9" r="1.5" fill="currentColor" stroke="none"/>`)],[`icon`,V(`<circle cx="8" cy="8" r="3"/><circle cx="16" cy="8" r="3"/><rect x="5" y="13" width="6" height="6" rx="1"/><rect x="13" y="13" width="6" height="6" rx="1"/>`)],[`code`,V(`<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>`)],[`expand`,V(`<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/>`)],[`foreColor`,V(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`)],[`backColor`,V(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/>`)],[`keyboard`,V(`<rect x="2" y="6" width="20" height="12" rx="2"/><line x1="6" y1="10" x2="6" y2="10" stroke-width="2.5"/><line x1="10" y1="10" x2="10" y2="10" stroke-width="2.5"/><line x1="14" y1="10" x2="14" y2="10" stroke-width="2.5"/><line x1="18" y1="10" x2="18" y2="10" stroke-width="2.5"/><line x1="8" y1="14" x2="16" y2="14" stroke-width="2"/>`)],[`caption`,V(`<rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/>`)],[`remove-format`,V(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`)],[`direction`,V(`<path d="M12 20V4"/><path d="m9 7-3 3 3 3"/><path d="M4 10h8"/><path d="m15 7 3 3-3 3"/><path d="M20 10h-8"/>`)],[`search`,V(`<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`)],[`find-replace`,V(`<circle cx="10" cy="10" r="6"/><line x1="18" y1="18" x2="14.35" y2="14.35"/><path d="M16 19h6"/><path d="M19 16v6"/>`)],[`inline-code`,V(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)],[`checklist`,V(`<rect x="3" y="4" width="5" height="5" rx="1"/><path d="m4 6.5 1 1 2-2"/><rect x="3" y="13" width="5" height="5" rx="1"/><line x1="10" y1="6.5" x2="21" y2="6.5"/><line x1="10" y1="15.5" x2="21" y2="15.5"/>`)],[`print`,V(`<path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/>`)]]),br=new Map([[`bold`,`fa-bold`],[`italic`,`fa-italic`],[`underline`,`fa-underline`],[`strikethrough`,`fa-strikethrough`],[`superscript`,`fa-superscript`],[`subscript`,`fa-subscript`],[`align-left`,`fa-align-left`],[`align-center`,`fa-align-center`],[`align-right`,`fa-align-right`],[`align-justify`,`fa-align-justify`],[`list-ul`,`fa-list-ul`],[`list-ol`,`fa-list-ol`],[`indent`,`fa-indent`],[`outdent`,`fa-outdent`],[`undo`,`fa-rotate-left`],[`redo`,`fa-rotate-right`],[`minus`,`fa-minus`],[`link`,`fa-link`],[`image`,`fa-image`],[`code`,`fa-code`],[`expand`,`fa-expand`],[`emoji`,`fa-face-smile`],[`icon`,`fa-icons`],[`foreColor`,`fa-font`],[`backColor`,`fa-highlighter`],[`keyboard`,`fa-keyboard`],[`remove-format`,`fa-remove-format`],[`direction`,`fa-arrow-right-arrow-left`],[`search`,`fa-magnifying-glass`],[`find-replace`,`fa-magnifying-glass-plus`],[`inline-code`,`fa-code`],[`checklist`,`fa-list-check`],[`print`,`fa-print`]]),xr=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._colorPickerClosers=[],this._refreshRaf=null}initialize(){return this.el=m(`div`,{class:`an-toolbar`,role:`toolbar`,"aria-orientation":`horizontal`,"aria-label":`Editor toolbar`}),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(_r).filter(Boolean).map(e=>[e.name,e])),this}destroy(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=null,this._disposers.forEach(e=>e()),this._disposers=[],this.el?.parentNode&&this.el.remove(),this.el=null}_buildButtons(){let e=this.options.toolbar||[],t=document.createDocumentFragment();e.forEach(e=>{let n=m(`div`,{class:`an-btn-group`});e.forEach(e=>{let t=_r(e);if(!t){console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);return}let r;r=t.type===`select`?this._createSelect(t):t.type===`grid`?this._createGridPicker(t):t.type===`colorpicker`?this._createColorPicker(t):this._createButton(t),n.appendChild(r)}),t.appendChild(n)}),this.el.appendChild(t)}_createGridPicker(e){let t=m(`div`,{class:`an-table-picker-wrap`}),n=m(`button`,{type:`button`,class:this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,"aria-haspopup":`true`,"aria-expanded":`false`});this._faReady?n.innerHTML=`<i class="${this.options.fontAwesomeClass||`fas`} fa-table" aria-hidden="true"></i>`:n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:block"><rect x="3" y="3" width="18" height="18" rx="1"/><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>`;let r=m(`div`,{class:`an-table-picker-popup`,role:`dialog`,"aria-label":`Select table size`}),i=m(`div`,{class:`an-table-grid`}),a=m(`div`,{class:`an-table-label`});a.textContent=this.context.locale.toolbar.insertTableLabel||`Insert Table`;let o=[];for(let e=1;e<=10;e++)for(let t=1;t<=10;t++){let n=m(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});o.push(n),i.appendChild(n)}r.appendChild(i),r.appendChild(a);let s=!1,c=(e,t)=>{o.forEach(n=>{let r=+n.dataset.row,i=+n.dataset.col;n.classList.toggle(`active`,r<=e&&i<=t)}),a.textContent=e&&t?`${e} × ${t}`:this.context.locale.toolbar.insertTableLabel||`Insert Table`},l=()=>{s=!0;let e=n.getBoundingClientRect();r.style.visibility=`hidden`,r.style.display=`block`;let t=r.offsetWidth,i=r.offsetHeight,a=e.left,o=e.bottom+4;a+t>globalThis.innerWidth-8&&(a=Math.max(8,globalThis.innerWidth-t-8)),o+i>globalThis.innerHeight-8&&(o=e.top-i-4),r.style.left=`${a}px`,r.style.top=`${o}px`,r.style.visibility=``,n.setAttribute(`aria-expanded`,`true`)},u=()=>{s=!1,r.style.display=`none`,n.setAttribute(`aria-expanded`,`false`),c(0,0)},d=_(n,`click`,e=>{e.stopPropagation(),s?u():l()}),f=_(i,`mouseover`,e=>{let t=e.target?.closest(`.an-table-cell`);t&&c(+t.dataset.row,+t.dataset.col)}),p=_(i,`mouseleave`,()=>c(0,0)),h=_(i,`click`,t=>{let n=t.target?.closest(`.an-table-cell`);if(!n)return;let r=+n.dataset.row,i=+n.dataset.col;u(),this.context.invoke(`editor.focus`),e.action(this.context,r,i)}),g=_(document,`click`,()=>{s&&u()});return this._disposers.push(d,f,p,h,g,()=>{r.parentNode&&r.remove()}),t.appendChild(n),document.body.appendChild(r),t}_createColorPicker(e){let t=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],n=e.defaultColor||`#000000`,r=m(`div`,{class:`an-color-picker-wrap`}),i=this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,a=m(`button`,{type:`button`,class:`${i} an-color-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),o=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`;a.innerHTML=e.name===`foreColor`?`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${o} style="display:block"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${o} style="display:block"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/></svg>`;let s=m(`span`,{class:`an-color-strip`});s.style.background=n,a.appendChild(s);let c=m(`button`,{type:`button`,class:`${i} an-color-arrow`,title:e.name===`foreColor`?this.context.locale.toolbar.chooseTextColor||`Choose text color`:this.context.locale.toolbar.chooseHighlightColor||`Choose highlight color`,"aria-haspopup":`true`,"aria-expanded":`false`});c.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 24 24" fill="currentColor" stroke="none" style="display:block"><path d="M7 10l5 5 5-5H7z"/></svg>`;let l=m(`div`,{class:`an-color-popup`});l.style.display=`none`;let u=m(`div`,{class:`an-color-swatches`}),d=Array.isArray(this.options.colorSwatches)?this.options.colorSwatches:[];[...new Set([...d,...t])].forEach(e=>{let t=m(`div`,{class:`an-color-swatch`,title:e,"data-color":e});t.style.background=e,u.appendChild(t)});let f=m(`div`,{class:`an-color-custom`}),p=m(`input`,{type:`color`,value:n,title:this.context.locale.toolbar.customColor||`Custom color`}),h=m(`span`,{},[this.context.locale.toolbar.customColor||`Custom color`]);f.appendChild(p),f.appendChild(h),l.appendChild(u),l.appendChild(f);let g=!1,v=null,ee=()=>{let e=globalThis.getSelection();v=e?.rangeCount?e.getRangeAt(0).cloneRange():null},y=()=>{if(v)try{let e=globalThis.getSelection();if(!e)return;e.removeAllRanges(),e.addRange(v)}catch{}},b=()=>{this._colorPickerClosers.forEach(e=>{e!==x&&e()}),ee(),g=!0;let e=c.getBoundingClientRect(),t=e.left;t+184>globalThis.innerWidth&&(t=e.right-184),l.style.top=`${e.bottom+4}px`,l.style.left=`${Math.max(4,t)}px`,l.style.display=`block`,c.setAttribute(`aria-expanded`,`true`)},x=()=>{g=!1,l.style.display=`none`,l.style.top=``,l.style.left=``,c.setAttribute(`aria-expanded`,`false`)},S=t=>{n=t,s.style.background=t,p.value=t,y(),e.action(this.context,t),this.context.invoke(`editor.afterCommand`),x()},C=_(a,`click`,t=>{t.preventDefault(),y(),e.action(this.context,n),this.context.invoke(`editor.afterCommand`)}),w=_(c,`mousedown`,e=>{e.preventDefault()}),T=_(c,`click`,e=>{e.stopPropagation(),g?x():b()}),E=_(u,`mousedown`,e=>{e.preventDefault()}),D=_(u,`click`,e=>{let t=e.target?.closest(`.an-color-swatch`);t&&S(t.dataset.color)}),te=_(p,`change`,e=>{S(e.target.value)}),ne=_(document,`click`,e=>{g&&!r.contains(e.target)&&!l.contains(e.target)&&x()}),re=_(l,`click`,e=>e.stopPropagation()),O=()=>{g&&x()};return document.addEventListener(`scroll`,O,{passive:!0,capture:!0}),globalThis.addEventListener(`resize`,O,{passive:!0}),this._disposers.push(C,w,T,E,D,te,ne,re,()=>document.removeEventListener(`scroll`,O,{capture:!0}),()=>globalThis.removeEventListener(`resize`,O),()=>{l.parentNode&&l.remove()}),this._colorPickerClosers.push(x),this._disposers.push(()=>{let e=this._colorPickerClosers.indexOf(x);e!==-1&&this._colorPickerClosers.splice(e,1)}),r.appendChild(a),r.appendChild(c),document.body.appendChild(l),r}_createSelect(e){let t=e.name===`fontFamily`?this.options.fontFamilies||[]:e.items||[],n=m(`select`,{class:e.selectClass?`an-select ${e.selectClass}`:`an-select`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),r=m(`option`,{value:``,disabled:``,hidden:``},[this.context.locale.toolbar[e.name+`Placeholder`]||e.placeholder||`Font`]);n.appendChild(r),t.forEach(t=>{let r=typeof t==`object`?t.value:t,i;i=typeof t==`object`?e.name===`paragraphStyle`&&this.context.locale.toolbar.paragraphItems?.[t.value]||t.label:t;let a=typeof t==`object`&&!!t.disabled,o={value:r};a&&(o.disabled=``);let s=m(`option`,o,[i]);e.name===`fontFamily`&&!a&&(s.style.fontFamily=r),n.appendChild(s)});let i=null,a=_(n,`mousedown`,()=>{let e=globalThis.getSelection();i=e?.rangeCount?e.getRangeAt(0).cloneRange():null}),o=_(n,`change`,t=>{let n=t.target.value,r=t.target.options[t.target.selectedIndex];if(!(!n||r.disabled)){if(this.context.invoke(`editor.focus`),i)try{let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(i))}catch{}e.action(this.context,n),this.context.invoke(`editor.afterCommand`)}});return this._disposers.push(a,o),n}_createButton(e){let t=m(`button`,{type:`button`,class:`${this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`}${e.className?` ${e.className}`:``}`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,...typeof e.isActive==`function`?{"aria-pressed":`false`}:{}}),n=this.options.fontAwesomeClass||`fas`;if(this._faReady){let r=br.get(e.icon)||br.get(e.name)||null;r?t.innerHTML=`<i class="${n} ${r}" aria-hidden="true"></i>`:H.has(e.icon)?t.innerHTML=H.get(e.icon):t.textContent=e.icon||e.name}else H.has(e.icon)?t.innerHTML=H.get(e.icon):H.has(e.name)?t.innerHTML=H.get(e.name):t.textContent=e.icon||e.name;let r=_(t,`click`,t=>{t.preventDefault(),this.context.invoke(`editor.focus`),e.action(this.context),this.context.invoke(`editor.afterCommand`),this.refresh()});return this._disposers.push(r),t}_controls(){return this.el?Array.from(this.el.querySelectorAll(`button, select`)):[]}_navigable(){return this._controls().filter(e=>!e.disabled)}_syncRovingTabindex(e){let t=this._controls(),n=this._navigable();if(!n.length)return;let r=e&&n.includes(e)?e:n.find(e=>e.getAttribute(`tabindex`)===`0`)||n[0];t.forEach(e=>e.setAttribute(`tabindex`,e===r?`0`:`-1`))}_initRovingFocus(){this.el&&(this._syncRovingTabindex(),this._disposers.push(_(this.el,`keydown`,e=>this._onToolbarKeydown(e)),_(this.el,`focusin`,e=>{let t=e.target?.closest?.(`button, select`);t&&this._syncRovingTabindex(t)})))}_onToolbarKeydown(e){if(![`ArrowRight`,`ArrowLeft`,`Home`,`End`].includes(e.key))return;let t=this._navigable(),n=e.target?.closest?.(`button, select`),r=n?t.indexOf(n):-1;if(r===-1)return;let i;if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t.at(-1);else{let n=this.options.direction===`rtl`;i=t[(r+(e.key===`ArrowRight`===n?-1:1)+t.length)%t.length]}i&&(e.preventDefault(),this._syncRovingTabindex(i),i.focus())}_detectFontAwesome(){if(!this.options.useFontAwesome)return!1;if(vr!==null)return vr;if(document.querySelector(`.fa, .fas, .far, .fal, .fab, .fa-solid`))return vr=!0,!0;let e=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).filter(e=>e.id!==`an-fontawesome-css`).map(e=>e.href||``).join(` `);return vr=/fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e),vr}refresh(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,this._doRefresh()})}_doRefresh(){if(!this.el)return;let e=this._btnMap||new Map;this.el.querySelectorAll(`button[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(n&&typeof n.isActive==`function`){let e=!!n.isActive(this.context);t.classList.toggle(`active`,e),t.setAttribute(`aria-pressed`,String(e))}n&&typeof n.isDisabled==`function`&&(t.disabled=!!n.isDisabled(this.context))}),this._syncRovingTabindex(),this.el.querySelectorAll(`select[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(!n||typeof n.getValue!=`function`)return;let r=(n.getValue(this.context)||``).replace(/["']/g,``).trim();r||=this.options.defaultFontFamily||this.options.fontFamilies?.[0]||``;let i=t,a=Array.from(i.options).find(e=>e.value?.toLowerCase()===r.toLowerCase());i.value=a?a.value:``})}show(){this.el&&(this.el.style.display=``)}hide(){this.el&&(this.el.style.display=`none`)}rebuild(){this._refreshRaf&&=(cancelAnimationFrame(this._refreshRaf),null),this._disposers.forEach(e=>e()),this._disposers=[],this.el&&(this.el.innerHTML=``),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(_r).filter(Boolean).map(e=>[e.name,e])),this.refresh()}};function Sr(e,t,n){if(!n){e.classList.remove(`an-count-warn`,`an-count-exceeded`);return}t>n?(e.classList.add(`an-count-exceeded`),e.classList.remove(`an-count-warn`)):t>=n*.9?(e.classList.add(`an-count-warn`),e.classList.remove(`an-count-exceeded`)):e.classList.remove(`an-count-warn`,`an-count-exceeded`)}var Cr=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._wordCountEl=null,this._charCountEl=null,this._counter=new fn}initialize(){if(this.el=m(`div`,{class:`an-statusbar`}),this.options.resizable!==!1){let e=m(`div`,{class:`an-resize-handle`,title:this.context.locale.statusbar.resizeHandle,"aria-hidden":`true`});this._bindResize(e),this.el.appendChild(e)}this._wordCountEl=m(`span`,{class:`an-word-count`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`}),this._charCountEl=m(`span`,{class:`an-char-count`,"aria-live":`polite`,"aria-atomic":`true`});let e=m(`div`,{class:`an-status-info`,"aria-label":`Editor statistics`});return e.appendChild(this._wordCountEl),e.appendChild(this._charCountEl),this.el.appendChild(e),this.update(),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this.el?.remove(),this.el=null}_bindResize(e){let t=0,n=0,r=this.context.layoutInfo.container,i=e=>{let i=e-t,a=Array.from(r.children).filter(e=>!e.classList.contains(`an-editable`)).reduce((e,t)=>e+t.offsetHeight,0),o=Math.max(this.options.minHeight||100,a+40);r.style.height=`${Math.max(o,n+i)}px`},a=e=>i(e.clientY),o=()=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),this._dragDisposers=null},s=e=>{t=e.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o),this._dragDisposers=[()=>document.removeEventListener(`mousemove`,a),()=>document.removeEventListener(`mouseup`,o)],e.preventDefault()},c=e=>{let t=e.touches[0];t&&(e.preventDefault(),i(t.clientY))},l=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),this._dragDisposers=null},u=e=>{let i=e.touches[0];i&&(t=i.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),this._dragDisposers=[()=>document.removeEventListener(`touchmove`,c),()=>document.removeEventListener(`touchend`,l)])},d=_(e,`mousedown`,s),f=_(e,`touchstart`,u);this._disposers.push(d,f)}_counts(){return this._counter.counts(this.context.layoutInfo.editable)}update(){if(!this._wordCountEl||!this._charCountEl)return;let{words:e,chars:t}=this._counts(),n=this.options.maxWords||0,r=this.options.maxChars||0,i=this.context.locale.statusbar;this._wordCountEl.textContent=n?i.wordsLimit(e,n):i.words(e),this._charCountEl.textContent=r?i.charsLimit(t,r):i.chars(t),Sr(this._wordCountEl,e,n),Sr(this._charCountEl,t,r)}getWordCount(){return this._counts().words}getCharCount(){return this._counts().chars}},wr=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){this._blobRegistry=new Map,this._forcePlain=!1;let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`paste`,e=>this._onPaste(e)),_(e,`dragover`,e=>this._onDragover(e)),_(e,`drop`,e=>this._onDrop(e))),this._mutationObserver=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)this._revokeRemovedBlobs(e)}),this._mutationObserver.observe(e,{childList:!0,subtree:!0}),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._mutationObserver&&=(this._mutationObserver.disconnect(),null),this._blobRegistry&&(this._blobRegistry.forEach((e,t)=>URL.revokeObjectURL(t)),this._blobRegistry.clear()),this._uploadPreviews&&(this._uploadPreviews.forEach(({previewUrl:e})=>URL.revokeObjectURL(e)),this._uploadPreviews.clear())}_revokeRemovedBlobs(e){if(!this._blobRegistry?.size)return;let t=[];e.nodeName===`IMG`?t.push(e):e.querySelectorAll&&t.push(...e.querySelectorAll(`img`)),t.forEach(e=>{let t=e.getAttribute(`src`)||``;t.startsWith(`blob:`)&&this._blobRegistry.has(t)&&(URL.revokeObjectURL(t),this._blobRegistry.delete(t))})}_cleanWordHtml(e){return e.replace(/<!--\[if[\s\S]*?\[endif\]-->/gi,``).replace(/<xml[\s\S]*?<\/xml>/gi,``).replace(/<\?xml[\s\S]*?\?>/gi,``).replace(/<\/?(o|w|m|v|st1):[a-z][^>]*>/gi,``).replace(/\s+class="Mso[^"]*"/gi,``).replace(/\s+style="([^"]*)"/gi,(e,t)=>{let n=t.split(`;`).map(e=>e.trim()).filter(e=>e&&!/^mso-/i.test(e)&&!/^(tab-stops|margin-[a-z]+-alt)/i.test(e)).join(`; `);return n?` style="${n}"`:``}).replace(/<p[^>]*>\s*( )?\s*<\/p>/gi,``)}_cleanSocialHtml(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=Array.from(t.querySelectorAll(`span, div`));for(let e=n.length-1;e>=0;e--){let t=n[e];if(!t.parentNode||t.querySelector(`a, strong, em, b, i, ul, ol, li, table, img, blockquote, pre, code, h1, h2, h3, h4, h5, h6`))continue;let r=t.parentNode;for(;t.firstChild;)r.insertBefore(t.firstChild,t);t.remove()}return t.querySelectorAll(`*`).forEach(e=>{e.removeAttribute(`class`),e.removeAttribute(`id`),Array.from(e.attributes).filter(e=>e.name.startsWith(`data-`)||e.name.startsWith(`aria-`)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_stripAttributes(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=new Set([`href`,`src`,`alt`,`target`,`rel`,`colspan`,`rowspan`,`type`]);return t.querySelectorAll(`*`).forEach(e=>{Array.from(e.attributes).filter(e=>!n.has(e.name)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_normalizeExternalTaskLists(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);for(let e of t.querySelectorAll(`input[type="checkbox"]`)){let t=e.closest(`li`),n=t?.closest(`ul`);if(!(!t||!n||n.classList.contains(`an-checklist`))){n.classList.add(`an-checklist`),e.removeAttribute(`disabled`),e.setAttribute(`contenteditable`,`false`);for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}}return t.body.innerHTML}_isTriviallyPlainHtml(e){return!new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`).body.querySelector(`a,img,table,ul,ol,li,blockquote,pre,code,h1,h2,h3,h4,h5,h6,strong,b,em,i,u,s,del,strike,hr,br`)}setForcePlain(e){this._forcePlain=!!e}_onPaste(e){let t=e.clipboardData||globalThis.clipboardData;if(!t)return;let n=this._forcePlain;this._forcePlain=!1;let r=(this.options.maxPasteSize??5)*1024*1024;if(r>0){let n=t.getData(`text/plain`)||``,i=t.getData(`text/html`)||``,a=Math.max(n.length,i.length);if(a>r){e.preventDefault();let t=`Pasted content (${a} bytes) exceeds the ${this.options.maxPasteSize??5} MB paste size limit.`;this.context.triggerEvent(`pasteError`,{size:a,maxBytes:r,message:t}),console.warn(`[AutumnNote] ${t}`);return}}if(t.items){let n=Array.from(t.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(n.length>0){e.preventDefault();let t=n.map(e=>e.getAsFile()).filter(Boolean);this._insertImageFiles(t);return}}if(typeof this.options.onPaste==`function`&&this.options.onPaste({text:t.getData(`text/plain`)||``,html:t.types.includes(`text/html`)?t.getData(`text/html`):null}),n||this.options.pasteAsPlainText){e.preventDefault(),k(`insertHTML`,t.getData(`text/plain`).split(/\r?\n/).map(e=>`<p>${this._escapeHTML(e)||`<br>`}</p>`).join(``)),this.context.invoke(`editor.afterCommand`);return}if(this.options.markdownPaste!==!1){let n=t.types.includes(`text/html`),r=n?t.getData(`text/html`):``,i=!n||this._isTriviallyPlainHtml(r),a=t.getData(`text/plain`);if(a&&i&&wn(a)){e.preventDefault(),k(`insertHTML`,M(Mn(a))),this.context.invoke(`editor.afterCommand`);return}}if(this.options.pasteCleanHTML!==!1&&t.types.includes(`text/html`)){e.preventDefault();let n=t.getData(`text/html`),r=/<[a-z]+:[a-z]/i.test(n)||/class="Mso/i.test(n)||/\bmso-/i.test(n),i=/class="[^"]*\b(?:x[a-z0-9]{6,}|r-[a-z0-9]{3,})\b/.test(n),a=n;r?a=this._cleanWordHtml(a):i&&(a=this._cleanSocialHtml(a)),a=this._normalizeExternalTaskLists(a),a=M(a),this.options.pasteStripAttributes&&(a=this._stripAttributes(a)),k(`insertHTML`,a),this.context.invoke(`editor.afterCommand`)}}_onDragover(e){e.dataTransfer&&Array.from(e.dataTransfer.types||[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}_onDrop(e){let t=e.dataTransfer;if(!t?.files?.length)return;let n=Array.from(t.files).filter(e=>e.type.startsWith(`image/`));if(n.length>0){e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertImageFiles(n);return}if(this.options.markdownPaste!==!1){let n=Array.from(t.files).find(e=>/\.md$/i.test(e.name)||e.type===`text/markdown`);n&&(e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertMarkdownFile(n))}}_insertMarkdownFile(e){let t=(this.options.maxPasteSize??5)*1024*1024;if(t>0&&e.size>t){let n=`Dropped file "${e.name}" (${e.size} bytes) exceeds the ${this.options.maxPasteSize??5} MB paste size limit.`;this.context.triggerEvent(`pasteError`,{size:e.size,maxBytes:t,message:n}),console.warn(`[AutumnNote] ${n}`);return}let n=new FileReader;n.onload=e=>{k(`insertHTML`,M(Mn(e.target.result||``))),this.context.invoke(`editor.afterCommand`)},n.onerror=()=>{let t=`Failed to read dropped markdown file "${e.name}".`;console.warn(`[AutumnNote] ${t}`),this.context.triggerEvent(`pasteError`,{message:t})},n.readAsText(e)}_insertImageFiles(e){if(!e||e.length===0)return;if(typeof this.options.onImageUpload==`function`){this._runUploadHandler(e);return}let t=new Set([`image/tiff`,`image/x-tiff`,`image/bmp`,`image/x-bmp`,`image/x-ms-bmp`]),n=(this.options.maxImageSize||5)*1024*1024;e.forEach(e=>{if(!e?.type?.startsWith(`image/`))return;if(t.has(e.type)){let t=`Image format "${e.type}" is not supported for display in web browsers. Please convert to PNG, JPEG, or WebP first.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote]`,t);return}if(e.size>n){let t=`Image "${e.name}" exceeds the ${this.options.maxImageSize||5} MB size limit.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote] ${t}`);return}let r=e.name.replace(/\.[^.]+$/,``);this.compressAndRegister(e).then(e=>{this.context.invoke(`editor.insertImage`,e,r)}).catch(t=>{let n=`Image "${e.name}" could not be processed.`;this.context.triggerEvent(`imageError`,{file:e,message:n,error:t}),console.warn(`[AutumnNote]`,n,t)})})}_escapeAttr(e){return String(e).replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}async _runUploadHandler(e){let t={context:this.context,setProgress:(e,t)=>this._setUploadProgress(e,t)},n;try{n=this.options.onImageUpload(e,t)}catch(t){this._reportUploadError(e,t);return}if(n===void 0)return;let r=e.map(e=>this._insertUploadPlaceholder(e)),i;try{i=await n}catch(t){r.forEach((n,r)=>this._failUpload(n,e[r],t));return}let a=Array.isArray(i)?i:[i];r.forEach((t,n)=>{let r=a[n];typeof r==`string`&&r?this._resolveUpload(t,r):this._failUpload(t,e[n],Error(`No URL returned for this file.`))})}_insertUploadPlaceholder(e){let t=`an-up-${Date.now().toString(36)}-${this._uploadSeq=(this._uploadSeq||0)+1}`,n=URL.createObjectURL(e);this._uploadPreviews=this._uploadPreviews||new Map,this._uploadPreviews.set(t,{previewUrl:n,file:e});let r=this._escapeAttr(e.name.replace(/\.[^.]+$/,``));return k(`insertHTML`,`<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`),this.context.invoke(`editor.afterCommand`),t}_findPlaceholder(e){return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`)??null}_resolveUpload(e,t){let n=this._findPlaceholder(e),r=this._uploadPreviews?.get(e);if(n){let i=Ht(t,{allowData:!0});if(i)n.setAttribute(`src`,i),n.classList.remove(`an-image-uploading`),n.removeAttribute(`data-an-upload`),n.style.removeProperty(`--an-upload-progress`);else{this._failUpload(e,r?.file,Error(`Rejected image URL: ${t}`));return}}r&&(URL.revokeObjectURL(r.previewUrl),this._uploadPreviews.delete(e)),this.context.invoke(`editor.afterCommand`)}_failUpload(e,t,n){let r=this._findPlaceholder(e);r&&(r.classList.remove(`an-image-uploading`),r.classList.add(`an-image-failed`),r.style.removeProperty(`--an-upload-progress`));let i=`Image "${t?.name??`unknown`}" could not be uploaded.`;console.warn(`[AutumnNote]`,i,n),this.context.triggerEvent(`imageError`,{file:t,message:i,error:n,retry:()=>{r?.remove(),this._uploadPreviews?.delete(e),t&&this._runUploadHandler([t])}})}_reportUploadError(e,t){let n=`The image upload handler threw before any file was sent.`;console.warn(`[AutumnNote]`,n,t),this.context.triggerEvent(`imageError`,{file:e[0],message:n,error:t})}_setUploadProgress(e,t){if(!this._uploadPreviews)return;let n=Math.max(0,Math.min(1,Number(t)||0));for(let[t,r]of this._uploadPreviews){if(r.file!==e)continue;let i=this._findPlaceholder(t);i&&i.style.setProperty(`--an-upload-progress`,String(n));return}}async compressAndRegister(e){let t=this.options.imageProcessor,n=typeof t==`function`?await t(e,{context:this.context}):await this._compressImage(e),r=this._dataUrlToBlob(n),i=URL.createObjectURL(r);return this._blobRegistry.set(i,n),i}resolveImages(e){return this._blobRegistry?.size?e.replace(/blob:[^"'> \t\n\r]*/g,e=>this._blobRegistry.get(e)||e):e}_dataUrlToBlob(e){let[t,n]=e.split(`,`),r=/:(.*?);/.exec(t)?.[1]??`image/png`,i=atob(n),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return new Blob([a],{type:r})}_compressImage(e){let t=1920,n=.85;return new Promise((r,i)=>{let a=URL.createObjectURL(e),o=new Image;o.onload=()=>{URL.revokeObjectURL(a);let{width:s,height:c}=o;(s>t||c>t)&&(s>=c?(c=Math.round(c*t/s),s=t):(s=Math.round(s*t/c),c=t));let l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u){let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e);return}u.drawImage(o,0,0,s,c);let d=l.toDataURL(`image/webp`,n);r(d.startsWith(`data:image/webp`)?d:l.toDataURL(`image/jpeg`,n))},o.onerror=()=>{URL.revokeObjectURL(a);let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e)},o.src=a})}_placeCaretAtPoint(e,t){let n;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(e,t);else if(document.caretPositionFromPoint){let r=document.caretPositionFromPoint(e,t);r&&(n=document.createRange(),n.setStart(r.offsetNode,r.offset),n.collapse(!0))}if(!n)return;let r=globalThis.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}_escapeHTML(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}},U={undo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>`,redo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/></svg>`,cut:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="20" r="3"/><circle cx="6" cy="4" r="3"/><line x1="19" y1="5" x2="6" y2="19"/><line x1="19" y1="19" x2="13.5" y2="13.5"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,paste:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>`,bold:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,link:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,video:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,videoAlign:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,copyFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,pasteFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/><path d="m9 14 2 2 4-4"/></svg>`,removeFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>`,table:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><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>`,textColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`,highlightColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/></svg>`,noColor:`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,back:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>`},Tr=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`];function Er(e){let t=e===`foreColor`?`Text Color`:`Highlight Color`,n=e===`foreColor`?`textColor`:`highlightColor`;return()=>[{back:!0,label:t,localeKey:n,navigate:()=>Dr},{colorPalette:!0,colorType:e}]}var Dr=[{name:`cut`,label:`Cut`,icon:U.cut,action:()=>document.execCommand(`cut`)},{name:`copy`,label:`Copy`,icon:U.copy,action:()=>document.execCommand(`copy`)},{name:`paste`,label:`Paste`,icon:U.paste,action:e=>{if(!navigator.clipboard)return;let t=e.layoutInfo?.editable;if(!t)return;let n=(n,r)=>{if(t.focus(),n){let e=M(n);document.execCommand(`insertHTML`,!1,e)}else r&&document.execCommand(`insertText`,!1,r);e.invoke(`editor.afterCommand`)};typeof navigator.clipboard.read==`function`?navigator.clipboard.read().then(e=>{for(let t of e)if(t.types.includes(`text/html`)){t.getType(`text/html`).then(e=>e.text()).then(e=>n(e,null)).catch(()=>{});return}navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}).catch(()=>{navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}):typeof navigator.clipboard.readText==`function`&&navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}},{separator:!0},{name:`bold`,label:`Bold`,icon:U.bold,action:e=>e.invoke(`editor.bold`)},{name:`italic`,label:`Italic`,icon:U.italic,action:e=>e.invoke(`editor.italic`)},{name:`underline`,label:`Underline`,icon:U.underline,action:e=>e.invoke(`editor.underline`)},{separator:!0},{name:`textColor`,label:`Text Color`,icon:U.textColor,colorStrip:`foreColor`,navigate:Er(`foreColor`)},{name:`highlightColor`,label:`Highlight Color`,icon:U.highlightColor,colorStrip:`hiliteColor`,navigate:Er(`hiliteColor`)},{separator:!0},{name:`copyFormat`,label:`Copy Format`,icon:U.copyFormat,action:e=>e.invoke(`contextMenu.copyFormat`)},{name:`pasteFormat`,label:`Paste Format`,icon:U.pasteFormat,action:e=>e.invoke(`contextMenu.pasteFormat`),disabled:e=>!e.invoke(`contextMenu.hasCopiedFormat`)},{name:`removeFormat`,label:`Remove Format`,icon:U.removeFormat,action:e=>e.invoke(`contextMenu.removeFormat`)},{separator:!0},{name:`link`,label:`Insert Link`,icon:U.link,action:e=>e.invoke(`linkDialog.show`)},{name:`image`,label:`Insert Image`,icon:U.image,action:e=>e.invoke(`imageDialog.show`)},{name:`video`,label:`Insert Video`,icon:U.video,action:e=>e.invoke(`videoDialog.show`)},{name:`table`,label:`Insert Table`,icon:U.table,tableGrid:!0}],Or=class{constructor(e){this.context=e,this.options=e.options||{},this._items=this.options.contextMenu?.items||Dr,this.el=null,this._disposers=[],this._menuDisposers=[],this._lastX=0,this._lastY=0,this._copiedFormat=null,this._savedRange=null}initialize(){this.el=m(`div`,{class:`an-contextmenu`,role:`menu`,"aria-hidden":`true`}),this.el.style.display=`none`,document.body.appendChild(this.el),this._renderItems(this._items);let e=this.context.layoutInfo?.editable;return e&&this._disposers.push(_(e,`contextmenu`,e=>this._onContextMenu(e))),this._disposers.push(_(document,`click`,e=>this._maybeHide(e)),_(document,`keydown`,e=>{e.key===`Escape`&&this.hide()}),_(globalThis,`scroll`,()=>this.hide(),{passive:!0})),this}destroy(){this._menuDisposers.forEach(e=>{try{e()}catch{}}),this._menuDisposers=[],this._disposers.forEach(e=>{try{e()}catch{}}),this._disposers=[],this.el&&this.el.remove(),this.el=null}_renderItems(e){this._menuDisposers.forEach(e=>e()),this._menuDisposers=[],this.el&&(this.el.innerHTML=``,e.forEach(e=>{if(e.separator||e.sep){this.el.appendChild(m(`div`,{class:`an-context-sep`}));return}if(e.back){let t=m(`button`,{type:`button`,class:`an-context-back`}),n=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=U.back,t.appendChild(n);let r=e.localeKey&&this.context.locale.contextMenu[e.localeKey]||e.label||this.context.locale.contextMenu.back||`Back`;t.appendChild(m(`span`,{class:`an-context-label`},[r]));let i=_(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(i),this.el.appendChild(t);return}if(e.navigate){let t=m(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||``});if(e.icon)if(e.colorStrip){let n=m(`span`,{class:`an-context-icon an-context-icon--color`,"aria-hidden":`true`}),r=m(`span`,{class:`an-context-icon-svg`});r.innerHTML=e.icon;let i=m(`span`,{class:`an-context-color-strip`});i.style.background=this._getSelectionColor(e.colorStrip),n.appendChild(r),n.appendChild(i),t.appendChild(n)}else{let n=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}t.appendChild(m(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=m(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,t.appendChild(n);let r=_(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(r),this.el.appendChild(t);return}if(e.colorPalette){let t=m(`div`,{class:`an-context-color-palette`});if(Tr.forEach(n=>{let r=m(`div`,{class:`an-context-color-swatch`,title:n,role:`button`,"aria-label":n});r.style.background=n;let i=_(r,`click`,t=>{t.stopPropagation(),this._applyColor(e.colorType,n)});this._menuDisposers.push(i),t.appendChild(r)}),e.colorType===`hiliteColor`){let e=m(`div`,{class:`an-context-color-swatch an-context-color-none`,title:this.context.locale.contextMenu.noHighlight||`No highlight`,role:`button`,"aria-label":this.context.locale.contextMenu.noHighlight||`No highlight`});e.innerHTML=U.noColor;let n=_(e,`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});this._menuDisposers.push(n),t.appendChild(e)}this.el.appendChild(t);let n=m(`div`,{class:`an-context-color-custom`}),r=m(`input`,{type:`color`,value:e.colorType===`foreColor`?`#000000`:`#ffff00`,title:this.context.locale.contextMenu.customColor||`Custom color`,"aria-label":this.context.locale.contextMenu.customColor||`Custom color`}),i=m(`span`,{},[this.context.locale.contextMenu.customColorLabel||`Custom…`]),a=_(r,`change`,()=>this._applyColor(e.colorType,r.value));this._menuDisposers.push(a),n.appendChild(r),n.appendChild(i),this.el.appendChild(n);return}if(e.tableGrid){let t=m(`div`,{class:`an-context-table-wrap`}),n=m(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||`table`});if(e.icon){let t=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});t.innerHTML=e.icon,n.appendChild(t)}n.appendChild(m(`span`,{class:`an-context-label`},[this.context.locale.contextMenu.table||e.label||`Insert Table`]));let r=m(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,n.appendChild(r);let i=m(`div`,{class:`an-context-table-grid-panel`});i.style.display=`none`;let a=m(`div`,{class:`an-table-grid`});a.style.gridTemplateColumns=`repeat(8, 16px)`;let o=m(`div`,{class:`an-table-label`});o.textContent=`Insert Table`;let s=[];for(let e=1;e<=8;e++)for(let t=1;t<=8;t++){let n=m(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});n.style.width=`16px`,n.style.height=`16px`,s.push(n),a.appendChild(n)}let c=(e,t)=>{s.forEach(n=>{n.classList.toggle(`active`,+n.dataset.row<=e&&+n.dataset.col<=t)}),o.textContent=e&&t?`${e} × ${t}`:this.context.locale.contextMenu.table||`Insert Table`};i.appendChild(a),i.appendChild(o);let l=!1,u=_(n,`click`,e=>{e.stopPropagation(),l=!l,i.style.display=l?``:`none`,r.style.transform=l?`rotate(90deg)`:``,this._reposition()});this._menuDisposers.push(u);let d=_(a,`mousemove`,e=>{let t=e.target?.closest(`[data-row]`);t&&c(+t.dataset.row,+t.dataset.col)}),f=_(a,`mouseleave`,()=>c(0,0)),p=_(a,`click`,e=>{let t=e.target?.closest(`[data-row]`);if(!t)return;let n=+t.dataset.row,r=+t.dataset.col,i=this.context.layoutInfo?.editable;if(i&&this._savedRange){i.focus();let e=globalThis.getSelection();e.removeAllRanges(),e.addRange(this._savedRange.cloneRange())}this.hide(),this.context.invoke(`editor.insertTable`,r,n)});this._menuDisposers.push(d,f,p),t.appendChild(n),t.appendChild(i),this.el.appendChild(t);return}let t=m(`button`,{type:`button`,class:`an-context-item`,"data-name":e.name||``});if((typeof e.disabled==`function`?e.disabled(this.context):e.disabled)&&(t.disabled=!0),e.icon){let n=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}t.appendChild(m(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=_(t,`click`,t=>{t.stopPropagation(),this.hide();try{e.action(this.context)}catch(e){console.error(e)}});this._menuDisposers.push(n),this.el.appendChild(t)}))}_onContextMenu(e){let t=this.context.layoutInfo?.editable;if(!t||!t.contains(e.target)||this.context.layoutInfo.container.classList.contains(`an-disabled`))return;e.preventDefault();let n=globalThis.getSelection();this._savedRange=n?.rangeCount>0?n.getRangeAt(0).cloneRange():null,this._renderItems(this._items);let r=e.clientX,i=e.clientY;if(this._savedRange&&!this._savedRange.collapsed)try{let e=this._savedRange.getBoundingClientRect();e.width>0&&e.height>0&&(i=e.bottom+4)}catch{}this._lastX=r,this._lastY=i,this.showAt(r,i)}_maybeHide(e){this.el&&(this.el.contains(e.target)||this.hide())}showAt(e,t){this.el&&(this.el.style.display=`block`,this._reposition(e,t),this.el.setAttribute(`aria-hidden`,`false`),this.context.triggerEvent(`contextMenu:show`))}_reposition(e,t){if(!this.el)return;let n=e===void 0?this._lastX:e,r=t===void 0?this._lastY:t,i=this.el.offsetWidth,a=this.el.offsetHeight,o=n,s=r;o+i>globalThis.innerWidth-8&&(o=globalThis.innerWidth-i-8),o<8&&(o=8),s+a>globalThis.innerHeight-8&&(s=globalThis.innerHeight-a-8),s<8&&(s=8),this.el.style.left=`${o}px`,this.el.style.top=`${s}px`}hide(){this.el&&(this.el.style.display=`none`,this.el.setAttribute(`aria-hidden`,`true`),this.context.triggerEvent(`contextMenu:hide`))}_getSelectionColor(e){let t=this._savedRange;if(!t)return e===`foreColor`?`#000000`:`transparent`;let n=t.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n)return e===`foreColor`?`#000000`:`transparent`;let r=globalThis.getComputedStyle(n);if(e===`foreColor`)return r.color||`#000000`;let i=r.backgroundColor;return!i||i===`rgba(0, 0, 0, 0)`||i===`transparent`?`transparent`:i}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges(),r.addRange(this._savedRange.cloneRange()),document.execCommand(e,!1,t),this.context.invoke(`editor.afterCommand`),this.hide()}hasCopiedFormat(){return!!this._copiedFormat}copyFormat(){let e=this._savedRange;if(!e)return;let t=this.context.layoutInfo?.editable,n=e.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n||!t?.contains(n))return;let r=globalThis.getComputedStyle(n),i=this._findExplicitStyle(n,t,`fontFamily`),a=this._findExplicitStyle(n,t,`fontSize`);this._copiedFormat={bold:Number.parseInt(r.fontWeight,10)>=700,italic:r.fontStyle===`italic`||r.fontStyle===`oblique`,underline:(r.textDecorationLine||``).includes(`underline`),strikethrough:(r.textDecorationLine||``).includes(`line-through`),fontFamily:i,fontSize:a,color:this._isDefaultColor(r.color)?null:r.color,backgroundColor:r.backgroundColor}}_findExplicitStyle(e,t,n){let r=e;for(;r&&r!==t&&r!==document.body;){if(r.style?.[n])return r.style[n];if(r.nodeName===`FONT`){if(n===`fontFamily`&&r.getAttribute(`face`))return r.getAttribute(`face`);if(n===`fontSize`&&r.getAttribute(`size`))return null}r=r.parentElement}return null}_isDefaultColor(e){return!e||e===`rgb(0, 0, 0)`||e===`rgba(0, 0, 0, 0)`||e===`transparent`}pasteFormat(){if(!this._copiedFormat||!this._savedRange)return;let e=this._copiedFormat,t=this.context.layoutInfo?.editable;if(!t)return;t.focus();let n=globalThis.getSelection();if(n.removeAllRanges(),n.addRange(this._savedRange.cloneRange()),document.execCommand(`removeFormat`),e.bold&&document.execCommand(`bold`),e.italic&&document.execCommand(`italic`),e.underline&&document.execCommand(`underline`),e.strikethrough&&document.execCommand(`strikeThrough`),e.color&&document.execCommand(`foreColor`,!1,e.color),(e=>!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`)(e.backgroundColor)||document.execCommand(`hiliteColor`,!1,e.backgroundColor),e.fontFamily&&document.execCommand(`fontName`,!1,e.fontFamily),e.fontSize){let n=`fs-${Date.now()}`,r=new Set(t.querySelectorAll(`font[size="7"]`));document.execCommand(`fontSize`,!1,`7`),t.querySelectorAll(`font[size="7"]`).forEach(e=>{r.has(e)||(e.dataset.anTmp=n)}),t.querySelectorAll(`[data-an-tmp="${n}"]`).forEach(t=>{let n=document.createElement(`span`);for(n.style.fontSize=e.fontSize,t.parentNode.insertBefore(n,t);t.firstChild;)n.appendChild(t.firstChild);t.remove()})}this.context.invoke(`editor.afterCommand`)}removeFormat(){if(!this._savedRange)return;let e=this.context.layoutInfo?.editable;if(!e)return;e.focus();let t=globalThis.getSelection();t.removeAllRanges(),t.addRange(this._savedRange.cloneRange()),document.execCommand(`removeFormat`);let n=t.getRangeAt(0),r=n.commonAncestorContainer,i=r.nodeType===Node.TEXT_NODE?r.parentElement:r,a=document.createNodeIterator(i,NodeFilter.SHOW_ELEMENT),o;for(;o=a.nextNode();)if(!(!e.contains(o)||o===e))try{n.intersectsNode(o)&&o.removeAttribute(`style`)}catch{}this.context.invoke(`editor.afterCommand`)}},kr=/[^\s\u200B]/;function Ar(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=t.nextNode();e;e=t.nextNode())if(kr.test(e.data))return!0;return!1}var jr=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){let e=this.context.layoutInfo.editable,t=this.options.placeholder||``;t&&(e.dataset.placeholder=t);let n=()=>this._update(),r=_(e,`input`,n),i=_(e,`focus`,n),a=_(e,`blur`,n);return this._disposers.push(r,i,a),this._update(),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_update(){let e=this.context.layoutInfo.editable,t=document.activeElement===e,n=!Ar(e)&&!e.querySelector(`img, table, hr, .an-video-wrapper`);e.classList.toggle(`an-placeholder`,n&&!t)}},Mr=class{constructor(e){this.context=e,this.options=e.options,this._active=!1,this._textarea=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._textarea?.remove(),this._textarea=null}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let{editable:e}=this.context.layoutInfo,t=e.innerHTML;this._textarea=m(`textarea`,{class:`an-codeview`,spellcheck:`false`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`}),this._textarea.value=this._prettyPrint(t),e.style.display=`none`,e.parentNode.insertBefore(this._textarea,e.nextSibling),this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active||!this._textarea)return;let{editable:e}=this.context.layoutInfo;e.innerHTML=M(this._textarea.value,{allowIframes:!0}),this._textarea.remove(),this._textarea=null,e.style.display=``,this._active=!1,this.context.invoke(`toolbar.refresh`),this.context.invoke(`editor.afterCommand`)}_prettyPrint(e){let t=/^<(a|abbr|b|bdo|br|button|cite|code|dfn|em|i|img|input|kbd|label|output|q|samp|select|small|span|strong|sub|sup|textarea|time|tt|u|var)([\s>/])/i,n=0;return e.replace(/>\s*</g,(e,n,r)=>{let i=r.slice(n+1);return t.test(i.trimStart())?`><`:`>
|
|
38
|
+
`);return n>0?t.slice(0,n):t}function mr(e){if(!e?.trim())return null;let t=pr(e.trim()),n=new Map;for(let{lang:e,re:r,w:i}of dr)r.test(t)&&n.set(e,(n.get(e)||0)+i);if(n.size===0)return null;for(let[e,t]of ur){let r=n.get(e);r&&n.set(e,r+(n.get(t)||0))}let r=[...n.entries()].sort((e,t)=>t[1]-e[1]),[i,a]=r[0],o=r[1]?.[1]??0;return a<cr||a-o<lr?null:i}var hr=new Set([`PRE`,`BLOCKQUOTE`,`TABLE`,`FIGURE`,`UL`,`OL`,`HR`]),gr=class{constructor(e){this.context=e,this.options=e.options,this._history=null,this._disposers=[],this._snapshotTimer=null,this._limitCounter=null}initialize(){let e=this.context.layoutInfo.editable;return this._history=new Zt(e,this.options.historyLimit||100,this.options.historyMaxBytes||10485760),this._bindEvents(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._history=null,clearTimeout(this._snapshotTimer),this._snapshotTimer=null}_bindEvents(e){let t=e=>this._onKeydown(e),n=()=>this.afterCommand(),r=e=>this._enforceLimit(e),i=()=>{if(!this.context._alive)return;let t=globalThis.getSelection();t?.rangeCount>0&&e.contains(t.anchorNode)&&(this.context.invoke(`toolbar.refresh`),typeof this.options.onSelectionChange==`function`&&this.options.onSelectionChange(this.context))},a=e=>{e.target.type===`checkbox`&&e.target.closest(`.an-checklist`)&&this.afterCommand()},o=t=>{let n=globalThis.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);if(!r.collapsed)return;let i=r.startContainer;if(i.nodeType!==Node.ELEMENT_NODE)return;let a=i,o=a.matches(`.an-checklist li`)?a:null;if(!o)return;let s=o.querySelector(`input[type="checkbox"]`);if(!s)return;if(t?.type===`mouseup`){let r=null;if(document.caretRangeFromPoint)r=document.caretRangeFromPoint(t.clientX,t.clientY);else if(document.caretPositionFromPoint){let e=document.caretPositionFromPoint(t.clientX,t.clientY);e&&(r=document.createRange(),r.setStart(e.offsetNode,e.offset))}if(r&&e.contains(r.startContainer)&&r.startContainer!==o){r.collapse(!0),n.removeAllRanges(),n.addRange(r);return}}let c=document.createRange(),l=null;for(let e of o.childNodes)if(e!==s&&e.nodeType===Node.TEXT_NODE){l=e;break}l?c.setStart(l,0):c.setStartAfter(s),c.collapse(!0),n.removeAllRanges(),n.addRange(c)},s=()=>this.context.layoutInfo.container.classList.contains(`an-disabled`);this._disposers.push(_(e,`keydown`,t),_(e,`beforeinput`,r),_(e,`input`,n),_(document,`selectionchange`,i),_(e,`click`,a),_(e,`mouseup`,o),_(e,`keyup`,o),_(e,`dragstart`,e=>{if(s()){e.preventDefault();return}let t=e.target;t&&(t.nodeName===`IFRAME`||t.closest(`.an-video-wrapper`))&&e.preventDefault()}),_(e,`drop`,e=>{s()&&e.preventDefault()}));let c=null;this._disposers.push(_(e,`compositionstart`,()=>{let e=globalThis.getSelection();if(!e?.rangeCount){c=null;return}let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),t){let e=t;c=e.closest(`sup`)?`superscript`:e.closest(`sub`)?`subscript`:null}}),_(e,`compositionend`,()=>{let e=c;if(c=null,!e)return;let t=globalThis.getSelection();if(!t?.rangeCount)return;let n=t.getRangeAt(0).startContainer;n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);let r=n;(e===`superscript`?r?.closest(`sup`):r?.closest(`sub`))||document.execCommand(e)}))}_onKeydown(e){let t=this.context.layoutInfo.editable;if(!on(e,t,this.options)){if(F(e,`z`)&&!e.shiftKey){e.preventDefault(),this.undo();return}if(F(e,`z`)&&e.shiftKey||F(e,`y`)){e.preventDefault(),this.redo();return}if(F(e,`b`)){e.preventDefault(),this.bold();return}if(F(e,`i`)){e.preventDefault(),this.italic();return}if(F(e,`u`)){e.preventDefault(),this.underline();return}if(F(e,`k`)){e.preventDefault(),this.context.invoke(`linkDialog.show`);return}if(F(e,`v`)&&e.shiftKey){this.context.invoke(`clipboard.setForcePlain`,!0);return}if(e.key===`/`&&e.shiftKey&&e.ctrlKey&&!e.metaKey){e.preventDefault(),this.context.invoke(`shortcutsDialog.show`);return}if(F(e,`f`)){e.preventDefault(),this.context.invoke(`findReplace.show`,`find`);return}F(e,`h`)&&(e.preventDefault(),this.context.invoke(`findReplace.show`,`replace`)),F(e,"`")&&(e.preventDefault(),this.inlineCode())}}_enforceLimit(e){let t=this.options.maxChars||0,n=this.options.maxWords||0;if(!t&&!n)return;this._limitCounter??=new fn;let r=e.inputType||``;if(r.startsWith(`delete`)||r===`historyUndo`||r===`historyRedo`||r===`insertFromPaste`||r===`insertFromDrop`||!r.startsWith(`insert`))return;let{words:i,chars:a}=this._limitCounter.counts(this.context.layoutInfo.editable);if(t&&a>=t){e.preventDefault(),typeof this.options.onCharLimitReached==`function`&&this.options.onCharLimitReached(this.context);return}n&&(e.data===` `||r===`insertParagraph`||r===`insertLineBreak`)&&i>=n&&(e.preventDefault(),typeof this.options.onWordLimitReached==`function`&&this.options.onWordLimitReached(this.context))}afterCommand(){this._cleanOrphanedFigures(),this._ensureTrailingParagraph(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this._scheduleSnapshot()}_scheduleSnapshot(){clearTimeout(this._snapshotTimer),this._snapshotTimer=setTimeout(()=>{this._snapshotTimer=null,this._history&&this._history.recordUndo(),this.context.triggerEvent(`change`,this.getHTML())},400)}_cleanOrphanedFigures(){this.context.layoutInfo.editable.querySelectorAll(`figure.an-figure`).forEach(e=>{e.querySelector(`img`)||e.remove()})}_ensureTrailingParagraph(){let e=this.context.layoutInfo.editable;if(!e)return;let t=e.lastElementChild;if(t&&hr.has(t.nodeName)){let t=document.createElement(`p`);t.innerHTML=`<br>`,e.appendChild(t)}}focus(){this.context.layoutInfo.editable.focus()}getHTML(){let e=this.context.layoutInfo.editable.innerHTML.replaceAll(``,``);return this.context.invoke(`clipboard.resolveImages`,e)??e}setHTML(e){let t=Rt(e,{allowIframes:!0});this.context.layoutInfo.editable.replaceChildren(...t.childNodes),this._history&&this._history.reset(),this.afterCommand()}getText(){return this.context.layoutInfo.editable.innerText||``}setText(e){this.context.layoutInfo.editable.textContent=e,this._history&&this._history.reset(),this.afterCommand()}clear(){this.setHTML(``)}clearHistory(){this._history&&this._history.reset()}isEmpty(){let e=(this.context.layoutInfo.editable.innerText||``).trim().replaceAll(`\xA0`,``),t=!!this.context.layoutInfo.editable.querySelector(`img, video, iframe, table`);return!e&&!t}insertHTML(e){e&&(k(`insertHTML`,M(e)),this.afterCommand())}insertText(e){e&&(k(`insertText`,e),this.afterCommand())}setMarkdown(e){this.setHTML(Mn(e||``))}getMarkdown(){return mn(this.getHTML())}undo(){this._history&&(this._flushPendingSnapshot(),this._history.undo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}redo(){this._history&&(this._flushPendingSnapshot(),this._history.redo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}_flushPendingSnapshot(){this._snapshotTimer!==null&&(clearTimeout(this._snapshotTimer),this._snapshotTimer=null,this._history?.recordUndo())}canUndo(){return this._history?this._history.canUndo():!1}canRedo(){return this._history?this._history.canRedo():!1}getUndoCount(){return this._history?this._history.getUndoCount():0}getRedoCount(){return this._history?this._history.getRedoCount():0}getSelectionBookmark(){return this._history?._serializeSelection()??null}restoreSelectionBookmark(e){return!e||!this._history?!1:(this._history._restoreSelection(e),!0)}bold(){ae(),this.afterCommand()}italic(){oe(),this.afterCommand()}underline(){se(),this.afterCommand()}strikethrough(){ce(),this.afterCommand()}superscript(){le(),this.afterCommand()}subscript(){ue(),this.afterCommand()}justifyLeft(){ge(),this.afterCommand()}justifyCenter(){_e(),this.afterCommand()}justifyRight(){ve(),this.afterCommand()}justifyFull(){ye(),this.afterCommand()}indent(){be(),this.afterCommand()}outdent(){Se(),this.afterCommand()}insertUL(){De(),this.afterCommand()}insertOL(){Oe(),this.afterCommand()}inlineCode(){Ae(this.context.layoutInfo.editable),this.afterCommand()}toggleChecklist(){Pe(),this.afterCommand()}print(){this.context.print()}formatBlock(e){if(he(e),e===`pre`){let e=globalThis.getSelection();if(e?.rangeCount>0){let t=e.getRangeAt(0).commonAncestorContainer,n=t.nodeType===1?t.closest(`pre`):t.parentElement?.closest(`pre`);if(n&&!n.dataset.language){let e=mr(n.textContent||``);if(e){this.context.invoke(`codeTooltip.applyLanguage`,n,e);return}}}}this.afterCommand()}foreColor(e){de(e),this.afterCommand()}backColor(e){fe(e),this.afterCommand()}fontName(e){pe(e),this.afterCommand()}fontSize(e){me(e,this.context.layoutInfo.editable),this.afterCommand()}insertHr(){k(`insertHorizontalRule`),this.afterCommand()}insertLink(e,t,n=!1){let r=globalThis.getSelection();if(!r||r.rangeCount===0)return;let i=Ht(e);if(i){if(r.toString().trim().length>0){if(k(`createLink`,i),n){let e=this._getClosestAnchor();e&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}}else{let e=this._escapeAttr(t||i);k(`insertHTML`,`<a href="${this._escapeAttr(i)}"${n?` target="_blank" rel="noopener noreferrer"`:``}>${e}</a>`)}this.afterCommand()}}unlink(){k(`unlink`),this.afterCommand()}insertImage(e,t=``,n=``){let r=Ht(e,{allowData:!0});if(!r)return;let i={left:`float:left;margin:0 1em 1em 0`,center:`display:block;margin:0 auto`,right:`float:right;margin:0 0 1em 1em`}[n]||``,a=i?` style="${i}"`:``;k(`insertHTML`,`<img src="${this._escapeAttr(r)}" alt="${this._escapeAttr(t)}" class="an-image"${a}>`),this.afterCommand()}insertVideo(e){e&&(k(`insertHTML`,e),this.afterCommand())}insertTable(e,t){$t(e,t,{headerRow:this.context.options.tableHeaderRow}),this.afterCommand()}_getClosestAnchor(){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).startContainer;for(;t;){if(t.nodeName===`A`)return t;t=t.parentNode}return null}_escapeAttr(e){return String(e??``).replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}},_r=e=>typeof e==`string`?Re(e):e,vr=null,yr=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,V=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${yr} style="display:block">${e}</svg>`,H=new Map([[`bold`,V(`<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"/>`)],[`italic`,V(`<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"/>`)],[`underline`,V(`<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"/>`)],[`strikethrough`,V(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`)],[`superscript`,V(`<path d="m4 19 8-8"/><path d="m12 19-8-8"/><path d="M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7.25C20 6 19 5 17.5 5S15 6 15 7"/>`)],[`subscript`,V(`<path d="m4 5 8 8"/><path d="m12 5-8 8"/><path d="M20 21h-4c0-1.5.44-2 1.5-2.5S20 17.33 20 16.25C20 15 19 14 17.5 14S15 15 15 16"/>`)],[`align-left`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/>`)],[`align-center`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="18" y1="12" x2="6" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`align-right`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/>`)],[`align-justify`,V(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`list-ul`,V(`<line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1" fill="currentColor" stroke="none"/>`)],[`list-ol`,V(`<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 6h1V3"/><path d="M4 10h2l-2 2h2"/><path d="M4 16.5A1.5 1.5 0 0 1 5.5 15a1.5 1.5 0 0 1 0 3H4"/>`)],[`indent`,V(`<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"/>`)],[`outdent`,V(`<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"/>`)],[`undo`,V(`<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>`)],[`redo`,V(`<path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/>`)],[`minus`,V(`<line x1="5" y1="12" x2="19" y2="12"/>`)],[`link`,V(`<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"/>`)],[`image`,V(`<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/>`)],[`video`,V(`<polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/>`)],[`table`,V(`<rect x="3" y="3" width="18" height="18" rx="1"/><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"/>`)],[`emoji`,V(`<circle cx="12" cy="12" r="10"/><path d="M8.5 14.5s1.5 2.5 3.5 2.5 3.5-2.5 3.5-2.5"/><circle cx="9" cy="9" r="1.5" fill="currentColor" stroke="none"/><circle cx="15" cy="9" r="1.5" fill="currentColor" stroke="none"/>`)],[`icon`,V(`<circle cx="8" cy="8" r="3"/><circle cx="16" cy="8" r="3"/><rect x="5" y="13" width="6" height="6" rx="1"/><rect x="13" y="13" width="6" height="6" rx="1"/>`)],[`code`,V(`<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>`)],[`expand`,V(`<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/>`)],[`foreColor`,V(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`)],[`backColor`,V(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/>`)],[`keyboard`,V(`<rect x="2" y="6" width="20" height="12" rx="2"/><line x1="6" y1="10" x2="6" y2="10" stroke-width="2.5"/><line x1="10" y1="10" x2="10" y2="10" stroke-width="2.5"/><line x1="14" y1="10" x2="14" y2="10" stroke-width="2.5"/><line x1="18" y1="10" x2="18" y2="10" stroke-width="2.5"/><line x1="8" y1="14" x2="16" y2="14" stroke-width="2"/>`)],[`caption`,V(`<rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/>`)],[`remove-format`,V(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`)],[`direction`,V(`<path d="M12 20V4"/><path d="m9 7-3 3 3 3"/><path d="M4 10h8"/><path d="m15 7 3 3-3 3"/><path d="M20 10h-8"/>`)],[`search`,V(`<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`)],[`find-replace`,V(`<circle cx="10" cy="10" r="6"/><line x1="18" y1="18" x2="14.35" y2="14.35"/><path d="M16 19h6"/><path d="M19 16v6"/>`)],[`inline-code`,V(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)],[`checklist`,V(`<rect x="3" y="4" width="5" height="5" rx="1"/><path d="m4 6.5 1 1 2-2"/><rect x="3" y="13" width="5" height="5" rx="1"/><line x1="10" y1="6.5" x2="21" y2="6.5"/><line x1="10" y1="15.5" x2="21" y2="15.5"/>`)],[`print`,V(`<path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/>`)]]),br=new Map([[`bold`,`fa-bold`],[`italic`,`fa-italic`],[`underline`,`fa-underline`],[`strikethrough`,`fa-strikethrough`],[`superscript`,`fa-superscript`],[`subscript`,`fa-subscript`],[`align-left`,`fa-align-left`],[`align-center`,`fa-align-center`],[`align-right`,`fa-align-right`],[`align-justify`,`fa-align-justify`],[`list-ul`,`fa-list-ul`],[`list-ol`,`fa-list-ol`],[`indent`,`fa-indent`],[`outdent`,`fa-outdent`],[`undo`,`fa-rotate-left`],[`redo`,`fa-rotate-right`],[`minus`,`fa-minus`],[`link`,`fa-link`],[`image`,`fa-image`],[`code`,`fa-code`],[`expand`,`fa-expand`],[`emoji`,`fa-face-smile`],[`icon`,`fa-icons`],[`foreColor`,`fa-font`],[`backColor`,`fa-highlighter`],[`keyboard`,`fa-keyboard`],[`remove-format`,`fa-remove-format`],[`direction`,`fa-arrow-right-arrow-left`],[`search`,`fa-magnifying-glass`],[`find-replace`,`fa-magnifying-glass-plus`],[`inline-code`,`fa-code`],[`checklist`,`fa-list-check`],[`print`,`fa-print`]]),xr=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._colorPickerClosers=[],this._refreshRaf=null}initialize(){return this.el=m(`div`,{class:`an-toolbar`,role:`toolbar`,"aria-orientation":`horizontal`,"aria-label":`Editor toolbar`}),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(_r).filter(Boolean).map(e=>[e.name,e])),this}destroy(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=null,this._disposers.forEach(e=>e()),this._disposers=[],this.el?.parentNode&&this.el.remove(),this.el=null}_buildButtons(){let e=this.options.toolbar||[],t=document.createDocumentFragment();e.forEach(e=>{let n=m(`div`,{class:`an-btn-group`});e.forEach(e=>{let t=_r(e);if(!t){console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);return}let r;r=t.type===`select`?this._createSelect(t):t.type===`grid`?this._createGridPicker(t):t.type===`colorpicker`?this._createColorPicker(t):this._createButton(t),n.appendChild(r)}),t.appendChild(n)}),this.el.appendChild(t)}_createGridPicker(e){let t=m(`div`,{class:`an-table-picker-wrap`}),n=m(`button`,{type:`button`,class:this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,"aria-haspopup":`true`,"aria-expanded":`false`});n.innerHTML=this._faReady?`<i class="${this.options.fontAwesomeClass||`fas`} fa-table" aria-hidden="true"></i>`:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:block"><rect x="3" y="3" width="18" height="18" rx="1"/><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>`;let r=m(`div`,{class:`an-table-picker-popup`,role:`dialog`,"aria-label":`Select table size`}),i=m(`div`,{class:`an-table-grid`}),a=m(`div`,{class:`an-table-label`});a.textContent=this.context.locale.toolbar.insertTableLabel||`Insert Table`;let o=[];for(let e=1;e<=10;e++)for(let t=1;t<=10;t++){let n=m(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});o.push(n),i.appendChild(n)}r.appendChild(i),r.appendChild(a);let s=!1,c=(e,t)=>{o.forEach(n=>{let r=+n.dataset.row,i=+n.dataset.col;n.classList.toggle(`active`,r<=e&&i<=t)}),a.textContent=e&&t?`${e} × ${t}`:this.context.locale.toolbar.insertTableLabel||`Insert Table`},l=()=>{s=!0;let e=n.getBoundingClientRect();r.style.visibility=`hidden`,r.style.display=`block`;let t=r.offsetWidth,i=r.offsetHeight,a=e.left,o=e.bottom+4;a+t>globalThis.innerWidth-8&&(a=Math.max(8,globalThis.innerWidth-t-8)),o+i>globalThis.innerHeight-8&&(o=e.top-i-4),r.style.left=`${a}px`,r.style.top=`${o}px`,r.style.visibility=``,n.setAttribute(`aria-expanded`,`true`)},u=()=>{s=!1,r.style.display=`none`,n.setAttribute(`aria-expanded`,`false`),c(0,0)},d=_(n,`click`,e=>{e.stopPropagation(),s?u():l()}),f=_(i,`mouseover`,e=>{let t=e.target?.closest(`.an-table-cell`);t&&c(+t.dataset.row,+t.dataset.col)}),p=_(i,`mouseleave`,()=>c(0,0)),h=_(i,`click`,t=>{let n=t.target?.closest(`.an-table-cell`);if(!n)return;let r=+n.dataset.row,i=+n.dataset.col;u(),this.context.invoke(`editor.focus`),e.action(this.context,r,i)}),g=_(document,`click`,()=>{s&&u()});return this._disposers.push(d,f,p,h,g,()=>{r.parentNode&&r.remove()}),t.appendChild(n),document.body.appendChild(r),t}_createColorPicker(e){let t=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],n=e.defaultColor||`#000000`,r=m(`div`,{class:`an-color-picker-wrap`}),i=this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,a=m(`button`,{type:`button`,class:`${i} an-color-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),o=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`;a.innerHTML=e.name===`foreColor`?`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${o} style="display:block"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${o} style="display:block"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/></svg>`;let s=m(`span`,{class:`an-color-strip`});s.style.background=n,a.appendChild(s);let c=m(`button`,{type:`button`,class:`${i} an-color-arrow`,title:e.name===`foreColor`?this.context.locale.toolbar.chooseTextColor||`Choose text color`:this.context.locale.toolbar.chooseHighlightColor||`Choose highlight color`,"aria-haspopup":`true`,"aria-expanded":`false`});c.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 24 24" fill="currentColor" stroke="none" style="display:block"><path d="M7 10l5 5 5-5H7z"/></svg>`;let l=m(`div`,{class:`an-color-popup`});l.style.display=`none`;let u=m(`div`,{class:`an-color-swatches`}),d=Array.isArray(this.options.colorSwatches)?this.options.colorSwatches:[];[...new Set([...d,...t])].forEach(e=>{let t=m(`div`,{class:`an-color-swatch`,title:e,"data-color":e});t.style.background=e,u.appendChild(t)});let f=m(`div`,{class:`an-color-custom`}),p=m(`input`,{type:`color`,value:n,title:this.context.locale.toolbar.customColor||`Custom color`}),h=m(`span`,{},[this.context.locale.toolbar.customColor||`Custom color`]);f.appendChild(p),f.appendChild(h),l.appendChild(u),l.appendChild(f);let g=!1,v=null,ee=()=>{let e=globalThis.getSelection();v=e?.rangeCount?e.getRangeAt(0).cloneRange():null},y=()=>{if(v)try{let e=globalThis.getSelection();if(!e)return;e.removeAllRanges(),e.addRange(v)}catch{}},b=()=>{this._colorPickerClosers.forEach(e=>{e!==x&&e()}),ee(),g=!0;let e=c.getBoundingClientRect(),t=e.left;t+184>globalThis.innerWidth&&(t=e.right-184),l.style.top=`${e.bottom+4}px`,l.style.left=`${Math.max(4,t)}px`,l.style.display=`block`,c.setAttribute(`aria-expanded`,`true`)},x=()=>{g=!1,l.style.display=`none`,l.style.top=``,l.style.left=``,c.setAttribute(`aria-expanded`,`false`)},S=t=>{n=t,s.style.background=t,p.value=t,y(),e.action(this.context,t),this.context.invoke(`editor.afterCommand`),x()},C=_(a,`click`,t=>{t.preventDefault(),y(),e.action(this.context,n),this.context.invoke(`editor.afterCommand`)}),w=_(c,`mousedown`,e=>{e.preventDefault()}),T=_(c,`click`,e=>{e.stopPropagation(),g?x():b()}),E=_(u,`mousedown`,e=>{e.preventDefault()}),D=_(u,`click`,e=>{let t=e.target?.closest(`.an-color-swatch`);t&&S(t.dataset.color)}),te=_(p,`change`,e=>{S(e.target.value)}),ne=_(document,`click`,e=>{g&&!r.contains(e.target)&&!l.contains(e.target)&&x()}),re=_(l,`click`,e=>e.stopPropagation()),O=()=>{g&&x()};return document.addEventListener(`scroll`,O,{passive:!0,capture:!0}),globalThis.addEventListener(`resize`,O,{passive:!0}),this._disposers.push(C,w,T,E,D,te,ne,re,()=>document.removeEventListener(`scroll`,O,{capture:!0}),()=>globalThis.removeEventListener(`resize`,O),()=>{l.parentNode&&l.remove()}),this._colorPickerClosers.push(x),this._disposers.push(()=>{let e=this._colorPickerClosers.indexOf(x);e!==-1&&this._colorPickerClosers.splice(e,1)}),r.appendChild(a),r.appendChild(c),document.body.appendChild(l),r}_createSelect(e){let t=e.name===`fontFamily`?this.options.fontFamilies||[]:e.items||[],n=m(`select`,{class:e.selectClass?`an-select ${e.selectClass}`:`an-select`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),r=m(`option`,{value:``,disabled:``,hidden:``},[this.context.locale.toolbar[e.name+`Placeholder`]||e.placeholder||`Font`]);n.appendChild(r),t.forEach(t=>{let r=typeof t==`object`?t.value:t,i;i=typeof t==`object`?e.name===`paragraphStyle`&&this.context.locale.toolbar.paragraphItems?.[t.value]||t.label:t;let a=typeof t==`object`&&!!t.disabled,o={value:r};a&&(o.disabled=``);let s=m(`option`,o,[i]);e.name===`fontFamily`&&!a&&(s.style.fontFamily=r),n.appendChild(s)});let i=null,a=_(n,`mousedown`,()=>{let e=globalThis.getSelection();i=e?.rangeCount?e.getRangeAt(0).cloneRange():null}),o=_(n,`change`,t=>{let n=t.target.value,r=t.target.options[t.target.selectedIndex];if(!(!n||r.disabled)){if(this.context.invoke(`editor.focus`),i)try{let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(i))}catch{}e.action(this.context,n),this.context.invoke(`editor.afterCommand`)}});return this._disposers.push(a,o),n}_createButton(e){let t=m(`button`,{type:`button`,class:`${this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`}${e.className?` ${e.className}`:``}`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,...typeof e.isActive==`function`?{"aria-pressed":`false`}:{}}),n=this.options.fontAwesomeClass||`fas`;if(this._faReady){let r=br.get(e.icon)||br.get(e.name)||null;r?t.innerHTML=`<i class="${n} ${r}" aria-hidden="true"></i>`:H.has(e.icon)?t.innerHTML=H.get(e.icon):t.textContent=e.icon||e.name}else H.has(e.icon)?t.innerHTML=H.get(e.icon):H.has(e.name)?t.innerHTML=H.get(e.name):t.textContent=e.icon||e.name;let r=_(t,`click`,t=>{t.preventDefault(),this.context.invoke(`editor.focus`),e.action(this.context),this.context.invoke(`editor.afterCommand`),this.refresh()});return this._disposers.push(r),t}_controls(){return this.el?Array.from(this.el.querySelectorAll(`button, select`)):[]}_navigable(){return this._controls().filter(e=>!e.disabled)}_syncRovingTabindex(e){let t=this._controls(),n=this._navigable();if(!n.length)return;let r=e&&n.includes(e)?e:n.find(e=>e.getAttribute(`tabindex`)===`0`)||n[0];t.forEach(e=>e.setAttribute(`tabindex`,e===r?`0`:`-1`))}_initRovingFocus(){this.el&&(this._syncRovingTabindex(),this._disposers.push(_(this.el,`keydown`,e=>this._onToolbarKeydown(e)),_(this.el,`focusin`,e=>{let t=e.target?.closest?.(`button, select`);t&&this._syncRovingTabindex(t)})))}_onToolbarKeydown(e){if(![`ArrowRight`,`ArrowLeft`,`Home`,`End`].includes(e.key))return;let t=this._navigable(),n=e.target?.closest?.(`button, select`),r=n?t.indexOf(n):-1;if(r===-1)return;let i;if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t.at(-1);else{let n=this.options.direction===`rtl`;i=t[(r+(e.key===`ArrowRight`===n?-1:1)+t.length)%t.length]}i&&(e.preventDefault(),this._syncRovingTabindex(i),i.focus())}_detectFontAwesome(){if(!this.options.useFontAwesome)return!1;if(vr!==null)return vr;if(document.querySelector(`.fa, .fas, .far, .fal, .fab, .fa-solid`))return vr=!0,!0;let e=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).filter(e=>e.id!==`an-fontawesome-css`).map(e=>e.href||``).join(` `);return vr=/fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e),vr}refresh(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,this._doRefresh()})}_doRefresh(){if(!this.el)return;let e=this._btnMap||new Map;this.el.querySelectorAll(`button[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(n&&typeof n.isActive==`function`){let e=!!n.isActive(this.context);t.classList.toggle(`active`,e),t.setAttribute(`aria-pressed`,String(e))}n&&typeof n.isDisabled==`function`&&(t.disabled=!!n.isDisabled(this.context))}),this._syncRovingTabindex(),this.el.querySelectorAll(`select[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(!n||typeof n.getValue!=`function`)return;let r=(n.getValue(this.context)||``).replace(/["']/g,``).trim();r||=this.options.defaultFontFamily||this.options.fontFamilies?.[0]||``;let i=t,a=Array.from(i.options).find(e=>e.value?.toLowerCase()===r.toLowerCase());i.value=a?a.value:``})}show(){this.el&&(this.el.style.display=``)}hide(){this.el&&(this.el.style.display=`none`)}rebuild(){this._refreshRaf&&=(cancelAnimationFrame(this._refreshRaf),null),this._disposers.forEach(e=>e()),this._disposers=[],this.el&&(this.el.innerHTML=``),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(_r).filter(Boolean).map(e=>[e.name,e])),this.refresh()}};function Sr(e,t,n){if(!n){e.classList.remove(`an-count-warn`,`an-count-exceeded`);return}t>n?(e.classList.add(`an-count-exceeded`),e.classList.remove(`an-count-warn`)):t>=n*.9?(e.classList.add(`an-count-warn`),e.classList.remove(`an-count-exceeded`)):e.classList.remove(`an-count-warn`,`an-count-exceeded`)}var Cr=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._wordCountEl=null,this._charCountEl=null,this._counter=new fn}initialize(){if(this.el=m(`div`,{class:`an-statusbar`}),this.options.resizable!==!1){let e=m(`div`,{class:`an-resize-handle`,title:this.context.locale.statusbar.resizeHandle,"aria-hidden":`true`});this._bindResize(e),this.el.appendChild(e)}this._wordCountEl=m(`span`,{class:`an-word-count`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`}),this._charCountEl=m(`span`,{class:`an-char-count`,"aria-live":`polite`,"aria-atomic":`true`});let e=m(`div`,{class:`an-status-info`,"aria-label":`Editor statistics`});return e.appendChild(this._wordCountEl),e.appendChild(this._charCountEl),this.el.appendChild(e),this.update(),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this.el?.remove(),this.el=null}_bindResize(e){let t=0,n=0,r=this.context.layoutInfo.container,i=e=>{let i=e-t,a=Array.from(r.children).filter(e=>!e.classList.contains(`an-editable`)).reduce((e,t)=>e+t.offsetHeight,0),o=Math.max(this.options.minHeight||100,a+40);r.style.height=`${Math.max(o,n+i)}px`},a=e=>i(e.clientY),o=()=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),this._dragDisposers=null},s=e=>{t=e.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o),this._dragDisposers=[()=>document.removeEventListener(`mousemove`,a),()=>document.removeEventListener(`mouseup`,o)],e.preventDefault()},c=e=>{let t=e.touches[0];t&&(e.preventDefault(),i(t.clientY))},l=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),this._dragDisposers=null},u=e=>{let i=e.touches[0];i&&(t=i.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),this._dragDisposers=[()=>document.removeEventListener(`touchmove`,c),()=>document.removeEventListener(`touchend`,l)])},d=_(e,`mousedown`,s),f=_(e,`touchstart`,u);this._disposers.push(d,f)}_counts(){return this._counter.counts(this.context.layoutInfo.editable)}update(){if(!this._wordCountEl||!this._charCountEl)return;let{words:e,chars:t}=this._counts(),n=this.options.maxWords||0,r=this.options.maxChars||0,i=this.context.locale.statusbar;this._wordCountEl.textContent=n?i.wordsLimit(e,n):i.words(e),this._charCountEl.textContent=r?i.charsLimit(t,r):i.chars(t),Sr(this._wordCountEl,e,n),Sr(this._charCountEl,t,r)}getWordCount(){return this._counts().words}getCharCount(){return this._counts().chars}},wr=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){this._blobRegistry=new Map,this._forcePlain=!1;let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`paste`,e=>this._onPaste(e)),_(e,`dragover`,e=>this._onDragover(e)),_(e,`drop`,e=>this._onDrop(e))),this._mutationObserver=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)this._revokeRemovedBlobs(e)}),this._mutationObserver.observe(e,{childList:!0,subtree:!0}),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._mutationObserver&&=(this._mutationObserver.disconnect(),null),this._blobRegistry&&(this._blobRegistry.forEach((e,t)=>URL.revokeObjectURL(t)),this._blobRegistry.clear()),this._uploadPreviews&&(this._uploadPreviews.forEach(({previewUrl:e})=>URL.revokeObjectURL(e)),this._uploadPreviews.clear())}_revokeRemovedBlobs(e){if(!this._blobRegistry?.size)return;let t=[];e.nodeName===`IMG`?t.push(e):e.querySelectorAll&&t.push(...e.querySelectorAll(`img`)),t.forEach(e=>{let t=e.getAttribute(`src`)||``;t.startsWith(`blob:`)&&this._blobRegistry.has(t)&&(URL.revokeObjectURL(t),this._blobRegistry.delete(t))})}_cleanWordHtml(e){return e.replace(/<!--\[if[\s\S]*?\[endif\]-->/gi,``).replace(/<xml[\s\S]*?<\/xml>/gi,``).replace(/<\?xml[\s\S]*?\?>/gi,``).replace(/<\/?(o|w|m|v|st1):[a-z][^>]*>/gi,``).replace(/\s+class="Mso[^"]*"/gi,``).replace(/\s+style="([^"]*)"/gi,(e,t)=>{let n=t.split(`;`).map(e=>e.trim()).filter(e=>e&&!/^mso-/i.test(e)&&!/^(tab-stops|margin-[a-z]+-alt)/i.test(e)).join(`; `);return n?` style="${n}"`:``}).replace(/<p[^>]*>\s*( )?\s*<\/p>/gi,``)}_cleanSocialHtml(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=Array.from(t.querySelectorAll(`span, div`));for(let e=n.length-1;e>=0;e--){let t=n[e];if(!t.parentNode||t.querySelector(`a, strong, em, b, i, ul, ol, li, table, img, blockquote, pre, code, h1, h2, h3, h4, h5, h6`))continue;let r=t.parentNode;for(;t.firstChild;)r.insertBefore(t.firstChild,t);t.remove()}return t.querySelectorAll(`*`).forEach(e=>{e.removeAttribute(`class`),e.removeAttribute(`id`),Array.from(e.attributes).filter(e=>e.name.startsWith(`data-`)||e.name.startsWith(`aria-`)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_stripAttributes(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=new Set([`href`,`src`,`alt`,`target`,`rel`,`colspan`,`rowspan`,`type`]);return t.querySelectorAll(`*`).forEach(e=>{Array.from(e.attributes).filter(e=>!n.has(e.name)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_normalizeExternalTaskLists(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);for(let e of t.querySelectorAll(`input[type="checkbox"]`)){let t=e.closest(`li`),n=t?.closest(`ul`);if(!(!t||!n||n.classList.contains(`an-checklist`))){n.classList.add(`an-checklist`),e.removeAttribute(`disabled`),e.setAttribute(`contenteditable`,`false`);for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}}return t.body.innerHTML}_isTriviallyPlainHtml(e){return!new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`).body.querySelector(`a,img,table,ul,ol,li,blockquote,pre,code,h1,h2,h3,h4,h5,h6,strong,b,em,i,u,s,del,strike,hr,br`)}setForcePlain(e){this._forcePlain=!!e}_onPaste(e){let t=e.clipboardData||globalThis.clipboardData;if(!t)return;let n=this._forcePlain;this._forcePlain=!1;let r=(this.options.maxPasteSize??5)*1024*1024;if(r>0){let n=t.getData(`text/plain`)||``,i=t.getData(`text/html`)||``,a=Math.max(n.length,i.length);if(a>r){e.preventDefault();let t=`Pasted content (${a} bytes) exceeds the ${this.options.maxPasteSize??5} MB paste size limit.`;this.context.triggerEvent(`pasteError`,{size:a,maxBytes:r,message:t}),console.warn(`[AutumnNote] ${t}`);return}}if(t.items){let n=Array.from(t.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(n.length>0){e.preventDefault();let t=n.map(e=>e.getAsFile()).filter(Boolean);this._insertImageFiles(t);return}}if(typeof this.options.onPaste==`function`&&this.options.onPaste({text:t.getData(`text/plain`)||``,html:t.types.includes(`text/html`)?t.getData(`text/html`):null}),n||this.options.pasteAsPlainText){e.preventDefault(),k(`insertHTML`,t.getData(`text/plain`).split(/\r?\n/).map(e=>`<p>${this._escapeHTML(e)||`<br>`}</p>`).join(``)),this.context.invoke(`editor.afterCommand`);return}if(this.options.markdownPaste!==!1){let n=t.types.includes(`text/html`),r=n?t.getData(`text/html`):``,i=!n||this._isTriviallyPlainHtml(r),a=t.getData(`text/plain`);if(a&&i&&wn(a)){e.preventDefault(),k(`insertHTML`,M(Mn(a))),this.context.invoke(`editor.afterCommand`);return}}if(this.options.pasteCleanHTML!==!1&&t.types.includes(`text/html`)){e.preventDefault();let n=t.getData(`text/html`),r=/<[a-z]+:[a-z]/i.test(n)||/class="Mso/i.test(n)||/\bmso-/i.test(n),i=/class="[^"]*\b(?:x[a-z0-9]{6,}|r-[a-z0-9]{3,})\b/.test(n),a=n;r?a=this._cleanWordHtml(a):i&&(a=this._cleanSocialHtml(a)),a=this._normalizeExternalTaskLists(a),a=M(a),this.options.pasteStripAttributes&&(a=this._stripAttributes(a)),k(`insertHTML`,a),this.context.invoke(`editor.afterCommand`)}}_onDragover(e){e.dataTransfer&&Array.from(e.dataTransfer.types||[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}_onDrop(e){let t=e.dataTransfer;if(!t?.files?.length)return;let n=Array.from(t.files).filter(e=>e.type.startsWith(`image/`));if(n.length>0){e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertImageFiles(n);return}if(this.options.markdownPaste!==!1){let n=Array.from(t.files).find(e=>/\.md$/i.test(e.name)||e.type===`text/markdown`);n&&(e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertMarkdownFile(n))}}_insertMarkdownFile(e){let t=(this.options.maxPasteSize??5)*1024*1024;if(t>0&&e.size>t){let n=`Dropped file "${e.name}" (${e.size} bytes) exceeds the ${this.options.maxPasteSize??5} MB paste size limit.`;this.context.triggerEvent(`pasteError`,{size:e.size,maxBytes:t,message:n}),console.warn(`[AutumnNote] ${n}`);return}let n=new FileReader;n.onload=e=>{k(`insertHTML`,M(Mn(e.target.result||``))),this.context.invoke(`editor.afterCommand`)},n.onerror=()=>{let t=`Failed to read dropped markdown file "${e.name}".`;console.warn(`[AutumnNote] ${t}`),this.context.triggerEvent(`pasteError`,{message:t})},n.readAsText(e)}_insertImageFiles(e){if(!e||e.length===0)return;if(typeof this.options.onImageUpload==`function`){this._runUploadHandler(e);return}let t=new Set([`image/tiff`,`image/x-tiff`,`image/bmp`,`image/x-bmp`,`image/x-ms-bmp`]),n=(this.options.maxImageSize||5)*1024*1024;e.forEach(e=>{if(!e?.type?.startsWith(`image/`))return;if(t.has(e.type)){let t=`Image format "${e.type}" is not supported for display in web browsers. Please convert to PNG, JPEG, or WebP first.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote]`,t);return}if(e.size>n){let t=`Image "${e.name}" exceeds the ${this.options.maxImageSize||5} MB size limit.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote] ${t}`);return}let r=e.name.replace(/\.[^.]+$/,``);this.compressAndRegister(e).then(e=>{this.context.invoke(`editor.insertImage`,e,r)}).catch(t=>{let n=`Image "${e.name}" could not be processed.`;this.context.triggerEvent(`imageError`,{file:e,message:n,error:t}),console.warn(`[AutumnNote]`,n,t)})})}_escapeAttr(e){return String(e).replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}async _runUploadHandler(e){let t={context:this.context,setProgress:(e,t)=>this._setUploadProgress(e,t)},n;try{n=this.options.onImageUpload(e,t)}catch(t){this._reportUploadError(e,t);return}if(n===void 0)return;let r=e.map(e=>this._insertUploadPlaceholder(e)),i;try{i=await n}catch(t){r.forEach((n,r)=>this._failUpload(n,e[r],t));return}let a=Array.isArray(i)?i:[i];r.forEach((t,n)=>{let r=a[n];typeof r==`string`&&r?this._resolveUpload(t,r):this._failUpload(t,e[n],Error(`No URL returned for this file.`))})}_insertUploadPlaceholder(e){let t=`an-up-${Date.now().toString(36)}-${this._uploadSeq=(this._uploadSeq||0)+1}`,n=URL.createObjectURL(e);this._uploadPreviews=this._uploadPreviews||new Map,this._uploadPreviews.set(t,{previewUrl:n,file:e});let r=this._escapeAttr(e.name.replace(/\.[^.]+$/,``));return k(`insertHTML`,`<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`),this.context.invoke(`editor.afterCommand`),t}_findPlaceholder(e){return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`)??null}_resolveUpload(e,t){let n=this._findPlaceholder(e),r=this._uploadPreviews?.get(e);if(n){let i=Ht(t,{allowData:!0});if(i)n.setAttribute(`src`,i),n.classList.remove(`an-image-uploading`),n.removeAttribute(`data-an-upload`),n.style.removeProperty(`--an-upload-progress`);else{this._failUpload(e,r?.file,Error(`Rejected image URL: ${t}`));return}}r&&(URL.revokeObjectURL(r.previewUrl),this._uploadPreviews.delete(e)),this.context.invoke(`editor.afterCommand`)}_failUpload(e,t,n){let r=this._findPlaceholder(e);r&&(r.classList.remove(`an-image-uploading`),r.classList.add(`an-image-failed`),r.style.removeProperty(`--an-upload-progress`));let i=`Image "${t?.name??`unknown`}" could not be uploaded.`;console.warn(`[AutumnNote]`,i,n),this.context.triggerEvent(`imageError`,{file:t,message:i,error:n,retry:()=>{r?.remove(),this._uploadPreviews?.delete(e),t&&this._runUploadHandler([t])}})}_reportUploadError(e,t){let n=`The image upload handler threw before any file was sent.`;console.warn(`[AutumnNote]`,n,t),this.context.triggerEvent(`imageError`,{file:e[0],message:n,error:t})}_setUploadProgress(e,t){if(!this._uploadPreviews)return;let n=Math.max(0,Math.min(1,Number(t)||0));for(let[t,r]of this._uploadPreviews){if(r.file!==e)continue;let i=this._findPlaceholder(t);i&&i.style.setProperty(`--an-upload-progress`,String(n));return}}async compressAndRegister(e){let t=this.options.imageProcessor,n=typeof t==`function`?await t(e,{context:this.context}):await this._compressImage(e),r=this._dataUrlToBlob(n),i=URL.createObjectURL(r);return this._blobRegistry.set(i,n),i}resolveImages(e){return this._blobRegistry?.size?e.replace(/blob:[^"'> \t\n\r]*/g,e=>this._blobRegistry.get(e)||e):e}_dataUrlToBlob(e){let[t,n]=e.split(`,`),r=/:(.*?);/.exec(t)?.[1]??`image/png`,i=atob(n),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return new Blob([a],{type:r})}_compressImage(e){let t=1920,n=.85;return new Promise((r,i)=>{let a=URL.createObjectURL(e),o=new Image;o.onload=()=>{URL.revokeObjectURL(a);let{width:s,height:c}=o;(s>t||c>t)&&(s>=c?(c=Math.round(c*t/s),s=t):(s=Math.round(s*t/c),c=t));let l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u){let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e);return}u.drawImage(o,0,0,s,c);let d=l.toDataURL(`image/webp`,n);r(d.startsWith(`data:image/webp`)?d:l.toDataURL(`image/jpeg`,n))},o.onerror=()=>{URL.revokeObjectURL(a);let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e)},o.src=a})}_placeCaretAtPoint(e,t){let n;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(e,t);else if(document.caretPositionFromPoint){let r=document.caretPositionFromPoint(e,t);r&&(n=document.createRange(),n.setStart(r.offsetNode,r.offset),n.collapse(!0))}if(!n)return;let r=globalThis.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}_escapeHTML(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}},U={undo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>`,redo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/></svg>`,cut:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="20" r="3"/><circle cx="6" cy="4" r="3"/><line x1="19" y1="5" x2="6" y2="19"/><line x1="19" y1="19" x2="13.5" y2="13.5"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,paste:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>`,bold:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,link:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,video:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,videoAlign:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,copyFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,pasteFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/><path d="m9 14 2 2 4-4"/></svg>`,removeFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>`,table:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><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>`,textColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`,highlightColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/></svg>`,noColor:`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,back:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>`},Tr=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`];function Er(e){let t=e===`foreColor`?`Text Color`:`Highlight Color`,n=e===`foreColor`?`textColor`:`highlightColor`;return()=>[{back:!0,label:t,localeKey:n,navigate:()=>Dr},{colorPalette:!0,colorType:e}]}var Dr=[{name:`cut`,label:`Cut`,icon:U.cut,action:()=>document.execCommand(`cut`)},{name:`copy`,label:`Copy`,icon:U.copy,action:()=>document.execCommand(`copy`)},{name:`paste`,label:`Paste`,icon:U.paste,action:e=>{if(!navigator.clipboard)return;let t=e.layoutInfo?.editable;if(!t)return;let n=(n,r)=>{if(t.focus(),n){let e=M(n);document.execCommand(`insertHTML`,!1,e)}else r&&document.execCommand(`insertText`,!1,r);e.invoke(`editor.afterCommand`)};typeof navigator.clipboard.read==`function`?navigator.clipboard.read().then(e=>{for(let t of e)if(t.types.includes(`text/html`)){t.getType(`text/html`).then(e=>e.text()).then(e=>n(e,null)).catch(()=>{});return}navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}).catch(()=>{navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}):typeof navigator.clipboard.readText==`function`&&navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}},{separator:!0},{name:`bold`,label:`Bold`,icon:U.bold,action:e=>e.invoke(`editor.bold`)},{name:`italic`,label:`Italic`,icon:U.italic,action:e=>e.invoke(`editor.italic`)},{name:`underline`,label:`Underline`,icon:U.underline,action:e=>e.invoke(`editor.underline`)},{separator:!0},{name:`textColor`,label:`Text Color`,icon:U.textColor,colorStrip:`foreColor`,navigate:Er(`foreColor`)},{name:`highlightColor`,label:`Highlight Color`,icon:U.highlightColor,colorStrip:`hiliteColor`,navigate:Er(`hiliteColor`)},{separator:!0},{name:`copyFormat`,label:`Copy Format`,icon:U.copyFormat,action:e=>e.invoke(`contextMenu.copyFormat`)},{name:`pasteFormat`,label:`Paste Format`,icon:U.pasteFormat,action:e=>e.invoke(`contextMenu.pasteFormat`),disabled:e=>!e.invoke(`contextMenu.hasCopiedFormat`)},{name:`removeFormat`,label:`Remove Format`,icon:U.removeFormat,action:e=>e.invoke(`contextMenu.removeFormat`)},{separator:!0},{name:`link`,label:`Insert Link`,icon:U.link,action:e=>e.invoke(`linkDialog.show`)},{name:`image`,label:`Insert Image`,icon:U.image,action:e=>e.invoke(`imageDialog.show`)},{name:`video`,label:`Insert Video`,icon:U.video,action:e=>e.invoke(`videoDialog.show`)},{name:`table`,label:`Insert Table`,icon:U.table,tableGrid:!0}],Or=class{constructor(e){this.context=e,this.options=e.options,this._items=this.options.contextMenu?.items||Dr,this.el=null,this._disposers=[],this._menuDisposers=[],this._lastX=0,this._lastY=0,this._copiedFormat=null,this._savedRange=null}initialize(){this.el=m(`div`,{class:`an-contextmenu`,role:`menu`,"aria-hidden":`true`}),this.el.style.display=`none`,document.body.appendChild(this.el),this._renderItems(this._items);let e=this.context.layoutInfo?.editable;return e&&this._disposers.push(_(e,`contextmenu`,e=>this._onContextMenu(e))),this._disposers.push(_(document,`click`,e=>this._maybeHide(e)),_(document,`keydown`,e=>{e.key===`Escape`&&this.hide()}),_(globalThis,`scroll`,()=>this.hide(),{passive:!0})),this}destroy(){this._menuDisposers.forEach(e=>{try{e()}catch{}}),this._menuDisposers=[],this._disposers.forEach(e=>{try{e()}catch{}}),this._disposers=[],this.el&&this.el.remove(),this.el=null}_renderItems(e){this._menuDisposers.forEach(e=>e()),this._menuDisposers=[],this.el&&(this.el.innerHTML=``,e.forEach(e=>{if(e.separator||e.sep){this.el.appendChild(m(`div`,{class:`an-context-sep`}));return}if(e.back){let t=m(`button`,{type:`button`,class:`an-context-back`}),n=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=U.back,t.appendChild(n);let r=e.localeKey&&this.context.locale.contextMenu[e.localeKey]||e.label||this.context.locale.contextMenu.back||`Back`;t.appendChild(m(`span`,{class:`an-context-label`},[r]));let i=_(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(i),this.el.appendChild(t);return}if(e.navigate){let t=m(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||``});if(e.icon){if(e.colorStrip){let n=m(`span`,{class:`an-context-icon an-context-icon--color`,"aria-hidden":`true`}),r=m(`span`,{class:`an-context-icon-svg`});r.innerHTML=e.icon;let i=m(`span`,{class:`an-context-color-strip`});i.style.background=this._getSelectionColor(e.colorStrip),n.appendChild(r),n.appendChild(i),t.appendChild(n)}else{let n=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}}t.appendChild(m(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=m(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,t.appendChild(n);let r=_(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(r),this.el.appendChild(t);return}if(e.colorPalette){let t=m(`div`,{class:`an-context-color-palette`});if(Tr.forEach(n=>{let r=m(`div`,{class:`an-context-color-swatch`,title:n,role:`button`,"aria-label":n});r.style.background=n;let i=_(r,`click`,t=>{t.stopPropagation(),this._applyColor(e.colorType,n)});this._menuDisposers.push(i),t.appendChild(r)}),e.colorType===`hiliteColor`){let e=m(`div`,{class:`an-context-color-swatch an-context-color-none`,title:this.context.locale.contextMenu.noHighlight||`No highlight`,role:`button`,"aria-label":this.context.locale.contextMenu.noHighlight||`No highlight`});e.innerHTML=U.noColor;let n=_(e,`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});this._menuDisposers.push(n),t.appendChild(e)}this.el.appendChild(t);let n=m(`div`,{class:`an-context-color-custom`}),r=m(`input`,{type:`color`,value:e.colorType===`foreColor`?`#000000`:`#ffff00`,title:this.context.locale.contextMenu.customColor||`Custom color`,"aria-label":this.context.locale.contextMenu.customColor||`Custom color`}),i=m(`span`,{},[this.context.locale.contextMenu.customColorLabel||`Custom…`]),a=_(r,`change`,()=>this._applyColor(e.colorType,r.value));this._menuDisposers.push(a),n.appendChild(r),n.appendChild(i),this.el.appendChild(n);return}if(e.tableGrid){let t=m(`div`,{class:`an-context-table-wrap`}),n=m(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||`table`});if(e.icon){let t=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});t.innerHTML=e.icon,n.appendChild(t)}n.appendChild(m(`span`,{class:`an-context-label`},[this.context.locale.contextMenu.table||e.label||`Insert Table`]));let r=m(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,n.appendChild(r);let i=m(`div`,{class:`an-context-table-grid-panel`});i.style.display=`none`;let a=m(`div`,{class:`an-table-grid`});a.style.gridTemplateColumns=`repeat(8, 16px)`;let o=m(`div`,{class:`an-table-label`});o.textContent=`Insert Table`;let s=[];for(let e=1;e<=8;e++)for(let t=1;t<=8;t++){let n=m(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});n.style.width=`16px`,n.style.height=`16px`,s.push(n),a.appendChild(n)}let c=(e,t)=>{s.forEach(n=>{n.classList.toggle(`active`,+n.dataset.row<=e&&+n.dataset.col<=t)}),o.textContent=e&&t?`${e} × ${t}`:this.context.locale.contextMenu.table||`Insert Table`};i.appendChild(a),i.appendChild(o);let l=!1,u=_(n,`click`,e=>{e.stopPropagation(),l=!l,i.style.display=l?``:`none`,r.style.transform=l?`rotate(90deg)`:``,this._reposition()});this._menuDisposers.push(u);let d=_(a,`mousemove`,e=>{let t=e.target?.closest(`[data-row]`);t&&c(+t.dataset.row,+t.dataset.col)}),f=_(a,`mouseleave`,()=>c(0,0)),p=_(a,`click`,e=>{let t=e.target?.closest(`[data-row]`);if(!t)return;let n=+t.dataset.row,r=+t.dataset.col,i=this.context.layoutInfo?.editable;if(i&&this._savedRange){i.focus();let e=globalThis.getSelection();e.removeAllRanges(),e.addRange(this._savedRange.cloneRange())}this.hide(),this.context.invoke(`editor.insertTable`,r,n)});this._menuDisposers.push(d,f,p),t.appendChild(n),t.appendChild(i),this.el.appendChild(t);return}let t=m(`button`,{type:`button`,class:`an-context-item`,"data-name":e.name||``});if((typeof e.disabled==`function`?e.disabled(this.context):e.disabled)&&(t.disabled=!0),e.icon){let n=m(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}t.appendChild(m(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=_(t,`click`,t=>{t.stopPropagation(),this.hide();try{e.action(this.context)}catch(e){console.error(e)}});this._menuDisposers.push(n),this.el.appendChild(t)}))}_onContextMenu(e){let t=this.context.layoutInfo?.editable;if(!t||!t.contains(e.target)||this.context.layoutInfo.container.classList.contains(`an-disabled`))return;e.preventDefault();let n=globalThis.getSelection();this._savedRange=n?.rangeCount>0?n.getRangeAt(0).cloneRange():null,this._renderItems(this._items);let r=e.clientX,i=e.clientY;if(this._savedRange&&!this._savedRange.collapsed)try{let e=this._savedRange.getBoundingClientRect();e.width>0&&e.height>0&&(i=e.bottom+4)}catch{}this._lastX=r,this._lastY=i,this.showAt(r,i)}_maybeHide(e){this.el&&(this.el.contains(e.target)||this.hide())}showAt(e,t){this.el&&(this.el.style.display=`block`,this._reposition(e,t),this.el.setAttribute(`aria-hidden`,`false`),this.context.triggerEvent(`contextMenu:show`))}_reposition(e,t){if(!this.el)return;let n=e===void 0?this._lastX:e,r=t===void 0?this._lastY:t,i=this.el.offsetWidth,a=this.el.offsetHeight,o=n,s=r;o+i>globalThis.innerWidth-8&&(o=globalThis.innerWidth-i-8),o<8&&(o=8),s+a>globalThis.innerHeight-8&&(s=globalThis.innerHeight-a-8),s<8&&(s=8),this.el.style.left=`${o}px`,this.el.style.top=`${s}px`}hide(){this.el&&(this.el.style.display=`none`,this.el.setAttribute(`aria-hidden`,`true`),this.context.triggerEvent(`contextMenu:hide`))}_getSelectionColor(e){let t=this._savedRange;if(!t)return e===`foreColor`?`#000000`:`transparent`;let n=t.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n)return e===`foreColor`?`#000000`:`transparent`;let r=globalThis.getComputedStyle(n);if(e===`foreColor`)return r.color||`#000000`;let i=r.backgroundColor;return!i||i===`rgba(0, 0, 0, 0)`||i===`transparent`?`transparent`:i}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges(),r.addRange(this._savedRange.cloneRange()),document.execCommand(e,!1,t),this.context.invoke(`editor.afterCommand`),this.hide()}hasCopiedFormat(){return!!this._copiedFormat}copyFormat(){let e=this._savedRange;if(!e)return;let t=this.context.layoutInfo?.editable,n=e.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n||!t?.contains(n))return;let r=globalThis.getComputedStyle(n),i=this._findExplicitStyle(n,t,`fontFamily`),a=this._findExplicitStyle(n,t,`fontSize`);this._copiedFormat={bold:Number.parseInt(r.fontWeight,10)>=700,italic:r.fontStyle===`italic`||r.fontStyle===`oblique`,underline:(r.textDecorationLine||``).includes(`underline`),strikethrough:(r.textDecorationLine||``).includes(`line-through`),fontFamily:i,fontSize:a,color:this._isDefaultColor(r.color)?null:r.color,backgroundColor:r.backgroundColor}}_findExplicitStyle(e,t,n){let r=e;for(;r&&r!==t&&r!==document.body;){if(r.style?.[n])return r.style[n];if(r.nodeName===`FONT`){if(n===`fontFamily`&&r.getAttribute(`face`))return r.getAttribute(`face`);if(n===`fontSize`&&r.getAttribute(`size`))return null}r=r.parentElement}return null}_isDefaultColor(e){return!e||e===`rgb(0, 0, 0)`||e===`rgba(0, 0, 0, 0)`||e===`transparent`}pasteFormat(){if(!this._copiedFormat||!this._savedRange)return;let e=this._copiedFormat,t=this.context.layoutInfo?.editable;if(!t)return;t.focus();let n=globalThis.getSelection();if(n.removeAllRanges(),n.addRange(this._savedRange.cloneRange()),document.execCommand(`removeFormat`),e.bold&&document.execCommand(`bold`),e.italic&&document.execCommand(`italic`),e.underline&&document.execCommand(`underline`),e.strikethrough&&document.execCommand(`strikeThrough`),e.color&&document.execCommand(`foreColor`,!1,e.color),(e=>!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`)(e.backgroundColor)||document.execCommand(`hiliteColor`,!1,e.backgroundColor),e.fontFamily&&document.execCommand(`fontName`,!1,e.fontFamily),e.fontSize){let n=`fs-${Date.now()}`,r=new Set(t.querySelectorAll(`font[size="7"]`));document.execCommand(`fontSize`,!1,`7`),t.querySelectorAll(`font[size="7"]`).forEach(e=>{r.has(e)||(e.dataset.anTmp=n)}),t.querySelectorAll(`[data-an-tmp="${n}"]`).forEach(t=>{let n=document.createElement(`span`);for(n.style.fontSize=e.fontSize,t.parentNode.insertBefore(n,t);t.firstChild;)n.appendChild(t.firstChild);t.remove()})}this.context.invoke(`editor.afterCommand`)}removeFormat(){if(!this._savedRange)return;let e=this.context.layoutInfo?.editable;if(!e)return;e.focus();let t=globalThis.getSelection();t.removeAllRanges(),t.addRange(this._savedRange.cloneRange()),document.execCommand(`removeFormat`);let n=t.getRangeAt(0),r=n.commonAncestorContainer,i=r.nodeType===Node.TEXT_NODE?r.parentElement:r,a=document.createNodeIterator(i,NodeFilter.SHOW_ELEMENT),o;for(;o=a.nextNode();)if(!(!e.contains(o)||o===e))try{n.intersectsNode(o)&&o.removeAttribute(`style`)}catch{}this.context.invoke(`editor.afterCommand`)}},kr=/[^\s\u200B]/;function Ar(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=t.nextNode();e;e=t.nextNode())if(kr.test(e.data))return!0;return!1}var jr=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){let e=this.context.layoutInfo.editable,t=this.options.placeholder||``;t&&(e.dataset.placeholder=t);let n=()=>this._update(),r=_(e,`input`,n),i=_(e,`focus`,n),a=_(e,`blur`,n);return this._disposers.push(r,i,a),this._update(),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_update(){let e=this.context.layoutInfo.editable,t=document.activeElement===e,n=!Ar(e)&&!e.querySelector(`img, table, hr, .an-video-wrapper`);e.classList.toggle(`an-placeholder`,n&&!t)}},Mr=class{constructor(e){this.context=e,this.options=e.options,this._active=!1,this._textarea=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._textarea?.remove(),this._textarea=null}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let{editable:e}=this.context.layoutInfo,t=e.innerHTML;this._textarea=m(`textarea`,{class:`an-codeview`,spellcheck:`false`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`}),this._textarea.value=this._prettyPrint(t),e.style.display=`none`,e.parentNode.insertBefore(this._textarea,e.nextSibling),this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active||!this._textarea)return;let{editable:e}=this.context.layoutInfo;e.innerHTML=M(this._textarea.value,{allowIframes:!0}),this._textarea.remove(),this._textarea=null,e.style.display=``,this._active=!1,this.context.invoke(`toolbar.refresh`),this.context.invoke(`editor.afterCommand`)}_prettyPrint(e){let t=/^<(a|abbr|b|bdo|br|button|cite|code|dfn|em|i|img|input|kbd|label|output|q|samp|select|small|span|strong|sub|sup|textarea|time|tt|u|var)([\s>/])/i,n=0;return e.replace(/>\s*</g,(e,n,r)=>{let i=r.slice(n+1);return t.test(i.trimStart())?`><`:`>
|
|
39
39
|
<`}).split(`
|
|
40
40
|
`).map(e=>{let r=e.trim();if(!r)return``;r.startsWith(`</`)&&(n=Math.max(0,n-1));let i=` `.repeat(n)+r;return/^<[^/!][^>]*[^/]>/.test(r)&&!t.test(r)&&!/^<(br|hr|img|input|link|meta)/.test(r)&&n++,i}).filter(Boolean).join(`
|
|
41
|
-
`)}},Nr=class{constructor(e){this.context=e,this._active=!1,this._disposers=[],this._prevHeight=``}initialize(){let e=_(document,`keydown`,e=>{this._active&&P(e,N.ESCAPE)&&this.deactivate()});return this._disposers.push(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._active&&this.deactivate()}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let e=this.context.layoutInfo.container;this._prevHeight=e.style.height,e.classList.add(`an-fullscreen`),e.style.height=``,document.body.style.overflow=`hidden`,this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active)return;let e=this.context.layoutInfo.container;e.classList.remove(`an-fullscreen`),e.style.height=this._prevHeight,document.body.style.overflow=``,this._active=!1,this.context.invoke(`toolbar.refresh`)}},W=class{constructor(e){this.context=e,this.options=e.options,this._dialog=null,this._disposers=[],this._savedRange=null,this._firstInput=null,this._removeTrap=null}_buildDialog(){throw Error(`_buildDialog() must be implemented by subclass`)}initialize(){return this._dialog=this._buildDialog(),document.body.appendChild(this._dialog),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dialog?.parentNode&&this._dialog.remove(),this._dialog=null}_saveRange(){S(e=>{this._savedRange=e})}_open(){this._dialog&&(this._dialog.style.display=`flex`,this._removeTrap=v(this._dialog,()=>this._close()),setTimeout(()=>this._firstInput?.focus(),50))}_close(){this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this._savedRange=null}_buildDialogShell(e,t,n){let r=m(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e}),i=m(`div`,{class:`an-dialog-box`}),a=m(`div`,{class:`an-dialog-header`}),o=m(`span`,{class:`an-dialog-icon`});o.innerHTML=t;let s=m(`h3`,{class:`an-dialog-title`});s.textContent=n,a.appendChild(o),a.appendChild(s),i.appendChild(a),r.appendChild(i),ee(a,i);let c=_(r,`click`,e=>{e.target===r&&this._close()});return this._disposers.push(c),{overlay:r,box:i}}_buildButtonRow(e,t,n){let r=m(`div`,{class:`an-dialog-actions`}),i=m(`button`,{type:`button`,class:`an-btn an-btn-primary`});i.textContent=e;let a=m(`button`,{type:`button`,class:`an-btn`});a.textContent=t,r.appendChild(i),r.appendChild(a);let o=_(i,`click`,n),s=_(a,`click`,()=>this._close());return this._disposers.push(o,s),r}},Pr=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,Fr=class extends W{show(){this._saveRange(),this._prefill(),this._open()}_buildDialog(){let e=this.context.locale.linkDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Pr,e.title),r=m(`label`,{class:`an-label`});r.textContent=e.url;let i=m(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,id:`an-link-url`,name:`url`,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=m(`label`,{class:`an-label`});a.textContent=e.displayText;let o=m(`input`,{type:`text`,class:`an-input`,placeholder:e.textPlaceholder,id:`an-link-text`,name:`linkText`,autocomplete:`off`});this._textInput=o;let s=m(`label`,{class:`an-label an-label-inline`}),c=m(`input`,{type:`checkbox`,id:`an-link-newtab`,name:`openInNewTab`});this._tabCheckbox=c,s.appendChild(c),s.appendChild(document.createTextNode(` `+e.openInNewTab));let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,l);let u=_(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=_(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_prefill(){let e=globalThis.getSelection(),t=null;if(e?.rangeCount>0){let n=e.getRangeAt(0).startContainer;for(;n;){if(n.nodeName===`A`){t=n;break}n=n.parentNode}}t?(this._urlInput.value=t.getAttribute(`href`)||``,this._textInput.value=t.textContent||``,this._tabCheckbox.checked=t.getAttribute(`target`)===`_blank`):(this._urlInput.value=``,this._textInput.value=e?e.toString():``,this._tabCheckbox.checked=!1)}_onInsert(){let e=this._urlInput.value.trim(),t=this._textInput.value.trim(),n=this._tabCheckbox.checked;if(!e){this._urlInput.focus();return}/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)||(e=`https://`+e);try{let t=new URL(e);if(/^javascript:/i.test(t.protocol)||/^vbscript:/i.test(t.protocol)||/^data:/i.test(t.protocol)){this._urlInput.focus();return}}catch{this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertLink`,e,t,n),this._close()}},Ir=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,Lr=class extends W{show({beforeInsert:e}={}){this._beforeInsert=typeof e==`function`?e:null,this._saveRange(),this._urlInput.value=``,this._altInput.value=``,this._fileInput&&(this._fileInput.value=``),this._open()}_buildDialog(){let e=this.context.locale.imageDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Ir,e.title),r=m(`label`,{class:`an-label`});r.textContent=e.imageUrl;let i=m(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=m(`label`,{class:`an-label`});a.textContent=e.altText;let o=m(`input`,{type:`text`,class:`an-input`,placeholder:e.altPlaceholder,autocomplete:`off`});this._altInput=o,n.append(r,i,a,o);let s=m(`label`,{class:`an-label`});s.textContent=e.alignment;let c=m(`div`,{class:`an-align-row`});if([{value:``,label:e.alignNone},{value:`left`,label:e.alignLeft},{value:`center`,label:e.alignCenter},{value:`right`,label:e.alignRight}].forEach(({value:e,label:t})=>{let n=`an-align-${e||`none`}`,r=m(`input`,{type:`radio`,name:`an-img-align`,id:n,value:e});e===``&&(r.checked=!0);let i=m(`label`,{for:n,class:`an-align-label`});i.textContent=t,c.append(r,i)}),this._alignRow=c,n.append(s,c),this.options.allowImageUpload!==!1){let t=m(`label`,{class:`an-label`});t.textContent=e.uploadLabel;let r=m(`input`,{type:`file`,class:`an-input`,accept:`image/jpeg,image/png,image/gif,image/webp,image/svg+xml,image/avif`});this._fileInput=r;let i=m(`p`,{class:`an-dialog-hint`});this._fileHint=i;let a=_(r,`change`,()=>this._onFileChange());this._disposers.push(a),n.append(t,r,i)}let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(l);let u=_(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=_(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_onFileChange(){if(this.context._alive===!1)return;let e=this._fileInput?.files?.[0];if(!e?.type?.startsWith(`image/`))return;if(!new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`,`image/avif`]).has(e.type)){let t=this.context.locale.errors.imageFormat(e.type);this._fileHint&&(this._fileHint.textContent=t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this._fileHint&&(this._fileHint.textContent=``);let t=(this.options.maxImageSize||5)*1024*1024;if(e.size>t){let t=this.context.locale.errors.imageSize(this.options.maxImageSize||5);this._fileHint&&(this._fileHint.textContent=t),console.warn(`[AutumnNote] ImageDialog:`,t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this.context.invoke(`clipboard.compressAndRegister`,e).then(e=>{this.context._alive!==!1&&(this._urlInput.value=e)}).catch(t=>{if(this.context._alive===!1)return;console.warn(`[AutumnNote] ImageDialog: image compression failed, using original file.`,t);let n=new FileReader;n.onload=e=>{this._urlInput.value=e.target.result},n.readAsDataURL(e)})}_onInsert(){let e=this._urlInput.value.trim(),t=this._altInput.value.trim(),n=this._alignRow?.querySelector(`input[name="an-img-align"]:checked`),r=n?n.value:``;if(!e){this._urlInput.focus();return}this._savedRange&&this._savedRange.select();let i=this._beforeInsert;this._beforeInsert=null,i?.(),this.context.invoke(`editor.insertImage`,e,t,r),this._close()}_close(){this._beforeInsert=null,super._close()}},Rr=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,zr=class extends W{show(){this._saveRange(),this._urlInput.value=``,this._widthInput.value=`560`,this._hintEl.textContent=``,this._open()}_buildDialog(){let e=this.context.locale.videoDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Rr,e.title),r=m(`label`,{class:`an-label`});r.textContent=e.videoUrl;let i=m(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=m(`p`,{class:`an-dialog-hint`});this._hintEl=a;let o=m(`label`,{class:`an-label`});o.textContent=e.widthLabel;let s=m(`input`,{type:`number`,class:`an-input`,placeholder:`560`,min:`80`,max:`1920`,value:`560`});this._widthInput=s;let c=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,c);let l=_(i,`input`,()=>{let e=this._parseVideoUrl(i.value.trim()),t=``;e?t=this.context.locale.videoDialog.detected(e.type):i.value&&(t=this.context.locale.videoDialog.unknownFormat),a.textContent=t}),u=_(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(l,u),t}_onInsert(){let e=this._urlInput.value.trim(),t=Math.max(80,Number.parseInt(this._widthInput.value,10)||560);if(!e){this._urlInput.focus();return}let n=this._buildEmbedHtml(e,t);if(!n){this._hintEl.textContent=this.context.locale.videoDialog.invalidUrl,this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertVideo`,n),this._close()}_parseVideoUrl(e){if(!e||!Ht(e,{media:!0}))return null;let t=/(?:youtube\.com\/watch\?(?:.*&)?v=|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.exec(e);if(t)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${t[1]}`};let n=/youtu\.be\/([a-zA-Z0-9_-]{11})/.exec(e);if(n)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${n[1]}`};let r=/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/.exec(e);if(r)return{type:`YouTube Shorts`,embedUrl:`https://www.youtube.com/embed/${r[1]}`};let i=/vimeo\.com\/(\d+)/.exec(e);return i?{type:`Vimeo`,embedUrl:`https://player.vimeo.com/video/${i[1]}`}:/\.(mp4|webm|ogg|ogv|mov)(#.*|\?.*)?$/i.test(e)?{type:`Direct video`,embedUrl:e}:null}_buildEmbedHtml(e,t){let n=this._parseVideoUrl(e),r=Math.round(t*9/16);if(n&&(n.type===`YouTube`||n.type===`YouTube Shorts`||n.type===`Vimeo`)){let e=`${n.type} video player`;return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><iframe src="${n.embedUrl}" width="${t}" height="${r}" title="${e}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" style="display:block;max-width:100%"></iframe><div class="an-video-shield"></div></div>`}if(n?.type===`Direct video`)return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${n.embedUrl.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`;let i=Ht(e,{media:!0});return i?`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${i.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`:null}},Br=[{pos:`nw`,cursor:`nw-resize`},{pos:`n`,cursor:`n-resize`},{pos:`ne`,cursor:`ne-resize`},{pos:`e`,cursor:`e-resize`},{pos:`se`,cursor:`se-resize`},{pos:`s`,cursor:`s-resize`},{pos:`sw`,cursor:`sw-resize`},{pos:`w`,cursor:`w-resize`}],Vr=class{constructor(e){this.context=e,this._active=null,this._overlay=null,this._disposers=[],this._positionRaf=null,this._lastOverlayPos=null}get _overlayClass(){return`an-resizer`}get _selectedClass(){return`an-selected`}_findTarget(e){return null}_getStartSize(e){return{w:0,h:0}}_getMinSize(){return{minW:20,minH:20}}_applySize(e,t,n){}_extraListeners(){return[]}initialize(){this._overlay=this._buildOverlay();let e=this.context.layoutInfo.editable.closest(`.an-container`)||document.body;e.appendChild(this._overlay),this._container=e;let t=this.context.layoutInfo.editable,n=null;return this._disposers.push(_(t,`click`,e=>this._onEditorClick(e)),_(t,`contextmenu`,e=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&this._select(t)}),_(document,`click`,e=>this._onDocClick(e)),_(globalThis,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),_(globalThis,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>this._updateOverlayPosition(),100)},{passive:!0}),_(t,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),...this._extraListeners()),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this._positionRaf&&=(cancelAnimationFrame(this._positionRaf),null),this._deselect(),this._overlay?.remove(),this._overlay=null}updateOverlay(){this._updateOverlayPosition()}deselect(){this._deselect()}_buildOverlay(){let e=document.createElement(`div`);return e.className=this._overlayClass,e.style.display=`none`,Br.forEach(({pos:t})=>{let n=document.createElement(`div`);n.className=`an-resize-handle an-resize-${t}`,n.dataset.handle=t,this._disposers.push(_(n,`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),this._startResize(e,t)})),e.appendChild(n)}),e}_onEditorClick(e){if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&(e.preventDefault(),this._select(t))}_onDocClick(e){this._active&&(this._active.contains(e.target)||this._overlay?.contains(e.target)||e.target.closest?.(`.an-contextmenu`)||this._deselect())}_select(e){this._active&&this._active!==e&&this._active.classList.remove(this._selectedClass),this._active=e,this._lastOverlayPos=null,e.classList.add(this._selectedClass),this._updateOverlayPosition(),this._overlay.style.display=`block`}_deselect(){this._active&&=(this._active.classList.remove(this._selectedClass),null),this._overlay&&(this._overlay.style.display=`none`)}_updateOverlayPosition(){this._positionRaf&&cancelAnimationFrame(this._positionRaf),this._positionRaf=requestAnimationFrame(()=>{this._positionRaf=null,this._updateOverlayPositionNow()})}_updateOverlayPositionNow(){if(!this._active||!this._overlay)return;let e=this._overlay.offsetParent||this._container,t=e.getBoundingClientRect(),n=this._active.getBoundingClientRect(),r=this._lastOverlayPos;if(r?.l===n.left&&r.t===n.top&&r.w===n.width&&r.h===n.height)return;this._lastOverlayPos={l:n.left,t:n.top,w:n.width,h:n.height};let i=n.left-t.left+e.scrollLeft,a=n.top-t.top+e.scrollTop;this._overlay.style.left=`${i}px`,this._overlay.style.top=`${a}px`,this._overlay.style.width=`${n.width}px`,this._overlay.style.height=`${n.height}px`}_startResize(e,t){let n=this._active;if(!n)return;let r=e.clientX,i=e.clientY,{w:a,h:o}=this._getStartSize(n),{minW:s,minH:c}=this._getMinSize(),l=a/(o||1),u=t.length===2,d=this.context.layoutInfo.editable,f=null,p=e=>{if(f!==null)return;let p=e.clientX,m=e.clientY;f=requestAnimationFrame(()=>{f=null;let e=p-r,h=m-i,g=d.clientWidth||1/0,_=a,v=o;t.includes(`e`)&&(_=Math.max(s,a+e)),t.includes(`w`)&&(_=Math.max(s,a-e)),t.includes(`s`)&&(v=Math.max(c,o+h)),t.includes(`n`)&&(v=Math.max(c,o-h)),_=Math.min(_,g),u&&(Math.abs(e)>=Math.abs(h)||(_=Math.min(Math.max(s,Math.round(v*l)),g)),v=Math.max(c,Math.round(_/l))),this._applySize(n,_,v),this._updateOverlayPosition()})},m=()=>{document.removeEventListener(`pointermove`,p),document.removeEventListener(`pointerup`,h),document.removeEventListener(`pointercancel`,h)},h=()=>{f!==null&&(cancelAnimationFrame(f),f=null),m(),this._dragDisposers=null,this.context.invoke(`editor.afterCommand`)};document.addEventListener(`pointermove`,p),document.addEventListener(`pointerup`,h),document.addEventListener(`pointercancel`,h),this._dragDisposers=[m]}},Hr=class extends Vr{get _overlayClass(){return`an-image-resizer`}get _selectedClass(){return`an-image-selected`}_findTarget(e){return e instanceof Element?e.closest(`img`):null}_getStartSize(e){return{w:e.offsetWidth||e.naturalWidth||100,h:e.offsetHeight||e.naturalHeight||100}}_getMinSize(){let e=this.context.options?.minImageSize??20;return{minW:e,minH:e}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`}getActiveImage(){return this._active}},Ur=class extends Vr{get _overlayClass(){return`an-video-resizer`}get _selectedClass(){return`an-video-selected`}_findTarget(e){return!e||!(e instanceof Element)?null:e.classList?.contains(`an-video-wrapper`)?e:e.closest(`.an-video-wrapper`)}_getStartSize(e){return{w:e.offsetWidth||560,h:e.offsetHeight||315}}_getMinSize(){return{minW:80,minH:45}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`;let r=e.querySelector(`iframe, video`);r&&(r.style.width=`${t}px`,r.style.height=`${n}px`)}_extraListeners(){let e=this.context.layoutInfo.editable;return[_(e,`dragstart`,e=>{e.target instanceof Element&&e.target.closest(`.an-video-wrapper`)&&e.preventDefault()})]}getActiveWrapper(){return this._active}},Wr={open:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,edit:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,unlink:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" y1="2" x2="8" y2="5"/><line x1="2" y1="8" x2="5" y2="8"/><line x1="16" y1="19" x2="16" y2="22"/><line x1="19" y1="16" x2="22" y2="16"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`},Gr=120,Kr=200,qr=class{constructor(e){this.context=e,this._el=null,this._activeAnchor=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{let n=t.target?.closest(`a[href]`);n&&e.contains(n)&&this._scheduleShow(n)}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.link,t=m(`div`,{class:`an-link-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._urlLabel=m(`span`,{class:`an-link-tooltip-url`}),t.appendChild(this._urlLabel),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._openBtn=this._makeBtn(Wr.open,e.openLink,()=>this._openLink()),this._copyBtn=this._makeBtn(Wr.copy,e.copyUrl,()=>this._copyLink()),this._editBtn=this._makeBtn(Wr.edit,e.editLink,()=>this._editLink()),this._unlinkBtn=this._makeBtn(Wr.unlink,e.removeLink,()=>this._unlink()),t.appendChild(this._openBtn),t.appendChild(this._copyBtn),t.appendChild(this._editBtn),t.appendChild(this._unlinkBtn),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_makeBtn(e,t,n){let r=m(`button`,{type:`button`,class:`an-link-tooltip-btn`,title:t});return r.innerHTML=e,this._disposers.push(_(r,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),r}_scheduleShow(e){this._activeAnchor===e&&this._el.style.display!==`none`||(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeAnchor=e,this._show(e)},Gr))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>{this._hide()},Kr))}_show(e){let t=this.context.layoutInfo.container.classList.contains(`an-disabled`),n=e.getAttribute(`href`)||``;this._urlLabel.textContent=this._truncateUrl(n),this._urlLabel.title=n,this._editBtn.style.display=t?`none`:``,this._unlinkBtn.style.display=t?`none`:``,this._el.style.display=`flex`,this._positionNear(e)}_hide(){this._el.style.display=`none`,this._activeAnchor=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||260,r=this._el.offsetHeight||34,i=t.bottom+6,a=t.left;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}_truncateUrl(e){try{let t=new URL(e),n=t.host+(t.pathname===`/`?``:t.pathname);return n.length>48?n.slice(0,48)+`…`:n}catch{return e.length>48?e.slice(0,48)+`…`:e}}_openLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&globalThis.open(e,`_blank`,`noopener,noreferrer`),this._hide()}_copyLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&navigator.clipboard.writeText(e).catch(()=>{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()}),this._copyBtn&&(this._copyBtn.classList.add(`an-link-tooltip-btn--copied`),setTimeout(()=>this._copyBtn?.classList.remove(`an-link-tooltip-btn--copied`),1e3))}_editLink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.context.invoke(`linkDialog.show`)}_unlink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),document.execCommand(`unlink`),this.context.invoke(`editor.afterCommand`)}},Jr=class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._active=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}_canHide(){return!0}_beforeHide(){}_makeBtn(e,t,n,r=!1){let i=m(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(_(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){this._active===e&&this._el.style.display!==`none`||(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._active=e,this._show(e)},100))}_scheduleHide(){this._canHide()&&(clearTimeout(this._showTimer),this._showTimer=null,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hide(),180))}_show(e){this._el.style.display=`flex`,requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_hide(){this._beforeHide(),this._el.style.display=`none`,this._active=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||220,r=this._el.offsetHeight||32,i=t.bottom+6,a=t.left+(t.width-n)/2;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}},G={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,caption:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/></svg>`,rotateLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><polyline points="3 3 3 8 8 8"/></svg>`,rotateRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><polyline points="21 3 21 8 16 8"/></svg>`,crop:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 2 6 18 22 18"/><polyline points="2 6 18 6 18 22"/></svg>`},Yr=class extends Jr{initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`img`);n&&e.contains(n)&&!n.closest(`a[href]`)&&this._scheduleShow(n)},{passive:!0}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),_(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.image,t=m(`div`,{class:`an-link-tooltip an-image-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(G.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(G.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(G.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(G.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(G.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),t.appendChild(this._makeBtn(G.rotateLeft,e.rotateLeft,()=>this._rotate(-90))),t.appendChild(this._makeBtn(G.rotateRight,e.rotateRight,()=>this._rotate(90))),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._cropBtn=this._makeBtn(G.crop,e.cropImage,()=>this._crop()),t.appendChild(this._cropBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._captionBtn=this._makeBtn(G.caption,e.addCaption,()=>this._toggleCaption()),t.appendChild(this._captionBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(G.deleteImg,e.deleteImage,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;if(!t)return;let n=t.closest(`figure.an-figure`)||t;n.style.float=e,n.style.display=``,n!==t&&(n.style.width=``),n.style.marginLeft=e===`right`?`12px`:``,n.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_setCenter(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`)||e;t.style.float=``,t.style.display=`block`,t!==e&&(t.style.width=`fit-content`),t.style.marginLeft=`auto`,t.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_resetSize(){let e=this._active;e&&(e.style.width=``,e.style.height=``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_rotate(e){let t=this._active;if(!t)return;let n=t.style.transform||``,r=/rotate\((-?[\d.]+)deg\)/.exec(n),i=((r?Number.parseFloat(r[1]):0)+e+360)%360,a=n.replace(/rotate\(-?[\d.]+deg\)/,``).trim();a?t.style.transform=`${a} rotate(${i}deg)`:t.style.transform=i===0?``:`rotate(${i}deg)`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;if(!e)return;this._hide(),this.context.invoke(`imageResizer.deselect`);let t=e.closest(`figure.an-figure`);t?t.remove():e.remove(),this.context.invoke(`editor.afterCommand`)}_crop(){let e=this._active;e&&(this._hide(),this.context.invoke(`imageCropOverlay.open`,e))}_toggleCaption(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`);if(t){let e=t.querySelector(`figcaption.an-figcaption`);if(e){this._hide();let t=document.createRange();t.selectNodeContents(e);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}return}let n=document.createElement(`figure`);n.className=`an-figure`,e.style.float?(n.style.float=e.style.float,n.style.marginLeft=e.style.marginLeft,n.style.marginRight=e.style.marginRight,e.style.float=``,e.style.marginLeft=``,e.style.marginRight=``):e.style.display===`block`&&e.style.marginLeft===`auto`&&(n.style.display=`block`,n.style.width=`fit-content`,n.style.marginLeft=`auto`,n.style.marginRight=`auto`,e.style.display=``,e.style.marginLeft=``,e.style.marginRight=``);let r=document.createElement(`figcaption`);r.className=`an-figcaption`,r.textContent=`Caption`,e.parentNode.insertBefore(n,e),n.appendChild(e),n.appendChild(r);let i=document.createRange();i.selectNodeContents(r);let a=globalThis.getSelection();a&&(a.removeAllRanges(),a.addRange(i)),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),this._hide()}},K={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,preview:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 3 19 12 5 21 5 3"/></svg>`},Xr=class extends Jr{initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`.an-video-wrapper`);n&&e.contains(n)&&this._scheduleShow(n)},{passive:!0}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),_(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._previewMode&&this._exitPreview(),this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_canHide(){return!this._previewMode}_beforeHide(){this._previewMode&&this._exitPreview()}_buildTooltip(){let e=this.context.locale.tooltips.video,t=m(`div`,{class:`an-link-tooltip an-video-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(K.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(K.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(K.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(K.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(K.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._previewBtn=this._makeBtn(K.preview,e.previewVideo,()=>this._togglePreview()),t.appendChild(this._previewBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(K.deleteVideo,e.deleteVideo,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;t&&(t.style.float=e,t.style.display=e?`inline-block`:``,t.style.marginLeft=e===`right`?`12px`:``,t.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_setCenter(){let e=this._active;e&&(e.style.float=``,e.style.display=`block`,e.style.marginLeft=`auto`,e.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_resetSize(){let e=this._active;if(!e)return;let t=e.querySelector(`iframe, video`);e.style.width=``,e.style.height=``,t&&(t.removeAttribute(`width`),t.removeAttribute(`height`),t.style.width=``,t.style.height=``),this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;e&&(this._hide(),this.context.invoke(`videoResizer.deselect`),e.remove(),this.context.invoke(`editor.afterCommand`))}_togglePreview(){this._previewMode?this._exitPreview():this._enterPreview()}_enterPreview(){let e=this._active;if(!e)return;this._previewMode=!0;let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=`none`),this.context.invoke(`videoResizer.deselect`),this._previewBtn.classList.add(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.exitPreview,this._previewClickOff=t=>{!e.contains(t.target)&&!this._el.contains(t.target)&&this._exitPreview()},document.addEventListener(`mousedown`,this._previewClickOff,!0)}_exitPreview(){this._previewMode=!1;let e=this._active;if(e){let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=``)}this._previewBtn.classList.remove(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.previewVideo,this._previewClickOff&&=(document.removeEventListener(`mousedown`,this._previewClickOff,!0),null)}},q={rowAbove:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 3v7"/><path d="M9 7l3-4 3 4"/></svg>`,rowBelow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 12v7"/><path d="M9 17l3 4 3-4"/></svg>`,deleteRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="15" y1="15" x2="21" y2="21"/><line x1="21" y1="15" x2="15" y2="21"/></svg>`,colLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M3 12h7"/><path d="M7 8l-4 4 4 4"/></svg>`,colRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M12 12h9"/><path d="M17 8l4 4-4 4"/></svg>`,deleteCol:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="15" y1="6" x2="21" y2="12"/><line x1="21" y1="6" x2="15" y2="12"/></svg>`,mergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="8" height="10" rx="1"/><rect x="14" y="7" width="8" height="10" rx="1"/><path d="M10 12h4"/><path d="M12 10l2 2-2 2"/></svg>`,unmergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="5" width="20" height="14" rx="1"/><line x1="12" y1="5" x2="12" y2="19" stroke-dasharray="2.5 2"/><line x1="2" y1="12" x2="22" y2="12" stroke-dasharray="2.5 2"/><path d="M9 9 L6 12 L9 15"/><path d="M15 9 L18 12 L15 15"/></svg>`,colWidth:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="4" x2="7" y2="20"/><line x1="17" y1="4" x2="17" y2="20"/><line x1="7" y1="12" x2="17" y2="12"/><path d="M10 9l-3 3 3 3"/><path d="M14 9l3 3-3 3"/></svg>`,rowHeight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="17" x2="20" y2="17"/><line x1="12" y1="7" x2="12" y2="17"/><path d="M9 10l3-3 3 3"/><path d="M9 14l3 3 3-3"/></svg>`,tableBorder:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6" stroke-width="1"/><line x1="3" y1="13" x2="21" y2="13" stroke-width="2"/><line x1="3" y1="20" x2="21" y2="20" stroke-width="3"/></svg>`,deleteTable:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><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"/><line x1="16" y1="16" x2="22" y2="22" stroke="#ef4444"/><line x1="22" y1="16" x2="16" y2="22" stroke="#ef4444"/></svg>`,selectCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z" fill="currentColor" opacity="0.15"/><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z"/></svg>`,cellShade:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 11L8.93 3.36a1 1 0 0 0-1.29.08L3.22 7.8a1 1 0 0 0-.07 1.29L11 20"/><path d="m5 14 5-5"/><path d="M22 22a2 2 0 0 1-2 2h-3a2 2 0 0 1-2-2c0-1.5 2.5-5 3.5-5s3.5 3.5 3.5 5z"/></svg>`,borderColor:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="14" rx="1"/><line x1="3" y1="10" x2="21" y2="10" stroke-width="1.5"/><line x1="12" y1="3" x2="12" y2="17" stroke-width="1.5"/><path d="M3 21h18" stroke-width="3"/></svg>`,alignLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="17" y1="12" x2="7" y2="12"/><line x1="19" y1="18" x2="5" y2="18"/></svg>`,alignRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/></svg>`,alignJustify:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/></svg>`,headerRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="3" y="3" width="18" height="8" rx="1" fill="currentColor" opacity="0.2"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="9" y1="11" x2="9" y2="21"/><line x1="15" y1="11" x2="15" y2="21"/></svg>`,sortAsc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="11" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="13" y2="18"/><path d="M15 9l3-3 3 3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,sortDesc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="13" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="11" y2="18"/><path d="M15 15l3 3 3-3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,exportCSV:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`,cellPadding:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="7" y="7" width="10" height="10" rx="0.5" stroke-dasharray="2 1.5"/></svg>`};function Zr(e){let t=e.closest(`tr`);if(!t)return-1;let n=0;for(let r of t.cells){if(r===e)return n;n+=r.colSpan||1}return-1}function J(e,t){let n=0;for(let r of e.cells){if(n===t)return r;if(n>t)break;n+=r.colSpan||1}return null}function Qr(e,t){let n=0;for(let r of e.cells)if(n+=r.colSpan||1,n>t){let e=r.nextElementSibling;return e?.tagName===`TD`||e?.tagName===`TH`?e:null}return null}function $r(e){let t=Array.from(e.rows),n={},r=new WeakMap;return t.forEach((e,t)=>{n[t]||(n[t]={});let i=0;for(let a of e.cells){for(;n[t][i];)i++;let e=a.rowSpan||1,o=a.colSpan||1;r.set(a,{r:t,c:i,rs:e,cs:o});for(let r=0;r<e;r++){n[t+r]||(n[t+r]={});for(let e=0;e<o;e++)n[t+r][i+e]=a}i+=o}}),{gridMap:n,cellPos:r}}var ei=120,ti=200,ni=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],ri=class{constructor(e){this.context=e,this._el=null,this._activeTable=null,this._activeCell=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._sizePopover=null,this._sizeApply=null,this._sizeTitleEl=null,this._sizeInputEl=null,this._shadePopover=null,this._shadeTitleEl=null,this._shadeColorStrip=null,this._borderColorPopover=null,this._borderColorTitleEl=null,this._borderColorStrip=null,this._borderColorNoBtn=null,this._selectMode=!1,this._selectedCells=[],this._selectStart=null,this._selectDragging=!1,this._selectBtn=null,this._editable=null}initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el),this._sizePopover=this._buildSizePopover(),document.body.appendChild(this._sizePopover),this._shadePopover=this._buildCellShadePopover(),document.body.appendChild(this._shadePopover),this._borderColorPopover=this._buildBorderColorPopover(),document.body.appendChild(this._borderColorPopover);let e=this.context.layoutInfo.editable;return this._editable=e,this._disposers.push(_(e,`mousedown`,t=>{if(!this._selectMode)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.style.cursor===`col-resize`||n.style.cursor===`row-resize`||(t.preventDefault(),this._activeTable=n.closest(`table`),this._selectStart=n,this._selectDragging=!0,this._setSelection([n]))}),_(e,`mousemove`,t=>{if(!this._selectMode||!this._selectDragging||!this._selectStart)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.closest(`table`)===this._activeTable&&this._setSelection(this._getRectCells(this._selectStart,n))}),_(document,`mouseup`,()=>{this._selectDragging=!1}),_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`table`);if(n&&e.contains(n)){let e=t.target?.closest(`td, th`);e&&(this._activeCell=e,this._syncShadeStrip()),this._scheduleShow(n)}},{passive:!0}),_(e,`mouseout`,t=>{if(this._selectMode)return;let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n)&&!this._sizePopover?.contains(n))&&this._scheduleHide()},{passive:!0}),_(document,`click`,e=>{let t=e.target;this._selectMode&&this._activeTable?.contains(t)||this._activeTable&&!this._activeTable.contains(t)&&!this._el.contains(t)&&!this._sizePopover?.contains(t)&&!this._shadePopover?.contains(t)&&!this._borderColorPopover?.contains(t)&&this._hide()}),_(document,`selectionchange`,()=>this._syncShadeStrip()),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this._initResize(),this}_initResize(){let e=this.context.layoutInfo.editable,t=null,n=null,r=!1,i=null,a=0,o=0,s=0,c=0,l=-1,u=null,d=null,f=null,p=null,m=null,h=()=>{t&&=(t.style.cursor=``,null),n=null};this._disposers.push(_(e,`mousemove`,i=>{if(r)return;if(this.context.layoutInfo.container.classList.contains(`an-disabled`)){h();return}if(m!==null)return;let a=i.target,o=i.clientX,s=i.clientY;m=requestAnimationFrame(()=>{m=null;let r=a.closest(`td, th`);if(!r||!e.contains(r)){h();return}t&&t!==r&&(t.style.cursor=``);let i=r.getBoundingClientRect(),c=Math.abs(o-i.right)<6,l=Math.abs(s-i.bottom)<6;c?(r.style.cursor=`col-resize`,t=r,n=`col`):l?(r.style.cursor=`row-resize`,t=r,n=`row`):h()})}),_(e,`mousedown`,e=>{if(!this.context.layoutInfo.container.classList.contains(`an-disabled`)&&!(!t||!n)){if(r=!0,i=n,a=e.clientX,o=e.clientY,f=t.closest(`table`),i===`col`)l=Zr(t)+(t.colSpan||1)-1,u=l>=0?Array.from(f.querySelectorAll(`tr`)).map(e=>J(e,l)).filter(Boolean).filter(e=>(e.colSpan||1)===1):[],s=u.length>0?u[0].offsetWidth:Math.max(30,Math.round(t.offsetWidth/(t.colSpan||1))),document.body.style.cursor=`col-resize`;else{let e=t.closest(`tr`),n=(e?Array.from(f.rows).indexOf(e):0)+(t.rowSpan||1)-1;d=f.rows[n]||e,c=d?d.offsetHeight:40,document.body.style.cursor=`row-resize`}document.body.style.userSelect=`none`,e.preventDefault(),e.stopPropagation()}}),_(document,`mousemove`,e=>{if(!r||p!==null)return;let t=e.clientX,n=e.clientY;p=requestAnimationFrame(()=>{if(p=null,i===`col`){let e=Math.max(30,s+(t-a));for(let t of u)t.style.width=`${e}px`,t.style.minWidth=`${e}px`}else{let e=Math.max(20,c+(n-o));if(d)for(let t of d.cells)t.style.height=`${e}px`,t.style.minHeight=`${e}px`}})}),_(document,`mouseup`,()=>{r&&(p!==null&&(cancelAnimationFrame(p),p=null),r=!1,document.body.style.userSelect=``,document.body.style.cursor=``,i=null,f=null,d=null,l=-1,u=null,this.context.invoke(`editor.afterCommand`))}))}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null,this._sizePopover?.parentNode&&this._sizePopover.remove(),this._sizePopover=null,this._shadePopover?.parentNode&&this._shadePopover.remove(),this._shadePopover=null,this._borderColorPopover?.parentNode&&this._borderColorPopover.remove(),this._borderColorPopover=null}_buildTooltip(){let e=this.context.locale.tooltips.table,t=m(`div`,{class:`an-link-tooltip an-table-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._selectBtn=this._makeBtn(q.selectCells,e.selectCells,()=>this._toggleSelectMode()),t.appendChild(this._selectBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.rowAbove,e.addRowAbove,()=>this._addRow(`above`))),t.appendChild(this._makeBtn(q.rowBelow,e.addRowBelow,()=>this._addRow(`below`))),t.appendChild(this._makeBtn(q.deleteRow,e.deleteRow,()=>this._deleteRow())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.colLeft,e.addColumnLeft,()=>this._addColumn(`left`))),t.appendChild(this._makeBtn(q.colRight,e.addColumnRight,()=>this._addColumn(`right`))),t.appendChild(this._makeBtn(q.deleteCol,e.deleteColumn,()=>this._deleteColumn())),t.appendChild(this._makeBtn(q.sortAsc,e.sortAsc,()=>this._sortColumn(`asc`))),t.appendChild(this._makeBtn(q.sortDesc,e.sortDesc,()=>this._sortColumn(`desc`))),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.mergeCells,e.mergeCells,()=>this._mergeCells())),t.appendChild(this._makeBtn(q.unmergeCells,e.unmergeCells,()=>this._unmergeCells())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.alignLeft,e.cellAlignLeft,()=>this._applyCellAlign(`left`))),t.appendChild(this._makeBtn(q.alignCenter,e.cellAlignCenter,()=>this._applyCellAlign(`center`))),t.appendChild(this._makeBtn(q.alignRight,e.cellAlignRight,()=>this._applyCellAlign(`right`))),t.appendChild(this._makeBtn(q.alignJustify,e.cellAlignJustify,()=>this._applyCellAlign(`justify`))),t.appendChild(this._makeBtn(q.headerRow,e.toggleHeaderRow,()=>this._toggleHeaderRow())),t.appendChild(this._sep());let n=m(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.cellBackground}),r=m(`span`,{class:`an-bubble-btn-svg`});r.innerHTML=q.cellShade;let i=m(`span`,{class:`an-link-tooltip-color-strip`});n.appendChild(r),n.appendChild(i),this._shadeColorStrip=i,this._disposers.push(_(n,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openCellShadePopover()})),t.appendChild(n),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.colWidth,e.columnWidth,()=>this._openSizePopover(`col`))),t.appendChild(this._makeBtn(q.rowHeight,e.rowHeight,()=>this._openSizePopover(`row`))),t.appendChild(this._makeBtn(q.tableBorder,e.tableBorderWidth,()=>this._openSizePopover(`border`))),t.appendChild(this._makeBtn(q.cellPadding,e.cellPadding,()=>this._openSizePopover(`cellPadding`)));let a=m(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.tableBorderColor}),o=m(`span`,{class:`an-bubble-btn-svg`});o.innerHTML=q.borderColor;let s=m(`span`,{class:`an-link-tooltip-color-strip`});return a.appendChild(o),a.appendChild(s),this._borderColorStrip=s,this._disposers.push(_(a,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openBorderColorPopover()})),t.appendChild(a),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.deleteTable,e.deleteTable,()=>this._deleteTable(),!0)),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.exportCSV,e.exportCSV,()=>this._exportTableCSV())),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>{this._selectMode||this._sizePopover&&this._sizePopover.style.display!==`none`||this._shadePopover&&this._shadePopover.style.display!==`none`||this._borderColorPopover&&this._borderColorPopover.style.display!==`none`||this._scheduleHide()})),t}_sep(){return m(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=m(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(_(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){this._activeTable===e&&this._el.style.display!==`none`||(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeTable=e,this._show()},ei))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>this._hide(),ti))}_show(){this._activeTable&&(this._el.style.display=`flex`,this._syncShadeStrip(),this._syncBorderColorStrip(),requestAnimationFrame(()=>{this._activeTable&&this._positionNear(this._activeTable)}))}_syncShadeStrip(){if(!this._shadeColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._getCell();this._shadeColorStrip.style.background=e?.style.backgroundColor||`transparent`}_hide(){this._el.style.display=`none`,this._activeTable=null,this._activeCell=null,this._selectMode&&(this._selectMode=!1,this._selectBtn&&this._selectBtn.classList.remove(`an-link-tooltip-btn--active`),this._editable&&this._editable.classList.remove(`an-table-select-mode`)),this._clearSelection(),this._clearTimers(),this._hideSizePopover(),this._hideBorderColorPopover()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){if(!e)return;let t=e.getBoundingClientRect(),n=this._el.offsetWidth||400,r=this._el.offsetHeight||30,i=t.left+(t.width-n)/2,a=t.top-r-6;a<6&&(a=t.bottom+6),i+n>globalThis.innerWidth-6&&(i=globalThis.innerWidth-n-6),i<6&&(i=6),this._el.style.left=`${i}px`,this._el.style.top=`${a}px`}_getCell(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`td, th`);if(n&&this._activeTable?.contains(n))return n}return this._activeCell||this._activeTable?.querySelector(`td, th`)}_toggleSelectMode(){this._selectMode=!this._selectMode,this._selectBtn&&this._selectBtn.classList.toggle(`an-link-tooltip-btn--active`,this._selectMode),this._editable&&this._editable.classList.toggle(`an-table-select-mode`,this._selectMode),this._selectMode||this._clearSelection()}_clearSelection(){this._selectedCells.forEach(e=>e.classList.remove(`an-cell-selected`)),this._selectedCells=[],this._selectStart=null}_setSelection(e){this._selectedCells.forEach(t=>{e.includes(t)||t.classList.remove(`an-cell-selected`)}),this._selectedCells=e,e.forEach(e=>e.classList.add(`an-cell-selected`))}_getRectCells(e,t){if(!e)return[];if(!t||e===t)return[e];let n=e.closest(`table`);if(!n?.contains(t))return[e];let{gridMap:r,cellPos:i}=$r(n),a=i.get(e),o=i.get(t);if(!a||!o)return[e];let s=Math.min(a.r,o.r),c=Math.max(a.r+a.rs-1,o.r+o.rs-1),l=Math.min(a.c,o.c),u=Math.max(a.c+a.cs-1,o.c+o.cs-1),d=!0;for(;d;){d=!1;for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];if(!n)continue;let r=i.get(n);r&&(r.r<s&&(s=r.r,d=!0),r.r+r.rs-1>c&&(c=r.r+r.rs-1,d=!0),r.c<l&&(l=r.c,d=!0),r.c+r.cs-1>u&&(u=r.c+r.cs-1,d=!0))}}}let f=new Set,p=[];for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];n&&!f.has(n)&&(f.add(n),p.push(n))}}return p.length>0?p:[e]}_getSelectedCells(){return this._selectedCells.length>0?this._selectedCells:[this._getCell()].filter(Boolean)}_addRow(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=Array.from(n.querySelectorAll(`tr`)),i=[...new Set(t.map(e=>e.closest(`tr`)).filter(Boolean))],a=i.reduce((t,n)=>{let i=r.indexOf(t),a=r.indexOf(n);return e===`above`?a<i?n:t:a>i?n:t},i[0]),o=Array.from(a.cells).reduce((e,t)=>e+(t.colSpan||1),0),s=document.createElement(`tr`),c=Array.from(a.cells);for(let e=0;e<o;e++){let t=m(`td`,{},[`\xA0`]),n=c[e];n?.style.width&&(t.style.width=n.style.width),n?.style.minWidth&&(t.style.minWidth=n.style.minWidth),s.appendChild(t)}e===`above`?a.parentElement?.insertBefore(s,a):a.after(s),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_addColumn(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=t.map(e=>Zr(e)),i=e===`left`?Math.min(...r):Math.max(...r),a=Array.from(n.querySelectorAll(`tr`)),o=a.map(t=>e===`left`?J(t,i):Qr(t,i)),s=a.map(e=>e.closest(`thead`)!==null);a.forEach((e,t)=>{e.insertBefore(m(s[t]?`th`:`td`,{},[`\xA0`]),o[t])}),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_deleteRow(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=t.querySelector(`tbody`),r=n?n.querySelectorAll(`tr`).length:t.querySelectorAll(`tr`).length,i=[...new Set(e.map(e=>e.closest(`tr`)).filter(Boolean))];i.filter(e=>e.closest(`tbody`)).length>=r||(this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_deleteColumn(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=Array.from(t.querySelectorAll(`tr`));if(n[0]&&n[0].cells.length<=1)return;let r=[...new Set(e.map(e=>Zr(e)))];if(r.length>=(n[0]?.cells.length??1))return;let i=[];r.forEach(e=>{n.forEach(t=>{let n=J(t,e);n&&i.push(n)})}),this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_mergeCells(){let e=this._getCell();if(!e)return;let t=e.closest(`table`);if(!t)return;let n=this._getSelectedCells().filter(e=>t.contains(e));if(n.length<2){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return;let r=e.getRangeAt(0);if(n=Array.from(t.querySelectorAll(`td, th`)).filter(e=>{try{return r.intersectsNode(e)}catch{return!1}}),n.length<2)return}let{gridMap:r,cellPos:i}=$r(t),a=1/0,o=-1/0,s=1/0,c=-1/0;if(n.forEach(e=>{let t=i.get(e);t&&(t.r<a&&(a=t.r),t.r+t.rs-1>o&&(o=t.r+t.rs-1),t.c<s&&(s=t.c),t.c+t.cs-1>c&&(c=t.c+t.cs-1))}),a===1/0)return;let l=new Set,u=[];for(let e=a;e<=o;e++){let t=r[e];if(t)for(let e=s;e<=c;e++){let n=t[e];n&&!l.has(n)&&(l.add(n),u.push(n))}}if(u.length<2)return;let d=u[0];d.colSpan=c-s+1,d.rowSpan=o-a+1,d.style.verticalAlign=`middle`,d.style.height=``,d.style.minHeight=``;let f=u.map(e=>e.innerHTML.replace(/^(<br\s*\/?>|\s)+$/i,``).trim()).filter(e=>e!==``);d.innerHTML=f.length?f.join(`<br>`):`<br>`,u.slice(1).forEach(e=>{let t=e.parentElement;e.remove(),t&&t.cells.length===0&&t.remove()}),this._clearSelection(),this.context.invoke(`editor.afterCommand`)}_deleteTable(){let e=this._activeTable;e&&(this._hide(),e.parentNode&&e.remove(),this.context.invoke(`editor.afterCommand`))}_unmergeCells(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=e.filter(e=>t.contains(e)&&((e.colSpan||1)>1||(e.rowSpan||1)>1));n.length&&(n.forEach(e=>{t.contains(e)&&this._unmergeOne(e,t)}),this._clearSelection(),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_unmergeOne(e,t){let n=e.colSpan||1,r=e.rowSpan||1;if(n===1&&r===1)return;let{cellPos:i}=$r(t),a=i.get(e);if(!a)return;let{r:o,c:s}=a,c=Array.from(t.rows),l=e.tagName.toLowerCase();if(e.rowSpan=1,e.colSpan=1,e.style.verticalAlign=``,n>1){let t=e.nextElementSibling;for(let e=1;e<n;e++)c[o].insertBefore(m(l,{},[`\xA0`]),t)}for(let e=1;e<r;e++){let t=c[o+e];if(!t)continue;let r=null;for(let e of t.cells)if(i.get(e)?.c>s){r=e;break}for(let e=0;e<n;e++)t.insertBefore(m(l,{},[`\xA0`]),r)}}_buildSizePopover(){let e=m(`div`,{class:`an-size-popover`});e.style.display=`none`;let t=m(`div`,{class:`an-size-popover-title`}),n=m(`div`,{class:`an-size-popover-body`}),r=m(`input`,{type:`number`,class:`an-size-input`,min:`1`,max:`2000`,step:`1`}),i=m(`span`,{class:`an-size-unit`},[`px`]);n.appendChild(r),n.appendChild(i);let a=m(`div`,{class:`an-size-popover-actions`}),o=m(`button`,{type:`button`,class:`an-btn`});o.textContent=this.context.locale.tooltips.table.cancelBtn;let s=m(`button`,{type:`button`,class:`an-btn an-btn-primary`});s.textContent=this.context.locale.tooltips.table.applyBtn,a.appendChild(o),a.appendChild(s),e.appendChild(t),e.appendChild(n),e.appendChild(a),this._sizeTitleEl=t,this._sizeInputEl=r,this._sizeApply=null;let c=_(s,`click`,()=>{let e=Number.parseInt(this._sizeInputEl.value,10);e>=0&&typeof this._sizeApply==`function`&&this._sizeApply(e),this._hideSizePopover()}),l=_(o,`click`,()=>this._hideSizePopover()),u=_(r,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),s.click()),t.key===`Escape`&&this._hideSizePopover()}),d=_(document,`click`,e=>{let t=e.target;this._sizePopover&&this._sizePopover.style.display!==`none`&&!this._sizePopover.contains(t)&&!this._el.contains(t)&&this._hideSizePopover()}),f=_(e,`mouseenter`,()=>this._clearTimers()),p=_(e,`mouseleave`,()=>this._scheduleHide());return this._disposers.push(c,l,u,d,f,p),e}_openSizePopover(e){let t=this._getCell();if(!(!t||!this._sizePopover)){if(e===`border`){let e=t.closest(`table`);if(!e)return;let n=e.querySelector(`td, th`),r=n&&(Number.parseInt(n.style.borderWidth,10)||Number.parseInt(globalThis.getComputedStyle(n).borderWidth,10))||1;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.tableBorderWidthPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`10`,this._sizeInputEl.value=String(r),this._sizeApply=t=>{let n=Array.from(e.querySelectorAll(`td, th`));t===0?n.forEach(e=>{e.style.borderWidth=`0`,e.style.borderStyle=`none`}):n.forEach(e=>{e.style.borderWidth=`${t}px`,e.style.borderStyle=`solid`}),this.context.invoke(`editor.afterCommand`)}}else if(e===`cellPadding`){let e=this._getSelectedCells()[0]||this._getCell(),t=e&&(Number.parseInt(e.style.padding,10)||Number.parseInt(e.style.paddingTop,10))||4;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.cellPaddingPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`40`,this._sizeInputEl.value=String(t),this._sizeApply=e=>{this._getSelectedCells().forEach(t=>{t&&(t.style.padding=`${e}px`)}),this.context.invoke(`editor.afterCommand`)}}else{let n=e===`col`,r=this._getSelectedCells().filter(e=>{let n=e.closest(`table`);return n&&n===t.closest(`table`)});if(this._sizeTitleEl.textContent=n?this.context.locale.tooltips.table.columnWidthPx:this.context.locale.tooltips.table.rowHeightPx,this._sizeInputEl.min=`1`,this._sizeInputEl.max=`2000`,n)this._sizeInputEl.value=t.offsetWidth||120;else{let e=t.closest(`tr`);this._sizeInputEl.value=e&&e.offsetHeight||40}this._sizeApply=e=>{let i=t.closest(`table`);if(i){if(n){let t=[...new Set(r.map(e=>Zr(e)))],n=Array.from(i.querySelectorAll(`tr`));t.forEach(t=>{n.forEach(n=>{let r=J(n,t);r&&(r.colSpan||1)===1&&(r.style.width=`${e}px`,r.style.minWidth=`${e}px`)})})}else[...new Set(r.map(e=>e.closest(`tr`)).filter(Boolean))].forEach(t=>{for(let n of t.cells)n.style.height=`${e}px`,n.style.minHeight=`${e}px`});this.context.invoke(`editor.afterCommand`)}}}this._sizePopover.style.display=`block`,requestAnimationFrame(()=>{if(!this._sizePopover||!this._el)return;let e=this._el.getBoundingClientRect(),t=this._sizePopover.offsetWidth||220,n=this._sizePopover.offsetHeight||110,r=e.left,i=e.bottom+6;r+t>globalThis.innerWidth-8&&(r=globalThis.innerWidth-t-8),i+n>globalThis.innerHeight-8&&(i=e.top-n-6),this._sizePopover.style.left=`${r}px`,this._sizePopover.style.top=`${i}px`,this._sizeInputEl&&(this._sizeInputEl.focus(),this._sizeInputEl.select())})}}_hideSizePopover(){this._sizePopover&&(this._sizePopover.style.display=`none`),this._sizeApply=null}_buildColorPopover({defaultColor:e,apply:t,getPopover:n,hide:r}){let i=m(`div`,{class:`an-cell-shade-popover`});i.style.display=`none`;let a=m(`div`,{class:`an-size-popover-title`});i.appendChild(a);let o=m(`div`,{class:`an-context-color-palette`});ni.forEach(e=>{let n=m(`div`,{class:`an-context-color-swatch`,title:e});n.style.background=e,this._disposers.push(_(n,`click`,n=>{n.stopPropagation(),t(e)})),o.appendChild(n)}),i.appendChild(o);let s=m(`div`,{class:`an-context-color-custom`}),c=m(`button`,{type:`button`,class:`an-shade-no-color`});this._disposers.push(_(c,`click`,()=>t(``))),s.appendChild(c),i.appendChild(s);let l=m(`div`,{class:`an-context-color-custom`}),u=m(`input`,{type:`color`,class:`an-shade-color-input`,value:e}),d=m(`span`);return d.textContent=this.context.locale.contextMenu.customColorLabel,this._disposers.push(_(u,`change`,()=>t(u.value))),l.appendChild(u),l.appendChild(d),i.appendChild(l),this._disposers.push(_(i,`mousedown`,e=>e.preventDefault()),_(i,`mouseenter`,()=>this._clearTimers()),_(i,`mouseleave`,()=>this._scheduleHide()),_(document,`click`,e=>{let t=e.target,i=n();i&&i.style.display!==`none`&&!i.contains(t)&&!this._el?.contains(t)&&r()})),{el:i,titleEl:a,noColorBtn:c}}_showColorPopover(e){let t=e();t&&(t.style.display=`block`,requestAnimationFrame(()=>{let t=e();if(!t||!this._el)return;let n=t.offsetWidth||170,r=t.offsetHeight||120,i=this._el.getBoundingClientRect(),a=i.left,o=i.bottom+6;a+n>globalThis.innerWidth-8&&(a=globalThis.innerWidth-n-8),o+r>globalThis.innerHeight-8&&(o=i.top-r-6),t.style.left=`${Math.max(8,a)}px`,t.style.top=`${Math.max(8,o)}px`}))}_buildCellShadePopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#ffffff`,apply:e=>this._applyCellShade(e),getPopover:()=>this._shadePopover,hide:()=>this._hideCellShadePopover()});return this._shadeTitleEl=t,this._shadeNoBtn=n,e}_openCellShadePopover(){if(!this._shadePopover)return;let e=this.context.locale.tooltips.table;this._shadeTitleEl&&(this._shadeTitleEl.textContent=e.cellBackground),this._shadeNoBtn&&(this._shadeNoBtn.textContent=e.noShading),this._showColorPopover(()=>this._shadePopover)}_hideCellShadePopover(){this._shadePopover&&(this._shadePopover.style.display=`none`)}_applyCellShade(e){(this._selectMode?this._selectedCells:[this._getCell()]).forEach(t=>{t&&(t.style.backgroundColor=e)}),this._shadeColorStrip&&(this._shadeColorStrip.style.background=e||`transparent`),this._hideCellShadePopover(),this.context.invoke(`editor.afterCommand`)}_buildBorderColorPopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#000000`,apply:e=>this._applyBorderColor(e),getPopover:()=>this._borderColorPopover,hide:()=>this._hideBorderColorPopover()});return this._borderColorTitleEl=t,this._borderColorNoBtn=n,e}_openBorderColorPopover(){if(!this._borderColorPopover)return;let e=this.context.locale.tooltips.table;this._borderColorTitleEl&&(this._borderColorTitleEl.textContent=e.tableBorderColor),this._borderColorNoBtn&&(this._borderColorNoBtn.textContent=e.noBorderColor),this._showColorPopover(()=>this._borderColorPopover)}_hideBorderColorPopover(){this._borderColorPopover&&(this._borderColorPopover.style.display=`none`)}_applyBorderColor(e){let t=this._activeTable;t&&(Array.from(t.querySelectorAll(`td, th`)).forEach(t=>{t.style.borderColor=e}),this._borderColorStrip&&(this._borderColorStrip.style.background=e||`transparent`),this._hideBorderColorPopover(),this.context.invoke(`editor.afterCommand`))}_syncBorderColorStrip(){if(!this._borderColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._activeTable?.querySelector(`td, th`);this._borderColorStrip.style.background=e?.style.borderColor||`transparent`}_applyCellAlign(e){this._getSelectedCells().forEach(t=>{t&&(t.style.textAlign=e)}),this.context.invoke(`editor.afterCommand`)}_toggleHeaderRow(){let e=this._activeTable;if(!e)return;let t=e.querySelector(`tr`);if(t){if(t.closest(`thead`)!==null){let n=e.querySelector(`tbody`);n||(n=document.createElement(`tbody`),e.appendChild(n)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`td`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.insertBefore(t,n.firstChild);let r=e.querySelector(`thead`);r&&r.rows.length===0&&r.remove()}else{let n=e.querySelector(`thead`);n||(n=document.createElement(`thead`),e.insertBefore(n,e.firstChild)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`th`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.appendChild(t)}this.context.invoke(`editor.afterCommand`)}}_sortColumn(e){let t=this._activeTable;if(!t)return;let n=this._getCell();if(!n)return;let r=Zr(n);if(r===-1)return;let i=t.querySelector(`tbody`)||t,a=Array.from(i.querySelectorAll(`:scope > tr`));a.length<2||(a.sort((t,n)=>{let i=J(t,r),a=J(n,r),o=(i?.textContent||``).trim(),s=(a?.textContent||``).trim(),c=parseFloat(o),l=parseFloat(s);return!isNaN(c)&&!isNaN(l)?e===`asc`?c-l:l-c:e===`asc`?o.localeCompare(s):s.localeCompare(o)}),a.forEach(e=>i.appendChild(e)),this._markSortIndicator(t,r,e),this.context.invoke(`editor.afterCommand`))}_markSortIndicator(e,t,n){let r=e.querySelector(`thead`);if(!r)return;r.querySelectorAll(`.an-sort-asc, .an-sort-desc`).forEach(e=>{e.classList.remove(`an-sort-asc`,`an-sort-desc`)});let i=r.querySelector(`tr`);if(!i)return;let a=J(i,t);a&&a.classList.add(n===`asc`?`an-sort-asc`:`an-sort-desc`)}_exportTableCSV(){let e=this._activeTable;if(!e)return;let t=Array.from(e.querySelectorAll(`tr`)).map(e=>Array.from(e.querySelectorAll(`td, th`)).map(e=>`"${(e.textContent||``).trim().replace(/"/g,`""`)}"`).join(`,`)).join(`
|
|
42
|
-
`),n=new Blob([``+t],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`table.csv`,i.style.display=`none`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}};function ii(e,t={}){t.cspNonce&&(e.nonce=t.cspNonce);let n=t.externalAssetCrossOrigin??`anonymous`,r=t.externalAssetReferrerPolicy??`no-referrer`;return n&&(e.crossOrigin=n),r&&(e.referrerPolicy=r),e}var ai=100,oi=180,si=/language-(\S+)/,Y={copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,wrapOn:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><path d="M3 12h15a3 3 0 0 1 0 6H3"/><polyline points="6 15 3 18 6 21"/></svg>`,toParagraph:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 4v16"/><path d="M17 4v16"/><path d="M9 4h8a4 4 0 0 1 0 8H9V4z"/></svg>`,deleteCode:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,lineNumbers:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-2-2-2"/></svg>`},ci=[[``,`Plain text`],[`javascript`,`JavaScript`],[`typescript`,`TypeScript`],[`python`,`Python`],[`html`,`HTML`],[`css`,`CSS`],[`scss`,`SCSS`],[`json`,`JSON`],[`yaml`,`YAML`],[`markdown`,`Markdown`],[`xml`,`XML`],[`bash`,`Bash / Shell`],[`sql`,`SQL`],[`java`,`Java`],[`csharp`,`C#`],[`php`,`PHP`],[`ruby`,`Ruby`],[`go`,`Go`],[`rust`,`Rust`],[`cpp`,`C++`],[`c`,`C`],[`kotlin`,`Kotlin`],[`swift`,`Swift`]];function li(e,t){[...e.classList].forEach(t=>{t.startsWith(`language-`)&&e.classList.remove(t)}),t&&e.classList.add(`language-${t}`)}var ui=class{constructor(e){this.context=e,this._el=null,this._activePre=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._copyBtn=null,this._wrapBtn=null,this._lineNumbersBtn=null,this._langSelect=null,this._prismScript=null,this._asyncDisposers=[]}initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el),this._ensurePrism();let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`pre`);n&&e.contains(n)&&this._scheduleShow(n)}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),_(document,`click`,e=>{let t=e.target;this._activePre&&!this._activePre.contains(t)&&!this._el.contains(t)&&this._hide()})),this}destroy(){this._clearTimers(),this._asyncDisposers.forEach(e=>e()),this._asyncDisposers=[],this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.code,t=m(`div`,{class:`an-link-tooltip an-code-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._langSelect=m(`select`,{class:`an-code-lang-select`,title:e.syntaxLanguage,"aria-label":e.syntaxAriaLabel}),ci.forEach(([e,t])=>{let n=m(`option`,{value:e});n.textContent=t,this._langSelect.appendChild(n)}),this._disposers.push(_(this._langSelect,`change`,()=>this._onLangChange())),t.appendChild(this._langSelect),t.appendChild(this._sep()),this._copyBtn=this._makeBtn(Y.copy,e.copyCode,()=>this._copyCode()),t.appendChild(this._copyBtn),t.appendChild(this._sep()),this._wrapBtn=this._makeBtn(Y.wrapOn,e.toggleWordWrap,()=>this._toggleWrap()),t.appendChild(this._wrapBtn),this._lineNumbersBtn=this._makeBtn(Y.lineNumbers,e.lineNumbers,()=>this._toggleLineNumbers()),t.appendChild(this._lineNumbersBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(Y.toParagraph,e.convertToParagraph,()=>this._toParagraph())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(Y.deleteCode,e.deleteCodeBlock,()=>this._delete(),!0)),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_sep(){return m(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=m(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(_(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){this._activePre
|
|
43
|
-
`)),n.Prism.highlightElement(r),this.context.invoke(`editor.afterCommand`))};if(t){if(n.Prism!==void 0){if(n.Prism.languages[t]){i();return}this._loadPrismComponent(t,i);return}
|
|
44
|
-
`),n=document.createElement(`p`);t.forEach((e,t)=>{t>0&&n.appendChild(document.createElement(`br`)),n.appendChild(document.createTextNode(e))}),e.parentNode.replaceChild(n,e),this._hide(),this.context.invoke(`editor.afterCommand`)}_delete(){let e=this._activePre;e&&(this._hide(),e.remove(),this.context.invoke(`editor.afterCommand`))}},di=n({EMOJI_CATS:()=>fi,EMOJI_LIST:()=>pi}),fi,pi,mi=t((()=>{fi=[{id:`smileys`,label:`Smileys`},{id:`people`,label:`People`},{id:`animals`,label:`Animals`},{id:`food`,label:`Food`},{id:`travel`,label:`Travel`},{id:`objects`,label:`Objects`},{id:`symbols`,label:`Symbols`}],pi=[[`😀`,`grin smile happy face`,`smileys`],[`😃`,`happy smile big eyes`,`smileys`],[`😄`,`grinning smile laugh`,`smileys`],[`😁`,`beaming smile grin`,`smileys`],[`😆`,`laughing lol`,`smileys`],[`😅`,`sweat grin awkward`,`smileys`],[`🤣`,`rolling laugh rofl`,`smileys`],[`😂`,`tears laugh cry joy`,`smileys`],[`🙂`,`slight smile`,`smileys`],[`🙃`,`upside down smile`,`smileys`],[`😉`,`wink`,`smileys`],[`😊`,`blush smile happy`,`smileys`],[`😇`,`innocent halo angel`,`smileys`],[`🥰`,`hearts love adore`,`smileys`],[`😍`,`heart eyes love`,`smileys`],[`🤩`,`star eyes excited wow`,`smileys`],[`😘`,`kiss blow love`,`smileys`],[`😋`,`yum delicious tongue`,`smileys`],[`😛`,`tongue stuck out`,`smileys`],[`😜`,`wink tongue crazy`,`smileys`],[`🤪`,`zany crazy wild`,`smileys`],[`😝`,`squint tongue`,`smileys`],[`🤑`,`money mouth`,`smileys`],[`🤗`,`hugging hug`,`smileys`],[`🤔`,`thinking hmm`,`smileys`],[`🤨`,`raised eyebrow`,`smileys`],[`😐`,`neutral face`,`smileys`],[`😶`,`no mouth`,`smileys`],[`😏`,`smirk`,`smileys`],[`😒`,`unamused`,`smileys`],[`🙄`,`roll eyes`,`smileys`],[`😬`,`grimace`,`smileys`],[`😔`,`pensive sad`,`smileys`],[`😪`,`sleepy tired`,`smileys`],[`😴`,`sleeping zzz`,`smileys`],[`🤤`,`drool`,`smileys`],[`😷`,`mask sick`,`smileys`],[`🤒`,`sick thermometer`,`smileys`],[`🤕`,`hurt bandage`,`smileys`],[`🤢`,`nausea sick`,`smileys`],[`🤮`,`vomit sick`,`smileys`],[`🤧`,`sneeze cold`,`smileys`],[`🥵`,`hot sweat`,`smileys`],[`🥶`,`cold freeze`,`smileys`],[`😵`,`dizzy dead`,`smileys`],[`🤯`,`mind blown`,`smileys`],[`🤠`,`cowboy hat`,`smileys`],[`🥳`,`party celebrate`,`smileys`],[`😎`,`cool sunglasses`,`smileys`],[`🤓`,`nerd glasses`,`smileys`],[`🧐`,`monocle curious`,`smileys`],[`😕`,`confused`,`smileys`],[`😟`,`worried`,`smileys`],[`🙁`,`frown sad`,`smileys`],[`☹️`,`sad frown`,`smileys`],[`😮`,`surprised open mouth`,`smileys`],[`😲`,`astonished`,`smileys`],[`🥺`,`pleading begging puppy eyes`,`smileys`],[`😢`,`cry sad tear`,`smileys`],[`😭`,`sob cry loudly`,`smileys`],[`😱`,`scream horror fear`,`smileys`],[`😡`,`angry red pouting`,`smileys`],[`😠`,`angry mad`,`smileys`],[`🤬`,`cursing swear`,`smileys`],[`😈`,`devil evil smile`,`smileys`],[`👿`,`devil angry evil`,`smileys`],[`💀`,`skull death`,`smileys`],[`☠️`,`skull crossbones`,`smileys`],[`💩`,`poop`,`smileys`],[`🤡`,`clown`,`smileys`],[`👻`,`ghost boo`,`smileys`],[`👽`,`alien ufo`,`smileys`],[`🤖`,`robot`,`smileys`],[`👋`,`wave hello hi hand`,`people`],[`🤚`,`raised back hand`,`people`],[`✋`,`raised hand stop`,`people`],[`🖖`,`vulcan salute spock`,`people`],[`👌`,`ok perfect fine`,`people`],[`✌️`,`peace victory fingers`,`people`],[`🤞`,`fingers crossed luck`,`people`],[`🤟`,`love you gesture`,`people`],[`🤘`,`sign of horns rock`,`people`],[`🤙`,`call me hand`,`people`],[`👈`,`point left`,`people`],[`👉`,`point right`,`people`],[`👆`,`point up`,`people`],[`👇`,`point down`,`people`],[`☝️`,`index pointing up`,`people`],[`👍`,`thumbs up like good`,`people`],[`👎`,`thumbs down dislike bad`,`people`],[`✊`,`raised fist punch`,`people`],[`👊`,`oncoming fist punch`,`people`],[`👏`,`clap applause`,`people`],[`🙌`,`celebrate raise hands`,`people`],[`🤝`,`handshake deal`,`people`],[`🙏`,`pray hope please thanks`,`people`],[`💅`,`nail polish`,`people`],[`💪`,`flexed bicep strong muscle`,`people`],[`👀`,`eyes look see`,`people`],[`👁️`,`eye`,`people`],[`👅`,`tongue`,`people`],[`👶`,`baby`,`people`],[`🧒`,`child`,`people`],[`👦`,`boy`,`people`],[`👧`,`girl`,`people`],[`🧑`,`person adult`,`people`],[`👨`,`man`,`people`],[`👩`,`woman`,`people`],[`🧔`,`beard man`,`people`],[`🧓`,`older person`,`people`],[`👴`,`old man`,`people`],[`👵`,`old woman`,`people`],[`❤️`,`heart love red`,`people`],[`🧡`,`orange heart love`,`people`],[`💛`,`yellow heart love`,`people`],[`💚`,`green heart love`,`people`],[`💙`,`blue heart love`,`people`],[`💜`,`purple heart love`,`people`],[`🖤`,`black heart`,`people`],[`🤍`,`white heart`,`people`],[`🤎`,`brown heart`,`people`],[`💔`,`broken heart`,`people`],[`❣️`,`exclamation heart`,`people`],[`💕`,`two hearts love`,`people`],[`💞`,`revolving hearts`,`people`],[`💓`,`beating heart`,`people`],[`💗`,`growing heart`,`people`],[`💖`,`sparkling heart`,`people`],[`💘`,`heart arrow`,`people`],[`💝`,`heart ribbon`,`people`],[`💬`,`speech bubble comment chat`,`people`],[`💭`,`thought bubble`,`people`],[`💯`,`100 hundred percent perfect`,`people`],[`💢`,`anger symbol mad`,`people`],[`💤`,`zzz sleep`,`people`],[`🐶`,`dog puppy`,`animals`],[`🐱`,`cat kitten`,`animals`],[`🐭`,`mouse`,`animals`],[`🐹`,`hamster`,`animals`],[`🐰`,`rabbit bunny`,`animals`],[`🦊`,`fox`,`animals`],[`🐻`,`bear`,`animals`],[`🐼`,`panda`,`animals`],[`🐨`,`koala`,`animals`],[`🐯`,`tiger`,`animals`],[`🦁`,`lion`,`animals`],[`🐮`,`cow`,`animals`],[`🐷`,`pig`,`animals`],[`🐸`,`frog`,`animals`],[`🐵`,`monkey`,`animals`],[`🙈`,`see no evil monkey`,`animals`],[`🙉`,`hear no evil monkey`,`animals`],[`🙊`,`speak no evil monkey`,`animals`],[`🐔`,`chicken hen`,`animals`],[`🐧`,`penguin`,`animals`],[`🐦`,`bird`,`animals`],[`🦆`,`duck`,`animals`],[`🦅`,`eagle`,`animals`],[`🦉`,`owl`,`animals`],[`🦇`,`bat`,`animals`],[`🐺`,`wolf`,`animals`],[`🐴`,`horse`,`animals`],[`🦄`,`unicorn`,`animals`],[`🐝`,`bee`,`animals`],[`🦋`,`butterfly`,`animals`],[`🐌`,`snail`,`animals`],[`🐞`,`ladybug`,`animals`],[`🐢`,`turtle`,`animals`],[`🐍`,`snake`,`animals`],[`🦎`,`lizard`,`animals`],[`🐊`,`crocodile`,`animals`],[`🐟`,`fish`,`animals`],[`🐠`,`tropical fish`,`animals`],[`🦈`,`shark`,`animals`],[`🐬`,`dolphin`,`animals`],[`🐳`,`whale`,`animals`],[`🐙`,`octopus`,`animals`],[`🦑`,`squid`,`animals`],[`🦀`,`crab`,`animals`],[`🌸`,`cherry blossom flower`,`animals`],[`🌺`,`hibiscus flower`,`animals`],[`🌻`,`sunflower`,`animals`],[`🌹`,`rose flower`,`animals`],[`🌷`,`tulip flower`,`animals`],[`🍀`,`four leaf clover luck`,`animals`],[`🌿`,`herb leaf green`,`animals`],[`🌱`,`seedling sprout`,`animals`],[`🌲`,`evergreen tree pine`,`animals`],[`🌳`,`deciduous tree`,`animals`],[`🌴`,`palm tree`,`animals`],[`🍄`,`mushroom`,`animals`],[`🌾`,`sheaf wheat`,`animals`],[`🐾`,`paw prints animal`,`animals`],[`🍎`,`apple red`,`food`],[`🍊`,`orange tangerine`,`food`],[`🍋`,`lemon yellow`,`food`],[`🍇`,`grapes`,`food`],[`🍓`,`strawberry`,`food`],[`🫐`,`blueberry`,`food`],[`🍒`,`cherry`,`food`],[`🍑`,`peach`,`food`],[`🥭`,`mango`,`food`],[`🍍`,`pineapple`,`food`],[`🥥`,`coconut`,`food`],[`🥝`,`kiwi`,`food`],[`🍅`,`tomato`,`food`],[`🥑`,`avocado`,`food`],[`🍆`,`eggplant aubergine`,`food`],[`🥕`,`carrot`,`food`],[`🌽`,`corn`,`food`],[`🥦`,`broccoli`,`food`],[`🥬`,`leafy green`,`food`],[`🧄`,`garlic`,`food`],[`🥜`,`peanut nut`,`food`],[`🍞`,`bread loaf`,`food`],[`🥐`,`croissant`,`food`],[`🧀`,`cheese`,`food`],[`🍳`,`egg fry cooking`,`food`],[`🥚`,`egg`,`food`],[`🥞`,`pancake`,`food`],[`🧇`,`waffle`,`food`],[`🥓`,`bacon`,`food`],[`🥩`,`meat steak`,`food`],[`🍗`,`chicken leg`,`food`],[`🌭`,`hotdog`,`food`],[`🍔`,`burger hamburger`,`food`],[`🍟`,`fries french`,`food`],[`🍕`,`pizza`,`food`],[`🌮`,`taco`,`food`],[`🌯`,`burrito wrap`,`food`],[`🍜`,`noodles ramen`,`food`],[`🍝`,`spaghetti pasta`,`food`],[`🍣`,`sushi`,`food`],[`🍱`,`bento box`,`food`],[`🍦`,`ice cream soft serve`,`food`],[`🍩`,`donut`,`food`],[`🍪`,`cookie`,`food`],[`🎂`,`birthday cake`,`food`],[`🍰`,`cake slice`,`food`],[`🧁`,`cupcake`,`food`],[`🍫`,`chocolate`,`food`],[`🍬`,`candy`,`food`],[`🍭`,`lollipop`,`food`],[`☕`,`coffee hot`,`food`],[`🍵`,`tea hot`,`food`],[`🧋`,`bubble tea boba`,`food`],[`🥤`,`cup straw drink`,`food`],[`🍷`,`wine red`,`food`],[`🍸`,`cocktail martini`,`food`],[`🍺`,`beer mug`,`food`],[`🍻`,`clinking beer mugs`,`food`],[`🥂`,`champagne toast celebrate`,`food`],[`🧃`,`juice box`,`food`],[`🧊`,`ice cube`,`food`],[`🚀`,`rocket space`,`travel`],[`🛸`,`ufo flying saucer`,`travel`],[`✈️`,`airplane plane fly`,`travel`],[`🚁`,`helicopter`,`travel`],[`🚂`,`train locomotive`,`travel`],[`🚄`,`bullet train fast`,`travel`],[`🚇`,`subway metro`,`travel`],[`🚌`,`bus`,`travel`],[`🚑`,`ambulance`,`travel`],[`🚒`,`fire truck`,`travel`],[`🚓`,`police car`,`travel`],[`🚕`,`taxi cab`,`travel`],[`🚗`,`car automobile red`,`travel`],[`🚙`,`suv car`,`travel`],[`🚚`,`truck delivery`,`travel`],[`🚜`,`tractor farm`,`travel`],[`🏎️`,`racing car fast`,`travel`],[`🏍️`,`motorcycle`,`travel`],[`🚲`,`bicycle bike`,`travel`],[`🛴`,`scooter kick`,`travel`],[`⛵`,`sailboat boat`,`travel`],[`🚢`,`ship cruise`,`travel`],[`🏠`,`house home`,`travel`],[`🏢`,`office building`,`travel`],[`🏥`,`hospital`,`travel`],[`🏦`,`bank`,`travel`],[`🏪`,`store shop convenience`,`travel`],[`🏫`,`school`,`travel`],[`🏰`,`castle european`,`travel`],[`🏯`,`japanese castle`,`travel`],[`🗼`,`tokyo tower`,`travel`],[`🗽`,`statue liberty new york`,`travel`],[`⛪`,`church`,`travel`],[`🕌`,`mosque`,`travel`],[`⛩️`,`shinto shrine`,`travel`],[`⛲`,`fountain`,`travel`],[`⛺`,`tent camping`,`travel`],[`🌁`,`fog foggy bridge`,`travel`],[`🌃`,`night city stars`,`travel`],[`🏙️`,`cityscape city buildings`,`travel`],[`🌅`,`sunrise morning`,`travel`],[`🌈`,`rainbow colorful`,`travel`],[`⛰️`,`mountain`,`travel`],[`🏔️`,`snow mountain`,`travel`],[`🗻`,`mount fuji`,`travel`],[`🏕️`,`camping tent`,`travel`],[`🗺️`,`world map`,`travel`],[`🧭`,`compass navigation`,`travel`],[`🌍`,`earth europe africa globe`,`travel`],[`🌎`,`earth americas globe`,`travel`],[`🌏`,`earth asia globe`,`travel`],[`🌐`,`globe internet web`,`travel`],[`💎`,`diamond gem jewel`,`objects`],[`💍`,`ring engagement`,`objects`],[`👑`,`crown royal king queen`,`objects`],[`🎩`,`top hat magic`,`objects`],[`💼`,`briefcase work business`,`objects`],[`👜`,`handbag purse`,`objects`],[`🎒`,`backpack bag school`,`objects`],[`👓`,`glasses eyewear`,`objects`],[`🕶️`,`sunglasses cool`,`objects`],[`💡`,`light bulb idea`,`objects`],[`🔦`,`flashlight torch`,`objects`],[`🕯️`,`candle light`,`objects`],[`🔋`,`battery charge`,`objects`],[`💻`,`laptop computer`,`objects`],[`🖥️`,`desktop monitor computer`,`objects`],[`📱`,`phone mobile cell`,`objects`],[`⌨️`,`keyboard type`,`objects`],[`🖱️`,`mouse computer click`,`objects`],[`📺`,`television tv`,`objects`],[`📷`,`camera photo`,`objects`],[`📹`,`video camera`,`objects`],[`🎥`,`movie camera film`,`objects`],[`☎️`,`telephone phone`,`objects`],[`⏰`,`alarm clock wake`,`objects`],[`⌚`,`watch time`,`objects`],[`🔑`,`key`,`objects`],[`🗝️`,`old key`,`objects`],[`🔒`,`lock closed`,`objects`],[`🔓`,`unlock open`,`objects`],[`🔨`,`hammer tool`,`objects`],[`🔧`,`wrench tool`,`objects`],[`🔩`,`bolt nut`,`objects`],[`⚙️`,`gear setting`,`objects`],[`🧲`,`magnet attract`,`objects`],[`📚`,`books stack library`,`objects`],[`📖`,`book open read`,`objects`],[`📝`,`memo write note`,`objects`],[`✏️`,`pencil write edit`,`objects`],[`📌`,`pushpin tack`,`objects`],[`📎`,`paperclip attach`,`objects`],[`📊`,`bar chart graph`,`objects`],[`📈`,`chart up growth trend`,`objects`],[`📉`,`chart down loss decline`,`objects`],[`📅`,`calendar date`,`objects`],[`📦`,`package box`,`objects`],[`📫`,`mailbox closed`,`objects`],[`📧`,`email envelope`,`objects`],[`🎁`,`gift present`,`objects`],[`🎀`,`ribbon bow`,`objects`],[`🎉`,`party celebrate confetti`,`objects`],[`🎊`,`confetti celebrate`,`objects`],[`🔮`,`crystal ball magic fortune`,`objects`],[`🪄`,`magic wand`,`objects`],[`🎯`,`target bullseye dart`,`objects`],[`🎲`,`dice game board`,`objects`],[`🎮`,`video game controller`,`objects`],[`🎭`,`theater masks drama`,`objects`],[`🎨`,`art palette paint`,`objects`],[`🎬`,`clapper film movie`,`objects`],[`🎤`,`microphone sing karaoke`,`objects`],[`🎧`,`headphones music listen`,`objects`],[`🎵`,`music note`,`objects`],[`🎶`,`music notes`,`objects`],[`🎸`,`guitar electric`,`objects`],[`🎹`,`piano keyboard music`,`objects`],[`🥁`,`drum percussion`,`objects`],[`🎷`,`saxophone jazz`,`objects`],[`🎺`,`trumpet`,`objects`],[`🎻`,`violin`,`objects`],[`⚽`,`soccer ball football`,`objects`],[`🏀`,`basketball`,`objects`],[`🏈`,`american football`,`objects`],[`⚾`,`baseball`,`objects`],[`🎾`,`tennis`,`objects`],[`🏐`,`volleyball`,`objects`],[`🏆`,`trophy winner award`,`objects`],[`🥇`,`gold medal first`,`objects`],[`🏅`,`sports medal`,`objects`],[`✅`,`check green done success`,`symbols`],[`❌`,`cross x no cancel`,`symbols`],[`⭕`,`circle red`,`symbols`],[`⛔`,`no entry stop`,`symbols`],[`🚫`,`prohibited no banned`,`symbols`],[`⚠️`,`warning caution danger`,`symbols`],[`❗`,`exclamation red important`,`symbols`],[`❓`,`question mark`,`symbols`],[`‼️`,`double exclamation`,`symbols`],[`💯`,`100 hundred percent perfect`,`symbols`],[`🔴`,`red circle dot`,`symbols`],[`🟠`,`orange circle`,`symbols`],[`🟡`,`yellow circle`,`symbols`],[`🟢`,`green circle`,`symbols`],[`🔵`,`blue circle`,`symbols`],[`🟣`,`purple circle`,`symbols`],[`⚫`,`black circle`,`symbols`],[`⚪`,`white circle`,`symbols`],[`🟤`,`brown circle`,`symbols`],[`🔺`,`red triangle up`,`symbols`],[`🔻`,`red triangle down`,`symbols`],[`🔷`,`blue diamond large`,`symbols`],[`🔶`,`orange diamond large`,`symbols`],[`🔹`,`blue diamond small`,`symbols`],[`🔸`,`orange diamond small`,`symbols`],[`⭐`,`star yellow`,`symbols`],[`🌟`,`glowing star shine`,`symbols`],[`✨`,`sparkles shine`,`symbols`],[`💫`,`dizzy star spin`,`symbols`],[`⚡`,`lightning bolt energy power`,`symbols`],[`🔥`,`fire hot flame`,`symbols`],[`💥`,`explosion boom`,`symbols`],[`❄️`,`snowflake cold ice winter`,`symbols`],[`🌊`,`wave water ocean sea`,`symbols`],[`💨`,`wind blow dash`,`symbols`],[`🌀`,`cyclone tornado spiral`,`symbols`],[`♻️`,`recycle loop green`,`symbols`],[`✔️`,`check tick done`,`symbols`],[`➕`,`plus add`,`symbols`],[`➖`,`minus subtract`,`symbols`],[`➗`,`divide division`,`symbols`],[`✖️`,`multiply times cross`,`symbols`],[`▶️`,`play button right`,`symbols`],[`⏸️`,`pause`,`symbols`],[`⏹️`,`stop square`,`symbols`],[`⏩`,`fast forward`,`symbols`],[`⏪`,`rewind fast backward`,`symbols`],[`🔔`,`bell notification`,`symbols`],[`🔕`,`bell slash mute`,`symbols`],[`🔊`,`speaker volume high`,`symbols`],[`🔇`,`mute silent no sound`,`symbols`],[`📢`,`loudspeaker announcement`,`symbols`],[`📣`,`megaphone cheer`,`symbols`],[`🏳️`,`white flag`,`symbols`],[`🏴`,`black flag`,`symbols`],[`🚩`,`red flag`,`symbols`],[`🏁`,`checkered flag finish race`,`symbols`],[`🆕`,`new badge`,`symbols`],[`🆓`,`free badge`,`symbols`],[`🆒`,`cool badge`,`symbols`],[`🔝`,`top arrow`,`symbols`],[`🔙`,`back arrow`,`symbols`],[`ℹ️`,`information info`,`symbols`],[`📍`,`pin location map`,`symbols`],[`🔗`,`link chain`,`symbols`],[`©️`,`copyright`,`symbols`],[`®️`,`registered trademark`,`symbols`],[`™️`,`trademark`,`symbols`],[`#️⃣`,`hash number`,`symbols`],[`0️⃣`,`zero number`,`symbols`],[`1️⃣`,`one number`,`symbols`],[`2️⃣`,`two number`,`symbols`],[`3️⃣`,`three number`,`symbols`],[`4️⃣`,`four number`,`symbols`],[`5️⃣`,`five number`,`symbols`]]})),hi=null,gi=null;function _i(){return hi?Promise.resolve(hi):(gi??=Promise.resolve().then(()=>(mi(),di)).then(e=>(hi={EMOJI_CATS:e.EMOJI_CATS,EMOJI_LIST:e.EMOJI_LIST},hi)),gi)}var vi=class extends W{_activeCat=`all`;initialize(){return this}async show(){if(this._saveRange(),!this._dialog){let{EMOJI_CATS:e,EMOJI_LIST:t}=await _i();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),document.body.appendChild(this._dialog))}this._activeCat=`all`,this._searchInput.value=``,this._updateCatTabs(),this._filterEmojis(``,`all`),this._open()}_buildDialog(){let e=this.context.locale.emojiDialog,t=m(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=m(`div`,{class:`an-dialog-box an-emoji-box`}),r=m(`div`,{class:`an-icon-title-row`}),i=m(`div`,{class:`an-dialog-title-group`}),a=m(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 13s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`;let o=m(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=m(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`×`,r.append(i,s);let c=m(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c;let l=m(`div`,{class:`an-icon-cats`}),u=m(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=m(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=m(`div`,{class:`an-emoji-grid`});this._list.forEach(([e,t,n])=>{let r=m(`button`,{type:`button`,class:`an-emoji-cell`,"data-char":e,"data-keywords":t,"data-cat":n,title:t.split(` `).slice(0,2).join(` `)});r.textContent=e,d.appendChild(r)}),this._grid=d,this._firstInput=c;let f=m(`div`,{class:`an-dialog-actions`}),p=m(`button`,{type:`button`,class:`an-btn`});p.textContent=e.cancelBtn,f.appendChild(p),n.append(r,c,l,d,f),t.appendChild(n),ee(r,n);let h=_(s,`click`,()=>this._close()),g=_(p,`click`,()=>this._close()),v=_(t,`click`,e=>{e.target===t&&this._close()}),y=_(c,`input`,()=>this._filterEmojis(c.value,this._activeCat)),b=_(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterEmojis(this._searchInput.value,this._activeCat))}),x=_(d,`click`,e=>{let t=e.target?.closest(`.an-emoji-cell`);t&&this._onEmojiClick(t.dataset.char)});return this._disposers.push(h,g,v,y,b,x),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterEmojis(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-emoji-cell`).forEach(e=>{let i=e,a=!t||t===`all`||i.dataset.cat===t,o=!n||i.dataset.keywords.includes(n)||i.dataset.char===n,s=a&&o;i.style.display=s?``:`none`,s&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=m(`div`,{class:`an-icon-empty`}),i.textContent=`No emojis found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_onEmojiClick(e){let t=this._savedRange,n=this.context.layoutInfo.editable;t&&t.select();let r=globalThis.getSelection(),i=r?.rangeCount>0?r.getRangeAt(0):null;i||(i=document.createRange(),i.selectNodeContents(n),i.collapse(!1));let a=i.startContainer,o=(a.nodeType===1?a:a.parentElement)?.closest(`td, th`);i.deleteContents(),o?.isConnected&&!o.contains(i.startContainer)&&(i.setStart(o,0),i.collapse(!0));let s=document.createTextNode(e);i.insertNode(s),i.setStartAfter(s),i.collapse(!0),r&&(r.removeAllRanges(),r.addRange(i)),this._close(),n.focus(),this.context.invoke(`editor.afterCommand`)}},yi=n({ICON_CATEGORIES:()=>bi,ICON_LIST:()=>xi}),bi,xi,Si=t((()=>{bi=[{id:`popular`,label:`Popular`},{id:`interface`,label:`Interface`},{id:`navigation`,label:`Navigation`},{id:`media`,label:`Media`},{id:`communication`,label:`Communication`},{id:`files`,label:`Files`},{id:`people`,label:`People`},{id:`objects`,label:`Objects`}],xi=[[`house`,`popular`],[`star`,`popular`],[`heart`,`popular`],[`check`,`popular`],[`xmark`,`popular`],[`plus`,`popular`],[`minus`,`popular`],[`magnifying-glass`,`popular`],[`gear`,`popular`],[`bell`,`popular`],[`user`,`popular`],[`envelope`,`popular`],[`phone`,`popular`],[`calendar`,`popular`],[`clock`,`popular`],[`lock`,`popular`],[`eye`,`popular`],[`eye-slash`,`popular`],[`trash`,`popular`],[`pen`,`popular`],[`bookmark`,`popular`],[`flag`,`popular`],[`thumbs-up`,`popular`],[`thumbs-down`,`popular`],[`circle-info`,`popular`],[`triangle-exclamation`,`popular`],[`circle-check`,`popular`],[`circle-xmark`,`popular`],[`share`,`popular`],[`download`,`popular`],[`upload`,`popular`],[`tag`,`popular`],[`bars`,`interface`],[`ellipsis`,`interface`],[`ellipsis-vertical`,`interface`],[`list`,`interface`],[`table-cells`,`interface`],[`table-list`,`interface`],[`grip`,`interface`],[`filter`,`interface`],[`sort`,`interface`],[`arrows-rotate`,`interface`],[`rotate`,`interface`],[`rotate-left`,`interface`],[`rotate-right`,`interface`],[`copy`,`interface`],[`floppy-disk`,`interface`],[`print`,`interface`],[`link`,`interface`],[`code`,`interface`],[`expand`,`interface`],[`compress`,`interface`],[`cloud`,`interface`],[`lock-open`,`interface`],[`key`,`interface`],[`shield`,`interface`],[`shield-halved`,`interface`],[`sliders`,`interface`],[`toggle-on`,`interface`],[`square-check`,`interface`],[`circle-plus`,`interface`],[`circle-minus`,`interface`],[`arrow-right`,`navigation`],[`arrow-left`,`navigation`],[`arrow-up`,`navigation`],[`arrow-down`,`navigation`],[`chevron-right`,`navigation`],[`chevron-left`,`navigation`],[`chevron-up`,`navigation`],[`chevron-down`,`navigation`],[`angle-right`,`navigation`],[`angle-left`,`navigation`],[`angle-up`,`navigation`],[`angle-down`,`navigation`],[`angles-right`,`navigation`],[`angles-left`,`navigation`],[`location-dot`,`navigation`],[`compass`,`navigation`],[`map`,`navigation`],[`map-pin`,`navigation`],[`route`,`navigation`],[`circle-arrow-right`,`navigation`],[`circle-arrow-left`,`navigation`],[`arrow-trend-up`,`navigation`],[`arrow-trend-down`,`navigation`],[`right-from-bracket`,`navigation`],[`right-to-bracket`,`navigation`],[`play`,`media`],[`pause`,`media`],[`stop`,`media`],[`forward`,`media`],[`backward`,`media`],[`forward-step`,`media`],[`backward-step`,`media`],[`volume-high`,`media`],[`volume-low`,`media`],[`volume-xmark`,`media`],[`volume-off`,`media`],[`music`,`media`],[`headphones`,`media`],[`microphone`,`media`],[`microphone-slash`,`media`],[`film`,`media`],[`camera`,`media`],[`camera-rotate`,`media`],[`video`,`media`],[`image`,`media`],[`images`,`media`],[`photo-film`,`media`],[`podcast`,`media`],[`radio`,`media`],[`comment`,`communication`],[`comments`,`communication`],[`comment-dots`,`communication`],[`message`,`communication`],[`paper-plane`,`communication`],[`reply`,`communication`],[`reply-all`,`communication`],[`at`,`communication`],[`hashtag`,`communication`],[`wifi`,`communication`],[`signal`,`communication`],[`rss`,`communication`],[`share-nodes`,`communication`],[`inbox`,`communication`],[`phone-volume`,`communication`],[`mobile`,`communication`],[`mobile-screen`,`communication`],[`laptop`,`communication`],[`desktop`,`communication`],[`tower-broadcast`,`communication`],[`file`,`files`],[`file-lines`,`files`],[`folder`,`files`],[`folder-open`,`files`],[`folder-plus`,`files`],[`folder-minus`,`files`],[`file-image`,`files`],[`file-pdf`,`files`],[`file-code`,`files`],[`file-zipper`,`files`],[`file-audio`,`files`],[`file-video`,`files`],[`file-arrow-up`,`files`],[`file-arrow-down`,`files`],[`database`,`files`],[`box`,`files`],[`box-open`,`files`],[`hard-drive`,`files`],[`server`,`files`],[`user`,`people`],[`users`,`people`],[`user-group`,`people`],[`user-plus`,`people`],[`user-minus`,`people`],[`user-check`,`people`],[`user-xmark`,`people`],[`user-tie`,`people`],[`user-shield`,`people`],[`user-secret`,`people`],[`person`,`people`],[`person-running`,`people`],[`person-walking`,`people`],[`child`,`people`],[`handshake`,`people`],[`hand`,`people`],[`hands-holding`,`people`],[`people-group`,`people`],[`pencil`,`objects`],[`paintbrush`,`objects`],[`eraser`,`objects`],[`scissors`,`objects`],[`wrench`,`objects`],[`screwdriver`,`objects`],[`hammer`,`objects`],[`toolbox`,`objects`],[`graduation-cap`,`objects`],[`book`,`objects`],[`book-open`,`objects`],[`glasses`,`objects`],[`microscope`,`objects`],[`flask`,`objects`],[`stethoscope`,`objects`],[`hospital`,`objects`],[`building`,`objects`],[`city`,`objects`],[`car`,`objects`],[`truck`,`objects`],[`plane`,`objects`],[`train`,`objects`],[`bicycle`,`objects`],[`bus`,`objects`],[`rocket`,`objects`],[`briefcase`,`objects`],[`cart-shopping`,`objects`],[`bag-shopping`,`objects`],[`credit-card`,`objects`],[`money-bill`,`objects`],[`chart-bar`,`objects`],[`chart-line`,`objects`],[`chart-pie`,`objects`],[`bolt`,`objects`],[`sun`,`objects`],[`moon`,`objects`],[`snowflake`,`objects`],[`fire`,`objects`],[`droplet`,`objects`],[`leaf`,`objects`],[`tree`,`objects`],[`earth-americas`,`objects`],[`globe`,`objects`],[`award`,`objects`],[`trophy`,`objects`],[`gift`,`objects`],[`puzzle-piece`,`objects`]]})),Ci=`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,wi=null,Ti=null;function Ei(){return wi?Promise.resolve(wi):(Ti??=Promise.resolve().then(()=>(Si(),yi)).then(e=>(wi={ICON_CATEGORIES:e.ICON_CATEGORIES,ICON_LIST:e.ICON_LIST},wi)),Ti)}var Di=class extends W{_selectedIcon=null;_activeCat=`all`;initialize(){return this}_ensureFontAwesome(){if(this.context.options.fontAwesomeAutoInject===!1)return;let e=this.context.options.fontAwesomeCDN||Ci;if(!e||document.getElementById(`an-fontawesome-css`))return;let t=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).map(e=>e.href||``).join(` `);if(/fontawesome|font-awesome/.test(t)||document.querySelector(`.fa-solid, .fas, .far, .fab`))return;let n=document.createElement(`link`);n.id=`an-fontawesome-css`,n.rel=`stylesheet`,n.href=e,ii(n,this.context.options),document.head.appendChild(n)}async show(){if(this._saveRange(),this._ensureFontAwesome(),!this._dialog){let{ICON_CATEGORIES:e,ICON_LIST:t}=await Ei();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),document.body.appendChild(this._dialog))}this._selectedIcon=null,this._activeCat=`all`,this._searchInput.value=``,this._grid.querySelectorAll(`.an-icon-cell.active`).forEach(e=>e.classList.remove(`active`)),this._insertBtn.setAttribute(`disabled`,``),this._updateCatTabs(),this._filterIcons(``,`all`),this._updatePreview(null),this._open()}_buildDialog(){let e=this.context.locale.iconDialog,t=m(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=m(`div`,{class:`an-dialog-box an-icon-box`}),r=m(`div`,{class:`an-icon-title-row`}),i=m(`div`,{class:`an-dialog-title-group`}),a=m(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>`;let o=m(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=m(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`×`,r.append(i,s);let c=m(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c,this._firstInput=c;let l=m(`div`,{class:`an-icon-cats`}),u=m(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=m(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=m(`div`,{class:`an-icon-grid`});this._list.forEach(([e,t])=>{let n=m(`button`,{type:`button`,class:`an-icon-cell`,"data-name":e,"data-cat":t,title:e}),r=m(`i`,{class:`fa-solid fa-`+e,"aria-hidden":`true`}),i=m(`span`);i.textContent=e,n.append(r,i),d.appendChild(n)}),this._grid=d;let f=m(`div`,{class:`an-icon-options`}),p=m(`label`,{class:`an-label`});p.textContent=e.style;let h=m(`select`,{class:`an-input an-icon-option-select`});[[`fa-solid`,`Solid`],[`fa-regular`,`Regular`],[`fa-light`,`Light (Pro)`]].forEach(([e,t])=>{let n=m(`option`,{value:e});n.textContent=t,h.appendChild(n)}),h.value=`fa-solid`,this._styleSelect=h;let g=m(`label`,{class:`an-label`});g.textContent=e.size;let v=m(`select`,{class:`an-input an-icon-option-select`});[[``,`Inherit`],[`0.75em`,`0.75em`],[`1em`,`1em`],[`1.25em`,`1.25em`],[`1.5em`,`1.5em`],[`2em`,`2em`],[`3em`,`3em`]].forEach(([e,t])=>{let n=m(`option`,{value:e});e===`1em`&&(n.selected=!0),n.textContent=t,v.appendChild(n)}),this._sizeSelect=v;let y=m(`label`,{class:`an-label`});y.textContent=e.color;let b=m(`input`,{type:`color`,class:`an-icon-color`,value:`#000000`});this._colorInput=b;let x=m(`label`,{class:`an-label an-label-inline an-icon-use-color`}),S=m(`input`,{type:`checkbox`,checked:``});this._useColorCb=S,x.append(S,document.createTextNode(e.useColor)),f.append(p,h,g,v,y,b,x);let C=m(`div`,{class:`an-icon-preview`}),w=m(`span`,{class:`an-icon-preview-hint`});w.textContent=e.selectHint,C.appendChild(w),this._preview=C;let T=m(`div`,{class:`an-dialog-actions`}),E=m(`button`,{type:`button`,class:`an-btn an-btn-primary`,disabled:``});E.textContent=e.insertBtn;let D=m(`button`,{type:`button`,class:`an-btn`});D.textContent=e.cancelBtn,T.append(E,D),this._insertBtn=E,n.append(r,c,l,d,f,C,T),t.appendChild(n),ee(r,n);let te=_(s,`click`,()=>this._close()),ne=_(D,`click`,()=>this._close()),re=_(E,`click`,()=>this._onInsert()),O=_(t,`click`,e=>{e.target===t&&this._close()}),ie=_(c,`input`,()=>this._filterIcons(c.value,this._activeCat)),k=_(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterIcons(this._searchInput.value,this._activeCat))}),ae=_(d,`click`,e=>{let t=e.target?.closest(`.an-icon-cell`);t&&this._selectIcon(t.dataset.name)}),oe=_(h,`change`,()=>this._updatePreview(this._selectedIcon)),se=_(v,`change`,()=>this._updatePreview(this._selectedIcon)),ce=_(b,`input`,()=>this._updatePreview(this._selectedIcon)),le=_(S,`change`,()=>this._updatePreview(this._selectedIcon));return this._disposers.push(te,ne,re,O,ie,k,ae,oe,se,ce,le),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterIcons(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-icon-cell`).forEach(e=>{let i=e,a=i.dataset.name,o=i.dataset.cat,s=!t||t===`all`||o===t,c=!n||a.includes(n),l=s&&c;i.style.display=l?``:`none`,l&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=m(`div`,{class:`an-icon-empty`}),i.textContent=`No icons found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_selectIcon(e){this._selectedIcon=e,this._grid.querySelectorAll(`.an-icon-cell`).forEach(t=>{t.classList.toggle(`active`,t.dataset.name===e)}),this._insertBtn.removeAttribute(`disabled`),this._updatePreview(e)}_updatePreview(e){if(!this._preview)return;if(!e){this._preview.innerHTML=`<span class="an-icon-preview-hint">Select an icon</span>`;return}let t=this._styleSelect?.value||`fa-solid`,n=this._sizeSelect?.value||`1em`,r=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,i=[n?`font-size:${n}`:``,r?`color:${r}`:``].filter(Boolean).join(`;`);this._preview.innerHTML=`<i class="${t} fa-${e}" aria-hidden="true"${i?` style="${i}"`:``}></i><div class="an-icon-preview-name">${t} fa-${e}</div>`}_onInsert(){if(!this._selectedIcon)return;let e=this._styleSelect?.value||`fa-solid`,t=this._sizeSelect?.value||``,n=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,r=[t?`font-size:${t}`:``,n?`color:${n}`:``].filter(Boolean),i=document.createElement(`i`);i.className=`${e} fa-${this._selectedIcon}`,i.setAttribute(`aria-hidden`,`true`),i.setAttribute(`contenteditable`,`false`),r.length&&i.setAttribute(`style`,r.join(`;`));let a=this._savedRange,o=this.context.layoutInfo.editable;a&&a.select();let s=globalThis.getSelection(),c=(s?.rangeCount??0)>0?s.getRangeAt(0):null;c||(c=document.createRange(),c.selectNodeContents(o),c.collapse(!1));let l=c.startContainer,u=(l.nodeType===1?l:l.parentElement)?.closest(`td, th`);c.deleteContents(),u?.isConnected&&!u.contains(c.startContainer)&&(c.setStart(u,0),c.collapse(!0)),c.insertNode(i);let d=i.nextSibling;d?.nodeType===Node.TEXT_NODE?d.textContent||=``:(d=document.createTextNode(``),i.parentNode.insertBefore(d,i.nextSibling));let f=+!!(d.textContent||``).startsWith(``),p=document.createRange();p.setStart(d,Math.min(f,d.textContent.length)),p.collapse(!0),s&&(s.removeAllRanges(),s.addRange(p)),this._close(),o.focus(),s&&(s.removeAllRanges(),s.addRange(p)),this.context.invoke(`editor.afterCommand`)}_close(){this._selectedIcon=null,super._close()}},Oi=[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}],ki=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M6 11h.01M10 11h.01M14 11h.01M18 11h.01M6 15h.01M18 15h.01M10 15h4"/><path d="M7 3l5 4 5-4"/></svg>`,Ai=class extends W{show(){this._open()}_buildDialog(){let e=this.context.locale.shortcutsDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,ki,e.title);n.classList.add(`an-shortcuts-box`);let r=m(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close,style:`margin-left:auto`});r.textContent=`×`,this._closeBtn=r,this._firstInput=r,n.querySelector(`.an-dialog-header`).appendChild(r),(this.context.locale.shortcutsDialog.shortcuts||Oi).forEach(({category:e,items:t})=>{let r=m(`div`,{class:`an-shortcuts-cat`});r.textContent=e,n.appendChild(r);let i=m(`div`,{class:`an-shortcuts-table`});t.forEach(({keys:e,action:t})=>{let n=m(`div`,{class:`an-shortcuts-row`}),r=m(`span`,{class:`an-shortcuts-key`});r.textContent=e;let a=m(`span`,{class:`an-shortcuts-action`});a.textContent=t,n.append(r,a),i.appendChild(n)}),n.appendChild(i)});let i=_(r,`click`,()=>this._close());return this._disposers.push(i),t}},ji=class extends W{constructor(e){super(e),this._findInput=null,this._replaceInput=null,this._caseCheckbox=null,this._counterEl=null,this._closeBtn=null,this._matches=[],this._currentIndex=-1,this._caseSensitive=!1,this._useRegex=!1,this._wholeWord=!1,this._mode=`find`,this._queryRegex=null,this._lastQuery=null,this._lastCaseSensitive=null,this._lastUseRegex=null,this._lastWholeWord=null,this._focusTimer=null}destroy(){clearTimeout(this._focusTimer),this._focusTimer=null,this._clearHighlights(),super.destroy()}show(e=`find`){this._mode=e,this._updateMode(),this._open(),clearTimeout(this._focusTimer),this._focusTimer=setTimeout(()=>{this._findInput&&(this._findInput.select(),this._findInput.focus())},50)}_open(){if(this._dialog){if(this._dialog.style.display===`flex`){this._findInput&&this._findInput.focus();return}this._dialog.style.display=`flex`,this._removeTrap&&=(this._removeTrap(),null),this._removeTrap=v(this._dialog,()=>this._close())}}_close(){this._clearHighlights(),this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this.context.invoke(`editor.focus`)}_updateMode(){if(!this._dialog)return;let e=this._dialog.querySelector(`.an-fr-replace-row`),t=this._dialog.querySelector(`.an-fr-replace-actions`),n=this._dialog.querySelector(`.an-dialog-title`),r=this._mode===`replace`;e&&(e.style.display=r?``:`none`),t&&(t.style.display=r?``:`none`),n&&(n.textContent=r?this.context.locale.findReplace.findReplaceTitle:this.context.locale.findReplace.findTitle)}_buildDialog(){let e=this.context.locale.findReplace,t=m(`div`,{class:`an-dialog-overlay an-fr-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":e.findReplaceTitle}),n=m(`div`,{class:`an-dialog-box an-fr-box`}),r=m(`div`,{class:`an-fr-header`}),i=m(`div`,{class:`an-dialog-title-group`}),a=m(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>`;let o=m(`h3`,{class:`an-dialog-title`});o.textContent=e.findTitle,i.append(a,o);let s=m(`button`,{type:`button`,class:`an-icon-close`,title:e.close,"aria-label":e.close});s.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" 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>`,this._closeBtn=s,r.append(i,s),n.appendChild(r);let c=m(`div`,{class:`an-fr-search-bar`}),l=m(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.findPlaceholder,"aria-label":e.searchAriaLabel});this._findInput=l;let u=m(`input`,{type:`checkbox`,style:`display:none`,"aria-hidden":`true`});this._caseCheckbox=u;let d=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:`Case sensitive`,"aria-label":`Case sensitive`});d.textContent=`Aa`;let f=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.useRegex,"aria-label":e.useRegex});f.textContent=`.*`;let p=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.wholeWord,"aria-label":e.wholeWord});p.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="7" width="18" height="10" rx="2"/><line x1="7" y1="21" x2="7" y2="17"/><line x1="17" y1="21" x2="17" y2="17"/></svg>`;let h=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:`Previous (Shift+Enter)`,"aria-label":`Previous`});h.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" 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>`;let g=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:`Next (Enter)`,"aria-label":`Next`});g.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" 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>`;let v=m(`span`,{class:`an-fr-counter`});this._counterEl=v,c.append(l,u,d,f,p,h,g,v),n.appendChild(c);let y=m(`div`,{class:`an-fr-replace-row`});y.style.display=`none`;let b=m(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.replacePlaceholder,"aria-label":e.replaceAriaLabel});this._replaceInput=b;let x=m(`button`,{type:`button`,class:`an-btn an-fr-replace-btn`});x.textContent=e.replaceBtn;let S=m(`button`,{type:`button`,class:`an-btn an-btn-primary an-fr-replace-btn`});S.textContent=e.replaceAllBtn,y.append(b,x,S),n.appendChild(y);let C=m(`div`,{class:`an-fr-replace-actions`});C.style.display=`none`,n.appendChild(C),t.appendChild(n),ee(r,n);let w=_(s,`click`,()=>this._close()),T=_(t,`click`,e=>{e.target===t&&this._close()}),E=_(l,`input`,()=>this._onSearch()),D=_(d,`click`,()=>{this._caseSensitive=!this._caseSensitive,u.checked=this._caseSensitive,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),te=_(u,`change`,()=>{this._caseSensitive=u.checked,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),ne=_(g,`click`,()=>this._next()),re=_(h,`click`,()=>this._prev()),O=_(x,`click`,()=>this._replace()),ie=_(S,`click`,()=>this._replaceAll()),k=_(l,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),t.shiftKey?this._prev():this._next())}),ae=_(b,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._replace())}),oe=_(f,`click`,()=>{this._useRegex=!this._useRegex,f.classList.toggle(`an-fr-icon-btn--active`,this._useRegex),this._queryRegex=null,this._lastQuery=null,this._onSearch()}),se=_(p,`click`,()=>{this._wholeWord=!this._wholeWord,p.classList.toggle(`an-fr-icon-btn--active`,this._wholeWord),this._queryRegex=null,this._lastQuery=null,this._onSearch()});return this._disposers.push(w,T,E,D,te,ne,re,O,ie,k,ae,oe,se),t}_onSearch(){this._clearHighlights();let e=this._findInput?this._findInput.value:``;if(!e){this._updateCounter();return}this._findAndHighlight(e),this._updateCounter()}_findAndHighlight(e){let t=this.context.layoutInfo.editable;if(!t)return;let n=this._findRawMatches(e,t);if(n.length!==0){for(let e=n.length-1;e>=0;e--){let{node:t,start:r,end:i}=n[e];try{let e=document.createRange();e.setStart(t,r),e.setEnd(t,i);let n=document.createElement(`mark`);n.className=`an-highlight`,e.surroundContents(n),this._matches.push({mark:n})}catch{this._matches.push({mark:null})}}this._matches.reverse(),this._matches=this._matches.filter(e=>e.mark),this._currentIndex=0,this._matches.length!==0&&this._matches[0]?.mark&&(this._matches[0].mark.className=`an-highlight an-highlight-current`,this._matches[0].mark.scrollIntoView({block:`center`,behavior:`smooth`}))}}_findRawMatches(e,t){let n=[];if(this._lastQuery!==e||this._lastCaseSensitive!==this._caseSensitive||this._lastUseRegex!==this._useRegex||this._lastWholeWord!==this._wholeWord){let t=this._caseSensitive?`g`:`gi`;try{let n=this._useRegex?e:e.replace(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);this._wholeWord&&(n=`\\b${n}\\b`),this._queryRegex=new RegExp(n,t)}catch{this._queryRegex=null}this._lastQuery=e,this._lastCaseSensitive=this._caseSensitive,this._lastUseRegex=this._useRegex,this._lastWholeWord=this._wholeWord}if(!this._queryRegex)return n;let r=this._queryRegex,i=document.createTreeWalker(t,4),a=i.nextNode();for(;a&&n.length<500;){r.lastIndex=0;let e;for(;(e=r.exec(a.textContent))!==null&&n.length<500;)n.push({node:a,start:e.index,end:e.index+e[0].length});a=i.nextNode()}return n}_next(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex+1)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_prev(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex-1+this._matches.length)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_scrollToMatch(e){let t=this._matches[e];t?.mark&&(this._matches.forEach((t,n)=>{t.mark&&(t.mark.className=n===e?`an-highlight an-highlight-current`:`an-highlight`)}),t.mark.scrollIntoView({block:`center`,behavior:`smooth`}))}_replace(){if(this._matches.length===0||this._currentIndex<0)return;let e=this._matches[this._currentIndex];if(!e?.mark?.parentNode)return;let t=this._replaceInput?this._replaceInput.value:``,n=e.mark.parentNode,r=document.createTextNode(t);n.insertBefore(r,e.mark),e.mark.remove(),n.normalize(),this.context.invoke(`editor.afterCommand`);let i=this._currentIndex;this._onSearch(),this._matches.length>0&&(this._currentIndex=Math.min(i,this._matches.length-1),this._scrollToMatch(this._currentIndex),this._updateCounter())}_replaceAll(){if(this._matches.length===0)return;let e=this._replaceInput?this._replaceInput.value:``;this._matches.forEach(({mark:t})=>{if(!t?.parentNode)return;let n=document.createTextNode(e);t.parentNode.insertBefore(n,t),t.remove()}),this.context.layoutInfo.editable&&this.context.layoutInfo.editable.normalize(),this._matches=[],this._currentIndex=-1,this.context.invoke(`editor.afterCommand`),this._onSearch()}_clearHighlights(){let e=this.context.layoutInfo.editable;e&&(e.querySelectorAll(`mark.an-highlight`).forEach(e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}),e.normalize(),this._matches=[],this._currentIndex=-1)}_updateCounter(){if(!this._counterEl)return;let e=this._matches.length;if(e===0){let e=this._findInput?this._findInput.value:``;this._counterEl.textContent=e?this.context.locale.findReplace.noResults:``}else this._counterEl.textContent=`${this._currentIndex+1} / ${e}`}},X=20,Mi=`#3b82f6`,Z=(e,t,n)=>Math.min(Math.max(e,t),n);function Ni(e,t,n,r){return new Promise(i=>{let a=e=>{let a=document.createElement(`canvas`);a.width=Math.round(n),a.height=Math.round(r);let o=a.getContext(`2d`);if(!o){i(null);return}try{o.drawImage(e,t.x,t.y,t.width,t.height,0,0,a.width,a.height),o.getImageData(0,0,1,1),i(a)}catch{i(null)}};if(e.src.startsWith(`data:`)||e.src.startsWith(`blob:`)||e.src.startsWith(globalThis.location.origin)){a(e);return}let o=new Image;o.crossOrigin=`anonymous`,o.onload=()=>a(o),o.onerror=()=>i(null),o.src=e.src+(e.src.includes(`?`)?`&`:`?`)+`_an=`+Date.now()})}var Pi=class{constructor(e){this.context=e,this._img=null,this._box=null,this._imgRect=null,this._scrim=null,this._cropBox=null,this._handles={},this._toolbar=null,this._infoEl=null,this._dragDisposers=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._close(!1)}open(e){this._scrim&&this._close(!1),this._img=e;let t=e.getBoundingClientRect();this._imgRect=t;let n=Math.min(12,t.width*.1,t.height*.1);this._box={x:t.left+n,y:t.top+n,w:t.width-n*2,h:t.height-n*2},this._buildDOM(),this._updateDOM(),this._bindEsc()}_buildDOM(){let e=document.createElement(`div`);e.className=`an-crop-scrim`,e.style.cssText=`
|
|
41
|
+
`)}},Nr=class{constructor(e){this.context=e,this._active=!1,this._disposers=[],this._prevHeight=``}initialize(){let e=_(document,`keydown`,e=>{this._active&&P(e,N.ESCAPE)&&this.deactivate()});return this._disposers.push(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._active&&this.deactivate()}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let e=this.context.layoutInfo.container;this._prevHeight=e.style.height,e.classList.add(`an-fullscreen`),e.style.height=``,document.body.style.overflow=`hidden`,this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active)return;let e=this.context.layoutInfo.container;e.classList.remove(`an-fullscreen`),e.style.height=this._prevHeight,document.body.style.overflow=``,this._active=!1,this.context.invoke(`toolbar.refresh`)}},W=class{constructor(e){this.context=e,this.options=e.options,this._dialog=null,this._disposers=[],this._savedRange=null,this._firstInput=null,this._removeTrap=null}_buildDialog(){throw Error(`_buildDialog() must be implemented by subclass`)}initialize(){return this._dialog=this._buildDialog(),document.body.appendChild(this._dialog),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dialog?.parentNode&&this._dialog.remove(),this._dialog=null}_saveRange(){S(e=>{this._savedRange=e})}_open(){this._dialog&&(this._dialog.style.display=`flex`,this._removeTrap=v(this._dialog,()=>this._close()),setTimeout(()=>this._firstInput?.focus(),50))}_close(){this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this._savedRange=null}_buildDialogShell(e,t,n){let r=m(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e}),i=m(`div`,{class:`an-dialog-box`}),a=m(`div`,{class:`an-dialog-header`}),o=m(`span`,{class:`an-dialog-icon`});o.innerHTML=t;let s=m(`h3`,{class:`an-dialog-title`});s.textContent=n,a.appendChild(o),a.appendChild(s),i.appendChild(a),r.appendChild(i),ee(a,i);let c=_(r,`click`,e=>{e.target===r&&this._close()});return this._disposers.push(c),{overlay:r,box:i}}_buildButtonRow(e,t,n){let r=m(`div`,{class:`an-dialog-actions`}),i=m(`button`,{type:`button`,class:`an-btn an-btn-primary`});i.textContent=e;let a=m(`button`,{type:`button`,class:`an-btn`});a.textContent=t,r.appendChild(i),r.appendChild(a);let o=_(i,`click`,n),s=_(a,`click`,()=>this._close());return this._disposers.push(o,s),r}},Pr=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,Fr=class extends W{show(){this._saveRange(),this._prefill(),this._open()}_buildDialog(){let e=this.context.locale.linkDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Pr,e.title),r=m(`label`,{class:`an-label`});r.textContent=e.url;let i=m(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,id:`an-link-url`,name:`url`,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=m(`label`,{class:`an-label`});a.textContent=e.displayText;let o=m(`input`,{type:`text`,class:`an-input`,placeholder:e.textPlaceholder,id:`an-link-text`,name:`linkText`,autocomplete:`off`});this._textInput=o;let s=m(`label`,{class:`an-label an-label-inline`}),c=m(`input`,{type:`checkbox`,id:`an-link-newtab`,name:`openInNewTab`});this._tabCheckbox=c,s.appendChild(c),s.appendChild(document.createTextNode(` `+e.openInNewTab));let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,l);let u=_(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=_(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_prefill(){let e=globalThis.getSelection(),t=null;if(e?.rangeCount>0){let n=e.getRangeAt(0).startContainer;for(;n;){if(n.nodeName===`A`){t=n;break}n=n.parentNode}}t?(this._urlInput.value=t.getAttribute(`href`)||``,this._textInput.value=t.textContent||``,this._tabCheckbox.checked=t.getAttribute(`target`)===`_blank`):(this._urlInput.value=``,this._textInput.value=e?e.toString():``,this._tabCheckbox.checked=!1)}_onInsert(){let e=this._urlInput.value.trim(),t=this._textInput.value.trim(),n=this._tabCheckbox.checked;if(!e){this._urlInput.focus();return}/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)||(e=`https://`+e);try{let t=new URL(e);if(/^javascript:/i.test(t.protocol)||/^vbscript:/i.test(t.protocol)||/^data:/i.test(t.protocol)){this._urlInput.focus();return}}catch{this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertLink`,e,t,n),this._close()}},Ir=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,Lr=class extends W{show({beforeInsert:e}={}){this._beforeInsert=typeof e==`function`?e:null,this._saveRange(),this._urlInput.value=``,this._altInput.value=``,this._fileInput&&(this._fileInput.value=``),this._open()}_buildDialog(){let e=this.context.locale.imageDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Ir,e.title),r=m(`label`,{class:`an-label`});r.textContent=e.imageUrl;let i=m(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=m(`label`,{class:`an-label`});a.textContent=e.altText;let o=m(`input`,{type:`text`,class:`an-input`,placeholder:e.altPlaceholder,autocomplete:`off`});this._altInput=o,n.append(r,i,a,o);let s=m(`label`,{class:`an-label`});s.textContent=e.alignment;let c=m(`div`,{class:`an-align-row`});if([{value:``,label:e.alignNone},{value:`left`,label:e.alignLeft},{value:`center`,label:e.alignCenter},{value:`right`,label:e.alignRight}].forEach(({value:e,label:t})=>{let n=`an-align-${e||`none`}`,r=m(`input`,{type:`radio`,name:`an-img-align`,id:n,value:e});e===``&&(r.checked=!0);let i=m(`label`,{for:n,class:`an-align-label`});i.textContent=t,c.append(r,i)}),this._alignRow=c,n.append(s,c),this.options.allowImageUpload!==!1){let t=m(`label`,{class:`an-label`});t.textContent=e.uploadLabel;let r=m(`input`,{type:`file`,class:`an-input`,accept:`image/jpeg,image/png,image/gif,image/webp,image/svg+xml,image/avif`});this._fileInput=r;let i=m(`p`,{class:`an-dialog-hint`});this._fileHint=i;let a=_(r,`change`,()=>this._onFileChange());this._disposers.push(a),n.append(t,r,i)}let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(l);let u=_(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=_(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_onFileChange(){if(this.context._alive===!1)return;let e=this._fileInput?.files?.[0];if(!e?.type?.startsWith(`image/`))return;if(!new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`,`image/avif`]).has(e.type)){let t=this.context.locale.errors.imageFormat(e.type);this._fileHint&&(this._fileHint.textContent=t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this._fileHint&&(this._fileHint.textContent=``);let t=(this.options.maxImageSize||5)*1024*1024;if(e.size>t){let t=this.context.locale.errors.imageSize(this.options.maxImageSize||5);this._fileHint&&(this._fileHint.textContent=t),console.warn(`[AutumnNote] ImageDialog:`,t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this.context.invoke(`clipboard.compressAndRegister`,e).then(e=>{this.context._alive!==!1&&(this._urlInput.value=e)}).catch(t=>{if(this.context._alive===!1)return;console.warn(`[AutumnNote] ImageDialog: image compression failed, using original file.`,t);let n=new FileReader;n.onload=e=>{this._urlInput.value=e.target.result},n.readAsDataURL(e)})}_onInsert(){let e=this._urlInput.value.trim(),t=this._altInput.value.trim(),n=this._alignRow?.querySelector(`input[name="an-img-align"]:checked`),r=n?n.value:``;if(!e){this._urlInput.focus();return}this._savedRange&&this._savedRange.select();let i=this._beforeInsert;this._beforeInsert=null,i?.(),this.context.invoke(`editor.insertImage`,e,t,r),this._close()}_close(){this._beforeInsert=null,super._close()}},Rr=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,zr=class extends W{show(){this._saveRange(),this._urlInput.value=``,this._widthInput.value=`560`,this._hintEl.textContent=``,this._open()}_buildDialog(){let e=this.context.locale.videoDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Rr,e.title),r=m(`label`,{class:`an-label`});r.textContent=e.videoUrl;let i=m(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=m(`p`,{class:`an-dialog-hint`});this._hintEl=a;let o=m(`label`,{class:`an-label`});o.textContent=e.widthLabel;let s=m(`input`,{type:`number`,class:`an-input`,placeholder:`560`,min:`80`,max:`1920`,value:`560`});this._widthInput=s;let c=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,c);let l=_(i,`input`,()=>{let e=this._parseVideoUrl(i.value.trim()),t=``;e?t=this.context.locale.videoDialog.detected(e.type):i.value&&(t=this.context.locale.videoDialog.unknownFormat),a.textContent=t}),u=_(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(l,u),t}_onInsert(){let e=this._urlInput.value.trim(),t=Math.max(80,Number.parseInt(this._widthInput.value,10)||560);if(!e){this._urlInput.focus();return}let n=this._buildEmbedHtml(e,t);if(!n){this._hintEl.textContent=this.context.locale.videoDialog.invalidUrl,this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertVideo`,n),this._close()}_parseVideoUrl(e){if(!e||!Ht(e,{media:!0}))return null;let t=/(?:youtube\.com\/watch\?(?:.*&)?v=|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.exec(e);if(t)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${t[1]}`};let n=/youtu\.be\/([a-zA-Z0-9_-]{11})/.exec(e);if(n)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${n[1]}`};let r=/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/.exec(e);if(r)return{type:`YouTube Shorts`,embedUrl:`https://www.youtube.com/embed/${r[1]}`};let i=/vimeo\.com\/(\d+)/.exec(e);return i?{type:`Vimeo`,embedUrl:`https://player.vimeo.com/video/${i[1]}`}:/\.(mp4|webm|ogg|ogv|mov)(#.*|\?.*)?$/i.test(e)?{type:`Direct video`,embedUrl:e}:null}_buildEmbedHtml(e,t){let n=this._parseVideoUrl(e),r=Math.round(t*9/16);if(n&&(n.type===`YouTube`||n.type===`YouTube Shorts`||n.type===`Vimeo`)){let e=`${n.type} video player`;return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><iframe src="${n.embedUrl}" width="${t}" height="${r}" title="${e}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" style="display:block;max-width:100%"></iframe><div class="an-video-shield"></div></div>`}if(n?.type===`Direct video`)return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${n.embedUrl.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`;let i=Ht(e,{media:!0});return i?`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${i.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`:null}},Br=[{pos:`nw`,cursor:`nw-resize`},{pos:`n`,cursor:`n-resize`},{pos:`ne`,cursor:`ne-resize`},{pos:`e`,cursor:`e-resize`},{pos:`se`,cursor:`se-resize`},{pos:`s`,cursor:`s-resize`},{pos:`sw`,cursor:`sw-resize`},{pos:`w`,cursor:`w-resize`}],Vr=class{constructor(e){this.context=e,this._active=null,this._overlay=null,this._disposers=[],this._positionRaf=null,this._lastOverlayPos=null}get _overlayClass(){return`an-resizer`}get _selectedClass(){return`an-selected`}_findTarget(e){return null}_getStartSize(e){return{w:0,h:0}}_getMinSize(){return{minW:20,minH:20}}_applySize(e,t,n){}_extraListeners(){return[]}initialize(){this._overlay=this._buildOverlay();let e=this.context.layoutInfo.editable.closest(`.an-container`)||document.body;e.appendChild(this._overlay),this._container=e;let t=this.context.layoutInfo.editable,n=null;return this._disposers.push(_(t,`click`,e=>this._onEditorClick(e)),_(t,`contextmenu`,e=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&this._select(t)}),_(document,`click`,e=>this._onDocClick(e)),_(globalThis,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),_(globalThis,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>this._updateOverlayPosition(),100)},{passive:!0}),_(t,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),...this._extraListeners()),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this._positionRaf&&=(cancelAnimationFrame(this._positionRaf),null),this._deselect(),this._overlay?.remove(),this._overlay=null}updateOverlay(){this._updateOverlayPosition()}deselect(){this._deselect()}_buildOverlay(){let e=document.createElement(`div`);return e.className=this._overlayClass,e.style.display=`none`,Br.forEach(({pos:t})=>{let n=document.createElement(`div`);n.className=`an-resize-handle an-resize-${t}`,n.dataset.handle=t,this._disposers.push(_(n,`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),this._startResize(e,t)})),e.appendChild(n)}),e}_onEditorClick(e){if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&(e.preventDefault(),this._select(t))}_onDocClick(e){this._active&&(this._active.contains(e.target)||this._overlay?.contains(e.target)||e.target.closest?.(`.an-contextmenu`)||this._deselect())}_select(e){this._active&&this._active!==e&&this._active.classList.remove(this._selectedClass),this._active=e,this._lastOverlayPos=null,e.classList.add(this._selectedClass),this._updateOverlayPosition(),this._overlay.style.display=`block`}_deselect(){this._active&&=(this._active.classList.remove(this._selectedClass),null),this._overlay&&(this._overlay.style.display=`none`)}_updateOverlayPosition(){this._positionRaf&&cancelAnimationFrame(this._positionRaf),this._positionRaf=requestAnimationFrame(()=>{this._positionRaf=null,this._updateOverlayPositionNow()})}_updateOverlayPositionNow(){if(!this._active||!this._overlay)return;let e=this._overlay.offsetParent||this._container,t=e.getBoundingClientRect(),n=this._active.getBoundingClientRect(),r=this._lastOverlayPos;if(r?.l===n.left&&r.t===n.top&&r.w===n.width&&r.h===n.height)return;this._lastOverlayPos={l:n.left,t:n.top,w:n.width,h:n.height};let i=n.left-t.left+e.scrollLeft,a=n.top-t.top+e.scrollTop;this._overlay.style.left=`${i}px`,this._overlay.style.top=`${a}px`,this._overlay.style.width=`${n.width}px`,this._overlay.style.height=`${n.height}px`}_startResize(e,t){let n=this._active;if(!n)return;let r=e.clientX,i=e.clientY,{w:a,h:o}=this._getStartSize(n),{minW:s,minH:c}=this._getMinSize(),l=a/(o||1),u=t.length===2,d=this.context.layoutInfo.editable,f=null,p=e=>{if(f!==null)return;let p=e.clientX,m=e.clientY;f=requestAnimationFrame(()=>{f=null;let e=p-r,h=m-i,g=d.clientWidth||1/0,_=a,v=o;t.includes(`e`)&&(_=Math.max(s,a+e)),t.includes(`w`)&&(_=Math.max(s,a-e)),t.includes(`s`)&&(v=Math.max(c,o+h)),t.includes(`n`)&&(v=Math.max(c,o-h)),_=Math.min(_,g),u&&(Math.abs(e)>=Math.abs(h)||(_=Math.min(Math.max(s,Math.round(v*l)),g)),v=Math.max(c,Math.round(_/l))),this._applySize(n,_,v),this._updateOverlayPosition()})},m=()=>{document.removeEventListener(`pointermove`,p),document.removeEventListener(`pointerup`,h),document.removeEventListener(`pointercancel`,h)},h=()=>{f!==null&&(cancelAnimationFrame(f),f=null),m(),this._dragDisposers=null,this.context.invoke(`editor.afterCommand`)};document.addEventListener(`pointermove`,p),document.addEventListener(`pointerup`,h),document.addEventListener(`pointercancel`,h),this._dragDisposers=[m]}},Hr=class extends Vr{get _overlayClass(){return`an-image-resizer`}get _selectedClass(){return`an-image-selected`}_findTarget(e){return e instanceof Element?e.closest(`img`):null}_getStartSize(e){return{w:e.offsetWidth||e.naturalWidth||100,h:e.offsetHeight||e.naturalHeight||100}}_getMinSize(){let e=this.context.options?.minImageSize??20;return{minW:e,minH:e}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`}getActiveImage(){return this._active}},Ur=class extends Vr{get _overlayClass(){return`an-video-resizer`}get _selectedClass(){return`an-video-selected`}_findTarget(e){return!e||!(e instanceof Element)?null:e.classList?.contains(`an-video-wrapper`)?e:e.closest(`.an-video-wrapper`)}_getStartSize(e){return{w:e.offsetWidth||560,h:e.offsetHeight||315}}_getMinSize(){return{minW:80,minH:45}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`;let r=e.querySelector(`iframe, video`);r&&(r.style.width=`${t}px`,r.style.height=`${n}px`)}_extraListeners(){let e=this.context.layoutInfo.editable;return[_(e,`dragstart`,e=>{e.target instanceof Element&&e.target.closest(`.an-video-wrapper`)&&e.preventDefault()})]}getActiveWrapper(){return this._active}},Wr={open:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,edit:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>`,unlink:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" y1="2" x2="8" y2="5"/><line x1="2" y1="8" x2="5" y2="8"/><line x1="16" y1="19" x2="16" y2="22"/><line x1="19" y1="16" x2="22" y2="16"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`},Gr=120,Kr=200,qr=class{constructor(e){this.context=e,this._el=null,this._activeAnchor=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{let n=t.target?.closest(`a[href]`);n&&e.contains(n)&&this._scheduleShow(n)}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.link,t=m(`div`,{class:`an-link-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._urlLabel=m(`span`,{class:`an-link-tooltip-url`}),t.appendChild(this._urlLabel),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._openBtn=this._makeBtn(Wr.open,e.openLink,()=>this._openLink()),this._copyBtn=this._makeBtn(Wr.copy,e.copyUrl,()=>this._copyLink()),this._editBtn=this._makeBtn(Wr.edit,e.editLink,()=>this._editLink()),this._unlinkBtn=this._makeBtn(Wr.unlink,e.removeLink,()=>this._unlink()),t.appendChild(this._openBtn),t.appendChild(this._copyBtn),t.appendChild(this._editBtn),t.appendChild(this._unlinkBtn),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_makeBtn(e,t,n){let r=m(`button`,{type:`button`,class:`an-link-tooltip-btn`,title:t});return r.innerHTML=e,this._disposers.push(_(r,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),r}_scheduleShow(e){(this._activeAnchor!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeAnchor=e,this._show(e)},Gr))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>{this._hide()},Kr))}_show(e){let t=this.context.layoutInfo.container.classList.contains(`an-disabled`),n=e.getAttribute(`href`)||``;this._urlLabel.textContent=this._truncateUrl(n),this._urlLabel.title=n,this._editBtn.style.display=t?`none`:``,this._unlinkBtn.style.display=t?`none`:``,this._el.style.display=`flex`,this._positionNear(e)}_hide(){this._el.style.display=`none`,this._activeAnchor=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||260,r=this._el.offsetHeight||34,i=t.bottom+6,a=t.left;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}_truncateUrl(e){try{let t=new URL(e),n=t.host+(t.pathname===`/`?``:t.pathname);return n.length>48?n.slice(0,48)+`…`:n}catch{return e.length>48?e.slice(0,48)+`…`:e}}_openLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&globalThis.open(e,`_blank`,`noopener,noreferrer`),this._hide()}_copyLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&navigator.clipboard.writeText(e).catch(()=>{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()}),this._copyBtn&&(this._copyBtn.classList.add(`an-link-tooltip-btn--copied`),setTimeout(()=>this._copyBtn?.classList.remove(`an-link-tooltip-btn--copied`),1e3))}_editLink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.context.invoke(`linkDialog.show`)}_unlink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),document.execCommand(`unlink`),this.context.invoke(`editor.afterCommand`)}},Jr=class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._active=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}_canHide(){return!0}_beforeHide(){}_makeBtn(e,t,n,r=!1){let i=m(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(_(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._active!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._active=e,this._show(e)},100))}_scheduleHide(){this._canHide()&&(clearTimeout(this._showTimer),this._showTimer=null,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hide(),180))}_show(e){this._el.style.display=`flex`,requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_hide(){this._beforeHide(),this._el.style.display=`none`,this._active=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||220,r=this._el.offsetHeight||32,i=t.bottom+6,a=t.left+(t.width-n)/2;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}},G={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,caption:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/></svg>`,rotateLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><polyline points="3 3 3 8 8 8"/></svg>`,rotateRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><polyline points="21 3 21 8 16 8"/></svg>`,crop:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 2 6 18 22 18"/><polyline points="2 6 18 6 18 22"/></svg>`},Yr=class extends Jr{initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`img`);n&&e.contains(n)&&!n.closest(`a[href]`)&&this._scheduleShow(n)},{passive:!0}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),_(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.image,t=m(`div`,{class:`an-link-tooltip an-image-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(G.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(G.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(G.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(G.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(G.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),t.appendChild(this._makeBtn(G.rotateLeft,e.rotateLeft,()=>this._rotate(-90))),t.appendChild(this._makeBtn(G.rotateRight,e.rotateRight,()=>this._rotate(90))),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._cropBtn=this._makeBtn(G.crop,e.cropImage,()=>this._crop()),t.appendChild(this._cropBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._captionBtn=this._makeBtn(G.caption,e.addCaption,()=>this._toggleCaption()),t.appendChild(this._captionBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(G.deleteImg,e.deleteImage,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;if(!t)return;let n=t.closest(`figure.an-figure`)||t;n.style.float=e,n.style.display=``,n!==t&&(n.style.width=``),n.style.marginLeft=e===`right`?`12px`:``,n.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_setCenter(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`)||e;t.style.float=``,t.style.display=`block`,t!==e&&(t.style.width=`fit-content`),t.style.marginLeft=`auto`,t.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_resetSize(){let e=this._active;e&&(e.style.width=``,e.style.height=``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_rotate(e){let t=this._active;if(!t)return;let n=t.style.transform||``,r=/rotate\((-?[\d.]+)deg\)/.exec(n),i=((r?Number.parseFloat(r[1]):0)+e+360)%360,a=n.replace(/rotate\(-?[\d.]+deg\)/,``).trim();a?t.style.transform=`${a} rotate(${i}deg)`:t.style.transform=i===0?``:`rotate(${i}deg)`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;if(!e)return;this._hide(),this.context.invoke(`imageResizer.deselect`);let t=e.closest(`figure.an-figure`);t?t.remove():e.remove(),this.context.invoke(`editor.afterCommand`)}_crop(){let e=this._active;e&&(this._hide(),this.context.invoke(`imageCropOverlay.open`,e))}_toggleCaption(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`);if(t){let e=t.querySelector(`figcaption.an-figcaption`);if(e){this._hide();let t=document.createRange();t.selectNodeContents(e);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}return}let n=document.createElement(`figure`);n.className=`an-figure`,e.style.float?(n.style.float=e.style.float,n.style.marginLeft=e.style.marginLeft,n.style.marginRight=e.style.marginRight,e.style.float=``,e.style.marginLeft=``,e.style.marginRight=``):e.style.display===`block`&&e.style.marginLeft===`auto`&&(n.style.display=`block`,n.style.width=`fit-content`,n.style.marginLeft=`auto`,n.style.marginRight=`auto`,e.style.display=``,e.style.marginLeft=``,e.style.marginRight=``);let r=document.createElement(`figcaption`);r.className=`an-figcaption`,r.textContent=`Caption`,e.parentNode.insertBefore(n,e),n.appendChild(e),n.appendChild(r);let i=document.createRange();i.selectNodeContents(r);let a=globalThis.getSelection();a&&(a.removeAllRanges(),a.addRange(i)),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),this._hide()}},K={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,preview:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 3 19 12 5 21 5 3"/></svg>`},Xr=class extends Jr{initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`.an-video-wrapper`);n&&e.contains(n)&&this._scheduleShow(n)},{passive:!0}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),_(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._previewMode&&this._exitPreview(),this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_canHide(){return!this._previewMode}_beforeHide(){this._previewMode&&this._exitPreview()}_buildTooltip(){let e=this.context.locale.tooltips.video,t=m(`div`,{class:`an-link-tooltip an-video-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(K.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(K.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(K.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(K.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(K.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._previewBtn=this._makeBtn(K.preview,e.previewVideo,()=>this._togglePreview()),t.appendChild(this._previewBtn),t.appendChild(m(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(K.deleteVideo,e.deleteVideo,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;t&&(t.style.float=e,t.style.display=e?`inline-block`:``,t.style.marginLeft=e===`right`?`12px`:``,t.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_setCenter(){let e=this._active;e&&(e.style.float=``,e.style.display=`block`,e.style.marginLeft=`auto`,e.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_resetSize(){let e=this._active;if(!e)return;let t=e.querySelector(`iframe, video`);e.style.width=``,e.style.height=``,t&&(t.removeAttribute(`width`),t.removeAttribute(`height`),t.style.width=``,t.style.height=``),this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;e&&(this._hide(),this.context.invoke(`videoResizer.deselect`),e.remove(),this.context.invoke(`editor.afterCommand`))}_togglePreview(){this._previewMode?this._exitPreview():this._enterPreview()}_enterPreview(){let e=this._active;if(!e)return;this._previewMode=!0;let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=`none`),this.context.invoke(`videoResizer.deselect`),this._previewBtn.classList.add(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.exitPreview,this._previewClickOff=t=>{!e.contains(t.target)&&!this._el.contains(t.target)&&this._exitPreview()},document.addEventListener(`mousedown`,this._previewClickOff,!0)}_exitPreview(){this._previewMode=!1;let e=this._active;if(e){let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=``)}this._previewBtn.classList.remove(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.previewVideo,this._previewClickOff&&=(document.removeEventListener(`mousedown`,this._previewClickOff,!0),null)}},q={rowAbove:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 3v7"/><path d="M9 7l3-4 3 4"/></svg>`,rowBelow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 12v7"/><path d="M9 17l3 4 3-4"/></svg>`,deleteRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="15" y1="15" x2="21" y2="21"/><line x1="21" y1="15" x2="15" y2="21"/></svg>`,colLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M3 12h7"/><path d="M7 8l-4 4 4 4"/></svg>`,colRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M12 12h9"/><path d="M17 8l4 4-4 4"/></svg>`,deleteCol:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="15" y1="6" x2="21" y2="12"/><line x1="21" y1="6" x2="15" y2="12"/></svg>`,mergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="8" height="10" rx="1"/><rect x="14" y="7" width="8" height="10" rx="1"/><path d="M10 12h4"/><path d="M12 10l2 2-2 2"/></svg>`,unmergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="5" width="20" height="14" rx="1"/><line x1="12" y1="5" x2="12" y2="19" stroke-dasharray="2.5 2"/><line x1="2" y1="12" x2="22" y2="12" stroke-dasharray="2.5 2"/><path d="M9 9 L6 12 L9 15"/><path d="M15 9 L18 12 L15 15"/></svg>`,colWidth:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="4" x2="7" y2="20"/><line x1="17" y1="4" x2="17" y2="20"/><line x1="7" y1="12" x2="17" y2="12"/><path d="M10 9l-3 3 3 3"/><path d="M14 9l3 3-3 3"/></svg>`,rowHeight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="17" x2="20" y2="17"/><line x1="12" y1="7" x2="12" y2="17"/><path d="M9 10l3-3 3 3"/><path d="M9 14l3 3 3-3"/></svg>`,tableBorder:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6" stroke-width="1"/><line x1="3" y1="13" x2="21" y2="13" stroke-width="2"/><line x1="3" y1="20" x2="21" y2="20" stroke-width="3"/></svg>`,deleteTable:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><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"/><line x1="16" y1="16" x2="22" y2="22" stroke="#ef4444"/><line x1="22" y1="16" x2="16" y2="22" stroke="#ef4444"/></svg>`,selectCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z" fill="currentColor" opacity="0.15"/><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z"/></svg>`,cellShade:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 11L8.93 3.36a1 1 0 0 0-1.29.08L3.22 7.8a1 1 0 0 0-.07 1.29L11 20"/><path d="m5 14 5-5"/><path d="M22 22a2 2 0 0 1-2 2h-3a2 2 0 0 1-2-2c0-1.5 2.5-5 3.5-5s3.5 3.5 3.5 5z"/></svg>`,borderColor:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="14" rx="1"/><line x1="3" y1="10" x2="21" y2="10" stroke-width="1.5"/><line x1="12" y1="3" x2="12" y2="17" stroke-width="1.5"/><path d="M3 21h18" stroke-width="3"/></svg>`,alignLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="17" y1="12" x2="7" y2="12"/><line x1="19" y1="18" x2="5" y2="18"/></svg>`,alignRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/></svg>`,alignJustify:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/></svg>`,headerRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="3" y="3" width="18" height="8" rx="1" fill="currentColor" opacity="0.2"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="9" y1="11" x2="9" y2="21"/><line x1="15" y1="11" x2="15" y2="21"/></svg>`,sortAsc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="11" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="13" y2="18"/><path d="M15 9l3-3 3 3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,sortDesc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="13" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="11" y2="18"/><path d="M15 15l3 3 3-3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,exportCSV:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`,cellPadding:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="7" y="7" width="10" height="10" rx="0.5" stroke-dasharray="2 1.5"/></svg>`};function Zr(e){let t=e.closest(`tr`);if(!t)return-1;let n=0;for(let r of t.cells){if(r===e)return n;n+=r.colSpan||1}return-1}function J(e,t){let n=0;for(let r of e.cells){if(n===t)return r;if(n>t)break;n+=r.colSpan||1}return null}function Qr(e,t){let n=0;for(let r of e.cells)if(n+=r.colSpan||1,n>t){let e=r.nextElementSibling;return e?.tagName===`TD`||e?.tagName===`TH`?e:null}return null}function $r(e){let t=Array.from(e.rows),n={},r=new WeakMap;return t.forEach((e,t)=>{n[t]||(n[t]={});let i=0;for(let a of e.cells){for(;n[t][i];)i++;let e=a.rowSpan||1,o=a.colSpan||1;r.set(a,{r:t,c:i,rs:e,cs:o});for(let r=0;r<e;r++){n[t+r]||(n[t+r]={});for(let e=0;e<o;e++)n[t+r][i+e]=a}i+=o}}),{gridMap:n,cellPos:r}}var ei=120,ti=200,ni=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],ri=class{constructor(e){this.context=e,this._el=null,this._activeTable=null,this._activeCell=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._sizePopover=null,this._sizeApply=null,this._sizeTitleEl=null,this._sizeInputEl=null,this._shadePopover=null,this._shadeTitleEl=null,this._shadeColorStrip=null,this._borderColorPopover=null,this._borderColorTitleEl=null,this._borderColorStrip=null,this._borderColorNoBtn=null,this._selectMode=!1,this._selectedCells=[],this._selectStart=null,this._selectDragging=!1,this._selectBtn=null,this._editable=null}initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el),this._sizePopover=this._buildSizePopover(),document.body.appendChild(this._sizePopover),this._shadePopover=this._buildCellShadePopover(),document.body.appendChild(this._shadePopover),this._borderColorPopover=this._buildBorderColorPopover(),document.body.appendChild(this._borderColorPopover);let e=this.context.layoutInfo.editable;return this._editable=e,this._disposers.push(_(e,`mousedown`,t=>{if(!this._selectMode)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.style.cursor!==`col-resize`&&n.style.cursor!==`row-resize`&&(t.preventDefault(),this._activeTable=n.closest(`table`),this._selectStart=n,this._selectDragging=!0,this._setSelection([n]))}),_(e,`mousemove`,t=>{if(!this._selectMode||!this._selectDragging||!this._selectStart)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.closest(`table`)===this._activeTable&&this._setSelection(this._getRectCells(this._selectStart,n))}),_(document,`mouseup`,()=>{this._selectDragging=!1}),_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`table`);if(n&&e.contains(n)){let e=t.target?.closest(`td, th`);e&&(this._activeCell=e,this._syncShadeStrip()),this._scheduleShow(n)}},{passive:!0}),_(e,`mouseout`,t=>{if(this._selectMode)return;let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n)&&!this._sizePopover?.contains(n))&&this._scheduleHide()},{passive:!0}),_(document,`click`,e=>{let t=e.target;this._selectMode&&this._activeTable?.contains(t)||this._activeTable&&!this._activeTable.contains(t)&&!this._el.contains(t)&&!this._sizePopover?.contains(t)&&!this._shadePopover?.contains(t)&&!this._borderColorPopover?.contains(t)&&this._hide()}),_(document,`selectionchange`,()=>this._syncShadeStrip()),_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),_(globalThis,`resize`,()=>this._hide(),{passive:!0})),this._initResize(),this}_initResize(){let e=this.context.layoutInfo.editable,t=null,n=null,r=!1,i=null,a=0,o=0,s=0,c=0,l=-1,u=null,d=null,f=null,p=null,m=null,h=()=>{t&&=(t.style.cursor=``,null),n=null};this._disposers.push(_(e,`mousemove`,i=>{if(r)return;if(this.context.layoutInfo.container.classList.contains(`an-disabled`)){h();return}if(m!==null)return;let a=i.target,o=i.clientX,s=i.clientY;m=requestAnimationFrame(()=>{m=null;let r=a.closest(`td, th`);if(!r||!e.contains(r)){h();return}t&&t!==r&&(t.style.cursor=``);let i=r.getBoundingClientRect(),c=Math.abs(o-i.right)<6,l=Math.abs(s-i.bottom)<6;c?(r.style.cursor=`col-resize`,t=r,n=`col`):l?(r.style.cursor=`row-resize`,t=r,n=`row`):h()})}),_(e,`mousedown`,e=>{if(!this.context.layoutInfo.container.classList.contains(`an-disabled`)&&!(!t||!n)){if(r=!0,i=n,a=e.clientX,o=e.clientY,f=t.closest(`table`),i===`col`)l=Zr(t)+(t.colSpan||1)-1,u=l>=0?Array.from(f.querySelectorAll(`tr`)).map(e=>J(e,l)).filter(Boolean).filter(e=>(e.colSpan||1)===1):[],s=u.length>0?u[0].offsetWidth:Math.max(30,Math.round(t.offsetWidth/(t.colSpan||1))),document.body.style.cursor=`col-resize`;else{let e=t.closest(`tr`),n=(e?Array.from(f.rows).indexOf(e):0)+(t.rowSpan||1)-1;d=f.rows[n]||e,c=d?d.offsetHeight:40,document.body.style.cursor=`row-resize`}document.body.style.userSelect=`none`,e.preventDefault(),e.stopPropagation()}}),_(document,`mousemove`,e=>{if(!r||p!==null)return;let t=e.clientX,n=e.clientY;p=requestAnimationFrame(()=>{if(p=null,i===`col`){let e=Math.max(30,s+(t-a));for(let t of u)t.style.width=`${e}px`,t.style.minWidth=`${e}px`}else{let e=Math.max(20,c+(n-o));if(d)for(let t of d.cells)t.style.height=`${e}px`,t.style.minHeight=`${e}px`}})}),_(document,`mouseup`,()=>{r&&(p!==null&&(cancelAnimationFrame(p),p=null),r=!1,document.body.style.userSelect=``,document.body.style.cursor=``,i=null,f=null,d=null,l=-1,u=null,this.context.invoke(`editor.afterCommand`))}))}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null,this._sizePopover?.parentNode&&this._sizePopover.remove(),this._sizePopover=null,this._shadePopover?.parentNode&&this._shadePopover.remove(),this._shadePopover=null,this._borderColorPopover?.parentNode&&this._borderColorPopover.remove(),this._borderColorPopover=null}_buildTooltip(){let e=this.context.locale.tooltips.table,t=m(`div`,{class:`an-link-tooltip an-table-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._selectBtn=this._makeBtn(q.selectCells,e.selectCells,()=>this._toggleSelectMode()),t.appendChild(this._selectBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.rowAbove,e.addRowAbove,()=>this._addRow(`above`))),t.appendChild(this._makeBtn(q.rowBelow,e.addRowBelow,()=>this._addRow(`below`))),t.appendChild(this._makeBtn(q.deleteRow,e.deleteRow,()=>this._deleteRow())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.colLeft,e.addColumnLeft,()=>this._addColumn(`left`))),t.appendChild(this._makeBtn(q.colRight,e.addColumnRight,()=>this._addColumn(`right`))),t.appendChild(this._makeBtn(q.deleteCol,e.deleteColumn,()=>this._deleteColumn())),t.appendChild(this._makeBtn(q.sortAsc,e.sortAsc,()=>this._sortColumn(`asc`))),t.appendChild(this._makeBtn(q.sortDesc,e.sortDesc,()=>this._sortColumn(`desc`))),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.mergeCells,e.mergeCells,()=>this._mergeCells())),t.appendChild(this._makeBtn(q.unmergeCells,e.unmergeCells,()=>this._unmergeCells())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.alignLeft,e.cellAlignLeft,()=>this._applyCellAlign(`left`))),t.appendChild(this._makeBtn(q.alignCenter,e.cellAlignCenter,()=>this._applyCellAlign(`center`))),t.appendChild(this._makeBtn(q.alignRight,e.cellAlignRight,()=>this._applyCellAlign(`right`))),t.appendChild(this._makeBtn(q.alignJustify,e.cellAlignJustify,()=>this._applyCellAlign(`justify`))),t.appendChild(this._makeBtn(q.headerRow,e.toggleHeaderRow,()=>this._toggleHeaderRow())),t.appendChild(this._sep());let n=m(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.cellBackground}),r=m(`span`,{class:`an-bubble-btn-svg`});r.innerHTML=q.cellShade;let i=m(`span`,{class:`an-link-tooltip-color-strip`});n.appendChild(r),n.appendChild(i),this._shadeColorStrip=i,this._disposers.push(_(n,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openCellShadePopover()})),t.appendChild(n),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.colWidth,e.columnWidth,()=>this._openSizePopover(`col`))),t.appendChild(this._makeBtn(q.rowHeight,e.rowHeight,()=>this._openSizePopover(`row`))),t.appendChild(this._makeBtn(q.tableBorder,e.tableBorderWidth,()=>this._openSizePopover(`border`))),t.appendChild(this._makeBtn(q.cellPadding,e.cellPadding,()=>this._openSizePopover(`cellPadding`)));let a=m(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.tableBorderColor}),o=m(`span`,{class:`an-bubble-btn-svg`});o.innerHTML=q.borderColor;let s=m(`span`,{class:`an-link-tooltip-color-strip`});return a.appendChild(o),a.appendChild(s),this._borderColorStrip=s,this._disposers.push(_(a,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openBorderColorPopover()})),t.appendChild(a),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.deleteTable,e.deleteTable,()=>this._deleteTable(),!0)),t.appendChild(this._sep()),t.appendChild(this._makeBtn(q.exportCSV,e.exportCSV,()=>this._exportTableCSV())),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>{this._selectMode||this._sizePopover&&this._sizePopover.style.display!==`none`||this._shadePopover&&this._shadePopover.style.display!==`none`||this._borderColorPopover&&this._borderColorPopover.style.display!==`none`||this._scheduleHide()})),t}_sep(){return m(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=m(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(_(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._activeTable!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeTable=e,this._show()},ei))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>this._hide(),ti))}_show(){this._activeTable&&(this._el.style.display=`flex`,this._syncShadeStrip(),this._syncBorderColorStrip(),requestAnimationFrame(()=>{this._activeTable&&this._positionNear(this._activeTable)}))}_syncShadeStrip(){if(!this._shadeColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._getCell();this._shadeColorStrip.style.background=e?.style.backgroundColor||`transparent`}_hide(){this._el.style.display=`none`,this._activeTable=null,this._activeCell=null,this._selectMode&&(this._selectMode=!1,this._selectBtn&&this._selectBtn.classList.remove(`an-link-tooltip-btn--active`),this._editable&&this._editable.classList.remove(`an-table-select-mode`)),this._clearSelection(),this._clearTimers(),this._hideSizePopover(),this._hideBorderColorPopover()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){if(!e)return;let t=e.getBoundingClientRect(),n=this._el.offsetWidth||400,r=this._el.offsetHeight||30,i=t.left+(t.width-n)/2,a=t.top-r-6;a<6&&(a=t.bottom+6),i+n>globalThis.innerWidth-6&&(i=globalThis.innerWidth-n-6),i<6&&(i=6),this._el.style.left=`${i}px`,this._el.style.top=`${a}px`}_getCell(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`td, th`);if(n&&this._activeTable?.contains(n))return n}return this._activeCell||this._activeTable?.querySelector(`td, th`)}_toggleSelectMode(){this._selectMode=!this._selectMode,this._selectBtn&&this._selectBtn.classList.toggle(`an-link-tooltip-btn--active`,this._selectMode),this._editable&&this._editable.classList.toggle(`an-table-select-mode`,this._selectMode),this._selectMode||this._clearSelection()}_clearSelection(){this._selectedCells.forEach(e=>e.classList.remove(`an-cell-selected`)),this._selectedCells=[],this._selectStart=null}_setSelection(e){this._selectedCells.forEach(t=>{e.includes(t)||t.classList.remove(`an-cell-selected`)}),this._selectedCells=e,e.forEach(e=>e.classList.add(`an-cell-selected`))}_getRectCells(e,t){if(!e)return[];if(!t||e===t)return[e];let n=e.closest(`table`);if(!n?.contains(t))return[e];let{gridMap:r,cellPos:i}=$r(n),a=i.get(e),o=i.get(t);if(!a||!o)return[e];let s=Math.min(a.r,o.r),c=Math.max(a.r+a.rs-1,o.r+o.rs-1),l=Math.min(a.c,o.c),u=Math.max(a.c+a.cs-1,o.c+o.cs-1),d=!0;for(;d;){d=!1;for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];if(!n)continue;let r=i.get(n);r&&(r.r<s&&(s=r.r,d=!0),r.r+r.rs-1>c&&(c=r.r+r.rs-1,d=!0),r.c<l&&(l=r.c,d=!0),r.c+r.cs-1>u&&(u=r.c+r.cs-1,d=!0))}}}let f=new Set,p=[];for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];n&&!f.has(n)&&(f.add(n),p.push(n))}}return p.length>0?p:[e]}_getSelectedCells(){return this._selectedCells.length>0?this._selectedCells:[this._getCell()].filter(Boolean)}_addRow(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=Array.from(n.querySelectorAll(`tr`)),i=[...new Set(t.map(e=>e.closest(`tr`)).filter(Boolean))],a=i.reduce((t,n)=>{let i=r.indexOf(t),a=r.indexOf(n);return e===`above`?a<i?n:t:a>i?n:t},i[0]),o=Array.from(a.cells).reduce((e,t)=>e+(t.colSpan||1),0),s=document.createElement(`tr`),c=Array.from(a.cells);for(let e=0;e<o;e++){let t=m(`td`,{},[`\xA0`]),n=c[e];n?.style.width&&(t.style.width=n.style.width),n?.style.minWidth&&(t.style.minWidth=n.style.minWidth),s.appendChild(t)}e===`above`?a.parentElement?.insertBefore(s,a):a.after(s),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_addColumn(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=t.map(e=>Zr(e)),i=e===`left`?Math.min(...r):Math.max(...r),a=Array.from(n.querySelectorAll(`tr`)),o=a.map(t=>e===`left`?J(t,i):Qr(t,i)),s=a.map(e=>e.closest(`thead`)!==null);a.forEach((e,t)=>{e.insertBefore(m(s[t]?`th`:`td`,{},[`\xA0`]),o[t])}),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_deleteRow(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=t.querySelector(`tbody`),r=n?n.querySelectorAll(`tr`).length:t.querySelectorAll(`tr`).length,i=[...new Set(e.map(e=>e.closest(`tr`)).filter(Boolean))];i.filter(e=>e.closest(`tbody`)).length>=r||(this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_deleteColumn(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=Array.from(t.querySelectorAll(`tr`));if(n[0]&&n[0].cells.length<=1)return;let r=[...new Set(e.map(e=>Zr(e)))];if(r.length>=(n[0]?.cells.length??1))return;let i=[];r.forEach(e=>{n.forEach(t=>{let n=J(t,e);n&&i.push(n)})}),this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_mergeCells(){let e=this._getCell();if(!e)return;let t=e.closest(`table`);if(!t)return;let n=this._getSelectedCells().filter(e=>t.contains(e));if(n.length<2){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return;let r=e.getRangeAt(0);if(n=Array.from(t.querySelectorAll(`td, th`)).filter(e=>{try{return r.intersectsNode(e)}catch{return!1}}),n.length<2)return}let{gridMap:r,cellPos:i}=$r(t),a=1/0,o=-1/0,s=1/0,c=-1/0;if(n.forEach(e=>{let t=i.get(e);t&&(t.r<a&&(a=t.r),t.r+t.rs-1>o&&(o=t.r+t.rs-1),t.c<s&&(s=t.c),t.c+t.cs-1>c&&(c=t.c+t.cs-1))}),a===1/0)return;let l=new Set,u=[];for(let e=a;e<=o;e++){let t=r[e];if(t)for(let e=s;e<=c;e++){let n=t[e];n&&!l.has(n)&&(l.add(n),u.push(n))}}if(u.length<2)return;let d=u[0];d.colSpan=c-s+1,d.rowSpan=o-a+1,d.style.verticalAlign=`middle`,d.style.height=``,d.style.minHeight=``;let f=u.map(e=>e.innerHTML.replace(/^(<br\s*\/?>|\s)+$/i,``).trim()).filter(e=>e!==``);d.innerHTML=f.length?f.join(`<br>`):`<br>`,u.slice(1).forEach(e=>{let t=e.parentElement;e.remove(),t&&t.cells.length===0&&t.remove()}),this._clearSelection(),this.context.invoke(`editor.afterCommand`)}_deleteTable(){let e=this._activeTable;e&&(this._hide(),e.parentNode&&e.remove(),this.context.invoke(`editor.afterCommand`))}_unmergeCells(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=e.filter(e=>t.contains(e)&&((e.colSpan||1)>1||(e.rowSpan||1)>1));n.length&&(n.forEach(e=>{t.contains(e)&&this._unmergeOne(e,t)}),this._clearSelection(),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_unmergeOne(e,t){let n=e.colSpan||1,r=e.rowSpan||1;if(n===1&&r===1)return;let{cellPos:i}=$r(t),a=i.get(e);if(!a)return;let{r:o,c:s}=a,c=Array.from(t.rows),l=e.tagName.toLowerCase();if(e.rowSpan=1,e.colSpan=1,e.style.verticalAlign=``,n>1){let t=e.nextElementSibling;for(let e=1;e<n;e++)c[o].insertBefore(m(l,{},[`\xA0`]),t)}for(let e=1;e<r;e++){let t=c[o+e];if(!t)continue;let r=null;for(let e of t.cells)if(i.get(e)?.c>s){r=e;break}for(let e=0;e<n;e++)t.insertBefore(m(l,{},[`\xA0`]),r)}}_buildSizePopover(){let e=m(`div`,{class:`an-size-popover`});e.style.display=`none`;let t=m(`div`,{class:`an-size-popover-title`}),n=m(`div`,{class:`an-size-popover-body`}),r=m(`input`,{type:`number`,class:`an-size-input`,min:`1`,max:`2000`,step:`1`}),i=m(`span`,{class:`an-size-unit`},[`px`]);n.appendChild(r),n.appendChild(i);let a=m(`div`,{class:`an-size-popover-actions`}),o=m(`button`,{type:`button`,class:`an-btn`});o.textContent=this.context.locale.tooltips.table.cancelBtn;let s=m(`button`,{type:`button`,class:`an-btn an-btn-primary`});s.textContent=this.context.locale.tooltips.table.applyBtn,a.appendChild(o),a.appendChild(s),e.appendChild(t),e.appendChild(n),e.appendChild(a),this._sizeTitleEl=t,this._sizeInputEl=r,this._sizeApply=null;let c=_(s,`click`,()=>{let e=Number.parseInt(this._sizeInputEl.value,10);e>=0&&typeof this._sizeApply==`function`&&this._sizeApply(e),this._hideSizePopover()}),l=_(o,`click`,()=>this._hideSizePopover()),u=_(r,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),s.click()),t.key===`Escape`&&this._hideSizePopover()}),d=_(document,`click`,e=>{let t=e.target;this._sizePopover&&this._sizePopover.style.display!==`none`&&!this._sizePopover.contains(t)&&!this._el.contains(t)&&this._hideSizePopover()}),f=_(e,`mouseenter`,()=>this._clearTimers()),p=_(e,`mouseleave`,()=>this._scheduleHide());return this._disposers.push(c,l,u,d,f,p),e}_openSizePopover(e){let t=this._getCell();if(!(!t||!this._sizePopover)){if(e===`border`){let e=t.closest(`table`);if(!e)return;let n=e.querySelector(`td, th`),r=n&&(Number.parseInt(n.style.borderWidth,10)||Number.parseInt(globalThis.getComputedStyle(n).borderWidth,10))||1;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.tableBorderWidthPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`10`,this._sizeInputEl.value=String(r),this._sizeApply=t=>{let n=Array.from(e.querySelectorAll(`td, th`));t===0?n.forEach(e=>{e.style.borderWidth=`0`,e.style.borderStyle=`none`}):n.forEach(e=>{e.style.borderWidth=`${t}px`,e.style.borderStyle=`solid`}),this.context.invoke(`editor.afterCommand`)}}else if(e===`cellPadding`){let e=this._getSelectedCells()[0]||this._getCell(),t=e&&(Number.parseInt(e.style.padding,10)||Number.parseInt(e.style.paddingTop,10))||4;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.cellPaddingPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`40`,this._sizeInputEl.value=String(t),this._sizeApply=e=>{this._getSelectedCells().forEach(t=>{t&&(t.style.padding=`${e}px`)}),this.context.invoke(`editor.afterCommand`)}}else{let n=e===`col`,r=this._getSelectedCells().filter(e=>{let n=e.closest(`table`);return n&&n===t.closest(`table`)});if(this._sizeTitleEl.textContent=n?this.context.locale.tooltips.table.columnWidthPx:this.context.locale.tooltips.table.rowHeightPx,this._sizeInputEl.min=`1`,this._sizeInputEl.max=`2000`,n)this._sizeInputEl.value=t.offsetWidth||120;else{let e=t.closest(`tr`);this._sizeInputEl.value=e&&e.offsetHeight||40}this._sizeApply=e=>{let i=t.closest(`table`);if(i){if(n){let t=[...new Set(r.map(e=>Zr(e)))],n=Array.from(i.querySelectorAll(`tr`));t.forEach(t=>{n.forEach(n=>{let r=J(n,t);r&&(r.colSpan||1)===1&&(r.style.width=`${e}px`,r.style.minWidth=`${e}px`)})})}else[...new Set(r.map(e=>e.closest(`tr`)).filter(Boolean))].forEach(t=>{for(let n of t.cells)n.style.height=`${e}px`,n.style.minHeight=`${e}px`});this.context.invoke(`editor.afterCommand`)}}}this._sizePopover.style.display=`block`,requestAnimationFrame(()=>{if(!this._sizePopover||!this._el)return;let e=this._el.getBoundingClientRect(),t=this._sizePopover.offsetWidth||220,n=this._sizePopover.offsetHeight||110,r=e.left,i=e.bottom+6;r+t>globalThis.innerWidth-8&&(r=globalThis.innerWidth-t-8),i+n>globalThis.innerHeight-8&&(i=e.top-n-6),this._sizePopover.style.left=`${r}px`,this._sizePopover.style.top=`${i}px`,this._sizeInputEl&&(this._sizeInputEl.focus(),this._sizeInputEl.select())})}}_hideSizePopover(){this._sizePopover&&(this._sizePopover.style.display=`none`),this._sizeApply=null}_buildColorPopover({defaultColor:e,apply:t,getPopover:n,hide:r}){let i=m(`div`,{class:`an-cell-shade-popover`});i.style.display=`none`;let a=m(`div`,{class:`an-size-popover-title`});i.appendChild(a);let o=m(`div`,{class:`an-context-color-palette`});ni.forEach(e=>{let n=m(`div`,{class:`an-context-color-swatch`,title:e});n.style.background=e,this._disposers.push(_(n,`click`,n=>{n.stopPropagation(),t(e)})),o.appendChild(n)}),i.appendChild(o);let s=m(`div`,{class:`an-context-color-custom`}),c=m(`button`,{type:`button`,class:`an-shade-no-color`});this._disposers.push(_(c,`click`,()=>t(``))),s.appendChild(c),i.appendChild(s);let l=m(`div`,{class:`an-context-color-custom`}),u=m(`input`,{type:`color`,class:`an-shade-color-input`,value:e}),d=m(`span`);return d.textContent=this.context.locale.contextMenu.customColorLabel,this._disposers.push(_(u,`change`,()=>t(u.value))),l.appendChild(u),l.appendChild(d),i.appendChild(l),this._disposers.push(_(i,`mousedown`,e=>e.preventDefault()),_(i,`mouseenter`,()=>this._clearTimers()),_(i,`mouseleave`,()=>this._scheduleHide()),_(document,`click`,e=>{let t=e.target,i=n();i&&i.style.display!==`none`&&!i.contains(t)&&!this._el?.contains(t)&&r()})),{el:i,titleEl:a,noColorBtn:c}}_showColorPopover(e){let t=e();t&&(t.style.display=`block`,requestAnimationFrame(()=>{let t=e();if(!t||!this._el)return;let n=t.offsetWidth||170,r=t.offsetHeight||120,i=this._el.getBoundingClientRect(),a=i.left,o=i.bottom+6;a+n>globalThis.innerWidth-8&&(a=globalThis.innerWidth-n-8),o+r>globalThis.innerHeight-8&&(o=i.top-r-6),t.style.left=`${Math.max(8,a)}px`,t.style.top=`${Math.max(8,o)}px`}))}_buildCellShadePopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#ffffff`,apply:e=>this._applyCellShade(e),getPopover:()=>this._shadePopover,hide:()=>this._hideCellShadePopover()});return this._shadeTitleEl=t,this._shadeNoBtn=n,e}_openCellShadePopover(){if(!this._shadePopover)return;let e=this.context.locale.tooltips.table;this._shadeTitleEl&&(this._shadeTitleEl.textContent=e.cellBackground),this._shadeNoBtn&&(this._shadeNoBtn.textContent=e.noShading),this._showColorPopover(()=>this._shadePopover)}_hideCellShadePopover(){this._shadePopover&&(this._shadePopover.style.display=`none`)}_applyCellShade(e){(this._selectMode?this._selectedCells:[this._getCell()]).forEach(t=>{t&&(t.style.backgroundColor=e)}),this._shadeColorStrip&&(this._shadeColorStrip.style.background=e||`transparent`),this._hideCellShadePopover(),this.context.invoke(`editor.afterCommand`)}_buildBorderColorPopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#000000`,apply:e=>this._applyBorderColor(e),getPopover:()=>this._borderColorPopover,hide:()=>this._hideBorderColorPopover()});return this._borderColorTitleEl=t,this._borderColorNoBtn=n,e}_openBorderColorPopover(){if(!this._borderColorPopover)return;let e=this.context.locale.tooltips.table;this._borderColorTitleEl&&(this._borderColorTitleEl.textContent=e.tableBorderColor),this._borderColorNoBtn&&(this._borderColorNoBtn.textContent=e.noBorderColor),this._showColorPopover(()=>this._borderColorPopover)}_hideBorderColorPopover(){this._borderColorPopover&&(this._borderColorPopover.style.display=`none`)}_applyBorderColor(e){let t=this._activeTable;t&&(Array.from(t.querySelectorAll(`td, th`)).forEach(t=>{t.style.borderColor=e}),this._borderColorStrip&&(this._borderColorStrip.style.background=e||`transparent`),this._hideBorderColorPopover(),this.context.invoke(`editor.afterCommand`))}_syncBorderColorStrip(){if(!this._borderColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._activeTable?.querySelector(`td, th`);this._borderColorStrip.style.background=e?.style.borderColor||`transparent`}_applyCellAlign(e){this._getSelectedCells().forEach(t=>{t&&(t.style.textAlign=e)}),this.context.invoke(`editor.afterCommand`)}_toggleHeaderRow(){let e=this._activeTable;if(!e)return;let t=e.querySelector(`tr`);if(t){if(t.closest(`thead`)!==null){let n=e.querySelector(`tbody`);n||(n=document.createElement(`tbody`),e.appendChild(n)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`td`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.insertBefore(t,n.firstChild);let r=e.querySelector(`thead`);r&&r.rows.length===0&&r.remove()}else{let n=e.querySelector(`thead`);n||(n=document.createElement(`thead`),e.insertBefore(n,e.firstChild)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`th`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.appendChild(t)}this.context.invoke(`editor.afterCommand`)}}_sortColumn(e){let t=this._activeTable;if(!t)return;let n=this._getCell();if(!n)return;let r=Zr(n);if(r===-1)return;let i=t.querySelector(`tbody`)||t,a=Array.from(i.querySelectorAll(`:scope > tr`));a.length<2||(a.sort((t,n)=>{let i=J(t,r),a=J(n,r),o=(i?.textContent||``).trim(),s=(a?.textContent||``).trim(),c=parseFloat(o),l=parseFloat(s);return!isNaN(c)&&!isNaN(l)?e===`asc`?c-l:l-c:e===`asc`?o.localeCompare(s):s.localeCompare(o)}),a.forEach(e=>i.appendChild(e)),this._markSortIndicator(t,r,e),this.context.invoke(`editor.afterCommand`))}_markSortIndicator(e,t,n){let r=e.querySelector(`thead`);if(!r)return;r.querySelectorAll(`.an-sort-asc, .an-sort-desc`).forEach(e=>{e.classList.remove(`an-sort-asc`,`an-sort-desc`)});let i=r.querySelector(`tr`);if(!i)return;let a=J(i,t);a&&a.classList.add(n===`asc`?`an-sort-asc`:`an-sort-desc`)}_exportTableCSV(){let e=this._activeTable;if(!e)return;let t=Array.from(e.querySelectorAll(`tr`)).map(e=>Array.from(e.querySelectorAll(`td, th`)).map(e=>`"${(e.textContent||``).trim().replace(/"/g,`""`)}"`).join(`,`)).join(`
|
|
42
|
+
`),n=new Blob([``+t],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`table.csv`,i.style.display=`none`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}};function ii(e,t={}){t.cspNonce&&(e.nonce=t.cspNonce);let n=t.externalAssetCrossOrigin??`anonymous`,r=t.externalAssetReferrerPolicy??`no-referrer`;return n&&(e.crossOrigin=n),r&&(e.referrerPolicy=r),e}var ai=100,oi=180,si=/language-(\S+)/,Y={copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,wrapOn:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><path d="M3 12h15a3 3 0 0 1 0 6H3"/><polyline points="6 15 3 18 6 21"/></svg>`,toParagraph:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 4v16"/><path d="M17 4v16"/><path d="M9 4h8a4 4 0 0 1 0 8H9V4z"/></svg>`,deleteCode:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,lineNumbers:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-2-2-2"/></svg>`},ci=[[``,`Plain text`],[`javascript`,`JavaScript`],[`typescript`,`TypeScript`],[`python`,`Python`],[`html`,`HTML`],[`css`,`CSS`],[`scss`,`SCSS`],[`json`,`JSON`],[`yaml`,`YAML`],[`markdown`,`Markdown`],[`xml`,`XML`],[`bash`,`Bash / Shell`],[`sql`,`SQL`],[`java`,`Java`],[`csharp`,`C#`],[`php`,`PHP`],[`ruby`,`Ruby`],[`go`,`Go`],[`rust`,`Rust`],[`cpp`,`C++`],[`c`,`C`],[`kotlin`,`Kotlin`],[`swift`,`Swift`]];function li(e,t){[...e.classList].forEach(t=>{t.startsWith(`language-`)&&e.classList.remove(t)}),t&&e.classList.add(`language-${t}`)}var ui=class{constructor(e){this.context=e,this._el=null,this._activePre=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._copyBtn=null,this._wrapBtn=null,this._lineNumbersBtn=null,this._langSelect=null,this._prismScript=null,this._asyncDisposers=[]}initialize(){this._el=this._buildTooltip(),document.body.appendChild(this._el),this._ensurePrism();let e=this.context.layoutInfo.editable;return this._disposers.push(_(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`pre`);n&&e.contains(n)&&this._scheduleShow(n)}),_(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),_(document,`click`,e=>{let t=e.target;this._activePre&&!this._activePre.contains(t)&&!this._el.contains(t)&&this._hide()})),this}destroy(){this._clearTimers(),this._asyncDisposers.forEach(e=>e()),this._asyncDisposers=[],this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.code,t=m(`div`,{class:`an-link-tooltip an-code-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=m(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._langSelect=m(`select`,{class:`an-code-lang-select`,title:e.syntaxLanguage,"aria-label":e.syntaxAriaLabel}),ci.forEach(([e,t])=>{let n=m(`option`,{value:e});n.textContent=t,this._langSelect.appendChild(n)}),this._disposers.push(_(this._langSelect,`change`,()=>this._onLangChange())),t.appendChild(this._langSelect),t.appendChild(this._sep()),this._copyBtn=this._makeBtn(Y.copy,e.copyCode,()=>this._copyCode()),t.appendChild(this._copyBtn),t.appendChild(this._sep()),this._wrapBtn=this._makeBtn(Y.wrapOn,e.toggleWordWrap,()=>this._toggleWrap()),t.appendChild(this._wrapBtn),this._lineNumbersBtn=this._makeBtn(Y.lineNumbers,e.lineNumbers,()=>this._toggleLineNumbers()),t.appendChild(this._lineNumbersBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(Y.toParagraph,e.convertToParagraph,()=>this._toParagraph())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(Y.deleteCode,e.deleteCodeBlock,()=>this._delete(),!0)),this._disposers.push(_(t,`mouseenter`,()=>this._clearTimers()),_(t,`mouseleave`,()=>this._scheduleHide())),t}_sep(){return m(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=m(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(_(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._activePre!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activePre=e,this._syncWrapBtn(),this._syncLineNumbersBtn(),this._syncLangSelect(),this._show(e)},ai))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hide(),oi)}_show(e){this._el.style.display=`flex`,this._positionNear(e)}_hide(){this._el.style.display=`none`,this._activePre=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||260,r=this._el.offsetHeight||32,i=t.top-r-6,a=t.left+(t.width-n)/2;i<6&&(i=t.bottom+6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}_syncWrapBtn(){if(!this._activePre||!this._wrapBtn)return;let e=(this._activePre.style.whiteSpace||``).includes(`pre-wrap`)||globalThis.getComputedStyle(this._activePre).whiteSpace===`pre-wrap`;this._wrapBtn.classList.toggle(`active`,e),this._wrapBtn.title=e?this.context.locale.tooltips.code.disableWordWrap:this.context.locale.tooltips.code.enableWordWrap}_syncLineNumbersBtn(){if(!this._activePre||!this._lineNumbersBtn)return;let e=this._activePre.classList.contains(`an-code-line-numbers`);this._lineNumbersBtn.classList.toggle(`active`,e),this._lineNumbersBtn.title=this.context.locale.tooltips.code.lineNumbers}_syncLangSelect(){if(!this._activePre||!this._langSelect)return;let e=this._activePre.querySelector(`code`),t=this._activePre.dataset.language||``,n=e&&(si.exec(e.className)||[])[1]||``;this._langSelect.value=t||n||``}_copyCode(){let e=this._activePre;if(!e)return;let t=e.textContent||``;if(navigator.clipboard)navigator.clipboard.writeText(t).then(()=>this._flashCopied()).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.cssText=`position:fixed;opacity:0;top:0;left:0`,document.body.appendChild(e),e.select();try{document.execCommand(`copy`),this._flashCopied()}catch{}e.remove()}}_flashCopied(){if(!this._copyBtn)return;let e=this._copyBtn.innerHTML;this._copyBtn.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,this._copyBtn.classList.add(`an-link-tooltip-btn--copied`),setTimeout(()=>{this._copyBtn&&(this._copyBtn.innerHTML=e,this._copyBtn.classList.remove(`an-link-tooltip-btn--copied`))},1400)}_toggleWrap(){let e=this._activePre;if(!e)return;let t=e.style.whiteSpace===`pre-wrap`;e.style.whiteSpace=t?`pre`:`pre-wrap`,this._syncWrapBtn(),this.context.invoke(`editor.afterCommand`),this._positionNear(e)}_toggleLineNumbers(){let e=this._activePre;e&&(e.classList.toggle(`an-code-line-numbers`),this._syncLineNumbersBtn(),this.context.invoke(`editor.afterCommand`))}applyLanguage(e,t){if(!e||!t)return;let n=this._activePre;this._activePre=e,this._langSelect&&(this._langSelect.value=t),this._onLangChange(),this._langSelect&&(this._langSelect.value=t),this._activePre=n||e}_onLangChange(){let e=this._activePre;if(!e)return;let t=this._langSelect.value,n=globalThis,r=e.querySelector(`code`);r||(r=document.createElement(`code`),r.innerHTML=e.innerHTML,e.innerHTML=``,e.appendChild(r)),li(r,t),li(e,t),t?e.dataset.language=t:delete e.dataset.language;let i=()=>{!this.context._alive||!r.isConnected||!n.Prism||(r.querySelectorAll(`br`).forEach(e=>e.replaceWith(`
|
|
43
|
+
`)),n.Prism.highlightElement(r),this.context.invoke(`editor.afterCommand`))};if(t){if(n.Prism!==void 0){if(n.Prism.languages[t]){i();return}this._loadPrismComponent(t,i);return}if(this._prismScript){this._onScriptLoad(this._prismScript,()=>{n.Prism.languages[t]?i():this._loadPrismComponent(t,i)});return}}this.context.invoke(`editor.afterCommand`)}_cdnBase(){return String(this.context.options.codeHighlightCDN??``).replace(/\/+$/,``)}_ensurePrism(){let e=globalThis;if(!this.context.options.codeHighlight||e.Prism)return;let t=this._cdnBase(),n=`${t}/themes/prism-tomorrow.min.css`,r=`${t}/prism.min.js`;if(!document.querySelector(`link[href="${n}"]`)){let e=document.createElement(`link`);e.rel=`stylesheet`,e.href=n,ii(e,this.context.options),document.head.appendChild(e)}let i=document.querySelector(`script[src="${r}"]`);if(i){this._prismScript=e.Prism?null:i;return}let a=document.createElement(`script`);a.dataset.manual=``,a.src=r,ii(a,this.context.options),this._prismScript=a,this._onScriptLoad(a,()=>{this._prismScript=null}),document.head.appendChild(a)}_onScriptLoad(e,t){let n=()=>{this.context._alive&&t()};e.addEventListener(`load`,n,{once:!0}),this._asyncDisposers.push(()=>e.removeEventListener(`load`,n))}_loadPrismComponent(e,t){let n=globalThis,r=`${this._cdnBase()}/components/prism-${e}.min.js`;if(document.querySelector(`script[src="${r}"]`)){let r=setInterval(()=>{if(!this.context._alive){clearInterval(r);return}n.Prism?.languages[e]&&(clearInterval(r),t())},50),i=setTimeout(()=>clearInterval(r),3e3);this._asyncDisposers.push(()=>{clearInterval(r),clearTimeout(i)});return}let i=document.createElement(`script`);i.src=r,ii(i,this.context.options),this._onScriptLoad(i,t),document.head.appendChild(i)}_toParagraph(){let e=this._activePre;if(!e||!this.context.layoutInfo.editable)return;let t=(e.textContent||``).split(`
|
|
44
|
+
`),n=document.createElement(`p`);t.forEach((e,t)=>{t>0&&n.appendChild(document.createElement(`br`)),n.appendChild(document.createTextNode(e))}),e.parentNode.replaceChild(n,e),this._hide(),this.context.invoke(`editor.afterCommand`)}_delete(){let e=this._activePre;e&&(this._hide(),e.remove(),this.context.invoke(`editor.afterCommand`))}},di=n({EMOJI_CATS:()=>fi,EMOJI_LIST:()=>pi}),fi,pi,mi=t((()=>{fi=[{id:`smileys`,label:`Smileys`},{id:`people`,label:`People`},{id:`animals`,label:`Animals`},{id:`food`,label:`Food`},{id:`travel`,label:`Travel`},{id:`objects`,label:`Objects`},{id:`symbols`,label:`Symbols`}],pi=[[`😀`,`grin smile happy face`,`smileys`],[`😃`,`happy smile big eyes`,`smileys`],[`😄`,`grinning smile laugh`,`smileys`],[`😁`,`beaming smile grin`,`smileys`],[`😆`,`laughing lol`,`smileys`],[`😅`,`sweat grin awkward`,`smileys`],[`🤣`,`rolling laugh rofl`,`smileys`],[`😂`,`tears laugh cry joy`,`smileys`],[`🙂`,`slight smile`,`smileys`],[`🙃`,`upside down smile`,`smileys`],[`😉`,`wink`,`smileys`],[`😊`,`blush smile happy`,`smileys`],[`😇`,`innocent halo angel`,`smileys`],[`🥰`,`hearts love adore`,`smileys`],[`😍`,`heart eyes love`,`smileys`],[`🤩`,`star eyes excited wow`,`smileys`],[`😘`,`kiss blow love`,`smileys`],[`😋`,`yum delicious tongue`,`smileys`],[`😛`,`tongue stuck out`,`smileys`],[`😜`,`wink tongue crazy`,`smileys`],[`🤪`,`zany crazy wild`,`smileys`],[`😝`,`squint tongue`,`smileys`],[`🤑`,`money mouth`,`smileys`],[`🤗`,`hugging hug`,`smileys`],[`🤔`,`thinking hmm`,`smileys`],[`🤨`,`raised eyebrow`,`smileys`],[`😐`,`neutral face`,`smileys`],[`😶`,`no mouth`,`smileys`],[`😏`,`smirk`,`smileys`],[`😒`,`unamused`,`smileys`],[`🙄`,`roll eyes`,`smileys`],[`😬`,`grimace`,`smileys`],[`😔`,`pensive sad`,`smileys`],[`😪`,`sleepy tired`,`smileys`],[`😴`,`sleeping zzz`,`smileys`],[`🤤`,`drool`,`smileys`],[`😷`,`mask sick`,`smileys`],[`🤒`,`sick thermometer`,`smileys`],[`🤕`,`hurt bandage`,`smileys`],[`🤢`,`nausea sick`,`smileys`],[`🤮`,`vomit sick`,`smileys`],[`🤧`,`sneeze cold`,`smileys`],[`🥵`,`hot sweat`,`smileys`],[`🥶`,`cold freeze`,`smileys`],[`😵`,`dizzy dead`,`smileys`],[`🤯`,`mind blown`,`smileys`],[`🤠`,`cowboy hat`,`smileys`],[`🥳`,`party celebrate`,`smileys`],[`😎`,`cool sunglasses`,`smileys`],[`🤓`,`nerd glasses`,`smileys`],[`🧐`,`monocle curious`,`smileys`],[`😕`,`confused`,`smileys`],[`😟`,`worried`,`smileys`],[`🙁`,`frown sad`,`smileys`],[`☹️`,`sad frown`,`smileys`],[`😮`,`surprised open mouth`,`smileys`],[`😲`,`astonished`,`smileys`],[`🥺`,`pleading begging puppy eyes`,`smileys`],[`😢`,`cry sad tear`,`smileys`],[`😭`,`sob cry loudly`,`smileys`],[`😱`,`scream horror fear`,`smileys`],[`😡`,`angry red pouting`,`smileys`],[`😠`,`angry mad`,`smileys`],[`🤬`,`cursing swear`,`smileys`],[`😈`,`devil evil smile`,`smileys`],[`👿`,`devil angry evil`,`smileys`],[`💀`,`skull death`,`smileys`],[`☠️`,`skull crossbones`,`smileys`],[`💩`,`poop`,`smileys`],[`🤡`,`clown`,`smileys`],[`👻`,`ghost boo`,`smileys`],[`👽`,`alien ufo`,`smileys`],[`🤖`,`robot`,`smileys`],[`👋`,`wave hello hi hand`,`people`],[`🤚`,`raised back hand`,`people`],[`✋`,`raised hand stop`,`people`],[`🖖`,`vulcan salute spock`,`people`],[`👌`,`ok perfect fine`,`people`],[`✌️`,`peace victory fingers`,`people`],[`🤞`,`fingers crossed luck`,`people`],[`🤟`,`love you gesture`,`people`],[`🤘`,`sign of horns rock`,`people`],[`🤙`,`call me hand`,`people`],[`👈`,`point left`,`people`],[`👉`,`point right`,`people`],[`👆`,`point up`,`people`],[`👇`,`point down`,`people`],[`☝️`,`index pointing up`,`people`],[`👍`,`thumbs up like good`,`people`],[`👎`,`thumbs down dislike bad`,`people`],[`✊`,`raised fist punch`,`people`],[`👊`,`oncoming fist punch`,`people`],[`👏`,`clap applause`,`people`],[`🙌`,`celebrate raise hands`,`people`],[`🤝`,`handshake deal`,`people`],[`🙏`,`pray hope please thanks`,`people`],[`💅`,`nail polish`,`people`],[`💪`,`flexed bicep strong muscle`,`people`],[`👀`,`eyes look see`,`people`],[`👁️`,`eye`,`people`],[`👅`,`tongue`,`people`],[`👶`,`baby`,`people`],[`🧒`,`child`,`people`],[`👦`,`boy`,`people`],[`👧`,`girl`,`people`],[`🧑`,`person adult`,`people`],[`👨`,`man`,`people`],[`👩`,`woman`,`people`],[`🧔`,`beard man`,`people`],[`🧓`,`older person`,`people`],[`👴`,`old man`,`people`],[`👵`,`old woman`,`people`],[`❤️`,`heart love red`,`people`],[`🧡`,`orange heart love`,`people`],[`💛`,`yellow heart love`,`people`],[`💚`,`green heart love`,`people`],[`💙`,`blue heart love`,`people`],[`💜`,`purple heart love`,`people`],[`🖤`,`black heart`,`people`],[`🤍`,`white heart`,`people`],[`🤎`,`brown heart`,`people`],[`💔`,`broken heart`,`people`],[`❣️`,`exclamation heart`,`people`],[`💕`,`two hearts love`,`people`],[`💞`,`revolving hearts`,`people`],[`💓`,`beating heart`,`people`],[`💗`,`growing heart`,`people`],[`💖`,`sparkling heart`,`people`],[`💘`,`heart arrow`,`people`],[`💝`,`heart ribbon`,`people`],[`💬`,`speech bubble comment chat`,`people`],[`💭`,`thought bubble`,`people`],[`💯`,`100 hundred percent perfect`,`people`],[`💢`,`anger symbol mad`,`people`],[`💤`,`zzz sleep`,`people`],[`🐶`,`dog puppy`,`animals`],[`🐱`,`cat kitten`,`animals`],[`🐭`,`mouse`,`animals`],[`🐹`,`hamster`,`animals`],[`🐰`,`rabbit bunny`,`animals`],[`🦊`,`fox`,`animals`],[`🐻`,`bear`,`animals`],[`🐼`,`panda`,`animals`],[`🐨`,`koala`,`animals`],[`🐯`,`tiger`,`animals`],[`🦁`,`lion`,`animals`],[`🐮`,`cow`,`animals`],[`🐷`,`pig`,`animals`],[`🐸`,`frog`,`animals`],[`🐵`,`monkey`,`animals`],[`🙈`,`see no evil monkey`,`animals`],[`🙉`,`hear no evil monkey`,`animals`],[`🙊`,`speak no evil monkey`,`animals`],[`🐔`,`chicken hen`,`animals`],[`🐧`,`penguin`,`animals`],[`🐦`,`bird`,`animals`],[`🦆`,`duck`,`animals`],[`🦅`,`eagle`,`animals`],[`🦉`,`owl`,`animals`],[`🦇`,`bat`,`animals`],[`🐺`,`wolf`,`animals`],[`🐴`,`horse`,`animals`],[`🦄`,`unicorn`,`animals`],[`🐝`,`bee`,`animals`],[`🦋`,`butterfly`,`animals`],[`🐌`,`snail`,`animals`],[`🐞`,`ladybug`,`animals`],[`🐢`,`turtle`,`animals`],[`🐍`,`snake`,`animals`],[`🦎`,`lizard`,`animals`],[`🐊`,`crocodile`,`animals`],[`🐟`,`fish`,`animals`],[`🐠`,`tropical fish`,`animals`],[`🦈`,`shark`,`animals`],[`🐬`,`dolphin`,`animals`],[`🐳`,`whale`,`animals`],[`🐙`,`octopus`,`animals`],[`🦑`,`squid`,`animals`],[`🦀`,`crab`,`animals`],[`🌸`,`cherry blossom flower`,`animals`],[`🌺`,`hibiscus flower`,`animals`],[`🌻`,`sunflower`,`animals`],[`🌹`,`rose flower`,`animals`],[`🌷`,`tulip flower`,`animals`],[`🍀`,`four leaf clover luck`,`animals`],[`🌿`,`herb leaf green`,`animals`],[`🌱`,`seedling sprout`,`animals`],[`🌲`,`evergreen tree pine`,`animals`],[`🌳`,`deciduous tree`,`animals`],[`🌴`,`palm tree`,`animals`],[`🍄`,`mushroom`,`animals`],[`🌾`,`sheaf wheat`,`animals`],[`🐾`,`paw prints animal`,`animals`],[`🍎`,`apple red`,`food`],[`🍊`,`orange tangerine`,`food`],[`🍋`,`lemon yellow`,`food`],[`🍇`,`grapes`,`food`],[`🍓`,`strawberry`,`food`],[`🫐`,`blueberry`,`food`],[`🍒`,`cherry`,`food`],[`🍑`,`peach`,`food`],[`🥭`,`mango`,`food`],[`🍍`,`pineapple`,`food`],[`🥥`,`coconut`,`food`],[`🥝`,`kiwi`,`food`],[`🍅`,`tomato`,`food`],[`🥑`,`avocado`,`food`],[`🍆`,`eggplant aubergine`,`food`],[`🥕`,`carrot`,`food`],[`🌽`,`corn`,`food`],[`🥦`,`broccoli`,`food`],[`🥬`,`leafy green`,`food`],[`🧄`,`garlic`,`food`],[`🥜`,`peanut nut`,`food`],[`🍞`,`bread loaf`,`food`],[`🥐`,`croissant`,`food`],[`🧀`,`cheese`,`food`],[`🍳`,`egg fry cooking`,`food`],[`🥚`,`egg`,`food`],[`🥞`,`pancake`,`food`],[`🧇`,`waffle`,`food`],[`🥓`,`bacon`,`food`],[`🥩`,`meat steak`,`food`],[`🍗`,`chicken leg`,`food`],[`🌭`,`hotdog`,`food`],[`🍔`,`burger hamburger`,`food`],[`🍟`,`fries french`,`food`],[`🍕`,`pizza`,`food`],[`🌮`,`taco`,`food`],[`🌯`,`burrito wrap`,`food`],[`🍜`,`noodles ramen`,`food`],[`🍝`,`spaghetti pasta`,`food`],[`🍣`,`sushi`,`food`],[`🍱`,`bento box`,`food`],[`🍦`,`ice cream soft serve`,`food`],[`🍩`,`donut`,`food`],[`🍪`,`cookie`,`food`],[`🎂`,`birthday cake`,`food`],[`🍰`,`cake slice`,`food`],[`🧁`,`cupcake`,`food`],[`🍫`,`chocolate`,`food`],[`🍬`,`candy`,`food`],[`🍭`,`lollipop`,`food`],[`☕`,`coffee hot`,`food`],[`🍵`,`tea hot`,`food`],[`🧋`,`bubble tea boba`,`food`],[`🥤`,`cup straw drink`,`food`],[`🍷`,`wine red`,`food`],[`🍸`,`cocktail martini`,`food`],[`🍺`,`beer mug`,`food`],[`🍻`,`clinking beer mugs`,`food`],[`🥂`,`champagne toast celebrate`,`food`],[`🧃`,`juice box`,`food`],[`🧊`,`ice cube`,`food`],[`🚀`,`rocket space`,`travel`],[`🛸`,`ufo flying saucer`,`travel`],[`✈️`,`airplane plane fly`,`travel`],[`🚁`,`helicopter`,`travel`],[`🚂`,`train locomotive`,`travel`],[`🚄`,`bullet train fast`,`travel`],[`🚇`,`subway metro`,`travel`],[`🚌`,`bus`,`travel`],[`🚑`,`ambulance`,`travel`],[`🚒`,`fire truck`,`travel`],[`🚓`,`police car`,`travel`],[`🚕`,`taxi cab`,`travel`],[`🚗`,`car automobile red`,`travel`],[`🚙`,`suv car`,`travel`],[`🚚`,`truck delivery`,`travel`],[`🚜`,`tractor farm`,`travel`],[`🏎️`,`racing car fast`,`travel`],[`🏍️`,`motorcycle`,`travel`],[`🚲`,`bicycle bike`,`travel`],[`🛴`,`scooter kick`,`travel`],[`⛵`,`sailboat boat`,`travel`],[`🚢`,`ship cruise`,`travel`],[`🏠`,`house home`,`travel`],[`🏢`,`office building`,`travel`],[`🏥`,`hospital`,`travel`],[`🏦`,`bank`,`travel`],[`🏪`,`store shop convenience`,`travel`],[`🏫`,`school`,`travel`],[`🏰`,`castle european`,`travel`],[`🏯`,`japanese castle`,`travel`],[`🗼`,`tokyo tower`,`travel`],[`🗽`,`statue liberty new york`,`travel`],[`⛪`,`church`,`travel`],[`🕌`,`mosque`,`travel`],[`⛩️`,`shinto shrine`,`travel`],[`⛲`,`fountain`,`travel`],[`⛺`,`tent camping`,`travel`],[`🌁`,`fog foggy bridge`,`travel`],[`🌃`,`night city stars`,`travel`],[`🏙️`,`cityscape city buildings`,`travel`],[`🌅`,`sunrise morning`,`travel`],[`🌈`,`rainbow colorful`,`travel`],[`⛰️`,`mountain`,`travel`],[`🏔️`,`snow mountain`,`travel`],[`🗻`,`mount fuji`,`travel`],[`🏕️`,`camping tent`,`travel`],[`🗺️`,`world map`,`travel`],[`🧭`,`compass navigation`,`travel`],[`🌍`,`earth europe africa globe`,`travel`],[`🌎`,`earth americas globe`,`travel`],[`🌏`,`earth asia globe`,`travel`],[`🌐`,`globe internet web`,`travel`],[`💎`,`diamond gem jewel`,`objects`],[`💍`,`ring engagement`,`objects`],[`👑`,`crown royal king queen`,`objects`],[`🎩`,`top hat magic`,`objects`],[`💼`,`briefcase work business`,`objects`],[`👜`,`handbag purse`,`objects`],[`🎒`,`backpack bag school`,`objects`],[`👓`,`glasses eyewear`,`objects`],[`🕶️`,`sunglasses cool`,`objects`],[`💡`,`light bulb idea`,`objects`],[`🔦`,`flashlight torch`,`objects`],[`🕯️`,`candle light`,`objects`],[`🔋`,`battery charge`,`objects`],[`💻`,`laptop computer`,`objects`],[`🖥️`,`desktop monitor computer`,`objects`],[`📱`,`phone mobile cell`,`objects`],[`⌨️`,`keyboard type`,`objects`],[`🖱️`,`mouse computer click`,`objects`],[`📺`,`television tv`,`objects`],[`📷`,`camera photo`,`objects`],[`📹`,`video camera`,`objects`],[`🎥`,`movie camera film`,`objects`],[`☎️`,`telephone phone`,`objects`],[`⏰`,`alarm clock wake`,`objects`],[`⌚`,`watch time`,`objects`],[`🔑`,`key`,`objects`],[`🗝️`,`old key`,`objects`],[`🔒`,`lock closed`,`objects`],[`🔓`,`unlock open`,`objects`],[`🔨`,`hammer tool`,`objects`],[`🔧`,`wrench tool`,`objects`],[`🔩`,`bolt nut`,`objects`],[`⚙️`,`gear setting`,`objects`],[`🧲`,`magnet attract`,`objects`],[`📚`,`books stack library`,`objects`],[`📖`,`book open read`,`objects`],[`📝`,`memo write note`,`objects`],[`✏️`,`pencil write edit`,`objects`],[`📌`,`pushpin tack`,`objects`],[`📎`,`paperclip attach`,`objects`],[`📊`,`bar chart graph`,`objects`],[`📈`,`chart up growth trend`,`objects`],[`📉`,`chart down loss decline`,`objects`],[`📅`,`calendar date`,`objects`],[`📦`,`package box`,`objects`],[`📫`,`mailbox closed`,`objects`],[`📧`,`email envelope`,`objects`],[`🎁`,`gift present`,`objects`],[`🎀`,`ribbon bow`,`objects`],[`🎉`,`party celebrate confetti`,`objects`],[`🎊`,`confetti celebrate`,`objects`],[`🔮`,`crystal ball magic fortune`,`objects`],[`🪄`,`magic wand`,`objects`],[`🎯`,`target bullseye dart`,`objects`],[`🎲`,`dice game board`,`objects`],[`🎮`,`video game controller`,`objects`],[`🎭`,`theater masks drama`,`objects`],[`🎨`,`art palette paint`,`objects`],[`🎬`,`clapper film movie`,`objects`],[`🎤`,`microphone sing karaoke`,`objects`],[`🎧`,`headphones music listen`,`objects`],[`🎵`,`music note`,`objects`],[`🎶`,`music notes`,`objects`],[`🎸`,`guitar electric`,`objects`],[`🎹`,`piano keyboard music`,`objects`],[`🥁`,`drum percussion`,`objects`],[`🎷`,`saxophone jazz`,`objects`],[`🎺`,`trumpet`,`objects`],[`🎻`,`violin`,`objects`],[`⚽`,`soccer ball football`,`objects`],[`🏀`,`basketball`,`objects`],[`🏈`,`american football`,`objects`],[`⚾`,`baseball`,`objects`],[`🎾`,`tennis`,`objects`],[`🏐`,`volleyball`,`objects`],[`🏆`,`trophy winner award`,`objects`],[`🥇`,`gold medal first`,`objects`],[`🏅`,`sports medal`,`objects`],[`✅`,`check green done success`,`symbols`],[`❌`,`cross x no cancel`,`symbols`],[`⭕`,`circle red`,`symbols`],[`⛔`,`no entry stop`,`symbols`],[`🚫`,`prohibited no banned`,`symbols`],[`⚠️`,`warning caution danger`,`symbols`],[`❗`,`exclamation red important`,`symbols`],[`❓`,`question mark`,`symbols`],[`‼️`,`double exclamation`,`symbols`],[`💯`,`100 hundred percent perfect`,`symbols`],[`🔴`,`red circle dot`,`symbols`],[`🟠`,`orange circle`,`symbols`],[`🟡`,`yellow circle`,`symbols`],[`🟢`,`green circle`,`symbols`],[`🔵`,`blue circle`,`symbols`],[`🟣`,`purple circle`,`symbols`],[`⚫`,`black circle`,`symbols`],[`⚪`,`white circle`,`symbols`],[`🟤`,`brown circle`,`symbols`],[`🔺`,`red triangle up`,`symbols`],[`🔻`,`red triangle down`,`symbols`],[`🔷`,`blue diamond large`,`symbols`],[`🔶`,`orange diamond large`,`symbols`],[`🔹`,`blue diamond small`,`symbols`],[`🔸`,`orange diamond small`,`symbols`],[`⭐`,`star yellow`,`symbols`],[`🌟`,`glowing star shine`,`symbols`],[`✨`,`sparkles shine`,`symbols`],[`💫`,`dizzy star spin`,`symbols`],[`⚡`,`lightning bolt energy power`,`symbols`],[`🔥`,`fire hot flame`,`symbols`],[`💥`,`explosion boom`,`symbols`],[`❄️`,`snowflake cold ice winter`,`symbols`],[`🌊`,`wave water ocean sea`,`symbols`],[`💨`,`wind blow dash`,`symbols`],[`🌀`,`cyclone tornado spiral`,`symbols`],[`♻️`,`recycle loop green`,`symbols`],[`✔️`,`check tick done`,`symbols`],[`➕`,`plus add`,`symbols`],[`➖`,`minus subtract`,`symbols`],[`➗`,`divide division`,`symbols`],[`✖️`,`multiply times cross`,`symbols`],[`▶️`,`play button right`,`symbols`],[`⏸️`,`pause`,`symbols`],[`⏹️`,`stop square`,`symbols`],[`⏩`,`fast forward`,`symbols`],[`⏪`,`rewind fast backward`,`symbols`],[`🔔`,`bell notification`,`symbols`],[`🔕`,`bell slash mute`,`symbols`],[`🔊`,`speaker volume high`,`symbols`],[`🔇`,`mute silent no sound`,`symbols`],[`📢`,`loudspeaker announcement`,`symbols`],[`📣`,`megaphone cheer`,`symbols`],[`🏳️`,`white flag`,`symbols`],[`🏴`,`black flag`,`symbols`],[`🚩`,`red flag`,`symbols`],[`🏁`,`checkered flag finish race`,`symbols`],[`🆕`,`new badge`,`symbols`],[`🆓`,`free badge`,`symbols`],[`🆒`,`cool badge`,`symbols`],[`🔝`,`top arrow`,`symbols`],[`🔙`,`back arrow`,`symbols`],[`ℹ️`,`information info`,`symbols`],[`📍`,`pin location map`,`symbols`],[`🔗`,`link chain`,`symbols`],[`©️`,`copyright`,`symbols`],[`®️`,`registered trademark`,`symbols`],[`™️`,`trademark`,`symbols`],[`#️⃣`,`hash number`,`symbols`],[`0️⃣`,`zero number`,`symbols`],[`1️⃣`,`one number`,`symbols`],[`2️⃣`,`two number`,`symbols`],[`3️⃣`,`three number`,`symbols`],[`4️⃣`,`four number`,`symbols`],[`5️⃣`,`five number`,`symbols`]]})),hi=null,gi=null;function _i(){return hi?Promise.resolve(hi):(gi??=Promise.resolve().then(()=>(mi(),di)).then(e=>(hi={EMOJI_CATS:e.EMOJI_CATS,EMOJI_LIST:e.EMOJI_LIST},hi)),gi)}var vi=class extends W{_activeCat=`all`;initialize(){return this}async show(){if(this._saveRange(),!this._dialog){let{EMOJI_CATS:e,EMOJI_LIST:t}=await _i();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),document.body.appendChild(this._dialog))}this._activeCat=`all`,this._searchInput.value=``,this._updateCatTabs(),this._filterEmojis(``,`all`),this._open()}_buildDialog(){let e=this.context.locale.emojiDialog,t=m(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=m(`div`,{class:`an-dialog-box an-emoji-box`}),r=m(`div`,{class:`an-icon-title-row`}),i=m(`div`,{class:`an-dialog-title-group`}),a=m(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 13s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`;let o=m(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=m(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`×`,r.append(i,s);let c=m(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c;let l=m(`div`,{class:`an-icon-cats`}),u=m(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=m(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=m(`div`,{class:`an-emoji-grid`});this._list.forEach(([e,t,n])=>{let r=m(`button`,{type:`button`,class:`an-emoji-cell`,"data-char":e,"data-keywords":t,"data-cat":n,title:t.split(` `).slice(0,2).join(` `)});r.textContent=e,d.appendChild(r)}),this._grid=d,this._firstInput=c;let f=m(`div`,{class:`an-dialog-actions`}),p=m(`button`,{type:`button`,class:`an-btn`});p.textContent=e.cancelBtn,f.appendChild(p),n.append(r,c,l,d,f),t.appendChild(n),ee(r,n);let h=_(s,`click`,()=>this._close()),g=_(p,`click`,()=>this._close()),v=_(t,`click`,e=>{e.target===t&&this._close()}),y=_(c,`input`,()=>this._filterEmojis(c.value,this._activeCat)),b=_(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterEmojis(this._searchInput.value,this._activeCat))}),x=_(d,`click`,e=>{let t=e.target?.closest(`.an-emoji-cell`);t&&this._onEmojiClick(t.dataset.char)});return this._disposers.push(h,g,v,y,b,x),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterEmojis(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-emoji-cell`).forEach(e=>{let i=e,a=!t||t===`all`||i.dataset.cat===t,o=!n||i.dataset.keywords.includes(n)||i.dataset.char===n,s=a&&o;i.style.display=s?``:`none`,s&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=m(`div`,{class:`an-icon-empty`}),i.textContent=`No emojis found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_onEmojiClick(e){let t=this._savedRange,n=this.context.layoutInfo.editable;t&&t.select();let r=globalThis.getSelection(),i=r?.rangeCount>0?r.getRangeAt(0):null;i||(i=document.createRange(),i.selectNodeContents(n),i.collapse(!1));let a=i.startContainer,o=(a.nodeType===1?a:a.parentElement)?.closest(`td, th`);i.deleteContents(),o?.isConnected&&!o.contains(i.startContainer)&&(i.setStart(o,0),i.collapse(!0));let s=document.createTextNode(e);i.insertNode(s),i.setStartAfter(s),i.collapse(!0),r&&(r.removeAllRanges(),r.addRange(i)),this._close(),n.focus(),this.context.invoke(`editor.afterCommand`)}},yi=n({ICON_CATEGORIES:()=>bi,ICON_LIST:()=>xi}),bi,xi,Si=t((()=>{bi=[{id:`popular`,label:`Popular`},{id:`interface`,label:`Interface`},{id:`navigation`,label:`Navigation`},{id:`media`,label:`Media`},{id:`communication`,label:`Communication`},{id:`files`,label:`Files`},{id:`people`,label:`People`},{id:`objects`,label:`Objects`}],xi=[[`house`,`popular`],[`star`,`popular`],[`heart`,`popular`],[`check`,`popular`],[`xmark`,`popular`],[`plus`,`popular`],[`minus`,`popular`],[`magnifying-glass`,`popular`],[`gear`,`popular`],[`bell`,`popular`],[`user`,`popular`],[`envelope`,`popular`],[`phone`,`popular`],[`calendar`,`popular`],[`clock`,`popular`],[`lock`,`popular`],[`eye`,`popular`],[`eye-slash`,`popular`],[`trash`,`popular`],[`pen`,`popular`],[`bookmark`,`popular`],[`flag`,`popular`],[`thumbs-up`,`popular`],[`thumbs-down`,`popular`],[`circle-info`,`popular`],[`triangle-exclamation`,`popular`],[`circle-check`,`popular`],[`circle-xmark`,`popular`],[`share`,`popular`],[`download`,`popular`],[`upload`,`popular`],[`tag`,`popular`],[`bars`,`interface`],[`ellipsis`,`interface`],[`ellipsis-vertical`,`interface`],[`list`,`interface`],[`table-cells`,`interface`],[`table-list`,`interface`],[`grip`,`interface`],[`filter`,`interface`],[`sort`,`interface`],[`arrows-rotate`,`interface`],[`rotate`,`interface`],[`rotate-left`,`interface`],[`rotate-right`,`interface`],[`copy`,`interface`],[`floppy-disk`,`interface`],[`print`,`interface`],[`link`,`interface`],[`code`,`interface`],[`expand`,`interface`],[`compress`,`interface`],[`cloud`,`interface`],[`lock-open`,`interface`],[`key`,`interface`],[`shield`,`interface`],[`shield-halved`,`interface`],[`sliders`,`interface`],[`toggle-on`,`interface`],[`square-check`,`interface`],[`circle-plus`,`interface`],[`circle-minus`,`interface`],[`arrow-right`,`navigation`],[`arrow-left`,`navigation`],[`arrow-up`,`navigation`],[`arrow-down`,`navigation`],[`chevron-right`,`navigation`],[`chevron-left`,`navigation`],[`chevron-up`,`navigation`],[`chevron-down`,`navigation`],[`angle-right`,`navigation`],[`angle-left`,`navigation`],[`angle-up`,`navigation`],[`angle-down`,`navigation`],[`angles-right`,`navigation`],[`angles-left`,`navigation`],[`location-dot`,`navigation`],[`compass`,`navigation`],[`map`,`navigation`],[`map-pin`,`navigation`],[`route`,`navigation`],[`circle-arrow-right`,`navigation`],[`circle-arrow-left`,`navigation`],[`arrow-trend-up`,`navigation`],[`arrow-trend-down`,`navigation`],[`right-from-bracket`,`navigation`],[`right-to-bracket`,`navigation`],[`play`,`media`],[`pause`,`media`],[`stop`,`media`],[`forward`,`media`],[`backward`,`media`],[`forward-step`,`media`],[`backward-step`,`media`],[`volume-high`,`media`],[`volume-low`,`media`],[`volume-xmark`,`media`],[`volume-off`,`media`],[`music`,`media`],[`headphones`,`media`],[`microphone`,`media`],[`microphone-slash`,`media`],[`film`,`media`],[`camera`,`media`],[`camera-rotate`,`media`],[`video`,`media`],[`image`,`media`],[`images`,`media`],[`photo-film`,`media`],[`podcast`,`media`],[`radio`,`media`],[`comment`,`communication`],[`comments`,`communication`],[`comment-dots`,`communication`],[`message`,`communication`],[`paper-plane`,`communication`],[`reply`,`communication`],[`reply-all`,`communication`],[`at`,`communication`],[`hashtag`,`communication`],[`wifi`,`communication`],[`signal`,`communication`],[`rss`,`communication`],[`share-nodes`,`communication`],[`inbox`,`communication`],[`phone-volume`,`communication`],[`mobile`,`communication`],[`mobile-screen`,`communication`],[`laptop`,`communication`],[`desktop`,`communication`],[`tower-broadcast`,`communication`],[`file`,`files`],[`file-lines`,`files`],[`folder`,`files`],[`folder-open`,`files`],[`folder-plus`,`files`],[`folder-minus`,`files`],[`file-image`,`files`],[`file-pdf`,`files`],[`file-code`,`files`],[`file-zipper`,`files`],[`file-audio`,`files`],[`file-video`,`files`],[`file-arrow-up`,`files`],[`file-arrow-down`,`files`],[`database`,`files`],[`box`,`files`],[`box-open`,`files`],[`hard-drive`,`files`],[`server`,`files`],[`user`,`people`],[`users`,`people`],[`user-group`,`people`],[`user-plus`,`people`],[`user-minus`,`people`],[`user-check`,`people`],[`user-xmark`,`people`],[`user-tie`,`people`],[`user-shield`,`people`],[`user-secret`,`people`],[`person`,`people`],[`person-running`,`people`],[`person-walking`,`people`],[`child`,`people`],[`handshake`,`people`],[`hand`,`people`],[`hands-holding`,`people`],[`people-group`,`people`],[`pencil`,`objects`],[`paintbrush`,`objects`],[`eraser`,`objects`],[`scissors`,`objects`],[`wrench`,`objects`],[`screwdriver`,`objects`],[`hammer`,`objects`],[`toolbox`,`objects`],[`graduation-cap`,`objects`],[`book`,`objects`],[`book-open`,`objects`],[`glasses`,`objects`],[`microscope`,`objects`],[`flask`,`objects`],[`stethoscope`,`objects`],[`hospital`,`objects`],[`building`,`objects`],[`city`,`objects`],[`car`,`objects`],[`truck`,`objects`],[`plane`,`objects`],[`train`,`objects`],[`bicycle`,`objects`],[`bus`,`objects`],[`rocket`,`objects`],[`briefcase`,`objects`],[`cart-shopping`,`objects`],[`bag-shopping`,`objects`],[`credit-card`,`objects`],[`money-bill`,`objects`],[`chart-bar`,`objects`],[`chart-line`,`objects`],[`chart-pie`,`objects`],[`bolt`,`objects`],[`sun`,`objects`],[`moon`,`objects`],[`snowflake`,`objects`],[`fire`,`objects`],[`droplet`,`objects`],[`leaf`,`objects`],[`tree`,`objects`],[`earth-americas`,`objects`],[`globe`,`objects`],[`award`,`objects`],[`trophy`,`objects`],[`gift`,`objects`],[`puzzle-piece`,`objects`]]})),Ci=`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,wi=null,Ti=null;function Ei(){return wi?Promise.resolve(wi):(Ti??=Promise.resolve().then(()=>(Si(),yi)).then(e=>(wi={ICON_CATEGORIES:e.ICON_CATEGORIES,ICON_LIST:e.ICON_LIST},wi)),Ti)}var Di=class extends W{_selectedIcon=null;_activeCat=`all`;initialize(){return this}_ensureFontAwesome(){if(this.context.options.fontAwesomeAutoInject===!1)return;let e=this.context.options.fontAwesomeCDN||Ci;if(!e||document.getElementById(`an-fontawesome-css`))return;let t=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).map(e=>e.href||``).join(` `);if(/fontawesome|font-awesome/.test(t)||document.querySelector(`.fa-solid, .fas, .far, .fab`))return;let n=document.createElement(`link`);n.id=`an-fontawesome-css`,n.rel=`stylesheet`,n.href=e,ii(n,this.context.options),document.head.appendChild(n)}async show(){if(this._saveRange(),this._ensureFontAwesome(),!this._dialog){let{ICON_CATEGORIES:e,ICON_LIST:t}=await Ei();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),document.body.appendChild(this._dialog))}this._selectedIcon=null,this._activeCat=`all`,this._searchInput.value=``,this._grid.querySelectorAll(`.an-icon-cell.active`).forEach(e=>e.classList.remove(`active`)),this._insertBtn.setAttribute(`disabled`,``),this._updateCatTabs(),this._filterIcons(``,`all`),this._updatePreview(null),this._open()}_buildDialog(){let e=this.context.locale.iconDialog,t=m(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=m(`div`,{class:`an-dialog-box an-icon-box`}),r=m(`div`,{class:`an-icon-title-row`}),i=m(`div`,{class:`an-dialog-title-group`}),a=m(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>`;let o=m(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=m(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`×`,r.append(i,s);let c=m(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c,this._firstInput=c;let l=m(`div`,{class:`an-icon-cats`}),u=m(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=m(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=m(`div`,{class:`an-icon-grid`});this._list.forEach(([e,t])=>{let n=m(`button`,{type:`button`,class:`an-icon-cell`,"data-name":e,"data-cat":t,title:e}),r=m(`i`,{class:`fa-solid fa-`+e,"aria-hidden":`true`}),i=m(`span`);i.textContent=e,n.append(r,i),d.appendChild(n)}),this._grid=d;let f=m(`div`,{class:`an-icon-options`}),p=m(`label`,{class:`an-label`});p.textContent=e.style;let h=m(`select`,{class:`an-input an-icon-option-select`});[[`fa-solid`,`Solid`],[`fa-regular`,`Regular`],[`fa-light`,`Light (Pro)`]].forEach(([e,t])=>{let n=m(`option`,{value:e});n.textContent=t,h.appendChild(n)}),h.value=`fa-solid`,this._styleSelect=h;let g=m(`label`,{class:`an-label`});g.textContent=e.size;let v=m(`select`,{class:`an-input an-icon-option-select`});[[``,`Inherit`],[`0.75em`,`0.75em`],[`1em`,`1em`],[`1.25em`,`1.25em`],[`1.5em`,`1.5em`],[`2em`,`2em`],[`3em`,`3em`]].forEach(([e,t])=>{let n=m(`option`,{value:e});e===`1em`&&(n.selected=!0),n.textContent=t,v.appendChild(n)}),this._sizeSelect=v;let y=m(`label`,{class:`an-label`});y.textContent=e.color;let b=m(`input`,{type:`color`,class:`an-icon-color`,value:`#000000`});this._colorInput=b;let x=m(`label`,{class:`an-label an-label-inline an-icon-use-color`}),S=m(`input`,{type:`checkbox`,checked:``});this._useColorCb=S,x.append(S,document.createTextNode(e.useColor)),f.append(p,h,g,v,y,b,x);let C=m(`div`,{class:`an-icon-preview`}),w=m(`span`,{class:`an-icon-preview-hint`});w.textContent=e.selectHint,C.appendChild(w),this._preview=C;let T=m(`div`,{class:`an-dialog-actions`}),E=m(`button`,{type:`button`,class:`an-btn an-btn-primary`,disabled:``});E.textContent=e.insertBtn;let D=m(`button`,{type:`button`,class:`an-btn`});D.textContent=e.cancelBtn,T.append(E,D),this._insertBtn=E,n.append(r,c,l,d,f,C,T),t.appendChild(n),ee(r,n);let te=_(s,`click`,()=>this._close()),ne=_(D,`click`,()=>this._close()),re=_(E,`click`,()=>this._onInsert()),O=_(t,`click`,e=>{e.target===t&&this._close()}),ie=_(c,`input`,()=>this._filterIcons(c.value,this._activeCat)),k=_(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterIcons(this._searchInput.value,this._activeCat))}),ae=_(d,`click`,e=>{let t=e.target?.closest(`.an-icon-cell`);t&&this._selectIcon(t.dataset.name)}),oe=_(h,`change`,()=>this._updatePreview(this._selectedIcon)),se=_(v,`change`,()=>this._updatePreview(this._selectedIcon)),ce=_(b,`input`,()=>this._updatePreview(this._selectedIcon)),le=_(S,`change`,()=>this._updatePreview(this._selectedIcon));return this._disposers.push(te,ne,re,O,ie,k,ae,oe,se,ce,le),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterIcons(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-icon-cell`).forEach(e=>{let i=e,a=i.dataset.name,o=i.dataset.cat,s=!t||t===`all`||o===t,c=!n||a.includes(n),l=s&&c;i.style.display=l?``:`none`,l&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=m(`div`,{class:`an-icon-empty`}),i.textContent=`No icons found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_selectIcon(e){this._selectedIcon=e,this._grid.querySelectorAll(`.an-icon-cell`).forEach(t=>{t.classList.toggle(`active`,t.dataset.name===e)}),this._insertBtn.removeAttribute(`disabled`),this._updatePreview(e)}_updatePreview(e){if(!this._preview)return;if(!e){this._preview.innerHTML=`<span class="an-icon-preview-hint">Select an icon</span>`;return}let t=this._styleSelect?.value||`fa-solid`,n=this._sizeSelect?.value||`1em`,r=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,i=[n?`font-size:${n}`:``,r?`color:${r}`:``].filter(Boolean).join(`;`);this._preview.innerHTML=`<i class="${t} fa-${e}" aria-hidden="true"${i?` style="${i}"`:``}></i><div class="an-icon-preview-name">${t} fa-${e}</div>`}_onInsert(){if(!this._selectedIcon)return;let e=this._styleSelect?.value||`fa-solid`,t=this._sizeSelect?.value||``,n=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,r=[t?`font-size:${t}`:``,n?`color:${n}`:``].filter(Boolean),i=document.createElement(`i`);i.className=`${e} fa-${this._selectedIcon}`,i.setAttribute(`aria-hidden`,`true`),i.setAttribute(`contenteditable`,`false`),r.length&&i.setAttribute(`style`,r.join(`;`));let a=this._savedRange,o=this.context.layoutInfo.editable;a&&a.select();let s=globalThis.getSelection(),c=(s?.rangeCount??0)>0?s.getRangeAt(0):null;c||(c=document.createRange(),c.selectNodeContents(o),c.collapse(!1));let l=c.startContainer,u=(l.nodeType===1?l:l.parentElement)?.closest(`td, th`);c.deleteContents(),u?.isConnected&&!u.contains(c.startContainer)&&(c.setStart(u,0),c.collapse(!0)),c.insertNode(i);let d=i.nextSibling;d?.nodeType===Node.TEXT_NODE?d.textContent||(d.textContent=``):(d=document.createTextNode(``),i.parentNode.insertBefore(d,i.nextSibling));let f=+!!(d.textContent||``).startsWith(``),p=document.createRange();p.setStart(d,Math.min(f,d.textContent.length)),p.collapse(!0),s&&(s.removeAllRanges(),s.addRange(p)),this._close(),o.focus(),s&&(s.removeAllRanges(),s.addRange(p)),this.context.invoke(`editor.afterCommand`)}_close(){this._selectedIcon=null,super._close()}},Oi=[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}],ki=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M6 11h.01M10 11h.01M14 11h.01M18 11h.01M6 15h.01M18 15h.01M10 15h4"/><path d="M7 3l5 4 5-4"/></svg>`,Ai=class extends W{show(){this._open()}_buildDialog(){let e=this.context.locale.shortcutsDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,ki,e.title);n.classList.add(`an-shortcuts-box`);let r=m(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close,style:`margin-left:auto`});r.textContent=`×`,this._closeBtn=r,this._firstInput=r,n.querySelector(`.an-dialog-header`).appendChild(r),(this.context.locale.shortcutsDialog.shortcuts||Oi).forEach(({category:e,items:t})=>{let r=m(`div`,{class:`an-shortcuts-cat`});r.textContent=e,n.appendChild(r);let i=m(`div`,{class:`an-shortcuts-table`});t.forEach(({keys:e,action:t})=>{let n=m(`div`,{class:`an-shortcuts-row`}),r=m(`span`,{class:`an-shortcuts-key`});r.textContent=e;let a=m(`span`,{class:`an-shortcuts-action`});a.textContent=t,n.append(r,a),i.appendChild(n)}),n.appendChild(i)});let i=_(r,`click`,()=>this._close());return this._disposers.push(i),t}},ji=class extends W{constructor(e){super(e),this._findInput=null,this._replaceInput=null,this._caseCheckbox=null,this._counterEl=null,this._closeBtn=null,this._matches=[],this._currentIndex=-1,this._caseSensitive=!1,this._useRegex=!1,this._wholeWord=!1,this._mode=`find`,this._queryRegex=null,this._lastQuery=null,this._lastCaseSensitive=null,this._lastUseRegex=null,this._lastWholeWord=null,this._focusTimer=null}destroy(){clearTimeout(this._focusTimer),this._focusTimer=null,this._clearHighlights(),super.destroy()}show(e=`find`){this._mode=e,this._updateMode(),this._open(),clearTimeout(this._focusTimer),this._focusTimer=setTimeout(()=>{this._findInput&&(this._findInput.select(),this._findInput.focus())},50)}_open(){if(this._dialog){if(this._dialog.style.display===`flex`){this._findInput&&this._findInput.focus();return}this._dialog.style.display=`flex`,this._removeTrap&&=(this._removeTrap(),null),this._removeTrap=v(this._dialog,()=>this._close())}}_close(){this._clearHighlights(),this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this.context.invoke(`editor.focus`)}_updateMode(){if(!this._dialog)return;let e=this._dialog.querySelector(`.an-fr-replace-row`),t=this._dialog.querySelector(`.an-fr-replace-actions`),n=this._dialog.querySelector(`.an-dialog-title`),r=this._mode===`replace`;e&&(e.style.display=r?``:`none`),t&&(t.style.display=r?``:`none`),n&&(n.textContent=r?this.context.locale.findReplace.findReplaceTitle:this.context.locale.findReplace.findTitle)}_buildDialog(){let e=this.context.locale.findReplace,t=m(`div`,{class:`an-dialog-overlay an-fr-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":e.findReplaceTitle}),n=m(`div`,{class:`an-dialog-box an-fr-box`}),r=m(`div`,{class:`an-fr-header`}),i=m(`div`,{class:`an-dialog-title-group`}),a=m(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>`;let o=m(`h3`,{class:`an-dialog-title`});o.textContent=e.findTitle,i.append(a,o);let s=m(`button`,{type:`button`,class:`an-icon-close`,title:e.close,"aria-label":e.close});s.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" 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>`,this._closeBtn=s,r.append(i,s),n.appendChild(r);let c=m(`div`,{class:`an-fr-search-bar`}),l=m(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.findPlaceholder,"aria-label":e.searchAriaLabel});this._findInput=l;let u=m(`input`,{type:`checkbox`,style:`display:none`,"aria-hidden":`true`});this._caseCheckbox=u;let d=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:`Case sensitive`,"aria-label":`Case sensitive`});d.textContent=`Aa`;let f=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.useRegex,"aria-label":e.useRegex});f.textContent=`.*`;let p=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.wholeWord,"aria-label":e.wholeWord});p.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="7" width="18" height="10" rx="2"/><line x1="7" y1="21" x2="7" y2="17"/><line x1="17" y1="21" x2="17" y2="17"/></svg>`;let h=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:`Previous (Shift+Enter)`,"aria-label":`Previous`});h.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" 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>`;let g=m(`button`,{type:`button`,class:`an-fr-icon-btn`,title:`Next (Enter)`,"aria-label":`Next`});g.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" 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>`;let v=m(`span`,{class:`an-fr-counter`});this._counterEl=v,c.append(l,u,d,f,p,h,g,v),n.appendChild(c);let y=m(`div`,{class:`an-fr-replace-row`});y.style.display=`none`;let b=m(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.replacePlaceholder,"aria-label":e.replaceAriaLabel});this._replaceInput=b;let x=m(`button`,{type:`button`,class:`an-btn an-fr-replace-btn`});x.textContent=e.replaceBtn;let S=m(`button`,{type:`button`,class:`an-btn an-btn-primary an-fr-replace-btn`});S.textContent=e.replaceAllBtn,y.append(b,x,S),n.appendChild(y);let C=m(`div`,{class:`an-fr-replace-actions`});C.style.display=`none`,n.appendChild(C),t.appendChild(n),ee(r,n);let w=_(s,`click`,()=>this._close()),T=_(t,`click`,e=>{e.target===t&&this._close()}),E=_(l,`input`,()=>this._onSearch()),D=_(d,`click`,()=>{this._caseSensitive=!this._caseSensitive,u.checked=this._caseSensitive,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),te=_(u,`change`,()=>{this._caseSensitive=u.checked,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),ne=_(g,`click`,()=>this._next()),re=_(h,`click`,()=>this._prev()),O=_(x,`click`,()=>this._replace()),ie=_(S,`click`,()=>this._replaceAll()),k=_(l,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),t.shiftKey?this._prev():this._next())}),ae=_(b,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._replace())}),oe=_(f,`click`,()=>{this._useRegex=!this._useRegex,f.classList.toggle(`an-fr-icon-btn--active`,this._useRegex),this._queryRegex=null,this._lastQuery=null,this._onSearch()}),se=_(p,`click`,()=>{this._wholeWord=!this._wholeWord,p.classList.toggle(`an-fr-icon-btn--active`,this._wholeWord),this._queryRegex=null,this._lastQuery=null,this._onSearch()});return this._disposers.push(w,T,E,D,te,ne,re,O,ie,k,ae,oe,se),t}_onSearch(){this._clearHighlights();let e=this._findInput?this._findInput.value:``;if(!e){this._updateCounter();return}this._findAndHighlight(e),this._updateCounter()}_findAndHighlight(e){let t=this.context.layoutInfo.editable;if(!t)return;let n=this._findRawMatches(e,t);if(n.length!==0){for(let e=n.length-1;e>=0;e--){let{node:t,start:r,end:i}=n[e];try{let e=document.createRange();e.setStart(t,r),e.setEnd(t,i);let n=document.createElement(`mark`);n.className=`an-highlight`,e.surroundContents(n),this._matches.push({mark:n})}catch{this._matches.push({mark:null})}}this._matches.reverse(),this._matches=this._matches.filter(e=>e.mark),this._currentIndex=0,this._matches.length!==0&&this._matches[0]?.mark&&(this._matches[0].mark.className=`an-highlight an-highlight-current`,this._matches[0].mark.scrollIntoView({block:`center`,behavior:`smooth`}))}}_findRawMatches(e,t){let n=[];if(this._lastQuery!==e||this._lastCaseSensitive!==this._caseSensitive||this._lastUseRegex!==this._useRegex||this._lastWholeWord!==this._wholeWord){let t=this._caseSensitive?`g`:`gi`;try{let n=this._useRegex?e:e.replace(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);this._wholeWord&&(n=`\\b${n}\\b`),this._queryRegex=new RegExp(n,t)}catch{this._queryRegex=null}this._lastQuery=e,this._lastCaseSensitive=this._caseSensitive,this._lastUseRegex=this._useRegex,this._lastWholeWord=this._wholeWord}if(!this._queryRegex)return n;let r=this._queryRegex,i=document.createTreeWalker(t,4),a=i.nextNode();for(;a&&n.length<500;){r.lastIndex=0;let e;for(;(e=r.exec(a.textContent))!==null&&n.length<500;)n.push({node:a,start:e.index,end:e.index+e[0].length});a=i.nextNode()}return n}_next(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex+1)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_prev(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex-1+this._matches.length)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_scrollToMatch(e){let t=this._matches[e];t?.mark&&(this._matches.forEach((t,n)=>{t.mark&&(t.mark.className=n===e?`an-highlight an-highlight-current`:`an-highlight`)}),t.mark.scrollIntoView({block:`center`,behavior:`smooth`}))}_replace(){if(this._matches.length===0||this._currentIndex<0)return;let e=this._matches[this._currentIndex];if(!e?.mark?.parentNode)return;let t=this._replaceInput?this._replaceInput.value:``,n=e.mark.parentNode,r=document.createTextNode(t);n.insertBefore(r,e.mark),e.mark.remove(),n.normalize(),this.context.invoke(`editor.afterCommand`);let i=this._currentIndex;this._onSearch(),this._matches.length>0&&(this._currentIndex=Math.min(i,this._matches.length-1),this._scrollToMatch(this._currentIndex),this._updateCounter())}_replaceAll(){if(this._matches.length===0)return;let e=this._replaceInput?this._replaceInput.value:``;this._matches.forEach(({mark:t})=>{if(!t?.parentNode)return;let n=document.createTextNode(e);t.parentNode.insertBefore(n,t),t.remove()}),this.context.layoutInfo.editable&&this.context.layoutInfo.editable.normalize(),this._matches=[],this._currentIndex=-1,this.context.invoke(`editor.afterCommand`),this._onSearch()}_clearHighlights(){let e=this.context.layoutInfo.editable;e&&(e.querySelectorAll(`mark.an-highlight`).forEach(e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}),e.normalize(),this._matches=[],this._currentIndex=-1)}_updateCounter(){if(!this._counterEl)return;let e=this._matches.length;if(e===0){let e=this._findInput?this._findInput.value:``;this._counterEl.textContent=e?this.context.locale.findReplace.noResults:``}else this._counterEl.textContent=`${this._currentIndex+1} / ${e}`}},X=20,Mi=`#3b82f6`,Z=(e,t,n)=>Math.min(Math.max(e,t),n);function Ni(e,t,n,r){return new Promise(i=>{let a=e=>{let a=document.createElement(`canvas`);a.width=Math.round(n),a.height=Math.round(r);let o=a.getContext(`2d`);if(!o){i(null);return}try{o.drawImage(e,t.x,t.y,t.width,t.height,0,0,a.width,a.height),o.getImageData(0,0,1,1),i(a)}catch{i(null)}};if(e.src.startsWith(`data:`)||e.src.startsWith(`blob:`)||e.src.startsWith(globalThis.location.origin)){a(e);return}let o=new Image;o.crossOrigin=`anonymous`,o.onload=()=>a(o),o.onerror=()=>i(null),o.src=e.src+(e.src.includes(`?`)?`&`:`?`)+`_an=`+Date.now()})}var Pi=class{constructor(e){this.context=e,this._img=null,this._box=null,this._imgRect=null,this._scrim=null,this._cropBox=null,this._handles={},this._toolbar=null,this._infoEl=null,this._dragDisposers=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._close(!1)}open(e){this._scrim&&this._close(!1),this._img=e;let t=e.getBoundingClientRect();this._imgRect=t;let n=Math.min(12,t.width*.1,t.height*.1);this._box={x:t.left+n,y:t.top+n,w:t.width-n*2,h:t.height-n*2},this._buildDOM(),this._updateDOM(),this._bindEsc()}_buildDOM(){let e=document.createElement(`div`);e.className=`an-crop-scrim`,e.style.cssText=`
|
|
45
45
|
position:fixed; inset:0; z-index:10100;
|
|
46
46
|
cursor:crosshair;
|
|
47
47
|
background: rgba(0,0,0,0.55);
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
`;let n=document.createElement(`div`);n.className=`an-crop-grid`,n.style.cssText=`
|
|
55
55
|
position:absolute; inset:0; pointer-events:none;
|
|
56
56
|
opacity:0.35;
|
|
57
|
-
`,[`33.33%`,`66.66%`].forEach(e=>{let t=document.createElement(`div`);t.style.cssText=`position:absolute;top:0;bottom:0;left:${e};width:1px;background:#fff;`;let r=document.createElement(`div`);r.style.cssText=`position:absolute;left:0;right:0;top:${e};height:1px;background:#fff;`,n.appendChild(t),n.appendChild(r)}),t.appendChild(n),[{id:`nw`,cur:`nw-resize`,top:`-5px`,left:`-5px`},{id:`n`,cur:`n-resize`,top:`-5px`,left:`calc(50% - 5px)`},{id:`ne`,cur:`ne-resize`,top:`-5px`,right:`-5px`},{id:`e`,cur:`e-resize`,top:`calc(50% - 5px)`,right:`-5px`},{id:`se`,cur:`se-resize`,bottom:`-5px`,right:`-5px`},{id:`s`,cur:`s-resize`,bottom:`-5px`,left:`calc(50% - 5px)`},{id:`sw`,cur:`sw-resize`,bottom:`-5px`,left:`-5px`},{id:`w`,cur:`w-resize`,top:`calc(50% - 5px)`,left:`-5px`}].forEach(({id:e,cur:n,...r})=>{let i=document.createElement(`div`);i.className=`an-crop-handle an-crop-handle-${e}`,i.style.cssText=[`position:absolute`,`width:10px`,`height:10px`,`background:${Mi}`,`border:2px solid #fff`,`border-radius:2px`,`box-sizing:border-box`,`cursor:${n}`,...Object.entries(r).map(([e,t])=>`${e}:${t}`)].join(`;`),this._disposers.push(_(i,`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),this._startHandleDrag(t,e)}),_(i,`touchstart`,t=>{t.preventDefault(),t.stopPropagation();let n=t;this._startHandleDrag({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY},e)},{passive:!1})),this._handles[e]=i,t.appendChild(i)}),this._disposers.push(_(t,`mousedown`,e=>{e.target.classList.contains(`an-crop-handle`)||e.target
|
|
57
|
+
`,[`33.33%`,`66.66%`].forEach(e=>{let t=document.createElement(`div`);t.style.cssText=`position:absolute;top:0;bottom:0;left:${e};width:1px;background:#fff;`;let r=document.createElement(`div`);r.style.cssText=`position:absolute;left:0;right:0;top:${e};height:1px;background:#fff;`,n.appendChild(t),n.appendChild(r)}),t.appendChild(n),[{id:`nw`,cur:`nw-resize`,top:`-5px`,left:`-5px`},{id:`n`,cur:`n-resize`,top:`-5px`,left:`calc(50% - 5px)`},{id:`ne`,cur:`ne-resize`,top:`-5px`,right:`-5px`},{id:`e`,cur:`e-resize`,top:`calc(50% - 5px)`,right:`-5px`},{id:`se`,cur:`se-resize`,bottom:`-5px`,right:`-5px`},{id:`s`,cur:`s-resize`,bottom:`-5px`,left:`calc(50% - 5px)`},{id:`sw`,cur:`sw-resize`,bottom:`-5px`,left:`-5px`},{id:`w`,cur:`w-resize`,top:`calc(50% - 5px)`,left:`-5px`}].forEach(({id:e,cur:n,...r})=>{let i=document.createElement(`div`);i.className=`an-crop-handle an-crop-handle-${e}`,i.style.cssText=[`position:absolute`,`width:10px`,`height:10px`,`background:${Mi}`,`border:2px solid #fff`,`border-radius:2px`,`box-sizing:border-box`,`cursor:${n}`,...Object.entries(r).map(([e,t])=>`${e}:${t}`)].join(`;`),this._disposers.push(_(i,`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),this._startHandleDrag(t,e)}),_(i,`touchstart`,t=>{t.preventDefault(),t.stopPropagation();let n=t;this._startHandleDrag({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY},e)},{passive:!1})),this._handles[e]=i,t.appendChild(i)}),this._disposers.push(_(t,`mousedown`,e=>{e.target.classList.contains(`an-crop-handle`)||(e.target===t||e.target===n)&&(e.preventDefault(),e.stopPropagation(),this._startBoxMove(e))}),_(t,`touchstart`,e=>{if(e.target.classList.contains(`an-crop-handle`)||e.target!==t&&e.target!==n)return;e.preventDefault(),e.stopPropagation();let r=e;this._startBoxMove({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY})},{passive:!1}));let r=document.createElement(`div`);r.className=`an-crop-info`,r.style.cssText=`
|
|
58
58
|
position:absolute; bottom:-28px; left:0;
|
|
59
59
|
font:bold 11px/20px system-ui,sans-serif;
|
|
60
60
|
color:#fff; white-space:nowrap;
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
color:${t}; padding:3px 10px; cursor:pointer; font-size:12px;
|
|
73
73
|
font-family:inherit;
|
|
74
74
|
transition:background 0.12s;
|
|
75
|
-
`,r.addEventListener(`mouseover`,()=>{r.style.background=t+`22`}),r.addEventListener(`mouseout`,()=>{r.style.background=`none`}),this._disposers.push(_(r,`click`,e=>{e.stopPropagation(),n()})),r}_updateDOM(){let{x:e,y:t,w:n,h:r}=this._box;this._cropBox.style.left=`${e}px`,this._cropBox.style.top=`${t}px`,this._cropBox.style.width=`${n}px`,this._cropBox.style.height=`${r}px`;let i=globalThis.innerWidth,a=globalThis.innerHeight;if(this._scrim.style.clipPath=[`polygon(`,`0 0, ${i}px 0, ${i}px ${a}px, 0 ${a}px, 0 0,`,`${e}px ${t}px, ${e}px ${t+r}px, ${e+n}px ${t+r}px, ${e+n}px ${t}px, ${e}px ${t}px`,`)`].join(``),this._img){let i=this._img.naturalWidth||0,a=this._img.naturalHeight||0,o=this._imgRect.width||1,s=this._imgRect.height||1,c={x:i/o,y:a/s},l=Z(e-this._imgRect.left,0,o),u=Z(t-this._imgRect.top,0,s),d=Z(n,0,o-l),f=Z(r,0,s-u);this._infoEl.textContent=`${Math.round(d*c.x)} × ${Math.round(f*c.y)} px`}let o=t+r+8;o+40>globalThis.innerHeight-8&&(o=t-40-8),this._toolbar.style.left=`${e}px`,this._toolbar.style.top=`${o}px`}_startBoxMove(e){let t=e.clientX-this._box.x,n=e.clientY-this._box.y,r=this._imgRect;this._attachDocDrag(e=>{this._box.x=Z(e.clientX-t,r.left,r.right-this._box.w),this._box.y=Z(e.clientY-n,r.top,r.bottom-this._box.h),this._updateDOM()})}_startHandleDrag(e,t){let n=e.clientX,r=e.clientY,i={...this._box},a=this._imgRect,o=this._arCheck?.checked,s=i.w/(i.h||1);this._attachDocDrag(e=>{let c=e.clientX-n,l=e.clientY-r,{x:u,y:d,w:f,h:p}=i;t.includes(`e`)&&(f=Math.max(X,i.w+c)),t.includes(`s`)&&(p=Math.max(X,i.h+l)),t.includes(`w`)&&(u=Math.min(i.x+i.w-X,i.x+c),f=i.x+i.w-u),t.includes(`n`)&&(d=Math.min(i.y+i.h-X,i.y+l),p=i.y+i.h-d),o&&t.length===2&&(Math.abs(c)>=Math.abs(l)?(p=f/s,t.includes(`n`)&&(d=i.y+i.h-p)):(f=p*s,t.includes(`w`)&&(u=i.x+i.w-f))),u=Z(u,a.left,a.right-X),d=Z(d,a.top,a.bottom-X),f=Z(f,X,a.right-u),p=Z(p,X,a.bottom-d),this._box={x:u,y:d,w:f,h:p},this._updateDOM()})}_attachDocDrag(e){this._dragDisposers?.();let t=t=>{t.preventDefault();let n=t;e({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY})},n=()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n),document.removeEventListener(`touchmove`,t),document.removeEventListener(`touchend`,n),document.body.style.userSelect=``,document.body.style.cursor=``,this._dragDisposers=null};this._dragDisposers=n,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n,{once:!0}),document.addEventListener(`touchmove`,t,{passive:!1}),document.addEventListener(`touchend`,n,{once:!0})}_bindEsc(){let e=e=>{e.key===`Escape`&&(e.preventDefault(),this._close(!1)),e.key===`Enter`&&(e.preventDefault(),this._confirm())};document.addEventListener(`keydown`,e),this._disposers.push(()=>document.removeEventListener(`keydown`,e))}async _confirm(){let e=this._img;if(!e){this._close(!1);return}let t=this._imgRect,{x:n,y:r,w:i,h:a}=this._box,o=(e.naturalWidth||e.width||1)/(t.width||1),s=(e.naturalHeight||e.height||1)/(t.height||1),c=Math.round(Z(n-t.left,0,t.width)*o),l=Math.round(Z(r-t.top,0,t.height)*s),u=Math.round(Z(i,0,t.width-(n-t.left))*o),d=Math.round(Z(a,0,t.height-(r-t.top))*s);if(u<=0||d<=0){this._close(!1);return}let f=await Ni(e,{x:c,y:l,width:u,height:d},i,a);if(!f){this._showCropError(`Cannot crop this image: the image server does not allow cross-origin access. Upload the image directly to use the crop tool.`),this._close(!1);return}let p=/^data:image\/(jpe?g)/i.exec(e.src)?`image/jpeg`:`image/png`,m=p===`image/jpeg`?.92:void 0,h=f.toDataURL(p,m);this._close(!1),e.src=h,e.style.width=``,e.style.height=``,e.removeAttribute(`width`),e.removeAttribute(`height`),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`)}_showCropError(e){let t=document.createElement(`div`);t.setAttribute(`role`,`alert`),t.style.cssText=[`position:fixed`,`bottom:24px`,`left:50%`,`transform:translateX(-50%)`,`z-index:10200`,`max-width:420px`,`width:max-content`,`background:#7f1d1d`,`color:#fecaca`,`border:1px solid #b91c1c`,`border-radius:8px`,`padding:12px 18px`,`font:13px/1.5 system-ui,sans-serif`,`box-shadow:0 4px 16px rgba(0,0,0,.4)`,`pointer-events:auto`].join(`;`),t.textContent=e,document.body.appendChild(t),setTimeout(()=>{t.remove()},4e3)}_close(e){this._dragDisposers?.(),this._dragDisposers=null,this._disposers.forEach(e=>e()),this._disposers=[],[this._scrim,this._cropBox,this._toolbar].forEach(e=>{e?.remove()}),this._scrim=null,this._cropBox=null,this._toolbar=null,this._infoEl=null,this._handles={},this._img=null,this._box=null,this._imgRect=null,this._arCheck=null}},Fi=class{constructor(e){this.context=e,this.options=e.options,this._banner=null}initialize(){if(!this.options.autoSave||!this.options.autoSaveRestore)return this;let e=this.options.autoSaveKey,t=e+`:asrmeta`,n,r;try{n=localStorage.getItem(e),r=JSON.parse(localStorage.getItem(t)||`{}`)}catch{return this}if(!n)return this;let i=this.options.autoSaveRestoreTimeout;if(i>0&&Date.now()-(r.savedAt||0)>i*864e5){try{localStorage.removeItem(e),localStorage.removeItem(t)}catch{}return this}return this._showBanner(n,r),this}destroy(){this._removeBanner()}_showBanner(e,t){let n=this.context.locale.autoSaveRestore||{},r=n.found||`Draft found. Restore?`,i=n.restore||`Restore`,a=n.discard||`Discard`,o=document.createElement(`div`);o.className=`an-asr-banner`,o.setAttribute(`role`,`alert`);let s=document.createElement(`span`);if(s.className=`an-asr-msg`,t.savedAt){let e=new Date(t.savedAt).toLocaleString();s.textContent=(n.foundAt||`Draft from {date}. Restore?`).replace(`{date}`,e)}else s.textContent=r;let c=document.createElement(`button`);c.type=`button`,c.className=`an-btn an-asr-btn-restore`,c.textContent=i,c.addEventListener(`click`,()=>this._restore(e));let l=document.createElement(`button`);l.type=`button`,l.className=`an-btn an-asr-btn-discard`,l.textContent=a,l.addEventListener(`click`,()=>this._discard()),o.appendChild(s),o.appendChild(c),o.appendChild(l),this._banner=o;let u=this.context.layoutInfo.container;u.insertBefore(o,u.firstChild)}_restore(e){this.context.setHTML(e),this.context.clearHistory(),this._removeBanner(),typeof this.options.onAutoSaveRestore==`function`&&this.options.onAutoSaveRestore(e,this.context)}_discard(){let e=this.options.autoSaveKey;try{localStorage.removeItem(e),localStorage.removeItem(e+`:asrmeta`)}catch{}this._removeBanner()}_removeBanner(){this._banner?.remove(),this._banner=null}},Ii=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){if(!this.options.markdownShortcuts)return this;let e=this.context.layoutInfo.editable,t=_(e,`keydown`,e=>this._onKeydown(e)),n=_(e,`input`,()=>this._onInput());return this._disposers.push(t,n),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_onKeydown(e){this._inCodeContext()||(e.key===` `?this._applyBlockRule()&&e.preventDefault():e.key===`Enter`&&this._applyEnterRule()&&e.preventDefault())}_inCodeContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;return!!(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(`pre, code`)}_getLineContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer))return null;let r=t.startContainer;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;(!r||r===n)&&(r=t.startContainer);let i=document.createRange();return i.setStart(r,0),i.setEnd(t.startContainer,t.startOffset),{text:i.toString(),range:t,lineNode:r}}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_applyBlockRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e,n=[{re:/^(#{1,6})$/,handler:e=>this._convertToHeading(e[1].length)},{re:/^>$/,handler:()=>this._convertToBlockquote()},{re:/^[-*+]$/,handler:()=>this._convertToList(`ul`)},{re:/^1[.)]$/,handler:()=>this._convertToList(`ol`)},{re:/^\[([ xX])\]$/,handler:e=>this._convertToChecklist(e[1].toLowerCase()===`x`)}];for(let{re:e,handler:r}of n){let n=e.exec(t);if(n)return r(n),!0}return!1}_applyEnterRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e;return/^(?:-{3,}|\*{3,}|_{3,})$/.test(t)?(this._convertToHr(),!0):/^(?:`{3}|~{3})/.test(t)?(this._convertToCodeBlock(),!0):!1}_selectLineAndDelete(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=document.createRange();n.setStart(t.startContainer.parentNode||t.startContainer,0),n.setEnd(t.startContainer,t.startOffset),n.deleteContents()}_convertToHeading(e){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`h${e}`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToBlockquote(){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`blockquote`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToList(e){this._selectLineAndDelete(),document.execCommand(e===`ul`?`insertUnorderedList`:`insertOrderedList`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToChecklist(e=!1){if(this._selectLineAndDelete(),this.context.invoke(`editor.toggleChecklist`),e){let e=globalThis.getSelection(),t=e?.rangeCount?e.getRangeAt(0).startContainer:null,n=(t?.nodeType===Node.ELEMENT_NODE?t:t?.parentElement??null)?.closest(`li`)?.querySelector(`input[type="checkbox"]`)??null;n&&(n.checked=!0)}this.context.triggerEvent(`change`,this.context.getHTML())}_convertToHr(){this._selectLineAndDelete(),this.context.invoke(`editor.insertHr`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToCodeBlock(){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`pre`),this.context.triggerEvent(`change`,this.context.getHTML())}_onInput(){if(this._inCodeContext())return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0);if(!t.collapsed||!this.context.layoutInfo.editable.contains(t.startContainer))return;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return;let r=n.textContent,i=t.startOffset,a=[{re:/\*\*(.+?)\*\*$/,tag:`strong`},{re:/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)$/,tag:`em`},{re:/~~(.+?)~~$/,tag:`s`},{re:/`([^`]+)`$/,tag:`code`}],o=r.slice(0,i);for(let{re:t,tag:s}of a){let a=t.exec(o);if(!a)continue;let c=o.length-a[0].length,l=i,u=a[1],d=r.slice(0,c),f=r.slice(l),p=document.createElement(s);p.textContent=u;let m=document.createTextNode(d),h=document.createTextNode(``+f);n.before(m,p,h),n.remove();let g=document.createRange();g.setStart(h,1),g.collapse(!0),e.removeAllRanges(),e.addRange(g),this.context.triggerEvent(`change`,this.context.getHTML());break}}},Li=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],Ri=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,Q=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" ${Ri} style="display:block">${e}</svg>`,zi={bold:Q(`<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"/>`),italic:Q(`<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"/>`),underline:Q(`<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"/>`),strikethrough:Q(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`),link:Q(`<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"/>`),foreColor:Q(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`),hiliteColor:Q(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/>`),removeFormat:Q(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`),inlineCode:Q(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)},Bi={bold:e=>e.invoke(`editor.bold`),italic:e=>e.invoke(`editor.italic`),underline:e=>e.invoke(`editor.underline`),strikethrough:e=>e.invoke(`editor.strikethrough`),link:e=>e.invoke(`linkDialog.show`),removeFormat:e=>{let t=e.layoutInfo?.editable;if(!t)return;t.focus(),document.execCommand(`removeFormat`);let n=globalThis.getSelection();if(n?.rangeCount>0&&!n.getRangeAt(0).collapsed){let e=n.getRangeAt(0),t=e.commonAncestorContainer,r=t.nodeType===1?t:t.parentElement;if(r){let t=[r,...r.querySelectorAll(`[style]`)];for(let n of t)n.hasAttribute(`style`)&&e.intersectsNode(n)&&n.removeAttribute(`style`)}}e.invoke(`editor.afterCommand`)},inlineCode:e=>e.invoke(`editor.inlineCode`)},Vi={bold:()=>document.queryCommandState(`bold`),italic:()=>document.queryCommandState(`italic`),underline:()=>document.queryCommandState(`underline`),strikethrough:()=>document.queryCommandState(`strikeThrough`)},Hi={foreColor:!0,hiliteColor:!0},Ui=[{name:`editor`,Class:gr},{name:`toolbar`,Class:xr},{name:`statusbar`,Class:Cr},{name:`clipboard`,Class:wr},{name:`placeholder`,Class:jr},{name:`contextMenu`,Class:Or},{name:`codeview`,Class:Mr},{name:`fullscreen`,Class:Nr},{name:`linkDialog`,Class:Fr},{name:`imageDialog`,Class:Lr},{name:`videoDialog`,Class:zr},{name:`imageResizer`,Class:Hr},{name:`videoResizer`,Class:Ur},{name:`linkTooltip`,Class:qr},{name:`imageTooltip`,Class:Yr},{name:`videoTooltip`,Class:Xr},{name:`tableTooltip`,Class:ri},{name:`codeTooltip`,Class:ui},{name:`emojiDialog`,Class:vi},{name:`iconDialog`,Class:Di},{name:`shortcutsDialog`,Class:Ai},{name:`findReplace`,Class:ji},{name:`imageCropOverlay`,Class:Pi},{name:`autoSaveRestore`,Class:Fi,enabled:e=>!!e.autoSaveRestore},{name:`markdownShortcuts`,Class:Ii,enabled:e=>e.markdownShortcuts!==!1},{name:`bubbleToolbar`,Class:class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._picker=null,this._pickerType=null,this._savedRange=null,this._visible=!1,this._rafId=null,this._contextMenuOpen=!1,this._disposers=[],this._onSelectionChange=this._onSelectionChange.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onContextMenu=this._onContextMenu.bind(this)}initialize(){if(!this.options.bubbleToolbar)return this;this._build(),this._buildColorPicker();let e=_(document,`selectionchange`,this._onSelectionChange),t=_(document,`mousedown`,this._onMousedown),n=_(document,`keydown`,this._onKeydown),r=_(document,`contextmenu`,this._onContextMenu),i=this.context.on(`contextMenu:show`,()=>{this._contextMenuOpen=!0,this._hide()}),a=this.context.on(`contextMenu:hide`,()=>{this._contextMenuOpen=!1}),o=_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),s=_(globalThis,`resize`,()=>this._hide(),{passive:!0});return this._disposers.push(e,t,n,r,i,a,o,s),this}destroy(){this._el?.remove(),this._el=null,this._picker?.remove(),this._picker=null,this._disposers.forEach(e=>e()),this._disposers=[],cancelAnimationFrame(this._rafId)}_build(){let e=document.createElement(`div`);e.className=`an-bubble-toolbar`,e.setAttribute(`role`,`toolbar`),e.setAttribute(`aria-label`,`Formatting`);let t=this.options.bubbleToolbarItems||[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`];for(let n of t){if(!zi[n])continue;let t=document.createElement(`button`);if(t.type=`button`,t.dataset.name=n,t.setAttribute(`aria-label`,n),Hi[n]){t.className=`an-bubble-btn an-bubble-btn--color`;let e=document.createElement(`span`);e.className=`an-bubble-btn-svg`,e.innerHTML=zi[n];let r=document.createElement(`span`);r.className=`an-bubble-color-strip`,r.style.background=n===`foreColor`?`#000000`:`transparent`,t.appendChild(e),t.appendChild(r)}else t.className=`an-bubble-btn`,t.innerHTML=zi[n];t.addEventListener(`mousedown`,e=>{e.preventDefault()}),t.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),Hi[n]){this._openColorPicker(n,t);return}this.context.invoke(`editor.focus`),Bi[n]&&Bi[n](this.context),this._syncActive()}),e.appendChild(t)}document.body.appendChild(e),this._el=e,this._btnCache=Array.from(e.querySelectorAll(`.an-bubble-btn`))}_buildColorPicker(){let e=document.createElement(`div`);e.className=`an-bubble-color-picker`,e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault());let t=document.createElement(`div`);t.className=`an-context-color-palette`,Li.forEach(e=>{let n=document.createElement(`div`);n.className=`an-context-color-swatch`,n.title=e,n.style.background=e,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,e),n.addEventListener(`click`,t=>{t.stopPropagation(),this._applyColor(this._pickerType,e)}),t.appendChild(n)});let n=document.createElement(`div`);n.className=`an-context-color-swatch an-context-color-none`,n.title=`No highlight`,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,`No highlight`),n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,n.addEventListener(`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});let r=document.createElement(`div`);r.className=`an-context-color-custom`;let i=document.createElement(`input`);i.type=`color`,i.value=`#000000`,i.title=`Custom color`,i.addEventListener(`mousedown`,e=>e.stopPropagation()),i.addEventListener(`change`,()=>{this._applyColor(this._pickerType,i.value)});let a=document.createElement(`span`);a.textContent=`Custom…`,r.appendChild(i),r.appendChild(a),e.appendChild(t),e.appendChild(r),document.body.appendChild(e),this._picker=e;let o=e;o._paletteEl=t,o._noColorBtn=n,o._colorInput=i}_openColorPicker(e,t){let n=globalThis.getSelection();n?.rangeCount>0&&(this._savedRange=n.getRangeAt(0).cloneRange()),this._pickerType=e;let r=this._picker,i=r._paletteEl,a=r._noColorBtn;e===`hiliteColor`?i.contains(a)||i.appendChild(a):i.contains(a)&&a.remove(),this._picker._colorInput.value=e===`foreColor`?`#000000`:`#ffff00`,this._picker.style.display=`block`;let o=this._picker.offsetWidth,s=this._picker.offsetHeight,c=this._el.getBoundingClientRect(),l=c.top-s-6;l<8&&(l=c.bottom+6);let u=t.getBoundingClientRect().left;u=Math.max(8,Math.min(u,globalThis.innerWidth-o-8)),this._picker.style.left=`${u}px`,this._picker.style.top=`${l}px`}_closeColorPicker(){this._picker&&(this._picker.style.display=`none`),this._pickerType=null}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges();try{r.addRange(this._savedRange.cloneRange())}catch{return}let i=e===`hiliteColor`?`hiliteColor`:e;!document.execCommand(i,!1,t)&&i===`hiliteColor`&&document.execCommand(`backColor`,!1,t),this.context.invoke(`editor.afterCommand`);let a=e===`hiliteColor`?`hiliteColor`:`foreColor`,o=(this._el?.querySelector(`[data-name="${a}"]`))?.querySelector(`.an-bubble-color-strip`);o&&(o.style.background=t===`transparent`?`transparent`:t),this._closeColorPicker(),this._syncActive()}_show(e){if(!this._el)return;let t=this._el;t.style.visibility=`hidden`,t.style.display=`flex`;let n=t.offsetWidth,r=t.offsetHeight,i=e.left+e.width/2-n/2,a=e.top-r-8;i=Math.max(8,Math.min(i,globalThis.innerWidth-n-8)),a<8&&(a=e.bottom+8);let o=document.querySelector(`.an-table-tooltip`);if(o&&o.style.display!==`none`){let t=o.getBoundingClientRect();a<t.bottom+8&&a+r>t.top-8&&(a=e.bottom+8,a+r>globalThis.innerHeight-8&&(a=t.bottom+8))}t.style.top=`${a}px`,t.style.left=`${i}px`,t.style.visibility=``,this._syncActive(),this._syncColorStrips(),this._visible=!0}_hide(){this._el&&(this._el.style.display=`none`,this._visible=!1,this._closeColorPicker())}_syncActive(){this._btnCache&&this._btnCache.forEach(e=>{let t=Vi[e.dataset.name];e.classList.toggle(`an-active`,!!t?.())})}_syncColorStrips(){if(!this._el)return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),!t)return;let n=globalThis.getComputedStyle(t),r=this._el.querySelector(`[data-name="foreColor"]`)?.querySelector(`.an-bubble-color-strip`);r&&(r.style.background=n.color||`#000000`);let i=this._el.querySelector(`[data-name="hiliteColor"]`)?.querySelector(`.an-bubble-color-strip`);if(i){let e=n.backgroundColor;i.style.background=!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`?`transparent`:e}}_onSelectionChange(){cancelAnimationFrame(this._rafId),this._rafId=requestAnimationFrame(()=>{if(this._contextMenuOpen||this._picker&&this._picker.style.display!==`none`)return;let e=globalThis.getSelection();if(!e||e.isCollapsed||!e.rangeCount){this._hide();return}if(!this.context.layoutInfo.editable.contains(e.anchorNode)){this._hide();return}if(this.context.options.readOnly){this._hide();return}let t=e.getRangeAt(0).getBoundingClientRect();if(!t||t.width===0){this._hide();return}this._show(t)})}_onMousedown(e){this._visible&&(this._el?.contains(e.target)||this._picker?.contains(e.target)||this.context.layoutInfo.editable.contains(e.target)||this._hide())}_onKeydown(e){e.key===`Escape`&&(this._picker&&this._picker.style.display!==`none`?this._closeColorPicker():this._visible&&this._hide())}_onContextMenu(){this._hide()}},enabled:e=>!!e.bubbleToolbar},{name:`mention`,Class:class{constructor(e){this.context=e,this._dropdown=null,this._query=``,this._debounceTimer=null,this._activeIndex=-1,this._items=[],this._open=!1,this._triggerNode=null,this._triggerOffset=0,this._caretRect=null,this._disposers=[]}initialize(){let e=this.context.options.mention;if(!e||typeof e.onSearch!=`function`)return this;this._cfg={trigger:e.trigger||`@`,minChars:e.minChars??0,maxResults:e.maxResults??8,debounce:e.debounce??200,onSearch:e.onSearch,onInsert:e.onInsert||null,onError:e.onError||null,mentionClass:e.mentionClass||`an-mention`,allowSpaces:e.allowSpaces||!1},this._buildDropdown();let t=this.context.layoutInfo.editable,n=_(t,`keydown`,e=>this._onKeydown(e)),r=_(t,`input`,()=>this._onInput()),i=_(document,`click`,e=>this._onDocClick(e));return this._disposers.push(n,r,i),this}destroy(){clearTimeout(this._debounceTimer),this._dropdown?.remove(),this._dropdown=null,this._disposers.forEach(e=>e()),this._disposers=[]}_buildDropdown(){let e=document.createElement(`div`);e.className=`an-mention-dropdown`,e.setAttribute(`role`,`listbox`),e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._highlightItem(+t.dataset.index)}),document.body.appendChild(e),this._dropdown=e}_renderItems(e){let t=this._dropdown;this._items=e.slice(0,this._cfg.maxResults),this._activeIndex=this._items.length>0?0:-1;let n=document.createDocumentFragment();this._items.forEach((e,t)=>{let r=document.createElement(`div`);if(r.className=`an-mention-item`,r.setAttribute(`role`,`option`),r.dataset.index=String(t),e.avatar){let t=document.createElement(`img`);t.src=e.avatar,t.className=`an-mention-avatar`,t.alt=``,r.appendChild(t)}let i=document.createElement(`span`);i.textContent=e.label,r.appendChild(i),n.appendChild(r)}),t.innerHTML=``,t.appendChild(n),this._highlightItem(this._activeIndex)}_highlightItem(e){this._dropdown&&(this._dropdown.querySelectorAll(`.an-mention-item`).forEach((t,n)=>{t.classList.toggle(`an-mention-active`,n===e)}),this._activeIndex=e)}_positionDropdown(){let e=this._dropdown,t=this._caretRect;if(!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_showDropdown(){this._open=!0,this._positionDropdown()}_hideDropdown(){this._dropdown&&(this._dropdown.style.display=`none`),this._open=!1,this._items=[],this._activeIndex=-1,this._triggerNode=null,this._caretRect=null,this._query=``}_captureCaretRect(){if(this._triggerNode?.isConnected)try{let e=document.createRange(),t=Math.min(this._triggerOffset+1,this._triggerNode.textContent.length);e.setStart(this._triggerNode,this._triggerOffset),e.setEnd(this._triggerNode,t);let n=e.getBoundingClientRect();if(n.height>0){this._caretRect=n;return}}catch{}let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).getClientRects();t.length>0&&(this._caretRect=t[t.length-1])}_getQueryAtCursor(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return null;let r=n.textContent.slice(0,t.startOffset),i=this._cfg.trigger,a=r.lastIndexOf(i);if(a===-1)return null;let o=r.slice(a+i.length);return!this._cfg.allowSpaces&&/\s/.test(o)||o.length<this._cfg.minChars?null:(this._triggerNode=n,this._triggerOffset=a,o)}_onInput(){if(!this._cfg)return;let e=this._getQueryAtCursor();if(e===null){this._hideDropdown();return}this._captureCaretRect(),this._query=e,clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{let e=e=>{if(!Array.isArray(e)||e.length===0){this._hideDropdown();return}this._renderItems(e),this._showDropdown()},t;try{t=this._cfg.onSearch(this._query,e)}catch(e){this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e);return}t&&typeof t.then==`function`&&t.then(e).catch(e=>{this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e)})},this._cfg.debounce)}_onKeydown(e){if(!(!this._cfg||!this._open))if(e.key===`ArrowDown`){e.preventDefault();let t=(this._activeIndex+1)%this._items.length;this._highlightItem(t)}else if(e.key===`ArrowUp`){e.preventDefault();let t=(this._activeIndex-1+this._items.length)%this._items.length;this._highlightItem(t)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&this._hideDropdown()}_onDocClick(e){this._open&&(this._dropdown?.contains(e.target)||this._hideDropdown())}_select(e){let t=this._items[e];if(!t)return;if(this._triggerNode){let e=this._triggerNode;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+this._cfg.trigger.length+this._query.length);let t=globalThis.getSelection(),n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}let n;typeof this._cfg.onInsert==`function`&&(n=this._cfg.onInsert(t)),n||=`<span class="${this._cfg.mentionClass}" data-mention-id="${t.id}" contenteditable="false">@${t.label}</span>`,this.context.invoke(`editor.insertHTML`,n+`​`),this._hideDropdown(),this.context.triggerEvent(`change`,this.context.getHTML())}},enabled:e=>!!e.mention},{name:`slashMenu`,Class:class{constructor(e){this.context=e,this.options=e.options,this._disposers=[],this._menu=null,this._filtered=[],this._activeIndex=-1,this._open=!1,this._query=``,this._textNode=null,this._triggerOffset=0,this._caretRect=null}initialize(){if(this.options.slashMenu===!1)return this;let e=this.context.layoutInfo.editable,t=_(e,`input`,()=>this._onInput()),n=_(e,`keydown`,e=>this._onKeydown(e)),r=_(document,`click`,e=>this._onDocClick(e));return this._disposers.push(t,n,r),this}destroy(){this._menu?.remove(),this._menu=null,this._disposers.forEach(e=>e()),this._disposers=[]}_commands(){let e=this.context.locale.slashMenu,t=this.context,n=[{id:`h1`,label:e.heading1,keywords:`h1 heading title`,run:()=>t.invoke(`editor.formatBlock`,`h1`)},{id:`h2`,label:e.heading2,keywords:`h2 heading subtitle`,run:()=>t.invoke(`editor.formatBlock`,`h2`)},{id:`h3`,label:e.heading3,keywords:`h3 heading`,run:()=>t.invoke(`editor.formatBlock`,`h3`)},{id:`ul`,label:e.bulletList,keywords:`ul bullet list unordered`,run:()=>t.invoke(`editor.insertUL`)},{id:`ol`,label:e.numberedList,keywords:`ol numbered list ordered`,run:()=>t.invoke(`editor.insertOL`)},{id:`checklist`,label:e.checklist,keywords:`checklist todo checkbox task`,run:()=>t.invoke(`editor.toggleChecklist`)},{id:`quote`,label:e.blockquote,keywords:`quote blockquote`,run:()=>t.invoke(`editor.formatBlock`,`blockquote`)},{id:`code`,label:e.codeBlock,keywords:`code pre block`,run:()=>t.invoke(`editor.formatBlock`,`pre`)},{id:`hr`,label:e.horizontalRule,keywords:`hr divider rule line`,run:()=>t.invoke(`editor.insertHr`)},{id:`table`,label:e.table,keywords:`table grid`,run:()=>t.invoke(`editor.insertTable`,3,3)},{id:`image`,label:e.image,keywords:`image picture photo upload`,run:()=>t.invoke(`imageDialog.show`)}],r=(this.options.slashCommands||[]).map(e=>({id:e.id,label:e.label||e.id,keywords:e.keywords||``,run:()=>e.run(t)}));return[...n,...r]}refresh(){this._open&&this._filterAndRender()}_buildMenu(){let e=document.createElement(`div`);return e.className=`an-slash-menu`,e.setAttribute(`role`,`listbox`),e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._highlight(+t.dataset.index)}),document.body.appendChild(e),this._menu=e,e}_renderItems(){this._menu||this._buildMenu();let e=this._menu,t=this.context.locale.slashMenu;if(this._filtered.length===0){e.innerHTML=``;let n=document.createElement(`div`);n.className=`an-slash-menu-empty`,n.textContent=t.noResults,e.appendChild(n),this._activeIndex=-1;return}let n=document.createDocumentFragment();this._filtered.forEach((e,t)=>{let r=document.createElement(`div`);r.className=`an-slash-menu-item`,r.setAttribute(`role`,`option`),r.id=`an-slash-option-${e.id}`,r.dataset.index=String(t),r.textContent=e.label,n.appendChild(r)}),e.innerHTML=``,e.appendChild(n),this._highlight(0)}_highlight(e){this._menu&&(this._menu.querySelectorAll(`.an-slash-menu-item`).forEach((t,n)=>{let r=n===e;t.classList.toggle(`an-slash-menu-active`,r),t.setAttribute(`aria-selected`,String(r)),r&&this._menu.setAttribute(`aria-activedescendant`,t.id)}),this._activeIndex=e)}_position(){let e=this._menu,t=this._caretRect;if(!e||!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_open_(){this._open=!0,this._filterAndRender(),this._position()}_close(){this._menu&&(this._menu.style.display=`none`),this._open=!1,this._filtered=[],this._activeIndex=-1,this._menu?.removeAttribute(`aria-activedescendant`),this._textNode=null,this._caretRect=null,this._query=``}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_getTriggerContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer)||t.startContainer.nodeType!==Node.TEXT_NODE)return null;let r=t.startContainer.parentNode;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;if(!r||r===n)return null;let i=r.textContent||``,a=document.createRange();a.setStart(r,0),a.setEnd(t.startContainer,t.startOffset);let o=a.toString(),s=/^\/(\S*)$/.exec(o);return!s||i.length>o.length?null:{query:s[1],textNode:t.startContainer,triggerOffset:t.startOffset-s[0].length}}_captureCaretRect(e,t){try{let n=document.createRange(),r=Math.min(t+1,e.textContent.length);n.setStart(e,t),n.setEnd(e,r);let i=n.getBoundingClientRect();if(i.height>0)return i}catch{}let n=globalThis.getSelection();if(!n?.rangeCount)return null;let r=n.getRangeAt(0).getClientRects();return r.length>0?r[r.length-1]:null}_filterAndRender(){let e=this._query.toLowerCase();this._filtered=e?this._commands().filter(t=>t.keywords.includes(e)||t.label.toLowerCase().includes(e)):this._commands(),this._renderItems()}_onInput(){let e=this._getTriggerContext();if(!e){this._open&&this._close();return}this._textNode=e.textNode,this._triggerOffset=e.triggerOffset,this._query=e.query,this._caretRect=this._captureCaretRect(e.textNode,e.triggerOffset),this._open?(this._filterAndRender(),this._position()):this._open_()}_onKeydown(e){if(this._open)if(e.key===`ArrowDown`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex+1)%this._filtered.length)}else if(e.key===`ArrowUp`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex-1+this._filtered.length)%this._filtered.length)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&(e.preventDefault(),this._close())}_onDocClick(e){this._open&&(this._menu?.contains(e.target)||this._close())}_deleteTriggerText(){let e=this._textNode;if(!e?.isConnected)return;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+1+this._query.length);let t=globalThis.getSelection();if(!t)return;let n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}_makeTriggerRemover(){let e=this._textNode,t=this._triggerOffset,n=this._query;return()=>{if(!e?.isConnected)return;let r=e.textContent.slice(0,t),i=e.textContent.slice(t+1+n.length);e.textContent=r+i;let a=globalThis.getSelection();if(!a)return;let o=document.createRange();o.setStart(e,t),o.collapse(!0),a.removeAllRanges(),a.addRange(o)}}_select(e){let t=this._filtered[e];if(t){if(t.id===`image`){let e=this._makeTriggerRemover();this._close(),this.context.invoke(`imageDialog.show`,{beforeInsert:e});return}this._deleteTriggerText(),this._close(),t.run()}}},enabled:e=>e.slashMenu!==!1}],Wi=`2.7.0`,Gi={...j},$=new WeakMap,Ki={create(e,t={}){let n=qi(e).map(e=>{if($.has(e))return $.get(e);let n=new Yt(e,t);return n._releaseInstance=()=>{$.get(e)===n&&$.delete(e)},n.initialize(),$.set(e,n),n});return n.length===1?n[0]:n},destroy(e){qi(e).forEach(e=>{let t=$.get(e);t&&(t.destroy(),$.delete(e))})},getInstance(e){let t=typeof e==`string`?document.querySelector(e):e;return t&&$.get(t)||null},get defaults(){return{...j}},setDefaults(e){Object.assign(j,e)},resetDefaults(){Object.keys(j).forEach(e=>delete j[e]),Object.assign(j,Gi)},registerModule(e,t){Gt.set(e,t)},use(e,t={}){if(!e||typeof e.name!=`string`)throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");return Jt.has(e.name)?(console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`),this):(Array.isArray(e.buttons)&&e.buttons.forEach(e=>Le(e)),Jt.set(e.name,{plugin:e,options:t}),this)},hasPlugin(e){return Jt.has(e)},registerButton(e){return Le(e),this},registerLocale(e,t){return s(e,t),this},registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=j.slashCommands,n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this},buttons:Tt,version:Wi};function qi(e){return typeof e==`string`?Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:e instanceof NodeList||Array.isArray(e)?Array.from(e):[]}return qt(Ui),Ki});
|
|
75
|
+
`,r.addEventListener(`mouseover`,()=>{r.style.background=t+`22`}),r.addEventListener(`mouseout`,()=>{r.style.background=`none`}),this._disposers.push(_(r,`click`,e=>{e.stopPropagation(),n()})),r}_updateDOM(){let{x:e,y:t,w:n,h:r}=this._box;this._cropBox.style.left=`${e}px`,this._cropBox.style.top=`${t}px`,this._cropBox.style.width=`${n}px`,this._cropBox.style.height=`${r}px`;let i=globalThis.innerWidth,a=globalThis.innerHeight;if(this._scrim.style.clipPath=[`polygon(`,`0 0, ${i}px 0, ${i}px ${a}px, 0 ${a}px, 0 0,`,`${e}px ${t}px, ${e}px ${t+r}px, ${e+n}px ${t+r}px, ${e+n}px ${t}px, ${e}px ${t}px`,`)`].join(``),this._img){let i=this._img.naturalWidth||0,a=this._img.naturalHeight||0,o=this._imgRect.width||1,s=this._imgRect.height||1,c={x:i/o,y:a/s},l=Z(e-this._imgRect.left,0,o),u=Z(t-this._imgRect.top,0,s),d=Z(n,0,o-l),f=Z(r,0,s-u);this._infoEl.textContent=`${Math.round(d*c.x)} × ${Math.round(f*c.y)} px`}let o=t+r+8;o+40>globalThis.innerHeight-8&&(o=t-40-8),this._toolbar.style.left=`${e}px`,this._toolbar.style.top=`${o}px`}_startBoxMove(e){let t=e.clientX-this._box.x,n=e.clientY-this._box.y,r=this._imgRect;this._attachDocDrag(e=>{this._box.x=Z(e.clientX-t,r.left,r.right-this._box.w),this._box.y=Z(e.clientY-n,r.top,r.bottom-this._box.h),this._updateDOM()})}_startHandleDrag(e,t){let n=e.clientX,r=e.clientY,i={...this._box},a=this._imgRect,o=this._arCheck?.checked,s=i.w/(i.h||1);this._attachDocDrag(e=>{let c=e.clientX-n,l=e.clientY-r,{x:u,y:d,w:f,h:p}=i;t.includes(`e`)&&(f=Math.max(X,i.w+c)),t.includes(`s`)&&(p=Math.max(X,i.h+l)),t.includes(`w`)&&(u=Math.min(i.x+i.w-X,i.x+c),f=i.x+i.w-u),t.includes(`n`)&&(d=Math.min(i.y+i.h-X,i.y+l),p=i.y+i.h-d),o&&t.length===2&&(Math.abs(c)>=Math.abs(l)?(p=f/s,t.includes(`n`)&&(d=i.y+i.h-p)):(f=p*s,t.includes(`w`)&&(u=i.x+i.w-f))),u=Z(u,a.left,a.right-X),d=Z(d,a.top,a.bottom-X),f=Z(f,X,a.right-u),p=Z(p,X,a.bottom-d),this._box={x:u,y:d,w:f,h:p},this._updateDOM()})}_attachDocDrag(e){this._dragDisposers?.();let t=t=>{t.preventDefault();let n=t;e({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY})},n=()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n),document.removeEventListener(`touchmove`,t),document.removeEventListener(`touchend`,n),document.body.style.userSelect=``,document.body.style.cursor=``,this._dragDisposers=null};this._dragDisposers=n,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n,{once:!0}),document.addEventListener(`touchmove`,t,{passive:!1}),document.addEventListener(`touchend`,n,{once:!0})}_bindEsc(){let e=e=>{e.key===`Escape`&&(e.preventDefault(),this._close(!1)),e.key===`Enter`&&(e.preventDefault(),this._confirm())};document.addEventListener(`keydown`,e),this._disposers.push(()=>document.removeEventListener(`keydown`,e))}async _confirm(){let e=this._img;if(!e){this._close(!1);return}let t=this._imgRect,{x:n,y:r,w:i,h:a}=this._box,o=(e.naturalWidth||e.width||1)/(t.width||1),s=(e.naturalHeight||e.height||1)/(t.height||1),c=Math.round(Z(n-t.left,0,t.width)*o),l=Math.round(Z(r-t.top,0,t.height)*s),u=Math.round(Z(i,0,t.width-(n-t.left))*o),d=Math.round(Z(a,0,t.height-(r-t.top))*s);if(u<=0||d<=0){this._close(!1);return}let f=await Ni(e,{x:c,y:l,width:u,height:d},i,a);if(!f){this._showCropError(`Cannot crop this image: the image server does not allow cross-origin access. Upload the image directly to use the crop tool.`),this._close(!1);return}let p=/^data:image\/(jpe?g)/i.exec(e.src)?`image/jpeg`:`image/png`,m=p===`image/jpeg`?.92:void 0,h=f.toDataURL(p,m);this._close(!1),e.src=h,e.style.width=``,e.style.height=``,e.removeAttribute(`width`),e.removeAttribute(`height`),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`)}_showCropError(e){let t=document.createElement(`div`);t.setAttribute(`role`,`alert`),t.style.cssText=[`position:fixed`,`bottom:24px`,`left:50%`,`transform:translateX(-50%)`,`z-index:10200`,`max-width:420px`,`width:max-content`,`background:#7f1d1d`,`color:#fecaca`,`border:1px solid #b91c1c`,`border-radius:8px`,`padding:12px 18px`,`font:13px/1.5 system-ui,sans-serif`,`box-shadow:0 4px 16px rgba(0,0,0,.4)`,`pointer-events:auto`].join(`;`),t.textContent=e,document.body.appendChild(t),setTimeout(()=>{t.remove()},4e3)}_close(e){this._dragDisposers?.(),this._dragDisposers=null,this._disposers.forEach(e=>e()),this._disposers=[],[this._scrim,this._cropBox,this._toolbar].forEach(e=>{e?.remove()}),this._scrim=null,this._cropBox=null,this._toolbar=null,this._infoEl=null,this._handles={},this._img=null,this._box=null,this._imgRect=null,this._arCheck=null}},Fi=class{constructor(e){this.context=e,this.options=e.options,this._banner=null}initialize(){if(!this.options.autoSave||!this.options.autoSaveRestore)return this;let e=this.options.autoSaveKey,t=e+`:asrmeta`,n,r;try{n=localStorage.getItem(e),r=JSON.parse(localStorage.getItem(t)||`{}`)}catch{return this}if(!n)return this;let i=this.options.autoSaveRestoreTimeout;if(i>0&&Date.now()-(r.savedAt||0)>i*864e5){try{localStorage.removeItem(e),localStorage.removeItem(t)}catch{}return this}return this._showBanner(n,r),this}destroy(){this._removeBanner()}_showBanner(e,t){let n=this.context.locale.autoSaveRestore||{},r=n.found||`Draft found. Restore?`,i=n.restore||`Restore`,a=n.discard||`Discard`,o=document.createElement(`div`);o.className=`an-asr-banner`,o.setAttribute(`role`,`alert`);let s=document.createElement(`span`);if(s.className=`an-asr-msg`,t.savedAt){let e=new Date(t.savedAt).toLocaleString();s.textContent=(n.foundAt||`Draft from {date}. Restore?`).replace(`{date}`,e)}else s.textContent=r;let c=document.createElement(`button`);c.type=`button`,c.className=`an-btn an-asr-btn-restore`,c.textContent=i,c.addEventListener(`click`,()=>this._restore(e));let l=document.createElement(`button`);l.type=`button`,l.className=`an-btn an-asr-btn-discard`,l.textContent=a,l.addEventListener(`click`,()=>this._discard()),o.appendChild(s),o.appendChild(c),o.appendChild(l),this._banner=o;let u=this.context.layoutInfo.container;u.insertBefore(o,u.firstChild)}_restore(e){this.context.setHTML(e),this.context.clearHistory(),this._removeBanner(),typeof this.options.onAutoSaveRestore==`function`&&this.options.onAutoSaveRestore(e,this.context)}_discard(){let e=this.options.autoSaveKey;try{localStorage.removeItem(e),localStorage.removeItem(e+`:asrmeta`)}catch{}this._removeBanner()}_removeBanner(){this._banner?.remove(),this._banner=null}},Ii=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){if(!this.options.markdownShortcuts)return this;let e=this.context.layoutInfo.editable,t=_(e,`keydown`,e=>this._onKeydown(e)),n=_(e,`input`,()=>this._onInput());return this._disposers.push(t,n),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_onKeydown(e){this._inCodeContext()||(e.key===` `?this._applyBlockRule()&&e.preventDefault():e.key===`Enter`&&this._applyEnterRule()&&e.preventDefault())}_inCodeContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;return!!(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(`pre, code`)}_getLineContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer))return null;let r=t.startContainer;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;(!r||r===n)&&(r=t.startContainer);let i=document.createRange();return i.setStart(r,0),i.setEnd(t.startContainer,t.startOffset),{text:i.toString(),range:t,lineNode:r}}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_applyBlockRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e,n=[{re:/^(#{1,6})$/,handler:e=>this._convertToHeading(e[1].length)},{re:/^>$/,handler:()=>this._convertToBlockquote()},{re:/^[-*+]$/,handler:()=>this._convertToList(`ul`)},{re:/^1[.)]$/,handler:()=>this._convertToList(`ol`)},{re:/^\[([ xX])\]$/,handler:e=>this._convertToChecklist(e[1].toLowerCase()===`x`)}];for(let{re:e,handler:r}of n){let n=e.exec(t);if(n)return r(n),!0}return!1}_applyEnterRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e;return/^(?:-{3,}|\*{3,}|_{3,})$/.test(t)?(this._convertToHr(),!0):/^(?:`{3}|~{3})/.test(t)?(this._convertToCodeBlock(),!0):!1}_selectLineAndDelete(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=document.createRange();n.setStart(t.startContainer.parentNode||t.startContainer,0),n.setEnd(t.startContainer,t.startOffset),n.deleteContents()}_convertToHeading(e){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`h${e}`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToBlockquote(){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`blockquote`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToList(e){this._selectLineAndDelete(),document.execCommand(e===`ul`?`insertUnorderedList`:`insertOrderedList`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToChecklist(e=!1){if(this._selectLineAndDelete(),this.context.invoke(`editor.toggleChecklist`),e){let e=globalThis.getSelection(),t=e?.rangeCount?e.getRangeAt(0).startContainer:null,n=(t?.nodeType===Node.ELEMENT_NODE?t:t?.parentElement??null)?.closest(`li`)?.querySelector(`input[type="checkbox"]`)??null;n&&(n.checked=!0)}this.context.triggerEvent(`change`,this.context.getHTML())}_convertToHr(){this._selectLineAndDelete(),this.context.invoke(`editor.insertHr`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToCodeBlock(){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`pre`),this.context.triggerEvent(`change`,this.context.getHTML())}_onInput(){if(this._inCodeContext())return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0);if(!t.collapsed||!this.context.layoutInfo.editable.contains(t.startContainer))return;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return;let r=n.textContent,i=t.startOffset,a=[{re:/\*\*(.+?)\*\*$/,tag:`strong`},{re:/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)$/,tag:`em`},{re:/~~(.+?)~~$/,tag:`s`},{re:/`([^`]+)`$/,tag:`code`}],o=r.slice(0,i);for(let{re:t,tag:s}of a){let a=t.exec(o);if(!a)continue;let c=o.length-a[0].length,l=i,u=a[1],d=r.slice(0,c),f=r.slice(l),p=document.createElement(s);p.textContent=u;let m=document.createTextNode(d),h=document.createTextNode(``+f);n.before(m,p,h),n.remove();let g=document.createRange();g.setStart(h,1),g.collapse(!0),e.removeAllRanges(),e.addRange(g),this.context.triggerEvent(`change`,this.context.getHTML());break}}},Li=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],Ri=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,Q=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" ${Ri} style="display:block">${e}</svg>`,zi={bold:Q(`<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"/>`),italic:Q(`<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"/>`),underline:Q(`<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"/>`),strikethrough:Q(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`),link:Q(`<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"/>`),foreColor:Q(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`),hiliteColor:Q(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/>`),removeFormat:Q(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`),inlineCode:Q(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)},Bi={bold:e=>e.invoke(`editor.bold`),italic:e=>e.invoke(`editor.italic`),underline:e=>e.invoke(`editor.underline`),strikethrough:e=>e.invoke(`editor.strikethrough`),link:e=>e.invoke(`linkDialog.show`),removeFormat:e=>{let t=e.layoutInfo?.editable;if(!t)return;t.focus(),document.execCommand(`removeFormat`);let n=globalThis.getSelection();if(n?.rangeCount>0&&!n.getRangeAt(0).collapsed){let e=n.getRangeAt(0),t=e.commonAncestorContainer,r=t.nodeType===1?t:t.parentElement;if(r){let t=[r,...r.querySelectorAll(`[style]`)];for(let n of t)n.hasAttribute(`style`)&&e.intersectsNode(n)&&n.removeAttribute(`style`)}}e.invoke(`editor.afterCommand`)},inlineCode:e=>e.invoke(`editor.inlineCode`)},Vi={bold:()=>document.queryCommandState(`bold`),italic:()=>document.queryCommandState(`italic`),underline:()=>document.queryCommandState(`underline`),strikethrough:()=>document.queryCommandState(`strikeThrough`)},Hi={foreColor:!0,hiliteColor:!0},Ui=[{name:`editor`,Class:gr},{name:`toolbar`,Class:xr},{name:`statusbar`,Class:Cr},{name:`clipboard`,Class:wr},{name:`placeholder`,Class:jr},{name:`contextMenu`,Class:Or},{name:`codeview`,Class:Mr},{name:`fullscreen`,Class:Nr},{name:`linkDialog`,Class:Fr},{name:`imageDialog`,Class:Lr},{name:`videoDialog`,Class:zr},{name:`imageResizer`,Class:Hr},{name:`videoResizer`,Class:Ur},{name:`linkTooltip`,Class:qr},{name:`imageTooltip`,Class:Yr},{name:`videoTooltip`,Class:Xr},{name:`tableTooltip`,Class:ri},{name:`codeTooltip`,Class:ui},{name:`emojiDialog`,Class:vi},{name:`iconDialog`,Class:Di},{name:`shortcutsDialog`,Class:Ai},{name:`findReplace`,Class:ji},{name:`imageCropOverlay`,Class:Pi},{name:`autoSaveRestore`,Class:Fi,enabled:e=>!!e.autoSaveRestore},{name:`markdownShortcuts`,Class:Ii,enabled:e=>e.markdownShortcuts!==!1},{name:`bubbleToolbar`,Class:class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._picker=null,this._pickerType=null,this._savedRange=null,this._visible=!1,this._rafId=null,this._contextMenuOpen=!1,this._disposers=[],this._onSelectionChange=this._onSelectionChange.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onContextMenu=this._onContextMenu.bind(this)}initialize(){if(!this.options.bubbleToolbar)return this;this._build(),this._buildColorPicker();let e=_(document,`selectionchange`,this._onSelectionChange),t=_(document,`mousedown`,this._onMousedown),n=_(document,`keydown`,this._onKeydown),r=_(document,`contextmenu`,this._onContextMenu),i=this.context.on(`contextMenu:show`,()=>{this._contextMenuOpen=!0,this._hide()}),a=this.context.on(`contextMenu:hide`,()=>{this._contextMenuOpen=!1}),o=_(globalThis,`scroll`,()=>this._hide(),{passive:!0}),s=_(globalThis,`resize`,()=>this._hide(),{passive:!0});return this._disposers.push(e,t,n,r,i,a,o,s),this}destroy(){this._el?.remove(),this._el=null,this._picker?.remove(),this._picker=null,this._disposers.forEach(e=>e()),this._disposers=[],cancelAnimationFrame(this._rafId)}_build(){let e=document.createElement(`div`);e.className=`an-bubble-toolbar`,e.setAttribute(`role`,`toolbar`),e.setAttribute(`aria-label`,`Formatting`);let t=this.options.bubbleToolbarItems||[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`];for(let n of t){if(!zi[n])continue;let t=document.createElement(`button`);if(t.type=`button`,t.dataset.name=n,t.setAttribute(`aria-label`,n),Hi[n]){t.className=`an-bubble-btn an-bubble-btn--color`;let e=document.createElement(`span`);e.className=`an-bubble-btn-svg`,e.innerHTML=zi[n];let r=document.createElement(`span`);r.className=`an-bubble-color-strip`,r.style.background=n===`foreColor`?`#000000`:`transparent`,t.appendChild(e),t.appendChild(r)}else t.className=`an-bubble-btn`,t.innerHTML=zi[n];t.addEventListener(`mousedown`,e=>{e.preventDefault()}),t.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),Hi[n]){this._openColorPicker(n,t);return}this.context.invoke(`editor.focus`),Bi[n]&&Bi[n](this.context),this._syncActive()}),e.appendChild(t)}document.body.appendChild(e),this._el=e,this._btnCache=Array.from(e.querySelectorAll(`.an-bubble-btn`))}_buildColorPicker(){let e=document.createElement(`div`);e.className=`an-bubble-color-picker`,e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault());let t=document.createElement(`div`);t.className=`an-context-color-palette`,Li.forEach(e=>{let n=document.createElement(`div`);n.className=`an-context-color-swatch`,n.title=e,n.style.background=e,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,e),n.addEventListener(`click`,t=>{t.stopPropagation(),this._applyColor(this._pickerType,e)}),t.appendChild(n)});let n=document.createElement(`div`);n.className=`an-context-color-swatch an-context-color-none`,n.title=`No highlight`,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,`No highlight`),n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,n.addEventListener(`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});let r=document.createElement(`div`);r.className=`an-context-color-custom`;let i=document.createElement(`input`);i.type=`color`,i.value=`#000000`,i.title=`Custom color`,i.addEventListener(`mousedown`,e=>e.stopPropagation()),i.addEventListener(`change`,()=>{this._applyColor(this._pickerType,i.value)});let a=document.createElement(`span`);a.textContent=`Custom…`,r.appendChild(i),r.appendChild(a),e.appendChild(t),e.appendChild(r),document.body.appendChild(e),this._picker=e;let o=e;o._paletteEl=t,o._noColorBtn=n,o._colorInput=i}_openColorPicker(e,t){let n=globalThis.getSelection();n?.rangeCount>0&&(this._savedRange=n.getRangeAt(0).cloneRange()),this._pickerType=e;let r=this._picker,i=r._paletteEl,a=r._noColorBtn;e===`hiliteColor`?i.contains(a)||i.appendChild(a):i.contains(a)&&a.remove(),this._picker._colorInput.value=e===`foreColor`?`#000000`:`#ffff00`,this._picker.style.display=`block`;let o=this._picker.offsetWidth,s=this._picker.offsetHeight,c=this._el.getBoundingClientRect(),l=c.top-s-6;l<8&&(l=c.bottom+6);let u=t.getBoundingClientRect().left;u=Math.max(8,Math.min(u,globalThis.innerWidth-o-8)),this._picker.style.left=`${u}px`,this._picker.style.top=`${l}px`}_closeColorPicker(){this._picker&&(this._picker.style.display=`none`),this._pickerType=null}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges();try{r.addRange(this._savedRange.cloneRange())}catch{return}let i=e===`hiliteColor`?`hiliteColor`:e;!document.execCommand(i,!1,t)&&i===`hiliteColor`&&document.execCommand(`backColor`,!1,t),this.context.invoke(`editor.afterCommand`);let a=e===`hiliteColor`?`hiliteColor`:`foreColor`,o=(this._el?.querySelector(`[data-name="${a}"]`))?.querySelector(`.an-bubble-color-strip`);o&&(o.style.background=t===`transparent`?`transparent`:t),this._closeColorPicker(),this._syncActive()}_show(e){if(!this._el)return;let t=this._el;t.style.visibility=`hidden`,t.style.display=`flex`;let n=t.offsetWidth,r=t.offsetHeight,i=e.left+e.width/2-n/2,a=e.top-r-8;i=Math.max(8,Math.min(i,globalThis.innerWidth-n-8)),a<8&&(a=e.bottom+8);let o=document.querySelector(`.an-table-tooltip`);if(o&&o.style.display!==`none`){let t=o.getBoundingClientRect();a<t.bottom+8&&a+r>t.top-8&&(a=e.bottom+8,a+r>globalThis.innerHeight-8&&(a=t.bottom+8))}t.style.top=`${a}px`,t.style.left=`${i}px`,t.style.visibility=``,this._syncActive(),this._syncColorStrips(),this._visible=!0}_hide(){this._el&&(this._el.style.display=`none`,this._visible=!1,this._closeColorPicker())}_syncActive(){this._btnCache&&this._btnCache.forEach(e=>{let t=Vi[e.dataset.name];e.classList.toggle(`an-active`,!!t?.())})}_syncColorStrips(){if(!this._el)return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),!t)return;let n=globalThis.getComputedStyle(t),r=this._el.querySelector(`[data-name="foreColor"]`)?.querySelector(`.an-bubble-color-strip`);r&&(r.style.background=n.color||`#000000`);let i=this._el.querySelector(`[data-name="hiliteColor"]`)?.querySelector(`.an-bubble-color-strip`);if(i){let e=n.backgroundColor;i.style.background=!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`?`transparent`:e}}_onSelectionChange(){cancelAnimationFrame(this._rafId),this._rafId=requestAnimationFrame(()=>{if(this._contextMenuOpen||this._picker&&this._picker.style.display!==`none`)return;let e=globalThis.getSelection();if(!e||e.isCollapsed||!e.rangeCount){this._hide();return}if(!this.context.layoutInfo.editable.contains(e.anchorNode)){this._hide();return}if(this.context.options.readOnly){this._hide();return}let t=e.getRangeAt(0).getBoundingClientRect();if(!t||t.width===0){this._hide();return}this._show(t)})}_onMousedown(e){this._visible&&(this._el?.contains(e.target)||this._picker?.contains(e.target)||this.context.layoutInfo.editable.contains(e.target)||this._hide())}_onKeydown(e){e.key===`Escape`&&(this._picker&&this._picker.style.display!==`none`?this._closeColorPicker():this._visible&&this._hide())}_onContextMenu(){this._hide()}},enabled:e=>!!e.bubbleToolbar},{name:`mention`,Class:class{constructor(e){this.context=e,this._dropdown=null,this._query=``,this._debounceTimer=null,this._activeIndex=-1,this._items=[],this._open=!1,this._triggerNode=null,this._triggerOffset=0,this._caretRect=null,this._disposers=[]}initialize(){let e=this.context.options.mention;if(!e||typeof e.onSearch!=`function`)return this;this._cfg={trigger:e.trigger||`@`,minChars:e.minChars??0,maxResults:e.maxResults??8,debounce:e.debounce??200,onSearch:e.onSearch,onInsert:e.onInsert||null,onError:e.onError||null,mentionClass:e.mentionClass||`an-mention`,allowSpaces:e.allowSpaces||!1},this._buildDropdown();let t=this.context.layoutInfo.editable,n=_(t,`keydown`,e=>this._onKeydown(e)),r=_(t,`input`,()=>this._onInput()),i=_(document,`click`,e=>this._onDocClick(e));return this._disposers.push(n,r,i),this}destroy(){clearTimeout(this._debounceTimer),this._dropdown?.remove(),this._dropdown=null,this._disposers.forEach(e=>e()),this._disposers=[]}_buildDropdown(){let e=document.createElement(`div`);e.className=`an-mention-dropdown`,e.setAttribute(`role`,`listbox`),e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._highlightItem(+t.dataset.index)}),document.body.appendChild(e),this._dropdown=e}_renderItems(e){let t=this._dropdown;this._items=e.slice(0,this._cfg.maxResults),this._activeIndex=this._items.length>0?0:-1;let n=document.createDocumentFragment();this._items.forEach((e,t)=>{let r=document.createElement(`div`);if(r.className=`an-mention-item`,r.setAttribute(`role`,`option`),r.dataset.index=String(t),e.avatar){let t=document.createElement(`img`);t.src=e.avatar,t.className=`an-mention-avatar`,t.alt=``,r.appendChild(t)}let i=document.createElement(`span`);i.textContent=e.label,r.appendChild(i),n.appendChild(r)}),t.innerHTML=``,t.appendChild(n),this._highlightItem(this._activeIndex)}_highlightItem(e){this._dropdown&&(this._dropdown.querySelectorAll(`.an-mention-item`).forEach((t,n)=>{t.classList.toggle(`an-mention-active`,n===e)}),this._activeIndex=e)}_positionDropdown(){let e=this._dropdown,t=this._caretRect;if(!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_showDropdown(){this._open=!0,this._positionDropdown()}_hideDropdown(){this._dropdown&&(this._dropdown.style.display=`none`),this._open=!1,this._items=[],this._activeIndex=-1,this._triggerNode=null,this._caretRect=null,this._query=``}_captureCaretRect(){if(this._triggerNode?.isConnected)try{let e=document.createRange(),t=Math.min(this._triggerOffset+1,this._triggerNode.textContent.length);e.setStart(this._triggerNode,this._triggerOffset),e.setEnd(this._triggerNode,t);let n=e.getBoundingClientRect();if(n.height>0){this._caretRect=n;return}}catch{}let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).getClientRects();t.length>0&&(this._caretRect=t[t.length-1])}_getQueryAtCursor(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return null;let r=n.textContent.slice(0,t.startOffset),i=this._cfg.trigger,a=r.lastIndexOf(i);if(a===-1)return null;let o=r.slice(a+i.length);return!this._cfg.allowSpaces&&/\s/.test(o)||o.length<this._cfg.minChars?null:(this._triggerNode=n,this._triggerOffset=a,o)}_onInput(){if(!this._cfg)return;let e=this._getQueryAtCursor();if(e===null){this._hideDropdown();return}this._captureCaretRect(),this._query=e,clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{let e=e=>{if(!Array.isArray(e)||e.length===0){this._hideDropdown();return}this._renderItems(e),this._showDropdown()},t;try{t=this._cfg.onSearch(this._query,e)}catch(e){this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e);return}t&&typeof t.then==`function`&&t.then(e).catch(e=>{this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e)})},this._cfg.debounce)}_onKeydown(e){if(!(!this._cfg||!this._open)){if(e.key===`ArrowDown`){e.preventDefault();let t=(this._activeIndex+1)%this._items.length;this._highlightItem(t)}else if(e.key===`ArrowUp`){e.preventDefault();let t=(this._activeIndex-1+this._items.length)%this._items.length;this._highlightItem(t)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&this._hideDropdown()}}_onDocClick(e){this._open&&(this._dropdown?.contains(e.target)||this._hideDropdown())}_select(e){let t=this._items[e];if(!t)return;if(this._triggerNode){let e=this._triggerNode;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+this._cfg.trigger.length+this._query.length);let t=globalThis.getSelection(),n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}let n;typeof this._cfg.onInsert==`function`&&(n=this._cfg.onInsert(t)),n||=`<span class="${this._cfg.mentionClass}" data-mention-id="${t.id}" contenteditable="false">@${t.label}</span>`,this.context.invoke(`editor.insertHTML`,n+`​`),this._hideDropdown(),this.context.triggerEvent(`change`,this.context.getHTML())}},enabled:e=>!!e.mention},{name:`slashMenu`,Class:class{constructor(e){this.context=e,this.options=e.options,this._disposers=[],this._menu=null,this._filtered=[],this._activeIndex=-1,this._open=!1,this._query=``,this._textNode=null,this._triggerOffset=0,this._caretRect=null}initialize(){if(this.options.slashMenu===!1)return this;let e=this.context.layoutInfo.editable,t=_(e,`input`,()=>this._onInput()),n=_(e,`keydown`,e=>this._onKeydown(e)),r=_(document,`click`,e=>this._onDocClick(e));return this._disposers.push(t,n,r),this}destroy(){this._menu?.remove(),this._menu=null,this._disposers.forEach(e=>e()),this._disposers=[]}_commands(){let e=this.context.locale.slashMenu,t=this.context,n=[{id:`h1`,label:e.heading1,keywords:`h1 heading title`,run:()=>t.invoke(`editor.formatBlock`,`h1`)},{id:`h2`,label:e.heading2,keywords:`h2 heading subtitle`,run:()=>t.invoke(`editor.formatBlock`,`h2`)},{id:`h3`,label:e.heading3,keywords:`h3 heading`,run:()=>t.invoke(`editor.formatBlock`,`h3`)},{id:`ul`,label:e.bulletList,keywords:`ul bullet list unordered`,run:()=>t.invoke(`editor.insertUL`)},{id:`ol`,label:e.numberedList,keywords:`ol numbered list ordered`,run:()=>t.invoke(`editor.insertOL`)},{id:`checklist`,label:e.checklist,keywords:`checklist todo checkbox task`,run:()=>t.invoke(`editor.toggleChecklist`)},{id:`quote`,label:e.blockquote,keywords:`quote blockquote`,run:()=>t.invoke(`editor.formatBlock`,`blockquote`)},{id:`code`,label:e.codeBlock,keywords:`code pre block`,run:()=>t.invoke(`editor.formatBlock`,`pre`)},{id:`hr`,label:e.horizontalRule,keywords:`hr divider rule line`,run:()=>t.invoke(`editor.insertHr`)},{id:`table`,label:e.table,keywords:`table grid`,run:()=>t.invoke(`editor.insertTable`,3,3)},{id:`image`,label:e.image,keywords:`image picture photo upload`,run:()=>t.invoke(`imageDialog.show`)}],r=(this.options.slashCommands||[]).map(e=>({id:e.id,label:e.label||e.id,keywords:e.keywords||``,run:()=>e.run(t)}));return[...n,...r]}refresh(){this._open&&this._filterAndRender()}_buildMenu(){let e=document.createElement(`div`);return e.className=`an-slash-menu`,e.setAttribute(`role`,`listbox`),e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._highlight(+t.dataset.index)}),document.body.appendChild(e),this._menu=e,e}_renderItems(){this._menu||this._buildMenu();let e=this._menu,t=this.context.locale.slashMenu;if(this._filtered.length===0){e.innerHTML=``;let n=document.createElement(`div`);n.className=`an-slash-menu-empty`,n.textContent=t.noResults,e.appendChild(n),this._activeIndex=-1;return}let n=document.createDocumentFragment();this._filtered.forEach((e,t)=>{let r=document.createElement(`div`);r.className=`an-slash-menu-item`,r.setAttribute(`role`,`option`),r.id=`an-slash-option-${e.id}`,r.dataset.index=String(t),r.textContent=e.label,n.appendChild(r)}),e.innerHTML=``,e.appendChild(n),this._highlight(0)}_highlight(e){this._menu&&(this._menu.querySelectorAll(`.an-slash-menu-item`).forEach((t,n)=>{let r=n===e;t.classList.toggle(`an-slash-menu-active`,r),t.setAttribute(`aria-selected`,String(r)),r&&this._menu.setAttribute(`aria-activedescendant`,t.id)}),this._activeIndex=e)}_position(){let e=this._menu,t=this._caretRect;if(!e||!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_open_(){this._open=!0,this._filterAndRender(),this._position()}_close(){this._menu&&(this._menu.style.display=`none`),this._open=!1,this._filtered=[],this._activeIndex=-1,this._menu?.removeAttribute(`aria-activedescendant`),this._textNode=null,this._caretRect=null,this._query=``}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_getTriggerContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer)||t.startContainer.nodeType!==Node.TEXT_NODE)return null;let r=t.startContainer.parentNode;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;if(!r||r===n)return null;let i=r.textContent||``,a=document.createRange();a.setStart(r,0),a.setEnd(t.startContainer,t.startOffset);let o=a.toString(),s=/^\/(\S*)$/.exec(o);return!s||i.length>o.length?null:{query:s[1],textNode:t.startContainer,triggerOffset:t.startOffset-s[0].length}}_captureCaretRect(e,t){try{let n=document.createRange(),r=Math.min(t+1,e.textContent.length);n.setStart(e,t),n.setEnd(e,r);let i=n.getBoundingClientRect();if(i.height>0)return i}catch{}let n=globalThis.getSelection();if(!n?.rangeCount)return null;let r=n.getRangeAt(0).getClientRects();return r.length>0?r[r.length-1]:null}_filterAndRender(){let e=this._query.toLowerCase();this._filtered=e?this._commands().filter(t=>t.keywords.includes(e)||t.label.toLowerCase().includes(e)):this._commands(),this._renderItems()}_onInput(){let e=this._getTriggerContext();if(!e){this._open&&this._close();return}this._textNode=e.textNode,this._triggerOffset=e.triggerOffset,this._query=e.query,this._caretRect=this._captureCaretRect(e.textNode,e.triggerOffset),this._open?(this._filterAndRender(),this._position()):this._open_()}_onKeydown(e){if(this._open){if(e.key===`ArrowDown`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex+1)%this._filtered.length)}else if(e.key===`ArrowUp`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex-1+this._filtered.length)%this._filtered.length)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&(e.preventDefault(),this._close())}}_onDocClick(e){this._open&&(this._menu?.contains(e.target)||this._close())}_deleteTriggerText(){let e=this._textNode;if(!e?.isConnected)return;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+1+this._query.length);let t=globalThis.getSelection();if(!t)return;let n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}_makeTriggerRemover(){let e=this._textNode,t=this._triggerOffset,n=this._query;return()=>{if(!e?.isConnected)return;let r=e.textContent.slice(0,t),i=e.textContent.slice(t+1+n.length);e.textContent=r+i;let a=globalThis.getSelection();if(!a)return;let o=document.createRange();o.setStart(e,t),o.collapse(!0),a.removeAllRanges(),a.addRange(o)}}_select(e){let t=this._filtered[e];if(t){if(t.id===`image`){let e=this._makeTriggerRemover();this._close(),this.context.invoke(`imageDialog.show`,{beforeInsert:e});return}this._deleteTriggerText(),this._close(),t.run()}}},enabled:e=>e.slashMenu!==!1}],Wi=`2.7.1`,Gi={...j},$=new WeakMap,Ki={create(e,t={}){let n=qi(e).map(e=>{if($.has(e))return $.get(e);let n=new Yt(e,t);return n._releaseInstance=()=>{$.get(e)===n&&$.delete(e)},n.initialize(),$.set(e,n),n});return n.length===1?n[0]:n},destroy(e){qi(e).forEach(e=>{let t=$.get(e);t&&(t.destroy(),$.delete(e))})},getInstance(e){let t=typeof e==`string`?document.querySelector(e):e;return t&&$.get(t)||null},get defaults(){return{...j}},setDefaults(e){Object.assign(j,e)},resetDefaults(){Object.keys(j).forEach(e=>delete j[e]),Object.assign(j,Gi)},registerModule(e,t){Gt.set(e,t)},use(e,t={}){if(!e||typeof e.name!=`string`)throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");return Jt.has(e.name)?(console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`),this):(Array.isArray(e.buttons)&&e.buttons.forEach(e=>Le(e)),Jt.set(e.name,{plugin:e,options:t}),this)},hasPlugin(e){return Jt.has(e)},registerButton(e){return Le(e),this},registerLocale(e,t){return s(e,t),this},registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=j.slashCommands,n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this},buttons:Tt,version:Wi};function qi(e){return typeof e==`string`?Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:e instanceof NodeList||Array.isArray(e)?Array.from(e):[]}return qt(Ui),Ki});
|
|
76
76
|
//# sourceMappingURL=autumnnote.umd.js.map
|