import{d as t}from"./p-7c87fba4.js";import{L as s,a as i}from"./p-1d7a7076.js";class e extends s{constructor(t){super(),this.tags=[],this.mutationObserver=void 0,this.mutationObserverInit={childList:!0,subtree:!0,attributes:!0,characterData:!0},this.mutationCallback=t=>t.some((t=>this.tags.includes(t.target.nodeName)))||t.some((t=>Array.from(t.removedNodes).some((t=>this.tags.includes(t.nodeName)))))||t.some((t=>"characterData"===t.type))||0===this.tags.length&&t.length>0?this.notify(void 0):void 0,this.tags=(t.tags||[]).map((t=>t.toUpperCase())),this.mutationObserverInit={childList:!1!==t.childList,subtree:!1!==t.subtree,attributes:!1!==t.attributes,characterData:!1!==t.characterData}}connect(t){super.connect(t),"undefined"!=typeof MutationObserver&&(this.destroyMutationObserver(),this.mutationObserver=new MutationObserver(this.mutationCallback),this.mutationObserver.observe(t,this.mutationObserverInit))}disconnect(){super.disconnect(),this.destroyMutationObserver()}destroyMutationObserver(){void 0!==this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=void 0)}}class h extends i{constructor(s){super((t=>{t.mutationObserverActive&&t.mutationListener()})),this.options=s,this.debouncedNotify=t((()=>this.notify()),50),this.listener=new e(s)}attach(t){var s,i,e;if(super.attach(t),this.options.closest){const i=t.el.closest(this.options.closest);i&&(null===(s=this.listener)||void 0===s||s.connect(i))}else null===(i=this.listener)||void 0===i||i.connect(t.el);null===(e=this.listener)||void 0===e||e.add((()=>this.debouncedNotify()))}detach(){var t;super.detach(),null===(t=this.listener)||void 0===t||t.disconnect()}}function r(t){return function(s){const{connectedCallback:i,disconnectedCallback:e}=s;s.connectedCallback=function(){return this._balMutationSubject=new h(t),this._balMutationSubject.attach(this),i&&i.call(this)},s.disconnectedCallback=function(){return this._balMutationSubject.detach(),e&&e.call(this)}}}export{r as L}