function t(t){return"string"!=typeof t||""===t?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(t)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)}function n(t){return"string"!=typeof t||""===t?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(t)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(t)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)}function e(e,r){return function(i,o,s,c=10){const u=e[r];if(!n(i))return;if(!t(o))return;if("function"!=typeof s)return void console.error("The hook callback must be a function.");if("number"!=typeof c)return void console.error("If specified, the hook priority must be a number.");const l={callback:s,priority:c,namespace:o};if(u[i]){const t=u[i].handlers;let n;for(n=t.length;n>0&&!(c>=t[n-1].priority);n--);n===t.length?t[n]=l:t.splice(n,0,l),u.__current.forEach((t=>{t.name===i&&t.currentIndex>=n&&t.currentIndex++}))}else u[i]={handlers:[l],runs:0};"hookAdded"!==i&&e.doAction("hookAdded",i,o,s,c)}}function i(e,r,i=!1){return function(o,s){const c=e[r];if(!n(o))return;if(!i&&!t(s))return;if(!c[o])return 0;let u=0;if(i)u=c[o].handlers.length,c[o]={runs:c[o].runs,handlers:[]};else{const t=c[o].handlers;for(let n=t.length-1;n>=0;n--)t[n].namespace===s&&(t.splice(n,1),u++,c.__current.forEach((t=>{t.name===o&&t.currentIndex>=n&&t.currentIndex--})))}return"hookRemoved"!==o&&e.doAction("hookRemoved",o,s),u}}function s(t,n){return function(e,r){const i=t[n];return void 0!==r?e in i&&i[e].handlers.some((t=>t.namespace===r)):e in i}}function r(t,n,e=!1){return function(r,...i){const o=t[n];o[r]||(o[r]={handlers:[],runs:0}),o[r].runs++;const s=o[r].handlers;if(!s||!s.length)return e?i[0]:void 0;const c={name:r,currentIndex:0};for(o.__current.push(c);c.currentIndex<s.length;){const t=s[c.currentIndex].callback.apply(null,i);e&&(i[0]=t),c.currentIndex++}return o.__current.pop(),e?i[0]:void 0}}function o(t,n){return function(){var e;const r=t[n];return null!==(e=r.__current[r.__current.length-1]?.name)&&void 0!==e?e:null}}function u(t,n){return function(e){const r=t[n];return void 0===e?void 0!==r.__current[0]:!!r.__current[0]&&e===r.__current[0].name}}function c(t,e){return function(r){const i=t[e];if(n(r))return i[r]&&i[r].runs?i[r].runs:0}}class f{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=e(this,"actions"),this.addFilter=e(this,"filters"),this.removeAction=i(this,"actions"),this.removeFilter=i(this,"filters"),this.hasAction=s(this,"actions"),this.hasFilter=s(this,"filters"),this.removeAllActions=i(this,"actions",!0),this.removeAllFilters=i(this,"filters",!0),this.doAction=r(this,"actions"),this.applyFilters=r(this,"filters",!0),this.currentAction=o(this,"actions"),this.currentFilter=o(this,"filters"),this.doingAction=u(this,"actions"),this.doingFilter=u(this,"filters"),this.didAction=c(this,"actions"),this.didFilter=c(this,"filters")}}function l(){return new f}const a=l(),{addAction:h,addFilter:d,removeAction:m,removeFilter:p,hasAction:A,hasFilter:b,removeAllActions:y,removeAllFilters:k,doAction:v,applyFilters:F,currentAction:g,currentFilter:T,doingAction:_,doingFilter:z,didAction:Z,didFilter:w,actions:j,filters:x}=a;export{F as a};