@limetech/lime-crm-building-blocks 1.120.0 → 1.121.0

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 (99) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/{_MapCache-De1Fwe0H.js → _MapCache-DHOVMBKi.js} +341 -3
  3. package/dist/cjs/{_getTag-CdUodI28.js → _Uint8Array-CXHKqIsu.js} +375 -30
  4. package/dist/cjs/{_baseIsEqual-BtwicGmu.js → _baseIsEqual-Ba8g_ag_.js} +11 -13
  5. package/dist/cjs/{_defineProperty-eImBwVFM.js → _defineProperty-Bl_qu8Vn.js} +2 -2
  6. package/dist/cjs/{get-BRGtX379.js → get-D1lIKhWp.js} +6 -7
  7. package/dist/cjs/{isSymbol-D8S28StA.js → isSymbol-BJj6FNl6.js} +2 -2
  8. package/dist/cjs/limebb-component-config.cjs.entry.js +3 -4
  9. package/dist/cjs/limebb-info-tile.cjs.entry.js +134 -135
  10. package/dist/cjs/limebb-lime-query-filter-builder_3.cjs.entry.js +5 -7
  11. package/dist/cjs/limebb-locale-picker.cjs.entry.js +18 -20
  12. package/dist/cjs/limebb-object-chip.cjs.entry.js +1 -1
  13. package/dist/cjs/limebb-percentage-visualizer.cjs.entry.js +3 -3
  14. package/dist/cjs/limebb-property-selector.cjs.entry.js +1 -1
  15. package/dist/cjs/limebb-text-editor.cjs.entry.js +23 -25
  16. package/dist/cjs/limebb-trend-indicator.cjs.entry.js +2 -2
  17. package/dist/cjs/{limetype-TVwQ2eby.js → limetype-C7_hrzhN.js} +46 -0
  18. package/dist/collection/components/info-tile/info-tile.js +30 -67
  19. package/dist/collection/components/percentage-visualizer/percentage-visualizer.js +3 -3
  20. package/dist/collection/components/text-editor/text-editor.js +1 -1
  21. package/dist/collection/components/trend-indicator/trend-indicator.js +2 -2
  22. package/dist/collection/util/explorer-link.js +68 -0
  23. package/dist/collection/util/find-filter.js +16 -0
  24. package/dist/collection/util/limetype.js +45 -0
  25. package/dist/collection/util/localize-record.js +21 -0
  26. package/dist/components/_MapCache.js +1 -1
  27. package/dist/components/_Uint8Array.js +1 -1
  28. package/dist/components/_baseIsEqual.js +1 -1
  29. package/dist/components/_defineProperty.js +1 -1
  30. package/dist/components/get.js +1 -1
  31. package/dist/components/isSymbol.js +1 -1
  32. package/dist/components/limebb-info-tile.js +1 -1
  33. package/dist/components/limebb-locale-picker.js +1 -1
  34. package/dist/components/limebb-text-editor.js +1 -1
  35. package/dist/components/limebb-trend-indicator.js +1 -1
  36. package/dist/components/limetype-field.js +1 -1
  37. package/dist/components/limetype.js +1 -1
  38. package/dist/components/percentage-visualizer.js +1 -1
  39. package/dist/esm/{_MapCache-C_kVhYUl.js → _MapCache-BgAfMcRA.js} +329 -2
  40. package/dist/esm/{_getTag-DZlkp9mJ.js → _Uint8Array-CUI8uY-p.js} +351 -11
  41. package/dist/esm/{_baseIsEqual-DB13O4pD.js → _baseIsEqual-C-Mrg4RA.js} +2 -4
  42. package/dist/esm/{_defineProperty-DSmG08hO.js → _defineProperty-DZ483KPn.js} +1 -1
  43. package/dist/esm/{get-Bo260bSC.js → get-Cq4rshNg.js} +2 -3
  44. package/dist/esm/{isSymbol-Ci8cASb6.js → isSymbol-_IkM6xCs.js} +1 -1
  45. package/dist/esm/limebb-component-config.entry.js +3 -4
  46. package/dist/esm/limebb-info-tile.entry.js +135 -136
  47. package/dist/esm/limebb-lime-query-filter-builder_3.entry.js +4 -6
  48. package/dist/esm/limebb-locale-picker.entry.js +6 -8
  49. package/dist/esm/limebb-object-chip.entry.js +1 -1
  50. package/dist/esm/limebb-percentage-visualizer.entry.js +3 -3
  51. package/dist/esm/limebb-property-selector.entry.js +1 -1
  52. package/dist/esm/limebb-text-editor.entry.js +5 -7
  53. package/dist/esm/limebb-trend-indicator.entry.js +2 -2
  54. package/dist/esm/{limetype-BCEsb4WT.js → limetype-C4AY5lRw.js} +46 -1
  55. package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
  56. package/dist/lime-crm-building-blocks/p--IuhN2yx.js +1 -0
  57. package/dist/lime-crm-building-blocks/{p-c663afd2.entry.js → p-0cac0e56.entry.js} +1 -1
  58. package/dist/lime-crm-building-blocks/{p-5f1a4341.entry.js → p-34ad8e75.entry.js} +1 -1
  59. package/dist/lime-crm-building-blocks/p-37bab931.entry.js +1 -0
  60. package/dist/lime-crm-building-blocks/p-4163a0c0.entry.js +1 -0
  61. package/dist/lime-crm-building-blocks/p-49edd4fe.entry.js +1 -0
  62. package/dist/lime-crm-building-blocks/p-6PYziigk.js +1 -0
  63. package/dist/lime-crm-building-blocks/p-7a983aca.entry.js +1 -0
  64. package/dist/lime-crm-building-blocks/p-9019ca6f.entry.js +1 -0
  65. package/dist/lime-crm-building-blocks/p-BgAfMcRA.js +1 -0
  66. package/dist/lime-crm-building-blocks/p-BsH0YW6Z.js +1 -0
  67. package/dist/lime-crm-building-blocks/p-CKEnwX6j.js +1 -0
  68. package/dist/lime-crm-building-blocks/p-Ceen0vzd.js +1 -0
  69. package/dist/lime-crm-building-blocks/p-CtcTT7BK.js +1 -0
  70. package/dist/lime-crm-building-blocks/p-aa9b7af3.entry.js +1 -0
  71. package/dist/lime-crm-building-blocks/p-f397b288.entry.js +1 -0
  72. package/dist/types/components/info-tile/info-tile.d.ts +0 -3
  73. package/dist/types/util/explorer-link.d.ts +52 -0
  74. package/dist/types/util/find-filter.d.ts +13 -0
  75. package/dist/types/util/limetype.d.ts +35 -0
  76. package/dist/types/util/localize-record.d.ts +17 -0
  77. package/package.json +2 -2
  78. package/dist/cjs/_Map-BlpAtLvq.js +0 -342
  79. package/dist/cjs/_Uint8Array-C_lvn5HO.js +0 -352
  80. package/dist/components/_Map.js +0 -1
  81. package/dist/components/_getTag.js +0 -1
  82. package/dist/esm/_Map-ByjZfyP_.js +0 -330
  83. package/dist/esm/_Uint8Array-DVXPnoWk.js +0 -345
  84. package/dist/lime-crm-building-blocks/p-25700afb.entry.js +0 -1
  85. package/dist/lime-crm-building-blocks/p-3622d9b7.entry.js +0 -1
  86. package/dist/lime-crm-building-blocks/p-44347a69.entry.js +0 -1
  87. package/dist/lime-crm-building-blocks/p-60a09d6b.entry.js +0 -1
  88. package/dist/lime-crm-building-blocks/p-7cbec456.entry.js +0 -1
  89. package/dist/lime-crm-building-blocks/p-B8RiYkLS.js +0 -1
  90. package/dist/lime-crm-building-blocks/p-BJ8HvfgI.js +0 -1
  91. package/dist/lime-crm-building-blocks/p-BoVsXNfL.js +0 -1
  92. package/dist/lime-crm-building-blocks/p-ByjZfyP_.js +0 -1
  93. package/dist/lime-crm-building-blocks/p-CQ-z_HTt.js +0 -1
  94. package/dist/lime-crm-building-blocks/p-V3xfp9dg.js +0 -1
  95. package/dist/lime-crm-building-blocks/p-e2a6b9d2.entry.js +0 -1
  96. package/dist/lime-crm-building-blocks/p-e70a5298.entry.js +0 -1
  97. package/dist/lime-crm-building-blocks/p-mljVfXwO.js +0 -1
  98. package/dist/lime-crm-building-blocks/p-wbuFLk-j.js +0 -1
  99. package/dist/lime-crm-building-blocks/p-yc--7_7T.js +0 -1
@@ -83,8 +83,54 @@ function hasHasManyRelation(limetype, relatedLabel) {
83
83
  const property = getRelationProperty(limetype, relatedLabel);
84
84
  return !!property && isManyRelation(property);
85
85
  }
86
+ /**
87
+ * Find the property on `targetLimetype` whose relation points back to
88
+ * `contextLimetypeName`. This is the property a Lime CRM widget can use
89
+ * to narrow a filter to "items related to the current context object"
90
+ * — for example, "deals belonging to *this* company" when a widget is
91
+ * placed on a company card.
92
+ *
93
+ * Pass `propertyName` (the widget's configured property) to prefer the
94
+ * back-reference of *that* property's relation when ambiguous, falling
95
+ * back to the first matching relation on the limetype otherwise.
96
+ * @param options - the lookup inputs.
97
+ * @param options.targetLimetype - the limetype the filter is querying
98
+ * (i.e. the limetype the explorer would land on). The returned property
99
+ * name is one of *its* properties.
100
+ * @param options.currentLimetype - the limetype of the page hosting the
101
+ * widget, used together with `propertyName` to resolve a back-reference
102
+ * when the configured property is itself a relation.
103
+ * @param options.contextLimetypeName - name of the page's limetype.
104
+ * Returns `undefined` when missing — there is no context to relate to.
105
+ * @param options.contextId - id of the current context object. Returns
106
+ * `undefined` when missing — the relation cannot be narrowed without it.
107
+ * @param options.propertyName - widget-configured property whose
108
+ * relation back-reference should be preferred over a generic limetype
109
+ * scan. Optional.
110
+ * @returns name of the property on `targetLimetype` that points back at
111
+ * the context, or `undefined` when no such relation exists or the
112
+ * required inputs are missing.
113
+ */
114
+ function getRelationPropertyName(options) {
115
+ var _a, _b, _c;
116
+ const { targetLimetype, currentLimetype, contextLimetypeName, contextId, propertyName, } = options;
117
+ if (!targetLimetype || !contextLimetypeName || !contextId) {
118
+ return undefined;
119
+ }
120
+ if (propertyName) {
121
+ const backReference = (_b = (_a = currentLimetype === null || currentLimetype === void 0 ? void 0 : currentLimetype.getProperty(propertyName)) === null || _a === void 0 ? void 0 : _a.relation) === null || _b === void 0 ? void 0 : _b.getBackreference();
122
+ if (backReference) {
123
+ return backReference.name;
124
+ }
125
+ }
126
+ return (_c = Object.values(targetLimetype.properties).find((property) => {
127
+ var _a;
128
+ return ((_a = property.relation) === null || _a === void 0 ? void 0 : _a.getLimetype().name) === contextLimetypeName;
129
+ })) === null || _c === void 0 ? void 0 : _c.name;
130
+ }
86
131
 
87
132
  exports.getIcon = getIcon;
88
133
  exports.getRelationProperty = getRelationProperty;
134
+ exports.getRelationPropertyName = getRelationPropertyName;
89
135
  exports.hasHasManyRelation = hasHasManyRelation;
90
136
  exports.hasLabel = hasLabel;
@@ -11,8 +11,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
11
11
  import { h } from "@stencil/core";
12
12
  import { AggregateOperator, PlatformServiceName, SelectFilters, SelectConfig, Operator, SelectLimeTypes, } from "@limetech/lime-web-components";
13
13
  import { InfoTileContextProvider } from "./info-tile-context-provider";
14
- import { isEmpty } from "lodash-es";
15
14
  import { InfoTileLoader } from "./loader";
15
+ import { localizeRecord } from "../../util/localize-record";
16
+ import { findFilter } from "../../util/find-filter";
17
+ import { buildExplorerHref } from "../../util/explorer-link";
18
+ import { getRelationPropertyName } from "../../util/limetype";
16
19
  import { InfoTileFormatterFactory } from "./format/factory";
17
20
  import { BasicFormatter } from "./format/basic";
18
21
  /**
@@ -100,7 +103,7 @@ export class InfoTile {
100
103
  const errorProps = Object.assign(Object.assign({}, baseProps), { icon: 'error', prefix: 'ERROR', loading: true, label: this.getLabel(filter) });
101
104
  const normalProps = Object.assign(Object.assign({}, baseProps), { label: this.getLabel(filter), link: this.getLink(filter), loading: this.loading, value: value === null || value === void 0 ? void 0 : value.value.trim() });
102
105
  const props = !filter || this.error ? errorProps : normalProps;
103
- return (h("limel-info-tile", Object.assign({ key: '163c9aa74b485cb28ae56735a9643dd7e6579465', class: { error: !filter || this.error } }, props)));
106
+ return (h("limel-info-tile", Object.assign({ key: '540d2ccbd5c4e3d09fb736e260b3ec5c02d42415', class: { error: !filter || this.error } }, props)));
104
107
  }
105
108
  getFormattedValue() {
106
109
  if (!this.value && this.value !== 0) {
@@ -124,79 +127,39 @@ export class InfoTile {
124
127
  return this.translator.get(this.label);
125
128
  }
126
129
  if (this.label && typeof this.label === 'object') {
127
- return this.getLocalizedString(this.label);
130
+ return localizeRecord(this.label, this.language);
128
131
  }
129
- return this.getLocalizedString(filter.name);
130
- }
131
- getLocalizedString(strings) {
132
- if (isEmpty(strings)) {
133
- return '';
134
- }
135
- let localizedString = strings[this.language];
136
- if (!localizedString) {
137
- localizedString =
138
- strings.en ||
139
- strings.en_us ||
140
- Object.values(localizedString !== null && localizedString !== void 0 ? localizedString : {}).find((name) => !!name);
141
- }
142
- return localizedString !== null && localizedString !== void 0 ? localizedString : '';
132
+ return localizeRecord(filter.name, this.language);
143
133
  }
144
134
  getLink(filter) {
145
- if (!filter) {
146
- return { href: '#' };
147
- }
148
- const baseHref = ['explorer', filter.limetype, filter.id].join('/');
149
- const relationPropertyName = this.getRelationPropertyName(this.limetypes[filter.limetype]);
150
- const contextAwareFilter = this.buildContextAwareFilter(filter.filter, relationPropertyName);
151
- if (!contextAwareFilter) {
152
- return { href: baseHref };
153
- }
154
- const filterQuery = encodeURIComponent(JSON.stringify(contextAwareFilter));
155
- return { href: `${baseHref}?filter=${filterQuery}` };
156
- }
157
- buildContextAwareFilter(filter, relationPropertyName) {
158
- if (!relationPropertyName) {
159
- return filter;
160
- }
161
- const relationFilter = {
162
- key: relationPropertyName,
163
- op: Operator.EQUALS,
164
- exp: this.context.id,
165
- };
166
- if (!filter) {
167
- return {
168
- relationFilter,
169
- };
170
- }
171
- return {
172
- op: Operator.AND,
173
- exp: [relationFilter, filter],
174
- };
135
+ const relationPropertyName = getRelationPropertyName({
136
+ targetLimetype: filter
137
+ ? this.limetypes[filter.limetype]
138
+ : undefined,
139
+ currentLimetype: this.context.limetype
140
+ ? this.limetypes[this.context.limetype]
141
+ : undefined,
142
+ contextLimetypeName: this.context.limetype,
143
+ contextId: this.context.id,
144
+ propertyName: this.propertyName,
145
+ });
146
+ const extras = relationPropertyName && this.context.id
147
+ ? [
148
+ {
149
+ key: relationPropertyName,
150
+ op: Operator.EQUALS,
151
+ exp: this.context.id,
152
+ },
153
+ ]
154
+ : [];
155
+ return { href: buildExplorerHref(filter, extras) };
175
156
  }
176
157
  getFilter() {
177
- var _a;
178
- return (_a = this.filters) === null || _a === void 0 ? void 0 : _a.find((filter) => filter.id === this.filterId);
158
+ return findFilter(this.filters, this.filterId);
179
159
  }
180
160
  getFormatter(value) {
181
161
  return new InfoTileFormatterFactory(this.language).createFormatter(this.format, value);
182
162
  }
183
- getRelationPropertyName(limetype) {
184
- var _a, _b, _c;
185
- if (!limetype || !this.context.limetype || !this.context.id) {
186
- return;
187
- }
188
- if (this.propertyName) {
189
- const currentLimeType = this.limetypes[this.context.limetype];
190
- const backReference = (_b = (_a = currentLimeType === null || currentLimeType === void 0 ? void 0 : currentLimeType.getProperty(this.propertyName)) === null || _a === void 0 ? void 0 : _a.relation) === null || _b === void 0 ? void 0 : _b.getBackreference();
191
- if (backReference) {
192
- return backReference.name;
193
- }
194
- }
195
- return (_c = Object.values(limetype.properties).find((property) => {
196
- var _a;
197
- return (((_a = property.relation) === null || _a === void 0 ? void 0 : _a.getLimetype().name) === this.context.limetype);
198
- })) === null || _c === void 0 ? void 0 : _c.name;
199
- }
200
163
  get translator() {
201
164
  return this.platform.get(PlatformServiceName.Translate);
202
165
  }
@@ -217,7 +180,7 @@ export class InfoTile {
217
180
  limetype: filter === null || filter === void 0 ? void 0 : filter.limetype,
218
181
  filterId: this.filterId,
219
182
  filterName: filter
220
- ? this.getLocalizedString(filter.name)
183
+ ? localizeRecord(filter.name, this.language)
221
184
  : undefined,
222
185
  aggregateOperator: this.aggregateOperator,
223
186
  propertyName: this.propertyName,
@@ -88,7 +88,7 @@ export class PercentageVisualizer {
88
88
  this.numberFormat = new Intl.NumberFormat(this.locale);
89
89
  }
90
90
  catch (_a) {
91
- console.error(`Could not get user's locale (${this.locale}), falling back to 'en'.`);
91
+ console.warn(`Could not get user's locale (${this.locale}), falling back to 'en'.`);
92
92
  this.locale = 'en';
93
93
  this.numberFormat = new Intl.NumberFormat('en');
94
94
  }
@@ -108,11 +108,11 @@ export class PercentageVisualizer {
108
108
  render() {
109
109
  const normalizedValue = this.getNormalizedValue();
110
110
  const zeroPoint = this.getZeroPointPosition();
111
- return (h(Host, { key: 'e3ff49b03b4703e06dbe85edc26421d95ed3974d', class: this.getContainerClassList(), style: {
111
+ return (h(Host, { key: '11b3795adc2f38c75866292070edc9f89bd7c099', class: this.getContainerClassList(), style: {
112
112
  '--limebb-percentage-visualizer-zero-point-position': `${zeroPoint}%`,
113
113
  '--limebb-percentage-visualizer-width': `${Math.abs(normalizedValue)}%`,
114
114
  '--limebb-percentage-visualizer-rotate': `${normalizedValue >= 0 ? '0deg' : '180deg'}`,
115
- } }, h("limel-notched-outline", { key: '308a71d2427118515f5a7bfbb3dbe20a7b310461', tabIndex: 0, role: "meter", "aria-valuemin": this.rangeMin, "aria-valuemax": this.rangeMax, "aria-valuenow": this.numValue, "aria-labelledby": this.labelId, "aria-describedby": this.helperTextId, label: this.label, labelId: this.labelId, invalid: this.invalid, required: this.required, hasValue: true, hasFloatingLabel: true, "aria-controls": this.helperTextId }, h("div", { key: '80bdd6e8423cc62ba4298d1f3af48cc77e662e72', slot: "content" }, this.renderVisualization())), this.renderHelperLine()));
115
+ } }, h("limel-notched-outline", { key: '2c3000f41ba01de424c3cb18dcb2f71799800449', tabIndex: 0, role: "meter", "aria-valuemin": this.rangeMin, "aria-valuemax": this.rangeMax, "aria-valuenow": this.numValue, "aria-labelledby": this.labelId, "aria-describedby": this.helperTextId, label: this.label, labelId: this.labelId, invalid: this.invalid, required: this.required, hasValue: true, hasFloatingLabel: true, "aria-controls": this.helperTextId }, h("div", { key: 'b0b064361c57341342344e7ecfe29818413737ee', slot: "content" }, this.renderVisualization())), this.renderHelperLine()));
116
116
  }
117
117
  renderVisualization() {
118
118
  if (this.reducePresence && (this.numValue === 0 || !this.hasValue())) {
@@ -834,7 +834,7 @@ export class LimeBBTextEditor {
834
834
  "mutable": false,
835
835
  "complexType": {
836
836
  "original": "TriggerMap",
837
- "resolved": "{ \".\"?: TriggerHandler | undefined; \"#\"?: TriggerHandler | undefined; \"/\"?: TriggerHandler | undefined; \"@\"?: TriggerHandler | undefined; $?: TriggerHandler | undefined; \"!\"?: TriggerHandler | undefined; \"?\"?: TriggerHandler | undefined; \"&\"?: TriggerHandler | undefined; \"*\"?: TriggerHandler | undefined; \"%\"?: TriggerHandler | undefined; \"+\"?: TriggerHandler | undefined; \"-\"?: TriggerHandler | undefined; \"=\"?: TriggerHandler | undefined; \"\\\\\"?: TriggerHandler | undefined; \"^\"?: TriggerHandler | undefined; \"~\"?: TriggerHandler | undefined; \"`\"?: TriggerHandler | undefined; \":\"?: TriggerHandler | undefined; \";\"?: TriggerHandler | undefined; \"|\"?: TriggerHandler | undefined; \",\"?: TriggerHandler | undefined; \"<\"?: TriggerHandler | undefined; \">\"?: TriggerHandler | undefined; \"[\"?: TriggerHandler | undefined; \"]\"?: TriggerHandler | undefined; \"{\"?: TriggerHandler | undefined; \"}\"?: TriggerHandler | undefined; \"(\"?: TriggerHandler | undefined; \")\"?: TriggerHandler | undefined; \"'\"?: TriggerHandler | undefined; }",
837
+ "resolved": "{ \".\"?: TriggerHandler | undefined; \"#\"?: TriggerHandler | undefined; \"/\"?: TriggerHandler | undefined; \"&\"?: TriggerHandler | undefined; \"@\"?: TriggerHandler | undefined; $?: TriggerHandler | undefined; \"!\"?: TriggerHandler | undefined; \"?\"?: TriggerHandler | undefined; \"*\"?: TriggerHandler | undefined; \"%\"?: TriggerHandler | undefined; \"+\"?: TriggerHandler | undefined; \"-\"?: TriggerHandler | undefined; \"=\"?: TriggerHandler | undefined; \"\\\\\"?: TriggerHandler | undefined; \"^\"?: TriggerHandler | undefined; \"~\"?: TriggerHandler | undefined; \"`\"?: TriggerHandler | undefined; \":\"?: TriggerHandler | undefined; \";\"?: TriggerHandler | undefined; \"|\"?: TriggerHandler | undefined; \",\"?: TriggerHandler | undefined; \"<\"?: TriggerHandler | undefined; \">\"?: TriggerHandler | undefined; \"[\"?: TriggerHandler | undefined; \"]\"?: TriggerHandler | undefined; \"{\"?: TriggerHandler | undefined; \"}\"?: TriggerHandler | undefined; \"(\"?: TriggerHandler | undefined; \")\"?: TriggerHandler | undefined; \"'\"?: TriggerHandler | undefined; }",
838
838
  "references": {
839
839
  "TriggerMap": {
840
840
  "location": "import",
@@ -62,14 +62,14 @@ export class TrendIndicator {
62
62
  this.numberFormat = new Intl.NumberFormat(this.locale);
63
63
  }
64
64
  catch (_a) {
65
- console.error(`Could not get user's locale (${this.locale}), falling back to 'en'.`);
65
+ console.warn(`Could not get user's locale (${this.locale}), falling back to 'en'.`);
66
66
  this.locale = 'en';
67
67
  this.numberFormat = new Intl.NumberFormat('en');
68
68
  }
69
69
  this.numValue = this.parseValue(this.value);
70
70
  }
71
71
  render() {
72
- return (h(Host, { key: 'c1d0e3cbfbfe0da3d821817b3986773ea7af13de', class: this.getContainerClassList() }, h("limel-notched-outline", { key: 'd32675f77f9a6bc700d566acc9f59b3575f03ff1', id: this.tooltipId, label: this.label, labelId: this.labelId, invalid: this.invalid, required: this.required, hasValue: true, hasFloatingLabel: true, "aria-labelledby": this.labelId, "aria-describedby": this.helperTextId, "aria-controls": this.helperTextId }, h("div", { key: '558eac3631f2daced6d6e4f246912140ceb65268', slot: "content", tabIndex: 0 }, this.renderVisualization())), this.renderHelperLine(), this.renderTooltip()));
72
+ return (h(Host, { key: '4dc77e741406e9b51fdde5744b8c46bf70fd8cab', class: this.getContainerClassList() }, h("limel-notched-outline", { key: '3a0209effdb1ef52d8109e420162e0675e40178f', id: this.tooltipId, label: this.label, labelId: this.labelId, invalid: this.invalid, required: this.required, hasValue: true, hasFloatingLabel: true, "aria-labelledby": this.labelId, "aria-describedby": this.helperTextId, "aria-controls": this.helperTextId }, h("div", { key: 'fcf81af972393a538a65e6014afa581935fcf837', slot: "content", tabIndex: 0 }, this.renderVisualization())), this.renderHelperLine(), this.renderTooltip()));
73
73
  }
74
74
  renderVisualization() {
75
75
  if (this.reducePresence && (this.numValue === 0 || !this.hasValue())) {
@@ -0,0 +1,68 @@
1
+ import { Operator } from "@limetech/lime-web-components";
2
+ /**
3
+ * Build a parsed explorer destination for a filter, optionally
4
+ * narrowing it with extra expressions AND-combined onto the filter's
5
+ * own expression. Use this when navigating imperatively via the
6
+ * `Navigator` service so the host SPA stays on the page (no full
7
+ * reload).
8
+ * @param filter - the filter set whose limetype and id form the
9
+ * explorer path. When `undefined`, the function returns
10
+ * `{ path: '#' }` so callers can wire it into a link without a
11
+ * special-case branch.
12
+ * @param extraExpressions - expressions to AND onto the filter's own
13
+ * expression. The chart passes `{ key: groupBy, op: '=', exp: item }`
14
+ * here, info-tile passes a back-reference constraint when the widget
15
+ * is on an object card. Order matters in the resulting AND: extras
16
+ * come before the filter's own expression.
17
+ * @returns `path` plus, when there's any filter expression to apply,
18
+ * `query.filter` holding the combined expression as a raw object (the
19
+ * navigator stringifies and URL-encodes it when generating the URL).
20
+ */
21
+ export function buildExplorerLocation(filter, extraExpressions = []) {
22
+ if (!filter) {
23
+ return { path: '#' };
24
+ }
25
+ const path = ['explorer', filter.limetype, filter.id].join('/');
26
+ const combined = combineExpressions(filter.filter, extraExpressions);
27
+ return combined ? { path, query: { filter: combined } } : { path };
28
+ }
29
+ /**
30
+ * Build a Lime CRM explorer href for a filter, optionally narrowing it
31
+ * with extra expressions AND-combined onto the filter's own expression.
32
+ *
33
+ * Used by widgets like `limebb-info-tile` to render anchor `<a>` links
34
+ * to a filtered list. For imperative navigation prefer
35
+ * {@link buildExplorerLocation} together with the `Navigator` service.
36
+ * @param filter - the filter set whose limetype and id form the
37
+ * explorer href. When `undefined`, the function returns `'#'` so
38
+ * callers can wire it into a link without a special-case branch.
39
+ * @param extraExpressions - expressions to AND onto the filter's own
40
+ * expression, with the same ordering and use-cases as
41
+ * {@link buildExplorerLocation}.
42
+ * @returns an explorer href such as
43
+ * `explorer/{limetype}/{filterId}?filter=<URL-encoded JSON>`, or
44
+ * `'#'` when `filter` is `undefined`.
45
+ */
46
+ export function buildExplorerHref(filter, extraExpressions = []) {
47
+ const { path, query } = buildExplorerLocation(filter, extraExpressions);
48
+ if (!query) {
49
+ return path;
50
+ }
51
+ const search = Object.entries(query)
52
+ .map(([key, value]) => `${key}=${encodeURIComponent(JSON.stringify(value))}`)
53
+ .join('&');
54
+ return `${path}?${search}`;
55
+ }
56
+ function combineExpressions(filter, extras) {
57
+ const all = [...extras, filter].filter((exp) => exp !== undefined);
58
+ if (all.length === 0) {
59
+ return undefined;
60
+ }
61
+ if (all.length === 1) {
62
+ return all[0];
63
+ }
64
+ return {
65
+ op: Operator.AND,
66
+ exp: all,
67
+ };
68
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Finds a filter set by id in an array of filter sets.
3
+ *
4
+ * Returns `undefined` when either `filters` or `filterId` is missing or
5
+ * when no filter matches — safe to call with optional inputs without a
6
+ * guard.
7
+ *
8
+ * @param filters - The filter sets to search.
9
+ * @param filterId - The id of the filter set to find.
10
+ */
11
+ export function findFilter(filters, filterId) {
12
+ if (!filters || !filterId) {
13
+ return undefined;
14
+ }
15
+ return filters.find((filter) => filter.id === filterId);
16
+ }
@@ -80,3 +80,48 @@ export function hasHasManyRelation(limetype, relatedLabel) {
80
80
  const property = getRelationProperty(limetype, relatedLabel);
81
81
  return !!property && isManyRelation(property);
82
82
  }
83
+ /**
84
+ * Find the property on `targetLimetype` whose relation points back to
85
+ * `contextLimetypeName`. This is the property a Lime CRM widget can use
86
+ * to narrow a filter to "items related to the current context object"
87
+ * — for example, "deals belonging to *this* company" when a widget is
88
+ * placed on a company card.
89
+ *
90
+ * Pass `propertyName` (the widget's configured property) to prefer the
91
+ * back-reference of *that* property's relation when ambiguous, falling
92
+ * back to the first matching relation on the limetype otherwise.
93
+ * @param options - the lookup inputs.
94
+ * @param options.targetLimetype - the limetype the filter is querying
95
+ * (i.e. the limetype the explorer would land on). The returned property
96
+ * name is one of *its* properties.
97
+ * @param options.currentLimetype - the limetype of the page hosting the
98
+ * widget, used together with `propertyName` to resolve a back-reference
99
+ * when the configured property is itself a relation.
100
+ * @param options.contextLimetypeName - name of the page's limetype.
101
+ * Returns `undefined` when missing — there is no context to relate to.
102
+ * @param options.contextId - id of the current context object. Returns
103
+ * `undefined` when missing — the relation cannot be narrowed without it.
104
+ * @param options.propertyName - widget-configured property whose
105
+ * relation back-reference should be preferred over a generic limetype
106
+ * scan. Optional.
107
+ * @returns name of the property on `targetLimetype` that points back at
108
+ * the context, or `undefined` when no such relation exists or the
109
+ * required inputs are missing.
110
+ */
111
+ export function getRelationPropertyName(options) {
112
+ var _a, _b, _c;
113
+ const { targetLimetype, currentLimetype, contextLimetypeName, contextId, propertyName, } = options;
114
+ if (!targetLimetype || !contextLimetypeName || !contextId) {
115
+ return undefined;
116
+ }
117
+ if (propertyName) {
118
+ const backReference = (_b = (_a = currentLimetype === null || currentLimetype === void 0 ? void 0 : currentLimetype.getProperty(propertyName)) === null || _a === void 0 ? void 0 : _a.relation) === null || _b === void 0 ? void 0 : _b.getBackreference();
119
+ if (backReference) {
120
+ return backReference.name;
121
+ }
122
+ }
123
+ return (_c = Object.values(targetLimetype.properties).find((property) => {
124
+ var _a;
125
+ return ((_a = property.relation) === null || _a === void 0 ? void 0 : _a.getLimetype().name) === contextLimetypeName;
126
+ })) === null || _c === void 0 ? void 0 : _c.name;
127
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Picks a localized string from a record keyed by locale code.
3
+ *
4
+ * Looks up the value for `language` first, then falls back to `en` and
5
+ * `en_us`. Returns an empty string when none of those keys carry a
6
+ * non-empty value, even if other locales are present in the record —
7
+ * matching the behavior consumers rely on today.
8
+ *
9
+ * Useful for resolving values such as `Filter.name`, where strings are
10
+ * provided per locale.
11
+ *
12
+ * @param strings - Record where keys are locale codes and values are
13
+ * the localized strings.
14
+ * @param language - The preferred locale code.
15
+ */
16
+ export function localizeRecord(strings, language) {
17
+ if (!strings) {
18
+ return '';
19
+ }
20
+ return strings[language] || strings.en || strings.en_us || '';
21
+ }
@@ -1 +1 @@
1
- import{g as t,M as n}from"./_Map.js";function i(t,n){return t===n||t!=t&&n!=n}var r=t(Object,"create"),s=Object.prototype.hasOwnProperty,u=Object.prototype.hasOwnProperty;function h(t){var n=-1,i=null==t?0:t.length;for(this.clear();++n<i;){var r=t[n];this.set(r[0],r[1])}}function o(t,n){for(var r=t.length;r--;)if(i(t[r][0],n))return r;return-1}h.prototype.clear=function(){this.__data__=r?r(null):{},this.size=0},h.prototype.delete=function(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n},h.prototype.get=function(t){var n=this.__data__;if(r){var i=n[t];return"__lodash_hash_undefined__"===i?void 0:i}return s.call(n,t)?n[t]:void 0},h.prototype.has=function(t){var n=this.__data__;return r?void 0!==n[t]:u.call(n,t)},h.prototype.set=function(t,n){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=r&&void 0===n?"__lodash_hash_undefined__":n,this};var e=Array.prototype.splice;function a(t){var n=-1,i=null==t?0:t.length;for(this.clear();++n<i;){var r=t[n];this.set(r[0],r[1])}}function f(t,n){var i,r,s=t.__data__;return("string"==(r=typeof(i=n))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==i:null===i)?s["string"==typeof n?"string":"hash"]:s.map}function c(t){var n=-1,i=null==t?0:t.length;for(this.clear();++n<i;){var r=t[n];this.set(r[0],r[1])}}a.prototype.clear=function(){this.__data__=[],this.size=0},a.prototype.delete=function(t){var n=this.__data__,i=o(n,t);return!(i<0||(i==n.length-1?n.pop():e.call(n,i,1),--this.size,0))},a.prototype.get=function(t){var n=this.__data__,i=o(n,t);return i<0?void 0:n[i][1]},a.prototype.has=function(t){return o(this.__data__,t)>-1},a.prototype.set=function(t,n){var i=this.__data__,r=o(i,t);return r<0?(++this.size,i.push([t,n])):i[r][1]=n,this},c.prototype.clear=function(){this.size=0,this.__data__={hash:new h,map:new(n||a),string:new h}},c.prototype.delete=function(t){var n=f(this,t).delete(t);return this.size-=n?1:0,n},c.prototype.get=function(t){return f(this,t).get(t)},c.prototype.has=function(t){return f(this,t).has(t)},c.prototype.set=function(t,n){var i=f(this,t),r=i.size;return i.set(t,n),this.size+=i.size==r?0:1,this};export{a as L,c as M,i as e}
1
+ var t="object"==typeof global&&global&&global.Object===Object&&global,n="object"==typeof self&&self&&self.Object===Object&&self,r=t||n||Function("return this")(),i=r.Symbol,o=Object.prototype,e=o.hasOwnProperty,u=o.toString,c=i?i.toStringTag:void 0,a=Object.prototype.toString,s=i?i.toStringTag:void 0;function f(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?function(t){var n=e.call(t,c),r=t[c];try{t[c]=void 0;var i=!0}catch(t){}var o=u.call(t);return i&&(n?t[c]=r:delete t[c]),o}(t):function(t){return a.call(t)}(t)}function h(t){return null!=t&&"object"==typeof t}var v=Array.isArray;function l(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function b(t){if(!l(t))return!1;var n=f(t);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}var d,j=r["__core-js_shared__"],_=(d=/[^.]+$/.exec(j&&j.keys&&j.keys.IE_PROTO||""))?"Symbol(src)_1."+d:"",y=Function.prototype.toString;function p(t){if(null!=t){try{return y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var g=/^\[object .+?Constructor\]$/,O=RegExp("^"+Function.prototype.toString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function F(t,n){var r=function(t,n){return null==t?void 0:t[n]}(t,n);return function(t){return!(!l(t)||(n=t,_&&_ in n))&&(b(t)?O:g).test(p(t));var n}(r)?r:void 0}function $(t,n){return t===n||t!=t&&n!=n}var m=F(Object,"create"),w=Object.prototype.hasOwnProperty,x=Object.prototype.hasOwnProperty;function A(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var i=t[n];this.set(i[0],i[1])}}function M(t,n){for(var r=t.length;r--;)if($(t[r][0],n))return r;return-1}A.prototype.clear=function(){this.__data__=m?m(null):{},this.size=0},A.prototype.delete=function(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n},A.prototype.get=function(t){var n=this.__data__;if(m){var r=n[t];return"__lodash_hash_undefined__"===r?void 0:r}return w.call(n,t)?n[t]:void 0},A.prototype.has=function(t){var n=this.__data__;return m?void 0!==n[t]:x.call(n,t)},A.prototype.set=function(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=m&&void 0===n?"__lodash_hash_undefined__":n,this};var P=Array.prototype.splice;function S(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var i=t[n];this.set(i[0],i[1])}}S.prototype.clear=function(){this.__data__=[],this.size=0},S.prototype.delete=function(t){var n=this.__data__,r=M(n,t);return!(r<0||(r==n.length-1?n.pop():P.call(n,r,1),--this.size,0))},S.prototype.get=function(t){var n=this.__data__,r=M(n,t);return r<0?void 0:n[r][1]},S.prototype.has=function(t){return M(this.__data__,t)>-1},S.prototype.set=function(t,n){var r=this.__data__,i=M(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this};var C=F(r,"Map");function E(t,n){var r,i,o=t.__data__;return("string"==(i=typeof(r=n))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==r:null===r)?o["string"==typeof n?"string":"hash"]:o.map}function G(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var i=t[n];this.set(i[0],i[1])}}G.prototype.clear=function(){this.size=0,this.__data__={hash:new A,map:new(C||S),string:new A}},G.prototype.delete=function(t){var n=E(this,t).delete(t);return this.size-=n?1:0,n},G.prototype.get=function(t){return E(this,t).get(t)},G.prototype.has=function(t){return E(this,t).has(t)},G.prototype.set=function(t,n){var r=E(this,t),i=r.size;return r.set(t,n),this.size+=r.size==i?0:1,this};export{S as L,G as M,i as S,v as a,f as b,l as c,b as d,$ as e,t as f,F as g,C as h,h as i,r,p as t}
@@ -1 +1 @@
1
- import{L as r,M as t}from"./_MapCache.js";import{a as n,M as a,r as i}from"./_Map.js";import{c as e,a as s,b as u,e as f,i as o}from"./_getTag.js";var c=/^(?:0|[1-9]\d*)$/;function h(r,t){var n=typeof r;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&c.test(r))&&r>-1&&r%1==0&&r<t}var v=Object.prototype.hasOwnProperty;function b(r){return o(r)?function(r){var t=n(r),a=!t&&e(r),i=!t&&!a&&s(r),f=!t&&!a&&!i&&u(r),o=t||a||i||f,c=o?function(r,t){for(var n=-1,a=Array(r);++n<r;)a[n]=t(n);return a}(r.length,String):[],b=c.length;for(var l in r)!v.call(r,l)||o&&("length"==l||i&&("offset"==l||"parent"==l)||f&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||h(l,b))||c.push(l);return c}(r):f(r)}function l(r,t){for(var n=-1,a=t.length,i=r.length;++n<a;)r[i+n]=t[n];return r}function m(t){var n=this.__data__=new r(t);this.size=n.size}m.prototype.clear=function(){this.__data__=new r,this.size=0},m.prototype.delete=function(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n},m.prototype.get=function(r){return this.__data__.get(r)},m.prototype.has=function(r){return this.__data__.has(r)},m.prototype.set=function(n,i){var e=this.__data__;if(e instanceof r){var s=e.__data__;if(!a||s.length<199)return s.push([n,i]),this.size=++e.size,this;e=this.__data__=new t(s)}return e.set(n,i),this.size=e.size,this};var p=Object.prototype.propertyIsEnumerable,j=Object.getOwnPropertySymbols,g=j?function(r){return null==r?[]:(r=Object(r),function(t){for(var n=-1,a=null==t?0:t.length,i=0,e=[];++n<a;){var s=t[n];p.call(r,s)&&(e[i++]=s)}return e}(j(r)))}:function(){return[]};function y(r){return function(r,t,a){var i=b(r);return n(r)?i:l(i,a(r))}(r,0,g)}var O=i.Uint8Array;export{m as S,O as U,l as a,y as g,h as i,b as k}
1
+ import{g as t,r,d as n,i as e,b as u,f as o,a,L as c,h as i,M as s,t as f}from"./_MapCache.js";var b=t(r,"WeakMap"),v=/^(?:0|[1-9]\d*)$/;function l(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&v.test(t))&&t>-1&&t%1==0&&t<r}function j(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function p(t){return null!=t&&j(t.length)&&!n(t)}var h=Object.prototype;function m(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||h)}function d(t){return e(t)&&"[object Arguments]"==u(t)}var y=Object.prototype,O=y.hasOwnProperty,w=y.propertyIsEnumerable,x=d(function(){return arguments}())?d:function(t){return e(t)&&O.call(t,"callee")&&!w.call(t,"callee")},g="object"==typeof exports&&exports&&!exports.nodeType&&exports,M=g&&"object"==typeof module&&module&&!module.nodeType&&module,S=M&&M.exports===g?r.Buffer:void 0,k=(S?S.isBuffer:void 0)||function(){return!1},A={};function D(t){return function(r){return t(r)}}A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A["[object Arguments]"]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object Boolean]"]=A["[object DataView]"]=A["[object Date]"]=A["[object Error]"]=A["[object Function]"]=A["[object Map]"]=A["[object Number]"]=A["[object Object]"]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object WeakMap]"]=!1;var L="object"==typeof exports&&exports&&!exports.nodeType&&exports,P=L&&"object"==typeof module&&module&&!module.nodeType&&module,V=P&&P.exports===L&&o.process,W=function(){try{return P&&P.require&&P.require("util").types||V&&V.binding&&V.binding("util")}catch(t){}}(),B=W&&W.isTypedArray,C=B?D(B):function(t){return e(t)&&j(t.length)&&!!A[u(t)]},U=Object.prototype.hasOwnProperty;function $(t,r){return function(n){return t(r(n))}}var _=$(Object.keys,Object),q=Object.prototype.hasOwnProperty;function z(t){return p(t)?function(t){var r=a(t),n=!r&&x(t),e=!r&&!n&&k(t),u=!r&&!n&&!e&&C(t),o=r||n||e||u,c=o?function(t,r){for(var n=-1,e=Array(t);++n<t;)e[n]=r(n);return e}(t.length,String):[],i=c.length;for(var s in t)!U.call(t,s)||o&&("length"==s||e&&("offset"==s||"parent"==s)||u&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||l(s,i))||c.push(s);return c}(t):function(t){if(!m(t))return _(t);var r=[];for(var n in Object(t))q.call(t,n)&&"constructor"!=n&&r.push(n);return r}(t)}function E(t,r){for(var n=-1,e=r.length,u=t.length;++n<e;)t[u+n]=r[n];return t}function F(t){var r=this.__data__=new c(t);this.size=r.size}F.prototype.clear=function(){this.__data__=new c,this.size=0},F.prototype.delete=function(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n},F.prototype.get=function(t){return this.__data__.get(t)},F.prototype.has=function(t){return this.__data__.has(t)},F.prototype.set=function(t,r){var n=this.__data__;if(n instanceof c){var e=n.__data__;if(!i||e.length<199)return e.push([t,r]),this.size=++n.size,this;n=this.__data__=new s(e)}return n.set(t,r),this.size=n.size,this};var G=Object.prototype.propertyIsEnumerable,H=Object.getOwnPropertySymbols,I=H?function(t){return null==t?[]:(t=Object(t),function(r){for(var n=-1,e=null==r?0:r.length,u=0,o=[];++n<e;){var a=r[n];G.call(t,a)&&(o[u++]=a)}return o}(H(t)))}:function(){return[]};function J(t){return function(t,r,n){var e=z(t);return a(t)?e:E(e,n(t))}(t,0,I)}var K=t(r,"DataView"),N=t(r,"Promise"),Q=t(r,"Set"),R="[object Map]",T="[object Promise]",X="[object Set]",Y="[object WeakMap]",Z="[object DataView]",tt=f(K),rt=f(i),nt=f(N),et=f(Q),ut=f(b),ot=u;(K&&ot(new K(new ArrayBuffer(1)))!=Z||i&&ot(new i)!=R||N&&ot(N.resolve())!=T||Q&&ot(new Q)!=X||b&&ot(new b)!=Y)&&(ot=function(t){var r=u(t),n="[object Object]"==r?t.constructor:void 0,e=n?f(n):"";if(e)switch(e){case tt:return Z;case rt:return R;case nt:return T;case et:return X;case ut:return Y}return r});var at=r.Uint8Array;export{F as S,at as U,ot as a,C as b,m as c,D as d,p as e,l as f,J as g,x as h,k as i,E as j,z as k,j as l,W as n,$ as o}
@@ -1 +1 @@
1
- import{U as r,g as e,S as t}from"./_Uint8Array.js";import{M as n,e as a}from"./_MapCache.js";import{S as i,a as o,i as f}from"./_Map.js";import{g as u,a as c,b as s}from"./_getTag.js";function v(r){var e=-1,t=null==r?0:r.length;for(this.__data__=new n;++e<t;)this.add(r[e])}function b(r,e){for(var t=-1,n=null==r?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}function j(r,e,t,n,a,i){var o=1&t,f=r.length,u=e.length;if(f!=u&&!(o&&u>f))return!1;var c=i.get(r),s=i.get(e);if(c&&s)return c==e&&s==r;var j=-1,_=!0,p=2&t?new v:void 0;for(i.set(r,e),i.set(e,r);++j<f;){var l=r[j],m=e[j];if(n)var w=o?n(m,l,j,e,r,i):n(l,m,j,r,e,i);if(void 0!==w){if(w)continue;_=!1;break}if(p){if(!b(e,(function(r,e){if(!p.has(e)&&(l===r||a(l,r,t,n,i)))return p.push(e)}))){_=!1;break}}else if(l!==m&&!a(l,m,t,n,i)){_=!1;break}}return i.delete(r),i.delete(e),_}function _(r){var e=-1,t=Array(r.size);return r.forEach((function(r,n){t[++e]=[n,r]})),t}function p(r){var e=-1,t=Array(r.size);return r.forEach((function(r){t[++e]=r})),t}v.prototype.add=v.prototype.push=function(r){return this.__data__.set(r,"__lodash_hash_undefined__"),this},v.prototype.has=function(r){return this.__data__.has(r)};var l=i?i.prototype:void 0,m=l?l.valueOf:void 0,w=Object.prototype.hasOwnProperty,d="[object Arguments]",h="[object Array]",y="[object Object]",g=Object.prototype.hasOwnProperty;function A(n,i,v,b,l){return n===i||(null==n||null==i||!f(n)&&!f(i)?n!=n&&i!=i:function(n,i,f,v,b,l){var A=o(n),S=o(i),k=A?h:u(n),M=S?h:u(i),O=(k=k==d?y:k)==y,x=(M=M==d?y:M)==y,B=k==M;if(B&&c(n)){if(!c(i))return!1;A=!0,O=!1}if(B&&!O)return l||(l=new t),A||s(n)?j(n,i,f,v,b,l):function(e,t,n,i,o,f,u){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!f(new r(e),new r(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return a(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var c=_;case"[object Set]":if(c||(c=p),e.size!=t.size&&!(1&i))return!1;var s=u.get(e);if(s)return s==t;i|=2,u.set(e,t);var v=j(c(e),c(t),i,o,f,u);return u.delete(e),v;case"[object Symbol]":if(m)return m.call(e)==m.call(t)}return!1}(n,i,k,f,v,b,l);if(!(1&f)){var D=O&&g.call(n,"__wrapped__"),E=x&&g.call(i,"__wrapped__");if(D||E){var U=D?n.value():n,C=E?i.value():i;return l||(l=new t),b(U,C,f,v,l)}}return!!B&&(l||(l=new t),function(r,t,n,a,i,o){var f=1&n,u=e(r),c=u.length;if(c!=e(t).length&&!f)return!1;for(var s=c;s--;){var v=u[s];if(!(f?v in t:w.call(t,v)))return!1}var b=o.get(r),j=o.get(t);if(b&&j)return b==t&&j==r;var _=!0;o.set(r,t),o.set(t,r);for(var p=f;++s<c;){var l=r[v=u[s]],m=t[v];if(a)var d=f?a(m,l,v,t,r,o):a(l,m,v,r,t,o);if(!(void 0===d?l===m||i(l,m,n,a,o):d)){_=!1;break}p||(p="constructor"==v)}if(_&&!p){var h=r.constructor,y=t.constructor;h==y||!("constructor"in r)||!("constructor"in t)||"function"==typeof h&&h instanceof h&&"function"==typeof y&&y instanceof y||(_=!1)}return o.delete(r),o.delete(t),_}(n,i,f,v,b,l))}(n,i,v,b,A,l))}export{A as b}
1
+ import{U as r,g as e,a as n,i as t,S as a,b as i}from"./_Uint8Array.js";import{M as o,S as u,e as c,a as f,i as s}from"./_MapCache.js";function v(r){var e=-1,n=null==r?0:r.length;for(this.__data__=new o;++e<n;)this.add(r[e])}function b(r,e){for(var n=-1,t=null==r?0:r.length;++n<t;)if(e(r[n],n,r))return!0;return!1}function j(r,e,n,t,a,i){var o=1&n,u=r.length,c=e.length;if(u!=c&&!(o&&c>u))return!1;var f=i.get(r),s=i.get(e);if(f&&s)return f==e&&s==r;var j=-1,_=!0,l=2&n?new v:void 0;for(i.set(r,e),i.set(e,r);++j<u;){var p=r[j],w=e[j];if(t)var d=o?t(w,p,j,e,r,i):t(p,w,j,r,e,i);if(void 0!==d){if(d)continue;_=!1;break}if(l){if(!b(e,(function(r,e){if(!l.has(e)&&(p===r||a(p,r,n,t,i)))return l.push(e)}))){_=!1;break}}else if(p!==w&&!a(p,w,n,t,i)){_=!1;break}}return i.delete(r),i.delete(e),_}function _(r){var e=-1,n=Array(r.size);return r.forEach((function(r,t){n[++e]=[t,r]})),n}function l(r){var e=-1,n=Array(r.size);return r.forEach((function(r){n[++e]=r})),n}v.prototype.add=v.prototype.push=function(r){return this.__data__.set(r,"__lodash_hash_undefined__"),this},v.prototype.has=function(r){return this.__data__.has(r)};var p=u?u.prototype:void 0,w=p?p.valueOf:void 0,d=Object.prototype.hasOwnProperty,h="[object Arguments]",y="[object Array]",m="[object Object]",A=Object.prototype.hasOwnProperty;function S(o,u,v,b,p){return o===u||(null==o||null==u||!s(o)&&!s(u)?o!=o&&u!=u:function(o,u,s,v,b,p){var S=f(o),g=f(u),k=S?y:n(o),M=g?y:n(u),O=(k=k==h?m:k)==m,x=(M=M==h?m:M)==m,B=k==M;if(B&&t(o)){if(!t(u))return!1;S=!0,O=!1}if(B&&!O)return p||(p=new a),S||i(o)?j(o,u,s,v,b,p):function(e,n,t,a,i,o,u){switch(t){case"[object DataView]":if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=n.byteLength||!o(new r(e),new r(n)));case"[object Boolean]":case"[object Date]":case"[object Number]":return c(+e,+n);case"[object Error]":return e.name==n.name&&e.message==n.message;case"[object RegExp]":case"[object String]":return e==n+"";case"[object Map]":var f=_;case"[object Set]":if(f||(f=l),e.size!=n.size&&!(1&a))return!1;var s=u.get(e);if(s)return s==n;a|=2,u.set(e,n);var v=j(f(e),f(n),a,i,o,u);return u.delete(e),v;case"[object Symbol]":if(w)return w.call(e)==w.call(n)}return!1}(o,u,k,s,v,b,p);if(!(1&s)){var D=O&&A.call(o,"__wrapped__"),E=x&&A.call(u,"__wrapped__");if(D||E){var U=D?o.value():o,C=E?u.value():u;return p||(p=new a),b(U,C,s,v,p)}}return!!B&&(p||(p=new a),function(r,n,t,a,i,o){var u=1&t,c=e(r),f=c.length;if(f!=e(n).length&&!u)return!1;for(var s=f;s--;){var v=c[s];if(!(u?v in n:d.call(n,v)))return!1}var b=o.get(r),j=o.get(n);if(b&&j)return b==n&&j==r;var _=!0;o.set(r,n),o.set(n,r);for(var l=u;++s<f;){var p=r[v=c[s]],w=n[v];if(a)var h=u?a(w,p,v,n,r,o):a(p,w,v,r,n,o);if(!(void 0===h?p===w||i(p,w,t,a,o):h)){_=!1;break}l||(l="constructor"==v)}if(_&&!l){var y=r.constructor,m=n.constructor;y==m||!("constructor"in r)||!("constructor"in n)||"function"==typeof y&&y instanceof y&&"function"==typeof m&&m instanceof m||(_=!1)}return o.delete(r),o.delete(n),_}(o,u,s,v,b,p))}(o,u,v,b,S,p))}export{S as b}
@@ -1 +1 @@
1
- import{g as r}from"./_Map.js";var t=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(r){}}();export{t as d}
1
+ import{g as r}from"./_MapCache.js";var t=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(r){}}();export{t as d}
@@ -1 +1 @@
1
- import{a as r,S as n}from"./_Map.js";import{i as t}from"./isSymbol.js";import{M as u}from"./_MapCache.js";function o(r,n){for(var t=-1,u=null==r?0:r.length,o=Array(u);++t<u;)o[t]=n(r[t],t,r);return o}var i=n?n.prototype:void 0,e=i?i.toString:void 0;function f(n){if("string"==typeof n)return n;if(r(n))return o(n,f)+"";if(t(n))return e?e.call(n):"";var u=n+"";return"0"==u&&1/n==-1/0?"-0":u}var a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,c=/^\w*$/;function s(n,u){if(r(n))return!1;var o=typeof n;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=n&&!t(n))||c.test(n)||!a.test(n)||null!=u&&n in Object(u)}function v(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var t=function(){var u=arguments,o=n?n.apply(this,u):u[0],i=t.cache;if(i.has(o))return i.get(o);var e=r.apply(this,u);return t.cache=i.set(o,e)||i,e};return t.cache=new(v.Cache||u),t}v.Cache=u;var l,p,d,m=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y=/\\(\\)?/g,b=(l=function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(m,(function(r,t,u,o){n.push(u?o.replace(y,"$1"):t||r)})),n},p=v(l,(function(r){return 500===d.size&&d.clear(),r})),d=p.cache,p);function g(r){return null==r?"":f(r)}function h(n,t){return r(n)?n:s(n,t)?[n]:b(g(n))}function j(r){if("string"==typeof r||t(r))return r;var n=r+"";return"0"==n&&1/r==-1/0?"-0":n}function w(r,n){for(var t=0,u=(n=h(n,r)).length;null!=r&&t<u;)r=r[j(n[t++])];return t&&t==u?r:void 0}function M(r,n,t){var u=null==r?void 0:w(r,n);return void 0===u?t:u}export{j as a,w as b,h as c,o as d,M as g,s as i,g as t}
1
+ import{a as r,S as n,M as t}from"./_MapCache.js";import{i as u}from"./isSymbol.js";function o(r,n){for(var t=-1,u=null==r?0:r.length,o=Array(u);++t<u;)o[t]=n(r[t],t,r);return o}var i=n?n.prototype:void 0,e=i?i.toString:void 0;function f(n){if("string"==typeof n)return n;if(r(n))return o(n,f)+"";if(u(n))return e?e.call(n):"";var t=n+"";return"0"==t&&1/n==-1/0?"-0":t}var a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,c=/^\w*$/;function s(n,t){if(r(n))return!1;var o=typeof n;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=n&&!u(n))||c.test(n)||!a.test(n)||null!=t&&n in Object(t)}function v(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var u=function(){var t=arguments,o=n?n.apply(this,t):t[0],i=u.cache;if(i.has(o))return i.get(o);var e=r.apply(this,t);return u.cache=i.set(o,e)||i,e};return u.cache=new(v.Cache||t),u}v.Cache=t;var l,p,d,y=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,m=/\\(\\)?/g,b=(l=function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(y,(function(r,t,u,o){n.push(u?o.replace(m,"$1"):t||r)})),n},p=v(l,(function(r){return 500===d.size&&d.clear(),r})),d=p.cache,p);function g(r){return null==r?"":f(r)}function h(n,t){return r(n)?n:s(n,t)?[n]:b(g(n))}function w(r){if("string"==typeof r||u(r))return r;var n=r+"";return"0"==n&&1/r==-1/0?"-0":n}function j(r,n){for(var t=0,u=(n=h(n,r)).length;null!=r&&t<u;)r=r[w(n[t++])];return t&&t==u?r:void 0}function $(r,n,t){var u=null==r?void 0:j(r,n);return void 0===u?t:u}export{w as a,j as b,h as c,o as d,$ as g,s as i,g as t}
@@ -1 +1 @@
1
- import{i as o,b as t}from"./_Map.js";function r(r){return"symbol"==typeof r||o(r)&&"[object Symbol]"==t(r)}export{r as i}
1
+ import{i as o,b as t}from"./_MapCache.js";function a(a){return"symbol"==typeof a||o(a)&&"[object Symbol]"==t(a)}export{a as i}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,h as i,transformTag as r}from"@stencil/core/internal/client";import{n as o,r as s,b as n,j as l,Z as a,X as u}from"./index.esm.js";import{i as h,a as c,b as f,c as d,g as p,d as v,e as g}from"./_getTag.js";import{a as m}from"./_Map.js";var b=Object.prototype.hasOwnProperty;class y{constructor(t){this.getState=t,this.contextType="info-tile"}getContext(){const{limetype:t,filterId:e,filterName:i,aggregateOperator:r,propertyName:o,value:s,label:n}=this.getState();if(!t||!e)return console.debug("InfoTileContextProvider: No limetype or filterId available"),null;const l={widgetType:"info-tile",limetype:t,filterId:e};return i&&(l.filterName=i),l.aggregateOperator=r,o&&(l.propertyName=o),void 0!==s&&(l.value=s),n&&(l.label=n),{data:l,purpose:"Shows an aggregated value from a filter. Clicking navigates to the explorer with that filter applied."}}}class w{constructor(t,e=[]){this.platform=t,this.filters=e}async load(t,e){let i;return i=this.isObjectIdentifier(e)?await this.loadLimeObjectInfoTile(t,e):await this.loadBasicInfoTile(t),i}async loadBasicInfoTile(t){const e=this.getFilter(t.filter);if(!e)throw Error(`Filter "${t.filter}" not found`);return(await this.query.execute({limetype:e.limetype,responseFormat:{aggregates:{infotiles:{value:{op:t.operator,key:t.name}}}},filter:e.filter})).aggregates.infotiles[0].value}async loadLimeObjectInfoTile(t,e){await this.objectRepository.loadObject(e.limetype,e.id,{properties:[t]});const i=this.objectRepository.getObject(e.limetype,e.id);return null==i?void 0:i.getValue([t.name,t.key].join("."))}isObjectIdentifier(t){return!(!(null==t?void 0:t.limetype)||!(null==t?void 0:t.id))}getFilter(t){return this.filters.find((e=>e.id===t))}get query(){return this.platform.get(o.Query)}get objectRepository(){return this.platform.get(o.LimeObjectRepository)}}class x{constructor(t){this.locale=t}format(t){let e=t+"";return"number"==typeof t?e=new Intl.NumberFormat(this.locale).format(t):new Date(t).getTime()&&(e=new Intl.DateTimeFormat(this.locale).format(new Date(t))),{value:e}}}class O{constructor(t){this.locale=t}format(t,e){const i=new Date(t);return{prefix:this.formatAffix("prefix",i,e),value:this.formatValue(i,e),suffix:this.formatAffix("suffix",i,e)}}formatValue(t,e){const i=Object.assign({},e.options);if(e.prefix)for(const t of e.prefix)delete i[t];if(e.suffix)for(const t of e.suffix)delete i[t];return new Intl.DateTimeFormat(this.locale,i).format(t)}formatAffix(t,e,i){const r=Object.assign({},i.options);for(const e of Object.keys(r))"hour12"!==e&&((i[t]||[]).includes(e)||delete r[e]);if(0!==Object.values(r).filter(Boolean).length)return new Intl.DateTimeFormat(this.locale,r).format(e)}}class j{constructor(t){this.locale=t}format(t,e){var i,r;const o=new Intl.NumberFormat(this.locale,e.options),s=o.formatToParts(t);let n="",l="",a="";for(const t of s)(null===(i=e.prefix)||void 0===i?void 0:i.includes(t.type))?n+=t.value:(null===(r=e.suffix)||void 0===r?void 0:r.includes(t.type))?a+=t.value:l+=t.value;return l||(l=o.format(t),n="",a=""),{prefix:n,value:l,suffix:a}}}class I{constructor(t){this.locale=t}format(t,e){const i=new Intl.RelativeTimeFormat(this.locale,e.options),{value:r,unit:o}=this.getRelativeTime(t),s=i.formatToParts(r,o);let n="",l="",a="";for(const t of s)"literal"!==t.type||l?"literal"===t.type&&l?a+=t.value:l+=t.value:n+=t.value;return l||(l=n||a,n="",a=""),{prefix:n,value:l,suffix:a}}getRelativeTime(t){const e=new Date(t),i=new Date,r=e.getTime()-i.getTime(),o=[{unit:"year",value:31536e6},{unit:"month",value:2592e6},{unit:"week",value:6048e5},{unit:"day",value:864e5},{unit:"hour",value:36e5},{unit:"minute",value:6e4},{unit:"second",value:1e3}];for(const t of o){const e=r/t.value;if(Math.abs(e)>=1)return{value:Math.round(e),unit:t.unit}}return{value:0,unit:"second"}}}class N{constructor(t){this.locale=t}createFormatter(t,e){return"number"===(null==t?void 0:t.type)&&"number"==typeof e?new j(this.locale):"date"===(null==t?void 0:t.type)&&"string"==typeof e?new O(this.locale):"relative-date"===(null==t?void 0:t.type)&&"string"==typeof e?new I(this.locale):new x(this.locale)}}var k=function(t,e,i,r){var o,s=arguments.length,n=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,r);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(n=(s<3?o(n):s>3?o(e,i,n):o(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n};const F=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.aggregateOperator=a.Count,this.loading=!1,this.error=!1}connectedCallback(){this.registerContextProvider()}disconnectedCallback(){var t;null===(t=this.unregisterContextProvider)||void 0===t||t.call(this)}componentWillLoad(){this.loadInfoTileValue()}watchFilterId(){this.loadInfoTileValue()}watchPropertyName(){this.loadInfoTileValue()}watchAggregateOperator(){this.loadInfoTileValue()}async loadInfoTileValue(){if(this.loading=!0,this.error=!1,this.getFilter()){try{const t={key:this.getKey(),name:this.propertyName,operator:this.aggregateOperator,filter:this.filterId};this.value=await this.loader.load(t,this.context)}catch(t){console.error(t),this.error=!0}this.loading=!1}else this.error=!0}getKey(){return Math.random().toString(36).slice(2)}render(){var t,e;const r=this.getFilter(),o=this.getFormattedValue(),s={disabled:this.disabled,icon:this.icon,prefix:(null===(t=null==o?void 0:o.prefix)||void 0===t?void 0:t.trim())||this.prefix,suffix:(null===(e=null==o?void 0:o.suffix)||void 0===e?void 0:e.trim())||this.suffix},n=Object.assign(Object.assign({},s),{icon:"error",prefix:"ERROR",loading:!0,label:this.getLabel(r)}),l=Object.assign(Object.assign({},s),{label:this.getLabel(r),link:this.getLink(r),loading:this.loading,value:null==o?void 0:o.value.trim()});return i("limel-info-tile",Object.assign({key:"163c9aa74b485cb28ae56735a9643dd7e6579465",class:{error:!r||this.error}},!r||this.error?n:l))}getFormattedValue(){if(!this.value&&0!==this.value)return{value:""};try{return this.getFormatter(this.value).format(this.value,this.format)}catch(t){return new x(this.language).format(this.value)}}getLabel(t){return t?"string"==typeof this.label?this.translator.get(this.label):this.getLocalizedString(this.label&&"object"==typeof this.label?this.label:t.name):"No filter set is selected"}getLocalizedString(t){if(function(t){if(null==t)return!0;if(h(t)&&(m(t)||"string"==typeof t||"function"==typeof t.splice||c(t)||f(t)||d(t)))return!t.length;var e=p(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(v(t))return!g(t).length;for(var i in t)if(b.call(t,i))return!1;return!0}(t))return"";let e=t[this.language];return e||(e=t.en||t.en_us||Object.values(null!=e?e:{}).find((t=>!!t))),null!=e?e:""}getLink(t){if(!t)return{href:"#"};const e=["explorer",t.limetype,t.id].join("/"),i=this.getRelationPropertyName(this.limetypes[t.limetype]),r=this.buildContextAwareFilter(t.filter,i);return r?{href:`${e}?filter=${encodeURIComponent(JSON.stringify(r))}`}:{href:e}}buildContextAwareFilter(t,e){if(!e)return t;const i={key:e,op:u.EQUALS,exp:this.context.id};return t?{op:u.AND,exp:[i,t]}:{relationFilter:i}}getFilter(){var t;return null===(t=this.filters)||void 0===t?void 0:t.find((t=>t.id===this.filterId))}getFormatter(t){return new N(this.language).createFormatter(this.format,t)}getRelationPropertyName(t){var e,i,r;if(t&&this.context.limetype&&this.context.id){if(this.propertyName){const t=this.limetypes[this.context.limetype],r=null===(i=null===(e=null==t?void 0:t.getProperty(this.propertyName))||void 0===e?void 0:e.relation)||void 0===i?void 0:i.getBackreference();if(r)return r.name}return null===(r=Object.values(t.properties).find((t=>{var e;return(null===(e=t.relation)||void 0===e?void 0:e.getLimetype().name)===this.context.limetype})))||void 0===r?void 0:r.name}}get translator(){return this.platform.get(o.Translate)}get language(){return this.platform.get(o.Application).getLanguage()}get loader(){return new w(this.platform,this.filters)}registerContextProvider(){const t=this.platform.get(o.AIContextRegistry);if(!(null==t?void 0:t.register))return;const e=new y((()=>{const t=this.getFilter();return{limetype:null==t?void 0:t.limetype,filterId:this.filterId,filterName:t?this.getLocalizedString(t.name):void 0,aggregateOperator:this.aggregateOperator,propertyName:this.propertyName,value:this.value,label:this.getLabel(t)}}));this.unregisterContextProvider=t.register(e,this.host)}get host(){return this}static get watchers(){return{filterId:[{watchFilterId:0}],propertyName:[{watchPropertyName:0}],aggregateOperator:[{watchAggregateOperator:0}]}}static get style(){return":host(limebb-info-tile){display:block;overflow:visible !important;background-color:transparent !important}limel-info-tile.error{--info-tile-icon-color:rgb(var(--color-red-dark));border:1px dashed rgb(var(--contrast-500));border-radius:var(--info-tile-border-radius, 1rem)}"}},[1,"limebb-info-tile",{platform:[16],context:[16],filterId:[513,"filter-id"],disabled:[4],icon:[513],label:[1],prefix:[1],suffix:[1],propertyName:[1,"property-name"],aggregateOperator:[1,"aggregate-operator"],format:[16],config:[32],filters:[32],value:[32],loading:[32],error:[32],limetypes:[32]},void 0,{filterId:[{watchFilterId:0}],propertyName:[{watchPropertyName:0}],aggregateOperator:[{watchAggregateOperator:0}]}]);k([s({})],F.prototype,"config",void 0),k([n()],F.prototype,"filters",void 0),k([l()],F.prototype,"limetypes",void 0);const R=F,C=function(){"undefined"!=typeof customElements&&["limebb-info-tile"].forEach((t=>{"limebb-info-tile"===t&&(customElements.get(r(t))||customElements.define(r(t),F))}))};export{R as LimebbInfoTile,C as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as e,h as i,transformTag as r}from"@stencil/core/internal/client";import{n as o,X as s,r as n,b as a,j as l,Z as h}from"./index.esm.js";import{a as c}from"./limetype.js";class u{constructor(t){this.getState=t,this.contextType="info-tile"}getContext(){const{limetype:t,filterId:e,filterName:i,aggregateOperator:r,propertyName:o,value:s,label:n}=this.getState();if(!t||!e)return console.debug("InfoTileContextProvider: No limetype or filterId available"),null;const a={widgetType:"info-tile",limetype:t,filterId:e};return i&&(a.filterName=i),a.aggregateOperator=r,o&&(a.propertyName=o),void 0!==s&&(a.value=s),n&&(a.label=n),{data:a,purpose:"Shows an aggregated value from a filter. Clicking navigates to the explorer with that filter applied."}}}class f{constructor(t,e=[]){this.platform=t,this.filters=e}async load(t,e){let i;return i=this.isObjectIdentifier(e)?await this.loadLimeObjectInfoTile(t,e):await this.loadBasicInfoTile(t),i}async loadBasicInfoTile(t){const e=this.getFilter(t.filter);if(!e)throw Error(`Filter "${t.filter}" not found`);return(await this.query.execute({limetype:e.limetype,responseFormat:{aggregates:{infotiles:{value:{op:t.operator,key:t.name}}}},filter:e.filter})).aggregates.infotiles[0].value}async loadLimeObjectInfoTile(t,e){await this.objectRepository.loadObject(e.limetype,e.id,{properties:[t]});const i=this.objectRepository.getObject(e.limetype,e.id);return null==i?void 0:i.getValue([t.name,t.key].join("."))}isObjectIdentifier(t){return!(!(null==t?void 0:t.limetype)||!(null==t?void 0:t.id))}getFilter(t){return this.filters.find((e=>e.id===t))}get query(){return this.platform.get(o.Query)}get objectRepository(){return this.platform.get(o.LimeObjectRepository)}}function d(t,e){return t&&(t[e]||t.en||t.en_us)||""}function p(t,e=[]){const{path:i,query:r}=function(t,e=[]){if(!t)return{path:"#"};const i=["explorer",t.limetype,t.id].join("/"),r=function(t,e){const i=[...e,t].filter((t=>void 0!==t));if(0!==i.length)return 1===i.length?i[0]:{op:s.AND,exp:i}}(t.filter,e);return r?{path:i,query:{filter:r}}:{path:i}}(t,e);return r?`${i}?${Object.entries(r).map((([t,e])=>`${t}=${encodeURIComponent(JSON.stringify(e))}`)).join("&")}`:i}class m{constructor(t){this.locale=t}format(t){let e=t+"";return"number"==typeof t?e=new Intl.NumberFormat(this.locale).format(t):new Date(t).getTime()&&(e=new Intl.DateTimeFormat(this.locale).format(new Date(t))),{value:e}}}class g{constructor(t){this.locale=t}format(t,e){const i=new Date(t);return{prefix:this.formatAffix("prefix",i,e),value:this.formatValue(i,e),suffix:this.formatAffix("suffix",i,e)}}formatValue(t,e){const i=Object.assign({},e.options);if(e.prefix)for(const t of e.prefix)delete i[t];if(e.suffix)for(const t of e.suffix)delete i[t];return new Intl.DateTimeFormat(this.locale,i).format(t)}formatAffix(t,e,i){const r=Object.assign({},i.options);for(const e of Object.keys(r))"hour12"!==e&&((i[t]||[]).includes(e)||delete r[e]);if(0!==Object.values(r).filter(Boolean).length)return new Intl.DateTimeFormat(this.locale,r).format(e)}}class v{constructor(t){this.locale=t}format(t,e){var i,r;const o=new Intl.NumberFormat(this.locale,e.options),s=o.formatToParts(t);let n="",a="",l="";for(const t of s)(null===(i=e.prefix)||void 0===i?void 0:i.includes(t.type))?n+=t.value:(null===(r=e.suffix)||void 0===r?void 0:r.includes(t.type))?l+=t.value:a+=t.value;return a||(a=o.format(t),n="",l=""),{prefix:n,value:a,suffix:l}}}class b{constructor(t){this.locale=t}format(t,e){const i=new Intl.RelativeTimeFormat(this.locale,e.options),{value:r,unit:o}=this.getRelativeTime(t),s=i.formatToParts(r,o);let n="",a="",l="";for(const t of s)"literal"!==t.type||a?"literal"===t.type&&a?l+=t.value:a+=t.value:n+=t.value;return a||(a=n||l,n="",l=""),{prefix:n,value:a,suffix:l}}getRelativeTime(t){const e=new Date(t),i=new Date,r=e.getTime()-i.getTime(),o=[{unit:"year",value:31536e6},{unit:"month",value:2592e6},{unit:"week",value:6048e5},{unit:"day",value:864e5},{unit:"hour",value:36e5},{unit:"minute",value:6e4},{unit:"second",value:1e3}];for(const t of o){const e=r/t.value;if(Math.abs(e)>=1)return{value:Math.round(e),unit:t.unit}}return{value:0,unit:"second"}}}class y{constructor(t){this.locale=t}createFormatter(t,e){return"number"===(null==t?void 0:t.type)&&"number"==typeof e?new v(this.locale):"date"===(null==t?void 0:t.type)&&"string"==typeof e?new g(this.locale):"relative-date"===(null==t?void 0:t.type)&&"string"==typeof e?new b(this.locale):new m(this.locale)}}var w=function(t,e,i,r){var o,s=arguments.length,n=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,i,n):o(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n};const x=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.aggregateOperator=h.Count,this.loading=!1,this.error=!1}connectedCallback(){this.registerContextProvider()}disconnectedCallback(){var t;null===(t=this.unregisterContextProvider)||void 0===t||t.call(this)}componentWillLoad(){this.loadInfoTileValue()}watchFilterId(){this.loadInfoTileValue()}watchPropertyName(){this.loadInfoTileValue()}watchAggregateOperator(){this.loadInfoTileValue()}async loadInfoTileValue(){if(this.loading=!0,this.error=!1,this.getFilter()){try{const t={key:this.getKey(),name:this.propertyName,operator:this.aggregateOperator,filter:this.filterId};this.value=await this.loader.load(t,this.context)}catch(t){console.error(t),this.error=!0}this.loading=!1}else this.error=!0}getKey(){return Math.random().toString(36).slice(2)}render(){var t,e;const r=this.getFilter(),o=this.getFormattedValue(),s={disabled:this.disabled,icon:this.icon,prefix:(null===(t=null==o?void 0:o.prefix)||void 0===t?void 0:t.trim())||this.prefix,suffix:(null===(e=null==o?void 0:o.suffix)||void 0===e?void 0:e.trim())||this.suffix},n=Object.assign(Object.assign({},s),{icon:"error",prefix:"ERROR",loading:!0,label:this.getLabel(r)}),a=Object.assign(Object.assign({},s),{label:this.getLabel(r),link:this.getLink(r),loading:this.loading,value:null==o?void 0:o.value.trim()});return i("limel-info-tile",Object.assign({key:"540d2ccbd5c4e3d09fb736e260b3ec5c02d42415",class:{error:!r||this.error}},!r||this.error?n:a))}getFormattedValue(){if(!this.value&&0!==this.value)return{value:""};try{return this.getFormatter(this.value).format(this.value,this.format)}catch(t){return new m(this.language).format(this.value)}}getLabel(t){return t?"string"==typeof this.label?this.translator.get(this.label):d(this.label&&"object"==typeof this.label?this.label:t.name,this.language):"No filter set is selected"}getLink(t){const e=c({targetLimetype:t?this.limetypes[t.limetype]:void 0,currentLimetype:this.context.limetype?this.limetypes[this.context.limetype]:void 0,contextLimetypeName:this.context.limetype,contextId:this.context.id,propertyName:this.propertyName});return{href:p(t,e&&this.context.id?[{key:e,op:s.EQUALS,exp:this.context.id}]:[])}}getFilter(){return function(t,e){if(t&&e)return t.find((t=>t.id===e))}(this.filters,this.filterId)}getFormatter(t){return new y(this.language).createFormatter(this.format,t)}get translator(){return this.platform.get(o.Translate)}get language(){return this.platform.get(o.Application).getLanguage()}get loader(){return new f(this.platform,this.filters)}registerContextProvider(){const t=this.platform.get(o.AIContextRegistry);if(!(null==t?void 0:t.register))return;const e=new u((()=>{const t=this.getFilter();return{limetype:null==t?void 0:t.limetype,filterId:this.filterId,filterName:t?d(t.name,this.language):void 0,aggregateOperator:this.aggregateOperator,propertyName:this.propertyName,value:this.value,label:this.getLabel(t)}}));this.unregisterContextProvider=t.register(e,this.host)}get host(){return this}static get watchers(){return{filterId:[{watchFilterId:0}],propertyName:[{watchPropertyName:0}],aggregateOperator:[{watchAggregateOperator:0}]}}static get style(){return":host(limebb-info-tile){display:block;overflow:visible !important;background-color:transparent !important}limel-info-tile.error{--info-tile-icon-color:rgb(var(--color-red-dark));border:1px dashed rgb(var(--contrast-500));border-radius:var(--info-tile-border-radius, 1rem)}"}},[1,"limebb-info-tile",{platform:[16],context:[16],filterId:[513,"filter-id"],disabled:[4],icon:[513],label:[1],prefix:[1],suffix:[1],propertyName:[1,"property-name"],aggregateOperator:[1,"aggregate-operator"],format:[16],config:[32],filters:[32],value:[32],loading:[32],error:[32],limetypes:[32]},void 0,{filterId:[{watchFilterId:0}],propertyName:[{watchPropertyName:0}],aggregateOperator:[{watchAggregateOperator:0}]}]);w([n({})],x.prototype,"config",void 0),w([a()],x.prototype,"filters",void 0),w([l()],x.prototype,"limetypes",void 0);const O=x,I=function(){"undefined"!=typeof customElements&&["limebb-info-tile"].forEach((t=>{"limebb-info-tile"===t&&(customElements.get(r(t))||customElements.define(r(t),x))}))};export{O as LimebbInfoTile,I as defineCustomElement}