@webiny/api 0.0.0-unstable.1e66d121db → 0.0.0-unstable.2af142b57e

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/Context.js CHANGED
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.Context = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class Context {
15
11
  constructor(params) {
16
12
  (0, _defineProperty2.default)(this, "_result", void 0);
@@ -25,33 +21,27 @@ class Context {
25
21
  this.plugins = new _plugins.PluginsContainer(plugins || []);
26
22
  this.WEBINY_VERSION = WEBINY_VERSION;
27
23
  }
28
-
29
24
  getResult() {
30
25
  return this._result;
31
26
  }
32
-
33
27
  hasResult() {
34
28
  return !!this._result;
35
29
  }
36
-
37
30
  setResult(value) {
38
31
  this._result = value;
39
32
  }
40
-
41
33
  waitFor(obj, cb) {
42
34
  const initialTargets = Array.isArray(obj) ? obj : [obj];
43
35
  const targets = [];
44
36
  /**
45
37
  * We go only through the first level properties
46
38
  */
47
-
48
39
  for (const key in initialTargets) {
49
40
  const target = initialTargets[key];
50
41
  /**
51
42
  * If property already exists, there is no need to wait for it, so we just continue the loop.
52
43
  * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.
53
44
  */
54
-
55
45
  if (this[target]) {
56
46
  continue;
57
47
  } else if (typeof target !== "string") {
@@ -61,8 +51,6 @@ class Context {
61
51
  * Since there is no property, we must define it with its setter and getter.
62
52
  * We could not know when it got defined otherwise.
63
53
  */
64
-
65
-
66
54
  Object.defineProperty(this, target, {
67
55
  /**
68
56
  * Setter sets the given value to this object.
@@ -75,7 +63,6 @@ class Context {
75
63
  /**
76
64
  * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.
77
65
  */
78
-
79
66
  for (const waiter of this.waiters) {
80
67
  if (waiter.targets.includes(target) === false) {
81
68
  continue;
@@ -83,13 +70,10 @@ class Context {
83
70
  /**
84
71
  * Remove currently set property so we know if there are any more to be waited for.
85
72
  */
86
-
87
-
88
73
  waiter.targets = waiter.targets.filter(t => t !== target);
89
74
  /**
90
75
  * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.
91
76
  */
92
-
93
77
  if (waiter.targets.length > 0) {
94
78
  continue;
95
79
  }
@@ -97,12 +81,9 @@ class Context {
97
81
  * And if there is nothing more to be waited for, we execute the callable.
98
82
  * Note that this callable is not async.
99
83
  */
100
-
101
-
102
84
  waiter.cb(this);
103
85
  }
104
86
  },
105
-
106
87
  /**
107
88
  * As we have set property with __ around it, we must get it as well.
108
89
  */
@@ -115,14 +96,11 @@ class Context {
115
96
  /**
116
97
  * We add the target to be awaited.
117
98
  */
118
-
119
99
  targets.push(target);
120
100
  }
121
101
  /**
122
102
  * If there are no targets to be awaited, just fire the callable.
123
103
  */
124
-
125
-
126
104
  if (targets.length === 0) {
127
105
  cb(this);
128
106
  return;
@@ -130,11 +108,8 @@ class Context {
130
108
  /**
131
109
  * Otherwise add the waiter for the target properties.
132
110
  */
133
-
134
-
135
111
  this.waiters.push({
136
112
  targets,
137
-
138
113
  /**
139
114
  * TODO @ts-refactor
140
115
  * Problem with possible subtype initialization
@@ -143,7 +118,5 @@ class Context {
143
118
  cb
144
119
  });
145
120
  }
146
-
147
121
  }
148
-
149
122
  exports.Context = Context;
package/Context.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["Context","constructor","params","plugins","WEBINY_VERSION","PluginsContainer","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","waiters","includes","filter","t","length","get","configurable","push"],"sources":["Context.ts"],"sourcesContent":["import { Context as ContextInterface } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\n\ninterface Waiter {\n targets: string[];\n cb: (context: ContextInterface) => void;\n}\n\nexport interface ContextParams {\n plugins?: PluginCollection;\n WEBINY_VERSION: string;\n}\nexport class Context implements ContextInterface {\n public _result: any;\n public args: any;\n public readonly plugins: PluginsContainer;\n public readonly WEBINY_VERSION: string;\n\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, WEBINY_VERSION } = params;\n this.plugins = new PluginsContainer(plugins || []);\n this.WEBINY_VERSION = WEBINY_VERSION;\n }\n\n public getResult(): any {\n return this._result;\n }\n\n public hasResult(): boolean {\n return !!this._result;\n }\n\n public setResult(value: any): void {\n this._result = value;\n }\n\n public waitFor<T extends ContextInterface = ContextInterface>(\n obj: string | string[],\n cb: (context: T) => void\n ): void {\n const initialTargets = Array.isArray(obj) ? obj : [obj];\n const targets: string[] = [];\n /**\n * We go only through the first level properties\n */\n for (const key in initialTargets) {\n const target = initialTargets[key] as keyof this;\n /**\n * If property already exists, there is no need to wait for it, so we just continue the loop.\n * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.\n */\n if (this[target]) {\n continue;\n } else if (typeof target !== \"string\") {\n continue;\n }\n /**\n * Since there is no property, we must define it with its setter and getter.\n * We could not know when it got defined otherwise.\n */\n Object.defineProperty(this, target, {\n /**\n * Setter sets the given value to this object.\n * We cannot set it on exact property name it is defined because it would go into loop of setting itself.\n * And that is why we add __ around the property name.\n */\n set: (value: any) => {\n const newTargetKey = `__${target}__` as keyof this;\n this[newTargetKey] = value;\n /**\n * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.\n */\n for (const waiter of this.waiters) {\n if (waiter.targets.includes(target) === false) {\n continue;\n }\n /**\n * Remove currently set property so we know if there are any more to be waited for.\n */\n waiter.targets = waiter.targets.filter(t => t !== target);\n /**\n * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.\n */\n if (waiter.targets.length > 0) {\n continue;\n }\n /**\n * And if there is nothing more to be waited for, we execute the callable.\n * Note that this callable is not async.\n */\n waiter.cb(this);\n }\n },\n /**\n * As we have set property with __ around it, we must get it as well.\n */\n get: (): any => {\n const newTargetKey = `__${target}__` as keyof this;\n return this[newTargetKey];\n },\n configurable: false\n });\n /**\n * We add the target to be awaited.\n */\n targets.push(target as string);\n }\n /**\n * If there are no targets to be awaited, just fire the callable.\n */\n if (targets.length === 0) {\n cb(this as any);\n return;\n }\n /**\n * Otherwise add the waiter for the target properties.\n */\n this.waiters.push({\n targets,\n /**\n * TODO @ts-refactor\n * Problem with possible subtype initialization\n */\n // @ts-ignore\n cb\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;;AAYO,MAAMA,OAAN,CAA0C;EAQtCC,WAAW,CAACC,MAAD,EAAwB;IAAA;IAAA;IAAA;IAAA;IAAA,+CAFL,EAEK;IACtC,MAAM;MAAEC,OAAF;MAAWC;IAAX,IAA8BF,MAApC;IACA,KAAKC,OAAL,GAAe,IAAIE,yBAAJ,CAAqBF,OAAO,IAAI,EAAhC,CAAf;IACA,KAAKC,cAAL,GAAsBA,cAAtB;EACH;;EAEME,SAAS,GAAQ;IACpB,OAAO,KAAKC,OAAZ;EACH;;EAEMC,SAAS,GAAY;IACxB,OAAO,CAAC,CAAC,KAAKD,OAAd;EACH;;EAEME,SAAS,CAACC,KAAD,EAAmB;IAC/B,KAAKH,OAAL,GAAeG,KAAf;EACH;;EAEMC,OAAO,CACVC,GADU,EAEVC,EAFU,EAGN;IACJ,MAAMC,cAAc,GAAGC,KAAK,CAACC,OAAN,CAAcJ,GAAd,IAAqBA,GAArB,GAA2B,CAACA,GAAD,CAAlD;IACA,MAAMK,OAAiB,GAAG,EAA1B;IACA;AACR;AACA;;IACQ,KAAK,MAAMC,GAAX,IAAkBJ,cAAlB,EAAkC;MAC9B,MAAMK,MAAM,GAAGL,cAAc,CAACI,GAAD,CAA7B;MACA;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OADc;;MAEd;AACZ;AACA;AACA;MACY;MACAJ;IAPc,CAAlB;EASH;;AApH4C"}
1
+ {"version":3,"names":["Context","constructor","params","plugins","WEBINY_VERSION","PluginsContainer","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","waiters","includes","filter","t","length","get","configurable","push"],"sources":["Context.ts"],"sourcesContent":["import { Context as ContextInterface } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\n\ninterface Waiter {\n targets: string[];\n cb: (context: ContextInterface) => void;\n}\n\nexport interface ContextParams {\n plugins?: PluginCollection;\n WEBINY_VERSION: string;\n}\nexport class Context implements ContextInterface {\n public _result: any;\n public args: any;\n public readonly plugins: PluginsContainer;\n public readonly WEBINY_VERSION: string;\n\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, WEBINY_VERSION } = params;\n this.plugins = new PluginsContainer(plugins || []);\n this.WEBINY_VERSION = WEBINY_VERSION;\n }\n\n public getResult(): any {\n return this._result;\n }\n\n public hasResult(): boolean {\n return !!this._result;\n }\n\n public setResult(value: any): void {\n this._result = value;\n }\n\n public waitFor<T extends ContextInterface = ContextInterface>(\n obj: string | string[],\n cb: (context: T) => void\n ): void {\n const initialTargets = Array.isArray(obj) ? obj : [obj];\n const targets: string[] = [];\n /**\n * We go only through the first level properties\n */\n for (const key in initialTargets) {\n const target = initialTargets[key] as keyof this;\n /**\n * If property already exists, there is no need to wait for it, so we just continue the loop.\n * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.\n */\n if (this[target]) {\n continue;\n } else if (typeof target !== \"string\") {\n continue;\n }\n /**\n * Since there is no property, we must define it with its setter and getter.\n * We could not know when it got defined otherwise.\n */\n Object.defineProperty(this, target, {\n /**\n * Setter sets the given value to this object.\n * We cannot set it on exact property name it is defined because it would go into loop of setting itself.\n * And that is why we add __ around the property name.\n */\n set: (value: any) => {\n const newTargetKey = `__${target}__` as keyof this;\n this[newTargetKey] = value;\n /**\n * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.\n */\n for (const waiter of this.waiters) {\n if (waiter.targets.includes(target) === false) {\n continue;\n }\n /**\n * Remove currently set property so we know if there are any more to be waited for.\n */\n waiter.targets = waiter.targets.filter(t => t !== target);\n /**\n * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.\n */\n if (waiter.targets.length > 0) {\n continue;\n }\n /**\n * And if there is nothing more to be waited for, we execute the callable.\n * Note that this callable is not async.\n */\n waiter.cb(this);\n }\n },\n /**\n * As we have set property with __ around it, we must get it as well.\n */\n get: (): any => {\n const newTargetKey = `__${target}__` as keyof this;\n return this[newTargetKey];\n },\n configurable: false\n });\n /**\n * We add the target to be awaited.\n */\n targets.push(target as string);\n }\n /**\n * If there are no targets to be awaited, just fire the callable.\n */\n if (targets.length === 0) {\n cb(this as any);\n return;\n }\n /**\n * Otherwise add the waiter for the target properties.\n */\n this.waiters.push({\n targets,\n /**\n * TODO @ts-refactor\n * Problem with possible subtype initialization\n */\n // @ts-ignore\n cb\n });\n }\n}\n"],"mappings":";;;;;;;;AACA;AAYO,MAAMA,OAAO,CAA6B;EAQtCC,WAAW,CAACC,MAAqB,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA,+CAFL,EAAE;IAGnC,MAAM;MAAEC,OAAO;MAAEC;IAAe,CAAC,GAAGF,MAAM;IAC1C,IAAI,CAACC,OAAO,GAAG,IAAIE,yBAAgB,CAACF,OAAO,IAAI,EAAE,CAAC;IAClD,IAAI,CAACC,cAAc,GAAGA,cAAc;EACxC;EAEOE,SAAS,GAAQ;IACpB,OAAO,IAAI,CAACC,OAAO;EACvB;EAEOC,SAAS,GAAY;IACxB,OAAO,CAAC,CAAC,IAAI,CAACD,OAAO;EACzB;EAEOE,SAAS,CAACC,KAAU,EAAQ;IAC/B,IAAI,CAACH,OAAO,GAAGG,KAAK;EACxB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I,YAAY,CAAC;QAC7B,CAAC;QACDQ,YAAY,EAAE;MAClB,CAAC,CAAC;MACF;AACZ;AACA;MACYd,OAAO,CAACe,IAAI,CAACb,MAAM,CAAW;IAClC;IACA;AACR;AACA;IACQ,IAAIF,OAAO,CAACY,MAAM,KAAK,CAAC,EAAE;MACtBhB,EAAE,CAAC,IAAI,CAAQ;MACf;IACJ;IACA;AACR;AACA;IACQ,IAAI,CAACY,OAAO,CAACO,IAAI,CAAC;MACdf,OAAO;MACP;AACZ;AACA;AACA;MACY;MACAJ;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
package/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _Context = require("./Context");
8
-
9
7
  Object.keys(_Context).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _Context[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_Context).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _ContextPlugin = require("./plugins/ContextPlugin");
21
-
22
18
  Object.keys(_ContextPlugin).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _ContextPlugin[key]) return;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/Context\";\nexport * from \"~/plugins/ContextPlugin\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/Context\";\nexport * from \"~/plugins/ContextPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api",
3
- "version": "0.0.0-unstable.1e66d121db",
3
+ "version": "0.0.0-unstable.2af142b57e",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,16 +12,16 @@
12
12
  ],
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@babel/runtime": "7.19.0",
16
- "@webiny/plugins": "0.0.0-unstable.1e66d121db"
15
+ "@babel/runtime": "7.20.13",
16
+ "@webiny/plugins": "0.0.0-unstable.2af142b57e"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@babel/cli": "^7.19.3",
20
20
  "@babel/core": "^7.19.3",
21
21
  "@babel/preset-env": "^7.19.4",
22
22
  "@babel/preset-typescript": "^7.18.6",
23
- "@webiny/cli": "^0.0.0-unstable.1e66d121db",
24
- "@webiny/project-utils": "^0.0.0-unstable.1e66d121db",
23
+ "@webiny/cli": "^0.0.0-unstable.2af142b57e",
24
+ "@webiny/project-utils": "^0.0.0-unstable.2af142b57e",
25
25
  "rimraf": "^3.0.2",
26
26
  "ttypescript": "^1.5.13",
27
27
  "typescript": "4.7.4"
@@ -34,5 +34,5 @@
34
34
  "build": "yarn webiny run build",
35
35
  "watch": "yarn webiny run watch"
36
36
  },
37
- "gitHead": "b670bf27c5039de1a2b0be764a09ba4cb94ad5e2"
37
+ "gitHead": "2af142b57e7cdc433f5098b3b6d43ae6caa5d54e"
38
38
  }
@@ -1,38 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createContextPlugin = exports.ContextPlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class ContextPlugin extends _plugins.Plugin {
15
11
  constructor(callable) {
16
12
  super();
17
13
  (0, _defineProperty2.default)(this, "_callable", void 0);
18
14
  this._callable = callable;
19
15
  }
20
-
21
16
  async apply(context) {
22
17
  if (typeof this._callable !== "function") {
23
18
  throw Error(`Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the "apply" method.`);
24
19
  }
25
-
26
20
  return this._callable(context);
27
21
  }
28
-
29
22
  }
30
-
31
23
  exports.ContextPlugin = ContextPlugin;
32
24
  (0, _defineProperty2.default)(ContextPlugin, "type", "context");
33
-
34
25
  const createContextPlugin = callable => {
35
26
  return new ContextPlugin(callable);
36
27
  };
37
-
38
28
  exports.createContextPlugin = createContextPlugin;
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","Plugin","constructor","callable","_callable","apply","context","Error","createContextPlugin"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface ContextPluginCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class ContextPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"context\";\n private readonly _callable: ContextPluginCallable<T>;\n\n constructor(callable: ContextPluginCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n): ContextPlugin<T> => {\n return new ContextPlugin<T>(callable);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAMA,aAAN,SAAyDC,eAAzD,CAAgE;EAInEC,WAAW,CAACC,QAAD,EAAqC;IAC5C;IAD4C;IAE5C,KAAKC,SAAL,GAAiBD,QAAjB;EACH;;EAEiB,MAALE,KAAK,CAACC,OAAD,EAA4B;IAC1C,IAAI,OAAO,KAAKF,SAAZ,KAA0B,UAA9B,EAA0C;MACtC,MAAMG,KAAK,CACN,uIADM,CAAX;IAGH;;IAED,OAAO,KAAKH,SAAL,CAAeE,OAAf,CAAP;EACH;;AAjBkE;;;8BAA1DN,a,UACsC,S;;AAmB5C,MAAMQ,mBAAmB,GAC5BL,QAD+B,IAEZ;EACnB,OAAO,IAAIH,aAAJ,CAAqBG,QAArB,CAAP;AACH,CAJM"}
1
+ {"version":3,"names":["ContextPlugin","Plugin","constructor","callable","_callable","apply","context","Error","createContextPlugin"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface ContextPluginCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class ContextPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"context\";\n private readonly _callable: ContextPluginCallable<T>;\n\n constructor(callable: ContextPluginCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n): ContextPlugin<T> => {\n return new ContextPlugin<T>(callable);\n};\n"],"mappings":";;;;;;;;AAAA;AAOO,MAAMA,aAAa,SAAsCC,eAAM,CAAC;EAInEC,WAAW,CAACC,QAAkC,EAAE;IAC5C,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAK,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACN,uIAAsI,CAC1I;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAAC;AAAA,8BAlBYN,aAAa,UACyB,SAAS;AAmBrD,MAAMQ,mBAAmB,GAC5BL,QAAkC,IACf;EACnB,OAAO,IAAIH,aAAa,CAAIG,QAAQ,CAAC;AACzC,CAAC;AAAC"}