!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ivent={})}(this,(function(e){"use strict";let t=1;function n(e,n){return n&&`${n}::${t++}`||e.uidEvent||t++}const o={};function r(e){const t=n(e);return e.uidEvent=t,o[t]=o[t]||{},o[t]}const c=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]),i=/[^.]*(?=\..*)\.|.*/,l=/\..*/,u={mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"};function a(e){const t=e.replace(l,"");return{event:u[t]||t,originalEvent:t,namespace:e.replace(i,"")||!1,isNative:c.has(t)}}function s(e,t,n){const o="string"==typeof t,r=o?n:t||n,c=a(e);let i=c.event;return c.isNative||(i=e),[o,r,i,c]}const f=/::\d+$/;function d(e,t,n,o){"string"==typeof t&&e&&t.split(" ").forEach((t=>{const[c,i,l,u]=s(t,n,o),a=r(e),d=a[l]||{},p=t.startsWith(".");if(void 0===i){if(p)for(const n of Object.keys(a))y(e,a,n,t.slice(1));for(const[n,o]of Object.entries(d)){const r=n.replace(f,"");u.namespace&&!t.includes(r)||m(e,a,l,o.callable,o.delegationSelector)}}else{if(!Object.keys(d).length)return;m(e,a,l,i,c?n:null)}}))}function p(e,t={}){for(const[n,o]of Object.entries(t))try{e[n]=o}catch{Object.defineProperty(e,n,{configurable:!0,get:()=>o})}return e}function g(e,t,n=null){return Object.values(e).find((e=>e.callable===t&&e.delegationSelector===n))}function v(e,t,o,c,i){let[l,u,a,f]=s(t,o,c);if(f.event!==f.originalEvent){const e=e=>function(t){return(!t.relatedTarget||t.relatedTarget!==t.delegateTarget&&!t.delegateTarget.contains(t.relatedTarget))&&e.call(this,t)};u=e(u)}const v=r(e),m=v[a]||(v[a]={}),y=g(m,u,l?o:null);if(y)return void(y.oneOff=y.oneOff&&i);const b=n(u,f.namespace),h=l?function(e,t,n){return function o(r){const c=e.querySelectorAll(t);for(let{target:i}=r;i&&i!==this;i=i.parentNode)for(const l of c)if(l===i)return p(r,{delegateTarget:i}),o.oneOff&&d(e,r.type,t,n),n.apply(i,[r]);return!1}}(e,o,u):function(e,t){return function n(o){return p(o,{delegateTarget:e}),n.oneOff&&d(e,o.type,t),t.apply(e,[o])}}(e,u);h.delegationSelector=l?o:null,h.callable=u,h.oneOff=i,h.uidEvent=b,m[b]=h,e!==document||"ready"!==a||l||(a="DOMContentLoaded","loading"===document.readyState)?e.addEventListener(a,h,l):h(new CustomEvent("ready"))}function m(e,t,n,o,r){const c=g(t[n],o,r);c&&(e.removeEventListener(n,c,Boolean(r)),delete t[n][c.uidEvent])}function y(e,t,n,o){const r=t[n]||{};for(const[c,i]of Object.entries(r))c.includes(o)&&m(e,t,n,i.callable,i.delegationSelector)}e.off=d,e.on=function(e,t,n,o){"string"==typeof t&&e&&t.split(" ").forEach((t=>{v(e,t,n,o,!1)}))},e.one=function(e,t,n,o){"string"==typeof t&&e&&t.split(" ").forEach((t=>{v(e,t,n,o,!0)}))},e.trigger=function(e,t,n){if("string"!=typeof t||!e)return null;const o=window.jQuery?window.jQuery:null;let r=null,c=!0,i=!0,l=!1;a(t).namespace&&o&&(r=o.Event(t,n),o(e).trigger(r),c=!r.isPropagationStopped(),i=!r.isImmediatePropagationStopped(),l=r.isDefaultPrevented());const u=p(new Event(t,{bubbles:c,cancelable:!0}),n);return l&&u.preventDefault(),i&&e.dispatchEvent(u),u.defaultPrevented&&r&&r.preventDefault(),u}}));