@arcgis/common-components 4.29.0-beta.5 → 4.29.0-beta.51

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 (137) hide show
  1. package/README.md +1 -1
  2. package/dist/arcgis-common-components/arcgis-common-components.esm.js +1 -1
  3. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ar.json +78 -0
  4. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.bg.json +78 -0
  5. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.bs.json +78 -0
  6. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ca.json +78 -0
  7. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.cs.json +78 -0
  8. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.da.json +78 -0
  9. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.de.json +78 -0
  10. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.el.json +78 -0
  11. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.en.json +78 -0
  12. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.es.json +78 -0
  13. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.et.json +78 -0
  14. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.fi.json +78 -0
  15. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.fr.json +78 -0
  16. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.he.json +78 -0
  17. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.hr.json +78 -0
  18. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.hu.json +78 -0
  19. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.id.json +78 -0
  20. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.it.json +78 -0
  21. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ja.json +78 -0
  22. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ko.json +78 -0
  23. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.lt.json +78 -0
  24. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.lv.json +78 -0
  25. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.nb.json +78 -0
  26. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.nl.json +78 -0
  27. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pl.json +78 -0
  28. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pt-BR.json +78 -0
  29. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.pt-PT.json +78 -0
  30. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ro.json +78 -0
  31. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.ru.json +78 -0
  32. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sk.json +78 -0
  33. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sl.json +78 -0
  34. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sr.json +78 -0
  35. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.sv.json +78 -0
  36. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.th.json +78 -0
  37. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.tr.json +78 -0
  38. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.uk.json +78 -0
  39. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.vi.json +78 -0
  40. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-CN.json +78 -0
  41. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-HK.json +78 -0
  42. package/dist/arcgis-common-components/assets/field-info/t9n/field-info.t9n.zh-TW.json +78 -0
  43. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ar.json +17 -0
  44. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.bg.json +17 -0
  45. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.bs.json +17 -0
  46. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ca.json +17 -0
  47. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.cs.json +17 -0
  48. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.da.json +17 -0
  49. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.de.json +17 -0
  50. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.el.json +17 -0
  51. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.en.json +17 -0
  52. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.es.json +17 -0
  53. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.et.json +17 -0
  54. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.fi.json +17 -0
  55. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.fr.json +17 -0
  56. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.he.json +17 -0
  57. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.hr.json +17 -0
  58. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.hu.json +17 -0
  59. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.id.json +17 -0
  60. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.it.json +17 -0
  61. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ja.json +17 -0
  62. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ko.json +17 -0
  63. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.lt.json +17 -0
  64. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.lv.json +17 -0
  65. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.nb.json +17 -0
  66. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.nl.json +17 -0
  67. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pl.json +17 -0
  68. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pt-BR.json +17 -0
  69. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.pt-PT.json +17 -0
  70. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ro.json +17 -0
  71. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.ru.json +17 -0
  72. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sk.json +17 -0
  73. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sl.json +17 -0
  74. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sr.json +17 -0
  75. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.sv.json +17 -0
  76. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.th.json +17 -0
  77. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.tr.json +17 -0
  78. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.uk.json +17 -0
  79. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.vi.json +17 -0
  80. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-CN.json +17 -0
  81. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-HK.json +17 -0
  82. package/dist/arcgis-common-components/assets/field-pick-list/t9n/field-pick-list.t9n.zh-TW.json +17 -0
  83. package/dist/arcgis-common-components/p-6c7d2684.js +1 -0
  84. package/dist/arcgis-common-components/p-7318a1d1.entry.js +1 -0
  85. package/dist/arcgis-common-components/p-a91ab432.js +2 -0
  86. package/dist/arcgis-common-components/p-efab92a8.entry.js +1 -0
  87. package/dist/cjs/arcgis-common-components.cjs.js +3 -3
  88. package/dist/cjs/arcgis-field-info.cjs.entry.js +1025 -0
  89. package/dist/cjs/arcgis-field-pick-list.cjs.entry.js +245 -0
  90. package/dist/cjs/index-5ec7f592.js +90 -0
  91. package/dist/cjs/index-e0422bc8.js +1887 -0
  92. package/dist/cjs/loader.cjs.js +3 -12
  93. package/dist/components/{arcgis-api-key.d.ts → arcgis-field-info.d.ts} +4 -4
  94. package/dist/components/arcgis-field-info.js +6 -0
  95. package/dist/components/{arcgis-identity.d.ts → arcgis-field-pick-list.d.ts} +4 -4
  96. package/dist/components/arcgis-field-pick-list.js +301 -0
  97. package/dist/components/field-info.js +1108 -0
  98. package/dist/components/index.d.ts +5 -4
  99. package/dist/components/index.js +1 -3
  100. package/dist/esm/arcgis-common-components.js +4 -4
  101. package/dist/esm/arcgis-field-info.entry.js +1021 -0
  102. package/dist/esm/arcgis-field-pick-list.entry.js +241 -0
  103. package/dist/esm/index-0c129ec4.js +1856 -0
  104. package/dist/esm/index-ba4fe890.js +59 -0
  105. package/dist/esm/loader.js +4 -13
  106. package/dist/loader/index.d.ts +2 -2
  107. package/dist/types/components/field-info/field-info.d.ts +68 -0
  108. package/dist/types/components/field-info/t9n-types.d.ts +82 -0
  109. package/dist/types/components/field-info/utils/basic.d.ts +44 -0
  110. package/dist/types/components/field-info/utils/feature.d.ts +17 -0
  111. package/dist/types/components/field-info/utils/field.d.ts +25 -0
  112. package/dist/types/components/field-info/utils/index.d.ts +3 -0
  113. package/dist/types/components/field-pick-list/field-pick-list.d.ts +122 -0
  114. package/dist/types/components/field-pick-list/t9n-types.d.ts +17 -0
  115. package/dist/types/components/field-pick-list/utils/types.d.ts +25 -0
  116. package/dist/types/components.d.ts +258 -49
  117. package/dist/types/stencil-public-runtime.d.ts +61 -17
  118. package/package.json +24 -26
  119. package/dist/arcgis-common-components/p-3768a3bb.entry.js +0 -1
  120. package/dist/arcgis-common-components/p-84fccaad.entry.js +0 -1
  121. package/dist/arcgis-common-components/p-9625972e.js +0 -1
  122. package/dist/arcgis-common-components/p-b0c98bba.js +0 -2
  123. package/dist/cjs/arcgis-api-key.cjs.entry.js +0 -51
  124. package/dist/cjs/arcgis-identity.cjs.entry.js +0 -139
  125. package/dist/cjs/index-e8c59179.js +0 -858
  126. package/dist/cjs/index-f1a937af.js +0 -65
  127. package/dist/components/arcgis-api-key.js +0 -67
  128. package/dist/components/arcgis-identity.js +0 -165
  129. package/dist/components/index2.js +0 -40
  130. package/dist/esm/arcgis-api-key.entry.js +0 -47
  131. package/dist/esm/arcgis-identity.entry.js +0 -135
  132. package/dist/esm/index-1f7e8e45.js +0 -831
  133. package/dist/esm/index-71b437b1.js +0 -40
  134. package/dist/esm/polyfills/css-shim.js +0 -1
  135. package/dist/types/components/arcgis-api-key/arcgis-api-key.d.ts +0 -9
  136. package/dist/types/components/arcgis-identity/arcgis-identity.d.ts +0 -31
  137. package/dist/types/components/types.d.ts +0 -10
@@ -0,0 +1,1025 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-e0422bc8.js');
6
+ const index$1 = require('./index-5ec7f592.js');
7
+
8
+ var Status;
9
+ (function (Status) {
10
+ Status["MISSING"] = "missing";
11
+ Status["IN_PROGRESS"] = "inProgress";
12
+ Status["SUCCESS"] = "success";
13
+ Status["FAILED"] = "failed";
14
+ })(Status || (Status = {}));
15
+ var SimpleFieldTypes;
16
+ (function (SimpleFieldTypes) {
17
+ SimpleFieldTypes["NUMBER"] = "number";
18
+ SimpleFieldTypes["STRING"] = "string";
19
+ SimpleFieldTypes["DATE"] = "date";
20
+ SimpleFieldTypes["DATE_ONLY"] = "date-only";
21
+ SimpleFieldTypes["TIME_ONLY"] = "time-only";
22
+ SimpleFieldTypes["TIMESTAMP_OFFSET"] = "timestamp-offset";
23
+ SimpleFieldTypes["OID"] = "oid";
24
+ SimpleFieldTypes["GUID"] = "guid";
25
+ SimpleFieldTypes["UNKNOWN"] = "unknown";
26
+ })(SimpleFieldTypes || (SimpleFieldTypes = {}));
27
+ /**
28
+ * Returns true if the value is defined
29
+ * @param value - value to check
30
+ */
31
+ function isDefined(value) {
32
+ return value !== undefined && value !== null;
33
+ }
34
+ /**
35
+ * Returns the URL used for queries.
36
+ * E.g. SceneLayers need to use the FeatureLayer URL for queries.
37
+ * @param value - value to check
38
+ */
39
+ function getQueryURL(layer) {
40
+ if (layer.type === "scene") {
41
+ return layer.associatedLayer?.url;
42
+ }
43
+ return layer.url;
44
+ }
45
+
46
+ /**
47
+ * Returns additional field information from layer
48
+ * @param props - properties containing layer and fieldName
49
+ */
50
+ function getFieldInfo(props) {
51
+ const { layer, fieldName } = props;
52
+ let fieldInfo = undefined;
53
+ const { popupTemplate } = layer;
54
+ const popupFieldInfos = popupTemplate ? popupTemplate.fieldInfos : [];
55
+ (layer.type === "imagery-tile"
56
+ ? layer.rasterFields
57
+ : layer.type === "imagery" && layer.rasterFields?.length
58
+ ? layer.rasterFields
59
+ : layer.fields)
60
+ .filter((layerField) => layerField.name === fieldName)
61
+ .forEach((layerField) => {
62
+ const list = popupFieldInfos
63
+ ? popupFieldInfos.filter((fInfo) => fInfo.fieldName === layerField.name)
64
+ : null;
65
+ const label = list?.length ? list[0].label : null;
66
+ if (/^raster.(item|service)pixelvalue/iu.test(fieldName)) {
67
+ // e.g. "Raster.ServicePixelValue" | "Raster.ItemPixelValue" | "Raster.ServicePixelValue.Raw"
68
+ // layer.rasterFields reports them as type "string"
69
+ layerField.type = "double";
70
+ }
71
+ const featureFilterField = {
72
+ layerField,
73
+ label: label || layerField.alias || layerField.name
74
+ };
75
+ featureFilterField.codedValues = getCodedValues(fieldName, props);
76
+ _getSimpleFieldType(featureFilterField);
77
+ if (featureFilterField.simpleFieldType) {
78
+ fieldInfo = featureFilterField;
79
+ } // else can't use field
80
+ });
81
+ return fieldInfo;
82
+ }
83
+ /**
84
+ * Returns feature count in layer
85
+ * @param props - properties containing layer and fieldName
86
+ */
87
+ async function getFeatureCount(props) {
88
+ props.statisticsStatus = Status.IN_PROGRESS;
89
+ const { layer, view } = props;
90
+ if (layer.type === "imagery" || layer.type === "imagery-tile" || layer.type === "stream") {
91
+ throw new Error("could not get feature count");
92
+ }
93
+ try {
94
+ return await getFeatureCountCommon(layer, view);
95
+ }
96
+ catch {
97
+ return;
98
+ }
99
+ }
100
+ /**
101
+ * Returns summary statistics
102
+ * @param props - properties containing layer and fieldName
103
+ */
104
+ async function getStatistics(props) {
105
+ const { layer, view, fieldName, fieldInfo, modules } = props;
106
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
107
+ throw new Error("could not get statistics for ImageryLayer/ImageryTileLayer");
108
+ }
109
+ if (!fieldInfo ||
110
+ fieldInfo.layerField.type === "oid" ||
111
+ fieldInfo.layerField.type === "guid" ||
112
+ fieldInfo.layerField.type === "global-id") {
113
+ const count = await getFeatureCount(props);
114
+ return Promise.resolve({ totalCount: count, nullcount: 0 } /*StatisticsResult*/);
115
+ }
116
+ try {
117
+ const result = await modules.summaryStatistics({
118
+ layer,
119
+ view,
120
+ field: fieldName
121
+ });
122
+ if (!isDefined(result.count)) {
123
+ // statistics is unusable
124
+ throw new Error("could not get statistics");
125
+ }
126
+ // if we hit maxRecordCount other stats values are probably not correct either
127
+ const hitMaxRecordCount = "sourceJSON" in layer && layer.sourceJSON.maxRecordCount === result.count;
128
+ // count only contains features with a value (!= null)
129
+ if (isDefined(result.nullcount) && !hitMaxRecordCount) {
130
+ // we can add the feature count without null and the count of nulls
131
+ const stats /*StatisticsResult*/ = { ...result, totalCount: result.count + result.nullcount };
132
+ return stats;
133
+ }
134
+ else {
135
+ // we want the total feature count
136
+ // happens e.g. for SceneLayers with older stats cache
137
+ const count = await getFeatureCount(props);
138
+ const stats = { ...result, totalCount: count };
139
+ return stats;
140
+ }
141
+ }
142
+ catch (error) {
143
+ throw new Error("could not get statistics");
144
+ }
145
+ }
146
+ /**
147
+ * Returns unique values
148
+ * @param props - properties containing layer and fieldName
149
+ */
150
+ async function getUniqueValues(props) {
151
+ const { layer, view, fieldName, modules } = props;
152
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
153
+ throw new Error("could not get unique values for ImageryLayer/ImageryTileLayer");
154
+ }
155
+ if (layer.type === "feature" && !layer.url) {
156
+ layer.outFields = ["*"];
157
+ }
158
+ try {
159
+ const result = await modules.uniqueValues({
160
+ layer,
161
+ view,
162
+ field: fieldName
163
+ });
164
+ return result;
165
+ }
166
+ catch {
167
+ throw new Error("could not get unique values");
168
+ }
169
+ }
170
+ function _getSimpleFieldType(featureFilterField) {
171
+ switch (featureFilterField.layerField.type) {
172
+ case "string":
173
+ featureFilterField.simpleFieldType = SimpleFieldTypes.STRING;
174
+ break;
175
+ case "date":
176
+ featureFilterField.simpleFieldType = SimpleFieldTypes.DATE;
177
+ break;
178
+ case "timestamp-offset":
179
+ featureFilterField.simpleFieldType = SimpleFieldTypes.TIMESTAMP_OFFSET;
180
+ break;
181
+ case "date-only":
182
+ featureFilterField.simpleFieldType = SimpleFieldTypes.DATE_ONLY;
183
+ break;
184
+ case "time-only":
185
+ featureFilterField.simpleFieldType = SimpleFieldTypes.TIME_ONLY;
186
+ break;
187
+ case "oid":
188
+ featureFilterField.simpleFieldType = SimpleFieldTypes.OID;
189
+ break;
190
+ case "guid":
191
+ case "global-id":
192
+ featureFilterField.simpleFieldType = SimpleFieldTypes.GUID;
193
+ break;
194
+ case "small-integer":
195
+ case "big-integer":
196
+ case "integer":
197
+ case "single":
198
+ case "double":
199
+ case "long":
200
+ featureFilterField.simpleFieldType = SimpleFieldTypes.NUMBER;
201
+ break;
202
+ }
203
+ }
204
+ function getCodedValues(fieldName, props) {
205
+ const { layer, modules } = props;
206
+ if (layer.type !== "feature") {
207
+ return;
208
+ }
209
+ const typeIdField = layer.typeIdField;
210
+ const types = layer.types;
211
+ let fieldDomains = undefined;
212
+ const field = layer.fields.find((field) => field.name === fieldName);
213
+ const fieldDomain = field.domain;
214
+ if (typeIdField && types) {
215
+ // layer has types
216
+ if (typeIdField === fieldName) {
217
+ // this is the field with the types
218
+ fieldDomains = types.map((type) =>
219
+ // fake coded Values
220
+ ({
221
+ code: type.id,
222
+ name: type.name
223
+ }));
224
+ }
225
+ else {
226
+ // field does not have types; look farther inside the types
227
+ fieldDomains = [];
228
+ types.forEach((type) => {
229
+ if (!type.domains || !type.domains[fieldName] || type.domains[fieldName].type === "inherited") {
230
+ const domain = fieldDomain;
231
+ if (domain?.codedValues) {
232
+ domain.codedValues.forEach(async (codedValue) => {
233
+ let found = false;
234
+ fieldDomains.forEach((codedVal) => {
235
+ if (codedVal.code === codedValue.code) {
236
+ found = true;
237
+ if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
238
+ codedVal.name += `, ${codedValue.name}`;
239
+ }
240
+ }
241
+ });
242
+ if (!found) {
243
+ fieldDomains.push(modules.esriLang.clone(codedValue));
244
+ }
245
+ });
246
+ }
247
+ }
248
+ else if (type.domains?.[fieldName]?.codedValues) {
249
+ type.domains[fieldName].codedValues.forEach(async (codedValue) => {
250
+ let found = false;
251
+ fieldDomains.forEach((codedVal) => {
252
+ if (codedVal.code === codedValue.code) {
253
+ found = true;
254
+ if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
255
+ codedVal.name += `, ${codedValue.name}`;
256
+ }
257
+ }
258
+ });
259
+ if (!found) {
260
+ fieldDomains.push(modules.esriLang.clone(codedValue));
261
+ }
262
+ });
263
+ }
264
+ });
265
+ }
266
+ if (!fieldDomains?.length && fieldDomain?.codedValues) {
267
+ fieldDomains = modules.esriLang.clone(fieldDomain.codedValues);
268
+ }
269
+ }
270
+ else if (fieldDomain?.codedValues) {
271
+ // domains directly on the layer field
272
+ fieldDomains = field.domain.codedValues;
273
+ }
274
+ return fieldDomains?.length ? fieldDomains : null;
275
+ }
276
+
277
+ /**
278
+ * Returns up to 5 features from the layer to get sample data
279
+ * @param props - properties containing layer and view
280
+ */
281
+ async function getOneFeature(props) {
282
+ const { view, layer } = props;
283
+ if (layer.type === "imagery" || layer.type === "imagery-tile") {
284
+ throw new Error("could not get feature");
285
+ }
286
+ if ((layer.type === "feature" && !layer.url) || layer.type === "wfs") {
287
+ // feature collection or wfs
288
+ const query = layer.createQuery();
289
+ query.start = 0;
290
+ query.num = 5;
291
+ query.outFields = ["*"];
292
+ const result = await layer.queryFeatures(query);
293
+ if (result.features?.length) {
294
+ return result;
295
+ }
296
+ else {
297
+ throw new Error("could not get feature");
298
+ }
299
+ }
300
+ else {
301
+ // service
302
+ if (!view) {
303
+ // get feature from service directly
304
+ return _queryOneFeature(props);
305
+ }
306
+ const layerView = (await view.whenLayerView(layer));
307
+ const hasAllFields = layerView.availableFields.length === layer.fields.length;
308
+ if (hasAllFields || (["stream", "ogc-feature"].indexOf(layer.type) > -1 && layerView.availableFields.length > 0)) {
309
+ // features on client have all fields
310
+ // or we can't make a server query, so we take what we can get
311
+ const query = layer.createQuery();
312
+ query.start = 0;
313
+ query.num = 5;
314
+ query.outFields = ["*"];
315
+ const result = await layerView.queryFeatures(query);
316
+ if (result.features?.length) {
317
+ // client side features
318
+ return result;
319
+ }
320
+ else {
321
+ // get feature from service
322
+ return _queryOneFeature(props);
323
+ }
324
+ }
325
+ else {
326
+ // get feature from service
327
+ return _queryOneFeature(props);
328
+ }
329
+ }
330
+ }
331
+ async function _queryOneFeature(props) {
332
+ const { layer, modules } = props;
333
+ if (["imagery", "imagery-tile", "stream", "ogc-feature"].indexOf(layer.type) > -1) {
334
+ throw new Error("cannot get feature from service");
335
+ }
336
+ const query = new modules.Query({
337
+ where: "1=1",
338
+ outFields: ["*"],
339
+ returnGeometry: false
340
+ });
341
+ return layer.queryFeatures(query);
342
+ }
343
+ /**
344
+ * Returns feature count of layer
345
+ * @param layer - FeatureLayer | WFSLayer | OGCFeatureLayer | StreamLayer | CSVLayer
346
+ * @param mapView - View
347
+ */
348
+ async function getFeatureCountCommon(layer, view) {
349
+ if (layer.type === "feature" && !layer.url) {
350
+ return getFeatureCountForCollection(layer);
351
+ }
352
+ else if (layer.type === "feature" ||
353
+ layer.type === "csv" ||
354
+ layer.type === "scene" ||
355
+ layer.type === "wfs" ||
356
+ layer.type === "geojson") {
357
+ return await layer.queryFeatureCount();
358
+ }
359
+ else if (view && (layer.type === "stream" || layer.type === "ogc-feature")) {
360
+ return getFeatureCountFromView(layer, view);
361
+ }
362
+ return undefined;
363
+ }
364
+ /**
365
+ * Returns feature count of feature collection layer
366
+ * @param layer - FeatureLayer
367
+ */
368
+ async function getFeatureCountForCollection(layer) {
369
+ const query = layer.createQuery();
370
+ query.outFields = ["*"];
371
+ const result = await layer.queryFeatures(query);
372
+ if (result.features?.length) {
373
+ return result.features.length;
374
+ }
375
+ else {
376
+ throw new Error("could not get feature count");
377
+ }
378
+ }
379
+ /**
380
+ * Returns feature count of feature collection layer
381
+ * @param layer - StreamLayer | OGCFeatureLayer
382
+ */
383
+ async function getFeatureCountFromView(layer, view) {
384
+ // we can only get the features from the map
385
+ const layerView = (await view.whenLayerView(layer));
386
+ return layerView.queryFeatureCount();
387
+ }
388
+
389
+ const fieldInfoScss = ":host{height:100%}.container{padding:6px;background-color:white}.title{font-weight:bold;padding:5px 0}.missing{color:#a9a9a9}.data{color:#a9a9a9}.count{white-space:nowrap}.section{padding:6px 0}.statistics-row{border-top:1px solid #e0e0e0;padding:6px 0;display:flex;justify-content:space-between}.statistics-row-top-values{border-top:1px solid #e0e0e0;padding:20px 0 6px 0;display:flex;justify-content:space-between}";
390
+
391
+ const ArcgisFieldInfo = class {
392
+ constructor(hostRef) {
393
+ index.registerInstance(this, hostRef);
394
+ this.arcgisFieldInfoComplete = index.createEvent(this, "arcgisFieldInfoComplete", 7);
395
+ this.view = undefined;
396
+ this.layer = undefined;
397
+ this.fieldName = undefined;
398
+ this.hideStatistics = false;
399
+ this.oneFeatureResponse = undefined;
400
+ this.oneFeatureResponseStatus = Status.MISSING;
401
+ this.statistics = undefined;
402
+ this.statisticsStatus = Status.MISSING;
403
+ this.uniqueValues = undefined;
404
+ this.uniqueValuesStatus = Status.MISSING;
405
+ this._lang = "";
406
+ this._t9nLocale = "";
407
+ this._t9nStrings = undefined;
408
+ }
409
+ //--------------------------------------------------------------------------
410
+ //
411
+ // Lifecycle
412
+ //
413
+ //--------------------------------------------------------------------------
414
+ async componentWillLoad() {
415
+ await index$1.F(this, index.getAssetPath("./assets"));
416
+ const esriLang = await index$1.importCoreLang();
417
+ const esriConfig = await index$1.importConfig();
418
+ const intl = await index$1.importIntl();
419
+ const Query = await index$1.importRestSupportQuery();
420
+ const summaryStatistics = await index$1.importSmartMappingStatisticsSummaryStatistics();
421
+ const uniqueValues = await index$1.importSmartMappingStatisticsUniqueValues();
422
+ const { view, layer, fieldName, hideStatistics } = this;
423
+ let sublayerFL;
424
+ if (layer.declaredClass === "esri.layers.support.Sublayer") {
425
+ // need to create a FeatureLayer
426
+ const sublayer = layer;
427
+ const { whenOnce } = await index$1.importCoreReactiveUtils();
428
+ if (view)
429
+ await whenOnce(() => !view.updating);
430
+ sublayerFL = await sublayer.createFeatureLayer();
431
+ await sublayerFL.load();
432
+ }
433
+ this.props = {
434
+ view,
435
+ layer: sublayerFL || layer,
436
+ fieldName,
437
+ hideStatistics,
438
+ modules: { esriLang, esriConfig, intl, Query, summaryStatistics, uniqueValues }
439
+ };
440
+ // required for initial load
441
+ this.props.fieldInfo = getFieldInfo(this.props);
442
+ // we don't know if the SceneLayer has an associated FL
443
+ // don't prompt for a login if it's not accessible
444
+ if (layer.type === "scene") {
445
+ esriConfig.request.interceptors?.push({
446
+ urls: `${getQueryURL(layer)}/${layer.layerId}`,
447
+ before(params) {
448
+ params.requestOptions.authMode = "no-prompt";
449
+ }
450
+ });
451
+ }
452
+ this.oneFeatureResponseStatus = Status.IN_PROGRESS;
453
+ try {
454
+ const result = await getOneFeature(this.props);
455
+ this.oneFeatureResponse = result;
456
+ this.oneFeatureResponseStatus = Status.SUCCESS;
457
+ }
458
+ catch {
459
+ this.oneFeatureResponseStatus = Status.FAILED;
460
+ }
461
+ if (layer.type === "stream") {
462
+ this.uniqueValuesStatus = Status.FAILED;
463
+ this.statisticsStatus = Status.FAILED;
464
+ return;
465
+ }
466
+ if (hideStatistics) {
467
+ this.uniqueValuesStatus = Status.FAILED;
468
+ }
469
+ else {
470
+ this.uniqueValuesStatus = Status.IN_PROGRESS;
471
+ try {
472
+ const uniqueValues = await getUniqueValues(this.props);
473
+ this.uniqueValues = uniqueValues;
474
+ if (uniqueValues?.uniqueValueInfos?.length) {
475
+ this.uniqueValuesStatus = Status.SUCCESS;
476
+ }
477
+ else {
478
+ this.uniqueValuesStatus = Status.FAILED;
479
+ }
480
+ }
481
+ catch (error) {
482
+ this.uniqueValuesStatus = Status.FAILED;
483
+ }
484
+ }
485
+ if (hideStatistics) {
486
+ this.statisticsStatus = Status.FAILED;
487
+ }
488
+ else {
489
+ this.statisticsStatus = Status.IN_PROGRESS;
490
+ try {
491
+ const statistics = await getStatistics(this.props);
492
+ if (!isDefined(statistics.totalCount) &&
493
+ isDefined(statistics.count) &&
494
+ this.uniqueValuesStatus === Status.SUCCESS) {
495
+ // take null values count from unique values and add with non-null count from statistics
496
+ const infos = this.uniqueValues.uniqueValueInfos;
497
+ for (let i = 0; i < infos.length; i += 1) {
498
+ const info = infos[i];
499
+ if (info.value === null) {
500
+ statistics.totalCount = info.count + statistics.count;
501
+ break;
502
+ }
503
+ }
504
+ if (!isDefined(statistics.totalCount)) {
505
+ // no null values
506
+ statistics.totalCount = statistics.count;
507
+ }
508
+ }
509
+ this.statistics = statistics;
510
+ this.statisticsStatus = Status.SUCCESS;
511
+ }
512
+ catch {
513
+ this.statisticsStatus = Status.FAILED;
514
+ }
515
+ }
516
+ }
517
+ async componentDidLoad() {
518
+ // once component is visible make other calls
519
+ const { props } = this;
520
+ const { modules } = props;
521
+ modules.intl.setLocale(this._lang);
522
+ // modules.intl.setLocale(this.locale) not returning the correct formatting for e.g. it-ch
523
+ }
524
+ disconnectedCallback() {
525
+ index$1.U(this);
526
+ }
527
+ // --------------------------------------------------------------------------
528
+ //
529
+ // Render Methods
530
+ //
531
+ //--------------------------------------------------------------------------
532
+ render() {
533
+ const { props } = this;
534
+ const { fieldInfo } = props;
535
+ if (!fieldInfo) {
536
+ return index.h(index.Fragment, null);
537
+ }
538
+ return (index.h(index.Host, null, index.h("div", { class: "container" }, this.renderFieldType(), this.renderFieldAlias(), this.renderFieldDescription(), this.renderFieldValueType(), this.renderFieldSampleValue(), this.renderFieldFormat(), this.renderFieldStatistics())));
539
+ }
540
+ renderFieldType() {
541
+ const { _t9nStrings, props } = this;
542
+ const { fieldInfo } = props;
543
+ const fieldType = this._getFieldTypeLabel(fieldInfo.layerField.type);
544
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldType), index.h("div", null, fieldType)));
545
+ }
546
+ renderFieldAlias() {
547
+ const { _t9nStrings, props } = this;
548
+ const { fieldInfo } = props;
549
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldAlias), index.h("div", null, fieldInfo.label)));
550
+ }
551
+ renderFieldDescription() {
552
+ const { _t9nStrings, props } = this;
553
+ const { layer } = props;
554
+ if (layer.type !== "feature") {
555
+ return index.h(index.Fragment, null);
556
+ }
557
+ const { fieldInfo } = props;
558
+ const description = fieldInfo.layerField.description;
559
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldDescription), index.h("div", { class: {
560
+ missing: !description
561
+ } }, description || _t9nStrings.fieldDescriptionNotSet)));
562
+ }
563
+ renderFieldValueType() {
564
+ const { _t9nStrings, props } = this;
565
+ const { layer } = props;
566
+ if (layer.type !== "feature") {
567
+ return index.h(index.Fragment, null);
568
+ }
569
+ const { fieldInfo } = props;
570
+ const fieldValueType = this._getFieldValueTypeCamelCase(fieldInfo);
571
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldValueType), index.h("div", { class: !fieldValueType ? "missing" : "" }, fieldValueType
572
+ ? _t9nStrings.fieldValueTypes[fieldValueType]
573
+ : _t9nStrings.fieldValueTypeNotSet)));
574
+ }
575
+ renderFieldSampleValue() {
576
+ const { oneFeatureResponse, oneFeatureResponseStatus, statisticsStatus, statistics, uniqueValuesStatus, uniqueValues, _t9nStrings, props } = this;
577
+ const { layer, fieldName, fieldInfo } = props;
578
+ const { statistics: statStrings } = _t9nStrings;
579
+ let value;
580
+ if (["imagery", "imagery-tile"].indexOf(layer.type) > -1) {
581
+ return index.h(index.Fragment, null);
582
+ }
583
+ if (layer.type !== "stream" &&
584
+ [SimpleFieldTypes.STRING, SimpleFieldTypes.OID, SimpleFieldTypes.GUID].indexOf(this._getStatisticsType(fieldInfo)) > -1 &&
585
+ uniqueValuesStatus !== Status.FAILED) {
586
+ // we show top values
587
+ return index.h(index.Fragment, null);
588
+ }
589
+ if (oneFeatureResponseStatus === Status.SUCCESS) {
590
+ // find first valid value entry
591
+ oneFeatureResponse.features.forEach((feature) => {
592
+ if (value === undefined || (value === null && feature.attributes[fieldName] !== null)) {
593
+ value = feature.attributes[fieldName];
594
+ }
595
+ });
596
+ }
597
+ else if (statisticsStatus === Status.SUCCESS) {
598
+ // use statistics min value
599
+ value = statistics.min;
600
+ }
601
+ else if (uniqueValuesStatus === Status.SUCCESS) {
602
+ // use a non-null value
603
+ value = uniqueValues.uniqueValueInfos?.[0]?.value || uniqueValues.uniqueValueInfos?.[1]?.value;
604
+ }
605
+ const codedValues = fieldInfo.codedValues;
606
+ if (isDefined(value)) {
607
+ if (codedValues) {
608
+ value = codedValues.find((codedValue) => value === codedValue.code)?.name || value;
609
+ }
610
+ else {
611
+ value = this._getDisplayString(value);
612
+ }
613
+ }
614
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldSampleValue), index.h("div", { class: (oneFeatureResponseStatus === Status.FAILED &&
615
+ statisticsStatus === Status.FAILED &&
616
+ uniqueValuesStatus === Status.FAILED) ||
617
+ !isDefined(value)
618
+ ? "missing"
619
+ : "" }, oneFeatureResponseStatus === Status.SUCCESS ||
620
+ statisticsStatus === Status.SUCCESS ||
621
+ uniqueValuesStatus === Status.SUCCESS
622
+ ? !isDefined(value)
623
+ ? statStrings.allNulls
624
+ : `${value}`
625
+ : oneFeatureResponseStatus === Status.FAILED &&
626
+ statisticsStatus === Status.FAILED &&
627
+ uniqueValuesStatus === Status.FAILED
628
+ ? _t9nStrings.fieldSampleNotAvailable
629
+ : _t9nStrings.fieldSampleRetrieving)));
630
+ }
631
+ renderFieldFormat() {
632
+ const { _t9nStrings, props } = this;
633
+ const { fieldName, fieldInfo, layer } = props;
634
+ if (["single", "double", "long"].indexOf(fieldInfo.layerField.type) === -1) {
635
+ return index.h(index.Fragment, null);
636
+ }
637
+ const popupTemplate = layer.popupTemplate;
638
+ if (popupTemplate?.fieldInfos) {
639
+ const popFieldInfos = popupTemplate.fieldInfos?.filter((fieldInfo) => fieldInfo.fieldName === fieldName);
640
+ if (popFieldInfos?.length) {
641
+ const popFieldInfo = popFieldInfos[0];
642
+ if (isDefined(popFieldInfo?.format?.places)) {
643
+ const num = popFieldInfo.format.places;
644
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), index.h("div", null,
645
+ // eslint-disable-next-line no-template-curly-in-string
646
+ _t9nStrings.fieldNumDecimalPlaces.replace("${number}", num.toString()))));
647
+ }
648
+ }
649
+ }
650
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), index.h("div", { class: "missing" }, _t9nStrings.fieldDecimalPlacesNotAvailable)));
651
+ }
652
+ renderFieldStatistics() {
653
+ const { statisticsStatus, uniqueValuesStatus, hideStatistics, _t9nStrings, props } = this;
654
+ const { layer, fieldInfo } = props;
655
+ if (hideStatistics) {
656
+ this.arcgisFieldInfoComplete.emit();
657
+ return index.h(index.Fragment, null);
658
+ }
659
+ if (["stream", "imagery", "imagery-tile"].indexOf(layer.type) > -1 ||
660
+ ["long"].indexOf(fieldInfo.layerField.type) > -1) {
661
+ // can't get statistics
662
+ this.arcgisFieldInfoComplete.emit();
663
+ return index.h(index.Fragment, null);
664
+ }
665
+ return (index.h("div", { class: "section" }, index.h("div", { class: "title" }, _t9nStrings.fieldStatistics), !statisticsStatus || statisticsStatus === Status.MISSING || statisticsStatus === Status.IN_PROGRESS ? (index.h("div", { key: "field-info-statistics-content", class: "missing" }, _t9nStrings.fieldStatisticsRetrieving)) : statisticsStatus === Status.FAILED && uniqueValuesStatus !== Status.SUCCESS ? (this.renderNoStatistics()) : (index.h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit() }, this.renderStatistics()))));
666
+ }
667
+ renderNoStatistics() {
668
+ const { _t9nStrings } = this;
669
+ return (index.h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit(), class: "missing" }, _t9nStrings.fieldStatisticsNotAvailable));
670
+ }
671
+ renderStatistics() {
672
+ const { props } = this;
673
+ const { fieldInfo } = props;
674
+ switch (this._getStatisticsType(fieldInfo)) {
675
+ case SimpleFieldTypes.NUMBER:
676
+ return this.renderNumberStatistics();
677
+ case SimpleFieldTypes.STRING:
678
+ case SimpleFieldTypes.OID:
679
+ case SimpleFieldTypes.GUID:
680
+ return this.renderStringStatistics();
681
+ case SimpleFieldTypes.DATE:
682
+ case SimpleFieldTypes.DATE_ONLY:
683
+ case SimpleFieldTypes.TIME_ONLY:
684
+ case SimpleFieldTypes.TIMESTAMP_OFFSET:
685
+ return this.renderDateStatistics();
686
+ default:
687
+ return index.h(index.Fragment, null);
688
+ }
689
+ }
690
+ renderNumberStatistics() {
691
+ const { statistics, _t9nStrings } = this;
692
+ if (!statistics) {
693
+ return this.renderNoStatistics();
694
+ }
695
+ const { statistics: statStrings } = _t9nStrings;
696
+ return (index.h("div", null, index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.numberOfValues), index.h("div", { class: "data" }, this._printNumValue(statistics.totalCount))), isDefined(statistics.sum) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.sumOfValues), index.h("div", { class: "data" }, this._printNumValue(statistics.sum)))) : null, isDefined(statistics.min) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.minimum), index.h("div", { class: "data" }, this._printNumValue(statistics.min)))) : null, isDefined(statistics.max) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.maximum), index.h("div", { class: "data" }, this._printNumValue(statistics.max)))) : null, isDefined(statistics.avg) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.average), index.h("div", { class: "data" }, this._printNumValue(statistics.avg)))) : null, isDefined(statistics.stddev) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.standardDeviation), index.h("div", { class: "data" }, this._printNumValue(statistics.stddev)))) : null, this.renderNullValues()));
697
+ }
698
+ renderStringStatistics() {
699
+ const { statistics, uniqueValuesStatus, _t9nStrings } = this;
700
+ const { statistics: statStrings } = _t9nStrings;
701
+ return (index.h("div", null, index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.numberOfValues), uniqueValuesStatus !== Status.SUCCESS ? (index.h("div", { class: "missing" }, "--")) : (index.h("div", { class: "data" }, this._printNumValue(statistics?.totalCount)))), this.renderNullValues(), this.renderTopValues()));
702
+ }
703
+ renderDateStatistics() {
704
+ // TODO UTC offset
705
+ const { statistics, view, props, _t9nStrings } = this;
706
+ const { fieldInfo } = props;
707
+ if (!statistics) {
708
+ return this.renderNoStatistics();
709
+ }
710
+ const { statistics: statStrings } = _t9nStrings;
711
+ const dateRange = statistics.max - statistics.min;
712
+ const years = Math.floor(dateRange / 31536000000);
713
+ let months = Math.floor((dateRange - years * 31536000000) / 2628000000);
714
+ let days = Math.ceil((dateRange - months * 2628000000) / 86400000);
715
+ if (days >= 30) {
716
+ months += 1;
717
+ days = 0;
718
+ }
719
+ let timeSpan = years === 1
720
+ ? statStrings.timeSpanOptions.year
721
+ : years > 1
722
+ ? // eslint-disable-next-line no-template-curly-in-string
723
+ statStrings.timeSpanOptions.years.replace("${years}", years.toString())
724
+ : "";
725
+ timeSpan += years > 0 && (months > 0 || days > 0) ? ", " : "";
726
+ timeSpan +=
727
+ months === 1
728
+ ? statStrings.timeSpanOptions.month
729
+ : months > 1
730
+ ? // eslint-disable-next-line no-template-curly-in-string
731
+ statStrings.timeSpanOptions.months.replace("${months}", months.toString())
732
+ : "";
733
+ timeSpan += months > 0 && days > 0 ? ", " : "";
734
+ timeSpan +=
735
+ days === 1
736
+ ? statStrings.timeSpanOptions.day
737
+ : days > 1
738
+ ? // eslint-disable-next-line no-template-curly-in-string
739
+ statStrings.timeSpanOptions.days.replace("${days}", days.toString())
740
+ : "";
741
+ const showStats = fieldInfo.simpleFieldType !== SimpleFieldTypes.TIMESTAMP_OFFSET ||
742
+ !view ||
743
+ view.timeZone !== "unknown";
744
+ const isTimeOnly = fieldInfo.simpleFieldType === SimpleFieldTypes.TIME_ONLY;
745
+ return (index.h("div", null, index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.numberOfValues), index.h("div", { class: "data" }, this._printNumValue(statistics?.totalCount))), showStats && isDefined(statistics.min) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, isTimeOnly ? statStrings.minimumTime : statStrings.minimumDate), index.h("div", { class: "data" }, `${this._getDisplayString(statistics.min)}`))) : null, showStats && isDefined(statistics.max) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, isTimeOnly ? statStrings.maximumTime : statStrings.maximumDate), index.h("div", { class: "data" }, `${this._getDisplayString(statistics.max)}`))) : null, showStats && isDefined(statistics.avg) ? (index.h("div", { class: "statistics-row" }, index.h("div", null, isTimeOnly ? statStrings.averageTime : statStrings.averageDate), index.h("div", { class: "data" }, `${this._getDisplayString(statistics.avg)}`))) : null, showStats && !isTimeOnly && isDefined(statistics.min) && isDefined(statistics.max) && dateRange > 0 ? (index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.timespan), index.h("div", { class: "data" }, timeSpan))) : null, this.renderNullValues()));
746
+ }
747
+ renderTopValues() {
748
+ const { uniqueValues, uniqueValuesStatus, _t9nStrings, props } = this;
749
+ const { fieldInfo } = props;
750
+ const { statistics: statStrings } = _t9nStrings;
751
+ if (uniqueValues?.uniqueValueInfos?.length) {
752
+ const infos = uniqueValues.uniqueValueInfos;
753
+ infos.sort((a, b) => (a.count < b.count ? 1 : a.count > b.count ? -1 : 0));
754
+ const codedValues = fieldInfo.codedValues;
755
+ const values = infos
756
+ .filter((info) => info.value !== null)
757
+ .filter((info, idx) => info && idx < 10)
758
+ .map((info) => {
759
+ let value = info.value;
760
+ if (codedValues) {
761
+ codedValues.forEach((codeValue) => {
762
+ if (value === codeValue.code) {
763
+ value = codeValue.name;
764
+ }
765
+ });
766
+ }
767
+ else {
768
+ value = this._getDisplayString(value);
769
+ }
770
+ return (index.h("div", { class: "statistics-row" }, index.h("div", { class: "data" }, `${value}`), index.h("div", { class: `$"data" $"count"` }, this._printNumValue(info.count))));
771
+ });
772
+ if (!values.length) {
773
+ return index.h(index.Fragment, null);
774
+ }
775
+ return (index.h("div", null, index.h("div", { class: "statistics-row-top-values" }, index.h("div", null, infos.length > 10 ? statStrings.topTenValues : statStrings.topValues), index.h("div", null, statStrings.count)), values));
776
+ }
777
+ else {
778
+ return (index.h("div", null, index.h("div", { class: "statistics-row-top-values" }, index.h("div", null, statStrings.topValues), index.h("div", null, statStrings.count)), index.h("div", { class: "statistics-row" }, index.h("div", { class: "missing" }, uniqueValuesStatus === Status.FAILED
779
+ ? _t9nStrings.fieldUniqueValuesNotAvailable
780
+ : _t9nStrings.fieldSampleRetrieving))));
781
+ }
782
+ }
783
+ renderNullValues() {
784
+ const { statistics, uniqueValues, _t9nStrings } = this;
785
+ const { statistics: statStrings } = _t9nStrings;
786
+ let count = statistics?.nullcount;
787
+ if (!isDefined(count) && uniqueValues) {
788
+ const infos = uniqueValues.uniqueValueInfos;
789
+ for (let i = 0; i < infos.length; i += 1) {
790
+ const info = infos[i];
791
+ if (info.value === null) {
792
+ count = info.count;
793
+ break;
794
+ }
795
+ }
796
+ }
797
+ return (index.h("div", { class: "statistics-row" }, index.h("div", null, statStrings.numberOfNulls), !isDefined(count) ? (index.h("div", { class: "missing" }, "--")) : (index.h("div", { class: "data" }, `${Number.parseInt(count).toLocaleString()}`))));
798
+ }
799
+ // --------------------------------------------------------------------------
800
+ //
801
+ // Private methods
802
+ //
803
+ // --------------------------------------------------------------------------
804
+ _getFieldTypeLabel(fieldType) {
805
+ const { _t9nStrings } = this;
806
+ const fieldTypes = _t9nStrings.fieldTypes;
807
+ switch (fieldType) {
808
+ case "small-integer":
809
+ return fieldTypes.smallInteger;
810
+ case "big-integer":
811
+ return fieldTypes.bigInteger;
812
+ case "integer":
813
+ return fieldTypes.integer;
814
+ case "single":
815
+ return fieldTypes.single;
816
+ case "double":
817
+ return fieldTypes.double;
818
+ case "long":
819
+ return fieldTypes.long;
820
+ case "string":
821
+ return fieldTypes.string;
822
+ case "date":
823
+ return fieldTypes.date;
824
+ case "date-only":
825
+ return fieldTypes.dateOnly;
826
+ case "time-only":
827
+ return fieldTypes.timeOnly;
828
+ case "timestamp-offset":
829
+ return fieldTypes.timestampOffset;
830
+ case "oid":
831
+ return fieldTypes.oid;
832
+ case "guid":
833
+ return fieldTypes.guid;
834
+ case "global-id":
835
+ return fieldTypes.globalId;
836
+ default:
837
+ return fieldTypes.string;
838
+ }
839
+ }
840
+ _getStatisticsType(fieldInfo) {
841
+ // "count-or-amount","percentage-or-ratio","measurement","unique-identifier","coordinate","binary"
842
+ // "name-or-title","type-or-category","description","location-or-place-name","ordered-or-ranked","date-and-time"
843
+ switch (fieldInfo.layerField.type) {
844
+ case "small-integer":
845
+ case "big-integer":
846
+ case "integer":
847
+ case "single":
848
+ case "double": {
849
+ if (fieldInfo.codedValues) {
850
+ return SimpleFieldTypes.STRING;
851
+ }
852
+ switch (fieldInfo.layerField.valueType) {
853
+ case "name-or-title":
854
+ case "type-or-category":
855
+ case "description":
856
+ case "location-or-place-name":
857
+ case "ordered-or-ranked":
858
+ case "binary":
859
+ //case "date-and-time":
860
+ return SimpleFieldTypes.STRING;
861
+ default:
862
+ return SimpleFieldTypes.NUMBER;
863
+ }
864
+ }
865
+ case "string":
866
+ return SimpleFieldTypes.STRING;
867
+ case "date":
868
+ return SimpleFieldTypes.DATE;
869
+ case "timestamp-offset":
870
+ return SimpleFieldTypes.TIMESTAMP_OFFSET;
871
+ case "date-only":
872
+ return SimpleFieldTypes.DATE_ONLY;
873
+ case "time-only":
874
+ return SimpleFieldTypes.TIME_ONLY;
875
+ default:
876
+ return SimpleFieldTypes.STRING;
877
+ }
878
+ }
879
+ _getFieldValueTypeCamelCase(field) {
880
+ switch (field.layerField.valueType) {
881
+ case "count-or-amount":
882
+ return "countOrAmount";
883
+ case "percentage-or-ratio":
884
+ return "percentageOrRatio";
885
+ case "unique-identifier":
886
+ return "uniqueIdentifier";
887
+ case "name-or-title":
888
+ return "nameOrTitle";
889
+ case "type-or-category":
890
+ return "typeOrCategory";
891
+ case "location-or-place-name":
892
+ return "locationOrPlaceName";
893
+ case "ordered-or-ranked":
894
+ return "orderedOrRanked";
895
+ case "date-and-time":
896
+ return "dateAndTime";
897
+ default:
898
+ return field.layerField.valueType;
899
+ }
900
+ }
901
+ _getDisplayString(value) {
902
+ const { props } = this;
903
+ const { fieldInfo } = props;
904
+ switch (fieldInfo.simpleFieldType) {
905
+ case SimpleFieldTypes.DATE:
906
+ return this._getDateString(value);
907
+ case SimpleFieldTypes.TIMESTAMP_OFFSET:
908
+ return this._getTimestampOffsetString(value);
909
+ case SimpleFieldTypes.DATE_ONLY:
910
+ return this._getDateOnlyString(value);
911
+ case SimpleFieldTypes.TIME_ONLY:
912
+ return this._getTimeOnlyString(value);
913
+ case SimpleFieldTypes.NUMBER:
914
+ return this._getNumberString(value);
915
+ case SimpleFieldTypes.GUID:
916
+ return this._getGuidString(value);
917
+ default:
918
+ // string, oid, global-id
919
+ return `${value}`;
920
+ }
921
+ }
922
+ _getDateString(value) {
923
+ const { modules, view } = this.props;
924
+ if (view && view.timeZone === "unknown") {
925
+ return modules.intl.formatDate(value, {
926
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
927
+ timeZone: "utc",
928
+ timeZoneName: "shortOffset"
929
+ });
930
+ }
931
+ else {
932
+ // known issues with formatting it-CH
933
+ return modules.intl.formatDate(value, {
934
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
935
+ timeZone: view?.timeZone || "system"
936
+ });
937
+ }
938
+ }
939
+ _getTimestampOffsetString(value) {
940
+ /*
941
+ const timestamp = "2023-03-19T16:00:00.123-01:00";
942
+ console.log("timestamp", timestamp);
943
+ console.log(
944
+ "local Time",
945
+ intl.formatTimestamp(timestamp, intl.convertDateFormatToIntlOptions("short-date-short-time"))
946
+ );
947
+ console.log(
948
+ "mapView Time (except unknown)",
949
+ intl.formatTimestamp(timestamp, {
950
+ ...intl.convertDateFormatToIntlOptions("short-date-short-time"),
951
+ timeZone: view.timeZone,
952
+ })
953
+ );
954
+ console.log(
955
+ "UTC Time (mapView time unknown)",
956
+ intl.formatTimestamp(timestamp, {
957
+ ...intl.convertDateFormatToIntlOptions("short-date-short-time"),
958
+ timeZone: "utc",
959
+ timeZoneName: "shortOffset"
960
+ })
961
+ );
962
+ console.log(
963
+ "Raw",
964
+ intl.formatTimestamp(timestamp, {
965
+ ...intl.convertDateFormatToIntlOptions("short-date-short-time"),
966
+ timeZoneName: "shortOffset"
967
+ })
968
+ );
969
+ */
970
+ const { modules, view } = this.props;
971
+ if (typeof value === "string") {
972
+ // raw value from layer
973
+ if (view && view.timeZone === "unknown") {
974
+ return modules.intl.formatTimestamp(value, {
975
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
976
+ timeZone: "utc",
977
+ timeZoneName: "shortOffset"
978
+ });
979
+ }
980
+ else {
981
+ return modules.intl.formatTimestamp(value, {
982
+ ...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
983
+ timeZone: view?.timeZone || "system"
984
+ });
985
+ }
986
+ }
987
+ else {
988
+ // e.g. UNIX timestamp from statistics call
989
+ return this._getDateString(value);
990
+ }
991
+ }
992
+ _getDateOnlyString(value) {
993
+ const { props } = this;
994
+ const { modules } = props;
995
+ return modules.intl.formatDateOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date"));
996
+ }
997
+ _getTimeOnlyString(value) {
998
+ const { props } = this;
999
+ const { modules } = props;
1000
+ if (typeof value === "string") {
1001
+ return modules.intl.formatTimeOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date-long-time"));
1002
+ }
1003
+ else {
1004
+ // UNIX timestamp
1005
+ return modules.intl.formatDate(value, {
1006
+ ...modules.intl.convertDateFormatToIntlOptions("long-time"),
1007
+ timeZone: "utc"
1008
+ });
1009
+ }
1010
+ }
1011
+ _getGuidString(value) {
1012
+ return value.startsWith("{") ? value : `{${value}}`;
1013
+ }
1014
+ _getNumberString(value) {
1015
+ return this.props.modules.intl.formatNumber(value);
1016
+ }
1017
+ _printNumValue(value) {
1018
+ return isDefined(value) ? this._getNumberString(Math.round(value * 100) / 100) : `--`;
1019
+ }
1020
+ static get assetsDirs() { return ["assets"]; }
1021
+ get _hostElement() { return index.getElement(this); }
1022
+ };
1023
+ ArcgisFieldInfo.style = fieldInfoScss;
1024
+
1025
+ exports.arcgis_field_info = ArcgisFieldInfo;