@aeriz/wysiwyg 1.0.2 → 1.0.3

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 (108) hide show
  1. package/README.md +610 -96
  2. package/angular/README.md +112 -0
  3. package/angular/aeriz-editor.directive.ts +243 -0
  4. package/angular/aeriz-wysiwyg.module.ts +14 -0
  5. package/angular/index.ts +5 -0
  6. package/dist/adapters/jquery.cjs +1 -0
  7. package/dist/adapters/jquery.js +91 -0
  8. package/dist/adapters/react.cjs +1 -0
  9. package/dist/adapters/react.js +66 -0
  10. package/dist/adapters/shared.cjs +1 -0
  11. package/dist/adapters/shared.js +87 -0
  12. package/dist/adapters/svelte.cjs +1 -0
  13. package/dist/adapters/svelte.js +29 -0
  14. package/dist/adapters/vue.cjs +1 -0
  15. package/dist/adapters/vue.js +110 -0
  16. package/dist/adapters/vue2.cjs +1 -0
  17. package/dist/adapters/vue2.js +117 -0
  18. package/dist/adapters/wc.cjs +1 -0
  19. package/dist/adapters/wc.js +207 -0
  20. package/dist/aeriz-wysiwyg-adapter.js +169 -0
  21. package/dist/aeriz-wysiwyg-adapter.min.js +1 -0
  22. package/dist/aeriz-wysiwyg-jquery.js +275 -0
  23. package/dist/aeriz-wysiwyg-jquery.min.js +1 -0
  24. package/dist/aeriz-wysiwyg-wc.js +401 -0
  25. package/dist/aeriz-wysiwyg-wc.min.js +1 -0
  26. package/dist/aeriz-wysiwyg.cjs +6912 -0
  27. package/dist/aeriz-wysiwyg.css +37 -129
  28. package/dist/aeriz-wysiwyg.esm.js +1170 -149
  29. package/dist/aeriz-wysiwyg.esm.min.js +2057 -1209
  30. package/dist/aeriz-wysiwyg.js +1169 -148
  31. package/dist/aeriz-wysiwyg.min.cjs +54 -0
  32. package/dist/aeriz-wysiwyg.min.css +1 -1
  33. package/dist/aeriz-wysiwyg.min.js +44 -13
  34. package/dist/server.cjs +32 -0
  35. package/dist/server.js +666 -0
  36. package/dist-types/adapters/jquery.d.ts +34 -0
  37. package/dist-types/adapters/jquery.d.ts.map +1 -0
  38. package/dist-types/adapters/react.d.ts +28 -0
  39. package/dist-types/adapters/react.d.ts.map +1 -0
  40. package/dist-types/adapters/shared.d.ts +83 -0
  41. package/dist-types/adapters/shared.d.ts.map +1 -0
  42. package/dist-types/adapters/svelte.d.ts +38 -0
  43. package/dist-types/adapters/svelte.d.ts.map +1 -0
  44. package/dist-types/adapters/vue.d.ts +189 -0
  45. package/dist-types/adapters/vue.d.ts.map +1 -0
  46. package/dist-types/adapters/vue2.d.ts +175 -0
  47. package/dist-types/adapters/vue2.d.ts.map +1 -0
  48. package/dist-types/adapters/wc.d.ts +96 -0
  49. package/dist-types/adapters/wc.d.ts.map +1 -0
  50. package/dist-types/cjs/adapters/jquery.d.cts +34 -0
  51. package/dist-types/cjs/adapters/react.d.cts +28 -0
  52. package/dist-types/cjs/adapters/shared.d.cts +83 -0
  53. package/dist-types/cjs/adapters/svelte.d.cts +38 -0
  54. package/dist-types/cjs/adapters/vue.d.cts +189 -0
  55. package/dist-types/cjs/adapters/vue2.d.cts +175 -0
  56. package/dist-types/cjs/adapters/wc.d.cts +96 -0
  57. package/dist-types/cjs/core/AerizEditor.d.cts +357 -0
  58. package/dist-types/cjs/core/AerizViewer.d.cts +61 -0
  59. package/dist-types/cjs/core/block-meta.d.cts +32 -0
  60. package/dist-types/cjs/core/blocks.d.cts +368 -0
  61. package/dist-types/cjs/core/fonts.d.cts +60 -0
  62. package/dist-types/cjs/core/highlight.d.cts +44 -0
  63. package/dist-types/cjs/core/html-mini.d.cts +65 -0
  64. package/dist-types/cjs/core/i18n.d.cts +209 -0
  65. package/dist-types/cjs/core/import-html.d.cts +39 -0
  66. package/dist-types/cjs/core/import-markdown.d.cts +37 -0
  67. package/dist-types/cjs/core/markdown-export.d.cts +30 -0
  68. package/dist-types/cjs/core/plain-text.d.cts +17 -0
  69. package/dist-types/cjs/core/render-string.d.cts +68 -0
  70. package/dist-types/cjs/core/snapshot.d.cts +51 -0
  71. package/dist-types/cjs/index.d.cts +20 -0
  72. package/dist-types/cjs/server/index.d.cts +37 -0
  73. package/dist-types/cjs/types/index.d.cts +61 -0
  74. package/dist-types/cjs/ui/Toolbar.d.cts +21 -0
  75. package/dist-types/cjs/ui/dialogs.d.cts +74 -0
  76. package/dist-types/cjs/ui/icons.d.cts +2 -0
  77. package/dist-types/cjs/ui/popovers.d.cts +70 -0
  78. package/dist-types/core/AerizEditor.d.ts +30 -10
  79. package/dist-types/core/AerizEditor.d.ts.map +1 -1
  80. package/dist-types/core/AerizViewer.d.ts +16 -4
  81. package/dist-types/core/AerizViewer.d.ts.map +1 -1
  82. package/dist-types/core/block-meta.d.ts +32 -0
  83. package/dist-types/core/block-meta.d.ts.map +1 -0
  84. package/dist-types/core/blocks.d.ts +62 -7
  85. package/dist-types/core/blocks.d.ts.map +1 -1
  86. package/dist-types/core/fonts.d.ts +11 -0
  87. package/dist-types/core/fonts.d.ts.map +1 -1
  88. package/dist-types/core/html-mini.d.ts +65 -0
  89. package/dist-types/core/html-mini.d.ts.map +1 -0
  90. package/dist-types/core/import-html.d.ts.map +1 -1
  91. package/dist-types/core/markdown-export.d.ts +30 -0
  92. package/dist-types/core/markdown-export.d.ts.map +1 -0
  93. package/dist-types/core/plain-text.d.ts +17 -0
  94. package/dist-types/core/plain-text.d.ts.map +1 -0
  95. package/dist-types/core/render-string.d.ts +68 -0
  96. package/dist-types/core/render-string.d.ts.map +1 -0
  97. package/dist-types/core/snapshot.d.ts +51 -0
  98. package/dist-types/core/snapshot.d.ts.map +1 -0
  99. package/dist-types/index.d.ts +19 -10
  100. package/dist-types/index.d.ts.map +1 -1
  101. package/dist-types/server/index.d.ts +37 -0
  102. package/dist-types/server/index.d.ts.map +1 -0
  103. package/dist-types/types/index.d.ts +21 -0
  104. package/dist-types/types/index.d.ts.map +1 -1
  105. package/dist-types/ui/Toolbar.d.ts +1 -1
  106. package/dist-types/ui/popovers.d.ts +1 -1
  107. package/dist-types/ui/popovers.d.ts.map +1 -1
  108. package/package.json +213 -58
@@ -0,0 +1,54 @@
1
+ "use strict";var Pt=Object.defineProperty;var qt=(n,e,t)=>e in n?Pt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var w=(n,e,t)=>qt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ft={items:["blockType","|","fontFamily","fontSize","|","bold","italic","underline","strike","|","color","backgroundColor","|","align","|","cellBg","tableMenu","codeLang"],sticky:!0},A={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>'},jt={undo:{name:"undo",label:"되돌리기",icon:"undo",shortcut:"Ctrl+Z"},redo:{name:"redo",label:"다시 실행",icon:"redo",shortcut:"Ctrl+Y"},blockType:{name:"blockType",label:"블록 유형",icon:"blockType",hasDropdown:!0},fontFamily:{name:"fontFamily",label:"글꼴",icon:"fontFamily",hasDropdown:!0},fontSize:{name:"fontSize",label:"글자 크기",icon:"fontSize",hasDropdown:!0},bold:{name:"bold",label:"굵게",icon:"bold",shortcut:"Ctrl+B"},italic:{name:"italic",label:"기울임",icon:"italic",shortcut:"Ctrl+I"},underline:{name:"underline",label:"밑줄",icon:"underline",shortcut:"Ctrl+U"},strike:{name:"strike",label:"취소선",icon:"strike",shortcut:"Ctrl+Shift+X"},color:{name:"color",label:"글자색",icon:"color",hasDropdown:!0},backgroundColor:{name:"backgroundColor",label:"배경색",icon:"backgroundColor",hasDropdown:!0},align:{name:"align",label:"정렬",icon:"alignLeft",hasDropdown:!0},cellBg:{name:"cellBg",label:"셀 배경색",icon:"cellBg",hasDropdown:!0},tableMenu:{name:"tableMenu",label:"표 편집",icon:"tableMenu",hasDropdown:!0},codeLang:{name:"codeLang",label:"코드 언어",icon:"codeLang",hasDropdown:!0},bulletList:{name:"bulletList",label:"글머리 기호",icon:"bulletList",shortcut:"Ctrl+Shift+8"},orderedList:{name:"orderedList",label:"번호 매기기",icon:"orderedList",shortcut:"Ctrl+Shift+7"},blockquote:{name:"blockquote",label:"인용구",icon:"blockquote",shortcut:"Ctrl+Shift+9"},codeBlock:{name:"codeBlock",label:"코드 블록",icon:"codeBlock",shortcut:"Ctrl+Shift+C"},link:{name:"link",label:"링크",icon:"link",shortcut:"Ctrl+K"},image:{name:"image",label:"이미지",icon:"image"},table:{name:"table",label:"표",icon:"table"},hr:{name:"hr",label:"구분선",icon:"hr"},clearFormat:{name:"clearFormat",label:"서식 지우기",icon:"clearFormat",shortcut:"Ctrl+\\"}};class Ut{constructor(e,t){w(this,"element");w(this,"buttons",new Map);this.element=document.createElement("div"),this.element.className="aw-toolbar",this.element.setAttribute("role","toolbar"),this.element.setAttribute("aria-label","서식 도구 모음"),e.sticky!==!1&&this.element.classList.add("aw-toolbar-sticky");let o=this.createGroup();this.element.appendChild(o);for(const r of e.items){if(r==="|"){o=this.createGroup(),this.element.appendChild(o);continue}const i=jt[r];if(!i)continue;const l=this.createButton(i,t);this.buttons.set(i.name,l),o.appendChild(l)}}setActive(e,t){const o=this.buttons.get(e);o&&(o.classList.toggle("aw-toolbar-btn-active",t),o.setAttribute("aria-pressed",String(t)))}setEnabled(e,t){const o=this.buttons.get(e);o&&(o.disabled=!t)}setVisible(e,t){const o=this.buttons.get(e);o&&(o.style.display=t?"":"none")}syncGroupVisibility(){const e=this.element.querySelectorAll(".aw-toolbar-group");for(const t of Array.from(e)){const o=Array.from(t.children).some(r=>r instanceof HTMLElement&&r.style.display!=="none");t.style.display=o?"":"none"}}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",e.hasDropdown&&o.classList.add("aw-toolbar-btn-dropdown");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=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",l=>{l.preventDefault()}),o.addEventListener("click",()=>{t.onAction(e.name,o)}),o}}function Z(n,e){const t=document.createElement("div");t.className="aw-dialog-overlay",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),e&&(t.dataset.theme=e);const o=document.createElement("div");o.className="aw-dialog";const r=document.createElement("div");r.className="aw-dialog-header";const i=document.createElement("h2");i.className="aw-dialog-title",i.textContent=n;const l=document.createElement("button");l.type="button",l.className="aw-dialog-close",l.setAttribute("aria-label","닫기"),l.innerHTML=A.close,r.appendChild(i),r.appendChild(l);const s=document.createElement("div");s.className="aw-dialog-body";const c=document.createElement("div");c.className="aw-dialog-footer",o.appendChild(r),o.appendChild(s),o.appendChild(c),t.appendChild(o);const a=()=>t.remove();return l.addEventListener("click",a),t.addEventListener("click",d=>{d.target===t&&a()}),document.addEventListener("keydown",function d(u){u.key==="Escape"&&(a(),document.removeEventListener("keydown",d))}),{overlay:t,body:s,footer:c,close:a}}function H(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 Wt(n={},e){return new Promise(t=>{const{overlay:o,body:r,footer:i,close:l}=Z("링크 삽입",e),s=document.createElement("input");s.type="text",s.className="aw-input",s.placeholder="링크에 표시할 텍스트",s.value=n.text??"";const c=document.createElement("input");c.type="url",c.className="aw-input",c.placeholder="https://example.com",c.value=n.href??"";const a=document.createElement("label");a.className="aw-checkbox";const d=document.createElement("input");d.type="checkbox",d.checked=n.newWindow??!1;const u=document.createElement("span");u.textContent="새 창에서 열기",a.appendChild(d),a.appendChild(u),r.appendChild(H("표시할 텍스트",s)),r.appendChild(H("URL",c)),r.appendChild(a);const p=document.createElement("button");p.type="button",p.className="aw-btn aw-btn-ghost",p.textContent="취소";const f=document.createElement("button");f.type="button",f.className="aw-btn aw-btn-primary",f.textContent="확인",i.appendChild(p),i.appendChild(f),p.addEventListener("click",()=>{l(),t({confirmed:!1})}),f.addEventListener("click",()=>{l(),t({confirmed:!0,text:s.value,href:c.value,newWindow:d.checked})}),document.body.appendChild(o),setTimeout(()=>c.focus(),0)})}function Kt(n={},e){return new Promise(t=>{const{overlay:o,body:r,footer:i,close:l}=Z("이미지",e),s=document.createElement("div");s.className="aw-tabs";const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent="임베드",c.title="base64 데이터로 본문에 직접 삽입";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent="URL",a.title="이미지 URL 입력";const d=document.createElement("button");d.type="button",d.className="aw-tab",d.textContent="업로드";const u=!!n.onUpload;u?d.title="서버 API 로 업로드 후 결과 URL 사용":(d.disabled=!0,d.classList.add("aw-tab-disabled"),d.title="개체 생성시 등록된 API 주소가 없습니다."),s.appendChild(c),s.appendChild(a),s.appendChild(d),r.appendChild(s);const p=document.createElement("div");p.className="aw-pane";const f=Ye("이미지 파일 선택 (base64 임베드)"),g=document.createElement("div");g.className="aw-preview",g.style.display="none",p.appendChild(f.dropzone),p.appendChild(g);const h=document.createElement("div");h.className="aw-pane";const b=document.createElement("input");b.type="url",b.className="aw-input",b.placeholder="https://example.com/image.jpg",h.appendChild(H("이미지 URL",b));const m=document.createElement("div");if(m.className="aw-pane",u){const y=Ye("서버 업로드용 이미지 선택"),x=document.createElement("div");x.className="aw-preview",x.style.display="none",m.appendChild(y.dropzone),m.appendChild(x),y.input.addEventListener("change",async()=>{var z;const I=(z=y.input.files)==null?void 0:z[0];if(!(!I||!n.onUpload))try{y.dropzone.classList.add("aw-dropzone-loading");const oe=await n.onUpload(I);C=oe,x.style.backgroundImage=`url(${JSON.stringify(oe)})`,x.style.display="block"}catch(oe){console.error(oe)}finally{y.dropzone.classList.remove("aw-dropzone-loading"),y.input.value=""}})}else{const y=document.createElement("div");y.className="aw-pane-notice",y.textContent="개체 생성시 등록된 API 주소가 없습니다.",m.appendChild(y)}r.appendChild(p),r.appendChild(h),r.appendChild(m);let k="embed",S,C;const L=y=>{y==="upload"&&!u||(k=y,c.classList.toggle("aw-tab-active",y==="embed"),a.classList.toggle("aw-tab-active",y==="url"),d.classList.toggle("aw-tab-active",y==="upload"),p.style.display=y==="embed"?"block":"none",h.style.display=y==="url"?"block":"none",m.style.display=y==="upload"?"block":"none")};L(k),c.addEventListener("click",()=>L("embed")),a.addEventListener("click",()=>L("url")),d.addEventListener("click",()=>L("upload")),f.input.addEventListener("change",()=>{var I;const y=(I=f.input.files)==null?void 0:I[0];if(!y)return;const x=new FileReader;x.onload=()=>{const z=String(x.result??"");S=z,g.style.backgroundImage=`url(${JSON.stringify(z)})`,g.style.display="block",f.input.value=""},x.readAsDataURL(y)});const T=document.createElement("button");T.type="button",T.className="aw-btn aw-btn-ghost",T.textContent="취소";const B=document.createElement("button");B.type="button",B.className="aw-btn aw-btn-primary",B.textContent="확인",i.appendChild(T),i.appendChild(B),T.addEventListener("click",()=>{l(),t({confirmed:!1})}),B.addEventListener("click",()=>{let y;k==="embed"?y=S:k==="url"?y=b.value||void 0:k==="upload"&&(y=C),l();const x={confirmed:!0};y&&(x.src=y),t(x)}),document.body.appendChild(o)})}function Ye(n){const e=document.createElement("label");e.className="aw-dropzone",e.innerHTML=`
2
+ ${A.upload}
3
+ <div class="aw-dropzone-text">${n}<br/>드래그 앤 드롭 또는 클릭</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 Vt(n){return new Promise(e=>{const{overlay:t,body:o,footer:r,close:i}=Z("HTML",n),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
+ ${A.importHtml}
6
+ <div class="aw-dropzone-text">HTML 파일 선택<br/>드래그 앤 드롭 또는 클릭</div>
7
+ `,s.appendChild(l);const c=document.createElement("div");c.className="aw-dialog-hint",c.textContent="선택된 파일 없음";const a=document.createElement("textarea");a.className="aw-input aw-textarea",a.placeholder="또는 HTML 을 직접 붙여넣기…",a.rows=8,o.appendChild(s),o.appendChild(c),o.appendChild(H("직접 붙여넣기",a));const d=document.createElement("div");d.className="aw-dialog-hint",d.textContent="iframe 으로 로드한 후 모든 스타일을 인라인으로 합쳐 가져옵니다.",o.appendChild(d);let u;l.addEventListener("change",()=>{var b;const g=(b=l.files)==null?void 0:b[0];if(!g)return;const h=new FileReader;h.onload=()=>{u=String(h.result??""),a.value=u,c.textContent=`${g.name} (${g.size.toLocaleString()} bytes)`,l.value=""},h.readAsText(g)}),s.addEventListener("dragover",g=>{g.preventDefault(),s.classList.add("aw-dropzone-loading")}),s.addEventListener("dragleave",()=>{s.classList.remove("aw-dropzone-loading")}),s.addEventListener("drop",g=>{var m,k;g.preventDefault(),s.classList.remove("aw-dropzone-loading");const h=(k=(m=g.dataTransfer)==null?void 0:m.files)==null?void 0:k[0];if(!h)return;const b=new FileReader;b.onload=()=>{u=String(b.result??""),a.value=u,c.textContent=`${h.name} (${h.size.toLocaleString()} bytes)`},b.readAsText(h)});const p=document.createElement("button");p.type="button",p.className="aw-btn aw-btn-ghost",p.textContent="취소";const f=document.createElement("button");f.type="button",f.className="aw-btn aw-btn-primary",f.textContent="가져오기",r.appendChild(p),r.appendChild(f),p.addEventListener("click",()=>{i(),e({confirmed:!1})}),f.addEventListener("click",()=>{const g=a.value.trim();i();const h={confirmed:!0};g.length>0&&(h.html=g),e(h)}),document.body.appendChild(t)})}function Yt(n){return new Promise(e=>{const{overlay:t,body:o,footer:r,close:i}=Z("Markdown",n),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
+ ${A.importMarkdown}
9
+ <div class="aw-dropzone-text">Markdown 파일 선택<br/>드래그 앤 드롭 또는 클릭</div>
10
+ `,s.appendChild(l);const c=document.createElement("div");c.className="aw-dialog-hint",c.textContent="선택된 파일 없음";const a=document.createElement("textarea");a.className="aw-input aw-textarea",a.placeholder="또는 Markdown 을 직접 붙여넣기…",a.rows=8,o.appendChild(s),o.appendChild(c),o.appendChild(H("직접 붙여넣기",a));const d=document.createElement("div");d.className="aw-dialog-hint",d.textContent="CommonMark 기본 문법(제목/목록/링크/코드/표/인용 등) 지원",o.appendChild(d),l.addEventListener("change",()=>{var h;const f=(h=l.files)==null?void 0:h[0];if(!f)return;const g=new FileReader;g.onload=()=>{const b=String(g.result??"");a.value=b,c.textContent=`${f.name} (${f.size.toLocaleString()} bytes)`,l.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 b,m;f.preventDefault(),s.classList.remove("aw-dropzone-loading");const g=(m=(b=f.dataTransfer)==null?void 0:b.files)==null?void 0:m[0];if(!g)return;const h=new FileReader;h.onload=()=>{const k=String(h.result??"");a.value=k,c.textContent=`${g.name} (${g.size.toLocaleString()} bytes)`},h.readAsText(g)});const u=document.createElement("button");u.type="button",u.className="aw-btn aw-btn-ghost",u.textContent="취소";const p=document.createElement("button");p.type="button",p.className="aw-btn aw-btn-primary",p.textContent="가져오기",r.appendChild(u),r.appendChild(p),u.addEventListener("click",()=>{i(),e({confirmed:!1})}),p.addEventListener("click",()=>{const f=a.value.trim();i();const g={confirmed:!0};f.length>0&&(g.markdown=f),e(g)}),document.body.appendChild(t)})}function Gt(n={},e){return new Promise(t=>{const{overlay:o,body:r,footer:i,close:l}=Z("파일 첨부",e),s=document.createElement("div");s.className="aw-tabs";const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent="URL",c.title="이미 호스팅된 파일의 URL 직접 입력";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent="업로드";const d=!!n.onUpload;d?a.title="서버 API 로 업로드 후 응답 URL 사용":(a.disabled=!0,a.classList.add("aw-tab-disabled"),a.title="개체 생성시 등록된 파일 업로드 API 가 없습니다."),s.appendChild(c),s.appendChild(a),r.appendChild(s);const u=document.createElement("div");u.className="aw-pane";const p=document.createElement("input");p.type="url",p.className="aw-input",p.placeholder="https://example.com/files/report.pdf",u.appendChild(H("파일 URL",p));const f=document.createElement("input");f.type="text",f.className="aw-input",f.placeholder="표시할 파일명 (예: report.pdf)",u.appendChild(H("파일명",f));const g=document.createElement("div");g.className="aw-pane";let h;if(d){const C=document.createElement("label");C.className="aw-dropzone",C.innerHTML=`
11
+ ${A.upload}
12
+ <div class="aw-dropzone-text">서버 업로드용 파일 선택<br/>드래그 앤 드롭 또는 클릭</div>
13
+ `;const L=document.createElement("input");L.type="file",L.style.display="none",C.appendChild(L);const T=document.createElement("div");T.className="aw-dialog-hint",T.textContent="선택된 파일 없음",g.appendChild(C),g.appendChild(T);const B=async y=>{if(n.onUpload)try{C.classList.add("aw-dropzone-loading"),h={src:await n.onUpload(y),name:y.name,size:y.size,type:y.type||""},T.textContent=`${y.name} (${y.size.toLocaleString()} bytes) — 업로드 완료`}catch(x){console.error(x),T.textContent=`업로드 실패: ${x instanceof Error?x.message:String(x)}`}finally{C.classList.remove("aw-dropzone-loading"),L.value=""}};L.addEventListener("change",()=>{var x;const y=(x=L.files)==null?void 0:x[0];y&&B(y)}),C.addEventListener("dragover",y=>{y.preventDefault(),C.classList.add("aw-dropzone-loading")}),C.addEventListener("dragleave",()=>{C.classList.remove("aw-dropzone-loading")}),C.addEventListener("drop",y=>{var I,z;y.preventDefault();const x=(z=(I=y.dataTransfer)==null?void 0:I.files)==null?void 0:z[0];x&&B(x)})}else{const C=document.createElement("div");C.className="aw-pane-notice",C.textContent="개체 생성시 등록된 파일 업로드 API 가 없습니다.",g.appendChild(C)}r.appendChild(u),r.appendChild(g);let b="url";const m=C=>{C==="upload"&&!d||(b=C,c.classList.toggle("aw-tab-active",C==="url"),a.classList.toggle("aw-tab-active",C==="upload"),u.style.display=C==="url"?"block":"none",g.style.display=C==="upload"?"block":"none")};m(b),c.addEventListener("click",()=>m("url")),a.addEventListener("click",()=>m("upload"));const k=document.createElement("button");k.type="button",k.className="aw-btn aw-btn-ghost",k.textContent="취소";const S=document.createElement("button");S.type="button",S.className="aw-btn aw-btn-primary",S.textContent="확인",i.appendChild(k),i.appendChild(S),k.addEventListener("click",()=>{l(),t({confirmed:!1})}),S.addEventListener("click",()=>{const C={confirmed:!0};if(b==="url"){const L=p.value.trim(),T=f.value.trim();L.length>0&&(C.src=L),T.length>0&&(C.name=T)}else h&&(C.src=h.src,C.name=h.name,C.size=h.size,h.type&&(C.type=h.type));l(),t(C)}),document.body.appendChild(o)})}function Zt(n){return new Promise(e=>{const{overlay:t,body:o,footer:r,close:i}=Z("유튜브 임베드",n),l=document.createElement("input");l.type="url",l.className="aw-input",l.placeholder="https://www.youtube.com/watch?v=…",o.appendChild(H("YouTube URL",l));const s=document.createElement("div");s.className="aw-dialog-hint",s.textContent="youtu.be / youtube.com/watch / /embed / /shorts 형식 모두 지원",o.appendChild(s);const c=document.createElement("button");c.type="button",c.className="aw-btn aw-btn-ghost",c.textContent="취소";const a=document.createElement("button");a.type="button",a.className="aw-btn aw-btn-primary",a.textContent="확인",r.appendChild(c),r.appendChild(a),c.addEventListener("click",()=>{i(),e({confirmed:!1})}),a.addEventListener("click",()=>{i(),e({confirmed:!0,url:l.value})}),document.body.appendChild(t),setTimeout(()=>l.focus(),0)})}const Xt="system",G=[{id:Xt,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 n={};for(const e of G)n[e.id]=e;return n})();const Qt=[12,13,14,15,16,18,20,24,28,32,40,48];function Jt(n){if(!n)return null;const e=n.trim(),t=/^(\d+(?:\.\d+)?)px$/i.exec(e);if(t&&t[1])return Math.round(Number(t[1]));const o=/^(\d+(?:\.\d+)?)rem$/i.exec(e);return o&&o[1]?Math.round(Number(o[1])*16):null}let Ge=!1;const ce=new Set,$e=new Set,en="가A";function tn(){return ce.size===0?G:G.filter(n=>!ce.has(n.id))}function nn(n){return $e.add(n),()=>{$e.delete(n)}}function on(n){const e=de(n);if(!e)return!1;const t=document.createElement("canvas").getContext("2d");if(!t)return!1;const o=r=>(t.font=`16px ${r}`,t.measureText("가나다ABCwi").width);return["monospace","serif"].some(r=>o(`"${e}", ${r}`)!==o(r))}function Ne(n){let e=!1;for(const t of n)ce.has(t.id)||on(t.stack)||(ce.add(t.id),e=!0);if(e)for(const t of $e)t()}function Ze(n){const e=document.fonts;if(!(!e||typeof e.load!="function"))for(const t of n){const o=de(t.stack);o&&e.load(`16px "${o}"`,en).then(r=>{r.length===0&&Ne([t])}).catch(()=>Ne([t]))}}function rn(){if(Ge||(Ge=!0,typeof document>"u"))return;const n=G.filter(e=>e.googleFonts);if(n.length>0){const e="https://fonts.googleapis.com/css2?"+n.map(t=>`family=${t.googleFonts}`).join("&")+"&display=swap";Xe(e,n)}for(const e of G)e.cssUrl&&Xe(e.cssUrl,[e])}function Xe(n,e){if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`)){Ze(e);return}const o=document.createElement("link");o.rel="stylesheet",o.href=n,o.addEventListener("error",()=>Ne(e)),o.addEventListener("load",()=>Ze(e)),document.head.appendChild(o)}function ln(n){var o;if(!n)return null;const e=de(n);if(!e)return null;const t=e.toLowerCase();for(const r of G){const i=(o=de(r.stack))==null?void 0:o.toLowerCase();if(i&&i===t)return r.id}return null}function de(n){var t;const e=(t=n.split(",")[0])==null?void 0:t.trim();return e?e.replace(/^["']|["']$/g,""):null}const M={lineComment:"//",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},ht=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"]),sn=new Set([...ht,"any","as","asserts","boolean","declare","infer","is","keyof","module","namespace","never","number","object","override","readonly","require","satisfies","string","symbol","type","unique","unknown"]),an=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"]),cn=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"]),mt=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"]),dn=new Set([...mt,"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"]),un=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"]),pn=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"]),fn=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"]),hn=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"]),mn=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"]),gn=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"]),bn=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"]),yn=new Set(["true","false","null"]),gt=[{id:"plaintext",label:"Plain Text",keywords:new Set},{id:"javascript",label:"JavaScript",keywords:ht,...M,stringDelims:['"',"'","`"]},{id:"typescript",label:"TypeScript",keywords:sn,...M,stringDelims:['"',"'","`"]},{id:"python",label:"Python",keywords:an,builtins:cn,lineComment:"#",stringDelims:['"',"'"]},{id:"json",label:"JSON",keywords:yn,stringDelims:['"']},{id:"html",label:"HTML",keywords:new Set,custom:n=>xn(n)},{id:"css",label:"CSS",keywords:new Set,custom:n=>An(n)},{id:"bash",label:"Bash",keywords:gn,lineComment:"#",stringDelims:['"',"'"]},{id:"sql",label:"SQL",keywords:bn,caseInsensitiveKeywords:!0,lineComment:"--",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},{id:"markdown",label:"Markdown",keywords:new Set,custom:n=>Ln(n)},{id:"c",label:"C",keywords:mt,...M},{id:"cpp",label:"C++",keywords:dn,...M},{id:"csharp",label:"C#",keywords:un,...M},{id:"java",label:"Java",keywords:pn,...M},{id:"kotlin",label:"Kotlin",keywords:fn,...M},{id:"go",label:"Go",keywords:hn,...M},{id:"rust",label:"Rust",keywords:mn,...M}],wn=(()=>{const n=new Map;for(const e of gt)n.set(e.id,e);return n})();function kn(n,e){if(!e)return v(n);const t=wn.get(e);return t?t.custom?t.custom(n):vn(n,t):v(n)}function vn(n,e){var l,s;const t=!!e.caseInsensitiveKeywords;let o="",r=0;const i=n.length;for(;r<i;){if(e.lineComment&&n.startsWith(e.lineComment,r)){const d=n.indexOf(`
14
+ `,r),u=d===-1?i:d;o+=`<span class="hl-comment">${v(n.slice(r,u))}</span>`,r=u;continue}if(e.blockComment&&n.startsWith(e.blockComment.start,r)){const d=n.indexOf(e.blockComment.end,r+e.blockComment.start.length),u=d===-1?i:d+e.blockComment.end.length;o+=`<span class="hl-comment">${v(n.slice(r,u))}</span>`,r=u;continue}const c=(l=e.stringDelims)==null?void 0:l.find(d=>n.startsWith(d,r));if(c){let d=r+c.length;for(;d<i;){const u=n[d]??"";if(u==="\\"){d+=2;continue}if(n.startsWith(c,d)){d+=c.length;break}if(u===`
15
+ `&&c!=="`")break;d++}o+=`<span class="hl-string">${v(n.slice(r,d))}</span>`,r=d;continue}const a=n[r]??"";if(/[0-9]/.test(a)){const d=Cn.exec(n.slice(r));if(d){o+=`<span class="hl-number">${v(d[0])}</span>`,r+=d[0].length;continue}}if(/[a-zA-Z_$]/.test(a)){let d=r+1;for(;d<i&&/[a-zA-Z0-9_$]/.test(n[d]??"");)d++;const u=n.slice(r,d),p=t?u.toLowerCase():u;if(e.keywords.has(p))o+=`<span class="hl-keyword">${v(u)}</span>`;else if((s=e.builtins)!=null&&s.has(p))o+=`<span class="hl-builtin">${v(u)}</span>`;else{let f=d;for(;f<i&&(n[f]===" "||n[f]===" ");)f++;n[f]==="("?o+=`<span class="hl-fn">${v(u)}</span>`:o+=v(u)}r=d;continue}o+=v(a),r++}return o}const Cn=/^(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 xn(n){let e="",t=0;const o=n.length;for(;t<o;){if(n.startsWith("<!--",t)){const r=n.indexOf("-->",t+4),i=r===-1?o:r+3;e+=`<span class="hl-comment">${v(n.slice(t,i))}</span>`,t=i;continue}if(n[t]==="<"){const r=n.indexOf(">",t);if(r===-1){e+=v(n.slice(t));break}const i=n.slice(t,r+1);e+=En(i),t=r+1;continue}e+=v(n[t]??""),t++}return e}function En(n){const e=n.slice(1,-1);let t='<span class="hl-punct">&lt;</span>';const o=/^\/?[a-zA-Z][a-zA-Z0-9-]*/.exec(e);if(o){t+=`<span class="hl-tag">${v(o[0])}</span>`;let r=e.slice(o[0].length);const i=/\s+([a-zA-Z_:][a-zA-Z0-9_:.-]*)(\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+)))?/g;let l=0,s;for(;s=i.exec(r);){t+=v(r.slice(l,s.index)),t+=v(r.slice(s.index,s.index+s[0].indexOf(s[1]??""))),t+=`<span class="hl-attr">${v(s[1]??"")}</span>`;const c=r.slice(s.index+(s[0].indexOf(s[1]??"")+(s[1]??"").length),s.index+s[0].length);if(c.includes("=")){const a=c.indexOf("=");t+=v(c.slice(0,a+1));const d=c.slice(a+1);t+=`<span class="hl-string">${v(d)}</span>`}l=s.index+s[0].length}t+=v(r.slice(l))}else t+=v(e);return t+='<span class="hl-punct">&gt;</span>',t}function An(n){let e="",t=0;const o=n.length;let r=!1;for(;t<o;){if(n.startsWith("/*",t)){const l=n.indexOf("*/",t+2),s=l===-1?o:l+2;e+=`<span class="hl-comment">${v(n.slice(t,s))}</span>`,t=s;continue}const i=n[t]??"";if(i==="{"){r=!0,e+=v(i),t++;continue}if(i==="}"){r=!1,e+=v(i),t++;continue}if(i==='"'||i==="'"){const l=i;let s=t+1;for(;s<o&&n[s]!==l;)n[s]==="\\"?s+=2:s++;s=Math.min(s+1,o),e+=`<span class="hl-string">${v(n.slice(t,s))}</span>`,t=s;continue}if(/[a-zA-Z_-]/.test(i)||i==="@"||i==="#"||i==="."||i===":"){let l=t+1;for(;l<o&&/[a-zA-Z0-9_-]/.test(n[l]??"");)l++;const s=n.slice(t,l);if(i==="@")e+=`<span class="hl-keyword">${v(s)}</span>`;else if(r&&/^[a-zA-Z-]+$/.test(s)){let c=l;for(;c<o&&(n[c]===" "||n[c]===" ");)c++;n[c]===":"?e+=`<span class="hl-prop">${v(s)}</span>`:e+=v(s)}else e+=`<span class="hl-tag">${v(s)}</span>`;t=l;continue}if(/[0-9]/.test(i)){const l=/^[0-9.]+(px|em|rem|%|vh|vw|s|ms|deg|fr)?/.exec(n.slice(t));if(l){e+=`<span class="hl-number">${v(l[0])}</span>`,t+=l[0].length;continue}}e+=v(i),t++}return e}function Ln(n){return n.split(`
16
+ `).map(Sn).join(`
17
+ `)}function Sn(n){const e=/^(#{1,6})\s+(.*)$/.exec(n);if(e)return`<span class="hl-keyword">${v(e[1]??"")}</span> <span class="hl-tag">${ve(e[2]??"")}</span>`;if(n.startsWith(">"))return`<span class="hl-comment">${v(n)}</span>`;if(n.startsWith("```"))return`<span class="hl-keyword">${v(n)}</span>`;const t=/^(\s*)([-*+]|\d+\.)\s+(.*)$/.exec(n);return t?`${t[1]??""}<span class="hl-keyword">${v(t[2]??"")}</span> ${ve(t[3]??"")}`:ve(n)}function ve(n){let e=v(n);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(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function $(n){n.addEventListener("mousedown",e=>e.preventDefault())}const Be=["#000000","#5c5c5c","#9c9c9c","#cfcfcf","#ffffff","#e03131","#f76707","#f59f00","#94d82d","#0ca678","#1c7ed6","#7048e8","#d6336c","#fab005","#37b24d","#1098ad"];function Ce(n,e,t=[]){_();const o=document.createElement("div");o.className="aw-popover aw-color-popover",o.dataset.popover="true",$(o);const r=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,$(u),u.addEventListener("click",p=>{p.stopPropagation(),r(d)}),u},l=document.createElement("div");l.className="aw-color-grid";for(const d of Be)l.appendChild(i(d));o.appendChild(l);const s=document.createElement("button");s.type="button",s.className="aw-popover-action",s.textContent="기본색",$(s),s.addEventListener("click",d=>{d.stopPropagation(),r(null)});const c=document.createElement("button");c.type="button",c.className="aw-popover-action",c.textContent="사용자 지정",$(c);const a=document.createElement("input");if(a.type="color",a.tabIndex=-1,a.setAttribute("aria-hidden","true"),a.style.position="absolute",a.style.left="-9999px",a.style.width="0",a.style.height="0",a.style.opacity="0",a.style.pointerEvents="none",a.addEventListener("change",()=>{r(a.value)}),c.addEventListener("click",d=>{d.stopPropagation(),a.click()}),o.appendChild(s),o.appendChild(c),o.appendChild(a),t.length>0){const d=document.createElement("div");d.className="aw-color-section",d.textContent="최근 사용",o.appendChild(d);const u=document.createElement("div");u.className="aw-color-grid";for(const p of t)u.appendChild(i(p));o.appendChild(u)}F(o,n)}const Tn=[{label:"본문",kind:"paragraph",attrs:{},glyph:"¶"},{label:"제목 1",kind:"heading",attrs:{level:1},glyph:"H1",weight:"700"},{label:"제목 2",kind:"heading",attrs:{level:2},glyph:"H2",weight:"700"},{label:"제목 3",kind:"heading",attrs:{level:3},glyph:"H3",weight:"700"},{label:"글머리 목록",kind:"bulletList",attrs:{},glyph:A.bulletList,glyphIsSvg:!0,divider:!0},{label:"번호 매기기 목록",kind:"orderedList",attrs:{},glyph:A.orderedList,glyphIsSvg:!0},{label:"인용구",kind:"blockquote",attrs:{},glyph:A.blockquote,glyphIsSvg:!0,divider:!0},{label:"코드 블록",kind:"codeBlock",attrs:{},glyph:A.codeBlock,glyphIsSvg:!0},{label:"링크",kind:"linkCard",attrs:{},glyph:A.link,glyphIsSvg:!0,divider:!0},{label:"이미지",kind:"image",attrs:{},glyph:A.image,glyphIsSvg:!0},{label:"표",kind:"table",attrs:{},glyph:A.table,glyphIsSvg:!0},{label:"유튜브",kind:"youtube",attrs:{},glyph:A.youtube,glyphIsSvg:!0},{label:"파일 첨부",kind:"file",attrs:{},glyph:A.attachFile,glyphIsSvg:!0},{label:"구분선",kind:"hr",attrs:{},glyph:A.hr,glyphIsSvg:!0},{label:"HTML",kind:"importHtml",attrs:{},glyph:A.importHtml,glyphIsSvg:!0,divider:!0},{label:"Markdown",kind:"importMarkdown",attrs:{},glyph:A.importMarkdown,glyphIsSvg:!0}];function $n(n,e){_();const t=document.createElement("div");t.className="aw-popover aw-block-type-popover",t.dataset.popover="true",$(t);for(const o of Tn){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),$(r),r.addEventListener("click",s=>{s.stopPropagation(),t.remove(),e({kind:o.kind,attrs:o.attrs})}),t.appendChild(r)}F(t,n)}function Nn(n,e){_();const t=document.createElement("div");t.className="aw-popover aw-align-popover",t.dataset.popover="true",$(t);const o=[{icon:"alignLeft",value:"left",label:"왼쪽 정렬"},{icon:"alignCenter",value:"center",label:"가운데 정렬"},{icon:"alignRight",value:"right",label:"오른쪽 정렬"},{icon:"alignJustify",value:"justify",label:"양쪽 정렬"}];for(const r of o){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-popover-item-icon",i.setAttribute("aria-label",r.label),i.title=r.label,i.innerHTML=A[r.icon]??"",$(i),i.addEventListener("click",l=>{l.stopPropagation(),t.remove(),e(r.value)}),t.appendChild(i)}F(t,n)}function Bn(n,e,t){rn(),_();const o=document.createElement("div");o.className="aw-popover aw-font-family-popover",o.dataset.popover="true",$(o);const r=()=>{o.replaceChildren();for(const l of tn()){const s=document.createElement("button");s.type="button",s.className="aw-popover-item aw-font-family-item",t&&t===l.id&&s.classList.add("aw-popover-item-active"),s.title=l.label;const c=document.createElement("span");c.className="aw-font-family-name",c.textContent=l.label;const a=document.createElement("span");a.className="aw-font-family-preview",a.textContent="가A",a.style.fontFamily=l.stack,s.appendChild(c),s.appendChild(a),$(s),s.addEventListener("click",d=>{d.stopPropagation(),o.remove(),e({id:l.id,label:l.label,stack:l.stack})}),o.appendChild(s)}};r();const i=nn(()=>{if(!o.isConnected){i();return}r()});F(o,n)}function Mn(n,e,t){_();const o=document.createElement("div");o.className="aw-popover aw-code-lang-popover",o.dataset.popover="true",$(o);for(const r of gt){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-code-lang-item",t===r.id&&i.classList.add("aw-popover-item-active"),i.title=r.label;const l=document.createElement("span");l.className="aw-popover-item-label",l.textContent=r.label,i.appendChild(l),$(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({id:r.id,label:r.label})}),o.appendChild(i)}F(o,n)}const In=[{action:"rowAbove",label:"위에 행 추가"},{action:"rowBelow",label:"아래에 행 추가"},{action:"colLeft",label:"왼쪽에 열 추가",divider:!0},{action:"colRight",label:"오른쪽에 열 추가"},{action:"deleteRow",label:"행 삭제",divider:!0},{action:"deleteCol",label:"열 삭제"}];function zn(n,e){_();const t=document.createElement("div");t.className="aw-popover aw-table-menu-popover",t.dataset.popover="true",$(t);for(const o of In){if(o.divider){const i=document.createElement("div");i.className="aw-popover-divider",t.appendChild(i)}const r=document.createElement("button");r.type="button",r.className="aw-popover-item aw-table-menu-item",r.textContent=o.label,$(r),r.addEventListener("click",i=>{i.stopPropagation(),t.remove(),e(o.action)}),t.appendChild(r)}F(t,n)}function Rn(n,e,t){_();const o=document.createElement("div");o.className="aw-popover aw-font-size-popover",o.dataset.popover="true",$(o);for(const r of Qt){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-font-size-item",t===r&&i.classList.add("aw-popover-item-active"),i.title=`${r}px`;const l=document.createElement("span");l.className="aw-font-size-label",l.textContent=String(r),i.appendChild(l),$(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({px:r})}),o.appendChild(i)}F(o,n)}function Dn(n,e){_();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,c=t,a=0,d=0;const u=[];function p(){for(let h=0;h<u.length;h++){const b=u[h];if(b)for(let m=0;m<b.length;m++){const k=b[m];k&&k.classList.toggle("aw-table-cell-active",h<a&&m<d)}}l.textContent=a>0&&d>0?`${a} × ${d} 표`:"크기를 선택하세요"}function f(){i.innerHTML="",i.style.gridTemplateColumns=`repeat(${c}, 18px)`,i.style.gridTemplateRows=`repeat(${s}, 18px)`,u.length=0;for(let h=0;h<s;h++){const b=[];for(let m=0;m<c;m++){const k=document.createElement("div");k.className="aw-table-cell",k.dataset.row=String(h+1),k.dataset.col=String(m+1),i.appendChild(k),b.push(k)}u.push(b)}p()}f(),i.addEventListener("mousemove",h=>{const b=h.target;if(!b.classList.contains("aw-table-cell"))return;const m=parseInt(b.dataset.row??"0",10),k=parseInt(b.dataset.col??"0",10);a=m,d=k;let S=!1;m>=s&&s<o&&(s=Math.min(o,m+1),S=!0),k>=c&&c<o&&(c=Math.min(o,k+1),S=!0),S?f():p()}),i.addEventListener("click",h=>{const b=h.target;if(!b.classList.contains("aw-table-cell"))return;const m=parseInt(b.dataset.row??"0",10),k=parseInt(b.dataset.col??"0",10);m>0&&k>0&&(e({rows:m,cols:k}),r.remove())});function g(h){h.key==="Escape"&&(r.remove(),document.removeEventListener("keydown",g))}document.addEventListener("keydown",g),r.appendChild(i),r.appendChild(l),F(r,n)}function F(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";const r=()=>{const a=e.getBoundingClientRect();n.style.top=`${a.bottom+4}px`,n.style.left=`${a.left}px`};r(),document.body.appendChild(n);const i=()=>r(),l=()=>r();window.addEventListener("scroll",i,!0),window.addEventListener("resize",l);function s(a){!n.contains(a.target)&&!e.contains(a.target)&&n.remove()}setTimeout(()=>{document.addEventListener("click",s)},0);const c=n.remove.bind(n);n.remove=function(){window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",l),document.removeEventListener("click",s),c()}}function _(){document.querySelectorAll('[data-popover="true"]').forEach(n=>n.remove())}const Hn=["script","noscript","meta","link","style","base"],Fn=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"]),_n=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 On(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 c=document.createElement("iframe");c.setAttribute("aria-hidden","true"),c.setAttribute("tabindex","-1"),c.style.position="fixed",c.style.left="-99999px",c.style.top="0",c.style.width=`${r}px`,c.style.height="768px",c.style.border="0",c.style.opacity="0",c.style.pointerEvents="none";let a=!1;const d=()=>{c.parentNode&&c.parentNode.removeChild(c)},u=h=>{a||(a=!0,d(),s(h))},p=h=>{a||(a=!0,d(),l(h))},f=window.setTimeout(()=>{u(new Error("HTML 로드 시간 초과"))},o),g=()=>{var S;const h=c.contentDocument;if(!h||!h.body||h.body.children.length===0&&(h.body.textContent??"").trim()==="")return;const b=c.contentWindow,m=(b==null?void 0:b.requestAnimationFrame)??window.requestAnimationFrame;(h.fonts&&typeof((S=h.fonts.ready)==null?void 0:S.then)=="function"?h.fonts.ready:Promise.resolve()).then(()=>{const C=()=>{window.setTimeout(()=>{if(!a)try{const L=c.contentWindow,T=c.contentDocument;if(!L||!T||!T.body){window.clearTimeout(f),u(new Error("iframe document 접근 실패"));return}const B=Pn(T.body,L,i);window.clearTimeout(f),p(B)}catch(L){window.clearTimeout(f),u(L instanceof Error?L:new Error(String(L)))}},t)};m(()=>m(C))})};c.addEventListener("load",g),c.srcdoc=n,document.body.appendChild(c)})}function Pn(n,e,t){var l;const o=n.ownerDocument;if(!o)throw new Error("body has no ownerDocument");const r=document.createElement("div"),i=qn(o,e,t);try{for(let c=0;c<n.attributes.length;c++){const a=n.attributes.item(c);a&&a.name!=="style"&&r.setAttribute(a.name,a.value)}const s=ze(n,null,"div",i.get,e);s.length>0&&r.setAttribute("style",s);for(const c of Array.from(n.children)){const a=document.importNode(c,!0);bt(c,a,n,i.get,e),r.appendChild(a)}}finally{i.cleanup()}for(const s of Hn)for(const c of Array.from(r.querySelectorAll(s)))(l=c.parentNode)==null||l.removeChild(c);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 qn(n,e,t){var d;let o,r,i;const l=((d=t==null?void 0:t.ownerDocument)==null?void 0:d.defaultView)??null;if(t&&l){o=t.ownerDocument,r=l;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;",t.appendChild(u),i=u}else{o=n,r=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 p=s.get(u);if(p)return p;const f=o.createElement(u);i.appendChild(f);const g=r.getComputedStyle(f),h=new Map;for(let b=0;b<g.length;b++){const m=g.item(b);m&&h.set(m,g.getPropertyValue(m))}return i.removeChild(f),s.set(u,h),h},cleanup:()=>{i.parentNode&&i.parentNode.removeChild(i)}}}function ze(n,e,t,o,r,i){const l=r.getComputedStyle(n,i??null),s=e?r.getComputedStyle(e):null,c=o(t);let a="";for(let d=0;d<l.length;d++){const u=l.item(d);if(!u)continue;const p=l.getPropertyValue(u);if(p&&!(i&&u==="content")&&!(_n.has(u)&&p===l.getPropertyValue("color"))){if(Fn.has(u)){if(s&&s.getPropertyValue(u)===p)continue}else if(c.get(u)===p)continue;a+=`${u}:${p};`}}return a}function jn(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 Un=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","UL","OL","DL","SELECT","OPTGROUP"]);function Qe(n,e,t,o,r){if(Un.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 c=jn(s),a=/url\((["']?)([^"')]+)\1\)/.exec(s),d=ze(n,n,"span",o,r,i);if(!c&&!a&&!d)return;const u=e.ownerDocument,p=u.createElement("span");if(p.setAttribute("data-imported-pseudo",t),d&&p.setAttribute("style",d),a!=null&&a[2]){const f=u.createElement("img");f.setAttribute("src",a[2]),f.setAttribute("alt",""),p.appendChild(f)}c&&p.appendChild(u.createTextNode(c)),t==="before"?e.insertBefore(p,e.firstChild):e.appendChild(p)}function bt(n,e,t,o,r){if(n.nodeType===1&&e.nodeType===1){const c=ze(n,t,n.tagName.toLowerCase(),o,r);c.length>0?e.setAttribute("style",c):e.hasAttribute("style")&&e.removeAttribute("style")}const i=n.children,l=e.children,s=Math.min(i.length,l.length);for(let c=0;c<s;c++){const a=i[c],d=l[c];a&&d&&bt(a,d,n,o,r)}n.nodeType===1&&e.nodeType===1&&(Qe(n,e,"before",o,r),Qe(n,e,"after",o,r))}function Wn(n){const e=Kn(n),t=document.createElement("div");t.innerHTML=e;const o=[];for(const r of Array.from(t.children))r instanceof HTMLElement&&o.push(r);return o}function Kn(n){const t=n.replace(/\r\n?/g,`
18
+ `).replace(/\s+$/,"").split(`
19
+ `),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 a=l[1]??"",d=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]??"");)d.push(t[r]??""),r++;r<t.length&&r++;const u=a?` data-language="${Q(a)}"`:"";o.push(`<pre><code${u}>${ae(d.join(`
20
+ `))}</code></pre>`);continue}const s=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(i);if(s){const a=(s[1]??"#").length;o.push(`<h${a}>${V(s[2]??"")}</h${a}>`),r++;continue}if(/^[\s]*([-*_])(\s*\1){2,}[\s]*$/.test(i)){o.push("<hr>"),r++;continue}if(yt(i,t[r+1]??"")){const a=[i];for(r++,a.push(t[r]??""),r++;r<t.length&&(t[r]??"").includes("|")&&(t[r]??"").trim()!=="";)a.push(t[r]??""),r++;o.push(Yn(a));continue}if(i.startsWith(">")){const a=[];for(;r<t.length&&(t[r]??"").startsWith(">");)a.push((t[r]??"").replace(/^>\s?/,"")),r++;const d=V(a.join(" ").trim());o.push(`<blockquote><p>${d}</p></blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(i)){const a=Je(t,r,/^[\s]*[-*+]\s+(.*)$/);r=a.next,o.push(`<ul>${a.html}</ul>`);continue}if(/^[\s]*\d+\.\s+/.test(i)){const a=Je(t,r,/^[\s]*\d+\.\s+(.*)$/);r=a.next,o.push(`<ol>${a.html}</ol>`);continue}const c=[];for(;r<t.length&&(t[r]??"").trim()!==""&&!Vn(t[r]??"",t[r+1]??"");)c.push(t[r]??""),r++;c.length>0&&o.push(`<p>${V(Gn(c))}</p>`)}return o.join(`
21
+ `)}function Vn(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)||yt(n,e)}function yt(n,e){return n.includes("|")?/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/.test(e):!1}function Yn(n){if(n.length<2)return"";const e=xe(n[0]??""),o=xe(n[1]??"").map(s=>{const c=s.trim(),a=c.startsWith(":"),d=c.endsWith(":");return a&&d?"center":d?"right":a?"left":null}),r=n.slice(2).map(xe),i=e.map((s,c)=>{const a=o[c];return`<th${a?` style="text-align:${a}"`:""}>${V(s.trim())}</th>`}).join(""),l=r.map(s=>`<tr>${s.map((a,d)=>{const u=o[d];return`<td${u?` style="text-align:${u}"`:""}>${V(a.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 Je(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>${V(l[1]??"")}</li>`),r++}return{html:o.join(""),next:r}}function Gn(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
+ <br>
23
+ `):e.push(r?o:o+" ")}return e.join("")}const ue="",Zn=new RegExp(ue+"([0-9]+)"+ue,"g");function V(n){const e=[];let t=n.replace(/(`+)([\s\S]+?)\1/g,(o,r,i)=>{const l=e.push(`<code>${ae(i)}</code>`)-1;return`${ue}${l}${ue}`});return t=ae(t),t=t.replace(/&lt;(https?:\/\/[^\s&]+)&gt;/g,(o,r)=>`<a href="${Q(r)}" target="_blank" rel="noopener">${ae(r)}</a>`),t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,r,i)=>`<img src="${Q(i)}" alt="${Q(r)}">`),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,r,i)=>`<a href="${Q(i)}" target="_blank" rel="noopener">${r}</a>`),t=t.replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^_\n]+?)__/g,"<strong>$1</strong>"),t=t.replace(/(^|[^*])\*([^*\n]+?)\*(?!\*)/g,"$1<em>$2</em>"),t=t.replace(/(^|[^_])_([^_\n]+?)_(?!_)/g,"$1<em>$2</em>"),t=t.replace(/~~([^~\n]+?)~~/g,"<s>$1</s>"),t=t.replace(Zn,(o,r)=>{const i=Number(r);return e[i]??""}),t}function ae(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Q(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function wt(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 kt(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 Re(n){try{return new URL(n).hostname}catch{return""}}function vt(n){const e=Re(n);return e?`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`:""}const Ct='<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>',xt='<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>',Et="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",De="https://www.youtube-nocookie.com/embed/",At="파일",R="data-block-id",Lt=1;function St(n){const e=n.version;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:1}const Xn=new Set(["paragraph","heading","bulletList","orderedList","blockquote","codeBlock","image","table","hr","linkCard","youtube","file","importedHtml","unknown"]);function te(n){return n.map(e=>He(e))}function He(n){const e=Xn.has(n.kind)?n.kind:"unknown",t=Math.max(St(n),1);return{...n,kind:e,version:t,html:typeof n.html=="string"?n.html:""}}const ne=["bold","italic","underline","strike"],Qn={kind:"paragraph",label:"단락",allowsInlineFormat:!0,allowedMarks:ne,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="P"?{kind:"paragraph",attrs:{}}:null,create:()=>we(document.createElement("p")),isEmpty:n=>q(n)},Jn={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=vo(n==null?void 0:n.level);return we(document.createElement(`h${e}`))},isEmpty:n=>q(n)},eo={kind:"bulletList",label:"글머리 목록",allowsInlineFormat:!0,allowedMarks:ne,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="UL"?{kind:"bulletList",attrs:{}}:null,create:()=>Dt("ul"),isEmpty:n=>Ht(n)},to={kind:"orderedList",label:"번호 매기기 목록",allowsInlineFormat:!0,allowedMarks:ne,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="OL"?{kind:"orderedList",attrs:{}}:null,create:()=>Dt("ol"),isEmpty:n=>Ht(n)},no={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(we(document.createElement("p"))),n},isEmpty:n=>q(n)},oo={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),e.appendChild(t),e},isEmpty:n=>q(n)},ro={kind:"image",label:"이미지",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{if(n.tagName==="FIGURE"){const e=n.querySelector(":scope > img"),t=rt(e),o=n.getAttribute("style");return o&&(t.wrapperStyle=o),{kind:"image",attrs:t}}return n.tagName==="IMG"?{kind:"image",attrs:rt(n)}:null},create:n=>{const e=document.createElement("figure");n!=null&&n.wrapperStyle&&e.setAttribute("style",n.wrapperStyle);const t=document.createElement("img");return n!=null&&n.src&&(t.src=n.src),n!=null&&n.alt&&(t.alt=n.alt),e.appendChild(t),e.appendChild(_e()),e.appendChild(Fe()),e},isEmpty:n=>{const e=n.tagName==="IMG"?n:n.querySelector(":scope > img");return!e||!e.getAttribute("src")}};function Fe(){const n=document.createElement("span");return n.className="aw-resize-handle",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n}function _e(){const n=document.createElement("span");n.className="aw-block-align-controls",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true");for(const e of["left","center","right"]){const t=document.createElement("button");t.type="button",t.className="aw-block-align-btn",t.dataset.align=e,t.title=e==="left"?"왼쪽 정렬":e==="center"?"가운데 정렬":"오른쪽 정렬",t.setAttribute("aria-label",t.title),t.innerHTML=io[e],n.appendChild(t)}return n}const 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>'},lo={kind:"table",label:"표",allowsInlineFormat:!0,allowedMarks:ne,allowsColor:!0,allowsFontSize:!0,matches:n=>{var r;if(n.tagName!=="TABLE")return null;const e=n.querySelectorAll(":scope > tbody > tr, :scope > tr"),t=e.length,o=((r=e[0])==null?void 0:r.children.length)??0;return{kind:"table",attrs:{rows:t,cols:o}}},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 c=document.createElement("td");c.appendChild(document.createElement("br")),l.appendChild(c)}r.appendChild(l)}return o.appendChild(r),o},isEmpty:n=>n.querySelectorAll(":scope tr").length===0},so={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},ao={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=(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=`${De}${e}`),o.setAttribute("allow",Et),o.setAttribute("allowfullscreen",""),o.setAttribute("frameborder","0"),o.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),t.appendChild(o),t.appendChild(_e()),t.appendChild(Fe()),t},isEmpty:n=>!n.getAttribute("data-youtube-id")},co={kind:"linkCard",label:"링크",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{var s,c,a,d,u;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)??((c=n.querySelector(":scope > .aw-link-card-text"))==null?void 0:c.textContent)??void 0,o=((a=n.querySelector(":scope > .aw-link-card-body > .aw-link-card-desc"))==null?void 0:a.textContent)??void 0,r=((d=n.querySelector(":scope > .aw-link-card-image"))==null?void 0:d.getAttribute("src"))??void 0,i=((u=n.querySelector(":scope .aw-link-card-favicon"))==null?void 0:u.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=(n==null?void 0:n.href)??"#",t=n!=null&&n.text&&n.text.length>0?n.text:Re(e)||e,o=(n==null?void 0:n.description)??"",r=(n==null?void 0:n.image)??"",i=(n==null?void 0:n.favicon)??vt(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 u=document.createElement("img");u.className="aw-link-card-image",u.src=r,u.alt="",u.loading="lazy",l.appendChild(u)}const s=document.createElement("span");s.className="aw-link-card-body";const c=document.createElement("span");if(c.className="aw-link-card-title",c.textContent=t,s.appendChild(c),o){const u=document.createElement("span");u.className="aw-link-card-desc",u.textContent=o,s.appendChild(u)}const a=document.createElement("span");if(a.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",a.appendChild(u)}const d=document.createElement("span");return d.className="aw-link-card-url-text",d.textContent=e,a.appendChild(d),s.appendChild(a),l.appendChild(s),l},isEmpty:n=>!n.getAttribute("href")},uo={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"),n!=null&&n.fileSrc&&(e.href=n.fileSrc),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 t=document.createElement("span");t.className="aw-file-icon",t.setAttribute("aria-hidden","true"),t.innerHTML=Ct;const o=document.createElement("span");o.className="aw-file-meta";const r=document.createElement("span");r.className="aw-file-name",r.textContent=(n==null?void 0:n.fileName)??At,o.appendChild(r);const i=[],l=kt(n==null?void 0:n.fileName,n==null?void 0:n.fileType);if(l&&i.push(l),(n==null?void 0:n.fileSize)!==void 0&&i.push(wt(n.fileSize)),i.length>0){const c=document.createElement("span");c.className="aw-file-info",c.textContent=i.join(" · "),o.appendChild(c)}const s=document.createElement("span");return s.className="aw-file-action",s.setAttribute("aria-hidden","true"),s.innerHTML=xt,e.appendChild(t),e.appendChild(o),e.appendChild(s),e},isEmpty:n=>!n.getAttribute("href")},po={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},Tt={kind:"unknown",label:"알 수 없음",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:()=>null,create:()=>we(document.createElement("div")),isEmpty:n=>q(n)},Oe=[Qn,Jn,eo,to,no,oo,ro,lo,so,co,ao,uo,po],N=(()=>{const n={unknown:Tt};for(const e of Oe)n[e.kind]=e;return n})();function P(n){for(const e of Oe){const t=e.matches(n);if(t)return{type:e,match:t}}return{type:Tt,match:{kind:"unknown",attrs:{}}}}class Pe{constructor(){w(this,"counter",0);w(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(R);if(t)return this.seen.add(t),t;const o=this.generate();return e.setAttribute(R,o),o}get(e){return e.getAttribute(R)}}function pe(n,e){const t=new Set;for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const r=o.getAttribute(R);if(r&&!t.has(r)){t.add(r),e.observe(r);continue}const i=e.generate();o.setAttribute(R,i),t.add(i)}}function Me(n){Rt(n);for(const e of Array.from(n.childNodes)){if(e.nodeType!==Node.TEXT_NODE)continue;if((e.textContent??"").trim().length===0){e.remove();continue}const o=document.createElement("p");n.replaceChild(o,e),o.appendChild(e)}for(const e of Array.from(n.querySelectorAll("hr")))e.getAttribute("contenteditable")!=="false"&&e.setAttribute("contenteditable","false");for(const e of Array.from(n.querySelectorAll("a.aw-link-card")))e.getAttribute("contenteditable")!=="false"&&e.setAttribute("contenteditable","false");for(const e of Array.from(n.querySelectorAll("div.aw-youtube-embed")))e.getAttribute("contenteditable")!=="false"&&e.setAttribute("contenteditable","false");for(const e of Array.from(n.querySelectorAll("a.aw-file-attachment")))e.getAttribute("contenteditable")!=="false"&&e.setAttribute("contenteditable","false");for(const e of Array.from(n.querySelectorAll("figure, div.aw-youtube-embed")))e instanceof HTMLElement&&(e.querySelector(":scope > .aw-block-align-controls")||e.appendChild(_e()),e.querySelector(":scope > .aw-resize-handle")||e.appendChild(Fe()))}function $t(n){switch(n.kind){case"paragraph":return"단락";case"heading":return`제목 ${n.attrs.level??1}`;case"bulletList":return"글머리 목록";case"orderedList":return"번호 목록";case"blockquote":return"인용구";case"codeBlock":return"코드";case"image":return"이미지";case"table":return"표";case"hr":return"구분선";case"linkCard":return"링크";case"youtube":return"유튜브";case"file":return"파일";case"importedHtml":return"HTML";default:return"?"}}function Nt(n){const e=n.element.getAttribute("style");return{version:Lt,id:n.id,kind:n.kind,attrs:{...n.attrs},html:fo(n.element),...e?{style:e}:{}}}function fo(n){if(!n.querySelector(".aw-block-align-controls, .aw-resize-handle"))return n.innerHTML;const e=n.cloneNode(!0);return ye(e),e.innerHTML}function qe(n){return n.map(Nt)}function Bt(n){const t=(N[n.kind]??N.unknown).create(n.attrs);return t.setAttribute(R,n.id),n.style&&t.setAttribute("style",n.style),n.html.length>0&&(t.innerHTML=n.html),t}function Mt(n,e){for(;n.firstChild;)n.removeChild(n.firstChild);for(const t of te(e))n.appendChild(Bt(t))}function fe(n,e){const t=[];for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const{match:r}=P(o);t.push({id:e(o),kind:r.kind,attrs:r.attrs,element:o})}return t}function he(n,e,t){let o=n;for(;o&&o!==e;){if(o.parentNode===e&&o.nodeType===Node.ELEMENT_NODE){const r=o,{match:i}=P(r);return{id:t(r),kind:i.kind,attrs:i.attrs,element:r}}o=o.parentNode}return null}function It(n){const e=n.element;switch(n.kind){case"paragraph":case"heading":return Array.from(e.childNodes);case"bulletList":case"orderedList":{const t=Array.from(e.querySelectorAll(":scope > li"));return et(t)}case"blockquote":{const t=Array.from(e.querySelectorAll(":scope > p"));return t.length>0?et(t):Array.from(e.childNodes)}case"codeBlock":{const t=e.querySelector(":scope > code");return t?Array.from(t.childNodes):Array.from(e.childNodes)}default:return[]}}function et(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 zt(n,e,t){if(t.length===0)return;let o=null;switch(e){case"paragraph":case"heading":o=n;break;case"bulletList":case"orderedList":o=n.querySelector(":scope > li");break;case"blockquote":o=n.querySelector(":scope > p");break;case"codeBlock":o=n.querySelector(":scope > code");break;default:return}if(!o)return;for(;o.firstChild;)o.removeChild(o.firstChild);for(const i of t)o.appendChild(i);const r=N[e];r&&ho(o,r)}function ho(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")){tt(o);continue}if(r==="span"||r==="font"){const i=o.style;if(!t.has("bold")){const a=i.fontWeight;(a==="bold"||a==="bolder"||/^[7-9]\d{2}$|^1000$/.test(a))&&i.removeProperty("font-weight")}!t.has("italic")&&i.fontStyle==="italic"&&i.removeProperty("font-style");const l=i.textDecorationLine||i.textDecoration||"";if(l){const a=l.split(/\s+/),d=a.filter(u=>!(u==="underline"&&!t.has("underline")||u==="line-through"&&!t.has("strike")));d.length!==a.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"),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,c=Array.from(o.attributes).some(a=>a.name!=="style");!s&&!c&&tt(o)}}}function tt(n){const e=n.parentNode;if(e){for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n)}}function mo(n={}){const e=n.fg||"currentColor",t=n.bg||"transparent",o=n.mode==="dark"?!0:n.mode==="light"?!1:go(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 go(n,e){const t=nt(n);if(t!==null)return t>.5;const o=nt(e);return o!==null?o<.5:!0}function nt(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 je(n){const e=getComputedStyle(n),t=a=>{const d=e.getPropertyValue(a).trim();return d.length>0?d:void 0},o={},r=t("--aw-primary"),i=t("--aw-fg"),l=t("--aw-bg"),s=t("--aw-border"),c=t("--aw-fg-muted");return r&&(o.primary=r),i&&(o.fg=i),l&&(o.bg=l),s&&(o.border=s),c&&(o.fgMuted=c),o}function bo(n){const e=`color-mix(in srgb, ${n.primary} 8%, transparent)`,t=`color-mix(in srgb, ${n.fg} 6%, ${n.bg})`;return`${n.fg}${n.bg}`,{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 yo(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 Ue(n,e={}){const t=mo(e),o=bo(t),r=yo(t);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")){Ee(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}const l=o[i.tagName];l&&Ee(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]")||Ee(s,l))}function Ee(n,e){const t=(n.getAttribute("style")??"").trim();if(!t){const s=e.replace(/;\s*$/,"").trim();s&&n.setAttribute("style",s);return}const o=ot(t),r=new Set(o.map(s=>s.prop)),l=[...ot(e).filter(s=>!r.has(s.prop)),...o].map(s=>`${s.prop}:${s.value}`).join(";");l?n.setAttribute("style",l):n.removeAttribute("style")}function ot(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 me={left:"aw-align-left",center:"aw-align-center",right:"aw-align-right",justify:"aw-align-justify"};function We(n){for(const e of Array.from(n.children)){if(!(e instanceof HTMLElement))continue;const{match:t}=P(e);e.classList.add("aw-block",`aw-block-${t.kind}`)}for(const e of Array.from(n.querySelectorAll("[style]")))e.closest("[data-imported-html]")||wo(e)}function wo(n){var r;const e=n.style.textAlign.trim().toLowerCase(),t=me[e],o=Object.values(me).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 Rt(n){var e;for(const[t,o]of Object.entries(me))for(const r of Array.from(n.querySelectorAll(`.${o}`)))r.style.textAlign||(r.style.textAlign=t),r.classList.remove(o),((e=r.getAttribute("class"))==null?void 0:e.trim())===""&&r.removeAttribute("class")}function ye(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 Ke(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-explicit]")))e.removeAttribute("data-block-explicit")}function j(n){const e=document.getSelection();if(!e)return;const t=document.createRange();if(n.tagName==="HR")t.setStartAfter(n);else{const o=ko(n);t.selectNodeContents(o),t.collapse(!0)}e.removeAllRanges(),e.addRange(t)}function ko(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 we(n){return n.appendChild(document.createElement("br")),n}function Dt(n){const e=document.createElement(n),t=document.createElement("li");return t.appendChild(document.createElement("br")),e.appendChild(t),e}function Ht(n){const e=n.querySelectorAll(":scope > li");return e.length===0?!0:e.length===1?q(e[0]):!1}function q(n){return(n.textContent??"").replace(/​/g,"").trim().length===0}function vo(n){return n===void 0||n<1?1:n>6?6:n}function rt(n){if(!n)return{};const e={},t=n.getAttribute("src"),o=n.getAttribute("alt");return t&&(e.src=t),o&&(e.alt=o),e}const it={bulletList:"bulletList",orderedList:"orderedList",blockquote:"blockquote",codeBlock:"codeBlock"},Ae="application/x-aeriz-block",lt=80;class Co{constructor(e){w(this,"root");w(this,"content");w(this,"toolbar",null);w(this,"contentWrap");w(this,"handlesLayer");w(this,"dropIndicator");w(this,"handles",new Map);w(this,"blockLabelPill");w(this,"statusBar");w(this,"statusBlockEl");w(this,"statusBlocksEl");w(this,"statusCharsEl");w(this,"statusSourceEl");w(this,"options");w(this,"observer");w(this,"blockIds",new Pe);w(this,"idFor",e=>this.blockIds.ensure(e));w(this,"listeners",new Set);w(this,"handleSelectionChange",()=>this.queueSync());w(this,"handleResize",()=>this.repositionHandles());w(this,"state",$o());w(this,"destroyed",!1);w(this,"syncQueued",!1);w(this,"lastSerialized","");w(this,"recentCustomColors",[]);w(this,"cellSelStart",null);w(this,"cellSelDrag",!1);w(this,"codeHighlightTimer",null);w(this,"tableResize",null);if(!(e.element instanceof HTMLElement))throw new TypeError("AerizEditor: options.element must be an HTMLElement");if(this.options=e,e.locale&&(e.locale,void 0),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??ft;this.toolbar=new Ut(l,{onAction:(s,c)=>this.handleToolbarAction(s,c)}),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.innerHTML=e.initialHTML??"<p><br></p>",Me(this.content),pe(this.content,this.blockIds),this.lastSerialized=this.content.innerHTML,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="블록 유형 변경",this.blockLabelPill.addEventListener("mousedown",l=>l.preventDefault()),this.blockLabelPill.addEventListener("click",l=>{l.stopPropagation();const s=this.state.activeBlockId??void 0;this.openBlockTypeMenu(this.blockLabelPill,s)}),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";const o=dt("되돌리기 (Ctrl+Z)",A.undo,()=>{this.content.focus(),document.execCommand("undo")}),r=dt("다시 실행 (Ctrl+Y)",A.redo,()=>{this.content.focus(),document.execCommand("redo")});this.statusBlockEl=document.createElement("span"),this.statusBlockEl.className="aw-status-item",t.appendChild(o),t.appendChild(r),t.appendChild(this.statusBlockEl);const i=document.createElement("div");i.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",i.appendChild(this.statusBlocksEl),i.appendChild(this.statusCharsEl),i.appendChild(this.statusSourceEl),this.statusBar.appendChild(t),this.statusBar.appendChild(i),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.handleCellSelStart(l)),this.content.addEventListener("mousemove",l=>this.handleCellSelMove(l)),document.addEventListener("mouseup",()=>this.handleCellSelEnd()),this.content.addEventListener("input",()=>this.scheduleCodeHighlight()),this.content.addEventListener("dragstart",l=>{const s=l.target;s&&(s.closest(".aw-block-handle")||s.closest("table")&&l.preventDefault())}),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 t=this.content.cloneNode(!0);if((e.styles??this.options.htmlStyles??"inline")==="class")We(t);else{const r=je(this.root),i=this.currentTheme();i&&(r.mode=i),Ue(t,r)}return Ke(t),ye(t),t.innerHTML}getRawHTML(){return this.content.innerHTML}setHTML(e){this.content.innerHTML=e,this.flush()}focus(){this.content.focus()}setTheme(e){this.root.dataset.theme=e}getState(){return this.state}getBlocks(){return fe(this.content,this.idFor)}serialize(){return qe(this.getBlocks())}findBlockById(e){const t=this.content.querySelector(`[data-block-id="${e}"]`);return t?he(t,this.content,this.idFor):null}getActiveBlock(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).commonAncestorContainer;return this.content.contains(t)?he(t,this.content,this.idFor):null}setBlockType(e,t,o){const r=N[e];if(!r)return;const i=o?this.findBlockById(o):this.getActiveBlock(),l=i?this.replaceBlock(i,r,t):this.appendBlock(r,t);this.flush(),this.content.focus(),j(l)}replaceBlock(e,t,o){const r=It(e),i=t.create(o);return zt(i,t.kind,r),i.setAttribute("data-block-explicit","true"),e.element.replaceWith(i),i}appendBlock(e,t){const o=e.create(t);return o.setAttribute("data-block-explicit","true"),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),window.removeEventListener("resize",this.handleResize),this.handles.clear(),this.listeners.clear(),this.root.remove())}flush(){var t,o;if(this.destroyed)return;Me(this.content),pe(this.content,this.blockIds),this.observer.takeRecords();const e=this.content.innerHTML;e!==this.lastSerialized&&(this.lastSerialized=e,(o=(t=this.options).onChange)==null||o.call(t,this.getHTML())),this.queueSync()}handleToolbarAction(e,t){switch(e){case"blockType":{const o=this.state.activeBlockId??void 0;this.openBlockTypeMenu(t,o);break}case"fontFamily":{if(!st(this.getActiveBlock()))return;const o=this.detectActiveFontId();Bn(t,r=>this.applyFontFamily(r.stack),o??void 0);break}case"fontSize":{if(!at(this.getActiveBlock()))return;const o=this.detectActiveFontSize();Rn(t,r=>this.applyFontSize(r.px),o??void 0);break}case"color":{if(!re(this.getActiveBlock()))return;Ce(t,o=>this.handleColorPick(o,"foreColor"),this.recentCustomColors);break}case"backgroundColor":{if(!re(this.getActiveBlock()))return;Ce(t,o=>this.handleColorPick(o,"hiliteColor"),this.recentCustomColors);break}case"align":{if(!Le(this.getActiveBlock()))return;Nn(t,o=>this.applyAlign(o));break}case"cellBg":{if(!ie(this.getActiveBlock()))return;const o=this.getSelectedTableCells();if(o.length===0)return;Ce(t,r=>this.applyCellBgToCells(o,r),this.recentCustomColors);break}case"tableMenu":{if(!ie(this.getActiveBlock()))return;zn(t,o=>this.runTableMenu(o));break}case"codeLang":{const o=this.getActiveBlock();if(!o||o.kind!=="codeBlock")return;const r=o.element.querySelector(":scope > code"),i=(r==null?void 0:r.getAttribute("data-language"))??void 0;Mn(t,l=>this.applyCodeLanguage(o.element,l.id),i);break}case"bold":case"italic":case"underline":case"strike":this.applyMark(e);break}}applyMark(e){const t=this.getActiveBlock();if(!X(t,e))return;this.content.focus(),document.execCommand("styleWithCSS",!1,"true");const o=e==="strike"?"strikeThrough":e;document.execCommand(o),this.queueSync()}handleColorPick(e,t){e&&!Be.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||!Le(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=t.element.querySelector(":scope > p");i instanceof HTMLElement&&(r=i)}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=le(i.startContainer);if(!l||!o.contains(l))return[];if(i.collapsed)return[l];const s=le(i.endContainer);return!s||!o.contains(s)||s===l?[l]:Se(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=Se(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}px`,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&&!Be.includes(t)&&(this.recentCustomColors=[t,...this.recentCustomColors.filter(r=>r!==t)].slice(0,8)),this.clearCellSelection(),this.flush())}runTableMenu(e){switch(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 t=this.getActiveTableCell();if(!t)return;const o=t.closest("tr");if(!o||!o.parentNode)return;const r=o.children.length,i=document.createElement("tr");for(let l=0;l<r;l++){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 t=this.getActiveTableCell();if(!t)return;const o=t.closest("tr");if(!o)return;const r=Array.from(o.children).indexOf(t);if(r<0)return;const i=o.closest("table");if(i){for(const l of Array.from(i.querySelectorAll("tr"))){const s=l.children[r];if(!s)continue;const c=s.tagName.toLowerCase(),a=document.createElement(c);a.appendChild(document.createElement("br")),e==="left"?l.insertBefore(a,s):l.insertBefore(a,s.nextSibling)}this.flush()}}deleteRow(){const e=this.getActiveTableCell();if(!e)return;const t=e.closest("tr");if(!t)return;const o=t.closest("table");o&&(o.querySelectorAll("tr").length<=1||(t.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 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=e.textContent??"",r=Eo(e);e.innerHTML=kn(o,t),r&&Ao(e,r)}rehighlightAllCodeBlocks(){const e=this.content.querySelectorAll(":scope > pre > code");for(const t of Array.from(e)){const o=t.getAttribute("data-language")??void 0;o&&this.rehighlightCode(t,o)}}deleteColumn(){var l;const e=this.getActiveTableCell();if(!e)return;const t=e.closest("tr");if(!t)return;const o=Array.from(t.children).indexOf(e);if(o<0)return;const r=t.closest("table");if(!r)return;const i=r.querySelector("tr");if(!(i&&i.children.length<=1)){for(const s of Array.from(r.querySelectorAll("tr")))(l=s.children[o])==null||l.remove();this.flush()}}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=ct(t,e.clientX,e.clientY);this.content.style.cursor=o==="right"?"col-resize":o==="bottom"?"row-resize":""}handleTableResizeStart(e){var c;if(e.button!==0)return;const t=e.target,o=t==null?void 0:t.closest(".aw-resize-handle");if(o instanceof HTMLElement){const a=o.parentElement;if(a instanceof HTMLElement&&(a.tagName==="FIGURE"||a.tagName==="DIV"&&a.classList.contains("aw-youtube-embed"))){e.preventDefault(),e.stopPropagation(),this.startBlockResize(a,e.clientX);return}}const r=(c=t==null?void 0:t.closest)==null?void 0:c.call(t,"td, th");if(!(r instanceof HTMLTableCellElement))return;const i=ct(r,e.clientX,e.clientY);if(!i)return;if(e.preventDefault(),e.stopPropagation(),i==="right"){const a=r.closest("tr"),d=a?Array.from(a.children).indexOf(r):-1,u=r.closest("table");if(!u||d<0)return;const p=[];for(const f of Array.from(u.querySelectorAll("tr"))){const g=f.children[d];g instanceof HTMLTableCellElement&&p.push(g)}this.tableResize={kind:"col",startX:e.clientX,startY:e.clientY,initialSize:r.getBoundingClientRect().width,targetCells:p,targetRow:null},document.body.style.cursor="col-resize"}else{const a=r.closest("tr");if(!(a instanceof HTMLTableRowElement))return;this.tableResize={kind:"row",startX:e.clientX,startY:e.clientY,initialSize:a.getBoundingClientRect().height,targetCells:[],targetRow:a},document.body.style.cursor="row-resize"}const l=a=>this.handleTableResizeMove(a),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`}}}handleBlockAlignClick(e){var i,l;const t=(l=(i=e.target)==null?void 0:i.closest)==null?void 0:l.call(i,".aw-block-align-btn");if(!(t instanceof HTMLButtonElement))return;const o=t.dataset.align;if(o!=="left"&&o!=="center"&&o!=="right")return;const r=t.closest("figure, div.aw-youtube-embed");r instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),o==="center"?(r.style.marginLeft="auto",r.style.marginRight="auto"):o==="right"?(r.style.marginLeft="auto",r.style.marginRight="0"):(r.style.marginLeft="0",r.style.marginRight="auto"),this.flush())}startBlockResize(e,t){const o=e.getBoundingClientRect().width,r=this.contentInnerWidth();document.body.style.cursor="nwse-resize",e.classList.add("aw-resizing");const i=s=>{const c=s.clientX-t,a=Math.max(lt,o+c);e.style.width=`${Math.round(Math.min(a,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(lt,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),this.queueSync()}detectActiveFontId(){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=getComputedStyle(t).fontFamily;return ln(o)}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 s=o.getRangeAt(0),c=le(s.startContainer),a=le(s.endContainer);if(c&&a&&c!==a&&this.content.contains(c)&&this.content.contains(a)){const d=c.closest("table");if(d instanceof HTMLTableElement){this.applyFontSizeToCells(Se(d,c,a),e);return}}}this.content.focus();const r=document.getSelection();if(!r||r.rangeCount===0)return;const i=r.getRangeAt(0);if(!this.content.contains(i.commonAncestorContainer))return;const l=document.createElement("span");if(l.style.fontSize=`${e}px`,i.collapsed){l.appendChild(document.createTextNode("​")),i.insertNode(l);const s=document.createRange();s.selectNodeContents(l),s.collapse(!1),r.removeAllRanges(),r.addRange(s)}else{try{i.surroundContents(l)}catch{const c=i.extractContents();l.appendChild(c),i.insertNode(l)}r.removeAllRanges();const s=document.createRange();s.selectNodeContents(l),r.addRange(s)}this.queueSync()}detectActiveFontSize(){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=getComputedStyle(t).fontSize;return Jt(o)}openBlockTypeMenu(e,t){$n(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"){Dn(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){Wt({},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.resolveImageUploadFn();Kt({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{o.confirmed&&o.src&&this.setBlockType("image",{src:o.src},e),this.queueSync()})}openYouTubeDialogAndApply(e){Zt(this.currentTheme()).then(t=>{if(!t.confirmed||!t.url)return;const o=Lo(t.url);o&&this.setBlockType("youtube",{videoId:o},e)})}openImportHtmlDialogAndApply(e){Vt(this.currentTheme()).then(async t=>{if(!t.confirmed)return;if(!t.html||t.html.length===0){window.alert("가져올 HTML 이 비어 있습니다.");return}let o;try{o=await On(t.html,{mountTarget:this.content})}catch(s){console.error("HTML 가져오기 실패:",s);const c=s instanceof Error?s.message:String(s);window.alert(`HTML 가져오기 실패: ${c}`);return}if(o.length===0){window.alert("HTML 에서 가져올 본문이 없습니다.");return}const r=e?this.content.querySelector(`[data-block-id="${e}"]`):null,i=[];for(const s of o){const c=Bo(s.tagName)?s:(()=>{const a=document.createElement("p");return a.appendChild(s),a})();c.setAttribute("data-block-explicit","true"),i.push(c)}if(r)if(r.tagName==="P"&&(r.textContent??"").trim().length===0&&i.length>0){const c=i[0];r.replaceWith(c);let a=c;for(let d=1;d<i.length;d++){const u=i[d];a.after(u),a=u}}else{let c=r;for(const a of i)c.after(a),c=a}else for(const s of i)this.content.appendChild(s);this.flush(),this.content.focus();const l=i[i.length-1];l&&j(l)})}openMarkdownImportDialogAndApply(e){Yt(this.currentTheme()).then(t=>{if(!t.confirmed)return;if(!t.markdown||t.markdown.length===0){window.alert("가져올 Markdown 이 비어 있습니다.");return}let o;try{o=Wn(t.markdown)}catch(l){console.error("Markdown 파싱 실패:",l);const s=l instanceof Error?l.message:String(l);window.alert(`Markdown 가져오기 실패: ${s}`);return}if(o.length===0){window.alert("Markdown 에서 가져올 본문이 없습니다.");return}for(const l of o)l.setAttribute("data-block-explicit","true");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 c=s;for(let a=1;a<o.length;a++){const d=o[a];c.after(d),c=d}}else{let s=r;for(const c of o)s.after(c),s=c}else for(const l of o)this.content.appendChild(l);this.flush(),this.content.focus();const i=o[o.length-1];i&&j(i)})}openFileAttachmentDialogAndApply(e){const t=this.resolveFileUploadFn();Gt({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{if(!o.confirmed)return;if(!o.src||o.src.length===0){window.alert("파일 URL 이 비어 있습니다.");return}const r={fileSrc:o.src},i=o.name&&o.name.length>0?o.name:So(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)})}resolveFileUploadFn(){if(this.options.onFileUpload)return this.options.onFileUpload;const e=this.options.fileUploadUrl;if(e)return async t=>{const o=new FormData;o.append("file",t);const r=await fetch(e,{method:"POST",body:o});if(!r.ok)throw new Error(`파일 업로드 실패: ${r.status}`);const i=await r.json(),l=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof l!="string"||l.length===0)throw new Error("파일 업로드 응답에 url 필드가 없습니다.");return l}}resolveImageUploadFn(){if(this.options.onImageUpload)return this.options.onImageUpload;const e=this.options.imageUploadUrl;if(e)return async t=>{const o=new FormData;o.append("file",t);const r=await fetch(e,{method:"POST",body:o});if(!r.ok)throw new Error(`이미지 업로드 실패: ${r.status}`);const i=await r.json(),l=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof l!="string"||l.length===0)throw new Error("이미지 업로드 응답에 url 필드가 없습니다.");return l}}insertImageBlock(e){this.setBlockType("image",{src:e})}queueSync(){this.syncQueued||this.destroyed||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,!this.destroyed&&this.sync()}))}sync(){const e=fe(this.content,this.idFor),t=this.getActiveBlock(),r=t!==null?{bold:se("bold"),italic:se("italic"),underline:se("underline"),strike:se("strikeThrough")}:{bold:!1,italic:!1,underline:!1,strike:!1};this.state={blocks:e,activeBlockId:(t==null?void 0:t.id)??null,inline:r},this.syncBlockMarkers((t==null?void 0:t.id)??null),this.syncBlockHandles(e),this.syncBlockLabelPill(t),this.syncStatusBar(t,e),this.applyToolbarState(this.state,t);for(const i of this.listeners)i(this.state)}handleKeyDown(e){if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.isComposing){const r=e.key.toLowerCase();let i=null;if(!e.shiftKey&&r==="b"?i="bold":!e.shiftKey&&r==="i"?i="italic":!e.shiftKey&&r==="u"?i="underline":e.shiftKey&&r==="x"&&(i="strike"),i){e.preventDefault(),this.applyMark(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();o&&(o.kind==="blockquote"||o.kind==="codeBlock")&&this.exitBlockOnEnter(e,o.element)}exitBlockOnEnter(e,t){e.preventDefault();const o=document.createElement("p");o.appendChild(document.createElement("br")),t.insertAdjacentElement("afterend",o),j(o),this.flush()}syncBlockHandles(e){const t=new Set;for(const o of e){t.add(o.id);let r=this.handles.get(o.id);r||(r=this.createBlockHandle(o.id),this.handlesLayer.appendChild(r),this.handles.set(o.id,r)),this.positionHandle(r,o.element)}for(const[o,r]of this.handles)t.has(o)||(r.remove(),this.handles.delete(o))}repositionHandles(){if(this.destroyed)return;for(const o of this.state.blocks){const r=this.handles.get(o.id);r&&this.positionHandle(r,o.element)}const e=this.state.activeBlockId,t=e?this.state.blocks.find(o=>o.id===e):null;this.syncBlockLabelPill(t??null)}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","블록 이동"),o.title="드래그로 블록 이동",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(Ae,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="아래에 단락 추가",r.setAttribute("aria-label","아래에 단락 추가"),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;const o=document.createElement("p");o.appendChild(document.createElement("br")),t.insertAdjacentElement("afterend",o),this.flush(),this.content.focus(),j(o)}handleDragOver(e){if(!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(Ae))return;e.preventDefault(),e.dataTransfer.dropEffect="move";const t=this.findDropTarget(e.clientY);t&&this.showDropIndicator(t)}handleDrop(e){if(!e.dataTransfer)return;const t=e.dataTransfer.getData(Ae);if(!t)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||(o.before?this.content.insertBefore(r,i):this.content.insertBefore(r,i.nextSibling))}handleDragLeave(e){this.content.contains(e.relatedTarget)||this.hideDropIndicator()}findDropTarget(e){for(const o of this.state.blocks){const r=o.element.getBoundingClientRect(),i=r.top+r.height/2;if(e<i)return{id:o.id,before:!0}}const t=this.state.blocks[this.state.blocks.length-1];return t?{id:t.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";return}const{type:t,match:o}=P(e.element),r=Te(e.element,t,o);this.blockLabelPill.textContent=r,this.blockLabelPill.style.display="inline-flex";const i=e.element.getBoundingClientRect(),l=this.contentWrap.getBoundingClientRect(),s=Math.max(0,i.top-l.top+this.contentWrap.scrollTop-12),c=i.left-l.left+4;this.blockLabelPill.style.top=`${s}px`,this.blockLabelPill.style.left=`${c}px`}syncStatusBar(e,t){if(e){const{type:l,match:s}=P(e.element);let c=Te(e.element,l,s);if(e.kind==="codeBlock"){const a=e.element.querySelector(":scope > code"),d=a==null?void 0:a.getAttribute("data-language");d&&(c+=` · ${d}`)}this.statusBlockEl.textContent=c}else this.statusBlockEl.textContent="— 선택된 블록 없음";this.statusBlocksEl.textContent=`${t.length} 블록`;const o=(this.content.textContent??"").replace(/\s+/g,""),r=Array.from(o).length;this.statusCharsEl.textContent=`텍스트 ${r} 자`;const i=this.content.innerHTML.length;this.statusSourceEl.textContent=`소스 ${To(i)}`}syncBlockMarkers(e){for(const t of Array.from(this.content.children)){if(!(t instanceof HTMLElement))continue;const{type:o,match:r}=P(t);t.setAttribute("data-block-kind",r.kind),t.setAttribute("data-block-label",Te(t,o,r));const i=this.blockIds.get(t);i&&i===e?t.setAttribute("data-block-focused",""):t.hasAttribute("data-block-focused")&&t.removeAttribute("data-block-focused")}this.observer.takeRecords()}applyToolbarState(e,t){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(it)){const r=it[o];this.toolbar.setActive(o,(t==null?void 0:t.kind)===r)}this.toolbar.setVisible("bold",X(t,"bold")),this.toolbar.setVisible("italic",X(t,"italic")),this.toolbar.setVisible("underline",X(t,"underline")),this.toolbar.setVisible("strike",X(t,"strike")),this.toolbar.setVisible("fontFamily",st(t)),this.toolbar.setVisible("fontSize",at(t)),this.toolbar.setVisible("color",re(t)),this.toolbar.setVisible("backgroundColor",re(t)),this.toolbar.setVisible("align",Le(t)),this.toolbar.setVisible("cellBg",ie(t)),this.toolbar.setVisible("tableMenu",ie(t)),this.toolbar.setVisible("codeLang",(t==null?void 0:t.kind)==="codeBlock"),this.toolbar.syncGroupVisibility()}}}function X(n,e){return n?(N[n.kind]??N.unknown).allowedMarks.includes(e):!1}function st(n){return n?(N[n.kind]??N.unknown).allowsInlineFormat:!1}function at(n){return n?(N[n.kind]??N.unknown).allowsFontSize:!1}function re(n){return n?(N[n.kind]??N.unknown).allowsColor:!1}const xo=new Set(["paragraph","heading","blockquote","table"]);function Le(n){return n?xo.has(n.kind):!1}function ie(n){return(n==null?void 0:n.kind)==="table"}function Eo(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),o.setEnd(t.startContainer,t.startOffset);const r=o.toString().length;o.setEnd(t.endContainer,t.endOffset);const i=o.toString().length;return{start:r,end:i}}function Ao(n,e){var u;const t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);let o=0,r=null,i=0,l=null,s=0,c=t.nextNode();for(;c;){const p=((u=c.textContent)==null?void 0:u.length)??0;if(!r&&o+p>=e.start&&(r=c,i=e.start-o),!l&&o+p>=e.end){l=c,s=e.end-o;break}o+=p,c=t.nextNode()}if(!r||!l)return;const a=document.createRange();a.setStart(r,i),a.setEnd(l,s);const d=document.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(a)}function le(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}function Se(n,e,t){const o=e.parentElement,r=t.parentElement;if(!(o instanceof HTMLTableRowElement)||!(r instanceof HTMLTableRowElement))return[e];const i=Array.from(n.querySelectorAll("tr")),l=i.indexOf(o),s=i.indexOf(r);if(l<0||s<0)return[e];const c=Math.min(l,s),a=Math.max(l,s),d=Array.from(o.children).indexOf(e),u=Array.from(r.children).indexOf(t);if(d<0||u<0)return[e];const p=Math.min(d,u),f=Math.max(d,u),g=[];for(let h=c;h<=a;h++){const b=i[h];if(b)for(let m=p;m<=f;m++){const k=b.children[m];k instanceof HTMLTableCellElement&&g.push(k)}}return g}function ct(n,e,t){const o=n.getBoundingClientRect(),r=6;return e<o.left-r||e>o.right+r||t<o.top-r||t>o.bottom+r?null:e>=o.right-r?"right":t>=o.bottom-r?"bottom":null}function Te(n,e,t){return n.getAttribute("data-block-explicit")==="true"||!e.isEmpty(n)?t.kind==="unknown"?n.tagName.toLowerCase():$t(t):"?"}function Lo(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 So(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 To(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:`${n}`}function dt(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 $o(){return{blocks:[],activeBlockId:null,inline:{bold:!1,italic:!1,underline:!1,strike:!1}}}function se(n){try{return document.queryCommandState(n)}catch{return!1}}const No=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 Bo(n){return No.has(n.toUpperCase())}class Mo{constructor(e){w(this,"root");w(this,"content");w(this,"blockIds",new Pe);w(this,"idFor",e=>this.blockIds.ensure(e));w(this,"options");w(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)}setBlocks(e){Mt(this.content,e),pe(this.content,this.blockIds)}getBlocks(){return qe(this.listBlocksInternal())}getBlockOf(e){return this.content.contains(e)?he(e,this.content,this.idFor):null}getHTML(e={}){const t=this.content.cloneNode(!0);if((e.styles??this.options.htmlStyles??"inline")==="class")We(t);else{const r=je(this.root),i=this.root.dataset.theme;(i==="light"||i==="dark")&&(r.mode=i),Ue(t,r)}return Ke(t),ye(t),t.innerHTML}setTheme(e){this.root.dataset.theme=e}destroy(){this.destroyed||(this.destroyed=!0,this.root.remove())}listBlocksInternal(){return fe(this.content,this.idFor)}}const Ft=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Io=new Set(["script","style"]),zo=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"])]]),Ro={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 W(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 Ro[t.toLowerCase()]??e}):n}function D(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function E(n){return D(n).replace(/"/g,"&quot;")}function Do(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()]=W(i)}return e}function Y(n){const e=[],t=[],o=()=>{const s=t[t.length-1];return s?s.children:e},r=s=>{if(s.length===0)return;const c=o(),a=c[c.length-1];a&&a.type==="text"?a.value+=s:c.push({type:"text",value:s})},i=s=>{var c;for(let a=t.length-1;a>=0;a--)if(((c=t[a])==null?void 0:c.tag)===s){t.length=a;return}};let l=0;for(;l<n.length;){const s=n.indexOf("<",l);if(s<0){r(W(n.slice(l)));break}if(s>l&&r(W(n.slice(l,s))),n.startsWith("<!--",s)){const m=n.indexOf("-->",s+4);l=m<0?n.length:m+3;continue}if(n.startsWith("<!",s)||n.startsWith("<?",s)){const m=n.indexOf(">",s+2);l=m<0?n.length:m+1;continue}const c=n.indexOf(">",s+1);if(c<0){r(W(n.slice(s)));break}const a=n.slice(s+1,c);if(l=c+1,a.startsWith("/")){const m=a.slice(1).trim().toLowerCase();m&&i(m);continue}const d=/^([A-Za-z][^\s/>]*)/.exec(a);if(!d||!d[1]){r(W(n.slice(s,l)));continue}const u=d[1].toLowerCase(),p=a.slice(d[1].length),f=/\/\s*$/.test(p),g=Do(f?p.replace(/\/\s*$/,""):p);if(Io.has(u)){const m=new RegExp(`</${u}\\s*>`,"i"),k=n.slice(l),S=m.exec(k);l=S?l+S.index+S[0].length:n.length;continue}const h=t[t.length-1];if(h){const m=zo.get(h.tag);m!=null&&m.has(u)&&t.pop()}const b={type:"element",tag:u,attrs:g,children:[]};o().push(b),!f&&!Ft.has(u)&&t.push(b)}return e}function Ve(n){let e="";for(const t of n){if(t.type==="text"){e+=D(t.value);continue}const o=Object.entries(t.attrs).map(([r,i])=>i===""?` ${r}`:` ${r}="${E(i)}"`).join("");if(Ft.has(t.tag)){e+=`<${t.tag}${o}>`;continue}e+=`<${t.tag}${o}>${Ve(t.children)}</${t.tag}>`}return e}function ke(n){let e="";for(const t of n){if(t.type==="text"){e+=t.value;continue}if(t.tag==="br"){e+=`
24
+ `;continue}e+=ke(t.children)}return e}const Ho=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 ee(n){let e="";for(const t of n){if(t.type==="text"){e+=t.value;continue}if(t.tag==="br"){e+=`
25
+ `;continue}const o=Ho.has(t.tag);o&&e!==""&&!e.endsWith(`
26
+ `)&&(e+=`
27
+ `),e+=ee(t.children),o&&!e.endsWith(`
28
+ `)&&(e+=`
29
+ `)}return e}function ge(n,e){return n.filter(t=>t.type==="element"&&t.tag===e)}function Fo(n,e={}){const t=e.blockIds!==!1,o=te(n).map(i=>_t(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 _o(n,e={}){return _t(He(n),e)}function _t(n,e={}){const t=e.blockIds===!1?"":` ${R}="${E(n.id)}"`,o=n.html,r=n.style?` style="${E(n.style)}"`:"";switch(n.kind){case"paragraph":return`<p${t}${r}>${o||"<br>"}</p>`;case"unknown":return`<div${t}${r}>${o||"<br>"}</div>`;case"heading":{const i=Oo(n.attrs.level);return`<h${i}${t}${r}>${o||"<br>"}</h${i}>`}case"bulletList":return`<ul${t}${r}>${o||"<li><br></li>"}</ul>`;case"orderedList":return`<ol${t}${r}>${o||"<li><br></li>"}</ol>`;case"blockquote":return`<blockquote${t}${r}>${o||"<p><br></p>"}</blockquote>`;case"codeBlock":{if(o)return`<pre${t}${r}>${o}</pre>`;const i=n.attrs.language,l=i?` data-language="${E(i)}"`:"";return`<pre${t}${r}><code${l}></code></pre>`}case"table":return`<table${t}${r}>${o||Po(n.attrs.rows,n.attrs.cols)}</table>`;case"hr":return`<hr${t}${r}>`;case"image":return o?`<figure${t}${r}>${be(o)}</figure>`:qo(n.attrs,t,r);case"youtube":{if(!o)return jo(n.attrs,t,r);const i=n.attrs.videoId;return`<div class="aw-youtube-embed"${i?` data-youtube-id="${E(i)}"`:""}${t}${r}>${be(o)}</div>`}case"linkCard":return Uo(n.attrs,t,r,o);case"file":return Wo(n.attrs,t,r,o);case"importedHtml":{const i=n.attrs.importedStyle,l=n.attrs.importedClass,s=n.style?r:i?` style="${E(i)}"`:"";return`<div data-imported-html="true"${l?` class="${E(l)}"`:""}${s}${t}>${o}</div>`}default:return""}}const ut=/aw-block-align-controls|aw-resize-handle/;function be(n){if(!ut.test(n))return n;const e=Y(n).filter(t=>!(t.type==="element"&&ut.test(t.attrs.class??"")));return Ve(e)}function Oo(n){return n===void 0||n<1?1:n>6?6:n}function Po(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 qo(n,e,t){const o=t||(n.wrapperStyle?` style="${E(n.wrapperStyle)}"`:""),r=n.src?` src="${E(n.src)}"`:"",i=` alt="${E(n.alt??"")}"`;return`<figure${e}${o}><img${r}${i}></figure>`}function jo(n,e,t){const o=n.videoId??"",r=t||(n.wrapperStyle?` style="${E(n.wrapperStyle)}"`:""),i=o?` data-youtube-id="${E(o)}"`:"",l=o?` src="${E(`${De}${o}`)}"`:"";return`<div class="aw-youtube-embed"${i}${e}${r}><iframe${l} allow="${E(Et)}" allowfullscreen frameborder="0" referrerpolicy="strict-origin-when-cross-origin"></iframe></div>`}function Uo(n,e,t,o){const r=n.href??"#",i=n.text&&n.text.length>0?n.text:Re(r)||r,l=n.description??"",s=n.image??"",c=n.favicon??vt(r),d=`<a class="${s?"aw-link-card aw-link-card-with-image":"aw-link-card"}" href="${E(r)}" target="_blank" rel="noopener"${e}${t}>`;if(o)return`${d}${be(o)}</a>`;let u=d;return s&&(u+=`<img class="aw-link-card-image" src="${E(s)}" alt="" loading="lazy">`),u+='<span class="aw-link-card-body">',u+=`<span class="aw-link-card-title">${D(i)}</span>`,l&&(u+=`<span class="aw-link-card-desc">${D(l)}</span>`),u+='<span class="aw-link-card-url">',c&&(u+=`<img class="aw-link-card-favicon" src="${E(c)}" alt="" loading="lazy">`),u+=`<span class="aw-link-card-url-text">${D(r)}</span>`,u+="</span></span></a>",u}function Wo(n,e,t,o){const r=n.fileSrc?` href="${E(n.fileSrc)}"`:"",i=n.fileName?` data-file-name="${E(n.fileName)}"`:"",l=n.fileSize!==void 0?` data-file-size="${E(String(n.fileSize))}"`:"",s=n.fileType?` data-file-type="${E(n.fileType)}"`:"",c=` download="${E(n.fileName??"")}"`,a=[],d=kt(n.fileName,n.fileType);d&&a.push(d),n.fileSize!==void 0&&a.push(wt(n.fileSize));const u=`<a class="aw-file-attachment" target="_blank" rel="noopener"${r}${c}${i}${l}${s}${e}${t}>`;if(o)return`${u}${be(o)}</a>`;let p=u;return p+=`<span class="aw-file-icon" aria-hidden="true">${Ct}</span>`,p+='<span class="aw-file-meta">',p+=`<span class="aw-file-name">${D(n.fileName??At)}</span>`,a.length>0&&(p+=`<span class="aw-file-info">${D(a.join(" · "))}</span>`),p+="</span>",p+=`<span class="aw-file-action" aria-hidden="true">${xt}</span>`,p+="</a>",p}const Ko=/([\\`*_[\]<])/g,Vo=/^([#>|+-]|\d+\.)/;function Yo(n,e={}){const t=e.bullet??"-",o=e.gfmTables!==!1,r=[];for(const i of te(n)){const l=Go(i,t,o);l!==""&&r.push(l)}return r.length>0?`${r.join(`
30
+
31
+ `)}
32
+ `:""}function Go(n,e,t){var r,i,l;const o=Y(n.html);switch(n.kind){case"paragraph":case"unknown":{const s=O(o).trim();return s===""?"":pt(s)}case"heading":{const s=Math.min(6,Math.max(1,n.attrs.level??1)),c=O(o).trim();return c===""?"":`${"#".repeat(s)} ${c}`}case"bulletList":return Ie(o,{ordered:!1,bullet:e,depth:0});case"orderedList":return Ie(o,{ordered:!0,bullet:e,depth:0});case"blockquote":{const s=ge(o,"p"),a=(s.length>0?s.map(d=>O(d.children).trim()):[O(o).trim()]).filter(d=>d!=="").join(`
33
+
34
+ `).split(`
35
+ `).map(d=>d===""?">":`> ${d}`);return a.length>0&&a[0]!==void 0?a.join(`
36
+ `):""}case"codeBlock":{const s=ge(o,"code")[0],c=ke(s?s.children:o).replace(/\n$/,""),a=n.attrs.language??(s==null?void 0:s.attrs["data-language"])??"",d="`".repeat(Math.max(3,Ot(c)+1));return`${d}${a}
37
+ ${c}
38
+ ${d}`}case"image":{const s=n.attrs.src??"";return s===""?"":`![${K(n.attrs.alt??"")}](${J(s)})`}case"table":return t?Zo(o):`<table>${n.html}</table>`;case"hr":return"---";case"linkCard":{const s=n.attrs.href??"";if(s==="")return"";const c=((r=n.attrs.text)==null?void 0:r.trim())||s,a=`[${K(c)}](${J(s)})`,d=(i=n.attrs.description)==null?void 0:i.trim();return d?`${a}
39
+
40
+ ${pt(K(d))}`:a}case"youtube":{const s=n.attrs.videoId;return s?`[YouTube](${De}${encodeURIComponent(s)})`:""}case"file":{const s=n.attrs.fileSrc??"";if(s==="")return"";const c=((l=n.attrs.fileName)==null?void 0:l.trim())||s;return`[${K(c)}](${J(s)})`}case"importedHtml":return n.html.trim();default:return""}}function Ie(n,e){const t=ge(n,"li");if(t.length===0)return"";const o=" ".repeat(e.depth),r=[];return t.forEach((i,l)=>{const s=[],c=[];for(const f of i.children)f.type==="element"&&(f.tag==="ul"||f.tag==="ol")?c.push(f):s.push(f);const a=e.ordered?`${l+1}.`:e.bullet,d=O(s).trim(),u=`${o}${" ".repeat(a.length+1)}`,p=d.split(`
41
+ `).join(`
42
+ ${u}`);r.push(`${o}${a} ${p}`);for(const f of c){const g=Ie(f.children,{ordered:f.tag==="ol",bullet:e.bullet,depth:e.depth+1});g!==""&&r.push(g)}}),r.join(`
43
+ `)}function Zo(n){const e=[],t=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")&&t(u.children)}};if(t(n),e.length===0)return"";const o=e.map(d=>d.children.filter(u=>u.type==="element"&&(u.tag==="td"||u.tag==="th")).map(u=>Xo(u.children))),r=o.reduce((d,u)=>Math.max(d,u.length),0);if(r===0)return"";const i=d=>d.length===r?d:[...d,...Array(r-d.length).fill("")],[l,...s]=o.map(i);return[`| ${(l??Array(r).fill("")).join(" | ")} |`,`| ${Array(r).fill("---").join(" | ")} |`,...s.map(d=>`| ${d.join(" | ")} |`)].join(`
44
+ `)}function Xo(n){return O(n,{inTableCell:!0}).replace(/\n+/g,"<br>").replace(/\|/g,"\\|").trim()}function O(n,e={}){let t="";for(const o of n){if(o.type==="text"){t+=K(o.value);continue}const r=()=>O(o.children,e);switch(o.tag){case"br":t+=e.inTableCell?`
45
+ `:`
46
+ `;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=ke(o.children),l="`".repeat(Ot(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}](${J(i)})`:l;break}case"img":{const i=o.attrs.src;i&&(t+=`![${K(o.attrs.alt??"")}](${J(i)})`);break}case"u":case"sub":case"sup":case"mark":t+=`<${o.tag}>${r()}</${o.tag}>`;break;default:t+=r();break}}return t}function K(n){return n.replace(Ko,"\\$1")}function pt(n){return n.replace(Vo,"\\$1")}function Ot(n){let e=0,t=0;for(const o of n)o==="`"?(t+=1,t>e&&(e=t)):t=0;return e}function J(n){const e=n.trim();return/[\s()]/.test(e)?`<${e.replace(/[<>]/g,"")}>`:e}function Qo(n,e={}){const t=e.blockSeparator??`
47
+
48
+ `,o=e.cellSeparator??" ",r=[];for(const i of te(n)){const l=Jo(i,o);l!==""&&r.push(l)}return r.join(t)}function Jo(n,e){switch(n.kind){case"hr":case"youtube":return"";case"image":return U(n.attrs.alt??"");case"linkCard":return U(n.attrs.text??n.attrs.href??"");case"file":return U(n.attrs.fileName??"");case"bulletList":case"orderedList":return ge(Y(n.html),"li").map(o=>U(ee(o.children))).filter(o=>o!=="").join(`
49
+ `);case"table":return er(Y(n.html),e);default:return U(ee(Y(n.html)))}}function er(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=>U(ee(i.children)).replace(/\n+/g," ")).join(e)).filter(r=>r.replace(new RegExp(tr(e),"g"),"").trim()!=="").join(`
50
+ `)}function U(n){return n.replace(/[​-‍]/g,"").split(`
51
+ `).map(e=>e.replace(/[^\S\n]+/g," ").trim()).join(`
52
+ `).replace(/\n{3,}/g,`
53
+
54
+ `).trim()}function tr(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}exports.ALIGN_CLASS_BY_VALUE=me;exports.ALL_INLINE_MARKS=ne;exports.AerizEditor=Co;exports.AerizViewer=Mo;exports.BLOCK_ID_ATTR=R;exports.BLOCK_TYPES=Oe;exports.BLOCK_TYPE_BY_KIND=N;exports.BlockIdRegistry=Pe;exports.DEFAULT_TOOLBAR=ft;exports.SNAPSHOT_VERSION=Lt;exports.applyBlockClassNames=We;exports.applyBlockInlineStyles=Ue;exports.assignMissingIds=pe;exports.blocksToMarkdown=Yo;exports.blocksToPlainText=Qo;exports.classifyBlockElement=P;exports.decodeEntities=W;exports.escapeAttr=E;exports.escapeHtml=D;exports.extractInlineContent=It;exports.fillInlineContent=zt;exports.findBlockFrom=he;exports.getBlockLabel=$t;exports.isElementBlank=q;exports.listBlocks=fe;exports.normalizeContent=Me;exports.parseHtmlFragment=Y;exports.placeCaretAtStart=j;exports.readBlockStyleTheme=je;exports.renderBlock=Bt;exports.renderBlockToHTML=_o;exports.renderBlocks=Mt;exports.renderBlocksToHTML=Fo;exports.restoreAlignFromClasses=Rt;exports.serializeBlock=Nt;exports.serializeBlocks=qe;exports.serializeNodes=Ve;exports.snapshotVersionOf=St;exports.stripEditorOnlyAttrs=Ke;exports.stripEditorOnlyNodes=ye;exports.textOf=ke;exports.textWithBlockBreaks=ee;exports.upgradeSnapshot=He;exports.upgradeSnapshots=te;typeof globalThis.AerizWysiwyg=="object"&&(globalThis.AerizEditor=globalThis.AerizWysiwyg.AerizEditor,globalThis.AerizViewer=globalThis.AerizWysiwyg.AerizViewer);