@editora/core 1.0.29 → 1.0.31
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 +6 -5
- package/dist/{CollaborationPlugin.native-B2AsCMfm.mjs → CollaborationPlugin.native-B9aiC2s7.mjs} +923 -898
- package/dist/{TextColorPlugin.native-C2IjioNM.mjs → TextColorPlugin.native-30VvsUUv.mjs} +2 -2
- package/dist/editora.min.js +2 -2
- package/dist/editora.umd.js +2 -2
- package/dist/{index-8sr_lMjf.mjs → index-8WhEVFK8.mjs} +164 -160
- package/dist/{index-hTD8Iy46.js → index-DMk3V5_f.js} +5 -5
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/plugin-loader.js +2 -2
- package/dist/webcomponent-core.js +223 -219
- package/dist/webcomponent-core.min.js +19 -19
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +134 -130
- package/dist/webcomponent.min.js +197 -197
- package/package.json +1 -1
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
`,i.forEach(l=>{const c=this.getShortcutDescription(l);o+=`- **${c}**: ${l.description||l.command}
|
|
6
6
|
`}),o+=`
|
|
7
|
-
`}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}class Lo{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Mo{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new Se,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=It.create(e),this.commandRegistry=new Lo(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let i;return e.length===0?i=o(this.state):e.length===1?i=o(this.state,e[0]):i=o(this.state,...e),i instanceof Promise?(i.then(r=>{r&&typeof r=="object"&&"doc"in r&&"selection"in r&&(this.setState(r),this.emit("change",this.state))}).catch(r=>{console.error(`Async command failed: ${t}`,r)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),this.emit("change",this.state),!0):i!==!1&&i!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const i=o.indexOf(e);i>-1&&o.splice(i,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(i=>{try{i(...e)}catch(r){console.error(`Error in ${t} handler:`,r)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class Io{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=i=>{var l,c;if(!this.expandedOpen)return;const r=i.target;r&&((l=this.moreButton)!=null&&l.contains(r)||(c=this.expandedRow)!=null&&c.contains(r))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),i=this.getAvailableToolbarItems(),r=new Map;i.forEach(c=>{c.command&&r.set(c.command,c),c.type==="group"&&c.label&&r.set(c.label,c)});const l={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",insertAudio:"insertAudio",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const f=[];c.split(/\s+/).filter(Boolean).forEach(g=>{if(g==="direction"){const E=r.get("setDirectionLTR"),k=r.get("setDirectionRTL");E&&f.push({id:"directionLTR",label:E.label,command:E.command,icon:E.icon,type:E.type||"button",options:E.options}),k&&f.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(g==="comments"){const E=r.get("addComment"),k=r.get("toggleComments");E&&f.push({id:"addComment",label:E.label,command:E.command,icon:E.icon,type:E.type||"button",options:E.options}),k&&f.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const w=l[g]||g;let T=r.get(w);T||(T=r.get(g)),T&&f.push({id:g,label:T.label,command:T.command,icon:T.icon,type:T.type==="separator"?"separator":T.type||"button",options:T.options,items:T.items})}),f.length>0&&e.push(f)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(o);i.forEach((r,l)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",r.forEach(f=>{this.appendToolbarButton(c,f);const m=c.lastElementChild;m instanceof HTMLElement&&(this.overflowUnits.push(m),this.overflowUnitHomes.set(m,c))}),e.appendChild(c),l<i.length-1){const f=document.createElement("div");f.className="editora-toolbar-separator",e.appendChild(f)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){const e=this.itemsContainer;if(!e||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const i=document.createElement("div");i.className="editora-toolbar-expanded-row",this.expandedRow=i,t.appendChild(i),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const r=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(H=>{var D;H.parentElement===i&&((D=this.overflowUnitHomes.get(H))==null||D.appendChild(H))});const f=t.clientWidth,m=16,g=40,w=4,T=Math.max(0,f-m),E=Math.max(0,T-g-w),k=getComputedStyle(t).direction==="rtl",tt=e.getBoundingClientRect(),$=H=>{const D=H.getBoundingClientRect();return k?tt.right-D.left:D.right-tt.left};let z=0;if($(c[c.length-1])<=T)z=c.length;else for(const H of c)if($(H)<=E)z++;else break;z=Math.max(1,Math.min(z,c.length));const st=z<c.length;o.style.display=st?"":"none",o.classList.toggle("active",st&&this.expandedOpen),!st&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((H,D)=>{D>=z&&i.appendChild(H)})},l=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(r)};this.resizeObserver=new ResizeObserver(()=>l()),this.resizeObserver.observe(t),l()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const i=document.createElement("div");i.className=`editora-toolbar-group-items ${o}`,t.items.forEach(r=>{this.appendToolbarButton(i,r)}),e.appendChild(i)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.setAttribute("aria-label",t.label),e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}makeMenuAccessible(t,e,o,i){e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-label",i),o.querySelectorAll(".editora-toolbar-dropdown-item").forEach(m=>{m.setAttribute("role","menuitem"),m.tabIndex=-1});const r=()=>Array.from(o.querySelectorAll('[role="menuitem"]')),l=()=>o.style.display==="block",c=new MutationObserver(()=>{e.setAttribute("aria-expanded",l()?"true":"false")});c.observe(o,{attributes:!0,attributeFilter:["style"]});const f=t._cleanupDropdown;t._cleanupDropdown=()=>{c.disconnect(),f==null||f()},e.addEventListener("click",m=>{var g;m.detail===0&&l()&&((g=r()[0])==null||g.focus())}),e.addEventListener("keydown",m=>{var w;if(m.key!=="ArrowDown"&&m.key!=="ArrowUp")return;m.preventDefault(),l()||e.click();const g=r();(w=m.key==="ArrowUp"?g[g.length-1]:g[0])==null||w.focus()}),o.addEventListener("keydown",m=>{const g=r();if(g.length===0)return;const w=g.indexOf(document.activeElement),T=E=>{m.preventDefault(),g[(E+g.length)%g.length].focus()};switch(m.key){case"ArrowDown":return T(w+1);case"ArrowUp":return T(w<0?g.length-1:w-1);case"Home":return T(0);case"End":return T(g.length-1);case"Escape":m.preventDefault(),m.stopPropagation(),o.style.display="none",e.focus();return;case"Tab":o.style.display="none";return}})}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const f=document.createElement("button");f.className="editora-toolbar-dropdown-item",f.type="button",f.textContent=c.label,f.setAttribute("data-value",c.value),f.addEventListener("click",m=>{m.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(f)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const f=i.style.display==="block";i.style.display=f?"none":"block"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),this.makeMenuAccessible(e,o,i,t.label),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const f=document.createElement("button");f.className="editora-toolbar-dropdown-item",f.type="button",f.textContent=c.label,f.setAttribute("data-value",c.value),f.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(f)}),o.addEventListener("click",c=>{var m;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const f=(m=this.container)==null?void 0:m.querySelectorAll(".editora-toolbar-dropdown-menu");f==null||f.forEach(g=>{g!==i&&(g.style.display="none")}),i.style.display=i.style.display==="none"?"block":"none"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),this.makeMenuAccessible(e,o,i,t.label),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const i=o._cleanupDropdown;i&&i()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Oo{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Do{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const r=this.statusInfo.selectionInfo;r.startLine===r.endLine&&r.startColumn===r.endColumn?o.push(`Ln ${r.startLine}, Col ${r.startColumn}`):(r.startLine===r.endLine?o.push(`Ln ${r.startLine}, Col ${r.startColumn}-${r.endColumn}`):o.push(`Ln ${r.startLine}:${r.startColumn} - ${r.endLine}:${r.endColumn}`),o.push(`${r.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const r=this.statusInfo.cursorPosition;o.push(`Ln ${r.line}, Col ${r.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const i=[];this.statusInfo.wordCount!==void 0&&i.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&i.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&i.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([r,l])=>{i.push(`${r}: ${l}`)}),o.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,t.appendChild(c),l<o.length-1){const f=document.createElement("span");f.className="editora-statusbar-separator",f.textContent="|",t.appendChild(f)}}),i.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,e.appendChild(c),l<i.length-1){const f=document.createElement("span");f.className="editora-statusbar-separator",f.textContent="|",e.appendChild(f)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}function Ro(s,t){const e=s.textContent||"",o=No(s,t.startContainer,t.startOffset),r=e.substring(0,o).split(`
|
|
7
|
+
`}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}class Lo{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Mo{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new Se,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=It.create(e),this.commandRegistry=new Lo(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let i;return e.length===0?i=o(this.state):e.length===1?i=o(this.state,e[0]):i=o(this.state,...e),i instanceof Promise?(i.then(r=>{r&&typeof r=="object"&&"doc"in r&&"selection"in r&&(this.setState(r),this.emit("change",this.state))}).catch(r=>{console.error(`Async command failed: ${t}`,r)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),this.emit("change",this.state),!0):i!==!1&&i!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const i=o.indexOf(e);i>-1&&o.splice(i,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(i=>{try{i(...e)}catch(r){console.error(`Error in ${t} handler:`,r)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class Io{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=i=>{var l,c;if(!this.expandedOpen)return;const r=i.target;r&&((l=this.moreButton)!=null&&l.contains(r)||(c=this.expandedRow)!=null&&c.contains(r))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),i=this.getAvailableToolbarItems(),r=new Map;i.forEach(c=>{c.command&&r.set(c.command,c),c.type==="group"&&c.label&&r.set(c.label,c)});const l={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",insertAudio:"insertAudio",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const p=[];c.split(/\s+/).filter(Boolean).forEach(g=>{if(g==="direction"){const v=r.get("setDirectionLTR"),k=r.get("setDirectionRTL");v&&p.push({id:"directionLTR",label:v.label,command:v.command,icon:v.icon,type:v.type||"button",options:v.options}),k&&p.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(g==="comments"){const v=r.get("addComment"),k=r.get("toggleComments");v&&p.push({id:"addComment",label:v.label,command:v.command,icon:v.icon,type:v.type||"button",options:v.options}),k&&p.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const w=l[g]||g;let T=r.get(w);T||(T=r.get(g)),T&&p.push({id:g,label:T.label,command:T.command,icon:T.icon,type:T.type==="separator"?"separator":T.type||"button",options:T.options,items:T.items})}),p.length>0&&e.push(p)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(o);i.forEach((r,l)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",r.forEach(p=>{this.appendToolbarButton(c,p);const m=c.lastElementChild;m instanceof HTMLElement&&(this.overflowUnits.push(m),this.overflowUnitHomes.set(m,c))}),e.appendChild(c),l<i.length-1){const p=document.createElement("div");p.className="editora-toolbar-separator",e.appendChild(p)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){const e=this.itemsContainer;if(!e||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const i=document.createElement("div");i.className="editora-toolbar-expanded-row",this.expandedRow=i,t.appendChild(i),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const r=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(H=>{var D;H.parentElement===i&&((D=this.overflowUnitHomes.get(H))==null||D.appendChild(H))});const p=t.clientWidth,m=16,g=40,w=4,T=Math.max(0,p-m),v=Math.max(0,T-g-w),k=getComputedStyle(t).direction==="rtl",tt=e.getBoundingClientRect(),$=H=>{const D=H.getBoundingClientRect();return k?tt.right-D.left:D.right-tt.left};let z=0;if($(c[c.length-1])<=T)z=c.length;else for(const H of c)if($(H)<=v)z++;else break;z=Math.max(1,Math.min(z,c.length));const st=z<c.length;o.style.display=st?"":"none",o.classList.toggle("active",st&&this.expandedOpen),!st&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((H,D)=>{D>=z&&i.appendChild(H)})},l=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(r)};this.resizeObserver=new ResizeObserver(()=>l()),this.resizeObserver.observe(t),l()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const i=document.createElement("div");i.className=`editora-toolbar-group-items ${o}`,t.items.forEach(r=>{this.appendToolbarButton(i,r)}),e.appendChild(i)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.setAttribute("aria-label",t.label),e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}makeMenuAccessible(t,e,o,i){e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-label",i),o.querySelectorAll(".editora-toolbar-dropdown-item").forEach(m=>{m.setAttribute("role","menuitem"),m.tabIndex=-1});const r=()=>Array.from(o.querySelectorAll('[role="menuitem"]')),l=()=>o.style.display==="block",c=new MutationObserver(()=>{e.setAttribute("aria-expanded",l()?"true":"false")});c.observe(o,{attributes:!0,attributeFilter:["style"]});const p=t._cleanupDropdown;t._cleanupDropdown=()=>{c.disconnect(),p==null||p()},e.addEventListener("click",m=>{var g;m.detail===0&&l()&&((g=r()[0])==null||g.focus())}),e.addEventListener("keydown",m=>{var w;if(m.key!=="ArrowDown"&&m.key!=="ArrowUp")return;m.preventDefault(),l()||e.click();const g=r();(w=m.key==="ArrowUp"?g[g.length-1]:g[0])==null||w.focus()}),o.addEventListener("keydown",m=>{const g=r();if(g.length===0)return;const w=g.indexOf(document.activeElement),T=v=>{m.preventDefault(),g[(v+g.length)%g.length].focus()};switch(m.key){case"ArrowDown":return T(w+1);case"ArrowUp":return T(w<0?g.length-1:w-1);case"Home":return T(0);case"End":return T(g.length-1);case"Escape":m.preventDefault(),m.stopPropagation(),o.style.display="none",e.focus();return;case"Tab":o.style.display="none";return}})}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const p=document.createElement("button");p.className="editora-toolbar-dropdown-item",p.type="button",p.textContent=c.label,p.setAttribute("data-value",c.value),p.addEventListener("click",m=>{m.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(p)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const p=i.style.display==="block";i.style.display=p?"none":"block"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),this.makeMenuAccessible(e,o,i,t.label),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const p=document.createElement("button");p.className="editora-toolbar-dropdown-item",p.type="button",p.textContent=c.label,p.setAttribute("data-value",c.value),p.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(p)}),o.addEventListener("click",c=>{var m;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const p=(m=this.container)==null?void 0:m.querySelectorAll(".editora-toolbar-dropdown-menu");p==null||p.forEach(g=>{g!==i&&(g.style.display="none")}),i.style.display=i.style.display==="none"?"block":"none"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),this.makeMenuAccessible(e,o,i,t.label),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const i=o._cleanupDropdown;i&&i()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Oo{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Do{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const r=this.statusInfo.selectionInfo;r.startLine===r.endLine&&r.startColumn===r.endColumn?o.push(`Ln ${r.startLine}, Col ${r.startColumn}`):(r.startLine===r.endLine?o.push(`Ln ${r.startLine}, Col ${r.startColumn}-${r.endColumn}`):o.push(`Ln ${r.startLine}:${r.startColumn} - ${r.endLine}:${r.endColumn}`),o.push(`${r.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const r=this.statusInfo.cursorPosition;o.push(`Ln ${r.line}, Col ${r.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const i=[];this.statusInfo.wordCount!==void 0&&i.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&i.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&i.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([r,l])=>{i.push(`${r}: ${l}`)}),o.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,t.appendChild(c),l<o.length-1){const p=document.createElement("span");p.className="editora-statusbar-separator",p.textContent="|",t.appendChild(p)}}),i.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,e.appendChild(c),l<i.length-1){const p=document.createElement("span");p.className="editora-statusbar-separator",p.textContent="|",e.appendChild(p)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}function Ro(s,t){const e=s.textContent||"",o=No(s,t.startContainer,t.startOffset),r=e.substring(0,o).split(`
|
|
8
8
|
`),l=r.length,c=r[r.length-1].length+1;return{line:l,column:c}}function No(s,t,e){var l;let o=0;const i=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null);let r=i.firstChild();for(;r;){if(r===t){o+=e;break}else r.nodeType===Node.TEXT_NODE&&(o+=((l=r.textContent)==null?void 0:l.length)||0);r=i.nextNode()}return o}function Po(s){var o,i;const t=s.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let e=1;if(t.length>0){e=t.length;const r=t[t.length-1];(r.tagName==="BR"||((o=r.innerHTML)==null?void 0:o.trim())===""||((i=r.textContent)==null?void 0:i.trim())==="")&&e++}else{const l=(s.textContent||"").split(`
|
|
9
|
-
`).length;e=Math.max(1,l)}return e}function zo(s){const t=s.trim()?s.trim().split(/\s+/).length:0,e=s.length;return{words:t,chars:e}}function Ho(s,t){const e=s.toString();return{startLine:t.line,startColumn:t.column,endLine:t.line,endColumn:t.column+e.length,selectedChars:e.length,selectedWords:e.trim().split(/\s+/).filter(Boolean).length}}function so(s,t){(t==null||t>s.length)&&(t=s.length);for(var e=0,o=Array(t);e<t;e++)o[e]=s[e];return o}function xn(s){if(Array.isArray(s))return s}function An(s,t){var e=s==null?null:typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e!=null){var o,i,r,l,c=[],
|
|
10
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sn(s,t){return xn(s)||An(s,t)||_n(s,t)||Cn()}function _n(s,t){if(s){if(typeof s=="string")return so(s,t);var e={}.toString.call(s).slice(8,-1);return e==="Object"&&s.constructor&&(e=s.constructor.name),e==="Map"||e==="Set"?Array.from(s):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?so(s,t):void 0}}const Bo=Object.entries,lo=Object.setPrototypeOf,Ln=Object.isFrozen,Mn=Object.getPrototypeOf,In=Object.getOwnPropertyDescriptor;let M=Object.freeze,I=Object.seal,yt=Object.create,Fo=typeof Reflect!="undefined"&&Reflect,ke=Fo.apply,xe=Fo.construct;M||(M=function(t){return t});I||(I=function(t){return t});ke||(ke=function(t,e){for(var o=arguments.length,i=new Array(o>2?o-2:0),r=2;r<o;r++)i[r-2]=arguments[r];return t.apply(e,i)});xe||(xe=function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return new t(...o)});const rt=L(Array.prototype.forEach),On=L(Array.prototype.lastIndexOf),co=L(Array.prototype.pop),Ct=L(Array.prototype.push),Dn=L(Array.prototype.splice),Et=Array.isArray,Mt=L(String.prototype.toLowerCase),me=L(String.prototype.toString),uo=L(String.prototype.match),St=L(String.prototype.replace),po=L(String.prototype.indexOf),Rn=L(String.prototype.trim),Nn=L(Number.prototype.toString),Pn=L(Boolean.prototype.toString),fo=typeof BigInt=="undefined"?null:L(BigInt.prototype.toString),ho=typeof Symbol=="undefined"?null:L(Symbol.prototype.toString),P=L(Object.prototype.hasOwnProperty),_t=L(Object.prototype.toString),O=L(RegExp.prototype.test),Z=zn(TypeError);function L(s){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return ke(s,t,o)}}function zn(s){return function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return xe(s,e)}}function v(s,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(lo&&lo(s,null),!Et(t))return s;let o=t.length;for(;o--;){let i=t[o];if(typeof i=="string"){const r=e(i);r!==i&&(Ln(t)||(t[o]=r),i=r)}s[i]=!0}return s}function Hn(s){for(let t=0;t<s.length;t++)P(s,t)||(s[t]=null);return s}function U(s){const t=yt(null);for(const o of Bo(s)){var e=Sn(o,2);const i=e[0],r=e[1];P(s,i)&&(Et(r)?t[i]=Hn(r):r&&typeof r=="object"&&r.constructor===Object?t[i]=U(r):t[i]=r)}return t}function Bn(s){switch(typeof s){case"string":return s;case"number":return Nn(s);case"boolean":return Pn(s);case"bigint":return fo?fo(s):"0";case"symbol":return ho?ho(s):"Symbol()";case"undefined":return _t(s);case"function":case"object":{if(s===null)return _t(s);const t=s,e=W(t,"toString");if(typeof e=="function"){const o=e(t);return typeof o=="string"?o:_t(o)}return _t(s)}default:return _t(s)}}function W(s,t){for(;s!==null;){const o=In(s,t);if(o){if(o.get)return L(o.get);if(typeof o.value=="function")return L(o.value)}s=Mn(s)}function e(){return null}return e}function Fn(s){try{return O(s,""),!0}catch(t){return!1}}const mo=M(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ge=M(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),be=M(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Un=M(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ye=M(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),jn=M(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),go=M(["#text"]),bo=M(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ve=M(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),yo=M(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Kt=M(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Wn=I(/{{[\w\W]*|^[\w\W]*}}/g),$n=I(/<%[\w\W]*|^[\w\W]*%>/g),Gn=I(/\${[\w\W]*/g),Kn=I(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yn=I(/^aria-[\-\w]+$/),vo=I(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qn=I(/^(?:\w+script|data):/i),Vn=I(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xn=I(/^html$/i),Zn=I(/^[a-z][.\w]*(-[.\w]+)+$/i),Eo=I(/<[/\w!]/g),wo=I(/<[/\w]/g),Jn=I(/<\/no(script|embed|frames)/i),Qn=I(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Uo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],ti=M(v({},Uo)),ei=(function(){const s={};return rt(Uo,t=>{s[t]=I(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),M(s)})(),oi=function(){return typeof window=="undefined"?null:window},ni=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(o=e.getAttribute(i));const r="dompurify"+(o?"#"+o:"");try{return t.createPolicy(r,{createHTML(l){return l},createScriptURL(l){return l}})}catch(l){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},To=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},J=function(t,e,o,i){return P(t,e)&&Et(t[e])?v(i.base?U(i.base):{},t[e],i.transform):o},Ee=function(t,e,o){const i=P(t,e)?t[e]:void 0;return i&&typeof i=="object"?U(i):o()};function jo(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oi();const t=u=>jo(u);if(t.version="3.4.16",t.removed=[],!s||!s.document||s.document.nodeType!==F.document||!s.Element)return t.isSupported=!1,t;let e=s.document;const o=e,i=o.currentScript;s.DocumentFragment;const r=s.HTMLTemplateElement,l=s.Node,c=s.Element,f=s.NodeFilter;s.NamedNodeMap===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const m=s.DOMParser,g=s.trustedTypes,w=c.prototype,T=W(w,"cloneNode"),E=W(w,"remove"),k=W(w,"removeAttributeNode"),tt=W(w,"nextSibling"),$=W(w,"childNodes"),z=W(w,"parentNode"),st=W(w,"shadowRoot"),H=W(w,"attributes"),D=l&&l.prototype?W(l.prototype,"nodeType"):null,lt=l&&l.prototype?W(l.prototype,"nodeName"):null,Ot=l&&l.prototype?W(l.prototype,"ownerDocument"):null,wt=function(n){return D?D(n):n.nodeType},Zt=function(n){return lt?lt(n):n.nodeName};if(typeof r=="function"){const u=e.createElement("template");u.content&&u.content.ownerDocument&&(e=u.content.ownerDocument)}let N,et="",Jt,Le=!1,Tt=0;const Me=function(){if(Tt>0)throw Z('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ct=function(n){Me(),Tt++;try{return N.createHTML(n)}finally{Tt--}},qo=function(n){Me(),Tt++;try{return N.createScriptURL(n)}finally{Tt--}},Vo=function(){return Le||(Jt=ni(g,i),Le=!0),Jt},Dt=e,Qt=Dt.implementation,Ie=Dt.createNodeIterator,Xo=Dt.createDocumentFragment,Zo=Dt.getElementsByTagName,Jo=o.importNode;let x=To();t.isSupported=typeof Bo=="function"&&typeof z=="function"&&Qt&&Qt.createHTMLDocument!==void 0;const Qo=Wn,tn=$n,en=Gn,on=Kn,nn=Yn,rn=qn,Oe=Vn,an=Zn;let De=vo,A=null;const te=v({},[...mo,...ge,...be,...ye,...go]);let C=null;const ee=v({},[...bo,...ve,...yo,...Kt]);let G=Object.seal(yt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),kt=null,Re=null;const q=Object.seal(yt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ne=!0,oe=!0,Pe=!1,ze=!0,V=!1,ot=!0,nt=!1,ne=!1,Rt=null,Nt=null,ie=!1,dt=!1,Pt=!1,zt=!1,He=!0,Be=!1;const Fe="user-content-";let re=!0,ae=!1,ut={},pt=null;const Ue=v({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let je=null;const We=v({},["audio","video","img","source","image","track"]);let $e=null;const Ge=v({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ht="http://www.w3.org/1998/Math/MathML",Bt="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let ft=K,se=!1,le=null;const sn=v({},[Ht,Bt,K],me),Ke=M(["mi","mo","mn","ms","mtext"]);let ce=v({},Ke);const Ye=M(["annotation-xml"]);let de=v({},Ye);const ln=v({},["title","style","font","a","script"]);let xt=null;const cn=["application/xhtml+xml","text/html"],dn="text/html";let _=null,ht=null;const un=e.createElement("form"),qe=function(n){return n instanceof RegExp||n instanceof Function},ue=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ht&&ht===n)return;(!n||typeof n!="object")&&(n={}),n=U(n),xt=cn.indexOf(n.PARSER_MEDIA_TYPE)===-1?dn:n.PARSER_MEDIA_TYPE,_=xt==="application/xhtml+xml"?me:Mt,A=J(n,"ALLOWED_TAGS",te,{transform:_}),C=J(n,"ALLOWED_ATTR",ee,{transform:_}),le=J(n,"ALLOWED_NAMESPACES",sn,{transform:me}),$e=J(n,"ADD_URI_SAFE_ATTR",Ge,{transform:_,base:Ge}),je=J(n,"ADD_DATA_URI_TAGS",We,{transform:_,base:We}),pt=J(n,"FORBID_CONTENTS",Ue,{transform:_}),kt=J(n,"FORBID_TAGS",U({}),{transform:_}),Re=J(n,"FORBID_ATTR",U({}),{transform:_}),ut=P(n,"USE_PROFILES")?n.USE_PROFILES&&typeof n.USE_PROFILES=="object"?U(n.USE_PROFILES):n.USE_PROFILES:!1,Ne=n.ALLOW_ARIA_ATTR!==!1,oe=n.ALLOW_DATA_ATTR!==!1,Pe=n.ALLOW_UNKNOWN_PROTOCOLS||!1,ze=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,V=n.SAFE_FOR_TEMPLATES||!1,ot=n.SAFE_FOR_XML!==!1,nt=n.WHOLE_DOCUMENT||!1,dt=n.RETURN_DOM||!1,Pt=n.RETURN_DOM_FRAGMENT||!1,zt=n.RETURN_TRUSTED_TYPE||!1,ie=n.FORCE_BODY||!1,He=n.SANITIZE_DOM!==!1,Be=n.SANITIZE_NAMED_PROPS||!1,re=n.KEEP_CONTENT!==!1,ae=n.IN_PLACE||!1,De=Fn(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:vo,ft=typeof n.NAMESPACE=="string"?n.NAMESPACE:K,ce=Ee(n,"MATHML_TEXT_INTEGRATION_POINTS",()=>v({},Ke)),de=Ee(n,"HTML_INTEGRATION_POINTS",()=>v({},Ye));const a=Ee(n,"CUSTOM_ELEMENT_HANDLING",()=>yt(null));if(G=yt(null),P(a,"tagNameCheck")&&qe(a.tagNameCheck)&&(G.tagNameCheck=a.tagNameCheck),P(a,"attributeNameCheck")&&qe(a.attributeNameCheck)&&(G.attributeNameCheck=a.attributeNameCheck),P(a,"allowCustomizedBuiltInElements")&&typeof a.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=a.allowCustomizedBuiltInElements),I(G),V&&(oe=!1),Pt&&(dt=!0),ut&&(A=v({},go),C=yt(null),ut.html===!0&&(v(A,mo),v(C,bo)),ut.svg===!0&&(v(A,ge),v(C,ve),v(C,Kt)),ut.svgFilters===!0&&(v(A,be),v(C,ve),v(C,Kt)),ut.mathMl===!0&&(v(A,ye),v(C,yo),v(C,Kt))),q.tagCheck=null,q.attributeCheck=null,P(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?q.tagCheck=n.ADD_TAGS:Et(n.ADD_TAGS)&&(A===te&&(A=U(A)),v(A,n.ADD_TAGS,_))),P(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?q.attributeCheck=n.ADD_ATTR:Et(n.ADD_ATTR)&&(C===ee&&(C=U(C)),v(C,n.ADD_ATTR,_))),P(n,"ADD_FORBID_CONTENTS")&&Et(n.ADD_FORBID_CONTENTS)&&(pt===Ue&&(pt=U(pt)),v(pt,n.ADD_FORBID_CONTENTS,_)),re&&(A["#text"]=!0),nt&&v(A,["html","head","body"]),A.table&&(v(A,["tbody"]),delete kt.tbody),n.TRUSTED_TYPES_POLICY){if(typeof n.TRUSTED_TYPES_POLICY.createHTML!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof n.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=N;N=n.TRUSTED_TYPES_POLICY;try{et=ct("")}catch(p){throw N=d,p}}else n.TRUSTED_TYPES_POLICY===null?(N=void 0,et=""):(N===void 0&&(N=Vo()),N&&typeof et=="string"&&(et=ct("")));M&&M(n),ht=n},Ve=v({},[...ge,...be,...Un]),Xe=v({},[...ye,...jn]),pn=function(n,a,d){return a.namespaceURI===K?n==="svg":a.namespaceURI===Ht?n==="svg"&&(d==="annotation-xml"||ce[d]):!!Ve[n]},fn=function(n,a,d){return a.namespaceURI===K?n==="math":a.namespaceURI===Bt?n==="math"&&de[d]:!!Xe[n]},hn=function(n,a,d){return a.namespaceURI===Bt&&!de[d]||a.namespaceURI===Ht&&!ce[d]?!1:!Xe[n]&&(ln[n]||!Ve[n])},mn=function(n){let a=z(n);(!a||!a.tagName)&&(a={namespaceURI:ft,tagName:"template"});const d=Mt(n.tagName),p=Mt(a.tagName);return le[n.namespaceURI]?n.namespaceURI===Bt?pn(d,a,p):n.namespaceURI===Ht?fn(d,a,p):n.namespaceURI===K?hn(d,a,p):!!(xt==="application/xhtml+xml"&&le[n.namespaceURI]):!1},X=function(n){Ct(t.removed,{element:n});try{z(n).removeChild(n)}catch(a){if(E(n),!z(n))throw Z("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ze=function(n,a,d){try{k(n,a)}catch(p){try{n.removeAttribute(d)}catch(h){}}},Ft=function(n){Ut(n);const a=$(n);if(a){const p=[];rt(a,h=>{Ct(p,h)}),rt(p,h=>{try{E(h)}catch(b){}})}const d=H(n);if(d)for(let p=d.length-1;p>=0;--p){const h=d[p],b=h&&h.name;typeof b=="string"&&Ze(n,h,b)}},it=function(n,a,d){if(!d)try{d=a.getAttributeNode(n)}catch(p){d=null}Ct(t.removed,{attribute:d||null,from:a});try{d?k(a,d):a.removeAttribute(n)}catch(p){try{a.removeAttribute(n)}catch(h){}}if(n==="is")if(dt||Pt)try{X(a)}catch(p){}else try{a.setAttribute(n,"")}catch(p){}},gn=function(n){const a=H(n);if(a)for(let d=a.length-1;d>=0;--d){const p=a[d],h=p&&p.name;typeof h!="string"||C[_(h)]||Ze(n,p,h)}},Ut=function(n){const a=[n];for(;a.length>0;){const d=a.pop();wt(d)===F.element&&gn(d);const p=$(d);if(p)for(let h=p.length-1;h>=0;--h)a.push(p[h])}},Je=function(n,a){return ot?n==="patchsrc"?!0:n==="for"&&a!=="label"&&a!=="output":!1},bn=function(n){if(!ot)return;const a=[n];for(;a.length>0;){const d=a.pop(),p=wt(d);if(p===F.processingInstruction||p===F.comment&&O(wo,d.data)){try{E(d)}catch(b){}continue}if(p===F.element){const b=d,y=_(Zt(d));try{b.hasAttribute&&b.hasAttribute("patchsrc")&&b.removeAttribute("patchsrc"),b.hasAttribute&&b.hasAttribute("for")&&Je("for",y)&&b.removeAttribute("for")}catch(S){}}const h=$(d);if(h)for(let b=h.length-1;b>=0;--b)a.push(h[b])}},Qe=function(n){let a=null,d=null;if(ie)n="<remove></remove>"+n;else{const b=uo(n,/^[\r\n\t ]+/);d=b&&b[0]}xt==="application/xhtml+xml"&&ft===K&&(n='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+n+"</body></html>");const p=N?ct(n):n;if(ft===K)try{a=new m().parseFromString(p,xt)}catch(b){}if(!a||!a.documentElement){a=Qt.createDocument(ft,"template",null);try{a.documentElement.innerHTML=se?et:p}catch(b){}}const h=a.body||a.documentElement;return n&&d&&h.insertBefore(e.createTextNode(d),h.childNodes[0]||null),ft===K?Zo.call(a,nt?"html":"body")[0]:nt?a.documentElement:h},to=function(n){const a=Ot?Ot(n):n.ownerDocument;return Ie.call(a||n,n,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},jt=function(n){return n=St(n,Qo," "),n=St(n,tn," "),n=St(n,en," "),n},pe=function(n){var a;n.normalize();const d=Ot?Ot(n):n.ownerDocument,p=Ie.call(d||n,n,f.SHOW_TEXT|f.SHOW_COMMENT|f.SHOW_CDATA_SECTION|f.SHOW_PROCESSING_INSTRUCTION,null);let h=p.nextNode();for(;h;)h.data=jt(h.data),h=p.nextNode();const b=(a=n.querySelectorAll)===null||a===void 0?void 0:a.call(n,"template");b&&rt(b,y=>{mt(y.content)&&pe(y.content)})},Wt=function(n){const a=lt?lt(n):null;return typeof a!="string"||_(a)!=="form"?!1:typeof n.nodeName!="string"||typeof n.textContent!="string"||typeof n.removeChild!="function"||n.attributes!==H(n)||typeof n.removeAttribute!="function"||typeof n.removeAttributeNode!="function"||typeof n.getAttributeNode!="function"||typeof n.setAttribute!="function"||typeof n.namespaceURI!="string"||typeof n.insertBefore!="function"||typeof n.hasChildNodes!="function"||n.nodeType!==D(n)||n.childNodes!==$(n)},mt=function(n){if(!D||typeof n!="object"||n===null)return!1;try{return D(n)===F.documentFragment}catch(a){return!1}},At=function(n){if(!D||typeof n!="object"||n===null)return!1;try{return typeof D(n)=="number"}catch(a){return!1}};function Y(u,n,a){u.length!==0&&rt(u,d=>{d.call(t,n,a,ht)})}const yn=function(n,a){return!!(ot&&n.hasChildNodes()&&!At(n.firstElementChild)&&O(Eo,n.textContent)&&O(Eo,n.innerHTML)||ot&&n.namespaceURI===K&&ti[a]&&(At(n.firstElementChild)||typeof n.textContent=="string"&&O(ei[a],n.textContent))||n.nodeType===F.processingInstruction||ot&&n.nodeType===F.comment&&O(wo,n.data))},$t=function(n,a){if(n instanceof RegExp)return O(n,a);if(n instanceof Function){for(var d=arguments.length,p=new Array(d>2?d-2:0),h=2;h<d;h++)p[h-2]=arguments[h];return!!n(a,...p)}return!1},vn=function(n,a,d){if(!kt[a]&&io(a)&&$t(G.tagNameCheck,a))return!1;if(re&&!pt[a]){const p=z(n),h=$(n);if(h&&p){const b=h.length;for(let y=b-1;y>=0;--y){const S=n===d?T(h[y],!0):h[y];p.insertBefore(S,tt(n))}}}return X(n),!0},eo=function(n,a,d,p){return n.length===0?a:a===d||a===p?U(a):a},gt=function(n,a){return n===a||z(n)!==null?!1:(ae&&Ut(n),!0)},oo=function(n,a){if(Y(x.beforeSanitizeElements,n,null),gt(n,a))return!0;if(Wt(n))return X(n),!0;const d=_(Zt(n));if(A=eo(x.uponSanitizeElement,A,te,Rt),Y(x.uponSanitizeElement,n,{tagName:d,allowedTags:A}),gt(n,a))return!0;if(yn(n,d))return X(n),!0;if(kt[d]||!(q.tagCheck instanceof Function&&q.tagCheck(d))&&!A[d]){const p=vn(n,d,a);return p===!1&&(Y(x.afterSanitizeElements,n,null),gt(n,a))?!0:p}if(wt(n)===F.element&&!mn(n)||(d==="noscript"||d==="noembed"||d==="noframes")&&O(Jn,n.innerHTML))return X(n),!0;if(V&&n.nodeType===F.text){const p=jt(n.textContent);n.textContent!==p&&(Ct(t.removed,{element:n.cloneNode()}),n.textContent=p)}return Y(x.afterSanitizeElements,n,null),gt(n,a)},no=function(n,a,d){if(Re[a]||Je(a,n)||He&&(a==="id"||a==="name")&&(d in e||d in un))return!1;const p=C[a]||q.attributeCheck instanceof Function&&q.attributeCheck(a,n);return oe&&O(on,a)||Ne&&O(nn,a)?!0:p?$e[a]||O(De,St(d,Oe,""))||(a==="src"||a==="xlink:href"||a==="href")&&n!=="script"&&po(d,"data:")===0&&je[n]||Pe&&!O(rn,St(d,Oe,""))?!0:!d:io(n)&&$t(G.tagNameCheck,n)&&$t(G.attributeNameCheck,a,n)||a==="is"&&G.allowCustomizedBuiltInElements&&$t(G.tagNameCheck,d)},En=v({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),io=function(n){return!En[Mt(n)]&&O(an,n)},wn=function(n,a,d,p){if(N&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!d)switch(g.getAttributeType(n,a)){case"TrustedHTML":return ct(p);case"TrustedScriptURL":return qo(p)}return p},Tn=function(n,a,d,p){try{return d?n.setAttributeNS(d,a,p):n.setAttribute(a,p),Wt(n)?(X(n),!1):!0}catch(h){return it(a,n),!1}},ro=function(n,a){if(Y(x.beforeSanitizeAttributes,n,null),gt(n,a))return;const d=n.attributes;if(!d||Wt(n))return;C=eo(x.uponSanitizeAttribute,C,ee,Nt);const p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:C,forceKeepAttr:void 0};let h=d.length;const b=_(n.nodeName);for(;h--;){const y=d[h],S=y.name,j=y.namespaceURI,B=y.value,bt=_(S),he=B;let R=S==="value"?he:Rn(he),ao=!1;if(p.attrName=bt,p.attrValue=R,p.keepAttr=!0,p.forceKeepAttr=void 0,Y(x.uponSanitizeAttribute,n,p),R=p.attrValue,Be&&(bt==="id"||bt==="name")&&po(R,Fe)!==0&&(it(S,n,y),R=Fe+R,ao=!0),ot&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,R)){it(S,n,y);continue}if(bt==="attributename"&&uo(R,"href")){it(S,n,y);continue}if(!p.forceKeepAttr){if(!p.keepAttr){it(S,n,y);continue}if(!ze&&O(Qn,R)){it(S,n,y);continue}if(V&&(R=jt(R)),!no(b,bt,R)){it(S,n,y);continue}R=wn(b,bt,j,R),R!==he&&Tn(n,S,j,R)&&ao&&co(t.removed)}}Y(x.afterSanitizeAttributes,n,null),gt(n,a)},Gt=function(n){let a=null;const d=to(n);for(Y(x.beforeSanitizeShadowDOM,n,null);a=d.nextNode();)if(Y(x.uponSanitizeShadowNode,a,null),oo(a,n),ro(a,n),mt(a.content)&&Gt(a.content),wt(a)===F.element){const p=st(a);mt(p)&&(fe(p),Gt(p))}Y(x.afterSanitizeShadowDOM,n,null)},fe=function(n){const a=[{node:n,shadow:null}];for(;a.length>0;){const d=a.pop();if(d.shadow){Gt(d.shadow);continue}const p=d.node,h=wt(p)===F.element,b=$(p);if(b)for(let y=b.length-1;y>=0;--y)a.push({node:b[y],shadow:null});if(h){const y=lt?lt(p):null;if(typeof y=="string"&&_(y)==="template"){const S=p.content;mt(S)&&a.push({node:S,shadow:null})}}if(h){const y=st(p);mt(y)&&a.push({node:null,shadow:y},{node:y,shadow:null})}}};return t.sanitize=function(u){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=null,d=null,p=null,h=null;if(se=!u,se&&(u="<!-->"),typeof u!="string"&&!At(u)&&(u=Bn(u),typeof u!="string"))throw Z("dirty is not a string, aborting");if(!t.isSupported)return u;ne?(A=Rt,C=Nt):ue(n),(x.uponSanitizeElement.length>0||x.uponSanitizeAttribute.length>0)&&(A=U(A)),x.uponSanitizeAttribute.length>0&&(C=U(C)),t.removed=[];const b=ae&&typeof u!="string"&&At(u);if(b){bn(u);const j=Zt(u);if(typeof j=="string"){const B=_(j);if(!A[B]||kt[B])throw Ft(u),Z("root node is forbidden and cannot be sanitized in-place")}if(Wt(u))throw Ft(u),Z("root node is clobbered and cannot be sanitized in-place");try{fe(u)}catch(B){throw Ft(u),B}}else if(At(u))a=Qe("<!---->"),d=a.ownerDocument.importNode(u,!0),d.nodeType===F.element&&d.nodeName==="BODY"||d.nodeName==="HTML"?a=d:a.appendChild(d),fe(a);else{if(!dt&&!V&&!nt&&u.indexOf("<")===-1)return N&&zt?ct(u):u;if(a=Qe(u),!a)return dt?null:zt?et:""}a&&ie&&X(a.firstChild);const y=b?u:a;try{const j=to(y);for(;p=j.nextNode();)oo(p,y),ro(p,y),mt(p.content)&&Gt(p.content)}catch(j){throw b&&(Ft(u),rt(t.removed,B=>{B.element&&Ut(B.element)})),j}if(b){let j=!1;if(rt(t.removed,B=>{B.element&&(B.element===u&&(j=!0),Ut(B.element))}),j)throw Z("a node selected for removal could not be safely returned; refusing to sanitize in place");return V&&pe(u),u}if(dt){if(V&&pe(a),Pt)for(h=Xo.call(a.ownerDocument);a.firstChild;)h.appendChild(a.firstChild);else h=a;return(C.shadowroot||C.shadowrootmode)&&(h=Jo.call(o,h,!0)),h}let S=nt?a.outerHTML:a.innerHTML;return nt&&A["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&O(Xn,a.ownerDocument.doctype.name)&&(S="<!DOCTYPE "+a.ownerDocument.doctype.name+`>
|
|
11
|
-
`+S),V&&(S=jt(S)),N&&zt?ct(S):S},t.setConfig=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ue(u),ne=!0,Rt=A,Nt=C},t.clearConfig=function(){ht=null,ne=!1,Rt=null,Nt=null,N=Jt,et=""},t.isValidAttribute=function(u,n,a){ht||ue({});const d=_(u),p=_(n);return no(d,p,a)},t.addHook=function(u,n){typeof n=="function"&&P(x,u)&&Ct(x[u],n)},t.removeHook=function(u,n){if(P(x,u)){if(n!==void 0){const a=On(x[u],n);return a===-1?void 0:Dn(x[u],a,1)[0]}return co(x[u])}},t.removeHooks=function(u){P(x,u)&&(x[u]=[])},t.removeAllHooks=function(){x=To()},t}var Yt=jo();const ii=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","figure","figcaption","sup","sub","hr"],ri={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],ol:["start","reversed"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"],iframe:["src","width","height","name","title","frameborder","scrolling","allowfullscreen","longdesc","allow"]},ai="data-editora-embed";function si(s){if(!s||/\s/.test(s.trim()))return!1;try{const t=new URL(s.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.hostname.length>0}catch(t){return!1}}function Wo(s,t,e,o){if((t==null?void 0:t.sanitize)===!1)return s;const i=t!=null&&t.allowedTags&&t.allowedTags.length>0?t.allowedTags:ii,r=e!=null&&e.length?Array.from(new Set([...i,...e])):i,c=!!(t!=null&&t.allowedAttributes)&&Object.keys(t.allowedAttributes).length>0?t.allowedAttributes:ri,f=new Set;for(const w of Object.values(c))for(const T of w)f.add(T);const m={ALLOWED_TAGS:r,ALLOWED_ATTR:Array.from(f)};if(!o)return Yt.sanitize(s,m);const g=r.includes("iframe");Yt.addHook("uponSanitizeElement",(w,T)=>{var k;if(T.tagName!=="iframe")return;const E=w;T.allowedTags.iframe=g||((k=E.getAttribute)==null?void 0:k.call(E,ai))==="true"&&si(E.getAttribute("src"))});try{return Yt.sanitize(s,m)}finally{Yt.removeHook("uponSanitizeElement")}}function $o(s,t,e,o){return Wo(s,t,o,!1)}function Go(s,t,e){return(e==null?void 0:e.sanitizeOnPaste)===!1?s:$o(s,t)}function Ae(s,t,e,o){return(e==null?void 0:e.sanitizeOnInput)===!1?s:Wo(s,t,o,!0)}const li=".resize-handle, .table-resize-handle, [data-rte-media-pending]",ci=/resize-handle|data-rte-media-pending|rte-media/;function _e(s){if(!s||!ci.test(s))return s;const t=document.createElement("template");t.innerHTML=s;const e=new Set;return t.content.querySelectorAll(li).forEach(o=>{const i=o.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&e.add(i),o.remove()}),e.forEach(o=>{var i;o.style.position==="relative"&&(o.style.removeProperty("position"),(i=o.getAttribute("style"))!=null&&i.trim()||o.removeAttribute("style"))}),t.content.querySelectorAll("figure.rte-media").forEach(o=>{var r;o.removeAttribute("contenteditable");const i=o.querySelector(":scope > figcaption");i&&(i.removeAttribute("contenteditable"),!((r=i.textContent)!=null&&r.trim())&&!i.querySelector("img, video, a")&&i.remove())}),t.innerHTML}function vt(s){return s?_e(s.innerHTML):""}const Xt=class Xt{static resolve(t){const e={};if(Object.assign(e,this.EDITOR_DEFAULTS),t.pluginDefaults&&Object.assign(e,t.pluginDefaults),t.attributes){const o=this.parseAttributes(t.attributes);Object.assign(e,o)}return t.jsConfig&&Object.assign(e,t.jsConfig),this.normalizeConfig(e)}static normalizeConfig(t){const e={...t};if(e.toolbarFloating!==void 0||e.toolbarSticky!==void 0){const l=typeof e.toolbar=="object"&&e.toolbar?{...e.toolbar}:typeof e.toolbar=="string"?{items:e.toolbar}:{};e.toolbarFloating!==void 0&&(l.floating=!!e.toolbarFloating),e.toolbarSticky!==void 0&&(l.sticky=!!e.toolbarSticky),e.toolbar=l}if(e.toolbarItems!==void 0&&typeof e.toolbar=="object"&&e.toolbar&&(e.toolbar.items=e.toolbarItems),e.autosaveEnabled!==void 0||e.autosaveIntervalMs!==void 0||e.autosaveStorageKey!==void 0||e.autosaveProvider!==void 0||e.autosaveApiUrl!==void 0){const l=typeof e.autosave=="object"&&e.autosave?{...e.autosave}:{};e.autosaveEnabled!==void 0&&(l.enabled=!!e.autosaveEnabled),e.autosaveIntervalMs!==void 0&&(l.intervalMs=Number(e.autosaveIntervalMs)),e.autosaveStorageKey!==void 0&&(l.storageKey=e.autosaveStorageKey),e.autosaveProvider!==void 0&&(l.provider=e.autosaveProvider),e.autosaveApiUrl!==void 0&&(l.apiUrl=e.autosaveApiUrl),e.autosave=l}const o={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof e.autosave=="boolean")e.autosave={...o,enabled:e.autosave};else if(typeof e.autosave=="object"&&e.autosave){const l={...o,...e.autosave};l.intervalMs===void 0&&l.interval!==void 0&&(l.intervalMs=Number(l.interval)),l.enabled===void 0&&(l.enabled=!0),(!Number.isFinite(l.intervalMs)||l.intervalMs<=0)&&(l.intervalMs=o.intervalMs),e.autosave=l}else e.autosave=o;if(e.languageLocale!==void 0||e.languageDirection!==void 0){const l=typeof e.language=="object"&&e.language?{...e.language}:{};e.languageLocale!==void 0&&(l.locale=e.languageLocale),e.languageDirection!==void 0&&(l.direction=e.languageDirection),e.language=l}const i={locale:"en",direction:"ltr"};if(typeof e.language=="string"?e.language={locale:e.language,direction:i.direction}:typeof e.language=="object"&&e.language?e.language={...i,...e.language}:e.language=i,e.spellcheckEnabled!==void 0||e.spellcheckProvider!==void 0||e.spellcheckApiUrl!==void 0){const l=typeof e.spellcheck=="object"&&e.spellcheck?{...e.spellcheck}:{};e.spellcheckEnabled!==void 0&&(l.enabled=!!e.spellcheckEnabled),e.spellcheckProvider!==void 0&&(l.provider=e.spellcheckProvider),e.spellcheckApiUrl!==void 0&&(l.apiUrl=e.spellcheckApiUrl),e.spellcheck=l}const r={enabled:!1,provider:"browser",apiUrl:""};if(typeof e.spellcheck=="boolean")e.spellcheck={...r,enabled:e.spellcheck};else if(typeof e.spellcheck=="object"&&e.spellcheck){const l={...r,...e.spellcheck};!l.provider&&l.mode&&(l.provider=l.mode==="local"?"browser":"api"),l.enabled===void 0&&(l.enabled=!!(l.mode||l.provider||l.apiUrl)),e.spellcheck=l}else e.spellcheck=r;return e.contextMenuEnabled!==void 0&&(e.contextMenu={enabled:!!e.contextMenuEnabled}),typeof e.contextMenu=="boolean"?e.contextMenu={enabled:e.contextMenu}:typeof e.contextMenu=="object"&&e.contextMenu?e.contextMenu={enabled:e.contextMenu.enabled!==!1}:e.contextMenu={enabled:!0},(e.pasteClean!==void 0||e.pasteKeepFormatting!==void 0||e.pasteConvertWord!==void 0)&&(e.paste={...e.paste||{},...e.pasteClean!==void 0?{clean:!!e.pasteClean}:{},...e.pasteKeepFormatting!==void 0?{keepFormatting:!!e.pasteKeepFormatting}:{},...e.pasteConvertWord!==void 0?{convertWord:!!e.pasteConvertWord}:{}}),e.paste={clean:!0,keepFormatting:!1,convertWord:!0,...e.paste||{}},e.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...e.contentConfig||{}},(e.securitySanitizeOnPaste!==void 0||e.securitySanitizeOnInput!==void 0)&&(e.security={...e.security||{},...e.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!e.securitySanitizeOnPaste}:{},...e.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!e.securitySanitizeOnInput}:{}}),e.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...e.security||{}},(e.accessibilityEnableAria!==void 0||e.accessibilityKeyboardNavigation!==void 0||e.accessibilityChecker!==void 0)&&(e.accessibility={...e.accessibility||{},...e.accessibilityEnableAria!==void 0?{enableARIA:!!e.accessibilityEnableAria}:{},...e.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!e.accessibilityKeyboardNavigation}:{},...e.accessibilityChecker!==void 0?{checker:!!e.accessibilityChecker}:{}}),typeof e.accessibility=="boolean"&&(e.accessibility={enableARIA:e.accessibility,keyboardNavigation:e.accessibility,checker:!1}),e.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...e.accessibility||{}},(e.performanceDebounceInputMs!==void 0||e.performanceViewportOnlyScan!==void 0)&&(e.performance={...e.performance||{},...e.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(e.performanceDebounceInputMs)}:{},...e.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!e.performanceViewportOnlyScan}:{}}),typeof e.performance=="boolean"&&(e.performance={debounceInputMs:100,viewportOnlyScan:e.performance}),e.performance={debounceInputMs:100,viewportOnlyScan:!0,...e.performance||{}},(typeof e.performance.debounceInputMs!="number"||!Number.isFinite(e.performance.debounceInputMs)||e.performance.debounceInputMs<0)&&(e.performance.debounceInputMs=100),e}static parseAttributes(t){const e={};for(const[o,i]of Object.entries(t)){const r=this.kebabToCamel(o);e[r]=this.BOOLEAN_ATTRIBUTES.has(o)&&(i===""||i===o)?!0:this.parseAttributeValue(i)}return e}static parseAttributeValue(t){if(t==="true")return!0;if(t==="false")return!1;if(/^\d+$/.test(t))return parseInt(t,10);if(/^\d+\.\d+$/.test(t))return parseFloat(t);if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return t}return t}static kebabToCamel(t){return t.replace(/-([a-z])/g,(e,o)=>o.toUpperCase())}static validate(t){const e=[];return t.height!==void 0&&typeof t.height=="number"&&t.height<0&&e.push("height must be a positive number"),t.width!==void 0&&typeof t.width=="number"&&t.width<0&&e.push("width must be a positive number"),t.plugins!==void 0&&!Array.isArray(t.plugins)&&typeof t.plugins!="string"&&e.push("plugins must be an array or string"),t.theme!==void 0&&typeof t.theme!="string"&&e.push("theme must be a string"),{valid:e.length===0,errors:e}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...t){const e={};for(const o of t)for(const[i,r]of Object.entries(o))r!=null&&(typeof r=="object"&&!Array.isArray(r)&&e[i]?e[i]=this.merge(e[i],r):e[i]=r);return e}};Xt.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},Xt.BOOLEAN_ATTRIBUTES=new Set(["readonly","disabled","autofocus","statusbar","toolbar-floating","toolbar-sticky","autosave-enabled","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance-viewport-only-scan","spellcheck-enabled","context-menu-enabled","paste-clean","paste-keep-formatting","paste-convert-word","security-sanitize-on-paste","security-sanitize-on-input"]);let Vt=Xt;class Ko{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(t,e){this.pluginRegistry.set(t,e)}async load(t,e){if(this.loadedPlugins.has(t))return this.loadedPlugins.get(t);const o=this.pluginRegistry.get(t);if(!o)return console.warn(`Plugin not found: ${t}`),null;const i=await o();return e&&this.applyPluginConfig(i,e),this.loadedPlugins.set(t,i),i}async loadMultiple(t,e){return(await Promise.all(t.map(i=>this.load(i,e)))).filter(i=>i!==null)}async parsePluginString(t,e){const o=t.split(/\s+/).filter(Boolean);return this.loadMultiple(o,e)}applyPluginConfig(t,e){t.__pluginConfig=e}unload(t){this.loadedPlugins.delete(t)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(t){return this.loadedPlugins.has(t)}}const di='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}editora-editor[data-loading]{display:block;position:relative;min-height:160px;border:1px solid var(--ui-color-border, #ddd);border-radius:var(--ui-radius, 4px);background:var(--ui-color-surface, #fff)}editora-editor[data-loading]:before{content:"";position:absolute;inset:0 0 auto;height:46px;border-bottom:1px solid var(--ui-color-border, #ddd);border-radius:var(--ui-radius, 4px) var(--ui-radius, 4px) 0 0;background:linear-gradient(90deg,var(--ui-color-surface-alt, #f5f5f5) 0%,color-mix(in srgb,var(--ui-color-surface-alt, #f5f5f5) 70%,var(--ui-color-border, #ddd)) 50%,var(--ui-color-surface-alt, #f5f5f5) 100%);background-size:220% 100%;animation:editora-loading-shimmer 1.2s linear infinite}editora-editor[data-loading]:after{content:"Loading editor…";position:absolute;top:62px;left:16px;font:14px/1.4 var(--ui-font-family, system-ui, sans-serif);color:var(--ui-color-muted, #6b7280)}editora-editor[data-loading]>*{visibility:hidden}@keyframes editora-loading-shimmer{to{background-position:-220% 0}}@media(prefers-reduced-motion:reduce){editora-editor[data-loading]:before{animation:none}}';let qt;const ui="__editoraCommandEditorRoot",pi="__editoraLastCommandButton",ko="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",xo=".rte-content, .editora-content",fi="Rich text editor",Ce=new Set;let Q=null,Ao=!1,we=null,Te=null;function Co(s){if(!(s instanceof HTMLElement))return!1;const t=s;return typeof t.execCommand=="function"&&(t.tagName.toLowerCase()==="editora-editor"||t.classList.contains("editora-editor")||t.hasAttribute("data-editora-editor"))}function hi(s){return s?s.nodeType===Node.ELEMENT_NODE?s:s.parentElement:null}function Lt(s){if(!s)return null;if(Co(s))return s;const t=s.matches(ko)?s:s.closest(ko);return!t||!Co(t)?null:t}function mi(){var i;if(typeof window=="undefined")return null;const s=window[ui];if(s instanceof HTMLElement){const r=Lt(s);if(r)return r;const l=s.matches(xo)?s:s.querySelector(xo);if(l){const c=Lt(l);if(c)return c}}const t=window[pi];if(t instanceof HTMLElement){const r=Lt(t);if(r)return r}const e=document.activeElement;if(e){const r=Lt(e);if(r)return r}const o=(i=window.getSelection)==null?void 0:i.call(window);if(o&&o.rangeCount>0){const r=Lt(hi(o.getRangeAt(0).startContainer));if(r)return r}if(Q&&Q.isConnected)return Q;for(const r of Ce)if(r.isConnected)return r;return null}function gi(){if(typeof window=="undefined"||Ao)return;we=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,Te=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const s=(t,...e)=>{const o=mi();return o?o.execCommand(t,...e):we?we(t,...e):Te?Te(t,...e):!1};window.executeEditorCommand=s,window.execEditorCommand=s,Ao=!0}function bi(){const s="editora-webcomponent-styles";if(!document.getElementById(s)){const t=document.createElement("style");t.id=s,t.textContent=di,document.head.appendChild(t)}}function Yo(){if(!qt){const s=at.__globalPluginLoader;s?qt=s:qt=new Ko}return qt}function yi(s){const t=Yo();Object.entries(s).forEach(([e,o])=>{t.register(e,o)})}class at extends HTMLElement{constructor(){if(super(),this.pluginLoader=Yo(),this.config={},this.isInitialized=!1,this.buildGeneration=0,this.keyboardShortcutManager=new _o,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,this.pendingHistorySnapshot=null,bi(),!this.hasAttribute("data-initial-content")){const t=this.innerHTML.trim();t&&this.setAttribute("data-initial-content",t)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","aria-label","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(at.__globalPluginLoader){this.pluginLoader=at.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{at.__globalPluginLoader?(this.pluginLoader=at.__globalPluginLoader,t()):setTimeout(e,0)};e()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(t,e,o){e!==o&&(this.config=this.resolveConfig(),this.handleAttributeChange(t,o))}async setConfig(t){this.jsConfig=t,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var r;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;const t=++this.buildGeneration;this.setAttribute("data-editora-editor","true"),Ce.add(this),Q||(Q=this),gi(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`),this.setAttribute("data-loading","true"),this.setAttribute("aria-busy","true");const e=await this.loadPlugins();if(t!==this.buildGeneration||!this.isConnected)return;if(this.loadedPlugins=e,e.forEach(l=>{if(l.init&&typeof l.init=="function")try{l.init({editorElement:this})}catch(c){console.error(`[RichTextEditor] Error initializing plugin ${l.name}:`,c)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const l=this.innerHTML.trim();l&&this.setAttribute("data-initial-content",l)}const o=this.preservedContent;this.preservedContent=null;const i=this.sanitizeLoadedContent((r=o!=null?o:this.restoreAutosavedContent())!=null?r:this.getAttribute("data-initial-content")||"");this.engine=new Mo({content:i,plugins:e,readonly:this.config.readonly}),this.createUI(e,i),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.removeAttribute("data-loading"),this.removeAttribute("aria-busy"),this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const t=this.querySelector("[slot]");return t?t.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(o=>o.nodeType===Node.TEXT_NODE?o.textContent:o.nodeType===Node.ELEMENT_NODE?o.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const t=[],e=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(e){if(typeof this.config.plugins=="string"){const r=this.config.plugins.split(/\s+/).filter(Boolean);i&&!r.includes("a11yChecker")&&r.push("a11yChecker");for(const l of r){const c=await this.pluginLoader.load(l,this.getPluginLoadConfig(l));c&&t.push(c)}}else if(Array.isArray(this.config.plugins)){for(const r of this.config.plugins)if(typeof r=="string"){const l=await this.pluginLoader.load(r,this.getPluginLoadConfig(r));l&&t.push(l)}else t.push(r);if(i&&!t.some(r=>(r==null?void 0:r.name)==="a11yChecker")){const r=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));r&&t.push(r)}}}else{const r=this.pluginLoader.getRegisteredPluginNames();for(const l of r){const c=await this.pluginLoader.load(l,this.getPluginLoadConfig(l));c&&t.push(c)}}return t}resolveToolbarItems(){const t=this.config.toolbarItems;if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");const e=this.config.toolbar;if(typeof e=="string")return e;if(!e||typeof e!="object")return;const o=e.items;if(typeof o=="string")return o;if(Array.isArray(o))return o.join(" ")}isToolbarStickyEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.sticky}isToolbarFloatingEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.floating}isStatusbarEnabled(){const t=this.config.statusbar;return typeof t=="boolean"?t:t&&typeof t=="object"?t.enabled!==!1:!1}getStatusbarPosition(){const t=this.config.statusbar;return t&&typeof t=="object"&&t.position==="top"?"top":"bottom"}getLanguageConfig(){const t=this.config.language;return typeof t=="string"?{locale:t,direction:"ltr"}:t&&typeof t=="object"?{locale:t.locale||"en",direction:t.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const t=this.config.accessibility;return typeof t=="boolean"?{enableARIA:t,keyboardNavigation:t,checker:!1}:t&&typeof t=="object"?{enableARIA:t.enableARIA!==!1,keyboardNavigation:t.keyboardNavigation!==!1,checker:!!t.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var e;const t=this.config.performance;if(typeof t=="boolean")return{debounceInputMs:100,viewportOnlyScan:t};if(t&&typeof t=="object"){const o=Number((e=t.debounceInputMs)!=null?e:100);return{debounceInputMs:Number.isFinite(o)&&o>=0?o:100,viewportOnlyScan:t.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const t=this.contentElement.getBoundingClientRect();return t.bottom>=0&&t.top<=window.innerHeight}applyAccessibilitySettings(){var e;if(!this.contentElement)return;const t=this.getAccessibilityConfig();if(t.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const o=(e=this.getAttribute("aria-label"))==null?void 0:e.trim(),i=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",o||i||fi)}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=t.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const t=this.getLanguageConfig();this.contentElement.setAttribute("lang",t.locale),this.contentElement.setAttribute("dir",t.direction)}getSpellcheckConfig(){const t=this.config.spellcheck;if(typeof t=="boolean")return{enabled:t,provider:"browser"};if(t&&typeof t=="object"){const e=t.provider||"browser";return{enabled:!!t.enabled,provider:e,mode:t.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const t=this.getSpellcheckConfig(),e=t.enabled&&t.provider==="browser";this.contentElement.spellcheck=e,this.contentElement.setAttribute("spellcheck",e?"true":"false")}executeCommand(t,...e){var r;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(l=>l.commands&&l.commands[t]);if(i&&i.commands){const l=i.commands[t];if(typeof l=="function")try{return t==="toggleFullscreen"?l(this,o):l(...e,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${t}:`,c),!1}}return((r=this.engine)==null?void 0:r.execCommand(t,...e))||!1}getPluginLoadConfig(t){const e=this.config.pluginConfig;if(e&&typeof e=="object"){const r=e[t];if(r&&typeof r=="object")return r}const o={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[t,t.toLowerCase(),...o[t]||[]];for(const r of i){const l=this.config[r];if(l&&typeof l=="object"&&!Array.isArray(l))return l}}getContentSanitizeConfig(){const t=this.config.contentConfig;return t&&typeof t=="object"?t:{sanitize:!0}}getSecurityConfig(){const t=this.config.security;return t&&typeof t=="object"?t:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(t){return Ae(t,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var e,o;const t=this.config.autosave;if(typeof t=="boolean")return{enabled:t,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(t&&typeof t=="object"){const i=Number((o=(e=t.intervalMs)!=null?e:t.interval)!=null?o:3e4);return{enabled:!!t.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(t.storageKey||"rte-autosave"),provider:t.provider||"localStorage",apiUrl:t.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(t){const e=this.getAutosaveConfig();if(e.enabled&&t!==this.lastAutosavedContent){if(this.lastAutosavedContent=t,e.provider==="localStorage"){try{localStorage.setItem(e.storageKey,t),localStorage.setItem(`${e.storageKey}-timestamp`,Date.now().toString())}catch(o){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",o)}return}e.provider==="api"&&e.apiUrl&&fetch(e.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,timestamp:Date.now()})}).catch(o=>{console.error("[RichTextEditor] Failed to save autosave content to API:",o)})}}restoreAutosavedContent(){const t=this.getAutosaveConfig();if(!t.enabled||t.provider!=="localStorage")return null;try{const e=localStorage.getItem(t.storageKey);if(e)return this.lastAutosavedContent=e,e}catch(e){console.error("[RichTextEditor] Failed to restore autosaved content:",e)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const t=this.getAutosaveConfig();!t.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(vt(this.contentElement))},t.intervalMs))}insertHTMLAtSelection(t){if(!this.contentElement)return;const e=window.getSelection();if(e&&e.rangeCount>0){const o=e.getRangeAt(0);o.deleteContents();const i=document.createElement("div");i.innerHTML=t;const r=document.createDocumentFragment();for(;i.firstChild;)r.appendChild(i.firstChild);o.insertNode(r),o.collapse(!1),e.removeAllRanges(),e.addRange(o)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,t)}createUI(t,e){const o=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!o?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Io({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((r,l)=>{var c;if(this.contentElement){this.contentElement.focus();const f=window.getSelection();if(!f||f.rangeCount===0||!this.contentElement.contains(f.anchorNode)){const m=document.createRange(),g=this.contentElement.lastChild||this.contentElement;g.nodeType===Node.TEXT_NODE?m.setStart(g,((c=g.textContent)==null?void 0:c.length)||0):g.nodeType===Node.ELEMENT_NODE?(m.selectNodeContents(g),m.collapse(!1)):m.setStart(this.contentElement,0),m.collapse(!0),f==null||f.removeAllRanges(),f==null||f.addRange(m)}}return this.executeCommand(r,l)}),this.toolbar.render(this.toolbarElement)):o&&this.appendChild(o),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(r){console.warn("defaultParagraphSeparator not supported:",r)}if(e){const r=document.createElement("div");r.innerHTML=e.trim(),!Array.from(r.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const f=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(f)}return!1})&&e.trim()?this.contentElement.innerHTML=`<p>${e.trim()}</p>`:this.contentElement.innerHTML=e}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Oo({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Do({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var r;return(r=this.contentElement)==null?void 0:r.focus()},0)}recordInputHistory(t){const e=this.pendingHistorySnapshot;if(this.pendingHistorySnapshot=null,!e||!this.contentElement||e.beforeHTML===t)return;const o=window.execEditorCommand;typeof o=="function"&&o("recordDomTransaction",this.contentElement,e.beforeHTML,t,{inputType:e.inputType,data:e.data,selectionCollapsed:e.selectionCollapsed})}setupEventListeners(){if(!this.contentElement||!this.engine)return;const t=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",o=>{var i,r;this.lastBeforeInputType=o.inputType||null,o.inputType==="historyUndo"||o.inputType==="historyRedo"?this.pendingHistorySnapshot=null:this.contentElement&&(this.pendingHistorySnapshot={beforeHTML:this.contentElement.innerHTML,inputType:o.inputType||null,data:typeof o.data=="string"?o.data:null,selectionCollapsed:(r=(i=window.getSelection())==null?void 0:i.isCollapsed)!=null?r:!0})}),this.contentElement.addEventListener("input",o=>{var T;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const r=(T=o==null?void 0:o.detail)==null?void 0:T.allowedTags,l=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),f=this.getSecurityConfig(),m=this.lastBeforeInputType;if(this.lastBeforeInputType=null,f.sanitizeOnInput!==!1&&c.sanitize!==!1&&!m){const E=Ae(i,c,f,r);if(E!==i){const k=window.getSelection(),tt=k&&k.rangeCount>0?k.getRangeAt(0):null;if(this.contentElement.innerHTML=E,tt&&k)try{k.removeAllRanges(),k.addRange(tt)}catch($){}i=E}}this.recordInputHistory(i),this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const w=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:_e(i)},bubbles:!0}))};l.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(w,l.debounceInputMs):w(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var g,w;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const i=this.config.paste||{};let r=((g=o.clipboardData)==null?void 0:g.getData("text/html"))||"";const l=((w=o.clipboardData)==null?void 0:w.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),f=this.getSecurityConfig(),m=!!r&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(r);if((i.clean||!i.keepFormatting)&&l){document.execCommand("insertText",!1,l);return}if(i.convertWord===!1&&m&&l){document.execCommand("insertText",!1,l);return}if(r){f.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(r=Go(r,c,f)),this.insertHTMLAtSelection(r);return}l&&document.execCommand("insertText",!1,l)}),this.contentElement.addEventListener("focus",()=>{Q=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:vt(this.contentElement)},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",o=>{this.getAccessibilityConfig().keyboardNavigation&&t.handleKeyDown(o,(r,l)=>{this.executeCommand(r,l)})});const e=()=>{const o=this.getSelectionRangeInEditor(),i=document.activeElement,r=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!r||!o&&!r||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=e,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0),o=e.commonAncestorContainer;return this.contentElement.contains(o)?e:null}isSelectionBackward(t){if(!t.anchorNode||!t.focusNode)return!1;try{const e=document.createRange();return e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset),e.collapsed}catch(e){return!1}}getSelectionAnchorRect(t,e){const o=Array.from(e.getClientRects()).filter(r=>r.width>0||r.height>0);return o.length===0?e.getBoundingClientRect():this.isSelectionBackward(t)?o[0]:o[o.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const e=this.getPerformanceConfig(),o=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!o){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const r=window.getSelection();if(!r){this.floatingToolbar.hide();return}const l=this.getSelectionAnchorRect(r,i);if(!l){this.floatingToolbar.hide();return}this.floatingToolbar.show(l.left,l.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const t=this.getPerformanceConfig(),e=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!e)return;const o=this.contentElement.textContent||"",{words:i,chars:r}=zo(o),l=Po(this.contentElement);let c,f;const m=this.getSelectionRangeInEditor();m&&(c=Ro(this.contentElement,m),m.collapsed||(f=Ho(m,c),c=void 0)),this.statusBar.update({wordCount:i,charCount:r,lineCount:l,cursorPosition:c,selectionInfo:f})}isReadonlyAttribute(t){return t!==null&&t!=="false"}handleAttributeChange(t,e){switch(t){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(e)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(e));break;case"theme":this.classList.forEach(o=>{o.startsWith("editora-theme-")&&this.classList.remove(o)}),e&&this.classList.add(`editora-theme-${e}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",e),this.applyAccessibilitySettings());break;case"aria-label":case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(o=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",o)})}));break}}resolveConfig(){const t={};for(let e=0;e<this.attributes.length;e++){const o=this.attributes[e];t[o.name]=o.value}return Vt.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>vt(this.contentElement),setContent:t=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))},execCommand:(t,e)=>this.executeCommand(t,e),focus:()=>{var t;(t=this.contentElement)==null||t.focus()},blur:()=>{var t;(t=this.contentElement)==null||t.blur()},destroy:()=>{this.destroy()},on:(t,e)=>(this.addEventListener(t,e),()=>this.removeEventListener(t,e)),getConfig:()=>({...this.config}),setReadonly:t=>{this.setAttribute("readonly",t.toString())}}}destroy(){var t,e,o,i;this.buildGeneration+=1,this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=vt(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(t=this.engine)==null||t.destroy(),(e=this.toolbar)==null||e.destroy(),(o=this.floatingToolbar)==null||o.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,Ce.delete(this),Q===this&&(Q=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return vt(this.contentElement)}setContent(t){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))}execCommand(t,...e){return this.executeCommand(t,...e)}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}}exports.CommandRegistry=Lo;exports.ConfigResolver=Vt;exports.EditorEngine=Mo;exports.EditorState=It;exports.FloatingToolbar=Oo;exports.KeyboardShortcutManager=_o;exports.PluginLoader=Ko;exports.PluginManager=Se;exports.RichTextEditorElement=at;exports.Schema=So;exports.StatusBar=Do;exports.ToolbarRenderer=Io;exports.calculateTextStats=zo;exports.countLines=Po;exports.createPluginManager=kn;exports.getCleanEditorHTML=vt;exports.getCursorPosition=Ro;exports.getSelectionInfo=Ho;exports.getTextOffset=No;exports.initWebComponent=yi;exports.sanitizeHTML=$o;exports.sanitizeInputHTML=Ae;exports.sanitizePastedHTML=Go;exports.stripEditorUiArtifacts=_e;
|
|
12
|
-
//# sourceMappingURL=index-
|
|
9
|
+
`).length;e=Math.max(1,l)}return e}function zo(s){const t=s.trim()?s.trim().split(/\s+/).length:0,e=s.length;return{words:t,chars:e}}function Ho(s,t){const e=s.toString();return{startLine:t.line,startColumn:t.column,endLine:t.line,endColumn:t.column+e.length,selectedChars:e.length,selectedWords:e.trim().split(/\s+/).filter(Boolean).length}}function so(s,t){(t==null||t>s.length)&&(t=s.length);for(var e=0,o=Array(t);e<t;e++)o[e]=s[e];return o}function xn(s){if(Array.isArray(s))return s}function An(s,t){var e=s==null?null:typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e!=null){var o,i,r,l,c=[],p=!0,m=!1;try{if(r=(e=e.call(s)).next,t!==0)for(;!(p=(o=r.call(e)).done)&&(c.push(o.value),c.length!==t);p=!0);}catch(g){m=!0,i=g}finally{try{if(!p&&e.return!=null&&(l=e.return(),Object(l)!==l))return}finally{if(m)throw i}}return c}}function Cn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
10
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sn(s,t){return xn(s)||An(s,t)||_n(s,t)||Cn()}function _n(s,t){if(s){if(typeof s=="string")return so(s,t);var e={}.toString.call(s).slice(8,-1);return e==="Object"&&s.constructor&&(e=s.constructor.name),e==="Map"||e==="Set"?Array.from(s):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?so(s,t):void 0}}const Bo=Object.entries,lo=Object.setPrototypeOf,Ln=Object.isFrozen,Mn=Object.getPrototypeOf,In=Object.getOwnPropertyDescriptor;let M=Object.freeze,I=Object.seal,yt=Object.create,Fo=typeof Reflect!="undefined"&&Reflect,ke=Fo.apply,xe=Fo.construct;M||(M=function(t){return t});I||(I=function(t){return t});ke||(ke=function(t,e){for(var o=arguments.length,i=new Array(o>2?o-2:0),r=2;r<o;r++)i[r-2]=arguments[r];return t.apply(e,i)});xe||(xe=function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return new t(...o)});const rt=L(Array.prototype.forEach),On=L(Array.prototype.lastIndexOf),co=L(Array.prototype.pop),Ct=L(Array.prototype.push),Dn=L(Array.prototype.splice),vt=Array.isArray,Mt=L(String.prototype.toLowerCase),me=L(String.prototype.toString),uo=L(String.prototype.match),St=L(String.prototype.replace),po=L(String.prototype.indexOf),Rn=L(String.prototype.trim),Nn=L(Number.prototype.toString),Pn=L(Boolean.prototype.toString),fo=typeof BigInt=="undefined"?null:L(BigInt.prototype.toString),ho=typeof Symbol=="undefined"?null:L(Symbol.prototype.toString),P=L(Object.prototype.hasOwnProperty),_t=L(Object.prototype.toString),O=L(RegExp.prototype.test),Z=zn(TypeError);function L(s){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return ke(s,t,o)}}function zn(s){return function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return xe(s,e)}}function E(s,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(lo&&lo(s,null),!vt(t))return s;let o=t.length;for(;o--;){let i=t[o];if(typeof i=="string"){const r=e(i);r!==i&&(Ln(t)||(t[o]=r),i=r)}s[i]=!0}return s}function Hn(s){for(let t=0;t<s.length;t++)P(s,t)||(s[t]=null);return s}function U(s){const t=yt(null);for(const o of Bo(s)){var e=Sn(o,2);const i=e[0],r=e[1];P(s,i)&&(vt(r)?t[i]=Hn(r):r&&typeof r=="object"&&r.constructor===Object?t[i]=U(r):t[i]=r)}return t}function Bn(s){switch(typeof s){case"string":return s;case"number":return Nn(s);case"boolean":return Pn(s);case"bigint":return fo?fo(s):"0";case"symbol":return ho?ho(s):"Symbol()";case"undefined":return _t(s);case"function":case"object":{if(s===null)return _t(s);const t=s,e=W(t,"toString");if(typeof e=="function"){const o=e(t);return typeof o=="string"?o:_t(o)}return _t(s)}default:return _t(s)}}function W(s,t){for(;s!==null;){const o=In(s,t);if(o){if(o.get)return L(o.get);if(typeof o.value=="function")return L(o.value)}s=Mn(s)}function e(){return null}return e}function Fn(s){try{return O(s,""),!0}catch(t){return!1}}const mo=M(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ge=M(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),be=M(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Un=M(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ye=M(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),jn=M(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),go=M(["#text"]),bo=M(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ee=M(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),yo=M(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Kt=M(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Wn=I(/{{[\w\W]*|^[\w\W]*}}/g),$n=I(/<%[\w\W]*|^[\w\W]*%>/g),Gn=I(/\${[\w\W]*/g),Kn=I(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yn=I(/^aria-[\-\w]+$/),Eo=I(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qn=I(/^(?:\w+script|data):/i),Vn=I(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xn=I(/^html$/i),Zn=I(/^[a-z][.\w]*(-[.\w]+)+$/i),vo=I(/<[/\w!]/g),wo=I(/<[/\w]/g),Jn=I(/<\/no(script|embed|frames)/i),Qn=I(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Uo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],ti=M(E({},Uo)),ei=(function(){const s={};return rt(Uo,t=>{s[t]=I(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),M(s)})(),oi=function(){return typeof window=="undefined"?null:window},ni=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(o=e.getAttribute(i));const r="dompurify"+(o?"#"+o:"");try{return t.createPolicy(r,{createHTML(l){return l},createScriptURL(l){return l}})}catch(l){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},To=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},J=function(t,e,o,i){return P(t,e)&&vt(t[e])?E(i.base?U(i.base):{},t[e],i.transform):o},ve=function(t,e,o){const i=P(t,e)?t[e]:void 0;return i&&typeof i=="object"?U(i):o()};function jo(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oi();const t=u=>jo(u);if(t.version="3.4.16",t.removed=[],!s||!s.document||s.document.nodeType!==F.document||!s.Element)return t.isSupported=!1,t;let e=s.document;const o=e,i=o.currentScript;s.DocumentFragment;const r=s.HTMLTemplateElement,l=s.Node,c=s.Element,p=s.NodeFilter;s.NamedNodeMap===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const m=s.DOMParser,g=s.trustedTypes,w=c.prototype,T=W(w,"cloneNode"),v=W(w,"remove"),k=W(w,"removeAttributeNode"),tt=W(w,"nextSibling"),$=W(w,"childNodes"),z=W(w,"parentNode"),st=W(w,"shadowRoot"),H=W(w,"attributes"),D=l&&l.prototype?W(l.prototype,"nodeType"):null,lt=l&&l.prototype?W(l.prototype,"nodeName"):null,Ot=l&&l.prototype?W(l.prototype,"ownerDocument"):null,wt=function(n){return D?D(n):n.nodeType},Zt=function(n){return lt?lt(n):n.nodeName};if(typeof r=="function"){const u=e.createElement("template");u.content&&u.content.ownerDocument&&(e=u.content.ownerDocument)}let N,et="",Jt,Le=!1,Tt=0;const Me=function(){if(Tt>0)throw Z('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ct=function(n){Me(),Tt++;try{return N.createHTML(n)}finally{Tt--}},qo=function(n){Me(),Tt++;try{return N.createScriptURL(n)}finally{Tt--}},Vo=function(){return Le||(Jt=ni(g,i),Le=!0),Jt},Dt=e,Qt=Dt.implementation,Ie=Dt.createNodeIterator,Xo=Dt.createDocumentFragment,Zo=Dt.getElementsByTagName,Jo=o.importNode;let x=To();t.isSupported=typeof Bo=="function"&&typeof z=="function"&&Qt&&Qt.createHTMLDocument!==void 0;const Qo=Wn,tn=$n,en=Gn,on=Kn,nn=Yn,rn=qn,Oe=Vn,an=Zn;let De=Eo,A=null;const te=E({},[...mo,...ge,...be,...ye,...go]);let C=null;const ee=E({},[...bo,...Ee,...yo,...Kt]);let G=Object.seal(yt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),kt=null,Re=null;const q=Object.seal(yt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ne=!0,oe=!0,Pe=!1,ze=!0,V=!1,ot=!0,nt=!1,ne=!1,Rt=null,Nt=null,ie=!1,dt=!1,Pt=!1,zt=!1,He=!0,Be=!1;const Fe="user-content-";let re=!0,ae=!1,ut={},pt=null;const Ue=E({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let je=null;const We=E({},["audio","video","img","source","image","track"]);let $e=null;const Ge=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ht="http://www.w3.org/1998/Math/MathML",Bt="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let ft=K,se=!1,le=null;const sn=E({},[Ht,Bt,K],me),Ke=M(["mi","mo","mn","ms","mtext"]);let ce=E({},Ke);const Ye=M(["annotation-xml"]);let de=E({},Ye);const ln=E({},["title","style","font","a","script"]);let xt=null;const cn=["application/xhtml+xml","text/html"],dn="text/html";let _=null,ht=null;const un=e.createElement("form"),qe=function(n){return n instanceof RegExp||n instanceof Function},ue=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ht&&ht===n)return;(!n||typeof n!="object")&&(n={}),n=U(n),xt=cn.indexOf(n.PARSER_MEDIA_TYPE)===-1?dn:n.PARSER_MEDIA_TYPE,_=xt==="application/xhtml+xml"?me:Mt,A=J(n,"ALLOWED_TAGS",te,{transform:_}),C=J(n,"ALLOWED_ATTR",ee,{transform:_}),le=J(n,"ALLOWED_NAMESPACES",sn,{transform:me}),$e=J(n,"ADD_URI_SAFE_ATTR",Ge,{transform:_,base:Ge}),je=J(n,"ADD_DATA_URI_TAGS",We,{transform:_,base:We}),pt=J(n,"FORBID_CONTENTS",Ue,{transform:_}),kt=J(n,"FORBID_TAGS",U({}),{transform:_}),Re=J(n,"FORBID_ATTR",U({}),{transform:_}),ut=P(n,"USE_PROFILES")?n.USE_PROFILES&&typeof n.USE_PROFILES=="object"?U(n.USE_PROFILES):n.USE_PROFILES:!1,Ne=n.ALLOW_ARIA_ATTR!==!1,oe=n.ALLOW_DATA_ATTR!==!1,Pe=n.ALLOW_UNKNOWN_PROTOCOLS||!1,ze=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,V=n.SAFE_FOR_TEMPLATES||!1,ot=n.SAFE_FOR_XML!==!1,nt=n.WHOLE_DOCUMENT||!1,dt=n.RETURN_DOM||!1,Pt=n.RETURN_DOM_FRAGMENT||!1,zt=n.RETURN_TRUSTED_TYPE||!1,ie=n.FORCE_BODY||!1,He=n.SANITIZE_DOM!==!1,Be=n.SANITIZE_NAMED_PROPS||!1,re=n.KEEP_CONTENT!==!1,ae=n.IN_PLACE||!1,De=Fn(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:Eo,ft=typeof n.NAMESPACE=="string"?n.NAMESPACE:K,ce=ve(n,"MATHML_TEXT_INTEGRATION_POINTS",()=>E({},Ke)),de=ve(n,"HTML_INTEGRATION_POINTS",()=>E({},Ye));const a=ve(n,"CUSTOM_ELEMENT_HANDLING",()=>yt(null));if(G=yt(null),P(a,"tagNameCheck")&&qe(a.tagNameCheck)&&(G.tagNameCheck=a.tagNameCheck),P(a,"attributeNameCheck")&&qe(a.attributeNameCheck)&&(G.attributeNameCheck=a.attributeNameCheck),P(a,"allowCustomizedBuiltInElements")&&typeof a.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=a.allowCustomizedBuiltInElements),I(G),V&&(oe=!1),Pt&&(dt=!0),ut&&(A=E({},go),C=yt(null),ut.html===!0&&(E(A,mo),E(C,bo)),ut.svg===!0&&(E(A,ge),E(C,Ee),E(C,Kt)),ut.svgFilters===!0&&(E(A,be),E(C,Ee),E(C,Kt)),ut.mathMl===!0&&(E(A,ye),E(C,yo),E(C,Kt))),q.tagCheck=null,q.attributeCheck=null,P(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?q.tagCheck=n.ADD_TAGS:vt(n.ADD_TAGS)&&(A===te&&(A=U(A)),E(A,n.ADD_TAGS,_))),P(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?q.attributeCheck=n.ADD_ATTR:vt(n.ADD_ATTR)&&(C===ee&&(C=U(C)),E(C,n.ADD_ATTR,_))),P(n,"ADD_FORBID_CONTENTS")&&vt(n.ADD_FORBID_CONTENTS)&&(pt===Ue&&(pt=U(pt)),E(pt,n.ADD_FORBID_CONTENTS,_)),re&&(A["#text"]=!0),nt&&E(A,["html","head","body"]),A.table&&(E(A,["tbody"]),delete kt.tbody),n.TRUSTED_TYPES_POLICY){if(typeof n.TRUSTED_TYPES_POLICY.createHTML!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof n.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=N;N=n.TRUSTED_TYPES_POLICY;try{et=ct("")}catch(f){throw N=d,f}}else n.TRUSTED_TYPES_POLICY===null?(N=void 0,et=""):(N===void 0&&(N=Vo()),N&&typeof et=="string"&&(et=ct("")));M&&M(n),ht=n},Ve=E({},[...ge,...be,...Un]),Xe=E({},[...ye,...jn]),pn=function(n,a,d){return a.namespaceURI===K?n==="svg":a.namespaceURI===Ht?n==="svg"&&(d==="annotation-xml"||ce[d]):!!Ve[n]},fn=function(n,a,d){return a.namespaceURI===K?n==="math":a.namespaceURI===Bt?n==="math"&&de[d]:!!Xe[n]},hn=function(n,a,d){return a.namespaceURI===Bt&&!de[d]||a.namespaceURI===Ht&&!ce[d]?!1:!Xe[n]&&(ln[n]||!Ve[n])},mn=function(n){let a=z(n);(!a||!a.tagName)&&(a={namespaceURI:ft,tagName:"template"});const d=Mt(n.tagName),f=Mt(a.tagName);return le[n.namespaceURI]?n.namespaceURI===Bt?pn(d,a,f):n.namespaceURI===Ht?fn(d,a,f):n.namespaceURI===K?hn(d,a,f):!!(xt==="application/xhtml+xml"&&le[n.namespaceURI]):!1},X=function(n){Ct(t.removed,{element:n});try{z(n).removeChild(n)}catch(a){if(v(n),!z(n))throw Z("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ze=function(n,a,d){try{k(n,a)}catch(f){try{n.removeAttribute(d)}catch(h){}}},Ft=function(n){Ut(n);const a=$(n);if(a){const f=[];rt(a,h=>{Ct(f,h)}),rt(f,h=>{try{v(h)}catch(b){}})}const d=H(n);if(d)for(let f=d.length-1;f>=0;--f){const h=d[f],b=h&&h.name;typeof b=="string"&&Ze(n,h,b)}},it=function(n,a,d){if(!d)try{d=a.getAttributeNode(n)}catch(f){d=null}Ct(t.removed,{attribute:d||null,from:a});try{d?k(a,d):a.removeAttribute(n)}catch(f){try{a.removeAttribute(n)}catch(h){}}if(n==="is")if(dt||Pt)try{X(a)}catch(f){}else try{a.setAttribute(n,"")}catch(f){}},gn=function(n){const a=H(n);if(a)for(let d=a.length-1;d>=0;--d){const f=a[d],h=f&&f.name;typeof h!="string"||C[_(h)]||Ze(n,f,h)}},Ut=function(n){const a=[n];for(;a.length>0;){const d=a.pop();wt(d)===F.element&&gn(d);const f=$(d);if(f)for(let h=f.length-1;h>=0;--h)a.push(f[h])}},Je=function(n,a){return ot?n==="patchsrc"?!0:n==="for"&&a!=="label"&&a!=="output":!1},bn=function(n){if(!ot)return;const a=[n];for(;a.length>0;){const d=a.pop(),f=wt(d);if(f===F.processingInstruction||f===F.comment&&O(wo,d.data)){try{v(d)}catch(b){}continue}if(f===F.element){const b=d,y=_(Zt(d));try{b.hasAttribute&&b.hasAttribute("patchsrc")&&b.removeAttribute("patchsrc"),b.hasAttribute&&b.hasAttribute("for")&&Je("for",y)&&b.removeAttribute("for")}catch(S){}}const h=$(d);if(h)for(let b=h.length-1;b>=0;--b)a.push(h[b])}},Qe=function(n){let a=null,d=null;if(ie)n="<remove></remove>"+n;else{const b=uo(n,/^[\r\n\t ]+/);d=b&&b[0]}xt==="application/xhtml+xml"&&ft===K&&(n='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+n+"</body></html>");const f=N?ct(n):n;if(ft===K)try{a=new m().parseFromString(f,xt)}catch(b){}if(!a||!a.documentElement){a=Qt.createDocument(ft,"template",null);try{a.documentElement.innerHTML=se?et:f}catch(b){}}const h=a.body||a.documentElement;return n&&d&&h.insertBefore(e.createTextNode(d),h.childNodes[0]||null),ft===K?Zo.call(a,nt?"html":"body")[0]:nt?a.documentElement:h},to=function(n){const a=Ot?Ot(n):n.ownerDocument;return Ie.call(a||n,n,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},jt=function(n){return n=St(n,Qo," "),n=St(n,tn," "),n=St(n,en," "),n},pe=function(n){var a;n.normalize();const d=Ot?Ot(n):n.ownerDocument,f=Ie.call(d||n,n,p.SHOW_TEXT|p.SHOW_COMMENT|p.SHOW_CDATA_SECTION|p.SHOW_PROCESSING_INSTRUCTION,null);let h=f.nextNode();for(;h;)h.data=jt(h.data),h=f.nextNode();const b=(a=n.querySelectorAll)===null||a===void 0?void 0:a.call(n,"template");b&&rt(b,y=>{mt(y.content)&&pe(y.content)})},Wt=function(n){const a=lt?lt(n):null;return typeof a!="string"||_(a)!=="form"?!1:typeof n.nodeName!="string"||typeof n.textContent!="string"||typeof n.removeChild!="function"||n.attributes!==H(n)||typeof n.removeAttribute!="function"||typeof n.removeAttributeNode!="function"||typeof n.getAttributeNode!="function"||typeof n.setAttribute!="function"||typeof n.namespaceURI!="string"||typeof n.insertBefore!="function"||typeof n.hasChildNodes!="function"||n.nodeType!==D(n)||n.childNodes!==$(n)},mt=function(n){if(!D||typeof n!="object"||n===null)return!1;try{return D(n)===F.documentFragment}catch(a){return!1}},At=function(n){if(!D||typeof n!="object"||n===null)return!1;try{return typeof D(n)=="number"}catch(a){return!1}};function Y(u,n,a){u.length!==0&&rt(u,d=>{d.call(t,n,a,ht)})}const yn=function(n,a){return!!(ot&&n.hasChildNodes()&&!At(n.firstElementChild)&&O(vo,n.textContent)&&O(vo,n.innerHTML)||ot&&n.namespaceURI===K&&ti[a]&&(At(n.firstElementChild)||typeof n.textContent=="string"&&O(ei[a],n.textContent))||n.nodeType===F.processingInstruction||ot&&n.nodeType===F.comment&&O(wo,n.data))},$t=function(n,a){if(n instanceof RegExp)return O(n,a);if(n instanceof Function){for(var d=arguments.length,f=new Array(d>2?d-2:0),h=2;h<d;h++)f[h-2]=arguments[h];return!!n(a,...f)}return!1},En=function(n,a,d){if(!kt[a]&&io(a)&&$t(G.tagNameCheck,a))return!1;if(re&&!pt[a]){const f=z(n),h=$(n);if(h&&f){const b=h.length;for(let y=b-1;y>=0;--y){const S=n===d?T(h[y],!0):h[y];f.insertBefore(S,tt(n))}}}return X(n),!0},eo=function(n,a,d,f){return n.length===0?a:a===d||a===f?U(a):a},gt=function(n,a){return n===a||z(n)!==null?!1:(ae&&Ut(n),!0)},oo=function(n,a){if(Y(x.beforeSanitizeElements,n,null),gt(n,a))return!0;if(Wt(n))return X(n),!0;const d=_(Zt(n));if(A=eo(x.uponSanitizeElement,A,te,Rt),Y(x.uponSanitizeElement,n,{tagName:d,allowedTags:A}),gt(n,a))return!0;if(yn(n,d))return X(n),!0;if(kt[d]||!(q.tagCheck instanceof Function&&q.tagCheck(d))&&!A[d]){const f=En(n,d,a);return f===!1&&(Y(x.afterSanitizeElements,n,null),gt(n,a))?!0:f}if(wt(n)===F.element&&!mn(n)||(d==="noscript"||d==="noembed"||d==="noframes")&&O(Jn,n.innerHTML))return X(n),!0;if(V&&n.nodeType===F.text){const f=jt(n.textContent);n.textContent!==f&&(Ct(t.removed,{element:n.cloneNode()}),n.textContent=f)}return Y(x.afterSanitizeElements,n,null),gt(n,a)},no=function(n,a,d){if(Re[a]||Je(a,n)||He&&(a==="id"||a==="name")&&(d in e||d in un))return!1;const f=C[a]||q.attributeCheck instanceof Function&&q.attributeCheck(a,n);return oe&&O(on,a)||Ne&&O(nn,a)?!0:f?$e[a]||O(De,St(d,Oe,""))||(a==="src"||a==="xlink:href"||a==="href")&&n!=="script"&&po(d,"data:")===0&&je[n]||Pe&&!O(rn,St(d,Oe,""))?!0:!d:io(n)&&$t(G.tagNameCheck,n)&&$t(G.attributeNameCheck,a,n)||a==="is"&&G.allowCustomizedBuiltInElements&&$t(G.tagNameCheck,d)},vn=E({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),io=function(n){return!vn[Mt(n)]&&O(an,n)},wn=function(n,a,d,f){if(N&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!d)switch(g.getAttributeType(n,a)){case"TrustedHTML":return ct(f);case"TrustedScriptURL":return qo(f)}return f},Tn=function(n,a,d,f){try{return d?n.setAttributeNS(d,a,f):n.setAttribute(a,f),Wt(n)?(X(n),!1):!0}catch(h){return it(a,n),!1}},ro=function(n,a){if(Y(x.beforeSanitizeAttributes,n,null),gt(n,a))return;const d=n.attributes;if(!d||Wt(n))return;C=eo(x.uponSanitizeAttribute,C,ee,Nt);const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:C,forceKeepAttr:void 0};let h=d.length;const b=_(n.nodeName);for(;h--;){const y=d[h],S=y.name,j=y.namespaceURI,B=y.value,bt=_(S),he=B;let R=S==="value"?he:Rn(he),ao=!1;if(f.attrName=bt,f.attrValue=R,f.keepAttr=!0,f.forceKeepAttr=void 0,Y(x.uponSanitizeAttribute,n,f),R=f.attrValue,Be&&(bt==="id"||bt==="name")&&po(R,Fe)!==0&&(it(S,n,y),R=Fe+R,ao=!0),ot&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,R)){it(S,n,y);continue}if(bt==="attributename"&&uo(R,"href")){it(S,n,y);continue}if(!f.forceKeepAttr){if(!f.keepAttr){it(S,n,y);continue}if(!ze&&O(Qn,R)){it(S,n,y);continue}if(V&&(R=jt(R)),!no(b,bt,R)){it(S,n,y);continue}R=wn(b,bt,j,R),R!==he&&Tn(n,S,j,R)&&ao&&co(t.removed)}}Y(x.afterSanitizeAttributes,n,null),gt(n,a)},Gt=function(n){let a=null;const d=to(n);for(Y(x.beforeSanitizeShadowDOM,n,null);a=d.nextNode();)if(Y(x.uponSanitizeShadowNode,a,null),oo(a,n),ro(a,n),mt(a.content)&&Gt(a.content),wt(a)===F.element){const f=st(a);mt(f)&&(fe(f),Gt(f))}Y(x.afterSanitizeShadowDOM,n,null)},fe=function(n){const a=[{node:n,shadow:null}];for(;a.length>0;){const d=a.pop();if(d.shadow){Gt(d.shadow);continue}const f=d.node,h=wt(f)===F.element,b=$(f);if(b)for(let y=b.length-1;y>=0;--y)a.push({node:b[y],shadow:null});if(h){const y=lt?lt(f):null;if(typeof y=="string"&&_(y)==="template"){const S=f.content;mt(S)&&a.push({node:S,shadow:null})}}if(h){const y=st(f);mt(y)&&a.push({node:null,shadow:y},{node:y,shadow:null})}}};return t.sanitize=function(u){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=null,d=null,f=null,h=null;if(se=!u,se&&(u="<!-->"),typeof u!="string"&&!At(u)&&(u=Bn(u),typeof u!="string"))throw Z("dirty is not a string, aborting");if(!t.isSupported)return u;ne?(A=Rt,C=Nt):ue(n),(x.uponSanitizeElement.length>0||x.uponSanitizeAttribute.length>0)&&(A=U(A)),x.uponSanitizeAttribute.length>0&&(C=U(C)),t.removed=[];const b=ae&&typeof u!="string"&&At(u);if(b){bn(u);const j=Zt(u);if(typeof j=="string"){const B=_(j);if(!A[B]||kt[B])throw Ft(u),Z("root node is forbidden and cannot be sanitized in-place")}if(Wt(u))throw Ft(u),Z("root node is clobbered and cannot be sanitized in-place");try{fe(u)}catch(B){throw Ft(u),B}}else if(At(u))a=Qe("<!---->"),d=a.ownerDocument.importNode(u,!0),d.nodeType===F.element&&d.nodeName==="BODY"||d.nodeName==="HTML"?a=d:a.appendChild(d),fe(a);else{if(!dt&&!V&&!nt&&u.indexOf("<")===-1)return N&&zt?ct(u):u;if(a=Qe(u),!a)return dt?null:zt?et:""}a&&ie&&X(a.firstChild);const y=b?u:a;try{const j=to(y);for(;f=j.nextNode();)oo(f,y),ro(f,y),mt(f.content)&&Gt(f.content)}catch(j){throw b&&(Ft(u),rt(t.removed,B=>{B.element&&Ut(B.element)})),j}if(b){let j=!1;if(rt(t.removed,B=>{B.element&&(B.element===u&&(j=!0),Ut(B.element))}),j)throw Z("a node selected for removal could not be safely returned; refusing to sanitize in place");return V&&pe(u),u}if(dt){if(V&&pe(a),Pt)for(h=Xo.call(a.ownerDocument);a.firstChild;)h.appendChild(a.firstChild);else h=a;return(C.shadowroot||C.shadowrootmode)&&(h=Jo.call(o,h,!0)),h}let S=nt?a.outerHTML:a.innerHTML;return nt&&A["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&O(Xn,a.ownerDocument.doctype.name)&&(S="<!DOCTYPE "+a.ownerDocument.doctype.name+`>
|
|
11
|
+
`+S),V&&(S=jt(S)),N&&zt?ct(S):S},t.setConfig=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ue(u),ne=!0,Rt=A,Nt=C},t.clearConfig=function(){ht=null,ne=!1,Rt=null,Nt=null,N=Jt,et=""},t.isValidAttribute=function(u,n,a){ht||ue({});const d=_(u),f=_(n);return no(d,f,a)},t.addHook=function(u,n){typeof n=="function"&&P(x,u)&&Ct(x[u],n)},t.removeHook=function(u,n){if(P(x,u)){if(n!==void 0){const a=On(x[u],n);return a===-1?void 0:Dn(x[u],a,1)[0]}return co(x[u])}},t.removeHooks=function(u){P(x,u)&&(x[u]=[])},t.removeAllHooks=function(){x=To()},t}var Yt=jo();const ii=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","figure","figcaption","sup","sub","hr"],ri={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],ol:["start","reversed"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"],iframe:["src","width","height","name","title","frameborder","scrolling","allowfullscreen","longdesc","allow"]},ai="data-editora-embed";function si(s){if(!s||/\s/.test(s.trim()))return!1;try{const t=new URL(s.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.hostname.length>0}catch(t){return!1}}function Wo(s,t,e,o){if((t==null?void 0:t.sanitize)===!1)return s;const i=t!=null&&t.allowedTags&&t.allowedTags.length>0?t.allowedTags:ii,r=e!=null&&e.length?Array.from(new Set([...i,...e])):i,c=!!(t!=null&&t.allowedAttributes)&&Object.keys(t.allowedAttributes).length>0?t.allowedAttributes:ri,p=new Set;for(const w of Object.values(c))for(const T of w)p.add(T);const m={ALLOWED_TAGS:r,ALLOWED_ATTR:Array.from(p)};if(!o)return Yt.sanitize(s,m);const g=r.includes("iframe");Yt.addHook("uponSanitizeElement",(w,T)=>{var k;if(T.tagName!=="iframe")return;const v=w;T.allowedTags.iframe=g||((k=v.getAttribute)==null?void 0:k.call(v,ai))==="true"&&si(v.getAttribute("src"))});try{return Yt.sanitize(s,m)}finally{Yt.removeHook("uponSanitizeElement")}}function $o(s,t,e,o){return Wo(s,t,o,!1)}function Go(s,t,e){return(e==null?void 0:e.sanitizeOnPaste)===!1?s:$o(s,t)}function Ae(s,t,e,o){return(e==null?void 0:e.sanitizeOnInput)===!1?s:Wo(s,t,o,!0)}const li=".resize-handle, .table-resize-handle, [data-rte-media-pending]",ci=/resize-handle|data-rte-media-pending|rte-media/;function _e(s){if(!s||!ci.test(s))return s;const t=document.createElement("template");t.innerHTML=s;const e=new Set;return t.content.querySelectorAll(li).forEach(o=>{const i=o.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&e.add(i),o.remove()}),e.forEach(o=>{var i;o.style.position==="relative"&&(o.style.removeProperty("position"),(i=o.getAttribute("style"))!=null&&i.trim()||o.removeAttribute("style"))}),t.content.querySelectorAll("figure.rte-media").forEach(o=>{var r;o.removeAttribute("contenteditable");const i=o.querySelector(":scope > figcaption");i&&(i.removeAttribute("contenteditable"),!((r=i.textContent)!=null&&r.trim())&&!i.querySelector("img, video, a")&&i.remove())}),t.innerHTML}function Et(s){return s?_e(s.innerHTML):""}const Xt=class Xt{static resolve(t){const e={};if(Object.assign(e,this.EDITOR_DEFAULTS),t.pluginDefaults&&Object.assign(e,t.pluginDefaults),t.attributes){const o=this.parseAttributes(t.attributes);Object.assign(e,o)}return t.jsConfig&&Object.assign(e,t.jsConfig),this.normalizeConfig(e)}static normalizeConfig(t){const e={...t};if(e.toolbarFloating!==void 0||e.toolbarSticky!==void 0){const l=typeof e.toolbar=="object"&&e.toolbar?{...e.toolbar}:typeof e.toolbar=="string"?{items:e.toolbar}:{};e.toolbarFloating!==void 0&&(l.floating=!!e.toolbarFloating),e.toolbarSticky!==void 0&&(l.sticky=!!e.toolbarSticky),e.toolbar=l}if(e.toolbarItems!==void 0&&typeof e.toolbar=="object"&&e.toolbar&&(e.toolbar.items=e.toolbarItems),e.autosaveEnabled!==void 0||e.autosaveIntervalMs!==void 0||e.autosaveStorageKey!==void 0||e.autosaveProvider!==void 0||e.autosaveApiUrl!==void 0){const l=typeof e.autosave=="object"&&e.autosave?{...e.autosave}:{};e.autosaveEnabled!==void 0&&(l.enabled=!!e.autosaveEnabled),e.autosaveIntervalMs!==void 0&&(l.intervalMs=Number(e.autosaveIntervalMs)),e.autosaveStorageKey!==void 0&&(l.storageKey=e.autosaveStorageKey),e.autosaveProvider!==void 0&&(l.provider=e.autosaveProvider),e.autosaveApiUrl!==void 0&&(l.apiUrl=e.autosaveApiUrl),e.autosave=l}const o={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof e.autosave=="boolean")e.autosave={...o,enabled:e.autosave};else if(typeof e.autosave=="object"&&e.autosave){const l={...o,...e.autosave};l.intervalMs===void 0&&l.interval!==void 0&&(l.intervalMs=Number(l.interval)),l.enabled===void 0&&(l.enabled=!0),(!Number.isFinite(l.intervalMs)||l.intervalMs<=0)&&(l.intervalMs=o.intervalMs),e.autosave=l}else e.autosave=o;if(e.languageLocale!==void 0||e.languageDirection!==void 0){const l=typeof e.language=="object"&&e.language?{...e.language}:{};e.languageLocale!==void 0&&(l.locale=e.languageLocale),e.languageDirection!==void 0&&(l.direction=e.languageDirection),e.language=l}const i={locale:"en",direction:"ltr"};if(typeof e.language=="string"?e.language={locale:e.language,direction:i.direction}:typeof e.language=="object"&&e.language?e.language={...i,...e.language}:e.language=i,e.spellcheckEnabled!==void 0||e.spellcheckProvider!==void 0||e.spellcheckApiUrl!==void 0){const l=typeof e.spellcheck=="object"&&e.spellcheck?{...e.spellcheck}:{};e.spellcheckEnabled!==void 0&&(l.enabled=!!e.spellcheckEnabled),e.spellcheckProvider!==void 0&&(l.provider=e.spellcheckProvider),e.spellcheckApiUrl!==void 0&&(l.apiUrl=e.spellcheckApiUrl),e.spellcheck=l}const r={enabled:!1,provider:"browser",apiUrl:""};if(typeof e.spellcheck=="boolean")e.spellcheck={...r,enabled:e.spellcheck};else if(typeof e.spellcheck=="object"&&e.spellcheck){const l={...r,...e.spellcheck};!l.provider&&l.mode&&(l.provider=l.mode==="local"?"browser":"api"),l.enabled===void 0&&(l.enabled=!!(l.mode||l.provider||l.apiUrl)),e.spellcheck=l}else e.spellcheck=r;return e.contextMenuEnabled!==void 0&&(e.contextMenu={enabled:!!e.contextMenuEnabled}),typeof e.contextMenu=="boolean"?e.contextMenu={enabled:e.contextMenu}:typeof e.contextMenu=="object"&&e.contextMenu?e.contextMenu={enabled:e.contextMenu.enabled!==!1}:e.contextMenu={enabled:!0},(e.pasteClean!==void 0||e.pasteKeepFormatting!==void 0||e.pasteConvertWord!==void 0)&&(e.paste={...e.paste||{},...e.pasteClean!==void 0?{clean:!!e.pasteClean}:{},...e.pasteKeepFormatting!==void 0?{keepFormatting:!!e.pasteKeepFormatting}:{},...e.pasteConvertWord!==void 0?{convertWord:!!e.pasteConvertWord}:{}}),e.paste={clean:!0,keepFormatting:!1,convertWord:!0,...e.paste||{}},e.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...e.contentConfig||{}},(e.securitySanitizeOnPaste!==void 0||e.securitySanitizeOnInput!==void 0)&&(e.security={...e.security||{},...e.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!e.securitySanitizeOnPaste}:{},...e.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!e.securitySanitizeOnInput}:{}}),e.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...e.security||{}},(e.accessibilityEnableAria!==void 0||e.accessibilityKeyboardNavigation!==void 0||e.accessibilityChecker!==void 0)&&(e.accessibility={...e.accessibility||{},...e.accessibilityEnableAria!==void 0?{enableARIA:!!e.accessibilityEnableAria}:{},...e.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!e.accessibilityKeyboardNavigation}:{},...e.accessibilityChecker!==void 0?{checker:!!e.accessibilityChecker}:{}}),typeof e.accessibility=="boolean"&&(e.accessibility={enableARIA:e.accessibility,keyboardNavigation:e.accessibility,checker:!1}),e.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...e.accessibility||{}},(e.performanceDebounceInputMs!==void 0||e.performanceViewportOnlyScan!==void 0)&&(e.performance={...e.performance||{},...e.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(e.performanceDebounceInputMs)}:{},...e.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!e.performanceViewportOnlyScan}:{}}),typeof e.performance=="boolean"&&(e.performance={debounceInputMs:100,viewportOnlyScan:e.performance}),e.performance={debounceInputMs:100,viewportOnlyScan:!0,...e.performance||{}},(typeof e.performance.debounceInputMs!="number"||!Number.isFinite(e.performance.debounceInputMs)||e.performance.debounceInputMs<0)&&(e.performance.debounceInputMs=100),e}static parseAttributes(t){const e={};for(const[o,i]of Object.entries(t)){const r=this.kebabToCamel(o);e[r]=this.BOOLEAN_ATTRIBUTES.has(o)&&(i===""||i===o)?!0:this.parseAttributeValue(i)}return e}static parseAttributeValue(t){if(t==="true")return!0;if(t==="false")return!1;if(/^\d+$/.test(t))return parseInt(t,10);if(/^\d+\.\d+$/.test(t))return parseFloat(t);if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return t}return t}static kebabToCamel(t){return t.replace(/-([a-z])/g,(e,o)=>o.toUpperCase())}static validate(t){const e=[];return t.height!==void 0&&typeof t.height=="number"&&t.height<0&&e.push("height must be a positive number"),t.width!==void 0&&typeof t.width=="number"&&t.width<0&&e.push("width must be a positive number"),t.plugins!==void 0&&!Array.isArray(t.plugins)&&typeof t.plugins!="string"&&e.push("plugins must be an array or string"),t.theme!==void 0&&typeof t.theme!="string"&&e.push("theme must be a string"),{valid:e.length===0,errors:e}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...t){const e={};for(const o of t)for(const[i,r]of Object.entries(o))r!=null&&(typeof r=="object"&&!Array.isArray(r)&&e[i]?e[i]=this.merge(e[i],r):e[i]=r);return e}};Xt.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},Xt.BOOLEAN_ATTRIBUTES=new Set(["readonly","disabled","autofocus","statusbar","toolbar-floating","toolbar-sticky","autosave-enabled","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance-viewport-only-scan","spellcheck-enabled","context-menu-enabled","paste-clean","paste-keep-formatting","paste-convert-word","security-sanitize-on-paste","security-sanitize-on-input"]);let Vt=Xt;class Ko{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(t,e){this.pluginRegistry.set(t,e)}async load(t,e){if(this.loadedPlugins.has(t))return this.loadedPlugins.get(t);const o=this.pluginRegistry.get(t);if(!o)return console.warn(`Plugin not found: ${t}`),null;const i=await o();return e&&this.applyPluginConfig(i,e),this.loadedPlugins.set(t,i),i}async loadMultiple(t,e){return(await Promise.all(t.map(i=>this.load(i,e)))).filter(i=>i!==null)}async parsePluginString(t,e){const o=t.split(/\s+/).filter(Boolean);return this.loadMultiple(o,e)}applyPluginConfig(t,e){t.__pluginConfig=e}unload(t){this.loadedPlugins.delete(t)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(t){return this.loadedPlugins.has(t)}}const di='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}editora-editor[data-loading]{display:block;position:relative;min-height:160px;border:1px solid var(--ui-color-border, #ddd);border-radius:var(--ui-radius, 4px);background:var(--ui-color-surface, #fff)}editora-editor[data-loading]:before{content:"";position:absolute;inset:0 0 auto;height:46px;border-bottom:1px solid var(--ui-color-border, #ddd);border-radius:var(--ui-radius, 4px) var(--ui-radius, 4px) 0 0;background:linear-gradient(90deg,var(--ui-color-surface-alt, #f5f5f5) 0%,color-mix(in srgb,var(--ui-color-surface-alt, #f5f5f5) 70%,var(--ui-color-border, #ddd)) 50%,var(--ui-color-surface-alt, #f5f5f5) 100%);background-size:220% 100%;animation:editora-loading-shimmer 1.2s linear infinite}editora-editor[data-loading]:after{content:"Loading editor…";position:absolute;top:62px;left:16px;font:14px/1.4 var(--ui-font-family, system-ui, sans-serif);color:var(--ui-color-muted, #6b7280)}editora-editor[data-loading]>*{visibility:hidden}@keyframes editora-loading-shimmer{to{background-position:-220% 0}}@media(prefers-reduced-motion:reduce){editora-editor[data-loading]:before{animation:none}}';let qt;const ui="__editoraCommandEditorRoot",pi="__editoraLastCommandButton",ko="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",xo=".rte-content, .editora-content",fi="Rich text editor",hi=new Set(["collaboration"]),Ce=new Set;let Q=null,Ao=!1,we=null,Te=null;function Co(s){if(!(s instanceof HTMLElement))return!1;const t=s;return typeof t.execCommand=="function"&&(t.tagName.toLowerCase()==="editora-editor"||t.classList.contains("editora-editor")||t.hasAttribute("data-editora-editor"))}function mi(s){return s?s.nodeType===Node.ELEMENT_NODE?s:s.parentElement:null}function Lt(s){if(!s)return null;if(Co(s))return s;const t=s.matches(ko)?s:s.closest(ko);return!t||!Co(t)?null:t}function gi(){var i;if(typeof window=="undefined")return null;const s=window[ui];if(s instanceof HTMLElement){const r=Lt(s);if(r)return r;const l=s.matches(xo)?s:s.querySelector(xo);if(l){const c=Lt(l);if(c)return c}}const t=window[pi];if(t instanceof HTMLElement){const r=Lt(t);if(r)return r}const e=document.activeElement;if(e){const r=Lt(e);if(r)return r}const o=(i=window.getSelection)==null?void 0:i.call(window);if(o&&o.rangeCount>0){const r=Lt(mi(o.getRangeAt(0).startContainer));if(r)return r}if(Q&&Q.isConnected)return Q;for(const r of Ce)if(r.isConnected)return r;return null}function bi(){if(typeof window=="undefined"||Ao)return;we=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,Te=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const s=(t,...e)=>{const o=gi();return o?o.execCommand(t,...e):we?we(t,...e):Te?Te(t,...e):!1};window.executeEditorCommand=s,window.execEditorCommand=s,Ao=!0}function yi(){const s="editora-webcomponent-styles";if(!document.getElementById(s)){const t=document.createElement("style");t.id=s,t.textContent=di,document.head.appendChild(t)}}function Yo(){if(!qt){const s=at.__globalPluginLoader;s?qt=s:qt=new Ko}return qt}function Ei(s){const t=Yo();Object.entries(s).forEach(([e,o])=>{t.register(e,o)})}const vi=typeof HTMLElement=="undefined"?class{}:HTMLElement;class at extends vi{constructor(){if(super(),this.pluginLoader=Yo(),this.config={},this.isInitialized=!1,this.buildGeneration=0,this.keyboardShortcutManager=new _o,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,this.pendingHistorySnapshot=null,yi(),!this.hasAttribute("data-initial-content")){const t=this.innerHTML.trim();t&&this.setAttribute("data-initial-content",t)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","aria-label","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(at.__globalPluginLoader){this.pluginLoader=at.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{at.__globalPluginLoader?(this.pluginLoader=at.__globalPluginLoader,t()):setTimeout(e,0)};e()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(t,e,o){e!==o&&(this.config=this.resolveConfig(),this.handleAttributeChange(t,o))}async setConfig(t){this.jsConfig=t,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var r;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;const t=++this.buildGeneration;this.setAttribute("data-editora-editor","true"),Ce.add(this),Q||(Q=this),bi(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`),this.setAttribute("data-loading","true"),this.setAttribute("aria-busy","true");const e=await this.loadPlugins();if(t!==this.buildGeneration||!this.isConnected)return;if(this.loadedPlugins=e,e.forEach(l=>{if(l.init&&typeof l.init=="function")try{l.init({editorElement:this})}catch(c){console.error(`[RichTextEditor] Error initializing plugin ${l.name}:`,c)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const l=this.innerHTML.trim();l&&this.setAttribute("data-initial-content",l)}const o=this.preservedContent;this.preservedContent=null;const i=this.sanitizeLoadedContent((r=o!=null?o:this.restoreAutosavedContent())!=null?r:this.getAttribute("data-initial-content")||"");this.engine=new Mo({content:i,plugins:e,readonly:this.config.readonly}),this.createUI(e,i),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.removeAttribute("data-loading"),this.removeAttribute("aria-busy"),this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const t=this.querySelector("[slot]");return t?t.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(o=>o.nodeType===Node.TEXT_NODE?o.textContent:o.nodeType===Node.ELEMENT_NODE?o.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const t=[],e=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(e){if(typeof this.config.plugins=="string"){const r=this.config.plugins.split(/\s+/).filter(Boolean);i&&!r.includes("a11yChecker")&&r.push("a11yChecker");for(const l of r){const c=await this.pluginLoader.load(l,this.getPluginLoadConfig(l));c&&t.push(c)}}else if(Array.isArray(this.config.plugins)){for(const r of this.config.plugins)if(typeof r=="string"){const l=await this.pluginLoader.load(r,this.getPluginLoadConfig(r));l&&t.push(l)}else t.push(r);if(i&&!t.some(r=>(r==null?void 0:r.name)==="a11yChecker")){const r=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));r&&t.push(r)}}}else{const r=this.pluginLoader.getRegisteredPluginNames();for(const l of r){const c=this.getPluginLoadConfig(l);if(hi.has(l)&&!c)continue;const p=await this.pluginLoader.load(l,c);p&&t.push(p)}}return t}resolveToolbarItems(){const t=this.config.toolbarItems;if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");const e=this.config.toolbar;if(typeof e=="string")return e;if(!e||typeof e!="object")return;const o=e.items;if(typeof o=="string")return o;if(Array.isArray(o))return o.join(" ")}isToolbarStickyEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.sticky}isToolbarFloatingEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.floating}isStatusbarEnabled(){const t=this.config.statusbar;return typeof t=="boolean"?t:t&&typeof t=="object"?t.enabled!==!1:!1}getStatusbarPosition(){const t=this.config.statusbar;return t&&typeof t=="object"&&t.position==="top"?"top":"bottom"}getLanguageConfig(){const t=this.config.language;return typeof t=="string"?{locale:t,direction:"ltr"}:t&&typeof t=="object"?{locale:t.locale||"en",direction:t.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const t=this.config.accessibility;return typeof t=="boolean"?{enableARIA:t,keyboardNavigation:t,checker:!1}:t&&typeof t=="object"?{enableARIA:t.enableARIA!==!1,keyboardNavigation:t.keyboardNavigation!==!1,checker:!!t.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var e;const t=this.config.performance;if(typeof t=="boolean")return{debounceInputMs:100,viewportOnlyScan:t};if(t&&typeof t=="object"){const o=Number((e=t.debounceInputMs)!=null?e:100);return{debounceInputMs:Number.isFinite(o)&&o>=0?o:100,viewportOnlyScan:t.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const t=this.contentElement.getBoundingClientRect();return t.bottom>=0&&t.top<=window.innerHeight}applyAccessibilitySettings(){var e;if(!this.contentElement)return;const t=this.getAccessibilityConfig();if(t.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const o=(e=this.getAttribute("aria-label"))==null?void 0:e.trim(),i=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",o||i||fi)}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=t.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const t=this.getLanguageConfig();this.contentElement.setAttribute("lang",t.locale),this.contentElement.setAttribute("dir",t.direction)}getSpellcheckConfig(){const t=this.config.spellcheck;if(typeof t=="boolean")return{enabled:t,provider:"browser"};if(t&&typeof t=="object"){const e=t.provider||"browser";return{enabled:!!t.enabled,provider:e,mode:t.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const t=this.getSpellcheckConfig(),e=t.enabled&&t.provider==="browser";this.contentElement.spellcheck=e,this.contentElement.setAttribute("spellcheck",e?"true":"false")}executeCommand(t,...e){var r;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(l=>l.commands&&l.commands[t]);if(i&&i.commands){const l=i.commands[t];if(typeof l=="function")try{return t==="toggleFullscreen"?l(this,o):l(...e,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${t}:`,c),!1}}return((r=this.engine)==null?void 0:r.execCommand(t,...e))||!1}getPluginLoadConfig(t){const e=this.config.pluginConfig;if(e&&typeof e=="object"){const r=e[t];if(r&&typeof r=="object")return r}const o={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[t,t.toLowerCase(),...o[t]||[]];for(const r of i){const l=this.config[r];if(l&&typeof l=="object"&&!Array.isArray(l))return l}}getContentSanitizeConfig(){const t=this.config.contentConfig;return t&&typeof t=="object"?t:{sanitize:!0}}getSecurityConfig(){const t=this.config.security;return t&&typeof t=="object"?t:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(t){return Ae(t,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var e,o;const t=this.config.autosave;if(typeof t=="boolean")return{enabled:t,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(t&&typeof t=="object"){const i=Number((o=(e=t.intervalMs)!=null?e:t.interval)!=null?o:3e4);return{enabled:!!t.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(t.storageKey||"rte-autosave"),provider:t.provider||"localStorage",apiUrl:t.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(t){const e=this.getAutosaveConfig();if(e.enabled&&t!==this.lastAutosavedContent){if(this.lastAutosavedContent=t,e.provider==="localStorage"){try{localStorage.setItem(e.storageKey,t),localStorage.setItem(`${e.storageKey}-timestamp`,Date.now().toString())}catch(o){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",o)}return}e.provider==="api"&&e.apiUrl&&fetch(e.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,timestamp:Date.now()})}).catch(o=>{console.error("[RichTextEditor] Failed to save autosave content to API:",o)})}}restoreAutosavedContent(){const t=this.getAutosaveConfig();if(!t.enabled||t.provider!=="localStorage")return null;try{const e=localStorage.getItem(t.storageKey);if(e)return this.lastAutosavedContent=e,e}catch(e){console.error("[RichTextEditor] Failed to restore autosaved content:",e)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const t=this.getAutosaveConfig();!t.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(Et(this.contentElement))},t.intervalMs))}insertHTMLAtSelection(t){if(!this.contentElement)return;const e=window.getSelection();if(e&&e.rangeCount>0){const o=e.getRangeAt(0);o.deleteContents();const i=document.createElement("div");i.innerHTML=t;const r=document.createDocumentFragment();for(;i.firstChild;)r.appendChild(i.firstChild);o.insertNode(r),o.collapse(!1),e.removeAllRanges(),e.addRange(o)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,t)}createUI(t,e){const o=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!o?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Io({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((r,l)=>{var c;if(this.contentElement){this.contentElement.focus();const p=window.getSelection();if(!p||p.rangeCount===0||!this.contentElement.contains(p.anchorNode)){const m=document.createRange(),g=this.contentElement.lastChild||this.contentElement;g.nodeType===Node.TEXT_NODE?m.setStart(g,((c=g.textContent)==null?void 0:c.length)||0):g.nodeType===Node.ELEMENT_NODE?(m.selectNodeContents(g),m.collapse(!1)):m.setStart(this.contentElement,0),m.collapse(!0),p==null||p.removeAllRanges(),p==null||p.addRange(m)}}return this.executeCommand(r,l)}),this.toolbar.render(this.toolbarElement)):o&&this.appendChild(o),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(r){console.warn("defaultParagraphSeparator not supported:",r)}if(e){const r=document.createElement("div");r.innerHTML=e.trim(),!Array.from(r.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const p=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(p)}return!1})&&e.trim()?this.contentElement.innerHTML=`<p>${e.trim()}</p>`:this.contentElement.innerHTML=e}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Oo({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Do({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var r;return(r=this.contentElement)==null?void 0:r.focus()},0)}recordInputHistory(t){const e=this.pendingHistorySnapshot;if(this.pendingHistorySnapshot=null,!e||!this.contentElement||e.beforeHTML===t)return;const o=window.execEditorCommand;typeof o=="function"&&o("recordDomTransaction",this.contentElement,e.beforeHTML,t,{inputType:e.inputType,data:e.data,selectionCollapsed:e.selectionCollapsed})}setupEventListeners(){if(!this.contentElement||!this.engine)return;const t=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",o=>{var i,r;this.lastBeforeInputType=o.inputType||null,o.inputType==="historyUndo"||o.inputType==="historyRedo"?this.pendingHistorySnapshot=null:this.contentElement&&(this.pendingHistorySnapshot={beforeHTML:this.contentElement.innerHTML,inputType:o.inputType||null,data:typeof o.data=="string"?o.data:null,selectionCollapsed:(r=(i=window.getSelection())==null?void 0:i.isCollapsed)!=null?r:!0})}),this.contentElement.addEventListener("input",o=>{var T;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const r=(T=o==null?void 0:o.detail)==null?void 0:T.allowedTags,l=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),p=this.getSecurityConfig(),m=this.lastBeforeInputType;if(this.lastBeforeInputType=null,p.sanitizeOnInput!==!1&&c.sanitize!==!1&&!m){const v=Ae(i,c,p,r);if(v!==i){const k=window.getSelection(),tt=k&&k.rangeCount>0?k.getRangeAt(0):null;if(this.contentElement.innerHTML=v,tt&&k)try{k.removeAllRanges(),k.addRange(tt)}catch($){}i=v}}this.recordInputHistory(i),this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const w=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:_e(i)},bubbles:!0}))};l.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(w,l.debounceInputMs):w(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var g,w;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const i=this.config.paste||{};let r=((g=o.clipboardData)==null?void 0:g.getData("text/html"))||"";const l=((w=o.clipboardData)==null?void 0:w.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),p=this.getSecurityConfig(),m=!!r&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(r);if((i.clean||!i.keepFormatting)&&l){document.execCommand("insertText",!1,l);return}if(i.convertWord===!1&&m&&l){document.execCommand("insertText",!1,l);return}if(r){p.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(r=Go(r,c,p)),this.insertHTMLAtSelection(r);return}l&&document.execCommand("insertText",!1,l)}),this.contentElement.addEventListener("focus",()=>{Q=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:Et(this.contentElement)},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",o=>{this.getAccessibilityConfig().keyboardNavigation&&t.handleKeyDown(o,(r,l)=>{this.executeCommand(r,l)})});const e=()=>{const o=this.getSelectionRangeInEditor(),i=document.activeElement,r=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!r||!o&&!r||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=e,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0),o=e.commonAncestorContainer;return this.contentElement.contains(o)?e:null}isSelectionBackward(t){if(!t.anchorNode||!t.focusNode)return!1;try{const e=document.createRange();return e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset),e.collapsed}catch(e){return!1}}getSelectionAnchorRect(t,e){const o=Array.from(e.getClientRects()).filter(r=>r.width>0||r.height>0);return o.length===0?e.getBoundingClientRect():this.isSelectionBackward(t)?o[0]:o[o.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const e=this.getPerformanceConfig(),o=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!o){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const r=window.getSelection();if(!r){this.floatingToolbar.hide();return}const l=this.getSelectionAnchorRect(r,i);if(!l){this.floatingToolbar.hide();return}this.floatingToolbar.show(l.left,l.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const t=this.getPerformanceConfig(),e=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!e)return;const o=this.contentElement.textContent||"",{words:i,chars:r}=zo(o),l=Po(this.contentElement);let c,p;const m=this.getSelectionRangeInEditor();m&&(c=Ro(this.contentElement,m),m.collapsed||(p=Ho(m,c),c=void 0)),this.statusBar.update({wordCount:i,charCount:r,lineCount:l,cursorPosition:c,selectionInfo:p})}isReadonlyAttribute(t){return t!==null&&t!=="false"}handleAttributeChange(t,e){switch(t){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(e)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(e));break;case"theme":this.classList.forEach(o=>{o.startsWith("editora-theme-")&&this.classList.remove(o)}),e&&this.classList.add(`editora-theme-${e}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",e),this.applyAccessibilitySettings());break;case"aria-label":case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(o=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",o)})}));break}}resolveConfig(){const t={};for(let e=0;e<this.attributes.length;e++){const o=this.attributes[e];t[o.name]=o.value}return Vt.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>Et(this.contentElement),setContent:t=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))},execCommand:(t,e)=>this.executeCommand(t,e),focus:()=>{var t;(t=this.contentElement)==null||t.focus()},blur:()=>{var t;(t=this.contentElement)==null||t.blur()},destroy:()=>{this.destroy()},on:(t,e)=>(this.addEventListener(t,e),()=>this.removeEventListener(t,e)),getConfig:()=>({...this.config}),setReadonly:t=>{this.setAttribute("readonly",t.toString())}}}destroy(){var t,e,o,i;this.buildGeneration+=1,this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=Et(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(t=this.engine)==null||t.destroy(),(e=this.toolbar)==null||e.destroy(),(o=this.floatingToolbar)==null||o.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,Ce.delete(this),Q===this&&(Q=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return Et(this.contentElement)}setContent(t){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))}execCommand(t,...e){return this.executeCommand(t,...e)}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}}exports.CommandRegistry=Lo;exports.ConfigResolver=Vt;exports.EditorEngine=Mo;exports.EditorState=It;exports.FloatingToolbar=Oo;exports.KeyboardShortcutManager=_o;exports.PluginLoader=Ko;exports.PluginManager=Se;exports.RichTextEditorElement=at;exports.Schema=So;exports.StatusBar=Do;exports.ToolbarRenderer=Io;exports.calculateTextStats=zo;exports.countLines=Po;exports.createPluginManager=kn;exports.getCleanEditorHTML=Et;exports.getCursorPosition=Ro;exports.getSelectionInfo=Ho;exports.getTextOffset=No;exports.initWebComponent=Ei;exports.sanitizeHTML=$o;exports.sanitizeInputHTML=Ae;exports.sanitizePastedHTML=Go;exports.stripEditorUiArtifacts=_e;
|
|
12
|
+
//# sourceMappingURL=index-DMk3V5_f.js.map
|