UNPKG

@creejs/commons-events

Version:
1 lines 67.6 kB
{"version":3,"file":"index-dev.cjs","sources":["../../../lang/dist/esm/index-min.js","../../lib/constants.js","../../lib/listener.js","../../lib/event.js","../../lib/event-emitter.js"],"sourcesContent":["const t={NOT_FOUND:404,NOT_SUPPORTED:505,NOT_IMPL:501};class r extends Error{static get Code(){return t}static isErrorLike(t){return null!=t&&(\"_\"===t._type&&\"number\"==typeof t.code)}static notFound(t){return new r(`Not Found: ${t}`,404)}static notImpled(){return new r(\"Not Impled Yet\",501)}static notSupported(t){return new r(\"Not Supported:\"+t,505)}static isNotSupported(t){return 505===t?.code}constructor(t,r){super(t),this._type=\"_\",this.code=r}}class e extends Error{static isAggregatedErrorLike(t){return t&&Array.isArray(t.errors)}static isAggregatedError(t){return t instanceof e}constructor(t,r){super(t),this.errors=r??[]}addError(t){this.errors.push(t)}removeError(t){const r=this.errors.indexOf(t);return-1!==r&&(this.errors.splice(r,1),!0)}}var n={constructorName:o,defaults:function(t,...r){if(null==t)throw new TypeError('\"target\" Should Not Nil');for(const e of r)if(null!=e)for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t},extend:i,extends:i,equals:function(t,r){if(t===r)return!0;if(\"function\"==typeof t?.equals)return t.equals(r);if(\"function\"==typeof r?.equals)return r.equals(t);return!1},isBrowser:s,isNode:function(){return!s()},cloneToPlainObject:function(t){if(null==t)return t;if(\"object\"!=typeof t)throw new Error(\"Only Object allowed to clone\");return{...t}},deepCloneToPlainObject:function(t){if(null==t)return t;if(\"object\"!=typeof t)throw new Error(\"Only Object allowed to clone\");return JSON.parse(JSON.stringify(t))}};function o(t){return t?.constructor?.name}function i(t,...r){if(null==t)throw new TypeError('\"target\" must not be null or undefined');for(const e of r)if(null!=e)for(const r in e)t[r]=e[r];return t}function s(){return\"undefined\"!=typeof window&&\"undefined\"!=typeof document}var u={isArray:f,isBoolean:a,isBuffer:function(t){return null!=t&&Buffer.isBuffer(t)},isFunction:c,isInstance:l,isIterable:function(t){return null!=t&&\"function\"==typeof t[Symbol.iterator]},isDate:function(t){return null!=t&&t instanceof Date},isError:function(t){return null!=t&&t instanceof Error},isMap:function(t){return null!=t&&\"object\"==typeof t&&t.constructor===Map},isWeakMap:function(t){return null!=t&&\"object\"==typeof t&&t.constructor===WeakMap},isNumber:m,isPositive:p,isNegative:g,isNotNegative:h,isNil:y,isNullOrUndefined:function(t){return null==t},isNull:w,isUndefined:d,isPlainObject:A,isObject:b,isPromise:E,isRegExp:function(t){return null!=t&&\"object\"==typeof t&&t.constructor===RegExp},isSet:function(t){return null!=t&&\"object\"==typeof t&&t.constructor===Set},isWeakSet:function(t){return null!=t&&\"object\"==typeof t&&t.constructor===WeakSet},isStream:function(t){return null!=t&&\"function\"==typeof t.pipe},isString:N,isSymbol:$,isPrimitive:function(t){return null!==t&&(\"string\"==typeof t||\"number\"==typeof t||\"boolean\"==typeof t)},isInt8Array:v,isUint8Array:j,isUint8ClampedArray:P,isInt16Array:S,isUint16Array:x,isInt32Array:U,isUint32Array:T,isFloat32Array:I,isFloat64Array:B,isBigInt64Array:k,isBigUint64Array:L,isTypedArray:O,isArrayBuffer:F};function f(t){return Array.isArray(t)}function a(t){return\"boolean\"==typeof t}function c(t){return\"function\"==typeof t}function l(t){return null!=t&&\"object\"==typeof t&&!A(t)}function y(t){return null==t}function p(t){return!!m(t)&&t>0}function h(t){return!!m(t)&&t>=0}function g(t){return!!m(t)&&t<0}function w(t){return null===t}function d(t){return void 0===t}function m(t){return null!=t&&\"number\"==typeof t}function b(t){return null!=t&&\"object\"==typeof t}function A(t){return null!==t&&\"object\"==typeof t&&(t.constructor===Object||void 0===t.constructor)}function E(t){return null!=t&&\"function\"==typeof t.then}function N(t){return null!=t&&\"string\"==typeof t}function $(t){return null!=t&&\"symbol\"==typeof t}function O(t){return ArrayBuffer.isView(t)&&t.constructor!==DataView}function v(t){return t instanceof Int8Array}function j(t){return t instanceof Uint8Array}function P(t){return t instanceof Uint8ClampedArray}function S(t){return t instanceof Int16Array}function x(t){return t instanceof Uint16Array}function U(t){return t instanceof Int32Array}function T(t){return t instanceof Uint32Array}function I(t){return t instanceof Float32Array}function B(t){return t instanceof Float64Array}function k(t){return t instanceof BigInt64Array}function L(t){return t instanceof BigUint64Array}function F(t){return t instanceof ArrayBuffer}var C={assertNumber:q,assertPositive:_,assertNegative:function(t,r){if(!g(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Negative: ${t}`)},assertNotNegative:J,assertBoolean:function(t,r){if(!a(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Boolean: type=${typeof t} value=${Z(t)}`)},assertObject:R,assertPlainObject:function(t,r){if(!A(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not PlainObject: type=${typeof t} value=${Z(t)}`)},assertSymbol:function(t,r){if(!$(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Symbol: type=${typeof t} value=${Z(t)}`)},assertFunction:W,assertInstance:function(t,r){if(!l(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Class Instance: type=${typeof t} value=${Z(t)}`)},assertPromise:H,assertNil:function(t,r){if(!y(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Neither Null nor Undefined: type=${typeof t} value=${Z(t)}`)},assertNotNil:V,assertNull:function(t,r){if(!w(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Null: type=${typeof t} value=${Z(t)}`)},assertNotNull:function(t,r){if(w(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Should Not Null\")},assertUndefined:function(t,r){if(!d(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Undefined: type=${typeof t} value=${Z(t)}`)},assertString:M,assertArray:D,assertStringOrSymbol:function(t,r){if(!N(t)&&!$(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not String or Symbol: type=${typeof t} value=${Z(t)}`)},assertInt8Array:function(t,r){if(v(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Int8Array\")},assertUint8Array:function(t,r){if(j(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Uint8Array\")},assertUint8ClampedArray:function(t,r){if(P(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Uint8ClampedArray\")},assertInt16Array:function(t,r){if(S(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Int16Array\")},assertUint16Array:function(t,r){if(x(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Uint16Array\")},assertInt32Array:function(t,r){if(U(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Int32Array\")},assertUint32Array:function(t,r){if(T(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Uint32Array\")},assertFloat32Array:function(t,r){if(I(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Float32Array\")},assertFloat64Array:function(t,r){if(B(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not Float64Array\")},assertBigInt64Array:function(t,r){if(k(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not BigInt64Array\")},assertBigUint64Array:function(t,r){if(L(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not BigUint64Array\")},assertTypedArray:function(t,r){if(O(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not TypedArray\")},assertArrayBuffer:z};function D(t,r){if(!Array.isArray(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Array: type=${typeof t} value=${Z(t)}`)}function M(t,r){if(!N(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not String: type=${typeof t} value=${Z(t)}`)}function q(t,r){if(!m(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Number: type=${typeof t} value=${Z(t)}`)}function _(t,r){if(!p(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Positive: ${t}`)}function J(t,r){if(!h(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not \"0 or Positive\": ${t}`)}function R(t,r){if(!b(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Object: type=${typeof t} value=${Z(t)}`)}function W(t,r){if(!c(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Function: type=${typeof t} value=${Z(t)}`)}function H(t,r){if(!E(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Not Promise: type=${typeof t} value=${Z(t)}`)}function V(t,r){if(y(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Should Not Nil\")}function z(t,r){if(!F(t))throw new Error((r?'\"'+r+'\" ':\"\")+\"Not ArrayBuffer\")}var G={isEmpty:K,assertNotEmpty:Y,isBlank:Q,assertNotBlank:function(t,r){if(Q(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}Is Blank: ${t}`)},capitalize:function(t){if(M(t),0===t.length)return t;const r=t.charAt(0),e=r.toUpperCase();return r===e?t:e+t.slice(1)},decapitalize:function(t){if(M(t),0===t.length)return t;const r=t.charAt(0),e=r.toLowerCase();return r===e?t:e+t.slice(1)},splitWithFixedLength:function(t,r,e=\" \"){if(M(t),q(r),M(e),0===t.length)return[];if(r<=0)throw new Error(\"length muse >=0\");if(t.length<r)return[t.padEnd(r,e)];const n=[];for(let o=0;o<t.length;o+=r){const i=t.substring(o,o+r);n.push(i.padEnd(r,e))}return n},split:function(t,...r){M(t);if(0===t.length)return[];const e=[...r];0===r.length&&r.push(\",\");const n=X(t,...e);if(0===n.length)return[];const o=[];let i=\"\",s=0;for(const{marker:r,index:e}of n)i=t.substring(s,e),o.push(i),s=e+r.length;return i=t.substring(s),o.push(i),o},findMarkerPositions:function(t,...r){if(M(t),0===r.length)throw new Error(\"At least one marker must be provided\");const e=[];for(const n of new Set(r)){if(K(n))continue;M(n);let r=t.indexOf(n);for(;-1!==r;)e.push({marker:n,index:r}),r=t.indexOf(n,r+n.length)}return e.sort((t,r)=>t.index-r.index),e},findMarkerPositionsRegex:X,substringBefore:function(t,r){if(M(t),M(r),0===t.length||0===r.length)return;const e=t.indexOf(r);if(-1===e)return;return t.substring(0,e)},substringBeforeLast:function(t,r){if(M(t),M(r),0===t.length||0===r.length)return;const e=t.lastIndexOf(r);if(-1===e)return;return t.substring(0,e)},substringAfter:function(t,r){if(M(t),M(r),0===t.length||0===r.length)return;const e=t.indexOf(r);if(-1===e)return;return t.substring(e+r.length)},substringAfterLast:function(t,r){if(M(t),M(r),0===t.length||0===r.length)return;const e=t.lastIndexOf(r);if(-1===e)return;return t.substring(e+r.length)},substringBetween:function(t,r,e){Y(t),Y(r),Y(e);const n=t.indexOf(r);if(-1===n)return;const o=t.indexOf(e,n+r.length);if(-1===o)return;return t.substring(n+r.length,o)},substringBetweenGreedy:function(t,r,e){Y(t),Y(r),Y(e);const n=t.indexOf(r);if(-1===n)return;const o=t.lastIndexOf(e);if(-1===o||o<=n)return;return t.substring(n+r.length,o)},substringsBetween:function(t,r,e){Y(t),Y(r),Y(e);const n=[];let o=0;for(;;){const i=t.indexOf(r,o);if(-1===i)break;const s=t.indexOf(e,i+r.length);if(-1===s)break;n.push(t.substring(i+r.length,s)),o=s+e.length}return n},safeToString:Z};function K(t){return null==t||(M(t),0===t.length)}function Y(t,r){if(K(t))throw new Error(`${r?'\"'+r+'\" ':\"\"}IsEmpty String: ${t}`)}function Q(t){return null==t||(M(t),0===t.trim().length)}function X(t,...r){if(M(t),0===r.length)throw new Error(\"At least one marker must be provided\");const e=[...new Set(r.filter(t=>null!=t))].map(t=>(M(t),t.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\"))),n=new RegExp(e.map(t=>`(${t})`).join(\"|\"),\"g\"),o=[];let i=null;for(;null!==(i=n.exec(t));){for(let t=1;t<i.length;t++)if(i[t]){o.push({marker:r[t-1],index:i.index});break}0===i[0].length&&n.lastIndex++}return o}function Z(t){if(null===t)return\"null\";if(void 0===t)return\"undefined\";let r;try{r=JSON.stringify(t)}catch(e){r=t.toString()}return r}var tt={quiet:function(t,r){W(t);try{const e=t();return E(e)?e.catch(t=>{r&&r.isErrorEnabled()&&r.error(\"quiet() with async error:\",t)}):e}catch(t){r&&r.isErrorEnabled()&&r.error(\"quiet() with sync error:\",t)}},quietKeepError:function(t,r){W(t),D(r);try{const e=t();return E(e)?e.catch(t=>r.push(t)):e}catch(t){r.push(t)}}},rt={any:function(t){if(D(t),0===t.length)throw new Error(\"Empty Tasks\");const r=et(),n=[];for(let o=0;o<t.length;o++){const i=t[o];let s;if(u.isPromise(i))s=i;else{if(!u.isFunction(i)){n.push(new Error(`Invalid Task at index ${o}/${t.length-1}: ${i}`));continue}s=ot(i)}s.then(t=>{r.resolve(t)}).catch(o=>{n.push(o),n.length>=t.length&&r.reject(new e(\"All Tasks Failed\",n))})}n.length===t.length&&r.reject(new e(\"All Tasks Failed\",n));return r.promise},defer:et,delay:function(t,r){u.isNumber(t)?(r=t,t=Promise.resolve()):null==t&&null==r&&(r=1,t=Promise.resolve());null!=t&&H(t),q(r=r??1e3);const e=et(),n=Date.now();return t.then((...t)=>{const o=Date.now()-n;o<r?setTimeout(()=>e.resolve(...t),r-o):e.resolve(...t)}).catch(t=>{const o=Date.now()-n;o<r?setTimeout(()=>e.reject(t),r-o):e.reject(t)}),e.promise},timeout:function(t,r,e){H(t),q(r=r??1);const n=et(r,e),o=Date.now();return t.then((...t)=>{Date.now()-o<=r?n.resolve(...t):n.reject(new Error(e??`Promise Timeout: ${r}ms`))}).catch(t=>{!n.resolved&&!n.rejected&&n.reject(t)}),n.promise},allSettled:nt,returnValuePromised:ot,series:async function(t){D(t);const r=[];for(const e of t)if(W(e),u.isFunction(e))r.push(await ot(e));else{if(!u.isPromise(e))throw new Error(`Invalid Task: ${e}`);r.push(await e)}return r},seriesAllSettled:async function(t){D(t);const r=[];for(const e of t){W(e);try{r.push({ok:!0,result:await e()})}catch(t){r.push({ok:!1,result:t})}}return r},parallel:async function(t,r=5){if(D(t),q(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>W(t));const e=[];if(t.length<=r){const r=await Promise.all(t.map(t=>ot(t)));return e.push(...r),e}const n=[];for(const o of t)if(W(o),n.push(o),n.length>=r){const t=await Promise.all(n.map(t=>ot(t)));e.push(...t),n.length=0}if(n.length>0&&n.length<r){const t=await Promise.all(n.map(t=>ot(t)));e.push(...t)}return e},parallelAny:async function(t,r=5){if(D(t,\"tasks\"),q(r),0===t.length)throw new Error(\"Empty Tasks\");if(r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);const n=[];let o=0,i=0;const s=et();function f(){if(o>=t.length)return;if(i>r)return;const a=t[o++];let c;i++,c=u.isPromise(a)?a:u.isFunction(a)?ot(a):Promise.reject(new TypeError(`Invalid task: ${typeof a}, Only Promise or Function allowed`)),c.then(t=>{i--,s.resolve(t)}).catch(r=>{n.push(r),n.length>=t.length&&s.pending?s.reject(new e(\"All Tasks Failed\",n)):(i--,f())})}const a=Math.min(t.length,r);for(let t=0;t<a;t++)f();return s.promise},parallelAllSettled:async function(t,r=5){if(D(t),q(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>W(t));const e=[];if(t.length<=r){const r=await nt(t.map(t=>ot(t)));return e.push(...r),e}const n=[];for(const o of t)if(n.push(o),n.length>=r){const t=await nt(n.map(t=>ot(t)));e.push(...t),n.length=0}if(n.length>0&&n.length<r){const t=await nt(n.map(t=>ot(t)));e.push(...t)}return e},wait:function(t){J(t);const r={};let e;return r.timerHandler=e=setTimeout(()=>{clearTimeout(e),r._resolve()},t),r.promise=new Promise((t,n)=>{r._resolve=r=>{null!=e&&clearTimeout(e),t(r)}}),r.wakeup=()=>{r._resolve()},r}};function et(t=-1,r){q(t);const e={};let n;return e.pending=!0,e.canceled=!1,e.rejected=!1,e.resolved=!1,t>=0&&(e.timerCleared=!1,e.timerHandler=n=setTimeout(()=>{clearTimeout(n),e.timerCleared=!0,e.reject(new Error(r??`Promise Timeout: ${t}ms`))},t)),e.promise=new Promise((t,r)=>{e.resolve=r=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.pending=!1,e.canceled=!1,e.rejected=!1,e.resolved=!0,t(r))},e.reject=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.pending=!1,e.canceled=!1,e.resolved=!1,e.rejected=!0,r(t))}}),e.cancel=e.promise.cancel=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.reject(t??new Error(\"Cancelled\")),e.canceled=e.promise.canceled=!0)},e}async function nt(t){D(t);const r=await Promise.allSettled(t),e=[];for(const t of r)\"fulfilled\"===t.status&&e.push({ok:!0,result:t.value}),\"rejected\"===t.status&&e.push({ok:!1,result:t.reason});return e}function ot(t){try{const r=t();return u.isPromise(r)?r:Promise.resolve(r)}catch(t){return Promise.reject(t)}}const{isPlainObject:it}=u;var st={proxy:ut,newProxyInstance:function(t,r,e,n=!0){const o=ut(t,e,n);return Reflect.construct(o,r??[])}};function ut(t,r,e=!0){if(\"function\"!=typeof t)throw new TypeError(`Not Class: type=${typeof t}, value=${JSON.stringify(t)}`);if(null!=r){if(!it(r))throw new TypeError(`Not PropertyHandler: type=${typeof r}, value=${JSON.stringify(r)}`);const{get:t,set:e}=r;if(null!=t&&\"function\"!=typeof t)throw new TypeError(`Not PropertyHandler.get: type=${typeof t}, value=${JSON.stringify(t)}`);if(null!=e&&\"function\"!=typeof e)throw new TypeError(`Not PropertyHandler.set: type=${typeof e}, value=${JSON.stringify(e)}`)}const n={construct(t,n,o){const i=Reflect.construct(t,n);return new Proxy(e?Object.preventExtensions(i):i,r??{})}};return new Proxy(t,n)}var ft={proxy:function(t,r,e=!0){if(y(t)||!b(t)||f(t))throw new TypeError(`Not Object: type=${typeof t}, value=${JSON.stringify(t)}`);return new Proxy(e?Object.preventExtensions(t):t,r??{})}};function at(t){R(t,\"obj\");const r=new Set;let e=t;for(;e&&e!==Object.prototype;){const n=Object.getOwnPropertyNames(e);for(const e of n)\"constructor\"!==e&&\"function\"==typeof t[e]&&r.add(e);e=Object.getPrototypeOf(e)}return[...new Set(r)]}var ct={getMethodsOfClass:function(t){W(t,\"cls\");const r=new Set;let e=t.prototype;for(;e&&e!==Object.prototype;){const t=Object.getOwnPropertyNames(e);for(const n of t)\"constructor\"!==n&&\"function\"==typeof e[n]&&r.add(n);e=Object.getPrototypeOf(e)}return[...new Set(r)]},getStaticMethodsOfClass:function(t){W(t,\"cls\");const r=new Set;let e=t;for(;e&&e!==Object.getPrototypeOf(Object);){const t=Object.getOwnPropertyNames(e);for(const n of t)\"function\"==typeof e[n]&&r.add(n);e=Object.getPrototypeOf(e)}return[...r]},getMethods:at,getMethodsOfObject:at},lt={startsWith:function(t,r){V(t,\"src\"),V(r,\"searching\");return pt(t.subarray(0,r.length),r)},isSameType:yt,equals:pt};function yt(t,r){return V(t,\"src\"),V(r,\"target\"),o(t)===o(r)}function pt(t,r){if(V(t,\"src\"),V(r,\"target\"),!yt(t,r))return!1;if(t.byteLength!==r.byteLength)return!1;const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let r=0;r<t.byteLength;r++)if(e.getUint8(r)!==n.getUint8(r))return!1;return!0}var ht={readString:function(t,r=0,e){if(z(t),J(r),r>=t.byteLength)return;let n=null;null!=e?(_(e),n=r+e>=t.byteLength?new Uint8Array(t,r):new Uint8Array(t,r,e)):n=new Uint8Array(t,r);return gt.decode(n)},writeString:function(t,r,e=0){z(t,\"buffer\"),M(r,\"str\"),J(e,\"offset\");const n=wt.encode(r),o=n.byteLength;if(e+o>t.byteLength)throw new Error(`offset + str.byteLength > buffer.byteLength:${e+o} > ${t.byteLength}`);new Uint8Array(t,e,n.byteLength).set(n)},writeArrayBuffer:function(t,r,e=0,n=0,o){z(t),z(r),q(e),q(n);const i=t.byteLength;if(e<-1*i)e=0;else if(e<0)e+=i;else if(e>=i)throw new Error(`Out of target Bounds: targetOffset(${e}) >= targetLength(${i})`);const s=r.byteLength;if(n<-1*s)n=0;else if(n<0)n+=s;else if(n>=s)throw new Error(`Out of data Bounds: dataOffset(${n}) >= dataArrayBufferLength(${s})`);null!=o&&(_(o,\"dataLength\"),n+o>s&&(o=void 0));const u=new Uint8Array(r,n,o);if(u.byteLength>i-e)throw new Error(`Out of target Bounds: from targetOffset(${e}), No Space to store dataArrayBuffer(${n}, ${o??\"NoLimit\"})`);new Uint8Array(t).set(u,e)}};const gt=new TextDecoder,wt=new TextEncoder;const dt=1e6;var mt={s2ns:1e9,ms2ns:dt,timestamp:function(){if(\"undefined\"!=typeof performance&&\"number\"==typeof performance.timeOrigin){const t=performance.timeOrigin,r=performance.now();return Math.ceil((t+r)/dt)}return Date.now()},timestamp64:bt,lapseNano:At,lapseMillis:Et,timeoutNano:function(t,r){return At(t)>r},timeoutMillis:function(t,r){return Et(t)>r}};function bt(){if(\"undefined\"!=typeof performance&&\"number\"==typeof performance.timeOrigin){const t=performance.timeOrigin,r=performance.now();return BigInt((t+r)*dt)}return BigInt(Date.now()*dt)}function At(t,r){return(r??bt())-t}function Et(t,r){r=r??bt();return BigInt(r-t)/BigInt(dt)}var Nt={first:function(t,r){return D(t,\"arr\"),t[0]??r},chunk:function(t,r){if(D(t,\"array\"),_(r,\"size\"),t.length<=r)return t;const e=[];let n=0;for(;n<t.length;)e.push(t.slice(n,r+n)),n+=r;return e},last:function(t,r){return D(t,\"arr\"),t[t.length-1]??r},equals:function(t,r,e){if(!Array.isArray(t)||!Array.isArray(r))return!1;if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(e){if(0!==e(t[n],r[n]))return!1}else if(t[n]!==r[n])return!1;return!0},equalsIgnoreOrder:function(t,r,e){if(!Array.isArray(t)||!Array.isArray(r))return!1;if(t.length!==r.length)return!1;t.sort(e),r.sort(e);for(let n=0;n<t.length;n++)if(e){if(0!==e(t[n],r[n]))return!1}else if(t[n]!==r[n])return!1;return!0}};var $t={_Error:r,AggregatedError:e,LangUtils:n,StringUtils:G,TypeUtils:u,TypeAssert:C,ExecUtils:tt,PromiseUtils:rt,Lang:n,Type:u,Exec:tt,ClassProxyUtils:st,InstanceProxyUtils:ft,ReflectUtils:ct,TypedArrayUtils:lt,ArrayBufferUtils:ht,TimeUtils:mt,ArrayUtils:Nt};export{e as AggregatedError,ht as ArrayBufferUtils,Nt as ArrayUtils,st as ClassProxyUtils,tt as Exec,tt as ExecUtils,ft as InstanceProxyUtils,n as Lang,n as LangUtils,rt as PromiseUtils,ct as ReflectUtils,G as StringUtils,mt as TimeUtils,u as Type,C as TypeAssert,u as TypeUtils,lt as TypedArrayUtils,r as _Error,$t as default};\n//# sourceMappingURL=index-min.js.map\n","export const DefaultOwner = 'DOwner$#$'\nexport default {\n DefaultOwner\n}\n","// 3rd\n// internal\nimport { TypeAssert } from '@creejs/commons-lang'\n\n// owned\nimport { DefaultOwner } from './constants.js'\n\n// module vars\nconst { assertFunction, assertNotNil } = TypeAssert\n/**\n * Wraps a function to be called when an event is fired.\n * @typedef {import('./event.js').default} Event\n * @class Listener\n */\nexport default class Listener {\n /**\n * @param {Event} event\n * @param {function} callback - The function to be called when event is fired\n * @param {boolean} [isOnce=false] - is a one time listener?\n */\n constructor (event, callback, isOnce = false) {\n assertNotNil(event, 'event')\n assertFunction(callback, 'callback')\n this._event = event\n this._callback = callback\n this._isOnce = !!isOnce // is Once Listener?\n this._owner = undefined\n }\n\n /**\n * Sets the owner of this listener.\n * @param {*} owner - The owner object to be associated with this listener.\n */\n set owner (owner) {\n this._owner = owner\n }\n\n get owner () {\n return this._owner === DefaultOwner ? undefined : this._owner\n }\n\n get event () {\n return this._event\n }\n\n get isOnce () {\n return this._isOnce\n }\n\n /**\n * Checks if the provided function is the same as the listener's wrapped function.\n * @param {Function} callback - The function to compare against.\n * @returns {boolean} True if the functions are the same, false otherwise.\n */\n isSameCallback (callback) {\n return this._callback === callback\n }\n\n get callback () {\n return this._callback\n }\n\n /**\n * Invokes the stored function with the provided arguments.\n * @param {...*} args - Arguments to pass to the function.\n * @returns {*} The result of the function invocation.\n */\n invoke (...args) {\n try {\n return this._callback(...args)\n } finally {\n if (this._isOnce) {\n try {\n this._event._remove(this)\n } catch (err) {\n // do nothing\n console.warn(err)\n }\n }\n }\n }\n\n /**\n * Invokes the listener with the provided arguments.\n * Alias for {@linkcode Listener.invoke}\n * @param {...*} args - Arguments to be passed to the listener.\n * @returns {*} The result of the listener invocation.\n */\n listener (...args) {\n return this.invoke(...args)\n }\n}\nexport { Listener as ListenerType }\n","// 3rd\n// internal\nimport { TypeUtils, TypeAssert } from '@creejs/commons-lang'\n\n// owned\n// eslint-disable-next-line no-unused-vars\nimport Listener from './listener.js'\nimport { DefaultOwner } from './constants.js'\n\n// module vars\nconst { isFunction, isNil } = TypeUtils\nconst { assertStringOrSymbol, assertFunction } = TypeAssert\n\n/**\n * An Event definition\n * 1. listeners are grouped by owner\n * * if not specified, group it into one Default owner\n * 2. one listener may belong to multiple owners\n * 3. one owner may have multiple listeners\n */\nexport default class Event {\n static get DefaultOwner () {\n return DefaultOwner\n }\n\n /**\n * Creates a new Event instance with the specified name.\n * @param {string|Symbol} eventName - The name of the event.\n */\n constructor (eventName) {\n assertStringOrSymbol(eventName, 'eventName')\n this._name = eventName\n /**\n * use Set to store unique listeners\n * @type {Set<function>}\n */\n this._callbacks = new Set()\n /**\n * @type {Array<Listener>}\n */\n this._listeners = [] // user array to keep order\n /**\n * @type {Map<function, Set<Listener>>}\n */\n this._callback2Listeners = new Map()\n /**\n * use listener to index owners. One Listener Instance only belongs to one owner\n * @type {Map<Listener, *>}\n */\n this._listener2Owner = new Map()\n /**\n * use \"owner\" to group listeners; one owner may have multiple listeners\n * @type {Map<*, Set<Listener>>}\n */\n this._owner2Listeners = new Map()\n }\n\n /**\n * Name of the event.\n * @returns {string|Symbol}\n */\n get name () {\n return this._name\n }\n\n isEmpty () {\n return this._callbacks.size === 0\n }\n\n /**\n * Returns a copy of the raw listeners array.\n * @returns {Array<Listener>} A shallow copy of the listeners array.\n */\n rawListeners () {\n return [...this._listeners]\n }\n\n /**\n * Returns the number of listeners listening for the event.\n * If callback is provided, it will return how many times the callback is found in the list of the listeners\n * @param {Function} [callback] - The callback function to count\n * @returns {number}\n */\n listenerCount (callback) {\n if (callback == null) {\n return this._listeners.length\n }\n return this._callback2Listeners.get(callback)?.size ?? 0\n }\n\n /**\n * Returns a shallow copy of the registered callbacks array.\n * if one callback function is added multiple times, it will be returned multiple times.\n * @returns {Array<function>} A new array containing all registered callbacks.\n */\n callbacks () {\n return [...this.rawListeners().map(listener => listener.callback)]\n }\n\n /**\n * Emits current event, invoking all registered listeners by order.\n * @param {...*} args - Arguments to be passed to each listener.\n * @returns {boolean} True if the event had listeners, false otherwise.\n */\n emit (...args) {\n if (this._listeners.length === 0) {\n return false\n }\n // Clone _listeners, it may be changed during call listener\n for (const listener of [...this._listeners]) {\n listener.invoke(...args)\n }\n return true\n }\n\n /**\n * Emits current event, invoking all registered listeners by order.\n * @param {string|Symbol} owner\n * @param {...*} args - Arguments to be passed to each listener.\n * @returns {boolean} True if the event had listeners, false otherwise.\n */\n emitOwner (owner, ...args) {\n if (this._listeners.length === 0) {\n return false\n }\n const listeners = this._owner2Listeners.get(owner)\n if (listeners == null) {\n return false\n }\n // Clone _listeners, it may be changed during call listener\n for (const listener of [...listeners]) {\n listener.invoke(...args)\n }\n return true\n }\n\n /**\n * Checks if listener is registered with this event.\n * @param {function} callback - The listener function to check.\n * @returns {boolean} True if the listener is registered, false otherwise.\n */\n hasListener (callback) {\n if (!isFunction(callback)) {\n return false\n }\n return this._callbacks.has(callback)\n }\n\n /**\n * Checks if owner has any registered listeners.\n * @param {*} owner - The owner to check for registered listeners.\n * @returns {boolean} True if the owner has listeners, false otherwise.\n */\n hasOwner (owner) {\n if (isNil(owner)) {\n return false\n }\n return this._owner2Listeners.has(owner)\n }\n\n /**\n * Adds an event listener\n * @param {function} callback - The callback function to be invoked when the event occurs.\n * @param {*} [owner] - use \"owner\" to group listeners, then can remove all listeners for an owner.\n * @returns {boolean} true if added, false otherwise.\n */\n addListener (callback, owner) {\n return this._addListener(callback, owner, false, false)\n }\n\n /**\n * Prepends a listener callback to the beginning of the listeners array.\n * No checks are made to see if the listener has already been added.\n * Multiple calls passing the same combination of eventName and listener will result in the listener being added,\n * and called, multiple times.\n * @param {Function} callback - The callback function to be executed when the event is emitted.\n * @param {Object} owner - The owner object to which the listener belongs.\n * @returns {boolean}\n */\n prependListener (callback, owner) {\n return this._addListener(callback, owner, false, true)\n }\n\n /**\n * Adds a one-time listener for the event. The listener is automatically removed after being invoked once.\n * @param {Function} callback - The function to call when the event is triggered.\n * @param {Object} [owner] - The object that owns the callback (used for binding `this` context).\n * @returns {boolean}\n */\n addOnceListener (callback, owner) {\n return this._addListener(callback, owner, true, false)\n }\n\n /**\n * Adds a one-time event listener that will be automatically removed after being triggered once.\n * The listener will only be triggered if the event is pretended (simulated).\n * @param {Function} callback - The function to call when the event is triggered.\n * @param {Object} owner - The object that owns the listener (used for reference tracking).\n * @returns {boolean} The listener function that was added.\n */\n prependOnceListener (callback, owner) {\n return this._addListener(callback, owner, true, true)\n }\n\n /**\n * Adds a listener for the event.\n * @param {Function} callback - The callback function to be executed when the event occurs\n * @param {*} [owner] - The owner object that the listener belongs to (defaults to DeaultOwner)\n * @param {boolean} [isOnce=false] - Whether the listener should be removed after first invocation\n * @param {boolean} [isPrepend=false] - Whether the listener should be inert at the beginning of the listeners array\n * @returns {boolean} Returns true if listener was added successfully, false if callback is nil or duplicate\n * @protected\n */\n _addListener (callback, owner, isOnce, isPrepend) {\n if (isNil(callback)) {\n return false\n }\n assertFunction(callback)\n if (!this._callbacks.has(callback)) {\n this._callbacks.add(callback)\n }\n // a listener must belong to an owner\n owner = owner ?? DefaultOwner\n\n // use Listener to wrap callback\n const listener = new Listener(this, callback, isOnce)\n listener.owner = owner\n if (isPrepend) {\n this._listeners.unshift(listener)\n } else {\n this._listeners.push(listener)\n }\n\n // index, rapadly find one listener's owner\n this._listener2Owner.set(listener, owner)\n\n // one callback function may be registered many times\n let callbackListeners = this._callback2Listeners.get(callback)\n if (callbackListeners == null) {\n callbackListeners = new Set()\n this._callback2Listeners.set(callback, callbackListeners)\n }\n callbackListeners.add(listener)\n\n // group by owner\n let ownerListeners = this._owner2Listeners.get(owner)\n if (ownerListeners == null) {\n ownerListeners = new Set()\n this._owner2Listeners.set(owner, ownerListeners)\n }\n ownerListeners.add(listener)\n\n return true\n }\n\n /**\n * Removes a callback\n * @param {Function} callback - The callback function to remove.\n * @returns {boolean} true if removed, false otherwise.\n */\n removeListener (callback) {\n if (isNil(callback)) {\n return false\n }\n if (!this._callbacks.has(callback)) {\n return false\n }\n this._callbacks.delete(callback)\n\n const listeners = this._callback2Listeners.get(callback)\n if (listeners == null) { // should not happen\n return false\n }\n this._callback2Listeners.delete(callback)\n for (const listener of listeners) {\n // remove from global index\n const index = this._listeners.indexOf(listener)\n index !== -1 && this._listeners.splice(this._listeners.indexOf(listener), 1)\n\n // remove from owner index\n const owner = this._listener2Owner.get(listener)\n if (owner == null) {\n continue\n }\n this._listener2Owner.delete(listener)\n const ownerListeners = this._owner2Listeners.get(owner)\n if (ownerListeners == null) {\n continue\n }\n ownerListeners.delete(listener)\n if (ownerListeners.size === 0) {\n this._owner2Listeners.delete(owner)\n }\n }\n return true\n }\n\n /**\n * Removes a listener from both global and owner indexes.\n * @param {Listener} listener - The listener function to remove\n */\n _remove (listener) {\n // remove from global index\n const index = this._listeners.indexOf(listener)\n index !== -1 && this._listeners.splice(index, 1)\n\n // clean callback index\n const { callback } = listener\n const callbackListeners = this._callback2Listeners.get(callback)\n if (callbackListeners != null) {\n callbackListeners.delete(listener)\n if (callbackListeners.size === 0) {\n this._callback2Listeners.delete(callback)\n this._callbacks.delete(callback)\n }\n }\n\n // remove from owner index\n const owner = this._listener2Owner.get(listener)\n if (owner == null) {\n return\n }\n this._listener2Owner.delete(listener)\n const ownerListeners = this._owner2Listeners.get(owner)\n if (ownerListeners == null) {\n return\n }\n ownerListeners.delete(listener)\n if (ownerListeners.size === 0) {\n this._owner2Listeners.delete(owner)\n }\n }\n\n /**\n * Removes all event listeners\n * @param {*} [owner] - Without owner, all listeners will be removed; otherwise, only listeners of \"owner\" will be removed.\n * @returns {this}\n */\n removeAllListeners (owner) {\n // remove listeners of owner\n if (isNil(owner)) {\n // remove all Listeners\n this._callbacks.clear()\n this._listeners.length = 0\n this._callback2Listeners.clear()\n this._listener2Owner.clear()\n this._owner2Listeners.clear()\n return this\n }\n // all listeners of the owner\n const ownerListeners = this._owner2Listeners.get(owner)\n // no owner\n if (ownerListeners == null) {\n return this\n }\n // clear owner index\n this._owner2Listeners.delete(owner)\n // clearn listeners of owner one by one\n for (const listener of ownerListeners) {\n // remove from global index\n const index = this._listeners.indexOf(listener)\n index !== -1 && this._listeners.splice(this._listeners.indexOf(listener), 1)\n\n // clean listener-owner index\n this._listener2Owner.delete(listener)\n\n // one callback function may be registered many times, has many Listeners\n const { callback } = listener\n const callbackListeners = this._callback2Listeners.get(callback)\n if (callbackListeners == null) {\n continue\n }\n callbackListeners.delete(listener)\n if (callbackListeners.size === 0) {\n this._callback2Listeners.delete(callback)\n this._callbacks.delete(callback)\n }\n }\n return this\n }\n}\n\nexport { Event as EventType }\n","// 3rd\n// internal\nimport { TypeUtils, TypeAssert } from '@creejs/commons-lang'\n\n// owned\nimport Event from './event.js'\n// eslint-disable-next-line no-unused-vars\nimport Listener from './listener.js'\n\n/**\n * @typedef {{\n * on(eventName:string, listener:function, owner?:any): EventEmitterLike,\n * addListener(eventName:string, listener:function, owner?:any): EventEmitterLike,\n * off(eventName:string, listener:function): EventEmitterLike,\n * removeListener(eventName:string, listener:function): EventEmitterLike,\n * offAll(eventName:string, owner:any): EventEmitterLike,\n * offOwner(owner:any): EventEmitterLike,\n * removeAllListeners(eventName:string): EventEmitterLike,\n * once(eventName:string, listener:function, owner?:any): EventEmitterLike,\n * emit(eventName:string, ...args:any[]): EventEmitterLike,\n * emitOwner(eventName:string, owner:any, ...args:any[]): EventEmitterLike,\n * }} EventEmitterLike\n */\n\n// module vars\nconst { isNil } = TypeUtils\nconst {\n assertString, assertFunction, assertNumber,\n assertStringOrSymbol, assertNotNil\n} = TypeAssert\n\n/**\n * methods allowed to mixin other objects\n */\nconst MixinMethods = [\n 'on', 'once', 'addListener', 'prependListener', 'prependOnceListener',\n 'off', 'offAll', 'offOwner', 'removeAllListeners', 'removeListener',\n 'emit', 'emitOwner', 'setMaxListeners', 'getMaxListeners', 'hasOwner',\n 'listeners', 'listenerCount', 'eventNames', 'rawListeners'\n]\nlet DefaultMaxListeners = 10\n/**\n * 1. An EventEmitter follows the API of NodeJS EventEmitter.\n * 2. Enhancement:\n * * Listeners are grouped by \"owner\".\n * * Operation via \"owner\"\n * * Duplicate listeners are filtered out. Only unique One kept.\n */\nexport default class EventEmitter {\n /**\n * Mixes EventEmitter methods into the given object.\n * @template T\n * @param {T} obj - The target object to mix methods into.\n * @returns {T} The modified object with EventEmitter methods.\n */\n static mixin (obj) {\n const emitter = new EventEmitter()\n // @ts-ignore\n obj.__emitter = emitter\n for (const name of MixinMethods) {\n // @ts-ignore\n const method = emitter[name]\n // @ts-ignore\n obj[name] = method.bind(emitter)\n }\n return obj\n }\n\n static get defaultMaxListeners () {\n return DefaultMaxListeners\n }\n\n static set defaultMaxListeners (maxListeners) {\n assertNumber(maxListeners)\n DefaultMaxListeners = maxListeners ?? 10\n }\n\n /**\n */\n constructor () {\n /**\n * @type {Map<string|Symbol, Event>}\n */\n this._name2Event = new Map()\n this._maxListeners = DefaultMaxListeners\n }\n\n /**\n * Alias of {@linkcode EventEmitter.addListener}\n * @param {string|Symbol} eventName\n * @param {function} listener\n * @param {*} [owner]\n * @returns {this}\n */\n addListener (eventName, listener, owner) {\n return this.on(eventName, listener, owner)\n }\n\n /**\n * Adds the listener function to the beginning of the listeners array for the event named eventName.\n * @param {string|Symbol} eventName\n * @param {function} listener\n * @param {*} [owner]\n * @returns {this}\n */\n prependListener (eventName, listener, owner) {\n assertString(eventName)\n assertFunction(listener)\n this._checkMaxListeners(eventName)\n\n const event = this._getOrCreateEvent(eventName)\n event.prependListener(listener, owner)\n return this\n }\n\n /**\n * Adds a one-time listener function for the event named eventName to the beginning of the listeners array.\n * @param {string|Symbol} eventName\n * @param {function} listener\n * @param {*} [owner]\n * @returns {this}\n */\n prependOnceListener (eventName, listener, owner) {\n assertString(eventName)\n assertFunction(listener)\n this._checkMaxListeners(eventName)\n\n const event = this._getOrCreateEvent(eventName)\n event.prependOnceListener(listener, owner)\n return this\n }\n\n /**\n * Synchronously calls each of the listeners registered for the event named eventName,\n * in the order they were registered, passing the supplied arguments to each.\n * Returns true if the event had listeners, false otherwise.\n * @param {string|Symbol} eventName - The name of the event.\n * @param {...*} args arguments to pass to the listeners.\n * @returns {boolean}\n */\n emit (eventName, ...args) {\n const event = this._name2Event.get(eventName)\n if (event == null || event.isEmpty()) {\n return false\n }\n event.emit(...args)\n return true\n }\n\n /**\n * Emits an event To the specified owner.\n * @param {string} eventName - The name of the event to emit.\n * @param {any} owner - The owner of listeners\n * @param {...*} args - Additional arguments to pass with the event.\n */\n emitOwner (eventName, owner, ...args) {\n if (owner == null) {\n throw new Error('Missing \"owner\"')\n }\n const event = this._name2Event.get(eventName)\n if (event == null || event.isEmpty()) {\n return false\n }\n event.emitOwner(owner, ...args)\n return true\n }\n\n /**\n * Returns an array listing the events for which the emitter has registered listeners.\n * @returns {Array<string|Symbol>} An array of event names.\n */\n eventNames () {\n return [...this._name2Event.keys()]\n }\n\n getMaxListeners () {\n return this._maxListeners\n }\n\n /**\n * Returns the number of listeners listening for the event named eventName.\n * If listener is provided, it will return how many times the listener is found\n * in the list of the listeners of the event.\n * @param {string|Symbol} eventName - The name of the event to check\n * @param {function} [listener] - Optional specific listener to count\n * @returns {number} The number of listeners for the event\n */\n listenerCount (eventName, listener) {\n assertStringOrSymbol(eventName, 'eventName')\n const event = this._name2Event.get(eventName)\n if (event == null || event.isEmpty()) {\n return 0\n }\n return event.listenerCount(listener)\n }\n\n /**\n * Returns a copy of the array of listeners for the event named eventName.\n * 1. if a callback function added multiple times, it will be returned multiple times.\n * @param {string} eventName\n * @returns {Array<function>}\n */\n listeners (eventName) {\n assertStringOrSymbol(eventName, 'eventName')\n const event = this._name2Event.get(eventName)\n if (event == null || event.isEmpty()) {\n return []\n }\n return event.callbacks()\n }\n\n /**\n * Removes a callback function from a specific event.\n * 1. If the event doesn't exist or has no listeners, do nothing\n * 2. if one callback function added multiple times, all of them will be removed.\n * * !!! This is different from the behavior of Node.js EventEmitter.\n *\n * @param {string} eventName - The name of the event to remove callback from\n * @param {function} callback - The callback function to remove\n * @returns {EventEmitter} Returns the emitter instance for chaining\n */\n off (eventName, callback) {\n const event = this._name2Event.get(eventName)\n if (event == null) {\n return this\n }\n event.removeListener(callback)\n if (event.isEmpty()) {\n this._name2Event.delete(eventName)\n return this\n }\n return this\n }\n\n /**\n * Removes all listeners for the specified event.\n * if owner is limited, only the listeners of the owner will be removed.\n *\n * @param {string|Symbol} eventName - The name of the event to clear listeners for.\n * @param {*} owner - The owner whose listeners should be removed.\n * @returns {EventEmitter} The emitter instance for chaining.\n */\n offAll (eventName, owner) {\n assertStringOrSymbol(eventName, 'eventName')\n const event = this._name2Event.get(eventName)\n if (event == null) {\n return this\n }\n event.removeAllListeners(owner)\n if (event.isEmpty()) {\n this._name2Event.delete(eventName)\n return this\n }\n return this\n }\n\n /**\n * Removes all event listeners belonging to the specified owner.\n * @param {*} owner - The owner whose listeners should be removed.\n * @returns {this}\n */\n offOwner (owner) {\n assertNotNil(owner, 'owner')\n const events = [...this._name2Event.values()]\n for (const event of events) {\n event.removeAllListeners(owner)\n if (event.isEmpty()) {\n this._name2Event.delete(event.name)\n }\n }\n return this\n }\n\n /**\n * Adds the listener function to the end of the listeners array for the event named eventName.\n * @param {string|Symbol} eventName\n * @param {function} callback\n * @param {*} [owner]\n * @returns {this}\n */\n on (eventName, callback, owner) {\n assertString(eventName)\n assertFunction(callback)\n this._checkMaxListeners(eventName)\n\n const event = this._getOrCreateEvent(eventName)\n event.addListener(callback, owner)\n return this\n }\n\n /**\n * Checks if the number of listeners for the given event exceeds the maximum allowed.\n * Emits a warning if the listener count reaches or exceeds the maxListeners threshold.\n * @private\n * @param {string|Symbol} eventName - The name of the event to check\n * @returns {void}\n */\n _checkMaxListeners (eventName) {\n let listenerCount = 0\n if (this._maxListeners !== 0 && this._maxListeners !== Infinity && (listenerCount = this.listenerCount(eventName)) >= this._maxListeners) {\n console.warn(`maxlistenersexceededwarning: Possible EventEmitter memory leak detected. ${listenerCount} ${eventName} listeners added to [${this}]. Use emitter.setMaxListeners() to increase limit`)\n }\n }\n\n /**\n * Adds a listener that will be invoked only once for the event named eventName.SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit`)\n }\n }\n\n /**\n * Adds a one-time callback function for the specified event.\n * The callback is invoked only once and then automatically removed.\n *\n * @param {string} eventName - The name of the event to listen for.\n * @param {Function} callback - The callback function to execute when the event is emitted.\n * @param {*} [owner] - Optional owner used to group listener callbacks.\n * @returns {EventEmitter} Returns the emitter instance for chaining.\n */\n once (eventName, callback, owner) {\n assertString(eventName)\n assertFunction(callback)\n\n const event = this._getOrCreateEvent(eventName)\n event.addOnceListener(callback, owner)\n return this\n }\n\n /**\n * Returns a copy of the array of listeners for the event named eventName,\n * including any wrappers (such as those created by .once()).\n * @param {string} eventName - The name of the event.\n * @returns {Listener[]} An array of raw listener functions, or empty array if none exist.\n */\n rawListeners (eventName) {\n return this._name2Event.get(eventName)?.rawListeners() || []\n }\n\n /**\n * Alias of {@linkcode EventEmitter.offAll}\n * @param {string|Symbol} eventName - The name of the event to remove listeners for.\n * @param {*} owner - The owner of the listeners to be removed.\n * @returns {EventEmitter} The emitter instance for chaining.\n */\n removeAllListeners (eventName, owner) {\n return this.offAll(eventName, owner)\n }\n\n /**\n * Alias of {@linkcode EventEmitter.off}\n * @param {string} eventName - The name of the event.\n * @param {Function} callback - The callback function to remove.\n * @returns {EventEmitter} The emitter instance for chaining.\n */\n removeListener (eventName, callback) {\n return this.off(eventName, callback)\n }\n\n /**\n * Sets the maximum number of listeners that can be added to this event emitter.\n * @param {number} max - The maximum number of listeners.\n * @returns {this} The set maximum number of listeners.\n */\n setMaxListeners (max) {\n assertNumber(max)\n if (max < 0) {\n throw new RangeError('maxListeners must >=0')\n }\n this._maxListeners = max\n return this\n }\n\n /**\n * Gets an existing event by name or creates a new one if it doesn't exist.\n * @private\n * @param {string|Symbol} eventName - The name of the event to get or create.\n * @returns {Event} The existing or newly created Event instance.\n */\n _getOrCreateEvent (eventName) {\n if (this._name2Event.has(eventName)) {\n // @ts-ignore\n return this._name2Event.get(eventName)\n }\n const event = new Event(eventName)\n this._name2Event.set(eventName, event)\n return event\n }\n\n /**\n * Checks if the specified owner has any registered events.\n * @param {Object} owner - The owner object to check for registered events.\n * @returns {boolean} True if the owner has any registered events, false otherwise.\n */\n hasOwner (owner) {\n if (isNil(owner)) {\n return false\n }\n for (const event of this._name2Event.values()) {\n if (event.hasOwner(owner)) {\n return true\n }\n }\n return false\n }\n}\n\nexport { EventEmitter as EventEmitterType }\n"],"names":["assertFunction","assertNotNil","TypeAssert","isNil","TypeUtils","assertStringOrSymbol"],"mappings":";;;;AAAosD,IAAI,CAAC,CAAC,CAAgF,UAAU,CAAC,CAAC,CAA6Z,KAAK,CAAC,CAAivB,CAAC,CAA+E,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAM,UAAU,EAAE,OAAO,CAAC,CAAyD,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAgK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAA8M,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,EAA