@zenflux/core 0.0.0-abc.9 → 0.0.0-alpha.0

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.
@@ -1,5 +1,5 @@
1
1
  var name = "@zenflux/core";
2
- var version = "0.0.0-abc.9";
2
+ var version = "0.0.0-abc.20";
3
3
  var description = "ZenFlux core";
4
4
  var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
5
5
  var scripts = {
@@ -70,42 +70,6 @@ var pkg = {
70
70
  dependencies: dependencies
71
71
  };
72
72
 
73
- class ForceMethodBase extends Error {
74
- constructor(className, methodName) {
75
- super(`ForeMethod implementation: at '${className}' method: '${methodName}'`);
76
- }
77
- }
78
- class ForceMethod extends Error {
79
- constructor(context, methodName) {
80
- super(`ForeMethod implementation: at '${context.getName()}' method: '${methodName}'`);
81
- }
82
- }
83
-
84
- /**
85
- * @author: Leonid Vinikov <leonidvinikov@gmail.com>
86
- * @description: is base class/object for all classes, responsible for: 'getName', implementation.
87
- */
88
- let IdCounter = 0;
89
- /**
90
- * Base class 4 *
91
- */
92
- class ObjectBase {
93
- virtualId = 0;
94
- static getName() {
95
- throw new ForceMethodBase("ObjectBase", "getName");
96
- }
97
- constructor() {
98
- this.virtualId = IdCounter;
99
- APIIncreaseIdCounter();
100
- }
101
- getName() {
102
- return this.constructor.getName();
103
- }
104
- }
105
- function APIIncreaseIdCounter() {
106
- return IdCounter++;
107
- }
108
-
109
73
  /**
110
74
  * Function getCircularReplacer() : Reduce circular references.
111
75
  *
@@ -460,159 +424,9 @@ class Logger {
460
424
  }
461
425
  }
462
426
 
463
- /**
464
- * @author: Leonid Vinikov <leonidvinikov@gmail.com>
465
- * @description: Base for all commands, they are all will be managed by the `Commands` managers.
466
- * @TODO
467
- * - Add validateArgs method or find something better.
468
- */
469
- class CommandBase extends ObjectBase {
470
- args = {};
471
- options = {};
472
- logger;
473
- constructor(args = {}, options = {}) {
474
- super();
475
- const name = this.constructor.getName();
476
- this.logger = new Logger(name, true, {
477
- sameColor: true
478
- });
479
- this.logger.startWith({
480
- args,
481
- options
482
- });
483
- this.initialize(args, options);
484
- }
485
- initialize(args, options) {
486
- this.args = args;
487
- this.options = options;
488
- }
489
- apply(args = this.args, options = this.options) {
490
- throw new ForceMethod(this, "apply");
491
- }
492
- async run() {
493
- this.onBeforeApply && this.onBeforeApply();
494
- const result = await this.apply(this.args, this.options);
495
- this.onAfterApply && this.onAfterApply();
496
- return result;
497
- }
498
- getArgs() {
499
- return this.args;
500
- }
501
- getOptions() {
502
- return this.options;
503
- }
504
- }
505
-
506
- /**
507
- * @author: Leonid Vinikov <leonidvinikov@gmail.com>
508
- * @description: CommandPublic represents a USER action, every class which inherit from this class will USER action.
509
- * */
510
- class CommandPublic extends CommandBase {
511
- static getName() {
512
- return 'Core/CommandBases/CommandPublic';
513
- }
514
- }
515
-
516
- /**
517
- * @author: Leonid Vinikov <leonidvinikov@gmail.com>
518
- * @description: Each data command should represent a final REST endpoint.
519
- */
520
- class CommandData extends CommandBase {
521
- static getName() {
522
- return 'Core/CommandBases/CommandData';
523
- }
524
- /**
525
- * Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
526
- * @example
527
- * ```
528
- * args = { query: { id: 1 } };
529
- * getEndpoint() = '/api/v1/users/{id}';
530
- * result = '/api/v1/users/1';
531
- * ```
532
- */
533
- getEndpoint() {
534
- throw new ForceMethod(this, 'getEndpoint');
535
- }
536
- apply(args = this.args, options = this.options) {
537
- const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
538
- return __ZEN_MANAGERS__.data.getClient().fetch(endpoint, __ZEN_MANAGERS__.data.currentHttpMethod, args || null);
539
- }
540
- applyEndpointFormat(endpoint, data = {}) {
541
- // Replace query with `magic` placeholders.
542
- if (endpoint.includes('{')) {
543
- endpoint = endpoint.split('/').map(endpointPart => {
544
- const match = endpointPart.match('\\{(.*?)\\}');
545
- if (match?.length && 'undefined' !== typeof data[match[1]]) {
546
- return data[match[1]];
547
- }
548
- return endpointPart;
549
- }).join('/');
550
- }
551
- return endpoint;
552
- }
553
- }
554
-
555
- /**
556
- * @author: Leonid Vinikov <leonidvinikov@gmail.com>
557
- * @description: CommandInternal, is used when part of the logic needed to be in the command but not represent a user action.
558
- */
559
- class CommandInternal extends CommandBase {
560
- static getName() {
561
- return 'Core/CommandBases/CommandInternal';
562
- }
563
- }
564
-
565
- /**
566
- * @author: Leonid Vinikov <leonidvinikov@gmail.com>
567
- */
568
-
569
427
  var index$5 = /*#__PURE__*/Object.freeze({
570
428
  __proto__: null,
571
- CommandBase: CommandBase,
572
- CommandData: CommandData,
573
- CommandInternal: CommandInternal,
574
- CommandPublic: CommandPublic
575
- });
576
-
577
- /**
578
- * @author: Leonid Vinikov <leonidvinikov@gmail.com>
579
- * @description: Responsible for commands, Aka ( CommandsSpace ).
580
- */
581
- class Controller extends ObjectBase {
582
- commands;
583
- data;
584
- internal;
585
- static getName() {
586
- return 'Core/Core/Controller';
587
- }
588
- constructor() {
589
- super();
590
- this.initialize();
591
- }
592
- initialize() {
593
- this.register();
594
- this.setupHooks && this.setupHooks();
595
- }
596
- register() {
597
- this.commands = __ZEN_MANAGERS__.commands.register(this.getCommands(), this);
598
- this.data = __ZEN_MANAGERS__.data.register(this.getData(), this);
599
- this.internal = __ZEN_MANAGERS__.internal.register(this.getInternal(), this);
600
- }
601
- getCommands() {
602
- return {};
603
- }
604
- getData() {
605
- return {};
606
- }
607
- getInternal() {
608
- return {};
609
- }
610
- }
611
-
612
- var index$4 = /*#__PURE__*/Object.freeze({
613
- __proto__: null,
614
- Controller: Controller,
615
- ObjectBase: ObjectBase
429
+ Logger: Logger
616
430
  });
617
431
 
618
432
  class CommandAlreadyRegistered extends Error {
@@ -636,7 +450,18 @@ class ControllerAlreadyRegistered extends Error {
636
450
  }
637
451
  }
638
452
 
639
- var index$3 = /*#__PURE__*/Object.freeze({
453
+ class ForceMethodBase extends Error {
454
+ constructor(className, methodName) {
455
+ super(`ForeMethod implementation: at '${className}' method: '${methodName}'`);
456
+ }
457
+ }
458
+ class ForceMethod extends Error {
459
+ constructor(context, methodName) {
460
+ super(`ForeMethod implementation: at '${context.getName()}' method: '${methodName}'`);
461
+ }
462
+ }
463
+
464
+ var index$4 = /*#__PURE__*/Object.freeze({
640
465
  __proto__: null,
641
466
  CommandAlreadyRegistered: CommandAlreadyRegistered,
642
467
  CommandNotFound: CommandNotFound,
@@ -644,10 +469,30 @@ ControllerAlreadyRegistered: ControllerAlreadyRegistered,
644
469
  ForceMethod: ForceMethod
645
470
  });
646
471
 
647
- var index$2 = /*#__PURE__*/Object.freeze({
648
- __proto__: null,
649
- Logger: Logger
650
- });
472
+ /**
473
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
474
+ * @description: is base class/object for all classes, responsible for: 'getName', implementation.
475
+ */
476
+ let IdCounter = 0;
477
+ /**
478
+ * Base class 4 *
479
+ */
480
+ class ObjectBase {
481
+ virtualId = 0;
482
+ static getName() {
483
+ throw new ForceMethodBase("ObjectBase", "getName");
484
+ }
485
+ constructor() {
486
+ this.virtualId = IdCounter;
487
+ APIIncreaseIdCounter();
488
+ }
489
+ getName() {
490
+ return this.constructor.getName();
491
+ }
492
+ }
493
+ function APIIncreaseIdCounter() {
494
+ return IdCounter++;
495
+ }
651
496
 
652
497
  /**
653
498
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
@@ -1011,33 +856,39 @@ class Internal extends Commands {
1011
856
  }
1012
857
  }
1013
858
 
1014
- if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
1015
- // @ts-ignore
1016
- globalThis.__ZEN_MANAGERS__ = {};
1017
- }
1018
-
1019
859
  /**
1020
860
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1021
861
  */
862
+ const afterInitializeCallbacks = [];
1022
863
  function initialize(config) {
1023
- __ZEN_MANAGERS__.commands = new Commands();
1024
- __ZEN_MANAGERS__.controllers = new Controllers();
1025
- __ZEN_MANAGERS__.data = new Data(config);
1026
- __ZEN_MANAGERS__.internal = new Internal();
864
+ commands = new Commands();
865
+ controllers = new Controllers();
866
+ data = new Data(config);
867
+ internal = new Internal();
1027
868
  }
1028
869
  function destroy() {
1029
- __ZEN_MANAGERS__.commands = {};
1030
- __ZEN_MANAGERS__.controllers = {};
1031
- __ZEN_MANAGERS__.data = {};
1032
- __ZEN_MANAGERS__.internal = {};
870
+ commands = {};
871
+ controllers = {};
872
+ data = {};
873
+ internal = {};
1033
874
  }
1034
- const controllers = __ZEN_MANAGERS__.controllers;
1035
- const commands = __ZEN_MANAGERS__.commands;
1036
- const data = __ZEN_MANAGERS__.data;
1037
- const internal = __ZEN_MANAGERS__.internal;
875
+ var commands = {};
876
+ var controllers = {};
877
+ var data = {};
878
+ var internal = {};
879
+ /*
880
+ __ZEN_MANAGERS__.initialize = initialize;
881
+ __ZEN_MANAGERS__.destroy = destroy;
1038
882
 
1039
- var index$1 = /*#__PURE__*/Object.freeze({
883
+ export var commands = __ZEN_MANAGERS__.commands;
884
+ export var controllers = __ZEN_MANAGERS__.controllers;
885
+ export var data = __ZEN_MANAGERS__.data;
886
+ export var internal = __ZEN_MANAGERS__.internal;
887
+ */
888
+
889
+ var index$3 = /*#__PURE__*/Object.freeze({
1040
890
  __proto__: null,
891
+ afterInitializeCallbacks: afterInitializeCallbacks,
1041
892
  get commands () { return commands; },
1042
893
  get controllers () { return controllers; },
1043
894
  get data () { return data; },
@@ -1046,6 +897,161 @@ initialize: initialize,
1046
897
  get internal () { return internal; }
1047
898
  });
1048
899
 
900
+ /**
901
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
902
+ * @description: Base for all commands, they are all will be managed by the `Commands` managers.
903
+ * @TODO
904
+ * - Add validateArgs method or find something better.
905
+ */
906
+ class CommandBase extends ObjectBase {
907
+ args = {};
908
+ options = {};
909
+ logger;
910
+ constructor(args = {}, options = {}) {
911
+ super();
912
+ const name = this.constructor.getName();
913
+ this.logger = new Logger(name, true, {
914
+ sameColor: true
915
+ });
916
+ this.logger.startWith({
917
+ args,
918
+ options
919
+ });
920
+ this.initialize(args, options);
921
+ }
922
+ initialize(args, options) {
923
+ this.args = args;
924
+ this.options = options;
925
+ }
926
+ apply(args = this.args, options = this.options) {
927
+ throw new ForceMethod(this, "apply");
928
+ }
929
+ async run() {
930
+ this.onBeforeApply && this.onBeforeApply();
931
+ const result = await this.apply(this.args, this.options);
932
+ this.onAfterApply && this.onAfterApply();
933
+ return result;
934
+ }
935
+ getArgs() {
936
+ return this.args;
937
+ }
938
+ getOptions() {
939
+ return this.options;
940
+ }
941
+ }
942
+
943
+ /**
944
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
945
+ * @description: CommandPublic represents a USER action, every class which inherit from this class will USER action.
946
+ * */
947
+ class CommandPublic extends CommandBase {
948
+ static getName() {
949
+ return 'Core/CommandBases/CommandPublic';
950
+ }
951
+ }
952
+
953
+ /**
954
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
955
+ * @description: Each data command should represent a final REST endpoint.
956
+ */
957
+ class CommandData extends CommandBase {
958
+ static getName() {
959
+ return 'Core/CommandBases/CommandData';
960
+ }
961
+ /**
962
+ * Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
963
+ * @example
964
+ * ```
965
+ * args = { query: { id: 1 } };
966
+ * getEndpoint() = '/api/v1/users/{id}';
967
+ * result = '/api/v1/users/1';
968
+ * ```
969
+ */
970
+ getEndpoint() {
971
+ throw new ForceMethod(this, 'getEndpoint');
972
+ }
973
+ apply(args = this.args, options = this.options) {
974
+ const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
975
+ return data.getClient().fetch(endpoint, data.currentHttpMethod, args || null);
976
+ }
977
+ applyEndpointFormat(endpoint, data = {}) {
978
+ // Replace query with `magic` placeholders.
979
+ if (endpoint.includes('{')) {
980
+ endpoint = endpoint.split('/').map(endpointPart => {
981
+ const match = endpointPart.match('\\{(.*?)\\}');
982
+ if (match?.length && 'undefined' !== typeof data[match[1]]) {
983
+ return data[match[1]];
984
+ }
985
+ return endpointPart;
986
+ }).join('/');
987
+ }
988
+ return endpoint;
989
+ }
990
+ }
991
+
992
+ /**
993
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
994
+ * @description: CommandInternal, is used when part of the logic needed to be in the command but not represent a user action.
995
+ */
996
+ class CommandInternal extends CommandBase {
997
+ static getName() {
998
+ return 'Core/CommandBases/CommandInternal';
999
+ }
1000
+ }
1001
+
1002
+ /**
1003
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1004
+ */
1005
+
1006
+ var index$2 = /*#__PURE__*/Object.freeze({
1007
+ __proto__: null,
1008
+ CommandBase: CommandBase,
1009
+ CommandData: CommandData,
1010
+ CommandInternal: CommandInternal,
1011
+ CommandPublic: CommandPublic
1012
+ });
1013
+
1014
+ /**
1015
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1016
+ * @description: Responsible for commands, Aka ( CommandsSpace ).
1017
+ */
1018
+ class Controller extends ObjectBase {
1019
+ commands;
1020
+ data;
1021
+ internal;
1022
+ static getName() {
1023
+ return 'Core/Core/Controller';
1024
+ }
1025
+ constructor() {
1026
+ super();
1027
+ this.initialize();
1028
+ }
1029
+ initialize() {
1030
+ this.register();
1031
+ this.setupHooks && this.setupHooks();
1032
+ }
1033
+ register() {
1034
+ this.commands = commands.register(this.getCommands(), this);
1035
+ this.data = data.register(this.getData(), this);
1036
+ this.internal = internal.register(this.getInternal(), this);
1037
+ }
1038
+ getCommands() {
1039
+ return {};
1040
+ }
1041
+ getData() {
1042
+ return {};
1043
+ }
1044
+ getInternal() {
1045
+ return {};
1046
+ }
1047
+ }
1048
+
1049
+ var index$1 = /*#__PURE__*/Object.freeze({
1050
+ __proto__: null,
1051
+ Controller: Controller,
1052
+ ObjectBase: ObjectBase
1053
+ });
1054
+
1049
1055
  /**
1050
1056
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1051
1057
  */
@@ -1064,12 +1070,12 @@ Internal: Internal
1064
1070
 
1065
1071
  var exported = /*#__PURE__*/Object.freeze({
1066
1072
  __proto__: null,
1067
- commandBases: index$5,
1068
- core: index$4,
1069
- errors: index$3,
1073
+ commandBases: index$2,
1074
+ core: index$1,
1075
+ errors: index$4,
1070
1076
  managerBases: index,
1071
- managers: index$1,
1072
- modules: index$2,
1077
+ managers: index$3,
1078
+ modules: index$5,
1073
1079
  utils: index$6
1074
1080
  });
1075
1081
 
@@ -1083,24 +1089,16 @@ errorInitTwice();
1083
1089
  let config = {
1084
1090
  version: pkg.version
1085
1091
  };
1086
- const afterInitializeCallbacks = [];
1087
1092
  const CoreAPI = {
1088
1093
  initialize: configuration => {
1089
1094
  errorInitTwice();
1090
1095
  config = configuration || config;
1091
- commands = new Commands();
1092
- controllers = new Controllers();
1093
- data = new Data(config);
1094
- internal = new Internal();
1096
+ initialize(config);
1095
1097
  isInitialized = true;
1096
- afterInitializeCallbacks.forEach(callback => callback());
1097
1098
  },
1098
1099
  destroy: () => {
1100
+ destroy();
1099
1101
  isInitialized = false;
1100
- commands = {};
1101
- controllers = {};
1102
- data = {};
1103
- internal = {};
1104
1102
  },
1105
1103
  onAfterInitialize: callback => {
1106
1104
  afterInitializeCallbacks.push(callback);
@@ -1111,4 +1109,4 @@ const CoreAPI = {
1111
1109
  // TODO: Make it available only for development.
1112
1110
  if (!globalThis?.ZenCore) globalThis.ZenCore = CoreAPI;
1113
1111
 
1114
- export { index$5 as commandBases, index$4 as core, CoreAPI as default, index$3 as errors, index as managerBases, index$1 as managers, index$2 as modules, index$6 as utils };
1112
+ export { index$2 as commandBases, index$1 as core, CoreAPI as default, index$4 as errors, index as managerBases, index$3 as managers, index$5 as modules, index$6 as utils };
@@ -1,12 +1,12 @@
1
- var t="0.0.0-abc.9";class e extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class r extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let s=0;class n{virtualId=0;static getName(){throw new e("ObjectBase","getName")}constructor(){this.virtualId=s,s++}getName(){return this.constructor.getName()}}
1
+ var t="0.0.0-abc.20";
2
2
  /**
3
3
  * Function getCircularReplacer() : Reduce circular references.
4
4
  *
5
5
  * @copyright https://stackoverflow.com/a/53731154
6
6
  */
7
- const o=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},a=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);let c=255-Math.abs(r-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
7
+ const e=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},r=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);let c=255-Math.abs(r-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
8
8
  /**
9
9
  * Function hexColorDelta() : Return color difference in ratio decimal point.
10
10
  *
11
11
  * @copyright http://jsfiddle.net/96sME/
12
- */var i=Object.freeze({__proto__:null,getCircularReplacer:o,hexColorDelta:a});class c{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){c.wrappers={},c.wrapperDepth=0,c.colorsInUse=[],c.sharedData={}}static createCustomWrapper(t,e){c.wrappers[t]||(c.wrappers[t.name]=[]),c.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(c.sharedData[this.name]||(c.sharedData[this.name]=this.getRandomColor()),this.color=c.sharedData[this.name]):(this.color=this.getRandomColor(),c.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;c.wrapperDepth++;let r={...t};return Object.values(c.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>c.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),c.wrapperDepth--,r):(c.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",c.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=c.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const r=c.getCallerName();t=Object.create(t);for(let s in t)"object"==typeof t[s]&&(t[s]=JSON.stringify(this.useWrapper(t[s]),o())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${r}%c() [${e}] ->> ${s}: '${t[s]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",c.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=c.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",c.getCallerName(),t),r&&this.printNextLineObject("tw",c.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=c.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(r).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in r){let e=r[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),o()):"function"==typeof r[t]&&(e=c.getFunctionView(e)),this.out.call(this,"%c"+t+": `"+this.useWrapper(e)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return c.colorsInUse.some((e=>a(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}class l extends n{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new c(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,e=this.options){throw new r(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}var h=Object.freeze({__proto__:null,CommandBase:l,CommandData:class extends l{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new r(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return __ZEN_MANAGERS__.data.getClient().fetch(r,__ZEN_MANAGERS__.data.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends l{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends l{static getName(){return"Core/CommandBases/CommandPublic"}}});var u=Object.freeze({__proto__:null,Controller:class extends n{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=__ZEN_MANAGERS__.commands.register(this.getCommands(),this),this.data=__ZEN_MANAGERS__.data.register(this.getData(),this),this.internal=__ZEN_MANAGERS__.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:n});class p extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class g extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class m extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var d,_=Object.freeze({__proto__:null,CommandAlreadyRegistered:p,CommandNotFound:g,ControllerAlreadyRegistered:m,ForceMethod:r}),f=Object.freeze({__proto__:null,Logger:c});class N extends n{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new c(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new p(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new g(t);return new s(e,r)}onBefore(t,e){N.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){N.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){N.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){N.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){N.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){N.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await N.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await N.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&N.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),N.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],N.trace.pop(),this.trace.pop()}}class A extends n{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new m(t);return this.controllers[t.getName()]=t,t}}!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(d||(d={}));class E extends n{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new c(E.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},n={};[d.POST,d.PUT,d.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class C extends N{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),C.client=new E(t.baseURL)}getClient(){return C.client}get(t,e={},r={}){return this.currentHttpMethod=d.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=d.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=d.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=d.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return d.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=d.__EMPTY__,e.result}}class y extends N{static getName(){return"Core/Managers/Internal"}}"undefined"!=typeof __ZEN_MANAGERS__&&__ZEN_MANAGERS__||(globalThis.__ZEN_MANAGERS__={});const b=__ZEN_MANAGERS__.controllers,w=__ZEN_MANAGERS__.commands,O=__ZEN_MANAGERS__.data,k=__ZEN_MANAGERS__.internal;var M=Object.freeze({__proto__:null,get commands(){return w},get controllers(){return b},get data(){return O},destroy:function(){__ZEN_MANAGERS__.commands={},__ZEN_MANAGERS__.controllers={},__ZEN_MANAGERS__.data={},__ZEN_MANAGERS__.internal={}},initialize:function(t){__ZEN_MANAGERS__.commands=new N,__ZEN_MANAGERS__.controllers=new A,__ZEN_MANAGERS__.data=new C(t),__ZEN_MANAGERS__.internal=new y},get internal(){return k}}),H=Object.freeze({__proto__:null,Commands:N,Controllers:A,Data:C,Internal:y}),j=Object.freeze({__proto__:null,commandBases:h,core:u,errors:_,managerBases:H,managers:M,modules:f,utils:i});let I=!1;function S(){if(I)throw Error("ZenCore is already initialized.")}S();let R={version:t};const $=[],B={initialize:t=>{S(),R=t||R,w=new N,b=new A,O=new C(R),k=new y,I=!0,$.forEach((t=>t()))},destroy:()=>{I=!1,w={},b={},O={},k={}},onAfterInitialize:t=>{$.push(t)},config:R,...j};globalThis?.ZenCore||(globalThis.ZenCore=B);export{h as commandBases,u as core,B as default,_ as errors,H as managerBases,M as managers,f as modules,i as utils};
12
+ */var s=Object.freeze({__proto__:null,getCircularReplacer:e,hexColorDelta:r});class n{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){n.wrappers={},n.wrapperDepth=0,n.colorsInUse=[],n.sharedData={}}static createCustomWrapper(t,e){n.wrappers[t]||(n.wrappers[t.name]=[]),n.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(n.sharedData[this.name]||(n.sharedData[this.name]=this.getRandomColor()),this.color=n.sharedData[this.name]):(this.color=this.getRandomColor(),n.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;n.wrapperDepth++;let r={...t};return Object.values(n.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>n.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),n.wrapperDepth--,r):(n.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",n.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=n.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},r=""){if(!this.state)return;const s=n.getCallerName();t=Object.create(t);for(let n in t)"object"==typeof t[n]&&(t[n]=JSON.stringify(this.useWrapper(t[n]),e())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${s}%c() [${r}] ->> ${n}: '${t[n]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",n.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=n.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",n.getCallerName(),t),r&&this.printNextLineObject("tw",n.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=n.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${r}%c(${Object.keys(s).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in s){let r=s[t];"object"==typeof r?r=JSON.stringify(this.useWrapper(r),e()):"function"==typeof s[t]&&(r=n.getFunctionView(r)),this.out.call(this,"%c"+t+": `"+this.useWrapper(r)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return n.colorsInUse.some((e=>r(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}var o=Object.freeze({__proto__:null,Logger:n});class a extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class i extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class c extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}class l extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class h extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}var u=Object.freeze({__proto__:null,CommandAlreadyRegistered:a,CommandNotFound:i,ControllerAlreadyRegistered:c,ForceMethod:h});let p=0;class g{virtualId=0;static getName(){throw new l("ObjectBase","getName")}constructor(){this.virtualId=p,p++}getName(){return this.constructor.getName()}}class m extends g{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new n(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new a(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new i(t);return new s(e,r)}onBefore(t,e){m.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){m.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){m.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){m.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){m.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){m.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await m.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await m.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&m.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),m.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],m.trace.pop(),this.trace.pop()}}class d extends g{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new c(t);return this.controllers[t.getName()]=t,t}}var f;!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(f||(f={}));class C extends g{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new n(C.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},n={};[f.POST,f.PUT,f.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class y extends m{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),y.client=new C(t.baseURL)}getClient(){return y.client}get(t,e={},r={}){return this.currentHttpMethod=f.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=f.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=f.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=f.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return f.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=f.__EMPTY__,e.result}}class b extends m{static getName(){return"Core/Managers/Internal"}}const N=[];function w(t){A=new m,k=new d,E=new y(t),H=new b}function O(){A={},k={},E={},H={}}var A={},k={},E={},H={},I=Object.freeze({__proto__:null,afterInitializeCallbacks:N,get commands(){return A},get controllers(){return k},get data(){return E},destroy:O,initialize:w,get internal(){return H}});class _ extends g{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new n(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,e=this.options){throw new h(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}var j=Object.freeze({__proto__:null,CommandBase:_,CommandData:class extends _{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new h(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return E.getClient().fetch(r,E.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends _{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends _{static getName(){return"Core/CommandBases/CommandPublic"}}});var $=Object.freeze({__proto__:null,Controller:class extends g{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=A.register(this.getCommands(),this),this.data=E.register(this.getData(),this),this.internal=H.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:g}),B=Object.freeze({__proto__:null,Commands:m,Controllers:d,Data:y,Internal:b}),T=Object.freeze({__proto__:null,commandBases:j,core:$,errors:u,managerBases:B,managers:I,modules:o,utils:s});let M=!1;function U(){if(M)throw Error("ZenCore is already initialized.")}U();let D={version:t};const L={initialize:t=>{U(),D=t||D,w(D),M=!0},destroy:()=>{O(),M=!1},onAfterInitialize:t=>{N.push(t)},config:D,...T};globalThis?.ZenCore||(globalThis.ZenCore=L);export{j as commandBases,$ as core,L as default,u as errors,B as managerBases,I as managers,o as modules,s as utils};