@gudhub/core 1.1.73 → 1.1.74

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.
@@ -25,7 +25,8 @@ export class DocumentManager {
25
25
  }
26
26
 
27
27
  emitDocumentInsert(data) {
28
- this.pipeService.emit("gh_document_insert_one", { app_id: data.app_id, item_id: data.item_id, element_id: data.element_id }, JSON.parse(data.data));
28
+ const dataToEmit = typeof data.data === "string" ? JSON.parse(data.data) : data.data;
29
+ this.pipeService.emit("gh_document_insert_one", { app_id: data.app_id, item_id: data.item_id, element_id: data.element_id }, dataToEmit);
29
30
  }
30
31
 
31
32
  getDocument(documentAddress) {
@@ -313,6 +313,8 @@ class ItemsFilter {
313
313
 
314
314
  filter(filters, items) {
315
315
 
316
+ const allFiltersAndStrategy = this.checkIfAllFiltersHaveAndStrategy(filters);
317
+
316
318
  const filteredItems = [];
317
319
  const activeFilters = filters.filter(function (filter) {
318
320
  return filter.valuesArray.length;
@@ -352,6 +354,12 @@ class ItemsFilter {
352
354
  default:
353
355
  result = result && filterChecker.check(filterAggregate);
354
356
  }
357
+
358
+ // Needed for performance optimization
359
+ // We don't need to check other filters if we already know that result is false in case of 'and' strategy
360
+ if(!result && allFiltersAndStrategy) {
361
+ break;
362
+ }
355
363
 
356
364
  }
357
365
 
@@ -368,4 +376,14 @@ class ItemsFilter {
368
376
  }
369
377
 
370
378
  }
379
+
380
+ checkIfAllFiltersHaveAndStrategy(filters) {
381
+ return filters.every((filter) => {
382
+ if(!filter.boolean_strategy || filter.boolean_strategy == 'and') {
383
+ return true;
384
+ }
385
+ return false;
386
+ });
387
+ }
388
+
371
389
  }
@@ -92,6 +92,49 @@ import { app_8263 } from '../../../fake_server/fake_server_data/app_8263.js';
92
92
  filter[0].valuesArray[1].should.equal(true);
93
93
 
94
94
  });
95
+
96
+ it('CHECK FILTER PERFORMANCE / filter with and strategy should run in less than 200ms', async () => {
97
+
98
+ const filters = [
99
+ {
100
+ "field_id": 96606,
101
+ "data_type": "text",
102
+ "valuesArray": [
103
+ "Oklahoma"
104
+ ],
105
+ "search_type": "contain_or",
106
+ "boolean_strategy": "and",
107
+ "selected_search_option_variable": "Value"
108
+ },
109
+
110
+ {
111
+ "field_id": 96608,
112
+ "data_type": "phone",
113
+ "valuesArray": [
114
+ "8453"
115
+ ],
116
+ "search_type": "contain_or",
117
+ "boolean_strategy": "and",
118
+ "selected_search_option_variable": "Value"
119
+ }
120
+ ];
121
+
122
+ let totalTime = 0;
123
+
124
+ const iterationsCount = 1000;
125
+
126
+ for (let i = 0; i < iterationsCount; i++) {
127
+ const startTime = new Date().getTime();
128
+ gudhub.filter(app_8263.items_list, filters);
129
+ totalTime += new Date().getTime() - startTime;
130
+ }
131
+
132
+ // Ideally, on my laptop with i7-9750H 2.60 it takes 60ms
133
+ totalTime.should.be.below(200);
134
+
135
+ console.log('Average time for filter with and strategy: ', totalTime);
136
+
137
+ });
95
138
 
96
139
  });
97
140
 
@@ -26,6 +26,20 @@ export function compiler(scheme, item, util, variables, appId) {
26
26
  value = await getFieldValue(scheme, item, appId);
27
27
  }
28
28
 
29
+ if (typeof scheme === "object" && typeof scheme.type === 'undefined') {
30
+ const result = {};
31
+
32
+ for (const key in scheme) {
33
+ if (scheme.hasOwnProperty(key)) {
34
+ const element = scheme[key];
35
+ const res = await schemeCompiler(element, item, appId);
36
+ result[key] = res[element.property_name];
37
+ }
38
+ }
39
+
40
+ return result;
41
+ }
42
+
29
43
  return { [scheme.property_name]: value };
30
44
  }
31
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.1.73",
3
+ "version": "1.1.74",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -120,7 +120,7 @@ var t="function"==typeof Map&&Map.prototype,e=Object.getOwnPropertyDescriptor&&t
120
120
  },{}],"zsiC":[function(require,module,exports) {
121
121
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDate=c,exports.getDistanceFromLatLonInKm=l,exports.isSimilarStrings=g,exports.searchValue=d;var e=t(require("fuse.js"));function t(e){return e&&e.__esModule?e:{default:e}}function r(e,t){return i(e)||u(e,t)||a(e,t)||n()}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){if(e){if("string"==typeof e)return o(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)?o(e,t):void 0}}function o(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 u(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,u,i=[],l=!0,s=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=o.call(r)).done)&&(i.push(n.value),i.length!==t);l=!0);}catch(c){s=!0,a=c}finally{try{if(!l&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(s)throw a}}return i}}function i(e){if(Array.isArray(e))return e}function l(e,t){var n=r(e.split(":"),3),a=n[0],o=n[1],u=n[2],i=r(t.split(":"),2),l=i[0],c=i[1],f=s(l-a),h=s(c-o),d=Math.sin(f/2)*Math.sin(f/2)+Math.cos(s(a))*Math.cos(s(l))*Math.sin(h/2)*Math.sin(h/2),v=6371*(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)));return Number(u)>=v}function s(e){return e*(Math.PI/180)}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.type,n=e.date,a=void 0===n?0:n,o=e.match,u=void 0===o||o,i=arguments.length>1?arguments[1]:void 0;if(!i&&t)return!1;var l=new Date,s=!0;switch(t){case"day":var c=h(a),d=h(a+1);s=c<=i&&i<d;break;case"days":if(a<0){var v=h(1);s=h(-6)<=i&&i<v}else{var g=h(),y=h(7);s=g<=i&&i<y}break;case"day_week":s=a===new Date(i).getDay();break;case"week":var w=l.getDate()-l.getDay(),b=w+(-2==a?13:6),p=r(f(l.setDate(w+7*a),(new Date).setDate(b+7*a)),2),D=p[0],m=p[1];s=D<=i&&i<=m;break;case"month":if(l.getFullYear()!==new Date(i).getFullYear())return!1;s=l.getMonth()+a===new Date(i).getMonth();break;case"year":s=l.getFullYear()+a===new Date(i).getFullYear();break;default:return!0}return u?s:!s}function f(e,t){return[new Date(e),new Date(t)]}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e).valueOf()}function d(e,t){if(e&&e.length)return t?e.filter(function(e){return e.fields.find(function(e){return e.index_value&&-1!==e.index_value.toLowerCase().indexOf(t.toLowerCase())})}):e}var v=new e.default([]);function g(e,t){return v.setCollection(t),Boolean(v.search(e).length)}
122
122
  },{"fuse.js":"jqRt"}],"mbGN":[function(require,module,exports) {
123
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=m;var e=require("./utils.js");function t(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=u(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},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 o,c=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){a=!0,o=e},f:function(){try{c||null==n.return||n.return()}finally{if(a)throw o}}}}function n(e,t){return c(e)||o(e,t)||u(e,t)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){if(e){if("string"==typeof e)return i(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)?i(e,t):void 0}}function i(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 o(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,u,i,o,c=[],a=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;a=!1}else for(;!(a=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);a=!0);}catch(f){s=!0,u=f}finally{try{if(!a&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(s)throw u}}return c}}function c(e){if(Array.isArray(e))return e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=y();return function(){var n,r=v(e);if(t){var u=v(this).constructor;n=Reflect.construct(r,arguments,u)}else n=r.apply(this,arguments);return l(this,n)}}function l(e,t){if(t&&("object"===b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(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 g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(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,d(r.key),r)}}function p(e,t,n){return t&&_(e.prototype,t),n&&_(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var t=k(e,"string");return"symbol"===b(t)?t:String(t)}function k(e,t){if("object"!==b(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function m(e,t){var n=new q;return e&&e.length?n.filter(t,e):[]}var S=function(){function t(){g(this,t)}return p(t,[{key:"changeBehavior",value:function(t){switch(t){case"contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"not_contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"not_contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"equal_or":this._checkFn=function(e,t){return!!e.length&&e.some(function(e){return t.some(function(t){return e==t})})};break;case"equal_and":this._checkFn=function(e,t){if(!e.length)return!1;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();n.has(r)&&n.delete(r)}return!n.size};break;case"not_equal_or":this._checkFn=function(e,t){if(!e.length)return!0;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(!n.has(r))return!0}return!1};break;case"not_equal_and":this._checkFn=function(e,t){for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(n.has(r))return!1}return!0};break;case"bigger":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e>t})})};break;case"lower":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e<t})})};break;case"range":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return t.start<=e&&e<t.end})})};break;case"value":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return e==t})})};break;case"search":this._checkFn=function(t,n){return n.some(function(n){return(0,e.isSimilarStrings)(n,t)})};break;case"phone_equal_or":this._checkFn=function(e,t){return!!e.length&&t.some(function(t){return e.some(function(e){return-1!==e.replace(/[^0-9]/g,"").indexOf(t.replace(/[^0-9]/g,""))})})};break;case"distance":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDistanceFromLatLonInKm)(n,t)})})};break;case"date_in":case"date_out":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDate)(n,t)})})};break;case"recurring_date":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return gudhub.checkRecurringDate(e,t)})})}}return this}},{key:"check",value:function(e){return this.changeBehavior(e.getCheckOption())._checkFn(e.getEntity(),e.getFilterValues())}}]),t}(),w=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[Number(e)]}},{key:"convertFilterValue",value:function(e){return Number(e)}}]),e}(),F=function(e){a(n,w);var t=f(n);function n(){return g(this,n),t.apply(this,arguments)}return p(n,[{key:"convertFilterValue",value:function(e){return{start:Number(e.split(":")[0]),end:Number(e.split(":")[1])}}}]),n}(),O=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return String(null!=e?e:"").toLowerCase().split(",")}},{key:"convertFilterValue",value:function(e){return 0===e?"0":String(e||"").toLowerCase()}}]),e}(),j=function(e){a(r,w);var t=f(r);function r(){return g(this,r),t.apply(this,arguments)}return p(r,[{key:"convertFilterValue",value:function(e){var t=n(e.split(":"),3),r=t[0],u=t[1],i=t[2];return{type:r,date:Number(u),match:!!Number(i)}}}]),r}(),V=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[String(Boolean(e))]}},{key:"convertFilterValue",value:function(e){return String(e)}}]),e}(),A=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[Number(e)]}},{key:"convertFilterValue",value:function(e){return String(e)}}]),e}(),P=function(){function e(){g(this,e),this._strategies={stringStrategy:new O,numberStrategy:new w,booleanStrategy:new V,rangeStrategy:new F,dateStrategy:new j,recurringDateStrategy:new A}}return p(e,[{key:"setStrategy",value:function(e){switch(this._checkOption=e,e){case"contain_or":case"contain_and":case"not_contain_or":case"not_contain_and":case"equal_or":case"equal_and":case"not_equal_or":case"not_equal_and":case"phone_equal_or":case"distance":case"search":this._currentStrategy=this._strategies.stringStrategy;break;case"bigger":case"lower":this._currentStrategy=this._strategies.numberStrategy;break;case"range":this._currentStrategy=this._strategies.rangeStrategy;break;case"date_in":case"date_out":this._currentStrategy=this._strategies.dateStrategy;break;case"value":this._currentStrategy=this._strategies.booleanStrategy;break;case"recurring_date":this._currentStrategy=this._strategies.recurringDateStrategy}return this}},{key:"setEntity",value:function(e){return this._entity=this._currentStrategy.convert(e),this}},{key:"getEntity",value:function(){return this._entity}},{key:"setFilterValues",value:function(e){var t=this,n=Array.isArray(e)?e:[e];return this._filterValues=n.map(function(e){return t._currentStrategy.convertFilterValue(e)}),this}},{key:"getFilterValues",value:function(){return this._filterValues}},{key:"getCheckOption",value:function(){return this._checkOption}}]),e}(),q=function(){function e(){g(this,e)}return p(e,[{key:"filter",value:function(e,n){var r,u=[],i=e.filter(function(e){return e.valuesArray.length}),o=t(n);try{for(o.s();!(r=o.n()).done;){for(var c=r.value,a=!0,s=function(){var e=i[f],t=c.fields.find(function(t){return e.field_id==t.field_id}),n=new P,r=new S;switch(n.setStrategy(e.search_type).setEntity(t&&null!=t.field_value?t.field_value:null).setFilterValues(e.valuesArray),e.boolean_strategy){case"and":a=a&&r.check(n);break;case"or":a=a||r.check(n);break;default:a=a&&r.check(n)}},f=0;f<i.length;f++)s();a&&u.push(c)}}catch(l){o.e(l)}finally{o.f()}return u.length||e.length&&!u.length?u:n}}]),e}();
123
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=m;var e=require("./utils.js");function t(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=u(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},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 o,c=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){a=!0,o=e},f:function(){try{c||null==n.return||n.return()}finally{if(a)throw o}}}}function n(e,t){return c(e)||o(e,t)||u(e,t)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){if(e){if("string"==typeof e)return i(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)?i(e,t):void 0}}function i(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 o(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,u,i,o,c=[],a=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;a=!1}else for(;!(a=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);a=!0);}catch(f){s=!0,u=f}finally{try{if(!a&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(s)throw u}}return c}}function c(e){if(Array.isArray(e))return e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=y();return function(){var n,r=v(e);if(t){var u=v(this).constructor;n=Reflect.construct(r,arguments,u)}else n=r.apply(this,arguments);return l(this,n)}}function l(e,t){if(t&&("object"===b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(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 g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(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,d(r.key),r)}}function p(e,t,n){return t&&_(e.prototype,t),n&&_(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var t=k(e,"string");return"symbol"===b(t)?t:String(t)}function k(e,t){if("object"!==b(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function m(e,t){var n=new q;return e&&e.length?n.filter(t,e):[]}var S=function(){function t(){g(this,t)}return p(t,[{key:"changeBehavior",value:function(t){switch(t){case"contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"not_contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"not_contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"equal_or":this._checkFn=function(e,t){return!!e.length&&e.some(function(e){return t.some(function(t){return e==t})})};break;case"equal_and":this._checkFn=function(e,t){if(!e.length)return!1;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();n.has(r)&&n.delete(r)}return!n.size};break;case"not_equal_or":this._checkFn=function(e,t){if(!e.length)return!0;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(!n.has(r))return!0}return!1};break;case"not_equal_and":this._checkFn=function(e,t){for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(n.has(r))return!1}return!0};break;case"bigger":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e>t})})};break;case"lower":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e<t})})};break;case"range":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return t.start<=e&&e<t.end})})};break;case"value":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return e==t})})};break;case"search":this._checkFn=function(t,n){return n.some(function(n){return(0,e.isSimilarStrings)(n,t)})};break;case"phone_equal_or":this._checkFn=function(e,t){return!!e.length&&t.some(function(t){return e.some(function(e){return-1!==e.replace(/[^0-9]/g,"").indexOf(t.replace(/[^0-9]/g,""))})})};break;case"distance":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDistanceFromLatLonInKm)(n,t)})})};break;case"date_in":case"date_out":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDate)(n,t)})})};break;case"recurring_date":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return gudhub.checkRecurringDate(e,t)})})}}return this}},{key:"check",value:function(e){return this.changeBehavior(e.getCheckOption())._checkFn(e.getEntity(),e.getFilterValues())}}]),t}(),w=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[Number(e)]}},{key:"convertFilterValue",value:function(e){return Number(e)}}]),e}(),F=function(e){a(n,w);var t=f(n);function n(){return g(this,n),t.apply(this,arguments)}return p(n,[{key:"convertFilterValue",value:function(e){return{start:Number(e.split(":")[0]),end:Number(e.split(":")[1])}}}]),n}(),O=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return String(null!=e?e:"").toLowerCase().split(",")}},{key:"convertFilterValue",value:function(e){return 0===e?"0":String(e||"").toLowerCase()}}]),e}(),j=function(e){a(r,w);var t=f(r);function r(){return g(this,r),t.apply(this,arguments)}return p(r,[{key:"convertFilterValue",value:function(e){var t=n(e.split(":"),3),r=t[0],u=t[1],i=t[2];return{type:r,date:Number(u),match:!!Number(i)}}}]),r}(),A=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[String(Boolean(e))]}},{key:"convertFilterValue",value:function(e){return String(e)}}]),e}(),V=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[Number(e)]}},{key:"convertFilterValue",value:function(e){return String(e)}}]),e}(),P=function(){function e(){g(this,e),this._strategies={stringStrategy:new O,numberStrategy:new w,booleanStrategy:new A,rangeStrategy:new F,dateStrategy:new j,recurringDateStrategy:new V}}return p(e,[{key:"setStrategy",value:function(e){switch(this._checkOption=e,e){case"contain_or":case"contain_and":case"not_contain_or":case"not_contain_and":case"equal_or":case"equal_and":case"not_equal_or":case"not_equal_and":case"phone_equal_or":case"distance":case"search":this._currentStrategy=this._strategies.stringStrategy;break;case"bigger":case"lower":this._currentStrategy=this._strategies.numberStrategy;break;case"range":this._currentStrategy=this._strategies.rangeStrategy;break;case"date_in":case"date_out":this._currentStrategy=this._strategies.dateStrategy;break;case"value":this._currentStrategy=this._strategies.booleanStrategy;break;case"recurring_date":this._currentStrategy=this._strategies.recurringDateStrategy}return this}},{key:"setEntity",value:function(e){return this._entity=this._currentStrategy.convert(e),this}},{key:"getEntity",value:function(){return this._entity}},{key:"setFilterValues",value:function(e){var t=this,n=Array.isArray(e)?e:[e];return this._filterValues=n.map(function(e){return t._currentStrategy.convertFilterValue(e)}),this}},{key:"getFilterValues",value:function(){return this._filterValues}},{key:"getCheckOption",value:function(){return this._checkOption}}]),e}(),q=function(){function e(){g(this,e)}return p(e,[{key:"filter",value:function(e,n){var r,u=this.checkIfAllFiltersHaveAndStrategy(e),i=[],o=e.filter(function(e){return e.valuesArray.length}),c=t(n);try{for(c.s();!(r=c.n()).done;){for(var a=r.value,s=!0,f=function(){var e=o[l],t=a.fields.find(function(t){return e.field_id==t.field_id}),n=new P,r=new S;switch(n.setStrategy(e.search_type).setEntity(t&&null!=t.field_value?t.field_value:null).setFilterValues(e.valuesArray),e.boolean_strategy){case"and":s=s&&r.check(n);break;case"or":s=s||r.check(n);break;default:s=s&&r.check(n)}if(!s&&u)return"break"},l=0;l<o.length;l++){if("break"===f())break}s&&i.push(a)}}catch(h){c.e(h)}finally{c.f()}return i.length||e.length&&!i.length?i:n}},{key:"checkIfAllFiltersHaveAndStrategy",value:function(e){return e.every(function(e){return!e.boolean_strategy||"and"==e.boolean_strategy})}}]),e}();
124
124
  },{"./utils.js":"zsiC"}],"LXWr":[function(require,module,exports) {
125
125
  "use strict";function e(e,r){var i=[],t=[];if(e.length>0?e.forEach(function(e){t.push(e)}):t=r,t.length>0){t.forEach(function(e,f){for(var n=0;n<r.length;n++)e.field_id==r[n].field_id&&(i.push(e.field_id),t[f]=gudhub.mergeObjects(r[n],e))});for(var f=0;f<r.length;f++)i.includes(r[f].field_id)||t.push(r[f])}return t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeFilters=e;
126
126
  },{}],"h8f7":[function(require,module,exports) {
@@ -171,7 +171,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
171
171
  },{}],"xR4c":[function(require,module,exports) {
172
172
  "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;
173
173
  },{}],"nKaW":[function(require,module,exports) {
174
- "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(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach(function(e){f(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function n(t){return u(t)||a(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,e){if(t){if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(t,e):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,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(){s=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.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(N){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof h?e:h,a=Object.create(o.prototype),u=new E(n||[]);return i(a,"_invoke",{value:O(t,r,u)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(N){return{type:"throw",arg:N}}}e.wrap=l;var d={};function h(){}function y(){}function v(){}var m={};f(m,a,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(S([])));g&&g!==r&&n.call(g,a)&&(m=g);var _=v.prototype=h.prototype=Object.create(m);function w(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function x(e,r){var o;i(this,"_invoke",{value:function(i,a){function u(){return new r(function(o,u){!function i(o,a,u,c){var s=p(e[o],e,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==t(l)&&n.call(l,"__await")?r.resolve(l.__await).then(function(t){i("next",t,u,c)},function(t){i("throw",t,u,c)}):r.resolve(l).then(function(t){f.value=t,u(f)},function(t){return i("throw",t,u,c)})}c(s.arg)}(i,a,o,u)})}return o=o?o.then(u,u):u()}})}function O(t,e,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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=j(a,r);if(u){if(u===d)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=p(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function j(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,j(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=p(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function k(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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return y.prototype=v,i(_,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:y,configurable:!0}),y.displayName=f(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,f(t,c,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},w(x.prototype),f(x.prototype,u,function(){return this}),e.AsyncIterator=x,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new x(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},w(_),f(_,c,"Generator"),f(_,a,function(){return this}),f(_,"toString",function(){return"[object Generator]"}),e.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}},e.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 e in this)"t"===e.charAt(0)&&n.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 i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):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),d},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),L(r),d}},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 i=n.arg;L(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function f(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(e){var r=p(e,"string");return"symbol"===t(r)?r:String(r)}function p(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,r||"default");if("object"!==t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function d(t,e,r,n,i,o,a){try{var u=t[o](a),c=u.value}catch(s){return void r(s)}u.done?e(c):Promise.resolve(c).then(n,i)}function h(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){d(o,n,i,a,u,"next",t)}function u(t){d(o,n,i,a,u,"throw",t)}a(void 0)})}}function y(t,e,i,o,a){function u(t,e,r){return c.apply(this,arguments)}function c(){return(c=h(s().mark(function t(e,r,n){var i;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null,"array"!==e.type){t.next=13;break}if(!Number(e.is_static)){t.next=10;break}return t.t0=Array,t.next=6,v(e.childs,r,n);case 6:t.t1=t.sent,i=new t.t0(t.t1),t.next=13;break;case 10:return t.next=12,l(e,r,n);case 12:i=t.sent;case 13:if("object"!==e.type){t.next=23;break}if(!Number(e.current_item)){t.next=20;break}return t.next=17,d(e,r);case 17:i=t.sent,t.next=23;break;case 20:return t.next=22,v(e.childs,r,n);case 22:i=t.sent;case 23:if("property"!==e.type){t.next=27;break}return t.next=26,b(e,r,n);case 26:i=t.sent;case 27:return t.abrupt("return",f({},e.property_name,i));case 28:case"end":return t.stop()}},t)}))).apply(this,arguments)}function l(t,e,r){return p.apply(this,arguments)}function p(){return(p=h(s().mark(function t(e,r,a){var u,c,f,l,p,d,y;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.getApp(Number(e.app_id));case 2:return u=t.sent,t.next=5,x(e.filter,u.items_list,a,r);case 5:return c=t.sent,e.isSortable&&e.field_id_to_sort&&""!==e.field_id_to_sort&&(f=c.flatMap(function(t){var r=t.fields.find(function(t){return t.field_id==e.field_id_to_sort});return r&&""!=r.field_value?t:[]}),l=c.filter(function(t){if(!f.includes(t))return t}),f=f.sort(function(t,r){return"desc"==e.sortType?r.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value-t.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value:t.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value-r.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value}),c=[].concat(n(f),n(l))),e.offset&&(p=e.use_variables_for_limit_and_offset&&o?o[e.offset]:/^[0-9]+$/.test(e.offset)?e.offset:0,c=c.slice(p)),e.limit&&0!==(d=e.use_variables_for_limit_and_offset&&o?o[e.limit]:/^[0-9]+$/.test(e.limit)||0)&&(c=c.slice(0,d)),y=c.map(function(){var t=h(s().mark(function t(r){return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",v(e.childs,r,u.app_id));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),t.abrupt("return",Promise.all(y));case 11:case"end":return t.stop()}},t)}))).apply(this,arguments)}function d(t,e){return y.apply(this,arguments)}function y(){return(y=h(s().mark(function t(e,r){var n,o;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.getApp(e.app_id);case 2:return n=t.sent,o=n.items_list||[],t.abrupt("return",v(e.childs,r||o[0],n.app_id));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}function v(t,e,r){return m.apply(this,arguments)}function m(){return(m=h(s().mark(function t(e,n,i){var o,a;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.map(function(){var t=h(s().mark(function t(e){return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",u(e,n,i));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}());case 2:return o=t.sent,t.next=5,Promise.all(o);case 5:return a=t.sent,t.abrupt("return",a.reduce(function(t,e){return r(r({},t),e)},{}));case 7:case"end":return t.stop()}},t)}))).apply(this,arguments)}function b(t,e,r){return g.apply(this,arguments)}function g(){return(g=h(s().mark(function t(e,r,o){var a,u,c,f,l;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.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",e.static_field_value);case 4:t.t1=e.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(r.item_id));case 9:return t.abrupt("return",e.field_id);case 10:if("function"!=typeof e.function){t.next=15;break}return a=e.function.apply(e,[r,o,i.gudhub].concat(n(e.args))),t.abrupt("return",a);case 15:return u=new Function("item, appId, gudhub","return (async "+e.function+")(item, appId, gudhub)"),t.next=18,u(r,o,i.gudhub);case 18:return c=t.sent,t.abrupt("return",c);case 20:if(e.field_id||!e.name_space){t.next=24;break}return t.next=23,i.gudhub.getFieldIdByNameSpace(o,e.name_space);case 23:e.field_id=t.sent;case 24:if(!Boolean(Number(e.interpretation))){t.next=31;break}return t.next=27,i.gudhub.getInterpretationById(Number(o),Number(r.item_id),Number(e.field_id),"value");case 27:return f=t.sent,t.abrupt("return",f);case 31:return t.next=33,i.gudhub.getFieldValue(Number(o),Number(r.item_id),Number(e.field_id));case 33:return l=t.sent,t.abrupt("return",l);case 35:case"end":return t.stop()}},t)}))).apply(this,arguments)}function _(t,e,r,n,i){return w.apply(this,arguments)}function w(){return(w=h(s().mark(function t(e,a,u,c,f){var l;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.prefilter(JSON.parse(JSON.stringify(e)),r({element_app_id:a,app_id:u,item_id:c},o));case 2:return l=t.sent,t.abrupt("return",i.gudhub.filter(f,[].concat(n(l),n(e))));case 4:case"end":return t.stop()}},t)}))).apply(this,arguments)}function x(){return O.apply(this,arguments)}function O(){return(O=h(s().mark(function t(){var e,r,i,o,a=arguments;return s().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=a.length>0&&void 0!==a[0]?a[0]:[],r=a.length>1&&void 0!==a[1]?a[1]:[],i=a.length>2&&void 0!==a[2]?a[2]:"",o=a.length>3&&void 0!==a[3]?a[3]:{},t.abrupt("return",e.length?_(e,i,i,o.item_id,r):n(r));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}return u(t,e,a,o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compiler=y;
174
+ "use strict";function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function e(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function r(t){return a(t)||o(t)||i(t)||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 i(t,e){if(t){if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}function o(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function a(t){if(Array.isArray(t))return u(t)}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function c(){c=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(N){s=function(t,e,r){return t[e]=r}}function f(t,e,r,i){var o=e&&e.prototype instanceof h?e:h,a=Object.create(o.prototype),u=new E(i||[]);return n(a,"_invoke",{value:O(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(N){return{type:"throw",arg:N}}}t.wrap=f;var d={};function h(){}function y(){}function v(){}var b={};s(b,o,function(){return this});var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==e&&r.call(g,o)&&(b=g);var _=v.prototype=h.prototype=Object.create(b);function w(t){["next","throw","return"].forEach(function(e){s(t,e,function(t){return this._invoke(e,t)})})}function x(t,e){var i;n(this,"_invoke",{value:function(n,o){function a(){return new e(function(i,a){!function n(i,o,a,u){var c=l(t[i],t,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==p(f)&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){n("next",t,a,u)},function(t){n("throw",t,a,u)}):e.resolve(f).then(function(t){s.value=t,a(s)},function(t){return n("throw",t,a,u)})}u(c.arg)}(n,o,i,a)})}return i=i?i.then(a,a):a()}})}function O(t,e,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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=k(a,r);if(u){if(u===d)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(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function k(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,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=l(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function j(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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return y.prototype=v,n(_,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:y,configurable:!0}),y.displayName=s(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,a,function(){return this}),t.AsyncIterator=x,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new x(f(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},w(_),s(_,u,"Generator"),s(_,o,function(){return this}),s(_,"toString",function(){return"[object Generator]"}),t.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}},t.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 e in this)"t"===e.charAt(0)&&r.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 n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.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(t,e){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"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):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),d},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),L(r),d}},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 i=n.arg;L(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function s(t,e,r){return(e=f(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function f(t){var e=l(t,"string");return"symbol"===p(e)?e:String(e)}function l(t,e){if("object"!==p(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function p(t){return(p="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})(t)}function d(t,e,r,n,i,o,a){try{var u=t[o](a),c=u.value}catch(s){return void r(s)}u.done?e(c):Promise.resolve(c).then(n,i)}function h(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){d(o,n,i,a,u,"next",t)}function u(t){d(o,n,i,a,u,"throw",t)}a(void 0)})}}function y(t,n,i,o,a){function u(t,e,r){return f.apply(this,arguments)}function f(){return(f=h(c().mark(function t(e,r,n){var i,o,a,f,d;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null,"array"!==e.type){t.next=13;break}if(!Number(e.is_static)){t.next=10;break}return t.t0=Array,t.next=6,b(e.childs,r,n);case 6:t.t1=t.sent,i=new t.t0(t.t1),t.next=13;break;case 10:return t.next=12,l(e,r,n);case 12:i=t.sent;case 13:if("object"!==e.type){t.next=23;break}if(!Number(e.current_item)){t.next=20;break}return t.next=17,y(e,r);case 17:i=t.sent,t.next=23;break;case 20:return t.next=22,b(e.childs,r,n);case 22:i=t.sent;case 23:if("property"!==e.type){t.next=27;break}return t.next=26,g(e,r,n);case 26:i=t.sent;case 27:if("object"!==p(e)||void 0!==e.type){t.next=41;break}o={},t.t2=c().keys(e);case 30:if((t.t3=t.t2()).done){t.next=40;break}if(a=t.t3.value,!e.hasOwnProperty(a)){t.next=38;break}return f=e[a],t.next=36,u(f,r,n);case 36:d=t.sent,o[a]=d[f.property_name];case 38:t.next=30;break;case 40:return t.abrupt("return",o);case 41:return t.abrupt("return",s({},e.property_name,i));case 42:case"end":return t.stop()}},t)}))).apply(this,arguments)}function l(t,e,r){return d.apply(this,arguments)}function d(){return(d=h(c().mark(function t(e,n,a){var u,s,f,l,p,d,y;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.getApp(Number(e.app_id));case 2:return u=t.sent,t.next=5,O(e.filter,u.items_list,a,n);case 5:return s=t.sent,e.isSortable&&e.field_id_to_sort&&""!==e.field_id_to_sort&&(f=s.flatMap(function(t){var r=t.fields.find(function(t){return t.field_id==e.field_id_to_sort});return r&&""!=r.field_value?t:[]}),l=s.filter(function(t){if(!f.includes(t))return t}),f=f.sort(function(t,r){return"desc"==e.sortType?r.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value-t.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value:t.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value-r.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value}),s=[].concat(r(f),r(l))),e.offset&&(p=e.use_variables_for_limit_and_offset&&o?o[e.offset]:/^[0-9]+$/.test(e.offset)?e.offset:0,s=s.slice(p)),e.limit&&0!==(d=e.use_variables_for_limit_and_offset&&o?o[e.limit]:/^[0-9]+$/.test(e.limit)||0)&&(s=s.slice(0,d)),y=s.map(function(){var t=h(c().mark(function t(r){return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",b(e.childs,r,u.app_id));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),t.abrupt("return",Promise.all(y));case 11:case"end":return t.stop()}},t)}))).apply(this,arguments)}function y(t,e){return v.apply(this,arguments)}function v(){return(v=h(c().mark(function t(e,r){var n,o;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.getApp(e.app_id);case 2:return n=t.sent,o=n.items_list||[],t.abrupt("return",b(e.childs,r||o[0],n.app_id));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}function b(t,e,r){return m.apply(this,arguments)}function m(){return(m=h(c().mark(function t(r,n,i){var o,a;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.map(function(){var t=h(c().mark(function t(e){return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",u(e,n,i));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}());case 2:return o=t.sent,t.next=5,Promise.all(o);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 g(t,e,r){return _.apply(this,arguments)}function _(){return(_=h(c().mark(function t(e,n,o){var a,u,s,f,l;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.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",e.static_field_value);case 4:t.t1=e.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(n.item_id));case 9:return t.abrupt("return",e.field_id);case 10:if("function"!=typeof e.function){t.next=15;break}return a=e.function.apply(e,[n,o,i.gudhub].concat(r(e.args))),t.abrupt("return",a);case 15:return u=new Function("item, appId, gudhub","return (async "+e.function+")(item, appId, gudhub)"),t.next=18,u(n,o,i.gudhub);case 18:return s=t.sent,t.abrupt("return",s);case 20:if(e.field_id||!e.name_space){t.next=24;break}return t.next=23,i.gudhub.getFieldIdByNameSpace(o,e.name_space);case 23:e.field_id=t.sent;case 24:if(!Boolean(Number(e.interpretation))){t.next=31;break}return t.next=27,i.gudhub.getInterpretationById(Number(o),Number(n.item_id),Number(e.field_id),"value");case 27:return f=t.sent,t.abrupt("return",f);case 31:return t.next=33,i.gudhub.getFieldValue(Number(o),Number(n.item_id),Number(e.field_id));case 33:return l=t.sent,t.abrupt("return",l);case 35:case"end":return t.stop()}},t)}))).apply(this,arguments)}function w(t,e,r,n,i){return x.apply(this,arguments)}function x(){return(x=h(c().mark(function t(n,a,u,s,f){var l;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.gudhub.prefilter(JSON.parse(JSON.stringify(n)),e({element_app_id:a,app_id:u,item_id:s},o));case 2:return l=t.sent,t.abrupt("return",i.gudhub.filter(f,[].concat(r(l),r(n))));case 4:case"end":return t.stop()}},t)}))).apply(this,arguments)}function O(){return k.apply(this,arguments)}function k(){return(k=h(c().mark(function t(){var e,n,i,o,a=arguments;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=a.length>0&&void 0!==a[0]?a[0]:[],n=a.length>1&&void 0!==a[1]?a[1]:[],i=a.length>2&&void 0!==a[2]?a[2]:"",o=a.length>3&&void 0!==a[3]?a[3]:{},t.abrupt("return",e.length?w(e,i,i,o.item_id,n):r(n));case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}return u(t,n,a,o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compiler=y;
175
175
  },{}],"zqOZ":[function(require,module,exports) {
176
176
  "use strict";function e(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=t(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},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(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw a}}}}function t(e,t){if(e){if("string"==typeof e)return n(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)?n(e,t):void 0}}function n(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 r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},c=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=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(S){f=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof h?t:h,a=Object.create(o.prototype),c=new P(r||[]);return i(a,"_invoke",{value:E(e,n,c)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(S){return{type:"throw",arg:S}}}e.wrap=l;var d={};function h(){}function _(){}function v(){}var m={};f(m,c,function(){return this});var y=Object.getPrototypeOf,g=y&&y(y(I([])));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 x(e,t){var r;i(this,"_invoke",{value:function(i,o){function c(){return new t(function(r,c){!function r(i,o,c,u){var s=p(e[i],e,o);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==a(l)&&n.call(l,"__await")?t.resolve(l.__await).then(function(e){r("next",e,c,u)},function(e){r("throw",e,c,u)}):t.resolve(l).then(function(e){f.value=e,c(f)},function(e){return r("throw",e,c,u)})}u(s.arg)}(i,o,r,c)})}return r=r?r.then(c,c):c()}})}function E(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return L()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var c=k(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"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=p(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function k(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=p(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;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,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function O(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 P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function I(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 r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return _.prototype=v,i(w,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:_,configurable:!0}),_.displayName=f(v,s,"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,s,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},b(x.prototype),f(x.prototype,u,function(){return this}),e.AsyncIterator=x,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new x(l(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then(function(e){return e.done?e.value:a.next()})},b(w),f(w,s,"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 r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=I,P.prototype={constructor:P,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 r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("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 r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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 r=n.completion;if("throw"===r.type){var i=r.arg;A(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:I(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function i(e,t,n,r,i,o,a){try{var c=e[o](a),u=c.value}catch(s){return void n(s)}c.done?t(u):Promise.resolve(u).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function c(e){i(a,r,o,c,u,"next",e)}function u(e){i(a,r,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 r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}function s(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=l(e,"string");return"symbol"===a(t)?t:String(t)}function l(e,t){if("object"!==a(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==a(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 p=function(){function t(e){c(this,t),this.gudhub=e,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}}return s(t,[{key:"createAppsFromTemplate",value:function(e,t,n,r){var i=this,o=this;return new Promise(function(c){var u=100/(6*e.apps.length),s=0;o.createApps(e,function(e){s+=1,n&&n.call(i,{percent:s*u,status:e})},r).then(function(e){o.createItems(e,t,function(e){"string"==typeof e?(s+=1,n&&n.call(i,{percent:s*u,status:e})):"object"===a(e)&&(n&&n.call(i,{status:"Done",apps:e}),c())},r)})})}},{key:"createItems",value:function(e,t,n,i){var a=this;return new Promise(function(){var c=o(r().mark(function c(u){var s,f,l,p,d,h;return r().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return s=t||1e5,f=a,l=[],p=[],c.next=6,f.gudhub.req.axiosRequest({method:"POST",url:"https://gudhub.com/GudHub_Test/auth/login",form:{auth_key:"3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=="}});case 6:d=c.sent,h=d.accesstoken,e.forEach(function(e){p.push(new Promise(function(){var t=o(r().mark(function t(o){var c,u,p;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i){t.next=6;break}return t.next=3,f.gudhub.req.axiosRequest({url:"https://gudhub.com/GudHub_Test/api/app/get?token=".concat(h,"&app_id=").concat(f._searchOldAppId(e.app_id,f.appsConnectingMap.apps)),method:"GET"});case 3:c=t.sent,t.next=9;break;case 6:return t.next=8,f.gudhub.getApp(f._searchOldAppId(e.app_id,f.appsConnectingMap.apps));case 8:c=t.sent;case 9:n&&n.call(a,"GET APP: ".concat(c.app_name," (Items steps)")),u=JSON.parse(JSON.stringify(c)),p=u.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,t){return t<=s}),f.gudhub.addNewItems(e.app_id,p).then(function(t){n&&n.call(a,"ADD NEW ITEMS: ".concat(c.app_name," (Items steps)")),e.items_list=t,f._updateMap(e.items_list,u.items_list),f._addFieldValue(u.items_list,e.items_list,f.appsConnectingMap),l.push(e),o()});case 13:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()))}),Promise.all(p).then(function(){l.forEach(function(e){e.items_list.forEach(function(e){e.fields.forEach(function(e){f.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)})})})}),f.deleteField(l),f.replaceValue(l,f.appsConnectingMap).then(function(){var e=[];l.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});f.gudhub.updateItems(t.app_id,r).then(function(){n&&n.call(a,"REPLACE VALUE: ".concat(t.app_name," (Items steps)")),e()})}))}),Promise.all(e).then(function(){n.call(a,l),u()})})});case 10:case"end":return c.stop()}},c)}));return function(e){return c.apply(this,arguments)}}())}},{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 i=o(r().mark(function i(o){var a,c;return r().wrap(function(r){for(;;)switch(r.prev=r.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(r){return void 0===r?(console.log("ERROR WHILE GETTING INSTANCE OF ",n.data_type),void t({type:n.data_type})):"file"==r.getTemplate().constructor?c.gudhub.util.fileInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(e)}):void("document"==r.getTemplate().constructor?c.documentInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(r)}):t(r))})}))})}),a.length>0?Promise.all(a).then(function(e){o(e)}):o(result);case 4:case"end":return r.stop()}},i)}));return function(e){return i.apply(this,arguments)}}())}},{key:"documentInstallerHelper",value:function(t,n,i){var a=this;return new Promise(function(){var c=o(r().mark(function o(c){var u,s,f,l,p,d,h;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:u=e(n),r.prev=1,u.s();case 3:if((s=u.n()).done){r.next=18;break}if(f=s.value,l=f.item_id,!((p=f.fields.find(function(e){return e.element_id===i}))&&p.field_value&&p.field_value.length>0)){r.next=16;break}return r.next=10,a.gudhub.getDocument({_id:p.field_value});case 10:if(!(d=r.sent)||!d.data){r.next=16;break}return r.next=14,a.gudhub.createDocument({app_id:t,item_id:l,element_id:i,data:d.data});case 14:h=r.sent,p.field_value=h._id;case 16:r.next=3;break;case 18:r.next=23;break;case 20:r.prev=20,r.t0=r.catch(1),u.e(r.t0);case 23:return r.prev=23,u.f(),r.finish(23);case 26:c();case 27:case"end":return r.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 r=e.field_value.split(",");r.forEach(function(e,t){var i=e.split(".");n.apps.forEach(function(e){i[0]==e.old_app_id&&(i[0]=e.new_app_id)}),n.items.forEach(function(e){i[1]==e.old_item_id&&(i[1]=e.new_item_id)}),r[t]=i.join(".")}),e.field_value=r.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(t,n,i){var a=this,c=this,u={step_size:100/(3*t.apps.length),apps:[]};return new Promise(function(){var s=o(r().mark(function o(s){var f,l,p,d,h,_,v,m;return r().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return f={},l=[],p=[],o.next=5,c.gudhub.req.axiosRequest({method:"POST",url:"https://gudhub.com/GudHub_Test/auth/login",form:{auth_key:"3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=="}});case 5:d=o.sent,h=d.accesstoken,_=e(t.apps),o.prev=8,m=r().mark(function e(){var o,d,_,m;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o=v.value,!i){e.next=7;break}return e.next=4,c.gudhub.req.axiosRequest({url:"https://gudhub.com/GudHub_Test/api/app/get?token=".concat(h,"&app_id=").concat(o),method:"GET"});case 4:d=e.sent,e.next=10;break;case 7:return e.next=9,c.gudhub.getApp(o);case 9:d=e.sent;case 10:n&&n.call(a,"GET APP: ".concat(d.app_name," (App steps)")),_=JSON.parse(JSON.stringify(d)),f[_.app_id]=_,u.apps.push(_.icon),(m=c.prepareAppTemplate(_)).app_name=m.app_name+" New",m.privacy=1,t.data_to_change&&(t.data_to_change.name&&(m.app_name=t.data_to_change.name),t.data_to_change.icon&&(m.icon=t.data_to_change.icon)),c.resetViewsIds(m),c.gudhub.createNewApp(m).then(function(e){n&&n.call(a,"CREATE NEW APP: ".concat(d.app_name," (App steps)")),l.push(e),c.mapApp(_,e,c.appsConnectingMap),t.apps.length==l.length&&(c.connectApps(l,c.appsConnectingMap,f),l.forEach(function(e){c.gudhub.updateApp(e).then(function(e){n&&n.call(a,"UPDATE APP: ".concat(d.app_name," (App steps)")),p.push(e),t.apps.length==p.length&&s(p)})}))});case 20:case"end":return e.stop()}},e)}),_.s();case 11:if((v=_.n()).done){o.next=15;break}return o.delegateYield(m(),"t0",13);case 13:o.next=11;break;case 15:o.next=20;break;case 17:o.prev=17,o.t1=o.catch(8),_.e(o.t1);case 20:return o.prev=20,_.f(),o.finish(20);case 23:case"end":return o.stop()}},o,null,[[8,17,20,23]])}));return function(e){return s.apply(this,arguments)}}())}},{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),r=this;n.length>0&&n.forEach(function(n){var i=e[n];void 0!==i&&"string"!=typeof e&&(t(n,i,e),r.crawling(i,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 r=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)})}),r.crawling(e.field_list,function(i,o,a){if(-1!==i.indexOf("field_id")||-1!==i.indexOf("FieldId")||-1!==i.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[i]=u.join(","))}if(-1==i.indexOf("app_id")&&-1==i.indexOf("AppId")&&-1==i.indexOf("destination_app")||t.apps.forEach(function(e){o==e.old_app_id&&(a[i]=e.new_app_id)}),-1!==i.indexOf("view_id")&&t.views.forEach(function(e){o==e.old_view_id&&(a[i]=e.new_view_id)}),-1!==i.indexOf("src")&&isFinite(o)){var s=t.apps.find(function(t){return t.new_app_id===e.app_id}).old_app_id,f=r.findPath(n[s].views_list,"container_id",o);a[i]="".concat(r.getValueByPath(e.views_list,f,"container_id"))}})}),e}},{key:"getValueByPath",value:function(e,t,n){var r=e;return t.split(".").forEach(function(e){r=r[e]}),r[n]}},{key:"findPath",value:function(e,t,n){var r=!1,i=!1,o=[];return this.crawling(e,function(e,c,u){i&&o.reverse().forEach(function(e){i&&(e.delete=!0,e.parent===u&&(i=!1,(o=o.filter(function(e){return!e.delete})).reverse()))}),r||("object"===a(u[e])&&o.push({prop:e,parent:u}),c==n&&t===e?r=!0:Object.keys(u).pop()===e&&"object"!==a(u[e])&&(i=!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;
177
177
  },{}],"E7yc":[function(require,module,exports) {
@@ -207,7 +207,7 @@ var t,e=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),expo
207
207
  },{}],"KHGc":[function(require,module,exports) {
208
208
  "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:{},u=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.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(A){f=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=r&&r.prototype instanceof v?r:v,a=Object.create(o.prototype),u=new j(n||[]);return i(a,"_invoke",{value:L(t,e,u)}),a}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(A){return{type:"throw",arg:A}}}e.wrap=h;var p={};function v(){}function y(){}function d(){}var g={};f(g,u,function(){return this});var m=Object.getPrototypeOf,b=m&&m(m(O([])));b&&b!==n&&o.call(b,u)&&(g=b);var w=d.prototype=v.prototype=Object.create(g);function x(t){["next","throw","return"].forEach(function(r){f(t,r,function(t){return this._invoke(r,t)})})}function k(r,e){var n;i(this,"_invoke",{value:function(i,a){function u(){return new e(function(n,u){!function n(i,a,u,c){var s=l(r[i],r,a);if("throw"!==s.type){var f=s.arg,h=f.value;return h&&"object"==t(h)&&o.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,u,c)},function(t){n("throw",t,u,c)}):e.resolve(h).then(function(t){f.value=t,u(f)},function(t){return n("throw",t,u,c)})}c(s.arg)}(i,a,n,u)})}return n=n?n.then(u,u):u()}})}function L(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 _()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=E(a,e);if(u){if(u===p)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=l(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}function E(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,E(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=l(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 P(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 j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(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,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:_}}function _(){return{value:void 0,done:!0}}return y.prototype=d,i(w,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:y,configurable:!0}),y.displayName=f(d,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===y||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,f(t,s,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(k.prototype),f(k.prototype,c,function(){return this}),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},x(w),f(w,s,"Generator"),f(w,u,function(){return this}),f(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=O,j.prototype={constructor:j,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 u=o.call(i,"catchLoc"),c=o.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 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:O(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),p}},e}function e(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 n(t){return function(){var r=this,n=arguments;return new Promise(function(o,i){var a=t.apply(r,n);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)})}}function o(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function i(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function a(t,r,e){return r&&i(t.prototype,r),e&&i(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(r){var e=c(r,"string");return"symbol"===t(e)?e:String(e)}function c(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)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChunksManager=void 0;var s=function(){function t(r,e,n,i){o(this,t),this.storage=r,this.pipeService=e,this.req=n,this.util=i,this.itemListeners()}return a(t,[{key:"getChunkApi",value:function(){var t=n(r().mark(function t(e,n){var o;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.req.axiosRequest({url:"".concat(this.req.root,"/api/get-items-chunk/").concat(e,"/").concat(n),method:"GET"});case 3:return o=t.sent,t.abrupt("return",o);case 7:return t.prev=7,t.t0=t.catch(0),console.log(t.t0),t.abrupt("return",null);case 11:case"end":return t.stop()}},t,this,[[0,7]])}));return function(r,e){return t.apply(this,arguments)}}()},{key:"getLastChunkApi",value:function(){var t=n(r().mark(function t(e){var n;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.req.axiosRequest({url:"".concat(this.req.root,"/api/get-last-items-chunk/").concat(e),method:"GET"});case 3:return n=t.sent,t.abrupt("return",n);case 7:return t.prev=7,t.t0=t.catch(0),console.log(t.t0),t.abrupt("return",null);case 11:case"end":return t.stop()}},t,this,[[0,7]])}));return function(r){return t.apply(this,arguments)}}()},{key:"getChunk",value:function(t,r){return this.getChunkApi(t,r)}},{key:"getChunks",value:function(){var t=n(r().mark(function t(e,n){var o,i=this;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(o=[],!n){t.next=5;break}return t.next=4,Promise.all(n.map(function(t){return i.getChunkApi(e,t)}));case 4:o=t.sent;case 5:return t.abrupt("return",o);case 6:case"end":return t.stop()}},t)}));return function(r,e){return t.apply(this,arguments)}}()},{key:"getLastChunk",value:function(){var t=n(r().mark(function t(e){var n;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getLastChunkApi(e);case 2:return n=t.sent,t.abrupt("return",n);case 4:case"end":return t.stop()}},t,this)}));return function(r){return t.apply(this,arguments)}}()},{key:"itemListeners",value:function(){}},{key:"getApp",value:function(){var t=n(r().mark(function t(e){var n;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return",null);case 2:if(n=this.getAppFromStorage(e)){t.next=16;break}if(!this.getAppPromises[e]){t.next=6;break}return t.abrupt("return",this.getAppPromises[e]);case 6:return this.getAppPromises[e]=this.getAppApi(e),t.next=9,this.getAppPromises[e];case 9:if(!(n=t.sent)){t.next=15;break}this.saveAppInStorage(n),this.ws.addSubscription(e),t.next=16;break;case 15:return t.abrupt("return",null);case 16:return t.abrupt("return",n);case 17:case"end":return t.stop()}},t,this)}));return function(r){return t.apply(this,arguments)}}()}]),t}();exports.ChunksManager=s;
209
209
  },{}],"K1Gs":[function(require,module,exports) {
210
- "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,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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,o(r.key),r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(t){var n=i(t,"string");return"symbol"===e(n)?n:String(n)}function i(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentManager=void 0;var u=function(){function e(n,r){t(this,e),this.req=n,this.pipeService=r}return r(e,[{key:"createDocument",value:function(e){return this.emitDocumentInsert(e),this.req.post({url:"/api/new/document/insert-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"emitDocumentInsert",value:function(e){this.pipeService.emit("gh_document_insert_one",{app_id:e.app_id,item_id:e.item_id,element_id:e.element_id},JSON.parse(e.data))}},{key:"getDocument",value:function(e){return this.req.post({url:"/api/new/document/find-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"getDocuments",value:function(e){return this.req.post({url:"/api/new/document/find",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"deleteDocument",value:function(e){return this.req.post({url:"/api/new/document/remove-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}}]),e}();exports.DocumentManager=u;
210
+ "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,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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,o(r.key),r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(t){var n=i(t,"string");return"symbol"===e(n)?n:String(n)}function i(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentManager=void 0;var u=function(){function e(n,r){t(this,e),this.req=n,this.pipeService=r}return r(e,[{key:"createDocument",value:function(e){return this.emitDocumentInsert(e),this.req.post({url:"/api/new/document/insert-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"emitDocumentInsert",value:function(e){var t="string"==typeof e.data?JSON.parse(e.data):e.data;this.pipeService.emit("gh_document_insert_one",{app_id:e.app_id,item_id:e.item_id,element_id:e.element_id},t)}},{key:"getDocument",value:function(e){return this.req.post({url:"/api/new/document/find-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"getDocuments",value:function(e){return this.req.post({url:"/api/new/document/find",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"deleteDocument",value:function(e){return this.req.post({url:"/api/new/document/remove-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}}]),e}();exports.DocumentManager=u;
211
211
  },{}],"X4Dt":[function(require,module,exports) {
212
212
  "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",c=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(S){l=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),u=new k(n||[]);return i(a,"_invoke",{value:_(t,r,u)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(S){return{type:"throw",arg:S}}}r.wrap=s;var p={};function d(){}function v(){}function y(){}var g={};l(g,u,function(){return this});var m=Object.getPrototypeOf,b=m&&m(m(I([])));b&&b!==n&&o.call(b,u)&&(g=b);var w=y.prototype=d.prototype=Object.create(g);function x(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function L(e,r){var n;i(this,"_invoke",{value:function(i,a){function u(){return new r(function(n,u){!function n(i,a,u,c){var f=h(e[i],e,a);if("throw"!==f.type){var l=f.arg,s=l.value;return s&&"object"==t(s)&&o.call(s,"__await")?r.resolve(s.__await).then(function(t){n("next",t,u,c)},function(t){n("throw",t,u,c)}):r.resolve(s).then(function(t){l.value=t,u(l)},function(t){return n("throw",t,u,c)})}c(f.arg)}(i,a,n,u)})}return n=n?n.then(u,u):u()}})}function _(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 P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(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 c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(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,E(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=h(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 j(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 O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function I(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:P}}function P(){return{value:void 0,done:!0}}return v.prototype=y,i(w,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:v,configurable:!0}),v.displayName=l(y,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,f,"GeneratorFunction")),t.prototype=Object.create(w),t},r.awrap=function(t){return{__await:t}},x(L.prototype),l(L.prototype,c,function(){return this}),r.AsyncIterator=L,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new L(s(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},x(w),l(w,f,"Generator"),l(w,u,function(){return this}),l(w,"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=I,k.prototype={constructor:k,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(O),!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"),c=o.call(i,"finallyLoc");if(u&&c){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(!c)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),O(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;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:I(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),c=u.value}catch(f){return void r(f)}u.done?e(c):Promise.resolve(c).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,c,"next",t)}function c(t){r(a,o,i,u,c,"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=c(e,"string");return"symbol"===t(r)?r:String(r)}function c(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.Interpritate=void 0;var f=function(){function t(e){o(this,t),this.gudhub=e}return a(t,[{key:"getInterpretationObj",value:function(t,e,r,n){var o={},i=e.data_model.interpretation.find(function(t){return t.src==r})||e.data_model.interpretation.find(function(t){return"table"==t.src})||{id:"default"};return t.data_model&&t.data_model.interpretation&&(o=t.data_model.interpretation.find(function(t){return t.src==n})||t.data_model.interpretation.find(function(t){return t.src==r})),gudhub.mergeObjects(i,o)}},{key:"getInterpretation",value:function(t,r,o,i,a,u,c){var f=this;return new Promise(function(){var l=n(e().mark(function n(l,s){var h;return e().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:(h=r&&r.data_type?r.data_type:o)?gudhub.ghconstructor.getInstance(h).then(function(e){if(e){var n=f.getInterpretationObj(r,e.getTemplate().model,i,c);e.getInterpretation(t,n.id,h,r,a,u).then(function(t){l(gudhub.mergeObjects(t,n))},function(t){s()})}},function(t){}):console.error("Get Interpretation: data_type is undefined",o,r);case 2:case"end":return e.stop()}},n)}));return function(t,e){return l.apply(this,arguments)}}())}},{key:"getInterpretationById",value:function(){var t=n(e().mark(function t(r,n,o,i){var a,u,c,f,l,s,h=arguments;return e().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=h.length>4&&void 0!==h[4]?h[4]:null,u=h.length>5&&void 0!==h[5]?h[5]:null,null!=a){t.next=8;break}return t.next=5,this.gudhub.getFieldValue(r,n,o);case 5:t.t0=t.sent,t.next=9;break;case 8:t.t0=a;case 9:if(c=t.t0,null!=u){t.next=16;break}return t.next=13,this.gudhub.getField(r,o);case 13:t.t1=t.sent,t.next=17;break;case 16:t.t1=u;case 17:if(null!=(f=t.t1)){t.next=20;break}return t.abrupt("return","");case 20:return t.next=22,this.gudhub.ghconstructor.getInstance(f.data_type);case 22:return l=t.sent,t.next=25,l.getInterpretation(c,i,f.data_type,f,n,r);case 25:if("<span>no interpretation</span>"!=(s=t.sent).html){t.next=30;break}return t.abrupt("return",c);case 30:return t.abrupt("return",s.html);case 31:case"end":return t.stop()}},t,this)}));return function(e,r,n,o){return t.apply(this,arguments)}}()}]),t}();exports.Interpritate=f;
213
213
  },{}],"sPce":[function(require,module,exports) {