rt-native 2.9.33 → 2.9.35

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/rt-native.js CHANGED
@@ -1,2 +1,2 @@
1
- class e{constructor(e,t,n,i,o){this.id=e,this.shadow_id=t,this.toolbar_id=n,this.styles=i,this.dotNetObjectReference=o,this._selectAllActive=!1,this.init()}init=()=>{this.hydrateShadowTree(),this.observeDefaultParagraphs(),this.Utilities=new r(this.shadowRoot,this.content),this.NodeManager=new n(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new o(this.shadowRoot,this.content,this.Utilities),this.ListProvider=new i(this.shadowRoot,this.content,this.Utilities,this.NodeManager),this.ColorPickers={};const e="rich-text-box-text-color-modal",p="rich-text-box-text-bg-color-modal";this.ColorPickers[e]=new g(this.shadowRoot,this.content,e,this.NodeManager,this.Utilities),this.ColorPickers[p]=new g(this.shadowRoot,this.content,p,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 c(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new d(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 t(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners(),this.addToolbarMenuKeyboardNavigation(),this.setDefaultParagraphSeparator()};hydrateShadowTree=()=>{const e=document.getElementById(this.shadow_id);this.shadowRoot=e.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=this.styles,this.shadowRoot.appendChild(t),this.contentContainer=document.createElement("div"),this.contentContainer.classList.add("rich-text-box-content-container","rich-text-box-scroll"),this.contentContainer.style.position="relative",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,this.openFileInput=document.createElement("input"),this.openFileInput.type="file",this.openFileInput.accept=".html,.htm,text/html",this.openFileInput.style.display="none",this.dropOverlay=document.createElement("div"),this.dropOverlay.className="rtb-drop-overlay",this.dropOverlay.innerHTML='\n <div class="rtb-drop-zone">\n <div class="rtb-drop-icon">HTML</div>\n <div class="rtb-drop-title">Drop HTML file to open</div>\n <div class="rtb-drop-subtitle">.html or .htm</div>\n </div>\n ',this.imageResizeOverlay=document.createElement("div"),this.imageResizeOverlay.className="rtb-image-resize-overlay",this.imageResizeOverlay.setAttribute("aria-hidden","true"),["nw","n","ne","e","se","s","sw","w"].forEach(e=>{const t=document.createElement("span");t.className=`rtb-image-resize-handle rtb-image-resize-${e}`,t.dataset.direction=e,this.imageResizeOverlay.appendChild(t)}),this.tableResizeOverlay=document.createElement("div"),this.tableResizeOverlay.className="rtb-table-resize-overlay",this.tableResizeOverlay.setAttribute("aria-hidden","true"),["nw","n","ne","e","se","s","sw","w"].forEach(e=>{const t=document.createElement("span");t.className=`rtb-table-resize-handle rtb-image-resize-${e}`,t.dataset.direction=e,this.tableResizeOverlay.appendChild(t)});const n=document.createElement("div");n.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),n.setAttribute("id","rich-text-box-message-bar");const i=document.createElement("span");i.setAttribute("class","rich-text-box-message");const o=document.createElement("button");o.setAttribute("class","rich-text-box-message-close-button"),o.textContent="×",o.onclick=()=>{this.Utilities.closeFadingBar()},n.appendChild(i),n.appendChild(o),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.statusLink=document.createElement("span"),this.statusLink.className="rtb-status-link",this.statusCount=document.createElement("span"),this.statusCount.className="rtb-status-count",this.statusCount.textContent="0 words · 0 characters",this.statusBar.append(this.statusLink,this.statusCount),this.findBar=document.createElement("div"),this.findBar.className="rtb-find-bar",this.findBar.setAttribute("role","search"),this.findBar.setAttribute("aria-label","Find in editor"),this.findBar.style.display="none",this.findBar.innerHTML='\n <input type="text" class="rtb-find-input" placeholder="Find..." aria-label="Find text" autocomplete="off" spellcheck="false">\n <span class="rtb-find-count" aria-live="polite"></span>\n <button class="rtb-find-nav-btn" title="Previous match (Shift+Enter)" aria-label="Previous match"><svg viewBox="0 -960 960 960"><path d="M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"/></svg></button>\n <button class="rtb-find-nav-btn" title="Next match (Enter)" aria-label="Next match"><svg viewBox="0 -960 960 960"><path d="M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"/></svg></button>\n <button class="rtb-find-close-btn" title="Close (Escape)" aria-label="Close find bar"><svg viewBox="0 -960 960 960"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></button>\n ',this._findMatches=[],this._findIndex=-1,this._findHighlightName=`rtb-find-match-${String(this.id).replace(/[^a-z0-9_-]/gi,"-")}`;const r=document.createElement("style");r.textContent=`::highlight(${this._findHighlightName}) { background: Highlight; color: HighlightText; }`,this.shadowRoot.appendChild(r),this._sourceFindHighlight=document.createElement("div"),this._sourceFindHighlight.setAttribute("aria-hidden","true"),this._sourceFindHighlight.style.display="none",this._sourceFindHighlight.style.pointerEvents="none",this._sourceFindHighlight.style.position="absolute",this._sourceFindHighlight.style.zIndex="2",this._sourceFindHighlight.style.color="transparent",this._sourceFindHighlight.style.background="transparent";const s=document.getElementById(this.toolbar_id);this.container.appendChild(s),this._setupToolbarOverflow(s),this.contentContainer.appendChild(this.content),this.contentContainer.appendChild(this.source),this.contentContainer.appendChild(this._sourceFindHighlight),this.contentContainer.appendChild(this.openFileInput),this.contentContainer.appendChild(this.dropOverlay),this.contentContainer.appendChild(this.imageResizeOverlay),this.contentContainer.appendChild(this.tableResizeOverlay),this.contextMenu=document.createElement("div"),this.contextMenu.className="rtb-context-menu",this.contextMenu.setAttribute("role","menu"),this.contextMenu.setAttribute("aria-hidden","true"),this.container.appendChild(n),this.container.appendChild(this.findBar),this.container.appendChild(this.contentContainer),this.container.appendChild(this.statusBar),this.container.appendChild(this.contextMenu),this.shadowRoot.appendChild(this.container)};observeDefaultParagraphs=()=>{const applyDefaultStyle=e=>{if(!(e instanceof Element))return;(e.matches("p")?[e]:Array.from(e.querySelectorAll("p"))).forEach(e=>{e.style.overflowWrap||(e.style.overflowWrap="break-word")})};this._paragraphObserver=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(applyDefaultStyle)})}),this._paragraphObserver.observe(this.content,{childList:!0,subtree:!0})};isDocumentFocusDrift=()=>{const e=document.activeElement;return!e||e===document.body||e===document.documentElement||e===this.shadowRoot.host};shouldRecoverEditorTab=e=>{if(e.defaultPrevented||"Tab"!==e.key||e.ctrlKey||e.altKey||e.metaKey)return!1;const t=e.composedPath?e.composedPath():[];if(t.includes(this.shadowRoot)||t.includes(this.container))return!1;if(!this.isDocumentFocusDrift())return!1;const n=this.Utilities.getSelection();return!!(n&&n.rangeCount>0&&this.isSelectionInsideEditor(n))};recoverEditorTab=e=>{this.shouldRecoverEditorTab(e)&&(e.preventDefault(),e.stopPropagation(),this.content.focus({preventScroll:!0}),this.keyEvents(e))};_setupToolbarOverflow=e=>{const t=new Set(["blazing-rich-text-file-button","blazing-rich-text-font-button","blazing-rich-text-size-button","blazing-rich-text-format-button","blazing-rich-text-insert-button"]),isPinned=e=>{if(!e.classList.contains("rich-text-box-dropdown"))return!1;const n=e.querySelector(":scope > button");return n&&t.has(n.id)},n=[],i=[],o=[];for(const t of Array.from(e.children))"DIALOG"===t.tagName?o.push(t):isPinned(t)?n.push(t):i.push(t);const r=document.createElement("div");r.className="rtb-toolbar-items";for(const e of i)r.appendChild(e);for(;e.firstChild;)e.removeChild(e.firstChild);for(const t of n)e.appendChild(t);e.appendChild(r);const s=document.createElement("button");s.className="rtb-overflow-btn",s.setAttribute("aria-label","More options"),s.setAttribute("title","More options (Alt+M)"),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-haspopup","true"),s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg>';const l=document.createElement("div");l.className="rtb-overflow-dropdown",l.setAttribute("role","toolbar"),l.setAttribute("aria-label","More toolbar options");const a=document.createElement("div");a.className="rtb-overflow-wrapper",a.style.display="none",a.appendChild(s),a.appendChild(l),e.appendChild(a),s.addEventListener("click",t=>{t.stopPropagation();const n=l.classList.toggle("rtb-overflow-open");s.setAttribute("aria-expanded",String(n)),n&&(l.style.maxWidth=e.offsetWidth-10+"px")}),l.addEventListener("click",()=>{l.classList.remove("rtb-overflow-open"),s.setAttribute("aria-expanded","false")}),document.addEventListener("click",t=>{t.composedPath().includes(e)||(l.classList.remove("rtb-overflow-open"),s.setAttribute("aria-expanded","false"))}),this._overflowBtn=s,this._overflowDropdown=l,this._overflowWrapper=a,this._overflowItemsContainer=r,this._overflowToolbar=e;const d=new ResizeObserver(()=>this._scheduleOverflowUpdate());d.observe(e),d.observe(r),d.observe(this.container),d.observe(this.contentContainer),this._overflowResizeObserver=d;for(const t of o)e.appendChild(t)};_scheduleOverflowUpdate=()=>{this._overflowItemsContainer&&!this._overflowUpdatePending&&(this._overflowUpdatePending=!0,requestAnimationFrame(()=>{this._overflowUpdatePending=!1,this._updateToolbarOverflow(),this.resizeOpenToolbarDropdowns()}))};_updateToolbarOverflow=()=>{const e=this._overflowItemsContainer,t=this._overflowWrapper,n=this._overflowDropdown,i=this._overflowToolbar;if(!e)return;if(n.classList.contains("rtb-overflow-open")&&(n.style.maxWidth=i.offsetWidth-10+"px"),Array.from(n.children).forEach(t=>e.appendChild(t)),t.style.display="none",e.scrollWidth<=e.offsetWidth)return;t.style.display="";const o=Array.from(e.children);for(let t=o.length-1;t>=0&&!(e.scrollWidth<=e.offsetWidth);t--)n.insertBefore(o[t],n.firstChild);n.firstChild||(t.style.display="none")};isOverflowOptionsVisible=()=>!(!this._overflowWrapper||!this._overflowBtn)&&("none"!==window.getComputedStyle(this._overflowWrapper).display&&!this._overflowBtn.disabled);isMoreOptionsShortcut=e=>e.altKey&&!e.ctrlKey&&!e.metaKey&&("m"===e.key.toLowerCase()||"KeyM"===e.code);getToolbarDropdownShortcutId=e=>{if(!e.altKey||e.ctrlKey||e.metaKey)return null;switch(e.key.toLowerCase()){case"l":return"blazing-rich-text-file-button-dropdown";case"f":return"blazing-rich-text-font-button-dropdown";case"s":return"blazing-rich-text-size-button-dropdown";case"t":return"blazing-rich-text-format-button-dropdown";case"i":return"blazing-rich-text-insert-button-dropdown";default:return null}};handleToolbarDropdownShortcut=e=>{const t=this.getToolbarDropdownShortcutId(e);return!!t&&(e.preventDefault(),this.openToolbarDropdown(t,!0),!0)};focusActiveEditor=()=>{this.EditMode?this.content.focus():this.source.focus()};getToolbarMenuItems=e=>e?Array.from(e.querySelectorAll("a.rich-text-box-menu-item, button.rich-text-box-menu-item, button.rich-text-box-menu-item-special, button.rich-text-box-insert-item, .rtb-overflow-dropdown button")).filter(e=>!e.disabled&&null!==e.offsetParent):[];focusToolbarMenuItem=(e,t)=>{const n=this.getToolbarMenuItems(e);if(0===n.length)return;const i=(t+n.length)%n.length;n.forEach(e=>{e.setAttribute("tabindex","-1"),e.classList.remove("active")}),n[i].classList.add("active"),n[i].focus({preventScroll:!0}),n[i].scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"})};focusFirstToolbarMenuItem=e=>{requestAnimationFrame(()=>this.focusToolbarMenuItem(e,0))};handleToolbarMenuArrowKey=(e,t)=>{const n=this.getToolbarMenuItems(t);if(0===n.length)return;const i=Math.max(0,n.indexOf(e.target)),o=t===this._overflowDropdown?"ArrowRight":"ArrowDown",r=t===this._overflowDropdown?"ArrowLeft":"ArrowUp";e.key===o&&(e.preventDefault(),this.focusToolbarMenuItem(t,i+1)),e.key===r&&(e.preventDefault(),this.focusToolbarMenuItem(t,i-1)),"Home"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,0)),"End"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,n.length-1))};addToolbarMenuKeyboardNavigation=()=>{this.shadowRoot.addEventListener("keydown",e=>{if(e.defaultPrevented)return;if(this.handleToolbarDropdownShortcut(e))return;if(this.isMoreOptionsShortcut(e))return void(this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)));const t=e.target.closest(".rich-text-box-dropdown-content.rich-text-box-show, .rtb-overflow-dropdown.rtb-overflow-open");if(t)return["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key)&&this.handleToolbarMenuArrowKey(e,t),"Escape"===e.key&&(e.preventDefault(),this.NodeManager.closeDropdowns(),this.focusActiveEditor()),void("Enter"!==e.key&&" "!==e.key||!this.getToolbarMenuItems(t).includes(e.target)||(e.preventDefault(),e.target.click()));const n=e.target.closest(".rich-text-box-dropdown-btn");if(n&&["ArrowDown","ArrowUp"].includes(e.key)){e.preventDefault();const t=n.parentElement?.querySelector(".rich-text-box-dropdown-content");if(t){t.classList.contains("rich-text-box-show")||this.openToolbarDropdown(t.id);const n="ArrowUp"===e.key?this.getToolbarMenuItems(t).length-1:0;requestAnimationFrame(()=>this.focusToolbarMenuItem(t,n))}}if(e.target===this._overflowBtn&&["ArrowLeft","ArrowRight"].includes(e.key)&&this.isOverflowOptionsVisible()){e.preventDefault(),this._overflowDropdown.classList.contains("rtb-overflow-open")||this.openOverflowOptions();const t="ArrowLeft"===e.key?this.getToolbarMenuItems(this._overflowDropdown).length-1:0;requestAnimationFrame(()=>this.focusToolbarMenuItem(this._overflowDropdown,t))}})};showImageResizeHandles=e=>{e&&"IMG"===e.tagName&&this.content.contains(e)&&(this.hideTableResizeHandles(),this.selectedResizeImage=e,this.imageResizeOverlay.classList.add("rtb-image-resize-visible"),this.positionImageResizeHandles())};hideImageResizeHandles=()=>{this._imageResizeState||(this.selectedResizeImage=null,this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"))};showTableResizeHandles=e=>{e&&"TABLE"===e.tagName&&this.content.contains(e)&&(this.hideImageResizeHandles(),this.selectedResizeTable=e,this.positionTableResizeHandles(),this.tableResizeOverlay.classList.add("rtb-table-resize-visible"),this._selectedTableResizeObserver||(this._selectedTableResizeObserver=new ResizeObserver(()=>{this.selectedResizeTable&&this.positionTableResizeHandles()})),this._selectedTableResizeObserver.disconnect(),this._selectedTableResizeObserver.observe(e))};hideTableResizeHandles=()=>{this._tableResizeState||(this._selectedTableResizeObserver?.disconnect(),this.selectedResizeTable=null,this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"))};positionTableResizeHandles=()=>{const e=this.selectedResizeTable;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideTableResizeHandles();const t=e.getBoundingClientRect(),n=this.contentContainer.getBoundingClientRect();this.tableResizeOverlay.style.left=`${t.left-n.left+this.contentContainer.scrollLeft}px`,this.tableResizeOverlay.style.top=`${t.top-n.top+this.contentContainer.scrollTop}px`,this.tableResizeOverlay.style.width=`${t.width}px`,this.tableResizeOverlay.style.height=`${t.height}px`};trackTableResizeTransition=()=>{const e=performance.now(),track=t=>{this.positionTableResizeHandles(),t-e<90&&this.selectedResizeTable&&requestAnimationFrame(track)};requestAnimationFrame(track)};startTableResize=e=>{const t=this.selectedResizeTable,n=e.currentTarget.dataset.direction;if(!t||!n)return;e.preventDefault(),e.stopPropagation();const i=t.getBoundingClientRect();this._tableResizeState={table:t,direction:n,startX:e.clientX,startY:e.clientY,startWidth:i.width,startHeight:i.height},this.tableResizeOverlay.classList.add("rtb-table-resizing"),e.currentTarget.setPointerCapture(e.pointerId)};resizeSelectedTable=e=>{const t=this._tableResizeState;if(!t)return;e.preventDefault();const n=e.clientX-t.startX,i=e.clientY-t.startY,o=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(o&&r){const e=t.direction.includes("w")?-n:n,o=t.direction.includes("n")?-i:i,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+o)/t.startHeight,l=Math.max(1/t.startWidth,1/t.startHeight,Math.abs(r-1)>=Math.abs(s-1)?r:s);t.table.style.width=`${Math.max(1,Math.round(t.startWidth*l))}px`,t.table.style.height=`${Math.max(1,Math.round(t.startHeight*l))}px`}else if(o){const e=t.direction.includes("w")?-n:n;t.table.style.width=`${Math.max(1,Math.round(t.startWidth+e))}px`}else if(r){const e=t.direction.includes("n")?-i:i;t.table.style.height=`${Math.max(1,Math.round(t.startHeight+e))}px`}this.positionTableResizeHandles()};finishTableResize=()=>{this._tableResizeState&&(this._tableResizeState=null,this.tableResizeOverlay.classList.remove("rtb-table-resizing"),this.positionTableResizeHandles())};getTableCellResizeEdge=e=>{const t=e.target instanceof Element?e.target.closest("td, th"):null,n=t?.closest("table");if(!t||!n||!this.content.contains(n))return null;const i=t.getBoundingClientRect(),o=[],r=t.parentElement,s=r?.rowIndex??-1,l=t.cellIndex;l>0&&o.push({axis:"column",index:l-1,distance:Math.abs(e.clientX-i.left)}),r&&l<r.cells.length-1&&o.push({axis:"column",index:l,distance:Math.abs(e.clientX-i.right)}),s>0&&o.push({axis:"row",index:s-1,distance:Math.abs(e.clientY-i.top)}),s>=0&&s<n.rows.length-1&&o.push({axis:"row",index:s,distance:Math.abs(e.clientY-i.bottom)}),0===l&&o.push({axis:"table-column",direction:"w",distance:Math.abs(e.clientX-i.left)}),r&&l===r.cells.length-1&&o.push({axis:"table-column",direction:"e",distance:Math.abs(e.clientX-i.right)}),0===s&&o.push({axis:"table-row",direction:"n",distance:Math.abs(e.clientY-i.top)}),s===n.rows.length-1&&o.push({axis:"table-row",direction:"s",distance:Math.abs(e.clientY-i.bottom)});const a=o.filter(e=>e.distance<=5).sort((e,t)=>e.distance-t.distance)[0];return a?{...a,table:n}:null};updateTableCellResizeCursor=e=>{if(this._tableCellResizeState)return;const t=this.getTableCellResizeEdge(e);this._tableCellResizeEdge=t,t?this.content.style.setProperty("--rtb-table-cell-cursor","column"===t.axis||"table-column"===t.axis?"ew-resize":"ns-resize"):this.content.style.removeProperty("--rtb-table-cell-cursor")};clearTableCellResizeCursor=()=>{this._tableCellResizeState||(this._tableCellResizeEdge=null,this.content.style.removeProperty("--rtb-table-cell-cursor"))};startTableCellResize=e=>{const t=this.getTableCellResizeEdge(e);if(!t)return;e.preventDefault(),e.stopPropagation();const{table:n,axis:i,index:o,direction:r}=t;if("column"===i){const t=Array.from(n.rows).map(e=>e.cells[o]).filter(e=>e&&1===e.colSpan);if(0===t.length)return;this._tableCellResizeState={axis:i,table:n,cells:t,startPosition:e.clientX,startSize:t[0].getBoundingClientRect().width}}else if("row"===i){const t=n.rows[o];if(!t)return;this._tableCellResizeState={axis:i,table:n,row:t,startPosition:e.clientY,startSize:t.getBoundingClientRect().height}}else{const t=n.getBoundingClientRect();this._tableCellResizeState={axis:i,direction:r,table:n,startPosition:"table-column"===i?e.clientX:e.clientY,startSize:"table-column"===i?t.width:t.height}}this.content.style.cursor="column"===i||"table-column"===i?"ew-resize":"ns-resize",this.content.setPointerCapture(e.pointerId)};resizeTableCellBoundary=e=>{const t=this._tableCellResizeState;if(t){if(e.preventDefault(),"column"===t.axis){const n=Math.max(24,Math.round(t.startSize+e.clientX-t.startPosition));t.cells.forEach(e=>{e.style.width=`${n}px`,e.style.minWidth=`${n}px`}),this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else if("row"===t.axis){const n=Math.max(24,Math.round(t.startSize+e.clientY-t.startPosition));t.row.style.height=`${n}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}else if("table-column"===t.axis){const n=e.clientX-t.startPosition,i=Math.max(24,Math.round(t.startSize+("w"===t.direction?-n:n)));t.table.style.width=`${i}px`,this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else{const n=e.clientY-t.startPosition,i=Math.max(24,Math.round(t.startSize+("n"===t.direction?-n:n)));t.table.style.height=`${i}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}this.selectedResizeTable===t.table&&this.positionTableResizeHandles()}};finishTableCellResize=()=>{this._tableCellResizeState&&(this._tableCellResizeState=null,this._tableCellResizeEdge=null,this.content.style.cursor="",this.content.style.removeProperty("--rtb-table-cell-cursor"),this.positionTableResizeHandles())};positionImageResizeHandles=()=>{const e=this.selectedResizeImage;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideImageResizeHandles();const t=e.getBoundingClientRect(),n=this.contentContainer.getBoundingClientRect();this.imageResizeOverlay.style.left=`${t.left-n.left+this.contentContainer.scrollLeft}px`,this.imageResizeOverlay.style.top=`${t.top-n.top+this.contentContainer.scrollTop}px`,this.imageResizeOverlay.style.width=`${t.width}px`,this.imageResizeOverlay.style.height=`${t.height}px`};trackImageResizeTransition=()=>{const e=performance.now(),track=t=>{this.positionImageResizeHandles(),t-e<90&&this.selectedResizeImage&&requestAnimationFrame(track)};requestAnimationFrame(track)};startImageResize=e=>{const t=this.selectedResizeImage,n=e.currentTarget.dataset.direction;if(!t||!n)return;e.preventDefault(),e.stopPropagation();const i=t.getBoundingClientRect();this._imageResizeState={image:t,direction:n,startX:e.clientX,startY:e.clientY,startWidth:i.width,startHeight:i.height},this.imageResizeOverlay.classList.add("rtb-image-resizing"),e.currentTarget.setPointerCapture(e.pointerId)};resizeSelectedImage=e=>{const t=this._imageResizeState;if(!t)return;e.preventDefault();const n=e.clientX-t.startX,i=e.clientY-t.startY,o=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(o&&r){const e=t.direction.includes("w")?-n:n,o=t.direction.includes("n")?-i:i,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+o)/t.startHeight,l=Math.max(1/t.startWidth,1/t.startHeight,Math.abs(r-1)>=Math.abs(s-1)?r:s);t.image.width=Math.max(1,Math.round(t.startWidth*l)),t.image.height=Math.max(1,Math.round(t.startHeight*l))}else if(o){const e=t.direction.includes("w")?-n:n;t.image.width=Math.max(1,Math.round(t.startWidth+e))}else if(r){const e=t.direction.includes("n")?-i:i;t.image.height=Math.max(1,Math.round(t.startHeight+e))}this.positionImageResizeHandles()};finishImageResize=()=>{this._imageResizeState&&(this._imageResizeState=null,this.imageResizeOverlay.classList.remove("rtb-image-resizing"),this.positionImageResizeHandles())};alignSelectedResizeImage=e=>{const t=this.selectedResizeImage;return!(!t||!this.content.contains(t))&&(this.selectResizeImageRange(),this.NodeManager.updateNode(e),requestAnimationFrame(this.positionImageResizeHandles),this.clearResizeImageRange(),!0)};selectResizeImageRange=()=>{const e=this.selectedResizeImage;if(!e||!this.content.contains(e))return null;if(e.parentNode===this.content){const t=document.createElement("p");t.style.overflowWrap="break-word",this.content.insertBefore(t,e),t.appendChild(e)}const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const n=document.createRange();return n.selectNode(e),t.removeAllRanges(),t.addRange(n),t};clearResizeImageRange=()=>{if(!this.selectedResizeImage||!this.content.contains(this.selectedResizeImage))return;const e=this.Utilities.getSelection()||window.getSelection();e?.removeAllRanges()};toggleListForSelectedResizeImage=e=>{const t=this.selectedResizeImage;if(!t||!this.content.contains(t))return!1;this.selectResizeImageRange();const n=t.closest("ol, ul");if(n&&this.content.contains(n))this.ListProvider.addlist(e);else{const n=t.parentElement;if(!n||n===this.content)return!1;const i=document.createElement(e),o=document.createElement("li");for(;n.firstChild;)o.appendChild(n.firstChild);i.appendChild(o),n.replaceWith(i),this.selectResizeImageRange()}return requestAnimationFrame(this.positionImageResizeHandles),this.clearResizeImageRange(),!0};selectResizeTableRange=()=>{const e=this.selectedResizeTable;if(!e||!this.content.contains(e))return null;const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const n=document.createRange();return n.selectNode(e),t.removeAllRanges(),t.addRange(n),t};clearResizeTableRange=()=>{if(!this.selectedResizeTable||!this.content.contains(this.selectedResizeTable))return;const e=this.Utilities.getSelection()||window.getSelection();e?.removeAllRanges()};isSelectionInsideSelectedTableCell=()=>{if(!this.selectedResizeTable||!this.content.contains(this.selectedResizeTable))return!1;const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return!1;const t=e.anchorNode instanceof Element?e.anchorNode:e.anchorNode?.parentElement,n=t?.closest("td, th");return!!n&&this.selectedResizeTable.contains(n)};alignSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.NodeManager.alignTable(t,e),this.NodeManager.refreshUI(),this.trackTableResizeTransition(),this.clearResizeTableRange(),!0)};toggleListForSelectedResizeTable=e=>{const t=this.selectedResizeTable;if(!t||!this.content.contains(t))return!1;const n=t.closest("ol, ul");if(n&&this.content.contains(n))if(n.nodeName===e){const e=t.closest("li");n.parentNode.insertBefore(t,n.nextSibling),e?.remove(),n.querySelector("li")||n.remove()}else{const t=document.createElement(e);for(;n.firstChild;)t.appendChild(n.firstChild);n.replaceWith(t)}else{const n=document.createElement(e),i=document.createElement("li");t.replaceWith(n),i.appendChild(t),n.appendChild(i)}return this.trackTableResizeTransition(),this.clearResizeTableRange(),!0};indentSelectedResizeTable=e=>{const t=this.selectedResizeTable;if(!t||!this.content.contains(t))return!1;const n=parseFloat(window.getComputedStyle(t).marginLeft)||0,i=e?n+40:Math.max(0,n-40);return i>0?t.style.marginLeft=`${i}px`:(t.style.removeProperty("margin-left"),0===t.style.length&&t.removeAttribute("style")),this.trackTableResizeTransition(),!0};addEventListeners=()=>{document.addEventListener("keydown",this.recoverEditorTab,!0),this.shadowRoot.addEventListener("keydown",e=>{this.trapDialogFocus(e)}),this._overflowToolbar&&this._overflowToolbar.addEventListener("mousedown",e=>{if(e.target.closest("dialog"))return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&e.preventDefault()},!1),document.addEventListener("selectionchange",e=>{const t=this.Utilities.getSelection();null!==t&&(this.clearSettings(t.anchorNode),this._hoveredStatusLink||this._updateStatusLinkFromNode(t.anchorNode))}),this.content.addEventListener("mouseover",e=>{const t=e.target instanceof Element?e.target.closest("a"):null;t&&this.content.contains(t)&&(this._hoveredStatusLink=t,this._setStatusLink(t.href))}),this.content.addEventListener("mouseout",e=>{if(!this._hoveredStatusLink)return;if((e.relatedTarget instanceof Element?e.relatedTarget.closest("a"):null)===this._hoveredStatusLink)return;this._hoveredStatusLink=null;const t=this.Utilities.getSelection();this._updateStatusLinkFromNode(t?.anchorNode)}),this.content.addEventListener("click",e=>{if("IMG"===e.target.tagName)this.showImageResizeHandles(e.target);else{this.hideImageResizeHandles();const t=e.target instanceof Element?e.target.closest("table"):null;t&&this.content.contains(t)?this.showTableResizeHandles(t):this.hideTableResizeHandles()}"A"===e.target.tagName&&(e.preventDefault(),e.stopPropagation())}),this.content.addEventListener("click",e=>{const t=e.target.tagName;if("VIDEO"===t||"SOURCE"===t){e.preventDefault();const n="SOURCE"===t?e.target.closest("video"):e.target;if(n&&n.parentNode===this.content){if(!n.nextSibling){const e=document.createElement("p");e.appendChild(document.createElement("br")),this.content.insertBefore(e,null)}const e=n.nextSibling,t=window.getSelection();if(t&&e){const n=document.createRange(),i=e.firstChild??e;n.setStart(i,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}}},!0),this.content.addEventListener("dblclick",e=>{const t=e.target.tagName;"VIDEO"!==t&&"SOURCE"!==t||e.preventDefault()},!0),this.content.addEventListener("dblclick",e=>{switch(e.target.tagName){case"A":e.preventDefault(),this.openLinkDialog();break;case"IMG":e.preventDefault();const t=this.Utilities.getSelection(),n=document.createRange();n.selectNode(e.target),t&&(t.removeAllRanges(),t.addRange(n)),e.target.src.startsWith("data")?this.uploadImageDialog():this.openImageDialogForElement(e.target);break;case"VIDEO":case"SOURCE":{e.preventDefault();const t="SOURCE"===e.target.tagName?e.target.closest("video"):e.target;if(t){const e=this.Utilities.getSelection(),n=document.createRange();n.selectNode(t),e.removeAllRanges(),e.addRange(n),this.openVideoDialogForElement(t)}else this.openVideoDialog();break}case"BLOCKQUOTE":e.preventDefault(),this.openBlockQuoteDialogForElement(e.target);break;case"PRE":e.preventDefault(),this.openCodeBlockDialogForElement(e.target);break;case"TD":case"TH":{const t=e.target.closest("table");t&&this.content.contains(t)&&(e.preventDefault(),this.openTableDialog());break}case"CODE":{const t=e.target.closest("pre");t&&this.content.contains(t)&&(e.preventDefault(),this.openCodeBlockDialogForElement(t));break}default:{const t=e.target.closest("pre");if(t&&this.content.contains(t)){e.preventDefault(),this.openCodeBlockDialogForElement(t);break}const n=e.target.closest("blockquote");if(n&&this.content.contains(n))e.preventDefault(),this.openBlockQuoteDialogForElement(n);else{const e=this.Utilities.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const t=e.getRangeAt(0),n=t.endContainer;if(n.nodeType===Node.TEXT_NODE){const i=n.textContent;let o=t.endOffset;for(;o>0&&/\s/.test(i[o-1]);)o--;o!==t.endOffset&&(t.setEnd(n,o),e.removeAllRanges(),e.addRange(t))}}}break}}}),this.content.addEventListener("input",e=>{this._selectAllActive=!1,this.updateWordCount();const t=this.Utilities.getSelection(),n=t.getRangeAt(0).startContainer;if(n.nodeType===Node.TEXT_NODE&&"SPAN"===n.parentNode.tagName){const e=n.parentNode,i=e.parentNode;if(this.NodeManager.isFormatElement(i)){if(!(e.style.color||e.style.backgroundColor||e.style.fontFamily||e.style.fontSize||e.style.fontWeight||e.style.fontStyle||e.style.textDecoration)){for(;e.firstChild;)i.insertBefore(e.firstChild,e);i.removeChild(e);const n=document.createRange();n.setStart(i.firstChild,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}}}),this.content.addEventListener("keydown",e=>{this.keyEvents(e)}),this.source.addEventListener("keydown",e=>{"Tab"!==e.key?(e.ctrlKey&&!e.shiftKey&&"f"===e.key&&(e.preventDefault(),this.openFindBar()),e.ctrlKey&&!e.shiftKey&&"/"===e.key&&(e.preventDefault(),this.openHelpDialog()),e.altKey&&!e.ctrlKey&&"l"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-file-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"f"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-font-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"s"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-size-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"t"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-format-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"i"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-insert-button-dropdown",!0)),this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),e.ctrlKey&&!e.shiftKey&&"s"===e.key.toLowerCase()&&(e.preventDefault(),this.saveHtml()),e.ctrlKey&&!e.shiftKey&&"o"===e.key.toLowerCase()&&(e.preventDefault(),this.openHtmlFile()),e.ctrlKey&&e.shiftKey&&"A"===e.key&&(e.preventDefault(),!0===this.EditMode?this.getHtml():this.getCode()),e.ctrlKey&&e.shiftKey&&"P"===e.key&&(e.preventDefault(),this.openPreview()),e.ctrlKey&&!e.shiftKey&&"\\"===e.key&&(e.preventDefault(),this.toggleStatusBar())):e.preventDefault()}),this.openFileInput.addEventListener("change",e=>{this.openDroppedOrSelectedHtmlFile(e.target.files?.[0]),e.target.value=""}),["dragenter","dragover"].forEach(e=>{this.contentContainer.addEventListener(e,e=>{this.dragEventHasHtmlFile(e)&&(e.preventDefault(),this.dropOverlay.classList.add("rtb-drop-overlay-visible"))})}),["dragleave","dragend"].forEach(e=>{this.contentContainer.addEventListener(e,t=>{"dragleave"===e&&this.contentContainer.contains(t.relatedTarget)||this.dropOverlay.classList.remove("rtb-drop-overlay-visible")})}),this.contentContainer.addEventListener("drop",e=>{this.dragEventHasHtmlFile(e)&&(e.preventDefault(),this.dropOverlay.classList.remove("rtb-drop-overlay-visible"),this.openDroppedOrSelectedHtmlFile(e.dataTransfer.files?.[0]))}),this.imageResizeOverlay.querySelectorAll(".rtb-image-resize-handle").forEach(e=>{e.addEventListener("pointerdown",this.startImageResize)}),this.tableResizeOverlay.querySelectorAll(".rtb-table-resize-handle").forEach(e=>{e.addEventListener("pointerdown",this.startTableResize)}),this.content.addEventListener("pointermove",this.updateTableCellResizeCursor),this.content.addEventListener("pointerleave",this.clearTableCellResizeCursor),this.content.addEventListener("pointerdown",this.startTableCellResize),document.addEventListener("pointermove",this.resizeSelectedImage),document.addEventListener("pointermove",this.resizeSelectedTable),document.addEventListener("pointermove",this.resizeTableCellBoundary),document.addEventListener("pointerup",this.finishImageResize),document.addEventListener("pointerup",this.finishTableResize),document.addEventListener("pointerup",this.finishTableCellResize),document.addEventListener("pointercancel",this.finishImageResize),document.addEventListener("pointercancel",this.finishTableResize),document.addEventListener("pointercancel",this.finishTableCellResize),document.addEventListener("pointerdown",e=>{if(!this.selectedResizeImage&&!this.selectedResizeTable||this._imageResizeState||this._tableResizeState)return;const t=e.composedPath(),n=new Set(["blazing-rich-text-alignleft-button","blazing-rich-text-aligncenter-button","blazing-rich-text-alignright-button","blazing-rich-text-alignjustify-button","blazing-rich-text-orderedlist-button","blazing-rich-text-unorderedlist-button","blazing-rich-text-increase-indent-button","blazing-rich-text-decrease-indent-button","blazing-rich-text-cut-button","blazing-rich-text-copy-button","blazing-rich-text-paste-button","blazing-rich-text-delete-button"]);t.some(e=>e instanceof Element&&n.has(e.id))||this.selectedResizeImage&&t.some(e=>e instanceof Element&&"blazing-rich-text-image-button"===e.id)||this.selectedResizeTable&&t.some(e=>e instanceof Element&&"blazing-rich-text-table-button"===e.id)||(!this.selectedResizeImage||t.includes(this.selectedResizeImage)||t.includes(this.imageResizeOverlay)||this.hideImageResizeHandles(),!this.selectedResizeTable||t.includes(this.selectedResizeTable)||t.includes(this.tableResizeOverlay)||this.hideTableResizeHandles())}),this.contentContainer.addEventListener("scroll",this.positionImageResizeHandles),this.contentContainer.addEventListener("scroll",this.positionTableResizeHandles),window.addEventListener("resize",this.positionImageResizeHandles),window.addEventListener("resize",this.positionTableResizeHandles);this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(e=>{e.addEventListener("mousedown",e=>{e.preventDefault()})});const e=this.findBar.querySelector(".rtb-find-input"),t=this.findBar.querySelector(".rtb-find-count"),[n,i]=this.findBar.querySelectorAll(".rtb-find-nav-btn"),o=this.findBar.querySelector(".rtb-find-close-btn");e.addEventListener("paste",t=>{t.preventDefault();const n=(t.clipboardData||window.clipboardData).getData("text").trim(),i=e.selectionStart,o=e.selectionEnd;e.value=e.value.substring(0,i)+n+e.value.substring(o),e.selectionStart=e.selectionEnd=i+n.length,e.dispatchEvent(new Event("input"))}),e.addEventListener("input",()=>{this._findMatches=[],this._findIndex=-1,this._clearFindHighlight(),t.textContent=""}),e.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),t.shiftKey?this.findPrev():this.findNext(),e.focus({preventScroll:!0})),"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),this.closeFindBar())}),n.addEventListener("mousedown",e=>e.preventDefault()),i.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("click",()=>{this.findPrev(),e.focus({preventScroll:!0})}),i.addEventListener("click",()=>{this.findNext(),e.focus({preventScroll:!0})}),o.addEventListener("click",()=>this.closeFindBar()),this.content.addEventListener("pointerdown",e=>{this._selectAllActive=!1,this._lastPointerType=e.pointerType}),this.content.addEventListener("contextmenu",e=>this.openEditorContextMenu(e)),this.content.addEventListener("paste",e=>{const t=e.clipboardData?.getData("text/html")||"";if(t){const e=document.createElement("template");e.innerHTML=t;const n=e.content.querySelector("img");n&&(this._imageClipboardHtml=n.outerHTML)}else{const t=Array.from(e.clipboardData?.items||[]).find(e=>e.type.startsWith("image/")),n=t?.getAsFile();if(n){const e=new FileReader;e.onload=()=>{const t=document.createElement("img");t.src=e.result,this._imageClipboardHtml=t.outerHTML},e.readAsDataURL(n)}}const n=e.clipboardData?.getData("text/plain")||"";n&&(e.preventDefault(),this.selectedResizeImage&&(this.selectResizeImageRange(),this.hideImageResizeHandles()),this.ActionOptions.paste(n))}),document.addEventListener("click",()=>this.hideContextMenu())};trapDialogFocus=e=>{if("Tab"!==e.key||e.ctrlKey||e.altKey||e.metaKey)return!1;const t=this.shadowRoot.querySelector("dialog[open]");if(!t)return!1;const n=Array.from(t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(e=>!e.disabled&&null!==e.offsetParent);if(0===n.length)return e.preventDefault(),t.focus(),!0;const i=n[0],o=n[n.length-1],r=this.shadowRoot.activeElement;return t.contains(r)?e.shiftKey&&r===i?(e.preventDefault(),o.focus(),!0):!e.shiftKey&&r===o&&(e.preventDefault(),i.focus(),!0):(e.preventDefault(),i.focus(),!0)};isSelectionInsideEditor=e=>{if(!e||0===e.rangeCount)return!1;const t=e.getRangeAt(0),containsNode=e=>!!e&&(e===this.content||this.content.contains(e));return containsNode(t.startContainer)&&containsNode(t.endContainer)&&(!e.anchorNode||containsNode(e.anchorNode))&&(!e.focusNode||containsNode(e.focusNode))};getSelectedResizeImageIndex=()=>this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)?Array.from(this.content.querySelectorAll("img")).indexOf(this.selectedResizeImage):-1;restoreImageResizeHandles=e=>{if(e<0)return;const t=this.content.querySelectorAll("img")[e];t?(this.selectedResizeImage=t,requestAnimationFrame(()=>this.showImageResizeHandles(t))):this.hideImageResizeHandles()};getSelectedResizeTableIndex=()=>this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)?Array.from(this.content.querySelectorAll("table")).indexOf(this.selectedResizeTable):-1;restoreTableResizeHandles=e=>{if(e<0)return;const t=this.content.querySelectorAll("table")[e];t?(this.selectedResizeTable=t,requestAnimationFrame(()=>this.showTableResizeHandles(t))):this.hideTableResizeHandles()};goBack=()=>{const e=this.getSelectedResizeImageIndex(),t=this.getSelectedResizeTableIndex();this.StateManager.goBack(),this.NodeManager.refreshUI(),this.updateWordCount(),this.restoreImageResizeHandles(e),this.restoreTableResizeHandles(t)};goForward=()=>{const e=this.getSelectedResizeImageIndex(),t=this.getSelectedResizeTableIndex();this.StateManager.goForward(),this.NodeManager.refreshUI(),this.updateWordCount(),this.restoreImageResizeHandles(e),this.restoreTableResizeHandles(t)};clearSettings=e=>{this.fontSize=void 0,this.NodeManager.selectButtons(e)};keyEvents=e=>{if(this.setDefaultParagraphSeparator(),this.NodeManager.createDefaultElement(),!1===this.EditMode)return e.ctrlKey&&"z"===e.key&&e.preventDefault(),void(e.ctrlKey&&"y"===e.key&&e.preventDefault());if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){e.preventDefault();const t=this.selectedResizeImage;return this.hideImageResizeHandles(),t.remove(),void this.updateWordCount()}if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)&&!this.isSelectionInsideSelectedTableCell()){e.preventDefault();const t=this.selectedResizeTable;return this.hideTableResizeHandles(),t.remove(),void this.updateWordCount()}const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&!this.isSelectionInsideEditor(t))e.preventDefault();else if(this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),"Enter"!==e.key||e.ctrlKey||e.altKey||e.metaKey||!this.insertParagraphAtTableBoundary()&&!this.insertParagraphAfterStructuredBlock()){if(e.ctrlKey&&"b"===e.key&&(e.preventDefault(),this.bold()),e.ctrlKey&&"i"===e.key&&(e.preventDefault(),this.italic()),e.ctrlKey&&"u"===e.key&&(e.preventDefault(),this.underline()),e.ctrlKey&&"d"===e.key&&(e.preventDefault(),this.strikethrough()),e.ctrlKey&&"c"===e.key&&(e.preventDefault(),this.copy()),e.ctrlKey&&"x"===e.key&&(e.preventDefault(),this.cut()),"Delete"===e.key||46===e.keyCode){const t=this.Utilities.getSelection();if(null!==t)if(t.toString().length>0)e.preventDefault(),this.delete();else if(t.isCollapsed){const n=t.getRangeAt(0),i=["P","DIV","H1","H2","H3","H4","H5","H6","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let o=t.anchorNode;for(;o&&o!==this.content&&(o.nodeType!==Node.ELEMENT_NODE||!i.includes(o.nodeName));)o=o.parentNode;if(o&&o!==this.content){if(""===o.textContent.trim()&&!o.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){e.preventDefault();let n=null,i=o.nextSibling;for(;i;){if(i.nodeType===Node.ELEMENT_NODE){n=i;break}if(i.nodeType===Node.TEXT_NODE&&""!==i.textContent.trim()){n=i;break}i=i.nextSibling}if(o.parentNode.removeChild(o),n){const e=document.createRange();e.selectNodeContents(n),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(n.startContainer,n.startOffset),t.setEnd(o,o.childNodes.length);const i=t.cloneContents();if(0===t.toString().length&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=o.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.nextSibling;let n=o.nodeName;if(!t){let e=o,i=o.parentNode;for(;i&&i!==this.content;){let o=null;for(let e=i.childNodes.length-1;e>=0;e--){const t=i.childNodes[e];if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&""!==t.textContent.trim()){o=t;break}}if(o!==e)break;let r=i.nextSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.nextSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,n=i.nodeName;break}e=i,i=i.parentNode}}const i=["P","A"];if(!t||t.nodeType!==Node.ELEMENT_NODE||t.nodeName===n||i.includes(n)&&i.includes(t.nodeName)){if(t&&t.nodeType===Node.ELEMENT_NODE){const e=o.style.fontFamily,n=t.style.fontFamily;e&&!n?t.style.fontFamily=e:!e&&n&&(o.style.fontFamily=n)}}else e.preventDefault()}}}}}if(e.ctrlKey&&"="===e.key&&(e.preventDefault(),this.subscript()),e.ctrlKey&&e.shiftKey&&"+"===e.key&&(e.preventDefault(),this.superscript()),e.ctrlKey&&e.shiftKey&&"E"===e.key&&(e.preventDefault(),this.inlinecode()),e.ctrlKey&&"l"===e.key&&(e.preventDefault(),this.alignleft()),e.ctrlKey&&"e"===e.key&&(e.preventDefault(),this.aligncenter()),e.ctrlKey&&"r"===e.key&&(e.preventDefault(),this.alignright()),e.ctrlKey&&"j"===e.key&&(e.preventDefault(),this.alignjustify()),e.ctrlKey&&"a"===e.key&&(e.preventDefault(),this.selectall()),e.ctrlKey&&"z"===e.key&&(e.preventDefault(),this.goBack()),e.ctrlKey&&"y"===e.key&&(e.preventDefault(),this.goForward()),e.ctrlKey&&e.shiftKey&&"A"===e.key&&(e.preventDefault(),this.toggleView()),e.ctrlKey&&!e.shiftKey&&"s"===e.key.toLowerCase()&&(e.preventDefault(),this.saveHtml()),e.ctrlKey&&!e.shiftKey&&"o"===e.key.toLowerCase()&&(e.preventDefault(),this.openHtmlFile()),e.ctrlKey&&e.shiftKey&&"&"===e.key&&(e.preventDefault(),this.uploadImageDialog()),e.ctrlKey&&e.shiftKey&&"U"===e.key&&(e.preventDefault(),this.unorderedlist()),e.ctrlKey&&e.shiftKey&&"O"===e.key&&(e.preventDefault(),this.orderedlist()),e.ctrlKey&&e.shiftKey&&">"===e.key&&(e.preventDefault(),this.changeFontSize(!0)),e.ctrlKey&&e.shiftKey&&"<"===e.key&&(e.preventDefault(),this.changeFontSize(!1)),e.ctrlKey&&e.shiftKey&&"C"===e.key&&(e.preventDefault(),this.openTextColorDialog()),e.ctrlKey&&e.shiftKey&&"B"===e.key&&(e.preventDefault(),this.openTextBackgroundColorDialog()),e.ctrlKey&&e.shiftKey&&"K"===e.key&&(e.preventDefault(),this.openLinkDialog()),e.ctrlKey&&e.shiftKey&&"*"===e.key&&(e.preventDefault(),this.openCodeBlockDialog()),e.ctrlKey&&e.shiftKey&&"Q"===e.key&&(e.preventDefault(),this.openBlockQuoteDialog()),e.ctrlKey&&e.shiftKey&&"I"===e.key&&(e.preventDefault(),this.openImageDialog()),e.ctrlKey&&e.shiftKey&&"M"===e.key&&(e.preventDefault(),this.openMediaDialog()),e.ctrlKey&&e.shiftKey&&"L"===e.key&&(e.preventDefault(),this.openTableDialog()),e.ctrlKey&&e.shiftKey&&"D"===e.key&&(e.preventDefault(),this.format("none")),e.ctrlKey&&e.shiftKey&&"P"===e.key&&(e.preventDefault(),this.openPreview()),e.ctrlKey&&e.shiftKey&&"!"===e.key&&(e.preventDefault(),this.format("h1")),e.ctrlKey&&e.shiftKey&&"@"===e.key&&(e.preventDefault(),this.format("h2")),e.ctrlKey&&e.shiftKey&&"#"===e.key&&(e.preventDefault(),this.format("h3")),e.ctrlKey&&e.shiftKey&&"$"===e.key&&(e.preventDefault(),this.format("h4")),e.ctrlKey&&e.shiftKey&&"%"===e.key&&(e.preventDefault(),this.format("h5")),e.ctrlKey&&e.shiftKey&&"^"===e.key&&(e.preventDefault(),this.format("h6")),e.ctrlKey&&e.shiftKey&&"V"===e.key&&(e.preventDefault(),this.openVideoDialog()),e.ctrlKey&&e.shiftKey&&"H"===e.key&&(e.preventDefault(),this.insertHorizontalRule()),e.ctrlKey&&!e.shiftKey&&"\\"===e.key&&(e.preventDefault(),this.toggleStatusBar()),e.ctrlKey&&!e.shiftKey&&"f"===e.key&&(e.preventDefault(),this.openFindBar()),e.ctrlKey&&!e.shiftKey&&"/"===e.key&&(e.preventDefault(),this.openHelpDialog()),e.altKey&&!e.ctrlKey&&"l"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-file-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"f"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-font-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"s"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-size-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"t"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-format-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"i"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-insert-button-dropdown",!0)),this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),"Backspace"===e.key){const t=this.Utilities.getSelection();if(t&&t.isCollapsed){const n=t.getRangeAt(0),i=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let o=t.anchorNode;for(;o&&o!==this.content&&(o.nodeType!==Node.ELEMENT_NODE||!i.includes(o.nodeName));)o=o.parentNode;if(o&&o!==this.content){if((parseFloat(window.getComputedStyle(o).marginLeft)||0)>0){const t=document.createRange();t.setStart(o,0),t.setEnd(n.startContainer,n.startOffset),0===t.toString().length&&(e.preventDefault(),this.decreaseIndent())}else{if(""===o.textContent.trim()&&!o.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){e.preventDefault();let n=null,i=o.previousSibling;for(;i;){if(i.nodeType===Node.ELEMENT_NODE){n=i;break}if(i.nodeType===Node.TEXT_NODE&&""!==i.textContent.trim()){n=i;break}i=i.previousSibling}if(o.parentNode.removeChild(o),n){const e=document.createRange();e.selectNodeContents(n),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(o,0),t.setEnd(n.startContainer,n.startOffset);const i=t.cloneContents();if(0===t.toString().length&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=o.previousSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;let n=o.nodeName;if(!t){let e=o,i=o.parentNode;for(;i&&i!==this.content;){let o=null;for(const e of i.childNodes)if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&""!==e.textContent.trim()){o=e;break}if(o!==e)break;let r=i.previousSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,n=i.nodeName;break}e=i,i=i.parentNode}}const i=["P","A"];if(t&&t.nodeType===Node.ELEMENT_NODE){if(i.includes(n)?!i.includes(t.nodeName):t.nodeName!==n)e.preventDefault();else{const e=t.style.fontFamily,n=o.style.fontFamily;e&&!n?o.style.fontFamily=e:!e&&n&&(t.style.fontFamily=n)}}}}}}}}if(!("ArrowLeft"!==e.key||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)){const t=this.Utilities.getSelection();if(t&&t.isCollapsed){const n=t.getRangeAt(0),i=["H1","H2","H3","H4","H5","H6"];let o=t.anchorNode;for(;o&&o!==this.content&&(o.nodeType!==Node.ELEMENT_NODE||!i.includes(o.nodeName));)o=o.parentNode;if(o&&o!==this.content&&i.includes(o.nodeName)){const i=document.createRange();i.setStart(o,0),i.setEnd(n.startContainer,n.startOffset);const r=i.cloneContents();if(0===i.toString().length&&!r.querySelector("*")){let n=o.previousSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&""===n.textContent.trim();)n=n.previousSibling;if(n&&"TABLE"===n.nodeName){e.preventDefault();const i=document.createRange();i.setStartAfter(n),i.collapse(!0),t.removeAllRanges(),t.addRange(i)}}}}}if(e.shiftKey&&"Tab"===e.key)e.preventDefault(),this.decreaseIndent();else if("Tab"===e.key){const t=this.Utilities.getSelection();if(null!==t&&null!=t.anchorNode){e.preventDefault();const n=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement,i=n?.closest("blockquote"),o=n?.closest("pre"),r=n?.closest("td, th");if(i&&this.content.contains(i)||o&&this.content.contains(o)){let e=o&&this.content.contains(o)?o:i;for(;e.parentNode&&e.parentNode!==this.content;)e=e.parentNode;let n=e.nextSibling;for(;n&&n.nodeType!==Node.ELEMENT_NODE;)n=n.nextSibling;if(n){this.content.focus();const e=document.createRange();e.selectNodeContents(n),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else r&&this.content.contains(r)?this.TableDialog.tableTab():this.increaseIndent()}}}else e.preventDefault()};isBreakable=e=>{let t=!1;switch(e){case"BLOCKQUOTE":case"CODE":case"P":case"SPAN":t=!0}return t};getStructuredBlockFromNode=e=>{if(!e||e===this.content)return null;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;if(!t||!this.content.contains(t))return null;const n=t.closest("pre");if(n&&this.content.contains(n))return n;const i=t.closest("blockquote");return i&&this.content.contains(i)?i:null};insertParagraphAfterStructuredBlock=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return!1;const t=this.getStructuredBlockFromNode(e.anchorNode);if(!t)return!1;const n=document.createElement("p");n.appendChild(document.createElement("br")),t.nextSibling?t.parentNode.insertBefore(n,t.nextSibling):t.parentNode.appendChild(n);const i=document.createRange();return i.setStart(n,0),i.collapse(!0),e.removeAllRanges(),e.addRange(i),this.content.focus(),!0};insertParagraphAtTableBoundary=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;const t=e.getRangeAt(0);if(t.startContainer!==this.content)return!1;const n=t.startOffset,i=this.content.childNodes[n],o=n>0?this.content.childNodes[n-1]:null;if("TABLE"!==i?.nodeName&&"TABLE"!==o?.nodeName)return!1;const r=document.createElement("p");r.appendChild(document.createElement("br")),this.content.insertBefore(r,i??null);const s=document.createRange();return s.setStart(r,0),s.collapse(!0),e.removeAllRanges(),e.addRange(s),this.content.focus(),!0};changeFontSize=e=>{if(void 0===this.fontSize){const e=this.Utilities.getSelection();if(null!==e&&e&&e.rangeCount>0){const t=e.getRangeAt(0),n=window.getComputedStyle(t.commonAncestorContainer.parentElement);this.fontSize=parseFloat(n.fontSize)}}e?this.fontSize+=1:this.fontSize-=1,this.NodeManager.updateNode("size",`${this.fontSize}px`)};openPreview=()=>{this.preview=this.shadowRoot.getElementById(`${this.id}_Preview`);const e=this.shadowRoot.getElementById("rich-text-box-preview");this.preview&&e&&(this.loadPreviewWindow(e),this.addPreviewEventListeners(this.preview),e.dataset.scrollListenerAdded||(e.dataset.scrollListenerAdded="1",e.addEventListener("keydown",t=>{if(!["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"].includes(t.key))return;t.preventDefault();const n=e.shadowRoot?.querySelector("iframe");if(!n?.contentWindow)return;const i=n.contentWindow,o=.9*i.innerHeight,r=i.document.documentElement.scrollHeight,s="ArrowUp"===t.key?-50:"ArrowDown"===t.key?50:"PageUp"===t.key?-o:"PageDown"===t.key?o:"Home"===t.key?-r:r;i.scrollBy({top:s,behavior:"instant"})})),this.preview.showModal(),e.scrollTop=0,e.scrollLeft=0,requestAnimationFrame(()=>e.focus({preventScroll:!0})))};addPreviewEventListeners=e=>{e.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.closePreview()),"Escape"===e.key&&(e.preventDefault(),this.closePreview())})};loadPreviewWindow=e=>{const t="block"===this.content.style.display?this.html()||"":this.source.value||"",n=e.shadowRoot||e.attachShadow({mode:"open"});for(;n.firstChild;)n.removeChild(n.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;}",n.appendChild(i);const o=(this._previewCssUrls||[]).filter(e=>e).map(e=>`<link rel="stylesheet" href="${e.replace(/"/g,"%22")}">`).join(""),r=this._previewCssText?`<style>${this._previewCssText}</style>`:"",s=this._rtbHostElement,l=s?getComputedStyle(s):null,getVar=(e,t)=>(l?l.getPropertyValue(e).trim():"")||t,a=s&&(s.classList.contains("dark")||s.classList.contains("fluent-dark")),d=["<style>",`html{margin:0;background-color:${getVar("--rtb-content-bg","#FFF")};color-scheme:${a?"dark":"light"};}`,"body{margin:0;}","body{",` max-width:${getVar("--rtb-page-width","860px")};margin-left:auto;margin-right:auto;`," 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")};`," overscroll-behavior:contain;","}",`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">',d,o,r,"</head><body>",t,'<script>document.addEventListener("click",function(e){var a=e.target.closest("a");if(a&&a.href){e.preventDefault();window.open(a.href,"_blank","noopener,noreferrer");}});<\/script>',"</body></html>"].join(""),n.appendChild(c),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus(),this.content.focus()};togglePreviewMaximize=()=>{const e=this.shadowRoot.getElementById(`${this.id}_Preview`),t=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!e||!t)return;const n=!e.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"]];n?(e.setAttribute("data-maximized",""),i.forEach(([t,n])=>e.style.setProperty(t,n))):(e.removeAttribute("data-maximized"),i.forEach(([t])=>e.style.removeProperty(t))),t.setAttribute("aria-label",n?"Restore preview":"Maximize preview"),t.querySelector("svg").innerHTML=n?'<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 e=this.shadowRoot.getElementById(`${this.id}_Preview`),t=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);e&&t&&(e.removeAttribute("data-maximized"),["width","height","max-width","max-height","top","left","transform","border-radius","resize"].forEach(t=>e.style.removeProperty(t)),t.setAttribute("aria-label","Maximize preview"),t.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"/>')};toggleEditorFullscreen=()=>{const e=this.shadowRoot.getElementById("blazing-rich-text-fullscreen-button");if(!e)return;const t=!this.container.classList.contains("rtb-editor-fullscreen");this.container.classList.toggle("rtb-editor-fullscreen",t);const n=this._rtbHostElement;if(t){if(this._editorFullscreenBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",n){n.classList.add("rtb-host-fullscreen"),this._editorFullscreenPopoverValue=n.getAttribute("popover"),n.setAttribute("popover","manual");try{n.showPopover(),this._editorFullscreenUsingPopover=!0}catch{this._editorFullscreenUsingPopover=!1}}}else document.body.style.overflow=this._editorFullscreenBodyOverflow||"",n&&(this._editorFullscreenUsingPopover&&n.matches(":popover-open")&&n.hidePopover(),n.classList.remove("rtb-host-fullscreen"),null===this._editorFullscreenPopoverValue?n.removeAttribute("popover"):n.setAttribute("popover",this._editorFullscreenPopoverValue),this._editorFullscreenUsingPopover=!1);e.setAttribute("aria-label",t?"Restore editor":"Maximize editor"),e.setAttribute("title",t?"Restore Editor":"Maximize Editor"),e.setAttribute("aria-pressed",t?"true":"false"),e.querySelector("svg").innerHTML=t?'<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"/>',requestAnimationFrame(()=>{this._scheduleOverflowUpdate(),this.positionImageResizeHandles(),this.positionTableResizeHandles()})};insertHorizontalRule=()=>{const e=this.Utilities.getSelection();if(!e||!e.rangeCount)return;const t=e.getRangeAt(0);t.deleteContents();let n=t.startContainer;if(n===this.content){const e=this.content.childNodes[t.startOffset]??null,n=document.createElement("hr");return this.content.insertBefore(n,e),this.cleanupHorizontalRuleInsertion(n),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;n.parentNode&&n.parentNode!==this.content;)if(n=n.parentNode,!this.content.contains(n)){const e=document.createElement("hr");return this.content.appendChild(e),this.cleanupHorizontalRuleInsertion(e),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}const i=document.createElement("hr");n&&n!==this.content&&this.content.contains(n)?this.isEmptyHorizontalRuleBlock(n)?n.replaceWith(i):this.content.insertBefore(i,n.nextSibling):this.content.appendChild(i),this.cleanupHorizontalRuleInsertion(i),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};isEmptyHorizontalRuleBlock=e=>e?.nodeType===Node.ELEMENT_NODE&&["P","DIV"].includes(e.nodeName)&&""===e.textContent.replace(/\u200B/g,"").trim()&&!e.querySelector("img, table, video, audio, iframe, canvas, svg, figure, object, embed, hr");removeEmptyLineAfterHorizontalRule=e=>{const t=e?.nextSibling;t&&("BR"!==t.nodeName?this.isEmptyHorizontalRuleBlock(t)&&t.remove():t.remove())};cleanupHorizontalRuleInsertion=e=>{this.removeEmptyLineAfterHorizontalRule(e),requestAnimationFrame(()=>this.removeEmptyLineAfterHorizontalRule(e))};toggleStatusBar=()=>{if(!this.statusBar)return;const e="none"===this.statusBar.style.display;e?(this.statusBar.style.display="",this.updateWordCount()):this.statusBar.style.display="none";const t=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");t&&(t.textContent=e?"Hide Status Bar":"Show Status Bar");try{localStorage.setItem("rtb-status-bar-visible",e?"1":"0")}catch{}};_applyStoredStatusBarVisibility=()=>{try{const e=localStorage.getItem("rtb-status-bar-visible");if(null===e||!this.statusBar)return;const t="1"===e;this.statusBar.style.display=t?"":"none",t&&this.updateWordCount();const n=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");n&&(n.textContent=t?"Hide Status Bar":"Show Status Bar")}catch{}};openFindBar=()=>{this.findBar.style.display="flex";const e=this.findBar.querySelector(".rtb-find-input");requestAnimationFrame(()=>{e.focus(),e.select()})};closeFindBar=()=>{this.findBar.style.display="none",this._findMatches=[],this._findIndex=-1,this._clearFindHighlight(),this.findBar.querySelector(".rtb-find-count").textContent="",this.EditMode?this.content.focus():this.source.focus()};openHelpDialog=()=>{const e=this.shadowRoot.getElementById("rich-text-box-help-modal");e.showModal(),requestAnimationFrame(()=>e.querySelector(".rtb-help-body")?.focus({preventScroll:!0}))};fileMenuAction=e=>{switch(this.closeDropdown("blazing-rich-text-file-button-dropdown"),e){case"open":this.openHtmlFile();break;case"save":this.saveHtml();break;case"find":this.openFindBar();break;case"toggleStatusBar":this.toggleStatusBar();break;case"shortcuts":this.openHelpDialog()}};closeHelpDialog=()=>{this.shadowRoot.getElementById("rich-text-box-help-modal").close(),this._returnFocus()};openEditorContextMenu=e=>{if(!this.EditMode)return;const t=e.target instanceof Element?e.target:e.target?.parentElement;if(!(t instanceof Element&&this.content.contains(t)))return;if("touch"===this._lastPointerType)return void e.preventDefault();e.preventDefault();const n=t.closest("a"),i=t.closest("img"),o=(t.tagName,t.closest("video")),r=t.closest("pre"),s=t.closest("blockquote"),l=t.closest("object"),a=t.closest("table"),d=t.closest("ul"),c=t.closest("ol"),h=t.closest("hr")||(()=>{for(const t of this.content.querySelectorAll("hr")){const n=t.getBoundingClientRect();if(e.clientX>=n.left&&e.clientX<=n.right&&e.clientY>=n.top-10&&e.clientY<=n.bottom+10)return t}return null})();let b,u;n&&this.content.contains(n)?(b=this._buildLinkContextItems(n),u=n):i&&this.content.contains(i)?(b=this._buildImageContextItems(i),u=i):o&&this.content.contains(o)?(b=this._buildVideoContextItems(o),u=o):r&&this.content.contains(r)?(b=this._buildCodeBlockContextItems(r),u=r):s&&this.content.contains(s)?(b=this._buildBlockQuoteContextItems(s),u=s):l&&this.content.contains(l)?(b=this._buildMediaContextItems(l),u=l):a&&this.content.contains(a)?(b=this._buildTableContextItems(a,t),u=a):h&&this.content.contains(h)?(b=this._buildHrContextItems(h),u=h):d&&this.content.contains(d)?(b=this._buildBulletListContextItems(d,t),u=d):c&&this.content.contains(c)?(b=this._buildNumberListContextItems(c,t),u=c):(b=this._buildTextContextItems(t),u=t),b&&0!==b.length&&(!1!==this._rtbHostElement?._visibility?.htmlView&&b.push({divider:!0},{label:"View HTML",icon:"Code",action:()=>this._viewElementHtml(u)}),e.stopPropagation(),this._showContextMenu(e,b))};_buildTextContextItems=e=>{const t=[],n=this._getInlineFormatAtNode(e,"bold"),i=this._getInlineFormatAtNode(e,"italic"),o=this._getInlineFormatAtNode(e,"underline"),r=this._getInlineFormatAtNode(e,"line-through"),s=this._getInlineFormatAtNode(e,"subscript"),l=this._getInlineFormatAtNode(e,"superscript"),a=this._getInlineFormatAtNode(e,"code");let d=!1,c=e instanceof Element?e:e?.parentElement;for(;c&&c!==this.content&&this.content.contains(c);){if(c.style.color||c.style.backgroundColor){d=!0;break}c=c.parentElement}return n&&t.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),i&&t.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),o&&t.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),r&&t.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),s&&t.push({label:"Remove Subscript",icon:"Delete",action:()=>{this.content.focus(),this.subscript()}}),l&&t.push({label:"Remove Superscript",icon:"Delete",action:()=>{this.content.focus(),this.superscript()}}),a&&t.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),d&&t.push({label:"Remove Color",icon:"RemoveTextFormat",action:()=>this.removeTextColor()}),t.length>0&&t.push({divider:!0}),[["Paragraph","p"],["Heading 1","h1"],["Heading 2","h2"],["Heading 3","h3"],["Heading 4","h4"],["Heading 5","h5"],["Heading 6","h6"]].forEach(([e,n])=>{t.push({label:e,icon:"Format",action:()=>{this.content.focus(),this.format(n)}})}),t};_buildLinkContextItems=e=>[{label:"Open Link",icon:"OpenInNew",action:()=>window.open(e.href,"_blank","noopener,noreferrer")},{label:"Edit Link",icon:"CreateLink",action:()=>this._openLinkDialogFromContext(e)},{label:"Remove Link",icon:"RemoveLink",action:()=>this._selectNodeForDialog(e,!0,()=>this.removeLink())}];_buildImageContextItems=e=>[{label:"Edit Image",icon:"Image",action:()=>{const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),e.src?.startsWith("data")?this.uploadImageDialog():this.openImageDialog()}},{label:"Remove Image",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildVideoContextItems=e=>[{label:"Edit Video",icon:"VideoFile",action:()=>this.openVideoDialogForElement(e)},{label:"Remove Video",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildBlockQuoteContextItems=e=>[{label:"Edit Block Quote",icon:"Quote",action:()=>this.openBlockQuoteDialogForElement(e)},{label:"Remove Block Quote",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildCodeBlockContextItems=e=>[{label:"Edit Code Block",icon:"CodeBlocks",action:()=>this.openCodeBlockDialogForElement(e)},{label:"Remove Code Block",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildMediaContextItems=e=>[{label:"Edit Media",icon:"PermMedia",action:()=>this._selectNodeForDialog(e,!1,()=>this.openMediaDialog())},{label:"Remove Media",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildTableContextItems=(e,t)=>{const n=t?.closest("td, th")||null;return[{label:"Edit Table",icon:"Table",action:()=>{const t=e.querySelector("td, th");if(t){const e=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}this.openTableDialog()}},{divider:!0},{label:"Insert Row Above",icon:"ArrowUp",action:()=>this.TableDialog.insertRowAbove(n,e)},{label:"Insert Row Below",icon:"ArrowDown",action:()=>this.TableDialog.insertRowBelow(n,e)},{label:"Insert Column Left",icon:"ArrowLeft",action:()=>this.TableDialog.insertColumnLeft(n,e)},{label:"Insert Column Right",icon:"ArrowRight",action:()=>this.TableDialog.insertColumnRight(n,e)},{divider:!0},{label:"Remove Row",icon:"Delete",action:()=>this.TableDialog.removeRow(n)},{label:"Remove Column",icon:"Delete",action:()=>this.TableDialog.removeColumn(n,e)},{divider:!0},{label:"Remove Table",icon:"Delete",action:()=>this._removeContentElement(e)}]};_buildHrContextItems=e=>[{label:"Remove Horizontal Rule",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildBulletListContextItems=(e,t)=>{const n=[],i=this._getInlineFormatAtNode(t,"bold"),o=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return i&&n.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),o&&n.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),r&&n.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),s&&n.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),l&&n.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),n.length>0&&n.push({divider:!0}),n.push({label:"Remove Bullet List",icon:"Delete",action:()=>{this.content.focus();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=e.querySelector("li");i?n.setStart(i,0):n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.unorderedlist()}}),n};_buildNumberListContextItems=(e,t)=>{const n=[],i=this._getInlineFormatAtNode(t,"bold"),o=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return i&&n.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),o&&n.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),r&&n.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),s&&n.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),l&&n.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),n.length>0&&n.push({divider:!0}),n.push({label:"Remove Number List",icon:"Delete",action:()=>{this.content.focus();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=e.querySelector("li");i?n.setStart(i,0):n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.orderedlist()}}),n};_selectNodeForDialog=(e,t,n)=>{if(!e||!this.content.contains(e))return;const i=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();t?o.selectNodeContents(e):o.selectNode(e),i.removeAllRanges(),i.addRange(o),n()};_openLinkDialogFromContext=e=>{if(!e||!this.content.contains(e))return;const t=this.Utilities.getSelection()||window.getSelection(),n=this.Utilities.saveSelection(t),i=document.createRange();i.selectNodeContents(e),t.removeAllRanges(),t.addRange(i),this.openLinkDialog(),this.savedSelection=n,this.LinkDialog.savedSelection=n};_removeContentElement=e=>{e&&this.content.contains(e)&&(e.remove(),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0})))};_viewElementHtml=async e=>{if(!e||!this.content.contains(e))return;if(await this.getHtml(),e===this.content)return this.source.focus({preventScroll:!0}),this.source.select(),void(this.source.scrollTop=0);if(!this.content.contains(e))return;const t=[];for(let n=e;n&&n!==this.content;n=n.parentNode)t.push(Array.prototype.indexOf.call(n.parentNode.childNodes,n));const n=this.content.cloneNode(!0);let i=n;for(const e of t.reverse())i=i.childNodes[e];if(!(i instanceof Element))return;const o="data-rtb-source-target",r=` ${o}=""`;i.setAttribute(o,"");const normalizeHtml=e=>e.replace(/font-family:\s*&quot;([^"]+?)&quot;;/g,"font-family: '$1';"),s=normalizeHtml(n.innerHTML),l=s.indexOf(r),a=s.lastIndexOf("<",l),d=normalizeHtml(i.outerHTML).replace(r,"");if(l<0||a<0)return;this.source.focus({preventScroll:!0}),this.source.setSelectionRange(a,a+d.length);const c=this.source.value;this.source.value=c.substring(0,a);const h=this.source.scrollHeight;this.source.value=c,this.source.setSelectionRange(a,a+d.length),this.source.scrollTop=h<=this.source.clientHeight?0:Math.max(0,h-this.source.clientHeight/2)};_showContextMenu=(e,t)=>{if(!this.contextMenu)return;this.contextMenu.replaceChildren(...t.map(e=>{if(e.divider){const e=document.createElement("div");return e.className="rtb-context-menu-divider",e}return this._createContextMenuItem(e)})),this.contextMenu.style.display="block",this.contextMenu.setAttribute("aria-hidden","false"),this.contextMenu.style.left="0px",this.contextMenu.style.top="0px";const n=this.contextMenu.getBoundingClientRect(),i=window.visualViewport,o=i?.width||window.innerWidth||document.documentElement.clientWidth,r=i?.height||window.innerHeight||document.documentElement.clientHeight,s=i?.offsetLeft||0,l=i?.offsetTop||0,a=Math.min(Math.max(s+4,e.clientX),s+o-n.width-4),d=Math.min(Math.max(l+4,e.clientY),l+r-n.height-4);this.contextMenu.style.left=a-n.left+"px",this.contextMenu.style.top=d-n.top+"px"};_createContextMenuItem=e=>{const t=document.createElement("button");return t.type="button",t.setAttribute("role","menuitem"),t.innerHTML=`${this._contextMenuIcon(e.icon)}<span>${e.label}</span>`,t.addEventListener("click",t=>{t.stopPropagation(),this.hideContextMenu(),e.action()}),t};_contextMenuIcon=e=>{const t=p[e]||{Format:"M280-160v-80h400v80H280Zm0-160v-80h400v80H280Zm-80-160v-320h560v320H200Zm80-80h400v-160H280v160Z",OpenInNew:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"}[e]||"";return t?`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true" focusable="false"><path d="${t}"/></svg>`:""};hideContextMenu=()=>{this.contextMenu&&(this.contextMenu.style.display="none",this.contextMenu.setAttribute("aria-hidden","true"))};_getInlineFormatAtNode=(e,t)=>{let n=e instanceof Element?e:e?.parentElement;for(;n&&n!==this.content&&this.content.contains(n);){switch(t){case"bold":if("bold"===n.style.fontWeight)return n;break;case"italic":if("italic"===n.style.fontStyle)return n;break;case"underline":if(n.style.textDecoration?.includes("underline"))return n;break;case"line-through":if(n.style.textDecoration?.includes("line-through"))return n;break;case"subscript":if("sub"===n.style.verticalAlign)return n;break;case"superscript":if("super"===n.style.verticalAlign)return n;break;case"code":if("CODE"===n.nodeName&&"PRE"!==n.parentElement?.nodeName)return n}n=n.parentElement}return null};findNext=()=>{const e=this.findBar.querySelector(".rtb-find-input").value;if(!e)return;const t=this._findIndex;this._runSearch(e),this._findMatches.length&&(this._findIndex=(t+1)%this._findMatches.length,this._applyFindMatch())};findPrev=()=>{const e=this.findBar.querySelector(".rtb-find-input").value;if(!e)return;const t=this._findIndex;this._runSearch(e),this._findMatches.length&&(this._findIndex=(t<=0?this._findMatches.length:t)-1,this._applyFindMatch())};_runSearch=e=>{this._findMatches=[],this._findIndex=-1,this._clearFindHighlight();const t=this.findBar.querySelector(".rtb-find-count");if(!e)return void(t.textContent="");const n=e.toLowerCase();if(this.EditMode){const t=document.createTreeWalker(this.content,NodeFilter.SHOW_TEXT);let i;for(;i=t.nextNode();){const t=i.textContent.toLowerCase();let o=0;for(;-1!==(o=t.indexOf(n,o));)this._findMatches.push({node:i,start:o,end:o+e.length}),o++}}else{const t=this.source.value.toLowerCase();let i=0;for(;-1!==(i=t.indexOf(n,i));)this._findMatches.push({start:i,end:i+e.length}),i++}this._findMatches.length||(t.textContent="No results")};_applyFindMatch=()=>{const e=this._findMatches[this._findIndex];if(this.findBar.querySelector(".rtb-find-count").textContent=`${this._findIndex+1} / ${this._findMatches.length}`,this.EditMode){const t=document.createRange();t.setStart(e.node,e.start),t.setEnd(e.node,e.end);const n=this.Utilities.getSelection()||window.getSelection();n.removeAllRanges(),n.addRange(t),this._setFindHighlight(t);const i=t.getBoundingClientRect(),o=this.contentContainer.getBoundingClientRect(),r=this.contentContainer.scrollTop+i.top-o.top-(this.contentContainer.clientHeight-i.height)/2,s=Math.max(0,this.contentContainer.scrollHeight-this.contentContainer.clientHeight);this.contentContainer.scrollTop=Math.min(s,Math.max(0,r))}else{const t=this.source.value;this.source.value=t.substring(0,e.start);const n=this.source.scrollHeight;this.source.value=t,this.source.focus({preventScroll:!0}),this.source.setSelectionRange(e.start,e.end),this.source.scrollTop=n<=this.source.clientHeight?0:Math.max(0,n-this.source.clientHeight/2),this._setSourceFindHighlight(e)}};_setFindHighlight=e=>{"undefined"!=typeof CSS&&CSS.highlights&&"undefined"!=typeof Highlight&&CSS.highlights.set(this._findHighlightName,new Highlight(e.cloneRange()))};_clearFindHighlight=()=>{"undefined"!=typeof CSS&&CSS.highlights&&CSS.highlights.delete(this._findHighlightName),this._sourceFindHighlight&&(this._sourceFindHighlight.style.display="none",this._sourceFindHighlight.replaceChildren())};_setSourceFindHighlight=e=>{if(!this._sourceFindHighlight||!e)return;const t=this.source.value,n=getComputedStyle(this.source),i=document.createTextNode(t.substring(0,e.start)),o=document.createElement("span");o.textContent=t.substring(e.start,e.end),o.style.background="rgba(255, 214, 0, 0.45)",o.style.color="transparent";const r=document.createTextNode(t.substring(e.end));this._sourceFindHighlight.replaceChildren(i,o,r),this._sourceFindHighlight.style.display="none"===this.source.style.display?"none":"block",this._sourceFindHighlight.style.left=`${this.source.offsetLeft}px`,this._sourceFindHighlight.style.top=`${this.source.offsetTop}px`,this._sourceFindHighlight.style.width=`${this.source.clientWidth}px`,this._sourceFindHighlight.style.height=`${this.source.clientHeight}px`,this._sourceFindHighlight.style.minHeight="0",this._sourceFindHighlight.style.overflow="hidden",this._sourceFindHighlight.style.boxSizing=n.boxSizing,this._sourceFindHighlight.style.padding=n.padding,this._sourceFindHighlight.style.border=`${n.borderTopWidth} solid transparent`,this._sourceFindHighlight.style.font=n.font,this._sourceFindHighlight.style.letterSpacing=n.letterSpacing,this._sourceFindHighlight.style.lineHeight=n.lineHeight,this._sourceFindHighlight.style.whiteSpace=n.whiteSpace,this._sourceFindHighlight.style.overflowWrap=n.overflowWrap,this._sourceFindHighlight.style.tabSize=n.tabSize,this._sourceFindHighlight.style.textAlign=n.textAlign,this._sourceFindHighlight.style.textIndent=n.textIndent,this._sourceFindHighlight.style.textTransform=n.textTransform,this._sourceFindHighlight.style.wordBreak=n.wordBreak,this._sourceFindHighlight.scrollTop=this.source.scrollTop,this._sourceFindHighlight.scrollLeft=this.source.scrollLeft};_setStatusLink=(e="")=>{if(this.statusLink){if(clearTimeout(this._statusLinkFadeTimer),e)return this.statusLink.textContent=e,this.statusLink.title=e,void this.statusLink.classList.add("rtb-status-link-visible");this.statusLink.classList.remove("rtb-status-link-visible"),this._statusLinkFadeTimer=setTimeout(()=>{this.statusLink.classList.contains("rtb-status-link-visible")||(this.statusLink.textContent="",this.statusLink.title="")},100)}};_updateStatusLinkFromNode=e=>{const t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement,n=t?.closest?.("a");this._setStatusLink(n&&this.content.contains(n)?n.href:"")};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const e=this.content.innerText||"",t=e.trim(),n=t?t.split(/\s+/).length:0,i=e.replace(/\n/g,"").length,fmt=e=>e.toLocaleString();this.statusCount.textContent=`${fmt(n)} word${1!==n?"s":""} · ${fmt(i)} character${1!==i?"s":""}`};_syncWordCountVisibility=()=>{const e=!1!==this._rtbHostElement?._visibility?.wordCount;this.statusBar&&(this.statusBar.style.display=e?"":"none");const t=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");t&&(t.textContent=e?"Hide Status Bar":"Show Status Bar")};setReadOnly=e=>{this.content.contentEditable=e?"false":"true",this.content.setAttribute("aria-readonly",e?"true":"false");const t=this.shadowRoot.querySelector(`#${CSS.escape(this.toolbar_id)}`);t&&(t.style.display=e?"none":"")};saveHtml=()=>{const e="block"===this.content.style.display?this.html()||"":this.source.value||"",t=new Blob([e],{type:"text/html"}),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=this.createTimestampedHtmlFileName(),i.click(),URL.revokeObjectURL(n)};openHtmlFile=()=>{this.openFileInput.click()};openDroppedOrSelectedHtmlFile=e=>{if(!e)return;if(!("text/html"===e.type||/\.(html|htm)$/i.test(e.name)))return void this.Utilities.showFadingBar("Please choose an HTML file.");const t=new FileReader;t.onload=()=>{const e=t.result||"";"block"===this.source.style.display?(this.loadInnerText(e),this.source.style.display="block",this.content.style.display="none",this.source.focus()):(this.loadHtml(e),this.content.style.display="block",this.source.style.display="none",this.content.focus(),this.StateManager.saveState())},t.readAsText(e)};dragEventHasHtmlFile=e=>{const t=Array.from(e.dataTransfer?.items||[]);if(t.length>0)return t.some(e=>"file"===e.kind&&("text/html"===e.type||""===e.type));return Array.from(e.dataTransfer?.files||[]).some(e=>"text/html"===e.type||/\.(html|htm)$/i.test(e.name))};createTimestampedHtmlFileName=()=>{const e=new Date,pad=e=>String(e).padStart(2,"0");return`html-${[e.getFullYear(),pad(e.getMonth()+1),pad(e.getDate())].join("-")+"_"+[pad(e.getHours()),pad(e.getMinutes()),pad(e.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=e=>{this.NodeManager.formatNode(e),this.closeDropdown("blazing-rich-text-format-button-dropdown")};dropdown=(e,t=!1)=>{const n=this.shadowRoot.getElementById(e);null!=n&&n.classList.contains("rich-text-box-show")?n.classList.remove("rich-text-box-show"):(this.NodeManager.closeDropdowns(),n.classList.add("rich-text-box-show"),this.sizeToolbarDropdown(n),t&&this.focusFirstToolbarMenuItem(n))};openToolbarDropdown=(e,t=!1)=>{const n=this.shadowRoot.getElementById(e);n&&(this.NodeManager.closeDropdowns(),n.classList.add("rich-text-box-show"),this.sizeToolbarDropdown(n),t&&this.focusFirstToolbarMenuItem(n))};sizeToolbarDropdown=e=>{if(!this.isResponsiveToolbarDropdown(e))return;e.style.maxHeight="";const t=this.contentContainer.getBoundingClientRect().bottom,n=e.getBoundingClientRect().top,i=Math.floor(t-n-12);i>0&&(e.style.maxHeight=`${i}px`)};isResponsiveToolbarDropdown=e=>!!e&&["blazing-rich-text-file-button-dropdown","blazing-rich-text-font-button-dropdown","blazing-rich-text-size-button-dropdown","blazing-rich-text-format-button-dropdown","blazing-rich-text-insert-button-dropdown"].includes(e.id);resizeOpenToolbarDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content.rich-text-box-show").forEach(e=>{this.isResponsiveToolbarDropdown(e)&&this.sizeToolbarDropdown(e)})};increaseIndent=()=>{if(this.indentSelectedResizeTable(!0))return;this.content.focus(),this.selectedResizeImage&&this.selectResizeImageRange();const e=this.Utilities.getSelection();if(!this.isSelectionInsideEditor(e))return;const t=this.ListProvider.getList(e.anchorNode);t?this.ListProvider.increaseIndent(e,t):this.NodeManager.indentBlock(e,!0),this.selectedResizeImage&&(this.trackImageResizeTransition(),this.clearResizeImageRange())};decreaseIndent=()=>{if(this.indentSelectedResizeTable(!1))return;this.content.focus(),this.selectedResizeImage&&this.selectResizeImageRange();const e=this.Utilities.getSelection();if(!this.isSelectionInsideEditor(e))return;const t=this.ListProvider.getList(e.anchorNode);t?this.ListProvider.decreaseIndent(e,t):this.NodeManager.indentBlock(e,!1),this.selectedResizeImage&&(this.trackImageResizeTransition(),this.clearResizeImageRange())};openTextColorDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(e),e){const t=this.ColorPickers["rich-text-box-text-color-modal"];this.selection=t.openColorPicker(e,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextColor=e=>{this.ColorPickers["rich-text-box-text-color-modal"].selectColor(e)};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.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(e),null!==e){const t=this.ColorPickers["rich-text-box-text-bg-color-modal"];this.selection=t.openColorPicker(e,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextBackgroundColor=e=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].selectColor(e)};insertTextBackgroundColor=()=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].insertColor()};openTableDialog=()=>{const e=this.selectedResizeTable;if(e&&this.content.contains(e))return void this.openTableDialogForElement(e);this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.TableDialog.openTableDialog(t):this.Utilities.showFadingBar("No content selected.")};openTableDialogForElement=e=>{if(!e||"TABLE"!==e.nodeName||!this.content.contains(e))return;this.hideTableResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),this.savedSelection=this.Utilities.saveSelection(t),this.TableDialog.openTableDialogForElement(e,n)};insertTable=()=>{this.TableDialog.insertTable()};font=e=>{this.NodeManager.updateNode("font",e),this.closeDropdown("blazing-rich-text-font-button-dropdown")};size=e=>{this.clearSettings(),this.NodeManager.updateNode("size",e),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")};inlinecode=()=>{const e=this.Utilities.getSelection();if(!e)return;let t=e.anchorNode instanceof Element?e.anchorNode:e.anchorNode?.parentElement;for(;t&&t!==this.content&&this.content.contains(t);){if("CODE"===t.nodeName&&"PRE"!==t.parentElement?.nodeName)return t.replaceWith(...t.childNodes),void this.NodeManager.refreshUI();t=t.parentElement}if(e.toString().length>0&&e.rangeCount>0){const t=e.getRangeAt(0),n=document.createElement("code");n.appendChild(t.cloneContents()),t.deleteContents(),t.insertNode(n),t.selectNodeContents(n),e.removeAllRanges(),e.addRange(t),this.NodeManager.refreshUI()}};alignleft=()=>{this.alignSelectedResizeImage("alignleft")||this.alignSelectedResizeTable("alignleft")||this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.alignSelectedResizeImage("aligncenter")||this.alignSelectedResizeTable("aligncenter")||this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.alignSelectedResizeImage("alignright")||this.alignSelectedResizeTable("alignright")||this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.alignSelectedResizeImage("alignjustify")||this.alignSelectedResizeTable("alignjustify")||this.NodeManager.updateNode("alignjustify")};copy=()=>this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)?(this._imageClipboardHtml=this.selectedResizeImage.outerHTML,this._tableClipboardHtml=null,this.selectResizeImageRange(),void document.execCommand("copy")):this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)?(this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this.selectResizeTableRange(),void document.execCommand("copy")):(this.ActionOptions.copy(),void this.NodeManager.refreshUI());cut=()=>{if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){this._imageClipboardHtml=this.selectedResizeImage.outerHTML,this._tableClipboardHtml=null,this.selectResizeImageRange(),document.execCommand("copy");const e=this.selectedResizeImage;return this.hideImageResizeHandles(),void e.remove()}if(this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)){this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this.selectResizeTableRange(),document.execCommand("copy");const e=this.selectedResizeTable;return this.hideTableResizeHandles(),void e.remove()}this.ActionOptions.cut(),this.NodeManager.refreshUI()};paste=()=>{if(this._imageClipboardHtml){const e=document.createElement("template");e.innerHTML=this._imageClipboardHtml.trim();const t=e.content.firstElementChild;if("IMG"===t?.nodeName){if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage))this.selectedResizeImage.replaceWith(t);else{this.content.focus();const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const n=e.getRangeAt(0);n.deleteContents(),n.insertNode(t),n.setStartAfter(t),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}this.showImageResizeHandles(t)}return}if(this._tableClipboardHtml){const e=document.createElement("template");e.innerHTML=this._tableClipboardHtml.trim();const t=e.content.firstElementChild;if("TABLE"===t?.nodeName){if(this.selectedResizeTable&&this.content.contains(this.selectedResizeTable))this.selectedResizeTable.replaceWith(t);else{this.content.focus();const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const n=e.getRangeAt(0);n.deleteContents(),n.insertNode(t),n.setStartAfter(t),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}this.showTableResizeHandles(t)}return}this.NodeManager.allSelected&&this.delete(),this.content.focus(),document.execCommand("paste")};_returnFocus=()=>{!1===this.EditMode?this.source.focus():this.content.focus()};_focusEditor=()=>{this.content.focus();const e=this.shadowRoot.getSelection();if(!e||0===e.rangeCount||!this.content.contains(e.anchorNode)){const t=document.createRange(),n=this.content.lastChild;n?(t.selectNodeContents(n),t.collapse(!1)):(t.setStart(this.content,0),t.collapse(!0)),e&&(e.removeAllRanges(),e.addRange(t))}};closeDropdown=e=>{this.shadowRoot.getElementById(e).classList.remove("rich-text-box-show"),this.lockToolbar=!1,this._returnFocus()};delete=()=>{if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){const e=this.selectedResizeImage;return this.hideImageResizeHandles(),e.remove(),void this.NodeManager.refreshUI()}const e=this.Utilities.getSelection();if(null!==e){if(this._selectAllActive||this.NodeManager.allSelected()){this.content.replaceChildren(),this._selectAllActive=!1;const t=document.createRange();return t.setStart(this.content,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),void this.NodeManager.refreshUI()}e.deleteFromDocument(),this._selectAllActive=!1,this.NodeManager.refreshUI()}};selectall=()=>{const e=document.createRange();e.selectNodeContents(this.content),this.content.focus();const t=this.Utilities.getSelection();null!==t&&(t.removeAllRanges(),t.addRange(e),this._selectAllActive=!0,this.content.focus())};orderedlist=()=>{this.toggleListForSelectedResizeImage("OL")||this.toggleListForSelectedResizeTable("OL")||this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.toggleListForSelectedResizeImage("UL")||this.toggleListForSelectedResizeTable("UL")||this.ListProvider.addlist("UL"),this.NodeManager.refreshUI()};openLinkDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.LinkDialog.openLinkDialog(e):this.Utilities.showFadingBar("No content selected.")};insertLink=()=>{this.LinkDialog.insertLink(),this.NodeManager.refreshUI()};removeLink=()=>{this.LinkDialog.removeLink()};openBlockQuoteDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.BlockQuoteDialog.openBlockQuoteDialog(e):this.Utilities.showFadingBar("No content selected.")};openBlockQuoteDialogForElement=e=>{if(!e||"BLOCKQUOTE"!==e.nodeName||!this.content.contains(e))return;this.lockToolbar=!0;const t=this.Utilities.getSelection()||window.getSelection();this.savedSelection=this.Utilities.saveSelection(t);const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.BlockQuoteDialog.openBlockQuoteDialogForElement(e,n)};insertBlockQuote=()=>{this.BlockQuoteDialog.insertBlockQuote(),this.NodeManager.refreshUI()};openCodeBlockDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.CodeBlockDialog.openCodeBlockDialog(e):this.Utilities.showFadingBar("No content selected.")};openCodeBlockDialogForElement=e=>{if(!e||"PRE"!==e.nodeName||!this.content.contains(e))return;const t=e.querySelector("code")||e;this.lockToolbar=!0;const n=this.Utilities.getSelection()||window.getSelection();this.savedSelection=this.Utilities.saveSelection(n);const i=document.createRange();i.selectNodeContents(t),n.removeAllRanges(),n.addRange(i),this.CodeBlockDialog.openCodeBlockDialogForElement(e,i)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.MediaDialog.openMediaDialog(e):this.Utilities.showFadingBar("No content selected.")};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.VideoDialog.openVideoDialog(e):this.Utilities.showFadingBar("No content selected.")};openVideoDialogForElement=e=>{this.lockToolbar=!0;const t=this.Utilities.getSelection(),n=this.Utilities.saveSelection(t);this.savedSelection=n,this.VideoDialog.openVideoDialogForElement(e,n)};insertVideo=()=>{this.VideoDialog.insertVideo(),this.NodeManager.refreshUI()};uploadImageDialog=()=>{this.hideImageResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.UploadImageDialog.openUploadImageDialog(e):this.Utilities.showFadingBar("No content selected.")};uploadImage=()=>{this.UploadImageDialog.insertUploadedImage()};openImageDialog=()=>{const e=this.selectedResizeImage;if(e&&this.content.contains(e))return void this.openImageDialogForElement(e);this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.ImageDialog.openImageDialog(t):this.Utilities.showFadingBar("No content selected.")};openImageDialogForElement=e=>{if(!e||"IMG"!==e.nodeName||!this.content.contains(e))return;this.hideImageResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),this.savedSelection=this.Utilities.saveSelection(t),this.ImageDialog.openImageDialogForElement(e,n)};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeDialog=e=>{this.lockToolbar=!1,this.Utilities.closeDialog(e,this.savedSelection)};enableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(e=>e.disabled=!1);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(e=>e.disabled=!1)};disableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(e=>e.disabled=!0);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(e=>e.disabled=!0)};toggleView=()=>{!0===this.EditMode?this.getHtml():this.getCode()};getHtml=async()=>{this.hideImageResizeHandles(),this.hideTableResizeHandles(),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 e=this.html();this.loadInnerText(e),this.content.style.display="none",this.source.style.display="block",this.source.focus(),this.Utilities.restoreScroll(this.source,this.sourceScroll),this.disableButtons(),"none"!==this.findBar.style.display&&this._runSearch(this.findBar.querySelector(".rtb-find-input").value)};getCode=async()=>{this.sourceScroll=this.Utilities.saveScroll(this.source);const e=this.source.value;this.loadHtml(e),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()),"none"!==this.findBar.style.display&&this._runSearch(this.findBar.querySelector(".rtb-find-input").value)};html=()=>(this.NodeManager.removeEmptyNodes(),this.content.innerHTML.replace(/font-family:\s*&quot;([^"]+?)&quot;;/g,"font-family: '$1';"));loadView=e=>{!0===this.EditMode?this.loadHtml(e):this.loadInnerText(e)};loadHtml=e=>{this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.EditMode=!0;const t=this.shadowRoot.getElementById("blazing-rich-text-source");t&&(t.classList.remove("selected"),t.setAttribute("aria-pressed","false")),this.content.innerHTML=null!=e?e:"",this.NodeManager.clearButtons(),this.updateWordCount()};loadInnerText=e=>{this.EditMode=!1;const t=this.shadowRoot.getElementById("blazing-rich-text-source");t&&(t.classList.add("selected"),t.setAttribute("aria-pressed","true")),this.source.value=null!=e?e:"",this.NodeManager.clearButtons()};insertEmoji=e=>{if(!0!==this.EditMode||!e)return;this.NodeManager.createDefaultElement();const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0);if(!this.content.contains(n.commonAncestorContainer))return;n.deleteContents();const i=document.createTextNode(e);n.insertNode(i),n.setStartAfter(i),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.content.focus(),this.NodeManager.closeDropdowns(),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};plaintext=()=>this.content.textContent;setDefaultParagraphSeparator=()=>{try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(e){}};toggleOverflowOptions=(e=!1)=>{this.isOverflowOptionsVisible()&&(this._overflowBtn.click(),e&&this._overflowDropdown?.classList.contains("rtb-overflow-open")&&this.focusFirstToolbarMenuItem(this._overflowDropdown))};openOverflowOptions=(e=!1)=>{this.isOverflowOptionsVisible()&&(this.NodeManager.closeDropdowns(),this._overflowDropdown.classList.add("rtb-overflow-open"),this._overflowBtn.setAttribute("aria-expanded","true"),this._overflowToolbar&&(this._overflowDropdown.style.maxWidth=this._overflowToolbar.offsetWidth-10+"px"),e&&this.focusFirstToolbarMenuItem(this._overflowDropdown))}}class t{constructor(e,t,n,i,o){this.content=e,this.source=t,this.Utilities=n,this.dotNetObjectReference=i,this.contentContainer=o,this.history=[],this.currentIndex=-1,this.currentIndex=-1,this.isNavigating=!1,this.mutationObserver()}mutationObserver=()=>{new MutationObserver((e,t)=>{if("block"!==this.content.style.display||this.isNavigating)this.isNavigating=!1,this.updateBinding();else for(let t of e)switch(t.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 e={html:this.content.innerHTML,selection:this.saveSelection(),scroll:this.Utilities.saveScroll(this.contentContainer)};this.PreviousHtml=this.content.innerHTML,-1!==this.currentIndex&&e===this.history[this.currentIndex]||(this.history=this.history.slice(0,this.currentIndex+1),this.history.push(e),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 e=this.Utilities.getSelection();if(e&&e.rangeCount>0){const t=e.getRangeAt(0),n=t.cloneRange();n.selectNodeContents(this.content),n.setEnd(t.startContainer,t.startOffset);const i=n.toString().length;return{start:i,end:i+t.toString().length}}return null};restoreSelection=e=>{if(e)try{const charIndex=(e,t)=>{let n=0;if(e.nodeType===Node.TEXT_NODE)return t<=e.length?[e,t]:[null,t-e.length];for(let i=0;i<e.childNodes.length;i++){const o=e.childNodes[i],[r,s]=charIndex(o,t-n);if(r)return[r,s];n+=o.textContent.length}return[null,t-n]},t=document.createRange();let[n,i]=charIndex(this.content,e.start),[o,r]=charIndex(this.content,e.end);if(n&&o){t.setStart(n,i),t.setEnd(o,r);const e=window.getSelection();e.removeAllRanges(),e.addRange(t)}}catch(e){}};restoreState=e=>{this.content.innerHTML=e.html,this.restoreSelection(e.selection),this.Utilities.restoreScroll(this.contentContainer,e.scroll),this.content.focus()}}class n{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n}_press=(e,t=!0)=>{e&&(e.classList.toggle("selected",t),e.setAttribute("aria-pressed",t?"true":"false"))};formatNode=e=>{let t,n;if(t=this.Utilities.getSelection(),null!==t){if(!this.isSelectionInsideContent(t))return;let i;if(0==t.toString().length)null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&this.content.contains(t.anchorNode.parentNode)&&(i=this.getElementByType(t.anchorNode.parentNode,"Format"));else if(1==this.hasCommonAncestor(t)){i=t.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else i=this.getElementByContent(t.anchorNode,e,t);if(null!=i&&i!=this.content&&null!=i.parentNode&&this.content.contains(i.parentNode)){if("none"==e){let e=this.Utilities.saveCaretPosition();const t=document.createElement("div");for(let e=0;e<i.style.length;e++){const n=i.style[e];t.style[n]=i.style[n]}for(;i.firstChild;)t.appendChild(i.firstChild);i.parentNode.replaceChild(t,i),this.Utilities.restoreCaretPosition(t,e)}else{let t=this.Utilities.saveCaretPosition();const n=document.createElement(e);n.innerHTML=i.innerHTML;const o=window.getComputedStyle(i);for(let e=0;e<o.length;e++){let t=o[e],r=i.style.getPropertyValue(t);""!==r&&(n.style[t]=r)}i.parentNode.replaceChild(n,i),this.Utilities.restoreCaretPosition(n,t)}return}if(t.toString().length>0){let i;switch(e){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&&t.rangeCount>0&&(n=t.getRangeAt(0),this.hasInvalidElementsInSelection(t)||(i.appendChild(n.cloneContents()),n.deleteContents(),n.insertNode(i),n.selectNodeContents(i),t.removeAllRanges(),t.addRange(n)))}}};updateNode=(e,t,n)=>{let i,o;if(i=this.Utilities.getSelection(),i||n){if(i&&n?(i.removeAllRanges(),i.addRange(n)):n&&(i=window.getSelection(),i.removeAllRanges(),i.addRange(n)),!this.isSelectionInsideContent(i))return;let r;if(this.isCommonAncestor=!1,0==i.toString().length){if("alignleft"===e||"aligncenter"===e||"alignright"===e||"alignjustify"===e){const e=i.anchorNode instanceof Element?i.anchorNode:i.anchorNode?.parentElement;let t=e?.closest("table");if(!t&&i.rangeCount>0){const e=i.getRangeAt(0);if(e.collapsed&&e.startContainer===this.content){const n=e.startOffset,i=this.content.childNodes[n],o=n>0?this.content.childNodes[n-1]:null;"TABLE"===i?.nodeName?t=i:"TABLE"===o?.nodeName&&(t=o)}}t&&this.content.contains(t)&&(r=t)}if(null==r&&(r=this.getElementByStyle(i.anchorNode,e)),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 e=i.anchorNode.querySelector("table");null!=e&&(r=e)}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,e,i);if(null!=r){let n;switch(e){case"textcolor":"None"==t?(n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"color",n.style.getPropertyValue("color"))):r.style.setProperty("color",t);break;case"textbgcolor":"None"==t?(n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"background-color",n.style.getPropertyValue("background-color"))):r.style.setProperty("background-color",t);break;case"font":if("None"==t)n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"font-family");else{const e=t.includes(" ")?`'${t}'`:t;r.style.setProperty("font-family",e)}break;case"size":"None"==t?(n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"font-size")):r.style.setProperty("font-size",t);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"!=t&&!this.isExcluded(i)){let n;switch(e){case"textcolor":n=this.createElement(i),n.style.color=t;break;case"textbgcolor":n=this.createElement(i),n.style.backgroundColor=t;break;case"font":n=this.createElement(i),n.style.fontFamily=t;break;case"size":n=this.createElement(i),n.style.fontSize=t;break;case"bold":n=this.createElement(i),n.style.fontWeight="bold";break;case"italic":n=this.createElement(i),n.style.fontStyle="italic";break;case"underline":n=this.createElement(i),this.addTextDecoration(n,"underline");break;case"line-through":n=this.createElement(i),this.addTextDecoration(n,"line-through");break;case"subscript":n=this.createElement(i),n.style.verticalAlign="sub";break;case"superscript":n=this.createElement(i),n.style.verticalAlign="super";break;case"alignleft":n=document.createElement("div"),n.style.textAlign="left";break;case"aligncenter":n=document.createElement("div"),n.style.textAlign="center";break;case"alignright":n=document.createElement("div"),n.style.textAlign="right";break;case"alignjustify":n=document.createElement("div"),n.style.textAlign="justify"}null!=n&&0!=i.rangeCount&&(o=i.getRangeAt(0),n.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(n),o.selectNodeContents(n),i.removeAllRanges(),i.addRange(o),this.selection=null,this.refreshUI())}}};alignTable=(e,t)=>{if("aligncenter"===t){const t=`${(getComputedStyle(this.content).getPropertyValue("--rtb-table-margin").trim()||"1.2em 0").split(/\s+/)[0]||"1.2em"} auto`;return void(e.style.margin===t?this.removeProperty(e,"margin",t):(e.style.removeProperty("margin-left"),e.style.removeProperty("margin-right"),e.style.setProperty("margin",t)))}"alignright"!==t?"alignleft"!==t&&"alignjustify"!==t||("auto"===e.style.marginRight&&"auto"!==e.style.marginLeft?this.removeProperty(e,"margin-right","auto"):(e.style.removeProperty("margin"),e.style.removeProperty("margin-left"),e.style.setProperty("margin-right","auto"))):"auto"===e.style.marginLeft&&"auto"!==e.style.marginRight?this.removeProperty(e,"margin-left","auto"):(e.style.removeProperty("margin"),e.style.removeProperty("margin-right"),e.style.setProperty("margin-left","auto"))};isSelectionInsideContent=e=>{if(!e||0===e.rangeCount)return!1;const t=e.getRangeAt(0),containsNode=e=>!!e&&(e===this.content||this.content.contains(e));return containsNode(t.startContainer)&&containsNode(t.endContainer)&&(!e.anchorNode||containsNode(e.anchorNode))&&(!e.focusNode||containsNode(e.focusNode))};isExcluded=e=>{if(e.anchorNode&&e.anchorNode.querySelector){const t=e.anchorNode.querySelector("table");if(null!=t&&e.toString().trim()!==t.innerText.trim())return!0}if(e.anchorNode.parentNode!==this.content)switch(e.anchorNode.parentNode.nodeName){case"TD":case"CODE":case"PRE":return!0}return!1};indentBlock=(e,t)=>{if(!e||!e.anchorNode||!this.content.contains(e.anchorNode))return;let n=e.anchorNode;for(;n&&n!==this.content&&!this.applyMargin(n,t);)n=n.parentNode};applyMargin=(e,t)=>{if(e.nodeType===Node.ELEMENT_NODE&&["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"].includes(e.nodeName)){const n=window.getComputedStyle(e).marginLeft,i=parseFloat(n)||0,o=40;return t?e.style.marginLeft=`${i+o}px`:i<=o?(e.style.marginLeft="",e.hasAttribute("style")&&(e.getAttribute("style")||e.removeAttribute("style"))):e.style.marginLeft=i-o+"px",!0}return!1};selectButtons=e=>{if(e===this.content){const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&t.isCollapsed){const n=t.getRangeAt(0);if(n.startContainer===this.content){const t=n.startOffset,i=this.content.childNodes[t],o=t>0?this.content.childNodes[t-1]:null;"TABLE"===i?.nodeName?e=i:"TABLE"===o?.nodeName&&(e=o)}}}if(null==e||e==this.content||!this.content.contains(e)||1==this.lockToolbar)return;this.clearButtons();const t=this.getButton("blazing-rich-text-bold-button"),n=this.getButton("blazing-rich-text-italic-button"),i=this.getButton("blazing-rich-text-underline-button"),o=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"),d=this.getButton("blazing-rich-text-alignright-button"),c=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"),p=this.getButton("blazing-rich-text-textcolor-button"),m=this.getButton("blazing-rich-text-text-bg-color-button"),x=this.getButton("blazing-rich-text-textcolor-remove-button"),f=this.getButton("blazing-rich-text-quote-button"),v=this.getButton("blazing-rich-text-code-block-button"),y=this.getButton("blazing-rich-text-inline-code-button"),w=this.getButton("blazing-rich-text-table-button"),C=this.getButton("blazing-rich-text-image-button"),R=this.getButton("blazing-rich-text-image-upload-button"),E=this.getButton("blazing-rich-text-embed-button"),N=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 T=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=T&&(T.innerText="Font",this.fontSelected=!1);const z=this.shadowRoot.getElementById("blazing-rich-text-size-button");for(null!=z&&(z.innerText="Size",this.fontSizeSelected=!1);e!==this.content&&null!==e.parentNode&&this.content.contains(e.parentNode)&&"#text"!=e.parentNode.nodeName&&"#document"!=e.parentNode.nodeName;){let I=window.getComputedStyle(e.parentNode);const _="TABLE"===e.nodeName?e:e.parentNode.closest?.("table"),A=null!=_;if(null!=e.parentNode.style&&"bold"==e.parentNode.style.fontWeight&&this._press(t),null!=e.parentNode.style&&e.parentNode.style.color&&this._press(p),null!=e.parentNode.style&&e.parentNode.style.backgroundColor&&this._press(m),(null!=e.parentNode.style&&e.parentNode.style.color||e.parentNode.style.backgroundColor)&&this._press(x),"italic"==I.getPropertyValue("font-style")&&this._press(n),I.getPropertyValue("text-decoration").includes("underline")&&"A"!=e.parentNode.nodeName&&this._press(i),I.getPropertyValue("text-decoration").includes("line-through")&&this._press(o),"sub"==I.getPropertyValue("vertical-align")&&this._press(r),"super"==I.getPropertyValue("vertical-align")&&this._press(s),_&&!this.textAlign&&("auto"===_.style.margin?(this._press(a),this.textAlign=!0):"auto"===_.style.marginLeft?(this._press(d),this.textAlign=!0):"auto"===_.style.marginRight&&(this._press(l),this.textAlign=!0)),A||"left"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(l),this.textAlign=!0),A||"center"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),A||"right"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),A||"justify"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),null!=e&&null!=e.style&&e.style.fontFamily&&!this.fontSelected&&(T.innerText=e.style.fontFamily.replace(/^(["'])(.*)\1$/,"$2"),this.fontSelected=!0),null!=e&&null!=e.style&&e.style.fontSize&&!this.fontSizeSelected&&(z.innerText=e.style.fontSize,this.fontSizeSelected=!0),"P"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Paragraph",this.formatSelected=!0),"H1"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 1",this.formatSelected=!0),"H2"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 2",this.formatSelected=!0),"H3"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 3",this.formatSelected=!0),"H4"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 4",this.formatSelected=!0),"H5"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 5",this.formatSelected=!0),"H6"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 6",this.formatSelected=!0),"A"==e.parentNode.nodeName&&(this._press(u),this._press(g)),"BLOCKQUOTE"==e.parentNode.nodeName&&this._press(f),"CODE"==e.parentNode.nodeName&&("PRE"!==e.parentNode.parentElement?.nodeName?this._press(y):this._press(v)),"TD"!=e.parentNode.nodeName&&"TH"!=e.parentNode.nodeName||this._press(w),"OL"==e.parentNode.nodeName&&this._press(h),"UL"==e.parentNode.nodeName&&this._press(b),"VIDEO"!==e.nodeName&&"SOURCE"!==e.nodeName||N&&this._press(N),e.querySelector){const t=e.querySelector("img");t&&(t.src.startsWith("data")?this._press(R):this._press(C));e.querySelector("object")&&this._press(E);e.querySelector("video")&&N&&this._press(N)}e=e.parentNode}this.closeDropdowns()};closeDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-menu-item.active, .rich-text-box-menu-item-special.active, .rich-text-box-insert-item.active, .rtb-overflow-dropdown button.active").forEach(e=>e.classList.remove("active"));this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(function(e){e.classList.contains("rich-text-box-show")&&e.classList.remove("rich-text-box-show")});const e=this.shadowRoot.querySelector(".rtb-overflow-dropdown");if(e&&e.classList.contains("rtb-overflow-open")){e.classList.remove("rtb-overflow-open");const t=this.shadowRoot.querySelector(".rtb-overflow-btn");t&&t.setAttribute("aria-expanded","false")}};getButton=e=>this.shadowRoot.getElementById(e);refreshUI=()=>{if(this.removeEmptyNodes(),""===this.content.innerHTML.trim())return this.clearButtons(),void this.content.focus();const e=this.Utilities.getSelection();null!==e&&this.selectButtons(e.anchorNode),this.content.focus()};removeEmptyNodes=()=>{const e=this.content;if(e){e.querySelectorAll("*").forEach(e=>{e.hasChildNodes()&&(1!==e.childNodes.length||3!==e.childNodes[0].nodeType||/\S/.test(e.textContent))||e.parentElement&&!this.isNotRemovable(e.nodeName)&&e.parentElement.removeChild(e)})}};createDefaultElement=()=>{if(""===this.content.innerHTML.trim()){const e=document.createElement("p");e.style.overflowWrap="break-word";const t=document.createElement("br");e.appendChild(t),this.content.appendChild(e)}};allSelected=()=>{const e=this.Utilities.getSelection();if(null!==e){if(0===e.rangeCount)return!1;const t=e.getRangeAt(0),n=document.createRange();return n.selectNodeContents(this.content),t.startContainer===n.startContainer&&t.startOffset===n.startOffset&&t.endContainer===n.endContainer&&t.endOffset===n.endOffset}return!1};clearButtons=()=>{this.closeDropdowns();this.shadowRoot.querySelectorAll(".rich-text-box-menu-item, .rich-text-box-menu-item-special").forEach(function(e){e.classList.remove("selected"),e.setAttribute("aria-pressed","false")});const e=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=e&&(e.innerText="Format",this.formatSelected=!1);const t=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=t&&(t.innerText="Font",this.fontSelected=!1);const n=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=n&&(n.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=e=>{switch(e.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(e){if(!e.rangeCount)return!1;const t=e.getRangeAt(0),n=t.cloneContents(),i=document.createElement("div");i.appendChild(n);const o=t.commonAncestorContainer;return o!==this.content&&this.content.contains(o)&&i.innerHTML==t.commonAncestorContainer.innerHTML&&o.nodeType!==Node.TEXT_NODE?(i.remove(),!0):(i.remove(),!1)}createElement=e=>this.hasInvalidElementsInSelection(e)?document.createElement("div"):document.createElement("span");hasInvalidElementsInSelection=e=>{if(e){const t=["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"],n=e.getRangeAt(0).cloneContents().querySelectorAll("*");for(let e=0;e<n.length;e++){const i=n[e];if(t.includes(i.tagName.toLowerCase()))return!0}}return!1};removeProperty=(e,t,n)=>{null!=e&&e!=this.content&&this.content.contains(e)&&(this.getUserDefinedStyleCount(e)>1?e.style.removeProperty(t,n):"SPAN"==e.nodeName?0==e.childElementCount?e.replaceWith(e.textContent):(e.insertAdjacentHTML("afterend",e.innerHTML),e.remove()):"DIV"==e.nodeName&&!0===this.isCommonAncestor?(e.insertAdjacentHTML("afterend",e.innerHTML),e.remove()):e.hasAttribute("style")&&e.removeAttribute("style"))};addTextDecoration=(e,t)=>{if(null==e||e==this.content||e==this.content.parentNode)return;const n=e.style.textDecoration;if(null!=n&&!n.includes(t)){const i=n?n+" "+t:t;e.style.textDecoration=i}};removeTextDecoration=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e))if(this.getUserDefinedStyleCount(e)>1){const n=e.style.textDecoration.split(" ").filter(e=>e!==t);e.style.textDecoration=n.join(" ")}else"SPAN"==e.nodeName&0==e.childElementCount?e.replaceWith(e.textContent):"SPAN"==e.nodeName?(e.insertAdjacentHTML("afterend",e.innerHTML),e.remove()):e.hasAttribute("style")&&e.removeAttribute("style")};getUserDefinedStyles=e=>{if(null==e||e==this.content||!this.content.contains(e))return;let t={};for(let n=0;n<e.style.length;n++){let i=e.style[n],o=e.style.getPropertyValue(i);t[i]=o}return t};getUserDefinedStyleCount=e=>{if(null==e||e==this.content||!this.content.contains(e))return;let t=0;for(let n=0;n<e.style.length;n++){let i=e.style[n],o=e.style.getPropertyValue(i);if(this.isFormatElement(e)){if("initial"!=o){let e=o.split(" ");if(!this.isMultiValueProperty(i)&&e.length>1)for(let n=0;n<e.length;n++)t++;else t++}}else t++}return t};isMultiValueProperty=e=>{switch(e){case"background-color":case"color":case"font-family":return!0}return!1};getElementByType=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e)){for(;e;){if(e===this.content||!this.content.contains(e))return;if("#text"!=e.nodeName&&"#document"!=e.nodeName)switch(t){case"Format":if(this.isFormatElement(e))return e;break;case"UL":case"OL":case"Element":if(e.nodeName===t)return e}e=e.parentNode}return null}};getElementByContent=(e,t,n)=>{if(null!=e&&e!=this.content&&this.content.contains(e))for(;e;){if(e===this.content||!this.content.contains(e))return;if("#text"!=e.nodeName&&"#document"!=e.nodeName){const i=this.getElementByStyle(e,t);if(null!=i&&this.selectionContainsNode(n,i))return i;if(null!==n&&n.toString().trim()==e.textContent.trim())return e}e=e.parentNode}};selectionContainsNode(e,t){if(null==t||t==this.content||!this.content.contains(t))return!1;if(e.rangeCount>0)for(let n=0;n<e.rangeCount;n++){let i=e.getRangeAt(n);if(this.isNodeInRange(t,i))return!0}return!1}isNodeInRange(e,t){if(null==e||e==this.content||!this.content.contains(e))return!1;let n=e.ownerDocument.createRange();return n.selectNode(e),t.compareBoundaryPoints(Range.START_TO_END,n)<=0&&t.compareBoundaryPoints(Range.END_TO_START,n)>=0}getElementByStyle=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e)){for(;e;){if(e===this.content||!this.content.contains(e))return;if(null!=e.style){let n=null;switch(t){case"textcolor":if(n=e.getAttribute("style"),null!=n&&n.includes("color:"))return e;break;case"textbgcolor":if(n=e.getAttribute("style"),null!=n&&n.includes("background-color:"))return e;break;case"font":if(n=e.getAttribute("style"),null!=n&&n.includes("font-family:"))return e;break;case"size":if(n=e.getAttribute("style"),null!=n&&n.includes("font-size:"))return e;break;case"bold":if(n=e.getAttribute("style"),null!=n&&n.includes("font-weight:")&&"bold"==e.style.fontWeight)return e;break;case"italic":if(n=e.getAttribute("style"),null!=n&&n.includes("font-style:")&&"italic"==e.style.fontStyle)return e;break;case"underline":if(n=e.getAttribute("style"),null!=n&&n.includes("text-decoration:")&&e.style.textDecoration.includes("underline"))return e;break;case"line-through":if(n=e.getAttribute("style"),null!=n&&n.includes("text-decoration:")&&e.style.textDecoration.includes("line-through"))return e;break;case"subscript":if(n=e.getAttribute("style"),null!=n&&n.includes("vertical-align:")&&"sub"==e.style.verticalAlign)return e;break;case"superscript":if(n=e.getAttribute("style"),null!=n&&n.includes("vertical-align:")&&"superscript"==e.style.verticalAlign)return e;break;case"alignleft":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"left"==e.style.textAlign)return e;break;case"aligncenter":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"center"==e.style.textAlign)return e;break;case"alignright":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"right"==e.style.textAlign)return e;break;case"alignjustify":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"justify"==e.style.textAlign)return e}}e=e.parentNode}return null}};isFormatElement=e=>!(null==e||e==this.content||!this.content.contains(e))&&("P"==e.nodeName||"H1"==e.nodeName||"H2"==e.nodeName||"H3"==e.nodeName||"H4"==e.nodeName||"H5"==e.nodeName||"H6"==e.nodeName||(null!=e.style&&null!=e.style.textDecoration||void 0));insertLineBreak=e=>{const t=document.createElement("p"),n=document.createElement("br");if(t.appendChild(n),"CODE"==e.nodeName){const n=e.parentNode.parentNode;n.nextSibling?n.parentNode.insertBefore(t,n.nextSibling):n.parentNode.appendChild(t)}else e.parentNode.insertBefore(t,e.nextSibling);const i=document.createRange();i.setStartBefore(n),i.collapse(!0);const o=this.Utilities.getSelection();null!==o&&(o.removeAllRanges(),o.addRange(i))}}class i{constructor(e,t,n,i){this.shadowRoot=e,this.content=t,this.Utilities=n,this.NodeManager=i}addlist=e=>{const t=this.Utilities.getSelection();if(null!==t){if(t.isCollapsed&&t.rangeCount>0&&this.isCollapsedAtElementBoundary(t.getRangeAt(0)))return;if("UL"==e){const e=this.NodeManager.getElementByType(t.anchorNode,"OL");if(null!=e)return void this.replaceList(e,"UL")}else{const e=this.NodeManager.getElementByType(t.anchorNode,"UL");if(null!=e)return void this.replaceList(e,"OL")}const n=this.NodeManager.getElementByType(t.anchorNode,e);if(null!=n)this.removelist(n);else{if(0===t.toString().trim().length){const n=t.getRangeAt(0);let i;const o=document.createElement(e);if(t.anchorNode.parentNode!==this.content&&(i=t.anchorNode.parentNode),t.anchorNode!==this.content&&(i=t.anchorNode),!i)return;if(i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),t=i.cloneNode(!0);this.appendListItemContent(e,t),o.appendChild(e),i.remove()}n.deleteContents(),n.insertNode(o);const r=document.createRange();r.selectNodeContents(o),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}else{const n=document.createElement(e);if(t.rangeCount>0){const e=t.getRangeAt(0),i=e.cloneContents().childNodes;Array.from(i).forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),i=e.cloneNode(!0);this.appendListItemContent(t,i),n.appendChild(t),e.remove()}}),e.deleteContents(),e.insertNode(n),e.selectNodeContents(n),t.removeAllRanges(),t.addRange(e)}}}}};isCollapsedAtElementBoundary=e=>{const t=e.startContainer,n=e.startOffset,i=new Set(["TABLE","IMG","VIDEO","AUDIO","IFRAME","CANVAS","SVG","FIGURE","OBJECT","EMBED","HR","PRE","BLOCKQUOTE"]);if(t===this.content){return[n>0?t.childNodes[n-1]:null,t.childNodes[n]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE)}if(t.nodeType!==Node.ELEMENT_NODE)return!1;if(i.has(t.nodeName))return!0;return[n>0?t.childNodes[n-1]:null,t.childNodes[n]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE&&i.has(e.nodeName))};appendListItemContent=(e,t)=>{if(e&&t)if(this.isParagraphChild(t))for(;t.firstChild;)e.appendChild(t.firstChild);else e.appendChild(t)};replaceList=(e,t)=>{if(null===e||e===this.content||!this.content.contains(e))return;const n=this.Utilities.getSelection();let i,o,r,s,l;null!==n&&n.rangeCount>0&&(i=n.getRangeAt(0),o=i.startContainer,r=i.startOffset,s=i.endContainer,l=i.endOffset);const a=document.createElement(t);for(;e.firstChild;)a.appendChild(e.firstChild);if(e.parentNode.replaceChild(a,e),i){const t=document.createRange();e.contains(o)?t.setStart(a,r):t.setStart(o,r),e.contains(s)?t.setEnd(a,l):t.setEnd(s,l),n.removeAllRanges(),n.addRange(t)}};removelist=e=>{if(null==e||e==this.content||!this.content.contains(e))return;if("OL"===e.nodeName||"UL"===e.nodeName)return void this.removeListAsParagraphs(e);let t=null;for(;e.firstChild;){const n=e.firstChild;if("UL"===n.nodeName||"OL"===n.nodeName)t||(t=n),e.parentNode.insertBefore(n,e);else{for(;n.firstChild;){const i=n.firstChild;t||(t=i),e.parentNode.insertBefore(i,e)}e.removeChild(n)}}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}};removeListAsParagraphs=e=>{let t=null;for(;e.firstChild;){const n=e.firstChild;if("LI"!==n.nodeName){t||(t=n),e.parentNode.insertBefore(n,e);continue}const i=document.createElement("p");for(;n.firstChild;){const e=n.firstChild;if("UL"===e.nodeName||"OL"===e.nodeName)break;if(this.isParagraphChild(e)){for(;e.firstChild;)i.appendChild(e.firstChild);n.removeChild(e)}else i.appendChild(e)}for(i.hasChildNodes()||i.appendChild(document.createElement("br")),t||(t=i),e.parentNode.insertBefore(i,e);n.firstChild;)e.parentNode.insertBefore(n.firstChild,e);e.removeChild(n)}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}};isParagraphChild=e=>!(!e||e.nodeType!==Node.ELEMENT_NODE)&&["P","DIV"].includes(e.nodeName);increaseIndent=(e,t)=>{if(!e||!t||"UL"!==t.nodeName&&"OL"!==t.nodeName)return;let n=this.getSelectedNodes(e,t);if(!n||0===n.length)return;let i=n[0].previousElementSibling;if(!i||"LI"!==i.nodeName)return;let o=Array.from(i.children).find(e=>e.nodeName===t.nodeName);o||(o=document.createElement(t.nodeName),i.appendChild(o)),n.forEach(e=>{"LI"===e.nodeName&&o.appendChild(e)}),this.selectListItemStart(e,n[0])};decreaseIndent=(e,t)=>{if(!e||!t||"UL"!==t.nodeName&&"OL"!==t.nodeName)return;const n=this.getSelectedNodes(e,t);if(!n||0===n.length)return;const i=t.parentElement,o=i?i.parentElement:null;if(!i||"LI"!==i.nodeName||!o||"UL"!==o.nodeName&&"OL"!==o.nodeName)return;const r=n[n.length-1],s=document.createElement(t.nodeName);for(;r.nextElementSibling;)s.appendChild(r.nextElementSibling);const l=document.createDocumentFragment();n.forEach(e=>{"LI"===e.nodeName&&l.appendChild(e)}),o.insertBefore(l,i.nextSibling),s.children.length>0&&r.appendChild(s),0===t.children.length&&t.remove(),this.selectListItemStart(e,n[0])};getSelectedNodes=(e,t)=>{const n=[];if(!e.rangeCount)return null;const i=e.getRangeAt(0);if(null!==t){const e=t.children;for(let t=0;t<e.length;t++){const o=e[t];i.intersectsNode(o)&&n.push(o)}return n}return null};saveListSelection=e=>e&&0!==e.rangeCount?e.getRangeAt(0).cloneRange():null;restoreListSelection=(e,t,n)=>{if(e&&t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))return e.removeAllRanges(),void e.addRange(t);this.selectListItem(e,n)};selectListItemStart=(e,t)=>{if(!e||!t)return;const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)};selectListItem=(e,t)=>{if(!e||!t)return;const n=document.createRange(),i=this.getFirstTextNode(t);i?n.setStart(i,i.textContent.length):(n.selectNodeContents(t),n.collapse(!1)),n.collapse(!0),e.removeAllRanges(),e.addRange(n)};getFirstTextNode=e=>{if(!e)return null;if(e.nodeType===Node.TEXT_NODE)return e;for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("UL"===n.nodeName||"OL"===n.nodeName)continue;const i=this.getFirstTextNode(n);if(i)return i}return null};getList=e=>{for(;e;){if(e===this.content||!this.content.contains(e))return;if("#text"!=e.nodeName&&"#document"!=e.nodeName)switch(e.nodeName){case"OL":case"UL":return e}e=e.parentNode}return null}}class o{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n}copy=()=>{const e=this.Utilities.getSelection();null!==e&&null!==e&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(e)};cut=()=>{const e=this.Utilities.getSelection();null!==e&&null!==e&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&(navigator.clipboard.writeText(e),e.deleteFromDocument())};paste=e=>{const t=String(e||"").trim();this.checkParagraphs(t)||this.checkTables(t)||this.checkLines(t)||this.checkText(t)};checkParagraphs=e=>{let t=e.split(/\n\s*\n/);if(t.length>1){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const n=e.getRangeAt(0);n.deleteContents();let i=document.createDocumentFragment();return t.forEach(e=>{let t=this.checkParagraphTable(e,i);if(t||(t=this.checkParagraphLines(e,i)),!t){let t=document.createElement("p");t.textContent=e.trim(),i.appendChild(t)}}),n.insertNode(i),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!0}}return!1};checkParagraphLines=(e,t)=>{let n=0,i=e.trim().split(/\n+/);return i.length>1&&(i.forEach(e=>{if(n++,n===i.length){let n=document.createElement("p");n.textContent=e.trim(),t.appendChild(n)}else{let n=document.createElement("div");n.textContent=e.trim(),t.appendChild(n)}}),!0)};checkParagraphTable=(e,t)=>{if(this.isTable(e)){let n=this.buildTable(e);return t.appendChild(n),!0}return!1};checkLines=e=>{let t=e.trim().split(/\n+/);if(t.length>1){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const n=e.getRangeAt(0);n.deleteContents();let i=document.createDocumentFragment();return t.forEach(e=>{let t=document.createElement("div");t.textContent=e.trim(),i.appendChild(t)}),n.insertNode(i),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!0}}};checkTables=e=>{if(this.isTable(e)){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const n=t.getRangeAt(0);n.deleteContents();let i=document.createDocumentFragment(),o=this.buildTable(e);return i.appendChild(o),n.insertNode(i),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0}}};buildTable=e=>{let t=document.createElement("table"),n=e.split("\n"),i=document.createElement("tbody");return n.forEach((e,t)=>{if(e.trim().length>0){let t=e.split("\t"),n=document.createElement("tr");t.forEach(e=>{let t=document.createElement("td");e.trim().length>0&&(t.textContent=e),n.appendChild(t)}),i.appendChild(n)}}),t.appendChild(i),t};isTable=e=>{if(e.includes("\t")){let t=e.split("\n");if(t.length>1&&t[1].trim().length>0){let e=(t[1].match(/\t/g)||[]).length;if(0===e)return!1;for(let n=1;n<t.length;n++){let i=t[n];if(i.trim().length>0){if((i.match(/\t/g)||[]).length!==e)return!1}}return!0}}return!1};checkText=e=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const n=t.getRangeAt(0);if(n.deleteContents(),""===this.content.innerHTML.trim()){const t=document.createElement("div"),i=document.createTextNode(e);t.appendChild(i),n.insertNode(t),n.setStartAfter(t),n.setEndAfter(t)}else{const t=document.createTextNode(e);n.insertNode(t),n.setStartAfter(t),n.setEndAfter(t)}t.removeAllRanges(),t.addRange(n)}}}class r{constructor(e,t){this.shadowRoot=e,this.content=t}closeDialog=(e,t)=>{const n=this.shadowRoot.getElementById(e);null!=n&&n.close(),t&&this.restoreSelection(window.getSelection(),t),this.content.focus()};addClasses=(e,t)=>{if(null!=e&&null!=t)if(t.classList.remove(...t.classList),e.length>0){e.split(" ").map(e=>e.trim()).forEach(e=>{e&&t.classList.add(e)})}else t.hasAttribute("class")&&t.removeAttribute("class")};getSelection=()=>{const e=this.shadowRoot.getSelection();return this.content.contains(e.anchorNode)&&this.content.contains(e.focusNode)?e:null};showFadingBar=e=>{const t=this.shadowRoot.getElementById("rich-text-box-message-bar"),n=t.querySelector(".rich-text-box-message");t&&n&&(n.textContent=e,t.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=e=>e&&e.rangeCount>0?e.getRangeAt(0).cloneRange():null;restoreSelection=(e,t)=>{e&&t&&(e.removeAllRanges(),e.addRange(t)),this.content.focus()};reselectNode=e=>{const t=document.createRange(),n=window.getSelection();e.childNodes.length>0?t.setStartAfter(e.childNodes[e.childNodes.length-1]):t.setStartAfter(e),t.collapse(!0),n.removeAllRanges(),n.addRange(t)};saveCaretPosition=()=>{const e=this.getSelection();if(null!==e){return{startOffset:e.getRangeAt(0).startOffset,endOffset:e.getRangeAt(0).endOffset}}return null};restoreCaretPosition=(e,t)=>{const n=this.getSelection();if(null!==n&&null!==t){let i=document.createRange();i.setStart(e.firstChild,t.startOffset),i.setEnd(e.firstChild,t.endOffset),n.removeAllRanges(),n.addRange(i)}};saveScroll=e=>e.scrollTop;restoreScroll=(e,t)=>{e.scrollTop=t}}class s{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-table-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){const t=this.shadowRoot.activeElement;if(t&&"BUTTON"===t.tagName)return;e.preventDefault(),this.insertTable()}"Escape"===e.key&&(e.preventDefault(),this.closeDialog())}),["rich-text-box-table-columns","rich-text-box-table-rows"].forEach(e=>{const t=this.shadowRoot.getElementById(e);t&&(t.addEventListener("keydown",e=>this.allowTableNumberKey(e)),t.addEventListener("input",()=>this.cleanTableNumberInput(t)))})};allowTableNumberKey=e=>{if(e.ctrlKey||e.metaKey||e.altKey)return;["Backspace","Delete","Tab","Enter","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)||/^\d$/.test(e.key)||e.preventDefault()};cleanTableNumberInput=e=>{const t=e.value.replace(/\D/g,""),n=parseInt(e.max,10)||1e4;e.value=t.length>0?String(Math.min(parseInt(t,10),n)):"",e.setCustomValidity("")};getValidTableNumber=(e,t)=>{const n=parseInt(e.value,10),i=parseInt(e.max,10)||1e4;if(!Number.isInteger(n)||n<1||n>i){const t="Enter a valid number.";return e.setCustomValidity(t),e.reportValidity(),this.Utilities.showFadingBar(t),e.focus(),e.select(),null}return e.setCustomValidity(""),n};openTableDialog=e=>{if(this.resetTableDialog(),this.savedSelection=this.Utilities.saveSelection(e),null==e.anchorNode||e.anchorNode==this.content||null==e.anchorNode.parentNode||e.anchorNode.parentNode==this.content||"TD"!==e.anchorNode.parentNode.nodeName&&"TH"!==e.anchorNode.parentNode.nodeName)null!==e&&e.rangeCount>0&&(this.tableSelection=e.getRangeAt(0).cloneRange());else{const t=this.getTable(e);if(t){const e=this.shadowRoot.getElementById("rich-text-box-table-rows");e.value=t.rows.length,e.disabled=!0;const n=this.shadowRoot.getElementById("rich-text-box-table-columns");n.value=this.getColumns(t),n.disabled=!0;this.shadowRoot.getElementById("rich-text-box-table-width").value=t.style.width;const i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=i){const e=t.classList;i.value=Array.from(e).join(" ")}const o=this.shadowRoot.getElementById("rich-text-box-table-header");o&&(o.checked=this._tableHasHeader(t)),this.table=t}}this.shadowRoot.getElementById("rich-text-box-table-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-table-columns");t&&t.focus()};openTableDialogForElement=(e,t)=>{if(!e||"TABLE"!==e.nodeName||!this.content.contains(e))return;this.resetTableDialog(),this.savedSelection=t?t.cloneRange():null,this.tableSelection=t?t.cloneRange():null,this.table=e;const n=this.shadowRoot.getElementById("rich-text-box-table-rows");n.value=e.rows.length,n.disabled=!0;const i=this.shadowRoot.getElementById("rich-text-box-table-columns");i.value=this.getColumns(e),i.disabled=!0,this.shadowRoot.getElementById("rich-text-box-table-width").value=e.style.width,this.shadowRoot.getElementById("rich-text-box-table-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-table-header").checked=this._tableHasHeader(e),this.shadowRoot.getElementById("rich-text-box-table-modal").show(),this.shadowRoot.getElementById("rich-text-box-table-width").focus()};getTable=e=>"TABLE"===e.anchorNode.parentNode.parentNode.parentNode.nodeName?e.anchorNode.parentNode.parentNode.parentNode:"TABLE"===e.anchorNode.parentNode.parentNode.parentNode.parentNode.nodeName?e.anchorNode.parentNode.parentNode.parentNode.parentNode:void 0;getColumns(e){let t=0;for(let n=0;n<e.rows.length;n++){let i=e.rows[n].cells.length;i>t&&(t=i)}return t}resetTableDialog=()=>{this.table=null,this.tableSelection=null;const e=this.shadowRoot.getElementById("rich-text-box-table-rows");e.value=null,e.disabled=!1;const t=this.shadowRoot.getElementById("rich-text-box-table-columns");t.value=null,t.disabled=!1;this.shadowRoot.getElementById("rich-text-box-table-width").value=null;const n=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=n&&(n.value=null);const i=this.shadowRoot.getElementById("rich-text-box-table-header");i&&(i.checked=!0)};insertTable=()=>{const e=this.shadowRoot.getElementById("rich-text-box-table-rows"),t=this.shadowRoot.getElementById("rich-text-box-table-columns"),n=this.shadowRoot.getElementById("rich-text-box-table-width"),i=this.shadowRoot.getElementById("rich-text-box-table-classes"),o=this.shadowRoot.getElementById("rich-text-box-table-header"),r=!!o&&o.checked,s=this.getValidTableNumber(t,"Columns");if(null===s)return;const l=this.getValidTableNumber(e,"Rows");if(null!==l){if(null!==this.table){n.value.trim().length>0?this.table.style.width=n.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);const e=this._tableHasHeader(this.table);r&&!e?this._addHeader(this.table):!r&&e&&this._removeHeader(this.table),this.Utilities.reselectNode(this.table)}else if(null!=this.tableSelection){const e=this.tableSelection,t=this.createTable(l,s,n.value,r);null!==i&&this.Utilities.addClasses(i.value,t),e.deleteContents();let o=e.startContainer;if(o===this.content){const n=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,n)}else{for(;o.parentNode&&o.parentNode!==this.content;)o=o.parentNode;o&&o!==this.content&&this.content.contains(o)?this.content.insertBefore(t,o.nextSibling):this.content.appendChild(t)}const a=t.previousSibling;a&&a.nodeType===Node.ELEMENT_NODE&&""===a.textContent.trim()&&a.parentNode.removeChild(a);const d=t.nextSibling;d&&d.nodeType===Node.ELEMENT_NODE&&""===d.textContent.trim()&&d.parentNode.removeChild(d);let c=t.querySelector("td, th"),h=document.createRange();h.setStart(c,0),h.setEnd(c,0),this.savedSelection=h}this.closeDialog()}};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-table-modal",this.savedSelection)};createTable=(e,t,n,i=!1)=>{const o=parseInt(e,10),r=parseInt(t,10),s=document.createElement("table");if(n&&(s.style.width=n),i){const e=document.createElement("thead"),t=document.createElement("tr");for(let e=0;e<r;e++){const e=document.createElement("th");e.innerHTML="&#8203;",t.appendChild(e)}e.appendChild(t),s.appendChild(e)}const l=document.createElement("tbody");for(let e=0;e<o;e++){const e=document.createElement("tr");for(let t=0;t<r;t++){const t=document.createElement("td");t.innerHTML="&#8203;",e.appendChild(t)}l.appendChild(e)}return s.appendChild(l),s};_tableHasHeader=e=>{const t=e.querySelector("thead");if(t&&t.querySelector("th"))return!0;const n=e.querySelector("tr");return!!n&&(n.cells.length>0&&Array.from(n.cells).every(e=>"TH"===e.tagName))};_addHeader=e=>{const t=this.getColumns(e),n=document.createElement("thead"),i=document.createElement("tr");for(let e=0;e<t;e++){const e=document.createElement("th");e.innerHTML="&#8203;",i.appendChild(e)}n.appendChild(i),e.insertBefore(n,e.firstChild)};_removeHeader=e=>{const t=e.querySelector("thead");if(t)return void t.remove();const n=e.querySelector("tr");n&&n.cells.length>0&&Array.from(n.cells).every(e=>"TH"===e.tagName)&&n.remove()};tableTab=()=>{const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return;const t=this.getCurrentCell(e);if(!t)return;const n=this.getNextElement(t);if(n){n.focus();const t=document.createRange();t.selectNodeContents(n),"​"===n.innerText&&t.collapse(),e.removeAllRanges(),e.addRange(t)}else{const n=t.closest("table");if(n){let t=n.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.nextSibling;if(t){const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}}this.content.focus()}};addRowFromLastCell=()=>{const e=this.Utilities.getSelection();if(null===e||!e.rangeCount)return!1;const t=this.getCurrentCell(e);if(!t)return!1;const n=t.parentElement,i=n?n.parentElement:null,o=i?i.closest("table"):null;if(!n||!i||!o)return!1;if(n.nextElementSibling)return!1;if(t.nextElementSibling)return!1;const r=Math.max(this.getColumns(o),n.cells.length,1),s=document.createElement("tr");for(let e=0;e<r;e++){const e=document.createElement("td");e.innerHTML="&#8203;",s.appendChild(e)}i.appendChild(s);const l=s.querySelector("td, th");return l&&this.selectCell(l),!0};_makeRow=e=>{const t=document.createElement("tr");for(let n=0;n<e;n++){const e=document.createElement("td");e.innerHTML="&#8203;",t.appendChild(e)}return t};insertRowAbove=(e,t)=>{const n=e?e.closest("tr"):t?.querySelector("tr");if(!n)return;const i=Math.max(this.getColumns(t||n.closest("table")),n.cells.length,1),o=this._makeRow(i);n.parentElement.insertBefore(o,n),e&&this.selectCell(e)};insertRowBelow=(e,t)=>{const n=t||e?.closest("table"),i=e?e.closest("tr"):n?.querySelector("tr:last-child");if(!i)return;const o=Math.max(this.getColumns(n),i.cells.length,1),r=this._makeRow(o);i.after(r),e&&this.selectCell(e)};insertColumnLeft=(e,t)=>{const n=t||e?.closest("table");if(!n)return;const i=e?e.cellIndex:0;for(const e of n.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),n=document.createElement(t?"th":"td");n.innerHTML="&#8203;",e.insertBefore(n,e.cells[i]||null)}e&&this.selectCell(e)};insertColumnRight=(e,t)=>{const n=t||e?.closest("table");if(!n)return;const i=e?e.cellIndex:n.rows[0]?.cells.length-1??0;for(const e of n.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),n=document.createElement(t?"th":"td");n.innerHTML="&#8203;",e.insertBefore(n,e.cells[i+1]||null)}e&&this.selectCell(e)};removeRow=e=>{const t=e?.closest("tr");if(!t)return;const n=t.parentElement,i=n?.closest("table");if(!i||n.rows.length<=1)return;const o=t.previousElementSibling||t.nextElementSibling;if(t.remove(),o){const e=o.querySelector("td, th");e&&this.selectCell(e)}};removeColumn=(e,t)=>{const n=t||e?.closest("table");if(!n||!e)return;const i=e.cellIndex;if(n.rows[0]?.cells.length<=1)return;for(const e of n.rows)e.cells[i]&&e.cells[i].remove();const o=e.closest("tr")||n.rows[0],r=o?.cells[i]||o?.cells[i-1];r&&this.selectCell(r)};getCurrentCell=e=>{if(!e||!e.anchorNode)return null;const t=e.anchorNode.nodeType===Node.ELEMENT_NODE?e.anchorNode:e.anchorNode.parentElement;if(!t||!this.content.contains(t))return null;const n=t.closest("td, th");return n&&this.content.contains(n)?n:null};selectCell=e=>{if(!e)return;this.content.focus();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNodeContents(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)};getNextElement=e=>{let t=e.nextElementSibling;if(!t){let n=e.parentElement.nextElementSibling;if(!n){const t=e.parentElement.parentElement?.nextElementSibling;t&&(n=t.querySelector("tr"))}n&&(t=n.querySelector("td, th"))}return t}}class l{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertMedia()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openMediaDialog=e=>{if(null!==e){if(this.resetMediaDialog(),this.savedSelection=this.Utilities.saveSelection(e),e.anchorNode&&e.anchorNode.querySelector&&(this.embed=e.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(" ")}e.rangeCount>0&&(this.embedSelection=e.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-embed-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-embed-source");t&&t.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 e=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=e&&(e.value=null)};insertMedia=()=>{const e=this.shadowRoot.getElementById("rich-text-box-embed-source"),t=this.shadowRoot.getElementById("rich-text-box-embed-width"),n=this.shadowRoot.getElementById("rich-text-box-embed-height"),i=this.shadowRoot.getElementById("rich-text-box-embed-type"),o=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");if(null!==this.embed)this.embed.data=e.value,i.value.trim().length>0?this.embed.type=i.value:this.embed.hasAttribute("type")&&this.embed.removeAttribute("type"),t.value.trim().length>0?this.embed.width=t.value:this.embed.hasAttribute("width")&&this.embed.removeAttribute("width"),n.value.trim().length>0?this.embed.height=n.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==o&&this.Utilities.addClasses(o.value,this.embed);else if(null!=this.embedSelection&&e.value.length>0){const r=this.embedSelection.cloneRange(),s=document.createElement("object");s.data=e.value,i.value.trim().length>0?s.type=i.value:s.hasAttribute("type")&&s.removeAttribute("type"),t.value.trim().length>0?s.width=t.value:s.hasAttribute("width")&&s.removeAttribute("width"),n.value.trim().length>0?s.height=n.value:s.hasAttribute("height")&&s.removeAttribute("height"),null!==o&&this.Utilities.addClasses(o.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(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,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",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertVideo()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};_populateFromVideo=e=>{const ge=e=>this.shadowRoot.getElementById(e),t=e.querySelector("source");ge("rich-text-box-video-source").value=t?t.getAttribute("src")||"":e.getAttribute("src")||"",ge("rich-text-box-video-source-type").value=t&&t.getAttribute("type")||"",ge("rich-text-box-video-poster").value=e.getAttribute("poster")||"",ge("rich-text-box-video-width").value=e.getAttribute("width")||"",ge("rich-text-box-video-height").value=e.getAttribute("height")||"",ge("rich-text-box-video-controls").checked=e.hasAttribute("controls"),ge("rich-text-box-video-autoplay").checked=e.hasAttribute("autoplay"),ge("rich-text-box-video-loop").checked=e.hasAttribute("loop"),ge("rich-text-box-video-muted").checked=e.hasAttribute("muted"),ge("rich-text-box-video-css-classes").value=Array.from(e.classList).join(" ")};_showDialog=()=>{this.shadowRoot.getElementById("rich-text-box-video-modal").show(),this.shadowRoot.getElementById("rich-text-box-video-source").focus()};openVideoDialog=e=>{if(null!==e){this.resetVideoDialog(),this.savedSelection=this.Utilities.saveSelection(e);const t=e.anchorNode;t&&("VIDEO"===t.nodeName?this.video=t:"SOURCE"===t.nodeName&&"VIDEO"===t.parentElement?.nodeName?this.video=t.parentElement:t.querySelector&&(this.video=t.querySelector("video")),!this.video&&t.closest&&(this.video=t.closest("video"))),null!==this.video&&this._populateFromVideo(this.video),e.rangeCount>0&&(this.videoSelection=e.getRangeAt(0).cloneRange()),this._showDialog()}};openVideoDialogForElement=(e,t)=>{this.resetVideoDialog(),this.savedSelection=t,this.video=e,this._populateFromVideo(e);const n=this.Utilities.getSelection();n&&n.rangeCount>0&&(this.videoSelection=n.getRangeAt(0).cloneRange()),this._showDialog()};resetVideoDialog=()=>{this.video=null,this.videoSelection=null;const ge=e=>this.shadowRoot.getElementById(e);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=e=>this.shadowRoot.getElementById(e),e=ge("rich-text-box-video-source").value.trim(),t=ge("rich-text-box-video-source-type").value.trim(),n=ge("rich-text-box-video-poster").value.trim(),i=ge("rich-text-box-video-width").value.trim(),o=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,d=ge("rich-text-box-video-css-classes").value.trim(),applyAttrs=c=>{let h=c.querySelector("source");h||(h=document.createElement("source"),c.appendChild(h)),h.setAttribute("src",e),t?h.setAttribute("type",t):h.removeAttribute("type"),n?c.setAttribute("poster",n):c.removeAttribute("poster"),i?c.setAttribute("width",i):c.removeAttribute("width"),o?c.setAttribute("height",o):c.removeAttribute("height"),r?c.setAttribute("controls",""):c.removeAttribute("controls"),s?c.setAttribute("autoplay",""):c.removeAttribute("autoplay"),l?c.setAttribute("loop",""):c.removeAttribute("loop"),a?c.setAttribute("muted",""):c.removeAttribute("muted"),this.Utilities.addClasses(d,c)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&e.length>0){const e=this.videoSelection.cloneRange();if(!this.content.contains(e.startContainer))return void this.closeDialog();const t=document.createElement("video");applyAttrs(t),e.deleteContents();let n=e.startContainer;if(n===this.content){const n=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,n)}else{for(;n.parentNode&&n.parentNode!==this.content;)if(n=n.parentNode,!this.content.contains(n))return this.content.appendChild(t),this._placeCursorAfterVideo(t),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(t,n.nextSibling),""!==n.textContent.trim()||n.querySelector("img, video, pre, blockquote")||n.parentNode.removeChild(n)}this._placeCursorAfterVideo(t),this.videoSelection=null}this.closeDialog()};_placeCursorAfterVideo=e=>{if(!e.nextSibling){const t=document.createElement("p");t.appendChild(document.createElement("br")),this.content.insertBefore(t,e.nextSibling)}this._insertedVideo=e};closeDialog=()=>{const e=this._insertedVideo;if(this._insertedVideo=null,this.Utilities.closeDialog("rich-text-box-video-modal",this.savedSelection),e){const t=e.nextSibling;if(t){const e=document.createRange(),n=t.firstChild??t;e.setStart(n,0),e.collapse(!0);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(e))}}}}class d{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{const e=this.shadowRoot.getElementById("rich-text-box-code");this.dialog=this.shadowRoot.getElementById("rich-text-box-code-block-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&t.target!==e&&(t.preventDefault(),t.stopPropagation(),this.insertCodeBlock()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openCodeBlockDialog=e=>{if(null!==e){this.resetCodeBlockDialog(),this.savedSelection=this.Utilities.saveSelection(e);const t=this.shadowRoot.getElementById("rich-text-box-code"),n=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content&&this.content.contains(e.anchorNode.parentNode)&&"CODE"===e.anchorNode.parentNode.nodeName){const i=e.anchorNode.parentNode.cloneNode(!0);if(t.value=i.textContent,null!=n){const t=e.anchorNode.parentNode.classList;n.value=Array.from(t).join(" ")}this.codeSelection=e.getRangeAt(0).cloneRange(),this.code=e.anchorNode.parentNode}else e.rangeCount>0&&(this.codeSelection=e.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),t&&(t.focus(),t.scrollTop=0,t.scrollLeft=0)}};openCodeBlockDialogForElement=(e,t)=>{if(!e||!this.content.contains(e))return;this.resetCodeBlockDialog(),this.savedSelection=t?t.cloneRange():null;const n=e.querySelector("code")||e,i=this.shadowRoot.getElementById("rich-text-box-code"),o=this.shadowRoot.getElementById("rich-text-box-code-css-classes");i.value=n.textContent,null!=o&&(o.value=Array.from(n.classList).join(" ")),this.codeSelection=t?t.cloneRange():null,this.code=n,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 e=this.shadowRoot.getElementById("rich-text-box-code-css-classes");null!=e&&(e.value=null)};insertCodeBlock=()=>{const e=this.shadowRoot.getElementById("rich-text-box-code"),t=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=this.code){const n=this.code;n.textContent=e.value,null!==t&&this.Utilities.addClasses(t.value,n);const i=document.createRange();i.selectNodeContents(n),i.collapse(!1),this.savedSelection=i}else if(null!=this.codeSelection&&e.value.length>0){const n=this.codeSelection.cloneRange(),i=document.createElement("pre"),o=document.createElement("code");null!==t&&this.Utilities.addClasses(t.value,o),o.textContent=e.value,i.appendChild(o),n.deleteContents(),n.insertNode(i);const r=i.previousSibling;r&&r.nodeType===Node.ELEMENT_NODE&&""===r.textContent.trim()&&r.parentNode.removeChild(r);const s=i.nextSibling;s&&s.nodeType===Node.ELEMENT_NODE&&""===s.textContent.trim()&&s.parentNode.removeChild(s),n.selectNodeContents(o),n.collapse(!1),this.savedSelection=n}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class c{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{const e=this.shadowRoot.getElementById("rich-text-box-quote");this.dialog=this.shadowRoot.getElementById("rich-text-box-block-quote-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&t.target!==e&&(t.preventDefault(),t.stopPropagation(),this.insertBlockQuote()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openBlockQuoteDialog=e=>{if(null!==e){this.resetBlockQuoteDialog(),this.savedSelection=this.Utilities.saveSelection(e);const t=this.shadowRoot.getElementById("rich-text-box-quote"),n=this.shadowRoot.getElementById("rich-text-box-cite"),i=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content&&this.content.contains(e.anchorNode.parentNode)&&"BLOCKQUOTE"==e.anchorNode.parentNode.nodeName){if(t.value=e.anchorNode.parentNode.textContent,null!=e.anchorNode.parentNode.cite&&(n.value=e.anchorNode.parentNode.cite),null!=i){const t=e.anchorNode.parentNode.classList;i.value=Array.from(t).join(" ")}this.quoteSelection=e.getRangeAt(0).cloneRange(),this.quote=e.anchorNode.parentNode}else e.rangeCount>0&&(this.quoteSelection=e.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),t&&(t.focus(),t.scrollTop=0,t.scrollLeft=0)}};openBlockQuoteDialogForElement=(e,t)=>{if(!e||!this.content.contains(e))return;this.resetBlockQuoteDialog(),this.savedSelection=t?t.cloneRange():null;const n=this.shadowRoot.getElementById("rich-text-box-quote"),i=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");n.value=e.textContent,null!=e.cite&&(i.value=e.cite),null!=o&&(o.value=Array.from(e.classList).join(" ")),this.quoteSelection=t?t.cloneRange():null,this.quote=e,this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),n.focus(),n.scrollTop=0,n.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 e=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");null!=e&&(e.value=null)};insertBlockQuote=()=>{const e=this.shadowRoot.getElementById("rich-text-box-quote"),t=this.shadowRoot.getElementById("rich-text-box-cite"),n=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const i=this.quote;i.textContent=e.value,t.value.trim().length>0?i.setAttribute("cite",t.value):i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==n&&this.Utilities.addClasses(n.value,i);const o=document.createRange();o.selectNodeContents(i),o.collapse(!1),this.savedSelection=o}else if(null!=this.quoteSelection&&e.value.length>0){const i=this.quoteSelection.cloneRange(),o=document.createElement("blockquote");o.textContent=e.value,t.value.trim().length>0?o.cite=t.value:o.hasAttribute("cite")&&o.removeAttribute("cite"),null!==n&&this.Utilities.addClasses(n.value,o),i.deleteContents(),i.insertNode(o);const r=o.previousSibling;r&&r.nodeType===Node.ELEMENT_NODE&&""===r.textContent.trim()&&r.parentNode.removeChild(r);const s=o.nextSibling;s&&s.nodeType===Node.ELEMENT_NODE&&""===s.textContent.trim()&&s.parentNode.removeChild(s),i.selectNodeContents(o),i.collapse(!1),this.savedSelection=i}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class h{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertUploadedImage()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())});this.shadowRoot.getElementById("rich-text-box-upload-image-file").addEventListener("change",this.handleFileSelect)};handleFileSelect=e=>{const t=e.target.files[0];this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=t.name;const n=document.createElement("img");if(t){const e=new FileReader;e.onloadend=function(){this.base64String=e.result.split(",")[1],n.src=`data:image/jpg;base64,${this.base64String}`},e.readAsDataURL(t),this.image=n}};openUploadImageDialog=e=>{if(null!==e){if(this.resetUploadImageDialog(),this.savedSelection=this.Utilities.saveSelection(e),e.anchorNode&&e.anchorNode.querySelector&&(this.currentImage=e.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.shadowRoot.getElementById("rich-text-box-upload-image-float").value=this.currentImage.style.float||"none";this.shadowRoot.getElementById("rich-text-box-upload-image-margin").value=this.currentImage.style.margin}this.range=e.getRangeAt(0).cloneRange(),this.shadowRoot.getElementById("rich-text-box-upload-image-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-upload-btn");t&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))}};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 e=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");null!=e&&(e.value=null);this.shadowRoot.getElementById("rich-text-box-upload-image-float").value="none";this.shadowRoot.getElementById("rich-text-box-upload-image-margin").value=null};insertUploadedImage=()=>{const e=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),t=this.shadowRoot.getElementById("rich-text-box-upload-image-height"),n=this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text"),i=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes"),o=this.shadowRoot.getElementById("rich-text-box-upload-image-float"),r=this.shadowRoot.getElementById("rich-text-box-upload-image-margin");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),e.value.trim().length>0?this.currentImage.width=e.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),t.value.trim().length>0?this.currentImage.height=t.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),n.value.trim().length>0?this.currentImage.alt=n.value:this.currentImage.hasAttribute("alt")&&this.currentImage.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.currentImage),"none"===o.value?(this.currentImage.style.removeProperty("float"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")):this.currentImage.style.float=o.value,Number.isFinite(parseFloat(r.value))&&0!==parseFloat(r.value)&&CSS.supports("margin",r.value)?this.currentImage.style.margin=r.value:(this.currentImage.style.removeProperty("margin"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")),this.Utilities.reselectNode(this.currentImage)):this.image&&(e.value.length>0?this.image.width=e.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),t.value.length>0?this.image.height=t.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),n.value.length>0?this.image.alt=n.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.image),"none"!==o.value&&(this.image.style.float=o.value),Number.isFinite(parseFloat(r.value))&&0!==parseFloat(r.value)&&CSS.supports("margin",r.value)&&(this.image.style.margin=r.value),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(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertImage()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openImageDialog=e=>{if(null!==e){if(this.resetImageDialog(),this.savedSelection=this.Utilities.saveSelection(e),e.anchorNode&&e.anchorNode.querySelector&&(this.image=e.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(" ");this.shadowRoot.getElementById("rich-text-box-image-float").value=this.image.style.float||"none";this.shadowRoot.getElementById("rich-text-box-image-margin").value=this.image.style.margin}e&&e.rangeCount>0&&(this.imageSelection=e.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-image-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress");t&&t.focus()}};openImageDialogForElement=(e,t)=>{e&&"IMG"===e.nodeName&&this.content.contains(e)&&(this.resetImageDialog(),this.image=e,this.savedSelection=t?t.cloneRange():null,this.imageSelection=t?t.cloneRange():null,this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=e.src,this.shadowRoot.getElementById("rich-text-box-image-width").value=e.width,this.shadowRoot.getElementById("rich-text-box-image-height").value=e.height,this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=e.alt,this.shadowRoot.getElementById("rich-text-box-image-css-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-image-float").value=e.style.float||"none",this.shadowRoot.getElementById("rich-text-box-image-margin").value=e.style.margin,this.shadowRoot.getElementById("rich-text-box-image-modal").show(),this.shadowRoot.getElementById("rich-text-box-image-webaddress").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 e=this.shadowRoot.getElementById("rich-text-box-image-css-classes");null!=e&&(e.value=null);this.shadowRoot.getElementById("rich-text-box-image-float").value="none";this.shadowRoot.getElementById("rich-text-box-image-margin").value=null};insertImage=()=>{const e=this.shadowRoot.getElementById("rich-text-box-image-webaddress"),t=this.shadowRoot.getElementById("rich-text-box-image-width"),n=this.shadowRoot.getElementById("rich-text-box-image-height"),i=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),o=this.shadowRoot.getElementById("rich-text-box-image-css-classes"),r=this.shadowRoot.getElementById("rich-text-box-image-float"),s=this.shadowRoot.getElementById("rich-text-box-image-margin");if(null!==this.imageSelection){const l=this.imageSelection.cloneRange();if(null!==this.image)e.value.trim().length>0&&(this.image.src=e.value),i.value.trim().length>0?this.image.alt=i.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),t.value.trim().length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),n.value.trim().length>0?this.image.height=n.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==o&&this.Utilities.addClasses(o.value,this.image),"none"===r.value?(this.image.style.removeProperty("float"),0===this.image.style.length&&this.image.removeAttribute("style")):this.image.style.float=r.value,Number.isFinite(parseFloat(s.value))&&0!==parseFloat(s.value)&&CSS.supports("margin",s.value)?this.image.style.margin=s.value:(this.image.style.removeProperty("margin"),0===this.image.style.length&&this.image.removeAttribute("style")),this.Utilities.reselectNode(this.image);else if(e.value.length>0){const a=document.createElement("img");a.src=e.value,t.value.trim().length>0&&(a.width=t.value),n.value.trim().length>0&&(a.height=n.value),i.value.trim().length>0&&(a.alt=i.value),null!==o&&this.Utilities.addClasses(o.value,a),"none"!==r.value&&(a.style.float=r.value),Number.isFinite(parseFloat(s.value))&&0!==parseFloat(s.value)&&CSS.supports("margin",s.value)&&(a.style.margin=s.value),l.deleteContents(),l.insertNode(a),this.Utilities.reselectNode(a)}this.imageSelection=l.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-image-modal",this.savedSelection)}}class u{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertLink()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openLinkDialog=e=>{if(null!==e){if(this.savedSelection=this.Utilities.saveSelection(e),this.resetLinkDialog(),null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content&&this.content.contains(e.anchorNode.parentNode)&&"A"===e.anchorNode.parentNode.nodeName){this.shadowRoot.getElementById("rich-text-box-linktext").value=e.anchorNode.parentNode.textContent;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=e.anchorNode.parentNode.getAttribute("href");const t=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=t){const n=e.anchorNode.parentNode.classList;t.value=Array.from(n).join(" ")}if("_blank"===e.anchorNode.parentNode.getAttribute("target")){this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!0}this.linkNode=e.anchorNode.parentNode}else{const t=this.shadowRoot.getElementById("rich-text-box-linktext");e.toString().length>0&&(this.linkSelection=e.getRangeAt(0).cloneRange(),t.value=this.linkSelection.toString())}this.shadowRoot.getElementById("rich-text-box-link-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-link-webaddress");t&&t.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 e=this.shadowRoot.getElementById("rich-text-box-link-css-classes");null!=e&&(e.value=null)};insertLink=()=>{const e=this.shadowRoot.getElementById("rich-text-box-linktext"),t=this.shadowRoot.getElementById("rich-text-box-link-webaddress"),n=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),i=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(0!=t.value.length&&0!=e.value.length){if(null!=this.linkNode){const o=this.linkNode;o.href=t.value,o.textContent=e.value,null!==i&&this.Utilities.addClasses(i.value,o),n.checked?o.target="_blank":o.hasAttribute("target")&&o.removeAttribute("target"),this.Utilities.reselectNode(o)}else if(null!=this.linkSelection){const o=this.linkSelection,r=document.createElement("a");r.href=t.value,r.textContent=e.value,null!==i&&this.Utilities.addClasses(i.value,r),n.checked&&(r.target="_blank"),o.deleteContents(),o.insertNode(r),o.setStartBefore(r.firstChild),o.setEndAfter(r.lastChild),this.savedSelection=o}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-link-modal",this.savedSelection)};removeLink=()=>{const e=this.Utilities.getSelection();if(null!==e){const t=this.Utilities.saveSelection(e);if(null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&this.content.contains(e.anchorNode.parentNode)&&"A"===e.anchorNode.parentNode.nodeName){const t=e.anchorNode.parentNode,n=document.createDocumentFragment();for(;t.firstChild;)n.appendChild(t.firstChild);t.parentNode.insertBefore(n,t),t.parentNode.removeChild(t)}this.Utilities.restoreSelection(e,t)}}}class g{constructor(e,t,n,i,o){this.shadowRoot=e,this.content=t,this.id=n,this.NodeManager=i,this.Utilities=o,this.init()}init=()=>{this.colorPickerDialog=this.shadowRoot.getElementById(this.id),this.colorPickerDialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertColor()),"Escape"===e.key&&(e.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 e=>{e.addEventListener("input",()=>this.updateColor())};addValueEventListener=async e=>{e.addEventListener("input",e=>{let t=Array.from(e.target.classList).find(e=>e.includes("value"));this.colorPicker.querySelector(`.${t.replace("value","slider")}`).value=e.target.value,this.updateColor()}),e.addEventListener("focus",e=>{e.target.select()})};addHexEventListener=async e=>{e.addEventListener("keyup",e=>{/^#?[0-9A-Fa-f]{6}$/.test(e.target.value)&&this.updateFromHex()}),e.addEventListener("change",()=>this.updateFromHex()),e.addEventListener("paste",()=>setTimeout(this.updateFromHex,0)),e.addEventListener("focus",t=>{e.select()})};openColorPicker=(e,t)=>{if(this.resetColorDialog(),this.savedSelection=this.Utilities.saveSelection(e),null!==e&&null!=e.anchorNode&&e.anchorNode!=t&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=t&&t.contains(e.anchorNode.parentNode)&&null!=e.anchorNode.parentNode.style){switch(this.selection=e.getRangeAt(0).cloneRange(),this.id){case"rich-text-box-text-color-modal":e.anchorNode.parentNode.style.color.toString().length>0&&(this.hexInput.value=this.colorToHex(e.anchorNode.parentNode.style.color));break;case"rich-text-box-text-bg-color-modal":e.anchorNode.parentNode.style.backgroundColor.toString().length>0&&(this.hexInput.value=this.colorToHex(e.anchorNode.parentNode.style.backgroundColor))}this.updateFromHex(),this.selection=e.getRangeAt(0).cloneRange()}else null!==e&&e.rangeCount>0&&(this.selection=e.getRangeAt(0).cloneRange());return this.colorPickerDialog.show(),requestAnimationFrame(()=>this.redSlider?.focus({preventScroll:!0})),this.selection};insertColor=()=>{let e;switch(this.currentColor=this.getCurrentColor(),this.id){case"rich-text-box-text-color-modal":e="textcolor";break;case"rich-text-box-text-bg-color-modal":e="textbgcolor"}null!==this.selection&&(this.savedSelection=this.Utilities.saveSelection(this.selection),null===this.currentColor?this.NodeManager.updateNode(e,"None",this.selection):this.NodeManager.updateNode(e,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=e=>{this.hexInput.value=e,this.updateFromHex()};updateColor=()=>{let e=parseInt(this.redSlider.value),t=parseInt(this.greenSlider.value),n=parseInt(this.blueSlider.value),i=`rgb(${e}, ${t}, ${n})`;this.currentColor=i,this.colorDisplay.style.backgroundColor=i,this.redValue.value=e,this.greenValue.value=t,this.blueValue.value=n,this.hexInput.value=this.rgbToHex(e,t,n)};getCurrentColor=()=>this.currentColor;updateFromHex=()=>{let e=this.hexInput.value.trim();if("#"!==e.charAt(0)&&(e="#"+e),/^#[0-9A-Fa-f]{6}$/.test(e)){let t=this.hexToRgb(e);t&&(this.redSlider.value=this.redValue.value=t.r,this.greenSlider.value=this.greenValue.value=t.g,this.blueSlider.value=this.blueValue.value=t.b)}this.updateColor()};rgbToHex=(e,t,n)=>"#"+((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1);hexToRgb=e=>{const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null};colorToHex=e=>{const t=document.createElement("canvas").getContext("2d");return t.fillStyle=e,t.fillStyle}}window.RTNative_Instances={},window.RTNative_Initialize=(t,n,i,o,r,s)=>{try{null==RTNative_Instances[t]&&(RTNative_Instances[t]=new e(t,n,i,o,s),RTNative_Instances[t].loadHtml(r))}catch(e){console.log(e)}},window.RTNative_Method=(e,t,n)=>{try{const i=RTNative_Instances[t];if(null!=i&&"function"==typeof i[e])return null!=n?i[e](n):i[e]()}catch(e){console.log(e)}};const p={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",InlineCode:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z",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",Add:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z",ArrowUp:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z",ArrowDown:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z",ArrowLeft:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z",ArrowRight:"M400-240l-56-56 184-184-184-184 56-56 240 240-240 240Z",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",Search:"M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z",Help:"M513.5-254.5Q528-269 528-290t-14.5-35.5Q499-340 478-340t-35.5 14.5Q428-311 428-290t14.5 35.5Q457-240 478-240t35.5-14.5ZM442-394h74q0-33 7.5-52t42.5-52q26-26 41-49.5t15-56.5q0-56-41-86t-97-30q-57 0-92.5 30T342-618l66 26q5-18 22.5-39t53.5-21q32 0 48 17.5t16 38.5q0 20-12 37.5T506-526q-44 39-54 59t-10 73Zm38 314q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"};class m extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=m._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText="",this._customButtons=[]}static _defaultVisibility(e=!0){return{font:e,size:e,format:e,insert:e,textStylesDivider:e,bold:e,italic:e,underline:e,strikethrough:e,subscript:e,superscript:e,inlineCode:e,formatDivider:e,textColor:e,textColorDivider:e,alignLeft:e,alignCenter:e,alignRight:e,alignJustify:e,alignDivider:e,copy:e,cut:e,paste:e,delete:e,selectAll:e,actionDivider:e,orderedList:e,unorderedList:e,indent:e,listDivider:e,link:e,image:e,imageUpload:e,quote:e,codeBlock:e,embedMedia:e,video:e,table:e,horizontalRule:e,mediaDivider:e,undo:e,redo:e,historyDivider:e,fileMenu:e,saveHtml:e,htmlView:e,preview:e,fullscreen:e,statusBarToggle:e,search:e,help:e,viewUtilDivider:e,wordCount:!1}}static _injectGlobalStyles(){if(document.getElementById("_rtb-global-styles"))return;const e=document.createElement("style");e.id="_rtb-global-styles",e.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: \"Segoe UI\", Arial, Helvetica, 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: hidden;\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.rtb-host-fullscreen {\n border: 0 !important;\n box-sizing: border-box !important;\n display: block !important;\n height: 100vh !important;\n inset: 0 !important;\n margin: 0 !important;\n max-height: 100vh !important;\n max-width: 100vw !important;\n padding: 0 !important;\n position: fixed !important;\n width: 100vw !important;\n z-index: 2147483647 !important;\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(e)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(e,t,n){if(t!==n){if("value"===e&&this._initialized&&(this._value=n||"",RTNative_Method("loadView",this._uid,n)),"width"===e&&this.style.setProperty("--rtb-editor-width",n||"100%"),"height"===e&&this.style.setProperty("--rtb-editor-height",n||"300px"),"config"===e)try{this.configure(JSON.parse(n))}catch(e){}if("placeholder"===e){const e=RTNative_Instances?.[this._uid];e?.content&&(n?e.content.setAttribute("data-placeholder",n):e.content.removeAttribute("data-placeholder"))}if("readonly"===e){const e=RTNative_Instances?.[this._uid];e&&e.setReadOnly(null!==n)}if("aria-label"===e||"label"===e){const e=RTNative_Instances?.[this._uid];e?.content&&n&&e.content.setAttribute("aria-label",n)}}}connectedCallback(){m._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(e){e?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(e){const t=(e||"").trim().replace(/>\s+</g,"><");this._value=t,this._initialized&&RTNative_Method("loadView",this._uid,t)}setPreviewCssFiles(...e){this._previewCssUrls=e.filter(e=>e&&"string"==typeof e),this._syncToInstance(),this._applyContentStyles()}setPreviewCssFile(e){this.setPreviewCssFiles(...e?[e]:[])}setPreviewCss(e){this._previewCssText=e||"",this._syncToInstance(),this._applyContentStyles()}addCustomButton(e){e&&e.id&&(this._customButtons=[...this._customButtons.filter(t=>t.id!==e.id),e],this._refreshToolbar())}setCustomButtons(e=[]){this._customButtons=Array.isArray(e)?e.filter(e=>e&&e.id):[],this._refreshToolbar()}removeCustomButton(e){this._customButtons=this._customButtons.filter(t=>t.id!==e),this._refreshToolbar()}clearCustomButtons(){this._customButtons=[],this._refreshToolbar()}_syncToInstance(){if(!this._initialized)return;const e=RTNative_Instances[this._uid];e&&(e._previewCssUrls=this._previewCssUrls,e._previewCssText=this._previewCssText)}_scopeCssText(e,t){e=e.replace(/\/\*[\s\S]*?\*\//g,"");let n="",i=0;for(;i<e.length;){for(;i<e.length&&/\s/.test(e[i]);)i++;if(i>=e.length)break;const o=e.indexOf("{",i);if(-1===o)break;const r=e.slice(i,o).trim();let s=1,l=o+1;for(;l<e.length&&s>0;)"{"===e[l]?s++:"}"===e[l]&&s--,l++;const a=e.slice(o+1,l-1);if(i=l,r)if(r.startsWith("@")){const e=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(e)?n+=r+" {\n"+this._scopeCssText(a,t)+"}\n":n+=r+" {"+a+"}\n"}else{n+=r.split(",").map(e=>e.trim()).filter(e=>e).map(e=>":root"===e?t:t+" "+e).join(",\n")+" {"+a+"}\n"}}return n}async _applyContentStyles(){if(!this._initialized)return;const e=RTNative_Instances[this._uid];if(!e||!e.shadowRoot)return;const t=e.shadowRoot.getElementById("_rtb-content-preview-styles");t&&t.remove();const n=".rich-text-box-content";let i="";for(const e of this._previewCssUrls)try{const t=await fetch(e);t.ok?i+=this._scopeCssText(await t.text(),n)+"\n":console.warn(`rt-native: failed to load preview CSS (${t.status}): ${e}`)}catch(t){console.warn(`rt-native: could not load preview CSS: ${e}`,t)}if(this._previewCssText&&(i+=this._scopeCssText(this._previewCssText,n)+"\n"),i.trim()){const t=document.createElement("style");t.id="_rtb-content-preview-styles",t.textContent=i,e.shadowRoot.appendChild(t)}}configure(e={}){const{visibility:t,customButtons:n,...i}=e;if(t){if(t.clearAll&&(this._visibility=m._defaultVisibility(!1)),!0===t.fileMenu&&!1===this._visibility.fileMenu){const e=m._defaultVisibility(!0);Object.prototype.hasOwnProperty.call(t,"search")||(this._visibility.search=e.search),Object.prototype.hasOwnProperty.call(t,"saveHtml")||(this._visibility.saveHtml=e.saveHtml),Object.prototype.hasOwnProperty.call(t,"help")||(this._visibility.help=e.help)}Object.assign(this._visibility,t)}n&&(this._customButtons=Array.isArray(n)?n.filter(e=>e&&e.id):[]),this._applyCSSVars(i),this._syncPreviewTheme(),this._initialized&&(t||n)&&this._reinitialize()}_syncPreviewTheme(){}_applyCSSVars(e){const set=(e,t)=>{null!=t&&this.style.setProperty(e,t)},t=e.toolbar||{};set("--rtb-toolbar-bg",t.backgroundColor),set("--rtb-toolbar-border-style",t.borderStyle),set("--rtb-toolbar-border-width",t.borderWidth),set("--rtb-toolbar-border-color",t.borderColor),set("--rtb-toolbar-border-radius",t.borderRadius),set("--rtb-dropdown-bg",t.dropdownBackgroundColor),set("--rtb-dropdown-text",t.dropdownTextColor),set("--rtb-dropdown-bg-hover",t.dropdownBackgroundColorHover),set("--rtb-dropdown-text-hover",t.dropdownTextColorHover);const n=e.button||{};set("--rtb-btn-text",n.textColor),set("--rtb-btn-size",n.textSize),set("--rtb-btn-font",n.textFont),set("--rtb-btn-bg",n.backgroundColor),set("--rtb-btn-bg-hover",n.backgroundColorHover),set("--rtb-btn-bg-selected",n.backgroundColorSelected),set("--rtb-btn-border-style",n.borderStyle),set("--rtb-btn-border-width",n.borderWidth),set("--rtb-btn-border-color",n.borderColor),set("--rtb-btn-border-hover",n.borderColorHover),set("--rtb-btn-border-selected",n.borderColorSelected),set("--rtb-btn-border-radius",n.borderRadius);const i=e.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 o=e.editor||{};set("--rtb-editor-width",o.width),set("--rtb-editor-height",o.height),set("--rtb-editor-border-radius",o.borderRadius),set("--rtb-editor-border-style",o.borderStyle),set("--rtb-editor-border-width",o.borderWidth),set("--rtb-editor-border-color",o.borderColor),set("--rtb-editor-shadow",o.boxShadow),null!=o.removeResizeHandle&&set("--rtb-editor-resize",o.removeResizeHandle?"visible":"hidden");const r=e.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=e.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=e.quote||{};set("--rtb-quote-bg",l.backgroundColor),set("--rtb-quote-border-color",l.borderColor),set("--rtb-quote-border-width",l.borderWidth);const a=e.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 t=this.getAttribute("value")||"",n=null!==this._value?this._value:t;this._value=n;const onValueChange=e=>{this._value=e,this.dispatchEvent(new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0}))};window.RTNative_Instances||(window.RTNative_Instances={}),RTNative_Instances[this._uid]=new e(this._uid,`${this._uid}_Shadow`,`${this._uid}_Toolbar`,'\n.rich-text-box-tool-bar {\n position: relative;\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 padding-bottom: 1px;\n display: flex;\n flex-wrap: nowrap;\n justify-content: flex-start;\n}\n.rich-text-box-tool-bar > .rich-text-box-dropdown {\n flex-shrink: 0;\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.rtb-toolbar-items {\n display: flex;\n flex-wrap: nowrap;\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n}\n.rtb-toolbar-items > * {\n flex-shrink: 0;\n}\n.rtb-overflow-wrapper {\n position: static;\n flex-shrink: 0;\n margin-right: 3px;\n}\n.rtb-overflow-btn svg {\n display: block;\n}\n.rtb-overflow-dropdown {\n position: absolute;\n top: 100%;\n margin-top: 1px;\n right: 0;\n left: auto;\n display: none;\n z-index: 9001;\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n border-radius: 4px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n padding: 4px;\n flex-wrap: wrap;\n align-items: center;\n max-height: 300px;\n overflow-y: auto;\n width: max-content;\n}\n.rtb-overflow-dropdown.rtb-overflow-open {\n display: flex;\n}\n.rtb-overflow-dropdown button {\n background-color: transparent;\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-dropdown-text, #000);\n outline: none;\n cursor: pointer;\n transition: none;\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.rtb-overflow-dropdown button:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e8e8e8);\n color: var(--rtb-dropdown-text-hover, #000);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rtb-overflow-dropdown button:focus-visible,\n.rtb-overflow-dropdown button.active {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-dropdown-bg-hover, #e8e8e8));\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #242424));\n outline: 2px solid var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n outline-offset: -2px;\n}\n.rtb-overflow-dropdown button.selected {\n background-color: var(--rtb-btn-bg-selected, #dcdcdc);\n border-color: var(--rtb-btn-border-selected, inherit);\n}\n.rtb-overflow-dropdown button:disabled {\n background-color: transparent;\n color: #999;\n cursor: default;\n}\n.rtb-overflow-dropdown button svg {\n fill: var(--rtb-btn-text, #000);\n width: var(--rtb-btn-size, 16px);\n height: var(--rtb-btn-size, 16px);\n display: block;\n}\n.rtb-overflow-dropdown button:hover svg {\n fill: var(--rtb-btn-text, #000);\n}\n.rtb-overflow-dropdown 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, hidden);\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-container.rtb-editor-fullscreen {\n border-radius: 0 !important;\n box-sizing: border-box !important;\n height: 100vh !important;\n inset: 0 !important;\n max-height: 100vh !important;\n max-width: 100vw !important;\n position: fixed !important;\n resize: none !important;\n width: 100vw !important;\n z-index: 2147483647 !important;\n}\n.rich-text-box-content-container {\n position: relative;\n width: 100%;\n height: 100%;\n overflow: auto;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n}\n.rtb-drop-overlay {\n position: absolute;\n inset: 10px;\n z-index: 20;\n display: none;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n background: color-mix(in srgb, var(--rtb-content-bg, #ffffff) 82%, transparent);\n border: 1px solid color-mix(in srgb, var(--rtb-btn-bg-selected, #8a8a8a) 65%, transparent);\n border-radius: 8px;\n box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);\n backdrop-filter: blur(2px);\n}\n.rtb-drop-overlay-visible {\n display: flex;\n}\n.rtb-drop-zone {\n min-width: 240px;\n max-width: min(420px, 80%);\n padding: 24px 28px;\n text-align: center;\n color: var(--rtb-content-text, #242424);\n background: var(--rtb-content-bg, #ffffff);\n border: 2px dashed var(--rtb-toolbar-border-color, #b8b8b8);\n border-radius: 8px;\n font-family: var(--rtb-content-font, Arial, sans-serif);\n}\n.rtb-drop-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 58px;\n height: 34px;\n margin-bottom: 12px;\n border-radius: 6px;\n background: var(--rtb-btn-bg-selected, #dcdcdc);\n color: var(--rtb-btn-text, #242424);\n font-size: 13px;\n font-weight: 700;\n letter-spacing: 0;\n}\n.rtb-drop-title {\n font-size: 18px;\n font-weight: 600;\n margin-bottom: 4px;\n}\n.rtb-drop-subtitle {\n font-size: 13px;\n color: color-mix(in srgb, var(--rtb-content-text, #242424) 70%, transparent);\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 display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n user-select: none;\n flex-shrink: 0;\n letter-spacing: 0.2px;\n}\n.rtb-status-link {\n min-width: 0;\n overflow: hidden;\n opacity: 0;\n text-align: left;\n text-overflow: ellipsis;\n transition: opacity 100ms ease-in-out;\n white-space: nowrap;\n}\n.rtb-status-link-visible { opacity: 1; }\n.rtb-status-count {\n flex-shrink: 0;\n margin-left: auto;\n text-align: right;\n}\n.rtb-find-bar {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n width: 100%;\n background-color: var(--rtb-toolbar-bg, #fff);\n border-bottom: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n padding: 4px 8px;\n box-sizing: border-box;\n}\n.rtb-find-input {\n border: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n border-radius: 4px;\n padding: 3px 7px;\n font-size: calc(var(--rtb-btn-size, 16px) * 0.875);\n color: var(--rtb-btn-text, #242424);\n background-color: var(--rtb-content-bg, #fff);\n outline: none;\n width: 180px;\n}\n.rtb-find-input:focus {\n border-color: var(--rtb-btn-bg-selected, #a0a0a0);\n}\n.rtb-find-count {\n font-size: calc(var(--rtb-btn-size, 16px) * 0.8);\n color: var(--rtb-btn-text, #666);\n min-width: 54px;\n text-align: center;\n white-space: nowrap;\n user-select: none;\n}\n.rtb-find-nav-btn, .rtb-find-close-btn {\n background: none;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n padding: 2px 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--rtb-btn-text, #242424);\n}\n.rtb-find-nav-btn svg, .rtb-find-close-btn svg {\n width: 18px;\n height: 18px;\n fill: currentColor;\n}\n.rtb-find-nav-btn:hover, .rtb-find-close-btn:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n}\n.rtb-context-menu {\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid rgba(0,0,0,0.12);\n border-radius: 4px;\n box-shadow: 0 8px 16px rgba(0,0,0,0.14), 0 0 2px rgba(0,0,0,0.12);\n box-sizing: border-box;\n display: none;\n min-width: 168px;\n padding: 4px;\n position: fixed;\n z-index: 9000;\n}\n.rtb-context-menu button {\n align-items: center;\n appearance: none;\n background: transparent;\n border: 0;\n border-radius: 4px;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #242424);\n cursor: pointer;\n display: flex;\n font-family: var(--rtb-btn-font, Arial, Helvetica, sans-serif);\n font-size: 14px;\n gap: 10px;\n justify-content: flex-start;\n line-height: 20px;\n min-height: 32px;\n padding: 6px 8px;\n text-align: left;\n width: 100%;\n}\n.rtb-context-menu button:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rtb-context-menu svg {\n fill: currentColor;\n flex: 0 0 auto;\n height: 18px;\n width: 18px;\n}\n.rtb-context-menu-divider {\n border-top: 1px solid rgba(128,128,128,0.18);\n margin: 4px 0;\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 padding-bottom: 10px;\n width: 100%;\n max-width: var(--rtb-page-width, 860px);\n margin-left: auto;\n margin-right: auto;\n min-height: 100%;\n box-sizing: border-box;\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}\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 cursor: pointer;\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 padding: 0;\n cursor: pointer;\n box-sizing: content-box;\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-content table { cursor: var(--rtb-table-cell-cursor, pointer); }\n.rtb-image-resize-overlay,\n.rtb-table-resize-overlay {\n border: 1px solid var(--rtb-btn-border-selected, #605e5c);\n box-sizing: border-box;\n pointer-events: none;\n position: absolute;\n transition: left 0.0375s ease, top 0.0375s ease;\n z-index: 15;\n}\n.rtb-image-resize-overlay {\n display: none;\n}\n.rtb-table-resize-overlay {\n opacity: 0;\n visibility: hidden;\n transition: left 0.0375s ease, top 0.0375s ease, opacity 0.12s ease;\n}\n.rtb-image-resize-overlay.rtb-image-resize-visible {\n display: block;\n}\n.rtb-table-resize-overlay.rtb-table-resize-visible {\n opacity: 1;\n visibility: visible;\n}\n.rtb-image-resize-handle,\n.rtb-table-resize-handle {\n background: linear-gradient(135deg, #479ef5, #0f6cbd);\n border: 2px solid var(--rtb-content-bg, #fff);\n border-radius: 3px;\n box-sizing: border-box;\n box-shadow: 0 0 0 1px #0f6cbd, 0 2px 5px rgba(0, 0, 0, 0.3);\n height: 13px;\n pointer-events: auto;\n position: absolute;\n touch-action: none;\n transition: filter 0.12s ease, box-shadow 0.12s ease;\n width: 13px;\n}\n.rtb-image-resize-handle:hover,\n.rtb-table-resize-handle:hover {\n box-shadow: 0 0 0 2px #0f6cbd, 0 2px 6px rgba(0, 0, 0, 0.38);\n filter: brightness(1.08);\n}\n:host(.dark) .rtb-image-resize-handle,\n:host(.dark) .rtb-table-resize-handle,\n:host(.fluent-dark) .rtb-image-resize-handle,\n:host(.fluent-dark) .rtb-table-resize-handle {\n background: linear-gradient(135deg, #62abf5, #2886de);\n box-shadow: 0 0 0 1px #62abf5, 0 2px 6px rgba(0, 0, 0, 0.65);\n}\n.rtb-image-resize-nw {\n cursor: nwse-resize;\n left: 0;\n top: 0;\n transform: translate(-50%, -50%);\n}\n.rtb-image-resize-n {\n cursor: ns-resize;\n left: 50%;\n top: 0;\n transform: translate(-50%, -50%);\n}\n.rtb-image-resize-ne {\n cursor: nesw-resize;\n right: 0;\n top: 0;\n transform: translate(50%, -50%);\n}\n.rtb-image-resize-e {\n cursor: ew-resize;\n right: 0;\n top: 50%;\n transform: translate(50%, -50%);\n}\n.rtb-image-resize-se {\n bottom: 0;\n cursor: nwse-resize;\n right: 0;\n transform: translate(50%, 50%);\n}\n.rtb-image-resize-s {\n bottom: 0;\n cursor: ns-resize;\n left: 50%;\n transform: translate(-50%, 50%);\n}\n.rtb-image-resize-sw {\n bottom: 0;\n cursor: nesw-resize;\n left: 0;\n transform: translate(-50%, 50%);\n}\n.rtb-image-resize-w {\n cursor: ew-resize;\n left: 0;\n top: 50%;\n transform: translate(-50%, -50%);\n}\n.rtb-image-resizing,\n.rtb-image-resizing .rtb-image-resize-handle,\n.rtb-table-resizing,\n.rtb-table-resizing .rtb-table-resize-handle {\n user-select: none;\n}\n.rich-text-box-source {\n padding: 10px max(10px, calc(50% - var(--rtb-page-width, 860px) / 2 + 10px));\n width: 100%;\n height: 100%;\n box-sizing: border-box;\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 letter-spacing: 0.04em;\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: static; display: flex; align-items: stretch; margin: 4px 1px; }\n.rich-text-box-dropdown > .rich-text-box-dropdown-btn { margin: 0; }\n.rich-text-box-dropdown-content {\n display: none;\n position: absolute;\n top: 100%;\n margin-top: 1px;\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-file-button,\n.rich-text-box-font-button,\n.rich-text-box-size-button,\n.rich-text-box-format-button,\n.rich-text-box-insert-button {\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif);\n font-size: 0.82rem;\n font-weight: 600;\n letter-spacing: 0;\n}\n.rich-text-box-file-content {\n min-width: 220px;\n max-width: 320px;\n padding: 4px;\n box-sizing: border-box;\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid var(--rtb-toolbar-border-color, #e0e0e0);\n border-radius: 8px;\n box-shadow: var(--rtb-file-menu-shadow, 0 8px 16px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12));\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif) !important;\n letter-spacing: 0.04em;\n line-height: 1.45;\n}\n.rich-text-box-format-content { min-width: 185px; }\n.rich-text-box-insert-content {\n width: 230px;\n max-height: 200px;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 8px;\n scroll-behavior: auto;\n box-sizing: border-box;\n}\n.rich-text-box-insert-group {\n color: var(--rtb-dropdown-text, #000);\n font-size: 12px;\n font-weight: 600;\n padding: 10px 8px 4px;\n opacity: 0.72;\n}\n.rich-text-box-insert-item {\n align-items: center;\n background: transparent;\n border: 0;\n border-radius: 4px;\n color: var(--rtb-dropdown-text, #000);\n cursor: pointer;\n display: grid;\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif);\n grid-template-columns: 34px 1fr;\n min-height: 34px;\n padding: 4px 8px;\n text-align: left;\n transition: none;\n width: 100%;\n}\n.rich-text-box-tool-bar .rich-text-box-insert-item,\n.rich-text-box-tool-bar .rich-text-box-insert-item * {\n transition: none;\n}\n.rich-text-box-insert-item:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rich-text-box-insert-item:focus-visible,\n.rich-text-box-insert-item.active,\n.rich-text-box-dropdown-content a:focus-visible {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-dropdown-bg-hover, #e5e5e5));\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #242424));\n outline: 2px solid var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n outline-offset: -2px;\n}\n.rich-text-box-insert-symbol {\n font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;\n font-size: 20px;\n line-height: 1;\n}\n.rich-text-box-insert-meaning {\n font-size: 14px;\n line-height: 18px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\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.rich-text-box-file-content a {\n align-items: center;\n border-radius: 4px;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #242424);\n display: flex;\n font-size: 0.88rem;\n gap: 24px;\n justify-content: space-between;\n line-height: inherit;\n min-height: 32px;\n padding: 6px 8px;\n text-decoration: none;\n}\n.rich-text-box-file-content a:hover {\n background-color: var(--rtb-dropdown-bg-hover, #f5f5f5);\n color: var(--rtb-dropdown-text-hover, #242424);\n}\n.rich-text-box-file-content a:active {\n background-color: var(--rtb-btn-bg-selected, #ebebeb);\n}\n.rich-text-box-menu-shortcut {\n color: var(--rtb-dropdown-text, #707070);\n font-size: 12px;\n font-weight: 400;\n line-height: inherit;\n margin-left: 6px;\n opacity: 0.6;\n}\n.rich-text-box-dropdown-divider {\n height: 0;\n margin: 2px 0;\n border: 0;\n border-top: 1px solid var(--rtb-file-menu-divider, var(--rtb-toolbar-border-color, #e0e0e0));\n}\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 letter-spacing: 0.03em;\n position: fixed;\n inset: 0;\n margin: auto;\n padding: 6px 16px 14px;\n border: 1px solid #888;\n width: 800px;\n max-width: calc(100vw - 20px);\n max-height: 90vh;\n overflow: hidden;\n box-sizing: border-box;\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[open] {\n display: flex;\n flex-direction: column;\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.rtb-modal-scroll-area {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n overflow-x: hidden;\n scrollbar-color: var(--rtb-scroll-thumb-bg, #AAA) var(--rtb-scroll-bg, transparent);\n scrollbar-width: thin;\n}\n.rtb-modal-body {\n overflow: visible;\n}\n.rtb-modal-scroll-area::-webkit-scrollbar {\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-modal-scroll-area::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rtb-modal-scroll-area::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-modal-scroll-area::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n.rtb-modal-footer {\n flex-shrink: 0;\n padding: 5px 5px 0 0;\n}\n.rich-text-box-form-left { float: left; width: calc(50% - 15px); }\n.rich-text-box-form-right { float: right; width: calc(50% - 15px); }\n@media screen and (max-width: 850px) {\n .rich-text-box-form-left,\n .rich-text-box-form-right { float: none; width: 100%; }\n .rich-text-box-modal { width: 430px; }\n}\n@media screen and (max-width: 500px) {\n .rich-text-box-modal { width: 100%; }\n}\n.clearfix { overflow: hidden; }\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 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@media screen and (max-width: 850px) {\n .rtb-preview-dialog {\n width: 95vw;\n }\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.rtb-help-dialog {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n width: min(95vw, 750px);\n padding: 0;\n box-sizing: border-box;\n max-height: 88vh;\n overflow: hidden;\n}\n.rtb-help-body {\n overflow-x: hidden;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-color: var(--rtb-scroll-thumb-bg, #AAA) var(--rtb-scroll-bg, transparent);\n scrollbar-width: thin;\n}\n.rtb-help-body::-webkit-scrollbar {\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-help-body::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rtb-help-body::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-help-body::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n.rtb-help-dialog[open] { display: flex; flex-direction: column; }\n.rtb-help-dialog::backdrop { background: transparent; }\n.rtb-help-sticky-header {\n z-index: 10;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n background: var(--rtb-modal-bg, #fefefe);\n padding: 10px 20px 11px;\n border-radius: 5px 5px 0 0;\n flex-shrink: 0;\n}\n.rtb-help-sticky-header .rich-text-box-modal-title {\n font-weight: bold;\n font-size: calc(var(--rtb-modal-text-size, 16px) + 2px);\n}\n.rtb-help-columns {\n display: flex;\n align-items: flex-start;\n padding: 14px 20px 22px;\n}\n.rtb-help-col {\n flex: 1;\n min-width: 0;\n}\n.rtb-help-col:first-child {\n padding-right: 30px;\n border-right: 1px solid rgba(128,128,128,0.16);\n}\n.rtb-help-col:last-child {\n padding-left: 30px;\n}\n@media (max-width: 850px) {\n .rtb-help-dialog { width: 430px; }\n .rtb-help-columns { flex-direction: column; align-items: stretch; padding: 10px 16px 18px; }\n .rtb-help-col:first-child { padding-right: 0; border-right: none; }\n .rtb-help-col:last-child { padding-left: 0; margin-top: 18px; }\n .rtb-help-col { width: 100%; }\n}\n.rtb-help-table {\n width: 100%;\n border-collapse: collapse;\n border: none;\n font-size: 0.84rem;\n}\n.rtb-help-table td {\n padding: 4px 8px;\n border: none;\n border-bottom: 1px solid rgba(128,128,128,0.07);\n vertical-align: middle;\n}\n.rtb-help-table td:first-child { padding-left: 2px; }\n.rtb-help-table td:last-child { padding-right: 2px; white-space: nowrap; text-align: right; }\n.rtb-help-table tr:not(.rtb-help-section):hover > td {\n background: rgba(128,128,128,0.06);\n}\n.rtb-help-section > td {\n text-align: left !important;\n font-weight: 700;\n font-size: 0.68rem;\n letter-spacing: 0.09em;\n text-transform: uppercase;\n opacity: 0.55;\n padding: 16px 2px 5px;\n border-top: none;\n border-bottom: 1px solid rgba(128,128,128,0.22);\n}\n.rtb-help-table > tbody > tr.rtb-help-section:first-child > td { padding-top: 4px; }\n.rtb-help-table kbd {\n font-family: "Consolas", "SF Mono", "Menlo", monospace;\n font-size: 0.74rem;\n background: rgba(128,128,128,0.11);\n border: 1px solid rgba(128,128,128,0.28);\n border-bottom-width: 2px;\n border-radius: 4px;\n padding: 1px 6px;\n white-space: nowrap;\n display: inline-block;\n line-height: 1.5;\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 letter-spacing: 0.03em;\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-float-dropdown {\n appearance: none;\n background-color: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n border-color: var(--rtb-toolbar-border-color, var(--rtb-modal-input-border, #CCC));\n border-radius: 5px;\n color: var(--rtb-dropdown-text, var(--rtb-modal-input-text, #000));\n cursor: pointer;\n transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;\n}\n.rich-text-box-float-dropdown:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #000));\n}\n.rich-text-box-float-dropdown:focus {\n background-color: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n border-color: var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c)) 25%, transparent);\n}\n.rich-text-box-float-dropdown:active {\n background-color: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n}\n.rich-text-box-float-dropdown option {\n background-color: var(--rtb-dropdown-bg, #fff);\n color: var(--rtb-dropdown-text, #000);\n}\n:host(.dark) .rich-text-box-form-element,\n:host(.fluent-dark) .rich-text-box-form-element {\n color-scheme: dark;\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 cursor: pointer;\n}\n.rich-text-box-form-checkbox-label,\nlabel:has(.rich-text-box-form-checkbox) {\n cursor: pointer;\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 letter-spacing: 0.05em;\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 4px 6px;\n}\n.rich-text-box-upload-btn:hover,\n.rich-text-box-upload-btn:focus-visible {\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 letter-spacing: 0.05em;\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 {\n box-sizing: border-box;\n width: calc(100% - 4px);\n height: 50px;\n border: 1px solid #ccc;\n margin: 20px 2px;\n}\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-form-element[type="number"] {\n color-scheme: light;\n}\n:host(.dark) .rich-text-box-form-element[type="number"],\n:host(.fluent-dark) .rich-text-box-form-element[type="number"] {\n color-scheme: dark;\n}\n.rich-text-box-form-element[type="number"]::-webkit-inner-spin-button,\n.rich-text-box-form-element[type="number"]::-webkit-outer-spin-button {\n opacity: 1;\n cursor: pointer;\n accent-color: var(--rtb-scroll-thumb-bg, #AAA);\n background-color: var(--rtb-scroll-bg, transparent);\n border-left: 1px solid var(--rtb-modal-input-border, #CCC);\n}\n.rich-text-box-form-element[type="number"]:hover::-webkit-inner-spin-button,\n.rich-text-box-form-element[type="number"]:hover::-webkit-outer-spin-button {\n accent-color: var(--rtb-scroll-thumb-bg-hover, #DDD);\n background-color: var(--rtb-scroll-thumb-bg, #AAA);\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@keyframes rtb-modal-zoom-in {\n from { opacity: 0; transform: scale(0.93); }\n to { opacity: 1; transform: scale(1); }\n}\n@keyframes rtb-dialog-zoom-in {\n from { opacity: 0; transform: translate(-50%, -50%) scale(0.93); }\n to { opacity: 1; transform: translate(-50%, -50%) scale(1); }\n}\n@keyframes rtb-dropdown-in {\n from { opacity: 0; transform: translateY(-5px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes rtb-content-enter {\n from { opacity: 0.5; }\n to { opacity: 1; }\n}\n.rich-text-box-modal[open] {\n animation: rtb-modal-zoom-in 0.06s ease-out;\n}\n.rtb-preview-dialog[open] {\n animation: rtb-dialog-zoom-in 0.06s ease-out;\n}\n.rtb-help-dialog[open] {\n animation: rtb-dialog-zoom-in 0.06s ease-out;\n}\n.rich-text-box-dropdown-content.rich-text-box-show {\n animation: rtb-dropdown-in 0.06s ease-out;\n}\n\n.rich-text-box-content * {\n transition: margin 0.075s ease;\n}\n.rich-text-box-content span {\n animation: none;\n}\n\n/* Focus ring for buttons and interactive controls inside dialog windows (excludes text inputs) */\ndialog *:not(input):not(textarea):not(select):focus-visible {\n outline: 2px solid var(--rtb-modal-text, #242424) !important;\n outline-offset: 1px !important;\n}\n/* Subtle border accent for text inputs, textareas, and selects on focus — no outline ring */\ndialog input:focus-visible,\ndialog textarea:focus-visible,\ndialog select:focus-visible {\n outline: none !important;\n border-color: var(--rtb-modal-text, #242424) !important;\n}\n',{invokeMethodAsync:(e,t)=>onValueChange(t)}),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 o=this.getAttribute("placeholder");o&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",o),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid]._applyStoredStatusBarVisibility(),RTNative_Instances[this._uid].loadHtml(n),this._initialized=!0,this._syncToInstance(),this._applyContentStyles(),this._attachCustomButtonHandlers()}_reinitialize(){const e=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(),e&&this.setValue(e)})}_refreshToolbar(){this._initialized?this._reinitialize():this.isConnected&&this._render()}_svg(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="${p[e]}"/></svg>`}_btn(e,t,n,i,o){return`<button id="${e}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==o?`RTNative_Method('${i}','${this._uid}','${o}')`:`RTNative_Method('${i}','${this._uid}')`}">${this._svg(t)}</button>`}_specialBtn(e,t,n,i){return`<button id="${e}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${i}','${this._uid}')">${this._svg(t)}</button>`}_fullscreenBtn(){return`<button id="blazing-rich-text-fullscreen-button" title="Maximize Editor" aria-label="Maximize editor" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('toggleEditorFullscreen','${this._uid}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false"><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>`}_divider(){return'<button class="rich-text-box-divider-btn" disabled><div class="rich-text-box-divider"></div></button>'}_escapeAttr(e){return String(e??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_customButton(e){const t=this._escapeAttr(e.id),n=this._escapeAttr(e.title||e.label||e.id),i=e.svg||"";return`<button id="${t}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item rich-text-box-custom-button" data-rtb-custom-button="${t}"${e.disabled?" disabled":""}>${i}</button>`}_customButtonsHTML(){return this._customButtons.length?this._customButtons.map(e=>this._customButton(e)).join("\n"):""}_resolveCustomButtonHandler(e){return"function"==typeof e?e:"string"==typeof e&&e.trim()?e.split(".").reduce((e,t)=>e?.[t],window):null}_attachCustomButtonHandlers(){const e=RTNative_Instances[this._uid];e?.shadowRoot&&this._customButtons.forEach(t=>{const n=e.shadowRoot.querySelector(`[data-rtb-custom-button="${CSS.escape(t.id)}"]`);n&&n.addEventListener("click",n=>{if(t.disabled)return;const i=this._resolveCustomButtonHandler(t.onClick||t.method);"function"==typeof i&&i.call(this,n,this,e),this.dispatchEvent(new CustomEvent("custom-button-click",{detail:{id:t.id,button:t,editor:this},bubbles:!0,composed:!0}))})})}_fontDropdown(){const e=this._uid,t=["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(t=>`<a class="rich-text-box-menu-item" style="font-family:${t};cursor:pointer" onclick="RTNative_Method('font','${e}','${t}')">${t}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-font-button" title="Font (Alt+F)" class="rich-text-box-font-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','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 ${t}\n </div>\n</div>`}_sizeDropdown(){const e=this._uid,t=["None","8","9","10","11","12","14","16","18","20","22","24","26","28","36","48","64"].map(t=>`<a class="rich-text-box-menu-item" style="${"None"===t?"":`font-size:${t}px !important;`}cursor:pointer" onclick="RTNative_Method('size','${e}','${"None"===t?"None":`${t}px`}')">${"None"===t?"None":t}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-size-button" title="Size (Alt+S)" class="rich-text-box-size-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','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 ${t}\n </div>\n</div>`}_formatDropdown(){const e=this._uid;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-format-button" title="Format (Alt+T)" class="rich-text-box-format-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','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','${e}','p')">Paragraph</a>\n <a class="rich-text-box-menu-item" style="font-size:34px;cursor:pointer" onclick="RTNative_Method('format','${e}','h1')">Header 1</a>\n <a class="rich-text-box-menu-item" style="font-size:30px;cursor:pointer" onclick="RTNative_Method('format','${e}','h2')">Header 2</a>\n <a class="rich-text-box-menu-item" style="font-size:24px;cursor:pointer" onclick="RTNative_Method('format','${e}','h3')">Header 3</a>\n <a class="rich-text-box-menu-item" style="font-size:20px;cursor:pointer" onclick="RTNative_Method('format','${e}','h4')">Header 4</a>\n <a class="rich-text-box-menu-item" style="font-size:18px;cursor:pointer" onclick="RTNative_Method('format','${e}','h5')">Header 5</a>\n <a class="rich-text-box-menu-item" style="font-size:16px;cursor:pointer" onclick="RTNative_Method('format','${e}','h6')">Header 6</a>\n </div>\n</div>`}_insertDropdown(){const e=this._uid,t=[["Status & Priority",[["✅","Success"],["❌","Failed"],["✔","Confirmed"],["✖","Rejected"],["⭐","Favorite"],["🌟","Featured"],["🔴","High Priority"],["🟡","Medium Priority"],["🟢","Low Priority"],["🔵","Informational"],["🏆","Best"],["💯","Excellent"]]],["Productivity & Workflow",[["⏳","In Progress"],["⌛","Waiting"],["🔄","Updating"],["🔁","Repeat"],["🚧","Work in Progress"],["🛠","Under Construction / Build"],["📌","Pinned"],["📍","Location"],["📖","Documentation"],["📝","Notes"],["📋","Checklist"],["📎","Attachment"],["🔍","Search"],["🧠","Thinking"],["📅","Schedule"],["🚀","Launch"]]],["Social & Emphasis",[["🔥","Trending"],["✨","Exciting"],["❤️","Love"],["👍","Approval"],["👀","Attention"],["👉","Pointing"],["🎯","Goal"],["⚡","Fast"],["📢","Announcement"],["💡","Idea"]]],["Technology",[["🚀","Deploy"],["🐛","Bug"],["✨","Feature"],["⚙","Settings"],["🔧","Configuration / Tools"],["📦","Package"],["🔒","Secure"],["🔓","Public"],["🧪","Experimental"],["🗑","Delete"],["💾","Save"]]],["Warnings & Errors",[["⚠","Warning"],["🚨","Critical Alert"],["🔥","Serious Issue"],["🛑","Stop"],["❗","Important Warning"],["❓","Unknown / Question"],["⁉","Clarification Needed"]]],["Arrows & Navigation",[["→","Right Arrow"],["←","Left Arrow"],["↑","Up Arrow"],["↓","Down Arrow"],["⇒","Result"],["➜","Action Arrow"],["↳","Sub-item"],["⇢","Link"]]],["Tree & Hierarchy",[["├─","Branch Node"],["└─","Last Branch"],["│","Vertical Line"],["─","Horizontal Line"],["╰─","Rounded Last Branch"],["╭─","Rounded Top Branch"]]]].map(([t,n])=>`\n <div class="rich-text-box-insert-group">${t}</div>\n ${n.map(([t,n])=>`\n <button type="button" class="rich-text-box-insert-item" onclick="RTNative_Method('insertEmoji','${e}','${this._escapeAttr(t)}')">\n <span class="rich-text-box-insert-symbol">${t}</span>\n <span class="rich-text-box-insert-meaning">${n||t}</span>\n </button>`).join("")}`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-insert-button" title="Insert (Alt+I)" class="rich-text-box-insert-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','blazing-rich-text-insert-button-dropdown')">Insert</button>\n <div id="blazing-rich-text-insert-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-insert-content rich-text-box-scroll">\n ${t}\n </div>\n</div>`}_fileDropdown(){const e=this._uid,t=this._visibility,n=`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','open')">Open<span class="rich-text-box-menu-shortcut">Ctrl+O</span></a>`;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-file-button" title="File (Alt+L)" class="rich-text-box-file-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','blazing-rich-text-file-button-dropdown')">File</button>\n <div id="blazing-rich-text-file-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-file-content rich-text-box-scroll">\n ${t.search?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','find')">Find<span class="rich-text-box-menu-shortcut">Ctrl+F</span></a>`:""}${n}${t.saveHtml?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','save')">Download<span class="rich-text-box-menu-shortcut">Ctrl+S</span></a>`:""}${(t.search||t.saveHtml||n)&&t.statusBarToggle?'<hr class="rich-text-box-dropdown-divider">':""}${t.statusBarToggle?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','toggleStatusBar')"><span id="blazing-rich-text-file-statusbar-label">Show Status Bar</span><span class="rich-text-box-menu-shortcut">Ctrl+\\</span></a>`:""}${(t.search||t.saveHtml||t.statusBarToggle)&&t.help?'<hr class="rich-text-box-dropdown-divider">':""}${t.help?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','shortcuts')">Keyboard Shortcuts<span class="rich-text-box-menu-shortcut">Ctrl+/</span></a>`:""}\n </div>\n</div>`}_colorSwatches(e){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(t=>`<div class="blazing-rich-text-color-option" onclick="RTNative_Method('${e}','${this._uid}','${t}')" style="background-color:${t};"></div>`).join("")}_colorDialog(e,t,n,i){const o=this._uid;return`\n<dialog id="${e}" class="rich-text-box-modal" aria-modal="true" aria-labelledby="${e}-title">\n <div class="rtb-modal-header">\n <div id="${e}-title" class="rich-text-box-modal-title">${t}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${o}','${e}')"><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="rtb-modal-scroll-area rich-text-box-scroll">\n <div class="rtb-modal-body">\n <div class="rich-text-box-color-picker">\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n ${this._colorSwatches(n)}\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>\n </div>\n <div class="rtb-modal-footer" style="text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${o}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${i}','${o}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(e,t,n,i,o=""){const r=this._uid;return`\n<dialog id="${e}" class="rich-text-box-modal" aria-modal="true" aria-labelledby="${e}-title">\n <div class="rtb-modal-header">\n <div id="${e}-title" class="rich-text-box-modal-title">${t}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${r}','${e}')"><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="rtb-modal-scroll-area rich-text-box-scroll">\n <div class="rtb-modal-body">\n ${i}\n </div>\n <div class="rtb-modal-footer" style="${o?"display:flex;justify-content:space-between;align-items:center;":"text-align:right;"}">\n ${o?`<div>${o}</div>`:""}\n <div>\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${r}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${n}','${r}')">OK</button>\n </div>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const e=this._uid,t=this._visibility,n=(t.font||t.size||t.format||t.insert)&&t.textStylesDivider,i=(t.bold||t.italic||t.underline||t.strikethrough||t.subscript||t.superscript||t.inlineCode)&&t.formatDivider,o=t.textColor&&t.textColorDivider,r=(t.alignLeft||t.alignCenter||t.alignRight||t.alignJustify)&&t.alignDivider,s=(t.copy||t.cut||t.paste||t.delete||t.selectAll)&&t.actionDivider,l=(t.orderedList||t.unorderedList||t.indent)&&t.listDivider,a=(t.link||t.image||t.imageUpload||t.quote||t.codeBlock||t.embedMedia||t.video||t.table||t.horizontalRule)&&t.mediaDivider,d=(t.undo||t.redo)&&t.historyDivider,c=this._customButtons.length>0;return`\n<div id="${e}_Toolbar" class="rich-text-box-tool-bar" role="toolbar" aria-label="Formatting toolbar">\n\n ${t.fileMenu?this._fileDropdown():""}\n ${t.font?this._fontDropdown():""}\n ${t.size?this._sizeDropdown():""}\n ${t.format?this._formatDropdown():""}\n ${t.insert?this._insertDropdown():""}\n ${n?this._divider():""}\n\n ${t.bold?this._btn("blazing-rich-text-bold-button","Bold","Bold (Ctrl+B)","bold"):""}\n ${t.italic?this._btn("blazing-rich-text-italic-button","Italic","Italic (Ctrl+I)","italic"):""}\n ${t.underline?this._btn("blazing-rich-text-underline-button","Underline","Underline (Ctrl+U)","underline"):""}\n ${t.strikethrough?this._btn("blazing-rich-text-strike-button","Strikethrough","Strikethrough (Ctrl+D)","strikethrough"):""}\n ${t.subscript?this._btn("blazing-rich-text-sub-button","Subscript","Subscript (Ctrl+=)","subscript"):""}\n ${t.superscript?this._btn("blazing-rich-text-super-button","Superscript","Superscript (Ctrl+Shift++)","superscript"):""}\n ${t.inlineCode?this._btn("blazing-rich-text-inline-code-button","InlineCode","Inline Code (Ctrl+Shift+E)","inlinecode"):""}\n ${i?this._divider():""}\n\n ${t.textColor?this._btn("blazing-rich-text-textcolor-button","TextColor","Text Color (Ctrl+Shift+C)","openTextColorDialog"):""}\n ${t.textColor?this._btn("blazing-rich-text-text-bg-color-button","TextBackgroundColor","Text Background Color (Ctrl+Shift+B)","openTextBackgroundColorDialog"):""}\n ${t.textColor?this._btn("blazing-rich-text-textcolor-remove-button","RemoveTextFormat","Remove Color","removeTextColor"):""}\n ${o?this._divider():""}\n\n ${t.alignLeft?this._btn("blazing-rich-text-alignleft-button","Alignleft","Align Left (Ctrl+L)","alignleft"):""}\n ${t.alignCenter?this._btn("blazing-rich-text-aligncenter-button","Aligncenter","Align Center (Ctrl+E)","aligncenter"):""}\n ${t.alignRight?this._btn("blazing-rich-text-alignright-button","Alignright","Align Right (Ctrl+R)","alignright"):""}\n ${t.alignJustify?this._btn("blazing-rich-text-alignjustify-button","Alignjustify","Align Justify (Ctrl+J)","alignjustify"):""}\n ${r?this._divider():""}\n\n ${t.cut?this._btn("blazing-rich-text-cut-button","Cut","Cut (Ctrl+X)","cut"):""}\n ${t.copy?this._btn("blazing-rich-text-copy-button","Copy","Copy (Ctrl+C)","copy"):""}\n ${t.paste?this._btn("blazing-rich-text-paste-button","Paste","Paste (Ctrl+V)","paste"):""}\n ${t.delete?this._btn("blazing-rich-text-delete-button","Delete","Delete","delete"):""}\n ${t.selectAll?this._btn("blazing-rich-text-selectall-button","Selectall","Select All (Ctrl+A)","selectall"):""}\n ${s?this._divider():""}\n\n ${t.orderedList?this._btn("blazing-rich-text-orderedlist-button","OrderedList","Ordered List (Ctrl+Shift+O)","orderedlist"):""}\n ${t.unorderedList?this._btn("blazing-rich-text-unorderedlist-button","UnorderedList","Unordered List (Ctrl+Shift+U)","unorderedlist"):""}\n ${t.indent?this._btn("blazing-rich-text-increase-indent-button","IncreaseIndent","Increase Indent (Tab)","increaseIndent"):""}\n ${t.indent?this._btn("blazing-rich-text-decrease-indent-button","DecreaseIndent","Decrease Indent (Shift+Tab)","decreaseIndent"):""}\n ${l?this._divider():""}\n\n ${t.link?this._btn("blazing-rich-text-link-button","CreateLink","Insert Link (Ctrl+Shift+K)","openLinkDialog"):""}\n ${t.link?this._btn("blazing-rich-text-remove-link-button","RemoveLink","Remove Link","removeLink"):""}\n ${t.image?this._btn("blazing-rich-text-image-button","Image","Insert Image (Ctrl+Shift+I)","openImageDialog"):""}\n ${t.imageUpload?this._btn("blazing-rich-text-image-upload-button","UploadImage","Upload Image (Ctrl+Shift+&)","uploadImageDialog"):""}\n ${t.quote?this._btn("blazing-rich-text-quote-button","Quote","Block Quote (Ctrl+Shift+Q)","openBlockQuoteDialog"):""}\n ${t.embedMedia?this._btn("blazing-rich-text-embed-button","PermMedia","Insert Media (Ctrl+Shift+M)","openMediaDialog"):""}\n ${t.video?this._btn("blazing-rich-text-video-button","VideoFile","Insert Video (Ctrl+Shift+V)","openVideoDialog"):""}\n ${t.table?this._btn("blazing-rich-text-table-button","Table","Table (Ctrl+Shift+L)","openTableDialog"):""}\n ${t.codeBlock?this._btn("blazing-rich-text-code-block-button","CodeBlocks","Code Block (Ctrl+Shift+*)","openCodeBlockDialog"):""}\n ${t.horizontalRule?this._btn("blazing-rich-text-hr-button","HorizontalRule","Horizontal Rule (Ctrl+Shift+H)","insertHorizontalRule"):""}\n ${a?this._divider():""}\n\n ${t.undo?this._btn("blazing-rich-text-undo-button","Undo","Undo (Ctrl+Z)","goBack"):""}\n ${t.redo?this._btn("blazing-rich-text-redo-button","Redo","Redo (Ctrl+Y)","goForward"):""}\n ${d?this._divider():""}\n\n ${t.htmlView?this._specialBtn("blazing-rich-text-source","Code","HTML Source (Ctrl+Shift+A)","toggleView"):""}\n ${t.preview?this._specialBtn("blazing-rich-text-preview-button","Preview","Preview (Ctrl+Shift+P)","openPreview"):""}\n ${t.fullscreen?this._fullscreenBtn():""}\n ${c?this._divider():""}\n ${this._customButtonsHTML()}\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="1" max="20" step="1" value="1" autocomplete="off" inputmode="numeric" pattern="[0-9]*">\n <label>Rows</label>\n <input type="number" id="rich-text-box-table-rows" class="rich-text-box-form-element" min="1" max="100" step="1" value="1" autocomplete="off" inputmode="numeric" pattern="[0-9]*">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input type="text" id="rich-text-box-table-width" class="rich-text-box-form-element" placeholder="500px">\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 ','<label class="rich-text-box-form-checkbox-label" style="display:flex;align-items:center;"><input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-table-header"> Include Header</label>')}\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 <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 class="rich-text-box-form-left">\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 </div>\n <div class="rich-text-box-form-right">\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>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-margin" placeholder="10px" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-image-float">\n <option value="none" selected>None</option>\n <option value="left">Left</option>\n <option value="right">Right</option>\n </select>\n </div>\n <div class="rich-text-box-form-left" style="clear: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 id="rich-text-box-upload-btn" for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn" tabindex="0" onkeydown="if(event.key===\'Enter\'||event.key===\' \'){event.preventDefault();event.stopPropagation();this.click()}">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>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-margin" placeholder="10px" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-upload-image-float">\n <option value="none" selected>None</option>\n <option value="left">Left</option>\n <option value="right">Right</option>\n </select>\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 </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 ','<label class="rich-text-box-form-checkbox-label" style="display:flex;align-items:center;"><input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox"> Open in New Tab</label>')}\n\n\n ${this._buildPreviewDialogHTML()}\n ${this._buildHelpDialogHTML()}\n\n</div>`}_buildPreviewDialogHTML(){const e=this._uid;return`\n<dialog id="${e}_Preview" class="rich-text-box-modal rich-text-box-scroll rtb-preview-dialog" aria-modal="true" aria-labelledby="${e}_Preview-title">\n <div class="rtb-modal-header">\n <div id="${e}_Preview-title" class="rich-text-box-modal-title">Preview</div>\n <div style="display:flex;gap:2px;align-items:center;">\n <button id="${e}_PreviewMaxBtn" class="rich-text-box-modal-close" aria-label="Maximize preview" onclick="RTNative_Method('togglePreviewMaximize','${e}')"><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','${e}')"><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" tabindex="0"></div>\n <div style="text-align:right;flex-shrink:0;padding-right:4px;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closePreview','${e}')">Close</button>\n </div>\n </div>\n</dialog>`}_buildHelpDialogHTML(){const k=(...e)=>e.map(e=>`<kbd>${e}</kbd>`).join("+");return`\n<dialog id="rich-text-box-help-modal" class="rich-text-box-modal rtb-help-dialog" aria-labelledby="rich-text-box-help-modal-title">\n <div class="rtb-help-sticky-header">\n <div id="rich-text-box-help-modal-title" class="rich-text-box-modal-title">Keyboard Shortcuts</div>\n <button class="rich-text-box-modal-close" aria-label="Close" onclick="RTNative_Method('closeHelpDialog','${this._uid}')"><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="rtb-help-body" tabindex="0">\n <div class="rtb-help-columns">\n <div class="rtb-help-col">\n <table class="rtb-help-table">\n <tbody>\n <tr class="rtb-help-section"><td colspan="2">Text Formatting</td></tr>\n <tr><td>Bold</td><td>${k("Ctrl","B")}</td></tr>\n <tr><td>Italic</td><td>${k("Ctrl","I")}</td></tr>\n <tr><td>Underline</td><td>${k("Ctrl","U")}</td></tr>\n <tr><td>Strikethrough</td><td>${k("Ctrl","D")}</td></tr>\n <tr><td>Subscript</td><td>${k("Ctrl","=")}</td></tr>\n <tr><td>Superscript</td><td>${k("Ctrl","Shift","+")}</td></tr>\n <tr><td>Inline code</td><td>${k("Ctrl","Shift","E")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Dropdowns</td></tr>\n <tr><td>File</td><td>${k("Alt","L")}</td></tr>\n <tr><td>Font</td><td>${k("Alt","F")}</td></tr>\n <tr><td>Size</td><td>${k("Alt","S")}</td></tr>\n <tr><td>Format</td><td>${k("Alt","T")}</td></tr>\n <tr><td>Insert</td><td>${k("Alt","I")}</td></tr>\n <tr><td>More options</td><td>${k("Alt","M")}</td></tr>\n <tr><td>Increase font size</td><td>${k("Ctrl","Shift","&gt;")}</td></tr>\n <tr><td>Decrease font size</td><td>${k("Ctrl","Shift","&lt;")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Paragraph Format</td></tr>\n <tr><td>Paragraph</td><td>${k("Ctrl","Shift","D")}</td></tr>\n <tr><td>Heading 1</td><td>${k("Ctrl","Shift","1")}</td></tr>\n <tr><td>Heading 2</td><td>${k("Ctrl","Shift","2")}</td></tr>\n <tr><td>Heading 3</td><td>${k("Ctrl","Shift","3")}</td></tr>\n <tr><td>Heading 4</td><td>${k("Ctrl","Shift","4")}</td></tr>\n <tr><td>Heading 5</td><td>${k("Ctrl","Shift","5")}</td></tr>\n <tr><td>Heading 6</td><td>${k("Ctrl","Shift","6")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Edit</td></tr>\n <tr><td>Copy</td><td>${k("Ctrl","C")}</td></tr>\n <tr><td>Cut</td><td>${k("Ctrl","X")}</td></tr>\n <tr><td>Paste</td><td>${k("Ctrl","V")}</td></tr>\n <tr><td>Select all</td><td>${k("Ctrl","A")}</td></tr>\n <tr><td>Undo</td><td>${k("Ctrl","Z")}</td></tr>\n <tr><td>Redo</td><td>${k("Ctrl","Y")}</td></tr>\n </tbody>\n </table>\n </div>\n <div class="rtb-help-col">\n <table class="rtb-help-table">\n <tbody>\n <tr class="rtb-help-section"><td colspan="2">Alignment</td></tr>\n <tr><td>Align left</td><td>${k("Ctrl","L")}</td></tr>\n <tr><td>Align center</td><td>${k("Ctrl","E")}</td></tr>\n <tr><td>Align right</td><td>${k("Ctrl","R")}</td></tr>\n <tr><td>Justify</td><td>${k("Ctrl","J")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Color</td></tr>\n <tr><td>Text color</td><td>${k("Ctrl","Shift","C")}</td></tr>\n <tr><td>Background color</td><td>${k("Ctrl","Shift","B")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Lists</td></tr>\n <tr><td>Unordered list</td><td>${k("Ctrl","Shift","U")}</td></tr>\n <tr><td>Ordered list</td><td>${k("Ctrl","Shift","O")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Insert</td></tr>\n <tr><td>Link</td><td>${k("Ctrl","Shift","K")}</td></tr>\n <tr><td>Image</td><td>${k("Ctrl","Shift","I")}</td></tr>\n <tr><td>Upload / embed image</td><td>${k("Ctrl","Shift","7")}</td></tr>\n <tr><td>Media</td><td>${k("Ctrl","Shift","M")}</td></tr>\n <tr><td>Video</td><td>${k("Ctrl","Shift","V")}</td></tr>\n <tr><td>Table</td><td>${k("Ctrl","Shift","L")}</td></tr>\n <tr><td>Code block</td><td>${k("Ctrl","Shift","8")}</td></tr>\n <tr><td>Block quote</td><td>${k("Ctrl","Shift","Q")}</td></tr>\n <tr><td>Horizontal rule</td><td>${k("Ctrl","Shift","H")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">View</td></tr>\n <tr><td>Toggle HTML source</td><td>${k("Ctrl","Shift","A")}</td></tr>\n <tr><td>Preview</td><td>${k("Ctrl","Shift","P")}</td></tr>\n <tr><td>Open HTML</td><td>${k("Ctrl","O")}</td></tr>\n <tr><td>Download HTML</td><td>${k("Ctrl","S")}</td></tr>\n <tr><td>Toggle status bar</td><td>${k("Ctrl","\\")}</td></tr>\n <tr><td>Find</td><td>${k("Ctrl","F")}</td></tr>\n <tr><td>Keyboard Shortcuts</td><td>${k("Ctrl","/")}</td></tr>\n </tbody>\n </table>\n </div>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",m);
1
+ class e{constructor(e,t,n,i,o){this.id=e,this.shadow_id=t,this.toolbar_id=n,this.styles=i,this.dotNetObjectReference=o,this._selectAllActive=!1,this.init()}init=()=>{this.hydrateShadowTree(),this.observeDefaultParagraphs(),this.Utilities=new r(this.shadowRoot,this.content),this.NodeManager=new n(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new o(this.shadowRoot,this.content,this.Utilities),this.ListProvider=new i(this.shadowRoot,this.content,this.Utilities,this.NodeManager),this.ColorPickers={};const e="rich-text-box-text-color-modal",m="rich-text-box-text-bg-color-modal";this.ColorPickers[e]=new g(this.shadowRoot,this.content,e,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.closeImageDialog),this.UploadImageDialog=new h(this.shadowRoot,this.content,this.Utilities),this.BlockQuoteDialog=new c(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new d(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.closeTableDialog),this.StateManager=new t(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners(),this.addToolbarMenuKeyboardNavigation(),this.setDefaultParagraphSeparator()};hydrateShadowTree=()=>{const e=document.getElementById(this.shadow_id);this.shadowRoot=e.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=this.styles,this.shadowRoot.appendChild(t),this.contentContainer=document.createElement("div"),this.contentContainer.classList.add("rich-text-box-content-container","rich-text-box-scroll"),this.contentContainer.style.position="relative",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,this.openFileInput=document.createElement("input"),this.openFileInput.type="file",this.openFileInput.accept=".html,.htm,text/html",this.openFileInput.style.display="none",this.dropOverlay=document.createElement("div"),this.dropOverlay.className="rtb-drop-overlay",this.dropOverlay.innerHTML='\n <div class="rtb-drop-zone">\n <div class="rtb-drop-icon">HTML</div>\n <div class="rtb-drop-title">Drop HTML file to open</div>\n <div class="rtb-drop-subtitle">.html or .htm</div>\n </div>\n ',this.imageResizeOverlay=document.createElement("div"),this.imageResizeOverlay.className="rtb-image-resize-overlay",this.imageResizeOverlay.setAttribute("aria-hidden","true"),["nw","n","ne","e","se","s","sw","w"].forEach(e=>{const t=document.createElement("span");t.className=`rtb-image-resize-handle rtb-image-resize-${e}`,t.dataset.direction=e,this.imageResizeOverlay.appendChild(t)}),this.tableResizeOverlay=document.createElement("div"),this.tableResizeOverlay.className="rtb-table-resize-overlay",this.tableResizeOverlay.setAttribute("aria-hidden","true"),["nw","n","ne","e","se","s","sw","w"].forEach(e=>{const t=document.createElement("span");t.className=`rtb-table-resize-handle rtb-image-resize-${e}`,t.dataset.direction=e,this.tableResizeOverlay.appendChild(t)});const n=document.createElement("div");n.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),n.setAttribute("id","rich-text-box-message-bar");const i=document.createElement("span");i.setAttribute("class","rich-text-box-message");const o=document.createElement("button");o.setAttribute("class","rich-text-box-message-close-button"),o.textContent="×",o.onclick=()=>{this.Utilities.closeFadingBar()},n.appendChild(i),n.appendChild(o),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.statusLink=document.createElement("span"),this.statusLink.className="rtb-status-link",this.statusCount=document.createElement("span"),this.statusCount.className="rtb-status-count",this.statusCount.textContent="0 words · 0 characters",this.statusBar.append(this.statusLink,this.statusCount),this.findBar=document.createElement("div"),this.findBar.className="rtb-find-bar",this.findBar.setAttribute("role","search"),this.findBar.setAttribute("aria-label","Find in editor"),this.findBar.style.display="none",this.findBar.innerHTML='\n <input type="text" class="rtb-find-input" placeholder="Find..." aria-label="Find text" autocomplete="off" spellcheck="false">\n <span class="rtb-find-count" aria-live="polite"></span>\n <button class="rtb-find-nav-btn" title="Previous match (Shift+Enter)" aria-label="Previous match"><svg viewBox="0 -960 960 960"><path d="M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"/></svg></button>\n <button class="rtb-find-nav-btn" title="Next match (Enter)" aria-label="Next match"><svg viewBox="0 -960 960 960"><path d="M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"/></svg></button>\n <button class="rtb-find-close-btn" title="Close (Escape)" aria-label="Close find bar"><svg viewBox="0 -960 960 960"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></button>\n ',this._findMatches=[],this._findIndex=-1,this._findHighlightName=`rtb-find-match-${String(this.id).replace(/[^a-z0-9_-]/gi,"-")}`;const r=document.createElement("style");r.textContent=`::highlight(${this._findHighlightName}) { background: Highlight; color: HighlightText; }`,this.shadowRoot.appendChild(r),this._sourceFindHighlight=document.createElement("div"),this._sourceFindHighlight.setAttribute("aria-hidden","true"),this._sourceFindHighlight.style.display="none",this._sourceFindHighlight.style.pointerEvents="none",this._sourceFindHighlight.style.position="absolute",this._sourceFindHighlight.style.zIndex="2",this._sourceFindHighlight.style.color="transparent",this._sourceFindHighlight.style.background="transparent";const s=document.getElementById(this.toolbar_id);this.container.appendChild(s),this._setupToolbarOverflow(s),this.contentContainer.appendChild(this.content),this.contentContainer.appendChild(this.source),this.contentContainer.appendChild(this._sourceFindHighlight),this.contentContainer.appendChild(this.openFileInput),this.contentContainer.appendChild(this.dropOverlay),this.contentContainer.appendChild(this.imageResizeOverlay),this.contentContainer.appendChild(this.tableResizeOverlay),this.contextMenu=document.createElement("div"),this.contextMenu.className="rtb-context-menu",this.contextMenu.setAttribute("role","menu"),this.contextMenu.setAttribute("aria-hidden","true"),this.container.appendChild(n),this.container.appendChild(this.findBar),this.container.appendChild(this.contentContainer),this.container.appendChild(this.statusBar),this.container.appendChild(this.contextMenu),this.shadowRoot.appendChild(this.container)};observeDefaultParagraphs=()=>{const applyDefaultStyle=e=>{if(!(e instanceof Element))return;(e.matches("p")?[e]:Array.from(e.querySelectorAll("p"))).forEach(e=>{e.style.overflowWrap||(e.style.overflowWrap="break-word")})};this._paragraphObserver=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(applyDefaultStyle)})}),this._paragraphObserver.observe(this.content,{childList:!0,subtree:!0})};isDocumentFocusDrift=()=>{const e=document.activeElement;return!e||e===document.body||e===document.documentElement||e===this.shadowRoot.host};shouldRecoverEditorTab=e=>{if(e.defaultPrevented||"Tab"!==e.key||e.ctrlKey||e.altKey||e.metaKey)return!1;const t=e.composedPath?e.composedPath():[];if(t.includes(this.shadowRoot)||t.includes(this.container))return!1;if(!this.isDocumentFocusDrift())return!1;const n=this.Utilities.getSelection();return!!(n&&n.rangeCount>0&&this.isSelectionInsideEditor(n))};recoverEditorTab=e=>{this.shouldRecoverEditorTab(e)&&(e.preventDefault(),e.stopPropagation(),this.content.focus({preventScroll:!0}),this.keyEvents(e))};_setupToolbarOverflow=e=>{const t=new Set(["blazing-rich-text-file-button","blazing-rich-text-font-button","blazing-rich-text-size-button","blazing-rich-text-format-button","blazing-rich-text-insert-button"]),isPinned=e=>{if(!e.classList.contains("rich-text-box-dropdown"))return!1;const n=e.querySelector(":scope > button");return n&&t.has(n.id)},n=[],i=[],o=[];for(const t of Array.from(e.children))"DIALOG"===t.tagName?o.push(t):isPinned(t)?n.push(t):i.push(t);const r=document.createElement("div");r.className="rtb-toolbar-items";for(const e of i)r.appendChild(e);for(;e.firstChild;)e.removeChild(e.firstChild);for(const t of n)e.appendChild(t);e.appendChild(r);const s=document.createElement("button");s.className="rtb-overflow-btn",s.setAttribute("aria-label","More options"),s.setAttribute("title","More options (Alt+M)"),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-haspopup","true"),s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg>';const l=document.createElement("div");l.className="rtb-overflow-dropdown",l.setAttribute("role","toolbar"),l.setAttribute("aria-label","More toolbar options");const a=document.createElement("div");a.className="rtb-overflow-wrapper",a.style.display="none",a.appendChild(s),a.appendChild(l),e.appendChild(a),s.addEventListener("click",t=>{t.stopPropagation();const n=l.classList.toggle("rtb-overflow-open");s.setAttribute("aria-expanded",String(n)),n&&(l.style.maxWidth=e.offsetWidth-10+"px")}),l.addEventListener("click",()=>{l.classList.remove("rtb-overflow-open"),s.setAttribute("aria-expanded","false")}),document.addEventListener("click",t=>{t.composedPath().includes(e)||(l.classList.remove("rtb-overflow-open"),s.setAttribute("aria-expanded","false"))}),this._overflowBtn=s,this._overflowDropdown=l,this._overflowWrapper=a,this._overflowItemsContainer=r,this._overflowToolbar=e;const d=new ResizeObserver(()=>this._scheduleOverflowUpdate());d.observe(e),d.observe(r),d.observe(this.container),d.observe(this.contentContainer),this._overflowResizeObserver=d;for(const t of o)e.appendChild(t)};_scheduleOverflowUpdate=()=>{this._overflowItemsContainer&&!this._overflowUpdatePending&&(this._overflowUpdatePending=!0,requestAnimationFrame(()=>{this._overflowUpdatePending=!1,this._updateToolbarOverflow(),this.resizeOpenToolbarDropdowns()}))};_updateToolbarOverflow=()=>{const e=this._overflowItemsContainer,t=this._overflowWrapper,n=this._overflowDropdown,i=this._overflowToolbar;if(!e)return;if(n.classList.contains("rtb-overflow-open")&&(n.style.maxWidth=i.offsetWidth-10+"px"),Array.from(n.children).forEach(t=>e.appendChild(t)),t.style.display="none",e.scrollWidth<=e.offsetWidth)return;t.style.display="";const o=Array.from(e.children);for(let t=o.length-1;t>=0&&!(e.scrollWidth<=e.offsetWidth);t--)n.insertBefore(o[t],n.firstChild);n.firstChild||(t.style.display="none")};isOverflowOptionsVisible=()=>!(!this._overflowWrapper||!this._overflowBtn)&&("none"!==window.getComputedStyle(this._overflowWrapper).display&&!this._overflowBtn.disabled);isMoreOptionsShortcut=e=>e.altKey&&!e.ctrlKey&&!e.metaKey&&("m"===e.key.toLowerCase()||"KeyM"===e.code);getToolbarDropdownShortcutId=e=>{if(!e.altKey||e.ctrlKey||e.metaKey)return null;switch(e.key.toLowerCase()){case"l":return"blazing-rich-text-file-button-dropdown";case"f":return"blazing-rich-text-font-button-dropdown";case"s":return"blazing-rich-text-size-button-dropdown";case"t":return"blazing-rich-text-format-button-dropdown";case"i":return"blazing-rich-text-insert-button-dropdown";default:return null}};handleToolbarDropdownShortcut=e=>{const t=this.getToolbarDropdownShortcutId(e);return!!t&&(e.preventDefault(),this.openToolbarDropdown(t,!0),!0)};focusActiveEditor=()=>{this.EditMode?this.content.focus():this.source.focus()};getToolbarMenuItems=e=>e?Array.from(e.querySelectorAll("a.rich-text-box-menu-item, button.rich-text-box-menu-item, button.rich-text-box-menu-item-special, button.rich-text-box-insert-item, .rtb-overflow-dropdown button")).filter(e=>!e.disabled&&null!==e.offsetParent):[];focusToolbarMenuItem=(e,t)=>{const n=this.getToolbarMenuItems(e);if(0===n.length)return;const i=(t+n.length)%n.length;n.forEach(e=>{e.setAttribute("tabindex","-1"),e.classList.remove("active")}),n[i].classList.add("active"),n[i].focus({preventScroll:!0}),n[i].scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"})};focusFirstToolbarMenuItem=e=>{requestAnimationFrame(()=>this.focusToolbarMenuItem(e,0))};handleToolbarMenuArrowKey=(e,t)=>{const n=this.getToolbarMenuItems(t);if(0===n.length)return;const i=Math.max(0,n.indexOf(e.target)),o=t===this._overflowDropdown?"ArrowRight":"ArrowDown",r=t===this._overflowDropdown?"ArrowLeft":"ArrowUp";e.key===o&&(e.preventDefault(),this.focusToolbarMenuItem(t,i+1)),e.key===r&&(e.preventDefault(),this.focusToolbarMenuItem(t,i-1)),"Home"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,0)),"End"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,n.length-1))};addToolbarMenuKeyboardNavigation=()=>{this.shadowRoot.addEventListener("keydown",e=>{if(e.defaultPrevented)return;if(this.handleToolbarDropdownShortcut(e))return;if(this.isMoreOptionsShortcut(e))return void(this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)));const t=e.target.closest(".rich-text-box-dropdown-content.rich-text-box-show, .rtb-overflow-dropdown.rtb-overflow-open");if(t)return["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key)&&this.handleToolbarMenuArrowKey(e,t),"Escape"===e.key&&(e.preventDefault(),this.NodeManager.closeDropdowns(),this.focusActiveEditor()),void("Enter"!==e.key&&" "!==e.key||!this.getToolbarMenuItems(t).includes(e.target)||(e.preventDefault(),e.target.click()));const n=e.target.closest(".rich-text-box-dropdown-btn");if(n&&["ArrowDown","ArrowUp"].includes(e.key)){e.preventDefault();const t=n.parentElement?.querySelector(".rich-text-box-dropdown-content");if(t){t.classList.contains("rich-text-box-show")||this.openToolbarDropdown(t.id);const n="ArrowUp"===e.key?this.getToolbarMenuItems(t).length-1:0;requestAnimationFrame(()=>this.focusToolbarMenuItem(t,n))}}if(e.target===this._overflowBtn&&["ArrowLeft","ArrowRight"].includes(e.key)&&this.isOverflowOptionsVisible()){e.preventDefault(),this._overflowDropdown.classList.contains("rtb-overflow-open")||this.openOverflowOptions();const t="ArrowLeft"===e.key?this.getToolbarMenuItems(this._overflowDropdown).length-1:0;requestAnimationFrame(()=>this.focusToolbarMenuItem(this._overflowDropdown,t))}})};showImageResizeHandles=e=>{e&&"IMG"===e.tagName&&this.content.contains(e)&&(this.hideTableResizeHandles(),this.selectedResizeImage=e,this.imageResizeOverlay.classList.add("rtb-image-resize-visible"),this.positionImageResizeHandles(),this.NodeManager.selectButtons(e))};hideImageResizeHandles=()=>{this._imageResizeState||(this.selectedResizeImage=null,this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"))};showTableResizeHandles=e=>{e&&"TABLE"===e.tagName&&this.content.contains(e)&&(this.hideImageResizeHandles(),this.selectedResizeTable=e,this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"),this.positionTableResizeHandles(),this.tableResizeOverlay.offsetWidth,this.tableResizeOverlay.classList.add("rtb-table-resize-visible"),this.NodeManager.selectButtons(e),this._selectedTableResizeObserver||(this._selectedTableResizeObserver=new ResizeObserver(()=>{this.selectedResizeTable&&this.positionTableResizeHandles()})),this._selectedTableResizeObserver.disconnect(),this._selectedTableResizeObserver.observe(e))};hideTableResizeHandles=()=>{this._tableResizeState||(this._selectedTableResizeObserver?.disconnect(),this.selectedResizeTable=null,this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"))};positionTableResizeHandles=()=>{const e=this.selectedResizeTable;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideTableResizeHandles();const t=e.getBoundingClientRect(),n=this.contentContainer.getBoundingClientRect();this.tableResizeOverlay.style.left=`${t.left-n.left+this.contentContainer.scrollLeft}px`,this.tableResizeOverlay.style.top=`${t.top-n.top+this.contentContainer.scrollTop}px`,this.tableResizeOverlay.style.width=`${t.width}px`,this.tableResizeOverlay.style.height=`${t.height}px`};trackTableResizeTransition=()=>{this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"),setTimeout(()=>{this.selectedResizeTable&&(this.positionTableResizeHandles(),this.tableResizeOverlay.classList.add("rtb-table-resize-visible"))},90)};startTableResize=e=>{const t=this.selectedResizeTable,n=e.currentTarget.dataset.direction;if(!t||!n)return;e.preventDefault(),e.stopPropagation();const i=t.getBoundingClientRect();this._tableResizeState={table:t,direction:n,startX:e.clientX,startY:e.clientY,startWidth:i.width,startHeight:i.height},this.tableResizeOverlay.classList.add("rtb-table-resizing"),e.currentTarget.setPointerCapture(e.pointerId)};resizeSelectedTable=e=>{const t=this._tableResizeState;if(!t)return;e.preventDefault();const n=e.clientX-t.startX,i=e.clientY-t.startY,o=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(o&&r){const e=t.direction.includes("w")?-n:n,o=t.direction.includes("n")?-i:i,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+o)/t.startHeight,l=Math.max(1/t.startWidth,1/t.startHeight,Math.abs(r-1)>=Math.abs(s-1)?r:s);t.table.style.width=`${Math.max(1,Math.round(t.startWidth*l))}px`,t.table.style.height=`${Math.max(1,Math.round(t.startHeight*l))}px`}else if(o){const e=t.direction.includes("w")?-n:n;t.table.style.width=`${Math.max(1,Math.round(t.startWidth+e))}px`}else if(r){const e=t.direction.includes("n")?-i:i;t.table.style.height=`${Math.max(1,Math.round(t.startHeight+e))}px`}this.positionTableResizeHandles()};finishTableResize=()=>{this._tableResizeState&&(this._tableResizeState=null,this.tableResizeOverlay.classList.remove("rtb-table-resizing"),this.positionTableResizeHandles())};getTableCellResizeEdge=e=>{const t=e.target instanceof Element?e.target.closest("td, th"):null,n=t?.closest("table");if(!t||!n||!this.content.contains(n))return null;const i=t.getBoundingClientRect(),o=[],r=t.parentElement,s=r?.rowIndex??-1,l=t.cellIndex;l>0&&o.push({axis:"column",index:l-1,distance:Math.abs(e.clientX-i.left)}),r&&l<r.cells.length-1&&o.push({axis:"column",index:l,distance:Math.abs(e.clientX-i.right)}),s>0&&o.push({axis:"row",index:s-1,distance:Math.abs(e.clientY-i.top)}),s>=0&&s<n.rows.length-1&&o.push({axis:"row",index:s,distance:Math.abs(e.clientY-i.bottom)}),0===l&&o.push({axis:"table-column",direction:"w",distance:Math.abs(e.clientX-i.left)}),r&&l===r.cells.length-1&&o.push({axis:"table-column",direction:"e",distance:Math.abs(e.clientX-i.right)}),0===s&&o.push({axis:"table-row",direction:"n",distance:Math.abs(e.clientY-i.top)}),s===n.rows.length-1&&o.push({axis:"table-row",direction:"s",distance:Math.abs(e.clientY-i.bottom)});const a=o.filter(e=>e.distance<=5).sort((e,t)=>e.distance-t.distance)[0];return a?{...a,table:n}:null};updateTableCellResizeCursor=e=>{if(this._tableCellResizeState)return;const t=this.getTableCellResizeEdge(e);this._tableCellResizeEdge=t,t?this.content.style.setProperty("--rtb-table-cell-cursor","column"===t.axis||"table-column"===t.axis?"ew-resize":"ns-resize"):this.content.style.removeProperty("--rtb-table-cell-cursor")};clearTableCellResizeCursor=()=>{this._tableCellResizeState||(this._tableCellResizeEdge=null,this.content.style.removeProperty("--rtb-table-cell-cursor"))};startTableCellResize=e=>{const t=this.getTableCellResizeEdge(e);if(!t)return;e.preventDefault(),e.stopPropagation();const{table:n,axis:i,index:o,direction:r}=t;if("column"===i){const t=Array.from(n.rows).map(e=>e.cells[o]).filter(e=>e&&1===e.colSpan);if(0===t.length)return;this._tableCellResizeState={axis:i,table:n,cells:t,startPosition:e.clientX,startSize:t[0].getBoundingClientRect().width}}else if("row"===i){const t=n.rows[o];if(!t)return;this._tableCellResizeState={axis:i,table:n,row:t,startPosition:e.clientY,startSize:t.getBoundingClientRect().height}}else{const t=n.getBoundingClientRect();this._tableCellResizeState={axis:i,direction:r,table:n,startPosition:"table-column"===i?e.clientX:e.clientY,startSize:"table-column"===i?t.width:t.height}}this.content.style.cursor="column"===i||"table-column"===i?"ew-resize":"ns-resize",this.content.setPointerCapture(e.pointerId)};resizeTableCellBoundary=e=>{const t=this._tableCellResizeState;if(t){if(e.preventDefault(),"column"===t.axis){const n=Math.max(1,Math.round(t.startSize+e.clientX-t.startPosition));t.cells.forEach(e=>{e.style.width=`${n}px`,e.style.minWidth="0"}),this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else if("row"===t.axis){const n=Math.max(1,Math.round(t.startSize+e.clientY-t.startPosition));t.row.style.height=`${n}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}else if("table-column"===t.axis){const n=e.clientX-t.startPosition,i=Math.max(1,Math.round(t.startSize+("w"===t.direction?-n:n)));t.table.style.width=`${i}px`,this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else{const n=e.clientY-t.startPosition,i=Math.max(1,Math.round(t.startSize+("n"===t.direction?-n:n)));t.table.style.height=`${i}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}this.selectedResizeTable===t.table&&this.positionTableResizeHandles()}};finishTableCellResize=()=>{this._tableCellResizeState&&(this._tableCellResizeState=null,this._tableCellResizeEdge=null,this.content.style.cursor="",this.content.style.removeProperty("--rtb-table-cell-cursor"),this.positionTableResizeHandles())};positionImageResizeHandles=()=>{const e=this.selectedResizeImage;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideImageResizeHandles();const t=e.getBoundingClientRect(),n=this.contentContainer.getBoundingClientRect();this.imageResizeOverlay.style.left=`${t.left-n.left+this.contentContainer.scrollLeft}px`,this.imageResizeOverlay.style.top=`${t.top-n.top+this.contentContainer.scrollTop}px`,this.imageResizeOverlay.style.width=`${t.width}px`,this.imageResizeOverlay.style.height=`${t.height}px`};trackImageResizeTransition=()=>{this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"),setTimeout(()=>{this.selectedResizeImage&&(this.positionImageResizeHandles(),this.imageResizeOverlay.classList.add("rtb-image-resize-visible"))},90)};startImageResize=e=>{const t=this.selectedResizeImage,n=e.currentTarget.dataset.direction;if(!t||!n)return;e.preventDefault(),e.stopPropagation();const i=t.getBoundingClientRect();this._imageResizeState={image:t,direction:n,startX:e.clientX,startY:e.clientY,startWidth:i.width,startHeight:i.height},this.imageResizeOverlay.classList.add("rtb-image-resizing"),e.currentTarget.setPointerCapture(e.pointerId)};resizeSelectedImage=e=>{const t=this._imageResizeState;if(!t)return;e.preventDefault();const n=e.clientX-t.startX,i=e.clientY-t.startY,o=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(o&&r){const e=t.direction.includes("w")?-n:n,o=t.direction.includes("n")?-i:i,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+o)/t.startHeight,l=Math.max(1/t.startWidth,1/t.startHeight,Math.abs(r-1)>=Math.abs(s-1)?r:s);t.image.width=Math.max(1,Math.round(t.startWidth*l)),t.image.height=Math.max(1,Math.round(t.startHeight*l))}else if(o){const e=t.direction.includes("w")?-n:n;t.image.width=Math.max(1,Math.round(t.startWidth+e))}else if(r){const e=t.direction.includes("n")?-i:i;t.image.height=Math.max(1,Math.round(t.startHeight+e))}this.positionImageResizeHandles()};finishImageResize=()=>{this._imageResizeState&&(this._imageResizeState=null,this.imageResizeOverlay.classList.remove("rtb-image-resizing"),this.positionImageResizeHandles())};alignSelectedResizeImage=e=>{const t=this.selectedResizeImage;return!(!t||!this.content.contains(t))&&(this.selectResizeImageRange(),this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"),this.NodeManager.updateNode(e),this.trackImageResizeTransition(),this.clearResizeImageRange(),this.NodeManager.selectButtons(t),!0)};selectResizeImageRange=()=>{const e=this.selectedResizeImage;if(!e||!this.content.contains(e))return null;if(e.parentNode===this.content){const t=document.createElement("p");t.style.overflowWrap="break-word",this.content.insertBefore(t,e),t.appendChild(e)}const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const n=document.createRange();return n.selectNode(e),t.removeAllRanges(),t.addRange(n),t};clearResizeImageRange=()=>{if(!this.selectedResizeImage||!this.content.contains(this.selectedResizeImage))return;const e=this.Utilities.getSelection()||window.getSelection();e?.removeAllRanges()};toggleListForSelectedResizeImage=e=>{const t=this.selectedResizeImage;if(!t||!this.content.contains(t))return!1;this.selectResizeImageRange();const n=t.closest("ol, ul");if(n&&this.content.contains(n))this.ListProvider.addlist(e);else{const n=t.parentElement;if(!n||n===this.content)return!1;const i=document.createElement(e),o=document.createElement("li");for(;n.firstChild;)o.appendChild(n.firstChild);i.appendChild(o),n.replaceWith(i),this.selectResizeImageRange()}return requestAnimationFrame(this.positionImageResizeHandles),this.clearResizeImageRange(),!0};selectResizeTableRange=()=>{const e=this.selectedResizeTable;if(!e||!this.content.contains(e))return null;const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const n=document.createRange();return n.selectNode(e),t.removeAllRanges(),t.addRange(n),t};clearResizeTableRange=()=>{if(!this.selectedResizeTable||!this.content.contains(this.selectedResizeTable))return;const e=this.Utilities.getSelection()||window.getSelection();e?.removeAllRanges()};isSelectionInsideSelectedTableCell=()=>{if(!this.selectedResizeTable||!this.content.contains(this.selectedResizeTable))return!1;const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return!1;const t=e.anchorNode instanceof Element?e.anchorNode:e.anchorNode?.parentElement,n=t?.closest("td, th");return!!n&&this.selectedResizeTable.contains(n)};alignSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"),this.NodeManager.alignTable(t,e),this.trackTableResizeTransition(),this.clearResizeTableRange(),this.NodeManager.selectButtons(t),!0)};toggleListForSelectedResizeTable=e=>{const t=this.selectedResizeTable;if(!t||!this.content.contains(t))return!1;const n=t.closest("ol, ul");if(n&&this.content.contains(n))if(n.nodeName===e){const e=t.closest("li");n.parentNode.insertBefore(t,n.nextSibling),e?.remove(),n.querySelector("li")||n.remove()}else{const t=document.createElement(e);for(;n.firstChild;)t.appendChild(n.firstChild);n.replaceWith(t)}else{const n=document.createElement(e),i=document.createElement("li");t.replaceWith(n),i.appendChild(t),n.appendChild(i)}return this.trackTableResizeTransition(),this.clearResizeTableRange(),!0};indentSelectedResizeTable=e=>{const t=this.selectedResizeTable;if(!t||!this.content.contains(t))return!1;const n=parseFloat(window.getComputedStyle(t).marginLeft)||0,i=e?n+40:Math.max(0,n-40);return i>0?t.style.marginLeft=`${i}px`:(t.style.removeProperty("margin-left"),0===t.style.length&&t.removeAttribute("style")),this.trackTableResizeTransition(),!0};addEventListeners=()=>{document.addEventListener("keydown",this.recoverEditorTab,!0),this.shadowRoot.addEventListener("keydown",e=>{this.trapDialogFocus(e)}),this._overflowToolbar&&this._overflowToolbar.addEventListener("mousedown",e=>{if(e.target.closest("dialog"))return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&e.preventDefault()},!1),document.addEventListener("selectionchange",e=>{const t=this.Utilities.getSelection();null!==t&&(this.clearSettings(t.anchorNode),this._hoveredStatusLink||this._updateStatusLinkFromNode(t.anchorNode))}),this.content.addEventListener("mouseover",e=>{const t=e.target instanceof Element?e.target.closest("a"):null;t&&this.content.contains(t)&&(this._hoveredStatusLink=t,this._setStatusLink(t.href))}),this.content.addEventListener("mouseout",e=>{if(!this._hoveredStatusLink)return;if((e.relatedTarget instanceof Element?e.relatedTarget.closest("a"):null)===this._hoveredStatusLink)return;this._hoveredStatusLink=null;const t=this.Utilities.getSelection();this._updateStatusLinkFromNode(t?.anchorNode)}),this.content.addEventListener("click",e=>{if("IMG"===e.target.tagName)this.showImageResizeHandles(e.target);else{this.hideImageResizeHandles();const t=e.target instanceof Element?e.target.closest("table"):null;t&&this.content.contains(t)?this.showTableResizeHandles(t):this.hideTableResizeHandles()}"A"===e.target.tagName&&(e.preventDefault(),e.stopPropagation())}),this.content.addEventListener("click",e=>{const t=e.target.tagName;if("VIDEO"===t||"SOURCE"===t){e.preventDefault();const n="SOURCE"===t?e.target.closest("video"):e.target;if(n&&n.parentNode===this.content){if(!n.nextSibling){const e=document.createElement("p");e.appendChild(document.createElement("br")),this.content.insertBefore(e,null)}const e=n.nextSibling,t=window.getSelection();if(t&&e){const n=document.createRange(),i=e.firstChild??e;n.setStart(i,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}}},!0),this.content.addEventListener("dblclick",e=>{const t=e.target.tagName;"VIDEO"!==t&&"SOURCE"!==t||e.preventDefault()},!0),this.content.addEventListener("dblclick",e=>{switch(e.target.tagName){case"A":e.preventDefault(),this.openLinkDialog();break;case"IMG":e.preventDefault();const t=this.Utilities.getSelection(),n=document.createRange();n.selectNode(e.target),t&&(t.removeAllRanges(),t.addRange(n)),e.target.src.startsWith("data")?this.uploadImageDialog():this.openImageDialogForElement(e.target);break;case"VIDEO":case"SOURCE":{e.preventDefault();const t="SOURCE"===e.target.tagName?e.target.closest("video"):e.target;if(t){const e=this.Utilities.getSelection(),n=document.createRange();n.selectNode(t),e.removeAllRanges(),e.addRange(n),this.openVideoDialogForElement(t)}else this.openVideoDialog();break}case"BLOCKQUOTE":e.preventDefault(),this.openBlockQuoteDialogForElement(e.target);break;case"PRE":e.preventDefault(),this.openCodeBlockDialogForElement(e.target);break;case"TD":case"TH":{const t=e.target.closest("table");t&&this.content.contains(t)&&(e.preventDefault(),this.openTableDialog());break}case"CODE":{const t=e.target.closest("pre");t&&this.content.contains(t)&&(e.preventDefault(),this.openCodeBlockDialogForElement(t));break}default:{const t=e.target.closest("pre");if(t&&this.content.contains(t)){e.preventDefault(),this.openCodeBlockDialogForElement(t);break}const n=e.target.closest("blockquote");if(n&&this.content.contains(n))e.preventDefault(),this.openBlockQuoteDialogForElement(n);else{const e=this.Utilities.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const t=e.getRangeAt(0),n=t.endContainer;if(n.nodeType===Node.TEXT_NODE){const i=n.textContent;let o=t.endOffset;for(;o>0&&/\s/.test(i[o-1]);)o--;o!==t.endOffset&&(t.setEnd(n,o),e.removeAllRanges(),e.addRange(t))}}}break}}}),this.content.addEventListener("input",e=>{this._selectAllActive=!1,this.updateWordCount();const t=this.Utilities.getSelection(),n=t.getRangeAt(0).startContainer;if(n.nodeType===Node.TEXT_NODE&&"SPAN"===n.parentNode.tagName){const e=n.parentNode,i=e.parentNode;if(this.NodeManager.isFormatElement(i)){if(!(e.style.color||e.style.backgroundColor||e.style.fontFamily||e.style.fontSize||e.style.fontWeight||e.style.fontStyle||e.style.textDecoration)){for(;e.firstChild;)i.insertBefore(e.firstChild,e);i.removeChild(e);const n=document.createRange();n.setStart(i.firstChild,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}}}),this.content.addEventListener("keydown",e=>{this.keyEvents(e)}),this.source.addEventListener("keydown",e=>{"Tab"!==e.key?(e.ctrlKey&&!e.shiftKey&&"f"===e.key&&(e.preventDefault(),this.openFindBar()),e.ctrlKey&&!e.shiftKey&&"/"===e.key&&(e.preventDefault(),this.openHelpDialog()),e.altKey&&!e.ctrlKey&&"l"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-file-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"f"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-font-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"s"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-size-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"t"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-format-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"i"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-insert-button-dropdown",!0)),this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),e.ctrlKey&&!e.shiftKey&&"s"===e.key.toLowerCase()&&(e.preventDefault(),this.saveHtml()),e.ctrlKey&&!e.shiftKey&&"o"===e.key.toLowerCase()&&(e.preventDefault(),this.openHtmlFile()),e.ctrlKey&&e.shiftKey&&"A"===e.key&&(e.preventDefault(),!0===this.EditMode?this.getHtml():this.getCode()),e.ctrlKey&&e.shiftKey&&"P"===e.key&&(e.preventDefault(),this.openPreview()),e.ctrlKey&&!e.shiftKey&&"\\"===e.key&&(e.preventDefault(),this.toggleStatusBar())):e.preventDefault()}),this.openFileInput.addEventListener("change",e=>{this.openDroppedOrSelectedHtmlFile(e.target.files?.[0]),e.target.value=""}),["dragenter","dragover"].forEach(e=>{this.contentContainer.addEventListener(e,e=>{this.dragEventHasHtmlFile(e)&&(e.preventDefault(),this.dropOverlay.classList.add("rtb-drop-overlay-visible"))})}),["dragleave","dragend"].forEach(e=>{this.contentContainer.addEventListener(e,t=>{"dragleave"===e&&this.contentContainer.contains(t.relatedTarget)||this.dropOverlay.classList.remove("rtb-drop-overlay-visible")})}),this.contentContainer.addEventListener("drop",e=>{this.dragEventHasHtmlFile(e)&&(e.preventDefault(),this.dropOverlay.classList.remove("rtb-drop-overlay-visible"),this.openDroppedOrSelectedHtmlFile(e.dataTransfer.files?.[0]))}),this.imageResizeOverlay.querySelectorAll(".rtb-image-resize-handle").forEach(e=>{e.addEventListener("pointerdown",this.startImageResize)}),this.tableResizeOverlay.querySelectorAll(".rtb-table-resize-handle").forEach(e=>{e.addEventListener("pointerdown",this.startTableResize)}),this.content.addEventListener("pointermove",this.updateTableCellResizeCursor),this.content.addEventListener("pointerleave",this.clearTableCellResizeCursor),this.content.addEventListener("pointerdown",this.startTableCellResize),document.addEventListener("pointermove",this.resizeSelectedImage),document.addEventListener("pointermove",this.resizeSelectedTable),document.addEventListener("pointermove",this.resizeTableCellBoundary),document.addEventListener("pointerup",this.finishImageResize),document.addEventListener("pointerup",this.finishTableResize),document.addEventListener("pointerup",this.finishTableCellResize),document.addEventListener("pointercancel",this.finishImageResize),document.addEventListener("pointercancel",this.finishTableResize),document.addEventListener("pointercancel",this.finishTableCellResize),document.addEventListener("pointerdown",e=>{if(!this.selectedResizeImage&&!this.selectedResizeTable||this._imageResizeState||this._tableResizeState)return;const t=e.composedPath(),n=new Set(["blazing-rich-text-alignleft-button","blazing-rich-text-aligncenter-button","blazing-rich-text-alignright-button","blazing-rich-text-alignjustify-button","blazing-rich-text-orderedlist-button","blazing-rich-text-unorderedlist-button","blazing-rich-text-increase-indent-button","blazing-rich-text-decrease-indent-button","blazing-rich-text-cut-button","blazing-rich-text-copy-button","blazing-rich-text-paste-button","blazing-rich-text-delete-button"]);t.some(e=>e instanceof Element&&n.has(e.id))||this.selectedResizeImage&&t.some(e=>e instanceof Element&&"blazing-rich-text-image-button"===e.id)||this.selectedResizeTable&&t.some(e=>e instanceof Element&&"blazing-rich-text-table-button"===e.id)||(!this.selectedResizeImage||t.includes(this.selectedResizeImage)||t.includes(this.imageResizeOverlay)||this.hideImageResizeHandles(),!this.selectedResizeTable||t.includes(this.selectedResizeTable)||t.includes(this.tableResizeOverlay)||this.hideTableResizeHandles())}),this.contentContainer.addEventListener("scroll",this.positionImageResizeHandles),this.contentContainer.addEventListener("scroll",this.positionTableResizeHandles),window.addEventListener("resize",this.positionImageResizeHandles),window.addEventListener("resize",this.positionTableResizeHandles);this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(e=>{e.addEventListener("mousedown",e=>{e.preventDefault()})});const e=this.findBar.querySelector(".rtb-find-input"),t=this.findBar.querySelector(".rtb-find-count"),[n,i]=this.findBar.querySelectorAll(".rtb-find-nav-btn"),o=this.findBar.querySelector(".rtb-find-close-btn");e.addEventListener("paste",t=>{t.preventDefault();const n=(t.clipboardData||window.clipboardData).getData("text").trim(),i=e.selectionStart,o=e.selectionEnd;e.value=e.value.substring(0,i)+n+e.value.substring(o),e.selectionStart=e.selectionEnd=i+n.length,e.dispatchEvent(new Event("input"))}),e.addEventListener("input",()=>{this._findMatches=[],this._findIndex=-1,this._clearFindHighlight(),t.textContent=""}),e.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),t.shiftKey?this.findPrev():this.findNext(),e.focus({preventScroll:!0})),"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),this.closeFindBar())}),n.addEventListener("mousedown",e=>e.preventDefault()),i.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("click",()=>{this.findPrev(),e.focus({preventScroll:!0})}),i.addEventListener("click",()=>{this.findNext(),e.focus({preventScroll:!0})}),o.addEventListener("click",()=>this.closeFindBar()),this.content.addEventListener("pointerdown",e=>{this._selectAllActive=!1,this._lastPointerType=e.pointerType}),this.content.addEventListener("contextmenu",e=>this.openEditorContextMenu(e)),this.content.addEventListener("paste",e=>{const t=e.clipboardData?.getData("text/html")||"";if(t){const e=document.createElement("template");e.innerHTML=t;const n=e.content.querySelector("img");n&&(this._imageClipboardHtml=n.outerHTML)}else{const t=Array.from(e.clipboardData?.items||[]).find(e=>e.type.startsWith("image/")),n=t?.getAsFile();if(n){const e=new FileReader;e.onload=()=>{const t=document.createElement("img");t.src=e.result,this._imageClipboardHtml=t.outerHTML},e.readAsDataURL(n)}}const n=e.clipboardData?.getData("text/plain")||"";n&&(e.preventDefault(),this.selectedResizeImage&&(this.selectResizeImageRange(),this.hideImageResizeHandles()),this.ActionOptions.paste(n))}),document.addEventListener("click",()=>this.hideContextMenu())};trapDialogFocus=e=>{if("Tab"!==e.key||e.ctrlKey||e.altKey||e.metaKey)return!1;const t=this.shadowRoot.querySelector("dialog[open]");if(!t)return!1;const n=Array.from(t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(e=>!e.disabled&&null!==e.offsetParent);if(0===n.length)return e.preventDefault(),t.focus(),!0;const i=n[0],o=n[n.length-1],r=this.shadowRoot.activeElement;return t.contains(r)?e.shiftKey&&r===i?(e.preventDefault(),o.focus(),!0):!e.shiftKey&&r===o&&(e.preventDefault(),i.focus(),!0):(e.preventDefault(),i.focus(),!0)};isSelectionInsideEditor=e=>{if(!e||0===e.rangeCount)return!1;const t=e.getRangeAt(0),containsNode=e=>!!e&&(e===this.content||this.content.contains(e));return containsNode(t.startContainer)&&containsNode(t.endContainer)&&(!e.anchorNode||containsNode(e.anchorNode))&&(!e.focusNode||containsNode(e.focusNode))};getSelectedResizeImageIndex=()=>this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)?Array.from(this.content.querySelectorAll("img")).indexOf(this.selectedResizeImage):-1;restoreImageResizeHandles=e=>{if(e<0)return;const t=this.content.querySelectorAll("img")[e];t?(this.selectedResizeImage=t,requestAnimationFrame(()=>this.showImageResizeHandles(t))):this.hideImageResizeHandles()};getSelectedResizeTableIndex=()=>this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)?Array.from(this.content.querySelectorAll("table")).indexOf(this.selectedResizeTable):-1;restoreTableResizeHandles=e=>{if(e<0)return;const t=this.content.querySelectorAll("table")[e];t?(this.selectedResizeTable=t,requestAnimationFrame(()=>this.showTableResizeHandles(t))):this.hideTableResizeHandles()};goBack=()=>{const e=this.getSelectedResizeImageIndex(),t=this.getSelectedResizeTableIndex();this.StateManager.goBack(),this.NodeManager.refreshUI(),this.updateWordCount(),this.restoreImageResizeHandles(e),this.restoreTableResizeHandles(t)};goForward=()=>{const e=this.getSelectedResizeImageIndex(),t=this.getSelectedResizeTableIndex();this.StateManager.goForward(),this.NodeManager.refreshUI(),this.updateWordCount(),this.restoreImageResizeHandles(e),this.restoreTableResizeHandles(t)};clearSettings=e=>{this.fontSize=void 0;const t=this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)?this.selectedResizeImage:null;this.NodeManager.selectButtons(t||e)};keyEvents=e=>{if(this.setDefaultParagraphSeparator(),this.NodeManager.createDefaultElement(),!1===this.EditMode)return e.ctrlKey&&"z"===e.key&&e.preventDefault(),void(e.ctrlKey&&"y"===e.key&&e.preventDefault());if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){e.preventDefault();const t=this.selectedResizeImage;return this.hideImageResizeHandles(),t.remove(),void this.updateWordCount()}if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)&&!this.isSelectionInsideSelectedTableCell()){e.preventDefault();const t=this.selectedResizeTable;return this.hideTableResizeHandles(),t.remove(),void this.updateWordCount()}const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&!this.isSelectionInsideEditor(t))e.preventDefault();else if(this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),"Enter"!==e.key||e.ctrlKey||e.altKey||e.metaKey||!this.insertParagraphAtTableBoundary()&&!this.insertParagraphAfterStructuredBlock()){if(e.ctrlKey&&"b"===e.key&&(e.preventDefault(),this.bold()),e.ctrlKey&&"i"===e.key&&(e.preventDefault(),this.italic()),e.ctrlKey&&"u"===e.key&&(e.preventDefault(),this.underline()),e.ctrlKey&&"d"===e.key&&(e.preventDefault(),this.strikethrough()),e.ctrlKey&&"c"===e.key&&(e.preventDefault(),this.copy()),e.ctrlKey&&"x"===e.key&&(e.preventDefault(),this.cut()),"Delete"===e.key||46===e.keyCode){const t=this.Utilities.getSelection();if(null!==t)if(t.toString().length>0)e.preventDefault(),this.delete();else if(t.isCollapsed){const n=t.getRangeAt(0),i=["P","DIV","H1","H2","H3","H4","H5","H6","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let o=t.anchorNode;for(;o&&o!==this.content&&(o.nodeType!==Node.ELEMENT_NODE||!i.includes(o.nodeName));)o=o.parentNode;if(o&&o!==this.content){if(""===o.textContent.trim()&&!o.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){e.preventDefault();let n=null,i=o.nextSibling;for(;i;){if(i.nodeType===Node.ELEMENT_NODE){n=i;break}if(i.nodeType===Node.TEXT_NODE&&""!==i.textContent.trim()){n=i;break}i=i.nextSibling}if(o.parentNode.removeChild(o),n){const e=document.createRange();e.selectNodeContents(n),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(n.startContainer,n.startOffset),t.setEnd(o,o.childNodes.length);const i=t.cloneContents();if(0===t.toString().length&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=o.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.nextSibling;let n=o.nodeName;if(!t){let e=o,i=o.parentNode;for(;i&&i!==this.content;){let o=null;for(let e=i.childNodes.length-1;e>=0;e--){const t=i.childNodes[e];if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&""!==t.textContent.trim()){o=t;break}}if(o!==e)break;let r=i.nextSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.nextSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,n=i.nodeName;break}e=i,i=i.parentNode}}const i=["P","A"];if(!t||t.nodeType!==Node.ELEMENT_NODE||t.nodeName===n||i.includes(n)&&i.includes(t.nodeName)){if(t&&t.nodeType===Node.ELEMENT_NODE){const e=o.style.fontFamily,n=t.style.fontFamily;e&&!n?t.style.fontFamily=e:!e&&n&&(o.style.fontFamily=n)}}else e.preventDefault()}}}}}if(e.ctrlKey&&"="===e.key&&(e.preventDefault(),this.subscript()),e.ctrlKey&&e.shiftKey&&"+"===e.key&&(e.preventDefault(),this.superscript()),e.ctrlKey&&e.shiftKey&&"E"===e.key&&(e.preventDefault(),this.inlinecode()),e.ctrlKey&&"l"===e.key&&(e.preventDefault(),this.alignleft()),e.ctrlKey&&"e"===e.key&&(e.preventDefault(),this.aligncenter()),e.ctrlKey&&"r"===e.key&&(e.preventDefault(),this.alignright()),e.ctrlKey&&"j"===e.key&&(e.preventDefault(),this.alignjustify()),e.ctrlKey&&"a"===e.key&&(e.preventDefault(),this.selectall()),e.ctrlKey&&"z"===e.key&&(e.preventDefault(),this.goBack()),e.ctrlKey&&"y"===e.key&&(e.preventDefault(),this.goForward()),e.ctrlKey&&e.shiftKey&&"A"===e.key&&(e.preventDefault(),this.toggleView()),e.ctrlKey&&!e.shiftKey&&"s"===e.key.toLowerCase()&&(e.preventDefault(),this.saveHtml()),e.ctrlKey&&!e.shiftKey&&"o"===e.key.toLowerCase()&&(e.preventDefault(),this.openHtmlFile()),e.ctrlKey&&e.shiftKey&&"&"===e.key&&(e.preventDefault(),this.uploadImageDialog()),e.ctrlKey&&e.shiftKey&&"U"===e.key&&(e.preventDefault(),this.unorderedlist()),e.ctrlKey&&e.shiftKey&&"O"===e.key&&(e.preventDefault(),this.orderedlist()),e.ctrlKey&&e.shiftKey&&">"===e.key&&(e.preventDefault(),this.changeFontSize(!0)),e.ctrlKey&&e.shiftKey&&"<"===e.key&&(e.preventDefault(),this.changeFontSize(!1)),e.ctrlKey&&e.shiftKey&&"C"===e.key&&(e.preventDefault(),this.openTextColorDialog()),e.ctrlKey&&e.shiftKey&&"B"===e.key&&(e.preventDefault(),this.openTextBackgroundColorDialog()),e.ctrlKey&&e.shiftKey&&"K"===e.key&&(e.preventDefault(),this.openLinkDialog()),e.ctrlKey&&e.shiftKey&&"*"===e.key&&(e.preventDefault(),this.openCodeBlockDialog()),e.ctrlKey&&e.shiftKey&&"Q"===e.key&&(e.preventDefault(),this.openBlockQuoteDialog()),e.ctrlKey&&e.shiftKey&&"I"===e.key&&(e.preventDefault(),this.openImageDialog()),e.ctrlKey&&e.shiftKey&&"M"===e.key&&(e.preventDefault(),this.openMediaDialog()),e.ctrlKey&&e.shiftKey&&"L"===e.key&&(e.preventDefault(),this.openTableDialog()),e.ctrlKey&&e.shiftKey&&"D"===e.key&&(e.preventDefault(),this.format("none")),e.ctrlKey&&e.shiftKey&&"P"===e.key&&(e.preventDefault(),this.openPreview()),e.ctrlKey&&e.shiftKey&&"!"===e.key&&(e.preventDefault(),this.format("h1")),e.ctrlKey&&e.shiftKey&&"@"===e.key&&(e.preventDefault(),this.format("h2")),e.ctrlKey&&e.shiftKey&&"#"===e.key&&(e.preventDefault(),this.format("h3")),e.ctrlKey&&e.shiftKey&&"$"===e.key&&(e.preventDefault(),this.format("h4")),e.ctrlKey&&e.shiftKey&&"%"===e.key&&(e.preventDefault(),this.format("h5")),e.ctrlKey&&e.shiftKey&&"^"===e.key&&(e.preventDefault(),this.format("h6")),e.ctrlKey&&e.shiftKey&&"V"===e.key&&(e.preventDefault(),this.openVideoDialog()),e.ctrlKey&&e.shiftKey&&"H"===e.key&&(e.preventDefault(),this.insertHorizontalRule()),e.ctrlKey&&!e.shiftKey&&"\\"===e.key&&(e.preventDefault(),this.toggleStatusBar()),e.ctrlKey&&!e.shiftKey&&"f"===e.key&&(e.preventDefault(),this.openFindBar()),e.ctrlKey&&!e.shiftKey&&"/"===e.key&&(e.preventDefault(),this.openHelpDialog()),e.altKey&&!e.ctrlKey&&"l"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-file-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"f"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-font-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"s"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-size-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"t"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-format-button-dropdown",!0)),e.altKey&&!e.ctrlKey&&"i"===e.key&&(e.preventDefault(),this.openToolbarDropdown("blazing-rich-text-insert-button-dropdown",!0)),this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),"Backspace"===e.key){const t=this.Utilities.getSelection();if(t&&t.isCollapsed){const n=t.getRangeAt(0),i=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let o=t.anchorNode;for(;o&&o!==this.content&&(o.nodeType!==Node.ELEMENT_NODE||!i.includes(o.nodeName));)o=o.parentNode;if(o&&o!==this.content){if((parseFloat(window.getComputedStyle(o).marginLeft)||0)>0){const t=document.createRange();t.setStart(o,0),t.setEnd(n.startContainer,n.startOffset),0===t.toString().length&&(e.preventDefault(),this.decreaseIndent())}else{if(""===o.textContent.trim()&&!o.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){e.preventDefault();let n=null,i=o.previousSibling;for(;i;){if(i.nodeType===Node.ELEMENT_NODE){n=i;break}if(i.nodeType===Node.TEXT_NODE&&""!==i.textContent.trim()){n=i;break}i=i.previousSibling}if(o.parentNode.removeChild(o),n){const e=document.createRange();e.selectNodeContents(n),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(o,0),t.setEnd(n.startContainer,n.startOffset);const i=t.cloneContents();if(0===t.toString().length&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=o.previousSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;let n=o.nodeName;if(!t){let e=o,i=o.parentNode;for(;i&&i!==this.content;){let o=null;for(const e of i.childNodes)if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&""!==e.textContent.trim()){o=e;break}if(o!==e)break;let r=i.previousSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,n=i.nodeName;break}e=i,i=i.parentNode}}const i=["P","A"];if(t&&t.nodeType===Node.ELEMENT_NODE){if(i.includes(n)?!i.includes(t.nodeName):t.nodeName!==n)e.preventDefault();else{const e=t.style.fontFamily,n=o.style.fontFamily;e&&!n?o.style.fontFamily=e:!e&&n&&(t.style.fontFamily=n)}}}}}}}}if(!("ArrowLeft"!==e.key||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)){const t=this.Utilities.getSelection();if(t&&t.isCollapsed){const n=t.getRangeAt(0),i=["H1","H2","H3","H4","H5","H6"];let o=t.anchorNode;for(;o&&o!==this.content&&(o.nodeType!==Node.ELEMENT_NODE||!i.includes(o.nodeName));)o=o.parentNode;if(o&&o!==this.content&&i.includes(o.nodeName)){const i=document.createRange();i.setStart(o,0),i.setEnd(n.startContainer,n.startOffset);const r=i.cloneContents();if(0===i.toString().length&&!r.querySelector("*")){let n=o.previousSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&""===n.textContent.trim();)n=n.previousSibling;if(n&&"TABLE"===n.nodeName){e.preventDefault();const i=document.createRange();i.setStartAfter(n),i.collapse(!0),t.removeAllRanges(),t.addRange(i)}}}}}if(e.shiftKey&&"Tab"===e.key)e.preventDefault(),this.decreaseIndent();else if("Tab"===e.key){const t=this.Utilities.getSelection();if(null!==t&&null!=t.anchorNode){e.preventDefault();const n=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement,i=n?.closest("blockquote"),o=n?.closest("pre"),r=n?.closest("td, th");if(i&&this.content.contains(i)||o&&this.content.contains(o)){let e=o&&this.content.contains(o)?o:i;for(;e.parentNode&&e.parentNode!==this.content;)e=e.parentNode;let n=e.nextSibling;for(;n&&n.nodeType!==Node.ELEMENT_NODE;)n=n.nextSibling;if(n){this.content.focus();const e=document.createRange();e.selectNodeContents(n),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else r&&this.content.contains(r)?this.TableDialog.tableTab():this.increaseIndent()}}}else e.preventDefault()};isBreakable=e=>{let t=!1;switch(e){case"BLOCKQUOTE":case"CODE":case"P":case"SPAN":t=!0}return t};getStructuredBlockFromNode=e=>{if(!e||e===this.content)return null;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;if(!t||!this.content.contains(t))return null;const n=t.closest("pre");if(n&&this.content.contains(n))return n;const i=t.closest("blockquote");return i&&this.content.contains(i)?i:null};insertParagraphAfterStructuredBlock=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return!1;const t=this.getStructuredBlockFromNode(e.anchorNode);if(!t)return!1;const n=document.createElement("p");n.appendChild(document.createElement("br")),t.nextSibling?t.parentNode.insertBefore(n,t.nextSibling):t.parentNode.appendChild(n);const i=document.createRange();return i.setStart(n,0),i.collapse(!0),e.removeAllRanges(),e.addRange(i),this.content.focus(),!0};insertParagraphAtTableBoundary=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;const t=e.getRangeAt(0);if(t.startContainer!==this.content)return!1;const n=t.startOffset,i=this.content.childNodes[n],o=n>0?this.content.childNodes[n-1]:null;if("TABLE"!==i?.nodeName&&"TABLE"!==o?.nodeName)return!1;const r=document.createElement("p");r.appendChild(document.createElement("br")),this.content.insertBefore(r,i??null);const s=document.createRange();return s.setStart(r,0),s.collapse(!0),e.removeAllRanges(),e.addRange(s),this.content.focus(),!0};changeFontSize=e=>{if(void 0===this.fontSize){const e=this.Utilities.getSelection();if(null!==e&&e&&e.rangeCount>0){const t=e.getRangeAt(0),n=window.getComputedStyle(t.commonAncestorContainer.parentElement);this.fontSize=parseFloat(n.fontSize)}}e?this.fontSize+=1:this.fontSize-=1,this.NodeManager.updateNode("size",`${this.fontSize}px`)};openPreview=()=>{this.preview=this.shadowRoot.getElementById(`${this.id}_Preview`);const e=this.shadowRoot.getElementById("rich-text-box-preview");this.preview&&e&&(this.loadPreviewWindow(e),this.addPreviewEventListeners(this.preview),e.dataset.scrollListenerAdded||(e.dataset.scrollListenerAdded="1",e.addEventListener("keydown",t=>{if(!["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"].includes(t.key))return;t.preventDefault();const n=e.shadowRoot?.querySelector("iframe");if(!n?.contentWindow)return;const i=n.contentWindow,o=.9*i.innerHeight,r=i.document.documentElement.scrollHeight,s="ArrowUp"===t.key?-50:"ArrowDown"===t.key?50:"PageUp"===t.key?-o:"PageDown"===t.key?o:"Home"===t.key?-r:r;i.scrollBy({top:s,behavior:"instant"})})),this.preview.showModal(),e.scrollTop=0,e.scrollLeft=0,requestAnimationFrame(()=>e.focus({preventScroll:!0})))};addPreviewEventListeners=e=>{e.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.closePreview()),"Escape"===e.key&&(e.preventDefault(),this.closePreview())})};loadPreviewWindow=e=>{const t="block"===this.content.style.display?this.html()||"":this.source.value||"",n=e.shadowRoot||e.attachShadow({mode:"open"});for(;n.firstChild;)n.removeChild(n.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;}",n.appendChild(i);const o=(this._previewCssUrls||[]).filter(e=>e).map(e=>`<link rel="stylesheet" href="${e.replace(/"/g,"%22")}">`).join(""),r=this._previewCssText?`<style>${this._previewCssText}</style>`:"",s=this._rtbHostElement,l=s?getComputedStyle(s):null,getVar=(e,t)=>(l?l.getPropertyValue(e).trim():"")||t,a=s&&(s.classList.contains("dark")||s.classList.contains("fluent-dark")),d=["<style>",`html{margin:0;background-color:${getVar("--rtb-content-bg","#FFF")};color-scheme:${a?"dark":"light"};}`,"body{margin:0;}","body{",` max-width:${getVar("--rtb-page-width","860px")};margin-left:auto;margin-right:auto;`," 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")};`," overscroll-behavior:contain;","}",`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;min-width:0;}","</style>"].join(""),c=document.createElement("iframe");c.srcdoc=["<!DOCTYPE html><html><head>",'<meta charset="UTF-8">',d,o,r,"</head><body>",t,'<script>document.addEventListener("click",function(e){var a=e.target.closest("a");if(a&&a.href){e.preventDefault();window.open(a.href,"_blank","noopener,noreferrer");}});<\/script>',"</body></html>"].join(""),n.appendChild(c),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus(),this.content.focus()};togglePreviewMaximize=()=>{const e=this.shadowRoot.getElementById(`${this.id}_Preview`),t=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!e||!t)return;const n=!e.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"]];n?(e.setAttribute("data-maximized",""),i.forEach(([t,n])=>e.style.setProperty(t,n))):(e.removeAttribute("data-maximized"),i.forEach(([t])=>e.style.removeProperty(t))),t.setAttribute("aria-label",n?"Restore preview":"Maximize preview"),t.querySelector("svg").innerHTML=n?'<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 e=this.shadowRoot.getElementById(`${this.id}_Preview`),t=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);e&&t&&(e.removeAttribute("data-maximized"),["width","height","max-width","max-height","top","left","transform","border-radius","resize"].forEach(t=>e.style.removeProperty(t)),t.setAttribute("aria-label","Maximize preview"),t.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"/>')};toggleEditorFullscreen=()=>{const e=this.shadowRoot.getElementById("blazing-rich-text-fullscreen-button");if(!e)return;const t=!this.container.classList.contains("rtb-editor-fullscreen");this.container.classList.toggle("rtb-editor-fullscreen",t);const n=this._rtbHostElement;if(t){if(this._editorFullscreenBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",n){n.classList.add("rtb-host-fullscreen"),this._editorFullscreenPopoverValue=n.getAttribute("popover"),n.setAttribute("popover","manual");try{n.showPopover(),this._editorFullscreenUsingPopover=!0}catch{this._editorFullscreenUsingPopover=!1}}}else document.body.style.overflow=this._editorFullscreenBodyOverflow||"",n&&(this._editorFullscreenUsingPopover&&n.matches(":popover-open")&&n.hidePopover(),n.classList.remove("rtb-host-fullscreen"),null===this._editorFullscreenPopoverValue?n.removeAttribute("popover"):n.setAttribute("popover",this._editorFullscreenPopoverValue),this._editorFullscreenUsingPopover=!1);e.setAttribute("aria-label",t?"Restore editor":"Maximize editor"),e.setAttribute("title",t?"Restore Editor":"Maximize Editor"),e.setAttribute("aria-pressed",t?"true":"false"),e.querySelector("svg").innerHTML=t?'<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"/>',requestAnimationFrame(()=>{this._scheduleOverflowUpdate(),this.positionImageResizeHandles(),this.positionTableResizeHandles()})};insertHorizontalRule=()=>{const e=this.Utilities.getSelection();if(!e||!e.rangeCount)return;const t=e.getRangeAt(0);t.deleteContents();let n=t.startContainer;if(n===this.content){const e=this.content.childNodes[t.startOffset]??null,n=document.createElement("hr");return this.content.insertBefore(n,e),this.cleanupHorizontalRuleInsertion(n),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;n.parentNode&&n.parentNode!==this.content;)if(n=n.parentNode,!this.content.contains(n)){const e=document.createElement("hr");return this.content.appendChild(e),this.cleanupHorizontalRuleInsertion(e),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}const i=document.createElement("hr");n&&n!==this.content&&this.content.contains(n)?this.isEmptyHorizontalRuleBlock(n)?n.replaceWith(i):this.content.insertBefore(i,n.nextSibling):this.content.appendChild(i),this.cleanupHorizontalRuleInsertion(i),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};isEmptyHorizontalRuleBlock=e=>e?.nodeType===Node.ELEMENT_NODE&&["P","DIV"].includes(e.nodeName)&&""===e.textContent.replace(/\u200B/g,"").trim()&&!e.querySelector("img, table, video, audio, iframe, canvas, svg, figure, object, embed, hr");removeEmptyLineAfterHorizontalRule=e=>{const t=e?.nextSibling;t&&("BR"!==t.nodeName?this.isEmptyHorizontalRuleBlock(t)&&t.remove():t.remove())};cleanupHorizontalRuleInsertion=e=>{this.removeEmptyLineAfterHorizontalRule(e),requestAnimationFrame(()=>this.removeEmptyLineAfterHorizontalRule(e))};toggleStatusBar=()=>{if(!this.statusBar)return;const e="none"===this.statusBar.style.display;e?(this.statusBar.style.display="",this.updateWordCount()):this.statusBar.style.display="none";const t=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");t&&(t.textContent=e?"Hide Status Bar":"Show Status Bar");try{localStorage.setItem("rtb-status-bar-visible",e?"1":"0")}catch{}};_applyStoredStatusBarVisibility=()=>{try{const e=localStorage.getItem("rtb-status-bar-visible");if(null===e||!this.statusBar)return;const t="1"===e;this.statusBar.style.display=t?"":"none",t&&this.updateWordCount();const n=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");n&&(n.textContent=t?"Hide Status Bar":"Show Status Bar")}catch{}};openFindBar=()=>{this.findBar.style.display="flex";const e=this.findBar.querySelector(".rtb-find-input");requestAnimationFrame(()=>{e.focus(),e.select()})};closeFindBar=()=>{this.findBar.style.display="none",this._findMatches=[],this._findIndex=-1,this._clearFindHighlight(),this.findBar.querySelector(".rtb-find-count").textContent="",this.EditMode?this.content.focus():this.source.focus()};openHelpDialog=()=>{const e=this.shadowRoot.getElementById("rich-text-box-help-modal");e.showModal(),requestAnimationFrame(()=>e.querySelector(".rtb-help-body")?.focus({preventScroll:!0}))};fileMenuAction=e=>{switch(this.closeDropdown("blazing-rich-text-file-button-dropdown"),e){case"open":this.openHtmlFile();break;case"save":this.saveHtml();break;case"find":this.openFindBar();break;case"toggleStatusBar":this.toggleStatusBar();break;case"shortcuts":this.openHelpDialog()}};closeHelpDialog=()=>{this.shadowRoot.getElementById("rich-text-box-help-modal").close(),this._returnFocus()};openEditorContextMenu=e=>{if(!this.EditMode)return;const t=e.target instanceof Element?e.target:e.target?.parentElement;if(!(t instanceof Element&&this.content.contains(t)))return;if("touch"===this._lastPointerType)return void e.preventDefault();e.preventDefault();const n=t.closest("a"),i=t.closest("img"),o=(t.tagName,t.closest("video")),r=t.closest("pre"),s=t.closest("blockquote"),l=t.closest("object"),a=t.closest("table"),d=t.closest("ul"),c=t.closest("ol"),h=t.closest("hr")||(()=>{for(const t of this.content.querySelectorAll("hr")){const n=t.getBoundingClientRect();if(e.clientX>=n.left&&e.clientX<=n.right&&e.clientY>=n.top-10&&e.clientY<=n.bottom+10)return t}return null})();let b,u;n&&this.content.contains(n)?(b=this._buildLinkContextItems(n),u=n):i&&this.content.contains(i)?(b=this._buildImageContextItems(i),u=i):o&&this.content.contains(o)?(b=this._buildVideoContextItems(o),u=o):r&&this.content.contains(r)?(b=this._buildCodeBlockContextItems(r),u=r):s&&this.content.contains(s)?(b=this._buildBlockQuoteContextItems(s),u=s):l&&this.content.contains(l)?(b=this._buildMediaContextItems(l),u=l):a&&this.content.contains(a)?(b=this._buildTableContextItems(a,t),u=a):h&&this.content.contains(h)?(b=this._buildHrContextItems(h),u=h):d&&this.content.contains(d)?(b=this._buildBulletListContextItems(d,t),u=d):c&&this.content.contains(c)?(b=this._buildNumberListContextItems(c,t),u=c):(b=this._buildTextContextItems(t),u=t),b&&0!==b.length&&(!1!==this._rtbHostElement?._visibility?.htmlView&&b.push({divider:!0},{label:"View HTML",icon:"Code",action:()=>this._viewElementHtml(u)}),e.stopPropagation(),this._showContextMenu(e,b))};_buildTextContextItems=e=>{const t=[],n=this._getInlineFormatAtNode(e,"bold"),i=this._getInlineFormatAtNode(e,"italic"),o=this._getInlineFormatAtNode(e,"underline"),r=this._getInlineFormatAtNode(e,"line-through"),s=this._getInlineFormatAtNode(e,"subscript"),l=this._getInlineFormatAtNode(e,"superscript"),a=this._getInlineFormatAtNode(e,"code");let d=!1,c=e instanceof Element?e:e?.parentElement;for(;c&&c!==this.content&&this.content.contains(c);){if(c.style.color||c.style.backgroundColor){d=!0;break}c=c.parentElement}return n&&t.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),i&&t.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),o&&t.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),r&&t.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),s&&t.push({label:"Remove Subscript",icon:"Delete",action:()=>{this.content.focus(),this.subscript()}}),l&&t.push({label:"Remove Superscript",icon:"Delete",action:()=>{this.content.focus(),this.superscript()}}),a&&t.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),d&&t.push({label:"Remove Color",icon:"RemoveTextFormat",action:()=>this.removeTextColor()}),t.length>0&&t.push({divider:!0}),[["Paragraph","p"],["Heading 1","h1"],["Heading 2","h2"],["Heading 3","h3"],["Heading 4","h4"],["Heading 5","h5"],["Heading 6","h6"]].forEach(([e,n])=>{t.push({label:e,icon:"Format",action:()=>{this.content.focus(),this.format(n)}})}),t};_buildLinkContextItems=e=>[{label:"Open Link",icon:"OpenInNew",action:()=>window.open(e.href,"_blank","noopener,noreferrer")},{label:"Edit Link",icon:"CreateLink",action:()=>this._openLinkDialogFromContext(e)},{label:"Remove Link",icon:"RemoveLink",action:()=>this._selectNodeForDialog(e,!0,()=>this.removeLink())}];_buildImageContextItems=e=>[{label:"Edit Image",icon:"Image",action:()=>{const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),e.src?.startsWith("data")?this.uploadImageDialog():this.openImageDialog()}},{label:"Remove Image",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildVideoContextItems=e=>[{label:"Edit Video",icon:"VideoFile",action:()=>this.openVideoDialogForElement(e)},{label:"Remove Video",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildBlockQuoteContextItems=e=>[{label:"Edit Block Quote",icon:"Quote",action:()=>this.openBlockQuoteDialogForElement(e)},{label:"Remove Block Quote",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildCodeBlockContextItems=e=>[{label:"Edit Code Block",icon:"CodeBlocks",action:()=>this.openCodeBlockDialogForElement(e)},{label:"Remove Code Block",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildMediaContextItems=e=>[{label:"Edit Media",icon:"PermMedia",action:()=>this._selectNodeForDialog(e,!1,()=>this.openMediaDialog())},{label:"Remove Media",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildTableContextItems=(e,t)=>{const n=t?.closest("td, th")||null;return[{label:"Edit Table",icon:"Table",action:()=>{const t=e.querySelector("td, th");if(t){const e=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}this.openTableDialog()}},{divider:!0},{label:"Insert Row Above",icon:"ArrowUp",action:()=>this.TableDialog.insertRowAbove(n,e)},{label:"Insert Row Below",icon:"ArrowDown",action:()=>this.TableDialog.insertRowBelow(n,e)},{label:"Insert Column Left",icon:"ArrowLeft",action:()=>this.TableDialog.insertColumnLeft(n,e)},{label:"Insert Column Right",icon:"ArrowRight",action:()=>this.TableDialog.insertColumnRight(n,e)},{divider:!0},{label:"Remove Row",icon:"Delete",action:()=>this.TableDialog.removeRow(n)},{label:"Remove Column",icon:"Delete",action:()=>this.TableDialog.removeColumn(n,e)},{divider:!0},{label:"Remove Table",icon:"Delete",action:()=>this._removeContentElement(e)}]};_buildHrContextItems=e=>[{label:"Remove Horizontal Rule",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildBulletListContextItems=(e,t)=>{const n=[],i=this._getInlineFormatAtNode(t,"bold"),o=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return i&&n.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),o&&n.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),r&&n.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),s&&n.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),l&&n.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),n.length>0&&n.push({divider:!0}),n.push({label:"Remove Bullet List",icon:"Delete",action:()=>{this.content.focus();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=e.querySelector("li");i?n.setStart(i,0):n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.unorderedlist()}}),n};_buildNumberListContextItems=(e,t)=>{const n=[],i=this._getInlineFormatAtNode(t,"bold"),o=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return i&&n.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),o&&n.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),r&&n.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),s&&n.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),l&&n.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),n.length>0&&n.push({divider:!0}),n.push({label:"Remove Number List",icon:"Delete",action:()=>{this.content.focus();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=e.querySelector("li");i?n.setStart(i,0):n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.orderedlist()}}),n};_selectNodeForDialog=(e,t,n)=>{if(!e||!this.content.contains(e))return;const i=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();t?o.selectNodeContents(e):o.selectNode(e),i.removeAllRanges(),i.addRange(o),n()};_openLinkDialogFromContext=e=>{if(!e||!this.content.contains(e))return;const t=this.Utilities.getSelection()||window.getSelection(),n=this.Utilities.saveSelection(t),i=document.createRange();i.selectNodeContents(e),t.removeAllRanges(),t.addRange(i),this.openLinkDialog(),this.savedSelection=n,this.LinkDialog.savedSelection=n};_removeContentElement=e=>{e&&this.content.contains(e)&&(e.remove(),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0})))};_viewElementHtml=async e=>{if(!e||!this.content.contains(e))return;if(await this.getHtml(),e===this.content)return this.source.focus({preventScroll:!0}),this.source.select(),void(this.source.scrollTop=0);if(!this.content.contains(e))return;const t=[];for(let n=e;n&&n!==this.content;n=n.parentNode)t.push(Array.prototype.indexOf.call(n.parentNode.childNodes,n));const n=this.content.cloneNode(!0);let i=n;for(const e of t.reverse())i=i.childNodes[e];if(!(i instanceof Element))return;const o="data-rtb-source-target",r=` ${o}=""`;i.setAttribute(o,"");const normalizeHtml=e=>e.replace(/font-family:\s*&quot;([^"]+?)&quot;;/g,"font-family: '$1';"),s=normalizeHtml(n.innerHTML),l=s.indexOf(r),a=s.lastIndexOf("<",l),d=normalizeHtml(i.outerHTML).replace(r,"");if(l<0||a<0)return;this.source.focus({preventScroll:!0}),this.source.setSelectionRange(a,a+d.length);const c=this.source.value;this.source.value=c.substring(0,a);const h=this.source.scrollHeight;this.source.value=c,this.source.setSelectionRange(a,a+d.length),this.source.scrollTop=h<=this.source.clientHeight?0:Math.max(0,h-this.source.clientHeight/2)};_showContextMenu=(e,t)=>{if(!this.contextMenu)return;this.contextMenu.replaceChildren(...t.map(e=>{if(e.divider){const e=document.createElement("div");return e.className="rtb-context-menu-divider",e}return this._createContextMenuItem(e)})),this.contextMenu.style.display="block",this.contextMenu.setAttribute("aria-hidden","false"),this.contextMenu.style.left="0px",this.contextMenu.style.top="0px";const n=this.contextMenu.getBoundingClientRect(),i=window.visualViewport,o=i?.width||window.innerWidth||document.documentElement.clientWidth,r=i?.height||window.innerHeight||document.documentElement.clientHeight,s=i?.offsetLeft||0,l=i?.offsetTop||0,a=Math.min(Math.max(s+4,e.clientX),s+o-n.width-4),d=Math.min(Math.max(l+4,e.clientY),l+r-n.height-4);this.contextMenu.style.left=a-n.left+"px",this.contextMenu.style.top=d-n.top+"px"};_createContextMenuItem=e=>{const t=document.createElement("button");return t.type="button",t.setAttribute("role","menuitem"),t.innerHTML=`${this._contextMenuIcon(e.icon)}<span>${e.label}</span>`,t.addEventListener("click",t=>{t.stopPropagation(),this.hideContextMenu(),e.action()}),t};_contextMenuIcon=e=>{const t=m[e]||{Format:"M280-160v-80h400v80H280Zm0-160v-80h400v80H280Zm-80-160v-320h560v320H200Zm80-80h400v-160H280v160Z",OpenInNew:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"}[e]||"";return t?`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true" focusable="false"><path d="${t}"/></svg>`:""};hideContextMenu=()=>{this.contextMenu&&(this.contextMenu.style.display="none",this.contextMenu.setAttribute("aria-hidden","true"))};_getInlineFormatAtNode=(e,t)=>{let n=e instanceof Element?e:e?.parentElement;for(;n&&n!==this.content&&this.content.contains(n);){switch(t){case"bold":if("bold"===n.style.fontWeight)return n;break;case"italic":if("italic"===n.style.fontStyle)return n;break;case"underline":if(n.style.textDecoration?.includes("underline"))return n;break;case"line-through":if(n.style.textDecoration?.includes("line-through"))return n;break;case"subscript":if("sub"===n.style.verticalAlign)return n;break;case"superscript":if("super"===n.style.verticalAlign)return n;break;case"code":if("CODE"===n.nodeName&&"PRE"!==n.parentElement?.nodeName)return n}n=n.parentElement}return null};findNext=()=>{const e=this.findBar.querySelector(".rtb-find-input").value;if(!e)return;const t=this._findIndex;this._runSearch(e),this._findMatches.length&&(this._findIndex=(t+1)%this._findMatches.length,this._applyFindMatch())};findPrev=()=>{const e=this.findBar.querySelector(".rtb-find-input").value;if(!e)return;const t=this._findIndex;this._runSearch(e),this._findMatches.length&&(this._findIndex=(t<=0?this._findMatches.length:t)-1,this._applyFindMatch())};_runSearch=e=>{this._findMatches=[],this._findIndex=-1,this._clearFindHighlight();const t=this.findBar.querySelector(".rtb-find-count");if(!e)return void(t.textContent="");const n=e.toLowerCase();if(this.EditMode){const t=document.createTreeWalker(this.content,NodeFilter.SHOW_TEXT);let i;for(;i=t.nextNode();){const t=i.textContent.toLowerCase();let o=0;for(;-1!==(o=t.indexOf(n,o));)this._findMatches.push({node:i,start:o,end:o+e.length}),o++}}else{const t=this.source.value.toLowerCase();let i=0;for(;-1!==(i=t.indexOf(n,i));)this._findMatches.push({start:i,end:i+e.length}),i++}this._findMatches.length||(t.textContent="No results")};_applyFindMatch=()=>{const e=this._findMatches[this._findIndex];if(this.findBar.querySelector(".rtb-find-count").textContent=`${this._findIndex+1} / ${this._findMatches.length}`,this.EditMode){const t=document.createRange();t.setStart(e.node,e.start),t.setEnd(e.node,e.end);const n=this.Utilities.getSelection()||window.getSelection();n.removeAllRanges(),n.addRange(t),this._setFindHighlight(t);const i=t.getBoundingClientRect(),o=this.contentContainer.getBoundingClientRect(),r=this.contentContainer.scrollTop+i.top-o.top-(this.contentContainer.clientHeight-i.height)/2,s=Math.max(0,this.contentContainer.scrollHeight-this.contentContainer.clientHeight);this.contentContainer.scrollTop=Math.min(s,Math.max(0,r))}else{const t=this.source.value;this.source.value=t.substring(0,e.start);const n=this.source.scrollHeight;this.source.value=t,this.source.focus({preventScroll:!0}),this.source.setSelectionRange(e.start,e.end),this.source.scrollTop=n<=this.source.clientHeight?0:Math.max(0,n-this.source.clientHeight/2),this._setSourceFindHighlight(e)}};_setFindHighlight=e=>{"undefined"!=typeof CSS&&CSS.highlights&&"undefined"!=typeof Highlight&&CSS.highlights.set(this._findHighlightName,new Highlight(e.cloneRange()))};_clearFindHighlight=()=>{"undefined"!=typeof CSS&&CSS.highlights&&CSS.highlights.delete(this._findHighlightName),this._sourceFindHighlight&&(this._sourceFindHighlight.style.display="none",this._sourceFindHighlight.replaceChildren())};_setSourceFindHighlight=e=>{if(!this._sourceFindHighlight||!e)return;const t=this.source.value,n=getComputedStyle(this.source),i=document.createTextNode(t.substring(0,e.start)),o=document.createElement("span");o.textContent=t.substring(e.start,e.end),o.style.background="rgba(255, 214, 0, 0.45)",o.style.color="transparent";const r=document.createTextNode(t.substring(e.end));this._sourceFindHighlight.replaceChildren(i,o,r),this._sourceFindHighlight.style.display="none"===this.source.style.display?"none":"block",this._sourceFindHighlight.style.left=`${this.source.offsetLeft}px`,this._sourceFindHighlight.style.top=`${this.source.offsetTop}px`,this._sourceFindHighlight.style.width=`${this.source.clientWidth}px`,this._sourceFindHighlight.style.height=`${this.source.clientHeight}px`,this._sourceFindHighlight.style.minHeight="0",this._sourceFindHighlight.style.overflow="hidden",this._sourceFindHighlight.style.boxSizing=n.boxSizing,this._sourceFindHighlight.style.padding=n.padding,this._sourceFindHighlight.style.border=`${n.borderTopWidth} solid transparent`,this._sourceFindHighlight.style.font=n.font,this._sourceFindHighlight.style.letterSpacing=n.letterSpacing,this._sourceFindHighlight.style.lineHeight=n.lineHeight,this._sourceFindHighlight.style.whiteSpace=n.whiteSpace,this._sourceFindHighlight.style.overflowWrap=n.overflowWrap,this._sourceFindHighlight.style.tabSize=n.tabSize,this._sourceFindHighlight.style.textAlign=n.textAlign,this._sourceFindHighlight.style.textIndent=n.textIndent,this._sourceFindHighlight.style.textTransform=n.textTransform,this._sourceFindHighlight.style.wordBreak=n.wordBreak,this._sourceFindHighlight.scrollTop=this.source.scrollTop,this._sourceFindHighlight.scrollLeft=this.source.scrollLeft};_setStatusLink=(e="")=>{if(this.statusLink){if(clearTimeout(this._statusLinkFadeTimer),e)return this.statusLink.textContent=e,this.statusLink.title=e,void this.statusLink.classList.add("rtb-status-link-visible");this.statusLink.classList.remove("rtb-status-link-visible"),this._statusLinkFadeTimer=setTimeout(()=>{this.statusLink.classList.contains("rtb-status-link-visible")||(this.statusLink.textContent="",this.statusLink.title="")},100)}};_updateStatusLinkFromNode=e=>{const t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement,n=t?.closest?.("a");this._setStatusLink(n&&this.content.contains(n)?n.href:"")};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const e=this.content.innerText||"",t=e.trim(),n=t?t.split(/\s+/).length:0,i=e.replace(/\n/g,"").length,fmt=e=>e.toLocaleString();this.statusCount.textContent=`${fmt(n)} word${1!==n?"s":""} · ${fmt(i)} character${1!==i?"s":""}`};_syncWordCountVisibility=()=>{const e=!1!==this._rtbHostElement?._visibility?.wordCount;this.statusBar&&(this.statusBar.style.display=e?"":"none");const t=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");t&&(t.textContent=e?"Hide Status Bar":"Show Status Bar")};setReadOnly=e=>{this.content.contentEditable=e?"false":"true",this.content.setAttribute("aria-readonly",e?"true":"false");const t=this.shadowRoot.querySelector(`#${CSS.escape(this.toolbar_id)}`);t&&(t.style.display=e?"none":"")};saveHtml=()=>{const e="block"===this.content.style.display?this.html()||"":this.source.value||"",t=new Blob([e],{type:"text/html"}),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=this.createTimestampedHtmlFileName(),i.click(),URL.revokeObjectURL(n)};openHtmlFile=()=>{this.openFileInput.click()};openDroppedOrSelectedHtmlFile=e=>{if(!e)return;if(!("text/html"===e.type||/\.(html|htm)$/i.test(e.name)))return void this.Utilities.showFadingBar("Please choose an HTML file.");const t=new FileReader;t.onload=()=>{const e=t.result||"";"block"===this.source.style.display?(this.loadInnerText(e),this.source.style.display="block",this.content.style.display="none",this.source.focus()):(this.loadHtml(e),this.content.style.display="block",this.source.style.display="none",this.content.focus(),this.StateManager.saveState())},t.readAsText(e)};dragEventHasHtmlFile=e=>{const t=Array.from(e.dataTransfer?.items||[]);if(t.length>0)return t.some(e=>"file"===e.kind&&("text/html"===e.type||""===e.type));return Array.from(e.dataTransfer?.files||[]).some(e=>"text/html"===e.type||/\.(html|htm)$/i.test(e.name))};createTimestampedHtmlFileName=()=>{const e=new Date,pad=e=>String(e).padStart(2,"0");return`html-${[e.getFullYear(),pad(e.getMonth()+1),pad(e.getDate())].join("-")+"_"+[pad(e.getHours()),pad(e.getMinutes()),pad(e.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=e=>{this.NodeManager.formatNode(e),this.closeDropdown("blazing-rich-text-format-button-dropdown")};dropdown=(e,t=!1)=>{const n=this.shadowRoot.getElementById(e);null!=n&&n.classList.contains("rich-text-box-show")?n.classList.remove("rich-text-box-show"):(this.NodeManager.closeDropdowns(),n.classList.add("rich-text-box-show"),this.sizeToolbarDropdown(n),t&&this.focusFirstToolbarMenuItem(n))};openToolbarDropdown=(e,t=!1)=>{const n=this.shadowRoot.getElementById(e);n&&(this.NodeManager.closeDropdowns(),n.classList.add("rich-text-box-show"),this.sizeToolbarDropdown(n),t&&this.focusFirstToolbarMenuItem(n))};sizeToolbarDropdown=e=>{if(!this.isResponsiveToolbarDropdown(e))return;e.style.maxHeight="";const t=this.contentContainer.getBoundingClientRect().bottom,n=e.getBoundingClientRect().top,i=Math.floor(t-n-12);i>0&&(e.style.maxHeight=`${i}px`)};isResponsiveToolbarDropdown=e=>!!e&&["blazing-rich-text-file-button-dropdown","blazing-rich-text-font-button-dropdown","blazing-rich-text-size-button-dropdown","blazing-rich-text-format-button-dropdown","blazing-rich-text-insert-button-dropdown"].includes(e.id);resizeOpenToolbarDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content.rich-text-box-show").forEach(e=>{this.isResponsiveToolbarDropdown(e)&&this.sizeToolbarDropdown(e)})};increaseIndent=()=>{if(this.indentSelectedResizeTable(!0))return;this.content.focus(),this.selectedResizeImage&&this.selectResizeImageRange();const e=this.Utilities.getSelection();if(!this.isSelectionInsideEditor(e))return;const t=this.ListProvider.getList(e.anchorNode);t?this.ListProvider.increaseIndent(e,t):this.NodeManager.indentBlock(e,!0),this.selectedResizeImage&&(this.trackImageResizeTransition(),this.clearResizeImageRange())};decreaseIndent=()=>{if(this.indentSelectedResizeTable(!1))return;this.content.focus(),this.selectedResizeImage&&this.selectResizeImageRange();const e=this.Utilities.getSelection();if(!this.isSelectionInsideEditor(e))return;const t=this.ListProvider.getList(e.anchorNode);t?this.ListProvider.decreaseIndent(e,t):this.NodeManager.indentBlock(e,!1),this.selectedResizeImage&&(this.trackImageResizeTransition(),this.clearResizeImageRange())};openTextColorDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(e),e){const t=this.ColorPickers["rich-text-box-text-color-modal"];this.selection=t.openColorPicker(e,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextColor=e=>{this.ColorPickers["rich-text-box-text-color-modal"].selectColor(e)};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.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(e),null!==e){const t=this.ColorPickers["rich-text-box-text-bg-color-modal"];this.selection=t.openColorPicker(e,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextBackgroundColor=e=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].selectColor(e)};insertTextBackgroundColor=()=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].insertColor()};openTableDialog=()=>{const e=this.selectedResizeTable;if(e&&this.content.contains(e))return void this.openTableDialogForElement(e);this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.TableDialog.openTableDialog(t):this.Utilities.showFadingBar("No content selected.")};openTableDialogForElement=e=>{if(!e||"TABLE"!==e.nodeName||!this.content.contains(e))return;this.hideTableResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),this.savedSelection=this.Utilities.saveSelection(t),this.TableDialog.openTableDialogForElement(e,n)};insertTable=()=>{this.TableDialog.insertTable()};font=e=>{this.NodeManager.updateNode("font",e),this.closeDropdown("blazing-rich-text-font-button-dropdown")};size=e=>{this.clearSettings(),this.NodeManager.updateNode("size",e),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")};inlinecode=()=>{const e=this.Utilities.getSelection();if(!e)return;let t=e.anchorNode instanceof Element?e.anchorNode:e.anchorNode?.parentElement;for(;t&&t!==this.content&&this.content.contains(t);){if("CODE"===t.nodeName&&"PRE"!==t.parentElement?.nodeName)return t.replaceWith(...t.childNodes),void this.NodeManager.refreshUI();t=t.parentElement}if(e.toString().length>0&&e.rangeCount>0){const t=e.getRangeAt(0),n=document.createElement("code");n.appendChild(t.cloneContents()),t.deleteContents(),t.insertNode(n),t.selectNodeContents(n),e.removeAllRanges(),e.addRange(t),this.NodeManager.refreshUI()}};alignleft=()=>{this.alignSelectedResizeImage("alignleft")||this.alignSelectedResizeTable("alignleft")||this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.alignSelectedResizeImage("aligncenter")||this.alignSelectedResizeTable("aligncenter")||this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.alignSelectedResizeImage("alignright")||this.alignSelectedResizeTable("alignright")||this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.alignSelectedResizeImage("alignjustify")||this.alignSelectedResizeTable("alignjustify")||this.NodeManager.updateNode("alignjustify")};copy=()=>this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)?(this._imageClipboardHtml=this.selectedResizeImage.outerHTML,this._tableClipboardHtml=null,this.selectResizeImageRange(),void document.execCommand("copy")):this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)?(this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this.selectResizeTableRange(),void document.execCommand("copy")):(this.ActionOptions.copy(),void this.NodeManager.refreshUI());cut=()=>{if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){this._imageClipboardHtml=this.selectedResizeImage.outerHTML,this._tableClipboardHtml=null,this.selectResizeImageRange(),document.execCommand("copy");const e=this.selectedResizeImage;return this.hideImageResizeHandles(),void e.remove()}if(this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)){this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this.selectResizeTableRange(),document.execCommand("copy");const e=this.selectedResizeTable;return this.hideTableResizeHandles(),void e.remove()}this.ActionOptions.cut(),this.NodeManager.refreshUI()};paste=()=>{if(this._imageClipboardHtml){const e=document.createElement("template");e.innerHTML=this._imageClipboardHtml.trim();const t=e.content.firstElementChild;if("IMG"===t?.nodeName){if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage))this.selectedResizeImage.replaceWith(t);else{this.content.focus();const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const n=e.getRangeAt(0);n.deleteContents(),n.insertNode(t),n.setStartAfter(t),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}this.showImageResizeHandles(t)}return}if(this._tableClipboardHtml){const e=document.createElement("template");e.innerHTML=this._tableClipboardHtml.trim();const t=e.content.firstElementChild;if("TABLE"===t?.nodeName){if(this.selectedResizeTable&&this.content.contains(this.selectedResizeTable))this.selectedResizeTable.replaceWith(t);else{this.content.focus();const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const n=e.getRangeAt(0);n.deleteContents(),n.insertNode(t),n.setStartAfter(t),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}this.showTableResizeHandles(t)}return}this.NodeManager.allSelected&&this.delete(),this.content.focus(),document.execCommand("paste")};_returnFocus=()=>{!1===this.EditMode?this.source.focus():this.content.focus()};_focusEditor=()=>{this.content.focus();const e=this.shadowRoot.getSelection();if(!e||0===e.rangeCount||!this.content.contains(e.anchorNode)){const t=document.createRange(),n=this.content.lastChild;n?(t.selectNodeContents(n),t.collapse(!1)):(t.setStart(this.content,0),t.collapse(!0)),e&&(e.removeAllRanges(),e.addRange(t))}};closeDropdown=e=>{this.shadowRoot.getElementById(e).classList.remove("rich-text-box-show"),this.lockToolbar=!1,this._returnFocus()};delete=()=>{if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){const e=this.selectedResizeImage;return this.hideImageResizeHandles(),e.remove(),void this.NodeManager.refreshUI()}const e=this.Utilities.getSelection();if(null!==e){if(this._selectAllActive||this.NodeManager.allSelected()){this.content.replaceChildren(),this._selectAllActive=!1;const t=document.createRange();return t.setStart(this.content,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),void this.NodeManager.refreshUI()}e.deleteFromDocument(),this._selectAllActive=!1,this.NodeManager.refreshUI()}};selectall=()=>{const e=document.createRange();e.selectNodeContents(this.content),this.content.focus();const t=this.Utilities.getSelection();null!==t&&(t.removeAllRanges(),t.addRange(e),this._selectAllActive=!0,this.content.focus())};orderedlist=()=>{this.toggleListForSelectedResizeImage("OL")||this.toggleListForSelectedResizeTable("OL")||this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.toggleListForSelectedResizeImage("UL")||this.toggleListForSelectedResizeTable("UL")||this.ListProvider.addlist("UL"),this.NodeManager.refreshUI()};openLinkDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.LinkDialog.openLinkDialog(e):this.Utilities.showFadingBar("No content selected.")};insertLink=()=>{this.LinkDialog.insertLink(),this.NodeManager.refreshUI()};removeLink=()=>{this.LinkDialog.removeLink()};openBlockQuoteDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.BlockQuoteDialog.openBlockQuoteDialog(e):this.Utilities.showFadingBar("No content selected.")};openBlockQuoteDialogForElement=e=>{if(!e||"BLOCKQUOTE"!==e.nodeName||!this.content.contains(e))return;this.lockToolbar=!0;const t=this.Utilities.getSelection()||window.getSelection();this.savedSelection=this.Utilities.saveSelection(t);const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.BlockQuoteDialog.openBlockQuoteDialogForElement(e,n)};insertBlockQuote=()=>{this.BlockQuoteDialog.insertBlockQuote(),this.NodeManager.refreshUI()};openCodeBlockDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.CodeBlockDialog.openCodeBlockDialog(e):this.Utilities.showFadingBar("No content selected.")};openCodeBlockDialogForElement=e=>{if(!e||"PRE"!==e.nodeName||!this.content.contains(e))return;const t=e.querySelector("code")||e;this.lockToolbar=!0;const n=this.Utilities.getSelection()||window.getSelection();this.savedSelection=this.Utilities.saveSelection(n);const i=document.createRange();i.selectNodeContents(t),n.removeAllRanges(),n.addRange(i),this.CodeBlockDialog.openCodeBlockDialogForElement(e,i)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.MediaDialog.openMediaDialog(e):this.Utilities.showFadingBar("No content selected.")};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.VideoDialog.openVideoDialog(e):this.Utilities.showFadingBar("No content selected.")};openVideoDialogForElement=e=>{this.lockToolbar=!0;const t=this.Utilities.getSelection(),n=this.Utilities.saveSelection(t);this.savedSelection=n,this.VideoDialog.openVideoDialogForElement(e,n)};insertVideo=()=>{this.VideoDialog.insertVideo(),this.NodeManager.refreshUI()};uploadImageDialog=()=>{this.hideImageResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const e=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(e),null!==e?this.UploadImageDialog.openUploadImageDialog(e):this.Utilities.showFadingBar("No content selected.")};uploadImage=()=>{this.UploadImageDialog.insertUploadedImage()};openImageDialog=()=>{const e=this.selectedResizeImage;if(e&&this.content.contains(e))return void this.openImageDialogForElement(e);this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns(),this._focusEditor();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.ImageDialog.openImageDialog(t):this.Utilities.showFadingBar("No content selected.")};openImageDialogForElement=e=>{if(!e||"IMG"!==e.nodeName||!this.content.contains(e))return;this.hideImageResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),this.savedSelection=this.Utilities.saveSelection(t),this.ImageDialog.openImageDialogForElement(e,n)};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeImageDialog=(e,t)=>{if(this.lockToolbar=!1,!e||!this.content.contains(e))return void this.Utilities.closeDialog("rich-text-box-image-modal",t);this.Utilities.closeDialog("rich-text-box-image-modal",null);const n=this.Utilities.getSelection()||window.getSelection();n?.removeAllRanges(),requestAnimationFrame(()=>this.showImageResizeHandles(e))};closeTableDialog=(e,t)=>{if(this.lockToolbar=!1,!e||!this.content.contains(e))return void this.Utilities.closeDialog("rich-text-box-table-modal",t);this.Utilities.closeDialog("rich-text-box-table-modal",null);const n=this.Utilities.getSelection()||window.getSelection();n?.removeAllRanges(),requestAnimationFrame(()=>this.showTableResizeHandles(e))};closeDialog=e=>{"rich-text-box-image-modal"!==e?"rich-text-box-table-modal"!==e?(this.lockToolbar=!1,this.Utilities.closeDialog(e,this.savedSelection)):this.TableDialog.closeDialog():this.ImageDialog.closeDialog()};enableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(e=>e.disabled=!1);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(e=>e.disabled=!1)};disableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(e=>e.disabled=!0);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(e=>e.disabled=!0)};toggleView=()=>{!0===this.EditMode?this.getHtml():this.getCode()};getHtml=async()=>{this.hideImageResizeHandles(),this.hideTableResizeHandles(),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 e=this.html();this.loadInnerText(e),this.content.style.display="none",this.contentContainer.classList.add("rtb-source-view"),this.source.style.display="block",this.source.focus(),this.Utilities.restoreScroll(this.source,this.sourceScroll),this.disableButtons(),"none"!==this.findBar.style.display&&this._runSearch(this.findBar.querySelector(".rtb-find-input").value)};getCode=async()=>{this.sourceScroll=this.Utilities.saveScroll(this.source);const e=this.source.value;this.loadHtml(e),this.content.style.display="block",this.source.style.display="none",this.contentContainer.classList.remove("rtb-source-view"),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()),"none"!==this.findBar.style.display&&this._runSearch(this.findBar.querySelector(".rtb-find-input").value)};html=()=>(this.NodeManager.removeEmptyNodes(),this.content.innerHTML.replace(/font-family:\s*&quot;([^"]+?)&quot;;/g,"font-family: '$1';"));loadView=e=>{!0===this.EditMode?this.loadHtml(e):this.loadInnerText(e)};loadHtml=e=>{this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.EditMode=!0;const t=this.shadowRoot.getElementById("blazing-rich-text-source");t&&(t.classList.remove("selected"),t.setAttribute("aria-pressed","false")),this.content.innerHTML=null!=e?e:"",this.NodeManager.clearButtons(),this.updateWordCount()};loadInnerText=e=>{this.EditMode=!1;const t=this.shadowRoot.getElementById("blazing-rich-text-source");t&&(t.classList.add("selected"),t.setAttribute("aria-pressed","true")),this.source.value=null!=e?e:"",this.NodeManager.clearButtons()};insertEmoji=e=>{if(!0!==this.EditMode||!e)return;this.NodeManager.createDefaultElement();const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0);if(!this.content.contains(n.commonAncestorContainer))return;n.deleteContents();const i=document.createTextNode(e);n.insertNode(i),n.setStartAfter(i),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.content.focus(),this.NodeManager.closeDropdowns(),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};plaintext=()=>this.content.textContent;setDefaultParagraphSeparator=()=>{try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(e){}};toggleOverflowOptions=(e=!1)=>{this.isOverflowOptionsVisible()&&(this._overflowBtn.click(),e&&this._overflowDropdown?.classList.contains("rtb-overflow-open")&&this.focusFirstToolbarMenuItem(this._overflowDropdown))};openOverflowOptions=(e=!1)=>{this.isOverflowOptionsVisible()&&(this.NodeManager.closeDropdowns(),this._overflowDropdown.classList.add("rtb-overflow-open"),this._overflowBtn.setAttribute("aria-expanded","true"),this._overflowToolbar&&(this._overflowDropdown.style.maxWidth=this._overflowToolbar.offsetWidth-10+"px"),e&&this.focusFirstToolbarMenuItem(this._overflowDropdown))}}class t{constructor(e,t,n,i,o){this.content=e,this.source=t,this.Utilities=n,this.dotNetObjectReference=i,this.contentContainer=o,this.history=[],this.currentIndex=-1,this.currentIndex=-1,this.isNavigating=!1,this.mutationObserver()}mutationObserver=()=>{new MutationObserver((e,t)=>{if("block"!==this.content.style.display||this.isNavigating)this.isNavigating=!1,this.updateBinding();else for(let t of e)switch(t.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 e={html:this.content.innerHTML,selection:this.saveSelection(),scroll:this.Utilities.saveScroll(this.contentContainer)};this.PreviousHtml=this.content.innerHTML,-1!==this.currentIndex&&e===this.history[this.currentIndex]||(this.history=this.history.slice(0,this.currentIndex+1),this.history.push(e),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 e=this.Utilities.getSelection();if(e&&e.rangeCount>0){const t=e.getRangeAt(0),n=t.cloneRange();n.selectNodeContents(this.content),n.setEnd(t.startContainer,t.startOffset);const i=n.toString().length;return{start:i,end:i+t.toString().length}}return null};restoreSelection=e=>{if(e)try{const charIndex=(e,t)=>{let n=0;if(e.nodeType===Node.TEXT_NODE)return t<=e.length?[e,t]:[null,t-e.length];for(let i=0;i<e.childNodes.length;i++){const o=e.childNodes[i],[r,s]=charIndex(o,t-n);if(r)return[r,s];n+=o.textContent.length}return[null,t-n]},t=document.createRange();let[n,i]=charIndex(this.content,e.start),[o,r]=charIndex(this.content,e.end);if(n&&o){t.setStart(n,i),t.setEnd(o,r);const e=window.getSelection();e.removeAllRanges(),e.addRange(t)}}catch(e){}};restoreState=e=>{this.content.innerHTML=e.html,this.restoreSelection(e.selection),this.Utilities.restoreScroll(this.contentContainer,e.scroll),this.content.focus()}}class n{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n}_press=(e,t=!0)=>{e&&(e.classList.toggle("selected",t),e.setAttribute("aria-pressed",t?"true":"false"))};formatNode=e=>{let t,n;if(t=this.Utilities.getSelection(),null!==t){if(!this.isSelectionInsideContent(t))return;let i;if(0==t.toString().length)null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&this.content.contains(t.anchorNode.parentNode)&&(i=this.getElementByType(t.anchorNode.parentNode,"Format"));else if(1==this.hasCommonAncestor(t)){i=t.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else i=this.getElementByContent(t.anchorNode,e,t);if(null!=i&&i!=this.content&&null!=i.parentNode&&this.content.contains(i.parentNode)){if("none"==e){let e=this.Utilities.saveCaretPosition();const t=document.createElement("div");for(let e=0;e<i.style.length;e++){const n=i.style[e];t.style[n]=i.style[n]}for(;i.firstChild;)t.appendChild(i.firstChild);i.parentNode.replaceChild(t,i),this.Utilities.restoreCaretPosition(t,e)}else{let t=this.Utilities.saveCaretPosition();const n=document.createElement(e);n.innerHTML=i.innerHTML;const o=window.getComputedStyle(i);for(let e=0;e<o.length;e++){let t=o[e],r=i.style.getPropertyValue(t);""!==r&&(n.style[t]=r)}i.parentNode.replaceChild(n,i),this.Utilities.restoreCaretPosition(n,t)}return}if(t.toString().length>0){let i;switch(e){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&&t.rangeCount>0&&(n=t.getRangeAt(0),this.hasInvalidElementsInSelection(t)||(i.appendChild(n.cloneContents()),n.deleteContents(),n.insertNode(i),n.selectNodeContents(i),t.removeAllRanges(),t.addRange(n)))}}};updateNode=(e,t,n)=>{let i,o;if(i=this.Utilities.getSelection(),i||n){if(i&&n?(i.removeAllRanges(),i.addRange(n)):n&&(i=window.getSelection(),i.removeAllRanges(),i.addRange(n)),!this.isSelectionInsideContent(i))return;let r;if(this.isCommonAncestor=!1,0==i.toString().length){if("alignleft"===e||"aligncenter"===e||"alignright"===e||"alignjustify"===e){const e=i.anchorNode instanceof Element?i.anchorNode:i.anchorNode?.parentElement;let t=e?.closest("table");if(!t&&i.rangeCount>0){const e=i.getRangeAt(0);if(e.collapsed&&e.startContainer===this.content){const n=e.startOffset,i=this.content.childNodes[n],o=n>0?this.content.childNodes[n-1]:null;"TABLE"===i?.nodeName?t=i:"TABLE"===o?.nodeName&&(t=o)}}t&&this.content.contains(t)&&(r=t)}if(null==r&&(r=this.getElementByStyle(i.anchorNode,e)),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 e=i.anchorNode.querySelector("table");null!=e&&(r=e)}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,e,i);if(null!=r){let n;switch(e){case"textcolor":"None"==t?(n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"color",n.style.getPropertyValue("color"))):r.style.setProperty("color",t);break;case"textbgcolor":"None"==t?(n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"background-color",n.style.getPropertyValue("background-color"))):r.style.setProperty("background-color",t);break;case"font":if("None"==t)n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"font-family");else{const e=t.includes(" ")?`'${t}'`:t;r.style.setProperty("font-family",e)}break;case"size":"None"==t?(n=this.getElementByStyle(r,e),null!=n&&this.removeProperty(n,"font-size")):r.style.setProperty("font-size",t);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"!=t&&!this.isExcluded(i)){let n;switch(e){case"textcolor":n=this.createElement(i),n.style.color=t;break;case"textbgcolor":n=this.createElement(i),n.style.backgroundColor=t;break;case"font":n=this.createElement(i),n.style.fontFamily=t;break;case"size":n=this.createElement(i),n.style.fontSize=t;break;case"bold":n=this.createElement(i),n.style.fontWeight="bold";break;case"italic":n=this.createElement(i),n.style.fontStyle="italic";break;case"underline":n=this.createElement(i),this.addTextDecoration(n,"underline");break;case"line-through":n=this.createElement(i),this.addTextDecoration(n,"line-through");break;case"subscript":n=this.createElement(i),n.style.verticalAlign="sub";break;case"superscript":n=this.createElement(i),n.style.verticalAlign="super";break;case"alignleft":n=document.createElement("div"),n.style.textAlign="left";break;case"aligncenter":n=document.createElement("div"),n.style.textAlign="center";break;case"alignright":n=document.createElement("div"),n.style.textAlign="right";break;case"alignjustify":n=document.createElement("div"),n.style.textAlign="justify"}null!=n&&0!=i.rangeCount&&(o=i.getRangeAt(0),n.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(n),o.selectNodeContents(n),i.removeAllRanges(),i.addRange(o),this.selection=null,this.refreshUI())}}};alignTable=(e,t)=>{if("aligncenter"===t){const t=`${(getComputedStyle(this.content).getPropertyValue("--rtb-table-margin").trim()||"1.2em 0").split(/\s+/)[0]||"1.2em"} auto`;return void(e.style.margin===t?this.removeProperty(e,"margin",t):(e.style.removeProperty("margin-left"),e.style.removeProperty("margin-right"),e.style.setProperty("margin",t)))}"alignright"!==t?"alignleft"!==t&&"alignjustify"!==t||("auto"===e.style.marginRight&&"auto"!==e.style.marginLeft?this.removeProperty(e,"margin-right","auto"):(e.style.removeProperty("margin"),e.style.removeProperty("margin-left"),e.style.setProperty("margin-right","auto"))):"auto"===e.style.marginLeft&&"auto"!==e.style.marginRight?this.removeProperty(e,"margin-left","auto"):(e.style.removeProperty("margin"),e.style.removeProperty("margin-right"),e.style.setProperty("margin-left","auto"))};isSelectionInsideContent=e=>{if(!e||0===e.rangeCount)return!1;const t=e.getRangeAt(0),containsNode=e=>!!e&&(e===this.content||this.content.contains(e));return containsNode(t.startContainer)&&containsNode(t.endContainer)&&(!e.anchorNode||containsNode(e.anchorNode))&&(!e.focusNode||containsNode(e.focusNode))};isExcluded=e=>{if(e.anchorNode&&e.anchorNode.querySelector){const t=e.anchorNode.querySelector("table");if(null!=t&&e.toString().trim()!==t.innerText.trim())return!0}if(e.anchorNode.parentNode!==this.content)switch(e.anchorNode.parentNode.nodeName){case"TD":case"CODE":case"PRE":return!0}return!1};indentBlock=(e,t)=>{if(!e||!e.anchorNode||!this.content.contains(e.anchorNode))return;let n=e.anchorNode;for(;n&&n!==this.content&&!this.applyMargin(n,t);)n=n.parentNode};applyMargin=(e,t)=>{if(e.nodeType===Node.ELEMENT_NODE&&["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"].includes(e.nodeName)){const n=window.getComputedStyle(e).marginLeft,i=parseFloat(n)||0,o=40;return t?e.style.marginLeft=`${i+o}px`:i<=o?(e.style.marginLeft="",e.hasAttribute("style")&&(e.getAttribute("style")||e.removeAttribute("style"))):e.style.marginLeft=i-o+"px",!0}return!1};selectButtons=e=>{if(e===this.content){const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&t.isCollapsed){const n=t.getRangeAt(0);if(n.startContainer===this.content){const t=n.startOffset,i=this.content.childNodes[t],o=t>0?this.content.childNodes[t-1]:null;"TABLE"===i?.nodeName?e=i:"TABLE"===o?.nodeName&&(e=o)}}}if(null==e||e==this.content||!this.content.contains(e)||1==this.lockToolbar)return;this.clearButtons();const t=this.getButton("blazing-rich-text-bold-button"),n=this.getButton("blazing-rich-text-italic-button"),i=this.getButton("blazing-rich-text-underline-button"),o=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"),d=this.getButton("blazing-rich-text-alignright-button"),c=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"),p=this.getButton("blazing-rich-text-text-bg-color-button"),x=this.getButton("blazing-rich-text-textcolor-remove-button"),f=this.getButton("blazing-rich-text-quote-button"),v=this.getButton("blazing-rich-text-code-block-button"),y=this.getButton("blazing-rich-text-inline-code-button"),w=this.getButton("blazing-rich-text-table-button"),C=this.getButton("blazing-rich-text-image-button"),R=this.getButton("blazing-rich-text-image-upload-button"),E=this.getButton("blazing-rich-text-embed-button"),N=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 T=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=T&&(T.innerText="Font",this.fontSelected=!1);const z=this.shadowRoot.getElementById("blazing-rich-text-size-button");for(null!=z&&(z.innerText="Size",this.fontSizeSelected=!1);e!==this.content&&null!==e.parentNode&&this.content.contains(e.parentNode)&&"#text"!=e.parentNode.nodeName&&"#document"!=e.parentNode.nodeName;){let I=window.getComputedStyle(e.parentNode);const _="TABLE"===e.nodeName?e:e.parentNode.closest?.("table"),D=null!=_;if(null!=e.parentNode.style&&"bold"==e.parentNode.style.fontWeight&&this._press(t),null!=e.parentNode.style&&e.parentNode.style.color&&this._press(m),null!=e.parentNode.style&&e.parentNode.style.backgroundColor&&this._press(p),(null!=e.parentNode.style&&e.parentNode.style.color||e.parentNode.style.backgroundColor)&&this._press(x),"italic"==I.getPropertyValue("font-style")&&this._press(n),I.getPropertyValue("text-decoration").includes("underline")&&"A"!=e.parentNode.nodeName&&this._press(i),I.getPropertyValue("text-decoration").includes("line-through")&&this._press(o),"sub"==I.getPropertyValue("vertical-align")&&this._press(r),"super"==I.getPropertyValue("vertical-align")&&this._press(s),_&&!this.textAlign&&("auto"===_.style.marginLeft&&"auto"===_.style.marginRight?(this._press(a),this.textAlign=!0):"auto"===_.style.marginLeft?(this._press(d),this.textAlign=!0):"auto"===_.style.marginRight&&(this._press(l),this.textAlign=!0)),D||"left"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(l),this.textAlign=!0),D||"center"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),D||"right"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),D||"justify"!=I.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),null!=e&&null!=e.style&&e.style.fontFamily&&!this.fontSelected&&(T.innerText=e.style.fontFamily.replace(/^(["'])(.*)\1$/,"$2"),this.fontSelected=!0),null!=e&&null!=e.style&&e.style.fontSize&&!this.fontSizeSelected&&(z.innerText=e.style.fontSize,this.fontSizeSelected=!0),"P"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Paragraph",this.formatSelected=!0),"H1"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 1",this.formatSelected=!0),"H2"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 2",this.formatSelected=!0),"H3"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 3",this.formatSelected=!0),"H4"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 4",this.formatSelected=!0),"H5"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 5",this.formatSelected=!0),"H6"!=e.parentNode.nodeName||this.formatSelected||null==S||(S.innerText="Header 6",this.formatSelected=!0),"A"==e.parentNode.nodeName&&(this._press(u),this._press(g)),"BLOCKQUOTE"==e.parentNode.nodeName&&this._press(f),"CODE"==e.parentNode.nodeName&&("PRE"!==e.parentNode.parentElement?.nodeName?this._press(y):this._press(v)),"TD"!=e.parentNode.nodeName&&"TH"!=e.parentNode.nodeName||this._press(w),"OL"==e.parentNode.nodeName&&this._press(h),"UL"==e.parentNode.nodeName&&this._press(b),"VIDEO"!==e.nodeName&&"SOURCE"!==e.nodeName||N&&this._press(N),e.querySelector){const t=e.querySelector("img");t&&(t.src.startsWith("data")?this._press(R):this._press(C));e.querySelector("object")&&this._press(E);e.querySelector("video")&&N&&this._press(N)}e=e.parentNode}this.closeDropdowns()};closeDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-menu-item.active, .rich-text-box-menu-item-special.active, .rich-text-box-insert-item.active, .rtb-overflow-dropdown button.active").forEach(e=>e.classList.remove("active"));this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(function(e){e.classList.contains("rich-text-box-show")&&e.classList.remove("rich-text-box-show")});const e=this.shadowRoot.querySelector(".rtb-overflow-dropdown");if(e&&e.classList.contains("rtb-overflow-open")){e.classList.remove("rtb-overflow-open");const t=this.shadowRoot.querySelector(".rtb-overflow-btn");t&&t.setAttribute("aria-expanded","false")}};getButton=e=>this.shadowRoot.getElementById(e);refreshUI=()=>{if(this.removeEmptyNodes(),""===this.content.innerHTML.trim())return this.clearButtons(),void this.content.focus();const e=this.Utilities.getSelection();null!==e&&this.selectButtons(e.anchorNode),this.content.focus()};removeEmptyNodes=()=>{const e=this.content;if(e){e.querySelectorAll("*").forEach(e=>{e.hasChildNodes()&&(1!==e.childNodes.length||3!==e.childNodes[0].nodeType||/\S/.test(e.textContent))||e.parentElement&&!this.isNotRemovable(e.nodeName)&&e.parentElement.removeChild(e)})}};createDefaultElement=()=>{if(""===this.content.innerHTML.trim()){const e=document.createElement("p");e.style.overflowWrap="break-word";const t=document.createElement("br");e.appendChild(t),this.content.appendChild(e)}};allSelected=()=>{const e=this.Utilities.getSelection();if(null!==e){if(0===e.rangeCount)return!1;const t=e.getRangeAt(0),n=document.createRange();return n.selectNodeContents(this.content),t.startContainer===n.startContainer&&t.startOffset===n.startOffset&&t.endContainer===n.endContainer&&t.endOffset===n.endOffset}return!1};clearButtons=()=>{this.closeDropdowns();this.shadowRoot.querySelectorAll(".rich-text-box-menu-item, .rich-text-box-menu-item-special").forEach(function(e){e.classList.remove("selected"),e.setAttribute("aria-pressed","false")});const e=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=e&&(e.innerText="Format",this.formatSelected=!1);const t=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=t&&(t.innerText="Font",this.fontSelected=!1);const n=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=n&&(n.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=e=>{switch(e.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(e){if(!e.rangeCount)return!1;const t=e.getRangeAt(0),n=t.cloneContents(),i=document.createElement("div");i.appendChild(n);const o=t.commonAncestorContainer;return o!==this.content&&this.content.contains(o)&&i.innerHTML==t.commonAncestorContainer.innerHTML&&o.nodeType!==Node.TEXT_NODE?(i.remove(),!0):(i.remove(),!1)}createElement=e=>this.hasInvalidElementsInSelection(e)?document.createElement("div"):document.createElement("span");hasInvalidElementsInSelection=e=>{if(e){const t=["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"],n=e.getRangeAt(0).cloneContents().querySelectorAll("*");for(let e=0;e<n.length;e++){const i=n[e];if(t.includes(i.tagName.toLowerCase()))return!0}}return!1};removeProperty=(e,t,n)=>{null!=e&&e!=this.content&&this.content.contains(e)&&(this.getUserDefinedStyleCount(e)>1?e.style.removeProperty(t,n):"SPAN"==e.nodeName?0==e.childElementCount?e.replaceWith(e.textContent):(e.insertAdjacentHTML("afterend",e.innerHTML),e.remove()):"DIV"==e.nodeName&&!0===this.isCommonAncestor?(e.insertAdjacentHTML("afterend",e.innerHTML),e.remove()):e.hasAttribute("style")&&e.removeAttribute("style"))};addTextDecoration=(e,t)=>{if(null==e||e==this.content||e==this.content.parentNode)return;const n=e.style.textDecoration;if(null!=n&&!n.includes(t)){const i=n?n+" "+t:t;e.style.textDecoration=i}};removeTextDecoration=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e))if(this.getUserDefinedStyleCount(e)>1){const n=e.style.textDecoration.split(" ").filter(e=>e!==t);e.style.textDecoration=n.join(" ")}else"SPAN"==e.nodeName&0==e.childElementCount?e.replaceWith(e.textContent):"SPAN"==e.nodeName?(e.insertAdjacentHTML("afterend",e.innerHTML),e.remove()):e.hasAttribute("style")&&e.removeAttribute("style")};getUserDefinedStyles=e=>{if(null==e||e==this.content||!this.content.contains(e))return;let t={};for(let n=0;n<e.style.length;n++){let i=e.style[n],o=e.style.getPropertyValue(i);t[i]=o}return t};getUserDefinedStyleCount=e=>{if(null==e||e==this.content||!this.content.contains(e))return;let t=0;for(let n=0;n<e.style.length;n++){let i=e.style[n],o=e.style.getPropertyValue(i);if(this.isFormatElement(e)){if("initial"!=o){let e=o.split(" ");if(!this.isMultiValueProperty(i)&&e.length>1)for(let n=0;n<e.length;n++)t++;else t++}}else t++}return t};isMultiValueProperty=e=>{switch(e){case"background-color":case"color":case"font-family":return!0}return!1};getElementByType=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e)){for(;e;){if(e===this.content||!this.content.contains(e))return;if("#text"!=e.nodeName&&"#document"!=e.nodeName)switch(t){case"Format":if(this.isFormatElement(e))return e;break;case"UL":case"OL":case"Element":if(e.nodeName===t)return e}e=e.parentNode}return null}};getElementByContent=(e,t,n)=>{if(null!=e&&e!=this.content&&this.content.contains(e))for(;e;){if(e===this.content||!this.content.contains(e))return;if("#text"!=e.nodeName&&"#document"!=e.nodeName){const i=this.getElementByStyle(e,t);if(null!=i&&this.selectionContainsNode(n,i))return i;if(null!==n&&n.toString().trim()==e.textContent.trim())return e}e=e.parentNode}};selectionContainsNode(e,t){if(null==t||t==this.content||!this.content.contains(t))return!1;if(e.rangeCount>0)for(let n=0;n<e.rangeCount;n++){let i=e.getRangeAt(n);if(this.isNodeInRange(t,i))return!0}return!1}isNodeInRange(e,t){if(null==e||e==this.content||!this.content.contains(e))return!1;let n=e.ownerDocument.createRange();return n.selectNode(e),t.compareBoundaryPoints(Range.START_TO_END,n)<=0&&t.compareBoundaryPoints(Range.END_TO_START,n)>=0}getElementByStyle=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e)){for(;e;){if(e===this.content||!this.content.contains(e))return;if(null!=e.style){let n=null;switch(t){case"textcolor":if(n=e.getAttribute("style"),null!=n&&n.includes("color:"))return e;break;case"textbgcolor":if(n=e.getAttribute("style"),null!=n&&n.includes("background-color:"))return e;break;case"font":if(n=e.getAttribute("style"),null!=n&&n.includes("font-family:"))return e;break;case"size":if(n=e.getAttribute("style"),null!=n&&n.includes("font-size:"))return e;break;case"bold":if(n=e.getAttribute("style"),null!=n&&n.includes("font-weight:")&&"bold"==e.style.fontWeight)return e;break;case"italic":if(n=e.getAttribute("style"),null!=n&&n.includes("font-style:")&&"italic"==e.style.fontStyle)return e;break;case"underline":if(n=e.getAttribute("style"),null!=n&&n.includes("text-decoration:")&&e.style.textDecoration.includes("underline"))return e;break;case"line-through":if(n=e.getAttribute("style"),null!=n&&n.includes("text-decoration:")&&e.style.textDecoration.includes("line-through"))return e;break;case"subscript":if(n=e.getAttribute("style"),null!=n&&n.includes("vertical-align:")&&"sub"==e.style.verticalAlign)return e;break;case"superscript":if(n=e.getAttribute("style"),null!=n&&n.includes("vertical-align:")&&"superscript"==e.style.verticalAlign)return e;break;case"alignleft":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"left"==e.style.textAlign)return e;break;case"aligncenter":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"center"==e.style.textAlign)return e;break;case"alignright":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"right"==e.style.textAlign)return e;break;case"alignjustify":if(n=e.getAttribute("style"),null!=n&&n.includes("text-align:")&&"justify"==e.style.textAlign)return e}}e=e.parentNode}return null}};isFormatElement=e=>!(null==e||e==this.content||!this.content.contains(e))&&("P"==e.nodeName||"H1"==e.nodeName||"H2"==e.nodeName||"H3"==e.nodeName||"H4"==e.nodeName||"H5"==e.nodeName||"H6"==e.nodeName||(null!=e.style&&null!=e.style.textDecoration||void 0));insertLineBreak=e=>{const t=document.createElement("p"),n=document.createElement("br");if(t.appendChild(n),"CODE"==e.nodeName){const n=e.parentNode.parentNode;n.nextSibling?n.parentNode.insertBefore(t,n.nextSibling):n.parentNode.appendChild(t)}else e.parentNode.insertBefore(t,e.nextSibling);const i=document.createRange();i.setStartBefore(n),i.collapse(!0);const o=this.Utilities.getSelection();null!==o&&(o.removeAllRanges(),o.addRange(i))}}class i{constructor(e,t,n,i){this.shadowRoot=e,this.content=t,this.Utilities=n,this.NodeManager=i}addlist=e=>{const t=this.Utilities.getSelection();if(null!==t){if(t.isCollapsed&&t.rangeCount>0&&this.isCollapsedAtElementBoundary(t.getRangeAt(0)))return;if("UL"==e){const e=this.NodeManager.getElementByType(t.anchorNode,"OL");if(null!=e)return void this.replaceList(e,"UL")}else{const e=this.NodeManager.getElementByType(t.anchorNode,"UL");if(null!=e)return void this.replaceList(e,"OL")}const n=this.NodeManager.getElementByType(t.anchorNode,e);if(null!=n)this.removelist(n);else{if(0===t.toString().trim().length){const n=t.getRangeAt(0);let i;const o=document.createElement(e);if(t.anchorNode.parentNode!==this.content&&(i=t.anchorNode.parentNode),t.anchorNode!==this.content&&(i=t.anchorNode),!i)return;if(i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),t=i.cloneNode(!0);this.appendListItemContent(e,t),o.appendChild(e),i.remove()}n.deleteContents(),n.insertNode(o);const r=document.createRange();r.selectNodeContents(o),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}else{const n=document.createElement(e);if(t.rangeCount>0){const e=t.getRangeAt(0),i=e.cloneContents().childNodes;Array.from(i).forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),i=e.cloneNode(!0);this.appendListItemContent(t,i),n.appendChild(t),e.remove()}}),e.deleteContents(),e.insertNode(n),e.selectNodeContents(n),t.removeAllRanges(),t.addRange(e)}}}}};isCollapsedAtElementBoundary=e=>{const t=e.startContainer,n=e.startOffset,i=new Set(["TABLE","IMG","VIDEO","AUDIO","IFRAME","CANVAS","SVG","FIGURE","OBJECT","EMBED","HR","PRE","BLOCKQUOTE"]);if(t===this.content){return[n>0?t.childNodes[n-1]:null,t.childNodes[n]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE)}if(t.nodeType!==Node.ELEMENT_NODE)return!1;if(i.has(t.nodeName))return!0;return[n>0?t.childNodes[n-1]:null,t.childNodes[n]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE&&i.has(e.nodeName))};appendListItemContent=(e,t)=>{if(e&&t)if(this.isParagraphChild(t))for(;t.firstChild;)e.appendChild(t.firstChild);else e.appendChild(t)};replaceList=(e,t)=>{if(null===e||e===this.content||!this.content.contains(e))return;const n=this.Utilities.getSelection();let i,o,r,s,l;null!==n&&n.rangeCount>0&&(i=n.getRangeAt(0),o=i.startContainer,r=i.startOffset,s=i.endContainer,l=i.endOffset);const a=document.createElement(t);for(;e.firstChild;)a.appendChild(e.firstChild);if(e.parentNode.replaceChild(a,e),i){const t=document.createRange();e.contains(o)?t.setStart(a,r):t.setStart(o,r),e.contains(s)?t.setEnd(a,l):t.setEnd(s,l),n.removeAllRanges(),n.addRange(t)}};removelist=e=>{if(null==e||e==this.content||!this.content.contains(e))return;if("OL"===e.nodeName||"UL"===e.nodeName)return void this.removeListAsParagraphs(e);let t=null;for(;e.firstChild;){const n=e.firstChild;if("UL"===n.nodeName||"OL"===n.nodeName)t||(t=n),e.parentNode.insertBefore(n,e);else{for(;n.firstChild;){const i=n.firstChild;t||(t=i),e.parentNode.insertBefore(i,e)}e.removeChild(n)}}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}};removeListAsParagraphs=e=>{let t=null;for(;e.firstChild;){const n=e.firstChild;if("LI"!==n.nodeName){t||(t=n),e.parentNode.insertBefore(n,e);continue}const i=document.createElement("p");for(;n.firstChild;){const e=n.firstChild;if("UL"===e.nodeName||"OL"===e.nodeName)break;if(this.isParagraphChild(e)){for(;e.firstChild;)i.appendChild(e.firstChild);n.removeChild(e)}else i.appendChild(e)}for(i.hasChildNodes()||i.appendChild(document.createElement("br")),t||(t=i),e.parentNode.insertBefore(i,e);n.firstChild;)e.parentNode.insertBefore(n.firstChild,e);e.removeChild(n)}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}};isParagraphChild=e=>!(!e||e.nodeType!==Node.ELEMENT_NODE)&&["P","DIV"].includes(e.nodeName);increaseIndent=(e,t)=>{if(!e||!t||"UL"!==t.nodeName&&"OL"!==t.nodeName)return;let n=this.getSelectedNodes(e,t);if(!n||0===n.length)return;let i=n[0].previousElementSibling;if(!i||"LI"!==i.nodeName)return;let o=Array.from(i.children).find(e=>e.nodeName===t.nodeName);o||(o=document.createElement(t.nodeName),i.appendChild(o)),n.forEach(e=>{"LI"===e.nodeName&&o.appendChild(e)}),this.selectListItemStart(e,n[0])};decreaseIndent=(e,t)=>{if(!e||!t||"UL"!==t.nodeName&&"OL"!==t.nodeName)return;const n=this.getSelectedNodes(e,t);if(!n||0===n.length)return;const i=t.parentElement,o=i?i.parentElement:null;if(!i||"LI"!==i.nodeName||!o||"UL"!==o.nodeName&&"OL"!==o.nodeName)return;const r=n[n.length-1],s=document.createElement(t.nodeName);for(;r.nextElementSibling;)s.appendChild(r.nextElementSibling);const l=document.createDocumentFragment();n.forEach(e=>{"LI"===e.nodeName&&l.appendChild(e)}),o.insertBefore(l,i.nextSibling),s.children.length>0&&r.appendChild(s),0===t.children.length&&t.remove(),this.selectListItemStart(e,n[0])};getSelectedNodes=(e,t)=>{const n=[];if(!e.rangeCount)return null;const i=e.getRangeAt(0);if(null!==t){const e=t.children;for(let t=0;t<e.length;t++){const o=e[t];i.intersectsNode(o)&&n.push(o)}return n}return null};saveListSelection=e=>e&&0!==e.rangeCount?e.getRangeAt(0).cloneRange():null;restoreListSelection=(e,t,n)=>{if(e&&t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))return e.removeAllRanges(),void e.addRange(t);this.selectListItem(e,n)};selectListItemStart=(e,t)=>{if(!e||!t)return;const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)};selectListItem=(e,t)=>{if(!e||!t)return;const n=document.createRange(),i=this.getFirstTextNode(t);i?n.setStart(i,i.textContent.length):(n.selectNodeContents(t),n.collapse(!1)),n.collapse(!0),e.removeAllRanges(),e.addRange(n)};getFirstTextNode=e=>{if(!e)return null;if(e.nodeType===Node.TEXT_NODE)return e;for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("UL"===n.nodeName||"OL"===n.nodeName)continue;const i=this.getFirstTextNode(n);if(i)return i}return null};getList=e=>{for(;e;){if(e===this.content||!this.content.contains(e))return;if("#text"!=e.nodeName&&"#document"!=e.nodeName)switch(e.nodeName){case"OL":case"UL":return e}e=e.parentNode}return null}}class o{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n}copy=()=>{const e=this.Utilities.getSelection();null!==e&&null!==e&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(e)};cut=()=>{const e=this.Utilities.getSelection();null!==e&&null!==e&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&(navigator.clipboard.writeText(e),e.deleteFromDocument())};paste=e=>{const t=String(e||"").trim();this.checkParagraphs(t)||this.checkTables(t)||this.checkLines(t)||this.checkText(t)};checkParagraphs=e=>{let t=e.split(/\n\s*\n/);if(t.length>1){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const n=e.getRangeAt(0);n.deleteContents();let i=document.createDocumentFragment();return t.forEach(e=>{let t=this.checkParagraphTable(e,i);if(t||(t=this.checkParagraphLines(e,i)),!t){let t=document.createElement("p");t.textContent=e.trim(),i.appendChild(t)}}),n.insertNode(i),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!0}}return!1};checkParagraphLines=(e,t)=>{let n=0,i=e.trim().split(/\n+/);return i.length>1&&(i.forEach(e=>{if(n++,n===i.length){let n=document.createElement("p");n.textContent=e.trim(),t.appendChild(n)}else{let n=document.createElement("div");n.textContent=e.trim(),t.appendChild(n)}}),!0)};checkParagraphTable=(e,t)=>{if(this.isTable(e)){let n=this.buildTable(e);return t.appendChild(n),!0}return!1};checkLines=e=>{let t=e.trim().split(/\n+/);if(t.length>1){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const n=e.getRangeAt(0);n.deleteContents();let i=document.createDocumentFragment();return t.forEach(e=>{let t=document.createElement("div");t.textContent=e.trim(),i.appendChild(t)}),n.insertNode(i),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!0}}};checkTables=e=>{if(this.isTable(e)){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const n=t.getRangeAt(0);n.deleteContents();let i=document.createDocumentFragment(),o=this.buildTable(e);return i.appendChild(o),n.insertNode(i),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0}}};buildTable=e=>{let t=document.createElement("table"),n=e.split("\n"),i=document.createElement("tbody");return n.forEach((e,t)=>{if(e.trim().length>0){let t=e.split("\t"),n=document.createElement("tr");t.forEach(e=>{let t=document.createElement("td");e.trim().length>0&&(t.textContent=e),n.appendChild(t)}),i.appendChild(n)}}),t.appendChild(i),t};isTable=e=>{if(e.includes("\t")){let t=e.split("\n");if(t.length>1&&t[1].trim().length>0){let e=(t[1].match(/\t/g)||[]).length;if(0===e)return!1;for(let n=1;n<t.length;n++){let i=t[n];if(i.trim().length>0){if((i.match(/\t/g)||[]).length!==e)return!1}}return!0}}return!1};checkText=e=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const n=t.getRangeAt(0);if(n.deleteContents(),""===this.content.innerHTML.trim()){const t=document.createElement("div"),i=document.createTextNode(e);t.appendChild(i),n.insertNode(t),n.setStartAfter(t),n.setEndAfter(t)}else{const t=document.createTextNode(e);n.insertNode(t),n.setStartAfter(t),n.setEndAfter(t)}t.removeAllRanges(),t.addRange(n)}}}class r{constructor(e,t){this.shadowRoot=e,this.content=t}closeDialog=(e,t)=>{const n=this.shadowRoot.getElementById(e);null!=n&&n.close(),t&&this.restoreSelection(window.getSelection(),t),this.content.focus()};addClasses=(e,t)=>{if(null!=e&&null!=t)if(t.classList.remove(...t.classList),e.length>0){e.split(" ").map(e=>e.trim()).forEach(e=>{e&&t.classList.add(e)})}else t.hasAttribute("class")&&t.removeAttribute("class")};getSelection=()=>{const e=this.shadowRoot.getSelection();return this.content.contains(e.anchorNode)&&this.content.contains(e.focusNode)?e:null};showFadingBar=e=>{const t=this.shadowRoot.getElementById("rich-text-box-message-bar"),n=t.querySelector(".rich-text-box-message");t&&n&&(n.textContent=e,t.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=e=>e&&e.rangeCount>0?e.getRangeAt(0).cloneRange():null;restoreSelection=(e,t)=>{e&&t&&(e.removeAllRanges(),e.addRange(t)),this.content.focus()};reselectNode=e=>{const t=document.createRange(),n=window.getSelection();e.childNodes.length>0?t.setStartAfter(e.childNodes[e.childNodes.length-1]):t.setStartAfter(e),t.collapse(!0),n.removeAllRanges(),n.addRange(t)};saveCaretPosition=()=>{const e=this.getSelection();if(null!==e){return{startOffset:e.getRangeAt(0).startOffset,endOffset:e.getRangeAt(0).endOffset}}return null};restoreCaretPosition=(e,t)=>{const n=this.getSelection();if(null!==n&&null!==t){let i=document.createRange();i.setStart(e.firstChild,t.startOffset),i.setEnd(e.firstChild,t.endOffset),n.removeAllRanges(),n.addRange(i)}};saveScroll=e=>e.scrollTop;restoreScroll=(e,t)=>{e.scrollTop=t}}class s{constructor(e,t,n,i){this.shadowRoot=e,this.content=t,this.Utilities=n,this.closeHandler=i,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-table-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){const t=this.shadowRoot.activeElement;if(t&&"BUTTON"===t.tagName)return;e.preventDefault(),this.insertTable()}"Escape"===e.key&&(e.preventDefault(),this.closeDialog())}),["rich-text-box-table-columns","rich-text-box-table-rows"].forEach(e=>{const t=this.shadowRoot.getElementById(e);t&&(t.addEventListener("keydown",e=>this.allowTableNumberKey(e)),t.addEventListener("input",()=>this.cleanTableNumberInput(t)))})};allowTableNumberKey=e=>{if(e.ctrlKey||e.metaKey||e.altKey)return;["Backspace","Delete","Tab","Enter","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)||/^\d$/.test(e.key)||e.preventDefault()};cleanTableNumberInput=e=>{const t=e.value.replace(/\D/g,""),n=parseInt(e.max,10)||1e4;e.value=t.length>0?String(Math.min(parseInt(t,10),n)):"",e.setCustomValidity("")};getValidTableNumber=(e,t)=>{const n=parseInt(e.value,10),i=parseInt(e.max,10)||1e4;if(!Number.isInteger(n)||n<1||n>i){const t="Enter a valid number.";return e.setCustomValidity(t),e.reportValidity(),this.Utilities.showFadingBar(t),e.focus(),e.select(),null}return e.setCustomValidity(""),n};openTableDialog=e=>{if(this.resetTableDialog(),this.savedSelection=this.Utilities.saveSelection(e),null==e.anchorNode||e.anchorNode==this.content||null==e.anchorNode.parentNode||e.anchorNode.parentNode==this.content||"TD"!==e.anchorNode.parentNode.nodeName&&"TH"!==e.anchorNode.parentNode.nodeName)null!==e&&e.rangeCount>0&&(this.tableSelection=e.getRangeAt(0).cloneRange());else{const t=this.getTable(e);if(t){const e=this.shadowRoot.getElementById("rich-text-box-table-rows");e.value=t.rows.length,e.disabled=!0;const n=this.shadowRoot.getElementById("rich-text-box-table-columns");n.value=this.getColumns(t),n.disabled=!0;this.shadowRoot.getElementById("rich-text-box-table-width").value=t.style.width;this.shadowRoot.getElementById("rich-text-box-table-height").value=t.style.height;this.shadowRoot.getElementById("rich-text-box-table-float").value=t.style.float||"none";this.shadowRoot.getElementById("rich-text-box-table-margin").value=t.style.margin;const i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=i){const e=t.classList;i.value=Array.from(e).join(" ")}const o=this.shadowRoot.getElementById("rich-text-box-table-header");o&&(o.checked=this._tableHasHeader(t)),this.table=t}}this.shadowRoot.getElementById("rich-text-box-table-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-table-columns");t&&t.focus()};openTableDialogForElement=(e,t)=>{if(!e||"TABLE"!==e.nodeName||!this.content.contains(e))return;this.resetTableDialog(),this.savedSelection=t?t.cloneRange():null,this.tableSelection=t?t.cloneRange():null,this.table=e;const n=this.shadowRoot.getElementById("rich-text-box-table-rows");n.value=e.rows.length,n.disabled=!0;const i=this.shadowRoot.getElementById("rich-text-box-table-columns");i.value=this.getColumns(e),i.disabled=!0,this.shadowRoot.getElementById("rich-text-box-table-width").value=e.style.width,this.shadowRoot.getElementById("rich-text-box-table-height").value=e.style.height,this.shadowRoot.getElementById("rich-text-box-table-float").value=e.style.float||"none",this.shadowRoot.getElementById("rich-text-box-table-margin").value=e.style.margin,this.shadowRoot.getElementById("rich-text-box-table-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-table-header").checked=this._tableHasHeader(e),this.shadowRoot.getElementById("rich-text-box-table-modal").show(),this.shadowRoot.getElementById("rich-text-box-table-width").focus()};getTable=e=>"TABLE"===e.anchorNode.parentNode.parentNode.parentNode.nodeName?e.anchorNode.parentNode.parentNode.parentNode:"TABLE"===e.anchorNode.parentNode.parentNode.parentNode.parentNode.nodeName?e.anchorNode.parentNode.parentNode.parentNode.parentNode:void 0;getColumns(e){let t=0;for(let n=0;n<e.rows.length;n++){let i=e.rows[n].cells.length;i>t&&(t=i)}return t}resetTableDialog=()=>{this.table=null,this.tableSelection=null;const e=this.shadowRoot.getElementById("rich-text-box-table-rows");e.value=null,e.disabled=!1;const t=this.shadowRoot.getElementById("rich-text-box-table-columns");t.value=null,t.disabled=!1;this.shadowRoot.getElementById("rich-text-box-table-width").value=null;this.shadowRoot.getElementById("rich-text-box-table-height").value=null;this.shadowRoot.getElementById("rich-text-box-table-float").value="none";this.shadowRoot.getElementById("rich-text-box-table-margin").value=null;const n=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=n&&(n.value=null);const i=this.shadowRoot.getElementById("rich-text-box-table-header");i&&(i.checked=!0)};insertTable=()=>{const e=this.shadowRoot.getElementById("rich-text-box-table-rows"),t=this.shadowRoot.getElementById("rich-text-box-table-columns"),n=this.shadowRoot.getElementById("rich-text-box-table-width"),i=this.shadowRoot.getElementById("rich-text-box-table-height"),o=this.shadowRoot.getElementById("rich-text-box-table-float"),r=this.shadowRoot.getElementById("rich-text-box-table-margin"),s=this.shadowRoot.getElementById("rich-text-box-table-classes"),l=this.shadowRoot.getElementById("rich-text-box-table-header"),a=!!l&&l.checked,d=this.getValidTableNumber(t,"Columns");if(null===d)return;const c=this.getValidTableNumber(e,"Rows");if(null!==c){if(null!==this.table){n.value.trim().length>0?this.table.style.width=n.value:(this.table.style.removeProperty("width"),0===this.table.style.cssText.trim().length&&this.table.hasAttribute("style")&&this.table.removeAttribute("style")),i.value.trim().length>0?this.table.style.height=i.value:this.table.style.removeProperty("height"),"none"===o.value?this.table.style.removeProperty("float"):this.table.style.float=o.value,Number.isFinite(parseFloat(r.value))&&0!==parseFloat(r.value)&&CSS.supports("margin",r.value)?this.table.style.margin=r.value:this.table.style.removeProperty("margin"),0===this.table.style.length&&this.table.removeAttribute("style"),null!==s&&this.Utilities.addClasses(s.value,this.table);const e=this._tableHasHeader(this.table);a&&!e?this._addHeader(this.table):!a&&e&&this._removeHeader(this.table),this.Utilities.reselectNode(this.table)}else if(null!=this.tableSelection){const e=this.tableSelection,t=this.createTable(c,d,n.value,i.value,a);"none"!==o.value&&(t.style.float=o.value),Number.isFinite(parseFloat(r.value))&&0!==parseFloat(r.value)&&CSS.supports("margin",r.value)&&(t.style.margin=r.value),null!==s&&this.Utilities.addClasses(s.value,t),e.deleteContents();let l=e.startContainer;if(l===this.content){const n=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,n)}else{for(;l.parentNode&&l.parentNode!==this.content;)l=l.parentNode;l&&l!==this.content&&this.content.contains(l)?this.content.insertBefore(t,l.nextSibling):this.content.appendChild(t)}const h=t.previousSibling;h&&h.nodeType===Node.ELEMENT_NODE&&""===h.textContent.trim()&&h.parentNode.removeChild(h);const b=t.nextSibling;b&&b.nodeType===Node.ELEMENT_NODE&&""===b.textContent.trim()&&b.parentNode.removeChild(b);let u=t.querySelector("td, th"),g=document.createRange();g.setStart(u,0),g.setEnd(u,0),this.savedSelection=g}this.closeDialog()}};closeDialog=()=>{this.closeHandler(this.table,this.savedSelection)};createTable=(e,t,n,i,o=!1)=>{const r=parseInt(e,10),s=parseInt(t,10),l=document.createElement("table");if(n&&(l.style.width=n),i&&(l.style.height=i),o){const e=document.createElement("thead"),t=document.createElement("tr");for(let e=0;e<s;e++){const e=document.createElement("th");e.innerHTML="&#8203;",t.appendChild(e)}e.appendChild(t),l.appendChild(e)}const a=document.createElement("tbody");for(let e=0;e<r;e++){const e=document.createElement("tr");for(let t=0;t<s;t++){const t=document.createElement("td");t.innerHTML="&#8203;",e.appendChild(t)}a.appendChild(e)}return l.appendChild(a),l};_tableHasHeader=e=>{const t=e.querySelector("thead");if(t&&t.querySelector("th"))return!0;const n=e.querySelector("tr");return!!n&&(n.cells.length>0&&Array.from(n.cells).every(e=>"TH"===e.tagName))};_addHeader=e=>{const t=this.getColumns(e),n=document.createElement("thead"),i=document.createElement("tr");for(let e=0;e<t;e++){const e=document.createElement("th");e.innerHTML="&#8203;",i.appendChild(e)}n.appendChild(i),e.insertBefore(n,e.firstChild)};_removeHeader=e=>{const t=e.querySelector("thead");if(t)return void t.remove();const n=e.querySelector("tr");n&&n.cells.length>0&&Array.from(n.cells).every(e=>"TH"===e.tagName)&&n.remove()};tableTab=()=>{const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return;const t=this.getCurrentCell(e);if(!t)return;const n=this.getNextElement(t);if(n){n.focus();const t=document.createRange();t.selectNodeContents(n),"​"===n.innerText&&t.collapse(),e.removeAllRanges(),e.addRange(t)}else{const n=t.closest("table");if(n){let t=n.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.nextSibling;if(t){const n=document.createRange();n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}}this.content.focus()}};addRowFromLastCell=()=>{const e=this.Utilities.getSelection();if(null===e||!e.rangeCount)return!1;const t=this.getCurrentCell(e);if(!t)return!1;const n=t.parentElement,i=n?n.parentElement:null,o=i?i.closest("table"):null;if(!n||!i||!o)return!1;if(n.nextElementSibling)return!1;if(t.nextElementSibling)return!1;const r=Math.max(this.getColumns(o),n.cells.length,1),s=document.createElement("tr");for(let e=0;e<r;e++){const e=document.createElement("td");e.innerHTML="&#8203;",s.appendChild(e)}i.appendChild(s);const l=s.querySelector("td, th");return l&&this.selectCell(l),!0};_makeRow=e=>{const t=document.createElement("tr");for(let n=0;n<e;n++){const e=document.createElement("td");e.innerHTML="&#8203;",t.appendChild(e)}return t};insertRowAbove=(e,t)=>{const n=e?e.closest("tr"):t?.querySelector("tr");if(!n)return;const i=Math.max(this.getColumns(t||n.closest("table")),n.cells.length,1),o=this._makeRow(i);n.parentElement.insertBefore(o,n),e&&this.selectCell(e)};insertRowBelow=(e,t)=>{const n=t||e?.closest("table"),i=e?e.closest("tr"):n?.querySelector("tr:last-child");if(!i)return;const o=Math.max(this.getColumns(n),i.cells.length,1),r=this._makeRow(o);i.after(r),e&&this.selectCell(e)};insertColumnLeft=(e,t)=>{const n=t||e?.closest("table");if(!n)return;const i=e?e.cellIndex:0;for(const e of n.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),n=document.createElement(t?"th":"td");n.innerHTML="&#8203;",e.insertBefore(n,e.cells[i]||null)}e&&this.selectCell(e)};insertColumnRight=(e,t)=>{const n=t||e?.closest("table");if(!n)return;const i=e?e.cellIndex:n.rows[0]?.cells.length-1??0;for(const e of n.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),n=document.createElement(t?"th":"td");n.innerHTML="&#8203;",e.insertBefore(n,e.cells[i+1]||null)}e&&this.selectCell(e)};removeRow=e=>{const t=e?.closest("tr");if(!t)return;const n=t.parentElement,i=n?.closest("table");if(!i||n.rows.length<=1)return;const o=t.previousElementSibling||t.nextElementSibling;if(t.remove(),o){const e=o.querySelector("td, th");e&&this.selectCell(e)}};removeColumn=(e,t)=>{const n=t||e?.closest("table");if(!n||!e)return;const i=e.cellIndex;if(n.rows[0]?.cells.length<=1)return;for(const e of n.rows)e.cells[i]&&e.cells[i].remove();const o=e.closest("tr")||n.rows[0],r=o?.cells[i]||o?.cells[i-1];r&&this.selectCell(r)};getCurrentCell=e=>{if(!e||!e.anchorNode)return null;const t=e.anchorNode.nodeType===Node.ELEMENT_NODE?e.anchorNode:e.anchorNode.parentElement;if(!t||!this.content.contains(t))return null;const n=t.closest("td, th");return n&&this.content.contains(n)?n:null};selectCell=e=>{if(!e)return;this.content.focus();const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNodeContents(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)};getNextElement=e=>{let t=e.nextElementSibling;if(!t){let n=e.parentElement.nextElementSibling;if(!n){const t=e.parentElement.parentElement?.nextElementSibling;t&&(n=t.querySelector("tr"))}n&&(t=n.querySelector("td, th"))}return t}}class l{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertMedia()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openMediaDialog=e=>{if(null!==e){if(this.resetMediaDialog(),this.savedSelection=this.Utilities.saveSelection(e),e.anchorNode&&e.anchorNode.querySelector&&(this.embed=e.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(" ")}e.rangeCount>0&&(this.embedSelection=e.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-embed-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-embed-source");t&&t.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 e=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=e&&(e.value=null)};insertMedia=()=>{const e=this.shadowRoot.getElementById("rich-text-box-embed-source"),t=this.shadowRoot.getElementById("rich-text-box-embed-width"),n=this.shadowRoot.getElementById("rich-text-box-embed-height"),i=this.shadowRoot.getElementById("rich-text-box-embed-type"),o=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");if(null!==this.embed)this.embed.data=e.value,i.value.trim().length>0?this.embed.type=i.value:this.embed.hasAttribute("type")&&this.embed.removeAttribute("type"),t.value.trim().length>0?this.embed.width=t.value:this.embed.hasAttribute("width")&&this.embed.removeAttribute("width"),n.value.trim().length>0?this.embed.height=n.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==o&&this.Utilities.addClasses(o.value,this.embed);else if(null!=this.embedSelection&&e.value.length>0){const r=this.embedSelection.cloneRange(),s=document.createElement("object");s.data=e.value,i.value.trim().length>0?s.type=i.value:s.hasAttribute("type")&&s.removeAttribute("type"),t.value.trim().length>0?s.width=t.value:s.hasAttribute("width")&&s.removeAttribute("width"),n.value.trim().length>0?s.height=n.value:s.hasAttribute("height")&&s.removeAttribute("height"),null!==o&&this.Utilities.addClasses(o.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(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,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",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertVideo()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};_populateFromVideo=e=>{const ge=e=>this.shadowRoot.getElementById(e),t=e.querySelector("source");ge("rich-text-box-video-source").value=t?t.getAttribute("src")||"":e.getAttribute("src")||"",ge("rich-text-box-video-source-type").value=t&&t.getAttribute("type")||"",ge("rich-text-box-video-poster").value=e.getAttribute("poster")||"",ge("rich-text-box-video-width").value=e.getAttribute("width")||"",ge("rich-text-box-video-height").value=e.getAttribute("height")||"",ge("rich-text-box-video-controls").checked=e.hasAttribute("controls"),ge("rich-text-box-video-autoplay").checked=e.hasAttribute("autoplay"),ge("rich-text-box-video-loop").checked=e.hasAttribute("loop"),ge("rich-text-box-video-muted").checked=e.hasAttribute("muted"),ge("rich-text-box-video-css-classes").value=Array.from(e.classList).join(" ")};_showDialog=()=>{this.shadowRoot.getElementById("rich-text-box-video-modal").show(),this.shadowRoot.getElementById("rich-text-box-video-source").focus()};openVideoDialog=e=>{if(null!==e){this.resetVideoDialog(),this.savedSelection=this.Utilities.saveSelection(e);const t=e.anchorNode;t&&("VIDEO"===t.nodeName?this.video=t:"SOURCE"===t.nodeName&&"VIDEO"===t.parentElement?.nodeName?this.video=t.parentElement:t.querySelector&&(this.video=t.querySelector("video")),!this.video&&t.closest&&(this.video=t.closest("video"))),null!==this.video&&this._populateFromVideo(this.video),e.rangeCount>0&&(this.videoSelection=e.getRangeAt(0).cloneRange()),this._showDialog()}};openVideoDialogForElement=(e,t)=>{this.resetVideoDialog(),this.savedSelection=t,this.video=e,this._populateFromVideo(e);const n=this.Utilities.getSelection();n&&n.rangeCount>0&&(this.videoSelection=n.getRangeAt(0).cloneRange()),this._showDialog()};resetVideoDialog=()=>{this.video=null,this.videoSelection=null;const ge=e=>this.shadowRoot.getElementById(e);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=e=>this.shadowRoot.getElementById(e),e=ge("rich-text-box-video-source").value.trim(),t=ge("rich-text-box-video-source-type").value.trim(),n=ge("rich-text-box-video-poster").value.trim(),i=ge("rich-text-box-video-width").value.trim(),o=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,d=ge("rich-text-box-video-css-classes").value.trim(),applyAttrs=c=>{let h=c.querySelector("source");h||(h=document.createElement("source"),c.appendChild(h)),h.setAttribute("src",e),t?h.setAttribute("type",t):h.removeAttribute("type"),n?c.setAttribute("poster",n):c.removeAttribute("poster"),i?c.setAttribute("width",i):c.removeAttribute("width"),o?c.setAttribute("height",o):c.removeAttribute("height"),r?c.setAttribute("controls",""):c.removeAttribute("controls"),s?c.setAttribute("autoplay",""):c.removeAttribute("autoplay"),l?c.setAttribute("loop",""):c.removeAttribute("loop"),a?c.setAttribute("muted",""):c.removeAttribute("muted"),this.Utilities.addClasses(d,c)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&e.length>0){const e=this.videoSelection.cloneRange();if(!this.content.contains(e.startContainer))return void this.closeDialog();const t=document.createElement("video");applyAttrs(t),e.deleteContents();let n=e.startContainer;if(n===this.content){const n=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,n)}else{for(;n.parentNode&&n.parentNode!==this.content;)if(n=n.parentNode,!this.content.contains(n))return this.content.appendChild(t),this._placeCursorAfterVideo(t),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(t,n.nextSibling),""!==n.textContent.trim()||n.querySelector("img, video, pre, blockquote")||n.parentNode.removeChild(n)}this._placeCursorAfterVideo(t),this.videoSelection=null}this.closeDialog()};_placeCursorAfterVideo=e=>{if(!e.nextSibling){const t=document.createElement("p");t.appendChild(document.createElement("br")),this.content.insertBefore(t,e.nextSibling)}this._insertedVideo=e};closeDialog=()=>{const e=this._insertedVideo;if(this._insertedVideo=null,this.Utilities.closeDialog("rich-text-box-video-modal",this.savedSelection),e){const t=e.nextSibling;if(t){const e=document.createRange(),n=t.firstChild??t;e.setStart(n,0),e.collapse(!0);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(e))}}}}class d{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{const e=this.shadowRoot.getElementById("rich-text-box-code");this.dialog=this.shadowRoot.getElementById("rich-text-box-code-block-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&t.target!==e&&(t.preventDefault(),t.stopPropagation(),this.insertCodeBlock()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openCodeBlockDialog=e=>{if(null!==e){this.resetCodeBlockDialog(),this.savedSelection=this.Utilities.saveSelection(e);const t=this.shadowRoot.getElementById("rich-text-box-code"),n=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content&&this.content.contains(e.anchorNode.parentNode)&&"CODE"===e.anchorNode.parentNode.nodeName){const i=e.anchorNode.parentNode.cloneNode(!0);if(t.value=i.textContent,null!=n){const t=e.anchorNode.parentNode.classList;n.value=Array.from(t).join(" ")}this.codeSelection=e.getRangeAt(0).cloneRange(),this.code=e.anchorNode.parentNode}else e.rangeCount>0&&(this.codeSelection=e.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),t&&(t.focus(),t.scrollTop=0,t.scrollLeft=0)}};openCodeBlockDialogForElement=(e,t)=>{if(!e||!this.content.contains(e))return;this.resetCodeBlockDialog(),this.savedSelection=t?t.cloneRange():null;const n=e.querySelector("code")||e,i=this.shadowRoot.getElementById("rich-text-box-code"),o=this.shadowRoot.getElementById("rich-text-box-code-css-classes");i.value=n.textContent,null!=o&&(o.value=Array.from(n.classList).join(" ")),this.codeSelection=t?t.cloneRange():null,this.code=n,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 e=this.shadowRoot.getElementById("rich-text-box-code-css-classes");null!=e&&(e.value=null)};insertCodeBlock=()=>{const e=this.shadowRoot.getElementById("rich-text-box-code"),t=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=this.code){const n=this.code;n.textContent=e.value,null!==t&&this.Utilities.addClasses(t.value,n);const i=document.createRange();i.selectNodeContents(n),i.collapse(!1),this.savedSelection=i}else if(null!=this.codeSelection&&e.value.length>0){const n=this.codeSelection.cloneRange(),i=document.createElement("pre"),o=document.createElement("code");null!==t&&this.Utilities.addClasses(t.value,o),o.textContent=e.value,i.appendChild(o),n.deleteContents(),n.insertNode(i);const r=i.previousSibling;r&&r.nodeType===Node.ELEMENT_NODE&&""===r.textContent.trim()&&r.parentNode.removeChild(r);const s=i.nextSibling;s&&s.nodeType===Node.ELEMENT_NODE&&""===s.textContent.trim()&&s.parentNode.removeChild(s),n.selectNodeContents(o),n.collapse(!1),this.savedSelection=n}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class c{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{const e=this.shadowRoot.getElementById("rich-text-box-quote");this.dialog=this.shadowRoot.getElementById("rich-text-box-block-quote-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&t.target!==e&&(t.preventDefault(),t.stopPropagation(),this.insertBlockQuote()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openBlockQuoteDialog=e=>{if(null!==e){this.resetBlockQuoteDialog(),this.savedSelection=this.Utilities.saveSelection(e);const t=this.shadowRoot.getElementById("rich-text-box-quote"),n=this.shadowRoot.getElementById("rich-text-box-cite"),i=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content&&this.content.contains(e.anchorNode.parentNode)&&"BLOCKQUOTE"==e.anchorNode.parentNode.nodeName){if(t.value=e.anchorNode.parentNode.textContent,null!=e.anchorNode.parentNode.cite&&(n.value=e.anchorNode.parentNode.cite),null!=i){const t=e.anchorNode.parentNode.classList;i.value=Array.from(t).join(" ")}this.quoteSelection=e.getRangeAt(0).cloneRange(),this.quote=e.anchorNode.parentNode}else e.rangeCount>0&&(this.quoteSelection=e.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),t&&(t.focus(),t.scrollTop=0,t.scrollLeft=0)}};openBlockQuoteDialogForElement=(e,t)=>{if(!e||!this.content.contains(e))return;this.resetBlockQuoteDialog(),this.savedSelection=t?t.cloneRange():null;const n=this.shadowRoot.getElementById("rich-text-box-quote"),i=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");n.value=e.textContent,null!=e.cite&&(i.value=e.cite),null!=o&&(o.value=Array.from(e.classList).join(" ")),this.quoteSelection=t?t.cloneRange():null,this.quote=e,this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),n.focus(),n.scrollTop=0,n.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 e=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");null!=e&&(e.value=null)};insertBlockQuote=()=>{const e=this.shadowRoot.getElementById("rich-text-box-quote"),t=this.shadowRoot.getElementById("rich-text-box-cite"),n=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const i=this.quote;i.textContent=e.value,t.value.trim().length>0?i.setAttribute("cite",t.value):i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==n&&this.Utilities.addClasses(n.value,i);const o=document.createRange();o.selectNodeContents(i),o.collapse(!1),this.savedSelection=o}else if(null!=this.quoteSelection&&e.value.length>0){const i=this.quoteSelection.cloneRange(),o=document.createElement("blockquote");o.textContent=e.value,t.value.trim().length>0?o.cite=t.value:o.hasAttribute("cite")&&o.removeAttribute("cite"),null!==n&&this.Utilities.addClasses(n.value,o),i.deleteContents(),i.insertNode(o);const r=o.previousSibling;r&&r.nodeType===Node.ELEMENT_NODE&&""===r.textContent.trim()&&r.parentNode.removeChild(r);const s=o.nextSibling;s&&s.nodeType===Node.ELEMENT_NODE&&""===s.textContent.trim()&&s.parentNode.removeChild(s),i.selectNodeContents(o),i.collapse(!1),this.savedSelection=i}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class h{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertUploadedImage()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())});this.shadowRoot.getElementById("rich-text-box-upload-image-file").addEventListener("change",this.handleFileSelect)};handleFileSelect=e=>{const t=e.target.files[0];this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=t.name;const n=document.createElement("img");if(t){const e=new FileReader;e.onloadend=function(){this.base64String=e.result.split(",")[1],n.src=`data:image/jpg;base64,${this.base64String}`},e.readAsDataURL(t),this.image=n}};openUploadImageDialog=e=>{if(null!==e){if(this.resetUploadImageDialog(),this.savedSelection=this.Utilities.saveSelection(e),e.anchorNode&&e.anchorNode.querySelector&&(this.currentImage=e.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.shadowRoot.getElementById("rich-text-box-upload-image-float").value=this.currentImage.style.float||"none";this.shadowRoot.getElementById("rich-text-box-upload-image-margin").value=this.currentImage.style.margin}this.range=e.getRangeAt(0).cloneRange(),this.shadowRoot.getElementById("rich-text-box-upload-image-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-upload-btn");t&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))}};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 e=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");null!=e&&(e.value=null);this.shadowRoot.getElementById("rich-text-box-upload-image-float").value="none";this.shadowRoot.getElementById("rich-text-box-upload-image-margin").value=null};insertUploadedImage=()=>{const e=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),t=this.shadowRoot.getElementById("rich-text-box-upload-image-height"),n=this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text"),i=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes"),o=this.shadowRoot.getElementById("rich-text-box-upload-image-float"),r=this.shadowRoot.getElementById("rich-text-box-upload-image-margin");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),e.value.trim().length>0?this.currentImage.width=e.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),t.value.trim().length>0?this.currentImage.height=t.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),n.value.trim().length>0?this.currentImage.alt=n.value:this.currentImage.hasAttribute("alt")&&this.currentImage.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.currentImage),"none"===o.value?(this.currentImage.style.removeProperty("float"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")):this.currentImage.style.float=o.value,Number.isFinite(parseFloat(r.value))&&0!==parseFloat(r.value)&&CSS.supports("margin",r.value)?this.currentImage.style.margin=r.value:(this.currentImage.style.removeProperty("margin"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")),this.Utilities.reselectNode(this.currentImage)):this.image&&(e.value.length>0?this.image.width=e.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),t.value.length>0?this.image.height=t.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),n.value.length>0?this.image.alt=n.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.image),"none"!==o.value&&(this.image.style.float=o.value),Number.isFinite(parseFloat(r.value))&&0!==parseFloat(r.value)&&CSS.supports("margin",r.value)&&(this.image.style.margin=r.value),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(e,t,n,i){this.shadowRoot=e,this.content=t,this.Utilities=n,this.closeHandler=i,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertImage()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openImageDialog=e=>{if(null!==e){if(this.resetImageDialog(),this.savedSelection=this.Utilities.saveSelection(e),e.anchorNode&&e.anchorNode.querySelector&&(this.image=e.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(" ");this.shadowRoot.getElementById("rich-text-box-image-float").value=this.image.style.float||"none";this.shadowRoot.getElementById("rich-text-box-image-margin").value=this.image.style.margin}e&&e.rangeCount>0&&(this.imageSelection=e.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-image-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress");t&&t.focus()}};openImageDialogForElement=(e,t)=>{e&&"IMG"===e.nodeName&&this.content.contains(e)&&(this.resetImageDialog(),this.image=e,this.savedSelection=t?t.cloneRange():null,this.imageSelection=t?t.cloneRange():null,this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=e.src,this.shadowRoot.getElementById("rich-text-box-image-width").value=e.width,this.shadowRoot.getElementById("rich-text-box-image-height").value=e.height,this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=e.alt,this.shadowRoot.getElementById("rich-text-box-image-css-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-image-float").value=e.style.float||"none",this.shadowRoot.getElementById("rich-text-box-image-margin").value=e.style.margin,this.shadowRoot.getElementById("rich-text-box-image-modal").show(),this.shadowRoot.getElementById("rich-text-box-image-webaddress").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 e=this.shadowRoot.getElementById("rich-text-box-image-css-classes");null!=e&&(e.value=null);this.shadowRoot.getElementById("rich-text-box-image-float").value="none";this.shadowRoot.getElementById("rich-text-box-image-margin").value=null};insertImage=()=>{const e=this.shadowRoot.getElementById("rich-text-box-image-webaddress"),t=this.shadowRoot.getElementById("rich-text-box-image-width"),n=this.shadowRoot.getElementById("rich-text-box-image-height"),i=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),o=this.shadowRoot.getElementById("rich-text-box-image-css-classes"),r=this.shadowRoot.getElementById("rich-text-box-image-float"),s=this.shadowRoot.getElementById("rich-text-box-image-margin");if(null!==this.imageSelection){const l=this.imageSelection.cloneRange();if(null!==this.image)e.value.trim().length>0&&(this.image.src=e.value),i.value.trim().length>0?this.image.alt=i.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),t.value.trim().length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),n.value.trim().length>0?this.image.height=n.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==o&&this.Utilities.addClasses(o.value,this.image),"none"===r.value?(this.image.style.removeProperty("float"),0===this.image.style.length&&this.image.removeAttribute("style")):this.image.style.float=r.value,Number.isFinite(parseFloat(s.value))&&0!==parseFloat(s.value)&&CSS.supports("margin",s.value)?this.image.style.margin=s.value:(this.image.style.removeProperty("margin"),0===this.image.style.length&&this.image.removeAttribute("style")),this.Utilities.reselectNode(this.image);else if(e.value.length>0){const a=document.createElement("img");a.src=e.value,t.value.trim().length>0&&(a.width=t.value),n.value.trim().length>0&&(a.height=n.value),i.value.trim().length>0&&(a.alt=i.value),null!==o&&this.Utilities.addClasses(o.value,a),"none"!==r.value&&(a.style.float=r.value),Number.isFinite(parseFloat(s.value))&&0!==parseFloat(s.value)&&CSS.supports("margin",s.value)&&(a.style.margin=s.value),l.deleteContents(),l.insertNode(a),this.Utilities.reselectNode(a)}this.imageSelection=l.cloneRange()}this.closeDialog()};closeDialog=()=>{this.closeHandler(this.image,this.savedSelection)}}class u{constructor(e,t,n){this.shadowRoot=e,this.content=t,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertLink()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openLinkDialog=e=>{if(null!==e){if(this.savedSelection=this.Utilities.saveSelection(e),this.resetLinkDialog(),null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content&&this.content.contains(e.anchorNode.parentNode)&&"A"===e.anchorNode.parentNode.nodeName){this.shadowRoot.getElementById("rich-text-box-linktext").value=e.anchorNode.parentNode.textContent;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=e.anchorNode.parentNode.getAttribute("href");const t=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=t){const n=e.anchorNode.parentNode.classList;t.value=Array.from(n).join(" ")}if("_blank"===e.anchorNode.parentNode.getAttribute("target")){this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!0}this.linkNode=e.anchorNode.parentNode}else{const t=this.shadowRoot.getElementById("rich-text-box-linktext");e.toString().length>0&&(this.linkSelection=e.getRangeAt(0).cloneRange(),t.value=this.linkSelection.toString())}this.shadowRoot.getElementById("rich-text-box-link-modal").show();const t=this.shadowRoot.getElementById("rich-text-box-link-webaddress");t&&t.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 e=this.shadowRoot.getElementById("rich-text-box-link-css-classes");null!=e&&(e.value=null)};insertLink=()=>{const e=this.shadowRoot.getElementById("rich-text-box-linktext"),t=this.shadowRoot.getElementById("rich-text-box-link-webaddress"),n=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),i=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(0!=t.value.length&&0!=e.value.length){if(null!=this.linkNode){const o=this.linkNode;o.href=t.value,o.textContent=e.value,null!==i&&this.Utilities.addClasses(i.value,o),n.checked?o.target="_blank":o.hasAttribute("target")&&o.removeAttribute("target"),this.Utilities.reselectNode(o)}else if(null!=this.linkSelection){const o=this.linkSelection,r=document.createElement("a");r.href=t.value,r.textContent=e.value,null!==i&&this.Utilities.addClasses(i.value,r),n.checked&&(r.target="_blank"),o.deleteContents(),o.insertNode(r),o.setStartBefore(r.firstChild),o.setEndAfter(r.lastChild),this.savedSelection=o}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-link-modal",this.savedSelection)};removeLink=()=>{const e=this.Utilities.getSelection();if(null!==e){const t=this.Utilities.saveSelection(e);if(null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&this.content.contains(e.anchorNode.parentNode)&&"A"===e.anchorNode.parentNode.nodeName){const t=e.anchorNode.parentNode,n=document.createDocumentFragment();for(;t.firstChild;)n.appendChild(t.firstChild);t.parentNode.insertBefore(n,t),t.parentNode.removeChild(t)}this.Utilities.restoreSelection(e,t)}}}class g{constructor(e,t,n,i,o){this.shadowRoot=e,this.content=t,this.id=n,this.NodeManager=i,this.Utilities=o,this.init()}init=()=>{this.colorPickerDialog=this.shadowRoot.getElementById(this.id),this.colorPickerDialog.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),this.insertColor()),"Escape"===e.key&&(e.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 e=>{e.addEventListener("input",()=>this.updateColor())};addValueEventListener=async e=>{e.addEventListener("input",e=>{let t=Array.from(e.target.classList).find(e=>e.includes("value"));this.colorPicker.querySelector(`.${t.replace("value","slider")}`).value=e.target.value,this.updateColor()}),e.addEventListener("focus",e=>{e.target.select()})};addHexEventListener=async e=>{e.addEventListener("keyup",e=>{/^#?[0-9A-Fa-f]{6}$/.test(e.target.value)&&this.updateFromHex()}),e.addEventListener("change",()=>this.updateFromHex()),e.addEventListener("paste",()=>setTimeout(this.updateFromHex,0)),e.addEventListener("focus",t=>{e.select()})};openColorPicker=(e,t)=>{if(this.resetColorDialog(),this.savedSelection=this.Utilities.saveSelection(e),null!==e&&null!=e.anchorNode&&e.anchorNode!=t&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=t&&t.contains(e.anchorNode.parentNode)&&null!=e.anchorNode.parentNode.style){switch(this.selection=e.getRangeAt(0).cloneRange(),this.id){case"rich-text-box-text-color-modal":e.anchorNode.parentNode.style.color.toString().length>0&&(this.hexInput.value=this.colorToHex(e.anchorNode.parentNode.style.color));break;case"rich-text-box-text-bg-color-modal":e.anchorNode.parentNode.style.backgroundColor.toString().length>0&&(this.hexInput.value=this.colorToHex(e.anchorNode.parentNode.style.backgroundColor))}this.updateFromHex(),this.selection=e.getRangeAt(0).cloneRange()}else null!==e&&e.rangeCount>0&&(this.selection=e.getRangeAt(0).cloneRange());return this.colorPickerDialog.show(),requestAnimationFrame(()=>this.redSlider?.focus({preventScroll:!0})),this.selection};insertColor=()=>{let e;switch(this.currentColor=this.getCurrentColor(),this.id){case"rich-text-box-text-color-modal":e="textcolor";break;case"rich-text-box-text-bg-color-modal":e="textbgcolor"}null!==this.selection&&(this.savedSelection=this.Utilities.saveSelection(this.selection),null===this.currentColor?this.NodeManager.updateNode(e,"None",this.selection):this.NodeManager.updateNode(e,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=e=>{this.hexInput.value=e,this.updateFromHex()};updateColor=()=>{let e=parseInt(this.redSlider.value),t=parseInt(this.greenSlider.value),n=parseInt(this.blueSlider.value),i=`rgb(${e}, ${t}, ${n})`;this.currentColor=i,this.colorDisplay.style.backgroundColor=i,this.redValue.value=e,this.greenValue.value=t,this.blueValue.value=n,this.hexInput.value=this.rgbToHex(e,t,n)};getCurrentColor=()=>this.currentColor;updateFromHex=()=>{let e=this.hexInput.value.trim();if("#"!==e.charAt(0)&&(e="#"+e),/^#[0-9A-Fa-f]{6}$/.test(e)){let t=this.hexToRgb(e);t&&(this.redSlider.value=this.redValue.value=t.r,this.greenSlider.value=this.greenValue.value=t.g,this.blueSlider.value=this.blueValue.value=t.b)}this.updateColor()};rgbToHex=(e,t,n)=>"#"+((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1);hexToRgb=e=>{const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null};colorToHex=e=>{const t=document.createElement("canvas").getContext("2d");return t.fillStyle=e,t.fillStyle}}window.RTNative_Instances={},window.RTNative_Initialize=(t,n,i,o,r,s)=>{try{null==RTNative_Instances[t]&&(RTNative_Instances[t]=new e(t,n,i,o,s),RTNative_Instances[t].loadHtml(r))}catch(e){console.log(e)}},window.RTNative_Method=(e,t,n)=>{try{const i=RTNative_Instances[t];if(null!=i&&"function"==typeof i[e])return null!=n?i[e](n):i[e]()}catch(e){console.log(e)}};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",InlineCode:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z",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",Add:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z",ArrowUp:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z",ArrowDown:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z",ArrowLeft:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z",ArrowRight:"M400-240l-56-56 184-184-184-184 56-56 240 240-240 240Z",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",Search:"M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z",Help:"M513.5-254.5Q528-269 528-290t-14.5-35.5Q499-340 478-340t-35.5 14.5Q428-311 428-290t14.5 35.5Q457-240 478-240t35.5-14.5ZM442-394h74q0-33 7.5-52t42.5-52q26-26 41-49.5t15-56.5q0-56-41-86t-97-30q-57 0-92.5 30T342-618l66 26q5-18 22.5-39t53.5-21q32 0 48 17.5t16 38.5q0 20-12 37.5T506-526q-44 39-54 59t-10 73Zm38 314q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"};class p extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=p._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText="",this._customButtons=[]}static _defaultVisibility(e=!0){return{font:e,size:e,format:e,insert:e,textStylesDivider:e,bold:e,italic:e,underline:e,strikethrough:e,subscript:e,superscript:e,inlineCode:e,formatDivider:e,textColor:e,textColorDivider:e,alignLeft:e,alignCenter:e,alignRight:e,alignJustify:e,alignDivider:e,copy:e,cut:e,paste:e,delete:e,selectAll:e,actionDivider:e,orderedList:e,unorderedList:e,indent:e,listDivider:e,link:e,image:e,imageUpload:e,quote:e,codeBlock:e,embedMedia:e,video:e,table:e,horizontalRule:e,mediaDivider:e,undo:e,redo:e,historyDivider:e,fileMenu:e,saveHtml:e,htmlView:e,preview:e,fullscreen:e,statusBarToggle:e,search:e,help:e,viewUtilDivider:e,wordCount:!1}}static _injectGlobalStyles(){if(document.getElementById("_rtb-global-styles"))return;const e=document.createElement("style");e.id="_rtb-global-styles",e.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: \"Segoe UI\", Arial, Helvetica, 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: 0;\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: hidden;\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.rtb-host-fullscreen {\n border: 0 !important;\n box-sizing: border-box !important;\n display: block !important;\n height: 100vh !important;\n inset: 0 !important;\n margin: 0 !important;\n max-height: 100vh !important;\n max-width: 100vw !important;\n padding: 0 !important;\n position: fixed !important;\n width: 100vw !important;\n z-index: 2147483647 !important;\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(e)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(e,t,n){if(t!==n){if("value"===e&&this._initialized&&(this._value=n||"",RTNative_Method("loadView",this._uid,n)),"width"===e&&this.style.setProperty("--rtb-editor-width",n||"100%"),"height"===e&&this.style.setProperty("--rtb-editor-height",n||"300px"),"config"===e)try{this.configure(JSON.parse(n))}catch(e){}if("placeholder"===e){const e=RTNative_Instances?.[this._uid];e?.content&&(n?e.content.setAttribute("data-placeholder",n):e.content.removeAttribute("data-placeholder"))}if("readonly"===e){const e=RTNative_Instances?.[this._uid];e&&e.setReadOnly(null!==n)}if("aria-label"===e||"label"===e){const e=RTNative_Instances?.[this._uid];e?.content&&n&&e.content.setAttribute("aria-label",n)}}}connectedCallback(){p._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(e){e?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(e){const t=(e||"").trim().replace(/>\s+</g,"><");this._value=t,this._initialized&&RTNative_Method("loadView",this._uid,t)}setPreviewCssFiles(...e){this._previewCssUrls=e.filter(e=>e&&"string"==typeof e),this._syncToInstance(),this._applyContentStyles()}setPreviewCssFile(e){this.setPreviewCssFiles(...e?[e]:[])}setPreviewCss(e){this._previewCssText=e||"",this._syncToInstance(),this._applyContentStyles()}addCustomButton(e){e&&e.id&&(this._customButtons=[...this._customButtons.filter(t=>t.id!==e.id),e],this._refreshToolbar())}setCustomButtons(e=[]){this._customButtons=Array.isArray(e)?e.filter(e=>e&&e.id):[],this._refreshToolbar()}removeCustomButton(e){this._customButtons=this._customButtons.filter(t=>t.id!==e),this._refreshToolbar()}clearCustomButtons(){this._customButtons=[],this._refreshToolbar()}_syncToInstance(){if(!this._initialized)return;const e=RTNative_Instances[this._uid];e&&(e._previewCssUrls=this._previewCssUrls,e._previewCssText=this._previewCssText)}_scopeCssText(e,t){e=e.replace(/\/\*[\s\S]*?\*\//g,"");let n="",i=0;for(;i<e.length;){for(;i<e.length&&/\s/.test(e[i]);)i++;if(i>=e.length)break;const o=e.indexOf("{",i);if(-1===o)break;const r=e.slice(i,o).trim();let s=1,l=o+1;for(;l<e.length&&s>0;)"{"===e[l]?s++:"}"===e[l]&&s--,l++;const a=e.slice(o+1,l-1);if(i=l,r)if(r.startsWith("@")){const e=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(e)?n+=r+" {\n"+this._scopeCssText(a,t)+"}\n":n+=r+" {"+a+"}\n"}else{n+=r.split(",").map(e=>e.trim()).filter(e=>e).map(e=>":root"===e?t:t+" "+e).join(",\n")+" {"+a+"}\n"}}return n}async _applyContentStyles(){if(!this._initialized)return;const e=RTNative_Instances[this._uid];if(!e||!e.shadowRoot)return;const t=e.shadowRoot.getElementById("_rtb-content-preview-styles");t&&t.remove();const n=".rich-text-box-content";let i="";for(const e of this._previewCssUrls)try{const t=await fetch(e);t.ok?i+=this._scopeCssText(await t.text(),n)+"\n":console.warn(`rt-native: failed to load preview CSS (${t.status}): ${e}`)}catch(t){console.warn(`rt-native: could not load preview CSS: ${e}`,t)}if(this._previewCssText&&(i+=this._scopeCssText(this._previewCssText,n)+"\n"),i.trim()){const t=document.createElement("style");t.id="_rtb-content-preview-styles",t.textContent=i,e.shadowRoot.appendChild(t)}}configure(e={}){const{visibility:t,customButtons:n,...i}=e;if(t){if(t.clearAll&&(this._visibility=p._defaultVisibility(!1)),!0===t.fileMenu&&!1===this._visibility.fileMenu){const e=p._defaultVisibility(!0);Object.prototype.hasOwnProperty.call(t,"search")||(this._visibility.search=e.search),Object.prototype.hasOwnProperty.call(t,"saveHtml")||(this._visibility.saveHtml=e.saveHtml),Object.prototype.hasOwnProperty.call(t,"help")||(this._visibility.help=e.help)}Object.assign(this._visibility,t)}n&&(this._customButtons=Array.isArray(n)?n.filter(e=>e&&e.id):[]),this._applyCSSVars(i),this._syncPreviewTheme(),this._initialized&&(t||n)&&this._reinitialize()}_syncPreviewTheme(){}_applyCSSVars(e){const set=(e,t)=>{null!=t&&this.style.setProperty(e,t)},t=e.toolbar||{};set("--rtb-toolbar-bg",t.backgroundColor),set("--rtb-toolbar-border-style",t.borderStyle),set("--rtb-toolbar-border-width",t.borderWidth),set("--rtb-toolbar-border-color",t.borderColor),set("--rtb-toolbar-border-radius",t.borderRadius),set("--rtb-dropdown-bg",t.dropdownBackgroundColor),set("--rtb-dropdown-text",t.dropdownTextColor),set("--rtb-dropdown-bg-hover",t.dropdownBackgroundColorHover),set("--rtb-dropdown-text-hover",t.dropdownTextColorHover);const n=e.button||{};set("--rtb-btn-text",n.textColor),set("--rtb-btn-size",n.textSize),set("--rtb-btn-font",n.textFont),set("--rtb-btn-bg",n.backgroundColor),set("--rtb-btn-bg-hover",n.backgroundColorHover),set("--rtb-btn-bg-selected",n.backgroundColorSelected),set("--rtb-btn-border-style",n.borderStyle),set("--rtb-btn-border-width",n.borderWidth),set("--rtb-btn-border-color",n.borderColor),set("--rtb-btn-border-hover",n.borderColorHover),set("--rtb-btn-border-selected",n.borderColorSelected),set("--rtb-btn-border-radius",n.borderRadius);const i=e.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 o=e.editor||{};set("--rtb-editor-width",o.width),set("--rtb-editor-height",o.height),set("--rtb-editor-border-radius",o.borderRadius),set("--rtb-editor-border-style",o.borderStyle),set("--rtb-editor-border-width",o.borderWidth),set("--rtb-editor-border-color",o.borderColor),set("--rtb-editor-shadow",o.boxShadow),null!=o.removeResizeHandle&&set("--rtb-editor-resize",o.removeResizeHandle?"visible":"hidden");const r=e.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=e.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=e.quote||{};set("--rtb-quote-bg",l.backgroundColor),set("--rtb-quote-border-color",l.borderColor),set("--rtb-quote-border-width",l.borderWidth);const a=e.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 t=this.getAttribute("value")||"",n=null!==this._value?this._value:t;this._value=n;const onValueChange=e=>{this._value=e,this.dispatchEvent(new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0}))};window.RTNative_Instances||(window.RTNative_Instances={}),RTNative_Instances[this._uid]=new e(this._uid,`${this._uid}_Shadow`,`${this._uid}_Toolbar`,'\n.rich-text-box-tool-bar {\n position: relative;\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 padding-bottom: 1px;\n display: flex;\n flex-wrap: nowrap;\n justify-content: flex-start;\n}\n.rich-text-box-tool-bar > .rich-text-box-dropdown {\n flex-shrink: 0;\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.rtb-toolbar-items {\n display: flex;\n flex-wrap: nowrap;\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n}\n.rtb-toolbar-items > * {\n flex-shrink: 0;\n}\n.rtb-overflow-wrapper {\n position: static;\n flex-shrink: 0;\n margin-right: 3px;\n}\n.rtb-overflow-btn svg {\n display: block;\n}\n.rtb-overflow-dropdown {\n position: absolute;\n top: 100%;\n margin-top: 1px;\n right: 0;\n left: auto;\n display: none;\n z-index: 9001;\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n border-radius: 4px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n padding: 4px;\n flex-wrap: wrap;\n align-items: center;\n max-height: 300px;\n overflow-y: auto;\n width: max-content;\n}\n.rtb-overflow-dropdown.rtb-overflow-open {\n display: flex;\n}\n.rtb-overflow-dropdown button {\n background-color: transparent;\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-dropdown-text, #000);\n outline: none;\n cursor: pointer;\n transition: none;\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.rtb-overflow-dropdown button:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e8e8e8);\n color: var(--rtb-dropdown-text-hover, #000);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rtb-overflow-dropdown button:focus-visible,\n.rtb-overflow-dropdown button.active {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-dropdown-bg-hover, #e8e8e8));\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #242424));\n outline: 2px solid var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n outline-offset: -2px;\n}\n.rtb-overflow-dropdown button.selected {\n background-color: var(--rtb-btn-bg-selected, #dcdcdc);\n border-color: var(--rtb-btn-border-selected, inherit);\n}\n.rtb-overflow-dropdown button:disabled {\n background-color: transparent;\n color: #999;\n cursor: default;\n}\n.rtb-overflow-dropdown button svg {\n fill: var(--rtb-btn-text, #000);\n width: var(--rtb-btn-size, 16px);\n height: var(--rtb-btn-size, 16px);\n display: block;\n}\n.rtb-overflow-dropdown button:hover svg {\n fill: var(--rtb-btn-text, #000);\n}\n.rtb-overflow-dropdown 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, hidden);\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-container.rtb-editor-fullscreen {\n border-radius: 0 !important;\n box-sizing: border-box !important;\n height: 100vh !important;\n inset: 0 !important;\n max-height: 100vh !important;\n max-width: 100vw !important;\n position: fixed !important;\n resize: none !important;\n width: 100vw !important;\n z-index: 2147483647 !important;\n}\n.rich-text-box-content-container {\n position: relative;\n width: 100%;\n height: 100%;\n overflow: auto;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n}\n.rich-text-box-content-container.rtb-source-view {\n overflow: hidden;\n}\n.rtb-drop-overlay {\n position: absolute;\n inset: 10px;\n z-index: 20;\n display: none;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n background: color-mix(in srgb, var(--rtb-content-bg, #ffffff) 82%, transparent);\n border: 1px solid color-mix(in srgb, var(--rtb-btn-bg-selected, #8a8a8a) 65%, transparent);\n border-radius: 8px;\n box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);\n backdrop-filter: blur(2px);\n}\n.rtb-drop-overlay-visible {\n display: flex;\n}\n.rtb-drop-zone {\n min-width: 240px;\n max-width: min(420px, 80%);\n padding: 24px 28px;\n text-align: center;\n color: var(--rtb-content-text, #242424);\n background: var(--rtb-content-bg, #ffffff);\n border: 2px dashed var(--rtb-toolbar-border-color, #b8b8b8);\n border-radius: 8px;\n font-family: var(--rtb-content-font, Arial, sans-serif);\n}\n.rtb-drop-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 58px;\n height: 34px;\n margin-bottom: 12px;\n border-radius: 6px;\n background: var(--rtb-btn-bg-selected, #dcdcdc);\n color: var(--rtb-btn-text, #242424);\n font-size: 13px;\n font-weight: 700;\n letter-spacing: 0;\n}\n.rtb-drop-title {\n font-size: 18px;\n font-weight: 600;\n margin-bottom: 4px;\n}\n.rtb-drop-subtitle {\n font-size: 13px;\n color: color-mix(in srgb, var(--rtb-content-text, #242424) 70%, transparent);\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 display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n user-select: none;\n flex-shrink: 0;\n letter-spacing: 0.2px;\n}\n.rtb-status-link {\n min-width: 0;\n overflow: hidden;\n opacity: 0;\n text-align: left;\n text-overflow: ellipsis;\n transition: opacity 100ms ease-in-out;\n white-space: nowrap;\n}\n.rtb-status-link-visible { opacity: 1; }\n.rtb-status-count {\n flex-shrink: 0;\n margin-left: auto;\n text-align: right;\n}\n.rtb-find-bar {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n width: 100%;\n background-color: var(--rtb-toolbar-bg, #fff);\n border-bottom: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n padding: 4px 8px;\n box-sizing: border-box;\n}\n.rtb-find-input {\n border: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n border-radius: 4px;\n padding: 3px 7px;\n font-size: calc(var(--rtb-btn-size, 16px) * 0.875);\n color: var(--rtb-btn-text, #242424);\n background-color: var(--rtb-content-bg, #fff);\n outline: none;\n width: 180px;\n}\n.rtb-find-input:focus {\n border-color: var(--rtb-btn-bg-selected, #a0a0a0);\n}\n.rtb-find-count {\n font-size: calc(var(--rtb-btn-size, 16px) * 0.8);\n color: var(--rtb-btn-text, #666);\n min-width: 54px;\n text-align: center;\n white-space: nowrap;\n user-select: none;\n}\n.rtb-find-nav-btn, .rtb-find-close-btn {\n background: none;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n padding: 2px 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--rtb-btn-text, #242424);\n}\n.rtb-find-nav-btn svg, .rtb-find-close-btn svg {\n width: 18px;\n height: 18px;\n fill: currentColor;\n}\n.rtb-find-nav-btn:hover, .rtb-find-close-btn:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n}\n.rtb-context-menu {\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid rgba(0,0,0,0.12);\n border-radius: 4px;\n box-shadow: 0 8px 16px rgba(0,0,0,0.14), 0 0 2px rgba(0,0,0,0.12);\n box-sizing: border-box;\n display: none;\n min-width: 168px;\n padding: 4px;\n position: fixed;\n z-index: 9000;\n}\n.rtb-context-menu button {\n align-items: center;\n appearance: none;\n background: transparent;\n border: 0;\n border-radius: 4px;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #242424);\n cursor: pointer;\n display: flex;\n font-family: var(--rtb-btn-font, Arial, Helvetica, sans-serif);\n font-size: 14px;\n gap: 10px;\n justify-content: flex-start;\n line-height: 20px;\n min-height: 32px;\n padding: 6px 8px;\n text-align: left;\n width: 100%;\n}\n.rtb-context-menu button:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rtb-context-menu svg {\n fill: currentColor;\n flex: 0 0 auto;\n height: 18px;\n width: 18px;\n}\n.rtb-context-menu-divider {\n border-top: 1px solid rgba(128,128,128,0.18);\n margin: 4px 0;\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 padding-bottom: 10px;\n width: 100%;\n max-width: var(--rtb-page-width, 860px);\n margin-left: auto;\n margin-right: auto;\n min-height: 100%;\n box-sizing: border-box;\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}\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 cursor: pointer;\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 padding: 0;\n cursor: pointer;\n box-sizing: content-box;\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, 0);\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-content table { cursor: var(--rtb-table-cell-cursor, pointer); }\n.rtb-image-resize-overlay,\n.rtb-table-resize-overlay {\n border: 1px solid var(--rtb-btn-border-selected, #605e5c);\n box-sizing: border-box;\n pointer-events: none;\n position: absolute;\n transition: left 0.0375s ease, top 0.0375s ease;\n z-index: 15;\n}\n.rtb-image-resize-overlay {\n display: none;\n}\n.rtb-table-resize-overlay {\n opacity: 0;\n transition: none;\n visibility: hidden;\n}\n.rtb-image-resize-overlay.rtb-image-resize-visible {\n display: block;\n}\n.rtb-table-resize-overlay.rtb-table-resize-visible {\n opacity: 1;\n transition: left 0.0375s ease, top 0.0375s ease, opacity 0.12s ease;\n visibility: visible;\n}\n.rtb-image-resize-handle,\n.rtb-table-resize-handle {\n background: linear-gradient(135deg, #479ef5, #0f6cbd);\n border: 2px solid var(--rtb-content-bg, #fff);\n border-radius: 3px;\n box-sizing: border-box;\n box-shadow: 0 0 0 1px #0f6cbd, 0 2px 5px rgba(0, 0, 0, 0.3);\n height: 13px;\n pointer-events: auto;\n position: absolute;\n touch-action: none;\n transition: filter 0.12s ease, box-shadow 0.12s ease;\n width: 13px;\n}\n.rtb-image-resize-handle:hover,\n.rtb-table-resize-handle:hover {\n box-shadow: 0 0 0 2px #0f6cbd, 0 2px 6px rgba(0, 0, 0, 0.38);\n filter: brightness(1.08);\n}\n:host(.dark) .rtb-image-resize-handle,\n:host(.dark) .rtb-table-resize-handle,\n:host(.fluent-dark) .rtb-image-resize-handle,\n:host(.fluent-dark) .rtb-table-resize-handle {\n background: linear-gradient(135deg, #62abf5, #2886de);\n box-shadow: 0 0 0 1px #62abf5, 0 2px 6px rgba(0, 0, 0, 0.65);\n}\n.rtb-image-resize-nw {\n cursor: nwse-resize;\n left: 0;\n top: 0;\n transform: translate(-50%, -50%);\n}\n.rtb-image-resize-n {\n cursor: ns-resize;\n left: 50%;\n top: 0;\n transform: translate(-50%, -50%);\n}\n.rtb-image-resize-ne {\n cursor: nesw-resize;\n right: 0;\n top: 0;\n transform: translate(50%, -50%);\n}\n.rtb-image-resize-e {\n cursor: ew-resize;\n right: 0;\n top: 50%;\n transform: translate(50%, -50%);\n}\n.rtb-image-resize-se {\n bottom: 0;\n cursor: nwse-resize;\n right: 0;\n transform: translate(50%, 50%);\n}\n.rtb-image-resize-s {\n bottom: 0;\n cursor: ns-resize;\n left: 50%;\n transform: translate(-50%, 50%);\n}\n.rtb-image-resize-sw {\n bottom: 0;\n cursor: nesw-resize;\n left: 0;\n transform: translate(-50%, 50%);\n}\n.rtb-image-resize-w {\n cursor: ew-resize;\n left: 0;\n top: 50%;\n transform: translate(-50%, -50%);\n}\n.rtb-image-resizing,\n.rtb-image-resizing .rtb-image-resize-handle,\n.rtb-table-resizing,\n.rtb-table-resizing .rtb-table-resize-handle {\n user-select: none;\n}\n.rich-text-box-source {\n padding: 10px max(10px, calc(50% - var(--rtb-page-width, 860px) / 2 + 10px));\n width: 100%;\n height: 100%;\n box-sizing: border-box;\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 letter-spacing: 0.04em;\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: static; display: flex; align-items: stretch; margin: 4px 1px; }\n.rich-text-box-dropdown > .rich-text-box-dropdown-btn { margin: 0; }\n.rich-text-box-dropdown-content {\n display: none;\n position: absolute;\n top: 100%;\n margin-top: 1px;\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-file-button,\n.rich-text-box-font-button,\n.rich-text-box-size-button,\n.rich-text-box-format-button,\n.rich-text-box-insert-button {\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif);\n font-size: 0.82rem;\n font-weight: 600;\n letter-spacing: 0;\n}\n.rich-text-box-file-content {\n min-width: 220px;\n max-width: 320px;\n padding: 4px;\n box-sizing: border-box;\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid var(--rtb-toolbar-border-color, #e0e0e0);\n border-radius: 8px;\n box-shadow: var(--rtb-file-menu-shadow, 0 8px 16px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12));\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif) !important;\n letter-spacing: 0.04em;\n line-height: 1.45;\n}\n.rich-text-box-format-content { min-width: 185px; }\n.rich-text-box-insert-content {\n width: 230px;\n max-height: 200px;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 8px;\n scroll-behavior: auto;\n box-sizing: border-box;\n}\n.rich-text-box-insert-group {\n color: var(--rtb-dropdown-text, #000);\n font-size: 12px;\n font-weight: 600;\n padding: 10px 8px 4px;\n opacity: 0.72;\n}\n.rich-text-box-insert-item {\n align-items: center;\n background: transparent;\n border: 0;\n border-radius: 4px;\n color: var(--rtb-dropdown-text, #000);\n cursor: pointer;\n display: grid;\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif);\n grid-template-columns: 34px 1fr;\n min-height: 34px;\n padding: 4px 8px;\n text-align: left;\n transition: none;\n width: 100%;\n}\n.rich-text-box-tool-bar .rich-text-box-insert-item,\n.rich-text-box-tool-bar .rich-text-box-insert-item * {\n transition: none;\n}\n.rich-text-box-insert-item:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rich-text-box-insert-item:focus-visible,\n.rich-text-box-insert-item.active,\n.rich-text-box-dropdown-content a:focus-visible {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-dropdown-bg-hover, #e5e5e5));\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #242424));\n outline: 2px solid var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n outline-offset: -2px;\n}\n.rich-text-box-insert-symbol {\n font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;\n font-size: 20px;\n line-height: 1;\n}\n.rich-text-box-insert-meaning {\n font-size: 14px;\n line-height: 18px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\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.rich-text-box-file-content a {\n align-items: center;\n border-radius: 4px;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #242424);\n display: flex;\n font-size: 0.88rem;\n gap: 24px;\n justify-content: space-between;\n line-height: inherit;\n min-height: 32px;\n padding: 6px 8px;\n text-decoration: none;\n}\n.rich-text-box-file-content a:hover {\n background-color: var(--rtb-dropdown-bg-hover, #f5f5f5);\n color: var(--rtb-dropdown-text-hover, #242424);\n}\n.rich-text-box-file-content a:active {\n background-color: var(--rtb-btn-bg-selected, #ebebeb);\n}\n.rich-text-box-menu-shortcut {\n color: var(--rtb-dropdown-text, #707070);\n font-size: 12px;\n font-weight: 400;\n line-height: inherit;\n margin-left: 6px;\n opacity: 0.6;\n}\n.rich-text-box-dropdown-divider {\n height: 0;\n margin: 2px 0;\n border: 0;\n border-top: 1px solid var(--rtb-file-menu-divider, var(--rtb-toolbar-border-color, #e0e0e0));\n}\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 letter-spacing: 0.03em;\n position: fixed;\n inset: 0;\n margin: auto;\n padding: 6px 16px 14px;\n border: 1px solid #888;\n width: 800px;\n max-width: calc(100vw - 20px);\n max-height: 90vh;\n overflow: hidden;\n box-sizing: border-box;\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[open] {\n display: flex;\n flex-direction: column;\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.rtb-modal-scroll-area {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n overflow-x: hidden;\n scrollbar-color: var(--rtb-scroll-thumb-bg, #AAA) var(--rtb-scroll-bg, transparent);\n scrollbar-width: thin;\n}\n.rtb-modal-body {\n overflow: visible;\n}\n.rtb-modal-scroll-area::-webkit-scrollbar {\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-modal-scroll-area::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rtb-modal-scroll-area::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-modal-scroll-area::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n.rtb-modal-footer {\n flex-shrink: 0;\n padding: 5px 5px 0 0;\n}\n.rich-text-box-form-left { float: left; width: calc(50% - 15px); }\n.rich-text-box-form-right { float: right; width: calc(50% - 15px); }\n@media screen and (max-width: 850px) {\n .rich-text-box-form-left,\n .rich-text-box-form-right { float: none; width: 100%; }\n .rich-text-box-modal { width: 430px; }\n}\n@media screen and (max-width: 500px) {\n .rich-text-box-modal { width: 100%; }\n}\n.clearfix { overflow: hidden; }\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 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@media screen and (max-width: 850px) {\n .rtb-preview-dialog {\n width: 95vw;\n }\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.rtb-help-dialog {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n width: min(95vw, 750px);\n padding: 0;\n box-sizing: border-box;\n max-height: 88vh;\n overflow: hidden;\n}\n.rtb-help-body {\n overflow-x: hidden;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-color: var(--rtb-scroll-thumb-bg, #AAA) var(--rtb-scroll-bg, transparent);\n scrollbar-width: thin;\n}\n.rtb-help-body::-webkit-scrollbar {\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-help-body::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rtb-help-body::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-help-body::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n.rtb-help-dialog[open] { display: flex; flex-direction: column; }\n.rtb-help-dialog::backdrop { background: transparent; }\n.rtb-help-sticky-header {\n z-index: 10;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n background: var(--rtb-modal-bg, #fefefe);\n padding: 10px 20px 11px;\n border-radius: 5px 5px 0 0;\n flex-shrink: 0;\n}\n.rtb-help-sticky-header .rich-text-box-modal-title {\n font-weight: bold;\n font-size: calc(var(--rtb-modal-text-size, 16px) + 2px);\n}\n.rtb-help-columns {\n display: flex;\n align-items: flex-start;\n padding: 14px 20px 22px;\n}\n.rtb-help-col {\n flex: 1;\n min-width: 0;\n}\n.rtb-help-col:first-child {\n padding-right: 30px;\n border-right: 1px solid rgba(128,128,128,0.16);\n}\n.rtb-help-col:last-child {\n padding-left: 30px;\n}\n@media (max-width: 850px) {\n .rtb-help-dialog { width: 430px; }\n .rtb-help-columns { flex-direction: column; align-items: stretch; padding: 10px 16px 18px; }\n .rtb-help-col:first-child { padding-right: 0; border-right: none; }\n .rtb-help-col:last-child { padding-left: 0; margin-top: 18px; }\n .rtb-help-col { width: 100%; }\n}\n.rtb-help-table {\n width: 100%;\n border-collapse: collapse;\n border: none;\n font-size: 0.84rem;\n}\n.rtb-help-table td {\n padding: 4px 8px;\n border: none;\n border-bottom: 1px solid rgba(128,128,128,0.07);\n vertical-align: middle;\n}\n.rtb-help-table td:first-child { padding-left: 2px; }\n.rtb-help-table td:last-child { padding-right: 2px; white-space: nowrap; text-align: right; }\n.rtb-help-table tr:not(.rtb-help-section):hover > td {\n background: rgba(128,128,128,0.06);\n}\n.rtb-help-section > td {\n text-align: left !important;\n font-weight: 700;\n font-size: 0.68rem;\n letter-spacing: 0.09em;\n text-transform: uppercase;\n opacity: 0.55;\n padding: 16px 2px 5px;\n border-top: none;\n border-bottom: 1px solid rgba(128,128,128,0.22);\n}\n.rtb-help-table > tbody > tr.rtb-help-section:first-child > td { padding-top: 4px; }\n.rtb-help-table kbd {\n font-family: "Consolas", "SF Mono", "Menlo", monospace;\n font-size: 0.74rem;\n background: rgba(128,128,128,0.11);\n border: 1px solid rgba(128,128,128,0.28);\n border-bottom-width: 2px;\n border-radius: 4px;\n padding: 1px 6px;\n white-space: nowrap;\n display: inline-block;\n line-height: 1.5;\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 letter-spacing: 0.03em;\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-float-dropdown {\n appearance: none;\n background-color: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n border-color: var(--rtb-toolbar-border-color, var(--rtb-modal-input-border, #CCC));\n border-radius: 5px;\n color: var(--rtb-dropdown-text, var(--rtb-modal-input-text, #000));\n cursor: pointer;\n transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;\n}\n.rich-text-box-float-dropdown:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #000));\n}\n.rich-text-box-float-dropdown:focus {\n background-color: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n border-color: var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c)) 25%, transparent);\n}\n.rich-text-box-float-dropdown:active {\n background-color: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n}\n.rich-text-box-float-dropdown option {\n background-color: var(--rtb-dropdown-bg, #fff);\n color: var(--rtb-dropdown-text, #000);\n}\n:host(.dark) .rich-text-box-form-element,\n:host(.fluent-dark) .rich-text-box-form-element {\n color-scheme: dark;\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 cursor: pointer;\n}\n.rich-text-box-form-checkbox-label,\nlabel:has(.rich-text-box-form-checkbox) {\n cursor: pointer;\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 letter-spacing: 0.05em;\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 4px 6px;\n}\n.rich-text-box-upload-btn:hover,\n.rich-text-box-upload-btn:focus-visible {\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 letter-spacing: 0.05em;\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 {\n box-sizing: border-box;\n width: calc(100% - 4px);\n height: 50px;\n border: 1px solid #ccc;\n margin: 20px 2px;\n}\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-form-element[type="number"] {\n color-scheme: light;\n}\n:host(.dark) .rich-text-box-form-element[type="number"],\n:host(.fluent-dark) .rich-text-box-form-element[type="number"] {\n color-scheme: dark;\n}\n.rich-text-box-form-element[type="number"]::-webkit-inner-spin-button,\n.rich-text-box-form-element[type="number"]::-webkit-outer-spin-button {\n opacity: 1;\n cursor: pointer;\n accent-color: var(--rtb-scroll-thumb-bg, #AAA);\n background-color: var(--rtb-scroll-bg, transparent);\n border-left: 1px solid var(--rtb-modal-input-border, #CCC);\n}\n.rich-text-box-form-element[type="number"]:hover::-webkit-inner-spin-button,\n.rich-text-box-form-element[type="number"]:hover::-webkit-outer-spin-button {\n accent-color: var(--rtb-scroll-thumb-bg-hover, #DDD);\n background-color: var(--rtb-scroll-thumb-bg, #AAA);\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; min-width: 0; }\n@keyframes rtb-modal-zoom-in {\n from { opacity: 0; transform: scale(0.93); }\n to { opacity: 1; transform: scale(1); }\n}\n@keyframes rtb-dialog-zoom-in {\n from { opacity: 0; transform: translate(-50%, -50%) scale(0.93); }\n to { opacity: 1; transform: translate(-50%, -50%) scale(1); }\n}\n@keyframes rtb-dropdown-in {\n from { opacity: 0; transform: translateY(-5px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes rtb-content-enter {\n from { opacity: 0.5; }\n to { opacity: 1; }\n}\n.rich-text-box-modal[open] {\n animation: rtb-modal-zoom-in 0.06s ease-out;\n}\n.rtb-preview-dialog[open] {\n animation: rtb-dialog-zoom-in 0.06s ease-out;\n}\n.rtb-help-dialog[open] {\n animation: rtb-dialog-zoom-in 0.06s ease-out;\n}\n.rich-text-box-dropdown-content.rich-text-box-show {\n animation: rtb-dropdown-in 0.06s ease-out;\n}\n\n.rich-text-box-content * {\n transition: margin 0.075s ease;\n}\n.rich-text-box-content span {\n animation: none;\n}\n\n/* Focus ring for buttons and interactive controls inside dialog windows (excludes text inputs) */\ndialog *:not(input):not(textarea):not(select):focus-visible {\n outline: 2px solid var(--rtb-modal-text, #242424) !important;\n outline-offset: 1px !important;\n}\n/* Subtle border accent for text inputs, textareas, and selects on focus — no outline ring */\ndialog input:focus-visible,\ndialog textarea:focus-visible,\ndialog select:focus-visible {\n outline: none !important;\n border-color: var(--rtb-modal-text, #242424) !important;\n}\n',{invokeMethodAsync:(e,t)=>onValueChange(t)}),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 o=this.getAttribute("placeholder");o&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",o),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid]._applyStoredStatusBarVisibility(),RTNative_Instances[this._uid].loadHtml(n),this._initialized=!0,this._syncToInstance(),this._applyContentStyles(),this._attachCustomButtonHandlers()}_reinitialize(){const e=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(),e&&this.setValue(e)})}_refreshToolbar(){this._initialized?this._reinitialize():this.isConnected&&this._render()}_svg(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="${m[e]}"/></svg>`}_btn(e,t,n,i,o){return`<button id="${e}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==o?`RTNative_Method('${i}','${this._uid}','${o}')`:`RTNative_Method('${i}','${this._uid}')`}">${this._svg(t)}</button>`}_specialBtn(e,t,n,i){return`<button id="${e}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${i}','${this._uid}')">${this._svg(t)}</button>`}_fullscreenBtn(){return`<button id="blazing-rich-text-fullscreen-button" title="Maximize Editor" aria-label="Maximize editor" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('toggleEditorFullscreen','${this._uid}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false"><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>`}_divider(){return'<button class="rich-text-box-divider-btn" disabled><div class="rich-text-box-divider"></div></button>'}_escapeAttr(e){return String(e??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_customButton(e){const t=this._escapeAttr(e.id),n=this._escapeAttr(e.title||e.label||e.id),i=e.svg||"";return`<button id="${t}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item rich-text-box-custom-button" data-rtb-custom-button="${t}"${e.disabled?" disabled":""}>${i}</button>`}_customButtonsHTML(){return this._customButtons.length?this._customButtons.map(e=>this._customButton(e)).join("\n"):""}_resolveCustomButtonHandler(e){return"function"==typeof e?e:"string"==typeof e&&e.trim()?e.split(".").reduce((e,t)=>e?.[t],window):null}_attachCustomButtonHandlers(){const e=RTNative_Instances[this._uid];e?.shadowRoot&&this._customButtons.forEach(t=>{const n=e.shadowRoot.querySelector(`[data-rtb-custom-button="${CSS.escape(t.id)}"]`);n&&n.addEventListener("click",n=>{if(t.disabled)return;const i=this._resolveCustomButtonHandler(t.onClick||t.method);"function"==typeof i&&i.call(this,n,this,e),this.dispatchEvent(new CustomEvent("custom-button-click",{detail:{id:t.id,button:t,editor:this},bubbles:!0,composed:!0}))})})}_fontDropdown(){const e=this._uid,t=["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(t=>`<a class="rich-text-box-menu-item" style="font-family:${t};cursor:pointer" onclick="RTNative_Method('font','${e}','${t}')">${t}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-font-button" title="Font (Alt+F)" class="rich-text-box-font-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','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 ${t}\n </div>\n</div>`}_sizeDropdown(){const e=this._uid,t=["None","8","9","10","11","12","14","16","18","20","22","24","26","28","36","48","64"].map(t=>`<a class="rich-text-box-menu-item" style="${"None"===t?"":`font-size:${t}px !important;`}cursor:pointer" onclick="RTNative_Method('size','${e}','${"None"===t?"None":`${t}px`}')">${"None"===t?"None":t}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-size-button" title="Size (Alt+S)" class="rich-text-box-size-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','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 ${t}\n </div>\n</div>`}_formatDropdown(){const e=this._uid;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-format-button" title="Format (Alt+T)" class="rich-text-box-format-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','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','${e}','p')">Paragraph</a>\n <a class="rich-text-box-menu-item" style="font-size:34px;cursor:pointer" onclick="RTNative_Method('format','${e}','h1')">Header 1</a>\n <a class="rich-text-box-menu-item" style="font-size:30px;cursor:pointer" onclick="RTNative_Method('format','${e}','h2')">Header 2</a>\n <a class="rich-text-box-menu-item" style="font-size:24px;cursor:pointer" onclick="RTNative_Method('format','${e}','h3')">Header 3</a>\n <a class="rich-text-box-menu-item" style="font-size:20px;cursor:pointer" onclick="RTNative_Method('format','${e}','h4')">Header 4</a>\n <a class="rich-text-box-menu-item" style="font-size:18px;cursor:pointer" onclick="RTNative_Method('format','${e}','h5')">Header 5</a>\n <a class="rich-text-box-menu-item" style="font-size:16px;cursor:pointer" onclick="RTNative_Method('format','${e}','h6')">Header 6</a>\n </div>\n</div>`}_insertDropdown(){const e=this._uid,t=[["Status & Priority",[["✅","Success"],["❌","Failed"],["✔","Confirmed"],["✖","Rejected"],["⭐","Favorite"],["🌟","Featured"],["🔴","High Priority"],["🟡","Medium Priority"],["🟢","Low Priority"],["🔵","Informational"],["🏆","Best"],["💯","Excellent"]]],["Productivity & Workflow",[["⏳","In Progress"],["⌛","Waiting"],["🔄","Updating"],["🔁","Repeat"],["🚧","Work in Progress"],["🛠","Under Construction / Build"],["📌","Pinned"],["📍","Location"],["📖","Documentation"],["📝","Notes"],["📋","Checklist"],["📎","Attachment"],["🔍","Search"],["🧠","Thinking"],["📅","Schedule"],["🚀","Launch"]]],["Social & Emphasis",[["🔥","Trending"],["✨","Exciting"],["❤️","Love"],["👍","Approval"],["👀","Attention"],["👉","Pointing"],["🎯","Goal"],["⚡","Fast"],["📢","Announcement"],["💡","Idea"]]],["Technology",[["🚀","Deploy"],["🐛","Bug"],["✨","Feature"],["⚙","Settings"],["🔧","Configuration / Tools"],["📦","Package"],["🔒","Secure"],["🔓","Public"],["🧪","Experimental"],["🗑","Delete"],["💾","Save"]]],["Warnings & Errors",[["⚠","Warning"],["🚨","Critical Alert"],["🔥","Serious Issue"],["🛑","Stop"],["❗","Important Warning"],["❓","Unknown / Question"],["⁉","Clarification Needed"]]],["Arrows & Navigation",[["→","Right Arrow"],["←","Left Arrow"],["↑","Up Arrow"],["↓","Down Arrow"],["⇒","Result"],["➜","Action Arrow"],["↳","Sub-item"],["⇢","Link"]]],["Tree & Hierarchy",[["├─","Branch Node"],["└─","Last Branch"],["│","Vertical Line"],["─","Horizontal Line"],["╰─","Rounded Last Branch"],["╭─","Rounded Top Branch"]]]].map(([t,n])=>`\n <div class="rich-text-box-insert-group">${t}</div>\n ${n.map(([t,n])=>`\n <button type="button" class="rich-text-box-insert-item" onclick="RTNative_Method('insertEmoji','${e}','${this._escapeAttr(t)}')">\n <span class="rich-text-box-insert-symbol">${t}</span>\n <span class="rich-text-box-insert-meaning">${n||t}</span>\n </button>`).join("")}`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-insert-button" title="Insert (Alt+I)" class="rich-text-box-insert-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','blazing-rich-text-insert-button-dropdown')">Insert</button>\n <div id="blazing-rich-text-insert-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-insert-content rich-text-box-scroll">\n ${t}\n </div>\n</div>`}_fileDropdown(){const e=this._uid,t=this._visibility,n=`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','open')">Open<span class="rich-text-box-menu-shortcut">Ctrl+O</span></a>`;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-file-button" title="File (Alt+L)" class="rich-text-box-file-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${e}','blazing-rich-text-file-button-dropdown')">File</button>\n <div id="blazing-rich-text-file-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-file-content rich-text-box-scroll">\n ${t.search?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','find')">Find<span class="rich-text-box-menu-shortcut">Ctrl+F</span></a>`:""}${n}${t.saveHtml?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','save')">Download<span class="rich-text-box-menu-shortcut">Ctrl+S</span></a>`:""}${(t.search||t.saveHtml||n)&&t.statusBarToggle?'<hr class="rich-text-box-dropdown-divider">':""}${t.statusBarToggle?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','toggleStatusBar')"><span id="blazing-rich-text-file-statusbar-label">Show Status Bar</span><span class="rich-text-box-menu-shortcut">Ctrl+\\</span></a>`:""}${(t.search||t.saveHtml||t.statusBarToggle)&&t.help?'<hr class="rich-text-box-dropdown-divider">':""}${t.help?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${e}','shortcuts')">Keyboard Shortcuts<span class="rich-text-box-menu-shortcut">Ctrl+/</span></a>`:""}\n </div>\n</div>`}_colorSwatches(e){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(t=>`<div class="blazing-rich-text-color-option" onclick="RTNative_Method('${e}','${this._uid}','${t}')" style="background-color:${t};"></div>`).join("")}_colorDialog(e,t,n,i){const o=this._uid;return`\n<dialog id="${e}" class="rich-text-box-modal" aria-modal="true" aria-labelledby="${e}-title">\n <div class="rtb-modal-header">\n <div id="${e}-title" class="rich-text-box-modal-title">${t}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${o}','${e}')"><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="rtb-modal-scroll-area rich-text-box-scroll">\n <div class="rtb-modal-body">\n <div class="rich-text-box-color-picker">\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n ${this._colorSwatches(n)}\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>\n </div>\n <div class="rtb-modal-footer" style="text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${o}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${i}','${o}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(e,t,n,i,o=""){const r=this._uid;return`\n<dialog id="${e}" class="rich-text-box-modal" aria-modal="true" aria-labelledby="${e}-title">\n <div class="rtb-modal-header">\n <div id="${e}-title" class="rich-text-box-modal-title">${t}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${r}','${e}')"><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="rtb-modal-scroll-area rich-text-box-scroll">\n <div class="rtb-modal-body">\n ${i}\n </div>\n <div class="rtb-modal-footer" style="${o?"display:flex;justify-content:space-between;align-items:center;":"text-align:right;"}">\n ${o?`<div>${o}</div>`:""}\n <div>\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${r}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${n}','${r}')">OK</button>\n </div>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const e=this._uid,t=this._visibility,n=(t.font||t.size||t.format||t.insert)&&t.textStylesDivider,i=(t.bold||t.italic||t.underline||t.strikethrough||t.subscript||t.superscript||t.inlineCode)&&t.formatDivider,o=t.textColor&&t.textColorDivider,r=(t.alignLeft||t.alignCenter||t.alignRight||t.alignJustify)&&t.alignDivider,s=(t.copy||t.cut||t.paste||t.delete||t.selectAll)&&t.actionDivider,l=(t.orderedList||t.unorderedList||t.indent)&&t.listDivider,a=(t.link||t.image||t.imageUpload||t.quote||t.codeBlock||t.embedMedia||t.video||t.table||t.horizontalRule)&&t.mediaDivider,d=(t.undo||t.redo)&&t.historyDivider,c=this._customButtons.length>0;return`\n<div id="${e}_Toolbar" class="rich-text-box-tool-bar" role="toolbar" aria-label="Formatting toolbar">\n\n ${t.fileMenu?this._fileDropdown():""}\n ${t.font?this._fontDropdown():""}\n ${t.size?this._sizeDropdown():""}\n ${t.format?this._formatDropdown():""}\n ${t.insert?this._insertDropdown():""}\n ${n?this._divider():""}\n\n ${t.bold?this._btn("blazing-rich-text-bold-button","Bold","Bold (Ctrl+B)","bold"):""}\n ${t.italic?this._btn("blazing-rich-text-italic-button","Italic","Italic (Ctrl+I)","italic"):""}\n ${t.underline?this._btn("blazing-rich-text-underline-button","Underline","Underline (Ctrl+U)","underline"):""}\n ${t.strikethrough?this._btn("blazing-rich-text-strike-button","Strikethrough","Strikethrough (Ctrl+D)","strikethrough"):""}\n ${t.subscript?this._btn("blazing-rich-text-sub-button","Subscript","Subscript (Ctrl+=)","subscript"):""}\n ${t.superscript?this._btn("blazing-rich-text-super-button","Superscript","Superscript (Ctrl+Shift++)","superscript"):""}\n ${t.inlineCode?this._btn("blazing-rich-text-inline-code-button","InlineCode","Inline Code (Ctrl+Shift+E)","inlinecode"):""}\n ${i?this._divider():""}\n\n ${t.textColor?this._btn("blazing-rich-text-textcolor-button","TextColor","Text Color (Ctrl+Shift+C)","openTextColorDialog"):""}\n ${t.textColor?this._btn("blazing-rich-text-text-bg-color-button","TextBackgroundColor","Text Background Color (Ctrl+Shift+B)","openTextBackgroundColorDialog"):""}\n ${t.textColor?this._btn("blazing-rich-text-textcolor-remove-button","RemoveTextFormat","Remove Color","removeTextColor"):""}\n ${o?this._divider():""}\n\n ${t.alignLeft?this._btn("blazing-rich-text-alignleft-button","Alignleft","Align Left (Ctrl+L)","alignleft"):""}\n ${t.alignCenter?this._btn("blazing-rich-text-aligncenter-button","Aligncenter","Align Center (Ctrl+E)","aligncenter"):""}\n ${t.alignRight?this._btn("blazing-rich-text-alignright-button","Alignright","Align Right (Ctrl+R)","alignright"):""}\n ${t.alignJustify?this._btn("blazing-rich-text-alignjustify-button","Alignjustify","Align Justify (Ctrl+J)","alignjustify"):""}\n ${r?this._divider():""}\n\n ${t.cut?this._btn("blazing-rich-text-cut-button","Cut","Cut (Ctrl+X)","cut"):""}\n ${t.copy?this._btn("blazing-rich-text-copy-button","Copy","Copy (Ctrl+C)","copy"):""}\n ${t.paste?this._btn("blazing-rich-text-paste-button","Paste","Paste (Ctrl+V)","paste"):""}\n ${t.delete?this._btn("blazing-rich-text-delete-button","Delete","Delete","delete"):""}\n ${t.selectAll?this._btn("blazing-rich-text-selectall-button","Selectall","Select All (Ctrl+A)","selectall"):""}\n ${s?this._divider():""}\n\n ${t.orderedList?this._btn("blazing-rich-text-orderedlist-button","OrderedList","Ordered List (Ctrl+Shift+O)","orderedlist"):""}\n ${t.unorderedList?this._btn("blazing-rich-text-unorderedlist-button","UnorderedList","Unordered List (Ctrl+Shift+U)","unorderedlist"):""}\n ${t.indent?this._btn("blazing-rich-text-increase-indent-button","IncreaseIndent","Increase Indent (Tab)","increaseIndent"):""}\n ${t.indent?this._btn("blazing-rich-text-decrease-indent-button","DecreaseIndent","Decrease Indent (Shift+Tab)","decreaseIndent"):""}\n ${l?this._divider():""}\n\n ${t.link?this._btn("blazing-rich-text-link-button","CreateLink","Insert Link (Ctrl+Shift+K)","openLinkDialog"):""}\n ${t.link?this._btn("blazing-rich-text-remove-link-button","RemoveLink","Remove Link","removeLink"):""}\n ${t.image?this._btn("blazing-rich-text-image-button","Image","Insert Image (Ctrl+Shift+I)","openImageDialog"):""}\n ${t.imageUpload?this._btn("blazing-rich-text-image-upload-button","UploadImage","Upload Image (Ctrl+Shift+&)","uploadImageDialog"):""}\n ${t.quote?this._btn("blazing-rich-text-quote-button","Quote","Block Quote (Ctrl+Shift+Q)","openBlockQuoteDialog"):""}\n ${t.embedMedia?this._btn("blazing-rich-text-embed-button","PermMedia","Insert Media (Ctrl+Shift+M)","openMediaDialog"):""}\n ${t.video?this._btn("blazing-rich-text-video-button","VideoFile","Insert Video (Ctrl+Shift+V)","openVideoDialog"):""}\n ${t.table?this._btn("blazing-rich-text-table-button","Table","Table (Ctrl+Shift+L)","openTableDialog"):""}\n ${t.codeBlock?this._btn("blazing-rich-text-code-block-button","CodeBlocks","Code Block (Ctrl+Shift+*)","openCodeBlockDialog"):""}\n ${t.horizontalRule?this._btn("blazing-rich-text-hr-button","HorizontalRule","Horizontal Rule (Ctrl+Shift+H)","insertHorizontalRule"):""}\n ${a?this._divider():""}\n\n ${t.undo?this._btn("blazing-rich-text-undo-button","Undo","Undo (Ctrl+Z)","goBack"):""}\n ${t.redo?this._btn("blazing-rich-text-redo-button","Redo","Redo (Ctrl+Y)","goForward"):""}\n ${d?this._divider():""}\n\n ${t.htmlView?this._specialBtn("blazing-rich-text-source","Code","HTML Source (Ctrl+Shift+A)","toggleView"):""}\n ${t.preview?this._specialBtn("blazing-rich-text-preview-button","Preview","Preview (Ctrl+Shift+P)","openPreview"):""}\n ${t.fullscreen?this._fullscreenBtn():""}\n ${c?this._divider():""}\n ${this._customButtonsHTML()}\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="1" max="20" step="1" value="1" autocomplete="off" inputmode="numeric" pattern="[0-9]*">\n <label>Rows</label>\n <input type="number" id="rich-text-box-table-rows" class="rich-text-box-form-element" min="1" max="100" step="1" value="1" autocomplete="off" inputmode="numeric" pattern="[0-9]*">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input type="text" id="rich-text-box-table-width" class="rich-text-box-form-element" placeholder="500px">\n <label>Height</label>\n <input type="text" id="rich-text-box-table-height" class="rich-text-box-form-element">\n </div>\n <div class="rich-text-box-form-left">\n <label>Margin</label>\n <input type="text" id="rich-text-box-table-margin" class="rich-text-box-form-element" placeholder="10px">\n </div>\n <div class="rich-text-box-form-right">\n <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-table-float">\n <option value="none" selected>None</option>\n <option value="left">Left</option>\n <option value="right">Right</option>\n </select>\n </div>\n <div class="rich-text-box-form-left" style="clear: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 ','<label class="rich-text-box-form-checkbox-label" style="display:flex;align-items:center;"><input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-table-header"> Include Header</label>')}\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 <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 class="rich-text-box-form-left">\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 </div>\n <div class="rich-text-box-form-right">\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>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-margin" placeholder="10px" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-image-float">\n <option value="none" selected>None</option>\n <option value="left">Left</option>\n <option value="right">Right</option>\n </select>\n </div>\n <div class="rich-text-box-form-left" style="clear: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 id="rich-text-box-upload-btn" for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn" tabindex="0" onkeydown="if(event.key===\'Enter\'||event.key===\' \'){event.preventDefault();event.stopPropagation();this.click()}">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>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-margin" placeholder="10px" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-upload-image-float">\n <option value="none" selected>None</option>\n <option value="left">Left</option>\n <option value="right">Right</option>\n </select>\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 </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 ','<label class="rich-text-box-form-checkbox-label" style="display:flex;align-items:center;"><input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox"> Open in New Tab</label>')}\n\n\n ${this._buildPreviewDialogHTML()}\n ${this._buildHelpDialogHTML()}\n\n</div>`}_buildPreviewDialogHTML(){const e=this._uid;return`\n<dialog id="${e}_Preview" class="rich-text-box-modal rich-text-box-scroll rtb-preview-dialog" aria-modal="true" aria-labelledby="${e}_Preview-title">\n <div class="rtb-modal-header">\n <div id="${e}_Preview-title" class="rich-text-box-modal-title">Preview</div>\n <div style="display:flex;gap:2px;align-items:center;">\n <button id="${e}_PreviewMaxBtn" class="rich-text-box-modal-close" aria-label="Maximize preview" onclick="RTNative_Method('togglePreviewMaximize','${e}')"><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','${e}')"><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" tabindex="0"></div>\n <div style="text-align:right;flex-shrink:0;padding-right:4px;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closePreview','${e}')">Close</button>\n </div>\n </div>\n</dialog>`}_buildHelpDialogHTML(){const k=(...e)=>e.map(e=>`<kbd>${e}</kbd>`).join("+");return`\n<dialog id="rich-text-box-help-modal" class="rich-text-box-modal rtb-help-dialog" aria-labelledby="rich-text-box-help-modal-title">\n <div class="rtb-help-sticky-header">\n <div id="rich-text-box-help-modal-title" class="rich-text-box-modal-title">Keyboard Shortcuts</div>\n <button class="rich-text-box-modal-close" aria-label="Close" onclick="RTNative_Method('closeHelpDialog','${this._uid}')"><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="rtb-help-body" tabindex="0">\n <div class="rtb-help-columns">\n <div class="rtb-help-col">\n <table class="rtb-help-table">\n <tbody>\n <tr class="rtb-help-section"><td colspan="2">Text Formatting</td></tr>\n <tr><td>Bold</td><td>${k("Ctrl","B")}</td></tr>\n <tr><td>Italic</td><td>${k("Ctrl","I")}</td></tr>\n <tr><td>Underline</td><td>${k("Ctrl","U")}</td></tr>\n <tr><td>Strikethrough</td><td>${k("Ctrl","D")}</td></tr>\n <tr><td>Subscript</td><td>${k("Ctrl","=")}</td></tr>\n <tr><td>Superscript</td><td>${k("Ctrl","Shift","+")}</td></tr>\n <tr><td>Inline code</td><td>${k("Ctrl","Shift","E")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Dropdowns</td></tr>\n <tr><td>File</td><td>${k("Alt","L")}</td></tr>\n <tr><td>Font</td><td>${k("Alt","F")}</td></tr>\n <tr><td>Size</td><td>${k("Alt","S")}</td></tr>\n <tr><td>Format</td><td>${k("Alt","T")}</td></tr>\n <tr><td>Insert</td><td>${k("Alt","I")}</td></tr>\n <tr><td>More options</td><td>${k("Alt","M")}</td></tr>\n <tr><td>Increase font size</td><td>${k("Ctrl","Shift","&gt;")}</td></tr>\n <tr><td>Decrease font size</td><td>${k("Ctrl","Shift","&lt;")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Paragraph Format</td></tr>\n <tr><td>Paragraph</td><td>${k("Ctrl","Shift","D")}</td></tr>\n <tr><td>Heading 1</td><td>${k("Ctrl","Shift","1")}</td></tr>\n <tr><td>Heading 2</td><td>${k("Ctrl","Shift","2")}</td></tr>\n <tr><td>Heading 3</td><td>${k("Ctrl","Shift","3")}</td></tr>\n <tr><td>Heading 4</td><td>${k("Ctrl","Shift","4")}</td></tr>\n <tr><td>Heading 5</td><td>${k("Ctrl","Shift","5")}</td></tr>\n <tr><td>Heading 6</td><td>${k("Ctrl","Shift","6")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Edit</td></tr>\n <tr><td>Copy</td><td>${k("Ctrl","C")}</td></tr>\n <tr><td>Cut</td><td>${k("Ctrl","X")}</td></tr>\n <tr><td>Paste</td><td>${k("Ctrl","V")}</td></tr>\n <tr><td>Select all</td><td>${k("Ctrl","A")}</td></tr>\n <tr><td>Undo</td><td>${k("Ctrl","Z")}</td></tr>\n <tr><td>Redo</td><td>${k("Ctrl","Y")}</td></tr>\n </tbody>\n </table>\n </div>\n <div class="rtb-help-col">\n <table class="rtb-help-table">\n <tbody>\n <tr class="rtb-help-section"><td colspan="2">Alignment</td></tr>\n <tr><td>Align left</td><td>${k("Ctrl","L")}</td></tr>\n <tr><td>Align center</td><td>${k("Ctrl","E")}</td></tr>\n <tr><td>Align right</td><td>${k("Ctrl","R")}</td></tr>\n <tr><td>Justify</td><td>${k("Ctrl","J")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Color</td></tr>\n <tr><td>Text color</td><td>${k("Ctrl","Shift","C")}</td></tr>\n <tr><td>Background color</td><td>${k("Ctrl","Shift","B")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Lists</td></tr>\n <tr><td>Unordered list</td><td>${k("Ctrl","Shift","U")}</td></tr>\n <tr><td>Ordered list</td><td>${k("Ctrl","Shift","O")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Insert</td></tr>\n <tr><td>Link</td><td>${k("Ctrl","Shift","K")}</td></tr>\n <tr><td>Image</td><td>${k("Ctrl","Shift","I")}</td></tr>\n <tr><td>Upload / embed image</td><td>${k("Ctrl","Shift","7")}</td></tr>\n <tr><td>Media</td><td>${k("Ctrl","Shift","M")}</td></tr>\n <tr><td>Video</td><td>${k("Ctrl","Shift","V")}</td></tr>\n <tr><td>Table</td><td>${k("Ctrl","Shift","L")}</td></tr>\n <tr><td>Code block</td><td>${k("Ctrl","Shift","8")}</td></tr>\n <tr><td>Block quote</td><td>${k("Ctrl","Shift","Q")}</td></tr>\n <tr><td>Horizontal rule</td><td>${k("Ctrl","Shift","H")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">View</td></tr>\n <tr><td>Toggle HTML source</td><td>${k("Ctrl","Shift","A")}</td></tr>\n <tr><td>Preview</td><td>${k("Ctrl","Shift","P")}</td></tr>\n <tr><td>Open HTML</td><td>${k("Ctrl","O")}</td></tr>\n <tr><td>Download HTML</td><td>${k("Ctrl","S")}</td></tr>\n <tr><td>Toggle status bar</td><td>${k("Ctrl","\\")}</td></tr>\n <tr><td>Find</td><td>${k("Ctrl","F")}</td></tr>\n <tr><td>Keyboard Shortcuts</td><td>${k("Ctrl","/")}</td></tr>\n </tbody>\n </table>\n </div>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",p);
2
2
  //# sourceMappingURL=rt-native.js.map