(()=>{function t(){document.getElementById("suggestions-container")&&document.getElementById("suggestions-container").remove()}document.addEventListener("DOMContentLoaded",(function(){wp.data.subscribe((function(){const{getSelectedBlock:e}=wp.data.select("core/block-editor"),n=e();if(null!==n){const{clientId:e}=n,o=document.querySelector(`.block-editor-block-list__block[data-block="${e}"]`);o?.addEventListener("input",(function(e){const n=e.data||"";if(" "===n||null===n)return void t();const o=window.getSelection(),c=function(t){if(!t)return"";const e=t.getRangeAt(0);e.collapse(!0);const n=e.startContainer,o=e.startOffset,c=n.textContent.substring(0,o).trim().split(/\s+/);return c[c.length-1]}(o);if(c.length>=3){const e=function(t){const e=t.split(/\s+/),n=e[e.length-1].toLowerCase(),o=betterDocsBlocksHelper?.betterdocs_glossaries;return o.filter((t=>t.toLowerCase().startsWith(n)))}(c);!function(t,e,n,o){let c=document.getElementById("suggestions-container");c||(c=document.createElement("div"),c.id="suggestions-container",document.body.appendChild(c)),c.innerHTML="";const{anchorNode:s,anchorOffset:i}=n,l=document.createRange();l.setStart(s,i);const d=l.getBoundingClientRect();c.style.position="absolute",c.style.top=`${d.bottom}px`,c.style.left=`${d.left}px`,e.forEach((t=>{const e=document.createElement("div");e.textContent=t,e.classList.add("suggestion-item"),e.addEventListener("click",(function(){!function(t,e){const n=wp.data.select("core/block-editor").getSelectedBlock(),o=document.querySelector(`.block-editor-block-list__block[data-block="${n.clientId}"]`).textContent.trim(),c=new RegExp("\\b"+e+"\\b","gi"),s=o.replace(c,t);wp.data.dispatch("core/block-editor").updateBlockAttributes(n.clientId,{content:s})}(t,o),c.remove()})),c.appendChild(e)}))}(0,e,o,c),e.length||t()}else t()}))}}))}))})();