import{t as e}from"../../preload-helper-4XLmkqGS.js";var t=()=>{let e=document.getElementById(`etch-iframe`);return e?.contentDocument||e?.contentWindow?.document||null};(async()=>{for(;!t()?.querySelector(`body`);)await new Promise(e=>setTimeout(e,100));console.log(`[Omni Icon] Etch editor detected, initializing...`);let[{openIconPicker:n,closeIconPicker:r,renderModal:i},a,o]=await Promise.all([e(()=>import(`../../editor-app-By3_GhwB.js`),[],import.meta.url),e(()=>import(`../../webcomponent-injector-DsXf2olS.js`),[],import.meta.url),e(()=>import(`../../element-menu-button-C11hQv_i.js`),[],import.meta.url),e(()=>import(`../../element-settings-panel-BT8eD30l.js`),[],import.meta.url)]);console.log(`[Omni Icon] Modules loaded, initializing modal...`),i(),window.omniIconPicker={open:(e,t)=>{n(e||``,t||(()=>{}))},close:r};let s=()=>{let e=t();e&&(new MutationObserver(()=>{let e=t();e&&e.querySelectorAll(`.etch-html-block-properties-wrapper:not([data-omni-icon-injected])`).forEach(e=>{e.setAttribute(`data-omni-icon-injected`,`true`),c(e)})}).observe(e,{subtree:!0,childList:!0}),console.log(`[Omni Icon] Etch observer initialized`))},c=e=>{let t=document.createElement(`button`);t.type=`button`,t.className=`etch-builder-button etch-builder-button--variant-primary omni-icon-picker-button`,t.textContent=`🎨 Select Icon`,t.style.marginTop=`8px`,t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),n(``,e=>{console.log(`[Omni Icon] Icon selected:`,e),l(e)})}),e.appendChild(t),console.log(`[Omni Icon] Icon picker button injected`)},l=e=>{let n=t();if(!n){console.error(`[Omni Icon] Could not access Etch iframe document`);return}let r=`<omni-icon name="${e}" width="24" height="24"></omni-icon>`;try{let t=n.getSelection();if(t&&t.rangeCount>0){let e=t.getRangeAt(0);e.deleteContents();let i=n.createElement(`div`);i.innerHTML=r;let a=i.firstChild;a&&(e.insertNode(a),e.collapse(!1),t.removeAllRanges(),t.addRange(e))}else{let e=n.querySelector(`body`);e&&e.insertAdjacentHTML(`beforeend`,r)}console.log(`[Omni Icon] Icon inserted into editor:`,e)}catch(e){console.error(`[Omni Icon] Error inserting icon:`,e)}};s(),console.log(`[Omni Icon] Etch integration initialized successfully`)})();