@adaas/a-concept 0.1.57 → 0.1.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/global/A-Scope/A-Scope.class.ts +59 -16
- package/src/global/A-Stage/A-Stage.class.ts +1 -1
- package/tests/A-Dependency.test.ts +198 -0
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var Ze=Object.defineProperty;var a=(p,e)=>Ze(p,"name",{value:e,configurable:true});var N={A_CONCEPT_NAME:"A_CONCEPT_NAME",A_CONCEPT_ROOT_SCOPE:"A_CONCEPT_ROOT_SCOPE",A_CONCEPT_ENVIRONMENT:"A_CONCEPT_ENVIRONMENT",A_CONCEPT_ROOT_FOLDER:"A_CONCEPT_ROOT_FOLDER",A_ERROR_DEFAULT_DESCRIPTION:"A_ERROR_DEFAULT_DESCRIPTION"},at=[N.A_CONCEPT_NAME,N.A_CONCEPT_ROOT_SCOPE,N.A_CONCEPT_ENVIRONMENT,N.A_CONCEPT_ROOT_FOLDER,N.A_ERROR_DEFAULT_DESCRIPTION];var He=(i=>(i.INITIALIZED="INITIALIZED",i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.INTERRUPTED="INTERRUPTED",i.FAILED="FAILED",i))(He||{});var _e=class _e{constructor(){this.meta=new Map;}[Symbol.iterator](){let e=this.meta.entries();return {next:a(()=>e.next(),"next")}}from(e){return this.meta=new Map(e.meta),this}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof _e:return e.toJSON();case e instanceof Map:let t={};for(let[n,i]of e.entries())t[String(n)]=this.recursiveToJSON(i);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,i]of Object.entries(e))r[n]=this.recursiveToJSON(i);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};a(_e,"A_Meta");var d=_e;var We=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(We||{}),Xe=(r=>(r.SAVE="save",r.DESTROY="destroy",r.LOAD="load",r))(Xe||{});var Qe=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Qe||{});var et=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(et||{});var fe=class fe extends d{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,i])=>{i.forEach(s=>{t.push({name:s.name,handler:s.handler,behavior:s.behavior,before:s.before||"",after:s.after||"",throwOnError:s.throwOnError||true,override:""});});}),t}features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-component-abstractions"),n=this.get("a-component-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,s])=>{s.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}};a(fe,"A_ComponentMeta");var j=fe;var Ee=class Ee{get name(){return this.config?.name||this.constructor.name}get scope(){return c.scope(this)}constructor(e={}){this.config=e,c.allocate(this,this.config);}async call(e,t){return await new v({name:e,component:this}).process(t)}};a(Ee,"A_Container");var $=Ee;var Te=class Te extends d{injections(e){return this.get("a-container-injections")?.get(e)||[]}features(){return this.get("a-container-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-container-abstractions"),n=this.get("a-container-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,s])=>{s.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,i])=>{i.forEach(s=>{t.push({name:s.name,handler:s.handler,behavior:s.behavior,before:s.before||"",after:s.after||"",throwOnError:s.throwOnError||true,override:""});});}),t}};a(Te,"A_ContainerMeta");var U=Te;var Se=class Se{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};a(Se,"A_FormatterHelper");var g=Se;var he=class he{static generateTimeId(e={timestamp:new Date,random:Math.random().toString(36).slice(2,8)}){let t=e.timestamp.getTime().toString(36),r=e.random;return `${t}-${r}`}static parseTimeId(e){let[t,r]=e.split("-");return {timestamp:new Date(parseInt(t,36)),random:r}}static formatWithLeadingZeros(e,t=10){return String(e).padStart(t+1,"0").slice(-t)}static removeLeadingZeros(e){return String(Number(e))}};a(he,"A_IdentityHelper");var J=he;var Z={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},Be="If you see this error please let us know.";var k=class k extends Error{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof k:return e;case e instanceof Error:super(e.message);break;case o.isErrorSerializedType(e):super(e.message);break;case(o.isErrorConstructorType(e)&&"description"in e):super(`[${e.title}]: ${e.description}`);break;case(o.isErrorConstructorType(e)&&!("description"in e)):super(e.title);break;case(o.isString(e)&&!t):super(e);break;case(o.isString(e)&&!!t):super(`[${e}]: ${t}`);break;default:throw new k(Z.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}this.getInitializer(e,t).call(this,e,t);}get aseid(){return this._aseid}get title(){return this._title}get message(){return super.message}get code(){return this._code||g.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||process.env[N.A_ERROR_DEFAULT_DESCRIPTION]||Be}get originalError(){return this._originalError}getInitializer(e,t){switch(true){case(o.isString(e)&&!t):return this.fromMessage;case(o.isString(e)&&!!t):return this.fromTitle;case e instanceof Error:return this.fromError;case o.isErrorSerializedType(e):return this.fromJSON;case o.isErrorConstructorType(e):return this.fromConstructor;default:throw new k(Z.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=Z.UNEXPECTED_ERROR,this._aseid=new P({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=Z.UNEXPECTED_ERROR,this._aseid=new P({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromJSON(e){this._aseid=new P(e.aseid),super.message=e.message,this._title=e.title,this._code=e.code,this._scope=e.scope,this._description=e.description,this._originalError=e.originalError?new k(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new P({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromConstructor(e){if(this.validateTitle(e.title),this._title=e.title,this._code=e.code,this._scope=e.scope?o.isScopeInstance(e.scope)?e.scope.name:e.scope:void 0,this._aseid=new P({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._description=e.description,this._link=e.link,e.originalError instanceof k){let t=e.originalError;for(;t.originalError instanceof k;)t=t.originalError;this._originalError=t.originalError||t;}else this._originalError=e.originalError;}toJSON(){return {aseid:this.aseid.toString(),title:this.title,code:this.code,type:this.type,message:this.message,link:this.link,scope:this.scope,description:this.description,originalError:this.originalError?.message}}validateTitle(e){if(e.length>60)throw new k(Z.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new k(Z.VALIDATION_ERROR,"A-Error title cannot be empty.")}};a(k,"A_Error");var A=k;var ne=class ne extends A{};a(ne,"ASEID_Error"),ne.ASEIDInitializationError="ASEID Initialization Error",ne.ASEIDValidationError="ASEID Validation Error";var O=ne;var L=class L{static isASEID(e){return this.regexp.test(e)}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||c.concept}get scope(){return this._scope||c.root.name}get entity(){return this._entity}get id(){return this._id}get version(){return this._version}get shard(){return this._shard}getInitializer(e){switch(true){case o.isString(e):return this.fromString;case o.isObject(e):return this.fromObject;default:throw new O(O.ASEIDInitializationError,"Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[i,s,_]=r.split(":"),l=_.includes(".")?_.split(".")[0]:void 0,E=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=i||c.root.name,this._entity=s,this._id=E,this._version=n,this._shard=l;}fromObject(e){this._concept=e.concept?L.isASEID(e.concept)?new L(e.concept).id:e.concept:c.concept,this._scope=e.scope?o.isNumber(e.scope)?J.formatWithLeadingZeros(e.scope):L.isASEID(e.scope)?new L(e.scope).id:e.scope:c.root.name,this._entity=e.entity,this._id=o.isNumber(e.id)?J.formatWithLeadingZeros(e.id):e.id,this._version=e.version,this._shard=e.shard;}toString(){return `${this.concept}@${this.scope}:${this.entity}:${this.shard?this.shard+"."+this.id:this.id}${this.version?"@"+this.version:""}`}toJSON(){return {concept:this._concept,scope:this._scope,entity:this._entity,id:this._id,version:this._version,shard:this._shard}}verifyInput(e){switch(true){case(o.isString(e)&&!L.isASEID(e)):throw new O(O.ASEIDValidationError,"Invalid ASEID format provided");case(o.isObject(e)&&!e.id):throw new O(O.ASEIDValidationError,"ASEID id is required");case(o.isObject(e)&&!e.entity):throw new O(O.ASEIDValidationError,"ASEID entity is required")}}};a(L,"ASEID"),L.regexp=new RegExp("^[a-z|A-Z|0-9|-]+@[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|\\.|-]+(@v[0-9|\\.]+|@lts)?$");var P=L;var ce=class ce extends A{};a(ce,"A_EntityError"),ce.ValidationError="A-Entity Validation Error";var X=ce;var ye=class ye{static get entity(){return g.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e){this.getInitializer(e).call(this,e);}get id(){return this.aseid.id}isStringASEID(e){return typeof e=="string"&&P.isASEID(e)}isASEIDInstance(e){return e instanceof P}isSerializedObject(e){return !!e&&typeof e=="object"&&"aseid"in e}isConstructorProps(e){return !!e&&typeof e=="object"&&!("aseid"in e)}getInitializer(e){if(!e)return this.fromUndefined;if(this.isStringASEID(e))return this.fromASEID;if(this.isASEIDInstance(e))return this.fromASEID;if(this.isSerializedObject(e))return this.fromJSON;if(this.isConstructorProps(e))return this.fromNew;throw new X(X.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}generateASEID(e){return new P({concept:e?.concept||this.constructor.concept,scope:e?.scope||this.constructor.scope,entity:e?.entity||this.constructor.entity,id:e?.id||J.generateTimeId()})}async call(e,t){return await new v({name:e,component:this,scope:t}).process(t)}async load(e){return this.call("load",e)}async destroy(e){return this.call("destroy",e)}async save(e){return this.call("save",e)}fromASEID(e){e instanceof P?this.aseid=e:this.aseid=new P(e);}fromUndefined(){this.aseid=this.generateASEID();}fromNew(e){this.aseid=this.generateASEID();}fromJSON(e){this.aseid=new P(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};a(ye,"A_Entity");var R=ye;var ge=class ge extends d{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};a(ge,"A_EntityMeta");var H=ge;var Ce=class Ce{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};a(Ce,"A_Fragment");var K=Ce;var Pe=class Pe{static resolve(){return new Promise(e=>e())}static isInheritedFrom(e,t){let r=e;for(;r;){if(r===t)return true;r=Object.getPrototypeOf(r);}return false}static getParentClasses(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=[];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getClassInheritanceChain(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=typeof e=="function"?[e]:[e.constructor];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getParentClass(e){return Object.getPrototypeOf(e)}static omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(i,s){let _=s[0];s.length===1?delete i[_]:i[_]!==void 0&&typeof i[_]=="object"&&n(i[_],s.slice(1));}return a(n,"removeProperties"),t.forEach(i=>{let s=i.split(".");n(r,s);}),r}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static deepMerge(e,t,r=new Map){if(this.isObject(e)&&this.isObject(t))for(let n in t)this.isObject(t[n])?(e[n]||(e[n]={}),r.has(t[n])?e[n]=r.get(t[n]):(r.set(t[n],{}),this.deepMerge(e[n],t[n],r))):e[n]=t[n];return e}static deepClone(e){if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(t=>this.deepClone(t));if(typeof e=="function")return e;if(e instanceof Object){let t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=this.deepClone(e[r]));return t}throw new Error("Unable to clone the object. Unsupported type.")}static deepCloneAndMerge(e,t){if(t==null&&e==null)return e;if(e==null&&t)return this.deepClone(t);if(typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(r=>this.deepCloneAndMerge(r,t));if(typeof e=="function")return e;if(e instanceof Object){let r={};for(let n in e)t[n]!==null&&t[n]!==void 0?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(e[n]);for(let n in t)e[n]!==void 0&&e[n]!==null?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(t[n]);return r}throw new Error("Unable to clone the object. Unsupported type.")}static getComponentName(e){let t="Unknown",r="Anonymous";if(e==null)return t;if(typeof e=="string")return e||t;if(typeof e=="symbol")try{return e.toString()}catch{return t}if(Array.isArray(e))return e.length===0?t:this.getComponentName(e[0]);if(typeof e=="function"){let n=e;if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);try{let s=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(s)return s[1]||s[2]||s[3]||r}catch{}return r}if(typeof e=="object"){let n=e;if(n.type)return this.getComponentName(n.type);if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name&&n.constructor.name!=="Object")return String(n.constructor.name);try{let i=n.toString();if(typeof i=="string"&&i!=="[object Object]")return i}catch{}return r}try{return String(e)}catch{return t}}};a(Pe,"A_CommonHelper");var u=Pe;var z=class z extends A{};a(z,"A_ScopeError"),z.InitializationError="A-Scope Initialization Error",z.ConstructorError="Unable to construct A-Scope instance",z.ResolutionError="A-Scope Resolution Error",z.RegistrationError="A-Scope Registration Error",z.CircularInheritanceError="A-Scope Circular Inheritance Error",z.DeregistrationError="A-Scope Deregistration Error";var f=z;var pe=class pe{constructor(e,t){this._meta=new d;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get parent(){return this._parent}*parents(){let e=this._parent;for(;e;)yield e,e=e._parent;}parentAtLevel(e){let t=this._parent,r=0;for(;t;){if(r===e)return t;t=t._parent,r++;}}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new f(f.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>c.deregister(e)),this._fragments.forEach(e=>c.deregister(e)),this._entities.forEach(e=>c.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this.issuer()&&c.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return c.issuer(this)}inherit(e){if(!e)throw new f(f.InitializationError,"Invalid parent scope provided");if(e===this)throw new f(f.CircularInheritanceError,`Unable to inherit scope ${this.name} from itself`);if(e===this._parent)return this;let t=this.checkCircularInheritance(e);if(t)throw new f(f.CircularInheritanceError,`Circular inheritance detected: ${[...t,e.name].join(" -> ")}`);return this._parent=e,this}has(e){let t=this.hasFlat(e);if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}hasFlat(e){let t=false;switch(true){case o.isScopeConstructor(e):return true;case o.isString(e):{Array.from(this.allowedComponents).find(_=>_.name===e)&&(t=true),Array.from(this.allowedFragments).find(_=>_.name===e)&&(t=true),Array.from(this.allowedEntities).find(_=>_.name===e)&&(t=true),Array.from(this.allowedErrors).find(_=>_.name===e)&&(t=true);break}case o.isComponentConstructor(e):{t=this.isAllowedComponent(e)||!![...this.allowedComponents].find(r=>u.isInheritedFrom(r,e));break}case o.isEntityConstructor(e):{t=this.isAllowedEntity(e)||!![...this.allowedEntities].find(r=>u.isInheritedFrom(r,e));break}case o.isFragmentConstructor(e):{t=this.isAllowedFragment(e)||!![...this.allowedFragments].find(r=>u.isInheritedFrom(r,e));break}case o.isErrorConstructor(e):{t=this.isAllowedError(e)||!![...this.allowedErrors].find(r=>u.isInheritedFrom(r,e));break}case(this.issuer()&&(this.issuer().constructor===e||u.isInheritedFrom(this.issuer().constructor,e))):{t=true;break}}return t}merge(e){return new pe({name:`${this.name} + ${e.name}`,components:[...this.allowedComponents,...e.allowedComponents],fragments:[...this.fragments,...e.fragments],entities:[...this.entities,...e.entities,...this.allowedEntities,...e.allowedEntities]},{parent:this._parent||e._parent})}resolveConstructor(e){let t=Array.from(this.allowedComponents).find(i=>i.name===e||i.name===g.toPascalCase(e));if(t)return t;let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.entity===e||i.entity===g.toKebabCase(e));if(r)return r;let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===g.toPascalCase(e));if(n)return n;if(this._parent)return this._parent.resolveConstructor(e)}resolveAll(e){let t=[],r=this.resolveFlatAll(e);t.push(...r);let n=this._parent;for(;n&&n.has(e);){let i=n.resolveFlatAll(e);t.push(...i),n=n._parent;}return t}resolveFlatAll(e){let t=[];switch(true){case o.isComponentConstructor(e):{this.allowedComponents.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolve(r);n&&t.push(n);}});break}case o.isFragmentConstructor(e):{this.allowedFragments.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolve(r);n&&t.push(n);}});break}case o.isEntityConstructor(e):{this.entities.forEach(r=>{u.isInheritedFrom(r.constructor,e)&&t.push(r);});break}case o.isString(e):{let r=this.resolveConstructor(e);if(!o.isComponentConstructor(r)&&!o.isEntityConstructor(r)&&!o.isFragmentConstructor(r))throw new f(f.ResolutionError,`Unable to resolve all instances for name: ${e} in scope ${this.name} as no matching component, entity or fragment constructor found`);if(r){let n=this.resolveAll(r);n&&t.push(...n);}break}default:throw new f(f.ResolutionError,`Invalid parameter provided to resolveAll method: ${e} in scope ${this.name}`)}return t}resolve(e,t){return o.isArray(e)?e.map(r=>this.resolveOnce(r,t)):this.resolveOnce(e,t)}resolveFlat(e,t){return o.isArray(e)?e.map(r=>this.resolveFlatOnce(r,t)):this.resolveFlatOnce(e,t)}resolveByName(e){let t=Array.from(this.allowedComponents).find(s=>s.name===e||s.name===g.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(s=>s.name===e||s.name===g.toPascalCase(e)||s.entity===e||s.entity===g.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(s=>s.name===e||s.name===g.toPascalCase(e));if(n)return this.resolveOnce(n);let i=Array.from(this.allowedErrors).find(s=>s.name===e||s.name===g.toPascalCase(e)||s.code===e||s.code===g.toKebabCase(e));if(i)return this.resolveOnce(i)}resolveFlatOnce(e,t){let r,n=u.getComponentName(e);if(!(!e||!this.has(e))){switch(true){case o.isString(e):{r=this.resolveByName(e);break}case o.isConstructorAllowedForScopeAllocation(e):{r=this.resolveIssuer(e);break}case o.isEntityConstructor(e):{r=this.resolveEntity(e,t);break}case o.isFragmentConstructor(e):{r=this.resolveFragment(e);break}case o.isScopeConstructor(e):{r=this.resolveScope(e);break}case o.isComponentConstructor(e):{r=this.resolveComponent(e);break}case o.isErrorConstructor(e):{r=this.resolveError(e);break}default:throw new f(f.ResolutionError,`Injected Component ${n} not found in the scope`)}return r}}resolveOnce(e,t){let r=this.resolveFlatOnce(e,t);return !r&&this.parent?this.parent.resolveOnce(e,t):r}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t}resolveEntity(e,t){let r=t?.query||{},n=t?.pagination?.count||1;switch(true){case !t:return this.entities.find(i=>i instanceof e);case(!!r.aseid&&typeof r.aseid=="string"&&this._entities.has(r.aseid)):return this._entities.get(r.aseid);case(!!r.aseid&&typeof r.aseid=="object"&&r.aseid instanceof P&&this._entities.has(r.aseid.toString())):return this._entities.get(r.aseid.toString());case !!r.id:return this.entities.filter(s=>s instanceof e).find(s=>String(s.id)===String(r.id));default:{let i=this.entities.filter(s=>s instanceof e).filter(s=>Object.entries(r).every(([_,l])=>_ in s?s[_]===l:false));return i.length===0?void 0:n===1?i[0]:i}}}resolveError(e){return this.errors.find(t=>t instanceof e)}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&Array.from(this._allowedFragments).some(r=>u.isInheritedFrom(r,e))):{let r=Array.from(this._allowedFragments).find(n=>u.isInheritedFrom(n,e));return this.resolveFragment(r)}default:return}}resolveScope(e){return this}resolveComponent(e){switch(true){case(this.allowedComponents.has(e)&&this._components.has(e)):return this._components.get(e);case(this.allowedComponents.has(e)&&!this._components.has(e)):{let n=(c.meta(e).get("a-component-injections")?.get("constructor")||[]).map(s=>{let _=u.getComponentName(s.target);if("instructions"in s&&s.instructions){let{target:l,instructions:E}=s,y=this.resolve(l,E);if(!y)throw new f(f.ResolutionError,`Unable to resolve dependency ${_} for component ${e.name} in scope ${this.name}`);return y}else {let{target:l,require:E,create:y,defaultArgs:h}=s,w=this.resolve(l);if(y&&!w&&o.isAllowedForDependencyDefaultCreation(l)){let b=new l(...h);return this.register(b),b}if(E&&!w)throw new f(f.ResolutionError,`Unable to resolve required dependency ${_} for component ${e.name} in scope ${this.name}`);return w}}),i=new e(...n);return this.register(i),this._components.get(e)}case(!this.allowedComponents.has(e)&&Array.from(this.allowedComponents).some(t=>u.isInheritedFrom(t,e))):{let t=Array.from(this.allowedComponents).find(r=>u.isInheritedFrom(r,e));return this.resolveComponent(t)}default:return}}register(e){switch(true){case e instanceof F:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),c.register(this,e);break}case(o.isEntityInstance(e)&&!this._entities.has(e.aseid.toString())):{this.allowedEntities.has(e.constructor)||this.allowedEntities.add(e.constructor),this._entities.set(e.aseid.toString(),e),c.register(this,e);break}case o.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),c.register(this,e);break}case o.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),c.register(this,e);break}case o.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case o.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case o.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case o.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof R)throw new f(f.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof K)throw new f(f.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new f(f.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof F:{this._components.delete(e.constructor),c.deregister(e);break}case o.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),c.deregister(e);break}case o.isFragmentInstance(e):{this._fragments.delete(e.constructor),c.deregister(e);break}case o.isErrorInstance(e):{this._errors.delete(e.code),c.deregister(e);break}case o.isComponentConstructor(e):{this.allowedComponents.delete(e);break}case o.isFragmentConstructor(e):{this.allowedFragments.delete(e);break}case o.isEntityConstructor(e):{this.allowedEntities.delete(e);break}case o.isErrorConstructor(e):{this.allowedErrors.delete(e);break}default:let t=u.getComponentName(e);throw new f(f.DeregistrationError,`Cannot deregister ${t} from the scope ${this.name}`)}}toJSON(){return this.fragments.reduce((e,t)=>{let r=t.toJSON();return {...e,[r.name]:r}},{})}isAllowedComponent(e){return o.isComponentConstructor(e)&&this.allowedComponents.has(e)}isAllowedEntity(e){return o.isEntityConstructor(e)&&this.allowedEntities.has(e)}isAllowedFragment(e){return o.isFragmentConstructor(e)&&this.allowedFragments.has(e)}isAllowedError(e){return o.isErrorConstructor(e)&&this.allowedErrors.has(e)}isInheritedFrom(e){let t=this;for(;t;){if(t===e)return true;t=t._parent;}return false}checkCircularInheritance(e){let t=[],r=this._parent;for(;r;){if(t.push(r.name),r===e)return t;r=r._parent;}return false}printInheritanceChain(){let e=[],t=this;for(;t;)e.push(t.name),t=t._parent;console.log(e.join(" -> "));}};a(pe,"A_Scope");var x=pe;var me=class me extends A{};a(me,"A_CallerError"),me.CallerInitializationError="Unable to initialize A-Caller";var Q=me;var Ie=class Ie{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!o.isAllowedForFeatureCall(e))throw new Q(Q.CallerInitializationError,`Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};a(Ie,"A_Caller");var B=Ie;var T=class T{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isArray(e){return Array.isArray(e)}static isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static isFunction(e){return typeof e=="function"}static isUndefined(e){return typeof e>"u"}static isRegExp(e){return e instanceof RegExp}static isContainerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,$)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,F)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,K)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,x)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,A)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,v)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,B)}static isContainerInstance(e){return e instanceof $}static isComponentInstance(e){return e instanceof F}static isFeatureInstance(e){return e instanceof v}static isFragmentInstance(e){return e instanceof K}static isEntityInstance(e){return e instanceof R}static isScopeInstance(e){return e instanceof x}static isErrorInstance(e){return e instanceof A}static isComponentMetaInstance(e){return e instanceof j}static isContainerMetaInstance(e){return e instanceof U}static isEntityMetaInstance(e){return e instanceof H}static isConstructorAllowedForScopeAllocation(e){return T.isContainerConstructor(e)||T.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return T.isContainerInstance(e)||T.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return T.isContainerInstance(e)||T.isComponentInstance(e)}static isTargetAvailableForInjection(e){return T.isComponentConstructor(e)||T.isComponentInstance(e)||T.isContainerInstance(e)||T.isEntityInstance(e)}static isAllowedForFeatureCall(e){return T.isContainerInstance(e)||T.isComponentInstance(e)||T.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return T.isContainerInstance(e)||T.isComponentInstance(e)||T.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return T.isComponentInstance(e)||T.isContainerInstance(e)||T.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return T.isContainerInstance(e)||T.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return T.isComponentConstructor(e)||u.isInheritedFrom(e,F)||T.isEntityConstructor(e)||u.isInheritedFrom(e,R)}static isErrorConstructorType(e){return !!e&&T.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&T.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&P.isASEID(e.aseid)}};a(T,"A_TypeGuards");var o=T;var V=class V extends A{fromConstructor(e){super.fromConstructor(e),this.stage=e.stage;}};a(V,"A_FeatureError"),V.Interruption="Feature Interrupted",V.FeatureInitializationError="Unable to initialize A-Feature",V.FeatureProcessingError="Error occurred during A-Feature processing",V.FeatureDefinitionError="Unable to define A-Feature",V.FeatureExtensionError="Unable to extend A-Feature";var S=V;function be(p={}){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureDefinition(e))throw new S(S.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let i=c.meta(e.constructor),s;switch(true){case o.isEntityInstance(e):s="a-component-features";break;case o.isContainerInstance(e):s="a-container-features";break;case o.isComponentInstance(e):s="a-component-features";break}let _=i.get(s)||new d,l=p.name||t,E=p.invoke||false;_.set(t,{name:`${e.constructor.name}.${l}`,handler:t,invoke:E,template:p.template&&p.template.length?p.template.map(h=>({...h,before:h.before||"",after:h.after||"",behavior:h.behavior||"sync",throwOnError:true,override:h.override||""})):[]}),c.meta(e.constructor).set(s,_);let y=r.value;return r.value=function(...h){if(E)y.apply(this,h);else return y.apply(this,h);if(typeof this.call=="function"&&E)return this.call(l)},r}}a(be,"A_Feature_Define");function Ye(p){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureExtension(e))throw new S(S.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let i,s="sync",_="",l="",E="",y=[],h=[],w=true,b;switch(true){case o.isEntityInstance(e):b="a-component-extensions";break;case o.isContainerInstance(e):b="a-container-extensions";break;case o.isComponentInstance(e):b="a-component-extensions";break}switch(true){case o.isRegExp(p):i=p;break;case(!!p&&typeof p=="object"):Array.isArray(p.scope)?y=p.scope:p.scope&&typeof p.scope=="object"&&(Array.isArray(p.scope.include)&&(y=p.scope.include),Array.isArray(p.scope.exclude)&&(h=p.scope.exclude)),i=tt(p,y,h,t),s=p.behavior||s,w=p.throwOnError!==void 0?p.throwOnError:w,_=o.isArray(p.before)?new RegExp(`^${p.before.join("|").replace(/\./g,"\\.")}$`).source:p.before instanceof RegExp?p.before.source:"",l=o.isArray(p.after)?new RegExp(`^${p.after.join("|").replace(/\./g,"\\.")}$`).source:p.after instanceof RegExp?p.after.source:"",E=o.isArray(p.override)?new RegExp(`^${p.override.join("|").replace(/\./g,"\\.")}$`).source:p.override instanceof RegExp?p.override.source:"";break;default:i=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let ae=c.meta(e).get(b),Ue=c.meta(e),Ae=Ue.get(b)?new d().from(Ue.get(b)):new d;if(ae&&ae.size()&&ae.has(t)&&ae.get(t).invoke)throw new S(S.FeatureExtensionError,`A-Feature-Extend cannot be used on the method "${t}" because it is already defined as a Feature with "invoke" set to true. Please remove the A-Feature-Extend decorator or set "invoke" to false in the A-Feature decorator.`);let re=[...Ae.get(i.source)||[]],Je=re.findIndex(Ge=>Ge.handler===t),Ke={name:i.source,handler:t,behavior:s,before:_,after:l,throwOnError:w,override:E};Je!==-1?re[Je]=Ke:re.push(Ke),re.push(),Ae.set(i.source,re),c.meta(e).set(b,Ae);}}a(Ye,"A_Feature_Extend");function tt(p,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",i=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",s=p.scope?`^${i}${n}\\.${p.name||r}$`:`.*\\.${p.name||r}$`;return new RegExp(s)}a(tt,"buildTargetRegexp");var rt=(s=>(s.PROCESSING="PROCESSING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s.SKIPPED="SKIPPED",s.INITIALIZED="INITIALIZED",s.ABORTED="ABORTED",s))(rt||{});var ue=class ue extends A{static get CompileError(){return "Unable to compile A-Stage"}};a(ue,"A_StageError"),ue.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var M=ue;var we=class we{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}async getStepArgs(e,t){let r;switch(true){case o.isContainerInstance(t.component):r=t.component.constructor;break;case o.isString(t.component):r=e.resolveConstructor(t.component);break;default:r=t.component;break}return Promise.all(c.meta(r).injections(t.handler).map(async n=>{switch(true){case o.isCallerConstructor(n.target):return this._feature.caller.component;case o.isFeatureConstructor(n.target):return this._feature;default:{let{target:i,require:s,create:_,defaultArgs:l,parent:E,flat:y}=n,h,w=e;switch(true){case y:{h=w.resolveFlat(i);break}case(E&&typeof E.layerOffset=="number"):{let b=w.parentAtLevel(E.layerOffset);if(!b)throw new M(M.ArgumentsResolutionError,`Unable to resolve parent scope at layer offset ${E.layerOffset} for argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);h=b.resolve(i),w=b;break}default:{h=w.resolve(i);break}}if(_&&!h&&o.isAllowedForDependencyDefaultCreation(i)){let b=new i(...l);return w.register(b),b}if(s&&!h)throw new M(M.ArgumentsResolutionError,`Unable to resolve required argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);return h}}}))}getStepComponent(e,t){let{component:r,handler:n}=t,i;switch(true){case o.isContainerInstance(r):i=r;break;case o.isString(r):i=e.resolve(r)||this.feature.scope.resolve(r);break;default:i=e.resolve(r)||this.feature.scope.resolve(r);break}if(!i)throw new M(M.CompileError,`Unable to resolve component ${typeof r=="string"?r:r.name} from scope ${e.name}`);if(!i[n])throw new M(M.CompileError,`Handler ${n} not found in ${i.constructor.name}`);return i}async callStepHandler(e,t){let r=await this.getStepComponent(t,e),n=await this.getStepArgs(t,e);return await r[e.handler](...n)}skip(){this._status="SKIPPED";}async process(e){let t=o.isScopeInstance(e)?e:this._feature.scope;return this._processed||(this._processed=new Promise(async(r,n)=>{try{return this._status="PROCESSING",this._definition.behavior==="sync"?await this.callStepHandler(this._definition,t):this.callStepHandler(this._definition,t),this.completed(),r()}catch(i){let s=new A(i);return this.failed(s),this._definition.throwOnError?r():n(s)}})),this._processed}completed(){this._status="COMPLETED";}failed(e){this._error=new A(e),this._status="FAILED";}toJSON(){return {name:this.name,status:this.status}}toString(){return `A-Stage(${this._feature.name}::${this._definition.behavior}@${this._definition.handler})`}};a(we,"A_Stage");var oe=we;var le=class le extends A{};a(le,"A_StepManagerError"),le.CircularDependencyError="A-StepManager Circular Dependency Error";var ee=le;var ve=class ve{constructor(e){this._isBuilt=false;this.entities=this.prepareSteps(e),this.graph=new Map,this.visited=new Set,this.tempMark=new Set,this.sortedEntities=[];}prepareSteps(e){return e.map(t=>({...t,behavior:t.behavior||"sync",before:t.before||"",after:t.after||"",override:t.override||"",throwOnError:false}))}ID(e){return `${typeof e.component=="string"?e.component:e.component.name}.${e.handler}`}buildGraph(){this._isBuilt||(this._isBuilt=true,this.entities=this.entities.filter((e,t,r)=>!r.some(n=>n.override?new RegExp(n.override).test(this.ID(e)):false)),this.entities.forEach(e=>this.graph.set(this.ID(e),new Set)),this.entities.forEach(e=>{let t=this.ID(e);e.before&&this.matchEntities(t,e.before).forEach(n=>{this.graph.has(n)||this.graph.set(n,new Set),this.graph.get(n).add(t);}),e.after&&this.matchEntities(t,e.after).forEach(n=>{this.graph.has(t)||this.graph.set(t,new Set),this.graph.get(t).add(n);});}));}matchEntities(e,t){let r=new RegExp(t);return this.entities.filter(n=>r.test(this.ID(n))&&this.ID(n)!==e).map(n=>this.ID(n))}visit(e){this.tempMark.has(e)||this.visited.has(e)||(this.tempMark.add(e),(this.graph.get(e)||[]).forEach(t=>this.visit(t)),this.tempMark.delete(e),this.visited.add(e),this.sortedEntities.push(e));}toSortedArray(){return this.buildGraph(),this.entities.forEach(e=>{this.visited.has(this.ID(e))||this.visit(this.ID(e));}),this.sortedEntities}toStages(e){return this.toSortedArray().map(r=>{let n=this.entities.find(i=>this.ID(i)===r);return new oe(e,n)})}};a(ve,"A_StepsManager");var te=ve;var ie=class ie{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return be}static get Extend(){return Ye}get name(){return this._name}get error(){return this._error}get state(){return this._state}get index(){return this._index}get stage(){return this._current}get caller(){return this._caller}get scope(){return c.scope(this)}get size(){return this._stages.length}get isDone(){return !this.stage||this._index>=this._stages.length}get isProcessed(){return this.state==="COMPLETED"||this.state==="FAILED"||this.state==="INTERRUPTED"}[Symbol.iterator](){return {next:a(()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._stages[this._index],this._index++,{value:this._current,done:false}),"next")}}validateParams(e){if(!e||typeof e!="object")throw new S(S.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}getInitializer(e){switch(true){case !("template"in e):return this.fromComponent;case "template"in e:return this.fromTemplate;default:throw new S(S.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}}fromTemplate(e){if(!e.template||!Array.isArray(e.template))throw new S(S.FeatureInitializationError,`Invalid A-Feature template provided of type: ${typeof e.template} with value: ${JSON.stringify(e.template).slice(0,100)}...`);if(!e.component&&(!e.scope||!(e.scope instanceof x)))throw new S(S.FeatureInitializationError,`Invalid A-Feature scope provided of type: ${typeof e.scope} with value: ${JSON.stringify(e.scope).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{e.component&&(t=c.scope(e.component));}catch(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new B(e.component||new F),c.allocate(this).inherit(t||r),this._SM=new te(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!o.isAllowedForFeatureDefinition(e.component))throw new S(S.FeatureInitializationError,`Invalid A-Feature component provided of type: ${typeof e.component} with value: ${JSON.stringify(e.component).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{t=c.scope(e.component);}catch(s){if(!r)throw s}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new B(e.component);let n=c.allocate(this);n.inherit(t||r);let i=c.featureTemplate(this._name,this._caller.component,n);this._SM=new te(i),this._stages=this._SM.toStages(this),this._current=this._stages[0];}async process(e){try{if(this.isProcessed)return;this._state="PROCESSING";for(let t of this)await t.process(e);return await this.completed()}catch(t){return await this.failed(new S({title:S.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:t}))}}next(e){let t=this._stages.indexOf(e);this._index=t+1,this._index>=this._stages.length&&this.completed();}async completed(){this.isProcessed||(this._state="COMPLETED",this.scope.destroy());}async failed(e){if(!this.isProcessed)throw this._state="FAILED",this._error=e,this.scope.destroy(),this._error}async interrupt(e){if(!this.isProcessed){switch(this._state="INTERRUPTED",true){case o.isString(e):this._error=new S(S.Interruption,e);break;case o.isErrorInstance(e):this._error=new S({code:S.Interruption,title:e.title,description:e.description,stage:this.stage,originalError:e});break;}this.scope.destroy();}}chain(e,t,r){let n,i;e instanceof ie?(n=e,i=t instanceof x?t:void 0):(n=new ie({name:t,component:e}),i=r instanceof x?r:void 0);let s=i||this.scope;return n._caller=this._caller,n.process(s)}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};a(ie,"A_Feature");var v=ie;var Fe=class Fe{async call(e,t){return await new v({name:e,component:this}).process(t)}};a(Fe,"A_Component");var F=Fe;var C=class C extends A{};a(C,"A_ContextError"),C.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",C.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",C.InvalidMetaParameterError="Invalid parameter provided to get meta",C.InvalidScopeParameterError="Invalid parameter provided to get scope",C.ScopeNotFoundError="Scope not found",C.InvalidFeatureParameterError="Invalid parameter provided to get feature",C.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",C.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",C.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",C.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",C.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",C.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",C.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",C.InvalidInjectionParameterError="Invalid parameter provided to get injections",C.InvalidExtensionParameterError="Invalid parameter provided to get extensions",C.InvalidRegisterParameterError="Invalid parameter provided to register component",C.InvalidComponentParameterError="Invalid component provided",C.ComponentNotRegisteredError="Component not registered in the context",C.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var m=C;var D=class D{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;let e="root";D.environment==="server"&&(e=process.env[N.A_CONCEPT_ROOT_SCOPE]||"root"),D.environment==="browser"&&(e=window[N.A_CONCEPT_ROOT_SCOPE]||"root"),this._root=new x({name:e});}static get concept(){return process.env[N.A_CONCEPT_NAME]||"a-concept"}static get root(){return this.getInstance()._root}static get environment(){let e="browser";try{e=window.location?"browser":"server";}catch{e="server";}return e}static getInstance(){return D._instance||(D._instance=new D),D._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new m(m.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new m(m.NotAllowedForScopeAllocationError,`Component ${r} is not allowed for scope allocation.`);return n._scopeStorage.set(t,e),e}static deregister(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new m(m.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new m(m.ComponentNotRegisteredError,`Unable to deregister component. Component ${t} is not registered.`);r._scopeStorage.delete(e);}static allocate(e,t){let r=u.getComponentName(e);if(!this.isAllowedForScopeAllocation(e))throw new m(m.NotAllowedForScopeAllocationError,`Component of type ${r} is not allowed for scope allocation. Only A_Container, A_Feature are allowed.`);let n=this.getInstance();if(n._registry.has(e))throw new m(m.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let i=o.isScopeInstance(t)?t:new x(t||{name:r+"-scope"},t);return i.isInheritedFrom(D.root)||i.inherit(D.root),n._registry.set(e,i),n._scopeIssuers.set(i,e),i}static deallocate(e){let t=this.getInstance(),r=o.isScopeInstance(e)?e:t._registry.get(e);if(!r)return;let n=o.isComponentInstance(e)?e:this.issuer(r);n&&t._registry.delete(n),r&&t._scopeIssuers.delete(r);}static meta(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new m(m.InvalidMetaParameterError,"Invalid parameter provided to get meta. Parameter cannot be null or undefined.");if(!(this.isAllowedForMeta(e)||this.isAllowedForMetaConstructor(e)||o.isString(e)||o.isFunction(e)))throw new m(m.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component of type ${t} is not allowed for meta storage. Only A_Container, A_Component and A_Entity are allowed.`);let n,i;switch(true){case o.isContainerInstance(e):{n=e.constructor,i=U;break}case o.isContainerConstructor(e):{n=e,i=U;break}case o.isComponentInstance(e):{n=e.constructor,i=j;break}case o.isComponentConstructor(e):{n=e,i=j;break}case o.isEntityInstance(e):{n=e.constructor,i=j;break}case o.isEntityConstructor(e):{n=e,i=H;break}case typeof e=="string":{let s=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===g.toKebabCase(e)||_.name===g.toPascalCase(e));if(!(s&&s.length))throw new m(m.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=s[0],i=j;break}default:{n=e,i=d;break}}if(!r._metaStorage.has(n)){let s=r._metaStorage.get(Object.getPrototypeOf(n))||new i;r._metaStorage.set(n,new i().from(s));}return r._metaStorage.get(n)}static issuer(e){let t=this.getInstance();if(!e)throw new m(m.InvalidComponentParameterError,"Invalid parameter provided to get scope issuer. Parameter cannot be null or undefined.");return t._scopeIssuers.get(e)}static scope(e){let t=e?.constructor?.name||String(e),r=this.getInstance();if(!e)throw new m(m.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new m(m.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed for scope allocation.`);switch(true){case this.isAllowedForScopeAllocation(e):if(!r._registry.has(e))throw new m(m.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`);return r._registry.get(e);case this.isAllowedToBeRegistered(e):if(!r._scopeStorage.has(e))throw new m(m.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`);return r._scopeStorage.get(e);default:throw new m(m.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed to be registered.`)}}static featureTemplate(e,t,r=this.scope(t)){let n=u.getComponentName(t);if(!t)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new m(m.InvalidFeatureTemplateParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);return [...this.featureDefinition(e,t),...this.featureExtensions(e,t,r)]}static featureExtensions(e,t,r){let n=this.getInstance(),i=u.getComponentName(t);if(!t)throw new m(m.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new m(m.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${i} is not allowed for feature definition.`);let s=u.getClassInheritanceChain(t).filter(l=>l!==F&&l!==$&&l!==R).map(l=>`${l.name}.${e}`),_=[];for(let l of s)for(let[E,y]of n._metaStorage)r.has(E)&&(o.isComponentMetaInstance(y)||o.isContainerMetaInstance(y))&&y.extensions(l).forEach(h=>{_.push({component:E,...h});});return n.filterToMostDerived(r,_)}filterToMostDerived(e,t){return t.filter(r=>{let n=typeof r.component=="string"?e.resolveConstructor(r.component):o.isContainerInstance(r.component)?r.component.constructor:r.component;return !t.some(s=>{if(s===r)return false;let _=typeof s.component=="string"?e.resolveConstructor(s.component):o.isContainerInstance(s.component)?s.component.constructor:s.component;return n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");switch(true){case t instanceof R:r="a-component-features";break;case t instanceof $:r="a-container-features";break;case t instanceof F:r="a-component-features";break;default:throw new m(m.InvalidFeatureTemplateParameterError,`A-Feature cannot be defined on the ${t} level`)}return [...this.meta(t)?.get(r)?.get(e)?.template||[]]}static abstractionTemplate(e,t){let r=u.getComponentName(t);if(!t)throw new m(m.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new m(m.InvalidAbstractionTemplateParameterError,`Unable to get feature template. Component of type ${r} is not allowed for feature definition.`);return [...this.abstractionExtensions(e,t)]}static abstractionExtensions(e,t){let r=this.getInstance(),n=u.getComponentName(t);if(!t)throw new m(m.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new m(m.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let i=[],s=this.scope(t);for(let[_,l]of r._metaStorage)s.has(_)&&(o.isComponentMetaInstance(l)||o.isContainerMetaInstance(l))&&l.abstractions(e).forEach(E=>{i.push({component:_,...E});});return r.filterToMostDerived(s,i)}static reset(){let e=D.getInstance();e._registry=new WeakMap;let t="root";D.environment==="server"&&(t=process.env[N.A_CONCEPT_ROOT_SCOPE]||"root"),D.environment==="browser"&&(t=window[N.A_CONCEPT_ROOT_SCOPE]||"root"),e._root=new x({name:t});}static isAllowedForScopeAllocation(e){return o.isContainerInstance(e)||o.isFeatureInstance(e)}static isAllowedToBeRegistered(e){return o.isEntityInstance(e)||o.isComponentInstance(e)||o.isFragmentInstance(e)||o.isErrorInstance(e)}static isAllowedForMeta(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForMetaConstructor(e){return o.isContainerConstructor(e)||o.isComponentConstructor(e)||o.isEntityConstructor(e)}};a(D,"A_Context");var c=D;var de=class de extends A{};a(de,"A_AbstractionError"),de.AbstractionExtensionError="Unable to extend abstraction execution";var q=de;function xe(p,e={}){return function(t,r,n){let i=u.getComponentName(t);if(!p)throw new q(q.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${i}'.`);if(!o.isConstructorAvailableForAbstraction(t))throw new q(q.AbstractionExtensionError,`Unable to extend Abstraction '${p}' for '${i}'. Only A-Containers and A-Components can extend Abstractions.`);let s,_=c.meta(t);switch(true){case(o.isContainerConstructor(t)||o.isContainerInstance(t)):s="a-container-abstractions";break;case(o.isComponentConstructor(t)||o.isComponentInstance(t)):s="a-component-abstractions";break}let l=`CONCEPT_ABSTRACTION::${p}`,E=_.get(s)?new d().from(_.get(s)):new d,y=[...E.get(l)||[]],h=y.findIndex(b=>b.handler===r),w={name:l,handler:r,behavior:e.behavior||"sync",throwOnError:e.throwOnError!==void 0?e.throwOnError:true,before:o.isArray(e.before)?new RegExp(`^${e.before.join("|").replace(/\./g,"\\.")}$`).source:e.before instanceof RegExp?e.before.source:"",after:o.isArray(e.after)?new RegExp(`^${e.after.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:"",override:o.isArray(e.override)?new RegExp(`^${e.override.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:""};h!==-1?y[h]=w:y.push(w),E.set(l,y),c.meta(t).set(s,E);}}a(xe,"A_Abstraction_Extend");var De=class De{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=c.abstractionTemplate(this._name,t);return new v({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return xe}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:a(()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false}),"next")}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};a(De,"A_Abstraction");var Y=De;var nt=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(nt||{}),ot=(e=>(e.LIFECYCLE="a-component-extensions",e))(ot||{});var Oe=class Oe{constructor(e){this.props=e;this._name=e.name||c.root.name,e.components&&e.components.length&&e.components.forEach(t=>this.scope.register(t)),e.fragments&&e.fragments.length&&e.fragments.forEach(t=>this.scope.register(t)),e.entities&&e.entities.length&&e.entities.forEach(t=>this.scope.register(t)),this._containers=e.containers||[];}static Load(e){return Y.Extend("load",e)}static Publish(e){return Y.Extend("publish")}static Deploy(e){return Y.Extend("deploy",e)}static Build(e){return Y.Extend("build",e)}static Run(e){return Y.Extend("run",e)}static Start(e){return Y.Extend("start",e)}static Stop(e){return Y.Extend("stop",e)}get name(){return c.root.name}get scope(){return c.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new Y({name:"load",containers:this._containers}).process(e);}async run(e){await new Y({name:"run",containers:this._containers}).process(e);}async start(e){await new Y({name:"start",containers:this._containers}).process(e);}async stop(e){await new Y({name:"stop",containers:this._containers}).process(e);}async build(e){await new Y({name:"build",containers:this._containers}).process(e);}async deploy(e){await new Y({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new Y({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new v({name:e,component:t}).process()}};a(Oe,"A_Concept");var Ne=Oe;var Me=class Me extends d{constructor(t){super();this.containers=t;}};a(Me,"A_ConceptMeta");var Re=Me;var W=class W extends A{};a(W,"A_DependencyError"),W.InvalidDependencyTarget="Invalid Dependency Target",W.InvalidLoadTarget="Invalid Load Target",W.InvalidLoadPath="Invalid Load Path",W.InvalidDefaultTarget="Invalid Default Target";var I=W;function ke(...p){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new I(I.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",s;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):s="a-component-injections";break;case o.isContainerInstance(e):s="a-container-injections";break}let _=c.meta(e).get(s)||new d,l=_.get(i)||[];l[r]={...l[r]||{},defaultArgs:p,create:true},_.set(i,l),c.meta(e).set(s,_);}}a(ke,"A_Dependency_Default");function Ve(){return function(p,e,t){let r=u.getComponentName(p);if(!o.isTargetAvailableForInjection(p))throw new I(I.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof p} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(o.isComponentConstructor(p)||o.isComponentInstance(p)):i="a-component-injections";break;case o.isContainerInstance(p):i="a-container-injections";break}let s=c.meta(p).get(i)||new d,_=s.get(n)||[];_[t]={..._[t]||{},flat:true},s.set(n,_),c.meta(p).set(i,s);}}a(Ve,"A_Dependency_Flat");function je(p){if(!p||typeof p!="string")throw new I(I.InvalidLoadPath,"A-Load decorator requires a valid path string to the dependency");return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new I(I.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",s;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):s="a-component-injections";break;case o.isContainerInstance(e):s="a-container-injections";break}let _=c.meta(e).get(s)||new d,l=_.get(i)||[];l[r]={...l[r]||{},load:p},_.set(i,l),c.meta(e).set(s,_);}}a(je,"A_Dependency_Load");function qe(p=-1){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new I(I.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",s;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):s="a-component-injections";break;case o.isContainerInstance(e):s="a-container-injections";break}let _=c.meta(e).get(s)||new d,l=_.get(i)||[];l[r]={...l[r]||{},parent:{layerOffset:p}},_.set(i,l),c.meta(e).set(s,_);}}a(qe,"A_Dependency_Parent");function $e(){return function(p,e,t){let r=u.getComponentName(p);if(!o.isTargetAvailableForInjection(p))throw new I(I.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof p} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(o.isComponentConstructor(p)||o.isComponentInstance(p)):i="a-component-injections";break;case o.isContainerInstance(p):i="a-container-injections";break}let s=c.meta(p).get(i)||new d,_=s.get(n)||[];_[t]={..._[t]||{},require:true},s.set(n,_),c.meta(p).set(i,s);}}a($e,"A_Dependency_Require");var ze=class ze{static get Required(){return $e}static get Loaded(){return je}static get Default(){return ke}static get Parent(){return qe}static get Flat(){return Ve}constructor(e){this._name=e;}get name(){return this._name}};a(ze,"A_Dependency");var Le=ze;var se=class se extends A{};a(se,"A_InjectError"),se.InvalidInjectionTarget="Invalid target for A-Inject decorator",se.MissingInjectionTarget="Missing target for A-Inject decorator";var G=se;function it(p,e){if(!p)throw new G(G.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let i=u.getComponentName(t);if(!o.isTargetAvailableForInjection(t))throw new G(G.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${i})`);let s=r?String(r):"constructor",_;switch(true){case(o.isComponentConstructor(t)||o.isComponentInstance(t)):_="a-component-injections";break;case o.isContainerInstance(t):_="a-container-injections";break;case o.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,E=l.get(s)||[];E[n]={target:p,instructions:e},l.set(s,E),c.meta(t).set(_,l);}}a(it,"A_Inject");
|
|
2
|
-
exports.ASEID=
|
|
1
|
+
'use strict';var Ze=Object.defineProperty;var a=(p,e)=>Ze(p,"name",{value:e,configurable:true});var N={A_CONCEPT_NAME:"A_CONCEPT_NAME",A_CONCEPT_ROOT_SCOPE:"A_CONCEPT_ROOT_SCOPE",A_CONCEPT_ENVIRONMENT:"A_CONCEPT_ENVIRONMENT",A_CONCEPT_ROOT_FOLDER:"A_CONCEPT_ROOT_FOLDER",A_ERROR_DEFAULT_DESCRIPTION:"A_ERROR_DEFAULT_DESCRIPTION"},at=[N.A_CONCEPT_NAME,N.A_CONCEPT_ROOT_SCOPE,N.A_CONCEPT_ENVIRONMENT,N.A_CONCEPT_ROOT_FOLDER,N.A_ERROR_DEFAULT_DESCRIPTION];var He=(i=>(i.INITIALIZED="INITIALIZED",i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.INTERRUPTED="INTERRUPTED",i.FAILED="FAILED",i))(He||{});var ce=class ce{constructor(){this.meta=new Map;}[Symbol.iterator](){let e=this.meta.entries();return {next:a(()=>e.next(),"next")}}from(e){return this.meta=new Map(e.meta),this}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof ce:return e.toJSON();case e instanceof Map:let t={};for(let[n,i]of e.entries())t[String(n)]=this.recursiveToJSON(i);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,i]of Object.entries(e))r[n]=this.recursiveToJSON(i);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};a(ce,"A_Meta");var d=ce;var We=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(We||{}),Xe=(r=>(r.SAVE="save",r.DESTROY="destroy",r.LOAD="load",r))(Xe||{});var Qe=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Qe||{});var et=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(et||{});var Ee=class Ee extends d{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,i])=>{i.forEach(s=>{t.push({name:s.name,handler:s.handler,behavior:s.behavior,before:s.before||"",after:s.after||"",throwOnError:s.throwOnError||true,override:""});});}),t}features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-component-abstractions"),n=this.get("a-component-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,s])=>{s.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}};a(Ee,"A_ComponentMeta");var $=Ee;var Te=class Te{get name(){return this.config?.name||this.constructor.name}get scope(){return c.scope(this)}constructor(e={}){this.config=e,c.allocate(this,this.config);}async call(e,t){return await new v({name:e,component:this}).process(t)}};a(Te,"A_Container");var L=Te;var Se=class Se extends d{injections(e){return this.get("a-container-injections")?.get(e)||[]}features(){return this.get("a-container-features")?.toArray().map(([,t])=>t)||[]}abstractions(e){let t=[],r=this.get("a-container-abstractions"),n=this.get("a-container-injections");return r?.find(`CONCEPT_ABSTRACTION::${e}`).forEach(([i,s])=>{s.forEach(_=>{let l=n?.get(_.handler)||[];t.push({..._,args:l});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,i])=>{i.forEach(s=>{t.push({name:s.name,handler:s.handler,behavior:s.behavior,before:s.before||"",after:s.after||"",throwOnError:s.throwOnError||true,override:""});});}),t}};a(Se,"A_ContainerMeta");var J=Se;var he=class he{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};a(he,"A_FormatterHelper");var y=he;var ye=class ye{static generateTimeId(e={timestamp:new Date,random:Math.random().toString(36).slice(2,8)}){let t=e.timestamp.getTime().toString(36),r=e.random;return `${t}-${r}`}static parseTimeId(e){let[t,r]=e.split("-");return {timestamp:new Date(parseInt(t,36)),random:r}}static formatWithLeadingZeros(e,t=10){return String(e).padStart(t+1,"0").slice(-t)}static removeLeadingZeros(e){return String(Number(e))}};a(ye,"A_IdentityHelper");var K=ye;var H={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},Be="If you see this error please let us know.";var j=class j extends Error{static get entity(){return y.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof j:return e;case e instanceof Error:super(e.message);break;case o.isErrorSerializedType(e):super(e.message);break;case(o.isErrorConstructorType(e)&&"description"in e):super(`[${e.title}]: ${e.description}`);break;case(o.isErrorConstructorType(e)&&!("description"in e)):super(e.title);break;case(o.isString(e)&&!t):super(e);break;case(o.isString(e)&&!!t):super(`[${e}]: ${t}`);break;default:throw new j(H.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}this.getInitializer(e,t).call(this,e,t);}get aseid(){return this._aseid}get title(){return this._title}get message(){return super.message}get code(){return this._code||y.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||process.env[N.A_ERROR_DEFAULT_DESCRIPTION]||Be}get originalError(){return this._originalError}getInitializer(e,t){switch(true){case(o.isString(e)&&!t):return this.fromMessage;case(o.isString(e)&&!!t):return this.fromTitle;case e instanceof Error:return this.fromError;case o.isErrorSerializedType(e):return this.fromJSON;case o.isErrorConstructorType(e):return this.fromConstructor;default:throw new j(H.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new I({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=H.UNEXPECTED_ERROR,this._aseid=new I({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromJSON(e){this._aseid=new I(e.aseid),super.message=e.message,this._title=e.title,this._code=e.code,this._scope=e.scope,this._description=e.description,this._originalError=e.originalError?new j(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new I({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._link=void 0,this._originalError=void 0;}fromConstructor(e){if(this.validateTitle(e.title),this._title=e.title,this._code=e.code,this._scope=e.scope?o.isScopeInstance(e.scope)?e.scope.name:e.scope:void 0,this._aseid=new I({concept:this.constructor.concept,scope:this._scope||this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._description=e.description,this._link=e.link,e.originalError instanceof j){let t=e.originalError;for(;t.originalError instanceof j;)t=t.originalError;this._originalError=t.originalError||t;}else this._originalError=e.originalError;}toJSON(){return {aseid:this.aseid.toString(),title:this.title,code:this.code,type:this.type,message:this.message,link:this.link,scope:this.scope,description:this.description,originalError:this.originalError?.message}}validateTitle(e){if(e.length>60)throw new j(H.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new j(H.VALIDATION_ERROR,"A-Error title cannot be empty.")}};a(j,"A_Error");var f=j;var ie=class ie extends f{};a(ie,"ASEID_Error"),ie.ASEIDInitializationError="ASEID Initialization Error",ie.ASEIDValidationError="ASEID Validation Error";var R=ie;var z=class z{static isASEID(e){return this.regexp.test(e)}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||c.concept}get scope(){return this._scope||c.root.name}get entity(){return this._entity}get id(){return this._id}get version(){return this._version}get shard(){return this._shard}getInitializer(e){switch(true){case o.isString(e):return this.fromString;case o.isObject(e):return this.fromObject;default:throw new R(R.ASEIDInitializationError,"Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[i,s,_]=r.split(":"),l=_.includes(".")?_.split(".")[0]:void 0,E=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=i||c.root.name,this._entity=s,this._id=E,this._version=n,this._shard=l;}fromObject(e){this._concept=e.concept?z.isASEID(e.concept)?new z(e.concept).id:e.concept:c.concept,this._scope=e.scope?o.isNumber(e.scope)?K.formatWithLeadingZeros(e.scope):z.isASEID(e.scope)?new z(e.scope).id:e.scope:c.root.name,this._entity=e.entity,this._id=o.isNumber(e.id)?K.formatWithLeadingZeros(e.id):e.id,this._version=e.version,this._shard=e.shard;}toString(){return `${this.concept}@${this.scope}:${this.entity}:${this.shard?this.shard+"."+this.id:this.id}${this.version?"@"+this.version:""}`}toJSON(){return {concept:this._concept,scope:this._scope,entity:this._entity,id:this._id,version:this._version,shard:this._shard}}verifyInput(e){switch(true){case(o.isString(e)&&!z.isASEID(e)):throw new R(R.ASEIDValidationError,"Invalid ASEID format provided");case(o.isObject(e)&&!e.id):throw new R(R.ASEIDValidationError,"ASEID id is required");case(o.isObject(e)&&!e.entity):throw new R(R.ASEIDValidationError,"ASEID entity is required")}}};a(z,"ASEID"),z.regexp=new RegExp("^[a-z|A-Z|0-9|-]+@[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|-]+:[a-z|A-Z|0-9|\\.|-]+(@v[0-9|\\.]+|@lts)?$");var I=z;var pe=class pe extends f{};a(pe,"A_EntityError"),pe.ValidationError="A-Entity Validation Error";var Q=pe;var ge=class ge{static get entity(){return y.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e){this.getInitializer(e).call(this,e);}get id(){return this.aseid.id}isStringASEID(e){return typeof e=="string"&&I.isASEID(e)}isASEIDInstance(e){return e instanceof I}isSerializedObject(e){return !!e&&typeof e=="object"&&"aseid"in e}isConstructorProps(e){return !!e&&typeof e=="object"&&!("aseid"in e)}getInitializer(e){if(!e)return this.fromUndefined;if(this.isStringASEID(e))return this.fromASEID;if(this.isASEIDInstance(e))return this.fromASEID;if(this.isSerializedObject(e))return this.fromJSON;if(this.isConstructorProps(e))return this.fromNew;throw new Q(Q.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}generateASEID(e){return new I({concept:e?.concept||this.constructor.concept,scope:e?.scope||this.constructor.scope,entity:e?.entity||this.constructor.entity,id:e?.id||K.generateTimeId()})}async call(e,t){return await new v({name:e,component:this,scope:t}).process(t)}async load(e){return this.call("load",e)}async destroy(e){return this.call("destroy",e)}async save(e){return this.call("save",e)}fromASEID(e){e instanceof I?this.aseid=e:this.aseid=new I(e);}fromUndefined(){this.aseid=this.generateASEID();}fromNew(e){this.aseid=this.generateASEID();}fromJSON(e){this.aseid=new I(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};a(ge,"A_Entity");var M=ge;var Ce=class Ce extends d{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};a(Ce,"A_EntityMeta");var W=Ce;var Pe=class Pe{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};a(Pe,"A_Fragment");var B=Pe;var Ie=class Ie{static resolve(){return new Promise(e=>e())}static isInheritedFrom(e,t){let r=e;for(;r;){if(r===t)return true;r=Object.getPrototypeOf(r);}return false}static getParentClasses(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=[];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getClassInheritanceChain(e){let t=Object.getPrototypeOf(typeof e=="function"?e:e.constructor),r=typeof e=="function"?[e]:[e.constructor];for(;t&&t!==Function.prototype;)r.push(t),t=Object.getPrototypeOf(t);return r}static getParentClass(e){return Object.getPrototypeOf(e)}static omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(i,s){let _=s[0];s.length===1?delete i[_]:i[_]!==void 0&&typeof i[_]=="object"&&n(i[_],s.slice(1));}return a(n,"removeProperties"),t.forEach(i=>{let s=i.split(".");n(r,s);}),r}static isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}static deepMerge(e,t,r=new Map){if(this.isObject(e)&&this.isObject(t))for(let n in t)this.isObject(t[n])?(e[n]||(e[n]={}),r.has(t[n])?e[n]=r.get(t[n]):(r.set(t[n],{}),this.deepMerge(e[n],t[n],r))):e[n]=t[n];return e}static deepClone(e){if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(t=>this.deepClone(t));if(typeof e=="function")return e;if(e instanceof Object){let t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=this.deepClone(e[r]));return t}throw new Error("Unable to clone the object. Unsupported type.")}static deepCloneAndMerge(e,t){if(t==null&&e==null)return e;if(e==null&&t)return this.deepClone(t);if(typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(r=>this.deepCloneAndMerge(r,t));if(typeof e=="function")return e;if(e instanceof Object){let r={};for(let n in e)t[n]!==null&&t[n]!==void 0?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(e[n]);for(let n in t)e[n]!==void 0&&e[n]!==null?r[n]=this.deepCloneAndMerge(e[n],t[n]):r[n]=this.deepClone(t[n]);return r}throw new Error("Unable to clone the object. Unsupported type.")}static getComponentName(e){let t="Unknown",r="Anonymous";if(e==null)return t;if(typeof e=="string")return e||t;if(typeof e=="symbol")try{return e.toString()}catch{return t}if(Array.isArray(e))return e.length===0?t:this.getComponentName(e[0]);if(typeof e=="function"){let n=e;if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);try{let s=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(s)return s[1]||s[2]||s[3]||r}catch{}return r}if(typeof e=="object"){let n=e;if(n.type)return this.getComponentName(n.type);if(n.displayName)return String(n.displayName);if(n.name)return String(n.name);if(n.constructor&&n.constructor.name&&n.constructor.name!=="Object")return String(n.constructor.name);try{let i=n.toString();if(typeof i=="string"&&i!=="[object Object]")return i}catch{}return r}try{return String(e)}catch{return t}}};a(Ie,"A_CommonHelper");var u=Ie;var U=class U extends f{};a(U,"A_ScopeError"),U.InitializationError="A-Scope Initialization Error",U.ConstructorError="Unable to construct A-Scope instance",U.ResolutionError="A-Scope Resolution Error",U.RegistrationError="A-Scope Registration Error",U.CircularInheritanceError="A-Scope Circular Inheritance Error",U.DeregistrationError="A-Scope Deregistration Error";var A=U;var me=class me{constructor(e,t){this._meta=new d;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get parent(){return this._parent}*parents(){let e=this._parent;for(;e;)yield e,e=e._parent;}parentOffset(e){let t=this.parent;for(;e<-1&&t;)t=t.parent,e++;return t}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new A(A.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>c.deregister(e)),this._fragments.forEach(e=>c.deregister(e)),this._entities.forEach(e=>c.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this.issuer()&&c.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return c.issuer(this)}inherit(e){if(!e)throw new A(A.InitializationError,"Invalid parent scope provided");if(e===this)throw new A(A.CircularInheritanceError,`Unable to inherit scope ${this.name} from itself`);if(e===this._parent)return this;let t=this.checkCircularInheritance(e);if(t)throw new A(A.CircularInheritanceError,`Circular inheritance detected: ${[...t,e.name].join(" -> ")}`);return this._parent=e,this}has(e){let t=this.hasFlat(e);if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}hasFlat(e){let t=false;switch(true){case o.isScopeConstructor(e):return true;case o.isString(e):{Array.from(this.allowedComponents).find(_=>_.name===e)&&(t=true),Array.from(this.allowedFragments).find(_=>_.name===e)&&(t=true),Array.from(this.allowedEntities).find(_=>_.name===e)&&(t=true),Array.from(this.allowedErrors).find(_=>_.name===e)&&(t=true);break}case o.isComponentConstructor(e):{t=this.isAllowedComponent(e)||!![...this.allowedComponents].find(r=>u.isInheritedFrom(r,e));break}case o.isEntityConstructor(e):{t=this.isAllowedEntity(e)||!![...this.allowedEntities].find(r=>u.isInheritedFrom(r,e));break}case o.isFragmentConstructor(e):{t=this.isAllowedFragment(e)||!![...this.allowedFragments].find(r=>u.isInheritedFrom(r,e));break}case o.isErrorConstructor(e):{t=this.isAllowedError(e)||!![...this.allowedErrors].find(r=>u.isInheritedFrom(r,e));break}case(this.issuer()&&(this.issuer().constructor===e||u.isInheritedFrom(this.issuer().constructor,e))):{t=true;break}}return t}merge(e){return new me({name:`${this.name} + ${e.name}`,components:[...this.allowedComponents,...e.allowedComponents],fragments:[...this.fragments,...e.fragments],entities:[...this.entities,...e.entities,...this.allowedEntities,...e.allowedEntities]},{parent:this._parent||e._parent})}resolveConstructor(e){let t=Array.from(this.allowedComponents).find(i=>i.name===e||i.name===y.toPascalCase(e));if(t)return t;let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===y.toPascalCase(e)||i.entity===e||i.entity===y.toKebabCase(e));if(r)return r;let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===y.toPascalCase(e));if(n)return n;if(this._parent)return this._parent.resolveConstructor(e)}resolveAll(e){let t=[],r=this.resolveFlatAll(e);t.push(...r);let n=this._parent;for(;n&&n.has(e);){let i=n.resolveFlatAll(e);t.push(...i),n=n._parent;}return t}resolveFlatAll(e){let t=[];switch(true){case o.isComponentConstructor(e):{this.allowedComponents.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolve(r);n&&t.push(n);}});break}case o.isFragmentConstructor(e):{this.allowedFragments.forEach(r=>{if(u.isInheritedFrom(r,e)){let n=this.resolve(r);n&&t.push(n);}});break}case o.isEntityConstructor(e):{this.entities.forEach(r=>{u.isInheritedFrom(r.constructor,e)&&t.push(r);});break}case o.isString(e):{let r=this.resolveConstructor(e);if(!o.isComponentConstructor(r)&&!o.isEntityConstructor(r)&&!o.isFragmentConstructor(r))throw new A(A.ResolutionError,`Unable to resolve all instances for name: ${e} in scope ${this.name} as no matching component, entity or fragment constructor found`);if(r){let n=this.resolveAll(r);n&&t.push(...n);}break}default:throw new A(A.ResolutionError,`Invalid parameter provided to resolveAll method: ${e} in scope ${this.name}`)}return t}resolve(e,t){return o.isArray(e)?e.map(r=>this.resolveOnce(r,t)):this.resolveOnce(e,t)}resolveFlat(e,t){return o.isArray(e)?e.map(r=>this.resolveFlatOnce(r,t)):this.resolveFlatOnce(e,t)}resolveByName(e){let t=Array.from(this.allowedComponents).find(s=>s.name===e||s.name===y.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(s=>s.name===e||s.name===y.toPascalCase(e)||s.entity===e||s.entity===y.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(s=>s.name===e||s.name===y.toPascalCase(e));if(n)return this.resolveOnce(n);let i=Array.from(this.allowedErrors).find(s=>s.name===e||s.name===y.toPascalCase(e)||s.code===e||s.code===y.toKebabCase(e));if(i)return this.resolveOnce(i)}resolveFlatOnce(e,t){let r,n=u.getComponentName(e);if(!(!e||!this.has(e))){switch(true){case o.isString(e):{r=this.resolveByName(e);break}case o.isConstructorAllowedForScopeAllocation(e):{r=this.resolveIssuer(e);break}case o.isEntityConstructor(e):{r=this.resolveEntity(e,t);break}case o.isFragmentConstructor(e):{r=this.resolveFragment(e);break}case o.isScopeConstructor(e):{r=this.resolveScope(e);break}case o.isComponentConstructor(e):{r=this.resolveComponent(e);break}case o.isErrorConstructor(e):{r=this.resolveError(e);break}default:throw new A(A.ResolutionError,`Injected Component ${n} not found in the scope`)}return r}}resolveOnce(e,t){let r=this.resolveFlatOnce(e,t);return !r&&this.parent?this.parent.resolveOnce(e,t):r}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t}resolveEntity(e,t){let r=t?.query||{},n=t?.pagination?.count||1;switch(true){case !t:return this.entities.find(i=>i instanceof e);case(!!r.aseid&&typeof r.aseid=="string"&&this._entities.has(r.aseid)):return this._entities.get(r.aseid);case(!!r.aseid&&typeof r.aseid=="object"&&r.aseid instanceof I&&this._entities.has(r.aseid.toString())):return this._entities.get(r.aseid.toString());case !!r.id:return this.entities.filter(s=>s instanceof e).find(s=>String(s.id)===String(r.id));default:{let i=this.entities.filter(s=>s instanceof e).filter(s=>Object.entries(r).every(([_,l])=>_ in s?s[_]===l:false));return i.length===0?void 0:n===1?i[0]:i}}}resolveError(e){return this.errors.find(t=>t instanceof e)}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&Array.from(this._allowedFragments).some(r=>u.isInheritedFrom(r,e))):{let r=Array.from(this._allowedFragments).find(n=>u.isInheritedFrom(n,e));return this.resolveFragment(r)}default:return}}resolveScope(e){return this}resolveComponent(e){switch(true){case(this.allowedComponents.has(e)&&this._components.has(e)):return this._components.get(e);case(this.allowedComponents.has(e)&&!this._components.has(e)):{let n=(c.meta(e).get("a-component-injections")?.get("constructor")||[]).map(s=>{let _=u.getComponentName(s.target);if("instructions"in s&&s.instructions){let{target:l,parent:E,flat:C,instructions:h}=s,P=this.resolve(l,h);if(!P)throw new A(A.ResolutionError,`Unable to resolve dependency ${_} for component ${e.name} in scope ${this.name}`);return P}else {let{target:l,require:E,create:C,defaultArgs:h,parent:P,flat:Y}=s,O;switch(true){case Y:{O=this.resolveFlat(l);break}case(P&&typeof P.layerOffset=="number"):{let ne=this.parentOffset(P.layerOffset);if(!ne)throw new A(A.ResolutionError,`Unable to resolve parent scope at offset ${P.layerOffset} for dependency ${_} for component ${e.name} in scope ${this.name}`);O=ne.resolve(l);break}default:{O=this.resolve(l);break}}if(C&&!O&&o.isAllowedForDependencyDefaultCreation(l)&&(O=new l(...h),this.register(O)),E&&!O)throw new A(A.ResolutionError,`Unable to resolve required dependency ${_} for component ${e.name} in scope ${this.name}`);return O}}),i=new e(...n);return this.register(i),this._components.get(e)}case(!this.allowedComponents.has(e)&&Array.from(this.allowedComponents).some(t=>u.isInheritedFrom(t,e))):{let t=Array.from(this.allowedComponents).find(r=>u.isInheritedFrom(r,e));return this.resolveComponent(t)}default:return}}register(e){switch(true){case e instanceof F:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),c.register(this,e);break}case(o.isEntityInstance(e)&&!this._entities.has(e.aseid.toString())):{this.allowedEntities.has(e.constructor)||this.allowedEntities.add(e.constructor),this._entities.set(e.aseid.toString(),e),c.register(this,e);break}case o.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),c.register(this,e);break}case o.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),c.register(this,e);break}case o.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case o.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case o.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case o.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof M)throw new A(A.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof B)throw new A(A.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new A(A.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof F:{this._components.delete(e.constructor),c.deregister(e);break}case o.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),c.deregister(e);break}case o.isFragmentInstance(e):{this._fragments.delete(e.constructor),c.deregister(e);break}case o.isErrorInstance(e):{this._errors.delete(e.code),c.deregister(e);break}case o.isComponentConstructor(e):{this.allowedComponents.delete(e);break}case o.isFragmentConstructor(e):{this.allowedFragments.delete(e);break}case o.isEntityConstructor(e):{this.allowedEntities.delete(e);break}case o.isErrorConstructor(e):{this.allowedErrors.delete(e);break}default:let t=u.getComponentName(e);throw new A(A.DeregistrationError,`Cannot deregister ${t} from the scope ${this.name}`)}}toJSON(){return this.fragments.reduce((e,t)=>{let r=t.toJSON();return {...e,[r.name]:r}},{})}isAllowedComponent(e){return o.isComponentConstructor(e)&&this.allowedComponents.has(e)}isAllowedEntity(e){return o.isEntityConstructor(e)&&this.allowedEntities.has(e)}isAllowedFragment(e){return o.isFragmentConstructor(e)&&this.allowedFragments.has(e)}isAllowedError(e){return o.isErrorConstructor(e)&&this.allowedErrors.has(e)}isInheritedFrom(e){let t=this;for(;t;){if(t===e)return true;t=t._parent;}return false}checkCircularInheritance(e){let t=[],r=this._parent;for(;r;){if(t.push(r.name),r===e)return t;r=r._parent;}return false}printInheritanceChain(){let e=[],t=this;for(;t;)e.push(t.name),t=t._parent;console.log(e.join(" -> "));}};a(me,"A_Scope");var x=me;var ue=class ue extends f{};a(ue,"A_CallerError"),ue.CallerInitializationError="Unable to initialize A-Caller";var ee=ue;var be=class be{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!o.isAllowedForFeatureCall(e))throw new ee(ee.CallerInitializationError,`Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};a(be,"A_Caller");var V=be;var T=class T{static isString(e){return typeof e=="string"||e instanceof String}static isNumber(e){return typeof e=="number"&&isFinite(e)}static isBoolean(e){return typeof e=="boolean"}static isArray(e){return Array.isArray(e)}static isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static isFunction(e){return typeof e=="function"}static isUndefined(e){return typeof e>"u"}static isRegExp(e){return e instanceof RegExp}static isContainerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,L)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,F)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,B)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,M)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,x)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,f)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,v)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,V)}static isContainerInstance(e){return e instanceof L}static isComponentInstance(e){return e instanceof F}static isFeatureInstance(e){return e instanceof v}static isFragmentInstance(e){return e instanceof B}static isEntityInstance(e){return e instanceof M}static isScopeInstance(e){return e instanceof x}static isErrorInstance(e){return e instanceof f}static isComponentMetaInstance(e){return e instanceof $}static isContainerMetaInstance(e){return e instanceof J}static isEntityMetaInstance(e){return e instanceof W}static isConstructorAllowedForScopeAllocation(e){return T.isContainerConstructor(e)||T.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return T.isContainerInstance(e)||T.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return T.isContainerInstance(e)||T.isComponentInstance(e)}static isTargetAvailableForInjection(e){return T.isComponentConstructor(e)||T.isComponentInstance(e)||T.isContainerInstance(e)||T.isEntityInstance(e)}static isAllowedForFeatureCall(e){return T.isContainerInstance(e)||T.isComponentInstance(e)||T.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return T.isContainerInstance(e)||T.isComponentInstance(e)||T.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return T.isComponentInstance(e)||T.isContainerInstance(e)||T.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return T.isContainerInstance(e)||T.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return T.isComponentConstructor(e)||u.isInheritedFrom(e,F)||T.isEntityConstructor(e)||u.isInheritedFrom(e,M)}static isErrorConstructorType(e){return !!e&&T.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&T.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&I.isASEID(e.aseid)}};a(T,"A_TypeGuards");var o=T;var q=class q extends f{fromConstructor(e){super.fromConstructor(e),this.stage=e.stage;}};a(q,"A_FeatureError"),q.Interruption="Feature Interrupted",q.FeatureInitializationError="Unable to initialize A-Feature",q.FeatureProcessingError="Error occurred during A-Feature processing",q.FeatureDefinitionError="Unable to define A-Feature",q.FeatureExtensionError="Unable to extend A-Feature";var S=q;function Ye(p={}){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureDefinition(e))throw new S(S.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let i=c.meta(e.constructor),s;switch(true){case o.isEntityInstance(e):s="a-component-features";break;case o.isContainerInstance(e):s="a-container-features";break;case o.isComponentInstance(e):s="a-component-features";break}let _=i.get(s)||new d,l=p.name||t,E=p.invoke||false;_.set(t,{name:`${e.constructor.name}.${l}`,handler:t,invoke:E,template:p.template&&p.template.length?p.template.map(h=>({...h,before:h.before||"",after:h.after||"",behavior:h.behavior||"sync",throwOnError:true,override:h.override||""})):[]}),c.meta(e.constructor).set(s,_);let C=r.value;return r.value=function(...h){if(E)C.apply(this,h);else return C.apply(this,h);if(typeof this.call=="function"&&E)return this.call(l)},r}}a(Ye,"A_Feature_Define");function we(p){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureExtension(e))throw new S(S.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let i,s="sync",_="",l="",E="",C=[],h=[],P=true,Y;switch(true){case o.isEntityInstance(e):Y="a-component-extensions";break;case o.isContainerInstance(e):Y="a-container-extensions";break;case o.isComponentInstance(e):Y="a-component-extensions";break}switch(true){case o.isRegExp(p):i=p;break;case(!!p&&typeof p=="object"):Array.isArray(p.scope)?C=p.scope:p.scope&&typeof p.scope=="object"&&(Array.isArray(p.scope.include)&&(C=p.scope.include),Array.isArray(p.scope.exclude)&&(h=p.scope.exclude)),i=tt(p,C,h,t),s=p.behavior||s,P=p.throwOnError!==void 0?p.throwOnError:P,_=o.isArray(p.before)?new RegExp(`^${p.before.join("|").replace(/\./g,"\\.")}$`).source:p.before instanceof RegExp?p.before.source:"",l=o.isArray(p.after)?new RegExp(`^${p.after.join("|").replace(/\./g,"\\.")}$`).source:p.after instanceof RegExp?p.after.source:"",E=o.isArray(p.override)?new RegExp(`^${p.override.join("|").replace(/\./g,"\\.")}$`).source:p.override instanceof RegExp?p.override.source:"";break;default:i=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let O=c.meta(e).get(Y),ne=c.meta(e),fe=ne.get(Y)?new d().from(ne.get(Y)):new d;if(O&&O.size()&&O.has(t)&&O.get(t).invoke)throw new S(S.FeatureExtensionError,`A-Feature-Extend cannot be used on the method "${t}" because it is already defined as a Feature with "invoke" set to true. Please remove the A-Feature-Extend decorator or set "invoke" to false in the A-Feature decorator.`);let oe=[...fe.get(i.source)||[]],Je=oe.findIndex(Ge=>Ge.handler===t),Ke={name:i.source,handler:t,behavior:s,before:_,after:l,throwOnError:P,override:E};Je!==-1?oe[Je]=Ke:oe.push(Ke),oe.push(),fe.set(i.source,oe),c.meta(e).set(Y,fe);}}a(we,"A_Feature_Extend");function tt(p,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",i=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",s=p.scope?`^${i}${n}\\.${p.name||r}$`:`.*\\.${p.name||r}$`;return new RegExp(s)}a(tt,"buildTargetRegexp");var rt=(s=>(s.PROCESSING="PROCESSING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s.SKIPPED="SKIPPED",s.INITIALIZED="INITIALIZED",s.ABORTED="ABORTED",s))(rt||{});var le=class le extends f{static get CompileError(){return "Unable to compile A-Stage"}};a(le,"A_StageError"),le.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var k=le;var ve=class ve{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}async getStepArgs(e,t){let r;switch(true){case o.isContainerInstance(t.component):r=t.component.constructor;break;case o.isString(t.component):r=e.resolveConstructor(t.component);break;default:r=t.component;break}return Promise.all(c.meta(r).injections(t.handler).map(async n=>{switch(true){case o.isCallerConstructor(n.target):return this._feature.caller.component;case o.isFeatureConstructor(n.target):return this._feature;default:{let{target:i,require:s,create:_,defaultArgs:l,parent:E,flat:C}=n,h,P=e;switch(true){case C:{h=P.resolveFlat(i);break}case(E&&typeof E.layerOffset=="number"):{let Y=P.parentOffset(E.layerOffset);if(!Y)throw new k(k.ArgumentsResolutionError,`Unable to resolve parent scope at layer offset ${E.layerOffset} for argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);h=Y.resolve(i),P=Y;break}default:{h=P.resolve(i);break}}if(_&&!h&&o.isAllowedForDependencyDefaultCreation(i)){let Y=new i(...l);return P.register(Y),Y}if(s&&!h)throw new k(k.ArgumentsResolutionError,`Unable to resolve required argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);return h}}}))}getStepComponent(e,t){let{component:r,handler:n}=t,i;switch(true){case o.isContainerInstance(r):i=r;break;case o.isString(r):i=e.resolve(r)||this.feature.scope.resolve(r);break;default:i=e.resolve(r)||this.feature.scope.resolve(r);break}if(!i)throw new k(k.CompileError,`Unable to resolve component ${typeof r=="string"?r:r.name} from scope ${e.name}`);if(!i[n])throw new k(k.CompileError,`Handler ${n} not found in ${i.constructor.name}`);return i}async callStepHandler(e,t){let r=await this.getStepComponent(t,e),n=await this.getStepArgs(t,e);return await r[e.handler](...n)}skip(){this._status="SKIPPED";}async process(e){let t=o.isScopeInstance(e)?e:this._feature.scope;return this._processed||(this._processed=new Promise(async(r,n)=>{try{return this._status="PROCESSING",this._definition.behavior==="sync"?await this.callStepHandler(this._definition,t):this.callStepHandler(this._definition,t),this.completed(),r()}catch(i){let s=new f(i);return this.failed(s),this._definition.throwOnError?r():n(s)}})),this._processed}completed(){this._status="COMPLETED";}failed(e){this._error=new f(e),this._status="FAILED";}toJSON(){return {name:this.name,status:this.status}}toString(){return `A-Stage(${this._feature.name}::${this._definition.behavior}@${this._definition.handler})`}};a(ve,"A_Stage");var se=ve;var de=class de extends f{};a(de,"A_StepManagerError"),de.CircularDependencyError="A-StepManager Circular Dependency Error";var te=de;var Fe=class Fe{constructor(e){this._isBuilt=false;this.entities=this.prepareSteps(e),this.graph=new Map,this.visited=new Set,this.tempMark=new Set,this.sortedEntities=[];}prepareSteps(e){return e.map(t=>({...t,behavior:t.behavior||"sync",before:t.before||"",after:t.after||"",override:t.override||"",throwOnError:false}))}ID(e){return `${typeof e.component=="string"?e.component:e.component.name}.${e.handler}`}buildGraph(){this._isBuilt||(this._isBuilt=true,this.entities=this.entities.filter((e,t,r)=>!r.some(n=>n.override?new RegExp(n.override).test(this.ID(e)):false)),this.entities.forEach(e=>this.graph.set(this.ID(e),new Set)),this.entities.forEach(e=>{let t=this.ID(e);e.before&&this.matchEntities(t,e.before).forEach(n=>{this.graph.has(n)||this.graph.set(n,new Set),this.graph.get(n).add(t);}),e.after&&this.matchEntities(t,e.after).forEach(n=>{this.graph.has(t)||this.graph.set(t,new Set),this.graph.get(t).add(n);});}));}matchEntities(e,t){let r=new RegExp(t);return this.entities.filter(n=>r.test(this.ID(n))&&this.ID(n)!==e).map(n=>this.ID(n))}visit(e){this.tempMark.has(e)||this.visited.has(e)||(this.tempMark.add(e),(this.graph.get(e)||[]).forEach(t=>this.visit(t)),this.tempMark.delete(e),this.visited.add(e),this.sortedEntities.push(e));}toSortedArray(){return this.buildGraph(),this.entities.forEach(e=>{this.visited.has(this.ID(e))||this.visit(this.ID(e));}),this.sortedEntities}toStages(e){return this.toSortedArray().map(r=>{let n=this.entities.find(i=>this.ID(i)===r);return new se(e,n)})}};a(Fe,"A_StepsManager");var re=Fe;var ae=class ae{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return Ye}static get Extend(){return we}get name(){return this._name}get error(){return this._error}get state(){return this._state}get index(){return this._index}get stage(){return this._current}get caller(){return this._caller}get scope(){return c.scope(this)}get size(){return this._stages.length}get isDone(){return !this.stage||this._index>=this._stages.length}get isProcessed(){return this.state==="COMPLETED"||this.state==="FAILED"||this.state==="INTERRUPTED"}[Symbol.iterator](){return {next:a(()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._stages[this._index],this._index++,{value:this._current,done:false}),"next")}}validateParams(e){if(!e||typeof e!="object")throw new S(S.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}getInitializer(e){switch(true){case !("template"in e):return this.fromComponent;case "template"in e:return this.fromTemplate;default:throw new S(S.FeatureInitializationError,`Invalid A-Feature initialization parameters of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}}fromTemplate(e){if(!e.template||!Array.isArray(e.template))throw new S(S.FeatureInitializationError,`Invalid A-Feature template provided of type: ${typeof e.template} with value: ${JSON.stringify(e.template).slice(0,100)}...`);if(!e.component&&(!e.scope||!(e.scope instanceof x)))throw new S(S.FeatureInitializationError,`Invalid A-Feature scope provided of type: ${typeof e.scope} with value: ${JSON.stringify(e.scope).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{e.component&&(t=c.scope(e.component));}catch(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component||new F),c.allocate(this).inherit(t||r),this._SM=new re(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!o.isAllowedForFeatureDefinition(e.component))throw new S(S.FeatureInitializationError,`Invalid A-Feature component provided of type: ${typeof e.component} with value: ${JSON.stringify(e.component).slice(0,100)}...`);this._name=e.name;let t,r=e.scope;try{t=c.scope(e.component);}catch(s){if(!r)throw s}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new V(e.component);let n=c.allocate(this);n.inherit(t||r);let i=c.featureTemplate(this._name,this._caller.component,n);this._SM=new re(i),this._stages=this._SM.toStages(this),this._current=this._stages[0];}async process(e){try{if(this.isProcessed)return;this._state="PROCESSING";for(let t of this)await t.process(e);return await this.completed()}catch(t){return await this.failed(new S({title:S.FeatureProcessingError,description:`An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name||"N/A"}.`,stage:this.stage,originalError:t}))}}next(e){let t=this._stages.indexOf(e);this._index=t+1,this._index>=this._stages.length&&this.completed();}async completed(){this.isProcessed||(this._state="COMPLETED",this.scope.destroy());}async failed(e){if(!this.isProcessed)throw this._state="FAILED",this._error=e,this.scope.destroy(),this._error}async interrupt(e){if(!this.isProcessed){switch(this._state="INTERRUPTED",true){case o.isString(e):this._error=new S(S.Interruption,e);break;case o.isErrorInstance(e):this._error=new S({code:S.Interruption,title:e.title,description:e.description,stage:this.stage,originalError:e});break;}this.scope.destroy();}}chain(e,t,r){let n,i;e instanceof ae?(n=e,i=t instanceof x?t:void 0):(n=new ae({name:t,component:e}),i=r instanceof x?r:void 0);let s=i||this.scope;return n._caller=this._caller,n.process(s)}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};a(ae,"A_Feature");var v=ae;var xe=class xe{async call(e,t){return await new v({name:e,component:this}).process(t)}};a(xe,"A_Component");var F=xe;var g=class g extends f{};a(g,"A_ContextError"),g.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",g.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",g.InvalidMetaParameterError="Invalid parameter provided to get meta",g.InvalidScopeParameterError="Invalid parameter provided to get scope",g.ScopeNotFoundError="Scope not found",g.InvalidFeatureParameterError="Invalid parameter provided to get feature",g.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",g.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",g.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",g.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",g.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",g.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",g.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",g.InvalidInjectionParameterError="Invalid parameter provided to get injections",g.InvalidExtensionParameterError="Invalid parameter provided to get extensions",g.InvalidRegisterParameterError="Invalid parameter provided to register component",g.InvalidComponentParameterError="Invalid component provided",g.ComponentNotRegisteredError="Component not registered in the context",g.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var m=g;var D=class D{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;let e="root";D.environment==="server"&&(e=process.env[N.A_CONCEPT_ROOT_SCOPE]||"root"),D.environment==="browser"&&(e=window[N.A_CONCEPT_ROOT_SCOPE]||"root"),this._root=new x({name:e});}static get concept(){return process.env[N.A_CONCEPT_NAME]||"a-concept"}static get root(){return this.getInstance()._root}static get environment(){let e="browser";try{e=window.location?"browser":"server";}catch{e="server";}return e}static getInstance(){return D._instance||(D._instance=new D),D._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new m(m.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new m(m.NotAllowedForScopeAllocationError,`Component ${r} is not allowed for scope allocation.`);return n._scopeStorage.set(t,e),e}static deregister(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new m(m.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new m(m.ComponentNotRegisteredError,`Unable to deregister component. Component ${t} is not registered.`);r._scopeStorage.delete(e);}static allocate(e,t){let r=u.getComponentName(e);if(!this.isAllowedForScopeAllocation(e))throw new m(m.NotAllowedForScopeAllocationError,`Component of type ${r} is not allowed for scope allocation. Only A_Container, A_Feature are allowed.`);let n=this.getInstance();if(n._registry.has(e))throw new m(m.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let i=o.isScopeInstance(t)?t:new x(t||{name:r+"-scope"},t);return i.isInheritedFrom(D.root)||i.inherit(D.root),n._registry.set(e,i),n._scopeIssuers.set(i,e),i}static deallocate(e){let t=this.getInstance(),r=o.isScopeInstance(e)?e:t._registry.get(e);if(!r)return;let n=o.isComponentInstance(e)?e:this.issuer(r);n&&t._registry.delete(n),r&&t._scopeIssuers.delete(r);}static meta(e){let t=u.getComponentName(e),r=this.getInstance();if(!e)throw new m(m.InvalidMetaParameterError,"Invalid parameter provided to get meta. Parameter cannot be null or undefined.");if(!(this.isAllowedForMeta(e)||this.isAllowedForMetaConstructor(e)||o.isString(e)||o.isFunction(e)))throw new m(m.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component of type ${t} is not allowed for meta storage. Only A_Container, A_Component and A_Entity are allowed.`);let n,i;switch(true){case o.isContainerInstance(e):{n=e.constructor,i=J;break}case o.isContainerConstructor(e):{n=e,i=J;break}case o.isComponentInstance(e):{n=e.constructor,i=$;break}case o.isComponentConstructor(e):{n=e,i=$;break}case o.isEntityInstance(e):{n=e.constructor,i=$;break}case o.isEntityConstructor(e):{n=e,i=W;break}case typeof e=="string":{let s=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===y.toKebabCase(e)||_.name===y.toPascalCase(e));if(!(s&&s.length))throw new m(m.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=s[0],i=$;break}default:{n=e,i=d;break}}if(!r._metaStorage.has(n)){let s=r._metaStorage.get(Object.getPrototypeOf(n))||new i;r._metaStorage.set(n,new i().from(s));}return r._metaStorage.get(n)}static issuer(e){let t=this.getInstance();if(!e)throw new m(m.InvalidComponentParameterError,"Invalid parameter provided to get scope issuer. Parameter cannot be null or undefined.");return t._scopeIssuers.get(e)}static scope(e){let t=e?.constructor?.name||String(e),r=this.getInstance();if(!e)throw new m(m.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new m(m.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed for scope allocation.`);switch(true){case this.isAllowedForScopeAllocation(e):if(!r._registry.has(e))throw new m(m.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`);return r._registry.get(e);case this.isAllowedToBeRegistered(e):if(!r._scopeStorage.has(e))throw new m(m.ScopeNotFoundError,`Invalid parameter provided to get scope. Component of type ${t} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`);return r._scopeStorage.get(e);default:throw new m(m.InvalidScopeParameterError,`Invalid parameter provided to get scope. Component of type ${t} is not allowed to be registered.`)}}static featureTemplate(e,t,r=this.scope(t)){let n=u.getComponentName(t);if(!t)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new m(m.InvalidFeatureTemplateParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);return [...this.featureDefinition(e,t),...this.featureExtensions(e,t,r)]}static featureExtensions(e,t,r){let n=this.getInstance(),i=u.getComponentName(t);if(!t)throw new m(m.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new m(m.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${i} is not allowed for feature definition.`);let s=u.getClassInheritanceChain(t).filter(l=>l!==F&&l!==L&&l!==M).map(l=>`${l.name}.${e}`),_=[];for(let l of s)for(let[E,C]of n._metaStorage)r.has(E)&&(o.isComponentMetaInstance(C)||o.isContainerMetaInstance(C))&&C.extensions(l).forEach(h=>{_.push({component:E,...h});});return n.filterToMostDerived(r,_)}filterToMostDerived(e,t){return t.filter(r=>{let n=typeof r.component=="string"?e.resolveConstructor(r.component):o.isContainerInstance(r.component)?r.component.constructor:r.component;return !t.some(s=>{if(s===r)return false;let _=typeof s.component=="string"?e.resolveConstructor(s.component):o.isContainerInstance(s.component)?s.component.constructor:s.component;return n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new m(m.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");switch(true){case t instanceof M:r="a-component-features";break;case t instanceof L:r="a-container-features";break;case t instanceof F:r="a-component-features";break;default:throw new m(m.InvalidFeatureTemplateParameterError,`A-Feature cannot be defined on the ${t} level`)}return [...this.meta(t)?.get(r)?.get(e)?.template||[]]}static abstractionTemplate(e,t){let r=u.getComponentName(t);if(!t)throw new m(m.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new m(m.InvalidAbstractionTemplateParameterError,`Unable to get feature template. Component of type ${r} is not allowed for feature definition.`);return [...this.abstractionExtensions(e,t)]}static abstractionExtensions(e,t){let r=this.getInstance(),n=u.getComponentName(t);if(!t)throw new m(m.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new m(m.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new m(m.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let i=[],s=this.scope(t);for(let[_,l]of r._metaStorage)s.has(_)&&(o.isComponentMetaInstance(l)||o.isContainerMetaInstance(l))&&l.abstractions(e).forEach(E=>{i.push({component:_,...E});});return r.filterToMostDerived(s,i)}static reset(){let e=D.getInstance();e._registry=new WeakMap;let t="root";D.environment==="server"&&(t=process.env[N.A_CONCEPT_ROOT_SCOPE]||"root"),D.environment==="browser"&&(t=window[N.A_CONCEPT_ROOT_SCOPE]||"root"),e._root=new x({name:t});}static isAllowedForScopeAllocation(e){return o.isContainerInstance(e)||o.isFeatureInstance(e)}static isAllowedToBeRegistered(e){return o.isEntityInstance(e)||o.isComponentInstance(e)||o.isFragmentInstance(e)||o.isErrorInstance(e)}static isAllowedForMeta(e){return o.isContainerInstance(e)||o.isComponentInstance(e)||o.isEntityInstance(e)}static isAllowedForMetaConstructor(e){return o.isContainerConstructor(e)||o.isComponentConstructor(e)||o.isEntityConstructor(e)}};a(D,"A_Context");var c=D;var Ae=class Ae extends f{};a(Ae,"A_AbstractionError"),Ae.AbstractionExtensionError="Unable to extend abstraction execution";var G=Ae;function De(p,e={}){return function(t,r,n){let i=u.getComponentName(t);if(!p)throw new G(G.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${i}'.`);if(!o.isConstructorAvailableForAbstraction(t))throw new G(G.AbstractionExtensionError,`Unable to extend Abstraction '${p}' for '${i}'. Only A-Containers and A-Components can extend Abstractions.`);let s,_=c.meta(t);switch(true){case(o.isContainerConstructor(t)||o.isContainerInstance(t)):s="a-container-abstractions";break;case(o.isComponentConstructor(t)||o.isComponentInstance(t)):s="a-component-abstractions";break}let l=`CONCEPT_ABSTRACTION::${p}`,E=_.get(s)?new d().from(_.get(s)):new d,C=[...E.get(l)||[]],h=C.findIndex(Y=>Y.handler===r),P={name:l,handler:r,behavior:e.behavior||"sync",throwOnError:e.throwOnError!==void 0?e.throwOnError:true,before:o.isArray(e.before)?new RegExp(`^${e.before.join("|").replace(/\./g,"\\.")}$`).source:e.before instanceof RegExp?e.before.source:"",after:o.isArray(e.after)?new RegExp(`^${e.after.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:"",override:o.isArray(e.override)?new RegExp(`^${e.override.join("|").replace(/\./g,"\\.")}$`).source:e.after instanceof RegExp?e.after.source:""};h!==-1?C[h]=P:C.push(P),E.set(l,C),c.meta(t).set(s,E);}}a(De,"A_Abstraction_Extend");var Oe=class Oe{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=c.abstractionTemplate(this._name,t);return new v({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return De}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:a(()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false}),"next")}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};a(Oe,"A_Abstraction");var w=Oe;var nt=(_=>(_.Run="run",_.Build="build",_.Publish="publish",_.Deploy="deploy",_.Load="load",_.Start="start",_.Stop="stop",_))(nt||{}),ot=(e=>(e.LIFECYCLE="a-component-extensions",e))(ot||{});var Re=class Re{constructor(e){this.props=e;this._name=e.name||c.root.name,e.components&&e.components.length&&e.components.forEach(t=>this.scope.register(t)),e.fragments&&e.fragments.length&&e.fragments.forEach(t=>this.scope.register(t)),e.entities&&e.entities.length&&e.entities.forEach(t=>this.scope.register(t)),this._containers=e.containers||[];}static Load(e){return w.Extend("load",e)}static Publish(e){return w.Extend("publish")}static Deploy(e){return w.Extend("deploy",e)}static Build(e){return w.Extend("build",e)}static Run(e){return w.Extend("run",e)}static Start(e){return w.Extend("start",e)}static Stop(e){return w.Extend("stop",e)}get name(){return c.root.name}get scope(){return c.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new w({name:"load",containers:this._containers}).process(e);}async run(e){await new w({name:"run",containers:this._containers}).process(e);}async start(e){await new w({name:"start",containers:this._containers}).process(e);}async stop(e){await new w({name:"stop",containers:this._containers}).process(e);}async build(e){await new w({name:"build",containers:this._containers}).process(e);}async deploy(e){await new w({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new w({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new v({name:e,component:t}).process()}};a(Re,"A_Concept");var Ne=Re;var ke=class ke extends d{constructor(t){super();this.containers=t;}};a(ke,"A_ConceptMeta");var Me=ke;var X=class X extends f{};a(X,"A_DependencyError"),X.InvalidDependencyTarget="Invalid Dependency Target",X.InvalidLoadTarget="Invalid Load Target",X.InvalidLoadPath="Invalid Load Path",X.InvalidDefaultTarget="Invalid Default Target";var b=X;function je(...p){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new b(b.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",s;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):s="a-component-injections";break;case o.isContainerInstance(e):s="a-container-injections";break}let _=c.meta(e).get(s)||new d,l=_.get(i)||[];l[r]={...l[r]||{},defaultArgs:p,create:true},_.set(i,l),c.meta(e).set(s,_);}}a(je,"A_Dependency_Default");function Ve(){return function(p,e,t){let r=u.getComponentName(p);if(!o.isTargetAvailableForInjection(p))throw new b(b.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof p} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(o.isComponentConstructor(p)||o.isComponentInstance(p)):i="a-component-injections";break;case o.isContainerInstance(p):i="a-container-injections";break}let s=c.meta(p).get(i)||new d,_=s.get(n)||[];_[t]={..._[t]||{},flat:true},s.set(n,_),c.meta(p).set(i,s);}}a(Ve,"A_Dependency_Flat");function $e(p){if(!p||typeof p!="string")throw new b(b.InvalidLoadPath,"A-Load decorator requires a valid path string to the dependency");return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new b(b.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",s;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):s="a-component-injections";break;case o.isContainerInstance(e):s="a-container-injections";break}let _=c.meta(e).get(s)||new d,l=_.get(i)||[];l[r]={...l[r]||{},load:p},_.set(i,l),c.meta(e).set(s,_);}}a($e,"A_Dependency_Load");function qe(p=-1){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new b(b.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof e} (${n})`);let i=t?String(t):"constructor",s;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):s="a-component-injections";break;case o.isContainerInstance(e):s="a-container-injections";break}let _=c.meta(e).get(s)||new d,l=_.get(i)||[];l[r]={...l[r]||{},parent:{layerOffset:p}},_.set(i,l),c.meta(e).set(s,_);}}a(qe,"A_Dependency_Parent");function Le(){return function(p,e,t){let r=u.getComponentName(p);if(!o.isTargetAvailableForInjection(p))throw new b(b.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof p} (${r})`);let n=e?String(e):"constructor",i;switch(true){case(o.isComponentConstructor(p)||o.isComponentInstance(p)):i="a-component-injections";break;case o.isContainerInstance(p):i="a-container-injections";break}let s=c.meta(p).get(i)||new d,_=s.get(n)||[];_[t]={..._[t]||{},require:true},s.set(n,_),c.meta(p).set(i,s);}}a(Le,"A_Dependency_Require");var Ue=class Ue{static get Required(){return Le}static get Loaded(){return $e}static get Default(){return je}static get Parent(){return qe}static get Flat(){return Ve}constructor(e){this._name=e;}get name(){return this._name}};a(Ue,"A_Dependency");var ze=Ue;var _e=class _e extends f{};a(_e,"A_InjectError"),_e.InvalidInjectionTarget="Invalid target for A-Inject decorator",_e.MissingInjectionTarget="Missing target for A-Inject decorator";var Z=_e;function it(p,e){if(!p)throw new Z(Z.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let i=u.getComponentName(t);if(!o.isTargetAvailableForInjection(t))throw new Z(Z.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${i})`);let s=r?String(r):"constructor",_;switch(true){case(o.isComponentConstructor(t)||o.isComponentInstance(t)):_="a-component-injections";break;case o.isContainerInstance(t):_="a-container-injections";break;case o.isEntityInstance(t):_="a-component-injections";break}let l=c.meta(t).get(_)||new d,E=l.get(s)||[];E[n]={target:p,instructions:e},l.set(s,E),c.meta(t).set(_,l);}}a(it,"A_Inject");
|
|
2
|
+
exports.ASEID=I;exports.ASEID_Error=R;exports.A_Abstraction=w;exports.A_AbstractionError=G;exports.A_Abstraction_Extend=De;exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES=N;exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY=at;exports.A_CONSTANTS__ERROR_CODES=H;exports.A_CONSTANTS__ERROR_DESCRIPTION=Be;exports.A_Caller=V;exports.A_CallerError=ee;exports.A_CommonHelper=u;exports.A_Component=F;exports.A_ComponentMeta=$;exports.A_Concept=Ne;exports.A_ConceptMeta=Me;exports.A_Container=L;exports.A_ContainerMeta=J;exports.A_Context=c;exports.A_ContextError=m;exports.A_Dependency=ze;exports.A_DependencyError=b;exports.A_Dependency_Default=je;exports.A_Dependency_Load=$e;exports.A_Dependency_Require=Le;exports.A_Entity=M;exports.A_EntityError=Q;exports.A_EntityMeta=W;exports.A_Error=f;exports.A_Feature=v;exports.A_FeatureError=S;exports.A_Feature_Define=Ye;exports.A_Feature_Extend=we;exports.A_FormatterHelper=y;exports.A_Fragment=B;exports.A_IdentityHelper=K;exports.A_Inject=it;exports.A_InjectError=Z;exports.A_Meta=d;exports.A_Scope=x;exports.A_ScopeError=A;exports.A_Stage=se;exports.A_StageError=k;exports.A_StepManagerError=te;exports.A_StepsManager=re;exports.A_TYPES__A_Stage_Status=rt;exports.A_TYPES__ComponentMetaKey=et;exports.A_TYPES__ConceptAbstractions=nt;exports.A_TYPES__ConceptMetaKey=ot;exports.A_TYPES__ContainerMetaKey=Qe;exports.A_TYPES__EntityFeatures=Xe;exports.A_TYPES__EntityMetaKey=We;exports.A_TYPES__FeatureState=He;exports.A_TypeGuards=o;//# sourceMappingURL=index.cjs.map
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|