@aeriz/wysiwyg 1.0.4 → 2.0.0

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.
Files changed (132) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +82 -573
  3. package/angular/README.md +10 -4
  4. package/angular/aeriz-editor.directive.ts +40 -18
  5. package/dist/adapters/jquery.cjs +1 -1
  6. package/dist/adapters/jquery.js +14 -14
  7. package/dist/adapters/shared.cjs +1 -1
  8. package/dist/adapters/shared.js +59 -56
  9. package/dist/adapters/vue.cjs +1 -1
  10. package/dist/adapters/vue.js +64 -56
  11. package/dist/adapters/vue2.cjs +1 -1
  12. package/dist/adapters/vue2.js +24 -17
  13. package/dist/adapters/wc.cjs +1 -1
  14. package/dist/adapters/wc.js +108 -72
  15. package/dist/aeriz-wysiwyg-adapter.js +24 -32
  16. package/dist/aeriz-wysiwyg-adapter.min.js +1 -1
  17. package/dist/aeriz-wysiwyg-highlight.js +964 -0
  18. package/dist/aeriz-wysiwyg-highlight.min.js +5 -0
  19. package/dist/aeriz-wysiwyg-jquery.js +25 -32
  20. package/dist/aeriz-wysiwyg-jquery.min.js +1 -1
  21. package/dist/aeriz-wysiwyg-wc.js +80 -43
  22. package/dist/aeriz-wysiwyg-wc.min.js +1 -1
  23. package/dist/aeriz-wysiwyg.cjs +3688 -1757
  24. package/dist/aeriz-wysiwyg.css +2104 -1904
  25. package/dist/aeriz-wysiwyg.esm.js +3688 -1757
  26. package/dist/aeriz-wysiwyg.esm.min.js +4904 -3538
  27. package/dist/aeriz-wysiwyg.js +3688 -1757
  28. package/dist/aeriz-wysiwyg.min.cjs +53 -40
  29. package/dist/aeriz-wysiwyg.min.css +1 -1
  30. package/dist/aeriz-wysiwyg.min.js +53 -40
  31. package/dist/highlight.cjs +5 -0
  32. package/dist/highlight.js +895 -0
  33. package/dist/server.cjs +24 -19
  34. package/dist/server.js +612 -251
  35. package/dist-types/adapters/shared.d.ts +0 -8
  36. package/dist-types/adapters/shared.d.ts.map +1 -1
  37. package/dist-types/adapters/vue.d.ts +62 -21
  38. package/dist-types/adapters/vue.d.ts.map +1 -1
  39. package/dist-types/adapters/vue2.d.ts +33 -14
  40. package/dist-types/adapters/vue2.d.ts.map +1 -1
  41. package/dist-types/adapters/wc.d.ts +15 -6
  42. package/dist-types/adapters/wc.d.ts.map +1 -1
  43. package/dist-types/cjs/adapters/shared.d.cts +0 -8
  44. package/dist-types/cjs/adapters/vue.d.cts +62 -21
  45. package/dist-types/cjs/adapters/vue2.d.cts +33 -14
  46. package/dist-types/cjs/adapters/wc.d.cts +15 -6
  47. package/dist-types/cjs/core/AerizEditor.d.cts +238 -48
  48. package/dist-types/cjs/core/AerizViewer.d.cts +7 -0
  49. package/dist-types/cjs/core/block-meta.d.cts +40 -0
  50. package/dist-types/cjs/core/block-tracker.d.cts +64 -0
  51. package/dist-types/cjs/core/blocks.d.cts +39 -4
  52. package/dist-types/cjs/core/fonts.d.cts +33 -46
  53. package/dist-types/cjs/core/highlight.d.cts +2 -0
  54. package/dist-types/cjs/core/history.d.cts +28 -10
  55. package/dist-types/cjs/core/html-to-blocks.d.cts +10 -0
  56. package/dist-types/cjs/core/i18n.d.cts +44 -0
  57. package/dist-types/cjs/core/import-html.d.cts +0 -13
  58. package/dist-types/cjs/core/insert-fragment.d.cts +21 -0
  59. package/dist-types/cjs/core/paste-clean.d.cts +36 -0
  60. package/dist-types/cjs/core/sanitize-dom.d.cts +21 -0
  61. package/dist-types/cjs/core/sanitize-html.d.cts +8 -0
  62. package/dist-types/cjs/core/sanitize-policy.d.cts +22 -0
  63. package/dist-types/cjs/core/selection.d.cts +5 -0
  64. package/dist-types/cjs/core/table-grid.d.cts +87 -0
  65. package/dist-types/cjs/core/table-ops.d.cts +2 -22
  66. package/dist-types/cjs/highlight/index.d.cts +5 -0
  67. package/dist-types/cjs/index.d.cts +19 -11
  68. package/dist-types/cjs/server/index.d.cts +4 -5
  69. package/dist-types/cjs/types/index.d.cts +63 -15
  70. package/dist-types/cjs/ui/Toolbar.d.cts +10 -0
  71. package/dist-types/cjs/ui/doc-tools.d.cts +58 -0
  72. package/dist-types/cjs/ui/popovers.d.cts +14 -25
  73. package/dist-types/core/AerizEditor.d.ts +238 -48
  74. package/dist-types/core/AerizEditor.d.ts.map +1 -1
  75. package/dist-types/core/AerizViewer.d.ts +7 -0
  76. package/dist-types/core/AerizViewer.d.ts.map +1 -1
  77. package/dist-types/core/block-meta.d.ts +40 -0
  78. package/dist-types/core/block-meta.d.ts.map +1 -1
  79. package/dist-types/core/block-policy.d.ts.map +1 -1
  80. package/dist-types/core/block-tracker.d.ts +64 -0
  81. package/dist-types/core/block-tracker.d.ts.map +1 -0
  82. package/dist-types/core/blocks.d.ts +39 -4
  83. package/dist-types/core/blocks.d.ts.map +1 -1
  84. package/dist-types/core/fonts.d.ts +33 -46
  85. package/dist-types/core/fonts.d.ts.map +1 -1
  86. package/dist-types/core/highlight.d.ts +2 -0
  87. package/dist-types/core/highlight.d.ts.map +1 -1
  88. package/dist-types/core/history.d.ts +28 -10
  89. package/dist-types/core/history.d.ts.map +1 -1
  90. package/dist-types/core/html-mini.d.ts.map +1 -1
  91. package/dist-types/core/html-to-blocks.d.ts +10 -0
  92. package/dist-types/core/html-to-blocks.d.ts.map +1 -0
  93. package/dist-types/core/i18n.d.ts +44 -0
  94. package/dist-types/core/i18n.d.ts.map +1 -1
  95. package/dist-types/core/import-html.d.ts +0 -13
  96. package/dist-types/core/import-html.d.ts.map +1 -1
  97. package/dist-types/core/import-markdown.d.ts.map +1 -1
  98. package/dist-types/core/insert-fragment.d.ts +21 -0
  99. package/dist-types/core/insert-fragment.d.ts.map +1 -0
  100. package/dist-types/core/markdown-export.d.ts.map +1 -1
  101. package/dist-types/core/paste-clean.d.ts +36 -0
  102. package/dist-types/core/paste-clean.d.ts.map +1 -0
  103. package/dist-types/core/render-string.d.ts.map +1 -1
  104. package/dist-types/core/sanitize-dom.d.ts +21 -0
  105. package/dist-types/core/sanitize-dom.d.ts.map +1 -0
  106. package/dist-types/core/sanitize-html.d.ts +8 -0
  107. package/dist-types/core/sanitize-html.d.ts.map +1 -0
  108. package/dist-types/core/sanitize-policy.d.ts +22 -0
  109. package/dist-types/core/sanitize-policy.d.ts.map +1 -0
  110. package/dist-types/core/selection.d.ts +5 -0
  111. package/dist-types/core/selection.d.ts.map +1 -1
  112. package/dist-types/core/snapshot.d.ts.map +1 -1
  113. package/dist-types/core/table-grid.d.ts +87 -0
  114. package/dist-types/core/table-grid.d.ts.map +1 -0
  115. package/dist-types/core/table-ops.d.ts +2 -22
  116. package/dist-types/core/table-ops.d.ts.map +1 -1
  117. package/dist-types/highlight/index.d.ts +5 -0
  118. package/dist-types/highlight/index.d.ts.map +1 -0
  119. package/dist-types/index.d.ts +19 -11
  120. package/dist-types/index.d.ts.map +1 -1
  121. package/dist-types/server/index.d.ts +4 -5
  122. package/dist-types/server/index.d.ts.map +1 -1
  123. package/dist-types/types/index.d.ts +63 -15
  124. package/dist-types/types/index.d.ts.map +1 -1
  125. package/dist-types/ui/Toolbar.d.ts +10 -0
  126. package/dist-types/ui/Toolbar.d.ts.map +1 -1
  127. package/dist-types/ui/doc-tools.d.ts +58 -0
  128. package/dist-types/ui/doc-tools.d.ts.map +1 -0
  129. package/dist-types/ui/icons.d.ts.map +1 -1
  130. package/dist-types/ui/popovers.d.ts +14 -25
  131. package/dist-types/ui/popovers.d.ts.map +1 -1
  132. package/package.json +70 -5
@@ -1,56 +1,69 @@
1
- "use strict";var kn=Object.defineProperty;var wn=(t,e,n)=>e in t?kn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var b=(t,e,n)=>wn(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Nt={items:["blockType","|","fontFamily","fontSize","|","bold","italic","underline","strike","|","color","backgroundColor","|","align","|","cellBg","tableMenu","codeLang"],sticky:!0},vn={toolbar:{ariaLabel:"Formatting toolbar",undo:"Undo",redo:"Redo",blockType:"Block type",fontFamily:"Font family",fontSize:"Font size",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",color:"Text color",backgroundColor:"Highlight color",align:"Align",cellBg:"Cell background",tableMenu:"Edit table",codeLang:"Code language",bulletList:"Bullet list",orderedList:"Numbered list",blockquote:"Blockquote",codeBlock:"Code block",link:"Link",image:"Image",table:"Table",hr:"Divider",clearFormat:"Clear formatting",blockTypeChangeTooltip:"Change block type",blockMoveTooltip:"Drag to move block",addBelowTooltip:"Add paragraph below"},blocks:{paragraph:"Body",heading:"Heading {n}",bulletList:"Bullet list",orderedList:"Numbered list",taskList:"Checklist",blockquote:"Blockquote",codeBlock:"Code",image:"Image",table:"Table",hr:"Divider",linkCard:"Link",youtube:"YouTube",file:"File",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"Body",taskList:"Checklist",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",bulletList:"Bullet list",orderedList:"Numbered list",blockquote:"Blockquote",codeBlock:"Code block",hr:"Divider",link:"Link",image:"Image",table:"Table",youtube:"YouTube",file:"File",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"Align left",center:"Align center",right:"Align right",justify:"Justify"},color:{customColor:"Custom",defaultColor:"Default",recent:"Recent"},tableMenu:{rowAbove:"Insert row above",rowBelow:"Insert row below",colLeft:"Insert column left",colRight:"Insert column right",deleteRow:"Delete row",deleteCol:"Delete column"},fontFamily:{systemDefault:"System default"},blockAlign:{left:"Align left",center:"Align center",right:"Align right"},comingSoon:{label:"Coming soon"},dialogs:{confirm:"OK",cancel:"Cancel",insert:"Insert",apply:"Apply",importBtn:"Import",close:"Close",selectedFileNone:"No file selected",dropOrClick:"Drag & drop or click"},link:{title:"Insert link",text:"Display text",textPlaceholder:"Text to show",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"Open in new window"},image:{title:"Image",embedTab:"Embed",embedTabTitle:"Insert image as base64 data URL",urlTab:"URL",urlTabTitle:"Image URL",uploadTab:"Upload",uploadTabTitle:"Upload to server, use response URL",uploadDisabledTitle:"No upload API registered",embedDropzone:"Select image (base64 embed)",urlLabel:"Image URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"Select image to upload",noUploadApi:"No upload API registered.",captionAdd:"Add caption",captionPlaceholder:"Write a caption"},youtube:{title:"YouTube embed",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"Supports youtu.be / youtube.com/watch / /embed / /shorts"},table:{title:"Insert table",statusZero:"0 × 0 table",statusFormat:"{r} × {c} table",pickerHint:"Select size"},importHtml:{title:"HTML",fileSelect:"Select HTML file",pasteLabel:"Paste directly",pastePlaceholder:"or paste HTML here…",hint:"Loads via iframe and bakes all styles inline.",errEmpty:"HTML to import is empty.",errNoBody:"No body content found in HTML.",errFailed:"HTML import failed: "},importMarkdown:{title:"Markdown",fileSelect:"Select Markdown file",pasteLabel:"Paste directly",pastePlaceholder:"or paste Markdown here…",hint:"Supports CommonMark basics (headings/lists/links/code/tables/quotes).",errEmpty:"Markdown to import is empty.",errNoBody:"No content found in Markdown.",errFailed:"Markdown parse failed: "},fileAttach:{title:"Attach file",urlTab:"URL",urlTabTitle:"Direct URL of a hosted file",uploadTab:"Upload",uploadTabTitle:"Upload to server, use response URL",uploadDisabledTitle:"No file upload API registered",urlLabel:"File URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"File name",namePlaceholder:"Display name (e.g., report.pdf)",noUploadApi:"No file upload API registered.",uploadDropzone:"Select file to upload",uploadComplete:" — uploaded",uploadFailed:"Upload failed: ",errEmpty:"File URL is empty."},content:{emptyHint:"Write something…"},status:{noActive:"— no active block",blocksCount:"{n} block(s)",chars:"{n} char(s)",source:"src {n}"}},It={toolbar:{ariaLabel:"서식 도구 모음",undo:"되돌리기",redo:"다시 실행",blockType:"블록 유형",fontFamily:"글꼴",fontSize:"글자 크기",bold:"굵게",italic:"기울임",underline:"밑줄",strike:"취소선",color:"글자색",backgroundColor:"배경색",align:"정렬",cellBg:"셀 배경색",tableMenu:"표 편집",codeLang:"코드 언어",bulletList:"글머리 기호",orderedList:"번호 매기기",blockquote:"인용구",codeBlock:"코드 블록",link:"링크",image:"이미지",table:"표",hr:"구분선",clearFormat:"서식 지우기",blockTypeChangeTooltip:"블록 유형 변경",blockMoveTooltip:"드래그로 블록 이동",addBelowTooltip:"아래에 단락 추가"},blocks:{paragraph:"본문",heading:"제목 {n}",bulletList:"글머리 목록",orderedList:"번호 목록",taskList:"체크리스트",blockquote:"인용구",codeBlock:"코드",image:"이미지",table:"표",hr:"구분선",linkCard:"링크",youtube:"유튜브",file:"파일",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"본문",taskList:"체크리스트",h1:"제목 1",h2:"제목 2",h3:"제목 3",bulletList:"글머리 목록",orderedList:"번호 매기기 목록",blockquote:"인용구",codeBlock:"코드 블록",hr:"구분선",link:"링크",image:"이미지",table:"표",youtube:"유튜브",file:"파일 첨부",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"왼쪽 정렬",center:"가운데 정렬",right:"오른쪽 정렬",justify:"양쪽 정렬"},color:{customColor:"사용자 지정",defaultColor:"기본색",recent:"최근 사용"},tableMenu:{rowAbove:"위에 행 추가",rowBelow:"아래에 행 추가",colLeft:"왼쪽에 열 추가",colRight:"오른쪽에 열 추가",deleteRow:"행 삭제",deleteCol:"열 삭제"},fontFamily:{systemDefault:"시스템 기본"},blockAlign:{left:"왼쪽 정렬",center:"가운데 정렬",right:"오른쪽 정렬"},comingSoon:{label:"기능 준비 중"},dialogs:{confirm:"확인",cancel:"취소",insert:"삽입",apply:"적용",importBtn:"가져오기",close:"닫기",selectedFileNone:"선택된 파일 없음",dropOrClick:"드래그 앤 드롭 또는 클릭"},link:{title:"링크 삽입",text:"표시할 텍스트",textPlaceholder:"링크에 표시할 텍스트",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"새 창에서 열기"},image:{title:"이미지",embedTab:"임베드",embedTabTitle:"base64 데이터로 본문에 직접 삽입",urlTab:"URL",urlTabTitle:"이미지 URL 입력",uploadTab:"업로드",uploadTabTitle:"서버 API 로 업로드 후 결과 URL 사용",uploadDisabledTitle:"개체 생성시 등록된 API 주소가 없습니다.",embedDropzone:"이미지 파일 선택 (base64 임베드)",urlLabel:"이미지 URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"서버 업로드용 이미지 선택",noUploadApi:"개체 생성시 등록된 API 주소가 없습니다.",captionAdd:"캡션 추가",captionPlaceholder:"캡션을 입력하세요"},youtube:{title:"유튜브 임베드",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"youtu.be / youtube.com/watch / /embed / /shorts 형식 모두 지원"},table:{title:"표 삽입",statusZero:"0 × 0 표",statusFormat:"{r} × {c} 표",pickerHint:"크기를 선택하세요"},importHtml:{title:"HTML",fileSelect:"HTML 파일 선택",pasteLabel:"직접 붙여넣기",pastePlaceholder:"또는 HTML 을 직접 붙여넣기…",hint:"iframe 으로 로드한 후 모든 스타일을 인라인으로 합쳐 가져옵니다.",errEmpty:"가져올 HTML 이 비어 있습니다.",errNoBody:"HTML 에서 가져올 본문이 없습니다.",errFailed:"HTML 가져오기 실패: "},importMarkdown:{title:"Markdown",fileSelect:"Markdown 파일 선택",pasteLabel:"직접 붙여넣기",pastePlaceholder:"또는 Markdown 을 직접 붙여넣기…",hint:"CommonMark 기본 문법(제목/목록/링크/코드/표/인용 등) 지원",errEmpty:"가져올 Markdown 이 비어 있습니다.",errNoBody:"Markdown 에서 가져올 본문이 없습니다.",errFailed:"Markdown 가져오기 실패: "},fileAttach:{title:"파일 첨부",urlTab:"URL",urlTabTitle:"이미 호스팅된 파일의 URL 직접 입력",uploadTab:"업로드",uploadTabTitle:"서버 API 로 업로드 후 응답 URL 사용",uploadDisabledTitle:"개체 생성시 등록된 파일 업로드 API 가 없습니다.",urlLabel:"파일 URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"파일명",namePlaceholder:"표시할 파일명 (예: report.pdf)",noUploadApi:"개체 생성시 등록된 파일 업로드 API 가 없습니다.",uploadDropzone:"서버 업로드용 파일 선택",uploadComplete:" — 업로드 완료",uploadFailed:"업로드 실패: ",errEmpty:"파일 URL 이 비어 있습니다."},content:{emptyHint:"내용을 입력하세요"},status:{noActive:"— 선택된 블록 없음",blocksCount:"{n} 블록",chars:"텍스트 {n} 자",source:"소스 {n}"}},Cn={toolbar:{ariaLabel:"書式ツールバー",undo:"元に戻す",redo:"やり直す",blockType:"ブロックの種類",fontFamily:"フォント",fontSize:"文字サイズ",bold:"太字",italic:"斜体",underline:"下線",strike:"取り消し線",color:"文字色",backgroundColor:"蛍光色",align:"配置",cellBg:"セル背景色",tableMenu:"表の編集",codeLang:"コード言語",bulletList:"箇条書き",orderedList:"番号付きリスト",blockquote:"引用",codeBlock:"コードブロック",link:"リンク",image:"画像",table:"表",hr:"区切り線",clearFormat:"書式をクリア",blockTypeChangeTooltip:"ブロックの種類を変更",blockMoveTooltip:"ドラッグでブロックを移動",addBelowTooltip:"下に段落を追加"},blocks:{paragraph:"本文",heading:"見出し {n}",bulletList:"箇条書き",orderedList:"番号リスト",taskList:"チェックリスト",blockquote:"引用",codeBlock:"コード",image:"画像",table:"表",hr:"区切り線",linkCard:"リンク",youtube:"YouTube",file:"ファイル",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"本文",taskList:"チェックリスト",h1:"見出し 1",h2:"見出し 2",h3:"見出し 3",bulletList:"箇条書き",orderedList:"番号付きリスト",blockquote:"引用",codeBlock:"コードブロック",hr:"区切り線",link:"リンク",image:"画像",table:"表",youtube:"YouTube",file:"ファイル添付",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"左揃え",center:"中央揃え",right:"右揃え",justify:"両端揃え"},color:{customColor:"カスタム",defaultColor:"デフォルト",recent:"最近使用"},tableMenu:{rowAbove:"上に行を追加",rowBelow:"下に行を追加",colLeft:"左に列を追加",colRight:"右に列を追加",deleteRow:"行を削除",deleteCol:"列を削除"},fontFamily:{systemDefault:"システム標準"},blockAlign:{left:"左揃え",center:"中央揃え",right:"右揃え"},comingSoon:{label:"準備中"},dialogs:{confirm:"OK",cancel:"キャンセル",insert:"挿入",apply:"適用",importBtn:"インポート",close:"閉じる",selectedFileNone:"ファイル未選択",dropOrClick:"ドラッグ&ドロップまたはクリック"},link:{title:"リンクを挿入",text:"表示するテキスト",textPlaceholder:"リンクに表示するテキスト",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"新しいウィンドウで開く"},image:{title:"画像",embedTab:"埋め込み",embedTabTitle:"base64 データとして本文に直接挿入",urlTab:"URL",urlTabTitle:"画像 URL の入力",uploadTab:"アップロード",uploadTabTitle:"サーバー API でアップロード後、結果 URL を使用",uploadDisabledTitle:"API が登録されていません。",embedDropzone:"画像ファイルを選択 (base64 埋め込み)",urlLabel:"画像 URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"アップロードする画像を選択",noUploadApi:"API が登録されていません。",captionAdd:"キャプション追加",captionPlaceholder:"キャプションを入力"},youtube:{title:"YouTube 埋め込み",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"youtu.be / youtube.com/watch / /embed / /shorts に対応"},table:{title:"表を挿入",statusZero:"0 × 0 表",statusFormat:"{r} × {c} 表",pickerHint:"サイズを選択"},importHtml:{title:"HTML",fileSelect:"HTML ファイルを選択",pasteLabel:"直接貼り付け",pastePlaceholder:"または HTML を直接貼り付け…",hint:"iframe で読み込み、全スタイルをインラインに変換します。",errEmpty:"インポートする HTML が空です。",errNoBody:"HTML に本文がありません。",errFailed:"HTML インポート失敗: "},importMarkdown:{title:"Markdown",fileSelect:"Markdown ファイルを選択",pasteLabel:"直接貼り付け",pastePlaceholder:"または Markdown を直接貼り付け…",hint:"CommonMark の基本構文(見出し/リスト/リンク/コード/表/引用)に対応",errEmpty:"インポートする Markdown が空です。",errNoBody:"Markdown に本文がありません。",errFailed:"Markdown 解析失敗: "},fileAttach:{title:"ファイル添付",urlTab:"URL",urlTabTitle:"ホスト済みファイルの URL を直接入力",uploadTab:"アップロード",uploadTabTitle:"サーバー API でアップロード後、応答 URL を使用",uploadDisabledTitle:"ファイルアップロード API が登録されていません",urlLabel:"ファイル URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"ファイル名",namePlaceholder:"表示名 (例: report.pdf)",noUploadApi:"ファイルアップロード API が登録されていません。",uploadDropzone:"アップロードするファイルを選択",uploadComplete:" — アップロード完了",uploadFailed:"アップロード失敗: ",errEmpty:"ファイル URL が空です。"},content:{emptyHint:"テキストを入力"},status:{noActive:"— アクティブなブロックなし",blocksCount:"{n} ブロック",chars:"テキスト {n} 字",source:"ソース {n}"}},Ln={toolbar:{ariaLabel:"格式工具栏",undo:"撤销",redo:"重做",blockType:"块类型",fontFamily:"字体",fontSize:"字号",bold:"加粗",italic:"斜体",underline:"下划线",strike:"删除线",color:"文字颜色",backgroundColor:"高亮颜色",align:"对齐",cellBg:"单元格背景",tableMenu:"编辑表格",codeLang:"代码语言",bulletList:"项目符号",orderedList:"编号列表",blockquote:"引用",codeBlock:"代码块",link:"链接",image:"图片",table:"表格",hr:"分隔线",clearFormat:"清除格式",blockTypeChangeTooltip:"更改块类型",blockMoveTooltip:"拖动以移动块",addBelowTooltip:"在下方添加段落"},blocks:{paragraph:"正文",heading:"标题 {n}",bulletList:"项目符号",orderedList:"编号列表",taskList:"清单",blockquote:"引用",codeBlock:"代码",image:"图片",table:"表格",hr:"分隔线",linkCard:"链接",youtube:"YouTube",file:"文件",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"正文",taskList:"清单",h1:"标题 1",h2:"标题 2",h3:"标题 3",bulletList:"项目符号",orderedList:"编号列表",blockquote:"引用",codeBlock:"代码块",hr:"分隔线",link:"链接",image:"图片",table:"表格",youtube:"YouTube",file:"附件",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"左对齐",center:"居中对齐",right:"右对齐",justify:"两端对齐"},color:{customColor:"自定义",defaultColor:"默认",recent:"最近使用"},tableMenu:{rowAbove:"在上方插入行",rowBelow:"在下方插入行",colLeft:"在左侧插入列",colRight:"在右侧插入列",deleteRow:"删除行",deleteCol:"删除列"},fontFamily:{systemDefault:"系统默认"},blockAlign:{left:"左对齐",center:"居中对齐",right:"右对齐"},comingSoon:{label:"功能开发中"},dialogs:{confirm:"确定",cancel:"取消",insert:"插入",apply:"应用",importBtn:"导入",close:"关闭",selectedFileNone:"未选择文件",dropOrClick:"拖放或点击"},link:{title:"插入链接",text:"显示文本",textPlaceholder:"要显示的文本",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"在新窗口中打开"},image:{title:"图片",embedTab:"嵌入",embedTabTitle:"以 base64 数据嵌入",urlTab:"URL",urlTabTitle:"图片 URL",uploadTab:"上传",uploadTabTitle:"上传到服务器,使用响应 URL",uploadDisabledTitle:"未注册上传 API",embedDropzone:"选择图片 (base64 嵌入)",urlLabel:"图片 URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"选择要上传的图片",noUploadApi:"未注册上传 API。",captionAdd:"添加说明",captionPlaceholder:"输入图片说明"},youtube:{title:"YouTube 嵌入",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"支持 youtu.be / youtube.com/watch / /embed / /shorts"},table:{title:"插入表格",statusZero:"0 × 0 表格",statusFormat:"{r} × {c} 表格",pickerHint:"选择尺寸"},importHtml:{title:"HTML",fileSelect:"选择 HTML 文件",pasteLabel:"直接粘贴",pastePlaceholder:"或在此处粘贴 HTML…",hint:"通过 iframe 加载并将所有样式内联化导入。",errEmpty:"要导入的 HTML 为空。",errNoBody:"HTML 中未找到内容。",errFailed:"HTML 导入失败: "},importMarkdown:{title:"Markdown",fileSelect:"选择 Markdown 文件",pasteLabel:"直接粘贴",pastePlaceholder:"或在此处粘贴 Markdown…",hint:"支持 CommonMark 基础语法(标题/列表/链接/代码/表格/引用)",errEmpty:"要导入的 Markdown 为空。",errNoBody:"Markdown 中未找到内容。",errFailed:"Markdown 解析失败: "},fileAttach:{title:"附加文件",urlTab:"URL",urlTabTitle:"直接输入已托管文件的 URL",uploadTab:"上传",uploadTabTitle:"上传到服务器,使用响应 URL",uploadDisabledTitle:"未注册文件上传 API",urlLabel:"文件 URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"文件名",namePlaceholder:"显示名称 (例如: report.pdf)",noUploadApi:"未注册文件上传 API。",uploadDropzone:"选择要上传的文件",uploadComplete:" — 上传完成",uploadFailed:"上传失败: ",errEmpty:"文件 URL 为空。"},content:{emptyHint:"输入内容"},status:{noActive:"— 无活动块",blocksCount:"{n} 块",chars:"文本 {n} 字",source:"源 {n}"}},xn={en:vn,ko:It,ja:Cn,zh:Ln};let Ht=It,Rt="ko";function zt(t){Rt=t,Ht=xn[t]}function En(){return Rt}function p(){return Ht}function se(t,e){return t.replace(/\{(\w+)\}/g,(n,o)=>String(e[o]??""))}const A={taskList:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 7 5 9 9 5"/><polyline points="3 17 5 19 9 15"/><line x1="13" y1="7" x2="21" y2="7"/><line x1="13" y1="17" x2="21" y2="17"/></svg>',undo:'<svg 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-15-6.7L3 13"/></svg>',redo:'<svg 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 15-6.7L21 13"/></svg>',blockType:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="5" rx="1.2"/><line x1="3" y1="13" x2="21" y2="13"/><line x1="3" y1="17" x2="21" y2="17"/><line x1="3" y1="21" x2="14" y2="21"/></svg>',fontFamily:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18 L7 6 L11 18"/><line x1="4.5" y1="14" x2="9.5" y2="14"/><path d="M14 12 a3 3 0 1 1 0 6 a3 3 0 0 1 0 -6"/><line x1="20" y1="12" x2="20" y2="18"/></svg>',fontSize:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6 L13 6"/><line x1="8" y1="6" x2="8" y2="19"/><polyline points="17 9 20 6 17 6"/><line x1="20" y1="6" x2="20" y2="18"/><polyline points="17 15 20 18 17 18"/></svg>',bold:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4h8a4 4 0 0 1 0 8H6z"/><path d="M6 12h9a4 4 0 0 1 0 8H6z"/></svg>',italic:'<svg 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 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 12 0V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>',strike:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',color:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16"/><path d="M6 17l5-12 2-1 2 1 5 12"/><path d="M8 13h8"/></svg>',backgroundColor:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12l9-9 9 9-9 9z"/><path d="M3 12h18"/></svg>',alignLeft:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>',alignCenter:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>',alignRight:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>',alignJustify:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="3" y2="18"/></svg>',bulletList:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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.5" cy="6" r="1.5" fill="currentColor"/><circle cx="4.5" cy="12" r="1.5" fill="currentColor"/><circle cx="4.5" cy="18" r="1.5" fill="currentColor"/></svg>',orderedList:'<svg 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-1.5-2-1"/></svg>',blockquote:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>',codeBlock:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',link:'<svg viewBox="0 0 24 24" 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 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" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',table:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',hr:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="12" x2="20" y2="12"/></svg>',clearFormat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7V4h16v3"/><path d="M5 20h6"/><path d="M13 4 8 20"/><line x1="15" y1="15" x2="20" y2="20"/><line x1="20" y1="15" x2="15" y2="20"/></svg>',chevronDown:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>',close:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>',upload:'<svg 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="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>',externalLink:'<svg 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>',youtube:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="20" height="12" rx="3"/><polygon points="10 9.5 15 12 10 14.5" fill="currentColor" stroke="none"/></svg>',importHtml:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h11l5 5v11a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><path d="M14 4v5h5"/><path d="M12 12v6"/><polyline points="9 15 12 18 15 15"/></svg>',importMarkdown:'<svg 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="2"/><path d="M6 15V9l3 3 3-3v6"/><path d="M16 9v6"/><polyline points="14 13 16 15 18 13"/></svg>',attachFile:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57a4 4 0 0 1 5.66 5.66l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',cellBg:'<svg 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.5"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/><rect x="3" y="3" width="9" height="9" fill="currentColor" opacity="0.35" stroke="none"/></svg>',tableMenu:'<svg 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.5"/><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>',codeLang:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/><line x1="14" y1="4" x2="10" y2="20"/></svg>'};function An(){const t=p().toolbar;return{undo:{name:"undo",label:t.undo,icon:"undo",shortcut:"Ctrl+Z"},redo:{name:"redo",label:t.redo,icon:"redo",shortcut:"Ctrl+Y"},blockType:{name:"blockType",label:t.blockType,icon:"blockType",hasDropdown:!0,shortcut:"Ctrl+Alt+0~9"},fontFamily:{name:"fontFamily",label:t.fontFamily,icon:"fontFamily",hasDropdown:!0},fontSize:{name:"fontSize",label:t.fontSize,icon:"fontSize",hasDropdown:!0},bold:{name:"bold",label:t.bold,icon:"bold",shortcut:"Ctrl+B"},italic:{name:"italic",label:t.italic,icon:"italic",shortcut:"Ctrl+I"},underline:{name:"underline",label:t.underline,icon:"underline",shortcut:"Ctrl+U"},strike:{name:"strike",label:t.strike,icon:"strike",shortcut:"Ctrl+Shift+X"},color:{name:"color",label:t.color,icon:"color",hasDropdown:!0},backgroundColor:{name:"backgroundColor",label:t.backgroundColor,icon:"backgroundColor",hasDropdown:!0},align:{name:"align",label:t.align,icon:"alignLeft",hasDropdown:!0},cellBg:{name:"cellBg",label:t.cellBg,icon:"cellBg",hasDropdown:!0},tableMenu:{name:"tableMenu",label:t.tableMenu,icon:"tableMenu",hasDropdown:!0},codeLang:{name:"codeLang",label:t.codeLang,icon:"codeLang",hasDropdown:!0},bulletList:{name:"bulletList",label:t.bulletList,icon:"bulletList",shortcut:"Ctrl+Alt+8"},orderedList:{name:"orderedList",label:t.orderedList,icon:"orderedList",shortcut:"Ctrl+Alt+7"},blockquote:{name:"blockquote",label:t.blockquote,icon:"blockquote",shortcut:"Ctrl+Alt+9"},codeBlock:{name:"codeBlock",label:t.codeBlock,icon:"codeBlock",shortcut:"Ctrl+Alt+C"},link:{name:"link",label:t.link,icon:"link"},image:{name:"image",label:t.image,icon:"image"},table:{name:"table",label:t.table,icon:"table"},hr:{name:"hr",label:t.hr,icon:"hr"},clearFormat:{name:"clearFormat",label:t.clearFormat,icon:"clearFormat"}}}class Tn{constructor(e,n){b(this,"element");b(this,"buttons",new Map);this.element=document.createElement("div"),this.element.className="aw-toolbar",this.element.setAttribute("role","toolbar"),this.element.setAttribute("aria-label",p().toolbar.ariaLabel),e.sticky!==!1&&this.element.classList.add("aw-toolbar-sticky");const o=An();let l=this.createGroup();this.element.appendChild(l);for(const i of e.items){if(i==="|"){l=this.createGroup(),this.element.appendChild(l);continue}const r=o[i];if(!r)continue;const s=this.createButton(r,n);this.buttons.set(r.name,s),l.appendChild(s)}}setActive(e,n){const o=this.buttons.get(e);o&&(o.classList.toggle("aw-toolbar-btn-active",n),o.setAttribute("aria-pressed",String(n)))}setEnabled(e,n){const o=this.buttons.get(e);o&&(o.disabled=!n)}setVisible(e,n){const o=this.buttons.get(e);o&&(o.style.display=n?"":"none")}syncGroupVisibility(){const e=this.element.querySelectorAll(".aw-toolbar-group");for(const n of Array.from(e)){const o=Array.from(n.children).some(l=>l instanceof HTMLElement&&l.style.display!=="none");n.style.display=o?"":"none"}}createGroup(){const e=document.createElement("div");return e.className="aw-toolbar-group",e}createButton(e,n){const o=document.createElement("button");o.type="button",o.className="aw-toolbar-btn",e.hasDropdown&&o.classList.add("aw-toolbar-btn-dropdown");const l=e.shortcut?`${e.label} (${e.shortcut})`:e.label;o.title=l,o.setAttribute("aria-label",l),o.dataset.command=e.name;const i=A[e.icon]??"";return o.innerHTML=`<span class="aw-toolbar-btn-icon">${i}</span>`,e.hasDropdown&&(o.innerHTML+=`<span class="aw-toolbar-btn-chevron">${A.chevronDown}</span>`),o.addEventListener("mousedown",r=>{r.preventDefault()}),o.addEventListener("click",()=>{n.onAction(e.name,o)}),o}}function oe(t,e,n){const o=document.createElement("div");o.className="aw-dialog-overlay",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),e&&(o.dataset.theme=e);const l=document.createElement("div");l.className="aw-dialog";const i=document.createElement("div");i.className="aw-dialog-header";const r=document.createElement("h2");r.className="aw-dialog-title",r.textContent=t;const s=document.createElement("button");s.type="button",s.className="aw-dialog-close",s.innerHTML=A.close,i.appendChild(r),i.appendChild(s);const a=document.createElement("div");a.className="aw-dialog-body";const c=document.createElement("div");c.className="aw-dialog-footer",l.appendChild(i),l.appendChild(a),l.appendChild(c),o.appendChild(l);let d=!1;const u=f=>{f.key==="Escape"&&m()},h=()=>{d||(d=!0,document.removeEventListener("keydown",u),o.remove())},m=()=>{d||(h(),n==null||n())};return s.setAttribute("aria-label",p().dialogs.close),s.addEventListener("click",m),o.addEventListener("click",f=>{f.target===o&&m()}),document.addEventListener("keydown",u),{overlay:o,body:a,footer:c,close:h}}function O(t,e){const n=document.createElement("div");n.className="aw-field";const o=document.createElement("label");return o.className="aw-field-label",o.textContent=t,n.appendChild(o),n.appendChild(e),n}function Sn(t={},e){return new Promise(n=>{const{overlay:o,body:l,footer:i,close:r}=oe(p().link.title,e,()=>n({confirmed:!1})),s=document.createElement("input");s.type="text",s.className="aw-input",s.placeholder=p().link.textPlaceholder,s.value=t.text??"";const a=document.createElement("input");a.type="url",a.className="aw-input",a.placeholder=p().link.urlPlaceholder,a.value=t.href??"";const c=document.createElement("label");c.className="aw-checkbox";const d=document.createElement("input");d.type="checkbox",d.checked=t.newWindow??!1;const u=document.createElement("span");u.textContent=p().link.openNewWindow,c.appendChild(d),c.appendChild(u),l.appendChild(O(p().link.text,s)),l.appendChild(O(p().link.url,a)),l.appendChild(c);const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-ghost",h.textContent=p().dialogs.cancel;const m=document.createElement("button");m.type="button",m.className="aw-btn aw-btn-primary",m.textContent=p().dialogs.confirm,i.appendChild(h),i.appendChild(m),h.addEventListener("click",()=>{r(),n({confirmed:!1})}),m.addEventListener("click",()=>{r(),n({confirmed:!0,text:s.value,href:a.value,newWindow:d.checked})}),document.body.appendChild(o),setTimeout(()=>a.focus(),0)})}function Bn(t={},e){return new Promise(n=>{const{overlay:o,body:l,footer:i,close:r}=oe(p().image.title,e,()=>n({confirmed:!1})),s=document.createElement("div");s.className="aw-tabs";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent=p().image.embedTab,a.title=p().image.embedTabTitle;const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent=p().image.urlTab,c.title=p().image.urlTabTitle;const d=document.createElement("button");d.type="button",d.className="aw-tab",d.textContent=p().image.uploadTab;const u=!!t.onUpload;u?d.title=p().image.uploadTabTitle:(d.disabled=!0,d.classList.add("aw-tab-disabled"),d.title=p().image.uploadDisabledTitle),s.appendChild(a),s.appendChild(c),s.appendChild(d),l.appendChild(s);const h=document.createElement("div");h.className="aw-pane";const m=at(p().image.embedDropzone),f=document.createElement("div");f.className="aw-preview",f.style.display="none",h.appendChild(m.dropzone),h.appendChild(f);const g=document.createElement("div");g.className="aw-pane";const k=document.createElement("input");k.type="url",k.className="aw-input",k.placeholder=p().image.urlPlaceholder,g.appendChild(O(p().image.urlLabel,k));const y=document.createElement("div");if(y.className="aw-pane",u){const w=at(p().image.uploadDropzone),L=document.createElement("div");L.className="aw-preview",L.style.display="none",y.appendChild(w.dropzone),y.appendChild(L),w.input.addEventListener("change",async()=>{var F;const D=(F=w.input.files)==null?void 0:F[0];if(!(!D||!t.onUpload))try{w.dropzone.classList.add("aw-dropzone-loading");const he=await t.onUpload(D);C=he,L.style.backgroundImage=`url(${JSON.stringify(he)})`,L.style.display="block"}catch(he){console.error(he)}finally{w.dropzone.classList.remove("aw-dropzone-loading"),w.input.value=""}})}else{const w=document.createElement("div");w.className="aw-pane-notice",w.textContent=p().image.noUploadApi,y.appendChild(w)}l.appendChild(h),l.appendChild(g),l.appendChild(y);let E="embed",$,C;const T=w=>{w==="upload"&&!u||(E=w,a.classList.toggle("aw-tab-active",w==="embed"),c.classList.toggle("aw-tab-active",w==="url"),d.classList.toggle("aw-tab-active",w==="upload"),h.style.display=w==="embed"?"block":"none",g.style.display=w==="url"?"block":"none",y.style.display=w==="upload"?"block":"none")};T(E),a.addEventListener("click",()=>T("embed")),c.addEventListener("click",()=>T("url")),d.addEventListener("click",()=>T("upload")),m.input.addEventListener("change",()=>{var D;const w=(D=m.input.files)==null?void 0:D[0];if(!w)return;const L=new FileReader;L.onload=()=>{const F=String(L.result??"");$=F,f.style.backgroundImage=`url(${JSON.stringify(F)})`,f.style.display="block",m.input.value=""},L.readAsDataURL(w)});const S=document.createElement("button");S.type="button",S.className="aw-btn aw-btn-ghost",S.textContent=p().dialogs.cancel;const N=document.createElement("button");N.type="button",N.className="aw-btn aw-btn-primary",N.textContent=p().dialogs.confirm,i.appendChild(S),i.appendChild(N),S.addEventListener("click",()=>{r(),n({confirmed:!1})}),N.addEventListener("click",()=>{let w;E==="embed"?w=$:E==="url"?w=k.value||void 0:E==="upload"&&(w=C),r();const L={confirmed:!0};w&&(L.src=w),n(L)}),document.body.appendChild(o)})}function at(t){const e=document.createElement("label");e.className="aw-dropzone",e.innerHTML=`
2
- ${A.upload}
3
- <div class="aw-dropzone-text">${t}<br/>${p().dialogs.dropOrClick}</div>
4
- `;const n=document.createElement("input");return n.type="file",n.accept="image/*",n.style.display="none",e.appendChild(n),{dropzone:e,input:n}}function $n(t){return new Promise(e=>{const{overlay:n,body:o,footer:l,close:i}=oe(p().importHtml.title,t,()=>e({confirmed:!1})),r=document.createElement("input");r.type="file",r.accept=".html,.htm,text/html",r.style.display="none";const s=document.createElement("label");s.className="aw-dropzone",s.innerHTML=`
5
- ${A.importHtml}
6
- <div class="aw-dropzone-text">${p().importHtml.fileSelect}<br/>${p().dialogs.dropOrClick}</div>
7
- `,s.appendChild(r);const a=document.createElement("div");a.className="aw-dialog-hint",a.textContent=p().dialogs.selectedFileNone;const c=document.createElement("textarea");c.className="aw-input aw-textarea",c.placeholder=p().importHtml.pastePlaceholder,c.rows=8,o.appendChild(s),o.appendChild(a),o.appendChild(O(p().importHtml.pasteLabel,c));const d=document.createElement("div");d.className="aw-dialog-hint",d.textContent=p().importHtml.hint,o.appendChild(d);let u;r.addEventListener("change",()=>{var k;const f=(k=r.files)==null?void 0:k[0];if(!f)return;const g=new FileReader;g.onload=()=>{u=String(g.result??""),c.value=u,a.textContent=`${f.name} (${f.size.toLocaleString()} bytes)`,r.value=""},g.readAsText(f)}),s.addEventListener("dragover",f=>{f.preventDefault(),s.classList.add("aw-dropzone-loading")}),s.addEventListener("dragleave",()=>{s.classList.remove("aw-dropzone-loading")}),s.addEventListener("drop",f=>{var y,E;f.preventDefault(),s.classList.remove("aw-dropzone-loading");const g=(E=(y=f.dataTransfer)==null?void 0:y.files)==null?void 0:E[0];if(!g)return;const k=new FileReader;k.onload=()=>{u=String(k.result??""),c.value=u,a.textContent=`${g.name} (${g.size.toLocaleString()} bytes)`},k.readAsText(g)});const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-ghost",h.textContent=p().dialogs.cancel;const m=document.createElement("button");m.type="button",m.className="aw-btn aw-btn-primary",m.textContent=p().dialogs.importBtn,l.appendChild(h),l.appendChild(m),h.addEventListener("click",()=>{i(),e({confirmed:!1})}),m.addEventListener("click",()=>{const f=c.value.trim();i();const g={confirmed:!0};f.length>0&&(g.html=f),e(g)}),document.body.appendChild(n)})}function Mn(t){return new Promise(e=>{const{overlay:n,body:o,footer:l,close:i}=oe(p().importMarkdown.title,t,()=>e({confirmed:!1})),r=document.createElement("input");r.type="file",r.accept=".md,.markdown,text/markdown,text/plain",r.style.display="none";const s=document.createElement("label");s.className="aw-dropzone",s.innerHTML=`
8
- ${A.importMarkdown}
9
- <div class="aw-dropzone-text">${p().importMarkdown.fileSelect}<br/>${p().dialogs.dropOrClick}</div>
10
- `,s.appendChild(r);const a=document.createElement("div");a.className="aw-dialog-hint",a.textContent=p().dialogs.selectedFileNone;const c=document.createElement("textarea");c.className="aw-input aw-textarea",c.placeholder=p().importMarkdown.pastePlaceholder,c.rows=8,o.appendChild(s),o.appendChild(a),o.appendChild(O(p().importMarkdown.pasteLabel,c));const d=document.createElement("div");d.className="aw-dialog-hint",d.textContent=p().importMarkdown.hint,o.appendChild(d),r.addEventListener("change",()=>{var g;const m=(g=r.files)==null?void 0:g[0];if(!m)return;const f=new FileReader;f.onload=()=>{const k=String(f.result??"");c.value=k,a.textContent=`${m.name} (${m.size.toLocaleString()} bytes)`,r.value=""},f.readAsText(m)}),s.addEventListener("dragover",m=>{m.preventDefault(),s.classList.add("aw-dropzone-loading")}),s.addEventListener("dragleave",()=>{s.classList.remove("aw-dropzone-loading")}),s.addEventListener("drop",m=>{var k,y;m.preventDefault(),s.classList.remove("aw-dropzone-loading");const f=(y=(k=m.dataTransfer)==null?void 0:k.files)==null?void 0:y[0];if(!f)return;const g=new FileReader;g.onload=()=>{const E=String(g.result??"");c.value=E,a.textContent=`${f.name} (${f.size.toLocaleString()} bytes)`},g.readAsText(f)});const u=document.createElement("button");u.type="button",u.className="aw-btn aw-btn-ghost",u.textContent=p().dialogs.cancel;const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-primary",h.textContent=p().dialogs.importBtn,l.appendChild(u),l.appendChild(h),u.addEventListener("click",()=>{i(),e({confirmed:!1})}),h.addEventListener("click",()=>{const m=c.value.trim();i();const f={confirmed:!0};m.length>0&&(f.markdown=m),e(f)}),document.body.appendChild(n)})}function Nn(t={},e){return new Promise(n=>{const{overlay:o,body:l,footer:i,close:r}=oe(p().fileAttach.title,e,()=>n({confirmed:!1})),s=document.createElement("div");s.className="aw-tabs";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent=p().fileAttach.urlTab,a.title=p().fileAttach.urlTabTitle;const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent=p().fileAttach.uploadTab;const d=!!t.onUpload;d?c.title=p().fileAttach.uploadTabTitle:(c.disabled=!0,c.classList.add("aw-tab-disabled"),c.title=p().fileAttach.uploadDisabledTitle),s.appendChild(a),s.appendChild(c),l.appendChild(s);const u=document.createElement("div");u.className="aw-pane";const h=document.createElement("input");h.type="url",h.className="aw-input",h.placeholder=p().fileAttach.urlPlaceholder,u.appendChild(O(p().fileAttach.urlLabel,h));const m=document.createElement("input");m.type="text",m.className="aw-input",m.placeholder=p().fileAttach.namePlaceholder,u.appendChild(O(p().fileAttach.nameLabel,m));const f=document.createElement("div");f.className="aw-pane";let g;if(d){const C=document.createElement("label");C.className="aw-dropzone",C.innerHTML=`
11
- ${A.upload}
12
- <div class="aw-dropzone-text">${p().fileAttach.uploadDropzone}<br/>${p().dialogs.dropOrClick}</div>
13
- `;const T=document.createElement("input");T.type="file",T.style.display="none",C.appendChild(T);const S=document.createElement("div");S.className="aw-dialog-hint",S.textContent=p().dialogs.selectedFileNone,f.appendChild(C),f.appendChild(S);const N=async w=>{if(t.onUpload)try{C.classList.add("aw-dropzone-loading"),g={src:await t.onUpload(w),name:w.name,size:w.size,type:w.type||""},S.textContent=`${w.name} (${w.size.toLocaleString()} bytes)${p().fileAttach.uploadComplete}`}catch(L){console.error(L),S.textContent=`${p().fileAttach.uploadFailed}${L instanceof Error?L.message:String(L)}`}finally{C.classList.remove("aw-dropzone-loading"),T.value=""}};T.addEventListener("change",()=>{var L;const w=(L=T.files)==null?void 0:L[0];w&&N(w)}),C.addEventListener("dragover",w=>{w.preventDefault(),C.classList.add("aw-dropzone-loading")}),C.addEventListener("dragleave",()=>{C.classList.remove("aw-dropzone-loading")}),C.addEventListener("drop",w=>{var D,F;w.preventDefault();const L=(F=(D=w.dataTransfer)==null?void 0:D.files)==null?void 0:F[0];L&&N(L)})}else{const C=document.createElement("div");C.className="aw-pane-notice",C.textContent=p().fileAttach.noUploadApi,f.appendChild(C)}l.appendChild(u),l.appendChild(f);let k="url";const y=C=>{C==="upload"&&!d||(k=C,a.classList.toggle("aw-tab-active",C==="url"),c.classList.toggle("aw-tab-active",C==="upload"),u.style.display=C==="url"?"block":"none",f.style.display=C==="upload"?"block":"none")};y(k),a.addEventListener("click",()=>y("url")),c.addEventListener("click",()=>y("upload"));const E=document.createElement("button");E.type="button",E.className="aw-btn aw-btn-ghost",E.textContent=p().dialogs.cancel;const $=document.createElement("button");$.type="button",$.className="aw-btn aw-btn-primary",$.textContent=p().dialogs.confirm,i.appendChild(E),i.appendChild($),E.addEventListener("click",()=>{r(),n({confirmed:!1})}),$.addEventListener("click",()=>{const C={confirmed:!0};if(k==="url"){const T=h.value.trim(),S=m.value.trim();T.length>0&&(C.src=T),S.length>0&&(C.name=S)}else g&&(C.src=g.src,C.name=g.name,C.size=g.size,g.type&&(C.type=g.type));r(),n(C)}),document.body.appendChild(o)})}function In(t){return new Promise(e=>{const{overlay:n,body:o,footer:l,close:i}=oe(p().youtube.title,t,()=>e({confirmed:!1})),r=document.createElement("input");r.type="url",r.className="aw-input",r.placeholder=p().youtube.urlPlaceholder,o.appendChild(O(p().youtube.urlLabel,r));const s=document.createElement("div");s.className="aw-dialog-hint",s.textContent=p().youtube.formatHint,o.appendChild(s);const a=document.createElement("button");a.type="button",a.className="aw-btn aw-btn-ghost",a.textContent=p().dialogs.cancel;const c=document.createElement("button");c.type="button",c.className="aw-btn aw-btn-primary",c.textContent=p().dialogs.confirm,l.appendChild(a),l.appendChild(c),a.addEventListener("click",()=>{i(),e({confirmed:!1})}),c.addEventListener("click",()=>{i(),e({confirmed:!0,url:r.value})}),document.body.appendChild(n),setTimeout(()=>r.focus(),0)})}const Dt="system",te=[{id:Dt,label:"시스템 기본",stack:'-apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif'},{id:"pretendard",label:"Pretendard",stack:'"Pretendard", -apple-system, sans-serif',cssUrl:"https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.min.css"},{id:"noto-sans-kr",label:"Noto Sans KR",stack:'"Noto Sans KR", sans-serif',googleFonts:"Noto+Sans+KR:wght@400;700"},{id:"noto-serif-kr",label:"Noto Serif KR",stack:'"Noto Serif KR", serif',googleFonts:"Noto+Serif+KR:wght@400;700"},{id:"nanum-gothic",label:"나눔고딕",stack:'"Nanum Gothic", sans-serif',googleFonts:"Nanum+Gothic:wght@400;700"},{id:"nanum-myeongjo",label:"나눔명조",stack:'"Nanum Myeongjo", serif',googleFonts:"Nanum+Myeongjo:wght@400;700"},{id:"nanum-pen",label:"나눔펜",stack:'"Nanum Pen Script", cursive',googleFonts:"Nanum+Pen+Script"},{id:"gowun-dodum",label:"고운 돋움",stack:'"Gowun Dodum", sans-serif',googleFonts:"Gowun+Dodum"},{id:"ibm-plex-sans-kr",label:"IBM Plex Sans KR",stack:'"IBM Plex Sans KR", sans-serif',googleFonts:"IBM+Plex+Sans+KR:wght@400;700"}];(()=>{const t={};for(const e of te)t[e.id]=e;return t})();const Hn=[12,13,14,15,16,18,20,24,28,32,40,48];function Rn(t){if(!t)return null;const e=t.trim(),n=/^(\d+(?:\.\d+)?)px$/i.exec(e);if(n&&n[1])return Math.round(Number(n[1]));const o=/^(\d+(?:\.\d+)?)rem$/i.exec(e);return o&&o[1]?Math.round(Number(o[1])*16):null}let ct=!1;const ve=new Set,qe=new Set,zn="가A";function Dn(){return ve.size===0?te:te.filter(t=>!ve.has(t.id))}function Fn(t){return qe.add(t),()=>{qe.delete(t)}}function Pn(t){const e=Ce(t);if(!e)return!1;const n=document.createElement("canvas").getContext("2d");if(!n)return!1;const o=l=>(n.font=`16px ${l}`,n.measureText("가나다ABCwi").width);return["monospace","serif"].some(l=>o(`"${e}", ${l}`)!==o(l))}function Ue(t){let e=!1;for(const n of t)ve.has(n.id)||Pn(n.stack)||(ve.add(n.id),e=!0);if(e)for(const n of qe)n()}function dt(t){const e=document.fonts;if(!(!e||typeof e.load!="function"))for(const n of t){const o=Ce(n.stack);o&&e.load(`16px "${o}"`,zn).then(l=>{l.length===0&&Ue([n])}).catch(()=>Ue([n]))}}function _n(){if(ct||(ct=!0,typeof document>"u"))return;const t=te.filter(e=>e.googleFonts);if(t.length>0){const e="https://fonts.googleapis.com/css2?"+t.map(n=>`family=${n.googleFonts}`).join("&")+"&display=swap";ut(e,t)}for(const e of te)e.cssUrl&&ut(e.cssUrl,[e])}function ut(t,e){if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`)){dt(e);return}const o=document.createElement("link");o.rel="stylesheet",o.href=t,o.addEventListener("error",()=>Ue(e)),o.addEventListener("load",()=>dt(e)),document.head.appendChild(o)}function On(t){var o;if(!t)return null;const e=Ce(t);if(!e)return null;const n=e.toLowerCase();for(const l of te){const i=(o=Ce(l.stack))==null?void 0:o.toLowerCase();if(i&&i===n)return l.id}return null}function Ce(t){var n;const e=(n=t.split(",")[0])==null?void 0:n.trim();return e?e.replace(/^["']|["']$/g,""):null}const H={lineComment:"//",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},Ft=new Set(["abstract","arguments","async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","new","null","of","package","private","protected","public","return","set","static","super","switch","this","throw","true","false","try","typeof","undefined","var","void","while","with","yield"]),qn=new Set([...Ft,"any","as","asserts","boolean","declare","infer","is","keyof","module","namespace","never","number","object","override","readonly","require","satisfies","string","symbol","type","unique","unknown"]),Un=new Set(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]),jn=new Set(["abs","all","any","bool","dict","enumerate","filter","float","int","isinstance","len","list","map","max","min","open","print","range","set","sorted","str","sum","tuple","type","zip","self","cls"]),Pt=new Set(["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","NULL"]),Wn=new Set([...Pt,"class","new","delete","try","catch","throw","template","typename","namespace","using","public","private","protected","virtual","override","this","nullptr","true","false","bool","explicit","friend","mutable","operator","reinterpret_cast","static_cast","dynamic_cast","const_cast","constexpr","decltype","noexcept","final","auto"]),Kn=new Set(["abstract","async","await","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","var","virtual","void","volatile","while","yield","record","init","nameof","when"]),Yn=new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","false","try","void","volatile","while","var","yield","record","sealed","permits","non-sealed"]),Gn=new Set(["abstract","actual","annotation","as","break","by","catch","class","companion","const","constructor","continue","crossinline","data","do","dynamic","else","enum","expect","external","false","final","finally","for","fun","get","if","import","in","init","inline","inner","interface","internal","is","it","lateinit","null","object","open","operator","out","override","package","private","protected","public","reified","return","sealed","set","super","suspend","tailrec","this","throw","true","try","typealias","typeof","val","var","vararg","when","where","while"]),Vn=new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","true","false","nil","iota"]),Zn=new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","unsafe","use","where","while","box","do","final","macro","override","priv","typeof","unsized","virtual","yield"]),Xn=new Set(["if","then","else","elif","fi","case","esac","for","while","until","do","done","function","return","select","break","continue","in","echo","export","local","readonly","declare","typeset","unset","eval","exec","source","true","false"]),Jn=new Set(["select","from","where","insert","update","delete","into","values","set","create","table","drop","alter","index","view","join","inner","left","right","outer","full","cross","on","group","by","order","having","limit","offset","union","all","distinct","as","and","or","not","null","true","false","is","in","between","like","exists","primary","key","foreign","references","unique","default","check","constraint","database","schema","with","case","when","then","else","end","cast","count","sum","avg","min","max","asc","desc"]),Qn=new Set(["true","false","null"]),_t=[{id:"plaintext",label:"Plain Text",keywords:new Set},{id:"javascript",label:"JavaScript",keywords:Ft,...H,stringDelims:['"',"'","`"]},{id:"typescript",label:"TypeScript",keywords:qn,...H,stringDelims:['"',"'","`"]},{id:"python",label:"Python",keywords:Un,builtins:jn,lineComment:"#",stringDelims:['"',"'"]},{id:"json",label:"JSON",keywords:Qn,stringDelims:['"']},{id:"html",label:"HTML",keywords:new Set,custom:t=>lo(t)},{id:"css",label:"CSS",keywords:new Set,custom:t=>ro(t)},{id:"bash",label:"Bash",keywords:Xn,lineComment:"#",stringDelims:['"',"'"]},{id:"sql",label:"SQL",keywords:Jn,caseInsensitiveKeywords:!0,lineComment:"--",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},{id:"markdown",label:"Markdown",keywords:new Set,custom:t=>so(t)},{id:"c",label:"C",keywords:Pt,...H},{id:"cpp",label:"C++",keywords:Wn,...H},{id:"csharp",label:"C#",keywords:Kn,...H},{id:"java",label:"Java",keywords:Yn,...H},{id:"kotlin",label:"Kotlin",keywords:Gn,...H},{id:"go",label:"Go",keywords:Vn,...H},{id:"rust",label:"Rust",keywords:Zn,...H}],eo=(()=>{const t=new Map;for(const e of _t)t.set(e.id,e);return t})();function to(t,e){if(!e)return v(t);const n=eo.get(e);return n?n.custom?n.custom(t):no(t,n):v(t)}function no(t,e){var r,s;const n=!!e.caseInsensitiveKeywords;let o="",l=0;const i=t.length;for(;l<i;){if(e.lineComment&&t.startsWith(e.lineComment,l)){const d=t.indexOf(`
14
- `,l),u=d===-1?i:d;o+=`<span class="hl-comment">${v(t.slice(l,u))}</span>`,l=u;continue}if(e.blockComment&&t.startsWith(e.blockComment.start,l)){const d=t.indexOf(e.blockComment.end,l+e.blockComment.start.length),u=d===-1?i:d+e.blockComment.end.length;o+=`<span class="hl-comment">${v(t.slice(l,u))}</span>`,l=u;continue}const a=(r=e.stringDelims)==null?void 0:r.find(d=>t.startsWith(d,l));if(a){let d=l+a.length;for(;d<i;){const u=t[d]??"";if(u==="\\"){d+=2;continue}if(t.startsWith(a,d)){d+=a.length;break}if(u===`
15
- `&&a!=="`")break;d++}o+=`<span class="hl-string">${v(t.slice(l,d))}</span>`,l=d;continue}const c=t[l]??"";if(/[0-9]/.test(c)){const d=oo.exec(t.slice(l));if(d){o+=`<span class="hl-number">${v(d[0])}</span>`,l+=d[0].length;continue}}if(/[a-zA-Z_$]/.test(c)){let d=l+1;for(;d<i&&/[a-zA-Z0-9_$]/.test(t[d]??"");)d++;const u=t.slice(l,d),h=n?u.toLowerCase():u;if(e.keywords.has(h))o+=`<span class="hl-keyword">${v(u)}</span>`;else if((s=e.builtins)!=null&&s.has(h))o+=`<span class="hl-builtin">${v(u)}</span>`;else{let m=d;for(;m<i&&(t[m]===" "||t[m]===" ");)m++;t[m]==="("?o+=`<span class="hl-fn">${v(u)}</span>`:o+=v(u)}l=d;continue}o+=v(c),l++}return o}const oo=/^(0[xX][0-9a-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|[0-9][0-9_]*(?:\.[0-9_]+)?(?:[eE][-+]?[0-9_]+)?)[a-zA-Z]*/;function lo(t){let e="",n=0;const o=t.length;for(;n<o;){if(t.startsWith("<!--",n)){const l=t.indexOf("-->",n+4),i=l===-1?o:l+3;e+=`<span class="hl-comment">${v(t.slice(n,i))}</span>`,n=i;continue}if(t[n]==="<"){const l=t.indexOf(">",n);if(l===-1){e+=v(t.slice(n));break}const i=t.slice(n,l+1);e+=io(i),n=l+1;continue}e+=v(t[n]??""),n++}return e}function io(t){const e=t.slice(1,-1);let n='<span class="hl-punct">&lt;</span>';const o=/^\/?[a-zA-Z][a-zA-Z0-9-]*/.exec(e);if(o){n+=`<span class="hl-tag">${v(o[0])}</span>`;let l=e.slice(o[0].length);const i=/\s+([a-zA-Z_:][a-zA-Z0-9_:.-]*)(\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+)))?/g;let r=0,s;for(;s=i.exec(l);){n+=v(l.slice(r,s.index)),n+=v(l.slice(s.index,s.index+s[0].indexOf(s[1]??""))),n+=`<span class="hl-attr">${v(s[1]??"")}</span>`;const a=l.slice(s.index+(s[0].indexOf(s[1]??"")+(s[1]??"").length),s.index+s[0].length);if(a.includes("=")){const c=a.indexOf("=");n+=v(a.slice(0,c+1));const d=a.slice(c+1);n+=`<span class="hl-string">${v(d)}</span>`}r=s.index+s[0].length}n+=v(l.slice(r))}else n+=v(e);return n+='<span class="hl-punct">&gt;</span>',n}function ro(t){let e="",n=0;const o=t.length;let l=!1;for(;n<o;){if(t.startsWith("/*",n)){const r=t.indexOf("*/",n+2),s=r===-1?o:r+2;e+=`<span class="hl-comment">${v(t.slice(n,s))}</span>`,n=s;continue}const i=t[n]??"";if(i==="{"){l=!0,e+=v(i),n++;continue}if(i==="}"){l=!1,e+=v(i),n++;continue}if(i==='"'||i==="'"){const r=i;let s=n+1;for(;s<o&&t[s]!==r;)t[s]==="\\"?s+=2:s++;s=Math.min(s+1,o),e+=`<span class="hl-string">${v(t.slice(n,s))}</span>`,n=s;continue}if(/[a-zA-Z_-]/.test(i)||i==="@"||i==="#"||i==="."||i===":"){let r=n+1;for(;r<o&&/[a-zA-Z0-9_-]/.test(t[r]??"");)r++;const s=t.slice(n,r);if(i==="@")e+=`<span class="hl-keyword">${v(s)}</span>`;else if(l&&/^[a-zA-Z-]+$/.test(s)){let a=r;for(;a<o&&(t[a]===" "||t[a]===" ");)a++;t[a]===":"?e+=`<span class="hl-prop">${v(s)}</span>`:e+=v(s)}else e+=`<span class="hl-tag">${v(s)}</span>`;n=r;continue}if(/[0-9]/.test(i)){const r=/^[0-9.]+(px|em|rem|%|vh|vw|s|ms|deg|fr)?/.exec(t.slice(n));if(r){e+=`<span class="hl-number">${v(r[0])}</span>`,n+=r[0].length;continue}}e+=v(i),n++}return e}function so(t){return t.split(`
16
- `).map(ao).join(`
17
- `)}function ao(t){const e=/^(#{1,6})\s+(.*)$/.exec(t);if(e)return`<span class="hl-keyword">${v(e[1]??"")}</span> <span class="hl-tag">${He(e[2]??"")}</span>`;if(t.startsWith(">"))return`<span class="hl-comment">${v(t)}</span>`;if(t.startsWith("```"))return`<span class="hl-keyword">${v(t)}</span>`;const n=/^(\s*)([-*+]|\d+\.)\s+(.*)$/.exec(t);return n?`${n[1]??""}<span class="hl-keyword">${v(n[2]??"")}</span> ${He(n[3]??"")}`:He(t)}function He(t){let e=v(t);return e=e.replace(/\*\*([^*]+)\*\*/g,'<span class="hl-keyword">**$1**</span>'),e=e.replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),'<span class="hl-string">*$1*</span>'),e=e.replace(/`([^`]+)`/g,'<span class="hl-builtin">`$1`</span>'),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<span class="hl-tag">[$1]</span><span class="hl-string">($2)</span>'),e}function v(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function B(t){t.addEventListener("mousedown",e=>e.preventDefault())}const je=["#000000","#5c5c5c","#9c9c9c","#cfcfcf","#ffffff","#e03131","#f76707","#f59f00","#94d82d","#0ca678","#1c7ed6","#7048e8","#d6336c","#fab005","#37b24d","#1098ad"];function Re(t,e,n=[]){W();const o=document.createElement("div");o.className="aw-popover aw-color-popover",o.dataset.popover="true",B(o);const l=d=>{e(d),o.remove()},i=d=>{const u=document.createElement("button");return u.type="button",u.className="aw-color-swatch",u.style.backgroundColor=d,u.setAttribute("aria-label",d),u.title=d,B(u),u.addEventListener("click",h=>{h.stopPropagation(),l(d)}),u},r=document.createElement("div");r.className="aw-color-grid";for(const d of je)r.appendChild(i(d));o.appendChild(r);const s=document.createElement("button");s.type="button",s.className="aw-popover-action",s.textContent=p().color.defaultColor,B(s),s.addEventListener("click",d=>{d.stopPropagation(),l(null)});const a=document.createElement("button");a.type="button",a.className="aw-popover-action",a.textContent=p().color.customColor,B(a);const c=document.createElement("input");if(c.type="color",c.tabIndex=-1,c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.left="-9999px",c.style.width="0",c.style.height="0",c.style.opacity="0",c.style.pointerEvents="none",c.addEventListener("change",()=>{l(c.value)}),a.addEventListener("click",d=>{d.stopPropagation(),c.click()}),o.appendChild(s),o.appendChild(a),o.appendChild(c),n.length>0){const d=document.createElement("div");d.className="aw-color-section",d.textContent=p().color.recent,o.appendChild(d);const u=document.createElement("div");u.className="aw-color-grid";for(const h of n)u.appendChild(i(h));o.appendChild(u)}j(o,t)}function co(){const t=p().blockMenu;return[{label:t.body,kind:"paragraph",attrs:{},glyph:"¶"},{label:t.h1,kind:"heading",attrs:{level:1},glyph:"H1",weight:"700"},{label:t.h2,kind:"heading",attrs:{level:2},glyph:"H2",weight:"700"},{label:t.h3,kind:"heading",attrs:{level:3},glyph:"H3",weight:"700"},{label:t.bulletList,kind:"bulletList",attrs:{},glyph:A.bulletList,glyphIsSvg:!0,divider:!0},{label:t.orderedList,kind:"orderedList",attrs:{},glyph:A.orderedList,glyphIsSvg:!0},{label:t.taskList,kind:"taskList",attrs:{},glyph:A.taskList,glyphIsSvg:!0},{label:t.blockquote,kind:"blockquote",attrs:{},glyph:A.blockquote,glyphIsSvg:!0,divider:!0},{label:t.codeBlock,kind:"codeBlock",attrs:{},glyph:A.codeBlock,glyphIsSvg:!0},{label:t.link,kind:"linkCard",attrs:{},glyph:A.link,glyphIsSvg:!0,divider:!0},{label:t.image,kind:"image",attrs:{},glyph:A.image,glyphIsSvg:!0},{label:t.table,kind:"table",attrs:{},glyph:A.table,glyphIsSvg:!0},{label:t.youtube,kind:"youtube",attrs:{},glyph:A.youtube,glyphIsSvg:!0},{label:t.file,kind:"file",attrs:{},glyph:A.attachFile,glyphIsSvg:!0},{label:t.hr,kind:"hr",attrs:{},glyph:A.hr,glyphIsSvg:!0},{label:t.importHtml,kind:"importHtml",attrs:{},glyph:A.importHtml,glyphIsSvg:!0,divider:!0},{label:t.importMarkdown,kind:"importMarkdown",attrs:{},glyph:A.importMarkdown,glyphIsSvg:!0}]}function uo(t,e){W();const n=document.createElement("div");n.className="aw-popover aw-block-type-popover",n.dataset.popover="true",B(n);for(const o of co()){if(o.divider){const s=document.createElement("div");s.className="aw-popover-divider",n.appendChild(s)}const l=document.createElement("button");l.type="button",l.className="aw-popover-item";const i=document.createElement("span");i.className="aw-popover-item-glyph",o.glyphIsSvg?i.innerHTML=o.glyph:i.textContent=o.glyph;const r=document.createElement("span");r.className="aw-popover-item-label",r.textContent=o.label,o.size&&(r.style.fontSize=o.size),o.weight&&(r.style.fontWeight=o.weight),l.appendChild(i),l.appendChild(r),B(l),l.addEventListener("click",s=>{s.stopPropagation(),n.remove(),e({kind:o.kind,attrs:o.attrs})}),n.appendChild(l)}j(n,t)}function po(t,e){W();const n=document.createElement("div");n.className="aw-popover aw-align-popover",n.dataset.popover="true",B(n);const o=p().align,l=[{icon:"alignLeft",value:"left",label:o.left},{icon:"alignCenter",value:"center",label:o.center},{icon:"alignRight",value:"right",label:o.right},{icon:"alignJustify",value:"justify",label:o.justify}];for(const i of l){const r=document.createElement("button");r.type="button",r.className="aw-popover-item aw-popover-item-icon",r.setAttribute("aria-label",i.label),r.title=i.label,r.innerHTML=A[i.icon]??"",B(r),r.addEventListener("click",s=>{s.stopPropagation(),n.remove(),e(i.value)}),n.appendChild(r)}j(n,t)}function ho(t,e,n){_n(),W();const o=document.createElement("div");o.className="aw-popover aw-font-family-popover",o.dataset.popover="true",B(o);const l=()=>{o.replaceChildren();for(const r of Dn()){const s=document.createElement("button");s.type="button",s.className="aw-popover-item aw-font-family-item",n&&n===r.id&&s.classList.add("aw-popover-item-active");const a=r.id===Dt?p().fontFamily.systemDefault:r.label;s.title=a;const c=document.createElement("span");c.className="aw-font-family-name",c.textContent=a;const d=document.createElement("span");d.className="aw-font-family-preview",d.textContent="가A",d.style.fontFamily=r.stack,s.appendChild(c),s.appendChild(d),B(s),s.addEventListener("click",u=>{u.stopPropagation(),o.remove(),e({id:r.id,label:r.label,stack:r.stack})}),o.appendChild(s)}};l();const i=Fn(()=>{if(!o.isConnected){i();return}l()});j(o,t)}function fo(t,e,n){W();const o=document.createElement("div");o.className="aw-popover aw-code-lang-popover",o.dataset.popover="true",B(o);for(const l of _t){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-code-lang-item",n===l.id&&i.classList.add("aw-popover-item-active"),i.title=l.label;const r=document.createElement("span");r.className="aw-popover-item-label",r.textContent=l.label,i.appendChild(r),B(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({id:l.id,label:l.label})}),o.appendChild(i)}j(o,t)}function mo(){const t=p().tableMenu;return[{action:"rowAbove",label:t.rowAbove},{action:"rowBelow",label:t.rowBelow},{action:"colLeft",label:t.colLeft,divider:!0},{action:"colRight",label:t.colRight},{action:"deleteRow",label:t.deleteRow,divider:!0},{action:"deleteCol",label:t.deleteCol}]}function go(t,e){W();const n=document.createElement("div");n.className="aw-popover aw-table-menu-popover",n.dataset.popover="true",B(n);for(const o of mo()){if(o.divider){const i=document.createElement("div");i.className="aw-popover-divider",n.appendChild(i)}const l=document.createElement("button");l.type="button",l.className="aw-popover-item aw-table-menu-item",l.textContent=o.label,B(l),l.addEventListener("click",i=>{i.stopPropagation(),n.remove(),e(o.action)}),n.appendChild(l)}j(n,t)}function bo(t,e,n){W();const o=document.createElement("div");o.className="aw-popover aw-font-size-popover",o.dataset.popover="true",B(o);for(const l of Hn){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-font-size-item",n===l&&i.classList.add("aw-popover-item-active"),i.title=`${l}px`;const r=document.createElement("span");r.className="aw-font-size-label",r.textContent=String(l),i.appendChild(r),B(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({px:l})}),o.appendChild(i)}j(o,t)}function pt(t,e){W();const n=2,o=12,l=document.createElement("div");l.className="aw-popover aw-table-popover",l.dataset.popover="true";const i=document.createElement("div");i.className="aw-table-picker-grid";const r=document.createElement("div");r.className="aw-table-status";let s=n,a=n,c=0,d=0;const u=[];function h(){for(let f=0;f<u.length;f++){const g=u[f];if(g)for(let k=0;k<g.length;k++){const y=g[k];y&&y.classList.toggle("aw-table-cell-active",f<c&&k<d)}}r.textContent=c>0&&d>0?se(p().table.statusFormat,{r:c,c:d}):p().table.pickerHint}function m(){i.innerHTML="",i.style.gridTemplateColumns=`repeat(${a}, 18px)`,i.style.gridTemplateRows=`repeat(${s}, 18px)`,u.length=0;for(let f=0;f<s;f++){const g=[];for(let k=0;k<a;k++){const y=document.createElement("div");y.className="aw-table-cell",y.dataset.row=String(f+1),y.dataset.col=String(k+1),i.appendChild(y),g.push(y)}u.push(g)}h()}m(),i.addEventListener("mousemove",f=>{const g=f.target;if(!g.classList.contains("aw-table-cell"))return;const k=parseInt(g.dataset.row??"0",10),y=parseInt(g.dataset.col??"0",10);c=k,d=y;let E=!1;k>=s&&s<o&&(s=Math.min(o,k+1),E=!0),y>=a&&a<o&&(a=Math.min(o,y+1),E=!0),E?m():h()}),i.addEventListener("click",f=>{const g=f.target;if(!g.classList.contains("aw-table-cell"))return;const k=parseInt(g.dataset.row??"0",10),y=parseInt(g.dataset.col??"0",10);k>0&&y>0&&(e({rows:k,cols:y}),l.remove())}),l.appendChild(i),l.appendChild(r),j(l,t)}function j(t,e){const n=e.closest(".aeriz-wysiwyg"),o=n==null?void 0:n.dataset.theme;o&&(t.dataset.theme=o),t.style.position="fixed",e.classList.add("is-popover-open");const l=()=>{const d=e.getBoundingClientRect();t.style.top=`${d.bottom+4}px`,t.style.left=`${d.left}px`};l(),document.body.appendChild(t);const i=()=>l(),r=()=>l();window.addEventListener("scroll",i,!0),window.addEventListener("resize",r);function s(d){!t.contains(d.target)&&!e.contains(d.target)&&t.remove()}setTimeout(()=>{document.addEventListener("click",s)},0);function a(d){d.key==="Escape"&&(d.stopPropagation(),t.remove())}document.addEventListener("keydown",a);const c=t.remove.bind(t);t.remove=function(){window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",r),document.removeEventListener("click",s),document.removeEventListener("keydown",a),e.classList.remove("is-popover-open"),c()}}function W(){document.querySelectorAll('[data-popover="true"]').forEach(t=>t.remove())}function Ot(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/1024/1024).toFixed(1)} MB`:`${(t/1024/1024/1024).toFixed(1)} GB`}function qt(t,e){if(t){const n=t.lastIndexOf(".");if(n>0&&n<t.length-1)return t.slice(n+1).toUpperCase()}return e?(e.split("/").pop()??"").toUpperCase():""}function We(t){try{return new URL(t).hostname}catch{return""}}function Ut(t){const e=We(t);return e?`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`:""}const jt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>',Wt='<svg 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>',Kt="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",ue="https://www.youtube-nocookie.com/embed/",Yt="파일",P="data-block-id",Ke=/[​-‍]/g,Ye=["id","class","dir","lang","title"],yo=new Set(["div","section","article","aside","header","footer","main","nav","details","summary","figure","figcaption","address","fieldset","dl","dt","dd","small","span"]);function Gt(t){if(!t)return"div";const e=t.toLowerCase();return yo.has(e)?e:"div"}function Vt(...t){const e=new Set;for(const n of t)if(n)for(const o of n.split(/\s+/))o&&e.add(o);return[...e].join(" ")}const q="aw-task-list",G="data-checked",ko=new Set(["http:","https:","mailto:","tel:","ftp:","sms:"]),wo=new Set(["http:","https:","blob:"]),vo=/^data:image\/[a-z0-9.+-]+[,;]/i;function Zt(t){return t.replace(Co,"")}const Co=new RegExp("[\\u0000-\\u0020\\u007f]","g");function Xt(t){const e=/^([a-z][a-z0-9+.-]*):/i.exec(t);return e&&e[1]?`${e[1].toLowerCase()}:`:null}function K(t){if(!t)return"";const e=t.trim();if(!e)return"";const n=Xt(Zt(e));return n===null||ko.has(n)?e:""}function I(t){if(!t)return"";const e=t.trim();if(!e)return"";const n=Zt(e),o=Xt(n);return o===null?e:o==="data:"?vo.test(n)?e:"":wo.has(o)?e:""}function Ge(t){return t&&/^[A-Za-z0-9_-]{6,20}$/.test(t)?t:""}const Jt=1;function Qt(t){const e=t.version;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:1}const Lo=new Set(["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock","image","table","hr","linkCard","youtube","file","importedHtml","unknown"]);function pe(t){return t.map(e=>Ve(e))}function Ve(t){const e=Lo.has(t.kind)?t.kind:"unknown",n=Math.max(Qt(t),1);return{...t,kind:e,version:n,html:typeof t.html=="string"?t.html:""}}const le=["bold","italic","underline","strike"],xo={kind:"paragraph",label:"본문",allowsInlineFormat:!0,allowedMarks:le,allowsColor:!0,allowsFontSize:!0,matches:t=>t.tagName==="P"?{kind:"paragraph",attrs:{}}:null,create:()=>ne(document.createElement("p")),isEmpty:t=>z(t)},Eo={kind:"heading",label:"제목",allowsInlineFormat:!0,allowedMarks:["italic"],allowsColor:!1,allowsFontSize:!1,matches:t=>{const e=/^H([1-6])$/.exec(t.tagName);return e?{kind:"heading",attrs:{level:Number(e[1])}}:null},create:t=>{const e=Qo(t==null?void 0:t.level);return ne(document.createElement(`h${e}`))},isEmpty:t=>z(t)},Ao={kind:"bulletList",label:"글머리 목록",allowsInlineFormat:!0,allowedMarks:le,allowsColor:!0,allowsFontSize:!0,matches:t=>t.tagName==="UL"?{kind:"bulletList",attrs:{}}:null,create:()=>it("ul"),isEmpty:t=>rt(t)},To={kind:"orderedList",label:"번호 매기기 목록",allowsInlineFormat:!0,allowedMarks:le,allowsColor:!0,allowsFontSize:!0,matches:t=>t.tagName==="OL"?{kind:"orderedList",attrs:{}}:null,create:()=>it("ol"),isEmpty:t=>rt(t)},So={kind:"taskList",label:"체크리스트",allowsInlineFormat:!0,allowedMarks:le,allowsColor:!0,allowsFontSize:!0,matches:t=>t.tagName==="UL"&&t.classList.contains(q)?{kind:"taskList",attrs:{}}:null,create:()=>{const t=it("ul");return t.classList.add(q),t},isEmpty:t=>rt(t)},Bo={kind:"blockquote",label:"인용구",allowsInlineFormat:!0,allowedMarks:["bold","underline","strike"],allowsColor:!1,allowsFontSize:!0,matches:t=>t.tagName==="BLOCKQUOTE"?{kind:"blockquote",attrs:{}}:null,create:()=>{const t=document.createElement("blockquote");return t.appendChild(ne(document.createElement("p"))),t},isEmpty:t=>z(t)},$o={kind:"codeBlock",label:"코드 블록",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!0,matches:t=>{if(t.tagName!=="PRE")return null;const e=t.querySelector(":scope > code"),n=e==null?void 0:e.getAttribute("data-language");return{kind:"codeBlock",attrs:n?{language:n}:{}}},create:t=>{const e=document.createElement("pre"),n=document.createElement("code");return t!=null&&t.language&&n.setAttribute("data-language",t.language),e.appendChild(n),e},isEmpty:t=>z(t)},Mo={kind:"image",label:"이미지",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:t=>{var e;if(t.tagName==="FIGURE"){const n=t.querySelector(":scope > img"),o=bt(n),l=((e=t.querySelector(":scope > figcaption"))==null?void 0:e.textContent)??"";l.trim()&&(o.caption=l);const i=t.getAttribute("style");return i&&(o.wrapperStyle=i),{kind:"image",attrs:o}}return t.tagName==="IMG"?{kind:"image",attrs:bt(t)}:null},create:t=>{const e=document.createElement("figure");t!=null&&t.wrapperStyle&&e.setAttribute("style",t.wrapperStyle);const n=document.createElement("img"),o=I(t==null?void 0:t.src);if(o&&(n.src=o),t!=null&&t.alt&&(n.alt=t.alt),e.appendChild(n),t!=null&&t.caption){const l=document.createElement("figcaption");l.textContent=t.caption,e.appendChild(l)}return e.appendChild(Xe({caption:!0})),e.appendChild(Ze()),e},isEmpty:t=>{const e=t.tagName==="IMG"?t:t.querySelector(":scope > img");return!e||!e.getAttribute("src")}};function Ze(){const t=document.createElement("span");return t.className="aw-resize-handle",t.setAttribute("contenteditable","false"),t.setAttribute("aria-hidden","true"),t}function Xe(t={}){const e=document.createElement("span");e.className="aw-block-align-controls",e.setAttribute("contenteditable","false"),e.setAttribute("aria-hidden","true");const n=p().blockAlign;for(const o of["left","center","right"]){const l=document.createElement("button");l.type="button",l.className="aw-block-align-btn",l.dataset.align=o,l.title=n[o],l.setAttribute("aria-label",l.title),l.innerHTML=Io[o],e.appendChild(l)}if(t.caption){const o=document.createElement("span");o.className="aw-block-ctl-divider",e.appendChild(o);const l=document.createElement("button");l.type="button",l.className="aw-block-caption-btn",l.dataset.action="caption",l.title=p().image.captionAdd,l.setAttribute("aria-label",l.title),l.innerHTML=No,e.appendChild(l)}return e}const No='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="11" rx="1.5"/><line x1="6" y1="19" x2="18" y2="19"/></svg>',Io={left:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>',center:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>',right:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>'},Ho={kind:"table",label:"표",allowsInlineFormat:!0,allowedMarks:le,allowsColor:!0,allowsFontSize:!0,matches:t=>{var l;if(t.tagName!=="TABLE")return null;const e=t.querySelectorAll(":scope > tbody > tr, :scope > tr"),n=e.length,o=((l=e[0])==null?void 0:l.children.length)??0;return{kind:"table",attrs:{rows:n,cols:o}}},create:t=>{const e=Math.max(1,(t==null?void 0:t.rows)??1),n=Math.max(1,(t==null?void 0:t.cols)??1),o=document.createElement("table"),l=document.createElement("tbody");for(let i=0;i<e;i++){const r=document.createElement("tr");for(let s=0;s<n;s++){const a=document.createElement("td");a.appendChild(document.createElement("br")),r.appendChild(a)}l.appendChild(r)}return o.appendChild(l),o},isEmpty:t=>t.querySelectorAll(":scope tr").length===0},Ro={kind:"hr",label:"구분선",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:t=>t.tagName==="HR"?{kind:"hr",attrs:{}}:null,create:()=>{const t=document.createElement("hr");return t.setAttribute("contenteditable","false"),t},isEmpty:()=>!1},zo={kind:"youtube",label:"유튜브",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:t=>{if(t.tagName!=="DIV"||!t.classList.contains("aw-youtube-embed"))return null;const e=t.getAttribute("data-youtube-id")??void 0,n={};e&&(n.videoId=e);const o=t.getAttribute("style");return o&&(n.wrapperStyle=o),{kind:"youtube",attrs:n}},create:t=>{const e=Ge(t==null?void 0:t.videoId),n=document.createElement("div");n.className="aw-youtube-embed",n.setAttribute("contenteditable","false"),e&&n.setAttribute("data-youtube-id",e),t!=null&&t.wrapperStyle&&n.setAttribute("style",t.wrapperStyle);const o=document.createElement("iframe");return e&&(o.src=`${ue}${e}`),o.setAttribute("allow",Kt),o.setAttribute("allowfullscreen",""),o.setAttribute("frameborder","0"),o.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),n.appendChild(o),n.appendChild(Xe()),n.appendChild(Ze()),n},isEmpty:t=>!t.getAttribute("data-youtube-id")},Do={kind:"linkCard",label:"링크",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:t=>{var s,a,c,d,u;if(t.tagName!=="A"||!t.classList.contains("aw-link-card"))return null;const e=t.getAttribute("href")??void 0,n=((s=t.querySelector(":scope > .aw-link-card-body > .aw-link-card-title"))==null?void 0:s.textContent)??((a=t.querySelector(":scope > .aw-link-card-text"))==null?void 0:a.textContent)??void 0,o=((c=t.querySelector(":scope > .aw-link-card-body > .aw-link-card-desc"))==null?void 0:c.textContent)??void 0,l=((d=t.querySelector(":scope > .aw-link-card-image"))==null?void 0:d.getAttribute("src"))??void 0,i=((u=t.querySelector(":scope .aw-link-card-favicon"))==null?void 0:u.getAttribute("src"))??void 0,r={};return e&&(r.href=e),n&&(r.text=n),o&&(r.description=o),l&&(r.image=l),i&&(r.favicon=i),{kind:"linkCard",attrs:r}},create:t=>{const e=K(t==null?void 0:t.href)||"#",n=t!=null&&t.text&&t.text.length>0?t.text:We(e)||e,o=(t==null?void 0:t.description)??"",l=I(t==null?void 0:t.image),i=t!=null&&t.favicon?I(t.favicon):Ut(e),r=document.createElement("a");if(r.className="aw-link-card",l&&r.classList.add("aw-link-card-with-image"),r.href=e,r.target="_blank",r.rel="noopener",r.setAttribute("contenteditable","false"),l){const u=document.createElement("img");u.className="aw-link-card-image",u.src=l,u.alt="",u.loading="lazy",r.appendChild(u)}const s=document.createElement("span");s.className="aw-link-card-body";const a=document.createElement("span");if(a.className="aw-link-card-title",a.textContent=n,s.appendChild(a),o){const u=document.createElement("span");u.className="aw-link-card-desc",u.textContent=o,s.appendChild(u)}const c=document.createElement("span");if(c.className="aw-link-card-url",i){const u=document.createElement("img");u.className="aw-link-card-favicon",u.src=i,u.alt="",u.loading="lazy",c.appendChild(u)}const d=document.createElement("span");return d.className="aw-link-card-url-text",d.textContent=e,c.appendChild(d),s.appendChild(c),r.appendChild(s),r},isEmpty:t=>!t.getAttribute("href")},Fo={kind:"file",label:"파일",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:t=>{if(t.tagName!=="A"||!t.classList.contains("aw-file-attachment"))return null;const e=t.getAttribute("href")??void 0,n=t.getAttribute("data-file-name")??void 0,o=t.getAttribute("data-file-size"),l=o?Number(o):void 0,i=t.getAttribute("data-file-type")??void 0,r={};return e&&(r.fileSrc=e),n&&(r.fileName=n),l!==void 0&&!Number.isNaN(l)&&(r.fileSize=l),i&&(r.fileType=i),{kind:"file",attrs:r}},create:t=>{const e=document.createElement("a");e.className="aw-file-attachment",e.setAttribute("contenteditable","false"),e.setAttribute("target","_blank"),e.setAttribute("rel","noopener");const n=K(t==null?void 0:t.fileSrc);n&&(e.href=n),e.setAttribute("download",(t==null?void 0:t.fileName)??""),t!=null&&t.fileName&&e.setAttribute("data-file-name",t.fileName),(t==null?void 0:t.fileSize)!==void 0&&e.setAttribute("data-file-size",String(t.fileSize)),t!=null&&t.fileType&&e.setAttribute("data-file-type",t.fileType);const o=document.createElement("span");o.className="aw-file-icon",o.setAttribute("aria-hidden","true"),o.innerHTML=jt;const l=document.createElement("span");l.className="aw-file-meta";const i=document.createElement("span");i.className="aw-file-name",i.textContent=(t==null?void 0:t.fileName)??Yt,l.appendChild(i);const r=[],s=qt(t==null?void 0:t.fileName,t==null?void 0:t.fileType);if(s&&r.push(s),(t==null?void 0:t.fileSize)!==void 0&&r.push(Ot(t.fileSize)),r.length>0){const c=document.createElement("span");c.className="aw-file-info",c.textContent=r.join(" · "),l.appendChild(c)}const a=document.createElement("span");return a.className="aw-file-action",a.setAttribute("aria-hidden","true"),a.innerHTML=Wt,e.appendChild(o),e.appendChild(l),e.appendChild(a),e},isEmpty:t=>!t.getAttribute("href")},Po={kind:"importedHtml",label:"HTML",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:t=>{if(t.tagName!=="DIV"||t.getAttribute("data-imported-html")!=="true")return null;const e={},n=t.getAttribute("style");n&&(e.importedStyle=n);const o=t.getAttribute("class");return o&&(e.importedClass=o),{kind:"importedHtml",attrs:e}},create:t=>{const e=document.createElement("div");return e.setAttribute("data-imported-html","true"),t!=null&&t.importedStyle&&e.setAttribute("style",t.importedStyle),t!=null&&t.importedClass&&e.setAttribute("class",t.importedClass),e},isEmpty:()=>!1},en={kind:"unknown",label:"알 수 없음",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:()=>null,create:t=>ne(document.createElement(Gt(t==null?void 0:t.tag))),isEmpty:t=>z(t)},Je=[xo,Eo,So,Ao,To,Bo,$o,Mo,Ho,Ro,Do,zo,Fo,Po],U=(()=>{const t={unknown:en};for(const e of Je)t[e.kind]=e;return t})();function _(t){for(const e of Je){const n=e.matches(t);if(n)return{type:e,match:n}}return{type:en,match:{kind:"unknown",attrs:{tag:t.tagName.toLowerCase()}}}}class Qe{constructor(){b(this,"counter",0);b(this,"seen",new Set)}observe(e){this.seen.add(e)}generate(){let e;do{const n=(++this.counter).toString(36),o=Math.random().toString(36).slice(2,6);e=`b${n}_${o}`}while(this.seen.has(e));return this.seen.add(e),e}ensure(e){const n=e.getAttribute(P);if(n)return this.seen.add(n),n;const o=this.generate();return e.setAttribute(P,o),o}get(e){return e.getAttribute(P)}}function ae(t,e){const n=new Set;for(const o of Array.from(t.children)){if(!(o instanceof HTMLElement))continue;const l=o.getAttribute(P);if(l&&!n.has(l)){n.add(l),e.observe(l);continue}const i=e.generate();o.setAttribute(P,i),n.add(i)}}function ye(t,e={}){var n;an(t);for(const o of Array.from(t.childNodes)){if(o.nodeType!==Node.TEXT_NODE)continue;if((o.textContent??"").trim().length===0){o.remove();continue}const i=document.createElement("p");t.replaceChild(i,o),i.appendChild(o)}for(const o of Array.from(t.querySelectorAll(`ul.${q} > li[style]`)))o.style.removeProperty("list-style-type"),((n=o.getAttribute("style"))==null?void 0:n.trim())===""&&o.removeAttribute("style");Oo(t);for(const o of Array.from(t.querySelectorAll("hr")))o.getAttribute("contenteditable")!=="false"&&o.setAttribute("contenteditable","false");for(const o of Array.from(t.querySelectorAll("a.aw-link-card")))o.getAttribute("contenteditable")!=="false"&&o.setAttribute("contenteditable","false");for(const o of Array.from(t.querySelectorAll("div.aw-youtube-embed")))o.getAttribute("contenteditable")!=="false"&&o.setAttribute("contenteditable","false");for(const o of Array.from(t.querySelectorAll("a.aw-file-attachment")))o.getAttribute("contenteditable")!=="false"&&o.setAttribute("contenteditable","false");for(const o of Array.from(t.querySelectorAll("figure, div.aw-youtube-embed")))o instanceof HTMLElement&&(o.querySelector(":scope > .aw-block-align-controls")||o.appendChild(Xe({caption:o.tagName==="FIGURE"})),o.querySelector(":scope > .aw-resize-handle")||o.appendChild(Ze()));_o(t),e.writableTail!==!1&&Uo(t)}function _o(t){var o;const e=t.querySelectorAll("figure > figcaption");if(e.length===0)return;const n=((o=document.getSelection())==null?void 0:o.anchorNode)??null;for(const l of Array.from(e))z(l)&&(n&&l.contains(n)||l.remove())}function Oo(t){for(const e of Array.from(t.querySelectorAll("[href]"))){const n=e.getAttribute("href");n&&!K(n)&&e.removeAttribute("href")}for(const e of Array.from(t.querySelectorAll("[src]"))){const n=e.getAttribute("src");if(n){if(e.tagName==="IFRAME"){n.startsWith(ue)||e.removeAttribute("src");continue}I(n)||e.removeAttribute("src")}}}const qo=new Set(["hr","image","youtube","linkCard","file","importedHtml"]);function Uo(t){const e=Array.from(t.children).filter(l=>l instanceof HTMLElement);if(e.length===0){t.appendChild(ne(document.createElement("p")));return}const n=e[e.length-1];if(!n)return;const{match:o}=_(n);qo.has(o.kind)&&t.appendChild(ne(document.createElement("p")))}function tn(t){const e=p().blocks;switch(t.kind){case"paragraph":return e.paragraph;case"heading":return se(e.heading,{n:t.attrs.level??1});case"bulletList":return e.bulletList;case"orderedList":return e.orderedList;case"taskList":return e.taskList;case"blockquote":return e.blockquote;case"codeBlock":return e.codeBlock;case"image":return e.image;case"table":return e.table;case"hr":return e.hr;case"linkCard":return e.linkCard;case"youtube":return e.youtube;case"file":return e.file;case"importedHtml":return e.importedHtml;default:return e.unknown}}function nn(t){const e=t.element.getAttribute("style"),n=jo(t.element);return{version:Jt,id:t.id,kind:t.kind,attrs:{...t.attrs},html:Wo(t.element),...e?{style:e}:{},...n?{attributes:n}:{}}}function jo(t){let e;for(const n of Ye){const o=t.getAttribute(n);o===null||o===""||((e??(e={}))[n]=o)}return e}function Wo(t){if(!t.querySelector(".aw-block-align-controls, .aw-resize-handle"))return t.innerHTML;const e=t.cloneNode(!0);return Be(e),e.innerHTML}function et(t){return t.map(nn)}function on(t){const n=(U[t.kind]??U.unknown).create(t.attrs);if(n.setAttribute(P,t.id),t.style&&n.setAttribute("style",t.style),t.attributes){for(const[o,l]of Object.entries(t.attributes))if(Ye.includes(o)){if(o==="class"){n.setAttribute("class",Vt(n.getAttribute("class"),l));continue}n.setAttribute(o,l)}}return t.html.length>0&&(n.innerHTML=t.html),n}function ln(t,e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const n of pe(e))t.appendChild(on(n))}function Le(t,e){const n=[];for(const o of Array.from(t.children)){if(!(o instanceof HTMLElement))continue;const{match:l}=_(o);n.push({id:e(o),kind:l.kind,attrs:l.attrs,element:o})}return n}function xe(t,e,n){let o=t;for(;o&&o!==e;){if(o.parentNode===e&&o.nodeType===Node.ELEMENT_NODE){const l=o,{match:i}=_(l);return{id:n(l),kind:i.kind,attrs:i.attrs,element:l}}o=o.parentNode}return null}function rn(t){const e=t.element;switch(t.kind){case"paragraph":case"heading":return Array.from(e.childNodes);case"bulletList":case"orderedList":case"taskList":{const n=Array.from(e.querySelectorAll(":scope > li"));return ht(n)}case"blockquote":{const n=Array.from(e.querySelectorAll(":scope > p"));return n.length>0?ht(n):Array.from(e.childNodes)}case"codeBlock":{const n=e.querySelector(":scope > code");return n?Array.from(n.childNodes):Array.from(e.childNodes)}case"table":case"importedHtml":{const n=(e.textContent??"").replace(/\s+/g," ").trim();return n?[document.createTextNode(n)]:[]}case"image":{const n=e.querySelector(":scope > figcaption"),o=((n==null?void 0:n.textContent)??"").trim();return o?[document.createTextNode(o)]:[]}default:return[]}}function ht(t){const e=[];return t.forEach((n,o)=>{o>0&&e.push(document.createElement("br"));for(const l of Array.from(n.childNodes))e.push(l)}),e}function sn(t,e,n){if(n.length===0)return;let o=null;switch(e){case"paragraph":case"heading":o=t;break;case"bulletList":case"orderedList":case"taskList":o=t.querySelector(":scope > li");break;case"blockquote":o=t.querySelector(":scope > p");break;case"codeBlock":o=t.querySelector(":scope > code");break;default:return}if(!o)return;for(;o.firstChild;)o.removeChild(o.firstChild);for(const i of n)o.appendChild(i);const l=U[e];l&&Ko(o,l)}function Ko(t,e){const n=new Set(e.allowedMarks);for(const o of Array.from(t.querySelectorAll("*"))){if(!(o instanceof HTMLElement)||!o.parentNode)continue;const l=o.tagName.toLowerCase();if((l==="b"||l==="strong")&&!n.has("bold")||(l==="i"||l==="em")&&!n.has("italic")||l==="u"&&!n.has("underline")||(l==="s"||l==="strike"||l==="del")&&!n.has("strike")){ft(o);continue}if(l==="span"||l==="font"){const i=o.style;if(!n.has("bold")){const c=i.fontWeight;(c==="bold"||c==="bolder"||/^[7-9]\d{2}$|^1000$/.test(c))&&i.removeProperty("font-weight")}!n.has("italic")&&i.fontStyle==="italic"&&i.removeProperty("font-style");const r=i.textDecorationLine||i.textDecoration||"";if(r){const c=r.split(/\s+/),d=c.filter(u=>!(u==="underline"&&!n.has("underline")||u==="line-through"&&!n.has("strike")));d.length!==c.length&&(i.removeProperty("text-decoration"),i.removeProperty("text-decoration-line"),d.length>0&&(i.textDecoration=d.join(" ")))}e.allowsColor||(i.removeProperty("color"),i.removeProperty("background-color"),l==="font"&&o.removeAttribute("color")),e.allowsFontSize||(i.removeProperty("font-size"),l==="font"&&o.removeAttribute("size")),e.allowsInlineFormat||(i.removeProperty("font-family"),l==="font"&&o.removeAttribute("face"));const s=i.cssText.trim().length>0,a=Array.from(o.attributes).some(c=>c.name!=="style");!s&&!a&&ft(o)}}}function ft(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function Yo(t={}){const e=t.fg||"currentColor",n=t.bg||"transparent",o=t.mode==="dark"?!0:t.mode==="light"?!1:Go(e,n);return{primary:t.primary||"#64c8ff",fg:e,bg:n,border:t.border||"rgba(127,127,127,0.25)",fgMuted:t.fgMuted||"rgba(127,127,127,0.6)",isDark:o}}function Go(t,e){const n=mt(t);if(n!==null)return n>.5;const o=mt(e);return o!==null?o<.5:!0}function mt(t){if(!t)return null;const e=t.trim();let n=-1,o=-1,l=-1;const i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e);if(i&&i[1]){const r=i[1];r.length===3?(n=parseInt(r[0]+r[0],16),o=parseInt(r[1]+r[1],16),l=parseInt(r[2]+r[2],16)):(n=parseInt(r.slice(0,2),16),o=parseInt(r.slice(2,4),16),l=parseInt(r.slice(4,6),16))}else{const r=/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/.exec(e);r&&(n=Number(r[1]),o=Number(r[2]),l=Number(r[3]))}return n<0?null:(.299*n+.587*o+.114*l)/255}function tt(t){const e=getComputedStyle(t),n=c=>{const d=e.getPropertyValue(c).trim();return d.length>0?d:void 0},o={},l=n("--aw-primary"),i=n("--aw-fg"),r=n("--aw-bg"),s=n("--aw-border"),a=n("--aw-fg-muted");return l&&(o.primary=l),i&&(o.fg=i),r&&(o.bg=r),s&&(o.border=s),a&&(o.fgMuted=a),o}function Vo(t){const e=`color-mix(in srgb, ${t.primary} 8%, transparent)`,n=`color-mix(in srgb, ${t.fg} 6%, ${t.bg})`;return{H1:`font-size:1.875rem;font-weight:700;line-height:1.3;margin:.6em 0 .4em;padding-bottom:.25em;border-bottom:1px solid ${t.border};color:${t.fg};`,H2:`font-size:1.5rem;font-weight:700;line-height:1.35;margin:.6em 0 .4em;padding-bottom:.25em;border-bottom:1px solid ${t.border};color:${t.fg};`,H3:`font-size:1.25rem;font-weight:700;line-height:1.4;margin:.6em 0 .4em;padding-bottom:.25em;border-bottom:1px solid ${t.border};color:${t.fg};`,H4:`font-size:1.125rem;font-weight:700;line-height:1.4;margin:.6em 0 .4em;color:${t.fg};`,H5:`font-size:1rem;font-weight:700;margin:.6em 0 .4em;color:${t.fg};`,H6:`font-size:.875rem;font-weight:700;margin:.6em 0 .4em;color:${t.fg};`,P:`margin:0 0 .8em;color:${t.fg};`,UL:`margin:.6em 0;padding-left:1.6em;list-style:disc;color:${t.fg};`,OL:`margin:.6em 0;padding-left:1.6em;list-style:decimal;color:${t.fg};`,BLOCKQUOTE:`margin:1em 0;padding:.5em 1em;border-left:4px solid ${t.primary};background-color:${e};color:${t.fg};font-style:italic;`,PRE:`margin:1em 0;padding:12px 16px;background-color:${n};border:1px solid ${t.border};border-radius:6px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.9em;line-height:1.6;overflow-x:auto;white-space:pre;color:${t.fg};`,HR:`border:none;border-top:1px solid ${t.border};margin:1.5em 0;`,TABLE:`width:100%;border-collapse:collapse;margin:1em 0;color:${t.fg};`,FIGURE:"margin:1em 0;text-align:center;",A:`display:block;text-decoration:none;margin:1em 0;padding:12px 16px;border:1px solid ${t.border};border-radius:8px;background-color:${e};color:${t.fg};`}}function Zo(t){const e=`color-mix(in srgb, ${t.fg} 5%, ${t.bg})`,n=`color-mix(in srgb, ${t.primary} 12%, transparent)`;return{"pre > code":"background:transparent;padding:0;font:inherit;color:inherit;display:block;","table td":`border:1px solid ${t.border};padding:6px 10px;`,"table th":`border:1px solid ${t.border};padding:6px 10px;background-color:${e};font-weight:600;text-align:left;`,img:"max-width:100%;height:auto;border-radius:4px;","a.aw-link-card .aw-link-card-text":`display:block;font-weight:600;font-size:1rem;margin-bottom:4px;color:${t.fg};text-decoration:none;`,"a.aw-link-card .aw-link-card-url":`display:block;font-size:.8rem;color:${t.primary};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;text-decoration:none;`,"div.aw-youtube-embed":"position:relative;width:100%;aspect-ratio:16/9;margin:1em 0;border-radius:8px;overflow:hidden;background:#000;","div.aw-youtube-embed iframe":"position:absolute;inset:0;width:100%;height:100%;border:0;display:block;","a.aw-file-attachment .aw-file-icon":`flex:0 0 auto;display:inline-flex;width:36px;height:36px;align-items:center;justify-content:center;border-radius:6px;background:${n};color:${t.primary};`,"a.aw-file-attachment .aw-file-icon svg":"width:20px;height:20px;","a.aw-file-attachment .aw-file-meta":"flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px;","a.aw-file-attachment .aw-file-name":`font-weight:600;font-size:.95rem;color:${t.fg};word-break:break-all;line-height:1.3;`,"a.aw-file-attachment .aw-file-info":`font-size:.75rem;color:${t.fgMuted};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.02em;`,"a.aw-file-attachment .aw-file-action":`flex:0 0 auto;display:inline-flex;width:32px;height:32px;align-items:center;justify-content:center;color:${t.fgMuted};`,"a.aw-file-attachment .aw-file-action svg":"width:18px;height:18px;","pre > code .hl-keyword":t.isDark?"color:#c678dd;font-weight:600;":"color:#a626a4;font-weight:600;","pre > code .hl-string":t.isDark?"color:#98c379;":"color:#50a14f;","pre > code .hl-number":t.isDark?"color:#d19a66;":"color:#986801;","pre > code .hl-comment":`color:${t.fgMuted};font-style:italic;`,"pre > code .hl-fn":t.isDark?"color:#61afef;":"color:#4078f2;","pre > code .hl-builtin":t.isDark?"color:#56b6c2;":"color:#0184bc;","pre > code .hl-tag":t.isDark?"color:#e06c75;":"color:#e45649;","pre > code .hl-attr":t.isDark?"color:#d19a66;":"color:#986801;","pre > code .hl-prop":t.isDark?"color:#61afef;":"color:#4078f2;","pre > code .hl-punct":`color:${t.fgMuted};`}}function nt(t,e={}){const n=Yo(e),o=Vo(n),l=Zo(n);for(const i of Array.from(t.children)){if(!(i instanceof HTMLElement)||i.getAttribute("data-imported-html")==="true")continue;if(i.tagName==="A"&&i.classList.contains("aw-file-attachment")){ie(i,`display:flex;align-items:center;gap:12px;margin:1em 0;padding:10px 14px;border:1px solid ${n.border};border-radius:8px;background:${n.bg};color:${n.fg};text-decoration:none;`);continue}if(i.tagName==="UL"&&i.classList.contains(q)){ie(i,`margin:.6em 0;padding-left:1.6em;color:${n.fg};`);for(const s of Array.from(i.querySelectorAll(":scope > li"))){const a=s.getAttribute(G)==="true";ie(s,a?`list-style-type:"\\2611 ";color:${n.fgMuted};text-decoration:line-through;`:'list-style-type:"\\2610 ";')}continue}const r=o[i.tagName];r&&ie(i,r)}for(const[i,r]of Object.entries(l))for(const s of Array.from(t.querySelectorAll(i)))s instanceof HTMLElement&&(s.closest("[data-imported-html]")||ie(s,r))}function ie(t,e){const n=(t.getAttribute("style")??"").trim();if(!n){const s=e.replace(/;\s*$/,"").trim();s&&t.setAttribute("style",s);return}const o=gt(n),l=new Set(o.map(s=>s.prop)),r=[...gt(e).filter(s=>!l.has(s.prop)),...o].map(s=>`${s.prop}:${s.value}`).join(";");r?t.setAttribute("style",r):t.removeAttribute("style")}function gt(t){const e=[];for(const n of t.split(";")){const o=n.trim();if(!o)continue;const l=o.indexOf(":");if(l<=0)continue;const i=o.slice(0,l).trim().toLowerCase(),r=o.slice(l+1).trim();!i||!r||e.push({prop:i,value:r})}return e}const Ee={left:"aw-align-left",center:"aw-align-center",right:"aw-align-right",justify:"aw-align-justify"};function ot(t){for(const e of Array.from(t.children)){if(!(e instanceof HTMLElement))continue;const{match:n}=_(e);e.classList.add("aw-block",`aw-block-${n.kind}`)}for(const e of Array.from(t.querySelectorAll("[style]")))e.closest("[data-imported-html]")||Xo(e)}function Xo(t){var l;const e=t.style.textAlign.trim().toLowerCase(),n=Ee[e],o=Object.values(Ee).filter(i=>i!==n&&t.classList.contains(i));for(const i of o)t.classList.remove(i);n&&(t.classList.add(n),t.style.removeProperty("text-align"),((l=t.getAttribute("style"))==null?void 0:l.trim())===""&&t.removeAttribute("style"))}function an(t){var e;for(const[n,o]of Object.entries(Ee))for(const l of Array.from(t.querySelectorAll(`.${o}`)))l.style.textAlign||(l.style.textAlign=n),l.classList.remove(o),((e=l.getAttribute("class"))==null?void 0:e.trim())===""&&l.removeAttribute("class")}function Be(t){const e=t.querySelectorAll(".aw-block-align-controls, .aw-resize-handle");for(const n of Array.from(e))n.remove();for(const n of Array.from(t.querySelectorAll("[contenteditable]")))n.removeAttribute("contenteditable")}function lt(t){for(const e of Array.from(t.querySelectorAll("[data-block-kind]")))e.removeAttribute("data-block-kind");for(const e of Array.from(t.querySelectorAll("[data-block-label]")))e.removeAttribute("data-block-label");for(const e of Array.from(t.querySelectorAll("[data-block-focused]")))e.removeAttribute("data-block-focused");for(const e of Array.from(t.querySelectorAll("[data-block-flash]")))e.removeAttribute("data-block-flash");for(const e of Array.from(t.querySelectorAll("[data-block-explicit]")))e.removeAttribute("data-block-explicit")}function M(t){const e=document.getSelection();if(!e)return;const n=document.createRange();if(t.tagName==="HR")n.setStartAfter(t);else{const o=Jo(t);n.selectNodeContents(o),n.collapse(!0)}e.removeAllRanges(),e.addRange(n)}function Jo(t){switch(t.tagName){case"UL":case"OL":{const e=t.querySelector(":scope > li");return e instanceof HTMLElement?e:t}case"BLOCKQUOTE":{const e=t.querySelector(":scope > p");return e instanceof HTMLElement?e:t}case"PRE":{const e=t.querySelector(":scope > code");return e instanceof HTMLElement?e:t}case"TABLE":{const e=t.querySelector(":scope td, :scope th");return e instanceof HTMLElement?e:t}default:return t}}function ne(t){return t.appendChild(document.createElement("br")),t}function it(t){const e=document.createElement(t),n=document.createElement("li");return n.appendChild(document.createElement("br")),e.appendChild(n),e}function rt(t){const e=t.querySelectorAll(":scope > li");return e.length===0?!0:e.length===1?z(e[0]):!1}function z(t){return(t.textContent??"").replace(/​/g,"").trim().length===0}function Qo(t){return t===void 0||t<1?1:t>6?6:t}function bt(t){if(!t)return{};const e={},n=t.getAttribute("src"),o=t.getAttribute("alt");return n&&(e.src=n),o&&(e.alt=o),e}function $e(t){return t?U[t.kind]??U.unknown:null}function re(t,e){var n;return((n=$e(t))==null?void 0:n.allowedMarks.includes(e))??!1}function yt(t){var e;return((e=$e(t))==null?void 0:e.allowsInlineFormat)??!1}function kt(t){var e;return((e=$e(t))==null?void 0:e.allowsFontSize)??!1}function fe(t){var e;return((e=$e(t))==null?void 0:e.allowsColor)??!1}const el=new Set(["paragraph","heading","blockquote","table"]);function ze(t){return t!==null&&el.has(t.kind)}function me(t){return(t==null?void 0:t.kind)==="table"}function De(t,e){return e.kind==="unknown"?t.tagName.toLowerCase():tn(e)}const wt={paragraph:"¶",heading:"H",bulletList:"•",orderedList:"1.",taskList:"☑",blockquote:"❝",codeBlock:"‹›",image:"▣",table:"▦",hr:"—",linkCard:"↗",youtube:"▶",file:"⇩",importedHtml:"</>",unknown:"?"};function tl(t){return t.kind==="heading"?`H${t.attrs.level??1}`:wt[t.kind]??wt.unknown}const nl={0:{kind:"paragraph"},1:{kind:"heading",attrs:{level:1}},2:{kind:"heading",attrs:{level:2}},3:{kind:"heading",attrs:{level:3}},4:{kind:"heading",attrs:{level:4}},5:{kind:"heading",attrs:{level:5}},6:{kind:"heading",attrs:{level:6}},7:{kind:"orderedList"},8:{kind:"bulletList"},9:{kind:"blockquote"},c:{kind:"codeBlock"},t:{kind:"taskList"}},cn=new RegExp(" ","g");function ol(t){const e=t.replace(cn," "),n=/^(#{1,6}) $/.exec(e);return n&&n[1]?{kind:"heading",attrs:{level:Math.min(6,n[1].length)}}:/^[-*+] $/.test(e)?{kind:"bulletList"}:/^\d+[.)] $/.test(e)?{kind:"orderedList"}:e==="> "?{kind:"blockquote"}:e==="```"||e==="~~~"?{kind:"codeBlock"}:e==="---"||e==="***"?{kind:"hr"}:null}function ll(t){const e=/^\[([ xX])\] $/.exec(t.replace(cn," "));return e?{checked:(e[1]??" ").toLowerCase()==="x"}:null}function il(t){return dn(t)}function rl(t,e){un(t,e)}function dn(t){const e=document.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(!t.contains(n.commonAncestorContainer))return null;const o=document.createRange();o.selectNodeContents(t);try{o.setEnd(n.startContainer,n.startOffset);const l=o.toString().length;return o.setEnd(n.endContainer,n.endOffset),{start:l,end:o.toString().length}}catch{return null}}function un(t,e){const n=vt(t,e.start),o=vt(t,e.end);if(!n||!o)return;const l=document.createRange();try{l.setStart(n.node,n.offset),l.setEnd(o.node,o.offset)}catch{return}const i=document.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(l)}function vt(t,e){var r;const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let o=0,l=null,i=n.nextNode();for(;i;){const s=((r=i.textContent)==null?void 0:r.length)??0;if(o+s>=e)return{node:i,offset:Math.max(0,e-o)};o+=s,l={node:i,offset:s},i=n.nextNode()}return l??{node:t,offset:0}}function sl(t){const e=document.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);if(!t.contains(n.endContainer))return!1;const o=document.createRange();o.selectNodeContents(t);try{o.setStart(n.endContainer,n.endOffset)}catch{return!1}return o.toString().replace(Ke,"").trim()===""}function Ct(t){const e=document.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return null;const n=e.getRangeAt(0);if(!t.contains(n.startContainer))return null;const o=document.createRange();o.selectNodeContents(t);try{o.setEnd(n.startContainer,n.startOffset)}catch{return null}return{text:o.toString(),range:o}}function ge(t){let e=t;if(e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentElement),!(e instanceof Element))return null;const n=e.closest("td, th");return n instanceof HTMLTableCellElement?n:null}function al(t,e){const n=pn(e),o=n.indexOf(t);if(o<0)return null;const l=n[o+1];return l||dl(t)}function cl(t){const e=t.closest("table");if(!e)return null;const n=pn(e),o=n.indexOf(t);return o>0?n[o-1]??null:null}function Fe(t,e,n){const o=e.parentElement,l=n.parentElement;if(!(o instanceof HTMLTableRowElement)||!(l instanceof HTMLTableRowElement))return[e];const i=Array.from(t.querySelectorAll("tr")),r=i.indexOf(o),s=i.indexOf(l);if(r<0||s<0)return[e];const a=Array.from(o.children).indexOf(e),c=Array.from(l.children).indexOf(n);if(a<0||c<0)return[e];const d=[];for(let u=Math.min(r,s);u<=Math.max(r,s);u++){const h=i[u];if(h)for(let m=Math.min(a,c);m<=Math.max(a,c);m++){const f=h.children[m];f instanceof HTMLTableCellElement&&d.push(f)}}return d}const Q=6;function Lt(t,e,n){const o=t.getBoundingClientRect();return e<o.left-Q||e>o.right+Q||n<o.top-Q||n>o.bottom+Q?null:e>=o.right-Q?"right":n>=o.bottom-Q?"bottom":null}function pn(t){return Array.from(t.querySelectorAll("td, th"))}function dl(t){const e=t.closest("tr");if(!e||!e.parentNode)return null;const n=document.createElement("tr");for(let l=0;l<e.children.length;l++){const i=document.createElement("td");i.appendChild(document.createElement("br")),n.appendChild(i)}e.parentNode.insertBefore(n,e.nextSibling);const o=n.firstElementChild;return o instanceof HTMLTableCellElement?o:null}const ul=600,pl=200,hl=64;class fl{constructor(e){b(this,"past",[]);b(this,"future",[]);b(this,"present");b(this,"lastPushAt",0);b(this,"lastKind","structural");this.present=e}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}record(e,n,o){if(e.html===this.present.html){this.present=e;return}const l=Math.abs(e.html.length-this.present.html.length)>hl;n==="typing"&&this.lastKind==="typing"&&!l&&o-this.lastPushAt<ul||(this.past.push(this.present),this.past.length>pl&&this.past.shift(),this.lastPushAt=o),this.lastKind=n,this.present=e,this.future.length=0}undo(){const e=this.past.pop();return e?(this.future.push(this.present),this.present=e,this.lastKind="structural",e):null}redo(){const e=this.future.pop();return e?(this.past.push(this.present),this.present=e,this.lastKind="structural",e):null}current(){return this.present}reset(e){this.past.length=0,this.future.length=0,this.present=e,this.lastKind="structural",this.lastPushAt=0}}const ml=new Set(["P","DIV","SECTION","ARTICLE","HEADER","FOOTER","NAV","ASIDE","MAIN","H1","H2","H3","H4","H5","H6","UL","OL","LI","DL","DT","DD","BLOCKQUOTE","PRE","HR","TABLE","FIGURE","FIGCAPTION","FORM","FIELDSET","ADDRESS"]);function gl(t){return ml.has(t.toUpperCase())}const bl=["script","noscript","meta","link","style","base"],yl=new Set(["border-collapse","border-spacing","caption-side","color","cursor","direction","empty-cells","font-family","font-size","font-style","font-variant","font-weight","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","orphans","quotes","text-align","text-indent","text-transform","visibility","white-space","widows","word-spacing","caret-color","font","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size-adjust","font-stretch","font-synthesis","font-synthesis-weight","font-synthesis-style","font-synthesis-small-caps","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","hanging-punctuation","hyphens","image-rendering","line-break","overflow-wrap","pointer-events","ruby-align","ruby-position","tab-size","text-align-last","text-combine-upright","text-decoration-color","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-justify","text-orientation","text-rendering","text-shadow","text-size-adjust","text-underline-offset","text-underline-position","white-space-collapse","word-break","word-wrap","writing-mode","color-scheme","print-color-adjust","-webkit-font-smoothing","-moz-osx-font-smoothing","-webkit-locale","-webkit-text-fill-color","-webkit-text-stroke","-webkit-text-stroke-color","-webkit-text-stroke-width","-webkit-print-color-adjust","clip-rule","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor"]),kl=new Set(["border-block-end-color","border-block-start-color","border-bottom-color","border-inline-end-color","border-inline-start-color","border-left-color","border-right-color","border-top-color","caret-color","column-rule-color","row-rule-color","outline-color","text-decoration-color","text-emphasis-color","-webkit-text-fill-color","-webkit-text-stroke-color"]);async function wl(t,e={}){const n=e.settleMs??1e3,o=e.timeoutMs??3e4,l=e.width??1024,i=e.mountTarget??null;return new Promise((r,s)=>{const a=document.createElement("iframe");a.setAttribute("aria-hidden","true"),a.setAttribute("tabindex","-1"),a.style.position="fixed",a.style.left="-99999px",a.style.top="0",a.style.width=`${l}px`,a.style.height="768px",a.style.border="0",a.style.opacity="0",a.style.pointerEvents="none",a.setAttribute("sandbox","allow-scripts allow-same-origin");let c=!1;const d=()=>{a.parentNode&&a.parentNode.removeChild(a)},u=g=>{c||(c=!0,d(),s(g))},h=g=>{c||(c=!0,d(),r(g))},m=window.setTimeout(()=>{u(new Error("HTML 로드 시간 초과"))},o),f=()=>{var $;const g=a.contentDocument;if(!g||!g.body||g.body.children.length===0&&(g.body.textContent??"").trim()==="")return;const k=a.contentWindow,y=(k==null?void 0:k.requestAnimationFrame)??window.requestAnimationFrame;(g.fonts&&typeof(($=g.fonts.ready)==null?void 0:$.then)=="function"?g.fonts.ready:Promise.resolve()).then(()=>{const C=()=>{window.setTimeout(()=>{if(!c)try{const T=a.contentWindow,S=a.contentDocument;if(!T||!S||!S.body){window.clearTimeout(m),u(new Error("iframe document 접근 실패"));return}const N=vl(S.body,T,i);window.clearTimeout(m),h(N)}catch(T){window.clearTimeout(m),u(T instanceof Error?T:new Error(String(T)))}},n)};y(()=>y(C))})};a.addEventListener("load",f),a.srcdoc=t,document.body.appendChild(a)})}function vl(t,e,n){var r;const o=t.ownerDocument;if(!o)throw new Error("body has no ownerDocument");const l=document.createElement("div"),i=Cl(o,e,n);try{for(let a=0;a<t.attributes.length;a++){const c=t.attributes.item(a);c&&c.name!=="style"&&l.setAttribute(c.name,c.value)}const s=st(t,null,"div",i.get,e);s.length>0&&l.setAttribute("style",s);for(const a of Array.from(t.children)){const c=document.importNode(a,!0);hn(a,c,t,i.get,e),l.appendChild(c)}}finally{i.cleanup()}for(const s of bl)for(const a of Array.from(l.querySelectorAll(s)))(r=a.parentNode)==null||r.removeChild(a);return l.style.width="auto",l.style.maxWidth="none",l.style.height="auto",l.style.maxHeight="none",l.setAttribute("data-imported-html","true"),[l]}function Cl(t,e,n){var d;let o,l,i;const r=((d=n==null?void 0:n.ownerDocument)==null?void 0:d.defaultView)??null;if(n&&r){o=n.ownerDocument,l=r;const u=o.createElement("div");u.setAttribute("data-imported-html","true"),u.setAttribute("aria-hidden","true"),u.style.cssText="position:absolute;left:-99999px;top:0;visibility:hidden;pointer-events:none;",n.appendChild(u),i=u}else{o=t,l=e;const u=o.createElement("div");u.setAttribute("aria-hidden","true"),u.style.cssText="position:absolute;left:-99999px;top:0;width:0;height:0;overflow:hidden;visibility:hidden;",o.body.appendChild(u),i=u}const s=new Map;return{get:u=>{const h=s.get(u);if(h)return h;const m=o.createElement(u);i.appendChild(m);const f=l.getComputedStyle(m),g=new Map;for(let k=0;k<f.length;k++){const y=f.item(k);y&&g.set(y,f.getPropertyValue(y))}return i.removeChild(m),s.set(u,g),g},cleanup:()=>{i.parentNode&&i.parentNode.removeChild(i)}}}function st(t,e,n,o,l,i){const r=l.getComputedStyle(t,i??null),s=e?l.getComputedStyle(e):null,a=o(n);let c="";for(let d=0;d<r.length;d++){const u=r.item(d);if(!u)continue;const h=r.getPropertyValue(u);if(h&&!(i&&u==="content")&&!(kl.has(u)&&h===r.getPropertyValue("color"))){if(yl.has(u)){if(s&&s.getPropertyValue(u)===h)continue}else if(a.get(u)===h)continue;c+=`${u}:${h};`}}return c}function Ll(t){let e="";const n=/"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'/g;let o;for(;(o=n.exec(t))!==null;){const l=o[1]??o[2]??"";e+=l.replace(/\\(?:([0-9a-fA-F]{1,6})\s?|(.))/g,(i,r,s)=>r?String.fromCodePoint(parseInt(r,16)):s??"")}return e}const xl=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","UL","OL","DL","SELECT","OPTGROUP"]);function xt(t,e,n,o,l){if(xl.has(e.tagName))return;const i=n==="before"?"::before":"::after",r=l.getComputedStyle(t,i),s=r.getPropertyValue("content");if(!s||s==="none"||s==="normal"||r.getPropertyValue("display")==="none")return;const a=Ll(s),c=/url\((["']?)([^"')]+)\1\)/.exec(s),d=st(t,t,"span",o,l,i);if(!a&&!c&&!d)return;const u=e.ownerDocument,h=u.createElement("span");if(h.setAttribute("data-imported-pseudo",n),d&&h.setAttribute("style",d),c!=null&&c[2]){const m=u.createElement("img");m.setAttribute("src",c[2]),m.setAttribute("alt",""),h.appendChild(m)}a&&h.appendChild(u.createTextNode(a)),n==="before"?e.insertBefore(h,e.firstChild):e.appendChild(h)}function hn(t,e,n,o,l){if(t.nodeType===1&&e.nodeType===1){const a=st(t,n,t.tagName.toLowerCase(),o,l);a.length>0?e.setAttribute("style",a):e.hasAttribute("style")&&e.removeAttribute("style")}const i=t.children,r=e.children,s=Math.min(i.length,r.length);for(let a=0;a<s;a++){const c=i[a],d=r[a];c&&d&&hn(c,d,t,o,l)}t.nodeType===1&&e.nodeType===1&&(xt(t,e,"before",o,l),xt(t,e,"after",o,l))}function El(t){const e=Al(t),n=document.createElement("div");n.innerHTML=e;const o=[];for(const l of Array.from(n.children))l instanceof HTMLElement&&o.push(l);return o}function Al(t){const n=t.replace(/\r\n?/g,`
1
+ "use strict";var uo=Object.defineProperty;var ho=(n,e,t)=>e in n?uo(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>ho(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const an={items:["blockType","|","fontFamily","fontSize","|","bold","italic","underline","strike","|","color","backgroundColor","|","align","lineHeight","letterSpacing","|","cellBg","tableMenu","codeLang","|","specialChar","findReplace","source","print","fullscreen"],sticky:!0},po={toolbar:{ariaLabel:"Formatting toolbar",undo:"Undo",redo:"Redo",blockType:"Block type",fontFamily:"Font family",fontSize:"Font size",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",superscript:"Superscript",subscript:"Subscript",color:"Text color",backgroundColor:"Highlight color",align:"Align",cellBg:"Cell background",tableMenu:"Edit table",codeLang:"Code language",bulletList:"Bullet list",orderedList:"Numbered list",blockquote:"Blockquote",codeBlock:"Code block",link:"Link",image:"Image",table:"Table",hr:"Divider",clearFormat:"Clear formatting",lineHeight:"Line height",letterSpacing:"Letter spacing",specialChar:"Special characters",findReplace:"Find and replace (Ctrl+H)",source:"HTML source",print:"Print",fullscreen:"Full screen",blockTypeChangeTooltip:"Change block type",blockMoveTooltip:"Drag to move block",addBelowTooltip:"Add paragraph below"},blocks:{paragraph:"Body",heading:"Heading {n}",bulletList:"Bullet list",orderedList:"Numbered list",taskList:"Checklist",blockquote:"Blockquote",codeBlock:"Code",toggle:"Toggle",callout:"Callout",image:"Image",table:"Table",hr:"Divider",linkCard:"Link",youtube:"YouTube",file:"File",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"Body",taskList:"Checklist",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",bulletList:"Bullet list",orderedList:"Numbered list",blockquote:"Blockquote",codeBlock:"Code block",toggle:"Toggle",callout:"Callout",hr:"Divider",link:"Link",image:"Image",table:"Table",youtube:"YouTube",file:"File",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"Align left",center:"Align center",right:"Align right",justify:"Justify"},color:{customColor:"Custom",defaultColor:"Default",recent:"Recent"},tableMenu:{rowAbove:"Insert row above",rowBelow:"Insert row below",colLeft:"Insert column left",colRight:"Insert column right",deleteRow:"Delete row",deleteCol:"Delete column",mergeCells:"Merge cells",splitCell:"Split cell"},docTools:{editorLabel:"Rich text editor",find:"Find",replaceWith:"Replace with",previous:"Previous",next:"Next",replace:"Replace",replaceAll:"Replace all",close:"Close",matchCount:"{current} of {total}",noMatch:"No results",replaced:"Replaced {count}",matchCase:"Match case",sourceLabel:"HTML source",letterSpacingNormal:"Normal",tooLarge:"File is larger than {size}",specialGroups:{symbols:"Symbols",arrows:"Arrows",numbers:"Circled",units:"Units",brackets:"Brackets",math:"Math"}},fontFamily:{systemDefault:"System default"},blockAlign:{left:"Align left",center:"Align center",right:"Align right"},comingSoon:{label:"Coming soon"},dialogs:{confirm:"OK",cancel:"Cancel",insert:"Insert",apply:"Apply",importBtn:"Import",close:"Close",selectedFileNone:"No file selected",dropOrClick:"Drag & drop or click"},link:{title:"Insert link",text:"Display text",textPlaceholder:"Text to show",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"Open in new window"},image:{title:"Image",embedTab:"Embed",embedTabTitle:"Insert image as base64 data URL",urlTab:"URL",urlTabTitle:"Image URL",uploadTab:"Upload",uploadTabTitle:"Upload to server, use response URL",uploadDisabledTitle:"No upload API registered",embedDropzone:"Select image (base64 embed)",urlLabel:"Image URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"Select image to upload",noUploadApi:"No upload API registered.",captionAdd:"Add caption",captionPlaceholder:"Write a caption"},youtube:{title:"YouTube embed",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"Supports youtu.be / youtube.com/watch / /embed / /shorts"},table:{title:"Insert table",statusZero:"0 × 0 table",statusFormat:"{r} × {c} table",pickerHint:"Select size"},importHtml:{title:"HTML",fileSelect:"Select HTML file",pasteLabel:"Paste directly",pastePlaceholder:"or paste HTML here…",hint:"Loads via iframe and bakes all styles inline.",errEmpty:"HTML to import is empty.",errNoBody:"No body content found in HTML.",errFailed:"HTML import failed: "},importMarkdown:{title:"Markdown",fileSelect:"Select Markdown file",pasteLabel:"Paste directly",pastePlaceholder:"or paste Markdown here…",hint:"Supports CommonMark basics (headings/lists/links/code/tables/quotes).",errEmpty:"Markdown to import is empty.",errNoBody:"No content found in Markdown.",errFailed:"Markdown parse failed: "},fileAttach:{title:"Attach file",urlTab:"URL",urlTabTitle:"Direct URL of a hosted file",uploadTab:"Upload",uploadTabTitle:"Upload to server, use response URL",uploadDisabledTitle:"No file upload API registered",urlLabel:"File URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"File name",namePlaceholder:"Display name (e.g., report.pdf)",noUploadApi:"No file upload API registered.",uploadDropzone:"Select file to upload",uploadComplete:" — uploaded",uploadFailed:"Upload failed: ",errEmpty:"File URL is empty."},content:{emptyHint:"Write something…"},status:{noActive:"— no active block",blocksCount:"{n} block(s)",chars:"{n} char(s)",source:"src {n}"}},cn={toolbar:{ariaLabel:"서식 도구 모음",undo:"되돌리기",redo:"다시 실행",blockType:"블록 유형",fontFamily:"글꼴",fontSize:"글자 크기",bold:"굵게",italic:"기울임",underline:"밑줄",strike:"취소선",superscript:"위 첨자",subscript:"아래 첨자",color:"글자색",backgroundColor:"배경색",align:"정렬",cellBg:"셀 배경색",tableMenu:"표 편집",codeLang:"코드 언어",bulletList:"글머리 기호",orderedList:"번호 매기기",blockquote:"인용구",codeBlock:"코드 블록",link:"링크",image:"이미지",table:"표",hr:"구분선",clearFormat:"서식 지우기",lineHeight:"줄 간격",letterSpacing:"자간",specialChar:"특수 문자",findReplace:"찾기 · 바꾸기 (Ctrl+H)",source:"HTML 소스",print:"인쇄",fullscreen:"전체 화면",blockTypeChangeTooltip:"블록 유형 변경",blockMoveTooltip:"드래그로 블록 이동",addBelowTooltip:"아래에 단락 추가"},blocks:{paragraph:"본문",heading:"제목 {n}",bulletList:"글머리 목록",orderedList:"번호 목록",taskList:"체크리스트",blockquote:"인용구",codeBlock:"코드",toggle:"토글",callout:"콜아웃",image:"이미지",table:"표",hr:"구분선",linkCard:"링크",youtube:"유튜브",file:"파일",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"본문",taskList:"체크리스트",h1:"제목 1",h2:"제목 2",h3:"제목 3",bulletList:"글머리 목록",orderedList:"번호 매기기 목록",blockquote:"인용구",codeBlock:"코드 블록",toggle:"토글",callout:"콜아웃",hr:"구분선",link:"링크",image:"이미지",table:"표",youtube:"유튜브",file:"파일 첨부",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"왼쪽 정렬",center:"가운데 정렬",right:"오른쪽 정렬",justify:"양쪽 정렬"},color:{customColor:"사용자 지정",defaultColor:"기본색",recent:"최근 사용"},tableMenu:{rowAbove:"위에 행 추가",rowBelow:"아래에 행 추가",colLeft:"왼쪽에 열 추가",colRight:"오른쪽에 열 추가",deleteRow:"행 삭제",deleteCol:"열 삭제",mergeCells:"셀 합치기",splitCell:"셀 나누기"},docTools:{editorLabel:"본문 편집기",find:"찾을 내용",replaceWith:"바꿀 내용",previous:"이전",next:"다음",replace:"바꾸기",replaceAll:"모두 바꾸기",close:"닫기",matchCount:"{total}건 중 {current}",noMatch:"찾는 내용이 없습니다",replaced:"{count}건을 바꿨습니다",matchCase:"대소문자 구분",sourceLabel:"HTML 소스",letterSpacingNormal:"기본",tooLarge:"{size}보다 큰 파일은 올릴 수 없습니다",specialGroups:{symbols:"기호",arrows:"화살표",numbers:"원 숫자",units:"단위",brackets:"괄호",math:"수학"}},fontFamily:{systemDefault:"시스템 기본"},blockAlign:{left:"왼쪽 정렬",center:"가운데 정렬",right:"오른쪽 정렬"},comingSoon:{label:"기능 준비 중"},dialogs:{confirm:"확인",cancel:"취소",insert:"삽입",apply:"적용",importBtn:"가져오기",close:"닫기",selectedFileNone:"선택된 파일 없음",dropOrClick:"드래그 앤 드롭 또는 클릭"},link:{title:"링크 삽입",text:"표시할 텍스트",textPlaceholder:"링크에 표시할 텍스트",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"새 창에서 열기"},image:{title:"이미지",embedTab:"임베드",embedTabTitle:"base64 데이터로 본문에 직접 삽입",urlTab:"URL",urlTabTitle:"이미지 URL 입력",uploadTab:"업로드",uploadTabTitle:"서버 API 로 업로드 후 결과 URL 사용",uploadDisabledTitle:"개체 생성시 등록된 API 주소가 없습니다.",embedDropzone:"이미지 파일 선택 (base64 임베드)",urlLabel:"이미지 URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"서버 업로드용 이미지 선택",noUploadApi:"개체 생성시 등록된 API 주소가 없습니다.",captionAdd:"캡션 추가",captionPlaceholder:"캡션을 입력하세요"},youtube:{title:"유튜브 임베드",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"youtu.be / youtube.com/watch / /embed / /shorts 형식 모두 지원"},table:{title:"표 삽입",statusZero:"0 × 0 표",statusFormat:"{r} × {c} 표",pickerHint:"크기를 선택하세요"},importHtml:{title:"HTML",fileSelect:"HTML 파일 선택",pasteLabel:"직접 붙여넣기",pastePlaceholder:"또는 HTML 을 직접 붙여넣기…",hint:"iframe 으로 로드한 후 모든 스타일을 인라인으로 합쳐 가져옵니다.",errEmpty:"가져올 HTML 이 비어 있습니다.",errNoBody:"HTML 에서 가져올 본문이 없습니다.",errFailed:"HTML 가져오기 실패: "},importMarkdown:{title:"Markdown",fileSelect:"Markdown 파일 선택",pasteLabel:"직접 붙여넣기",pastePlaceholder:"또는 Markdown 을 직접 붙여넣기…",hint:"CommonMark 기본 문법(제목/목록/링크/코드/표/인용 등) 지원",errEmpty:"가져올 Markdown 이 비어 있습니다.",errNoBody:"Markdown 에서 가져올 본문이 없습니다.",errFailed:"Markdown 가져오기 실패: "},fileAttach:{title:"파일 첨부",urlTab:"URL",urlTabTitle:"이미 호스팅된 파일의 URL 직접 입력",uploadTab:"업로드",uploadTabTitle:"서버 API 로 업로드 후 응답 URL 사용",uploadDisabledTitle:"개체 생성시 등록된 파일 업로드 API 가 없습니다.",urlLabel:"파일 URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"파일명",namePlaceholder:"표시할 파일명 (예: report.pdf)",noUploadApi:"개체 생성시 등록된 파일 업로드 API 가 없습니다.",uploadDropzone:"서버 업로드용 파일 선택",uploadComplete:" — 업로드 완료",uploadFailed:"업로드 실패: ",errEmpty:"파일 URL 이 비어 있습니다."},content:{emptyHint:"내용을 입력하세요"},status:{noActive:"— 선택된 블록 없음",blocksCount:"{n} 블록",chars:"텍스트 {n} 자",source:"소스 {n}"}},fo={toolbar:{ariaLabel:"書式ツールバー",undo:"元に戻す",redo:"やり直す",blockType:"ブロックの種類",fontFamily:"フォント",fontSize:"文字サイズ",bold:"太字",italic:"斜体",underline:"下線",strike:"取り消し線",superscript:"上付き文字",subscript:"下付き文字",color:"文字色",backgroundColor:"蛍光色",align:"配置",cellBg:"セル背景色",tableMenu:"表の編集",codeLang:"コード言語",bulletList:"箇条書き",orderedList:"番号付きリスト",blockquote:"引用",codeBlock:"コードブロック",link:"リンク",image:"画像",table:"表",hr:"区切り線",clearFormat:"書式をクリア",lineHeight:"行間",letterSpacing:"文字間隔",specialChar:"特殊文字",findReplace:"検索と置換 (Ctrl+H)",source:"HTMLソース",print:"印刷",fullscreen:"全画面",blockTypeChangeTooltip:"ブロックの種類を変更",blockMoveTooltip:"ドラッグでブロックを移動",addBelowTooltip:"下に段落を追加"},blocks:{paragraph:"本文",heading:"見出し {n}",bulletList:"箇条書き",orderedList:"番号リスト",taskList:"チェックリスト",blockquote:"引用",codeBlock:"コード",toggle:"トグル",callout:"コールアウト",image:"画像",table:"表",hr:"区切り線",linkCard:"リンク",youtube:"YouTube",file:"ファイル",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"本文",taskList:"チェックリスト",h1:"見出し 1",h2:"見出し 2",h3:"見出し 3",bulletList:"箇条書き",orderedList:"番号付きリスト",blockquote:"引用",codeBlock:"コードブロック",toggle:"トグル",callout:"コールアウト",hr:"区切り線",link:"リンク",image:"画像",table:"表",youtube:"YouTube",file:"ファイル添付",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"左揃え",center:"中央揃え",right:"右揃え",justify:"両端揃え"},color:{customColor:"カスタム",defaultColor:"デフォルト",recent:"最近使用"},tableMenu:{rowAbove:"上に行を追加",rowBelow:"下に行を追加",colLeft:"左に列を追加",colRight:"右に列を追加",deleteRow:"行を削除",deleteCol:"列を削除",mergeCells:"セルを結合",splitCell:"セルを分割"},docTools:{editorLabel:"本文エディター",find:"検索",replaceWith:"置換後",previous:"前へ",next:"次へ",replace:"置換",replaceAll:"すべて置換",close:"閉じる",matchCount:"{total}件中 {current}",noMatch:"見つかりません",replaced:"{count}件を置換しました",matchCase:"大文字と小文字を区別",sourceLabel:"HTMLソース",letterSpacingNormal:"標準",tooLarge:"{size}を超えるファイルはアップロードできません",specialGroups:{symbols:"記号",arrows:"矢印",numbers:"丸数字",units:"単位",brackets:"括弧",math:"数学"}},fontFamily:{systemDefault:"システム標準"},blockAlign:{left:"左揃え",center:"中央揃え",right:"右揃え"},comingSoon:{label:"準備中"},dialogs:{confirm:"OK",cancel:"キャンセル",insert:"挿入",apply:"適用",importBtn:"インポート",close:"閉じる",selectedFileNone:"ファイル未選択",dropOrClick:"ドラッグ&ドロップまたはクリック"},link:{title:"リンクを挿入",text:"表示するテキスト",textPlaceholder:"リンクに表示するテキスト",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"新しいウィンドウで開く"},image:{title:"画像",embedTab:"埋め込み",embedTabTitle:"base64 データとして本文に直接挿入",urlTab:"URL",urlTabTitle:"画像 URL の入力",uploadTab:"アップロード",uploadTabTitle:"サーバー API でアップロード後、結果 URL を使用",uploadDisabledTitle:"API が登録されていません。",embedDropzone:"画像ファイルを選択 (base64 埋め込み)",urlLabel:"画像 URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"アップロードする画像を選択",noUploadApi:"API が登録されていません。",captionAdd:"キャプション追加",captionPlaceholder:"キャプションを入力"},youtube:{title:"YouTube 埋め込み",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"youtu.be / youtube.com/watch / /embed / /shorts に対応"},table:{title:"表を挿入",statusZero:"0 × 0 表",statusFormat:"{r} × {c} 表",pickerHint:"サイズを選択"},importHtml:{title:"HTML",fileSelect:"HTML ファイルを選択",pasteLabel:"直接貼り付け",pastePlaceholder:"または HTML を直接貼り付け…",hint:"iframe で読み込み、全スタイルをインラインに変換します。",errEmpty:"インポートする HTML が空です。",errNoBody:"HTML に本文がありません。",errFailed:"HTML インポート失敗: "},importMarkdown:{title:"Markdown",fileSelect:"Markdown ファイルを選択",pasteLabel:"直接貼り付け",pastePlaceholder:"または Markdown を直接貼り付け…",hint:"CommonMark の基本構文(見出し/リスト/リンク/コード/表/引用)に対応",errEmpty:"インポートする Markdown が空です。",errNoBody:"Markdown に本文がありません。",errFailed:"Markdown 解析失敗: "},fileAttach:{title:"ファイル添付",urlTab:"URL",urlTabTitle:"ホスト済みファイルの URL を直接入力",uploadTab:"アップロード",uploadTabTitle:"サーバー API でアップロード後、応答 URL を使用",uploadDisabledTitle:"ファイルアップロード API が登録されていません",urlLabel:"ファイル URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"ファイル名",namePlaceholder:"表示名 (例: report.pdf)",noUploadApi:"ファイルアップロード API が登録されていません。",uploadDropzone:"アップロードするファイルを選択",uploadComplete:" — アップロード完了",uploadFailed:"アップロード失敗: ",errEmpty:"ファイル URL が空です。"},content:{emptyHint:"テキストを入力"},status:{noActive:"— アクティブなブロックなし",blocksCount:"{n} ブロック",chars:"テキスト {n} 字",source:"ソース {n}"}},mo={toolbar:{ariaLabel:"格式工具栏",undo:"撤销",redo:"重做",blockType:"块类型",fontFamily:"字体",fontSize:"字号",bold:"加粗",italic:"斜体",underline:"下划线",strike:"删除线",superscript:"上标",subscript:"下标",color:"文字颜色",backgroundColor:"高亮颜色",align:"对齐",cellBg:"单元格背景",tableMenu:"编辑表格",codeLang:"代码语言",bulletList:"项目符号",orderedList:"编号列表",blockquote:"引用",codeBlock:"代码块",link:"链接",image:"图片",table:"表格",hr:"分隔线",clearFormat:"清除格式",lineHeight:"行距",letterSpacing:"字间距",specialChar:"特殊字符",findReplace:"查找和替换 (Ctrl+H)",source:"HTML 源码",print:"打印",fullscreen:"全屏",blockTypeChangeTooltip:"更改块类型",blockMoveTooltip:"拖动以移动块",addBelowTooltip:"在下方添加段落"},blocks:{paragraph:"正文",heading:"标题 {n}",bulletList:"项目符号",orderedList:"编号列表",taskList:"清单",blockquote:"引用",codeBlock:"代码",toggle:"折叠块",callout:"提示框",image:"图片",table:"表格",hr:"分隔线",linkCard:"链接",youtube:"YouTube",file:"文件",importedHtml:"HTML",unknown:"?"},blockMenu:{body:"正文",taskList:"清单",h1:"标题 1",h2:"标题 2",h3:"标题 3",bulletList:"项目符号",orderedList:"编号列表",blockquote:"引用",codeBlock:"代码块",toggle:"折叠块",callout:"提示框",hr:"分隔线",link:"链接",image:"图片",table:"表格",youtube:"YouTube",file:"附件",importHtml:"HTML",importMarkdown:"Markdown"},align:{left:"左对齐",center:"居中对齐",right:"右对齐",justify:"两端对齐"},color:{customColor:"自定义",defaultColor:"默认",recent:"最近使用"},tableMenu:{rowAbove:"在上方插入行",rowBelow:"在下方插入行",colLeft:"在左侧插入列",colRight:"在右侧插入列",deleteRow:"删除行",deleteCol:"删除列",mergeCells:"合并单元格",splitCell:"拆分单元格"},docTools:{editorLabel:"正文编辑器",find:"查找",replaceWith:"替换为",previous:"上一个",next:"下一个",replace:"替换",replaceAll:"全部替换",close:"关闭",matchCount:"第 {current} 个,共 {total} 个",noMatch:"未找到",replaced:"已替换 {count} 处",matchCase:"区分大小写",sourceLabel:"HTML 源码",letterSpacingNormal:"标准",tooLarge:"文件不能超过 {size}",specialGroups:{symbols:"符号",arrows:"箭头",numbers:"圆圈数字",units:"单位",brackets:"括号",math:"数学"}},fontFamily:{systemDefault:"系统默认"},blockAlign:{left:"左对齐",center:"居中对齐",right:"右对齐"},comingSoon:{label:"功能开发中"},dialogs:{confirm:"确定",cancel:"取消",insert:"插入",apply:"应用",importBtn:"导入",close:"关闭",selectedFileNone:"未选择文件",dropOrClick:"拖放或点击"},link:{title:"插入链接",text:"显示文本",textPlaceholder:"要显示的文本",url:"URL",urlPlaceholder:"https://example.com",openNewWindow:"在新窗口中打开"},image:{title:"图片",embedTab:"嵌入",embedTabTitle:"以 base64 数据嵌入",urlTab:"URL",urlTabTitle:"图片 URL",uploadTab:"上传",uploadTabTitle:"上传到服务器,使用响应 URL",uploadDisabledTitle:"未注册上传 API",embedDropzone:"选择图片 (base64 嵌入)",urlLabel:"图片 URL",urlPlaceholder:"https://example.com/image.jpg",uploadDropzone:"选择要上传的图片",noUploadApi:"未注册上传 API。",captionAdd:"添加说明",captionPlaceholder:"输入图片说明"},youtube:{title:"YouTube 嵌入",urlLabel:"YouTube URL",urlPlaceholder:"https://www.youtube.com/watch?v=…",formatHint:"支持 youtu.be / youtube.com/watch / /embed / /shorts"},table:{title:"插入表格",statusZero:"0 × 0 表格",statusFormat:"{r} × {c} 表格",pickerHint:"选择尺寸"},importHtml:{title:"HTML",fileSelect:"选择 HTML 文件",pasteLabel:"直接粘贴",pastePlaceholder:"或在此处粘贴 HTML…",hint:"通过 iframe 加载并将所有样式内联化导入。",errEmpty:"要导入的 HTML 为空。",errNoBody:"HTML 中未找到内容。",errFailed:"HTML 导入失败: "},importMarkdown:{title:"Markdown",fileSelect:"选择 Markdown 文件",pasteLabel:"直接粘贴",pastePlaceholder:"或在此处粘贴 Markdown…",hint:"支持 CommonMark 基础语法(标题/列表/链接/代码/表格/引用)",errEmpty:"要导入的 Markdown 为空。",errNoBody:"Markdown 中未找到内容。",errFailed:"Markdown 解析失败: "},fileAttach:{title:"附加文件",urlTab:"URL",urlTabTitle:"直接输入已托管文件的 URL",uploadTab:"上传",uploadTabTitle:"上传到服务器,使用响应 URL",uploadDisabledTitle:"未注册文件上传 API",urlLabel:"文件 URL",urlPlaceholder:"https://example.com/files/report.pdf",nameLabel:"文件名",namePlaceholder:"显示名称 (例如: report.pdf)",noUploadApi:"未注册文件上传 API。",uploadDropzone:"选择要上传的文件",uploadComplete:" — 上传完成",uploadFailed:"上传失败: ",errEmpty:"文件 URL 为空。"},content:{emptyHint:"输入内容"},status:{noActive:"— 无活动块",blocksCount:"{n} 块",chars:"文本 {n} 字",source:"源 {n}"}},go={en:po,ko:cn,ja:fo,zh:mo};let dn=cn;function bo(n){dn=go[n]}function m(){return dn}function J(n,e){return n.replace(/\{(\w+)\}/g,(t,o)=>String(e[o]??""))}const x={taskList:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 7 5 9 9 5"/><polyline points="3 17 5 19 9 15"/><line x1="13" y1="7" x2="21" y2="7"/><line x1="13" y1="17" x2="21" y2="17"/></svg>',undo:'<svg 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-15-6.7L3 13"/></svg>',redo:'<svg 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 15-6.7L21 13"/></svg>',blockType:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="5" rx="1.2"/><line x1="3" y1="13" x2="21" y2="13"/><line x1="3" y1="17" x2="21" y2="17"/><line x1="3" y1="21" x2="14" y2="21"/></svg>',fontFamily:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18 L7 6 L11 18"/><line x1="4.5" y1="14" x2="9.5" y2="14"/><path d="M14 12 a3 3 0 1 1 0 6 a3 3 0 0 1 0 -6"/><line x1="20" y1="12" x2="20" y2="18"/></svg>',fontSize:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6 L13 6"/><line x1="8" y1="6" x2="8" y2="19"/><polyline points="17 9 20 6 17 6"/><line x1="20" y1="6" x2="20" y2="18"/><polyline points="17 15 20 18 17 18"/></svg>',bold:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4h8a4 4 0 0 1 0 8H6z"/><path d="M6 12h9a4 4 0 0 1 0 8H6z"/></svg>',italic:'<svg 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 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 12 0V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>',strike:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',superscript:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l8 13"/><path d="M12 6L4 19"/><path d="M17 9V5h2.5a1.5 1.5 0 0 1 0 3H19a1.5 1.5 0 0 0 0 3h2"/></svg>',subscript:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 5l8 13"/><path d="M12 5L4 18"/><path d="M17 21v-4h2.5a1.5 1.5 0 0 1 0 3H19a1.5 1.5 0 0 0 0 3h2"/></svg>',color:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16"/><path d="M6 17l5-12 2-1 2 1 5 12"/><path d="M8 13h8"/></svg>',backgroundColor:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12l9-9 9 9-9 9z"/><path d="M3 12h18"/></svg>',alignLeft:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>',alignCenter:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>',alignRight:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>',alignJustify:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="3" y2="18"/></svg>',bulletList:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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.5" cy="6" r="1.5" fill="currentColor"/><circle cx="4.5" cy="12" r="1.5" fill="currentColor"/><circle cx="4.5" cy="18" r="1.5" fill="currentColor"/></svg>',orderedList:'<svg 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-1.5-2-1"/></svg>',blockquote:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>',codeBlock:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',callout:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><line x1="7" y1="4" x2="7" y2="20"/><line x1="12" y1="9" x2="12" y2="13"/><circle cx="12" cy="16" r="0.6" fill="currentColor"/></svg>',toggle:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 5 11 9 5 13" fill="currentColor" stroke="none"/><line x1="14" y1="9" x2="21" y2="9"/><line x1="3" y1="18" x2="21" y2="18"/></svg>',link:'<svg 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 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" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',table:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',hr:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="12" x2="20" y2="12"/></svg>',clearFormat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7V4h16v3"/><path d="M5 20h6"/><path d="M13 4 8 20"/><line x1="15" y1="15" x2="20" y2="20"/><line x1="20" y1="15" x2="15" y2="20"/></svg>',lineHeight:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="11" y1="6" x2="21" y2="6"/><line x1="11" y1="12" x2="21" y2="12"/><line x1="11" y1="18" x2="21" y2="18"/><polyline points="3 8 5.5 5 8 8"/><polyline points="3 16 5.5 19 8 16"/><line x1="5.5" y1="5" x2="5.5" y2="19"/></svg>',letterSpacing:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 14 L9 5 L12 14"/><line x1="7" y1="11" x2="11" y2="11"/><path d="M14 14 V5 h3 a2.2 2.2 0 0 1 0 4.5 H14 h3.5 a2.3 2.3 0 0 1 0 4.5 H14"/><polyline points="5 20 3 18 5 16"/><polyline points="19 16 21 18 19 20"/><line x1="3" y1="18" x2="21" y2="18"/></svg>',specialChar:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 20h-4v-2.5a7.5 7.5 0 1 1 16 0V20h-4"/><path d="M8 20v-2.2a5 5 0 0 1-1-1.3"/><path d="M16 20v-2.2a5 5 0 0 0 1-1.3"/></svg>',findReplace:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><line x1="15.5" y1="15.5" x2="21" y2="21"/></svg>',source:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 7 3 12 8 17"/><polyline points="16 7 21 12 16 17"/><line x1="13.5" y1="5" x2="10.5" y2="19"/></svg>',print:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 6 3 18 3 18 9"/><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="7"/></svg>',fullscreen:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 9 4 4 9 4"/><polyline points="20 9 20 4 15 4"/><polyline points="4 15 4 20 9 20"/><polyline points="20 15 20 20 15 20"/></svg>',chevronDown:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>',close:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>',upload:'<svg 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="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>',externalLink:'<svg 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>',youtube:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="20" height="12" rx="3"/><polygon points="10 9.5 15 12 10 14.5" fill="currentColor" stroke="none"/></svg>',importHtml:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h11l5 5v11a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><path d="M14 4v5h5"/><path d="M12 12v6"/><polyline points="9 15 12 18 15 15"/></svg>',importMarkdown:'<svg 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="2"/><path d="M6 15V9l3 3 3-3v6"/><path d="M16 9v6"/><polyline points="14 13 16 15 18 13"/></svg>',attachFile:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57a4 4 0 0 1 5.66 5.66l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',cellBg:'<svg 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.5"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/><rect x="3" y="3" width="9" height="9" fill="currentColor" opacity="0.35" stroke="none"/></svg>',tableMenu:'<svg 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.5"/><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>',codeLang:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/><line x1="14" y1="4" x2="10" y2="20"/></svg>'};function yo(){const n=m().toolbar;return{undo:{name:"undo",label:n.undo,icon:"undo",shortcut:"Ctrl+Z"},redo:{name:"redo",label:n.redo,icon:"redo",shortcut:"Ctrl+Y"},blockType:{name:"blockType",label:n.blockType,icon:"blockType",hasDropdown:!0,shortcut:"Ctrl+Alt+0~9"},fontFamily:{name:"fontFamily",label:n.fontFamily,icon:"fontFamily",hasDropdown:!0},fontSize:{name:"fontSize",label:n.fontSize,icon:"fontSize",hasDropdown:!0},bold:{name:"bold",label:n.bold,icon:"bold",shortcut:"Ctrl+B"},italic:{name:"italic",label:n.italic,icon:"italic",shortcut:"Ctrl+I"},underline:{name:"underline",label:n.underline,icon:"underline",shortcut:"Ctrl+U"},strike:{name:"strike",label:n.strike,icon:"strike",shortcut:"Ctrl+Shift+X"},superscript:{name:"superscript",label:n.superscript,icon:"superscript",shortcut:"Ctrl+."},subscript:{name:"subscript",label:n.subscript,icon:"subscript",shortcut:"Ctrl+,"},color:{name:"color",label:n.color,icon:"color",hasDropdown:!0},backgroundColor:{name:"backgroundColor",label:n.backgroundColor,icon:"backgroundColor",hasDropdown:!0},align:{name:"align",label:n.align,icon:"alignLeft",hasDropdown:!0},cellBg:{name:"cellBg",label:n.cellBg,icon:"cellBg",hasDropdown:!0},tableMenu:{name:"tableMenu",label:n.tableMenu,icon:"tableMenu",hasDropdown:!0},codeLang:{name:"codeLang",label:n.codeLang,icon:"codeLang",hasDropdown:!0},bulletList:{name:"bulletList",label:n.bulletList,icon:"bulletList",shortcut:"Ctrl+Alt+8"},orderedList:{name:"orderedList",label:n.orderedList,icon:"orderedList",shortcut:"Ctrl+Alt+7"},blockquote:{name:"blockquote",label:n.blockquote,icon:"blockquote",shortcut:"Ctrl+Alt+9"},codeBlock:{name:"codeBlock",label:n.codeBlock,icon:"codeBlock",shortcut:"Ctrl+Alt+C"},link:{name:"link",label:n.link,icon:"link"},image:{name:"image",label:n.image,icon:"image"},table:{name:"table",label:n.table,icon:"table"},hr:{name:"hr",label:n.hr,icon:"hr"},clearFormat:{name:"clearFormat",label:n.clearFormat,icon:"clearFormat"},lineHeight:{name:"lineHeight",label:n.lineHeight,icon:"lineHeight",hasDropdown:!0},letterSpacing:{name:"letterSpacing",label:n.letterSpacing,icon:"letterSpacing",hasDropdown:!0},specialChar:{name:"specialChar",label:n.specialChar,icon:"specialChar",hasDropdown:!0},findReplace:{name:"findReplace",label:n.findReplace,icon:"findReplace"},source:{name:"source",label:n.source,icon:"source"},print:{name:"print",label:n.print,icon:"print"},fullscreen:{name:"fullscreen",label:n.fullscreen,icon:"fullscreen"}}}class ko{constructor(e,t){b(this,"element");b(this,"buttons",new Map);this.element=document.createElement("div"),this.element.className="aw-toolbar",this.element.setAttribute("role","toolbar"),this.element.setAttribute("aria-label",m().toolbar.ariaLabel),e.sticky!==!1&&this.element.classList.add("aw-toolbar-sticky");const o=yo();let r=this.createGroup();this.element.appendChild(r);for(const l of e.items){if(l==="|"){r=this.createGroup(),this.element.appendChild(r);continue}const s=o[l];if(!s)continue;const a=this.createButton(s,t);this.buttons.set(s.name,a),r.appendChild(a)}const i=this.buttons.values().next().value;i&&(i.tabIndex=0),this.element.addEventListener("keydown",l=>this.handleKeydown(l,t)),this.element.addEventListener("focusin",l=>{const s=l.target;if(s instanceof HTMLButtonElement)for(const a of this.buttons.values()){const c=a===s?0:-1;a.tabIndex!==c&&(a.tabIndex=c)}})}names(){return Array.from(this.buttons.keys())}focus(){const e=this.focusable(),t=e.find(o=>o.tabIndex===0)??e[0];t==null||t.focus()}setAllEnabled(e,t){for(const[o,r]of this.buttons)o!==t&&(r.disabled=!e)}focusable(){return Array.from(this.buttons.values()).filter(e=>{var t;return!e.disabled&&e.style.display!=="none"&&((t=e.parentElement)==null?void 0:t.style.display)!=="none"})}handleKeydown(e,t){var l;if(e.key==="Escape"){e.preventDefault(),t.onEscape();return}const o=this.focusable(),r=o.indexOf(document.activeElement);let i=-1;e.key==="ArrowRight"?i=(r+1)%o.length:e.key==="ArrowLeft"?i=(r-1+o.length)%o.length:e.key==="Home"?i=0:e.key==="End"&&(i=o.length-1),!(i<0||o.length===0)&&(e.preventDefault(),(l=o[i])==null||l.focus())}setActive(e,t){const o=this.buttons.get(e);if(!o)return;o.classList.contains("aw-toolbar-btn-active")!==t&&o.classList.toggle("aw-toolbar-btn-active",t);const r=String(t);o.getAttribute("aria-pressed")!==r&&o.setAttribute("aria-pressed",r)}setEnabled(e,t){const o=this.buttons.get(e);o&&(o.disabled=!t)}setVisible(e,t){const o=this.buttons.get(e);if(!o)return;const r=t?"":"none";o.style.display!==r&&(o.style.display=r)}syncGroupVisibility(){const e=this.element.querySelectorAll(".aw-toolbar-group");for(const t of Array.from(e)){const r=Array.from(t.children).some(i=>i instanceof HTMLElement&&i.style.display!=="none")?"":"none";t.style.display!==r&&(t.style.display=r)}}createGroup(){const e=document.createElement("div");return e.className="aw-toolbar-group",e}createButton(e,t){const o=document.createElement("button");o.type="button",o.className="aw-toolbar-btn",o.tabIndex=-1,e.hasDropdown&&(o.classList.add("aw-toolbar-btn-dropdown"),o.setAttribute("aria-haspopup","menu"));const r=e.shortcut?`${e.label} (${e.shortcut})`:e.label;o.title=r,o.setAttribute("aria-label",r),o.dataset.command=e.name;const i=x[e.icon]??"";return o.innerHTML=`<span class="aw-toolbar-btn-icon">${i}</span>`,e.hasDropdown&&(o.innerHTML+=`<span class="aw-toolbar-btn-chevron">${x.chevronDown}</span>`),o.addEventListener("mousedown",l=>{l.preventDefault()}),o.addEventListener("click",()=>{t.onAction(e.name,o)}),o}}function ae(n,e,t){const o=document.createElement("div");o.className="aw-dialog-overlay",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),e&&(o.dataset.theme=e);const r=document.createElement("div");r.className="aw-dialog";const i=document.createElement("div");i.className="aw-dialog-header";const l=document.createElement("h2");l.className="aw-dialog-title",l.textContent=n;const s=document.createElement("button");s.type="button",s.className="aw-dialog-close",s.innerHTML=x.close,i.appendChild(l),i.appendChild(s);const a=document.createElement("div");a.className="aw-dialog-body";const c=document.createElement("div");c.className="aw-dialog-footer",r.appendChild(i),r.appendChild(a),r.appendChild(c),o.appendChild(r);let u=!1;const d=p=>{p.key==="Escape"&&f()},h=()=>{u||(u=!0,document.removeEventListener("keydown",d),o.remove())},f=()=>{u||(h(),t==null||t())};return s.setAttribute("aria-label",m().dialogs.close),s.addEventListener("click",f),o.addEventListener("click",p=>{p.target===o&&f()}),document.addEventListener("keydown",d),{overlay:o,body:a,footer:c,close:h}}function W(n,e){const t=document.createElement("div");t.className="aw-field";const o=document.createElement("label");return o.className="aw-field-label",o.textContent=n,t.appendChild(o),t.appendChild(e),t}function wo(n={},e){return new Promise(t=>{const{overlay:o,body:r,footer:i,close:l}=ae(m().link.title,e,()=>t({confirmed:!1})),s=document.createElement("input");s.type="text",s.className="aw-input",s.placeholder=m().link.textPlaceholder,s.value=n.text??"";const a=document.createElement("input");a.type="url",a.className="aw-input",a.placeholder=m().link.urlPlaceholder,a.value=n.href??"";const c=document.createElement("label");c.className="aw-checkbox";const u=document.createElement("input");u.type="checkbox",u.checked=n.newWindow??!1;const d=document.createElement("span");d.textContent=m().link.openNewWindow,c.appendChild(u),c.appendChild(d),r.appendChild(W(m().link.text,s)),r.appendChild(W(m().link.url,a)),r.appendChild(c);const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-ghost",h.textContent=m().dialogs.cancel;const f=document.createElement("button");f.type="button",f.className="aw-btn aw-btn-primary",f.textContent=m().dialogs.confirm,i.appendChild(h),i.appendChild(f),h.addEventListener("click",()=>{l(),t({confirmed:!1})}),f.addEventListener("click",()=>{l(),t({confirmed:!0,text:s.value,href:a.value,newWindow:u.checked})}),document.body.appendChild(o),setTimeout(()=>a.focus(),0)})}function vo(n={},e){return new Promise(t=>{const{overlay:o,body:r,footer:i,close:l}=ae(m().image.title,e,()=>t({confirmed:!1})),s=document.createElement("div");s.className="aw-tabs";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent=m().image.embedTab,a.title=m().image.embedTabTitle;const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent=m().image.urlTab,c.title=m().image.urlTabTitle;const u=document.createElement("button");u.type="button",u.className="aw-tab",u.textContent=m().image.uploadTab;const d=!!n.onUpload;d?u.title=m().image.uploadTabTitle:(u.disabled=!0,u.classList.add("aw-tab-disabled"),u.title=m().image.uploadDisabledTitle),s.appendChild(a),s.appendChild(c),s.appendChild(u),r.appendChild(s);const h=document.createElement("div");h.className="aw-pane";const f=Et(m().image.embedDropzone),p=document.createElement("div");p.className="aw-preview",p.style.display="none",h.appendChild(f.dropzone),h.appendChild(p);const g=document.createElement("div");g.className="aw-pane";const k=document.createElement("input");k.type="url",k.className="aw-input",k.placeholder=m().image.urlPlaceholder,g.appendChild(W(m().image.urlLabel,k));const y=document.createElement("div");if(y.className="aw-pane",d){const w=Et(m().image.uploadDropzone),E=document.createElement("div");E.className="aw-preview",E.style.display="none",y.appendChild(w.dropzone),y.appendChild(E),w.input.addEventListener("change",async()=>{var _;const q=(_=w.input.files)==null?void 0:_[0];if(!(!q||!n.onUpload))try{w.dropzone.classList.add("aw-dropzone-loading");const we=await n.onUpload(q);v=we,E.style.backgroundImage=`url(${JSON.stringify(we)})`,E.style.display="block"}catch(we){console.error(we)}finally{w.dropzone.classList.remove("aw-dropzone-loading"),w.input.value=""}})}else{const w=document.createElement("div");w.className="aw-pane-notice",w.textContent=m().image.noUploadApi,y.appendChild(w)}r.appendChild(h),r.appendChild(g),r.appendChild(y);let C="embed",A,v;const L=w=>{w==="upload"&&!d||(C=w,a.classList.toggle("aw-tab-active",w==="embed"),c.classList.toggle("aw-tab-active",w==="url"),u.classList.toggle("aw-tab-active",w==="upload"),h.style.display=w==="embed"?"block":"none",g.style.display=w==="url"?"block":"none",y.style.display=w==="upload"?"block":"none")};L(C),a.addEventListener("click",()=>L("embed")),c.addEventListener("click",()=>L("url")),u.addEventListener("click",()=>L("upload")),f.input.addEventListener("change",()=>{var q;const w=(q=f.input.files)==null?void 0:q[0];if(!w)return;const E=new FileReader;E.onload=()=>{const _=String(E.result??"");A=_,p.style.backgroundImage=`url(${JSON.stringify(_)})`,p.style.display="block",f.input.value=""},E.readAsDataURL(w)});const N=document.createElement("button");N.type="button",N.className="aw-btn aw-btn-ghost",N.textContent=m().dialogs.cancel;const $=document.createElement("button");$.type="button",$.className="aw-btn aw-btn-primary",$.textContent=m().dialogs.confirm,i.appendChild(N),i.appendChild($),N.addEventListener("click",()=>{l(),t({confirmed:!1})}),$.addEventListener("click",()=>{let w;C==="embed"?w=A:C==="url"?w=k.value||void 0:C==="upload"&&(w=v),l();const E={confirmed:!0};w&&(E.src=w),t(E)}),document.body.appendChild(o)})}function Et(n){const e=document.createElement("label");e.className="aw-dropzone",e.innerHTML=`
2
+ ${x.upload}
3
+ <div class="aw-dropzone-text">${n}<br/>${m().dialogs.dropOrClick}</div>
4
+ `;const t=document.createElement("input");return t.type="file",t.accept="image/*",t.style.display="none",e.appendChild(t),{dropzone:e,input:t}}function Co(n){return new Promise(e=>{const{overlay:t,body:o,footer:r,close:i}=ae(m().importHtml.title,n,()=>e({confirmed:!1})),l=document.createElement("input");l.type="file",l.accept=".html,.htm,text/html",l.style.display="none";const s=document.createElement("label");s.className="aw-dropzone",s.innerHTML=`
5
+ ${x.importHtml}
6
+ <div class="aw-dropzone-text">${m().importHtml.fileSelect}<br/>${m().dialogs.dropOrClick}</div>
7
+ `,s.appendChild(l);const a=document.createElement("div");a.className="aw-dialog-hint",a.textContent=m().dialogs.selectedFileNone;const c=document.createElement("textarea");c.className="aw-input aw-textarea",c.placeholder=m().importHtml.pastePlaceholder,c.rows=8,o.appendChild(s),o.appendChild(a),o.appendChild(W(m().importHtml.pasteLabel,c));const u=document.createElement("div");u.className="aw-dialog-hint",u.textContent=m().importHtml.hint,o.appendChild(u);let d;l.addEventListener("change",()=>{var k;const p=(k=l.files)==null?void 0:k[0];if(!p)return;const g=new FileReader;g.onload=()=>{d=String(g.result??""),c.value=d,a.textContent=`${p.name} (${p.size.toLocaleString()} bytes)`,l.value=""},g.readAsText(p)}),s.addEventListener("dragover",p=>{p.preventDefault(),s.classList.add("aw-dropzone-loading")}),s.addEventListener("dragleave",()=>{s.classList.remove("aw-dropzone-loading")}),s.addEventListener("drop",p=>{var y,C;p.preventDefault(),s.classList.remove("aw-dropzone-loading");const g=(C=(y=p.dataTransfer)==null?void 0:y.files)==null?void 0:C[0];if(!g)return;const k=new FileReader;k.onload=()=>{d=String(k.result??""),c.value=d,a.textContent=`${g.name} (${g.size.toLocaleString()} bytes)`},k.readAsText(g)});const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-ghost",h.textContent=m().dialogs.cancel;const f=document.createElement("button");f.type="button",f.className="aw-btn aw-btn-primary",f.textContent=m().dialogs.importBtn,r.appendChild(h),r.appendChild(f),h.addEventListener("click",()=>{i(),e({confirmed:!1})}),f.addEventListener("click",()=>{const p=c.value.trim();i();const g={confirmed:!0};p.length>0&&(g.html=p),e(g)}),document.body.appendChild(t)})}function Ao(n){return new Promise(e=>{const{overlay:t,body:o,footer:r,close:i}=ae(m().importMarkdown.title,n,()=>e({confirmed:!1})),l=document.createElement("input");l.type="file",l.accept=".md,.markdown,text/markdown,text/plain",l.style.display="none";const s=document.createElement("label");s.className="aw-dropzone",s.innerHTML=`
8
+ ${x.importMarkdown}
9
+ <div class="aw-dropzone-text">${m().importMarkdown.fileSelect}<br/>${m().dialogs.dropOrClick}</div>
10
+ `,s.appendChild(l);const a=document.createElement("div");a.className="aw-dialog-hint",a.textContent=m().dialogs.selectedFileNone;const c=document.createElement("textarea");c.className="aw-input aw-textarea",c.placeholder=m().importMarkdown.pastePlaceholder,c.rows=8,o.appendChild(s),o.appendChild(a),o.appendChild(W(m().importMarkdown.pasteLabel,c));const u=document.createElement("div");u.className="aw-dialog-hint",u.textContent=m().importMarkdown.hint,o.appendChild(u),l.addEventListener("change",()=>{var g;const f=(g=l.files)==null?void 0:g[0];if(!f)return;const p=new FileReader;p.onload=()=>{const k=String(p.result??"");c.value=k,a.textContent=`${f.name} (${f.size.toLocaleString()} bytes)`,l.value=""},p.readAsText(f)}),s.addEventListener("dragover",f=>{f.preventDefault(),s.classList.add("aw-dropzone-loading")}),s.addEventListener("dragleave",()=>{s.classList.remove("aw-dropzone-loading")}),s.addEventListener("drop",f=>{var k,y;f.preventDefault(),s.classList.remove("aw-dropzone-loading");const p=(y=(k=f.dataTransfer)==null?void 0:k.files)==null?void 0:y[0];if(!p)return;const g=new FileReader;g.onload=()=>{const C=String(g.result??"");c.value=C,a.textContent=`${p.name} (${p.size.toLocaleString()} bytes)`},g.readAsText(p)});const d=document.createElement("button");d.type="button",d.className="aw-btn aw-btn-ghost",d.textContent=m().dialogs.cancel;const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-primary",h.textContent=m().dialogs.importBtn,r.appendChild(d),r.appendChild(h),d.addEventListener("click",()=>{i(),e({confirmed:!1})}),h.addEventListener("click",()=>{const f=c.value.trim();i();const p={confirmed:!0};f.length>0&&(p.markdown=f),e(p)}),document.body.appendChild(t)})}function Lo(n={},e){return new Promise(t=>{const{overlay:o,body:r,footer:i,close:l}=ae(m().fileAttach.title,e,()=>t({confirmed:!1})),s=document.createElement("div");s.className="aw-tabs";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent=m().fileAttach.urlTab,a.title=m().fileAttach.urlTabTitle;const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent=m().fileAttach.uploadTab;const u=!!n.onUpload;u?c.title=m().fileAttach.uploadTabTitle:(c.disabled=!0,c.classList.add("aw-tab-disabled"),c.title=m().fileAttach.uploadDisabledTitle),s.appendChild(a),s.appendChild(c),r.appendChild(s);const d=document.createElement("div");d.className="aw-pane";const h=document.createElement("input");h.type="url",h.className="aw-input",h.placeholder=m().fileAttach.urlPlaceholder,d.appendChild(W(m().fileAttach.urlLabel,h));const f=document.createElement("input");f.type="text",f.className="aw-input",f.placeholder=m().fileAttach.namePlaceholder,d.appendChild(W(m().fileAttach.nameLabel,f));const p=document.createElement("div");p.className="aw-pane";let g;if(u){const v=document.createElement("label");v.className="aw-dropzone",v.innerHTML=`
11
+ ${x.upload}
12
+ <div class="aw-dropzone-text">${m().fileAttach.uploadDropzone}<br/>${m().dialogs.dropOrClick}</div>
13
+ `;const L=document.createElement("input");L.type="file",L.style.display="none",v.appendChild(L);const N=document.createElement("div");N.className="aw-dialog-hint",N.textContent=m().dialogs.selectedFileNone,p.appendChild(v),p.appendChild(N);const $=async w=>{if(n.onUpload)try{v.classList.add("aw-dropzone-loading"),g={src:await n.onUpload(w),name:w.name,size:w.size,type:w.type||""},N.textContent=`${w.name} (${w.size.toLocaleString()} bytes)${m().fileAttach.uploadComplete}`}catch(E){console.error(E),N.textContent=`${m().fileAttach.uploadFailed}${E instanceof Error?E.message:String(E)}`}finally{v.classList.remove("aw-dropzone-loading"),L.value=""}};L.addEventListener("change",()=>{var E;const w=(E=L.files)==null?void 0:E[0];w&&$(w)}),v.addEventListener("dragover",w=>{w.preventDefault(),v.classList.add("aw-dropzone-loading")}),v.addEventListener("dragleave",()=>{v.classList.remove("aw-dropzone-loading")}),v.addEventListener("drop",w=>{var q,_;w.preventDefault();const E=(_=(q=w.dataTransfer)==null?void 0:q.files)==null?void 0:_[0];E&&$(E)})}else{const v=document.createElement("div");v.className="aw-pane-notice",v.textContent=m().fileAttach.noUploadApi,p.appendChild(v)}r.appendChild(d),r.appendChild(p);let k="url";const y=v=>{v==="upload"&&!u||(k=v,a.classList.toggle("aw-tab-active",v==="url"),c.classList.toggle("aw-tab-active",v==="upload"),d.style.display=v==="url"?"block":"none",p.style.display=v==="upload"?"block":"none")};y(k),a.addEventListener("click",()=>y("url")),c.addEventListener("click",()=>y("upload"));const C=document.createElement("button");C.type="button",C.className="aw-btn aw-btn-ghost",C.textContent=m().dialogs.cancel;const A=document.createElement("button");A.type="button",A.className="aw-btn aw-btn-primary",A.textContent=m().dialogs.confirm,i.appendChild(C),i.appendChild(A),C.addEventListener("click",()=>{l(),t({confirmed:!1})}),A.addEventListener("click",()=>{const v={confirmed:!0};if(k==="url"){const L=h.value.trim(),N=f.value.trim();L.length>0&&(v.src=L),N.length>0&&(v.name=N)}else g&&(v.src=g.src,v.name=g.name,v.size=g.size,g.type&&(v.type=g.type));l(),t(v)}),document.body.appendChild(o)})}function xo(n){return new Promise(e=>{const{overlay:t,body:o,footer:r,close:i}=ae(m().youtube.title,n,()=>e({confirmed:!1})),l=document.createElement("input");l.type="url",l.className="aw-input",l.placeholder=m().youtube.urlPlaceholder,o.appendChild(W(m().youtube.urlLabel,l));const s=document.createElement("div");s.className="aw-dialog-hint",s.textContent=m().youtube.formatHint,o.appendChild(s);const a=document.createElement("button");a.type="button",a.className="aw-btn aw-btn-ghost",a.textContent=m().dialogs.cancel;const c=document.createElement("button");c.type="button",c.className="aw-btn aw-btn-primary",c.textContent=m().dialogs.confirm,r.appendChild(a),r.appendChild(c),a.addEventListener("click",()=>{i(),e({confirmed:!1})}),c.addEventListener("click",()=>{i(),e({confirmed:!0,url:l.value})}),document.body.appendChild(t),setTimeout(()=>l.focus(),0)})}const Eo={label:"",stack:""},un=[Eo,{label:"맑은 고딕",stack:'"Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif'},{label:"굴림",stack:'Gulim, "굴림", sans-serif'},{label:"돋움",stack:'Dotum, "돋움", sans-serif'},{label:"바탕",stack:'Batang, "바탕", AppleMyungjo, serif'},{label:"궁서",stack:'Gungsuh, "궁서", serif'},{label:"나눔고딕",stack:'"Nanum Gothic", "나눔고딕", sans-serif'},{label:"나눔명조",stack:'"Nanum Myeongjo", "나눔명조", serif'},{label:"Apple SD 산돌고딕 Neo",stack:'"Apple SD Gothic Neo", sans-serif'},{label:"Arial",stack:"Arial, Helvetica, sans-serif"},{label:"Times New Roman",stack:'"Times New Roman", Times, serif'},{label:"Courier New",stack:'"Courier New", Courier, monospace'}],hn=[8,9,10,10.5,11,12,14,16,18,20,24,28,32,36,48];function So(n){var r;if(!n)return null;const e=/^(\d+(?:\.\d+)?)(px|pt)$/i.exec(n.trim());if(!e||!e[1])return null;const t=Number(e[1]),o=((r=e[2])==null?void 0:r.toLowerCase())==="pt"?t:t*.75;return Math.round(o*2)/2}const et=new Set,St=new Set,tt=new Set,To="가A";function No(n){return n.filter(e=>!e.stack||!et.has(e.stack))}function Bo(n){return tt.add(n),()=>{tt.delete(n)}}function Mo(n){if(!it(n))return!1;const t=document.createElement("canvas").getContext("2d");if(!t)return!0;const o=i=>(t.font=`16px ${i}`,t.measureText("가나다ABCwi").width);return n.split(",").map(i=>i.trim().replace(/^["']|["']$/g,"")).filter(i=>i&&!/^(serif|sans-serif|monospace|cursive|fantasy|system-ui)$/i.test(i)).slice(0,2).some(i=>["monospace","serif"].some(l=>o(`"${i}", ${l}`)!==o(l)))}function Ae(n){let e=!1;for(const t of n)et.has(t.stack)||Mo(t.stack)||(et.add(t.stack),e=!0);if(e)for(const t of tt)t()}function $o(n){if(typeof document>"u")return;const e=[];for(const t of n)!t.stack||St.has(t.stack)||(St.add(t.stack),t.cssUrl?Ho(t.cssUrl,t):e.push(t));e.length&&Ae(e)}function Ho(n,e){const t=()=>{const r=it(e.stack),i=document.fonts;!r||!i||typeof i.load!="function"||i.load(`16px "${r}"`,To).then(l=>{l.length===0&&Ae([e])}).catch(()=>Ae([e]))};if(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(r=>r.href===n)){t();return}const o=document.createElement("link");o.rel="stylesheet",o.href=n,o.addEventListener("error",()=>Ae([e])),o.addEventListener("load",t),document.head.appendChild(o)}function Ro(n,e){var o;const t=e?(o=it(e))==null?void 0:o.toLowerCase():null;if(!t)return null;for(const r of n){if(!r.stack)continue;if(r.stack.split(",").slice(0,2).map(l=>l.trim().replace(/^["']|["']$/g,"").toLowerCase()).includes(t))return r}return null}function it(n){var t;const e=(t=n.split(",")[0])==null?void 0:t.trim();return e?e.replace(/^["']|["']$/g,""):null}function T(n){n.addEventListener("mousedown",e=>e.preventDefault())}const nt=["#000000","#5c5c5c","#9c9c9c","#cfcfcf","#ffffff","#e03131","#f76707","#f59f00","#94d82d","#0ca678","#1c7ed6","#7048e8","#d6336c","#fab005","#37b24d","#1098ad"];function Pe(n,e,t=[]){F();const o=document.createElement("div");o.className="aw-popover aw-color-popover",o.dataset.popover="true",T(o);const r=u=>{e(u),o.remove()},i=u=>{const d=document.createElement("button");return d.type="button",d.className="aw-color-swatch",d.style.backgroundColor=u,d.setAttribute("aria-label",u),d.title=u,T(d),d.addEventListener("click",h=>{h.stopPropagation(),r(u)}),d},l=document.createElement("div");l.className="aw-color-grid";for(const u of nt)l.appendChild(i(u));o.appendChild(l);const s=document.createElement("button");s.type="button",s.className="aw-popover-action",s.textContent=m().color.defaultColor,T(s),s.addEventListener("click",u=>{u.stopPropagation(),r(null)});const a=document.createElement("button");a.type="button",a.className="aw-popover-action",a.textContent=m().color.customColor,T(a);const c=document.createElement("input");if(c.type="color",c.tabIndex=-1,c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.left="-9999px",c.style.width="0",c.style.height="0",c.style.opacity="0",c.style.pointerEvents="none",c.addEventListener("change",()=>{r(c.value)}),a.addEventListener("click",u=>{u.stopPropagation(),c.click()}),o.appendChild(s),o.appendChild(a),o.appendChild(c),t.length>0){const u=document.createElement("div");u.className="aw-color-section",u.textContent=m().color.recent,o.appendChild(u);const d=document.createElement("div");d.className="aw-color-grid";for(const h of t)d.appendChild(i(h));o.appendChild(d)}z(o,n)}function Io(){const n=m().blockMenu;return[{label:n.body,kind:"paragraph",attrs:{},glyph:"¶"},{label:n.h1,kind:"heading",attrs:{level:1},glyph:"H1",weight:"700"},{label:n.h2,kind:"heading",attrs:{level:2},glyph:"H2",weight:"700"},{label:n.h3,kind:"heading",attrs:{level:3},glyph:"H3",weight:"700"},{label:n.bulletList,kind:"bulletList",attrs:{},glyph:x.bulletList,glyphIsSvg:!0,divider:!0},{label:n.orderedList,kind:"orderedList",attrs:{},glyph:x.orderedList,glyphIsSvg:!0},{label:n.taskList,kind:"taskList",attrs:{},glyph:x.taskList,glyphIsSvg:!0},{label:n.blockquote,kind:"blockquote",attrs:{},glyph:x.blockquote,glyphIsSvg:!0,divider:!0},{label:n.codeBlock,kind:"codeBlock",attrs:{},glyph:x.codeBlock,glyphIsSvg:!0},{label:n.toggle,kind:"toggle",attrs:{},glyph:x.toggle,glyphIsSvg:!0},{label:n.callout,kind:"callout",attrs:{},glyph:x.callout,glyphIsSvg:!0},{label:n.link,kind:"linkCard",attrs:{},glyph:x.link,glyphIsSvg:!0,divider:!0},{label:n.image,kind:"image",attrs:{},glyph:x.image,glyphIsSvg:!0},{label:n.table,kind:"table",attrs:{},glyph:x.table,glyphIsSvg:!0},{label:n.youtube,kind:"youtube",attrs:{},glyph:x.youtube,glyphIsSvg:!0},{label:n.file,kind:"file",attrs:{},glyph:x.attachFile,glyphIsSvg:!0},{label:n.hr,kind:"hr",attrs:{},glyph:x.hr,glyphIsSvg:!0},{label:n.importHtml,kind:"importHtml",attrs:{},glyph:x.importHtml,glyphIsSvg:!0,divider:!0},{label:n.importMarkdown,kind:"importMarkdown",attrs:{},glyph:x.importMarkdown,glyphIsSvg:!0}]}function Do(n,e){F();const t=document.createElement("div");t.className="aw-popover aw-block-type-popover",t.dataset.popover="true",T(t);for(const o of Io()){if(o.divider){const s=document.createElement("div");s.className="aw-popover-divider",t.appendChild(s)}const r=document.createElement("button");r.type="button",r.className="aw-popover-item";const i=document.createElement("span");i.className="aw-popover-item-glyph",o.glyphIsSvg?i.innerHTML=o.glyph:i.textContent=o.glyph;const l=document.createElement("span");l.className="aw-popover-item-label",l.textContent=o.label,o.size&&(l.style.fontSize=o.size),o.weight&&(l.style.fontWeight=o.weight),r.appendChild(i),r.appendChild(l),T(r),r.addEventListener("click",s=>{s.stopPropagation(),t.remove(),e({kind:o.kind,attrs:o.attrs})}),t.appendChild(r)}z(t,n)}function Po(n,e){F();const t=document.createElement("div");t.className="aw-popover aw-align-popover",t.dataset.popover="true",T(t);const o=m().align,r=[{icon:"alignLeft",value:"left",label:o.left},{icon:"alignCenter",value:"center",label:o.center},{icon:"alignRight",value:"right",label:o.right},{icon:"alignJustify",value:"justify",label:o.justify}];for(const i of r){const l=document.createElement("button");l.type="button",l.className="aw-popover-item aw-popover-item-icon",l.setAttribute("aria-label",i.label),l.title=i.label,l.innerHTML=x[i.icon]??"",T(l),l.addEventListener("click",s=>{s.stopPropagation(),t.remove(),e(i.value)}),t.appendChild(l)}z(t,n)}function zo(n,e,t,o){F();const r=document.createElement("div");r.className="aw-popover aw-font-family-popover",r.dataset.popover="true",r.setAttribute("role","menu"),T(r);const i=()=>{r.replaceChildren();for(const s of No(e)){const a=document.createElement("button");a.type="button",a.className="aw-popover-item aw-font-family-item",a.setAttribute("role","menuitem"),(o===s||!o&&!s.stack)&&a.classList.add("aw-popover-item-active");const c=s.stack?s.label:s.label||m().fontFamily.systemDefault;a.title=c;const u=document.createElement("span");u.className="aw-font-family-name",u.textContent=c;const d=document.createElement("span");d.className="aw-font-family-preview",d.textContent="가A",s.stack&&(d.style.fontFamily=s.stack),a.appendChild(u),a.appendChild(d),T(a),a.addEventListener("click",h=>{h.stopPropagation(),r.remove(),t(s)}),r.appendChild(a)}};i(),$o(e);const l=Bo(()=>{if(!r.isConnected){l();return}i()});z(r,n)}function Fo(n,e,t,o){F();const r=document.createElement("div");r.className="aw-popover aw-code-lang-popover",r.dataset.popover="true",T(r);for(const i of e){const l=document.createElement("button");l.type="button",l.className="aw-popover-item aw-code-lang-item",o===i.id&&l.classList.add("aw-popover-item-active"),l.title=i.label;const s=document.createElement("span");s.className="aw-popover-item-label",s.textContent=i.label,l.appendChild(s),T(l),l.addEventListener("click",a=>{a.stopPropagation(),r.remove(),t({id:i.id,label:i.label})}),r.appendChild(l)}z(r,n)}function Oo(){const n=m().tableMenu;return[{action:"rowAbove",label:n.rowAbove},{action:"rowBelow",label:n.rowBelow},{action:"colLeft",label:n.colLeft,divider:!0},{action:"colRight",label:n.colRight},{action:"deleteRow",label:n.deleteRow,divider:!0},{action:"deleteCol",label:n.deleteCol},{action:"mergeCells",label:n.mergeCells,divider:!0},{action:"splitCell",label:n.splitCell}]}function qo(n,e,t=new Set){F();const o=document.createElement("div");o.className="aw-popover aw-table-menu-popover",o.dataset.popover="true",T(o);for(const r of Oo()){if(r.divider){const l=document.createElement("div");l.className="aw-popover-divider",o.appendChild(l)}const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-table-menu-item",i.textContent=r.label,i.disabled=t.has(r.action),T(i),i.addEventListener("click",l=>{l.stopPropagation(),o.remove(),e(r.action)}),o.appendChild(i)}z(o,n)}function _o(n,e,t,o){F();const r=document.createElement("div");r.className="aw-popover aw-font-size-popover",r.dataset.popover="true",r.setAttribute("role","menu"),T(r);for(const i of e){const l=document.createElement("button");l.type="button",l.className="aw-popover-item aw-font-size-item",l.setAttribute("role","menuitem"),o===i&&l.classList.add("aw-popover-item-active"),l.title=`${i}pt`;const s=document.createElement("span");s.className="aw-font-size-label",s.textContent=String(i),l.appendChild(s),T(l),l.addEventListener("click",a=>{a.stopPropagation(),r.remove(),t(i)}),r.appendChild(l)}z(r,n)}function Tt(n,e){F();const t=2,o=12,r=document.createElement("div");r.className="aw-popover aw-table-popover",r.dataset.popover="true";const i=document.createElement("div");i.className="aw-table-picker-grid";const l=document.createElement("div");l.className="aw-table-status";let s=t,a=t,c=0,u=0;const d=[];function h(){for(let p=0;p<d.length;p++){const g=d[p];if(g)for(let k=0;k<g.length;k++){const y=g[k];y&&y.classList.toggle("aw-table-cell-active",p<c&&k<u)}}l.textContent=c>0&&u>0?J(m().table.statusFormat,{r:c,c:u}):m().table.pickerHint}function f(){i.innerHTML="",i.style.gridTemplateColumns=`repeat(${a}, 18px)`,i.style.gridTemplateRows=`repeat(${s}, 18px)`,d.length=0;for(let p=0;p<s;p++){const g=[];for(let k=0;k<a;k++){const y=document.createElement("div");y.className="aw-table-cell",y.dataset.row=String(p+1),y.dataset.col=String(k+1),i.appendChild(y),g.push(y)}d.push(g)}h()}f(),i.addEventListener("mousemove",p=>{const g=p.target;if(!g.classList.contains("aw-table-cell"))return;const k=parseInt(g.dataset.row??"0",10),y=parseInt(g.dataset.col??"0",10);c=k,u=y;let C=!1;k>=s&&s<o&&(s=Math.min(o,k+1),C=!0),y>=a&&a<o&&(a=Math.min(o,y+1),C=!0),C?f():h()}),i.addEventListener("click",p=>{const g=p.target;if(!g.classList.contains("aw-table-cell"))return;const k=parseInt(g.dataset.row??"0",10),y=parseInt(g.dataset.col??"0",10);k>0&&y>0&&(e({rows:k,cols:y}),r.remove())}),r.appendChild(i),r.appendChild(l),z(r,n)}function z(n,e){const t=e.closest(".aeriz-wysiwyg"),o=t==null?void 0:t.dataset.theme;o&&(n.dataset.theme=o),n.style.position="fixed",e.classList.add("is-popover-open");const r=()=>{const u=e.getBoundingClientRect();n.style.top=`${u.bottom+4}px`,n.style.left=`${u.left}px`};r(),document.body.appendChild(n);const i=()=>r(),l=()=>r();window.addEventListener("scroll",i,!0),window.addEventListener("resize",l);function s(u){!n.contains(u.target)&&!e.contains(u.target)&&n.remove()}setTimeout(()=>{document.addEventListener("click",s)},0);function a(u){u.key==="Escape"&&(u.stopPropagation(),n.remove())}document.addEventListener("keydown",a);const c=n.remove.bind(n);n.remove=function(){window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",l),document.removeEventListener("click",s),document.removeEventListener("keydown",a),e.classList.remove("is-popover-open"),c()}}function F(){document.querySelectorAll('[data-popover="true"]').forEach(n=>n.remove())}function pn(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:n<1024*1024*1024?`${(n/1024/1024).toFixed(1)} MB`:`${(n/1024/1024/1024).toFixed(1)} GB`}function fn(n,e){if(n){const t=n.lastIndexOf(".");if(t>0&&t<n.length-1)return n.slice(t+1).toUpperCase()}return e?(e.split("/").pop()??"").toUpperCase():""}function lt(n){try{return new URL(n).hostname}catch{return""}}function mn(n){const e=lt(n);return e?`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`:""}const gn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>',bn='<svg 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>',yn="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",Re="https://www.youtube-nocookie.com/embed/",kn="파일",Q="data-block-id",st=/[​-‍]/g,at=["id","class","dir","lang","title"],Uo=new Set(["div","section","article","aside","header","footer","main","nav","details","summary","figure","figcaption","address","fieldset","dl","dt","dd","small","span"]);function wn(n){if(!n)return"div";const e=n.toLowerCase();return Uo.has(e)?e:"div"}function vn(...n){const e=new Set;for(const t of n)if(t)for(const o of t.split(/\s+/))o&&e.add(o);return[...e].join(" ")}const K="aw-task-list",X="data-checked",Le=["note","tip","warning","danger"],ce="aw-callout",le="aw-callout-";function be(n){return Le.find(t=>t===n)??"note"}const Cn="aw-toggle-summary",ct="aw-toggle-body",jo=new Set(["http:","https:","mailto:","tel:","ftp:","sms:"]),Wo=new Set(["http:","https:","blob:"]),Ko=/^data:image\/[a-z0-9.+-]+[,;]/i;function An(n){return n.replace(Go,"")}const Go=new RegExp("[\\u0000-\\u0020\\u007f]","g");function Ln(n){const e=/^([a-z][a-z0-9+.-]*):/i.exec(n);return e&&e[1]?`${e[1].toLowerCase()}:`:null}function te(n){if(!n)return"";const e=n.trim();if(!e)return"";const t=Ln(An(e));return t===null||jo.has(t)?e:""}function I(n){if(!n)return"";const e=n.trim();if(!e)return"";const t=An(e),o=Ln(t);return o===null?e:o==="data:"?Ko.test(t)?e:"":Wo.has(o)?e:""}function dt(n){return n&&/^[A-Za-z0-9_-]{6,20}$/.test(n)?n:""}function Vo(n){return/^on/i.test(n)}const Yo=new Set(["srcdoc","formaction","action","xlink:href","ping"]);function Xo(n){return Yo.has(n.toLowerCase())}function Zo(n){const e=n.split(",");for(const t of e){const o=t.trim().split(/\s+/)[0]??"";if(o!==""&&!I(o))return!1}return!0}const Jo=new Set(["script","style","template","noscript","noembed","noframes","xmp","plaintext","object","embed","applet","frame","frameset","base","link","meta","title","head","form","input","button","textarea","select","option","optgroup","datalist","output","portal","param","math","foreignobject","use","animate","animatemotion","animatetransform","set","image","audio","video","source","track","canvas","dialog","slot"]),Qo=new Set(["p","div","span","br","hr","h1","h2","h3","h4","h5","h6","blockquote","pre","code","section","article","aside","header","footer","main","nav","address","figure","figcaption","details","summary","center","fieldset","legend","ul","ol","li","dl","dt","dd","a","b","strong","i","em","u","s","strike","del","ins","mark","small","big","sub","sup","kbd","samp","var","q","cite","abbr","dfn","time","bdi","bdo","wbr","ruby","rt","rp","font","label","table","caption","colgroup","col","thead","tbody","tfoot","tr","td","th","img","picture","iframe","svg","g","path","line","polyline","polygon","circle","ellipse","rect","desc"]);function xn(n){const e=n.toLowerCase();return Jo.has(e)?"drop":Qo.has(e)?"keep":"unwrap"}const er=new Set(["class","style","title","lang","dir","role","contenteditable","spellcheck","translate","hidden"]),tr={a:new Set(["href","target","rel","download","hreflang"]),img:new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),iframe:new Set(["src","allow","allowfullscreen","frameborder","referrerpolicy","loading","width","height"]),table:new Set(["border","cellpadding","cellspacing","width","summary","align","bgcolor"]),td:new Set(["colspan","rowspan","headers","scope","width","height","align","valign","bgcolor","nowrap"]),th:new Set(["colspan","rowspan","headers","scope","abbr","width","height","align","valign","bgcolor","nowrap"]),tr:new Set(["align","valign","bgcolor","height"]),col:new Set(["span","width"]),colgroup:new Set(["span","width"]),ol:new Set(["start","type","reversed"]),ul:new Set(["type"]),li:new Set(["value","type"]),details:new Set(["open"]),time:new Set(["datetime"]),blockquote:new Set(["cite"]),q:new Set(["cite"]),del:new Set(["cite","datetime"]),ins:new Set(["cite","datetime"]),font:new Set(["color","face","size"]),p:new Set(["align"]),div:new Set(["align"]),h1:new Set(["align"]),h2:new Set(["align"]),h3:new Set(["align"]),h4:new Set(["align"]),h5:new Set(["align"]),h6:new Set(["align"]),svg:new Set(["viewbox","width","height","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","xmlns","preserveaspectratio","focusable"])},nr=new Set(["d","points","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","opacity","fill-rule","clip-rule","transform"]),or=new Set(["g","path","line","polyline","polygon","circle","ellipse","rect"]),rr=/^(?:data|aria)-[a-z0-9_.:-]+$/;function de(n,e,t){var o;return Vo(e)||Xo(e)?null:e==="style"?ar(t)||null:e==="href"?te(t)?t:null:e==="src"?n==="iframe"?t.startsWith(Re)?t:null:I(t)?t:null:e==="srcset"?Zo(t)?t:null:e==="cite"?te(t)?t:null:e==="id"?lr(t):e==="contenteditable"?t==="false"?t:null:er.has(e)||rr.test(e)||(o=tr[n])!=null&&o.has(e)||or.has(n)&&nr.has(e)?t:null}const ir=new Set(["window","document","self","top","parent","frames","opener","location","cookie","domain","body","head","forms","images","links","scripts","anchors","embeds","plugins","documentelement","defaultview","name","localstorage","sessionstorage","navigator","history","alert","eval","fetch","xmlhttprequest","implementation","currentscript","activeelement"]);function lr(n){return/^[A-Za-z][\w:.-]{0,127}$/.test(n)?ir.has(n.toLowerCase())?null:n:null}const Nt=/expression\s*\(|behavior\s*:|-moz-binding|@import|javascript:|vbscript:/i,sr=/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gi;function ar(n){if(!n)return"";const e=n.replace(/\/\*[\s\S]*?\*\//g,"");if(!Nt.test(e.replace(/\\/g,""))&&!/url\s*\(/i.test(e))return e.trim();const t=[];for(const o of e.split(";")){const r=o.trim();if(!r||Nt.test(r.replace(/\\/g,"")))continue;let i=!1;r.replace(sr,(l,s,a)=>(I(a)||(i=!0),l)),!i&&t.push(r)}return t.join("; ")}function En(n,e){if(!n||n.toLowerCase()==="_self")return e;const t=new Set((e??"").split(/\s+/).filter(Boolean));return t.add("noopener"),t.add("noreferrer"),[...t].join(" ")}function Z(n,e=document){const t=e.createElement("template");t.innerHTML=n;const o=t.content;return ut(o),e.importNode(o,!0)}function ut(n){let e=n.firstChild;for(;e;){const t=e.nextSibling;cr(e),e=t}}function cr(n){var i;const e=n.nodeType;if(e===8||e===7){(i=n.parentNode)==null||i.removeChild(n);return}if(e!==1)return;const t=n,o=t.localName,r=xn(o);if(r==="drop"||o==="iframe"&&de("iframe","src",t.getAttribute("src")??"")===null){t.remove();return}if(ut(t),r==="unwrap"){const l=t.parentNode;if(l){for(;t.firstChild;)l.insertBefore(t.firstChild,t);l.removeChild(t)}return}dr(t,o)}function dr(n,e){const t=n.attributes;for(let o=t.length-1;o>=0;o--){const r=t[o];if(!r)continue;const i=r.name.toLowerCase();let l=de(e,i,r.value);l!==null&&i==="id"&&ur(l)&&(l=null),l===null?n.removeAttribute(r.name):l!==r.value&&n.setAttribute(r.name,l)}if(e==="a"){const o=En(n.getAttribute("target"),n.getAttribute("rel"));o&&n.setAttribute("rel",o)}}function ur(n){try{return n in document||typeof window<"u"&&n in window}catch{return!0}}function Bt(n){const e=n.getElementsByTagName("*");for(let t=e.length-1;t>=0;t--){const o=e[t];if(o){if(hr(o)){o.remove();continue}Mt(o)}}Mt(n)}function hr(n){const e=n.localName;return e==="iframe"?de("iframe","src",n.getAttribute("src")??"")===null:pr.has(e)}const pr=new Set(["script","style","object","embed","applet","frame","frameset","base","link","meta","form","template","noscript","portal","math","foreignobject","use","animate","animatemotion","animatetransform","set","input","textarea","select","audio","video"]);function Mt(n){const e=n.attributes;for(let t=e.length-1;t>=0;t--){const o=e[t];if(!o)continue;const r=o.name.toLowerCase();if(r.startsWith("on")||r==="href"||r==="src"||r==="srcset"||r==="srcdoc"||r==="formaction"||r==="action"||r==="xlink:href"||r==="style"){const i=de(n.localName,r,o.value);i===null?n.removeAttribute(o.name):i!==o.value&&n.setAttribute(o.name,i)}}}const Sn=new Set(["font-weight","font-style","text-decoration","color","background","background-color","text-align","vertical-align","border","border-top","border-right","border-bottom","border-left"]),fr=new Set([...Sn,"font-size","font-family","letter-spacing","line-height","width","height","margin-left","text-indent"]),$t=/^(?:normal|auto|none|initial|inherit|general|windowtext|black|#000000?|transparent|0)$/i;function mr(n){const e=n.slice(0,4e3);return/ProgId\s*=?\s*"?Excel\.|urn:schemas-microsoft-com:office:excel/i.test(e)?"excel":/ProgId\s*=?\s*"?Word\.|urn:schemas-microsoft-com:office:word|class="?Mso/i.test(e+n.slice(0,2e4))?"word":/Hancom|HStyle\d/i.test(e)?"hwp":"web"}function gr(n){const e=mr(n),t=new DOMParser().parseFromString(n,"text/html"),o=t.body;if(!o)return"";const r=e==="web"?new Map:Cr(t),i=e==="word"?Lr(t):new Map;Ar(o);for(const l of Array.from(o.querySelectorAll("style, meta, link, title, xml, script")))l.remove();for(const l of Array.from(o.querySelectorAll("*"))){const s=l.tagName.toLowerCase();if(s.includes(":")){l.replaceWith(...Array.from(l.childNodes));continue}const a=new Map;for(const d of Array.from(l.classList)){const h=r.get(`${s}.${d.toLowerCase()}`)??r.get(`.${d.toLowerCase()}`);if(h)for(const[f,p]of h)a.set(f,p)}const c=se(l.getAttribute("style")??""),u=c.get("mso-list");for(const[d,h]of c)a.set(d,h);kr(l,a,c),u&&l.setAttribute("data-paste-list",u),e!=="web"&&(l.removeAttribute("class"),l.removeAttribute("lang")),l.removeAttribute("data-block-id"),ze(l,"align","text-align"),ze(l,"valign","vertical-align"),ze(l,"bgcolor","background-color");for(const d of["width","height","border","cellspacing","cellpadding"])s!=="img"&&s!=="col"&&l.removeAttribute(d)}e==="word"&&xr(o,i);for(const l of Array.from(o.querySelectorAll("[data-paste-list]")))l.removeAttribute("data-paste-list");Nr(o),Br(o);for(const l of Array.from(o.querySelectorAll("col, colgroup")))l.remove();return e!=="web"&&br(o),o.innerHTML.trim()}function br(n){for(const e of Array.from(n.querySelectorAll('[style*="background-color"]'))){if(e.style.color)continue;const t=e.style.backgroundColor;t&&yr(t)&&e.setAttribute("style",`${e.getAttribute("style")}; color: #000`)}}function yr(n){let e,t,o;const r=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n.trim()),i=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(n);if(r){const l=r[1].length===3?r[1].replace(/./g,"$&$&"):r[1];[e,t,o]=[0,2,4].map(s=>parseInt(l.slice(s,s+2),16))}else if(i)[e,t,o]=[i[1],i[2],i[3]].map(Number);else return/^(white|ivory|beige|lightyellow|lightgr[ae]y|whitesmoke|lightcyan|yellow)$/i.test(n.trim());return(.299*e+.587*t+.114*o)/255>.6}function se(n){const e=new Map;for(const t of n.match(/(?:[^;"']|"[^"]*"|'[^']*')+/g)??[]){const o=t.indexOf(":");if(o<0)continue;const r=t.slice(0,o).trim().toLowerCase(),i=t.slice(o+1).trim();r&&i&&e.set(r,i)}return e}function kr(n,e,t){var r;const o=[];for(const[i,l]of e){const s=!t.has(i);if(!(s?Sn:fr).has(i)||(i==="width"||i==="height")&&!/^(TD|TH|IMG)$/.test(n.tagName))continue;let a=l.replace(/\s*!important$/i,"").replace(/windowtext/gi,"#000").trim();if((i==="width"||i==="height")&&/^\d+(\.\d+)?$/.test(a)&&(a+="px"),!((i==="margin-left"||i==="text-indent"||i==="letter-spacing")&&/^-?0(\.0+)?[a-z%]*$/i.test(a))){if(i==="background"){const c=(r=a.match(/#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|\b[a-z]+\b/i))==null?void 0:r[0];if(!c||$t.test(c))continue;o.push(`background-color: ${c}`);continue}if(i.startsWith("border")){if(/^none$/i.test(a)){s||o.push(`${i}: none`);continue}}else if(i!=="font-family"&&(a=a.replace(/^"(.*)"$/,"$1"))&&($t.test(a)||i==="font-weight"&&a==="400"))continue;i==="font-weight"&&/^"?(bold|700|800|900)"?$/i.test(a)&&(a="bold"),i==="font-style"&&(a=a.replace(/"/g,"")),!(i==="font-family"&&(a=wr(a),!a))&&(i==="line-height"&&!/^\d+(\.\d+)?%?$/.test(a)||(i!=="font-size"&&(a=a.replace(/(-?\d*\.?\d+)pt\b/g,(c,u)=>`${vr(Number(u)*4/3)}px`)),i.startsWith("border")&&(a=a.replace(new RegExp("(?<![\\d.])0?\\.\\d+px\\b","g"),"1px")),o.push(`${i}: ${a}`)))}}o.length>0?n.setAttribute("style",o.join("; ")):n.removeAttribute("style")}function wr(n){const e=(n.split(",")[0]??"").trim().replace(/^["']|["']$/g,"");if(!e||/^(monospace|serif|sans-serif|wingdings|symbol)$/i.test(e))return"";const t=/바탕|명조|궁서|batang|myeongjo|gungsuh|times|georgia|serif/i.test(e)?"serif":"sans-serif";return`${/[\s"]/.test(e)||/[^\x00-\x7f]/.test(e)?`"${e}"`:e}, ${t}`}function vr(n){return Math.round(n*100)/100}function ze(n,e,t){const o=n.getAttribute(e);if(o===null)return;n.removeAttribute(e);const r=n.getAttribute("style")??"";n.tagName==="IMG"||!/^[#\w-]+$/.test(o)||se(r).has(t)||n.setAttribute("style",r?`${r}; ${t}: ${o.toLowerCase()}`:`${t}: ${o.toLowerCase()}`)}function Cr(n){const e=new Map;for(const t of Array.from(n.querySelectorAll("style"))){const o=(t.textContent??"").replace(/<!--|-->/g,"").replace(/\/\*[\s\S]*?\*\//g,"");for(const r of o.matchAll(/([^{}@]+)\{([^{}]*)\}/g)){const i=se(r[2]??"");for(const l of(r[1]??"").split(",")){const s=l.trim().toLowerCase();if(!/^[a-z0-9]*\.[\w-]+$/.test(s))continue;const a=e.get(s);e.set(s,a?new Map([...a,...i]):i)}}}return e}function Ar(n){var o;const e=n.ownerDocument.createTreeWalker(n,NodeFilter.SHOW_COMMENT),t=[];for(;e.nextNode();)t.push(e.currentNode);for(const r of t)(o=r.parentNode)==null||o.removeChild(r)}function Lr(n){const e=new Map;for(const t of Array.from(n.querySelectorAll("style"))){const o=t.textContent??"";for(const r of o.matchAll(/@list\s+(l\d+):level1\s*\{([^}]*)\}/gi)){const i=(r[1]??"").toLowerCase();e.set(i,/mso-level-number-format:\s*bullet/i.test(r[2]??"")?"ul":"ol")}}return e}function xr(n,e){var s,a;const t=n.ownerDocument,o=Array.from(n.querySelectorAll("p[data-paste-list], li[data-paste-list], h1[data-paste-list], h2[data-paste-list], h3[data-paste-list]"));let r=[],i=null,l="";for(const c of o){const u=c.getAttribute("data-paste-list")??"",d=(((s=/\b(l\d+)\b/i.exec(u))==null?void 0:s[1])??"").toLowerCase(),h=Number(((a=/level(\d+)/i.exec(u))==null?void 0:a[1])??"1"),f=Sr(c);Tr(c);const p=r[0];p!==void 0&&Er(p)===c&&d===l||(r=[],i=null);const k=e.get(d)??(/^[\d一-龥a-z]{1,3}[.)]/i.test(f)?"ol":"ul");for(;r.length>h;)r.pop();for(;r.length<h;){const A=t.createElement(k);r.length===0?c.before(A):(i??r[r.length-1]).appendChild(A),r.push(A)}const y=t.createElement("li");for(;c.firstChild;)y.appendChild(c.firstChild);const C=c.getAttribute("style");if(C){const A=[...se(C)].filter(([v])=>v==="text-align"||v==="color");A.length&&y.setAttribute("style",A.map(([v,L])=>`${v}: ${L}`).join("; "))}r[r.length-1].appendChild(y),c.remove(),i=y,l=d}}function Er(n){let e=n.nextSibling;for(;e&&e.nodeType!==1;){if(e.nodeType===3&&(e.textContent??"").trim())return null;e=e.nextSibling}return e}function Sr(n){for(const e of Array.from(n.querySelectorAll("[data-paste-list]")))if(/ignore/i.test(e.getAttribute("data-paste-list")??""))return(e.textContent??"").trim();return""}function Tr(n){for(const e of Array.from(n.querySelectorAll("[data-paste-list]")))if(/ignore/i.test(e.getAttribute("data-paste-list")??"")){const t=e.parentElement;e.remove(),t&&t!==n&&!(t.textContent??"").trim()&&!t.querySelector("img")&&t.remove()}}function Nr(n){for(const e of Array.from(n.querySelectorAll("td, th"))){const t=Array.from(e.children).filter(o=>/^(P|DIV|H[1-6])$/.test(o.tagName));if(t.length!==0){t.forEach((o,r)=>{const i=se(o.getAttribute("style")??"").get("text-align"),l=e.getAttribute("style")??"";i&&i!=="justify"&&!se(l).has("text-align")&&e.setAttribute("style",l?`${l}; text-align: ${i}`:`text-align: ${i}`),r>0&&o.before(e.ownerDocument.createElement("br")),o.replaceWith(...Array.from(o.childNodes))});for(const o of Array.from(e.childNodes))o.nodeType===3&&!(o.textContent??"").trim()&&o.remove()}}}function Br(n){for(const e of Array.from(n.querySelectorAll("span, font")).reverse())e.attributes.length===0&&e.replaceWith(...Array.from(e.childNodes))}const Mr=[100,115,130,150,160,180,200,250,300],$r=[-10,-5,-3,0,3,5,10,20];function Tn(n,e,t,o){F();const r=document.createElement("div");r.className=`aw-popover ${e}`,r.dataset.popover="true",r.setAttribute("role","menu"),T(r);for(const i of t){const l=document.createElement("button");l.type="button",l.className="aw-popover-item",l.setAttribute("role","menuitemradio"),l.setAttribute("aria-checked",String(i.active)),i.active&&l.classList.add("aw-popover-item-active"),l.textContent=i.label,T(l),l.addEventListener("click",s=>{s.stopPropagation(),r.remove(),o(i.value)}),r.appendChild(l)}z(r,n)}function Hr(n,e,t){Tn(n,"aw-line-height-popover",Mr.map(o=>({label:`${o}%`,value:String(o),active:o===t})),o=>e(Number(o)))}function Rr(n,e,t){Tn(n,"aw-letter-spacing-popover",$r.map(o=>({label:o===0?m().docTools.letterSpacingNormal:`${o>0?"+":""}${o}%`,value:String(o),active:o===(t??0)})),o=>e(Number(o)))}const Ir={symbols:"※□■○●◎◇◆△▲▽▼☆★☞☜♡♥·‥…〃§¶†‡※✓✔✕",arrows:"→←↑↓↔↕⇒⇔⇐⇑⇓↗↘↙↖▶◀▷◁",numbers:"①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮㉠㉡㉢㉣㉤㉥㉦㉧㉨㉩⑴⑵⑶⑷⑸",units:"℃℉%‰㎜㎝㎞㎎㎏㎖㎗ℓ㎡㎥㏄㏈₩$£¥€",brackets:"「」『』【】〈〉《》〔〕{}[]",math:"±×÷≠≤≥≒≡∞∴∵√∑∫∂∈∋⊂⊃∪∩∧∨¬"};function Dr(n,e){F();const t=document.createElement("div");t.className="aw-popover aw-special-char-popover",t.dataset.popover="true",T(t);const o=m().docTools.specialGroups;for(const[r,i]of Object.entries(Ir)){const l=document.createElement("div");l.className="aw-popover-section",l.textContent=o[r],t.appendChild(l);const s=document.createElement("div");s.className="aw-special-char-grid";for(const a of Array.from(i)){const c=document.createElement("button");c.type="button",c.className="aw-special-char",c.textContent=a,c.title=`U+${a.codePointAt(0).toString(16).toUpperCase().padStart(4,"0")}`,T(c),c.addEventListener("click",u=>{u.stopPropagation(),e(a)}),s.appendChild(c)}t.appendChild(s)}z(t,n)}function Pr(n,e,t){var i;if(!e)return[];const o=t?e:e.toLowerCase(),r=[];for(const l of Array.from(n.children)){const s=[],a=document.createTreeWalker(l,NodeFilter.SHOW_TEXT);for(;a.nextNode();)s.push(a.currentNode);if(s.length===0)continue;let c="";const u=[];let d=null;for(const p of s){const g=((i=p.parentElement)==null?void 0:i.closest("td, th, li"))??null;g!==d&&c&&(c+="\0"),d=g,u.push(c.length),c+=p.data}const h=t?c:c.toLowerCase();let f=0;for(;;){const p=h.indexOf(o,f);if(p<0)break;const g=document.createRange(),[k,y]=Ht(s,u,p),[C,A]=Ht(s,u,p+o.length,!0);g.setStart(k,y),g.setEnd(C,A),r.push({range:g}),f=p+Math.max(1,o.length)}}return r}function Ht(n,e,t,o=!1){for(let i=0;i<n.length;i++){const l=e[i],s=l+n[i].data.length;if(o?t>l&&t<=s:t>=l&&t<s)return[n[i],t-l]}const r=n[n.length-1];return[r,r.data.length]}const Fe="aw-find",Oe="aw-find-current";function Nn(){const n=globalThis.CSS,e=globalThis.Highlight;return n!=null&&n.highlights&&e?n.highlights:null}function ne(n,e){const t=Nn();if(!t)return;const o=globalThis.Highlight;e.length?t.set(n,new o(...e)):t.delete(n)}class zr{constructor(e){b(this,"element");b(this,"findInput");b(this,"replaceInput");b(this,"caseBox");b(this,"status");b(this,"matches",[]);b(this,"index",-1);this.host=e;const t=m().docTools;this.element=document.createElement("div"),this.element.className="aw-find-panel",this.element.setAttribute("role","search"),this.element.hidden=!0,this.findInput=Dt(t.find),this.replaceInput=Dt(t.replaceWith),this.caseBox=document.createElement("input"),this.caseBox.type="checkbox";const o=document.createElement("label");o.className="aw-find-case",o.append(this.caseBox,document.createTextNode(t.matchCase)),this.status=document.createElement("span"),this.status.className="aw-find-status",this.status.setAttribute("aria-live","polite");const r=ue(t.previous,()=>this.step(-1)),i=ue(t.next,()=>this.step(1)),l=ue(t.replace,()=>this.replaceOne()),s=ue(t.replaceAll,()=>this.replaceAll()),a=ue(t.close,()=>this.close());a.classList.add("aw-find-close");const c=document.createElement("div");c.className="aw-find-row",c.append(this.findInput,r,i,this.status,o,a);const u=document.createElement("div");u.className="aw-find-row",u.append(this.replaceInput,l,s),this.element.append(c,u),this.findInput.addEventListener("input",()=>this.search(!0)),this.caseBox.addEventListener("change",()=>this.search(!0)),this.element.addEventListener("keydown",d=>{d.key==="Escape"?(d.preventDefault(),this.close()):d.key==="Enter"&&(d.preventDefault(),d.target===this.replaceInput?this.replaceOne():this.step(d.shiftKey?-1:1))})}get isOpen(){return!this.element.hidden}open(){this.element.hidden=!1;const e=document.getSelection(),t=e&&!e.isCollapsed&&this.host.content.contains(e.anchorNode)?e.toString():"";t&&!t.includes(`
14
+ `)&&(this.findInput.value=t),this.findInput.focus(),this.findInput.select(),this.search(!0)}close(){this.element.hidden=!0,ne(Fe,[]),ne(Oe,[]);const e=this.matches[this.index];this.matches=[],this.host.content.focus(),e&&It(e.range)}refresh(){this.isOpen&&this.search(!1)}search(e){if(this.matches=Pr(this.host.content,this.findInput.value,this.caseBox.checked),e||this.index>=this.matches.length){const t=document.getSelection(),o=t&&t.rangeCount&&this.host.content.contains(t.anchorNode)?t.getRangeAt(0):null;this.index=o?Math.max(0,this.matches.findIndex(r=>r.range.compareBoundaryPoints(Range.START_TO_START,o)>=0)):0,this.index<0&&(this.index=0)}this.paint()}step(e){this.matches.length!==0&&(this.index=(this.index+e+this.matches.length)%this.matches.length,this.paint())}paint(){const e=m().docTools,t=this.matches.length;if(t===0){this.status.textContent=this.findInput.value?e.noMatch:"",ne(Fe,[]),ne(Oe,[]);return}this.index=Math.min(Math.max(this.index,0),t-1);const o=this.matches[this.index];this.status.textContent=J(e.matchCount,{current:this.index+1,total:t}),Nn()?(ne(Fe,this.matches.map(i=>i.range)),ne(Oe,[o.range])):It(o.range);const r=o.range.getBoundingClientRect();(r.top<0||r.bottom>window.innerHeight)&&(o.range.startContainer.parentElement??this.host.content).scrollIntoView({block:"center"})}replaceOne(){const e=this.matches[this.index];e&&(this.host.beforeChange(),Rt(e.range,this.replaceInput.value),this.host.afterChange(),this.search(!1))}replaceAll(){if(this.matches.length===0)return;const e=this.matches.length;this.host.beforeChange();for(const t of[...this.matches].reverse())Rt(t.range,this.replaceInput.value);this.host.afterChange(),this.search(!0),this.status.textContent=J(m().docTools.replaced,{count:e})}}function Rt(n,e){const t=n.startContainer,o=n.startOffset;n.deleteContents(),t.nodeType===3?t.insertData(o,e):e&&n.insertNode(document.createTextNode(e))}function It(n){const e=document.getSelection();e&&(e.removeAllRanges(),e.addRange(n))}function Dt(n){const e=document.createElement("input");return e.type="text",e.className="aw-find-input",e.placeholder=n,e.setAttribute("aria-label",n),e}function ue(n,e){const t=document.createElement("button");return t.type="button",t.className="aw-find-btn",t.textContent=n,t.addEventListener("click",e),t}function Fr(n,e){const t=document.createElement("iframe");t.setAttribute("sandbox","allow-modals allow-same-origin"),t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden",document.body.appendChild(t);const o=t.contentDocument,r=t.contentWindow;if(!o||!r){t.remove();return}o.open(),o.write(`<!doctype html><html><head><meta charset="utf-8"><title>${Or(e)}</title><style>@page{margin:20mm 18mm}body{margin:0;font:12pt/1.6 "Malgun Gothic","Apple SD Gothic Neo",sans-serif;color:#000}table{border-collapse:collapse;page-break-inside:auto}tr{page-break-inside:avoid}img{max-width:100%}h1,h2,h3{page-break-after:avoid}td,th{border:1px solid #999;padding:4px 8px}</style></head><body>${n}</body></html>`),o.close();const i=()=>{window.setTimeout(()=>t.remove(),1e3)};r.addEventListener("afterprint",i,{once:!0}),window.setTimeout(()=>{r.focus(),r.print(),i()},50)}function Or(n){return n.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[e])}const qr=new Set(["P","H1","H2","H3","H4","H5","H6","UL","OL","TABLE","BLOCKQUOTE","PRE","FIGURE","HR","DIV","ASIDE","DETAILS","SECTION","ARTICLE","HEADER","FOOTER","NAV","MAIN","DL","ADDRESS","CENTER"]),_r="td, th, li, pre, figcaption, summary, dt, dd",qe=/^(P|H[1-6])$/;function Pt(n){return n.nodeType===1&&qr.has(n.tagName)}function _e(n){return!(n.textContent??"").replace(/[​\s]/g,"")&&!n.querySelector("img, table, hr, iframe")}function Ur(n){const e=n.ownerDocument,t=[];let o=null;const r=i=>{for(const l of i){if(l.nodeType===1&&["DIV","SECTION","ARTICLE","HEADER","FOOTER","NAV","MAIN","CENTER"].includes(l.tagName)){const s=l;if(Array.from(s.childNodes).some(Pt)){o=null,r(Array.from(s.childNodes));continue}const a=e.createElement("p"),c=s.getAttribute("style");for(c&&a.setAttribute("style",c);s.firstChild;)a.appendChild(s.firstChild);t.push(a),o=null;continue}if(Pt(l)){t.push(l),o=null;continue}l.nodeType===3&&!(l.textContent??"").trim()&&o===null||l.nodeType===1&&l.tagName==="BR"&&o===null||(o||(o=e.createElement("p"),t.push(o)),o.appendChild(l))}};return r(Array.from(n.childNodes)),t}function jr(n){var r;const e=((r=n[0])==null?void 0:r.ownerDocument)??document,t=[],o=i=>{t.length&&t.push(e.createElement("br")),t.push(...i)};for(const i of n)if(i.tagName==="TABLE")for(const l of Array.from(i.querySelectorAll("tr"))){const s=Array.from(l.children).map(a=>(a.textContent??"").trim()).join(" ");o([e.createTextNode(s)])}else if(i.tagName==="UL"||i.tagName==="OL")for(const l of Array.from(i.querySelectorAll("li")))o([e.createTextNode((l.textContent??"").trim())]);else{if(i.tagName==="HR"||i.tagName==="FIGURE")continue;o(Array.from(i.childNodes))}return t}function Wr(n,e,t){e.collapsed||e.deleteContents();const o=n.ownerDocument,r=Ur(t);if(r.length===0)return null;if(e.startContainer===n){const y=o.createElement("p");y.appendChild(o.createElement("br")),n.insertBefore(y,n.childNodes[e.startOffset]??null),e.setStart(y,0),e.collapse(!0)}const i=e.startContainer.nodeType===1?e.startContainer:e.startContainer.parentElement;let l=i;for(;l&&l.parentElement!==n;)l=l.parentElement;if(!l||!i)return null;const s=i.closest(_r),a=r.length===1&&qe.test(r[0].tagName)&&r[0].tagName==="P";if(s&&n.contains(s)||a){const y=a?Array.from(r[0].childNodes):jr(r);return Kr(e,y)}if(!qe.test(l.tagName)){let y=l;for(const C of r)y.after(C),y=C;return Ft(y)}const c=o.createRange();c.setStart(e.startContainer,e.startOffset),c.setEnd(l,l.childNodes.length);const u=c.extractContents(),d=l.cloneNode(!1);d.removeAttribute("data-block-id"),d.appendChild(u);const h=r[0];let f=r;if(h.tagName==="P"&&!_e(l)){for(zt(l);h.firstChild;)l.appendChild(h.firstChild);f=r.slice(1)}let p=l;for(const y of f)p.after(y),p=y;f.length>0&&_e(l)&&l.remove();const g=p,k=Ft(g);if(!_e(d)){if(qe.test(g.tagName)&&g.isConnected){zt(g);const y=g.childNodes.length;for(;d.firstChild;)g.appendChild(d.firstChild);return[g,y]}g.after(d)}return k}function Kr(n,e){if(e.length===0)return null;const t=n.startContainer.ownerDocument.createDocumentFragment();for(const l of e)t.appendChild(l);const o=t.lastChild;n.insertNode(t);const r=o.nextSibling;r&&r.nodeName==="BR"&&!r.nextSibling&&o.nodeName!=="BR"&&r.remove();const i=o.parentNode;return[i,Array.prototype.indexOf.call(i.childNodes,o)+1]}function zt(n){const e=n.lastChild;e&&e.nodeName==="BR"&&e.remove()}function Ft(n){const e=n.matches("table")?n.querySelectorAll("td, th"):n.matches("ul, ol")?n.querySelectorAll("li"):null,t=(e==null?void 0:e[e.length-1])??n;return[t,t.childNodes.length]}function Gr(n){const e=[];for(const t of Array.from(n.children))if(t.tagName==="TR")e.push(t);else if(t.tagName==="THEAD"||t.tagName==="TBODY"||t.tagName==="TFOOT")for(const o of Array.from(t.children))o.tagName==="TR"&&e.push(o);return e}function ht(n){const e=[];for(const t of Array.from(n.children))(t.tagName==="TD"||t.tagName==="TH")&&e.push(t);return e}function Se(n,e){const t=Number.parseInt(n.getAttribute(e)??"1",10);return Number.isFinite(t)&&t>0?Math.min(t,1e3):1}function B(n){const e=Gr(n),t=e.map(()=>[]),o=new Map;let r=0;e.forEach((i,l)=>{let s=0;for(const a of ht(i)){const c=t[l]??[];for(;c[s];)s++;const u=Math.min(Se(a,"rowspan"),e.length-l),d=Se(a,"colspan"),h={el:a,row:l,col:s,rowSpan:u,colSpan:d};o.set(a,h);for(let f=0;f<u;f++){const p=t[l+f];if(p)for(let g=0;g<d;g++)p[s+g]=h}s+=d,r=Math.max(r,s)}});for(const i of t){for(let l=0;l<r;l++)i[l]||(i[l]=null);r=Math.max(r,i.length)}return{rows:e,slots:t,width:r,cells:o}}function D(n,e,t){t<=1?n.removeAttribute(e):n.setAttribute(e,String(t))}function pt(n){const e=document.createElement((n==null?void 0:n.tagName)==="TH"?"th":"td");return n&&(n.style.backgroundColor&&(e.style.backgroundColor=n.style.backgroundColor),n.style.textAlign&&(e.style.textAlign=n.style.textAlign)),e.appendChild(document.createElement("br")),e}function ft(n,e,t,o){const r=n.rows[e];if(r){for(const i of ht(r)){const l=n.cells.get(i);if(l&&l.col>=t){r.insertBefore(o,i);return}}r.appendChild(o)}}function Te(n){return{top:n.row,left:n.col,bottom:n.row+n.rowSpan-1,right:n.col+n.colSpan-1}}function Bn(n,e){var r;const t={...e};let o=!0;for(;o;){o=!1;for(let i=t.top;i<=t.bottom;i++)for(let l=t.left;l<=t.right;l++){const s=(r=n.slots[i])==null?void 0:r[l];if(!s)continue;const a=Te(s);a.top<t.top&&(t.top=a.top,o=!0),a.left<t.left&&(t.left=a.left,o=!0),a.bottom>t.bottom&&(t.bottom=a.bottom,o=!0),a.right>t.right&&(t.right=a.right,o=!0)}}return t}function mt(n,e){var r;const t=new Set,o=[];for(let i=e.top;i<=e.bottom;i++)for(let l=e.left;l<=e.right;l++){const s=(r=n.slots[i])==null?void 0:r[l];s&&!t.has(s.el)&&(t.add(s.el),o.push(s.el))}return o}function Ue(n,e,t){const o=B(n),r=o.cells.get(e),i=o.cells.get(t);if(!r||!i)return[e];const l=Te(r),s=Te(i),a=Bn(o,{top:Math.min(l.top,s.top),left:Math.min(l.left,s.left),bottom:Math.max(l.bottom,s.bottom),right:Math.max(l.right,s.right)});return mt(o,a)}function Mn(n,e){let t=null;for(const o of e){const r=n.cells.get(o);if(!r)continue;const i=Te(r);t=t?{top:Math.min(t.top,i.top),left:Math.min(t.left,i.left),bottom:Math.max(t.bottom,i.bottom),right:Math.max(t.right,i.right)}:i}return t?Bn(n,t):null}function Ot(n,e,t){var u,d,h;const o=B(n),r=o.cells.get(e);if(!r)return null;const i=t==="above"?r.row:r.row+r.rowSpan,l=o.rows[t==="above"?r.row:r.row+r.rowSpan-1];if(!l)return null;const s=document.createElement("tr"),a=new Set;let c=null;for(let f=0;f<o.width;f++){const p=((u=o.slots[i-1])==null?void 0:u[f])??null,g=((d=o.slots[i])==null?void 0:d[f])??null;if(p&&p===g){a.has(p)||(a.add(p),D(p.el,"rowspan",p.rowSpan+1)),f+=p.colSpan-1;continue}const k=(t==="above"?g:p)??p??g,y=(k==null?void 0:k.colSpan)??1,C=pt(k==null?void 0:k.el),A=k?k.col:f;k&&y>1&&A===f&&(D(C,"colspan",y),f+=y-1),s.appendChild(C),c??(c=C)}return(h=l.parentNode)==null||h.insertBefore(s,t==="above"?l:l.nextSibling),c}function Vr(n,e){const t=B(n),o=t.cells.get(e);if(!o||t.rows.length-o.rowSpan<1)return!1;for(let r=o.row+o.rowSpan-1;r>=o.row;r--)Yr(B(n),r);return!0}function Yr(n,e){var r;const t=n.rows[e];if(!t)return;const o=new Set;for(let i=0;i<n.width;i++){const l=(r=n.slots[e])==null?void 0:r[i];!l||o.has(l)||(o.add(l),l.rowSpan!==1&&(l.row<e?D(l.el,"rowspan",l.rowSpan-1):(D(l.el,"rowspan",l.rowSpan-1),ft(n,e+1,l.col,l.el))))}t.remove()}function Xr(n,e,t){var a,c;const o=B(n),r=o.cells.get(e);if(!r)return;const i=t==="left"?r.col:r.col+r.colSpan,l=new Set,s=[];for(let u=0;u<o.rows.length;u++){const d=((a=o.slots[u])==null?void 0:a[i-1])??null,h=((c=o.slots[u])==null?void 0:c[i])??null;if(d&&d===h){l.has(d)||(l.add(d),D(d.el,"colspan",d.colSpan+1));continue}const f=t==="left"?h??d:d??h;if(f&&f.row!==u&&l.has(f))continue;const p=pt(f==null?void 0:f.el);f&&f.rowSpan>1&&(D(p,"rowspan",f.rowSpan-(u-f.row)),l.add(f)),s.push({r:u,el:p})}for(const{r:u,el:d}of s)ft(o,u,i,d);$n(n,i,"insert")}function Zr(n,e){var r;const t=B(n),o=t.cells.get(e);if(!o||t.width-o.colSpan<1)return!1;for(let i=o.col+o.colSpan-1;i>=o.col;i--){const l=B(n),s=new Set;for(let a=0;a<l.rows.length;a++){const c=(r=l.slots[a])==null?void 0:r[i];!c||s.has(c)||(s.add(c),c.colSpan>1?D(c.el,"colspan",c.colSpan-1):c.el.remove())}$n(n,i,"delete")}return Hn(n),!0}function $n(n,e,t){var i;const o=n.querySelector(":scope > colgroup");if(!o)return;const r=Array.from(o.querySelectorAll(":scope > col"));if(t==="insert"){const l=document.createElement("col");o.insertBefore(l,r[e]??null)}else(i=r[e])==null||i.remove()}function Jr(n,e){if(e.length<2)return!1;const t=B(n),o=Mn(t,e);return o?mt(t,o).length>1:!1}function Qr(n,e){const t=B(n),o=Mn(t,e);if(!o)return null;const r=mt(t,o);if(r.length<2)return null;const[i,...l]=r;if(!i)return null;for(const s of l){if(!qt(s))for(qt(i)?i.replaceChildren():i.appendChild(document.createElement("br"));s.firstChild;)i.appendChild(s.firstChild);s.remove()}return D(i,"rowspan",o.bottom-o.top+1),D(i,"colspan",o.right-o.left+1),Hn(n),i}function ei(n,e){const t=B(n),o=t.cells.get(e);if(!o||o.rowSpan===1&&o.colSpan===1)return!1;e.removeAttribute("rowspan"),e.removeAttribute("colspan");for(let r=o.row;r<o.row+o.rowSpan;r++)for(let i=o.col;i<o.col+o.colSpan;i++){if(r===o.row&&i===o.col)continue;const l=pt(e);ft(t,r,i,l),t.cells.set(l,{el:l,row:r,col:i,rowSpan:1,colSpan:1})}return!0}function ti(n){return Se(n,"rowspan")>1||Se(n,"colspan")>1}function qt(n){return(n.textContent??"").replace(/[​ \s]/g,"")===""&&!n.querySelector("img, table, hr")}function Hn(n){var e;for(;;){const t=B(n),o=t.rows.findIndex(i=>ht(i).length===0);if(o<0)return;const r=new Set;for(const i of t.slots[o]??[])!i||r.has(i)||(r.add(i),D(i.el,"rowspan",i.rowSpan-1));(e=t.rows[o])==null||e.remove()}}function ni(n,e){const t=Array.from(B(n).cells.keys()),o=t.indexOf(e);return o>=0?t[o+1]??null:null}function oi(n,e){const t=Array.from(B(n).cells.keys()),o=t.indexOf(e);return o>0?t[o-1]??null:null}function ri(n,e,t){const o=B(n),r=o.cells.get(e);if(!r)return null;const i=(l,s)=>{var c;const a=(c=o.slots[l])==null?void 0:c[s];return a&&a.el!==e?a.el:null};return t==="row"?i(r.row+r.rowSpan,r.col)??i(r.row-1,r.col):i(r.row,r.col+r.colSpan)??i(r.row,r.col-1)}function ii(n,e){const t=B(n),o=t.cells.get(e);if(!o)return[e];const r=o.col+o.colSpan-1,i=[];for(const l of t.cells.values())l.col===r&&l.colSpan===1&&i.push(l.el);return i.length>0?i:[e]}const Rn=1;function li(n){const e=n.version;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:1}const si=new Set(["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock","toggle","callout","image","table","hr","linkCard","youtube","file","importedHtml","unknown"]);function ye(n){return n.map(e=>ai(e))}function ai(n){const e=si.has(n.kind)?n.kind:"unknown",t=Math.max(li(n),1);return{...n,kind:e,version:t,html:typeof n.html=="string"?n.html:""}}const R=["bold","italic","underline","strike","superscript","subscript"],ci={kind:"paragraph",label:"본문",allowsInlineFormat:!0,allowedMarks:R,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="P"?{kind:"paragraph",attrs:{}}:null,create:()=>P(document.createElement("p")),isEmpty:n=>O(n)},di={kind:"heading",label:"제목",allowsInlineFormat:!0,allowedMarks:["italic"],allowsColor:!1,allowsFontSize:!1,matches:n=>{const e=/^H([1-6])$/.exec(n.tagName);return e?{kind:"heading",attrs:{level:Number(e[1])}}:null},create:n=>{const e=Gi(n==null?void 0:n.level);return P(document.createElement(`h${e}`))},isEmpty:n=>O(n)},ui={kind:"bulletList",label:"글머리 목록",allowsInlineFormat:!0,allowedMarks:R,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="UL"?{kind:"bulletList",attrs:{}}:null,create:()=>vt("ul"),isEmpty:n=>Ct(n)},hi={kind:"orderedList",label:"번호 매기기 목록",allowsInlineFormat:!0,allowedMarks:R,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="OL"?{kind:"orderedList",attrs:{}}:null,create:()=>vt("ol"),isEmpty:n=>Ct(n)},pi={kind:"taskList",label:"체크리스트",allowsInlineFormat:!0,allowedMarks:R,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="UL"&&n.classList.contains(K)?{kind:"taskList",attrs:{}}:null,create:()=>{const n=vt("ul");return n.classList.add(K),n},isEmpty:n=>Ct(n)},fi={kind:"blockquote",label:"인용구",allowsInlineFormat:!0,allowedMarks:["bold","underline","strike"],allowsColor:!1,allowsFontSize:!0,matches:n=>n.tagName==="BLOCKQUOTE"?{kind:"blockquote",attrs:{}}:null,create:()=>{const n=document.createElement("blockquote");return n.appendChild(P(document.createElement("p"))),n},isEmpty:n=>O(n)},mi={kind:"codeBlock",label:"코드 블록",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!0,matches:n=>{if(n.tagName!=="PRE")return null;const e=n.querySelector(":scope > code"),t=e==null?void 0:e.getAttribute("data-language");return{kind:"codeBlock",attrs:t?{language:t}:{}}},create:n=>{const e=document.createElement("pre"),t=document.createElement("code");return n!=null&&n.language&&t.setAttribute("data-language",n.language),P(t),e.appendChild(t),e},isEmpty:n=>O(n)},gi={kind:"toggle",label:"토글",allowsInlineFormat:!0,allowedMarks:R,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="DETAILS"?{kind:"toggle",attrs:n.hasAttribute("open")?{open:!0}:{}}:null,create:n=>{const e=document.createElement("details");(n==null?void 0:n.open)!==!1&&e.setAttribute("open","");const t=document.createElement("summary");t.className=Cn,P(t);const o=document.createElement("div");return o.className=ct,o.appendChild(P(document.createElement("p"))),e.appendChild(t),e.appendChild(o),e},isEmpty:n=>O(n)},bi={kind:"callout",label:"콜아웃",allowsInlineFormat:!0,allowedMarks:R,allowsColor:!1,allowsFontSize:!0,matches:n=>n.tagName!=="ASIDE"||!n.classList.contains(ce)?null:{kind:"callout",attrs:{variant:In(n)}},create:n=>{const e=document.createElement("aside");return Dn(e,be(n==null?void 0:n.variant)),e.appendChild(P(document.createElement("p"))),e},isEmpty:n=>O(n)};function In(n){for(const e of Array.from(n.classList))if(e!==ce&&e.startsWith(le))return be(e.slice(le.length));return"note"}function Dn(n,e){for(const t of Array.from(n.classList))t.startsWith(le)&&n.classList.remove(t);n.classList.add(ce),n.classList.add(`${le}${e}`)}const yi={kind:"image",label:"이미지",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{var e;if(n.tagName==="FIGURE"){const t=n.querySelector(":scope > img"),o=Wt(t),r=((e=n.querySelector(":scope > figcaption"))==null?void 0:e.textContent)??"";r.trim()&&(o.caption=r);const i=n.getAttribute("style");return i&&(o.wrapperStyle=i),{kind:"image",attrs:o}}return n.tagName==="IMG"?{kind:"image",attrs:Wt(n)}:null},create:n=>{const e=document.createElement("figure");n!=null&&n.wrapperStyle&&e.setAttribute("style",n.wrapperStyle);const t=document.createElement("img"),o=I(n==null?void 0:n.src);if(o&&(t.src=o),n!=null&&n.alt&&(t.alt=n.alt),e.appendChild(t),n!=null&&n.caption){const r=document.createElement("figcaption");r.textContent=n.caption,e.appendChild(r)}return e.appendChild(bt({caption:!0})),e.appendChild(gt()),e},isEmpty:n=>{const e=n.tagName==="IMG"?n:n.querySelector(":scope > img");return!e||!e.getAttribute("src")}};function gt(){const n=document.createElement("span");return n.className="aw-resize-handle",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n}function bt(n={}){const e=document.createElement("span");e.className="aw-block-align-controls",e.setAttribute("contenteditable","false"),e.setAttribute("aria-hidden","true");const t=m().blockAlign;for(const o of["left","center","right"]){const r=document.createElement("button");r.type="button",r.className="aw-block-align-btn",r.dataset.align=o,r.title=t[o],r.setAttribute("aria-label",r.title),r.innerHTML=wi[o],e.appendChild(r)}if(n.caption){const o=document.createElement("span");o.className="aw-block-ctl-divider",e.appendChild(o);const r=document.createElement("button");r.type="button",r.className="aw-block-caption-btn",r.dataset.action="caption",r.title=m().image.captionAdd,r.setAttribute("aria-label",r.title),r.innerHTML=ki,e.appendChild(r)}return e}const ki='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="11" rx="1.5"/><line x1="6" y1="19" x2="18" y2="19"/></svg>',wi={left:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>',center:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>',right:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>'},vi={kind:"table",label:"표",allowsInlineFormat:!0,allowedMarks:R,allowsColor:!0,allowsFontSize:!0,matches:n=>{if(n.tagName!=="TABLE")return null;const e=B(n);return{kind:"table",attrs:{rows:e.rows.length,cols:e.width}}},create:n=>{const e=Math.max(1,(n==null?void 0:n.rows)??1),t=Math.max(1,(n==null?void 0:n.cols)??1),o=document.createElement("table"),r=document.createElement("tbody");for(let i=0;i<e;i++){const l=document.createElement("tr");for(let s=0;s<t;s++){const a=document.createElement("td");a.appendChild(document.createElement("br")),l.appendChild(a)}r.appendChild(l)}return o.appendChild(r),o},isEmpty:n=>n.querySelectorAll(":scope tr").length===0},Ci={kind:"hr",label:"구분선",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>n.tagName==="HR"?{kind:"hr",attrs:{}}:null,create:()=>{const n=document.createElement("hr");return n.setAttribute("contenteditable","false"),n},isEmpty:()=>!1},Ai={kind:"youtube",label:"유튜브",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{if(n.tagName!=="DIV"||!n.classList.contains("aw-youtube-embed"))return null;const e=n.getAttribute("data-youtube-id")??void 0,t={};e&&(t.videoId=e);const o=n.getAttribute("style");return o&&(t.wrapperStyle=o),{kind:"youtube",attrs:t}},create:n=>{const e=dt(n==null?void 0:n.videoId),t=document.createElement("div");t.className="aw-youtube-embed",t.setAttribute("contenteditable","false"),e&&t.setAttribute("data-youtube-id",e),n!=null&&n.wrapperStyle&&t.setAttribute("style",n.wrapperStyle);const o=document.createElement("iframe");return e&&(o.src=`${Re}${e}`),o.setAttribute("allow",yn),o.setAttribute("allowfullscreen",""),o.setAttribute("frameborder","0"),o.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),t.appendChild(o),t.appendChild(bt()),t.appendChild(gt()),t},isEmpty:n=>!n.getAttribute("data-youtube-id")},Li={kind:"linkCard",label:"링크",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{var s,a,c,u,d;if(n.tagName!=="A"||!n.classList.contains("aw-link-card"))return null;const e=n.getAttribute("href")??void 0,t=((s=n.querySelector(":scope > .aw-link-card-body > .aw-link-card-title"))==null?void 0:s.textContent)??((a=n.querySelector(":scope > .aw-link-card-text"))==null?void 0:a.textContent)??void 0,o=((c=n.querySelector(":scope > .aw-link-card-body > .aw-link-card-desc"))==null?void 0:c.textContent)??void 0,r=((u=n.querySelector(":scope > .aw-link-card-image"))==null?void 0:u.getAttribute("src"))??void 0,i=((d=n.querySelector(":scope .aw-link-card-favicon"))==null?void 0:d.getAttribute("src"))??void 0,l={};return e&&(l.href=e),t&&(l.text=t),o&&(l.description=o),r&&(l.image=r),i&&(l.favicon=i),{kind:"linkCard",attrs:l}},create:n=>{const e=te(n==null?void 0:n.href)||"#",t=n!=null&&n.text&&n.text.length>0?n.text:lt(e)||e,o=(n==null?void 0:n.description)??"",r=I(n==null?void 0:n.image),i=n!=null&&n.favicon?I(n.favicon):mn(e),l=document.createElement("a");if(l.className="aw-link-card",r&&l.classList.add("aw-link-card-with-image"),l.href=e,l.target="_blank",l.rel="noopener",l.setAttribute("contenteditable","false"),r){const d=document.createElement("img");d.className="aw-link-card-image",d.src=r,d.alt="",d.loading="lazy",l.appendChild(d)}const s=document.createElement("span");s.className="aw-link-card-body";const a=document.createElement("span");if(a.className="aw-link-card-title",a.textContent=t,s.appendChild(a),o){const d=document.createElement("span");d.className="aw-link-card-desc",d.textContent=o,s.appendChild(d)}const c=document.createElement("span");if(c.className="aw-link-card-url",i){const d=document.createElement("img");d.className="aw-link-card-favicon",d.src=i,d.alt="",d.loading="lazy",c.appendChild(d)}const u=document.createElement("span");return u.className="aw-link-card-url-text",u.textContent=e,c.appendChild(u),s.appendChild(c),l.appendChild(s),l},isEmpty:n=>!n.getAttribute("href")},xi={kind:"file",label:"파일",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{if(n.tagName!=="A"||!n.classList.contains("aw-file-attachment"))return null;const e=n.getAttribute("href")??void 0,t=n.getAttribute("data-file-name")??void 0,o=n.getAttribute("data-file-size"),r=o?Number(o):void 0,i=n.getAttribute("data-file-type")??void 0,l={};return e&&(l.fileSrc=e),t&&(l.fileName=t),r!==void 0&&!Number.isNaN(r)&&(l.fileSize=r),i&&(l.fileType=i),{kind:"file",attrs:l}},create:n=>{const e=document.createElement("a");e.className="aw-file-attachment",e.setAttribute("contenteditable","false"),e.setAttribute("target","_blank"),e.setAttribute("rel","noopener");const t=te(n==null?void 0:n.fileSrc);t&&(e.href=t),e.setAttribute("download",(n==null?void 0:n.fileName)??""),n!=null&&n.fileName&&e.setAttribute("data-file-name",n.fileName),(n==null?void 0:n.fileSize)!==void 0&&e.setAttribute("data-file-size",String(n.fileSize)),n!=null&&n.fileType&&e.setAttribute("data-file-type",n.fileType);const o=document.createElement("span");o.className="aw-file-icon",o.setAttribute("aria-hidden","true"),o.innerHTML=gn;const r=document.createElement("span");r.className="aw-file-meta";const i=document.createElement("span");i.className="aw-file-name",i.textContent=(n==null?void 0:n.fileName)??kn,r.appendChild(i);const l=[],s=fn(n==null?void 0:n.fileName,n==null?void 0:n.fileType);if(s&&l.push(s),(n==null?void 0:n.fileSize)!==void 0&&l.push(pn(n.fileSize)),l.length>0){const c=document.createElement("span");c.className="aw-file-info",c.textContent=l.join(" · "),r.appendChild(c)}const a=document.createElement("span");return a.className="aw-file-action",a.setAttribute("aria-hidden","true"),a.innerHTML=bn,e.appendChild(o),e.appendChild(r),e.appendChild(a),e},isEmpty:n=>!n.getAttribute("href")},Ei={kind:"importedHtml",label:"HTML",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{if(n.tagName!=="DIV"||n.getAttribute("data-imported-html")!=="true")return null;const e={},t=n.getAttribute("style");t&&(e.importedStyle=t);const o=n.getAttribute("class");return o&&(e.importedClass=o),{kind:"importedHtml",attrs:e}},create:n=>{const e=document.createElement("div");return e.setAttribute("data-imported-html","true"),n!=null&&n.importedStyle&&e.setAttribute("style",n.importedStyle),n!=null&&n.importedClass&&e.setAttribute("class",n.importedClass),e},isEmpty:()=>!1},Pn={kind:"unknown",label:"알 수 없음",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:()=>null,create:n=>P(document.createElement(wn(n==null?void 0:n.tag))),isEmpty:n=>O(n)},zn=[ci,di,pi,ui,hi,fi,mi,gi,bi,yi,vi,Ci,Li,Ai,xi,Ei],U=(()=>{const n={unknown:Pn};for(const e of zn)n[e.kind]=e;return n})();function ke(n){for(const e of zn){const t=e.matches(n);if(t)return{type:e,match:t}}return{type:Pn,match:{kind:"unknown",attrs:{tag:n.tagName.toLowerCase()}}}}class yt{constructor(){b(this,"counter",0);b(this,"seen",new Set)}observe(e){this.seen.add(e)}generate(){let e;do{const t=(++this.counter).toString(36),o=Math.random().toString(36).slice(2,6);e=`b${t}_${o}`}while(this.seen.has(e));return this.seen.add(e),e}ensure(e){const t=e.getAttribute(Q);if(t)return this.seen.add(t),t;const o=this.generate();return e.setAttribute(Q,o),o}get(e){return e.getAttribute(Q)}}function V(n,e){const t=new Set;for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const r=o.getAttribute(Q);if(r&&!t.has(r)){t.add(r),e.observe(r);continue}const i=e.generate();o.setAttribute(Q,i),t.add(i)}}function Fn(n,e,t){if(!e)return Array.from(n.querySelectorAll(t));const o=[];for(const r of e){r.matches(t)&&o.push(r);for(const i of Array.from(r.querySelectorAll(t)))o.push(i)}return o}function G(n,e={}){var r;const t=e.blocks?Array.from(e.blocks).filter(i=>i.parentNode===n):null,o=i=>Fn(n,t,i);Wi(n,t);for(const i of Array.from(n.childNodes)){if(i.nodeType!==Node.TEXT_NODE)continue;if((i.textContent??"").trim().length===0){i.remove();continue}const s=document.createElement("p");n.replaceChild(s,i),s.appendChild(i)}for(const i of o(`ul.${K} > li[style]`))i.style.removeProperty("list-style-type"),((r=i.getAttribute("style"))==null?void 0:r.trim())===""&&i.removeAttribute("style");if(t)for(const i of t)Bt(i);else Bt(n);for(const i of o("hr, a.aw-link-card, div.aw-youtube-embed, a.aw-file-attachment"))i.getAttribute("contenteditable")!=="false"&&i.setAttribute("contenteditable","false");for(const i of o("figure, div.aw-youtube-embed"))i.querySelector(":scope > .aw-block-align-controls")||i.appendChild(bt({caption:i.tagName==="FIGURE"})),i.querySelector(":scope > .aw-resize-handle")||i.appendChild(gt());for(const i of o("pre > code"))i.childNodes.length===0&&i.appendChild(document.createElement("br"));Si(o("figure > figcaption")),e.writableTail!==!1&&Ni(n)}function Si(n){var t;if(n.length===0)return;const e=((t=document.getSelection())==null?void 0:t.anchorNode)??null;for(const o of n)O(o)&&(e&&o.contains(e)||o.remove())}const Ti=new Set(["hr","image","youtube","linkCard","file","importedHtml"]);function Ni(n){const e=Array.from(n.children).filter(r=>r instanceof HTMLElement);if(e.length===0){n.appendChild(P(document.createElement("p")));return}const t=e[e.length-1];if(!t)return;const{match:o}=ke(t);Ti.has(o.kind)&&n.appendChild(P(document.createElement("p")))}function Bi(n){const e=m().blocks;switch(n.kind){case"paragraph":return e.paragraph;case"heading":return J(e.heading,{n:n.attrs.level??1});case"bulletList":return e.bulletList;case"orderedList":return e.orderedList;case"taskList":return e.taskList;case"blockquote":return e.blockquote;case"codeBlock":return e.codeBlock;case"toggle":return e.toggle;case"callout":return e.callout;case"image":return e.image;case"table":return e.table;case"hr":return e.hr;case"linkCard":return e.linkCard;case"youtube":return e.youtube;case"file":return e.file;case"importedHtml":return e.importedHtml;default:return e.unknown}}function Mi(n){const e=n.element.getAttribute("style"),t=$i(n.element);return{version:Rn,id:n.id,kind:n.kind,attrs:{...n.attrs},html:Hi(n.element),...e?{style:e}:{},...t?{attributes:t}:{}}}function $i(n){let e;for(const t of at){const o=n.getAttribute(t);o===null||o===""||((e??(e={}))[t]=o)}return e}function Hi(n){if(!n.querySelector(".aw-block-align-controls, .aw-resize-handle"))return n.innerHTML;const e=n.cloneNode(!0);return wt(e),e.innerHTML}function kt(n){return n.map(Mi)}function Ri(n){const t=(U[n.kind]??U.unknown).create(n.attrs);if(t.setAttribute(Q,n.id),n.style&&t.setAttribute("style",n.style),n.attributes){for(const[o,r]of Object.entries(n.attributes))if(at.includes(o)){if(o==="class"){t.setAttribute("class",vn(t.getAttribute("class"),r));continue}t.setAttribute(o,r)}}return n.html.length>0&&t.replaceChildren(Z(n.html)),t}function On(n,e){for(;n.firstChild;)n.removeChild(n.firstChild);for(const t of ye(e))n.appendChild(Ri(t))}function qn(n,e){const t=[];for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const{match:r}=ke(o);t.push({id:e(o),kind:r.kind,attrs:r.attrs,element:o})}return t}function Ii(n,e,t){let o=n;for(;o&&o!==e;){if(o.parentNode===e&&o.nodeType===Node.ELEMENT_NODE){const r=o,{match:i}=ke(r);return{id:t(r),kind:i.kind,attrs:i.attrs,element:r}}o=o.parentNode}return null}function Di(n){const e=n.element;switch(n.kind){case"paragraph":case"heading":return Array.from(e.childNodes);case"bulletList":case"orderedList":case"taskList":{const t=Array.from(e.querySelectorAll(":scope > li"));return je(t)}case"blockquote":case"callout":{const t=Array.from(e.querySelectorAll(":scope > p"));return t.length>0?je(t):Array.from(e.childNodes)}case"codeBlock":{const t=e.querySelector(":scope > code");return t?Array.from(t.childNodes):Array.from(e.childNodes)}case"toggle":{const t=e.querySelector(":scope > summary"),o=e.querySelector(`:scope > .${ct}`),r=[...t instanceof HTMLElement?[t]:[],...o?Array.from(o.children):[]].filter(i=>i instanceof Element);return je(r)}case"table":case"importedHtml":{const t=(e.textContent??"").replace(/\s+/g," ").trim();return t?[document.createTextNode(t)]:[]}case"image":{const t=e.querySelector(":scope > figcaption"),o=((t==null?void 0:t.textContent)??"").trim();return o?[document.createTextNode(o)]:[]}default:return[]}}function je(n){const e=[];return n.forEach((t,o)=>{o>0&&e.push(document.createElement("br"));for(const r of Array.from(t.childNodes))e.push(r)}),e}function Pi(n,e,t){if(t.length===0)return;let o=null;switch(e){case"paragraph":case"heading":o=n;break;case"bulletList":case"orderedList":case"taskList":o=n.querySelector(":scope > li");break;case"blockquote":case"callout":o=n.querySelector(":scope > p");break;case"codeBlock":o=n.querySelector(":scope > code");break;case"toggle":o=n.querySelector(":scope > summary");break;default:return}if(!o)return;for(;o.firstChild;)o.removeChild(o.firstChild);for(const i of t)o.appendChild(i);const r=U[e];r&&zi(o,r)}function zi(n,e){const t=new Set(e.allowedMarks);for(const o of Array.from(n.querySelectorAll("*"))){if(!(o instanceof HTMLElement)||!o.parentNode)continue;const r=o.tagName.toLowerCase();if((r==="b"||r==="strong")&&!t.has("bold")||(r==="i"||r==="em")&&!t.has("italic")||r==="u"&&!t.has("underline")||(r==="s"||r==="strike"||r==="del")&&!t.has("strike")||r==="sup"&&!t.has("superscript")||r==="sub"&&!t.has("subscript")){_t(o);continue}if(r==="span"||r==="font"){const i=o.style;if(!t.has("bold")){const c=i.fontWeight;(c==="bold"||c==="bolder"||/^[7-9]\d{2}$|^1000$/.test(c))&&i.removeProperty("font-weight")}!t.has("italic")&&i.fontStyle==="italic"&&i.removeProperty("font-style");const l=i.textDecorationLine||i.textDecoration||"";if(l){const c=l.split(/\s+/),u=c.filter(d=>!(d==="underline"&&!t.has("underline")||d==="line-through"&&!t.has("strike")));u.length!==c.length&&(i.removeProperty("text-decoration"),i.removeProperty("text-decoration-line"),u.length>0&&(i.textDecoration=u.join(" ")))}e.allowsColor||(i.removeProperty("color"),i.removeProperty("background-color"),r==="font"&&o.removeAttribute("color")),e.allowsFontSize||(i.removeProperty("font-size"),r==="font"&&o.removeAttribute("size")),e.allowsInlineFormat||(i.removeProperty("font-family"),r==="font"&&o.removeAttribute("face"));const s=i.cssText.trim().length>0,a=Array.from(o.attributes).some(c=>c.name!=="style");!s&&!a&&_t(o)}}}function _t(n){const e=n.parentNode;if(e){for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n)}}function Fi(n={}){const e=n.fg||"currentColor",t=n.bg||"transparent",o=n.mode==="dark"?!0:n.mode==="light"?!1:Oi(e,t);return{primary:n.primary||"#64c8ff",fg:e,bg:t,border:n.border||"rgba(127,127,127,0.25)",fgMuted:n.fgMuted||"rgba(127,127,127,0.6)",isDark:o}}function Oi(n,e){const t=Ut(n);if(t!==null)return t>.5;const o=Ut(e);return o!==null?o<.5:!0}function Ut(n){if(!n)return null;const e=n.trim();let t=-1,o=-1,r=-1;const i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e);if(i&&i[1]){const l=i[1];l.length===3?(t=parseInt(l[0]+l[0],16),o=parseInt(l[1]+l[1],16),r=parseInt(l[2]+l[2],16)):(t=parseInt(l.slice(0,2),16),o=parseInt(l.slice(2,4),16),r=parseInt(l.slice(4,6),16))}else{const l=/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/.exec(e);l&&(t=Number(l[1]),o=Number(l[2]),r=Number(l[3]))}return t<0?null:(.299*t+.587*o+.114*r)/255}function _n(n){const e=getComputedStyle(n),t=c=>{const u=e.getPropertyValue(c).trim();return u.length>0?u:void 0},o={},r=t("--aw-primary"),i=t("--aw-fg"),l=t("--aw-bg"),s=t("--aw-border"),a=t("--aw-fg-muted");return r&&(o.primary=r),i&&(o.fg=i),l&&(o.bg=l),s&&(o.border=s),a&&(o.fgMuted=a),o}function qi(n){const e=`color-mix(in srgb, ${n.primary} 8%, transparent)`,t=`color-mix(in srgb, ${n.fg} 6%, ${n.bg})`;return{H1:`font-size:1.875rem;font-weight:700;line-height:1.3;margin:.6em 0 .4em;padding-bottom:.25em;border-bottom:1px solid ${n.border};color:${n.fg};`,H2:`font-size:1.5rem;font-weight:700;line-height:1.35;margin:.6em 0 .4em;padding-bottom:.25em;border-bottom:1px solid ${n.border};color:${n.fg};`,H3:`font-size:1.25rem;font-weight:700;line-height:1.4;margin:.6em 0 .4em;padding-bottom:.25em;border-bottom:1px solid ${n.border};color:${n.fg};`,H4:`font-size:1.125rem;font-weight:700;line-height:1.4;margin:.6em 0 .4em;color:${n.fg};`,H5:`font-size:1rem;font-weight:700;margin:.6em 0 .4em;color:${n.fg};`,H6:`font-size:.875rem;font-weight:700;margin:.6em 0 .4em;color:${n.fg};`,P:`margin:0 0 .8em;color:${n.fg};`,UL:`margin:.6em 0;padding-left:1.6em;list-style:disc;color:${n.fg};`,OL:`margin:.6em 0;padding-left:1.6em;list-style:decimal;color:${n.fg};`,BLOCKQUOTE:`margin:1em 0;padding:.5em 1em;border-left:4px solid ${n.primary};background-color:${e};color:${n.fg};font-style:italic;`,PRE:`margin:1em 0;padding:12px 16px;background-color:${t};border:1px solid ${n.border};border-radius:6px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.9em;line-height:1.6;overflow-x:auto;white-space:pre;color:${n.fg};`,HR:`border:none;border-top:1px solid ${n.border};margin:1.5em 0;`,TABLE:`width:100%;border-collapse:collapse;margin:1em 0;color:${n.fg};`,FIGURE:"margin:1em 0;text-align:center;",A:`display:block;text-decoration:none;margin:1em 0;padding:12px 16px;border:1px solid ${n.border};border-radius:8px;background-color:${e};color:${n.fg};`}}function _i(n){const e=`color-mix(in srgb, ${n.fg} 5%, ${n.bg})`,t=`color-mix(in srgb, ${n.primary} 12%, transparent)`;return{"pre > code":"background:transparent;padding:0;font:inherit;color:inherit;display:block;","table td":`border:1px solid ${n.border};padding:6px 10px;`,"table th":`border:1px solid ${n.border};padding:6px 10px;background-color:${e};font-weight:600;text-align:left;`,img:"max-width:100%;height:auto;border-radius:4px;","a.aw-link-card .aw-link-card-text":`display:block;font-weight:600;font-size:1rem;margin-bottom:4px;color:${n.fg};text-decoration:none;`,"a.aw-link-card .aw-link-card-url":`display:block;font-size:.8rem;color:${n.primary};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;text-decoration:none;`,"div.aw-youtube-embed":"position:relative;width:100%;aspect-ratio:16/9;margin:1em 0;border-radius:8px;overflow:hidden;background:#000;","div.aw-youtube-embed iframe":"position:absolute;inset:0;width:100%;height:100%;border:0;display:block;","a.aw-file-attachment .aw-file-icon":`flex:0 0 auto;display:inline-flex;width:36px;height:36px;align-items:center;justify-content:center;border-radius:6px;background:${t};color:${n.primary};`,"a.aw-file-attachment .aw-file-icon svg":"width:20px;height:20px;","a.aw-file-attachment .aw-file-meta":"flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px;","a.aw-file-attachment .aw-file-name":`font-weight:600;font-size:.95rem;color:${n.fg};word-break:break-all;line-height:1.3;`,"a.aw-file-attachment .aw-file-info":`font-size:.75rem;color:${n.fgMuted};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.02em;`,"a.aw-file-attachment .aw-file-action":`flex:0 0 auto;display:inline-flex;width:32px;height:32px;align-items:center;justify-content:center;color:${n.fgMuted};`,"a.aw-file-attachment .aw-file-action svg":"width:18px;height:18px;","pre > code .hl-keyword":n.isDark?"color:#c678dd;font-weight:600;":"color:#a626a4;font-weight:600;","pre > code .hl-string":n.isDark?"color:#98c379;":"color:#50a14f;","pre > code .hl-number":n.isDark?"color:#d19a66;":"color:#986801;","pre > code .hl-comment":`color:${n.fgMuted};font-style:italic;`,"pre > code .hl-fn":n.isDark?"color:#61afef;":"color:#4078f2;","pre > code .hl-builtin":n.isDark?"color:#56b6c2;":"color:#0184bc;","pre > code .hl-tag":n.isDark?"color:#e06c75;":"color:#e45649;","pre > code .hl-attr":n.isDark?"color:#d19a66;":"color:#986801;","pre > code .hl-prop":n.isDark?"color:#61afef;":"color:#4078f2;","pre > code .hl-punct":`color:${n.fgMuted};`}}function Un(n,e={}){const{t,blockStyles:o,nestedStyles:r}=Ui(e);for(const i of Array.from(n.children)){if(!(i instanceof HTMLElement)||i.getAttribute("data-imported-html")==="true")continue;if(i.tagName==="A"&&i.classList.contains("aw-file-attachment")){pe(i,`display:flex;align-items:center;gap:12px;margin:1em 0;padding:10px 14px;border:1px solid ${t.border};border-radius:8px;background:${t.bg};color:${t.fg};text-decoration:none;`);continue}if(i.tagName==="UL"&&i.classList.contains(K)){pe(i,`margin:.6em 0;padding-left:1.6em;color:${t.fg};`);for(const s of Array.from(i.querySelectorAll(":scope > li"))){const a=s.getAttribute(X)==="true";pe(s,a?`list-style-type:"\\2611 ";color:${t.fgMuted};text-decoration:line-through;`:'list-style-type:"\\2610 ";')}continue}const l=o[i.tagName];l&&pe(i,l)}for(const[i,l]of Object.entries(r))for(const s of Array.from(n.querySelectorAll(i)))s instanceof HTMLElement&&(s.closest("[data-imported-html]")||pe(s,l))}let he=null;function Ui(n){const e=JSON.stringify(n);if(he&&he.key===e)return he;const t=Fi(n);return he={key:e,t,blockStyles:qi(t),nestedStyles:_i(t)},he}function pe(n,e){const t=(n.getAttribute("style")??"").trim();if(!t){const s=e.replace(/;\s*$/,"").trim();s&&n.setAttribute("style",s);return}const o=jt(t),r=new Set(o.map(s=>s.prop)),l=[...jt(e).filter(s=>!r.has(s.prop)),...o].map(s=>`${s.prop}:${s.value}`).join(";");l?n.setAttribute("style",l):n.removeAttribute("style")}function jt(n){const e=[];for(const t of n.split(";")){const o=t.trim();if(!o)continue;const r=o.indexOf(":");if(r<=0)continue;const i=o.slice(0,r).trim().toLowerCase(),l=o.slice(r+1).trim();!i||!l||e.push({prop:i,value:l})}return e}const ot={left:"aw-align-left",center:"aw-align-center",right:"aw-align-right",justify:"aw-align-justify"};function jn(n){for(const e of Array.from(n.children)){if(!(e instanceof HTMLElement))continue;const{match:t}=ke(e);e.classList.add("aw-block",`aw-block-${t.kind}`)}for(const e of Array.from(n.querySelectorAll("[style]")))e.closest("[data-imported-html]")||ji(e)}function ji(n){var r;const e=n.style.textAlign.trim().toLowerCase(),t=ot[e],o=Object.values(ot).filter(i=>i!==t&&n.classList.contains(i));for(const i of o)n.classList.remove(i);t&&(n.classList.add(t),n.style.removeProperty("text-align"),((r=n.getAttribute("style"))==null?void 0:r.trim())===""&&n.removeAttribute("style"))}function Wi(n,e=null){var t;for(const[o,r]of Object.entries(ot))for(const i of Fn(n,e,`.${r}`))i.style.textAlign||(i.style.textAlign=o),i.classList.remove(r),((t=i.getAttribute("class"))==null?void 0:t.trim())===""&&i.removeAttribute("class")}function wt(n){const e=n.querySelectorAll(".aw-block-align-controls, .aw-resize-handle");for(const t of Array.from(e))t.remove();for(const t of Array.from(n.querySelectorAll("[contenteditable]")))t.removeAttribute("contenteditable")}function Wn(n){for(const e of Array.from(n.querySelectorAll("[data-block-kind]")))e.removeAttribute("data-block-kind");for(const e of Array.from(n.querySelectorAll("[data-block-label]")))e.removeAttribute("data-block-label");for(const e of Array.from(n.querySelectorAll("[data-block-focused]")))e.removeAttribute("data-block-focused");for(const e of Array.from(n.querySelectorAll("[data-block-flash]")))e.removeAttribute("data-block-flash");for(const e of Array.from(n.querySelectorAll("[data-block-explicit]")))e.removeAttribute("data-block-explicit")}function M(n){const e=document.getSelection();if(!e)return;const t=document.createRange();if(n.tagName==="HR")t.setStartAfter(n);else{const o=Ki(n);t.selectNodeContents(o),t.collapse(!0)}e.removeAllRanges(),e.addRange(t)}function Ki(n){switch(n.tagName){case"UL":case"OL":{const e=n.querySelector(":scope > li");return e instanceof HTMLElement?e:n}case"BLOCKQUOTE":{const e=n.querySelector(":scope > p");return e instanceof HTMLElement?e:n}case"PRE":{const e=n.querySelector(":scope > code");return e instanceof HTMLElement?e:n}case"TABLE":{const e=n.querySelector(":scope td, :scope th");return e instanceof HTMLElement?e:n}default:return n}}function P(n){return n.appendChild(document.createElement("br")),n}function vt(n){const e=document.createElement(n),t=document.createElement("li");return t.appendChild(document.createElement("br")),e.appendChild(t),e}function Ct(n){const e=n.querySelectorAll(":scope > li");return e.length===0?!0:e.length===1?O(e[0]):!1}function O(n){return(n.textContent??"").replace(/​/g,"").trim().length===0}function Gi(n){return n===void 0||n<1?1:n>6?6:n}function Wt(n){if(!n)return{};const e={},t=n.getAttribute("src"),o=n.getAttribute("alt");return t&&(e.src=t),o&&(e.alt=o),e}function Ie(n){return n?U[n.kind]??U.unknown:null}function Kt(n,e){var t;return((t=Ie(n))==null?void 0:t.allowedMarks.includes(e))??!1}function We(n){var e;return((e=Ie(n))==null?void 0:e.allowsInlineFormat)??!1}function Gt(n){var e;return((e=Ie(n))==null?void 0:e.allowsFontSize)??!1}function ve(n){var e;return((e=Ie(n))==null?void 0:e.allowsColor)??!1}const Vi=new Set(["paragraph","heading","blockquote","table"]);function Ke(n){return n!==null&&Vi.has(n.kind)}function Ge(n){return(n==null?void 0:n.kind)==="table"}function Ve(n,e){return e.kind==="unknown"?n.tagName.toLowerCase():Bi(e)}const Vt={paragraph:"¶",heading:"H",bulletList:"•",orderedList:"1.",taskList:"☑",blockquote:"❝",codeBlock:"‹›",toggle:"▸",callout:"⚠",image:"▣",table:"▦",hr:"—",linkCard:"↗",youtube:"▶",file:"⇩",importedHtml:"</>",unknown:"?"};function Yi(n){return n.kind==="heading"?`H${n.attrs.level??1}`:Vt[n.kind]??Vt.unknown}const Xi={0:{kind:"paragraph"},1:{kind:"heading",attrs:{level:1}},2:{kind:"heading",attrs:{level:2}},3:{kind:"heading",attrs:{level:3}},4:{kind:"heading",attrs:{level:4}},5:{kind:"heading",attrs:{level:5}},6:{kind:"heading",attrs:{level:6}},7:{kind:"orderedList"},8:{kind:"bulletList"},9:{kind:"blockquote"},c:{kind:"codeBlock"},t:{kind:"taskList"}},Kn=new RegExp(" ","g");function Zi(n){const e=n.replace(Kn," "),t=/^(#{1,6}) $/.exec(e);return t&&t[1]?{kind:"heading",attrs:{level:Math.min(6,t[1].length)}}:/^[-*+] $/.test(e)?{kind:"bulletList"}:/^\d+[.)] $/.test(e)?{kind:"orderedList"}:e==="> "?{kind:"blockquote"}:e==="```"||e==="~~~"?{kind:"codeBlock"}:e==="---"||e==="***"?{kind:"hr"}:null}function Ji(n){const e=/^\[([ xX])\] $/.exec(n.replace(Kn," "));return e?{checked:(e[1]??" ").toLowerCase()==="x"}:null}function Qi(n){return Gn(n)}function el(n,e){Vn(n,e)}function Gn(n){const e=document.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0);if(!n.contains(t.commonAncestorContainer))return null;const o=document.createRange();o.selectNodeContents(n);try{o.setEnd(t.startContainer,t.startOffset);const r=o.toString().length;return o.setEnd(t.endContainer,t.endOffset),{start:r,end:o.toString().length}}catch{return null}}function Vn(n,e){const t=Ne(n,e.start),o=Ne(n,e.end);if(!t||!o)return;const r=document.createRange();try{r.setStart(t.node,t.offset),r.setEnd(o.node,o.offset)}catch{return}const i=document.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(r)}function Ne(n,e){var l;const t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);let o=0,r=null,i=t.nextNode();for(;i;){const s=((l=i.textContent)==null?void 0:l.length)??0;if(o+s>=e)return{node:i,offset:Math.max(0,e-o)};o+=s,r={node:i,offset:s},i=t.nextNode()}return r??{node:n,offset:0}}function tl(n){const e=document.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);if(!n.contains(t.endContainer))return!1;const o=document.createRange();o.selectNodeContents(n);try{o.setStart(t.endContainer,t.endOffset)}catch{return!1}return o.toString().replace(st,"").trim()===""}function Yt(n){const e=document.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return null;const t=e.getRangeAt(0);if(!n.contains(t.startContainer))return null;const o=document.createRange();o.selectNodeContents(n);try{o.setEnd(t.startContainer,t.startOffset)}catch{return null}return{text:o.toString(),range:o}}function Ce(n){let e=n;if(e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentElement),!(e instanceof Element))return null;const t=e.closest("td, th");return t instanceof HTMLTableCellElement?t:null}const oe=6;function Xt(n,e,t){const o=n.getBoundingClientRect();return e<o.left-oe||e>o.right+oe||t<o.top-oe||t>o.bottom+oe?null:e>=o.right-oe?"right":t>=o.bottom-oe?"bottom":null}const nl=new Set(["data-block-focused","data-block-flash","data-block-kind","data-block-label"]),ol=/ data-block-(?:focused|flash|kind|label)(?:="[^"]*")?/g;function Ye(n){if(!n.includes(" data-block-"))return n;let e=!1,t=-1;for(let r=0;r<n.length;r++){const i=n.charCodeAt(r);if(i===34)e=!e;else if(i===62&&!e){t=r;break}}return t<0?n:n.slice(0,t).replace(ol,"")+n.slice(t)}class rl{constructor(e){b(this,"dirty",new Set);b(this,"structure",!1);b(this,"raw",new WeakMap);b(this,"out",new WeakMap);b(this,"info",new WeakMap);b(this,"children",[]);this.root=e}topLevelOf(e){let t=e;for(;t&&t.parentNode!==this.root;)t=t.parentNode;return t&&t.nodeType===1?t:null}collect(e){for(const t of e){if(t.target===this.root){if(t.type!=="childList")continue;this.structure=!0,t.addedNodes.forEach(r=>{r.nodeType===1&&this.mark(r)});continue}if(t.type==="attributes"&&t.attributeName&&nl.has(t.attributeName)&&t.target.parentNode===this.root)continue;const o=this.topLevelOf(t.target);o&&this.mark(o)}}mark(e){this.dirty.add(e),this.out.delete(e),this.info.delete(e)}get pending(){return this.structure||this.dirty.size>0}commit(e){let t=!1;for(const o of this.dirty){if(o.parentNode!==this.root)continue;e.push(o);const r=Ye(o.outerHTML);this.raw.get(o)!==r&&(this.raw.set(o,r),t=!0)}if(this.dirty.clear(),this.structure){this.structure=!1;const o=Array.from(this.root.children);!t&&!il(o,this.children)&&(t=!0),this.children=o}return t}snapshot(){const e=[];for(const t of Array.from(this.root.children))e.push(this.rawOf(t));return e}rawOf(e){let t=this.raw.get(e);return t===void 0&&(t=Ye(e.outerHTML),this.raw.set(e,t)),t}output(e,t,o){const r=this.out.get(e);if(r&&r.key===t&&!this.dirty.has(e))return r.html;const i=o(e);return this.out.set(e,{key:t,html:i}),i}classify(e){let t=this.info.get(e);return t||(t=ke(e),this.info.set(e,t)),t}reset(){this.dirty.clear(),this.structure=!1,this.children=Array.from(this.root.children);for(const e of this.children)this.raw.set(e,Ye(e.outerHTML)),this.out.delete(e),this.info.delete(e)}}function il(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function Yn(n,e){if(n.blocks===e.blocks)return!0;if(n.size!==e.size||n.blocks.length!==e.blocks.length)return!1;for(let t=0;t<n.blocks.length;t++)if(n.blocks[t]!==e.blocks[t])return!1;return!0}const ll=600,sl=200,al=64;class cl{constructor(e){b(this,"past",[]);b(this,"future",[]);b(this,"present");b(this,"lastPushAt",0);b(this,"lastKind","structural");this.present=e}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}record(e,t,o){if(Yn(e,this.present)){this.present=e;return}const r=Math.abs(e.size-this.present.size)>al;t==="typing"&&this.lastKind==="typing"&&!r&&o-this.lastPushAt<ll||(this.past.push(this.present),this.past.length>sl&&this.past.shift(),this.lastPushAt=o),this.lastKind=t,this.present=e,this.future.length=0}undo(){const e=this.past.pop();return e?(this.future.push(this.present),this.present=e,this.lastKind="structural",e):null}redo(){const e=this.future.pop();return e?(this.past.push(this.present),this.present=e,this.lastKind="structural",e):null}current(){return this.present}reset(e){this.past.length=0,this.future.length=0,this.present=e,this.lastKind="structural",this.lastPushAt=0}}const dl=new Set(["P","DIV","SECTION","ARTICLE","HEADER","FOOTER","NAV","ASIDE","MAIN","H1","H2","H3","H4","H5","H6","UL","OL","LI","DL","DT","DD","BLOCKQUOTE","PRE","HR","TABLE","FIGURE","FIGCAPTION","FORM","FIELDSET","ADDRESS"]);function ul(n){return dl.has(n.toUpperCase())}const hl=["script","noscript","meta","link","style","base"],pl=new Set(["border-collapse","border-spacing","caption-side","color","cursor","direction","empty-cells","font-family","font-size","font-style","font-variant","font-weight","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","orphans","quotes","text-align","text-indent","text-transform","visibility","white-space","widows","word-spacing","caret-color","font","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size-adjust","font-stretch","font-synthesis","font-synthesis-weight","font-synthesis-style","font-synthesis-small-caps","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","hanging-punctuation","hyphens","image-rendering","line-break","overflow-wrap","pointer-events","ruby-align","ruby-position","tab-size","text-align-last","text-combine-upright","text-decoration-color","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-justify","text-orientation","text-rendering","text-shadow","text-size-adjust","text-underline-offset","text-underline-position","white-space-collapse","word-break","word-wrap","writing-mode","color-scheme","print-color-adjust","-webkit-font-smoothing","-moz-osx-font-smoothing","-webkit-locale","-webkit-text-fill-color","-webkit-text-stroke","-webkit-text-stroke-color","-webkit-text-stroke-width","-webkit-print-color-adjust","clip-rule","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor"]),fl=new Set(["border-block-end-color","border-block-start-color","border-bottom-color","border-inline-end-color","border-inline-start-color","border-left-color","border-right-color","border-top-color","caret-color","column-rule-color","row-rule-color","outline-color","text-decoration-color","text-emphasis-color","-webkit-text-fill-color","-webkit-text-stroke-color"]);async function ml(n,e={}){const t=e.settleMs??1e3,o=e.timeoutMs??3e4,r=e.width??1024,i=e.mountTarget??null;return new Promise((l,s)=>{const a=document.createElement("iframe");a.setAttribute("aria-hidden","true"),a.setAttribute("tabindex","-1"),a.style.position="fixed",a.style.left="-99999px",a.style.top="0",a.style.width=`${r}px`,a.style.height="768px",a.style.border="0",a.style.opacity="0",a.style.pointerEvents="none",a.setAttribute("sandbox","allow-same-origin");let c=!1;const u=()=>{a.parentNode&&a.parentNode.removeChild(a)},d=g=>{c||(c=!0,u(),s(g))},h=g=>{c||(c=!0,u(),l(g))},f=window.setTimeout(()=>{d(new Error("HTML 로드 시간 초과"))},o),p=()=>{var A;const g=a.contentDocument;if(!g||!g.body||g.body.children.length===0&&(g.body.textContent??"").trim()==="")return;const k=a.contentWindow,y=(k==null?void 0:k.requestAnimationFrame)??window.requestAnimationFrame;(g.fonts&&typeof((A=g.fonts.ready)==null?void 0:A.then)=="function"?g.fonts.ready:Promise.resolve()).then(()=>{const v=()=>{window.setTimeout(()=>{if(!c)try{const L=a.contentWindow,N=a.contentDocument;if(!L||!N||!N.body){window.clearTimeout(f),d(new Error("iframe document 접근 실패"));return}const $=gl(N.body,L,i);for(const w of $)ut(w);window.clearTimeout(f),h($)}catch(L){window.clearTimeout(f),d(L instanceof Error?L:new Error(String(L)))}},t)};y(()=>y(v))})};a.addEventListener("load",p),a.srcdoc=n,document.body.appendChild(a)})}function gl(n,e,t){var l;const o=n.ownerDocument;if(!o)throw new Error("body has no ownerDocument");const r=document.createElement("div"),i=bl(o,e,t);try{for(let a=0;a<n.attributes.length;a++){const c=n.attributes.item(a);c&&c.name!=="style"&&r.setAttribute(c.name,c.value)}const s=At(n,null,"div",i.get,e);s.length>0&&r.setAttribute("style",s);for(const a of Array.from(n.children)){const c=document.importNode(a,!0);Xn(a,c,n,i.get,e),r.appendChild(c)}}finally{i.cleanup()}for(const s of hl)for(const a of Array.from(r.querySelectorAll(s)))(l=a.parentNode)==null||l.removeChild(a);return r.style.width="auto",r.style.maxWidth="none",r.style.height="auto",r.style.maxHeight="none",r.setAttribute("data-imported-html","true"),[r]}function bl(n,e,t){var u;let o,r,i;const l=((u=t==null?void 0:t.ownerDocument)==null?void 0:u.defaultView)??null;if(t&&l){o=t.ownerDocument,r=l;const d=o.createElement("div");d.setAttribute("data-imported-html","true"),d.setAttribute("aria-hidden","true"),d.style.cssText="position:absolute;left:-99999px;top:0;visibility:hidden;pointer-events:none;",t.appendChild(d),i=d}else{o=n,r=e;const d=o.createElement("div");d.setAttribute("aria-hidden","true"),d.style.cssText="position:absolute;left:-99999px;top:0;width:0;height:0;overflow:hidden;visibility:hidden;",o.body.appendChild(d),i=d}const s=new Map;return{get:d=>{const h=s.get(d);if(h)return h;const f=o.createElement(d);i.appendChild(f);const p=r.getComputedStyle(f),g=new Map;for(let k=0;k<p.length;k++){const y=p.item(k);y&&g.set(y,p.getPropertyValue(y))}return i.removeChild(f),s.set(d,g),g},cleanup:()=>{i.parentNode&&i.parentNode.removeChild(i)}}}function At(n,e,t,o,r,i){const l=r.getComputedStyle(n,i??null),s=e?r.getComputedStyle(e):null,a=o(t);let c="";for(let u=0;u<l.length;u++){const d=l.item(u);if(!d)continue;const h=l.getPropertyValue(d);if(h&&!(i&&d==="content")&&!(fl.has(d)&&h===l.getPropertyValue("color"))){if(pl.has(d)){if(s&&s.getPropertyValue(d)===h)continue}else if(a.get(d)===h)continue;c+=`${d}:${h};`}}return c}function yl(n){let e="";const t=/"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'/g;let o;for(;(o=t.exec(n))!==null;){const r=o[1]??o[2]??"";e+=r.replace(/\\(?:([0-9a-fA-F]{1,6})\s?|(.))/g,(i,l,s)=>l?String.fromCodePoint(parseInt(l,16)):s??"")}return e}const kl=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","UL","OL","DL","SELECT","OPTGROUP"]);function Zt(n,e,t,o,r){if(kl.has(e.tagName))return;const i=t==="before"?"::before":"::after",l=r.getComputedStyle(n,i),s=l.getPropertyValue("content");if(!s||s==="none"||s==="normal"||l.getPropertyValue("display")==="none")return;const a=yl(s),c=/url\((["']?)([^"')]+)\1\)/.exec(s),u=At(n,n,"span",o,r,i);if(!a&&!c&&!u)return;const d=e.ownerDocument,h=d.createElement("span");if(h.setAttribute("data-imported-pseudo",t),u&&h.setAttribute("style",u),c!=null&&c[2]){const f=d.createElement("img");f.setAttribute("src",c[2]),f.setAttribute("alt",""),h.appendChild(f)}a&&h.appendChild(d.createTextNode(a)),t==="before"?e.insertBefore(h,e.firstChild):e.appendChild(h)}function Xn(n,e,t,o,r){if(n.nodeType===1&&e.nodeType===1){const a=At(n,t,n.tagName.toLowerCase(),o,r);a.length>0?e.setAttribute("style",a):e.hasAttribute("style")&&e.removeAttribute("style")}const i=n.children,l=e.children,s=Math.min(i.length,l.length);for(let a=0;a<s;a++){const c=i[a],u=l[a];c&&u&&Xn(c,u,n,o,r)}n.nodeType===1&&e.nodeType===1&&(Zt(n,e,"before",o,r),Zt(n,e,"after",o,r))}function Zn(n){const e=Jn(n),t=Z(e),o=[];for(const r of Array.from(t.children))r instanceof HTMLElement&&o.push(r);return o}function Jn(n){const t=n.replace(/\r\n?/g,`
18
15
  `).replace(/\s+$/,"").split(`
19
- `),o=[];let l=0;for(;l<n.length;){const i=n[l]??"";if(i.trim()===""){l++;continue}const r=/^```\s*([\w-]*)\s*$/.exec(i);if(r){const c=r[1]??"",d=[];for(l++;l<n.length&&!/^```\s*$/.test(n[l]??"");)d.push(n[l]??""),l++;l<n.length&&l++;const u=c?` data-language="${Me(c)}"`:"";o.push(`<pre><code${u}>${ke(d.join(`
20
- `))}</code></pre>`);continue}const s=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(i);if(s){const c=(s[1]??"#").length;o.push(`<h${c}>${X(s[2]??"")}</h${c}>`),l++;continue}if(/^[\s]*([-*_])(\s*\1){2,}[\s]*$/.test(i)){o.push("<hr>"),l++;continue}if(fn(i,n[l+1]??"")){const c=[i];for(l++,c.push(n[l]??""),l++;l<n.length&&(n[l]??"").includes("|")&&(n[l]??"").trim()!=="";)c.push(n[l]??""),l++;o.push(Sl(c));continue}if(i.startsWith(">")){const c=[];for(;l<n.length&&(n[l]??"").startsWith(">");)c.push((n[l]??"").replace(/^>\s?/,"")),l++;const d=X(c.join(" ").trim());o.push(`<blockquote><p>${d}</p></blockquote>`);continue}if(/^[\s]*[-*+]\s+\[[ xX]\]\s+/.test(i)){const c=Bl(n,l);l=c.next,o.push(`<ul class="${q}">${c.html}</ul>`);continue}if(/^[\s]*[-*+]\s+/.test(i)){const c=Et(n,l,/^[\s]*[-*+]\s+(.*)$/);l=c.next,o.push(`<ul>${c.html}</ul>`);continue}if(/^[\s]*\d+\.\s+/.test(i)){const c=Et(n,l,/^[\s]*\d+\.\s+(.*)$/);l=c.next,o.push(`<ol>${c.html}</ol>`);continue}const a=[];for(;l<n.length&&(n[l]??"").trim()!==""&&!Tl(n[l]??"",n[l+1]??"");)a.push(n[l]??""),l++;a.length>0&&o.push(`<p>${X($l(a))}</p>`)}return o.join(`
21
- `)}function Tl(t,e){return/^#{1,6}\s/.test(t)||/^[\s]*[-*+]\s+/.test(t)||/^[\s]*\d+\.\s+/.test(t)||t.startsWith(">")||/^```/.test(t)||/^[\s]*([-*_])(\s*\1){2,}[\s]*$/.test(t)||fn(t,e)}function fn(t,e){return t.includes("|")?/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/.test(e):!1}function Sl(t){if(t.length<2)return"";const e=Pe(t[0]??""),o=Pe(t[1]??"").map(s=>{const a=s.trim(),c=a.startsWith(":"),d=a.endsWith(":");return c&&d?"center":d?"right":c?"left":null}),l=t.slice(2).map(Pe),i=e.map((s,a)=>{const c=o[a];return`<th${c?` style="text-align:${c}"`:""}>${X(s.trim())}</th>`}).join(""),r=l.map(s=>`<tr>${s.map((c,d)=>{const u=o[d];return`<td${u?` style="text-align:${u}"`:""}>${X(c.trim())}</td>`}).join("")}</tr>`).join("");return`<table><thead><tr>${i}</tr></thead><tbody>${r}</tbody></table>`}function Pe(t){return t.trim().replace(/^\|/,"").replace(/\|$/,"").split("|")}function Et(t,e,n){const o=[];let l=e;for(;l<t.length;){const i=t[l]??"";if(i.trim()===""){const s=t[l+1]??"";if(n.test(s)){l++;continue}break}const r=n.exec(i);if(!r)break;o.push(`<li>${X(r[1]??"")}</li>`),l++}return{html:o.join(""),next:l}}function Bl(t,e){const n=/^[\s]*[-*+]\s+\[([ xX])\]\s+(.*)$/,o=[];let l=e;for(;l<t.length;){const i=n.exec(t[l]??"");if(!i)break;const s=(i[1]??" ").toLowerCase()==="x"?` ${G}="true"`:"";o.push(`<li${s}>${X(i[2]??"")}</li>`),l++}return{html:o.join(""),next:l}}function $l(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n]??"",l=n===t.length-1;!l&&/ +$/.test(o)?e.push(o.replace(/\s+$/,"")+`
16
+ `),o=[];let r=0;for(;r<t.length;){const i=t[r]??"";if(i.trim()===""){r++;continue}const l=/^```\s*([\w-]*)\s*$/.exec(i);if(l){const c=l[1]??"",u=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]??"");)u.push(t[r]??""),r++;r<t.length&&r++;const d=c?` data-language="${De(c)}"`:"";o.push(`<pre><code${d}>${xe(u.join(`
17
+ `))}</code></pre>`);continue}const s=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(i);if(s){const c=(s[1]??"#").length;o.push(`<h${c}>${ee(s[2]??"")}</h${c}>`),r++;continue}if(/^[\s]*([-*_])(\s*\1){2,}[\s]*$/.test(i)){o.push("<hr>"),r++;continue}if(Qn(i,t[r+1]??"")){const c=[i];for(r++,c.push(t[r]??""),r++;r<t.length&&(t[r]??"").includes("|")&&(t[r]??"").trim()!=="";)c.push(t[r]??""),r++;o.push(vl(c));continue}if(i.startsWith(">")){const c=[];for(;r<t.length&&(t[r]??"").startsWith(">");)c.push((t[r]??"").replace(/^>\s?/,"")),r++;const u=/^\[!([A-Za-z]+)\]\s*$/.exec(c[0]??""),d=u?c.slice(1):c,h=ee(d.join(" ").trim());if(u){const f=be((u[1]??"").toLowerCase());o.push(`<aside class="${ce} ${le}${f}"><p>${h}</p></aside>`)}else o.push(`<blockquote><p>${h}</p></blockquote>`);continue}if(/^[\s]*[-*+]\s+\[[ xX]\]\s+/.test(i)){const c=Cl(t,r);r=c.next,o.push(`<ul class="${K}">${c.html}</ul>`);continue}if(/^[\s]*[-*+]\s+/.test(i)){const c=Jt(t,r,/^[\s]*[-*+]\s+(.*)$/);r=c.next,o.push(`<ul>${c.html}</ul>`);continue}if(/^[\s]*\d+\.\s+/.test(i)){const c=Jt(t,r,/^[\s]*\d+\.\s+(.*)$/);r=c.next,o.push(`<ol>${c.html}</ol>`);continue}const a=[];for(;r<t.length&&(t[r]??"").trim()!==""&&!wl(t[r]??"",t[r+1]??"");)a.push(t[r]??""),r++;a.length>0&&o.push(`<p>${ee(Al(a))}</p>`)}return o.join(`
18
+ `)}function wl(n,e){return/^#{1,6}\s/.test(n)||/^[\s]*[-*+]\s+/.test(n)||/^[\s]*\d+\.\s+/.test(n)||n.startsWith(">")||/^```/.test(n)||/^[\s]*([-*_])(\s*\1){2,}[\s]*$/.test(n)||Qn(n,e)}function Qn(n,e){return n.includes("|")?/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/.test(e):!1}function vl(n){if(n.length<2)return"";const e=Xe(n[0]??""),o=Xe(n[1]??"").map(s=>{const a=s.trim(),c=a.startsWith(":"),u=a.endsWith(":");return c&&u?"center":u?"right":c?"left":null}),r=n.slice(2).map(Xe),i=e.map((s,a)=>{const c=o[a];return`<th${c?` style="text-align:${c}"`:""}>${ee(s.trim())}</th>`}).join(""),l=r.map(s=>`<tr>${s.map((c,u)=>{const d=o[u];return`<td${d?` style="text-align:${d}"`:""}>${ee(c.trim())}</td>`}).join("")}</tr>`).join("");return`<table><thead><tr>${i}</tr></thead><tbody>${l}</tbody></table>`}function Xe(n){return n.trim().replace(/^\|/,"").replace(/\|$/,"").split("|")}function Jt(n,e,t){const o=[];let r=e;for(;r<n.length;){const i=n[r]??"";if(i.trim()===""){const s=n[r+1]??"";if(t.test(s)){r++;continue}break}const l=t.exec(i);if(!l)break;o.push(`<li>${ee(l[1]??"")}</li>`),r++}return{html:o.join(""),next:r}}function Cl(n,e){const t=/^[\s]*[-*+]\s+\[([ xX])\]\s+(.*)$/,o=[];let r=e;for(;r<n.length;){const i=t.exec(n[r]??"");if(!i)break;const s=(i[1]??" ").toLowerCase()==="x"?` ${X}="true"`:"";o.push(`<li${s}>${ee(i[2]??"")}</li>`),r++}return{html:o.join(""),next:r}}function Al(n){const e=[];for(let t=0;t<n.length;t++){const o=n[t]??"",r=t===n.length-1;!r&&/ +$/.test(o)?e.push(o.replace(/\s+$/,"")+`
22
19
  <br>
23
- `):e.push(l?o:o+" ")}return e.join("")}const Ae="",Ml=new RegExp(Ae+"([0-9]+)"+Ae,"g");function X(t){const e=[];let n=t.replace(/(`+)([\s\S]+?)\1/g,(o,l,i)=>{const r=e.push(`<code>${ke(i)}</code>`)-1;return`${Ae}${r}${Ae}`});return n=ke(n),n=n.replace(/&lt;(https?:\/\/[^\s&]+)&gt;/g,(o,l)=>`<a${At(l)} target="_blank" rel="noopener">${ke(l)}</a>`),n=n.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,l,i)=>`<img${Nl(i)} alt="${Me(l)}">`),n=n.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,l,i)=>`<a${At(i)} target="_blank" rel="noopener">${l}</a>`),n=n.replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/__([^_\n]+?)__/g,"<strong>$1</strong>"),n=n.replace(/(^|[^*])\*([^*\n]+?)\*(?!\*)/g,"$1<em>$2</em>"),n=n.replace(/(^|[^_])_([^_\n]+?)_(?!_)/g,"$1<em>$2</em>"),n=n.replace(/~~([^~\n]+?)~~/g,"<s>$1</s>"),n=n.replace(Ml,(o,l)=>{const i=Number(l);return e[i]??""}),n}function At(t){const e=K(t);return e?` href="${Me(e)}"`:""}function Nl(t){const e=I(t);return e?` src="${Me(e)}"`:""}function ke(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Me(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}const _e={bulletList:"bulletList",orderedList:"orderedList",blockquote:"blockquote",codeBlock:"codeBlock"},Oe="application/x-aeriz-block",Tt=80;class Il{constructor(e){b(this,"root");b(this,"content");b(this,"toolbar",null);b(this,"contentWrap");b(this,"handlesLayer");b(this,"dropIndicator");b(this,"handles",new Map);b(this,"blockLabelPill");b(this,"pillGlyphEl");b(this,"pillTextEl");b(this,"statusBar");b(this,"undoBtn");b(this,"redoBtn");b(this,"statusBlockEl");b(this,"statusBlocksEl");b(this,"statusCharsEl");b(this,"statusSourceEl");b(this,"options");b(this,"observer");b(this,"blockIds",new Qe);b(this,"idFor",e=>this.blockIds.ensure(e));b(this,"listeners",new Set);b(this,"handleSelectionChange",()=>this.queueSync());b(this,"handleResize",()=>this.repositionHandles());b(this,"handleDocumentMouseUp",()=>this.handleCellSelEnd());b(this,"state",Dl());b(this,"destroyed",!1);b(this,"syncQueued",!1);b(this,"lastSerialized","");b(this,"hoveredBlockId",null);b(this,"hoverRaf",null);b(this,"pillBlockId",null);b(this,"history");b(this,"applyingHistory",!1);b(this,"pendingChangeKind","typing");b(this,"recentCustomColors",[]);b(this,"cellSelStart",null);b(this,"cellSelDrag",!1);b(this,"codeHighlightTimer",null);b(this,"tableResize",null);b(this,"handleHoverMove",e=>{if(this.hoverRaf!==null)return;const{clientY:n}=e;this.hoverRaf=window.requestAnimationFrame(()=>{this.hoverRaf=null,!this.destroyed&&this.setHoveredBlock(this.blockIdAtViewportY(n))})});b(this,"handleHoverLeave",()=>{this.setHoveredBlock(null)});if(!(e.element instanceof HTMLElement))throw new TypeError("AerizEditor: options.element must be an HTMLElement");if(this.options=e,e.locale&&zt(e.locale),this.root=document.createElement("div"),this.root.className="aeriz-wysiwyg",e.theme&&(this.root.dataset.theme=e.theme),e.toolbar!==!1){const l=e.toolbar??Nt;this.toolbar=new Tn(l,{onAction:(i,r)=>this.handleToolbarAction(i,r)}),this.root.appendChild(this.toolbar.element)}this.contentWrap=document.createElement("div"),this.contentWrap.className="aw-content-wrap",this.content=document.createElement("div"),this.content.className="aw-content",this.content.contentEditable="true",this.content.setAttribute("role","textbox"),this.content.setAttribute("aria-multiline","true"),e.placeholder&&(this.content.dataset.placeholder=e.placeholder),this.content.style.setProperty("--aw-empty-hint",JSON.stringify(p().content.emptyHint)),this.content.style.setProperty("--aw-caption-hint",JSON.stringify(p().image.captionPlaceholder)),this.content.innerHTML=e.initialHTML??"<p><br></p>",ye(this.content),ae(this.content,this.blockIds),this.rehighlightAllCodeBlocks(),this.lastSerialized=this.content.innerHTML,this.history=new fl({html:this.lastSerialized,selection:null}),this.contentWrap.appendChild(this.content),this.handlesLayer=document.createElement("div"),this.handlesLayer.className="aw-block-handles",this.contentWrap.appendChild(this.handlesLayer),this.dropIndicator=document.createElement("div"),this.dropIndicator.className="aw-block-drop-indicator",this.dropIndicator.style.display="none",this.contentWrap.appendChild(this.dropIndicator),this.blockLabelPill=document.createElement("button"),this.blockLabelPill.type="button",this.blockLabelPill.className="aw-block-label-pill",this.blockLabelPill.style.display="none",this.blockLabelPill.title=p().toolbar.blockTypeChangeTooltip,this.pillGlyphEl=document.createElement("span"),this.pillGlyphEl.className="aw-pill-glyph",this.pillGlyphEl.setAttribute("aria-hidden","true"),this.pillTextEl=document.createElement("span"),this.pillTextEl.className="aw-pill-text",this.blockLabelPill.appendChild(this.pillGlyphEl),this.blockLabelPill.appendChild(this.pillTextEl),this.blockLabelPill.addEventListener("mousedown",l=>l.preventDefault()),this.blockLabelPill.addEventListener("click",l=>{l.stopPropagation();const i=this.state.activeBlockId??void 0;this.openBlockTypeMenu(this.blockLabelPill,i)}),this.contentWrap.appendChild(this.blockLabelPill),this.root.appendChild(this.contentWrap),this.statusBar=document.createElement("div"),this.statusBar.className="aw-status-bar";const n=document.createElement("div");n.className="aw-status-left",this.undoBtn=St(`${p().toolbar.undo} (Ctrl+Z)`,A.undo,()=>{this.undo()}),this.redoBtn=St(`${p().toolbar.redo} (Ctrl+Y)`,A.redo,()=>{this.redo()}),this.statusBlockEl=document.createElement("span"),this.statusBlockEl.className="aw-status-item",n.appendChild(this.undoBtn),n.appendChild(this.redoBtn),n.appendChild(this.statusBlockEl);const o=document.createElement("div");o.className="aw-status-right",this.statusBlocksEl=document.createElement("span"),this.statusBlocksEl.className="aw-status-item",this.statusCharsEl=document.createElement("span"),this.statusCharsEl.className="aw-status-item",this.statusSourceEl=document.createElement("span"),this.statusSourceEl.className="aw-status-item",o.appendChild(this.statusBlocksEl),o.appendChild(this.statusCharsEl),o.appendChild(this.statusSourceEl),this.statusBar.appendChild(n),this.statusBar.appendChild(o),this.root.appendChild(this.statusBar),e.element.innerHTML="",e.element.appendChild(this.root),this.observer=new MutationObserver(()=>this.flush()),this.observer.observe(this.content,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),this.content.addEventListener("keyup",this.handleSelectionChange),this.content.addEventListener("mouseup",this.handleSelectionChange),this.content.addEventListener("focus",this.handleSelectionChange),this.content.addEventListener("blur",()=>{this.handleSelectionChange(),this.rehighlightAllCodeBlocks()}),this.content.addEventListener("keydown",l=>this.handleKeyDown(l)),document.addEventListener("selectionchange",this.handleSelectionChange),this.content.addEventListener("mousemove",l=>this.handleTableCursor(l)),this.content.addEventListener("mousedown",l=>this.handleTableResizeStart(l)),this.content.addEventListener("click",l=>this.handleBlockAlignClick(l)),this.content.addEventListener("mousedown",l=>this.handleTaskToggle(l)),this.content.addEventListener("mousedown",l=>this.handleCellSelStart(l)),this.content.addEventListener("mousemove",l=>this.handleCellSelMove(l)),document.addEventListener("mouseup",this.handleDocumentMouseUp),this.content.addEventListener("input",()=>this.scheduleCodeHighlight()),this.content.addEventListener("input",l=>this.handleInputRule(l)),this.content.addEventListener("dragstart",l=>{const i=l.target;i&&(i.closest(".aw-block-handle")||i.closest("table")&&l.preventDefault())}),this.contentWrap.addEventListener("mousemove",this.handleHoverMove),this.contentWrap.addEventListener("mouseleave",this.handleHoverLeave),this.content.addEventListener("dragover",l=>this.handleDragOver(l)),this.content.addEventListener("drop",l=>this.handleDrop(l)),this.content.addEventListener("dragleave",l=>this.handleDragLeave(l)),window.addEventListener("resize",this.handleResize),this.sync()}getHTML(e={}){const n=this.content.cloneNode(!0);if((e.styles??this.options.htmlStyles??"inline")==="class")ot(n);else{const l=tt(this.root),i=this.currentTheme();i&&(l.mode=i),nt(n,l)}return lt(n),Be(n),n.innerHTML}getRawHTML(){return this.content.innerHTML}setHTML(e){this.content.innerHTML=e,this.rehighlightAllCodeBlocks(),this.flush(),this.history.reset({html:this.lastSerialized,selection:null})}focus(){this.content.focus()}setTheme(e){this.root.dataset.theme=e}getState(){return this.state}getBlocks(){return Le(this.content,this.idFor)}serialize(){return et(this.getBlocks())}findBlockById(e){const n=this.content.querySelector(`[data-block-id="${e}"]`);return n?xe(n,this.content,this.idFor):null}getActiveBlock(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0).commonAncestorContainer;return this.content.contains(n)?xe(n,this.content,this.idFor):null}setBlockType(e,n,o){const l=U[e];if(!l)return;this.markStructuralChange();const i=o?this.findBlockById(o):this.getActiveBlock(),r=i?this.replaceBlock(i,l,n):this.appendBlock(l,n);this.flush(),this.content.focus(),M(r),this.flashBlock(r)}replaceBlock(e,n,o){const l=rn(e),i=n.create(o);return sn(i,n.kind,l),e.element.replaceWith(i),i}appendBlock(e,n){const o=e.create(n);return this.content.appendChild(o),o}onStateChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.destroyed||(this.destroyed=!0,this.observer.disconnect(),document.removeEventListener("selectionchange",this.handleSelectionChange),document.removeEventListener("mouseup",this.handleDocumentMouseUp),window.removeEventListener("resize",this.handleResize),this.hoverRaf!==null&&(window.cancelAnimationFrame(this.hoverRaf),this.hoverRaf=null),this.codeHighlightTimer!==null&&(window.clearTimeout(this.codeHighlightTimer),this.codeHighlightTimer=null),this.handles.clear(),this.listeners.clear(),this.root.remove())}flush(){var n,o;if(this.destroyed)return;ye(this.content),ae(this.content,this.blockIds),this.observer.takeRecords();const e=this.content.innerHTML;e!==this.lastSerialized&&(this.lastSerialized=e,this.recordHistory(),(o=(n=this.options).onChange)==null||o.call(n,this.getHTML())),this.queueSync()}recordHistory(){this.applyingHistory||(this.history.record({html:this.lastSerialized,selection:dn(this.content)},this.pendingChangeKind,Date.now()),this.pendingChangeKind="typing")}flashBlock(e){e.setAttribute("data-block-flash",""),this.observer.takeRecords();const n=()=>{e.removeAttribute("data-block-flash"),this.observer.takeRecords()};e.addEventListener("animationend",n,{once:!0}),window.setTimeout(n,700)}markStructuralChange(){this.pendingChangeKind="structural"}undo(){this.applyHistoryEntry(this.history.undo())}redo(){this.applyHistoryEntry(this.history.redo())}applyHistoryEntry(e){var n,o;if(e){this.applyingHistory=!0;try{this.content.innerHTML=e.html,ye(this.content),ae(this.content,this.blockIds),this.rehighlightAllCodeBlocks(),this.observer.takeRecords(),this.lastSerialized=this.content.innerHTML,this.content.focus(),e.selection&&un(this.content,e.selection),(o=(n=this.options).onChange)==null||o.call(n,this.getHTML())}finally{this.applyingHistory=!1}this.queueSync()}}handleToolbarAction(e,n){switch(e){case"blockType":{const o=this.state.activeBlockId??void 0;this.openBlockTypeMenu(n,o);break}case"fontFamily":{if(!yt(this.getActiveBlock()))return;const o=this.detectActiveFontId();ho(n,l=>this.applyFontFamily(l.stack),o??void 0);break}case"fontSize":{if(!kt(this.getActiveBlock()))return;const o=this.detectActiveFontSize();bo(n,l=>this.applyFontSize(l.px),o??void 0);break}case"color":{if(!fe(this.getActiveBlock()))return;Re(n,o=>this.handleColorPick(o,"foreColor"),this.recentCustomColors);break}case"backgroundColor":{if(!fe(this.getActiveBlock()))return;Re(n,o=>this.handleColorPick(o,"hiliteColor"),this.recentCustomColors);break}case"align":{if(!ze(this.getActiveBlock()))return;po(n,o=>this.applyAlign(o));break}case"cellBg":{if(!me(this.getActiveBlock()))return;const o=this.getSelectedTableCells();if(o.length===0)return;Re(n,l=>this.applyCellBgToCells(o,l),this.recentCustomColors);break}case"tableMenu":{if(!me(this.getActiveBlock()))return;go(n,o=>this.runTableMenu(o));break}case"codeLang":{const o=this.getActiveBlock();if(!o||o.kind!=="codeBlock")return;const l=o.element.querySelector(":scope > code"),i=(l==null?void 0:l.getAttribute("data-language"))??void 0;fo(n,r=>this.applyCodeLanguage(o.element,r.id),i);break}case"bold":case"italic":case"underline":case"strike":this.applyMark(e);break;case"undo":this.undo();break;case"redo":this.redo();break;case"bulletList":case"orderedList":case"blockquote":case"codeBlock":{const o=_e[e];if(!o)break;const l=this.getActiveBlock();this.setBlockType((l==null?void 0:l.kind)===o?"paragraph":o);break}case"hr":this.setBlockType("hr");break;case"link":this.openLinkDialogAndApply(this.state.activeBlockId??void 0);break;case"image":this.openImageDialogAndApply(this.state.activeBlockId??void 0);break;case"table":{const o=this.state.activeBlockId??void 0;pt(n,l=>{this.setBlockType("table",{rows:l.rows,cols:l.cols},o)});break}case"clearFormat":this.clearInlineFormat();break}}clearInlineFormat(){this.content.focus(),document.execCommand("removeFormat"),this.queueSync()}applyMark(e){const n=this.getActiveBlock();if(!re(n,e))return;this.content.focus(),document.execCommand("styleWithCSS",!1,"true");const o=e==="strike"?"strikeThrough":e;document.execCommand(o),this.queueSync()}handleColorPick(e,n){e&&!je.includes(e)&&(this.recentCustomColors=[e,...this.recentCustomColors.filter(o=>o!==e)].slice(0,8)),this.applyColor(n,e),this.queueSync()}applyColor(e,n){this.content.focus(),document.execCommand("styleWithCSS",!1,"true"),document.execCommand(e,!1,n??"inherit")}applyAlign(e){const n=this.getActiveBlock();if(!n||!ze(n))return;const o=Array.from(this.content.querySelectorAll("td.aw-cell-selected, th.aw-cell-selected"));if(o.length>0){for(const i of o)i.style.textAlign=e;this.clearCellSelection(),this.queueSync();return}let l=n.element;if(n.kind==="blockquote"){const i=Array.from(n.element.querySelectorAll(":scope > p"));if(i.length>0){for(const r of i)r.style.textAlign=e;this.queueSync();return}}else if(n.kind==="table"){const i=this.getActiveTableCell();i&&(l=i)}l.style.textAlign=e,this.queueSync()}getActiveTableCell(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let n=e.getRangeAt(0).startContainer;if(!n||!this.content.contains(n)||(n.nodeType!==Node.ELEMENT_NODE&&(n=n.parentElement),!(n instanceof Element)))return null;const o=n.closest("td, th");return o instanceof HTMLTableCellElement?o:null}getSelectedTableCells(){const e=Array.from(this.content.querySelectorAll("td.aw-cell-selected, th.aw-cell-selected"));if(e.length>0)return e;const n=this.getActiveBlock();if(!n||n.kind!=="table")return[];const o=n.element,l=document.getSelection();if(!l||l.rangeCount===0)return[];const i=l.getRangeAt(0),r=ge(i.startContainer);if(!r||!o.contains(r))return[];if(i.collapsed)return[r];const s=ge(i.endContainer);return!s||!o.contains(s)||s===r?[r]:Fe(o,r,s)}handleCellSelStart(e){if(e.button!==0)return;const n=e.target;if(n!=null&&n.closest(".aw-resize-handle, .aw-block-align-controls, .aw-file-attachment, .aw-link-card"))return;this.clearCellSelection();const o=n==null?void 0:n.closest("td, th");o instanceof HTMLTableCellElement&&this.content.contains(o)&&(this.cellSelStart=o,this.cellSelDrag=!1)}handleCellSelMove(e){if(!this.cellSelStart||!(e.buttons&1))return;const n=e.target,o=n==null?void 0:n.closest("td, th");if(!(o instanceof HTMLTableCellElement)||o===this.cellSelStart&&!this.cellSelDrag)return;const l=o.closest("table");if(!(l instanceof HTMLTableElement))return;const i=Fe(l,this.cellSelStart,o);if(!(i.length<=1)){this.cellSelDrag=!0,this.clearCellSelection();for(const r of i)r.classList.add("aw-cell-selected")}}handleCellSelEnd(){this.cellSelStart=null,this.cellSelDrag=!1}clearCellSelection(){const e=this.content.querySelectorAll(".aw-cell-selected");for(const n of Array.from(e))n.classList.remove("aw-cell-selected")}applyFontSizeToCells(e,n){let o=0;for(const l of e)l.isConnected&&(l.style.fontSize=`${n}px`,o++);o!==0&&(this.clearCellSelection(),this.flush())}applyCellBgToCells(e,n){let o=0;for(const l of e)l.isConnected&&(n?l.style.setProperty("background-color",n,"important"):l.style.removeProperty("background-color"),o++);o!==0&&(n&&!je.includes(n)&&(this.recentCustomColors=[n,...this.recentCustomColors.filter(l=>l!==n)].slice(0,8)),this.clearCellSelection(),this.flush())}runTableMenu(e){switch(this.markStructuralChange(),e){case"rowAbove":this.insertRow("above");break;case"rowBelow":this.insertRow("below");break;case"colLeft":this.insertColumn("left");break;case"colRight":this.insertColumn("right");break;case"deleteRow":this.deleteRow();break;case"deleteCol":this.deleteColumn();break}}insertRow(e){const n=this.getActiveTableCell();if(!n)return;const o=n.closest("tr");if(!o||!o.parentNode)return;const l=o.children.length,i=document.createElement("tr");for(let r=0;r<l;r++){const s=document.createElement("td");s.appendChild(document.createElement("br")),i.appendChild(s)}e==="above"?o.parentNode.insertBefore(i,o):o.parentNode.insertBefore(i,o.nextSibling),this.flush()}insertColumn(e){const n=this.getActiveTableCell();if(!n)return;const o=n.closest("tr");if(!o)return;const l=Array.from(o.children).indexOf(n);if(l<0)return;const i=o.closest("table");if(i){for(const r of Array.from(i.querySelectorAll("tr"))){const s=r.children[l];if(!s)continue;const a=s.tagName.toLowerCase(),c=document.createElement(a);c.appendChild(document.createElement("br")),e==="left"?r.insertBefore(c,s):r.insertBefore(c,s.nextSibling)}this.flush()}}deleteRow(){const e=this.getActiveTableCell();if(!e)return;const n=e.closest("tr");if(!n)return;const o=n.closest("table");o&&(o.querySelectorAll("tr").length<=1||(n.remove(),this.flush()))}scheduleCodeHighlight(){this.codeHighlightTimer!==null&&window.clearTimeout(this.codeHighlightTimer),this.codeHighlightTimer=window.setTimeout(()=>{this.codeHighlightTimer=null;const e=this.getActiveBlock();if((e==null?void 0:e.kind)!=="codeBlock")return;const n=e.element.querySelector(":scope > code");if(!(n instanceof HTMLElement))return;const o=n.getAttribute("data-language");o&&this.rehighlightCode(n,o)},300)}applyCodeLanguage(e,n){const o=e.querySelector(":scope > code");o instanceof HTMLElement&&(n==="plaintext"?o.removeAttribute("data-language"):o.setAttribute("data-language",n),this.rehighlightCode(o,n),this.flush())}rehighlightCode(e,n){const o=e.textContent??"",l=il(e);e.innerHTML=to(o,n),l&&rl(e,l)}rehighlightAllCodeBlocks(){const e=this.content.querySelectorAll(":scope > pre > code");for(const n of Array.from(e)){const o=n.getAttribute("data-language")??void 0;o&&this.rehighlightCode(n,o)}}deleteColumn(){var r;const e=this.getActiveTableCell();if(!e)return;const n=e.closest("tr");if(!n)return;const o=Array.from(n.children).indexOf(e);if(o<0)return;const l=n.closest("table");if(!l)return;const i=l.querySelector("tr");if(!(i&&i.children.length<=1)){for(const s of Array.from(l.querySelectorAll("tr")))(r=s.children[o])==null||r.remove();this.flush()}}handleTableCursor(e){var l,i;if(this.tableResize)return;const n=(i=(l=e.target)==null?void 0:l.closest)==null?void 0:i.call(l,"td, th");if(!(n instanceof HTMLTableCellElement)){this.content.style.cursor="";return}const o=Lt(n,e.clientX,e.clientY);this.content.style.cursor=o==="right"?"col-resize":o==="bottom"?"row-resize":""}handleTableResizeStart(e){var a;if(e.button!==0)return;const n=e.target,o=n==null?void 0:n.closest(".aw-resize-handle");if(o instanceof HTMLElement){const c=o.parentElement;if(c instanceof HTMLElement&&(c.tagName==="FIGURE"||c.tagName==="DIV"&&c.classList.contains("aw-youtube-embed"))){e.preventDefault(),e.stopPropagation(),this.startBlockResize(c,e.clientX);return}}const l=(a=n==null?void 0:n.closest)==null?void 0:a.call(n,"td, th");if(!(l instanceof HTMLTableCellElement))return;const i=Lt(l,e.clientX,e.clientY);if(!i)return;if(e.preventDefault(),e.stopPropagation(),i==="right"){const c=l.closest("tr"),d=c?Array.from(c.children).indexOf(l):-1,u=l.closest("table");if(!u||d<0)return;const h=[];for(const m of Array.from(u.querySelectorAll("tr"))){const f=m.children[d];f instanceof HTMLTableCellElement&&h.push(f)}this.tableResize={kind:"col",startX:e.clientX,startY:e.clientY,initialSize:l.getBoundingClientRect().width,targetCells:h,targetRow:null},document.body.style.cursor="col-resize"}else{const c=l.closest("tr");if(!(c instanceof HTMLTableRowElement))return;this.tableResize={kind:"row",startX:e.clientX,startY:e.clientY,initialSize:c.getBoundingClientRect().height,targetCells:[],targetRow:c},document.body.style.cursor="row-resize"}const r=c=>this.handleTableResizeMove(c),s=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s),document.body.style.cursor="",this.tableResize=null,this.flush()};document.addEventListener("mousemove",r),document.addEventListener("mouseup",s)}handleTableResizeMove(e){const n=this.tableResize;if(n){if(n.kind==="col"){const o=e.clientX-n.startX,l=Math.max(40,n.initialSize+o),i=`${Math.round(l)}px`;for(const r of n.targetCells)r.style.width=i}else if(n.targetRow){const o=e.clientY-n.startY,l=Math.max(20,n.initialSize+o);n.targetRow.style.height=`${Math.round(l)}px`}}}handleTaskToggle(e){var c;if(e.button!==0)return;const n=e.target,o=(c=n==null?void 0:n.closest)==null?void 0:c.call(n,"li");if(!(o instanceof HTMLLIElement))return;const l=o.parentElement;if(!l||!l.classList.contains(q))return;const i=o.getBoundingClientRect(),r=getComputedStyle(o),s=i.left+(Number.parseFloat(r.paddingLeft)||0);if(e.clientX>s)return;e.preventDefault(),e.stopPropagation(),this.markStructuralChange(),o.getAttribute(G)==="true"?o.removeAttribute(G):o.setAttribute(G,"true"),this.flush()}focusImageCaption(e){if(!(e instanceof HTMLElement))return;let n=e.querySelector(":scope > figcaption");const o=!n;if(!n){this.markStructuralChange(),n=document.createElement("figcaption");const l=e.querySelector(":scope > .aw-block-align-controls");l?e.insertBefore(n,l):e.appendChild(n)}this.content.focus(),M(n),o?this.flush():this.queueSync()}handleBlockAlignClick(e){var r,s,a,c;const n=(s=(r=e.target)==null?void 0:r.closest)==null?void 0:s.call(r,".aw-block-caption-btn");if(n instanceof HTMLButtonElement){e.preventDefault(),e.stopPropagation(),this.focusImageCaption(n.closest("figure"));return}const o=(c=(a=e.target)==null?void 0:a.closest)==null?void 0:c.call(a,".aw-block-align-btn");if(!(o instanceof HTMLButtonElement))return;const l=o.dataset.align;if(l!=="left"&&l!=="center"&&l!=="right")return;const i=o.closest("figure, div.aw-youtube-embed");i instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),l==="center"?(i.style.marginLeft="auto",i.style.marginRight="auto"):l==="right"?(i.style.marginLeft="auto",i.style.marginRight="0"):(i.style.marginLeft="0",i.style.marginRight="auto"),this.flush())}startBlockResize(e,n){this.markStructuralChange();const o=e.getBoundingClientRect().width,l=this.contentInnerWidth();document.body.style.cursor="nwse-resize",e.classList.add("aw-resizing");const i=s=>{const a=s.clientX-n,c=Math.max(Tt,o+a);e.style.width=`${Math.round(Math.min(c,l))}px`},r=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",r),document.body.style.cursor="",e.classList.remove("aw-resizing"),this.flush()};document.addEventListener("mousemove",i),document.addEventListener("mouseup",r)}contentInnerWidth(){const e=getComputedStyle(this.content),n=this.content.clientWidth-(Number.parseFloat(e.paddingLeft)||0)-(Number.parseFloat(e.paddingRight)||0);return Math.max(Tt,n)}currentTheme(){const e=this.root.dataset.theme;return e==="dark"||e==="light"?e:void 0}applyFontFamily(e){this.content.focus(),document.execCommand("styleWithCSS",!1,"true"),document.execCommand("fontName",!1,e),this.queueSync()}detectActiveFontId(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let n=e.getRangeAt(0).startContainer;if(!n||!this.content.contains(n)||(n.nodeType!==Node.ELEMENT_NODE&&(n=n.parentElement),!(n instanceof Element)))return null;const o=getComputedStyle(n).fontFamily;return On(o)}applyFontSize(e){const n=Array.from(this.content.querySelectorAll("td.aw-cell-selected, th.aw-cell-selected"));if(n.length>0){this.applyFontSizeToCells(n,e);return}const o=document.getSelection();if(o&&o.rangeCount>0&&!o.getRangeAt(0).collapsed){const s=o.getRangeAt(0),a=ge(s.startContainer),c=ge(s.endContainer);if(a&&c&&a!==c&&this.content.contains(a)&&this.content.contains(c)){const d=a.closest("table");if(d instanceof HTMLTableElement){this.applyFontSizeToCells(Fe(d,a,c),e);return}}}this.content.focus();const l=document.getSelection();if(!l||l.rangeCount===0)return;const i=l.getRangeAt(0);if(!this.content.contains(i.commonAncestorContainer))return;const r=document.createElement("span");if(r.style.fontSize=`${e}px`,i.collapsed){r.appendChild(document.createTextNode("​")),i.insertNode(r);const s=document.createRange();s.selectNodeContents(r),s.collapse(!1),l.removeAllRanges(),l.addRange(s)}else{try{i.surroundContents(r)}catch{const a=i.extractContents();r.appendChild(a),i.insertNode(r)}l.removeAllRanges();const s=document.createRange();s.selectNodeContents(r),l.addRange(s)}this.queueSync()}detectActiveFontSize(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let n=e.getRangeAt(0).startContainer;if(!n||!this.content.contains(n)||(n.nodeType!==Node.ELEMENT_NODE&&(n=n.parentElement),!(n instanceof Element)))return null;const o=getComputedStyle(n).fontSize;return Rn(o)}openBlockTypeMenu(e,n){uo(e,o=>{if(o.kind==="linkCard"){this.openLinkDialogAndApply(n);return}if(o.kind==="youtube"){this.openYouTubeDialogAndApply(n);return}if(o.kind==="image"){this.openImageDialogAndApply(n);return}if(o.kind==="table"){pt(e,l=>{this.setBlockType("table",{rows:l.rows,cols:l.cols},n)});return}if(o.kind==="importHtml"){this.openImportHtmlDialogAndApply(n);return}if(o.kind==="importMarkdown"){this.openMarkdownImportDialogAndApply(n);return}if(o.kind==="file"){this.openFileAttachmentDialogAndApply(n);return}this.setBlockType(o.kind,o.attrs,n)})}openLinkDialogAndApply(e){Sn({},this.currentTheme()).then(n=>{var r;if(!n.confirmed||!n.href)return;const o=n.href,l=((r=n.text)==null?void 0:r.trim())??"",i=l.length>0?l:o;this.setBlockType("linkCard",{href:o,text:i},e)})}openImageDialogAndApply(e){const n=this.resolveImageUploadFn();Bn({...n?{onUpload:n}:{}},this.currentTheme()).then(o=>{o.confirmed&&o.src&&this.setBlockType("image",{src:o.src},e),this.queueSync()})}openYouTubeDialogAndApply(e){In(this.currentTheme()).then(n=>{if(!n.confirmed||!n.url)return;const o=Hl(n.url);o&&this.setBlockType("youtube",{videoId:o},e)})}openImportHtmlDialogAndApply(e){$n(this.currentTheme()).then(async n=>{if(!n.confirmed)return;if(!n.html||n.html.length===0){window.alert(p().importHtml.errEmpty);return}let o;try{o=await wl(n.html,{mountTarget:this.content})}catch(s){console.error("HTML import failed:",s);const a=s instanceof Error?s.message:String(s);window.alert(`${p().importHtml.errFailed}${a}`);return}if(o.length===0){window.alert(p().importHtml.errNoBody);return}const l=e?this.content.querySelector(`[data-block-id="${e}"]`):null,i=[];for(const s of o){const a=gl(s.tagName)?s:(()=>{const c=document.createElement("p");return c.appendChild(s),c})();i.push(a)}if(l)if(l.tagName==="P"&&(l.textContent??"").trim().length===0&&i.length>0){const a=i[0];l.replaceWith(a);let c=a;for(let d=1;d<i.length;d++){const u=i[d];c.after(u),c=u}}else{let a=l;for(const c of i)a.after(c),a=c}else for(const s of i)this.content.appendChild(s);this.flush(),this.content.focus();const r=i[i.length-1];r&&M(r)})}openMarkdownImportDialogAndApply(e){Mn(this.currentTheme()).then(n=>{if(!n.confirmed)return;if(!n.markdown||n.markdown.length===0){window.alert(p().importMarkdown.errEmpty);return}let o;try{o=El(n.markdown)}catch(r){console.error("Markdown parse failed:",r);const s=r instanceof Error?r.message:String(r);window.alert(`${p().importMarkdown.errFailed}${s}`);return}if(o.length===0){window.alert(p().importMarkdown.errNoBody);return}const l=e?this.content.querySelector(`[data-block-id="${e}"]`):null;if(l)if(l.tagName==="P"&&(l.textContent??"").trim().length===0&&o.length>0){const s=o[0];l.replaceWith(s);let a=s;for(let c=1;c<o.length;c++){const d=o[c];a.after(d),a=d}}else{let s=l;for(const a of o)s.after(a),s=a}else for(const r of o)this.content.appendChild(r);this.flush(),this.content.focus();const i=o[o.length-1];i&&M(i)})}openFileAttachmentDialogAndApply(e){const n=this.resolveFileUploadFn();Nn({...n?{onUpload:n}:{}},this.currentTheme()).then(o=>{if(!o.confirmed)return;if(!o.src||o.src.length===0){window.alert(p().fileAttach.errEmpty);return}const l={fileSrc:o.src},i=o.name&&o.name.length>0?o.name:Rl(o.src);i&&(l.fileName=i),o.size!==void 0&&(l.fileSize=o.size),o.type&&(l.fileType=o.type),this.setBlockType("file",l,e)})}resolveFileUploadFn(){if(this.options.onFileUpload)return this.options.onFileUpload;const e=this.options.fileUploadUrl;if(e)return async n=>{const o=new FormData;o.append("file",n);const l=await fetch(e,{method:"POST",body:o});if(!l.ok)throw new Error(`파일 업로드 실패: ${l.status}`);const i=await l.json(),r=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof r!="string"||r.length===0)throw new Error("파일 업로드 응답에 url 필드가 없습니다.");return r}}resolveImageUploadFn(){if(this.options.onImageUpload)return this.options.onImageUpload;const e=this.options.imageUploadUrl;if(e)return async n=>{const o=new FormData;o.append("file",n);const l=await fetch(e,{method:"POST",body:o});if(!l.ok)throw new Error(`이미지 업로드 실패: ${l.status}`);const i=await l.json(),r=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof r!="string"||r.length===0)throw new Error("이미지 업로드 응답에 url 필드가 없습니다.");return r}}queueSync(){this.syncQueued||this.destroyed||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,!this.destroyed&&this.sync()}))}sync(){const e=Le(this.content,this.idFor),n=this.getActiveBlock(),l=n!==null?{bold:be("bold"),italic:be("italic"),underline:be("underline"),strike:be("strikeThrough")}:{bold:!1,italic:!1,underline:!1,strike:!1};this.state={blocks:e,activeBlockId:(n==null?void 0:n.id)??null,inline:l},this.syncBlockMarkers((n==null?void 0:n.id)??null),this.syncBlockHandles(e),this.syncBlockLabelPill(n),this.syncStatusBar(n,e),this.syncHistoryButtons(),this.applyToolbarState(this.state,n);for(const i of this.listeners)i(this.state)}handleKeyDown(e){if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.isComposing){const l=e.key.toLowerCase();let i=null;if(!e.shiftKey&&l==="b"?i="bold":!e.shiftKey&&l==="i"?i="italic":!e.shiftKey&&l==="u"?i="underline":e.shiftKey&&l==="x"&&(i="strike"),i){e.preventDefault(),this.applyMark(i);return}}if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.isComposing){const l=e.key.toLowerCase();if(l==="z"){e.preventDefault(),e.shiftKey?this.redo():this.undo();return}if(l==="y"&&!e.shiftKey){e.preventDefault(),this.redo();return}}if(this.handleBlockShortcut(e)||e.key==="Tab"&&!e.isComposing&&this.handleTabKey(e)||e.key==="Backspace"&&!e.isComposing&&this.handleBackspaceKey(e)||e.key!=="Enter"||e.shiftKey||e.isComposing)return;const n=document.getSelection();if(!n||n.rangeCount===0||!n.isCollapsed)return;const o=this.getActiveBlock();if(o){if(o.kind==="blockquote"||o.kind==="codeBlock"){this.exitBlockOnEnter(e,o.element);return}o.kind==="heading"&&sl(o.element)&&this.exitBlockOnEnter(e,o.element)}}handleInputRule(e){if(e.isComposing)return;const n=this.getActiveBlock();if(!n)return;if(n.kind==="bulletList"){this.applyTaskItemRule(n);return}if(n.kind!=="paragraph")return;const o=Ct(n.element);if(!o)return;const l=ol(o.text);l&&(o.range.deleteContents(),this.setBlockType(l.kind,l.attrs))}applyTaskItemRule(e){var s;const n=document.getSelection(),o=n==null?void 0:n.anchorNode;if(!o)return;const l=(s=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)==null?void 0:s.closest("li");if(!l||l.parentElement!==e.element)return;const i=Ct(l);if(!i)return;const r=ll(i.text);r&&(this.markStructuralChange(),i.range.deleteContents(),z(l)&&!l.querySelector("br")&&l.appendChild(document.createElement("br")),e.element.classList.add(q),r.checked&&l.setAttribute(G,"true"),this.flush(),this.content.focus(),M(l))}handleBlockShortcut(e){if(e.isComposing||!(e.metaKey||e.ctrlKey))return!1;if(e.shiftKey&&!e.altKey){const l=e.key.toLowerCase();return l==="arrowup"||l==="arrowdown"?(e.preventDefault(),this.moveActiveBlock(l==="arrowup"?"up":"down"),!0):l==="d"?(e.preventDefault(),this.deleteActiveBlock(),!0):!1}if(!e.altKey)return!1;const o=nl[e.key.toLowerCase()];return o?(e.preventDefault(),this.setBlockType(o.kind,o.attrs),!0):!1}moveActiveBlock(e){const n=this.getActiveBlock();if(!n)return;const o=n.element,l=e==="up"?o.previousElementSibling:o.nextElementSibling;l&&(this.markStructuralChange(),e==="up"?l.before(o):l.after(o),this.flush(),this.content.focus(),M(o),this.flashBlock(o),typeof o.scrollIntoView=="function"&&o.scrollIntoView({block:"nearest"}))}deleteActiveBlock(){const e=this.getActiveBlock();if(!e)return;const n=e.element,o=n.nextElementSibling??n.previousElementSibling;this.markStructuralChange(),n.remove(),this.flush(),this.content.focus();const l=o instanceof HTMLElement?o:this.content.firstElementChild;l instanceof HTMLElement&&M(l)}handleTabKey(e){const n=this.getActiveBlock();if(!n)return!1;if(n.kind==="table"){const o=this.getActiveTableCell();if(!o)return!1;e.preventDefault();const l=e.shiftKey?cl(o):al(o,n.element);return l&&M(l),this.flush(),!0}return n.kind==="bulletList"||n.kind==="orderedList"?(e.preventDefault(),this.content.focus(),document.execCommand(e.shiftKey?"outdent":"indent"),this.queueSync(),!0):!1}handleBackspaceKey(e){const n=document.getSelection();if(!n||n.rangeCount===0||!n.isCollapsed)return!1;const o=this.getActiveBlock();if(!o||o.kind==="paragraph")return!1;const l=U[o.kind];if(!l||!l.allowsInlineFormat||!l.isEmpty(o.element))return!1;e.preventDefault();const i=document.createElement("p");return i.appendChild(document.createElement("br")),o.element.replaceWith(i),this.flush(),this.content.focus(),M(i),!0}exitBlockOnEnter(e,n){e.preventDefault(),this.markStructuralChange();const o=document.createElement("p");o.appendChild(document.createElement("br")),n.insertAdjacentElement("afterend",o),M(o),this.flush()}syncBlockHandles(e){const n=new Set;for(const o of e){n.add(o.id);let l=this.handles.get(o.id);l||(l=this.createBlockHandle(o.id),this.handlesLayer.appendChild(l),this.handles.set(o.id,l)),this.positionHandle(l,o.element)}for(const[o,l]of this.handles)n.has(o)||(l.remove(),this.handles.delete(o));this.syncHandleVisibility()}syncHandleVisibility(){const e=this.state.activeBlockId;for(const[n,o]of this.handles)o.classList.toggle("is-hovered",n===this.hoveredBlockId),o.classList.toggle("is-active",n===e)}setHoveredBlock(e){this.hoveredBlockId!==e&&(this.hoveredBlockId=e,this.syncHandleVisibility())}blockIdAtViewportY(e){let n=null;for(const o of this.state.blocks){const l=o.element.getBoundingClientRect();if(e>=l.top&&e<=l.bottom)return o.id;const i=e<l.top?l.top-e:e-l.bottom;(!n||i<n.distance)&&(n={id:o.id,distance:i})}return n&&n.distance<=24?n.id:null}repositionHandles(){if(this.destroyed)return;for(const o of this.state.blocks){const l=this.handles.get(o.id);l&&this.positionHandle(l,o.element)}const e=this.state.activeBlockId,n=e?this.state.blocks.find(o=>o.id===e):null;this.syncBlockLabelPill(n??null)}positionHandle(e,n){const o=n.getBoundingClientRect(),l=this.contentWrap.getBoundingClientRect(),i=18,r=o.height<i?(o.height-i)/2:0,s=o.top-l.top+this.contentWrap.scrollTop+r;e.style.top=`${s}px`}createBlockHandle(e){const n=document.createElement("div");n.className="aw-block-controls",n.dataset.blockId=e;const o=document.createElement("div");o.className="aw-block-handle",o.draggable=!0,o.setAttribute("role","button"),o.setAttribute("aria-label",p().toolbar.blockMoveTooltip),o.title=p().toolbar.blockMoveTooltip,o.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="6" cy="3" r="1.4"/><circle cx="10" cy="3" r="1.4"/><circle cx="6" cy="8" r="1.4"/><circle cx="10" cy="8" r="1.4"/><circle cx="6" cy="13" r="1.4"/><circle cx="10" cy="13" r="1.4"/></svg>',o.addEventListener("dragstart",i=>{if(!i.dataTransfer)return;i.dataTransfer.setData(Oe,e),i.dataTransfer.setData("text/plain",e),i.dataTransfer.effectAllowed="move",o.classList.add("is-dragging");const r=this.content.querySelector(`[data-block-id="${e}"]`);if(r){r.classList.add("is-block-dragging");try{i.dataTransfer.setDragImage(r,12,12)}catch{}}}),o.addEventListener("dragend",()=>{o.classList.remove("is-dragging");const i=this.content.querySelector(`[data-block-id="${e}"]`);i&&i.classList.remove("is-block-dragging"),this.hideDropIndicator()});const l=document.createElement("button");return l.type="button",l.className="aw-block-add",l.title=p().toolbar.addBelowTooltip,l.setAttribute("aria-label",p().toolbar.addBelowTooltip),l.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="8" y1="3" x2="8" y2="13"/><line x1="3" y1="8" x2="13" y2="8"/></svg>',l.addEventListener("mousedown",i=>i.preventDefault()),l.addEventListener("click",i=>{i.stopPropagation(),this.insertParagraphAfter(e)}),n.appendChild(o),n.appendChild(l),n}insertParagraphAfter(e){const n=this.content.querySelector(`[data-block-id="${e}"]`);if(!n)return;this.markStructuralChange();const o=document.createElement("p");o.appendChild(document.createElement("br")),n.insertAdjacentElement("afterend",o),this.flush(),this.content.focus(),M(o)}handleDragOver(e){if(!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(Oe))return;e.preventDefault(),e.dataTransfer.dropEffect="move";const n=this.findDropTarget(e.clientY);n&&this.showDropIndicator(n)}handleDrop(e){if(!e.dataTransfer)return;const n=e.dataTransfer.getData(Oe);if(!n)return;e.preventDefault();const o=this.findDropTarget(e.clientY);if(this.hideDropIndicator(),!o||o.id===n)return;const l=this.content.querySelector(`[data-block-id="${n}"]`),i=this.content.querySelector(`[data-block-id="${o.id}"]`);!l||!i||(this.markStructuralChange(),o.before?this.content.insertBefore(l,i):this.content.insertBefore(l,i.nextSibling))}handleDragLeave(e){this.content.contains(e.relatedTarget)||this.hideDropIndicator()}findDropTarget(e){for(const o of this.state.blocks){const l=o.element.getBoundingClientRect(),i=l.top+l.height/2;if(e<i)return{id:o.id,before:!0}}const n=this.state.blocks[this.state.blocks.length-1];return n?{id:n.id,before:!1}:null}showDropIndicator(e){const n=this.content.querySelector(`[data-block-id="${e.id}"]`);if(!n)return;const o=n.getBoundingClientRect(),l=this.contentWrap.getBoundingClientRect(),i=(e.before?o.top:o.bottom)-l.top+this.contentWrap.scrollTop;this.dropIndicator.style.top=`${i}px`,this.dropIndicator.style.display="block"}hideDropIndicator(){this.dropIndicator.style.display="none"}syncBlockLabelPill(e){if(!e){this.blockLabelPill.style.display="none",this.blockLabelPill.classList.remove("is-entering"),this.pillBlockId=null;return}const{match:n}=_(e.element),o=De(e.element,n),l=tl(n);this.pillGlyphEl.textContent!==l&&(this.pillGlyphEl.textContent=l),this.pillTextEl.textContent!==o&&(this.pillTextEl.textContent=o),this.blockLabelPill.dataset.kind=n.kind,this.blockLabelPill.style.display="inline-flex",this.pillBlockId!==e.id&&(this.pillBlockId=e.id,this.blockLabelPill.classList.remove("is-entering"),this.blockLabelPill.offsetWidth,this.blockLabelPill.classList.add("is-entering"));const i=e.element.getBoundingClientRect(),r=this.contentWrap.getBoundingClientRect(),s=3,a=this.blockLabelPill.offsetHeight||15,c=Math.max(0,i.top-r.top+this.contentWrap.scrollTop-a-s),d=i.left-r.left+4;this.blockLabelPill.style.top=`${c}px`,this.blockLabelPill.style.left=`${d}px`}syncStatusBar(e,n){if(e){const{match:r}=_(e.element);let s=De(e.element,r);if(e.kind==="codeBlock"){const a=e.element.querySelector(":scope > code"),c=a==null?void 0:a.getAttribute("data-language");c&&(s+=` · ${c}`)}this.statusBlockEl.textContent=s}else this.statusBlockEl.textContent=p().status.noActive;this.statusBlocksEl.textContent=se(p().status.blocksCount,{n:n.length});const o=(this.content.textContent??"").replace(Ke,"").replace(/\s+/g,""),l=Array.from(o).length;this.statusCharsEl.textContent=se(p().status.chars,{n:l});const i=this.content.innerHTML.length;this.statusSourceEl.textContent=se(p().status.source,{n:zl(i)})}syncHistoryButtons(){this.undoBtn.disabled=!this.history.canUndo,this.redoBtn.disabled=!this.history.canRedo}syncBlockMarkers(e){for(const n of Array.from(this.content.children)){if(!(n instanceof HTMLElement))continue;const{match:o}=_(n);n.setAttribute("data-block-kind",o.kind),n.setAttribute("data-block-label",De(n,o));const l=this.blockIds.get(n);l&&l===e?n.setAttribute("data-block-focused",""):n.hasAttribute("data-block-focused")&&n.removeAttribute("data-block-focused")}this.observer.takeRecords()}applyToolbarState(e,n){if(this.toolbar){this.toolbar.setActive("bold",e.inline.bold),this.toolbar.setActive("italic",e.inline.italic),this.toolbar.setActive("underline",e.inline.underline),this.toolbar.setActive("strike",e.inline.strike);for(const o of Object.keys(_e)){const l=_e[o];this.toolbar.setActive(o,(n==null?void 0:n.kind)===l)}this.toolbar.setVisible("bold",re(n,"bold")),this.toolbar.setVisible("italic",re(n,"italic")),this.toolbar.setVisible("underline",re(n,"underline")),this.toolbar.setVisible("strike",re(n,"strike")),this.toolbar.setVisible("fontFamily",yt(n)),this.toolbar.setVisible("fontSize",kt(n)),this.toolbar.setVisible("color",fe(n)),this.toolbar.setVisible("backgroundColor",fe(n)),this.toolbar.setVisible("align",ze(n)),this.toolbar.setVisible("cellBg",me(n)),this.toolbar.setVisible("tableMenu",me(n)),this.toolbar.setVisible("codeLang",(n==null?void 0:n.kind)==="codeBlock"),this.toolbar.syncGroupVisibility()}}}function Hl(t){const e=t.trim();if(!e)return null;let n;try{n=new URL(e)}catch{return/^[A-Za-z0-9_-]{11}$/.test(e)?e:null}const o=n.hostname.replace(/^www\./,"");if(o==="youtu.be")return n.pathname.slice(1).split("/")[0]||null;if(o==="youtube.com"||o==="m.youtube.com"||o==="youtube-nocookie.com"){if(n.pathname==="/watch")return n.searchParams.get("v");if(n.pathname.startsWith("/embed/")||n.pathname.startsWith("/shorts/")||n.pathname.startsWith("/v/"))return n.pathname.split("/")[2]??null}return null}function Rl(t){var e;try{const l=new URL(t,"http://localhost").pathname.split("/").filter(Boolean).pop();return l?decodeURIComponent(l):""}catch{return(((e=t.split("?")[0])==null?void 0:e.split("#")[0])??"").split("/").filter(Boolean).pop()??""}}function zl(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:`${t}`}function St(t,e,n){const o=document.createElement("button");return o.type="button",o.className="aw-status-action",o.title=t,o.setAttribute("aria-label",t),o.innerHTML=e,o.addEventListener("mousedown",l=>l.preventDefault()),o.addEventListener("click",n),o}function Dl(){return{blocks:[],activeBlockId:null,inline:{bold:!1,italic:!1,underline:!1,strike:!1}}}function be(t){try{return document.queryCommandState(t)}catch{return!1}}class Fl{constructor(e){b(this,"root");b(this,"content");b(this,"blockIds",new Qe);b(this,"idFor",e=>this.blockIds.ensure(e));b(this,"options");b(this,"destroyed",!1);if(!(e.element instanceof HTMLElement))throw new TypeError("AerizViewer: options.element must be an HTMLElement");this.options=e,this.root=document.createElement("div"),this.root.className="aeriz-wysiwyg aeriz-wysiwyg-viewer",e.theme&&(this.root.dataset.theme=e.theme);const n=document.createElement("div");n.className="aw-content-wrap",this.content=document.createElement("div"),this.content.className="aw-content",this.content.contentEditable="false",this.content.setAttribute("role","document"),n.appendChild(this.content),this.root.appendChild(n),e.element.innerHTML="",e.element.appendChild(this.root),e.initialBlocks&&e.initialBlocks.length>0&&this.setBlocks(e.initialBlocks)}setBlocks(e){ln(this.content,e),ae(this.content,this.blockIds)}getBlocks(){return et(this.listBlocksInternal())}getBlockOf(e){return this.content.contains(e)?xe(e,this.content,this.idFor):null}getHTML(e={}){const n=this.content.cloneNode(!0);if((e.styles??this.options.htmlStyles??"inline")==="class")ot(n);else{const l=tt(this.root),i=this.root.dataset.theme;(i==="light"||i==="dark")&&(l.mode=i),nt(n,l)}return lt(n),Be(n),n.innerHTML}setTheme(e){this.root.dataset.theme=e}destroy(){this.destroyed||(this.destroyed=!0,this.root.remove())}listBlocksInternal(){return Le(this.content,this.idFor)}}const mn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Pl=new Set(["script","style"]),_l=new Map([["li",new Set(["li"])],["p",new Set(["p","div","ul","ol","blockquote","pre","table","h1","h2","h3","h4","h5","h6"])],["td",new Set(["td","th","tr"])],["th",new Set(["td","th","tr"])],["tr",new Set(["tr"])],["option",new Set(["option"])]]),Ol={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",hellip:"…",mdash:"—",ndash:"–",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",middot:"·",bull:"•",copy:"©",reg:"®",trade:"™",deg:"°",plusmn:"±",times:"×",divide:"÷",laquo:"«",raquo:"»"};function V(t){return t.includes("&")?t.replace(/&(#[Xx][0-9A-Fa-f]+|#\d+|[A-Za-z][A-Za-z0-9]{1,31});/g,(e,n)=>{if(n.charCodeAt(0)===35){const l=n[1]==="x"||n[1]==="X",i=l?n.slice(2):n.slice(1),r=Number.parseInt(i,l?16:10);if(!Number.isFinite(r)||r<0||r>1114111||r>=55296&&r<=57343)return e;try{return String.fromCodePoint(r)}catch{return e}}return Ol[n.toLowerCase()]??e}):t}function R(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function x(t){return R(t).replace(/"/g,"&quot;")}function ql(t){const e={},n=/([^\s/=>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;let o;for(;(o=n.exec(t))!==null;){const l=o[1];if(!l)continue;const i=o[2]??o[3]??o[4]??"";e[l.toLowerCase()]=V(i)}return e}function J(t){const e=[],n=[],o=()=>{const s=n[n.length-1];return s?s.children:e},l=s=>{if(s.length===0)return;const a=o(),c=a[a.length-1];c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s})},i=s=>{var a;for(let c=n.length-1;c>=0;c--)if(((a=n[c])==null?void 0:a.tag)===s){n.length=c;return}};let r=0;for(;r<t.length;){const s=t.indexOf("<",r);if(s<0){l(V(t.slice(r)));break}if(s>r&&l(V(t.slice(r,s))),t.startsWith("<!--",s)){const y=t.indexOf("-->",s+4);r=y<0?t.length:y+3;continue}if(t.startsWith("<!",s)||t.startsWith("<?",s)){const y=t.indexOf(">",s+2);r=y<0?t.length:y+1;continue}const a=t.indexOf(">",s+1);if(a<0){l(V(t.slice(s)));break}const c=t.slice(s+1,a);if(r=a+1,c.startsWith("/")){const y=c.slice(1).trim().toLowerCase();y&&i(y);continue}const d=/^([A-Za-z][^\s/>]*)/.exec(c);if(!d||!d[1]){l(V(t.slice(s,r)));continue}const u=d[1].toLowerCase(),h=c.slice(d[1].length),m=/\/\s*$/.test(h),f=ql(m?h.replace(/\/\s*$/,""):h);if(Pl.has(u)){const y=new RegExp(`</${u}\\s*>`,"i"),E=t.slice(r),$=y.exec(E);r=$?r+$.index+$[0].length:t.length;continue}const g=n[n.length-1];if(g){const y=_l.get(g.tag);y!=null&&y.has(u)&&n.pop()}const k={type:"element",tag:u,attrs:f,children:[]};o().push(k),!m&&!mn.has(u)&&n.push(k)}return e}function Ne(t){let e="";for(const n of t){if(n.type==="text"){e+=R(n.value);continue}const o=Object.entries(n.attrs).map(([l,i])=>i===""?` ${l}`:` ${l}="${x(i)}"`).join("");if(mn.has(n.tag)){e+=`<${n.tag}${o}>`;continue}e+=`<${n.tag}${o}>${Ne(n.children)}</${n.tag}>`}return e}function Ie(t){let e="";for(const n of t){if(n.type==="text"){e+=n.value;continue}if(n.tag==="br"){e+=`
24
- `;continue}e+=Ie(n.children)}return e}const Ul=new Set(["address","article","aside","blockquote","div","dd","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"]);function de(t){let e="";for(const n of t){if(n.type==="text"){e+=n.value;continue}if(n.tag==="br"){e+=`
25
- `;continue}const o=Ul.has(n.tag);o&&e!==""&&!e.endsWith(`
20
+ `):e.push(r?o:o+" ")}return e.join("")}const Be="",Ll=new RegExp(Be+"([0-9]+)"+Be,"g"),eo="((?:[^()\\s]|\\([^()\\s]*\\))*)",to='(?:\\s+"[^"]*")?',xl=new RegExp(`!\\[([^\\]]*)\\]\\(${eo}${to}\\)`,"g"),El=new RegExp(`\\[([^\\]]+)\\]\\(${eo}${to}\\)`,"g"),Sl=/<(https?:\/\/[^\s<>]+)>/g;function ee(n){const e=[],t=r=>`${Be}${e.push(r)-1}${Be}`;let o=n.replace(/(`+)([\s\S]+?)\1/g,(r,i,l)=>t(`<code>${xe(l)}</code>`));return o=o.replace(Sl,(r,i)=>t(`<a${Qt(i)} target="_blank" rel="noopener">${xe(i)}</a>`)),o=o.replace(xl,(r,i,l)=>t(`<img${Tl(l)} alt="${De(i)}">`)),o=o.replace(El,(r,i,l)=>`${t(`<a${Qt(l)} target="_blank" rel="noopener">`)}${i}${t("</a>")}`),o=xe(o),o=o.replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>"),o=o.replace(/__([^_\n]+?)__/g,"<strong>$1</strong>"),o=o.replace(/(^|[^*])\*([^*\n]+?)\*(?!\*)/g,"$1<em>$2</em>"),o=o.replace(/(^|[^_])_([^_\n]+?)_(?!_)/g,"$1<em>$2</em>"),o=o.replace(/~~([^~\n]+?)~~/g,"<s>$1</s>"),o.replace(Ll,(r,i)=>e[Number(i)]??"")}function Qt(n){const e=te(n);return e?` href="${De(e)}"`:""}function Tl(n){const e=I(n);return e?` src="${De(e)}"`:""}function xe(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function De(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const en={strike:"strikeThrough"};function no(){return Object.fromEntries(R.map(n=>[n,!1]))}const Ze={bulletList:"bulletList",orderedList:"orderedList",blockquote:"blockquote",codeBlock:"codeBlock"},Je="application/x-aeriz-block",tn=80,He=class He{constructor(e){b(this,"root");b(this,"content");b(this,"toolbar",null);b(this,"contentWrap");b(this,"handlesLayer");b(this,"dropIndicator");b(this,"handles",new Map);b(this,"blockLabelPill");b(this,"pillGlyphEl");b(this,"pillTextEl");b(this,"statusBar");b(this,"undoBtn");b(this,"redoBtn");b(this,"statusBlockEl");b(this,"statusBlocksEl");b(this,"statusCharsEl");b(this,"options");b(this,"observer");b(this,"blockIds",new yt);b(this,"idFor",e=>this.blockIds.ensure(e));b(this,"listeners",new Set);b(this,"handleSelectionChange",()=>this.queueSync());b(this,"handleDocumentSelectionChange",()=>{const e=document.getSelection(),t=!!e&&e.rangeCount>0&&this.content.contains(e.anchorNode);!t&&!this.selectionInside||(this.selectionInside=t,this.queueSync())});b(this,"selectionInside",!1);b(this,"handleResize",()=>this.repositionHandles());b(this,"handleDocumentMouseUp",()=>this.handleCellSelEnd());b(this,"state",Ml());b(this,"destroyed",!1);b(this,"syncQueued",!1);b(this,"tracker");b(this,"markerPending",new Set);b(this,"blocksStale",!0);b(this,"cachedBlocks",[]);b(this,"focusedEl",null);b(this,"overlayRaf",null);b(this,"statusTimer",null);b(this,"hoveredBlockId",null);b(this,"hoverRaf",null);b(this,"pillBlockId",null);b(this,"composing",!1);b(this,"history");b(this,"applyingHistory",!1);b(this,"pendingChangeKind","typing");b(this,"recentCustomColors",[]);b(this,"readOnly",!1);b(this,"findPanel",null);b(this,"sourceArea",null);b(this,"sourceStart","");b(this,"fullscreenScroll",null);b(this,"cellSelStart",null);b(this,"cellSelDrag",!1);b(this,"codeHighlightTimer",null);b(this,"tableResize",null);b(this,"inlineCache",null);b(this,"handleHoverMove",e=>{if(this.hoverRaf!==null)return;const{clientY:t}=e;this.hoverRaf=window.requestAnimationFrame(()=>{this.hoverRaf=null,!this.destroyed&&this.setHoveredBlock(this.blockIdAtViewportY(t))})});b(this,"handleHoverLeave",()=>{this.setHoveredBlock(null)});b(this,"plainPasteNext",!1);if(!(e.element instanceof HTMLElement))throw new TypeError("AerizEditor: options.element must be an HTMLElement");if(this.options=e,e.locale&&bo(e.locale),this.root=document.createElement("div"),this.root.className="aeriz-wysiwyg",e.theme&&(this.root.dataset.theme=e.theme),e.height!==void 0&&(this.root.style.height=typeof e.height=="number"?`${e.height}px`:e.height,this.root.style.minHeight="0",this.root.classList.add("aw-fixed-height")),e.toolbar!==!1){const r=e.toolbar??an;this.toolbar=new ko(r,{onAction:(i,l)=>this.handleToolbarAction(i,l),onEscape:()=>this.focus()}),this.root.appendChild(this.toolbar.element)}this.contentWrap=document.createElement("div"),this.contentWrap.className="aw-content-wrap",this.content=document.createElement("div"),this.content.className="aw-content",this.content.contentEditable="true",this.content.setAttribute("role","textbox"),this.content.setAttribute("aria-multiline","true"),this.content.setAttribute("aria-label",e.ariaLabel??m().docTools.editorLabel),e.placeholder&&(this.content.dataset.placeholder=e.placeholder),this.content.style.setProperty("--aw-empty-hint",JSON.stringify(m().content.emptyHint)),this.content.style.setProperty("--aw-caption-hint",JSON.stringify(m().image.captionPlaceholder)),this.content.replaceChildren(Z(e.initialHTML??"<p><br></p>")),G(this.content),V(this.content,this.blockIds),this.rehighlightAllCodeBlocks(),this.tracker=new rl(this.content),this.tracker.reset();for(const r of Array.from(this.content.children))this.markerPending.add(r);this.history=new cl(this.makeHistoryEntry(null)),this.contentWrap.appendChild(this.content),this.handlesLayer=document.createElement("div"),this.handlesLayer.className="aw-block-handles",this.contentWrap.appendChild(this.handlesLayer),this.dropIndicator=document.createElement("div"),this.dropIndicator.className="aw-block-drop-indicator",this.dropIndicator.style.display="none",this.contentWrap.appendChild(this.dropIndicator),this.blockLabelPill=document.createElement("button"),this.blockLabelPill.type="button",this.blockLabelPill.className="aw-block-label-pill",this.blockLabelPill.style.display="none",this.blockLabelPill.title=m().toolbar.blockTypeChangeTooltip,this.pillGlyphEl=document.createElement("span"),this.pillGlyphEl.className="aw-pill-glyph",this.pillGlyphEl.setAttribute("aria-hidden","true"),this.pillTextEl=document.createElement("span"),this.pillTextEl.className="aw-pill-text",this.blockLabelPill.appendChild(this.pillGlyphEl),this.blockLabelPill.appendChild(this.pillTextEl),this.blockLabelPill.addEventListener("mousedown",r=>r.preventDefault()),this.blockLabelPill.addEventListener("click",r=>{r.stopPropagation();const i=this.state.activeBlockId??void 0;this.openBlockTypeMenu(this.blockLabelPill,i)}),this.contentWrap.appendChild(this.blockLabelPill),this.root.appendChild(this.contentWrap),this.statusBar=document.createElement("div"),this.statusBar.className="aw-status-bar";const t=document.createElement("div");t.className="aw-status-left",this.undoBtn=on(`${m().toolbar.undo} (Ctrl+Z)`,x.undo,()=>{this.undo()}),this.redoBtn=on(`${m().toolbar.redo} (Ctrl+Y)`,x.redo,()=>{this.redo()}),this.statusBlockEl=document.createElement("span"),this.statusBlockEl.className="aw-status-item",t.appendChild(this.undoBtn),t.appendChild(this.redoBtn),t.appendChild(this.statusBlockEl);const o=document.createElement("div");o.className="aw-status-right",this.statusBlocksEl=document.createElement("span"),this.statusBlocksEl.className="aw-status-item",this.statusCharsEl=document.createElement("span"),this.statusCharsEl.className="aw-status-item",o.appendChild(this.statusBlocksEl),o.appendChild(this.statusCharsEl),this.statusBar.appendChild(t),this.statusBar.appendChild(o),e.statusBar!==!1&&this.root.appendChild(this.statusBar),e.element.innerHTML="",e.element.appendChild(this.root),this.observer=new MutationObserver(r=>this.flush(r)),this.observer.observe(this.content,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),this.content.addEventListener("mouseup",this.handleSelectionChange),this.content.addEventListener("focus",this.handleSelectionChange),this.content.addEventListener("blur",()=>{this.handleSelectionChange(),this.rehighlightAllCodeBlocks()}),this.content.addEventListener("keydown",r=>this.handleKeyDown(r)),this.content.addEventListener("paste",r=>this.handlePaste(r)),document.addEventListener("selectionchange",this.handleDocumentSelectionChange),this.content.addEventListener("mousemove",r=>this.handleTableCursor(r)),this.content.addEventListener("mousedown",r=>this.handleTableResizeStart(r)),this.content.addEventListener("click",r=>this.handleBlockAlignClick(r)),this.content.addEventListener("mousedown",r=>this.handleTaskToggle(r)),this.content.addEventListener("click",r=>this.handleToggleSummaryClick(r)),this.content.addEventListener("mousedown",r=>this.handleCalloutVariantClick(r)),this.content.addEventListener("mousedown",r=>this.handleCellSelStart(r)),this.content.addEventListener("mousemove",r=>this.handleCellSelMove(r)),document.addEventListener("mouseup",this.handleDocumentMouseUp),this.content.addEventListener("input",()=>this.scheduleCodeHighlight()),this.content.addEventListener("input",r=>this.handleInputRule(r)),this.content.addEventListener("compositionstart",()=>{this.composing=!0}),this.content.addEventListener("compositionend",()=>{this.composing=!1,this.flush(),this.scheduleCodeHighlight()}),this.content.addEventListener("dragstart",r=>{const i=r.target;i&&(i.closest(".aw-block-handle")||i.closest("table")&&r.preventDefault())}),this.contentWrap.addEventListener("mousemove",this.handleHoverMove),this.contentWrap.addEventListener("mouseleave",this.handleHoverLeave),this.content.addEventListener("dragover",r=>this.handleDragOver(r)),this.content.addEventListener("drop",r=>this.handleDrop(r)),this.content.addEventListener("dragleave",r=>this.handleDragLeave(r)),window.addEventListener("resize",this.handleResize),e.readOnly&&this.setReadOnly(!0),this.sync()}getHTML(e={}){const t=this.observer.takeRecords();t.length>0&&(this.tracker.collect(t),queueMicrotask(()=>this.flush()));const o=e.styles??this.options.htmlStyles??"inline";let r=o,i;if(o==="class")i=jn;else{const s=_n(this.root),a=this.currentTheme();a&&(s.mode=a),r+=JSON.stringify(s),i=c=>Un(c,s)}let l="";for(const s of Array.from(this.content.children))l+=this.tracker.output(s,r,a=>{const c=document.createElement("div");return c.appendChild(a.cloneNode(!0)),i(c),Wn(c),wt(c),c.innerHTML});return l}setHTML(e){this.replaceDocument(()=>this.content.replaceChildren(Z(e)))}setBlocks(e){this.replaceDocument(()=>On(this.content,e))}replaceDocument(e){var r,i;this.flush();const t=this.history.current();e(),G(this.content),V(this.content,this.blockIds),this.rehighlightAllCodeBlocks(),this.observer.takeRecords(),this.tracker.reset(),this.blocksStale=!0,this.focusedEl=null;for(const l of Array.from(this.content.children))this.markerPending.add(l);const o=this.makeHistoryEntry(null);this.history.reset(o),Yn(t,o)||(i=(r=this.options).onChange)==null||i.call(r,this.getHTML()),this.queueSync()}focus(){this.content.focus()}setReadOnly(e){if(this.readOnly!==e){if(e&&this.sourceArea&&this.toggleSource(),this.readOnly=e,this.content.contentEditable=e?"false":"true",this.content.setAttribute("aria-readonly",String(e)),this.root.classList.toggle("aw-readonly",e),this.toolbar)for(const t of this.toolbar.names())t!=="print"&&t!=="fullscreen"&&this.toolbar.setEnabled(t,!e);e&&this.clearCellSelection(),this.syncBlockHandles(),this.syncHistoryButtons()}}setTheme(e){this.root.dataset.theme=e}getState(){return this.state}getBlocks(){return kt(this.currentBlocks())}currentBlocks(){if(!this.blocksStale)return this.cachedBlocks;const e=[];for(const t of Array.from(this.content.children))e.push(this.blockOf(t));return this.cachedBlocks=e,this.blocksStale=!1,e}blockOf(e){const{match:t}=this.tracker.classify(e);return{id:this.idFor(e),kind:t.kind,attrs:t.attrs,element:e}}findBlockById(e){const t=this.content.querySelector(`[data-block-id="${e}"]`);if(!t)return null;const o=this.tracker.topLevelOf(t);return o?this.blockOf(o):null}getActiveBlock(){const e=document.getSelection();if(!e||e.rangeCount===0||!this.content.contains(e.anchorNode))return null;const t=e.getRangeAt(0).commonAncestorContainer;if(!this.content.contains(t))return null;const o=this.tracker.topLevelOf(t);return o?this.blockOf(o):null}setBlockType(e,t,o){const r=U[e];if(!r)return;this.markStructuralChange();const i=o?this.findBlockById(o):this.getActiveBlock(),l=i?this.replaceBlock(i,r,t):this.appendBlock(r,t);this.flush(),this.content.focus(),M(l),this.flashBlock(l)}replaceBlock(e,t,o){const r=Di(e),i=t.create(o);return Pi(i,t.kind,r),e.element.replaceWith(i),i}appendBlock(e,t){const o=e.create(t);return this.content.appendChild(o),o}onStateChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.destroyed||(this.destroyed=!0,this.observer.disconnect(),document.removeEventListener("selectionchange",this.handleDocumentSelectionChange),this.overlayRaf!==null&&window.cancelAnimationFrame(this.overlayRaf),this.statusTimer!==null&&window.clearTimeout(this.statusTimer),document.removeEventListener("mouseup",this.handleDocumentMouseUp),window.removeEventListener("resize",this.handleResize),this.hoverRaf!==null&&(window.cancelAnimationFrame(this.hoverRaf),this.hoverRaf=null),this.codeHighlightTimer!==null&&(window.clearTimeout(this.codeHighlightTimer),this.codeHighlightTimer=null),this.handles.clear(),this.listeners.clear(),this.root.remove())}flush(e){var r,i;if(this.destroyed||(e&&this.tracker.collect(e),this.tracker.collect(this.observer.takeRecords()),this.composing))return;if(!this.tracker.pending){this.queueSync();return}G(this.content,{blocks:this.tracker.dirty}),this.tracker.collect(this.observer.takeRecords()),V(this.content,this.blockIds),this.tracker.collect(this.observer.takeRecords());const t=[],o=this.tracker.commit(t);for(const l of t)this.markerPending.add(l);this.blocksStale=!0,o&&(this.recordHistory(),(i=(r=this.options).onChange)==null||i.call(r,this.getHTML())),this.queueSync()}makeHistoryEntry(e){const t=this.tracker.snapshot();let o=0;for(const r of t)o+=r.length;return{blocks:t,size:o,selection:e}}captureDocSelection(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0),o=this.tracker.topLevelOf(t.startContainer),r=this.tracker.topLevelOf(t.endContainer);if(!o||!r)return null;const i=this.content.children,l=a=>Array.prototype.indexOf.call(i,a),s=(a,c,u)=>{const d=document.createRange();d.selectNodeContents(a);try{d.setEnd(c,u)}catch{return 0}return d.toString().length};return{startBlock:l(o),start:s(o,t.startContainer,t.startOffset),endBlock:l(r),end:s(r,t.endContainer,t.endOffset)}}restoreDocSelection(e){const t=this.content.children[e.startBlock],o=this.content.children[e.endBlock];if(!t||!o)return;const r=Ne(t,e.start),i=Ne(o,e.end),l=document.createRange();try{l.setStart(r.node,r.offset),l.setEnd(i.node,i.offset)}catch{return}const s=document.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(l)}recordHistory(){this.applyingHistory||(this.history.record(this.makeHistoryEntry(this.captureDocSelection()),this.pendingChangeKind,Date.now()),this.pendingChangeKind="typing")}flashBlock(e){e.setAttribute("data-block-flash",""),this.absorb();const t=()=>{e.removeAttribute("data-block-flash"),this.absorb()};e.addEventListener("animationend",t,{once:!0}),window.setTimeout(t,700)}markStructuralChange(){this.pendingChangeKind="structural"}undo(){this.applyHistoryEntry(this.history.undo())}redo(){this.applyHistoryEntry(this.history.redo())}applyHistoryEntry(e){var t;if(e){this.flush(),this.applyingHistory=!0;try{const o=this.tracker.snapshot(),r=e.blocks;let i=0;for(;i<o.length&&i<r.length&&o[i]===r[i];)i++;let l=0;for(;l<o.length-i&&l<r.length-i&&o[o.length-1-l]===r[r.length-1-l];)l++;const s=Array.from(this.content.children),a=s[o.length-l]??null;for(let h=i;h<o.length-l;h++)(t=s[h])==null||t.remove();const c=document.createElement("template");c.innerHTML=r.slice(i,r.length-l).join("");const u=Array.from(c.content.children);this.content.insertBefore(document.importNode(c.content,!0),a);const d=Array.from(this.content.children).slice(i,i+u.length);G(this.content,{blocks:d}),V(this.content,this.blockIds);for(const h of d){const f=h.matches("pre")?h.querySelector(":scope > code"):null,p=f==null?void 0:f.getAttribute("data-language");f&&p&&this.rehighlightCode(f,p)}this.content.focus(),e.selection&&this.restoreDocSelection(e.selection),this.flush()}finally{this.applyingHistory=!1}this.queueSync()}}handleToolbarAction(e,t){var o,r,i;if(!(this.readOnly&&e!=="print"&&e!=="fullscreen"))switch(e){case"blockType":{const l=this.state.activeBlockId??void 0;this.openBlockTypeMenu(t,l);break}case"fontFamily":{if(!We(this.getActiveBlock()))return;const l=this.options.fonts??un;zo(t,l,s=>this.applyFontFamily(s.stack),Ro(l,(o=this.computedStyleAtCaret())==null?void 0:o.fontFamily));break}case"fontSize":{if(!Gt(this.getActiveBlock()))return;_o(t,this.options.fontSizes??hn,l=>this.applyFontSize(l),So((r=this.computedStyleAtCaret())==null?void 0:r.fontSize));break}case"color":{if(!ve(this.getActiveBlock()))return;Pe(t,l=>this.handleColorPick(l,"foreColor"),this.recentCustomColors);break}case"backgroundColor":{if(!ve(this.getActiveBlock()))return;Pe(t,l=>this.handleColorPick(l,"hiliteColor"),this.recentCustomColors);break}case"align":{if(!Ke(this.getActiveBlock()))return;Po(t,l=>this.applyAlign(l));break}case"cellBg":{if(!Ge(this.getActiveBlock()))return;const l=this.getSelectedTableCells();if(l.length===0)return;Pe(t,s=>this.applyCellBgToCells(l,s),this.recentCustomColors);break}case"tableMenu":{const l=this.getActiveBlock();if(!l||l.kind!=="table")return;const s=l.element,a=this.getActiveTableCell(),c=this.getSelectedTableCells(),u=new Set;Jr(s,c)||u.add("mergeCells"),(!a||!ti(a))&&u.add("splitCell"),qo(t,d=>this.runTableMenu(d,s,a??c[0]??null,c),u);break}case"codeLang":{const l=this.getActiveBlock();if(!l||l.kind!=="codeBlock")return;const s=l.element.querySelector(":scope > code"),a=(s==null?void 0:s.getAttribute("data-language"))??void 0,c=(i=this.options.highlighter)==null?void 0:i.languages;if(!c)return;Fo(t,c,u=>this.applyCodeLanguage(l.element,u.id),a);break}case"bold":case"italic":case"underline":case"strike":case"superscript":case"subscript":this.applyMark(e);break;case"undo":this.undo();break;case"redo":this.redo();break;case"bulletList":case"orderedList":case"blockquote":case"codeBlock":{const l=Ze[e];if(!l)break;const s=this.getActiveBlock();this.setBlockType((s==null?void 0:s.kind)===l?"paragraph":l);break}case"hr":this.setBlockType("hr");break;case"link":this.openLinkDialogAndApply(this.state.activeBlockId??void 0);break;case"image":this.openImageDialogAndApply(this.state.activeBlockId??void 0);break;case"table":{const l=this.state.activeBlockId??void 0;Tt(t,s=>{this.setBlockType("table",{rows:s.rows,cols:s.cols},l)});break}case"clearFormat":this.clearInlineFormat();break;case"lineHeight":{const l=this.selectedTopBlocks();if(l.length===0)return;Hr(t,s=>this.applyLineHeight(l,s),Dl(l[0]));break}case"letterSpacing":{if(!We(this.getActiveBlock()))return;const l=this.computedStyleAtCaret(),s=l&&l.letterSpacing!=="normal"?Math.round(Number.parseFloat(l.letterSpacing)/Number.parseFloat(l.fontSize)*100):0;Rr(t,a=>this.applyLetterSpacing(a),s);break}case"specialChar":Dr(t,l=>{this.content.focus(),document.execCommand("insertText",!1,l)});break;case"findReplace":this.openFind();break;case"source":this.toggleSource();break;case"print":Fr(this.getHTML(),document.title);break;case"fullscreen":this.toggleFullscreen();break}}selectedTopBlocks(){const e=document.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0),o=this.tracker.topLevelOf(t.startContainer),r=this.tracker.topLevelOf(t.endContainer);if(!o||!r)return[];const i=[];for(let l=o;l&&(i.push(l),l!==r);l=l.nextElementSibling);return i}applyLineHeight(e,t){this.markStructuralChange();for(const o of e)!o.isConnected||o.tagName==="HR"||o.tagName==="FIGURE"||(o.style.lineHeight=t===160&&!o.style.lineHeight?"":`${t}%`);this.flush()}applyLetterSpacing(e){this.wrapSelectionStyle("letterSpacing",e===0?"normal":`${e/100}em`)}openFind(){this.findPanel||(this.findPanel=new zr({content:this.content,beforeChange:()=>this.markStructuralChange(),afterChange:()=>this.flush()}),this.root.insertBefore(this.findPanel.element,this.contentWrap)),this.findPanel.open()}toggleSource(){var o,r,i,l;if(this.sourceArea){const s=this.sourceArea,a=s.value;this.sourceArea=null,s.remove(),this.content.hidden=!1,(o=this.toolbar)==null||o.setAllEnabled(!0,"source"),(r=this.toolbar)==null||r.setActive("source",!1),a!==this.sourceStart&&(this.markStructuralChange(),this.content.replaceChildren(Z(a||"<p><br></p>")),G(this.content),V(this.content,this.blockIds),this.rehighlightAllCodeBlocks(),this.flush()),this.content.focus(),this.syncHistoryButtons();return}this.flush();const e=document.createElement("template");e.innerHTML=this.getHTML(),this.sourceStart=Array.from(e.content.childNodes).map(s=>s instanceof Element?s.outerHTML:s.textContent??"").join(`
21
+ `);const t=document.createElement("textarea");t.className="aw-source",t.spellcheck=!1,t.value=this.sourceStart,t.setAttribute("aria-label",m().docTools.sourceLabel),t.style.minHeight=`${Math.max(240,this.content.offsetHeight)}px`,this.content.hidden=!0,this.contentWrap.appendChild(t),this.sourceArea=t,(i=this.toolbar)==null||i.setAllEnabled(!1,"source"),(l=this.toolbar)==null||l.setActive("source",!0),t.focus()}toggleFullscreen(){var t;const e=!this.root.classList.contains("aw-fullscreen");this.root.classList.toggle("aw-fullscreen",e),(t=this.toolbar)==null||t.setActive("fullscreen",e),e?(this.fullscreenScroll=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"):(document.documentElement.style.overflow=this.fullscreenScroll??"",this.fullscreenScroll=null),this.scheduleOverlays()}clearInlineFormat(){this.content.focus(),document.execCommand("removeFormat"),this.queueSync()}applyMark(e){const t=this.getActiveBlock();if(!Kt(t,e))return;this.content.focus();const o=e==="superscript"||e==="subscript";document.execCommand("styleWithCSS",!1,o?"false":"true"),document.execCommand(en[e]??e),this.invalidateInlineState(),this.queueSync()}handleColorPick(e,t){e&&!nt.includes(e)&&(this.recentCustomColors=[e,...this.recentCustomColors.filter(o=>o!==e)].slice(0,8)),this.applyColor(t,e),this.queueSync()}applyColor(e,t){this.content.focus(),document.execCommand("styleWithCSS",!1,"true"),document.execCommand(e,!1,t??"inherit")}applyAlign(e){const t=this.getActiveBlock();if(!t||!Ke(t))return;const o=Array.from(this.content.querySelectorAll("td.aw-cell-selected, th.aw-cell-selected"));if(o.length>0){for(const i of o)i.style.textAlign=e;this.clearCellSelection(),this.queueSync();return}let r=t.element;if(t.kind==="blockquote"){const i=Array.from(t.element.querySelectorAll(":scope > p"));if(i.length>0){for(const l of i)l.style.textAlign=e;this.queueSync();return}}else if(t.kind==="table"){const i=this.getActiveTableCell();i&&(r=i)}r.style.textAlign=e,this.queueSync()}getActiveTableCell(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).startContainer;if(!t||!this.content.contains(t)||(t.nodeType!==Node.ELEMENT_NODE&&(t=t.parentElement),!(t instanceof Element)))return null;const o=t.closest("td, th");return o instanceof HTMLTableCellElement?o:null}getSelectedTableCells(){const e=Array.from(this.content.querySelectorAll("td.aw-cell-selected, th.aw-cell-selected"));if(e.length>0)return e;const t=this.getActiveBlock();if(!t||t.kind!=="table")return[];const o=t.element,r=document.getSelection();if(!r||r.rangeCount===0)return[];const i=r.getRangeAt(0),l=Ce(i.startContainer);if(!l||!o.contains(l))return[];if(i.collapsed)return[l];const s=Ce(i.endContainer);return!s||!o.contains(s)||s===l?[l]:Ue(o,l,s)}handleCellSelStart(e){if(e.button!==0)return;const t=e.target;if(t!=null&&t.closest(".aw-resize-handle, .aw-block-align-controls, .aw-file-attachment, .aw-link-card"))return;this.clearCellSelection();const o=t==null?void 0:t.closest("td, th");o instanceof HTMLTableCellElement&&this.content.contains(o)&&(this.cellSelStart=o,this.cellSelDrag=!1)}handleCellSelMove(e){if(!this.cellSelStart||!(e.buttons&1))return;const t=e.target,o=t==null?void 0:t.closest("td, th");if(!(o instanceof HTMLTableCellElement)||o===this.cellSelStart&&!this.cellSelDrag)return;const r=o.closest("table");if(!(r instanceof HTMLTableElement))return;const i=Ue(r,this.cellSelStart,o);if(!(i.length<=1)){this.cellSelDrag=!0,this.clearCellSelection();for(const l of i)l.classList.add("aw-cell-selected")}}handleCellSelEnd(){this.cellSelStart=null,this.cellSelDrag=!1}clearCellSelection(){const e=this.content.querySelectorAll(".aw-cell-selected");for(const t of Array.from(e))t.classList.remove("aw-cell-selected")}applyFontSizeToCells(e,t){let o=0;for(const r of e)r.isConnected&&(r.style.fontSize=`${t}pt`,o++);o!==0&&(this.clearCellSelection(),this.flush())}applyCellBgToCells(e,t){let o=0;for(const r of e)r.isConnected&&(t?r.style.setProperty("background-color",t,"important"):r.style.removeProperty("background-color"),o++);o!==0&&(t&&!nt.includes(t)&&(this.recentCustomColors=[t,...this.recentCustomColors.filter(r=>r!==t)].slice(0,8)),this.clearCellSelection(),this.flush())}runTableMenu(e,t,o,r){if(!o||!t.isConnected||!t.contains(o))return;this.markStructuralChange();let i=null;switch(e){case"rowAbove":case"rowBelow":i=Ot(t,o,e==="rowAbove"?"above":"below");break;case"colLeft":case"colRight":Xr(t,o,e==="colLeft"?"left":"right"),i=o;break;case"deleteRow":case"deleteCol":{const l=ri(t,o,e==="deleteRow"?"row":"col");(e==="deleteRow"?Vr(t,o):Zr(t,o))&&(i=l);break}case"mergeCells":i=Qr(t,r);break;case"splitCell":ei(t,o)&&(i=o);break}this.clearCellSelection(),i!=null&&i.isConnected&&M(i),this.flush()}scheduleCodeHighlight(){this.options.highlighter&&(this.codeHighlightTimer!==null&&window.clearTimeout(this.codeHighlightTimer),this.codeHighlightTimer=window.setTimeout(()=>{if(this.codeHighlightTimer=null,this.composing)return;const e=this.getActiveBlock();if((e==null?void 0:e.kind)!=="codeBlock")return;const t=e.element.querySelector(":scope > code");if(!(t instanceof HTMLElement))return;const o=t.getAttribute("data-language");o&&this.rehighlightCode(t,o)},300))}applyCodeLanguage(e,t){const o=e.querySelector(":scope > code");o instanceof HTMLElement&&(t==="plaintext"?o.removeAttribute("data-language"):o.setAttribute("data-language",t),this.rehighlightCode(o,t),this.flush())}rehighlightCode(e,t){const o=nn(e),r=Qi(e);e.innerHTML=this.codeHtml(o,t)||"<br>",r&&el(e,r)}codeHtml(e,t){const o=this.options.highlighter;if(!o||!t)return rn(e);let r;try{r=o.highlight(e,t)}catch{return rn(e)}return zl(r)}rehighlightAllCodeBlocks(){const e=this.content.querySelectorAll(":scope > pre > code");if(!this.options.highlighter){for(const t of Array.from(e))(!t.firstChild||t.querySelector("br"))&&this.rehighlightCode(t,void 0);return}for(const t of Array.from(e)){const o=t.getAttribute("data-language")??void 0;o&&this.rehighlightCode(t,o)}}handleTableCursor(e){var r,i;if(this.tableResize)return;const t=(i=(r=e.target)==null?void 0:r.closest)==null?void 0:i.call(r,"td, th");if(!(t instanceof HTMLTableCellElement)){this.content.style.cursor="";return}const o=Xt(t,e.clientX,e.clientY);this.content.style.cursor=o==="right"?"col-resize":o==="bottom"?"row-resize":""}handleTableResizeStart(e){var a;if(e.button!==0)return;const t=e.target,o=t==null?void 0:t.closest(".aw-resize-handle");if(o instanceof HTMLElement){const c=o.parentElement;if(c instanceof HTMLElement&&(c.tagName==="FIGURE"||c.tagName==="DIV"&&c.classList.contains("aw-youtube-embed"))){e.preventDefault(),e.stopPropagation(),this.startBlockResize(c,e.clientX);return}}const r=(a=t==null?void 0:t.closest)==null?void 0:a.call(t,"td, th");if(!(r instanceof HTMLTableCellElement))return;const i=Xt(r,e.clientX,e.clientY);if(!i)return;if(e.preventDefault(),e.stopPropagation(),i==="right"){const c=r.closest("table");if(!(c instanceof HTMLTableElement))return;const u=ii(c,r);this.tableResize={kind:"col",startX:e.clientX,startY:e.clientY,initialSize:r.getBoundingClientRect().width,targetCells:u,targetRow:null},document.body.style.cursor="col-resize"}else{const c=r.closest("tr");if(!(c instanceof HTMLTableRowElement))return;this.tableResize={kind:"row",startX:e.clientX,startY:e.clientY,initialSize:c.getBoundingClientRect().height,targetCells:[],targetRow:c},document.body.style.cursor="row-resize"}const l=c=>this.handleTableResizeMove(c),s=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s),document.body.style.cursor="",this.tableResize=null,this.flush()};document.addEventListener("mousemove",l),document.addEventListener("mouseup",s)}handleTableResizeMove(e){const t=this.tableResize;if(t){if(t.kind==="col"){const o=e.clientX-t.startX,r=Math.max(40,t.initialSize+o),i=`${Math.round(r)}px`;for(const l of t.targetCells)l.style.width=i}else if(t.targetRow){const o=e.clientY-t.startY,r=Math.max(20,t.initialSize+o);t.targetRow.style.height=`${Math.round(r)}px`}}}handleTaskToggle(e){var c;if(e.button!==0)return;const t=e.target,o=(c=t==null?void 0:t.closest)==null?void 0:c.call(t,"li");if(!(o instanceof HTMLLIElement))return;const r=o.parentElement;if(!r||!r.classList.contains(K))return;const i=o.getBoundingClientRect(),l=getComputedStyle(o),s=i.left+(Number.parseFloat(l.paddingLeft)||0);if(e.clientX>s)return;e.preventDefault(),e.stopPropagation(),this.markStructuralChange(),o.getAttribute(X)==="true"?o.removeAttribute(X):o.setAttribute(X,"true"),this.flush()}handleCalloutVariantClick(e){var c;if(e.button!==0)return;const t=e.target,o=(c=t==null?void 0:t.closest)==null?void 0:c.call(t,`aside.${ce}`);if(!(o instanceof HTMLElement)||!this.content.contains(o))return;const r=o.getBoundingClientRect(),i=getComputedStyle(o),l=r.left+(Number.parseFloat(i.paddingLeft)||0);if(e.clientX>l)return;e.preventDefault();const s=In(o),a=Le[(Le.indexOf(s)+1)%Le.length];a&&(this.markStructuralChange(),Dn(o,a),this.flush())}handleToggleSummaryClick(e){var s;if(e.button!==0)return;const t=e.target,o=(s=t==null?void 0:t.closest)==null?void 0:s.call(t,"summary");if(!(o instanceof HTMLElement)||!this.content.contains(o))return;const r=o.getBoundingClientRect(),i=getComputedStyle(o),l=r.left+(Number.parseFloat(i.paddingLeft)||0);if(e.clientX<=l){this.markStructuralChange();return}e.preventDefault()}focusImageCaption(e){if(!(e instanceof HTMLElement))return;let t=e.querySelector(":scope > figcaption");const o=!t;if(!t){this.markStructuralChange(),t=document.createElement("figcaption");const r=e.querySelector(":scope > .aw-block-align-controls");r?e.insertBefore(t,r):e.appendChild(t)}this.content.focus(),M(t),o?this.flush():this.queueSync()}handleBlockAlignClick(e){var l,s,a,c;const t=(s=(l=e.target)==null?void 0:l.closest)==null?void 0:s.call(l,".aw-block-caption-btn");if(t instanceof HTMLButtonElement){e.preventDefault(),e.stopPropagation(),this.focusImageCaption(t.closest("figure"));return}const o=(c=(a=e.target)==null?void 0:a.closest)==null?void 0:c.call(a,".aw-block-align-btn");if(!(o instanceof HTMLButtonElement))return;const r=o.dataset.align;if(r!=="left"&&r!=="center"&&r!=="right")return;const i=o.closest("figure, div.aw-youtube-embed");i instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),r==="center"?(i.style.marginLeft="auto",i.style.marginRight="auto"):r==="right"?(i.style.marginLeft="auto",i.style.marginRight="0"):(i.style.marginLeft="0",i.style.marginRight="auto"),this.flush())}startBlockResize(e,t){this.markStructuralChange();const o=e.getBoundingClientRect().width,r=this.contentInnerWidth();document.body.style.cursor="nwse-resize",e.classList.add("aw-resizing");const i=s=>{const a=s.clientX-t,c=Math.max(tn,o+a);e.style.width=`${Math.round(Math.min(c,r))}px`},l=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",l),document.body.style.cursor="",e.classList.remove("aw-resizing"),this.flush()};document.addEventListener("mousemove",i),document.addEventListener("mouseup",l)}contentInnerWidth(){const e=getComputedStyle(this.content),t=this.content.clientWidth-(Number.parseFloat(e.paddingLeft)||0)-(Number.parseFloat(e.paddingRight)||0);return Math.max(tn,t)}currentTheme(){const e=this.root.dataset.theme;return e==="dark"||e==="light"?e:void 0}applyFontFamily(e){this.content.focus(),document.execCommand("styleWithCSS",!1,"true"),document.execCommand("fontName",!1,e||"inherit"),this.queueSync()}computedStyleAtCaret(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).startContainer;return!t||!this.content.contains(t)?null:(t.nodeType!==Node.ELEMENT_NODE&&(t=t.parentElement),t instanceof Element?getComputedStyle(t):null)}applyFontSize(e){const t=Array.from(this.content.querySelectorAll("td.aw-cell-selected, th.aw-cell-selected"));if(t.length>0){this.applyFontSizeToCells(t,e);return}const o=document.getSelection();if(o&&o.rangeCount>0&&!o.getRangeAt(0).collapsed){const r=o.getRangeAt(0),i=Ce(r.startContainer),l=Ce(r.endContainer);if(i&&l&&i!==l&&this.content.contains(i)&&this.content.contains(l)){const s=i.closest("table");if(s instanceof HTMLTableElement){this.applyFontSizeToCells(Ue(s,i,l),e);return}}}this.wrapSelectionStyle("fontSize",`${e}pt`)}wrapSelectionStyle(e,t){this.content.focus();const o=document.getSelection();if(!o||o.rangeCount===0)return;const r=o.getRangeAt(0);if(!this.content.contains(r.commonAncestorContainer))return;const i=document.createElement("span");if(i.style[e]=t,r.collapsed){i.appendChild(document.createTextNode("​")),r.insertNode(i);const l=document.createRange();l.selectNodeContents(i),l.collapse(!1),o.removeAllRanges(),o.addRange(l)}else{try{r.surroundContents(i)}catch{const s=r.extractContents();i.appendChild(s),r.insertNode(i)}for(const s of Array.from(i.querySelectorAll("span")))s.style[e]&&(s.style[e]=""),s.getAttribute("style")||s.removeAttribute("style");o.removeAllRanges();const l=document.createRange();l.selectNodeContents(i),o.addRange(l)}this.queueSync()}openBlockTypeMenu(e,t){Do(e,o=>{if(o.kind==="linkCard"){this.openLinkDialogAndApply(t);return}if(o.kind==="youtube"){this.openYouTubeDialogAndApply(t);return}if(o.kind==="image"){this.openImageDialogAndApply(t);return}if(o.kind==="table"){Tt(e,r=>{this.setBlockType("table",{rows:r.rows,cols:r.cols},t)});return}if(o.kind==="importHtml"){this.openImportHtmlDialogAndApply(t);return}if(o.kind==="importMarkdown"){this.openMarkdownImportDialogAndApply(t);return}if(o.kind==="file"){this.openFileAttachmentDialogAndApply(t);return}this.setBlockType(o.kind,o.attrs,t)})}openLinkDialogAndApply(e){wo({},this.currentTheme()).then(t=>{var l;if(!t.confirmed||!t.href)return;const o=t.href,r=((l=t.text)==null?void 0:l.trim())??"",i=r.length>0?r:o;this.setBlockType("linkCard",{href:o,text:i},e)})}openImageDialogAndApply(e){const t=this.uploader("image");vo({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{o.confirmed&&o.src&&this.setBlockType("image",{src:o.src},e),this.queueSync()})}openYouTubeDialogAndApply(e){xo(this.currentTheme()).then(t=>{if(!t.confirmed||!t.url)return;const o=Nl(t.url);o&&this.setBlockType("youtube",{videoId:o},e)})}openImportHtmlDialogAndApply(e){Co(this.currentTheme()).then(async t=>{if(!t.confirmed)return;if(!t.html||t.html.length===0){window.alert(m().importHtml.errEmpty);return}let o;try{o=await ml(t.html,{mountTarget:this.content})}catch(s){console.error("HTML import failed:",s);const a=s instanceof Error?s.message:String(s);window.alert(`${m().importHtml.errFailed}${a}`);return}if(o.length===0){window.alert(m().importHtml.errNoBody);return}const r=e?this.content.querySelector(`[data-block-id="${e}"]`):null,i=[];for(const s of o){const a=ul(s.tagName)?s:(()=>{const c=document.createElement("p");return c.appendChild(s),c})();i.push(a)}if(r)if(r.tagName==="P"&&(r.textContent??"").trim().length===0&&i.length>0){const a=i[0];r.replaceWith(a);let c=a;for(let u=1;u<i.length;u++){const d=i[u];c.after(d),c=d}}else{let a=r;for(const c of i)a.after(c),a=c}else for(const s of i)this.content.appendChild(s);this.flush(),this.content.focus();const l=i[i.length-1];l&&M(l)})}openMarkdownImportDialogAndApply(e){Ao(this.currentTheme()).then(t=>{if(!t.confirmed)return;if(!t.markdown||t.markdown.length===0){window.alert(m().importMarkdown.errEmpty);return}let o;try{o=Zn(t.markdown)}catch(l){console.error("Markdown parse failed:",l);const s=l instanceof Error?l.message:String(l);window.alert(`${m().importMarkdown.errFailed}${s}`);return}if(o.length===0){window.alert(m().importMarkdown.errNoBody);return}const r=e?this.content.querySelector(`[data-block-id="${e}"]`):null;if(r)if(r.tagName==="P"&&(r.textContent??"").trim().length===0&&o.length>0){const s=o[0];r.replaceWith(s);let a=s;for(let c=1;c<o.length;c++){const u=o[c];a.after(u),a=u}}else{let s=r;for(const a of o)s.after(a),s=a}else for(const l of o)this.content.appendChild(l);this.flush(),this.content.focus();const i=o[o.length-1];i&&M(i)})}openFileAttachmentDialogAndApply(e){const t=this.uploader("file");Lo({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{if(!o.confirmed)return;if(!o.src||o.src.length===0){window.alert(m().fileAttach.errEmpty);return}const r={fileSrc:o.src},i=o.name&&o.name.length>0?o.name:Bl(o.src);i&&(r.fileName=i),o.size!==void 0&&(r.fileSize=o.size),o.type&&(r.fileType=o.type),this.setBlockType("file",r,e)})}uploader(e){const t=this.options.upload;if(!(!t||!t.handler&&!t.url))return async o=>{try{if(t.maxSize!==void 0&&o.size>t.maxSize)throw new Error(J(m().docTools.tooLarge,{size:Pl(t.maxSize)}));if(t.handler)return await t.handler(o,e);const r=new FormData;r.append("file",o),r.append("kind",e);const i=typeof t.headers=="function"?t.headers():t.headers,l=await fetch(t.url,{method:"POST",body:r,...i?{headers:i}:{}});if(!l.ok)throw new Error(`upload failed: HTTP ${l.status}`);const s=await l.json(),a=typeof s=="object"&&s&&"url"in s?s.url:void 0;if(typeof a!="string"||!a)throw new Error('upload response has no "url"');return a}catch(r){throw this.reportError(r,"upload"),r}}}reportError(e,t){const o=e instanceof Error?e:new Error(String(e));this.options.onError?this.options.onError(o,{code:t}):console.error(`[aeriz-wysiwyg] ${t}:`,o)}queueSync(){this.syncQueued||this.destroyed||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,!this.destroyed&&this.sync()}))}sync(){if(this.composing)return;const e=this.currentBlocks(),t=this.getActiveBlock(),r=t!==null?this.readInlineState():no();this.state={blocks:e,activeBlockId:(t==null?void 0:t.id)??null,inline:r},this.syncBlockMarkers(t),this.syncBlockHandles(),this.scheduleOverlays(),this.scheduleStatusBar(),this.syncHistoryButtons(),this.applyToolbarState(this.state,t);for(const i of this.listeners)i(this.state)}readInlineState(){const e=document.getSelection(),t=(e==null?void 0:e.anchorNode)??null,o=(t==null?void 0:t.parentNode)??null;if(this.inlineCache&&t===this.inlineCache.node&&o===this.inlineCache.parent)return this.inlineCache.state;const r=Object.fromEntries(R.map(i=>[i,$l(en[i]??i)]));return this.inlineCache={node:t,parent:o,state:r},r}invalidateInlineState(){this.inlineCache=null}handleKeyDown(e){var r;if(this.readOnly)return;if(e.altKey&&e.key==="F10"){e.preventDefault(),(r=this.toolbar)==null||r.focus();return}if((e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="h"){e.preventDefault(),this.openFind();return}if(e.key==="Escape"&&this.root.classList.contains("aw-fullscreen")){e.preventDefault(),this.toggleFullscreen();return}if((e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="v"&&(this.plainPasteNext=!0,window.setTimeout(()=>{this.plainPasteNext=!1},500)),(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.isComposing){const i=e.key.toLowerCase();let l=null;if(!e.shiftKey&&i==="b"?l="bold":!e.shiftKey&&i==="i"?l="italic":!e.shiftKey&&i==="u"?l="underline":e.shiftKey&&i==="x"?l="strike":i==="."||i===">"?l="superscript":(i===","||i==="<")&&(l="subscript"),l){e.preventDefault(),this.applyMark(l);return}}if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.isComposing){const i=e.key.toLowerCase();if(i==="z"){e.preventDefault(),e.shiftKey?this.redo():this.undo();return}if(i==="y"&&!e.shiftKey){e.preventDefault(),this.redo();return}}if(this.handleBlockShortcut(e)||e.key==="Tab"&&!e.isComposing&&this.handleTabKey(e)||e.key==="Backspace"&&!e.isComposing&&this.handleBackspaceKey(e))return;if(e.key==="Enter"&&e.shiftKey&&!e.isComposing){const i=this.getActiveBlock();(i==null?void 0:i.kind)==="codeBlock"&&this.insertCodeLineBreak(e,i);return}if(e.key!=="Enter"||e.shiftKey||e.isComposing)return;const t=document.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return;const o=this.getActiveBlock();if(o){if(o.kind==="blockquote"||o.kind==="codeBlock"){this.exitBlockOnEnter(e,o.element);return}o.kind==="heading"&&tl(o.element)&&this.exitBlockOnEnter(e,o.element)}}handleInputRule(e){if(e.isComposing)return;const t=this.getActiveBlock();if(!t)return;if(t.kind==="bulletList"){this.applyTaskItemRule(t);return}if(t.kind!=="paragraph")return;const o=Yt(t.element);if(!o)return;const r=Zi(o.text);r&&(o.range.deleteContents(),this.setBlockType(r.kind,r.attrs))}applyTaskItemRule(e){var s;const t=document.getSelection(),o=t==null?void 0:t.anchorNode;if(!o)return;const r=(s=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)==null?void 0:s.closest("li");if(!r||r.parentElement!==e.element)return;const i=Yt(r);if(!i)return;const l=Ji(i.text);l&&(this.markStructuralChange(),i.range.deleteContents(),O(r)&&!r.querySelector("br")&&r.appendChild(document.createElement("br")),e.element.classList.add(K),l.checked&&r.setAttribute(X,"true"),this.flush(),this.content.focus(),M(r))}handleBlockShortcut(e){if(e.isComposing||!(e.metaKey||e.ctrlKey))return!1;if(e.shiftKey&&!e.altKey){const r=e.key.toLowerCase();return r==="arrowup"||r==="arrowdown"?(e.preventDefault(),this.moveActiveBlock(r==="arrowup"?"up":"down"),!0):r==="d"?(e.preventDefault(),this.deleteActiveBlock(),!0):!1}if(!e.altKey)return!1;const o=Xi[e.key.toLowerCase()];return o?(e.preventDefault(),this.setBlockType(o.kind,o.attrs),!0):!1}moveActiveBlock(e){const t=this.getActiveBlock();if(!t)return;const o=t.element,r=e==="up"?o.previousElementSibling:o.nextElementSibling;r&&(this.markStructuralChange(),e==="up"?r.before(o):r.after(o),this.flush(),this.content.focus(),M(o),this.flashBlock(o),typeof o.scrollIntoView=="function"&&o.scrollIntoView({block:"nearest"}))}deleteActiveBlock(){const e=this.getActiveBlock();if(!e)return;const t=e.element,o=t.nextElementSibling??t.previousElementSibling;this.markStructuralChange(),t.remove(),this.flush(),this.content.focus();const r=o instanceof HTMLElement?o:this.content.firstElementChild;r instanceof HTMLElement&&M(r)}handleTabKey(e){const t=this.getActiveBlock();if(!t)return!1;if(t.kind==="table"){const o=this.getActiveTableCell();if(!o)return!1;e.preventDefault();const r=t.element,i=e.shiftKey?oi(r,o):ni(r,o)??Ot(r,o,"below");return i&&M(i),this.flush(),!0}return t.kind==="bulletList"||t.kind==="orderedList"?(e.preventDefault(),this.content.focus(),document.execCommand(e.shiftKey?"outdent":"indent"),this.queueSync(),!0):t.kind==="codeBlock"?this.indentCode(e,t,e.shiftKey):!1}indentCode(e,t,o){const r=t.element.querySelector(":scope > code");if(!r)return!1;const i=Gn(r)??{start:0,end:0},l=nn(r),s=He.CODE_INDENT;let a,c,u;if(!o&&i.start===i.end)a=l.slice(0,i.start)+s+l.slice(i.start),c=u=i.start+s.length;else{const h=l.lastIndexOf(`
22
+ `,i.start-1)+1,f=l.indexOf(`
23
+ `,i.end),p=f===-1?l.length:f;let g=0,k=0;const y=l.slice(h,p).split(`
24
+ `).map((C,A)=>{if(o){const v=/^(\t| {1,2})/.exec(C),L=(v==null?void 0:v[0].length)??0;return A===0&&(g=-L),k-=L,C.slice(L)}return C===""?C:(A===0&&(g=s.length),k+=s.length,s+C)}).join(`
25
+ `);if(k===0)return e.preventDefault(),!0;a=l.slice(0,h)+y+l.slice(p),c=Math.max(h,i.start+g),u=Math.max(c,i.end+k)}e.preventDefault(),this.markStructuralChange();const d=r.getAttribute("data-language")??void 0;return r.innerHTML=this.codeHtml(a,d),this.content.focus(),Vn(r,{start:c,end:u}),this.flush(),!0}handleBackspaceKey(e){const t=document.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;const o=this.getActiveBlock();if(!o||o.kind==="paragraph")return!1;const r=U[o.kind];if(!r||!r.allowsInlineFormat||!r.isEmpty(o.element))return!1;e.preventDefault();const i=document.createElement("p");return i.appendChild(document.createElement("br")),o.element.replaceWith(i),this.flush(),this.content.focus(),M(i),!0}insertCodeLineBreak(e,t){const o=t.element.querySelector(":scope > code");if(!o)return;const r=document.getSelection();if(!r||r.rangeCount===0)return;e.preventDefault(),o.contains(r.getRangeAt(0).commonAncestorContainer)||M(t.element);const i=r.getRangeAt(0);if(!o.contains(i.commonAncestorContainer))return;i.deleteContents();const l=document.createRange();l.selectNodeContents(o),l.setStart(i.endContainer,i.endOffset);const s=l.toString()==="",a=document.createTextNode(s?`
26
+
27
+ `:`
28
+ `);i.insertNode(a);const c=document.createRange();c.setStart(a,1),c.collapse(!0),r.removeAllRanges(),r.addRange(c),this.flush()}exitBlockOnEnter(e,t){e.preventDefault(),this.markStructuralChange();const o=document.createElement("p");o.appendChild(document.createElement("br")),t.insertAdjacentElement("afterend",o),M(o),this.flush()}syncBlockHandles(){const e=new Set;this.state.activeBlockId&&!this.readOnly&&e.add(this.state.activeBlockId),this.hoveredBlockId&&!this.readOnly&&e.add(this.hoveredBlockId);for(const[t,o]of this.handles)e.has(t)||(o.remove(),this.handles.delete(t));for(const t of e){if(this.handles.has(t))continue;const o=this.createBlockHandle(t);this.handlesLayer.appendChild(o),this.handles.set(t,o)}this.syncHandleVisibility()}scheduleOverlays(){this.overlayRaf===null&&(this.overlayRaf=window.requestAnimationFrame(()=>{this.overlayRaf=null,!this.destroyed&&this.repositionHandles()}))}syncHandleVisibility(){const e=this.state.activeBlockId;for(const[t,o]of this.handles)o.classList.toggle("is-hovered",t===this.hoveredBlockId),o.classList.toggle("is-active",t===e)}setHoveredBlock(e){this.hoveredBlockId!==e&&(this.hoveredBlockId=e,this.syncBlockHandles(),this.repositionHandles())}blockIdAtViewportY(e){const t=this.currentBlocks(),o=this.blockIndexAtY(t,e);let r=null;for(const i of[o-1,o,o+1]){const l=t[i];if(!l)continue;const s=l.element.getBoundingClientRect();if(e>=s.top&&e<=s.bottom)return l.id;const a=e<s.top?s.top-e:e-s.bottom;(!r||a<r.distance)&&(r={id:l.id,distance:a})}return r&&r.distance<=24?r.id:null}blockIndexAtY(e,t){let o=0,r=e.length-1;for(;o<r;){const i=o+r>>1,l=e[i];if(!l)break;l.element.getBoundingClientRect().bottom<t?o=i+1:r=i}return o}repositionHandles(){if(this.destroyed)return;for(const[o,r]of this.handles){const i=this.elementOfId(o);i&&this.positionHandle(r,i)}const e=this.state.activeBlockId,t=e?this.elementOfId(e):null;this.syncBlockLabelPill(t?this.blockOf(t):null)}elementOfId(e){var t;if(((t=this.focusedEl)==null?void 0:t.getAttribute("data-block-id"))===e&&this.focusedEl.parentNode===this.content)return this.focusedEl;for(const o of this.cachedBlocks)if(o.id===e&&o.element.parentNode===this.content)return o.element;return this.content.querySelector(`:scope > [data-block-id="${e}"]`)}positionHandle(e,t){const o=t.getBoundingClientRect(),r=this.contentWrap.getBoundingClientRect(),i=18,l=o.height<i?(o.height-i)/2:0,s=o.top-r.top+this.contentWrap.scrollTop+l;e.style.top=`${s}px`}createBlockHandle(e){const t=document.createElement("div");t.className="aw-block-controls",t.dataset.blockId=e;const o=document.createElement("div");o.className="aw-block-handle",o.draggable=!0,o.setAttribute("role","button"),o.setAttribute("aria-label",m().toolbar.blockMoveTooltip),o.title=m().toolbar.blockMoveTooltip,o.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="6" cy="3" r="1.4"/><circle cx="10" cy="3" r="1.4"/><circle cx="6" cy="8" r="1.4"/><circle cx="10" cy="8" r="1.4"/><circle cx="6" cy="13" r="1.4"/><circle cx="10" cy="13" r="1.4"/></svg>',o.addEventListener("dragstart",i=>{if(!i.dataTransfer)return;i.dataTransfer.setData(Je,e),i.dataTransfer.setData("text/plain",e),i.dataTransfer.effectAllowed="move",o.classList.add("is-dragging");const l=this.content.querySelector(`[data-block-id="${e}"]`);if(l){l.classList.add("is-block-dragging");try{i.dataTransfer.setDragImage(l,12,12)}catch{}}}),o.addEventListener("dragend",()=>{o.classList.remove("is-dragging");const i=this.content.querySelector(`[data-block-id="${e}"]`);i&&i.classList.remove("is-block-dragging"),this.hideDropIndicator()});const r=document.createElement("button");return r.type="button",r.className="aw-block-add",r.title=m().toolbar.addBelowTooltip,r.setAttribute("aria-label",m().toolbar.addBelowTooltip),r.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="8" y1="3" x2="8" y2="13"/><line x1="3" y1="8" x2="13" y2="8"/></svg>',r.addEventListener("mousedown",i=>i.preventDefault()),r.addEventListener("click",i=>{i.stopPropagation(),this.insertParagraphAfter(e)}),t.appendChild(o),t.appendChild(r),t}insertParagraphAfter(e){const t=this.content.querySelector(`[data-block-id="${e}"]`);if(!t)return;this.markStructuralChange();const o=document.createElement("p");o.appendChild(document.createElement("br")),t.insertAdjacentElement("afterend",o),this.flush(),this.content.focus(),M(o)}handlePaste(e){const t=e.clipboardData;if(!t||this.composing||this.readOnly)return;e.preventDefault();const o=this.plainPasteNext;this.plainPasteNext=!1,this.insertTransfer(t,o)}insertTransfer(e,t){const o=Array.from(e.files).filter(s=>s.type.startsWith("image/")),r=t?"":e.getData("text/html");if(o.length>0&&!r.trim()){this.insertImageFiles(o);return}const i=this.getActiveBlock();if((i==null?void 0:i.kind)==="codeBlock"||!r.trim()&&!e.getData("text/plain")){const s=e.getData("text/plain");s&&document.execCommand("insertText",!1,s);return}const l=r.trim()?Z(gr(r)):Hl(e.getData("text/plain"));this.insertFragmentAtCaret(l)}insertFragmentAtCaret(e){const t=document.getSelection();let o=t&&t.rangeCount>0?t.getRangeAt(0):null;(!o||!this.content.contains(o.commonAncestorContainer))&&(o=document.createRange(),o.selectNodeContents(this.content),o.collapse(!1)),this.markStructuralChange();const r=Wr(this.content,o,e);if(this.flush(),this.content.focus(),r&&r[0].isConnected){const i=document.createRange();i.setStart(r[0],Math.min(r[1],r[0].childNodes.length||(r[0].textContent??"").length)),i.collapse(!0),t==null||t.removeAllRanges(),t==null||t.addRange(i);const l=r[0].nodeType===1?r[0]:r[0].parentElement;l&&typeof l.scrollIntoView=="function"&&l.scrollIntoView({block:"nearest"})}this.queueSync()}async insertImageFiles(e){var r;const t=this.uploader("image");let o=((r=this.getActiveBlock())==null?void 0:r.element)??null;for(const i of e){let l;try{l=t?await t(i):await Rl(i)}catch(c){t||this.reportError(c,"paste");continue}if(this.destroyed)return;const s=U.image;if(!s)return;this.markStructuralChange();const a=s.create({src:l});o!=null&&o.isConnected?o.after(a):this.content.appendChild(a),o=a,this.flush()}this.queueSync()}handleDragOver(e){if(!e.dataTransfer)return;if(!Array.from(e.dataTransfer.types).includes(Je)){Array.from(e.dataTransfer.types).some(o=>o==="Files"||o==="text/html"||o==="text/plain")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy");return}e.preventDefault(),e.dataTransfer.dropEffect="move";const t=this.findDropTarget(e.clientY);t&&this.showDropIndicator(t)}handleDrop(e){var l;if(!e.dataTransfer)return;const t=e.dataTransfer.getData(Je);if(!t){if(this.readOnly){e.preventDefault();return}if(e.dataTransfer.types.includes("Files")||!this.content.contains(((l=document.getSelection())==null?void 0:l.anchorNode)??null)){e.preventDefault();const s=Il(e.clientX,e.clientY);if(s&&this.content.contains(s.startContainer)){const a=document.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(s)}this.insertTransfer(e.dataTransfer,!1)}return}e.preventDefault();const o=this.findDropTarget(e.clientY);if(this.hideDropIndicator(),!o||o.id===t)return;const r=this.content.querySelector(`[data-block-id="${t}"]`),i=this.content.querySelector(`[data-block-id="${o.id}"]`);!r||!i||(this.markStructuralChange(),o.before?this.content.insertBefore(r,i):this.content.insertBefore(r,i.nextSibling))}handleDragLeave(e){this.content.contains(e.relatedTarget)||this.hideDropIndicator()}findDropTarget(e){const t=this.currentBlocks(),o=this.blockIndexAtY(t,e);for(let i=Math.max(0,o-1);i<t.length;i++){const l=t[i];if(!l)continue;const s=l.element.getBoundingClientRect(),a=s.top+s.height/2;if(e<a)return{id:l.id,before:!0}}const r=t[t.length-1];return r?{id:r.id,before:!1}:null}showDropIndicator(e){const t=this.content.querySelector(`[data-block-id="${e.id}"]`);if(!t)return;const o=t.getBoundingClientRect(),r=this.contentWrap.getBoundingClientRect(),i=(e.before?o.top:o.bottom)-r.top+this.contentWrap.scrollTop;this.dropIndicator.style.top=`${i}px`,this.dropIndicator.style.display="block"}hideDropIndicator(){this.dropIndicator.style.display="none"}syncBlockLabelPill(e){if(!e){this.blockLabelPill.style.display="none",this.blockLabelPill.classList.remove("is-entering"),this.pillBlockId=null;return}const{match:t}=this.tracker.classify(e.element),o=Ve(e.element,t),r=Yi(t);this.pillGlyphEl.textContent!==r&&(this.pillGlyphEl.textContent=r),this.pillTextEl.textContent!==o&&(this.pillTextEl.textContent=o),this.blockLabelPill.dataset.kind=t.kind,this.blockLabelPill.style.display="inline-flex",this.pillBlockId!==e.id&&(this.pillBlockId=e.id,this.blockLabelPill.classList.remove("is-entering"),this.blockLabelPill.offsetWidth,this.blockLabelPill.classList.add("is-entering"));const i=e.element.getBoundingClientRect(),l=this.contentWrap.getBoundingClientRect(),s=3,a=this.blockLabelPill.offsetHeight||15,c=Math.max(0,i.top-l.top+this.contentWrap.scrollTop-a-s),u=i.left-l.left+4;this.blockLabelPill.style.top=`${c}px`,this.blockLabelPill.style.left=`${u}px`}scheduleStatusBar(){if(this.options.statusBar===!1)return;const e=this.state.activeBlockId?this.findBlockById(this.state.activeBlockId):null;this.syncStatusBlock(e),this.statusTimer!==null&&window.clearTimeout(this.statusTimer),this.statusTimer=window.setTimeout(()=>{this.statusTimer=null,this.destroyed||this.syncStatusCounts()},250)}syncStatusBlock(e){let t;if(e){const{match:o}=this.tracker.classify(e.element);if(t=Ve(e.element,o),e.kind==="codeBlock"){const r=e.element.querySelector(":scope > code"),i=r==null?void 0:r.getAttribute("data-language");i&&(t+=` · ${i}`)}}else t=m().status.noActive;Qe(this.statusBlockEl,t)}syncStatusCounts(){Qe(this.statusBlocksEl,J(m().status.blocksCount,{n:this.content.childElementCount}));const e=(this.content.textContent??"").replace(st,"").replace(/\s+/g,""),t=Array.from(e).length;Qe(this.statusCharsEl,J(m().status.chars,{n:t}))}syncHistoryButtons(){const e=!this.readOnly&&this.history.canUndo,t=!this.readOnly&&this.history.canRedo;this.undoBtn.disabled!==!e&&(this.undoBtn.disabled=!e),this.redoBtn.disabled!==!t&&(this.redoBtn.disabled=!t)}syncBlockMarkers(e){for(const o of this.markerPending){if(o.parentNode!==this.content)continue;const{match:r}=this.tracker.classify(o);o.getAttribute("data-block-kind")!==r.kind&&o.setAttribute("data-block-kind",r.kind);const i=Ve(o,r);o.getAttribute("data-block-label")!==i&&o.setAttribute("data-block-label",i)}this.markerPending.clear();const t=(e==null?void 0:e.element)??null;if(this.focusedEl!==t){const o=this.focusedEl;o&&o.parentNode===this.content&&o.querySelector("figcaption")&&G(this.content,{blocks:[o]}),o==null||o.removeAttribute("data-block-focused"),t==null||t.setAttribute("data-block-focused",""),this.focusedEl=t}else t&&!t.hasAttribute("data-block-focused")&&t.setAttribute("data-block-focused","");this.absorb()}absorb(){this.tracker.collect(this.observer.takeRecords()),this.tracker.pending&&queueMicrotask(()=>this.flush())}applyToolbarState(e,t){if(this.toolbar){for(const o of R)this.toolbar.setActive(o,e.inline[o]);for(const o of Object.keys(Ze)){const r=Ze[o];this.toolbar.setActive(o,(t==null?void 0:t.kind)===r)}for(const o of R)this.toolbar.setVisible(o,Kt(t,o));this.toolbar.setVisible("fontFamily",We(t)),this.toolbar.setVisible("fontSize",Gt(t)),this.toolbar.setVisible("color",ve(t)),this.toolbar.setVisible("backgroundColor",ve(t)),this.toolbar.setVisible("align",Ke(t)),this.toolbar.setVisible("cellBg",Ge(t)),this.toolbar.setVisible("tableMenu",Ge(t)),this.toolbar.setVisible("codeLang",(t==null?void 0:t.kind)==="codeBlock"&&!!this.options.highlighter),this.toolbar.syncGroupVisibility()}}};b(He,"CODE_INDENT"," ");let rt=He;function nn(n){var o;if(n.childNodes.length===1&&((o=n.firstChild)==null?void 0:o.nodeName)==="BR")return"";let e="";const t=r=>{for(const i of Array.from(r.childNodes))i.nodeType===Node.TEXT_NODE?e+=i.textContent??"":i.nodeName==="BR"?e+=`
29
+ `:t(i)};return t(n),e}function Nl(n){const e=n.trim();if(!e)return null;let t;try{t=new URL(e)}catch{return/^[A-Za-z0-9_-]{11}$/.test(e)?e:null}const o=t.hostname.replace(/^www\./,"");if(o==="youtu.be")return t.pathname.slice(1).split("/")[0]||null;if(o==="youtube.com"||o==="m.youtube.com"||o==="youtube-nocookie.com"){if(t.pathname==="/watch")return t.searchParams.get("v");if(t.pathname.startsWith("/embed/")||t.pathname.startsWith("/shorts/")||t.pathname.startsWith("/v/"))return t.pathname.split("/")[2]??null}return null}function Bl(n){var e;try{const r=new URL(n,"http://localhost").pathname.split("/").filter(Boolean).pop();return r?decodeURIComponent(r):""}catch{return(((e=n.split("?")[0])==null?void 0:e.split("#")[0])??"").split("/").filter(Boolean).pop()??""}}function Qe(n,e){n.textContent!==e&&(n.textContent=e)}function on(n,e,t){const o=document.createElement("button");return o.type="button",o.className="aw-status-action",o.title=n,o.setAttribute("aria-label",n),o.innerHTML=e,o.addEventListener("mousedown",r=>r.preventDefault()),o.addEventListener("click",t),o}function Ml(){return{blocks:[],activeBlockId:null,inline:no()}}function $l(n){try{return document.queryCommandState(n)}catch{return!1}}function Hl(n){const e=document.createDocumentFragment(),t=n.replace(/\r\n?/g,`
30
+ `).replace(/\n$/,"").split(`
31
+ `);if(t.length===1)return e.appendChild(document.createTextNode(t[0]??"")),e;for(const o of t){const r=document.createElement("p");o?r.textContent=o:r.appendChild(document.createElement("br")),e.appendChild(r)}return e}function Rl(n){return new Promise((e,t)=>{const o=new FileReader;o.onload=()=>e(String(o.result)),o.onerror=()=>t(o.error),o.readAsDataURL(n)})}function Il(n,e){var o;const t=document;if(typeof t.caretPositionFromPoint=="function"){const r=t.caretPositionFromPoint(n,e);if(!r)return null;const i=document.createRange();return i.setStart(r.offsetNode,r.offset),i.collapse(!0),i}return((o=document.caretRangeFromPoint)==null?void 0:o.call(document,n,e))??null}function Dl(n){const e=/^(\d+(?:\.\d+)?)%$/.exec(n.style.lineHeight);if(e)return Number(e[1]);const t=getComputedStyle(n),o=Number.parseFloat(t.lineHeight),r=Number.parseFloat(t.fontSize);return o&&r?Math.round(o/r*10)*10:null}function Pl(n){return n>=1024*1024?`${Math.round(n/1024/1024*10)/10}MB`:n>=1024?`${Math.round(n/1024)}KB`:`${n}B`}function rn(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zl(n){const e=document.createElement("template");e.innerHTML=n;const t=o=>{var r;for(const i of Array.from(o.childNodes))if(i.nodeType!==3){if(i.nodeType===1&&i.tagName==="SPAN"){const l=i;for(const s of Array.from(l.attributes))s.name!=="class"&&l.removeAttribute(s.name);t(l);continue}if(i.nodeType===1){const l=i;if(/^(SCRIPT|STYLE|TEMPLATE|IFRAME|OBJECT)$/.test(l.tagName)){l.remove();continue}t(l),l.replaceWith(...Array.from(l.childNodes));continue}(r=i.parentNode)==null||r.removeChild(i)}};return t(e.content),e.innerHTML}function oo(n){const e=document.createElement("div");e.appendChild(Z(n)),G(e,{writableTail:!1});const t=new yt;return V(e,t),kt(qn(e,o=>t.ensure(o)))}class Fl{constructor(e){b(this,"root");b(this,"content");b(this,"blockIds",new yt);b(this,"idFor",e=>this.blockIds.ensure(e));b(this,"options");b(this,"destroyed",!1);if(!(e.element instanceof HTMLElement))throw new TypeError("AerizViewer: options.element must be an HTMLElement");this.options=e,this.root=document.createElement("div"),this.root.className="aeriz-wysiwyg aeriz-wysiwyg-viewer",e.theme&&(this.root.dataset.theme=e.theme);const t=document.createElement("div");t.className="aw-content-wrap",this.content=document.createElement("div"),this.content.className="aw-content",this.content.contentEditable="false",this.content.setAttribute("role","document"),t.appendChild(this.content),this.root.appendChild(t),e.element.innerHTML="",e.element.appendChild(this.root),e.initialBlocks&&e.initialBlocks.length>0?this.setBlocks(e.initialBlocks):e.initialHTML&&this.setHTML(e.initialHTML)}setBlocks(e){On(this.content,e),V(this.content,this.blockIds)}setHTML(e){this.setBlocks(oo(e))}getBlocks(){return kt(this.listBlocksInternal())}getBlockOf(e){return this.content.contains(e)?Ii(e,this.content,this.idFor):null}getHTML(e={}){const t=this.content.cloneNode(!0);if((e.styles??this.options.htmlStyles??"inline")==="class")jn(t);else{const r=_n(this.root),i=this.root.dataset.theme;(i==="light"||i==="dark")&&(r.mode=i),Un(t,r)}return Wn(t),wt(t),t.innerHTML}setTheme(e){this.root.dataset.theme=e}destroy(){this.destroyed||(this.destroyed=!0,this.root.remove())}listBlocksInternal(){return qn(this.content,this.idFor)}}const ro=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ol=new Set(["script","style"]),ql=new Map([["li",new Set(["li"])],["p",new Set(["p","div","ul","ol","blockquote","pre","table","h1","h2","h3","h4","h5","h6"])],["td",new Set(["td","th","tr"])],["th",new Set(["td","th","tr"])],["tr",new Set(["tr"])],["option",new Set(["option"])]]),_l={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",hellip:"…",mdash:"—",ndash:"–",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",middot:"·",bull:"•",copy:"©",reg:"®",trade:"™",deg:"°",plusmn:"±",times:"×",divide:"÷",laquo:"«",raquo:"»"};function fe(n){return n.includes("&")?n.replace(/&(#[Xx][0-9A-Fa-f]+|#\d+|[A-Za-z][A-Za-z0-9]{1,31});/g,(e,t)=>{if(t.charCodeAt(0)===35){const r=t[1]==="x"||t[1]==="X",i=r?t.slice(2):t.slice(1),l=Number.parseInt(i,r?16:10);if(!Number.isFinite(l)||l<0||l>1114111||l>=55296&&l<=57343)return e;try{return String.fromCodePoint(l)}catch{return e}}return _l[t.toLowerCase()]??e}):n}function j(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function S(n){return j(n).replace(/"/g,"&quot;")}function Ul(n){const e={},t=/([^\s/=>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;let o;for(;(o=t.exec(n))!==null;){const r=o[1];if(!r)continue;const i=o[2]??o[3]??o[4]??"";e[r.toLowerCase()]=fe(i)}return e}function ie(n){const e=[],t=[],o=()=>{const s=t[t.length-1];return s?s.children:e},r=s=>{if(s.length===0)return;const a=o(),c=a[a.length-1];c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s})},i=s=>{var a;for(let c=t.length-1;c>=0;c--)if(((a=t[c])==null?void 0:a.tag)===s){t.length=c;return}};let l=0;for(;l<n.length;){const s=n.indexOf("<",l);if(s<0){r(fe(n.slice(l)));break}if(s>l&&r(fe(n.slice(l,s))),n.startsWith("<!--",s)){const y=n.indexOf("-->",s+4);l=y<0?n.length:y+3;continue}if(n.startsWith("<!",s)||n.startsWith("<?",s)){const y=n.indexOf(">",s+2);l=y<0?n.length:y+1;continue}const a=n.indexOf(">",s+1);if(a<0){r(fe(n.slice(s)));break}const c=n.slice(s+1,a);if(l=a+1,c.startsWith("/")){const y=c.slice(1).trim().toLowerCase();y&&i(y);continue}const u=/^([A-Za-z][^\s/>]*)/.exec(c);if(!u||!u[1]){r(fe(n.slice(s,l)));continue}const d=u[1].toLowerCase(),h=c.slice(u[1].length),f=/\/\s*$/.test(h),p=Ul(f?h.replace(/\/\s*$/,""):h);if(Ol.has(d)){const y=new RegExp(`</${d}\\s*>`,"i"),C=n.slice(l),A=y.exec(C);l=A?l+A.index+A[0].length:n.length;continue}const g=t[t.length-1];if(g){const y=ql.get(g.tag);y!=null&&y.has(d)&&t.pop()}const k={type:"element",tag:d,attrs:p,children:[]};o().push(k),!f&&!ro.has(d)&&t.push(k)}return e}function Lt(n){let e="";for(const t of n){if(t.type==="text"){e+=j(t.value);continue}const o=Object.entries(t.attrs).map(([r,i])=>i===""?` ${r}`:` ${r}="${S(i)}"`).join("");if(ro.has(t.tag)){e+=`<${t.tag}${o}>`;continue}e+=`<${t.tag}${o}>${Lt(t.children)}</${t.tag}>`}return e}function xt(n){let e="";for(const t of n){if(t.type==="text"){e+=t.value;continue}if(t.tag==="br"){e+=`
32
+ `;continue}e+=xt(t.children)}return e}const jl=new Set(["address","article","aside","blockquote","details","div","dd","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"]);function Me(n){let e="";for(const t of n){if(t.type==="text"){e+=t.value;continue}if(t.tag==="br"){e+=`
33
+ `;continue}const o=jl.has(t.tag);o&&e!==""&&!e.endsWith(`
26
34
  `)&&(e+=`
27
- `),e+=de(n.children),o&&!e.endsWith(`
35
+ `),e+=Me(t.children),o&&!e.endsWith(`
28
36
  `)&&(e+=`
29
- `)}return e}function Te(t,e){return t.filter(n=>n.type==="element"&&n.tag===e)}function jl(t,e={}){const n=e.blockIds!==!1,o=pe(t).map(i=>gn(i,{blockIds:n})).join("");return e.wrapper!=="content"?o:`<div class="aeriz-wysiwyg aeriz-wysiwyg-viewer"${e.theme?` data-theme="${e.theme}"`:""}><div class="aw-content-wrap"><div class="aw-content">${o}</div></div></div>`}function Wl(t,e={}){return gn(Ve(t),e)}function gn(t,e={}){const n=e.blockIds===!1?"":` ${P}="${x(t.id)}"`,o=Yl(t.html),l=(t.style?` style="${x(t.style)}"`:"")+Kl(t.attributes),i=r=>{var a;const s=Vt(r,(a=t.attributes)==null?void 0:a.class);return s?` class="${x(s)}"`:""};switch(t.kind){case"paragraph":return`<p${n}${l}>${o||"<br>"}</p>`;case"unknown":{const r=Gt(t.attrs.tag);return`<${r}${n}${l}>${o||"<br>"}</${r}>`}case"heading":{const r=Zl(t.attrs.level);return`<h${r}${n}${l}>${o||"<br>"}</h${r}>`}case"bulletList":return`<ul${n}${l}>${o||"<li><br></li>"}</ul>`;case"orderedList":return`<ol${n}${l}>${o||"<li><br></li>"}</ol>`;case"taskList":return`<ul${i(q)}${n}${l}>${o||"<li><br></li>"}</ul>`;case"blockquote":return`<blockquote${n}${l}>${o||"<p><br></p>"}</blockquote>`;case"codeBlock":{if(o)return`<pre${n}${l}>${o}</pre>`;const r=t.attrs.language,s=r?` data-language="${x(r)}"`:"";return`<pre${n}${l}><code${s}></code></pre>`}case"table":return`<table${n}${l}>${o||Xl(t.attrs.rows,t.attrs.cols)}</table>`;case"hr":return`<hr${n}${l}>`;case"image":return o?`<figure${n}${l}>${Se(o)}</figure>`:Jl(t.attrs,n,l);case"youtube":{if(!o)return Ql(t.attrs,n,l,i);const r=Ge(t.attrs.videoId),s=r?` data-youtube-id="${x(r)}"`:"";return`<div${i("aw-youtube-embed")}${s}${n}${l}>${Se(o)}</div>`}case"linkCard":return ei(t.attrs,n,l,o,i);case"file":return ti(t.attrs,n,l,o,i);case"importedHtml":{const r=t.attrs.importedStyle,s=t.style?l:r?` style="${x(r)}"`:"";return`<div data-imported-html="true"${i(t.attrs.importedClass)}${s}${n}>${o}</div>`}default:return""}}function Kl(t){if(!t)return"";let e="";for(const n of Ye){if(n==="class")continue;const o=t[n];o===void 0||o===""||(e+=` ${n}="${x(o)}"`)}return e}const Bt=/\s(href|src)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi;function Yl(t){return!t||!Vl(t)&&!Gl.test(t)?t:Ne(J(t).map(bn))}const Gl=/<iframe[\s>]/i;function Vl(t){Bt.lastIndex=0;let e;for(;(e=Bt.exec(t))!==null;){const n=(e[1]??"").toLowerCase(),o=V(e[2]??e[3]??e[4]??"");if(!(n==="href"?K(o):I(o)))return!0}return!1}function bn(t){if(t.type!=="element")return t;const e=t.tag==="iframe",n={};for(const[o,l]of Object.entries(t.attrs))o==="href"&&!K(l)||o==="src"&&!(e?l.startsWith(ue):I(l))||(n[o]=l);return{...t,attrs:n,children:t.children.map(bn)}}const $t=/aw-block-align-controls|aw-resize-handle/;function Se(t){if(!$t.test(t))return t;const e=J(t).filter(n=>!(n.type==="element"&&$t.test(n.attrs.class??"")));return Ne(e)}function Zl(t){return t===void 0||t<1?1:t>6?6:t}function Xl(t,e){const n=Math.max(1,Number.isFinite(t)?t:1),o=Math.max(1,Number.isFinite(e)?e:1);return`<tbody>${`<tr>${"<td><br></td>".repeat(o)}</tr>`.repeat(n)}</tbody>`}function Jl(t,e,n){const o=n||(t.wrapperStyle?` style="${x(t.wrapperStyle)}"`:""),l=I(t.src),i=l?` src="${x(l)}"`:"",r=` alt="${x(t.alt??"")}"`,s=t.caption?`<figcaption>${R(t.caption)}</figcaption>`:"";return`<figure${e}${o}><img${i}${r}>${s}</figure>`}function Ql(t,e,n,o){const l=Ge(t.videoId),i=n||(t.wrapperStyle?` style="${x(t.wrapperStyle)}"`:""),r=l?` data-youtube-id="${x(l)}"`:"",s=l?` src="${x(`${ue}${l}`)}"`:"";return`<div${o("aw-youtube-embed")}${r}${e}${i}><iframe${s} allow="${x(Kt)}" allowfullscreen frameborder="0" referrerpolicy="strict-origin-when-cross-origin"></iframe></div>`}function ei(t,e,n,o,l){const i=K(t.href)||"#",r=t.text&&t.text.length>0?t.text:We(i)||i,s=t.description??"",a=I(t.image),c=t.favicon?I(t.favicon):Ut(i),u=`<a${l(a?"aw-link-card aw-link-card-with-image":"aw-link-card")} href="${x(i)}" target="_blank" rel="noopener"${e}${n}>`;if(o)return`${u}${Se(o)}</a>`;let h=u;return a&&(h+=`<img class="aw-link-card-image" src="${x(a)}" alt="" loading="lazy">`),h+='<span class="aw-link-card-body">',h+=`<span class="aw-link-card-title">${R(r)}</span>`,s&&(h+=`<span class="aw-link-card-desc">${R(s)}</span>`),h+='<span class="aw-link-card-url">',c&&(h+=`<img class="aw-link-card-favicon" src="${x(c)}" alt="" loading="lazy">`),h+=`<span class="aw-link-card-url-text">${R(i)}</span>`,h+="</span></span></a>",h}function ti(t,e,n,o,l){const i=K(t.fileSrc),r=i?` href="${x(i)}"`:"",s=t.fileName?` data-file-name="${x(t.fileName)}"`:"",a=t.fileSize!==void 0?` data-file-size="${x(String(t.fileSize))}"`:"",c=t.fileType?` data-file-type="${x(t.fileType)}"`:"",d=` download="${x(t.fileName??"")}"`,u=[],h=qt(t.fileName,t.fileType);h&&u.push(h),t.fileSize!==void 0&&u.push(Ot(t.fileSize));const m=`<a${l("aw-file-attachment")} target="_blank" rel="noopener"${r}${d}${s}${a}${c}${e}${n}>`;if(o)return`${m}${Se(o)}</a>`;let f=m;return f+=`<span class="aw-file-icon" aria-hidden="true">${jt}</span>`,f+='<span class="aw-file-meta">',f+=`<span class="aw-file-name">${R(t.fileName??Yt)}</span>`,u.length>0&&(f+=`<span class="aw-file-info">${R(u.join(" · "))}</span>`),f+="</span>",f+=`<span class="aw-file-action" aria-hidden="true">${Wt}</span>`,f+="</a>",f}const ni=/([\\`*_[\]<])/g,oi=/^([#>|+-]|\d+\.)/;function li(t,e={}){const n=e.bullet??"-",o=e.gfmTables!==!1,l=[];for(const i of pe(t)){const r=ii(i,n,o);r!==""&&l.push(r)}return l.length>0?`${l.join(`
37
+ `)}return e}function me(n,e){return n.filter(t=>t.type==="element"&&t.tag===e)}function io(n,e){for(const t of n){if(t.type!=="element")continue;if(t.tag===e)return t;const o=io(t.children,e);if(o)return o}return null}function lo(n){return n?Lt(so(ie(n))):""}function so(n){const e=[];for(const t of n){if(t.type==="text"){e.push(t);continue}const o=xn(t.tag);if(o==="drop"||t.tag==="iframe"&&!Wl(t))continue;const r=so(t.children);if(o==="unwrap"){e.push(...r);continue}e.push({type:"element",tag:t.tag,attrs:Kl(t),children:r})}return e}function Wl(n){return de("iframe","src",n.attrs.src??"")!==null}function Kl(n){const e={};for(const[t,o]of Object.entries(n.attrs)){const r=de(n.tag,t,o);r!==null&&(e[t]=r)}if(n.tag==="a"){const t=En(e.target??null,e.rel??null);t&&(e.rel=t)}return e}function Gl(n,e={}){const t=e.blockIds!==!1,o=ye(n).map(i=>Vl(i,{blockIds:t})).join("");return e.wrapper!=="content"?o:`<div class="aeriz-wysiwyg aeriz-wysiwyg-viewer"${e.theme?` data-theme="${e.theme}"`:""}><div class="aw-content-wrap"><div class="aw-content">${o}</div></div></div>`}function Vl(n,e={}){const t=e.blockIds===!1?"":` ${Q}="${S(n.id)}"`,o=lo(n.html),r=(n.style?` style="${S(n.style)}"`:"")+Yl(n.attributes),i=l=>{var a;const s=vn(l,(a=n.attributes)==null?void 0:a.class);return s?` class="${S(s)}"`:""};switch(n.kind){case"paragraph":return`<p${t}${r}>${o||"<br>"}</p>`;case"unknown":{const l=wn(n.attrs.tag);return`<${l}${t}${r}>${o||"<br>"}</${l}>`}case"heading":{const l=Xl(n.attrs.level);return`<h${l}${t}${r}>${o||"<br>"}</h${l}>`}case"bulletList":return`<ul${t}${r}>${o||"<li><br></li>"}</ul>`;case"orderedList":return`<ol${t}${r}>${o||"<li><br></li>"}</ol>`;case"taskList":return`<ul${i(K)}${t}${r}>${o||"<li><br></li>"}</ul>`;case"blockquote":return`<blockquote${t}${r}>${o||"<p><br></p>"}</blockquote>`;case"codeBlock":{if(o)return`<pre${t}${r}>${o}</pre>`;const l=n.attrs.language,s=l?` data-language="${S(l)}"`:"";return`<pre${t}${r}><code${s}></code></pre>`}case"callout":{const l=be(n.attrs.variant),s=`${ce} ${le}${l}`;return`<aside${i(s)}${t}${r}>${o||"<p><br></p>"}</aside>`}case"toggle":return`<details${n.attrs.open?" open":""}${t}${r}>${o||Zl()}</details>`;case"table":return`<table${t}${r}>${o||Jl(n.attrs.rows,n.attrs.cols)}</table>`;case"hr":return`<hr${t}${r}>`;case"image":return o?`<figure${t}${r}>${$e(o)}</figure>`:Ql(n.attrs,t,r);case"youtube":{if(!o)return es(n.attrs,t,r,i);const l=dt(n.attrs.videoId),s=l?` data-youtube-id="${S(l)}"`:"";return`<div${i("aw-youtube-embed")}${s}${t}${r}>${$e(o)}</div>`}case"linkCard":return ts(n.attrs,t,r,o,i);case"file":return ns(n.attrs,t,r,o,i);case"importedHtml":{const l=n.attrs.importedStyle,s=n.style?r:l?` style="${S(l)}"`:"";return`<div data-imported-html="true"${i(n.attrs.importedClass)}${s}${t}>${o}</div>`}default:return""}}function Yl(n){if(!n)return"";let e="";for(const t of at){if(t==="class")continue;const o=n[t];o===void 0||o===""||(e+=` ${t}="${S(o)}"`)}return e}const ln=/aw-block-align-controls|aw-resize-handle/;function $e(n){if(!ln.test(n))return n;const e=ie(n).filter(t=>!(t.type==="element"&&ln.test(t.attrs.class??"")));return Lt(e)}function Xl(n){return n===void 0||n<1?1:n>6?6:n}function Zl(){return`<summary class="${Cn}"><br></summary><div class="${ct}"><p><br></p></div>`}function Jl(n,e){const t=Math.max(1,Number.isFinite(n)?n:1),o=Math.max(1,Number.isFinite(e)?e:1);return`<tbody>${`<tr>${"<td><br></td>".repeat(o)}</tr>`.repeat(t)}</tbody>`}function Ql(n,e,t){const o=t||(n.wrapperStyle?` style="${S(n.wrapperStyle)}"`:""),r=I(n.src),i=r?` src="${S(r)}"`:"",l=` alt="${S(n.alt??"")}"`,s=n.caption?`<figcaption>${j(n.caption)}</figcaption>`:"";return`<figure${e}${o}><img${i}${l}>${s}</figure>`}function es(n,e,t,o){const r=dt(n.videoId),i=t||(n.wrapperStyle?` style="${S(n.wrapperStyle)}"`:""),l=r?` data-youtube-id="${S(r)}"`:"",s=r?` src="${S(`${Re}${r}`)}"`:"";return`<div${o("aw-youtube-embed")}${l}${e}${i}><iframe${s} allow="${S(yn)}" allowfullscreen frameborder="0" referrerpolicy="strict-origin-when-cross-origin"></iframe></div>`}function ts(n,e,t,o,r){const i=te(n.href)||"#",l=n.text&&n.text.length>0?n.text:lt(i)||i,s=n.description??"",a=I(n.image),c=n.favicon?I(n.favicon):mn(i),d=`<a${r(a?"aw-link-card aw-link-card-with-image":"aw-link-card")} href="${S(i)}" target="_blank" rel="noopener"${e}${t}>`;if(o)return`${d}${$e(o)}</a>`;let h=d;return a&&(h+=`<img class="aw-link-card-image" src="${S(a)}" alt="" loading="lazy">`),h+='<span class="aw-link-card-body">',h+=`<span class="aw-link-card-title">${j(l)}</span>`,s&&(h+=`<span class="aw-link-card-desc">${j(s)}</span>`),h+='<span class="aw-link-card-url">',c&&(h+=`<img class="aw-link-card-favicon" src="${S(c)}" alt="" loading="lazy">`),h+=`<span class="aw-link-card-url-text">${j(i)}</span>`,h+="</span></span></a>",h}function ns(n,e,t,o,r){const i=te(n.fileSrc),l=i?` href="${S(i)}"`:"",s=n.fileName?` data-file-name="${S(n.fileName)}"`:"",a=n.fileSize!==void 0?` data-file-size="${S(String(n.fileSize))}"`:"",c=n.fileType?` data-file-type="${S(n.fileType)}"`:"",u=` download="${S(n.fileName??"")}"`,d=[],h=fn(n.fileName,n.fileType);h&&d.push(h),n.fileSize!==void 0&&d.push(pn(n.fileSize));const f=`<a${r("aw-file-attachment")} target="_blank" rel="noopener"${l}${u}${s}${a}${c}${e}${t}>`;if(o)return`${f}${$e(o)}</a>`;let p=f;return p+=`<span class="aw-file-icon" aria-hidden="true">${gn}</span>`,p+='<span class="aw-file-meta">',p+=`<span class="aw-file-name">${j(n.fileName??kn)}</span>`,d.length>0&&(p+=`<span class="aw-file-info">${j(d.join(" · "))}</span>`),p+="</span>",p+=`<span class="aw-file-action" aria-hidden="true">${bn}</span>`,p+="</a>",p}const os=/([\\`*_[\]<])/g,rs=/^([#>|+-]|\d+\.)/;function is(n,e={}){const t=e.bullet??"-",o=e.gfmTables!==!1,r=[];for(const i of ye(n)){const l=ls(i,t,o);l!==""&&r.push(l)}return r.length>0?`${r.join(`
30
38
 
31
39
  `)}
32
- `:""}function ii(t,e,n){var l,i,r,s;const o=J(t.html);switch(t.kind){case"paragraph":case"unknown":{const a=Z(o).trim();return a===""?"":Mt(a)}case"heading":{const a=Math.min(6,Math.max(1,t.attrs.level??1)),c=Z(o).trim();return c===""?"":`${"#".repeat(a)} ${c}`}case"bulletList":return we(o,{ordered:!1,bullet:e,depth:0});case"orderedList":return we(o,{ordered:!0,bullet:e,depth:0});case"taskList":return we(o,{ordered:!1,bullet:e,depth:0,task:!0});case"blockquote":{const a=Te(o,"p"),d=(a.length>0?a.map(u=>Z(u.children).trim()):[Z(o).trim()]).filter(u=>u!=="").join(`
40
+ `:""}function ls(n,e,t){var r,i,l,s;const o=ie(n.html);switch(n.kind){case"paragraph":case"unknown":{const a=H(o).trim();return a===""?"":sn(a)}case"heading":{const a=Math.min(6,Math.max(1,n.attrs.level??1)),c=H(o).trim();return c===""?"":`${"#".repeat(a)} ${c}`}case"bulletList":return Ee(o,{ordered:!1,bullet:e,depth:0});case"orderedList":return Ee(o,{ordered:!0,bullet:e,depth:0});case"taskList":return Ee(o,{ordered:!1,bullet:e,depth:0,task:!0});case"blockquote":{const a=me(o,"p"),u=(a.length>0?a.map(d=>H(d.children).trim()):[H(o).trim()]).filter(d=>d!=="").join(`
33
41
 
34
42
  `).split(`
35
- `).map(u=>u===""?">":`> ${u}`);return d.length>0&&d[0]!==void 0?d.join(`
36
- `):""}case"codeBlock":{const a=Te(o,"code")[0],c=Ie(a?a.children:o).replace(/\n$/,""),d=t.attrs.language??(a==null?void 0:a.attrs["data-language"])??"",u="`".repeat(Math.max(3,yn(c)+1));return`${u}${d}
43
+ `).map(d=>d===""?">":`> ${d}`);return u.length>0&&u[0]!==void 0?u.join(`
44
+ `):""}case"codeBlock":{const a=me(o,"code")[0],c=xt(a?a.children:o).replace(/\n$/,""),u=n.attrs.language??(a==null?void 0:a.attrs["data-language"])??"",d="`".repeat(Math.max(3,co(c)+1));return`${d}${u}
37
45
  ${c}
38
- ${u}`}case"image":{const a=t.attrs.src??"";if(a==="")return"";const c=`![${Y(t.attrs.alt??"")}](${ce(a)})`,d=(l=t.attrs.caption)==null?void 0:l.trim();return d?`${c}
39
- *${Y(d)}*`:c}case"table":return n?ri(o):`<table>${t.html}</table>`;case"hr":return"---";case"linkCard":{const a=t.attrs.href??"";if(a==="")return"";const c=((i=t.attrs.text)==null?void 0:i.trim())||a,d=`[${Y(c)}](${ce(a)})`,u=(r=t.attrs.description)==null?void 0:r.trim();return u?`${d}
46
+ ${d}`}case"image":{const a=n.attrs.src??"";if(a==="")return"";const c=`![${Y(n.attrs.alt??"")}](${ge(a)})`,u=(r=n.attrs.caption)==null?void 0:r.trim();return u?`${c}
47
+ *${Y(u)}*`:c}case"table":return t&&!ao(o)?ss(o):`<table>${n.html}</table>`;case"hr":return"---";case"linkCard":{const a=n.attrs.href??"";if(a==="")return"";const c=((i=n.attrs.text)==null?void 0:i.trim())||a,u=`[${Y(c)}](${ge(a)})`,d=(l=n.attrs.description)==null?void 0:l.trim();return d?`${u}
48
+
49
+ ${sn(Y(d))}`:u}case"youtube":{const a=n.attrs.videoId;return a?`[YouTube](${Re}${encodeURIComponent(a)})`:""}case"file":{const a=n.attrs.fileSrc??"";if(a==="")return"";const c=((s=n.attrs.fileName)==null?void 0:s.trim())||a;return`[${Y(c)}](${ge(a)})`}case"callout":{const a=be(n.attrs.variant),c=me(o,"p"),d=(c.length>0?c.map(h=>H(h.children).trim()):[H(o).trim()]).filter(h=>h!=="").join(`
40
50
 
41
- ${Mt(Y(u))}`:d}case"youtube":{const a=t.attrs.videoId;return a?`[YouTube](${ue}${encodeURIComponent(a)})`:""}case"file":{const a=t.attrs.fileSrc??"";if(a==="")return"";const c=((s=t.attrs.fileName)==null?void 0:s.trim())||a;return`[${Y(c)}](${ce(a)})`}case"importedHtml":return t.html.trim();default:return""}}function we(t,e){const n=Te(t,"li");if(n.length===0)return"";const o=" ".repeat(e.depth),l=[];return n.forEach((i,r)=>{const s=[],a=[];for(const f of i.children)f.type==="element"&&(f.tag==="ul"||f.tag==="ol")?a.push(f):s.push(f);const c=e.ordered?`${r+1}.`:e.bullet,d=e.task?`${c} ${i.attrs[G]==="true"?"[x]":"[ ]"}`:c,u=Z(s).trim(),h=`${o}${" ".repeat(d.length+1)}`,m=u.split(`
51
+ `).split(`
52
+ `).map(h=>h===""?">":`> ${h}`);return[`> [!${a.toUpperCase()}]`,...d].join(`
53
+ `)}case"toggle":{const a=io(o,"summary"),c=a?H(a.children).trim():"",u=o.filter(h=>h.type!=="element"||h.tag!=="summary"),d=H(u).trim();return["<details>",`<summary>${c}</summary>`,"",d,"</details>"].join(`
54
+ `)}case"importedHtml":return n.html.trim();default:return""}}function Ee(n,e){const t=me(n,"li");if(t.length===0)return"";const o=" ".repeat(e.depth),r=[];return t.forEach((i,l)=>{const s=[],a=[];for(const p of i.children)p.type==="element"&&(p.tag==="ul"||p.tag==="ol")?a.push(p):s.push(p);const c=e.ordered?`${l+1}.`:e.bullet,u=e.task?`${c} ${i.attrs[X]==="true"?"[x]":"[ ]"}`:c,d=H(s).trim(),h=`${o}${" ".repeat(u.length+1)}`,f=d.split(`
42
55
  `).join(`
43
- ${h}`);l.push(`${o}${d} ${m}`);for(const f of a){const g=we(f.children,{ordered:f.tag==="ol",bullet:e.bullet,depth:e.depth+1});g!==""&&l.push(g)}}),l.join(`
44
- `)}function ri(t){const e=[],n=d=>{for(const u of d)if(u.type==="element"){if(u.tag==="tr"){e.push(u);continue}(u.tag==="tbody"||u.tag==="thead"||u.tag==="tfoot")&&n(u.children)}};if(n(t),e.length===0)return"";const o=e.map(d=>d.children.filter(u=>u.type==="element"&&(u.tag==="td"||u.tag==="th")).map(u=>si(u.children))),l=o.reduce((d,u)=>Math.max(d,u.length),0);if(l===0)return"";const i=d=>d.length===l?d:[...d,...Array(l-d.length).fill("")],[r,...s]=o.map(i);return[`| ${(r??Array(l).fill("")).join(" | ")} |`,`| ${Array(l).fill("---").join(" | ")} |`,...s.map(d=>`| ${d.join(" | ")} |`)].join(`
45
- `)}function si(t){return Z(t,{inTableCell:!0}).replace(/\n+/g,"<br>").replace(/\|/g,"\\|").trim()}function Z(t,e={}){let n="";for(const o of t){if(o.type==="text"){n+=Y(o.value);continue}const l=()=>Z(o.children,e);switch(o.tag){case"br":n+=e.inTableCell?`
56
+ ${h}`);r.push(`${o}${u} ${f}`);for(const p of a){const g=Ee(p.children,{ordered:p.tag==="ol",bullet:e.bullet,depth:e.depth+1});g!==""&&r.push(g)}}),r.join(`
57
+ `)}function ao(n){return n.some(e=>e.type==="element"&&((e.tag==="td"||e.tag==="th")&&(Number(e.attrs.rowspan)>1||Number(e.attrs.colspan)>1)||ao(e.children)))}function ss(n){const e=[],t=u=>{for(const d of u)if(d.type==="element"){if(d.tag==="tr"){e.push(d);continue}(d.tag==="tbody"||d.tag==="thead"||d.tag==="tfoot")&&t(d.children)}};if(t(n),e.length===0)return"";const o=e.map(u=>u.children.filter(d=>d.type==="element"&&(d.tag==="td"||d.tag==="th")).map(d=>as(d.children))),r=o.reduce((u,d)=>Math.max(u,d.length),0);if(r===0)return"";const i=u=>u.length===r?u:[...u,...Array(r-u.length).fill("")],[l,...s]=o.map(i);return[`| ${(l??Array(r).fill("")).join(" | ")} |`,`| ${Array(r).fill("---").join(" | ")} |`,...s.map(u=>`| ${u.join(" | ")} |`)].join(`
58
+ `)}function as(n){return H(n,{inTableCell:!0}).replace(/\n+/g,"<br>").replace(/\|/g,"\\|").trim()}function H(n,e={}){let t="";for(const o of n){if(o.type==="text"){t+=Y(o.value);continue}const r=()=>H(o.children,e);switch(o.tag){case"br":t+=e.inTableCell?`
46
59
  `:`
47
- `;break;case"b":case"strong":{const i=l();n+=i.trim()===""?i:`**${i}**`;break}case"i":case"em":{const i=l();n+=i.trim()===""?i:`*${i}*`;break}case"s":case"del":case"strike":{const i=l();n+=i.trim()===""?i:`~~${i}~~`;break}case"code":{const i=Ie(o.children),r="`".repeat(yn(i)+1),s=i.startsWith("`")||i.endsWith("`")?" ":"";n+=`${r}${s}${i}${s}${r}`;break}case"a":{const i=o.attrs.href,r=l();n+=i?`[${r}](${ce(i)})`:r;break}case"img":{const i=o.attrs.src;i&&(n+=`![${Y(o.attrs.alt??"")}](${ce(i)})`);break}case"u":case"sub":case"sup":case"mark":n+=`<${o.tag}>${l()}</${o.tag}>`;break;default:n+=l();break}}return n}function Y(t){return t.replace(ni,"\\$1")}function Mt(t){return t.replace(oi,"\\$1")}function yn(t){let e=0,n=0;for(const o of t)o==="`"?(n+=1,n>e&&(e=n)):n=0;return e}function ce(t){const e=t.trim();return/[\s()]/.test(e)?`<${e.replace(/[<>]/g,"")}>`:e}function ai(t,e={}){const n=e.blockSeparator??`
60
+ `;break;case"b":case"strong":{const i=r();t+=i.trim()===""?i:`**${i}**`;break}case"i":case"em":{const i=r();t+=i.trim()===""?i:`*${i}*`;break}case"s":case"del":case"strike":{const i=r();t+=i.trim()===""?i:`~~${i}~~`;break}case"code":{const i=xt(o.children),l="`".repeat(co(i)+1),s=i.startsWith("`")||i.endsWith("`")?" ":"";t+=`${l}${s}${i}${s}${l}`;break}case"a":{const i=o.attrs.href,l=r();t+=i?`[${l}](${ge(i)})`:l;break}case"img":{const i=o.attrs.src;i&&(t+=`![${Y(o.attrs.alt??"")}](${ge(i)})`);break}case"u":case"sub":case"sup":case"mark":t+=`<${o.tag}>${r()}</${o.tag}>`;break;default:t+=r();break}}return t}function Y(n){return n.replace(os,"\\$1")}function sn(n){return n.replace(rs,"\\$1")}function co(n){let e=0,t=0;for(const o of n)o==="`"?(t+=1,t>e&&(e=t)):t=0;return e}function ge(n){const e=n.trim();return/[\s()]/.test(e)?`<${e.replace(/[<>]/g,"")}>`:e}function cs(n,e={}){const t=e.blockSeparator??`
48
61
 
49
- `,o=e.cellSeparator??" ",l=[];for(const i of pe(t)){const r=ci(i,o);r!==""&&l.push(r)}return l.join(n)}function ci(t,e){switch(t.kind){case"hr":case"youtube":return"";case"image":return ee([t.attrs.alt,t.attrs.caption].filter(Boolean).join(`
50
- `));case"linkCard":return ee(t.attrs.text??t.attrs.href??"");case"file":return ee(t.attrs.fileName??"");case"bulletList":case"orderedList":case"taskList":return Te(J(t.html),"li").map(o=>ee(de(o.children))).filter(o=>o!=="").join(`
51
- `);case"table":return di(J(t.html),e);default:return ee(de(J(t.html)))}}function di(t,e){const n=[],o=l=>{for(const i of l)i.type==="element"&&(i.tag==="tr"?n.push(i):["tbody","thead","tfoot"].includes(i.tag)&&o(i.children))};return o(t),n.map(l=>l.children.filter(i=>i.type==="element"&&(i.tag==="td"||i.tag==="th")).map(i=>ee(de(i.children)).replace(/\n+/g," ")).join(e)).filter(l=>l.replace(new RegExp(ui(e),"g"),"").trim()!=="").join(`
52
- `)}function ee(t){return t.replace(Ke,"").split(`
62
+ `,o=e.cellSeparator??" ",r=[];for(const i of ye(n)){const l=ds(i,o);l!==""&&r.push(l)}return r.join(t)}function ds(n,e){switch(n.kind){case"hr":case"youtube":return"";case"image":return re([n.attrs.alt,n.attrs.caption].filter(Boolean).join(`
63
+ `));case"linkCard":return re(n.attrs.text??n.attrs.href??"");case"file":return re(n.attrs.fileName??"");case"bulletList":case"orderedList":case"taskList":return me(ie(n.html),"li").map(o=>re(Me(o.children))).filter(o=>o!=="").join(`
64
+ `);case"table":return us(ie(n.html),e);default:return re(Me(ie(n.html)))}}function us(n,e){const t=[],o=r=>{for(const i of r)i.type==="element"&&(i.tag==="tr"?t.push(i):["tbody","thead","tfoot"].includes(i.tag)&&o(i.children))};return o(n),t.map(r=>r.children.filter(i=>i.type==="element"&&(i.tag==="td"||i.tag==="th")).map(i=>re(Me(i.children)).replace(/\n+/g," ")).join(e)).filter(r=>r.replace(new RegExp(hs(e),"g"),"").trim()!=="").join(`
65
+ `)}function re(n){return n.replace(st,"").split(`
53
66
  `).map(e=>e.replace(/[^\S\n]+/g," ").trim()).join(`
54
67
  `).replace(/\n{3,}/g,`
55
68
 
56
- `).trim()}function ui(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}exports.ALIGN_CLASS_BY_VALUE=Ee;exports.ALL_INLINE_MARKS=le;exports.AerizEditor=Il;exports.AerizViewer=Fl;exports.BLOCK_ID_ATTR=P;exports.BLOCK_TYPES=Je;exports.BLOCK_TYPE_BY_KIND=U;exports.BlockIdRegistry=Qe;exports.DEFAULT_TOOLBAR=Nt;exports.SNAPSHOT_VERSION=Jt;exports.applyBlockClassNames=ot;exports.applyBlockInlineStyles=nt;exports.assignMissingIds=ae;exports.blocksToMarkdown=li;exports.blocksToPlainText=ai;exports.classifyBlockElement=_;exports.decodeEntities=V;exports.escapeAttr=x;exports.escapeHtml=R;exports.extractInlineContent=rn;exports.fillInlineContent=sn;exports.findBlockFrom=xe;exports.getBlockLabel=tn;exports.getLocale=En;exports.isElementBlank=z;exports.listBlocks=Le;exports.normalizeContent=ye;exports.parseHtmlFragment=J;exports.placeCaretAtStart=M;exports.readBlockStyleTheme=tt;exports.renderBlock=on;exports.renderBlockToHTML=Wl;exports.renderBlocks=ln;exports.renderBlocksToHTML=jl;exports.restoreAlignFromClasses=an;exports.serializeBlock=nn;exports.serializeBlocks=et;exports.serializeNodes=Ne;exports.setLocale=zt;exports.snapshotVersionOf=Qt;exports.stripEditorOnlyAttrs=lt;exports.stripEditorOnlyNodes=Be;exports.t=p;exports.textOf=Ie;exports.textWithBlockBreaks=de;exports.upgradeSnapshot=Ve;exports.upgradeSnapshots=pe;typeof globalThis.AerizWysiwyg=="object"&&(globalThis.AerizEditor=globalThis.AerizWysiwyg.AerizEditor,globalThis.AerizViewer=globalThis.AerizWysiwyg.AerizViewer);
69
+ `).trim()}function hs(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}exports.AerizEditor=rt;exports.AerizViewer=Fl;exports.DEFAULT_FONTS=un;exports.DEFAULT_FONT_SIZES=hn;exports.DEFAULT_TOOLBAR=an;exports.SNAPSHOT_VERSION=Rn;exports.blocksToMarkdown=is;exports.blocksToPlainText=cs;exports.htmlToBlocks=oo;exports.markdownToBlocks=Zn;exports.markdownToHtml=Jn;exports.renderBlocksToHTML=Gl;exports.sanitizeHTML=lo;exports.upgradeSnapshots=ye;typeof globalThis.AerizWysiwyg=="object"&&(globalThis.AerizEditor=globalThis.AerizWysiwyg.AerizEditor,globalThis.AerizViewer=globalThis.AerizWysiwyg.AerizViewer);