@aeriz/wysiwyg 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -0
- package/dist/aeriz-wysiwyg.css +10 -1
- package/dist/aeriz-wysiwyg.esm.js +332 -43
- package/dist/aeriz-wysiwyg.esm.min.js +941 -710
- package/dist/aeriz-wysiwyg.js +332 -43
- package/dist/aeriz-wysiwyg.min.css +1 -1
- package/dist/aeriz-wysiwyg.min.js +17 -17
- package/dist-types/core/AerizEditor.d.ts.map +1 -1
- package/dist-types/core/blocks.d.ts +10 -0
- package/dist-types/core/blocks.d.ts.map +1 -1
- package/dist-types/core/import-html.d.ts +13 -2
- package/dist-types/core/import-html.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var AerizWysiwyg=function(E){"use strict";var Mn=Object.defineProperty;var $n=(E,N,x)=>N in E?Mn(E,N,{enumerable:!0,configurable:!0,writable:!0,value:x}):E[N]=x;var k=(E,N,x)=>$n(E,typeof N!="symbol"?N+"":N,x);const N={items:["blockType","|","fontFamily","fontSize","|","bold","italic","underline","strike","|","color","backgroundColor","|","align","|","cellBg","tableMenu","codeLang"],sticky:!0},x={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>'},Qe={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 Je{constructor(e,t){k(this,"element");k(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 l of e.items){if(l==="|"){o=this.createGroup(),this.element.appendChild(o);continue}const i=Qe[l];if(!i)continue;const r=this.createButton(i,t);this.buttons.set(i.name,r),o.appendChild(r)}}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(l=>l instanceof HTMLElement&&l.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 l=e.shortcut?`${e.label} (${e.shortcut})`:e.label;o.title=l,o.setAttribute("aria-label",l),o.dataset.command=e.name;const i=x[e.icon]??"";return o.innerHTML=`<span class="aw-toolbar-btn-icon">${i}</span>`,e.hasDropdown&&(o.innerHTML+=`<span class="aw-toolbar-btn-chevron">${x.chevronDown}</span>`),o.addEventListener("mousedown",r=>{r.preventDefault()}),o.addEventListener("click",()=>{t.onAction(e.name,o)}),o}}function P(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 l=document.createElement("div");l.className="aw-dialog-header";const i=document.createElement("h2");i.className="aw-dialog-title",i.textContent=n;const r=document.createElement("button");r.type="button",r.className="aw-dialog-close",r.setAttribute("aria-label","닫기"),r.innerHTML=x.close,l.appendChild(i),l.appendChild(r);const s=document.createElement("div");s.className="aw-dialog-body";const c=document.createElement("div");c.className="aw-dialog-footer",o.appendChild(l),o.appendChild(s),o.appendChild(c),t.appendChild(o);const a=()=>t.remove();return r.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 $(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 et(n={},e){return new Promise(t=>{const{overlay:o,body:l,footer:i,close:r}=P("링크 삽입",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),l.appendChild($("표시할 텍스트",s)),l.appendChild($("URL",c)),l.appendChild(a);const m=document.createElement("button");m.type="button",m.className="aw-btn aw-btn-ghost",m.textContent="취소";const f=document.createElement("button");f.type="button",f.className="aw-btn aw-btn-primary",f.textContent="확인",i.appendChild(m),i.appendChild(f),m.addEventListener("click",()=>{r(),t({confirmed:!1})}),f.addEventListener("click",()=>{r(),t({confirmed:!0,text:s.value,href:c.value,newWindow:d.checked})}),document.body.appendChild(o),setTimeout(()=>c.focus(),0)})}function tt(n={},e){return new Promise(t=>{const{overlay:o,body:l,footer:i,close:r}=P("이미지",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),l.appendChild(s);const m=document.createElement("div");m.className="aw-pane";const f=Ee("이미지 파일 선택 (base64 임베드)"),p=document.createElement("div");p.className="aw-preview",p.style.display="none",m.appendChild(f.dropzone),m.appendChild(p);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($("이미지 URL",b));const C=document.createElement("div");if(C.className="aw-pane",u){const g=Ee("서버 업로드용 이미지 선택"),L=document.createElement("div");L.className="aw-preview",L.style.display="none",C.appendChild(g.dropzone),C.appendChild(L),g.input.addEventListener("change",async()=>{var F;const H=(F=g.input.files)==null?void 0:F[0];if(!(!H||!n.onUpload))try{g.dropzone.classList.add("aw-dropzone-loading");const le=await n.onUpload(H);y=le,L.style.backgroundImage=`url(${JSON.stringify(le)})`,L.style.display="block"}catch(le){console.error(le)}finally{g.dropzone.classList.remove("aw-dropzone-loading"),g.input.value=""}})}else{const g=document.createElement("div");g.className="aw-pane-notice",g.textContent="개체 생성시 등록된 API 주소가 없습니다.",C.appendChild(g)}l.appendChild(m),l.appendChild(h),l.appendChild(C);let w="embed",B,y;const A=g=>{g==="upload"&&!u||(w=g,c.classList.toggle("aw-tab-active",g==="embed"),a.classList.toggle("aw-tab-active",g==="url"),d.classList.toggle("aw-tab-active",g==="upload"),m.style.display=g==="embed"?"block":"none",h.style.display=g==="url"?"block":"none",C.style.display=g==="upload"?"block":"none")};A(w),c.addEventListener("click",()=>A("embed")),a.addEventListener("click",()=>A("url")),d.addEventListener("click",()=>A("upload")),f.input.addEventListener("change",()=>{var H;const g=(H=f.input.files)==null?void 0:H[0];if(!g)return;const L=new FileReader;L.onload=()=>{const F=String(L.result??"");B=F,p.style.backgroundImage=`url(${JSON.stringify(F)})`,p.style.display="block",f.input.value=""},L.readAsDataURL(g)});const T=document.createElement("button");T.type="button",T.className="aw-btn aw-btn-ghost",T.textContent="취소";const D=document.createElement("button");D.type="button",D.className="aw-btn aw-btn-primary",D.textContent="확인",i.appendChild(T),i.appendChild(D),T.addEventListener("click",()=>{r(),t({confirmed:!1})}),D.addEventListener("click",()=>{let g;w==="embed"?g=B:w==="url"?g=b.value||void 0:w==="upload"&&(g=y),r();const L={confirmed:!0};g&&(L.src=g),t(L)}),document.body.appendChild(o)})}function Ee(n){const e=document.createElement("label");e.className="aw-dropzone",e.innerHTML=`
|
|
2
|
-
${
|
|
1
|
+
var AerizWysiwyg=function(x){"use strict";var In=Object.defineProperty;var Rn=(x,M,E)=>M in x?In(x,M,{enumerable:!0,configurable:!0,writable:!0,value:E}):x[M]=E;var w=(x,M,E)=>Rn(x,typeof M!="symbol"?M+"":M,E);const M={items:["blockType","|","fontFamily","fontSize","|","bold","italic","underline","strike","|","color","backgroundColor","|","align","|","cellBg","tableMenu","codeLang"],sticky:!0},E={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>'},et={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 tt{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 l of e.items){if(l==="|"){o=this.createGroup(),this.element.appendChild(o);continue}const i=et[l];if(!i)continue;const r=this.createButton(i,t);this.buttons.set(i.name,r),o.appendChild(r)}}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(l=>l instanceof HTMLElement&&l.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 l=e.shortcut?`${e.label} (${e.shortcut})`:e.label;o.title=l,o.setAttribute("aria-label",l),o.dataset.command=e.name;const i=E[e.icon]??"";return o.innerHTML=`<span class="aw-toolbar-btn-icon">${i}</span>`,e.hasDropdown&&(o.innerHTML+=`<span class="aw-toolbar-btn-chevron">${E.chevronDown}</span>`),o.addEventListener("mousedown",r=>{r.preventDefault()}),o.addEventListener("click",()=>{t.onAction(e.name,o)}),o}}function _(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 l=document.createElement("div");l.className="aw-dialog-header";const i=document.createElement("h2");i.className="aw-dialog-title",i.textContent=n;const r=document.createElement("button");r.type="button",r.className="aw-dialog-close",r.setAttribute("aria-label","닫기"),r.innerHTML=E.close,l.appendChild(i),l.appendChild(r);const s=document.createElement("div");s.className="aw-dialog-body";const a=document.createElement("div");a.className="aw-dialog-footer",o.appendChild(l),o.appendChild(s),o.appendChild(a),t.appendChild(o);const c=()=>t.remove();return r.addEventListener("click",c),t.addEventListener("click",d=>{d.target===t&&c()}),document.addEventListener("keydown",function d(u){u.key==="Escape"&&(c(),document.removeEventListener("keydown",d))}),{overlay:t,body:s,footer:a,close:c}}function I(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 nt(n={},e){return new Promise(t=>{const{overlay:o,body:l,footer:i,close:r}=_("링크 삽입",e),s=document.createElement("input");s.type="text",s.className="aw-input",s.placeholder="링크에 표시할 텍스트",s.value=n.text??"";const a=document.createElement("input");a.type="url",a.className="aw-input",a.placeholder="https://example.com",a.value=n.href??"";const c=document.createElement("label");c.className="aw-checkbox";const d=document.createElement("input");d.type="checkbox",d.checked=n.newWindow??!1;const u=document.createElement("span");u.textContent="새 창에서 열기",c.appendChild(d),c.appendChild(u),l.appendChild(I("표시할 텍스트",s)),l.appendChild(I("URL",a)),l.appendChild(c);const m=document.createElement("button");m.type="button",m.className="aw-btn aw-btn-ghost",m.textContent="취소";const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-primary",h.textContent="확인",i.appendChild(m),i.appendChild(h),m.addEventListener("click",()=>{r(),t({confirmed:!1})}),h.addEventListener("click",()=>{r(),t({confirmed:!0,text:s.value,href:a.value,newWindow:d.checked})}),document.body.appendChild(o),setTimeout(()=>a.focus(),0)})}function ot(n={},e){return new Promise(t=>{const{overlay:o,body:l,footer:i,close:r}=_("이미지",e),s=document.createElement("div");s.className="aw-tabs";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent="임베드",a.title="base64 데이터로 본문에 직접 삽입";const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent="URL",c.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(a),s.appendChild(c),s.appendChild(d),l.appendChild(s);const m=document.createElement("div");m.className="aw-pane";const h=xe("이미지 파일 선택 (base64 임베드)"),f=document.createElement("div");f.className="aw-preview",f.style.display="none",m.appendChild(h.dropzone),m.appendChild(f);const p=document.createElement("div");p.className="aw-pane";const g=document.createElement("input");g.type="url",g.className="aw-input",g.placeholder="https://example.com/image.jpg",p.appendChild(I("이미지 URL",g));const b=document.createElement("div");if(b.className="aw-pane",u){const y=xe("서버 업로드용 이미지 선택"),L=document.createElement("div");L.className="aw-preview",L.style.display="none",b.appendChild(y.dropzone),b.appendChild(L),y.input.addEventListener("change",async()=>{var F;const H=(F=y.input.files)==null?void 0:F[0];if(!(!H||!n.onUpload))try{y.dropzone.classList.add("aw-dropzone-loading");const le=await n.onUpload(H);C=le,L.style.backgroundImage=`url(${JSON.stringify(le)})`,L.style.display="block"}catch(le){console.error(le)}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 주소가 없습니다.",b.appendChild(y)}l.appendChild(m),l.appendChild(p),l.appendChild(b);let v="embed",B,C;const A=y=>{y==="upload"&&!u||(v=y,a.classList.toggle("aw-tab-active",y==="embed"),c.classList.toggle("aw-tab-active",y==="url"),d.classList.toggle("aw-tab-active",y==="upload"),m.style.display=y==="embed"?"block":"none",p.style.display=y==="url"?"block":"none",b.style.display=y==="upload"?"block":"none")};A(v),a.addEventListener("click",()=>A("embed")),c.addEventListener("click",()=>A("url")),d.addEventListener("click",()=>A("upload")),h.input.addEventListener("change",()=>{var H;const y=(H=h.input.files)==null?void 0:H[0];if(!y)return;const L=new FileReader;L.onload=()=>{const F=String(L.result??"");B=F,f.style.backgroundImage=`url(${JSON.stringify(F)})`,f.style.display="block",h.input.value=""},L.readAsDataURL(y)});const S=document.createElement("button");S.type="button",S.className="aw-btn aw-btn-ghost",S.textContent="취소";const $=document.createElement("button");$.type="button",$.className="aw-btn aw-btn-primary",$.textContent="확인",i.appendChild(S),i.appendChild($),S.addEventListener("click",()=>{r(),t({confirmed:!1})}),$.addEventListener("click",()=>{let y;v==="embed"?y=B:v==="url"?y=g.value||void 0:v==="upload"&&(y=C),r();const L={confirmed:!0};y&&(L.src=y),t(L)}),document.body.appendChild(o)})}function xe(n){const e=document.createElement("label");e.className="aw-dropzone",e.innerHTML=`
|
|
2
|
+
${E.upload}
|
|
3
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
|
|
5
|
-
${
|
|
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 lt(n){return new Promise(e=>{const{overlay:t,body:o,footer:l,close:i}=_("HTML",n),r=document.createElement("input");r.type="file",r.accept=".html,.htm,text/html",r.style.display="none";const s=document.createElement("label");s.className="aw-dropzone",s.innerHTML=`
|
|
5
|
+
${E.importHtml}
|
|
6
6
|
<div class="aw-dropzone-text">HTML 파일 선택<br/>드래그 앤 드롭 또는 클릭</div>
|
|
7
|
-
`,s.appendChild(r);const
|
|
8
|
-
${
|
|
7
|
+
`,s.appendChild(r);const a=document.createElement("div");a.className="aw-dialog-hint",a.textContent="선택된 파일 없음";const c=document.createElement("textarea");c.className="aw-input aw-textarea",c.placeholder="또는 HTML 을 직접 붙여넣기…",c.rows=8,o.appendChild(s),o.appendChild(a),o.appendChild(I("직접 붙여넣기",c));const d=document.createElement("div");d.className="aw-dialog-hint",d.textContent="iframe 으로 로드한 후 모든 스타일을 인라인으로 합쳐 가져옵니다.",o.appendChild(d);let u;r.addEventListener("change",()=>{var g;const f=(g=r.files)==null?void 0:g[0];if(!f)return;const p=new FileReader;p.onload=()=>{u=String(p.result??""),c.value=u,a.textContent=`${f.name} (${f.size.toLocaleString()} bytes)`,r.value=""},p.readAsText(f)}),s.addEventListener("dragover",f=>{f.preventDefault(),s.classList.add("aw-dropzone-loading")}),s.addEventListener("dragleave",()=>{s.classList.remove("aw-dropzone-loading")}),s.addEventListener("drop",f=>{var b,v;f.preventDefault(),s.classList.remove("aw-dropzone-loading");const p=(v=(b=f.dataTransfer)==null?void 0:b.files)==null?void 0:v[0];if(!p)return;const g=new FileReader;g.onload=()=>{u=String(g.result??""),c.value=u,a.textContent=`${p.name} (${p.size.toLocaleString()} bytes)`},g.readAsText(p)});const m=document.createElement("button");m.type="button",m.className="aw-btn aw-btn-ghost",m.textContent="취소";const h=document.createElement("button");h.type="button",h.className="aw-btn aw-btn-primary",h.textContent="가져오기",l.appendChild(m),l.appendChild(h),m.addEventListener("click",()=>{i(),e({confirmed:!1})}),h.addEventListener("click",()=>{const f=c.value.trim();i();const p={confirmed:!0};f.length>0&&(p.html=f),e(p)}),document.body.appendChild(t)})}function it(n){return new Promise(e=>{const{overlay:t,body:o,footer:l,close:i}=_("Markdown",n),r=document.createElement("input");r.type="file",r.accept=".md,.markdown,text/markdown,text/plain",r.style.display="none";const s=document.createElement("label");s.className="aw-dropzone",s.innerHTML=`
|
|
8
|
+
${E.importMarkdown}
|
|
9
9
|
<div class="aw-dropzone-text">Markdown 파일 선택<br/>드래그 앤 드롭 또는 클릭</div>
|
|
10
|
-
`,s.appendChild(r);const
|
|
11
|
-
${
|
|
10
|
+
`,s.appendChild(r);const a=document.createElement("div");a.className="aw-dialog-hint",a.textContent="선택된 파일 없음";const c=document.createElement("textarea");c.className="aw-input aw-textarea",c.placeholder="또는 Markdown 을 직접 붙여넣기…",c.rows=8,o.appendChild(s),o.appendChild(a),o.appendChild(I("직접 붙여넣기",c));const d=document.createElement("div");d.className="aw-dialog-hint",d.textContent="CommonMark 기본 문법(제목/목록/링크/코드/표/인용 등) 지원",o.appendChild(d),r.addEventListener("change",()=>{var p;const h=(p=r.files)==null?void 0:p[0];if(!h)return;const f=new FileReader;f.onload=()=>{const g=String(f.result??"");c.value=g,a.textContent=`${h.name} (${h.size.toLocaleString()} bytes)`,r.value=""},f.readAsText(h)}),s.addEventListener("dragover",h=>{h.preventDefault(),s.classList.add("aw-dropzone-loading")}),s.addEventListener("dragleave",()=>{s.classList.remove("aw-dropzone-loading")}),s.addEventListener("drop",h=>{var g,b;h.preventDefault(),s.classList.remove("aw-dropzone-loading");const f=(b=(g=h.dataTransfer)==null?void 0:g.files)==null?void 0:b[0];if(!f)return;const p=new FileReader;p.onload=()=>{const v=String(p.result??"");c.value=v,a.textContent=`${f.name} (${f.size.toLocaleString()} bytes)`},p.readAsText(f)});const u=document.createElement("button");u.type="button",u.className="aw-btn aw-btn-ghost",u.textContent="취소";const m=document.createElement("button");m.type="button",m.className="aw-btn aw-btn-primary",m.textContent="가져오기",l.appendChild(u),l.appendChild(m),u.addEventListener("click",()=>{i(),e({confirmed:!1})}),m.addEventListener("click",()=>{const h=c.value.trim();i();const f={confirmed:!0};h.length>0&&(f.markdown=h),e(f)}),document.body.appendChild(t)})}function rt(n={},e){return new Promise(t=>{const{overlay:o,body:l,footer:i,close:r}=_("파일 첨부",e),s=document.createElement("div");s.className="aw-tabs";const a=document.createElement("button");a.type="button",a.className="aw-tab",a.textContent="URL",a.title="이미 호스팅된 파일의 URL 직접 입력";const c=document.createElement("button");c.type="button",c.className="aw-tab",c.textContent="업로드";const d=!!n.onUpload;d?c.title="서버 API 로 업로드 후 응답 URL 사용":(c.disabled=!0,c.classList.add("aw-tab-disabled"),c.title="개체 생성시 등록된 파일 업로드 API 가 없습니다."),s.appendChild(a),s.appendChild(c),l.appendChild(s);const u=document.createElement("div");u.className="aw-pane";const m=document.createElement("input");m.type="url",m.className="aw-input",m.placeholder="https://example.com/files/report.pdf",u.appendChild(I("파일 URL",m));const h=document.createElement("input");h.type="text",h.className="aw-input",h.placeholder="표시할 파일명 (예: report.pdf)",u.appendChild(I("파일명",h));const f=document.createElement("div");f.className="aw-pane";let p;if(d){const C=document.createElement("label");C.className="aw-dropzone",C.innerHTML=`
|
|
11
|
+
${E.upload}
|
|
12
12
|
<div class="aw-dropzone-text">서버 업로드용 파일 선택<br/>드래그 앤 드롭 또는 클릭</div>
|
|
13
|
-
`;const A=document.createElement("input");A.type="file",A.style.display="none",y.appendChild(A);const T=document.createElement("div");T.className="aw-dialog-hint",T.textContent="선택된 파일 없음",p.appendChild(y),p.appendChild(T);const D=async g=>{if(n.onUpload)try{y.classList.add("aw-dropzone-loading"),h={src:await n.onUpload(g),name:g.name,size:g.size,type:g.type||""},T.textContent=`${g.name} (${g.size.toLocaleString()} bytes) — 업로드 완료`}catch(L){console.error(L),T.textContent=`업로드 실패: ${L instanceof Error?L.message:String(L)}`}finally{y.classList.remove("aw-dropzone-loading"),A.value=""}};A.addEventListener("change",()=>{var L;const g=(L=A.files)==null?void 0:L[0];g&&D(g)}),y.addEventListener("dragover",g=>{g.preventDefault(),y.classList.add("aw-dropzone-loading")}),y.addEventListener("dragleave",()=>{y.classList.remove("aw-dropzone-loading")}),y.addEventListener("drop",g=>{var H,F;g.preventDefault();const L=(F=(H=g.dataTransfer)==null?void 0:H.files)==null?void 0:F[0];L&&D(L)})}else{const y=document.createElement("div");y.className="aw-pane-notice",y.textContent="개체 생성시 등록된 파일 업로드 API 가 없습니다.",p.appendChild(y)}l.appendChild(u),l.appendChild(p);let b="url";const C=y=>{y==="upload"&&!d||(b=y,c.classList.toggle("aw-tab-active",y==="url"),a.classList.toggle("aw-tab-active",y==="upload"),u.style.display=y==="url"?"block":"none",p.style.display=y==="upload"?"block":"none")};C(b),c.addEventListener("click",()=>C("url")),a.addEventListener("click",()=>C("upload"));const w=document.createElement("button");w.type="button",w.className="aw-btn aw-btn-ghost",w.textContent="취소";const B=document.createElement("button");B.type="button",B.className="aw-btn aw-btn-primary",B.textContent="확인",i.appendChild(w),i.appendChild(B),w.addEventListener("click",()=>{r(),t({confirmed:!1})}),B.addEventListener("click",()=>{const y={confirmed:!0};if(b==="url"){const A=m.value.trim(),T=f.value.trim();A.length>0&&(y.src=A),T.length>0&&(y.name=T)}else h&&(y.src=h.src,y.name=h.name,y.size=h.size,h.type&&(y.type=h.type));r(),t(y)}),document.body.appendChild(o)})}function it(n){return new Promise(e=>{const{overlay:t,body:o,footer:l,close:i}=P("유튜브 임베드",n),r=document.createElement("input");r.type="url",r.className="aw-input",r.placeholder="https://www.youtube.com/watch?v=…",o.appendChild($("YouTube URL",r));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="확인",l.appendChild(c),l.appendChild(a),c.addEventListener("click",()=>{i(),e({confirmed:!1})}),a.addEventListener("click",()=>{i(),e({confirmed:!0,url:r.value})}),document.body.appendChild(t),setTimeout(()=>r.focus(),0)})}const W=[{id:"system",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 W)n[e.id]=e;return n})();const rt=[12,13,14,15,16,18,20,24,28,32,40,48];function st(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 xe=!1;function at(){if(xe||(xe=!0,typeof document>"u"))return;const n=W.map(e=>e.googleFonts).filter(e=>typeof e=="string"&&e.length>0);if(n.length>0){const e="https://fonts.googleapis.com/css2?"+n.map(t=>`family=${t}`).join("&")+"&display=swap";Le(e)}for(const e of W)e.cssUrl&&Le(e.cssUrl)}function Le(n){if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return;const t=document.createElement("link");t.rel="stylesheet",t.href=n,document.head.appendChild(t)}function ct(n){var o;if(!n)return null;const e=Ae(n);if(!e)return null;const t=e.toLowerCase();for(const l of W){const i=(o=Ae(l.stack))==null?void 0:o.toLowerCase();if(i&&i===t)return l.id}return null}function Ae(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:['"',"'"]},Se=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"]),dt=new Set([...Se,"any","as","asserts","boolean","declare","infer","is","keyof","module","namespace","never","number","object","override","readonly","require","satisfies","string","symbol","type","unique","unknown"]),ut=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"]),pt=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"]),Te=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"]),ht=new Set([...Te,"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"]),mt=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"]),ft=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"]),gt=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"]),bt=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"]),yt=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"]),kt=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"]),wt=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"]),vt=new Set(["true","false","null"]),Be=[{id:"plaintext",label:"Plain Text",keywords:new Set},{id:"javascript",label:"JavaScript",keywords:Se,...M,stringDelims:['"',"'","`"]},{id:"typescript",label:"TypeScript",keywords:dt,...M,stringDelims:['"',"'","`"]},{id:"python",label:"Python",keywords:ut,builtins:pt,lineComment:"#",stringDelims:['"',"'"]},{id:"json",label:"JSON",keywords:vt,stringDelims:['"']},{id:"html",label:"HTML",keywords:new Set,custom:n=>At(n)},{id:"css",label:"CSS",keywords:new Set,custom:n=>Tt(n)},{id:"bash",label:"Bash",keywords:kt,lineComment:"#",stringDelims:['"',"'"]},{id:"sql",label:"SQL",keywords:wt,caseInsensitiveKeywords:!0,lineComment:"--",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},{id:"markdown",label:"Markdown",keywords:new Set,custom:n=>Bt(n)},{id:"c",label:"C",keywords:Te,...M},{id:"cpp",label:"C++",keywords:ht,...M},{id:"csharp",label:"C#",keywords:mt,...M},{id:"java",label:"Java",keywords:ft,...M},{id:"kotlin",label:"Kotlin",keywords:gt,...M},{id:"go",label:"Go",keywords:bt,...M},{id:"rust",label:"Rust",keywords:yt,...M}],Ct=(()=>{const n=new Map;for(const e of Be)n.set(e.id,e);return n})();function Et(n,e){if(!e)return v(n);const t=Ct.get(e);return t?t.custom?t.custom(n):xt(n,t):v(n)}function xt(n,e){var r,s;const t=!!e.caseInsensitiveKeywords;let o="",l=0;const i=n.length;for(;l<i;){if(e.lineComment&&n.startsWith(e.lineComment,l)){const d=n.indexOf(`
|
|
14
|
-
`,l),u=d===-1?i:d;o+=`<span class="hl-comment">${
|
|
15
|
-
`&&
|
|
16
|
-
`).map(
|
|
17
|
-
`)}function Nt(n){const e=/^(#{1,6})\s+(.*)$/.exec(n);if(e)return`<span class="hl-keyword">${v(e[1]??"")}</span> <span class="hl-tag">${ie(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> ${ie(t[3]??"")}`:ie(n)}function ie(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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function S(n){n.addEventListener("mousedown",e=>e.preventDefault())}const re=["#000000","#5c5c5c","#9c9c9c","#cfcfcf","#ffffff","#e03131","#f76707","#f59f00","#94d82d","#0ca678","#1c7ed6","#7048e8","#d6336c","#fab005","#37b24d","#1098ad"];function se(n,e,t=[]){R();const o=document.createElement("div");o.className="aw-popover aw-color-popover",o.dataset.popover="true",S(o);const l=d=>{e(d),o.remove()},i=d=>{const u=document.createElement("button");return u.type="button",u.className="aw-color-swatch",u.style.backgroundColor=d,u.setAttribute("aria-label",d),u.title=d,S(u),u.addEventListener("click",m=>{m.stopPropagation(),l(d)}),u},r=document.createElement("div");r.className="aw-color-grid";for(const d of re)r.appendChild(i(d));o.appendChild(r);const s=document.createElement("button");s.type="button",s.className="aw-popover-action",s.textContent="기본색",S(s),s.addEventListener("click",d=>{d.stopPropagation(),l(null)});const c=document.createElement("button");c.type="button",c.className="aw-popover-action",c.textContent="사용자 지정",S(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",()=>{l(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 m of t)u.appendChild(i(m));o.appendChild(u)}I(o,n)}const Mt=[{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:x.bulletList,glyphIsSvg:!0,divider:!0},{label:"번호 매기기 목록",kind:"orderedList",attrs:{},glyph:x.orderedList,glyphIsSvg:!0},{label:"인용구",kind:"blockquote",attrs:{},glyph:x.blockquote,glyphIsSvg:!0,divider:!0},{label:"코드 블록",kind:"codeBlock",attrs:{},glyph:x.codeBlock,glyphIsSvg:!0},{label:"링크",kind:"linkCard",attrs:{},glyph:x.link,glyphIsSvg:!0,divider:!0},{label:"이미지",kind:"image",attrs:{},glyph:x.image,glyphIsSvg:!0},{label:"표",kind:"table",attrs:{},glyph:x.table,glyphIsSvg:!0},{label:"유튜브",kind:"youtube",attrs:{},glyph:x.youtube,glyphIsSvg:!0},{label:"파일 첨부",kind:"file",attrs:{},glyph:x.attachFile,glyphIsSvg:!0},{label:"구분선",kind:"hr",attrs:{},glyph:x.hr,glyphIsSvg:!0},{label:"HTML",kind:"importHtml",attrs:{},glyph:x.importHtml,glyphIsSvg:!0,divider:!0},{label:"Markdown",kind:"importMarkdown",attrs:{},glyph:x.importMarkdown,glyphIsSvg:!0}];function $t(n,e){R();const t=document.createElement("div");t.className="aw-popover aw-block-type-popover",t.dataset.popover="true",S(t);for(const o of Mt){if(o.divider){const s=document.createElement("div");s.className="aw-popover-divider",t.appendChild(s)}const l=document.createElement("button");l.type="button",l.className="aw-popover-item";const i=document.createElement("span");i.className="aw-popover-item-glyph",o.glyphIsSvg?i.innerHTML=o.glyph:i.textContent=o.glyph;const r=document.createElement("span");r.className="aw-popover-item-label",r.textContent=o.label,o.size&&(r.style.fontSize=o.size),o.weight&&(r.style.fontWeight=o.weight),l.appendChild(i),l.appendChild(r),S(l),l.addEventListener("click",s=>{s.stopPropagation(),t.remove(),e({kind:o.kind,attrs:o.attrs})}),t.appendChild(l)}I(t,n)}function It(n,e){R();const t=document.createElement("div");t.className="aw-popover aw-align-popover",t.dataset.popover="true",S(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 l of o){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-popover-item-icon",i.setAttribute("aria-label",l.label),i.title=l.label,i.innerHTML=x[l.icon]??"",S(i),i.addEventListener("click",r=>{r.stopPropagation(),t.remove(),e(l.value)}),t.appendChild(i)}I(t,n)}function Rt(n,e,t){at(),R();const o=document.createElement("div");o.className="aw-popover aw-font-family-popover",o.dataset.popover="true",S(o);for(const l of W){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-font-family-item",t&&t===l.id&&i.classList.add("aw-popover-item-active"),i.title=l.label;const r=document.createElement("span");r.className="aw-font-family-name",r.textContent=l.label;const s=document.createElement("span");s.className="aw-font-family-preview",s.textContent="가A",s.style.fontFamily=l.stack,i.appendChild(r),i.appendChild(s),S(i),i.addEventListener("click",c=>{c.stopPropagation(),o.remove(),e({id:l.id,label:l.label,stack:l.stack})}),o.appendChild(i)}I(o,n)}function zt(n,e,t){R();const o=document.createElement("div");o.className="aw-popover aw-code-lang-popover",o.dataset.popover="true",S(o);for(const l of Be){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-code-lang-item",t===l.id&&i.classList.add("aw-popover-item-active"),i.title=l.label;const r=document.createElement("span");r.className="aw-popover-item-label",r.textContent=l.label,i.appendChild(r),S(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({id:l.id,label:l.label})}),o.appendChild(i)}I(o,n)}const Dt=[{action:"rowAbove",label:"위에 행 추가"},{action:"rowBelow",label:"아래에 행 추가"},{action:"colLeft",label:"왼쪽에 열 추가",divider:!0},{action:"colRight",label:"오른쪽에 열 추가"},{action:"deleteRow",label:"행 삭제",divider:!0},{action:"deleteCol",label:"열 삭제"}];function Ht(n,e){R();const t=document.createElement("div");t.className="aw-popover aw-table-menu-popover",t.dataset.popover="true",S(t);for(const o of Dt){if(o.divider){const i=document.createElement("div");i.className="aw-popover-divider",t.appendChild(i)}const l=document.createElement("button");l.type="button",l.className="aw-popover-item aw-table-menu-item",l.textContent=o.label,S(l),l.addEventListener("click",i=>{i.stopPropagation(),t.remove(),e(o.action)}),t.appendChild(l)}I(t,n)}function Ft(n,e,t){R();const o=document.createElement("div");o.className="aw-popover aw-font-size-popover",o.dataset.popover="true",S(o);for(const l of rt){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-font-size-item",t===l&&i.classList.add("aw-popover-item-active"),i.title=`${l}px`;const r=document.createElement("span");r.className="aw-font-size-label",r.textContent=String(l),i.appendChild(r),S(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({px:l})}),o.appendChild(i)}I(o,n)}function _t(n,e){R();const t=2,o=12,l=document.createElement("div");l.className="aw-popover aw-table-popover",l.dataset.popover="true";const i=document.createElement("div");i.className="aw-table-picker-grid";const r=document.createElement("div");r.className="aw-table-status";let s=t,c=t,a=0,d=0;const u=[];function m(){for(let h=0;h<u.length;h++){const b=u[h];if(b)for(let C=0;C<b.length;C++){const w=b[C];w&&w.classList.toggle("aw-table-cell-active",h<a&&C<d)}}r.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 C=0;C<c;C++){const w=document.createElement("div");w.className="aw-table-cell",w.dataset.row=String(h+1),w.dataset.col=String(C+1),i.appendChild(w),b.push(w)}u.push(b)}m()}f(),i.addEventListener("mousemove",h=>{const b=h.target;if(!b.classList.contains("aw-table-cell"))return;const C=parseInt(b.dataset.row??"0",10),w=parseInt(b.dataset.col??"0",10);a=C,d=w;let B=!1;C>=s&&s<o&&(s=Math.min(o,C+1),B=!0),w>=c&&c<o&&(c=Math.min(o,w+1),B=!0),B?f():m()}),i.addEventListener("click",h=>{const b=h.target;if(!b.classList.contains("aw-table-cell"))return;const C=parseInt(b.dataset.row??"0",10),w=parseInt(b.dataset.col??"0",10);C>0&&w>0&&(e({rows:C,cols:w}),l.remove())});function p(h){h.key==="Escape"&&(l.remove(),document.removeEventListener("keydown",p))}document.addEventListener("keydown",p),l.appendChild(i),l.appendChild(r),I(l,n)}function I(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 l=()=>{const a=e.getBoundingClientRect();n.style.top=`${a.bottom+4}px`,n.style.left=`${a.left}px`};l(),document.body.appendChild(n);const i=()=>l(),r=()=>l();window.addEventListener("scroll",i,!0),window.addEventListener("resize",r);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",r),document.removeEventListener("click",s),c()}}function R(){document.querySelectorAll('[data-popover="true"]').forEach(n=>n.remove())}function Rn(n){}const Ot=["script","noscript","meta","link","style","base"];async function Pt(n,e={}){const t=e.settleMs??1e3,o=e.timeoutMs??3e4,l=e.width??1024;return new Promise((i,r)=>{const s=document.createElement("iframe");s.setAttribute("aria-hidden","true"),s.setAttribute("tabindex","-1"),s.style.position="fixed",s.style.left="-99999px",s.style.top="0",s.style.width=`${l}px`,s.style.height="768px",s.style.border="0",s.style.opacity="0",s.style.pointerEvents="none";let c=!1;const a=()=>{s.parentNode&&s.parentNode.removeChild(s)},d=p=>{c||(c=!0,a(),r(p))},u=p=>{c||(c=!0,a(),i(p))},m=window.setTimeout(()=>{d(new Error("HTML 로드 시간 초과"))},o),f=()=>{var w;const p=s.contentDocument;if(!p||!p.body||p.body.children.length===0&&(p.body.textContent??"").trim()==="")return;const h=s.contentWindow,b=(h==null?void 0:h.requestAnimationFrame)??window.requestAnimationFrame;(p.fonts&&typeof((w=p.fonts.ready)==null?void 0:w.then)=="function"?p.fonts.ready:Promise.resolve()).then(()=>{const B=()=>{window.setTimeout(()=>{if(!c)try{const y=s.contentWindow,A=s.contentDocument;if(!y||!A||!A.body){window.clearTimeout(m),d(new Error("iframe document 접근 실패"));return}const T=qt(A.body,y);window.clearTimeout(m),u(T)}catch(y){window.clearTimeout(m),d(y instanceof Error?y:new Error(String(y)))}},t)};b(()=>b(B))})};s.addEventListener("load",f),s.srcdoc=n,document.body.appendChild(s)})}function qt(n,e){var l;const t=document.createElement("div");for(let i=0;i<n.attributes.length;i++){const r=n.attributes.item(i);r&&r.name!=="style"&&t.setAttribute(r.name,r.value)}const o=Ne(n,e);o.length>0&&t.setAttribute("style",o);for(const i of Array.from(n.children)){const r=document.importNode(i,!0);Me(i,r,e),t.appendChild(r)}for(const i of Ot)for(const r of Array.from(t.querySelectorAll(i)))(l=r.parentNode)==null||l.removeChild(r);return t.style.width="auto",t.style.maxWidth="none",t.style.height="auto",t.style.maxHeight="none",t.setAttribute("data-imported-html","true"),[t]}function Ne(n,e){const t=e.getComputedStyle(n);let o="";for(let l=0;l<t.length;l++){const i=t.item(l);if(!i)continue;const r=t.getPropertyValue(i);r&&r.length>0&&(o+=`${i}:${r};`)}return o}function Me(n,e,t){if(n.nodeType===1&&e.nodeType===1){const r=Ne(n,t);r.length>0&&e.setAttribute("style",r)}const o=n.children,l=e.children,i=Math.min(o.length,l.length);for(let r=0;r<i;r++){const s=o[r],c=l[r];s&&c&&Me(s,c,t)}}function jt(n){const e=Ut(n),t=document.createElement("div");t.innerHTML=e;const o=[];for(const l of Array.from(t.children))l instanceof HTMLElement&&o.push(l);return o}function Ut(n){const t=n.replace(/\r\n?/g,`
|
|
13
|
+
`;const A=document.createElement("input");A.type="file",A.style.display="none",C.appendChild(A);const S=document.createElement("div");S.className="aw-dialog-hint",S.textContent="선택된 파일 없음",f.appendChild(C),f.appendChild(S);const $=async y=>{if(n.onUpload)try{C.classList.add("aw-dropzone-loading"),p={src:await n.onUpload(y),name:y.name,size:y.size,type:y.type||""},S.textContent=`${y.name} (${y.size.toLocaleString()} bytes) — 업로드 완료`}catch(L){console.error(L),S.textContent=`업로드 실패: ${L instanceof Error?L.message:String(L)}`}finally{C.classList.remove("aw-dropzone-loading"),A.value=""}};A.addEventListener("change",()=>{var L;const y=(L=A.files)==null?void 0:L[0];y&&$(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 H,F;y.preventDefault();const L=(F=(H=y.dataTransfer)==null?void 0:H.files)==null?void 0:F[0];L&&$(L)})}else{const C=document.createElement("div");C.className="aw-pane-notice",C.textContent="개체 생성시 등록된 파일 업로드 API 가 없습니다.",f.appendChild(C)}l.appendChild(u),l.appendChild(f);let g="url";const b=C=>{C==="upload"&&!d||(g=C,a.classList.toggle("aw-tab-active",C==="url"),c.classList.toggle("aw-tab-active",C==="upload"),u.style.display=C==="url"?"block":"none",f.style.display=C==="upload"?"block":"none")};b(g),a.addEventListener("click",()=>b("url")),c.addEventListener("click",()=>b("upload"));const v=document.createElement("button");v.type="button",v.className="aw-btn aw-btn-ghost",v.textContent="취소";const B=document.createElement("button");B.type="button",B.className="aw-btn aw-btn-primary",B.textContent="확인",i.appendChild(v),i.appendChild(B),v.addEventListener("click",()=>{r(),t({confirmed:!1})}),B.addEventListener("click",()=>{const C={confirmed:!0};if(g==="url"){const A=m.value.trim(),S=h.value.trim();A.length>0&&(C.src=A),S.length>0&&(C.name=S)}else p&&(C.src=p.src,C.name=p.name,C.size=p.size,p.type&&(C.type=p.type));r(),t(C)}),document.body.appendChild(o)})}function st(n){return new Promise(e=>{const{overlay:t,body:o,footer:l,close:i}=_("유튜브 임베드",n),r=document.createElement("input");r.type="url",r.className="aw-input",r.placeholder="https://www.youtube.com/watch?v=…",o.appendChild(I("YouTube URL",r));const s=document.createElement("div");s.className="aw-dialog-hint",s.textContent="youtu.be / youtube.com/watch / /embed / /shorts 형식 모두 지원",o.appendChild(s);const a=document.createElement("button");a.type="button",a.className="aw-btn aw-btn-ghost",a.textContent="취소";const c=document.createElement("button");c.type="button",c.className="aw-btn aw-btn-primary",c.textContent="확인",l.appendChild(a),l.appendChild(c),a.addEventListener("click",()=>{i(),e({confirmed:!1})}),c.addEventListener("click",()=>{i(),e({confirmed:!0,url:r.value})}),document.body.appendChild(t),setTimeout(()=>r.focus(),0)})}const W=[{id:"system",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 W)n[e.id]=e;return n})();const at=[12,13,14,15,16,18,20,24,28,32,40,48];function ct(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 Ee=!1;function dt(){if(Ee||(Ee=!0,typeof document>"u"))return;const n=W.map(e=>e.googleFonts).filter(e=>typeof e=="string"&&e.length>0);if(n.length>0){const e="https://fonts.googleapis.com/css2?"+n.map(t=>`family=${t}`).join("&")+"&display=swap";Le(e)}for(const e of W)e.cssUrl&&Le(e.cssUrl)}function Le(n){if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return;const t=document.createElement("link");t.rel="stylesheet",t.href=n,document.head.appendChild(t)}function ut(n){var o;if(!n)return null;const e=Ae(n);if(!e)return null;const t=e.toLowerCase();for(const l of W){const i=(o=Ae(l.stack))==null?void 0:o.toLowerCase();if(i&&i===t)return l.id}return null}function Ae(n){var t;const e=(t=n.split(",")[0])==null?void 0:t.trim();return e?e.replace(/^["']|["']$/g,""):null}const z={lineComment:"//",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},Se=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"]),pt=new Set([...Se,"any","as","asserts","boolean","declare","infer","is","keyof","module","namespace","never","number","object","override","readonly","require","satisfies","string","symbol","type","unique","unknown"]),ht=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"]),mt=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"]),Te=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"]),ft=new Set([...Te,"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"]),gt=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"]),bt=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"]),yt=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"]),wt=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"]),kt=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"]),vt=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"]),Ct=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"]),xt=new Set(["true","false","null"]),Be=[{id:"plaintext",label:"Plain Text",keywords:new Set},{id:"javascript",label:"JavaScript",keywords:Se,...z,stringDelims:['"',"'","`"]},{id:"typescript",label:"TypeScript",keywords:pt,...z,stringDelims:['"',"'","`"]},{id:"python",label:"Python",keywords:ht,builtins:mt,lineComment:"#",stringDelims:['"',"'"]},{id:"json",label:"JSON",keywords:xt,stringDelims:['"']},{id:"html",label:"HTML",keywords:new Set,custom:n=>Tt(n)},{id:"css",label:"CSS",keywords:new Set,custom:n=>Nt(n)},{id:"bash",label:"Bash",keywords:vt,lineComment:"#",stringDelims:['"',"'"]},{id:"sql",label:"SQL",keywords:Ct,caseInsensitiveKeywords:!0,lineComment:"--",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},{id:"markdown",label:"Markdown",keywords:new Set,custom:n=>Mt(n)},{id:"c",label:"C",keywords:Te,...z},{id:"cpp",label:"C++",keywords:ft,...z},{id:"csharp",label:"C#",keywords:gt,...z},{id:"java",label:"Java",keywords:bt,...z},{id:"kotlin",label:"Kotlin",keywords:yt,...z},{id:"go",label:"Go",keywords:wt,...z},{id:"rust",label:"Rust",keywords:kt,...z}],Et=(()=>{const n=new Map;for(const e of Be)n.set(e.id,e);return n})();function Lt(n,e){if(!e)return k(n);const t=Et.get(e);return t?t.custom?t.custom(n):At(n,t):k(n)}function At(n,e){var r,s;const t=!!e.caseInsensitiveKeywords;let o="",l=0;const i=n.length;for(;l<i;){if(e.lineComment&&n.startsWith(e.lineComment,l)){const d=n.indexOf(`
|
|
14
|
+
`,l),u=d===-1?i:d;o+=`<span class="hl-comment">${k(n.slice(l,u))}</span>`,l=u;continue}if(e.blockComment&&n.startsWith(e.blockComment.start,l)){const d=n.indexOf(e.blockComment.end,l+e.blockComment.start.length),u=d===-1?i:d+e.blockComment.end.length;o+=`<span class="hl-comment">${k(n.slice(l,u))}</span>`,l=u;continue}const a=(r=e.stringDelims)==null?void 0:r.find(d=>n.startsWith(d,l));if(a){let d=l+a.length;for(;d<i;){const u=n[d]??"";if(u==="\\"){d+=2;continue}if(n.startsWith(a,d)){d+=a.length;break}if(u===`
|
|
15
|
+
`&&a!=="`")break;d++}o+=`<span class="hl-string">${k(n.slice(l,d))}</span>`,l=d;continue}const c=n[l]??"";if(/[0-9]/.test(c)){const d=St.exec(n.slice(l));if(d){o+=`<span class="hl-number">${k(d[0])}</span>`,l+=d[0].length;continue}}if(/[a-zA-Z_$]/.test(c)){let d=l+1;for(;d<i&&/[a-zA-Z0-9_$]/.test(n[d]??"");)d++;const u=n.slice(l,d),m=t?u.toLowerCase():u;if(e.keywords.has(m))o+=`<span class="hl-keyword">${k(u)}</span>`;else if((s=e.builtins)!=null&&s.has(m))o+=`<span class="hl-builtin">${k(u)}</span>`;else{let h=d;for(;h<i&&(n[h]===" "||n[h]===" ");)h++;n[h]==="("?o+=`<span class="hl-fn">${k(u)}</span>`:o+=k(u)}l=d;continue}o+=k(c),l++}return o}const St=/^(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 Tt(n){let e="",t=0;const o=n.length;for(;t<o;){if(n.startsWith("<!--",t)){const l=n.indexOf("-->",t+4),i=l===-1?o:l+3;e+=`<span class="hl-comment">${k(n.slice(t,i))}</span>`,t=i;continue}if(n[t]==="<"){const l=n.indexOf(">",t);if(l===-1){e+=k(n.slice(t));break}const i=n.slice(t,l+1);e+=Bt(i),t=l+1;continue}e+=k(n[t]??""),t++}return e}function Bt(n){const e=n.slice(1,-1);let t='<span class="hl-punct"><</span>';const o=/^\/?[a-zA-Z][a-zA-Z0-9-]*/.exec(e);if(o){t+=`<span class="hl-tag">${k(o[0])}</span>`;let l=e.slice(o[0].length);const i=/\s+([a-zA-Z_:][a-zA-Z0-9_:.-]*)(\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+)))?/g;let r=0,s;for(;s=i.exec(l);){t+=k(l.slice(r,s.index)),t+=k(l.slice(s.index,s.index+s[0].indexOf(s[1]??""))),t+=`<span class="hl-attr">${k(s[1]??"")}</span>`;const a=l.slice(s.index+(s[0].indexOf(s[1]??"")+(s[1]??"").length),s.index+s[0].length);if(a.includes("=")){const c=a.indexOf("=");t+=k(a.slice(0,c+1));const d=a.slice(c+1);t+=`<span class="hl-string">${k(d)}</span>`}r=s.index+s[0].length}t+=k(l.slice(r))}else t+=k(e);return t+='<span class="hl-punct">></span>',t}function Nt(n){let e="",t=0;const o=n.length;let l=!1;for(;t<o;){if(n.startsWith("/*",t)){const r=n.indexOf("*/",t+2),s=r===-1?o:r+2;e+=`<span class="hl-comment">${k(n.slice(t,s))}</span>`,t=s;continue}const i=n[t]??"";if(i==="{"){l=!0,e+=k(i),t++;continue}if(i==="}"){l=!1,e+=k(i),t++;continue}if(i==='"'||i==="'"){const r=i;let s=t+1;for(;s<o&&n[s]!==r;)n[s]==="\\"?s+=2:s++;s=Math.min(s+1,o),e+=`<span class="hl-string">${k(n.slice(t,s))}</span>`,t=s;continue}if(/[a-zA-Z_-]/.test(i)||i==="@"||i==="#"||i==="."||i===":"){let r=t+1;for(;r<o&&/[a-zA-Z0-9_-]/.test(n[r]??"");)r++;const s=n.slice(t,r);if(i==="@")e+=`<span class="hl-keyword">${k(s)}</span>`;else if(l&&/^[a-zA-Z-]+$/.test(s)){let a=r;for(;a<o&&(n[a]===" "||n[a]===" ");)a++;n[a]===":"?e+=`<span class="hl-prop">${k(s)}</span>`:e+=k(s)}else e+=`<span class="hl-tag">${k(s)}</span>`;t=r;continue}if(/[0-9]/.test(i)){const r=/^[0-9.]+(px|em|rem|%|vh|vw|s|ms|deg|fr)?/.exec(n.slice(t));if(r){e+=`<span class="hl-number">${k(r[0])}</span>`,t+=r[0].length;continue}}e+=k(i),t++}return e}function Mt(n){return n.split(`
|
|
16
|
+
`).map($t).join(`
|
|
17
|
+
`)}function $t(n){const e=/^(#{1,6})\s+(.*)$/.exec(n);if(e)return`<span class="hl-keyword">${k(e[1]??"")}</span> <span class="hl-tag">${ie(e[2]??"")}</span>`;if(n.startsWith(">"))return`<span class="hl-comment">${k(n)}</span>`;if(n.startsWith("```"))return`<span class="hl-keyword">${k(n)}</span>`;const t=/^(\s*)([-*+]|\d+\.)\s+(.*)$/.exec(n);return t?`${t[1]??""}<span class="hl-keyword">${k(t[2]??"")}</span> ${ie(t[3]??"")}`:ie(n)}function ie(n){let e=k(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 k(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function T(n){n.addEventListener("mousedown",e=>e.preventDefault())}const re=["#000000","#5c5c5c","#9c9c9c","#cfcfcf","#ffffff","#e03131","#f76707","#f59f00","#94d82d","#0ca678","#1c7ed6","#7048e8","#d6336c","#fab005","#37b24d","#1098ad"];function se(n,e,t=[]){D();const o=document.createElement("div");o.className="aw-popover aw-color-popover",o.dataset.popover="true",T(o);const l=d=>{e(d),o.remove()},i=d=>{const u=document.createElement("button");return u.type="button",u.className="aw-color-swatch",u.style.backgroundColor=d,u.setAttribute("aria-label",d),u.title=d,T(u),u.addEventListener("click",m=>{m.stopPropagation(),l(d)}),u},r=document.createElement("div");r.className="aw-color-grid";for(const d of re)r.appendChild(i(d));o.appendChild(r);const s=document.createElement("button");s.type="button",s.className="aw-popover-action",s.textContent="기본색",T(s),s.addEventListener("click",d=>{d.stopPropagation(),l(null)});const a=document.createElement("button");a.type="button",a.className="aw-popover-action",a.textContent="사용자 지정",T(a);const c=document.createElement("input");if(c.type="color",c.tabIndex=-1,c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.left="-9999px",c.style.width="0",c.style.height="0",c.style.opacity="0",c.style.pointerEvents="none",c.addEventListener("change",()=>{l(c.value)}),a.addEventListener("click",d=>{d.stopPropagation(),c.click()}),o.appendChild(s),o.appendChild(a),o.appendChild(c),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 m of t)u.appendChild(i(m));o.appendChild(u)}R(o,n)}const zt=[{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:E.bulletList,glyphIsSvg:!0,divider:!0},{label:"번호 매기기 목록",kind:"orderedList",attrs:{},glyph:E.orderedList,glyphIsSvg:!0},{label:"인용구",kind:"blockquote",attrs:{},glyph:E.blockquote,glyphIsSvg:!0,divider:!0},{label:"코드 블록",kind:"codeBlock",attrs:{},glyph:E.codeBlock,glyphIsSvg:!0},{label:"링크",kind:"linkCard",attrs:{},glyph:E.link,glyphIsSvg:!0,divider:!0},{label:"이미지",kind:"image",attrs:{},glyph:E.image,glyphIsSvg:!0},{label:"표",kind:"table",attrs:{},glyph:E.table,glyphIsSvg:!0},{label:"유튜브",kind:"youtube",attrs:{},glyph:E.youtube,glyphIsSvg:!0},{label:"파일 첨부",kind:"file",attrs:{},glyph:E.attachFile,glyphIsSvg:!0},{label:"구분선",kind:"hr",attrs:{},glyph:E.hr,glyphIsSvg:!0},{label:"HTML",kind:"importHtml",attrs:{},glyph:E.importHtml,glyphIsSvg:!0,divider:!0},{label:"Markdown",kind:"importMarkdown",attrs:{},glyph:E.importMarkdown,glyphIsSvg:!0}];function It(n,e){D();const t=document.createElement("div");t.className="aw-popover aw-block-type-popover",t.dataset.popover="true",T(t);for(const o of zt){if(o.divider){const s=document.createElement("div");s.className="aw-popover-divider",t.appendChild(s)}const l=document.createElement("button");l.type="button",l.className="aw-popover-item";const i=document.createElement("span");i.className="aw-popover-item-glyph",o.glyphIsSvg?i.innerHTML=o.glyph:i.textContent=o.glyph;const r=document.createElement("span");r.className="aw-popover-item-label",r.textContent=o.label,o.size&&(r.style.fontSize=o.size),o.weight&&(r.style.fontWeight=o.weight),l.appendChild(i),l.appendChild(r),T(l),l.addEventListener("click",s=>{s.stopPropagation(),t.remove(),e({kind:o.kind,attrs:o.attrs})}),t.appendChild(l)}R(t,n)}function Rt(n,e){D();const t=document.createElement("div");t.className="aw-popover aw-align-popover",t.dataset.popover="true",T(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 l of o){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-popover-item-icon",i.setAttribute("aria-label",l.label),i.title=l.label,i.innerHTML=E[l.icon]??"",T(i),i.addEventListener("click",r=>{r.stopPropagation(),t.remove(),e(l.value)}),t.appendChild(i)}R(t,n)}function Dt(n,e,t){dt(),D();const o=document.createElement("div");o.className="aw-popover aw-font-family-popover",o.dataset.popover="true",T(o);for(const l of W){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-font-family-item",t&&t===l.id&&i.classList.add("aw-popover-item-active"),i.title=l.label;const r=document.createElement("span");r.className="aw-font-family-name",r.textContent=l.label;const s=document.createElement("span");s.className="aw-font-family-preview",s.textContent="가A",s.style.fontFamily=l.stack,i.appendChild(r),i.appendChild(s),T(i),i.addEventListener("click",a=>{a.stopPropagation(),o.remove(),e({id:l.id,label:l.label,stack:l.stack})}),o.appendChild(i)}R(o,n)}function Ht(n,e,t){D();const o=document.createElement("div");o.className="aw-popover aw-code-lang-popover",o.dataset.popover="true",T(o);for(const l of Be){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-code-lang-item",t===l.id&&i.classList.add("aw-popover-item-active"),i.title=l.label;const r=document.createElement("span");r.className="aw-popover-item-label",r.textContent=l.label,i.appendChild(r),T(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({id:l.id,label:l.label})}),o.appendChild(i)}R(o,n)}const Ft=[{action:"rowAbove",label:"위에 행 추가"},{action:"rowBelow",label:"아래에 행 추가"},{action:"colLeft",label:"왼쪽에 열 추가",divider:!0},{action:"colRight",label:"오른쪽에 열 추가"},{action:"deleteRow",label:"행 삭제",divider:!0},{action:"deleteCol",label:"열 삭제"}];function Pt(n,e){D();const t=document.createElement("div");t.className="aw-popover aw-table-menu-popover",t.dataset.popover="true",T(t);for(const o of Ft){if(o.divider){const i=document.createElement("div");i.className="aw-popover-divider",t.appendChild(i)}const l=document.createElement("button");l.type="button",l.className="aw-popover-item aw-table-menu-item",l.textContent=o.label,T(l),l.addEventListener("click",i=>{i.stopPropagation(),t.remove(),e(o.action)}),t.appendChild(l)}R(t,n)}function Ot(n,e,t){D();const o=document.createElement("div");o.className="aw-popover aw-font-size-popover",o.dataset.popover="true",T(o);for(const l of at){const i=document.createElement("button");i.type="button",i.className="aw-popover-item aw-font-size-item",t===l&&i.classList.add("aw-popover-item-active"),i.title=`${l}px`;const r=document.createElement("span");r.className="aw-font-size-label",r.textContent=String(l),i.appendChild(r),T(i),i.addEventListener("click",s=>{s.stopPropagation(),o.remove(),e({px:l})}),o.appendChild(i)}R(o,n)}function _t(n,e){D();const t=2,o=12,l=document.createElement("div");l.className="aw-popover aw-table-popover",l.dataset.popover="true";const i=document.createElement("div");i.className="aw-table-picker-grid";const r=document.createElement("div");r.className="aw-table-status";let s=t,a=t,c=0,d=0;const u=[];function m(){for(let p=0;p<u.length;p++){const g=u[p];if(g)for(let b=0;b<g.length;b++){const v=g[b];v&&v.classList.toggle("aw-table-cell-active",p<c&&b<d)}}r.textContent=c>0&&d>0?`${c} × ${d} 표`:"크기를 선택하세요"}function h(){i.innerHTML="",i.style.gridTemplateColumns=`repeat(${a}, 18px)`,i.style.gridTemplateRows=`repeat(${s}, 18px)`,u.length=0;for(let p=0;p<s;p++){const g=[];for(let b=0;b<a;b++){const v=document.createElement("div");v.className="aw-table-cell",v.dataset.row=String(p+1),v.dataset.col=String(b+1),i.appendChild(v),g.push(v)}u.push(g)}m()}h(),i.addEventListener("mousemove",p=>{const g=p.target;if(!g.classList.contains("aw-table-cell"))return;const b=parseInt(g.dataset.row??"0",10),v=parseInt(g.dataset.col??"0",10);c=b,d=v;let B=!1;b>=s&&s<o&&(s=Math.min(o,b+1),B=!0),v>=a&&a<o&&(a=Math.min(o,v+1),B=!0),B?h():m()}),i.addEventListener("click",p=>{const g=p.target;if(!g.classList.contains("aw-table-cell"))return;const b=parseInt(g.dataset.row??"0",10),v=parseInt(g.dataset.col??"0",10);b>0&&v>0&&(e({rows:b,cols:v}),l.remove())});function f(p){p.key==="Escape"&&(l.remove(),document.removeEventListener("keydown",f))}document.addEventListener("keydown",f),l.appendChild(i),l.appendChild(r),R(l,n)}function R(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 l=()=>{const c=e.getBoundingClientRect();n.style.top=`${c.bottom+4}px`,n.style.left=`${c.left}px`};l(),document.body.appendChild(n);const i=()=>l(),r=()=>l();window.addEventListener("scroll",i,!0),window.addEventListener("resize",r);function s(c){!n.contains(c.target)&&!e.contains(c.target)&&n.remove()}setTimeout(()=>{document.addEventListener("click",s)},0);const a=n.remove.bind(n);n.remove=function(){window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",r),document.removeEventListener("click",s),a()}}function D(){document.querySelectorAll('[data-popover="true"]').forEach(n=>n.remove())}function Hn(n){}const qt=["script","noscript","meta","link","style","base"],jt=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"]);async function Ut(n,e={}){const t=e.settleMs??1e3,o=e.timeoutMs??3e4,l=e.width??1024,i=e.mountTarget??null;return new Promise((r,s)=>{const a=document.createElement("iframe");a.setAttribute("aria-hidden","true"),a.setAttribute("tabindex","-1"),a.style.position="fixed",a.style.left="-99999px",a.style.top="0",a.style.width=`${l}px`,a.style.height="768px",a.style.border="0",a.style.opacity="0",a.style.pointerEvents="none";let c=!1;const d=()=>{a.parentNode&&a.parentNode.removeChild(a)},u=p=>{c||(c=!0,d(),s(p))},m=p=>{c||(c=!0,d(),r(p))},h=window.setTimeout(()=>{u(new Error("HTML 로드 시간 초과"))},o),f=()=>{var B;const p=a.contentDocument;if(!p||!p.body||p.body.children.length===0&&(p.body.textContent??"").trim()==="")return;const g=a.contentWindow,b=(g==null?void 0:g.requestAnimationFrame)??window.requestAnimationFrame;(p.fonts&&typeof((B=p.fonts.ready)==null?void 0:B.then)=="function"?p.fonts.ready:Promise.resolve()).then(()=>{const C=()=>{window.setTimeout(()=>{if(!c)try{const A=a.contentWindow,S=a.contentDocument;if(!A||!S||!S.body){window.clearTimeout(h),u(new Error("iframe document 접근 실패"));return}const $=Wt(S.body,A,i);window.clearTimeout(h),m($)}catch(A){window.clearTimeout(h),u(A instanceof Error?A:new Error(String(A)))}},t)};b(()=>b(C))})};a.addEventListener("load",f),a.srcdoc=n,document.body.appendChild(a)})}function Wt(n,e,t){var r;const o=n.ownerDocument;if(!o)throw new Error("body has no ownerDocument");const l=document.createElement("div"),i=Kt(o,e,t);try{for(let a=0;a<n.attributes.length;a++){const c=n.attributes.item(a);c&&c.name!=="style"&&l.setAttribute(c.name,c.value)}const s=Ne(n,null,"div",i.get,e);s.length>0&&l.setAttribute("style",s);for(const a of Array.from(n.children)){const c=document.importNode(a,!0);Me(a,c,n,i.get,e),l.appendChild(c)}}finally{i.cleanup()}for(const s of qt)for(const a of Array.from(l.querySelectorAll(s)))(r=a.parentNode)==null||r.removeChild(a);return l.style.width="auto",l.style.maxWidth="none",l.style.height="auto",l.style.maxHeight="none",l.setAttribute("data-imported-html","true"),[l]}function Kt(n,e,t){var d;let o,l,i;const r=((d=t==null?void 0:t.ownerDocument)==null?void 0:d.defaultView)??null;if(t&&r){o=t.ownerDocument,l=r;const u=o.createElement("div");u.setAttribute("data-imported-html","true"),u.setAttribute("aria-hidden","true"),u.style.cssText="position:absolute;left:-99999px;top:0;visibility:hidden;pointer-events:none;",t.appendChild(u),i=u}else{o=n,l=e;const u=o.createElement("div");u.setAttribute("aria-hidden","true"),u.style.cssText="position:absolute;left:-99999px;top:0;width:0;height:0;overflow:hidden;visibility:hidden;",o.body.appendChild(u),i=u}const s=new Map;return{get:u=>{const m=s.get(u);if(m)return m;const h=o.createElement(u);i.appendChild(h);const f=l.getComputedStyle(h),p=new Map;for(let g=0;g<f.length;g++){const b=f.item(g);b&&p.set(b,f.getPropertyValue(b))}return i.removeChild(h),s.set(u,p),p},cleanup:()=>{i.parentNode&&i.parentNode.removeChild(i)}}}function Ne(n,e,t,o,l){const i=l.getComputedStyle(n),r=e?l.getComputedStyle(e):null,s=o(t);let a="";for(let c=0;c<i.length;c++){const d=i.item(c);if(!d)continue;const u=i.getPropertyValue(d);if(u){if(jt.has(d)){if(r&&r.getPropertyValue(d)===u)continue}else if(s.get(d)===u)continue;a+=`${d}:${u};`}}return a}function Me(n,e,t,o,l){if(n.nodeType===1&&e.nodeType===1){const a=Ne(n,t,n.tagName.toLowerCase(),o,l);a.length>0?e.setAttribute("style",a):e.hasAttribute("style")&&e.removeAttribute("style")}const i=n.children,r=e.children,s=Math.min(i.length,r.length);for(let a=0;a<s;a++){const c=i[a],d=r[a];c&&d&&Me(c,d,n,o,l)}}function Yt(n){const e=Vt(n),t=document.createElement("div");t.innerHTML=e;const o=[];for(const l of Array.from(t.children))l instanceof HTMLElement&&o.push(l);return o}function Vt(n){const t=n.replace(/\r\n?/g,`
|
|
18
18
|
`).replace(/\s+$/,"").split(`
|
|
19
|
-
`),o=[];let l=0;for(;l<t.length;){const i=t[l]??"";if(i.trim()===""){l++;continue}const r=/^```\s*([\w-]*)\s*$/.exec(i);if(r){const
|
|
20
|
-
`))}</code></pre>`);continue}const s=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(i);if(s){const
|
|
21
|
-
`)}function
|
|
19
|
+
`),o=[];let l=0;for(;l<t.length;){const i=t[l]??"";if(i.trim()===""){l++;continue}const r=/^```\s*([\w-]*)\s*$/.exec(i);if(r){const c=r[1]??"",d=[];for(l++;l<t.length&&!/^```\s*$/.test(t[l]??"");)d.push(t[l]??""),l++;l<t.length&&l++;const u=c?` data-language="${K(c)}"`:"";o.push(`<pre><code${u}>${G(d.join(`
|
|
20
|
+
`))}</code></pre>`);continue}const s=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(i);if(s){const c=(s[1]??"#").length;o.push(`<h${c}>${q(s[2]??"")}</h${c}>`),l++;continue}if(/^[\s]*([-*_])(\s*\1){2,}[\s]*$/.test(i)){o.push("<hr>"),l++;continue}if($e(i,t[l+1]??"")){const c=[i];for(l++,c.push(t[l]??""),l++;l<t.length&&(t[l]??"").includes("|")&&(t[l]??"").trim()!=="";)c.push(t[l]??""),l++;o.push(Zt(c));continue}if(i.startsWith(">")){const c=[];for(;l<t.length&&(t[l]??"").startsWith(">");)c.push((t[l]??"").replace(/^>\s?/,"")),l++;const d=q(c.join(" ").trim());o.push(`<blockquote><p>${d}</p></blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(i)){const c=ze(t,l,/^[\s]*[-*+]\s+(.*)$/);l=c.next,o.push(`<ul>${c.html}</ul>`);continue}if(/^[\s]*\d+\.\s+/.test(i)){const c=ze(t,l,/^[\s]*\d+\.\s+(.*)$/);l=c.next,o.push(`<ol>${c.html}</ol>`);continue}const a=[];for(;l<t.length&&(t[l]??"").trim()!==""&&!Gt(t[l]??"",t[l+1]??"");)a.push(t[l]??""),l++;a.length>0&&o.push(`<p>${q(Xt(a))}</p>`)}return o.join(`
|
|
21
|
+
`)}function Gt(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)||$e(n,e)}function $e(n,e){return n.includes("|")?/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/.test(e):!1}function Zt(n){if(n.length<2)return"";const e=ae(n[0]??""),o=ae(n[1]??"").map(s=>{const a=s.trim(),c=a.startsWith(":"),d=a.endsWith(":");return c&&d?"center":d?"right":c?"left":null}),l=n.slice(2).map(ae),i=e.map((s,a)=>{const c=o[a];return`<th${c?` style="text-align:${c}"`:""}>${q(s.trim())}</th>`}).join(""),r=l.map(s=>`<tr>${s.map((c,d)=>{const u=o[d];return`<td${u?` style="text-align:${u}"`:""}>${q(c.trim())}</td>`}).join("")}</tr>`).join("");return`<table><thead><tr>${i}</tr></thead><tbody>${r}</tbody></table>`}function ae(n){return n.trim().replace(/^\|/,"").replace(/\|$/,"").split("|")}function ze(n,e,t){const o=[];let l=e;for(;l<n.length;){const i=n[l]??"";if(i.trim()===""){const s=n[l+1]??"";if(t.test(s)){l++;continue}break}const r=t.exec(i);if(!r)break;o.push(`<li>${q(r[1]??"")}</li>`),l++}return{html:o.join(""),next:l}}function Xt(n){const e=[];for(let t=0;t<n.length;t++){const o=n[t]??"",l=t===n.length-1;!l&&/ +$/.test(o)?e.push(o.replace(/\s+$/,"")+`
|
|
22
22
|
<br>
|
|
23
|
-
`):e.push(l?o:o+" ")}return e.join("")}function q(n){const e=[];let t=n.replace(/(`+)([\s\S]+?)\1/g,(o,l,i)=>`\0CODE${e.push(`<code>${G(i)}</code>`)-1}\0`);return t=G(t),t=t.replace(/<(https?:\/\/[^\s&]+)>/g,(o,l)=>`<a href="${K(l)}" target="_blank" rel="noopener">${G(l)}</a>`),t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,l,i)=>`<img src="${K(i)}" alt="${K(l)}">`),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,l,i)=>`<a href="${K(i)}" target="_blank" rel="noopener">${l}</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(/CODE(\d+)/g,(o,l)=>{const i=Number(l);return e[i]??""}),t}function G(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function K(n){return n.replace(/&/g,"&").replace(/"/g,""")}const Y=["bold","italic","underline","strike"],Vt={kind:"paragraph",label:"단락",allowsInlineFormat:!0,allowedMarks:Y,matches:n=>n.tagName==="P"?{kind:"paragraph",attrs:{}}:null,create:()=>J(document.createElement("p")),isEmpty:n=>O(n)},Gt={kind:"heading",label:"제목",allowsInlineFormat:!0,allowedMarks:["italic"],matches:n=>{const e=/^H([1-6])$/.exec(n.tagName);return e?{kind:"heading",attrs:{level:Number(e[1])}}:null},create:n=>{const e=bn(n==null?void 0:n.level);return J(document.createElement(`h${e}`))},isEmpty:n=>O(n)},Zt={kind:"bulletList",label:"글머리 목록",allowsInlineFormat:!0,allowedMarks:Y,matches:n=>n.tagName==="UL"?{kind:"bulletList",attrs:{}}:null,create:()=>Ue("ul"),isEmpty:n=>We(n)},Xt={kind:"orderedList",label:"번호 매기기 목록",allowsInlineFormat:!0,allowedMarks:Y,matches:n=>n.tagName==="OL"?{kind:"orderedList",attrs:{}}:null,create:()=>Ue("ol"),isEmpty:n=>We(n)},Qt={kind:"blockquote",label:"인용구",allowsInlineFormat:!0,allowedMarks:["bold","underline","strike"],matches:n=>n.tagName==="BLOCKQUOTE"?{kind:"blockquote",attrs:{}}:null,create:()=>{const n=document.createElement("blockquote");return n.appendChild(J(document.createElement("p"))),n},isEmpty:n=>O(n)},Jt={kind:"codeBlock",label:"코드 블록",allowsInlineFormat:!1,allowedMarks:[],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=>O(n)},en={kind:"image",label:"이미지",allowsInlineFormat:!1,allowedMarks:[],matches:n=>{if(n.tagName==="FIGURE"){const e=n.querySelector(":scope > img"),t=Ke(e),o=n.getAttribute("style");return o&&(t.wrapperStyle=o),{kind:"image",attrs:t}}return n.tagName==="IMG"?{kind:"image",attrs:Ke(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(de()),e.appendChild(ce()),e},isEmpty:n=>{const e=n.tagName==="IMG"?n:n.querySelector(":scope > img");return!e||!e.getAttribute("src")}};function ce(){const n=document.createElement("span");return n.className="aw-resize-handle",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n}function de(){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=tn[e],n.appendChild(t)}return n}const tn={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>'},nn={kind:"table",label:"표",allowsInlineFormat:!0,allowedMarks:Y,matches:n=>{var l;if(n.tagName!=="TABLE")return null;const e=n.querySelectorAll(":scope > tbody > tr, :scope > tr"),t=e.length,o=((l=e[0])==null?void 0:l.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"),l=document.createElement("tbody");for(let i=0;i<e;i++){const r=document.createElement("tr");for(let s=0;s<t;s++){const c=document.createElement("td");c.appendChild(document.createElement("br")),r.appendChild(c)}l.appendChild(r)}return o.appendChild(l),o},isEmpty:n=>n.querySelectorAll(":scope tr").length===0},on={kind:"hr",label:"구분선",allowsInlineFormat:!1,allowedMarks:[],matches:n=>n.tagName==="HR"?{kind:"hr",attrs:{}}:null,create:()=>{const n=document.createElement("hr");return n.setAttribute("contenteditable","false"),n},isEmpty:()=>!1},ln={kind:"youtube",label:"유튜브",allowsInlineFormat:!1,allowedMarks:[],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=`https://www.youtube-nocookie.com/embed/${e}`),o.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),o.setAttribute("allowfullscreen",""),o.setAttribute("frameborder","0"),o.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),t.appendChild(o),t.appendChild(de()),t.appendChild(ce()),t},isEmpty:n=>!n.getAttribute("data-youtube-id")},rn={kind:"linkCard",label:"링크",allowsInlineFormat:!1,allowedMarks:[],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,l=((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,r={};return e&&(r.href=e),t&&(r.text=t),o&&(r.description=o),l&&(r.image=l),i&&(r.favicon=i),{kind:"linkCard",attrs:r}},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)??"",l=(n==null?void 0:n.image)??"",i=(n==null?void 0:n.favicon)??sn(e),r=document.createElement("a");if(r.className="aw-link-card",l&&r.classList.add("aw-link-card-with-image"),r.href=e,r.target="_blank",r.rel="noopener",r.setAttribute("contenteditable","false"),l){const u=document.createElement("img");u.className="aw-link-card-image",u.src=l,u.alt="",u.loading="lazy",r.appendChild(u)}const s=document.createElement("span");s.className="aw-link-card-body";const 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),r.appendChild(s),r},isEmpty:n=>!n.getAttribute("href")};function Re(n){try{return new URL(n).hostname}catch{return""}}function sn(n){const e=Re(n);return e?`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`:""}const an={kind:"file",label:"파일",allowsInlineFormat:!1,allowedMarks:[],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"),l=o?Number(o):void 0,i=n.getAttribute("data-file-type")??void 0,r={};return e&&(r.fileSrc=e),t&&(r.fileName=t),l!==void 0&&!Number.isNaN(l)&&(r.fileSize=l),i&&(r.fileType=i),{kind:"file",attrs:r}},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='<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>';const o=document.createElement("span");o.className="aw-file-meta";const l=document.createElement("span");l.className="aw-file-name",l.textContent=(n==null?void 0:n.fileName)??"파일",o.appendChild(l);const i=[],r=dn(n==null?void 0:n.fileName,n==null?void 0:n.fileType);if(r&&i.push(r),(n==null?void 0:n.fileSize)!==void 0&&i.push(cn(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='<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>',e.appendChild(t),e.appendChild(o),e.appendChild(s),e},isEmpty:n=>!n.getAttribute("href")};function cn(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(1)} KB`:n<1073741824?`${(n/1024/1024).toFixed(1)} MB`:`${(n/1024/1024/1024).toFixed(1)} GB`}function dn(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():""}const un={kind:"importedHtml",label:"HTML",allowsInlineFormat:!1,allowedMarks:[],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},ze={kind:"unknown",label:"알 수 없음",allowsInlineFormat:!1,allowedMarks:[],matches:()=>null,create:()=>J(document.createElement("p")),isEmpty:n=>O(n)},ue=[Vt,Gt,Zt,Xt,Qt,Jt,en,nn,on,rn,ln,an,un],z=(()=>{const n={unknown:ze};for(const e of ue)n[e.kind]=e;return n})();function j(n){for(const e of ue){const t=e.matches(n);if(t)return{type:e,match:t}}return{type:ze,match:{kind:"unknown",attrs:{}}}}const _="data-block-id";class pe{constructor(){k(this,"counter",0);k(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(_);if(t)return this.seen.add(t),t;const o=this.generate();return e.setAttribute(_,o),o}get(e){return e.getAttribute(_)}}function Z(n,e){const t=new Set;for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const l=o.getAttribute(_);if(l&&!t.has(l)){t.add(l),e.observe(l);continue}const i=e.generate();o.setAttribute(_,i),t.add(i)}}function he(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(de()),e.querySelector(":scope > .aw-resize-handle")||e.appendChild(ce()))}function De(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 He(n){return{id:n.id,kind:n.kind,attrs:{...n.attrs},html:n.element.innerHTML}}function me(n){return n.map(He)}function Fe(n){const t=(z[n.kind]??z.unknown).create(n.attrs);return t.setAttribute(_,n.id),n.html.length>0&&(t.innerHTML=n.html),t}function _e(n,e){for(;n.firstChild;)n.removeChild(n.firstChild);for(const t of e)n.appendChild(Fe(t))}function X(n,e){const t=[];for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const{match:l}=j(o);t.push({id:e(o),kind:l.kind,attrs:l.attrs,element:o})}return t}function Q(n,e,t){let o=n;for(;o&&o!==e;){if(o.parentNode===e&&o.nodeType===Node.ELEMENT_NODE){const l=o,{match:i}=j(l);return{id:t(l),kind:i.kind,attrs:i.attrs,element:l}}o=o.parentNode}return null}function Oe(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 Pe(t)}case"blockquote":{const t=Array.from(e.querySelectorAll(":scope > p"));return t.length>0?Pe(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 Pe(n){const e=[];return n.forEach((t,o)=>{o>0&&e.push(document.createElement("br"));for(const l of Array.from(t.childNodes))e.push(l)}),e}function qe(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){for(;o.firstChild;)o.removeChild(o.firstChild);for(const l of t)o.appendChild(l)}}function pn(n={}){const e=n.fg||"currentColor",t=n.bg||"transparent",o=n.mode==="dark"?!0:n.mode==="light"?!1:hn(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 hn(n,e){const t=je(n);if(t!==null)return t>.5;const o=je(e);return o!==null?o<.5:!0}function je(n){if(!n)return null;const e=n.trim();let t=-1,o=-1,l=-1;const i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e);if(i&&i[1]){const r=i[1];r.length===3?(t=parseInt(r[0]+r[0],16),o=parseInt(r[1]+r[1],16),l=parseInt(r[2]+r[2],16)):(t=parseInt(r.slice(0,2),16),o=parseInt(r.slice(2,4),16),l=parseInt(r.slice(4,6),16))}else{const r=/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/.exec(e);r&&(t=Number(r[1]),o=Number(r[2]),l=Number(r[3]))}return t<0?null:(.299*t+.587*o+.114*l)/255}function fe(n){const e=getComputedStyle(n),t=a=>{const d=e.getPropertyValue(a).trim();return d.length>0?d:void 0},o={},l=t("--aw-primary"),i=t("--aw-fg"),r=t("--aw-bg"),s=t("--aw-border"),c=t("--aw-fg-muted");return l&&(o.primary=l),i&&(o.fg=i),r&&(o.bg=r),s&&(o.border=s),c&&(o.fgMuted=c),o}function mn(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 fn(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 ge(n,e={}){const t=pn(e),o=mn(t),l=fn(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")){be(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 r=o[i.tagName];r&&be(i,r)}for(const[i,r]of Object.entries(l))for(const s of Array.from(n.querySelectorAll(i)))s instanceof HTMLElement&&(s.closest("[data-imported-html]")||be(s,r))}function be(n,e){const t=(n.getAttribute("style")??"").trim();if(!t){n.setAttribute("style",e);return}const o=e.replace(/;\s*$/,""),l=t.replace(/;\s*$/,"");n.setAttribute("style",`${o};${l}`)}function ye(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 U(n){const e=document.getSelection();if(!e)return;const t=document.createRange();if(n.tagName==="HR")t.setStartAfter(n);else{const o=gn(n);t.selectNodeContents(o),t.collapse(!0)}e.removeAllRanges(),e.addRange(t)}function gn(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 J(n){return n.appendChild(document.createElement("br")),n}function Ue(n){const e=document.createElement(n),t=document.createElement("li");return t.appendChild(document.createElement("br")),e.appendChild(t),e}function We(n){const e=n.querySelectorAll(":scope > li");return e.length===0?!0:e.length===1?O(e[0]):!1}function O(n){return(n.textContent??"").replace(//g,"").trim().length===0}function bn(n){return n===void 0||n<1?1:n>6?6:n}function Ke(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 Ye={bulletList:"bulletList",orderedList:"orderedList",blockquote:"blockquote",codeBlock:"codeBlock"},ke="application/x-aeriz-block";class yn{constructor(e){k(this,"root");k(this,"content");k(this,"toolbar",null);k(this,"contentWrap");k(this,"handlesLayer");k(this,"dropIndicator");k(this,"handles",new Map);k(this,"blockLabelPill");k(this,"statusBar");k(this,"statusBlockEl");k(this,"statusBlocksEl");k(this,"statusCharsEl");k(this,"statusSourceEl");k(this,"options");k(this,"observer");k(this,"blockIds",new pe);k(this,"idFor",e=>this.blockIds.ensure(e));k(this,"listeners",new Set);k(this,"handleSelectionChange",()=>this.queueSync());k(this,"handleResize",()=>this.repositionHandles());k(this,"state",Sn());k(this,"destroyed",!1);k(this,"syncQueued",!1);k(this,"lastSerialized","");k(this,"recentCustomColors",[]);k(this,"cellSelStart",null);k(this,"cellSelDrag",!1);k(this,"codeHighlightTimer",null);k(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 r=e.toolbar??N;this.toolbar=new Je(r,{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>",he(this.content),Z(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",r=>r.preventDefault()),this.blockLabelPill.addEventListener("click",r=>{r.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=Xe("되돌리기 (Ctrl+Z)",x.undo,()=>{this.content.focus(),document.execCommand("undo")}),l=Xe("다시 실행 (Ctrl+Y)",x.redo,()=>{this.content.focus(),document.execCommand("redo")});this.statusBlockEl=document.createElement("span"),this.statusBlockEl.className="aw-status-item",t.appendChild(o),t.appendChild(l),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",r=>this.handleKeyDown(r)),document.addEventListener("selectionchange",this.handleSelectionChange),this.content.addEventListener("mousemove",r=>this.handleTableCursor(r)),this.content.addEventListener("mousedown",r=>this.handleTableResizeStart(r)),this.content.addEventListener("click",r=>this.handleBlockAlignClick(r)),this.content.addEventListener("mousedown",r=>this.handleCellSelStart(r)),this.content.addEventListener("mousemove",r=>this.handleCellSelMove(r)),document.addEventListener("mouseup",()=>this.handleCellSelEnd()),this.content.addEventListener("input",()=>this.scheduleCodeHighlight()),this.content.addEventListener("dragstart",r=>{const s=r.target;s&&(s.closest(".aw-block-handle")||s.closest("table")&&r.preventDefault())}),this.content.addEventListener("dragover",r=>this.handleDragOver(r)),this.content.addEventListener("drop",r=>this.handleDrop(r)),this.content.addEventListener("dragleave",r=>this.handleDragLeave(r)),window.addEventListener("resize",this.handleResize),this.sync()}getHTML(){const e=this.content.cloneNode(!0),t=fe(this.root),o=this.currentTheme();return o&&(t.mode=o),ge(e,t),ye(e),e.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 X(this.content,this.idFor)}serialize(){return me(this.getBlocks())}findBlockById(e){const t=this.content.querySelector(`[data-block-id="${e}"]`);return t?Q(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)?Q(t,this.content,this.idFor):null}setBlockType(e,t,o){const l=z[e];if(!l)return;const i=o?this.findBlockById(o):this.getActiveBlock(),r=i?this.replaceBlock(i,l,t):this.appendBlock(l,t);this.flush(),this.content.focus(),U(r)}replaceBlock(e,t,o){const l=Oe(e),i=t.create(o);return qe(i,t.kind,l),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;he(this.content),Z(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(!Ve(this.getActiveBlock()))return;const o=this.detectActiveFontId();Rt(t,l=>this.applyFontFamily(l.stack),o??void 0);break}case"fontSize":{if(!Ge(this.getActiveBlock()))return;const o=this.detectActiveFontSize();Ft(t,l=>this.applyFontSize(l.px),o??void 0);break}case"color":{if(!ee(this.getActiveBlock()))return;se(t,o=>this.handleColorPick(o,"foreColor"),this.recentCustomColors);break}case"backgroundColor":{if(!ee(this.getActiveBlock()))return;se(t,o=>this.handleColorPick(o,"hiliteColor"),this.recentCustomColors);break}case"align":{if(!we(this.getActiveBlock()))return;It(t,o=>this.applyAlign(o));break}case"cellBg":{if(!te(this.getActiveBlock()))return;const o=this.getSelectedTableCells();if(o.length===0)return;se(t,l=>this.applyCellBgToCells(o,l),this.recentCustomColors);break}case"tableMenu":{if(!te(this.getActiveBlock()))return;Ht(t,o=>this.runTableMenu(o));break}case"codeLang":{const o=this.getActiveBlock();if(!o||o.kind!=="codeBlock")return;const l=o.element.querySelector(":scope > code"),i=(l==null?void 0:l.getAttribute("data-language"))??void 0;zt(t,r=>this.applyCodeLanguage(o.element,r.id),i);break}case"bold":case"italic":case"underline":case"strike":this.applyMark(e);break}}applyMark(e){const t=this.getActiveBlock();if(!V(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&&!re.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||!we(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 l=t.element;if(t.kind==="blockquote"){const i=t.element.querySelector(":scope > p");i instanceof HTMLElement&&(l=i)}else if(t.kind==="table"){const i=this.getActiveTableCell();i&&(l=i)}l.style.textAlign=e,this.queueSync()}getActiveTableCell(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let 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,l=document.getSelection();if(!l||l.rangeCount===0)return[];const i=l.getRangeAt(0),r=ne(i.startContainer);if(!r||!o.contains(r))return[];if(i.collapsed)return[r];const s=ne(i.endContainer);return!s||!o.contains(s)||s===r?[r]:ve(o,r,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 l=o.closest("table");if(!(l instanceof HTMLTableElement))return;const i=ve(l,this.cellSelStart,o);if(!(i.length<=1)){this.cellSelDrag=!0,this.clearCellSelection();for(const r of i)r.classList.add("aw-cell-selected")}}handleCellSelEnd(){this.cellSelStart=null,this.cellSelDrag=!1}clearCellSelection(){const e=this.content.querySelectorAll(".aw-cell-selected");for(const t of Array.from(e))t.classList.remove("aw-cell-selected")}applyFontSizeToCells(e,t){let o=0;for(const l of e)l.isConnected&&(l.style.fontSize=`${t}px`,o++);o!==0&&(this.clearCellSelection(),this.flush())}applyCellBgToCells(e,t){let o=0;for(const l of e)l.isConnected&&(t?l.style.setProperty("background-color",t,"important"):l.style.removeProperty("background-color"),o++);o!==0&&(t&&!re.includes(t)&&(this.recentCustomColors=[t,...this.recentCustomColors.filter(l=>l!==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 l=o.children.length,i=document.createElement("tr");for(let r=0;r<l;r++){const s=document.createElement("td");s.appendChild(document.createElement("br")),i.appendChild(s)}e==="above"?o.parentNode.insertBefore(i,o):o.parentNode.insertBefore(i,o.nextSibling),this.flush()}insertColumn(e){const t=this.getActiveTableCell();if(!t)return;const o=t.closest("tr");if(!o)return;const l=Array.from(o.children).indexOf(t);if(l<0)return;const i=o.closest("table");if(i){for(const r of Array.from(i.querySelectorAll("tr"))){const s=r.children[l];if(!s)continue;const c=s.tagName.toLowerCase(),a=document.createElement(c);a.appendChild(document.createElement("br")),e==="left"?r.insertBefore(a,s):r.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??"",l=Cn(e);e.innerHTML=Et(o,t),l&&En(e,l)}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 r;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 l=t.closest("table");if(!l)return;const i=l.querySelector("tr");if(!(i&&i.children.length<=1)){for(const s of Array.from(l.querySelectorAll("tr")))(r=s.children[o])==null||r.remove();this.flush()}}handleTableCursor(e){var l,i;if(this.tableResize)return;const t=(i=(l=e.target)==null?void 0:l.closest)==null?void 0:i.call(l,"td, th");if(!(t instanceof HTMLTableCellElement)){this.content.style.cursor="";return}const o=Ze(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 l=(c=t==null?void 0:t.closest)==null?void 0:c.call(t,"td, th");if(!(l instanceof HTMLTableCellElement))return;const i=Ze(l,e.clientX,e.clientY);if(!i)return;if(e.preventDefault(),e.stopPropagation(),i==="right"){const a=l.closest("tr"),d=a?Array.from(a.children).indexOf(l):-1,u=l.closest("table");if(!u||d<0)return;const m=[];for(const f of Array.from(u.querySelectorAll("tr"))){const p=f.children[d];p instanceof HTMLTableCellElement&&m.push(p)}this.tableResize={kind:"col",startX:e.clientX,startY:e.clientY,initialSize:l.getBoundingClientRect().width,targetCells:m,targetRow:null},document.body.style.cursor="col-resize"}else{const a=l.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 r=a=>this.handleTableResizeMove(a),s=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s),document.body.style.cursor="",this.tableResize=null,this.flush()};document.addEventListener("mousemove",r),document.addEventListener("mouseup",s)}handleTableResizeMove(e){const t=this.tableResize;if(t){if(t.kind==="col"){const o=e.clientX-t.startX,l=Math.max(40,t.initialSize+o),i=`${Math.round(l)}px`;for(const r of t.targetCells)r.style.width=i}else if(t.targetRow){const o=e.clientY-t.startY,l=Math.max(20,t.initialSize+o);t.targetRow.style.height=`${Math.round(l)}px`}}}handleBlockAlignClick(e){var i,r;const t=(r=(i=e.target)==null?void 0:i.closest)==null?void 0:r.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 l=t.closest("figure, div.aw-youtube-embed");l instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),o==="center"?(l.style.marginLeft="auto",l.style.marginRight="auto"):o==="right"?(l.style.marginLeft="auto",l.style.marginRight="0"):(l.style.marginLeft="0",l.style.marginRight="auto"),this.flush())}startBlockResize(e,t){const o=e.getBoundingClientRect().width;document.body.style.cursor="nwse-resize",e.classList.add("aw-resizing");const l=r=>{const s=r.clientX-t,c=Math.max(80,o+s);e.style.width=`${Math.round(c)}px`},i=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",i),document.body.style.cursor="",e.classList.remove("aw-resizing"),this.flush()};document.addEventListener("mousemove",l),document.addEventListener("mouseup",i)}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 ct(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=ne(s.startContainer),a=ne(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(ve(d,c,a),e);return}}}this.content.focus();const l=document.getSelection();if(!l||l.rangeCount===0)return;const i=l.getRangeAt(0);if(!this.content.contains(i.commonAncestorContainer))return;const r=document.createElement("span");if(r.style.fontSize=`${e}px`,i.collapsed){r.appendChild(document.createTextNode("")),i.insertNode(r);const s=document.createRange();s.selectNodeContents(r),s.collapse(!1),l.removeAllRanges(),l.addRange(s)}else{try{i.surroundContents(r)}catch{const c=i.extractContents();r.appendChild(c),i.insertNode(r)}l.removeAllRanges();const s=document.createRange();s.selectNodeContents(r),l.addRange(s)}this.queueSync()}detectActiveFontSize(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let 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 st(o)}openBlockTypeMenu(e,t){$t(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"){_t(e,l=>{this.setBlockType("table",{rows:l.rows,cols:l.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){et({},this.currentTheme()).then(t=>{var r;if(!t.confirmed||!t.href)return;const o=t.href,l=((r=t.text)==null?void 0:r.trim())??"",i=l.length>0?l:o;this.setBlockType("linkCard",{href:o,text:i},e)})}openImageDialogAndApply(e){const t=this.resolveImageUploadFn();tt({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{o.confirmed&&o.src&&this.setBlockType("image",{src:o.src},e),this.queueSync()})}openYouTubeDialogAndApply(e){it(this.currentTheme()).then(t=>{if(!t.confirmed||!t.url)return;const o=xn(t.url);o&&this.setBlockType("youtube",{videoId:o},e)})}openImportHtmlDialogAndApply(e){nt(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 Pt(t.html)}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 l=e?this.content.querySelector(`[data-block-id="${e}"]`):null,i=[];for(const s of o){const c=Bn(s.tagName)?s:(()=>{const a=document.createElement("p");return a.appendChild(s),a})();c.setAttribute("data-block-explicit","true"),i.push(c)}if(l)if(l.tagName==="P"&&(l.textContent??"").trim().length===0&&i.length>0){const c=i[0];l.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=l;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 r=i[i.length-1];r&&U(r)})}openMarkdownImportDialogAndApply(e){ot(this.currentTheme()).then(t=>{if(!t.confirmed)return;if(!t.markdown||t.markdown.length===0){window.alert("가져올 Markdown 이 비어 있습니다.");return}let o;try{o=jt(t.markdown)}catch(r){console.error("Markdown 파싱 실패:",r);const s=r instanceof Error?r.message:String(r);window.alert(`Markdown 가져오기 실패: ${s}`);return}if(o.length===0){window.alert("Markdown 에서 가져올 본문이 없습니다.");return}for(const r of o)r.setAttribute("data-block-explicit","true");const l=e?this.content.querySelector(`[data-block-id="${e}"]`):null;if(l)if(l.tagName==="P"&&(l.textContent??"").trim().length===0&&o.length>0){const s=o[0];l.replaceWith(s);let c=s;for(let a=1;a<o.length;a++){const d=o[a];c.after(d),c=d}}else{let s=l;for(const c of o)s.after(c),s=c}else for(const r of o)this.content.appendChild(r);this.flush(),this.content.focus();const i=o[o.length-1];i&&U(i)})}openFileAttachmentDialogAndApply(e){const t=this.resolveFileUploadFn();lt({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{if(!o.confirmed)return;if(!o.src||o.src.length===0){window.alert("파일 URL 이 비어 있습니다.");return}const l={fileSrc:o.src},i=o.name&&o.name.length>0?o.name:Ln(o.src);i&&(l.fileName=i),o.size!==void 0&&(l.fileSize=o.size),o.type&&(l.fileType=o.type),this.setBlockType("file",l,e)})}resolveFileUploadFn(){if(this.options.onFileUpload)return this.options.onFileUpload;const e=this.options.fileUploadUrl;if(e)return async t=>{const o=new FormData;o.append("file",t);const l=await fetch(e,{method:"POST",body:o});if(!l.ok)throw new Error(`파일 업로드 실패: ${l.status}`);const i=await l.json(),r=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof r!="string"||r.length===0)throw new Error("파일 업로드 응답에 url 필드가 없습니다.");return r}}resolveImageUploadFn(){if(this.options.onImageUpload)return this.options.onImageUpload;const e=this.options.imageUploadUrl;if(e)return async t=>{const o=new FormData;o.append("file",t);const l=await fetch(e,{method:"POST",body:o});if(!l.ok)throw new Error(`이미지 업로드 실패: ${l.status}`);const i=await l.json(),r=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof r!="string"||r.length===0)throw new Error("이미지 업로드 응답에 url 필드가 없습니다.");return r}}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=X(this.content,this.idFor),t=this.getActiveBlock(),l=t!==null?{bold:oe("bold"),italic:oe("italic"),underline:oe("underline"),strike:oe("strikeThrough")}:{bold:!1,italic:!1,underline:!1,strike:!1};this.state={blocks:e,activeBlockId:(t==null?void 0:t.id)??null,inline:l},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 l=e.key.toLowerCase();let i=null;if(!e.shiftKey&&l==="b"?i="bold":!e.shiftKey&&l==="i"?i="italic":!e.shiftKey&&l==="u"?i="underline":e.shiftKey&&l==="x"&&(i="strike"),i){e.preventDefault(),this.applyMark(i);return}}if(e.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),U(o),this.flush()}syncBlockHandles(e){const t=new Set;for(const o of e){t.add(o.id);let l=this.handles.get(o.id);l||(l=this.createBlockHandle(o.id),this.handlesLayer.appendChild(l),this.handles.set(o.id,l)),this.positionHandle(l,o.element)}for(const[o,l]of this.handles)t.has(o)||(l.remove(),this.handles.delete(o))}repositionHandles(){if(this.destroyed)return;for(const o of this.state.blocks){const l=this.handles.get(o.id);l&&this.positionHandle(l,o.element)}const e=this.state.activeBlockId,t=e?this.state.blocks.find(o=>o.id===e):null;this.syncBlockLabelPill(t??null)}positionHandle(e,t){const o=t.getBoundingClientRect(),l=this.contentWrap.getBoundingClientRect(),i=22,r=o.height<i?(o.height-i)/2:0,s=o.top-l.top+this.contentWrap.scrollTop+r;e.style.top=`${s}px`}createBlockHandle(e){const 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(ke,e),i.dataTransfer.setData("text/plain",e),i.dataTransfer.effectAllowed="move",o.classList.add("is-dragging");const r=this.content.querySelector(`[data-block-id="${e}"]`);if(r){r.classList.add("is-block-dragging");try{i.dataTransfer.setDragImage(r,12,12)}catch{}}}),o.addEventListener("dragend",()=>{o.classList.remove("is-dragging");const i=this.content.querySelector(`[data-block-id="${e}"]`);i&&i.classList.remove("is-block-dragging"),this.hideDropIndicator()});const l=document.createElement("button");return l.type="button",l.className="aw-block-add",l.title="아래에 단락 추가",l.setAttribute("aria-label","아래에 단락 추가"),l.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="8" y1="3" x2="8" y2="13"/><line x1="3" y1="8" x2="13" y2="8"/></svg>',l.addEventListener("mousedown",i=>i.preventDefault()),l.addEventListener("click",i=>{i.stopPropagation(),this.insertParagraphAfter(e)}),t.appendChild(o),t.appendChild(l),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(),U(o)}handleDragOver(e){if(!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(ke))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(ke);if(!t)return;e.preventDefault();const o=this.findDropTarget(e.clientY);if(this.hideDropIndicator(),!o||o.id===t)return;const l=this.content.querySelector(`[data-block-id="${t}"]`),i=this.content.querySelector(`[data-block-id="${o.id}"]`);!l||!i||(o.before?this.content.insertBefore(l,i):this.content.insertBefore(l,i.nextSibling))}handleDragLeave(e){this.content.contains(e.relatedTarget)||this.hideDropIndicator()}findDropTarget(e){for(const o of this.state.blocks){const l=o.element.getBoundingClientRect(),i=l.top+l.height/2;if(e<i)return{id:o.id,before:!0}}const 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(),l=this.contentWrap.getBoundingClientRect(),i=(e.before?o.top:o.bottom)-l.top+this.contentWrap.scrollTop;this.dropIndicator.style.top=`${i}px`,this.dropIndicator.style.display="block"}hideDropIndicator(){this.dropIndicator.style.display="none"}syncBlockLabelPill(e){if(!e){this.blockLabelPill.style.display="none";return}const{type:t,match:o}=j(e.element),l=Ce(e.element,t,o);this.blockLabelPill.textContent=l,this.blockLabelPill.style.display="inline-flex";const i=e.element.getBoundingClientRect(),r=this.contentWrap.getBoundingClientRect(),s=Math.max(0,i.top-r.top+this.contentWrap.scrollTop-12),c=i.left-r.left+4;this.blockLabelPill.style.top=`${s}px`,this.blockLabelPill.style.left=`${c}px`}syncStatusBar(e,t){if(e){const{type:r,match:s}=j(e.element);let c=Ce(e.element,r,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,""),l=Array.from(o).length;this.statusCharsEl.textContent=`텍스트 ${l} 자`;const i=this.content.innerHTML.length;this.statusSourceEl.textContent=`소스 ${An(i)}`}syncBlockMarkers(e){for(const t of Array.from(this.content.children)){if(!(t instanceof HTMLElement))continue;const{type:o,match:l}=j(t);t.setAttribute("data-block-kind",l.kind),t.setAttribute("data-block-label",Ce(t,o,l));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(Ye)){const l=Ye[o];this.toolbar.setActive(o,(t==null?void 0:t.kind)===l)}this.toolbar.setVisible("bold",V(t,"bold")),this.toolbar.setVisible("italic",V(t,"italic")),this.toolbar.setVisible("underline",V(t,"underline")),this.toolbar.setVisible("strike",V(t,"strike")),this.toolbar.setVisible("fontFamily",Ve(t)),this.toolbar.setVisible("fontSize",Ge(t)),this.toolbar.setVisible("color",ee(t)),this.toolbar.setVisible("backgroundColor",ee(t)),this.toolbar.setVisible("align",we(t)),this.toolbar.setVisible("cellBg",te(t)),this.toolbar.setVisible("tableMenu",te(t)),this.toolbar.setVisible("codeLang",(t==null?void 0:t.kind)==="codeBlock"),this.toolbar.syncGroupVisibility()}}}function V(n,e){return n?(z[n.kind]??z.unknown).allowedMarks.includes(e):!1}function Ve(n){return n?(z[n.kind]??z.unknown).allowsInlineFormat:!1}const kn=new Set(["paragraph","bulletList","orderedList","blockquote","codeBlock","table"]);function Ge(n){return n?kn.has(n.kind):!1}const wn=new Set(["paragraph","bulletList","orderedList","table"]);function ee(n){return n?wn.has(n.kind):!1}const vn=new Set(["paragraph","heading","blockquote","table"]);function we(n){return n?vn.has(n.kind):!1}function te(n){return(n==null?void 0:n.kind)==="table"}function Cn(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 l=o.toString().length;o.setEnd(t.endContainer,t.endOffset);const i=o.toString().length;return{start:l,end:i}}function En(n,e){var u;const t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);let o=0,l=null,i=0,r=null,s=0,c=t.nextNode();for(;c;){const m=((u=c.textContent)==null?void 0:u.length)??0;if(!l&&o+m>=e.start&&(l=c,i=e.start-o),!r&&o+m>=e.end){r=c,s=e.end-o;break}o+=m,c=t.nextNode()}if(!l||!r)return;const a=document.createRange();a.setStart(l,i),a.setEnd(r,s);const d=document.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(a)}function ne(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 ve(n,e,t){const o=e.parentElement,l=t.parentElement;if(!(o instanceof HTMLTableRowElement)||!(l instanceof HTMLTableRowElement))return[e];const i=Array.from(n.querySelectorAll("tr")),r=i.indexOf(o),s=i.indexOf(l);if(r<0||s<0)return[e];const c=Math.min(r,s),a=Math.max(r,s),d=Array.from(o.children).indexOf(e),u=Array.from(l.children).indexOf(t);if(d<0||u<0)return[e];const m=Math.min(d,u),f=Math.max(d,u),p=[];for(let h=c;h<=a;h++){const b=i[h];if(b)for(let C=m;C<=f;C++){const w=b.children[C];w instanceof HTMLTableCellElement&&p.push(w)}}return p}function Ze(n,e,t){const o=n.getBoundingClientRect(),l=6;return e<o.left-l||e>o.right+l||t<o.top-l||t>o.bottom+l?null:e>=o.right-l?"right":t>=o.bottom-l?"bottom":null}function Ce(n,e,t){return n.getAttribute("data-block-explicit")==="true"||!e.isEmpty(n)?t.kind==="unknown"?n.tagName.toLowerCase():De(t):"?"}function xn(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 Ln(n){var e;try{const l=new URL(n,"http://localhost").pathname.split("/").filter(Boolean).pop();return l?decodeURIComponent(l):""}catch{return(((e=n.split("?")[0])==null?void 0:e.split("#")[0])??"").split("/").filter(Boolean).pop()??""}}function An(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:`${n}`}function Xe(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",l=>l.preventDefault()),o.addEventListener("click",t),o}function Sn(){return{blocks:[],activeBlockId:null,inline:{bold:!1,italic:!1,underline:!1,strike:!1}}}function oe(n){try{return document.queryCommandState(n)}catch{return!1}}const Tn=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 Bn(n){return Tn.has(n.toUpperCase())}class Nn{constructor(e){k(this,"root");k(this,"content");k(this,"blockIds",new pe);k(this,"idFor",e=>this.blockIds.ensure(e));k(this,"destroyed",!1);if(!(e.element instanceof HTMLElement))throw new TypeError("AerizViewer: options.element must be an HTMLElement");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){_e(this.content,e),Z(this.content,this.blockIds)}getBlocks(){return me(this.listBlocksInternal())}getBlockOf(e){return this.content.contains(e)?Q(e,this.content,this.idFor):null}getHTML(){const e=this.content.cloneNode(!0),t=fe(this.root),o=this.root.dataset.theme;return(o==="light"||o==="dark")&&(t.mode=o),ge(e,t),ye(e),e.innerHTML}setTheme(e){this.root.dataset.theme=e}destroy(){this.destroyed||(this.destroyed=!0,this.root.remove())}listBlocksInternal(){return X(this.content,this.idFor)}}return E.ALL_INLINE_MARKS=Y,E.AerizEditor=yn,E.AerizViewer=Nn,E.BLOCK_ID_ATTR=_,E.BLOCK_TYPES=ue,E.BLOCK_TYPE_BY_KIND=z,E.BlockIdRegistry=pe,E.DEFAULT_TOOLBAR=N,E.applyBlockInlineStyles=ge,E.assignMissingIds=Z,E.classifyBlockElement=j,E.extractInlineContent=Oe,E.fillInlineContent=qe,E.findBlockFrom=Q,E.getBlockLabel=De,E.isElementBlank=O,E.listBlocks=X,E.normalizeContent=he,E.placeCaretAtStart=U,E.readBlockStyleTheme=fe,E.renderBlock=Fe,E.renderBlocks=_e,E.serializeBlock=He,E.serializeBlocks=me,E.stripEditorOnlyAttrs=ye,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"}),E}({});typeof globalThis.AerizWysiwyg=="object"&&(globalThis.AerizEditor=globalThis.AerizWysiwyg.AerizEditor,globalThis.AerizViewer=globalThis.AerizWysiwyg.AerizViewer);
|
|
23
|
+
`):e.push(l?o:o+" ")}return e.join("")}function q(n){const e=[];let t=n.replace(/(`+)([\s\S]+?)\1/g,(o,l,i)=>`\0CODE${e.push(`<code>${G(i)}</code>`)-1}\0`);return t=G(t),t=t.replace(/<(https?:\/\/[^\s&]+)>/g,(o,l)=>`<a href="${K(l)}" target="_blank" rel="noopener">${G(l)}</a>`),t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,l,i)=>`<img src="${K(i)}" alt="${K(l)}">`),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g,(o,l,i)=>`<a href="${K(i)}" target="_blank" rel="noopener">${l}</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(/CODE(\d+)/g,(o,l)=>{const i=Number(l);return e[i]??""}),t}function G(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function K(n){return n.replace(/&/g,"&").replace(/"/g,""")}const Y=["bold","italic","underline","strike"],Qt={kind:"paragraph",label:"단락",allowsInlineFormat:!0,allowedMarks:Y,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="P"?{kind:"paragraph",attrs:{}}:null,create:()=>J(document.createElement("p")),isEmpty:n=>O(n)},Jt={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=Cn(n==null?void 0:n.level);return J(document.createElement(`h${e}`))},isEmpty:n=>O(n)},en={kind:"bulletList",label:"글머리 목록",allowsInlineFormat:!0,allowedMarks:Y,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="UL"?{kind:"bulletList",attrs:{}}:null,create:()=>Ke("ul"),isEmpty:n=>Ye(n)},tn={kind:"orderedList",label:"번호 매기기 목록",allowsInlineFormat:!0,allowedMarks:Y,allowsColor:!0,allowsFontSize:!0,matches:n=>n.tagName==="OL"?{kind:"orderedList",attrs:{}}:null,create:()=>Ke("ol"),isEmpty:n=>Ye(n)},nn={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(J(document.createElement("p"))),n},isEmpty:n=>O(n)},on={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=>O(n)},ln={kind:"image",label:"이미지",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{if(n.tagName==="FIGURE"){const e=n.querySelector(":scope > img"),t=Ve(e),o=n.getAttribute("style");return o&&(t.wrapperStyle=o),{kind:"image",attrs:t}}return n.tagName==="IMG"?{kind:"image",attrs:Ve(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(de()),e.appendChild(ce()),e},isEmpty:n=>{const e=n.tagName==="IMG"?n:n.querySelector(":scope > img");return!e||!e.getAttribute("src")}};function ce(){const n=document.createElement("span");return n.className="aw-resize-handle",n.setAttribute("contenteditable","false"),n.setAttribute("aria-hidden","true"),n}function de(){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=rn[e],n.appendChild(t)}return n}const rn={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>'},sn={kind:"table",label:"표",allowsInlineFormat:!0,allowedMarks:Y,allowsColor:!0,allowsFontSize:!0,matches:n=>{var l;if(n.tagName!=="TABLE")return null;const e=n.querySelectorAll(":scope > tbody > tr, :scope > tr"),t=e.length,o=((l=e[0])==null?void 0:l.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"),l=document.createElement("tbody");for(let i=0;i<e;i++){const r=document.createElement("tr");for(let s=0;s<t;s++){const a=document.createElement("td");a.appendChild(document.createElement("br")),r.appendChild(a)}l.appendChild(r)}return o.appendChild(l),o},isEmpty:n=>n.querySelectorAll(":scope tr").length===0},an={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},cn={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=`https://www.youtube-nocookie.com/embed/${e}`),o.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),o.setAttribute("allowfullscreen",""),o.setAttribute("frameborder","0"),o.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),t.appendChild(o),t.appendChild(de()),t.appendChild(ce()),t},isEmpty:n=>!n.getAttribute("data-youtube-id")},dn={kind:"linkCard",label:"링크",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:n=>{var s,a,c,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)??((a=n.querySelector(":scope > .aw-link-card-text"))==null?void 0:a.textContent)??void 0,o=((c=n.querySelector(":scope > .aw-link-card-body > .aw-link-card-desc"))==null?void 0:c.textContent)??void 0,l=((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,r={};return e&&(r.href=e),t&&(r.text=t),o&&(r.description=o),l&&(r.image=l),i&&(r.favicon=i),{kind:"linkCard",attrs:r}},create:n=>{const e=(n==null?void 0:n.href)??"#",t=n!=null&&n.text&&n.text.length>0?n.text:Ie(e)||e,o=(n==null?void 0:n.description)??"",l=(n==null?void 0:n.image)??"",i=(n==null?void 0:n.favicon)??un(e),r=document.createElement("a");if(r.className="aw-link-card",l&&r.classList.add("aw-link-card-with-image"),r.href=e,r.target="_blank",r.rel="noopener",r.setAttribute("contenteditable","false"),l){const u=document.createElement("img");u.className="aw-link-card-image",u.src=l,u.alt="",u.loading="lazy",r.appendChild(u)}const s=document.createElement("span");s.className="aw-link-card-body";const a=document.createElement("span");if(a.className="aw-link-card-title",a.textContent=t,s.appendChild(a),o){const u=document.createElement("span");u.className="aw-link-card-desc",u.textContent=o,s.appendChild(u)}const c=document.createElement("span");if(c.className="aw-link-card-url",i){const u=document.createElement("img");u.className="aw-link-card-favicon",u.src=i,u.alt="",u.loading="lazy",c.appendChild(u)}const d=document.createElement("span");return d.className="aw-link-card-url-text",d.textContent=e,c.appendChild(d),s.appendChild(c),r.appendChild(s),r},isEmpty:n=>!n.getAttribute("href")};function Ie(n){try{return new URL(n).hostname}catch{return""}}function un(n){const e=Ie(n);return e?`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`:""}const pn={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"),l=o?Number(o):void 0,i=n.getAttribute("data-file-type")??void 0,r={};return e&&(r.fileSrc=e),t&&(r.fileName=t),l!==void 0&&!Number.isNaN(l)&&(r.fileSize=l),i&&(r.fileType=i),{kind:"file",attrs:r}},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='<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>';const o=document.createElement("span");o.className="aw-file-meta";const l=document.createElement("span");l.className="aw-file-name",l.textContent=(n==null?void 0:n.fileName)??"파일",o.appendChild(l);const i=[],r=mn(n==null?void 0:n.fileName,n==null?void 0:n.fileType);if(r&&i.push(r),(n==null?void 0:n.fileSize)!==void 0&&i.push(hn(n.fileSize)),i.length>0){const a=document.createElement("span");a.className="aw-file-info",a.textContent=i.join(" · "),o.appendChild(a)}const s=document.createElement("span");return s.className="aw-file-action",s.setAttribute("aria-hidden","true"),s.innerHTML='<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>',e.appendChild(t),e.appendChild(o),e.appendChild(s),e},isEmpty:n=>!n.getAttribute("href")};function hn(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(1)} KB`:n<1073741824?`${(n/1024/1024).toFixed(1)} MB`:`${(n/1024/1024/1024).toFixed(1)} GB`}function mn(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():""}const fn={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},Re={kind:"unknown",label:"알 수 없음",allowsInlineFormat:!1,allowedMarks:[],allowsColor:!1,allowsFontSize:!1,matches:()=>null,create:()=>J(document.createElement("p")),isEmpty:n=>O(n)},ue=[Qt,Jt,en,tn,nn,on,ln,sn,an,dn,cn,pn,fn],N=(()=>{const n={unknown:Re};for(const e of ue)n[e.kind]=e;return n})();function j(n){for(const e of ue){const t=e.matches(n);if(t)return{type:e,match:t}}return{type:Re,match:{kind:"unknown",attrs:{}}}}const P="data-block-id";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(P);if(t)return this.seen.add(t),t;const o=this.generate();return e.setAttribute(P,o),o}get(e){return e.getAttribute(P)}}function Z(n,e){const t=new Set;for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const l=o.getAttribute(P);if(l&&!t.has(l)){t.add(l),e.observe(l);continue}const i=e.generate();o.setAttribute(P,i),t.add(i)}}function he(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(de()),e.querySelector(":scope > .aw-resize-handle")||e.appendChild(ce()))}function De(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 He(n){return{id:n.id,kind:n.kind,attrs:{...n.attrs},html:n.element.innerHTML}}function me(n){return n.map(He)}function Fe(n){const t=(N[n.kind]??N.unknown).create(n.attrs);return t.setAttribute(P,n.id),n.html.length>0&&(t.innerHTML=n.html),t}function Pe(n,e){for(;n.firstChild;)n.removeChild(n.firstChild);for(const t of e)n.appendChild(Fe(t))}function X(n,e){const t=[];for(const o of Array.from(n.children)){if(!(o instanceof HTMLElement))continue;const{match:l}=j(o);t.push({id:e(o),kind:l.kind,attrs:l.attrs,element:o})}return t}function Q(n,e,t){let o=n;for(;o&&o!==e;){if(o.parentNode===e&&o.nodeType===Node.ELEMENT_NODE){const l=o,{match:i}=j(l);return{id:t(l),kind:i.kind,attrs:i.attrs,element:l}}o=o.parentNode}return null}function Oe(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 _e(t)}case"blockquote":{const t=Array.from(e.querySelectorAll(":scope > p"));return t.length>0?_e(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 _e(n){const e=[];return n.forEach((t,o)=>{o>0&&e.push(document.createElement("br"));for(const l of Array.from(t.childNodes))e.push(l)}),e}function qe(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 l=N[e];l&&gn(o,l)}function gn(n,e){const t=new Set(e.allowedMarks);for(const o of Array.from(n.querySelectorAll("*"))){if(!(o instanceof HTMLElement)||!o.parentNode)continue;const l=o.tagName.toLowerCase();if((l==="b"||l==="strong")&&!t.has("bold")||(l==="i"||l==="em")&&!t.has("italic")||l==="u"&&!t.has("underline")||(l==="s"||l==="strike"||l==="del")&&!t.has("strike")){je(o);continue}if(l==="span"||l==="font"){const i=o.style;if(!t.has("bold")){const c=i.fontWeight;(c==="bold"||c==="bolder"||/^[7-9]\d{2}$|^1000$/.test(c))&&i.removeProperty("font-weight")}!t.has("italic")&&i.fontStyle==="italic"&&i.removeProperty("font-style");const r=i.textDecorationLine||i.textDecoration||"";if(r){const c=r.split(/\s+/),d=c.filter(u=>!(u==="underline"&&!t.has("underline")||u==="line-through"&&!t.has("strike")));d.length!==c.length&&(i.removeProperty("text-decoration"),i.removeProperty("text-decoration-line"),d.length>0&&(i.textDecoration=d.join(" ")))}e.allowsColor||(i.removeProperty("color"),i.removeProperty("background-color"),l==="font"&&o.removeAttribute("color")),e.allowsFontSize||(i.removeProperty("font-size"),l==="font"&&o.removeAttribute("size")),e.allowsInlineFormat||(i.removeProperty("font-family"),l==="font"&&o.removeAttribute("face"));const s=i.cssText.trim().length>0,a=Array.from(o.attributes).some(c=>c.name!=="style");!s&&!a&&je(o)}}}function je(n){const e=n.parentNode;if(e){for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n)}}function bn(n={}){const e=n.fg||"currentColor",t=n.bg||"transparent",o=n.mode==="dark"?!0:n.mode==="light"?!1:yn(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 yn(n,e){const t=Ue(n);if(t!==null)return t>.5;const o=Ue(e);return o!==null?o<.5:!0}function Ue(n){if(!n)return null;const e=n.trim();let t=-1,o=-1,l=-1;const i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e);if(i&&i[1]){const r=i[1];r.length===3?(t=parseInt(r[0]+r[0],16),o=parseInt(r[1]+r[1],16),l=parseInt(r[2]+r[2],16)):(t=parseInt(r.slice(0,2),16),o=parseInt(r.slice(2,4),16),l=parseInt(r.slice(4,6),16))}else{const r=/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/.exec(e);r&&(t=Number(r[1]),o=Number(r[2]),l=Number(r[3]))}return t<0?null:(.299*t+.587*o+.114*l)/255}function fe(n){const e=getComputedStyle(n),t=c=>{const d=e.getPropertyValue(c).trim();return d.length>0?d:void 0},o={},l=t("--aw-primary"),i=t("--aw-fg"),r=t("--aw-bg"),s=t("--aw-border"),a=t("--aw-fg-muted");return l&&(o.primary=l),i&&(o.fg=i),r&&(o.bg=r),s&&(o.border=s),a&&(o.fgMuted=a),o}function wn(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 kn(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 ge(n,e={}){const t=bn(e),o=wn(t),l=kn(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")){be(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 r=o[i.tagName];r&&be(i,r)}for(const[i,r]of Object.entries(l))for(const s of Array.from(n.querySelectorAll(i)))s instanceof HTMLElement&&(s.closest("[data-imported-html]")||be(s,r))}function be(n,e){const t=(n.getAttribute("style")??"").trim();if(!t){const s=e.replace(/;\s*$/,"").trim();s&&n.setAttribute("style",s);return}const o=We(t),l=new Set(o.map(s=>s.prop)),r=[...We(e).filter(s=>!l.has(s.prop)),...o].map(s=>`${s.prop}:${s.value}`).join(";");r?n.setAttribute("style",r):n.removeAttribute("style")}function We(n){const e=[];for(const t of n.split(";")){const o=t.trim();if(!o)continue;const l=o.indexOf(":");if(l<=0)continue;const i=o.slice(0,l).trim().toLowerCase(),r=o.slice(l+1).trim();!i||!r||e.push({prop:i,value:r})}return e}function ye(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 U(n){const e=document.getSelection();if(!e)return;const t=document.createRange();if(n.tagName==="HR")t.setStartAfter(n);else{const o=vn(n);t.selectNodeContents(o),t.collapse(!0)}e.removeAllRanges(),e.addRange(t)}function vn(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 J(n){return n.appendChild(document.createElement("br")),n}function Ke(n){const e=document.createElement(n),t=document.createElement("li");return t.appendChild(document.createElement("br")),e.appendChild(t),e}function Ye(n){const e=n.querySelectorAll(":scope > li");return e.length===0?!0:e.length===1?O(e[0]):!1}function O(n){return(n.textContent??"").replace(//g,"").trim().length===0}function Cn(n){return n===void 0||n<1?1:n>6?6:n}function Ve(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 Ge={bulletList:"bulletList",orderedList:"orderedList",blockquote:"blockquote",codeBlock:"codeBlock"},we="application/x-aeriz-block";class xn{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",Nn());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 r=e.toolbar??M;this.toolbar=new tt(r,{onAction:(s,a)=>this.handleToolbarAction(s,a)}),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>",he(this.content),Z(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",r=>r.preventDefault()),this.blockLabelPill.addEventListener("click",r=>{r.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=Je("되돌리기 (Ctrl+Z)",E.undo,()=>{this.content.focus(),document.execCommand("undo")}),l=Je("다시 실행 (Ctrl+Y)",E.redo,()=>{this.content.focus(),document.execCommand("redo")});this.statusBlockEl=document.createElement("span"),this.statusBlockEl.className="aw-status-item",t.appendChild(o),t.appendChild(l),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",r=>this.handleKeyDown(r)),document.addEventListener("selectionchange",this.handleSelectionChange),this.content.addEventListener("mousemove",r=>this.handleTableCursor(r)),this.content.addEventListener("mousedown",r=>this.handleTableResizeStart(r)),this.content.addEventListener("click",r=>this.handleBlockAlignClick(r)),this.content.addEventListener("mousedown",r=>this.handleCellSelStart(r)),this.content.addEventListener("mousemove",r=>this.handleCellSelMove(r)),document.addEventListener("mouseup",()=>this.handleCellSelEnd()),this.content.addEventListener("input",()=>this.scheduleCodeHighlight()),this.content.addEventListener("dragstart",r=>{const s=r.target;s&&(s.closest(".aw-block-handle")||s.closest("table")&&r.preventDefault())}),this.content.addEventListener("dragover",r=>this.handleDragOver(r)),this.content.addEventListener("drop",r=>this.handleDrop(r)),this.content.addEventListener("dragleave",r=>this.handleDragLeave(r)),window.addEventListener("resize",this.handleResize),this.sync()}getHTML(){const e=this.content.cloneNode(!0),t=fe(this.root),o=this.currentTheme();return o&&(t.mode=o),ge(e,t),ye(e),e.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 X(this.content,this.idFor)}serialize(){return me(this.getBlocks())}findBlockById(e){const t=this.content.querySelector(`[data-block-id="${e}"]`);return t?Q(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)?Q(t,this.content,this.idFor):null}setBlockType(e,t,o){const l=N[e];if(!l)return;const i=o?this.findBlockById(o):this.getActiveBlock(),r=i?this.replaceBlock(i,l,t):this.appendBlock(l,t);this.flush(),this.content.focus(),U(r)}replaceBlock(e,t,o){const l=Oe(e),i=t.create(o);return qe(i,t.kind,l),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;he(this.content),Z(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(!Ze(this.getActiveBlock()))return;const o=this.detectActiveFontId();Dt(t,l=>this.applyFontFamily(l.stack),o??void 0);break}case"fontSize":{if(!Xe(this.getActiveBlock()))return;const o=this.detectActiveFontSize();Ot(t,l=>this.applyFontSize(l.px),o??void 0);break}case"color":{if(!ee(this.getActiveBlock()))return;se(t,o=>this.handleColorPick(o,"foreColor"),this.recentCustomColors);break}case"backgroundColor":{if(!ee(this.getActiveBlock()))return;se(t,o=>this.handleColorPick(o,"hiliteColor"),this.recentCustomColors);break}case"align":{if(!ke(this.getActiveBlock()))return;Rt(t,o=>this.applyAlign(o));break}case"cellBg":{if(!te(this.getActiveBlock()))return;const o=this.getSelectedTableCells();if(o.length===0)return;se(t,l=>this.applyCellBgToCells(o,l),this.recentCustomColors);break}case"tableMenu":{if(!te(this.getActiveBlock()))return;Pt(t,o=>this.runTableMenu(o));break}case"codeLang":{const o=this.getActiveBlock();if(!o||o.kind!=="codeBlock")return;const l=o.element.querySelector(":scope > code"),i=(l==null?void 0:l.getAttribute("data-language"))??void 0;Ht(t,r=>this.applyCodeLanguage(o.element,r.id),i);break}case"bold":case"italic":case"underline":case"strike":this.applyMark(e);break}}applyMark(e){const t=this.getActiveBlock();if(!V(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&&!re.includes(e)&&(this.recentCustomColors=[e,...this.recentCustomColors.filter(o=>o!==e)].slice(0,8)),this.applyColor(t,e),this.queueSync()}applyColor(e,t){this.content.focus(),document.execCommand("styleWithCSS",!1,"true"),document.execCommand(e,!1,t??"inherit")}applyAlign(e){const t=this.getActiveBlock();if(!t||!ke(t))return;const o=Array.from(this.content.querySelectorAll("td.aw-cell-selected, th.aw-cell-selected"));if(o.length>0){for(const i of o)i.style.textAlign=e;this.clearCellSelection(),this.queueSync();return}let l=t.element;if(t.kind==="blockquote"){const i=t.element.querySelector(":scope > p");i instanceof HTMLElement&&(l=i)}else if(t.kind==="table"){const i=this.getActiveTableCell();i&&(l=i)}l.style.textAlign=e,this.queueSync()}getActiveTableCell(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let 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,l=document.getSelection();if(!l||l.rangeCount===0)return[];const i=l.getRangeAt(0),r=ne(i.startContainer);if(!r||!o.contains(r))return[];if(i.collapsed)return[r];const s=ne(i.endContainer);return!s||!o.contains(s)||s===r?[r]:ve(o,r,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 l=o.closest("table");if(!(l instanceof HTMLTableElement))return;const i=ve(l,this.cellSelStart,o);if(!(i.length<=1)){this.cellSelDrag=!0,this.clearCellSelection();for(const r of i)r.classList.add("aw-cell-selected")}}handleCellSelEnd(){this.cellSelStart=null,this.cellSelDrag=!1}clearCellSelection(){const e=this.content.querySelectorAll(".aw-cell-selected");for(const t of Array.from(e))t.classList.remove("aw-cell-selected")}applyFontSizeToCells(e,t){let o=0;for(const l of e)l.isConnected&&(l.style.fontSize=`${t}px`,o++);o!==0&&(this.clearCellSelection(),this.flush())}applyCellBgToCells(e,t){let o=0;for(const l of e)l.isConnected&&(t?l.style.setProperty("background-color",t,"important"):l.style.removeProperty("background-color"),o++);o!==0&&(t&&!re.includes(t)&&(this.recentCustomColors=[t,...this.recentCustomColors.filter(l=>l!==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 l=o.children.length,i=document.createElement("tr");for(let r=0;r<l;r++){const s=document.createElement("td");s.appendChild(document.createElement("br")),i.appendChild(s)}e==="above"?o.parentNode.insertBefore(i,o):o.parentNode.insertBefore(i,o.nextSibling),this.flush()}insertColumn(e){const t=this.getActiveTableCell();if(!t)return;const o=t.closest("tr");if(!o)return;const l=Array.from(o.children).indexOf(t);if(l<0)return;const i=o.closest("table");if(i){for(const r of Array.from(i.querySelectorAll("tr"))){const s=r.children[l];if(!s)continue;const a=s.tagName.toLowerCase(),c=document.createElement(a);c.appendChild(document.createElement("br")),e==="left"?r.insertBefore(c,s):r.insertBefore(c,s.nextSibling)}this.flush()}}deleteRow(){const e=this.getActiveTableCell();if(!e)return;const 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??"",l=Ln(e);e.innerHTML=Lt(o,t),l&&An(e,l)}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 r;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 l=t.closest("table");if(!l)return;const i=l.querySelector("tr");if(!(i&&i.children.length<=1)){for(const s of Array.from(l.querySelectorAll("tr")))(r=s.children[o])==null||r.remove();this.flush()}}handleTableCursor(e){var l,i;if(this.tableResize)return;const t=(i=(l=e.target)==null?void 0:l.closest)==null?void 0:i.call(l,"td, th");if(!(t instanceof HTMLTableCellElement)){this.content.style.cursor="";return}const o=Qe(t,e.clientX,e.clientY);this.content.style.cursor=o==="right"?"col-resize":o==="bottom"?"row-resize":""}handleTableResizeStart(e){var a;if(e.button!==0)return;const t=e.target,o=t==null?void 0:t.closest(".aw-resize-handle");if(o instanceof HTMLElement){const c=o.parentElement;if(c instanceof HTMLElement&&(c.tagName==="FIGURE"||c.tagName==="DIV"&&c.classList.contains("aw-youtube-embed"))){e.preventDefault(),e.stopPropagation(),this.startBlockResize(c,e.clientX);return}}const l=(a=t==null?void 0:t.closest)==null?void 0:a.call(t,"td, th");if(!(l instanceof HTMLTableCellElement))return;const i=Qe(l,e.clientX,e.clientY);if(!i)return;if(e.preventDefault(),e.stopPropagation(),i==="right"){const c=l.closest("tr"),d=c?Array.from(c.children).indexOf(l):-1,u=l.closest("table");if(!u||d<0)return;const m=[];for(const h of Array.from(u.querySelectorAll("tr"))){const f=h.children[d];f instanceof HTMLTableCellElement&&m.push(f)}this.tableResize={kind:"col",startX:e.clientX,startY:e.clientY,initialSize:l.getBoundingClientRect().width,targetCells:m,targetRow:null},document.body.style.cursor="col-resize"}else{const c=l.closest("tr");if(!(c instanceof HTMLTableRowElement))return;this.tableResize={kind:"row",startX:e.clientX,startY:e.clientY,initialSize:c.getBoundingClientRect().height,targetCells:[],targetRow:c},document.body.style.cursor="row-resize"}const r=c=>this.handleTableResizeMove(c),s=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s),document.body.style.cursor="",this.tableResize=null,this.flush()};document.addEventListener("mousemove",r),document.addEventListener("mouseup",s)}handleTableResizeMove(e){const t=this.tableResize;if(t){if(t.kind==="col"){const o=e.clientX-t.startX,l=Math.max(40,t.initialSize+o),i=`${Math.round(l)}px`;for(const r of t.targetCells)r.style.width=i}else if(t.targetRow){const o=e.clientY-t.startY,l=Math.max(20,t.initialSize+o);t.targetRow.style.height=`${Math.round(l)}px`}}}handleBlockAlignClick(e){var i,r;const t=(r=(i=e.target)==null?void 0:i.closest)==null?void 0:r.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 l=t.closest("figure, div.aw-youtube-embed");l instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),o==="center"?(l.style.marginLeft="auto",l.style.marginRight="auto"):o==="right"?(l.style.marginLeft="auto",l.style.marginRight="0"):(l.style.marginLeft="0",l.style.marginRight="auto"),this.flush())}startBlockResize(e,t){const o=e.getBoundingClientRect().width;document.body.style.cursor="nwse-resize",e.classList.add("aw-resizing");const l=r=>{const s=r.clientX-t,a=Math.max(80,o+s);e.style.width=`${Math.round(a)}px`},i=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",i),document.body.style.cursor="",e.classList.remove("aw-resizing"),this.flush()};document.addEventListener("mousemove",l),document.addEventListener("mouseup",i)}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 ut(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),a=ne(s.startContainer),c=ne(s.endContainer);if(a&&c&&a!==c&&this.content.contains(a)&&this.content.contains(c)){const d=a.closest("table");if(d instanceof HTMLTableElement){this.applyFontSizeToCells(ve(d,a,c),e);return}}}this.content.focus();const l=document.getSelection();if(!l||l.rangeCount===0)return;const i=l.getRangeAt(0);if(!this.content.contains(i.commonAncestorContainer))return;const r=document.createElement("span");if(r.style.fontSize=`${e}px`,i.collapsed){r.appendChild(document.createTextNode("")),i.insertNode(r);const s=document.createRange();s.selectNodeContents(r),s.collapse(!1),l.removeAllRanges(),l.addRange(s)}else{try{i.surroundContents(r)}catch{const a=i.extractContents();r.appendChild(a),i.insertNode(r)}l.removeAllRanges();const s=document.createRange();s.selectNodeContents(r),l.addRange(s)}this.queueSync()}detectActiveFontSize(){const e=document.getSelection();if(!e||e.rangeCount===0)return null;let 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 ct(o)}openBlockTypeMenu(e,t){It(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"){_t(e,l=>{this.setBlockType("table",{rows:l.rows,cols:l.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){nt({},this.currentTheme()).then(t=>{var r;if(!t.confirmed||!t.href)return;const o=t.href,l=((r=t.text)==null?void 0:r.trim())??"",i=l.length>0?l:o;this.setBlockType("linkCard",{href:o,text:i},e)})}openImageDialogAndApply(e){const t=this.resolveImageUploadFn();ot({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{o.confirmed&&o.src&&this.setBlockType("image",{src:o.src},e),this.queueSync()})}openYouTubeDialogAndApply(e){st(this.currentTheme()).then(t=>{if(!t.confirmed||!t.url)return;const o=Sn(t.url);o&&this.setBlockType("youtube",{videoId:o},e)})}openImportHtmlDialogAndApply(e){lt(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 Ut(t.html,{mountTarget:this.content})}catch(s){console.error("HTML 가져오기 실패:",s);const a=s instanceof Error?s.message:String(s);window.alert(`HTML 가져오기 실패: ${a}`);return}if(o.length===0){window.alert("HTML 에서 가져올 본문이 없습니다.");return}const l=e?this.content.querySelector(`[data-block-id="${e}"]`):null,i=[];for(const s of o){const a=$n(s.tagName)?s:(()=>{const c=document.createElement("p");return c.appendChild(s),c})();a.setAttribute("data-block-explicit","true"),i.push(a)}if(l)if(l.tagName==="P"&&(l.textContent??"").trim().length===0&&i.length>0){const a=i[0];l.replaceWith(a);let c=a;for(let d=1;d<i.length;d++){const u=i[d];c.after(u),c=u}}else{let a=l;for(const c of i)a.after(c),a=c}else for(const s of i)this.content.appendChild(s);this.flush(),this.content.focus();const r=i[i.length-1];r&&U(r)})}openMarkdownImportDialogAndApply(e){it(this.currentTheme()).then(t=>{if(!t.confirmed)return;if(!t.markdown||t.markdown.length===0){window.alert("가져올 Markdown 이 비어 있습니다.");return}let o;try{o=Yt(t.markdown)}catch(r){console.error("Markdown 파싱 실패:",r);const s=r instanceof Error?r.message:String(r);window.alert(`Markdown 가져오기 실패: ${s}`);return}if(o.length===0){window.alert("Markdown 에서 가져올 본문이 없습니다.");return}for(const r of o)r.setAttribute("data-block-explicit","true");const l=e?this.content.querySelector(`[data-block-id="${e}"]`):null;if(l)if(l.tagName==="P"&&(l.textContent??"").trim().length===0&&o.length>0){const s=o[0];l.replaceWith(s);let a=s;for(let c=1;c<o.length;c++){const d=o[c];a.after(d),a=d}}else{let s=l;for(const a of o)s.after(a),s=a}else for(const r of o)this.content.appendChild(r);this.flush(),this.content.focus();const i=o[o.length-1];i&&U(i)})}openFileAttachmentDialogAndApply(e){const t=this.resolveFileUploadFn();rt({...t?{onUpload:t}:{}},this.currentTheme()).then(o=>{if(!o.confirmed)return;if(!o.src||o.src.length===0){window.alert("파일 URL 이 비어 있습니다.");return}const l={fileSrc:o.src},i=o.name&&o.name.length>0?o.name:Tn(o.src);i&&(l.fileName=i),o.size!==void 0&&(l.fileSize=o.size),o.type&&(l.fileType=o.type),this.setBlockType("file",l,e)})}resolveFileUploadFn(){if(this.options.onFileUpload)return this.options.onFileUpload;const e=this.options.fileUploadUrl;if(e)return async t=>{const o=new FormData;o.append("file",t);const l=await fetch(e,{method:"POST",body:o});if(!l.ok)throw new Error(`파일 업로드 실패: ${l.status}`);const i=await l.json(),r=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof r!="string"||r.length===0)throw new Error("파일 업로드 응답에 url 필드가 없습니다.");return r}}resolveImageUploadFn(){if(this.options.onImageUpload)return this.options.onImageUpload;const e=this.options.imageUploadUrl;if(e)return async t=>{const o=new FormData;o.append("file",t);const l=await fetch(e,{method:"POST",body:o});if(!l.ok)throw new Error(`이미지 업로드 실패: ${l.status}`);const i=await l.json(),r=typeof i=="object"&&i&&"url"in i?i.url:void 0;if(typeof r!="string"||r.length===0)throw new Error("이미지 업로드 응답에 url 필드가 없습니다.");return r}}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=X(this.content,this.idFor),t=this.getActiveBlock(),l=t!==null?{bold:oe("bold"),italic:oe("italic"),underline:oe("underline"),strike:oe("strikeThrough")}:{bold:!1,italic:!1,underline:!1,strike:!1};this.state={blocks:e,activeBlockId:(t==null?void 0:t.id)??null,inline:l},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 l=e.key.toLowerCase();let i=null;if(!e.shiftKey&&l==="b"?i="bold":!e.shiftKey&&l==="i"?i="italic":!e.shiftKey&&l==="u"?i="underline":e.shiftKey&&l==="x"&&(i="strike"),i){e.preventDefault(),this.applyMark(i);return}}if(e.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),U(o),this.flush()}syncBlockHandles(e){const t=new Set;for(const o of e){t.add(o.id);let l=this.handles.get(o.id);l||(l=this.createBlockHandle(o.id),this.handlesLayer.appendChild(l),this.handles.set(o.id,l)),this.positionHandle(l,o.element)}for(const[o,l]of this.handles)t.has(o)||(l.remove(),this.handles.delete(o))}repositionHandles(){if(this.destroyed)return;for(const o of this.state.blocks){const l=this.handles.get(o.id);l&&this.positionHandle(l,o.element)}const e=this.state.activeBlockId,t=e?this.state.blocks.find(o=>o.id===e):null;this.syncBlockLabelPill(t??null)}positionHandle(e,t){const o=t.getBoundingClientRect(),l=this.contentWrap.getBoundingClientRect(),i=22,r=o.height<i?(o.height-i)/2:0,s=o.top-l.top+this.contentWrap.scrollTop+r;e.style.top=`${s}px`}createBlockHandle(e){const 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(we,e),i.dataTransfer.setData("text/plain",e),i.dataTransfer.effectAllowed="move",o.classList.add("is-dragging");const r=this.content.querySelector(`[data-block-id="${e}"]`);if(r){r.classList.add("is-block-dragging");try{i.dataTransfer.setDragImage(r,12,12)}catch{}}}),o.addEventListener("dragend",()=>{o.classList.remove("is-dragging");const i=this.content.querySelector(`[data-block-id="${e}"]`);i&&i.classList.remove("is-block-dragging"),this.hideDropIndicator()});const l=document.createElement("button");return l.type="button",l.className="aw-block-add",l.title="아래에 단락 추가",l.setAttribute("aria-label","아래에 단락 추가"),l.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="8" y1="3" x2="8" y2="13"/><line x1="3" y1="8" x2="13" y2="8"/></svg>',l.addEventListener("mousedown",i=>i.preventDefault()),l.addEventListener("click",i=>{i.stopPropagation(),this.insertParagraphAfter(e)}),t.appendChild(o),t.appendChild(l),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(),U(o)}handleDragOver(e){if(!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(we))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(we);if(!t)return;e.preventDefault();const o=this.findDropTarget(e.clientY);if(this.hideDropIndicator(),!o||o.id===t)return;const l=this.content.querySelector(`[data-block-id="${t}"]`),i=this.content.querySelector(`[data-block-id="${o.id}"]`);!l||!i||(o.before?this.content.insertBefore(l,i):this.content.insertBefore(l,i.nextSibling))}handleDragLeave(e){this.content.contains(e.relatedTarget)||this.hideDropIndicator()}findDropTarget(e){for(const o of this.state.blocks){const l=o.element.getBoundingClientRect(),i=l.top+l.height/2;if(e<i)return{id:o.id,before:!0}}const 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(),l=this.contentWrap.getBoundingClientRect(),i=(e.before?o.top:o.bottom)-l.top+this.contentWrap.scrollTop;this.dropIndicator.style.top=`${i}px`,this.dropIndicator.style.display="block"}hideDropIndicator(){this.dropIndicator.style.display="none"}syncBlockLabelPill(e){if(!e){this.blockLabelPill.style.display="none";return}const{type:t,match:o}=j(e.element),l=Ce(e.element,t,o);this.blockLabelPill.textContent=l,this.blockLabelPill.style.display="inline-flex";const i=e.element.getBoundingClientRect(),r=this.contentWrap.getBoundingClientRect(),s=Math.max(0,i.top-r.top+this.contentWrap.scrollTop-12),a=i.left-r.left+4;this.blockLabelPill.style.top=`${s}px`,this.blockLabelPill.style.left=`${a}px`}syncStatusBar(e,t){if(e){const{type:r,match:s}=j(e.element);let a=Ce(e.element,r,s);if(e.kind==="codeBlock"){const c=e.element.querySelector(":scope > code"),d=c==null?void 0:c.getAttribute("data-language");d&&(a+=` · ${d}`)}this.statusBlockEl.textContent=a}else this.statusBlockEl.textContent="— 선택된 블록 없음";this.statusBlocksEl.textContent=`${t.length} 블록`;const o=(this.content.textContent??"").replace(/\s+/g,""),l=Array.from(o).length;this.statusCharsEl.textContent=`텍스트 ${l} 자`;const i=this.content.innerHTML.length;this.statusSourceEl.textContent=`소스 ${Bn(i)}`}syncBlockMarkers(e){for(const t of Array.from(this.content.children)){if(!(t instanceof HTMLElement))continue;const{type:o,match:l}=j(t);t.setAttribute("data-block-kind",l.kind),t.setAttribute("data-block-label",Ce(t,o,l));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(Ge)){const l=Ge[o];this.toolbar.setActive(o,(t==null?void 0:t.kind)===l)}this.toolbar.setVisible("bold",V(t,"bold")),this.toolbar.setVisible("italic",V(t,"italic")),this.toolbar.setVisible("underline",V(t,"underline")),this.toolbar.setVisible("strike",V(t,"strike")),this.toolbar.setVisible("fontFamily",Ze(t)),this.toolbar.setVisible("fontSize",Xe(t)),this.toolbar.setVisible("color",ee(t)),this.toolbar.setVisible("backgroundColor",ee(t)),this.toolbar.setVisible("align",ke(t)),this.toolbar.setVisible("cellBg",te(t)),this.toolbar.setVisible("tableMenu",te(t)),this.toolbar.setVisible("codeLang",(t==null?void 0:t.kind)==="codeBlock"),this.toolbar.syncGroupVisibility()}}}function V(n,e){return n?(N[n.kind]??N.unknown).allowedMarks.includes(e):!1}function Ze(n){return n?(N[n.kind]??N.unknown).allowsInlineFormat:!1}function Xe(n){return n?(N[n.kind]??N.unknown).allowsFontSize:!1}function ee(n){return n?(N[n.kind]??N.unknown).allowsColor:!1}const En=new Set(["paragraph","heading","blockquote","table"]);function ke(n){return n?En.has(n.kind):!1}function te(n){return(n==null?void 0:n.kind)==="table"}function Ln(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 l=o.toString().length;o.setEnd(t.endContainer,t.endOffset);const i=o.toString().length;return{start:l,end:i}}function An(n,e){var u;const t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);let o=0,l=null,i=0,r=null,s=0,a=t.nextNode();for(;a;){const m=((u=a.textContent)==null?void 0:u.length)??0;if(!l&&o+m>=e.start&&(l=a,i=e.start-o),!r&&o+m>=e.end){r=a,s=e.end-o;break}o+=m,a=t.nextNode()}if(!l||!r)return;const c=document.createRange();c.setStart(l,i),c.setEnd(r,s);const d=document.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(c)}function ne(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 ve(n,e,t){const o=e.parentElement,l=t.parentElement;if(!(o instanceof HTMLTableRowElement)||!(l instanceof HTMLTableRowElement))return[e];const i=Array.from(n.querySelectorAll("tr")),r=i.indexOf(o),s=i.indexOf(l);if(r<0||s<0)return[e];const a=Math.min(r,s),c=Math.max(r,s),d=Array.from(o.children).indexOf(e),u=Array.from(l.children).indexOf(t);if(d<0||u<0)return[e];const m=Math.min(d,u),h=Math.max(d,u),f=[];for(let p=a;p<=c;p++){const g=i[p];if(g)for(let b=m;b<=h;b++){const v=g.children[b];v instanceof HTMLTableCellElement&&f.push(v)}}return f}function Qe(n,e,t){const o=n.getBoundingClientRect(),l=6;return e<o.left-l||e>o.right+l||t<o.top-l||t>o.bottom+l?null:e>=o.right-l?"right":t>=o.bottom-l?"bottom":null}function Ce(n,e,t){return n.getAttribute("data-block-explicit")==="true"||!e.isEmpty(n)?t.kind==="unknown"?n.tagName.toLowerCase():De(t):"?"}function Sn(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 Tn(n){var e;try{const l=new URL(n,"http://localhost").pathname.split("/").filter(Boolean).pop();return l?decodeURIComponent(l):""}catch{return(((e=n.split("?")[0])==null?void 0:e.split("#")[0])??"").split("/").filter(Boolean).pop()??""}}function Bn(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:`${n}`}function Je(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",l=>l.preventDefault()),o.addEventListener("click",t),o}function Nn(){return{blocks:[],activeBlockId:null,inline:{bold:!1,italic:!1,underline:!1,strike:!1}}}function oe(n){try{return document.queryCommandState(n)}catch{return!1}}const Mn=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 $n(n){return Mn.has(n.toUpperCase())}class zn{constructor(e){w(this,"root");w(this,"content");w(this,"blockIds",new pe);w(this,"idFor",e=>this.blockIds.ensure(e));w(this,"destroyed",!1);if(!(e.element instanceof HTMLElement))throw new TypeError("AerizViewer: options.element must be an HTMLElement");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){Pe(this.content,e),Z(this.content,this.blockIds)}getBlocks(){return me(this.listBlocksInternal())}getBlockOf(e){return this.content.contains(e)?Q(e,this.content,this.idFor):null}getHTML(){const e=this.content.cloneNode(!0),t=fe(this.root),o=this.root.dataset.theme;return(o==="light"||o==="dark")&&(t.mode=o),ge(e,t),ye(e),e.innerHTML}setTheme(e){this.root.dataset.theme=e}destroy(){this.destroyed||(this.destroyed=!0,this.root.remove())}listBlocksInternal(){return X(this.content,this.idFor)}}return x.ALL_INLINE_MARKS=Y,x.AerizEditor=xn,x.AerizViewer=zn,x.BLOCK_ID_ATTR=P,x.BLOCK_TYPES=ue,x.BLOCK_TYPE_BY_KIND=N,x.BlockIdRegistry=pe,x.DEFAULT_TOOLBAR=M,x.applyBlockInlineStyles=ge,x.assignMissingIds=Z,x.classifyBlockElement=j,x.extractInlineContent=Oe,x.fillInlineContent=qe,x.findBlockFrom=Q,x.getBlockLabel=De,x.isElementBlank=O,x.listBlocks=X,x.normalizeContent=he,x.placeCaretAtStart=U,x.readBlockStyleTheme=fe,x.renderBlock=Fe,x.renderBlocks=Pe,x.serializeBlock=He,x.serializeBlocks=me,x.stripEditorOnlyAttrs=ye,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"}),x}({});typeof globalThis.AerizWysiwyg=="object"&&(globalThis.AerizEditor=globalThis.AerizWysiwyg.AerizEditor,globalThis.AerizViewer=globalThis.AerizWysiwyg.AerizViewer);
|