/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/ngn@2.0.0-alpha.14/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
// ngn v2.0.0-alpha.14
// Copyright (c) 2022 Corey Butler
// Released under the MIT License.
const NODELIKE=void 0!==globalThis.process,RUNTIME=NODELIKE?"node":globalThis.hasOwnProperty("Deno")?"deno":"browser",RUNTIME_VERSION="node"===RUNTIME?process.versions.node:"deno"===RUNTIME?Deno.version.deno:"unknown",OS$1="deno"===RUNTIME?globalThis.Deno.build.os:((NODELIKE?globalThis.process:globalThis.navigator).platform||"unknown").toLowerCase(),REFERENCE_ID=Symbol("NGN 2.0.0-alpha.14"),WARN_EVENT$1=Symbol("NGN.WARN"),INFO_EVENT$1=Symbol("NGN.INFO"),ERROR_EVENT$1=Symbol("NGN.ERROR"),INTERNAL_EVENT$1=Symbol("NGN.INTERNAL"),allFalse$1=[!1,!1,!1],config$1=function(enumerable,writable,configurable,value){return{enumerable:enumerable,writable:writable,configurable:configurable,value:value}},warn=function(){globalThis[REFERENCE_ID]&&globalThis[REFERENCE_ID].has("LEDGER")&&globalThis[REFERENCE_ID].get("LEDGER").emit(WARN_EVENT$1,...arguments)},typeOf$1=el=>{if(void 0===el)return"undefined";if(null===el)return"null";const value=Object.prototype.toString.call(el).split(" ")[1].replace(/[^A-Za-z]/gi,"").toLowerCase();if("function"===value||"function"==typeof el){if(!el.name){let name=el.toString().replace(/\n/gi,"").replace(/^function\s|\(.*$/gim,"").toLowerCase();return name=0===name.length||name.indexOf(" ")>=0?"function":name,name.toLowerCase()}return(el.name||"function").toLowerCase()}return value.toLowerCase()},typeContains$1=function(){const args=Array.from(arguments),arg=args.shift(),types=new Set(args);for(const type of types)if("function"==typeof type&&arg instanceof type||"string"==typeof type&&type===typeOf$1(arg))return!0;return!1};var base={public:config$1(...allFalse$1,value=>config$1(!0,"function"!=typeof value,!1,value)),hidden:config$1(!1,!0,!1,value=>config$1(!1,"function"!=typeof value,!1,value)),constant:config$1(...allFalse$1,value=>config$1(!0,!1,!1,value)),hiddenconstant:config$1(...allFalse$1,value=>config$1(...allFalse$1,value)),get:config$1(...allFalse$1,fn=>({enumerable:!1,get:fn})),set:config$1(...allFalse$1,fn=>({enumerable:!1,set:fn})),getset:config$1(...allFalse$1,(getterFn,setterFn)=>({enumerable:!1,get:getterFn,set:setterFn})),before:config$1(...allFalse$1,(preFn,fn)=>function(){return preFn(...arguments),fn(...arguments)}),after:config$1(...allFalse$1,(fn,postFn)=>function(){return setTimeout(()=>postFn(...arguments),0),fn(...arguments)}),wrap:config$1(...allFalse$1,wrapper=>fn=>wrapper(fn)),deprecate:config$1(...allFalse$1,(fn,message="The method has been deprecated.",stdout=!1)=>function(){return warn("DEPRECATED.FUNCTION",message),stdout&&console.warn(message),fn(...arguments)}),wrapClass:config$1(...allFalse$1,(preFn,ClassFn)=>function(){return preFn(...arguments),new ClassFn(...arguments)}),deprecateClass:config$1(...allFalse$1,(function(ClassFn,message="The class has been deprecated.",stdout=!1){return function(){return warn("DEPRECATED.CLASS",message),stdout&&console.warn(message),new ClassFn(...arguments)}})),typeof:config$1(...allFalse$1,typeOf$1),acceptableType:config$1(...allFalse$1,typeContains$1),unacceptableType:config$1(...allFalse$1,(function(){return!typeContains$1(...arguments)}))};const allFalse=[!1,!1,!1];function config(enumerable,writable,configurable,value){return{enumerable:enumerable,writable:writable,configurable:configurable,value:value}}const typeOf=el=>{if(void 0===el)return"undefined";if(null===el)return"null";const value=Object.prototype.toString.call(el).split(" ")[1].replace(/[^A-Za-z]/gi,"").toLowerCase();if("function"===value||"function"==typeof el){if(!el.name){let name=el.toString().replace(/\n/gi,"").replace(/^function\s|\(.*$/gim,"").toLowerCase();return name=0===name.length||name.indexOf(" ")>=0?"function":name,name.toLowerCase()}return(el.name||"function").toLowerCase()}return value.toLowerCase()},typeContains=function(){const args=Array.from(arguments),arg=args.shift(),types=new Set(args);for(const type of types)if("function"==typeof type&&arg instanceof type||"string"==typeof type&&type===typeOf(arg))return!0;return!1};var type={typeof:config(...allFalse,typeOf),acceptableType:config(...allFalse,typeContains),unacceptableType:config(...allFalse,(function(){return!typeContains(...arguments)}))};function _classPrivateFieldGet(receiver,privateMap){return function _classApplyDescriptorGet(receiver,descriptor){return descriptor.get?descriptor.get.call(receiver):descriptor.value}(receiver,_classExtractFieldDescriptor(receiver,privateMap,"get"))}function _classPrivateFieldSet(receiver,privateMap,value){return function _classApplyDescriptorSet(receiver,descriptor,value){if(descriptor.set)descriptor.set.call(receiver,value);else{if(!descriptor.writable)throw new TypeError("attempted to set read only private field");descriptor.value=value}}(receiver,_classExtractFieldDescriptor(receiver,privateMap,"set"),value),value}function _classExtractFieldDescriptor(receiver,privateMap,action){if(!privateMap.has(receiver))throw new TypeError("attempted to "+action+" private field on non-instance");return privateMap.get(receiver)}const TYPES=new Set(["parent","sibling"]);var _base$1=new WeakMap,_related$1=new WeakMap,_type=new WeakMap,_name$1=new WeakMap,_description$1=new WeakMap,_oid$2=new WeakMap,_destroyed=new WeakMap,_update=new WeakMap;class Relationship$1{constructor(base$1,related,type="parent"){_base$1.set(this,{writable:!0,value:void 0}),_related$1.set(this,{writable:!0,value:void 0}),_type.set(this,{writable:!0,value:"parent"}),_name$1.set(this,{writable:!0,value:void 0}),_description$1.set(this,{writable:!0,value:void 0}),_oid$2.set(this,{writable:!0,value:void 0}),_destroyed.set(this,{writable:!0,value:!1}),_update.set(this,{writable:!0,value:(name,payload)=>{_classPrivateFieldGet(this,_destroyed)||setTimeout(()=>{_classPrivateFieldGet(this,_base$1).emit&&"function"==typeof _classPrivateFieldGet(this,_base$1).emit&&_classPrivateFieldGet(this,_base$1).emit(name,payload),_classPrivateFieldGet(this,_related$1)&&_classPrivateFieldGet(this,_related$1).emit&&"function"==typeof _classPrivateFieldGet(this,_related$1).emit&&_classPrivateFieldGet(this,_related$1).emit(name,payload)},0)}}),_classPrivateFieldSet(this,_base$1,base$1),_classPrivateFieldSet(this,_related$1,related),this.type=type,_classPrivateFieldSet(this,_name$1,`${base$1.name||"Unknown"+base.typeof(base$1)}${related.name||"Unknown"+base.typeof(related)}Relationship`),_classPrivateFieldSet(this,_description$1,`${base$1.name||"Unknown "+base.typeof(base$1)} <-> ${related.name||"Unknown "+base.typeof(related)} ${this.type} relationship.`),_classPrivateFieldSet(this,_oid$2,Symbol(_classPrivateFieldGet(this,_name$1))),Object.defineProperty(this,"destroy",{enumerable:!1,configurable:!1,writable:!1,value:()=>{_classPrivateFieldGet(this,_update).call(this,"relationship.destroy",this),_classPrivateFieldSet(this,_destroyed,!0)}}),_classPrivateFieldGet(this,_update).call(this,"relationship",this)}get OID(){return _classPrivateFieldGet(this,_oid$2)}get name(){return _classPrivateFieldGet(this,_name$1)}get description(){return _classPrivateFieldGet(this,_description$1)}get base(){return _classPrivateFieldGet(this,_base$1)}set base(value){_classPrivateFieldGet(this,_base$1)!==value&&(_classPrivateFieldGet(this,_update).call(this,"relationship.destroy",this),_classPrivateFieldSet(this,_base$1,value),_classPrivateFieldGet(this,_update).call(this,"relationship",this))}get related(){return _classPrivateFieldGet(this,_related$1)}set related(value){_classPrivateFieldGet(this,_related$1)!==value&&(_classPrivateFieldGet(this,_update).call(this,"relationship.destroy",this),_classPrivateFieldSet(this,_related$1,value),_classPrivateFieldGet(this,_update).call(this,"relationship",this))}get type(){return _classPrivateFieldGet(this,_type)}set type(value){if(value!==_classPrivateFieldGet(this,_type)){const old=_classPrivateFieldGet(this,_type);if(value=(value||"parent").toLowerCase(),!TYPES.has(value))throw new Error(`Invalid relationship type "${value}". Acceptable values are: ${Array.from(TYPES).join(", ")}`);_classPrivateFieldSet(this,_type,value),_classPrivateFieldGet(this,_update).call(this,"relationship.type.update",{old:old,new:value,relationship:this})}}}var _related=new WeakMap,_base=new WeakMap;class Relationships$1{constructor(base$1){_related.set(this,{writable:!0,value:new Set}),_base.set(this,{writable:!0,value:void 0}),_classPrivateFieldSet(this,_base,base$1),Object.defineProperties(this,{insert:base.hiddenconstant.value(rel=>_classPrivateFieldGet(this,_related).add(rel)),add:base.hiddenconstant.value((base,related,type="parent")=>{const rel=new Relationship$1(base,related,type),other=base===_classPrivateFieldGet(this,_base)?related:base;_classPrivateFieldGet(this,_related).add(rel),other.related&&other.related instanceof Relationships$1&&other.related.insert(rel)}),destroy:base.hiddenconstant.value(rel=>{if(_classPrivateFieldGet(this,_related).has(rel)){const other=rel.base===_classPrivateFieldGet(this,_base)?rel.related:rel.base;rel.destroy(),_classPrivateFieldGet(this,_related).delete(rel),other.related&&other.related instanceof Relationships$1&&other.related.destroy(rel)}})})}get size(){return _classPrivateFieldGet(this,_related).size}get parent(){for(const rel of _classPrivateFieldGet(this,_related))if("parent"===rel.type&&rel.related===_classPrivateFieldGet(this,_base))return rel.base;return null}set parent(value){if(!value)return void(this.parents=null);const p=this.parent;if(p!==value){if(null!==p)for(const rel of _classPrivateFieldGet(this,_related))if("parent"===rel.type&&rel.base===p){rel.destroy();break}null!==value&&this.add(value,_classPrivateFieldGet(this,_base))}}addParent(){for(const parent of arguments)this.add(parent,_classPrivateFieldGet(this,_base))}get parents(){const result=new Set;for(const rel of _classPrivateFieldGet(this,_related))"parent"===rel.type&&rel.related===_classPrivateFieldGet(this,_base)&&result.add(rel.base);return Array.from(result)}set parents(value){value=new Set(Array.from(value||[]));for(const rel of _classPrivateFieldGet(this,_related))"parent"===rel.type&&rel.related===_classPrivateFieldGet(this,_base)&&(value.has(rel.base)?value.delete(rel.base):this.destroy(rel));this.addParent(...value)}get child(){for(const rel of _classPrivateFieldGet(this,_related))if("parent"===rel.type&&rel.base===_classPrivateFieldGet(this,_base))return rel.related;return null}set child(value){if(!value)return void(this.children=null);const p=this.child;if(p!==value){if(null!==p)for(const rel of _classPrivateFieldGet(this,_related))if("parent"===rel.type&&rel.related===p){rel.destroy();break}null!==value&&this.add(_classPrivateFieldGet(this,_base),value)}}get children(){const result=new Set;for(const rel of _classPrivateFieldGet(this,_related))"parent"===rel.type&&rel.base===_classPrivateFieldGet(this,_base)&&result.add(rel.related);return Array.from(result)}set children(value){value=new Set(Array.from(value||[]));for(const rel of _classPrivateFieldGet(this,_related))"parent"===rel.type&&rel.base===_classPrivateFieldGet(this,_base)&&(value.has(rel.related)?value.delete(rel.related):this.destroy(rel));this.addChild(...value)}addChild(){for(const child of arguments)this.add(_classPrivateFieldGet(this,_base),child)}get sibling(){for(const rel of _classPrivateFieldGet(this,_related))if("sibling"===rel.type)return rel.base===_classPrivateFieldGet(this,_base)?rel.related:rel.base;return null}set sibling(value){if(!value)return void(this.siblings=null);const p=this.sibling;if(p!==value){if(null!==p)for(const rel of _classPrivateFieldGet(this,_related))if("sibling"===rel.type&&rel.related===p){rel.destroy();break}null!==value&&this.add(_classPrivateFieldGet(this,_base),value,"sibling")}}get siblings(){const result=new Set;for(const rel of _classPrivateFieldGet(this,_related))"sibling"===rel.type&&result.add(rel.base===_classPrivateFieldGet(this,_base)?rel.related:rel.base);return Array.from(result)}set siblings(value){value=new Set(Array.from(value||[]));for(const rel of _classPrivateFieldGet(this,_related))"sibling"===rel.type&&(value.has(rel.related)||value.has(rel.base)?(value.delete(rel.related),value.delete(rel.base)):this.destroy(rel));this.addSibling(...value)}addSibling(){for(const sibling of arguments)this.add(_classPrivateFieldGet(this,_base),sibling,"sibling")}clear(){for(const rel of _classPrivateFieldGet(this,_related))rel.destroy();_classPrivateFieldSet(this,_related,new Set)}clearParents(){for(const rel of _classPrivateFieldGet(this,_related))"parent"===rel.type&&rel.related===_classPrivateFieldGet(this,_base)&&this.destroy(rel)}clearChildren(){for(const rel of _classPrivateFieldGet(this,_related))"parent"===rel.type&&rel.base===_classPrivateFieldGet(this,_base)&&this.destroy(rel)}clearSiblings(){for(const rel of _classPrivateFieldGet(this,_related))"sibling"===rel.type&&this.destroy(rel)}}var _name=new WeakMap,_description=new WeakMap,_oid$1=new WeakMap,_relationships=new WeakMap;class Core{constructor(cfg={}){_name.set(this,{writable:!0,value:void 0}),_description.set(this,{writable:!0,value:void 0}),_oid$1.set(this,{writable:!0,value:void 0}),_relationships.set(this,{writable:!0,value:void 0}),cfg.name&&"string"==typeof cfg.name&&_classPrivateFieldSet(this,_name,cfg.name),_classPrivateFieldSet(this,_relationships,new Relationships$1(this)),cfg.description&&"string"==typeof cfg.description&&_classPrivateFieldSet(this,_description,cfg.description),cfg.parent&&(_classPrivateFieldGet(this,_relationships).parent=cfg.parent),cfg.parents&&(_classPrivateFieldGet(this,_relationships).parents=cfg.parents),cfg.child&&(_classPrivateFieldGet(this,_relationships).child=cfg.child),cfg.children&&(_classPrivateFieldGet(this,_relationships).children=cfg.children),cfg.sibling&&(_classPrivateFieldGet(this,_relationships).sibling=cfg.sibling),cfg.siblings&&(_classPrivateFieldGet(this,_relationships).siblings=cfg.siblings),Object.defineProperties(this,{alias:base.hidden.value((name,value)=>{Object.defineProperty(this,name,base.get.value(()=>value))}),rename:base.hidden.value((old,name,fn=null)=>{if(!fn){const me=this;fn=function(){return"function"==typeof me[name]?me[name](...arguments):me[name]}}Object.defineProperty(this,old,base.hidden.value(base.deprecate.value(fn,`${this.name} ${old} is now "${name}".`)))}),typeof:base.typeof,allowParameterType:base.acceptableType,disallowParameterType:base.unacceptableType,register:base.hiddenconstant.value(type=>register(type,this))})}get OID(){return _classPrivateFieldGet(this,_oid$1)||_classPrivateFieldSet(this,_oid$1,Symbol(_classPrivateFieldGet(this,_name)||"NGN Class")),_classPrivateFieldGet(this,_oid$1)}get name(){return _classPrivateFieldGet(this,_name)||this.constructor.name||"Unknown"}set name(value){_classPrivateFieldSet(this,_name,value)}get description(){return _classPrivateFieldGet(this,_description)||"No description available."}set description(value){_classPrivateFieldSet(this,_description,value)}get related(){return _classPrivateFieldGet(this,_relationships)}}var _event=new WeakMap,_maxListeners$1=new WeakMap,_handlers=new WeakMap,_once=new WeakMap,_dynamic=new WeakMap,_flush=new WeakMap,_expire=new WeakMap;class EventListener extends Core{constructor(eventName,maxListeners=25){if(!eventName)throw new TypeError("EventListener must be provided with an event name to listen for.");super({name:eventName,description:"Event listener."}),_event.set(this,{writable:!0,value:void 0}),_maxListeners$1.set(this,{writable:!0,value:void 0}),_handlers.set(this,{writable:!0,value:new Map}),_once.set(this,{writable:!0,value:new Set}),_dynamic.set(this,{writable:!0,value:!1}),_flush.set(this,{writable:!0,value:void 0}),_expire.set(this,{writable:!0,value:void 0}),_classPrivateFieldSet(this,_event,eventName),_classPrivateFieldSet(this,_maxListeners$1,maxListeners),_classPrivateFieldSet(this,_dynamic,eventName instanceof RegExp||"string"==typeof eventName&&eventName.indexOf("*")>=0),this.register("EventHandler",this)}execute(event){const scope={event:event,get emitter(){return this.parent}},args=Array.from(arguments).slice(1),me=this;_classPrivateFieldGet(this,_handlers).forEach((handler,oid)=>{const fn=handler;_classPrivateFieldGet(me,_once).has(oid)&&(_classPrivateFieldGet(me,_handlers).delete(oid),_classPrivateFieldGet(me,_once).delete(oid)),0===me.size&&_classPrivateFieldGet(me,_flush).call(me),scope.handler=fn,scope.remove=()=>me.remove(oid);try{fn.apply(scope,args)}catch(e){console.log(e.message),console.log((new Error).stack),console.log(fn.toString())}})}get dynamic(){return _classPrivateFieldGet(this,_dynamic)}get size(){return _classPrivateFieldGet(this,_handlers).size}set maxListeners(value){_classPrivateFieldSet(this,_maxListeners$1,value)}add(handler,prepend=!1,ttl=null){if("function"!=typeof handler)throw console.log(arguments),new TypeError(`The ${typeof handler} argument (${handler.toString()}) provided as a "${this.name}" event handler must be a function.`);const OID=Symbol(_classPrivateFieldGet(this,_event).toString());if(prepend?_classPrivateFieldSet(this,_handlers,new Map([[OID,handler],..._classPrivateFieldGet(this,_handlers)])):_classPrivateFieldGet(this,_handlers).set(OID,handler),_classPrivateFieldGet(this,_handlers).size>_classPrivateFieldGet(this,_maxListeners$1))throw new RangeError(`Maximum call stack exceeeded (${this.parent.name} emitter limit ${_classPrivateFieldGet(this,_maxListeners$1)}).`);return!isNaN(ttl)&&ttl>0&&setTimeout(()=>this.remove(OID),ttl),OID}remove(handler){const type=typeof handler;"symbol"===type?_classPrivateFieldGet(this,_handlers).delete(handler):"function"===type?_classPrivateFieldGet(this,_handlers).forEach((value,id)=>{value===handler&&_classPrivateFieldGet(this,_handlers).delete(id)}):_classPrivateFieldSet(this,_handlers,new Map),0===this.size&&_classPrivateFieldGet(this,_flush).call(this)}run(){this.execute(_classPrivateFieldGet(this,_event),...arguments)}once(oid){_classPrivateFieldGet(this,_once).add(oid)}set flush(fn){_classPrivateFieldSet(this,_flush,fn)}}var _ttl=new WeakMap,_maxListeners=new WeakMap,_listeners=new WeakMap,_dynamicListeners=new WeakMap,_isDynamicEventName=new WeakMap,_getListenerRegex=new WeakMap,_forEachListener=new WeakMap;class EventEmitter$1 extends Core{constructor(cfg={}){super(...arguments),_ttl.set(this,{writable:!0,value:-1}),_maxListeners.set(this,{writable:!0,value:25}),_listeners.set(this,{writable:!0,value:new Map}),_dynamicListeners.set(this,{writable:!0,value:new Set}),_isDynamicEventName.set(this,{writable:!0,value:(name=null)=>null!==name&&(name instanceof RegExp||"string"==typeof name&&name.indexOf("*"))}),_getListenerRegex.set(this,{writable:!0,value:name=>name instanceof RegExp?name:new RegExp("^"+name.replace(/\./g,"\\.").replace(/\*/g,".*")+"$")}),_forEachListener.set(this,{writable:!0,value:(name,fn)=>this.listeners(name).map(i=>_classPrivateFieldGet(this,_listeners).get(i)).forEach(i=>fn(i))}),cfg.hasOwnProperty("defaultMaxListeners")&&_classPrivateFieldSet(this,_maxListeners,cfg.defaultMaxListeners),(cfg.TTL||cfg.ttl)&&(this.TTL=cfg.TTL||cfg.ttl),this.alias("addListener",this.on),this.alias("addEventListener",this.on),this.alias("removeListener",this.off),this.alias("removeEventListener",this.off),this.alias("clear",this.removeAllListeners),this.register("EventEmitter")}get TTL(){return _classPrivateFieldGet(this,_ttl)}set TTL(value){if(_classPrivateFieldGet(this,_ttl)!==value){if(isNaN(value))throw new TypeError(`The TTL value supplied to the ${this.name} event emitter must be an integer, not ${typeof value}.`);0===value&&(value=-1),_classPrivateFieldSet(this,_ttl,value)}}get maxListeners(){return _classPrivateFieldGet(this,_maxListeners)}set maxListeners(value){if(isNaN(value)){if(value===1/0)throw new TypeError("maxListeners must be a non-zero integer.");value=-1}value!==_classPrivateFieldGet(this,_maxListeners)&&(_classPrivateFieldSet(this,_maxListeners,value),_classPrivateFieldGet(this,_forEachListener).call(this,null,l=>{l.maxListeners=value}))}getMaxListeners(){return _classPrivateFieldGet(this,_maxListeners)}setMaxListeners(value){this.maxListeners=value}on(name,handler,ttl=null,prepend=!1){if(Array.isArray(name))return void name.forEach(eventName=>this.on(eventName,handler,ttl,prepend));if("object"==typeof name)return this.pool(name);if("string"!=typeof name&&"symbol"!=typeof name)throw new TypeError(`The ${this.name} event emitter cannot listen for ${typeof name} events. Please provide a string or symbol.`);let listener=_classPrivateFieldGet(this,_listeners).get(name);listener||(listener=new EventListener(name,_classPrivateFieldGet(this,_maxListeners)),listener.parent=this,listener.flush=()=>{_classPrivateFieldGet(this,_listeners).delete(name),this.emit("removeListener",name)});const id=listener.add(handler,prepend,ttl||_classPrivateFieldGet(this,_ttl));return _classPrivateFieldGet(this,_listeners).set(name,listener),listener.dynamic&&_classPrivateFieldGet(this,_dynamicListeners).add(name),this.emit("newListener",name,handler,id),id}prependListener(name,handler,ttl=null){return this.on(name,handler,ttl,!0)}once(name,handler,ttl=null,prepend=!1){const oid=this.on(...arguments);_classPrivateFieldGet(this,_forEachListener).call(this,name,listener=>listener.once(oid))}prependOnceListener(name,handler,ttl=null){this.once(name,handler,ttl,!0)}off(name,handler){if(0===arguments.length)return this.removeAllListeners();if(Array.isArray(name))return void name.forEach(eventName=>this.off(eventName,handler));const listeners=this.listeners(name);0===listeners.length?WARN$1(`Failed to remove event listener(s). The "${this.name}" event emitter has no listeners for the "${name.toString()}" event.`):listeners.forEach(name=>{_classPrivateFieldGet(this,_listeners).get(name).remove(handler),this.emit("removeListener",name)})}removeAllListeners(name=null){if(arguments.length>1)new Set([...arguments]).forEach(arg=>this.removeAllListeners(arg));else if(null!==name)this.off(name);else{const events=this.listeners();_classPrivateFieldSet(this,_listeners,new Map),events.forEach(eventName=>this.emit("removeListener",eventName))}}listenerCount(name){const listener=_classPrivateFieldGet(this,_listeners).get(name);return listener?listener.size:0}listeners(filter=null){const list=Array.from(new Set(Array.from(_classPrivateFieldGet(this,_listeners).keys())));return null===filter?list:list.filter(name=>"symbol"==typeof name?name===filter:_classPrivateFieldGet(this,_getListenerRegex).call(this,name).test(filter))}emit(){const args=Array.from(arguments),name=args.shift();Array.isArray(name)?name.forEach(eventName=>this.emit(eventName,...args)):_classPrivateFieldGet(this,_forEachListener).call(this,name,listener=>listener.execute(name,...args))}eventNames(){return this.listeners()}pool(prefix,group){"string"!=typeof prefix&&(group=prefix,prefix=null);const me=this,pool={};for(const eventName in group){const topic=`${prefix||""}${eventName}`;"function"==typeof group[eventName]?(this.maxListeners++,pool[eventName]=this.on(topic,group[eventName])):"object"==typeof group[eventName]?this.pool(topic+".",group[eventName]):"string"==typeof group[eventName]?pool[eventName]=this.on(topic,(function(){me.emit(group[eventName],...arguments)})):WARN$1(topic+" could not be pooled in the event emitter because its value is not a function.")}}}const forceArray=value=>null===value?[]:Array.isArray(value)?value:[value];var _queued=new WeakMap,_collections=new WeakMap,_funnels=new WeakMap,_after=new WeakMap,_funnel=new WeakMap,_eventFunnel=new WeakMap,_afterEvent=new WeakMap;class EnhancedEventEmitter extends EventEmitter$1{constructor(){super(...arguments),_queued.set(this,{writable:!0,value:new Map}),_collections.set(this,{writable:!0,value:new Map}),_funnels.set(this,{writable:!0,value:new Map}),_after.set(this,{writable:!0,value:new Map}),_funnel.set(this,{writable:!0,value:(key,name,trigger,args=[],once=!1)=>{const queue=_classPrivateFieldGet(this,_collections).get(key);if(queue)if(queue.delete(name),this.maxListeners--,0===queue.size){if(once)_classPrivateFieldGet(this,_collections).delete(key),_classPrivateFieldGet(this,_funnels).delete(key);else{const collection=_classPrivateFieldGet(this,_funnels).get(key);_classPrivateFieldGet(this,_collections).set(key,collection),this.maxListeners+=collection.size,collection.forEach(event=>this.once(event,()=>_classPrivateFieldGet(this,_funnel).call(this,key,event,trigger,args)))}"function"==typeof trigger?trigger(...args):this.emit(trigger,...args)}else _classPrivateFieldGet(this,_collections).set(key,queue)}}),_eventFunnel.set(this,{writable:!0,value:function(once,collection,trigger,payload){if(!(Array.isArray(collection)||collection instanceof Set))throw new Error(`EventEmitter.reduce expected an array of events, but received a(n) ${typeof collection} instead.`);const key=Symbol("reduce.event");collection=collection instanceof Set?collection:new Set(collection),_classPrivateFieldGet(this,_collections).set(key,collection),this.maxListeners+=collection.size;const handlers=new Set;return collection.forEach(event=>handlers.add(this[once?"once":"on"](event,()=>_classPrivateFieldGet(this,_funnel).call(this,key,event,trigger,Array.from(arguments).slice(3))))),_classPrivateFieldGet(this,_funnels).set(key,collection),Object.defineProperty({},"remove",base.constant.value(()=>{_classPrivateFieldGet(this,_collections).delete(key),Array.from(collection).forEach((event,i)=>this.off(event,handlers[i]))}))}}),_afterEvent.set(this,{writable:!0,value:function(once,event,limit,target){const oid=Symbol(`after.${limit}.${event}`);_classPrivateFieldGet(this,_after).set(oid,{remaining:limit,limit:limit,once:once});const args=Array.from(arguments),me=this,OID=this.on(event,(function(){const meta=_classPrivateFieldGet(me,_after).get(oid);meta&&(meta.remaining--,0===meta.remaining?(meta.once?(_classPrivateFieldGet(me,_after).delete(oid),me.off(event,OID)):(meta.remaining=meta.limit,_classPrivateFieldGet(me,_after).set(oid,meta)),"function"==typeof target?target(...args.slice(4)):me.emit(target,...arguments)):_classPrivateFieldGet(me,_after).set(oid,meta))}));return Object.defineProperty({},"remove",base.constant.value(()=>{_classPrivateFieldGet(this,_after).delete(oid),this.off(event,oid)}))}}),this.rename("funnel","reduce"),this.rename("funnelOnce","reduceOnce"),this.rename("threshold","after"),this.rename("thresholdOnce","afterOnce"),Object.defineProperties(this,{increaseMaxListeners:base.hidden.value((count=1)=>{this.maxListeners+=count}),decreaseMaxListeners:base.hidden.value((count=1)=>{this.maxListeners=this.maxListeners-count})})}emit(name){("string"!=typeof name&&"symbol"!=typeof name||!_classPrivateFieldGet(this,_queued).has(name))&&super.emit(...arguments)}delayEmit(name,delay){if(!_classPrivateFieldGet(this,_queued).has(name)){const args=Array.from(arguments);args.splice(1,1),_classPrivateFieldGet(this,_queued).set(name,setTimeout(()=>{_classPrivateFieldGet(this,_queued).delete(name),this.emit(...args)},delay))}}attach(eventName,preventDefaultAction){return preventDefaultAction="boolean"==typeof preventDefaultAction&&preventDefaultAction,e=>{preventDefaultAction&&!NODELIKE&&e.preventDefault(),this.emit(eventName,...arguments)}}forward(eventName,triggers,payload){if(Array.isArray(eventName))return eventName.forEach(name=>this.forward(...Array.from(arguments).slice(1)));triggers=forceArray(triggers);const me=this;this.maxListeners++;const oid=this.on(eventName,(function(){const args=Array.from(arguments);payload&&args.push(payload),me.emit(triggers,...args)}));return{id:oid,remove:()=>{this.maxListeners--,this.off(eventName,oid)}}}reduce(){return _classPrivateFieldGet(this,_eventFunnel).call(this,!1,...arguments)}reduceOnce(){return _classPrivateFieldGet(this,_eventFunnel).call(this,!0,...arguments)}relay(name,target,prefix=null,postfix=null,once=!1){if(target===this||"function"!=typeof target.emit)throw new Error(`Cannot relay events from "${this.name}" event emitter to a non-event emitter.`);name=forceArray(name),this.maxListeners+=name.length;const me=this;name.forEach(event=>{this[once?"once":"on"](event,(function(){"string"!=typeof event?(null===prefix&&null===postfix||INFO$1("RELAY",`Cannot relay a pre/postfixed "${this.event.toString()}" event (${typeof this.event}) from ${me.name} event emitter to ${target instanceof EventEmitter$1?target.name:"target event emitter"}.`),target.emit(this.event,...arguments)):target.emit(`${prefix?prefix+".":""}${this.event}${postfix?"."+postfix:""}`.replace(/\.{2,}/gi,"."),...arguments)}))})}relayOnce(){this.relay(...arguments,!0)}after(){return _classPrivateFieldGet(this,_afterEvent).call(this,!1,...arguments)}afterOnce(){return _classPrivateFieldGet(this,_afterEvent).call(this,!0,...arguments)}deprecate(event,replacementName){const me=this;this.on(event,(function(){if(WARN$1("DEPRECATED.EVENT",event+" is deprecated. "+(replacementName?`Use ${replacementName} instead.`:"")),replacementName){const args=Array.from(arguments).slice(1);args.unshift(replacementName),me.emit(...args)}}))}}const globalId=Symbol.for("NGN");globalThis[REFERENCE_ID]=new Map,globalThis[REFERENCE_ID].set("REFERENCE_ID",REFERENCE_ID),globalThis[REFERENCE_ID].set("VERSION","2.0.0-alpha.14"),globalThis[globalId]||(globalThis[globalId]=[]),globalThis[globalId].push(REFERENCE_ID);const register=(key,value)=>{if("REFERENCE_ID"!==key&&"LEDGER"!==key&&"version"!==key){if("INSTANCE"===key)return void(globalThis[REFERENCE_ID].has("INSTANCE")||globalThis[REFERENCE_ID].set(key,value));const meta=globalThis[REFERENCE_ID].get(key)||new Map;meta.set(Symbol(key),value),globalThis[REFERENCE_ID].set(key,meta)}},plugins$1=new Proxy(globalThis[REFERENCE_ID],{get:(target,property)=>target.has("PLUGINS")?target.get("PLUGINS").get(property):void 0});var _events=new WeakMap;const LEDGER$1=new class LedgerEventEmitter extends EnhancedEventEmitter{constructor(...args){super(...args),_events.set(this,{writable:!0,value:new Map})}registerEventType(eventName){if(_classPrivateFieldGet(this,_events).has(eventName))throw new Error(`"${eventName}" already exists.`);const CUSTOM_EVENT=Symbol(eventName),emitterFn=function(){LEDGER_EVENT(CUSTOM_EVENT)(...arguments)};return _classPrivateFieldGet(this,_events).set(eventName,emitterFn),[CUSTOM_EVENT,emitterFn]}get events(){return Object.assign({INFO_EVENT:INFO_EVENT$1,WARN_EVENT:WARN_EVENT$1,ERROR_EVENT:ERROR_EVENT$1,INTERNAL_EVENT:INTERNAL_EVENT$1},Object.fromEntries(_classPrivateFieldGet(this,_events)))}get emitters(){const methods={INFO:INFO$1,WARN:WARN$1,ERROR:ERROR$1,INTERNAL:INTERNAL$1};for(const[name,fn]of Object.entries(_classPrivateFieldGet(this,_events)))methods[name]=fn;return methods}}({name:"NGN Ledger",description:"A ledger of events, outputs, and information produced by the system."});globalThis[REFERENCE_ID].set("LEDGER",LEDGER$1);const LEDGER_EVENT=EVENT=>function(){LEDGER$1.emit(EVENT,...arguments)},WARN$1=function(){LEDGER_EVENT(WARN_EVENT$1)(...arguments)},INFO$1=function(){LEDGER_EVENT(INFO_EVENT$1)(...arguments)},ERROR$1=function(){LEDGER_EVENT(ERROR_EVENT$1)(...arguments)},INTERNAL$1=function(){LEDGER_EVENT(INTERNAL_EVENT$1)(...arguments)};"node"===RUNTIME?(process.on("uncaughtException",e=>{"symbol"==typeof e.OID&&ERROR$1(e)}),process.on("unhandledRejection",ERROR$1),process.on("warning",WARN$1)):void 0!==globalThis.window&&(globalThis.window.addEventListener("error",ERROR$1),globalThis.window.addEventListener("unhandledrejection",ERROR$1));const PARSER=new Map([["PROTOCOL",/(\w+:\/\/?.*):([0-9]+):([0-9]+)(?!=[^0-9])/i],["NO_PROTOCOL",/\((.+):([0-9]+):([0-9]+)\)/i],["NO_PARENTHESIS",/\s(?!\()([^\s]+):([0-9]+):([0-9]+)(?!=[^0-9])(?!\))/i],["OLD_STACK",/Line\s+([0-9]+).+\s(\w+:\/\/?[^\s|:]+):?/i]]);var _id=new WeakMap,_custom=new WeakMap,_oid=new WeakMap;class Exception$1 extends Error{constructor(config={}){super(),_id.set(this,{writable:!0,value:void 0}),_custom.set(this,{writable:!0,value:void 0}),_oid.set(this,{writable:!0,value:void 0}),config="string"==typeof config?{message:config}:config,this.name=config.name||"NgnError",this.type=config.type||"Error",this.severity=config.severity||"minor",this.message=config.message||"Unknown Error",this.category=config.category||"programmer",this.description=this.message,this.parent=globalThis,this.name=this.name.replace(/[^a-zA-Z0-9_]/gi,""),_classPrivateFieldSet(this,_custom,config.custom||{}),_classPrivateFieldSet(this,_id,(config.id?config.id:_classPrivateFieldGet(this,_custom).id)||this.name),_classPrivateFieldSet(this,_oid,Symbol(this.name)),Error.captureStackTrace&&Error.captureStackTrace(this,Exception$1),("boolean"!=typeof config.DO_NOT_REGISTER||config.DO_NOT_REGISTER)&&register("Exception",this),ERROR$1(this)}get OID(){return _classPrivateFieldGet(this,_oid)}get help(){return _classPrivateFieldGet(this,_custom).help?"Tip: "+_classPrivateFieldGet(this,_custom).help:null}get cause(){return _classPrivateFieldGet(this,_custom).cause?_classPrivateFieldGet(this,_custom).cause:null}get id(){return _classPrivateFieldGet(this,_id)}get trace(){return this.stack.split("\n").reduce((result,line)=>{for(const[name,pattern]of PARSER){const match=pattern.exec(line);if(null!==match){"OLD_STACK"!==name?result.push({path:match[1],line:match[2],column:match[3]}):result.push({path:match[2],line:match[1],column:0});break}}return result},[])}}function defineException$1(config={}){globalThis[config.name||"NGNError"]=function(){return arguments.length>0&&(config.message=arguments[0]),new Exception$1(config)}}const NGN=Object.defineProperties({},Object.assign({},base,type));Object.defineProperties(NGN,{version:NGN.constant("2.0.0-alpha.14"),OS:NGN.constant(OS$1),nodelike:NGN.hiddenconstant(NODELIKE),runtime:NGN.hiddenconstant(RUNTIME),runtimeVersion:NGN.hiddenconstant(RUNTIME_VERSION),platform:NGN.get(()=>OS$1.indexOf("ios")>=0||OS$1.indexOf("like mac")?"ios":OS$1.indexOf("mac")>=0||OS$1.indexOf("darwin")>=0?"mac":OS$1.indexOf("win")>=0?"windows":OS$1.indexOf("android")>=0?"android":OS$1.indexOf("linux")>=0?"linux":"unrecognized"),platformVersion:NGN.get(async()=>NODELIKE?(await import("os")).release():new Promise(resolve=>resolve("deno"===RUNTIME?"unknown":/\((.*)\)/i.exec(globalThis.navigator.userAgent)[1].split(";")[0].split(/\s+/i).pop()))),WARN_EVENT:NGN.hiddenconstant(WARN_EVENT$1),INFO_EVENT:NGN.hiddenconstant(INFO_EVENT$1),ERROR_EVENT:NGN.hiddenconstant(ERROR_EVENT$1),INTERNAL_EVENT:NGN.hiddenconstant(INTERNAL_EVENT$1),WARN:NGN.hiddenconstant(WARN$1),INFO:NGN.hiddenconstant(INFO$1),ERROR:NGN.hiddenconstant(ERROR$1),INTERNAL:NGN.hiddenconstant(INTERNAL$1),stack:NGN.get(()=>new Exception$1({DO_NOT_REGISTER:!0}).trace),defineException:NGN.constant(defineException$1),BUS:NGN.constant(new EnhancedEventEmitter({name:"NGN.BUS",description:"Global event bus"})),LEDGER:NGN.get(()=>LEDGER$1),Class:NGN.public(Core),Middleware:NGN.public(class Middleware$1 extends Core{constructor(){super(...arguments),Object.defineProperties(this,{_data:{enumerable:!1,configurable:!1,value:[]},go:{enumerable:!1,configurable:!1,writable:!0,value:(...args)=>{args.pop().apply(this,args)}}}),this.register("Middleware")}get size(){return this._data.length}get data(){return this._data}use(method){const methodBody=method.toString();methodBody.indexOf("[native code]")<0&&this._data.push(methodBody),this.go=(stack=>(...args)=>{const next=args.pop();stack(...args,()=>{method.apply(this,[...args,next.bind(null,...args)])})})(this.go)}run(){const args=Array.from(arguments);0!==args.length&&"function"==typeof args[args.length-1]||args.push(()=>{}),this.go(...args)}}),BaseEventEmitter:NGN.public(EventEmitter$1),EventEmitter:NGN.public(EnhancedEventEmitter),Relationships:NGN.public(Relationships$1),Relationship:NGN.public(Relationship$1),plugins:NGN.constant(plugins$1)}),defineException$1({name:"MissingNgnDependencyError",type:"MissingNgnDependencyError",severity:"critical",message:"An NGN dependency is missing or could not be found.",category:"programmer",custom:{help:"Include the missing library.",cause:"A required dependency was not included (or was included in the wrong sequence)."}}),defineException$1({name:"ReservedWordError",type:"ReservedWordError",severity:"critical",message:"An attempt to use a reserved word failed.",category:"programmer",custom:{help:"Use an alternative word.",cause:"A word was used to define an attribute, method, field, or other element that already exists."}}),defineException$1({name:"InvalidConfigurationError",type:"InvalidConfigurationError",severity:"critical",message:"Invalid configuration.",category:"programmer",custom:{help:"See the documentation for the proper configuration.",cause:"The configuration specified was marked as invalid or caused an error during instantiation."}}),defineException$1({name:"UnacceptableParameterTypeError",type:"UnacceptableParameterTypeError",severity:"critical",message:"The parameter/argument provided is unacceptable.",category:"programmer",custom:{help:"See the documentation for a list of accepted parameter types.",cause:'This is commonly caused by a variable evaluating to an incorrect data type, such as "undefined" or "null". It is also commonly caused by providing arguments to a function in the incorrect order, or just an unawareness of the acceptable parameter types.'}}),register("INSTANCE",NGN);const{BaseEventEmitter:BaseEventEmitter,EventEmitter:EventEmitter,Middleware:Middleware,Exception:Exception,Class:Class,version:version,OS:OS,nodelike:nodelike,platform:platform,platformVersion:platformVersion,runtime:runtime,runtimeVersion:runtimeVersion,WARN_EVENT:WARN_EVENT,INFO_EVENT:INFO_EVENT,ERROR_EVENT:ERROR_EVENT,INTERNAL_EVENT:INTERNAL_EVENT,WARN:WARN,INFO:INFO,ERROR:ERROR,INTERNAL:INTERNAL,wrapClass:wrapClass,deprecateClass:deprecateClass,wrap:wrap,deprecate:deprecate,stack:stack,defineException:defineException,BUS:BUS,LEDGER:LEDGER,Relationship:Relationship,Relationships:Relationships,plugins:plugins}=NGN;export default NGN;export{BUS,BaseEventEmitter,Class,ERROR,ERROR_EVENT,EventEmitter,Exception,INFO,INFO_EVENT,INTERNAL,INTERNAL_EVENT,LEDGER,Middleware,NGN,OS,Relationship,Relationships,WARN,WARN_EVENT,defineException,deprecate,deprecateClass,nodelike,platform,platformVersion,plugins,runtime,runtimeVersion,stack,version,wrap,wrapClass};
//# sourceMappingURL=../ngn-debug/index.js.map
