rt-native 1.0.115 → 1.0.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rt-native.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rt-native",
3
- "version": "1.0.115",
3
+ "version": "1.0.116",
4
4
  "description": "rt-native HTML Editor is a free native web component that provides accessibility features and a wide variety of elements and customizations that make it one of the most robust and flexible HTML editors available. It allows the programmer to apply custom .css files to the preview window, so see how the content will be displayed in production. The editor uses embedded .svg Google Font Icons and the shadow DOM to isolate the HTML from inheriting the existing page styles. No frameworks, no build step, no dependencies — drop one script tag into any HTML page and you're done.",
5
5
  "main": "rt-native.js",
6
6
  "exports": {
package/rt-native.js CHANGED
@@ -1,2 +1,2 @@
1
- class t{constructor(t,e,o,i,n){this.id=t,this.shadow_id=e,this.toolbar_id=o,this.styles=i,this.dotNetObjectReference=n,this.init()}init=()=>{this.hydrateShadowTree(),this.Utilities=new r(this.shadowRoot,this.content),this.NodeManager=new o(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new n(this.shadowRoot,this.content,this.Utilities),this.ListProvider=new i(this.shadowRoot,this.content,this.Utilities,this.NodeManager),this.ColorPickers={};const t="rich-text-box-text-color-modal",m="rich-text-box-text-bg-color-modal";this.ColorPickers[t]=new g(this.shadowRoot,this.content,t,this.NodeManager,this.Utilities),this.ColorPickers[m]=new g(this.shadowRoot,this.content,m,this.NodeManager,this.Utilities),this.LinkDialog=new u(this.shadowRoot,this.content,this.Utilities),this.ImageDialog=new b(this.shadowRoot,this.content,this.Utilities),this.UploadImageDialog=new h(this.shadowRoot,this.content,this.Utilities),this.BlockQuoteDialog=new d(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new c(this.shadowRoot,this.content,this.Utilities),this.MediaDialog=new l(this.shadowRoot,this.content,this.Utilities),this.VideoDialog=new a(this.shadowRoot,this.content,this.Utilities),this.TableDialog=new s(this.shadowRoot,this.content,this.Utilities),this.StateManager=new e(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners()};hydrateShadowTree=()=>{const t=document.getElementById(this.shadow_id);this.shadowRoot=t.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=this.styles,this.shadowRoot.appendChild(e),this.contentContainer=document.createElement("div"),this.contentContainer.classList.add("rich-text-box-content-container","rich-text-box-scroll"),this.container=document.createElement("div"),this.container.classList.add("rich-text-box-container","rich-text-box-scroll"),this.content=document.createElement("div"),this.content.setAttribute("id",this.id),this.content.setAttribute("class","rich-text-box-content"),this.content.setAttribute("contenteditable","true"),this.content.setAttribute("role","textbox"),this.content.setAttribute("aria-multiline","true"),this.content.setAttribute("aria-label","Rich text editor"),this.content.setAttribute("aria-readonly","false"),this.content.style.display="block",this.source=document.createElement("textarea"),this.source.setAttribute("id","rich-text-box-source"),this.source.setAttribute("aria-label","HTML source"),this.source.classList.add("rich-text-box-source","rich-text-box-scroll"),this.source.style.display="none",this.source.spellcheck=!1;const o=document.createElement("div");o.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),o.setAttribute("id","rich-text-box-message-bar");const i=document.createElement("span");i.setAttribute("class","rich-text-box-message");const n=document.createElement("button");n.setAttribute("class","rich-text-box-message-close-button"),n.textContent="×",n.onclick=()=>{this.Utilities.closeFadingBar()},o.appendChild(i),o.appendChild(n),this.statusBar=document.createElement("div"),this.statusBar.className="rtb-status-bar",this.statusBar.setAttribute("role","status"),this.statusBar.setAttribute("aria-live","polite"),this.statusBar.setAttribute("aria-atomic","true"),this.statusBar.id="rich-text-box-status-bar",this.statusBar.textContent="0 words · 0 characters";const r=document.getElementById(this.toolbar_id);this.container.appendChild(r),this.contentContainer.appendChild(this.content),this.contentContainer.appendChild(this.source),this.container.appendChild(o),this.container.appendChild(this.contentContainer),this.container.appendChild(this.statusBar),this.shadowRoot.appendChild(this.container)};addEventListeners=()=>{document.addEventListener("selectionchange",t=>{const e=this.Utilities.getSelection();null!==e&&this.clearSettings(e.anchorNode)}),this.content.addEventListener("click",t=>{"A"===t.target.tagName&&(t.preventDefault(),t.stopPropagation())}),this.content.addEventListener("click",t=>{const e=t.target.tagName;if("VIDEO"===e||"SOURCE"===e){t.preventDefault();const o="SOURCE"===e?t.target.closest("video"):t.target;if(o&&o.parentNode===this.content){if(!o.nextSibling){const t=document.createElement("p");t.appendChild(document.createElement("br")),this.content.insertBefore(t,null)}const t=o.nextSibling,e=window.getSelection();if(e&&t){const o=document.createRange(),i=t.firstChild??t;o.setStart(i,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}}},!0),this.content.addEventListener("dblclick",t=>{const e=t.target.tagName;"VIDEO"!==e&&"SOURCE"!==e||t.preventDefault()},!0),this.content.addEventListener("dblclick",t=>{switch(t.target.tagName){case"A":t.preventDefault(),this.openLinkDialog();break;case"IMG":t.preventDefault();const e=this.Utilities.getSelection(),o=document.createRange();o.selectNodeContents(t.target),e.removeAllRanges(),e.addRange(o),t.target.src.startsWith("data")?this.uploadImageDialog():this.openImageDialog();break;case"VIDEO":case"SOURCE":{t.preventDefault();const e="SOURCE"===t.target.tagName?t.target.closest("video"):t.target;if(e){const t=this.Utilities.getSelection(),o=document.createRange();o.selectNode(e),t.removeAllRanges(),t.addRange(o),this.openVideoDialogForElement(e)}else this.openVideoDialog();break}case"BLOCKQUOTE":t.preventDefault(),this.openBlockQuoteDialogForElement(t.target);break;case"PRE":t.preventDefault(),this.openCodeBlockDialogForElement(t.target);break;case"CODE":{const e=t.target.closest("pre");e&&this.content.contains(e)&&(t.preventDefault(),this.openCodeBlockDialogForElement(e));break}default:{const e=t.target.closest("pre");if(e&&this.content.contains(e)){t.preventDefault(),this.openCodeBlockDialogForElement(e);break}const o=t.target.closest("blockquote");o&&this.content.contains(o)&&(t.preventDefault(),this.openBlockQuoteDialogForElement(o));break}}}),this.content.addEventListener("input",t=>{this.updateWordCount();const e=this.Utilities.getSelection(),o=e.getRangeAt(0).startContainer;if(o.nodeType===Node.TEXT_NODE&&"SPAN"===o.parentNode.tagName){const t=o.parentNode,i=t.parentNode;if(this.NodeManager.isFormatElement(i)){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t);const o=document.createRange();o.setStart(i.firstChild,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}}),this.content.addEventListener("keydown",t=>{this.keyEvents(t)}),this.source.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),!0===this.EditMode?this.getHtml():this.getCode()),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar())});this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(t=>{t.addEventListener("mousedown",t=>{t.preventDefault()})})};goBack=()=>{this.StateManager.goBack(),this.NodeManager.refreshUI(),this.updateWordCount()};goForward=()=>{this.StateManager.goForward(),this.NodeManager.refreshUI(),this.updateWordCount()};clearSettings=t=>{this.fontSize=void 0,this.NodeManager.selectButtons(t)};keyEvents=t=>{if(this.NodeManager.createDefaultElement(),!1===this.EditMode)return t.ctrlKey&&"z"===t.key&&t.preventDefault(),void(t.ctrlKey&&"y"===t.key&&t.preventDefault());if("Enter"===t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey){if(this.TableDialog.addRowFromLastCell())return void t.preventDefault();if(this.insertParagraphAfterStructuredBlock())return void t.preventDefault()}if(t.ctrlKey&&"b"===t.key&&(t.preventDefault(),this.bold()),t.ctrlKey&&"i"===t.key&&(t.preventDefault(),this.italic()),t.ctrlKey&&"u"===t.key&&(t.preventDefault(),this.underline()),t.ctrlKey&&"d"===t.key&&(t.preventDefault(),this.strikethrough()),t.ctrlKey&&"c"===t.key&&(t.preventDefault(),this.copy()),t.ctrlKey&&"x"===t.key&&(t.preventDefault(),this.cut()),t.ctrlKey&&"v"===t.key&&(t.preventDefault(),this.paste()),"Delete"===t.key||46===t.keyCode){const e=this.Utilities.getSelection();null!==e&&e.toString().length>0&&(t.preventDefault(),this.delete())}if(t.ctrlKey&&"="===t.key&&(t.preventDefault(),this.subscript()),t.ctrlKey&&t.shiftKey&&"+"===t.key&&(t.preventDefault(),this.superscript()),t.ctrlKey&&"l"===t.key&&(t.preventDefault(),this.alignleft()),t.ctrlKey&&"e"===t.key&&(t.preventDefault(),this.aligncenter()),t.ctrlKey&&"r"===t.key&&(t.preventDefault(),this.alignright()),t.ctrlKey&&"j"===t.key&&(t.preventDefault(),this.alignjustify()),t.ctrlKey&&"a"===t.key&&(t.preventDefault(),this.selectall()),t.ctrlKey&&"z"===t.key&&(t.preventDefault(),this.goBack()),t.ctrlKey&&"y"===t.key&&(t.preventDefault(),this.goForward()),t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),this.toggleView()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&t.shiftKey&&"&"===t.key&&(t.preventDefault(),this.uploadImageDialog()),t.ctrlKey&&t.shiftKey&&"U"===t.key&&(t.preventDefault(),this.unorderedlist()),t.ctrlKey&&t.shiftKey&&"O"===t.key&&(t.preventDefault(),this.orderedlist()),t.ctrlKey&&t.shiftKey&&">"===t.key&&(t.preventDefault(),this.changeFontSize(!0)),t.ctrlKey&&t.shiftKey&&"<"===t.key&&(t.preventDefault(),this.changeFontSize(!1)),t.ctrlKey&&t.shiftKey&&"C"===t.key&&(t.preventDefault(),this.openTextColorDialog()),t.ctrlKey&&t.shiftKey&&"B"===t.key&&(t.preventDefault(),this.openTextBackgroundColorDialog()),t.ctrlKey&&t.shiftKey&&"K"===t.key&&(t.preventDefault(),this.openLinkDialog()),t.ctrlKey&&t.shiftKey&&"*"===t.key&&(t.preventDefault(),this.openCodeBlockDialog()),t.ctrlKey&&t.shiftKey&&"Q"===t.key&&(t.preventDefault(),this.openBlockQuoteDialog()),t.ctrlKey&&t.shiftKey&&"I"===t.key&&(t.preventDefault(),this.openImageDialog()),t.ctrlKey&&t.shiftKey&&"M"===t.key&&(t.preventDefault(),this.openMediaDialog()),t.ctrlKey&&t.shiftKey&&"L"===t.key&&(t.preventDefault(),this.openTableDialog()),t.ctrlKey&&t.shiftKey&&"D"===t.key&&(t.preventDefault(),this.format("none")),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"!"===t.key&&(t.preventDefault(),this.format("h1")),t.ctrlKey&&t.shiftKey&&"@"===t.key&&(t.preventDefault(),this.format("h2")),t.ctrlKey&&t.shiftKey&&"#"===t.key&&(t.preventDefault(),this.format("h3")),t.ctrlKey&&t.shiftKey&&"$"===t.key&&(t.preventDefault(),this.format("h4")),t.ctrlKey&&t.shiftKey&&"%"===t.key&&(t.preventDefault(),this.format("h5")),t.ctrlKey&&t.shiftKey&&"^"===t.key&&(t.preventDefault(),this.format("h6")),t.ctrlKey&&t.shiftKey&&"V"===t.key&&(t.preventDefault(),this.openVideoDialog()),t.ctrlKey&&t.shiftKey&&"H"===t.key&&(t.preventDefault(),this.insertHorizontalRule()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar()),"Backspace"===t.key){const e=this.Utilities.getSelection();if(e&&e.isCollapsed){const o=e.getRangeAt(0),i=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"];let n=e.anchorNode;for(;n&&n!==this.content&&(n.nodeType!==Node.ELEMENT_NODE||!i.includes(n.nodeName));)n=n.parentNode;if(n&&n!==this.content){if((parseFloat(window.getComputedStyle(n).marginLeft)||0)>0){const e=document.createRange();e.setStart(n,0),e.setEnd(o.startContainer,o.startOffset),0===e.toString().length&&(t.preventDefault(),this.decreaseIndent())}}}}if(t.shiftKey&&"Tab"===t.key)t.preventDefault(),this.decreaseIndent();else if("Tab"===t.key){const e=this.Utilities.getSelection();if(null!==e&&null!=e.anchorNode&&e.anchorNode!==this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content)if("TD"===e.anchorNode.parentNode.nodeName)t.preventDefault(),this.TableDialog.tableTab();else t.preventDefault(),this.increaseIndent()}};isBreakable=t=>{let e=!1;switch(t){case"BLOCKQUOTE":case"CODE":case"P":case"SPAN":e=!0}return e};getStructuredBlockFromNode=t=>{if(!t||t===this.content)return null;const e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!e||!this.content.contains(e))return null;const o=e.closest("pre");if(o&&this.content.contains(o))return o;const i=e.closest("blockquote");return i&&this.content.contains(i)?i:null};insertParagraphAfterStructuredBlock=()=>{const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return!1;const e=this.getStructuredBlockFromNode(t.anchorNode);if(!e)return!1;const o=document.createElement("p");o.appendChild(document.createElement("br")),e.nextSibling?e.parentNode.insertBefore(o,e.nextSibling):e.parentNode.appendChild(o);const i=document.createRange();return i.setStart(o,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),this.content.focus(),!0};changeFontSize=t=>{if(void 0===this.fontSize){const t=this.Utilities.getSelection();if(null!==t&&t&&t.rangeCount>0){const e=t.getRangeAt(0),o=window.getComputedStyle(e.commonAncestorContainer.parentElement);this.fontSize=parseFloat(o.fontSize)}}t?this.fontSize+=1:this.fontSize-=1,this.NodeManager.updateNode("size",`${this.fontSize}px`)};openPreview=()=>{this.preview=this.shadowRoot.getElementById(`${this.id}_Preview`);const t=this.shadowRoot.getElementById("rich-text-box-preview");this.preview&&t&&(this.loadPreviewWindow(t),this.addPreviewEventListeners(this.preview),this.preview.showModal(),t.scrollTop=0,t.scrollLeft=0)};addPreviewEventListeners=t=>{t.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.closePreview()),"Escape"===t.key&&(t.preventDefault(),this.closePreview())})};loadPreviewWindow=t=>{const e="block"===this.content.style.display?this.html()||"":this.source.value||"",o=t.shadowRoot||t.attachShadow({mode:"open"});for(;o.firstChild;)o.removeChild(o.firstChild);const i=document.createElement("style");i.textContent=":host{display:block;position:relative;}iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none;}",o.appendChild(i);const n=(this._previewCssUrls||[]).filter(t=>t).map(t=>`<link rel="stylesheet" href="${t.replace(/"/g,"%22")}">`).join(""),r=this._previewCssText?`<style>${this._previewCssText}</style>`:"",s=this._rtbHostElement,l=s?getComputedStyle(s):null,getVar=(t,e)=>(l?l.getPropertyValue(t).trim():"")||e,a=["<style>","html,body{margin:0;}","body{"," padding:20px 24px;",` color:${getVar("--rtb-content-text","#242424")};`,` font-size:${getVar("--rtb-content-size","16px")};`,` font-family:${getVar("--rtb-content-font","Arial, Helvetica, Verdana, sans-serif")};`,` line-height:${getVar("--rtb-content-line-height","1.55")};`,` background-color:${getVar("--rtb-content-bg","#FFF")};`,"}",`blockquote{background:${getVar("--rtb-quote-bg","#f9f9f9")};border-left:${getVar("--rtb-quote-border-width","5px")} solid ${getVar("--rtb-quote-border-color","#ccc")};color:${getVar("--rtb-quote-text",getVar("--rtb-content-text","#242424"))};margin:1.5em 10px;padding:0.5em 10px;}`,`pre{background:${getVar("--rtb-code-bg","#f9f9f9")};border-radius:${getVar("--rtb-code-border-radius","10px")};overflow-x:auto;white-space:pre-wrap;margin:1.5em 10px;padding:0.5em 10px;}`,"table{border-collapse:collapse;}","td,th{border:1px solid #ccc;padding:4px 6px;height:25px;min-width:100px;}","</style>"].join(""),c=document.createElement("iframe");c.srcdoc=["<!DOCTYPE html><html><head>",'<meta charset="UTF-8">',a,n,r,"</head><body>",e,"</body></html>"].join(""),o.appendChild(c),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus(),this.content.focus()};togglePreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!t||!e)return;const o=!t.hasAttribute("data-maximized"),i=[["width","100vw"],["height","100vh"],["max-width","100vw"],["max-height","100vh"],["top","0"],["left","0"],["transform","none"],["border-radius","0"],["resize","none"]];o?(t.setAttribute("data-maximized",""),i.forEach(([e,o])=>t.style.setProperty(e,o))):(t.removeAttribute("data-maximized"),i.forEach(([e])=>t.style.removeProperty(e))),e.setAttribute("aria-label",o?"Restore preview":"Maximize preview"),e.querySelector("svg").innerHTML=o?'<path d="M4.5 1.5V4.5H1.5M7.5 10.5V7.5H10.5M4.5 4.5L1.5 1.5M7.5 7.5L10.5 10.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>':'<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>'};_resetPreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);t&&e&&(t.removeAttribute("data-maximized"),["width","height","max-width","max-height","top","left","transform","border-radius","resize"].forEach(e=>t.style.removeProperty(e)),e.setAttribute("aria-label","Maximize preview"),e.querySelector("svg").innerHTML='<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>')};insertHorizontalRule=()=>{const t=this.Utilities.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);e.deleteContents();let o=e.startContainer;if(o===this.content){const t=this.content.childNodes[e.startOffset]??null,o=document.createElement("hr");return this.content.insertBefore(o,t),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(document.createElement("hr")),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}));const i=document.createElement("hr");o&&o!==this.content&&this.content.contains(o)?this.content.insertBefore(i,o.nextSibling):this.content.appendChild(i),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};toggleStatusBar=()=>{if(!this.statusBar)return;const t="none"===this.statusBar.style.display,e=this.shadowRoot.getElementById("blazing-rich-text-statusbar-button");t?(this.statusBar.style.display="",e&&(e.classList.add("selected"),e.setAttribute("aria-pressed","true")),this.updateWordCount()):(this.statusBar.style.display="none",e&&(e.classList.remove("selected"),e.setAttribute("aria-pressed","false")))};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const t=this.content.innerText||"",e=t.trim(),o=e?e.split(/\s+/).length:0,i=t.replace(/\n/g,"").length;this.statusBar.textContent=`${o} word${1!==o?"s":""} · ${i} character${1!==i?"s":""}`};_syncWordCountVisibility=()=>{const t=!1!==this._rtbHostElement?._visibility?.wordCount;this.statusBar&&(this.statusBar.style.display=t?"":"none")};setReadOnly=t=>{this.content.contentEditable=t?"false":"true",this.content.setAttribute("aria-readonly",t?"true":"false");const e=this.shadowRoot.querySelector(`#${CSS.escape(this.toolbar_id)}`);e&&(e.style.display=t?"none":"")};saveHtml=()=>{const t="block"===this.content.style.display?this.html()||"":this.source.value||"",e=new Blob([t],{type:"text/html"}),o=URL.createObjectURL(e),i=document.createElement("a");i.href=o,i.download=this.createTimestampedHtmlFileName(),i.click(),URL.revokeObjectURL(o)};createTimestampedHtmlFileName=()=>{const t=new Date,pad=t=>String(t).padStart(2,"0");return`html-${[t.getFullYear(),pad(t.getMonth()+1),pad(t.getDate())].join("-")+"_"+[pad(t.getHours()),pad(t.getMinutes()),pad(t.getSeconds())].join("-")}.html`};enablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!0,this.disableButtons()};disablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!1,"block"===this.content.style.display&&this.enableButtons()};format=t=>{this.NodeManager.formatNode(t),this.closeDropdown("blazing-rich-text-format-button-dropdown")};dropdown=t=>{const e=this.shadowRoot.getElementById(t);null!=e&&e.classList.contains("rich-text-box-show")?e.classList.remove("rich-text-box-show"):(this.NodeManager.closeDropdowns(),e.classList.add("rich-text-box-show"))};increaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)};decreaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)};openTextColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),t){const e=this.ColorPickers["rich-text-box-text-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextColor=t=>{this.ColorPickers["rich-text-box-text-color-modal"].selectColor(t)};insertTextColor=()=>{this.ColorPickers["rich-text-box-text-color-modal"].insertColor()};removeTextColor=()=>{this.currentColor=null,this.NodeManager.updateNode("textcolor","None"),this.NodeManager.updateNode("textbgcolor","None")};openTextBackgroundColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),null!==t){const e=this.ColorPickers["rich-text-box-text-bg-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextBackgroundColor=t=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].selectColor(t)};insertTextBackgroundColor=()=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].insertColor()};openTableDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.TableDialog.openTableDialog(t):this.Utilities.showFadingBar("No content selected.")};insertTable=()=>{this.TableDialog.insertTable()};font=t=>{this.NodeManager.updateNode("font",t),this.closeDropdown("blazing-rich-text-font-button-dropdown")};size=t=>{this.clearSettings(),this.NodeManager.updateNode("size",t),this.closeDropdown("blazing-rich-text-size-button-dropdown")};bold=()=>{this.NodeManager.updateNode("bold")};italic=()=>{this.NodeManager.updateNode("italic")};underline=()=>{this.NodeManager.updateNode("underline")};strikethrough=()=>{this.NodeManager.updateNode("line-through")};subscript=()=>{this.NodeManager.updateNode("subscript")};superscript=()=>{this.NodeManager.updateNode("superscript")};alignleft=()=>{this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.NodeManager.updateNode("alignjustify")};copy=()=>{this.ActionOptions.copy(),this.NodeManager.refreshUI()};cut=()=>{this.ActionOptions.cut(),this.NodeManager.refreshUI()};paste=()=>{this.NodeManager.allSelected&&this.delete(),this.ActionOptions.paste(),this.NodeManager.refreshUI()};closeDropdown=t=>{this.shadowRoot.getElementById(t).classList.remove("rich-text-box-show"),this.lockToolbar=!1,this.content.focus()};delete=()=>{const t=this.Utilities.getSelection();null!==t&&(t.deleteFromDocument(),this.NodeManager.refreshUI())};selectall=()=>{const t=document.createRange();t.selectNodeContents(this.content),this.content.focus();const e=this.Utilities.getSelection();null!==e&&(e.removeAllRanges(),e.addRange(t),this.content.focus())};orderedlist=()=>{this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.ListProvider.addlist("UL"),this.NodeManager.refreshUI()};openLinkDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.LinkDialog.openLinkDialog(t):this.Utilities.showFadingBar("No content selected.")};insertLink=()=>{this.LinkDialog.insertLink(),this.NodeManager.refreshUI()};removeLink=()=>{this.LinkDialog.removeLink()};openBlockQuoteDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.BlockQuoteDialog.openBlockQuoteDialog(t):this.Utilities.showFadingBar("No content selected.")};openBlockQuoteDialogForElement=t=>{if(!t||"BLOCKQUOTE"!==t.nodeName||!this.content.contains(t))return;this.lockToolbar=!0;const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.selectNodeContents(t),e.removeAllRanges(),e.addRange(o),this.savedSelection=this.Utilities.saveSelection(e),this.BlockQuoteDialog.openBlockQuoteDialogForElement(t,o)};insertBlockQuote=()=>{this.BlockQuoteDialog.insertBlockQuote(),this.NodeManager.refreshUI()};openCodeBlockDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.CodeBlockDialog.openCodeBlockDialog(t):this.Utilities.showFadingBar("No content selected.")};openCodeBlockDialogForElement=t=>{if(!t||"PRE"!==t.nodeName||!this.content.contains(t))return;const e=t.querySelector("code")||t;this.lockToolbar=!0;const o=this.Utilities.getSelection()||window.getSelection(),i=document.createRange();i.selectNodeContents(e),o.removeAllRanges(),o.addRange(i),this.savedSelection=this.Utilities.saveSelection(o),this.CodeBlockDialog.openCodeBlockDialogForElement(t,i)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.MediaDialog.openMediaDialog(t):this.Utilities.showFadingBar("No content selected.")};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.VideoDialog.openVideoDialog(t):this.Utilities.showFadingBar("No content selected.")};openVideoDialogForElement=t=>{this.lockToolbar=!0;const e=this.Utilities.getSelection(),o=this.Utilities.saveSelection(e);this.savedSelection=o,this.VideoDialog.openVideoDialogForElement(t,o)};insertVideo=()=>{this.VideoDialog.insertVideo(),this.NodeManager.refreshUI()};uploadImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.UploadImageDialog.openUploadImageDialog(t):this.Utilities.showFadingBar("No content selected.")};uploadImage=()=>{this.UploadImageDialog.insertUploadedImage()};openImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.ImageDialog.openImageDialog(t):this.Utilities.showFadingBar("No content selected.")};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeDialog=t=>{this.lockToolbar=!1,this.Utilities.closeDialog(t,this.savedSelection)};enableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!1);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!1)};disableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!0);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!0)};toggleView=()=>{!0===this.EditMode?this.getHtml():this.getCode()};getHtml=async()=>{this.htmlSelection=this.StateManager.saveSelection(),this.contentScroll=this.Utilities.saveScroll(this.contentContainer),this.statusBar&&(this._statusBarWasVisible="none"!==this.statusBar.style.display,this.statusBar.style.display="none");const t=this.html();this.loadInnerText(t),this.content.style.display="none",this.source.style.display="block",this.source.focus(),this.Utilities.restoreScroll(this.source,this.sourceScroll),this.disableButtons()};getCode=async()=>{this.sourceScroll=this.Utilities.saveScroll(this.source);const t=this.source.value;this.loadHtml(t),this.content.style.display="block",this.source.style.display="none",this.content.focus(),this.StateManager.restoreSelection(this.htmlSelection),this.Utilities.restoreScroll(this.contentContainer,this.contentScroll),this.enableButtons(),this.statusBar&&this._statusBarWasVisible&&(this.statusBar.style.display="",this.updateWordCount())};html=()=>(this.NodeManager.removeEmptyNodes(),this.content.innerHTML);loadView=t=>{!0===this.EditMode?this.loadHtml(t):this.loadInnerText(t)};loadHtml=t=>{this.EditMode=!0;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.remove("selected"),e.setAttribute("aria-pressed","false")),this.content.innerHTML=null!=t?t:"",this.NodeManager.clearButtons(),this.updateWordCount()};loadInnerText=t=>{this.EditMode=!1;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.add("selected"),e.setAttribute("aria-pressed","true")),this.source.value=null!=t?t:"",this.NodeManager.clearButtons()};plaintext=()=>this.content.textContent}class e{constructor(t,e,o,i,n){this.content=t,this.source=e,this.Utilities=o,this.dotNetObjectReference=i,this.contentContainer=n,this.history=[],this.currentIndex=-1,this.currentIndex=-1,this.isNavigating=!1,this.mutationObserver()}mutationObserver=()=>{new MutationObserver((t,e)=>{if("block"!==this.content.style.display||this.isNavigating)this.isNavigating=!1,this.updateBinding();else for(let e of t)switch(e.type){case"attributes":case"characterData":case"subtree":case"childList":this.saveState()}}).observe(this.content,{attributes:!0,childList:!0,subtree:!0,characterData:!0})};updateBinding=()=>{"block"===this.content.style.display?this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.content.innerHTML):this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.source.value)};saveState=()=>{if(this.PreviousHtml===this.content.innerHTML)return;const t={html:this.content.innerHTML,selection:this.saveSelection(),scroll:this.Utilities.saveScroll(this.contentContainer)};this.PreviousHtml=this.content.innerHTML,-1!==this.currentIndex&&t===this.history[this.currentIndex]||(this.history=this.history.slice(0,this.currentIndex+1),this.history.push(t),this.currentIndex++,this.history.length>60&&(this.history.shift(),this.currentIndex--),this.updateBinding())};restoreLastState=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.restoreState(this.history[this.currentIndex]))};goBack=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.currentIndex--,this.restoreState(this.history[this.currentIndex]))};goForward=()=>{this.currentIndex<this.history.length-1&&(this.isNavigating=!0,this.currentIndex++,this.restoreState(this.history[this.currentIndex]))};saveSelection=()=>{const t=this.Utilities.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),o=e.cloneRange();o.selectNodeContents(this.content),o.setEnd(e.startContainer,e.startOffset);const i=o.toString().length;return{start:i,end:i+e.toString().length}}return null};restoreSelection=t=>{if(t)try{const charIndex=(t,e)=>{let o=0;if(t.nodeType===Node.TEXT_NODE)return e<=t.length?[t,e]:[null,e-t.length];for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i],[r,s]=charIndex(n,e-o);if(r)return[r,s];o+=n.textContent.length}return[null,e-o]},e=document.createRange();let[o,i]=charIndex(this.content,t.start),[n,r]=charIndex(this.content,t.end);if(o&&n){e.setStart(o,i),e.setEnd(n,r);const t=window.getSelection();t.removeAllRanges(),t.addRange(e)}}catch(t){}};restoreState=t=>{this.content.innerHTML=t.html,this.restoreSelection(t.selection),this.Utilities.restoreScroll(this.contentContainer,t.scroll),this.content.focus()}}class o{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o}_press=(t,e=!0)=>{t&&(t.classList.toggle("selected",e),t.setAttribute("aria-pressed",e?"true":"false"))};formatNode=t=>{let e,o;if(e=this.Utilities.getSelection(),null!==e){let i;if(0==e.toString().length)null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&this.content.contains(e.anchorNode.parentNode)&&(i=this.getElementByType(e.anchorNode.parentNode,"Format"));else if(1==this.hasCommonAncestor(e)){i=e.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else i=this.getElementByContent(e.anchorNode,t,e);if(null!=i&&i!=this.content&&null!=i.parentNode&&this.content.contains(i.parentNode)){if("none"==t){let t=this.Utilities.saveCaretPosition();const e=document.createElement("div");for(let t=0;t<i.style.length;t++){const o=i.style[t];e.style[o]=i.style[o]}for(;i.firstChild;)e.appendChild(i.firstChild);i.parentNode.replaceChild(e,i),this.Utilities.restoreCaretPosition(e,t)}else{let e=this.Utilities.saveCaretPosition();const o=document.createElement(t);o.innerHTML=i.innerHTML;const n=window.getComputedStyle(i);for(let t=0;t<n.length;t++){let e=n[t],r=i.style.getPropertyValue(e);""!==r&&(o.style[e]=r)}i.parentNode.replaceChild(o,i),this.Utilities.restoreCaretPosition(o,e)}return}if(e.toString().length>0){let i;switch(t){case"p":i=document.createElement("p");break;case"h1":i=document.createElement("h1");break;case"h2":i=document.createElement("h2");break;case"h3":i=document.createElement("h3");break;case"h4":i=document.createElement("h4");break;case"h5":i=document.createElement("h5")}null!=i&&e.rangeCount>0&&(o=e.getRangeAt(0),this.hasInvalidElementsInSelection(e)||(i.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(i),o.selectNodeContents(i),e.removeAllRanges(),e.addRange(o)))}}};updateNode=(t,e,o)=>{let i,n;if(i=this.Utilities.getSelection(),i||o){let r;if(i&&o?(i.removeAllRanges(),i.addRange(o)):o&&(i=window.getSelection(),i.removeAllRanges(),i.addRange(o)),this.isCommonAncestor=!1,0==i.toString().length){if(r=this.getElementByStyle(i.anchorNode,t),null==r&&null!=i.anchorNode&&i.anchorNode!=this.content&&this.content.contains(i.anchorNode)&&i.anchorNode.querySelector){null!=i.anchorNode.querySelector("img")&&(r=i.anchorNode);null!=i.anchorNode.querySelector("embed")&&(r=i.anchorNode);null!=i.anchorNode.querySelector("object")&&(r=i.anchorNode);const t=i.anchorNode.querySelector("table");null!=t&&(r=t)}null==r&&null!=i.anchorNode&&i.anchorNode!=this.content&&null!=i.anchorNode.parentNode&&i.anchorNode.parentNode!=this.content&&this.content.contains(i.anchorNode.parentNode)&&(r=i.anchorNode.parentNode)}else if(1==this.hasCommonAncestor(i)){r=i.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else r=this.getElementByContent(i.anchorNode,t,i);if(null!=r){let o;switch(t){case"textcolor":"None"==e?(o=this.getElementByStyle(r,t),null!=o&&this.removeProperty(o,"color",o.style.getPropertyValue("color"))):r.style.setProperty("color",e);break;case"textbgcolor":"None"==e?(o=this.getElementByStyle(r,t),null!=o&&this.removeProperty(o,"background-color",o.style.getPropertyValue("background-color"))):r.style.setProperty("background-color",e);break;case"font":"None"==e?this.removeProperty(r,"font-family",e):r.style.setProperty("font-family",e);break;case"size":"None"==e?this.removeProperty(r,"font-size"):r.style.setProperty("font-size",e);break;case"bold":"bold"==r.style.fontWeight?this.removeProperty(r,"font-weight","bold"):r.style.setProperty("font-weight","bold");break;case"italic":"italic"==r.style.fontStyle?this.removeProperty(r,"font-style","italic"):r.style.setProperty("font-style","italic");break;case"underline":r.style.textDecoration.includes("underline")?this.removeTextDecoration(r,"underline"):this.addTextDecoration(r,"underline");break;case"line-through":r.style.textDecoration.includes("line-through")?this.removeTextDecoration(r,"line-through"):this.addTextDecoration(r,"line-through");break;case"subscript":"sub"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","sub"):r.style.setProperty("vertical-align","sub");break;case"superscript":"super"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","super"):r.style.setProperty("vertical-align","super");break;case"alignleft":"TABLE"===r.nodeName?this.alignTable(r,"alignleft"):"left"==r.style.textAlign?this.removeProperty(r,"text-align","left"):r.style.setProperty("text-align","left");break;case"aligncenter":"TABLE"===r.nodeName?this.alignTable(r,"aligncenter"):"center"==r.style.textAlign?this.removeProperty(r,"text-align","center"):r.style.setProperty("text-align","center");break;case"alignright":"TABLE"===r.nodeName?this.alignTable(r,"alignright"):"right"==r.style.textAlign?this.removeProperty(r,"text-align","right"):r.style.setProperty("text-align","right");break;case"alignjustify":"TABLE"===r.nodeName?this.alignTable(r,"alignjustify"):"justify"==r.style.textAlign?this.removeProperty(r,"text-align","justify"):r.style.setProperty("text-align","justify")}return this.selection=null,void this.refreshUI()}if(i.toString().length>0&&"None"!=e&&!this.isExcluded(i)){let o;switch(t){case"textcolor":o=this.createElement(i),o.style.color=e;break;case"textbgcolor":o=this.createElement(i),o.style.backgroundColor=e;break;case"font":o=this.createElement(i),o.style.fontFamily=e;break;case"size":o=this.createElement(i),o.style.fontSize=e;break;case"bold":o=this.createElement(i),o.style.fontWeight="bold";break;case"italic":o=this.createElement(i),o.style.fontStyle="italic";break;case"underline":o=this.createElement(i),this.addTextDecoration(o,"underline");break;case"line-through":o=this.createElement(i),this.addTextDecoration(o,"line-through");break;case"subscript":o=this.createElement(i),o.style.verticalAlign="sub";break;case"superscript":o=this.createElement(i),o.style.verticalAlign="super";break;case"alignleft":o=document.createElement("div"),o.style.textAlign="left";break;case"aligncenter":o=document.createElement("div"),o.style.textAlign="center";break;case"alignright":o=document.createElement("div"),o.style.textAlign="right";break;case"alignjustify":o=document.createElement("div"),o.style.textAlign="justify"}null!=o&&0!=i.rangeCount&&(n=i.getRangeAt(0),o.appendChild(n.cloneContents()),n.deleteContents(),n.insertNode(o),n.selectNodeContents(o),i.removeAllRanges(),i.addRange(n),this.selection=null,this.refreshUI())}}};alignTable=(t,e)=>{"alignleft"!==e&&"alignjustify"!==e||("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft&&this.removeProperty(t,"margin-left","auto")),"aligncenter"===e&&(t.style.margin&&"auto"===t.style.margin?this.removeProperty(t,"margin","auto"):t.style.setProperty("margin","auto")),"alignright"===e&&("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft?this.removeProperty(t,"margin-left","auto"):t.style.setProperty("margin-left","auto"))};isExcluded=t=>{if(t.anchorNode&&t.anchorNode.querySelector){const e=t.anchorNode.querySelector("table");if(null!=e&&t.toString().trim()!==e.innerText.trim())return!0}if(t.anchorNode.parentNode!==this.content)switch(t.anchorNode.parentNode.nodeName){case"TD":case"CODE":case"PRE":return!0}return!1};indentBlock=(t,e)=>{let o=t.anchorNode;for(;o&&!this.applyMargin(o,e);)o=o.parentNode};applyMargin=(t,e)=>{if(t.nodeType===Node.ELEMENT_NODE&&["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"].includes(t.nodeName)){const o=window.getComputedStyle(t).marginLeft,i=parseFloat(o)||0,n=40;return e?t.style.marginLeft=`${i+n}px`:i<=n?(t.style.marginLeft="",t.hasAttribute("style")&&(t.getAttribute("style")||t.removeAttribute("style"))):t.style.marginLeft=i-n+"px",!0}return!1};selectButtons=t=>{if(null==t||t==this.content||!this.content.contains(t)||1==this.lockToolbar)return;this.clearButtons();const e=this.getButton("blazing-rich-text-bold-button"),o=this.getButton("blazing-rich-text-italic-button"),i=this.getButton("blazing-rich-text-underline-button"),n=this.getButton("blazing-rich-text-strike-button"),r=this.getButton("blazing-rich-text-sub-button"),s=this.getButton("blazing-rich-text-super-button"),l=this.getButton("blazing-rich-text-alignleft-button"),a=this.getButton("blazing-rich-text-aligncenter-button"),c=this.getButton("blazing-rich-text-alignright-button"),d=this.getButton("blazing-rich-text-alignjustify-button");this.textAlign=!1;const h=this.getButton("blazing-rich-text-orderedlist-button"),b=this.getButton("blazing-rich-text-unorderedlist-button"),u=this.getButton("blazing-rich-text-link-button"),g=this.getButton("blazing-rich-text-remove-link-button"),m=this.getButton("blazing-rich-text-textcolor-button"),x=this.getButton("blazing-rich-text-text-bg-color-button"),p=this.getButton("blazing-rich-text-textcolor-remove-button"),v=this.getButton("blazing-rich-text-quote-button"),f=this.getButton("blazing-rich-text-code-block-button"),y=this.getButton("blazing-rich-text-table-button"),w=this.getButton("blazing-rich-text-image-button"),C=this.getButton("blazing-rich-text-image-upload-button"),N=this.getButton("blazing-rich-text-embed-button"),k=this.getButton("blazing-rich-text-video-button"),S=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=S&&(S.innerText="Format",this.formatSelected=!1);const E=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=E&&(E.innerText="Font",this.fontSelected=!1);const R=this.shadowRoot.getElementById("blazing-rich-text-size-button");for(null!=R&&(R.innerText="Size",this.fontSizeSelected=!1);t!==this.content&&null!==t.parentNode&&this.content.contains(t.parentNode)&&"#text"!=t.parentNode.nodeName&&"#document"!=t.parentNode.nodeName;){let T=window.getComputedStyle(t.parentNode);if(null!=t.parentNode.style&&"bold"==t.parentNode.style.fontWeight&&this._press(e),null!=t.parentNode.style&&t.parentNode.style.color&&this._press(m),null!=t.parentNode.style&&t.parentNode.style.backgroundColor&&this._press(x),(null!=t.parentNode.style&&t.parentNode.style.color||t.parentNode.style.backgroundColor)&&this._press(p),"italic"==T.getPropertyValue("font-style")&&this._press(o),T.getPropertyValue("text-decoration").includes("underline")&&"A"!=t.parentNode.nodeName&&this._press(i),T.getPropertyValue("text-decoration").includes("line-through")&&this._press(n),"sub"==T.getPropertyValue("vertical-align")&&this._press(r),"super"==T.getPropertyValue("vertical-align")&&this._press(s),"left"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(l),this.textAlign=!0),"center"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),"right"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),"justify"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),null!=t&&null!=t.style&&t.style.fontFamily&&!this.fontSelected&&(E.innerText=t.style.fontFamily.replace(/^"(.*)"$/,"$1"),this.fontSelected=!0),null!=t&&null!=t.style&&t.style.fontSize&&!this.fontSizeSelected&&(R.innerText=t.style.fontSize,this.fontSizeSelected=!0),"P"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Paragraph",this.formatSelected=!0),"H1"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 1",this.formatSelected=!0),"H2"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 2",this.formatSelected=!0),"H3"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 3",this.formatSelected=!0),"H4"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 4",this.formatSelected=!0),"H5"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 5",this.formatSelected=!0),"A"==t.parentNode.nodeName&&(this._press(u),this._press(g)),"BLOCKQUOTE"==t.parentNode.nodeName&&this._press(v),"CODE"==t.parentNode.nodeName&&this._press(f),"TD"==t.parentNode.nodeName&&this._press(y),"OL"==t.parentNode.nodeName&&this._press(h),"UL"==t.parentNode.nodeName&&this._press(b),"VIDEO"!==t.nodeName&&"SOURCE"!==t.nodeName||k&&this._press(k),t.querySelector){const e=t.querySelector("img");e&&(e.src.startsWith("data")?this._press(C):this._press(w));t.querySelector("object")&&this._press(N);t.querySelector("video")&&k&&this._press(k)}t=t.parentNode}this.closeDropdowns()};closeDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(function(t){t.classList.contains("rich-text-box-show")&&t.classList.remove("rich-text-box-show")})};getButton=t=>this.shadowRoot.getElementById(t);refreshUI=()=>{const t=this.Utilities.getSelection();null!==t&&this.selectButtons(t.anchorNode),this.removeEmptyNodes(),this.content.focus()};removeEmptyNodes=()=>{const t=this.content;if(t){t.querySelectorAll("*").forEach(t=>{t.hasChildNodes()&&(1!==t.childNodes.length||3!==t.childNodes[0].nodeType||/\S/.test(t.textContent))||t.parentElement&&!this.isNotRemovable(t.nodeName)&&t.parentElement.removeChild(t)})}};createDefaultElement=()=>{if(""===this.content.innerHTML.trim()){const t=document.createElement("div"),e=document.createElement("br");t.appendChild(e),this.content.appendChild(t)}};allSelected=()=>{const t=this.Utilities.getSelection();if(null!==t){if(0===t.rangeCount)return!1;const e=t.getRangeAt(0),o=document.createRange();return o.selectNodeContents(this.content),e.startContainer===o.startContainer&&e.startOffset===o.startOffset&&e.endContainer===o.endContainer&&e.endOffset===o.endOffset}return!1};clearButtons=()=>{this.closeDropdowns();this.shadowRoot.querySelectorAll(".rich-text-box-menu-item, .rich-text-box-menu-item-special").forEach(function(t){t.classList.remove("selected"),t.setAttribute("aria-pressed","false")});const t=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=t&&(t.innerText="Format",this.formatSelected=!1);const e=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=e&&(e.innerText="Font",this.fontSelected=!1);const o=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=o&&(o.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=t=>{switch(t.toLowerCase()){case"td":case"img":case"i":case"br":case"area":case"base":case"col":case"embed":case"object":case"video":case"source":case"hr":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":case"keygen":return!0}return!1};hasCommonAncestor(t){if(!t.rangeCount)return!1;const e=t.getRangeAt(0),o=e.cloneContents(),i=document.createElement("div");i.appendChild(o);const n=e.commonAncestorContainer;return n!==this.content&&this.content.contains(n)&&i.innerHTML==e.commonAncestorContainer.innerHTML&&n.nodeType!==Node.TEXT_NODE?(i.remove(),!0):(i.remove(),!1)}createElement=t=>this.hasInvalidElementsInSelection(t)?document.createElement("div"):document.createElement("span");hasInvalidElementsInSelection=t=>{if(t){const e=["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","header","hgroup","hr","main","menu","nav","ol","p","pre","section","table","ul","button","input","textarea","select","form","h1","h2","h3","h4","h5","h6"],o=t.getRangeAt(0).cloneContents().querySelectorAll("*");for(let t=0;t<o.length;t++){const i=o[t];if(e.includes(i.tagName.toLowerCase()))return!0}}return!1};removeProperty=(t,e,o)=>{null!=t&&t!=this.content&&this.content.contains(t)&&(this.getUserDefinedStyleCount(t)>1?t.style.removeProperty(e,o):"SPAN"==t.nodeName?0==t.childElementCount?t.replaceWith(t.textContent):(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):"DIV"==t.nodeName&&!0===this.isCommonAncestor?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style"))};addTextDecoration=(t,e)=>{if(null==t||t==this.content||t==this.content.parentNode)return;const o=t.style.textDecoration;if(null!=o&&!o.includes(e)){const i=o?o+" "+e:e;t.style.textDecoration=i}};removeTextDecoration=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t))if(this.getUserDefinedStyleCount(t)>1){const o=t.style.textDecoration.split(" ").filter(t=>t!==e);t.style.textDecoration=o.join(" ")}else"SPAN"==t.nodeName&0==t.childElementCount?t.replaceWith(t.textContent):"SPAN"==t.nodeName?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style")};getUserDefinedStyles=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e={};for(let o=0;o<t.style.length;o++){let i=t.style[o],n=t.style.getPropertyValue(i);e[i]=n}return e};getUserDefinedStyleCount=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e=0;for(let o=0;o<t.style.length;o++){let i=t.style[o],n=t.style.getPropertyValue(i);if(this.isFormatElement(t)){if("initial"!=n){let t=n.split(" ");if(!this.isMultiValueProperty(i)&&t.length>1)for(let o=0;o<t.length;o++)e++;else e++}}else e++}return e};isMultiValueProperty=t=>{switch(t){case"background-color":case"color":case"font-family":return!0}return!1};getElementByType=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(e){case"Format":if(this.isFormatElement(t))return t;break;case"UL":case"OL":case"Element":if(t.nodeName===e)return t}t=t.parentNode}return null}};getElementByContent=(t,e,o)=>{if(null!=t&&t!=this.content&&this.content.contains(t))for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName){const i=this.getElementByStyle(t,e);if(null!=i&&this.selectionContainsNode(o,i))return i;if("LI"===t.nodeName)return t.parentNode;if(null!==o&&o.toString().trim()==t.textContent.trim())return t}t=t.parentNode}};selectionContainsNode(t,e){if(null==e||e==this.content||!this.content.contains(e))return!1;if(t.rangeCount>0)for(let o=0;o<t.rangeCount;o++){let i=t.getRangeAt(o);if(this.isNodeInRange(e,i))return!0}return!1}isNodeInRange(t,e){if(null==t||t==this.content||!this.content.contains(t))return!1;let o=t.ownerDocument.createRange();return o.selectNode(t),e.compareBoundaryPoints(Range.START_TO_END,o)<=0&&e.compareBoundaryPoints(Range.END_TO_START,o)>=0}getElementByStyle=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if(null!=t.style){let o=null;switch(e){case"textcolor":if(o=t.getAttribute("style"),null!=o&&o.includes("color:"))return t;break;case"textbgcolor":if(o=t.getAttribute("style"),null!=o&&o.includes("background-color:"))return t;break;case"font":if(o=t.getAttribute("style"),null!=o&&o.includes("font-family:"))return t;break;case"size":if(o=t.getAttribute("style"),null!=o&&o.includes("font-size:"))return t;break;case"bold":if(o=t.getAttribute("style"),null!=o&&o.includes("font-weight:")&&"bold"==t.style.fontWeight)return t;break;case"italic":if(o=t.getAttribute("style"),null!=o&&o.includes("font-style:")&&"italic"==t.style.fontStyle)return t;break;case"underline":if(o=t.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&t.style.textDecoration.includes("underline"))return t;break;case"line-through":if(o=t.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&t.style.textDecoration.includes("line-through"))return t;break;case"subscript":if(o=t.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"sub"==t.style.verticalAlign)return t;break;case"superscript":if(o=t.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"superscript"==t.style.verticalAlign)return t;break;case"alignleft":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"left"==t.style.textAlign)return t;break;case"aligncenter":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"center"==t.style.textAlign)return t;break;case"alignright":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"right"==t.style.textAlign)return t;break;case"alignjustify":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"justify"==t.style.textAlign)return t}}t=t.parentNode}return null}};isFormatElement=t=>!(null==t||t==this.content||!this.content.contains(t))&&("P"==t.nodeName||"H1"==t.nodeName||"H2"==t.nodeName||"H3"==t.nodeName||"H4"==t.nodeName||"H5"==t.nodeName||(null!=t.style&&null!=t.style.textDecoration||void 0));insertLineBreak=t=>{const e=document.createElement("div"),o=document.createElement("br");if(e.appendChild(o),"CODE"==t.nodeName){const o=t.parentNode.parentNode;o.nextSibling?o.parentNode.insertBefore(e,o.nextSibling):o.parentNode.appendChild(e)}else t.parentNode.insertBefore(e,t.nextSibling);const i=document.createRange();i.setStartBefore(o),i.collapse(!0);const n=this.Utilities.getSelection();null!==n&&(n.removeAllRanges(),n.addRange(i))}}class i{constructor(t,e,o,i){this.shadowRoot=t,this.content=e,this.Utilities=o,this.NodeManager=i}addlist=t=>{const e=this.Utilities.getSelection();if(null!==e){if("UL"==t){const t=this.NodeManager.getElementByType(e.anchorNode,"OL");if(null!=t)return void this.replaceList(t,"UL")}else{const t=this.NodeManager.getElementByType(e.anchorNode,"UL");if(null!=t)return void this.replaceList(t,"OL")}const o=this.NodeManager.getElementByType(e.anchorNode,t);if(null!=o)this.removelist(o);else{if(0===e.toString().trim().length){const o=e.getRangeAt(0);let i;const n=document.createElement(t);if(e.anchorNode.parentNode!==this.content&&(i=e.anchorNode.parentNode),e.anchorNode!==this.content&&(i=e.anchorNode),i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),e=i.cloneNode(!0);this.appendListItemContent(t,e),n.appendChild(t),i.remove()}o.deleteContents(),o.insertNode(n);const r=document.createRange();r.selectNodeContents(n),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}else{const o=document.createElement(t);if(e.rangeCount>0){const t=e.getRangeAt(0),i=t.cloneContents().childNodes;Array.from(i).forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),i=t.cloneNode(!0);this.appendListItemContent(e,i),o.appendChild(e),t.remove()}}),t.deleteContents(),t.insertNode(o),t.selectNodeContents(o),e.removeAllRanges(),e.addRange(t)}}}}};appendListItemContent=(t,e)=>{if(t&&e)if(this.isParagraphChild(e))for(;e.firstChild;)t.appendChild(e.firstChild);else t.appendChild(e)};replaceList=(t,e)=>{if(null===t||t===this.content||!this.content.contains(t))return;const o=this.Utilities.getSelection();let i,n,r,s,l;null!==o&&o.rangeCount>0&&(i=o.getRangeAt(0),n=i.startContainer,r=i.startOffset,s=i.endContainer,l=i.endOffset);const a=document.createElement(e);for(;t.firstChild;)a.appendChild(t.firstChild);if(t.parentNode.replaceChild(a,t),i){const e=document.createRange();t.contains(n)?e.setStart(a,r):e.setStart(n,r),t.contains(s)?e.setEnd(a,l):e.setEnd(s,l),o.removeAllRanges(),o.addRange(e)}};removelist=t=>{if(null==t||t==this.content||!this.content.contains(t))return;if("OL"===t.nodeName||"UL"===t.nodeName)return void this.removeListAsParagraphs(t);let e=null;for(;t.firstChild;){const o=t.firstChild;if("UL"===o.nodeName||"OL"===o.nodeName)e||(e=o),t.parentNode.insertBefore(o,t);else{for(;o.firstChild;){const i=o.firstChild;e||(e=i),t.parentNode.insertBefore(i,t)}t.removeChild(o)}}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}};removeListAsParagraphs=t=>{let e=null;for(;t.firstChild;){const o=t.firstChild;if("LI"!==o.nodeName){e||(e=o),t.parentNode.insertBefore(o,t);continue}const i=document.createElement("p");for(;o.firstChild;){const t=o.firstChild;if("UL"===t.nodeName||"OL"===t.nodeName)break;if(this.isParagraphChild(t)){for(;t.firstChild;)i.appendChild(t.firstChild);o.removeChild(t)}else i.appendChild(t)}for(i.hasChildNodes()||i.appendChild(document.createElement("br")),e||(e=i),t.parentNode.insertBefore(i,t);o.firstChild;)t.parentNode.insertBefore(o.firstChild,t);t.removeChild(o)}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}};isParagraphChild=t=>!(!t||t.nodeType!==Node.ELEMENT_NODE)&&["P","DIV"].includes(t.nodeName);increaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;let o=this.getSelectedNodes(t,e);if(!o||0===o.length)return;let i=o[0].previousElementSibling;if(!i||"LI"!==i.nodeName)return;let n=Array.from(i.children).find(t=>t.nodeName===e.nodeName);n||(n=document.createElement(e.nodeName),i.appendChild(n)),o.forEach(t=>{"LI"===t.nodeName&&n.appendChild(t)}),this.selectListItemStart(t,o[0])};decreaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;const o=this.getSelectedNodes(t,e);if(!o||0===o.length)return;const i=e.parentElement,n=i?i.parentElement:null;if(!i||"LI"!==i.nodeName||!n||"UL"!==n.nodeName&&"OL"!==n.nodeName)return;const r=o[o.length-1],s=document.createElement(e.nodeName);for(;r.nextElementSibling;)s.appendChild(r.nextElementSibling);const l=document.createDocumentFragment();o.forEach(t=>{"LI"===t.nodeName&&l.appendChild(t)}),n.insertBefore(l,i.nextSibling),s.children.length>0&&r.appendChild(s),0===e.children.length&&e.remove(),this.selectListItemStart(t,o[0])};getSelectedNodes=(t,e)=>{const o=[];if(!t.rangeCount)return null;const i=t.getRangeAt(0);if(null!==e){const t=e.children;for(let e=0;e<t.length;e++){const n=t[e];i.intersectsNode(n)&&o.push(n)}return o}return null};saveListSelection=t=>t&&0!==t.rangeCount?t.getRangeAt(0).cloneRange():null;restoreListSelection=(t,e,o)=>{if(t&&e&&this.content.contains(e.startContainer)&&this.content.contains(e.endContainer))return t.removeAllRanges(),void t.addRange(e);this.selectListItem(t,o)};selectListItemStart=(t,e)=>{if(!t||!e)return;const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)};selectListItem=(t,e)=>{if(!t||!e)return;const o=document.createRange(),i=this.getFirstTextNode(e);i?o.setStart(i,i.textContent.length):(o.selectNodeContents(e),o.collapse(!1)),o.collapse(!0),t.removeAllRanges(),t.addRange(o)};getFirstTextNode=t=>{if(!t)return null;if(t.nodeType===Node.TEXT_NODE)return t;for(let e=0;e<t.childNodes.length;e++){const o=t.childNodes[e];if("UL"===o.nodeName||"OL"===o.nodeName)continue;const i=this.getFirstTextNode(o);if(i)return i}return null};getList=t=>{for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(t.nodeName){case"OL":case"UL":return t}t=t.parentNode}return null}}class n{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o}copy=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(t)};cut=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&(navigator.clipboard.writeText(t),t.deleteFromDocument())};paste=()=>{navigator.clipboard.readText().then(t=>{this.checkParagraphs(t.trim())||this.checkTables(t.trim())||this.checkLines(t.trim())||this.checkText(t.trim())}).catch(t=>{console.error("Failed to read clipboard contents: ",t)})};checkParagraphs=t=>{let e=t.split(/\n\s*\n/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment();return e.forEach(t=>{let e=this.checkParagraphTable(t,i);if(e||(e=this.checkParagraphLines(t,i)),!e){let e=document.createElement("p");e.textContent=t.trim(),i.appendChild(e)}}),o.insertNode(i),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}return!1};checkParagraphLines=(t,e)=>{let o=0,i=t.trim().split(/\n+/);return i.length>1&&(i.forEach(t=>{if(o++,o===i.length){let o=document.createElement("p");o.textContent=t.trim(),e.appendChild(o)}else{let o=document.createElement("div");o.textContent=t.trim(),e.appendChild(o)}}),!0)};checkParagraphTable=(t,e)=>{if(this.isTable(t)){let o=this.buildTable(t);return e.appendChild(o),!0}return!1};checkLines=t=>{let e=t.trim().split(/\n+/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment();return e.forEach(t=>{let e=document.createElement("div");e.textContent=t.trim(),i.appendChild(e)}),o.insertNode(i),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}};checkTables=t=>{if(this.isTable(t)){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const o=e.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment(),n=this.buildTable(t);return i.appendChild(n),o.insertNode(i),o.collapse(!0),e.removeAllRanges(),e.addRange(o),!0}}};buildTable=t=>{let e=document.createElement("table"),o=t.split("\n"),i=document.createElement("tbody");return o.forEach((t,e)=>{if(t.trim().length>0){let e=t.split("\t"),o=document.createElement("tr");e.forEach(t=>{let e=document.createElement("td");t.trim().length>0&&(e.textContent=t),o.appendChild(e)}),i.appendChild(o)}}),e.appendChild(i),e};isTable=t=>{if(t.includes("\t")){let e=t.split("\n");if(e.length>1&&e[1].trim().length>0){let t=(e[1].match(/\t/g)||[]).length;if(0===t)return!1;for(let o=1;o<e.length;o++){let i=e[o];if(i.trim().length>0){if((i.match(/\t/g)||[]).length!==t)return!1}}return!0}}return!1};checkText=t=>{const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const o=e.getRangeAt(0);if(o.deleteContents(),""===this.content.innerHTML.trim()){const e=document.createElement("div"),i=document.createTextNode(t);e.appendChild(i),o.insertNode(e),o.setStartAfter(e),o.setEndAfter(e)}else{const e=document.createTextNode(t);o.insertNode(e),o.setStartAfter(e),o.setEndAfter(e)}e.removeAllRanges(),e.addRange(o)}}}class r{constructor(t,e){this.shadowRoot=t,this.content=e}closeDialog=(t,e)=>{const o=this.shadowRoot.getElementById(t);null!=o&&o.close(),e&&this.restoreSelection(window.getSelection(),e),this.content.focus()};addClasses=(t,e)=>{if(null!=t&&null!=e)if(e.classList.remove(...e.classList),t.length>0){t.split(" ").map(t=>t.trim()).forEach(t=>{t&&e.classList.add(t)})}else e.hasAttribute("class")&&e.removeAttribute("class")};getSelection=()=>{const t=this.shadowRoot.getSelection();return this.content.contains(t.anchorNode)&&this.content.contains(t.focusNode)?t:null};showFadingBar=t=>{const e=this.shadowRoot.getElementById("rich-text-box-message-bar"),o=e.querySelector(".rich-text-box-message");e&&o&&(o.textContent=t,e.classList.remove("rich-text-box-message-hidden"),setTimeout(()=>{this.closeFadingBar()},2e3))};closeFadingBar=()=>{this.shadowRoot.getElementById("rich-text-box-message-bar").classList.add("rich-text-box-message-hidden")};saveSelection=t=>t&&t.rangeCount>0?t.getRangeAt(0).cloneRange():null;restoreSelection=(t,e)=>{t&&e&&(t.removeAllRanges(),t.addRange(e)),this.content.focus()};reselectNode=t=>{const e=document.createRange(),o=window.getSelection();t.childNodes.length>0?e.setStartAfter(t.childNodes[t.childNodes.length-1]):e.setStartAfter(t),e.collapse(!0),o.removeAllRanges(),o.addRange(e)};saveCaretPosition=()=>{const t=this.getSelection();if(null!==t){return{startOffset:t.getRangeAt(0).startOffset,endOffset:t.getRangeAt(0).endOffset}}return null};restoreCaretPosition=(t,e)=>{const o=this.getSelection();if(null!==o&&null!==e){let i=document.createRange();i.setStart(t.firstChild,e.startOffset),i.setEnd(t.firstChild,e.endOffset),o.removeAllRanges(),o.addRange(i)}};saveScroll=t=>t.scrollTop;restoreScroll=(t,e)=>{t.scrollTop=e}}class s{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-table-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertTable()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openTableDialog=t=>{if(this.resetTableDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&"TD"===t.anchorNode.parentNode.nodeName){const e=this.getTable(t);if(e){const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=e.rows.length,t.disabled=!0;const o=this.shadowRoot.getElementById("rich-text-box-table-columns");o.value=this.getColumns(e),o.disabled=!0;this.shadowRoot.getElementById("rich-text-box-table-width").value=e.style.width;const i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=i){const t=e.classList;i.value=Array.from(t).join(" ")}this.table=e}}else null!==t&&t.rangeCount>0&&(this.tableSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-table-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e&&e.focus()};getTable=t=>"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode:"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode.parentNode:void 0;getColumns(t){let e=0;for(let o=0;o<t.rows.length;o++){let i=t.rows[o].cells.length;i>e&&(e=i)}return e}resetTableDialog=()=>{this.table=null,this.tableSelection=null;const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=null,t.disabled=!1;const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e.value=null,e.disabled=!1;this.shadowRoot.getElementById("rich-text-box-table-width").value=null;const o=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=o&&(o.value=null)};insertTable=()=>{const t=this.shadowRoot.getElementById("rich-text-box-table-rows"),e=this.shadowRoot.getElementById("rich-text-box-table-columns"),o=this.shadowRoot.getElementById("rich-text-box-table-width"),i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(0!=t.value.length&&0!=e.value.length){if(null!==this.table)o.value.trim().length>0?this.table.style.width=o.value:(this.table.style.removeProperty("width"),0===this.table.style.cssText.trim().length&&this.table.hasAttribute("style")&&this.table.removeAttribute("style")),null!==i&&this.Utilities.addClasses(i.value,this.table),this.Utilities.reselectNode(this.table);else if(null!=this.tableSelection){const n=this.tableSelection,r=this.createTable(t.value,e.value,o.value);null!==i&&this.Utilities.addClasses(i.value,r),n.deleteContents(),n.insertNode(r);let s=r.querySelector("td, th"),l=document.createRange();l.setStart(s,0),l.setEnd(s,0),this.savedSelection=l}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-table-modal",this.savedSelection)};createTable=(t,e,o)=>{const i=parseInt(t,10),n=parseInt(e,10),r=document.createElement("table");o&&(r.style.width=o);const s=document.createElement("tbody");for(let t=0;t<i;t++){const t=document.createElement("tr");for(let e=0;e<n;e++){const e=document.createElement("td");e.innerHTML="&#8203;",t.appendChild(e)}s.appendChild(t)}return r.appendChild(s),r};tableTab=()=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return;const e=this.getCurrentCell(t);if(!e)return;const o=this.getNextElement(e);if(o){o.focus();const e=document.createRange();e.selectNodeContents(o),"​"===o.innerText&&e.collapse(),t.removeAllRanges(),t.addRange(e)}this.content.focus()}};addRowFromLastCell=()=>{const t=this.Utilities.getSelection();if(null===t||!t.rangeCount)return!1;const e=this.getCurrentCell(t);if(!e)return!1;const o=e.parentElement,i=o?o.parentElement:null,n=i?i.closest("table"):null;if(!o||!i||!n)return!1;if(o.nextElementSibling)return!1;if(e.nextElementSibling)return!1;const r=Math.max(this.getColumns(n),o.cells.length,1),s=document.createElement("tr");for(let t=0;t<r;t++){const t=document.createElement("td");t.innerHTML="&#8203;",s.appendChild(t)}i.appendChild(s);const l=s.querySelector("td, th");return l&&this.selectCell(l),!0};getCurrentCell=t=>{if(!t||!t.anchorNode)return null;const e=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement;if(!e||!this.content.contains(e))return null;const o=e.closest("td, th");return o&&this.content.contains(o)?o:null};selectCell=t=>{if(!t)return;this.content.focus();const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.selectNodeContents(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)};getNextElement=t=>{let e=t.nextElementSibling;if(!e){let o=t.parentElement.nextElementSibling;o&&(e=o.querySelector("td"))}return e}}class l{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertMedia()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openMediaDialog=t=>{if(null!==t){if(this.resetMediaDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.embed=t.anchorNode.querySelector("object"),null!==this.embed)){this.shadowRoot.getElementById("rich-text-box-embed-source").value=this.embed.data;this.shadowRoot.getElementById("rich-text-box-embed-width").value=this.embed.width;this.shadowRoot.getElementById("rich-text-box-embed-height").value=this.embed.height;this.shadowRoot.getElementById("rich-text-box-embed-type").value=this.embed.type;this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(this.embed.classList).join(" ")}t.rangeCount>0&&(this.embedSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-embed-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-embed-source");e&&e.focus()}};resetMediaDialog=()=>{this.embed=null,this.embedSelection=null;this.shadowRoot.getElementById("rich-text-box-embed-source").value=null;this.shadowRoot.getElementById("rich-text-box-embed-width").value=null;this.shadowRoot.getElementById("rich-text-box-embed-height").value=null;this.shadowRoot.getElementById("rich-text-box-embed-type").value=null;const t=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=t&&(t.value=null)};insertMedia=()=>{const t=this.shadowRoot.getElementById("rich-text-box-embed-source"),e=this.shadowRoot.getElementById("rich-text-box-embed-width"),o=this.shadowRoot.getElementById("rich-text-box-embed-height"),i=this.shadowRoot.getElementById("rich-text-box-embed-type"),n=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");if(null!==this.embed)this.embed.data=t.value,i.value.trim().length>0?this.embed.type=i.value:this.embed.hasAttribute("type")&&this.embed.removeAttribute("type"),e.value.trim().length>0?this.embed.width=e.value:this.embed.hasAttribute("width")&&this.embed.removeAttribute("width"),o.value.trim().length>0?this.embed.height=o.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,this.embed);else if(null!=this.embedSelection&&t.value.length>0){const r=this.embedSelection.cloneRange(),s=document.createElement("object");s.data=t.value,i.value.trim().length>0?s.type=i.value:s.hasAttribute("type")&&s.removeAttribute("type"),e.value.trim().length>0?s.width=e.value:s.hasAttribute("width")&&s.removeAttribute("width"),o.value.trim().length>0?s.height=o.value:s.hasAttribute("height")&&s.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,s),r.deleteContents(),r.insertNode(s),this.Utilities.reselectNode(s),this.embedSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-embed-modal",this.savedSelection)}}class a{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.video=null,this.videoSelection=null,this.savedSelection=null,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-video-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertVideo()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};_populateFromVideo=t=>{const ge=t=>this.shadowRoot.getElementById(t),e=t.querySelector("source");ge("rich-text-box-video-source").value=e?e.getAttribute("src")||"":t.getAttribute("src")||"",ge("rich-text-box-video-source-type").value=e&&e.getAttribute("type")||"",ge("rich-text-box-video-poster").value=t.getAttribute("poster")||"",ge("rich-text-box-video-width").value=t.getAttribute("width")||"",ge("rich-text-box-video-height").value=t.getAttribute("height")||"",ge("rich-text-box-video-controls").checked=t.hasAttribute("controls"),ge("rich-text-box-video-autoplay").checked=t.hasAttribute("autoplay"),ge("rich-text-box-video-loop").checked=t.hasAttribute("loop"),ge("rich-text-box-video-muted").checked=t.hasAttribute("muted"),ge("rich-text-box-video-css-classes").value=Array.from(t.classList).join(" ")};_showDialog=()=>{this.shadowRoot.getElementById("rich-text-box-video-modal").show(),this.shadowRoot.getElementById("rich-text-box-video-source").focus()};openVideoDialog=t=>{if(null!==t){this.resetVideoDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=t.anchorNode;e&&("VIDEO"===e.nodeName?this.video=e:"SOURCE"===e.nodeName&&"VIDEO"===e.parentElement?.nodeName?this.video=e.parentElement:e.querySelector&&(this.video=e.querySelector("video")),!this.video&&e.closest&&(this.video=e.closest("video"))),null!==this.video&&this._populateFromVideo(this.video),t.rangeCount>0&&(this.videoSelection=t.getRangeAt(0).cloneRange()),this._showDialog()}};openVideoDialogForElement=(t,e)=>{this.resetVideoDialog(),this.savedSelection=e,this.video=t,this._populateFromVideo(t);const o=this.Utilities.getSelection();o&&o.rangeCount>0&&(this.videoSelection=o.getRangeAt(0).cloneRange()),this._showDialog()};resetVideoDialog=()=>{this.video=null,this.videoSelection=null;const ge=t=>this.shadowRoot.getElementById(t);ge("rich-text-box-video-source").value="",ge("rich-text-box-video-source-type").value="",ge("rich-text-box-video-poster").value="",ge("rich-text-box-video-width").value="",ge("rich-text-box-video-height").value="",ge("rich-text-box-video-controls").checked=!0,ge("rich-text-box-video-autoplay").checked=!1,ge("rich-text-box-video-loop").checked=!1,ge("rich-text-box-video-muted").checked=!1,ge("rich-text-box-video-css-classes").value=""};insertVideo=()=>{const ge=t=>this.shadowRoot.getElementById(t),t=ge("rich-text-box-video-source").value.trim(),e=ge("rich-text-box-video-source-type").value.trim(),o=ge("rich-text-box-video-poster").value.trim(),i=ge("rich-text-box-video-width").value.trim(),n=ge("rich-text-box-video-height").value.trim(),r=ge("rich-text-box-video-controls").checked,s=ge("rich-text-box-video-autoplay").checked,l=ge("rich-text-box-video-loop").checked,a=ge("rich-text-box-video-muted").checked,c=ge("rich-text-box-video-css-classes").value.trim(),applyAttrs=d=>{let h=d.querySelector("source");h||(h=document.createElement("source"),d.appendChild(h)),h.setAttribute("src",t),e?h.setAttribute("type",e):h.removeAttribute("type"),o?d.setAttribute("poster",o):d.removeAttribute("poster"),i?d.setAttribute("width",i):d.removeAttribute("width"),n?d.setAttribute("height",n):d.removeAttribute("height"),r?d.setAttribute("controls",""):d.removeAttribute("controls"),s?d.setAttribute("autoplay",""):d.removeAttribute("autoplay"),l?d.setAttribute("loop",""):d.removeAttribute("loop"),a?d.setAttribute("muted",""):d.removeAttribute("muted"),this.Utilities.addClasses(c,d)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&t.length>0){const t=this.videoSelection.cloneRange();if(!this.content.contains(t.startContainer))return void this.closeDialog();const e=document.createElement("video");applyAttrs(e),t.deleteContents();let o=t.startContainer;if(o===this.content){const o=this.content.childNodes[t.startOffset]??null;this.content.insertBefore(e,o)}else{for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(e),this._placeCursorAfterVideo(e),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(e,o.nextSibling)}this._placeCursorAfterVideo(e),this.videoSelection=null}this.closeDialog()};_placeCursorAfterVideo=t=>{if(!t.nextSibling){const e=document.createElement("p");e.appendChild(document.createElement("br")),this.content.insertBefore(e,t.nextSibling)}this._insertedVideo=t};closeDialog=()=>{const t=this._insertedVideo;if(this._insertedVideo=null,this.Utilities.closeDialog("rich-text-box-video-modal",this.savedSelection),t){const e=t.nextSibling;if(e){const t=document.createRange(),o=e.firstChild??e;t.setStart(o,0),t.collapse(!0);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(t))}}}}class c{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code");this.dialog=this.shadowRoot.getElementById("rich-text-box-code-block-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertCodeBlock()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openCodeBlockDialog=t=>{if(null!==t){this.resetCodeBlockDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-code"),o=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"CODE"===t.anchorNode.parentNode.nodeName){const i=t.anchorNode.parentNode.cloneNode(!0);if(e.value=i.textContent,null!=o){const e=t.anchorNode.parentNode.classList;o.value=Array.from(e).join(" ")}this.codeSelection=t.getRangeAt(0).cloneRange(),this.code=t.anchorNode.parentNode}else t.rangeCount>0&&(this.codeSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openCodeBlockDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetCodeBlockDialog(),this.savedSelection=e?e.cloneRange():null;const o=t.querySelector("code")||t,i=this.shadowRoot.getElementById("rich-text-box-code"),n=this.shadowRoot.getElementById("rich-text-box-code-css-classes");i.value=o.textContent,null!=n&&(n.value=Array.from(o.classList).join(" ")),this.codeSelection=e?e.cloneRange():null,this.code=o,this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),i.focus(),i.scrollTop=0,i.scrollLeft=0};resetCodeBlockDialog=()=>{this.code=null,this.codeSelection=null;this.shadowRoot.getElementById("rich-text-box-code").value=null;const t=this.shadowRoot.getElementById("rich-text-box-code-css-classes");null!=t&&(t.value=null)};insertCodeBlock=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code"),e=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=this.code){const o=this.code;o.textContent=t.value,null!==e&&this.Utilities.addClasses(e.value,o);const i=o.closest("pre")||o,n=document.createRange();n.setStartAfter(i),n.collapse(!0),this.savedSelection=n}else if(null!=this.codeSelection&&t.value.length>0){const o=this.codeSelection.cloneRange(),i=document.createElement("pre"),n=document.createElement("code");null!==e&&this.Utilities.addClasses(e.value,n),n.textContent=t.value,i.appendChild(n),o.deleteContents(),o.insertNode(i),o.setStartAfter(i),o.setEndAfter(i),this.savedSelection=o}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class d{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote");this.dialog=this.shadowRoot.getElementById("rich-text-box-block-quote-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertBlockQuote()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openBlockQuoteDialog=t=>{if(null!==t){this.resetBlockQuoteDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-quote"),o=this.shadowRoot.getElementById("rich-text-box-cite"),i=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"BLOCKQUOTE"==t.anchorNode.parentNode.nodeName){if(e.value=t.anchorNode.parentNode.textContent,null!=t.anchorNode.parentNode.cite&&(o.value=t.anchorNode.parentNode.cite),null!=i){const e=t.anchorNode.parentNode.classList;i.value=Array.from(e).join(" ")}this.quoteSelection=t.getRangeAt(0).cloneRange(),this.quote=t.anchorNode.parentNode}else t.rangeCount>0&&(this.quoteSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openBlockQuoteDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetBlockQuoteDialog(),this.savedSelection=e?e.cloneRange():null;const o=this.shadowRoot.getElementById("rich-text-box-quote"),i=this.shadowRoot.getElementById("rich-text-box-cite"),n=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");o.value=t.textContent,null!=t.cite&&(i.value=t.cite),null!=n&&(n.value=Array.from(t.classList).join(" ")),this.quoteSelection=e?e.cloneRange():null,this.quote=t,this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),o.focus(),o.scrollTop=0,o.scrollLeft=0};resetBlockQuoteDialog=()=>{this.quote=null,this.quoteSelection=null;this.shadowRoot.getElementById("rich-text-box-quote").value=null;this.shadowRoot.getElementById("rich-text-box-cite").value=null;const t=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");null!=t&&(t.value=null)};insertBlockQuote=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote"),e=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const i=this.quote;i.textContent=t.value,e.value.trim().length>0?i.setAttribute("cite",e.value):i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,i);const n=document.createRange();n.setStartAfter(i),n.collapse(!0),this.savedSelection=n}else if(null!=this.quoteSelection&&t.value.length>0){const i=this.quoteSelection.cloneRange(),n=document.createElement("blockquote");n.textContent=t.value,e.value.trim().length>0?n.cite=e.value:n.hasAttribute("cite")&&n.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,n),i.deleteContents(),i.insertNode(n),i.setStartAfter(n),i.setEndAfter(n),this.savedSelection=i}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class h{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertUploadedImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())});this.shadowRoot.getElementById("rich-text-box-upload-image-file").addEventListener("change",this.handleFileSelect)};handleFileSelect=t=>{const e=t.target.files[0];this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=e.name;const o=document.createElement("img");if(e){const t=new FileReader;t.onloadend=function(){this.base64String=t.result.split(",")[1],o.src=`data:image/jpg;base64,${this.base64String}`},t.readAsDataURL(e),this.image=o}};openUploadImageDialog=t=>{if(null!==t){if(this.resetUploadImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.currentImage=t.anchorNode.querySelector("img"),null!==this.currentImage)){this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=this.currentImage.width;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=this.currentImage.height;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=this.currentImage.alt;this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes").value=Array.from(this.currentImage.classList).join(" ")}this.range=t.getRangeAt(0).cloneRange(),this.shadowRoot.getElementById("rich-text-box-upload-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-upload-btn");e&&e.focus()}};resetUploadImageDialog=()=>{this.currentImage=null,this.image=null,this.range=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");null!=t&&(t.value=null)};insertUploadedImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),e=this.shadowRoot.getElementById("rich-text-box-upload-image-height"),o=this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text"),i=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),t.value.trim().length>0?this.currentImage.width=t.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),e.value.trim().length>0?this.currentImage.height=e.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),o.value.trim().length>0?this.currentImage.alt=o.value:this.currentImage.hasAttribute("alt")&&this.currentImage.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.currentImage),this.Utilities.reselectNode(this.currentImage)):this.image&&(t.value.length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),e.value.length>0?this.image.height=e.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),o.value.length>0?this.image.alt=o.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.image),this.range.deleteContents(),this.range.insertNode(this.image),this.Utilities.reselectNode(this.image)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-upload-image-modal",this.savedSelection)}}class b{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openImageDialog=t=>{if(null!==t){if(this.resetImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.image=t.anchorNode.querySelector("img"),null!==this.image)){this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=this.image.src;this.shadowRoot.getElementById("rich-text-box-image-width").value=this.image.width;this.shadowRoot.getElementById("rich-text-box-image-height").value=this.image.height;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=this.image.alt;this.shadowRoot.getElementById("rich-text-box-image-css-classes").value=Array.from(this.image.classList).join(" ")}t&&t.rangeCount>0&&(this.imageSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-image-webaddress");e&&e.focus()}};resetImageDialog=()=>{this.image=null,this.imageSelection=null;this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-image-css-classes");null!=t&&(t.value=null)};insertImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress"),e=this.shadowRoot.getElementById("rich-text-box-image-width"),o=this.shadowRoot.getElementById("rich-text-box-image-height"),i=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),n=this.shadowRoot.getElementById("rich-text-box-image-css-classes");if(null!==this.imageSelection){const r=this.imageSelection.cloneRange();if(null!==this.image)t.value.trim().length>0&&(this.image.src=t.value),i.value.trim().length>0?this.image.alt=i.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),e.value.trim().length>0?this.image.width=e.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),o.value.trim().length>0?this.image.height=o.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,this.image),this.Utilities.reselectNode(this.image);else if(t.value.length>0){const s=document.createElement("img");s.src=t.value,e.value.trim().length>0&&(s.width=e.value),o.value.trim().length>0&&(s.height=o.value),i.value.trim().length>0&&(s.alt=i.value),null!==n&&this.Utilities.addClasses(n.value,s),r.deleteContents(),r.insertNode(s),this.Utilities.reselectNode(s)}this.imageSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-image-modal",this.savedSelection)}}class u{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertLink()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openLinkDialog=t=>{if(null!==t){if(this.savedSelection=this.Utilities.saveSelection(t),this.resetLinkDialog(),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){this.shadowRoot.getElementById("rich-text-box-linktext").value=t.anchorNode.parentNode.textContent;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=t.anchorNode.parentNode.getAttribute("href");const e=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=e){const o=t.anchorNode.parentNode.classList;e.value=Array.from(o).join(" ")}if("_blank"===t.anchorNode.parentNode.getAttribute("target")){this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!0}this.linkNode=t.anchorNode.parentNode}else{const e=this.shadowRoot.getElementById("rich-text-box-linktext");t.toString().length>0&&(this.linkSelection=t.getRangeAt(0).cloneRange(),e.value=this.linkSelection.toString())}this.shadowRoot.getElementById("rich-text-box-link-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-link-webaddress");e&&e.focus()}};resetLinkDialog=()=>{this.linkNode=null,this.linkSelection=null;this.shadowRoot.getElementById("rich-text-box-linktext").value=null;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!1;const t=this.shadowRoot.getElementById("rich-text-box-link-css-classes");null!=t&&(t.value=null)};insertLink=()=>{const t=this.shadowRoot.getElementById("rich-text-box-linktext"),e=this.shadowRoot.getElementById("rich-text-box-link-webaddress"),o=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),i=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(0!=e.value.length&&0!=t.value.length){if(null!=this.linkNode){const n=this.linkNode;n.href=e.value,n.textContent=t.value,null!==i&&this.Utilities.addClasses(i.value,n),o.checked?n.target="_blank":n.hasAttribute("target")&&n.removeAttribute("target"),this.Utilities.reselectNode(n)}else if(null!=this.linkSelection){const n=this.linkSelection,r=document.createElement("a");r.href=e.value,r.textContent=t.value,null!==i&&this.Utilities.addClasses(i.value,r),o.checked&&(r.target="_blank"),n.deleteContents(),n.insertNode(r),n.setStartBefore(r.firstChild),n.setEndAfter(r.lastChild),this.savedSelection=n}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-link-modal",this.savedSelection)};removeLink=()=>{const t=this.Utilities.getSelection();if(null!==t){const e=this.Utilities.saveSelection(t);if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){const e=t.anchorNode.parentNode,o=document.createDocumentFragment();for(;e.firstChild;)o.appendChild(e.firstChild);e.parentNode.insertBefore(o,e),e.parentNode.removeChild(e)}this.Utilities.restoreSelection(t,e)}}}class g{constructor(t,e,o,i,n){this.shadowRoot=t,this.content=e,this.id=o,this.NodeManager=i,this.Utilities=n,this.init()}init=()=>{this.colorPickerDialog=this.shadowRoot.getElementById(this.id),this.colorPickerDialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertColor()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())}),this.colorPicker=this.colorPickerDialog.querySelector(".rich-text-box-color-picker"),this.redSlider=this.colorPicker.querySelector(".rich-text-box-red-slider"),this.addSliderEventListener(this.redSlider),this.greenSlider=this.colorPicker.querySelector(".rich-text-box-green-slider"),this.addSliderEventListener(this.greenSlider),this.blueSlider=this.colorPicker.querySelector(".rich-text-box-blue-slider"),this.addSliderEventListener(this.blueSlider),this.redValue=this.colorPicker.querySelector(".rich-text-box-red-value"),this.addValueEventListener(this.redValue),this.greenValue=this.colorPicker.querySelector(".rich-text-box-green-value"),this.addValueEventListener(this.greenValue),this.blueValue=this.colorPicker.querySelector(".rich-text-box-blue-value"),this.addValueEventListener(this.blueValue),this.hexInput=this.colorPicker.querySelector(".rich-text-box-hex-input"),this.addHexEventListener(this.hexInput),this.colorDisplay=this.colorPicker.querySelector(".rich-text-box-color-display")};addSliderEventListener=async t=>{t.addEventListener("input",()=>this.updateColor())};addValueEventListener=async t=>{t.addEventListener("input",t=>{let e=Array.from(t.target.classList).find(t=>t.includes("value"));this.colorPicker.querySelector(`.${e.replace("value","slider")}`).value=t.target.value,this.updateColor()}),t.addEventListener("focus",t=>{t.target.select()})};addHexEventListener=async t=>{t.addEventListener("keyup",t=>{/^#?[0-9A-Fa-f]{6}$/.test(t.target.value)&&this.updateFromHex()}),t.addEventListener("change",()=>this.updateFromHex()),t.addEventListener("paste",()=>setTimeout(this.updateFromHex,0)),t.addEventListener("focus",e=>{t.select()})};openColorPicker=(t,e)=>{if(this.resetColorDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!==t&&null!=t.anchorNode&&t.anchorNode!=e&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=e&&e.contains(t.anchorNode.parentNode)&&null!=t.anchorNode.parentNode.style){switch(this.selection=t.getRangeAt(0).cloneRange(),this.id){case"rich-text-box-text-color-modal":t.anchorNode.parentNode.style.color.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.color));break;case"rich-text-box-text-bg-color-modal":t.anchorNode.parentNode.style.backgroundColor.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.backgroundColor))}this.updateFromHex(),this.selection=t.getRangeAt(0).cloneRange()}else null!==t&&t.rangeCount>0&&(this.selection=t.getRangeAt(0).cloneRange());return this.colorPickerDialog.show(),this.selection};insertColor=()=>{let t;switch(this.currentColor=this.getCurrentColor(),this.id){case"rich-text-box-text-color-modal":t="textcolor";break;case"rich-text-box-text-bg-color-modal":t="textbgcolor"}null!==this.selection&&(this.savedSelection=this.Utilities.saveSelection(this.selection),null===this.currentColor?this.NodeManager.updateNode(t,"None",this.selection):this.NodeManager.updateNode(t,this.currentColor,this.selection)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog(this.id,this.savedSelection)};resetColorDialog=()=>{this.selection=null,this.hexInput.value="#000000",this.updateFromHex()};selectColor=t=>{this.hexInput.value=t,this.updateFromHex()};updateColor=()=>{let t=parseInt(this.redSlider.value),e=parseInt(this.greenSlider.value),o=parseInt(this.blueSlider.value),i=`rgb(${t}, ${e}, ${o})`;this.currentColor=i,this.colorDisplay.style.backgroundColor=i,this.redValue.value=t,this.greenValue.value=e,this.blueValue.value=o,this.hexInput.value=this.rgbToHex(t,e,o)};getCurrentColor=()=>this.currentColor;updateFromHex=()=>{let t=this.hexInput.value.trim();if("#"!==t.charAt(0)&&(t="#"+t),/^#[0-9A-Fa-f]{6}$/.test(t)){let e=this.hexToRgb(t);e&&(this.redSlider.value=this.redValue.value=e.r,this.greenSlider.value=this.greenValue.value=e.g,this.blueSlider.value=this.blueValue.value=e.b)}this.updateColor()};rgbToHex=(t,e,o)=>"#"+((1<<24)+(t<<16)+(e<<8)+o).toString(16).slice(1);hexToRgb=t=>{const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null};colorToHex=t=>{const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,e.fillStyle}}window.RTNative_Instances={},window.RTNative_Initialize=(e,o,i,n,r,s)=>{try{null==RTNative_Instances[e]&&(RTNative_Instances[e]=new t(e,o,i,n,s),RTNative_Instances[e].loadHtml(r))}catch(t){console.log(t)}},window.RTNative_Method=(t,e,o)=>{try{const i=RTNative_Instances[e];if(null!=i&&"function"==typeof i[t])return null!=o?i[t](o):i[t]()}catch(t){console.log(t)}};const m={Bold:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z",Italic:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z",Underline:"M200-120v-80h560v80H200Zm280-160q-101 0-157-63t-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63Z",Strikethrough:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z",Subscript:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z",Superscript:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z",Alignleft:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z",Aligncenter:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z",Alignright:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z",Alignjustify:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z",Copy:"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",Cut:"M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6ZM240-160q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z",Paste:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z",Delete:"M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Selectall:"M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z",OrderedList:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z",UnorderedList:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z",CreateLink:"M680-160v-120H560v-80h120v-120h80v120h120v80H760v120h-80ZM440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm560-40h-80q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480Z",RemoveLink:"m770-302-60-62q40-11 65-42.5t25-73.5q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 57-29.5 105T770-302ZM634-440l-80-80h86v80h-6ZM792-56 56-792l56-56 736 736-56 56ZM440-280H280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h65l79 80H320Z",Image:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z",Undo:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z",Redo:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z",CodeBlocks:"m384-336 56-57-87-87 87-87-56-57-144 144 144 144Zm192 0 144-144-144-144-56 57 87 87-87 87 56 57ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z",Code:"M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z",Preview:"M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z",PermMedia:"M360-440h400L622-620l-92 120-62-80-108 140ZM120-120q-33 0-56.5-23.5T40-200v-520h80v520h680v80H120Zm160-160q-33 0-56.5-23.5T200-360v-440q0-33 23.5-56.5T280-880h200l80 80h280q33 0 56.5 23.5T920-720v360q0 33-23.5 56.5T840-280H280Zm0-80h560v-360H527l-80-80H280v440Zm0 0v-440 440Z",TextColor:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z",TextBackgroundColor:"M80 0v-160h800V0H80Zm504-480L480-584 320-424l103 104 161-160Zm-47-160 103 103 160-159-104-104-159 160Zm-84-29 216 216-189 190q-24 24-56.5 24T367-263l-27 23H140l126-125q-24-24-25-57.5t23-57.5l189-189Zm0 0 187-187q24-24 56.5-24t56.5 24l104 103q24 24 24 56.5T857-640L669-453 453-669Z",RemoveTextFormat:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z",Quote:"m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM320-500q25 0 42.5-17.5T380-560q0-25-17.5-42.5T320-620q-25 0-42.5 17.5T260-560q0 25 17.5 42.5T320-500Zm360 0q25 0 42.5-17.5T740-560q0-25-17.5-42.5T680-620q-25 0-42.5 17.5T620-560q0 25 17.5 42.5T680-500Zm0-60Zm-360 0Z",VideoFile:"M360-240h160q17 0 28.5-11.5T560-280v-40l80 42v-164l-80 42v-40q0-17-11.5-28.5T520-480H360q-17 0-28.5 11.5T320-440v160q0 17 11.5 28.5T360-240ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",Table:"M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm80-400h560v-160H200v160Zm213 200h134v-120H413v120Zm0 200h134v-120H413v120ZM200-400h133v-120H200v120Zm427 0h133v-120H627v120ZM200-200h133v-120H200v120Zm427 0h133v-120H627v120Z",IncreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z",DecreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z",UploadImage:"M440-200h80v-167l64 64 56-57-160-160-160 160 57 56 63-63v167ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",SaveHtml:"m720-120 160-160-56-56-64 64v-167h-80v167l-64-64-56 56 160 160ZM560 0v-80h320V0H560ZM240-160q-33 0-56.5-23.5T160-240v-560q0-33 23.5-56.5T240-880h280l240 240v121h-80v-81H480v-200H240v560h240v80H240Zm0-80v-560 560Z",HorizontalRule:"M160-440v-80h640v80H160Z",StatusBar:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-200v120h560v-120H568q-17 18-39.5 29T480-280q-26 0-48.5-11T392-320H200Zm308.5-51.5Q520-383 520-400t-11.5-28.5Q497-440 480-440t-28.5 11.5Q440-417 440-400t11.5 28.5Q463-360 480-360t28.5-11.5ZM200-400h160q0-50 35-85t85-35q50 0 85 35t35 85h160v-360H200v360Zm0 200h560-560Z"};class x extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=x._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText=""}static _defaultVisibility(t=!0){return{font:t,size:t,format:t,textStylesDivider:t,bold:t,italic:t,underline:t,strikethrough:t,subscript:t,superscript:t,formatDivider:t,textColor:t,textColorDivider:t,alignLeft:t,alignCenter:t,alignRight:t,alignJustify:t,alignDivider:t,copy:t,cut:t,paste:t,delete:t,selectAll:t,actionDivider:t,orderedList:t,unorderedList:t,indent:t,listDivider:t,link:t,image:t,imageUpload:t,quote:t,codeBlock:t,embedMedia:t,video:t,table:t,horizontalRule:t,mediaDivider:t,undo:t,redo:t,historyDivider:t,saveHtml:t,htmlView:t,preview:t,statusBarToggle:t,wordCount:!1}}static _injectGlobalStyles(){if(document.getElementById("_rtb-global-styles"))return;const t=document.createElement("style");t.id="_rtb-global-styles",t.textContent="\n/* ── rt-native host defaults ──────────────────────────────────────────────\n Override any --rtb-* variable on rt-native (or a higher-specificity rule\n such as .my-wrapper rt-native or rt-native.my-class) to theme the editor.\n ──────────────────────────────────────────────────────────────────────── */\nrt-native {\n display: block;\n\n /* Toolbar — Fluent 2 colorNeutralBackground1 + colorNeutralStroke1 separator */\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-style: solid;\n --rtb-toolbar-border-width: 1px;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-toolbar-border-radius: 0px;\n\n /* Toolbar dropdowns */\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n\n /* Buttons — transparent at rest, no border */\n --rtb-btn-text: #242424;\n --rtb-btn-size: 16px;\n --rtb-btn-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-style: none;\n --rtb-btn-border-width: 0px;\n --rtb-btn-border-color: #d1d1d1;\n --rtb-btn-border-hover: inherit;\n --rtb-btn-border-selected: inherit;\n --rtb-btn-border-radius: 4px;\n\n /* Editor content area */\n --rtb-content-text: #242424;\n --rtb-content-size: 1rem;\n --rtb-content-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-content-bg: #ffffff;\n --rtb-content-shadow: none;\n --rtb-content-line-height: 1.55;\n --rtb-content-padding: 20px 24px;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-heading-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-heading-weight: 600;\n --rtb-heading-line-height: 1.2;\n --rtb-heading-margin: 0 0 0.55em;\n --rtb-h1-size: 2.15em;\n --rtb-h2-size: 1.65em;\n --rtb-h3-size: 1.35em;\n --rtb-h4-size: 1.15em;\n --rtb-h5-size: 1em;\n --rtb-h6-size: 0.92em;\n --rtb-paragraph-margin: 0 0 0.9em;\n --rtb-list-margin: 0.35em 0 0.9em 1.35em;\n --rtb-list-padding-left: 1.35em;\n --rtb-list-item-margin: 0.18em 0;\n --rtb-link-text: #0969da;\n --rtb-link-decoration: underline;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-inline-code-border-radius: 4px;\n --rtb-code-font: Consolas, Monaco, 'Courier New', monospace;\n --rtb-inline-code-size: 0.92em;\n --rtb-inline-code-padding: 0.15em 0.35em;\n --rtb-hr-border: 1px solid #d1d1d1;\n --rtb-hr-margin: 1.25em 0;\n\n /* Blockquote — brand-blue left accent on a tinted surface */\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-border-width: 5px;\n --rtb-quote-text: #242424;\n --rtb-quote-margin: 1.5em 10px;\n --rtb-quote-padding: 0.5em 10px;\n\n /* Code / pre — neutral surface, Fluent medium corner radius */\n --rtb-code-bg: #f5f5f5;\n --rtb-code-border-radius: 4px;\n --rtb-code-margin: 1.2em 0;\n --rtb-code-padding: 0.85em 1em;\n --rtb-table-margin: 1.2em 0;\n --rtb-table-width: auto;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-cell-min-width: 100px;\n --rtb-table-cell-padding: 6px 10px;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n --rtb-table-header-weight: 600;\n\n /* Editor container — hairline border + featherweight shadow */\n --rtb-editor-width: 100%;\n --rtb-editor-height: 300px;\n --rtb-editor-border-radius: 4px;\n --rtb-editor-border-style: solid;\n --rtb-editor-border-width: 1px;\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-editor-resize: auto;\n\n /* Scrollbars — thin pill-shaped Fluent style */\n --rtb-scroll-width: 6px;\n --rtb-scroll-opacity: 1;\n --rtb-scroll-bg: transparent;\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-scroll-thumb-radius: 3px;\n\n /* Placeholder */\n --rtb-placeholder-color: #9ca3af;\n\n /* Stacking context — raise the entire editor above surrounding content */\n --rtb-z-index: 1;\n\n /* Modals / dialogs */\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-text-size: 1rem;\n --rtb-modal-text-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n --rtb-modal-checkbox: #0078d4;\n}\n\nrt-native.light,\nrt-native.fluent {\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n --rtb-btn-text: #242424;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-color: #d1d1d1;\n\n --rtb-content-text: #242424;\n --rtb-content-bg: #ffffff;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-link-text: #0969da;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-hr-border: 1px solid #d1d1d1;\n\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-text: #242424;\n\n --rtb-code-bg: #f5f5f5;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-placeholder-color: #9ca3af;\n\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n}\n\nrt-native.dark,\nrt-native.fluent-dark {\n --rtb-toolbar-bg: #1f1f1f;\n --rtb-toolbar-border-color: #3f3f46;\n --rtb-dropdown-bg: #242424;\n --rtb-dropdown-text: #f5f5f5;\n --rtb-dropdown-bg-hover: #323238;\n --rtb-dropdown-text-hover: #ffffff;\n --rtb-btn-text: #f5f5f5;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #323238;\n --rtb-btn-bg-selected: #3f3f46;\n --rtb-btn-border-color: #3f3f46;\n\n --rtb-content-text: #f5f5f5;\n --rtb-content-bg: #1f1f1f;\n --rtb-heading-text: #ffffff;\n --rtb-heading-muted-text: #a1a1aa;\n --rtb-link-text: #7ab7ff;\n --rtb-inline-code-bg: rgba(255, 255, 255, 0.12);\n --rtb-hr-border: 1px solid #3f3f46;\n\n --rtb-quote-bg: #10243a;\n --rtb-quote-border-color: #479ef5;\n --rtb-quote-text: #eef6ff;\n\n --rtb-code-bg: #141414;\n --rtb-table-border: 1px solid #52525b;\n --rtb-table-header-bg: #2b2b2b;\n --rtb-table-header-text: #ffffff;\n\n --rtb-editor-border-color: #3f3f46;\n --rtb-editor-shadow: none;\n --rtb-scroll-thumb-bg: #5c5c5c;\n --rtb-scroll-thumb-bg-hover: #7a7a7a;\n --rtb-placeholder-color: #a1a1aa;\n\n --rtb-modal-bg: #242424;\n --rtb-modal-text: #f5f5f5;\n --rtb-modal-input-bg: #1f1f1f;\n --rtb-modal-input-text: #f5f5f5;\n --rtb-modal-input-border: #52525b;\n}\n\n",document.head.appendChild(t)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(t,e,o){if(e!==o){if("value"===t&&this._initialized&&(this._value=o||"",RTNative_Method("loadView",this._uid,o)),"width"===t&&this.style.setProperty("--rtb-editor-width",o||"100%"),"height"===t&&this.style.setProperty("--rtb-editor-height",o||"300px"),"config"===t)try{this.configure(JSON.parse(o))}catch(t){}if("placeholder"===t){const t=RTNative_Instances?.[this._uid];t?.content&&(o?t.content.setAttribute("data-placeholder",o):t.content.removeAttribute("data-placeholder"))}if("readonly"===t){const t=RTNative_Instances?.[this._uid];t&&t.setReadOnly(null!==o)}if("aria-label"===t||"label"===t){const t=RTNative_Instances?.[this._uid];t?.content&&o&&t.content.setAttribute("aria-label",o)}}}connectedCallback(){x._injectGlobalStyles(),this.style.setProperty("--rtb-editor-width",this.getAttribute("width")||"100%"),this.style.setProperty("--rtb-editor-height",this.getAttribute("height")||"300px"),this._render(),requestAnimationFrame(()=>this._initialize())}get readOnly(){return this.hasAttribute("readonly")}setReadOnly(t){t?this.setAttribute("readonly",""):this.removeAttribute("readonly")}disconnectedCallback(){window.RTNative_Instances?.[this._uid]&&delete RTNative_Instances[this._uid]}getValue(){return this._initialized?RTNative_Method("html",this._uid)||this._value||"":this._value||""}getPlainText(){return this._initialized&&RTNative_Method("plaintext",this._uid)||""}setValue(t){const e=(t||"").trim().replace(/>\s+</g,"><");this._value=e,this._initialized&&RTNative_Method("loadView",this._uid,e)}setPreviewCssFiles(...t){this._previewCssUrls=t.filter(t=>t&&"string"==typeof t),this._syncToInstance(),this._applyContentStyles()}setPreviewCssFile(t){this.setPreviewCssFiles(...t?[t]:[])}setPreviewCss(t){this._previewCssText=t||"",this._syncToInstance(),this._applyContentStyles()}_syncToInstance(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];t&&(t._previewCssUrls=this._previewCssUrls,t._previewCssText=this._previewCssText)}_scopeCssText(t,e){t=t.replace(/\/\*[\s\S]*?\*\//g,"");let o="",i=0;for(;i<t.length;){for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length)break;const n=t.indexOf("{",i);if(-1===n)break;const r=t.slice(i,n).trim();let s=1,l=n+1;for(;l<t.length&&s>0;)"{"===t[l]?s++:"}"===t[l]&&s--,l++;const a=t.slice(n+1,l-1);if(i=l,r)if(r.startsWith("@")){const t=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(t)?o+=r+" {\n"+this._scopeCssText(a,e)+"}\n":o+=r+" {"+a+"}\n"}else{o+=r.split(",").map(t=>t.trim()).filter(t=>t).map(t=>":root"===t?e:e+" "+t).join(",\n")+" {"+a+"}\n"}}return o}async _applyContentStyles(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];if(!t||!t.shadowRoot)return;const e=t.shadowRoot.getElementById("_rtb-content-preview-styles");e&&e.remove();const o=".rich-text-box-content";let i="";for(const t of this._previewCssUrls)try{const e=await fetch(t);e.ok?i+=this._scopeCssText(await e.text(),o)+"\n":console.warn(`rt-native: failed to load preview CSS (${e.status}): ${t}`)}catch(e){console.warn(`rt-native: could not load preview CSS: ${t}`,e)}if(this._previewCssText&&(i+=this._scopeCssText(this._previewCssText,o)+"\n"),i.trim()){const e=document.createElement("style");e.id="_rtb-content-preview-styles",e.textContent=i,t.shadowRoot.appendChild(e)}}configure(t={}){const{visibility:e,...o}=t;e&&(e.clearAll&&(this._visibility=x._defaultVisibility(!1)),Object.assign(this._visibility,e)),this._applyCSSVars(o),this._syncPreviewTheme(),this._initialized&&e&&this._reinitialize()}_syncPreviewTheme(){}_applyCSSVars(t){const set=(t,e)=>{null!=e&&this.style.setProperty(t,e)},e=t.toolbar||{};set("--rtb-toolbar-bg",e.backgroundColor),set("--rtb-toolbar-border-style",e.borderStyle),set("--rtb-toolbar-border-width",e.borderWidth),set("--rtb-toolbar-border-color",e.borderColor),set("--rtb-toolbar-border-radius",e.borderRadius),set("--rtb-dropdown-bg",e.dropdownBackgroundColor),set("--rtb-dropdown-text",e.dropdownTextColor),set("--rtb-dropdown-bg-hover",e.dropdownBackgroundColorHover),set("--rtb-dropdown-text-hover",e.dropdownTextColorHover);const o=t.button||{};set("--rtb-btn-text",o.textColor),set("--rtb-btn-size",o.textSize),set("--rtb-btn-font",o.textFont),set("--rtb-btn-bg",o.backgroundColor),set("--rtb-btn-bg-hover",o.backgroundColorHover),set("--rtb-btn-bg-selected",o.backgroundColorSelected),set("--rtb-btn-border-style",o.borderStyle),set("--rtb-btn-border-width",o.borderWidth),set("--rtb-btn-border-color",o.borderColor),set("--rtb-btn-border-hover",o.borderColorHover),set("--rtb-btn-border-selected",o.borderColorSelected),set("--rtb-btn-border-radius",o.borderRadius);const i=t.content||{};set("--rtb-content-text",i.textColor),set("--rtb-content-size",i.textSize),set("--rtb-content-font",i.textFont),set("--rtb-content-bg",i.backgroundColor),set("--rtb-content-shadow",i.boxShadow);const n=t.editor||{};set("--rtb-editor-width",n.width),set("--rtb-editor-height",n.height),set("--rtb-editor-border-radius",n.borderRadius),set("--rtb-editor-border-style",n.borderStyle),set("--rtb-editor-border-width",n.borderWidth),set("--rtb-editor-border-color",n.borderColor),set("--rtb-editor-shadow",n.boxShadow),null!=n.removeResizeHandle&&set("--rtb-editor-resize",n.removeResizeHandle?"visible":"auto");const r=t.scroll||{};set("--rtb-scroll-width",r.width),set("--rtb-scroll-opacity",r.opacity),set("--rtb-scroll-bg",r.backgroundColor),set("--rtb-scroll-thumb-bg",r.thumbBackground),set("--rtb-scroll-thumb-bg-hover",r.thumbBackgroundHover),set("--rtb-scroll-thumb-radius",r.thumbBorderRadius);const s=t.modal||{};set("--rtb-modal-bg",s.backgroundColor),set("--rtb-modal-text",s.textColor),set("--rtb-modal-text-size",s.textSize),set("--rtb-modal-text-font",s.textFont),set("--rtb-modal-input-bg",s.textboxBackgroundColor),set("--rtb-modal-input-text",s.textboxTextColor),set("--rtb-modal-input-border",s.textboxBorderColor),set("--rtb-modal-checkbox",s.checkboxAccentColor);const l=t.quote||{};set("--rtb-quote-bg",l.backgroundColor),set("--rtb-quote-border-color",l.borderColor),set("--rtb-quote-border-width",l.borderWidth);const a=t.code||{};set("--rtb-code-bg",a.backgroundColor),set("--rtb-code-border-radius",a.borderRadius)}_render(){this.innerHTML=this._buildToolbarHTML()+`<div id="${this._uid}_Shadow"></div>`}_initialize(){const e=this.getAttribute("value")||"",o=null!==this._value?this._value:e;this._value=o;const onValueChange=t=>{this._value=t,this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,composed:!0}))};window.RTNative_Instances||(window.RTNative_Instances={}),RTNative_Instances[this._uid]=new t(this._uid,`${this._uid}_Shadow`,`${this._uid}_Toolbar`,'\n.rich-text-box-tool-bar {\n background-color: var(--rtb-toolbar-bg, #FFF);\n border-bottom-style: var(--rtb-toolbar-border-style, solid);\n border-bottom-width: var(--rtb-toolbar-border-width, 1px);\n border-bottom-color: var(--rtb-toolbar-border-color, #EEE);\n border-radius: var(--rtb-toolbar-border-radius, 0px);\n padding-left: 3px;\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n}\n.rich-text-box-tool-bar button {\n background-color: var(--rtb-btn-bg, inherit);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n transition: 0.3s;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-tool-bar button:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-tool-bar button.selected {\n background-color: var(--rtb-btn-bg-selected, #dcdcdc);\n border-color: var(--rtb-btn-border-selected, inherit);\n}\n.rich-text-box-tool-bar button:disabled {\n background-color: transparent;\n color: #999;\n cursor: default;\n}\n.rich-text-box-tool-bar button svg {\n fill: var(--rtb-btn-text, #000);\n width: var(--rtb-btn-size, 16px);\n height: var(--rtb-btn-size, 16px);\n}\n.rich-text-box-tool-bar button:hover svg {\n fill: var(--rtb-btn-text, #000);\n}\n.rich-text-box-tool-bar button:disabled svg {\n fill: #999;\n}\n.rich-text-box-menu-item {}\n.rich-text-box-menu-item-special {}\n.rich-text-box-menu-item svg,\n.rich-text-box-menu-item-special svg {\n display: block;\n height: auto;\n width: auto;\n max-height: 100%;\n max-width: 100%;\n}\n.rich-text-box-menu-item:disabled { color: #999; }\n\n.rich-text-box-container {\n resize: both;\n overflow: var(--rtb-editor-resize, auto);\n border-style: var(--rtb-editor-border-style, solid);\n border-width: var(--rtb-editor-border-width, 1px);\n border-color: var(--rtb-editor-border-color, #EEE);\n border-radius: var(--rtb-editor-border-radius, 0px);\n box-shadow: var(--rtb-editor-shadow, none);\n max-width: var(--rtb-editor-width, 100%);\n height: var(--rtb-editor-height, 300px);\n display: flex;\n flex-direction: column;\n z-index: var(--rtb-z-index, 1);\n}\n.rich-text-box-content-container {\n width: 100%;\n height: 100%;\n overflow: auto;\n display: flex;\n flex-direction: row;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n}\n.rtb-status-bar {\n /* Mirror the toolbar\'s background and typography so every theme is\n automatically reflected without adding status-bar-specific CSS vars. */\n background-color: var(--rtb-toolbar-bg, #ffffff);\n color: var(--rtb-btn-text, #242424);\n font-family: var(--rtb-btn-font, Arial, Helvetica, Verdana, sans-serif);\n font-size: calc(var(--rtb-btn-size, 16px) * 0.9);\n border-top: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n padding: 5px 24px 5px 10px;\n text-align: right;\n user-select: none;\n flex-shrink: 0;\n letter-spacing: 0.2px;\n}\n.rich-text-box-content[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--rtb-placeholder-color, #9ca3af);\n pointer-events: none;\n font-style: italic;\n}\n.rich-text-box-content[contenteditable="false"] {\n cursor: default;\n opacity: 0.85;\n}\n.rich-text-box-content {\n color: var(--rtb-content-text, #000);\n font-size: var(--rtb-content-size, 16px);\n font-family: var(--rtb-content-font, Arial, sans-serif);\n line-height: var(--rtb-content-line-height, 1.55);\n padding: var(--rtb-content-padding, 20px 24px);\n width: 100%;\n min-height: 25px;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: 0px solid transparent;\n}\n.rich-text-box-content h1,\n.rich-text-box-content h2,\n.rich-text-box-content h3,\n.rich-text-box-content h4,\n.rich-text-box-content h5,\n.rich-text-box-content h6 {\n color: var(--rtb-heading-text, var(--rtb-content-text, #242424));\n font-family: var(--rtb-heading-font, var(--rtb-content-font, Arial, sans-serif));\n font-weight: var(--rtb-heading-weight, 600);\n line-height: var(--rtb-heading-line-height, 1.2);\n margin: var(--rtb-heading-margin, 0 0 0.55em);\n padding: 0;\n border: 0;\n border-bottom: 0;\n text-decoration: none !important;\n}\n.rich-text-box-content h1 { font-size: var(--rtb-h1-size, 2.15em); }\n.rich-text-box-content h2 { font-size: var(--rtb-h2-size, 1.65em); }\n.rich-text-box-content h3 { font-size: var(--rtb-h3-size, 1.35em); }\n.rich-text-box-content h4 { font-size: var(--rtb-h4-size, 1.15em); }\n.rich-text-box-content h5 { font-size: var(--rtb-h5-size, 1em); }\n.rich-text-box-content h6 {\n color: var(--rtb-heading-muted-text, #6b7280);\n font-size: var(--rtb-h6-size, 0.92em);\n}\n.rich-text-box-content p { margin: var(--rtb-paragraph-margin, 0 0 0.9em); }\n.rich-text-box-content ul,\n.rich-text-box-content ol {\n margin: var(--rtb-list-margin, 0.35em 0 0.9em 1.35em);\n padding-left: var(--rtb-list-padding-left, 1.35em);\n}\n.rich-text-box-content li { margin: var(--rtb-list-item-margin, 0.18em 0); }\n.rich-text-box-content a {\n color: var(--rtb-link-text, #0969da);\n text-decoration: var(--rtb-link-decoration, underline);\n}\n.rich-text-box-content blockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\n.rich-text-box-content blockquote > :first-child {\n margin-top: 0;\n}\n.rich-text-box-content blockquote > :last-child {\n margin-bottom: 0;\n}\n.rich-text-box-content code {\n background: var(--rtb-inline-code-bg, rgba(175, 184, 193, 0.2));\n border-radius: var(--rtb-inline-code-border-radius, 4px);\n font-family: var(--rtb-code-font, Consolas, Monaco, \'Courier New\', monospace);\n font-size: var(--rtb-inline-code-size, 0.92em);\n padding: var(--rtb-inline-code-padding, 0.15em 0.35em);\n}\n.rich-text-box-content pre {\n background: var(--rtb-code-bg, #f5f5f5);\n border-radius: var(--rtb-code-border-radius, 4px);\n margin: var(--rtb-code-margin, 1.2em 0);\n overflow-x: auto;\n padding: var(--rtb-code-padding, 0.85em 1em);\n white-space: pre-wrap;\n}\n.rich-text-box-content pre code {\n background: transparent;\n border-radius: 0;\n display: block;\n padding: 0;\n}\n.rich-text-box-content hr {\n border: 0;\n border-top: var(--rtb-hr-border, 1px solid #d1d1d1);\n margin: var(--rtb-hr-margin, 1.25em 0);\n}\n.rich-text-box-content table {\n border-collapse: collapse;\n margin: var(--rtb-table-margin, 1.2em 0);\n width: var(--rtb-table-width, auto);\n}\n.rich-text-box-content th,\n.rich-text-box-content td {\n border: var(--rtb-table-border, 1px solid #d1d1d1);\n min-width: var(--rtb-table-cell-min-width, 100px);\n padding: var(--rtb-table-cell-padding, 6px 10px);\n}\n.rich-text-box-content th {\n background: var(--rtb-table-header-bg, #f5f5f5);\n color: var(--rtb-table-header-text, var(--rtb-content-text, #242424));\n font-weight: var(--rtb-table-header-weight, 600);\n}\n.rich-text-box-content img { cursor: pointer; }\n.rich-text-box-source {\n padding: 10px;\n width: 100%;\n min-height: 25px;\n color: var(--rtb-content-text, #000) !important;\n font-size: var(--rtb-content-size, 16px) !important;\n white-space: pre-wrap;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n border-style: none;\n display: none;\n resize: none;\n margin: 0;\n line-height: 1.6;\n outline: 0px solid transparent;\n}\n.rich-text-box-divider-btn {\n background-color: inherit;\n align-items: center;\n justify-content: center;\n text-align: center;\n border: none !important;\n outline: none;\n cursor: pointer;\n padding: 3px 4px;\n transition: 0.3s;\n margin: 4px 1px;\n}\n.rich-text-box-divider-btn[disabled],\n.rich-text-box-divider-btn[disabled]:hover,\n.rich-text-box-divider-btn[disabled]:focus,\n.rich-text-box-divider-btn[disabled]:active {\n background: unset;\n color: unset;\n cursor: default;\n}\n.rich-text-box-divider {\n min-height: 25px;\n height: var(--rtb-btn-size, 16px);\n background-color: var(--rtb-btn-text, #000);\n display: block;\n border-left: 0.5px solid rgba(255, 255, 255, 0.6);\n opacity: 0.5;\n}\n.rich-text-box-scroll::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n opacity: var(--rtb-scroll-opacity, 1);\n}\n.rich-text-box-scroll::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n cursor: default;\n}\n.rich-text-box-dropdown { position: relative; display: inline-block; }\n.rich-text-box-dropdown-content {\n display: none;\n position: absolute;\n background-color: var(--rtb-dropdown-bg, #FFF);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: 5px;\n max-height: 200px;\n overflow: auto;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2);\n font-family: Arial, sans-serif !important;\n z-index: 2;\n}\n.rich-text-box-dropdown-btn {\n font-size: var(--rtb-btn-size, 16px);\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n padding: 0 10px;\n}\n.rich-text-box-format-button {}\n.rich-text-box-format-content { min-width: 185px; }\n.rich-text-box-font-button {}\n.rich-text-box-font-content { min-width: 180px; }\n.rich-text-box-size-button {}\n.rich-text-box-size-content { min-width: 80px; }\n.rich-text-box-dropdown-content a {\n color: var(--rtb-dropdown-text, #000);\n font-size: 18px;\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n}\n.rich-text-box-dropdown a:hover,\n.rich-text-box-menu-item.active {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rich-text-box-show { display: block; }\n\n.rich-text-box-modal {\n background-color: var(--rtb-modal-bg, #fefefe);\n color: var(--rtb-modal-text, #000);\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n margin: auto;\n padding: 6px 16px 14px;\n border: 1px solid #888;\n width: 800px;\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);\n border-radius: 5px;\n user-select: none;\n z-index: 2;\n}\n.rich-text-box-modal-title {\n font-weight: bold;\n font-size: calc(var(--rtb-modal-text-size, 16px) + 2px);\n}\n.rtb-modal-header {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n padding-bottom: 10px;\n}\n.rich-text-box-form-left { float: left; width: 380px; }\n.rich-text-box-form-right { float: right; width: 380px; }\n@media screen and (max-width: 850px) {\n .rich-text-box-form-left,\n .rich-text-box-form-right { float: none; }\n .rich-text-box-modal { width: 400px; }\n}\n@media screen and (max-width: 500px) {\n .rich-text-box-modal { width: 100%; }\n}\n.clearfix { overflow: auto; }\n.clearfix::after { content: ""; clear: both; display: table; }\n.rich-text-box-modal-close {\n appearance: none;\n background: none;\n border: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n align-self: center;\n width: 32px;\n height: 32px;\n min-width: 32px;\n min-height: 32px;\n max-width: 32px;\n max-height: 32px;\n border-radius: 50%;\n padding: 0;\n color: var(--rtb-modal-text, #000);\n cursor: pointer;\n opacity: 0.75;\n}\n/* SVG icon inside the close button — block display eliminates inline\n baseline offset so the flex centering acts on the icon bounds only.\n Width/height are set via CSS (not just SVG attributes) so the size is\n reliably enforced regardless of browser presentation-attribute handling. */\n.rich-text-box-modal-close svg { display: block; width: 11px; height: 11px; }\n.rich-text-box-modal-close:hover {\n opacity: 1;\n background: rgba(128, 128, 128, 0.18);\n}\n.rich-text-box-modal-close:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n.rich-text-box-modal-body { padding: 2px 8px; }\n.rtb-preview-window {\n flex: 1;\n min-height: 0;\n width: 100%;\n overflow: auto;\n border: 1px solid var(--rtb-editor-border-color, #eee);\n border-radius: 4px;\n box-sizing: border-box;\n display: block;\n}\n.rtb-preview-window::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-preview-window::-webkit-scrollbar-track { background: transparent; }\n.rtb-preview-window::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-preview-window::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n/* Preview dialog — flex column layout so the dialog itself is resizable and\n the html viewer automatically fills the remaining space.\n display is intentionally NOT set here so the browser UA rule\n dialog:not([open]){display:none} still applies when the dialog is closed.\n display:flex is only added when the dialog is open (has the [open] attr). */\n.rtb-preview-dialog {\n padding: 6px 12px 10px;\n flex-direction: column;\n height: 520px;\n min-width: 400px;\n min-height: 300px;\n max-width: 95vw;\n max-height: 95vh;\n resize: both;\n overflow: hidden;\n box-sizing: border-box;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n}\n.rtb-preview-dialog[open] {\n display: flex;\n}\n.rtb-preview-dialog::backdrop {\n background: transparent;\n}\n.rtb-preview-dialog-body {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n overflow: hidden;\n gap: 6px;\n}\n.rich-text-box-form-element {\n width: 100%;\n padding: 10px;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px;\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0;\n border-radius: 0px;\n box-sizing: border-box;\n margin-top: 0px;\n margin-bottom: 16px;\n resize: vertical;\n}\n.rich-text-box-form-element:disabled {\n color: #999;\n border-color: #DDD;\n cursor: default;\n}\n.rich-text-box-form-checkbox {\n outline: none;\n width: 20px;\n height: 20px;\n margin-right: 8px;\n accent-color: var(--rtb-modal-checkbox, #007bff);\n}\n.rich-text-box-form-checkbox:focus {\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n border-width: 1px;\n box-shadow: 0 0 5px 2px rgba(169, 169, 169, 0.8);\n}\n.rich-text-box-upload-btn {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n transition: 0.3s;\n background-color: var(--rtb-btn-bg, inherit);\n border: 1px solid var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n min-width: 100% !important;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-upload-btn:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-form-button {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n transition: 0.3s;\n}\n.rich-text-box-form-button:focus {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.blazing-rich-text-color-picker-container { position: relative; }\n.blazing-rich-text-color-picker-button { min-height: calc(var(--rtb-btn-size, 16px) + 14px); }\n.blazing-rich-text-color-picker-dropdown { width: 80px; padding: 10px 10px 6px 10px; }\n.blazing-rich-text-color-option {\n width: 15px; height: 15px; margin: 2px; cursor: pointer;\n display: inline-block; border: 1px solid #999;\n}\n.blazing-rich-text-color-option:hover { border-color: #000; }\n.blazing-rich-text-color-selection {\n width: 100%; border-style: solid; border-width: 1px; border-color: #999;\n height: 40px; cursor: pointer; display: inline-block;\n}\n.rich-text-box-quote { font-family: var(--rtb-modal-text-font, Arial, sans-serif); }\n.rich-text-box-code { overflow: auto !important; white-space: pre; }\n.rich-text-box-message-bar {\n font-size: var(--rtb-content-size, 16px);\n background-color: rgba(0, 0, 0, 0.6);\n color: white;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 5px 10px;\n opacity: 1;\n transform: translateY(0);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n pointer-events: auto;\n}\n.rich-text-box-message-bar.rich-text-box-message-hidden {\n opacity: 0; height: 0; padding: 0; color: transparent; pointer-events: none;\n}\n.rich-text-box-message {}\n.rich-text-box-message-close-button {\n background: none; border: none; color: white; font-size: 18px; cursor: pointer;\n}\n.rich-text-box-color-picker { width: 100%; }\n.rich-text-box-color-display { width: 100%; height: 50px; border: 1px solid #ccc; margin: 20px 0; }\n.rich-text-box-slider-container { display: flex; align-items: center; margin-bottom: 10px; }\n.rich-text-box-slider-container label {\n width: 20px; margin-right: 10px;\n color: var(--rtb-modal-text, #000);\n}\n.rich-text-box-range { width: 100%; -webkit-appearance: none; cursor: pointer; }\n.rich-text-box-range:focus { outline: none; }\n.rich-text-box-range::-webkit-slider-runnable-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-red-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(255,0,0) 100%) !important;\n}\n.rich-text-box-green-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,255,0) 100%) !important;\n}\n.rich-text-box-blue-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,0,255) 100%) !important;\n}\n.rich-text-box-range::-moz-range-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-range::-webkit-slider-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-range::-moz-range-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-number {\n width: 100px; margin-left: 10px; padding: 5px; font-size: 14px;\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px; border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0; border-radius: 0px; box-sizing: border-box;\n}\n.rich-text-box-hex-container { display: flex; align-items: center; margin-top: 20px; }\n.rich-text-box-hex-input { width: 100px !important; margin-left: 10px; }\nblockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\npre {\n background: var(--rtb-code-bg, #f9f9f9);\n border-radius: var(--rtb-code-border-radius, 10px);\n overflow-x: auto; white-space: pre-wrap; margin: 1.5em 10px; padding: 0.5em 10px;\n}\ntable { border-collapse: collapse; }\ntd, th { border: 1px solid #ccc; padding: 4px 6px; height: 25px; min-width: 100px; }\n',{invokeMethodAsync:(t,e)=>onValueChange(e)}),RTNative_Instances[this._uid]._rtbHostElement=this;const i=this.getAttribute("aria-label")||this.getAttribute("label");i&&RTNative_Instances[this._uid].content.setAttribute("aria-label",i);const n=this.getAttribute("placeholder");n&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",n),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid].loadHtml(o),this._initialized=!0,this._syncToInstance(),this._applyContentStyles()}_reinitialize(){const t=this.getValue();delete RTNative_Instances[this._uid],this._initialized=!1,this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._render(),requestAnimationFrame(()=>{this._initialize(),t&&this.setValue(t)})}_svg(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="${m[t]}"/></svg>`}_btn(t,e,o,i,n){return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==n?`RTNative_Method('${i}','${this._uid}','${n}')`:`RTNative_Method('${i}','${this._uid}')`}">${this._svg(e)}</button>`}_specialBtn(t,e,o,i){return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${i}','${this._uid}')">${this._svg(e)}</button>`}_divider(){return'<button class="rich-text-box-divider-btn" disabled><div class="rich-text-box-divider"></div></button>'}_fontDropdown(){const t=this._uid,e=["None","Arial","Arial Narrow","Baskerville","Brush Script","Calibri","Cambria","Candara","Century Gothic","Claude Garamond","Comic Sans MS","Copperplate","Courier","Didot","Georgia","Gill Sans","Helvetica","Impact","Lucida Bright","Monospace","Optima","Palatino","Segoe UI","Tahoma","Times New Roman","Trebuchet MS","Verdana"].map(e=>`<a class="rich-text-box-menu-item" style="font-family:${e};cursor:pointer" onclick="RTNative_Method('font','${t}','${e}')">${e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-font-button" title="Font" class="rich-text-box-font-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-font-button-dropdown')">Font</button>\n <div id="blazing-rich-text-font-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-font-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_sizeDropdown(){const t=this._uid,e=["None","8","9","10","11","12","14","16","18","20","22","24","26","28","36","48","64"].map(e=>`<a class="rich-text-box-menu-item" style="${"None"===e?"":`font-size:${e}px !important;`}cursor:pointer" onclick="RTNative_Method('size','${t}','${"None"===e?"None":`${e}px`}')">${"None"===e?"None":e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-size-button" title="Size (Ctrl+Shift+[&lt;,&gt;])" class="rich-text-box-size-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-size-button-dropdown')">Size</button>\n <div id="blazing-rich-text-size-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-size-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_formatDropdown(){const t=this._uid;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-format-button" title="Format (Ctrl+Shift+[D,P,1,2...])" class="rich-text-box-format-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-format-button-dropdown')">Format</button>\n <div id="blazing-rich-text-format-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-format-content rich-text-box-scroll">\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','none')">None</a>\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','p')">Paragraph</a>\n <a class="rich-text-box-menu-item" style="font-size:34px;cursor:pointer" onclick="RTNative_Method('format','${t}','h1')">Header 1</a>\n <a class="rich-text-box-menu-item" style="font-size:30px;cursor:pointer" onclick="RTNative_Method('format','${t}','h2')">Header 2</a>\n <a class="rich-text-box-menu-item" style="font-size:24px;cursor:pointer" onclick="RTNative_Method('format','${t}','h3')">Header 3</a>\n <a class="rich-text-box-menu-item" style="font-size:20px;cursor:pointer" onclick="RTNative_Method('format','${t}','h4')">Header 4</a>\n <a class="rich-text-box-menu-item" style="font-size:18px;cursor:pointer" onclick="RTNative_Method('format','${t}','h5')">Header 5</a>\n <a class="rich-text-box-menu-item" style="font-size:16px;cursor:pointer" onclick="RTNative_Method('format','${t}','h6')">Header 6</a>\n </div>\n</div>`}_colorSwatches(t){return["#FFFFFF","#DCDCDC","#A9A9A9","#696969","#303030","#000000","#FFCCCC","#FF6666","#FF3333","#FF0000","#CC0000","#990000","#800000","#CCFFCC","#99FF99","#66FF66","#33CC33","#009900","#CCCCFF","#9999FF","#6666FF","#3333CC","#000099","#002060","#FFFFCC","#FFFF99","#FFFF66","#CCCC33","#999900","#CCFFFF","#99FFFF","#66FFFF","#33CCCC","#009999","#FFCCFF","#FF99FF","#FF66FF","#CC33CC","#990099","#FFDDCC","#FFBB99","#FF9966","#FF7733","#CC4400","#E0CCFF","#C199FF","#A366FF","#8533FF","#6600CC"].map(e=>`<div class="blazing-rich-text-color-option" onclick="RTNative_Method('${t}','${this._uid}','${e}')" style="background-color:${e};"></div>`).join("")}_colorDialog(t,e,o,i){const n=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${n}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div class="rich-text-box-color-picker">\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n ${this._colorSwatches(o)}\n <div class="rich-text-box-color-display"></div>\n </div>\n <div class="rich-text-box-form-right">\n <div class="rich-text-box-slider-container">\n <label>R</label>\n <input type="range" class="rich-text-box-range rich-text-box-red-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-red-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>G</label>\n <input type="range" class="rich-text-box-range rich-text-box-green-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-green-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>B</label>\n <input type="range" class="rich-text-box-range rich-text-box-blue-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-blue-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-hex-container">\n <label>Hex:</label>\n <input type="text" class="rich-text-box-form-element rich-text-box-hex-input" value="#000000" autocomplete="off">\n </div>\n </div>\n </div>\n <div style="text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${n}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${i}','${n}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(t,e,o,i){const n=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${n}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div>\n ${i}\n <div style="margin-top:5px;text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${n}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${o}','${n}')">OK</button>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const t=this._uid,e=this._visibility,o=(e.font||e.size||e.format)&&e.textStylesDivider,i=(e.bold||e.italic||e.underline||e.strikethrough||e.subscript||e.superscript)&&e.formatDivider,n=e.textColor&&e.textColorDivider,r=(e.alignLeft||e.alignCenter||e.alignRight||e.alignJustify)&&e.alignDivider,s=(e.copy||e.cut||e.paste||e.delete||e.selectAll)&&e.actionDivider,l=(e.orderedList||e.unorderedList||e.indent)&&e.listDivider,a=(e.link||e.image||e.imageUpload||e.quote||e.codeBlock||e.embedMedia||e.video||e.table||e.horizontalRule)&&e.mediaDivider,c=(e.undo||e.redo)&&e.historyDivider;return`\n<div id="${t}_Toolbar" class="rich-text-box-tool-bar" role="toolbar" aria-label="Formatting toolbar">\n\n ${e.font?this._fontDropdown():""}\n ${e.size?this._sizeDropdown():""}\n ${e.format?this._formatDropdown():""}\n ${o?this._divider():""}\n\n ${e.bold?this._btn("blazing-rich-text-bold-button","Bold","Bold (Ctrl+B)","bold"):""}\n ${e.italic?this._btn("blazing-rich-text-italic-button","Italic","Italic (Ctrl+I)","italic"):""}\n ${e.underline?this._btn("blazing-rich-text-underline-button","Underline","Underline (Ctrl+U)","underline"):""}\n ${e.strikethrough?this._btn("blazing-rich-text-strike-button","Strikethrough","Strikethrough (Ctrl+D)","strikethrough"):""}\n ${e.subscript?this._btn("blazing-rich-text-sub-button","Subscript","Subscript (Ctrl+=)","subscript"):""}\n ${e.superscript?this._btn("blazing-rich-text-super-button","Superscript","Superscript (Ctrl+Shift++)","superscript"):""}\n ${i?this._divider():""}\n\n ${e.textColor?this._btn("blazing-rich-text-textcolor-button","TextColor","Text Color (Ctrl+Shift+C)","openTextColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-text-bg-color-button","TextBackgroundColor","Text Background Color (Ctrl+Shift+B)","openTextBackgroundColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-textcolor-remove-button","RemoveTextFormat","Remove Color","removeTextColor"):""}\n ${n?this._divider():""}\n\n ${e.alignLeft?this._btn("blazing-rich-text-alignleft-button","Alignleft","Align Left (Ctrl+L)","alignleft"):""}\n ${e.alignCenter?this._btn("blazing-rich-text-aligncenter-button","Aligncenter","Align Center (Ctrl+E)","aligncenter"):""}\n ${e.alignRight?this._btn("blazing-rich-text-alignright-button","Alignright","Align Right (Ctrl+R)","alignright"):""}\n ${e.alignJustify?this._btn("blazing-rich-text-alignjustify-button","Alignjustify","Align Justify (Ctrl+J)","alignjustify"):""}\n ${r?this._divider():""}\n\n ${e.cut?this._btn("blazing-rich-text-cut-button","Cut","Cut (Ctrl+X)","cut"):""}\n ${e.copy?this._btn("blazing-rich-text-copy-button","Copy","Copy (Ctrl+C)","copy"):""}\n ${e.paste?this._btn("blazing-rich-text-paste-button","Paste","Paste (Ctrl+V)","paste"):""}\n ${e.delete?this._btn("blazing-rich-text-delete-button","Delete","Delete","delete"):""}\n ${e.selectAll?this._btn("blazing-rich-text-selectall-button","Selectall","Select All (Ctrl+A)","selectall"):""}\n ${s?this._divider():""}\n\n ${e.orderedList?this._btn("blazing-rich-text-orderedlist-button","OrderedList","Ordered List (Ctrl+Shift+O)","orderedlist"):""}\n ${e.unorderedList?this._btn("blazing-rich-text-unorderedlist-button","UnorderedList","Unordered List (Ctrl+Shift+U)","unorderedlist"):""}\n ${e.indent?this._btn("blazing-rich-text-increase-indent-button","IncreaseIndent","Increase Indent (Tab)","increaseIndent"):""}\n ${e.indent?this._btn("blazing-rich-text-decrease-indent-button","DecreaseIndent","Decrease Indent (Shift+Tab)","decreaseIndent"):""}\n ${l?this._divider():""}\n\n ${e.link?this._btn("blazing-rich-text-link-button","CreateLink","Insert Link (Ctrl+Shift+K)","openLinkDialog"):""}\n ${e.link?this._btn("blazing-rich-text-remove-link-button","RemoveLink","Remove Link","removeLink"):""}\n ${e.image?this._btn("blazing-rich-text-image-button","Image","Insert Image (Ctrl+Shift+I)","openImageDialog"):""}\n ${e.imageUpload?this._btn("blazing-rich-text-image-upload-button","UploadImage","Upload Image (Ctrl+Shift+&)","uploadImageDialog"):""}\n ${e.quote?this._btn("blazing-rich-text-quote-button","Quote","Block Quote (Ctrl+Shift+Q)","openBlockQuoteDialog"):""}\n ${e.embedMedia?this._btn("blazing-rich-text-embed-button","PermMedia","Insert Media (Ctrl+Shift+M)","openMediaDialog"):""}\n ${e.video?this._btn("blazing-rich-text-video-button","VideoFile","Insert Video (Ctrl+Shift+V)","openVideoDialog"):""}\n ${e.table?this._btn("blazing-rich-text-table-button","Table","Table (Ctrl+Shift+L)","openTableDialog"):""}\n ${e.codeBlock?this._btn("blazing-rich-text-code-block-button","CodeBlocks","Code Block (Ctrl+Shift+*)","openCodeBlockDialog"):""}\n ${e.horizontalRule?this._btn("blazing-rich-text-hr-button","HorizontalRule","Horizontal Rule (Ctrl+Shift+H)","insertHorizontalRule"):""}\n ${a?this._divider():""}\n\n ${e.undo?this._btn("blazing-rich-text-undo-button","Undo","Undo (Ctrl+Z)","goBack"):""}\n ${e.redo?this._btn("blazing-rich-text-redo-button","Redo","Redo (Ctrl+Y)","goForward"):""}\n ${c?this._divider():""}\n\n ${e.statusBarToggle?this._btn("blazing-rich-text-statusbar-button","StatusBar","Toggle Status Bar (Ctrl+\\)","toggleStatusBar"):""}\n ${e.saveHtml?this._specialBtn("blazing-rich-text-save-button","SaveHtml","Save HTML (Ctrl+Shift+S)","saveHtml"):""}\n ${e.htmlView?this._specialBtn("blazing-rich-text-source","Code","HTML Source (Ctrl+Shift+A)","toggleView"):""}\n ${e.preview?this._specialBtn("blazing-rich-text-preview-button","Preview","Preview (Ctrl+Shift+P)","openPreview"):""}\n\n ${this._colorDialog("rich-text-box-text-color-modal","Text Color","selectTextColor","insertTextColor")}\n ${this._colorDialog("rich-text-box-text-bg-color-modal","Text Background Color","selectTextBackgroundColor","insertTextBackgroundColor")}\n\n ${this._genericDialog("rich-text-box-table-modal","Table","insertTable",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Columns</label>\n <input type="number" id="rich-text-box-table-columns" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Rows</label>\n <input type="number" id="rich-text-box-table-rows" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n <label>Width</label>\n <input type="text" id="rich-text-box-table-width" class="rich-text-box-form-element" placeholder="500px">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-table-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-embed-modal","Media","insertMedia",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-source" placeholder="e.g., /documents/file.pdf" autocomplete="off">\n <label>Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-type" placeholder="e.g., audio/mp3, application/pdf" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-width" placeholder="450" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-height" placeholder="250" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-video-modal","Video","insertVideo",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source" placeholder="e.g., /videos/movie.mp4" autocomplete="off">\n <label>Source Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source-type" placeholder="e.g., video/mp4" autocomplete="off">\n <label>Poster Image URL</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-poster" placeholder="e.g., /images/poster.jpg" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-width" placeholder="640" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-height" placeholder="360" autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-css-classes" placeholder="class1 class2 class3">\n </div>\n <div style="clear:both;display:grid;grid-template-columns:1fr 1fr;gap:2px 20px;margin-top:10px;">\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-controls">\n Controls\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-autoplay">\n Autoplay\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-loop">\n Loop\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-muted">\n Muted\n </label>\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-code-block-modal","Code Block","insertCodeBlock",'\n <div class="clearfix">\n <label>Code Block</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-code rich-text-box-scroll" id="rich-text-box-code" spellcheck="false"></textarea>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-code-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-block-quote-modal","Block Quote","insertBlockQuote",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Quote</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-quote rich-text-box-scroll" id="rich-text-box-quote"></textarea>\n </div>\n <div class="rich-text-box-form-right">\n <label>Cite</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-cite" placeholder="https://www..." autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-quote-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-image-modal","Image","insertImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-webaddress" placeholder="https://www..." autocomplete="off">\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-upload-image-modal","Upload / Embed Image","uploadImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <div style="height:40px;padding:20px 0 10px 0;">\n <input type="file" id="rich-text-box-upload-image-file" hidden>\n <label for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn">Choose File</label>\n <span id="rich-text-box-upload-image-file-chosen">No file chosen</span>\n </div>\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-link-modal","Link","insertLink",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-webaddress" placeholder="https://www..." autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Link Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-linktext" autocomplete="off">\n <label style="display:flex;align-items:center;margin-bottom:12px;">\n <input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox">\n Open in New Tab\n </label>\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n\n ${this._buildPreviewDialogHTML()}\n\n</div>`}_buildPreviewDialogHTML(){const t=this._uid;return`\n<dialog id="${t}_Preview" class="rich-text-box-modal rich-text-box-scroll rtb-preview-dialog" aria-modal="true" aria-labelledby="${t}_Preview-title">\n <div class="rtb-modal-header">\n <div id="${t}_Preview-title" class="rich-text-box-modal-title">Preview</div>\n <div style="display:flex;gap:2px;align-items:center;">\n <button id="${t}_PreviewMaxBtn" class="rich-text-box-modal-close" aria-label="Maximize preview" onclick="RTNative_Method('togglePreviewMaximize','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="11" height="11" style="display:block"><path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg></button>\n <button class="rich-text-box-modal-close" aria-label="Close preview" onclick="RTNative_Method('closePreview','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n </div>\n <div class="rtb-preview-dialog-body">\n <div id="rich-text-box-preview" class="rtb-preview-window"></div>\n <div style="text-align:right;flex-shrink:0;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closePreview','${t}')">Close</button>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",x);
1
+ class t{constructor(t,e,o,i,n){this.id=t,this.shadow_id=e,this.toolbar_id=o,this.styles=i,this.dotNetObjectReference=n,this.init()}init=()=>{this.hydrateShadowTree(),this.Utilities=new r(this.shadowRoot,this.content),this.NodeManager=new o(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new n(this.shadowRoot,this.content,this.Utilities),this.ListProvider=new i(this.shadowRoot,this.content,this.Utilities,this.NodeManager),this.ColorPickers={};const t="rich-text-box-text-color-modal",m="rich-text-box-text-bg-color-modal";this.ColorPickers[t]=new g(this.shadowRoot,this.content,t,this.NodeManager,this.Utilities),this.ColorPickers[m]=new g(this.shadowRoot,this.content,m,this.NodeManager,this.Utilities),this.LinkDialog=new u(this.shadowRoot,this.content,this.Utilities),this.ImageDialog=new b(this.shadowRoot,this.content,this.Utilities),this.UploadImageDialog=new h(this.shadowRoot,this.content,this.Utilities),this.BlockQuoteDialog=new d(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new c(this.shadowRoot,this.content,this.Utilities),this.MediaDialog=new l(this.shadowRoot,this.content,this.Utilities),this.VideoDialog=new a(this.shadowRoot,this.content,this.Utilities),this.TableDialog=new s(this.shadowRoot,this.content,this.Utilities),this.StateManager=new e(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners()};hydrateShadowTree=()=>{const t=document.getElementById(this.shadow_id);this.shadowRoot=t.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=this.styles,this.shadowRoot.appendChild(e),this.contentContainer=document.createElement("div"),this.contentContainer.classList.add("rich-text-box-content-container","rich-text-box-scroll"),this.container=document.createElement("div"),this.container.classList.add("rich-text-box-container","rich-text-box-scroll"),this.content=document.createElement("div"),this.content.setAttribute("id",this.id),this.content.setAttribute("class","rich-text-box-content"),this.content.setAttribute("contenteditable","true"),this.content.setAttribute("role","textbox"),this.content.setAttribute("aria-multiline","true"),this.content.setAttribute("aria-label","Rich text editor"),this.content.setAttribute("aria-readonly","false"),this.content.style.display="block",this.source=document.createElement("textarea"),this.source.setAttribute("id","rich-text-box-source"),this.source.setAttribute("aria-label","HTML source"),this.source.classList.add("rich-text-box-source","rich-text-box-scroll"),this.source.style.display="none",this.source.spellcheck=!1;const o=document.createElement("div");o.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),o.setAttribute("id","rich-text-box-message-bar");const i=document.createElement("span");i.setAttribute("class","rich-text-box-message");const n=document.createElement("button");n.setAttribute("class","rich-text-box-message-close-button"),n.textContent="×",n.onclick=()=>{this.Utilities.closeFadingBar()},o.appendChild(i),o.appendChild(n),this.statusBar=document.createElement("div"),this.statusBar.className="rtb-status-bar",this.statusBar.setAttribute("role","status"),this.statusBar.setAttribute("aria-live","polite"),this.statusBar.setAttribute("aria-atomic","true"),this.statusBar.id="rich-text-box-status-bar",this.statusBar.textContent="0 words · 0 characters";const r=document.getElementById(this.toolbar_id);this.container.appendChild(r),this.contentContainer.appendChild(this.content),this.contentContainer.appendChild(this.source),this.container.appendChild(o),this.container.appendChild(this.contentContainer),this.container.appendChild(this.statusBar),this.shadowRoot.appendChild(this.container)};addEventListeners=()=>{document.addEventListener("selectionchange",t=>{const e=this.Utilities.getSelection();null!==e&&this.clearSettings(e.anchorNode)}),this.content.addEventListener("click",t=>{"A"===t.target.tagName&&(t.preventDefault(),t.stopPropagation())}),this.content.addEventListener("click",t=>{const e=t.target.tagName;if("VIDEO"===e||"SOURCE"===e){t.preventDefault();const o="SOURCE"===e?t.target.closest("video"):t.target;if(o&&o.parentNode===this.content){if(!o.nextSibling){const t=document.createElement("p");t.appendChild(document.createElement("br")),this.content.insertBefore(t,null)}const t=o.nextSibling,e=window.getSelection();if(e&&t){const o=document.createRange(),i=t.firstChild??t;o.setStart(i,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}}},!0),this.content.addEventListener("dblclick",t=>{const e=t.target.tagName;"VIDEO"!==e&&"SOURCE"!==e||t.preventDefault()},!0),this.content.addEventListener("dblclick",t=>{switch(t.target.tagName){case"A":t.preventDefault(),this.openLinkDialog();break;case"IMG":t.preventDefault();const e=this.Utilities.getSelection(),o=document.createRange();o.selectNodeContents(t.target),e.removeAllRanges(),e.addRange(o),t.target.src.startsWith("data")?this.uploadImageDialog():this.openImageDialog();break;case"VIDEO":case"SOURCE":{t.preventDefault();const e="SOURCE"===t.target.tagName?t.target.closest("video"):t.target;if(e){const t=this.Utilities.getSelection(),o=document.createRange();o.selectNode(e),t.removeAllRanges(),t.addRange(o),this.openVideoDialogForElement(e)}else this.openVideoDialog();break}case"BLOCKQUOTE":t.preventDefault(),this.openBlockQuoteDialogForElement(t.target);break;case"PRE":t.preventDefault(),this.openCodeBlockDialogForElement(t.target);break;case"CODE":{const e=t.target.closest("pre");e&&this.content.contains(e)&&(t.preventDefault(),this.openCodeBlockDialogForElement(e));break}default:{const e=t.target.closest("pre");if(e&&this.content.contains(e)){t.preventDefault(),this.openCodeBlockDialogForElement(e);break}const o=t.target.closest("blockquote");o&&this.content.contains(o)&&(t.preventDefault(),this.openBlockQuoteDialogForElement(o));break}}}),this.content.addEventListener("input",t=>{this.updateWordCount();const e=this.Utilities.getSelection(),o=e.getRangeAt(0).startContainer;if(o.nodeType===Node.TEXT_NODE&&"SPAN"===o.parentNode.tagName){const t=o.parentNode,i=t.parentNode;if(this.NodeManager.isFormatElement(i)){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t);const o=document.createRange();o.setStart(i.firstChild,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}}),this.content.addEventListener("keydown",t=>{this.keyEvents(t)}),this.source.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),!0===this.EditMode?this.getHtml():this.getCode()),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar())});this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(t=>{t.addEventListener("mousedown",t=>{t.preventDefault()})})};goBack=()=>{this.StateManager.goBack(),this.NodeManager.refreshUI(),this.updateWordCount()};goForward=()=>{this.StateManager.goForward(),this.NodeManager.refreshUI(),this.updateWordCount()};clearSettings=t=>{this.fontSize=void 0,this.NodeManager.selectButtons(t)};keyEvents=t=>{if(this.NodeManager.createDefaultElement(),!1===this.EditMode)return t.ctrlKey&&"z"===t.key&&t.preventDefault(),void(t.ctrlKey&&"y"===t.key&&t.preventDefault());if("Enter"===t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey){if(this.TableDialog.addRowFromLastCell())return void t.preventDefault();if(this.insertParagraphAfterStructuredBlock())return void t.preventDefault()}if(t.ctrlKey&&"b"===t.key&&(t.preventDefault(),this.bold()),t.ctrlKey&&"i"===t.key&&(t.preventDefault(),this.italic()),t.ctrlKey&&"u"===t.key&&(t.preventDefault(),this.underline()),t.ctrlKey&&"d"===t.key&&(t.preventDefault(),this.strikethrough()),t.ctrlKey&&"c"===t.key&&(t.preventDefault(),this.copy()),t.ctrlKey&&"x"===t.key&&(t.preventDefault(),this.cut()),t.ctrlKey&&"v"===t.key&&(t.preventDefault(),this.paste()),"Delete"===t.key||46===t.keyCode){const e=this.Utilities.getSelection();null!==e&&e.toString().length>0&&(t.preventDefault(),this.delete())}if(t.ctrlKey&&"="===t.key&&(t.preventDefault(),this.subscript()),t.ctrlKey&&t.shiftKey&&"+"===t.key&&(t.preventDefault(),this.superscript()),t.ctrlKey&&"l"===t.key&&(t.preventDefault(),this.alignleft()),t.ctrlKey&&"e"===t.key&&(t.preventDefault(),this.aligncenter()),t.ctrlKey&&"r"===t.key&&(t.preventDefault(),this.alignright()),t.ctrlKey&&"j"===t.key&&(t.preventDefault(),this.alignjustify()),t.ctrlKey&&"a"===t.key&&(t.preventDefault(),this.selectall()),t.ctrlKey&&"z"===t.key&&(t.preventDefault(),this.goBack()),t.ctrlKey&&"y"===t.key&&(t.preventDefault(),this.goForward()),t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),this.toggleView()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&t.shiftKey&&"&"===t.key&&(t.preventDefault(),this.uploadImageDialog()),t.ctrlKey&&t.shiftKey&&"U"===t.key&&(t.preventDefault(),this.unorderedlist()),t.ctrlKey&&t.shiftKey&&"O"===t.key&&(t.preventDefault(),this.orderedlist()),t.ctrlKey&&t.shiftKey&&">"===t.key&&(t.preventDefault(),this.changeFontSize(!0)),t.ctrlKey&&t.shiftKey&&"<"===t.key&&(t.preventDefault(),this.changeFontSize(!1)),t.ctrlKey&&t.shiftKey&&"C"===t.key&&(t.preventDefault(),this.openTextColorDialog()),t.ctrlKey&&t.shiftKey&&"B"===t.key&&(t.preventDefault(),this.openTextBackgroundColorDialog()),t.ctrlKey&&t.shiftKey&&"K"===t.key&&(t.preventDefault(),this.openLinkDialog()),t.ctrlKey&&t.shiftKey&&"*"===t.key&&(t.preventDefault(),this.openCodeBlockDialog()),t.ctrlKey&&t.shiftKey&&"Q"===t.key&&(t.preventDefault(),this.openBlockQuoteDialog()),t.ctrlKey&&t.shiftKey&&"I"===t.key&&(t.preventDefault(),this.openImageDialog()),t.ctrlKey&&t.shiftKey&&"M"===t.key&&(t.preventDefault(),this.openMediaDialog()),t.ctrlKey&&t.shiftKey&&"L"===t.key&&(t.preventDefault(),this.openTableDialog()),t.ctrlKey&&t.shiftKey&&"D"===t.key&&(t.preventDefault(),this.format("none")),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"!"===t.key&&(t.preventDefault(),this.format("h1")),t.ctrlKey&&t.shiftKey&&"@"===t.key&&(t.preventDefault(),this.format("h2")),t.ctrlKey&&t.shiftKey&&"#"===t.key&&(t.preventDefault(),this.format("h3")),t.ctrlKey&&t.shiftKey&&"$"===t.key&&(t.preventDefault(),this.format("h4")),t.ctrlKey&&t.shiftKey&&"%"===t.key&&(t.preventDefault(),this.format("h5")),t.ctrlKey&&t.shiftKey&&"^"===t.key&&(t.preventDefault(),this.format("h6")),t.ctrlKey&&t.shiftKey&&"V"===t.key&&(t.preventDefault(),this.openVideoDialog()),t.ctrlKey&&t.shiftKey&&"H"===t.key&&(t.preventDefault(),this.insertHorizontalRule()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar()),"Backspace"===t.key){const e=this.Utilities.getSelection();if(e&&e.isCollapsed){const o=e.getRangeAt(0),i=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"];let n=e.anchorNode;for(;n&&n!==this.content&&(n.nodeType!==Node.ELEMENT_NODE||!i.includes(n.nodeName));)n=n.parentNode;if(n&&n!==this.content){if((parseFloat(window.getComputedStyle(n).marginLeft)||0)>0){const e=document.createRange();e.setStart(n,0),e.setEnd(o.startContainer,o.startOffset),0===e.toString().length&&(t.preventDefault(),this.decreaseIndent())}}}}if(t.shiftKey&&"Tab"===t.key)t.preventDefault(),this.decreaseIndent();else if("Tab"===t.key){const e=this.Utilities.getSelection();if(null!==e&&null!=e.anchorNode&&e.anchorNode!==this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content)if("TD"===e.anchorNode.parentNode.nodeName)t.preventDefault(),this.TableDialog.tableTab();else t.preventDefault(),this.increaseIndent()}};isBreakable=t=>{let e=!1;switch(t){case"BLOCKQUOTE":case"CODE":case"P":case"SPAN":e=!0}return e};getStructuredBlockFromNode=t=>{if(!t||t===this.content)return null;const e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!e||!this.content.contains(e))return null;const o=e.closest("pre");if(o&&this.content.contains(o))return o;const i=e.closest("blockquote");return i&&this.content.contains(i)?i:null};insertParagraphAfterStructuredBlock=()=>{const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return!1;const e=this.getStructuredBlockFromNode(t.anchorNode);if(!e)return!1;const o=document.createElement("p");o.appendChild(document.createElement("br")),e.nextSibling?e.parentNode.insertBefore(o,e.nextSibling):e.parentNode.appendChild(o);const i=document.createRange();return i.setStart(o,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),this.content.focus(),!0};changeFontSize=t=>{if(void 0===this.fontSize){const t=this.Utilities.getSelection();if(null!==t&&t&&t.rangeCount>0){const e=t.getRangeAt(0),o=window.getComputedStyle(e.commonAncestorContainer.parentElement);this.fontSize=parseFloat(o.fontSize)}}t?this.fontSize+=1:this.fontSize-=1,this.NodeManager.updateNode("size",`${this.fontSize}px`)};openPreview=()=>{this.preview=this.shadowRoot.getElementById(`${this.id}_Preview`);const t=this.shadowRoot.getElementById("rich-text-box-preview");this.preview&&t&&(this.loadPreviewWindow(t),this.addPreviewEventListeners(this.preview),this.preview.showModal(),t.scrollTop=0,t.scrollLeft=0)};addPreviewEventListeners=t=>{t.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.closePreview()),"Escape"===t.key&&(t.preventDefault(),this.closePreview())})};loadPreviewWindow=t=>{const e="block"===this.content.style.display?this.html()||"":this.source.value||"",o=t.shadowRoot||t.attachShadow({mode:"open"});for(;o.firstChild;)o.removeChild(o.firstChild);const i=document.createElement("style");i.textContent=":host{display:block;position:relative;}iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none;}",o.appendChild(i);const n=(this._previewCssUrls||[]).filter(t=>t).map(t=>`<link rel="stylesheet" href="${t.replace(/"/g,"%22")}">`).join(""),r=this._previewCssText?`<style>${this._previewCssText}</style>`:"",s=this._rtbHostElement,l=s?getComputedStyle(s):null,getVar=(t,e)=>(l?l.getPropertyValue(t).trim():"")||e,a=["<style>","html,body{margin:0;}","body{"," padding:20px 24px;",` color:${getVar("--rtb-content-text","#242424")};`,` font-size:${getVar("--rtb-content-size","16px")};`,` font-family:${getVar("--rtb-content-font","Arial, Helvetica, Verdana, sans-serif")};`,` line-height:${getVar("--rtb-content-line-height","1.55")};`,` background-color:${getVar("--rtb-content-bg","#FFF")};`,"}",`blockquote{background:${getVar("--rtb-quote-bg","#f9f9f9")};border-left:${getVar("--rtb-quote-border-width","5px")} solid ${getVar("--rtb-quote-border-color","#ccc")};color:${getVar("--rtb-quote-text",getVar("--rtb-content-text","#242424"))};margin:1.5em 10px;padding:0.5em 10px;}`,`pre{background:${getVar("--rtb-code-bg","#f9f9f9")};border-radius:${getVar("--rtb-code-border-radius","10px")};overflow-x:auto;white-space:pre-wrap;margin:1.5em 10px;padding:0.5em 10px;}`,"table{border-collapse:collapse;}","td,th{border:1px solid #ccc;padding:4px 6px;height:25px;min-width:100px;}","</style>"].join(""),c=document.createElement("iframe");c.srcdoc=["<!DOCTYPE html><html><head>",'<meta charset="UTF-8">',a,n,r,"</head><body>",e,"</body></html>"].join(""),o.appendChild(c),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus(),this.content.focus()};togglePreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!t||!e)return;const o=!t.hasAttribute("data-maximized"),i=[["width","100vw"],["height","100vh"],["max-width","100vw"],["max-height","100vh"],["top","0"],["left","0"],["transform","none"],["border-radius","0"],["resize","none"]];o?(t.setAttribute("data-maximized",""),i.forEach(([e,o])=>t.style.setProperty(e,o))):(t.removeAttribute("data-maximized"),i.forEach(([e])=>t.style.removeProperty(e))),e.setAttribute("aria-label",o?"Restore preview":"Maximize preview"),e.querySelector("svg").innerHTML=o?'<path d="M4.5 1.5V4.5H1.5M7.5 10.5V7.5H10.5M4.5 4.5L1.5 1.5M7.5 7.5L10.5 10.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>':'<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>'};_resetPreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);t&&e&&(t.removeAttribute("data-maximized"),["width","height","max-width","max-height","top","left","transform","border-radius","resize"].forEach(e=>t.style.removeProperty(e)),e.setAttribute("aria-label","Maximize preview"),e.querySelector("svg").innerHTML='<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>')};insertHorizontalRule=()=>{const t=this.Utilities.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);e.deleteContents();let o=e.startContainer;if(o===this.content){const t=this.content.childNodes[e.startOffset]??null,o=document.createElement("hr");return this.content.insertBefore(o,t),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(document.createElement("hr")),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}));const i=document.createElement("hr");o&&o!==this.content&&this.content.contains(o)?this.content.insertBefore(i,o.nextSibling):this.content.appendChild(i),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};toggleStatusBar=()=>{if(!this.statusBar)return;const t="none"===this.statusBar.style.display,e=this.shadowRoot.getElementById("blazing-rich-text-statusbar-button");t?(this.statusBar.style.display="",e&&(e.classList.add("selected"),e.setAttribute("aria-pressed","true")),this.updateWordCount()):(this.statusBar.style.display="none",e&&(e.classList.remove("selected"),e.setAttribute("aria-pressed","false")))};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const t=this.content.innerText||"",e=t.trim(),o=e?e.split(/\s+/).length:0,i=t.replace(/\n/g,"").length;this.statusBar.textContent=`${o} word${1!==o?"s":""} · ${i} character${1!==i?"s":""}`};_syncWordCountVisibility=()=>{const t=!1!==this._rtbHostElement?._visibility?.wordCount;this.statusBar&&(this.statusBar.style.display=t?"":"none")};setReadOnly=t=>{this.content.contentEditable=t?"false":"true",this.content.setAttribute("aria-readonly",t?"true":"false");const e=this.shadowRoot.querySelector(`#${CSS.escape(this.toolbar_id)}`);e&&(e.style.display=t?"none":"")};saveHtml=()=>{const t="block"===this.content.style.display?this.html()||"":this.source.value||"",e=new Blob([t],{type:"text/html"}),o=URL.createObjectURL(e),i=document.createElement("a");i.href=o,i.download=this.createTimestampedHtmlFileName(),i.click(),URL.revokeObjectURL(o)};createTimestampedHtmlFileName=()=>{const t=new Date,pad=t=>String(t).padStart(2,"0");return`html-${[t.getFullYear(),pad(t.getMonth()+1),pad(t.getDate())].join("-")+"_"+[pad(t.getHours()),pad(t.getMinutes()),pad(t.getSeconds())].join("-")}.html`};enablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!0,this.disableButtons()};disablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!1,"block"===this.content.style.display&&this.enableButtons()};format=t=>{this.NodeManager.formatNode(t),this.closeDropdown("blazing-rich-text-format-button-dropdown")};dropdown=t=>{const e=this.shadowRoot.getElementById(t);null!=e&&e.classList.contains("rich-text-box-show")?e.classList.remove("rich-text-box-show"):(this.NodeManager.closeDropdowns(),e.classList.add("rich-text-box-show"))};increaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)};decreaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)};openTextColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),t){const e=this.ColorPickers["rich-text-box-text-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextColor=t=>{this.ColorPickers["rich-text-box-text-color-modal"].selectColor(t)};insertTextColor=()=>{this.ColorPickers["rich-text-box-text-color-modal"].insertColor()};removeTextColor=()=>{this.currentColor=null,this.NodeManager.updateNode("textcolor","None"),this.NodeManager.updateNode("textbgcolor","None")};openTextBackgroundColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),null!==t){const e=this.ColorPickers["rich-text-box-text-bg-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextBackgroundColor=t=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].selectColor(t)};insertTextBackgroundColor=()=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].insertColor()};openTableDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.TableDialog.openTableDialog(t):this.Utilities.showFadingBar("No content selected.")};insertTable=()=>{this.TableDialog.insertTable()};font=t=>{this.NodeManager.updateNode("font",t),this.closeDropdown("blazing-rich-text-font-button-dropdown")};size=t=>{this.clearSettings(),this.NodeManager.updateNode("size",t),this.closeDropdown("blazing-rich-text-size-button-dropdown")};bold=()=>{this.NodeManager.updateNode("bold")};italic=()=>{this.NodeManager.updateNode("italic")};underline=()=>{this.NodeManager.updateNode("underline")};strikethrough=()=>{this.NodeManager.updateNode("line-through")};subscript=()=>{this.NodeManager.updateNode("subscript")};superscript=()=>{this.NodeManager.updateNode("superscript")};alignleft=()=>{this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.NodeManager.updateNode("alignjustify")};copy=()=>{this.ActionOptions.copy(),this.NodeManager.refreshUI()};cut=()=>{this.ActionOptions.cut(),this.NodeManager.refreshUI()};paste=()=>{this.NodeManager.allSelected&&this.delete(),this.ActionOptions.paste(),this.NodeManager.refreshUI()};closeDropdown=t=>{this.shadowRoot.getElementById(t).classList.remove("rich-text-box-show"),this.lockToolbar=!1,this.content.focus()};delete=()=>{const t=this.Utilities.getSelection();null!==t&&(t.deleteFromDocument(),this.NodeManager.refreshUI())};selectall=()=>{const t=document.createRange();t.selectNodeContents(this.content),this.content.focus();const e=this.Utilities.getSelection();null!==e&&(e.removeAllRanges(),e.addRange(t),this.content.focus())};orderedlist=()=>{this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.ListProvider.addlist("UL"),this.NodeManager.refreshUI()};openLinkDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.LinkDialog.openLinkDialog(t):this.Utilities.showFadingBar("No content selected.")};insertLink=()=>{this.LinkDialog.insertLink(),this.NodeManager.refreshUI()};removeLink=()=>{this.LinkDialog.removeLink()};openBlockQuoteDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.BlockQuoteDialog.openBlockQuoteDialog(t):this.Utilities.showFadingBar("No content selected.")};openBlockQuoteDialogForElement=t=>{if(!t||"BLOCKQUOTE"!==t.nodeName||!this.content.contains(t))return;this.lockToolbar=!0;const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.selectNodeContents(t),e.removeAllRanges(),e.addRange(o),this.savedSelection=this.Utilities.saveSelection(e),this.BlockQuoteDialog.openBlockQuoteDialogForElement(t,o)};insertBlockQuote=()=>{this.BlockQuoteDialog.insertBlockQuote(),this.NodeManager.refreshUI()};openCodeBlockDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.CodeBlockDialog.openCodeBlockDialog(t):this.Utilities.showFadingBar("No content selected.")};openCodeBlockDialogForElement=t=>{if(!t||"PRE"!==t.nodeName||!this.content.contains(t))return;const e=t.querySelector("code")||t;this.lockToolbar=!0;const o=this.Utilities.getSelection()||window.getSelection(),i=document.createRange();i.selectNodeContents(e),o.removeAllRanges(),o.addRange(i),this.savedSelection=this.Utilities.saveSelection(o),this.CodeBlockDialog.openCodeBlockDialogForElement(t,i)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.MediaDialog.openMediaDialog(t):this.Utilities.showFadingBar("No content selected.")};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.VideoDialog.openVideoDialog(t):this.Utilities.showFadingBar("No content selected.")};openVideoDialogForElement=t=>{this.lockToolbar=!0;const e=this.Utilities.getSelection(),o=this.Utilities.saveSelection(e);this.savedSelection=o,this.VideoDialog.openVideoDialogForElement(t,o)};insertVideo=()=>{this.VideoDialog.insertVideo(),this.NodeManager.refreshUI()};uploadImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.UploadImageDialog.openUploadImageDialog(t):this.Utilities.showFadingBar("No content selected.")};uploadImage=()=>{this.UploadImageDialog.insertUploadedImage()};openImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.ImageDialog.openImageDialog(t):this.Utilities.showFadingBar("No content selected.")};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeDialog=t=>{this.lockToolbar=!1,this.Utilities.closeDialog(t,this.savedSelection)};enableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!1);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!1)};disableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!0);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!0)};toggleView=()=>{!0===this.EditMode?this.getHtml():this.getCode()};getHtml=async()=>{this.htmlSelection=this.StateManager.saveSelection(),this.contentScroll=this.Utilities.saveScroll(this.contentContainer),this.statusBar&&(this._statusBarWasVisible="none"!==this.statusBar.style.display,this.statusBar.style.display="none");const t=this.html();this.loadInnerText(t),this.content.style.display="none",this.source.style.display="block",this.source.focus(),this.Utilities.restoreScroll(this.source,this.sourceScroll),this.disableButtons()};getCode=async()=>{this.sourceScroll=this.Utilities.saveScroll(this.source);const t=this.source.value;this.loadHtml(t),this.content.style.display="block",this.source.style.display="none",this.content.focus(),this.StateManager.restoreSelection(this.htmlSelection),this.Utilities.restoreScroll(this.contentContainer,this.contentScroll),this.enableButtons(),this.statusBar&&this._statusBarWasVisible&&(this.statusBar.style.display="",this.updateWordCount())};html=()=>(this.NodeManager.removeEmptyNodes(),this.content.innerHTML);loadView=t=>{!0===this.EditMode?this.loadHtml(t):this.loadInnerText(t)};loadHtml=t=>{this.EditMode=!0;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.remove("selected"),e.setAttribute("aria-pressed","false")),this.content.innerHTML=null!=t?t:"",this.NodeManager.clearButtons(),this.updateWordCount()};loadInnerText=t=>{this.EditMode=!1;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.add("selected"),e.setAttribute("aria-pressed","true")),this.source.value=null!=t?t:"",this.NodeManager.clearButtons()};plaintext=()=>this.content.textContent}class e{constructor(t,e,o,i,n){this.content=t,this.source=e,this.Utilities=o,this.dotNetObjectReference=i,this.contentContainer=n,this.history=[],this.currentIndex=-1,this.currentIndex=-1,this.isNavigating=!1,this.mutationObserver()}mutationObserver=()=>{new MutationObserver((t,e)=>{if("block"!==this.content.style.display||this.isNavigating)this.isNavigating=!1,this.updateBinding();else for(let e of t)switch(e.type){case"attributes":case"characterData":case"subtree":case"childList":this.saveState()}}).observe(this.content,{attributes:!0,childList:!0,subtree:!0,characterData:!0})};updateBinding=()=>{"block"===this.content.style.display?this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.content.innerHTML):this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.source.value)};saveState=()=>{if(this.PreviousHtml===this.content.innerHTML)return;const t={html:this.content.innerHTML,selection:this.saveSelection(),scroll:this.Utilities.saveScroll(this.contentContainer)};this.PreviousHtml=this.content.innerHTML,-1!==this.currentIndex&&t===this.history[this.currentIndex]||(this.history=this.history.slice(0,this.currentIndex+1),this.history.push(t),this.currentIndex++,this.history.length>60&&(this.history.shift(),this.currentIndex--),this.updateBinding())};restoreLastState=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.restoreState(this.history[this.currentIndex]))};goBack=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.currentIndex--,this.restoreState(this.history[this.currentIndex]))};goForward=()=>{this.currentIndex<this.history.length-1&&(this.isNavigating=!0,this.currentIndex++,this.restoreState(this.history[this.currentIndex]))};saveSelection=()=>{const t=this.Utilities.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),o=e.cloneRange();o.selectNodeContents(this.content),o.setEnd(e.startContainer,e.startOffset);const i=o.toString().length;return{start:i,end:i+e.toString().length}}return null};restoreSelection=t=>{if(t)try{const charIndex=(t,e)=>{let o=0;if(t.nodeType===Node.TEXT_NODE)return e<=t.length?[t,e]:[null,e-t.length];for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i],[r,s]=charIndex(n,e-o);if(r)return[r,s];o+=n.textContent.length}return[null,e-o]},e=document.createRange();let[o,i]=charIndex(this.content,t.start),[n,r]=charIndex(this.content,t.end);if(o&&n){e.setStart(o,i),e.setEnd(n,r);const t=window.getSelection();t.removeAllRanges(),t.addRange(e)}}catch(t){}};restoreState=t=>{this.content.innerHTML=t.html,this.restoreSelection(t.selection),this.Utilities.restoreScroll(this.contentContainer,t.scroll),this.content.focus()}}class o{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o}_press=(t,e=!0)=>{t&&(t.classList.toggle("selected",e),t.setAttribute("aria-pressed",e?"true":"false"))};formatNode=t=>{let e,o;if(e=this.Utilities.getSelection(),null!==e){let i;if(0==e.toString().length)null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&this.content.contains(e.anchorNode.parentNode)&&(i=this.getElementByType(e.anchorNode.parentNode,"Format"));else if(1==this.hasCommonAncestor(e)){i=e.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else i=this.getElementByContent(e.anchorNode,t,e);if(null!=i&&i!=this.content&&null!=i.parentNode&&this.content.contains(i.parentNode)){if("none"==t){let t=this.Utilities.saveCaretPosition();const e=document.createElement("div");for(let t=0;t<i.style.length;t++){const o=i.style[t];e.style[o]=i.style[o]}for(;i.firstChild;)e.appendChild(i.firstChild);i.parentNode.replaceChild(e,i),this.Utilities.restoreCaretPosition(e,t)}else{let e=this.Utilities.saveCaretPosition();const o=document.createElement(t);o.innerHTML=i.innerHTML;const n=window.getComputedStyle(i);for(let t=0;t<n.length;t++){let e=n[t],r=i.style.getPropertyValue(e);""!==r&&(o.style[e]=r)}i.parentNode.replaceChild(o,i),this.Utilities.restoreCaretPosition(o,e)}return}if(e.toString().length>0){let i;switch(t){case"p":i=document.createElement("p");break;case"h1":i=document.createElement("h1");break;case"h2":i=document.createElement("h2");break;case"h3":i=document.createElement("h3");break;case"h4":i=document.createElement("h4");break;case"h5":i=document.createElement("h5")}null!=i&&e.rangeCount>0&&(o=e.getRangeAt(0),this.hasInvalidElementsInSelection(e)||(i.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(i),o.selectNodeContents(i),e.removeAllRanges(),e.addRange(o)))}}};updateNode=(t,e,o)=>{let i,n;if(i=this.Utilities.getSelection(),i||o){let r;if(i&&o?(i.removeAllRanges(),i.addRange(o)):o&&(i=window.getSelection(),i.removeAllRanges(),i.addRange(o)),this.isCommonAncestor=!1,0==i.toString().length){if(r=this.getElementByStyle(i.anchorNode,t),null==r&&null!=i.anchorNode&&i.anchorNode!=this.content&&this.content.contains(i.anchorNode)&&i.anchorNode.querySelector){null!=i.anchorNode.querySelector("img")&&(r=i.anchorNode);null!=i.anchorNode.querySelector("embed")&&(r=i.anchorNode);null!=i.anchorNode.querySelector("object")&&(r=i.anchorNode);const t=i.anchorNode.querySelector("table");null!=t&&(r=t)}null==r&&null!=i.anchorNode&&i.anchorNode!=this.content&&null!=i.anchorNode.parentNode&&i.anchorNode.parentNode!=this.content&&this.content.contains(i.anchorNode.parentNode)&&(r=i.anchorNode.parentNode)}else if(1==this.hasCommonAncestor(i)){r=i.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else r=this.getElementByContent(i.anchorNode,t,i);if(null!=r){let o;switch(t){case"textcolor":"None"==e?(o=this.getElementByStyle(r,t),null!=o&&this.removeProperty(o,"color",o.style.getPropertyValue("color"))):r.style.setProperty("color",e);break;case"textbgcolor":"None"==e?(o=this.getElementByStyle(r,t),null!=o&&this.removeProperty(o,"background-color",o.style.getPropertyValue("background-color"))):r.style.setProperty("background-color",e);break;case"font":"None"==e?this.removeProperty(r,"font-family",e):r.style.setProperty("font-family",e);break;case"size":"None"==e?this.removeProperty(r,"font-size"):r.style.setProperty("font-size",e);break;case"bold":"bold"==r.style.fontWeight?this.removeProperty(r,"font-weight","bold"):r.style.setProperty("font-weight","bold");break;case"italic":"italic"==r.style.fontStyle?this.removeProperty(r,"font-style","italic"):r.style.setProperty("font-style","italic");break;case"underline":r.style.textDecoration.includes("underline")?this.removeTextDecoration(r,"underline"):this.addTextDecoration(r,"underline");break;case"line-through":r.style.textDecoration.includes("line-through")?this.removeTextDecoration(r,"line-through"):this.addTextDecoration(r,"line-through");break;case"subscript":"sub"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","sub"):r.style.setProperty("vertical-align","sub");break;case"superscript":"super"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","super"):r.style.setProperty("vertical-align","super");break;case"alignleft":"TABLE"===r.nodeName?this.alignTable(r,"alignleft"):"left"==r.style.textAlign?this.removeProperty(r,"text-align","left"):r.style.setProperty("text-align","left");break;case"aligncenter":"TABLE"===r.nodeName?this.alignTable(r,"aligncenter"):"center"==r.style.textAlign?this.removeProperty(r,"text-align","center"):r.style.setProperty("text-align","center");break;case"alignright":"TABLE"===r.nodeName?this.alignTable(r,"alignright"):"right"==r.style.textAlign?this.removeProperty(r,"text-align","right"):r.style.setProperty("text-align","right");break;case"alignjustify":"TABLE"===r.nodeName?this.alignTable(r,"alignjustify"):"justify"==r.style.textAlign?this.removeProperty(r,"text-align","justify"):r.style.setProperty("text-align","justify")}return this.selection=null,void this.refreshUI()}if(i.toString().length>0&&"None"!=e&&!this.isExcluded(i)){let o;switch(t){case"textcolor":o=this.createElement(i),o.style.color=e;break;case"textbgcolor":o=this.createElement(i),o.style.backgroundColor=e;break;case"font":o=this.createElement(i),o.style.fontFamily=e;break;case"size":o=this.createElement(i),o.style.fontSize=e;break;case"bold":o=this.createElement(i),o.style.fontWeight="bold";break;case"italic":o=this.createElement(i),o.style.fontStyle="italic";break;case"underline":o=this.createElement(i),this.addTextDecoration(o,"underline");break;case"line-through":o=this.createElement(i),this.addTextDecoration(o,"line-through");break;case"subscript":o=this.createElement(i),o.style.verticalAlign="sub";break;case"superscript":o=this.createElement(i),o.style.verticalAlign="super";break;case"alignleft":o=document.createElement("div"),o.style.textAlign="left";break;case"aligncenter":o=document.createElement("div"),o.style.textAlign="center";break;case"alignright":o=document.createElement("div"),o.style.textAlign="right";break;case"alignjustify":o=document.createElement("div"),o.style.textAlign="justify"}null!=o&&0!=i.rangeCount&&(n=i.getRangeAt(0),o.appendChild(n.cloneContents()),n.deleteContents(),n.insertNode(o),n.selectNodeContents(o),i.removeAllRanges(),i.addRange(n),this.selection=null,this.refreshUI())}}};alignTable=(t,e)=>{"alignleft"!==e&&"alignjustify"!==e||("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft&&this.removeProperty(t,"margin-left","auto")),"aligncenter"===e&&(t.style.margin&&"auto"===t.style.margin?this.removeProperty(t,"margin","auto"):t.style.setProperty("margin","auto")),"alignright"===e&&("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft?this.removeProperty(t,"margin-left","auto"):t.style.setProperty("margin-left","auto"))};isExcluded=t=>{if(t.anchorNode&&t.anchorNode.querySelector){const e=t.anchorNode.querySelector("table");if(null!=e&&t.toString().trim()!==e.innerText.trim())return!0}if(t.anchorNode.parentNode!==this.content)switch(t.anchorNode.parentNode.nodeName){case"TD":case"CODE":case"PRE":return!0}return!1};indentBlock=(t,e)=>{let o=t.anchorNode;for(;o&&!this.applyMargin(o,e);)o=o.parentNode};applyMargin=(t,e)=>{if(t.nodeType===Node.ELEMENT_NODE&&["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"].includes(t.nodeName)){const o=window.getComputedStyle(t).marginLeft,i=parseFloat(o)||0,n=40;return e?t.style.marginLeft=`${i+n}px`:i<=n?(t.style.marginLeft="",t.hasAttribute("style")&&(t.getAttribute("style")||t.removeAttribute("style"))):t.style.marginLeft=i-n+"px",!0}return!1};selectButtons=t=>{if(null==t||t==this.content||!this.content.contains(t)||1==this.lockToolbar)return;this.clearButtons();const e=this.getButton("blazing-rich-text-bold-button"),o=this.getButton("blazing-rich-text-italic-button"),i=this.getButton("blazing-rich-text-underline-button"),n=this.getButton("blazing-rich-text-strike-button"),r=this.getButton("blazing-rich-text-sub-button"),s=this.getButton("blazing-rich-text-super-button"),l=this.getButton("blazing-rich-text-alignleft-button"),a=this.getButton("blazing-rich-text-aligncenter-button"),c=this.getButton("blazing-rich-text-alignright-button"),d=this.getButton("blazing-rich-text-alignjustify-button");this.textAlign=!1;const h=this.getButton("blazing-rich-text-orderedlist-button"),b=this.getButton("blazing-rich-text-unorderedlist-button"),u=this.getButton("blazing-rich-text-link-button"),g=this.getButton("blazing-rich-text-remove-link-button"),m=this.getButton("blazing-rich-text-textcolor-button"),x=this.getButton("blazing-rich-text-text-bg-color-button"),p=this.getButton("blazing-rich-text-textcolor-remove-button"),v=this.getButton("blazing-rich-text-quote-button"),f=this.getButton("blazing-rich-text-code-block-button"),y=this.getButton("blazing-rich-text-table-button"),w=this.getButton("blazing-rich-text-image-button"),C=this.getButton("blazing-rich-text-image-upload-button"),N=this.getButton("blazing-rich-text-embed-button"),k=this.getButton("blazing-rich-text-video-button"),S=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=S&&(S.innerText="Format",this.formatSelected=!1);const E=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=E&&(E.innerText="Font",this.fontSelected=!1);const R=this.shadowRoot.getElementById("blazing-rich-text-size-button");for(null!=R&&(R.innerText="Size",this.fontSizeSelected=!1);t!==this.content&&null!==t.parentNode&&this.content.contains(t.parentNode)&&"#text"!=t.parentNode.nodeName&&"#document"!=t.parentNode.nodeName;){let T=window.getComputedStyle(t.parentNode);if(null!=t.parentNode.style&&"bold"==t.parentNode.style.fontWeight&&this._press(e),null!=t.parentNode.style&&t.parentNode.style.color&&this._press(m),null!=t.parentNode.style&&t.parentNode.style.backgroundColor&&this._press(x),(null!=t.parentNode.style&&t.parentNode.style.color||t.parentNode.style.backgroundColor)&&this._press(p),"italic"==T.getPropertyValue("font-style")&&this._press(o),T.getPropertyValue("text-decoration").includes("underline")&&"A"!=t.parentNode.nodeName&&this._press(i),T.getPropertyValue("text-decoration").includes("line-through")&&this._press(n),"sub"==T.getPropertyValue("vertical-align")&&this._press(r),"super"==T.getPropertyValue("vertical-align")&&this._press(s),"left"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(l),this.textAlign=!0),"center"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),"right"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),"justify"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),null!=t&&null!=t.style&&t.style.fontFamily&&!this.fontSelected&&(E.innerText=t.style.fontFamily.replace(/^"(.*)"$/,"$1"),this.fontSelected=!0),null!=t&&null!=t.style&&t.style.fontSize&&!this.fontSizeSelected&&(R.innerText=t.style.fontSize,this.fontSizeSelected=!0),"P"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Paragraph",this.formatSelected=!0),"H1"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 1",this.formatSelected=!0),"H2"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 2",this.formatSelected=!0),"H3"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 3",this.formatSelected=!0),"H4"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 4",this.formatSelected=!0),"H5"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 5",this.formatSelected=!0),"A"==t.parentNode.nodeName&&(this._press(u),this._press(g)),"BLOCKQUOTE"==t.parentNode.nodeName&&this._press(v),"CODE"==t.parentNode.nodeName&&this._press(f),"TD"==t.parentNode.nodeName&&this._press(y),"OL"==t.parentNode.nodeName&&this._press(h),"UL"==t.parentNode.nodeName&&this._press(b),"VIDEO"!==t.nodeName&&"SOURCE"!==t.nodeName||k&&this._press(k),t.querySelector){const e=t.querySelector("img");e&&(e.src.startsWith("data")?this._press(C):this._press(w));t.querySelector("object")&&this._press(N);t.querySelector("video")&&k&&this._press(k)}t=t.parentNode}this.closeDropdowns()};closeDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(function(t){t.classList.contains("rich-text-box-show")&&t.classList.remove("rich-text-box-show")})};getButton=t=>this.shadowRoot.getElementById(t);refreshUI=()=>{const t=this.Utilities.getSelection();null!==t&&this.selectButtons(t.anchorNode),this.removeEmptyNodes(),this.content.focus()};removeEmptyNodes=()=>{const t=this.content;if(t){t.querySelectorAll("*").forEach(t=>{t.hasChildNodes()&&(1!==t.childNodes.length||3!==t.childNodes[0].nodeType||/\S/.test(t.textContent))||t.parentElement&&!this.isNotRemovable(t.nodeName)&&t.parentElement.removeChild(t)})}};createDefaultElement=()=>{if(""===this.content.innerHTML.trim()){const t=document.createElement("div"),e=document.createElement("br");t.appendChild(e),this.content.appendChild(t)}};allSelected=()=>{const t=this.Utilities.getSelection();if(null!==t){if(0===t.rangeCount)return!1;const e=t.getRangeAt(0),o=document.createRange();return o.selectNodeContents(this.content),e.startContainer===o.startContainer&&e.startOffset===o.startOffset&&e.endContainer===o.endContainer&&e.endOffset===o.endOffset}return!1};clearButtons=()=>{this.closeDropdowns();this.shadowRoot.querySelectorAll(".rich-text-box-menu-item, .rich-text-box-menu-item-special").forEach(function(t){t.classList.remove("selected"),t.setAttribute("aria-pressed","false")});const t=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=t&&(t.innerText="Format",this.formatSelected=!1);const e=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=e&&(e.innerText="Font",this.fontSelected=!1);const o=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=o&&(o.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=t=>{switch(t.toLowerCase()){case"td":case"img":case"i":case"br":case"area":case"base":case"col":case"embed":case"object":case"video":case"source":case"hr":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":case"keygen":return!0}return!1};hasCommonAncestor(t){if(!t.rangeCount)return!1;const e=t.getRangeAt(0),o=e.cloneContents(),i=document.createElement("div");i.appendChild(o);const n=e.commonAncestorContainer;return n!==this.content&&this.content.contains(n)&&i.innerHTML==e.commonAncestorContainer.innerHTML&&n.nodeType!==Node.TEXT_NODE?(i.remove(),!0):(i.remove(),!1)}createElement=t=>this.hasInvalidElementsInSelection(t)?document.createElement("div"):document.createElement("span");hasInvalidElementsInSelection=t=>{if(t){const e=["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","header","hgroup","hr","main","menu","nav","ol","p","pre","section","table","ul","button","input","textarea","select","form","h1","h2","h3","h4","h5","h6"],o=t.getRangeAt(0).cloneContents().querySelectorAll("*");for(let t=0;t<o.length;t++){const i=o[t];if(e.includes(i.tagName.toLowerCase()))return!0}}return!1};removeProperty=(t,e,o)=>{null!=t&&t!=this.content&&this.content.contains(t)&&(this.getUserDefinedStyleCount(t)>1?t.style.removeProperty(e,o):"SPAN"==t.nodeName?0==t.childElementCount?t.replaceWith(t.textContent):(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):"DIV"==t.nodeName&&!0===this.isCommonAncestor?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style"))};addTextDecoration=(t,e)=>{if(null==t||t==this.content||t==this.content.parentNode)return;const o=t.style.textDecoration;if(null!=o&&!o.includes(e)){const i=o?o+" "+e:e;t.style.textDecoration=i}};removeTextDecoration=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t))if(this.getUserDefinedStyleCount(t)>1){const o=t.style.textDecoration.split(" ").filter(t=>t!==e);t.style.textDecoration=o.join(" ")}else"SPAN"==t.nodeName&0==t.childElementCount?t.replaceWith(t.textContent):"SPAN"==t.nodeName?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style")};getUserDefinedStyles=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e={};for(let o=0;o<t.style.length;o++){let i=t.style[o],n=t.style.getPropertyValue(i);e[i]=n}return e};getUserDefinedStyleCount=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e=0;for(let o=0;o<t.style.length;o++){let i=t.style[o],n=t.style.getPropertyValue(i);if(this.isFormatElement(t)){if("initial"!=n){let t=n.split(" ");if(!this.isMultiValueProperty(i)&&t.length>1)for(let o=0;o<t.length;o++)e++;else e++}}else e++}return e};isMultiValueProperty=t=>{switch(t){case"background-color":case"color":case"font-family":return!0}return!1};getElementByType=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(e){case"Format":if(this.isFormatElement(t))return t;break;case"UL":case"OL":case"Element":if(t.nodeName===e)return t}t=t.parentNode}return null}};getElementByContent=(t,e,o)=>{if(null!=t&&t!=this.content&&this.content.contains(t))for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName){const i=this.getElementByStyle(t,e);if(null!=i&&this.selectionContainsNode(o,i))return i;if("LI"===t.nodeName)return t.parentNode;if(null!==o&&o.toString().trim()==t.textContent.trim())return t}t=t.parentNode}};selectionContainsNode(t,e){if(null==e||e==this.content||!this.content.contains(e))return!1;if(t.rangeCount>0)for(let o=0;o<t.rangeCount;o++){let i=t.getRangeAt(o);if(this.isNodeInRange(e,i))return!0}return!1}isNodeInRange(t,e){if(null==t||t==this.content||!this.content.contains(t))return!1;let o=t.ownerDocument.createRange();return o.selectNode(t),e.compareBoundaryPoints(Range.START_TO_END,o)<=0&&e.compareBoundaryPoints(Range.END_TO_START,o)>=0}getElementByStyle=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if(null!=t.style){let o=null;switch(e){case"textcolor":if(o=t.getAttribute("style"),null!=o&&o.includes("color:"))return t;break;case"textbgcolor":if(o=t.getAttribute("style"),null!=o&&o.includes("background-color:"))return t;break;case"font":if(o=t.getAttribute("style"),null!=o&&o.includes("font-family:"))return t;break;case"size":if(o=t.getAttribute("style"),null!=o&&o.includes("font-size:"))return t;break;case"bold":if(o=t.getAttribute("style"),null!=o&&o.includes("font-weight:")&&"bold"==t.style.fontWeight)return t;break;case"italic":if(o=t.getAttribute("style"),null!=o&&o.includes("font-style:")&&"italic"==t.style.fontStyle)return t;break;case"underline":if(o=t.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&t.style.textDecoration.includes("underline"))return t;break;case"line-through":if(o=t.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&t.style.textDecoration.includes("line-through"))return t;break;case"subscript":if(o=t.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"sub"==t.style.verticalAlign)return t;break;case"superscript":if(o=t.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"superscript"==t.style.verticalAlign)return t;break;case"alignleft":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"left"==t.style.textAlign)return t;break;case"aligncenter":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"center"==t.style.textAlign)return t;break;case"alignright":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"right"==t.style.textAlign)return t;break;case"alignjustify":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"justify"==t.style.textAlign)return t}}t=t.parentNode}return null}};isFormatElement=t=>!(null==t||t==this.content||!this.content.contains(t))&&("P"==t.nodeName||"H1"==t.nodeName||"H2"==t.nodeName||"H3"==t.nodeName||"H4"==t.nodeName||"H5"==t.nodeName||(null!=t.style&&null!=t.style.textDecoration||void 0));insertLineBreak=t=>{const e=document.createElement("div"),o=document.createElement("br");if(e.appendChild(o),"CODE"==t.nodeName){const o=t.parentNode.parentNode;o.nextSibling?o.parentNode.insertBefore(e,o.nextSibling):o.parentNode.appendChild(e)}else t.parentNode.insertBefore(e,t.nextSibling);const i=document.createRange();i.setStartBefore(o),i.collapse(!0);const n=this.Utilities.getSelection();null!==n&&(n.removeAllRanges(),n.addRange(i))}}class i{constructor(t,e,o,i){this.shadowRoot=t,this.content=e,this.Utilities=o,this.NodeManager=i}addlist=t=>{const e=this.Utilities.getSelection();if(null!==e){if("UL"==t){const t=this.NodeManager.getElementByType(e.anchorNode,"OL");if(null!=t)return void this.replaceList(t,"UL")}else{const t=this.NodeManager.getElementByType(e.anchorNode,"UL");if(null!=t)return void this.replaceList(t,"OL")}const o=this.NodeManager.getElementByType(e.anchorNode,t);if(null!=o)this.removelist(o);else{if(0===e.toString().trim().length){const o=e.getRangeAt(0);let i;const n=document.createElement(t);if(e.anchorNode.parentNode!==this.content&&(i=e.anchorNode.parentNode),e.anchorNode!==this.content&&(i=e.anchorNode),i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),e=i.cloneNode(!0);this.appendListItemContent(t,e),n.appendChild(t),i.remove()}o.deleteContents(),o.insertNode(n);const r=document.createRange();r.selectNodeContents(n),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}else{const o=document.createElement(t);if(e.rangeCount>0){const t=e.getRangeAt(0),i=t.cloneContents().childNodes;Array.from(i).forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),i=t.cloneNode(!0);this.appendListItemContent(e,i),o.appendChild(e),t.remove()}}),t.deleteContents(),t.insertNode(o),t.selectNodeContents(o),e.removeAllRanges(),e.addRange(t)}}}}};appendListItemContent=(t,e)=>{if(t&&e)if(this.isParagraphChild(e))for(;e.firstChild;)t.appendChild(e.firstChild);else t.appendChild(e)};replaceList=(t,e)=>{if(null===t||t===this.content||!this.content.contains(t))return;const o=this.Utilities.getSelection();let i,n,r,s,l;null!==o&&o.rangeCount>0&&(i=o.getRangeAt(0),n=i.startContainer,r=i.startOffset,s=i.endContainer,l=i.endOffset);const a=document.createElement(e);for(;t.firstChild;)a.appendChild(t.firstChild);if(t.parentNode.replaceChild(a,t),i){const e=document.createRange();t.contains(n)?e.setStart(a,r):e.setStart(n,r),t.contains(s)?e.setEnd(a,l):e.setEnd(s,l),o.removeAllRanges(),o.addRange(e)}};removelist=t=>{if(null==t||t==this.content||!this.content.contains(t))return;if("OL"===t.nodeName||"UL"===t.nodeName)return void this.removeListAsParagraphs(t);let e=null;for(;t.firstChild;){const o=t.firstChild;if("UL"===o.nodeName||"OL"===o.nodeName)e||(e=o),t.parentNode.insertBefore(o,t);else{for(;o.firstChild;){const i=o.firstChild;e||(e=i),t.parentNode.insertBefore(i,t)}t.removeChild(o)}}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}};removeListAsParagraphs=t=>{let e=null;for(;t.firstChild;){const o=t.firstChild;if("LI"!==o.nodeName){e||(e=o),t.parentNode.insertBefore(o,t);continue}const i=document.createElement("p");for(;o.firstChild;){const t=o.firstChild;if("UL"===t.nodeName||"OL"===t.nodeName)break;if(this.isParagraphChild(t)){for(;t.firstChild;)i.appendChild(t.firstChild);o.removeChild(t)}else i.appendChild(t)}for(i.hasChildNodes()||i.appendChild(document.createElement("br")),e||(e=i),t.parentNode.insertBefore(i,t);o.firstChild;)t.parentNode.insertBefore(o.firstChild,t);t.removeChild(o)}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}};isParagraphChild=t=>!(!t||t.nodeType!==Node.ELEMENT_NODE)&&["P","DIV"].includes(t.nodeName);increaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;let o=this.getSelectedNodes(t,e);if(!o||0===o.length)return;let i=o[0].previousElementSibling;if(!i||"LI"!==i.nodeName)return;let n=Array.from(i.children).find(t=>t.nodeName===e.nodeName);n||(n=document.createElement(e.nodeName),i.appendChild(n)),o.forEach(t=>{"LI"===t.nodeName&&n.appendChild(t)}),this.selectListItemStart(t,o[0])};decreaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;const o=this.getSelectedNodes(t,e);if(!o||0===o.length)return;const i=e.parentElement,n=i?i.parentElement:null;if(!i||"LI"!==i.nodeName||!n||"UL"!==n.nodeName&&"OL"!==n.nodeName)return;const r=o[o.length-1],s=document.createElement(e.nodeName);for(;r.nextElementSibling;)s.appendChild(r.nextElementSibling);const l=document.createDocumentFragment();o.forEach(t=>{"LI"===t.nodeName&&l.appendChild(t)}),n.insertBefore(l,i.nextSibling),s.children.length>0&&r.appendChild(s),0===e.children.length&&e.remove(),this.selectListItemStart(t,o[0])};getSelectedNodes=(t,e)=>{const o=[];if(!t.rangeCount)return null;const i=t.getRangeAt(0);if(null!==e){const t=e.children;for(let e=0;e<t.length;e++){const n=t[e];i.intersectsNode(n)&&o.push(n)}return o}return null};saveListSelection=t=>t&&0!==t.rangeCount?t.getRangeAt(0).cloneRange():null;restoreListSelection=(t,e,o)=>{if(t&&e&&this.content.contains(e.startContainer)&&this.content.contains(e.endContainer))return t.removeAllRanges(),void t.addRange(e);this.selectListItem(t,o)};selectListItemStart=(t,e)=>{if(!t||!e)return;const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)};selectListItem=(t,e)=>{if(!t||!e)return;const o=document.createRange(),i=this.getFirstTextNode(e);i?o.setStart(i,i.textContent.length):(o.selectNodeContents(e),o.collapse(!1)),o.collapse(!0),t.removeAllRanges(),t.addRange(o)};getFirstTextNode=t=>{if(!t)return null;if(t.nodeType===Node.TEXT_NODE)return t;for(let e=0;e<t.childNodes.length;e++){const o=t.childNodes[e];if("UL"===o.nodeName||"OL"===o.nodeName)continue;const i=this.getFirstTextNode(o);if(i)return i}return null};getList=t=>{for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(t.nodeName){case"OL":case"UL":return t}t=t.parentNode}return null}}class n{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o}copy=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(t)};cut=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&(navigator.clipboard.writeText(t),t.deleteFromDocument())};paste=()=>{navigator.clipboard.readText().then(t=>{this.checkParagraphs(t.trim())||this.checkTables(t.trim())||this.checkLines(t.trim())||this.checkText(t.trim())}).catch(t=>{console.error("Failed to read clipboard contents: ",t)})};checkParagraphs=t=>{let e=t.split(/\n\s*\n/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment();return e.forEach(t=>{let e=this.checkParagraphTable(t,i);if(e||(e=this.checkParagraphLines(t,i)),!e){let e=document.createElement("p");e.textContent=t.trim(),i.appendChild(e)}}),o.insertNode(i),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}return!1};checkParagraphLines=(t,e)=>{let o=0,i=t.trim().split(/\n+/);return i.length>1&&(i.forEach(t=>{if(o++,o===i.length){let o=document.createElement("p");o.textContent=t.trim(),e.appendChild(o)}else{let o=document.createElement("div");o.textContent=t.trim(),e.appendChild(o)}}),!0)};checkParagraphTable=(t,e)=>{if(this.isTable(t)){let o=this.buildTable(t);return e.appendChild(o),!0}return!1};checkLines=t=>{let e=t.trim().split(/\n+/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment();return e.forEach(t=>{let e=document.createElement("div");e.textContent=t.trim(),i.appendChild(e)}),o.insertNode(i),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}};checkTables=t=>{if(this.isTable(t)){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const o=e.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment(),n=this.buildTable(t);return i.appendChild(n),o.insertNode(i),o.collapse(!0),e.removeAllRanges(),e.addRange(o),!0}}};buildTable=t=>{let e=document.createElement("table"),o=t.split("\n"),i=document.createElement("tbody");return o.forEach((t,e)=>{if(t.trim().length>0){let e=t.split("\t"),o=document.createElement("tr");e.forEach(t=>{let e=document.createElement("td");t.trim().length>0&&(e.textContent=t),o.appendChild(e)}),i.appendChild(o)}}),e.appendChild(i),e};isTable=t=>{if(t.includes("\t")){let e=t.split("\n");if(e.length>1&&e[1].trim().length>0){let t=(e[1].match(/\t/g)||[]).length;if(0===t)return!1;for(let o=1;o<e.length;o++){let i=e[o];if(i.trim().length>0){if((i.match(/\t/g)||[]).length!==t)return!1}}return!0}}return!1};checkText=t=>{const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const o=e.getRangeAt(0);if(o.deleteContents(),""===this.content.innerHTML.trim()){const e=document.createElement("div"),i=document.createTextNode(t);e.appendChild(i),o.insertNode(e),o.setStartAfter(e),o.setEndAfter(e)}else{const e=document.createTextNode(t);o.insertNode(e),o.setStartAfter(e),o.setEndAfter(e)}e.removeAllRanges(),e.addRange(o)}}}class r{constructor(t,e){this.shadowRoot=t,this.content=e}closeDialog=(t,e)=>{const o=this.shadowRoot.getElementById(t);null!=o&&o.close(),e&&this.restoreSelection(window.getSelection(),e),this.content.focus()};addClasses=(t,e)=>{if(null!=t&&null!=e)if(e.classList.remove(...e.classList),t.length>0){t.split(" ").map(t=>t.trim()).forEach(t=>{t&&e.classList.add(t)})}else e.hasAttribute("class")&&e.removeAttribute("class")};getSelection=()=>{const t=this.shadowRoot.getSelection();return this.content.contains(t.anchorNode)&&this.content.contains(t.focusNode)?t:null};showFadingBar=t=>{const e=this.shadowRoot.getElementById("rich-text-box-message-bar"),o=e.querySelector(".rich-text-box-message");e&&o&&(o.textContent=t,e.classList.remove("rich-text-box-message-hidden"),setTimeout(()=>{this.closeFadingBar()},2e3))};closeFadingBar=()=>{this.shadowRoot.getElementById("rich-text-box-message-bar").classList.add("rich-text-box-message-hidden")};saveSelection=t=>t&&t.rangeCount>0?t.getRangeAt(0).cloneRange():null;restoreSelection=(t,e)=>{t&&e&&(t.removeAllRanges(),t.addRange(e)),this.content.focus()};reselectNode=t=>{const e=document.createRange(),o=window.getSelection();t.childNodes.length>0?e.setStartAfter(t.childNodes[t.childNodes.length-1]):e.setStartAfter(t),e.collapse(!0),o.removeAllRanges(),o.addRange(e)};saveCaretPosition=()=>{const t=this.getSelection();if(null!==t){return{startOffset:t.getRangeAt(0).startOffset,endOffset:t.getRangeAt(0).endOffset}}return null};restoreCaretPosition=(t,e)=>{const o=this.getSelection();if(null!==o&&null!==e){let i=document.createRange();i.setStart(t.firstChild,e.startOffset),i.setEnd(t.firstChild,e.endOffset),o.removeAllRanges(),o.addRange(i)}};saveScroll=t=>t.scrollTop;restoreScroll=(t,e)=>{t.scrollTop=e}}class s{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-table-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertTable()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openTableDialog=t=>{if(this.resetTableDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&"TD"===t.anchorNode.parentNode.nodeName){const e=this.getTable(t);if(e){const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=e.rows.length,t.disabled=!0;const o=this.shadowRoot.getElementById("rich-text-box-table-columns");o.value=this.getColumns(e),o.disabled=!0;this.shadowRoot.getElementById("rich-text-box-table-width").value=e.style.width;const i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=i){const t=e.classList;i.value=Array.from(t).join(" ")}this.table=e}}else null!==t&&t.rangeCount>0&&(this.tableSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-table-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e&&e.focus()};getTable=t=>"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode:"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode.parentNode:void 0;getColumns(t){let e=0;for(let o=0;o<t.rows.length;o++){let i=t.rows[o].cells.length;i>e&&(e=i)}return e}resetTableDialog=()=>{this.table=null,this.tableSelection=null;const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=null,t.disabled=!1;const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e.value=null,e.disabled=!1;this.shadowRoot.getElementById("rich-text-box-table-width").value=null;const o=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=o&&(o.value=null)};insertTable=()=>{const t=this.shadowRoot.getElementById("rich-text-box-table-rows"),e=this.shadowRoot.getElementById("rich-text-box-table-columns"),o=this.shadowRoot.getElementById("rich-text-box-table-width"),i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(0!=t.value.length&&0!=e.value.length){if(null!==this.table)o.value.trim().length>0?this.table.style.width=o.value:(this.table.style.removeProperty("width"),0===this.table.style.cssText.trim().length&&this.table.hasAttribute("style")&&this.table.removeAttribute("style")),null!==i&&this.Utilities.addClasses(i.value,this.table),this.Utilities.reselectNode(this.table);else if(null!=this.tableSelection){const n=this.tableSelection,r=this.createTable(t.value,e.value,o.value);null!==i&&this.Utilities.addClasses(i.value,r),n.deleteContents(),n.insertNode(r);let s=r.querySelector("td, th"),l=document.createRange();l.setStart(s,0),l.setEnd(s,0),this.savedSelection=l}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-table-modal",this.savedSelection)};createTable=(t,e,o)=>{const i=parseInt(t,10),n=parseInt(e,10),r=document.createElement("table");o&&(r.style.width=o);const s=document.createElement("tbody");for(let t=0;t<i;t++){const t=document.createElement("tr");for(let e=0;e<n;e++){const e=document.createElement("td");e.innerHTML="&#8203;",t.appendChild(e)}s.appendChild(t)}return r.appendChild(s),r};tableTab=()=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return;const e=this.getCurrentCell(t);if(!e)return;const o=this.getNextElement(e);if(o){o.focus();const e=document.createRange();e.selectNodeContents(o),"​"===o.innerText&&e.collapse(),t.removeAllRanges(),t.addRange(e)}this.content.focus()}};addRowFromLastCell=()=>{const t=this.Utilities.getSelection();if(null===t||!t.rangeCount)return!1;const e=this.getCurrentCell(t);if(!e)return!1;const o=e.parentElement,i=o?o.parentElement:null,n=i?i.closest("table"):null;if(!o||!i||!n)return!1;if(o.nextElementSibling)return!1;if(e.nextElementSibling)return!1;const r=Math.max(this.getColumns(n),o.cells.length,1),s=document.createElement("tr");for(let t=0;t<r;t++){const t=document.createElement("td");t.innerHTML="&#8203;",s.appendChild(t)}i.appendChild(s);const l=s.querySelector("td, th");return l&&this.selectCell(l),!0};getCurrentCell=t=>{if(!t||!t.anchorNode)return null;const e=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement;if(!e||!this.content.contains(e))return null;const o=e.closest("td, th");return o&&this.content.contains(o)?o:null};selectCell=t=>{if(!t)return;this.content.focus();const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.selectNodeContents(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)};getNextElement=t=>{let e=t.nextElementSibling;if(!e){let o=t.parentElement.nextElementSibling;o&&(e=o.querySelector("td"))}return e}}class l{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertMedia()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openMediaDialog=t=>{if(null!==t){if(this.resetMediaDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.embed=t.anchorNode.querySelector("object"),null!==this.embed)){this.shadowRoot.getElementById("rich-text-box-embed-source").value=this.embed.data;this.shadowRoot.getElementById("rich-text-box-embed-width").value=this.embed.width;this.shadowRoot.getElementById("rich-text-box-embed-height").value=this.embed.height;this.shadowRoot.getElementById("rich-text-box-embed-type").value=this.embed.type;this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(this.embed.classList).join(" ")}t.rangeCount>0&&(this.embedSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-embed-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-embed-source");e&&e.focus()}};resetMediaDialog=()=>{this.embed=null,this.embedSelection=null;this.shadowRoot.getElementById("rich-text-box-embed-source").value=null;this.shadowRoot.getElementById("rich-text-box-embed-width").value=null;this.shadowRoot.getElementById("rich-text-box-embed-height").value=null;this.shadowRoot.getElementById("rich-text-box-embed-type").value=null;const t=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=t&&(t.value=null)};insertMedia=()=>{const t=this.shadowRoot.getElementById("rich-text-box-embed-source"),e=this.shadowRoot.getElementById("rich-text-box-embed-width"),o=this.shadowRoot.getElementById("rich-text-box-embed-height"),i=this.shadowRoot.getElementById("rich-text-box-embed-type"),n=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");if(null!==this.embed)this.embed.data=t.value,i.value.trim().length>0?this.embed.type=i.value:this.embed.hasAttribute("type")&&this.embed.removeAttribute("type"),e.value.trim().length>0?this.embed.width=e.value:this.embed.hasAttribute("width")&&this.embed.removeAttribute("width"),o.value.trim().length>0?this.embed.height=o.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,this.embed);else if(null!=this.embedSelection&&t.value.length>0){const r=this.embedSelection.cloneRange(),s=document.createElement("object");s.data=t.value,i.value.trim().length>0?s.type=i.value:s.hasAttribute("type")&&s.removeAttribute("type"),e.value.trim().length>0?s.width=e.value:s.hasAttribute("width")&&s.removeAttribute("width"),o.value.trim().length>0?s.height=o.value:s.hasAttribute("height")&&s.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,s),r.deleteContents(),r.insertNode(s),this.Utilities.reselectNode(s),this.embedSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-embed-modal",this.savedSelection)}}class a{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.video=null,this.videoSelection=null,this.savedSelection=null,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-video-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertVideo()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};_populateFromVideo=t=>{const ge=t=>this.shadowRoot.getElementById(t),e=t.querySelector("source");ge("rich-text-box-video-source").value=e?e.getAttribute("src")||"":t.getAttribute("src")||"",ge("rich-text-box-video-source-type").value=e&&e.getAttribute("type")||"",ge("rich-text-box-video-poster").value=t.getAttribute("poster")||"",ge("rich-text-box-video-width").value=t.getAttribute("width")||"",ge("rich-text-box-video-height").value=t.getAttribute("height")||"",ge("rich-text-box-video-controls").checked=t.hasAttribute("controls"),ge("rich-text-box-video-autoplay").checked=t.hasAttribute("autoplay"),ge("rich-text-box-video-loop").checked=t.hasAttribute("loop"),ge("rich-text-box-video-muted").checked=t.hasAttribute("muted"),ge("rich-text-box-video-css-classes").value=Array.from(t.classList).join(" ")};_showDialog=()=>{this.shadowRoot.getElementById("rich-text-box-video-modal").show(),this.shadowRoot.getElementById("rich-text-box-video-source").focus()};openVideoDialog=t=>{if(null!==t){this.resetVideoDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=t.anchorNode;e&&("VIDEO"===e.nodeName?this.video=e:"SOURCE"===e.nodeName&&"VIDEO"===e.parentElement?.nodeName?this.video=e.parentElement:e.querySelector&&(this.video=e.querySelector("video")),!this.video&&e.closest&&(this.video=e.closest("video"))),null!==this.video&&this._populateFromVideo(this.video),t.rangeCount>0&&(this.videoSelection=t.getRangeAt(0).cloneRange()),this._showDialog()}};openVideoDialogForElement=(t,e)=>{this.resetVideoDialog(),this.savedSelection=e,this.video=t,this._populateFromVideo(t);const o=this.Utilities.getSelection();o&&o.rangeCount>0&&(this.videoSelection=o.getRangeAt(0).cloneRange()),this._showDialog()};resetVideoDialog=()=>{this.video=null,this.videoSelection=null;const ge=t=>this.shadowRoot.getElementById(t);ge("rich-text-box-video-source").value="",ge("rich-text-box-video-source-type").value="",ge("rich-text-box-video-poster").value="",ge("rich-text-box-video-width").value="",ge("rich-text-box-video-height").value="",ge("rich-text-box-video-controls").checked=!0,ge("rich-text-box-video-autoplay").checked=!1,ge("rich-text-box-video-loop").checked=!1,ge("rich-text-box-video-muted").checked=!1,ge("rich-text-box-video-css-classes").value=""};insertVideo=()=>{const ge=t=>this.shadowRoot.getElementById(t),t=ge("rich-text-box-video-source").value.trim(),e=ge("rich-text-box-video-source-type").value.trim(),o=ge("rich-text-box-video-poster").value.trim(),i=ge("rich-text-box-video-width").value.trim(),n=ge("rich-text-box-video-height").value.trim(),r=ge("rich-text-box-video-controls").checked,s=ge("rich-text-box-video-autoplay").checked,l=ge("rich-text-box-video-loop").checked,a=ge("rich-text-box-video-muted").checked,c=ge("rich-text-box-video-css-classes").value.trim(),applyAttrs=d=>{let h=d.querySelector("source");h||(h=document.createElement("source"),d.appendChild(h)),h.setAttribute("src",t),e?h.setAttribute("type",e):h.removeAttribute("type"),o?d.setAttribute("poster",o):d.removeAttribute("poster"),i?d.setAttribute("width",i):d.removeAttribute("width"),n?d.setAttribute("height",n):d.removeAttribute("height"),r?d.setAttribute("controls",""):d.removeAttribute("controls"),s?d.setAttribute("autoplay",""):d.removeAttribute("autoplay"),l?d.setAttribute("loop",""):d.removeAttribute("loop"),a?d.setAttribute("muted",""):d.removeAttribute("muted"),this.Utilities.addClasses(c,d)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&t.length>0){const t=this.videoSelection.cloneRange();if(!this.content.contains(t.startContainer))return void this.closeDialog();const e=document.createElement("video");applyAttrs(e),t.deleteContents();let o=t.startContainer;if(o===this.content){const o=this.content.childNodes[t.startOffset]??null;this.content.insertBefore(e,o)}else{for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(e),this._placeCursorAfterVideo(e),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(e,o.nextSibling)}this._placeCursorAfterVideo(e),this.videoSelection=null}this.closeDialog()};_placeCursorAfterVideo=t=>{if(!t.nextSibling){const e=document.createElement("p");e.appendChild(document.createElement("br")),this.content.insertBefore(e,t.nextSibling)}this._insertedVideo=t};closeDialog=()=>{const t=this._insertedVideo;if(this._insertedVideo=null,this.Utilities.closeDialog("rich-text-box-video-modal",this.savedSelection),t){const e=t.nextSibling;if(e){const t=document.createRange(),o=e.firstChild??e;t.setStart(o,0),t.collapse(!0);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(t))}}}}class c{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code");this.dialog=this.shadowRoot.getElementById("rich-text-box-code-block-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertCodeBlock()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openCodeBlockDialog=t=>{if(null!==t){this.resetCodeBlockDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-code"),o=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"CODE"===t.anchorNode.parentNode.nodeName){const i=t.anchorNode.parentNode.cloneNode(!0);if(e.value=i.textContent,null!=o){const e=t.anchorNode.parentNode.classList;o.value=Array.from(e).join(" ")}this.codeSelection=t.getRangeAt(0).cloneRange(),this.code=t.anchorNode.parentNode}else t.rangeCount>0&&(this.codeSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openCodeBlockDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetCodeBlockDialog(),this.savedSelection=e?e.cloneRange():null;const o=t.querySelector("code")||t,i=this.shadowRoot.getElementById("rich-text-box-code"),n=this.shadowRoot.getElementById("rich-text-box-code-css-classes");i.value=o.textContent,null!=n&&(n.value=Array.from(o.classList).join(" ")),this.codeSelection=e?e.cloneRange():null,this.code=o,this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),i.focus(),i.scrollTop=0,i.scrollLeft=0};resetCodeBlockDialog=()=>{this.code=null,this.codeSelection=null;this.shadowRoot.getElementById("rich-text-box-code").value=null;const t=this.shadowRoot.getElementById("rich-text-box-code-css-classes");null!=t&&(t.value=null)};insertCodeBlock=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code"),e=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=this.code){const o=this.code;o.textContent=t.value,null!==e&&this.Utilities.addClasses(e.value,o);const i=o.closest("pre")||o,n=document.createRange();n.setStartAfter(i),n.collapse(!0),this.savedSelection=n}else if(null!=this.codeSelection&&t.value.length>0){const o=this.codeSelection.cloneRange(),i=document.createElement("pre"),n=document.createElement("code");null!==e&&this.Utilities.addClasses(e.value,n),n.textContent=t.value,i.appendChild(n),o.deleteContents(),o.insertNode(i),o.setStartAfter(i),o.setEndAfter(i),this.savedSelection=o}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class d{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote");this.dialog=this.shadowRoot.getElementById("rich-text-box-block-quote-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertBlockQuote()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openBlockQuoteDialog=t=>{if(null!==t){this.resetBlockQuoteDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-quote"),o=this.shadowRoot.getElementById("rich-text-box-cite"),i=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"BLOCKQUOTE"==t.anchorNode.parentNode.nodeName){if(e.value=t.anchorNode.parentNode.textContent,null!=t.anchorNode.parentNode.cite&&(o.value=t.anchorNode.parentNode.cite),null!=i){const e=t.anchorNode.parentNode.classList;i.value=Array.from(e).join(" ")}this.quoteSelection=t.getRangeAt(0).cloneRange(),this.quote=t.anchorNode.parentNode}else t.rangeCount>0&&(this.quoteSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openBlockQuoteDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetBlockQuoteDialog(),this.savedSelection=e?e.cloneRange():null;const o=this.shadowRoot.getElementById("rich-text-box-quote"),i=this.shadowRoot.getElementById("rich-text-box-cite"),n=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");o.value=t.textContent,null!=t.cite&&(i.value=t.cite),null!=n&&(n.value=Array.from(t.classList).join(" ")),this.quoteSelection=e?e.cloneRange():null,this.quote=t,this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),o.focus(),o.scrollTop=0,o.scrollLeft=0};resetBlockQuoteDialog=()=>{this.quote=null,this.quoteSelection=null;this.shadowRoot.getElementById("rich-text-box-quote").value=null;this.shadowRoot.getElementById("rich-text-box-cite").value=null;const t=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");null!=t&&(t.value=null)};insertBlockQuote=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote"),e=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const i=this.quote;i.textContent=t.value,e.value.trim().length>0?i.setAttribute("cite",e.value):i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,i);const n=document.createRange();n.setStartAfter(i),n.collapse(!0),this.savedSelection=n}else if(null!=this.quoteSelection&&t.value.length>0){const i=this.quoteSelection.cloneRange(),n=document.createElement("blockquote");n.textContent=t.value,e.value.trim().length>0?n.cite=e.value:n.hasAttribute("cite")&&n.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,n),i.deleteContents(),i.insertNode(n),i.setStartAfter(n),i.setEndAfter(n),this.savedSelection=i}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class h{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertUploadedImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())});this.shadowRoot.getElementById("rich-text-box-upload-image-file").addEventListener("change",this.handleFileSelect)};handleFileSelect=t=>{const e=t.target.files[0];this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=e.name;const o=document.createElement("img");if(e){const t=new FileReader;t.onloadend=function(){this.base64String=t.result.split(",")[1],o.src=`data:image/jpg;base64,${this.base64String}`},t.readAsDataURL(e),this.image=o}};openUploadImageDialog=t=>{if(null!==t){if(this.resetUploadImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.currentImage=t.anchorNode.querySelector("img"),null!==this.currentImage)){this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=this.currentImage.width;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=this.currentImage.height;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=this.currentImage.alt;this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes").value=Array.from(this.currentImage.classList).join(" ")}this.range=t.getRangeAt(0).cloneRange(),this.shadowRoot.getElementById("rich-text-box-upload-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-upload-btn");e&&e.focus()}};resetUploadImageDialog=()=>{this.currentImage=null,this.image=null,this.range=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");null!=t&&(t.value=null)};insertUploadedImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),e=this.shadowRoot.getElementById("rich-text-box-upload-image-height"),o=this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text"),i=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),t.value.trim().length>0?this.currentImage.width=t.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),e.value.trim().length>0?this.currentImage.height=e.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),o.value.trim().length>0?this.currentImage.alt=o.value:this.currentImage.hasAttribute("alt")&&this.currentImage.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.currentImage),this.Utilities.reselectNode(this.currentImage)):this.image&&(t.value.length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),e.value.length>0?this.image.height=e.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),o.value.length>0?this.image.alt=o.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.image),this.range.deleteContents(),this.range.insertNode(this.image),this.Utilities.reselectNode(this.image)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-upload-image-modal",this.savedSelection)}}class b{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openImageDialog=t=>{if(null!==t){if(this.resetImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.image=t.anchorNode.querySelector("img"),null!==this.image)){this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=this.image.src;this.shadowRoot.getElementById("rich-text-box-image-width").value=this.image.width;this.shadowRoot.getElementById("rich-text-box-image-height").value=this.image.height;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=this.image.alt;this.shadowRoot.getElementById("rich-text-box-image-css-classes").value=Array.from(this.image.classList).join(" ")}t&&t.rangeCount>0&&(this.imageSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-image-webaddress");e&&e.focus()}};resetImageDialog=()=>{this.image=null,this.imageSelection=null;this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-image-css-classes");null!=t&&(t.value=null)};insertImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress"),e=this.shadowRoot.getElementById("rich-text-box-image-width"),o=this.shadowRoot.getElementById("rich-text-box-image-height"),i=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),n=this.shadowRoot.getElementById("rich-text-box-image-css-classes");if(null!==this.imageSelection){const r=this.imageSelection.cloneRange();if(null!==this.image)t.value.trim().length>0&&(this.image.src=t.value),i.value.trim().length>0?this.image.alt=i.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),e.value.trim().length>0?this.image.width=e.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),o.value.trim().length>0?this.image.height=o.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,this.image),this.Utilities.reselectNode(this.image);else if(t.value.length>0){const s=document.createElement("img");s.src=t.value,e.value.trim().length>0&&(s.width=e.value),o.value.trim().length>0&&(s.height=o.value),i.value.trim().length>0&&(s.alt=i.value),null!==n&&this.Utilities.addClasses(n.value,s),r.deleteContents(),r.insertNode(s),this.Utilities.reselectNode(s)}this.imageSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-image-modal",this.savedSelection)}}class u{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertLink()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openLinkDialog=t=>{if(null!==t){if(this.savedSelection=this.Utilities.saveSelection(t),this.resetLinkDialog(),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){this.shadowRoot.getElementById("rich-text-box-linktext").value=t.anchorNode.parentNode.textContent;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=t.anchorNode.parentNode.getAttribute("href");const e=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=e){const o=t.anchorNode.parentNode.classList;e.value=Array.from(o).join(" ")}if("_blank"===t.anchorNode.parentNode.getAttribute("target")){this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!0}this.linkNode=t.anchorNode.parentNode}else{const e=this.shadowRoot.getElementById("rich-text-box-linktext");t.toString().length>0&&(this.linkSelection=t.getRangeAt(0).cloneRange(),e.value=this.linkSelection.toString())}this.shadowRoot.getElementById("rich-text-box-link-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-link-webaddress");e&&e.focus()}};resetLinkDialog=()=>{this.linkNode=null,this.linkSelection=null;this.shadowRoot.getElementById("rich-text-box-linktext").value=null;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!1;const t=this.shadowRoot.getElementById("rich-text-box-link-css-classes");null!=t&&(t.value=null)};insertLink=()=>{const t=this.shadowRoot.getElementById("rich-text-box-linktext"),e=this.shadowRoot.getElementById("rich-text-box-link-webaddress"),o=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),i=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(0!=e.value.length&&0!=t.value.length){if(null!=this.linkNode){const n=this.linkNode;n.href=e.value,n.textContent=t.value,null!==i&&this.Utilities.addClasses(i.value,n),o.checked?n.target="_blank":n.hasAttribute("target")&&n.removeAttribute("target"),this.Utilities.reselectNode(n)}else if(null!=this.linkSelection){const n=this.linkSelection,r=document.createElement("a");r.href=e.value,r.textContent=t.value,null!==i&&this.Utilities.addClasses(i.value,r),o.checked&&(r.target="_blank"),n.deleteContents(),n.insertNode(r),n.setStartBefore(r.firstChild),n.setEndAfter(r.lastChild),this.savedSelection=n}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-link-modal",this.savedSelection)};removeLink=()=>{const t=this.Utilities.getSelection();if(null!==t){const e=this.Utilities.saveSelection(t);if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){const e=t.anchorNode.parentNode,o=document.createDocumentFragment();for(;e.firstChild;)o.appendChild(e.firstChild);e.parentNode.insertBefore(o,e),e.parentNode.removeChild(e)}this.Utilities.restoreSelection(t,e)}}}class g{constructor(t,e,o,i,n){this.shadowRoot=t,this.content=e,this.id=o,this.NodeManager=i,this.Utilities=n,this.init()}init=()=>{this.colorPickerDialog=this.shadowRoot.getElementById(this.id),this.colorPickerDialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertColor()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())}),this.colorPicker=this.colorPickerDialog.querySelector(".rich-text-box-color-picker"),this.redSlider=this.colorPicker.querySelector(".rich-text-box-red-slider"),this.addSliderEventListener(this.redSlider),this.greenSlider=this.colorPicker.querySelector(".rich-text-box-green-slider"),this.addSliderEventListener(this.greenSlider),this.blueSlider=this.colorPicker.querySelector(".rich-text-box-blue-slider"),this.addSliderEventListener(this.blueSlider),this.redValue=this.colorPicker.querySelector(".rich-text-box-red-value"),this.addValueEventListener(this.redValue),this.greenValue=this.colorPicker.querySelector(".rich-text-box-green-value"),this.addValueEventListener(this.greenValue),this.blueValue=this.colorPicker.querySelector(".rich-text-box-blue-value"),this.addValueEventListener(this.blueValue),this.hexInput=this.colorPicker.querySelector(".rich-text-box-hex-input"),this.addHexEventListener(this.hexInput),this.colorDisplay=this.colorPicker.querySelector(".rich-text-box-color-display")};addSliderEventListener=async t=>{t.addEventListener("input",()=>this.updateColor())};addValueEventListener=async t=>{t.addEventListener("input",t=>{let e=Array.from(t.target.classList).find(t=>t.includes("value"));this.colorPicker.querySelector(`.${e.replace("value","slider")}`).value=t.target.value,this.updateColor()}),t.addEventListener("focus",t=>{t.target.select()})};addHexEventListener=async t=>{t.addEventListener("keyup",t=>{/^#?[0-9A-Fa-f]{6}$/.test(t.target.value)&&this.updateFromHex()}),t.addEventListener("change",()=>this.updateFromHex()),t.addEventListener("paste",()=>setTimeout(this.updateFromHex,0)),t.addEventListener("focus",e=>{t.select()})};openColorPicker=(t,e)=>{if(this.resetColorDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!==t&&null!=t.anchorNode&&t.anchorNode!=e&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=e&&e.contains(t.anchorNode.parentNode)&&null!=t.anchorNode.parentNode.style){switch(this.selection=t.getRangeAt(0).cloneRange(),this.id){case"rich-text-box-text-color-modal":t.anchorNode.parentNode.style.color.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.color));break;case"rich-text-box-text-bg-color-modal":t.anchorNode.parentNode.style.backgroundColor.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.backgroundColor))}this.updateFromHex(),this.selection=t.getRangeAt(0).cloneRange()}else null!==t&&t.rangeCount>0&&(this.selection=t.getRangeAt(0).cloneRange());return this.colorPickerDialog.show(),this.selection};insertColor=()=>{let t;switch(this.currentColor=this.getCurrentColor(),this.id){case"rich-text-box-text-color-modal":t="textcolor";break;case"rich-text-box-text-bg-color-modal":t="textbgcolor"}null!==this.selection&&(this.savedSelection=this.Utilities.saveSelection(this.selection),null===this.currentColor?this.NodeManager.updateNode(t,"None",this.selection):this.NodeManager.updateNode(t,this.currentColor,this.selection)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog(this.id,this.savedSelection)};resetColorDialog=()=>{this.selection=null,this.hexInput.value="#000000",this.updateFromHex()};selectColor=t=>{this.hexInput.value=t,this.updateFromHex()};updateColor=()=>{let t=parseInt(this.redSlider.value),e=parseInt(this.greenSlider.value),o=parseInt(this.blueSlider.value),i=`rgb(${t}, ${e}, ${o})`;this.currentColor=i,this.colorDisplay.style.backgroundColor=i,this.redValue.value=t,this.greenValue.value=e,this.blueValue.value=o,this.hexInput.value=this.rgbToHex(t,e,o)};getCurrentColor=()=>this.currentColor;updateFromHex=()=>{let t=this.hexInput.value.trim();if("#"!==t.charAt(0)&&(t="#"+t),/^#[0-9A-Fa-f]{6}$/.test(t)){let e=this.hexToRgb(t);e&&(this.redSlider.value=this.redValue.value=e.r,this.greenSlider.value=this.greenValue.value=e.g,this.blueSlider.value=this.blueValue.value=e.b)}this.updateColor()};rgbToHex=(t,e,o)=>"#"+((1<<24)+(t<<16)+(e<<8)+o).toString(16).slice(1);hexToRgb=t=>{const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null};colorToHex=t=>{const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,e.fillStyle}}window.RTNative_Instances={},window.RTNative_Initialize=(e,o,i,n,r,s)=>{try{null==RTNative_Instances[e]&&(RTNative_Instances[e]=new t(e,o,i,n,s),RTNative_Instances[e].loadHtml(r))}catch(t){console.log(t)}},window.RTNative_Method=(t,e,o)=>{try{const i=RTNative_Instances[e];if(null!=i&&"function"==typeof i[t])return null!=o?i[t](o):i[t]()}catch(t){console.log(t)}};const m={Bold:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z",Italic:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z",Underline:"M200-120v-80h560v80H200Zm280-160q-101 0-157-63t-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63Z",Strikethrough:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z",Subscript:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z",Superscript:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z",Alignleft:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z",Aligncenter:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z",Alignright:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z",Alignjustify:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z",Copy:"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",Cut:"M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6ZM240-160q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z",Paste:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z",Delete:"M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Selectall:"M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z",OrderedList:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z",UnorderedList:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z",CreateLink:"M680-160v-120H560v-80h120v-120h80v120h120v80H760v120h-80ZM440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm560-40h-80q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480Z",RemoveLink:"m770-302-60-62q40-11 65-42.5t25-73.5q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 57-29.5 105T770-302ZM634-440l-80-80h86v80h-6ZM792-56 56-792l56-56 736 736-56 56ZM440-280H280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h65l79 80H320Z",Image:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z",Undo:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z",Redo:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z",CodeBlocks:"m384-336 56-57-87-87 87-87-56-57-144 144 144 144Zm192 0 144-144-144-144-56 57 87 87-87 87 56 57ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z",Code:"M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z",Preview:"M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z",PermMedia:"M360-440h400L622-620l-92 120-62-80-108 140ZM120-120q-33 0-56.5-23.5T40-200v-520h80v520h680v80H120Zm160-160q-33 0-56.5-23.5T200-360v-440q0-33 23.5-56.5T280-880h200l80 80h280q33 0 56.5 23.5T920-720v360q0 33-23.5 56.5T840-280H280Zm0-80h560v-360H527l-80-80H280v440Zm0 0v-440 440Z",TextColor:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z",TextBackgroundColor:"M80 0v-160h800V0H80Zm504-480L480-584 320-424l103 104 161-160Zm-47-160 103 103 160-159-104-104-159 160Zm-84-29 216 216-189 190q-24 24-56.5 24T367-263l-27 23H140l126-125q-24-24-25-57.5t23-57.5l189-189Zm0 0 187-187q24-24 56.5-24t56.5 24l104 103q24 24 24 56.5T857-640L669-453 453-669Z",RemoveTextFormat:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z",Quote:"m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM320-500q25 0 42.5-17.5T380-560q0-25-17.5-42.5T320-620q-25 0-42.5 17.5T260-560q0 25 17.5 42.5T320-500Zm360 0q25 0 42.5-17.5T740-560q0-25-17.5-42.5T680-620q-25 0-42.5 17.5T620-560q0 25 17.5 42.5T680-500Zm0-60Zm-360 0Z",VideoFile:"M360-240h160q17 0 28.5-11.5T560-280v-40l80 42v-164l-80 42v-40q0-17-11.5-28.5T520-480H360q-17 0-28.5 11.5T320-440v160q0 17 11.5 28.5T360-240ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",Table:"M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm80-400h560v-160H200v160Zm213 200h134v-120H413v120Zm0 200h134v-120H413v120ZM200-400h133v-120H200v120Zm427 0h133v-120H627v120ZM200-200h133v-120H200v120Zm427 0h133v-120H627v120Z",IncreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z",DecreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z",UploadImage:"M440-200h80v-167l64 64 56-57-160-160-160 160 57 56 63-63v167ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",SaveHtml:"m720-120 160-160-56-56-64 64v-167h-80v167l-64-64-56 56 160 160ZM560 0v-80h320V0H560ZM240-160q-33 0-56.5-23.5T160-240v-560q0-33 23.5-56.5T240-880h280l240 240v121h-80v-81H480v-200H240v560h240v80H240Zm0-80v-560 560Z",HorizontalRule:"M160-440v-80h640v80H160Z",StatusBar:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-200v120h560v-120H568q-17 18-39.5 29T480-280q-26 0-48.5-11T392-320H200Zm308.5-51.5Q520-383 520-400t-11.5-28.5Q497-440 480-440t-28.5 11.5Q440-417 440-400t11.5 28.5Q463-360 480-360t28.5-11.5ZM200-400h160q0-50 35-85t85-35q50 0 85 35t35 85h160v-360H200v360Zm0 200h560-560Z"};class x extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=x._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText=""}static _defaultVisibility(t=!0){return{font:t,size:t,format:t,textStylesDivider:t,bold:t,italic:t,underline:t,strikethrough:t,subscript:t,superscript:t,formatDivider:t,textColor:t,textColorDivider:t,alignLeft:t,alignCenter:t,alignRight:t,alignJustify:t,alignDivider:t,copy:t,cut:t,paste:t,delete:t,selectAll:t,actionDivider:t,orderedList:t,unorderedList:t,indent:t,listDivider:t,link:t,image:t,imageUpload:t,quote:t,codeBlock:t,embedMedia:t,video:t,table:t,horizontalRule:t,mediaDivider:t,undo:t,redo:t,historyDivider:t,saveHtml:t,htmlView:t,preview:t,statusBarToggle:t,wordCount:!1}}static _injectGlobalStyles(){if(document.getElementById("_rtb-global-styles"))return;const t=document.createElement("style");t.id="_rtb-global-styles",t.textContent="\n/* ── rt-native host defaults ──────────────────────────────────────────────\n Override any --rtb-* variable on rt-native (or a higher-specificity rule\n such as .my-wrapper rt-native or rt-native.my-class) to theme the editor.\n ──────────────────────────────────────────────────────────────────────── */\nrt-native {\n display: block;\n\n /* Toolbar — Fluent 2 colorNeutralBackground1 + colorNeutralStroke1 separator */\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-style: solid;\n --rtb-toolbar-border-width: 1px;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-toolbar-border-radius: 0px;\n\n /* Toolbar dropdowns */\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n\n /* Buttons — transparent at rest, no border */\n --rtb-btn-text: #242424;\n --rtb-btn-size: 16px;\n --rtb-btn-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-style: none;\n --rtb-btn-border-width: 0px;\n --rtb-btn-border-color: #d1d1d1;\n --rtb-btn-border-hover: inherit;\n --rtb-btn-border-selected: inherit;\n --rtb-btn-border-radius: 4px;\n\n /* Editor content area */\n --rtb-content-text: #242424;\n --rtb-content-size: 1rem;\n --rtb-content-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-content-bg: #ffffff;\n --rtb-content-shadow: none;\n --rtb-content-line-height: 1.55;\n --rtb-content-padding: 20px 24px;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-heading-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-heading-weight: 600;\n --rtb-heading-line-height: 1.2;\n --rtb-heading-margin: 0 0 0.55em;\n --rtb-h1-size: 2.15em;\n --rtb-h2-size: 1.65em;\n --rtb-h3-size: 1.35em;\n --rtb-h4-size: 1.15em;\n --rtb-h5-size: 1em;\n --rtb-h6-size: 0.92em;\n --rtb-paragraph-margin: 0 0 0.9em;\n --rtb-list-margin: 0.35em 0 0.9em 1.35em;\n --rtb-list-padding-left: 1.35em;\n --rtb-list-item-margin: 0.18em 0;\n --rtb-link-text: #0969da;\n --rtb-link-decoration: underline;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-inline-code-border-radius: 4px;\n --rtb-code-font: Consolas, Monaco, 'Courier New', monospace;\n --rtb-inline-code-size: 0.92em;\n --rtb-inline-code-padding: 0.15em 0.35em;\n --rtb-hr-border: 1px solid #d1d1d1;\n --rtb-hr-margin: 1.25em 0;\n\n /* Blockquote — brand-blue left accent on a tinted surface */\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-border-width: 5px;\n --rtb-quote-text: #242424;\n --rtb-quote-margin: 1.5em 10px;\n --rtb-quote-padding: 0.5em 10px;\n\n /* Code / pre — neutral surface, Fluent medium corner radius */\n --rtb-code-bg: #f5f5f5;\n --rtb-code-border-radius: 4px;\n --rtb-code-margin: 1.2em 0;\n --rtb-code-padding: 0.85em 1em;\n --rtb-table-margin: 1.2em 0;\n --rtb-table-width: auto;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-cell-min-width: 100px;\n --rtb-table-cell-padding: 6px 10px;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n --rtb-table-header-weight: 600;\n\n /* Editor container — hairline border + featherweight shadow */\n --rtb-editor-width: 100%;\n --rtb-editor-height: 300px;\n --rtb-editor-border-radius: 4px;\n --rtb-editor-border-style: solid;\n --rtb-editor-border-width: 1px;\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-editor-resize: auto;\n\n /* Scrollbars — thin pill-shaped Fluent style */\n --rtb-scroll-width: 6px;\n --rtb-scroll-opacity: 1;\n --rtb-scroll-bg: transparent;\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-scroll-thumb-radius: 3px;\n\n /* Placeholder */\n --rtb-placeholder-color: #9ca3af;\n\n /* Stacking context — raise the entire editor above surrounding content */\n --rtb-z-index: 1;\n\n /* Modals / dialogs */\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-text-size: 1rem;\n --rtb-modal-text-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n --rtb-modal-checkbox: #0078d4;\n}\n\nrt-native.light,\nrt-native.fluent {\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n --rtb-btn-text: #242424;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-color: #d1d1d1;\n\n --rtb-content-text: #242424;\n --rtb-content-bg: #ffffff;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-link-text: #0969da;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-hr-border: 1px solid #d1d1d1;\n\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-text: #242424;\n\n --rtb-code-bg: #f5f5f5;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-placeholder-color: #9ca3af;\n\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n}\n\nrt-native.dark,\nrt-native.fluent-dark {\n --rtb-toolbar-bg: #1f1f1f;\n --rtb-toolbar-border-color: #3f3f46;\n --rtb-dropdown-bg: #242424;\n --rtb-dropdown-text: #f5f5f5;\n --rtb-dropdown-bg-hover: #323238;\n --rtb-dropdown-text-hover: #ffffff;\n --rtb-btn-text: #f5f5f5;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #323238;\n --rtb-btn-bg-selected: #3f3f46;\n --rtb-btn-border-color: #3f3f46;\n\n --rtb-content-text: #f5f5f5;\n --rtb-content-bg: #1f1f1f;\n --rtb-heading-text: #ffffff;\n --rtb-heading-muted-text: #a1a1aa;\n --rtb-link-text: #7ab7ff;\n --rtb-inline-code-bg: rgba(255, 255, 255, 0.12);\n --rtb-hr-border: 1px solid #3f3f46;\n\n --rtb-quote-bg: #10243a;\n --rtb-quote-border-color: #479ef5;\n --rtb-quote-text: #eef6ff;\n\n --rtb-code-bg: #141414;\n --rtb-table-border: 1px solid #52525b;\n --rtb-table-header-bg: #2b2b2b;\n --rtb-table-header-text: #ffffff;\n\n --rtb-editor-border-color: #3f3f46;\n --rtb-editor-shadow: none;\n --rtb-scroll-thumb-bg: #5c5c5c;\n --rtb-scroll-thumb-bg-hover: #7a7a7a;\n --rtb-placeholder-color: #a1a1aa;\n\n --rtb-modal-bg: #242424;\n --rtb-modal-text: #f5f5f5;\n --rtb-modal-input-bg: #1f1f1f;\n --rtb-modal-input-text: #f5f5f5;\n --rtb-modal-input-border: #52525b;\n}\n\n",document.head.appendChild(t)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(t,e,o){if(e!==o){if("value"===t&&this._initialized&&(this._value=o||"",RTNative_Method("loadView",this._uid,o)),"width"===t&&this.style.setProperty("--rtb-editor-width",o||"100%"),"height"===t&&this.style.setProperty("--rtb-editor-height",o||"300px"),"config"===t)try{this.configure(JSON.parse(o))}catch(t){}if("placeholder"===t){const t=RTNative_Instances?.[this._uid];t?.content&&(o?t.content.setAttribute("data-placeholder",o):t.content.removeAttribute("data-placeholder"))}if("readonly"===t){const t=RTNative_Instances?.[this._uid];t&&t.setReadOnly(null!==o)}if("aria-label"===t||"label"===t){const t=RTNative_Instances?.[this._uid];t?.content&&o&&t.content.setAttribute("aria-label",o)}}}connectedCallback(){x._injectGlobalStyles(),this.style.setProperty("--rtb-editor-width",this.getAttribute("width")||"100%"),this.style.setProperty("--rtb-editor-height",this.getAttribute("height")||"300px"),this._render(),requestAnimationFrame(()=>this._initialize())}get readOnly(){return this.hasAttribute("readonly")}setReadOnly(t){t?this.setAttribute("readonly",""):this.removeAttribute("readonly")}disconnectedCallback(){window.RTNative_Instances?.[this._uid]&&delete RTNative_Instances[this._uid]}getValue(){return this._initialized?RTNative_Method("html",this._uid)||this._value||"":this._value||""}getPlainText(){return this._initialized&&RTNative_Method("plaintext",this._uid)||""}setValue(t){const e=(t||"").trim().replace(/>\s+</g,"><");this._value=e,this._initialized&&RTNative_Method("loadView",this._uid,e)}setPreviewCssFiles(...t){this._previewCssUrls=t.filter(t=>t&&"string"==typeof t),this._syncToInstance(),this._applyContentStyles()}setPreviewCssFile(t){this.setPreviewCssFiles(...t?[t]:[])}setPreviewCss(t){this._previewCssText=t||"",this._syncToInstance(),this._applyContentStyles()}_syncToInstance(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];t&&(t._previewCssUrls=this._previewCssUrls,t._previewCssText=this._previewCssText)}_scopeCssText(t,e){t=t.replace(/\/\*[\s\S]*?\*\//g,"");let o="",i=0;for(;i<t.length;){for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length)break;const n=t.indexOf("{",i);if(-1===n)break;const r=t.slice(i,n).trim();let s=1,l=n+1;for(;l<t.length&&s>0;)"{"===t[l]?s++:"}"===t[l]&&s--,l++;const a=t.slice(n+1,l-1);if(i=l,r)if(r.startsWith("@")){const t=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(t)?o+=r+" {\n"+this._scopeCssText(a,e)+"}\n":o+=r+" {"+a+"}\n"}else{o+=r.split(",").map(t=>t.trim()).filter(t=>t).map(t=>":root"===t?e:e+" "+t).join(",\n")+" {"+a+"}\n"}}return o}async _applyContentStyles(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];if(!t||!t.shadowRoot)return;const e=t.shadowRoot.getElementById("_rtb-content-preview-styles");e&&e.remove();const o=".rich-text-box-content";let i="";for(const t of this._previewCssUrls)try{const e=await fetch(t);e.ok?i+=this._scopeCssText(await e.text(),o)+"\n":console.warn(`rt-native: failed to load preview CSS (${e.status}): ${t}`)}catch(e){console.warn(`rt-native: could not load preview CSS: ${t}`,e)}if(this._previewCssText&&(i+=this._scopeCssText(this._previewCssText,o)+"\n"),i.trim()){const e=document.createElement("style");e.id="_rtb-content-preview-styles",e.textContent=i,t.shadowRoot.appendChild(e)}}configure(t={}){const{visibility:e,...o}=t;e&&(e.clearAll&&(this._visibility=x._defaultVisibility(!1)),Object.assign(this._visibility,e)),this._applyCSSVars(o),this._syncPreviewTheme(),this._initialized&&e&&this._reinitialize()}_syncPreviewTheme(){}_applyCSSVars(t){const set=(t,e)=>{null!=e&&this.style.setProperty(t,e)},e=t.toolbar||{};set("--rtb-toolbar-bg",e.backgroundColor),set("--rtb-toolbar-border-style",e.borderStyle),set("--rtb-toolbar-border-width",e.borderWidth),set("--rtb-toolbar-border-color",e.borderColor),set("--rtb-toolbar-border-radius",e.borderRadius),set("--rtb-dropdown-bg",e.dropdownBackgroundColor),set("--rtb-dropdown-text",e.dropdownTextColor),set("--rtb-dropdown-bg-hover",e.dropdownBackgroundColorHover),set("--rtb-dropdown-text-hover",e.dropdownTextColorHover);const o=t.button||{};set("--rtb-btn-text",o.textColor),set("--rtb-btn-size",o.textSize),set("--rtb-btn-font",o.textFont),set("--rtb-btn-bg",o.backgroundColor),set("--rtb-btn-bg-hover",o.backgroundColorHover),set("--rtb-btn-bg-selected",o.backgroundColorSelected),set("--rtb-btn-border-style",o.borderStyle),set("--rtb-btn-border-width",o.borderWidth),set("--rtb-btn-border-color",o.borderColor),set("--rtb-btn-border-hover",o.borderColorHover),set("--rtb-btn-border-selected",o.borderColorSelected),set("--rtb-btn-border-radius",o.borderRadius);const i=t.content||{};set("--rtb-content-text",i.textColor),set("--rtb-content-size",i.textSize),set("--rtb-content-font",i.textFont),set("--rtb-content-bg",i.backgroundColor),set("--rtb-content-shadow",i.boxShadow);const n=t.editor||{};set("--rtb-editor-width",n.width),set("--rtb-editor-height",n.height),set("--rtb-editor-border-radius",n.borderRadius),set("--rtb-editor-border-style",n.borderStyle),set("--rtb-editor-border-width",n.borderWidth),set("--rtb-editor-border-color",n.borderColor),set("--rtb-editor-shadow",n.boxShadow),null!=n.removeResizeHandle&&set("--rtb-editor-resize",n.removeResizeHandle?"visible":"auto");const r=t.scroll||{};set("--rtb-scroll-width",r.width),set("--rtb-scroll-opacity",r.opacity),set("--rtb-scroll-bg",r.backgroundColor),set("--rtb-scroll-thumb-bg",r.thumbBackground),set("--rtb-scroll-thumb-bg-hover",r.thumbBackgroundHover),set("--rtb-scroll-thumb-radius",r.thumbBorderRadius);const s=t.modal||{};set("--rtb-modal-bg",s.backgroundColor),set("--rtb-modal-text",s.textColor),set("--rtb-modal-text-size",s.textSize),set("--rtb-modal-text-font",s.textFont),set("--rtb-modal-input-bg",s.textboxBackgroundColor),set("--rtb-modal-input-text",s.textboxTextColor),set("--rtb-modal-input-border",s.textboxBorderColor),set("--rtb-modal-checkbox",s.checkboxAccentColor);const l=t.quote||{};set("--rtb-quote-bg",l.backgroundColor),set("--rtb-quote-border-color",l.borderColor),set("--rtb-quote-border-width",l.borderWidth);const a=t.code||{};set("--rtb-code-bg",a.backgroundColor),set("--rtb-code-border-radius",a.borderRadius)}_render(){this.innerHTML=this._buildToolbarHTML()+`<div id="${this._uid}_Shadow"></div>`}_initialize(){const e=this.getAttribute("value")||"",o=null!==this._value?this._value:e;this._value=o;const onValueChange=t=>{this._value=t,this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,composed:!0}))};window.RTNative_Instances||(window.RTNative_Instances={}),RTNative_Instances[this._uid]=new t(this._uid,`${this._uid}_Shadow`,`${this._uid}_Toolbar`,'\n.rich-text-box-tool-bar {\n background-color: var(--rtb-toolbar-bg, #FFF);\n border-bottom-style: var(--rtb-toolbar-border-style, solid);\n border-bottom-width: var(--rtb-toolbar-border-width, 1px);\n border-bottom-color: var(--rtb-toolbar-border-color, #EEE);\n border-radius: var(--rtb-toolbar-border-radius, 0px);\n padding-left: 3px;\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n}\n.rich-text-box-tool-bar button {\n background-color: var(--rtb-btn-bg, inherit);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n transition: 0.3s;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-tool-bar button:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-tool-bar button.selected {\n background-color: var(--rtb-btn-bg-selected, #dcdcdc);\n border-color: var(--rtb-btn-border-selected, inherit);\n}\n.rich-text-box-tool-bar button:disabled {\n background-color: transparent;\n color: #999;\n cursor: default;\n}\n.rich-text-box-tool-bar button svg {\n fill: var(--rtb-btn-text, #000);\n width: var(--rtb-btn-size, 16px);\n height: var(--rtb-btn-size, 16px);\n}\n.rich-text-box-tool-bar button:hover svg {\n fill: var(--rtb-btn-text, #000);\n}\n.rich-text-box-tool-bar button:disabled svg {\n fill: #999;\n}\n.rich-text-box-menu-item {}\n.rich-text-box-menu-item-special {}\n.rich-text-box-menu-item svg,\n.rich-text-box-menu-item-special svg {\n display: block;\n height: auto;\n width: auto;\n max-height: 100%;\n max-width: 100%;\n}\n.rich-text-box-menu-item:disabled { color: #999; }\n\n.rich-text-box-container {\n resize: both;\n overflow: var(--rtb-editor-resize, auto);\n border-style: var(--rtb-editor-border-style, solid);\n border-width: var(--rtb-editor-border-width, 1px);\n border-color: var(--rtb-editor-border-color, #EEE);\n border-radius: var(--rtb-editor-border-radius, 0px);\n box-shadow: var(--rtb-editor-shadow, none);\n max-width: var(--rtb-editor-width, 100%);\n height: var(--rtb-editor-height, 300px);\n display: flex;\n flex-direction: column;\n z-index: var(--rtb-z-index, 1);\n}\n.rich-text-box-content-container {\n width: 100%;\n height: 100%;\n overflow: auto;\n display: flex;\n flex-direction: row;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n}\n.rtb-status-bar {\n /* Mirror the toolbar\'s background and typography so every theme is\n automatically reflected without adding status-bar-specific CSS vars. */\n background-color: var(--rtb-toolbar-bg, #ffffff);\n color: var(--rtb-btn-text, #242424);\n font-family: var(--rtb-btn-font, Arial, Helvetica, Verdana, sans-serif);\n font-size: calc(var(--rtb-btn-size, 16px) * 0.9);\n border-top: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n padding: 5px 24px 5px 10px;\n text-align: right;\n user-select: none;\n flex-shrink: 0;\n letter-spacing: 0.2px;\n}\n.rich-text-box-content[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--rtb-placeholder-color, #9ca3af);\n pointer-events: none;\n font-style: italic;\n}\n.rich-text-box-content[contenteditable="false"] {\n cursor: default;\n opacity: 0.85;\n}\n.rich-text-box-content {\n color: var(--rtb-content-text, #000);\n font-size: var(--rtb-content-size, 16px);\n font-family: var(--rtb-content-font, Arial, sans-serif);\n line-height: var(--rtb-content-line-height, 1.55);\n padding: var(--rtb-content-padding, 20px 24px);\n width: 100%;\n min-height: 25px;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: 0px solid transparent;\n}\n.rich-text-box-content h1,\n.rich-text-box-content h2,\n.rich-text-box-content h3,\n.rich-text-box-content h4,\n.rich-text-box-content h5,\n.rich-text-box-content h6 {\n color: var(--rtb-heading-text, var(--rtb-content-text, #242424));\n font-family: var(--rtb-heading-font, var(--rtb-content-font, Arial, sans-serif));\n font-weight: var(--rtb-heading-weight, 600);\n line-height: var(--rtb-heading-line-height, 1.2);\n margin: var(--rtb-heading-margin, 0 0 0.55em);\n padding: 0;\n border: 0;\n border-bottom: 0;\n text-decoration: none !important;\n}\n.rich-text-box-content h1 { font-size: var(--rtb-h1-size, 2.15em); }\n.rich-text-box-content h2 { font-size: var(--rtb-h2-size, 1.65em); }\n.rich-text-box-content h3 { font-size: var(--rtb-h3-size, 1.35em); }\n.rich-text-box-content h4 { font-size: var(--rtb-h4-size, 1.15em); }\n.rich-text-box-content h5 { font-size: var(--rtb-h5-size, 1em); }\n.rich-text-box-content h6 {\n color: var(--rtb-heading-muted-text, #6b7280);\n font-size: var(--rtb-h6-size, 0.92em);\n}\n.rich-text-box-content p { margin: var(--rtb-paragraph-margin, 0 0 0.9em); }\n.rich-text-box-content ul,\n.rich-text-box-content ol {\n margin: var(--rtb-list-margin, 0.35em 0 0.9em 1.35em);\n padding-left: var(--rtb-list-padding-left, 1.35em);\n}\n.rich-text-box-content li { margin: var(--rtb-list-item-margin, 0.18em 0); }\n.rich-text-box-content a {\n color: var(--rtb-link-text, #0969da);\n text-decoration: var(--rtb-link-decoration, underline);\n}\n.rich-text-box-content blockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\n.rich-text-box-content blockquote > :first-child {\n margin-top: 0;\n}\n.rich-text-box-content blockquote > :last-child {\n margin-bottom: 0;\n}\n.rich-text-box-content code {\n background: var(--rtb-inline-code-bg, rgba(175, 184, 193, 0.2));\n border-radius: var(--rtb-inline-code-border-radius, 4px);\n font-family: var(--rtb-code-font, Consolas, Monaco, \'Courier New\', monospace);\n font-size: var(--rtb-inline-code-size, 0.92em);\n padding: var(--rtb-inline-code-padding, 0.15em 0.35em);\n}\n.rich-text-box-content pre {\n background: var(--rtb-code-bg, #f5f5f5);\n border-radius: var(--rtb-code-border-radius, 4px);\n margin: var(--rtb-code-margin, 1.2em 0);\n overflow-x: auto;\n padding: var(--rtb-code-padding, 0.85em 1em);\n white-space: pre-wrap;\n}\n.rich-text-box-content pre code {\n background: transparent;\n border-radius: 0;\n display: block;\n padding: 0;\n}\n.rich-text-box-content hr {\n border: 0;\n border-top: var(--rtb-hr-border, 1px solid #d1d1d1);\n margin: var(--rtb-hr-margin, 1.25em 0);\n}\n.rich-text-box-content table {\n border-collapse: collapse;\n margin: var(--rtb-table-margin, 1.2em 0);\n width: var(--rtb-table-width, auto);\n}\n.rich-text-box-content th,\n.rich-text-box-content td {\n border: var(--rtb-table-border, 1px solid #d1d1d1);\n min-width: var(--rtb-table-cell-min-width, 100px);\n padding: var(--rtb-table-cell-padding, 6px 10px);\n}\n.rich-text-box-content th {\n background: var(--rtb-table-header-bg, #f5f5f5);\n color: var(--rtb-table-header-text, var(--rtb-content-text, #242424));\n font-weight: var(--rtb-table-header-weight, 600);\n}\n.rich-text-box-content img { cursor: pointer; }\n.rich-text-box-source {\n padding: 10px;\n width: 100%;\n min-height: 25px;\n color: var(--rtb-content-text, #000) !important;\n font-size: var(--rtb-content-size, 16px) !important;\n white-space: pre-wrap;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n border-style: none;\n display: none;\n resize: none;\n margin: 0;\n line-height: 1.6;\n outline: 0px solid transparent;\n}\n.rich-text-box-divider-btn {\n background-color: inherit;\n align-items: center;\n justify-content: center;\n text-align: center;\n border: none !important;\n outline: none;\n cursor: pointer;\n padding: 3px 4px;\n transition: 0.3s;\n margin: 4px 1px;\n}\n.rich-text-box-divider-btn[disabled],\n.rich-text-box-divider-btn[disabled]:hover,\n.rich-text-box-divider-btn[disabled]:focus,\n.rich-text-box-divider-btn[disabled]:active {\n background: unset;\n color: unset;\n cursor: default;\n}\n.rich-text-box-divider {\n min-height: 25px;\n height: var(--rtb-btn-size, 16px);\n background-color: var(--rtb-btn-text, #000);\n display: block;\n border-left: 0.5px solid rgba(255, 255, 255, 0.6);\n opacity: 0.5;\n}\n.rich-text-box-scroll::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n opacity: var(--rtb-scroll-opacity, 1);\n}\n.rich-text-box-scroll::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n cursor: default;\n}\n.rich-text-box-dropdown { position: relative; display: inline-block; }\n.rich-text-box-dropdown-content {\n display: none;\n position: absolute;\n background-color: var(--rtb-dropdown-bg, #FFF);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: 5px;\n max-height: 200px;\n overflow: auto;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2);\n font-family: Arial, sans-serif !important;\n z-index: 2;\n}\n.rich-text-box-dropdown-btn {\n font-size: var(--rtb-btn-size, 16px);\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n padding: 0 10px;\n}\n.rich-text-box-font-button,\n.rich-text-box-size-button,\n.rich-text-box-format-button {\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n font-size: calc(var(--rtb-btn-size, 16px) * 0.9);\n font-weight: 400;\n line-height: normal;\n}\n.rich-text-box-format-content { min-width: 185px; }\n.rich-text-box-font-content { min-width: 180px; }\n.rich-text-box-size-content { min-width: 80px; }\n.rich-text-box-dropdown-content a {\n color: var(--rtb-dropdown-text, #000);\n font-size: 18px;\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n}\n.rich-text-box-dropdown a:hover,\n.rich-text-box-menu-item.active {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rich-text-box-show { display: block; }\n\n.rich-text-box-modal {\n background-color: var(--rtb-modal-bg, #fefefe);\n color: var(--rtb-modal-text, #000);\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n margin: auto;\n padding: 6px 16px 14px;\n border: 1px solid #888;\n width: 800px;\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);\n border-radius: 5px;\n user-select: none;\n z-index: 2;\n}\n.rich-text-box-modal-title {\n font-weight: bold;\n font-size: calc(var(--rtb-modal-text-size, 16px) + 2px);\n}\n.rtb-modal-header {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n padding-bottom: 10px;\n}\n.rich-text-box-form-left { float: left; width: 380px; }\n.rich-text-box-form-right { float: right; width: 380px; }\n@media screen and (max-width: 850px) {\n .rich-text-box-form-left,\n .rich-text-box-form-right { float: none; }\n .rich-text-box-modal { width: 400px; }\n}\n@media screen and (max-width: 500px) {\n .rich-text-box-modal { width: 100%; }\n}\n.clearfix { overflow: auto; }\n.clearfix::after { content: ""; clear: both; display: table; }\n.rich-text-box-modal-close {\n appearance: none;\n background: none;\n border: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n align-self: center;\n width: 32px;\n height: 32px;\n min-width: 32px;\n min-height: 32px;\n max-width: 32px;\n max-height: 32px;\n border-radius: 50%;\n padding: 0;\n color: var(--rtb-modal-text, #000);\n cursor: pointer;\n opacity: 0.75;\n}\n/* SVG icon inside the close button — block display eliminates inline\n baseline offset so the flex centering acts on the icon bounds only.\n Width/height are set via CSS (not just SVG attributes) so the size is\n reliably enforced regardless of browser presentation-attribute handling. */\n.rich-text-box-modal-close svg { display: block; width: 11px; height: 11px; }\n.rich-text-box-modal-close:hover {\n opacity: 1;\n background: rgba(128, 128, 128, 0.18);\n}\n.rich-text-box-modal-close:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n.rich-text-box-modal-body { padding: 2px 8px; }\n.rtb-preview-window {\n flex: 1;\n min-height: 0;\n width: 100%;\n overflow: auto;\n border: 1px solid var(--rtb-editor-border-color, #eee);\n border-radius: 4px;\n box-sizing: border-box;\n display: block;\n}\n.rtb-preview-window::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-preview-window::-webkit-scrollbar-track { background: transparent; }\n.rtb-preview-window::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-preview-window::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n/* Preview dialog — flex column layout so the dialog itself is resizable and\n the html viewer automatically fills the remaining space.\n display is intentionally NOT set here so the browser UA rule\n dialog:not([open]){display:none} still applies when the dialog is closed.\n display:flex is only added when the dialog is open (has the [open] attr). */\n.rtb-preview-dialog {\n padding: 6px 12px 10px;\n flex-direction: column;\n height: 520px;\n min-width: 400px;\n min-height: 300px;\n max-width: 95vw;\n max-height: 95vh;\n resize: both;\n overflow: hidden;\n box-sizing: border-box;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n}\n.rtb-preview-dialog[open] {\n display: flex;\n}\n.rtb-preview-dialog::backdrop {\n background: transparent;\n}\n.rtb-preview-dialog-body {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n overflow: hidden;\n gap: 6px;\n}\n.rich-text-box-form-element {\n width: 100%;\n padding: 10px;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px;\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0;\n border-radius: 0px;\n box-sizing: border-box;\n margin-top: 0px;\n margin-bottom: 16px;\n resize: vertical;\n}\n.rich-text-box-form-element:disabled {\n color: #999;\n border-color: #DDD;\n cursor: default;\n}\n.rich-text-box-form-checkbox {\n outline: none;\n width: 20px;\n height: 20px;\n margin-right: 8px;\n accent-color: var(--rtb-modal-checkbox, #007bff);\n}\n.rich-text-box-form-checkbox:focus {\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n border-width: 1px;\n box-shadow: 0 0 5px 2px rgba(169, 169, 169, 0.8);\n}\n.rich-text-box-upload-btn {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n transition: 0.3s;\n background-color: var(--rtb-btn-bg, inherit);\n border: 1px solid var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n min-width: 100% !important;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-upload-btn:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-form-button {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n transition: 0.3s;\n}\n.rich-text-box-form-button:focus {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.blazing-rich-text-color-picker-container { position: relative; }\n.blazing-rich-text-color-picker-button { min-height: calc(var(--rtb-btn-size, 16px) + 14px); }\n.blazing-rich-text-color-picker-dropdown { width: 80px; padding: 10px 10px 6px 10px; }\n.blazing-rich-text-color-option {\n width: 15px; height: 15px; margin: 2px; cursor: pointer;\n display: inline-block; border: 1px solid #999;\n}\n.blazing-rich-text-color-option:hover { border-color: #000; }\n.blazing-rich-text-color-selection {\n width: 100%; border-style: solid; border-width: 1px; border-color: #999;\n height: 40px; cursor: pointer; display: inline-block;\n}\n.rich-text-box-quote { font-family: var(--rtb-modal-text-font, Arial, sans-serif); }\n.rich-text-box-code { overflow: auto !important; white-space: pre; }\n.rich-text-box-message-bar {\n font-size: var(--rtb-content-size, 16px);\n background-color: rgba(0, 0, 0, 0.6);\n color: white;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 5px 10px;\n opacity: 1;\n transform: translateY(0);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n pointer-events: auto;\n}\n.rich-text-box-message-bar.rich-text-box-message-hidden {\n opacity: 0; height: 0; padding: 0; color: transparent; pointer-events: none;\n}\n.rich-text-box-message {}\n.rich-text-box-message-close-button {\n background: none; border: none; color: white; font-size: 18px; cursor: pointer;\n}\n.rich-text-box-color-picker { width: 100%; }\n.rich-text-box-color-display { width: 100%; height: 50px; border: 1px solid #ccc; margin: 20px 0; }\n.rich-text-box-slider-container { display: flex; align-items: center; margin-bottom: 10px; }\n.rich-text-box-slider-container label {\n width: 20px; margin-right: 10px;\n color: var(--rtb-modal-text, #000);\n}\n.rich-text-box-range { width: 100%; -webkit-appearance: none; cursor: pointer; }\n.rich-text-box-range:focus { outline: none; }\n.rich-text-box-range::-webkit-slider-runnable-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-red-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(255,0,0) 100%) !important;\n}\n.rich-text-box-green-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,255,0) 100%) !important;\n}\n.rich-text-box-blue-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,0,255) 100%) !important;\n}\n.rich-text-box-range::-moz-range-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-range::-webkit-slider-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-range::-moz-range-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-number {\n width: 100px; margin-left: 10px; padding: 5px; font-size: 14px;\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px; border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0; border-radius: 0px; box-sizing: border-box;\n}\n.rich-text-box-hex-container { display: flex; align-items: center; margin-top: 20px; }\n.rich-text-box-hex-input { width: 100px !important; margin-left: 10px; }\nblockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\npre {\n background: var(--rtb-code-bg, #f9f9f9);\n border-radius: var(--rtb-code-border-radius, 10px);\n overflow-x: auto; white-space: pre-wrap; margin: 1.5em 10px; padding: 0.5em 10px;\n}\ntable { border-collapse: collapse; }\ntd, th { border: 1px solid #ccc; padding: 4px 6px; height: 25px; min-width: 100px; }\n',{invokeMethodAsync:(t,e)=>onValueChange(e)}),RTNative_Instances[this._uid]._rtbHostElement=this;const i=this.getAttribute("aria-label")||this.getAttribute("label");i&&RTNative_Instances[this._uid].content.setAttribute("aria-label",i);const n=this.getAttribute("placeholder");n&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",n),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid].loadHtml(o),this._initialized=!0,this._syncToInstance(),this._applyContentStyles()}_reinitialize(){const t=this.getValue();delete RTNative_Instances[this._uid],this._initialized=!1,this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._render(),requestAnimationFrame(()=>{this._initialize(),t&&this.setValue(t)})}_svg(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="${m[t]}"/></svg>`}_btn(t,e,o,i,n){return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==n?`RTNative_Method('${i}','${this._uid}','${n}')`:`RTNative_Method('${i}','${this._uid}')`}">${this._svg(e)}</button>`}_specialBtn(t,e,o,i){return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${i}','${this._uid}')">${this._svg(e)}</button>`}_divider(){return'<button class="rich-text-box-divider-btn" disabled><div class="rich-text-box-divider"></div></button>'}_fontDropdown(){const t=this._uid,e=["None","Arial","Arial Narrow","Baskerville","Brush Script","Calibri","Cambria","Candara","Century Gothic","Claude Garamond","Comic Sans MS","Copperplate","Courier","Didot","Georgia","Gill Sans","Helvetica","Impact","Lucida Bright","Monospace","Optima","Palatino","Segoe UI","Tahoma","Times New Roman","Trebuchet MS","Verdana"].map(e=>`<a class="rich-text-box-menu-item" style="font-family:${e};cursor:pointer" onclick="RTNative_Method('font','${t}','${e}')">${e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-font-button" title="Font" class="rich-text-box-font-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-font-button-dropdown')">Font</button>\n <div id="blazing-rich-text-font-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-font-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_sizeDropdown(){const t=this._uid,e=["None","8","9","10","11","12","14","16","18","20","22","24","26","28","36","48","64"].map(e=>`<a class="rich-text-box-menu-item" style="${"None"===e?"":`font-size:${e}px !important;`}cursor:pointer" onclick="RTNative_Method('size','${t}','${"None"===e?"None":`${e}px`}')">${"None"===e?"None":e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-size-button" title="Size (Ctrl+Shift+[&lt;,&gt;])" class="rich-text-box-size-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-size-button-dropdown')">Size</button>\n <div id="blazing-rich-text-size-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-size-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_formatDropdown(){const t=this._uid;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-format-button" title="Format (Ctrl+Shift+[D,P,1,2...])" class="rich-text-box-format-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-format-button-dropdown')">Format</button>\n <div id="blazing-rich-text-format-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-format-content rich-text-box-scroll">\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','none')">None</a>\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','p')">Paragraph</a>\n <a class="rich-text-box-menu-item" style="font-size:34px;cursor:pointer" onclick="RTNative_Method('format','${t}','h1')">Header 1</a>\n <a class="rich-text-box-menu-item" style="font-size:30px;cursor:pointer" onclick="RTNative_Method('format','${t}','h2')">Header 2</a>\n <a class="rich-text-box-menu-item" style="font-size:24px;cursor:pointer" onclick="RTNative_Method('format','${t}','h3')">Header 3</a>\n <a class="rich-text-box-menu-item" style="font-size:20px;cursor:pointer" onclick="RTNative_Method('format','${t}','h4')">Header 4</a>\n <a class="rich-text-box-menu-item" style="font-size:18px;cursor:pointer" onclick="RTNative_Method('format','${t}','h5')">Header 5</a>\n <a class="rich-text-box-menu-item" style="font-size:16px;cursor:pointer" onclick="RTNative_Method('format','${t}','h6')">Header 6</a>\n </div>\n</div>`}_colorSwatches(t){return["#FFFFFF","#DCDCDC","#A9A9A9","#696969","#303030","#000000","#FFCCCC","#FF6666","#FF3333","#FF0000","#CC0000","#990000","#800000","#CCFFCC","#99FF99","#66FF66","#33CC33","#009900","#CCCCFF","#9999FF","#6666FF","#3333CC","#000099","#002060","#FFFFCC","#FFFF99","#FFFF66","#CCCC33","#999900","#CCFFFF","#99FFFF","#66FFFF","#33CCCC","#009999","#FFCCFF","#FF99FF","#FF66FF","#CC33CC","#990099","#FFDDCC","#FFBB99","#FF9966","#FF7733","#CC4400","#E0CCFF","#C199FF","#A366FF","#8533FF","#6600CC"].map(e=>`<div class="blazing-rich-text-color-option" onclick="RTNative_Method('${t}','${this._uid}','${e}')" style="background-color:${e};"></div>`).join("")}_colorDialog(t,e,o,i){const n=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${n}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div class="rich-text-box-color-picker">\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n ${this._colorSwatches(o)}\n <div class="rich-text-box-color-display"></div>\n </div>\n <div class="rich-text-box-form-right">\n <div class="rich-text-box-slider-container">\n <label>R</label>\n <input type="range" class="rich-text-box-range rich-text-box-red-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-red-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>G</label>\n <input type="range" class="rich-text-box-range rich-text-box-green-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-green-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>B</label>\n <input type="range" class="rich-text-box-range rich-text-box-blue-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-blue-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-hex-container">\n <label>Hex:</label>\n <input type="text" class="rich-text-box-form-element rich-text-box-hex-input" value="#000000" autocomplete="off">\n </div>\n </div>\n </div>\n <div style="text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${n}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${i}','${n}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(t,e,o,i){const n=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${n}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div>\n ${i}\n <div style="margin-top:5px;text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${n}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${o}','${n}')">OK</button>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const t=this._uid,e=this._visibility,o=(e.font||e.size||e.format)&&e.textStylesDivider,i=(e.bold||e.italic||e.underline||e.strikethrough||e.subscript||e.superscript)&&e.formatDivider,n=e.textColor&&e.textColorDivider,r=(e.alignLeft||e.alignCenter||e.alignRight||e.alignJustify)&&e.alignDivider,s=(e.copy||e.cut||e.paste||e.delete||e.selectAll)&&e.actionDivider,l=(e.orderedList||e.unorderedList||e.indent)&&e.listDivider,a=(e.link||e.image||e.imageUpload||e.quote||e.codeBlock||e.embedMedia||e.video||e.table||e.horizontalRule)&&e.mediaDivider,c=(e.undo||e.redo)&&e.historyDivider;return`\n<div id="${t}_Toolbar" class="rich-text-box-tool-bar" role="toolbar" aria-label="Formatting toolbar">\n\n ${e.font?this._fontDropdown():""}\n ${e.size?this._sizeDropdown():""}\n ${e.format?this._formatDropdown():""}\n ${o?this._divider():""}\n\n ${e.bold?this._btn("blazing-rich-text-bold-button","Bold","Bold (Ctrl+B)","bold"):""}\n ${e.italic?this._btn("blazing-rich-text-italic-button","Italic","Italic (Ctrl+I)","italic"):""}\n ${e.underline?this._btn("blazing-rich-text-underline-button","Underline","Underline (Ctrl+U)","underline"):""}\n ${e.strikethrough?this._btn("blazing-rich-text-strike-button","Strikethrough","Strikethrough (Ctrl+D)","strikethrough"):""}\n ${e.subscript?this._btn("blazing-rich-text-sub-button","Subscript","Subscript (Ctrl+=)","subscript"):""}\n ${e.superscript?this._btn("blazing-rich-text-super-button","Superscript","Superscript (Ctrl+Shift++)","superscript"):""}\n ${i?this._divider():""}\n\n ${e.textColor?this._btn("blazing-rich-text-textcolor-button","TextColor","Text Color (Ctrl+Shift+C)","openTextColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-text-bg-color-button","TextBackgroundColor","Text Background Color (Ctrl+Shift+B)","openTextBackgroundColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-textcolor-remove-button","RemoveTextFormat","Remove Color","removeTextColor"):""}\n ${n?this._divider():""}\n\n ${e.alignLeft?this._btn("blazing-rich-text-alignleft-button","Alignleft","Align Left (Ctrl+L)","alignleft"):""}\n ${e.alignCenter?this._btn("blazing-rich-text-aligncenter-button","Aligncenter","Align Center (Ctrl+E)","aligncenter"):""}\n ${e.alignRight?this._btn("blazing-rich-text-alignright-button","Alignright","Align Right (Ctrl+R)","alignright"):""}\n ${e.alignJustify?this._btn("blazing-rich-text-alignjustify-button","Alignjustify","Align Justify (Ctrl+J)","alignjustify"):""}\n ${r?this._divider():""}\n\n ${e.cut?this._btn("blazing-rich-text-cut-button","Cut","Cut (Ctrl+X)","cut"):""}\n ${e.copy?this._btn("blazing-rich-text-copy-button","Copy","Copy (Ctrl+C)","copy"):""}\n ${e.paste?this._btn("blazing-rich-text-paste-button","Paste","Paste (Ctrl+V)","paste"):""}\n ${e.delete?this._btn("blazing-rich-text-delete-button","Delete","Delete","delete"):""}\n ${e.selectAll?this._btn("blazing-rich-text-selectall-button","Selectall","Select All (Ctrl+A)","selectall"):""}\n ${s?this._divider():""}\n\n ${e.orderedList?this._btn("blazing-rich-text-orderedlist-button","OrderedList","Ordered List (Ctrl+Shift+O)","orderedlist"):""}\n ${e.unorderedList?this._btn("blazing-rich-text-unorderedlist-button","UnorderedList","Unordered List (Ctrl+Shift+U)","unorderedlist"):""}\n ${e.indent?this._btn("blazing-rich-text-increase-indent-button","IncreaseIndent","Increase Indent (Tab)","increaseIndent"):""}\n ${e.indent?this._btn("blazing-rich-text-decrease-indent-button","DecreaseIndent","Decrease Indent (Shift+Tab)","decreaseIndent"):""}\n ${l?this._divider():""}\n\n ${e.link?this._btn("blazing-rich-text-link-button","CreateLink","Insert Link (Ctrl+Shift+K)","openLinkDialog"):""}\n ${e.link?this._btn("blazing-rich-text-remove-link-button","RemoveLink","Remove Link","removeLink"):""}\n ${e.image?this._btn("blazing-rich-text-image-button","Image","Insert Image (Ctrl+Shift+I)","openImageDialog"):""}\n ${e.imageUpload?this._btn("blazing-rich-text-image-upload-button","UploadImage","Upload Image (Ctrl+Shift+&)","uploadImageDialog"):""}\n ${e.quote?this._btn("blazing-rich-text-quote-button","Quote","Block Quote (Ctrl+Shift+Q)","openBlockQuoteDialog"):""}\n ${e.embedMedia?this._btn("blazing-rich-text-embed-button","PermMedia","Insert Media (Ctrl+Shift+M)","openMediaDialog"):""}\n ${e.video?this._btn("blazing-rich-text-video-button","VideoFile","Insert Video (Ctrl+Shift+V)","openVideoDialog"):""}\n ${e.table?this._btn("blazing-rich-text-table-button","Table","Table (Ctrl+Shift+L)","openTableDialog"):""}\n ${e.codeBlock?this._btn("blazing-rich-text-code-block-button","CodeBlocks","Code Block (Ctrl+Shift+*)","openCodeBlockDialog"):""}\n ${e.horizontalRule?this._btn("blazing-rich-text-hr-button","HorizontalRule","Horizontal Rule (Ctrl+Shift+H)","insertHorizontalRule"):""}\n ${a?this._divider():""}\n\n ${e.undo?this._btn("blazing-rich-text-undo-button","Undo","Undo (Ctrl+Z)","goBack"):""}\n ${e.redo?this._btn("blazing-rich-text-redo-button","Redo","Redo (Ctrl+Y)","goForward"):""}\n ${c?this._divider():""}\n\n ${e.statusBarToggle?this._btn("blazing-rich-text-statusbar-button","StatusBar","Toggle Status Bar (Ctrl+\\)","toggleStatusBar"):""}\n ${e.saveHtml?this._specialBtn("blazing-rich-text-save-button","SaveHtml","Save HTML (Ctrl+Shift+S)","saveHtml"):""}\n ${e.htmlView?this._specialBtn("blazing-rich-text-source","Code","HTML Source (Ctrl+Shift+A)","toggleView"):""}\n ${e.preview?this._specialBtn("blazing-rich-text-preview-button","Preview","Preview (Ctrl+Shift+P)","openPreview"):""}\n\n ${this._colorDialog("rich-text-box-text-color-modal","Text Color","selectTextColor","insertTextColor")}\n ${this._colorDialog("rich-text-box-text-bg-color-modal","Text Background Color","selectTextBackgroundColor","insertTextBackgroundColor")}\n\n ${this._genericDialog("rich-text-box-table-modal","Table","insertTable",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Columns</label>\n <input type="number" id="rich-text-box-table-columns" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Rows</label>\n <input type="number" id="rich-text-box-table-rows" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n <label>Width</label>\n <input type="text" id="rich-text-box-table-width" class="rich-text-box-form-element" placeholder="500px">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-table-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-embed-modal","Media","insertMedia",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-source" placeholder="e.g., /documents/file.pdf" autocomplete="off">\n <label>Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-type" placeholder="e.g., audio/mp3, application/pdf" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-width" placeholder="450" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-height" placeholder="250" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-video-modal","Video","insertVideo",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source" placeholder="e.g., /videos/movie.mp4" autocomplete="off">\n <label>Source Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source-type" placeholder="e.g., video/mp4" autocomplete="off">\n <label>Poster Image URL</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-poster" placeholder="e.g., /images/poster.jpg" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-width" placeholder="640" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-height" placeholder="360" autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-css-classes" placeholder="class1 class2 class3">\n </div>\n <div style="clear:both;display:grid;grid-template-columns:1fr 1fr;gap:2px 20px;margin-top:10px;">\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-controls">\n Controls\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-autoplay">\n Autoplay\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-loop">\n Loop\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-muted">\n Muted\n </label>\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-code-block-modal","Code Block","insertCodeBlock",'\n <div class="clearfix">\n <label>Code Block</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-code rich-text-box-scroll" id="rich-text-box-code" spellcheck="false"></textarea>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-code-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-block-quote-modal","Block Quote","insertBlockQuote",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Quote</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-quote rich-text-box-scroll" id="rich-text-box-quote"></textarea>\n </div>\n <div class="rich-text-box-form-right">\n <label>Cite</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-cite" placeholder="https://www..." autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-quote-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-image-modal","Image","insertImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-webaddress" placeholder="https://www..." autocomplete="off">\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-upload-image-modal","Upload / Embed Image","uploadImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <div style="height:40px;padding:20px 0 10px 0;">\n <input type="file" id="rich-text-box-upload-image-file" hidden>\n <label for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn">Choose File</label>\n <span id="rich-text-box-upload-image-file-chosen">No file chosen</span>\n </div>\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-link-modal","Link","insertLink",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-webaddress" placeholder="https://www..." autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Link Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-linktext" autocomplete="off">\n <label style="display:flex;align-items:center;margin-bottom:12px;">\n <input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox">\n Open in New Tab\n </label>\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n\n ${this._buildPreviewDialogHTML()}\n\n</div>`}_buildPreviewDialogHTML(){const t=this._uid;return`\n<dialog id="${t}_Preview" class="rich-text-box-modal rich-text-box-scroll rtb-preview-dialog" aria-modal="true" aria-labelledby="${t}_Preview-title">\n <div class="rtb-modal-header">\n <div id="${t}_Preview-title" class="rich-text-box-modal-title">Preview</div>\n <div style="display:flex;gap:2px;align-items:center;">\n <button id="${t}_PreviewMaxBtn" class="rich-text-box-modal-close" aria-label="Maximize preview" onclick="RTNative_Method('togglePreviewMaximize','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="11" height="11" style="display:block"><path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg></button>\n <button class="rich-text-box-modal-close" aria-label="Close preview" onclick="RTNative_Method('closePreview','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n </div>\n <div class="rtb-preview-dialog-body">\n <div id="rich-text-box-preview" class="rtb-preview-window"></div>\n <div style="text-align:right;flex-shrink:0;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closePreview','${t}')">Close</button>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",x);
2
2
  //# sourceMappingURL=rt-native.js.map