rt-native 2.9.82 → 2.9.83

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
- const e={storageKey:"rtb-settings",legacyStatusBarKey:"rtb-status-bar-visible",colorDialogIds:["rich-text-box-text-color-modal","rich-text-box-text-bg-color-modal"],normalizeCustomColors(e){const t=Array.isArray(e)?e.slice(0,5).map(e=>/^#[0-9A-F]{6}$/i.test(e)?e.toUpperCase():""):[];for(;t.length<5;)t.push("");return t},read(){let e={};try{const t=localStorage.getItem(this.storageKey);if(t){const o=Uint8Array.from(atob(t),e=>e.charCodeAt(0));e=JSON.parse((new TextDecoder).decode(o))}}catch{}if(e&&"object"==typeof e&&!Array.isArray(e)||(e={}),"boolean"!=typeof e.statusBarVisible)try{const t=localStorage.getItem(this.legacyStatusBarKey);null!==t&&(e.statusBarVisible="1"===t)}catch{}const t=Array.isArray(e.customColors)?this.normalizeCustomColors(e.customColors):null,o=e.customColors&&"object"==typeof e.customColors&&!Array.isArray(e.customColors)?e.customColors:{};return e.customColors=Object.fromEntries(this.colorDialogIds.map(e=>[e,this.normalizeCustomColors(o[e]||t)])),e},write(e){try{const t={...this.read(),...e},o=(new TextEncoder).encode(JSON.stringify(t)),n=btoa(Array.from(o,e=>String.fromCharCode(e)).join(""));localStorage.setItem(this.storageKey,n),localStorage.removeItem(this.legacyStatusBarKey)}catch{}}};class t{constructor(e,t,o,n,i){this.id=e,this.shadow_id=t,this.toolbar_id=o,this.styles=n,this.dotNetObjectReference=i,this._selectAllActive=!1,this._suppressTableToolbarForKeyboardNavigation=!1,this.init()}init=()=>{this.hydrateShadowTree(),this.associateDialogLabels(),this.Utilities=new s(this.shadowRoot,this.content),this.NodeManager=new n(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new r(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",t="rich-text-box-text-bg-color-modal";this.ColorPickers[e]=new p(this.shadowRoot,this.content,e,this.NodeManager,this.Utilities),this.ColorPickers[t]=new p(this.shadowRoot,this.content,t,this.NodeManager,this.Utilities),this.LinkDialog=new g(this.shadowRoot,this.content,this.Utilities),this.ImageDialog=new u(this.shadowRoot,this.content,this.Utilities,this.closeImageDialog),this.UploadImageDialog=new b(this.shadowRoot,this.content,this.Utilities,this.closeUploadImageDialog),this.BlockQuoteDialog=new h(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new d(this.shadowRoot,this.content,this.Utilities),this.MediaDialog=new a(this.shadowRoot,this.content,this.Utilities,this.closeMediaDialog),this.VideoDialog=new c(this.shadowRoot,this.content,this.Utilities,this.closeVideoDialog),this.TableDialog=new l(this.shadowRoot,this.content,this.Utilities,this.closeTableDialog),this.StateManager=new o(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners(),this.addDialogCloseFocusRestoration(),this.addToolbarMenuKeyboardNavigation(),this.setDefaultParagraphSeparator(),this.initMainToolbarTabstop(),this.addMainToolbarFocusStyle()};associateDialogLabels=()=>{let e=0;this.shadowRoot.querySelectorAll("dialog").forEach(t=>{t.querySelectorAll("label").forEach(o=>{if(o.hasAttribute("for")||o.querySelector("input, select, textarea"))return;let n=o.nextElementSibling;n&&!n.matches("input, select, textarea")&&(n=n.querySelector?.("input, select, textarea")),n&&(n.id||(e++,n.id=`${t.id||"rich-text-box-dialog"}-control-${e}`),o.setAttribute("for",n.id))}),t.querySelectorAll(".rich-text-box-slider-container").forEach(e=>{const t=e.querySelector("label"),o=e.querySelector('input[type="number"]');t&&o&&!o.hasAttribute("aria-label")&&o.setAttribute("aria-label",`${t.textContent.trim()} numeric value`)})})};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)}),this.mediaResizeOverlay=document.createElement("div"),this.mediaResizeOverlay.className="rtb-media-resize-overlay",this.mediaResizeOverlay.setAttribute("aria-hidden","true"),["nw","n","ne","e","se","s","sw","w"].forEach(e=>{const t=document.createElement("span");t.className=`rtb-media-resize-handle rtb-image-resize-${e}`,t.dataset.direction=e,this.mediaResizeOverlay.appendChild(t)}),this.tableToolbar=this.createTableToolbar();const o=document.createElement("div");o.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),o.setAttribute("id","rich-text-box-message-bar");const n=document.createElement("span");n.setAttribute("class","rich-text-box-message");const i=document.createElement("button");i.setAttribute("class","rich-text-box-message-close-button"),i.setAttribute("type","button"),i.setAttribute("aria-label","Close error message"),i.textContent="�",i.onclick=e=>{e.preventDefault(),e.stopPropagation(),this.Utilities.closeFadingBar()},o.appendChild(n),o.appendChild(i),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.contentContainer.appendChild(this.mediaResizeOverlay),this.contentContainer.appendChild(this.tableToolbar),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(o),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)};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 o=this.Utilities.getSelection();return!!(o&&o.rangeCount>0&&this.isSelectionInsideEditor(o))};recoverEditorTab=e=>{this.shouldRecoverEditorTab(e)&&(e.preventDefault(),e.stopPropagation(),this.content.focus({preventScroll:!0}),this.keyEvents(e))};escapeEditor=()=>{const e=this._rtbHostElement||this.shadowRoot.host.parentElement||this.shadowRoot.host,t=Array.from(document.querySelectorAll('a[href]:not([tabindex="-1"]), button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), textarea:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])')).filter(t=>!e.contains(t)).filter(t=>!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)),o=t.length>0?t[0]:null;o&&o.focus({preventScroll:!0})};_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 o=e.querySelector(":scope > button");return o&&t.has(o.id)},o=[],n=[],i=[];for(const t of Array.from(e.children))"DIALOG"===t.tagName?i.push(t):isPinned(t)?o.push(t):n.push(t);const r=document.createElement("div");r.className="rtb-toolbar-items";for(const e of n)r.appendChild(e);for(;e.firstChild;)e.removeChild(e.firstChild);for(const t of o)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 o=l.classList.toggle("rtb-overflow-open");s.setAttribute("aria-expanded",String(o)),o&&(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 c=new ResizeObserver(()=>this._scheduleOverflowUpdate());c.observe(e),c.observe(r),c.observe(this.container),c.observe(this.contentContainer),this._overflowResizeObserver=c;for(const t of i)e.appendChild(t)};_scheduleOverflowUpdate=()=>{this._overflowItemsContainer&&!this._overflowUpdatePending&&(this._overflowUpdatePending=!0,requestAnimationFrame(()=>{this._overflowUpdatePending=!1,this._updateToolbarOverflow(),this.resizeOpenToolbarDropdowns(),this.initMainToolbarTabstop()}))};_updateToolbarOverflow=()=>{const e=this._overflowItemsContainer,t=this._overflowWrapper,o=this._overflowDropdown,n=this._overflowToolbar;if(!e)return;if(o.classList.contains("rtb-overflow-open")&&(o.style.maxWidth=n.offsetWidth-10+"px"),Array.from(o.children).forEach(t=>e.appendChild(t)),t.style.display="none",e.scrollWidth<=e.offsetWidth)return;t.style.display="";const i=Array.from(e.children);for(let t=i.length-1;t>=0&&!(e.scrollWidth<=e.offsetWidth);t--)o.insertBefore(i[t],o.firstChild);o.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({preventScroll:!0}):this.source.focus({preventScroll:!0})};scrollElementIntoNearestEditorScroller=e=>{if(!e?.getBoundingClientRect)return;let t=e.parentElement;for(;t&&t!==this.container;){const o=window.getComputedStyle(t),n=/(auto|scroll|overlay)/.test(o.overflowY)&&t.scrollHeight>t.clientHeight,i=/(auto|scroll|overlay)/.test(o.overflowX)&&t.scrollWidth>t.clientWidth;if(n||i){const o=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n&&(o.top<r.top?t.scrollTop-=r.top-o.top:o.bottom>r.bottom&&(t.scrollTop+=o.bottom-r.bottom)),void(i&&(o.left<r.left?t.scrollLeft-=r.left-o.left:o.right>r.right&&(t.scrollLeft+=o.right-r.right)))}t=t.parentElement}};scheduleCaretScrollIntoView=()=>{this._caretScrollFrame||(this._caretScrollFrame=requestAnimationFrame(()=>{this._caretScrollFrame=null,this.scrollCaretIntoView()}))};scrollCaretIntoView=()=>{if(this._suppressCaretScroll)return;if(!this.EditMode||"none"===this.content.style.display)return;const e=this.Utilities.getSelection();if(!e||0===e.rangeCount||!this.isSelectionInsideEditor(e))return;const t=e.getRangeAt(0).cloneRange();t.collapse(e.focusNode===t.startContainer&&e.focusOffset===t.startOffset);let o=t.getClientRects()[0]||t.getBoundingClientRect();if(!o||!o.width&&!o.height){const e=t.startContainer.nodeType===Node.ELEMENT_NODE?t.startContainer:t.startContainer.parentElement,n=t.startContainer.nodeType===Node.ELEMENT_NODE&&e?.childNodes?.[t.startOffset]||e;o=n?.getBoundingClientRect?.()||e?.getBoundingClientRect?.()}if(!o)return;const n=this.contentContainer,i=n.getBoundingClientRect(),r=Math.max(o.height||0,16),s=Math.ceil(r/2);o.top<i.top+s?n.scrollTop-=i.top+s-o.top:o.bottom>i.bottom-s&&(n.scrollTop+=o.bottom-(i.bottom-s)),o.left<i.left+s?n.scrollLeft-=i.left+s-o.left:o.right>i.right-s&&(n.scrollLeft+=o.right-(i.right-s))};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):[];getMainToolbarButtons=()=>{const e=[],t=this._overflowToolbar;return t?(t.querySelectorAll(":scope > .rich-text-box-dropdown > .rich-text-box-dropdown-btn").forEach(t=>{t.disabled||e.push(t)}),this._overflowItemsContainer&&this._overflowItemsContainer.querySelectorAll(":scope > button:not(:disabled)").forEach(t=>{e.push(t)}),this._overflowBtn&&this.isOverflowOptionsVisible()&&e.push(this._overflowBtn),e):e};initMainToolbarTabstop=()=>{const e=this.getMainToolbarButtons();if(!e.length)return;const t=e.find(e=>"0"===e.getAttribute("tabindex"))||e[0];e.forEach(e=>e.setAttribute("tabindex",e===t?"0":"-1"))};focusMainToolbarButton=e=>{this.getMainToolbarButtons().forEach(e=>e.setAttribute("tabindex","-1")),e.setAttribute("tabindex","0"),e.focus({preventScroll:!0})};focusToolbarMenuItem=(e,t)=>{const o=this.getToolbarMenuItems(e);if(0===o.length)return;const n=(t+o.length)%o.length;o.forEach(e=>{e.setAttribute("tabindex","-1"),e.classList.remove("active")}),o[n].classList.add("active"),o[n].focus({preventScroll:!0}),this.scrollElementIntoNearestEditorScroller(o[n])};focusFirstToolbarMenuItem=e=>{requestAnimationFrame(()=>this.focusToolbarMenuItem(e,0))};handleToolbarMenuArrowKey=(e,t)=>{const o=this.getToolbarMenuItems(t);if(0===o.length)return;const n=Math.max(0,o.indexOf(e.target)),i=t===this._overflowDropdown?"ArrowRight":"ArrowDown",r=t===this._overflowDropdown?"ArrowLeft":"ArrowUp";if(e.key===i&&(e.preventDefault(),this.focusToolbarMenuItem(t,n+1)),e.key===r||"ArrowUp"===e.key&&0===n)if(e.preventDefault(),0===n){const e=t===this._overflowDropdown?this._overflowBtn:t.closest(".rich-text-box-dropdown")?.querySelector(".rich-text-box-dropdown-btn");this.NodeManager.closeDropdowns(),e&&this.focusMainToolbarButton(e)}else this.focusToolbarMenuItem(t,n-1);"Home"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,0)),"End"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,o.length-1))};addToolbarMenuKeyboardNavigation=()=>{this.shadowRoot.addEventListener("keydown",e=>{if(e.defaultPrevented)return;if(e.altKey&&!e.ctrlKey&&!e.metaKey&&"F10"===e.key){e.preventDefault();const t=this.getMainToolbarButtons();if(t.length){const e=t.find(e=>"0"===e.getAttribute("tabindex"))||t[0];this.focusMainToolbarButton(e)}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 o=e.target.closest(".rich-text-box-dropdown-btn");if(o&&["ArrowDown","ArrowUp"].includes(e.key)){e.preventDefault();const t=o.parentElement?.querySelector(".rich-text-box-dropdown-content");if(t){t.classList.contains("rich-text-box-show")||this.openToolbarDropdown(t.id);const o="ArrowUp"===e.key?this.getToolbarMenuItems(t).length-1:0;requestAnimationFrame(()=>this.focusToolbarMenuItem(t,o))}}if(["ArrowLeft","ArrowRight"].includes(e.key)){const t=this.getMainToolbarButtons(),o=t.indexOf(e.target);if(-1!==o){e.preventDefault();const n=(o+("ArrowRight"===e.key?1:-1)+t.length)%t.length;return void this.focusMainToolbarButton(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))}e.target===this._overflowBtn&&"ArrowDown"===e.key&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this._overflowDropdown.classList.contains("rtb-overflow-open")||this.openOverflowOptions(),requestAnimationFrame(()=>this.focusToolbarMenuItem(this._overflowDropdown,0)))})};addMainToolbarFocusStyle=()=>{const e=this._overflowToolbar;e&&(e.addEventListener("focusin",e=>{const t=this.getMainToolbarButtons();t.forEach(e=>e.classList.remove("active")),t.includes(e.target)&&e.target.classList.add("active")}),e.addEventListener("focusout",t=>{e.contains(t.relatedTarget)||this.getMainToolbarButtons().forEach(e=>e.classList.remove("active"))}))};showImageResizeHandles=(e,t=!0)=>{e&&"IMG"===e.tagName&&this.content.contains(e)&&(this.hideTableResizeHandles(),this.hideMediaResizeHandles(),this.clearEditorTextSelection(),this.content.focus({preventScroll:!0}),this.selectedResizeImage=e,this._updateStatusLinkFromNode(e),this.imageResizeOverlay.classList.add("rtb-image-resize-visible"),this.positionImageResizeHandles(),this.NodeManager.selectButtons(e),t&&this.showPersistentContextToolbar(e),this.observeSelectedResizeElement(e))};hideImageResizeHandles=()=>{this._imageResizeState||(this._selectedResizeObserverElement===this.selectedResizeImage&&(this._selectedResizeObserver?.disconnect(),this._selectedResizeObserverElement=null),this.selectedResizeImage=null,this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"),this._hoveredStatusLink||this._updateStatusLinkFromNode(this.Utilities.getSelection()?.anchorNode))};showTableResizeHandles=e=>{e&&"TABLE"===e.tagName&&this.content.contains(e)&&(this.hideImageResizeHandles(),this.hideMediaResizeHandles(),this.selectedResizeTable=e,this.positionTableResizeHandles(),this.tableResizeOverlay.classList.add("rtb-table-resize-visible"),this.NodeManager.selectButtons(e),this._selectedTableResizeObserver||(this._selectedTableResizeObserver=new ResizeObserver(()=>{this.selectedResizeTable&&(this.positionTableResizeHandles(),this.positionTableToolbar())})),this._selectedTableResizeObserver.disconnect(),this._selectedTableResizeObserver.observe(e))};createTableToolbar=()=>{const e=document.createElement("div");return e.className="rtb-table-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Context tools"),e.setAttribute("aria-hidden","true"),e};addContextToolbarDivider=()=>{const e=document.createElement("span");e.className="rtb-table-toolbar-divider",e.setAttribute("aria-hidden","true"),this.tableToolbar.appendChild(e)};addContextToolbarButton=(e,t=!0)=>{const o=document.createElement("button");o.type="button",o.className=t?"rtb-table-toolbar-button rtb-table-toolbar-icon-button":"rtb-table-toolbar-button",o.setAttribute("aria-label",e.label),o.title=e.label,o.innerHTML=`${this._contextMenuIcon(e.icon)}${t?"":`<span>${e.label}</span>`}`,o.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("click",t=>{t.stopPropagation(),this.closeTableToolbarMenus();try{e.action()}finally{this.hideTableToolbar()}}),this.tableToolbar.appendChild(o)};addDialogCloseFocusRestoration=()=>{this.shadowRoot.querySelectorAll("dialog").forEach(e=>{e.addEventListener("close",()=>{requestAnimationFrame(this.focusEditorAfterDialogClose)})})};focusEditorAfterDialogClose=()=>{if(this._skipNextDialogFocusRestore)return void(this._skipNextDialogFocusRestore=!1);if(this.shadowRoot.querySelector("dialog[open]"))return;if(!1===this.EditMode)return void this.source.focus({preventScroll:!0});this.content.focus({preventScroll:!0});const e=this.shadowRoot.getSelection()||window.getSelection();if(!e)return;const t=this._lastEditorSelectionRange;if(this._lastEditorSelectionRange=null,t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))try{return e.removeAllRanges(),e.addRange(t),void this.content.focus({preventScroll:!0})}catch{}if(e.rangeCount>0&&this.content.contains(e.anchorNode)&&this.content.contains(e.focusNode))return;const o=document.createRange(),n=this.content.lastChild;n?(o.selectNodeContents(n),o.collapse(!1)):(o.setStart(this.content,0),o.collapse(!0)),e.removeAllRanges(),e.addRange(o),this.content.focus({preventScroll:!0})};rememberEditorSelection=()=>{if(this.shadowRoot.querySelector("dialog[open]"))return;const e=this.Utilities.getSelection();e?.rangeCount>0&&(this._lastEditorSelectionRange=e.getRangeAt(0).cloneRange())};clearEditorTextSelection=()=>{const e=this.shadowRoot.getSelection()||window.getSelection();e&&e.rangeCount>0&&this.isSelectionInsideEditor(e)&&e.removeAllRanges(),this._lastEditorSelectionRange=null};removeSelectedObjectAndRestoreCaret=(e,t)=>{if(!e||!this.content.contains(e))return!1;const o=e.parentNode;if(!o)return!1;const n=Array.prototype.indexOf.call(o.childNodes,e);"function"==typeof t&&t();const i=this.shadowRoot.getSelection()||window.getSelection();if(i){const t=document.createRange();if("OBJECT"===e.tagName||"VIDEO"===e.tagName){const i=this.getTopLevelEditorChild(e);if(i===e||i&&""===i.textContent.replace(/\u200B/g,"").trim()&&!Array.from(i.querySelectorAll("img, object, video, table, hr")).some(t=>t!==e)){const o=document.createElement("p");o.appendChild(document.createElement("br"));(i===e?e:i).replaceWith(o),t.setStart(o,0)}else{e.remove();const i=Math.max(0,Math.min(n,o.childNodes.length));t.setStart(o,i)}}else{e.remove();const i=Math.max(0,Math.min(n,o.childNodes.length));t.setStart(o,i)}t.collapse(!0),i.removeAllRanges(),i.addRange(t),this._lastEditorSelectionRange=t.cloneRange()}else e.remove();return this.content.focus({preventScroll:!0}),!0};scheduleResizeHandlePosition=()=>{this._resizeHandlePositionFrame||(this._resizeHandlePositionFrame=requestAnimationFrame(()=>{this._resizeHandlePositionFrame=null,this.selectedResizeImage&&this.positionImageResizeHandles(),this.selectedResizeTable&&this.positionTableResizeHandles(),this.selectedResizeMedia&&this.positionMediaResizeHandles()}))};addContextToolbarDropdown=(e,t)=>{const o=document.createElement("div");o.className="rtb-table-toolbar-dropdown";const n=document.createElement("button");n.type="button",n.className="rtb-table-toolbar-button",n.setAttribute("aria-haspopup","menu"),n.setAttribute("aria-expanded","false"),n.innerHTML=`<span>${e}</span>${this._contextMenuIcon("ArrowDown")}`,n.addEventListener("mousedown",e=>e.preventDefault());const i=document.createElement("div");i.className="rtb-table-toolbar-menu",i.setAttribute("role","menu"),t.forEach(e=>{if(e.divider){const e=document.createElement("div");return e.className="rtb-table-toolbar-menu-divider",e.setAttribute("role","separator"),void i.appendChild(e)}const t=document.createElement("button");t.type="button",t.setAttribute("role","menuitem"),t.setAttribute("tabindex","-1"),t.innerHTML=`${this._contextMenuIcon(e.icon)}<span>${e.label}</span>`,t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{t.stopPropagation(),this.closeTableToolbarMenus();try{e.action()}finally{this.hideTableToolbar()}}),i.appendChild(t)}),n.addEventListener("click",e=>{e.stopPropagation(),o.classList.contains("rtb-table-toolbar-dropdown-open")?(this.closeTableToolbarMenus(),this.focusTableToolbarControl(this.getTableToolbarControls().indexOf(n))):this.openTableToolbarMenu(o,0)}),o.append(n,i),this.tableToolbar.appendChild(o)};renderTableToolbar=()=>{this.tableToolbar.replaceChildren(),this.addContextToolbarButton({label:"Edit Table",icon:"Edit",action:()=>this.openTableDialogForElement(this._tableToolbarTable)}),this.addContextToolbarDivider(),this.addContextToolbarDropdown("Insert",[{label:"Row Above",icon:"ArrowUp",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertRowAbove(e,t))},{label:"Row Below",icon:"ArrowDown",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertRowBelow(e,t))},{label:"Column Left",icon:"ArrowLeft",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertColumnLeft(e,t))},{label:"Column Right",icon:"ArrowRight",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertColumnRight(e,t))}]),this.addContextToolbarDropdown("Align",[{label:"Left",icon:"Alignleft",action:()=>this.runTableToolbarAction((e,t)=>this.alignTableToolbarColumn(t,e,"left"),!0)},{label:"Right",icon:"Alignright",action:()=>this.runTableToolbarAction((e,t)=>this.alignTableToolbarColumn(t,e,"right"),!0)},{label:"Center",icon:"Aligncenter",action:()=>this.runTableToolbarAction((e,t)=>this.alignTableToolbarColumn(t,e,"center"),!0)}]),this.addContextToolbarDropdown("Remove",[{label:"Row",icon:"Delete",action:()=>this.runTableToolbarAction(e=>this.TableDialog.removeRow(e))},{label:"Column",icon:"Delete",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.removeColumn(e,t))},{divider:!0},{label:"Table",icon:"Delete",action:()=>{const e=this._tableToolbarTable;this.hideTableToolbar(),this._removeContentElement(e)}}]),this.addContextToolbarDivider(),this.addContextToolbarButton({label:"View HTML",icon:"Code",action:()=>this._viewElementHtml(this._tableToolbarTable)})};renderContextToolbar=(e,t)=>{this.tableToolbar.replaceChildren();const o=t.filter(e=>!e.divider),n=o.find(e=>"View HTML"===e.label),i=o.filter(e=>e!==n);if(n&&1===i.length&&"Delete"===i[0].icon)this.addContextToolbarButton(n),this.addContextToolbarDivider(),this.addContextToolbarButton(i[0]);else if("text"===e){const e=i.filter(e=>"Paragraph"===e.label||e.label.startsWith("Heading ")),t=i.find(e=>"Delete Element"===e.label),o=i.filter(e=>e.label.startsWith("Remove ")).map(e=>({...e,label:e.label.substring(7)}));o.length>0&&(this.addContextToolbarDropdown("Remove",o),this.addContextToolbarDivider()),this.addContextToolbarDropdown("Format",e),t&&(this.addContextToolbarDivider(),this.addContextToolbarButton(t))}else if("list"===e){const e=i.filter(e=>"Remove Bullet List"===e.label||"Remove Number List"===e.label),t=i.filter(t=>t.label.startsWith("Remove ")&&!e.includes(t));t.length>0&&(this.addContextToolbarDropdown("Remove",t.map(e=>({...e,label:e.label.replace(/^Remove /,"")}))),this.addContextToolbarDivider()),e.forEach((e,t)=>{t>0&&this.addContextToolbarDivider(),this.addContextToolbarButton(e)})}else"link"===e?i.forEach((e,t)=>{1===t&&this.addContextToolbarDivider(),this.addContextToolbarButton(e)}):i.forEach((e,t)=>{t>0&&this.addContextToolbarDivider(),this.addContextToolbarButton(e)});!n||1===i.length&&"Delete"===i[0].icon||(this.tableToolbar.childElementCount>0&&this.addContextToolbarDivider(),this.addContextToolbarButton(n))};getTableToolbarControls=()=>this.tableToolbar?Array.from(this.tableToolbar.querySelectorAll(":scope > .rtb-table-toolbar-button, :scope > .rtb-table-toolbar-dropdown > .rtb-table-toolbar-button")):[];focusTableToolbarControl=e=>{const t=this.getTableToolbarControls();if(0===t.length)return;const o=(e+t.length)%t.length;t.forEach(e=>e.classList.remove("active")),t[o].classList.add("active"),t[o].focus({preventScroll:!0})};focusTableToolbarMenuItem=(e,t)=>{const o=Array.from(e?.querySelectorAll('button[role="menuitem"]')||[]);if(0===o.length)return;const n=(t+o.length)%o.length;this.getTableToolbarControls().forEach(e=>e.classList.remove("active")),o.forEach(e=>e.classList.remove("active")),o[n].classList.add("active"),o[n].focus({preventScroll:!0})};openTableToolbarMenu=(e,t=0)=>{if(!e)return;this.closeTableToolbarMenus(),e.classList.add("rtb-table-toolbar-dropdown-open"),e.querySelector(":scope > button")?.setAttribute("aria-expanded","true");const o=e.querySelector(".rtb-table-toolbar-menu");requestAnimationFrame(()=>this.focusTableToolbarMenuItem(o,t))};restoreTableToolbarSelection=()=>{this.getTableToolbarControls().forEach(e=>e.classList.remove("active"));const e=this.Utilities.getSelection()||window.getSelection(),t=this._tableToolbarReturnRange;if(this._tableToolbarReturnRange=null,e&&t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))return e.removeAllRanges(),e.addRange(t),void this.content.focus({preventScroll:!0});const o=this.getTableToolbarCell();"table"===this._contextToolbarType&&o?this.TableDialog.selectCell(o):this.content.focus({preventScroll:!0})};toggleTableToolbarFocus=()=>{const e=this.shadowRoot.activeElement;if(this.tableToolbar.classList.contains("rtb-table-toolbar-visible")){if(e&&this.tableToolbar.contains(e)){const e=this._tableToolbarTable;this.closeTableToolbarMenus(),this.restoreTableToolbarSelection();e===this.selectedResizeImage&&this.imageResizeOverlay.classList.contains("rtb-image-resize-visible")||e===this.selectedResizeMedia&&this.mediaResizeOverlay.classList.contains("rtb-media-resize-visible")?(this._contextToolbarHiddenByShortcutElement=null,this.positionTableToolbar()):(this._contextToolbarHiddenByShortcutElement=e,this.hideTableToolbar())}else{const e=this.Utilities.getSelection();e?.rangeCount>0&&(this._tableToolbarReturnRange=e.getRangeAt(0).cloneRange()),this.closeTableToolbarMenus(),this.focusTableToolbarControl(0)}return!0}const t=this.Utilities.getSelection();let o=this._tableToolbarTable;if(!o||!this.content.contains(o)){const e=this.selectedResizeImage||this.selectedResizeMedia||this.selectedResizeTable,n=t?.anchorNode?.nodeType===Node.ELEMENT_NODE?t.anchorNode:t?.anchorNode?.parentElement,i=this.getContextToolbarDescriptor(e?.isConnected?e:n);if(!i)return!1;this.displayContextToolbar(i),o=i.element}if(t?.rangeCount>0&&(this._tableToolbarReturnRange=t.getRangeAt(0).cloneRange()),"table"===this._contextToolbarType){const e=this.TableDialog.getCurrentCell(t)||this.getTableToolbarCell();this.showTableToolbar(o,e)}return this.closeTableToolbarMenus(),this.focusTableToolbarControl(0),!0};getTopLevelEditorChild=e=>{let t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement;if(!t||!this.content.contains(t))return null;for(;t.parentElement&&t.parentElement!==this.content;)t=t.parentElement;return t.parentElement===this.content?t:null};getAdjacentEditorChild=(e,t)=>{let o="down"===t?e?.nextSibling:e?.previousSibling;for(;o;){if(o.nodeType===Node.ELEMENT_NODE)return o;if(o.nodeType===Node.TEXT_NODE&&""!==o.textContent.trim())return o;o="down"===t?o.nextSibling:o.previousSibling}return null};getMediaNavigationElement=(e,t)=>{if(!(e instanceof Element))return null;if(["IMG","VIDEO","OBJECT"].includes(e.tagName))return e;const o=Array.from(e.querySelectorAll("img, video, object"));return"down"===t?o[0]||null:o[o.length-1]||null};selectMediaForKeyboardNavigation=e=>!(!e||!this.content.contains(e))&&(this.content.focus({preventScroll:!0}),this.showObjectResizeHandles(e),!0);placeCaretInEditorChild=(e,t)=>{if(!e||!this.content.contains(e))return!1;const o=this.Utilities.getSelection()||window.getSelection();if(!o)return!1;this.hideImageResizeHandles(),this.hideMediaResizeHandles(),"element"===this._contextToolbarType&&this.hideTableToolbar();const n=document.createRange();return e.nodeType===Node.TEXT_NODE?n.setStart(e,"down"===t?0:e.textContent.length):(n.selectNodeContents(e),n.collapse("down"===t)),o.removeAllRanges(),o.addRange(n),this.content.focus({preventScroll:!0}),!0};isCaretAtEditorChildBoundary=(e,t,o)=>{if(!e?.isCollapsed||0===e.rangeCount||!t)return!1;const n=e.getRangeAt(0),i=document.createRange();try{i.selectNodeContents(t),"down"===o?i.setStart(n.startContainer,n.startOffset):i.setEnd(n.startContainer,n.startOffset)}catch{return!1}const r=i.cloneContents();return""===r.textContent.replace(/\u200B/g,"").trim()&&!r.querySelector("img, video, object")};isCaretOnEditorChildEdgeLine=(e,t,o)=>{if(!e?.isCollapsed||0===e.rangeCount||!t?.getBoundingClientRect)return!1;const n=e.getRangeAt(0).cloneRange();n.collapse(!0);const i=n.getClientRects()[0]||n.getBoundingClientRect(),r=t.getBoundingClientRect();if(!i||!i.width&&!i.height)return!1;const s=Math.max(i.height,16);return"down"===o?i.bottom>=r.bottom-s:i.top<=r.top+s};getMediaAdjacentToCaret=(e,t,o)=>{if(!e?.isCollapsed||0===e.rangeCount||!t)return null;const n=e.getRangeAt(0),i=Array.from(t.querySelectorAll?.("img, video, object")||[]);["IMG","VIDEO","OBJECT"].includes(t.tagName)&&i.unshift(t),"up"===o&&i.reverse();for(const e of i){const t=document.createRange();try{if("down"===o){if(t.setStart(n.startContainer,n.startOffset),t.setEndBefore(e),t.startContainer!==n.startContainer||t.startOffset!==n.startOffset)continue}else if(t.setStartAfter(e),t.setEnd(n.startContainer,n.startOffset),t.endContainer!==n.startContainer||t.endOffset!==n.startOffset)continue}catch{continue}const i=t.cloneContents();if(""===i.textContent.replace(/\u200B/g,"").trim()&&!i.querySelector("img, video, object"))return e}return null};placeCaretBesideSelectedMedia=(e,t,o)=>{if(!e||!t)return!1;const n=document.createRange();try{n.selectNodeContents(t),"down"===o?n.setStartAfter(e):n.setEndBefore(e)}catch{return!1}if(""===n.cloneContents().textContent.replace(/\u200B/g,"").trim())return!1;const i=this.Utilities.getSelection()||window.getSelection();if(!i)return!1;const r=document.createRange();return"down"===o?r.setStartAfter(e):r.setStartBefore(e),r.collapse(!0),i.removeAllRanges(),i.addRange(r),this.hideImageResizeHandles(),this.hideMediaResizeHandles(),"element"===this._contextToolbarType&&this.hideTableToolbar(),this.content.focus({preventScroll:!0}),!0};scheduleSkippedMediaNavigation=e=>{if(!["ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)return;const t=this.Utilities.getSelection();if(!t?.isCollapsed||0===t.rangeCount)return;const o=t.getRangeAt(0).cloneRange(),n="ArrowDown"===e.key?"down":"up";requestAnimationFrame(()=>{if(this.selectedResizeImage||this.selectedResizeMedia||this.selectedResizeTable)return;const e=this.Utilities.getSelection();if(!e?.isCollapsed||0===e.rangeCount)return;const t=e.getRangeAt(0).cloneRange();if(!this.content.contains(o.startContainer)||!this.content.contains(t.startContainer))return;const i=document.createRange();try{"down"===n?(i.setStart(o.startContainer,o.startOffset),i.setEnd(t.startContainer,t.startOffset)):(i.setStart(t.startContainer,t.startOffset),i.setEnd(o.startContainer,o.startOffset))}catch{return}const r=i.cloneContents();if(0===Array.from(r.querySelectorAll("object, video")).length)return;const s=Array.from(this.content.querySelectorAll("object, video")),l=("down"===n?s:s.reverse()).find(e=>i.intersectsNode(e));l&&this.selectMediaForKeyboardNavigation(l)})};navigateAccessibleMedia=e=>{if(!["ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)return!1;const t="ArrowDown"===e.key?"down":"up",o=this.selectedResizeImage||this.selectedResizeMedia;let n;if(o?.isConnected&&this.content.contains(o)){n=this.getTopLevelEditorChild(o);const i=Array.from(n?.querySelectorAll?.("img, video, object")||[]);["IMG","VIDEO","OBJECT"].includes(n?.tagName)&&i.unshift(n);const r=i.indexOf(o),s=i[r+("down"===t?1:-1)];if(s)return e.preventDefault(),this.selectMediaForKeyboardNavigation(s);if(this.placeCaretBesideSelectedMedia(o,n,t))return e.preventDefault(),!0}else{const o=this.Utilities.getSelection();if(!o?.isCollapsed)return!1;if(this.TableDialog.getCurrentCell(o))return!1;n=this.getTopLevelEditorChild(o.anchorNode);const i=this.getMediaAdjacentToCaret(o,n,t);if(i)return e.preventDefault(),this.selectMediaForKeyboardNavigation(i);if(!this.isCaretAtEditorChildBoundary(o,n,t)&&!this.isCaretOnEditorChildEdgeLine(o,n,t))return!1}const i=this.getAdjacentEditorChild(n,t);if(!i)return!1;const r=this.getMediaNavigationElement(i,t);return e.preventDefault(),r?this.selectMediaForKeyboardNavigation(r):this.placeCaretInEditorChild(i,t)};navigateIntoAdjacentTable=e=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)return!1;const t=this.Utilities.getSelection();if(!t?.isCollapsed||this.TableDialog.getCurrentCell(t))return!1;const o="ArrowRight"===e.key||"ArrowDown"===e.key,n=this.getTopLevelEditorChild(t.anchorNode);if(!n||!this.isCaretAtEditorChildBoundary(t,n,o?"down":"up"))return!1;const i=this.getAdjacentEditorChild(n,o?"down":"up");if(!(i instanceof Element)||"TABLE"!==i.tagName)return!1;const r=Array.from(i.querySelectorAll("td, th")),s=o?r[0]:r[r.length-1];return!!s&&(e.preventDefault(),this.markTableKeyboardNavigation(),this.TableDialog.selectCell(s,!o),!0)};markTableKeyboardNavigation=()=>{this._suppressTableToolbarForKeyboardNavigation=!0,clearTimeout(this._tableKeyboardNavigationTimer),this._tableKeyboardNavigationTimer=setTimeout(()=>{this._suppressTableToolbarForKeyboardNavigation=!1},1e3)};handleTableToolbarKeydown=e=>{if(e.altKey&&!e.ctrlKey&&!e.metaKey&&"o"===e.key.toLowerCase())return void(this.toggleTableToolbarFocus()&&(e.preventDefault(),e.stopPropagation()));const t=e.target;if(!(t instanceof Element&&this.tableToolbar.contains(t)))return;const o=t.closest(".rtb-table-toolbar-menu");if(o){const n=Array.from(o.querySelectorAll('button[role="menuitem"]')),i=Math.max(0,n.indexOf(t));if("ArrowDown"===e.key||"ArrowUp"===e.key)if(e.preventDefault(),"ArrowUp"===e.key&&0===i){const e=o.closest(".rtb-table-toolbar-dropdown")?.querySelector(":scope > button");this.closeTableToolbarMenus(),e?.classList.add("active"),e?.focus({preventScroll:!0})}else this.focusTableToolbarMenuItem(o,i+("ArrowDown"===e.key?1:-1));else if("Home"===e.key||"End"===e.key)e.preventDefault(),this.focusTableToolbarMenuItem(o,"Home"===e.key?0:n.length-1);else if("Escape"===e.key||"ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault();const t=o.closest(".rtb-table-toolbar-dropdown"),n=t?.querySelector(":scope > button");if(this.closeTableToolbarMenus(),"Escape"===e.key)n?.classList.add("active"),n?.focus({preventScroll:!0});else{const t=this.getTableToolbarControls().indexOf(n);this.focusTableToolbarControl(t+("ArrowRight"===e.key?1:-1))}}return}const n=this.getTableToolbarControls().indexOf(t);if(!(n<0))if("ArrowLeft"===e.key||"ArrowRight"===e.key)e.preventDefault(),this.closeTableToolbarMenus(),this.focusTableToolbarControl(n+("ArrowRight"===e.key?1:-1));else if("ArrowDown"===e.key||"ArrowUp"===e.key){const o=t.closest(".rtb-table-toolbar-dropdown");if(!o)return;e.preventDefault();const n=o.querySelectorAll('button[role="menuitem"]').length;this.openTableToolbarMenu(o,"ArrowUp"===e.key?n-1:0)}else if("Escape"===e.key){e.preventDefault();const t=this._tableToolbarTable;this.restoreTableToolbarSelection();t===this.selectedResizeImage&&this.imageResizeOverlay.classList.contains("rtb-image-resize-visible")||t===this.selectedResizeMedia&&this.mediaResizeOverlay.classList.contains("rtb-media-resize-visible")||(this._contextToolbarHiddenByShortcutElement=t,this.hideTableToolbar())}};getTableToolbarCell=()=>{if("table"!==this._contextToolbarType)return null;const e=this._tableToolbarTable;if(!e)return null;const t=this.TableDialog.getCurrentCell(this.Utilities.getSelection());return t&&e.contains(t)?t:this._tableToolbarCell?.isConnected&&e.contains(this._tableToolbarCell)?this._tableToolbarCell:e.querySelector("td, th")};runTableToolbarAction=(e,t=!1)=>{const o=this._tableToolbarTable,n=this.getTableToolbarCell();o&&o.isConnected&&n&&(this._tableToolbarCell=n,e(n,o),this.content.dispatchEvent(new Event("input",{bubbles:!0})),t&&this.restoreTableToolbarSelection(),this.positionTableToolbar())};alignTableToolbarColumn=(e,t,o)=>{const n=this.Utilities.getSelection()||window.getSelection();if((n&&!n.isCollapsed?(n.anchorNode?.nodeType===Node.ELEMENT_NODE?n.anchorNode:n.anchorNode?.parentElement)?.closest?.("td, th"):null)===t)return void(t.style.textAlign=o);const i=t.cellIndex;for(const t of e.rows)t.cells[i]&&(t.cells[i].style.textAlign=o)};showTableToolbar=(e,t=null)=>{e&&"TABLE"===e.tagName&&this.content.contains(e)&&(this._tableToolbarTable===e&&"table"===this._contextToolbarType||(this._tableToolbarBelow=!1),"table"!==this._contextToolbarType&&this.renderTableToolbar(),this._contextToolbarType="table",this._tableToolbarTable=e,this._contextToolbarSourceTarget=t||e,t&&e.contains(t)&&(this._tableToolbarCell=t),clearTimeout(this._hideTableToolbarResetTimer),this.tableToolbar.classList.add("rtb-table-toolbar-visible"),this.tableToolbar.setAttribute("aria-hidden","false"),this.observeContextToolbarElement(e),this.positionTableToolbar(),requestAnimationFrame(this.positionTableToolbar))};showContextToolbar=(e,t,o)=>{if(!e||!this.content.contains(e))return;const n=this.Utilities.getSelection();n?.rangeCount>0&&(this._tableToolbarReturnRange=n.getRangeAt(0).cloneRange()),this._contextToolbarType=t,this._tableToolbarTable=e,this._tableToolbarCell=null,this._tableToolbarBelow=!1,this.renderContextToolbar(t,o),clearTimeout(this._hideTableToolbarResetTimer),this.tableToolbar.classList.add("rtb-table-toolbar-visible"),this.tableToolbar.setAttribute("aria-hidden","false"),this.observeContextToolbarElement(e),this.positionTableToolbar(),requestAnimationFrame(this.positionTableToolbar)};refreshContextToolbarAfterAction=()=>{if(!this._tableToolbarTable?.isConnected)return void this.hideTableToolbar();if("table"===this._contextToolbarType)return void this.positionTableToolbar();const e=this.Utilities.getSelection(),t=e?.anchorNode?.nodeType===Node.ELEMENT_NODE?e.anchorNode:e?.anchorNode?.parentElement,o=t&&this.content.contains(t)?t:this._contextToolbarSourceTarget,n=this.getContextToolbarDescriptor(o);n?this.displayContextToolbar(n):this.hideTableToolbar()};observeContextToolbarElement=e=>{window.ResizeObserver&&(this._contextToolbarResizeObserver??=new ResizeObserver(this.positionTableToolbar),this._contextToolbarResizeObserver.disconnect(),this._contextToolbarResizeObserver.observe(e))};hideTableToolbar=()=>{this.closeTableToolbarMenus(),this._contextToolbarResizeObserver?.disconnect(),this._tableToolbarTable=null,this._tableToolbarCell=null,this._contextToolbarSourceTarget=null,this._contextToolbarPositionElement=null,this._contextToolbarPointerAnchor=null,this._contextToolbarType=null,this._tableToolbarBelow=!1,this.tableToolbar.classList.remove("rtb-table-toolbar-visible"),this.tableToolbar.setAttribute("aria-hidden","true"),clearTimeout(this._hideTableToolbarResetTimer),this._hideTableToolbarResetTimer=setTimeout(()=>{this.tableToolbar.classList.contains("rtb-table-toolbar-visible")||(this.tableToolbar.style.left="0px",this.tableToolbar.style.top="0px")},100)};closeTableToolbarMenus=()=>{this.tableToolbar?.querySelectorAll(".rtb-table-toolbar-dropdown-open").forEach(e=>{e.classList.remove("rtb-table-toolbar-dropdown-open"),e.querySelector(":scope > button")?.setAttribute("aria-expanded","false")}),this.tableToolbar?.querySelectorAll(".rtb-table-toolbar-menu .active").forEach(e=>{e.classList.remove("active")})};positionTableToolbar=()=>{const e=this._tableToolbarTable;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideTableToolbar();const t=["IMG","VIDEO","OBJECT"].includes(e.tagName);let o;if(this._contextToolbarPointerAnchor){const{clientX:e,clientY:t}=this._contextToolbarPointerAnchor;o={left:e,right:e,top:t,bottom:t,width:0,height:0}}else if(t)o=e.getBoundingClientRect();else{const t=this.Utilities.getSelection();let n=null;if(t?.rangeCount>0){const e=t.getRangeAt(0).cloneRange();e.collapse(!0),n=e.getBoundingClientRect(),n.width||n.height||(n=e.getClientRects()[0]||null)}const i=this._contextToolbarPositionElement?.isConnected?this._contextToolbarPositionElement:e;o=n||i.getBoundingClientRect()}const n=this.contentContainer.getBoundingClientRect(),i=this.tableToolbar.getBoundingClientRect(),r=this.tableToolbar.querySelector(".rtb-table-toolbar-dropdown-open .rtb-table-toolbar-menu"),s=r?Math.max(0,r.getBoundingClientRect().right-i.right):0,l=o.left-n.left+this.contentContainer.scrollLeft,a=o.top-n.top+this.contentContainer.scrollTop,c=this.contentContainer.scrollLeft+4,d=this.contentContainer.scrollLeft+this.contentContainer.clientWidth-i.width-s-4,h=t&&!this._contextToolbarPointerAnchor?l+(o.width-i.width)/2:l,b=o.top-n.top,u="table"===this._contextToolbarType?12:6;this._tableToolbarBelow=b<i.height+u,this.tableToolbar.style.left=`${Math.max(c,Math.min(h,d))}px`,this.tableToolbar.style.top=this._tableToolbarBelow?`${a+Math.max(o.height,t?0:16)+u}px`:a-i.height-u+"px"};syncTableToolbarWithSelection=()=>{if(!this.EditMode)return void this.hideTableToolbar();const e=this.Utilities.getSelection(),t=e?.anchorNode?.nodeType===Node.ELEMENT_NODE?e.anchorNode:e?.anchorNode?.parentElement,o=this.selectedResizeImage||this.selectedResizeMedia;if(o?.isConnected&&this.content.contains(o))return this._contextToolbarHiddenByShortcutElement=null,void(o===this._tableToolbarTable&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.showPersistentContextToolbar(o));const n=this.TableDialog.getCurrentCell(e),i=n?.closest("table");if(i&&this.content.contains(i))return this._suppressTableToolbarForKeyboardNavigation?void this.hideTableToolbar():void("table"===this._contextToolbarType&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.hideTableToolbar());const r=this.getPersistentContextElement(t);if(r)return"TABLE"===r.tagName&&t?.closest?.("caption")?void this.hideTableToolbar():"BLOCKQUOTE"===r.tagName||"PRE"===r.tagName?void(r===this._tableToolbarTable&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.tableToolbar.contains(this.shadowRoot.activeElement)||this.hideTableToolbar()):void(r!==this._contextToolbarHiddenByShortcutElement&&(r===this._tableToolbarTable&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.displayContextToolbar(this.getContextToolbarDescriptor(t))));this._contextToolbarType&&"table"!==this._contextToolbarType&&t&&this._tableToolbarTable?.contains(t)?this.positionTableToolbar():this.tableToolbar.contains(this.shadowRoot.activeElement)||this.hideTableToolbar()};hideTableResizeHandles=()=>{this._tableResizeState||(this._selectedTableResizeObserver?.disconnect(),this.selectedResizeTable=null,this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"))};showMediaResizeHandles=(e,t=!0)=>{e&&["OBJECT","VIDEO"].includes(e.tagName)&&this.content.contains(e)&&(this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.clearEditorTextSelection(),this.content.focus({preventScroll:!0}),this.selectedResizeMedia=e,this._updateStatusLinkFromNode(e),this.positionMediaResizeHandles(),this.mediaResizeOverlay.classList.add("rtb-media-resize-visible"),this.NodeManager.selectButtons(e),t&&this.showPersistentContextToolbar(e),this.observeSelectedResizeElement(e),requestAnimationFrame(()=>{this.positionMediaResizeHandles(),requestAnimationFrame(this.positionMediaResizeHandles)}))};hideMediaResizeHandles=()=>{this._mediaResizeState||(this._selectedResizeObserverElement===this.selectedResizeMedia&&(this._selectedResizeObserver?.disconnect(),this._selectedResizeObserverElement=null),this.selectedResizeMedia=null,this.mediaResizeOverlay.classList.remove("rtb-media-resize-visible"),this._hoveredStatusLink||this._updateStatusLinkFromNode(this.Utilities.getSelection()?.anchorNode))};positionMediaResizeHandles=()=>{const e=this.selectedResizeMedia;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideMediaResizeHandles();const t=e.getBoundingClientRect(),o=this.contentContainer.getBoundingClientRect();this.mediaResizeOverlay.style.left=`${t.left-o.left+this.contentContainer.scrollLeft}px`,this.mediaResizeOverlay.style.top=`${t.top-o.top+this.contentContainer.scrollTop}px`,this.mediaResizeOverlay.style.width=`${t.width}px`,this.mediaResizeOverlay.style.height=`${t.height}px`};observeSelectedResizeElement=e=>{window.ResizeObserver&&e&&(this._selectedResizeObserver??=new ResizeObserver(()=>{const e=this._selectedResizeObserverElement;this.selectedResizeImage===e&&this.positionImageResizeHandles(),this.selectedResizeMedia===e&&this.positionMediaResizeHandles(),this._tableToolbarTable===e&&this.positionTableToolbar()}),this._selectedResizeObserver.disconnect(),this._selectedResizeObserverElement=e,this._selectedResizeObserver.observe(e))};hideObjectResizeHandles=e=>{e&&("IMG"===e.tagName?this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"):"TABLE"===e.tagName?this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"):["OBJECT","VIDEO"].includes(e.tagName)&&this.mediaResizeOverlay.classList.remove("rtb-media-resize-visible"))};showObjectResizeHandles=(e,t=!0)=>{e&&e.isConnected&&this.content.contains(e)&&("IMG"===e.tagName?this.showImageResizeHandles(e,t):"TABLE"===e.tagName?this.showTableResizeHandles(e):["OBJECT","VIDEO"].includes(e.tagName)&&this.showMediaResizeHandles(e,t))};updateObjectWithResizeHandles=(e,t)=>{this.hideObjectResizeHandles(e);try{t()}finally{this.showObjectResizeHandles(e)}};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(),o=this.contentContainer.getBoundingClientRect();this.tableResizeOverlay.style.left=`${t.left-o.left+this.contentContainer.scrollLeft}px`,this.tableResizeOverlay.style.top=`${t.top-o.top+this.contentContainer.scrollTop}px`,this.tableResizeOverlay.style.width=`${t.width}px`,this.tableResizeOverlay.style.height=`${t.height}px`};startTableResize=e=>{const t=this.selectedResizeTable,o=e.currentTarget.dataset.direction;if(!t||!o)return;e.preventDefault(),e.stopPropagation();const n=t.getBoundingClientRect();this._tableResizeState={table:t,direction:o,startX:e.clientX,startY:e.clientY,startWidth:n.width,startHeight:n.height},e.currentTarget.setPointerCapture(e.pointerId),this.tableResizeOverlay.classList.add("rtb-table-resizing")};resizeSelectedTable=e=>{const t=this._tableResizeState;if(!t)return;e.preventDefault();const o=e.clientX-t.startX,n=e.clientY-t.startY,i=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(i&&r){const e=t.direction.includes("w")?-o:o,i=t.direction.includes("n")?-n:n,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+i)/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(i){const e=t.direction.includes("w")?-o:o;t.table.style.width=`${Math.max(1,Math.round(t.startWidth+e))}px`}else if(r){const e=t.direction.includes("n")?-n:n;t.table.style.height=`${Math.max(1,Math.round(t.startHeight+e))}px`}this.positionTableResizeHandles(),this.positionTableToolbar()};finishTableResize=()=>{this._tableResizeState&&(this._tableResizeState=null,this.tableResizeOverlay.classList.remove("rtb-table-resizing"),this.showObjectResizeHandles(this.selectedResizeTable))};getTableCellResizeEdge=e=>{const t=e.target instanceof Element?e.target.closest("td, th"):null,o=t?.closest("table");if(!t||!o||!this.content.contains(o))return null;const n=t.getBoundingClientRect(),i=[],r=t.parentElement,s=r?.rowIndex??-1,l=t.cellIndex;i.push({axis:"column",index:l>0?l-1:l,direction:l>0?"e":"w",distance:Math.abs(e.clientX-n.left)}),r&&i.push({axis:"column",index:l,direction:"e",distance:Math.abs(e.clientX-n.right)}),s>=0&&i.push({axis:"row",index:s>0?s-1:s,direction:s>0?"s":"n",distance:Math.abs(e.clientY-n.top)}),s>=0&&i.push({axis:"row",index:s,direction:"s",distance:Math.abs(e.clientY-n.bottom)});const a=i.filter(e=>e.distance<=5),c=a.filter(e=>"row"===e.axis).sort((e,t)=>e.distance-t.distance)[0],d=a.filter(e=>"column"===e.axis).sort((e,t)=>e.distance-t.distance)[0],h=c&&(!d||c.distance<=d.distance)?c:d||a.sort((e,t)=>e.distance-t.distance)[0];return h?{...h,table:o}: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:o,axis:n,index:i,direction:r}=t;if("column"===n){const t=Array.from(o.rows).map(e=>e.cells[i]).filter(e=>e&&1===e.colSpan);if(0===t.length)return;const s=t[0].getBoundingClientRect().width,l=parseFloat(window.getComputedStyle(t[0]).width)||s;this._tableCellResizeState={axis:n,direction:r,table:o,cells:t,startPosition:e.clientX,startSize:s,startCssSize:l,startTableSize:o.getBoundingClientRect().width}}else if("row"===n){const t=o.rows[i];if(!t)return;this._tableCellResizeState={axis:n,direction:r,table:o,row:t,startPosition:e.clientY,startSize:t.getBoundingClientRect().height,startTableSize:o.getBoundingClientRect().height}}else{const t=o.getBoundingClientRect();this._tableCellResizeState={axis:n,direction:r,table:o,startPosition:"table-column"===n?e.clientX:e.clientY,startSize:"table-column"===n?t.width:t.height}}this.content.style.cursor="column"===n||"table-column"===n?"ew-resize":"ns-resize",this.content.setPointerCapture(e.pointerId)};resizeTableCellBoundary=e=>{const t=this._tableCellResizeState;if(t){if(e.preventDefault(),"column"===t.axis){const o=e.clientX-t.startPosition,n=Math.max(1,Math.round(t.startSize+("w"===t.direction?-o:o)))-t.startSize,i=Math.max(0,t.startCssSize+n);t.cells.forEach(e=>{e.style.width=`${i}px`}),t.table.style.width=`${Math.max(1,Math.round(t.startTableSize+n))}px`,this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else if("row"===t.axis){const o=e.clientY-t.startPosition,n=Math.max(1,Math.round(t.startSize+("n"===t.direction?-o:o))),i=n-t.startSize;t.row.style.height=`${n}px`,t.table.style.height=`${Math.max(1,Math.round(t.startTableSize+i))}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}else if("table-column"===t.axis){const o=e.clientX-t.startPosition,n=Math.max(1,Math.round(t.startSize+("w"===t.direction?-o:o)));t.table.style.width=`${n}px`,this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else{const o=e.clientY-t.startPosition,n=Math.max(1,Math.round(t.startSize+("n"===t.direction?-o:o)));t.table.style.height=`${n}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}this.selectedResizeTable===t.table&&this.positionTableResizeHandles(),this._tableToolbarTable===t.table&&this.positionTableToolbar()}};finishTableCellResize=()=>{this._tableCellResizeState&&(this._tableCellResizeState=null,this._tableCellResizeEdge=null,this.content.style.cursor="",this.content.style.removeProperty("--rtb-table-cell-cursor"),this.showObjectResizeHandles(this.selectedResizeTable))};prepareTableCellInput=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return void(this._tableCellInputState=null);const t=e.anchorNode instanceof Element?e.anchorNode:e.anchorNode?.parentElement,o=t?.closest("td, th"),n=o?.closest("table");if(!o||!n||!this.content.contains(n))return void(this._tableCellInputState=null);const i=o.cellIndex,r=Array.from(n.rows).map(e=>e.cells[i]).filter(e=>e&&1===e.colSpan);if(0===r.length)return void(this._tableCellInputState=null);const s=o.getBoundingClientRect().width,l=parseFloat(window.getComputedStyle(o).width)||s,a=n.getBoundingClientRect().width;r.forEach(e=>{e.style.width=`${l}px`}),n.style.width=`${a}px`,this._tableCellInputState={cell:o,cells:r,table:n,cellWidth:s,cellCssWidth:l,tableWidth:a}};resizeTableCellForInput=()=>{const e=this._tableCellInputState;if(this._tableCellInputState=null,!e||!e.cell.isConnected||!e.table.isConnected)return;const t=window.getComputedStyle(e.cell),o=(this._tableCellMeasureCanvas||(this._tableCellMeasureCanvas=document.createElement("canvas"))).getContext("2d");if(!o)return;o.font=`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;const n=(e.cell.textContent||"").split(/\r?\n/).reduce((e,t)=>Math.max(e,o.measureText(t).width),0),i=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderLeftWidth)+parseFloat(t.borderRightWidth),r=Math.ceil(n+i);if(r<=e.cellWidth)return;const s=r-e.cellWidth,l=e.cellCssWidth+s;e.cells.forEach(e=>{e.style.width=`${l}px`}),e.table.style.width=`${e.tableWidth+s}px`};hideTableResizeHandlesForTyping=e=>{if(!["insertText","insertCompositionText","insertReplacementText"].includes(e.inputType))return;const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return;const o=t.anchorNode instanceof Element?t.anchorNode:t.anchorNode?.parentElement,n=o?.closest("td, th");n&&this.content.contains(n)&&(this._tableResizeHandlesHiddenForCell=n,this.hideTableResizeHandles())};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(),o=this.contentContainer.getBoundingClientRect();this.imageResizeOverlay.style.left=`${t.left-o.left+this.contentContainer.scrollLeft}px`,this.imageResizeOverlay.style.top=`${t.top-o.top+this.contentContainer.scrollTop}px`,this.imageResizeOverlay.style.width=`${t.width}px`,this.imageResizeOverlay.style.height=`${t.height}px`};startImageResize=e=>{const t=this.selectedResizeImage,o=e.currentTarget.dataset.direction;if(!t||!o)return;e.preventDefault(),e.stopPropagation();const n=t.getBoundingClientRect();this._imageResizeState={image:t,direction:o,startX:e.clientX,startY:e.clientY,startWidth:n.width,startHeight:n.height},e.currentTarget.setPointerCapture(e.pointerId),this.imageResizeOverlay.classList.add("rtb-image-resizing")};resizeSelectedImage=e=>{const t=this._imageResizeState;if(!t)return;e.preventDefault();const o=e.clientX-t.startX,n=e.clientY-t.startY,i=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(i&&r){const e=t.direction.includes("w")?-o:o,i=t.direction.includes("n")?-n:n,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+i)/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(i){const e=t.direction.includes("w")?-o:o;t.image.width=Math.max(1,Math.round(t.startWidth+e))}else if(r){const e=t.direction.includes("n")?-n:n;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.showObjectResizeHandles(this.selectedResizeImage))};startMediaResize=e=>{const t=this.selectedResizeMedia,o=e.currentTarget.dataset.direction;if(!t||!o)return;e.preventDefault(),e.stopPropagation();const n=t.getBoundingClientRect();this._mediaResizeState={element:t,direction:o,startX:e.clientX,startY:e.clientY,startWidth:n.width,startHeight:n.height},e.currentTarget.setPointerCapture(e.pointerId),this.mediaResizeOverlay.classList.add("rtb-media-resizing")};resizeSelectedMedia=e=>{const t=this._mediaResizeState;if(!t)return;e.preventDefault();const o=e.clientX-t.startX,n=e.clientY-t.startY,i=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(i&&r){const e=t.direction.includes("w")?-o:o,i=t.direction.includes("n")?-n:n,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+i)/t.startHeight,l=Math.max(1/t.startWidth,1/t.startHeight,Math.abs(r-1)>=Math.abs(s-1)?r:s);t.element.width=Math.max(1,Math.round(t.startWidth*l)),t.element.height=Math.max(1,Math.round(t.startHeight*l))}else if(i){const e=t.direction.includes("w")?-o:o;t.element.width=Math.max(1,Math.round(t.startWidth+e))}else if(r){const e=t.direction.includes("n")?-n:n;t.element.height=Math.max(1,Math.round(t.startHeight+e))}this.positionMediaResizeHandles()};finishMediaResize=()=>{this._mediaResizeState&&(this._mediaResizeState=null,this.mediaResizeOverlay.classList.remove("rtb-media-resizing"),this.showObjectResizeHandles(this.selectedResizeMedia))};alignSelectedResizeMedia=e=>{const t=this.selectedResizeMedia;if(!t||!this.content.contains(t))return!1;if("VIDEO"===t.tagName&&["alignleft","aligncenter","alignright"].includes(e))return this.updateObjectWithResizeHandles(t,()=>{t.style.display="block",t.style.removeProperty("float"),"aligncenter"===e?(t.style.marginLeft="auto",t.style.marginRight="auto"):"alignright"===e?(t.style.marginLeft="auto",t.style.marginRight="0"):(t.style.marginLeft="0",t.style.marginRight="auto")}),this.clearResizeMediaRange(),this.NodeManager.selectButtons(t),!0;const o=this.selectResizeMediaRange();return this.updateObjectWithResizeHandles(t,()=>this.NodeManager.updateNode(e)),o.removeAllRanges(),this.NodeManager.selectButtons(t),!0};selectResizeMediaRange=()=>{const e=this.selectedResizeMedia;if(!e||!this.content.contains(e))return null;const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const o=document.createRange();return o.selectNode(e),t.removeAllRanges(),t.addRange(o),t};clearResizeMediaRange=()=>{if(!this.selectedResizeMedia||!this.content.contains(this.selectedResizeMedia))return;const e=this.Utilities.getSelection()||window.getSelection();e?.removeAllRanges()};toggleListForSelectedResizeMedia=e=>{const t=this.selectedResizeMedia;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=t.closest("ol, ul");if(o&&this.content.contains(o))if(o.nodeName===e){const e=t.closest("li");o.parentNode.insertBefore(t,o.nextSibling),e?.remove(),o.querySelector("li")||o.remove()}else{const t=document.createElement(e);for(;o.firstChild;)t.appendChild(o.firstChild);o.replaceWith(t)}else{const o=document.createElement(e),n=document.createElement("li");t.replaceWith(o),n.appendChild(t),o.appendChild(n)}}),this.clearResizeMediaRange(),!0)};indentSelectedResizeMedia=e=>{const t=this.selectedResizeMedia;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=parseFloat(window.getComputedStyle(t).marginLeft)||0,n=e?o+40:Math.max(0,o-40);n>0?t.style.marginLeft=`${n}px`:(t.style.removeProperty("margin-left"),0===t.style.length&&t.removeAttribute("style"))}),!0)};alignSelectedResizeImage=e=>{const t=this.selectedResizeImage;return!(!t||!this.content.contains(t))&&(this.selectResizeImageRange(),this.updateObjectWithResizeHandles(t,()=>this.NodeManager.updateNode(e)),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");this.content.insertBefore(t,e),t.appendChild(e)}const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const o=document.createRange();return o.selectNode(e),t.removeAllRanges(),t.addRange(o),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;return!(!t||!this.content.contains(t))&&(this.selectResizeImageRange(),this.updateObjectWithResizeHandles(t,()=>{const o=t.closest("ol, ul");if(o&&this.content.contains(o))this.ListProvider.addlist(e);else{const o=t.parentElement;if(!o||o===this.content)return;const n=document.createElement(e),i=document.createElement("li");for(;o.firstChild;)i.appendChild(o.firstChild);n.appendChild(i),o.replaceWith(n),this.selectResizeImageRange()}}),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 o=document.createRange();return o.selectNode(e),t.removeAllRanges(),t.addRange(o),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,o=t?.closest("td, th");return!!o&&this.selectedResizeTable.contains(o)};alignSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>this.NodeManager.alignTable(t,e)),this.clearResizeTableRange(),this.NodeManager.selectButtons(t),!0)};toggleListForSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=t.closest("ol, ul");if(o&&this.content.contains(o))if(o.nodeName===e){const e=t.closest("li");o.parentNode.insertBefore(t,o.nextSibling),e?.remove(),o.querySelector("li")||o.remove()}else{const t=document.createElement(e);for(;o.firstChild;)t.appendChild(o.firstChild);o.replaceWith(t)}else{const o=document.createElement(e),n=document.createElement("li");t.replaceWith(o),n.appendChild(t),o.appendChild(n)}}),this.clearResizeTableRange(),!0)};indentSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=parseFloat(window.getComputedStyle(t).marginLeft)||0,n=e?o+40:Math.max(0,o-40);n>0?t.style.marginLeft=`${n}px`:(t.style.removeProperty("margin-left"),0===t.style.length&&t.removeAttribute("style"))}),!0)};addEventListeners=()=>{document.addEventListener("keydown",this.recoverEditorTab,!0),this.shadowRoot.addEventListener("keydown",e=>{this.handleTableToolbarKeydown(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.rememberEditorSelection(),this.clearSettings(t.anchorNode),this._hoveredStatusLink||this._updateStatusLinkFromNode(t.anchorNode),this.scheduleCaretScrollIntoView())}),this.content.addEventListener("mouseover",e=>{const t=e.target instanceof Element?e.target.closest("a, img, blockquote, object, video"):null;t&&this.content.contains(t)&&(this._hoveredStatusLink=t,this._setStatusLink(this._getStatusLinkAddress(t)))}),this.content.addEventListener("mouseout",e=>{if(!this._hoveredStatusLink)return;if((e.relatedTarget instanceof Element?e.relatedTarget.closest("a, img, blockquote, object, video"):null)===this._hoveredStatusLink)return;this._hoveredStatusLink=null;const t=this.Utilities.getSelection();this._updateStatusLinkFromNode(t?.anchorNode)}),this.contentContainer.addEventListener("pointerdown",e=>{if("block"!==this.content.style.display)return;const t=e.target instanceof Element?e.target:null,o=t?.closest("img, object, video, source");if(o&&this.content.contains(o)){if("touch"===e.pointerType){const e="SOURCE"===o.tagName?o.closest("video"):o;e&&["OBJECT","VIDEO"].includes(e.tagName)&&this.showMediaResizeHandles(e)}return void e.preventDefault()}const n=this.content.getBoundingClientRect();if(!(e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom))return;const i=this.contentContainer.getBoundingClientRect(),r=this.contentContainer.offsetWidth-this.contentContainer.clientWidth,s=this.contentContainer.offsetHeight-this.contentContainer.clientHeight,l=r>0&&e.clientX>=i.right-r,a=s>0&&e.clientY>=i.bottom-s;l||a||(e.preventDefault(),this.content.focus({preventScroll:!0}))},!0),this.contentContainer.addEventListener("click",e=>{if("block"!==this.content.style.display)return;const t=this.content.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this.NodeManager.closeDropdowns()}),this.content.addEventListener("click",e=>{if(this.closeTableToolbarMenus(),"IMG"===e.target.tagName)this.showImageResizeHandles(e.target);else if("OBJECT"===e.target.tagName||"VIDEO"===e.target.tagName||"SOURCE"===e.target.tagName){const t="SOURCE"===e.target.tagName?e.target.closest("video"):e.target;this.showMediaResizeHandles(t)}else{this.hideImageResizeHandles(),this.hideMediaResizeHandles();const t=e.target instanceof Element?e.target.closest("table"):null;if(t&&this.content.contains(t)){const o=e.target.closest("td, th");"table"===this._contextToolbarType&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")&&this._tableToolbarCell&&o!==this._tableToolbarCell?this.hideTableToolbar():this._tableToolbarCell=o,o&&o===this._tableResizeHandlesHiddenForCell?this.hideTableResizeHandles():(this._tableResizeHandlesHiddenForCell=null,this.showTableResizeHandles(t))}else this._tableResizeHandlesHiddenForCell=null,this.hideTableResizeHandles()}"A"===e.target.tagName&&(e.preventDefault(),e.stopPropagation())}),this.content.addEventListener("click",e=>{const t=e.target.tagName;if("OBJECT"!==t){if("VIDEO"===t||"SOURCE"===t){e.preventDefault();const o="SOURCE"===t?e.target.closest("video"):e.target;this.showMediaResizeHandles(o)}}else this.showMediaResizeHandles(e.target)},!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(),e.target.src.startsWith("data")?this.openUploadImageDialogForElement(e.target):this.openImageDialogForElement(e.target);break;case"VIDEO":case"SOURCE":{e.preventDefault();const t="SOURCE"===e.target.tagName?e.target.closest("video"):e.target;t?this.openVideoDialogForElement(t):this.openVideoDialog();break}case"OBJECT":e.preventDefault(),this.openMediaDialogForElement(e.target);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 o=e.target.closest("blockquote");if(o&&this.content.contains(o))e.preventDefault(),this.openBlockQuoteDialogForElement(o);else{const e=this.Utilities.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const t=e.getRangeAt(0),o=t.endContainer;if(o.nodeType===Node.TEXT_NODE){const n=o.textContent;let i=t.endOffset;for(;i>0&&/\s/.test(n[i-1]);)i--;i!==t.endOffset&&(t.setEnd(o,i),e.removeAllRanges(),e.addRange(t))}}}break}}}),this.content.addEventListener("beforeinput",e=>{this.closeTableToolbarMenus(),("text"===this._contextToolbarType||"element"===this._contextToolbarType&&["BLOCKQUOTE","PRE"].includes(this._tableToolbarTable?.tagName))&&this.hideTableToolbar(),this.prepareTableCellInput(),this.hideTableResizeHandlesForTyping(e)}),this.content.addEventListener("input",e=>{this.resizeTableCellForInput(),this.scheduleResizeHandlePosition(),this.scheduleCaretScrollIntoView(),this._selectAllActive=!1,this.updateWordCount();const t=this.Utilities.getSelection(),o=t.getRangeAt(0).startContainer;if(o.nodeType===Node.TEXT_NODE&&"SPAN"===o.parentNode.tagName){const e=o.parentNode,n=e.parentNode;if(this.NodeManager.isFormatElement(n)){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;)n.insertBefore(e.firstChild,e);n.removeChild(e);const o=document.createRange();o.setStart(n.firstChild,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}}}),this.content.addEventListener("keydown",e=>{this.keyEvents(e),this.scheduleCaretScrollIntoView()}),this.content.addEventListener("keyup",()=>{this.scheduleCaretScrollIntoView()}),this.content.addEventListener("mouseup",()=>{this.scheduleCaretScrollIntoView()}),this.source.addEventListener("keydown",e=>{if("Escape"===e.key)return e.preventDefault(),void this.escapeEditor();"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&&"f"===e.key.toLowerCase()&&(e.preventDefault(),this.toggleEditorFullscreen()),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.mediaResizeOverlay.querySelectorAll(".rtb-media-resize-handle").forEach(e=>{e.addEventListener("pointerdown",this.startMediaResize)}),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.resizeSelectedMedia),document.addEventListener("pointermove",this.resizeTableCellBoundary),document.addEventListener("pointerup",this.finishImageResize),document.addEventListener("pointerup",this.finishTableResize),document.addEventListener("pointerup",this.finishMediaResize),document.addEventListener("pointerup",this.finishTableCellResize),document.addEventListener("pointercancel",this.finishImageResize),document.addEventListener("pointercancel",this.finishTableResize),document.addEventListener("pointercancel",this.finishMediaResize),document.addEventListener("pointercancel",this.finishTableCellResize),document.addEventListener("pointerdown",e=>{const t=e.composedPath(),o=t.find(e=>e instanceof Element&&e!==this.content&&this.content.contains(e)),n=this.getPersistentContextElement(o);if(!this._tableToolbarTable||t.includes(this._tableToolbarTable)||t.includes(this.tableToolbar)||n||this.hideTableToolbar(),!this.selectedResizeImage&&!this.selectedResizeTable&&!this.selectedResizeMedia||this._imageResizeState||this._tableResizeState||this._mediaResizeState)return;const i=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&&i.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)||"OBJECT"===this.selectedResizeMedia?.tagName&&t.some(e=>e instanceof Element&&"blazing-rich-text-embed-button"===e.id)||"VIDEO"===this.selectedResizeMedia?.tagName&&t.some(e=>e instanceof Element&&"blazing-rich-text-video-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.selectedResizeMedia||t.includes(this.selectedResizeMedia)||t.includes(this.mediaResizeOverlay)||this.hideMediaResizeHandles())}),this.contentContainer.addEventListener("scroll",this.positionImageResizeHandles),this.contentContainer.addEventListener("scroll",this.positionTableResizeHandles),this.contentContainer.addEventListener("scroll",this.positionMediaResizeHandles),this.contentContainer.addEventListener("scroll",this.positionTableToolbar),window.addEventListener("resize",this.positionImageResizeHandles),window.addEventListener("resize",this.positionTableResizeHandles),window.addEventListener("resize",this.positionMediaResizeHandles),window.addEventListener("resize",this.positionTableToolbar),document.addEventListener("selectionchange",this.syncTableToolbarWithSelection),this.content.addEventListener("input",this.positionTableToolbar);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"),[o,n]=this.findBar.querySelectorAll(".rtb-find-nav-btn"),i=this.findBar.querySelector(".rtb-find-close-btn");e.addEventListener("paste",t=>{t.preventDefault();const o=(t.clipboardData||window.clipboardData).getData("text").trim(),n=e.selectionStart,i=e.selectionEnd;e.value=e.value.substring(0,n)+o+e.value.substring(i),e.selectionStart=e.selectionEnd=n+o.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())}),o.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("mousedown",e=>e.preventDefault()),i.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("click",()=>{this.findPrev(),e.focus({preventScroll:!0})}),n.addEventListener("click",()=>{this.findNext(),e.focus({preventScroll:!0})}),i.addEventListener("click",()=>this.closeFindBar()),this.content.addEventListener("pointerdown",e=>{this._selectAllActive=!1,this._lastPointerType=e.pointerType,this._suppressTableToolbarForKeyboardNavigation=!1,clearTimeout(this._tableKeyboardNavigationTimer),this.closeTableToolbarMenus(),("text"===this._contextToolbarType||"element"===this._contextToolbarType&&["BLOCKQUOTE","PRE"].includes(this._tableToolbarTable?.tagName))&&this.hideTableToolbar()}),this.content.addEventListener("contextmenu",e=>this.openEditorContextMenu(e),!0),this.content.addEventListener("paste",e=>{if(this.pasteTableValuesIntoCells(e))return;const t=new Set(this.content.querySelectorAll("table"));requestAnimationFrame(()=>{this.content.querySelectorAll("table").forEach(e=>{t.has(e)||this.moveTableOutsideParagraph(e)})});const o=e.clipboardData?.getData("text/html")||"";if(o){const e=document.createElement("template");e.innerHTML=o;const t=e.content.querySelector("img");t&&(this._imageClipboardHtml=t.outerHTML)}else{const t=Array.from(e.clipboardData?.items||[]).find(e=>e.type.startsWith("image/")),o=t?.getAsFile();if(o){const e=new FileReader;e.onload=()=>{const t=document.createElement("img");t.src=e.result,this._imageClipboardHtml=t.outerHTML},e.readAsDataURL(o)}}const n=e.clipboardData?.getData("text/plain")||"";n&&(e.preventDefault(),this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=n,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 o=Array.from(t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(e=>!e.disabled&&null!==e.offsetParent).map((e,t)=>({el:e,index:t,tabIndex:e.tabIndex})).sort((e,t)=>{const o=e.tabIndex>0,n=t.tabIndex>0;return o&&n?e.tabIndex-t.tabIndex||e.index-t.index:o?-1:n?1:e.index-t.index}).map(e=>e.el);if(0===o.length)return e.preventDefault(),t.focus({preventScroll:!0}),!0;const n=o[0],i=o[o.length-1],r=this.shadowRoot.activeElement;return t.contains(r)?e.shiftKey&&r===n?(e.preventDefault(),i.focus({preventScroll:!0}),!0):!e.shiftKey&&r===i&&(e.preventDefault(),n.focus({preventScroll:!0}),!0):(e.preventDefault(),n.focus({preventScroll:!0}),!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,o=this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)?this.selectedResizeMedia:null;this.NodeManager.selectButtons(t||o||e)};getPreviousMeaningfulSibling=e=>{let t=e?.previousSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;return t};removeTrailingBreak=e=>{if(e?.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.lastChild;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;return"BR"===t?.nodeName&&(t.remove(),!0)};removeTrailingBreakBeforeBlock=e=>{let t=e;for(;t&&t!==this.content;){const e=this.getPreviousMeaningfulSibling(t);if(e)return this.removeTrailingBreak(e);t=t.parentNode}return!1};removeBreakBeforeCaretAtBlockEnd=(e,t)=>{const o=document.createRange();o.setStart(e.startContainer,e.startOffset),o.setEnd(t,t.childNodes.length);const n=o.cloneContents();if(n.textContent.length>0||n.querySelector("*"))return!1;let i=e.startContainer,r=e.startOffset;for(;i&&i!==t;){if(i.nodeType===Node.ELEMENT_NODE&&r>0){const e=i.childNodes[r-1];return"BR"===e?.nodeName&&(e.remove(),!0)}r=Array.prototype.indexOf.call(i.parentNode.childNodes,i),i=i.parentNode}if(i===t&&r>0){const e=t.childNodes[r-1];if("BR"===e?.nodeName)return e.remove(),!0}return!1};getCaretAdjacentNode=(e,t,o)=>{let n=e.startContainer,i=e.startOffset;if(n.nodeType===Node.TEXT_NODE){if(o&&i>0||!o&&i<n.textContent.length)return null;const e=n.parentNode;i=Array.prototype.indexOf.call(e.childNodes,n)+(o?0:1),n=e}for(;n&&n.nodeType===Node.ELEMENT_NODE;){const e=n.childNodes[i-(o?1:0)];if(e){if(e.nodeType===Node.TEXT_NODE&&""===e.textContent.trim()){i+=o?-1:1;continue}return e}if(n===t)break;const r=n.parentNode;i=Array.prototype.indexOf.call(r.childNodes,n)+(o?0:1),n=r}return null};isBreakOnlyBlock=e=>!(!e||""!==e.textContent.replace(/\u200B/g,"").trim())&&(!e.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr")&&Array.from(e.querySelectorAll("*")).every(e=>"BR"===e.tagName));removeAdjacentEmptyParagraph=(e,t,o)=>{if(!t?.isCollapsed||!o)return!1;const n=this.getCaretAdjacentNode(o,this.content,"Backspace"===e);if(n?.nodeType!==Node.ELEMENT_NODE||"P"!==n.tagName||n.contains(o.startContainer)||!this.isBreakOnlyBlock(n))return!1;const i=o.cloneRange();return n.remove(),t.removeAllRanges(),t.addRange(i),!0};removeEmptyLineBreak=(e,t,o,n)=>{if(!t?.isCollapsed||!n||n===this.content)return!1;if("Backspace"===e&&this.isBreakOnlyBlock(n)){const e=this.getPreviousMeaningfulSibling(n);if(!e)return!1;n.remove();const o=document.createRange();return o.selectNodeContents(e),o.collapse(!1),t.removeAllRanges(),t.addRange(o),!0}const i=this.getCaretAdjacentNode(o,n,!1),r=this.getCaretAdjacentNode(o,n,!0),s="Delete"===e&&"BR"===i?.nodeName?i:"BR"===r?.nodeName?r:null;if(!s)return!1;const l=s.parentNode,a=Array.prototype.indexOf.call(l.childNodes,s);s.remove();const c=document.createRange();return c.setStart(l,Math.min(a,l.childNodes.length)),c.collapse(!0),t.removeAllRanges(),t.addRange(c),!0};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(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey||(this.markTableKeyboardNavigation(),this.scheduleSkippedMediaNavigation(e)),this.navigateIntoAdjacentTable(e))return;if(this.navigateAccessibleMedia(e))return;if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeImage&&this.content.contains(this.selectedResizeImage))return e.preventDefault(),void this.preservePageScrollDuringDelete(()=>{const e=this.selectedResizeImage;this.removeSelectedObjectAndRestoreCaret(e,this.hideImageResizeHandles),this.updateWordCount()});if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)&&!this.isSelectionInsideSelectedTableCell())return e.preventDefault(),void this.preservePageScrollDuringDelete(()=>{const e=this.selectedResizeTable;this.hideTableResizeHandles(),e.remove(),this.updateWordCount()});if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia))return e.preventDefault(),void this.preservePageScrollDuringDelete(()=>{const e=this.selectedResizeMedia;this.removeSelectedObjectAndRestoreCaret(e,this.hideMediaResizeHandles),this.updateWordCount()});const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&!this.isSelectionInsideEditor(t))return void e.preventDefault();if(("Delete"===e.key||"Backspace"===e.key||46===e.keyCode||8===e.keyCode)&&t&&!t.isCollapsed&&this.isSelectionInsideEditor(t))return e.preventDefault(),void this.delete();if(this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),!("Escape"!==e.key||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey))return e.preventDefault(),void this.escapeEditor();if("Enter"===e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&(this.insertCleanParagraphAtBlockStart()||this.insertParagraphAtTableBoundary()||this.insertParagraphAfterStructuredBlock()))return void e.preventDefault();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()),e.ctrlKey&&"v"===e.key.toLowerCase()&&this._mediaClipboardHtml&&(e.preventDefault(),this.paste()),"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 o=t.getRangeAt(0);if(this.removeAdjacentEmptyParagraph("Delete",t,o))return void e.preventDefault();const n=["P","DIV","H1","H2","H3","H4","H5","H6","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let i=t.anchorNode;for(;i&&i!==this.content&&(i.nodeType!==Node.ELEMENT_NODE||!n.includes(i.nodeName));)i=i.parentNode;if(i&&i!==this.content){if(this.removeEmptyLineBreak("Delete",t,o,i))return void e.preventDefault();const n=""===i.textContent.trim()&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed"),r=i.querySelector("table, hr");if(n&&this.removeTrailingBreakBeforeBlock(i)||(!n||r)&&this.removeBreakBeforeCaretAtBlockEnd(o,i))return void e.preventDefault();if(n){e.preventDefault();let o=null,n=i.nextSibling;for(;n;){if(n.nodeType===Node.ELEMENT_NODE){o=n;break}if(n.nodeType===Node.TEXT_NODE&&""!==n.textContent.trim()){o=n;break}n=n.nextSibling}if(i.parentNode.removeChild(i),o){const e=document.createRange();e.selectNodeContents(o),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(o.startContainer,o.startOffset),t.setEnd(i,i.childNodes.length);const n=t.cloneContents();if(0===t.toString().length&&!n.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=i.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.nextSibling;let o=i.nodeName;if(!t){let e=i,n=i.parentNode;for(;n&&n!==this.content;){let i=null;for(let e=n.childNodes.length-1;e>=0;e--){const t=n.childNodes[e];if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&""!==t.textContent.trim()){i=t;break}}if(i!==e)break;let r=n.nextSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.nextSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,o=n.nodeName;break}e=n,n=n.parentNode}}const n=["P","A"];if(!t||t.nodeType!==Node.ELEMENT_NODE||t.nodeName===o||n.includes(o)&&n.includes(t.nodeName)){if(t&&t.nodeType===Node.ELEMENT_NODE){const e=i.style.fontFamily,o=t.style.fontFamily;e&&!o?t.style.fontFamily=e:!e&&o&&(i.style.fontFamily=o)}}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&&"f"===e.key.toLowerCase()&&(e.preventDefault(),this.toggleEditorFullscreen()),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 o=t.getRangeAt(0);if(this.removeAdjacentEmptyParagraph("Backspace",t,o))return void e.preventDefault();const n=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let i=t.anchorNode;for(;i&&i!==this.content&&(i.nodeType!==Node.ELEMENT_NODE||!n.includes(i.nodeName));)i=i.parentNode;if(i&&i!==this.content){if(this.removeEmptyLineBreak("Backspace",t,o,i))return void e.preventDefault();const n=document.createRange();n.selectNodeContents(i),n.setEnd(o.startContainer,o.startOffset);const r=n.cloneContents(),s=0===r.textContent.length&&!r.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed");if(s&&this.removeTrailingBreakBeforeBlock(i))return void e.preventDefault();let l=i.previousSibling;for(;l&&l.nodeType===Node.TEXT_NODE&&""===l.textContent.trim();)l=l.previousSibling;const a=l?.nodeType===Node.ELEMENT_NODE&&""===l.textContent.trim()&&!l.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr");if(s&&a){e.preventDefault();const n=o.cloneRange();return l.remove(),t.removeAllRanges(),void t.addRange(n)}if((parseFloat(window.getComputedStyle(i).marginLeft)||0)>0){const t=document.createRange();t.setStart(i,0),t.setEnd(o.startContainer,o.startOffset),0===t.toString().length&&(e.preventDefault(),this.decreaseIndent())}else{if(""===i.textContent.trim()&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){e.preventDefault();let o=null,n=i.previousSibling;for(;n;){if(n.nodeType===Node.ELEMENT_NODE){o=n;break}if(n.nodeType===Node.TEXT_NODE&&""!==n.textContent.trim()){o=n;break}n=n.previousSibling}if(i.parentNode.removeChild(i),o){const e=document.createRange();e.selectNodeContents(o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(i,0),t.setEnd(o.startContainer,o.startOffset);const n=t.cloneContents();if(0===t.toString().length&&!n.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=i.previousSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;let o=i.nodeName;if(!t){let e=i,n=i.parentNode;for(;n&&n!==this.content;){let i=null;for(const e of n.childNodes)if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&""!==e.textContent.trim()){i=e;break}if(i!==e)break;let r=n.previousSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,o=n.nodeName;break}e=n,n=n.parentNode}}const n=["P","A"];if(t&&t.nodeType===Node.ELEMENT_NODE){if(n.includes(o)?!n.includes(t.nodeName):t.nodeName!==o)e.preventDefault();else{const e=t.style.fontFamily,o=i.style.fontFamily;e&&!o?i.style.fontFamily=e:!e&&o&&(t.style.fontFamily=o)}}}}}}}}if(!("ArrowLeft"!==e.key||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)){const t=this.Utilities.getSelection();if(t&&t.isCollapsed){const o=t.getRangeAt(0),n=["H1","H2","H3","H4","H5","H6"];let i=t.anchorNode;for(;i&&i!==this.content&&(i.nodeType!==Node.ELEMENT_NODE||!n.includes(i.nodeName));)i=i.parentNode;if(i&&i!==this.content&&n.includes(i.nodeName)){const n=document.createRange();n.setStart(i,0),n.setEnd(o.startContainer,o.startOffset);const r=n.cloneContents();if(0===n.toString().length&&!r.querySelector("*")){let o=i.previousSibling;for(;o&&o.nodeType===Node.TEXT_NODE&&""===o.textContent.trim();)o=o.previousSibling;if(o&&"TABLE"===o.nodeName){e.preventDefault();const n=document.createRange();n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}}}}const o=this.TableDialog.getCurrentCell(this.Utilities.getSelection()),n=o&&["ArrowUp","ArrowDown"].includes(e.key),i=o&&["ArrowLeft","ArrowRight"].includes(e.key)&&this.Utilities.getSelection()?.isCollapsed;if(!n&&!i||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey){if(e.shiftKey&&"Tab"===e.key)e.preventDefault(),o?this.TableDialog.tableTab(!0):this.decreaseIndent();else if("Tab"===e.key){const t=this.Utilities.getSelection();if(null!==t&&null!=t.anchorNode){e.preventDefault();const o=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement,n=o?.closest("blockquote"),i=o?.closest("pre"),r=o?.closest("td, th");if(n&&this.content.contains(n)||i&&this.content.contains(i)){let e=i&&this.content.contains(i)?i:n;for(;e.parentNode&&e.parentNode!==this.content;)e=e.parentNode;let o=e.nextSibling;for(;o&&o.nodeType!==Node.ELEMENT_NODE;)o=o.nextSibling;if(o){this.content.focus({preventScroll:!0});const e=document.createRange();e.selectNodeContents(o),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else r&&this.content.contains(r)?this.TableDialog.tableTab(!1):this.increaseIndent()}}}else this.markTableKeyboardNavigation(),i?this.TableDialog.moveCaretHorizontally(e.key)&&e.preventDefault():(e.preventDefault(),this.TableDialog.navigateCell(e.key))};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 o=t.closest("pre");if(o&&this.content.contains(o))return o;const n=t.closest("blockquote");return n&&this.content.contains(n)?n: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 o=document.createElement("p");o.appendChild(document.createElement("br"));let n=t;for(;n.parentNode&&n.parentNode!==this.content;)n=n.parentNode;if(n.parentNode!==this.content)return!1;n.nextSibling?this.content.insertBefore(o,n.nextSibling):this.content.appendChild(o);const i=document.createRange();return i.setStart(o,0),i.collapse(!0),e.removeAllRanges(),e.addRange(i),this.content.focus({preventScroll:!0}),!0};insertCleanParagraphAtBlockStart=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;const t=e.getRangeAt(0),o=t.cloneRange(),n=t.startContainer instanceof Element?t.startContainer:t.startContainer.parentElement,i=n?.closest("p, div, h1, h2, h3, h4, h5, h6");if(!i||i===this.content||i.parentElement!==this.content)return!1;const r=document.createRange();r.selectNodeContents(i),r.setEnd(t.startContainer,t.startOffset);const s=r.cloneContents();if(s.textContent.length>0||s.querySelector("br, img, video, audio, object, table, hr"))return!1;const l=document.createElement("p");return l.appendChild(document.createElement("br")),i.parentNode.insertBefore(l,i),e.removeAllRanges(),e.addRange(o),this.content.focus({preventScroll:!0}),!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 o=t.startOffset,n=this.content.childNodes[o],i=o>0?this.content.childNodes[o-1]:null;if("TABLE"!==n?.nodeName&&"TABLE"!==i?.nodeName)return!1;const r=document.createElement("p");r.appendChild(document.createElement("br")),this.content.insertBefore(r,n??null);const s=document.createRange();return s.setStart(r,0),s.collapse(!0),e.removeAllRanges(),e.addRange(s),this.content.focus({preventScroll:!0}),!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),o=window.getComputedStyle(t.commonAncestorContainer.parentElement);this.fontSize=parseFloat(o.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 o=e.shadowRoot?.querySelector("iframe");if(!o?.contentWindow)return;const n=o.contentWindow,i=.9*n.innerHeight,r=n.document.documentElement.scrollHeight,s="ArrowUp"===t.key?-50:"ArrowDown"===t.key?50:"PageUp"===t.key?-i:"PageDown"===t.key?i:"Home"===t.key?-r:r;n.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||"",o=e.shadowRoot||e.attachShadow({mode:"open"});for(;o.firstChild;)o.removeChild(o.firstChild);const n=document.createElement("style");n.textContent=":host{display:block;position:relative;}iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none;}",o.appendChild(n);const i=(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")),c=["<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;}","</style>"].join(""),d=document.createElement("iframe");d.srcdoc=["<!DOCTYPE html><html><head>",'<meta charset="UTF-8">',c,i,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(""),o.appendChild(d),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus({preventScroll:!0}),this.content.focus({preventScroll:!0})};togglePreviewMaximize=()=>{const e=this.shadowRoot.getElementById(`${this.id}_Preview`),t=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!e||!t)return;const o=!e.hasAttribute("data-maximized"),n=[["width","100vw"],["height","100vh"],["max-width","100vw"],["max-height","100vh"],["top","0"],["left","0"],["transform","none"],["border-radius","0"],["resize","none"]];o?(e.setAttribute("data-maximized",""),n.forEach(([t,o])=>e.style.setProperty(t,o))):(e.removeAttribute("data-maximized"),n.forEach(([t])=>e.style.removeProperty(t))),t.setAttribute("aria-label",o?"Restore preview":"Maximize preview"),t.querySelector("svg").innerHTML=o?'<path d="M4.5 1.5V4.5H1.5M7.5 10.5V7.5H10.5M4.5 4.5L1.5 1.5M7.5 7.5L10.5 10.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>':'<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>'};_resetPreviewMaximize=()=>{const 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 o=this._rtbHostElement;if(t){if(this._editorFullscreenBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",o){o.classList.add("rtb-host-fullscreen"),this._editorFullscreenPopoverValue=o.getAttribute("popover"),o.setAttribute("popover","manual");try{o.showPopover(),this._editorFullscreenUsingPopover=!0}catch{this._editorFullscreenUsingPopover=!1}}}else document.body.style.overflow=this._editorFullscreenBodyOverflow||"",o&&(this._editorFullscreenUsingPopover&&o.matches(":popover-open")&&o.hidePopover(),o.classList.remove("rtb-host-fullscreen"),null===this._editorFullscreenPopoverValue?o.removeAttribute("popover"):o.setAttribute("popover",this._editorFullscreenPopoverValue),this._editorFullscreenUsingPopover=!1);e.setAttribute("aria-label",t?"Restore editor":"Maximize editor"),e.setAttribute("title",(t?"Restore Editor":"Maximize Editor")+" (Ctrl+Shift+F)"),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 o=t.startContainer;if(o===this.content){const e=this.content.childNodes[t.startOffset]??null,o=document.createElement("hr");return this.content.insertBefore(o,e),this.cleanupHorizontalRuleInsertion(o),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o)){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 n=document.createElement("hr");o&&o!==this.content&&this.content.contains(o)?this.isEmptyHorizontalRuleBlock(o)?o.replaceWith(n):this.content.insertBefore(n,o.nextSibling):this.content.appendChild(n),this.cleanupHorizontalRuleInsertion(n),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 t="none"===this.statusBar.style.display;t?(this.statusBar.style.display="",this.updateWordCount()):this.statusBar.style.display="none";const o=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");o&&(o.textContent=t?"Hide Status Bar":"Show Status Bar"),e.write({statusBarVisible:t})};_applyStoredStatusBarVisibility=()=>{const t=e.read();if("boolean"!=typeof t.statusBarVisible||!this.statusBar)return;const o=t.statusBarVisible;this.statusBar.style.display=o?"":"none",o&&this.updateWordCount();const n=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");n&&(n.textContent=o?"Hide Status Bar":"Show Status Bar");try{null!==localStorage.getItem(e.legacyStatusBarKey)&&e.write({statusBarVisible:o})}catch{}};openFindBar=()=>{this.findBar.style.display="flex";const e=this.findBar.querySelector(".rtb-find-input");requestAnimationFrame(()=>{e.focus({preventScroll:!0}),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({preventScroll:!0}):this.source.focus({preventScroll:!0})};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()};getContextToolbarDescriptor=(e,t=null)=>{if(!(e instanceof Element&&this.content.contains(e)))return null;const o=e.closest("a"),n=e.closest("img"),i=(e.tagName,e.closest("video")),r=e.closest("pre"),s=e.closest("blockquote"),l=e.closest("object"),a=e.closest("table"),c=e.closest("ul"),d=e.closest("ol"),h=e.closest("hr")||t;let b,u,g="element";if(o&&this.content.contains(o))b=this._buildLinkContextItems(o),u=o,g="link";else if(n&&this.content.contains(n))b=this._buildImageContextItems(n),u=n;else if(i&&this.content.contains(i))b=this._buildVideoContextItems(i),u=i;else if(r&&this.content.contains(r))b=this._buildCodeBlockContextItems(r),u=r;else if(s&&this.content.contains(s))b=this._buildBlockQuoteContextItems(s),u=s;else if(l&&this.content.contains(l))b=this._buildMediaContextItems(l),u=l;else{if(a&&this.content.contains(a))return{element:a,type:"table",cell:e.closest("td, th"),target:e};if(h&&this.content.contains(h))b=this._buildHrContextItems(h),u=h;else if(c&&this.content.contains(c))b=this._buildBulletListContextItems(c,e),u=c,g="list";else if(d&&this.content.contains(d))b=this._buildNumberListContextItems(d,e),u=d,g="list";else{b=this._buildTextContextItems(e);const t=e.closest("p, h1, h2, h3, h4, h5, h6, li, div");u=t&&t!==this.content?t:e,g="text"}}return b&&0!==b.length?(!1!==this._rtbHostElement?._visibility?.htmlView&&b.push({divider:!0},{label:"View HTML",icon:"Code",action:()=>this._viewElementHtml(u)}),{element:u,positionElement:"list"===g&&u.querySelector("li")||u,target:e,type:g,items:b}):null};displayContextToolbar=e=>{if(!e)return!1;if(this.hideContextMenu(),this._contextToolbarHiddenByShortcutElement=null,this._contextToolbarSourceTarget=e.target||e.element,this._contextToolbarPositionElement=e.positionElement||e.element,this._contextToolbarPointerAnchor=e.pointerAnchor||null,"table"===e.type){if(this._suppressTableToolbarForKeyboardNavigation)return this.hideTableToolbar(),!1;this.showTableToolbar(e.element,e.cell)}else this.showContextToolbar(e.element,e.type,e.items);return!0};getPersistentContextElement=e=>e instanceof Element&&this.content.contains(e)?e.closest("img, video, object, table, blockquote, pre"):null;showPersistentContextToolbar=e=>!!this.getPersistentContextElement(e)&&this.displayContextToolbar(this.getContextToolbarDescriptor(e));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();let o=null;if(!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){o=t;break}}const n=this.getContextToolbarDescriptor(t,o);if(!n)return;e.stopPropagation(),n.pointerAnchor={clientX:e.clientX,clientY:e.clientY};const i=n.element?.closest?.("img, table, object, video");this.displayContextToolbar(n),i&&this.content.contains(i)&&this.showObjectResizeHandles(i,!1)};_buildTextContextItems=e=>{const t=[],o=this._getInlineFormatAtNode(e,"bold"),n=this._getInlineFormatAtNode(e,"italic"),i=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 c=!1,d=e instanceof Element?e:e?.parentElement;for(;d&&d!==this.content&&this.content.contains(d);){if(d.style.color||d.style.backgroundColor){c=!0;break}d=d.parentElement}o&&t.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.bold()}}),n&&t.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.italic()}}),i&&t.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.underline()}}),r&&t.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.strikethrough()}}),s&&t.push({label:"Remove Subscript",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.subscript()}}),l&&t.push({label:"Remove Superscript",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.superscript()}}),a&&t.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.inlinecode()}}),c&&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,o])=>{t.push({label:e,icon:"Format",action:()=>{this.content.focus({preventScroll:!0}),this.format(o)}})});const h=e.closest("p, h1, h2, h3, h4, h5, h6");return h&&this.content.contains(h)&&t.push({label:"Delete Element",icon:"Delete",action:()=>this._removeContentElement(h)}),t};_buildLinkContextItems=e=>[{label:"Open Link",icon:"OpenInNew",action:()=>window.open(e.href,"_blank","noopener,noreferrer")},{label:"Edit Link",icon:"Edit",action:()=>this._openLinkDialogFromContext(e)},{label:"Remove Link",icon:"RemoveLink",action:()=>this._selectNodeForDialog(e,!0,()=>this.removeLink())}];_buildImageContextItems=e=>[{label:"Edit Image",icon:"Edit",action:()=>{e.src?.startsWith("data")?this.openUploadImageDialogForElement(e):this.openImageDialogForElement(e)}},{label:"Remove Image",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildVideoContextItems=e=>[{label:"Edit Video",icon:"Edit",action:()=>this.openVideoDialogForElement(e)},{label:"Remove Video",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildBlockQuoteContextItems=e=>[{label:"Edit Block Quote",icon:"Edit",action:()=>this.openBlockQuoteDialogForElement(e)},{label:"Remove Block Quote",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildCodeBlockContextItems=e=>[{label:"Edit Code Block",icon:"Edit",action:()=>this.openCodeBlockDialogForElement(e)},{label:"Remove Code Block",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildMediaContextItems=e=>[{label:"Edit Media",icon:"Edit",action:()=>this.openMediaDialogForElement(e)},{label:"Remove Media",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildTableContextItems=(e,t)=>{const o=t?.closest("td, th")||null,alignColumn=t=>{if(!o)return;const n=this.Utilities.getSelection()||window.getSelection();if((n&&!n.isCollapsed?(n.anchorNode?.nodeType===Node.ELEMENT_NODE?n.anchorNode:n.anchorNode?.parentElement)?.closest?.("td, th"):null)===o)return void(o.style.textAlign=t);const i=o.cellIndex;for(const o of e.rows)o.cells[i]&&(o.cells[i].style.textAlign=t)};return[{label:"Edit Table",icon:"Edit",action:()=>{const t=e.querySelector("td, th");if(t){const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}this.openTableDialog()}},{divider:!0},{label:"Insert Row Above",icon:"ArrowUp",action:()=>this.TableDialog.insertRowAbove(o,e)},{label:"Insert Row Below",icon:"ArrowDown",action:()=>this.TableDialog.insertRowBelow(o,e)},{label:"Insert Column Left",icon:"ArrowLeft",action:()=>this.TableDialog.insertColumnLeft(o,e)},{label:"Insert Column Right",icon:"ArrowRight",action:()=>this.TableDialog.insertColumnRight(o,e)},{divider:!0},{label:"Align Left",icon:"Alignleft",action:()=>alignColumn("left")},{label:"Align Right",icon:"Alignright",action:()=>alignColumn("right")},{label:"Align Center",icon:"Aligncenter",action:()=>alignColumn("center")},{divider:!0},{label:"Remove Row",icon:"Delete",action:()=>this.TableDialog.removeRow(o)},{label:"Remove Column",icon:"Delete",action:()=>this.TableDialog.removeColumn(o,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 o=[],n=this._getInlineFormatAtNode(t,"bold"),i=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return n&&o.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.bold()}}),i&&o.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.italic()}}),r&&o.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.underline()}}),s&&o.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.strikethrough()}}),l&&o.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.inlinecode()}}),o.length>0&&o.push({divider:!0}),o.push({label:"Remove Bullet List",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0});const t=this.Utilities.getSelection()||window.getSelection(),o=document.createRange(),n=e.querySelector("li");n?o.setStart(n,0):o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),this.unorderedlist()}}),o};_buildNumberListContextItems=(e,t)=>{const o=[],n=this._getInlineFormatAtNode(t,"bold"),i=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return n&&o.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.bold()}}),i&&o.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.italic()}}),r&&o.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.underline()}}),s&&o.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.strikethrough()}}),l&&o.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.inlinecode()}}),o.length>0&&o.push({divider:!0}),o.push({label:"Remove Number List",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0});const t=this.Utilities.getSelection()||window.getSelection(),o=document.createRange(),n=e.querySelector("li");n?o.setStart(n,0):o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),this.orderedlist()}}),o};_selectNodeForDialog=(e,t,o)=>{if(!e||!this.content.contains(e))return;const n=this.Utilities.getSelection()||window.getSelection(),i=document.createRange();t?i.selectNodeContents(e):i.selectNode(e),n.removeAllRanges(),n.addRange(i),o()};_openLinkDialogFromContext=e=>{if(!e||!this.content.contains(e))return;const t=this.Utilities.getSelection()||window.getSelection(),o=this.Utilities.saveSelection(t),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.openLinkDialog(),this.savedSelection=o,this.LinkDialog.savedSelection=o};_removeContentElement=e=>{e&&this.content.contains(e)&&this.preservePageScrollDuringDelete(()=>{e.remove(),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))})};preservePageScrollDuringDelete=e=>{const t=window.scrollX,o=window.scrollY,n=document.documentElement.scrollLeft,i=document.documentElement.scrollTop,r=document.body?.scrollLeft||0,s=document.body?.scrollTop||0,l=this.contentContainer.scrollLeft,a=this.contentContainer.scrollTop,c=this.getScrollableAncestors(this.contentContainer).map(e=>({element:e,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop})),d=document.documentElement.style.scrollBehavior,h=document.body?.style.scrollBehavior;let b=!1;const restore=()=>{b||(b=!0,window.scrollTo({left:t,top:o,behavior:"instant"}),document.documentElement.scrollLeft=n,document.documentElement.scrollTop=i,document.body&&(document.body.scrollLeft=r,document.body.scrollTop=s),c.forEach(e=>{e.element.scrollLeft=e.scrollLeft,e.element.scrollTop=e.scrollTop}),this.contentContainer.scrollLeft=l,this.contentContainer.scrollTop=a,b=!1)},restoreOnScroll=()=>restore(),u=this._suppressCaretScroll;document.documentElement.style.scrollBehavior="auto",document.body&&(document.body.style.scrollBehavior="auto"),window.addEventListener("scroll",restoreOnScroll,!0),document.addEventListener("scroll",restoreOnScroll,!0);try{this._suppressCaretScroll=!0,e()}finally{restore(),requestAnimationFrame(()=>{restore(),requestAnimationFrame(()=>{restore(),window.removeEventListener("scroll",restoreOnScroll,!0),document.removeEventListener("scroll",restoreOnScroll,!0),document.documentElement.style.scrollBehavior=d,document.body&&(document.body.style.scrollBehavior=h),this._suppressCaretScroll=u})})}};getScrollableAncestors=e=>{const t=[],o=new Set;let n=e;for(;n;){if(n=n.parentNode instanceof ShadowRoot?n.parentNode.host:n.parentElement||n.parentNode,!(n instanceof Element)||o.has(n))continue;o.add(n);const e=window.getComputedStyle(n);(/(auto|scroll|overlay)/.test(e.overflowY)&&n.scrollHeight>n.clientHeight||/(auto|scroll|overlay)/.test(e.overflowX)&&n.scrollWidth>n.clientWidth)&&t.push(n)}return t};_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 o=e;o&&o!==this.content;o=o.parentNode)t.push(Array.prototype.indexOf.call(o.parentNode.childNodes,o));const o=this.content.cloneNode(!0);let n=o;for(const e of t.reverse())n=n.childNodes[e];if(!(n instanceof Element))return;const i="data-rtb-source-target",r=` ${i}=""`;n.setAttribute(i,"");const normalizeHtml=e=>e.replace(/font-family:\s*&quot;([^"]+?)&quot;;/g,"font-family: '$1';"),s=normalizeHtml(o.innerHTML),l=s.indexOf(r),a=s.lastIndexOf("<",l),c=normalizeHtml(n.outerHTML).replace(r,"");if(l<0||a<0)return;this.source.focus({preventScroll:!0}),this.source.setSelectionRange(a,a+c.length);const d=this.source.value;this.source.value=d.substring(0,a);const h=this.source.scrollHeight;this.source.value=d,this.source.setSelectionRange(a,a+c.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 o=this.contextMenu.getBoundingClientRect(),n=window.visualViewport,i=n?.width||window.innerWidth||document.documentElement.clientWidth,r=n?.height||window.innerHeight||document.documentElement.clientHeight,s=n?.offsetLeft||0,l=n?.offsetTop||0,a=Math.min(Math.max(s+4,e.clientX),s+i-o.width-4),c=Math.min(Math.max(l+4,e.clientY),l+r-o.height-4);this.contextMenu.style.left=a-o.left+"px",this.contextMenu.style.top=c-o.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",Edit:"M120-120v-170l450-450q12-12 26.5-17.5T623-763q15 0 27.5 5.5T677-740l63 63q12 12 17.5 26.5T763-623q0 14-5.5 26.5T740-570L290-120H120Zm503-503 54 54 63-63-54-54-63 63ZM200-200h56l363-363-56-56-363 363v56Z",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 o=e instanceof Element?e:e?.parentElement;for(;o&&o!==this.content&&this.content.contains(o);){switch(t){case"bold":if("bold"===o.style.fontWeight)return o;break;case"italic":if("italic"===o.style.fontStyle)return o;break;case"underline":if(o.style.textDecoration?.includes("underline"))return o;break;case"line-through":if(o.style.textDecoration?.includes("line-through"))return o;break;case"subscript":if("sub"===o.style.verticalAlign)return o;break;case"superscript":if("super"===o.style.verticalAlign)return o;break;case"code":if("CODE"===o.nodeName&&"PRE"!==o.parentElement?.nodeName)return o}o=o.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 o=e.toLowerCase();if(this.EditMode){const t=document.createTreeWalker(this.content,NodeFilter.SHOW_TEXT);let n;for(;n=t.nextNode();){const t=n.textContent.toLowerCase();let i=0;for(;-1!==(i=t.indexOf(o,i));)this._findMatches.push({node:n,start:i,end:i+e.length}),i++}}else{const t=this.source.value.toLowerCase();let n=0;for(;-1!==(n=t.indexOf(o,n));)this._findMatches.push({start:n,end:n+e.length}),n++}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 o=this.Utilities.getSelection()||window.getSelection();o.removeAllRanges(),o.addRange(t),this._setFindHighlight(t);const n=t.getBoundingClientRect(),i=this.contentContainer.getBoundingClientRect(),r=this.contentContainer.scrollTop+n.top-i.top-(this.contentContainer.clientHeight-n.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 o=this.source.scrollHeight;this.source.value=t,this.source.focus({preventScroll:!0}),this.source.setSelectionRange(e.start,e.end),this.source.scrollTop=o<=this.source.clientHeight?0:Math.max(0,o-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,o=getComputedStyle(this.source),n=document.createTextNode(t.substring(0,e.start)),i=document.createElement("span");i.textContent=t.substring(e.start,e.end),i.style.background="rgba(255, 214, 0, 0.45)",i.style.color="transparent";const r=document.createTextNode(t.substring(e.end));this._sourceFindHighlight.replaceChildren(n,i,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=o.boxSizing,this._sourceFindHighlight.style.padding=o.padding,this._sourceFindHighlight.style.border=`${o.borderTopWidth} solid transparent`,this._sourceFindHighlight.style.font=o.font,this._sourceFindHighlight.style.letterSpacing=o.letterSpacing,this._sourceFindHighlight.style.lineHeight=o.lineHeight,this._sourceFindHighlight.style.whiteSpace=o.whiteSpace,this._sourceFindHighlight.style.overflowWrap=o.overflowWrap,this._sourceFindHighlight.style.tabSize=o.tabSize,this._sourceFindHighlight.style.textAlign=o.textAlign,this._sourceFindHighlight.style.textIndent=o.textIndent,this._sourceFindHighlight.style.textTransform=o.textTransform,this._sourceFindHighlight.style.wordBreak=o.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)}};_getStatusLinkAddress=e=>{let t="";switch(e?.tagName){case"A":t=e.href;break;case"IMG":t=e.src;break;case"BLOCKQUOTE":t=e.cite;break;case"OBJECT":t=e.data;break;case"VIDEO":t=e.currentSrc||e.src||e.querySelector("source[src]")?.src||""}return"A"!==e?.tagName&&/^(data|blob):/i.test(t)?"":t};_updateStatusLinkFromNode=e=>{const t="BLOCKQUOTE"===this._tableToolbarTable?.tagName?this._tableToolbarTable:null,o=[this.selectedResizeImage,this.selectedResizeMedia,t].find(e=>e?.isConnected&&this.content.contains(e)),n=o||(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement),i=n?.closest?.("a, img, blockquote, object, video");i&&this.content.contains(i)?this._setStatusLink(this._getStatusLinkAddress(i)):this._setStatusLink("")};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const e=this.content.innerText||"",t=e.trim(),o=t?t.split(/\s+/).length:0,n=e.replace(/\n/g,"").length,fmt=e=>e.toLocaleString();this.statusCount.textContent=`${fmt(o)} word${1!==o?"s":""} - ${fmt(n)} character${1!==n?"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"}),o=URL.createObjectURL(t),n=document.createElement("a");n.href=o,n.download=this.createTimestampedHtmlFileName(),n.click(),URL.revokeObjectURL(o)};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({preventScroll:!0})):(this.loadHtml(e),this.content.style.display="block",this.source.style.display="none",this.content.focus({preventScroll:!0}),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 o=this.shadowRoot.getElementById(e);null!=o&&o.classList.contains("rich-text-box-show")?this.setToolbarDropdownExpanded(o,!1):(this.NodeManager.closeDropdowns(),this.setToolbarDropdownExpanded(o,!0),this.sizeToolbarDropdown(o),t&&this.focusFirstToolbarMenuItem(o))};openToolbarDropdown=(e,t=!1)=>{const o=this.shadowRoot.getElementById(e);o&&(this.NodeManager.closeDropdowns(),this.setToolbarDropdownExpanded(o,!0),this.sizeToolbarDropdown(o),t&&this.focusFirstToolbarMenuItem(o))};setToolbarDropdownExpanded=(e,t)=>{if(!e)return;e.classList.toggle("rich-text-box-show",t);const o=this.shadowRoot.querySelector(`[aria-controls="${CSS.escape(e.id)}"]`);o?.setAttribute("aria-expanded",String(t))};sizeToolbarDropdown=e=>{if(!this.isResponsiveToolbarDropdown(e))return;e.style.maxHeight="";const t=this.contentContainer.getBoundingClientRect().bottom,o=e.getBoundingClientRect().top,n=Math.floor(t-o-12);n>0&&(e.style.maxHeight=`${n}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;if(this.indentSelectedResizeMedia(!0))return;this.content.focus({preventScroll:!0});const e=this.selectedResizeImage;e&&this.selectResizeImageRange();const t=this.Utilities.getSelection();if(this.isSelectionInsideEditor(t))if(e)this.updateObjectWithResizeHandles(e,()=>{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)}),this.clearResizeImageRange();else{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)}};decreaseIndent=()=>{if(this.indentSelectedResizeTable(!1))return;if(this.indentSelectedResizeMedia(!1))return;this.content.focus({preventScroll:!0});const e=this.selectedResizeImage;e&&this.selectResizeImageRange();const t=this.Utilities.getSelection();if(this.isSelectionInsideEditor(t))if(e)this.updateObjectWithResizeHandles(e,()=>{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)}),this.clearResizeImageRange();else{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)}};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=()=>{const e=this.ColorPickers["rich-text-box-text-color-modal"];e.insertColor(),e.savedSelection&&(this._lastEditorSelectionRange=e.savedSelection.cloneRange())};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=()=>{const e=this.ColorPickers["rich-text-box-text-bg-color-modal"];e.insertColor(),e.savedSelection&&(this._lastEditorSelectionRange=e.savedSelection.cloneRange())};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(),o=document.createRange();o.selectNode(e),t.removeAllRanges(),t.addRange(o),this.savedSelection=this.Utilities.saveSelection(t),this.TableDialog.openTableDialogForElement(e,o)};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),o=document.createElement("code");o.appendChild(t.cloneContents()),t.deleteContents(),t.insertNode(o),t.selectNodeContents(o),e.removeAllRanges(),e.addRange(t),this.NodeManager.refreshUI()}};alignleft=()=>{this.alignSelectedResizeImage("alignleft")||this.alignSelectedResizeTable("alignleft")||this.alignSelectedResizeMedia("alignleft")||this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.alignSelectedResizeImage("aligncenter")||this.alignSelectedResizeTable("aligncenter")||this.alignSelectedResizeMedia("aligncenter")||this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.alignSelectedResizeImage("alignright")||this.alignSelectedResizeTable("alignright")||this.alignSelectedResizeMedia("alignright")||this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.alignSelectedResizeImage("alignjustify")||this.alignSelectedResizeTable("alignjustify")||this.alignSelectedResizeMedia("alignjustify")||this.NodeManager.updateNode("alignjustify")};copy=()=>this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)?(this._imageClipboardHtml=this.selectedResizeImage.outerHTML,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.selectResizeImageRange(),void document.execCommand("copy")):this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)&&!this.isSelectionInsideSelectedTableCell()?(this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.selectResizeTableRange(),void document.execCommand("copy")):this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)?(this._mediaClipboardHtml=this.selectedResizeMedia.outerHTML,this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._textClipboardText=null,this.selectResizeMediaRange(),void document.execCommand("copy")):(this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=this.Utilities.getSelection()?.toString()||"",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._mediaClipboardHtml=null,this._textClipboardText=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.isSelectionInsideSelectedTableCell()){this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.selectResizeTableRange(),document.execCommand("copy");const e=this.selectedResizeTable;return this.hideTableResizeHandles(),void e.remove()}if(this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)){this._mediaClipboardHtml=this.selectedResizeMedia.outerHTML,this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._textClipboardText=null,this.selectResizeMediaRange(),document.execCommand("copy");const e=this.selectedResizeMedia;return this.hideMediaResizeHandles(),void e.remove()}this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=this.Utilities.getSelection()?.toString()||"",this.ActionOptions.cut(),this.NodeManager.refreshUI()};moveTableOutsideParagraph=e=>{const t=e?.closest("p");if(!t||!this.content.contains(t))return;const o=document.createRange();o.selectNodeContents(t),o.setEndBefore(e);const n=t.cloneNode(!1);n.appendChild(o.cloneContents());const i=document.createRange();i.selectNodeContents(t),i.setStartAfter(e);const r=t.cloneNode(!1);r.appendChild(i.cloneContents());const hasContent=e=>""!==e.textContent.trim()||!!e.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, hr"),s=document.createDocumentFragment();hasContent(n)&&s.appendChild(n),s.appendChild(e),hasContent(r)&&s.appendChild(r),t.replaceWith(s)};pasteTableValuesIntoCells=e=>{const t=this.Utilities.getSelection(),o=this.TableDialog.getCurrentCell(t);if(!o)return!1;let n=null;const i=e.clipboardData?.getData("text/html")||"";if(i){const e=document.createElement("template");e.innerHTML=i;const t=e.content.querySelector("table");t&&(n=Array.from(t.rows,e=>Array.from(e.cells,e=>e.textContent||"")))}if(!n){const t=(e.clipboardData?.getData("text/plain")||"").replace(/\r\n?/g,"\n").replace(/\n$/,"").split("\n").map(e=>e.split("\t"));if(!t.some(e=>e.length>1))return!1;n=t}if(n=n.filter(e=>e.length>0),0===n.length)return!1;const r=o.closest("table"),s=Array.from(r.rows).indexOf(o.parentElement),l=o.cellIndex;if(s<0||l<0)return!1;e.preventDefault();const a=s+n.length,c=l+Math.max(...n.map(e=>e.length)),appendCell=e=>{const t="THEAD"===e.parentElement?.tagName||e.cells.length>0&&Array.from(e.cells).every(e=>"TH"===e.tagName),o=document.createElement(t?"th":"td");o.innerHTML="&#8203;",e.appendChild(o)};Array.from(r.rows).forEach(e=>{for(;e.cells.length<c;)appendCell(e)});const d=r.tBodies[0]||r.createTBody();for(;r.rows.length<a;){const e=document.createElement("tr");for(let t=0;t<c;t++)appendCell(e);d.appendChild(e)}let h=o;return n.forEach((e,t)=>{const o=r.rows[s+t];for(;o.cells.length<c;)appendCell(o);e.forEach((e,t)=>{const n=o.cells[l+t];n.textContent=e,""===e&&(n.innerHTML="&#8203;"),h=n})}),this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.TableDialog.selectCell(h,!0),!0};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({preventScroll:!0});const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const o=e.getRangeAt(0);o.deleteContents(),o.insertNode(t),o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}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({preventScroll:!0});const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const o=e.getRangeAt(0);o.deleteContents(),o.insertNode(t),o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}this.moveTableOutsideParagraph(t),this.showTableResizeHandles(t)}return}if(this._mediaClipboardHtml){const e=document.createElement("template");e.innerHTML=this._mediaClipboardHtml.trim();const t=e.content.firstElementChild;if(t&&["OBJECT","VIDEO"].includes(t.nodeName)){if(this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia))this.selectedResizeMedia.replaceWith(t);else{this.content.focus({preventScroll:!0});const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const o=e.getRangeAt(0);o.deleteContents(),o.insertNode(t),o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}this.showMediaResizeHandles(t)}return}this.NodeManager.allSelected&&this.delete(),this.content.focus({preventScroll:!0}),this._textClipboardText&&this.ActionOptions.paste(this._textClipboardText)};_returnFocus=()=>{!1===this.EditMode?this.source.focus({preventScroll:!0}):this.content.focus({preventScroll:!0})};_focusEditor=()=>{this.content.focus({preventScroll:!0});const e=this.shadowRoot.getSelection();if(!e||0===e.rangeCount||!this.content.contains(e.anchorNode)){const t=document.createRange(),o=this.content.lastChild;o?(t.selectNodeContents(o),t.collapse(!1)):(t.setStart(this.content,0),t.collapse(!0)),e&&(e.removeAllRanges(),e.addRange(t))}};closeDropdown=e=>{const t=this.shadowRoot.getElementById(e);this.setToolbarDropdownExpanded(t,!1),this.lockToolbar=!1,this._returnFocus()};delete=()=>{this.preservePageScrollDuringDelete(()=>{if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){const e=this.selectedResizeImage;return this.removeSelectedObjectAndRestoreCaret(e,this.hideImageResizeHandles),void this.NodeManager.refreshUI()}if(this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)){const e=this.selectedResizeMedia;return this.removeSelectedObjectAndRestoreCaret(e,this.hideMediaResizeHandles),void this.NodeManager.refreshUI()}const e=this.Utilities.getSelection();if(null!==e){if(this._selectAllActive||this.NodeManager.allSelected()){e.removeAllRanges(),this.content.replaceChildren(),this._selectAllActive=!1,this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.hideMediaResizeHandles(),this.hideTableToolbar(),this.NodeManager.clearButtons(),this.updateWordCount(),this.content.focus({preventScroll:!0});const t=document.createRange();return t.setStart(this.content,0),t.collapse(!0),e.removeAllRanges(),void e.addRange(t)}e.deleteFromDocument(),this._selectAllActive=!1,this.NodeManager.refreshUI()}})};selectall=()=>{const e=document.createRange();e.selectNodeContents(this.content),this.content.focus({preventScroll:!0});const t=this.Utilities.getSelection();null!==t&&(t.removeAllRanges(),t.addRange(e),this._selectAllActive=!0,this.content.focus({preventScroll:!0}))};orderedlist=()=>{this.toggleListForSelectedResizeImage("OL")||this.toggleListForSelectedResizeTable("OL")||this.toggleListForSelectedResizeMedia("OL")||this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.toggleListForSelectedResizeImage("UL")||this.toggleListForSelectedResizeTable("UL")||this.toggleListForSelectedResizeMedia("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 o=document.createRange();o.selectNodeContents(e),t.removeAllRanges(),t.addRange(o),this.BlockQuoteDialog.openBlockQuoteDialogForElement(e,o)};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 o=this.Utilities.getSelection()||window.getSelection();this.savedSelection=this.Utilities.saveSelection(o);const n=document.createRange();n.selectNodeContents(t),o.removeAllRanges(),o.addRange(n),this.CodeBlockDialog.openCodeBlockDialogForElement(e,n)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{if("OBJECT"===this.selectedResizeMedia?.tagName&&this.content.contains(this.selectedResizeMedia))return void this.openMediaDialogForElement(this.selectedResizeMedia);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.")};openMediaDialogForElement=e=>{if(!e||"OBJECT"!==e.tagName||!this.content.contains(e))return;this.hideMediaResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=document.createRange();t.setStartAfter(e),t.collapse(!0),this.savedSelection=t.cloneRange(),this.MediaDialog.openMediaDialogForElement(e,t)};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{if("VIDEO"===this.selectedResizeMedia?.tagName&&this.content.contains(this.selectedResizeMedia))return void this.openVideoDialogForElement(this.selectedResizeMedia);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=>{if(!e||"VIDEO"!==e.tagName||!this.content.contains(e))return;this.hideMediaResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=document.createRange();t.setStartAfter(e),t.collapse(!0),this.savedSelection=t.cloneRange(),this.VideoDialog.openVideoDialogForElement(e,t)};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()};openUploadImageDialogForElement=e=>{if(!e||"IMG"!==e.nodeName||!this.content.contains(e))return;this.hideImageResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=document.createRange();t.setStartAfter(e),t.collapse(!0),this.savedSelection=t.cloneRange(),this.UploadImageDialog.openUploadImageDialogForElement(e,t)};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(),o=document.createRange();o.selectNode(e),t.removeAllRanges(),t.addRange(o),this.savedSelection=this.Utilities.saveSelection(t),this.ImageDialog.openImageDialogForElement(e,o)};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeImageDialog=(e,t)=>{this.lockToolbar=!1,e&&this.content.contains(e)?this.restoreImageSelectionAfterDialog("rich-text-box-image-modal",e):this.Utilities.closeDialog("rich-text-box-image-modal",t)};closeUploadImageDialog=(e,t)=>{this.lockToolbar=!1,e&&this.content.contains(e)?this.restoreImageSelectionAfterDialog("rich-text-box-upload-image-modal",e):this.Utilities.closeDialog("rich-text-box-upload-image-modal",t)};restoreImageSelectionAfterDialog=(e,t)=>{const o=window.scrollX,n=window.scrollY,i=this.contentContainer.scrollTop,r=this.contentContainer.scrollLeft,restoreScroll=()=>{window.scrollTo(o,n),this.contentContainer.scrollTop=i,this.contentContainer.scrollLeft=r};this._suppressCaretScroll=!0;const s=document.createRange();s.setStartAfter(t),s.collapse(!0),this._lastEditorSelectionRange=s.cloneRange(),this._skipNextDialogFocusRestore=!0;const l=this.shadowRoot.getElementById(e);l?.open&&l.close();const a=this.Utilities.getSelection()||window.getSelection();a&&(a.removeAllRanges(),a.addRange(s.cloneRange())),this.showImageResizeHandles(t),this.NodeManager.refreshUI(),restoreScroll(),requestAnimationFrame(()=>{this.content.contains(t)&&(this._lastEditorSelectionRange=s.cloneRange(),this.showImageResizeHandles(t),this.NodeManager.refreshUI()),restoreScroll(),requestAnimationFrame(()=>{this.content.contains(t)&&(this.showImageResizeHandles(t),this.NodeManager.refreshUI()),restoreScroll(),this._suppressCaretScroll=!1})})};closeTableDialog=(e,t)=>{if(this.lockToolbar=!1,!e||!this.content.contains(e))return t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer)&&(this._lastEditorSelectionRange=t.cloneRange()),void this.Utilities.closeDialog("rich-text-box-table-modal",t);this.Utilities.closeDialog("rich-text-box-table-modal",null);const o=this.Utilities.getSelection()||window.getSelection();o?.removeAllRanges(),this.showObjectResizeHandles(e)};closeMediaDialog=(e,t)=>{if(this.lockToolbar=!1,!e||!this.content.contains(e))return void this.Utilities.closeDialog("rich-text-box-embed-modal",t);this._skipNextDialogFocusRestore=!0,this.Utilities.closeDialog("rich-text-box-embed-modal",null);const o=this.Utilities.getSelection()||window.getSelection();o?.removeAllRanges(),this.showObjectResizeHandles(e)};closeVideoDialog=(e,t,o)=>{this.lockToolbar=!1;const n=e||o;if(n&&this.content.contains(n)){this._skipNextDialogFocusRestore=!0,this.Utilities.closeDialog("rich-text-box-video-modal",null);const e=this.Utilities.getSelection()||window.getSelection();return e?.removeAllRanges(),void this.showObjectResizeHandles(n)}this.Utilities.closeDialog("rich-text-box-video-modal",t)};closeDialog=e=>{"rich-text-box-image-modal"!==e?"rich-text-box-upload-image-modal"!==e?"rich-text-box-table-modal"!==e?"rich-text-box-embed-modal"!==e?"rich-text-box-video-modal"!==e?(this.lockToolbar=!1,this.Utilities.closeDialog(e,this.savedSelection)):this.VideoDialog.closeDialog():this.MediaDialog.closeDialog():this.TableDialog.closeDialog():this.UploadImageDialog.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.hideMediaResizeHandles(),this.htmlSelection=this.StateManager.saveSelection(),this.contentScroll=this.Utilities.saveScroll(this.contentContainer),this.hideTableToolbar(),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.contentContainer.scrollTop=0,this.contentContainer.scrollLeft=0,this.source.focus({preventScroll:!0}),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({preventScroll:!0}),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.hideMediaResizeHandles(),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 o=t.getRangeAt(0);if(!this.content.contains(o.commonAncestorContainer))return;o.deleteContents();const n=document.createTextNode(e);o.insertNode(n),o.setStartAfter(n),o.collapse(!0),t.removeAllRanges(),t.addRange(o),this.content.focus({preventScroll:!0}),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 o{constructor(e,t,o,n,i){this.content=e,this.source=t,this.Utilities=o,this.dotNetObjectReference=n,this.contentContainer=i,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),o=t.cloneRange();o.selectNodeContents(this.content),o.setEnd(t.startContainer,t.startOffset);const n=o.toString().length;return{start:n,end:n+t.toString().length}}return null};restoreSelection=e=>{if(e)try{const charIndex=(e,t)=>{let o=0;if(e.nodeType===Node.TEXT_NODE)return t<=e.length?[e,t]:[null,t-e.length];for(let n=0;n<e.childNodes.length;n++){const i=e.childNodes[n],[r,s]=charIndex(i,t-o);if(r)return[r,s];o+=i.textContent.length}return[null,t-o]},t=document.createRange();let[o,n]=charIndex(this.content,e.start),[i,r]=charIndex(this.content,e.end);if(o&&i){t.setStart(o,n),t.setEnd(i,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({preventScroll:!0})}}class n{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o}_press=(e,t=!0)=>{e&&(e.classList.toggle("selected",t),e.setAttribute("aria-pressed",t?"true":"false"))};setColorProperty=(e,t,o)=>{e.style.setProperty(t,o);const n=e.getAttribute("style")||"",i=new RegExp(`(^|;)\\s*${t}\\s*:[^;]*`,"i"),r=i.test(n)?n.replace(i,(e,n)=>`${n} ${t}: ${o}`):`${n}${n.trim()&&!n.trim().endsWith(";")?";":""} ${t}: ${o}`;e.setAttribute("style",r.trim())};applyColorToSelection=(e,t,o)=>{if(!o||o.collapsed)return void this.updateNode(e,t,o);const n="textbgcolor"===e?"background-color":"color",restoreSelection=()=>{const e=window.getSelection();e.removeAllRanges(),e.addRange(o)},i=o.toString().trim();let r=o.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?o.commonAncestorContainer:o.commonAncestorContainer.parentElement;for(;r&&r!==this.content&&this.content.contains(r);){if(i===r.textContent.trim())return this.setColorProperty(r,n,t),this.refreshUI(),void restoreSelection();r=r.parentElement}const s=document.createElement("span");this.setColorProperty(s,n,t),s.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(s),o.selectNodeContents(s),this.refreshUI(),restoreSelection()};formatNode=e=>{let t,o;if(t=this.Utilities.getSelection(),null!==t){if(!this.isSelectionInsideContent(t))return;const n=/^(P|H1|H2|H3|H4|H5|H6)$/,getTopLevelFormatElement=e=>{let t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement;for(;t&&t!==this.content&&!n.test(t.nodeName);)t=t.parentElement;return t&&n.test(t.nodeName)&&t.parentElement===this.content?t:null},i=t.rangeCount>0?t.getRangeAt(0):null,r=i?getTopLevelFormatElement(i.startContainer):null,s=i?getTopLevelFormatElement(i.endContainer):null;if(!r||r!==s)return;const l=r;if(null!=l&&l!=this.content&&null!=l.parentNode&&this.content.contains(l.parentNode)){if("none"==e){let e=this.Utilities.saveCaretPosition();const t=document.createElement("div");for(let e=0;e<l.style.length;e++){const o=l.style[e];t.style[o]=l.style[o]}for(;l.firstChild;)t.appendChild(l.firstChild);l.parentNode.replaceChild(t,l),this.Utilities.restoreCaretPosition(t,e)}else{let t=this.Utilities.saveCaretPosition();const o=document.createElement(e);o.innerHTML=l.innerHTML;const n=window.getComputedStyle(l);for(let e=0;e<n.length;e++){let t=n[e],i=l.style.getPropertyValue(t);""!==i&&(o.style[t]=i)}l.parentNode.replaceChild(o,l),this.Utilities.restoreCaretPosition(o,t)}return}if(t.toString().length>0){let n;switch(e){case"p":n=document.createElement("p");break;case"h1":n=document.createElement("h1");break;case"h2":n=document.createElement("h2");break;case"h3":n=document.createElement("h3");break;case"h4":n=document.createElement("h4");break;case"h5":n=document.createElement("h5");break;case"h6":n=document.createElement("h6")}null!=n&&t.rangeCount>0&&(o=t.getRangeAt(0),this.hasInvalidElementsInSelection(t)||(n.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(n),o.selectNodeContents(n),t.removeAllRanges(),t.addRange(o)))}}};updateNode=(e,t,o)=>{let n,i;if(n=this.Utilities.getSelection(),n||o){if(n&&o?(n.removeAllRanges(),n.addRange(o)):o&&(n=window.getSelection(),n.removeAllRanges(),n.addRange(o)),!this.isSelectionInsideContent(n))return;let r;if(this.isCommonAncestor=!1,0==n.toString().length){if("alignleft"===e||"aligncenter"===e||"alignright"===e||"alignjustify"===e){const e=n.anchorNode instanceof Element?n.anchorNode:n.anchorNode?.parentElement;let t=e?.closest("table");if(!t&&n.rangeCount>0){const e=n.getRangeAt(0);if(e.collapsed&&e.startContainer===this.content){const o=e.startOffset,n=this.content.childNodes[o],i=o>0?this.content.childNodes[o-1]:null;"TABLE"===n?.nodeName?t=n:"TABLE"===i?.nodeName&&(t=i)}}t&&this.content.contains(t)&&(r=t)}if(null==r&&(r=this.getElementByStyle(n.anchorNode,e)),null==r&&null!=n.anchorNode&&n.anchorNode!=this.content&&this.content.contains(n.anchorNode)&&n.anchorNode.querySelector){null!=n.anchorNode.querySelector("img")&&(r=n.anchorNode);null!=n.anchorNode.querySelector("embed")&&(r=n.anchorNode);null!=n.anchorNode.querySelector("object")&&(r=n.anchorNode);const e=n.anchorNode.querySelector("table");null!=e&&(r=e)}null==r&&null!=n.anchorNode&&n.anchorNode!=this.content&&null!=n.anchorNode.parentNode&&n.anchorNode.parentNode!=this.content&&this.content.contains(n.anchorNode.parentNode)&&(r=n.anchorNode.parentNode)}else if(1==this.hasCommonAncestor(n)){r=n.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else r=this.getElementByContent(n.anchorNode,e,n);if(null!=r){let o;switch(e){case"textcolor":"None"==t?(o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"color",o.style.getPropertyValue("color"))):this.setColorProperty(r,"color",t);break;case"textbgcolor":"None"==t?(o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"background-color",o.style.getPropertyValue("background-color"))):this.setColorProperty(r,"background-color",t);break;case"font":if("None"==t)o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"font-family");else{const e=t.includes(" ")?`'${t}'`:t;r.style.setProperty("font-family",e)}break;case"size":"None"==t?(o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"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(n.toString().length>0&&"None"!=t&&!this.isExcluded(n)){let o;switch(e){case"textcolor":o=this.createElement(n),this.setColorProperty(o,"color",t);break;case"textbgcolor":o=this.createElement(n),this.setColorProperty(o,"background-color",t);break;case"font":o=this.createElement(n),o.style.fontFamily=t;break;case"size":o=this.createElement(n),o.style.fontSize=t;break;case"bold":o=this.createElement(n),o.style.fontWeight="bold";break;case"italic":o=this.createElement(n),o.style.fontStyle="italic";break;case"underline":o=this.createElement(n),this.addTextDecoration(o,"underline");break;case"line-through":o=this.createElement(n),this.addTextDecoration(o,"line-through");break;case"subscript":o=this.createElement(n),o.style.verticalAlign="sub";break;case"superscript":o=this.createElement(n),o.style.verticalAlign="super";break;case"alignleft":o=document.createElement("div"),o.style.textAlign="left";break;case"aligncenter":o=document.createElement("div"),o.style.textAlign="center";break;case"alignright":o=document.createElement("div"),o.style.textAlign="right";break;case"alignjustify":o=document.createElement("div"),o.style.textAlign="justify"}null!=o&&0!=n.rangeCount&&(i=n.getRangeAt(0),o.appendChild(i.cloneContents()),i.deleteContents(),i.insertNode(o),i.selectNodeContents(o),n.removeAllRanges(),n.addRange(i),this.selection=null,this.refreshUI())}}};alignTable=(e,t)=>{const o=getComputedStyle(this.content).getPropertyValue("--rtb-table-margin").trim()||"1.2em 0",n=document.createElement("div").style;n.margin=o;const i=e.style.marginTop||n.marginTop||"1.2em",r=e.style.marginBottom||n.marginBottom||i,setTableMargins=(t,o)=>{e.style.marginTop=i,e.style.marginRight=o,e.style.marginBottom=r,e.style.marginLeft=t};if("aligncenter"===t){const t="auto"===e.style.marginLeft&&"auto"===e.style.marginRight;return void setTableMargins(t?"0":"auto",t?"0":"auto")}if("alignright"===t){return void setTableMargins("auto"===e.style.marginLeft&&"auto"!==e.style.marginRight?"0":"auto","0")}if("alignleft"===t||"alignjustify"===t){setTableMargins("0","auto"===e.style.marginRight&&"auto"!==e.style.marginLeft?"0":"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 o=e.anchorNode;for(;o&&o!==this.content&&!this.applyMargin(o,t);)o=o.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 o=window.getComputedStyle(e).marginLeft,n=parseFloat(o)||0,i=40;return t?e.style.marginLeft=`${n+i}px`:n<=i?(e.style.marginLeft="",e.hasAttribute("style")&&(e.getAttribute("style")||e.removeAttribute("style"))):e.style.marginLeft=n-i+"px",!0}return!1};selectButtons=e=>{if(e===this.content){const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&t.isCollapsed){const o=t.getRangeAt(0);if(o.startContainer===this.content){const t=o.startOffset,n=this.content.childNodes[t],i=t>0?this.content.childNodes[t-1]:null;"TABLE"===n?.nodeName?e=n:"TABLE"===i?.nodeName&&(e=i)}}}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"),o=this.getButton("blazing-rich-text-italic-button"),n=this.getButton("blazing-rich-text-underline-button"),i=this.getButton("blazing-rich-text-strike-button"),r=this.getButton("blazing-rich-text-sub-button"),s=this.getButton("blazing-rich-text-super-button"),l=this.getButton("blazing-rich-text-alignleft-button"),a=this.getButton("blazing-rich-text-aligncenter-button"),c=this.getButton("blazing-rich-text-alignright-button"),d=this.getButton("blazing-rich-text-alignjustify-button");this.textAlign=!1;const h=this.getButton("blazing-rich-text-orderedlist-button"),b=this.getButton("blazing-rich-text-unorderedlist-button"),u=this.getButton("blazing-rich-text-link-button"),g=this.getButton("blazing-rich-text-remove-link-button"),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"),T=this.getButton("blazing-rich-text-image-upload-button"),R=this.getButton("blazing-rich-text-embed-button"),E=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 N=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=N&&(N.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 A=window.getComputedStyle(e.parentNode);const D="TABLE"===e.nodeName?e:e.parentNode.closest?.("table"),_=null!=D;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"==A.getPropertyValue("font-style")&&this._press(o),A.getPropertyValue("text-decoration").includes("underline")&&"A"!=e.parentNode.nodeName&&this._press(n),A.getPropertyValue("text-decoration").includes("line-through")&&this._press(i),"sub"==A.getPropertyValue("vertical-align")&&this._press(r),"super"==A.getPropertyValue("vertical-align")&&this._press(s),D&&!this.textAlign&&("auto"===D.style.marginLeft&&"auto"===D.style.marginRight?(this._press(a),this.textAlign=!0):"auto"===D.style.marginLeft?(this._press(c),this.textAlign=!0):"auto"===D.style.marginRight&&(this._press(l),this.textAlign=!0)),_||"left"!=A.getPropertyValue("text-align")||this.textAlign||(this._press(l),this.textAlign=!0),_||"center"!=A.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),_||"right"!=A.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),_||"justify"!=A.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),null!=e&&null!=e.style&&e.style.fontFamily&&!this.fontSelected&&(N.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||E&&this._press(E),e.querySelector){const t=e.querySelector("img");t&&(t.src.startsWith("data")?this._press(T):this._press(C));e.querySelector("object")&&this._press(R);e.querySelector("video")&&E&&this._press(E)}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 t=e.getRootNode().querySelector(`[aria-controls="${CSS.escape(e.id)}"]`);t?.setAttribute("aria-expanded","false")});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({preventScroll:!0});const e=this.Utilities.getSelection();null!==e&&this.selectButtons(e.anchorNode),this.content.focus({preventScroll:!0})};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"),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),o=document.createRange();return o.selectNodeContents(this.content),t.startContainer===o.startContainer&&t.startOffset===o.startOffset&&t.endContainer===o.endContainer&&t.endOffset===o.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 o=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=o&&(o.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=e=>{switch(e.toLowerCase()){case"td":case"th":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),o=t.cloneContents(),n=document.createElement("div");n.appendChild(o);const i=t.commonAncestorContainer;return i!==this.content&&this.content.contains(i)&&n.innerHTML==t.commonAncestorContainer.innerHTML&&i.nodeType!==Node.TEXT_NODE?(n.remove(),!0):(n.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"],o=e.getRangeAt(0).cloneContents().querySelectorAll("*");for(let e=0;e<o.length;e++){const n=o[e];if(t.includes(n.tagName.toLowerCase()))return!0}}return!1};removeProperty=(e,t,o)=>{null!=e&&e!=this.content&&this.content.contains(e)&&(this.getUserDefinedStyleCount(e)>1?e.style.removeProperty(t,o):"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 o=e.style.textDecoration;if(null!=o&&!o.includes(t)){const n=o?o+" "+t:t;e.style.textDecoration=n}};removeTextDecoration=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e))if(this.getUserDefinedStyleCount(e)>1){const o=e.style.textDecoration.split(" ").filter(e=>e!==t);e.style.textDecoration=o.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 o=0;o<e.style.length;o++){let n=e.style[o],i=e.style.getPropertyValue(n);t[n]=i}return t};getUserDefinedStyleCount=e=>{if(null==e||e==this.content||!this.content.contains(e))return;let t=0;for(let o=0;o<e.style.length;o++){let n=e.style[o],i=e.style.getPropertyValue(n);if(this.isFormatElement(e)){if("initial"!=i){let e=i.split(" ");if(!this.isMultiValueProperty(n)&&e.length>1)for(let o=0;o<e.length;o++)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,o)=>{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 n=this.getElementByStyle(e,t);if(null!=n&&this.selectionContainsNode(o,n))return n;if(null!==o&&o.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 o=0;o<e.rangeCount;o++){let n=e.getRangeAt(o);if(this.isNodeInRange(t,n))return!0}return!1}isNodeInRange(e,t){if(null==e||e==this.content||!this.content.contains(e))return!1;let o=e.ownerDocument.createRange();return o.selectNode(e),t.compareBoundaryPoints(Range.START_TO_END,o)<=0&&t.compareBoundaryPoints(Range.END_TO_START,o)>=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 o=null;switch(t){case"textcolor":if(o=e.getAttribute("style"),null!=o&&o.includes("color:"))return e;break;case"textbgcolor":if(o=e.getAttribute("style"),null!=o&&o.includes("background-color:"))return e;break;case"font":if(o=e.getAttribute("style"),null!=o&&o.includes("font-family:"))return e;break;case"size":if(o=e.getAttribute("style"),null!=o&&o.includes("font-size:"))return e;break;case"bold":if(o=e.getAttribute("style"),null!=o&&o.includes("font-weight:")&&"bold"==e.style.fontWeight)return e;break;case"italic":if(o=e.getAttribute("style"),null!=o&&o.includes("font-style:")&&"italic"==e.style.fontStyle)return e;break;case"underline":if(o=e.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&e.style.textDecoration.includes("underline"))return e;break;case"line-through":if(o=e.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&e.style.textDecoration.includes("line-through"))return e;break;case"subscript":if(o=e.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"sub"==e.style.verticalAlign)return e;break;case"superscript":if(o=e.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"superscript"==e.style.verticalAlign)return e;break;case"alignleft":if(o=e.getAttribute("style"),null!=o&&o.includes("text-align:")&&"left"==e.style.textAlign)return e;break;case"aligncenter":if(o=e.getAttribute("style"),null!=o&&o.includes("text-align:")&&"center"==e.style.textAlign)return e;break;case"alignright":if(o=e.getAttribute("style"),null!=o&&o.includes("text-align:")&&"right"==e.style.textAlign)return e;break;case"alignjustify":if(o=e.getAttribute("style"),null!=o&&o.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"),o=document.createElement("br");if(t.appendChild(o),"CODE"==e.nodeName){const o=e.parentNode.parentNode;o.nextSibling?o.parentNode.insertBefore(t,o.nextSibling):o.parentNode.appendChild(t)}else e.parentNode.insertBefore(t,e.nextSibling);const n=document.createRange();n.setStartBefore(o),n.collapse(!0);const i=this.Utilities.getSelection();null!==i&&(i.removeAllRanges(),i.addRange(n))}}class i{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.NodeManager=n}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 o=this.NodeManager.getElementByType(t.anchorNode,e);if(null!=o)this.removelist(o);else{if(0===t.toString().trim().length){const o=t.getRangeAt(0);let n;const i=document.createElement(e);if(t.anchorNode.parentNode!==this.content&&(n=t.anchorNode.parentNode),t.anchorNode!==this.content&&(n=t.anchorNode),!n)return;if(n.nodeType===Node.ELEMENT_NODE||n.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),t=n.cloneNode(!0);this.appendListItemContent(e,t),i.appendChild(e),n.remove()}o.deleteContents(),o.insertNode(i);const r=document.createRange();r.selectNodeContents(i),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}else{const o=document.createElement(e);if(t.rangeCount>0){const e=t.getRangeAt(0),n=e.cloneContents().childNodes;Array.from(n).forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),n=e.cloneNode(!0);this.appendListItemContent(t,n),o.appendChild(t),e.remove()}}),e.deleteContents(),e.insertNode(o),e.selectNodeContents(o),t.removeAllRanges(),t.addRange(e)}}}}};isCollapsedAtElementBoundary=e=>{const t=e.startContainer,o=e.startOffset,n=new Set(["TABLE","IMG","VIDEO","AUDIO","IFRAME","CANVAS","SVG","FIGURE","OBJECT","EMBED","HR","PRE","BLOCKQUOTE"]);if(t===this.content){return[o>0?t.childNodes[o-1]:null,t.childNodes[o]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE)}if(t.nodeType!==Node.ELEMENT_NODE)return!1;if(n.has(t.nodeName))return!0;return[o>0?t.childNodes[o-1]:null,t.childNodes[o]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE&&n.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 o=this.Utilities.getSelection();let n,i,r,s,l;null!==o&&o.rangeCount>0&&(n=o.getRangeAt(0),i=n.startContainer,r=n.startOffset,s=n.endContainer,l=n.endOffset);const a=document.createElement(t);for(;e.firstChild;)a.appendChild(e.firstChild);if(e.parentNode.replaceChild(a,e),n){const t=document.createRange();e.contains(i)?t.setStart(a,r):t.setStart(i,r),e.contains(s)?t.setEnd(a,l):t.setEnd(s,l),o.removeAllRanges(),o.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 o=e.firstChild;if("UL"===o.nodeName||"OL"===o.nodeName)t||(t=o),e.parentNode.insertBefore(o,e);else{for(;o.firstChild;){const n=o.firstChild;t||(t=n),e.parentNode.insertBefore(n,e)}e.removeChild(o)}}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}};removeListAsParagraphs=e=>{let t=null;for(;e.firstChild;){const o=e.firstChild;if("LI"!==o.nodeName){t||(t=o),e.parentNode.insertBefore(o,e);continue}const n=document.createElement("p");for(;o.firstChild;){const e=o.firstChild;if("UL"===e.nodeName||"OL"===e.nodeName)break;if(this.isParagraphChild(e)){for(;e.firstChild;)n.appendChild(e.firstChild);o.removeChild(e)}else n.appendChild(e)}for(n.hasChildNodes()||n.appendChild(document.createElement("br")),t||(t=n),e.parentNode.insertBefore(n,e);o.firstChild;)e.parentNode.insertBefore(o.firstChild,e);e.removeChild(o)}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}};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 o=this.getSelectedNodes(e,t);if(!o||0===o.length)return;let n=o[0].previousElementSibling;if(!n||"LI"!==n.nodeName)return;let i=Array.from(n.children).find(e=>e.nodeName===t.nodeName);i||(i=document.createElement(t.nodeName),n.appendChild(i)),o.forEach(e=>{"LI"===e.nodeName&&i.appendChild(e)}),this.selectListItemStart(e,o[0])};decreaseIndent=(e,t)=>{if(!e||!t||"UL"!==t.nodeName&&"OL"!==t.nodeName)return;const o=this.getSelectedNodes(e,t);if(!o||0===o.length)return;const n=t.parentElement,i=n?n.parentElement:null;if(!n||"LI"!==n.nodeName||!i||"UL"!==i.nodeName&&"OL"!==i.nodeName)return;const r=o[o.length-1],s=document.createElement(t.nodeName);for(;r.nextElementSibling;)s.appendChild(r.nextElementSibling);const l=document.createDocumentFragment();o.forEach(e=>{"LI"===e.nodeName&&l.appendChild(e)}),i.insertBefore(l,n.nextSibling),s.children.length>0&&r.appendChild(s),0===t.children.length&&t.remove(),this.selectListItemStart(e,o[0])};getSelectedNodes=(e,t)=>{const o=[];if(!e.rangeCount)return null;const n=e.getRangeAt(0);if(null!==t){const e=t.children;for(let t=0;t<e.length;t++){const i=e[t];n.intersectsNode(i)&&o.push(i)}return o}return null};saveListSelection=e=>e&&0!==e.rangeCount?e.getRangeAt(0).cloneRange():null;restoreListSelection=(e,t,o)=>{if(e&&t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))return e.removeAllRanges(),void e.addRange(t);this.selectListItem(e,o)};selectListItemStart=(e,t)=>{if(!e||!t)return;const o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)};selectListItem=(e,t)=>{if(!e||!t)return;const o=document.createRange(),n=this.getFirstTextNode(t);n?o.setStart(n,n.textContent.length):(o.selectNodeContents(t),o.collapse(!1)),o.collapse(!0),e.removeAllRanges(),e.addRange(o)};getFirstTextNode=e=>{if(!e)return null;if(e.nodeType===Node.TEXT_NODE)return e;for(let t=0;t<e.childNodes.length;t++){const o=e.childNodes[t];if("UL"===o.nodeName||"OL"===o.nodeName)continue;const n=this.getFirstTextNode(o);if(n)return n}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 r{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o}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||"").replace(/\r\n?/g,"\n").trim();t&&(this.checkStructuredText(t)||this.checkLists(t)||this.checkParagraphs(t)||this.checkTables(t)||this.checkLines(t)||this.checkText(t))};checkStructuredText=e=>{const t=this.buildStructuredTextFragment(e);return!!t&&this.insertBlockFragment(t)};buildStructuredTextFragment=e=>{const t=e.split("\n");if(t.length<=1&&!this.parsePlainTextListItem(e))return null;const o=document.createDocumentFragment();let n=[],i=!1;const flushParagraphs=()=>{n.forEach(e=>{const t=e.trim();if(!t)return;const n=document.createElement("p");n.textContent=t,o.appendChild(n)}),n=[]};for(let e=0;e<t.length;){if(""===t[e].trim()){flushParagraphs(),e++;continue}if(this.parsePlainTextListItem(t[e])){flushParagraphs();const n=e;for(e++;e<t.length&&this.parsePlainTextListItem(t[e]);)e++;o.appendChild(this.buildListFragment(t.slice(n,e).join("\n"))),i=!0;continue}const r=this.getTableBlockLineCount(t,e);r>0?(flushParagraphs(),o.appendChild(this.buildTable(t.slice(e,e+r).join("\n"))),i=!0,e+=r):(n.push(t[e]),e++)}return flushParagraphs(),o.hasChildNodes()?!i&&t.length<=1?null:o:null};getTableBlockLineCount=(e,t)=>{const o=((e[t]||"").match(/\t/g)||[]).length;if(0===o)return 0;let n=0;for(let i=t;i<e.length;i++){const t=e[i];if(""===t.trim())break;if(this.parsePlainTextListItem(t))break;if((t.match(/\t/g)||[]).length!==o)break;n++}return n>1?n:0};checkParagraphs=e=>{let t=e.split(/\n\s*\n/);if(t.length>1){const e=document.createDocumentFragment();return t.forEach(t=>{let o=this.checkParagraphList(t,e);if(o||(o=this.checkParagraphTable(t,e)),o||(o=this.checkParagraphLines(t,e)),!o){let o=document.createElement("p");o.textContent=t.trim(),e.appendChild(o)}}),this.insertBlockFragment(e)}return!1};checkLists=e=>{const t=this.buildListFragment(e);return!!t&&this.insertBlockFragment(t)};checkParagraphList=(e,t)=>{const o=this.buildListFragment(e);return!!o&&(t.appendChild(o),!0)};buildListFragment=e=>{const t=e.split("\n").filter(e=>e.trim().length>0);if(t.length<1)return null;const o=t.map(e=>this.parsePlainTextListItem(e));if(o.some(e=>null===e))return null;const n=document.createDocumentFragment();let i=null,r=null;return o.forEach(e=>{e.type!==r&&(i=document.createElement(e.type),n.appendChild(i),r=e.type);const t=document.createElement("li");t.textContent=e.text,i.appendChild(t)}),n};parsePlainTextListItem=e=>{const t=e.match(/^\s*(?:[-*+]|\u2022)\s+(.+)$/);if(t)return{type:"ul",text:t[1].trim()};const o=e.match(/^\s*(?:\d+|[a-zA-Z])[\.)]\s+(.+)$/);return o?{type:"ol",text:o[1].trim()}:null};checkParagraphLines=(e,t)=>{let o=e.trim().split(/\n+/);return o.length>1&&(o.forEach(e=>{let o=document.createElement("p");o.textContent=e.trim(),t.appendChild(o)}),!0)};checkParagraphTable=(e,t)=>{if(this.isTable(e)){let o=this.buildTable(e);return t.appendChild(o),!0}return!1};checkLines=e=>{let t=e.trim().split(/\n+/);if(t.length>1){let e=document.createDocumentFragment();return t.forEach(t=>{let o=document.createElement("p");o.textContent=t.trim(),e.appendChild(o)}),this.insertBlockFragment(e)}};checkTables=e=>{if(this.isTable(e)){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let n=document.createDocumentFragment(),i=this.buildTable(e);return n.appendChild(i),o.insertNode(n),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}};buildTable=e=>{let t=document.createElement("table"),o=e.split("\n"),n=document.createElement("thead"),i=document.createElement("tbody"),r=0;return o.forEach(e=>{if(e.trim().length>0){let t=e.split("\t"),o=document.createElement("tr");t.forEach(e=>{let t=document.createElement(0===r?"th":"td");0===r&&t.setAttribute("scope","col"),e.trim().length>0&&(t.textContent=e),o.appendChild(t)}),(0===r?n:i).appendChild(o),r++}}),t.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 o=1;o<t.length;o++){let n=t[o];if(n.trim().length>0){if((n.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 o=t.getRangeAt(0),n=this.getEmptyTextBlock(o);if(n){const o=document.createElement("p");return o.textContent=e,this.replaceEmptyBlockWithFragment(n,o,t)}if(o.deleteContents(),""===this.content.innerHTML.trim()){const t=document.createElement("p");t.textContent=e,o.insertNode(t),o.setStartAfter(t),o.setEndAfter(t)}else{const t=document.createTextNode(e);o.insertNode(t),o.setStartAfter(t),o.setEndAfter(t)}t.removeAllRanges(),t.addRange(o)}};getTextBlock=e=>{let t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentNode;for(;t&&t!==this.content;){if(t.nodeType===Node.ELEMENT_NODE&&/^(P|H1|H2|H3|H4|H5|H6)$/.test(t.nodeName))return t;t=t.parentNode}return null};isEmptyTextBlock=e=>!!e&&""===e.textContent.replace(/\u200B/g,"").trim()&&!e.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr");getEmptyTextBlock=e=>{const t=this.getTextBlock(e.startContainer);return this.isEmptyTextBlock(t)?t:null};replaceEmptyBlockWithFragment=(e,t,o)=>{e.parentNode.insertBefore(t,e);const n=e.previousSibling;return e.remove(),this.moveSelectionAfterNode(o,n),!0};insertBlockFragment=e=>{const t=this.Utilities.getSelection();if(null===t||!t.rangeCount||!e?.hasChildNodes())return!1;const o=t.getRangeAt(0),n=e.lastChild,i=this.getEmptyTextBlock(o);if(i)return i.parentNode.insertBefore(e,i),i.remove(),this.moveSelectionAfterNode(t,n),!0;const r=document.createElement("div");if(r.appendChild(e),insertBlockOutsideContainer(o,r,this.content)){for(;r.firstChild;)r.parentNode.insertBefore(r.firstChild,r);return r.remove(),this.moveSelectionAfterNode(t,n),!0}return!1};moveSelectionAfterNode=(e,t)=>{if(!e||!t?.parentNode)return;const o=document.createRange();o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}class s{constructor(e,t){this.shadowRoot=e,this.content=t}openDialog=e=>{e&&(e.open||(e.classList.contains("rtb-centered-dialog")?e.showModal():e.show()))};closeDialog=(e,t)=>{const o=this.shadowRoot.getElementById(e);null!=o&&o.close(),t&&this.restoreSelection(window.getSelection(),t),this.content.focus({preventScroll:!0})};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")};setOptionalAttribute=(e,t,o)=>{if(!e)return;const n=o?.trim()||"";n?e.setAttribute(t,n):e.removeAttribute(t)};validateRequiredFields=(...e)=>{for(const t of e){if(!t)continue;t.setCustomValidity("");const e="file"===t.type&&0===t.files.length,o="file"!==t.type&&0===t.value.trim().length;if((e||o)&&t.setCustomValidity("Please fill out this field."),!t.checkValidity())return t.reportValidity(),this.showFadingBar(t.validationMessage),t.focus({preventScroll:!0}),!1}return!0};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"),o=t.querySelector(".rich-text-box-message");if(t&&o){o.textContent=e;const n=this.content.parentElement;n&&(t.style.top=`${n.offsetTop}px`),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({preventScroll:!0})};reselectNode=e=>{const t=document.createRange(),o=window.getSelection();e.childNodes.length>0?t.setStartAfter(e.childNodes[e.childNodes.length-1]):t.setStartAfter(e),t.collapse(!0),o.removeAllRanges(),o.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 o=this.getSelection();if(null!==o&&null!==t){let n=document.createRange();n.setStart(e.firstChild,t.startOffset),n.setEnd(e.firstChild,t.endOffset),o.removeAllRanges(),o.addRange(n)}};saveScroll=e=>e.scrollTop;restoreScroll=(e,t)=>{e.scrollTop=t}}class l{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=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)))})};loadCaption=e=>{const t=this.shadowRoot.getElementById("rich-text-box-table-caption");t&&(t.value=e.caption?.textContent||"")};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,""),o=parseInt(e.max,10)||1e4;e.value=t.length>0?String(Math.min(parseInt(t,10),o)):"",e.setCustomValidity("")};getValidTableNumber=(e,t)=>{const o=parseInt(e.value,10),n=parseInt(e.max,10)||1e4;if(!Number.isInteger(o)||o<1||o>n){const t="Enter a valid number.";return e.setCustomValidity(t),e.reportValidity(),this.Utilities.showFadingBar(t),e.focus({preventScroll:!0}),e.select(),null}return e.setCustomValidity(""),o};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 o=this.shadowRoot.getElementById("rich-text-box-table-columns");o.value=this.getColumns(t),o.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 n=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=n){const e=t.classList;n.value=Array.from(e).join(" ")}this.loadCaption(t);const i=this.shadowRoot.getElementById("rich-text-box-table-header");i&&(i.checked=this._tableHasHeader(t)),this.table=t}}this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-table-modal"));const t=this.shadowRoot.getElementById("rich-text-box-table-columns");t&&t.focus({preventScroll:!0})};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 o=this.shadowRoot.getElementById("rich-text-box-table-rows");o.value=e.rows.length,o.disabled=!0;const n=this.shadowRoot.getElementById("rich-text-box-table-columns");n.value=this.getColumns(e),n.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.loadCaption(e),this.shadowRoot.getElementById("rich-text-box-table-header").checked=this._tableHasHeader(e),this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-table-modal")),this.shadowRoot.getElementById("rich-text-box-table-width").focus({preventScroll:!0})};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 o=0;o<e.rows.length;o++){let n=e.rows[o].cells.length;n>t&&(t=n)}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 o=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=o&&(o.value=null);const n=this.shadowRoot.getElementById("rich-text-box-table-caption");n&&(n.value="");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"),o=this.shadowRoot.getElementById("rich-text-box-table-width"),n=this.shadowRoot.getElementById("rich-text-box-table-height"),i=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-caption"),a=l?.value.trim()||"",c=this.shadowRoot.getElementById("rich-text-box-table-header"),d=!!c&&c.checked,h=this.getValidTableNumber(t,"Columns");if(null===h)return;const b=this.getValidTableNumber(e,"Rows");if(null!==b){if(null!==this.table){o.value.trim().length>0?this.table.style.width=o.value:(this.table.style.removeProperty("width"),0===this.table.style.cssText.trim().length&&this.table.hasAttribute("style")&&this.table.removeAttribute("style")),n.value.trim().length>0?this.table.style.height=n.value:this.table.style.removeProperty("height"),"none"===i.value?this.table.style.removeProperty("float"):this.table.style.float=i.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),a?this.table.createCaption().textContent=a:this.table.deleteCaption();const e=this._tableHasHeader(this.table);d&&!e?this._addHeader(this.table):!d&&e&&this._removeHeader(this.table),this.Utilities.reselectNode(this.table)}else if(null!=this.tableSelection){const e=this.tableSelection,t=this.createTable(b,h,o.value,n.value,d);"none"!==i.value&&(t.style.float=i.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),a&&(t.createCaption().textContent=a),e.deleteContents();let l=e.startContainer;if(l===this.content){const o=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,o)}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 c=t.previousSibling;c&&c.nodeType===Node.ELEMENT_NODE&&""===c.textContent.trim()&&c.parentNode.removeChild(c);const u=t.nextSibling;u&&u.nodeType===Node.ELEMENT_NODE&&""===u.textContent.trim()&&u.parentNode.removeChild(u);const g=t.querySelector("td, th"),p=document.createTreeWalker(g,NodeFilter.SHOW_TEXT).nextNode(),m=document.createRange();if(p){const e=p.textContent.match(/^\u200B*/)?.[0].length||0;m.setStart(p,e)}else m.setStart(g,0);m.collapse(!0),this.savedSelection=m}this.closeDialog()}};closeDialog=()=>{this.closeHandler(this.table,this.savedSelection)};createTable=(e,t,o,n,i=!1)=>{const r=parseInt(e,10),s=parseInt(t,10),l=document.createElement("table");if(o&&(l.style.width=o),n&&(l.style.height=n),i){const e=document.createElement("thead"),t=document.createElement("tr");for(let e=0;e<s;e++){const e=document.createElement("th");e.setAttribute("scope","col"),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.tHead;if(t&&t.querySelector("th"))return!0;const o=e.rows[0];return!!o&&(o.cells.length>0&&Array.from(o.cells).every(e=>"TH"===e.tagName))};_addHeader=e=>{const t=e.rows[0];if(!t)return;Array.from(t.cells).forEach(e=>{if("TH"===e.tagName)return void e.setAttribute("scope","col");const t=document.createElement("th");for(Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value)),t.setAttribute("scope","col");e.firstChild;)t.appendChild(e.firstChild);e.replaceWith(t)});(e.tHead||e.createTHead()).appendChild(t)};_removeHeader=e=>{const t=e.rows[0];if(!t)return;Array.from(t.cells).forEach(e=>{if("TD"===e.tagName)return;const t=document.createElement("td");for(Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value));e.firstChild;)t.appendChild(e.firstChild);e.replaceWith(t)});const o=e.tHead;if(o&&t.parentNode===o){const n=e.tBodies[0]||e.createTBody();n.insertBefore(t,n.firstChild),0===o.rows.length&&o.remove()}};tableTab=(e=!1)=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return;const o=this.getCurrentCell(t);if(!o)return;const n=e?this.getPreviousElement(o):this.getNextElement(o);if(n)this.selectCell(n);else{const n=o.closest("table");if(n){let o=e?n.previousSibling:n.nextSibling;for(;o&&o.nodeType===Node.TEXT_NODE&&""===o.textContent.trim();)o=e?o.previousSibling:o.nextSibling;if(o){const n=document.createRange();n.selectNodeContents(o),n.collapse(!e),t.removeAllRanges(),t.addRange(n)}}}this.content.focus({preventScroll:!0})}};navigateCell=e=>{const t=this.Utilities.getSelection(),o=this.getCurrentCell(t);if(!o)return!1;let n=null;if("ArrowLeft"===e&&(n=this.getPreviousElement(o)),"ArrowRight"===e&&(n=this.getNextElement(o)),"ArrowUp"===e||"ArrowDown"===e){const t=o.closest("table"),i=t?Array.from(t.rows):[],r=i.indexOf(o.parentElement),s=i[r+("ArrowUp"===e?-1:1)];s&&(n=s.cells[Math.min(o.cellIndex,s.cells.length-1)]||null)}if(n){if(["ArrowUp","ArrowDown"].includes(e)&&""===n.textContent.replace(/\u200B/g,"").trim()&&!n.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr")){const e=document.createTextNode("​");n.replaceChildren(e),this.content.focus({preventScroll:!0});const o=document.createRange();o.setStart(e,e.textContent.length),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}else this.selectCell(n,"ArrowLeft"===e||"ArrowUp"===e);return!0}const i="ArrowRight"===e||"ArrowDown"===e,r=o.closest("table");let s=i?r?.nextSibling:r?.previousSibling;for(;s&&s.nodeType===Node.TEXT_NODE&&""===s.textContent.trim();)s=i?s.nextSibling:s.previousSibling;if(!s)return!1;const l=document.createRange();return l.selectNodeContents(s),l.collapse(i),t.removeAllRanges(),t.addRange(l),this.content.focus({preventScroll:!0}),!0};moveCaretHorizontally=e=>{const t=this.Utilities.getSelection(),o=this.getCurrentCell(t);if(!o||!t.isCollapsed||!t.rangeCount)return!1;const n=t.getRangeAt(0),i=document.createRange();i.selectNodeContents(o),i.setEnd(n.startContainer,n.startOffset);const r=document.createRange();r.selectNodeContents(o),r.setStart(n.startContainer,n.startOffset);const s=i.toString().replace(/\u200B/g,""),l=r.toString().replace(/\u200B/g,"");return!("ArrowLeft"===e&&s.length>0||"ArrowRight"===e&&l.length>0)&&this.navigateCell(e)};setCaretOffset=(e,t)=>{const o=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r,s=t;for(;r=i.nextNode();){if(s<=r.textContent.length)return n.setStart(r,s),n.collapse(!0),o.removeAllRanges(),void o.addRange(n);s-=r.textContent.length}n.selectNodeContents(e),n.collapse(!1),o.removeAllRanges(),o.addRange(n)};addRowFromLastCell=()=>{const e=this.Utilities.getSelection();if(null===e||!e.rangeCount)return!1;const t=this.getCurrentCell(e);if(!t)return!1;const o=t.parentElement,n=o?o.parentElement:null,i=n?n.closest("table"):null;if(!o||!n||!i)return!1;if(o.nextElementSibling)return!1;if(t.nextElementSibling)return!1;const r=Math.max(this.getColumns(i),o.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)}n.appendChild(s);const l=s.querySelector("td, th");return l&&this.selectCell(l),!0};_makeRow=e=>{const t=document.createElement("tr");for(let o=0;o<e;o++){const e=document.createElement("td");e.innerHTML="&#8203;",t.appendChild(e)}return t};insertRowAbove=(e,t)=>{const o=e?e.closest("tr"):t?.querySelector("tr");if(!o)return;const n=Math.max(this.getColumns(t||o.closest("table")),o.cells.length,1),i=this._makeRow(n);o.parentElement.insertBefore(i,o),e&&this.selectCell(e)};insertRowBelow=(e,t)=>{const o=t||e?.closest("table"),n=e?e.closest("tr"):o?.querySelector("tr:last-child");if(!n)return;const i=Math.max(this.getColumns(o),n.cells.length,1),r=this._makeRow(i);n.after(r),e&&this.selectCell(e)};insertColumnLeft=(e,t)=>{const o=t||e?.closest("table");if(!o)return;const n=e?e.cellIndex:0;for(const e of o.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),o=document.createElement(t?"th":"td");t&&o.setAttribute("scope","col"),o.innerHTML="&#8203;",e.insertBefore(o,e.cells[n]||null)}e&&this.selectCell(e)};insertColumnRight=(e,t)=>{const o=t||e?.closest("table");if(!o)return;const n=e?e.cellIndex:o.rows[0]?.cells.length-1??0;for(const e of o.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),o=document.createElement(t?"th":"td");t&&o.setAttribute("scope","col"),o.innerHTML="&#8203;",e.insertBefore(o,e.cells[n+1]||null)}e&&this.selectCell(e)};removeRow=e=>{const t=e?.closest("tr");if(!t)return;const o=t.parentElement,n=o?.closest("table");if(!n||o.rows.length<=1)return;const i=t.previousElementSibling||t.nextElementSibling;if(t.remove(),i){const e=i.querySelector("td, th");e&&this.selectCell(e)}};removeColumn=(e,t)=>{const o=t||e?.closest("table");if(!o||!e)return;const n=e.cellIndex;if(o.rows[0]?.cells.length<=1)return;for(const e of o.rows)e.cells[n]&&e.cells[n].remove();const i=e.closest("tr")||o.rows[0],r=i?.cells[n]||i?.cells[n-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 o=t.closest("td, th");return o&&this.content.contains(o)?o:null};selectCell=(e,t=!1)=>{if(!e)return;this.content.focus({preventScroll:!0});const o=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=i.nextNode();if(t){let e;for(;e=i.nextNode();)r=e}if(r){const e=t?r.textContent.length:r.textContent.match(/^\u200B*/)?.[0].length||0;n.setStart(r,e)}else n.selectNodeContents(e),n.collapse(!t);n.collapse(!0),o.removeAllRanges(),o.addRange(n)};getNextElement=e=>{let t=e.nextElementSibling;if(!t){const o=e.closest("table"),n=o?Array.from(o.rows):[],i=n.indexOf(e.parentElement),r=n[i+1];r&&(t=r.cells[0]||null)}return t};getPreviousElement=e=>{let t=e.previousElementSibling;if(!t){const o=e.closest("table"),n=o?Array.from(o.rows):[],i=n.indexOf(e.parentElement),r=n[i-1];r&&(t=r.cells[r.cells.length-1]||null)}return t}}const wireEditableCombobox=(e,t,o)=>{const n=e.getElementById(t),i=e.getElementById(o);if(!n||!i)return;const r=Array.from(i.querySelectorAll("[data-value]"));let s=-1;const close=()=>{i.hidden=!0,r.forEach(e=>e.classList.remove("rich-text-box-combobox-option-active")),s=-1},open=()=>{i.hidden=!1},setActive=e=>{0!==r.length&&(s=(e+r.length)%r.length,r.forEach((e,t)=>{e.classList.toggle("rich-text-box-combobox-option-active",t===s),e.classList.toggle("rich-text-box-combobox-option-selected",t===s),e.setAttribute("aria-selected",t===s?"true":"false")}),n.value=r[s].dataset.value,n.dispatchEvent(new Event("input",{bubbles:!0})),(e=>{if(!e?.getBoundingClientRect)return;const t=e.getBoundingClientRect(),o=i.getBoundingClientRect();t.top<o.top?i.scrollTop-=o.top-t.top:t.bottom>o.bottom&&(i.scrollTop+=t.bottom-o.bottom)})(r[s]))};n.addEventListener("focus",open),n.addEventListener("click",open),i.addEventListener("pointerdown",e=>e.preventDefault()),i.addEventListener("click",e=>{const t=e.target.closest("[data-value]");t&&(r.forEach(e=>{const o=e===t;e.classList.toggle("rich-text-box-combobox-option-selected",o),e.setAttribute("aria-selected",o?"true":"false")}),n.value=t.dataset.value,n.dispatchEvent(new Event("input",{bubbles:!0})),close(),n.focus({preventScroll:!0}))}),n.addEventListener("keydown",e=>{"ArrowDown"===e.key?(e.preventDefault(),e.stopPropagation(),i.hidden&&open(),setActive(s+1)):"ArrowUp"===e.key?(e.preventDefault(),e.stopPropagation(),i.hidden&&open(),setActive(s<0?r.length-1:s-1)):"Enter"===e.key&&!i.hidden&&s>=0?(e.preventDefault(),e.stopPropagation(),s<0||!r[s]||(n.value=r[s].dataset.value,n.dispatchEvent(new Event("input",{bubbles:!0})),close())):"Tab"!==e.key||i.hidden?"Escape"!==e.key||i.hidden||(e.preventDefault(),e.stopPropagation(),close()):close()}),e.addEventListener("pointerdown",e=>{e.composedPath().includes(n)||e.composedPath().includes(i)||close()})},insertBlockOutsideContainer=(e,t,o)=>{if(!e||!t||!o)return!1;e.deleteContents();const n=document.createComment("rtb-block-insertion");e.insertNode(n);let i=n;for(;i.parentNode&&i.parentNode!==o;)i=i.parentNode;if(!i||i!==n&&i.parentNode!==o)return n.remove(),!1;if(i.nodeType===Node.ELEMENT_NODE&&/^(P|H1|H2|H3|H4|H5|H6)$/.test(i.nodeName)){const e=i.cloneNode(!1),o=document.createRange();o.setStartAfter(n),o.setEnd(i,i.childNodes.length),e.appendChild(o.extractContents()),n.remove(),i.parentNode.insertBefore(t,i.nextSibling),(""!==e.textContent.trim()||e.querySelector("br, img, video, audio, object, table, hr"))&&t.parentNode.insertBefore(e,t.nextSibling),""!==i.textContent.trim()||i.querySelector("br, img, video, audio, object, table, hr")||i.remove()}else i===n?n.replaceWith(t):(n.remove(),i.parentNode.insertBefore(t,i.nextSibling));return!0};class a{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.addEventListeners(),wireEditableCombobox(this.shadowRoot,"rich-text-box-embed-type","rich-text-box-embed-type-list")}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",e=>{if("Tab"===e.key){const t=this.dialog.querySelectorAll(".rtb-modal-footer .rich-text-box-form-button"),o=[this.shadowRoot.getElementById("rich-text-box-embed-source"),this.shadowRoot.getElementById("rich-text-box-embed-type"),this.shadowRoot.getElementById("rich-text-box-embed-width"),this.shadowRoot.getElementById("rich-text-box-embed-height"),this.shadowRoot.getElementById("rich-text-box-embed-margin"),this.shadowRoot.getElementById("rich-text-box-embed-float"),this.shadowRoot.getElementById("rich-text-box-embed-aria-label"),this.shadowRoot.getElementById("rich-text-box-embed-css-classes"),t[0],t[1],this.dialog.querySelector(".rtb-modal-header .rich-text-box-modal-close")].filter(Boolean),n=o.indexOf(this.shadowRoot.activeElement),i=e.shiftKey?n<=0?o.length-1:n-1:n<0||n===o.length-1?0:n+1;return e.preventDefault(),e.stopPropagation(),void o[i]?.focus({preventScroll:!0})}if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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-margin").value=this.embed.style.margin;this.shadowRoot.getElementById("rich-text-box-embed-float").value=this.embed.style.float||"none";this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(this.embed.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value=this.embed.getAttribute("aria-label")||""}e.rangeCount>0&&(this.embedSelection=e.getRangeAt(0).cloneRange()),this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-embed-modal"));const t=this.shadowRoot.getElementById("rich-text-box-embed-source");t&&t.focus({preventScroll:!0})}};openMediaDialogForElement=(e,t)=>{this.resetMediaDialog(),this.embed=e,this.savedSelection=t?.cloneRange?t.cloneRange():t,this.embedSelection=t?.cloneRange?t.cloneRange():null,this.shadowRoot.getElementById("rich-text-box-embed-source").value=e.getAttribute("data")||"",this.shadowRoot.getElementById("rich-text-box-embed-width").value=e.getAttribute("width")||"",this.shadowRoot.getElementById("rich-text-box-embed-height").value=e.getAttribute("height")||"";this.shadowRoot.getElementById("rich-text-box-embed-type").value=e.getAttribute("type")||"",this.shadowRoot.getElementById("rich-text-box-embed-margin").value=e.style.margin,this.shadowRoot.getElementById("rich-text-box-embed-float").value=e.style.float||"none",this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value=e.getAttribute("aria-label")||"",this.Utilities.openDialog(this.dialog),this.shadowRoot.getElementById("rich-text-box-embed-source").focus({preventScroll:!0})};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="";this.shadowRoot.getElementById("rich-text-box-embed-margin").value=null;this.shadowRoot.getElementById("rich-text-box-embed-float").value="none";const e=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=e&&(e.value=null),this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value=""};insertMedia=()=>{const e=this.shadowRoot.getElementById("rich-text-box-embed-source");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-embed-width"),o=this.shadowRoot.getElementById("rich-text-box-embed-height"),n=this.shadowRoot.getElementById("rich-text-box-embed-type"),i=this.shadowRoot.getElementById("rich-text-box-embed-margin"),r=this.shadowRoot.getElementById("rich-text-box-embed-float"),s=this.shadowRoot.getElementById("rich-text-box-embed-css-classes"),l=this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value;if(null!==this.embed)this.embed.data=e.value,n.value.trim().length>0?this.embed.type=n.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"),o.value.trim().length>0?this.embed.height=o.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==s&&this.Utilities.addClasses(s.value,this.embed),this.Utilities.setOptionalAttribute(this.embed,"aria-label",l),"none"===r.value?this.embed.style.removeProperty("float"):this.embed.style.float=r.value,Number.isFinite(parseFloat(i.value))&&0!==parseFloat(i.value)&&CSS.supports("margin",i.value)?this.embed.style.margin=i.value:this.embed.style.removeProperty("margin"),0===this.embed.style.length&&this.embed.removeAttribute("style");else if(null!=this.embedSelection&&e.value.length>0){const a=this.embedSelection.cloneRange(),c=n.value.trim().toLowerCase(),d=e.value.trim(),h=d.split(/[?#]/,1)[0].toLowerCase(),b=c.startsWith("video/")||/\.(mp4|webm|ogv)$/.test(h),u=!b&&(c.startsWith("audio/")||/\.(mp3|m4a|aac|wav|oga|opus)$/.test(h)),g=document.createElement(b?"video":u?"audio":"object");if(b||u){g.setAttribute("controls","");const e=document.createElement("source");e.src=d,c&&(e.type=c),g.appendChild(e)}else g.data=d,c&&(g.type=c);t.value.trim().length>0?g.width=t.value:g.hasAttribute("width")&&g.removeAttribute("width"),o.value.trim().length>0?g.height=o.value:g.hasAttribute("height")&&g.removeAttribute("height"),null!==s&&this.Utilities.addClasses(s.value,g),this.Utilities.setOptionalAttribute(g,"aria-label",l),"none"!==r.value&&(g.style.float=r.value),Number.isFinite(parseFloat(i.value))&&0!==parseFloat(i.value)&&CSS.supports("margin",i.value)&&(g.style.margin=i.value),a.deleteContents(),a.insertNode(g),this.embed=g,this.embedSelection=a.cloneRange()}this.closeDialog()};closeDialog=()=>{this.closeHandler(this.embed,this.savedSelection)}}class c{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.video=null,this.videoSelection=null,this.savedSelection=null,this.addEventListeners(),wireEditableCombobox(this.shadowRoot,"rich-text-box-video-source-type","rich-text-box-video-source-type-list")}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-video-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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-margin").value=e.style.margin,ge("rich-text-box-video-float").value=e.style.float||"none",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(" "),ge("rich-text-box-video-aria-label").value=e.getAttribute("aria-label")||""};_showDialog=()=>{this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-video-modal")),this.shadowRoot.getElementById("rich-text-box-video-source").focus({preventScroll:!0})};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?.cloneRange?t.cloneRange():t,this.video=e,this._populateFromVideo(e),this.videoSelection=t?.cloneRange?t.cloneRange():null,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-margin").value="",ge("rich-text-box-video-float").value="none",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="",ge("rich-text-box-video-aria-label").value=""};insertVideo=()=>{const ge=e=>this.shadowRoot.getElementById(e),e=ge("rich-text-box-video-source");if(!this.Utilities.validateRequiredFields(e))return;const t=e.value.trim(),o=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(),r=ge("rich-text-box-video-height").value.trim(),s=ge("rich-text-box-video-margin").value,l=ge("rich-text-box-video-float").value,a=ge("rich-text-box-video-controls").checked,c=ge("rich-text-box-video-autoplay").checked,d=ge("rich-text-box-video-loop").checked,h=ge("rich-text-box-video-muted").checked,b=ge("rich-text-box-video-css-classes").value.trim(),u=ge("rich-text-box-video-aria-label").value,applyAttrs=e=>{let g=e.querySelector("source");g||(g=document.createElement("source"),e.appendChild(g)),g.setAttribute("src",t),o?g.setAttribute("type",o):g.removeAttribute("type"),n?e.setAttribute("poster",n):e.removeAttribute("poster"),i?e.setAttribute("width",i):e.removeAttribute("width"),r?e.setAttribute("height",r):e.removeAttribute("height"),"none"===l?e.style.removeProperty("float"):e.style.float=l,Number.isFinite(parseFloat(s))&&0!==parseFloat(s)&&CSS.supports("margin",s)?e.style.margin=s:e.style.removeProperty("margin"),0===e.style.length&&e.removeAttribute("style"),a?e.setAttribute("controls",""):e.removeAttribute("controls"),c?e.setAttribute("autoplay",""):e.removeAttribute("autoplay"),d?e.setAttribute("loop",""):e.removeAttribute("loop"),h?e.setAttribute("muted",""):e.removeAttribute("muted"),this.Utilities.addClasses(b,e),this.Utilities.setOptionalAttribute(e,"aria-label",u)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&t.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 o=e.startContainer;if(o===this.content){const o=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,o)}else{for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(t),this._placeCursorAfterVideo(t),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(t,o.nextSibling),""!==o.textContent.trim()||o.querySelector("img, video, pre, blockquote")||o.parentNode.removeChild(o)}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;this._insertedVideo=null,this.closeHandler(this.video,this.savedSelection,e)}}class d{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o,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&&"BUTTON"!==t.target.tagName&&(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"),o=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 n=e.anchorNode.parentNode.cloneNode(!0);if(t.value=n.textContent,null!=o){const t=e.anchorNode.parentNode.classList;o.value=Array.from(t).join(" ")}this.shadowRoot.getElementById("rich-text-box-code-aria-label").value=e.anchorNode.parentNode.parentElement?.getAttribute("aria-label")||"",this.codeSelection=e.getRangeAt(0).cloneRange(),this.code=e.anchorNode.parentNode}else e.rangeCount>0&&(this.codeSelection=e.getRangeAt(0).cloneRange());this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-code-block-modal")),t&&(t.focus({preventScroll:!0}),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 o=e.querySelector("code")||e,n=this.shadowRoot.getElementById("rich-text-box-code"),i=this.shadowRoot.getElementById("rich-text-box-code-css-classes");n.value=o.textContent,null!=i&&(i.value=Array.from(o.classList).join(" ")),this.shadowRoot.getElementById("rich-text-box-code-aria-label").value=e.getAttribute("aria-label")||"",this.codeSelection=t?t.cloneRange():null,this.code=o,this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-code-block-modal")),n.focus({preventScroll:!0}),n.scrollTop=0,n.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),this.shadowRoot.getElementById("rich-text-box-code-aria-label").value=""};insertCodeBlock=()=>{const e=this.shadowRoot.getElementById("rich-text-box-code");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-code-css-classes"),o=this.shadowRoot.getElementById("rich-text-box-code-aria-label").value;if(null!=this.code){const n=this.code;n.textContent=e.value,null!==t&&this.Utilities.addClasses(t.value,n),this.Utilities.setOptionalAttribute(n.parentElement,"aria-label",o);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"),r=document.createElement("code");if(null!==t&&this.Utilities.addClasses(t.value,r),this.Utilities.setOptionalAttribute(i,"aria-label",o),r.textContent=e.value,i.appendChild(r),!insertBlockOutsideContainer(n,i,this.content))return;const s=i.previousSibling;s&&s.nodeType===Node.ELEMENT_NODE&&""===s.textContent.trim()&&s.parentNode.removeChild(s);const l=i.nextSibling;l&&l.nodeType===Node.ELEMENT_NODE&&""===l.textContent.trim()&&l.parentNode.removeChild(l),n.selectNodeContents(r),n.collapse(!1),this.savedSelection=n}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class h{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o,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&&"BUTTON"!==t.target.tagName&&(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"),o=this.shadowRoot.getElementById("rich-text-box-cite"),n=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&&(o.value=e.anchorNode.parentNode.cite),null!=n){const t=e.anchorNode.parentNode.classList;n.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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-block-quote-modal")),t&&(t.focus({preventScroll:!0}),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 o=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");o.value=e.textContent,null!=e.cite&&(n.value=e.cite),null!=i&&(i.value=Array.from(e.classList).join(" ")),this.quoteSelection=t?t.cloneRange():null,this.quote=e,this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-block-quote-modal")),o.focus({preventScroll:!0}),o.scrollTop=0,o.scrollLeft=0};resetBlockQuoteDialog=()=>{this.quote=null,this.quoteSelection=null;this.shadowRoot.getElementById("rich-text-box-quote").value=null;this.shadowRoot.getElementById("rich-text-box-cite").value=null;const 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");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const n=this.quote;n.textContent=e.value,t.value.trim().length>0?n.setAttribute("cite",t.value):n.hasAttribute("cite")&&n.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,n);const i=document.createRange();i.selectNodeContents(n),i.collapse(!1),this.savedSelection=i}else if(null!=this.quoteSelection&&e.value.length>0){const n=this.quoteSelection.cloneRange(),i=document.createElement("blockquote");if(i.textContent=e.value,t.value.trim().length>0?i.cite=t.value:i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,i),!insertBlockOutsideContainer(n,i,this.content))return;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(i),n.collapse(!1),this.savedSelection=n}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class b{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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 o=document.createElement("img");if(t){const e=new FileReader;e.onloadend=function(){this.base64String=e.result.split(",")[1],o.src=`data:image/jpg;base64,${this.base64String}`},e.readAsDataURL(t),this.image=o}};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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-upload-image-modal"));const t=this.shadowRoot.getElementById("rich-text-box-upload-btn");t&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))}};openUploadImageDialogForElement=(e,t)=>{if(!e||"IMG"!==e.nodeName||!this.content.contains(e))return;this.resetUploadImageDialog(),this.currentImage=e,this.savedSelection=t?t.cloneRange():null,this.range=t?t.cloneRange():null,this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=e.width,this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=e.height,this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=e.alt,this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-upload-image-float").value=e.style.float||"none",this.shadowRoot.getElementById("rich-text-box-upload-image-margin").value=e.style.margin,this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-upload-image-modal"));const o=this.shadowRoot.getElementById("rich-text-box-upload-btn");o&&requestAnimationFrame(()=>o.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-file");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),o=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"),r=this.shadowRoot.getElementById("rich-text-box-upload-image-float"),s=this.shadowRoot.getElementById("rich-text-box-upload-image-margin");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),t.value.trim().length>0?this.currentImage.width=t.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),o.value.trim().length>0?this.currentImage.height=o.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),n.value.trim().length>0?(this.currentImage.alt=n.value,this.currentImage.removeAttribute("role")):(this.currentImage.removeAttribute("alt"),this.currentImage.removeAttribute("role")),null!==i&&this.Utilities.addClasses(i.value,this.currentImage),"none"===r.value?(this.currentImage.style.removeProperty("float"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")):this.currentImage.style.float=r.value,Number.isFinite(parseFloat(s.value))&&0!==parseFloat(s.value)&&CSS.supports("margin",s.value)?this.currentImage.style.margin=s.value:(this.currentImage.style.removeProperty("margin"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")),this.Utilities.reselectNode(this.currentImage)):this.image&&(t.value.length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),o.value.length>0?this.image.height=o.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),n.value.length>0?(this.image.alt=n.value,this.image.removeAttribute("role")):(this.image.removeAttribute("alt"),this.image.removeAttribute("role")),null!==i&&this.Utilities.addClasses(i.value,this.image),"none"!==r.value&&(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.range.deleteContents(),this.range.insertNode(this.image),this.currentImage=this.image,this.Utilities.reselectNode(this.image)),this.closeDialog()};closeDialog=()=>{this.closeHandler(this.currentImage||this.image,this.savedSelection)}}class u{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-image-modal"));const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress");t&&t.focus({preventScroll:!0})}};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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-image-modal")),this.shadowRoot.getElementById("rich-text-box-image-webaddress").focus({preventScroll:!0}))};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");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-image-width"),o=this.shadowRoot.getElementById("rich-text-box-image-height"),n=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),i=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),n.value.trim().length>0?(this.image.alt=n.value,this.image.removeAttribute("role")):(this.image.removeAttribute("alt"),this.image.removeAttribute("role")),t.value.trim().length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),o.value.trim().length>0?this.image.height=o.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==i&&this.Utilities.addClasses(i.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),o.value.trim().length>0&&(a.height=o.value),n.value.trim().length>0&&(a.alt=n.value),null!==i&&this.Utilities.addClasses(i.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.image=a,this.Utilities.reselectNode(a)}this.imageSelection=l.cloneRange()}this.closeDialog()};closeDialog=()=>{this.closeHandler(this.image,this.savedSelection)}}class g{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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 o=e.anchorNode.parentNode.classList;t.value=Array.from(o).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.rangeCount>0&&(this.linkSelection=e.getRangeAt(0).cloneRange(),this.linkSelection.collapsed||(t.value=this.linkSelection.toString()))}this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-link-modal"));const t=this.shadowRoot.getElementById("rich-text-box-link-webaddress");t&&t.focus({preventScroll:!0})}};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");if(!this.Utilities.validateRequiredFields(t,e))return;const o=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),n=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=this.linkNode){const i=this.linkNode;i.href=t.value,i.textContent=e.value,null!==n&&this.Utilities.addClasses(n.value,i),o.checked?i.target="_blank":i.hasAttribute("target")&&i.removeAttribute("target"),this.Utilities.reselectNode(i)}else if(null!=this.linkSelection){const i=this.linkSelection,r=document.createElement("a");r.href=t.value,r.textContent=e.value,null!==n&&this.Utilities.addClasses(n.value,r),o.checked&&(r.target="_blank"),i.deleteContents(),i.insertNode(r),i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),this.savedSelection=i}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,o=document.createDocumentFragment();for(;t.firstChild;)o.appendChild(t.firstChild);t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t)}this.Utilities.restoreSelection(e,t)}}}class p{constructor(e,t,o,n,i){this.shadowRoot=e,this.content=t,this.id=o,this.NodeManager=n,this.Utilities=i,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.swatchRegion=this.colorPicker.querySelector(".rich-text-box-color-swatches"),this.swatches=Array.from(this.swatchRegion.querySelectorAll(".blazing-rich-text-color-option")),this.swatches.forEach((e,t)=>{e.id=`${this.id}-swatch-${t}`,e.setAttribute("aria-selected","false")}),this.swatchRegion.addEventListener("keydown",this.handleSwatchKeydown),this.redSlider=this.colorPicker.querySelector(".rich-text-box-red-slider"),this.redSlider.style.setProperty("--rtb-slider-thumb-color","rgb(0, 0, 0)"),this.addSliderEventListener(this.redSlider),this.greenSlider=this.colorPicker.querySelector(".rich-text-box-green-slider"),this.greenSlider.style.setProperty("--rtb-slider-thumb-color","rgb(0, 0, 0)"),this.addSliderEventListener(this.greenSlider),this.blueSlider=this.colorPicker.querySelector(".rich-text-box-blue-slider"),this.blueSlider.style.setProperty("--rtb-slider-thumb-color","rgb(0, 0, 0)"),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"),this.customColorInputs=Array.from(this.colorPicker.querySelectorAll(".rich-text-box-custom-color")),this.customColorInputs.forEach(e=>this.addCustomColorEventListeners(e)),this.saveFormatInputs=Array.from(this.colorPicker.querySelectorAll(".rich-text-box-color-save-format"))};handleSwatchKeydown=e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault(),e.stopPropagation();const t="ArrowRight"===e.key?1:-1,o=Number.isInteger(this.selectedSwatchIndex)?(this.selectedSwatchIndex+t+this.swatches.length)%this.swatches.length:t>0?0:this.swatches.length-1;this.selectSwatch(o)};selectSwatch=e=>{const t=this.swatches[e];t&&(this.selectedSwatchIndex=e,this.swatches.forEach((t,o)=>{const n=o===e;t.classList.toggle("rich-text-box-color-option-selected",n),t.setAttribute("aria-selected",String(n))}),this.swatchRegion.setAttribute("aria-activedescendant",t.id),this.selectColor(t.getAttribute("data-color")))};addCustomColorEventListeners=e=>{e.addEventListener("input",()=>{const t=this.normalizeHexColor(e.value);e.setAttribute("aria-invalid",String(""!==e.value.trim()&&null===t)),this.updateCustomColorAppearance(e,t||""),t?(this.saveCustomColors(),this.selectColor(t)):""===e.value.trim()&&this.saveCustomColors()}),e.addEventListener("change",()=>{const t=this.normalizeHexColor(e.value);e.setAttribute("aria-invalid",String(""!==e.value.trim()&&null===t)),t?(e.value=t,this.updateCustomColorAppearance(e,t),this.saveCustomColors(),this.selectColor(t)):""===t&&this.saveCustomColors()}),e.addEventListener("focus",()=>{e.select();const t=this.normalizeHexColor(e.value);t&&this.selectColor(t)})};normalizeHexColor=e=>{const t=e.trim();if(""===t)return"";const o=t.startsWith("#")?t:`#${t}`;return/^#[0-9A-Fa-f]{6}$/.test(o)?o.toUpperCase():null};loadCustomColors=()=>{const t=e.read().customColors[this.id];this.customColorInputs.forEach((e,o)=>{e.value=t[o]||"",e.setAttribute("aria-invalid","false"),this.updateCustomColorAppearance(e,e.value)})};saveCustomColors=()=>{const t=e.read(),o=this.customColorInputs.map(e=>this.normalizeHexColor(e.value)||"");e.write({customColors:{...t.customColors,[this.id]:o}})};updateCustomColorAppearance=(e,t)=>{e.style.setProperty("--rtb-custom-color",t||"var(--rtb-modal-input-border, #CCC)")};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("input",e=>{const t=e.target.selectionStart,o=e.target.selectionEnd;e.target.value=e.target.value.toUpperCase(),e.target.setSelectionRange(t,o),/^#?[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.loadCustomColors(),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.colorElement=e.anchorNode.parentNode,this.colorProperty="color",this.selectSaveFormat(this.getInlineColorFormat(e.anchorNode.parentNode,"color")),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.colorElement=e.anchorNode.parentNode,this.colorProperty="background-color",this.selectSaveFormat(this.getInlineColorFormat(e.anchorNode.parentNode,"background-color")),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.Utilities.openDialog(this.colorPickerDialog),requestAnimationFrame(()=>this.redSlider?.focus({preventScroll:!0})),this.selection};insertColor=()=>{let e;switch(this.currentColor=this.getCurrentColor(this.getSaveFormat()),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.selection.cloneRange(),null===this.currentColor?this.NodeManager.updateNode(e,"None",this.selection):(this.NodeManager.applyColorToSelection(e,this.currentColor,this.selection),this.savedSelection=this.selection.cloneRange())),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog(this.id,this.savedSelection)};resetColorDialog=()=>{this.selection=null,this.colorElement=null,this.colorProperty=null,this.selectedSwatchIndex=null,this.swatches.forEach(e=>{e.classList.remove("rich-text-box-color-option-selected"),e.setAttribute("aria-selected","false")}),this.swatchRegion.removeAttribute("aria-activedescendant"),this.selectSaveFormat("hex"),this.hexInput.value="#000000",this.updateFromHex()};selectColor=e=>{this.hexInput.value=e,this.updateFromHex();const t=this.hexInput.value.toUpperCase(),o=this.swatches.findIndex(e=>e.getAttribute("data-color")===t);o>=0&&o!==this.selectedSwatchIndex?(this.selectedSwatchIndex=o,this.swatches.forEach((e,t)=>{const n=t===o;e.classList.toggle("rich-text-box-color-option-selected",n),e.setAttribute("aria-selected",String(n))}),this.swatchRegion.setAttribute("aria-activedescendant",this.swatches[o].id)):o<0&&(this.selectedSwatchIndex=null,this.swatches.forEach(e=>{e.classList.remove("rich-text-box-color-option-selected"),e.setAttribute("aria-selected","false")}),this.swatchRegion.removeAttribute("aria-activedescendant"))};updateColor=()=>{let e=parseInt(this.redSlider.value),t=parseInt(this.greenSlider.value),o=parseInt(this.blueSlider.value),n=`rgb(${e}, ${t}, ${o})`;this.currentColor=n,this.colorDisplay.style.backgroundColor=n,this.redSlider.style.setProperty("--rtb-slider-thumb-color",`rgb(${e}, 0, 0)`),this.greenSlider.style.setProperty("--rtb-slider-thumb-color",`rgb(0, ${t}, 0)`),this.blueSlider.style.setProperty("--rtb-slider-thumb-color",`rgb(0, 0, ${o})`),this.redValue.value=e,this.greenValue.value=t,this.blueValue.value=o,this.hexInput.value=this.rgbToHex(e,t,o)};getCurrentColor=(e="rgb")=>"hex"===e?this.hexInput.value.startsWith("#")?this.hexInput.value:`#${this.hexInput.value}`:`rgb(${this.redSlider.value}, ${this.greenSlider.value}, ${this.blueSlider.value})`;getSaveFormat=()=>this.saveFormatInputs.find(e=>e.checked)?.value||"rgb";selectSaveFormat=e=>{this.saveFormatInputs.forEach(t=>{t.checked=t.value===e})};getInlineColorFormat=(e,t)=>{const o=(e.getAttribute("style")||"").match(new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"i"));return o&&o[1].trim().startsWith("#")?"hex":"rgb"};updateFromHex=()=>{let e=this.hexInput.value.trim();if("#"!==e.charAt(0)&&(e="#"+e),this.hexInput.value=e.toUpperCase(),/^#[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,o)=>("#"+((1<<24)+(e<<16)+(t<<8)+o).toString(16).slice(1)).toUpperCase();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.toUpperCase()}}window.RTNative_Instances={},window.RTNative_Initialize=(e,o,n,i,r,s)=>{try{null==RTNative_Instances[e]&&(RTNative_Instances[e]=new t(e,o,n,i,s),RTNative_Instances[e].loadHtml(r))}catch(e){console.log(e)}},window.RTNative_Method=(e,t,o)=>{try{const n=RTNative_Instances[t];if(null!=n&&"function"==typeof n[e])return null!=o?n[e](o):n[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 x extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=x._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText="",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-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: #0f6cbd;\n --rtb-modal-checkbox-check: #ffffff;\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 --rtb-modal-checkbox-check: #ffffff;\n}\n\n",document.head.appendChild(e)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(e,t,o){if(t!==o){if("value"===e&&this._initialized&&(this._value=o||"",RTNative_Method("loadView",this._uid,o)),"width"===e&&this.style.setProperty("--rtb-editor-width",o||"100%"),"height"===e&&this.style.setProperty("--rtb-editor-height",o||"300px"),"config"===e)try{this.configure(JSON.parse(o))}catch(e){}if("placeholder"===e){const e=RTNative_Instances?.[this._uid];e?.content&&(o?e.content.setAttribute("data-placeholder",o):e.content.removeAttribute("data-placeholder"))}if("readonly"===e){const e=RTNative_Instances?.[this._uid];e&&e.setReadOnly(null!==o)}if("aria-label"===e||"label"===e){const e=RTNative_Instances?.[this._uid];e?.content&&o&&e.content.setAttribute("aria-label",o)}}}connectedCallback(){x._injectGlobalStyles(),this.style.setProperty("--rtb-editor-width",this.getAttribute("width")||"100%"),this.style.setProperty("--rtb-editor-height",this.getAttribute("height")||"300px"),this._render(),requestAnimationFrame(()=>this._initialize())}get readOnly(){return this.hasAttribute("readonly")}setReadOnly(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 o="",n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;const i=e.indexOf("{",n);if(-1===i)break;const r=e.slice(n,i).trim();let s=1,l=i+1;for(;l<e.length&&s>0;)"{"===e[l]?s++:"}"===e[l]&&s--,l++;const a=e.slice(i+1,l-1);if(n=l,r)if(r.startsWith("@")){const e=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(e)?o+=r+" {\n"+this._scopeCssText(a,t)+"}\n":o+=r+" {"+a+"}\n"}else{o+=r.split(",").map(e=>e.trim()).filter(e=>e).map(e=>":root"===e?t:t+" "+e).join(",\n")+" {"+a+"}\n"}}return o}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();let o="";if(this._previewCssText&&(o+=this._scopeCssText(this._previewCssText,".rich-text-box-content")+"\n"),o.trim()){const t=document.createElement("style");t.id="_rtb-content-preview-styles",t.textContent=o,e.shadowRoot.appendChild(t)}}configure(e={}){const{visibility:t,customButtons:o,...n}=e;if(t){if(t.clearAll&&(this._visibility=x._defaultVisibility(!1)),!0===t.fileMenu&&!1===this._visibility.fileMenu){const e=x._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)}o&&(this._customButtons=Array.isArray(o)?o.filter(e=>e&&e.id):[]),this._applyCSSVars(n),this._syncPreviewTheme(),this._initialized&&(t||o)&&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 o=e.button||{};set("--rtb-btn-text",o.textColor),set("--rtb-btn-size",o.textSize),set("--rtb-btn-font",o.textFont),set("--rtb-btn-bg",o.backgroundColor),set("--rtb-btn-bg-hover",o.backgroundColorHover),set("--rtb-btn-bg-selected",o.backgroundColorSelected),set("--rtb-btn-border-style",o.borderStyle),set("--rtb-btn-border-width",o.borderWidth),set("--rtb-btn-border-color",o.borderColor),set("--rtb-btn-border-hover",o.borderColorHover),set("--rtb-btn-border-selected",o.borderColorSelected),set("--rtb-btn-border-radius",o.borderRadius);const n=e.content||{};set("--rtb-content-text",n.textColor),set("--rtb-content-size",n.textSize),set("--rtb-content-font",n.textFont),set("--rtb-content-bg",n.backgroundColor),set("--rtb-content-shadow",n.boxShadow);const i=e.editor||{};set("--rtb-editor-width",i.width),set("--rtb-editor-height",i.height),set("--rtb-editor-border-radius",i.borderRadius),set("--rtb-editor-border-style",i.borderStyle),set("--rtb-editor-border-width",i.borderWidth),set("--rtb-editor-border-color",i.borderColor),set("--rtb-editor-shadow",i.boxShadow),null!=i.removeResizeHandle&&set("--rtb-editor-resize",i.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 e=this.getAttribute("value")||"",o=null!==this._value?this._value:e;this._value=o;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 t(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: 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.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.active {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-btn-bg-hover, #e8e8e8));\n outline: 2px solid var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n outline-offset: -2px;\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 position: relative;\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-container.rtb-editor-fullscreen > .rich-text-box-content-container {\n flex: 1 1 auto;\n height: auto;\n min-height: 0;\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.rich-text-box-content-container.rtb-source-view .rtb-table-toolbar {\n display: none;\n}\n.rich-text-box-content-container.rtb-source-view .rich-text-box-source {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\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.rtb-table-toolbar {\n align-items: center;\n background-color: var(--rtb-toolbar-bg, #fff);\n border: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n border-radius: 5px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.16);\n box-sizing: border-box;\n display: flex;\n gap: 2px;\n opacity: 0;\n padding: 3px;\n pointer-events: none;\n position: absolute;\n transform: translateY(3px);\n transition: opacity 100ms ease-in-out, transform 100ms ease-in-out;\n user-select: none;\n white-space: nowrap;\n z-index: 20;\n}\n.rtb-table-toolbar.rtb-table-toolbar-visible {\n opacity: 1;\n pointer-events: auto;\n transform: translateY(0);\n}\n.rtb-table-toolbar-button,\n.rtb-table-toolbar-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-btn-text, #242424);\n cursor: pointer;\n display: flex;\n font-family: var(--rtb-btn-font, Arial, Helvetica, sans-serif);\n font-size: 13px;\n gap: 5px;\n justify-content: center;\n min-height: 28px;\n padding: 4px 7px;\n}\n.rtb-table-toolbar-button:hover,\n.rtb-table-toolbar-button:focus-visible,\n.rtb-table-toolbar-button.active,\n.rtb-table-toolbar-menu button:hover,\n.rtb-table-toolbar-menu button:focus-visible,\n.rtb-table-toolbar-menu button.active {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-dropdown-bg-hover, #e5e5e5));\n color: var(--rtb-btn-text-selected, var(--rtb-dropdown-text-hover, #000));\n outline: none;\n}\n.rtb-table-toolbar-icon-button {\n padding-left: 5px;\n padding-right: 5px;\n}\n.rtb-table-toolbar svg {\n fill: currentColor;\n flex: 0 0 auto;\n height: 17px;\n width: 17px;\n}\n.rtb-table-toolbar-button svg:last-child:not(:first-child) {\n height: 13px;\n width: 13px;\n}\n.rtb-table-toolbar-divider {\n align-self: stretch;\n border-left: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n margin: 3px 2px;\n}\n.rtb-table-toolbar-dropdown {\n position: relative;\n}\n.rtb-table-toolbar-menu {\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 6px 14px rgba(0,0,0,0.16);\n display: none;\n left: 0;\n min-width: 148px;\n padding: 4px;\n position: absolute;\n top: calc(100% + 4px);\n z-index: 1;\n}\n.rtb-table-toolbar-dropdown-open .rtb-table-toolbar-menu {\n display: block;\n}\n.rtb-table-toolbar-menu button {\n color: var(--rtb-dropdown-text, #242424);\n gap: 8px;\n justify-content: flex-start;\n text-align: left;\n width: 100%;\n}\n.rtb-table-toolbar-menu-divider {\n border-top: 1px solid rgba(128,128,128,0.18);\n margin: 4px;\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 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 object,\n.rich-text-box-content video { cursor: pointer; }\n.rich-text-box-content table { cursor: var(--rtb-table-cell-cursor, text); }\n.rtb-image-resize-overlay,\n.rtb-table-resize-overlay,\n.rtb-media-resize-overlay {\n border: 1px solid var(--rtb-btn-border-selected, #605e5c);\n box-sizing: border-box;\n display: none;\n pointer-events: none;\n position: absolute;\n transition: none;\n z-index: 15;\n}\n.rtb-image-resize-overlay.rtb-image-resize-visible,\n.rtb-table-resize-overlay.rtb-table-resize-visible,\n.rtb-media-resize-overlay.rtb-media-resize-visible {\n display: block;\n}\n.rtb-image-resize-handle,\n.rtb-table-resize-handle,\n.rtb-media-resize-handle {\n background: var(--rtb-modal-checkbox, #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 var(--rtb-modal-checkbox, #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: none;\n width: 13px;\n}\n.rtb-image-resize-handle:hover,\n.rtb-table-resize-handle:hover,\n.rtb-media-resize-handle:hover {\n box-shadow: 0 0 0 2px var(--rtb-modal-checkbox, #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(.dark) .rtb-media-resize-handle,\n:host(.fluent-dark) .rtb-image-resize-handle,\n:host(.fluent-dark) .rtb-table-resize-handle,\n:host(.fluent-dark) .rtb-media-resize-handle {\n background: var(--rtb-modal-checkbox, #0f6cbd);\n box-shadow: 0 0 0 1px var(--rtb-modal-checkbox, #0f6cbd), 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.rtb-media-resizing,\n.rtb-media-resizing .rtb-media-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-self: stretch;\n border: 0 !important;\n border-left: 1px solid var(--rtb-toolbar-border-color, #d1d1d1) !important;\n outline: none;\n cursor: default;\n margin: 3px 2px;\n padding: 0;\n transform: scaleY(0.78);\n transform-origin: center;\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 display: none;\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 align-items: center;\n display: inline-flex;\n font-size: var(--rtb-btn-size, 16px);\n justify-content: center;\n line-height: 1;\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-file-content,\n.rich-text-box-font-content,\n.rich-text-box-size-content,\n.rich-text-box-format-content {\n overflow-x: hidden;\n overflow-y: auto;\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 .rich-text-box-menu-item: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: 16px;\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 .rich-text-box-menu-item {\n background: transparent;\n border: 0;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #000);\n cursor: pointer;\n font-family: inherit;\n font-size: 18px;\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n text-align: left;\n width: 100%;\n}\n.rich-text-box-dropdown .rich-text-box-menu-item: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 .rich-text-box-menu-item {\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 .rich-text-box-menu-item: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 .rich-text-box-menu-item: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 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.rtb-centered-dialog {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n}\n.rtb-centered-dialog::backdrop {\n background: transparent;\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: 4px;\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 min-height: 32px;\n padding: 5px 12px;\n font-size: 14px;\n line-height: 20px;\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: normal;\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: 4px;\n box-sizing: border-box;\n margin-top: 0px;\n margin-bottom: 12px;\n resize: vertical;\n}\n.rich-text-box-form-element:not(textarea) {\n height: 32px;\n}\n.rich-text-box-form-element:is(textarea) {\n min-height: 52px;\n padding: 6px 12px;\n}\n.rich-text-box-modal label {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n letter-spacing: normal;\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: 4px;\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.rich-text-box-combobox {\n appearance: none;\n cursor: text;\n margin-bottom: 0;\n transition: none;\n}\n.rich-text-box-combobox-wrap {\n margin-bottom: 12px;\n position: relative;\n}\n.rich-text-box-combobox-list {\n background: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n border: 1px solid var(--rtb-toolbar-border-color, var(--rtb-modal-input-border, #CCC));\n border-radius: 5px;\n box-shadow: none;\n box-sizing: border-box;\n font-family: inherit;\n font-size: calc(var(--rtb-modal-text-size, 16px) - 2px);\n font-weight: 400;\n left: 0;\n margin-top: 2px;\n max-height: 121px;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 5px;\n position: absolute;\n right: 0;\n z-index: 20;\n}\n.rich-text-box-combobox-list[hidden] {\n display: none;\n}\n.rich-text-box-combobox-option {\n background: transparent;\n border: 0;\n color: var(--rtb-dropdown-text, var(--rtb-modal-input-text, #000));\n cursor: pointer;\n display: block;\n font: inherit;\n line-height: 20px;\n margin: 2px 0;\n overflow: hidden;\n padding: 5px 10px;\n text-align: left;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n transition: none;\n}\n.rich-text-box-combobox-option:hover,\n.rich-text-box-combobox-option:focus {\n background: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #000));\n outline: none;\n}\n.rich-text-box-combobox-option-active,\n.rich-text-box-combobox-option-selected {\n background: var(--rtb-btn-bg-selected, #dcdcdc) !important;\n box-shadow: none;\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #242424));\n outline: none;\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 appearance: none;\n -webkit-appearance: none;\n background-color: var(--rtb-modal-input-bg, #fff);\n border: 1px solid var(--rtb-modal-input-border, #CCC);\n box-sizing: border-box;\n display: inline-grid;\n flex: 0 0 auto;\n place-content: center;\n outline: none;\n width: 16px;\n height: 16px;\n margin-right: 4px;\n border-radius: 4px;\n cursor: pointer;\n}\n.rich-text-box-form-checkbox:checked {\n background-color: var(--rtb-modal-checkbox, #0f6cbd);\n border-color: var(--rtb-modal-checkbox, #0f6cbd);\n}\n.rich-text-box-form-checkbox:checked::before {\n content: "";\n width: 11px;\n height: 11px;\n clip-path: polygon(14% 44%, 0 58%, 36% 94%, 100% 18%, 86% 6%, 34% 68%);\n background-color: var(--rtb-modal-checkbox-check, #fff);\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-checkbox, #0f6cbd);\n border-width: 1px;\n box-shadow: none;\n}\n.rich-text-box-upload-btn {\n padding: 5px 12px !important;\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: normal;\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: 4px;\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n min-width: 100% !important;\n min-height: 32px;\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-upload-image-modal .rtb-upload-image-file-row {\n box-sizing: border-box;\n display: flex;\n align-items: flex-start;\n gap: 8px;\n height: 64px;\n padding-top: 5px;\n margin-bottom: -5px;\n}\n#rich-text-box-upload-image-modal .rtb-visually-hidden-file {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-grid {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n column-gap: 30px;\n row-gap: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-field {\n box-sizing: border-box;\n min-width: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-left {\n grid-column: 1;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-right {\n grid-column: 2;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-field label:not(.rich-text-box-upload-btn) {\n display: block;\n margin: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-field .rich-text-box-form-element {\n display: block;\n}\n#rich-text-box-upload-image-modal .rich-text-box-upload-btn {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: auto;\n min-width: 0 !important;\n height: 32px;\n min-height: 32px;\n margin: 0 0 0 5px;\n white-space: nowrap;\n}\n#rich-text-box-upload-image-modal #rich-text-box-upload-image-file-chosen {\n display: inline-flex;\n align-items: center;\n min-width: 0;\n min-height: 32px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n@media screen and (max-width: 850px) {\n #rich-text-box-upload-image-modal .rtb-upload-image-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n #rich-text-box-upload-image-modal .rtb-upload-image-file-row {\n height: auto;\n margin-bottom: 10px;\n }\n #rich-text-box-upload-image-modal .rtb-upload-image-left,\n #rich-text-box-upload-image-modal .rtb-upload-image-right {\n grid-column: 1;\n }\n}\n.rich-text-box-form-button {\n min-height: 36px;\n padding: 7px 16px !important;\n border-radius: 4px;\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: normal;\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.rich-text-box-color-swatches {\n display: grid;\n grid-template-columns: repeat(auto-fit, 18px);\n gap: 5px;\n justify-content: center;\n padding: 4px 2px;\n border-radius: 4px;\n}\n.rich-text-box-color-swatches:focus-visible {\n outline: 2px solid var(--rtb-modal-text, #242424);\n outline-offset: 2px;\n}\n.blazing-rich-text-color-option {\n width: 18px;\n height: 18px;\n margin: 0;\n cursor: pointer;\n display: block;\n border: 1px solid #999;\n border-radius: 50%;\n box-sizing: border-box;\n transition: transform 0.12s ease;\n}\n.blazing-rich-text-color-option:hover,\n.blazing-rich-text-color-option.rich-text-box-color-option-selected {\n transform: scale(1.18);\n}\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 position: absolute;\n top: 0;\n left: 0;\n z-index: 20;\n box-sizing: border-box;\n width: 100%;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);\n font-size: 14px;\n background-color: rgba(0, 0, 0, 0.6);\n color: #ffffff;\n display: flex;\n gap: 16px;\n justify-content: space-between;\n align-items: center;\n padding: 5px 10px;\n opacity: 1;\n visibility: visible;\n transition: opacity 160ms ease-in-out, visibility 0s linear 0s;\n pointer-events: auto;\n}\n.rich-text-box-message-bar.rich-text-box-message-hidden {\n opacity: 0;\n pointer-events: none;\n visibility: hidden;\n transition: opacity 160ms ease-in-out, visibility 0s linear 160ms;\n}\n.rich-text-box-message {}\n.rich-text-box-message-close-button {\n background: none; border: none; color: #ffffff; font-size: 18px; cursor: pointer;\n}\n.rich-text-box-color-picker {\n width: 100%;\n --rtb-color-picker-left-width: 367px;\n}\n.rich-text-box-color-swatches,\n.rich-text-box-color-display {\n box-sizing: border-box;\n width: var(--rtb-color-picker-left-width);\n max-width: 100%;\n}\n.rich-text-box-color-swatches {\n margin: 0 auto;\n}\n.rich-text-box-color-display {\n height: 55px;\n border: 1px solid #ccc;\n margin: 8px auto 4px;\n}\n.rich-text-box-custom-colors {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: repeat(5, minmax(0, 1fr));\n gap: 6px;\n width: var(--rtb-color-picker-left-width);\n max-width: 100%;\n margin: 8px auto 0;\n}\n.rich-text-box-custom-color {\n box-sizing: border-box;\n min-width: 0;\n width: 100%;\n padding: 5px 4px;\n border-left: 8px solid var(--rtb-custom-color, var(--rtb-modal-input-border, #CCC));\n text-align: center;\n font-size: 12px;\n text-transform: uppercase;\n cursor: pointer;\n margin-bottom: 0;\n}\n.rich-text-box-custom-color::placeholder {\n text-transform: none;\n}\n.rich-text-box-color-modal input.rich-text-box-custom-color:focus-visible {\n border-color: var(--rtb-modal-input-border, #CCC) !important;\n border-left-color: var(--rtb-custom-color, var(--rtb-modal-input-border, #CCC)) !important;\n}\n.rich-text-box-custom-color[aria-invalid="true"] {\n border-color: #c42b1c;\n}\n.rich-text-box-color-modal .rtb-modal-footer {\n padding-top: 0;\n}\n.rich-text-box-color-modal .rich-text-box-form-right {\n box-sizing: border-box;\n padding-top: 27px;\n}\n@media screen and (max-width: 850px) {\n .rich-text-box-color-modal .rich-text-box-form-right {\n padding-top: 0;\n }\n}\n.rich-text-box-slider-container {\n display: flex;\n align-items: center;\n margin-bottom: 10px;\n position: relative;\n top: -10px;\n}\n@media screen and (max-width: 850px) {\n .rich-text-box-slider-container {\n top: 10px;\n }\n}\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;\n height: 18px;\n width: 18px;\n background: var(--rtb-slider-thumb-color, var(--rtb-modal-bg, #fefefe));\n margin-top: -6.5px;\n border: 1px solid #999;\n border-radius: 50%;\n box-sizing: border-box;\n transition: transform 0.12s ease;\n}\n.rich-text-box-range::-moz-range-thumb {\n -webkit-appearance: none;\n height: 18px;\n width: 18px;\n background: var(--rtb-slider-thumb-color, var(--rtb-modal-bg, #fefefe));\n margin-top: -6.5px;\n border: 1px solid #999;\n border-radius: 50%;\n box-sizing: border-box;\n transition: transform 0.12s ease;\n}\n.rich-text-box-range:focus-visible::-webkit-slider-thumb {\n transform: scale(1.18);\n}\n.rich-text-box-range:focus-visible::-moz-range-thumb {\n transform: scale(1.18);\n}\n.rich-text-box-number {\n width: 100px; margin-left: 10px; padding: 5px 12px; 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: 4px; box-sizing: border-box;\n}\n.rich-text-box-form-element[type="number"] {\n color-scheme: inherit;\n}\n:host(.light),\n:host(.fluent) {\n color-scheme: light;\n}\n:host(.dark),\n:host(.fluent-dark) {\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 {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: 20px;\n align-items: start;\n margin-top: 30px;\n}\n.rich-text-box-color-control {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n.rich-text-box-color-control > label,\n.rich-text-box-color-save-as {\n margin: 0;\n}\n.rich-text-box-color-control > label,\n.rich-text-box-color-save-as legend {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.rich-text-box-hex-input {\n width: 100% !important;\n margin: 0;\n}\n.rich-text-box-color-save-as {\n border: 0;\n display: flex;\n align-items: flex-start;\n flex-direction: column;\n padding: 0;\n}\n.rich-text-box-color-save-as legend {\n float: none;\n padding: 0;\n}\n.rich-text-box-color-save-as ul {\n align-items: center;\n display: flex;\n gap: 10px;\n list-style: none;\n margin: 0;\n min-height: 28px;\n overflow: visible;\n padding: 0;\n}\n.rich-text-box-color-save-as li {\n display: flex;\n margin: 0;\n}\n.rich-text-box-color-save-as label {\n align-items: center;\n border: 1px solid transparent;\n border-radius: 4px;\n cursor: pointer;\n display: inline-flex;\n gap: 5px;\n line-height: 20px;\n padding: 3px 6px;\n}\n.rich-text-box-color-save-format {\n appearance: none;\n -webkit-appearance: none;\n background-color: var(--rtb-modal-input-bg, #fff);\n border: 2px solid var(--rtb-modal-input-border, #a0a0a0);\n border-radius: 50%;\n box-sizing: border-box;\n cursor: pointer;\n flex: 0 0 16px;\n height: 16px;\n margin: 0;\n width: 16px;\n}\n.rich-text-box-color-save-format:checked {\n background-color: var(--rtb-modal-checkbox, #0f6cbd);\n border-color: var(--rtb-modal-checkbox, #0f6cbd);\n box-shadow: inset 0 0 0 3px var(--rtb-modal-input-bg, #fff);\n}\n.rich-text-box-color-save-format:focus-visible {\n outline: 2px solid var(--rtb-modal-checkbox, #0f6cbd);\n outline-offset: 2px;\n transform: scale(1.08);\n}\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; }\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-centered-dialog[open] {\n animation: rtb-dialog-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 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 n=this.getAttribute("aria-label")||this.getAttribute("label");n&&RTNative_Instances[this._uid].content.setAttribute("aria-label",n);const i=this.getAttribute("placeholder");i&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",i),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid]._applyStoredStatusBarVisibility(),RTNative_Instances[this._uid].loadHtml(o),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,o,n,i){return`<button id="${e}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==i?`RTNative_Method('${n}','${this._uid}','${i}')`:`RTNative_Method('${n}','${this._uid}')`}">${this._svg(t)}</button>`}_specialBtn(e,t,o,n){return`<button id="${e}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${n}','${this._uid}')">${this._svg(t)}</button>`}_fullscreenBtn(){return`<button id="blazing-rich-text-fullscreen-button" title="Maximize Editor (Ctrl+Shift+F)" 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),o=this._escapeAttr(e.title||e.label||e.id),n=e.svg||"";return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item rich-text-box-custom-button" data-rtb-custom-button="${t}"${e.disabled?" disabled":""}>${n}</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 o=e.shadowRoot.querySelector(`[data-rtb-custom-button="${CSS.escape(t.id)}"]`);o&&o.addEventListener("click",o=>{if(t.disabled)return;const n=this._resolveCustomButtonHandler(t.onClick||t.method);"function"==typeof n&&n.call(this,o,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=>`<button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-family:${t}" onclick="RTNative_Method('font','${e}','${t}')">${t}</button>`).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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-font-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-font-button">\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=>`<button type="button" role="menuitem" class="rich-text-box-menu-item" style="${"None"===t?"":`font-size:${t}px !important;`}" onclick="RTNative_Method('size','${e}','${"None"===t?"None":`${t}px`}')">${"None"===t?"None":t}</button>`).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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-size-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-size-button">\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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-format-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-format-button">\n <button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('format','${e}','p')">Paragraph</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:34px" onclick="RTNative_Method('format','${e}','h1')">Heading 1</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:30px" onclick="RTNative_Method('format','${e}','h2')">Heading 2</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:24px" onclick="RTNative_Method('format','${e}','h3')">Heading 3</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:20px" onclick="RTNative_Method('format','${e}','h4')">Heading 4</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:18px" onclick="RTNative_Method('format','${e}','h5')">Heading 5</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:16px" onclick="RTNative_Method('format','${e}','h6')">Heading 6</button>\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,o])=>`\n <div class="rich-text-box-insert-group" role="presentation">${t}</div>\n ${o.map(([t,o])=>`\n <button type="button" role="menuitem" 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">${o||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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-insert-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-insert-button">\n ${t}\n </div>\n</div>`}_fileDropdown(){const e=this._uid,t=this._visibility,o=`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','open')">Open<span class="rich-text-box-menu-shortcut">Ctrl+O</span></button>`;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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-file-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-file-button">\n ${t.search?`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','find')">Find<span class="rich-text-box-menu-shortcut">Ctrl+F</span></button>`:""}${o}${t.saveHtml?`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','save')">Download<span class="rich-text-box-menu-shortcut">Ctrl+S</span></button>`:""}${(t.search||t.saveHtml||o)&&t.statusBarToggle?'<hr class="rich-text-box-dropdown-divider" role="separator">':""}${t.statusBarToggle?`<button type="button" role="menuitem" class="rich-text-box-menu-item" 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></button>`:""}${(t.search||t.saveHtml||t.statusBarToggle)&&t.help?'<hr class="rich-text-box-dropdown-divider" role="separator">':""}${t.help?`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','shortcuts')">Keyboard Shortcuts<span class="rich-text-box-menu-shortcut">Ctrl+/</span></button>`:""}\n </div>\n</div>`}_colorSwatches(e){const t=[0,12,24,36,48,60,90,120,150,180,205,230,255,280,305,330];return[80,68,56,44,32,20].flatMap(e=>t.map(t=>((e,t,o)=>{t/=100,o/=100;const n=(1-Math.abs(2*o-1))*t,i=e/60,r=n*(1-Math.abs(i%2-1)),s=o-n/2;return`#${(i<1?[n,r,0]:i<2?[r,n,0]:i<3?[0,n,r]:i<4?[0,r,n]:i<5?[r,0,n]:[n,0,r]).map(e=>Math.round(255*(e+s)).toString(16).padStart(2,"0")).join("").toUpperCase()}`})(t,85,e))).concat(["#000000","#101010","#202020","#303030","#404040","#555555","#6A6A6A","#7F7F7F","#949494","#A8A8A8","#BDBDBD","#D0D0D0","#E0E0E0","#EDEDED","#F7F7F7","#FFFFFF"]).map(t=>`<div class="blazing-rich-text-color-option" role="option" aria-label="${t}" title="${t}" data-color="${t}" onclick="RTNative_Method('${e}','${this._uid}','${t}')" style="background-color:${t};"></div>`).join("")}_colorDialog(e,t,o,n){const i=this._uid;return`\n<dialog id="${e}" class="rich-text-box-modal rich-text-box-color-modal rtb-centered-dialog" 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','${i}','${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 <div class="rich-text-box-color-swatches" role="listbox" tabindex="0" aria-label="Preset colors; use left and right arrow keys to select">\n ${this._colorSwatches(o)}\n </div>\n <div class="rich-text-box-custom-colors" aria-label="Custom colors">\n ${[1,2,3,4,5].map(e=>`<input type="text" class="rich-text-box-form-element rich-text-box-custom-color" placeholder="Hex ${e}" aria-label="Custom color Hex ${e}" maxlength="7" autocomplete="off" spellcheck="false">`).join("")}\n </div>\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 <div class="rich-text-box-color-control">\n <label for="${e}-hex-input">Hexadecimal</label>\n <input id="${e}-hex-input" type="text" class="rich-text-box-form-element rich-text-box-hex-input" value="#000000" autocomplete="off">\n </div>\n <fieldset class="rich-text-box-color-save-as rich-text-box-color-control">\n <legend>Save As</legend>\n <ul>\n <li><label><input class="rich-text-box-color-save-format" type="radio" name="${e}-save-format" value="hex" checked> Hex</label></li>\n <li><label><input class="rich-text-box-color-save-format" type="radio" name="${e}-save-format" value="rgb"> RGB</label></li>\n </ul>\n </fieldset>\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','${i}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${n}','${i}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(e,t,o,n,i=""){const r=this._uid,s="rich-text-box-upload-image-modal"===e?{close:' tabindex="10"',footerClose:' tabindex="8"',ok:' tabindex="9"'}:{close:"",footerClose:"",ok:""};return`\n<dialog id="${e}" class="rich-text-box-modal rtb-centered-dialog" 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"${s.close} 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 ${n}\n </div>\n <div class="rtb-modal-footer" style="${i?"display:flex;justify-content:space-between;align-items:center;":"text-align:right;"}">\n ${i?`<div>${i}</div>`:""}\n <div>\n <button class="rich-text-box-form-button"${s.footerClose} onclick="RTNative_Method('closeDialog','${r}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button"${s.ok} onclick="RTNative_Method('${o}','${r}')">OK</button>\n </div>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const e=this._uid,t=this._visibility,o=(t.font||t.size||t.format||t.insert)&&t.textStylesDivider,n=(t.bold||t.italic||t.underline||t.strikethrough||t.subscript||t.superscript||t.inlineCode)&&t.formatDivider,i=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,c=(t.undo||t.redo)&&t.historyDivider,d=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 ${o?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 ${n?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 ${i?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 ${c?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 ${d?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" style="clear:left;">\n <label>Margin</label>\n <input type="text" id="rich-text-box-table-margin" class="rich-text-box-form-element" placeholder="10px">\n <label>Caption (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-table-caption">\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 <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" required>\n <label>Type</label>\n <div class="rich-text-box-combobox-wrap">\n <input class="rich-text-box-form-element rich-text-box-float-dropdown rich-text-box-combobox" type="text" id="rich-text-box-embed-type" placeholder="None" autocomplete="off">\n <div class="rich-text-box-combobox-list" id="rich-text-box-embed-type-list" role="listbox" hidden>\n ${["application/pdf","audio/mpeg","audio/mp4","audio/ogg","audio/wav","audio/webm","image/avif","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","text/html","text/plain","video/mp4","video/ogg","video/webm"].map(e=>`<button type="button" class="rich-text-box-combobox-option" data-value="${e}" role="option">${e}</button>`).join("")}\n </div>\n </div>\n <label>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-margin" placeholder="10px" autocomplete="off">\n <label>Aria-label (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-aria-label">\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 <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-embed-float">\n <option value="none" selected>None</option>\n <option value="left">Left</option>\n <option value="right">Right</option>\n </select>\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" required>\n <label>Type</label>\n <div class="rich-text-box-combobox-wrap">\n <input class="rich-text-box-form-element rich-text-box-float-dropdown rich-text-box-combobox" type="text" id="rich-text-box-video-source-type" placeholder="None" autocomplete="off">\n <div class="rich-text-box-combobox-list" id="rich-text-box-video-source-type-list" role="listbox" hidden>\n ${["video/mp4","video/webm","video/ogg"].map(e=>`<button type="button" class="rich-text-box-combobox-option" data-value="${e}" role="option">${e}</button>`).join("")}\n </div>\n </div>\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 <label>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-margin" placeholder="10px" 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 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>Aria-label (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-aria-label">\n <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-video-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 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" required></textarea>\n <div class="rich-text-box-form-left">\n <label>Aria-label (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-code-aria-label">\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-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" required></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" required>\n <label>Alt Text (for screen readers)</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="rtb-upload-image-grid">\n <div class="rtb-upload-image-field rtb-upload-image-left">\n <div class="rtb-upload-image-file-row">\n <input type="file" id="rich-text-box-upload-image-file" class="rtb-visually-hidden-file" required>\n <label id="rich-text-box-upload-btn" for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn" tabindex="1" 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 </div>\n <div class="rtb-upload-image-field rtb-upload-image-left">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-width" tabindex="2" placeholder="400" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-right">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-height" tabindex="3" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-left">\n <label>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-margin" tabindex="4" placeholder="10px" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-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" tabindex="5">\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="rtb-upload-image-field rtb-upload-image-left">\n <label>Alt Text (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-alt-text" tabindex="6" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-right">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-css-classes" tabindex="7" 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" required>\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" required>\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 class="rich-text-box-form-right">\n <label class="rich-text-box-form-checkbox-label" style="display:flex;align-items:center;margin-top:20px;"><input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox"> Open in New Tab</label>\n </div>\n </div>\n ')}\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>Toolbar</td><td>${k("Alt","F10")}</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>Context toolbar</td><td>${k("Alt","O")}</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><td>Increase indent</td><td>${k("Tab")}</td></tr>\n <tr><td>Decrease indent</td><td>${k("Shift","Tab")}</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>Maximize editor</td><td>${k("Ctrl","Shift","F")}</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 <tr><td>Escape editor</td><td>${k("Escape")}</td></tr>\n </tbody>\n </table>\n </div>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",x);
1
+ const e={storageKey:"rtb-settings",legacyStatusBarKey:"rtb-status-bar-visible",colorDialogIds:["rich-text-box-text-color-modal","rich-text-box-text-bg-color-modal"],normalizeCustomColors(e){const t=Array.isArray(e)?e.slice(0,5).map(e=>/^#[0-9A-F]{6}$/i.test(e)?e.toUpperCase():""):[];for(;t.length<5;)t.push("");return t},read(){let e={};try{const t=localStorage.getItem(this.storageKey);if(t){const o=Uint8Array.from(atob(t),e=>e.charCodeAt(0));e=JSON.parse((new TextDecoder).decode(o))}}catch{}if(e&&"object"==typeof e&&!Array.isArray(e)||(e={}),"boolean"!=typeof e.statusBarVisible)try{const t=localStorage.getItem(this.legacyStatusBarKey);null!==t&&(e.statusBarVisible="1"===t)}catch{}const t=Array.isArray(e.customColors)?this.normalizeCustomColors(e.customColors):null,o=e.customColors&&"object"==typeof e.customColors&&!Array.isArray(e.customColors)?e.customColors:{};return e.customColors=Object.fromEntries(this.colorDialogIds.map(e=>[e,this.normalizeCustomColors(o[e]||t)])),e},write(e){try{const t={...this.read(),...e},o=(new TextEncoder).encode(JSON.stringify(t)),n=btoa(Array.from(o,e=>String.fromCharCode(e)).join(""));localStorage.setItem(this.storageKey,n),localStorage.removeItem(this.legacyStatusBarKey)}catch{}}};class t{constructor(e,t,o,n,i){this.id=e,this.shadow_id=t,this.toolbar_id=o,this.styles=n,this.dotNetObjectReference=i,this._selectAllActive=!1,this._suppressTableToolbarForKeyboardNavigation=!1,this.init()}init=()=>{this.hydrateShadowTree(),this.associateDialogLabels(),this.Utilities=new s(this.shadowRoot,this.content),this.NodeManager=new n(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new r(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",t="rich-text-box-text-bg-color-modal";this.ColorPickers[e]=new p(this.shadowRoot,this.content,e,this.NodeManager,this.Utilities),this.ColorPickers[t]=new p(this.shadowRoot,this.content,t,this.NodeManager,this.Utilities),this.LinkDialog=new g(this.shadowRoot,this.content,this.Utilities),this.ImageDialog=new u(this.shadowRoot,this.content,this.Utilities,this.closeImageDialog),this.UploadImageDialog=new b(this.shadowRoot,this.content,this.Utilities,this.closeUploadImageDialog),this.BlockQuoteDialog=new h(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new d(this.shadowRoot,this.content,this.Utilities),this.MediaDialog=new a(this.shadowRoot,this.content,this.Utilities,this.closeMediaDialog),this.VideoDialog=new c(this.shadowRoot,this.content,this.Utilities,this.closeVideoDialog),this.TableDialog=new l(this.shadowRoot,this.content,this.Utilities,this.closeTableDialog),this.StateManager=new o(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners(),this.addDialogCloseFocusRestoration(),this.addToolbarMenuKeyboardNavigation(),this.setDefaultParagraphSeparator(),this.initMainToolbarTabstop(),this.addMainToolbarFocusStyle()};associateDialogLabels=()=>{let e=0;this.shadowRoot.querySelectorAll("dialog").forEach(t=>{t.querySelectorAll("label").forEach(o=>{if(o.hasAttribute("for")||o.querySelector("input, select, textarea"))return;let n=o.nextElementSibling;n&&!n.matches("input, select, textarea")&&(n=n.querySelector?.("input, select, textarea")),n&&(n.id||(e++,n.id=`${t.id||"rich-text-box-dialog"}-control-${e}`),o.setAttribute("for",n.id))}),t.querySelectorAll(".rich-text-box-slider-container").forEach(e=>{const t=e.querySelector("label"),o=e.querySelector('input[type="number"]');t&&o&&!o.hasAttribute("aria-label")&&o.setAttribute("aria-label",`${t.textContent.trim()} numeric value`)})})};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)}),this.mediaResizeOverlay=document.createElement("div"),this.mediaResizeOverlay.className="rtb-media-resize-overlay",this.mediaResizeOverlay.setAttribute("aria-hidden","true"),["nw","n","ne","e","se","s","sw","w"].forEach(e=>{const t=document.createElement("span");t.className=`rtb-media-resize-handle rtb-image-resize-${e}`,t.dataset.direction=e,this.mediaResizeOverlay.appendChild(t)}),this.tableToolbar=this.createTableToolbar();const o=document.createElement("div");o.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),o.setAttribute("id","rich-text-box-message-bar");const n=document.createElement("span");n.setAttribute("class","rich-text-box-message");const i=document.createElement("button");i.setAttribute("class","rich-text-box-message-close-button"),i.setAttribute("type","button"),i.setAttribute("aria-label","Close error message"),i.textContent="�",i.onclick=e=>{e.preventDefault(),e.stopPropagation(),this.Utilities.closeFadingBar()},o.appendChild(n),o.appendChild(i),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.contentContainer.appendChild(this.mediaResizeOverlay),this.contentContainer.appendChild(this.tableToolbar),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(o),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)};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 o=this.Utilities.getSelection();return!!(o&&o.rangeCount>0&&this.isSelectionInsideEditor(o))};recoverEditorTab=e=>{this.shouldRecoverEditorTab(e)&&(e.preventDefault(),e.stopPropagation(),this.content.focus({preventScroll:!0}),this.keyEvents(e))};escapeEditor=()=>{const e=this._rtbHostElement||this.shadowRoot.host.parentElement||this.shadowRoot.host,t=Array.from(document.querySelectorAll('a[href]:not([tabindex="-1"]), button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), textarea:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])')).filter(t=>!e.contains(t)).filter(t=>!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)),o=t.length>0?t[0]:null;o&&o.focus({preventScroll:!0})};_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 o=e.querySelector(":scope > button");return o&&t.has(o.id)},o=[],n=[],i=[];for(const t of Array.from(e.children))"DIALOG"===t.tagName?i.push(t):isPinned(t)?o.push(t):n.push(t);const r=document.createElement("div");r.className="rtb-toolbar-items";for(const e of n)r.appendChild(e);for(;e.firstChild;)e.removeChild(e.firstChild);for(const t of o)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 o=l.classList.toggle("rtb-overflow-open");s.setAttribute("aria-expanded",String(o)),o&&(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 c=new ResizeObserver(()=>this._scheduleOverflowUpdate());c.observe(e),c.observe(r),c.observe(this.container),c.observe(this.contentContainer),this._overflowResizeObserver=c;for(const t of i)e.appendChild(t)};_scheduleOverflowUpdate=()=>{this._overflowItemsContainer&&!this._overflowUpdatePending&&(this._overflowUpdatePending=!0,requestAnimationFrame(()=>{this._overflowUpdatePending=!1,this._updateToolbarOverflow(),this.resizeOpenToolbarDropdowns(),this.initMainToolbarTabstop()}))};_updateToolbarOverflow=()=>{const e=this._overflowItemsContainer,t=this._overflowWrapper,o=this._overflowDropdown,n=this._overflowToolbar;if(!e)return;if(o.classList.contains("rtb-overflow-open")&&(o.style.maxWidth=n.offsetWidth-10+"px"),Array.from(o.children).forEach(t=>e.appendChild(t)),t.style.display="none",e.scrollWidth<=e.offsetWidth)return;t.style.display="";const i=Array.from(e.children);for(let t=i.length-1;t>=0&&!(e.scrollWidth<=e.offsetWidth);t--)o.insertBefore(i[t],o.firstChild);o.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({preventScroll:!0}):this.source.focus({preventScroll:!0})};scrollElementIntoNearestEditorScroller=e=>{if(!e?.getBoundingClientRect)return;let t=e.parentElement;for(;t&&t!==this.container;){const o=window.getComputedStyle(t),n=/(auto|scroll|overlay)/.test(o.overflowY)&&t.scrollHeight>t.clientHeight,i=/(auto|scroll|overlay)/.test(o.overflowX)&&t.scrollWidth>t.clientWidth;if(n||i){const o=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n&&(o.top<r.top?t.scrollTop-=r.top-o.top:o.bottom>r.bottom&&(t.scrollTop+=o.bottom-r.bottom)),void(i&&(o.left<r.left?t.scrollLeft-=r.left-o.left:o.right>r.right&&(t.scrollLeft+=o.right-r.right)))}t=t.parentElement}};scheduleCaretScrollIntoView=()=>{this._caretScrollFrame||(this._caretScrollFrame=requestAnimationFrame(()=>{this._caretScrollFrame=null,this.scrollCaretIntoView()}))};scrollCaretIntoView=()=>{if(this._suppressCaretScroll)return;if(!this.EditMode||"none"===this.content.style.display)return;const e=this.Utilities.getSelection();if(!e||0===e.rangeCount||!this.isSelectionInsideEditor(e))return;const t=e.getRangeAt(0).cloneRange();t.collapse(e.focusNode===t.startContainer&&e.focusOffset===t.startOffset);let o=t.getClientRects()[0]||t.getBoundingClientRect();if(!o||!o.width&&!o.height){const e=t.startContainer.nodeType===Node.ELEMENT_NODE?t.startContainer:t.startContainer.parentElement,n=t.startContainer.nodeType===Node.ELEMENT_NODE&&e?.childNodes?.[t.startOffset]||e;o=n?.getBoundingClientRect?.()||e?.getBoundingClientRect?.()}if(!o)return;const n=this.contentContainer,i=n.getBoundingClientRect(),r=Math.max(o.height||0,16),s=Math.ceil(r/2);o.top<i.top+s?n.scrollTop-=i.top+s-o.top:o.bottom>i.bottom-s&&(n.scrollTop+=o.bottom-(i.bottom-s)),o.left<i.left+s?n.scrollLeft-=i.left+s-o.left:o.right>i.right-s&&(n.scrollLeft+=o.right-(i.right-s))};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):[];getMainToolbarButtons=()=>{const e=[],t=this._overflowToolbar;return t?(t.querySelectorAll(":scope > .rich-text-box-dropdown > .rich-text-box-dropdown-btn").forEach(t=>{t.disabled||e.push(t)}),this._overflowItemsContainer&&this._overflowItemsContainer.querySelectorAll(":scope > button:not(:disabled)").forEach(t=>{e.push(t)}),this._overflowBtn&&this.isOverflowOptionsVisible()&&e.push(this._overflowBtn),e):e};initMainToolbarTabstop=()=>{const e=this.getMainToolbarButtons();if(!e.length)return;const t=e.find(e=>"0"===e.getAttribute("tabindex"))||e[0];e.forEach(e=>e.setAttribute("tabindex",e===t?"0":"-1"))};focusMainToolbarButton=e=>{this.getMainToolbarButtons().forEach(e=>e.setAttribute("tabindex","-1")),e.setAttribute("tabindex","0"),e.focus({preventScroll:!0})};focusToolbarMenuItem=(e,t)=>{const o=this.getToolbarMenuItems(e);if(0===o.length)return;const n=(t+o.length)%o.length;o.forEach(e=>{e.setAttribute("tabindex","-1"),e.classList.remove("active")}),o[n].classList.add("active"),o[n].focus({preventScroll:!0}),this.scrollElementIntoNearestEditorScroller(o[n])};focusFirstToolbarMenuItem=e=>{requestAnimationFrame(()=>this.focusToolbarMenuItem(e,0))};handleToolbarMenuArrowKey=(e,t)=>{const o=this.getToolbarMenuItems(t);if(0===o.length)return;const n=Math.max(0,o.indexOf(e.target)),i=t===this._overflowDropdown?"ArrowRight":"ArrowDown",r=t===this._overflowDropdown?"ArrowLeft":"ArrowUp";if(e.key===i&&(e.preventDefault(),this.focusToolbarMenuItem(t,n+1)),e.key===r||"ArrowUp"===e.key&&0===n)if(e.preventDefault(),0===n){const e=t===this._overflowDropdown?this._overflowBtn:t.closest(".rich-text-box-dropdown")?.querySelector(".rich-text-box-dropdown-btn");this.NodeManager.closeDropdowns(),e&&this.focusMainToolbarButton(e)}else this.focusToolbarMenuItem(t,n-1);"Home"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,0)),"End"===e.key&&(e.preventDefault(),this.focusToolbarMenuItem(t,o.length-1))};addToolbarMenuKeyboardNavigation=()=>{this.shadowRoot.addEventListener("keydown",e=>{if(e.defaultPrevented)return;if(e.altKey&&!e.ctrlKey&&!e.metaKey&&"F10"===e.key){e.preventDefault();const t=this.getMainToolbarButtons();if(t.length){const e=t.find(e=>"0"===e.getAttribute("tabindex"))||t[0];this.focusMainToolbarButton(e)}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 o=e.target.closest(".rich-text-box-dropdown-btn");if(o&&["ArrowDown","ArrowUp"].includes(e.key)){e.preventDefault();const t=o.parentElement?.querySelector(".rich-text-box-dropdown-content");if(t){t.classList.contains("rich-text-box-show")||this.openToolbarDropdown(t.id);const o="ArrowUp"===e.key?this.getToolbarMenuItems(t).length-1:0;requestAnimationFrame(()=>this.focusToolbarMenuItem(t,o))}}if(["ArrowLeft","ArrowRight"].includes(e.key)){const t=this.getMainToolbarButtons(),o=t.indexOf(e.target);if(-1!==o){e.preventDefault();const n=(o+("ArrowRight"===e.key?1:-1)+t.length)%t.length;return void this.focusMainToolbarButton(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))}e.target===this._overflowBtn&&"ArrowDown"===e.key&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this._overflowDropdown.classList.contains("rtb-overflow-open")||this.openOverflowOptions(),requestAnimationFrame(()=>this.focusToolbarMenuItem(this._overflowDropdown,0)))})};addMainToolbarFocusStyle=()=>{const e=this._overflowToolbar;e&&(e.addEventListener("focusin",e=>{const t=this.getMainToolbarButtons();t.forEach(e=>e.classList.remove("active")),t.includes(e.target)&&e.target.classList.add("active")}),e.addEventListener("focusout",t=>{e.contains(t.relatedTarget)||this.getMainToolbarButtons().forEach(e=>e.classList.remove("active"))}))};showImageResizeHandles=(e,t=!0)=>{e&&"IMG"===e.tagName&&this.content.contains(e)&&(this.hideTableResizeHandles(),this.hideMediaResizeHandles(),this.clearEditorTextSelection(),this.content.focus({preventScroll:!0}),this.selectedResizeImage=e,this._updateStatusLinkFromNode(e),this.imageResizeOverlay.classList.add("rtb-image-resize-visible"),this.positionImageResizeHandles(),this.NodeManager.selectButtons(e),t&&this.showPersistentContextToolbar(e),this.observeSelectedResizeElement(e))};hideImageResizeHandles=()=>{this._imageResizeState||(this._selectedResizeObserverElement===this.selectedResizeImage&&(this._selectedResizeObserver?.disconnect(),this._selectedResizeObserverElement=null),this.selectedResizeImage=null,this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"),this._hoveredStatusLink||this._updateStatusLinkFromNode(this.Utilities.getSelection()?.anchorNode))};showTableResizeHandles=e=>{e&&"TABLE"===e.tagName&&this.content.contains(e)&&(this.hideImageResizeHandles(),this.hideMediaResizeHandles(),this.selectedResizeTable=e,this.positionTableResizeHandles(),this.tableResizeOverlay.classList.add("rtb-table-resize-visible"),this.NodeManager.selectButtons(e),this._selectedTableResizeObserver||(this._selectedTableResizeObserver=new ResizeObserver(()=>{this.selectedResizeTable&&(this.positionTableResizeHandles(),this.positionTableToolbar())})),this._selectedTableResizeObserver.disconnect(),this._selectedTableResizeObserver.observe(e))};createTableToolbar=()=>{const e=document.createElement("div");return e.className="rtb-table-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Context tools"),e.setAttribute("aria-hidden","true"),e};addContextToolbarDivider=()=>{const e=document.createElement("span");e.className="rtb-table-toolbar-divider",e.setAttribute("aria-hidden","true"),this.tableToolbar.appendChild(e)};addContextToolbarButton=(e,t=!0)=>{const o=document.createElement("button");o.type="button",o.className=t?"rtb-table-toolbar-button rtb-table-toolbar-icon-button":"rtb-table-toolbar-button",o.setAttribute("aria-label",e.label),o.title=e.label,o.innerHTML=`${this._contextMenuIcon(e.icon)}${t?"":`<span>${e.label}</span>`}`,o.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("click",t=>{t.stopPropagation(),this.closeTableToolbarMenus();try{e.action()}finally{this.hideTableToolbar()}}),this.tableToolbar.appendChild(o)};addDialogCloseFocusRestoration=()=>{this.shadowRoot.querySelectorAll("dialog").forEach(e=>{e.addEventListener("close",()=>{requestAnimationFrame(this.focusEditorAfterDialogClose)})})};focusEditorAfterDialogClose=()=>{if(this._skipNextDialogFocusRestore)return void(this._skipNextDialogFocusRestore=!1);if(this.shadowRoot.querySelector("dialog[open]"))return;if(!1===this.EditMode)return void this.source.focus({preventScroll:!0});this.content.focus({preventScroll:!0});const e=this.shadowRoot.getSelection()||window.getSelection();if(!e)return;const t=this._lastEditorSelectionRange;if(this._lastEditorSelectionRange=null,t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))try{return e.removeAllRanges(),e.addRange(t),void this.content.focus({preventScroll:!0})}catch{}if(e.rangeCount>0&&this.content.contains(e.anchorNode)&&this.content.contains(e.focusNode))return;const o=document.createRange(),n=this.content.lastChild;n?(o.selectNodeContents(n),o.collapse(!1)):(o.setStart(this.content,0),o.collapse(!0)),e.removeAllRanges(),e.addRange(o),this.content.focus({preventScroll:!0})};rememberEditorSelection=()=>{if(this.shadowRoot.querySelector("dialog[open]"))return;const e=this.Utilities.getSelection();e?.rangeCount>0&&(this._lastEditorSelectionRange=e.getRangeAt(0).cloneRange())};clearEditorTextSelection=()=>{const e=this.shadowRoot.getSelection()||window.getSelection();e&&e.rangeCount>0&&this.isSelectionInsideEditor(e)&&e.removeAllRanges(),this._lastEditorSelectionRange=null};removeSelectedObjectAndRestoreCaret=(e,t)=>{if(!e||!this.content.contains(e))return!1;const o=e.parentNode;if(!o)return!1;const n=Array.prototype.indexOf.call(o.childNodes,e);"function"==typeof t&&t();const i=this.shadowRoot.getSelection()||window.getSelection();if(i){const t=document.createRange();if("OBJECT"===e.tagName||"VIDEO"===e.tagName){const i=this.getTopLevelEditorChild(e);if(i===e||i&&""===i.textContent.replace(/\u200B/g,"").trim()&&!Array.from(i.querySelectorAll("img, object, video, table, hr")).some(t=>t!==e)){const o=document.createElement("p");o.appendChild(document.createElement("br"));(i===e?e:i).replaceWith(o),t.setStart(o,0)}else{e.remove();const i=Math.max(0,Math.min(n,o.childNodes.length));t.setStart(o,i)}}else{e.remove();const i=Math.max(0,Math.min(n,o.childNodes.length));t.setStart(o,i)}t.collapse(!0),i.removeAllRanges(),i.addRange(t),this._lastEditorSelectionRange=t.cloneRange()}else e.remove();return this.content.focus({preventScroll:!0}),!0};scheduleResizeHandlePosition=()=>{this._resizeHandlePositionFrame||(this._resizeHandlePositionFrame=requestAnimationFrame(()=>{this._resizeHandlePositionFrame=null,this.selectedResizeImage&&this.positionImageResizeHandles(),this.selectedResizeTable&&this.positionTableResizeHandles(),this.selectedResizeMedia&&this.positionMediaResizeHandles()}))};addContextToolbarDropdown=(e,t)=>{const o=document.createElement("div");o.className="rtb-table-toolbar-dropdown";const n=document.createElement("button");n.type="button",n.className="rtb-table-toolbar-button",n.setAttribute("aria-haspopup","menu"),n.setAttribute("aria-expanded","false"),n.innerHTML=`<span>${e}</span>${this._contextMenuIcon("ArrowDown")}`,n.addEventListener("mousedown",e=>e.preventDefault());const i=document.createElement("div");i.className="rtb-table-toolbar-menu",i.setAttribute("role","menu"),t.forEach(e=>{if(e.divider){const e=document.createElement("div");return e.className="rtb-table-toolbar-menu-divider",e.setAttribute("role","separator"),void i.appendChild(e)}const t=document.createElement("button");t.type="button",t.setAttribute("role","menuitem"),t.setAttribute("tabindex","-1"),t.innerHTML=`${this._contextMenuIcon(e.icon)}<span>${e.label}</span>`,t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{t.stopPropagation(),this.closeTableToolbarMenus();try{e.action()}finally{this.hideTableToolbar()}}),i.appendChild(t)}),n.addEventListener("click",e=>{e.stopPropagation(),o.classList.contains("rtb-table-toolbar-dropdown-open")?(this.closeTableToolbarMenus(),this.focusTableToolbarControl(this.getTableToolbarControls().indexOf(n))):this.openTableToolbarMenu(o,0)}),o.append(n,i),this.tableToolbar.appendChild(o)};renderTableToolbar=()=>{this.tableToolbar.replaceChildren(),this.addContextToolbarButton({label:"Edit Table",icon:"Edit",action:()=>this.openTableDialogForElement(this._tableToolbarTable)}),this.addContextToolbarDivider(),this.addContextToolbarDropdown("Insert",[{label:"Row Above",icon:"ArrowUp",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertRowAbove(e,t))},{label:"Row Below",icon:"ArrowDown",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertRowBelow(e,t))},{label:"Column Left",icon:"ArrowLeft",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertColumnLeft(e,t))},{label:"Column Right",icon:"ArrowRight",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.insertColumnRight(e,t))}]),this.addContextToolbarDropdown("Align",[{label:"Left",icon:"Alignleft",action:()=>this.runTableToolbarAction((e,t)=>this.alignTableToolbarColumn(t,e,"left"),!0)},{label:"Right",icon:"Alignright",action:()=>this.runTableToolbarAction((e,t)=>this.alignTableToolbarColumn(t,e,"right"),!0)},{label:"Center",icon:"Aligncenter",action:()=>this.runTableToolbarAction((e,t)=>this.alignTableToolbarColumn(t,e,"center"),!0)}]),this.addContextToolbarDropdown("Remove",[{label:"Row",icon:"Delete",action:()=>this.runTableToolbarAction(e=>this.TableDialog.removeRow(e))},{label:"Column",icon:"Delete",action:()=>this.runTableToolbarAction((e,t)=>this.TableDialog.removeColumn(e,t))},{divider:!0},{label:"Table",icon:"Delete",action:()=>{const e=this._tableToolbarTable;this.hideTableToolbar(),this._removeContentElement(e)}}]),this.addContextToolbarDivider(),this.addContextToolbarButton({label:"View HTML",icon:"Code",action:()=>this._viewElementHtml(this._tableToolbarTable)})};renderContextToolbar=(e,t)=>{this.tableToolbar.replaceChildren();const o=t.filter(e=>!e.divider),n=o.find(e=>"View HTML"===e.label),i=o.filter(e=>e!==n);if(n&&1===i.length&&"Delete"===i[0].icon)this.addContextToolbarButton(n),this.addContextToolbarDivider(),this.addContextToolbarButton(i[0]);else if("text"===e){const e=i.filter(e=>"Paragraph"===e.label||e.label.startsWith("Heading ")),t=i.find(e=>"Delete Element"===e.label),o=i.filter(e=>e.label.startsWith("Remove ")).map(e=>({...e,label:e.label.substring(7)}));o.length>0&&(this.addContextToolbarDropdown("Remove",o),this.addContextToolbarDivider()),this.addContextToolbarDropdown("Format",e),t&&(this.addContextToolbarDivider(),this.addContextToolbarButton(t))}else if("list"===e){const e=i.filter(e=>"Remove Bullet List"===e.label||"Remove Number List"===e.label),t=i.filter(t=>t.label.startsWith("Remove ")&&!e.includes(t));t.length>0&&(this.addContextToolbarDropdown("Remove",t.map(e=>({...e,label:e.label.replace(/^Remove /,"")}))),this.addContextToolbarDivider()),e.forEach((e,t)=>{t>0&&this.addContextToolbarDivider(),this.addContextToolbarButton(e)})}else"link"===e?i.forEach((e,t)=>{1===t&&this.addContextToolbarDivider(),this.addContextToolbarButton(e)}):i.forEach((e,t)=>{t>0&&this.addContextToolbarDivider(),this.addContextToolbarButton(e)});!n||1===i.length&&"Delete"===i[0].icon||(this.tableToolbar.childElementCount>0&&this.addContextToolbarDivider(),this.addContextToolbarButton(n))};getTableToolbarControls=()=>this.tableToolbar?Array.from(this.tableToolbar.querySelectorAll(":scope > .rtb-table-toolbar-button, :scope > .rtb-table-toolbar-dropdown > .rtb-table-toolbar-button")):[];focusTableToolbarControl=e=>{const t=this.getTableToolbarControls();if(0===t.length)return;const o=(e+t.length)%t.length;t.forEach(e=>e.classList.remove("active")),t[o].classList.add("active"),t[o].focus({preventScroll:!0})};focusTableToolbarMenuItem=(e,t)=>{const o=Array.from(e?.querySelectorAll('button[role="menuitem"]')||[]);if(0===o.length)return;const n=(t+o.length)%o.length;this.getTableToolbarControls().forEach(e=>e.classList.remove("active")),o.forEach(e=>e.classList.remove("active")),o[n].classList.add("active"),o[n].focus({preventScroll:!0})};openTableToolbarMenu=(e,t=0)=>{if(!e)return;this.closeTableToolbarMenus(),e.classList.add("rtb-table-toolbar-dropdown-open"),e.querySelector(":scope > button")?.setAttribute("aria-expanded","true");const o=e.querySelector(".rtb-table-toolbar-menu");requestAnimationFrame(()=>this.focusTableToolbarMenuItem(o,t))};restoreTableToolbarSelection=()=>{this.getTableToolbarControls().forEach(e=>e.classList.remove("active"));const e=this.Utilities.getSelection()||window.getSelection(),t=this._tableToolbarReturnRange;if(this._tableToolbarReturnRange=null,e&&t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))return e.removeAllRanges(),e.addRange(t),void this.content.focus({preventScroll:!0});const o=this.getTableToolbarCell();"table"===this._contextToolbarType&&o?this.TableDialog.selectCell(o):this.content.focus({preventScroll:!0})};toggleTableToolbarFocus=()=>{const e=this.shadowRoot.activeElement;if(this.tableToolbar.classList.contains("rtb-table-toolbar-visible")){if(e&&this.tableToolbar.contains(e)){const e=this._tableToolbarTable;this.closeTableToolbarMenus(),this.restoreTableToolbarSelection();e===this.selectedResizeImage&&this.imageResizeOverlay.classList.contains("rtb-image-resize-visible")||e===this.selectedResizeMedia&&this.mediaResizeOverlay.classList.contains("rtb-media-resize-visible")?(this._contextToolbarHiddenByShortcutElement=null,this.positionTableToolbar()):(this._contextToolbarHiddenByShortcutElement=e,this.hideTableToolbar())}else{const e=this.Utilities.getSelection();e?.rangeCount>0&&(this._tableToolbarReturnRange=e.getRangeAt(0).cloneRange()),this.closeTableToolbarMenus(),this.focusTableToolbarControl(0)}return!0}const t=this.Utilities.getSelection();let o=this._tableToolbarTable;if(!o||!this.content.contains(o)){const e=this.selectedResizeImage||this.selectedResizeMedia||this.selectedResizeTable,n=t?.anchorNode?.nodeType===Node.ELEMENT_NODE?t.anchorNode:t?.anchorNode?.parentElement,i=this.getContextToolbarDescriptor(e?.isConnected?e:n);if(!i)return!1;this.displayContextToolbar(i),o=i.element}if(t?.rangeCount>0&&(this._tableToolbarReturnRange=t.getRangeAt(0).cloneRange()),"table"===this._contextToolbarType){const e=this.TableDialog.getCurrentCell(t)||this.getTableToolbarCell();this.showTableToolbar(o,e)}return this.closeTableToolbarMenus(),this.focusTableToolbarControl(0),!0};getTopLevelEditorChild=e=>{let t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement;if(!t||!this.content.contains(t))return null;for(;t.parentElement&&t.parentElement!==this.content;)t=t.parentElement;return t.parentElement===this.content?t:null};getAdjacentEditorChild=(e,t)=>{let o="down"===t?e?.nextSibling:e?.previousSibling;for(;o;){if(o.nodeType===Node.ELEMENT_NODE)return o;if(o.nodeType===Node.TEXT_NODE&&""!==o.textContent.trim())return o;o="down"===t?o.nextSibling:o.previousSibling}return null};getMediaNavigationElement=(e,t)=>{if(!(e instanceof Element))return null;if(["IMG","VIDEO","OBJECT"].includes(e.tagName))return e;const o=Array.from(e.querySelectorAll("img, video, object"));return"down"===t?o[0]||null:o[o.length-1]||null};selectMediaForKeyboardNavigation=e=>!(!e||!this.content.contains(e))&&(this.content.focus({preventScroll:!0}),this.showObjectResizeHandles(e),!0);placeCaretInEditorChild=(e,t)=>{if(!e||!this.content.contains(e))return!1;const o=this.Utilities.getSelection()||window.getSelection();if(!o)return!1;this.hideImageResizeHandles(),this.hideMediaResizeHandles(),"element"===this._contextToolbarType&&this.hideTableToolbar();const n=document.createRange();return e.nodeType===Node.TEXT_NODE?n.setStart(e,"down"===t?0:e.textContent.length):(n.selectNodeContents(e),n.collapse("down"===t)),o.removeAllRanges(),o.addRange(n),this.content.focus({preventScroll:!0}),!0};isCaretAtEditorChildBoundary=(e,t,o)=>{if(!e?.isCollapsed||0===e.rangeCount||!t)return!1;const n=e.getRangeAt(0),i=document.createRange();try{i.selectNodeContents(t),"down"===o?i.setStart(n.startContainer,n.startOffset):i.setEnd(n.startContainer,n.startOffset)}catch{return!1}const r=i.cloneContents();return""===r.textContent.replace(/\u200B/g,"").trim()&&!r.querySelector("img, video, object")};isCaretOnEditorChildEdgeLine=(e,t,o)=>{if(!e?.isCollapsed||0===e.rangeCount||!t?.getBoundingClientRect)return!1;const n=e.getRangeAt(0).cloneRange();n.collapse(!0);const i=n.getClientRects()[0]||n.getBoundingClientRect(),r=t.getBoundingClientRect();if(!i||!i.width&&!i.height)return!1;const s=Math.max(i.height,16);return"down"===o?i.bottom>=r.bottom-s:i.top<=r.top+s};getMediaAdjacentToCaret=(e,t,o)=>{if(!e?.isCollapsed||0===e.rangeCount||!t)return null;const n=e.getRangeAt(0),i=Array.from(t.querySelectorAll?.("img, video, object")||[]);["IMG","VIDEO","OBJECT"].includes(t.tagName)&&i.unshift(t),"up"===o&&i.reverse();for(const e of i){const t=document.createRange();try{if("down"===o){if(t.setStart(n.startContainer,n.startOffset),t.setEndBefore(e),t.startContainer!==n.startContainer||t.startOffset!==n.startOffset)continue}else if(t.setStartAfter(e),t.setEnd(n.startContainer,n.startOffset),t.endContainer!==n.startContainer||t.endOffset!==n.startOffset)continue}catch{continue}const i=t.cloneContents();if(""===i.textContent.replace(/\u200B/g,"").trim()&&!i.querySelector("img, video, object"))return e}return null};placeCaretBesideSelectedMedia=(e,t,o)=>{if(!e||!t)return!1;const n=document.createRange();try{n.selectNodeContents(t),"down"===o?n.setStartAfter(e):n.setEndBefore(e)}catch{return!1}if(""===n.cloneContents().textContent.replace(/\u200B/g,"").trim())return!1;const i=this.Utilities.getSelection()||window.getSelection();if(!i)return!1;const r=document.createRange();return"down"===o?r.setStartAfter(e):r.setStartBefore(e),r.collapse(!0),i.removeAllRanges(),i.addRange(r),this.hideImageResizeHandles(),this.hideMediaResizeHandles(),"element"===this._contextToolbarType&&this.hideTableToolbar(),this.content.focus({preventScroll:!0}),!0};scheduleSkippedMediaNavigation=e=>{if(!["ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)return;const t=this.Utilities.getSelection();if(!t?.isCollapsed||0===t.rangeCount)return;const o=t.getRangeAt(0).cloneRange(),n="ArrowDown"===e.key?"down":"up";requestAnimationFrame(()=>{if(this.selectedResizeImage||this.selectedResizeMedia||this.selectedResizeTable)return;const e=this.Utilities.getSelection();if(!e?.isCollapsed||0===e.rangeCount)return;const t=e.getRangeAt(0).cloneRange();if(!this.content.contains(o.startContainer)||!this.content.contains(t.startContainer))return;const i=document.createRange();try{"down"===n?(i.setStart(o.startContainer,o.startOffset),i.setEnd(t.startContainer,t.startOffset)):(i.setStart(t.startContainer,t.startOffset),i.setEnd(o.startContainer,o.startOffset))}catch{return}const r=i.cloneContents();if(0===Array.from(r.querySelectorAll("object, video")).length)return;const s=Array.from(this.content.querySelectorAll("object, video")),l=("down"===n?s:s.reverse()).find(e=>i.intersectsNode(e));l&&this.selectMediaForKeyboardNavigation(l)})};navigateAccessibleMedia=e=>{if(!["ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)return!1;const t="ArrowDown"===e.key?"down":"up",o=this.selectedResizeImage||this.selectedResizeMedia;let n;if(o?.isConnected&&this.content.contains(o)){n=this.getTopLevelEditorChild(o);const i=Array.from(n?.querySelectorAll?.("img, video, object")||[]);["IMG","VIDEO","OBJECT"].includes(n?.tagName)&&i.unshift(n);const r=i.indexOf(o),s=i[r+("down"===t?1:-1)];if(s)return e.preventDefault(),this.selectMediaForKeyboardNavigation(s);if(this.placeCaretBesideSelectedMedia(o,n,t))return e.preventDefault(),!0}else{const o=this.Utilities.getSelection();if(!o?.isCollapsed)return!1;if(this.TableDialog.getCurrentCell(o))return!1;n=this.getTopLevelEditorChild(o.anchorNode);const i=this.getMediaAdjacentToCaret(o,n,t);if(i)return e.preventDefault(),this.selectMediaForKeyboardNavigation(i);if(!this.isCaretAtEditorChildBoundary(o,n,t)&&!this.isCaretOnEditorChildEdgeLine(o,n,t))return!1}const i=this.getAdjacentEditorChild(n,t);if(!i)return!1;const r=this.getMediaNavigationElement(i,t);return e.preventDefault(),r?this.selectMediaForKeyboardNavigation(r):this.placeCaretInEditorChild(i,t)};navigateIntoAdjacentTable=e=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)return!1;const t=this.Utilities.getSelection();if(!t?.isCollapsed||this.TableDialog.getCurrentCell(t))return!1;const o="ArrowRight"===e.key||"ArrowDown"===e.key,n=this.getTopLevelEditorChild(t.anchorNode);if(!n||!this.isCaretAtEditorChildBoundary(t,n,o?"down":"up"))return!1;const i=this.getAdjacentEditorChild(n,o?"down":"up");if(!(i instanceof Element)||"TABLE"!==i.tagName)return!1;const r=Array.from(i.querySelectorAll("td, th")),s=o?r[0]:r[r.length-1];return!!s&&(e.preventDefault(),this.markTableKeyboardNavigation(),this.TableDialog.selectCell(s,!o),!0)};markTableKeyboardNavigation=()=>{this._suppressTableToolbarForKeyboardNavigation=!0,clearTimeout(this._tableKeyboardNavigationTimer),this._tableKeyboardNavigationTimer=setTimeout(()=>{this._suppressTableToolbarForKeyboardNavigation=!1},1e3)};handleTableToolbarKeydown=e=>{if(e.altKey&&!e.ctrlKey&&!e.metaKey&&"o"===e.key.toLowerCase())return void(this.toggleTableToolbarFocus()&&(e.preventDefault(),e.stopPropagation()));const t=e.target;if(!(t instanceof Element&&this.tableToolbar.contains(t)))return;const o=t.closest(".rtb-table-toolbar-menu");if(o){const n=Array.from(o.querySelectorAll('button[role="menuitem"]')),i=Math.max(0,n.indexOf(t));if("ArrowDown"===e.key||"ArrowUp"===e.key)if(e.preventDefault(),"ArrowUp"===e.key&&0===i){const e=o.closest(".rtb-table-toolbar-dropdown")?.querySelector(":scope > button");this.closeTableToolbarMenus(),e?.classList.add("active"),e?.focus({preventScroll:!0})}else this.focusTableToolbarMenuItem(o,i+("ArrowDown"===e.key?1:-1));else if("Home"===e.key||"End"===e.key)e.preventDefault(),this.focusTableToolbarMenuItem(o,"Home"===e.key?0:n.length-1);else if("Escape"===e.key||"ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault();const t=o.closest(".rtb-table-toolbar-dropdown"),n=t?.querySelector(":scope > button");if(this.closeTableToolbarMenus(),"Escape"===e.key)n?.classList.add("active"),n?.focus({preventScroll:!0});else{const t=this.getTableToolbarControls().indexOf(n);this.focusTableToolbarControl(t+("ArrowRight"===e.key?1:-1))}}return}const n=this.getTableToolbarControls().indexOf(t);if(!(n<0))if("ArrowLeft"===e.key||"ArrowRight"===e.key)e.preventDefault(),this.closeTableToolbarMenus(),this.focusTableToolbarControl(n+("ArrowRight"===e.key?1:-1));else if("ArrowDown"===e.key||"ArrowUp"===e.key){const o=t.closest(".rtb-table-toolbar-dropdown");if(!o)return;e.preventDefault();const n=o.querySelectorAll('button[role="menuitem"]').length;this.openTableToolbarMenu(o,"ArrowUp"===e.key?n-1:0)}else if("Escape"===e.key){e.preventDefault();const t=this._tableToolbarTable;this.restoreTableToolbarSelection();t===this.selectedResizeImage&&this.imageResizeOverlay.classList.contains("rtb-image-resize-visible")||t===this.selectedResizeMedia&&this.mediaResizeOverlay.classList.contains("rtb-media-resize-visible")||(this._contextToolbarHiddenByShortcutElement=t,this.hideTableToolbar())}};getTableToolbarCell=()=>{if("table"!==this._contextToolbarType)return null;const e=this._tableToolbarTable;if(!e)return null;const t=this.TableDialog.getCurrentCell(this.Utilities.getSelection());return t&&e.contains(t)?t:this._tableToolbarCell?.isConnected&&e.contains(this._tableToolbarCell)?this._tableToolbarCell:e.querySelector("td, th")};runTableToolbarAction=(e,t=!1)=>{const o=this._tableToolbarTable,n=this.getTableToolbarCell();o&&o.isConnected&&n&&(this._tableToolbarCell=n,e(n,o),this.content.dispatchEvent(new Event("input",{bubbles:!0})),t&&this.restoreTableToolbarSelection(),this.positionTableToolbar())};alignTableToolbarColumn=(e,t,o)=>{const n=this.Utilities.getSelection()||window.getSelection();if((n&&!n.isCollapsed?(n.anchorNode?.nodeType===Node.ELEMENT_NODE?n.anchorNode:n.anchorNode?.parentElement)?.closest?.("td, th"):null)===t)return void(t.style.textAlign=o);const i=t.cellIndex;for(const t of e.rows)t.cells[i]&&(t.cells[i].style.textAlign=o)};showTableToolbar=(e,t=null)=>{e&&"TABLE"===e.tagName&&this.content.contains(e)&&(this._tableToolbarTable===e&&"table"===this._contextToolbarType||(this._tableToolbarBelow=!1),"table"!==this._contextToolbarType&&this.renderTableToolbar(),this._contextToolbarType="table",this._tableToolbarTable=e,this._contextToolbarSourceTarget=t||e,t&&e.contains(t)&&(this._tableToolbarCell=t),clearTimeout(this._hideTableToolbarResetTimer),this.tableToolbar.classList.add("rtb-table-toolbar-visible"),this.tableToolbar.setAttribute("aria-hidden","false"),this.observeContextToolbarElement(e),this.positionTableToolbar(),requestAnimationFrame(this.positionTableToolbar))};showContextToolbar=(e,t,o)=>{if(!e||!this.content.contains(e))return;const n=this.Utilities.getSelection();n?.rangeCount>0&&(this._tableToolbarReturnRange=n.getRangeAt(0).cloneRange()),this._contextToolbarType=t,this._tableToolbarTable=e,this._tableToolbarCell=null,this._tableToolbarBelow=!1,this.renderContextToolbar(t,o),clearTimeout(this._hideTableToolbarResetTimer),this.tableToolbar.classList.add("rtb-table-toolbar-visible"),this.tableToolbar.setAttribute("aria-hidden","false"),this.observeContextToolbarElement(e),this.positionTableToolbar(),requestAnimationFrame(this.positionTableToolbar)};refreshContextToolbarAfterAction=()=>{if(!this._tableToolbarTable?.isConnected)return void this.hideTableToolbar();if("table"===this._contextToolbarType)return void this.positionTableToolbar();const e=this.Utilities.getSelection(),t=e?.anchorNode?.nodeType===Node.ELEMENT_NODE?e.anchorNode:e?.anchorNode?.parentElement,o=t&&this.content.contains(t)?t:this._contextToolbarSourceTarget,n=this.getContextToolbarDescriptor(o);n?this.displayContextToolbar(n):this.hideTableToolbar()};observeContextToolbarElement=e=>{window.ResizeObserver&&(this._contextToolbarResizeObserver??=new ResizeObserver(this.positionTableToolbar),this._contextToolbarResizeObserver.disconnect(),this._contextToolbarResizeObserver.observe(e))};hideTableToolbar=()=>{this.closeTableToolbarMenus(),this._contextToolbarResizeObserver?.disconnect(),this._tableToolbarTable=null,this._tableToolbarCell=null,this._contextToolbarSourceTarget=null,this._contextToolbarPositionElement=null,this._contextToolbarPointerAnchor=null,this._contextToolbarType=null,this._tableToolbarBelow=!1,this.tableToolbar.classList.remove("rtb-table-toolbar-visible"),this.tableToolbar.setAttribute("aria-hidden","true"),clearTimeout(this._hideTableToolbarResetTimer),this._hideTableToolbarResetTimer=setTimeout(()=>{this.tableToolbar.classList.contains("rtb-table-toolbar-visible")||(this.tableToolbar.style.left="0px",this.tableToolbar.style.top="0px")},100)};closeTableToolbarMenus=()=>{this.tableToolbar?.querySelectorAll(".rtb-table-toolbar-dropdown-open").forEach(e=>{e.classList.remove("rtb-table-toolbar-dropdown-open"),e.querySelector(":scope > button")?.setAttribute("aria-expanded","false")}),this.tableToolbar?.querySelectorAll(".rtb-table-toolbar-menu .active").forEach(e=>{e.classList.remove("active")})};positionTableToolbar=()=>{const e=this._tableToolbarTable;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideTableToolbar();const t=["IMG","VIDEO","OBJECT"].includes(e.tagName);let o;if(this._contextToolbarPointerAnchor){const{clientX:e,clientY:t}=this._contextToolbarPointerAnchor;o={left:e,right:e,top:t,bottom:t,width:0,height:0}}else if(t)o=e.getBoundingClientRect();else{const t=this.Utilities.getSelection();let n=null;if(t?.rangeCount>0){const e=t.getRangeAt(0).cloneRange();e.collapse(!0),n=e.getBoundingClientRect(),n.width||n.height||(n=e.getClientRects()[0]||null)}const i=this._contextToolbarPositionElement?.isConnected?this._contextToolbarPositionElement:e;o=n||i.getBoundingClientRect()}const n=this.contentContainer.getBoundingClientRect(),i=this.tableToolbar.getBoundingClientRect(),r=this.tableToolbar.querySelector(".rtb-table-toolbar-dropdown-open .rtb-table-toolbar-menu"),s=r?Math.max(0,r.getBoundingClientRect().right-i.right):0,l=o.left-n.left+this.contentContainer.scrollLeft,a=o.top-n.top+this.contentContainer.scrollTop,c=this.contentContainer.scrollLeft+4,d=this.contentContainer.scrollLeft+this.contentContainer.clientWidth-i.width-s-4,h=t&&!this._contextToolbarPointerAnchor?l+(o.width-i.width)/2:l,b=o.top-n.top,u="table"===this._contextToolbarType?12:6;this._tableToolbarBelow=b<i.height+u,this.tableToolbar.style.left=`${Math.max(c,Math.min(h,d))}px`,this.tableToolbar.style.top=this._tableToolbarBelow?`${a+Math.max(o.height,t?0:16)+u}px`:a-i.height-u+"px"};syncTableToolbarWithSelection=()=>{if(!this.EditMode)return void this.hideTableToolbar();const e=this.Utilities.getSelection(),t=e?.anchorNode?.nodeType===Node.ELEMENT_NODE?e.anchorNode:e?.anchorNode?.parentElement,o=this.selectedResizeImage||this.selectedResizeMedia;if(o?.isConnected&&this.content.contains(o))return this._contextToolbarHiddenByShortcutElement=null,void(o===this._tableToolbarTable&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.showPersistentContextToolbar(o));const n=this.TableDialog.getCurrentCell(e),i=n?.closest("table");if(i&&this.content.contains(i))return this._suppressTableToolbarForKeyboardNavigation?void this.hideTableToolbar():void("table"===this._contextToolbarType&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.hideTableToolbar());const r=this.getPersistentContextElement(t);if(r)return"TABLE"===r.tagName&&t?.closest?.("caption")?void this.hideTableToolbar():"BLOCKQUOTE"===r.tagName||"PRE"===r.tagName?void(r===this._tableToolbarTable&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.tableToolbar.contains(this.shadowRoot.activeElement)||this.hideTableToolbar()):void(r!==this._contextToolbarHiddenByShortcutElement&&(r===this._tableToolbarTable&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")?this.positionTableToolbar():this.displayContextToolbar(this.getContextToolbarDescriptor(t))));this._contextToolbarType&&"table"!==this._contextToolbarType&&t&&this._tableToolbarTable?.contains(t)?this.positionTableToolbar():this.tableToolbar.contains(this.shadowRoot.activeElement)||this.hideTableToolbar()};hideTableResizeHandles=()=>{this._tableResizeState||(this._selectedTableResizeObserver?.disconnect(),this.selectedResizeTable=null,this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"))};showMediaResizeHandles=(e,t=!0)=>{e&&["OBJECT","VIDEO"].includes(e.tagName)&&this.content.contains(e)&&(this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.clearEditorTextSelection(),this.content.focus({preventScroll:!0}),this.selectedResizeMedia=e,this._updateStatusLinkFromNode(e),this.positionMediaResizeHandles(),this.mediaResizeOverlay.classList.add("rtb-media-resize-visible"),this.NodeManager.selectButtons(e),t&&this.showPersistentContextToolbar(e),this.observeSelectedResizeElement(e),requestAnimationFrame(()=>{this.positionMediaResizeHandles(),requestAnimationFrame(this.positionMediaResizeHandles)}))};hideMediaResizeHandles=()=>{this._mediaResizeState||(this._selectedResizeObserverElement===this.selectedResizeMedia&&(this._selectedResizeObserver?.disconnect(),this._selectedResizeObserverElement=null),this.selectedResizeMedia=null,this.mediaResizeOverlay.classList.remove("rtb-media-resize-visible"),this._hoveredStatusLink||this._updateStatusLinkFromNode(this.Utilities.getSelection()?.anchorNode))};positionMediaResizeHandles=()=>{const e=this.selectedResizeMedia;if(!e||!e.isConnected||!this.content.contains(e)||"none"===this.content.style.display)return void this.hideMediaResizeHandles();const t=e.getBoundingClientRect(),o=this.contentContainer.getBoundingClientRect();this.mediaResizeOverlay.style.left=`${t.left-o.left+this.contentContainer.scrollLeft}px`,this.mediaResizeOverlay.style.top=`${t.top-o.top+this.contentContainer.scrollTop}px`,this.mediaResizeOverlay.style.width=`${t.width}px`,this.mediaResizeOverlay.style.height=`${t.height}px`};observeSelectedResizeElement=e=>{window.ResizeObserver&&e&&(this._selectedResizeObserver??=new ResizeObserver(()=>{const e=this._selectedResizeObserverElement;this.selectedResizeImage===e&&this.positionImageResizeHandles(),this.selectedResizeMedia===e&&this.positionMediaResizeHandles(),this._tableToolbarTable===e&&this.positionTableToolbar()}),this._selectedResizeObserver.disconnect(),this._selectedResizeObserverElement=e,this._selectedResizeObserver.observe(e))};hideObjectResizeHandles=e=>{e&&("IMG"===e.tagName?this.imageResizeOverlay.classList.remove("rtb-image-resize-visible"):"TABLE"===e.tagName?this.tableResizeOverlay.classList.remove("rtb-table-resize-visible"):["OBJECT","VIDEO"].includes(e.tagName)&&this.mediaResizeOverlay.classList.remove("rtb-media-resize-visible"))};showObjectResizeHandles=(e,t=!0)=>{e&&e.isConnected&&this.content.contains(e)&&("IMG"===e.tagName?this.showImageResizeHandles(e,t):"TABLE"===e.tagName?this.showTableResizeHandles(e):["OBJECT","VIDEO"].includes(e.tagName)&&this.showMediaResizeHandles(e,t))};updateObjectWithResizeHandles=(e,t)=>{this.hideObjectResizeHandles(e);try{t()}finally{this.showObjectResizeHandles(e)}};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(),o=this.contentContainer.getBoundingClientRect();this.tableResizeOverlay.style.left=`${t.left-o.left+this.contentContainer.scrollLeft}px`,this.tableResizeOverlay.style.top=`${t.top-o.top+this.contentContainer.scrollTop}px`,this.tableResizeOverlay.style.width=`${t.width}px`,this.tableResizeOverlay.style.height=`${t.height}px`};startTableResize=e=>{const t=this.selectedResizeTable,o=e.currentTarget.dataset.direction;if(!t||!o)return;e.preventDefault(),e.stopPropagation();const n=t.getBoundingClientRect();this._tableResizeState={table:t,direction:o,startX:e.clientX,startY:e.clientY,startWidth:n.width,startHeight:n.height},e.currentTarget.setPointerCapture(e.pointerId),this.tableResizeOverlay.classList.add("rtb-table-resizing")};resizeSelectedTable=e=>{const t=this._tableResizeState;if(!t)return;e.preventDefault();const o=e.clientX-t.startX,n=e.clientY-t.startY,i=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(i&&r){const e=t.direction.includes("w")?-o:o,i=t.direction.includes("n")?-n:n,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+i)/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(i){const e=t.direction.includes("w")?-o:o;t.table.style.width=`${Math.max(1,Math.round(t.startWidth+e))}px`}else if(r){const e=t.direction.includes("n")?-n:n;t.table.style.height=`${Math.max(1,Math.round(t.startHeight+e))}px`}this.positionTableResizeHandles(),this.positionTableToolbar()};finishTableResize=()=>{this._tableResizeState&&(this._tableResizeState=null,this.tableResizeOverlay.classList.remove("rtb-table-resizing"),this.showObjectResizeHandles(this.selectedResizeTable))};getTableCellResizeEdge=e=>{const t=e.target instanceof Element?e.target.closest("td, th"):null,o=t?.closest("table");if(!t||!o||!this.content.contains(o))return null;const n=t.getBoundingClientRect(),i=[],r=t.parentElement,s=r?.rowIndex??-1,l=t.cellIndex;i.push({axis:"column",index:l>0?l-1:l,direction:l>0?"e":"w",distance:Math.abs(e.clientX-n.left)}),r&&i.push({axis:"column",index:l,direction:"e",distance:Math.abs(e.clientX-n.right)}),s>=0&&i.push({axis:"row",index:s>0?s-1:s,direction:s>0?"s":"n",distance:Math.abs(e.clientY-n.top)}),s>=0&&i.push({axis:"row",index:s,direction:"s",distance:Math.abs(e.clientY-n.bottom)});const a=i.filter(e=>e.distance<=5),c=a.filter(e=>"row"===e.axis).sort((e,t)=>e.distance-t.distance)[0],d=a.filter(e=>"column"===e.axis).sort((e,t)=>e.distance-t.distance)[0],h=c&&(!d||c.distance<=d.distance)?c:d||a.sort((e,t)=>e.distance-t.distance)[0];return h?{...h,table:o}: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:o,axis:n,index:i,direction:r}=t;if("column"===n){const t=Array.from(o.rows).map(e=>e.cells[i]).filter(e=>e&&1===e.colSpan);if(0===t.length)return;const s=t[0].getBoundingClientRect().width,l=parseFloat(window.getComputedStyle(t[0]).width)||s;this._tableCellResizeState={axis:n,direction:r,table:o,cells:t,startPosition:e.clientX,startSize:s,startCssSize:l,startTableSize:o.getBoundingClientRect().width}}else if("row"===n){const t=o.rows[i];if(!t)return;this._tableCellResizeState={axis:n,direction:r,table:o,row:t,startPosition:e.clientY,startSize:t.getBoundingClientRect().height,startTableSize:o.getBoundingClientRect().height}}else{const t=o.getBoundingClientRect();this._tableCellResizeState={axis:n,direction:r,table:o,startPosition:"table-column"===n?e.clientX:e.clientY,startSize:"table-column"===n?t.width:t.height}}this.content.style.cursor="column"===n||"table-column"===n?"ew-resize":"ns-resize",this.content.setPointerCapture(e.pointerId)};resizeTableCellBoundary=e=>{const t=this._tableCellResizeState;if(t){if(e.preventDefault(),"column"===t.axis){const o=e.clientX-t.startPosition,n=Math.max(1,Math.round(t.startSize+("w"===t.direction?-o:o)))-t.startSize,i=Math.max(0,t.startCssSize+n);t.cells.forEach(e=>{e.style.width=`${i}px`}),t.table.style.width=`${Math.max(1,Math.round(t.startTableSize+n))}px`,this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else if("row"===t.axis){const o=e.clientY-t.startPosition,n=Math.max(1,Math.round(t.startSize+("n"===t.direction?-o:o))),i=n-t.startSize;t.row.style.height=`${n}px`,t.table.style.height=`${Math.max(1,Math.round(t.startTableSize+i))}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}else if("table-column"===t.axis){const o=e.clientX-t.startPosition,n=Math.max(1,Math.round(t.startSize+("w"===t.direction?-o:o)));t.table.style.width=`${n}px`,this.content.style.cursor="ew-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ew-resize")}else{const o=e.clientY-t.startPosition,n=Math.max(1,Math.round(t.startSize+("n"===t.direction?-o:o)));t.table.style.height=`${n}px`,this.content.style.cursor="ns-resize",this.content.style.setProperty("--rtb-table-cell-cursor","ns-resize")}this.selectedResizeTable===t.table&&this.positionTableResizeHandles(),this._tableToolbarTable===t.table&&this.positionTableToolbar()}};finishTableCellResize=()=>{this._tableCellResizeState&&(this._tableCellResizeState=null,this._tableCellResizeEdge=null,this.content.style.cursor="",this.content.style.removeProperty("--rtb-table-cell-cursor"),this.showObjectResizeHandles(this.selectedResizeTable))};prepareTableCellInput=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return void(this._tableCellInputState=null);const t=e.anchorNode instanceof Element?e.anchorNode:e.anchorNode?.parentElement,o=t?.closest("td, th"),n=o?.closest("table");if(!o||!n||!this.content.contains(n))return void(this._tableCellInputState=null);const i=o.cellIndex,r=Array.from(n.rows).map(e=>e.cells[i]).filter(e=>e&&1===e.colSpan);if(0===r.length)return void(this._tableCellInputState=null);const s=o.getBoundingClientRect().width,l=parseFloat(window.getComputedStyle(o).width)||s,a=n.getBoundingClientRect().width;r.forEach(e=>{e.style.width=`${l}px`}),n.style.width=`${a}px`,this._tableCellInputState={cell:o,cells:r,table:n,cellWidth:s,cellCssWidth:l,tableWidth:a}};resizeTableCellForInput=()=>{const e=this._tableCellInputState;if(this._tableCellInputState=null,!e||!e.cell.isConnected||!e.table.isConnected)return;const t=window.getComputedStyle(e.cell),o=(this._tableCellMeasureCanvas||(this._tableCellMeasureCanvas=document.createElement("canvas"))).getContext("2d");if(!o)return;o.font=`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;const n=(e.cell.textContent||"").split(/\r?\n/).reduce((e,t)=>Math.max(e,o.measureText(t).width),0),i=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderLeftWidth)+parseFloat(t.borderRightWidth),r=Math.ceil(n+i);if(r<=e.cellWidth)return;const s=r-e.cellWidth,l=e.cellCssWidth+s;e.cells.forEach(e=>{e.style.width=`${l}px`}),e.table.style.width=`${e.tableWidth+s}px`};hideTableResizeHandlesForTyping=e=>{if(!["insertText","insertCompositionText","insertReplacementText"].includes(e.inputType))return;const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return;const o=t.anchorNode instanceof Element?t.anchorNode:t.anchorNode?.parentElement,n=o?.closest("td, th");n&&this.content.contains(n)&&(this._tableResizeHandlesHiddenForCell=n,this.hideTableResizeHandles())};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(),o=this.contentContainer.getBoundingClientRect();this.imageResizeOverlay.style.left=`${t.left-o.left+this.contentContainer.scrollLeft}px`,this.imageResizeOverlay.style.top=`${t.top-o.top+this.contentContainer.scrollTop}px`,this.imageResizeOverlay.style.width=`${t.width}px`,this.imageResizeOverlay.style.height=`${t.height}px`};startImageResize=e=>{const t=this.selectedResizeImage,o=e.currentTarget.dataset.direction;if(!t||!o)return;e.preventDefault(),e.stopPropagation();const n=t.getBoundingClientRect();this._imageResizeState={image:t,direction:o,startX:e.clientX,startY:e.clientY,startWidth:n.width,startHeight:n.height},e.currentTarget.setPointerCapture(e.pointerId),this.imageResizeOverlay.classList.add("rtb-image-resizing")};resizeSelectedImage=e=>{const t=this._imageResizeState;if(!t)return;e.preventDefault();const o=e.clientX-t.startX,n=e.clientY-t.startY,i=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(i&&r){const e=t.direction.includes("w")?-o:o,i=t.direction.includes("n")?-n:n,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+i)/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(i){const e=t.direction.includes("w")?-o:o;t.image.width=Math.max(1,Math.round(t.startWidth+e))}else if(r){const e=t.direction.includes("n")?-n:n;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.showObjectResizeHandles(this.selectedResizeImage))};startMediaResize=e=>{const t=this.selectedResizeMedia,o=e.currentTarget.dataset.direction;if(!t||!o)return;e.preventDefault(),e.stopPropagation();const n=t.getBoundingClientRect();this._mediaResizeState={element:t,direction:o,startX:e.clientX,startY:e.clientY,startWidth:n.width,startHeight:n.height},e.currentTarget.setPointerCapture(e.pointerId),this.mediaResizeOverlay.classList.add("rtb-media-resizing")};resizeSelectedMedia=e=>{const t=this._mediaResizeState;if(!t)return;e.preventDefault();const o=e.clientX-t.startX,n=e.clientY-t.startY,i=t.direction.includes("e")||t.direction.includes("w"),r=t.direction.includes("n")||t.direction.includes("s");if(i&&r){const e=t.direction.includes("w")?-o:o,i=t.direction.includes("n")?-n:n,r=(t.startWidth+e)/t.startWidth,s=(t.startHeight+i)/t.startHeight,l=Math.max(1/t.startWidth,1/t.startHeight,Math.abs(r-1)>=Math.abs(s-1)?r:s);t.element.width=Math.max(1,Math.round(t.startWidth*l)),t.element.height=Math.max(1,Math.round(t.startHeight*l))}else if(i){const e=t.direction.includes("w")?-o:o;t.element.width=Math.max(1,Math.round(t.startWidth+e))}else if(r){const e=t.direction.includes("n")?-n:n;t.element.height=Math.max(1,Math.round(t.startHeight+e))}this.positionMediaResizeHandles()};finishMediaResize=()=>{this._mediaResizeState&&(this._mediaResizeState=null,this.mediaResizeOverlay.classList.remove("rtb-media-resizing"),this.showObjectResizeHandles(this.selectedResizeMedia))};alignSelectedResizeMedia=e=>{const t=this.selectedResizeMedia;if(!t||!this.content.contains(t))return!1;if("VIDEO"===t.tagName&&["alignleft","aligncenter","alignright"].includes(e))return this.updateObjectWithResizeHandles(t,()=>{t.style.display="block",t.style.removeProperty("float"),"aligncenter"===e?(t.style.marginLeft="auto",t.style.marginRight="auto"):"alignright"===e?(t.style.marginLeft="auto",t.style.marginRight="0"):(t.style.marginLeft="0",t.style.marginRight="auto")}),this.clearResizeMediaRange(),this.NodeManager.selectButtons(t),!0;const o=this.selectResizeMediaRange();return this.updateObjectWithResizeHandles(t,()=>this.NodeManager.updateNode(e)),o.removeAllRanges(),this.NodeManager.selectButtons(t),!0};selectResizeMediaRange=()=>{const e=this.selectedResizeMedia;if(!e||!this.content.contains(e))return null;const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const o=document.createRange();return o.selectNode(e),t.removeAllRanges(),t.addRange(o),t};clearResizeMediaRange=()=>{if(!this.selectedResizeMedia||!this.content.contains(this.selectedResizeMedia))return;const e=this.Utilities.getSelection()||window.getSelection();e?.removeAllRanges()};toggleListForSelectedResizeMedia=e=>{const t=this.selectedResizeMedia;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=t.closest("ol, ul");if(o&&this.content.contains(o))if(o.nodeName===e){const e=t.closest("li");o.parentNode.insertBefore(t,o.nextSibling),e?.remove(),o.querySelector("li")||o.remove()}else{const t=document.createElement(e);for(;o.firstChild;)t.appendChild(o.firstChild);o.replaceWith(t)}else{const o=document.createElement(e),n=document.createElement("li");t.replaceWith(o),n.appendChild(t),o.appendChild(n)}}),this.clearResizeMediaRange(),!0)};indentSelectedResizeMedia=e=>{const t=this.selectedResizeMedia;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=parseFloat(window.getComputedStyle(t).marginLeft)||0,n=e?o+40:Math.max(0,o-40);n>0?t.style.marginLeft=`${n}px`:(t.style.removeProperty("margin-left"),0===t.style.length&&t.removeAttribute("style"))}),!0)};alignSelectedResizeImage=e=>{const t=this.selectedResizeImage;return!(!t||!this.content.contains(t))&&(this.selectResizeImageRange(),this.updateObjectWithResizeHandles(t,()=>this.NodeManager.updateNode(e)),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");this.content.insertBefore(t,e),t.appendChild(e)}const t=this.Utilities.getSelection()||window.getSelection();if(!t)return null;const o=document.createRange();return o.selectNode(e),t.removeAllRanges(),t.addRange(o),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;return!(!t||!this.content.contains(t))&&(this.selectResizeImageRange(),this.updateObjectWithResizeHandles(t,()=>{const o=t.closest("ol, ul");if(o&&this.content.contains(o))this.ListProvider.addlist(e);else{const o=t.parentElement;if(!o||o===this.content)return;const n=document.createElement(e),i=document.createElement("li");for(;o.firstChild;)i.appendChild(o.firstChild);n.appendChild(i),o.replaceWith(n),this.selectResizeImageRange()}}),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 o=document.createRange();return o.selectNode(e),t.removeAllRanges(),t.addRange(o),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,o=t?.closest("td, th");return!!o&&this.selectedResizeTable.contains(o)};alignSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>this.NodeManager.alignTable(t,e)),this.clearResizeTableRange(),this.NodeManager.selectButtons(t),!0)};toggleListForSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=t.closest("ol, ul");if(o&&this.content.contains(o))if(o.nodeName===e){const e=t.closest("li");o.parentNode.insertBefore(t,o.nextSibling),e?.remove(),o.querySelector("li")||o.remove()}else{const t=document.createElement(e);for(;o.firstChild;)t.appendChild(o.firstChild);o.replaceWith(t)}else{const o=document.createElement(e),n=document.createElement("li");t.replaceWith(o),n.appendChild(t),o.appendChild(n)}}),this.clearResizeTableRange(),!0)};indentSelectedResizeTable=e=>{const t=this.selectedResizeTable;return!(!t||!this.content.contains(t))&&(this.updateObjectWithResizeHandles(t,()=>{const o=parseFloat(window.getComputedStyle(t).marginLeft)||0,n=e?o+40:Math.max(0,o-40);n>0?t.style.marginLeft=`${n}px`:(t.style.removeProperty("margin-left"),0===t.style.length&&t.removeAttribute("style"))}),!0)};addEventListeners=()=>{document.addEventListener("keydown",this.recoverEditorTab,!0),this.shadowRoot.addEventListener("keydown",e=>{this.handleTableToolbarKeydown(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.rememberEditorSelection(),this.clearSettings(t.anchorNode),this._hoveredStatusLink||this._updateStatusLinkFromNode(t.anchorNode),this.scheduleCaretScrollIntoView())}),this.content.addEventListener("mouseover",e=>{const t=e.target instanceof Element?e.target.closest("a, img, blockquote, object, video"):null;t&&this.content.contains(t)&&(this._hoveredStatusLink=t,this._setStatusLink(this._getStatusLinkAddress(t)))}),this.content.addEventListener("mouseout",e=>{if(!this._hoveredStatusLink)return;if((e.relatedTarget instanceof Element?e.relatedTarget.closest("a, img, blockquote, object, video"):null)===this._hoveredStatusLink)return;this._hoveredStatusLink=null;const t=this.Utilities.getSelection();this._updateStatusLinkFromNode(t?.anchorNode)}),this.contentContainer.addEventListener("pointerdown",e=>{if("block"!==this.content.style.display)return;const t=e.target instanceof Element?e.target:null,o=t?.closest("img, object, video, source");if(o&&this.content.contains(o)){if("touch"===e.pointerType){const e="SOURCE"===o.tagName?o.closest("video"):o;e&&["OBJECT","VIDEO"].includes(e.tagName)&&this.showMediaResizeHandles(e)}return void e.preventDefault()}const n=this.content.getBoundingClientRect();if(!(e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom))return;const i=this.contentContainer.getBoundingClientRect(),r=this.contentContainer.offsetWidth-this.contentContainer.clientWidth,s=this.contentContainer.offsetHeight-this.contentContainer.clientHeight,l=r>0&&e.clientX>=i.right-r,a=s>0&&e.clientY>=i.bottom-s;l||a||(e.preventDefault(),this.content.focus({preventScroll:!0}))},!0),this.contentContainer.addEventListener("click",e=>{if("block"!==this.content.style.display)return;const t=this.content.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this.NodeManager.closeDropdowns()}),this.content.addEventListener("click",e=>{if(this.closeTableToolbarMenus(),"IMG"===e.target.tagName)this.showImageResizeHandles(e.target);else if("OBJECT"===e.target.tagName||"VIDEO"===e.target.tagName||"SOURCE"===e.target.tagName){const t="SOURCE"===e.target.tagName?e.target.closest("video"):e.target;this.showMediaResizeHandles(t)}else{this.hideImageResizeHandles(),this.hideMediaResizeHandles();const t=e.target instanceof Element?e.target.closest("table"):null;if(t&&this.content.contains(t)){const o=e.target.closest("td, th");"table"===this._contextToolbarType&&this.tableToolbar.classList.contains("rtb-table-toolbar-visible")&&this._tableToolbarCell&&o!==this._tableToolbarCell?this.hideTableToolbar():this._tableToolbarCell=o,o&&o===this._tableResizeHandlesHiddenForCell?this.hideTableResizeHandles():(this._tableResizeHandlesHiddenForCell=null,this.showTableResizeHandles(t))}else this._tableResizeHandlesHiddenForCell=null,this.hideTableResizeHandles()}"A"===e.target.tagName&&(e.preventDefault(),e.stopPropagation())}),this.content.addEventListener("click",e=>{const t=e.target.tagName;if("OBJECT"!==t){if("VIDEO"===t||"SOURCE"===t){e.preventDefault();const o="SOURCE"===t?e.target.closest("video"):e.target;this.showMediaResizeHandles(o)}}else this.showMediaResizeHandles(e.target)},!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(),e.target.src.startsWith("data")?this.openUploadImageDialogForElement(e.target):this.openImageDialogForElement(e.target);break;case"VIDEO":case"SOURCE":{e.preventDefault();const t="SOURCE"===e.target.tagName?e.target.closest("video"):e.target;t?this.openVideoDialogForElement(t):this.openVideoDialog();break}case"OBJECT":e.preventDefault(),this.openMediaDialogForElement(e.target);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 o=e.target.closest("blockquote");if(o&&this.content.contains(o))e.preventDefault(),this.openBlockQuoteDialogForElement(o);else{const e=this.Utilities.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const t=e.getRangeAt(0),o=t.endContainer;if(o.nodeType===Node.TEXT_NODE){const n=o.textContent;let i=t.endOffset;for(;i>0&&/\s/.test(n[i-1]);)i--;i!==t.endOffset&&(t.setEnd(o,i),e.removeAllRanges(),e.addRange(t))}}}break}}}),this.content.addEventListener("beforeinput",e=>{this.closeTableToolbarMenus(),("text"===this._contextToolbarType||"element"===this._contextToolbarType&&["BLOCKQUOTE","PRE"].includes(this._tableToolbarTable?.tagName))&&this.hideTableToolbar(),this.prepareTableCellInput(),this.hideTableResizeHandlesForTyping(e)}),this.content.addEventListener("input",e=>{this.resizeTableCellForInput(),this.scheduleResizeHandlePosition(),this.scheduleCaretScrollIntoView(),this._selectAllActive=!1,this.updateWordCount();const t=this.Utilities.getSelection(),o=t.getRangeAt(0).startContainer;if(o.nodeType===Node.TEXT_NODE&&"SPAN"===o.parentNode.tagName){const e=o.parentNode,n=e.parentNode;if(this.NodeManager.isFormatElement(n)){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;)n.insertBefore(e.firstChild,e);n.removeChild(e);const o=document.createRange();o.setStart(n.firstChild,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}}}),this.content.addEventListener("keydown",e=>{this.keyEvents(e),this.scheduleCaretScrollIntoView()}),this.content.addEventListener("keyup",()=>{this.scheduleCaretScrollIntoView()}),this.content.addEventListener("mouseup",()=>{this.scheduleCaretScrollIntoView()}),this.source.addEventListener("keydown",e=>{if("Escape"===e.key)return e.preventDefault(),void this.escapeEditor();"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&&"f"===e.key.toLowerCase()&&(e.preventDefault(),this.toggleEditorFullscreen()),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.mediaResizeOverlay.querySelectorAll(".rtb-media-resize-handle").forEach(e=>{e.addEventListener("pointerdown",this.startMediaResize)}),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.resizeSelectedMedia),document.addEventListener("pointermove",this.resizeTableCellBoundary),document.addEventListener("pointerup",this.finishImageResize),document.addEventListener("pointerup",this.finishTableResize),document.addEventListener("pointerup",this.finishMediaResize),document.addEventListener("pointerup",this.finishTableCellResize),document.addEventListener("pointercancel",this.finishImageResize),document.addEventListener("pointercancel",this.finishTableResize),document.addEventListener("pointercancel",this.finishMediaResize),document.addEventListener("pointercancel",this.finishTableCellResize),document.addEventListener("pointerdown",e=>{const t=e.composedPath(),o=t.find(e=>e instanceof Element&&e!==this.content&&this.content.contains(e)),n=this.getPersistentContextElement(o);if(!this._tableToolbarTable||t.includes(this._tableToolbarTable)||t.includes(this.tableToolbar)||n||this.hideTableToolbar(),!this.selectedResizeImage&&!this.selectedResizeTable&&!this.selectedResizeMedia||this._imageResizeState||this._tableResizeState||this._mediaResizeState)return;const i=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&&i.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)||"OBJECT"===this.selectedResizeMedia?.tagName&&t.some(e=>e instanceof Element&&"blazing-rich-text-embed-button"===e.id)||"VIDEO"===this.selectedResizeMedia?.tagName&&t.some(e=>e instanceof Element&&"blazing-rich-text-video-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.selectedResizeMedia||t.includes(this.selectedResizeMedia)||t.includes(this.mediaResizeOverlay)||this.hideMediaResizeHandles())}),this.contentContainer.addEventListener("scroll",this.positionImageResizeHandles),this.contentContainer.addEventListener("scroll",this.positionTableResizeHandles),this.contentContainer.addEventListener("scroll",this.positionMediaResizeHandles),this.contentContainer.addEventListener("scroll",this.positionTableToolbar),window.addEventListener("resize",this.positionImageResizeHandles),window.addEventListener("resize",this.positionTableResizeHandles),window.addEventListener("resize",this.positionMediaResizeHandles),window.addEventListener("resize",this.positionTableToolbar),document.addEventListener("selectionchange",this.syncTableToolbarWithSelection),this.content.addEventListener("input",this.positionTableToolbar);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"),[o,n]=this.findBar.querySelectorAll(".rtb-find-nav-btn"),i=this.findBar.querySelector(".rtb-find-close-btn");e.addEventListener("paste",t=>{t.preventDefault();const o=(t.clipboardData||window.clipboardData).getData("text").trim(),n=e.selectionStart,i=e.selectionEnd;e.value=e.value.substring(0,n)+o+e.value.substring(i),e.selectionStart=e.selectionEnd=n+o.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())}),o.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("mousedown",e=>e.preventDefault()),i.addEventListener("mousedown",e=>e.preventDefault()),o.addEventListener("click",()=>{this.findPrev(),e.focus({preventScroll:!0})}),n.addEventListener("click",()=>{this.findNext(),e.focus({preventScroll:!0})}),i.addEventListener("click",()=>this.closeFindBar()),this.content.addEventListener("pointerdown",e=>{this._selectAllActive=!1,this._lastPointerType=e.pointerType,this._suppressTableToolbarForKeyboardNavigation=!1,clearTimeout(this._tableKeyboardNavigationTimer),this.closeTableToolbarMenus(),("text"===this._contextToolbarType||"element"===this._contextToolbarType&&["BLOCKQUOTE","PRE"].includes(this._tableToolbarTable?.tagName))&&this.hideTableToolbar()}),this.content.addEventListener("contextmenu",e=>this.openEditorContextMenu(e),!0),this.content.addEventListener("paste",e=>{if(this.pasteTableValuesIntoCells(e))return;const t=new Set(this.content.querySelectorAll("table"));requestAnimationFrame(()=>{this.content.querySelectorAll("table").forEach(e=>{t.has(e)||this.moveTableOutsideParagraph(e)})});const o=e.clipboardData?.getData("text/html")||"";if(o){const e=document.createElement("template");e.innerHTML=o;const t=e.content.querySelector("img");t&&(this._imageClipboardHtml=t.outerHTML)}else{const t=Array.from(e.clipboardData?.items||[]).find(e=>e.type.startsWith("image/")),o=t?.getAsFile();if(o){const e=new FileReader;e.onload=()=>{const t=document.createElement("img");t.src=e.result,this._imageClipboardHtml=t.outerHTML},e.readAsDataURL(o)}}const n=e.clipboardData?.getData("text/plain")||"";n&&(e.preventDefault(),this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=n,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 o=Array.from(t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(e=>!e.disabled&&null!==e.offsetParent).map((e,t)=>({el:e,index:t,tabIndex:e.tabIndex})).sort((e,t)=>{const o=e.tabIndex>0,n=t.tabIndex>0;return o&&n?e.tabIndex-t.tabIndex||e.index-t.index:o?-1:n?1:e.index-t.index}).map(e=>e.el);if(0===o.length)return e.preventDefault(),t.focus({preventScroll:!0}),!0;const n=o[0],i=o[o.length-1],r=this.shadowRoot.activeElement;return t.contains(r)?e.shiftKey&&r===n?(e.preventDefault(),i.focus({preventScroll:!0}),!0):!e.shiftKey&&r===i&&(e.preventDefault(),n.focus({preventScroll:!0}),!0):(e.preventDefault(),n.focus({preventScroll:!0}),!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,o=this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)?this.selectedResizeMedia:null;this.NodeManager.selectButtons(t||o||e)};getPreviousMeaningfulSibling=e=>{let t=e?.previousSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;return t};getNextMeaningfulSibling=e=>{let t=e?.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.nextSibling;return t};removeTrailingBreak=e=>{if(e?.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.lastChild;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;return"BR"===t?.nodeName&&(t.remove(),!0)};removeTrailingBreakBeforeBlock=e=>{let t=e;for(;t&&t!==this.content;){const e=this.getPreviousMeaningfulSibling(t);if(e)return this.removeTrailingBreak(e);t=t.parentNode}return!1};removeBreakBeforeCaretAtBlockEnd=(e,t)=>{const o=document.createRange();o.setStart(e.startContainer,e.startOffset),o.setEnd(t,t.childNodes.length);const n=o.cloneContents();if(n.textContent.length>0||n.querySelector("*"))return!1;let i=e.startContainer,r=e.startOffset;for(;i&&i!==t;){if(i.nodeType===Node.ELEMENT_NODE&&r>0){const e=i.childNodes[r-1];return"BR"===e?.nodeName&&(e.remove(),!0)}r=Array.prototype.indexOf.call(i.parentNode.childNodes,i),i=i.parentNode}if(i===t&&r>0){const e=t.childNodes[r-1];if("BR"===e?.nodeName)return e.remove(),!0}return!1};getCaretAdjacentNode=(e,t,o)=>{let n=e.startContainer,i=e.startOffset;if(n.nodeType===Node.TEXT_NODE){if(o&&i>0||!o&&i<n.textContent.length)return null;const e=n.parentNode;i=Array.prototype.indexOf.call(e.childNodes,n)+(o?0:1),n=e}for(;n&&n.nodeType===Node.ELEMENT_NODE;){const e=n.childNodes[i-(o?1:0)];if(e){if(e.nodeType===Node.TEXT_NODE&&""===e.textContent.trim()){i+=o?-1:1;continue}return e}if(n===t)break;const r=n.parentNode;i=Array.prototype.indexOf.call(r.childNodes,n)+(o?0:1),n=r}return null};isBreakOnlyBlock=e=>!(!e||""!==e.textContent.replace(/\u200B/g,"").trim())&&(!e.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr")&&Array.from(e.querySelectorAll("*")).every(e=>"BR"===e.tagName));removeAdjacentEmptyParagraph=(e,t,o)=>{if(!t?.isCollapsed||!o)return!1;const n=this.getCaretAdjacentNode(o,this.content,"Backspace"===e);if(n?.nodeType!==Node.ELEMENT_NODE||"P"!==n.tagName||n.contains(o.startContainer)||!this.isBreakOnlyBlock(n))return!1;const i=o.cloneRange();return n.remove(),t.removeAllRanges(),t.addRange(i),!0};removeEmptyLineBreak=(e,t,o,n)=>{if(!t?.isCollapsed||!n||n===this.content)return!1;if("Backspace"===e&&this.isBreakOnlyBlock(n)){const e=this.getPreviousMeaningfulSibling(n);if(!e)return!1;n.remove();const o=document.createRange();return o.selectNodeContents(e),o.collapse(!1),t.removeAllRanges(),t.addRange(o),!0}if("Delete"===e&&this.isBreakOnlyBlock(n)){const e=this.getNextMeaningfulSibling(n);if(!e)return!1;n.remove();const o=document.createRange();return o.selectNodeContents(e),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}const i=this.getCaretAdjacentNode(o,n,!1),r=this.getCaretAdjacentNode(o,n,!0),s="Delete"===e&&"BR"===i?.nodeName?i:"BR"===r?.nodeName?r:null;if(!s)return!1;const l=s.parentNode,a=Array.prototype.indexOf.call(l.childNodes,s);s.remove();const c=document.createRange();return c.setStart(l,Math.min(a,l.childNodes.length)),c.collapse(!0),t.removeAllRanges(),t.addRange(c),!0};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(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey||(this.markTableKeyboardNavigation(),this.scheduleSkippedMediaNavigation(e)),this.navigateIntoAdjacentTable(e))return;if(this.navigateAccessibleMedia(e))return;if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeImage&&this.content.contains(this.selectedResizeImage))return e.preventDefault(),void this.preservePageScrollDuringDelete(()=>{const e=this.selectedResizeImage;this.removeSelectedObjectAndRestoreCaret(e,this.hideImageResizeHandles),this.updateWordCount()});if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)&&!this.isSelectionInsideSelectedTableCell())return e.preventDefault(),void this.preservePageScrollDuringDelete(()=>{const e=this.selectedResizeTable;this.hideTableResizeHandles(),e.remove(),this.updateWordCount()});if(("Delete"===e.key||46===e.keyCode)&&this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia))return e.preventDefault(),void this.preservePageScrollDuringDelete(()=>{const e=this.selectedResizeMedia;this.removeSelectedObjectAndRestoreCaret(e,this.hideMediaResizeHandles),this.updateWordCount()});const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&!this.isSelectionInsideEditor(t))return void e.preventDefault();if(("Delete"===e.key||"Backspace"===e.key||46===e.keyCode||8===e.keyCode)&&t&&!t.isCollapsed&&this.isSelectionInsideEditor(t))return e.preventDefault(),void this.delete();if(this.isMoreOptionsShortcut(e)&&this.isOverflowOptionsVisible()&&(e.preventDefault(),this.openOverflowOptions(!0)),!("Escape"!==e.key||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey))return e.preventDefault(),void this.escapeEditor();if("Enter"===e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&(this.insertCleanParagraphAtBlockStart()||this.insertParagraphAtTableBoundary()||this.insertParagraphAfterStructuredBlock()))return void e.preventDefault();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()),e.ctrlKey&&"v"===e.key.toLowerCase()&&this._mediaClipboardHtml&&(e.preventDefault(),this.paste()),"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 o=t.getRangeAt(0);if(this.removeAdjacentEmptyParagraph("Delete",t,o))return void e.preventDefault();const n=["P","DIV","H1","H2","H3","H4","H5","H6","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let i=t.anchorNode;for(;i&&i!==this.content&&(i.nodeType!==Node.ELEMENT_NODE||!n.includes(i.nodeName));)i=i.parentNode;if(i&&i!==this.content){if(this.removeEmptyLineBreak("Delete",t,o,i))return void e.preventDefault();const n=""===i.textContent.trim()&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed"),r=i.querySelector("table, hr");if(n&&this.removeTrailingBreakBeforeBlock(i)||(!n||r)&&this.removeBreakBeforeCaretAtBlockEnd(o,i))return void e.preventDefault();if(n){e.preventDefault();let o=null,n=i.nextSibling;for(;n;){if(n.nodeType===Node.ELEMENT_NODE){o=n;break}if(n.nodeType===Node.TEXT_NODE&&""!==n.textContent.trim()){o=n;break}n=n.nextSibling}if(i.parentNode.removeChild(i),o){const e=document.createRange();e.selectNodeContents(o),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(o.startContainer,o.startOffset),t.setEnd(i,i.childNodes.length);const n=t.cloneContents();if(0===t.toString().length&&!n.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=i.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.nextSibling;let o=i.nodeName;if(!t){let e=i,n=i.parentNode;for(;n&&n!==this.content;){let i=null;for(let e=n.childNodes.length-1;e>=0;e--){const t=n.childNodes[e];if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&""!==t.textContent.trim()){i=t;break}}if(i!==e)break;let r=n.nextSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.nextSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,o=n.nodeName;break}e=n,n=n.parentNode}}const n=["P","A"];if(!t||t.nodeType!==Node.ELEMENT_NODE||t.nodeName===o||n.includes(o)&&n.includes(t.nodeName)){if(t&&t.nodeType===Node.ELEMENT_NODE){const e=i.style.fontFamily,o=t.style.fontFamily;e&&!o?t.style.fontFamily=e:!e&&o&&(i.style.fontFamily=o)}}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&&"f"===e.key.toLowerCase()&&(e.preventDefault(),this.toggleEditorFullscreen()),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 o=t.getRangeAt(0);if(this.removeAdjacentEmptyParagraph("Backspace",t,o))return void e.preventDefault();const n=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","PRE","BLOCKQUOTE","SECTION","ARTICLE","HEADER","FOOTER"];let i=t.anchorNode;for(;i&&i!==this.content&&(i.nodeType!==Node.ELEMENT_NODE||!n.includes(i.nodeName));)i=i.parentNode;if(i&&i!==this.content){if(this.removeEmptyLineBreak("Backspace",t,o,i))return void e.preventDefault();const n=document.createRange();n.selectNodeContents(i),n.setEnd(o.startContainer,o.startOffset);const r=n.cloneContents(),s=0===r.textContent.length&&!r.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed");if(s&&this.removeTrailingBreakBeforeBlock(i))return void e.preventDefault();let l=i.previousSibling;for(;l&&l.nodeType===Node.TEXT_NODE&&""===l.textContent.trim();)l=l.previousSibling;const a=l?.nodeType===Node.ELEMENT_NODE&&""===l.textContent.trim()&&!l.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr");if(s&&a){e.preventDefault();const n=o.cloneRange();return l.remove(),t.removeAllRanges(),void t.addRange(n)}if((parseFloat(window.getComputedStyle(i).marginLeft)||0)>0){const t=document.createRange();t.setStart(i,0),t.setEnd(o.startContainer,o.startOffset),0===t.toString().length&&(e.preventDefault(),this.decreaseIndent())}else{if(""===i.textContent.trim()&&!i.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){e.preventDefault();let o=null,n=i.previousSibling;for(;n;){if(n.nodeType===Node.ELEMENT_NODE){o=n;break}if(n.nodeType===Node.TEXT_NODE&&""!==n.textContent.trim()){o=n;break}n=n.previousSibling}if(i.parentNode.removeChild(i),o){const e=document.createRange();e.selectNodeContents(o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}}else{const t=document.createRange();t.setStart(i,0),t.setEnd(o.startContainer,o.startOffset);const n=t.cloneContents();if(0===t.toString().length&&!n.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed")){let t=i.previousSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&""===t.textContent.trim();)t=t.previousSibling;let o=i.nodeName;if(!t){let e=i,n=i.parentNode;for(;n&&n!==this.content;){let i=null;for(const e of n.childNodes)if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&""!==e.textContent.trim()){i=e;break}if(i!==e)break;let r=n.previousSibling;for(;r&&r.nodeType===Node.TEXT_NODE&&""===r.textContent.trim();)r=r.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){t=r,o=n.nodeName;break}e=n,n=n.parentNode}}const n=["P","A"];if(t&&t.nodeType===Node.ELEMENT_NODE){if(n.includes(o)?!n.includes(t.nodeName):t.nodeName!==o)e.preventDefault();else{const e=t.style.fontFamily,o=i.style.fontFamily;e&&!o?i.style.fontFamily=e:!e&&o&&(t.style.fontFamily=o)}}}}}}}}if(!("ArrowLeft"!==e.key||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)){const t=this.Utilities.getSelection();if(t&&t.isCollapsed){const o=t.getRangeAt(0),n=["H1","H2","H3","H4","H5","H6"];let i=t.anchorNode;for(;i&&i!==this.content&&(i.nodeType!==Node.ELEMENT_NODE||!n.includes(i.nodeName));)i=i.parentNode;if(i&&i!==this.content&&n.includes(i.nodeName)){const n=document.createRange();n.setStart(i,0),n.setEnd(o.startContainer,o.startOffset);const r=n.cloneContents();if(0===n.toString().length&&!r.querySelector("*")){let o=i.previousSibling;for(;o&&o.nodeType===Node.TEXT_NODE&&""===o.textContent.trim();)o=o.previousSibling;if(o&&"TABLE"===o.nodeName){e.preventDefault();const n=document.createRange();n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}}}}const o=this.TableDialog.getCurrentCell(this.Utilities.getSelection()),n=o&&["ArrowUp","ArrowDown"].includes(e.key),i=o&&["ArrowLeft","ArrowRight"].includes(e.key)&&this.Utilities.getSelection()?.isCollapsed;if(!n&&!i||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey){if(e.shiftKey&&"Tab"===e.key)e.preventDefault(),o?this.TableDialog.tableTab(!0):this.decreaseIndent();else if("Tab"===e.key){const t=this.Utilities.getSelection();if(null!==t&&null!=t.anchorNode){e.preventDefault();const o=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement,n=o?.closest("blockquote"),i=o?.closest("pre"),r=o?.closest("td, th");if(n&&this.content.contains(n)||i&&this.content.contains(i)){let e=i&&this.content.contains(i)?i:n;for(;e.parentNode&&e.parentNode!==this.content;)e=e.parentNode;let o=e.nextSibling;for(;o&&o.nodeType!==Node.ELEMENT_NODE;)o=o.nextSibling;if(o){this.content.focus({preventScroll:!0});const e=document.createRange();e.selectNodeContents(o),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}}else r&&this.content.contains(r)?this.TableDialog.tableTab(!1):this.increaseIndent()}}}else this.markTableKeyboardNavigation(),i?this.TableDialog.moveCaretHorizontally(e.key)&&e.preventDefault():(e.preventDefault(),this.TableDialog.navigateCell(e.key))};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 o=t.closest("pre");if(o&&this.content.contains(o))return o;const n=t.closest("blockquote");return n&&this.content.contains(n)?n: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 o=document.createElement("p");o.appendChild(document.createElement("br"));let n=t;for(;n.parentNode&&n.parentNode!==this.content;)n=n.parentNode;if(n.parentNode!==this.content)return!1;n.nextSibling?this.content.insertBefore(o,n.nextSibling):this.content.appendChild(o);const i=document.createRange();return i.setStart(o,0),i.collapse(!0),e.removeAllRanges(),e.addRange(i),this.content.focus({preventScroll:!0}),!0};insertCleanParagraphAtBlockStart=()=>{const e=this.Utilities.getSelection();if(!e||0===e.rangeCount||!e.isCollapsed)return!1;const t=e.getRangeAt(0),o=t.cloneRange(),n=t.startContainer instanceof Element?t.startContainer:t.startContainer.parentElement,i=n?.closest("p, div, h1, h2, h3, h4, h5, h6");if(!i||i===this.content||i.parentElement!==this.content)return!1;const r=document.createRange();r.selectNodeContents(i),r.setEnd(t.startContainer,t.startOffset);const s=r.cloneContents();if(s.textContent.length>0||s.querySelector("br, img, video, audio, object, table, hr"))return!1;const l=document.createElement("p");return l.appendChild(document.createElement("br")),i.parentNode.insertBefore(l,i),e.removeAllRanges(),e.addRange(o),this.content.focus({preventScroll:!0}),!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 o=t.startOffset,n=this.content.childNodes[o],i=o>0?this.content.childNodes[o-1]:null;if("TABLE"!==n?.nodeName&&"TABLE"!==i?.nodeName)return!1;const r=document.createElement("p");r.appendChild(document.createElement("br")),this.content.insertBefore(r,n??null);const s=document.createRange();return s.setStart(r,0),s.collapse(!0),e.removeAllRanges(),e.addRange(s),this.content.focus({preventScroll:!0}),!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),o=window.getComputedStyle(t.commonAncestorContainer.parentElement);this.fontSize=parseFloat(o.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 o=e.shadowRoot?.querySelector("iframe");if(!o?.contentWindow)return;const n=o.contentWindow,i=.9*n.innerHeight,r=n.document.documentElement.scrollHeight,s="ArrowUp"===t.key?-50:"ArrowDown"===t.key?50:"PageUp"===t.key?-i:"PageDown"===t.key?i:"Home"===t.key?-r:r;n.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||"",o=e.shadowRoot||e.attachShadow({mode:"open"});for(;o.firstChild;)o.removeChild(o.firstChild);const n=document.createElement("style");n.textContent=":host{display:block;position:relative;}iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none;}",o.appendChild(n);const i=(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")),c=["<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;}","</style>"].join(""),d=document.createElement("iframe");d.srcdoc=["<!DOCTYPE html><html><head>",'<meta charset="UTF-8">',c,i,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(""),o.appendChild(d),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus({preventScroll:!0}),this.content.focus({preventScroll:!0})};togglePreviewMaximize=()=>{const e=this.shadowRoot.getElementById(`${this.id}_Preview`),t=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!e||!t)return;const o=!e.hasAttribute("data-maximized"),n=[["width","100vw"],["height","100vh"],["max-width","100vw"],["max-height","100vh"],["top","0"],["left","0"],["transform","none"],["border-radius","0"],["resize","none"]];o?(e.setAttribute("data-maximized",""),n.forEach(([t,o])=>e.style.setProperty(t,o))):(e.removeAttribute("data-maximized"),n.forEach(([t])=>e.style.removeProperty(t))),t.setAttribute("aria-label",o?"Restore preview":"Maximize preview"),t.querySelector("svg").innerHTML=o?'<path d="M4.5 1.5V4.5H1.5M7.5 10.5V7.5H10.5M4.5 4.5L1.5 1.5M7.5 7.5L10.5 10.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>':'<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>'};_resetPreviewMaximize=()=>{const 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 o=this._rtbHostElement;if(t){if(this._editorFullscreenBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",o){o.classList.add("rtb-host-fullscreen"),this._editorFullscreenPopoverValue=o.getAttribute("popover"),o.setAttribute("popover","manual");try{o.showPopover(),this._editorFullscreenUsingPopover=!0}catch{this._editorFullscreenUsingPopover=!1}}}else document.body.style.overflow=this._editorFullscreenBodyOverflow||"",o&&(this._editorFullscreenUsingPopover&&o.matches(":popover-open")&&o.hidePopover(),o.classList.remove("rtb-host-fullscreen"),null===this._editorFullscreenPopoverValue?o.removeAttribute("popover"):o.setAttribute("popover",this._editorFullscreenPopoverValue),this._editorFullscreenUsingPopover=!1);e.setAttribute("aria-label",t?"Restore editor":"Maximize editor"),e.setAttribute("title",(t?"Restore Editor":"Maximize Editor")+" (Ctrl+Shift+F)"),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 o=t.startContainer;if(o===this.content){const e=this.content.childNodes[t.startOffset]??null,o=document.createElement("hr");return this.content.insertBefore(o,e),this.cleanupHorizontalRuleInsertion(o),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o)){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 n=document.createElement("hr");o&&o!==this.content&&this.content.contains(o)?this.isEmptyHorizontalRuleBlock(o)?o.replaceWith(n):this.content.insertBefore(n,o.nextSibling):this.content.appendChild(n),this.cleanupHorizontalRuleInsertion(n),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 t="none"===this.statusBar.style.display;t?(this.statusBar.style.display="",this.updateWordCount()):this.statusBar.style.display="none";const o=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");o&&(o.textContent=t?"Hide Status Bar":"Show Status Bar"),e.write({statusBarVisible:t})};_applyStoredStatusBarVisibility=()=>{const t=e.read();if("boolean"!=typeof t.statusBarVisible||!this.statusBar)return;const o=t.statusBarVisible;this.statusBar.style.display=o?"":"none",o&&this.updateWordCount();const n=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");n&&(n.textContent=o?"Hide Status Bar":"Show Status Bar");try{null!==localStorage.getItem(e.legacyStatusBarKey)&&e.write({statusBarVisible:o})}catch{}};openFindBar=()=>{this.findBar.style.display="flex";const e=this.findBar.querySelector(".rtb-find-input");requestAnimationFrame(()=>{e.focus({preventScroll:!0}),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({preventScroll:!0}):this.source.focus({preventScroll:!0})};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()};getContextToolbarDescriptor=(e,t=null)=>{if(!(e instanceof Element&&this.content.contains(e)))return null;const o=e.closest("a"),n=e.closest("img"),i=(e.tagName,e.closest("video")),r=e.closest("pre"),s=e.closest("blockquote"),l=e.closest("object"),a=e.closest("table"),c=e.closest("ul"),d=e.closest("ol"),h=e.closest("hr")||t;let b,u,g="element";if(o&&this.content.contains(o))b=this._buildLinkContextItems(o),u=o,g="link";else if(n&&this.content.contains(n))b=this._buildImageContextItems(n),u=n;else if(i&&this.content.contains(i))b=this._buildVideoContextItems(i),u=i;else if(r&&this.content.contains(r))b=this._buildCodeBlockContextItems(r),u=r;else if(s&&this.content.contains(s))b=this._buildBlockQuoteContextItems(s),u=s;else if(l&&this.content.contains(l))b=this._buildMediaContextItems(l),u=l;else{if(a&&this.content.contains(a))return{element:a,type:"table",cell:e.closest("td, th"),target:e};if(h&&this.content.contains(h))b=this._buildHrContextItems(h),u=h;else if(c&&this.content.contains(c))b=this._buildBulletListContextItems(c,e),u=c,g="list";else if(d&&this.content.contains(d))b=this._buildNumberListContextItems(d,e),u=d,g="list";else{b=this._buildTextContextItems(e);const t=e.closest("p, h1, h2, h3, h4, h5, h6, li, div");u=t&&t!==this.content?t:e,g="text"}}return b&&0!==b.length?(!1!==this._rtbHostElement?._visibility?.htmlView&&b.push({divider:!0},{label:"View HTML",icon:"Code",action:()=>this._viewElementHtml(u)}),{element:u,positionElement:"list"===g&&u.querySelector("li")||u,target:e,type:g,items:b}):null};displayContextToolbar=e=>{if(!e)return!1;if(this.hideContextMenu(),this._contextToolbarHiddenByShortcutElement=null,this._contextToolbarSourceTarget=e.target||e.element,this._contextToolbarPositionElement=e.positionElement||e.element,this._contextToolbarPointerAnchor=e.pointerAnchor||null,"table"===e.type){if(this._suppressTableToolbarForKeyboardNavigation)return this.hideTableToolbar(),!1;this.showTableToolbar(e.element,e.cell)}else this.showContextToolbar(e.element,e.type,e.items);return!0};getPersistentContextElement=e=>e instanceof Element&&this.content.contains(e)?e.closest("img, video, object, table, blockquote, pre"):null;showPersistentContextToolbar=e=>!!this.getPersistentContextElement(e)&&this.displayContextToolbar(this.getContextToolbarDescriptor(e));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();let o=null;if(!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){o=t;break}}const n=this.getContextToolbarDescriptor(t,o);if(!n)return;e.stopPropagation(),n.pointerAnchor={clientX:e.clientX,clientY:e.clientY};const i=n.element?.closest?.("img, table, object, video");this.displayContextToolbar(n),i&&this.content.contains(i)&&this.showObjectResizeHandles(i,!1)};_buildTextContextItems=e=>{const t=[],o=this._getInlineFormatAtNode(e,"bold"),n=this._getInlineFormatAtNode(e,"italic"),i=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 c=!1,d=e instanceof Element?e:e?.parentElement;for(;d&&d!==this.content&&this.content.contains(d);){if(d.style.color||d.style.backgroundColor){c=!0;break}d=d.parentElement}o&&t.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.bold()}}),n&&t.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.italic()}}),i&&t.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.underline()}}),r&&t.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.strikethrough()}}),s&&t.push({label:"Remove Subscript",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.subscript()}}),l&&t.push({label:"Remove Superscript",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.superscript()}}),a&&t.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.inlinecode()}}),c&&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,o])=>{t.push({label:e,icon:"Format",action:()=>{this.content.focus({preventScroll:!0}),this.format(o)}})});const h=e.closest("p, h1, h2, h3, h4, h5, h6");return h&&this.content.contains(h)&&t.push({label:"Delete Element",icon:"Delete",action:()=>this._removeContentElement(h)}),t};_buildLinkContextItems=e=>[{label:"Open Link",icon:"OpenInNew",action:()=>window.open(e.href,"_blank","noopener,noreferrer")},{label:"Edit Link",icon:"Edit",action:()=>this._openLinkDialogFromContext(e)},{label:"Remove Link",icon:"RemoveLink",action:()=>this._selectNodeForDialog(e,!0,()=>this.removeLink())}];_buildImageContextItems=e=>[{label:"Edit Image",icon:"Edit",action:()=>{e.src?.startsWith("data")?this.openUploadImageDialogForElement(e):this.openImageDialogForElement(e)}},{label:"Remove Image",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildVideoContextItems=e=>[{label:"Edit Video",icon:"Edit",action:()=>this.openVideoDialogForElement(e)},{label:"Remove Video",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildBlockQuoteContextItems=e=>[{label:"Edit Block Quote",icon:"Edit",action:()=>this.openBlockQuoteDialogForElement(e)},{label:"Remove Block Quote",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildCodeBlockContextItems=e=>[{label:"Edit Code Block",icon:"Edit",action:()=>this.openCodeBlockDialogForElement(e)},{label:"Remove Code Block",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildMediaContextItems=e=>[{label:"Edit Media",icon:"Edit",action:()=>this.openMediaDialogForElement(e)},{label:"Remove Media",icon:"Delete",action:()=>this._removeContentElement(e)}];_buildTableContextItems=(e,t)=>{const o=t?.closest("td, th")||null,alignColumn=t=>{if(!o)return;const n=this.Utilities.getSelection()||window.getSelection();if((n&&!n.isCollapsed?(n.anchorNode?.nodeType===Node.ELEMENT_NODE?n.anchorNode:n.anchorNode?.parentElement)?.closest?.("td, th"):null)===o)return void(o.style.textAlign=t);const i=o.cellIndex;for(const o of e.rows)o.cells[i]&&(o.cells[i].style.textAlign=t)};return[{label:"Edit Table",icon:"Edit",action:()=>{const t=e.querySelector("td, th");if(t){const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}this.openTableDialog()}},{divider:!0},{label:"Insert Row Above",icon:"ArrowUp",action:()=>this.TableDialog.insertRowAbove(o,e)},{label:"Insert Row Below",icon:"ArrowDown",action:()=>this.TableDialog.insertRowBelow(o,e)},{label:"Insert Column Left",icon:"ArrowLeft",action:()=>this.TableDialog.insertColumnLeft(o,e)},{label:"Insert Column Right",icon:"ArrowRight",action:()=>this.TableDialog.insertColumnRight(o,e)},{divider:!0},{label:"Align Left",icon:"Alignleft",action:()=>alignColumn("left")},{label:"Align Right",icon:"Alignright",action:()=>alignColumn("right")},{label:"Align Center",icon:"Aligncenter",action:()=>alignColumn("center")},{divider:!0},{label:"Remove Row",icon:"Delete",action:()=>this.TableDialog.removeRow(o)},{label:"Remove Column",icon:"Delete",action:()=>this.TableDialog.removeColumn(o,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 o=[],n=this._getInlineFormatAtNode(t,"bold"),i=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return n&&o.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.bold()}}),i&&o.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.italic()}}),r&&o.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.underline()}}),s&&o.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.strikethrough()}}),l&&o.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.inlinecode()}}),o.length>0&&o.push({divider:!0}),o.push({label:"Remove Bullet List",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0});const t=this.Utilities.getSelection()||window.getSelection(),o=document.createRange(),n=e.querySelector("li");n?o.setStart(n,0):o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),this.unorderedlist()}}),o};_buildNumberListContextItems=(e,t)=>{const o=[],n=this._getInlineFormatAtNode(t,"bold"),i=this._getInlineFormatAtNode(t,"italic"),r=this._getInlineFormatAtNode(t,"underline"),s=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"code");return n&&o.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.bold()}}),i&&o.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.italic()}}),r&&o.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.underline()}}),s&&o.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.strikethrough()}}),l&&o.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0}),this.inlinecode()}}),o.length>0&&o.push({divider:!0}),o.push({label:"Remove Number List",icon:"Delete",action:()=>{this.content.focus({preventScroll:!0});const t=this.Utilities.getSelection()||window.getSelection(),o=document.createRange(),n=e.querySelector("li");n?o.setStart(n,0):o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),this.orderedlist()}}),o};_selectNodeForDialog=(e,t,o)=>{if(!e||!this.content.contains(e))return;const n=this.Utilities.getSelection()||window.getSelection(),i=document.createRange();t?i.selectNodeContents(e):i.selectNode(e),n.removeAllRanges(),n.addRange(i),o()};_openLinkDialogFromContext=e=>{if(!e||!this.content.contains(e))return;const t=this.Utilities.getSelection()||window.getSelection(),o=this.Utilities.saveSelection(t),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.openLinkDialog(),this.savedSelection=o,this.LinkDialog.savedSelection=o};_removeContentElement=e=>{e&&this.content.contains(e)&&this.preservePageScrollDuringDelete(()=>{e.remove(),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))})};preservePageScrollDuringDelete=e=>{const t=window.scrollX,o=window.scrollY,n=document.documentElement.scrollLeft,i=document.documentElement.scrollTop,r=document.body?.scrollLeft||0,s=document.body?.scrollTop||0,l=this.contentContainer.scrollLeft,a=this.contentContainer.scrollTop,c=this.getScrollableAncestors(this.contentContainer).map(e=>({element:e,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop})),d=document.documentElement.style.scrollBehavior,h=document.body?.style.scrollBehavior;let b=!1;const restore=()=>{b||(b=!0,window.scrollTo({left:t,top:o,behavior:"instant"}),document.documentElement.scrollLeft=n,document.documentElement.scrollTop=i,document.body&&(document.body.scrollLeft=r,document.body.scrollTop=s),c.forEach(e=>{e.element.scrollLeft=e.scrollLeft,e.element.scrollTop=e.scrollTop}),this.contentContainer.scrollLeft=l,this.contentContainer.scrollTop=a,b=!1)},restoreOnScroll=()=>restore(),u=this._suppressCaretScroll;document.documentElement.style.scrollBehavior="auto",document.body&&(document.body.style.scrollBehavior="auto"),window.addEventListener("scroll",restoreOnScroll,!0),document.addEventListener("scroll",restoreOnScroll,!0);try{this._suppressCaretScroll=!0,e()}finally{restore(),requestAnimationFrame(()=>{restore(),requestAnimationFrame(()=>{restore(),window.removeEventListener("scroll",restoreOnScroll,!0),document.removeEventListener("scroll",restoreOnScroll,!0),document.documentElement.style.scrollBehavior=d,document.body&&(document.body.style.scrollBehavior=h),this._suppressCaretScroll=u})})}};getScrollableAncestors=e=>{const t=[],o=new Set;let n=e;for(;n;){if(n=n.parentNode instanceof ShadowRoot?n.parentNode.host:n.parentElement||n.parentNode,!(n instanceof Element)||o.has(n))continue;o.add(n);const e=window.getComputedStyle(n);(/(auto|scroll|overlay)/.test(e.overflowY)&&n.scrollHeight>n.clientHeight||/(auto|scroll|overlay)/.test(e.overflowX)&&n.scrollWidth>n.clientWidth)&&t.push(n)}return t};_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 o=e;o&&o!==this.content;o=o.parentNode)t.push(Array.prototype.indexOf.call(o.parentNode.childNodes,o));const o=this.content.cloneNode(!0);let n=o;for(const e of t.reverse())n=n.childNodes[e];if(!(n instanceof Element))return;const i="data-rtb-source-target",r=` ${i}=""`;n.setAttribute(i,"");const normalizeHtml=e=>e.replace(/font-family:\s*&quot;([^"]+?)&quot;;/g,"font-family: '$1';"),s=normalizeHtml(o.innerHTML),l=s.indexOf(r),a=s.lastIndexOf("<",l),c=normalizeHtml(n.outerHTML).replace(r,"");if(l<0||a<0)return;this.source.focus({preventScroll:!0}),this.source.setSelectionRange(a,a+c.length);const d=this.source.value;this.source.value=d.substring(0,a);const h=this.source.scrollHeight;this.source.value=d,this.source.setSelectionRange(a,a+c.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 o=this.contextMenu.getBoundingClientRect(),n=window.visualViewport,i=n?.width||window.innerWidth||document.documentElement.clientWidth,r=n?.height||window.innerHeight||document.documentElement.clientHeight,s=n?.offsetLeft||0,l=n?.offsetTop||0,a=Math.min(Math.max(s+4,e.clientX),s+i-o.width-4),c=Math.min(Math.max(l+4,e.clientY),l+r-o.height-4);this.contextMenu.style.left=a-o.left+"px",this.contextMenu.style.top=c-o.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",Edit:"M120-120v-170l450-450q12-12 26.5-17.5T623-763q15 0 27.5 5.5T677-740l63 63q12 12 17.5 26.5T763-623q0 14-5.5 26.5T740-570L290-120H120Zm503-503 54 54 63-63-54-54-63 63ZM200-200h56l363-363-56-56-363 363v56Z",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 o=e instanceof Element?e:e?.parentElement;for(;o&&o!==this.content&&this.content.contains(o);){switch(t){case"bold":if("bold"===o.style.fontWeight)return o;break;case"italic":if("italic"===o.style.fontStyle)return o;break;case"underline":if(o.style.textDecoration?.includes("underline"))return o;break;case"line-through":if(o.style.textDecoration?.includes("line-through"))return o;break;case"subscript":if("sub"===o.style.verticalAlign)return o;break;case"superscript":if("super"===o.style.verticalAlign)return o;break;case"code":if("CODE"===o.nodeName&&"PRE"!==o.parentElement?.nodeName)return o}o=o.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 o=e.toLowerCase();if(this.EditMode){const t=document.createTreeWalker(this.content,NodeFilter.SHOW_TEXT);let n;for(;n=t.nextNode();){const t=n.textContent.toLowerCase();let i=0;for(;-1!==(i=t.indexOf(o,i));)this._findMatches.push({node:n,start:i,end:i+e.length}),i++}}else{const t=this.source.value.toLowerCase();let n=0;for(;-1!==(n=t.indexOf(o,n));)this._findMatches.push({start:n,end:n+e.length}),n++}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 o=this.Utilities.getSelection()||window.getSelection();o.removeAllRanges(),o.addRange(t),this._setFindHighlight(t);const n=t.getBoundingClientRect(),i=this.contentContainer.getBoundingClientRect(),r=this.contentContainer.scrollTop+n.top-i.top-(this.contentContainer.clientHeight-n.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 o=this.source.scrollHeight;this.source.value=t,this.source.focus({preventScroll:!0}),this.source.setSelectionRange(e.start,e.end),this.source.scrollTop=o<=this.source.clientHeight?0:Math.max(0,o-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,o=getComputedStyle(this.source),n=document.createTextNode(t.substring(0,e.start)),i=document.createElement("span");i.textContent=t.substring(e.start,e.end),i.style.background="rgba(255, 214, 0, 0.45)",i.style.color="transparent";const r=document.createTextNode(t.substring(e.end));this._sourceFindHighlight.replaceChildren(n,i,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=o.boxSizing,this._sourceFindHighlight.style.padding=o.padding,this._sourceFindHighlight.style.border=`${o.borderTopWidth} solid transparent`,this._sourceFindHighlight.style.font=o.font,this._sourceFindHighlight.style.letterSpacing=o.letterSpacing,this._sourceFindHighlight.style.lineHeight=o.lineHeight,this._sourceFindHighlight.style.whiteSpace=o.whiteSpace,this._sourceFindHighlight.style.overflowWrap=o.overflowWrap,this._sourceFindHighlight.style.tabSize=o.tabSize,this._sourceFindHighlight.style.textAlign=o.textAlign,this._sourceFindHighlight.style.textIndent=o.textIndent,this._sourceFindHighlight.style.textTransform=o.textTransform,this._sourceFindHighlight.style.wordBreak=o.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)}};_getStatusLinkAddress=e=>{let t="";switch(e?.tagName){case"A":t=e.href;break;case"IMG":t=e.src;break;case"BLOCKQUOTE":t=e.cite;break;case"OBJECT":t=e.data;break;case"VIDEO":t=e.currentSrc||e.src||e.querySelector("source[src]")?.src||""}return"A"!==e?.tagName&&/^(data|blob):/i.test(t)?"":t};_updateStatusLinkFromNode=e=>{const t="BLOCKQUOTE"===this._tableToolbarTable?.tagName?this._tableToolbarTable:null,o=[this.selectedResizeImage,this.selectedResizeMedia,t].find(e=>e?.isConnected&&this.content.contains(e)),n=o||(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement),i=n?.closest?.("a, img, blockquote, object, video");i&&this.content.contains(i)?this._setStatusLink(this._getStatusLinkAddress(i)):this._setStatusLink("")};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const e=this.content.innerText||"",t=e.trim(),o=t?t.split(/\s+/).length:0,n=e.replace(/\n/g,"").length,fmt=e=>e.toLocaleString();this.statusCount.textContent=`${fmt(o)} word${1!==o?"s":""} - ${fmt(n)} character${1!==n?"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"}),o=URL.createObjectURL(t),n=document.createElement("a");n.href=o,n.download=this.createTimestampedHtmlFileName(),n.click(),URL.revokeObjectURL(o)};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({preventScroll:!0})):(this.loadHtml(e),this.content.style.display="block",this.source.style.display="none",this.content.focus({preventScroll:!0}),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 o=this.shadowRoot.getElementById(e);null!=o&&o.classList.contains("rich-text-box-show")?this.setToolbarDropdownExpanded(o,!1):(this.NodeManager.closeDropdowns(),this.setToolbarDropdownExpanded(o,!0),this.sizeToolbarDropdown(o),t&&this.focusFirstToolbarMenuItem(o))};openToolbarDropdown=(e,t=!1)=>{const o=this.shadowRoot.getElementById(e);o&&(this.NodeManager.closeDropdowns(),this.setToolbarDropdownExpanded(o,!0),this.sizeToolbarDropdown(o),t&&this.focusFirstToolbarMenuItem(o))};setToolbarDropdownExpanded=(e,t)=>{if(!e)return;e.classList.toggle("rich-text-box-show",t);const o=this.shadowRoot.querySelector(`[aria-controls="${CSS.escape(e.id)}"]`);o?.setAttribute("aria-expanded",String(t))};sizeToolbarDropdown=e=>{if(!this.isResponsiveToolbarDropdown(e))return;e.style.maxHeight="";const t=this.contentContainer.getBoundingClientRect().bottom,o=e.getBoundingClientRect().top,n=Math.floor(t-o-12);n>0&&(e.style.maxHeight=`${n}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;if(this.indentSelectedResizeMedia(!0))return;this.content.focus({preventScroll:!0});const e=this.selectedResizeImage;e&&this.selectResizeImageRange();const t=this.Utilities.getSelection();if(this.isSelectionInsideEditor(t))if(e)this.updateObjectWithResizeHandles(e,()=>{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)}),this.clearResizeImageRange();else{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)}};decreaseIndent=()=>{if(this.indentSelectedResizeTable(!1))return;if(this.indentSelectedResizeMedia(!1))return;this.content.focus({preventScroll:!0});const e=this.selectedResizeImage;e&&this.selectResizeImageRange();const t=this.Utilities.getSelection();if(this.isSelectionInsideEditor(t))if(e)this.updateObjectWithResizeHandles(e,()=>{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)}),this.clearResizeImageRange();else{const e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)}};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=()=>{const e=this.ColorPickers["rich-text-box-text-color-modal"];e.insertColor(),e.savedSelection&&(this._lastEditorSelectionRange=e.savedSelection.cloneRange())};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=()=>{const e=this.ColorPickers["rich-text-box-text-bg-color-modal"];e.insertColor(),e.savedSelection&&(this._lastEditorSelectionRange=e.savedSelection.cloneRange())};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(),o=document.createRange();o.selectNode(e),t.removeAllRanges(),t.addRange(o),this.savedSelection=this.Utilities.saveSelection(t),this.TableDialog.openTableDialogForElement(e,o)};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),o=document.createElement("code");o.appendChild(t.cloneContents()),t.deleteContents(),t.insertNode(o),t.selectNodeContents(o),e.removeAllRanges(),e.addRange(t),this.NodeManager.refreshUI()}};alignleft=()=>{this.alignSelectedResizeImage("alignleft")||this.alignSelectedResizeTable("alignleft")||this.alignSelectedResizeMedia("alignleft")||this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.alignSelectedResizeImage("aligncenter")||this.alignSelectedResizeTable("aligncenter")||this.alignSelectedResizeMedia("aligncenter")||this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.alignSelectedResizeImage("alignright")||this.alignSelectedResizeTable("alignright")||this.alignSelectedResizeMedia("alignright")||this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.alignSelectedResizeImage("alignjustify")||this.alignSelectedResizeTable("alignjustify")||this.alignSelectedResizeMedia("alignjustify")||this.NodeManager.updateNode("alignjustify")};copy=()=>this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)?(this._imageClipboardHtml=this.selectedResizeImage.outerHTML,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.selectResizeImageRange(),void document.execCommand("copy")):this.selectedResizeTable&&this.content.contains(this.selectedResizeTable)&&!this.isSelectionInsideSelectedTableCell()?(this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.selectResizeTableRange(),void document.execCommand("copy")):this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)?(this._mediaClipboardHtml=this.selectedResizeMedia.outerHTML,this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._textClipboardText=null,this.selectResizeMediaRange(),void document.execCommand("copy")):(this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=this.Utilities.getSelection()?.toString()||"",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._mediaClipboardHtml=null,this._textClipboardText=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.isSelectionInsideSelectedTableCell()){this._tableClipboardHtml=this.selectedResizeTable.outerHTML,this._imageClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.selectResizeTableRange(),document.execCommand("copy");const e=this.selectedResizeTable;return this.hideTableResizeHandles(),void e.remove()}if(this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)){this._mediaClipboardHtml=this.selectedResizeMedia.outerHTML,this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._textClipboardText=null,this.selectResizeMediaRange(),document.execCommand("copy");const e=this.selectedResizeMedia;return this.hideMediaResizeHandles(),void e.remove()}this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=this.Utilities.getSelection()?.toString()||"",this.ActionOptions.cut(),this.NodeManager.refreshUI()};moveTableOutsideParagraph=e=>{const t=e?.closest("p");if(!t||!this.content.contains(t))return;const o=document.createRange();o.selectNodeContents(t),o.setEndBefore(e);const n=t.cloneNode(!1);n.appendChild(o.cloneContents());const i=document.createRange();i.selectNodeContents(t),i.setStartAfter(e);const r=t.cloneNode(!1);r.appendChild(i.cloneContents());const hasContent=e=>""!==e.textContent.trim()||!!e.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, hr"),s=document.createDocumentFragment();hasContent(n)&&s.appendChild(n),s.appendChild(e),hasContent(r)&&s.appendChild(r),t.replaceWith(s)};pasteTableValuesIntoCells=e=>{const t=this.Utilities.getSelection(),o=this.TableDialog.getCurrentCell(t);if(!o)return!1;let n=null;const i=e.clipboardData?.getData("text/html")||"";if(i){const e=document.createElement("template");e.innerHTML=i;const t=e.content.querySelector("table");t&&(n=Array.from(t.rows,e=>Array.from(e.cells,e=>e.textContent||"")))}if(!n){const t=(e.clipboardData?.getData("text/plain")||"").replace(/\r\n?/g,"\n").replace(/\n$/,"").split("\n").map(e=>e.split("\t"));if(!t.some(e=>e.length>1))return!1;n=t}if(n=n.filter(e=>e.length>0),0===n.length)return!1;const r=o.closest("table"),s=Array.from(r.rows).indexOf(o.parentElement),l=o.cellIndex;if(s<0||l<0)return!1;e.preventDefault();const a=s+n.length,c=l+Math.max(...n.map(e=>e.length)),appendCell=e=>{const t="THEAD"===e.parentElement?.tagName||e.cells.length>0&&Array.from(e.cells).every(e=>"TH"===e.tagName),o=document.createElement(t?"th":"td");o.innerHTML="&#8203;",e.appendChild(o)};Array.from(r.rows).forEach(e=>{for(;e.cells.length<c;)appendCell(e)});const d=r.tBodies[0]||r.createTBody();for(;r.rows.length<a;){const e=document.createElement("tr");for(let t=0;t<c;t++)appendCell(e);d.appendChild(e)}let h=o;return n.forEach((e,t)=>{const o=r.rows[s+t];for(;o.cells.length<c;)appendCell(o);e.forEach((e,t)=>{const n=o.cells[l+t];n.textContent=e,""===e&&(n.innerHTML="&#8203;"),h=n})}),this._imageClipboardHtml=null,this._tableClipboardHtml=null,this._mediaClipboardHtml=null,this._textClipboardText=null,this.TableDialog.selectCell(h,!0),!0};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({preventScroll:!0});const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const o=e.getRangeAt(0);o.deleteContents(),o.insertNode(t),o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}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({preventScroll:!0});const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const o=e.getRangeAt(0);o.deleteContents(),o.insertNode(t),o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}this.moveTableOutsideParagraph(t),this.showTableResizeHandles(t)}return}if(this._mediaClipboardHtml){const e=document.createElement("template");e.innerHTML=this._mediaClipboardHtml.trim();const t=e.content.firstElementChild;if(t&&["OBJECT","VIDEO"].includes(t.nodeName)){if(this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia))this.selectedResizeMedia.replaceWith(t);else{this.content.focus({preventScroll:!0});const e=this.Utilities.getSelection();if(!e||0===e.rangeCount)return;const o=e.getRangeAt(0);o.deleteContents(),o.insertNode(t),o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}this.showMediaResizeHandles(t)}return}this.NodeManager.allSelected&&this.delete(),this.content.focus({preventScroll:!0}),this._textClipboardText&&this.ActionOptions.paste(this._textClipboardText)};_returnFocus=()=>{!1===this.EditMode?this.source.focus({preventScroll:!0}):this.content.focus({preventScroll:!0})};_focusEditor=()=>{this.content.focus({preventScroll:!0});const e=this.shadowRoot.getSelection();if(!e||0===e.rangeCount||!this.content.contains(e.anchorNode)){const t=document.createRange(),o=this.content.lastChild;o?(t.selectNodeContents(o),t.collapse(!1)):(t.setStart(this.content,0),t.collapse(!0)),e&&(e.removeAllRanges(),e.addRange(t))}};closeDropdown=e=>{const t=this.shadowRoot.getElementById(e);this.setToolbarDropdownExpanded(t,!1),this.lockToolbar=!1,this._returnFocus()};delete=()=>{this.preservePageScrollDuringDelete(()=>{if(this.selectedResizeImage&&this.content.contains(this.selectedResizeImage)){const e=this.selectedResizeImage;return this.removeSelectedObjectAndRestoreCaret(e,this.hideImageResizeHandles),void this.NodeManager.refreshUI()}if(this.selectedResizeMedia&&this.content.contains(this.selectedResizeMedia)){const e=this.selectedResizeMedia;return this.removeSelectedObjectAndRestoreCaret(e,this.hideMediaResizeHandles),void this.NodeManager.refreshUI()}const e=this.Utilities.getSelection();if(null!==e){if(this._selectAllActive||this.NodeManager.allSelected()){e.removeAllRanges(),this.content.replaceChildren(),this._selectAllActive=!1,this.hideImageResizeHandles(),this.hideTableResizeHandles(),this.hideMediaResizeHandles(),this.hideTableToolbar(),this.NodeManager.clearButtons(),this.updateWordCount(),this.content.focus({preventScroll:!0});const t=document.createRange();return t.setStart(this.content,0),t.collapse(!0),e.removeAllRanges(),void e.addRange(t)}e.deleteFromDocument(),this._selectAllActive=!1,this.NodeManager.refreshUI()}})};selectall=()=>{const e=document.createRange();e.selectNodeContents(this.content),this.content.focus({preventScroll:!0});const t=this.Utilities.getSelection();null!==t&&(t.removeAllRanges(),t.addRange(e),this._selectAllActive=!0,this.content.focus({preventScroll:!0}))};orderedlist=()=>{this.toggleListForSelectedResizeImage("OL")||this.toggleListForSelectedResizeTable("OL")||this.toggleListForSelectedResizeMedia("OL")||this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.toggleListForSelectedResizeImage("UL")||this.toggleListForSelectedResizeTable("UL")||this.toggleListForSelectedResizeMedia("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 o=document.createRange();o.selectNodeContents(e),t.removeAllRanges(),t.addRange(o),this.BlockQuoteDialog.openBlockQuoteDialogForElement(e,o)};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 o=this.Utilities.getSelection()||window.getSelection();this.savedSelection=this.Utilities.saveSelection(o);const n=document.createRange();n.selectNodeContents(t),o.removeAllRanges(),o.addRange(n),this.CodeBlockDialog.openCodeBlockDialogForElement(e,n)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{if("OBJECT"===this.selectedResizeMedia?.tagName&&this.content.contains(this.selectedResizeMedia))return void this.openMediaDialogForElement(this.selectedResizeMedia);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.")};openMediaDialogForElement=e=>{if(!e||"OBJECT"!==e.tagName||!this.content.contains(e))return;this.hideMediaResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=document.createRange();t.setStartAfter(e),t.collapse(!0),this.savedSelection=t.cloneRange(),this.MediaDialog.openMediaDialogForElement(e,t)};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{if("VIDEO"===this.selectedResizeMedia?.tagName&&this.content.contains(this.selectedResizeMedia))return void this.openVideoDialogForElement(this.selectedResizeMedia);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=>{if(!e||"VIDEO"!==e.tagName||!this.content.contains(e))return;this.hideMediaResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=document.createRange();t.setStartAfter(e),t.collapse(!0),this.savedSelection=t.cloneRange(),this.VideoDialog.openVideoDialogForElement(e,t)};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()};openUploadImageDialogForElement=e=>{if(!e||"IMG"!==e.nodeName||!this.content.contains(e))return;this.hideImageResizeHandles(),this.lockToolbar=!0,this.NodeManager.closeDropdowns();const t=document.createRange();t.setStartAfter(e),t.collapse(!0),this.savedSelection=t.cloneRange(),this.UploadImageDialog.openUploadImageDialogForElement(e,t)};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(),o=document.createRange();o.selectNode(e),t.removeAllRanges(),t.addRange(o),this.savedSelection=this.Utilities.saveSelection(t),this.ImageDialog.openImageDialogForElement(e,o)};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeImageDialog=(e,t)=>{this.lockToolbar=!1,e&&this.content.contains(e)?this.restoreImageSelectionAfterDialog("rich-text-box-image-modal",e):this.Utilities.closeDialog("rich-text-box-image-modal",t)};closeUploadImageDialog=(e,t)=>{this.lockToolbar=!1,e&&this.content.contains(e)?this.restoreImageSelectionAfterDialog("rich-text-box-upload-image-modal",e):this.Utilities.closeDialog("rich-text-box-upload-image-modal",t)};restoreImageSelectionAfterDialog=(e,t)=>{const o=window.scrollX,n=window.scrollY,i=this.contentContainer.scrollTop,r=this.contentContainer.scrollLeft,restoreScroll=()=>{window.scrollTo(o,n),this.contentContainer.scrollTop=i,this.contentContainer.scrollLeft=r};this._suppressCaretScroll=!0;const s=document.createRange();s.setStartAfter(t),s.collapse(!0),this._lastEditorSelectionRange=s.cloneRange(),this._skipNextDialogFocusRestore=!0;const l=this.shadowRoot.getElementById(e);l?.open&&l.close();const a=this.Utilities.getSelection()||window.getSelection();a&&(a.removeAllRanges(),a.addRange(s.cloneRange())),this.showImageResizeHandles(t),this.NodeManager.refreshUI(),restoreScroll(),requestAnimationFrame(()=>{this.content.contains(t)&&(this._lastEditorSelectionRange=s.cloneRange(),this.showImageResizeHandles(t),this.NodeManager.refreshUI()),restoreScroll(),requestAnimationFrame(()=>{this.content.contains(t)&&(this.showImageResizeHandles(t),this.NodeManager.refreshUI()),restoreScroll(),this._suppressCaretScroll=!1})})};closeTableDialog=(e,t)=>{if(this.lockToolbar=!1,!e||!this.content.contains(e))return t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer)&&(this._lastEditorSelectionRange=t.cloneRange()),void this.Utilities.closeDialog("rich-text-box-table-modal",t);this.Utilities.closeDialog("rich-text-box-table-modal",null);const o=this.Utilities.getSelection()||window.getSelection();o?.removeAllRanges(),this.showObjectResizeHandles(e)};closeMediaDialog=(e,t)=>{if(this.lockToolbar=!1,!e||!this.content.contains(e))return void this.Utilities.closeDialog("rich-text-box-embed-modal",t);this._skipNextDialogFocusRestore=!0,this.Utilities.closeDialog("rich-text-box-embed-modal",null);const o=this.Utilities.getSelection()||window.getSelection();o?.removeAllRanges(),this.showObjectResizeHandles(e)};closeVideoDialog=(e,t,o)=>{this.lockToolbar=!1;const n=e||o;if(n&&this.content.contains(n)){this._skipNextDialogFocusRestore=!0,this.Utilities.closeDialog("rich-text-box-video-modal",null);const e=this.Utilities.getSelection()||window.getSelection();return e?.removeAllRanges(),void this.showObjectResizeHandles(n)}this.Utilities.closeDialog("rich-text-box-video-modal",t)};closeDialog=e=>{"rich-text-box-image-modal"!==e?"rich-text-box-upload-image-modal"!==e?"rich-text-box-table-modal"!==e?"rich-text-box-embed-modal"!==e?"rich-text-box-video-modal"!==e?(this.lockToolbar=!1,this.Utilities.closeDialog(e,this.savedSelection)):this.VideoDialog.closeDialog():this.MediaDialog.closeDialog():this.TableDialog.closeDialog():this.UploadImageDialog.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.hideMediaResizeHandles(),this.htmlSelection=this.StateManager.saveSelection(),this.contentScroll=this.Utilities.saveScroll(this.contentContainer),this.hideTableToolbar(),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.contentContainer.scrollTop=0,this.contentContainer.scrollLeft=0,this.source.focus({preventScroll:!0}),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({preventScroll:!0}),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.hideMediaResizeHandles(),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 o=t.getRangeAt(0);if(!this.content.contains(o.commonAncestorContainer))return;o.deleteContents();const n=document.createTextNode(e);o.insertNode(n),o.setStartAfter(n),o.collapse(!0),t.removeAllRanges(),t.addRange(o),this.content.focus({preventScroll:!0}),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 o{constructor(e,t,o,n,i){this.content=e,this.source=t,this.Utilities=o,this.dotNetObjectReference=n,this.contentContainer=i,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),o=t.cloneRange();o.selectNodeContents(this.content),o.setEnd(t.startContainer,t.startOffset);const n=o.toString().length;return{start:n,end:n+t.toString().length}}return null};restoreSelection=e=>{if(e)try{const charIndex=(e,t)=>{let o=0;if(e.nodeType===Node.TEXT_NODE)return t<=e.length?[e,t]:[null,t-e.length];for(let n=0;n<e.childNodes.length;n++){const i=e.childNodes[n],[r,s]=charIndex(i,t-o);if(r)return[r,s];o+=i.textContent.length}return[null,t-o]},t=document.createRange();let[o,n]=charIndex(this.content,e.start),[i,r]=charIndex(this.content,e.end);if(o&&i){t.setStart(o,n),t.setEnd(i,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({preventScroll:!0})}}class n{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o}_press=(e,t=!0)=>{e&&(e.classList.toggle("selected",t),e.setAttribute("aria-pressed",t?"true":"false"))};setColorProperty=(e,t,o)=>{e.style.setProperty(t,o);const n=e.getAttribute("style")||"",i=new RegExp(`(^|;)\\s*${t}\\s*:[^;]*`,"i"),r=i.test(n)?n.replace(i,(e,n)=>`${n} ${t}: ${o}`):`${n}${n.trim()&&!n.trim().endsWith(";")?";":""} ${t}: ${o}`;e.setAttribute("style",r.trim())};applyColorToSelection=(e,t,o)=>{if(!o||o.collapsed)return void this.updateNode(e,t,o);const n="textbgcolor"===e?"background-color":"color",restoreSelection=()=>{const e=window.getSelection();e.removeAllRanges(),e.addRange(o)},i=o.toString().trim();let r=o.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?o.commonAncestorContainer:o.commonAncestorContainer.parentElement;for(;r&&r!==this.content&&this.content.contains(r);){if(i===r.textContent.trim())return this.setColorProperty(r,n,t),this.refreshUI(),void restoreSelection();r=r.parentElement}const s=document.createElement("span");this.setColorProperty(s,n,t),s.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(s),o.selectNodeContents(s),this.refreshUI(),restoreSelection()};formatNode=e=>{let t,o;if(t=this.Utilities.getSelection(),null!==t){if(!this.isSelectionInsideContent(t))return;const n=/^(P|H1|H2|H3|H4|H5|H6)$/,getTopLevelFormatElement=e=>{let t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement;for(;t&&t!==this.content&&!n.test(t.nodeName);)t=t.parentElement;return t&&n.test(t.nodeName)&&t.parentElement===this.content?t:null},i=t.rangeCount>0?t.getRangeAt(0):null,r=i?getTopLevelFormatElement(i.startContainer):null,s=i?getTopLevelFormatElement(i.endContainer):null;if(!r||r!==s)return;const l=r;if(null!=l&&l!=this.content&&null!=l.parentNode&&this.content.contains(l.parentNode)){if("none"==e){let e=this.Utilities.saveCaretPosition();const t=document.createElement("div");for(let e=0;e<l.style.length;e++){const o=l.style[e];t.style[o]=l.style[o]}for(;l.firstChild;)t.appendChild(l.firstChild);l.parentNode.replaceChild(t,l),this.Utilities.restoreCaretPosition(t,e)}else{let t=this.Utilities.saveCaretPosition();const o=document.createElement(e);o.innerHTML=l.innerHTML;const n=window.getComputedStyle(l);for(let e=0;e<n.length;e++){let t=n[e],i=l.style.getPropertyValue(t);""!==i&&(o.style[t]=i)}l.parentNode.replaceChild(o,l),this.Utilities.restoreCaretPosition(o,t)}return}if(t.toString().length>0){let n;switch(e){case"p":n=document.createElement("p");break;case"h1":n=document.createElement("h1");break;case"h2":n=document.createElement("h2");break;case"h3":n=document.createElement("h3");break;case"h4":n=document.createElement("h4");break;case"h5":n=document.createElement("h5");break;case"h6":n=document.createElement("h6")}null!=n&&t.rangeCount>0&&(o=t.getRangeAt(0),this.hasInvalidElementsInSelection(t)||(n.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(n),o.selectNodeContents(n),t.removeAllRanges(),t.addRange(o)))}}};updateNode=(e,t,o)=>{let n,i;if(n=this.Utilities.getSelection(),n||o){if(n&&o?(n.removeAllRanges(),n.addRange(o)):o&&(n=window.getSelection(),n.removeAllRanges(),n.addRange(o)),!this.isSelectionInsideContent(n))return;let r;if(this.isCommonAncestor=!1,0==n.toString().length){if("alignleft"===e||"aligncenter"===e||"alignright"===e||"alignjustify"===e){const e=n.anchorNode instanceof Element?n.anchorNode:n.anchorNode?.parentElement;let t=e?.closest("table");if(!t&&n.rangeCount>0){const e=n.getRangeAt(0);if(e.collapsed&&e.startContainer===this.content){const o=e.startOffset,n=this.content.childNodes[o],i=o>0?this.content.childNodes[o-1]:null;"TABLE"===n?.nodeName?t=n:"TABLE"===i?.nodeName&&(t=i)}}t&&this.content.contains(t)&&(r=t)}if(null==r&&(r=this.getElementByStyle(n.anchorNode,e)),null==r&&null!=n.anchorNode&&n.anchorNode!=this.content&&this.content.contains(n.anchorNode)&&n.anchorNode.querySelector){null!=n.anchorNode.querySelector("img")&&(r=n.anchorNode);null!=n.anchorNode.querySelector("embed")&&(r=n.anchorNode);null!=n.anchorNode.querySelector("object")&&(r=n.anchorNode);const e=n.anchorNode.querySelector("table");null!=e&&(r=e)}null==r&&null!=n.anchorNode&&n.anchorNode!=this.content&&null!=n.anchorNode.parentNode&&n.anchorNode.parentNode!=this.content&&this.content.contains(n.anchorNode.parentNode)&&(r=n.anchorNode.parentNode)}else if(1==this.hasCommonAncestor(n)){r=n.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else r=this.getElementByContent(n.anchorNode,e,n);if(null!=r){let o;switch(e){case"textcolor":"None"==t?(o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"color",o.style.getPropertyValue("color"))):this.setColorProperty(r,"color",t);break;case"textbgcolor":"None"==t?(o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"background-color",o.style.getPropertyValue("background-color"))):this.setColorProperty(r,"background-color",t);break;case"font":if("None"==t)o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"font-family");else{const e=t.includes(" ")?`'${t}'`:t;r.style.setProperty("font-family",e)}break;case"size":"None"==t?(o=this.getElementByStyle(r,e),null!=o&&this.removeProperty(o,"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(n.toString().length>0&&"None"!=t&&!this.isExcluded(n)){let o;switch(e){case"textcolor":o=this.createElement(n),this.setColorProperty(o,"color",t);break;case"textbgcolor":o=this.createElement(n),this.setColorProperty(o,"background-color",t);break;case"font":o=this.createElement(n),o.style.fontFamily=t;break;case"size":o=this.createElement(n),o.style.fontSize=t;break;case"bold":o=this.createElement(n),o.style.fontWeight="bold";break;case"italic":o=this.createElement(n),o.style.fontStyle="italic";break;case"underline":o=this.createElement(n),this.addTextDecoration(o,"underline");break;case"line-through":o=this.createElement(n),this.addTextDecoration(o,"line-through");break;case"subscript":o=this.createElement(n),o.style.verticalAlign="sub";break;case"superscript":o=this.createElement(n),o.style.verticalAlign="super";break;case"alignleft":o=document.createElement("div"),o.style.textAlign="left";break;case"aligncenter":o=document.createElement("div"),o.style.textAlign="center";break;case"alignright":o=document.createElement("div"),o.style.textAlign="right";break;case"alignjustify":o=document.createElement("div"),o.style.textAlign="justify"}null!=o&&0!=n.rangeCount&&(i=n.getRangeAt(0),o.appendChild(i.cloneContents()),i.deleteContents(),i.insertNode(o),i.selectNodeContents(o),n.removeAllRanges(),n.addRange(i),this.selection=null,this.refreshUI())}}};alignTable=(e,t)=>{const o=getComputedStyle(this.content).getPropertyValue("--rtb-table-margin").trim()||"1.2em 0",n=document.createElement("div").style;n.margin=o;const i=e.style.marginTop||n.marginTop||"1.2em",r=e.style.marginBottom||n.marginBottom||i,setTableMargins=(t,o)=>{e.style.marginTop=i,e.style.marginRight=o,e.style.marginBottom=r,e.style.marginLeft=t};if("aligncenter"===t){const t="auto"===e.style.marginLeft&&"auto"===e.style.marginRight;return void setTableMargins(t?"0":"auto",t?"0":"auto")}if("alignright"===t){return void setTableMargins("auto"===e.style.marginLeft&&"auto"!==e.style.marginRight?"0":"auto","0")}if("alignleft"===t||"alignjustify"===t){setTableMargins("0","auto"===e.style.marginRight&&"auto"!==e.style.marginLeft?"0":"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 o=e.anchorNode;for(;o&&o!==this.content&&!this.applyMargin(o,t);)o=o.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 o=window.getComputedStyle(e).marginLeft,n=parseFloat(o)||0,i=40;return t?e.style.marginLeft=`${n+i}px`:n<=i?(e.style.marginLeft="",e.hasAttribute("style")&&(e.getAttribute("style")||e.removeAttribute("style"))):e.style.marginLeft=n-i+"px",!0}return!1};selectButtons=e=>{if(e===this.content){const t=this.Utilities.getSelection();if(t&&t.rangeCount>0&&t.isCollapsed){const o=t.getRangeAt(0);if(o.startContainer===this.content){const t=o.startOffset,n=this.content.childNodes[t],i=t>0?this.content.childNodes[t-1]:null;"TABLE"===n?.nodeName?e=n:"TABLE"===i?.nodeName&&(e=i)}}}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"),o=this.getButton("blazing-rich-text-italic-button"),n=this.getButton("blazing-rich-text-underline-button"),i=this.getButton("blazing-rich-text-strike-button"),r=this.getButton("blazing-rich-text-sub-button"),s=this.getButton("blazing-rich-text-super-button"),l=this.getButton("blazing-rich-text-alignleft-button"),a=this.getButton("blazing-rich-text-aligncenter-button"),c=this.getButton("blazing-rich-text-alignright-button"),d=this.getButton("blazing-rich-text-alignjustify-button");this.textAlign=!1;const h=this.getButton("blazing-rich-text-orderedlist-button"),b=this.getButton("blazing-rich-text-unorderedlist-button"),u=this.getButton("blazing-rich-text-link-button"),g=this.getButton("blazing-rich-text-remove-link-button"),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"),T=this.getButton("blazing-rich-text-image-upload-button"),R=this.getButton("blazing-rich-text-embed-button"),E=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 N=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=N&&(N.innerText="Font",this.fontSelected=!1);const A=this.shadowRoot.getElementById("blazing-rich-text-size-button");for(null!=A&&(A.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 z=window.getComputedStyle(e.parentNode);const D="TABLE"===e.nodeName?e:e.parentNode.closest?.("table"),_=null!=D;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"==z.getPropertyValue("font-style")&&this._press(o),z.getPropertyValue("text-decoration").includes("underline")&&"A"!=e.parentNode.nodeName&&this._press(n),z.getPropertyValue("text-decoration").includes("line-through")&&this._press(i),"sub"==z.getPropertyValue("vertical-align")&&this._press(r),"super"==z.getPropertyValue("vertical-align")&&this._press(s),D&&!this.textAlign&&("auto"===D.style.marginLeft&&"auto"===D.style.marginRight?(this._press(a),this.textAlign=!0):"auto"===D.style.marginLeft?(this._press(c),this.textAlign=!0):"auto"===D.style.marginRight&&(this._press(l),this.textAlign=!0)),_||"left"!=z.getPropertyValue("text-align")||this.textAlign||(this._press(l),this.textAlign=!0),_||"center"!=z.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),_||"right"!=z.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),_||"justify"!=z.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),null!=e&&null!=e.style&&e.style.fontFamily&&!this.fontSelected&&(N.innerText=e.style.fontFamily.replace(/^(["'])(.*)\1$/,"$2"),this.fontSelected=!0),null!=e&&null!=e.style&&e.style.fontSize&&!this.fontSizeSelected&&(A.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||E&&this._press(E),e.querySelector){const t=e.querySelector("img");t&&(t.src.startsWith("data")?this._press(T):this._press(C));e.querySelector("object")&&this._press(R);e.querySelector("video")&&E&&this._press(E)}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 t=e.getRootNode().querySelector(`[aria-controls="${CSS.escape(e.id)}"]`);t?.setAttribute("aria-expanded","false")});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({preventScroll:!0});const e=this.Utilities.getSelection();null!==e&&this.selectButtons(e.anchorNode),this.content.focus({preventScroll:!0})};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"),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),o=document.createRange();return o.selectNodeContents(this.content),t.startContainer===o.startContainer&&t.startOffset===o.startOffset&&t.endContainer===o.endContainer&&t.endOffset===o.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 o=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=o&&(o.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=e=>{switch(e.toLowerCase()){case"td":case"th":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),o=t.cloneContents(),n=document.createElement("div");n.appendChild(o);const i=t.commonAncestorContainer;return i!==this.content&&this.content.contains(i)&&n.innerHTML==t.commonAncestorContainer.innerHTML&&i.nodeType!==Node.TEXT_NODE?(n.remove(),!0):(n.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"],o=e.getRangeAt(0).cloneContents().querySelectorAll("*");for(let e=0;e<o.length;e++){const n=o[e];if(t.includes(n.tagName.toLowerCase()))return!0}}return!1};removeProperty=(e,t,o)=>{null!=e&&e!=this.content&&this.content.contains(e)&&(this.getUserDefinedStyleCount(e)>1?e.style.removeProperty(t,o):"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 o=e.style.textDecoration;if(null!=o&&!o.includes(t)){const n=o?o+" "+t:t;e.style.textDecoration=n}};removeTextDecoration=(e,t)=>{if(null!=e&&e!=this.content&&this.content.contains(e))if(this.getUserDefinedStyleCount(e)>1){const o=e.style.textDecoration.split(" ").filter(e=>e!==t);e.style.textDecoration=o.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 o=0;o<e.style.length;o++){let n=e.style[o],i=e.style.getPropertyValue(n);t[n]=i}return t};getUserDefinedStyleCount=e=>{if(null==e||e==this.content||!this.content.contains(e))return;let t=0;for(let o=0;o<e.style.length;o++){let n=e.style[o],i=e.style.getPropertyValue(n);if(this.isFormatElement(e)){if("initial"!=i){let e=i.split(" ");if(!this.isMultiValueProperty(n)&&e.length>1)for(let o=0;o<e.length;o++)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,o)=>{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 n=this.getElementByStyle(e,t);if(null!=n&&this.selectionContainsNode(o,n))return n;if(null!==o&&o.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 o=0;o<e.rangeCount;o++){let n=e.getRangeAt(o);if(this.isNodeInRange(t,n))return!0}return!1}isNodeInRange(e,t){if(null==e||e==this.content||!this.content.contains(e))return!1;let o=e.ownerDocument.createRange();return o.selectNode(e),t.compareBoundaryPoints(Range.START_TO_END,o)<=0&&t.compareBoundaryPoints(Range.END_TO_START,o)>=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 o=null;switch(t){case"textcolor":if(o=e.getAttribute("style"),null!=o&&o.includes("color:"))return e;break;case"textbgcolor":if(o=e.getAttribute("style"),null!=o&&o.includes("background-color:"))return e;break;case"font":if(o=e.getAttribute("style"),null!=o&&o.includes("font-family:"))return e;break;case"size":if(o=e.getAttribute("style"),null!=o&&o.includes("font-size:"))return e;break;case"bold":if(o=e.getAttribute("style"),null!=o&&o.includes("font-weight:")&&"bold"==e.style.fontWeight)return e;break;case"italic":if(o=e.getAttribute("style"),null!=o&&o.includes("font-style:")&&"italic"==e.style.fontStyle)return e;break;case"underline":if(o=e.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&e.style.textDecoration.includes("underline"))return e;break;case"line-through":if(o=e.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&e.style.textDecoration.includes("line-through"))return e;break;case"subscript":if(o=e.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"sub"==e.style.verticalAlign)return e;break;case"superscript":if(o=e.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"superscript"==e.style.verticalAlign)return e;break;case"alignleft":if(o=e.getAttribute("style"),null!=o&&o.includes("text-align:")&&"left"==e.style.textAlign)return e;break;case"aligncenter":if(o=e.getAttribute("style"),null!=o&&o.includes("text-align:")&&"center"==e.style.textAlign)return e;break;case"alignright":if(o=e.getAttribute("style"),null!=o&&o.includes("text-align:")&&"right"==e.style.textAlign)return e;break;case"alignjustify":if(o=e.getAttribute("style"),null!=o&&o.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"),o=document.createElement("br");if(t.appendChild(o),"CODE"==e.nodeName){const o=e.parentNode.parentNode;o.nextSibling?o.parentNode.insertBefore(t,o.nextSibling):o.parentNode.appendChild(t)}else e.parentNode.insertBefore(t,e.nextSibling);const n=document.createRange();n.setStartBefore(o),n.collapse(!0);const i=this.Utilities.getSelection();null!==i&&(i.removeAllRanges(),i.addRange(n))}}class i{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.NodeManager=n}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 o=this.NodeManager.getElementByType(t.anchorNode,e);if(null!=o)this.removelist(o);else{if(0===t.toString().trim().length){const o=t.getRangeAt(0);let n;const i=document.createElement(e);if(t.anchorNode.parentNode!==this.content&&(n=t.anchorNode.parentNode),t.anchorNode!==this.content&&(n=t.anchorNode),!n)return;if(n.nodeType===Node.ELEMENT_NODE||n.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),t=n.cloneNode(!0);this.appendListItemContent(e,t),i.appendChild(e),n.remove()}o.deleteContents(),o.insertNode(i);const r=document.createRange();r.selectNodeContents(i),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}else{const o=document.createElement(e);if(t.rangeCount>0){const e=t.getRangeAt(0),n=e.cloneContents().childNodes;Array.from(n).forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),n=e.cloneNode(!0);this.appendListItemContent(t,n),o.appendChild(t),e.remove()}}),e.deleteContents(),e.insertNode(o),e.selectNodeContents(o),t.removeAllRanges(),t.addRange(e)}}}}};isCollapsedAtElementBoundary=e=>{const t=e.startContainer,o=e.startOffset,n=new Set(["TABLE","IMG","VIDEO","AUDIO","IFRAME","CANVAS","SVG","FIGURE","OBJECT","EMBED","HR","PRE","BLOCKQUOTE"]);if(t===this.content){return[o>0?t.childNodes[o-1]:null,t.childNodes[o]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE)}if(t.nodeType!==Node.ELEMENT_NODE)return!1;if(n.has(t.nodeName))return!0;return[o>0?t.childNodes[o-1]:null,t.childNodes[o]||null].some(e=>e?.nodeType===Node.ELEMENT_NODE&&n.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 o=this.Utilities.getSelection();let n,i,r,s,l;null!==o&&o.rangeCount>0&&(n=o.getRangeAt(0),i=n.startContainer,r=n.startOffset,s=n.endContainer,l=n.endOffset);const a=document.createElement(t);for(;e.firstChild;)a.appendChild(e.firstChild);if(e.parentNode.replaceChild(a,e),n){const t=document.createRange();e.contains(i)?t.setStart(a,r):t.setStart(i,r),e.contains(s)?t.setEnd(a,l):t.setEnd(s,l),o.removeAllRanges(),o.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 o=e.firstChild;if("UL"===o.nodeName||"OL"===o.nodeName)t||(t=o),e.parentNode.insertBefore(o,e);else{for(;o.firstChild;){const n=o.firstChild;t||(t=n),e.parentNode.insertBefore(n,e)}e.removeChild(o)}}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}};removeListAsParagraphs=e=>{let t=null;for(;e.firstChild;){const o=e.firstChild;if("LI"!==o.nodeName){t||(t=o),e.parentNode.insertBefore(o,e);continue}const n=document.createElement("p");for(;o.firstChild;){const e=o.firstChild;if("UL"===e.nodeName||"OL"===e.nodeName)break;if(this.isParagraphChild(e)){for(;e.firstChild;)n.appendChild(e.firstChild);o.removeChild(e)}else n.appendChild(e)}for(n.hasChildNodes()||n.appendChild(document.createElement("br")),t||(t=n),e.parentNode.insertBefore(n,e);o.firstChild;)e.parentNode.insertBefore(o.firstChild,e);e.removeChild(o)}if(e.parentNode.removeChild(e),t){const e=this.Utilities.getSelection();if(null!==e){const o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}};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 o=this.getSelectedNodes(e,t);if(!o||0===o.length)return;let n=o[0].previousElementSibling;if(!n||"LI"!==n.nodeName)return;let i=Array.from(n.children).find(e=>e.nodeName===t.nodeName);i||(i=document.createElement(t.nodeName),n.appendChild(i)),o.forEach(e=>{"LI"===e.nodeName&&i.appendChild(e)}),this.selectListItemStart(e,o[0])};decreaseIndent=(e,t)=>{if(!e||!t||"UL"!==t.nodeName&&"OL"!==t.nodeName)return;const o=this.getSelectedNodes(e,t);if(!o||0===o.length)return;const n=t.parentElement,i=n?n.parentElement:null;if(!n||"LI"!==n.nodeName||!i||"UL"!==i.nodeName&&"OL"!==i.nodeName)return;const r=o[o.length-1],s=document.createElement(t.nodeName);for(;r.nextElementSibling;)s.appendChild(r.nextElementSibling);const l=document.createDocumentFragment();o.forEach(e=>{"LI"===e.nodeName&&l.appendChild(e)}),i.insertBefore(l,n.nextSibling),s.children.length>0&&r.appendChild(s),0===t.children.length&&t.remove(),this.selectListItemStart(e,o[0])};getSelectedNodes=(e,t)=>{const o=[];if(!e.rangeCount)return null;const n=e.getRangeAt(0);if(null!==t){const e=t.children;for(let t=0;t<e.length;t++){const i=e[t];n.intersectsNode(i)&&o.push(i)}return o}return null};saveListSelection=e=>e&&0!==e.rangeCount?e.getRangeAt(0).cloneRange():null;restoreListSelection=(e,t,o)=>{if(e&&t&&this.content.contains(t.startContainer)&&this.content.contains(t.endContainer))return e.removeAllRanges(),void e.addRange(t);this.selectListItem(e,o)};selectListItemStart=(e,t)=>{if(!e||!t)return;const o=document.createRange();o.setStart(t,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)};selectListItem=(e,t)=>{if(!e||!t)return;const o=document.createRange(),n=this.getFirstTextNode(t);n?o.setStart(n,n.textContent.length):(o.selectNodeContents(t),o.collapse(!1)),o.collapse(!0),e.removeAllRanges(),e.addRange(o)};getFirstTextNode=e=>{if(!e)return null;if(e.nodeType===Node.TEXT_NODE)return e;for(let t=0;t<e.childNodes.length;t++){const o=e.childNodes[t];if("UL"===o.nodeName||"OL"===o.nodeName)continue;const n=this.getFirstTextNode(o);if(n)return n}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 r{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o}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||"").replace(/\r\n?/g,"\n").trim();t&&(this.checkStructuredText(t)||this.checkLists(t)||this.checkParagraphs(t)||this.checkTables(t)||this.checkLines(t)||this.checkText(t))};checkStructuredText=e=>{const t=this.buildStructuredTextFragment(e);return!!t&&this.insertBlockFragment(t)};buildStructuredTextFragment=e=>{const t=e.split("\n");if(t.length<=1&&!this.parsePlainTextListItem(e))return null;const o=document.createDocumentFragment();let n=[],i=!1;const flushParagraphs=()=>{n.forEach(e=>{const t=e.trim();if(!t)return;const n=document.createElement("p");n.textContent=t,o.appendChild(n)}),n=[]};for(let e=0;e<t.length;){if(""===t[e].trim()){flushParagraphs(),e++;continue}if(this.parsePlainTextListItem(t[e])){flushParagraphs();const n=e;for(e++;e<t.length&&this.parsePlainTextListItem(t[e]);)e++;o.appendChild(this.buildListFragment(t.slice(n,e).join("\n"))),i=!0;continue}const r=this.getTableBlockLineCount(t,e);r>0?(flushParagraphs(),o.appendChild(this.buildTable(t.slice(e,e+r).join("\n"))),i=!0,e+=r):(n.push(t[e]),e++)}return flushParagraphs(),o.hasChildNodes()?!i&&t.length<=1?null:o:null};getTableBlockLineCount=(e,t)=>{const o=((e[t]||"").match(/\t/g)||[]).length;if(0===o)return 0;let n=0;for(let i=t;i<e.length;i++){const t=e[i];if(""===t.trim())break;if(this.parsePlainTextListItem(t))break;if((t.match(/\t/g)||[]).length!==o)break;n++}return n>1?n:0};checkParagraphs=e=>{let t=e.split(/\n\s*\n/);if(t.length>1){const e=document.createDocumentFragment();return t.forEach(t=>{let o=this.checkParagraphList(t,e);if(o||(o=this.checkParagraphTable(t,e)),o||(o=this.checkParagraphLines(t,e)),!o){let o=document.createElement("p");o.textContent=t.trim(),e.appendChild(o)}}),this.insertBlockFragment(e)}return!1};checkLists=e=>{const t=this.buildListFragment(e);return!!t&&this.insertBlockFragment(t)};checkParagraphList=(e,t)=>{const o=this.buildListFragment(e);return!!o&&(t.appendChild(o),!0)};buildListFragment=e=>{const t=e.split("\n").filter(e=>e.trim().length>0);if(t.length<1)return null;const o=t.map(e=>this.parsePlainTextListItem(e));if(o.some(e=>null===e))return null;const n=document.createDocumentFragment();let i=null,r=null;return o.forEach(e=>{e.type!==r&&(i=document.createElement(e.type),n.appendChild(i),r=e.type);const t=document.createElement("li");t.textContent=e.text,i.appendChild(t)}),n};parsePlainTextListItem=e=>{const t=e.match(/^\s*(?:[-*+]|\u2022)\s+(.+)$/);if(t)return{type:"ul",text:t[1].trim()};const o=e.match(/^\s*(?:\d+|[a-zA-Z])[\.)]\s+(.+)$/);return o?{type:"ol",text:o[1].trim()}:null};checkParagraphLines=(e,t)=>{let o=e.trim().split(/\n+/);return o.length>1&&(o.forEach(e=>{let o=document.createElement("p");o.textContent=e.trim(),t.appendChild(o)}),!0)};checkParagraphTable=(e,t)=>{if(this.isTable(e)){let o=this.buildTable(e);return t.appendChild(o),!0}return!1};checkLines=e=>{let t=e.trim().split(/\n+/);if(t.length>1){let e=document.createDocumentFragment();return t.forEach(t=>{let o=document.createElement("p");o.textContent=t.trim(),e.appendChild(o)}),this.insertBlockFragment(e)}};checkTables=e=>{if(this.isTable(e)){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let n=document.createDocumentFragment(),i=this.buildTable(e);return n.appendChild(i),o.insertNode(n),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}};buildTable=e=>{let t=document.createElement("table"),o=e.split("\n"),n=document.createElement("thead"),i=document.createElement("tbody"),r=0;return o.forEach(e=>{if(e.trim().length>0){let t=e.split("\t"),o=document.createElement("tr");t.forEach(e=>{let t=document.createElement(0===r?"th":"td");0===r&&t.setAttribute("scope","col"),e.trim().length>0&&(t.textContent=e),o.appendChild(t)}),(0===r?n:i).appendChild(o),r++}}),t.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 o=1;o<t.length;o++){let n=t[o];if(n.trim().length>0){if((n.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 o=t.getRangeAt(0),n=this.getEmptyTextBlock(o);if(n){const o=document.createElement("p");return o.textContent=e,this.replaceEmptyBlockWithFragment(n,o,t)}if(o.deleteContents(),""===this.content.innerHTML.trim()){const t=document.createElement("p");t.textContent=e,o.insertNode(t),o.setStartAfter(t),o.setEndAfter(t)}else{const t=document.createTextNode(e);o.insertNode(t),o.setStartAfter(t),o.setEndAfter(t)}t.removeAllRanges(),t.addRange(o)}};getTextBlock=e=>{let t=e?.nodeType===Node.ELEMENT_NODE?e:e?.parentNode;for(;t&&t!==this.content;){if(t.nodeType===Node.ELEMENT_NODE&&/^(P|H1|H2|H3|H4|H5|H6)$/.test(t.nodeName))return t;t=t.parentNode}return null};isEmptyTextBlock=e=>!!e&&""===e.textContent.replace(/\u200B/g,"").trim()&&!e.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr");getEmptyTextBlock=e=>{const t=this.getTextBlock(e.startContainer);return this.isEmptyTextBlock(t)?t:null};replaceEmptyBlockWithFragment=(e,t,o)=>{e.parentNode.insertBefore(t,e);const n=e.previousSibling;return e.remove(),this.moveSelectionAfterNode(o,n),!0};insertBlockFragment=e=>{const t=this.Utilities.getSelection();if(null===t||!t.rangeCount||!e?.hasChildNodes())return!1;const o=t.getRangeAt(0),n=e.lastChild,i=this.getEmptyTextBlock(o);if(i)return i.parentNode.insertBefore(e,i),i.remove(),this.moveSelectionAfterNode(t,n),!0;const r=document.createElement("div");if(r.appendChild(e),insertBlockOutsideContainer(o,r,this.content)){for(;r.firstChild;)r.parentNode.insertBefore(r.firstChild,r);return r.remove(),this.moveSelectionAfterNode(t,n),!0}return!1};moveSelectionAfterNode=(e,t)=>{if(!e||!t?.parentNode)return;const o=document.createRange();o.setStartAfter(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}class s{constructor(e,t){this.shadowRoot=e,this.content=t}openDialog=e=>{e&&(e.open||(e.classList.contains("rtb-centered-dialog")?e.showModal():e.show()))};closeDialog=(e,t)=>{const o=this.shadowRoot.getElementById(e);null!=o&&o.close(),t&&this.restoreSelection(window.getSelection(),t),this.content.focus({preventScroll:!0})};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")};setOptionalAttribute=(e,t,o)=>{if(!e)return;const n=o?.trim()||"";n?e.setAttribute(t,n):e.removeAttribute(t)};validateRequiredFields=(...e)=>{for(const t of e){if(!t)continue;t.setCustomValidity("");const e="file"===t.type&&0===t.files.length,o="file"!==t.type&&0===t.value.trim().length;if((e||o)&&t.setCustomValidity("Please fill out this field."),!t.checkValidity())return t.reportValidity(),this.showFadingBar(t.validationMessage),t.focus({preventScroll:!0}),!1}return!0};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"),o=t.querySelector(".rich-text-box-message");if(t&&o){o.textContent=e;const n=this.content.parentElement;n&&(t.style.top=`${n.offsetTop}px`),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({preventScroll:!0})};reselectNode=e=>{const t=document.createRange(),o=window.getSelection();e.childNodes.length>0?t.setStartAfter(e.childNodes[e.childNodes.length-1]):t.setStartAfter(e),t.collapse(!0),o.removeAllRanges(),o.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 o=this.getSelection();if(null!==o&&null!==t){let n=document.createRange();n.setStart(e.firstChild,t.startOffset),n.setEnd(e.firstChild,t.endOffset),o.removeAllRanges(),o.addRange(n)}};saveScroll=e=>e.scrollTop;restoreScroll=(e,t)=>{e.scrollTop=t}}class l{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=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)))})};loadCaption=e=>{const t=this.shadowRoot.getElementById("rich-text-box-table-caption");t&&(t.value=e.caption?.textContent||"")};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,""),o=parseInt(e.max,10)||1e4;e.value=t.length>0?String(Math.min(parseInt(t,10),o)):"",e.setCustomValidity("")};getValidTableNumber=(e,t)=>{const o=parseInt(e.value,10),n=parseInt(e.max,10)||1e4;if(!Number.isInteger(o)||o<1||o>n){const t="Enter a valid number.";return e.setCustomValidity(t),e.reportValidity(),this.Utilities.showFadingBar(t),e.focus({preventScroll:!0}),e.select(),null}return e.setCustomValidity(""),o};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 o=this.shadowRoot.getElementById("rich-text-box-table-columns");o.value=this.getColumns(t),o.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 n=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=n){const e=t.classList;n.value=Array.from(e).join(" ")}this.loadCaption(t);const i=this.shadowRoot.getElementById("rich-text-box-table-header");i&&(i.checked=this._tableHasHeader(t)),this.table=t}}this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-table-modal"));const t=this.shadowRoot.getElementById("rich-text-box-table-columns");t&&t.focus({preventScroll:!0})};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 o=this.shadowRoot.getElementById("rich-text-box-table-rows");o.value=e.rows.length,o.disabled=!0;const n=this.shadowRoot.getElementById("rich-text-box-table-columns");n.value=this.getColumns(e),n.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.loadCaption(e),this.shadowRoot.getElementById("rich-text-box-table-header").checked=this._tableHasHeader(e),this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-table-modal")),this.shadowRoot.getElementById("rich-text-box-table-width").focus({preventScroll:!0})};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 o=0;o<e.rows.length;o++){let n=e.rows[o].cells.length;n>t&&(t=n)}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 o=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=o&&(o.value=null);const n=this.shadowRoot.getElementById("rich-text-box-table-caption");n&&(n.value="");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"),o=this.shadowRoot.getElementById("rich-text-box-table-width"),n=this.shadowRoot.getElementById("rich-text-box-table-height"),i=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-caption"),a=l?.value.trim()||"",c=this.shadowRoot.getElementById("rich-text-box-table-header"),d=!!c&&c.checked,h=this.getValidTableNumber(t,"Columns");if(null===h)return;const b=this.getValidTableNumber(e,"Rows");if(null!==b){if(null!==this.table){o.value.trim().length>0?this.table.style.width=o.value:(this.table.style.removeProperty("width"),0===this.table.style.cssText.trim().length&&this.table.hasAttribute("style")&&this.table.removeAttribute("style")),n.value.trim().length>0?this.table.style.height=n.value:this.table.style.removeProperty("height"),"none"===i.value?this.table.style.removeProperty("float"):this.table.style.float=i.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),a?this.table.createCaption().textContent=a:this.table.deleteCaption();const e=this._tableHasHeader(this.table);d&&!e?this._addHeader(this.table):!d&&e&&this._removeHeader(this.table),this.Utilities.reselectNode(this.table)}else if(null!=this.tableSelection){const e=this.tableSelection,t=this.createTable(b,h,o.value,n.value,d);"none"!==i.value&&(t.style.float=i.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),a&&(t.createCaption().textContent=a),e.deleteContents();let l=e.startContainer;if(l===this.content){const o=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,o)}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 c=t.previousSibling;c&&c.nodeType===Node.ELEMENT_NODE&&""===c.textContent.trim()&&c.parentNode.removeChild(c);const u=t.nextSibling;u&&u.nodeType===Node.ELEMENT_NODE&&""===u.textContent.trim()&&u.parentNode.removeChild(u);const g=t.querySelector("td, th"),p=document.createTreeWalker(g,NodeFilter.SHOW_TEXT).nextNode(),m=document.createRange();if(p){const e=p.textContent.match(/^\u200B*/)?.[0].length||0;m.setStart(p,e)}else m.setStart(g,0);m.collapse(!0),this.savedSelection=m}this.closeDialog()}};closeDialog=()=>{this.closeHandler(this.table,this.savedSelection)};createTable=(e,t,o,n,i=!1)=>{const r=parseInt(e,10),s=parseInt(t,10),l=document.createElement("table");if(o&&(l.style.width=o),n&&(l.style.height=n),i){const e=document.createElement("thead"),t=document.createElement("tr");for(let e=0;e<s;e++){const e=document.createElement("th");e.setAttribute("scope","col"),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.tHead;if(t&&t.querySelector("th"))return!0;const o=e.rows[0];return!!o&&(o.cells.length>0&&Array.from(o.cells).every(e=>"TH"===e.tagName))};_addHeader=e=>{const t=e.rows[0];if(!t)return;Array.from(t.cells).forEach(e=>{if("TH"===e.tagName)return void e.setAttribute("scope","col");const t=document.createElement("th");for(Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value)),t.setAttribute("scope","col");e.firstChild;)t.appendChild(e.firstChild);e.replaceWith(t)});(e.tHead||e.createTHead()).appendChild(t)};_removeHeader=e=>{const t=e.rows[0];if(!t)return;Array.from(t.cells).forEach(e=>{if("TD"===e.tagName)return;const t=document.createElement("td");for(Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value));e.firstChild;)t.appendChild(e.firstChild);e.replaceWith(t)});const o=e.tHead;if(o&&t.parentNode===o){const n=e.tBodies[0]||e.createTBody();n.insertBefore(t,n.firstChild),0===o.rows.length&&o.remove()}};tableTab=(e=!1)=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return;const o=this.getCurrentCell(t);if(!o)return;const n=e?this.getPreviousElement(o):this.getNextElement(o);if(n)this.selectCell(n);else{const n=o.closest("table");if(n){let o=e?n.previousSibling:n.nextSibling;for(;o&&o.nodeType===Node.TEXT_NODE&&""===o.textContent.trim();)o=e?o.previousSibling:o.nextSibling;if(o){const n=document.createRange();n.selectNodeContents(o),n.collapse(!e),t.removeAllRanges(),t.addRange(n)}}}this.content.focus({preventScroll:!0})}};navigateCell=e=>{const t=this.Utilities.getSelection(),o=this.getCurrentCell(t);if(!o)return!1;let n=null;if("ArrowLeft"===e&&(n=this.getPreviousElement(o)),"ArrowRight"===e&&(n=this.getNextElement(o)),"ArrowUp"===e||"ArrowDown"===e){const t=o.closest("table"),i=t?Array.from(t.rows):[],r=i.indexOf(o.parentElement),s=i[r+("ArrowUp"===e?-1:1)];s&&(n=s.cells[Math.min(o.cellIndex,s.cells.length-1)]||null)}if(n){if(["ArrowUp","ArrowDown"].includes(e)&&""===n.textContent.replace(/\u200B/g,"").trim()&&!n.querySelector("img, video, audio, iframe, canvas, svg, figure, object, embed, table, hr")){const e=document.createTextNode("​");n.replaceChildren(e),this.content.focus({preventScroll:!0});const o=document.createRange();o.setStart(e,e.textContent.length),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}else this.selectCell(n,"ArrowLeft"===e||"ArrowUp"===e);return!0}const i="ArrowRight"===e||"ArrowDown"===e,r=o.closest("table");let s=i?r?.nextSibling:r?.previousSibling;for(;s&&s.nodeType===Node.TEXT_NODE&&""===s.textContent.trim();)s=i?s.nextSibling:s.previousSibling;if(!s)return!1;const l=document.createRange();return l.selectNodeContents(s),l.collapse(i),t.removeAllRanges(),t.addRange(l),this.content.focus({preventScroll:!0}),!0};moveCaretHorizontally=e=>{const t=this.Utilities.getSelection(),o=this.getCurrentCell(t);if(!o||!t.isCollapsed||!t.rangeCount)return!1;const n=t.getRangeAt(0),i=document.createRange();i.selectNodeContents(o),i.setEnd(n.startContainer,n.startOffset);const r=document.createRange();r.selectNodeContents(o),r.setStart(n.startContainer,n.startOffset);const s=i.toString().replace(/\u200B/g,""),l=r.toString().replace(/\u200B/g,"");return!("ArrowLeft"===e&&s.length>0||"ArrowRight"===e&&l.length>0)&&this.navigateCell(e)};setCaretOffset=(e,t)=>{const o=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r,s=t;for(;r=i.nextNode();){if(s<=r.textContent.length)return n.setStart(r,s),n.collapse(!0),o.removeAllRanges(),void o.addRange(n);s-=r.textContent.length}n.selectNodeContents(e),n.collapse(!1),o.removeAllRanges(),o.addRange(n)};addRowFromLastCell=()=>{const e=this.Utilities.getSelection();if(null===e||!e.rangeCount)return!1;const t=this.getCurrentCell(e);if(!t)return!1;const o=t.parentElement,n=o?o.parentElement:null,i=n?n.closest("table"):null;if(!o||!n||!i)return!1;if(o.nextElementSibling)return!1;if(t.nextElementSibling)return!1;const r=Math.max(this.getColumns(i),o.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)}n.appendChild(s);const l=s.querySelector("td, th");return l&&this.selectCell(l),!0};_makeRow=e=>{const t=document.createElement("tr");for(let o=0;o<e;o++){const e=document.createElement("td");e.innerHTML="&#8203;",t.appendChild(e)}return t};insertRowAbove=(e,t)=>{const o=e?e.closest("tr"):t?.querySelector("tr");if(!o)return;const n=Math.max(this.getColumns(t||o.closest("table")),o.cells.length,1),i=this._makeRow(n);o.parentElement.insertBefore(i,o),e&&this.selectCell(e)};insertRowBelow=(e,t)=>{const o=t||e?.closest("table"),n=e?e.closest("tr"):o?.querySelector("tr:last-child");if(!n)return;const i=Math.max(this.getColumns(o),n.cells.length,1),r=this._makeRow(i);n.after(r),e&&this.selectCell(e)};insertColumnLeft=(e,t)=>{const o=t||e?.closest("table");if(!o)return;const n=e?e.cellIndex:0;for(const e of o.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),o=document.createElement(t?"th":"td");t&&o.setAttribute("scope","col"),o.innerHTML="&#8203;",e.insertBefore(o,e.cells[n]||null)}e&&this.selectCell(e)};insertColumnRight=(e,t)=>{const o=t||e?.closest("table");if(!o)return;const n=e?e.cellIndex:o.rows[0]?.cells.length-1??0;for(const e of o.rows){const t="THEAD"===e.parentElement?.tagName||Array.from(e.cells).every(e=>"TH"===e.tagName),o=document.createElement(t?"th":"td");t&&o.setAttribute("scope","col"),o.innerHTML="&#8203;",e.insertBefore(o,e.cells[n+1]||null)}e&&this.selectCell(e)};removeRow=e=>{const t=e?.closest("tr");if(!t)return;const o=t.parentElement,n=o?.closest("table");if(!n||o.rows.length<=1)return;const i=t.previousElementSibling||t.nextElementSibling;if(t.remove(),i){const e=i.querySelector("td, th");e&&this.selectCell(e)}};removeColumn=(e,t)=>{const o=t||e?.closest("table");if(!o||!e)return;const n=e.cellIndex;if(o.rows[0]?.cells.length<=1)return;for(const e of o.rows)e.cells[n]&&e.cells[n].remove();const i=e.closest("tr")||o.rows[0],r=i?.cells[n]||i?.cells[n-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 o=t.closest("td, th");return o&&this.content.contains(o)?o:null};selectCell=(e,t=!1)=>{if(!e)return;this.content.focus({preventScroll:!0});const o=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=i.nextNode();if(t){let e;for(;e=i.nextNode();)r=e}if(r){const e=t?r.textContent.length:r.textContent.match(/^\u200B*/)?.[0].length||0;n.setStart(r,e)}else n.selectNodeContents(e),n.collapse(!t);n.collapse(!0),o.removeAllRanges(),o.addRange(n)};getNextElement=e=>{let t=e.nextElementSibling;if(!t){const o=e.closest("table"),n=o?Array.from(o.rows):[],i=n.indexOf(e.parentElement),r=n[i+1];r&&(t=r.cells[0]||null)}return t};getPreviousElement=e=>{let t=e.previousElementSibling;if(!t){const o=e.closest("table"),n=o?Array.from(o.rows):[],i=n.indexOf(e.parentElement),r=n[i-1];r&&(t=r.cells[r.cells.length-1]||null)}return t}}const wireEditableCombobox=(e,t,o)=>{const n=e.getElementById(t),i=e.getElementById(o);if(!n||!i)return;const r=Array.from(i.querySelectorAll("[data-value]"));let s=-1;const close=()=>{i.hidden=!0,r.forEach(e=>e.classList.remove("rich-text-box-combobox-option-active")),s=-1},open=()=>{i.hidden=!1},setActive=e=>{0!==r.length&&(s=(e+r.length)%r.length,r.forEach((e,t)=>{e.classList.toggle("rich-text-box-combobox-option-active",t===s),e.classList.toggle("rich-text-box-combobox-option-selected",t===s),e.setAttribute("aria-selected",t===s?"true":"false")}),n.value=r[s].dataset.value,n.dispatchEvent(new Event("input",{bubbles:!0})),(e=>{if(!e?.getBoundingClientRect)return;const t=e.getBoundingClientRect(),o=i.getBoundingClientRect();t.top<o.top?i.scrollTop-=o.top-t.top:t.bottom>o.bottom&&(i.scrollTop+=t.bottom-o.bottom)})(r[s]))};n.addEventListener("focus",open),n.addEventListener("click",open),i.addEventListener("pointerdown",e=>e.preventDefault()),i.addEventListener("click",e=>{const t=e.target.closest("[data-value]");t&&(r.forEach(e=>{const o=e===t;e.classList.toggle("rich-text-box-combobox-option-selected",o),e.setAttribute("aria-selected",o?"true":"false")}),n.value=t.dataset.value,n.dispatchEvent(new Event("input",{bubbles:!0})),close(),n.focus({preventScroll:!0}))}),n.addEventListener("keydown",e=>{"ArrowDown"===e.key?(e.preventDefault(),e.stopPropagation(),i.hidden&&open(),setActive(s+1)):"ArrowUp"===e.key?(e.preventDefault(),e.stopPropagation(),i.hidden&&open(),setActive(s<0?r.length-1:s-1)):"Enter"===e.key&&!i.hidden&&s>=0?(e.preventDefault(),e.stopPropagation(),s<0||!r[s]||(n.value=r[s].dataset.value,n.dispatchEvent(new Event("input",{bubbles:!0})),close())):"Tab"!==e.key||i.hidden?"Escape"!==e.key||i.hidden||(e.preventDefault(),e.stopPropagation(),close()):close()}),e.addEventListener("pointerdown",e=>{e.composedPath().includes(n)||e.composedPath().includes(i)||close()})},insertBlockOutsideContainer=(e,t,o)=>{if(!e||!t||!o)return!1;e.deleteContents();const n=document.createComment("rtb-block-insertion");e.insertNode(n);let i=n;for(;i.parentNode&&i.parentNode!==o;)i=i.parentNode;if(!i||i!==n&&i.parentNode!==o)return n.remove(),!1;if(i.nodeType===Node.ELEMENT_NODE&&/^(P|H1|H2|H3|H4|H5|H6)$/.test(i.nodeName)){const e=i.cloneNode(!1),o=document.createRange();o.setStartAfter(n),o.setEnd(i,i.childNodes.length),e.appendChild(o.extractContents()),n.remove(),i.parentNode.insertBefore(t,i.nextSibling),(""!==e.textContent.trim()||e.querySelector("br, img, video, audio, object, table, hr"))&&t.parentNode.insertBefore(e,t.nextSibling),""!==i.textContent.trim()||i.querySelector("br, img, video, audio, object, table, hr")||i.remove()}else i===n?n.replaceWith(t):(n.remove(),i.parentNode.insertBefore(t,i.nextSibling));return!0};class a{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.addEventListeners(),wireEditableCombobox(this.shadowRoot,"rich-text-box-embed-type","rich-text-box-embed-type-list")}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",e=>{if("Tab"===e.key){const t=this.dialog.querySelectorAll(".rtb-modal-footer .rich-text-box-form-button"),o=[this.shadowRoot.getElementById("rich-text-box-embed-source"),this.shadowRoot.getElementById("rich-text-box-embed-type"),this.shadowRoot.getElementById("rich-text-box-embed-width"),this.shadowRoot.getElementById("rich-text-box-embed-height"),this.shadowRoot.getElementById("rich-text-box-embed-margin"),this.shadowRoot.getElementById("rich-text-box-embed-float"),this.shadowRoot.getElementById("rich-text-box-embed-aria-label"),this.shadowRoot.getElementById("rich-text-box-embed-css-classes"),t[0],t[1],this.dialog.querySelector(".rtb-modal-header .rich-text-box-modal-close")].filter(Boolean),n=o.indexOf(this.shadowRoot.activeElement),i=e.shiftKey?n<=0?o.length-1:n-1:n<0||n===o.length-1?0:n+1;return e.preventDefault(),e.stopPropagation(),void o[i]?.focus({preventScroll:!0})}if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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-margin").value=this.embed.style.margin;this.shadowRoot.getElementById("rich-text-box-embed-float").value=this.embed.style.float||"none";this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(this.embed.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value=this.embed.getAttribute("aria-label")||""}e.rangeCount>0&&(this.embedSelection=e.getRangeAt(0).cloneRange()),this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-embed-modal"));const t=this.shadowRoot.getElementById("rich-text-box-embed-source");t&&t.focus({preventScroll:!0})}};openMediaDialogForElement=(e,t)=>{this.resetMediaDialog(),this.embed=e,this.savedSelection=t?.cloneRange?t.cloneRange():t,this.embedSelection=t?.cloneRange?t.cloneRange():null,this.shadowRoot.getElementById("rich-text-box-embed-source").value=e.getAttribute("data")||"",this.shadowRoot.getElementById("rich-text-box-embed-width").value=e.getAttribute("width")||"",this.shadowRoot.getElementById("rich-text-box-embed-height").value=e.getAttribute("height")||"";this.shadowRoot.getElementById("rich-text-box-embed-type").value=e.getAttribute("type")||"",this.shadowRoot.getElementById("rich-text-box-embed-margin").value=e.style.margin,this.shadowRoot.getElementById("rich-text-box-embed-float").value=e.style.float||"none",this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value=e.getAttribute("aria-label")||"",this.Utilities.openDialog(this.dialog),this.shadowRoot.getElementById("rich-text-box-embed-source").focus({preventScroll:!0})};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="";this.shadowRoot.getElementById("rich-text-box-embed-margin").value=null;this.shadowRoot.getElementById("rich-text-box-embed-float").value="none";const e=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=e&&(e.value=null),this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value=""};insertMedia=()=>{const e=this.shadowRoot.getElementById("rich-text-box-embed-source");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-embed-width"),o=this.shadowRoot.getElementById("rich-text-box-embed-height"),n=this.shadowRoot.getElementById("rich-text-box-embed-type"),i=this.shadowRoot.getElementById("rich-text-box-embed-margin"),r=this.shadowRoot.getElementById("rich-text-box-embed-float"),s=this.shadowRoot.getElementById("rich-text-box-embed-css-classes"),l=this.shadowRoot.getElementById("rich-text-box-embed-aria-label").value;if(null!==this.embed)this.embed.data=e.value,n.value.trim().length>0?this.embed.type=n.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"),o.value.trim().length>0?this.embed.height=o.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==s&&this.Utilities.addClasses(s.value,this.embed),this.Utilities.setOptionalAttribute(this.embed,"aria-label",l),"none"===r.value?this.embed.style.removeProperty("float"):this.embed.style.float=r.value,Number.isFinite(parseFloat(i.value))&&0!==parseFloat(i.value)&&CSS.supports("margin",i.value)?this.embed.style.margin=i.value:this.embed.style.removeProperty("margin"),0===this.embed.style.length&&this.embed.removeAttribute("style");else if(null!=this.embedSelection&&e.value.length>0){const a=this.embedSelection.cloneRange(),c=n.value.trim().toLowerCase(),d=e.value.trim(),h=d.split(/[?#]/,1)[0].toLowerCase(),b=c.startsWith("video/")||/\.(mp4|webm|ogv)$/.test(h),u=!b&&(c.startsWith("audio/")||/\.(mp3|m4a|aac|wav|oga|opus)$/.test(h)),g=document.createElement(b?"video":u?"audio":"object");if(b||u){g.setAttribute("controls","");const e=document.createElement("source");e.src=d,c&&(e.type=c),g.appendChild(e)}else g.data=d,c&&(g.type=c);t.value.trim().length>0?g.width=t.value:g.hasAttribute("width")&&g.removeAttribute("width"),o.value.trim().length>0?g.height=o.value:g.hasAttribute("height")&&g.removeAttribute("height"),null!==s&&this.Utilities.addClasses(s.value,g),this.Utilities.setOptionalAttribute(g,"aria-label",l),"none"!==r.value&&(g.style.float=r.value),Number.isFinite(parseFloat(i.value))&&0!==parseFloat(i.value)&&CSS.supports("margin",i.value)&&(g.style.margin=i.value),a.deleteContents(),a.insertNode(g),this.embed=g,this.embedSelection=a.cloneRange()}this.closeDialog()};closeDialog=()=>{this.closeHandler(this.embed,this.savedSelection)}}class c{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.video=null,this.videoSelection=null,this.savedSelection=null,this.addEventListeners(),wireEditableCombobox(this.shadowRoot,"rich-text-box-video-source-type","rich-text-box-video-source-type-list")}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-video-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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-margin").value=e.style.margin,ge("rich-text-box-video-float").value=e.style.float||"none",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(" "),ge("rich-text-box-video-aria-label").value=e.getAttribute("aria-label")||""};_showDialog=()=>{this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-video-modal")),this.shadowRoot.getElementById("rich-text-box-video-source").focus({preventScroll:!0})};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?.cloneRange?t.cloneRange():t,this.video=e,this._populateFromVideo(e),this.videoSelection=t?.cloneRange?t.cloneRange():null,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-margin").value="",ge("rich-text-box-video-float").value="none",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="",ge("rich-text-box-video-aria-label").value=""};insertVideo=()=>{const ge=e=>this.shadowRoot.getElementById(e),e=ge("rich-text-box-video-source");if(!this.Utilities.validateRequiredFields(e))return;const t=e.value.trim(),o=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(),r=ge("rich-text-box-video-height").value.trim(),s=ge("rich-text-box-video-margin").value,l=ge("rich-text-box-video-float").value,a=ge("rich-text-box-video-controls").checked,c=ge("rich-text-box-video-autoplay").checked,d=ge("rich-text-box-video-loop").checked,h=ge("rich-text-box-video-muted").checked,b=ge("rich-text-box-video-css-classes").value.trim(),u=ge("rich-text-box-video-aria-label").value,applyAttrs=e=>{let g=e.querySelector("source");g||(g=document.createElement("source"),e.appendChild(g)),g.setAttribute("src",t),o?g.setAttribute("type",o):g.removeAttribute("type"),n?e.setAttribute("poster",n):e.removeAttribute("poster"),i?e.setAttribute("width",i):e.removeAttribute("width"),r?e.setAttribute("height",r):e.removeAttribute("height"),"none"===l?e.style.removeProperty("float"):e.style.float=l,Number.isFinite(parseFloat(s))&&0!==parseFloat(s)&&CSS.supports("margin",s)?e.style.margin=s:e.style.removeProperty("margin"),0===e.style.length&&e.removeAttribute("style"),a?e.setAttribute("controls",""):e.removeAttribute("controls"),c?e.setAttribute("autoplay",""):e.removeAttribute("autoplay"),d?e.setAttribute("loop",""):e.removeAttribute("loop"),h?e.setAttribute("muted",""):e.removeAttribute("muted"),this.Utilities.addClasses(b,e),this.Utilities.setOptionalAttribute(e,"aria-label",u)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&t.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 o=e.startContainer;if(o===this.content){const o=this.content.childNodes[e.startOffset]??null;this.content.insertBefore(t,o)}else{for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(t),this._placeCursorAfterVideo(t),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(t,o.nextSibling),""!==o.textContent.trim()||o.querySelector("img, video, pre, blockquote")||o.parentNode.removeChild(o)}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;this._insertedVideo=null,this.closeHandler(this.video,this.savedSelection,e)}}class d{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o,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&&"BUTTON"!==t.target.tagName&&(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"),o=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 n=e.anchorNode.parentNode.cloneNode(!0);if(t.value=n.textContent,null!=o){const t=e.anchorNode.parentNode.classList;o.value=Array.from(t).join(" ")}this.shadowRoot.getElementById("rich-text-box-code-aria-label").value=e.anchorNode.parentNode.parentElement?.getAttribute("aria-label")||"",this.codeSelection=e.getRangeAt(0).cloneRange(),this.code=e.anchorNode.parentNode}else e.rangeCount>0&&(this.codeSelection=e.getRangeAt(0).cloneRange());this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-code-block-modal")),t&&(t.focus({preventScroll:!0}),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 o=e.querySelector("code")||e,n=this.shadowRoot.getElementById("rich-text-box-code"),i=this.shadowRoot.getElementById("rich-text-box-code-css-classes");n.value=o.textContent,null!=i&&(i.value=Array.from(o.classList).join(" ")),this.shadowRoot.getElementById("rich-text-box-code-aria-label").value=e.getAttribute("aria-label")||"",this.codeSelection=t?t.cloneRange():null,this.code=o,this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-code-block-modal")),n.focus({preventScroll:!0}),n.scrollTop=0,n.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),this.shadowRoot.getElementById("rich-text-box-code-aria-label").value=""};insertCodeBlock=()=>{const e=this.shadowRoot.getElementById("rich-text-box-code");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-code-css-classes"),o=this.shadowRoot.getElementById("rich-text-box-code-aria-label").value;if(null!=this.code){const n=this.code;n.textContent=e.value,null!==t&&this.Utilities.addClasses(t.value,n),this.Utilities.setOptionalAttribute(n.parentElement,"aria-label",o);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"),r=document.createElement("code");if(null!==t&&this.Utilities.addClasses(t.value,r),this.Utilities.setOptionalAttribute(i,"aria-label",o),r.textContent=e.value,i.appendChild(r),!insertBlockOutsideContainer(n,i,this.content))return;const s=i.previousSibling;s&&s.nodeType===Node.ELEMENT_NODE&&""===s.textContent.trim()&&s.parentNode.removeChild(s);const l=i.nextSibling;l&&l.nodeType===Node.ELEMENT_NODE&&""===l.textContent.trim()&&l.parentNode.removeChild(l),n.selectNodeContents(r),n.collapse(!1),this.savedSelection=n}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class h{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o,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&&"BUTTON"!==t.target.tagName&&(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"),o=this.shadowRoot.getElementById("rich-text-box-cite"),n=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&&(o.value=e.anchorNode.parentNode.cite),null!=n){const t=e.anchorNode.parentNode.classList;n.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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-block-quote-modal")),t&&(t.focus({preventScroll:!0}),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 o=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");o.value=e.textContent,null!=e.cite&&(n.value=e.cite),null!=i&&(i.value=Array.from(e.classList).join(" ")),this.quoteSelection=t?t.cloneRange():null,this.quote=e,this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-block-quote-modal")),o.focus({preventScroll:!0}),o.scrollTop=0,o.scrollLeft=0};resetBlockQuoteDialog=()=>{this.quote=null,this.quoteSelection=null;this.shadowRoot.getElementById("rich-text-box-quote").value=null;this.shadowRoot.getElementById("rich-text-box-cite").value=null;const 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");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const n=this.quote;n.textContent=e.value,t.value.trim().length>0?n.setAttribute("cite",t.value):n.hasAttribute("cite")&&n.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,n);const i=document.createRange();i.selectNodeContents(n),i.collapse(!1),this.savedSelection=i}else if(null!=this.quoteSelection&&e.value.length>0){const n=this.quoteSelection.cloneRange(),i=document.createElement("blockquote");if(i.textContent=e.value,t.value.trim().length>0?i.cite=t.value:i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,i),!insertBlockOutsideContainer(n,i,this.content))return;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(i),n.collapse(!1),this.savedSelection=n}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class b{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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 o=document.createElement("img");if(t){const e=new FileReader;e.onloadend=function(){this.base64String=e.result.split(",")[1],o.src=`data:image/jpg;base64,${this.base64String}`},e.readAsDataURL(t),this.image=o}};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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-upload-image-modal"));const t=this.shadowRoot.getElementById("rich-text-box-upload-btn");t&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))}};openUploadImageDialogForElement=(e,t)=>{if(!e||"IMG"!==e.nodeName||!this.content.contains(e))return;this.resetUploadImageDialog(),this.currentImage=e,this.savedSelection=t?t.cloneRange():null,this.range=t?t.cloneRange():null,this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=e.width,this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=e.height,this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=e.alt,this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes").value=Array.from(e.classList).join(" "),this.shadowRoot.getElementById("rich-text-box-upload-image-float").value=e.style.float||"none",this.shadowRoot.getElementById("rich-text-box-upload-image-margin").value=e.style.margin,this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-upload-image-modal"));const o=this.shadowRoot.getElementById("rich-text-box-upload-btn");o&&requestAnimationFrame(()=>o.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-file");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),o=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"),r=this.shadowRoot.getElementById("rich-text-box-upload-image-float"),s=this.shadowRoot.getElementById("rich-text-box-upload-image-margin");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),t.value.trim().length>0?this.currentImage.width=t.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),o.value.trim().length>0?this.currentImage.height=o.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),n.value.trim().length>0?(this.currentImage.alt=n.value,this.currentImage.removeAttribute("role")):(this.currentImage.removeAttribute("alt"),this.currentImage.removeAttribute("role")),null!==i&&this.Utilities.addClasses(i.value,this.currentImage),"none"===r.value?(this.currentImage.style.removeProperty("float"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")):this.currentImage.style.float=r.value,Number.isFinite(parseFloat(s.value))&&0!==parseFloat(s.value)&&CSS.supports("margin",s.value)?this.currentImage.style.margin=s.value:(this.currentImage.style.removeProperty("margin"),0===this.currentImage.style.length&&this.currentImage.removeAttribute("style")),this.Utilities.reselectNode(this.currentImage)):this.image&&(t.value.length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),o.value.length>0?this.image.height=o.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),n.value.length>0?(this.image.alt=n.value,this.image.removeAttribute("role")):(this.image.removeAttribute("alt"),this.image.removeAttribute("role")),null!==i&&this.Utilities.addClasses(i.value,this.image),"none"!==r.value&&(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.range.deleteContents(),this.range.insertNode(this.image),this.currentImage=this.image,this.Utilities.reselectNode(this.image)),this.closeDialog()};closeDialog=()=>{this.closeHandler(this.currentImage||this.image,this.savedSelection)}}class u{constructor(e,t,o,n){this.shadowRoot=e,this.content=t,this.Utilities=o,this.closeHandler=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-image-modal"));const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress");t&&t.focus({preventScroll:!0})}};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.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-image-modal")),this.shadowRoot.getElementById("rich-text-box-image-webaddress").focus({preventScroll:!0}))};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");if(!this.Utilities.validateRequiredFields(e))return;const t=this.shadowRoot.getElementById("rich-text-box-image-width"),o=this.shadowRoot.getElementById("rich-text-box-image-height"),n=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),i=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),n.value.trim().length>0?(this.image.alt=n.value,this.image.removeAttribute("role")):(this.image.removeAttribute("alt"),this.image.removeAttribute("role")),t.value.trim().length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),o.value.trim().length>0?this.image.height=o.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==i&&this.Utilities.addClasses(i.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),o.value.trim().length>0&&(a.height=o.value),n.value.trim().length>0&&(a.alt=n.value),null!==i&&this.Utilities.addClasses(i.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.image=a,this.Utilities.reselectNode(a)}this.imageSelection=l.cloneRange()}this.closeDialog()};closeDialog=()=>{this.closeHandler(this.image,this.savedSelection)}}class g{constructor(e,t,o){this.shadowRoot=e,this.content=t,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",e=>{if("Enter"===e.key){if("BUTTON"===e.target.tagName)return;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 o=e.anchorNode.parentNode.classList;t.value=Array.from(o).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.rangeCount>0&&(this.linkSelection=e.getRangeAt(0).cloneRange(),this.linkSelection.collapsed||(t.value=this.linkSelection.toString()))}this.Utilities.openDialog(this.shadowRoot.getElementById("rich-text-box-link-modal"));const t=this.shadowRoot.getElementById("rich-text-box-link-webaddress");t&&t.focus({preventScroll:!0})}};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");if(!this.Utilities.validateRequiredFields(t,e))return;const o=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),n=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=this.linkNode){const i=this.linkNode;i.href=t.value,i.textContent=e.value,null!==n&&this.Utilities.addClasses(n.value,i),o.checked?i.target="_blank":i.hasAttribute("target")&&i.removeAttribute("target"),this.Utilities.reselectNode(i)}else if(null!=this.linkSelection){const i=this.linkSelection,r=document.createElement("a");r.href=t.value,r.textContent=e.value,null!==n&&this.Utilities.addClasses(n.value,r),o.checked&&(r.target="_blank"),i.deleteContents(),i.insertNode(r),i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),this.savedSelection=i}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,o=document.createDocumentFragment();for(;t.firstChild;)o.appendChild(t.firstChild);t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t)}this.Utilities.restoreSelection(e,t)}}}class p{constructor(e,t,o,n,i){this.shadowRoot=e,this.content=t,this.id=o,this.NodeManager=n,this.Utilities=i,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.swatchRegion=this.colorPicker.querySelector(".rich-text-box-color-swatches"),this.swatches=Array.from(this.swatchRegion.querySelectorAll(".blazing-rich-text-color-option")),this.swatches.forEach((e,t)=>{e.id=`${this.id}-swatch-${t}`,e.setAttribute("aria-selected","false")}),this.swatchRegion.addEventListener("keydown",this.handleSwatchKeydown),this.redSlider=this.colorPicker.querySelector(".rich-text-box-red-slider"),this.redSlider.style.setProperty("--rtb-slider-thumb-color","rgb(0, 0, 0)"),this.addSliderEventListener(this.redSlider),this.greenSlider=this.colorPicker.querySelector(".rich-text-box-green-slider"),this.greenSlider.style.setProperty("--rtb-slider-thumb-color","rgb(0, 0, 0)"),this.addSliderEventListener(this.greenSlider),this.blueSlider=this.colorPicker.querySelector(".rich-text-box-blue-slider"),this.blueSlider.style.setProperty("--rtb-slider-thumb-color","rgb(0, 0, 0)"),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"),this.customColorInputs=Array.from(this.colorPicker.querySelectorAll(".rich-text-box-custom-color")),this.customColorInputs.forEach(e=>this.addCustomColorEventListeners(e)),this.saveFormatInputs=Array.from(this.colorPicker.querySelectorAll(".rich-text-box-color-save-format"))};handleSwatchKeydown=e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault(),e.stopPropagation();const t="ArrowRight"===e.key?1:-1,o=Number.isInteger(this.selectedSwatchIndex)?(this.selectedSwatchIndex+t+this.swatches.length)%this.swatches.length:t>0?0:this.swatches.length-1;this.selectSwatch(o)};selectSwatch=e=>{const t=this.swatches[e];t&&(this.selectedSwatchIndex=e,this.swatches.forEach((t,o)=>{const n=o===e;t.classList.toggle("rich-text-box-color-option-selected",n),t.setAttribute("aria-selected",String(n))}),this.swatchRegion.setAttribute("aria-activedescendant",t.id),this.selectColor(t.getAttribute("data-color")))};addCustomColorEventListeners=e=>{e.addEventListener("input",()=>{const t=this.normalizeHexColor(e.value);e.setAttribute("aria-invalid",String(""!==e.value.trim()&&null===t)),this.updateCustomColorAppearance(e,t||""),t?(this.saveCustomColors(),this.selectColor(t)):""===e.value.trim()&&this.saveCustomColors()}),e.addEventListener("change",()=>{const t=this.normalizeHexColor(e.value);e.setAttribute("aria-invalid",String(""!==e.value.trim()&&null===t)),t?(e.value=t,this.updateCustomColorAppearance(e,t),this.saveCustomColors(),this.selectColor(t)):""===t&&this.saveCustomColors()}),e.addEventListener("focus",()=>{e.select();const t=this.normalizeHexColor(e.value);t&&this.selectColor(t)})};normalizeHexColor=e=>{const t=e.trim();if(""===t)return"";const o=t.startsWith("#")?t:`#${t}`;return/^#[0-9A-Fa-f]{6}$/.test(o)?o.toUpperCase():null};loadCustomColors=()=>{const t=e.read().customColors[this.id];this.customColorInputs.forEach((e,o)=>{e.value=t[o]||"",e.setAttribute("aria-invalid","false"),this.updateCustomColorAppearance(e,e.value)})};saveCustomColors=()=>{const t=e.read(),o=this.customColorInputs.map(e=>this.normalizeHexColor(e.value)||"");e.write({customColors:{...t.customColors,[this.id]:o}})};updateCustomColorAppearance=(e,t)=>{e.style.setProperty("--rtb-custom-color",t||"var(--rtb-modal-input-border, #CCC)")};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("input",e=>{const t=e.target.selectionStart,o=e.target.selectionEnd;e.target.value=e.target.value.toUpperCase(),e.target.setSelectionRange(t,o),/^#?[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.loadCustomColors(),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.colorElement=e.anchorNode.parentNode,this.colorProperty="color",this.selectSaveFormat(this.getInlineColorFormat(e.anchorNode.parentNode,"color")),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.colorElement=e.anchorNode.parentNode,this.colorProperty="background-color",this.selectSaveFormat(this.getInlineColorFormat(e.anchorNode.parentNode,"background-color")),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.Utilities.openDialog(this.colorPickerDialog),requestAnimationFrame(()=>this.redSlider?.focus({preventScroll:!0})),this.selection};insertColor=()=>{let e;switch(this.currentColor=this.getCurrentColor(this.getSaveFormat()),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.selection.cloneRange(),null===this.currentColor?this.NodeManager.updateNode(e,"None",this.selection):(this.NodeManager.applyColorToSelection(e,this.currentColor,this.selection),this.savedSelection=this.selection.cloneRange())),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog(this.id,this.savedSelection)};resetColorDialog=()=>{this.selection=null,this.colorElement=null,this.colorProperty=null,this.selectedSwatchIndex=null,this.swatches.forEach(e=>{e.classList.remove("rich-text-box-color-option-selected"),e.setAttribute("aria-selected","false")}),this.swatchRegion.removeAttribute("aria-activedescendant"),this.selectSaveFormat("hex"),this.hexInput.value="#000000",this.updateFromHex()};selectColor=e=>{this.hexInput.value=e,this.updateFromHex();const t=this.hexInput.value.toUpperCase(),o=this.swatches.findIndex(e=>e.getAttribute("data-color")===t);o>=0&&o!==this.selectedSwatchIndex?(this.selectedSwatchIndex=o,this.swatches.forEach((e,t)=>{const n=t===o;e.classList.toggle("rich-text-box-color-option-selected",n),e.setAttribute("aria-selected",String(n))}),this.swatchRegion.setAttribute("aria-activedescendant",this.swatches[o].id)):o<0&&(this.selectedSwatchIndex=null,this.swatches.forEach(e=>{e.classList.remove("rich-text-box-color-option-selected"),e.setAttribute("aria-selected","false")}),this.swatchRegion.removeAttribute("aria-activedescendant"))};updateColor=()=>{let e=parseInt(this.redSlider.value),t=parseInt(this.greenSlider.value),o=parseInt(this.blueSlider.value),n=`rgb(${e}, ${t}, ${o})`;this.currentColor=n,this.colorDisplay.style.backgroundColor=n,this.redSlider.style.setProperty("--rtb-slider-thumb-color",`rgb(${e}, 0, 0)`),this.greenSlider.style.setProperty("--rtb-slider-thumb-color",`rgb(0, ${t}, 0)`),this.blueSlider.style.setProperty("--rtb-slider-thumb-color",`rgb(0, 0, ${o})`),this.redValue.value=e,this.greenValue.value=t,this.blueValue.value=o,this.hexInput.value=this.rgbToHex(e,t,o)};getCurrentColor=(e="rgb")=>"hex"===e?this.hexInput.value.startsWith("#")?this.hexInput.value:`#${this.hexInput.value}`:`rgb(${this.redSlider.value}, ${this.greenSlider.value}, ${this.blueSlider.value})`;getSaveFormat=()=>this.saveFormatInputs.find(e=>e.checked)?.value||"rgb";selectSaveFormat=e=>{this.saveFormatInputs.forEach(t=>{t.checked=t.value===e})};getInlineColorFormat=(e,t)=>{const o=(e.getAttribute("style")||"").match(new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"i"));return o&&o[1].trim().startsWith("#")?"hex":"rgb"};updateFromHex=()=>{let e=this.hexInput.value.trim();if("#"!==e.charAt(0)&&(e="#"+e),this.hexInput.value=e.toUpperCase(),/^#[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,o)=>("#"+((1<<24)+(e<<16)+(t<<8)+o).toString(16).slice(1)).toUpperCase();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.toUpperCase()}}window.RTNative_Instances={},window.RTNative_Initialize=(e,o,n,i,r,s)=>{try{null==RTNative_Instances[e]&&(RTNative_Instances[e]=new t(e,o,n,i,s),RTNative_Instances[e].loadHtml(r))}catch(e){console.log(e)}},window.RTNative_Method=(e,t,o)=>{try{const n=RTNative_Instances[t];if(null!=n&&"function"==typeof n[e])return null!=o?n[e](o):n[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 x extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=x._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText="",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-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: #0f6cbd;\n --rtb-modal-checkbox-check: #ffffff;\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 --rtb-modal-checkbox-check: #ffffff;\n}\n\n",document.head.appendChild(e)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(e,t,o){if(t!==o){if("value"===e&&this._initialized&&(this._value=o||"",RTNative_Method("loadView",this._uid,o)),"width"===e&&this.style.setProperty("--rtb-editor-width",o||"100%"),"height"===e&&this.style.setProperty("--rtb-editor-height",o||"300px"),"config"===e)try{this.configure(JSON.parse(o))}catch(e){}if("placeholder"===e){const e=RTNative_Instances?.[this._uid];e?.content&&(o?e.content.setAttribute("data-placeholder",o):e.content.removeAttribute("data-placeholder"))}if("readonly"===e){const e=RTNative_Instances?.[this._uid];e&&e.setReadOnly(null!==o)}if("aria-label"===e||"label"===e){const e=RTNative_Instances?.[this._uid];e?.content&&o&&e.content.setAttribute("aria-label",o)}}}connectedCallback(){x._injectGlobalStyles(),this.style.setProperty("--rtb-editor-width",this.getAttribute("width")||"100%"),this.style.setProperty("--rtb-editor-height",this.getAttribute("height")||"300px"),this._render(),requestAnimationFrame(()=>this._initialize())}get readOnly(){return this.hasAttribute("readonly")}setReadOnly(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 o="",n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;const i=e.indexOf("{",n);if(-1===i)break;const r=e.slice(n,i).trim();let s=1,l=i+1;for(;l<e.length&&s>0;)"{"===e[l]?s++:"}"===e[l]&&s--,l++;const a=e.slice(i+1,l-1);if(n=l,r)if(r.startsWith("@")){const e=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(e)?o+=r+" {\n"+this._scopeCssText(a,t)+"}\n":o+=r+" {"+a+"}\n"}else{o+=r.split(",").map(e=>e.trim()).filter(e=>e).map(e=>":root"===e?t:t+" "+e).join(",\n")+" {"+a+"}\n"}}return o}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();let o="";if(this._previewCssText&&(o+=this._scopeCssText(this._previewCssText,".rich-text-box-content")+"\n"),o.trim()){const t=document.createElement("style");t.id="_rtb-content-preview-styles",t.textContent=o,e.shadowRoot.appendChild(t)}}configure(e={}){const{visibility:t,customButtons:o,...n}=e;if(t){if(t.clearAll&&(this._visibility=x._defaultVisibility(!1)),!0===t.fileMenu&&!1===this._visibility.fileMenu){const e=x._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)}o&&(this._customButtons=Array.isArray(o)?o.filter(e=>e&&e.id):[]),this._applyCSSVars(n),this._syncPreviewTheme(),this._initialized&&(t||o)&&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 o=e.button||{};set("--rtb-btn-text",o.textColor),set("--rtb-btn-size",o.textSize),set("--rtb-btn-font",o.textFont),set("--rtb-btn-bg",o.backgroundColor),set("--rtb-btn-bg-hover",o.backgroundColorHover),set("--rtb-btn-bg-selected",o.backgroundColorSelected),set("--rtb-btn-border-style",o.borderStyle),set("--rtb-btn-border-width",o.borderWidth),set("--rtb-btn-border-color",o.borderColor),set("--rtb-btn-border-hover",o.borderColorHover),set("--rtb-btn-border-selected",o.borderColorSelected),set("--rtb-btn-border-radius",o.borderRadius);const n=e.content||{};set("--rtb-content-text",n.textColor),set("--rtb-content-size",n.textSize),set("--rtb-content-font",n.textFont),set("--rtb-content-bg",n.backgroundColor),set("--rtb-content-shadow",n.boxShadow);const i=e.editor||{};set("--rtb-editor-width",i.width),set("--rtb-editor-height",i.height),set("--rtb-editor-border-radius",i.borderRadius),set("--rtb-editor-border-style",i.borderStyle),set("--rtb-editor-border-width",i.borderWidth),set("--rtb-editor-border-color",i.borderColor),set("--rtb-editor-shadow",i.boxShadow),null!=i.removeResizeHandle&&set("--rtb-editor-resize",i.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 e=this.getAttribute("value")||"",o=null!==this._value?this._value:e;this._value=o;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 t(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: 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.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.active {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-btn-bg-hover, #e8e8e8));\n outline: 2px solid var(--rtb-btn-border-selected, var(--rtb-toolbar-border-color, #605e5c));\n outline-offset: -2px;\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 position: relative;\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-container.rtb-editor-fullscreen > .rich-text-box-content-container {\n flex: 1 1 auto;\n height: auto;\n min-height: 0;\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.rich-text-box-content-container.rtb-source-view .rtb-table-toolbar {\n display: none;\n}\n.rich-text-box-content-container.rtb-source-view .rich-text-box-source {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\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.rtb-table-toolbar {\n align-items: center;\n background-color: var(--rtb-toolbar-bg, #fff);\n border: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n border-radius: 5px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.16);\n box-sizing: border-box;\n display: flex;\n gap: 2px;\n opacity: 0;\n padding: 3px;\n pointer-events: none;\n position: absolute;\n transform: translateY(3px);\n transition: opacity 100ms ease-in-out, transform 100ms ease-in-out;\n user-select: none;\n white-space: nowrap;\n z-index: 20;\n}\n.rtb-table-toolbar.rtb-table-toolbar-visible {\n opacity: 1;\n pointer-events: auto;\n transform: translateY(0);\n}\n.rtb-table-toolbar-button,\n.rtb-table-toolbar-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-btn-text, #242424);\n cursor: pointer;\n display: flex;\n font-family: var(--rtb-btn-font, Arial, Helvetica, sans-serif);\n font-size: 13px;\n gap: 5px;\n justify-content: center;\n min-height: 28px;\n padding: 4px 7px;\n}\n.rtb-table-toolbar-button:hover,\n.rtb-table-toolbar-button:focus-visible,\n.rtb-table-toolbar-button.active,\n.rtb-table-toolbar-menu button:hover,\n.rtb-table-toolbar-menu button:focus-visible,\n.rtb-table-toolbar-menu button.active {\n background-color: var(--rtb-btn-bg-selected, var(--rtb-dropdown-bg-hover, #e5e5e5));\n color: var(--rtb-btn-text-selected, var(--rtb-dropdown-text-hover, #000));\n outline: none;\n}\n.rtb-table-toolbar-icon-button {\n padding-left: 5px;\n padding-right: 5px;\n}\n.rtb-table-toolbar svg {\n fill: currentColor;\n flex: 0 0 auto;\n height: 17px;\n width: 17px;\n}\n.rtb-table-toolbar-button svg:last-child:not(:first-child) {\n height: 13px;\n width: 13px;\n}\n.rtb-table-toolbar-divider {\n align-self: stretch;\n border-left: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n margin: 3px 2px;\n}\n.rtb-table-toolbar-dropdown {\n position: relative;\n}\n.rtb-table-toolbar-menu {\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 6px 14px rgba(0,0,0,0.16);\n display: none;\n left: 0;\n min-width: 148px;\n padding: 4px;\n position: absolute;\n top: calc(100% + 4px);\n z-index: 1;\n}\n.rtb-table-toolbar-dropdown-open .rtb-table-toolbar-menu {\n display: block;\n}\n.rtb-table-toolbar-menu button {\n color: var(--rtb-dropdown-text, #242424);\n gap: 8px;\n justify-content: flex-start;\n text-align: left;\n width: 100%;\n}\n.rtb-table-toolbar-menu-divider {\n border-top: 1px solid rgba(128,128,128,0.18);\n margin: 4px;\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 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 object,\n.rich-text-box-content video { cursor: pointer; }\n.rich-text-box-content table { cursor: var(--rtb-table-cell-cursor, text); }\n.rtb-image-resize-overlay,\n.rtb-table-resize-overlay,\n.rtb-media-resize-overlay {\n border: 1px solid var(--rtb-btn-border-selected, #605e5c);\n box-sizing: border-box;\n display: none;\n pointer-events: none;\n position: absolute;\n transition: none;\n z-index: 15;\n}\n.rtb-image-resize-overlay.rtb-image-resize-visible,\n.rtb-table-resize-overlay.rtb-table-resize-visible,\n.rtb-media-resize-overlay.rtb-media-resize-visible {\n display: block;\n}\n.rtb-image-resize-handle,\n.rtb-table-resize-handle,\n.rtb-media-resize-handle {\n background: var(--rtb-modal-checkbox, #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 var(--rtb-modal-checkbox, #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: none;\n width: 13px;\n}\n.rtb-image-resize-handle:hover,\n.rtb-table-resize-handle:hover,\n.rtb-media-resize-handle:hover {\n box-shadow: 0 0 0 2px var(--rtb-modal-checkbox, #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(.dark) .rtb-media-resize-handle,\n:host(.fluent-dark) .rtb-image-resize-handle,\n:host(.fluent-dark) .rtb-table-resize-handle,\n:host(.fluent-dark) .rtb-media-resize-handle {\n background: var(--rtb-modal-checkbox, #0f6cbd);\n box-shadow: 0 0 0 1px var(--rtb-modal-checkbox, #0f6cbd), 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.rtb-media-resizing,\n.rtb-media-resizing .rtb-media-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-self: stretch;\n border: 0 !important;\n border-left: 1px solid var(--rtb-toolbar-border-color, #d1d1d1) !important;\n outline: none;\n cursor: default;\n margin: 3px 2px;\n padding: 0;\n transform: scaleY(0.78);\n transform-origin: center;\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 display: none;\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 align-items: center;\n display: inline-flex;\n font-size: var(--rtb-btn-size, 16px);\n justify-content: center;\n line-height: 1;\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-file-content,\n.rich-text-box-font-content,\n.rich-text-box-size-content,\n.rich-text-box-format-content {\n overflow-x: hidden;\n overflow-y: auto;\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 .rich-text-box-menu-item: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: 16px;\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 .rich-text-box-menu-item {\n background: transparent;\n border: 0;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #000);\n cursor: pointer;\n font-family: inherit;\n font-size: 18px;\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n text-align: left;\n width: 100%;\n}\n.rich-text-box-dropdown .rich-text-box-menu-item: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 .rich-text-box-menu-item {\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 .rich-text-box-menu-item: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 .rich-text-box-menu-item: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 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.rtb-centered-dialog {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n}\n.rtb-centered-dialog::backdrop {\n background: transparent;\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: 4px;\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 min-height: 32px;\n padding: 5px 12px;\n font-size: 14px;\n line-height: 20px;\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: normal;\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: 4px;\n box-sizing: border-box;\n margin-top: 0px;\n margin-bottom: 12px;\n resize: vertical;\n}\n.rich-text-box-form-element:not(textarea) {\n height: 32px;\n}\n.rich-text-box-form-element:is(textarea) {\n min-height: 52px;\n padding: 6px 12px;\n}\n.rich-text-box-modal label {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n letter-spacing: normal;\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: 4px;\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.rich-text-box-combobox {\n appearance: none;\n cursor: text;\n margin-bottom: 0;\n transition: none;\n}\n.rich-text-box-combobox-wrap {\n margin-bottom: 12px;\n position: relative;\n}\n.rich-text-box-combobox-list {\n background: var(--rtb-dropdown-bg, var(--rtb-modal-input-bg, #fff));\n border: 1px solid var(--rtb-toolbar-border-color, var(--rtb-modal-input-border, #CCC));\n border-radius: 5px;\n box-shadow: none;\n box-sizing: border-box;\n font-family: inherit;\n font-size: calc(var(--rtb-modal-text-size, 16px) - 2px);\n font-weight: 400;\n left: 0;\n margin-top: 2px;\n max-height: 121px;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 5px;\n position: absolute;\n right: 0;\n z-index: 20;\n}\n.rich-text-box-combobox-list[hidden] {\n display: none;\n}\n.rich-text-box-combobox-option {\n background: transparent;\n border: 0;\n color: var(--rtb-dropdown-text, var(--rtb-modal-input-text, #000));\n cursor: pointer;\n display: block;\n font: inherit;\n line-height: 20px;\n margin: 2px 0;\n overflow: hidden;\n padding: 5px 10px;\n text-align: left;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n transition: none;\n}\n.rich-text-box-combobox-option:hover,\n.rich-text-box-combobox-option:focus {\n background: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #000));\n outline: none;\n}\n.rich-text-box-combobox-option-active,\n.rich-text-box-combobox-option-selected {\n background: var(--rtb-btn-bg-selected, #dcdcdc) !important;\n box-shadow: none;\n color: var(--rtb-dropdown-text-hover, var(--rtb-dropdown-text, #242424));\n outline: none;\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 appearance: none;\n -webkit-appearance: none;\n background-color: var(--rtb-modal-input-bg, #fff);\n border: 1px solid var(--rtb-modal-input-border, #CCC);\n box-sizing: border-box;\n display: inline-grid;\n flex: 0 0 auto;\n place-content: center;\n outline: none;\n width: 16px;\n height: 16px;\n margin-right: 4px;\n border-radius: 4px;\n cursor: pointer;\n}\n.rich-text-box-form-checkbox:checked {\n background-color: var(--rtb-modal-checkbox, #0f6cbd);\n border-color: var(--rtb-modal-checkbox, #0f6cbd);\n}\n.rich-text-box-form-checkbox:checked::before {\n content: "";\n width: 11px;\n height: 11px;\n clip-path: polygon(14% 44%, 0 58%, 36% 94%, 100% 18%, 86% 6%, 34% 68%);\n background-color: var(--rtb-modal-checkbox-check, #fff);\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-checkbox, #0f6cbd);\n border-width: 1px;\n box-shadow: none;\n}\n.rich-text-box-upload-btn {\n padding: 5px 12px !important;\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: normal;\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: 4px;\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n min-width: 100% !important;\n min-height: 32px;\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-upload-image-modal .rtb-upload-image-file-row {\n box-sizing: border-box;\n display: flex;\n align-items: flex-start;\n gap: 8px;\n height: 64px;\n padding-top: 5px;\n margin-bottom: -5px;\n}\n#rich-text-box-upload-image-modal .rtb-visually-hidden-file {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-grid {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n column-gap: 30px;\n row-gap: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-field {\n box-sizing: border-box;\n min-width: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-left {\n grid-column: 1;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-right {\n grid-column: 2;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-field label:not(.rich-text-box-upload-btn) {\n display: block;\n margin: 0;\n}\n#rich-text-box-upload-image-modal .rtb-upload-image-field .rich-text-box-form-element {\n display: block;\n}\n#rich-text-box-upload-image-modal .rich-text-box-upload-btn {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: auto;\n min-width: 0 !important;\n height: 32px;\n min-height: 32px;\n margin: 0 0 0 5px;\n white-space: nowrap;\n}\n#rich-text-box-upload-image-modal #rich-text-box-upload-image-file-chosen {\n display: inline-flex;\n align-items: center;\n min-width: 0;\n min-height: 32px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n@media screen and (max-width: 850px) {\n #rich-text-box-upload-image-modal .rtb-upload-image-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n #rich-text-box-upload-image-modal .rtb-upload-image-file-row {\n height: auto;\n margin-bottom: 10px;\n }\n #rich-text-box-upload-image-modal .rtb-upload-image-left,\n #rich-text-box-upload-image-modal .rtb-upload-image-right {\n grid-column: 1;\n }\n}\n.rich-text-box-form-button {\n min-height: 36px;\n padding: 7px 16px !important;\n border-radius: 4px;\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: normal;\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.rich-text-box-color-swatches {\n display: grid;\n grid-template-columns: repeat(auto-fit, 18px);\n gap: 5px;\n justify-content: center;\n padding: 4px 2px;\n border-radius: 4px;\n}\n.rich-text-box-color-swatches:focus-visible {\n outline: 2px solid var(--rtb-modal-text, #242424);\n outline-offset: 2px;\n}\n.blazing-rich-text-color-option {\n width: 18px;\n height: 18px;\n margin: 0;\n cursor: pointer;\n display: block;\n border: 1px solid #999;\n border-radius: 50%;\n box-sizing: border-box;\n transition: transform 0.12s ease;\n}\n.blazing-rich-text-color-option:hover,\n.blazing-rich-text-color-option.rich-text-box-color-option-selected {\n transform: scale(1.18);\n}\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 position: absolute;\n top: 0;\n left: 0;\n z-index: 20;\n box-sizing: border-box;\n width: 100%;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);\n font-size: 14px;\n background-color: rgba(0, 0, 0, 0.6);\n color: #ffffff;\n display: flex;\n gap: 16px;\n justify-content: space-between;\n align-items: center;\n padding: 5px 10px;\n opacity: 1;\n visibility: visible;\n transition: opacity 160ms ease-in-out, visibility 0s linear 0s;\n pointer-events: auto;\n}\n.rich-text-box-message-bar.rich-text-box-message-hidden {\n opacity: 0;\n pointer-events: none;\n visibility: hidden;\n transition: opacity 160ms ease-in-out, visibility 0s linear 160ms;\n}\n.rich-text-box-message {}\n.rich-text-box-message-close-button {\n background: none; border: none; color: #ffffff; font-size: 18px; cursor: pointer;\n}\n.rich-text-box-color-picker {\n width: 100%;\n --rtb-color-picker-left-width: 367px;\n}\n.rich-text-box-color-swatches,\n.rich-text-box-color-display {\n box-sizing: border-box;\n width: var(--rtb-color-picker-left-width);\n max-width: 100%;\n}\n.rich-text-box-color-swatches {\n margin: 0 auto;\n}\n.rich-text-box-color-display {\n height: 55px;\n border: 1px solid #ccc;\n margin: 8px auto 4px;\n}\n.rich-text-box-custom-colors {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: repeat(5, minmax(0, 1fr));\n gap: 6px;\n width: var(--rtb-color-picker-left-width);\n max-width: 100%;\n margin: 8px auto 0;\n}\n.rich-text-box-custom-color {\n box-sizing: border-box;\n min-width: 0;\n width: 100%;\n padding: 5px 4px;\n border-left: 8px solid var(--rtb-custom-color, var(--rtb-modal-input-border, #CCC));\n text-align: center;\n font-size: 12px;\n text-transform: uppercase;\n cursor: pointer;\n margin-bottom: 0;\n}\n.rich-text-box-custom-color::placeholder {\n text-transform: none;\n}\n.rich-text-box-color-modal input.rich-text-box-custom-color:focus-visible {\n border-color: var(--rtb-modal-input-border, #CCC) !important;\n border-left-color: var(--rtb-custom-color, var(--rtb-modal-input-border, #CCC)) !important;\n}\n.rich-text-box-custom-color[aria-invalid="true"] {\n border-color: #c42b1c;\n}\n.rich-text-box-color-modal .rtb-modal-footer {\n padding-top: 0;\n}\n.rich-text-box-color-modal .rich-text-box-form-right {\n box-sizing: border-box;\n padding-top: 27px;\n}\n@media screen and (max-width: 850px) {\n .rich-text-box-color-modal .rich-text-box-form-right {\n padding-top: 0;\n }\n}\n.rich-text-box-slider-container {\n display: flex;\n align-items: center;\n margin-bottom: 10px;\n position: relative;\n top: -10px;\n}\n@media screen and (max-width: 850px) {\n .rich-text-box-slider-container {\n top: 10px;\n }\n}\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;\n height: 18px;\n width: 18px;\n background: var(--rtb-slider-thumb-color, var(--rtb-modal-bg, #fefefe));\n margin-top: -6.5px;\n border: 1px solid #999;\n border-radius: 50%;\n box-sizing: border-box;\n transition: transform 0.12s ease;\n}\n.rich-text-box-range::-moz-range-thumb {\n -webkit-appearance: none;\n height: 18px;\n width: 18px;\n background: var(--rtb-slider-thumb-color, var(--rtb-modal-bg, #fefefe));\n margin-top: -6.5px;\n border: 1px solid #999;\n border-radius: 50%;\n box-sizing: border-box;\n transition: transform 0.12s ease;\n}\n.rich-text-box-range:focus-visible::-webkit-slider-thumb {\n transform: scale(1.18);\n}\n.rich-text-box-range:focus-visible::-moz-range-thumb {\n transform: scale(1.18);\n}\n.rich-text-box-number {\n width: 100px; margin-left: 10px; padding: 5px 12px; 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: 4px; box-sizing: border-box;\n}\n.rich-text-box-form-element[type="number"] {\n color-scheme: inherit;\n}\n:host(.light),\n:host(.fluent) {\n color-scheme: light;\n}\n:host(.dark),\n:host(.fluent-dark) {\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 {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: 20px;\n align-items: start;\n margin-top: 30px;\n}\n.rich-text-box-color-control {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n.rich-text-box-color-control > label,\n.rich-text-box-color-save-as {\n margin: 0;\n}\n.rich-text-box-color-control > label,\n.rich-text-box-color-save-as legend {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n margin-bottom: 4px;\n}\n.rich-text-box-hex-input {\n width: 100% !important;\n margin: 0;\n}\n.rich-text-box-color-save-as {\n border: 0;\n display: flex;\n align-items: flex-start;\n flex-direction: column;\n padding: 0;\n}\n.rich-text-box-color-save-as legend {\n float: none;\n padding: 0;\n}\n.rich-text-box-color-save-as ul {\n align-items: center;\n display: flex;\n gap: 10px;\n list-style: none;\n margin: 0;\n min-height: 28px;\n overflow: visible;\n padding: 0;\n}\n.rich-text-box-color-save-as li {\n display: flex;\n margin: 0;\n}\n.rich-text-box-color-save-as label {\n align-items: center;\n border: 1px solid transparent;\n border-radius: 4px;\n cursor: pointer;\n display: inline-flex;\n gap: 5px;\n line-height: 20px;\n padding: 3px 6px;\n}\n.rich-text-box-color-save-format {\n appearance: none;\n -webkit-appearance: none;\n background-color: var(--rtb-modal-input-bg, #fff);\n border: 2px solid var(--rtb-modal-input-border, #a0a0a0);\n border-radius: 50%;\n box-sizing: border-box;\n cursor: pointer;\n flex: 0 0 16px;\n height: 16px;\n margin: 0;\n width: 16px;\n}\n.rich-text-box-color-save-format:checked {\n background-color: var(--rtb-modal-checkbox, #0f6cbd);\n border-color: var(--rtb-modal-checkbox, #0f6cbd);\n box-shadow: inset 0 0 0 3px var(--rtb-modal-input-bg, #fff);\n}\n.rich-text-box-color-save-format:focus-visible {\n outline: 2px solid var(--rtb-modal-checkbox, #0f6cbd);\n outline-offset: 2px;\n transform: scale(1.08);\n}\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; }\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-centered-dialog[open] {\n animation: rtb-dialog-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 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 n=this.getAttribute("aria-label")||this.getAttribute("label");n&&RTNative_Instances[this._uid].content.setAttribute("aria-label",n);const i=this.getAttribute("placeholder");i&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",i),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid]._applyStoredStatusBarVisibility(),RTNative_Instances[this._uid].loadHtml(o),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,o,n,i){return`<button id="${e}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==i?`RTNative_Method('${n}','${this._uid}','${i}')`:`RTNative_Method('${n}','${this._uid}')`}">${this._svg(t)}</button>`}_specialBtn(e,t,o,n){return`<button id="${e}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${n}','${this._uid}')">${this._svg(t)}</button>`}_fullscreenBtn(){return`<button id="blazing-rich-text-fullscreen-button" title="Maximize Editor (Ctrl+Shift+F)" 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),o=this._escapeAttr(e.title||e.label||e.id),n=e.svg||"";return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item rich-text-box-custom-button" data-rtb-custom-button="${t}"${e.disabled?" disabled":""}>${n}</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 o=e.shadowRoot.querySelector(`[data-rtb-custom-button="${CSS.escape(t.id)}"]`);o&&o.addEventListener("click",o=>{if(t.disabled)return;const n=this._resolveCustomButtonHandler(t.onClick||t.method);"function"==typeof n&&n.call(this,o,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=>`<button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-family:${t}" onclick="RTNative_Method('font','${e}','${t}')">${t}</button>`).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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-font-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-font-button">\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=>`<button type="button" role="menuitem" class="rich-text-box-menu-item" style="${"None"===t?"":`font-size:${t}px !important;`}" onclick="RTNative_Method('size','${e}','${"None"===t?"None":`${t}px`}')">${"None"===t?"None":t}</button>`).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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-size-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-size-button">\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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-format-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-format-button">\n <button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('format','${e}','p')">Paragraph</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:34px" onclick="RTNative_Method('format','${e}','h1')">Heading 1</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:30px" onclick="RTNative_Method('format','${e}','h2')">Heading 2</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:24px" onclick="RTNative_Method('format','${e}','h3')">Heading 3</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:20px" onclick="RTNative_Method('format','${e}','h4')">Heading 4</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:18px" onclick="RTNative_Method('format','${e}','h5')">Heading 5</button>\n <button type="button" role="menuitem" class="rich-text-box-menu-item" style="font-size:16px" onclick="RTNative_Method('format','${e}','h6')">Heading 6</button>\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,o])=>`\n <div class="rich-text-box-insert-group" role="presentation">${t}</div>\n ${o.map(([t,o])=>`\n <button type="button" role="menuitem" 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">${o||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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-insert-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-insert-button">\n ${t}\n </div>\n</div>`}_fileDropdown(){const e=this._uid,t=this._visibility,o=`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','open')">Open<span class="rich-text-box-menu-shortcut">Ctrl+O</span></button>`;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 aria-haspopup="menu" aria-expanded="false" aria-controls="blazing-rich-text-file-button-dropdown"\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" role="menu" aria-labelledby="blazing-rich-text-file-button">\n ${t.search?`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','find')">Find<span class="rich-text-box-menu-shortcut">Ctrl+F</span></button>`:""}${o}${t.saveHtml?`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','save')">Download<span class="rich-text-box-menu-shortcut">Ctrl+S</span></button>`:""}${(t.search||t.saveHtml||o)&&t.statusBarToggle?'<hr class="rich-text-box-dropdown-divider" role="separator">':""}${t.statusBarToggle?`<button type="button" role="menuitem" class="rich-text-box-menu-item" 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></button>`:""}${(t.search||t.saveHtml||t.statusBarToggle)&&t.help?'<hr class="rich-text-box-dropdown-divider" role="separator">':""}${t.help?`<button type="button" role="menuitem" class="rich-text-box-menu-item" onclick="RTNative_Method('fileMenuAction','${e}','shortcuts')">Keyboard Shortcuts<span class="rich-text-box-menu-shortcut">Ctrl+/</span></button>`:""}\n </div>\n</div>`}_colorSwatches(e){const t=[0,12,24,36,48,60,90,120,150,180,205,230,255,280,305,330];return[80,68,56,44,32,20].flatMap(e=>t.map(t=>((e,t,o)=>{t/=100,o/=100;const n=(1-Math.abs(2*o-1))*t,i=e/60,r=n*(1-Math.abs(i%2-1)),s=o-n/2;return`#${(i<1?[n,r,0]:i<2?[r,n,0]:i<3?[0,n,r]:i<4?[0,r,n]:i<5?[r,0,n]:[n,0,r]).map(e=>Math.round(255*(e+s)).toString(16).padStart(2,"0")).join("").toUpperCase()}`})(t,85,e))).concat(["#000000","#101010","#202020","#303030","#404040","#555555","#6A6A6A","#7F7F7F","#949494","#A8A8A8","#BDBDBD","#D0D0D0","#E0E0E0","#EDEDED","#F7F7F7","#FFFFFF"]).map(t=>`<div class="blazing-rich-text-color-option" role="option" aria-label="${t}" title="${t}" data-color="${t}" onclick="RTNative_Method('${e}','${this._uid}','${t}')" style="background-color:${t};"></div>`).join("")}_colorDialog(e,t,o,n){const i=this._uid;return`\n<dialog id="${e}" class="rich-text-box-modal rich-text-box-color-modal rtb-centered-dialog" 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','${i}','${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 <div class="rich-text-box-color-swatches" role="listbox" tabindex="0" aria-label="Preset colors; use left and right arrow keys to select">\n ${this._colorSwatches(o)}\n </div>\n <div class="rich-text-box-custom-colors" aria-label="Custom colors">\n ${[1,2,3,4,5].map(e=>`<input type="text" class="rich-text-box-form-element rich-text-box-custom-color" placeholder="Hex ${e}" aria-label="Custom color Hex ${e}" maxlength="7" autocomplete="off" spellcheck="false">`).join("")}\n </div>\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 <div class="rich-text-box-color-control">\n <label for="${e}-hex-input">Hexadecimal</label>\n <input id="${e}-hex-input" type="text" class="rich-text-box-form-element rich-text-box-hex-input" value="#000000" autocomplete="off">\n </div>\n <fieldset class="rich-text-box-color-save-as rich-text-box-color-control">\n <legend>Save As</legend>\n <ul>\n <li><label><input class="rich-text-box-color-save-format" type="radio" name="${e}-save-format" value="hex" checked> Hex</label></li>\n <li><label><input class="rich-text-box-color-save-format" type="radio" name="${e}-save-format" value="rgb"> RGB</label></li>\n </ul>\n </fieldset>\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','${i}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${n}','${i}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(e,t,o,n,i=""){const r=this._uid,s="rich-text-box-upload-image-modal"===e?{close:' tabindex="10"',footerClose:' tabindex="8"',ok:' tabindex="9"'}:{close:"",footerClose:"",ok:""};return`\n<dialog id="${e}" class="rich-text-box-modal rtb-centered-dialog" 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"${s.close} 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 ${n}\n </div>\n <div class="rtb-modal-footer" style="${i?"display:flex;justify-content:space-between;align-items:center;":"text-align:right;"}">\n ${i?`<div>${i}</div>`:""}\n <div>\n <button class="rich-text-box-form-button"${s.footerClose} onclick="RTNative_Method('closeDialog','${r}','${e}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button"${s.ok} onclick="RTNative_Method('${o}','${r}')">OK</button>\n </div>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const e=this._uid,t=this._visibility,o=(t.font||t.size||t.format||t.insert)&&t.textStylesDivider,n=(t.bold||t.italic||t.underline||t.strikethrough||t.subscript||t.superscript||t.inlineCode)&&t.formatDivider,i=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,c=(t.undo||t.redo)&&t.historyDivider,d=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 ${o?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 ${n?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 ${i?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 ${c?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 ${d?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" style="clear:left;">\n <label>Margin</label>\n <input type="text" id="rich-text-box-table-margin" class="rich-text-box-form-element" placeholder="10px">\n <label>Caption (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-table-caption">\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 <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" required>\n <label>Type</label>\n <div class="rich-text-box-combobox-wrap">\n <input class="rich-text-box-form-element rich-text-box-float-dropdown rich-text-box-combobox" type="text" id="rich-text-box-embed-type" placeholder="None" autocomplete="off">\n <div class="rich-text-box-combobox-list" id="rich-text-box-embed-type-list" role="listbox" hidden>\n ${["application/pdf","audio/mpeg","audio/mp4","audio/ogg","audio/wav","audio/webm","image/avif","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","text/html","text/plain","video/mp4","video/ogg","video/webm"].map(e=>`<button type="button" class="rich-text-box-combobox-option" data-value="${e}" role="option">${e}</button>`).join("")}\n </div>\n </div>\n <label>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-margin" placeholder="10px" autocomplete="off">\n <label>Aria-label (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-aria-label">\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 <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-embed-float">\n <option value="none" selected>None</option>\n <option value="left">Left</option>\n <option value="right">Right</option>\n </select>\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" required>\n <label>Type</label>\n <div class="rich-text-box-combobox-wrap">\n <input class="rich-text-box-form-element rich-text-box-float-dropdown rich-text-box-combobox" type="text" id="rich-text-box-video-source-type" placeholder="None" autocomplete="off">\n <div class="rich-text-box-combobox-list" id="rich-text-box-video-source-type-list" role="listbox" hidden>\n ${["video/mp4","video/webm","video/ogg"].map(e=>`<button type="button" class="rich-text-box-combobox-option" data-value="${e}" role="option">${e}</button>`).join("")}\n </div>\n </div>\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 <label>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-margin" placeholder="10px" 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 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>Aria-label (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-aria-label">\n <label>Float</label>\n <select class="rich-text-box-form-element rich-text-box-float-dropdown" id="rich-text-box-video-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 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" required></textarea>\n <div class="rich-text-box-form-left">\n <label>Aria-label (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-code-aria-label">\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-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" required></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" required>\n <label>Alt Text (for screen readers)</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="rtb-upload-image-grid">\n <div class="rtb-upload-image-field rtb-upload-image-left">\n <div class="rtb-upload-image-file-row">\n <input type="file" id="rich-text-box-upload-image-file" class="rtb-visually-hidden-file" required>\n <label id="rich-text-box-upload-btn" for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn" tabindex="1" 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 </div>\n <div class="rtb-upload-image-field rtb-upload-image-left">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-width" tabindex="2" placeholder="400" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-right">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-height" tabindex="3" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-left">\n <label>Margin</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-margin" tabindex="4" placeholder="10px" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-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" tabindex="5">\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="rtb-upload-image-field rtb-upload-image-left">\n <label>Alt Text (for screen readers)</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-alt-text" tabindex="6" autocomplete="off">\n </div>\n <div class="rtb-upload-image-field rtb-upload-image-right">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-css-classes" tabindex="7" 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" required>\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" required>\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 class="rich-text-box-form-right">\n <label class="rich-text-box-form-checkbox-label" style="display:flex;align-items:center;margin-top:20px;"><input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox"> Open in New Tab</label>\n </div>\n </div>\n ')}\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>Toolbar</td><td>${k("Alt","F10")}</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>Context toolbar</td><td>${k("Alt","O")}</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><td>Increase indent</td><td>${k("Tab")}</td></tr>\n <tr><td>Decrease indent</td><td>${k("Shift","Tab")}</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>Maximize editor</td><td>${k("Ctrl","Shift","F")}</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 <tr><td>Escape editor</td><td>${k("Escape")}</td></tr>\n </tbody>\n </table>\n </div>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",x);
2
2
  //# sourceMappingURL=rt-native.js.map