@adaas/a-concept 0.1.48 → 0.1.50
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/README.md +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/global/A-Scope/A-Scope.class.ts +7 -0
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var Ze=Object.defineProperty;var a=(m,e)=>Ze(m,"name",{value:e,configurable:true});var D={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"},st=[D.A_CONCEPT_NAME,D.A_CONCEPT_ROOT_SCOPE,D.A_CONCEPT_ENVIRONMENT,D.A_CONCEPT_ROOT_FOLDER,D.A_ERROR_DEFAULT_DESCRIPTION];var Ge=(s=>(s.INITIALIZED="INITIALIZED",s.PROCESSING="PROCESSING",s.COMPLETED="COMPLETED",s.INTERRUPTED="INTERRUPTED",s.FAILED="FAILED",s))(Ge||{});var ae=class ae{constructor(){this.meta=new Map;}[Symbol.iterator](){let e=this.meta.entries();return {next:a(()=>e.next(),"next")}}from(e){return this.meta=new Map(e.meta),this}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof ae:return e.toJSON();case e instanceof Map:let t={};for(let[n,s]of e.entries())t[String(n)]=this.recursiveToJSON(s);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,s]of Object.entries(e))r[n]=this.recursiveToJSON(s);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};a(ae,"A_Meta");var l=ae;var He=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(He||{}),We=(r=>(r.SAVE="save",r.DESTROY="destroy",r.LOAD="load",r))(We||{});var Xe=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Xe||{});var Qe=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(Qe||{});var Ae=class Ae 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(c=>{let d=n?.get(c.handler)||[];t.push({...c,args:d});});}),t}};a(Ae,"A_ComponentMeta");var k=Ae;var fe=class fe{get name(){return this.config?.name||this.constructor.name}get scope(){return _.scope(this)}constructor(e={}){this.config=e,_.allocate(this,this.config);}async call(e,t){return await new Y({name:e,component:this}).process(t)}};a(fe,"A_Container");var U=fe;var Ee=class Ee 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(c=>{let d=n?.get(c.handler)||[];t.push({...c,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(Ee,"A_ContainerMeta");var J=Ee;var Se=class Se{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};a(Se,"A_FormatterHelper");var g=Se;var Te=class Te{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(Te,"A_IdentityHelper");var $=Te;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 O=class O extends Error{static get entity(){return g.toKebabCase(this.name)}static get concept(){return _.concept}static get scope(){return _.root.name}constructor(e,t){switch(true){case e instanceof O: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 O(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||g.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||process.env[D.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 O(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 O(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 O){let t=e.originalError;for(;t.originalError instanceof O;)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 O(G.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new O(G.VALIDATION_ERROR,"A-Error title cannot be empty.")}};a(O,"A_Error");var A=O;var ne=class ne extends A{};a(ne,"ASEID_Error"),ne.ASEIDInitializationError="ASEID Initialization Error",ne.ASEIDValidationError="ASEID Validation Error";var N=ne;var L=class L{static isASEID(e){return this.regexp.test(e)}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||_.concept}get scope(){return this._scope||_.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 N(N.ASEIDInitializationError,"Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[s,i,c]=r.split(":"),d=c.includes(".")?c.split(".")[0]:void 0,E=c.includes(".")?c.split(".")[1]:c;this._concept=t||_.root.name,this._scope=s||_.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:_.concept,this._scope=e.scope?o.isNumber(e.scope)?$.formatWithLeadingZeros(e.scope):L.isASEID(e.scope)?new L(e.scope).id:e.scope:_.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 N(N.ASEIDValidationError,"Invalid ASEID format provided");case(o.isObject(e)&&!e.id):throw new N(N.ASEIDValidationError,"ASEID id is required");case(o.isObject(e)&&!e.entity):throw new N(N.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 ce=class ce extends A{};a(ce,"A_EntityError"),ce.ValidationError="A-Entity Validation Error";var X=ce;var he=class he{static get entity(){return g.toKebabCase(this.name)}static get concept(){return _.concept}static get scope(){return _.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 X(X.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}async call(e,t){return await new Y({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(he,"A_Entity");var M=he;var ge=class ge extends l{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};a(ge,"A_EntityMeta");var H=ge;var ye=class ye{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};a(ye,"A_Fragment");var K=ye;var Ce=class Ce{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 c=i[0];i.length===1?delete s[c]:s[c]!==void 0&&typeof s[c]=="object"&&n(s[c],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(Ce,"A_CommonHelper");var u=Ce;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 _e=class _e{constructor(e,t){this._meta=new l;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get parent(){return this._parent}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new f(f.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>_.deregister(e)),this._fragments.forEach(e=>_.deregister(e)),this._entities.forEach(e=>_.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this.issuer()&&_.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return _.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(c=>c.name===e)&&(t=true),Array.from(this.allowedFragments).find(c=>c.name===e)&&(t=true),Array.from(this.allowedEntities).find(c=>c.name===e)&&(t=true),Array.from(this.allowedErrors).find(c=>c.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 _e({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===g.toPascalCase(e));if(t)return t;let r=Array.from(this.allowedEntities).find(s=>s.name===e||s.name===g.toPascalCase(e)||s.entity===e||s.entity===g.toKebabCase(e));if(r)return r;let n=Array.from(this.allowedFragments).find(s=>s.name===e||s.name===g.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===g.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.entity===e||i.entity===g.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===g.toPascalCase(e));if(n)return this.resolveOnce(n);let s=Array.from(this.allowedErrors).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.code===e||i.code===g.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(([c,d])=>c in i?i[c]===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=(_.meta(e).get("a-component-injections")?.get("constructor")||[]).map(i=>{let c=u.getComponentName(i.target);if("instructions"in i&&i.instructions){let{target:d,instructions:E}=i,h=this.resolve(d,E);if(!h)throw new f(f.ResolutionError,`Unable to resolve dependency ${c} for component ${e.name} in scope ${this.name}`);return h}else {let{target:d,require:E,create:h,defaultArgs:I}=i,P=this.resolve(d);if(h&&!P&&o.isAllowedForDependencyDefaultCreation(d)){let v=new d(...I);return this.register(v),v}if(E&&!P)throw new f(f.ResolutionError,`Unable to resolve required dependency ${c} for component ${e.name} in scope ${this.name}`);return P}}),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 x:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),_.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),_.register(this,e);break}case o.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),_.register(this,e);break}case o.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),_.register(this,e);break}case o.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case o.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case o.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case o.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof M)throw new f(f.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof K)throw new f(f.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new f(f.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof x:{this._components.delete(e.constructor),_.deregister(e);break}case o.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),_.deregister(e);break}case o.isFragmentInstance(e):{this._fragments.delete(e.constructor),_.deregister(e);break}case o.isErrorInstance(e):{this._errors.delete(e.code),_.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(_e,"A_Scope");var R=_e;var pe=class pe extends A{};a(pe,"A_CallerError"),pe.CallerInitializationError="Unable to initialize A-Caller";var Q=pe;var Ie=class Ie{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!o.isAllowedForFeatureCall(e))throw new Q(Q.CallerInitializationError,`Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};a(Ie,"A_Caller");var B=Ie;var 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,x)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,K)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,M)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,A)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Y)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,B)}static isContainerInstance(e){return e instanceof U}static isComponentInstance(e){return e instanceof x}static isFeatureInstance(e){return e instanceof Y}static isFragmentInstance(e){return e instanceof K}static isEntityInstance(e){return e instanceof M}static isScopeInstance(e){return e instanceof R}static isErrorInstance(e){return e instanceof A}static isComponentMetaInstance(e){return e instanceof k}static isContainerMetaInstance(e){return e instanceof J}static isEntityMetaInstance(e){return e instanceof H}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,x)||S.isEntityConstructor(e)||u.isInheritedFrom(e,M)}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=_.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 c=s.get(i)||new l,d=m.name||t,E=m.invoke||false;c.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||""})):[]}),_.meta(e.constructor).set(i,c);let h=r.value;return r.value=function(...I){if(E)h.apply(this,I);else return h.apply(this,I);if(typeof this.call=="function"&&E)return this.call(d)},r}}a(Pe,"A_Feature_Define");function be(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",c="",d="",E="",h=[],I=[],P=true,v;switch(true){case o.isEntityInstance(e):v="a-component-extensions";break;case o.isContainerInstance(e):v="a-container-extensions";break;case o.isComponentInstance(e):v="a-component-extensions";break}switch(true){case o.isRegExp(m):s=m;break;case(!!m&&typeof m=="object"):Array.isArray(m.scope)?h=m.scope:m.scope&&typeof m.scope=="object"&&(Array.isArray(m.scope.include)&&(h=m.scope.include),Array.isArray(m.scope.exclude)&&(I=m.scope.exclude)),s=et(m,h,I,t),i=m.behavior||i,P=m.throwOnError!==void 0?m.throwOnError:P,c=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 se=_.meta(e).get(v),Ue=_.meta(e),le=Ue.get(v)?new l().from(Ue.get(v)):new l;if(se&&se.size()&&se.has(t)&&se.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 re=[...le.get(s.source)||[]],Je=re.findIndex(qe=>qe.handler===t),Ke={name:s.source,handler:t,behavior:i,before:c,after:d,throwOnError:P,override:E};Je!==-1?re[Je]=Ke:re.push(Ke),re.push(),le.set(s.source,re),_.meta(e).set(v,le);}}a(be,"A_Feature_Extend");function et(m,e,t,r){let n=e.length?`(${e.map(c=>c.name).join("|")})`:".*",s=t.length?`(?!${t.map(c=>c.name).join("|")})`:"",i=m.scope?`^${s}${n}\\.${m.name||r}$`:`.*\\.${m.name||r}$`;return new RegExp(i)}a(et,"buildTargetRegexp");var tt=(i=>(i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.FAILED="FAILED",i.SKIPPED="SKIPPED",i.INITIALIZED="INITIALIZED",i.ABORTED="ABORTED",i))(tt||{});var me=class me extends A{static get CompileError(){return "Unable to compile A-Stage"}};a(me,"A_StageError"),me.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var j=me;var we=class we{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}async getStepArgs(e,t){let r;switch(true){case o.isContainerInstance(t.component):r=t.component.constructor;break;case o.isString(t.component):r=e.resolveConstructor(t.component);break;default:r=t.component;break}return Promise.all(_.meta(r).injections(t.handler).map(async n=>{switch(true){case o.isCallerConstructor(n.target):return this._feature.caller.component;case o.isFeatureConstructor(n.target):return this._feature;default:{let{target:s,require:i,create:c,defaultArgs:d,parent:E}=n,h,I=e;if(E&&typeof E.layerOffset=="number"){let P=e.parent,v=E.layerOffset;for(;v<-1&&P;)P=P.parent,v++;P&&(h=P.resolve(s),I=P);}else h=I.resolve(s);if(c&&!h&&o.isAllowedForDependencyDefaultCreation(s)){let P=new s(...d);return I.register(P),P}if(i&&!h)throw new j(j.ArgumentsResolutionError,`Unable to resolve required argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);return h}}}))}getStepComponent(e,t){let{component:r,handler:n}=t,s;switch(true){case o.isContainerInstance(r):s=r;break;case o.isString(r):s=e.resolve(r)||this.feature.scope.resolve(r);break;default:s=e.resolve(r)||this.feature.scope.resolve(r);break}if(!s)throw new j(j.CompileError,`Unable to resolve component ${typeof r=="string"?r:r.name} from scope ${e.name}`);if(!s[n])throw new j(j.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(we,"A_Stage");var oe=we;var ue=class ue extends A{};a(ue,"A_StepManagerError"),ue.CircularDependencyError="A-StepManager Circular Dependency Error";var ee=ue;var Ye=class Ye{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(Ye,"A_StepsManager");var te=Ye;var ve=class ve{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 be}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 _.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 R)))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=_.scope(e.component));}catch(s){if(!r)throw s}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new B(e.component||new x),_.allocate(this).inherit(t||r),this._SM=new te(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!o.isAllowedForFeatureDefinition(e.component))throw new 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=_.scope(e.component);}catch(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new B(e.component);let n=_.allocate(this);n.inherit(t||r);let s=_.featureTemplate(this._name,this._caller.component,n);this._SM=new te(s),this._stages=this._SM.toStages(this),this._current=this._stages[0];}async process(e){try{if(this.isProcessed)return;this._state="PROCESSING";for(let t of this)await t.process(e);return await this.completed()}catch(t){return await this.failed(new 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(ve,"A_Feature");var Y=ve;var xe=class xe{async call(e,t){return await new Y({name:e,component:this}).process(t)}};a(xe,"A_Component");var x=xe;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 F=class F{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;let e="root";F.environment==="server"&&(e=process.env[D.A_CONCEPT_ROOT_SCOPE]||"root"),F.environment==="browser"&&(e=window[D.A_CONCEPT_ROOT_SCOPE]||"root"),this._root=new R({name:e});}static get concept(){return process.env[D.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 F._instance||(F._instance=new F),F._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 R(t||{name:r+"-scope"},t);return s.isInheritedFrom(F.root)||s.inherit(F.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=J;break}case o.isContainerConstructor(e):{n=e,s=J;break}case o.isComponentInstance(e):{n=e.constructor,s=k;break}case o.isComponentConstructor(e):{n=e,s=k;break}case o.isEntityInstance(e):{n=e.constructor,s=k;break}case o.isEntityConstructor(e):{n=e,s=H;break}case typeof e=="string":{let i=Array.from(r._metaStorage).find(([c])=>c.name===e||c.name===g.toKebabCase(e)||c.name===g.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=k;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}`,c=[];for(let[d,E]of n._metaStorage)r.has(d)&&(o.isComponentMetaInstance(E)||o.isContainerMetaInstance(E))&&E.extensions(i).forEach(h=>{c.push({component:d,...h});});return n.filterToMostDerived(r,c)}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 c=typeof i.component=="string"?e.resolveConstructor(i.component):o.isContainerInstance(i.component)?i.component.constructor:i.component;return n.prototype.isPrototypeOf(c.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 M:r="a-component-features";break;case t instanceof U:r="a-container-features";break;case t instanceof x: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[c,d]of r._metaStorage)i.has(c)&&(o.isComponentMetaInstance(d)||o.isContainerMetaInstance(d))&&d.abstractions(e).forEach(E=>{s.push({component:c,...E});});return r.filterToMostDerived(i,s)}static reset(){let e=F.getInstance();e._registry=new WeakMap;let t="root";F.environment==="server"&&(t=process.env[D.A_CONCEPT_ROOT_SCOPE]||"root"),F.environment==="browser"&&(t=window[D.A_CONCEPT_ROOT_SCOPE]||"root"),e._root=new R({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(F,"A_Context");var _=F;var de=class de extends A{};a(de,"A_AbstractionError"),de.AbstractionExtensionError="Unable to extend abstraction execution";var q=de;function Fe(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=c.get(i)?new l().from(c.get(i)):new l,h=[...E.get(d)||[]],I=h.findIndex(v=>v.handler===r),P={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?h[I]=P:h.push(P),E.set(d,h),_.meta(t).set(i,E);}}a(Fe,"A_Abstraction_Extend");var De=class De{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=_.abstractionTemplate(this._name,t);return new Y({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return Fe}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:a(()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false}),"next")}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};a(De,"A_Abstraction");var b=De;var rt=(c=>(c.Run="run",c.Build="build",c.Publish="publish",c.Deploy="deploy",c.Load="load",c.Start="start",c.Stop="stop",c))(rt||{}),nt=(e=>(e.LIFECYCLE="a-component-extensions",e))(nt||{});var Re=class Re{constructor(e){this.props=e;this._name=e.name||_.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 b.Extend("load",e)}static Publish(e){return b.Extend("publish")}static Deploy(e){return b.Extend("deploy",e)}static Build(e){return b.Extend("build",e)}static Run(e){return b.Extend("run",e)}static Start(e){return b.Extend("start",e)}static Stop(e){return b.Extend("stop",e)}get name(){return _.root.name}get scope(){return _.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new b({name:"load",containers:this._containers}).process(e);}async run(e){await new b({name:"run",containers:this._containers}).process(e);}async start(e){await new b({name:"start",containers:this._containers}).process(e);}async stop(e){await new b({name:"stop",containers:this._containers}).process(e);}async build(e){await new b({name:"build",containers:this._containers}).process(e);}async deploy(e){await new b({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new b({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new Y({name:e,component:t}).process()}};a(Re,"A_Concept");var Ne=Re;var Me=class Me extends l{constructor(t){super();this.containers=t;}};a(Me,"A_ConceptMeta");var Oe=Me;var W=class W extends A{};a(W,"A_DependencyError"),W.InvalidDependencyTarget="Invalid Dependency Target",W.InvalidLoadTarget="Invalid Load Target",W.InvalidLoadPath="Invalid Load Path",W.InvalidDefaultTarget="Invalid Default Target";var w=W;function ke(...m){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new w(w.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=c.get(s)||[];d[r]={...d[r]||{},defaultArgs:m,create:true},c.set(s,d),_.meta(e).set(i,c);}}a(ke,"A_Dependency_Default");function je(m){if(!m||typeof m!="string")throw new w(w.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 w(w.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=c.get(s)||[];d[r]={...d[r]||{},load:m},c.set(s,d),_.meta(e).set(i,c);}}a(je,"A_Dependency_Load");function Ve(m=-1){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new w(w.InvalidDependencyTarget,`A-Dependency 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=c.get(s)||[];d[r]={...d[r]||{},parent:{layerOffset:m}},c.set(s,d),_.meta(e).set(i,c);}}a(Ve,"A_Dependency_Parent");function $e(){return function(m,e,t){let r=u.getComponentName(m);if(!o.isTargetAvailableForInjection(m))throw new w(w.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=_.meta(m).get(s)||new l,c=i.get(n)||[];c[t]={...c[t]||{},require:true},i.set(n,c),_.meta(m).set(s,i);}}a($e,"A_Dependency_Require");var ze=class ze{static get Required(){return $e}static get Loaded(){return je}static get Default(){return ke}static get Parent(){return Ve}constructor(e){this._name=e;}get name(){return this._name}};a(ze,"A_Dependency");var Le=ze;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 ot(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",c;switch(true){case(o.isComponentConstructor(t)||o.isComponentInstance(t)):c="a-component-injections";break;case o.isContainerInstance(t):c="a-container-injections";break;case o.isEntityInstance(t):c="a-component-injections";break}let d=_.meta(t).get(c)||new l,E=d.get(i)||[];E[n]={target:m,instructions:e},d.set(i,E),_.meta(t).set(c,d);}}a(ot,"A_Inject");
|
|
1
|
+
var Ze=Object.defineProperty;var a=(m,e)=>Ze(m,"name",{value:e,configurable:true});var D={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"},st=[D.A_CONCEPT_NAME,D.A_CONCEPT_ROOT_SCOPE,D.A_CONCEPT_ENVIRONMENT,D.A_CONCEPT_ROOT_FOLDER,D.A_ERROR_DEFAULT_DESCRIPTION];var Ge=(s=>(s.INITIALIZED="INITIALIZED",s.PROCESSING="PROCESSING",s.COMPLETED="COMPLETED",s.INTERRUPTED="INTERRUPTED",s.FAILED="FAILED",s))(Ge||{});var ae=class ae{constructor(){this.meta=new Map;}[Symbol.iterator](){let e=this.meta.entries();return {next:a(()=>e.next(),"next")}}from(e){return this.meta=new Map(e.meta),this}set(e,t){let r=this.meta.get(e)||Array.isArray(t)?[]:t instanceof Map?new Map:{};this.meta.get(e)||Array.isArray(t)?[...r]:t instanceof Map?new Map(r):{...r};this.meta.set(e,t);}get(e){return this.meta.get(e)}delete(e){return this.meta.delete(e)}size(){return this.meta.size}convertToRegExp(e){return e instanceof RegExp?e:new RegExp(e)}find(e){let t=[];for(let[r,n]of this.meta.entries())this.convertToRegExp(String(r)).test(e)&&t.push([r,n]);return t}findByRegex(e){let t=[];for(let[r,n]of this.meta.entries())e.test(String(r))&&t.push([r,n]);return t}has(e){return this.meta.has(e)}entries(){return this.meta.entries()}clear(){this.meta.clear();}toArray(){return Array.from(this.meta.entries())}recursiveToJSON(e){switch(true){case e instanceof ae:return e.toJSON();case e instanceof Map:let t={};for(let[n,s]of e.entries())t[String(n)]=this.recursiveToJSON(s);return t;case Array.isArray(e):return e.map(n=>this.recursiveToJSON(n));case(!!e&&typeof e=="object"):let r={};for(let[n,s]of Object.entries(e))r[n]=this.recursiveToJSON(s);return r;default:return e}}toJSON(){let e={};for(let[t,r]of this.meta.entries())e[String(t)]=this.recursiveToJSON(r);return e}};a(ae,"A_Meta");var l=ae;var He=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.ABSTRACTIONS="a-component-abstractions",n.INJECTIONS="a-component-injections",n))(He||{}),We=(r=>(r.SAVE="save",r.DESTROY="destroy",r.LOAD="load",r))(We||{});var Xe=(n=>(n.FEATURES="a-container-features",n.INJECTIONS="a-container-injections",n.ABSTRACTIONS="a-container-abstractions",n.EXTENSIONS="a-container-extensions",n))(Xe||{});var Qe=(n=>(n.EXTENSIONS="a-component-extensions",n.FEATURES="a-component-features",n.INJECTIONS="a-component-injections",n.ABSTRACTIONS="a-component-abstractions",n))(Qe||{});var Ae=class Ae 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(c=>{let d=n?.get(c.handler)||[];t.push({...c,args:d});});}),t}};a(Ae,"A_ComponentMeta");var k=Ae;var fe=class fe{get name(){return this.config?.name||this.constructor.name}get scope(){return _.scope(this)}constructor(e={}){this.config=e,_.allocate(this,this.config);}async call(e,t){return await new Y({name:e,component:this}).process(t)}};a(fe,"A_Container");var U=fe;var Ee=class Ee 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(c=>{let d=n?.get(c.handler)||[];t.push({...c,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(Ee,"A_ContainerMeta");var J=Ee;var Se=class Se{static toUpperSnakeCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toUpperCase()}static toCamelCase(e){return e.trim().replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toPascalCase(e){return e.trim().replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z0-9]+/g," ").split(" ").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}static toKebabCase(e){return e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\s+/g,"-").toLowerCase()}};a(Se,"A_FormatterHelper");var g=Se;var Te=class Te{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(Te,"A_IdentityHelper");var $=Te;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 O=class O extends Error{static get entity(){return g.toKebabCase(this.name)}static get concept(){return _.concept}static get scope(){return _.root.name}constructor(e,t){switch(true){case e instanceof O: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 O(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||g.toKebabCase(this.title)}get type(){return this.constructor.entity}get link(){return this._link?this._link:new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`).toString()}get scope(){return this._aseid.scope}get description(){return this._description||process.env[D.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 O(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 O(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 O){let t=e.originalError;for(;t.originalError instanceof O;)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 O(G.VALIDATION_ERROR,"A-Error title exceeds 60 characters limit.");if(e.length===0)throw new O(G.VALIDATION_ERROR,"A-Error title cannot be empty.")}};a(O,"A_Error");var A=O;var ne=class ne extends A{};a(ne,"ASEID_Error"),ne.ASEIDInitializationError="ASEID Initialization Error",ne.ASEIDValidationError="ASEID Validation Error";var N=ne;var L=class L{static isASEID(e){return this.regexp.test(e)}constructor(e){this.verifyInput(e),this.getInitializer(e).call(this,e);}get concept(){return this._concept||_.concept}get scope(){return this._scope||_.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 N(N.ASEIDInitializationError,"Invalid parameters provided to ASEID constructor")}}fromString(e){let[t,r,n]=e.split("@"),[s,i,c]=r.split(":"),d=c.includes(".")?c.split(".")[0]:void 0,E=c.includes(".")?c.split(".")[1]:c;this._concept=t||_.root.name,this._scope=s||_.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:_.concept,this._scope=e.scope?o.isNumber(e.scope)?$.formatWithLeadingZeros(e.scope):L.isASEID(e.scope)?new L(e.scope).id:e.scope:_.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 N(N.ASEIDValidationError,"Invalid ASEID format provided");case(o.isObject(e)&&!e.id):throw new N(N.ASEIDValidationError,"ASEID id is required");case(o.isObject(e)&&!e.entity):throw new N(N.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 ce=class ce extends A{};a(ce,"A_EntityError"),ce.ValidationError="A-Entity Validation Error";var X=ce;var he=class he{static get entity(){return g.toKebabCase(this.name)}static get concept(){return _.concept}static get scope(){return _.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 X(X.ValidationError,"Unable to determine A-Entity constructor initialization method. Please check the provided parameters.")}async call(e,t){return await new Y({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(he,"A_Entity");var M=he;var ge=class ge extends l{features(){return this.get("a-component-features")?.toArray().map(([,t])=>t)||[]}injections(e){return this.get("a-component-injections")?.get(e)||[]}};a(ge,"A_EntityMeta");var H=ge;var ye=class ye{constructor(e={}){this._name=e.name||this.constructor.name;}get name(){return this._name}toJSON(){return {name:this.name}}};a(ye,"A_Fragment");var K=ye;var Ce=class Ce{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 c=i[0];i.length===1?delete s[c]:s[c]!==void 0&&typeof s[c]=="object"&&n(s[c],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(Ce,"A_CommonHelper");var u=Ce;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 _e=class _e{constructor(e,t){this._meta=new l;this._allowedComponents=new Set;this._allowedErrors=new Set;this._allowedEntities=new Set;this._allowedFragments=new Set;this._components=new Map;this._errors=new Map;this._entities=new Map;this._fragments=new Map;this.getInitializer(e).call(this,e,t);}get name(){return this._name}get meta(){return this._meta}get allowedComponents(){return this._allowedComponents}get allowedEntities(){return this._allowedEntities}get allowedFragments(){return this._allowedFragments}get allowedErrors(){return this._allowedErrors}get entities(){return Array.from(this._entities.values())}get fragments(){return Array.from(this._fragments.values())}get components(){return Array.from(this._components.values())}get errors(){return Array.from(this._errors.values())}get parent(){return this._parent}getInitializer(e,t){switch(true){case(!e&&!t):return this.defaultInitialized;case !!e:return this.defaultInitialized;default:throw new f(f.ConstructorError,"Invalid parameters provided to A_Scope constructor")}}defaultInitialized(e={},t={}){this._name=e.name||this.constructor.name,this.initComponents(e.components),this.initErrors(e.errors),this.initFragments(e.fragments),this.initEntities(e.entities),this.initMeta(e.meta),t.parent&&(this._parent=t.parent);}initComponents(e){e?.forEach(this.register.bind(this));}initErrors(e){e?.forEach(this.register.bind(this));}initEntities(e){e?.forEach(t=>this.register(t));}initFragments(e){e?.forEach(this.register.bind(this));}initMeta(e){e&&Object.entries(e).forEach(([t,r])=>{this._meta.set(t,r);});}destroy(){this._components.forEach(e=>_.deregister(e)),this._fragments.forEach(e=>_.deregister(e)),this._entities.forEach(e=>_.deregister(e)),this._components.clear(),this._errors.clear(),this._fragments.clear(),this._entities.clear(),this.issuer()&&_.deallocate(this);}get(e){return this._meta.get(e)}set(e,t){this._meta.set(e,t);}issuer(){return _.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(c=>c.name===e)&&(t=true),Array.from(this.allowedFragments).find(c=>c.name===e)&&(t=true),Array.from(this.allowedEntities).find(c=>c.name===e)&&(t=true),Array.from(this.allowedErrors).find(c=>c.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 _e({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===g.toPascalCase(e));if(t)return t;let r=Array.from(this.allowedEntities).find(s=>s.name===e||s.name===g.toPascalCase(e)||s.entity===e||s.entity===g.toKebabCase(e));if(r)return r;let n=Array.from(this.allowedFragments).find(s=>s.name===e||s.name===g.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===g.toPascalCase(e));if(t)return this.resolveOnce(t);let r=Array.from(this.allowedEntities).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.entity===e||i.entity===g.toKebabCase(e));if(r)return this.resolveOnce(r);let n=Array.from(this.allowedFragments).find(i=>i.name===e||i.name===g.toPascalCase(e));if(n)return this.resolveOnce(n);let s=Array.from(this.allowedErrors).find(i=>i.name===e||i.name===g.toPascalCase(e)||i.code===e||i.code===g.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(([c,d])=>c in i?i[c]===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&&Array.from(this._allowedFragments).some(r=>u.isInheritedFrom(r,e))):{let r=Array.from(this._allowedFragments).find(n=>u.isInheritedFrom(n,e));return this.resolveFragment(r)}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=(_.meta(e).get("a-component-injections")?.get("constructor")||[]).map(i=>{let c=u.getComponentName(i.target);if("instructions"in i&&i.instructions){let{target:d,instructions:E}=i,h=this.resolve(d,E);if(!h)throw new f(f.ResolutionError,`Unable to resolve dependency ${c} for component ${e.name} in scope ${this.name}`);return h}else {let{target:d,require:E,create:h,defaultArgs:I}=i,P=this.resolve(d);if(h&&!P&&o.isAllowedForDependencyDefaultCreation(d)){let v=new d(...I);return this.register(v),v}if(E&&!P)throw new f(f.ResolutionError,`Unable to resolve required dependency ${c} for component ${e.name} in scope ${this.name}`);return P}}),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 x:{this.allowedComponents.has(e.constructor)||this.allowedComponents.add(e.constructor),this._components.set(e.constructor,e),_.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),_.register(this,e);break}case o.isFragmentInstance(e):{this.allowedFragments.has(e.constructor)||this.allowedFragments.add(e.constructor),this._fragments.set(e.constructor,e),_.register(this,e);break}case o.isErrorInstance(e):{this.allowedErrors.has(e.constructor)||this.allowedErrors.add(e.constructor),this._errors.set(e.code,e),_.register(this,e);break}case o.isComponentConstructor(e):{this.allowedComponents.has(e)||this.allowedComponents.add(e);break}case o.isFragmentConstructor(e):{this.allowedFragments.has(e)||this.allowedFragments.add(e);break}case o.isEntityConstructor(e):{this.allowedEntities.has(e)||this.allowedEntities.add(e);break}case o.isErrorConstructor(e):{this.allowedErrors.has(e)||this.allowedErrors.add(e);break}default:if(e instanceof M)throw new f(f.RegistrationError,`Entity with ASEID ${e.aseid.toString()} is already registered in the scope ${this.name}`);if(e instanceof K)throw new f(f.RegistrationError,`Fragment ${e.constructor.name} is already registered in the scope ${this.name}`);{let t=u.getComponentName(e);throw new f(f.RegistrationError,`Cannot register ${t} in the scope ${this.name}`)}}}deregister(e){switch(true){case e instanceof x:{this._components.delete(e.constructor),_.deregister(e);break}case o.isEntityInstance(e):{this._entities.delete(e.aseid.toString()),_.deregister(e);break}case o.isFragmentInstance(e):{this._fragments.delete(e.constructor),_.deregister(e);break}case o.isErrorInstance(e):{this._errors.delete(e.code),_.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(_e,"A_Scope");var R=_e;var pe=class pe extends A{};a(pe,"A_CallerError"),pe.CallerInitializationError="Unable to initialize A-Caller";var Q=pe;var Ie=class Ie{constructor(e){this.validateParams(e),this._component=e;}get component(){return this._component}validateParams(e){if(!o.isAllowedForFeatureCall(e))throw new Q(Q.CallerInitializationError,`Invalid A-Caller component provided of type: ${typeof e} with value: ${JSON.stringify(e).slice(0,100)}...`)}};a(Ie,"A_Caller");var B=Ie;var 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,x)}static isFragmentConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,K)}static isEntityConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,M)}static isScopeConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,R)}static isErrorConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,A)}static isFeatureConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,Y)}static isCallerConstructor(e){return typeof e=="function"&&u.isInheritedFrom(e,B)}static isContainerInstance(e){return e instanceof U}static isComponentInstance(e){return e instanceof x}static isFeatureInstance(e){return e instanceof Y}static isFragmentInstance(e){return e instanceof K}static isEntityInstance(e){return e instanceof M}static isScopeInstance(e){return e instanceof R}static isErrorInstance(e){return e instanceof A}static isComponentMetaInstance(e){return e instanceof k}static isContainerMetaInstance(e){return e instanceof J}static isEntityMetaInstance(e){return e instanceof H}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,x)||S.isEntityConstructor(e)||u.isInheritedFrom(e,M)}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=_.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 c=s.get(i)||new l,d=m.name||t,E=m.invoke||false;c.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||""})):[]}),_.meta(e.constructor).set(i,c);let h=r.value;return r.value=function(...I){if(E)h.apply(this,I);else return h.apply(this,I);if(typeof this.call=="function"&&E)return this.call(d)},r}}a(Pe,"A_Feature_Define");function be(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",c="",d="",E="",h=[],I=[],P=true,v;switch(true){case o.isEntityInstance(e):v="a-component-extensions";break;case o.isContainerInstance(e):v="a-container-extensions";break;case o.isComponentInstance(e):v="a-component-extensions";break}switch(true){case o.isRegExp(m):s=m;break;case(!!m&&typeof m=="object"):Array.isArray(m.scope)?h=m.scope:m.scope&&typeof m.scope=="object"&&(Array.isArray(m.scope.include)&&(h=m.scope.include),Array.isArray(m.scope.exclude)&&(I=m.scope.exclude)),s=et(m,h,I,t),i=m.behavior||i,P=m.throwOnError!==void 0?m.throwOnError:P,c=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 se=_.meta(e).get(v),Ue=_.meta(e),le=Ue.get(v)?new l().from(Ue.get(v)):new l;if(se&&se.size()&&se.has(t)&&se.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 re=[...le.get(s.source)||[]],Je=re.findIndex(qe=>qe.handler===t),Ke={name:s.source,handler:t,behavior:i,before:c,after:d,throwOnError:P,override:E};Je!==-1?re[Je]=Ke:re.push(Ke),re.push(),le.set(s.source,re),_.meta(e).set(v,le);}}a(be,"A_Feature_Extend");function et(m,e,t,r){let n=e.length?`(${e.map(c=>c.name).join("|")})`:".*",s=t.length?`(?!${t.map(c=>c.name).join("|")})`:"",i=m.scope?`^${s}${n}\\.${m.name||r}$`:`.*\\.${m.name||r}$`;return new RegExp(i)}a(et,"buildTargetRegexp");var tt=(i=>(i.PROCESSING="PROCESSING",i.COMPLETED="COMPLETED",i.FAILED="FAILED",i.SKIPPED="SKIPPED",i.INITIALIZED="INITIALIZED",i.ABORTED="ABORTED",i))(tt||{});var me=class me extends A{static get CompileError(){return "Unable to compile A-Stage"}};a(me,"A_StageError"),me.ArgumentsResolutionError="A-Stage Arguments Resolution Error";var j=me;var we=class we{constructor(e,t){this._status="INITIALIZED";this._feature=e,this._definition=t;}get name(){return this.toString()}get definition(){return this._definition}get status(){return this._status}get feature(){return this._feature}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"||this._status==="SKIPPED"}get error(){return this._error}async getStepArgs(e,t){let r;switch(true){case o.isContainerInstance(t.component):r=t.component.constructor;break;case o.isString(t.component):r=e.resolveConstructor(t.component);break;default:r=t.component;break}return Promise.all(_.meta(r).injections(t.handler).map(async n=>{switch(true){case o.isCallerConstructor(n.target):return this._feature.caller.component;case o.isFeatureConstructor(n.target):return this._feature;default:{let{target:s,require:i,create:c,defaultArgs:d,parent:E}=n,h,I=e;if(E&&typeof E.layerOffset=="number"){let P=e.parent,v=E.layerOffset;for(;v<-1&&P;)P=P.parent,v++;P&&(h=P.resolve(s),I=P);}else h=I.resolve(s);if(c&&!h&&o.isAllowedForDependencyDefaultCreation(s)){let P=new s(...d);return I.register(P),P}if(i&&!h)throw new j(j.ArgumentsResolutionError,`Unable to resolve required argument ${u.getComponentName(n.target)} for stage ${this.name} in scope ${e.name}`);return h}}}))}getStepComponent(e,t){let{component:r,handler:n}=t,s;switch(true){case o.isContainerInstance(r):s=r;break;case o.isString(r):s=e.resolve(r)||this.feature.scope.resolve(r);break;default:s=e.resolve(r)||this.feature.scope.resolve(r);break}if(!s)throw new j(j.CompileError,`Unable to resolve component ${typeof r=="string"?r:r.name} from scope ${e.name}`);if(!s[n])throw new j(j.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(we,"A_Stage");var oe=we;var ue=class ue extends A{};a(ue,"A_StepManagerError"),ue.CircularDependencyError="A-StepManager Circular Dependency Error";var ee=ue;var Ye=class Ye{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(Ye,"A_StepsManager");var te=Ye;var ve=class ve{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 be}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 _.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 R)))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=_.scope(e.component));}catch(s){if(!r)throw s}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new B(e.component||new x),_.allocate(this).inherit(t||r),this._SM=new te(e.template),this._stages=this._SM.toStages(this),this._current=this._stages[0];}fromComponent(e){if(!e.component||!o.isAllowedForFeatureDefinition(e.component))throw new 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=_.scope(e.component);}catch(i){if(!r)throw i}t&&r&&!r.isInheritedFrom(t)&&r.inherit(t),this._caller=new B(e.component);let n=_.allocate(this);n.inherit(t||r);let s=_.featureTemplate(this._name,this._caller.component,n);this._SM=new te(s),this._stages=this._SM.toStages(this),this._current=this._stages[0];}async process(e){try{if(this.isProcessed)return;this._state="PROCESSING";for(let t of this)await t.process(e);return await this.completed()}catch(t){return await this.failed(new 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(ve,"A_Feature");var Y=ve;var xe=class xe{async call(e,t){return await new Y({name:e,component:this}).process(t)}};a(xe,"A_Component");var x=xe;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 F=class F{constructor(){this._registry=new WeakMap;this._scopeIssuers=new WeakMap;this._scopeStorage=new WeakMap;this._metaStorage=new Map;let e="root";F.environment==="server"&&(e=process.env[D.A_CONCEPT_ROOT_SCOPE]||"root"),F.environment==="browser"&&(e=window[D.A_CONCEPT_ROOT_SCOPE]||"root"),this._root=new R({name:e});}static get concept(){return process.env[D.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 F._instance||(F._instance=new F),F._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 R(t||{name:r+"-scope"},t);return s.isInheritedFrom(F.root)||s.inherit(F.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=J;break}case o.isContainerConstructor(e):{n=e,s=J;break}case o.isComponentInstance(e):{n=e.constructor,s=k;break}case o.isComponentConstructor(e):{n=e,s=k;break}case o.isEntityInstance(e):{n=e.constructor,s=k;break}case o.isEntityConstructor(e):{n=e,s=H;break}case typeof e=="string":{let i=Array.from(r._metaStorage).find(([c])=>c.name===e||c.name===g.toKebabCase(e)||c.name===g.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=k;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}`,c=[];for(let[d,E]of n._metaStorage)r.has(d)&&(o.isComponentMetaInstance(E)||o.isContainerMetaInstance(E))&&E.extensions(i).forEach(h=>{c.push({component:d,...h});});return n.filterToMostDerived(r,c)}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 c=typeof i.component=="string"?e.resolveConstructor(i.component):o.isContainerInstance(i.component)?i.component.constructor:i.component;return n.prototype.isPrototypeOf(c.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 M:r="a-component-features";break;case t instanceof U:r="a-container-features";break;case t instanceof x: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[c,d]of r._metaStorage)i.has(c)&&(o.isComponentMetaInstance(d)||o.isContainerMetaInstance(d))&&d.abstractions(e).forEach(E=>{s.push({component:c,...E});});return r.filterToMostDerived(i,s)}static reset(){let e=F.getInstance();e._registry=new WeakMap;let t="root";F.environment==="server"&&(t=process.env[D.A_CONCEPT_ROOT_SCOPE]||"root"),F.environment==="browser"&&(t=window[D.A_CONCEPT_ROOT_SCOPE]||"root"),e._root=new R({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(F,"A_Context");var _=F;var de=class de extends A{};a(de,"A_AbstractionError"),de.AbstractionExtensionError="Unable to extend abstraction execution";var q=de;function Fe(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=c.get(i)?new l().from(c.get(i)):new l,h=[...E.get(d)||[]],I=h.findIndex(v=>v.handler===r),P={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?h[I]=P:h.push(P),E.set(d,h),_.meta(t).set(i,E);}}a(Fe,"A_Abstraction_Extend");var De=class De{constructor(e){this._features=[];this._index=0;this._name=e.name,this._features=e.containers.map(t=>{let r=_.abstractionTemplate(this._name,t);return new Y({name:this._name,component:t,template:r})}),this._current=this._features[0];}static get Extend(){return Fe}get name(){return this._name}get feature(){return this._current}get isDone(){return !this.feature||this._index>=this._features.length}[Symbol.iterator](){return {next:a(()=>this.isDone?(this._current=void 0,{value:void 0,done:true}):(this._current=this._features[this._index],{value:this._current,done:false}),"next")}}next(e){if(this._index>=this._features.length)return;let t=this._features.indexOf(e);this._index=t+1;}async process(e){if(!this.isDone)for(let t of this._features)await t.process(e);}};a(De,"A_Abstraction");var b=De;var rt=(c=>(c.Run="run",c.Build="build",c.Publish="publish",c.Deploy="deploy",c.Load="load",c.Start="start",c.Stop="stop",c))(rt||{}),nt=(e=>(e.LIFECYCLE="a-component-extensions",e))(nt||{});var Re=class Re{constructor(e){this.props=e;this._name=e.name||_.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 b.Extend("load",e)}static Publish(e){return b.Extend("publish")}static Deploy(e){return b.Extend("deploy",e)}static Build(e){return b.Extend("build",e)}static Run(e){return b.Extend("run",e)}static Start(e){return b.Extend("start",e)}static Stop(e){return b.Extend("stop",e)}get name(){return _.root.name}get scope(){return _.root}get register(){return this.scope.register.bind(this.scope)}get resolve(){return this.scope.resolve.bind(this.scope)}async load(e){await new b({name:"load",containers:this._containers}).process(e);}async run(e){await new b({name:"run",containers:this._containers}).process(e);}async start(e){await new b({name:"start",containers:this._containers}).process(e);}async stop(e){await new b({name:"stop",containers:this._containers}).process(e);}async build(e){await new b({name:"build",containers:this._containers}).process(e);}async deploy(e){await new b({name:"deploy",containers:this._containers}).process(e);}async publish(e){await new b({name:"publish",containers:this._containers}).process(e);}async call(e,t){return await new Y({name:e,component:t}).process()}};a(Re,"A_Concept");var Ne=Re;var Me=class Me extends l{constructor(t){super();this.containers=t;}};a(Me,"A_ConceptMeta");var Oe=Me;var W=class W extends A{};a(W,"A_DependencyError"),W.InvalidDependencyTarget="Invalid Dependency Target",W.InvalidLoadTarget="Invalid Load Target",W.InvalidLoadPath="Invalid Load Path",W.InvalidDefaultTarget="Invalid Default Target";var w=W;function ke(...m){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new w(w.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=c.get(s)||[];d[r]={...d[r]||{},defaultArgs:m,create:true},c.set(s,d),_.meta(e).set(i,c);}}a(ke,"A_Dependency_Default");function je(m){if(!m||typeof m!="string")throw new w(w.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 w(w.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=c.get(s)||[];d[r]={...d[r]||{},load:m},c.set(s,d),_.meta(e).set(i,c);}}a(je,"A_Dependency_Load");function Ve(m=-1){return function(e,t,r){let n=u.getComponentName(e);if(!o.isTargetAvailableForInjection(e))throw new w(w.InvalidDependencyTarget,`A-Dependency 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=c.get(s)||[];d[r]={...d[r]||{},parent:{layerOffset:m}},c.set(s,d),_.meta(e).set(i,c);}}a(Ve,"A_Dependency_Parent");function $e(){return function(m,e,t){let r=u.getComponentName(m);if(!o.isTargetAvailableForInjection(m))throw new w(w.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=_.meta(m).get(s)||new l,c=i.get(n)||[];c[t]={...c[t]||{},require:true},i.set(n,c),_.meta(m).set(s,i);}}a($e,"A_Dependency_Require");var ze=class ze{static get Required(){return $e}static get Loaded(){return je}static get Default(){return ke}static get Parent(){return Ve}constructor(e){this._name=e;}get name(){return this._name}};a(ze,"A_Dependency");var Le=ze;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 ot(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",c;switch(true){case(o.isComponentConstructor(t)||o.isComponentInstance(t)):c="a-component-injections";break;case o.isContainerInstance(t):c="a-container-injections";break;case o.isEntityInstance(t):c="a-component-injections";break}let d=_.meta(t).get(c)||new l,E=d.get(i)||[];E[n]={target:m,instructions:e},d.set(i,E),_.meta(t).set(c,d);}}a(ot,"A_Inject");
|
|
2
2
|
export{C as ASEID,N as ASEID_Error,b as A_Abstraction,q as A_AbstractionError,Fe as A_Abstraction_Extend,D as A_CONSTANTS__DEFAULT_ENV_VARIABLES,st as A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,G as A_CONSTANTS__ERROR_CODES,Be as A_CONSTANTS__ERROR_DESCRIPTION,B as A_Caller,Q as A_CallerError,u as A_CommonHelper,x as A_Component,k as A_ComponentMeta,Ne as A_Concept,Oe as A_ConceptMeta,U as A_Container,J as A_ContainerMeta,_ as A_Context,p as A_ContextError,Le as A_Dependency,w as A_DependencyError,ke as A_Dependency_Default,je as A_Dependency_Load,$e as A_Dependency_Require,M as A_Entity,X as A_EntityError,H as A_EntityMeta,A as A_Error,Y as A_Feature,T as A_FeatureError,Pe as A_Feature_Define,be as A_Feature_Extend,g as A_FormatterHelper,K as A_Fragment,$ as A_IdentityHelper,ot as A_Inject,Z as A_InjectError,l as A_Meta,R as A_Scope,f as A_ScopeError,oe as A_Stage,j as A_StageError,ee as A_StepManagerError,te as A_StepsManager,tt as A_TYPES__A_Stage_Status,Qe as A_TYPES__ComponentMetaKey,rt as A_TYPES__ConceptAbstractions,nt as A_TYPES__ConceptMetaKey,Xe as A_TYPES__ContainerMetaKey,We as A_TYPES__EntityFeatures,He as A_TYPES__EntityMetaKey,Ge as A_TYPES__FeatureState,o as A_TypeGuards};//# sourceMappingURL=index.mjs.map
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|