@adaas/a-concept 0.2.3 → 0.2.5

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