@adaas/a-concept 0.1.43 → 0.1.44

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.d.mts CHANGED
@@ -1437,6 +1437,10 @@ declare class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES_
1437
1437
  * @returns
1438
1438
  */
1439
1439
  get isDone(): boolean;
1440
+ /**
1441
+ * Indicates whether the feature has been processed (completed, failed, or interrupted)
1442
+ */
1443
+ get isProcessed(): boolean;
1440
1444
  /**
1441
1445
  * Iterator to iterate over the steps of the feature
1442
1446
  *
package/dist/index.d.ts CHANGED
@@ -1437,6 +1437,10 @@ declare class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES_
1437
1437
  * @returns
1438
1438
  */
1439
1439
  get isDone(): boolean;
1440
+ /**
1441
+ * Indicates whether the feature has been processed (completed, failed, or interrupted)
1442
+ */
1443
+ get isProcessed(): boolean;
1440
1444
  /**
1441
1445
  * Iterator to iterate over the steps of the feature
1442
1446
  *
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var Ve=Object.defineProperty;var a=(m,e)=>Ve(m,"name",{value:e,configurable:true});var x={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"},Xe=[x.A_CONCEPT_NAME,x.A_CONCEPT_ROOT_SCOPE,x.A_CONCEPT_ENVIRONMENT,x.A_CONCEPT_ROOT_FOLDER,x.A_ERROR_DEFAULT_DESCRIPTION];var qe=(s=>(s.INITIALIZED="INITIALIZED",s.PROCESSING="PROCESSING",s.COMPLETED="COMPLETED",s.INTERRUPTED="INTERRUPTED",s.FAILED="FAILED",s))(qe||{});var de=class de{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())}};a(de,"A_Meta");var l=de;var le=class le extends l{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,s])=>{s.forEach(i=>{t.push({name:i.name,handler:i.handler,behavior:i.behavior,before:i.before||"",after:i.after||"",throwOnError:i.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(([s,i])=>{i.forEach(_=>{let d=n?.get(_.handler)||[];t.push({..._,args:d});});}),t}};a(le,"A_ComponentMeta");var O=le;var Ae=class Ae{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 b({name:e,component:this}).process(t)}};a(Ae,"A_Container");var U=Ae;var fe=class fe extends l{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(([s,i])=>{i.forEach(_=>{let d=n?.get(_.handler)||[];t.push({..._,args:d});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,s])=>{s.forEach(i=>{t.push({name:i.name,handler:i.handler,behavior:i.behavior,before:i.before||"",after:i.after||"",throwOnError:i.throwOnError||true,override:""});});}),t}};a(fe,"A_ContainerMeta");var K=fe;var Ee=class Ee{static toUpperSnakeCase(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]([A-Z])/g,"_$1").replace(/-/g,"_").toUpperCase()}static toCamelCase(e){return e.toLowerCase().replace(/_([a-z])/g,(t,r)=>r.toUpperCase())}static toPascalCase(e){let t=this.toCamelCase(e);return t.charAt(0).toUpperCase()+t.slice(1)}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(Ee,"A_FormatterHelper");var h=Ee;var Se=class Se{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(Se,"A_IdentityHelper");var $=Se;var G={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},Be="If you see this error please let us know.";var M=class M extends Error{static get entity(){return h.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof M: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 M(G.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||h.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[x.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 M(G.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=G.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=G.UNEXPECTED_ERROR,this._aseid=new C({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 C(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 M(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new C({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 C({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 M){let t=e.originalError;for(;t.originalError instanceof M;)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 M(G.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new M(G.VALIDATION_ERROR,"A-Error title cannot be empty.")}};a(M,"A_Error");var A=M;var re=class re extends A{};a(re,"ASEID_Error"),re.ASEIDInitializationError="ASEID Initialization Error",re.ASEIDValidationError="ASEID Validation Error";var F=re;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 F(F.ASEIDInitializationError,"Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[s,i,_]=r.split(":"),d=_.includes(".")?_.split(".")[0]:void 0,E=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=s||c.root.name,this._entity=i,this._id=E,this._version=n,this._shard=d;}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)?$.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)?$.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 F(F.ASEIDValidationError,"Invalid ASEID format provided");case(o.isObject(e)&&!e.id):throw new F(F.ASEIDValidationError,"ASEID id is required");case(o.isObject(e)&&!e.entity):throw new F(F.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 C=L;var se=class se extends A{};a(se,"A_Entity_Error"),se.ValidationError="A-Entity Validation Error";var ne=se;var Te=class Te{static get entity(){return h.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"&&C.isASEID(e)}isASEIDInstance(e){return e instanceof C}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 ne(ne.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}async call(e,t){return await new b({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 C?this.aseid=e:this.aseid=new C(e);}fromUndefined(){this.aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:$.generateTimeId()});}fromNew(e){this.aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:$.generateTimeId()});}fromJSON(e){this.aseid=new C(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};a(Te,"A_Entity");var R=Te;var he=class he extends l{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};a(he,"A_EntityMeta");var W=he;var ye=class ye{constructor(e={}){this._meta=new l;this._name=e.name||this.constructor.name;}get name(){return this._name}get meta(){return this._meta}has(e){return this._meta.has(e)}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}drop(e){this._meta.delete(e);}clear(){this._meta.clear();}size(){return this._meta.size()}keys(){return this._meta.toArray().map(([e])=>e)}setMultiple(e){Object.entries(e).forEach(([t,r])=>{r!==void 0&&this._meta.set(t,r);});}clone(e){let t=new this.constructor({name:e||`${this._name}_copy`});return this._meta.toArray().forEach(([r,n])=>{t.set(r,n);}),t}toJSON(){return {name:this.name,...this.meta.toArray().reduce((t,[r,n])=>(t[r]=n,t),{})}}};a(ye,"A_Fragment");var B=ye;var ge=class ge{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 omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(s,i){let _=i[0];i.length===1?delete s[_]:s[_]!==void 0&&typeof s[_]=="object"&&n(s[_],i.slice(1));}return a(n,"removeProperties"),t.forEach(s=>{let i=s.split(".");n(r,i);}),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 i=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(i)return i[1]||i[2]||i[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 s=n.toString();if(typeof s=="string"&&s!=="[object Object]")return s}catch{}return r}try{return String(e)}catch{return t}}};a(ge,"A_CommonHelper");var u=ge;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 ae=class ae{constructor(e,t){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 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}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),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));}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);}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=false;switch(true){case o.isScopeConstructor(e):return true;case typeof e=="string":return 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),this._parent?this._parent.has(e):false;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}}if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}merge(e){return new ae({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(s=>s.name===e||s.name===h.toPascalCase(e));if(t)return t;let r=Array.from(this.allowedEntities).find(s=>s.name===e||s.name===h.toPascalCase(e)||s.entity===e||s.entity===h.toKebabCase(e));if(r)return r;let n=Array.from(this.allowedFragments).find(s=>s.name===e||s.name===h.toPascalCase(e));if(n)return n;if(this._parent)return this._parent.resolveConstructor(e)}resolve(e,t){switch(true){case o.isArray(e):return e.map(r=>o.isString(r)?this.resolveByName(r):this.resolveOnce(r,t)).filter(Boolean);case o.isFunction(e):return this.resolveOnce(e,t);case o.isString(e):return this.resolveByName(e);default:throw new f(f.ResolutionError,`Invalid parameter provided to resolve method: ${e} in scope ${this.name}`)}}resolveByName(e){let t=Array.from(this.allowedComponents).find(i=>i.name===e||i.name===h.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===h.toPascalCase(e)||i.entity===e||i.entity===h.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===h.toPascalCase(e));if(n)return this.resolveOnce(n);let s=Array.from(this.allowedErrors).find(i=>i.name===e||i.name===h.toPascalCase(e)||i.code===e||i.code===h.toKebabCase(e));if(s)return this.resolveOnce(s);if(this._parent)return this._parent.resolveByName(e)}resolveOnce(e,t){let r=u.getComponentName(e);if(!(!e||!this.has(e)))switch(true){case o.isConstructorAllowedForScopeAllocation(e):return this.resolveIssuer(e);case o.isEntityConstructor(e):return this.resolveEntity(e,t);case o.isFragmentConstructor(e):return this.resolveFragment(e);case o.isScopeConstructor(e):return this.resolveScope(e);case o.isComponentConstructor(e):return this.resolveComponent(e);case o.isErrorConstructor(e):return this.resolveError(e);default:throw new f(f.ResolutionError,`Injected Component ${r} not found in the scope`)}}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t;if(this._parent)return this._parent.resolveIssuer(e)}resolveEntity(e,t){let r=t?.query||{},n=t?.pagination?.count||1;switch(true){case !t:{let s=this.entities.find(i=>i instanceof e);switch(true){case !!s:return s;case(!s&&!!this._parent):return this._parent.resolveEntity(e,t);default:return}}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 C&&this._entities.has(r.aseid.toString())):return this._entities.get(r.aseid.toString());case !!r.id:return this.entities.filter(i=>i instanceof e).find(i=>String(i.id)===String(r.id));default:{let s=this.entities.filter(i=>i instanceof e).filter(i=>Object.entries(r).every(([_,d])=>_ in i?i[_]===d:false));return s.length===0&&this._parent?this._parent.resolveEntity(e,t):n===1?s[0]:s}}}resolveError(e){let t=this.errors.find(r=>r instanceof e);switch(true){case !!t:return t;case(!t&&!!this._parent):return this._parent.resolveError(e);default:return}}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&!!this._parent):return this._parent.resolveFragment(e);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(i=>{let _=u.getComponentName(i.target);if("instructions"in i&&i.instructions){let{target:d,instructions:E}=i,g=this.resolve(d,E);if(!g)throw new f(f.ResolutionError,`Unable to resolve dependency ${_} for component ${e.name} in scope ${this.name}`);return g}else {let{target:d,require:E,create:g,defaultArgs:I}=i,N=this.resolve(d);if(g&&!N&&o.isAllowedForDependencyDefaultCreation(d)){let j=new d(...I);return this.register(j),j}if(E&&!N)throw new f(f.ResolutionError,`Unable to resolve required dependency ${_} for component ${e.name} in scope ${this.name}`);return N}}),s=new e(...n);return this.register(s),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)}case !!this._parent:return this._parent.resolveComponent(e);default:throw new f(f.ResolutionError,`Component ${e.name} not found in the scope ${this.name}`)}}register(e){switch(true){case e instanceof w:{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 B)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 w:{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(ae,"A_Scope");var D=ae;var _e=class _e extends A{};a(_e,"A_CallerError"),_e.CallerInitializationError="Unable to initialize A-Caller";var X=_e;var Ce=class Ce{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!o.isAllowedForFeatureCall(e))throw new X(X.CallerInitializationError,`Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};a(Ce,"A_Caller");var J=Ce;var S=class S{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,U)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,w)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,B)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,D)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,A)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,b)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,J)}static isContainerInstance(e){return e instanceof U}static isComponentInstance(e){return e instanceof w}static isFeatureInstance(e){return e instanceof b}static isFragmentInstance(e){return e instanceof B}static isEntityInstance(e){return e instanceof R}static isScopeInstance(e){return e instanceof D}static isErrorInstance(e){return e instanceof A}static isComponentMetaInstance(e){return e instanceof O}static isContainerMetaInstance(e){return e instanceof K}static isEntityMetaInstance(e){return e instanceof W}static isConstructorAllowedForScopeAllocation(e){return S.isContainerConstructor(e)||S.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return S.isContainerInstance(e)||S.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return S.isContainerInstance(e)||S.isComponentInstance(e)}static isTargetAvailableForInjection(e){return S.isComponentConstructor(e)||S.isComponentInstance(e)||S.isContainerInstance(e)||S.isEntityInstance(e)}static isAllowedForFeatureCall(e){return S.isContainerInstance(e)||S.isComponentInstance(e)||S.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return S.isContainerInstance(e)||S.isComponentInstance(e)||S.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return S.isComponentInstance(e)||S.isContainerInstance(e)||S.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return S.isContainerInstance(e)||S.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return S.isComponentConstructor(e)||u.isInheritedFrom(e,w)||S.isEntityConstructor(e)||u.isInheritedFrom(e,R)}static isErrorConstructorType(e){return !!e&&S.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&S.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&C.isASEID(e.aseid)}};a(S,"A_TypeGuards");var o=S;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 T=V;function Pe(m={}){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureDefinition(e))throw new T(T.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let s=c.meta(e.constructor),i;switch(true){case o.isEntityInstance(e):i="a-component-features";break;case o.isContainerInstance(e):i="a-container-features";break;case o.isComponentInstance(e):i="a-component-features";break}let _=s.get(i)||new l,d=m.name||t,E=m.invoke||false;_.set(t,{name:`${e.constructor.name}.${d}`,handler:t,invoke:E,template:m.template&&m.template.length?m.template.map(I=>({...I,before:I.before||"",after:I.after||"",behavior:I.behavior||"sync",throwOnError:true,override:I.override||""})):[]}),c.meta(e.constructor).set(i,_);let g=r.value;return r.value=function(...I){if(E)g.apply(this,I);else return g.apply(this,I);if(typeof this.call=="function"&&E)return this.call(d)},r}}a(Pe,"A_Feature_Define");function Ie(m){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureExtension(e))throw new T(T.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let s,i="sync",_="",d="",E="",g=[],I=[],N=true;switch(true){case o.isRegExp(m):s=m;break;case(!!m&&typeof m=="object"):Array.isArray(m.scope)?g=m.scope:m.scope&&typeof m.scope=="object"&&(Array.isArray(m.scope.include)&&(g=m.scope.include),Array.isArray(m.scope.exclude)&&(I=m.scope.exclude)),s=Ge(m,g,I,t),i=m.behavior||i,N=m.throwOnError!==void 0?m.throwOnError:N,_=o.isArray(m.before)?new RegExp(`^${m.before.join("|").replace(/\./g,"\\.")}$`).source:m.before instanceof RegExp?m.before.source:"",d=o.isArray(m.after)?new RegExp(`^${m.after.join("|").replace(/\./g,"\\.")}$`).source:m.after instanceof RegExp?m.after.source:"",E=o.isArray(m.override)?new RegExp(`^${m.override.join("|").replace(/\./g,"\\.")}$`).source:m.override instanceof RegExp?m.override.source:"";break;default:s=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let j=c.meta(e).get("a-component-features"),ze=c.meta(e),ue=ze.get("a-component-extensions")?new l().from(ze.get("a-component-extensions")):new l;if(j&&j.size()&&j.has(t)&&j.get(t).invoke)throw new T(T.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 te=[...ue.get(s.source)||[]],Ue=te.findIndex(Je=>Je.handler===t),Ke={name:s.source,handler:t,behavior:i,before:_,after:d,throwOnError:N,override:E};Ue!==-1?te[Ue]=Ke:te.push(Ke),te.push(),ue.set(s.source,te),c.meta(e).set("a-component-extensions",ue);}}a(Ie,"A_Feature_Extend");function Ge(m,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",s=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",i=m.scope?`^${s}${n}\\.${m.name||r}$`:`.*\\.${m.name||r}$`;return new RegExp(i)}a(Ge,"buildTargetRegexp");var He=(i=>(i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.FAILED="FAILED",i.SKIPPED="SKIPPED",i.INITIALIZED="INITIALIZED",i.ABORTED="ABORTED",i))(He||{});var ce=class ce extends A{static get CompileError(){return "Unable to compile A-Stage"}};a(ce,"A_StageError"),ce.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var k=ce;var be=class be{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.isScopeConstructor(n.target):return e;case o.isFeatureConstructor(n.target):return this._feature;case(o.isEntityConstructor(n.target)&&"instructions"in n&&!!n.instructions):return e.resolve(n.target,n.instructions);default:{let{target:s,require:i,create:_,defaultArgs:d}=n,E=e.resolve(s);if(_&&!E&&o.isAllowedForDependencyDefaultCreation(s)){let g=new s(...d);return e.register(g),g}if(i&&!E)throw new k(k.ArgumentsResolutionError,`Unable to resolve required argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);return e.resolve(n.target)}}}))}getStepComponent(e,t){let{component:r,handler:n}=t,s;switch(true){case o.isContainerInstance(r):s=r;break;case o.isString(r):s=e.resolve(r);break;default:s=e.resolve(r);break}if(!s)throw new k(k.CompileError,`Unable to resolve component ${typeof r=="string"?r:r.name} from scope ${e.name}`);if(!s[n])throw new k(k.CompileError,`Handler ${n} not found in ${s.constructor.name}`);return s}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(s){let i=new A(s);return this.failed(i),this._definition.throwOnError?r():n(i)}})),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(be,"A_Stage");var oe=be;var pe=class pe extends A{};a(pe,"A_StepManagerError"),pe.CircularDependencyError="A-StepManager Circular Dependency Error";var Q=pe;var we=class we{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(s=>this.ID(s)===r);return new oe(e,n)})}};a(we,"A_StepsManager");var ee=we;var Ye=class Ye{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return Pe}static get Extend(){return Ie}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||this.state==="COMPLETED"||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 T(T.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 T(T.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 T(T.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 D)))throw new T(T.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(s){if(!r)throw s}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new J(e.component||new w),c.allocate(this).inherit(t||r),this._SM=new ee(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!o.isAllowedForFeatureDefinition(e.component))throw new T(T.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(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new J(e.component);let n=c.allocate(this);n.inherit(t||r);let s=c.featureTemplate(this._name,this._caller.component,n);this._SM=new ee(s),this._stages=this._SM.toStages(this),this._current=this._stages[0];}async process(e){try{if(e&&!e.isInheritedFrom(c.scope(this))&&e.inherit(c.scope(this)),this.isDone)return;this._state="PROCESSING";for(let t of this)await t.process(e);return await this.completed()}catch(t){return await this.failed(new T({title:T.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.isDone||(this._state="COMPLETED",this.scope.destroy());}async failed(e){if(!this.isDone)throw this._state="FAILED",this._error=e,this.scope.destroy(),this._error}async interrupt(e){if(!this.isDone){switch(this._state="INTERRUPTED",true){case o.isString(e):this._error=new T(T.Interruption,e);break;case o.isErrorInstance(e):this._error=new T({code:T.Interruption,title:e.title,description:e.description,stage:this.stage,originalError:e});break;}this.scope.destroy();}}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};a(Ye,"A_Feature");var b=Ye;var ve=class ve{async call(e,t){return await new b({name:e,component:this}).process(t)}};a(ve,"A_Component");var w=ve;var y=class y extends A{};a(y,"A_ContextError"),y.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",y.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",y.InvalidMetaParameterError="Invalid parameter provided to get meta",y.InvalidScopeParameterError="Invalid parameter provided to get scope",y.ScopeNotFoundError="Scope not found",y.InvalidFeatureParameterError="Invalid parameter provided to get feature",y.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",y.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",y.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",y.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",y.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",y.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",y.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",y.InvalidInjectionParameterError="Invalid parameter provided to get injections",y.InvalidExtensionParameterError="Invalid parameter provided to get extensions",y.InvalidRegisterParameterError="Invalid parameter provided to register component",y.InvalidComponentParameterError="Invalid component provided",y.ComponentNotRegisteredError="Component not registered in the context",y.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var p=y;var Y=class Y{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;let e="root";Y.environment==="server"&&(e=process.env[x.A_CONCEPT_ROOT_SCOPE]||"root"),Y.environment==="browser"&&(e=window[x.A_CONCEPT_ROOT_SCOPE]||"root"),this._root=new D({name:e});}static get concept(){return process.env[x.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 Y._instance||(Y._instance=new Y),Y._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new p(p.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 p(p.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new p(p.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 p(p.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 p(p.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let s=o.isScopeInstance(t)?t:new D(t||{name:r+"-scope"},t);return s.isInheritedFrom(Y.root)||s.inherit(Y.root),n._registry.set(e,s),n._scopeIssuers.set(s,e),s}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 p(p.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 p(p.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,s;switch(true){case o.isContainerInstance(e):{n=e.constructor,s=K;break}case o.isContainerConstructor(e):{n=e,s=K;break}case o.isComponentInstance(e):{n=e.constructor,s=O;break}case o.isComponentConstructor(e):{n=e,s=O;break}case o.isEntityInstance(e):{n=e.constructor,s=O;break}case o.isEntityConstructor(e):{n=e,s=W;break}case typeof e=="string":{let i=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===h.toKebabCase(e)||_.name===h.toPascalCase(e));if(!(i&&i.length))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=i[0],s=O;break}default:{n=e,s=l;break}}if(!r._metaStorage.has(n)){let i=r._metaStorage.get(Object.getPrototypeOf(n))||new s;r._metaStorage.set(n,new s().from(i));}return r._metaStorage.get(n)}static issuer(e){let t=this.getInstance();if(!e)throw new p(p.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 p(p.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new p(p.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 p(p.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 p(p.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 p(p.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 p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new p(p.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(),s=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${s} is not allowed for feature definition.`);let i=`${t.constructor.name}.${e}`,_=[];for(let[d,E]of n._metaStorage)r.has(d)&&(o.isComponentMetaInstance(E)||o.isContainerMetaInstance(E))&&E.extensions(i).forEach(g=>{_.push({component:d,...g});});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(i=>{if(i===r)return false;let _=typeof i.component=="string"?e.resolveConstructor(i.component):o.isContainerInstance(i.component)?i.component.constructor:i.component;return n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new p(p.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 U:r="a-container-features";break;case t instanceof w:r="a-component-features";break;default:throw new p(p.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 p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new p(p.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 p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let s=[],i=this.scope(t);for(let[_,d]of r._metaStorage)i.has(_)&&(o.isComponentMetaInstance(d)||o.isContainerMetaInstance(d))&&d.abstractions(e).forEach(E=>{s.push({component:_,...E});});return r.filterToMostDerived(i,s)}static reset(){let e=Y.getInstance();e._registry=new WeakMap;let t="root";Y.environment==="server"&&(t=process.env[x.A_CONCEPT_ROOT_SCOPE]||"root"),Y.environment==="browser"&&(t=window[x.A_CONCEPT_ROOT_SCOPE]||"root"),e._root=new D({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(Y,"A_Context");var c=Y;var me=class me extends A{};a(me,"A_AbstractionError"),me.AbstractionExtensionError="Unable to extend abstraction execution";var q=me;function xe(m,e={}){return function(t,r,n){let s=u.getComponentName(t);if(!m)throw new q(q.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${s}'.`);if(!o.isConstructorAvailableForAbstraction(t))throw new q(q.AbstractionExtensionError,`Unable to extend Abstraction '${m}' for '${s}'. Only A-Containers and A-Components can extend Abstractions.`);let i,_=c.meta(t);switch(true){case(o.isContainerConstructor(t)||o.isContainerInstance(t)):i="a-container-abstractions";break;case(o.isComponentConstructor(t)||o.isComponentInstance(t)):i="a-component-abstractions";break}let d=`CONCEPT_ABSTRACTION::${m}`,E=_.get(i)?new l().from(_.get(i)):new l,g=[...E.get(d)||[]],I=g.findIndex(j=>j.handler===r),N={name:d,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:""};I!==-1?g[I]=N:g.push(N),E.set(d,g),c.meta(t).set(i,E);}}a(xe,"A_Abstraction_Extend");var Fe=class Fe{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 b({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(Fe,"A_Abstraction");var P=Fe;var Me=class Me{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 P.Extend("load",e)}static Publish(e){return P.Extend("publish")}static Deploy(e){return P.Extend("deploy",e)}static Build(e){return P.Extend("build",e)}static Run(e){return P.Extend("run",e)}static Start(e){return P.Extend("start",e)}static Stop(e){return P.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 P({name:"load",containers:this._containers}).process(e);}async run(e){await new P({name:"run",containers:this._containers}).process(e);}async start(e){await new P({name:"start",containers:this._containers}).process(e);}async stop(e){await new P({name:"stop",containers:this._containers}).process(e);}async build(e){await new P({name:"build",containers:this._containers}).process(e);}async deploy(e){await new P({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new P({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new b({name:e,component:t}).process()}};a(Me,"A_Concept");var De=Me;var Ne=class Ne extends l{constructor(t){super();this.containers=t;}};a(Ne,"A_ConceptMeta");var Re=Ne;var H=class H extends A{};a(H,"A_DependencyError"),H.InvalidDependencyTarget="Invalid Dependency Target",H.InvalidLoadTarget="Invalid Load Target",H.InvalidLoadPath="Invalid Load Path",H.InvalidDefaultTarget="Invalid Default Target";var v=H;function Oe(...m){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new v(v.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let s=t?String(t):"constructor",i;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):i="a-component-injections";break;case o.isContainerInstance(e):i="a-container-injections";break}let _=c.meta(e).get(i)||new l,d=_.get(s)||[];d[r]={...d[r]||{},defaultArgs:m,create:true},_.set(s,d),c.meta(e).set(i,_);}}a(Oe,"A_Dependency_Default");function ke(m){if(!m||typeof m!="string")throw new v(v.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 v(v.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof e} (${n})`);let s=t?String(t):"constructor",i;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):i="a-component-injections";break;case o.isContainerInstance(e):i="a-container-injections";break}let _=c.meta(e).get(i)||new l,d=_.get(s)||[];d[r]={...d[r]||{},load:m},_.set(s,d),c.meta(e).set(i,_);}}a(ke,"A_Dependency_Load");function je(){return function(m,e,t){let r=u.getComponentName(m);if(!o.isTargetAvailableForInjection(m))throw new v(v.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof m} (${r})`);let n=e?String(e):"constructor",s;switch(true){case(o.isComponentConstructor(m)||o.isComponentInstance(m)):s="a-component-injections";break;case o.isContainerInstance(m):s="a-container-injections";break}let i=c.meta(m).get(s)||new l,_=i.get(n)||[];_[t]={..._[t]||{},require:true},i.set(n,_),c.meta(m).set(s,i);}}a(je,"A_Dependency_Require");var Le=class Le{static get Required(){return je}static get Loaded(){return ke}static get Default(){return Oe}};a(Le,"A_Dependency");var $e=Le;var ie=class ie extends A{};a(ie,"A_InjectError"),ie.InvalidInjectionTarget="Invalid target for A-Inject decorator",ie.MissingInjectionTarget="Missing target for A-Inject decorator";var Z=ie;function Ze(m,e){if(!m)throw new Z(Z.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let s=u.getComponentName(t);if(!o.isTargetAvailableForInjection(t))throw new Z(Z.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${s})`);let i=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 d=c.meta(t).get(_)||new l,E=d.get(i)||[];E[n]={target:m,instructions:e},d.set(i,E),c.meta(t).set(_,d);}}a(Ze,"A_Inject");
1
+ var Ve=Object.defineProperty;var a=(m,e)=>Ve(m,"name",{value:e,configurable:true});var x={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"},Xe=[x.A_CONCEPT_NAME,x.A_CONCEPT_ROOT_SCOPE,x.A_CONCEPT_ENVIRONMENT,x.A_CONCEPT_ROOT_FOLDER,x.A_ERROR_DEFAULT_DESCRIPTION];var qe=(s=>(s.INITIALIZED="INITIALIZED",s.PROCESSING="PROCESSING",s.COMPLETED="COMPLETED",s.INTERRUPTED="INTERRUPTED",s.FAILED="FAILED",s))(qe||{});var de=class de{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())}};a(de,"A_Meta");var l=de;var le=class le extends l{injections(e){return this.get("a-component-injections")?.get(e)||[]}extensions(e){let t=[];return this.get("a-component-extensions")?.find(e).forEach(([n,s])=>{s.forEach(i=>{t.push({name:i.name,handler:i.handler,behavior:i.behavior,before:i.before||"",after:i.after||"",throwOnError:i.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(([s,i])=>{i.forEach(_=>{let d=n?.get(_.handler)||[];t.push({..._,args:d});});}),t}};a(le,"A_ComponentMeta");var O=le;var Ae=class Ae{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 b({name:e,component:this}).process(t)}};a(Ae,"A_Container");var U=Ae;var fe=class fe extends l{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(([s,i])=>{i.forEach(_=>{let d=n?.get(_.handler)||[];t.push({..._,args:d});});}),t}extensions(e){let t=[];return this.get("a-container-extensions")?.find(e).forEach(([n,s])=>{s.forEach(i=>{t.push({name:i.name,handler:i.handler,behavior:i.behavior,before:i.before||"",after:i.after||"",throwOnError:i.throwOnError||true,override:""});});}),t}};a(fe,"A_ContainerMeta");var K=fe;var Ee=class Ee{static toUpperSnakeCase(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]([A-Z])/g,"_$1").replace(/-/g,"_").toUpperCase()}static toCamelCase(e){return e.toLowerCase().replace(/_([a-z])/g,(t,r)=>r.toUpperCase())}static toPascalCase(e){let t=this.toCamelCase(e);return t.charAt(0).toUpperCase()+t.slice(1)}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(Ee,"A_FormatterHelper");var h=Ee;var Se=class Se{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(Se,"A_IdentityHelper");var $=Se;var G={UNEXPECTED_ERROR:"A-Error Unexpected Error",VALIDATION_ERROR:"A-Error Validation Error"},Be="If you see this error please let us know.";var M=class M extends Error{static get entity(){return h.toKebabCase(this.name)}static get concept(){return c.concept}static get scope(){return c.root.name}constructor(e,t){switch(true){case e instanceof M: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 M(G.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||h.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[x.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 M(G.VALIDATION_ERROR,"Invalid parameters provided to A_Error constructor")}}fromError(e){this._title=G.UNEXPECTED_ERROR,this._aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:this.code}),this._originalError=e;}fromMessage(e){this._title=G.UNEXPECTED_ERROR,this._aseid=new C({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 C(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 M(e.originalError):void 0,this._link=e.link;}fromTitle(e,t){this.validateTitle(e),this._title=e,this._description=t,this._aseid=new C({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 C({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 M){let t=e.originalError;for(;t.originalError instanceof M;)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 M(G.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new M(G.VALIDATION_ERROR,"A-Error title cannot be empty.")}};a(M,"A_Error");var A=M;var re=class re extends A{};a(re,"ASEID_Error"),re.ASEIDInitializationError="ASEID Initialization Error",re.ASEIDValidationError="ASEID Validation Error";var F=re;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 F(F.ASEIDInitializationError,"Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[s,i,_]=r.split(":"),d=_.includes(".")?_.split(".")[0]:void 0,E=_.includes(".")?_.split(".")[1]:_;this._concept=t||c.root.name,this._scope=s||c.root.name,this._entity=i,this._id=E,this._version=n,this._shard=d;}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)?$.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)?$.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 F(F.ASEIDValidationError,"Invalid ASEID format provided");case(o.isObject(e)&&!e.id):throw new F(F.ASEIDValidationError,"ASEID id is required");case(o.isObject(e)&&!e.entity):throw new F(F.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 C=L;var se=class se extends A{};a(se,"A_Entity_Error"),se.ValidationError="A-Entity Validation Error";var ne=se;var Te=class Te{static get entity(){return h.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"&&C.isASEID(e)}isASEIDInstance(e){return e instanceof C}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 ne(ne.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}async call(e,t){return await new b({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 C?this.aseid=e:this.aseid=new C(e);}fromUndefined(){this.aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:$.generateTimeId()});}fromNew(e){this.aseid=new C({concept:this.constructor.concept,scope:this.constructor.scope,entity:this.constructor.entity,id:$.generateTimeId()});}fromJSON(e){this.aseid=new C(e.aseid);}toJSON(){return {aseid:this.aseid.toString()}}toString(){return this.aseid?this.aseid.toString():this.constructor.name}};a(Te,"A_Entity");var R=Te;var he=class he extends l{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};a(he,"A_EntityMeta");var W=he;var ye=class ye{constructor(e={}){this._meta=new l;this._name=e.name||this.constructor.name;}get name(){return this._name}get meta(){return this._meta}has(e){return this._meta.has(e)}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}drop(e){this._meta.delete(e);}clear(){this._meta.clear();}size(){return this._meta.size()}keys(){return this._meta.toArray().map(([e])=>e)}setMultiple(e){Object.entries(e).forEach(([t,r])=>{r!==void 0&&this._meta.set(t,r);});}clone(e){let t=new this.constructor({name:e||`${this._name}_copy`});return this._meta.toArray().forEach(([r,n])=>{t.set(r,n);}),t}toJSON(){return {name:this.name,...this.meta.toArray().reduce((t,[r,n])=>(t[r]=n,t),{})}}};a(ye,"A_Fragment");var B=ye;var ge=class ge{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 omitProperties(e,t){let r=JSON.parse(JSON.stringify(e));function n(s,i){let _=i[0];i.length===1?delete s[_]:s[_]!==void 0&&typeof s[_]=="object"&&n(s[_],i.slice(1));}return a(n,"removeProperties"),t.forEach(s=>{let i=s.split(".");n(r,i);}),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 i=Function.prototype.toString.call(e).match(/^(?:class\s+([A-Za-z0-9_$]+)|function\s+([A-Za-z0-9_$]+)|([A-Za-z0-9_$]+)\s*=>)/);if(i)return i[1]||i[2]||i[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 s=n.toString();if(typeof s=="string"&&s!=="[object Object]")return s}catch{}return r}try{return String(e)}catch{return t}}};a(ge,"A_CommonHelper");var u=ge;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 ae=class ae{constructor(e,t){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 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}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),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));}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);}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=false;switch(true){case o.isScopeConstructor(e):return true;case typeof e=="string":return 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),this._parent?this._parent.has(e):false;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}}if(!t&&this._parent)try{return this._parent.has(e)}catch{return false}return t}merge(e){return new ae({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(s=>s.name===e||s.name===h.toPascalCase(e));if(t)return t;let r=Array.from(this.allowedEntities).find(s=>s.name===e||s.name===h.toPascalCase(e)||s.entity===e||s.entity===h.toKebabCase(e));if(r)return r;let n=Array.from(this.allowedFragments).find(s=>s.name===e||s.name===h.toPascalCase(e));if(n)return n;if(this._parent)return this._parent.resolveConstructor(e)}resolve(e,t){switch(true){case o.isArray(e):return e.map(r=>o.isString(r)?this.resolveByName(r):this.resolveOnce(r,t)).filter(Boolean);case o.isFunction(e):return this.resolveOnce(e,t);case o.isString(e):return this.resolveByName(e);default:throw new f(f.ResolutionError,`Invalid parameter provided to resolve method: ${e} in scope ${this.name}`)}}resolveByName(e){let t=Array.from(this.allowedComponents).find(i=>i.name===e||i.name===h.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===h.toPascalCase(e)||i.entity===e||i.entity===h.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===h.toPascalCase(e));if(n)return this.resolveOnce(n);let s=Array.from(this.allowedErrors).find(i=>i.name===e||i.name===h.toPascalCase(e)||i.code===e||i.code===h.toKebabCase(e));if(s)return this.resolveOnce(s);if(this._parent)return this._parent.resolveByName(e)}resolveOnce(e,t){let r=u.getComponentName(e);if(!(!e||!this.has(e)))switch(true){case o.isConstructorAllowedForScopeAllocation(e):return this.resolveIssuer(e);case o.isEntityConstructor(e):return this.resolveEntity(e,t);case o.isFragmentConstructor(e):return this.resolveFragment(e);case o.isScopeConstructor(e):return this.resolveScope(e);case o.isComponentConstructor(e):return this.resolveComponent(e);case o.isErrorConstructor(e):return this.resolveError(e);default:throw new f(f.ResolutionError,`Injected Component ${r} not found in the scope`)}}resolveIssuer(e){let t=this.issuer();if(t&&(t.constructor===e||u.isInheritedFrom(t?.constructor,e)))return t;if(this._parent)return this._parent.resolveIssuer(e)}resolveEntity(e,t){let r=t?.query||{},n=t?.pagination?.count||1;switch(true){case !t:{let s=this.entities.find(i=>i instanceof e);switch(true){case !!s:return s;case(!s&&!!this._parent):return this._parent.resolveEntity(e,t);default:return}}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 C&&this._entities.has(r.aseid.toString())):return this._entities.get(r.aseid.toString());case !!r.id:return this.entities.filter(i=>i instanceof e).find(i=>String(i.id)===String(r.id));default:{let s=this.entities.filter(i=>i instanceof e).filter(i=>Object.entries(r).every(([_,d])=>_ in i?i[_]===d:false));return s.length===0&&this._parent?this._parent.resolveEntity(e,t):n===1?s[0]:s}}}resolveError(e){let t=this.errors.find(r=>r instanceof e);switch(true){case !!t:return t;case(!t&&!!this._parent):return this._parent.resolveError(e);default:return}}resolveFragment(e){let t=this._fragments.get(e);switch(true){case(t&&this._fragments.has(e)):return t;case(!t&&!!this._parent):return this._parent.resolveFragment(e);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(i=>{let _=u.getComponentName(i.target);if("instructions"in i&&i.instructions){let{target:d,instructions:E}=i,g=this.resolve(d,E);if(!g)throw new f(f.ResolutionError,`Unable to resolve dependency ${_} for component ${e.name} in scope ${this.name}`);return g}else {let{target:d,require:E,create:g,defaultArgs:I}=i,N=this.resolve(d);if(g&&!N&&o.isAllowedForDependencyDefaultCreation(d)){let j=new d(...I);return this.register(j),j}if(E&&!N)throw new f(f.ResolutionError,`Unable to resolve required dependency ${_} for component ${e.name} in scope ${this.name}`);return N}}),s=new e(...n);return this.register(s),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)}case !!this._parent:return this._parent.resolveComponent(e);default:throw new f(f.ResolutionError,`Component ${e.name} not found in the scope ${this.name}`)}}register(e){switch(true){case e instanceof w:{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 B)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 w:{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(ae,"A_Scope");var D=ae;var _e=class _e extends A{};a(_e,"A_CallerError"),_e.CallerInitializationError="Unable to initialize A-Caller";var X=_e;var Ce=class Ce{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!o.isAllowedForFeatureCall(e))throw new X(X.CallerInitializationError,`Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};a(Ce,"A_Caller");var J=Ce;var S=class S{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,U)}static isComponentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,w)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,B)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,D)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,A)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,b)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,J)}static isContainerInstance(e){return e instanceof U}static isComponentInstance(e){return e instanceof w}static isFeatureInstance(e){return e instanceof b}static isFragmentInstance(e){return e instanceof B}static isEntityInstance(e){return e instanceof R}static isScopeInstance(e){return e instanceof D}static isErrorInstance(e){return e instanceof A}static isComponentMetaInstance(e){return e instanceof O}static isContainerMetaInstance(e){return e instanceof K}static isEntityMetaInstance(e){return e instanceof W}static isConstructorAllowedForScopeAllocation(e){return S.isContainerConstructor(e)||S.isFeatureConstructor(e)}static isInstanceAllowedForScopeAllocation(e){return S.isContainerInstance(e)||S.isFeatureInstance(e)}static isConstructorAvailableForAbstraction(e){return S.isContainerInstance(e)||S.isComponentInstance(e)}static isTargetAvailableForInjection(e){return S.isComponentConstructor(e)||S.isComponentInstance(e)||S.isContainerInstance(e)||S.isEntityInstance(e)}static isAllowedForFeatureCall(e){return S.isContainerInstance(e)||S.isComponentInstance(e)||S.isEntityInstance(e)}static isAllowedForFeatureDefinition(e){return S.isContainerInstance(e)||S.isComponentInstance(e)||S.isEntityInstance(e)}static isAllowedForFeatureExtension(e){return S.isComponentInstance(e)||S.isContainerInstance(e)||S.isEntityInstance(e)}static isAllowedForAbstractionDefinition(e){return S.isContainerInstance(e)||S.isComponentInstance(e)}static isAllowedForDependencyDefaultCreation(e){return S.isComponentConstructor(e)||u.isInheritedFrom(e,w)||S.isEntityConstructor(e)||u.isInheritedFrom(e,R)}static isErrorConstructorType(e){return !!e&&S.isObject(e)&&!(e instanceof Error)&&"title"in e}static isErrorSerializedType(e){return !!e&&S.isObject(e)&&!(e instanceof Error)&&"aseid"in e&&C.isASEID(e.aseid)}};a(S,"A_TypeGuards");var o=S;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 T=V;function Pe(m={}){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureDefinition(e))throw new T(T.FeatureDefinitionError,`A-Feature cannot be defined on the ${n} level`);let s=c.meta(e.constructor),i;switch(true){case o.isEntityInstance(e):i="a-component-features";break;case o.isContainerInstance(e):i="a-container-features";break;case o.isComponentInstance(e):i="a-component-features";break}let _=s.get(i)||new l,d=m.name||t,E=m.invoke||false;_.set(t,{name:`${e.constructor.name}.${d}`,handler:t,invoke:E,template:m.template&&m.template.length?m.template.map(I=>({...I,before:I.before||"",after:I.after||"",behavior:I.behavior||"sync",throwOnError:true,override:I.override||""})):[]}),c.meta(e.constructor).set(i,_);let g=r.value;return r.value=function(...I){if(E)g.apply(this,I);else return g.apply(this,I);if(typeof this.call=="function"&&E)return this.call(d)},r}}a(Pe,"A_Feature_Define");function Ie(m){return function(e,t,r){let n=u.getComponentName(e);if(!o.isAllowedForFeatureExtension(e))throw new T(T.FeatureExtensionError,`A-Feature-Extend cannot be applied on the ${n} level`);let s,i="sync",_="",d="",E="",g=[],I=[],N=true;switch(true){case o.isRegExp(m):s=m;break;case(!!m&&typeof m=="object"):Array.isArray(m.scope)?g=m.scope:m.scope&&typeof m.scope=="object"&&(Array.isArray(m.scope.include)&&(g=m.scope.include),Array.isArray(m.scope.exclude)&&(I=m.scope.exclude)),s=Ge(m,g,I,t),i=m.behavior||i,N=m.throwOnError!==void 0?m.throwOnError:N,_=o.isArray(m.before)?new RegExp(`^${m.before.join("|").replace(/\./g,"\\.")}$`).source:m.before instanceof RegExp?m.before.source:"",d=o.isArray(m.after)?new RegExp(`^${m.after.join("|").replace(/\./g,"\\.")}$`).source:m.after instanceof RegExp?m.after.source:"",E=o.isArray(m.override)?new RegExp(`^${m.override.join("|").replace(/\./g,"\\.")}$`).source:m.override instanceof RegExp?m.override.source:"";break;default:s=new RegExp(`^.*${t.replace(/\./g,"\\.")}$`);break}let j=c.meta(e).get("a-component-features"),ze=c.meta(e),ue=ze.get("a-component-extensions")?new l().from(ze.get("a-component-extensions")):new l;if(j&&j.size()&&j.has(t)&&j.get(t).invoke)throw new T(T.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 te=[...ue.get(s.source)||[]],Ue=te.findIndex(Je=>Je.handler===t),Ke={name:s.source,handler:t,behavior:i,before:_,after:d,throwOnError:N,override:E};Ue!==-1?te[Ue]=Ke:te.push(Ke),te.push(),ue.set(s.source,te),c.meta(e).set("a-component-extensions",ue);}}a(Ie,"A_Feature_Extend");function Ge(m,e,t,r){let n=e.length?`(${e.map(_=>_.name).join("|")})`:".*",s=t.length?`(?!${t.map(_=>_.name).join("|")})`:"",i=m.scope?`^${s}${n}\\.${m.name||r}$`:`.*\\.${m.name||r}$`;return new RegExp(i)}a(Ge,"buildTargetRegexp");var He=(i=>(i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.FAILED="FAILED",i.SKIPPED="SKIPPED",i.INITIALIZED="INITIALIZED",i.ABORTED="ABORTED",i))(He||{});var ce=class ce extends A{static get CompileError(){return "Unable to compile A-Stage"}};a(ce,"A_StageError"),ce.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var k=ce;var be=class be{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.isScopeConstructor(n.target):return e;case o.isFeatureConstructor(n.target):return this._feature;case(o.isEntityConstructor(n.target)&&"instructions"in n&&!!n.instructions):return e.resolve(n.target,n.instructions);default:{let{target:s,require:i,create:_,defaultArgs:d}=n,E=e.resolve(s);if(_&&!E&&o.isAllowedForDependencyDefaultCreation(s)){let g=new s(...d);return e.register(g),g}if(i&&!E)throw new k(k.ArgumentsResolutionError,`Unable to resolve required argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);return e.resolve(n.target)}}}))}getStepComponent(e,t){let{component:r,handler:n}=t,s;switch(true){case o.isContainerInstance(r):s=r;break;case o.isString(r):s=e.resolve(r);break;default:s=e.resolve(r);break}if(!s)throw new k(k.CompileError,`Unable to resolve component ${typeof r=="string"?r:r.name} from scope ${e.name}`);if(!s[n])throw new k(k.CompileError,`Handler ${n} not found in ${s.constructor.name}`);return s}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(s){let i=new A(s);return this.failed(i),this._definition.throwOnError?r():n(i)}})),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(be,"A_Stage");var oe=be;var pe=class pe extends A{};a(pe,"A_StepManagerError"),pe.CircularDependencyError="A-StepManager Circular Dependency Error";var Q=pe;var we=class we{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(s=>this.ID(s)===r);return new oe(e,n)})}};a(we,"A_StepsManager");var ee=we;var Ye=class Ye{constructor(e){this._stages=[];this._index=0;this._state="INITIALIZED";this.validateParams(e),this.getInitializer(e).call(this,e);}static get Define(){return Pe}static get Extend(){return Ie}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 T(T.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 T(T.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 T(T.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 D)))throw new T(T.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(s){if(!r)throw s}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new J(e.component||new w),c.allocate(this).inherit(t||r),this._SM=new ee(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!o.isAllowedForFeatureDefinition(e.component))throw new T(T.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(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new J(e.component);let n=c.allocate(this);n.inherit(t||r);let s=c.featureTemplate(this._name,this._caller.component,n);this._SM=new ee(s),this._stages=this._SM.toStages(this),this._current=this._stages[0];}async process(e){try{if(e&&!e.isInheritedFrom(c.scope(this))&&e.inherit(c.scope(this)),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 T({title:T.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 T(T.Interruption,e);break;case o.isErrorInstance(e):this._error=new T({code:T.Interruption,title:e.title,description:e.description,stage:this.stage,originalError:e});break;}this.scope.destroy();}}toString(){return `A-Feature(${this.caller.component?.constructor?.name||"Unknown"}::${this.name})`}};a(Ye,"A_Feature");var b=Ye;var ve=class ve{async call(e,t){return await new b({name:e,component:this}).process(t)}};a(ve,"A_Component");var w=ve;var y=class y extends A{};a(y,"A_ContextError"),y.NotAllowedForScopeAllocationError="Component is not allowed for scope allocation",y.ComponentAlreadyHasScopeAllocatedError="Component already has scope allocated",y.InvalidMetaParameterError="Invalid parameter provided to get meta",y.InvalidScopeParameterError="Invalid parameter provided to get scope",y.ScopeNotFoundError="Scope not found",y.InvalidFeatureParameterError="Invalid parameter provided to get feature",y.InvalidFeatureDefinitionParameterError="Invalid parameter provided to define feature",y.InvalidFeatureTemplateParameterError="Invalid parameter provided to get feature template",y.InvalidFeatureExtensionParameterError="Invalid parameter provided to extend feature",y.InvalidAbstractionParameterError="Invalid parameter provided to get abstraction",y.InvalidAbstractionDefinitionParameterError="Invalid parameter provided to define abstraction",y.InvalidAbstractionTemplateParameterError="Invalid parameter provided to get abstraction template",y.InvalidAbstractionExtensionParameterError="Invalid parameter provided to extend abstraction",y.InvalidInjectionParameterError="Invalid parameter provided to get injections",y.InvalidExtensionParameterError="Invalid parameter provided to get extensions",y.InvalidRegisterParameterError="Invalid parameter provided to register component",y.InvalidComponentParameterError="Invalid component provided",y.ComponentNotRegisteredError="Component not registered in the context",y.InvalidDeregisterParameterError="Invalid parameter provided to deregister component";var p=y;var Y=class Y{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;let e="root";Y.environment==="server"&&(e=process.env[x.A_CONCEPT_ROOT_SCOPE]||"root"),Y.environment==="browser"&&(e=window[x.A_CONCEPT_ROOT_SCOPE]||"root"),this._root=new D({name:e});}static get concept(){return process.env[x.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 Y._instance||(Y._instance=new Y),Y._instance}static register(e,t){let r=u.getComponentName(t),n=this.getInstance();if(!t)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidRegisterParameterError,"Unable to register component. Scope cannot be null or undefined.");if(!this.isAllowedToBeRegistered(t))throw new p(p.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 p(p.InvalidDeregisterParameterError,"Unable to deregister component. Component cannot be null or undefined.");if(!r._scopeStorage.has(e))throw new p(p.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 p(p.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 p(p.ComponentAlreadyHasScopeAllocatedError,`Component ${r} already has a scope allocated.`);let s=o.isScopeInstance(t)?t:new D(t||{name:r+"-scope"},t);return s.isInheritedFrom(Y.root)||s.inherit(Y.root),n._registry.set(e,s),n._scopeIssuers.set(s,e),s}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 p(p.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 p(p.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,s;switch(true){case o.isContainerInstance(e):{n=e.constructor,s=K;break}case o.isContainerConstructor(e):{n=e,s=K;break}case o.isComponentInstance(e):{n=e.constructor,s=O;break}case o.isComponentConstructor(e):{n=e,s=O;break}case o.isEntityInstance(e):{n=e.constructor,s=O;break}case o.isEntityConstructor(e):{n=e,s=W;break}case typeof e=="string":{let i=Array.from(r._metaStorage).find(([_])=>_.name===e||_.name===h.toKebabCase(e)||_.name===h.toPascalCase(e));if(!(i&&i.length))throw new p(p.InvalidMetaParameterError,`Invalid parameter provided to get meta. Component with name ${e} not found in the meta storage.`);n=i[0],s=O;break}default:{n=e,s=l;break}}if(!r._metaStorage.has(n)){let i=r._metaStorage.get(Object.getPrototypeOf(n))||new s;r._metaStorage.set(n,new s().from(i));}return r._metaStorage.get(n)}static issuer(e){let t=this.getInstance();if(!e)throw new p(p.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 p(p.InvalidScopeParameterError,"Invalid parameter provided to get scope. Parameter cannot be null or undefined.");if(!this.isAllowedForScopeAllocation(e)&&!this.isAllowedToBeRegistered(e))throw new p(p.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 p(p.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 p(p.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 p(p.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 p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new p(p.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(),s=u.getComponentName(t);if(!t)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidFeatureExtensionParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!o.isAllowedForFeatureDefinition(t))throw new p(p.InvalidFeatureExtensionParameterError,`Unable to get feature template. Component of type ${s} is not allowed for feature definition.`);let i=`${t.constructor.name}.${e}`,_=[];for(let[d,E]of n._metaStorage)r.has(d)&&(o.isComponentMetaInstance(E)||o.isContainerMetaInstance(E))&&E.extensions(i).forEach(g=>{_.push({component:d,...g});});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(i=>{if(i===r)return false;let _=typeof i.component=="string"?e.resolveConstructor(i.component):o.isContainerInstance(i.component)?i.component.constructor:i.component;return n.prototype.isPrototypeOf(_.prototype)})})}static featureDefinition(e,t){let r;if(!e)throw new p(p.InvalidFeatureTemplateParameterError,"Unable to get feature template. Feature name cannot be null or undefined.");if(!t)throw new p(p.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 U:r="a-container-features";break;case t instanceof w:r="a-component-features";break;default:throw new p(p.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 p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionTemplateParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new p(p.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 p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Component cannot be null or undefined.");if(!e)throw new p(p.InvalidAbstractionExtensionParameterError,"Unable to get feature template. Abstraction stage cannot be null or undefined.");if(!o.isAllowedForAbstractionDefinition(t))throw new p(p.InvalidAbstractionExtensionParameterError,`Unable to get feature template. Component of type ${n} is not allowed for feature definition.`);let s=[],i=this.scope(t);for(let[_,d]of r._metaStorage)i.has(_)&&(o.isComponentMetaInstance(d)||o.isContainerMetaInstance(d))&&d.abstractions(e).forEach(E=>{s.push({component:_,...E});});return r.filterToMostDerived(i,s)}static reset(){let e=Y.getInstance();e._registry=new WeakMap;let t="root";Y.environment==="server"&&(t=process.env[x.A_CONCEPT_ROOT_SCOPE]||"root"),Y.environment==="browser"&&(t=window[x.A_CONCEPT_ROOT_SCOPE]||"root"),e._root=new D({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(Y,"A_Context");var c=Y;var me=class me extends A{};a(me,"A_AbstractionError"),me.AbstractionExtensionError="Unable to extend abstraction execution";var q=me;function xe(m,e={}){return function(t,r,n){let s=u.getComponentName(t);if(!m)throw new q(q.AbstractionExtensionError,`Abstraction name must be provided to extend abstraction for '${s}'.`);if(!o.isConstructorAvailableForAbstraction(t))throw new q(q.AbstractionExtensionError,`Unable to extend Abstraction '${m}' for '${s}'. Only A-Containers and A-Components can extend Abstractions.`);let i,_=c.meta(t);switch(true){case(o.isContainerConstructor(t)||o.isContainerInstance(t)):i="a-container-abstractions";break;case(o.isComponentConstructor(t)||o.isComponentInstance(t)):i="a-component-abstractions";break}let d=`CONCEPT_ABSTRACTION::${m}`,E=_.get(i)?new l().from(_.get(i)):new l,g=[...E.get(d)||[]],I=g.findIndex(j=>j.handler===r),N={name:d,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:""};I!==-1?g[I]=N:g.push(N),E.set(d,g),c.meta(t).set(i,E);}}a(xe,"A_Abstraction_Extend");var Fe=class Fe{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 b({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(Fe,"A_Abstraction");var P=Fe;var Me=class Me{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 P.Extend("load",e)}static Publish(e){return P.Extend("publish")}static Deploy(e){return P.Extend("deploy",e)}static Build(e){return P.Extend("build",e)}static Run(e){return P.Extend("run",e)}static Start(e){return P.Extend("start",e)}static Stop(e){return P.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 P({name:"load",containers:this._containers}).process(e);}async run(e){await new P({name:"run",containers:this._containers}).process(e);}async start(e){await new P({name:"start",containers:this._containers}).process(e);}async stop(e){await new P({name:"stop",containers:this._containers}).process(e);}async build(e){await new P({name:"build",containers:this._containers}).process(e);}async deploy(e){await new P({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new P({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new b({name:e,component:t}).process()}};a(Me,"A_Concept");var De=Me;var Ne=class Ne extends l{constructor(t){super();this.containers=t;}};a(Ne,"A_ConceptMeta");var Re=Ne;var H=class H extends A{};a(H,"A_DependencyError"),H.InvalidDependencyTarget="Invalid Dependency Target",H.InvalidLoadTarget="Invalid Load Target",H.InvalidLoadPath="Invalid Load Path",H.InvalidDefaultTarget="Invalid Default Target";var v=H;function Oe(...m){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new v(v.InvalidDefaultTarget,`A-Default cannot be used on the target of type ${typeof e} (${n})`);let s=t?String(t):"constructor",i;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):i="a-component-injections";break;case o.isContainerInstance(e):i="a-container-injections";break}let _=c.meta(e).get(i)||new l,d=_.get(s)||[];d[r]={...d[r]||{},defaultArgs:m,create:true},_.set(s,d),c.meta(e).set(i,_);}}a(Oe,"A_Dependency_Default");function ke(m){if(!m||typeof m!="string")throw new v(v.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 v(v.InvalidLoadTarget,`A-Load cannot be used on the target of type ${typeof e} (${n})`);let s=t?String(t):"constructor",i;switch(true){case(o.isComponentConstructor(e)||o.isComponentInstance(e)):i="a-component-injections";break;case o.isContainerInstance(e):i="a-container-injections";break}let _=c.meta(e).get(i)||new l,d=_.get(s)||[];d[r]={...d[r]||{},load:m},_.set(s,d),c.meta(e).set(i,_);}}a(ke,"A_Dependency_Load");function je(){return function(m,e,t){let r=u.getComponentName(m);if(!o.isTargetAvailableForInjection(m))throw new v(v.InvalidDependencyTarget,`A-Dependency cannot be used on the target of type ${typeof m} (${r})`);let n=e?String(e):"constructor",s;switch(true){case(o.isComponentConstructor(m)||o.isComponentInstance(m)):s="a-component-injections";break;case o.isContainerInstance(m):s="a-container-injections";break}let i=c.meta(m).get(s)||new l,_=i.get(n)||[];_[t]={..._[t]||{},require:true},i.set(n,_),c.meta(m).set(s,i);}}a(je,"A_Dependency_Require");var Le=class Le{static get Required(){return je}static get Loaded(){return ke}static get Default(){return Oe}};a(Le,"A_Dependency");var $e=Le;var ie=class ie extends A{};a(ie,"A_InjectError"),ie.InvalidInjectionTarget="Invalid target for A-Inject decorator",ie.MissingInjectionTarget="Missing target for A-Inject decorator";var Z=ie;function Ze(m,e){if(!m)throw new Z(Z.MissingInjectionTarget,"A-Inject decorator is missing the target to inject");return function(t,r,n){let s=u.getComponentName(t);if(!o.isTargetAvailableForInjection(t))throw new Z(Z.InvalidInjectionTarget,`A-Inject cannot be used on the target of type ${typeof t} (${s})`);let i=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 d=c.meta(t).get(_)||new l,E=d.get(i)||[];E[n]={target:m,instructions:e},d.set(i,E),c.meta(t).set(_,d);}}a(Ze,"A_Inject");
2
2
  export{C as ASEID,F as ASEID_Error,P as A_Abstraction,q as A_AbstractionError,xe as A_Abstraction_Extend,x as A_CONSTANTS__DEFAULT_ENV_VARIABLES,Xe as A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,J as A_Caller,X as A_CallerError,u as A_CommonHelper,w as A_Component,O as A_ComponentMeta,De as A_Concept,Re as A_ConceptMeta,U as A_Container,K as A_ContainerMeta,c as A_Context,$e as A_Dependency,v as A_DependencyError,Oe as A_Dependency_Default,ke as A_Dependency_Load,je as A_Dependency_Require,R as A_Entity,A as A_Error,b as A_Feature,T as A_FeatureError,Pe as A_Feature_Define,Ie as A_Feature_Extend,h as A_FormatterHelper,B as A_Fragment,$ as A_IdentityHelper,Ze as A_Inject,l as A_Meta,D as A_Scope,f as A_ScopeError,oe as A_Stage,k as A_StageError,Q as A_StepManagerError,ee as A_StepsManager,He as A_TYPES__A_Stage_Status,qe as A_TYPES__FeatureState,o as A_TypeGuards};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map