@entropic-bond/crud-panel 3.4.0 → 3.4.1

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.
@@ -8,178 +8,101 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.CrudController = void 0;
40
- var entropic_bond_1 = require("entropic-bond");
41
- var progress_controller_1 = require("./progress-controller");
42
- var CrudController = /** @class */ (function () {
43
- function CrudController(document) {
13
+ const entropic_bond_1 = require("entropic-bond");
14
+ const progress_controller_1 = require("./progress-controller");
15
+ class CrudController {
16
+ constructor(document) {
44
17
  this.progressController = new progress_controller_1.ProgressController();
45
18
  this.onChangeHdl = new entropic_bond_1.Observable();
46
19
  this.setDocument(document || this.createDocument());
47
20
  }
48
- CrudController.prototype.storeDoc = function () {
21
+ storeDoc() {
49
22
  return this.model.save(this.document);
50
- };
51
- CrudController.prototype.deleteDoc = function () {
23
+ }
24
+ deleteDoc() {
52
25
  return this.model.delete(this.document.id);
53
- };
54
- CrudController.prototype.findDocs = function (limit) {
26
+ }
27
+ findDocs(limit) {
55
28
  return this.model.find().limit(limit).get();
56
- };
57
- CrudController.prototype.onChange = function (observer) {
29
+ }
30
+ onChange(observer) {
58
31
  return this.onChangeHdl.subscribe(observer);
59
- };
60
- CrudController.prototype.notifyChange = function (event) {
32
+ }
33
+ notifyChange(event) {
61
34
  this.onChangeHdl.notify(event);
62
- };
63
- CrudController.prototype.newDocument = function () {
35
+ }
36
+ newDocument() {
64
37
  return this.setDocument(this.createDocument());
65
- };
66
- CrudController.prototype.storeDocument = function () {
67
- return __awaiter(this, void 0, void 0, function () {
68
- var progressStage, _a, _b;
69
- var _c;
70
- return __generator(this, function (_d) {
71
- switch (_d.label) {
72
- case 0:
73
- progressStage = 'Saving main document';
74
- _d.label = 1;
75
- case 1:
76
- _d.trys.push([1, , 4, 5]);
77
- this.progressController.notifyBusy(true, progressStage);
78
- return [4 /*yield*/, this.storeDoc()];
79
- case 2:
80
- _d.sent();
81
- _b = (_a = this.onChangeHdl).notify;
82
- _c = {};
83
- return [4 /*yield*/, this.documentCollection()];
84
- case 3:
85
- _b.apply(_a, [(_c.documentCollection = _d.sent(),
86
- _c.action = 'saved',
87
- _c)]);
88
- return [3 /*break*/, 5];
89
- case 4:
90
- this.progressController.notifyBusy(false, progressStage);
91
- return [7 /*endfinally*/];
92
- case 5: return [2 /*return*/];
93
- }
94
- });
38
+ }
39
+ storeDocument() {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const progressStage = 'Saving main document';
42
+ try {
43
+ this.progressController.notifyBusy(true, progressStage);
44
+ yield this.storeDoc();
45
+ this.onChangeHdl.notify({
46
+ documentCollection: yield this.documentCollection(),
47
+ action: 'saved'
48
+ });
49
+ }
50
+ finally {
51
+ this.progressController.notifyBusy(false, progressStage);
52
+ }
95
53
  });
96
- };
97
- CrudController.prototype.deleteDocument = function () {
98
- return __awaiter(this, void 0, void 0, function () {
99
- var progressStage, _a, _b;
100
- var _c;
101
- return __generator(this, function (_d) {
102
- switch (_d.label) {
103
- case 0:
104
- progressStage = 'Delete main document';
105
- _d.label = 1;
106
- case 1:
107
- _d.trys.push([1, , 4, 5]);
108
- this.progressController.notifyBusy(true, progressStage);
109
- return [4 /*yield*/, this.deleteDoc()];
110
- case 2:
111
- _d.sent();
112
- _b = (_a = this.onChangeHdl).notify;
113
- _c = {};
114
- return [4 /*yield*/, this.documentCollection()];
115
- case 3:
116
- _b.apply(_a, [(_c.documentCollection = _d.sent(),
117
- _c.action = 'deleted',
118
- _c)]);
119
- return [3 /*break*/, 5];
120
- case 4:
121
- this.progressController.notifyBusy(false, progressStage);
122
- return [7 /*endfinally*/];
123
- case 5: return [2 /*return*/];
124
- }
125
- });
54
+ }
55
+ deleteDocument() {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const progressStage = 'Delete main document';
58
+ try {
59
+ this.progressController.notifyBusy(true, progressStage);
60
+ yield this.deleteDoc();
61
+ this.onChangeHdl.notify({
62
+ documentCollection: yield this.documentCollection(),
63
+ action: 'deleted'
64
+ });
65
+ }
66
+ finally {
67
+ this.progressController.notifyBusy(false, progressStage);
68
+ }
126
69
  });
127
- };
128
- CrudController.prototype.documentCollection = function (limit) {
129
- return __awaiter(this, void 0, void 0, function () {
130
- var progressStage, found;
131
- return __generator(this, function (_a) {
132
- switch (_a.label) {
133
- case 0:
134
- progressStage = 'Retrieving document collection';
135
- _a.label = 1;
136
- case 1:
137
- _a.trys.push([1, , 3, 4]);
138
- this.progressController.notifyBusy(true, progressStage);
139
- return [4 /*yield*/, this.findDocs(limit)];
140
- case 2:
141
- found = _a.sent();
142
- return [3 /*break*/, 4];
143
- case 3:
144
- this.progressController.notifyBusy(false, progressStage);
145
- return [7 /*endfinally*/];
146
- case 4: return [2 /*return*/, found];
147
- }
148
- });
70
+ }
71
+ documentCollection(limit) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const progressStage = 'Retrieving document collection';
74
+ try {
75
+ this.progressController.notifyBusy(true, progressStage);
76
+ var found = yield this.findDocs(limit);
77
+ }
78
+ finally {
79
+ this.progressController.notifyBusy(false, progressStage);
80
+ }
81
+ return found;
149
82
  });
150
- };
151
- CrudController.prototype.onProgress = function (observer) {
83
+ }
84
+ onProgress(observer) {
152
85
  return this.progressController.onProgress(observer);
153
- };
154
- Object.defineProperty(CrudController.prototype, "model", {
155
- get: function () {
156
- return this._model || (this._model = this.getModel());
157
- },
158
- enumerable: false,
159
- configurable: true
160
- });
161
- CrudController.prototype.setDocument = function (value) {
162
- var _this = this;
86
+ }
87
+ get model() {
88
+ return this._model || (this._model = this.getModel());
89
+ }
90
+ setDocument(value) {
163
91
  if (this._document !== value) {
164
92
  if (this.unsubscribeDocument)
165
93
  this.unsubscribeDocument();
166
- this.unsubscribeDocument = value.onChange(function (e) { return _this.onChangeHdl.notify({ documentProps: e }); });
94
+ this.unsubscribeDocument = value.onChange(e => this.onChangeHdl.notify({ documentProps: e }));
167
95
  this._document = value;
168
96
  this.onChangeHdl.notify({ documentChanged: this._document });
169
97
  }
170
98
  return this;
171
- };
172
- Object.defineProperty(CrudController.prototype, "document", {
173
- get: function () {
174
- return this._document;
175
- },
176
- set: function (value) {
177
- this.setDocument(value);
178
- },
179
- enumerable: false,
180
- configurable: true
181
- });
182
- return CrudController;
183
- }());
99
+ }
100
+ set document(value) {
101
+ this.setDocument(value);
102
+ }
103
+ get document() {
104
+ return this._document;
105
+ }
106
+ }
184
107
  exports.CrudController = CrudController;
185
108
  //# sourceMappingURL=crud-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crud-controller.js","sourceRoot":"","sources":["../src/crud-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA6G;AAC7G,6DAAyE;AAWzE;IACC,wBAAa,QAAY;QA0Gf,uBAAkB,GAAuB,IAAI,wCAAkB,EAAE,CAAA;QACjE,gBAAW,GAAuC,IAAI,0BAAU,EAA0B,CAAA;QA1GnG,IAAI,CAAC,WAAW,CAAE,QAAQ,IAAI,IAAI,CAAC,cAAc,EAAE,CAAE,CAAA;IACtD,CAAC;IAMS,iCAAQ,GAAlB;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,IAAI,CAAC,QAAQ,CAAE,CAAA;IACxC,CAAC;IAES,kCAAS,GAAnB;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAE,CAAA;IAC7C,CAAC;IAES,iCAAQ,GAAlB,UAAoB,KAAa;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAE,KAAK,CAAE,CAAC,GAAG,EAAE,CAAA;IAC9C,CAAC;IAED,iCAAQ,GAAR,UAAU,QAA0C;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAE,QAAQ,CAAE,CAAA;IAC9C,CAAC;IAES,qCAAY,GAAtB,UAAwB,KAA6B;QACpD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAE,KAAK,CAAE,CAAA;IACjC,CAAC;IAED,oCAAW,GAAX;QACC,OAAO,IAAI,CAAC,WAAW,CAAE,IAAI,CA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C/B,IAAK,IAAI,CAAC,mBAAmB;gBAAG,IAAI,CAAC,mBAAmB,EAAE,CAAA;YAC1D,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,QAAQ,CAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAE,CAAE,CAAA;YAChG,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;YACtB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;SAC5D;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,IAAI,QAAQ,CAAE,KAAQ;QACrB,IAAI,CAAC,WAAW,CAAE,KAAK,CAAE,CAAA;IAC1B,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAA;IACtB,CAAC;CAOD;AAhHD,wCAgHC"}
@@ -1,30 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
29
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -40,38 +14,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
40
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
41
15
  });
42
16
  };
43
- var __generator = (this && this.__generator) || function (thisArg, body) {
44
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
45
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
46
- function verb(n) { return function (v) { return step([n, v]); }; }
47
- function step(op) {
48
- if (f) throw new TypeError("Generator is already executing.");
49
- while (_) try {
50
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
51
- if (y = 0, t) op = [op[0] & 2, t.value];
52
- switch (op[0]) {
53
- case 0: case 1: t = op; break;
54
- case 4: _.label++; return { value: op[1], done: false };
55
- case 5: _.label++; y = op[1]; op = [0]; continue;
56
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
57
- default:
58
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
59
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
60
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
61
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
62
- if (t[2]) _.ops.pop();
63
- _.trys.pop(); continue;
64
- }
65
- op = body.call(thisArg, _);
66
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
67
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
68
- }
69
- };
70
17
  Object.defineProperty(exports, "__esModule", { value: true });
71
18
  exports.TestController = exports.Test = void 0;
72
- var entropic_bond_1 = require("entropic-bond");
73
- var crud_controller_1 = require("./crud-controller");
74
- var mockData = {
19
+ const entropic_bond_1 = require("entropic-bond");
20
+ const crud_controller_1 = require("./crud-controller");
21
+ const mockData = {
75
22
  Test: {
76
23
  test1: {
77
24
  __className: 'Test',
@@ -85,92 +32,60 @@ var mockData = {
85
32
  }
86
33
  }
87
34
  };
88
- var Test = /** @class */ (function (_super) {
89
- __extends(Test, _super);
90
- function Test() {
91
- return _super !== null && _super.apply(this, arguments) || this;
35
+ let Test = class Test extends entropic_bond_1.EntropicComponent {
36
+ set testProp(value) {
37
+ this.changeProp('testProp', value);
92
38
  }
93
- Object.defineProperty(Test.prototype, "testProp", {
94
- get: function () {
95
- return this._testProp;
96
- },
97
- set: function (value) {
98
- this.changeProp('testProp', value);
99
- },
100
- enumerable: false,
101
- configurable: true
102
- });
103
- __decorate([
104
- entropic_bond_1.persistent
105
- ], Test.prototype, "_testProp", void 0);
106
- Test = __decorate([
107
- (0, entropic_bond_1.registerPersistentClass)('Test')
108
- ], Test);
109
- return Test;
110
- }(entropic_bond_1.EntropicComponent));
111
- exports.Test = Test;
112
- var TestController = /** @class */ (function (_super) {
113
- __extends(TestController, _super);
114
- function TestController() {
115
- return _super !== null && _super.apply(this, arguments) || this;
39
+ get testProp() {
40
+ return this._testProp;
116
41
  }
117
- TestController.prototype.createDocument = function () {
42
+ };
43
+ __decorate([
44
+ entropic_bond_1.persistent
45
+ ], Test.prototype, "_testProp", void 0);
46
+ Test = __decorate([
47
+ (0, entropic_bond_1.registerPersistentClass)('Test')
48
+ ], Test);
49
+ exports.Test = Test;
50
+ class TestController extends crud_controller_1.CrudController {
51
+ createDocument() {
118
52
  return new Test();
119
- };
120
- TestController.prototype.getModel = function () {
53
+ }
54
+ getModel() {
121
55
  return entropic_bond_1.Store.getModel('Test');
122
- };
123
- TestController.prototype.allRequiredPropertiesFilled = function () {
56
+ }
57
+ allRequiredPropertiesFilled() {
124
58
  return true;
125
- };
126
- return TestController;
127
- }(crud_controller_1.CrudController));
59
+ }
60
+ }
128
61
  exports.TestController = TestController;
129
- describe('Crud Controller', function () {
130
- var controller;
131
- var datasource;
132
- var onProgress;
133
- beforeEach(function () {
134
- datasource = new entropic_bond_1.JsonDataSource(__assign({}, mockData));
62
+ describe('Crud Controller', () => {
63
+ let controller;
64
+ let datasource;
65
+ let onProgress;
66
+ beforeEach(() => {
67
+ datasource = new entropic_bond_1.JsonDataSource(Object.assign({}, mockData));
135
68
  entropic_bond_1.Store.useDataSource(datasource);
136
69
  controller = new TestController();
137
70
  onProgress = jest.fn();
138
71
  controller.onProgress(onProgress);
139
72
  });
140
- describe('Long operations', function () {
141
- beforeEach(function () {
73
+ describe('Long operations', () => {
74
+ beforeEach(() => {
142
75
  datasource.simulateDelay(50);
143
76
  });
144
- it('should notify busy on delete', function () { return __awaiter(void 0, void 0, void 0, function () {
145
- var promise;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0:
149
- promise = controller.deleteDocument();
150
- expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: true }));
151
- return [4 /*yield*/, promise];
152
- case 1:
153
- _a.sent();
154
- expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: false }));
155
- return [2 /*return*/];
156
- }
157
- });
158
- }); });
159
- it('should notify busy on store', function () { return __awaiter(void 0, void 0, void 0, function () {
160
- var promise;
161
- return __generator(this, function (_a) {
162
- switch (_a.label) {
163
- case 0:
164
- promise = controller.storeDocument();
165
- expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: true }));
166
- return [4 /*yield*/, promise];
167
- case 1:
168
- _a.sent();
169
- expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: false }));
170
- return [2 /*return*/];
171
- }
172
- });
173
- }); });
77
+ it('should notify busy on delete', () => __awaiter(void 0, void 0, void 0, function* () {
78
+ const promise = controller.deleteDocument();
79
+ expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: true }));
80
+ yield promise;
81
+ expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: false }));
82
+ }));
83
+ it('should notify busy on store', () => __awaiter(void 0, void 0, void 0, function* () {
84
+ const promise = controller.storeDocument();
85
+ expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: true }));
86
+ yield promise;
87
+ expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: false }));
88
+ }));
174
89
  });
175
90
  });
176
91
  //# sourceMappingURL=crud-controller.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crud-controller.spec.js","sourceRoot":"","sources":["../src/crud-controller.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAoH;AACpH,qDAAkD;AAElD,IAAM,QAAQ,GAAG;IAChB,IAAI,EAAE;QACL,KAAK,EAAC;YACL,WAAW,EAAE,MAAM;YACnB,EAAE,EAAE,OAAO;YACX,QAAQ,EAAE,aAAa;SACvB;QACD,KAAK,EAAC;YACL,WAAW,EAAE,MAAM;YACnB,EAAE,EAAE,OAAO;YACX,QAAQ,EAAE,aAAa;SACvB;KACD;CACD,CAAA;AAGD;IAA0B,wBAAiB;IAA3C;;IAUA,CAAC;IATA,sBAAI,0BAAQ;aAIZ;YACC,OAAO,IAAI,CAAC,SAAS,CAAA;QACtB,CAAC;aAND,UAAc,KAAa;YAC1B,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAE,CAAA;QACpC,CAAC;;;OAAA;IAMW;QAAX,0BAAU;2CAA0B;IATzB,IAAI;QADhB,IAAA,uCAAuB,EAAE,MAAM,CAAE;OACrB,IAAI,CAUhB;IAAD,WAAC;CA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