@hestia-earth/ui-components 0.0.4 → 0.0.7

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.
Files changed (91) hide show
  1. package/auth/{public-api.d.ts → index.d.ts} +0 -0
  2. package/bibliographies/{public-api.d.ts → index.d.ts} +0 -0
  3. package/bundles/hestia-earth-ui-components.umd.js +1607 -1673
  4. package/bundles/hestia-earth-ui-components.umd.js.map +1 -1
  5. package/common/blank-node-state/blank-node-state.component.d.ts +1 -1
  6. package/common/blank-node-value-delta/blank-node-value-delta.component.d.ts +2 -2
  7. package/common/common.service.d.ts +1 -2
  8. package/common/delta-utils.d.ts +20 -0
  9. package/common/{public-api.d.ts → index.d.ts} +2 -0
  10. package/common/toast/toast.component.d.ts +2 -2
  11. package/common/toast.service.d.ts +3 -3
  12. package/common/utils.d.ts +8 -26
  13. package/cycles/{public-api.d.ts → index.d.ts} +1 -0
  14. package/engine/aggregation-engine.service.d.ts +13 -25
  15. package/engine/engine.service.d.ts +2 -6
  16. package/engine/index.d.ts +2 -0
  17. package/esm2015/auth/index.js +2 -0
  18. package/esm2015/bibliographies/index.js +3 -0
  19. package/esm2015/common/blank-node-diffs/blank-node-diffs.component.js +3 -4
  20. package/esm2015/common/blank-node-value-delta/blank-node-value-delta.component.js +4 -4
  21. package/esm2015/common/common.service.js +1 -7
  22. package/esm2015/common/delta-utils.js +54 -0
  23. package/esm2015/common/index.js +33 -0
  24. package/esm2015/common/toast/toast.component.js +3 -3
  25. package/esm2015/common/toast.service.js +5 -5
  26. package/esm2015/common/utils.js +20 -84
  27. package/esm2015/cycles/index.js +12 -0
  28. package/esm2015/engine/aggregation-engine.service.js +11 -47
  29. package/esm2015/engine/engine.service.js +9 -15
  30. package/esm2015/engine/index.js +3 -0
  31. package/esm2015/files/index.js +5 -0
  32. package/esm2015/fontawesome/index.js +2 -0
  33. package/esm2015/impact-assessments/impact-assessments-products/impact-assessments-products.component.js +3 -3
  34. package/esm2015/impact-assessments/index.js +7 -0
  35. package/esm2015/mendeley/index.js +2 -0
  36. package/esm2015/mendeley/mendeley.service.js +1 -1
  37. package/esm2015/node/index.js +14 -0
  38. package/esm2015/node/node-csv.service.js +1 -1
  39. package/esm2015/node/node-diffs/node-diffs.component.js +5 -5
  40. package/esm2015/node/node-diffs/node-diffs.model.js +6 -6
  41. package/esm2015/node/node.service.js +26 -16
  42. package/esm2015/public-api.js +16 -16
  43. package/esm2015/schema/index.js +2 -0
  44. package/esm2015/schema/schema.service.js +1 -1
  45. package/esm2015/search/index.js +4 -0
  46. package/esm2015/search/search.service.js +1 -1
  47. package/esm2015/sites/index.js +6 -0
  48. package/esm2015/terms/index.js +2 -0
  49. package/esm2015/users/index.js +2 -0
  50. package/fesm2015/hestia-earth-ui-components.js +827 -919
  51. package/fesm2015/hestia-earth-ui-components.js.map +1 -1
  52. package/files/{public-api.d.ts → index.d.ts} +2 -0
  53. package/fontawesome/{public-api.d.ts → index.d.ts} +0 -0
  54. package/impact-assessments/impact-assessments-products/impact-assessments-products.component.d.ts +2 -2
  55. package/impact-assessments/{public-api.d.ts → index.d.ts} +0 -0
  56. package/mendeley/{public-api.d.ts → index.d.ts} +0 -0
  57. package/mendeley/mendeley.service.d.ts +2 -2
  58. package/node/{public-api.d.ts → index.d.ts} +1 -0
  59. package/node/node-csv.service.d.ts +1 -1
  60. package/node/node-diffs/node-diffs.component.d.ts +3 -3
  61. package/node/node-diffs/node-diffs.model.d.ts +1 -1
  62. package/node/node.service.d.ts +16 -7
  63. package/package.json +1 -1
  64. package/public-api.d.ts +15 -15
  65. package/schema/{public-api.d.ts → index.d.ts} +0 -0
  66. package/schema/schema.service.d.ts +1 -1
  67. package/search/{public-api.d.ts → index.d.ts} +0 -0
  68. package/search/search.service.d.ts +2 -2
  69. package/sites/{public-api.d.ts → index.d.ts} +0 -0
  70. package/terms/{public-api.d.ts → index.d.ts} +0 -0
  71. package/users/{public-api.d.ts → index.d.ts} +0 -0
  72. package/common/blank-node-diffs/blank-node-diffs.service.d.ts +0 -5
  73. package/common/blank-node-value-delta/blank-node-value-delta.service.d.ts +0 -6
  74. package/engine/public-api.d.ts +0 -2
  75. package/esm2015/auth/public-api.js +0 -2
  76. package/esm2015/bibliographies/public-api.js +0 -3
  77. package/esm2015/common/blank-node-diffs/blank-node-diffs.service.js +0 -20
  78. package/esm2015/common/blank-node-value-delta/blank-node-value-delta.service.js +0 -31
  79. package/esm2015/common/public-api.js +0 -31
  80. package/esm2015/cycles/public-api.js +0 -11
  81. package/esm2015/engine/public-api.js +0 -3
  82. package/esm2015/files/public-api.js +0 -3
  83. package/esm2015/fontawesome/public-api.js +0 -2
  84. package/esm2015/impact-assessments/public-api.js +0 -7
  85. package/esm2015/mendeley/public-api.js +0 -2
  86. package/esm2015/node/public-api.js +0 -13
  87. package/esm2015/schema/public-api.js +0 -2
  88. package/esm2015/search/public-api.js +0 -4
  89. package/esm2015/sites/public-api.js +0 -6
  90. package/esm2015/terms/public-api.js +0 -2
  91. package/esm2015/users/public-api.js +0 -2
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@ng-bootstrap/ng-bootstrap'), require('@angular/google-maps'), require('@fortawesome/angular-fontawesome'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-solid-svg-icons'), require('@hestia-earth/utils'), require('random-material-color'), require('@hestia-earth/schema'), require('@hestia-earth/api'), require('rxjs'), require('rxjs/operators'), require('csvtojson'), require('@angular/common/http'), require('@angular/platform-browser'), require('pluralize'), require('@hestia-earth/bulma-tagsinput'), require('json-2-csv'), require('@angular/cdk/drag-drop'), require('@hestia-earth/schema-convert'), require('@hestia-earth/json-schema/schema-utils'), require('jsondiffpatch'), require('chart.js'), require('@google/markerclustererplus'), require('moment'), require('moment/locale/en-gb'), require('uuid'), require('chartjs-plugin-datalabels')) :
3
- typeof define === 'function' && define.amd ? define('@hestia-earth/ui-components', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@ng-bootstrap/ng-bootstrap', '@angular/google-maps', '@fortawesome/angular-fontawesome', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-solid-svg-icons', '@hestia-earth/utils', 'random-material-color', '@hestia-earth/schema', '@hestia-earth/api', 'rxjs', 'rxjs/operators', 'csvtojson', '@angular/common/http', '@angular/platform-browser', 'pluralize', '@hestia-earth/bulma-tagsinput', 'json-2-csv', '@angular/cdk/drag-drop', '@hestia-earth/schema-convert', '@hestia-earth/json-schema/schema-utils', 'jsondiffpatch', 'chart.js', '@google/markerclustererplus', 'moment', 'moment/locale/en-gb', 'uuid', 'chartjs-plugin-datalabels'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["hestia-earth"] = global["hestia-earth"] || {}, global["hestia-earth"]["ui-components"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.i10, global.ng.googleMaps, global.i1, global.freeRegularSvgIcons, global.freeSolidSvgIcons, global.utils, global.randomMaterialColor, global.schema, global.api, global.rxjs, global.rxjs.operators, global.csvtojson, global.ng.common.http, global.ng.platformBrowser, global.pluralize, global.BulmaTagsInput, global.json2Csv, global.ng.cdk.dragDrop, global.schemaConvert, global.schemaUtils, global.jsondiffpatch, global.chart_js, global.MarkerClusterer, global.moment, null, global.uuid, global.ChartDataLabels));
5
- })(this, (function (exports, i0, i3, i1$4, i4, i10, i1$2, i1, freeRegularSvgIcons, freeSolidSvgIcons, utils, randomMaterialColor, schema, api, rxjs, operators, csvtojson, i1$1, i1$3, pluralize, BulmaTagsInput, json2Csv, i6, schemaConvert, schemaUtils, jsondiffpatch, chart_js, MarkerClusterer, moment, enGb, uuid, ChartDataLabels) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@ng-bootstrap/ng-bootstrap'), require('@angular/google-maps'), require('@fortawesome/angular-fontawesome'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-solid-svg-icons'), require('random-material-color'), require('@hestia-earth/schema'), require('@hestia-earth/api'), require('@hestia-earth/utils'), require('rxjs'), require('rxjs/operators'), require('csvtojson'), require('@angular/common/http'), require('@angular/platform-browser'), require('pluralize'), require('@hestia-earth/bulma-tagsinput'), require('json-2-csv'), require('@angular/cdk/drag-drop'), require('@hestia-earth/schema-convert'), require('@hestia-earth/json-schema/schema-utils'), require('jsondiffpatch'), require('chart.js'), require('moment'), require('moment/locale/en-gb'), require('uuid'), require('@google/markerclustererplus'), require('chartjs-plugin-datalabels')) :
3
+ typeof define === 'function' && define.amd ? define('@hestia-earth/ui-components', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@ng-bootstrap/ng-bootstrap', '@angular/google-maps', '@fortawesome/angular-fontawesome', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-solid-svg-icons', 'random-material-color', '@hestia-earth/schema', '@hestia-earth/api', '@hestia-earth/utils', 'rxjs', 'rxjs/operators', 'csvtojson', '@angular/common/http', '@angular/platform-browser', 'pluralize', '@hestia-earth/bulma-tagsinput', 'json-2-csv', '@angular/cdk/drag-drop', '@hestia-earth/schema-convert', '@hestia-earth/json-schema/schema-utils', 'jsondiffpatch', 'chart.js', 'moment', 'moment/locale/en-gb', 'uuid', '@google/markerclustererplus', 'chartjs-plugin-datalabels'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["hestia-earth"] = global["hestia-earth"] || {}, global["hestia-earth"]["ui-components"] = {}), global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.i10, global.ng.googleMaps, global.i1, global.freeRegularSvgIcons, global.freeSolidSvgIcons, global.randomMaterialColor, global.schema, global.api, global.utils, global.rxjs, global.rxjs.operators, global.csvtojson, global.ng.common.http, global.ng.platformBrowser, global.pluralize, global.BulmaTagsInput, global.json2Csv, global.ng.cdk.dragDrop, global.schemaConvert, global.schemaUtils, global.jsondiffpatch, global.chart_js, global.moment, null, global.uuid, global.MarkerClusterer, global.ChartDataLabels));
5
+ })(this, (function (exports, i0, i3, i1$4, i4, i10, i1$2, i1, freeRegularSvgIcons, freeSolidSvgIcons, randomMaterialColor, schema, api, utils, rxjs, operators, csvtojson, i1$1, i1$3, pluralize, BulmaTagsInput, json2Csv, i6, schemaConvert, schemaUtils, jsondiffpatch, chart_js, moment, enGb, uuid, MarkerClusterer, ChartDataLabels) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -37,8 +37,8 @@
37
37
  var pluralize__namespace = /*#__PURE__*/_interopNamespace(pluralize);
38
38
  var BulmaTagsInput__default = /*#__PURE__*/_interopDefaultLegacy(BulmaTagsInput);
39
39
  var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
40
- var MarkerClusterer__default = /*#__PURE__*/_interopDefaultLegacy(MarkerClusterer);
41
40
  var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
41
+ var MarkerClusterer__default = /*#__PURE__*/_interopDefaultLegacy(MarkerClusterer);
42
42
  var ChartDataLabels__default = /*#__PURE__*/_interopDefaultLegacy(ChartDataLabels);
43
43
 
44
44
  var HeAuthService = /** @class */ (function () {
@@ -417,10 +417,11 @@
417
417
  }]
418
418
  }], ctorParameters: function () { return [{ type: i1__namespace.FaIconLibrary }]; } });
419
419
 
420
- var _a$6, _b$3;
421
- var get$5 = require('lodash.get');
420
+ var _a$6;
421
+ var get$4 = require('lodash.get');
422
422
  var gitHome = 'https://gitlab.com/hestia-earth';
423
423
  var gitRawBaseUrl = 'https://glcdn.githack.com/hestia-earth';
424
+ var gitBranch = function () { return ['dev', 'staging'].some(function (env) { return baseUrl().includes(env); }) ? 'develop' : 'master'; };
424
425
  var isChrome = function () { return window.navigator.userAgent.includes('Chrome'); };
425
426
  var baseUrl = function () { return window.location.origin.includes('localhost') ?
426
427
  'https://www-dev.hestia.earth' :
@@ -429,18 +430,8 @@
429
430
  'https://www.hestia.earth'; };
430
431
  var isExternal = function () { return baseUrl() !== window.location.origin; };
431
432
  ;
432
- var loadScript = function (src) { return new Promise(function (resolve, reject) {
433
- if (!src || document.body.querySelectorAll('script[src="' + src + '"]').length > 0) {
434
- return resolve({});
435
- }
436
- var script = document.createElement('script');
437
- script.onload = resolve;
438
- script.onerror = reject;
439
- script.src = src;
440
- document.body.appendChild(script);
441
- }); };
442
433
  var parseErrorStatus = function (error) { return ((error === null || error === void 0 ? void 0 : error.statusText) || '').toLowerCase().replace(/\s/g, '-'); };
443
- var parseErrorMessage = function (error) { return get$5(error, 'error.error', get$5(error, 'error.message', get$5(error, 'error', get$5(error, 'message', error)))); };
434
+ var parseErrorMessage = function (error) { return get$4(error, 'error.error', get$4(error, 'error.message', get$4(error, 'error', get$4(error, 'message', error)))); };
444
435
  var handleAPIError = function (error) {
445
436
  try {
446
437
  error = parseErrorMessage(error);
@@ -455,21 +446,6 @@
455
446
  var err = parseErrorMessage(error);
456
447
  return parseErrorStatus(err) || err;
457
448
  };
458
- var toFormData = function (data, formData) {
459
- if (formData === void 0) { formData = new FormData(); }
460
- for (var key in data) {
461
- if (data.hasOwnProperty(key)) {
462
- var value = data[key];
463
- if (typeof value === 'object') {
464
- formData.append(key, JSON.stringify(value));
465
- }
466
- else {
467
- formData.append(key, value);
468
- }
469
- }
470
- }
471
- return formData;
472
- };
473
449
  var filterParams = function (obj) {
474
450
  var res = {};
475
451
  Object.keys(obj).sort().forEach(function (key) {
@@ -480,14 +456,6 @@
480
456
  });
481
457
  return res;
482
458
  };
483
- var toSearchParams = function (params) {
484
- if (params === void 0) { params = {}; }
485
- var searchParams = new URLSearchParams();
486
- Object.keys(params)
487
- .filter(function (key) { return typeof params[key] !== 'undefined'; })
488
- .forEach(function (key) { return searchParams.append(key, "" + params[key]); });
489
- return searchParams;
490
- };
491
459
  var waitFor = function (variable, callback) {
492
460
  if (variable in window) {
493
461
  return callback();
@@ -502,23 +470,6 @@
502
470
  setTimeout(function () { return el ? el.scrollIntoView() : (retries < 10 ? scrollToEl(id, retries + 1) : null); }, 100);
503
471
  };
504
472
  var scrollTop = function () { return window.scrollTo(0, 0); };
505
- var animateCounter = function (total, callback) {
506
- var animationDuration = 10;
507
- var step = Math.pow(10, ("" + total).length - 1);
508
- var maxSteps = parseInt("" + total / step, 10);
509
- var current = 0;
510
- var interval = setInterval(function () {
511
- callback(current);
512
- current += (step / animationDuration);
513
- if (current > maxSteps * step) {
514
- animationDuration = 100;
515
- }
516
- if (current > total) {
517
- callback(total);
518
- clearInterval(interval);
519
- }
520
- }, animationDuration);
521
- };
522
473
  var safeJSONParse = function (value, defaultValue) {
523
474
  try {
524
475
  return typeof value === 'string' ? JSON.parse(value) : value;
@@ -582,7 +533,7 @@
582
533
  group[termId].values[nodeId].nodes.push(blankNode);
583
534
  group[termId].values[nodeId].value = concatBlankNodeValue(group[termId].values[nodeId].value, blankNode.value);
584
535
  grouppedValueKeys.forEach(function (arrayKey) {
585
- var newValue = get$5(blankNode, arrayKey, []);
536
+ var newValue = get$4(blankNode, arrayKey, []);
586
537
  group[termId].values[nodeId][arrayKey] = __spreadArray(__spreadArray([], __read((group[termId].values[nodeId][arrayKey] || []))), __read((Array.isArray(newValue) ? newValue : [newValue])));
587
538
  });
588
539
  return group;
@@ -592,7 +543,7 @@
592
543
  Object.keys(group.values).map(function (nodeId) {
593
544
  var index = group.values[nodeId].index;
594
545
  var termId = group.term['@id'];
595
- var originalValue = get$5(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
546
+ var originalValue = get$4(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
596
547
  if (originalValue.length > 0) {
597
548
  var value = originalValue.reduce(function (array, curr) { return concatBlankNodeValue(array, curr.value); }, []);
598
549
  group.originalValues[nodeId] = { value: propertyValue$1(value) };
@@ -601,7 +552,6 @@
601
552
  });
602
553
  return groups;
603
554
  };
604
- var sortByFn = function (key, asc) { return function (a, b) { return asc ? get$5(a, key, '').localeCompare(get$5(b, key, '')) : get$5(b, key, '').localeCompare(get$5(a, key, '')); }; };
605
555
  var ellipsis = function (text, maxlength) {
606
556
  if (text === void 0) { text = ''; }
607
557
  if (maxlength === void 0) { maxlength = 20; }
@@ -625,8 +575,6 @@
625
575
  // handle years
626
576
  .replace(/([0-9]{4})/g, function (g) { return "-" + g; }) :
627
577
  null; };
628
- var nodeTypeToString = function (type) { return "" + type.charAt(0).toLowerCase() + type.substring(1); };
629
- var parseNodeType = function (type) { return Object.values(schema.NodeType).find(function (v) { return v.toString().toLowerCase() === (type || '').toLowerCase(); }); };
630
578
  var nodeDefaultLabel = (_a$6 = {},
631
579
  _a$6[schema.NodeType.ImpactAssessment] = function (_a) {
632
580
  var name = _a.name, country = _a.country, endDate = _a.endDate, product = _a.product;
@@ -644,54 +592,8 @@
644
592
  var defaultLabel = function (node) { return node ? (node['@type'] in nodeDefaultLabel ? nodeDefaultLabel[node['@type']](node) : node.name) || node['@id'] || node.id : ''; };
645
593
  var itemColor = function (index) { return randomMaterialColor.getColor({ text: "" + index }); };
646
594
  var listColor = function (_v, index) { return itemColor(index); };
647
- var minutesBefore = function (date, minutes) {
648
- if (minutes === void 0) { minutes = 1; }
649
- date.setMinutes(date.getMinutes() - minutes);
650
- return date;
651
- };
652
- var hoursBefore = function (date, hours) {
653
- if (hours === void 0) { hours = 1; }
654
- date.setHours(date.getHours() - hours);
655
- return date;
656
- };
657
- var repeat = function (times) {
658
- if (times === void 0) { times = 0; }
659
- return (Array.from(Array(times), Math.random));
660
- };
661
- exports.DeltaDisplayType = void 0;
662
- (function (DeltaDisplayType) {
663
- DeltaDisplayType["absolute"] = "absolute";
664
- DeltaDisplayType["percent"] = "percent";
665
- })(exports.DeltaDisplayType || (exports.DeltaDisplayType = {}));
666
- var deltaPerType = (_b$3 = {},
667
- _b$3[exports.DeltaDisplayType.absolute] = function (value, original) { return value - original; },
668
- _b$3[exports.DeltaDisplayType.percent] = function (value, original) { return ((value - original) / original) * 100; },
669
- _b$3);
670
- var roundValue = function (value) { return +("" + value).substring(0, 10); };
671
- var delta = function (value, originalValue, displayType, customDeltaFuncs) {
672
- if (displayType === void 0) { displayType = exports.DeltaDisplayType.percent; }
673
- var vvalue = roundValue(propertyValue$1(value));
674
- var voriginalValue = roundValue(propertyValue$1(originalValue));
675
- var deltaFuncs = Object.assign(Object.assign({}, deltaPerType), customDeltaFuncs);
676
- var diff = vvalue === voriginalValue ? 0 : deltaFuncs[displayType](vvalue, voriginalValue);
677
- return Number.isFinite(diff) ? (diff === -0 ? 0 : diff) : 0;
678
- };
679
- exports.DeltaColour = void 0;
680
- (function (DeltaColour) {
681
- DeltaColour["Success"] = "success";
682
- DeltaColour["Warning"] = "warning";
683
- DeltaColour["Danger"] = "danger";
684
- })(exports.DeltaColour || (exports.DeltaColour = {}));
685
- var emptyValue = function (value) { return utils.isEmpty(value) || isNaN(propertyValue$1(value)); };
686
- var filenameWithoutExt = function (filename) {
687
- if (filename === void 0) { filename = ''; }
688
- var file = api.fileToExt(filename, '');
689
- // remove last .
690
- return file.endsWith('.') ? file.substring(0, file.length - 1) : file;
691
- };
692
-
693
595
  var reduceValues$1 = function (values) { return values.length ? values.reduce(function (p, v) { return p + propertyValue$1(v.value); }, 0) : undefined; };
694
- var formatValues = function (originalValues, recalculatedValues) {
596
+ var formatDiffValues = function (originalValues, recalculatedValues) {
695
597
  if (originalValues === void 0) { originalValues = []; }
696
598
  if (recalculatedValues === void 0) { recalculatedValues = []; }
697
599
  var originalValuesFiltered = originalValues.filter(function (value) { return !value.deleted; });
@@ -709,35 +611,70 @@
709
611
  });
710
612
  return values;
711
613
  };
614
+ var emptyValue = function (value) { return utils.isEmpty(value) || isNaN(propertyValue$1(value)); };
615
+ var repeat = function (times) {
616
+ if (times === void 0) { times = 0; }
617
+ return (Array.from(Array(times), Math.random));
618
+ };
619
+ var filenameWithoutExt = function (filename) {
620
+ if (filename === void 0) { filename = ''; }
621
+ var file = api.fileToExt(filename, '');
622
+ // remove last .
623
+ return file.endsWith('.') ? file.substring(0, file.length - 1) : file;
624
+ };
712
625
 
713
- var _a$5, _b$2, _c$2;
626
+ var _a$5, _b$2, _c$2, _d$2;
714
627
  var SUCCESS_CRITERION_MAX_DELTA_PERCENT = 5;
715
628
  var WARNING_CRITERION_MAX_DELTA_PERCENT = 20;
629
+ exports.DeltaColour = void 0;
630
+ (function (DeltaColour) {
631
+ DeltaColour["Success"] = "success";
632
+ DeltaColour["Warning"] = "warning";
633
+ DeltaColour["Danger"] = "danger";
634
+ })(exports.DeltaColour || (exports.DeltaColour = {}));
635
+ exports.DeltaDisplayType = void 0;
636
+ (function (DeltaDisplayType) {
637
+ DeltaDisplayType["absolute"] = "absolute";
638
+ DeltaDisplayType["percent"] = "percent";
639
+ })(exports.DeltaDisplayType || (exports.DeltaDisplayType = {}));
640
+ var deltaPerType = (_a$5 = {},
641
+ _a$5[exports.DeltaDisplayType.absolute] = function (value, original) { return value - original; },
642
+ _a$5[exports.DeltaDisplayType.percent] = function (value, original) { return ((value - original) / original) * 100; },
643
+ _a$5);
644
+ var roundValue = function (value) { return +("" + value).substring(0, 10); };
645
+ var delta = function (value, originalValue, displayType, mapping) {
646
+ if (displayType === void 0) { displayType = exports.DeltaDisplayType.percent; }
647
+ var vvalue = roundValue(propertyValue$1(value));
648
+ var voriginalValue = roundValue(propertyValue$1(originalValue));
649
+ var deltaFuncs = Object.assign(Object.assign({}, deltaPerType), mapping);
650
+ var diff = vvalue === voriginalValue ? 0 : deltaFuncs[displayType](vvalue, voriginalValue);
651
+ return Number.isFinite(diff) ? (diff === -0 ? 0 : diff) : 0;
652
+ };
716
653
  var PercentDeltaConditions;
717
654
  (function (PercentDeltaConditions) {
718
655
  PercentDeltaConditions["recalculated0"] = "recalculated should be 0";
719
656
  PercentDeltaConditions["original0"] = "original is 0";
720
657
  })(PercentDeltaConditions || (PercentDeltaConditions = {}));
721
- var calculatePercentDeltaConditions = (_a$5 = {},
722
- _a$5[PercentDeltaConditions.recalculated0] = function (original, recalculated) { return original > 0 && recalculated === 0; },
723
- _a$5[PercentDeltaConditions.original0] = function (original, recalculated) { return original === 0 && recalculated > 0; },
724
- _a$5);
725
- var calculatePercentDeltaResult = (_b$2 = {},
726
- _b$2[PercentDeltaConditions.recalculated0] = function (original, recalculated) { return (recalculated - original) / (original + 1); },
727
- // Always considered an error so deliberately exceed SUCCESS_CRITERION_MAX_DELTA_PERCENT
728
- _b$2[PercentDeltaConditions.original0] = function (original, recalculated) { return Math.sign(recalculated - original); },
729
- _b$2.default = function (original, recalculated) { return (recalculated - original) / original; },
658
+ var calculatePercentDeltaConditions = (_b$2 = {},
659
+ _b$2[PercentDeltaConditions.recalculated0] = function (original, recalculated) { return original > 0 && recalculated === 0; },
660
+ _b$2[PercentDeltaConditions.original0] = function (original, recalculated) { return original === 0 && recalculated > 0; },
730
661
  _b$2);
662
+ var calculatePercentDeltaResult = (_c$2 = {},
663
+ _c$2[PercentDeltaConditions.recalculated0] = function (original, recalculated) { return (recalculated - original) / (original + 1); },
664
+ // Always considered an error so deliberately exceed SUCCESS_CRITERION_MAX_DELTA_PERCENT
665
+ _c$2[PercentDeltaConditions.original0] = function (original, recalculated) { return Math.sign(recalculated - original); },
666
+ _c$2.default = function (original, recalculated) { return (recalculated - original) / original; },
667
+ _c$2);
731
668
  var calculatePercentDelta = function (recalculated, original) {
732
669
  var matchingCondition = Object.values(PercentDeltaConditions).find(function (value) { return calculatePercentDeltaConditions[value](original, recalculated); }) || 'default';
733
670
  return calculatePercentDeltaResult[matchingCondition](original, recalculated) * 100;
734
671
  };
735
- var customDeltaFuncs = (_c$2 = {},
736
- _c$2[exports.DeltaDisplayType.percent] = calculatePercentDelta,
737
- _c$2);
738
- var evaluateSuccess = function (delta) { return Math.abs(delta) < SUCCESS_CRITERION_MAX_DELTA_PERCENT
672
+ var customDeltaFuncs = (_d$2 = {},
673
+ _d$2[exports.DeltaDisplayType.percent] = calculatePercentDelta,
674
+ _d$2);
675
+ var evaluateSuccess = function (deltaValue) { return Math.abs(deltaValue) < SUCCESS_CRITERION_MAX_DELTA_PERCENT
739
676
  ? exports.DeltaColour.Success
740
- : Math.abs(delta) < WARNING_CRITERION_MAX_DELTA_PERCENT
677
+ : Math.abs(deltaValue) < WARNING_CRITERION_MAX_DELTA_PERCENT
741
678
  ? exports.DeltaColour.Warning
742
679
  : exports.DeltaColour.Danger; };
743
680
 
@@ -836,7 +773,7 @@
836
773
  this.values = [];
837
774
  }
838
775
  BlankNodeDiffsComponent.prototype.ngOnInit = function () {
839
- this.values = formatValues(this.originalValues, this.recalculatedValues);
776
+ this.values = formatDiffValues(this.originalValues, this.recalculatedValues);
840
777
  };
841
778
  return BlankNodeDiffsComponent;
842
779
  }());
@@ -855,334 +792,46 @@
855
792
  type: i0.Input
856
793
  }] } });
857
794
 
858
- var _a$4, _b$1, _c$1, _d$1, _e;
859
- var searchableTypes = [
860
- schema.NodeType.Cycle,
861
- schema.NodeType.Source
862
- ];
863
- var serializeSearchFilters = function (filters) { return Object.keys(filters || {})
864
- .filter(function (key) { return filters[key].length; })
865
- .map(function (key) { return key + "=" + filters[key].filter(Boolean).join('|'); })
866
- .join(';'); };
867
- var deserializeSearchFilters = function (filters) { return (filters || '').split(';').reduce(function (prev, curr) {
868
- var _a = __read(curr.split('='), 2), key = _a[0], values = _a[1];
869
- prev[key] = (values || '').split('|').filter(Boolean);
870
- return prev;
871
- }, {}); };
872
- var matchType = function (type) { return Object.freeze({
873
- match: { '@type': type }
874
- }); };
875
- var matchTermType = function (termType) { return Object.freeze({
876
- match: { termType: termType }
877
- }); };
878
- var matchRegex = function (key, value) {
879
- var _a;
880
- return Object.freeze({
881
- regexp: (_a = {}, _a[key] = { value: value.toString() }, _a)
882
- });
883
- };
884
- var matchQuery = function (key, value, boost) {
885
- var _a;
886
- return Object.freeze({
887
- match: (_a = {},
888
- _a[key] = Object.assign({ query: value }, (boost ? { boost: boost } : {})),
889
- _a)
890
- });
891
- };
892
- var matchExactQuery = function (key, value, boost) { return matchQuery(key + ".keyword", value, boost); };
893
- var matchNameNormalized = function (query, boost) {
894
- if (boost === void 0) { boost = 20; }
895
- return Object.freeze({
896
- match: { nameNormalized: { query: query, boost: boost } }
795
+ var _a$4, _b$1, _c$1;
796
+ var termProperties = function (term) { return Object.keys(term).filter(function (key) { return !schema.isExpandable(term[key]) && ![
797
+ 'pinned', 'expanded', 'extended', 'selected', 'loading',
798
+ '_score', '@type', '@id', '@context', 'createdAt',
799
+ 'name', 'synonyms', 'termType', 'location', 'properties', 'schemaVersion'
800
+ ].includes(key); }); };
801
+ var findPropertyById = function (_a, key) {
802
+ var defaultProperties = _a.defaultProperties;
803
+ return (defaultProperties || []).find(function (_a) {
804
+ var term = _a.term;
805
+ return term['@id'] === key;
897
806
  });
898
807
  };
899
- var numberGte = function (key, value) {
900
- var _a;
901
- return Object.freeze({
902
- range: (_a = {}, _a[key] = { gte: value }, _a)
808
+ var termLocationName = function (_a) {
809
+ var gadmFullName = _a.gadmFullName;
810
+ return ({
811
+ name: gadmFullName || ''
903
812
  });
904
813
  };
905
- var multiMatchQuery = function (query, fields, type, boost, analyzer) {
906
- if (type === void 0) { type = 'best_fields'; }
907
- return Object.freeze({
908
- multi_match: Object.assign(Object.assign({ query: query, fields: fields, type: type }, (boost ? { boost: boost } : {})), (analyzer ? { analyzer: analyzer } : {}))
814
+ var termLocation = function (_a) {
815
+ var latitude = _a.latitude, longitude = _a.longitude;
816
+ return ({
817
+ lat: latitude,
818
+ lng: longitude
909
819
  });
910
820
  };
911
- var matchPhraseQuery = function (query, boost) {
912
- var fields = [];
913
- for (var _i = 2; _i < arguments.length; _i++) {
914
- fields[_i - 2] = arguments[_i];
915
- }
916
- return fields.length ? multiMatchQuery(query, fields, 'phrase', boost) : matchExactQuery('name', query, boost);
917
- };
918
- var matchPhrasePrefixQuery = function (query, boost) {
919
- if (boost === void 0) { boost = 2; }
920
- var fields = [];
921
- for (var _i = 2; _i < arguments.length; _i++) {
922
- fields[_i - 2] = arguments[_i];
923
- }
924
- return fields.length ?
925
- multiMatchQuery(query, fields, 'phrase_prefix', boost) :
926
- Object.freeze({
927
- match_phrase_prefix: {
928
- nameSearchAsYouType: {
929
- query: query,
930
- boost: boost
931
- }
932
- }
933
- });
934
- };
935
- var matchBoolPrefixQuery = function (query, boost) {
936
- if (boost === void 0) { boost = 1; }
937
- var fields = [];
938
- for (var _i = 2; _i < arguments.length; _i++) {
939
- fields[_i - 2] = arguments[_i];
940
- }
941
- return fields.length ?
942
- multiMatchQuery(query, fields, 'bool_prefix', boost) :
943
- Object.freeze({
944
- match_bool_prefix: {
945
- name: {
946
- query: query,
947
- boost: boost
948
- }
949
- }
950
- });
951
- };
952
- var wildcardQuery = function (query, boost) {
953
- if (boost === void 0) { boost = 3; }
954
- var fields = [];
955
- for (var _i = 2; _i < arguments.length; _i++) {
956
- fields[_i - 2] = arguments[_i];
957
- }
958
- return Object.freeze({
959
- simple_query_string: {
960
- query: "*" + query + "*",
961
- fields: fields,
962
- analyze_wildcard: true,
963
- boost: boost
964
- }
965
- });
966
- };
967
- var matchCountryLevel = { match: { gadmLevel: 0 } };
968
- var matchGlobalRegion = { regexp: { '@id': 'region-*' } };
969
- var matchCountry = Object.freeze({
970
- bool: {
971
- should: [
972
- matchCountryLevel,
973
- matchGlobalRegion
974
- ],
975
- minimum_should_match: 1
976
- }
977
- });
978
- var countriesQuery = Object.freeze({
979
- bool: {
980
- must: [
981
- matchType(schema.NodeType.Term),
982
- matchTermType(schema.TermTermType.region),
983
- matchCountryLevel
984
- ]
985
- }
986
- });
987
- var allCountriesQuery = Object.freeze({
988
- bool: Object.assign({ must: [
989
- matchType(schema.NodeType.Term),
990
- matchTermType(schema.TermTermType.region)
991
- ] }, matchCountry.bool)
992
- });
993
- var matchRegion = numberGte('gadmLevel', 1);
994
- var regionsQuery = Object.freeze({
995
- bool: {
996
- must: [
997
- matchType(schema.NodeType.Term),
998
- matchTermType(schema.TermTermType.region),
999
- matchRegion
1000
- ]
1001
- }
1002
- });
1003
- var worldRegion = Object.freeze({
1004
- '@id': 'region-world',
1005
- name: 'World'
1006
- });
1007
- var cropsQuery = Object.freeze({
1008
- bool: {
1009
- must: [
1010
- matchType(schema.NodeType.Term),
1011
- matchTermType(schema.TermTermType.crop)
1012
- ]
1013
- }
1014
- });
1015
- var matchAggregatedQuery = matchQuery('aggregated', true);
1016
- var isNestedKey = function (key) { return schema.nestedSearchableKeys.includes(key.split('.')[0]); };
1017
- var matchNestedKey = function (key, query) { return isNestedKey(key) ? {
1018
- nested: { path: key.split('.')[0], query: query }
1019
- } : query; };
1020
- /**
1021
- * List of fields to return in the search results.
1022
- */
1023
- var searchResultsFields = Object.freeze((_a$4 = {},
1024
- _a$4[schema.NodeType.Cycle] = [
1025
- 'description', 'dataDescription', 'endDate',
1026
- 'emissionsCount', 'inputsCount', 'productsCount',
1027
- 'site.location', 'site.country.name', 'site.region.name'
1028
- ],
1029
- _a$4[schema.NodeType.Source] = ['bibliography.title', 'bibliography.documentDOI'],
1030
- _a$4[schema.NodeType.ImpactAssessment] = ['emissionsResourceUseCount', 'impactsCount', 'country.name'],
1031
- _a$4));
1032
- /**
1033
- * List of fields to search in.
1034
- */
1035
- var searchFields = Object.freeze((_b$1 = {},
1036
- _b$1[schema.NodeType.Cycle] = ['name', 'description', 'dataDescription'],
1037
- _b$1[schema.NodeType.Source] = ['name', 'bibliography.title'],
1038
- _b$1[schema.NodeType.ImpactAssessment] = ['name', 'product.name', 'country.name'],
1039
- _b$1));
1040
- var searchFieldsNested = Object.freeze((_c$1 = {},
1041
- _c$1[schema.NodeType.Cycle] = [
1042
- 'inputs.term.name',
1043
- 'emissions.term.name',
1044
- 'practices.term.name'
1045
- ],
1046
- _c$1[schema.NodeType.Source] = [],
1047
- _c$1[schema.NodeType.ImpactAssessment] = [
1048
- 'emissionsResourceUse.term.name',
1049
- 'impacts.term.name'
1050
- ],
1051
- _c$1));
1052
- /**
1053
- * Specific strict queries per type.
1054
- */
1055
- var searchQueries = (_d$1 = {},
1056
- _d$1[schema.NodeType.Cycle] = { must: [], must_not: [matchAggregatedQuery] },
1057
- _d$1[schema.NodeType.Source] = { must: [], must_not: [matchAggregatedQuery] },
1058
- _d$1);
1059
- var searchFiltersKeys = (_e = {},
1060
- _e[schema.NodeType.Cycle] = function (key) { return key; },
1061
- _e[schema.NodeType.Source] = function (key) { return key; },
1062
- _e);
1063
- /* eslint-disable complexity */
1064
- var searchQuery = function (type, query, filters, aggregated) {
1065
- var boolQuery = (Object.assign(Object.assign({ must: [
1066
- matchType(type),
1067
- aggregated ? matchAggregatedQuery : null
1068
- ].filter(Boolean) }, (query ? {
1069
- should: __spreadArray([
1070
- matchPhraseQuery.apply(void 0, __spreadArray([query, 100], __read(searchFields[type]))),
1071
- matchPhrasePrefixQuery.apply(void 0, __spreadArray([query, 20], __read(searchFields[type]))),
1072
- matchBoolPrefixQuery.apply(void 0, __spreadArray([query, 10], __read(searchFields[type])))
1073
- ], __read(searchFieldsNested[type].map(function (field) { return matchNestedKey(field, matchBoolPrefixQuery(query, 1, field)); }))),
1074
- minimum_should_match: 1
1075
- } : {})), { must_not: [
1076
- aggregated ? null : matchAggregatedQuery
1077
- ].filter(Boolean) }));
1078
- var keys = Object.keys(filters || {}).filter(function (key) { return filters[key].length; });
1079
- return {
1080
- bool: keys.length ? {
1081
- must: keys.map(function (key) {
1082
- var filterKey = searchFiltersKeys[type](key);
1083
- return {
1084
- bool: {
1085
- should: filters[key]
1086
- .map(function (value) { return matchNestedKey(filterKey, matchExactQuery(filterKey, value)); })
1087
- .map(function (must) {
1088
- var localQuery = JSON.parse(JSON.stringify(boolQuery));
1089
- localQuery.must.push(must);
1090
- return { bool: localQuery };
1091
- }),
1092
- minimum_should_match: 1
1093
- }
1094
- };
1095
- })
1096
- } : boolQuery
1097
- };
1098
- };
1099
- /* eslint-enable complexity */
1100
-
1101
- var primaryProduct = function (_a) {
1102
- var products = _a.products;
1103
- return (products || []).find(function (_a) {
1104
- var primary = _a.primary;
1105
- return primary;
1106
- });
1107
- };
1108
-
1109
- var HE_API_BASE_URL = new i0.InjectionToken('HE_API_BASE_URL');
1110
- var HeCommonService = /** @class */ (function () {
1111
- function HeCommonService(_apiBaseUrl) {
1112
- this._apiBaseUrl = _apiBaseUrl;
1113
- }
1114
- Object.defineProperty(HeCommonService.prototype, "apiBaseUrl", {
1115
- get: function () {
1116
- return this._apiBaseUrl || '/api';
1117
- },
1118
- enumerable: false,
1119
- configurable: true
1120
- });
1121
- Object.defineProperty(HeCommonService.prototype, "gitBranch", {
1122
- get: function () {
1123
- return ['dev', 'staging'].some(function (env) { return baseUrl().includes(env); })
1124
- ? 'develop'
1125
- : 'master';
1126
- },
1127
- enumerable: false,
1128
- configurable: true
1129
- });
1130
- return HeCommonService;
1131
- }());
1132
- HeCommonService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeCommonService, deps: [{ token: HE_API_BASE_URL }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1133
- HeCommonService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeCommonService, providedIn: 'root' });
1134
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeCommonService, decorators: [{
1135
- type: i0.Injectable,
1136
- args: [{
1137
- providedIn: 'root'
1138
- }]
1139
- }], ctorParameters: function () {
1140
- return [{ type: undefined, decorators: [{
1141
- type: i0.Inject,
1142
- args: [HE_API_BASE_URL]
1143
- }] }];
1144
- } });
1145
-
1146
- var _a$3, _b, _c;
1147
- var termProperties = function (term) { return Object.keys(term).filter(function (key) { return !schema.isExpandable(term[key]) && ![
1148
- 'pinned', 'expanded', 'extended', 'selected', 'loading',
1149
- '_score', '@type', '@id', '@context', 'createdAt',
1150
- 'name', 'synonyms', 'termType', 'location', 'properties', 'schemaVersion'
1151
- ].includes(key); }); };
1152
- var findPropertyById = function (_a, key) {
1153
- var defaultProperties = _a.defaultProperties;
1154
- return (defaultProperties || []).find(function (_a) {
1155
- var term = _a.term;
1156
- return term['@id'] === key;
1157
- });
1158
- };
1159
- var termLocationName = function (_a) {
1160
- var gadmFullName = _a.gadmFullName;
1161
- return ({
1162
- name: gadmFullName || ''
1163
- });
1164
- };
1165
- var termLocation = function (_a) {
1166
- var latitude = _a.latitude, longitude = _a.longitude;
1167
- return ({
1168
- lat: latitude,
1169
- lng: longitude
1170
- });
1171
- };
1172
- var termTypeToLabel = (_a$3 = {},
1173
- _a$3[schema.TermTermType.methodEmissionResourceUse] = 'Method (Emissions)',
1174
- _a$3[schema.TermTermType.methodMeasurement] = 'Method (Measurement)',
1175
- _a$3[schema.TermTermType.pesticideAI] = 'Pesticide Active Ingredient',
1176
- _a$3[schema.TermTermType.standardsLabels] = 'Standards & Labels',
1177
- _a$3[schema.TermTermType.usdaSoilType] = 'USDA Soil Type',
1178
- _a$3);
1179
- var termTypeLabel = function (type) {
1180
- if (type === void 0) { type = 'N/A'; }
1181
- return type in termTypeToLabel ? termTypeToLabel[type] : keyToLabel(type);
821
+ var termTypeToLabel = (_a$4 = {},
822
+ _a$4[schema.TermTermType.methodEmissionResourceUse] = 'Method (Emissions)',
823
+ _a$4[schema.TermTermType.methodMeasurement] = 'Method (Measurement)',
824
+ _a$4[schema.TermTermType.pesticideAI] = 'Pesticide Active Ingredient',
825
+ _a$4[schema.TermTermType.standardsLabels] = 'Standards & Labels',
826
+ _a$4[schema.TermTermType.usdaSoilType] = 'USDA Soil Type',
827
+ _a$4);
828
+ var termTypeLabel = function (type) {
829
+ if (type === void 0) { type = 'N/A'; }
830
+ return type in termTypeToLabel ? termTypeToLabel[type] : keyToLabel(type);
1182
831
  };
1183
832
  var termTypesToChildren = function (termTypes) { return termTypes.map(function (termType) { return ({ label: termTypeLabel(termType), termType: termType }); }); };
1184
- var groups = Object.freeze((_b = {},
1185
- _b[schema.TermTermType.emission] = {
833
+ var groups = Object.freeze((_b$1 = {},
834
+ _b$1[schema.TermTermType.emission] = {
1186
835
  label: 'Emissions & Resource Use',
1187
836
  termType: 'Emissions & Resource Use',
1188
837
  children: termTypesToChildren([
@@ -1194,12 +843,12 @@
1194
843
  schema.TermTermType.methodEmissionResourceUse
1195
844
  ])
1196
845
  },
1197
- _b[schema.TermTermType.region] = {
846
+ _b$1[schema.TermTermType.region] = {
1198
847
  label: termTypeLabel(schema.TermTermType.region),
1199
848
  termType: schema.TermTermType.region,
1200
849
  children: []
1201
850
  },
1202
- _b.infrastructure = {
851
+ _b$1.infrastructure = {
1203
852
  label: 'Infrastructure & Equipment',
1204
853
  termType: 'Infrastructure & Equipment',
1205
854
  children: termTypesToChildren([
@@ -1210,7 +859,7 @@
1210
859
  schema.TermTermType.machinery
1211
860
  ])
1212
861
  },
1213
- _b.input = {
862
+ _b$1.input = {
1214
863
  label: 'Inputs',
1215
864
  termType: 'Inputs',
1216
865
  children: termTypesToChildren([
@@ -1228,7 +877,7 @@
1228
877
  schema.TermTermType.water
1229
878
  ])
1230
879
  },
1231
- _b[schema.TermTermType.measurement] = {
880
+ _b$1[schema.TermTermType.measurement] = {
1232
881
  label: 'Measurements',
1233
882
  termType: 'Measurements',
1234
883
  children: termTypesToChildren([
@@ -1239,7 +888,7 @@
1239
888
  schema.TermTermType.methodMeasurement
1240
889
  ])
1241
890
  },
1242
- _b.practice = {
891
+ _b$1.practice = {
1243
892
  label: 'Practices',
1244
893
  termType: 'Production Practices',
1245
894
  children: termTypesToChildren([
@@ -1257,7 +906,7 @@
1257
906
  schema.TermTermType.waterRegime,
1258
907
  ])
1259
908
  },
1260
- _b.product = {
909
+ _b$1.product = {
1261
910
  label: 'Products',
1262
911
  termType: 'Products',
1263
912
  children: termTypesToChildren([
@@ -1270,12 +919,12 @@
1270
919
  schema.TermTermType.processedFood
1271
920
  ])
1272
921
  },
1273
- _b[schema.TermTermType.property] = {
922
+ _b$1[schema.TermTermType.property] = {
1274
923
  label: termTypeLabel(schema.TermTermType.property),
1275
924
  termType: schema.TermTermType.property,
1276
925
  children: []
1277
926
  },
1278
- _b));
927
+ _b$1));
1279
928
  var termTypeGroups = [
1280
929
  groups.property,
1281
930
  groups.region,
@@ -1286,10 +935,10 @@
1286
935
  groups.measurement,
1287
936
  groups.infrastructure
1288
937
  ];
1289
- var termToParent = (_c = {},
1290
- _c[schema.TermTermType.property] = 'Properties',
1291
- _c[schema.TermTermType.region] = 'Geographies',
1292
- _c);
938
+ var termToParent = (_c$1 = {},
939
+ _c$1[schema.TermTermType.property] = 'Properties',
940
+ _c$1[schema.TermTermType.region] = 'Geographies',
941
+ _c$1);
1293
942
  var termChildToParent = function (termType) { return termTypeGroups.find(function (_a) {
1294
943
  var children = _a.children;
1295
944
  return (children || []).some(function (child) { return child.termType === termType; });
@@ -1344,6 +993,52 @@
1344
993
  schema.TermTermType.standardsLabels
1345
994
  ];
1346
995
 
996
+ var HE_API_BASE_URL = new i0.InjectionToken('HE_API_BASE_URL');
997
+ var HeCommonService = /** @class */ (function () {
998
+ function HeCommonService(_apiBaseUrl) {
999
+ this._apiBaseUrl = _apiBaseUrl;
1000
+ }
1001
+ Object.defineProperty(HeCommonService.prototype, "apiBaseUrl", {
1002
+ get: function () {
1003
+ return this._apiBaseUrl || '/api';
1004
+ },
1005
+ enumerable: false,
1006
+ configurable: true
1007
+ });
1008
+ return HeCommonService;
1009
+ }());
1010
+ HeCommonService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeCommonService, deps: [{ token: HE_API_BASE_URL }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1011
+ HeCommonService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeCommonService, providedIn: 'root' });
1012
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeCommonService, decorators: [{
1013
+ type: i0.Injectable,
1014
+ args: [{
1015
+ providedIn: 'root'
1016
+ }]
1017
+ }], ctorParameters: function () {
1018
+ return [{ type: undefined, decorators: [{
1019
+ type: i0.Inject,
1020
+ args: [HE_API_BASE_URL]
1021
+ }] }];
1022
+ } });
1023
+
1024
+ var nodeTypeUrl = function (apiBaseUrl, type) { return type ? apiBaseUrl + "/" + api.nodeTypeToParam(type) : ''; };
1025
+ /**
1026
+ * Get the full url to fetch the node data.
1027
+ *
1028
+ * @param apiBaseUrl The url of the API hosting the data.
1029
+ * @param node The node with a type, id and optionally a dataState
1030
+ * @returns The full url.
1031
+ */
1032
+ var nodeUrl = function (apiBaseUrl, _a) {
1033
+ var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1034
+ return nodeTypeUrl(apiBaseUrl, node['@type'] || node.type) + "/" + (node['@id'] || node.id) + (dataState ? "?dataState=" + dataState : '');
1035
+ };
1036
+ var nodeLogsUrl = function (apiBaseUrl, _a) {
1037
+ var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1038
+ return nodeUrl(apiBaseUrl, node) + "/log" + (dataState ? "?dataState=" + dataState : '');
1039
+ };
1040
+ var lookupUrl = function (filename) { return filename.startsWith('http') ? filename : baseUrl() + "/glossary/lookups/" + filename + ".csv"; };
1041
+ var termTypeLookupUrl = function (termType) { return baseUrl() + "/glossary/" + termChildToParent(termType).termType + "/" + termType + ".csv"; };
1347
1042
  var HeNodeService = /** @class */ (function () {
1348
1043
  function HeNodeService(http, authService, commonService) {
1349
1044
  this.http = http;
@@ -1398,28 +1093,20 @@
1398
1093
  .catch(function () { return (responseType === 'json' ? ({}) : ''); });
1399
1094
  };
1400
1095
  HeNodeService.prototype.nodeTypeUrl = function (type) {
1401
- return this.commonService.apiBaseUrl + "/" + api.nodeTypeToParam(type);
1402
- };
1403
- HeNodeService.prototype.nodeUrl = function (_a) {
1404
- var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1405
- return this.nodeTypeUrl(node['@type'] || node.type) + "/" + (node['@id'] || node.id) + (dataState ? "?dataState=" + dataState : '');
1096
+ return nodeTypeUrl(this.commonService.apiBaseUrl, type);
1406
1097
  };
1407
- HeNodeService.prototype.nodeLogsUrl = function (_a) {
1408
- var dataState = _a.dataState, node = __rest(_a, ["dataState"]);
1409
- return this.nodeUrl(node) + "/log" + (dataState ? "?dataState=" + dataState : '');
1410
- };
1411
- HeNodeService.prototype.lookupUrl = function (filename) {
1412
- return filename.startsWith('http') ? filename : baseUrl() + "/glossary/lookups/" + filename + ".csv";
1098
+ HeNodeService.prototype.nodeUrl = function (node) {
1099
+ return nodeUrl(this.commonService.apiBaseUrl, node);
1413
1100
  };
1414
- HeNodeService.prototype.termTypeLookupUrl = function (termType) {
1415
- return baseUrl() + "/glossary/" + termChildToParent(termType).termType + "/" + termType + ".csv";
1101
+ HeNodeService.prototype.nodeLogsUrl = function (node) {
1102
+ return nodeLogsUrl(this.commonService.apiBaseUrl, node);
1416
1103
  };
1417
1104
  HeNodeService.prototype.downloadLookup = function (filename) {
1418
1105
  return __awaiter(this, void 0, void 0, function () {
1419
1106
  var url;
1420
1107
  return __generator(this, function (_b) {
1421
1108
  try {
1422
- url = this.lookupUrl(filename);
1109
+ url = lookupUrl(filename);
1423
1110
  return [2 /*return*/, this.downloadRaw(url, 'text')];
1424
1111
  }
1425
1112
  catch (_err) {
@@ -1439,7 +1126,7 @@
1439
1126
  return [4 /*yield*/, this.downloadLookup(termType)];
1440
1127
  case 1:
1441
1128
  data = _b.sent();
1442
- return [2 /*return*/, (data === null || data === void 0 ? void 0 : data.startsWith('term.id')) ? this.lookupUrl(termType) : null];
1129
+ return [2 /*return*/, (data === null || data === void 0 ? void 0 : data.startsWith('term.id')) ? lookupUrl(termType) : null];
1443
1130
  case 2:
1444
1131
  _err_1 = _b.sent();
1445
1132
  return [2 /*return*/, null];
@@ -1459,54 +1146,15 @@
1459
1146
  }]
1460
1147
  }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeAuthService }, { type: HeCommonService }]; } });
1461
1148
 
1462
- var get$4 = require('lodash.get');
1149
+ var gitUrl$1 = function () { return gitHome + "/hestia-aggregation-engine/-/blob/" + gitBranch(); };
1150
+ var rawUrl$1 = function () { return gitRawBaseUrl + "/hestia-aggregation-engine/-/raw/" + gitBranch(); };
1463
1151
  var lookups = Object.freeze({
1464
1152
  cropYield: 'region-crop-cropGroupingFaostatProduction-yield',
1465
1153
  cropGroupingColumn: 'cropGroupingFaostatProduction'
1466
1154
  });
1467
- var extractGroupedDataClosesDate = function (data, year) {
1468
- var dataByDate = (data || '').split(';').reduce(function (prev, curr) {
1469
- var _d;
1470
- return (Object.assign(Object.assign({}, prev), (curr.length > 0 && curr.split(':')[1] !== '-' ? (_d = {}, _d[curr.split(':')[0]] = curr.split(':')[1], _d) : {})));
1471
- }, {});
1472
- var years = Object.keys(dataByDate).map(function (v) { return +v; });
1473
- var closestYear = years.reduce(function (prev, curr) { return Math.abs(curr - year) < Math.abs(prev - year) ? curr : prev; }, 0);
1474
- return closestYear ? +dataByDate[closestYear] / 10 : null;
1475
- };
1476
- var cropGrouping = function (lookup, product) { return (lookup.find(function (_d) {
1477
- var term = _d.term;
1478
- return term.id === (product === null || product === void 0 ? void 0 : product.term['@id']);
1479
- }) || {})[lookups.cropGroupingColumn]; };
1480
- var cropYieldCountry = function (cropYield, cycle) { return cropYield.find(function (_d) {
1481
- var term = _d.term;
1482
- return term.id === get$4(cycle, 'site.country.@id', worldRegion['@id']);
1483
- }) || {}; };
1484
- var extendCycle = function (_d) {
1485
- var crop = _d.crop, cropYield = _d.cropYield;
1486
- return function (cycle) {
1487
- var _a, _b, _c;
1488
- var product = primaryProduct(cycle);
1489
- var grouping = cropGrouping(crop, product);
1490
- var countryData = cropYieldCountry(cropYield, cycle)[grouping];
1491
- var countryValue = extractGroupedDataClosesDate(countryData, +(cycle.endDate || ''));
1492
- var productValue = propertyValue$1(product === null || product === void 0 ? void 0 : product.value);
1493
- return {
1494
- cycle: cycle,
1495
- name: (_a = product === null || product === void 0 ? void 0 : product.term) === null || _a === void 0 ? void 0 : _a.name,
1496
- startDate: cycle.startDate,
1497
- endDate: cycle.endDate,
1498
- country: ((_c = (_b = cycle.site) === null || _b === void 0 ? void 0 : _b.country) === null || _c === void 0 ? void 0 : _c.name) || worldRegion.name,
1499
- observations: propertyValue$1(product === null || product === void 0 ? void 0 : product.observations) || 0,
1500
- yield: productValue,
1501
- faoYield: countryValue || undefined,
1502
- diff: delta(productValue, countryValue)
1503
- };
1504
- };
1505
- };
1506
1155
  var HeAggregationEngineService = /** @class */ (function () {
1507
- function HeAggregationEngineService(http, commonService, nodeService) {
1156
+ function HeAggregationEngineService(http, nodeService) {
1508
1157
  this.http = http;
1509
- this.commonService = commonService;
1510
1158
  this.nodeService = nodeService;
1511
1159
  this.modelsLoading = false;
1512
1160
  this.modelsLoaded = false;
@@ -1518,38 +1166,24 @@
1518
1166
  }
1519
1167
  HeAggregationEngineService.prototype.init = function () {
1520
1168
  return __awaiter(this, void 0, void 0, function () {
1521
- return __generator(this, function (_d) {
1522
- switch (_d.label) {
1169
+ return __generator(this, function (_b) {
1170
+ switch (_b.label) {
1523
1171
  case 0: return [4 /*yield*/, this.loadModels().toPromise()];
1524
1172
  case 1:
1525
- _d.sent();
1173
+ _b.sent();
1526
1174
  return [2 /*return*/];
1527
1175
  }
1528
1176
  });
1529
1177
  });
1530
1178
  };
1531
- Object.defineProperty(HeAggregationEngineService.prototype, "gitUrl", {
1532
- get: function () {
1533
- return gitHome + "/hestia-aggregation-engine/-/blob/" + this.commonService.gitBranch;
1534
- },
1535
- enumerable: false,
1536
- configurable: true
1537
- });
1538
- Object.defineProperty(HeAggregationEngineService.prototype, "rawUrl", {
1539
- get: function () {
1540
- return gitRawBaseUrl + "/hestia-aggregation-engine/-/raw/" + this.commonService.gitBranch;
1541
- },
1542
- enumerable: false,
1543
- configurable: true
1544
- });
1545
1179
  HeAggregationEngineService.prototype.loadModels = function () {
1546
1180
  var _this = this;
1547
1181
  this.modelsLoading = true;
1548
- return this.http.get(this.rawUrl + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_d) {
1549
- var links = _d.links;
1182
+ return this.http.get(rawUrl$1() + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_b) {
1183
+ var links = _b.links;
1550
1184
  _this._models.next(links.map(function (_a) {
1551
1185
  var modelPath = _a.path, docPath = _a.docPath, link = __rest(_a, ["path", "docPath"]);
1552
- return (Object.assign(Object.assign({}, link), { path: _this.gitUrl + "/" + modelPath, docPath: _this.gitUrl + "/" + docPath }));
1186
+ return (Object.assign(Object.assign({}, link), { path: gitUrl$1() + "/" + modelPath, docPath: gitUrl$1() + "/" + docPath }));
1553
1187
  }));
1554
1188
  _this.modelsLoading = false;
1555
1189
  _this.modelsLoaded = true;
@@ -1575,11 +1209,11 @@
1575
1209
  HeAggregationEngineService.prototype.loadLookup = function (filename) {
1576
1210
  return __awaiter(this, void 0, void 0, function () {
1577
1211
  var data;
1578
- return __generator(this, function (_d) {
1579
- switch (_d.label) {
1212
+ return __generator(this, function (_b) {
1213
+ switch (_b.label) {
1580
1214
  case 0: return [4 /*yield*/, this.nodeService.downloadLookup(filename)];
1581
1215
  case 1:
1582
- data = _d.sent();
1216
+ data = _b.sent();
1583
1217
  return [2 /*return*/, csvtojson__namespace({ delimiter: 'auto' }).fromString(data)];
1584
1218
  }
1585
1219
  });
@@ -1609,16 +1243,18 @@
1609
1243
  };
1610
1244
  return HeAggregationEngineService;
1611
1245
  }());
1612
- HeAggregationEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, deps: [{ token: i1__namespace$1.HttpClient }, { token: HeCommonService }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1246
+ HeAggregationEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, deps: [{ token: i1__namespace$1.HttpClient }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1613
1247
  HeAggregationEngineService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, providedIn: 'root' });
1614
1248
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeAggregationEngineService, decorators: [{
1615
1249
  type: i0.Injectable,
1616
1250
  args: [{
1617
1251
  providedIn: 'root'
1618
1252
  }]
1619
- }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeCommonService }, { type: HeNodeService }]; } });
1253
+ }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeNodeService }]; } });
1620
1254
 
1621
1255
  var HE_ORCHESTRATOR_BASE_URL = new i0.InjectionToken('HE_ORCHESTRATOR_BASE_URL');
1256
+ var gitUrl = function () { return gitHome + "/hestia-engine-models/-/blob/" + gitBranch(); };
1257
+ var rawUrl = function () { return gitRawBaseUrl + "/hestia-engine-models/-/raw/" + gitBranch(); };
1622
1258
  var findConfigModels = function (_b, modelId, modelKey) {
1623
1259
  var models = _b.models;
1624
1260
  return models.flat().filter(function (_b) {
@@ -1636,9 +1272,8 @@
1636
1272
  ].filter(Boolean).join('-')
1637
1273
  ].join('/'); };
1638
1274
  var HeEngineService = /** @class */ (function () {
1639
- function HeEngineService(http, commonService) {
1275
+ function HeEngineService(http) {
1640
1276
  this.http = http;
1641
- this.commonService = commonService;
1642
1277
  this.modelsLoading = false;
1643
1278
  this.modelsLoaded = false;
1644
1279
  this._models = new rxjs.ReplaySubject(1);
@@ -1656,28 +1291,14 @@
1656
1291
  });
1657
1292
  });
1658
1293
  };
1659
- Object.defineProperty(HeEngineService.prototype, "gitUrl", {
1660
- get: function () {
1661
- return gitHome + "/hestia-engine-models/-/blob/" + this.commonService.gitBranch;
1662
- },
1663
- enumerable: false,
1664
- configurable: true
1665
- });
1666
- Object.defineProperty(HeEngineService.prototype, "rawUrl", {
1667
- get: function () {
1668
- return gitRawBaseUrl + "/hestia-engine-models/-/raw/" + this.commonService.gitBranch;
1669
- },
1670
- enumerable: false,
1671
- configurable: true
1672
- });
1673
1294
  HeEngineService.prototype.loadModels = function () {
1674
1295
  var _this = this;
1675
1296
  this.modelsLoading = true;
1676
- return this.http.get(this.rawUrl + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_b) {
1297
+ return this.http.get(rawUrl() + "/model-links.json").pipe(operators.catchError(function () { return rxjs.of({ links: [] }); }), operators.map(function (_b) {
1677
1298
  var links = _b.links;
1678
1299
  _this._models.next(links.map(function (_a) {
1679
1300
  var path = _a.path, docPath = _a.docPath, link = __rest(_a, ["path", "docPath"]);
1680
- return (Object.assign(Object.assign({}, link), { path: _this.gitUrl + "/" + path, docPath: _this.gitUrl + "/" + docPath, apiDocsPath: pathToApiDocsPath(link.model, link.term || link.modelKey) }));
1301
+ return (Object.assign(Object.assign({}, link), { path: gitUrl() + "/" + path, docPath: gitUrl() + "/" + docPath, apiDocsPath: pathToApiDocsPath(link.model, link.term || link.modelKey) }));
1681
1302
  }));
1682
1303
  _this.modelsLoading = false;
1683
1304
  _this.modelsLoaded = true;
@@ -1707,14 +1328,14 @@
1707
1328
  };
1708
1329
  return HeEngineService;
1709
1330
  }());
1710
- HeEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, deps: [{ token: i1__namespace$1.HttpClient }, { token: HeCommonService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1331
+ HeEngineService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, deps: [{ token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1711
1332
  HeEngineService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, providedIn: 'root' });
1712
1333
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeEngineService, decorators: [{
1713
1334
  type: i0.Injectable,
1714
1335
  args: [{
1715
1336
  providedIn: 'root'
1716
1337
  }]
1717
- }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeCommonService }]; } });
1338
+ }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }]; } });
1718
1339
 
1719
1340
  var NodeKeyState;
1720
1341
  (function (NodeKeyState) {
@@ -2390,11 +2011,11 @@
2390
2011
  }] } });
2391
2012
 
2392
2013
  var toastId = 0;
2393
- var ToastService = /** @class */ (function () {
2394
- function ToastService() {
2014
+ var HeToastService = /** @class */ (function () {
2015
+ function HeToastService() {
2395
2016
  this.toasts = new rxjs.ReplaySubject(1);
2396
2017
  }
2397
- ToastService.prototype.success = function (message, duration) {
2018
+ HeToastService.prototype.success = function (message, duration) {
2398
2019
  if (duration === void 0) { duration = 3000; }
2399
2020
  this.toasts.next({
2400
2021
  id: ++toastId,
@@ -2404,7 +2025,7 @@
2404
2025
  showRawMessage: true
2405
2026
  });
2406
2027
  };
2407
- ToastService.prototype.error = function (message, showRawMessage, duration) {
2028
+ HeToastService.prototype.error = function (message, showRawMessage, duration) {
2408
2029
  if (showRawMessage === void 0) { showRawMessage = true; }
2409
2030
  if (duration === void 0) { duration = 3000; }
2410
2031
  this.toasts.next({
@@ -2415,11 +2036,11 @@
2415
2036
  showRawMessage: showRawMessage
2416
2037
  });
2417
2038
  };
2418
- return ToastService;
2039
+ return HeToastService;
2419
2040
  }());
2420
- ToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2421
- ToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastService, providedIn: 'root' });
2422
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastService, decorators: [{
2041
+ HeToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2042
+ HeToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeToastService, providedIn: 'root' });
2043
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeToastService, decorators: [{
2423
2044
  type: i0.Injectable,
2424
2045
  args: [{
2425
2046
  providedIn: 'root'
@@ -2451,7 +2072,7 @@
2451
2072
  };
2452
2073
  return ToastComponent;
2453
2074
  }());
2454
- ToastComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastComponent, deps: [{ token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
2075
+ ToastComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastComponent, deps: [{ token: HeToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
2455
2076
  ToastComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ToastComponent, selector: "he-toast", ngImport: i0__namespace, template: "<div class=\"mb-3 columns is-centered is-vcentered\">\n <div class=\"notification is-{{toast.color}}\" role=\"alert\" *ngFor=\"let toast of toasts\">\n <button class=\"delete\" aria-label=\"delete\" (click)=\"dismiss(toast)\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n <strong [ngSwitch]=\"toast.color\">\n <ng-container *ngSwitchCase=\"'danger'\">\n <ng-container [ngSwitch]=\"toast.message\">\n <span *ngSwitchCase=\"'Unauthorized'\">You are not allowed to perform this action.</span>\n <span *ngSwitchCase=\"'form-invalid'\">Please fix all the errors on this page.</span>\n <span *ngSwitchCase=\"'users-email-already-taken'\">Email already taken.</span>\n <span *ngSwitchCase=\"'users-auth-already-taken'\">Account already connected.</span>\n <span *ngSwitchDefault>\n <span *ngIf=\"toast.showRawMessage\">{{toast.message}}</span>\n <span [class.is-hidden]=\"toast.showRawMessage\">An unknown error occurred. Please try again later.</span>\n </span>\n </ng-container>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <span *ngIf=\"toast.showRawMessage\">{{toast.message}}</span>\n <span [class.is-hidden]=\"toast.showRawMessage\">An unknown error occurred. Please try again later.</span>\n </ng-container>\n </strong>\n </div>\n</div>\n", styles: [":host{bottom:0;position:fixed;width:100%}\n"], directives: [{ type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i3__namespace.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2456
2077
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ToastComponent, decorators: [{
2457
2078
  type: i0.Component,
@@ -2460,7 +2081,7 @@
2460
2081
  templateUrl: './toast.component.html',
2461
2082
  styleUrls: ['./toast.component.scss']
2462
2083
  }]
2463
- }], ctorParameters: function () { return [{ type: ToastService }]; } });
2084
+ }], ctorParameters: function () { return [{ type: HeToastService }]; } });
2464
2085
 
2465
2086
  var KeysPipe = /** @class */ (function () {
2466
2087
  function KeysPipe() {
@@ -2944,26 +2565,269 @@
2944
2565
  }]
2945
2566
  }], ctorParameters: function () { return [{ type: i1__namespace$1.HttpClient }, { type: HeCommonService }]; } });
2946
2567
 
2947
- var emptySearchResult = function () { return ({
2948
- time: 0,
2949
- count: 0,
2950
- results: []
2568
+ var _a$3, _b, _c, _d$1, _e;
2569
+ var searchableTypes = [
2570
+ schema.NodeType.Cycle,
2571
+ schema.NodeType.Source
2572
+ ];
2573
+ var serializeSearchFilters = function (filters) { return Object.keys(filters || {})
2574
+ .filter(function (key) { return filters[key].length; })
2575
+ .map(function (key) { return key + "=" + filters[key].filter(Boolean).join('|'); })
2576
+ .join(';'); };
2577
+ var deserializeSearchFilters = function (filters) { return (filters || '').split(';').reduce(function (prev, curr) {
2578
+ var _a = __read(curr.split('='), 2), key = _a[0], values = _a[1];
2579
+ prev[key] = (values || '').split('|').filter(Boolean);
2580
+ return prev;
2581
+ }, {}); };
2582
+ var matchType = function (type) { return Object.freeze({
2583
+ match: { '@type': type }
2951
2584
  }); };
2952
- var MAX_RESULTS = 10000;
2953
- var suggestMatchQuery = function (query) { return [
2954
- matchPhraseQuery(query, 10),
2955
- matchQuery('nameNormalized', query, 8),
2956
- matchPhrasePrefixQuery(query, 2)
2957
- ]; };
2958
- var suggestQuery = function (query, type, extraQueries) {
2959
- if (extraQueries === void 0) { extraQueries = []; }
2960
- return ({
2961
- bool: {
2962
- must: extraQueries,
2963
- should: (type ? [type] : searchableTypes).map(function (v) { return ({
2964
- bool: {
2965
- must: [matchType(v)],
2966
- should: suggestMatchQuery(query),
2585
+ var matchTermType = function (termType) { return Object.freeze({
2586
+ match: { termType: termType }
2587
+ }); };
2588
+ var matchRegex = function (key, value) {
2589
+ var _a;
2590
+ return Object.freeze({
2591
+ regexp: (_a = {}, _a[key] = { value: value.toString() }, _a)
2592
+ });
2593
+ };
2594
+ var matchQuery = function (key, value, boost) {
2595
+ var _a;
2596
+ return Object.freeze({
2597
+ match: (_a = {},
2598
+ _a[key] = Object.assign({ query: value }, (boost ? { boost: boost } : {})),
2599
+ _a)
2600
+ });
2601
+ };
2602
+ var matchExactQuery = function (key, value, boost) { return matchQuery(key + ".keyword", value, boost); };
2603
+ var matchNameNormalized = function (query, boost) {
2604
+ if (boost === void 0) { boost = 20; }
2605
+ return Object.freeze({
2606
+ match: { nameNormalized: { query: query, boost: boost } }
2607
+ });
2608
+ };
2609
+ var numberGte = function (key, value) {
2610
+ var _a;
2611
+ return Object.freeze({
2612
+ range: (_a = {}, _a[key] = { gte: value }, _a)
2613
+ });
2614
+ };
2615
+ var multiMatchQuery = function (query, fields, type, boost, analyzer) {
2616
+ if (type === void 0) { type = 'best_fields'; }
2617
+ return Object.freeze({
2618
+ multi_match: Object.assign(Object.assign({ query: query, fields: fields, type: type }, (boost ? { boost: boost } : {})), (analyzer ? { analyzer: analyzer } : {}))
2619
+ });
2620
+ };
2621
+ var matchPhraseQuery = function (query, boost) {
2622
+ var fields = [];
2623
+ for (var _i = 2; _i < arguments.length; _i++) {
2624
+ fields[_i - 2] = arguments[_i];
2625
+ }
2626
+ return fields.length ? multiMatchQuery(query, fields, 'phrase', boost) : matchExactQuery('name', query, boost);
2627
+ };
2628
+ var matchPhrasePrefixQuery = function (query, boost) {
2629
+ if (boost === void 0) { boost = 2; }
2630
+ var fields = [];
2631
+ for (var _i = 2; _i < arguments.length; _i++) {
2632
+ fields[_i - 2] = arguments[_i];
2633
+ }
2634
+ return fields.length ?
2635
+ multiMatchQuery(query, fields, 'phrase_prefix', boost) :
2636
+ Object.freeze({
2637
+ match_phrase_prefix: {
2638
+ nameSearchAsYouType: {
2639
+ query: query,
2640
+ boost: boost
2641
+ }
2642
+ }
2643
+ });
2644
+ };
2645
+ var matchBoolPrefixQuery = function (query, boost) {
2646
+ if (boost === void 0) { boost = 1; }
2647
+ var fields = [];
2648
+ for (var _i = 2; _i < arguments.length; _i++) {
2649
+ fields[_i - 2] = arguments[_i];
2650
+ }
2651
+ return fields.length ?
2652
+ multiMatchQuery(query, fields, 'bool_prefix', boost) :
2653
+ Object.freeze({
2654
+ match_bool_prefix: {
2655
+ name: {
2656
+ query: query,
2657
+ boost: boost
2658
+ }
2659
+ }
2660
+ });
2661
+ };
2662
+ var wildcardQuery = function (query, boost) {
2663
+ if (boost === void 0) { boost = 3; }
2664
+ var fields = [];
2665
+ for (var _i = 2; _i < arguments.length; _i++) {
2666
+ fields[_i - 2] = arguments[_i];
2667
+ }
2668
+ return Object.freeze({
2669
+ simple_query_string: {
2670
+ query: "*" + query + "*",
2671
+ fields: fields,
2672
+ analyze_wildcard: true,
2673
+ boost: boost
2674
+ }
2675
+ });
2676
+ };
2677
+ var matchCountryLevel = { match: { gadmLevel: 0 } };
2678
+ var matchGlobalRegion = { regexp: { '@id': 'region-*' } };
2679
+ var matchCountry = Object.freeze({
2680
+ bool: {
2681
+ should: [
2682
+ matchCountryLevel,
2683
+ matchGlobalRegion
2684
+ ],
2685
+ minimum_should_match: 1
2686
+ }
2687
+ });
2688
+ var countriesQuery = Object.freeze({
2689
+ bool: {
2690
+ must: [
2691
+ matchType(schema.NodeType.Term),
2692
+ matchTermType(schema.TermTermType.region),
2693
+ matchCountryLevel
2694
+ ]
2695
+ }
2696
+ });
2697
+ var allCountriesQuery = Object.freeze({
2698
+ bool: Object.assign({ must: [
2699
+ matchType(schema.NodeType.Term),
2700
+ matchTermType(schema.TermTermType.region)
2701
+ ] }, matchCountry.bool)
2702
+ });
2703
+ var matchRegion = numberGte('gadmLevel', 1);
2704
+ var regionsQuery = Object.freeze({
2705
+ bool: {
2706
+ must: [
2707
+ matchType(schema.NodeType.Term),
2708
+ matchTermType(schema.TermTermType.region),
2709
+ matchRegion
2710
+ ]
2711
+ }
2712
+ });
2713
+ var worldRegion = Object.freeze({
2714
+ '@id': 'region-world',
2715
+ name: 'World'
2716
+ });
2717
+ var cropsQuery = Object.freeze({
2718
+ bool: {
2719
+ must: [
2720
+ matchType(schema.NodeType.Term),
2721
+ matchTermType(schema.TermTermType.crop)
2722
+ ]
2723
+ }
2724
+ });
2725
+ var matchAggregatedQuery = matchQuery('aggregated', true);
2726
+ var isNestedKey = function (key) { return schema.nestedSearchableKeys.includes(key.split('.')[0]); };
2727
+ var matchNestedKey = function (key, query) { return isNestedKey(key) ? {
2728
+ nested: { path: key.split('.')[0], query: query }
2729
+ } : query; };
2730
+ /**
2731
+ * List of fields to return in the search results.
2732
+ */
2733
+ var searchResultsFields = Object.freeze((_a$3 = {},
2734
+ _a$3[schema.NodeType.Cycle] = [
2735
+ 'description', 'dataDescription', 'endDate',
2736
+ 'emissionsCount', 'inputsCount', 'productsCount',
2737
+ 'site.location', 'site.country.name', 'site.region.name'
2738
+ ],
2739
+ _a$3[schema.NodeType.Source] = ['bibliography.title', 'bibliography.documentDOI'],
2740
+ _a$3[schema.NodeType.ImpactAssessment] = ['emissionsResourceUseCount', 'impactsCount', 'country.name'],
2741
+ _a$3));
2742
+ /**
2743
+ * List of fields to search in.
2744
+ */
2745
+ var searchFields = Object.freeze((_b = {},
2746
+ _b[schema.NodeType.Cycle] = ['name', 'description', 'dataDescription'],
2747
+ _b[schema.NodeType.Source] = ['name', 'bibliography.title'],
2748
+ _b[schema.NodeType.ImpactAssessment] = ['name', 'product.name', 'country.name'],
2749
+ _b));
2750
+ var searchFieldsNested = Object.freeze((_c = {},
2751
+ _c[schema.NodeType.Cycle] = [
2752
+ 'inputs.term.name',
2753
+ 'emissions.term.name',
2754
+ 'practices.term.name'
2755
+ ],
2756
+ _c[schema.NodeType.Source] = [],
2757
+ _c[schema.NodeType.ImpactAssessment] = [
2758
+ 'emissionsResourceUse.term.name',
2759
+ 'impacts.term.name'
2760
+ ],
2761
+ _c));
2762
+ /**
2763
+ * Specific strict queries per type.
2764
+ */
2765
+ var searchQueries = (_d$1 = {},
2766
+ _d$1[schema.NodeType.Cycle] = { must: [], must_not: [matchAggregatedQuery] },
2767
+ _d$1[schema.NodeType.Source] = { must: [], must_not: [matchAggregatedQuery] },
2768
+ _d$1);
2769
+ var searchFiltersKeys = (_e = {},
2770
+ _e[schema.NodeType.Cycle] = function (key) { return key; },
2771
+ _e[schema.NodeType.Source] = function (key) { return key; },
2772
+ _e);
2773
+ /* eslint-disable complexity */
2774
+ var searchQuery = function (type, query, filters, aggregated) {
2775
+ var boolQuery = (Object.assign(Object.assign({ must: [
2776
+ matchType(type),
2777
+ aggregated ? matchAggregatedQuery : null
2778
+ ].filter(Boolean) }, (query ? {
2779
+ should: __spreadArray([
2780
+ matchPhraseQuery.apply(void 0, __spreadArray([query, 100], __read(searchFields[type]))),
2781
+ matchPhrasePrefixQuery.apply(void 0, __spreadArray([query, 20], __read(searchFields[type]))),
2782
+ matchBoolPrefixQuery.apply(void 0, __spreadArray([query, 10], __read(searchFields[type])))
2783
+ ], __read(searchFieldsNested[type].map(function (field) { return matchNestedKey(field, matchBoolPrefixQuery(query, 1, field)); }))),
2784
+ minimum_should_match: 1
2785
+ } : {})), { must_not: [
2786
+ aggregated ? null : matchAggregatedQuery
2787
+ ].filter(Boolean) }));
2788
+ var keys = Object.keys(filters || {}).filter(function (key) { return filters[key].length; });
2789
+ return {
2790
+ bool: keys.length ? {
2791
+ must: keys.map(function (key) {
2792
+ var filterKey = searchFiltersKeys[type](key);
2793
+ return {
2794
+ bool: {
2795
+ should: filters[key]
2796
+ .map(function (value) { return matchNestedKey(filterKey, matchExactQuery(filterKey, value)); })
2797
+ .map(function (must) {
2798
+ var localQuery = JSON.parse(JSON.stringify(boolQuery));
2799
+ localQuery.must.push(must);
2800
+ return { bool: localQuery };
2801
+ }),
2802
+ minimum_should_match: 1
2803
+ }
2804
+ };
2805
+ })
2806
+ } : boolQuery
2807
+ };
2808
+ };
2809
+ /* eslint-enable complexity */
2810
+
2811
+ var emptySearchResult = function () { return ({
2812
+ time: 0,
2813
+ count: 0,
2814
+ results: []
2815
+ }); };
2816
+ var MAX_RESULTS = 10000;
2817
+ var suggestMatchQuery = function (query) { return [
2818
+ matchPhraseQuery(query, 10),
2819
+ matchQuery('nameNormalized', query, 8),
2820
+ matchPhrasePrefixQuery(query, 2)
2821
+ ]; };
2822
+ var suggestQuery = function (query, type, extraQueries) {
2823
+ if (extraQueries === void 0) { extraQueries = []; }
2824
+ return ({
2825
+ bool: {
2826
+ must: extraQueries,
2827
+ should: (type ? [type] : searchableTypes).map(function (v) { return ({
2828
+ bool: {
2829
+ must: [matchType(v)],
2830
+ should: suggestMatchQuery(query),
2967
2831
  minimum_should_match: 1
2968
2832
  }
2969
2833
  }); }),
@@ -3234,6 +3098,14 @@
3234
3098
  emptyFieldValue: ''
3235
3099
  }); };
3236
3100
 
3101
+ var primaryProduct = function (_a) {
3102
+ var products = _a.products;
3103
+ return (products || []).find(function (_a) {
3104
+ var primary = _a.primary;
3105
+ return primary;
3106
+ });
3107
+ };
3108
+
3237
3109
  var _a$1;
3238
3110
  var linkTypeEnabled = function (type) { return [
3239
3111
  schema.NodeType.Cycle,
@@ -3653,11 +3525,11 @@
3653
3525
  type: i0.Output
3654
3526
  }] } });
3655
3527
 
3656
- var DisplayType;
3657
- (function (DisplayType) {
3658
- DisplayType["diffs"] = "diffs";
3659
- DisplayType["sideBySide"] = "side-by-side";
3660
- })(DisplayType || (DisplayType = {}));
3528
+ exports.DiffsDisplayType = void 0;
3529
+ (function (DiffsDisplayType) {
3530
+ DiffsDisplayType["diffs"] = "diffs";
3531
+ DiffsDisplayType["sideBySide"] = "side-by-side";
3532
+ })(exports.DiffsDisplayType || (exports.DiffsDisplayType = {}));
3661
3533
 
3662
3534
  var omit = require('lodash.omit');
3663
3535
  var ignoreProperties = [
@@ -3673,9 +3545,9 @@
3673
3545
  var NodeDiffsComponent = /** @class */ (function () {
3674
3546
  function NodeDiffsComponent(nodeService) {
3675
3547
  this.nodeService = nodeService;
3676
- this.displayType = DisplayType.diffs;
3548
+ this.displayType = exports.DiffsDisplayType.diffs;
3677
3549
  this.diffsLoaded = new i0.EventEmitter();
3678
- this.DisplayType = DisplayType;
3550
+ this.DiffsDisplayType = exports.DiffsDisplayType;
3679
3551
  this.loading = true;
3680
3552
  }
3681
3553
  NodeDiffsComponent.prototype.ngOnInit = function () {
@@ -3709,7 +3581,7 @@
3709
3581
  return NodeDiffsComponent;
3710
3582
  }());
3711
3583
  NodeDiffsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: NodeDiffsComponent, deps: [{ token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
3712
- NodeDiffsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: NodeDiffsComponent, selector: "he-node-diffs", inputs: { data: "data", id: "id", type: "type", displayType: "displayType" }, outputs: { diffsLoaded: "diffsLoaded" }, ngImport: i0__namespace, template: "<div *ngIf=\"loading\" class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n</div>\n\n<ng-container *ngIf=\"left && right\">\n <ng-container [ngSwitch]=\"displayType\">\n <div *ngSwitchCase=\"DisplayType.diffs\" [innerHTML]=\"diffHtml\"></div>\n\n <div *ngSwitchCase=\"DisplayType.sideBySide\" class=\"columns\">\n <div class=\"column is-6\">\n <pre class=\"has-background-black has-text-white\"><code>{{left | json}}</code></pre>\n </div>\n <div class=\"column is-6\">\n <pre class=\"has-background-black has-text-white\"><code>{{right | json}}</code></pre>\n </div>\n </div>\n </ng-container>\n</ng-container>\n", styles: [""], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }], pipes: { "json": i3__namespace.JsonPipe } });
3584
+ NodeDiffsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: NodeDiffsComponent, selector: "he-node-diffs", inputs: { data: "data", id: "id", type: "type", displayType: "displayType" }, outputs: { diffsLoaded: "diffsLoaded" }, ngImport: i0__namespace, template: "<div *ngIf=\"loading\" class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n</div>\n\n<ng-container *ngIf=\"left && right\">\n <ng-container [ngSwitch]=\"displayType\">\n <div *ngSwitchCase=\"DiffsDisplayType.diffs\" [innerHTML]=\"diffHtml\"></div>\n\n <div *ngSwitchCase=\"DiffsDisplayType.sideBySide\" class=\"columns\">\n <div class=\"column is-6\">\n <pre class=\"has-background-black has-text-white\"><code>{{left | json}}</code></pre>\n </div>\n <div class=\"column is-6\">\n <pre class=\"has-background-black has-text-white\"><code>{{right | json}}</code></pre>\n </div>\n </div>\n </ng-container>\n</ng-container>\n", styles: [""], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }], pipes: { "json": i3__namespace.JsonPipe } });
3713
3585
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: NodeDiffsComponent, decorators: [{
3714
3586
  type: i0.Component,
3715
3587
  args: [{
@@ -4909,443 +4781,11 @@
4909
4781
  }]
4910
4782
  }] });
4911
4783
 
4912
- var isSite = function (_a) {
4913
- var type = _a["@type"], id = _a["@id"];
4914
- return type === schema.NodeType.Site && !!id;
4915
- };
4916
- var siteLocation = function (_a) {
4917
- var latitude = _a.latitude, longitude = _a.longitude;
4918
- return latitude && longitude ? ({
4919
- lat: latitude,
4920
- lng: longitude
4921
- }) : undefined;
4922
- };
4923
- var siteDefaultLocation = function (_a) {
4924
- var region = _a.region, country = _a.country;
4925
- var markers = [
4926
- region ? createMarker(termLocation(region), termLocationName(region).name, undefined, 20) : undefined,
4927
- country ? createMarker(termLocation(country), termLocationName(country).name, undefined, 40) : undefined
4928
- ].filter(Boolean);
4929
- return (markers.length ? markers[0] : undefined);
4930
- };
4931
- var siteMarker = function (site) { return createMarker(site ? siteLocation(site) : undefined, site.name); };
4932
- var sitePolygon = function (_a) {
4933
- var boundary = _a.boundary;
4934
- return (boundary ? polygonsFromFeature(boundary) : undefined);
4935
- };
4936
- var regions = function (sites) { return utils.unique(sites.map(function (_a) {
4937
- var country = _a.country, region = _a.region;
4938
- return region ? region['@id'] : (country ? country['@id'] : null);
4939
- }).filter(Boolean)); };
4940
- var defaultCenter = { lat: 0, lng: 0 };
4941
- var SitesMapsComponent = /** @class */ (function () {
4942
- function SitesMapsComponent(nodeService) {
4943
- this.nodeService = nodeService;
4944
- this.loaded = false;
4945
- this.loadPolygons = true;
4946
- this.sites = [];
4947
- this.nodes = [];
4948
- this.center = defaultCenter;
4949
- this.zoom = 2;
4950
- this.showNotice = true;
4951
- this.googleLoaded = false;
4952
- this.showNoLocation = false;
4953
- }
4954
- SitesMapsComponent.prototype.ngOnInit = function () {
4955
- var _this = this;
4956
- waitFor('google', function () {
4957
- _this.googleLoaded = true;
4958
- setTimeout(function () { return !_this.loaded && _this.loadData(); });
4959
- });
4960
- };
4961
- SitesMapsComponent.prototype.ngAfterViewInit = function () {
4962
- return this.googleLoaded && this.loadData();
4963
- };
4964
- SitesMapsComponent.prototype.loadData = function () {
4965
- return __awaiter(this, void 0, void 0, function () {
4966
- var sites, markers, polygons, termPolygons;
4967
- var _this = this;
4968
- return __generator(this, function (_a) {
4969
- switch (_a.label) {
4970
- case 0:
4971
- // loaded data as geojson
4972
- this.map.googleMap.data.setStyle(function () { return (Object.assign(Object.assign({}, strokeStyle), { strokeOpacity: 0.1 })); });
4973
- return [4 /*yield*/, this.getSites()];
4974
- case 1:
4975
- sites = _a.sent();
4976
- markers = this.addSiteMarkers(sites);
4977
- polygons = sites.flatMap(sitePolygon).filter(Boolean);
4978
- polygons.map(function (polygon) { return polygon === null || polygon === void 0 ? void 0 : polygon.setMap(_this.map.googleMap); });
4979
- this.loaded = true;
4980
- return [4 /*yield*/, Promise.all(regions(sites).map(function (v) { return _this.addTermsPolygons(v); }))];
4981
- case 2:
4982
- termPolygons = (_a.sent()).flat();
4983
- this.showNoLocation = markers.length === 0 && polygons.length === 0 && termPolygons.length === 0;
4984
- return [2 /*return*/, markers.length ?
4985
- this.centerMarker(markers[0]) :
4986
- this.centerPolygons(polygons.length ? polygons : termPolygons)];
4987
- }
4988
- });
4989
- });
4990
- };
4991
- SitesMapsComponent.prototype.addMarkers = function (markers, cluster) {
4992
- var _this = this;
4993
- if (cluster === void 0) { cluster = false; }
4994
- return cluster ?
4995
- new MarkerClusterer__default["default"](this.map.googleMap, markers, { imagePath: clustererImage }) :
4996
- markers.map(function (marker) { return marker.setMap(_this.map.googleMap); });
4997
- };
4998
- SitesMapsComponent.prototype.addTermsPolygons = function (id) {
4999
- return __awaiter(this, void 0, void 0, function () {
5000
- var _a;
5001
- return __generator(this, function (_b) {
5002
- switch (_b.label) {
5003
- case 0:
5004
- if (!this.loadPolygons) return [3 /*break*/, 2];
5005
- return [4 /*yield*/, this.termPolygons(id)];
5006
- case 1:
5007
- _a = _b.sent();
5008
- return [3 /*break*/, 3];
5009
- case 2:
5010
- _a = [];
5011
- _b.label = 3;
5012
- case 3: return [2 /*return*/, _a];
5013
- }
5014
- });
5015
- });
5016
- };
5017
- SitesMapsComponent.prototype.centerMarker = function (marker) {
5018
- var center = marker.getPosition();
5019
- this.center = center ? { lat: center.lat(), lng: center.lng() } : defaultCenter;
5020
- };
5021
- SitesMapsComponent.prototype.centerPolygons = function (polygons) {
5022
- try {
5023
- return polygons.length ? this.map.googleMap.fitBounds(polygonBounds(polygons)) : null;
5024
- }
5025
- catch (err) {
5026
- if (polygons.length) {
5027
- this.map.googleMap.fitBounds(polygonBounds(polygons[0]));
5028
- this.zoom = 3;
5029
- }
5030
- }
5031
- };
5032
- SitesMapsComponent.prototype.addSiteMarkers = function (sites) {
5033
- var siteMarkers = sites.map(siteMarker).filter(Boolean);
5034
- var markers = siteMarkers.length ? siteMarkers : sites.map(siteDefaultLocation).filter(Boolean);
5035
- this.addMarkers(markers, !!siteMarkers.length);
5036
- return markers;
5037
- };
5038
- SitesMapsComponent.prototype.loadSite = function (node) {
5039
- return __awaiter(this, void 0, void 0, function () {
5040
- var _a;
5041
- return __generator(this, function (_b) {
5042
- switch (_b.label) {
5043
- case 0:
5044
- if (!('schemaVersion' in node)) return [3 /*break*/, 1];
5045
- _a = node;
5046
- return [3 /*break*/, 3];
5047
- case 1: return [4 /*yield*/, this.nodeService.get(node)];
5048
- case 2:
5049
- _a = _b.sent();
5050
- _b.label = 3;
5051
- case 3:
5052
- // means the site was already downloaded
5053
- return [2 /*return*/, _a];
5054
- }
5055
- });
5056
- });
5057
- };
5058
- SitesMapsComponent.prototype.siteData = function (node) {
5059
- return __awaiter(this, void 0, void 0, function () {
5060
- var _a, _b, _c, _d;
5061
- return __generator(this, function (_e) {
5062
- switch (_e.label) {
5063
- case 0:
5064
- if (![
5065
- schema.NodeType.Site,
5066
- schema.NodeType.Organisation
5067
- ].includes(node.type)) return [3 /*break*/, 1];
5068
- _a = node;
5069
- return [3 /*break*/, 7];
5070
- case 1:
5071
- if (!isSite(node)) return [3 /*break*/, 2];
5072
- _b = this.loadSite(node);
5073
- return [3 /*break*/, 6];
5074
- case 2:
5075
- if (!('site' in node && isSite(node.site))) return [3 /*break*/, 3];
5076
- _c = this.loadSite(node.site);
5077
- return [3 /*break*/, 5];
5078
- case 3:
5079
- _d = this.siteData;
5080
- return [4 /*yield*/, this.loadSite(node)];
5081
- case 4:
5082
- _c = _d.apply(this, [_e.sent()]);
5083
- _e.label = 5;
5084
- case 5:
5085
- _b = (_c);
5086
- _e.label = 6;
5087
- case 6:
5088
- _a = (_b);
5089
- _e.label = 7;
5090
- case 7: return [2 /*return*/, _a];
5091
- }
5092
- });
5093
- });
5094
- };
5095
- SitesMapsComponent.prototype.getSites = function () {
5096
- var _this = this;
5097
- var nodes = this.sites && this.sites.length ? this.sites : this.nodes;
5098
- return Promise.all(nodes.map(function (node) { return _this.siteData(node); }));
5099
- };
5100
- SitesMapsComponent.prototype.termPolygons = function (id) {
5101
- return __awaiter(this, void 0, void 0, function () {
5102
- var data, polygons, _err_1;
5103
- var _this = this;
5104
- return __generator(this, function (_a) {
5105
- switch (_a.label) {
5106
- case 0:
5107
- _a.trys.push([0, 2, , 3]);
5108
- return [4 /*yield*/, this.nodeService.downloadRaw(baseUrl() + "/gadm/" + id + ".geojson")];
5109
- case 1:
5110
- data = _a.sent();
5111
- polygons = polygonsFromFeature(data);
5112
- polygons.map(function (polygon) { return polygon.setMap(_this.map.googleMap); });
5113
- return [2 /*return*/, polygons];
5114
- case 2:
5115
- _err_1 = _a.sent();
5116
- // ignore error if the file does not exist
5117
- return [2 /*return*/, []];
5118
- case 3: return [2 /*return*/];
5119
- }
5120
- });
5121
- });
5122
- };
5123
- return SitesMapsComponent;
5124
- }());
5125
- SitesMapsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, deps: [{ token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5126
- SitesMapsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMapsComponent, selector: "he-sites-maps", inputs: { loadPolygons: "loadPolygons", sites: "sites", nodes: "nodes", center: "center", zoom: "zoom", showNotice: "showNotice" }, viewQueries: [{ propertyName: "map", first: true, predicate: i1$2.GoogleMap, descendants: true }], ngImport: i0__namespace, template: "<google-map *ngIf=\"googleLoaded\"\n height=\"100%\"\n width=\"100%\"\n [zoom]=\"zoom\"\n [center]=\"center\"\n></google-map>\n\n<p *ngIf=\"showNotice\" class=\"mt-2 is-italic is-size-7\">The information provided might not be complete</p>\n\n<div class=\"no-location has-text-center has-text-light\" *ngIf=\"showNoLocation\">\n <span>No precise location data</span>\n</div>\n", styles: [":host{display:block;height:100%;position:relative;width:100%}.no-location{background-color:#0000004d;left:0;height:100%;position:absolute;top:0;width:100%;z-index:9}.no-location>span{display:inline-block;margin-top:12%}\n"], components: [{ type: i1__namespace$2.GoogleMap, selector: "google-map", inputs: ["height", "width", "center", "zoom", "options", "mapTypeId"], outputs: ["authFailure", "boundsChanged", "centerChanged", "mapClick", "mapDblclick", "mapDrag", "mapDragend", "mapDragstart", "headingChanged", "idle", "maptypeidChanged", "mapMousemove", "mapMouseout", "mapMouseover", "projectionChanged", "mapRightclick", "tilesloaded", "tiltChanged", "zoomChanged"], exportAs: ["googleMap"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5127
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, decorators: [{
5128
- type: i0.Component,
5129
- args: [{
5130
- selector: 'he-sites-maps',
5131
- templateUrl: './sites-maps.component.html',
5132
- styleUrls: ['./sites-maps.component.scss']
5133
- }]
5134
- }], ctorParameters: function () { return [{ type: HeNodeService }]; }, propDecorators: { map: [{
5135
- type: i0.ViewChild,
5136
- args: [i1$2.GoogleMap]
5137
- }], loadPolygons: [{
5138
- type: i0.Input
5139
- }], sites: [{
5140
- type: i0.Input
5141
- }], nodes: [{
5142
- type: i0.Input
5143
- }], center: [{
5144
- type: i0.Input
5145
- }], zoom: [{
5146
- type: i0.Input
5147
- }], showNotice: [{
5148
- type: i0.Input
5149
- }] } });
5150
-
5151
- var maxAreaSize = 5000;
5152
- var siteTooBig = function (_a) {
5153
- var area = _a.area;
5154
- return area && area / 100 > maxAreaSize;
5155
- };
5156
- var hasMultipleValues = function (values) { return (values || []).length > 1; };
5157
- var weighedAverage = function (_a) {
5158
- var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5159
- return value.reduce(function (prev, curr, index) { return prev + (curr * (depthLower[index] - depthUpper[index])); }, 0) /
5160
- value.reduce(function (prev, _curr, index) { return prev + (depthLower[index] - depthUpper[index]); }, 0);
5161
- };
5162
- var measurementValue = function (_a) {
5163
- var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5164
- return hasMultipleValues(value) && hasMultipleValues(depthLower) && hasMultipleValues(depthUpper) ?
5165
- weighedAverage({ value: value, depthLower: depthLower, depthUpper: depthUpper }) :
5166
- propertyValue$1(value);
5167
- };
5168
-
5169
- var SitesMeasurementsLogsComponent = /** @class */ (function () {
5170
- function SitesMeasurementsLogsComponent(searchService, nodeService) {
5171
- this.searchService = searchService;
5172
- this.nodeService = nodeService;
5173
- this.originalValues = [];
5174
- this.recalculatedValues = [];
5175
- this.loading = true;
5176
- this.NodeType = schema.NodeType;
5177
- this.models = [];
5178
- this.measurements = [];
5179
- }
5180
- SitesMeasurementsLogsComponent.prototype.ngOnInit = function () {
5181
- return __awaiter(this, void 0, void 0, function () {
5182
- var _a, measurements;
5183
- return __generator(this, function (_b) {
5184
- switch (_b.label) {
5185
- case 0:
5186
- this.logsUrl = this.nodeService.nodeLogsUrl(this.node);
5187
- _a = this;
5188
- return [4 /*yield*/, this.nodeService.getModelsLog(this.node)];
5189
- case 1:
5190
- _a.logs = _b.sent();
5191
- return [4 /*yield*/, this.searchService.search({
5192
- fields: ['@type', '@id', 'name'],
5193
- limit: 1000,
5194
- query: {
5195
- bool: {
5196
- must: [
5197
- matchType(schema.NodeType.Term),
5198
- matchTermType(schema.TermTermType.measurement)
5199
- ]
5200
- }
5201
- }
5202
- })];
5203
- case 2:
5204
- measurements = (_b.sent()).results;
5205
- this.measurements = measurements;
5206
- this.loading = false;
5207
- return [2 /*return*/];
5208
- }
5209
- });
5210
- });
5211
- };
5212
- Object.defineProperty(SitesMeasurementsLogsComponent.prototype, "node", {
5213
- get: function () {
5214
- return Object.assign(Object.assign({}, this.site), { dataState: api.DataState.recalculated });
5215
- },
5216
- enumerable: false,
5217
- configurable: true
5218
- });
5219
- return SitesMeasurementsLogsComponent;
5220
- }());
5221
- SitesMeasurementsLogsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, deps: [{ token: HeSearchService }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5222
- SitesMeasurementsLogsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: { site: "site", originalValues: "originalValues", recalculatedValues: "recalculatedValues" }, ngImport: i0__namespace, template: "<he-node-logs-models *ngIf=\"!loading; else loader\"\n [logsUrl]=\"logsUrl\"\n [nodeType]=\"NodeType.Site\"\n [originalValues]=\"originalValues\"\n [recalculatedValues]=\"recalculatedValues\"\n [terms]=\"measurements\"\n [logs]=\"logs\"\n filteredType=\"Measurement\"\n></he-node-logs-models>\n\n<ng-template #loader>\n <div class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n </div>\n</ng-template>\n", styles: [""], components: [{ type: NodeLogsModelsComponent, selector: "he-node-logs-models", inputs: ["nodeType", "nodeKey", "logsUrl", "originalValues", "recalculatedValues", "terms", "logs", "filteredType"] }, { type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5223
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, decorators: [{
5224
- type: i0.Component,
5225
- args: [{
5226
- selector: 'he-sites-measurements-logs',
5227
- templateUrl: './sites-measurements-logs.component.html',
5228
- styleUrls: ['./sites-measurements-logs.component.scss']
5229
- }]
5230
- }], ctorParameters: function () { return [{ type: HeSearchService }, { type: HeNodeService }]; }, propDecorators: { site: [{
5231
- type: i0.Input
5232
- }], originalValues: [{
5233
- type: i0.Input
5234
- }], recalculatedValues: [{
5235
- type: i0.Input
5236
- }] } });
5237
-
5238
- var orderBy$1 = require('lodash.orderby');
5239
- var View$1;
5240
- (function (View) {
5241
- View["table"] = "table";
5242
- View["logs"] = "logs";
5243
- })(View$1 || (View$1 = {}));
5244
- var SitesMeasurementsComponent = /** @class */ (function () {
5245
- function SitesMeasurementsComponent() {
5246
- this.originalValues = [];
5247
- this.sites = [];
5248
- this.showDownload = false;
5249
- this.View = View$1;
5250
- this.selectedView = View$1.table;
5251
- this.maxAreaSize = maxAreaSize;
5252
- this.siteTooBig = siteTooBig;
5253
- this.defaultLabel = defaultLabel;
5254
- this.measurementValue = measurementValue;
5255
- this.measurements = [];
5256
- }
5257
- SitesMeasurementsComponent.prototype.ngOnChanges = function (changes) {
5258
- if ('sites' in changes) {
5259
- return this.update();
5260
- }
5261
- if ('dataState' in changes) {
5262
- this.selectedView = View$1.table;
5263
- }
5264
- };
5265
- SitesMeasurementsComponent.prototype.trackById = function (_index, item) {
5266
- return item['@id'];
5267
- };
5268
- Object.defineProperty(SitesMeasurementsComponent.prototype, "isOriginal", {
5269
- get: function () {
5270
- return this.dataState === api.DataState.original;
5271
- },
5272
- enumerable: false,
5273
- configurable: true
5274
- });
5275
- SitesMeasurementsComponent.prototype.update = function () {
5276
- var measurementsPerSite = groupNodesByTerm(this.sites, 'measurements', this.originalValues);
5277
- this.measurements = orderBy$1(grouppedKeys(measurementsPerSite), ['key'], ['asc']);
5278
- };
5279
- SitesMeasurementsComponent.prototype.togglePopover = function (popover, context) {
5280
- return popover.isOpen() ? popover.close() : popover.open(context);
5281
- };
5282
- Object.defineProperty(SitesMeasurementsComponent.prototype, "showAreaTooBig", {
5283
- get: function () {
5284
- return this.dataState === api.DataState.recalculated && (this.sites || []).some(siteTooBig);
5285
- },
5286
- enumerable: false,
5287
- configurable: true
5288
- });
5289
- return SitesMeasurementsComponent;
5290
- }());
5291
- SitesMeasurementsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
5292
- SitesMeasurementsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsComponent, selector: "he-sites-measurements", inputs: { originalValues: "originalValues", sites: "sites", dataState: "dataState" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-container *ngIf=\"measurements.length; else emptyTable\">\n <div class=\"columns is-variable is-2 m-0\">\n <div class=\"column is-hidden-mobile\"></div>\n <div class=\"column is-narrow\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.table\" (click)=\"selectedView = View.table\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"list\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Table view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"!isOriginal && sites.length === 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.logs\" (click)=\"selectedView = View.logs\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"calculator\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Recalculations logs</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"px-3 pb-3\" [class.is-hidden]=\"selectedView !== View.table\">\n <div class=\"has-text-right mb-2\">\n <button class=\"button is-dark is-outlined is-small\" (click)=\"showDownload = true\">\n <fa-icon icon=\"download\"></fa-icon>\n <span class=\"pl-2\">Download (CSV)</span>\n </button>\n </div>\n\n <div class=\"table-container data-table-container mb-1\">\n <table class=\"table is-narrow data-table has-children-{{measurements.length}}\">\n <thead>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.name\"\n >\n <he-node-link [node]=\"measurement.value.term\">\n <span>{{measurement.value.term.name | ellipsis:30}}</span>\n </he-node-link>\n </th>\n </tr>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.units\"\n >{{measurement.value.term.units}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let site of sites; trackBy: trackById; let i = index\">\n <td class=\"width-auto\" [attr.title]=\"defaultLabel(site)\">\n <he-node-link [node]=\"site\">\n <span class=\"is-nowrap has-text-ellipsis\">{{i + 1}}. {{defaultLabel(site)}}</span>\n </he-node-link>\n </td>\n <td class=\"is-nowrap\" *ngFor=\"let measurement of measurements\">\n <span *ngIf=\"measurement.value.values[site['@id']]\"\n class=\"trigger-popover\"\n [ngbPopover]=\"details\" [autoClose]=\"'outside'\"\n triggers=\"manual\" #p=\"ngbPopover\" placement=\"left\" container=\"body\"\n (click)=\"togglePopover(p, { data: measurement.value.values[site['@id']], site: site, key: 'measurements' })\"\n >\n <span pointer>{{measurementValue(measurement.value.values[site['@id']]) | precision:3 | default:'-'}}</span>\n <he-blank-node-state class=\"ml-1\"\n [node]=\"measurement.value.values[site['@id']].nodes[0]\"\n key=\"value\"\n ></he-blank-node-state>\n </span>\n <span *ngIf=\"!measurement.value.values[site['@id']]\">\n <span>-</span>\n <sup class=\"pl-1\" *ngIf=\"siteTooBig(site)\">(1)</sup>\n </span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n <he-blank-node-state-notice [dataState]=\"dataState\"></he-blank-node-state-notice>\n\n <p class=\"is-size-7 is-italic\" *ngIf=\"showAreaTooBig\">\n (1) This region is >{{maxAreaSize}}km2 and is too large to reliably gap fill Measurements.\n </p>\n </div>\n\n <he-sites-measurements-logs *ngIf=\"selectedView === View.logs && !isOriginal\"\n [site]=\"sites[0]\"\n [originalValues]=\"originalValues[0].measurements\"\n [recalculatedValues]=\"sites[0].measurements\"\n ></he-sites-measurements-logs>\n</ng-container>\n\n<he-node-csv-export-confirm *ngIf=\"showDownload\"\n [nodes]=\"sites\" filename=\"site-measurements.csv\" [isUpload]=\"false\"\n [headerKeys]=\"['site.id', 'site.@id', 'site.measurements.']\"\n (closed)=\"showDownload = false\"\n></he-node-csv-export-confirm>\n\n<ng-template #emptyTable>\n <div class=\"panel-block\">\n <span>No data</span>\n </div>\n</ng-template>\n\n<ng-template #emptyValue>\n <span>-</span>\n</ng-template>\n\n<ng-template #details let-node=\"site\" let-data=\"data\" let-key=\"key\">\n <p><b>{{node.name}}</b></p>\n <he-node-value-details\n [data]=\"data\" [nodeType]=\"node['@type']\" [dataKey]=\"key\"\n ></he-node-value-details>\n</ng-template>\n", styles: ["fa-icon{display:inline-block;width:10px}\n"], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }, { type: NodeLinkComponent, selector: "he-node-link", inputs: ["node", "showExternalLink"] }, { type: BlankNodeStateComponent, selector: "he-blank-node-state", inputs: ["nodeType", "dataKey", "key", "node", "state"] }, { type: BlankNodeStateNoticeComponent, selector: "he-blank-node-state-notice", inputs: ["dataState", "showDeleted"] }, { type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: ["site", "originalValues", "recalculatedValues"] }, { type: NodeCsvExportConfirmComponent, selector: "he-node-csv-export-confirm", inputs: ["nodes", "filename", "headerKeys", "extension", "isUpload"], outputs: ["closed"] }, { type: NodeValueDetailsComponent, selector: "he-node-value-details", inputs: ["data", "nodeType", "dataKey"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgbPopover, selector: "[ngbPopover]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disablePopover", "popoverClass", "openDelay", "closeDelay", "ngbPopover", "popoverTitle"], outputs: ["shown", "hidden"], exportAs: ["ngbPopover"] }], pipes: { "ellipsis": EllipsisPipe, "default": DefaultPipe, "precision": PrecisionPipe } });
5293
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, decorators: [{
5294
- type: i0.Component,
5295
- args: [{
5296
- selector: 'he-sites-measurements',
5297
- templateUrl: './sites-measurements.component.html',
5298
- styleUrls: ['./sites-measurements.component.scss']
5299
- }]
5300
- }], propDecorators: { originalValues: [{
5301
- type: i0.Input
5302
- }], sites: [{
5303
- type: i0.Input
5304
- }], dataState: [{
5305
- type: i0.Input
5306
- }] } });
5307
-
5308
- var components$2 = [
5309
- SitesMapsComponent,
5310
- SitesMeasurementsComponent,
5311
- SitesMeasurementsLogsComponent
5312
- ];
5313
- var HeSitesModule = /** @class */ (function () {
5314
- function HeSitesModule() {
5315
- }
5316
- return HeSitesModule;
5317
- }());
5318
- HeSitesModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
5319
- HeSitesModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, declarations: [SitesMapsComponent,
5320
- SitesMeasurementsComponent,
5321
- SitesMeasurementsLogsComponent], imports: [i3.CommonModule, i1$4.ReactiveFormsModule,
5322
- HeCommonModule,
5323
- HeNodeModule], exports: [SitesMapsComponent,
5324
- SitesMeasurementsComponent,
5325
- SitesMeasurementsLogsComponent] });
5326
- HeSitesModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, imports: [[
5327
- i3.CommonModule, i1$4.ReactiveFormsModule,
5328
- HeCommonModule,
5329
- HeNodeModule
5330
- ]] });
5331
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, decorators: [{
5332
- type: i0.NgModule,
5333
- args: [{
5334
- declarations: components$2,
5335
- exports: components$2,
5336
- imports: [
5337
- i3.CommonModule, i1$4.ReactiveFormsModule,
5338
- HeCommonModule,
5339
- HeNodeModule
5340
- ]
5341
- }]
5342
- }] });
5343
-
5344
- var _f;
5345
- var mapErrorMessage = 'does not contain latitude and longitude';
5346
- var parseDataPath = function (dataPath) {
5347
- var _f = __read(dataPath.split('.')), _ = _f[0], paths = _f.slice(1);
5348
- return paths.map(function (path) { return ({ path: path, label: keyToLabel(path.replace(/\[\d+\]/g, '')) }); });
4784
+ var _f;
4785
+ var mapErrorMessage = 'does not contain latitude and longitude';
4786
+ var parseDataPath = function (dataPath) {
4787
+ var _f = __read(dataPath.split('.')), _ = _f[0], paths = _f.slice(1);
4788
+ return paths.map(function (path) { return ({ path: path, label: keyToLabel(path.replace(/\[\d+\]/g, '')) }); });
5349
4789
  };
5350
4790
  var contactUsEmail = 'community@hestia.earth';
5351
4791
  var externalLink = function (href, text) { return "<a href=\"" + href + "\" target=\"_blank\">" + text + "</a>"; };
@@ -5474,671 +4914,1103 @@
5474
4914
  var _a, _b, _c, _d, _e;
5475
4915
  return "You have the following Product " + code((_a = params === null || params === void 0 ? void 0 : params.product) === null || _a === void 0 ? void 0 : _a.name) + " however,\n you have used a generic " + glossaryTypeLink((_b = params === null || params === void 0 ? void 0 : params.term) === null || _b === void 0 ? void 0 : _b.termType) + " term " + code((_c = params === null || params === void 0 ? void 0 : params.term) === null || _c === void 0 ? void 0 : _c.name) + ".\n Use a more specific term for the " + glossaryTypeLink((_d = params === null || params === void 0 ? void 0 : params.term) === null || _d === void 0 ? void 0 : _d.termType) + " which reflects the specific " + glossaryTypeLink((_e = params === null || params === void 0 ? void 0 : params.product) === null || _e === void 0 ? void 0 : _e.termType) + ".";
5476
4916
  },
5477
- _f['is missing required bibliographic information'] = function () { return "The automatic bibliography search failed for this Bibliography. Either:\n 1) manually fill-in the <b>required</b> bibliographic information as per\n " + schemaLink(schema.SchemaType.Bibliography, 'our schema') + ".\n 2) provide the " + code('documentDOI') + " as well as the " + code('title') + "\n 3) check the " + code('documentDOI') + " and " + code('title') + " for typos against the\n " + externalLink('https://www.mendeley.com', 'Mendeley catalogue'); },
5478
- _f['should be lower than max size'] = function (_f) {
5479
- var params = _f.params;
5480
- return "The boundary or region is >" + (params === null || params === void 0 ? void 0 : params.expected) + "km2 and is too large to reliably gap fill Measurements.";
4917
+ _f['is missing required bibliographic information'] = function () { return "The automatic bibliography search failed for this Bibliography. Either:\n 1) manually fill-in the <b>required</b> bibliographic information as per\n " + schemaLink(schema.SchemaType.Bibliography, 'our schema') + ".\n 2) provide the " + code('documentDOI') + " as well as the " + code('title') + "\n 3) check the " + code('documentDOI') + " and " + code('title') + " for typos against the\n " + externalLink('https://www.mendeley.com', 'Mendeley catalogue'); },
4918
+ _f['should be lower than max size'] = function (_f) {
4919
+ var params = _f.params;
4920
+ return "The boundary or region is >" + (params === null || params === void 0 ? void 0 : params.expected) + "km2 and is too large to reliably gap fill Measurements.";
4921
+ },
4922
+ _f['an excreta input is required when using an excretaManagement practice'] = function (_f) {
4923
+ var dataPath = _f.dataPath;
4924
+ var paths = parseDataPath(dataPath);
4925
+ return "Excreta management is the conversion of excreta to another type of excreta.\n You have added an excretaManagement Practice to this " + paths[0].label + " but there is no excreta Input.\n To represent excreta management, use a " + paths[0].label + " with excreta as an Input and excretaManagement as a Practice.";
4926
+ },
4927
+ _f['only 1 primary product allowed'] = function () { return 'There can only be one primary product in each Cycle.'; },
4928
+ _f['is not allowed in combination with noTillage'] = function () { return "This operation involves tillage, yet you have specified the Practice " + termLink(noTillage) + ".\n Either change this operation or the Practice."; },
4929
+ _f['should contain a tillage practice'] = function () { return "We recommend specifying the type of tillage used for this Cycle.\n Please see the " + glossaryTypeLink(schema.TermTermType.tillage) + " glossary."; },
4930
+ _f['must set value for every tillage practice'] = function () { return "Either specify a single " + glossaryTypeLink(schema.TermTermType.tillage) + " practice or add a value to all practices."; },
4931
+ _f['sum not equal to 100% for tillage practices'] = function () { return "The sum of " + glossaryTypeLink(schema.TermTermType.tillage) + " practices must equal 100%."; },
4932
+ _f['can only have 1 tillage practice without a value'] = function (_f) {
4933
+ var params = _f.params;
4934
+ var _a;
4935
+ return "It is not possible for a Cycle to have the following tillage Practices:\n " + ((_a = params === null || params === void 0 ? void 0 : params.current) !== null && _a !== void 0 ? _a : []).map(function (_f) {
4936
+ var name = _f.name;
4937
+ return name;
4938
+ }).join(' and ') + " at the same time.\n If multiple tillage practices did occur, please specify the percentage of area they occurred on.";
4939
+ },
4940
+ _f['can not be linked to the same Cycle'] = function () { return 'You can not link an Input to the Impact Assessment of the same Cycle.'; },
4941
+ _f['must be 0 for product value 0'] = function (_f, errorCount) {
4942
+ var dataPath = _f.dataPath, params = _f.params;
4943
+ return "If the amount produced is zero, the " + code(dataPath === null || dataPath === void 0 ? void 0 : dataPath.split('.').pop()) + " of " + (errorCount === 1 ? code(params === null || params === void 0 ? void 0 : params.term.name) : 'that product') + " must also be zero.";
4944
+ },
4945
+ _f);
4946
+ var formatCustomErrorMessage = function (message, error, errorCount) {
4947
+ if (errorCount === void 0) { errorCount = 1; }
4948
+ var formattedMessage = message && message in customErrorMessage ?
4949
+ customErrorMessage[message](error, errorCount) :
4950
+ message;
4951
+ return formattedMessage ? "<p class=\"is-normal\">" + formattedMessage + "</p>" : '';
4952
+ };
4953
+ var formatError = function (error, errorCount) {
4954
+ if (errorCount === void 0) { errorCount = 1; }
4955
+ return error ? (Object.assign(Object.assign({ level: 'error' }, error), { mapError: error.message === mapErrorMessage, message: formatCustomErrorMessage(error.message, error, errorCount) })) : undefined;
4956
+ };
4957
+ var errorHasError = function (error) { return error && (error.level === 'error' || !error.level); };
4958
+ var errorHasWarning = function (error) { return error && error.level === 'warning'; };
4959
+ var isMissingPropertyError = function (_f) {
4960
+ var params = _f.params;
4961
+ return !!params && 'missingProperty' in params;
4962
+ };
4963
+ var isMissingOneOfError = function (_f) {
4964
+ var keyword = _f.keyword, schemaPath = _f.schemaPath;
4965
+ return keyword === 'required' && (schemaPath || '').includes('oneOf');
4966
+ };
4967
+ var isFailingKeywordError = function (_f) {
4968
+ var params = _f.params;
4969
+ return !!params && 'failingKeyword' in params;
4970
+ };
4971
+ var filterError = function (error) { return [
4972
+ isFailingKeywordError
4973
+ ].every(function (func) { return !func(error); }); };
4974
+ var missingNodeErrors = function (errors) { return errors.filter(function (_f) {
4975
+ var keyword = _f.keyword, params = _f.params;
4976
+ return keyword === 'required' && ((params === null || params === void 0 ? void 0 : params.missingProperty) === '@type' || (params === null || params === void 0 ? void 0 : params.missingProperty) === '@id');
4977
+ }); };
4978
+
4979
+ var _d;
4980
+ /* eslint-disable complexity */
4981
+ var get$1 = require('lodash.get');
4982
+ var ARRAY_DELIMITER = ';';
4983
+ var privateKeys = [
4984
+ 'filepath'
4985
+ ];
4986
+ var defaultSuggestionType = 'default';
4987
+ var stringValue = function (value) { return (typeof value === 'undefined' || value === null ? '' : value).toString(); };
4988
+ var nonExpandableArrayDataPath = function (key) { return key.replace(/\[\d+\]$/, ''); };
4989
+ var keyToDataPath = function (key) { return (key === null || key === void 0 ? void 0 : key.length) ? "." + key : ''; };
4990
+ var dataPathToKey = function (dataPath, trimArray) {
4991
+ if (trimArray === void 0) { trimArray = false; }
4992
+ return trimArray ? nonExpandableArrayDataPath(dataPath.substring(1)) : dataPath.substring(1);
4993
+ };
4994
+ var parentKey = function (key) {
4995
+ var keys = (key.startsWith('.') ? key.substring(1) : key).split('.');
4996
+ keys.pop();
4997
+ return keys.join('.');
4998
+ };
4999
+ /**
5000
+ * Sort properties having errors, type, id, ...properties (simple), and finally the groups
5001
+ *
5002
+ * @param a {INodeProperty}
5003
+ * @param b {INodeProperty}
5004
+ */
5005
+ var sortProperties = function (a, b) {
5006
+ if (utils.isNumber(a.key) && utils.isNumber(b.key)) {
5007
+ return +a.key - +b.key;
5008
+ }
5009
+ if (a.isExpandable) {
5010
+ return b.isExpandable ? a.key.localeCompare(b.key) : 1;
5011
+ }
5012
+ if (b.isExpandable) {
5013
+ return -1;
5014
+ }
5015
+ if (!a.key) {
5016
+ return -1;
5017
+ }
5018
+ var aKey = a.key.replace('@', '');
5019
+ var bKey = b.key.replace('@', '');
5020
+ if (aKey === 'type') {
5021
+ return -1;
5022
+ }
5023
+ if (bKey === 'type') {
5024
+ return 1;
5025
+ }
5026
+ if (aKey === 'id' && bKey !== 'type') {
5027
+ return -1;
5028
+ }
5029
+ if (a.hasError || a.hasWarning) {
5030
+ return -1;
5031
+ }
5032
+ return a.key.localeCompare(b.key);
5033
+ };
5034
+ var defaultPropertyError = {
5035
+ max: function (_d) {
5036
+ var max = _d.max;
5037
+ return "should be <= " + max;
5038
+ },
5039
+ min: function (_d) {
5040
+ var min = _d.min;
5041
+ return "should be >= " + min;
5042
+ },
5043
+ pattern: function (_d) {
5044
+ var requiredPattern = _d.requiredPattern;
5045
+ return "should match pattern \"" + requiredPattern + "\"";
5046
+ },
5047
+ required: function (_e, _d) {
5048
+ var schemaType = _d.schemaType;
5049
+ return schemaType ? "should be set or linked to another " + schemaType : undefined;
5050
+ }
5051
+ };
5052
+ var formatPropertyError = function (errors, property) {
5053
+ var key = Object.keys(errors)[0];
5054
+ return key in defaultPropertyError ? formatCustomErrorMessage(defaultPropertyError[key](errors[key], property)) : '';
5055
+ };
5056
+ var hasError = function (value) { return Array.isArray(value) ? value.some(hasError) : value.hasError; };
5057
+ var hasWarning = function (value) { return Array.isArray(value) ? value.some(hasWarning) : value.hasWarning; };
5058
+ var compileSuggestionQueries = function (key, allOf) {
5059
+ var conditions = (allOf || [])
5060
+ .filter(function (v) { var _c; return (((_c = v.if) === null || _c === void 0 ? void 0 : _c.required) || []).includes(key); })
5061
+ .map(function (v) { var _c; return (_c = v.then) === null || _c === void 0 ? void 0 : _c.properties[key]; })
5062
+ .map(function (v) { var _c; return ((_c = v === null || v === void 0 ? void 0 : v.items) === null || _c === void 0 ? void 0 : _c.properties) || (v === null || v === void 0 ? void 0 : v.properties); })
5063
+ .filter(Boolean);
5064
+ return conditions.length ? [{
5065
+ bool: {
5066
+ should: conditions.flatMap(function (cond) { return Object.keys(cond).flatMap(function (k) { return (cond[k].enum || []).map(function (v) {
5067
+ var _d;
5068
+ return ({
5069
+ match: (_d = {}, _d[k] = v, _d)
5070
+ });
5071
+ }); }); }),
5072
+ minimum_should_match: 1
5073
+ }
5074
+ }] : [];
5075
+ };
5076
+ // default suggest for linking nodes together using the `id` field
5077
+ var suggestLinkNodes = function (type, fullKey) {
5078
+ var keys = fullKey.split('.');
5079
+ var key = keys.pop();
5080
+ return key === 'id' && keys.length >= 1 ? { type: type, isLinkNode: true } : undefined;
5081
+ };
5082
+ var suggestExistingNode = function (type, fullKey) {
5083
+ var keys = fullKey.split('.');
5084
+ var key = keys.pop();
5085
+ return keys.length >= 1 && ['@id', 'openLCAId'].includes(key) ? { type: type, isUniqueKey: '@id' } : undefined;
5086
+ };
5087
+ var defaultNodeTypeSuggestion = function (type) { return function (fullKey) { return suggestLinkNodes(type, fullKey) || suggestExistingNode(type, fullKey); }; };
5088
+ var termSuggestions = function (parent, _d) {
5089
+ var allOf = _d.allOf;
5090
+ return ({
5091
+ type: schema.NodeType.Term,
5092
+ queries: __spreadArray(__spreadArray([], __read(compileSuggestionQueries(nonExpandableArrayDataPath(parent), allOf))), __read((['country'].includes(parent) ? [matchCountry] : [])))
5093
+ });
5094
+ };
5095
+ var formatLinkNodesSuggestions = function (nodeMap, type) { return (nodeMap[type] || []).map(function (id) { return ({ type: type, id: id, name: "Link with " + type + ": " + id }); }); };
5096
+ var typeToSuggestion = (_d = {},
5097
+ _d[schema.NodeType.Actor] = defaultNodeTypeSuggestion(schema.NodeType.Actor),
5098
+ _d[schema.NodeType.Cycle] = defaultNodeTypeSuggestion(schema.NodeType.Cycle),
5099
+ _d[schema.NodeType.ImpactAssessment] = defaultNodeTypeSuggestion(schema.NodeType.ImpactAssessment),
5100
+ _d[schema.NodeType.Organisation] = defaultNodeTypeSuggestion(schema.NodeType.Organisation),
5101
+ _d[schema.NodeType.Site] = defaultNodeTypeSuggestion(schema.NodeType.Site),
5102
+ _d[schema.NodeType.Source] = defaultNodeTypeSuggestion(schema.NodeType.Source),
5103
+ _d[schema.NodeType.Term] = function (fullKey, parentSchema) {
5104
+ var keys = fullKey.split('.');
5105
+ var key = keys.pop();
5106
+ return ['name'].includes(key) && keys.length >= 1 ?
5107
+ termSuggestions(keys.pop(), parentSchema) :
5108
+ defaultNodeTypeSuggestion(schema.NodeType.Term)(fullKey);
5109
+ },
5110
+ _d[schema.SchemaType.Bibliography] = function (fullKey) {
5111
+ var keys = fullKey.split('.');
5112
+ var key = keys.pop();
5113
+ var parent = keys.pop();
5114
+ // prevent replacing a top-level source
5115
+ return ['title', 'documentDOI', 'scopus'].includes(key) && parent === 'bibliography' && keys.length >= 1 ? {
5116
+ type: schema.NodeType.Source,
5117
+ parentLevel: 1
5118
+ } : null;
5481
5119
  },
5482
- _f['an excreta input is required when using an excretaManagement practice'] = function (_f) {
5483
- var dataPath = _f.dataPath;
5484
- var paths = parseDataPath(dataPath);
5485
- return "Excreta management is the conversion of excreta to another type of excreta.\n You have added an excretaManagement Practice to this " + paths[0].label + " but there is no excreta Input.\n To represent excreta management, use a " + paths[0].label + " with excreta as an Input and excretaManagement as a Practice.";
5120
+ _d.number = function (_a, _b, schema) {
5121
+ var values = schema.const ? [schema.const] : [];
5122
+ return {
5123
+ type: values.length > 0 ? 'select' : defaultSuggestionType,
5124
+ // exclude suggesting SchemaType
5125
+ values: values
5126
+ };
5486
5127
  },
5487
- _f['only 1 primary product allowed'] = function () { return 'There can only be one primary product in each Cycle.'; },
5488
- _f['is not allowed in combination with noTillage'] = function () { return "This operation involves tillage, yet you have specified the Practice " + termLink(noTillage) + ".\n Either change this operation or the Practice."; },
5489
- _f['should contain a tillage practice'] = function () { return "We recommend specifying the type of tillage used for this Cycle.\n Please see the " + glossaryTypeLink(schema.TermTermType.tillage) + " glossary."; },
5490
- _f['must set value for every tillage practice'] = function () { return "Either specify a single " + glossaryTypeLink(schema.TermTermType.tillage) + " practice or add a value to all practices."; },
5491
- _f['sum not equal to 100% for tillage practices'] = function () { return "The sum of " + glossaryTypeLink(schema.TermTermType.tillage) + " practices must equal 100%."; },
5492
- _f['can only have 1 tillage practice without a value'] = function (_f) {
5493
- var params = _f.params;
5494
- var _a;
5495
- return "It is not possible for a Cycle to have the following tillage Practices:\n " + ((_a = params === null || params === void 0 ? void 0 : params.current) !== null && _a !== void 0 ? _a : []).map(function (_f) {
5496
- var name = _f.name;
5497
- return name;
5498
- }).join(' and ') + " at the same time.\n If multiple tillage practices did occur, please specify the percentage of area they occurred on.";
5128
+ _d.integer = function (_a, _b, schema) {
5129
+ var values = schema.const ? [schema.const] : [];
5130
+ return {
5131
+ type: values.length > 0 ? 'select' : defaultSuggestionType,
5132
+ // exclude suggesting SchemaType
5133
+ values: values
5134
+ };
5499
5135
  },
5500
- _f['can not be linked to the same Cycle'] = function () { return 'You can not link an Input to the Impact Assessment of the same Cycle.'; },
5501
- _f['must be 0 for product value 0'] = function (_f, errorCount) {
5502
- var dataPath = _f.dataPath, params = _f.params;
5503
- return "If the amount produced is zero, the " + code(dataPath === null || dataPath === void 0 ? void 0 : dataPath.split('.').pop()) + " of " + (errorCount === 1 ? code(params === null || params === void 0 ? void 0 : params.term.name) : 'that product') + " must also be zero.";
5136
+ _d.string = function (fullKey, _b, schema$1) {
5137
+ // exclude suggesting SchemaType
5138
+ var values = schema$1.const ?
5139
+ [schema$1.const] :
5140
+ (schema$1.enum || []).filter(function (val) { return !Object.values(schema.SchemaType).includes(val); });
5141
+ var key = fullKey.split('.').pop();
5142
+ return {
5143
+ type: values.length > 0 && key !== 'type' ? 'select' : defaultSuggestionType,
5144
+ values: values
5145
+ };
5504
5146
  },
5505
- _f);
5506
- var formatCustomErrorMessage = function (message, error, errorCount) {
5507
- if (errorCount === void 0) { errorCount = 1; }
5508
- var formattedMessage = message && message in customErrorMessage ?
5509
- customErrorMessage[message](error, errorCount) :
5510
- message;
5511
- return formattedMessage ? "<p class=\"is-normal\">" + formattedMessage + "</p>" : '';
5147
+ _d.boolean = function (_a) { return ({
5148
+ type: 'select',
5149
+ values: ['true', 'false']
5150
+ }); },
5151
+ _d);
5152
+ var enableSuggestions = function (parentSchema, type, fullKey, schema) {
5153
+ var suggestion = type in typeToSuggestion ? typeToSuggestion[type](fullKey, parentSchema) : null;
5154
+ return suggestion !== null ? suggestion : (schema && schema.type in typeToSuggestion ?
5155
+ typeToSuggestion[schema.type](fullKey, parentSchema, schema) :
5156
+ null);
5512
5157
  };
5513
- var formatError = function (error, errorCount) {
5514
- if (errorCount === void 0) { errorCount = 1; }
5515
- return error ? (Object.assign(Object.assign({ level: 'error' }, error), { mapError: error.message === mapErrorMessage, message: formatCustomErrorMessage(error.message, error, errorCount) })) : undefined;
5158
+ var formatProperty = function (prop) { return (Object.assign(Object.assign({ '@type': schema.SchemaType.Property }, prop), { term: Object.assign({ '@type': schema.NodeType.Term }, prop.term) })); };
5159
+ var formatSuggestion = function (_c) {
5160
+ var defaultProperties = _c.defaultProperties, node = __rest(_c, ["defaultProperties"]);
5161
+ return (Object.assign(Object.assign({}, node), (defaultProperties ? { defaultProperties: defaultProperties.map(formatProperty) } : {})));
5516
5162
  };
5517
- var errorHasError = function (error) { return error && (error.level === 'error' || !error.level); };
5518
- var errorHasWarning = function (error) { return error && error.level === 'warning'; };
5519
- var isMissingPropertyError = function (_f) {
5520
- var params = _f.params;
5521
- return !!params && 'missingProperty' in params;
5163
+ var nodeAvailableProperties = function (node, _d) {
5164
+ var fullKey = _d.fullKey, schema = _d.schema, schemaType = _d.schemaType;
5165
+ return availableProperties(schema, schemaType, fullKey ? get$1(node, fullKey, {}) : node, fullKey.length > 0);
5522
5166
  };
5523
- var isMissingOneOfError = function (_f) {
5524
- var keyword = _f.keyword, schemaPath = _f.schemaPath;
5525
- return keyword === 'required' && (schemaPath || '').includes('oneOf');
5167
+ var isAddPropertyEnabled = function (node, schemaType, schema, fullKey) {
5168
+ if (fullKey === void 0) { fullKey = ''; }
5169
+ return !!schema &&
5170
+ !!Object.keys(nodeAvailableProperties(node, { fullKey: fullKey, schema: schema })).length &&
5171
+ (!fullKey || nestingTypeEnabled(schemaType));
5526
5172
  };
5527
- var isFailingKeywordError = function (_f) {
5528
- var params = _f.params;
5529
- return !!params && 'failingKeyword' in params;
5173
+ var editableKey = function (key) { return !['type', '@type', 'termType'].includes(key); };
5174
+ var propertyId = function () { return uuid.v4(); };
5175
+ var propertyUrl = function (node, key) { return ['@id', 'name'].includes(key) && linkTypeEnabled(node['@type']) ?
5176
+ {
5177
+ url: baseUrl() + "/" + node['@type'].toLowerCase() + "/" + node['@id'],
5178
+ title: 'Open'
5179
+ } :
5180
+ (node.type === schema.SchemaType.Term && ['name'].includes(key) ? {
5181
+ url: baseUrl() + "/glossary?query=",
5182
+ urlParamValue: true,
5183
+ title: 'Search in Glossary'
5184
+ } : undefined); };
5185
+ var propertyMapsUrl = function (node, key, value) { return ['type'].includes(key) && [
5186
+ schema.SchemaType.Site.toString(),
5187
+ schema.SchemaType.Organisation.toString()
5188
+ ].includes(stringValue(value) || node.type) ?
5189
+ {
5190
+ url: mapsUrl({ lat: node.latitude, lng: node.longitude }),
5191
+ title: 'View on maps',
5192
+ icon: 'map'
5193
+ } :
5194
+ undefined; };
5195
+ var propertyExternalUrl = function (node, key, value) { return propertyUrl(node, key) ||
5196
+ propertyMapsUrl(node, key, value); };
5197
+ var arrayPlaceholder = function (valueType) { return "Type a " + valueType + " then press Enter"; };
5198
+ var defaultPlaceholder = function (_d, valueType) {
5199
+ var type = _d.type, examples = _d.examples;
5200
+ return (examples === null || examples === void 0 ? void 0 : examples.length) ? (Array.isArray(examples[0]) ? arrayPlaceholder(valueType) : examples[0]) : "Must be of type " + (type || valueType);
5201
+ };
5202
+ var schemaPlacholder = function (schema, fullKey) {
5203
+ var _d = __read(fullKey.split('.')), parent = _d[0], keys = _d.slice(1);
5204
+ var properties = schema.properties || {};
5205
+ var examples = (parent in properties ? properties[parent] : { examples: [] }).examples;
5206
+ return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$1(examples[0], keys.join('.'), null) : null;
5207
+ };
5208
+ var propertyPlaceholder = function (schema, valueType, fullKey, parentSchema) {
5209
+ if (fullKey === void 0) { fullKey = ''; }
5210
+ return schema.type === 'array' ?
5211
+ arrayPlaceholder(valueType) : (parentSchema && (fullKey === null || fullKey === void 0 ? void 0 : fullKey.length) ? schemaPlacholder(parentSchema, fullKey) : null) || defaultPlaceholder(schema, valueType);
5212
+ };
5213
+ var propertyTypeValue = {
5214
+ object: function (val) { return safeJSONStringify(val); },
5215
+ array: function (val, schema) {
5216
+ var items = schema.items;
5217
+ return '$ref' in items ? val : (Array.isArray(val) ?
5218
+ val.map(function (value) { return propertyValue(items, value); }).join(ARRAY_DELIMITER) :
5219
+ val);
5220
+ },
5221
+ json: function (val) { return val || ''; },
5222
+ string: function (val) { return ("" + val || '').trim(); },
5223
+ number: function (val) { return +("" + val || '0'); },
5224
+ integer: function (val) { return +("" + val || '0'); },
5225
+ boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5226
+ };
5227
+ var propertyValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5228
+ propertyTypeValue[typeof value](value, schema) :
5229
+ propertyTypeValue[schema.type](value, schema)) :
5230
+ safeJSONStringify(value); };
5231
+ var propertyValueType = function (schema, value) { return (schema.type ? (Array.isArray(schema.type) ?
5232
+ schema.type[0] :
5233
+ schema.type === 'array' ?
5234
+ propertyValueType(Object.assign(Object.assign({}, schema), { type: [schema.items.type] })) :
5235
+ schema.type) : typeof value); };
5236
+ var propertyTypeParseValue = {
5237
+ object: function (val) { return safeJSONParse(val); },
5238
+ array: function (val, schema) {
5239
+ var items = schema.items;
5240
+ return '$ref' in items ? val : (!val || Array.isArray(val) ? val : val.split(ARRAY_DELIMITER).map(function (value) { return parseNewValue(items, value); }));
5241
+ },
5242
+ json: function (val) { return val || ''; },
5243
+ string: function (val) { return ("" + val || '').trim(); },
5244
+ number: function (val) { return +("" + val || '0'); },
5245
+ integer: function (val) { return +("" + val || '0'); },
5246
+ boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5247
+ };
5248
+ /**
5249
+ * Convert value to the final type in the schema.
5250
+ *
5251
+ * @param schema Definition of the value.
5252
+ * @param value
5253
+ * @returns Value in the correct format.
5254
+ */
5255
+ var parseNewValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5256
+ propertyTypeParseValue[typeof value](value, schema) :
5257
+ propertyTypeParseValue[schema.type](value, schema)) : value; };
5258
+ var isOpenDefault = function (schemaType) { return [
5259
+ schema.SchemaType.Term
5260
+ ].includes(schemaType); };
5261
+ // can the property be seen when the group is closed
5262
+ var isKeyClosedVisible = function (key) { return ['type', 'id', '@type', '@id'].includes(key); };
5263
+ var isKeyHidden = function (key) { return ['type', '@type'].includes(key); };
5264
+ var isKeyRequired = function (key, def) { return ['type', 'id'].includes(key) || ((def === null || def === void 0 ? void 0 : def.required) || []).includes(key); };
5265
+ var propertyError = function (errors) { return function (dataPath, nonExpandableArray) {
5266
+ if (nonExpandableArray === void 0) { nonExpandableArray = false; }
5267
+ return errors.find(function (error) { return (error.dataPath === dataPath || (nonExpandableArray && nonExpandableArrayDataPath(error.dataPath) === nonExpandableArrayDataPath(dataPath))) && (dataPath.length > 0 || !isMissingPropertyError(error)); });
5268
+ }; };
5269
+ var missingPropertyErrors = function (node, errors, parent) {
5270
+ if (parent === void 0) { parent = ''; }
5271
+ var allErrors = errors.filter(function (error) { return error.dataPath === keyToDataPath(parent) && isMissingPropertyError(error); });
5272
+ // check for node not found errors
5273
+ var missingNode = missingNodeErrors(allErrors);
5274
+ return missingNode.length === 2 ? [{
5275
+ id: propertyId(),
5276
+ schemaType: node.type,
5277
+ suggestions: { type: defaultSuggestionType },
5278
+ key: '',
5279
+ fullKey: parent,
5280
+ value: '',
5281
+ error: {
5282
+ level: 'error',
5283
+ message: missingNodeErrorMessage(node)
5284
+ },
5285
+ hasError: true,
5286
+ properties: [],
5287
+ addPropertyEnabled: false
5288
+ }] : allErrors.map(function (error) {
5289
+ var missingProperty = error.params.missingProperty;
5290
+ var fullKey = parent ? parent + "." + missingProperty : missingProperty;
5291
+ var missingOneOf = isMissingOneOfError(error);
5292
+ return {
5293
+ id: propertyId(),
5294
+ schemaType: node.type,
5295
+ suggestions: { type: defaultSuggestionType },
5296
+ key: missingProperty,
5297
+ fullKey: fullKey,
5298
+ value: 'Add field to fix',
5299
+ editable: false,
5300
+ error: formatError(error),
5301
+ hasError: missingOneOf ? false : errorHasError(error),
5302
+ hasWarning: missingOneOf || errorHasWarning(error),
5303
+ properties: [],
5304
+ addPropertyEnabled: true
5305
+ };
5306
+ });
5530
5307
  };
5531
- var filterError = function (error) { return [
5532
- isFailingKeywordError
5533
- ].every(function (func) { return !func(error); }); };
5534
- var missingNodeErrors = function (errors) { return errors.filter(function (_f) {
5535
- var keyword = _f.keyword, params = _f.params;
5536
- return keyword === 'required' && ((params === null || params === void 0 ? void 0 : params.missingProperty) === '@type' || (params === null || params === void 0 ? void 0 : params.missingProperty) === '@id');
5537
- }); };
5538
-
5539
- var _d;
5540
- /* eslint-disable complexity */
5541
- var get$1 = require('lodash.get');
5542
- var ARRAY_DELIMITER = ';';
5543
- var privateKeys = [
5544
- 'filepath'
5545
- ];
5546
- var defaultSuggestionType = 'default';
5547
- var stringValue = function (value) { return (typeof value === 'undefined' || value === null ? '' : value).toString(); };
5548
- var nonExpandableArrayDataPath = function (key) { return key.replace(/\[\d+\]$/, ''); };
5549
- var keyToDataPath = function (key) { return (key === null || key === void 0 ? void 0 : key.length) ? "." + key : ''; };
5550
- var dataPathToKey = function (dataPath, trimArray) {
5551
- if (trimArray === void 0) { trimArray = false; }
5552
- return trimArray ? nonExpandableArrayDataPath(dataPath.substring(1)) : dataPath.substring(1);
5308
+ var propertyFromNode = function (schemas, errors, nodeSchema, deepEditable, parent, node) {
5309
+ if (parent === void 0) { parent = ''; }
5310
+ return function (key) {
5311
+ var value = node[key];
5312
+ var expandable = schema.isExpandable(value);
5313
+ var isArray = Array.isArray(value);
5314
+ var nonExpandableArray = isArray && !expandable;
5315
+ var fullKey = Array.isArray(node) ? parent + "[" + key + "]" : [
5316
+ parent,
5317
+ key
5318
+ ].filter(Boolean).join('.');
5319
+ var nodeType = node.type || node['@type'];
5320
+ var schemaType = expandable ? (isArray && value.length ? value[0].type || value[0]['@type'] : value.type || value['@type']) : nodeType;
5321
+ var schema$1 = (schemas && schema.isTypeValid({ type: schemaType }) ? (expandable ? schemas[schemaType] : schemas[schemaType].properties[key]) : null) || {};
5322
+ var isIri = isSchemaIri(schema$1);
5323
+ var error = propertyError(errors)(keyToDataPath(fullKey), nonExpandableArray);
5324
+ var parentSchema = expandable ? (
5325
+ // TODO: for non-array, should be schema unless last recursion
5326
+ isArray ? schema$1 : nodeSchema) : nodeSchema;
5327
+ var properties = expandable || isIri ?
5328
+ recursiveProperties(schemas, errors, parentSchema, deepEditable, fullKey)(value) : [];
5329
+ var inError = errorHasError(error) || hasError(properties);
5330
+ var inWarning = errorHasWarning(error) || hasWarning(properties);
5331
+ var editable = schema.isTypeNode(node['@type']) || (expandable && schema.isTypeNode(value['@type'])) ?
5332
+ false :
5333
+ (
5334
+ // prevent editing/adding new properties on existing sub-nodes
5335
+ !deepEditable && schema.isTypeNode(schemaType) && (expandable ? value.type !== schema.NodeType.Term : parent && node.type !== schema.NodeType.Term) ?
5336
+ false :
5337
+ // handle IRI
5338
+ (!schemaType && key === '@id') || editableKey(key));
5339
+ var valueType = propertyValueType(schema$1, value);
5340
+ return {
5341
+ id: propertyId(),
5342
+ schemaType: isIri ? null : schemaType,
5343
+ schema: schema$1,
5344
+ key: key,
5345
+ fullKey: fullKey,
5346
+ value: propertyValue(schema$1, value),
5347
+ editable: inError || editable,
5348
+ suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema$1),
5349
+ addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schema$1, fullKey),
5350
+ newProperty: {},
5351
+ newError: { level: 'warning' },
5352
+ error: formatError(error),
5353
+ isHidden: parent && isKeyHidden(key),
5354
+ closedVisible: isKeyClosedVisible(key),
5355
+ hasError: inError,
5356
+ hasWarning: inWarning,
5357
+ isRequired: isKeyRequired(key, schemas[nodeType]),
5358
+ isArray: isArray,
5359
+ isExpandable: expandable,
5360
+ isOpen: isOpenDefault(schemaType),
5361
+ properties: properties,
5362
+ placeholder: propertyPlaceholder(schema$1, valueType, fullKey, parentSchema),
5363
+ externalUrl: propertyExternalUrl(node, key, value)
5364
+ };
5365
+ };
5553
5366
  };
5554
- var parentKey = function (key) {
5555
- var keys = (key.startsWith('.') ? key.substring(1) : key).split('.');
5556
- keys.pop();
5557
- return keys.join('.');
5367
+ var singleProperty = function (schemas, errors, node, fullKey) {
5368
+ var _d = __read(fullKey.split('.')), _t = _d[0], keys = _d.slice(1);
5369
+ var key = keys.pop();
5370
+ var parent = keys.join('.');
5371
+ var parentNode = parent.length ? get$1(node, parent) : node;
5372
+ var schemaType = schema.typeToSchemaType(parentNode.type || parentNode['@type']);
5373
+ var parentSchema = schemas[schemaType];
5374
+ return propertyFromNode(schemas, errors, parentSchema, true, parent, parentNode)(key);
5558
5375
  };
5559
- /**
5560
- * Sort properties having errors, type, id, ...properties (simple), and finally the groups
5561
- *
5562
- * @param a {INodeProperty}
5563
- * @param b {INodeProperty}
5564
- */
5565
- var sortProperties = function (a, b) {
5566
- if (utils.isNumber(a.key) && utils.isNumber(b.key)) {
5567
- return +a.key - +b.key;
5568
- }
5569
- if (a.isExpandable) {
5570
- return b.isExpandable ? a.key.localeCompare(b.key) : 1;
5571
- }
5572
- if (b.isExpandable) {
5573
- return -1;
5574
- }
5575
- if (!a.key) {
5576
- return -1;
5577
- }
5578
- var aKey = a.key.replace('@', '');
5579
- var bKey = b.key.replace('@', '');
5580
- if (aKey === 'type') {
5581
- return -1;
5582
- }
5583
- if (bKey === 'type') {
5584
- return 1;
5585
- }
5586
- if (aKey === 'id' && bKey !== 'type') {
5587
- return -1;
5588
- }
5589
- if (a.hasError || a.hasWarning) {
5590
- return -1;
5591
- }
5592
- return a.key.localeCompare(b.key);
5376
+ var recursiveProperties = function (schemas, errors, nodeSchema, deepEditable, parent) {
5377
+ if (parent === void 0) { parent = ''; }
5378
+ return function (node) {
5379
+ var _d;
5380
+ return (_d = Object.keys(node)
5381
+ .filter(function (key) { return !privateKeys.includes(key); })
5382
+ .map(propertyFromNode(schemas, errors, nodeSchema, deepEditable, parent, node)))
5383
+ .concat.apply(_d, __spreadArray([], __read(missingPropertyErrors(node, errors, parent)))).sort(sortProperties);
5384
+ };
5593
5385
  };
5594
- var defaultPropertyError = {
5595
- max: function (_d) {
5596
- var max = _d.max;
5597
- return "should be <= " + max;
5598
- },
5599
- min: function (_d) {
5600
- var min = _d.min;
5601
- return "should be >= " + min;
5602
- },
5603
- pattern: function (_d) {
5604
- var requiredPattern = _d.requiredPattern;
5605
- return "should match pattern \"" + requiredPattern + "\"";
5606
- },
5607
- required: function (_e, _d) {
5608
- var schemaType = _d.schemaType;
5609
- return schemaType ? "should be set or linked to another " + schemaType : undefined;
5386
+ var fullKeyParts = function (fullKey) { return fullKey.split('.').flatMap(function (val) {
5387
+ if (val.endsWith(']')) {
5388
+ var _d = __read(val.split('['), 2), key = _d[0], index = _d[1];
5389
+ return [key, index.replace(']', '')];
5610
5390
  }
5391
+ return val;
5392
+ }); };
5393
+ var updateProperties = function (_d, updater) {
5394
+ var properties = _d.properties;
5395
+ return (properties || []).map(function (prop) { return updateProperties(updater(prop), updater); });
5611
5396
  };
5612
- var formatPropertyError = function (errors, property) {
5613
- var key = Object.keys(errors)[0];
5614
- return key in defaultPropertyError ? formatCustomErrorMessage(defaultPropertyError[key](errors[key], property)) : '';
5397
+ var typeToNewProperty = function (schemas, schema, nodeSchema, node, fullKey) {
5398
+ var key = fullKeyParts(fullKey).pop();
5399
+ var mappings = {
5400
+ object: function () {
5401
+ var _d = schemaRequiredProperties(schemas, schema), schemaType = _d.schemaType, properties = _d.properties;
5402
+ node[key] = node[key] || {};
5403
+ node[key].type = schemaType;
5404
+ // TODO: handle load schemas from http source
5405
+ if (schemaType.startsWith('http')) {
5406
+ return typeToNewProperty(schemas, { type: 'json' }, nodeSchema, node, fullKey);
5407
+ }
5408
+ // TODO: handle nodeSchema should be schema unless last recursion
5409
+ var props = properties
5410
+ .filter(function (prop) { return nestingEnabled(schemaType, prop.key) && !!prop.value; })
5411
+ .map(function (v) { return (Object.assign(Object.assign({}, typeToNewProperty(schemas, v.value, nodeSchema, node[key], fullKey + "." + v.key)), { isRequired: true })); });
5412
+ var value = props.reduce(function (prev, curr) {
5413
+ var _d;
5414
+ return (Object.assign(Object.assign({}, prev), (_d = {}, _d[curr.key] = curr.value, _d)));
5415
+ }, {});
5416
+ return {
5417
+ id: propertyId(),
5418
+ isAdded: true,
5419
+ schema: schemas[schemaType],
5420
+ schemaType: schemaType,
5421
+ key: key,
5422
+ fullKey: fullKey,
5423
+ value: value,
5424
+ editable: editableKey(key),
5425
+ isHidden: isKeyHidden(key),
5426
+ closedVisible: isKeyClosedVisible(key),
5427
+ suggestions: enableSuggestions(nodeSchema, schemaType, fullKey),
5428
+ properties: props.sort(sortProperties),
5429
+ addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schemas[schemaType], key),
5430
+ newProperty: {},
5431
+ newError: { level: 'warning' },
5432
+ isRequired: isKeyRequired(key, schema),
5433
+ isArray: false,
5434
+ isExpandable: true,
5435
+ isOpen: isOpenDefault(schemaType)
5436
+ };
5437
+ },
5438
+ array: function () {
5439
+ var items = schema.items;
5440
+ // array of string, number and boolean
5441
+ if (items.type) {
5442
+ return mappings.default();
5443
+ }
5444
+ var schemaType = definitionToSchemaType(items);
5445
+ node[key] = node[key] || [];
5446
+ node[key].push({});
5447
+ var property = typeToNewProperty(schemas, items, schemas[schemaType], node[key][0], fullKey + "[0]");
5448
+ return {
5449
+ id: propertyId(),
5450
+ isAdded: true,
5451
+ schema: schema,
5452
+ schemaType: schemaType,
5453
+ key: key,
5454
+ fullKey: fullKey,
5455
+ value: [property.value],
5456
+ editable: editableKey(key),
5457
+ isHidden: isKeyHidden(key),
5458
+ closedVisible: isKeyClosedVisible(key),
5459
+ suggestions: undefined,
5460
+ properties: [property],
5461
+ newProperty: {},
5462
+ newError: { level: 'warning' },
5463
+ isArray: true,
5464
+ isExpandable: true,
5465
+ addPropertyEnabled: false
5466
+ };
5467
+ },
5468
+ default: function () {
5469
+ var valueType = propertyValueType(schema);
5470
+ var value = schema.default || schema.const || valueTypeToDefault[valueType];
5471
+ node[key] = value;
5472
+ return {
5473
+ id: propertyId(),
5474
+ isAdded: true,
5475
+ schema: schema,
5476
+ schemaType: node.type,
5477
+ key: key,
5478
+ fullKey: fullKey,
5479
+ value: propertyValue(schema, value),
5480
+ editable: editableKey(key),
5481
+ isHidden: isKeyHidden(key),
5482
+ closedVisible: isKeyClosedVisible(key),
5483
+ suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema),
5484
+ placeholder: propertyPlaceholder(schema, valueType, fullKey, nodeSchema),
5485
+ externalUrl: propertyExternalUrl(node, key, value),
5486
+ properties: [],
5487
+ addPropertyEnabled: false
5488
+ };
5489
+ }
5490
+ };
5491
+ var mapped = !schema.type ? mappings.object : (schema.type in mappings ? mappings[schema.type] : mappings.default);
5492
+ return mapped();
5615
5493
  };
5616
- var hasError = function (value) { return Array.isArray(value) ? value.some(hasError) : value.hasError; };
5617
- var hasWarning = function (value) { return Array.isArray(value) ? value.some(hasWarning) : value.hasWarning; };
5618
- var compileSuggestionQueries = function (key, allOf) {
5619
- var conditions = (allOf || [])
5620
- .filter(function (v) { var _c; return (((_c = v.if) === null || _c === void 0 ? void 0 : _c.required) || []).includes(key); })
5621
- .map(function (v) { var _c; return (_c = v.then) === null || _c === void 0 ? void 0 : _c.properties[key]; })
5622
- .map(function (v) { var _c; return ((_c = v === null || v === void 0 ? void 0 : v.items) === null || _c === void 0 ? void 0 : _c.properties) || (v === null || v === void 0 ? void 0 : v.properties); })
5623
- .filter(Boolean);
5624
- return conditions.length ? [{
5625
- bool: {
5626
- should: conditions.flatMap(function (cond) { return Object.keys(cond).flatMap(function (k) { return (cond[k].enum || []).map(function (v) {
5627
- var _d;
5628
- return ({
5629
- match: (_d = {}, _d[k] = v, _d)
5630
- });
5631
- }); }); }),
5632
- minimum_should_match: 1
5494
+ var findProperty = function (properties, fullKey) {
5495
+ var e_1, _d;
5496
+ try {
5497
+ for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
5498
+ var p = properties_1_1.value;
5499
+ if (p.fullKey === fullKey) {
5500
+ return p;
5633
5501
  }
5634
- }] : [];
5635
- };
5636
- // default suggest for linking nodes together using the `id` field
5637
- var suggestLinkNodes = function (type, fullKey) {
5638
- var keys = fullKey.split('.');
5639
- var key = keys.pop();
5640
- return key === 'id' && keys.length >= 1 ? { type: type, isLinkNode: true } : undefined;
5502
+ var childP = findProperty(p.properties, fullKey);
5503
+ if (childP) {
5504
+ return childP;
5505
+ }
5506
+ }
5507
+ }
5508
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
5509
+ finally {
5510
+ try {
5511
+ if (properties_1_1 && !properties_1_1.done && (_d = properties_1.return)) _d.call(properties_1);
5512
+ }
5513
+ finally { if (e_1) throw e_1.error; }
5514
+ }
5515
+ return null;
5641
5516
  };
5642
- var suggestExistingNode = function (type, fullKey) {
5643
- var keys = fullKey.split('.');
5644
- var key = keys.pop();
5645
- return keys.length >= 1 && ['@id', 'openLCAId'].includes(key) ? { type: type, isUniqueKey: '@id' } : undefined;
5517
+ var parentProperty = function (properties, property) {
5518
+ var _c;
5519
+ var allKeys = property.fullKey.split('.');
5520
+ __spreadArray([], __read(new Array(((_c = property.suggestions) === null || _c === void 0 ? void 0 : _c.parentLevel) || 0))).map(function () { return allKeys.pop(); });
5521
+ var parentKeys = fullKeyParts(allKeys.join('.'));
5522
+ parentKeys.pop();
5523
+ var parent = parentKeys.reduce(function (prev, curr, currIndex) {
5524
+ var prop = prev.find(function (v) { return v.key === curr; });
5525
+ return currIndex === parentKeys.length - 1 ? (prop || {}) : (prop.properties || []);
5526
+ }, properties);
5527
+ return Array.isArray(parent) ? property : parent;
5646
5528
  };
5647
- var defaultNodeTypeSuggestion = function (type) { return function (fullKey) { return suggestLinkNodes(type, fullKey) || suggestExistingNode(type, fullKey); }; };
5648
- var termSuggestions = function (parent, _d) {
5649
- var allOf = _d.allOf;
5650
- return ({
5651
- type: schema.NodeType.Term,
5652
- queries: __spreadArray(__spreadArray([], __read(compileSuggestionQueries(nonExpandableArrayDataPath(parent), allOf))), __read((['country'].includes(parent) ? [matchCountry] : [])))
5529
+ var nestedProperty = function (_d, nestedKey) {
5530
+ var properties = _d.properties;
5531
+ return properties.find(function (_d) {
5532
+ var key = _d.key;
5533
+ return key === nestedKey;
5653
5534
  });
5654
5535
  };
5655
- var formatLinkNodesSuggestions = function (nodeMap, type) { return (nodeMap[type] || []).map(function (id) { return ({ type: type, id: id, name: "Link with " + type + ": " + id }); }); };
5656
- var typeToSuggestion = (_d = {},
5657
- _d[schema.NodeType.Actor] = defaultNodeTypeSuggestion(schema.NodeType.Actor),
5658
- _d[schema.NodeType.Cycle] = defaultNodeTypeSuggestion(schema.NodeType.Cycle),
5659
- _d[schema.NodeType.ImpactAssessment] = defaultNodeTypeSuggestion(schema.NodeType.ImpactAssessment),
5660
- _d[schema.NodeType.Organisation] = defaultNodeTypeSuggestion(schema.NodeType.Organisation),
5661
- _d[schema.NodeType.Site] = defaultNodeTypeSuggestion(schema.NodeType.Site),
5662
- _d[schema.NodeType.Source] = defaultNodeTypeSuggestion(schema.NodeType.Source),
5663
- _d[schema.NodeType.Term] = function (fullKey, parentSchema) {
5664
- var keys = fullKey.split('.');
5665
- var key = keys.pop();
5666
- return ['name'].includes(key) && keys.length >= 1 ?
5667
- termSuggestions(keys.pop(), parentSchema) :
5668
- defaultNodeTypeSuggestion(schema.NodeType.Term)(fullKey);
5669
- },
5670
- _d[schema.SchemaType.Bibliography] = function (fullKey) {
5671
- var keys = fullKey.split('.');
5672
- var key = keys.pop();
5673
- var parent = keys.pop();
5674
- // prevent replacing a top-level source
5675
- return ['title', 'documentDOI', 'scopus'].includes(key) && parent === 'bibliography' && keys.length >= 1 ? {
5676
- type: schema.NodeType.Source,
5677
- parentLevel: 1
5678
- } : null;
5679
- },
5680
- _d.number = function (_a, _b, schema) {
5681
- var values = schema.const ? [schema.const] : [];
5682
- return {
5683
- type: values.length > 0 ? 'select' : defaultSuggestionType,
5684
- // exclude suggesting SchemaType
5685
- values: values
5686
- };
5687
- },
5688
- _d.integer = function (_a, _b, schema) {
5689
- var values = schema.const ? [schema.const] : [];
5690
- return {
5691
- type: values.length > 0 ? 'select' : defaultSuggestionType,
5692
- // exclude suggesting SchemaType
5693
- values: values
5694
- };
5695
- },
5696
- _d.string = function (fullKey, _b, schema$1) {
5697
- // exclude suggesting SchemaType
5698
- var values = schema$1.const ?
5699
- [schema$1.const] :
5700
- (schema$1.enum || []).filter(function (val) { return !Object.values(schema.SchemaType).includes(val); });
5701
- var key = fullKey.split('.').pop();
5702
- return {
5703
- type: values.length > 0 && key !== 'type' ? 'select' : defaultSuggestionType,
5704
- values: values
5705
- };
5706
- },
5707
- _d.boolean = function (_a) { return ({
5708
- type: 'select',
5709
- values: ['true', 'false']
5710
- }); },
5711
- _d);
5712
- var enableSuggestions = function (parentSchema, type, fullKey, schema) {
5713
- var suggestion = type in typeToSuggestion ? typeToSuggestion[type](fullKey, parentSchema) : null;
5714
- return suggestion !== null ? suggestion : (schema && schema.type in typeToSuggestion ?
5715
- typeToSuggestion[schema.type](fullKey, parentSchema, schema) :
5716
- null);
5717
- };
5718
- var formatProperty = function (prop) { return (Object.assign(Object.assign({ '@type': schema.SchemaType.Property }, prop), { term: Object.assign({ '@type': schema.NodeType.Term }, prop.term) })); };
5719
- var formatSuggestion = function (_c) {
5720
- var defaultProperties = _c.defaultProperties, node = __rest(_c, ["defaultProperties"]);
5721
- return (Object.assign(Object.assign({}, node), (defaultProperties ? { defaultProperties: defaultProperties.map(formatProperty) } : {})));
5722
- };
5723
- var nodeAvailableProperties = function (node, _d) {
5724
- var fullKey = _d.fullKey, schema = _d.schema, schemaType = _d.schemaType;
5725
- return availableProperties(schema, schemaType, fullKey ? get$1(node, fullKey, {}) : node, fullKey.length > 0);
5726
- };
5727
- var isAddPropertyEnabled = function (node, schemaType, schema, fullKey) {
5728
- if (fullKey === void 0) { fullKey = ''; }
5729
- return !!schema &&
5730
- !!Object.keys(nodeAvailableProperties(node, { fullKey: fullKey, schema: schema })).length &&
5731
- (!fullKey || nestingTypeEnabled(schemaType));
5536
+ var siblingProperty = function (properties, property, siblingKey) {
5537
+ var parent = parentProperty(properties, property);
5538
+ var parentProperties = parent === property ? properties : parent.properties;
5539
+ return parentProperties.find(function (prop) { return prop.key === siblingKey; });
5732
5540
  };
5733
- var editableKey = function (key) { return !['type', '@type', 'termType'].includes(key); };
5734
- var propertyId = function () { return uuid.v4(); };
5735
- var propertyUrl = function (node, key) { return ['@id', 'name'].includes(key) && linkTypeEnabled(node['@type']) ?
5736
- {
5737
- url: baseUrl() + "/" + node['@type'].toLowerCase() + "/" + node['@id'],
5738
- title: 'Open'
5739
- } :
5740
- (node.type === schema.SchemaType.Term && ['name'].includes(key) ? {
5741
- url: baseUrl() + "/glossary?query=",
5742
- urlParamValue: true,
5743
- title: 'Search in Glossary'
5744
- } : undefined); };
5745
- var propertyMapsUrl = function (node, key, value) { return ['type'].includes(key) && [
5746
- schema.SchemaType.Site.toString(),
5747
- schema.SchemaType.Organisation.toString()
5748
- ].includes(stringValue(value) || node.type) ?
5749
- {
5750
- url: mapsUrl({ lat: node.latitude, lng: node.longitude }),
5751
- title: 'View on maps',
5752
- icon: 'map'
5753
- } :
5754
- undefined; };
5755
- var propertyExternalUrl = function (node, key, value) { return propertyUrl(node, key) ||
5756
- propertyMapsUrl(node, key, value); };
5757
- var arrayPlaceholder = function (valueType) { return "Type a " + valueType + " then press Enter"; };
5758
- var defaultPlaceholder = function (_d, valueType) {
5759
- var type = _d.type, examples = _d.examples;
5760
- return (examples === null || examples === void 0 ? void 0 : examples.length) ? (Array.isArray(examples[0]) ? arrayPlaceholder(valueType) : examples[0]) : "Must be of type " + (type || valueType);
5541
+ var groupChanged = function (properties, key, value) {
5542
+ try {
5543
+ var parentKeys_1 = fullKeyParts(key);
5544
+ parentKeys_1.reduce(function (prev, curr, currIndex) {
5545
+ if (currIndex === parentKeys_1.length - 1 && value === null) {
5546
+ return prev.splice(prev.findIndex(function (v) { return v.key === curr; }), 1);
5547
+ }
5548
+ else {
5549
+ var prop = prev.find(function (v) { return v.key === curr; });
5550
+ prop.changed = true;
5551
+ return prop.properties;
5552
+ }
5553
+ }, properties);
5554
+ }
5555
+ catch (_err) { }
5761
5556
  };
5762
- var schemaPlacholder = function (schema, fullKey) {
5763
- var _d = __read(fullKey.split('.')), parent = _d[0], keys = _d.slice(1);
5764
- var properties = schema.properties || {};
5765
- var examples = (parent in properties ? properties[parent] : { examples: [] }).examples;
5766
- return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$1(examples[0], keys.join('.'), null) : null;
5557
+ var refreshPropertyKeys = function (property) { return property.properties.map(function (prop, i) {
5558
+ prop.fullKey = "" + property.fullKey + (property.isArray ? "[" + i + "]" : "." + prop.key);
5559
+ prop.key = property.isArray ? "" + i : prop.key;
5560
+ return refreshPropertyKeys(prop);
5561
+ }); };
5562
+ var calculateCycleDurationEnabled = function (properties, property) {
5563
+ var startDate = siblingProperty(properties, property, 'startDate');
5564
+ var endDate = siblingProperty(properties, property, 'endDate');
5565
+ return !!(startDate === null || startDate === void 0 ? void 0 : startDate.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
5767
5566
  };
5768
- var propertyPlaceholder = function (schema, valueType, fullKey, parentSchema) {
5769
- if (fullKey === void 0) { fullKey = ''; }
5770
- return schema.type === 'array' ?
5771
- arrayPlaceholder(valueType) : (parentSchema && (fullKey === null || fullKey === void 0 ? void 0 : fullKey.length) ? schemaPlacholder(parentSchema, fullKey) : null) || defaultPlaceholder(schema, valueType);
5567
+ var calculateCycleDuration = function (properties, property) {
5568
+ var startDate = siblingProperty(properties, property, 'startDate');
5569
+ var endDate = siblingProperty(properties, property, 'endDate');
5570
+ return utils.diffInDays(startDate.value, endDate.value);
5772
5571
  };
5773
- var propertyTypeValue = {
5774
- object: function (val) { return safeJSONStringify(val); },
5775
- array: function (val, schema) {
5776
- var items = schema.items;
5777
- return '$ref' in items ? val : (Array.isArray(val) ?
5778
- val.map(function (value) { return propertyValue(items, value); }).join(ARRAY_DELIMITER) :
5779
- val);
5780
- },
5781
- json: function (val) { return val || ''; },
5782
- string: function (val) { return ("" + val || '').trim(); },
5783
- number: function (val) { return +("" + val || '0'); },
5784
- integer: function (val) { return +("" + val || '0'); },
5785
- boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5572
+ var calculateCycleStartDateEnabled = function (properties, property) {
5573
+ var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
5574
+ var endDate = siblingProperty(properties, property, 'endDate');
5575
+ return !!(cycleDuration === null || cycleDuration === void 0 ? void 0 : cycleDuration.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
5786
5576
  };
5787
- var propertyValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5788
- propertyTypeValue[typeof value](value, schema) :
5789
- propertyTypeValue[schema.type](value, schema)) :
5790
- safeJSONStringify(value); };
5791
- var propertyValueType = function (schema, value) { return (schema.type ? (Array.isArray(schema.type) ?
5792
- schema.type[0] :
5793
- schema.type === 'array' ?
5794
- propertyValueType(Object.assign(Object.assign({}, schema), { type: [schema.items.type] })) :
5795
- schema.type) : typeof value); };
5796
- var propertyTypeParseValue = {
5797
- object: function (val) { return safeJSONParse(val); },
5798
- array: function (val, schema) {
5799
- var items = schema.items;
5800
- return '$ref' in items ? val : (!val || Array.isArray(val) ? val : val.split(ARRAY_DELIMITER).map(function (value) { return parseNewValue(items, value); }));
5801
- },
5802
- json: function (val) { return val || ''; },
5803
- string: function (val) { return ("" + val || '').trim(); },
5804
- number: function (val) { return +("" + val || '0'); },
5805
- integer: function (val) { return +("" + val || '0'); },
5806
- boolean: function (val) { return ("" + val || '').toLowerCase() === 'true'; }
5577
+ var calculateCycleStartDate = function (properties, property) {
5578
+ var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
5579
+ var endDate = siblingProperty(properties, property, 'endDate');
5580
+ return moment__namespace(endDate.value).locale('en-gb').subtract(cycleDuration.value, 'days').format('YYYY-MM-DD');
5807
5581
  };
5808
- /**
5809
- * Convert value to the final type in the schema.
5810
- *
5811
- * @param schema Definition of the value.
5812
- * @param value
5813
- * @returns Value in the correct format.
5814
- */
5815
- var parseNewValue = function (schema, value) { return schema.type ? (Array.isArray(schema.type) ?
5816
- propertyTypeParseValue[typeof value](value, schema) :
5817
- propertyTypeParseValue[schema.type](value, schema)) : value; };
5818
- var isOpenDefault = function (schemaType) { return [
5819
- schema.SchemaType.Term
5820
- ].includes(schemaType); };
5821
- // can the property be seen when the group is closed
5822
- var isKeyClosedVisible = function (key) { return ['type', 'id', '@type', '@id'].includes(key); };
5823
- var isKeyHidden = function (key) { return ['type', '@type'].includes(key); };
5824
- var isKeyRequired = function (key, def) { return ['type', 'id'].includes(key) || ((def === null || def === void 0 ? void 0 : def.required) || []).includes(key); };
5825
- var propertyError = function (errors) { return function (dataPath, nonExpandableArray) {
5826
- if (nonExpandableArray === void 0) { nonExpandableArray = false; }
5827
- return errors.find(function (error) { return (error.dataPath === dataPath || (nonExpandableArray && nonExpandableArrayDataPath(error.dataPath) === nonExpandableArrayDataPath(dataPath))) && (dataPath.length > 0 || !isMissingPropertyError(error)); });
5828
- }; };
5829
- var missingPropertyErrors = function (node, errors, parent) {
5830
- if (parent === void 0) { parent = ''; }
5831
- var allErrors = errors.filter(function (error) { return error.dataPath === keyToDataPath(parent) && isMissingPropertyError(error); });
5832
- // check for node not found errors
5833
- var missingNode = missingNodeErrors(allErrors);
5834
- return missingNode.length === 2 ? [{
5835
- id: propertyId(),
5836
- schemaType: node.type,
5837
- suggestions: { type: defaultSuggestionType },
5838
- key: '',
5839
- fullKey: parent,
5840
- value: '',
5841
- error: {
5842
- level: 'error',
5843
- message: missingNodeErrorMessage(node)
5844
- },
5845
- hasError: true,
5846
- properties: [],
5847
- addPropertyEnabled: false
5848
- }] : allErrors.map(function (error) {
5849
- var missingProperty = error.params.missingProperty;
5850
- var fullKey = parent ? parent + "." + missingProperty : missingProperty;
5851
- var missingOneOf = isMissingOneOfError(error);
5852
- return {
5853
- id: propertyId(),
5854
- schemaType: node.type,
5855
- suggestions: { type: defaultSuggestionType },
5856
- key: missingProperty,
5857
- fullKey: fullKey,
5858
- value: 'Add field to fix',
5859
- editable: false,
5860
- error: formatError(error),
5861
- hasError: missingOneOf ? false : errorHasError(error),
5862
- hasWarning: missingOneOf || errorHasWarning(error),
5863
- properties: [],
5864
- addPropertyEnabled: true
5865
- };
5866
- });
5582
+
5583
+ var isSite = function (_a) {
5584
+ var type = _a["@type"], id = _a["@id"];
5585
+ return type === schema.NodeType.Site && !!id;
5867
5586
  };
5868
- var propertyFromNode = function (schemas, errors, nodeSchema, deepEditable, parent, node) {
5869
- if (parent === void 0) { parent = ''; }
5870
- return function (key) {
5871
- var value = node[key];
5872
- var expandable = schema.isExpandable(value);
5873
- var isArray = Array.isArray(value);
5874
- var nonExpandableArray = isArray && !expandable;
5875
- var fullKey = Array.isArray(node) ? parent + "[" + key + "]" : [
5876
- parent,
5877
- key
5878
- ].filter(Boolean).join('.');
5879
- var nodeType = node.type || node['@type'];
5880
- var schemaType = expandable ? (isArray && value.length ? value[0].type || value[0]['@type'] : value.type || value['@type']) : nodeType;
5881
- var schema$1 = (schemas && schema.isTypeValid({ type: schemaType }) ? (expandable ? schemas[schemaType] : schemas[schemaType].properties[key]) : null) || {};
5882
- var isIri = isSchemaIri(schema$1);
5883
- var error = propertyError(errors)(keyToDataPath(fullKey), nonExpandableArray);
5884
- var parentSchema = expandable ? (
5885
- // TODO: for non-array, should be schema unless last recursion
5886
- isArray ? schema$1 : nodeSchema) : nodeSchema;
5887
- var properties = expandable || isIri ?
5888
- recursiveProperties(schemas, errors, parentSchema, deepEditable, fullKey)(value) : [];
5889
- var inError = errorHasError(error) || hasError(properties);
5890
- var inWarning = errorHasWarning(error) || hasWarning(properties);
5891
- var editable = schema.isTypeNode(node['@type']) || (expandable && schema.isTypeNode(value['@type'])) ?
5892
- false :
5893
- (
5894
- // prevent editing/adding new properties on existing sub-nodes
5895
- !deepEditable && schema.isTypeNode(schemaType) && (expandable ? value.type !== schema.NodeType.Term : parent && node.type !== schema.NodeType.Term) ?
5896
- false :
5897
- // handle IRI
5898
- (!schemaType && key === '@id') || editableKey(key));
5899
- var valueType = propertyValueType(schema$1, value);
5900
- return {
5901
- id: propertyId(),
5902
- schemaType: isIri ? null : schemaType,
5903
- schema: schema$1,
5904
- key: key,
5905
- fullKey: fullKey,
5906
- value: propertyValue(schema$1, value),
5907
- editable: inError || editable,
5908
- suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema$1),
5909
- addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schema$1, fullKey),
5910
- newProperty: {},
5911
- newError: { level: 'warning' },
5912
- error: formatError(error),
5913
- isHidden: parent && isKeyHidden(key),
5914
- closedVisible: isKeyClosedVisible(key),
5915
- hasError: inError,
5916
- hasWarning: inWarning,
5917
- isRequired: isKeyRequired(key, schemas[nodeType]),
5918
- isArray: isArray,
5919
- isExpandable: expandable,
5920
- isOpen: isOpenDefault(schemaType),
5921
- properties: properties,
5922
- placeholder: propertyPlaceholder(schema$1, valueType, fullKey, parentSchema),
5923
- externalUrl: propertyExternalUrl(node, key, value)
5924
- };
5925
- };
5587
+ var siteLocation = function (_a) {
5588
+ var latitude = _a.latitude, longitude = _a.longitude;
5589
+ return latitude && longitude ? ({
5590
+ lat: latitude,
5591
+ lng: longitude
5592
+ }) : undefined;
5926
5593
  };
5927
- var singleProperty = function (schemas, errors, node, fullKey) {
5928
- var _d = __read(fullKey.split('.')), _t = _d[0], keys = _d.slice(1);
5929
- var key = keys.pop();
5930
- var parent = keys.join('.');
5931
- var parentNode = parent.length ? get$1(node, parent) : node;
5932
- var schemaType = schema.typeToSchemaType(parentNode.type || parentNode['@type']);
5933
- var parentSchema = schemas[schemaType];
5934
- return propertyFromNode(schemas, errors, parentSchema, true, parent, parentNode)(key);
5594
+ var siteDefaultLocation = function (_a) {
5595
+ var region = _a.region, country = _a.country;
5596
+ var markers = [
5597
+ region ? createMarker(termLocation(region), termLocationName(region).name, undefined, 20) : undefined,
5598
+ country ? createMarker(termLocation(country), termLocationName(country).name, undefined, 40) : undefined
5599
+ ].filter(Boolean);
5600
+ return (markers.length ? markers[0] : undefined);
5935
5601
  };
5936
- var recursiveProperties = function (schemas, errors, nodeSchema, deepEditable, parent) {
5937
- if (parent === void 0) { parent = ''; }
5938
- return function (node) {
5939
- var _d;
5940
- return (_d = Object.keys(node)
5941
- .filter(function (key) { return !privateKeys.includes(key); })
5942
- .map(propertyFromNode(schemas, errors, nodeSchema, deepEditable, parent, node)))
5943
- .concat.apply(_d, __spreadArray([], __read(missingPropertyErrors(node, errors, parent)))).sort(sortProperties);
5602
+ var siteMarker = function (site) { return createMarker(site ? siteLocation(site) : undefined, site.name); };
5603
+ var sitePolygon = function (_a) {
5604
+ var boundary = _a.boundary;
5605
+ return (boundary ? polygonsFromFeature(boundary) : undefined);
5606
+ };
5607
+ var regions = function (sites) { return utils.unique(sites.map(function (_a) {
5608
+ var country = _a.country, region = _a.region;
5609
+ return region ? region['@id'] : (country ? country['@id'] : null);
5610
+ }).filter(Boolean)); };
5611
+ var defaultCenter = { lat: 0, lng: 0 };
5612
+ var SitesMapsComponent = /** @class */ (function () {
5613
+ function SitesMapsComponent(nodeService) {
5614
+ this.nodeService = nodeService;
5615
+ this.loaded = false;
5616
+ this.loadPolygons = true;
5617
+ this.sites = [];
5618
+ this.nodes = [];
5619
+ this.center = defaultCenter;
5620
+ this.zoom = 2;
5621
+ this.showNotice = true;
5622
+ this.googleLoaded = false;
5623
+ this.showNoLocation = false;
5624
+ }
5625
+ SitesMapsComponent.prototype.ngOnInit = function () {
5626
+ var _this = this;
5627
+ waitFor('google', function () {
5628
+ _this.googleLoaded = true;
5629
+ setTimeout(function () { return !_this.loaded && _this.loadData(); });
5630
+ });
5631
+ };
5632
+ SitesMapsComponent.prototype.ngAfterViewInit = function () {
5633
+ return this.googleLoaded && this.loadData();
5634
+ };
5635
+ SitesMapsComponent.prototype.loadData = function () {
5636
+ return __awaiter(this, void 0, void 0, function () {
5637
+ var sites, markers, polygons, termPolygons;
5638
+ var _this = this;
5639
+ return __generator(this, function (_a) {
5640
+ switch (_a.label) {
5641
+ case 0:
5642
+ // loaded data as geojson
5643
+ this.map.googleMap.data.setStyle(function () { return (Object.assign(Object.assign({}, strokeStyle), { strokeOpacity: 0.1 })); });
5644
+ return [4 /*yield*/, this.getSites()];
5645
+ case 1:
5646
+ sites = _a.sent();
5647
+ markers = this.addSiteMarkers(sites);
5648
+ polygons = sites.flatMap(sitePolygon).filter(Boolean);
5649
+ polygons.map(function (polygon) { return polygon === null || polygon === void 0 ? void 0 : polygon.setMap(_this.map.googleMap); });
5650
+ this.loaded = true;
5651
+ return [4 /*yield*/, Promise.all(regions(sites).map(function (v) { return _this.addTermsPolygons(v); }))];
5652
+ case 2:
5653
+ termPolygons = (_a.sent()).flat();
5654
+ this.showNoLocation = markers.length === 0 && polygons.length === 0 && termPolygons.length === 0;
5655
+ return [2 /*return*/, markers.length ?
5656
+ this.centerMarker(markers[0]) :
5657
+ this.centerPolygons(polygons.length ? polygons : termPolygons)];
5658
+ }
5659
+ });
5660
+ });
5661
+ };
5662
+ SitesMapsComponent.prototype.addMarkers = function (markers, cluster) {
5663
+ var _this = this;
5664
+ if (cluster === void 0) { cluster = false; }
5665
+ return cluster ?
5666
+ new MarkerClusterer__default["default"](this.map.googleMap, markers, { imagePath: clustererImage }) :
5667
+ markers.map(function (marker) { return marker.setMap(_this.map.googleMap); });
5668
+ };
5669
+ SitesMapsComponent.prototype.addTermsPolygons = function (id) {
5670
+ return __awaiter(this, void 0, void 0, function () {
5671
+ var _a;
5672
+ return __generator(this, function (_b) {
5673
+ switch (_b.label) {
5674
+ case 0:
5675
+ if (!this.loadPolygons) return [3 /*break*/, 2];
5676
+ return [4 /*yield*/, this.termPolygons(id)];
5677
+ case 1:
5678
+ _a = _b.sent();
5679
+ return [3 /*break*/, 3];
5680
+ case 2:
5681
+ _a = [];
5682
+ _b.label = 3;
5683
+ case 3: return [2 /*return*/, _a];
5684
+ }
5685
+ });
5686
+ });
5944
5687
  };
5945
- };
5946
- var fullKeyParts = function (fullKey) { return fullKey.split('.').flatMap(function (val) {
5947
- if (val.endsWith(']')) {
5948
- var _d = __read(val.split('['), 2), key = _d[0], index = _d[1];
5949
- return [key, index.replace(']', '')];
5950
- }
5951
- return val;
5952
- }); };
5953
- var updateProperties = function (_d, updater) {
5954
- var properties = _d.properties;
5955
- return (properties || []).map(function (prop) { return updateProperties(updater(prop), updater); });
5956
- };
5957
- var typeToNewProperty = function (schemas, schema, nodeSchema, node, fullKey) {
5958
- var key = fullKeyParts(fullKey).pop();
5959
- var mappings = {
5960
- object: function () {
5961
- var _d = schemaRequiredProperties(schemas, schema), schemaType = _d.schemaType, properties = _d.properties;
5962
- node[key] = node[key] || {};
5963
- node[key].type = schemaType;
5964
- // TODO: handle load schemas from http source
5965
- if (schemaType.startsWith('http')) {
5966
- return typeToNewProperty(schemas, { type: 'json' }, nodeSchema, node, fullKey);
5967
- }
5968
- // TODO: handle nodeSchema should be schema unless last recursion
5969
- var props = properties
5970
- .filter(function (prop) { return nestingEnabled(schemaType, prop.key) && !!prop.value; })
5971
- .map(function (v) { return (Object.assign(Object.assign({}, typeToNewProperty(schemas, v.value, nodeSchema, node[key], fullKey + "." + v.key)), { isRequired: true })); });
5972
- var value = props.reduce(function (prev, curr) {
5973
- var _d;
5974
- return (Object.assign(Object.assign({}, prev), (_d = {}, _d[curr.key] = curr.value, _d)));
5975
- }, {});
5976
- return {
5977
- id: propertyId(),
5978
- isAdded: true,
5979
- schema: schemas[schemaType],
5980
- schemaType: schemaType,
5981
- key: key,
5982
- fullKey: fullKey,
5983
- value: value,
5984
- editable: editableKey(key),
5985
- isHidden: isKeyHidden(key),
5986
- closedVisible: isKeyClosedVisible(key),
5987
- suggestions: enableSuggestions(nodeSchema, schemaType, fullKey),
5988
- properties: props.sort(sortProperties),
5989
- addPropertyEnabled: isAddPropertyEnabled(node, schemaType, schemas[schemaType], key),
5990
- newProperty: {},
5991
- newError: { level: 'warning' },
5992
- isRequired: isKeyRequired(key, schema),
5993
- isArray: false,
5994
- isExpandable: true,
5995
- isOpen: isOpenDefault(schemaType)
5996
- };
5997
- },
5998
- array: function () {
5999
- var items = schema.items;
6000
- // array of string, number and boolean
6001
- if (items.type) {
6002
- return mappings.default();
5688
+ SitesMapsComponent.prototype.centerMarker = function (marker) {
5689
+ var center = marker.getPosition();
5690
+ this.center = center ? { lat: center.lat(), lng: center.lng() } : defaultCenter;
5691
+ };
5692
+ SitesMapsComponent.prototype.centerPolygons = function (polygons) {
5693
+ try {
5694
+ return polygons.length ? this.map.googleMap.fitBounds(polygonBounds(polygons)) : null;
5695
+ }
5696
+ catch (err) {
5697
+ if (polygons.length) {
5698
+ this.map.googleMap.fitBounds(polygonBounds(polygons[0]));
5699
+ this.zoom = 3;
6003
5700
  }
6004
- var schemaType = definitionToSchemaType(items);
6005
- node[key] = node[key] || [];
6006
- node[key].push({});
6007
- var property = typeToNewProperty(schemas, items, schemas[schemaType], node[key][0], fullKey + "[0]");
6008
- return {
6009
- id: propertyId(),
6010
- isAdded: true,
6011
- schema: schema,
6012
- schemaType: schemaType,
6013
- key: key,
6014
- fullKey: fullKey,
6015
- value: [property.value],
6016
- editable: editableKey(key),
6017
- isHidden: isKeyHidden(key),
6018
- closedVisible: isKeyClosedVisible(key),
6019
- suggestions: undefined,
6020
- properties: [property],
6021
- newProperty: {},
6022
- newError: { level: 'warning' },
6023
- isArray: true,
6024
- isExpandable: true,
6025
- addPropertyEnabled: false
6026
- };
6027
- },
6028
- default: function () {
6029
- var valueType = propertyValueType(schema);
6030
- var value = schema.default || schema.const || valueTypeToDefault[valueType];
6031
- node[key] = value;
6032
- return {
6033
- id: propertyId(),
6034
- isAdded: true,
6035
- schema: schema,
6036
- schemaType: node.type,
6037
- key: key,
6038
- fullKey: fullKey,
6039
- value: propertyValue(schema, value),
6040
- editable: editableKey(key),
6041
- isHidden: isKeyHidden(key),
6042
- closedVisible: isKeyClosedVisible(key),
6043
- suggestions: enableSuggestions(nodeSchema, node.type, fullKey, schema),
6044
- placeholder: propertyPlaceholder(schema, valueType, fullKey, nodeSchema),
6045
- externalUrl: propertyExternalUrl(node, key, value),
6046
- properties: [],
6047
- addPropertyEnabled: false
6048
- };
6049
5701
  }
6050
5702
  };
6051
- var mapped = !schema.type ? mappings.object : (schema.type in mappings ? mappings[schema.type] : mappings.default);
6052
- return mapped();
5703
+ SitesMapsComponent.prototype.addSiteMarkers = function (sites) {
5704
+ var siteMarkers = sites.map(siteMarker).filter(Boolean);
5705
+ var markers = siteMarkers.length ? siteMarkers : sites.map(siteDefaultLocation).filter(Boolean);
5706
+ this.addMarkers(markers, !!siteMarkers.length);
5707
+ return markers;
5708
+ };
5709
+ SitesMapsComponent.prototype.loadSite = function (node) {
5710
+ return __awaiter(this, void 0, void 0, function () {
5711
+ var _a;
5712
+ return __generator(this, function (_b) {
5713
+ switch (_b.label) {
5714
+ case 0:
5715
+ if (!('schemaVersion' in node)) return [3 /*break*/, 1];
5716
+ _a = node;
5717
+ return [3 /*break*/, 3];
5718
+ case 1: return [4 /*yield*/, this.nodeService.get(node)];
5719
+ case 2:
5720
+ _a = _b.sent();
5721
+ _b.label = 3;
5722
+ case 3:
5723
+ // means the site was already downloaded
5724
+ return [2 /*return*/, _a];
5725
+ }
5726
+ });
5727
+ });
5728
+ };
5729
+ SitesMapsComponent.prototype.siteData = function (node) {
5730
+ return __awaiter(this, void 0, void 0, function () {
5731
+ var _a, _b, _c, _d;
5732
+ return __generator(this, function (_e) {
5733
+ switch (_e.label) {
5734
+ case 0:
5735
+ if (![
5736
+ schema.NodeType.Site,
5737
+ schema.NodeType.Organisation
5738
+ ].includes(node.type)) return [3 /*break*/, 1];
5739
+ _a = node;
5740
+ return [3 /*break*/, 7];
5741
+ case 1:
5742
+ if (!isSite(node)) return [3 /*break*/, 2];
5743
+ _b = this.loadSite(node);
5744
+ return [3 /*break*/, 6];
5745
+ case 2:
5746
+ if (!('site' in node && isSite(node.site))) return [3 /*break*/, 3];
5747
+ _c = this.loadSite(node.site);
5748
+ return [3 /*break*/, 5];
5749
+ case 3:
5750
+ _d = this.siteData;
5751
+ return [4 /*yield*/, this.loadSite(node)];
5752
+ case 4:
5753
+ _c = _d.apply(this, [_e.sent()]);
5754
+ _e.label = 5;
5755
+ case 5:
5756
+ _b = (_c);
5757
+ _e.label = 6;
5758
+ case 6:
5759
+ _a = (_b);
5760
+ _e.label = 7;
5761
+ case 7: return [2 /*return*/, _a];
5762
+ }
5763
+ });
5764
+ });
5765
+ };
5766
+ SitesMapsComponent.prototype.getSites = function () {
5767
+ var _this = this;
5768
+ var nodes = this.sites && this.sites.length ? this.sites : this.nodes;
5769
+ return Promise.all(nodes.map(function (node) { return _this.siteData(node); }));
5770
+ };
5771
+ SitesMapsComponent.prototype.termPolygons = function (id) {
5772
+ return __awaiter(this, void 0, void 0, function () {
5773
+ var data, polygons, _err_1;
5774
+ var _this = this;
5775
+ return __generator(this, function (_a) {
5776
+ switch (_a.label) {
5777
+ case 0:
5778
+ _a.trys.push([0, 2, , 3]);
5779
+ return [4 /*yield*/, this.nodeService.downloadRaw(baseUrl() + "/gadm/" + id + ".geojson")];
5780
+ case 1:
5781
+ data = _a.sent();
5782
+ polygons = polygonsFromFeature(data);
5783
+ polygons.map(function (polygon) { return polygon.setMap(_this.map.googleMap); });
5784
+ return [2 /*return*/, polygons];
5785
+ case 2:
5786
+ _err_1 = _a.sent();
5787
+ // ignore error if the file does not exist
5788
+ return [2 /*return*/, []];
5789
+ case 3: return [2 /*return*/];
5790
+ }
5791
+ });
5792
+ });
5793
+ };
5794
+ return SitesMapsComponent;
5795
+ }());
5796
+ SitesMapsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, deps: [{ token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5797
+ SitesMapsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMapsComponent, selector: "he-sites-maps", inputs: { loadPolygons: "loadPolygons", sites: "sites", nodes: "nodes", center: "center", zoom: "zoom", showNotice: "showNotice" }, viewQueries: [{ propertyName: "map", first: true, predicate: i1$2.GoogleMap, descendants: true }], ngImport: i0__namespace, template: "<google-map *ngIf=\"googleLoaded\"\n height=\"100%\"\n width=\"100%\"\n [zoom]=\"zoom\"\n [center]=\"center\"\n></google-map>\n\n<p *ngIf=\"showNotice\" class=\"mt-2 is-italic is-size-7\">The information provided might not be complete</p>\n\n<div class=\"no-location has-text-center has-text-light\" *ngIf=\"showNoLocation\">\n <span>No precise location data</span>\n</div>\n", styles: [":host{display:block;height:100%;position:relative;width:100%}.no-location{background-color:#0000004d;left:0;height:100%;position:absolute;top:0;width:100%;z-index:9}.no-location>span{display:inline-block;margin-top:12%}\n"], components: [{ type: i1__namespace$2.GoogleMap, selector: "google-map", inputs: ["height", "width", "center", "zoom", "options", "mapTypeId"], outputs: ["authFailure", "boundsChanged", "centerChanged", "mapClick", "mapDblclick", "mapDrag", "mapDragend", "mapDragstart", "headingChanged", "idle", "maptypeidChanged", "mapMousemove", "mapMouseout", "mapMouseover", "projectionChanged", "mapRightclick", "tilesloaded", "tiltChanged", "zoomChanged"], exportAs: ["googleMap"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5798
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMapsComponent, decorators: [{
5799
+ type: i0.Component,
5800
+ args: [{
5801
+ selector: 'he-sites-maps',
5802
+ templateUrl: './sites-maps.component.html',
5803
+ styleUrls: ['./sites-maps.component.scss']
5804
+ }]
5805
+ }], ctorParameters: function () { return [{ type: HeNodeService }]; }, propDecorators: { map: [{
5806
+ type: i0.ViewChild,
5807
+ args: [i1$2.GoogleMap]
5808
+ }], loadPolygons: [{
5809
+ type: i0.Input
5810
+ }], sites: [{
5811
+ type: i0.Input
5812
+ }], nodes: [{
5813
+ type: i0.Input
5814
+ }], center: [{
5815
+ type: i0.Input
5816
+ }], zoom: [{
5817
+ type: i0.Input
5818
+ }], showNotice: [{
5819
+ type: i0.Input
5820
+ }] } });
5821
+
5822
+ var maxAreaSize = 5000;
5823
+ var siteTooBig = function (_a) {
5824
+ var area = _a.area;
5825
+ return area && area / 100 > maxAreaSize;
5826
+ };
5827
+ var hasMultipleValues = function (values) { return (values || []).length > 1; };
5828
+ var weighedAverage = function (_a) {
5829
+ var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5830
+ return value.reduce(function (prev, curr, index) { return prev + (curr * (depthLower[index] - depthUpper[index])); }, 0) /
5831
+ value.reduce(function (prev, _curr, index) { return prev + (depthLower[index] - depthUpper[index]); }, 0);
5832
+ };
5833
+ var measurementValue = function (_a) {
5834
+ var value = _a.value, depthLower = _a.depthLower, depthUpper = _a.depthUpper;
5835
+ return hasMultipleValues(value) && hasMultipleValues(depthLower) && hasMultipleValues(depthUpper) ?
5836
+ weighedAverage({ value: value, depthLower: depthLower, depthUpper: depthUpper }) :
5837
+ propertyValue$1(value);
6053
5838
  };
6054
- var findProperty = function (properties, fullKey) {
6055
- var e_1, _d;
6056
- try {
6057
- for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
6058
- var p = properties_1_1.value;
6059
- if (p.fullKey === fullKey) {
6060
- return p;
6061
- }
6062
- var childP = findProperty(p.properties, fullKey);
6063
- if (childP) {
6064
- return childP;
6065
- }
6066
- }
5839
+
5840
+ var SitesMeasurementsLogsComponent = /** @class */ (function () {
5841
+ function SitesMeasurementsLogsComponent(searchService, nodeService) {
5842
+ this.searchService = searchService;
5843
+ this.nodeService = nodeService;
5844
+ this.originalValues = [];
5845
+ this.recalculatedValues = [];
5846
+ this.loading = true;
5847
+ this.NodeType = schema.NodeType;
5848
+ this.models = [];
5849
+ this.measurements = [];
6067
5850
  }
6068
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6069
- finally {
6070
- try {
6071
- if (properties_1_1 && !properties_1_1.done && (_d = properties_1.return)) _d.call(properties_1);
6072
- }
6073
- finally { if (e_1) throw e_1.error; }
5851
+ SitesMeasurementsLogsComponent.prototype.ngOnInit = function () {
5852
+ return __awaiter(this, void 0, void 0, function () {
5853
+ var _a, measurements;
5854
+ return __generator(this, function (_b) {
5855
+ switch (_b.label) {
5856
+ case 0:
5857
+ this.logsUrl = this.nodeService.nodeLogsUrl(this.node);
5858
+ _a = this;
5859
+ return [4 /*yield*/, this.nodeService.getModelsLog(this.node)];
5860
+ case 1:
5861
+ _a.logs = _b.sent();
5862
+ return [4 /*yield*/, this.searchService.search({
5863
+ fields: ['@type', '@id', 'name'],
5864
+ limit: 1000,
5865
+ query: {
5866
+ bool: {
5867
+ must: [
5868
+ matchType(schema.NodeType.Term),
5869
+ matchTermType(schema.TermTermType.measurement)
5870
+ ]
5871
+ }
5872
+ }
5873
+ })];
5874
+ case 2:
5875
+ measurements = (_b.sent()).results;
5876
+ this.measurements = measurements;
5877
+ this.loading = false;
5878
+ return [2 /*return*/];
5879
+ }
5880
+ });
5881
+ });
5882
+ };
5883
+ Object.defineProperty(SitesMeasurementsLogsComponent.prototype, "node", {
5884
+ get: function () {
5885
+ return Object.assign(Object.assign({}, this.site), { dataState: api.DataState.recalculated });
5886
+ },
5887
+ enumerable: false,
5888
+ configurable: true
5889
+ });
5890
+ return SitesMeasurementsLogsComponent;
5891
+ }());
5892
+ SitesMeasurementsLogsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, deps: [{ token: HeSearchService }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
5893
+ SitesMeasurementsLogsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: { site: "site", originalValues: "originalValues", recalculatedValues: "recalculatedValues" }, ngImport: i0__namespace, template: "<he-node-logs-models *ngIf=\"!loading; else loader\"\n [logsUrl]=\"logsUrl\"\n [nodeType]=\"NodeType.Site\"\n [originalValues]=\"originalValues\"\n [recalculatedValues]=\"recalculatedValues\"\n [terms]=\"measurements\"\n [logs]=\"logs\"\n filteredType=\"Measurement\"\n></he-node-logs-models>\n\n<ng-template #loader>\n <div class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n </div>\n</ng-template>\n", styles: [""], components: [{ type: NodeLogsModelsComponent, selector: "he-node-logs-models", inputs: ["nodeType", "nodeKey", "logsUrl", "originalValues", "recalculatedValues", "terms", "logs", "filteredType"] }, { type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
5894
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsLogsComponent, decorators: [{
5895
+ type: i0.Component,
5896
+ args: [{
5897
+ selector: 'he-sites-measurements-logs',
5898
+ templateUrl: './sites-measurements-logs.component.html',
5899
+ styleUrls: ['./sites-measurements-logs.component.scss']
5900
+ }]
5901
+ }], ctorParameters: function () { return [{ type: HeSearchService }, { type: HeNodeService }]; }, propDecorators: { site: [{
5902
+ type: i0.Input
5903
+ }], originalValues: [{
5904
+ type: i0.Input
5905
+ }], recalculatedValues: [{
5906
+ type: i0.Input
5907
+ }] } });
5908
+
5909
+ var orderBy$1 = require('lodash.orderby');
5910
+ var View$1;
5911
+ (function (View) {
5912
+ View["table"] = "table";
5913
+ View["logs"] = "logs";
5914
+ })(View$1 || (View$1 = {}));
5915
+ var SitesMeasurementsComponent = /** @class */ (function () {
5916
+ function SitesMeasurementsComponent() {
5917
+ this.originalValues = [];
5918
+ this.sites = [];
5919
+ this.showDownload = false;
5920
+ this.View = View$1;
5921
+ this.selectedView = View$1.table;
5922
+ this.maxAreaSize = maxAreaSize;
5923
+ this.siteTooBig = siteTooBig;
5924
+ this.defaultLabel = defaultLabel;
5925
+ this.measurementValue = measurementValue;
5926
+ this.measurements = [];
6074
5927
  }
6075
- return null;
6076
- };
6077
- var parentProperty = function (properties, property) {
6078
- var _c;
6079
- var allKeys = property.fullKey.split('.');
6080
- __spreadArray([], __read(new Array(((_c = property.suggestions) === null || _c === void 0 ? void 0 : _c.parentLevel) || 0))).map(function () { return allKeys.pop(); });
6081
- var parentKeys = fullKeyParts(allKeys.join('.'));
6082
- parentKeys.pop();
6083
- var parent = parentKeys.reduce(function (prev, curr, currIndex) {
6084
- var prop = prev.find(function (v) { return v.key === curr; });
6085
- return currIndex === parentKeys.length - 1 ? (prop || {}) : (prop.properties || []);
6086
- }, properties);
6087
- return Array.isArray(parent) ? property : parent;
6088
- };
6089
- var nestedProperty = function (_d, nestedKey) {
6090
- var properties = _d.properties;
6091
- return properties.find(function (_d) {
6092
- var key = _d.key;
6093
- return key === nestedKey;
5928
+ SitesMeasurementsComponent.prototype.ngOnChanges = function (changes) {
5929
+ if ('sites' in changes) {
5930
+ return this.update();
5931
+ }
5932
+ if ('dataState' in changes) {
5933
+ this.selectedView = View$1.table;
5934
+ }
5935
+ };
5936
+ SitesMeasurementsComponent.prototype.trackById = function (_index, item) {
5937
+ return item['@id'];
5938
+ };
5939
+ Object.defineProperty(SitesMeasurementsComponent.prototype, "isOriginal", {
5940
+ get: function () {
5941
+ return this.dataState === api.DataState.original;
5942
+ },
5943
+ enumerable: false,
5944
+ configurable: true
6094
5945
  });
6095
- };
6096
- var siblingProperty = function (properties, property, siblingKey) {
6097
- var parent = parentProperty(properties, property);
6098
- var parentProperties = parent === property ? properties : parent.properties;
6099
- return parentProperties.find(function (prop) { return prop.key === siblingKey; });
6100
- };
6101
- var groupChanged = function (properties, key, value) {
6102
- try {
6103
- var parentKeys_1 = fullKeyParts(key);
6104
- parentKeys_1.reduce(function (prev, curr, currIndex) {
6105
- if (currIndex === parentKeys_1.length - 1 && value === null) {
6106
- return prev.splice(prev.findIndex(function (v) { return v.key === curr; }), 1);
6107
- }
6108
- else {
6109
- var prop = prev.find(function (v) { return v.key === curr; });
6110
- prop.changed = true;
6111
- return prop.properties;
6112
- }
6113
- }, properties);
5946
+ SitesMeasurementsComponent.prototype.update = function () {
5947
+ var measurementsPerSite = groupNodesByTerm(this.sites, 'measurements', this.originalValues);
5948
+ this.measurements = orderBy$1(grouppedKeys(measurementsPerSite), ['key'], ['asc']);
5949
+ };
5950
+ SitesMeasurementsComponent.prototype.togglePopover = function (popover, context) {
5951
+ return popover.isOpen() ? popover.close() : popover.open(context);
5952
+ };
5953
+ Object.defineProperty(SitesMeasurementsComponent.prototype, "showAreaTooBig", {
5954
+ get: function () {
5955
+ return this.dataState === api.DataState.recalculated && (this.sites || []).some(siteTooBig);
5956
+ },
5957
+ enumerable: false,
5958
+ configurable: true
5959
+ });
5960
+ return SitesMeasurementsComponent;
5961
+ }());
5962
+ SitesMeasurementsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
5963
+ SitesMeasurementsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SitesMeasurementsComponent, selector: "he-sites-measurements", inputs: { originalValues: "originalValues", sites: "sites", dataState: "dataState" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-container *ngIf=\"measurements.length; else emptyTable\">\n <div class=\"columns is-variable is-2 m-0\">\n <div class=\"column is-hidden-mobile\"></div>\n <div class=\"column is-narrow\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.table\" (click)=\"selectedView = View.table\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"list\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Table view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"!isOriginal && sites.length === 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.logs\" (click)=\"selectedView = View.logs\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"calculator\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Recalculations logs</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"px-3 pb-3\" [class.is-hidden]=\"selectedView !== View.table\">\n <div class=\"has-text-right mb-2\">\n <button class=\"button is-dark is-outlined is-small\" (click)=\"showDownload = true\">\n <fa-icon icon=\"download\"></fa-icon>\n <span class=\"pl-2\">Download (CSV)</span>\n </button>\n </div>\n\n <div class=\"table-container data-table-container mb-1\">\n <table class=\"table is-narrow data-table has-children-{{measurements.length}}\">\n <thead>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.name\"\n >\n <he-node-link [node]=\"measurement.value.term\">\n <span>{{measurement.value.term.name | ellipsis:30}}</span>\n </he-node-link>\n </th>\n </tr>\n <tr>\n <th class=\"width-auto\"></th>\n <th *ngFor=\"let measurement of measurements\"\n [attr.title]=\"measurement.value.term.units\"\n >{{measurement.value.term.units}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let site of sites; trackBy: trackById; let i = index\">\n <td class=\"width-auto\" [attr.title]=\"defaultLabel(site)\">\n <he-node-link [node]=\"site\">\n <span class=\"is-nowrap has-text-ellipsis\">{{i + 1}}. {{defaultLabel(site)}}</span>\n </he-node-link>\n </td>\n <td class=\"is-nowrap\" *ngFor=\"let measurement of measurements\">\n <span *ngIf=\"measurement.value.values[site['@id']]\"\n class=\"trigger-popover\"\n [ngbPopover]=\"details\" [autoClose]=\"'outside'\"\n triggers=\"manual\" #p=\"ngbPopover\" placement=\"left\" container=\"body\"\n (click)=\"togglePopover(p, { data: measurement.value.values[site['@id']], site: site, key: 'measurements' })\"\n >\n <span pointer>{{measurementValue(measurement.value.values[site['@id']]) | precision:3 | default:'-'}}</span>\n <he-blank-node-state class=\"ml-1\"\n [node]=\"measurement.value.values[site['@id']].nodes[0]\"\n key=\"value\"\n ></he-blank-node-state>\n </span>\n <span *ngIf=\"!measurement.value.values[site['@id']]\">\n <span>-</span>\n <sup class=\"pl-1\" *ngIf=\"siteTooBig(site)\">(1)</sup>\n </span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n <he-blank-node-state-notice [dataState]=\"dataState\"></he-blank-node-state-notice>\n\n <p class=\"is-size-7 is-italic\" *ngIf=\"showAreaTooBig\">\n (1) This region is >{{maxAreaSize}}km2 and is too large to reliably gap fill Measurements.\n </p>\n </div>\n\n <he-sites-measurements-logs *ngIf=\"selectedView === View.logs && !isOriginal\"\n [site]=\"sites[0]\"\n [originalValues]=\"originalValues[0].measurements\"\n [recalculatedValues]=\"sites[0].measurements\"\n ></he-sites-measurements-logs>\n</ng-container>\n\n<he-node-csv-export-confirm *ngIf=\"showDownload\"\n [nodes]=\"sites\" filename=\"site-measurements.csv\" [isUpload]=\"false\"\n [headerKeys]=\"['site.id', 'site.@id', 'site.measurements.']\"\n (closed)=\"showDownload = false\"\n></he-node-csv-export-confirm>\n\n<ng-template #emptyTable>\n <div class=\"panel-block\">\n <span>No data</span>\n </div>\n</ng-template>\n\n<ng-template #emptyValue>\n <span>-</span>\n</ng-template>\n\n<ng-template #details let-node=\"site\" let-data=\"data\" let-key=\"key\">\n <p><b>{{node.name}}</b></p>\n <he-node-value-details\n [data]=\"data\" [nodeType]=\"node['@type']\" [dataKey]=\"key\"\n ></he-node-value-details>\n</ng-template>\n", styles: ["fa-icon{display:inline-block;width:10px}\n"], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }, { type: NodeLinkComponent, selector: "he-node-link", inputs: ["node", "showExternalLink"] }, { type: BlankNodeStateComponent, selector: "he-blank-node-state", inputs: ["nodeType", "dataKey", "key", "node", "state"] }, { type: BlankNodeStateNoticeComponent, selector: "he-blank-node-state-notice", inputs: ["dataState", "showDeleted"] }, { type: SitesMeasurementsLogsComponent, selector: "he-sites-measurements-logs", inputs: ["site", "originalValues", "recalculatedValues"] }, { type: NodeCsvExportConfirmComponent, selector: "he-node-csv-export-confirm", inputs: ["nodes", "filename", "headerKeys", "extension", "isUpload"], outputs: ["closed"] }, { type: NodeValueDetailsComponent, selector: "he-node-value-details", inputs: ["data", "nodeType", "dataKey"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgbPopover, selector: "[ngbPopover]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disablePopover", "popoverClass", "openDelay", "closeDelay", "ngbPopover", "popoverTitle"], outputs: ["shown", "hidden"], exportAs: ["ngbPopover"] }], pipes: { "ellipsis": EllipsisPipe, "default": DefaultPipe, "precision": PrecisionPipe } });
5964
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SitesMeasurementsComponent, decorators: [{
5965
+ type: i0.Component,
5966
+ args: [{
5967
+ selector: 'he-sites-measurements',
5968
+ templateUrl: './sites-measurements.component.html',
5969
+ styleUrls: ['./sites-measurements.component.scss']
5970
+ }]
5971
+ }], propDecorators: { originalValues: [{
5972
+ type: i0.Input
5973
+ }], sites: [{
5974
+ type: i0.Input
5975
+ }], dataState: [{
5976
+ type: i0.Input
5977
+ }] } });
5978
+
5979
+ var components$2 = [
5980
+ SitesMapsComponent,
5981
+ SitesMeasurementsComponent,
5982
+ SitesMeasurementsLogsComponent
5983
+ ];
5984
+ var HeSitesModule = /** @class */ (function () {
5985
+ function HeSitesModule() {
6114
5986
  }
6115
- catch (_err) { }
6116
- };
6117
- var refreshPropertyKeys = function (property) { return property.properties.map(function (prop, i) {
6118
- prop.fullKey = "" + property.fullKey + (property.isArray ? "[" + i + "]" : "." + prop.key);
6119
- prop.key = property.isArray ? "" + i : prop.key;
6120
- return refreshPropertyKeys(prop);
6121
- }); };
6122
- var calculateCycleDurationEnabled = function (properties, property) {
6123
- var startDate = siblingProperty(properties, property, 'startDate');
6124
- var endDate = siblingProperty(properties, property, 'endDate');
6125
- return !!(startDate === null || startDate === void 0 ? void 0 : startDate.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
6126
- };
6127
- var calculateCycleDuration = function (properties, property) {
6128
- var startDate = siblingProperty(properties, property, 'startDate');
6129
- var endDate = siblingProperty(properties, property, 'endDate');
6130
- return utils.diffInDays(startDate.value, endDate.value);
6131
- };
6132
- var calculateCycleStartDateEnabled = function (properties, property) {
6133
- var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
6134
- var endDate = siblingProperty(properties, property, 'endDate');
6135
- return !!(cycleDuration === null || cycleDuration === void 0 ? void 0 : cycleDuration.value) && !!(endDate === null || endDate === void 0 ? void 0 : endDate.value);
6136
- };
6137
- var calculateCycleStartDate = function (properties, property) {
6138
- var cycleDuration = siblingProperty(properties, property, 'cycleDuration');
6139
- var endDate = siblingProperty(properties, property, 'endDate');
6140
- return moment__namespace(endDate.value).locale('en-gb').subtract(cycleDuration.value, 'days').format('YYYY-MM-DD');
6141
- };
5987
+ return HeSitesModule;
5988
+ }());
5989
+ HeSitesModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
5990
+ HeSitesModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, declarations: [SitesMapsComponent,
5991
+ SitesMeasurementsComponent,
5992
+ SitesMeasurementsLogsComponent], imports: [i3.CommonModule, i1$4.ReactiveFormsModule,
5993
+ HeCommonModule,
5994
+ HeNodeModule], exports: [SitesMapsComponent,
5995
+ SitesMeasurementsComponent,
5996
+ SitesMeasurementsLogsComponent] });
5997
+ HeSitesModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, imports: [[
5998
+ i3.CommonModule, i1$4.ReactiveFormsModule,
5999
+ HeCommonModule,
6000
+ HeNodeModule
6001
+ ]] });
6002
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: HeSitesModule, decorators: [{
6003
+ type: i0.NgModule,
6004
+ args: [{
6005
+ declarations: components$2,
6006
+ exports: components$2,
6007
+ imports: [
6008
+ i3.CommonModule, i1$4.ReactiveFormsModule,
6009
+ HeCommonModule,
6010
+ HeNodeModule
6011
+ ]
6012
+ }]
6013
+ }] });
6142
6014
 
6143
6015
  var user = {};
6144
6016
  var HeUsersService = /** @class */ (function () {
@@ -7327,7 +7199,7 @@
7327
7199
  };
7328
7200
  return ImpactAssessmentsProductsComponent;
7329
7201
  }());
7330
- ImpactAssessmentsProductsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsComponent, deps: [{ token: i1__namespace$4.FormBuilder }, { token: HeNodeService }, { token: HeSearchService }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
7202
+ ImpactAssessmentsProductsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsComponent, deps: [{ token: i1__namespace$4.FormBuilder }, { token: HeNodeService }, { token: HeSearchService }, { token: HeToastService }], target: i0__namespace.ɵɵFactoryTarget.Component });
7331
7203
  ImpactAssessmentsProductsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ImpactAssessmentsProductsComponent, selector: "he-impact-assessments-products", inputs: { cycles: "cycles", impactAssessments: "impactAssessments", key: "key", dataState: "dataState", enableCompare: "enableCompare", filterTermTypes: "filterTermTypes", enableFilterMethodModel: "enableFilterMethodModel" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-container *ngIf=\"indicators.length; else emptyTable\">\n <div class=\"columns is-variable is-2 m-0\">\n <div class=\"column is-hidden-mobile\"></div>\n <div class=\"column is-narrow\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.table\" (click)=\"selectedView = View.table\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"list\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Table view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"impactAssessments.length > 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.chart\" (click)=\"selectedView = View.chart\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"chart-bar\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Chart view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"enableBreakdown\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.breakdown\" (click)=\"selectedView = View.breakdown\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"chart-bar\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Breakdown view</span>\n </button>\n </div>\n <div class=\"control\" *ngIf=\"!isOriginal && impactAssessments.length === 1\">\n <button class=\"button is-small\" [class.is-active]=\"selectedView === View.logs\" (click)=\"showRecalculationLogs()\">\n <span class=\"icon is-small\">\n <fa-icon icon=\"calculator\" aria-hidden=\"true\"></fa-icon>\n </span>\n <span>Recalculations logs</span>\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"px-3 pb-3\" [class.is-hidden]=\"selectedView !== View.table\">\n <div class=\"has-text-right mb-2\">\n <button class=\"button is-dark is-outlined is-small\" (click)=\"showDownload = true\">\n <fa-icon icon=\"download\"></fa-icon>\n <span class=\"pl-2\">Download (CSV)</span>\n </button>\n </div>\n\n <div class=\"table-container data-table-container mb-1\" *bindOnce=\"indicators\">\n <table class=\"table is-narrow data-table has-children-{{indicators.length + 1}}\">\n <thead>\n <tr>\n <th class=\"width-auto\">\n <div class=\"select is-small\" *ngIf=\"enableFilterMethodModel\">\n <select name=\"selectedMethodModel\"\n (change)=\"updateImpacts()\" [(ngModel)]=\"selectedMethodModel\"\n >\n <option [ngValue]=\"undefined\">Filter Model</option>\n <option *ngFor=\"let term of methodModels\" [ngValue]=\"term\">{{term.name}}</option>\n </select>\n </div>\n </th>\n <th></th>\n <th *ngFor=\"let indicator of indicators\"\n [attr.title]=\"indicator.value.term.name\"\n >\n <he-node-link [node]=\"indicator.value.term\">\n <span>{{indicator.value.term.name | ellipsis:30}}</span>\n </he-node-link>\n </th>\n </tr>\n <tr>\n <th class=\"width-auto\">\n <a [href]=\"baseUrl + '/schema/ImpactAssessment#functionalUnit'\" target=\"_blank\">Functional unit:</a>\n <span class=\"pl-1\">1 kg</span>\n </th>\n <th>Product</th>\n <th *ngFor=\"let indicator of indicators\"\n [attr.title]=\"indicator.value.term.units\"\n >{{indicator.value.term.units}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let impactAssessment of impactAssessments; trackBy: trackById; let i = index\">\n <td class=\"width-auto\" [attr.title]=\"impactName(impactAssessment)\" [style.border-left-color]=\"itemColor(i)\">\n <label *ngIf=\"enableCompare\" class=\"is-inline-block checkbox\">\n <input type=\"checkbox\" class=\"selector\"\n (change)=\"toggleImpact(impactAssessment)\"\n [checked]=\"isSelected(impactAssessment)\"\n >\n </label>\n <he-node-link class=\"is-inline-block\" [node]=\"impactAssessment\">\n <span class=\"is-nowrap has-text-ellipsis\">{{i + 1}}. {{impactName(impactAssessment)}}</span>\n </he-node-link>\n </td>\n <td [attr.title]=\"impactAssessment.product?.name\">\n <he-node-link *ngIf=\"impactAssessment.product\" [node]=\"impactAssessment.product\">\n <span>{{impactAssessment.product.name | ellipsis:30}}</span>\n </he-node-link>\n </td>\n <td class=\"is-nowrap\" *ngFor=\"let indicator of indicators\">\n <span *ngIf=\"indicator.value.values[impactAssessment['@id']]; else emptyValue\"\n class=\"trigger-popover\"\n [ngbPopover]=\"details\" [autoClose]=\"'outside'\"\n triggers=\"manual\" #p=\"ngbPopover\" placement=\"left\" container=\"body\"\n (click)=\"togglePopover(p, { data: indicator.value.values[impactAssessment['@id']], impactAssessment: impactAssessment, key: key })\"\n >\n <span pointer>{{propertyValue(indicator.value.values[impactAssessment['@id']].value, key === 'impacts') | precision:3 | default:'-'}}</span>\n <he-blank-node-state class=\"ml-1\"\n [node]=\"indicator.value.values[impactAssessment['@id']].nodes[0]\"\n key=\"value\"\n [state]=\"impactAssessment.aggregated ? 'aggregated' : null\"\n ></he-blank-node-state>\n </span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n <he-blank-node-state-notice [dataState]=\"dataState\"></he-blank-node-state-notice>\n\n <form *ngIf=\"enableCompare\" class=\"mt-2\" [formGroup]=\"form\" (submit)=\"form.valid && addImpact()\">\n <div class=\"field has-addons\">\n <div class=\"control\">\n <span class=\"button is-small is-static\">Compare with Aggregated Impact Assessment</span>\n </div>\n <div class=\"control is-expanded\" [class.has-icons-right]=\"suggesting || loading\">\n <input class=\"input is-small\"\n placeholder=\"Search by name or id\"\n formControlName=\"search\" name=\"search\"\n\n [ngbTypeahead]=\"suggestImpactAssessment\"\n [inputFormatter]=\"formatter\"\n [resultTemplate]=\"suggestion\"\n [focusFirst]=\"true\"\n >\n <span class=\"icon is-small is-right has-text-grey-dark\" [class.is-hidden]=\"!(suggesting || loading)\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"sm\"></fa-icon>\n </span>\n </div>\n <div class=\"control\">\n <button class=\"button is-small\" type=\"submit\" [disabled]=\"suggesting || loading\">\n <fa-icon icon=\"plus\"></fa-icon>\n </button>\n </div>\n </div>\n </form>\n </div>\n\n <he-impact-assessments-indicator-breakdown-chart *ngIf=\"selectedView === View.breakdown\"\n [impactAssessment]=\"impactAssessments[0]\"\n [indicators]=\"impactAssessments[0][key]\"\n ></he-impact-assessments-indicator-breakdown-chart>\n\n <he-impact-assessments-indicators-chart *ngIf=\"impactAssessments.length > 1\" [class.is-hidden]=\"selectedView !== View.chart\"\n [key]=\"key\"\n [impactAssessments]=\"selectedImpactAssessments\"\n [filterTermTypes]=\"filterTermTypes\"\n ></he-impact-assessments-indicators-chart>\n\n <he-impact-assessments-products-logs *ngIf=\"selectedView === View.logs && !isOriginal\"\n [key]=\"key\"\n [impactAssessment]=\"impactAssessments[0]\"\n [filterTermTypes]=\"filterTermTypes\"\n [originalValues]=\"originalValues[0][key]\"\n [recalculatedValues]=\"impactAssessments[0][key]\"\n ></he-impact-assessments-products-logs>\n</ng-container>\n\n<he-node-csv-export-confirm *ngIf=\"showDownload\"\n [nodes]=\"impactAssessments\" [filename]=\"'impact-' + key + '.csv'\" [isUpload]=\"false\"\n [headerKeys]=\"['impactAssessment.id', 'impactAssessment.@id', 'impactAssessment.' + key + '.']\"\n (closed)=\"showDownload = false\"\n></he-node-csv-export-confirm>\n\n<ng-template #emptyTable>\n <div class=\"panel-block\">\n <span>No data</span>\n </div>\n</ng-template>\n\n<ng-template #emptyValue>\n <span>-</span>\n</ng-template>\n\n<ng-template #details let-node=\"impactAssessment\" let-data=\"data\" let-key=\"key\">\n <p *bindOnce=\"node\">\n <b>\n <span *ngIf=\"data.cycle\">{{cycleLabel(node.cycle)}}</span>\n <span *ngIf=\"!data.cycle\">{{data.name}}</span>\n </b>\n </p>\n <he-node-value-details\n [data]=\"data\" [nodeType]=\"node['@type']\" [dataKey]=\"key\"\n ></he-node-value-details>\n</ng-template>\n\n<ng-template #suggestion let-impact=\"result\" let-t=\"term\">\n <div class=\"is-block\">\n <ngb-highlight [result]=\"impact.name || impact.cycle.name\" [term]=\"t\"></ngb-highlight>\n </div>\n <div class=\"columns is-flex\">\n <div class=\"column\" *ngIf=\"impact.country\">\n <span class=\"pr-1 has-text-underline\">Country:</span>\n <span class=\"is-inline-flex\"><ngb-highlight [result]=\"impact.country.name\" [term]=\"t\"></ngb-highlight></span>\n </div>\n <div class=\"column\" *ngIf=\"impact.product\">\n <span class=\"pr-1 has-text-underline\">Product:</span>\n <span class=\"is-inline-flex\"><ngb-highlight [result]=\"impact.product.name\" [term]=\"t\"></ngb-highlight></span>\n </div>\n <div class=\"column\" *ngIf=\"impact.endDate\">\n <span class=\"pr-1 has-text-underline\">Date:</span>\n <span class=\"is-inline-flex\"><ngb-highlight [result]=\"impact.endDate\" [term]=\"t\"></ngb-highlight></span>\n </div>\n </div>\n</ng-template>\n", styles: ["label.checkbox{width:20px}td he-node-link{width:160px}table.data-table td:first-child{border-left-width:8px}\n"], components: [{ type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }, { type: NodeLinkComponent, selector: "he-node-link", inputs: ["node", "showExternalLink"] }, { type: BlankNodeStateComponent, selector: "he-blank-node-state", inputs: ["nodeType", "dataKey", "key", "node", "state"] }, { type: BlankNodeStateNoticeComponent, selector: "he-blank-node-state-notice", inputs: ["dataState", "showDeleted"] }, { type: ImpactAssessmentsIndicatorBreakdownChartComponent, selector: "he-impact-assessments-indicator-breakdown-chart", inputs: ["impactAssessment", "indicators"] }, { type: ImpactAssessmentsIndicatorsChartComponent, selector: "he-impact-assessments-indicators-chart", inputs: ["impactAssessments", "key", "filterTermTypes"] }, { type: ImpactAssessmentsProductsLogsComponent, selector: "he-impact-assessments-products-logs", inputs: ["impactAssessment", "key", "filterTermTypes", "originalValues", "recalculatedValues"] }, { type: NodeCsvExportConfirmComponent, selector: "he-node-csv-export-confirm", inputs: ["nodes", "filename", "headerKeys", "extension", "isUpload"], outputs: ["closed"] }, { type: NodeValueDetailsComponent, selector: "he-node-value-details", inputs: ["data", "nodeType", "dataKey"] }, { type: i10__namespace.NgbHighlight, selector: "ngb-highlight", inputs: ["highlightClass", "result", "term"] }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: BindOnceDirective, selector: "[bindOnce]", inputs: ["bindOnce"] }, { type: i1__namespace$4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i1__namespace$4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1__namespace$4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1__namespace$4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1__namespace$4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgbPopover, selector: "[ngbPopover]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disablePopover", "popoverClass", "openDelay", "closeDelay", "ngbPopover", "popoverTitle"], outputs: ["shown", "hidden"], exportAs: ["ngbPopover"] }, { type: i1__namespace$4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1__namespace$4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1__namespace$4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1__namespace$4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i10__namespace.NgbTypeahead, selector: "input[ngbTypeahead]", inputs: ["autocomplete", "placement", "container", "editable", "focusFirst", "showHint", "inputFormatter", "ngbTypeahead", "resultFormatter", "resultTemplate"], outputs: ["selectItem"], exportAs: ["ngbTypeahead"] }, { type: i1__namespace$4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }], pipes: { "ellipsis": EllipsisPipe, "default": DefaultPipe, "precision": PrecisionPipe } });
7332
7204
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsComponent, decorators: [{
7333
7205
  type: i0.Component,
@@ -7336,7 +7208,7 @@
7336
7208
  templateUrl: './impact-assessments-products.component.html',
7337
7209
  styleUrls: ['./impact-assessments-products.component.scss']
7338
7210
  }]
7339
- }], ctorParameters: function () { return [{ type: i1__namespace$4.FormBuilder }, { type: HeNodeService }, { type: HeSearchService }, { type: ToastService }]; }, propDecorators: { cycles: [{
7211
+ }], ctorParameters: function () { return [{ type: i1__namespace$4.FormBuilder }, { type: HeNodeService }, { type: HeSearchService }, { type: HeToastService }]; }, propDecorators: { cycles: [{
7340
7212
  type: i0.Input
7341
7213
  }], impactAssessments: [{
7342
7214
  type: i0.Input
@@ -7436,6 +7308,7 @@
7436
7308
  * Generated bundle index. Do not edit.
7437
7309
  */
7438
7310
 
7311
+ exports.ARRAY_DELIMITER = ARRAY_DELIMITER;
7439
7312
  exports.BibliographiesSearchConfirmComponent = BibliographiesSearchConfirmComponent;
7440
7313
  exports.BindOnceDirective = BindOnceDirective;
7441
7314
  exports.BlankNodeDiffsComponent = BlankNodeDiffsComponent;
@@ -7477,6 +7350,7 @@
7477
7350
  exports.HeSearchModule = HeSearchModule;
7478
7351
  exports.HeSearchService = HeSearchService;
7479
7352
  exports.HeSitesModule = HeSitesModule;
7353
+ exports.HeToastService = HeToastService;
7480
7354
  exports.HeUsersService = HeUsersService;
7481
7355
  exports.ImpactAssessmentsIndicatorBreakdownChartComponent = ImpactAssessmentsIndicatorBreakdownChartComponent;
7482
7356
  exports.ImpactAssessmentsIndicatorsChartComponent = ImpactAssessmentsIndicatorsChartComponent;
@@ -7510,45 +7384,82 @@
7510
7384
  exports.TagsInputDirective = TagsInputDirective;
7511
7385
  exports.TimesPipe = TimesPipe;
7512
7386
  exports.ToastComponent = ToastComponent;
7513
- exports.ToastService = ToastService;
7514
7387
  exports.UnitConverterComponent = UnitConverterComponent;
7388
+ exports.addPolygonToFeature = addPolygonToFeature;
7515
7389
  exports.allCountriesQuery = allCountriesQuery;
7516
- exports.animateCounter = animateCounter;
7517
7390
  exports.arrayValue = arrayValue;
7518
7391
  exports.availableProperties = availableProperties;
7519
7392
  exports.baseUrl = baseUrl;
7520
7393
  exports.bottom = bottom;
7394
+ exports.calculateCycleDuration = calculateCycleDuration;
7395
+ exports.calculateCycleDurationEnabled = calculateCycleDurationEnabled;
7396
+ exports.calculateCycleStartDate = calculateCycleStartDate;
7397
+ exports.calculateCycleStartDateEnabled = calculateCycleStartDateEnabled;
7398
+ exports.calculatePercentDelta = calculatePercentDelta;
7399
+ exports.clustererImage = clustererImage;
7400
+ exports.code = code;
7401
+ exports.coordinatesToPoint = coordinatesToPoint;
7521
7402
  exports.countriesQuery = countriesQuery;
7403
+ exports.createMarker = createMarker;
7522
7404
  exports.cropsQuery = cropsQuery;
7405
+ exports.customDeltaFuncs = customDeltaFuncs;
7406
+ exports.dataPathToKey = dataPathToKey;
7523
7407
  exports.dataValue = dataValue;
7408
+ exports.defaultFeature = defaultFeature;
7524
7409
  exports.defaultLabel = defaultLabel;
7410
+ exports.defaultSuggestionType = defaultSuggestionType;
7525
7411
  exports.definitionToSchemaType = definitionToSchemaType;
7526
7412
  exports.delta = delta;
7527
7413
  exports.deserializeSearchFilters = deserializeSearchFilters;
7528
7414
  exports.ellipsis = ellipsis;
7529
7415
  exports.emptyValue = emptyValue;
7416
+ exports.errorHasError = errorHasError;
7417
+ exports.errorHasWarning = errorHasWarning;
7530
7418
  exports.errorText = errorText;
7419
+ exports.evaluateSuccess = evaluateSuccess;
7531
7420
  exports.filenameWithoutExt = filenameWithoutExt;
7421
+ exports.fillColor = fillColor;
7422
+ exports.fillStyle = fillStyle;
7423
+ exports.filterError = filterError;
7532
7424
  exports.filterParams = filterParams;
7425
+ exports.findConfigModels = findConfigModels;
7426
+ exports.findProperty = findProperty;
7533
7427
  exports.findPropertyById = findPropertyById;
7428
+ exports.formatCustomErrorMessage = formatCustomErrorMessage;
7429
+ exports.formatDiffValues = formatDiffValues;
7430
+ exports.formatError = formatError;
7431
+ exports.formatLinkNodesSuggestions = formatLinkNodesSuggestions;
7432
+ exports.formatPropertyError = formatPropertyError;
7433
+ exports.formatSuggestion = formatSuggestion;
7434
+ exports.gitBranch = gitBranch;
7534
7435
  exports.gitHome = gitHome;
7535
7436
  exports.gitRawBaseUrl = gitRawBaseUrl;
7437
+ exports.groupChanged = groupChanged;
7536
7438
  exports.groupNodesByTerm = groupNodesByTerm;
7537
7439
  exports.grouppedKeys = grouppedKeys;
7538
7440
  exports.grouppedValueKeys = grouppedValueKeys;
7539
7441
  exports.handleAPIError = handleAPIError;
7540
- exports.hoursBefore = hoursBefore;
7442
+ exports.hasError = hasError;
7443
+ exports.hasWarning = hasWarning;
7444
+ exports.isAddPropertyEnabled = isAddPropertyEnabled;
7541
7445
  exports.isChrome = isChrome;
7542
7446
  exports.isExternal = isExternal;
7447
+ exports.isMissingOneOfError = isMissingOneOfError;
7448
+ exports.isMissingPropertyError = isMissingPropertyError;
7543
7449
  exports.isSchemaIri = isSchemaIri;
7544
7450
  exports.isScrolledBelow = isScrolledBelow;
7545
7451
  exports.itemColor = itemColor;
7452
+ exports.keyToDataPath = keyToDataPath;
7546
7453
  exports.keyToLabel = keyToLabel;
7547
7454
  exports.levels = levels;
7548
7455
  exports.linkTypeEnabled = linkTypeEnabled;
7549
7456
  exports.listColor = listColor;
7550
- exports.loadScript = loadScript;
7457
+ exports.locationQuery = locationQuery;
7458
+ exports.lookupUrl = lookupUrl;
7459
+ exports.lookups = lookups;
7551
7460
  exports.mapsUrl = mapsUrl;
7461
+ exports.markerIcon = markerIcon;
7462
+ exports.markerPie = markerPie;
7552
7463
  exports.matchAggregatedQuery = matchAggregatedQuery;
7553
7464
  exports.matchBoolPrefixQuery = matchBoolPrefixQuery;
7554
7465
  exports.matchCountry = matchCountry;
@@ -7565,18 +7476,36 @@
7565
7476
  exports.matchType = matchType;
7566
7477
  exports.maxAreaSize = maxAreaSize;
7567
7478
  exports.measurementValue = measurementValue;
7568
- exports.minutesBefore = minutesBefore;
7479
+ exports.missingNodeErrorMessage = missingNodeErrorMessage;
7480
+ exports.missingNodeErrors = missingNodeErrors;
7569
7481
  exports.multiMatchQuery = multiMatchQuery;
7482
+ exports.nestedProperty = nestedProperty;
7570
7483
  exports.nestingEnabled = nestingEnabled;
7571
7484
  exports.nestingTypeEnabled = nestingTypeEnabled;
7572
- exports.nodeTypeToString = nodeTypeToString;
7485
+ exports.nodeAvailableProperties = nodeAvailableProperties;
7486
+ exports.nodeLink = nodeLink;
7487
+ exports.nodeLogsUrl = nodeLogsUrl;
7488
+ exports.nodeUrl = nodeUrl;
7573
7489
  exports.numberGte = numberGte;
7490
+ exports.parentKey = parentKey;
7491
+ exports.parentProperty = parentProperty;
7574
7492
  exports.parseData = parseData;
7493
+ exports.parseDataPath = parseDataPath;
7575
7494
  exports.parseLines = parseLines;
7576
7495
  exports.parseMessage = parseMessage;
7577
- exports.parseNodeType = parseNodeType;
7496
+ exports.parseNewValue = parseNewValue;
7497
+ exports.pathToApiDocsPath = pathToApiDocsPath;
7498
+ exports.pointToCoordinates = pointToCoordinates;
7499
+ exports.polygonBounds = polygonBounds;
7500
+ exports.polygonToCoordinates = polygonToCoordinates;
7501
+ exports.polygonsFromFeature = polygonsFromFeature;
7502
+ exports.primaryProduct = primaryProduct;
7503
+ exports.propertyError = propertyError;
7504
+ exports.propertyId = propertyId;
7578
7505
  exports.propertyValue = propertyValue$1;
7506
+ exports.recursiveProperties = recursiveProperties;
7579
7507
  exports.refToSchemaType = refToSchemaType;
7508
+ exports.refreshPropertyKeys = refreshPropertyKeys;
7580
7509
  exports.regionsQuery = regionsQuery;
7581
7510
  exports.repeat = repeat;
7582
7511
  exports.roundValue = roundValue;
@@ -7590,9 +7519,13 @@
7590
7519
  exports.searchResultsFields = searchResultsFields;
7591
7520
  exports.searchableTypes = searchableTypes;
7592
7521
  exports.serializeSearchFilters = serializeSearchFilters;
7522
+ exports.siblingProperty = siblingProperty;
7523
+ exports.singleProperty = singleProperty;
7593
7524
  exports.siteTooBig = siteTooBig;
7594
- exports.sortByFn = sortByFn;
7595
7525
  exports.sortOrder = sortOrder;
7526
+ exports.sortProperties = sortProperties;
7527
+ exports.strokeColor = strokeColor;
7528
+ exports.strokeStyle = strokeStyle;
7596
7529
  exports.suggestMatchQuery = suggestMatchQuery;
7597
7530
  exports.suggestQuery = suggestQuery;
7598
7531
  exports.termChildToParent = termChildToParent;
@@ -7601,10 +7534,11 @@
7601
7534
  exports.termProperties = termProperties;
7602
7535
  exports.termTypeGroups = termTypeGroups;
7603
7536
  exports.termTypeLabel = termTypeLabel;
7537
+ exports.termTypeLookupUrl = termTypeLookupUrl;
7604
7538
  exports.toCsv = toCsv$1;
7605
7539
  exports.toDashCase = toDashCase;
7606
- exports.toFormData = toFormData;
7607
- exports.toSearchParams = toSearchParams;
7540
+ exports.typeToNewProperty = typeToNewProperty;
7541
+ exports.updateProperties = updateProperties;
7608
7542
  exports.valueTypeToDefault = valueTypeToDefault;
7609
7543
  exports.waitFor = waitFor;
7610
7544
  exports.wildcardQuery = wildcardQuery;