import{aD as t,aE as e,aF as s,w as i,v as n,aJ as h,aK as a}from"./p-BTBbFFOR.js";var r=function(t,e,s,i){var n,h=arguments.length,a=h<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var r=t.length-1;r>=0;r--)(n=t[r])&&(a=(h<3?n(a):h>3?n(e,s,a):n(e,s))||a);return h>3&&a&&Object.defineProperty(e,s,a),a};class o extends s{constructor(t,e,s,i){if(super(),this.eventIds=[],this.useCapture=!1,this.isEventListenerAdded=!1,this.disabled=!1,this.preventChildEvent=t=>{const e=this.getHostElement();if(!this.shouldSkipEventPrevent())if("function"==typeof this.customPreventHandle)this.customPreventHandle(t);else{const s=t.composedPath();e===t.target&&e===s[0]||t.stopImmediatePropagation()}},this.eventIds=t,this.getHostElement=e,!0===s)this.useCapture=!0;else if(s){const{useCapture:t=!1,customPreventHandle:e}=s;this.useCapture=t,this.customPreventHandle=e}this.disabled=!0===i}setup(){this.addOrRemoveEventListener("add")}checkEventListenerStatus(){this.isEventListenerAdded||this.setup(),this.setSkipEventPreventFlag()}destroy(){this.addOrRemoveEventListener("remove")}setSkipEventPreventFlag(){i.isEnabled("VEGA_REACT.SKIP_NATIVE_EVENT_PREVENT_BY_DEFAULT")&&this.disabled&&this.host&&"react"===n.getVegaEnv().framework&&"native"===h.getSemantics(this.host).namespace&&this.getHostElement().setAttribute("data-vega-no-event-prevent","true")}addOrRemoveEventListener(t){const e=this.getHostElement();this.eventIds&&this.eventIds.length&&e&&(this.eventIds.filter((t=>this.shouldPrevent(t))).forEach((s=>{e["add"===t?"addEventListener":"removeEventListener"](this.getCurrentEventName(s),this.preventChildEvent,this.useCapture)})),this.isEventListenerAdded="add"===t)}getCurrentEventName(t){return t.getCurrentName(h.getSemantics(this.host))}shouldPrevent(t){const{namespace:e,jqueryDelegatedEvent:s}=h.getSemantics(this.host);return!("native"===e&&s&&a.isSupportDelegated(this.host,t))}shouldSkipEventPrevent(){const t=this.getHostElement();return t&&"true"===t.dataset.vegaNoEventPrevent}}r([t()],o.prototype,"host",void 0),r([e("connectedCallback")],o.prototype,"setup",null),r([e("componentDidLoad")],o.prototype,"checkEventListenerStatus",null),r([e("disconnectedCallback")],o.prototype,"destroy",null);export{o as C}