@gudhub/core 1.1.57 → 1.1.58

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.
@@ -17,26 +17,25 @@ export default class AppsTemplateService {
17
17
  let currentStep = 0;
18
18
  self.createApps(pack, (status) => {
19
19
  currentStep += 1;
20
- progressCallback.call(this, {
20
+ progressCallback ? progressCallback.call(this, {
21
21
  percent: currentStep * stepPercents,
22
22
  status
23
- })
23
+ }) : null;
24
24
  }).then(success => {
25
25
  self.createItems(success, maxNumberOfInsstalledItems, (status) => {
26
26
  if (typeof status === 'string') {
27
27
  currentStep += 1;
28
- progressCallback.call(this, {
28
+ progressCallback ? progressCallback.call(this, {
29
29
  percent: currentStep * stepPercents,
30
30
  status
31
- })
31
+ }) : null;
32
32
  } else if (typeof status === 'object') {
33
- progressCallback.call(this, {
33
+ progressCallback ? progressCallback.call(this, {
34
34
  status: 'Done',
35
35
  apps: status
36
- })
36
+ }) : null;
37
+ resolve();
37
38
  }
38
- }).then(() => {
39
- resolve();
40
39
  })
41
40
  })
42
41
  });
@@ -61,64 +60,64 @@ export default class AppsTemplateService {
61
60
  fields: []
62
61
  }
63
62
  }).filter((item, index) => index <= MAX_NUMBER_OF_INSTALLED_ITEMS);
64
-
65
63
  self.gudhub.addNewItems(app.app_id, items).then(items => {
66
64
  callback ? callback.call(this, `ADD NEW ITEMS: ${result_app.app_name} (Items steps)`) : null;
67
65
 
68
- if (items.length === 0) {
69
- callback ? callback.call(this, `NO ITEMS TO REPLACE VALUE: ${result_app.app_name} (Items steps)`) : null;
70
- app_resolve();
71
- }
72
-
73
66
  app.items_list = items;
74
67
  self._updateMap(app.items_list, source_app.items_list);
75
68
  self._addFieldValue(source_app.items_list, app.items_list, self.appsConnectingMap);
76
69
 
77
70
  createsItems.push(app);
78
71
 
79
- if (self.appsConnectingMap.apps.length === createsItems.length) {
80
- createsItems.forEach(app => {
81
- app.items_list.forEach(item => {
82
- item.fields.forEach(field_item => {
83
- self.appsConnectingMap.fields.forEach(field_map => {
84
- if (field_item.field_id === field_map.old_field_id) {
85
- field_item.field_id = field_map.new_field_id;
86
- field_item.element_id = field_map.new_field_id;
87
- }
88
- })
89
- })
90
- })
91
- });
92
-
93
- self.deleteField(createsItems);
94
-
95
- self.replaceValue(createsItems, self.appsConnectingMap).then(() => {
96
- callback ? callback.call(this, `REPLACE VALUE: ${result_app.app_name} (Items steps)`) : null;
97
- createsItems.forEach(created_app => {
98
- let newItems = created_app.items_list.map(item => {
99
- item.fields.forEach(field => {
100
- delete field.data_id;
101
- });
102
- return item;
103
- });
104
-
105
- self.gudhub.updateItems(created_app.app_id, newItems).then(() => {
106
- app_resolve();
107
- })
108
- })
109
- });
110
- }
72
+ app_resolve();
111
73
  });
112
74
  });
113
75
  }));
114
76
  });
115
77
 
116
78
  Promise.all(promises).then(() => {
117
- let apps = create_apps.map(app => {
118
- return app.app_id;
79
+
80
+ createsItems.forEach(app => {
81
+ app.items_list.forEach(item => {
82
+ item.fields.forEach(field_item => {
83
+ self.appsConnectingMap.fields.forEach(field_map => {
84
+ if (field_item.field_id === field_map.old_field_id) {
85
+ field_item.field_id = field_map.new_field_id;
86
+ field_item.element_id = field_map.new_field_id;
87
+ }
88
+ })
89
+ })
90
+ })
91
+ });
92
+
93
+ self.deleteField(createsItems);
94
+
95
+ self.replaceValue(createsItems, self.appsConnectingMap).then(() => {
96
+
97
+ const promises = [];
98
+
99
+ createsItems.forEach(created_app => {
100
+ promises.push(new Promise(resolve => {
101
+ let newItems = created_app.items_list.map(item => {
102
+ item.fields.forEach(field => {
103
+ delete field.data_id;
104
+ });
105
+ return item;
106
+ });
107
+
108
+ self.gudhub.updateItems(created_app.app_id, newItems).then(() => {
109
+ callback ? callback.call(this, `REPLACE VALUE: ${created_app.app_name} (Items steps)`) : null;
110
+ resolve();
111
+ })
112
+ }));
113
+ });
114
+
115
+ Promise.all(promises).then(() => {
116
+ callback.call(this, createsItems);
117
+ resolve();
119
118
  });
120
- callback.call(this, apps);
121
- resolve();
119
+
120
+ });
122
121
  })
123
122
  })
124
123
  }
@@ -185,26 +184,30 @@ export default class AppsTemplateService {
185
184
  documentInstallerHelper(appId, items, elementId) {
186
185
  const self = this;
187
186
  return new Promise(async (resolve) => {
188
- items.forEach(item => {
187
+ for(const item of items) {
189
188
  const itemId = item.item_id;
190
189
  const field = item.fields.find(field => field.element_id === elementId);
191
190
 
192
191
  if (field && field.field_value && field.field_value.length > 0) {
193
- self.gudhub.getDocument({
192
+ const document = await self.gudhub.getDocument({
194
193
  _id: field.field_value
195
- }).then(document => {
196
- self.gudhub.createDocument({
194
+ });
195
+
196
+ if(document && document.data) {
197
+
198
+ const newDocument = await self.gudhub.createDocument({
197
199
  app_id: appId,
198
200
  item_id: itemId,
199
201
  element_id: elementId,
200
202
  data: document.data
201
- }).then(new_document => {
202
- field.field_value = new_document._id;
203
- resolve();
204
- })
205
- })
203
+ });
204
+
205
+ field.field_value = newDocument._id;
206
+
207
+ }
206
208
  }
207
- });
209
+ }
210
+ resolve();
208
211
  });
209
212
  }
210
213
 
@@ -21,6 +21,7 @@ import { compiler } from "./json_constructor/json_constructor.js";
21
21
  import AppsTemplateService from "./AppsTemplateService/AppsTemplateService.js";
22
22
  import { FileHelper } from "./FIleHelper/FileHelper.js";
23
23
  import { compareObjects } from "./compareObjects/compareObjects.js";
24
+ import { dynamicPromiseAll } from "./dynamicPromiseAll/dynamicPromiseAll.js";
24
25
 
25
26
  export class Utils {
26
27
  constructor(gudhub) {
@@ -206,4 +207,8 @@ export class Utils {
206
207
  callback(diff);
207
208
  });
208
209
  }
210
+
211
+ dynamicPromiseAll(promisesArray) {
212
+ return dynamicPromiseAll(promisesArray);
213
+ }
209
214
  }
@@ -0,0 +1,49 @@
1
+ export async function dynamicPromiseAll(promises) {
2
+
3
+ await Promise.all(promises);
4
+
5
+ let allDone = true;
6
+
7
+ for(const promise of promises) {
8
+ const result = await _checkPromiseStatus(promise);
9
+ if(result.state === 'pending') {
10
+ allDone = false;
11
+ break;
12
+ }
13
+ if(result.state === 'rejected') {
14
+ throw result.reason;
15
+ break;
16
+ }
17
+ }
18
+
19
+ if(allDone) {
20
+ return true;
21
+ }
22
+
23
+ return dynamicPromiseAll(promises);
24
+
25
+ }
26
+
27
+ function _checkPromiseStatus(promise) {
28
+
29
+ const pending = {
30
+ state: 'pending',
31
+ };
32
+
33
+ return Promise.race([promise, pending]).then(
34
+ (value) => {
35
+ if (value === pending) {
36
+ return value;
37
+ }
38
+ return {
39
+ state: 'resolved',
40
+ value
41
+ };
42
+ },
43
+ (reason) => ({
44
+ state: 'rejected',
45
+ reason
46
+ })
47
+ );
48
+ }
49
+
@@ -114,11 +114,11 @@ export function compiler(scheme, item, util, variables, appId) {
114
114
 
115
115
  case "function":
116
116
  if(typeof scheme.function === 'function') {
117
- let result = scheme.function(item, appId, ...scheme.args);
117
+ let result = scheme.function(item, appId, util.gudhub, ...scheme.args);
118
118
  return result;
119
119
  } else {
120
- const func = new Function('item, appId', 'return (async ' + scheme.function + ')(item, appId)');
121
- let result = await func(item, appId);
120
+ const func = new Function('item, appId, gudhub', 'return (async ' + scheme.function + ')(item, appId, util.gudhub)');
121
+ let result = await func(item, appId, util.gudhub);
122
122
  return result;
123
123
  }
124
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.1.57",
3
+ "version": "1.1.58",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -169,16 +169,18 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
169
169
  },{}],"xR4c":[function(require,module,exports) {
170
170
  "use strict";function e(){return'function createList(items) {\n return items.reduce(\n (acc, item) => {\n acc.list[item.item_id] = item;\n acc.ids.push(item.item_id);\n return acc;\n },\n { ids: [], list: {} }\n );\n };\n function compareItemsLists(oldItems, newItems) {\n const { ids: oldIds, list: oldList } = createList(oldItems);\n const { ids: newIds, list: newList } = createList(newItems);\n\n const deletedItemsIds = oldIds.filter((id) => !newIds.includes(id));\n const recentItemsIds = oldIds.filter((id) => !deletedItemsIds.includes(id));\n const newItemsIds = newIds.filter((id) => !oldIds.includes(id));\n\n const diff_fields_items = {};\n const diff_fields_items_Ids = [];\n \n recentItemsIds.forEach((id) => {\n const newItem = newList[id];\n const oldItem = oldList[id];\n\n oldItem.fields.forEach((field1) => {\n const sameField = newItem.fields.find(\n (field2) => Number(field2.field_id) === Number(field1.field_id)\n );\n\n if (!sameField) {\n if (!diff_fields_items[newItem.item_id]) {\n diff_fields_items[newItem.item_id] = [];\n diff_fields_items_Ids.push(newItem.item_id);\n }\n\n return diff_fields_items[newItem.item_id].push(field1);\n }\n\n if (field1.field_value != sameField.field_value) {\n if (!diff_fields_items[newItem.item_id]) {\n diff_fields_items[newItem.item_id] = [];\n diff_fields_items_Ids.push(newItem.item_id);\n }\n return diff_fields_items[newItem.item_id].push(field1);\n }\n });\n });\n\n return {\n newItems: newItemsIds.reduce((acc, id) => {\n acc.push(newList[id]);\n return acc;\n }, []),\n deletedItems: deletedItemsIds.reduce((acc, id) => {\n acc.push(oldList[id]);\n return acc;\n }, []),\n diff_fields_items_Ids,\n diff_fields_items,\n diff_items: diff_fields_items_Ids.reduce((acc, id) => {\n acc.push(oldList[id]);\n return acc;\n }, []),\n };\n }\n\n self.addEventListener("message", (event) => {\n const { items_list1, items_list2 } = event.data;\n\n const diff = compareItemsLists(items_list1, items_list2);\n self.postMessage({ diff });\n });'}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compare_items_lists_Worker=e;
171
171
  },{}],"nKaW":[function(require,module,exports) {
172
- "use strict";function t(r){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(r)}function r(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function e(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach(function(r){f(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n(t){return u(t)||a(t)||i(t)||o()}function o(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(t,r){if(t){if("string"==typeof t)return c(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?c(t,r):void 0}}function a(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function u(t){if(Array.isArray(t))return c(t)}function c(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function s(){s=function(){return r};var r={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(N){f=function(t,r,e){return t[r]=e}}function l(t,r,e,n){var i=r&&r.prototype instanceof d?r:d,a=Object.create(i.prototype),u=new E(n||[]);return o(a,"_invoke",{value:O(t,e,u)}),a}function p(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(N){return{type:"throw",arg:N}}}r.wrap=l;var h={};function d(){}function y(){}function v(){}var m={};f(m,a,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(S([])));g&&g!==e&&n.call(g,a)&&(m=g);var w=v.prototype=d.prototype=Object.create(m);function _(t){["next","throw","return"].forEach(function(r){f(t,r,function(t){return this._invoke(r,t)})})}function x(r,e){var i;o(this,"_invoke",{value:function(o,a){function u(){return new e(function(i,u){!function o(i,a,u,c){var s=p(r[i],r,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==t(l)&&n.call(l,"__await")?e.resolve(l.__await).then(function(t){o("next",t,u,c)},function(t){o("throw",t,u,c)}):e.resolve(l).then(function(t){f.value=t,u(f)},function(t){return o("throw",t,u,c)})}c(s.arg)}(o,a,i,u)})}return i=i?i.then(u,u):u()}})}function O(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=j(a,e);if(u){if(u===h)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=p(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}function j(t,r){var e=r.method,n=t.iterator[e];if(void 0===n)return r.delegate=null,"throw"===e&&t.iterator.return&&(r.method="return",r.arg=void 0,j(t,r),"throw"===r.method)||"return"!==e&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+e+"' method")),h;var o=p(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,h;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,h):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}function k(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function L(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,o=function r(){for(;++e<t.length;)if(n.call(t,e))return r.value=t[e],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return y.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:y,configurable:!0}),y.displayName=f(v,c,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===y||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,f(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},r.awrap=function(t){return{__await:t}},_(x.prototype),f(x.prototype,u,function(){return this}),r.AsyncIterator=x,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new x(l(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},_(w),f(w,c,"Generator"),f(w,a,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=S,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),h},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),L(e),h}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;L(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:S(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),h}},r}function f(t,r,e){return(r=l(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function l(r){var e=p(r,"string");return"symbol"===t(e)?e:String(e)}function p(r,e){if("object"!==t(r)||null===r)return r;var n=r[Symbol.toPrimitive];if(void 0!==n){var o=n.call(r,e||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}function h(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(s){return void e(s)}u.done?r(c):Promise.resolve(c).then(n,o)}function d(t){return function(){var r=this,e=arguments;return new Promise(function(n,o){var i=t.apply(r,e);function a(t){h(i,n,o,a,u,"next",t)}function u(t){h(i,n,o,a,u,"throw",t)}a(void 0)})}}function y(t,r,o,i,a){function u(t,r,e){return c.apply(this,arguments)}function c(){return(c=d(s().mark(function t(r,e,n){var o;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(o=null,"array"!==r.type){t.next=13;break}if(!Number(r.is_static)){t.next=10;break}return t.t0=Array,t.next=6,v(r.childs,e,n);case 6:t.t1=t.sent,o=new t.t0(t.t1),t.next=13;break;case 10:return t.next=12,l(r,e,n);case 12:o=t.sent;case 13:if("object"!==r.type){t.next=23;break}if(!Number(r.current_item)){t.next=20;break}return t.next=17,h(r,e);case 17:o=t.sent,t.next=23;break;case 20:return t.next=22,v(r.childs,e,n);case 22:o=t.sent;case 23:if("property"!==r.type){t.next=27;break}return t.next=26,b(r,e,n);case 26:o=t.sent;case 27:return t.abrupt("return",f({},r.property_name,o));case 28:case"end":return t.stop()}},t)}))).apply(this,arguments)}function l(t,r,e){return p.apply(this,arguments)}function p(){return(p=d(s().mark(function t(r,e,i){var a,u,c,f,l;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.gudhub.getApp(Number(r.app_id));case 2:return a=t.sent,t.next=5,x(r.filter,a.items_list,i,e);case 5:return u=t.sent,r.isSortable&&r.field_id_to_sort&&""!==r.field_id_to_sort&&(c=u.flatMap(function(t){var e=t.fields.find(function(t){return t.field_id==r.field_id_to_sort});return e&&""!=e.field_value?t:[]}),f=u.filter(function(t){if(!c.includes(t))return t}),c=c.sort(function(t,e){return"desc"==r.sortType?e.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value-t.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value:t.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value-e.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value}),u=[].concat(n(c),n(f))),l=u.map(function(){var t=d(s().mark(function t(e){return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",v(r.childs,e,a.app_id));case 1:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}()),t.abrupt("return",Promise.all(l));case 9:case"end":return t.stop()}},t)}))).apply(this,arguments)}function h(t,r){return y.apply(this,arguments)}function y(){return(y=d(s().mark(function t(r,e){var n,i;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.gudhub.getApp(r.app_id);case 2:return n=t.sent,i=n.items_list||[],t.abrupt("return",v(r.childs,e||i[0],n.app_id));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}function v(t,r,e){return m.apply(this,arguments)}function m(){return(m=d(s().mark(function t(r,n,o){var i,a;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.map(function(){var t=d(s().mark(function t(r){return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",u(r,n,o));case 1:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}());case 2:return i=t.sent,t.next=5,Promise.all(i);case 5:return a=t.sent,t.abrupt("return",a.reduce(function(t,r){return e(e({},t),r)},{}));case 7:case"end":return t.stop()}},t)}))).apply(this,arguments)}function b(t,r,e){return g.apply(this,arguments)}function g(){return(g=d(s().mark(function t(r,e,i){var a,u,c,f,l;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=r.property_type,t.next="static"===t.t0?3:"variable"===t.t0?4:"field_id"===t.t0?9:"function"===t.t0?10:(t.t0,20);break;case 3:return t.abrupt("return",r.static_field_value);case 4:t.t1=r.variable_type,t.next="app_id"===t.t1?7:(t.t1,8);break;case 7:return t.abrupt("return",i);case 8:return t.abrupt("return","".concat(i,".").concat(e.item_id));case 9:return t.abrupt("return",r.field_id);case 10:if("function"!=typeof r.function){t.next=15;break}return a=r.function.apply(r,[e,i].concat(n(r.args))),t.abrupt("return",a);case 15:return u=new Function("item, appId","return (async "+r.function+")(item, appId)"),t.next=18,u(e,i);case 18:return c=t.sent,t.abrupt("return",c);case 20:if(!Boolean(Number(r.interpretation))){t.next=27;break}return t.next=23,o.gudhub.getInterpretationById(Number(i),Number(e.item_id),Number(r.field_id),"value");case 23:return f=t.sent,t.abrupt("return",f);case 27:return t.next=29,o.gudhub.getFieldValue(Number(i),Number(e.item_id),Number(r.field_id));case 29:return l=t.sent,t.abrupt("return",l);case 31:case"end":return t.stop()}},t)}))).apply(this,arguments)}function w(t,r,e,n,o){return _.apply(this,arguments)}function _(){return(_=d(s().mark(function t(r,e,a,u,c){var f;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.gudhub.prefilter(JSON.parse(JSON.stringify(r)),e,a,u,i);case 2:return f=t.sent,t.abrupt("return",o.gudhub.filter(c,[].concat(n(f),n(r))));case 4:case"end":return t.stop()}},t)}))).apply(this,arguments)}function x(){return O.apply(this,arguments)}function O(){return(O=d(s().mark(function t(){var r,e,o,i,a=arguments;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>0&&void 0!==a[0]?a[0]:[],e=a.length>1&&void 0!==a[1]?a[1]:[],o=a.length>2&&void 0!==a[2]?a[2]:"",i=a.length>3&&void 0!==a[3]?a[3]:{},t.abrupt("return",r.length?w(r,o,o,i.item_id,e):n(e));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}return u(t,r,a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compiler=y;
172
+ "use strict";function t(r){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(r)}function r(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function e(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach(function(r){f(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n(t){return a(t)||u(t)||o(t)||i()}function i(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(t,r){if(t){if("string"==typeof t)return c(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?c(t,r):void 0}}function u(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function a(t){if(Array.isArray(t))return c(t)}function c(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function s(){s=function(){return r};var r={},e=Object.prototype,n=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},o="function"==typeof Symbol?Symbol:{},u=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(N){f=function(t,r,e){return t[r]=e}}function l(t,r,e,n){var o=r&&r.prototype instanceof d?r:d,u=Object.create(o.prototype),a=new E(n||[]);return i(u,"_invoke",{value:O(t,e,a)}),u}function p(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(N){return{type:"throw",arg:N}}}r.wrap=l;var h={};function d(){}function y(){}function v(){}var b={};f(b,u,function(){return this});var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==e&&n.call(g,u)&&(b=g);var w=v.prototype=d.prototype=Object.create(b);function _(t){["next","throw","return"].forEach(function(r){f(t,r,function(t){return this._invoke(r,t)})})}function x(r,e){var o;i(this,"_invoke",{value:function(i,u){function a(){return new e(function(o,a){!function i(o,u,a,c){var s=p(r[o],r,u);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==t(l)&&n.call(l,"__await")?e.resolve(l.__await).then(function(t){i("next",t,a,c)},function(t){i("throw",t,a,c)}):e.resolve(l).then(function(t){f.value=t,a(f)},function(t){return i("throw",t,a,c)})}c(s.arg)}(i,u,o,a)})}return o=o?o.then(a,a):a()}})}function O(t,r,e){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return P()}for(e.method=i,e.arg=o;;){var u=e.delegate;if(u){var a=j(u,e);if(a){if(a===h)continue;return a}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=p(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}function j(t,r){var e=r.method,n=t.iterator[e];if(void 0===n)return r.delegate=null,"throw"===e&&t.iterator.return&&(r.method="return",r.arg=void 0,j(t,r),"throw"===r.method)||"return"!==e&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+e+"' method")),h;var i=p(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,h;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,h):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}function k(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function L(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,i=function r(){for(;++e<t.length;)if(n.call(t,e))return r.value=t[e],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return y.prototype=v,i(w,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:y,configurable:!0}),y.displayName=f(v,c,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===y||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,f(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},r.awrap=function(t){return{__await:t}},_(x.prototype),f(x.prototype,a,function(){return this}),r.AsyncIterator=x,r.async=function(t,e,n,i,o){void 0===o&&(o=Promise);var u=new x(l(t,e,n,i),o);return r.isGeneratorFunction(e)?u:u.next().then(function(t){return t.done?t.value:u.next()})},_(w),f(w,c,"Generator"),f(w,u,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=S,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,n){return u.type="throw",u.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],u=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var u=o?o.completion:{};return u.type=t,u.arg=r,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(u)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),h},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),L(e),h}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var i=n.arg;L(e)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:S(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),h}},r}function f(t,r,e){return(r=l(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function l(r){var e=p(r,"string");return"symbol"===t(e)?e:String(e)}function p(r,e){if("object"!==t(r)||null===r)return r;var n=r[Symbol.toPrimitive];if(void 0!==n){var i=n.call(r,e||"default");if("object"!==t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}function h(t,r,e,n,i,o,u){try{var a=t[o](u),c=a.value}catch(s){return void e(s)}a.done?r(c):Promise.resolve(c).then(n,i)}function d(t){return function(){var r=this,e=arguments;return new Promise(function(n,i){var o=t.apply(r,e);function u(t){h(o,n,i,u,a,"next",t)}function a(t){h(o,n,i,u,a,"throw",t)}u(void 0)})}}function y(t,r,i,o,u){function a(t,r,e){return c.apply(this,arguments)}function c(){return(c=d(s().mark(function t(r,e,n){var i;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null,"array"!==r.type){t.next=13;break}if(!Number(r.is_static)){t.next=10;break}return t.t0=Array,t.next=6,v(r.childs,e,n);case 6:t.t1=t.sent,i=new t.t0(t.t1),t.next=13;break;case 10:return t.next=12,l(r,e,n);case 12:i=t.sent;case 13:if("object"!==r.type){t.next=23;break}if(!Number(r.current_item)){t.next=20;break}return t.next=17,h(r,e);case 17:i=t.sent,t.next=23;break;case 20:return t.next=22,v(r.childs,e,n);case 22:i=t.sent;case 23:if("property"!==r.type){t.next=27;break}return t.next=26,m(r,e,n);case 26:i=t.sent;case 27:return t.abrupt("return",f({},r.property_name,i));case 28:case"end":return t.stop()}},t)}))).apply(this,arguments)}function l(t,r,e){return p.apply(this,arguments)}function p(){return(p=d(s().mark(function t(r,e,o){var u,a,c,f,l;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.getApp(Number(r.app_id));case 2:return u=t.sent,t.next=5,x(r.filter,u.items_list,o,e);case 5:return a=t.sent,r.isSortable&&r.field_id_to_sort&&""!==r.field_id_to_sort&&(c=a.flatMap(function(t){var e=t.fields.find(function(t){return t.field_id==r.field_id_to_sort});return e&&""!=e.field_value?t:[]}),f=a.filter(function(t){if(!c.includes(t))return t}),c=c.sort(function(t,e){return"desc"==r.sortType?e.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value-t.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value:t.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value-e.fields.find(function(t){return t.field_id==r.field_id_to_sort}).field_value}),a=[].concat(n(c),n(f))),l=a.map(function(){var t=d(s().mark(function t(e){return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",v(r.childs,e,u.app_id));case 1:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}()),t.abrupt("return",Promise.all(l));case 9:case"end":return t.stop()}},t)}))).apply(this,arguments)}function h(t,r){return y.apply(this,arguments)}function y(){return(y=d(s().mark(function t(r,e){var n,o;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.getApp(r.app_id);case 2:return n=t.sent,o=n.items_list||[],t.abrupt("return",v(r.childs,e||o[0],n.app_id));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}function v(t,r,e){return b.apply(this,arguments)}function b(){return(b=d(s().mark(function t(r,n,i){var o,u;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.map(function(){var t=d(s().mark(function t(r){return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a(r,n,i));case 1:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}());case 2:return o=t.sent,t.next=5,Promise.all(o);case 5:return u=t.sent,t.abrupt("return",u.reduce(function(t,r){return e(e({},t),r)},{}));case 7:case"end":return t.stop()}},t)}))).apply(this,arguments)}function m(t,r,e){return g.apply(this,arguments)}function g(){return(g=d(s().mark(function t(r,e,o){var u,a,c,f,l;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=r.property_type,t.next="static"===t.t0?3:"variable"===t.t0?4:"field_id"===t.t0?9:"function"===t.t0?10:(t.t0,20);break;case 3:return t.abrupt("return",r.static_field_value);case 4:t.t1=r.variable_type,t.next="app_id"===t.t1?7:(t.t1,8);break;case 7:return t.abrupt("return",o);case 8:return t.abrupt("return","".concat(o,".").concat(e.item_id));case 9:return t.abrupt("return",r.field_id);case 10:if("function"!=typeof r.function){t.next=15;break}return u=r.function.apply(r,[e,o,i.gudhub].concat(n(r.args))),t.abrupt("return",u);case 15:return a=new Function("item, appId, gudhub","return (async "+r.function+")(item, appId, util.gudhub)"),t.next=18,a(e,o,i.gudhub);case 18:return c=t.sent,t.abrupt("return",c);case 20:if(!Boolean(Number(r.interpretation))){t.next=27;break}return t.next=23,i.gudhub.getInterpretationById(Number(o),Number(e.item_id),Number(r.field_id),"value");case 23:return f=t.sent,t.abrupt("return",f);case 27:return t.next=29,i.gudhub.getFieldValue(Number(o),Number(e.item_id),Number(r.field_id));case 29:return l=t.sent,t.abrupt("return",l);case 31:case"end":return t.stop()}},t)}))).apply(this,arguments)}function w(t,r,e,n,i){return _.apply(this,arguments)}function _(){return(_=d(s().mark(function t(r,e,u,a,c){var f;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.prefilter(JSON.parse(JSON.stringify(r)),e,u,a,o);case 2:return f=t.sent,t.abrupt("return",i.gudhub.filter(c,[].concat(n(f),n(r))));case 4:case"end":return t.stop()}},t)}))).apply(this,arguments)}function x(){return O.apply(this,arguments)}function O(){return(O=d(s().mark(function t(){var r,e,i,o,u=arguments;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>0&&void 0!==u[0]?u[0]:[],e=u.length>1&&void 0!==u[1]?u[1]:[],i=u.length>2&&void 0!==u[2]?u[2]:"",o=u.length>3&&void 0!==u[3]?u[3]:{},t.abrupt("return",r.length?w(r,i,i,o.item_id,e):n(e));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}return a(t,r,u)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compiler=y;
173
173
  },{}],"zqOZ":[function(require,module,exports) {
174
- "use strict";function e(){e=function(){return t};var t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(N){f=function(e,t,n){return e[t]=n}}function p(e,t,n,i){var r=t&&t.prototype instanceof h?t:h,a=Object.create(r.prototype),c=new L(i||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(N){return{type:"throw",arg:N}}}t.wrap=p;var d={};function h(){}function _(){}function v(){}var m={};f(m,c,function(){return this});var y=Object.getPrototypeOf,g=y&&y(y(k([])));g&&g!==n&&r.call(g,c)&&(m=g);var w=v.prototype=h.prototype=Object.create(m);function E(e){["next","throw","return"].forEach(function(t){f(e,t,function(e){return this._invoke(t,e)})})}function b(e,t){var n;o(this,"_invoke",{value:function(o,a){function c(){return new t(function(n,c){!function n(o,a,c,u){var l=s(e[o],e,a);if("throw"!==l.type){var f=l.arg,p=f.value;return p&&"object"==i(p)&&r.call(p,"__await")?t.resolve(p.__await).then(function(e){n("next",e,c,u)},function(e){n("throw",e,c,u)}):t.resolve(p).then(function(e){f.value=e,c(f)},function(e){return n("throw",e,c,u)})}u(l.arg)}(o,a,n,c)})}return n=n?n.then(c,c):c()}})}function x(e,t,n){var i="suspendedStart";return function(r,o){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===r)throw o;return I()}for(n.method=r,n.arg=o;;){var a=n.delegate;if(a){var c=O(a,n);if(c){if(c===d)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var u=s(e,t,n);if("normal"===u.type){if(i=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i="completed",n.method="throw",n.arg=u.arg)}}}function O(e,t){var n=t.method,i=e.iterator[n];if(void 0===i)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var r=s(i,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,d;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function k(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return _.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:_,configurable:!0}),_.displayName=f(v,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,f(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},E(b.prototype),f(b.prototype,u,function(){return this}),t.AsyncIterator=b,t.async=function(e,n,i,r,o){void 0===o&&(o=Promise);var a=new b(p(e,n,i,r),o);return t.isGeneratorFunction(n)?a:a.next().then(function(e){return e.done?e.value:a.next()})},E(w),f(w,l,"Generator"),f(w,c,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},t.values=k,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,i){return a.type="throw",a.arg=e,t.next=n,i&&(t.method="next",t.arg=void 0),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:k(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},t}function t(e,t,n,i,r,o,a){try{var c=e[o](a),u=c.value}catch(l){return void n(l)}c.done?t(u):Promise.resolve(u).then(i,r)}function n(e){return function(){var n=this,i=arguments;return new Promise(function(r,o){var a=e.apply(n,i);function c(e){t(a,r,o,c,u,"next",e)}function u(e){t(a,r,o,c,u,"throw",e)}c(void 0)})}}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,c(i.key),i)}}function a(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e){var t=u(e,"string");return"symbol"===i(t)?t:String(t)}function u(e,t){if("object"!==i(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var l=function(){function t(e){r(this,t),this.gudhub=e,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}}return a(t,[{key:"createAppsFromTemplate",value:function(e,t,n){var r=this,o=this;return new Promise(function(a){var c=100/(6*e.apps.length),u=0;o.createApps(e,function(e){u+=1,n.call(r,{percent:u*c,status:e})}).then(function(e){o.createItems(e,t,function(e){"string"==typeof e?(u+=1,n.call(r,{percent:u*c,status:e})):"object"===i(e)&&n.call(r,{status:"Done",apps:e})}).then(function(){a()})})})}},{key:"createItems",value:function(e,t,n){var i=this;return new Promise(function(r){var o=t||1e5,a=i,c=[],u=[];e.forEach(function(e){u.push(new Promise(function(t){a.gudhub.getApp(a._searchOldAppId(e.app_id,a.appsConnectingMap.apps)).then(function(r){n&&n.call(i,"GET APP: ".concat(r.app_name," (Items steps)"));var u=JSON.parse(JSON.stringify(r)),l=u.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,t){return t<=o});a.gudhub.addNewItems(e.app_id,l).then(function(o){n&&n.call(i,"ADD NEW ITEMS: ".concat(r.app_name," (Items steps)")),0===o.length&&(n&&n.call(i,"NO ITEMS TO REPLACE VALUE: ".concat(r.app_name," (Items steps)")),t()),e.items_list=o,a._updateMap(e.items_list,u.items_list),a._addFieldValue(u.items_list,e.items_list,a.appsConnectingMap),c.push(e),a.appsConnectingMap.apps.length===c.length&&(c.forEach(function(e){e.items_list.forEach(function(e){e.fields.forEach(function(e){a.appsConnectingMap.fields.forEach(function(t){e.field_id===t.old_field_id&&(e.field_id=t.new_field_id,e.element_id=t.new_field_id)})})})}),a.deleteField(c),a.replaceValue(c,a.appsConnectingMap).then(function(){n&&n.call(i,"REPLACE VALUE: ".concat(r.app_name," (Items steps)")),c.forEach(function(e){var n=e.items_list.map(function(e){return e.fields.forEach(function(e){delete e.data_id}),e});a.gudhub.updateItems(e.app_id,n).then(function(){t()})})}))})})}))}),Promise.all(u).then(function(){var t=e.map(function(e){return e.app_id});n.call(i,t),r()})})}},{key:"deleteField",value:function(e){e.forEach(function(e){e.items_list.forEach(function(t){t.fields=t.fields.filter(function(t){return e.field_list.findIndex(function(e){return e.field_id==t.field_id})>-1})})})}},{key:"replaceValue",value:function(t,i){var r=this;return new Promise(function(){var o=n(e().mark(function n(o){var a,c;return e().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=[],c=r,t.forEach(function(e){e.field_list.forEach(function(t){"item_ref"===t.data_type&&c._replaceValueItemRef(e,t,i),a.push(new Promise(function(n){c.gudhub.ghconstructor.getInstance(t.data_type).then(function(i){return void 0===i?(console.log("ERROR WHILE GETTING INSTANCE OF ",t.data_type),void n({type:t.data_type})):"file"==i.getTemplate().constructor?c.gudhub.util.fileInstallerHelper(e.app_id,e.items_list,t.field_id).then(function(e){n(e)}):void("document"==i.getTemplate().constructor?c.documentInstallerHelper(e.app_id,e.items_list,t.field_id).then(function(e){n(i)}):n(i))})}))})}),a.length>0?Promise.all(a).then(function(e){o(e)}):o(result);case 4:case"end":return e.stop()}},n)}));return function(e){return o.apply(this,arguments)}}())}},{key:"documentInstallerHelper",value:function(t,i,r){var o=this;return new Promise(function(){var a=n(e().mark(function n(a){return e().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:i.forEach(function(e){var n=e.item_id,i=e.fields.find(function(e){return e.element_id===r});i&&i.field_value&&i.field_value.length>0&&o.gudhub.getDocument({_id:i.field_value}).then(function(e){o.gudhub.createDocument({app_id:t,item_id:n,element_id:r,data:e.data}).then(function(e){i.field_value=e._id,a()})})});case 1:case"end":return e.stop()}},n)}));return function(e){return a.apply(this,arguments)}}())}},{key:"_replaceValueItemRef",value:function(e,t,n){e.items_list.forEach(function(e){e.fields.forEach(function(e){if(e.field_id===t.field_id&&e.field_value){var i=e.field_value.split(",");i.forEach(function(e,t){var r=e.split(".");n.apps.forEach(function(e){r[0]==e.old_app_id&&(r[0]=e.new_app_id)}),n.items.forEach(function(e){r[1]==e.old_item_id&&(r[1]=e.new_item_id)}),i[t]=r.join(".")}),e.field_value=i.join(",")}})})}},{key:"_addFieldValue",value:function(e,t,n){t.forEach(function(t){n.items.forEach(function(n){t.item_id===n.new_item_id&&e.forEach(function(e){n.old_item_id===e.item_id&&(t.fields=e.fields)})})})}},{key:"_updateMap",value:function(e,t){var n=this;t.forEach(function(t){e.forEach(function(e){t.index_number===e.index_number&&n.appsConnectingMap.items.push({old_item_id:t.item_id,new_item_id:e.item_id})})})}},{key:"_searchOldAppId",value:function(e,t){var n=0;return t.forEach(function(t){t.new_app_id===e&&(n=t.old_app_id)}),n}},{key:"createApps",value:function(e,t){var n=this,i=this,r={step_size:100/(3*e.apps.length),apps:[]};return new Promise(function(o){var a={},c=[],u=[];e.apps.forEach(function(l){i.gudhub.getApp(l).then(function(l){t&&t.call(n,"GET APP: ".concat(l.app_name," (App steps)"));var f=JSON.parse(JSON.stringify(l));a[f.app_id]=f,r.apps.push(f.icon);var p=i.prepareAppTemplate(f);p.app_name=p.app_name+" New",p.privacy=1,e.data_to_change&&(e.data_to_change.name&&(p.app_name=e.data_to_change.name),e.data_to_change.icon&&(p.icon=e.data_to_change.icon)),i.resetViewsIds(p),i.gudhub.createNewApp(p).then(function(r){t&&t.call(n,"CREATE NEW APP: ".concat(l.app_name," (App steps)")),c.push(r),i.mapApp(f,r,i.appsConnectingMap),e.apps.length==c.length&&(i.connectApps(c,i.appsConnectingMap,a),c.forEach(function(r){i.gudhub.updateApp(r).then(function(i){t&&t.call(n,"UPDATE APP: ".concat(l.app_name," (App steps)")),u.push(i),e.apps.length==u.length&&o(u)})}))})})})})}},{key:"mapApp",value:function(e,t,n){n.apps.push({old_app_id:e.app_id,new_app_id:t.app_id,old_view_init:e.view_init,new_view_init:t.view_init}),e.field_list.forEach(function(e){t.field_list.forEach(function(t){e.name_space==t.name_space&&n.fields.push({name_space:e.name_space,old_field_id:e.field_id,new_field_id:t.field_id})})}),e.views_list.forEach(function(e){t.views_list.forEach(function(t){e.name==t.name&&n.views.push({name:e.name,old_view_id:e.view_id,new_view_id:t.view_id})})})}},{key:"crawling",value:function(e,t){var n=null===e?[]:Object.keys(e),i=this;n.length>0&&n.forEach(function(n){var r=e[n];void 0!==r&&"string"!=typeof e&&(t(n,r,e),i.crawling(r,t))})}},{key:"resetViewsIds",value:function(e){e.view_init=0,this.crawling(e.views_list,function(e,t,n){"view_id"!=e&&"container_id"!=e||(n[e]=0)})}},{key:"connectApps",value:function(e,t,n){var i=this;return e.forEach(function(e){t.apps.forEach(function(n){e.view_init===n.new_view_init&&t.views.forEach(function(t){n.old_view_init===t.old_view_id&&(e.view_init=t.new_view_id)})}),i.crawling(e.field_list,function(r,o,a){if(-1!==r.indexOf("field_id")||-1!==r.indexOf("FieldId")||-1!==r.indexOf("destination_field")){var c=String(o).split(","),u=[];t.fields.forEach(function(e){c.forEach(function(t){t==e.old_field_id&&u.push(e.new_field_id)})}),u.length&&(a[r]=u.join(","))}if(-1==r.indexOf("app_id")&&-1==r.indexOf("AppId")&&-1==r.indexOf("destination_app")||t.apps.forEach(function(e){o==e.old_app_id&&(a[r]=e.new_app_id)}),-1!==r.indexOf("view_id")&&t.views.forEach(function(e){o==e.old_view_id&&(a[r]=e.new_view_id)}),-1!==r.indexOf("src")&&isFinite(o)){var l=t.apps.find(function(t){return t.new_app_id===e.app_id}).old_app_id,f=i.findPath(n[l].views_list,"container_id",o);a[r]="".concat(i.getValueByPath(e.views_list,f,"container_id"))}})}),e}},{key:"getValueByPath",value:function(e,t,n){var i=e;return t.split(".").forEach(function(e){i=i[e]}),i[n]}},{key:"findPath",value:function(e,t,n){var r=!1,o=!1,a=[];return this.crawling(e,function(e,c,u){o&&a.reverse().forEach(function(e){o&&(e.delete=!0,e.parent===u&&(o=!1,(a=a.filter(function(e){return!e.delete})).reverse()))}),r||("object"===i(u[e])&&a.push({prop:e,parent:u}),c==n&&t===e?r=!0:Object.keys(u).pop()===e&&"object"!==i(u[e])&&(o=!0))}),a.map(function(e){return e.prop}).join(".")}},{key:"prepareAppTemplate",value:function(e){var t=JSON.parse(JSON.stringify(e));return this.crawling(t.views_list,function(e,t,n){"element_id"==e&&(n.element_id=-Number(t),n.create_element=-Number(t))}),t.field_list.forEach(function(e){e.create_field=-Number(e.field_id),e.element_id=-Number(e.field_id),e.field_id=-Number(e.field_id),e.field_value=""}),t.items_list=[],delete t.app_id,delete t.icon.id,delete t.group_id,delete t.trash,delete t.last_update,delete t.file_list,t}}]),t}();exports.default=l;
174
+ "use strict";function e(e,n){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=t(e))||n&&e&&"number"==typeof e.length){i&&(e=i);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==i.return||i.return()}finally{if(u)throw a}}}}function t(e,t){if(e){if("string"==typeof e)return n(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function i(){i=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},c=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(I){f=function(e,t,n){return e[t]=n}}function s(e,t,n,i){var o=t&&t.prototype instanceof h?t:h,a=Object.create(o.prototype),c=new k(i||[]);return r(a,"_invoke",{value:x(e,n,c)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(I){return{type:"throw",arg:I}}}e.wrap=s;var d={};function h(){}function _(){}function v(){}var m={};f(m,c,function(){return this});var y=Object.getPrototypeOf,g=y&&y(y(L([])));g&&g!==t&&n.call(g,c)&&(m=g);var w=v.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach(function(t){f(e,t,function(e){return this._invoke(t,e)})})}function E(e,t){var i;r(this,"_invoke",{value:function(r,o){function c(){return new t(function(i,c){!function i(r,o,c,u){var l=p(e[r],e,o);if("throw"!==l.type){var f=l.arg,s=f.value;return s&&"object"==a(s)&&n.call(s,"__await")?t.resolve(s.__await).then(function(e){i("next",e,c,u)},function(e){i("throw",e,c,u)}):t.resolve(s).then(function(e){f.value=e,c(f)},function(e){return i("throw",e,c,u)})}u(l.arg)}(r,o,i,c)})}return i=i?i.then(c,c):c()}})}function x(e,t,n){var i="suspendedStart";return function(r,o){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===r)throw o;return j()}for(n.method=r,n.arg=o;;){var a=n.delegate;if(a){var c=O(a,n);if(c){if(c===d)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var u=p(e,t,n);if("normal"===u.type){if(i=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i="completed",n.method="throw",n.arg=u.arg)}}}function O(e,t){var n=t.method,i=e.iterator[n];if(void 0===i)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var r=p(i,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,d;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function L(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,r=function t(){for(;++i<e.length;)if(n.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:j}}function j(){return{value:void 0,done:!0}}return _.prototype=v,r(w,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:_,configurable:!0}),_.displayName=f(v,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,f(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},b(E.prototype),f(E.prototype,u,function(){return this}),e.AsyncIterator=E,e.async=function(t,n,i,r,o){void 0===o&&(o=Promise);var a=new E(s(t,n,i,r),o);return e.isGeneratorFunction(n)?a:a.next().then(function(e){return e.done?e.value:a.next()})},b(w),f(w,l,"Generator"),f(w,c,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=L,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(n,i){return a.type="throw",a.arg=e,t.next=n,i&&(t.method="next",t.arg=void 0),!!i}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function r(e,t,n,i,r,o,a){try{var c=e[o](a),u=c.value}catch(l){return void n(l)}c.done?t(u):Promise.resolve(u).then(i,r)}function o(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var a=e.apply(t,n);function c(e){r(a,i,o,c,u,"next",e)}function u(e){r(a,i,o,c,u,"throw",e)}c(void 0)})}}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,f(i.key),i)}}function l(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e){var t=s(e,"string");return"symbol"===a(t)?t:String(t)}function s(e,t){if("object"!==a(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var p=function(){function t(e){c(this,t),this.gudhub=e,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}}return l(t,[{key:"createAppsFromTemplate",value:function(e,t,n){var i=this,r=this;return new Promise(function(o){var c=100/(6*e.apps.length),u=0;r.createApps(e,function(e){u+=1,n&&n.call(i,{percent:u*c,status:e})}).then(function(e){r.createItems(e,t,function(e){"string"==typeof e?(u+=1,n&&n.call(i,{percent:u*c,status:e})):"object"===a(e)&&(n&&n.call(i,{status:"Done",apps:e}),o())})})})}},{key:"createItems",value:function(e,t,n){var i=this;return new Promise(function(r){var o=t||1e5,a=i,c=[],u=[];e.forEach(function(e){u.push(new Promise(function(t){a.gudhub.getApp(a._searchOldAppId(e.app_id,a.appsConnectingMap.apps)).then(function(r){n&&n.call(i,"GET APP: ".concat(r.app_name," (Items steps)"));var u=JSON.parse(JSON.stringify(r)),l=u.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,t){return t<=o});a.gudhub.addNewItems(e.app_id,l).then(function(o){n&&n.call(i,"ADD NEW ITEMS: ".concat(r.app_name," (Items steps)")),e.items_list=o,a._updateMap(e.items_list,u.items_list),a._addFieldValue(u.items_list,e.items_list,a.appsConnectingMap),c.push(e),t()})})}))}),Promise.all(u).then(function(){c.forEach(function(e){e.items_list.forEach(function(e){e.fields.forEach(function(e){a.appsConnectingMap.fields.forEach(function(t){e.field_id===t.old_field_id&&(e.field_id=t.new_field_id,e.element_id=t.new_field_id)})})})}),a.deleteField(c),a.replaceValue(c,a.appsConnectingMap).then(function(){var e=[];c.forEach(function(t){e.push(new Promise(function(e){var r=t.items_list.map(function(e){return e.fields.forEach(function(e){delete e.data_id}),e});a.gudhub.updateItems(t.app_id,r).then(function(){n&&n.call(i,"REPLACE VALUE: ".concat(t.app_name," (Items steps)")),e()})}))}),Promise.all(e).then(function(){n.call(i,c),r()})})})})}},{key:"deleteField",value:function(e){e.forEach(function(e){e.items_list.forEach(function(t){t.fields=t.fields.filter(function(t){return e.field_list.findIndex(function(e){return e.field_id==t.field_id})>-1})})})}},{key:"replaceValue",value:function(e,t){var n=this;return new Promise(function(){var r=o(i().mark(function r(o){var a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:a=[],c=n,e.forEach(function(e){e.field_list.forEach(function(n){"item_ref"===n.data_type&&c._replaceValueItemRef(e,n,t),a.push(new Promise(function(t){c.gudhub.ghconstructor.getInstance(n.data_type).then(function(i){return void 0===i?(console.log("ERROR WHILE GETTING INSTANCE OF ",n.data_type),void t({type:n.data_type})):"file"==i.getTemplate().constructor?c.gudhub.util.fileInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(e)}):void("document"==i.getTemplate().constructor?c.documentInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(i)}):t(i))})}))})}),a.length>0?Promise.all(a).then(function(e){o(e)}):o(result);case 4:case"end":return i.stop()}},r)}));return function(e){return r.apply(this,arguments)}}())}},{key:"documentInstallerHelper",value:function(t,n,r){var a=this;return new Promise(function(){var c=o(i().mark(function o(c){var u,l,f,s,p,d,h;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:u=e(n),i.prev=1,u.s();case 3:if((l=u.n()).done){i.next=18;break}if(f=l.value,s=f.item_id,!((p=f.fields.find(function(e){return e.element_id===r}))&&p.field_value&&p.field_value.length>0)){i.next=16;break}return i.next=10,a.gudhub.getDocument({_id:p.field_value});case 10:if(!(d=i.sent)||!d.data){i.next=16;break}return i.next=14,a.gudhub.createDocument({app_id:t,item_id:s,element_id:r,data:d.data});case 14:h=i.sent,p.field_value=h._id;case 16:i.next=3;break;case 18:i.next=23;break;case 20:i.prev=20,i.t0=i.catch(1),u.e(i.t0);case 23:return i.prev=23,u.f(),i.finish(23);case 26:c();case 27:case"end":return i.stop()}},o,null,[[1,20,23,26]])}));return function(e){return c.apply(this,arguments)}}())}},{key:"_replaceValueItemRef",value:function(e,t,n){e.items_list.forEach(function(e){e.fields.forEach(function(e){if(e.field_id===t.field_id&&e.field_value){var i=e.field_value.split(",");i.forEach(function(e,t){var r=e.split(".");n.apps.forEach(function(e){r[0]==e.old_app_id&&(r[0]=e.new_app_id)}),n.items.forEach(function(e){r[1]==e.old_item_id&&(r[1]=e.new_item_id)}),i[t]=r.join(".")}),e.field_value=i.join(",")}})})}},{key:"_addFieldValue",value:function(e,t,n){t.forEach(function(t){n.items.forEach(function(n){t.item_id===n.new_item_id&&e.forEach(function(e){n.old_item_id===e.item_id&&(t.fields=e.fields)})})})}},{key:"_updateMap",value:function(e,t){var n=this;t.forEach(function(t){e.forEach(function(e){t.index_number===e.index_number&&n.appsConnectingMap.items.push({old_item_id:t.item_id,new_item_id:e.item_id})})})}},{key:"_searchOldAppId",value:function(e,t){var n=0;return t.forEach(function(t){t.new_app_id===e&&(n=t.old_app_id)}),n}},{key:"createApps",value:function(e,t){var n=this,i=this,r={step_size:100/(3*e.apps.length),apps:[]};return new Promise(function(o){var a={},c=[],u=[];e.apps.forEach(function(l){i.gudhub.getApp(l).then(function(l){t&&t.call(n,"GET APP: ".concat(l.app_name," (App steps)"));var f=JSON.parse(JSON.stringify(l));a[f.app_id]=f,r.apps.push(f.icon);var s=i.prepareAppTemplate(f);s.app_name=s.app_name+" New",s.privacy=1,e.data_to_change&&(e.data_to_change.name&&(s.app_name=e.data_to_change.name),e.data_to_change.icon&&(s.icon=e.data_to_change.icon)),i.resetViewsIds(s),i.gudhub.createNewApp(s).then(function(r){t&&t.call(n,"CREATE NEW APP: ".concat(l.app_name," (App steps)")),c.push(r),i.mapApp(f,r,i.appsConnectingMap),e.apps.length==c.length&&(i.connectApps(c,i.appsConnectingMap,a),c.forEach(function(r){i.gudhub.updateApp(r).then(function(i){t&&t.call(n,"UPDATE APP: ".concat(l.app_name," (App steps)")),u.push(i),e.apps.length==u.length&&o(u)})}))})})})})}},{key:"mapApp",value:function(e,t,n){n.apps.push({old_app_id:e.app_id,new_app_id:t.app_id,old_view_init:e.view_init,new_view_init:t.view_init}),e.field_list.forEach(function(e){t.field_list.forEach(function(t){e.name_space==t.name_space&&n.fields.push({name_space:e.name_space,old_field_id:e.field_id,new_field_id:t.field_id})})}),e.views_list.forEach(function(e){t.views_list.forEach(function(t){e.name==t.name&&n.views.push({name:e.name,old_view_id:e.view_id,new_view_id:t.view_id})})})}},{key:"crawling",value:function(e,t){var n=null===e?[]:Object.keys(e),i=this;n.length>0&&n.forEach(function(n){var r=e[n];void 0!==r&&"string"!=typeof e&&(t(n,r,e),i.crawling(r,t))})}},{key:"resetViewsIds",value:function(e){e.view_init=0,this.crawling(e.views_list,function(e,t,n){"view_id"!=e&&"container_id"!=e||(n[e]=0)})}},{key:"connectApps",value:function(e,t,n){var i=this;return e.forEach(function(e){t.apps.forEach(function(n){e.view_init===n.new_view_init&&t.views.forEach(function(t){n.old_view_init===t.old_view_id&&(e.view_init=t.new_view_id)})}),i.crawling(e.field_list,function(r,o,a){if(-1!==r.indexOf("field_id")||-1!==r.indexOf("FieldId")||-1!==r.indexOf("destination_field")){var c=String(o).split(","),u=[];t.fields.forEach(function(e){c.forEach(function(t){t==e.old_field_id&&u.push(e.new_field_id)})}),u.length&&(a[r]=u.join(","))}if(-1==r.indexOf("app_id")&&-1==r.indexOf("AppId")&&-1==r.indexOf("destination_app")||t.apps.forEach(function(e){o==e.old_app_id&&(a[r]=e.new_app_id)}),-1!==r.indexOf("view_id")&&t.views.forEach(function(e){o==e.old_view_id&&(a[r]=e.new_view_id)}),-1!==r.indexOf("src")&&isFinite(o)){var l=t.apps.find(function(t){return t.new_app_id===e.app_id}).old_app_id,f=i.findPath(n[l].views_list,"container_id",o);a[r]="".concat(i.getValueByPath(e.views_list,f,"container_id"))}})}),e}},{key:"getValueByPath",value:function(e,t,n){var i=e;return t.split(".").forEach(function(e){i=i[e]}),i[n]}},{key:"findPath",value:function(e,t,n){var i=!1,r=!1,o=[];return this.crawling(e,function(e,c,u){r&&o.reverse().forEach(function(e){r&&(e.delete=!0,e.parent===u&&(r=!1,(o=o.filter(function(e){return!e.delete})).reverse()))}),i||("object"===a(u[e])&&o.push({prop:e,parent:u}),c==n&&t===e?i=!0:Object.keys(u).pop()===e&&"object"!==a(u[e])&&(r=!0))}),o.map(function(e){return e.prop}).join(".")}},{key:"prepareAppTemplate",value:function(e){var t=JSON.parse(JSON.stringify(e));return this.crawling(t.views_list,function(e,t,n){"element_id"==e&&(n.element_id=-Number(t),n.create_element=-Number(t))}),t.field_list.forEach(function(e){e.create_field=-Number(e.field_id),e.element_id=-Number(e.field_id),e.field_id=-Number(e.field_id),e.field_value=""}),t.items_list=[],delete t.app_id,delete t.icon.id,delete t.group_id,delete t.trash,delete t.last_update,delete t.file_list,t}}]),t}();exports.default=p;
175
175
  },{}],"E7yc":[function(require,module,exports) {
176
176
  "use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e){return o(e)||i(e)||r(e)||n()}function n(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function r(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function i(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function o(e){if(Array.isArray(e))return u(e)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,c(r.key),r)}}function a(e,t,n){return t&&f(e.prototype,t),n&&f(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(t){var n=s(t,"string");return"symbol"===e(n)?n:String(n)}function s(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,n||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileHelper=void 0;var p=function(){function e(t){l(this,e),this.gudhub=t}return a(e,[{key:"fileInstallerHelper",value:function(e,n,r){var i=this;return new Promise(function(o){var u=[[]],l=Promise.resolve(),f=[];n.forEach(function(t){var n=t.item_id,i=t.fields.find(function(e){return e.element_id===r});i&&i.field_value&&i.field_value.split(".").forEach(function(t){var i={source:t,destination:{app_id:e,item_id:n,element_id:r}};10!==u[u.length-1].length?u[u.length-1].push(i):u.push([i])})}),u.forEach(function(e){l=l.then(function(){return i.gudhub.duplicateFile(e)}).then(function(e){f=[].concat(t(f),t(e))})}),l.then(function(){n.forEach(function(e){var t=e.item_id,n=e.fields.find(function(e){return e.element_id===r});n&&n.field_value&&(n.field_value="",f.forEach(function(e){e.item_id===t&&(n.field_value=n.field_value.split(",").filter(function(e){return e}).concat(e.file_id).join(","))}))}),o()})})}}]),e}();exports.FileHelper=p;
177
177
  },{}],"AefJ":[function(require,module,exports) {
178
178
  "use strict";function e(e,t){return JSON.stringify(e)===JSON.stringify(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compareObjects=e;
179
+ },{}],"ndUf":[function(require,module,exports) {
180
+ "use strict";function t(r){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(r)}function r(){r=function(){return e};var e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(A){l=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=r&&r.prototype instanceof y?r:y,a=Object.create(o.prototype),c=new _(n||[]);return i(a,"_invoke",{value:E(t,e,c)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(A){return{type:"throw",arg:A}}}e.wrap=s;var p={};function y(){}function v(){}function d(){}var m={};l(m,c,function(){return this});var g=Object.getPrototypeOf,b=g&&g(g(k([])));b&&b!==n&&o.call(b,c)&&(m=b);var w=d.prototype=y.prototype=Object.create(m);function x(t){["next","throw","return"].forEach(function(r){l(t,r,function(t){return this._invoke(r,t)})})}function L(r,e){var n;i(this,"_invoke",{value:function(i,a){function c(){return new e(function(n,c){!function n(i,a,c,u){var f=h(r[i],r,a);if("throw"!==f.type){var l=f.arg,s=l.value;return s&&"object"==t(s)&&o.call(s,"__await")?e.resolve(s.__await).then(function(t){n("next",t,c,u)},function(t){n("throw",t,c,u)}):e.resolve(s).then(function(t){l.value=t,c(l)},function(t){return n("throw",t,c,u)})}u(f.arg)}(i,a,n,c)})}return n=n?n.then(c,c):c()}})}function E(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var c=j(a,e);if(c){if(c===p)continue;return c}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var u=h(t,r,e);if("normal"===u.type){if(n=e.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(n="completed",e.method="throw",e.arg=u.arg)}}}function j(t,r){var e=r.method,n=t.iterator[e];if(void 0===n)return r.delegate=null,"throw"===e&&t.iterator.return&&(r.method="return",r.arg=void 0,j(t,r),"throw"===r.method)||"return"!==e&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+e+"' method")),p;var o=h(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,p;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,p):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}function O(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function S(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function k(t){if(t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function r(){for(;++e<t.length;)if(o.call(t,e))return r.value=t[e],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:P}}function P(){return{value:void 0,done:!0}}return v.prototype=d,i(w,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:v,configurable:!0}),v.displayName=l(d,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===v||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,l(t,f,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(L.prototype),l(L.prototype,u,function(){return this}),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new L(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},x(w),l(w,f,"Generator"),l(w,c,function(){return this}),l(w,"toString",function(){return"[object Generator]"}),e.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=k,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var c=o.call(i,"catchLoc"),u=o.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),p},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),S(e),p}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;S(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:k(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),p}},e}function e(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=n(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return c=t.done,t},e:function(t){u=!0,a=t},f:function(){try{c||null==e.return||e.return()}finally{if(u)throw a}}}}function n(t,r){if(t){if("string"==typeof t)return o(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,r):void 0}}function o(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function i(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(f){return void e(f)}c.done?r(u):Promise.resolve(u).then(n,o)}function a(t){return function(){var r=this,e=arguments;return new Promise(function(n,o){var a=t.apply(r,e);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)})}}function c(t){return u.apply(this,arguments)}function u(){return(u=a(r().mark(function t(n){var o,i,a,u,l;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(n);case 2:o=!0,i=e(n),t.prev=4,i.s();case 6:if((a=i.n()).done){t.next=19;break}return u=a.value,t.next=10,f(u);case 10:if("pending"!==(l=t.sent).state){t.next=14;break}return o=!1,t.abrupt("break",19);case 14:if("rejected"!==l.state){t.next=17;break}throw l.reason;case 17:t.next=6;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(4),i.e(t.t0);case 24:return t.prev=24,i.f(),t.finish(24);case 27:if(!o){t.next=29;break}return t.abrupt("return",!0);case 29:return t.abrupt("return",c(n));case 30:case"end":return t.stop()}},t,null,[[4,21,24,27]])}))).apply(this,arguments)}function f(t){var r={state:"pending"};return Promise.race([t,r]).then(function(t){return t===r?t:{state:"resolved",value:t}},function(t){return{state:"rejected",reason:t}})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.dynamicPromiseAll=c;
179
181
  },{}],"mWlG":[function(require,module,exports) {
180
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utils=void 0;var e=require("./filter/filterPreparation.js"),t=g(require("./filter/filter.js")),r=require("./json_to_items/json_to_items.js"),n=require("./merge_compare_items/merge_compare_items.js"),o=require("./filter/group.js"),i=require("./filter/utils.js"),a=g(require("./populate_items/populate_items.js")),u=require("./get_date/get_date.js"),c=require("./merge_objects/merge_objects.js"),s=require("./merge_chunks/merge_chunks.js"),l=require("./nested_list/nested_list.js"),f=g(require("./MergeFields/MergeFields.js")),p=g(require("./ItemsSelection/ItemsSelection.js")),h=require("./compare_items_lists_worker/compare_items_lists.worker.js"),v=require("./json_constructor/json_constructor.js"),m=g(require("./AppsTemplateService/AppsTemplateService.js")),y=require("./FIleHelper/FileHelper.js"),d=require("./compareObjects/compareObjects.js");function g(e){return e&&e.__esModule?e:{default:e}}function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function b(){b=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(F){c=function(e,t,r){return e[t]=r}}function s(e,t,r,o){var i=t&&t.prototype instanceof p?t:p,a=Object.create(i.prototype),u=new x(o||[]);return n(a,"_invoke",{value:_(e,r,u)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(F){return{type:"throw",arg:F}}}e.wrap=s;var f={};function p(){}function h(){}function v(){}var m={};c(m,i,function(){return this});var y=Object.getPrototypeOf,d=y&&y(y(E([])));d&&d!==t&&r.call(d,i)&&(m=d);var g=v.prototype=p.prototype=Object.create(m);function j(e){["next","throw","return"].forEach(function(t){c(e,t,function(e){return this._invoke(t,e)})})}function k(e,t){var o;n(this,"_invoke",{value:function(n,i){function a(){return new t(function(o,a){!function n(o,i,a,u){var c=l(e[o],e,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==w(f)&&r.call(f,"__await")?t.resolve(f.__await).then(function(e){n("next",e,a,u)},function(e){n("throw",e,a,u)}):t.resolve(f).then(function(e){s.value=e,a(s)},function(e){return n("throw",e,a,u)})}u(c.arg)}(n,i,o,a)})}return o=o?o.then(a,a):a()}})}function _(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return O()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=L(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function L(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,L(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=l(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,f;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function E(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:h,configurable:!0}),h.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},j(k.prototype),c(k.prototype,a,function(){return this}),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})},j(g),c(g,u,"Generator"),c(g,i,function(){return this}),c(g,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=E,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function j(e){return S(e)||L(e)||_(e)||k()}function k(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(e,t){if(e){if("string"==typeof e)return I(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}function L(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function S(e){if(Array.isArray(e))return I(e)}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function x(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(s){return void r(s)}u.done?t(c):Promise.resolve(c).then(n,o)}function E(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){x(i,n,o,a,u,"next",e)}function u(e){x(i,n,o,a,u,"throw",e)}a(void 0)})}}function O(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,A(n.key),n)}}function T(e,t,r){return t&&F(e.prototype,t),r&&F(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function A(e){var t=q(e,"string");return"symbol"===w(t)?t:String(t)}function q(e,t){if("object"!==w(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==w(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var P=function(){function g(e){O(this,g),this.gudhub=e,this.MergeFields=new f.default(e),this.ItemsSelection=new p.default(e),this.AppsTemplateService=new m.default(e),this.FileHelper=new y.FileHelper(e)}return T(g,[{key:"prefilter",value:function(t,r,n,o){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return(0,e.filterPreparation)(t,r,n,o,this.gudhub.storage,this.gudhub.pipeService,i)}},{key:"filter",value:function(e,r){return(0,t.default)(e,r)}},{key:"group",value:function(e,t){return(0,o.group)(e,t)}},{key:"getFilteredItems",value:function(){var e=E(b().mark(function e(){var t,r,n,o,a,u,c,s,l,f,p,h=arguments;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=h.length>0&&void 0!==h[0]?h[0]:[],r=h.length>1&&void 0!==h[1]?h[1]:[],n=h.length>2?h[2]:void 0,o=h.length>3?h[3]:void 0,a=h.length>4?h[4]:void 0,u=h.length>5&&void 0!==h[5]?h[5]:"",c=h.length>6?h[6]:void 0,s=h.length>7?h[7]:void 0,e.next=10,this.prefilter(r,n,o,a);case 10:return l=e.sent,f=this.filter(t,[].concat(j(r),j(l))),p=this.group(u,f),e.abrupt("return",p.filter(function(e){return!c||1===(0,i.searchValue)([e],c).length}).filter(function(e){return!s||1===(0,i.searchValue)([e],s).length}));case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"jsonToItems",value:function(e,t){return(0,r.jsonToItems)(e,t)}},{key:"getDate",value:function(e){return(0,u.getDate)(e)}},{key:"checkRecurringDate",value:function(e,t){return(0,u.checkRecurringDate)(e,t)}},{key:"populateItems",value:function(e,t,r){return(0,a.default)(e,t,r)}},{key:"populateWithDate",value:function(e,t){return(0,u.populateWithDate)(e,t)}},{key:"populateWithItemRef",value:function(e,t,r,o,i,a){return(0,n.populateWithItemRef)(e,t,r,o,i,a)}},{key:"compareItems",value:function(e,t,r){return(0,n.compareItems)(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return(0,n.mergeItems)(e,t,r)}},{key:"mergeObjects",value:function(e,t,r){return(0,c.mergeObjects)(e,t,r)}},{key:"makeNestedList",value:function(e,t,r,n,o){return(0,l.makeNestedList)(e,t,r,n,o)}},{key:"mergeChunks",value:function(e){return(0,s.mergeChunks)(e)}},{key:"mergeFieldLists",value:function(e,t){return this.MergeFields.mergeFieldLists(e,t)}},{key:"createFieldsListToView",value:function(e,t){return this.MergeFields.createFieldsListToView(e,t)}},{key:"createFieldsListToViewWithDataType",value:function(e,t){return this.MergeFields.createFieldsListToViewWithDataType(e,t)}},{key:"selectItems",value:function(e,t){return this.ItemsSelection.selectItems(e,t)}},{key:"getSelectedItems",value:function(e){return this.ItemsSelection.getSelectedItems(e)}},{key:"clearSelectedItems",value:function(e){return this.ItemsSelection.clearSelectedItems(e)}},{key:"isItemSelected",value:function(e,t){return this.ItemsSelection.isItemSelected(e,t)}},{key:"jsonConstructor",value:function(e,t,r,n){return(0,v.compiler)(e,t,this,r,n)}},{key:"fileInstallerHelper",value:function(e,t,r){return this.FileHelper.fileInstallerHelper(e,t,r)}},{key:"createAppsFromTemplate",value:function(e,t,r){return this.AppsTemplateService.createAppsFromTemplate(e,t,r)}},{key:"createApps",value:function(e){return this.AppsTemplateService.createApps(e)}},{key:"createItems",value:function(e,t){return this.AppsTemplateService.createItems(e,t)}},{key:"compareObjects",value:function(e,t){return(0,d.compareObjects)(e,t)}},{key:"compareAppsItemsLists",value:function(e,t,r){var n=new Blob([(0,h.compare_items_lists_Worker)()],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.worker.postMessage({items_list1:e,items_list2:t}),this.worker.addEventListener("message",function(e){var t=e.data.diff;r(t)})}}]),g}();exports.Utils=P;
181
- },{"./filter/filterPreparation.js":"DvAj","./filter/filter.js":"mbGN","./json_to_items/json_to_items.js":"UCDv","./merge_compare_items/merge_compare_items.js":"xDLX","./filter/group.js":"VgUi","./filter/utils.js":"zsiC","./populate_items/populate_items.js":"EzAv","./get_date/get_date.js":"VzfS","./merge_objects/merge_objects.js":"EE1j","./merge_chunks/merge_chunks.js":"AMYJ","./nested_list/nested_list.js":"S7Iy","./MergeFields/MergeFields.js":"vno1","./ItemsSelection/ItemsSelection.js":"DfIi","./compare_items_lists_worker/compare_items_lists.worker.js":"xR4c","./json_constructor/json_constructor.js":"nKaW","./AppsTemplateService/AppsTemplateService.js":"zqOZ","./FIleHelper/FileHelper.js":"E7yc","./compareObjects/compareObjects.js":"AefJ"}],"rK64":[function(require,module,exports) {
182
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utils=void 0;var e=require("./filter/filterPreparation.js"),t=w(require("./filter/filter.js")),r=require("./json_to_items/json_to_items.js"),n=require("./merge_compare_items/merge_compare_items.js"),i=require("./filter/group.js"),o=require("./filter/utils.js"),a=w(require("./populate_items/populate_items.js")),u=require("./get_date/get_date.js"),c=require("./merge_objects/merge_objects.js"),s=require("./merge_chunks/merge_chunks.js"),l=require("./nested_list/nested_list.js"),f=w(require("./MergeFields/MergeFields.js")),p=w(require("./ItemsSelection/ItemsSelection.js")),h=require("./compare_items_lists_worker/compare_items_lists.worker.js"),m=require("./json_constructor/json_constructor.js"),v=w(require("./AppsTemplateService/AppsTemplateService.js")),y=require("./FIleHelper/FileHelper.js"),d=require("./compareObjects/compareObjects.js"),g=require("./dynamicPromiseAll/dynamicPromiseAll.js");function w(e){return e&&e.__esModule?e:{default:e}}function b(e){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function j(){j=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(F){c=function(e,t,r){return e[t]=r}}function s(e,t,r,i){var o=t&&t.prototype instanceof p?t:p,a=Object.create(o.prototype),u=new x(i||[]);return n(a,"_invoke",{value:_(e,r,u)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(F){return{type:"throw",arg:F}}}e.wrap=s;var f={};function p(){}function h(){}function m(){}var v={};c(v,o,function(){return this});var y=Object.getPrototypeOf,d=y&&y(y(E([])));d&&d!==t&&r.call(d,o)&&(v=d);var g=m.prototype=p.prototype=Object.create(v);function w(e){["next","throw","return"].forEach(function(t){c(e,t,function(e){return this._invoke(t,e)})})}function k(e,t){var i;n(this,"_invoke",{value:function(n,o){function a(){return new t(function(i,a){!function n(i,o,a,u){var c=l(e[i],e,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==b(f)&&r.call(f,"__await")?t.resolve(f.__await).then(function(e){n("next",e,a,u)},function(e){n("throw",e,a,u)}):t.resolve(f).then(function(e){s.value=e,a(s)},function(e){return n("throw",e,a,u)})}u(c.arg)}(n,o,i,a)})}return i=i?i.then(a,a):a()}})}function _(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=L(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function L(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,L(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function E(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=m,n(g,"constructor",{value:m,configurable:!0}),n(m,"constructor",{value:h,configurable:!0}),h.displayName=c(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},w(k.prototype),c(k.prototype,a,function(){return this}),e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new k(s(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})},w(g),c(g,u,"Generator"),c(g,o,function(){return this}),c(g,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=E,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function k(e){return I(e)||S(e)||L(e)||_()}function _(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function L(e,t){if(e){if("string"==typeof e)return x(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}function S(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(e){if(Array.isArray(e))return x(e)}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E(e,t,r,n,i,o,a){try{var u=e[o](a),c=u.value}catch(s){return void r(s)}u.done?t(c):Promise.resolve(c).then(n,i)}function O(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){E(o,n,i,a,u,"next",e)}function u(e){E(o,n,i,a,u,"throw",e)}a(void 0)})}}function F(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function A(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,P(n.key),n)}}function T(e,t,r){return t&&A(e.prototype,t),r&&A(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function P(e){var t=q(e,"string");return"symbol"===b(t)?t:String(t)}function q(e,t){if("object"!==b(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var N=function(){function w(e){F(this,w),this.gudhub=e,this.MergeFields=new f.default(e),this.ItemsSelection=new p.default(e),this.AppsTemplateService=new v.default(e),this.FileHelper=new y.FileHelper(e)}return T(w,[{key:"prefilter",value:function(t,r,n,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return(0,e.filterPreparation)(t,r,n,i,this.gudhub.storage,this.gudhub.pipeService,o)}},{key:"filter",value:function(e,r){return(0,t.default)(e,r)}},{key:"group",value:function(e,t){return(0,i.group)(e,t)}},{key:"getFilteredItems",value:function(){var e=O(j().mark(function e(){var t,r,n,i,a,u,c,s,l,f,p,h=arguments;return j().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=h.length>0&&void 0!==h[0]?h[0]:[],r=h.length>1&&void 0!==h[1]?h[1]:[],n=h.length>2?h[2]:void 0,i=h.length>3?h[3]:void 0,a=h.length>4?h[4]:void 0,u=h.length>5&&void 0!==h[5]?h[5]:"",c=h.length>6?h[6]:void 0,s=h.length>7?h[7]:void 0,e.next=10,this.prefilter(r,n,i,a);case 10:return l=e.sent,f=this.filter(t,[].concat(k(r),k(l))),p=this.group(u,f),e.abrupt("return",p.filter(function(e){return!c||1===(0,o.searchValue)([e],c).length}).filter(function(e){return!s||1===(0,o.searchValue)([e],s).length}));case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"jsonToItems",value:function(e,t){return(0,r.jsonToItems)(e,t)}},{key:"getDate",value:function(e){return(0,u.getDate)(e)}},{key:"checkRecurringDate",value:function(e,t){return(0,u.checkRecurringDate)(e,t)}},{key:"populateItems",value:function(e,t,r){return(0,a.default)(e,t,r)}},{key:"populateWithDate",value:function(e,t){return(0,u.populateWithDate)(e,t)}},{key:"populateWithItemRef",value:function(e,t,r,i,o,a){return(0,n.populateWithItemRef)(e,t,r,i,o,a)}},{key:"compareItems",value:function(e,t,r){return(0,n.compareItems)(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return(0,n.mergeItems)(e,t,r)}},{key:"mergeObjects",value:function(e,t,r){return(0,c.mergeObjects)(e,t,r)}},{key:"makeNestedList",value:function(e,t,r,n,i){return(0,l.makeNestedList)(e,t,r,n,i)}},{key:"mergeChunks",value:function(e){return(0,s.mergeChunks)(e)}},{key:"mergeFieldLists",value:function(e,t){return this.MergeFields.mergeFieldLists(e,t)}},{key:"createFieldsListToView",value:function(e,t){return this.MergeFields.createFieldsListToView(e,t)}},{key:"createFieldsListToViewWithDataType",value:function(e,t){return this.MergeFields.createFieldsListToViewWithDataType(e,t)}},{key:"selectItems",value:function(e,t){return this.ItemsSelection.selectItems(e,t)}},{key:"getSelectedItems",value:function(e){return this.ItemsSelection.getSelectedItems(e)}},{key:"clearSelectedItems",value:function(e){return this.ItemsSelection.clearSelectedItems(e)}},{key:"isItemSelected",value:function(e,t){return this.ItemsSelection.isItemSelected(e,t)}},{key:"jsonConstructor",value:function(e,t,r,n){return(0,m.compiler)(e,t,this,r,n)}},{key:"fileInstallerHelper",value:function(e,t,r){return this.FileHelper.fileInstallerHelper(e,t,r)}},{key:"createAppsFromTemplate",value:function(e,t,r){return this.AppsTemplateService.createAppsFromTemplate(e,t,r)}},{key:"createApps",value:function(e){return this.AppsTemplateService.createApps(e)}},{key:"createItems",value:function(e,t){return this.AppsTemplateService.createItems(e,t)}},{key:"compareObjects",value:function(e,t){return(0,d.compareObjects)(e,t)}},{key:"compareAppsItemsLists",value:function(e,t,r){var n=new Blob([(0,h.compare_items_lists_Worker)()],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.worker.postMessage({items_list1:e,items_list2:t}),this.worker.addEventListener("message",function(e){var t=e.data.diff;r(t)})}},{key:"dynamicPromiseAll",value:function(e){return(0,g.dynamicPromiseAll)(e)}}]),w}();exports.Utils=N;
183
+ },{"./filter/filterPreparation.js":"DvAj","./filter/filter.js":"mbGN","./json_to_items/json_to_items.js":"UCDv","./merge_compare_items/merge_compare_items.js":"xDLX","./filter/group.js":"VgUi","./filter/utils.js":"zsiC","./populate_items/populate_items.js":"EzAv","./get_date/get_date.js":"VzfS","./merge_objects/merge_objects.js":"EE1j","./merge_chunks/merge_chunks.js":"AMYJ","./nested_list/nested_list.js":"S7Iy","./MergeFields/MergeFields.js":"vno1","./ItemsSelection/ItemsSelection.js":"DfIi","./compare_items_lists_worker/compare_items_lists.worker.js":"xR4c","./json_constructor/json_constructor.js":"nKaW","./AppsTemplateService/AppsTemplateService.js":"zqOZ","./FIleHelper/FileHelper.js":"E7yc","./compareObjects/compareObjects.js":"AefJ","./dynamicPromiseAll/dynamicPromiseAll.js":"ndUf"}],"rK64":[function(require,module,exports) {
182
184
  "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(){e=function(){return r};var r={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(P){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof v?e:v,a=Object.create(o.prototype),u=new O(n||[]);return i(a,"_invoke",{value:L(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(P){return{type:"throw",arg:P}}}r.wrap=h;var p={};function v(){}function y(){}function d(){}var g={};f(g,u,function(){return this});var m=Object.getPrototypeOf,w=m&&m(m(_([])));w&&w!==n&&o.call(w,u)&&(g=w);var b=d.prototype=v.prototype=Object.create(g);function x(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function k(e,r){var n;i(this,"_invoke",{value:function(i,a){function u(){return new r(function(n,u){!function n(i,a,u,s){var c=l(e[i],e,a);if("throw"!==c.type){var f=c.arg,h=f.value;return h&&"object"==t(h)&&o.call(h,"__await")?r.resolve(h.__await).then(function(t){n("next",t,u,s)},function(t){n("throw",t,u,s)}):r.resolve(h).then(function(t){f.value=t,u(f)},function(t){return n("throw",t,u,s)})}s(c.arg)}(i,a,n,u)})}return n=n?n.then(u,u):u()}})}function L(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return j()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=S(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=l(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===p)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}function S(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,S(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function U(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function _(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(o.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:j}}function j(){return{value:void 0,done:!0}}return y.prototype=d,i(b,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:y,configurable:!0}),y.displayName=f(d,c,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,f(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},r.awrap=function(t){return{__await:t}},x(k.prototype),f(k.prototype,s,function(){return this}),r.AsyncIterator=k,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},x(b),f(b,c,"Generator"),f(b,u,function(){return this}),f(b,"toString",function(){return"[object Generator]"}),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=_,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(U),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=o.call(i,"catchLoc"),s=o.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),U(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;U(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},r}function r(t,e,r,n,o,i,a){try{var u=t[i](a),s=u.value}catch(c){return void r(c)}u.done?e(s):Promise.resolve(s).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var a=t.apply(e,n);function u(t){r(a,o,i,u,s,"next",t)}function s(t){r(a,o,i,u,s,"throw",t)}u(void 0)})}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function a(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(e){var r=s(e,"string");return"symbol"===t(r)?r:String(r)}function s(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=void 0;var c=function(){function t(e,r){o(this,t),this.req=e,this.storage=r}return a(t,[{key:"login",value:function(){var t=n(e().mark(function t(){var r,n,o,i,a=arguments;return e().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>0&&void 0!==a[0]?a[0]:{},n=r.username,o=r.password,t.next=3,this.req.axiosRequest({method:"POST",url:"".concat(this.req.root,"/auth/login"),form:{username:n,password:o}});case 3:return i=t.sent,this.storage.updateUser(i),t.abrupt("return",i);case 6:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"logout",value:function(t){return this.req.post({url:"/auth/logout",form:{token:t}})}},{key:"signup",value:function(t){return this.req.axiosRequest({method:"POST",url:"".concat(this.req.root,"/auth/singup"),form:{user:JSON.stringify(t)}})}},{key:"getUsersList",value:function(t){return this.req.get({url:"/auth/userlist",params:{keyword:t}})}},{key:"updateUserApi",value:function(t){return this.req.post({url:"/auth/updateuser",form:{user:JSON.stringify(t)}})}},{key:"updateToken",value:function(t){return this.req.axiosRequest({method:"POST",url:"".concat(this.req.root,"/auth/login"),form:{auth_key:t}})}},{key:"avatarUploadApi",value:function(t){return this.req.post({url:"/auth/avatar-upload",form:{image:t}})}},{key:"getUserByIdApi",value:function(t){return this.req.get({url:"/auth/getuserbyid",params:{id:t}})}},{key:"getVersion",value:function(){return this.req.get({url:"/version"})}},{key:"getUserFromStorage",value:function(t){return this.storage.getUsersList().find(function(e){return e.user_id==t})}},{key:"saveUserToStorage",value:function(t){var e=this.storage.getUsersList(),r=e.find(function(e){return e.user_id==t.user_id});return r||(e.push(t),t)}},{key:"getUserById",value:function(){var t=n(e().mark(function t(r){var n,o;return e().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.getUserFromStorage(r)){t.next=9;break}return t.next=4,this.getUserByIdApi(r);case 4:if(o=t.sent){t.next=7;break}return t.abrupt("return",null);case 7:(n=this.getUserFromStorage(r))||(this.saveUserToStorage(o),n=o);case 9:return t.abrupt("return",n);case 10:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"getToken",value:function(){var t=n(e().mark(function t(){var r,n,o,i;return e().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=new Date(this.storage.getUser().expirydate),n=new Date,o=this.storage.getUser().accesstoken,!(r<n)&&o){t.next=9;break}return t.next=6,this.updateToken(this.storage.getUser().auth_key);case 6:i=t.sent,this.storage.updateUser(i),o=i.accesstoken;case 9:return t.abrupt("return",o);case 10:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"updateUser",value:function(){var t=n(e().mark(function t(r){var n;return e().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.updateUserApi(r);case 2:return n=t.sent,this.storage.updateUser(n),t.abrupt("return",n);case 5:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"updateAvatar",value:function(){var t=n(e().mark(function t(r){var n;return e().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.avatarUploadApi(r);case 2:return n=t.sent,this.storage.updateUser(n),t.abrupt("return",n);case 5:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()}]),t}();exports.Auth=c;
183
185
  },{}],"UV2u":[function(require,module,exports) {
184
186
  "use strict";function e(o){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.IS_WEB=void 0;var o=!["undefined"==typeof window?"undefined":e(window),"undefined"==typeof document?"undefined":e(document)].includes("undefined");exports.IS_WEB=o;