import{c as t,M as e,V as s}from"./p-6e1ab235.js";import{i,j as n}from"./p-4dd02704.js";import{v as r}from"./p-5f377954.js";import{F as h}from"./p-18e8d9b7.js";var o=function(t,e,s,i){var n,r=arguments.length,h=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,s,i);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(h=(r<3?n(h):r>3?n(e,s,h):n(e,s))||h);return r>3&&h&&Object.defineProperty(e,s,h),h};class a 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(){h.isEnabled("VEGA_REACT.SKIP_NATIVE_EVENT_PREVENT_BY_DEFAULT")&&this.disabled&&this.host&&"react"===r.getVegaEnv().framework&&"native"===i.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(i.getSemantics(this.host))}shouldPrevent(t){const{namespace:e,jqueryDelegatedEvent:s}=i.getSemantics(this.host);return!("native"===e&&s&&n.isSupportDelegated(this.host,t))}shouldSkipEventPrevent(){const t=this.getHostElement();return t&&"true"===t.dataset.vegaNoEventPrevent}}o([t()],a.prototype,"host",void 0),o([e("connectedCallback")],a.prototype,"setup",null),o([e("componentDidLoad")],a.prototype,"checkEventListenerStatus",null),o([e("disconnectedCallback")],a.prototype,"destroy",null);export{a as C}