chunk-6H5PP7QI.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. import {
  2. J,
  3. O,
  4. x
  5. } from "./chunk-XIEPNAEI.js";
  6. import {
  7. g as g2
  8. } from "./chunk-M5BTTMP6.js";
  9. import {
  10. m as m2
  11. } from "./chunk-ETWBEEKL.js";
  12. import {
  13. D,
  14. T,
  15. V,
  16. c,
  17. d,
  18. f,
  19. g,
  20. h,
  21. m,
  22. s as s3,
  23. y,
  24. z
  25. } from "./chunk-D5GG5NVO.js";
  26. import {
  27. s as s2
  28. } from "./chunk-Q34L5KZA.js";
  29. import {
  30. e as e2
  31. } from "./chunk-7IKYLNB5.js";
  32. import {
  33. H
  34. } from "./chunk-WZQZRKNH.js";
  35. import {
  36. a
  37. } from "./chunk-LRDX4TO7.js";
  38. import {
  39. e,
  40. l,
  41. l2,
  42. v
  43. } from "./chunk-OWVBLVP3.js";
  44. import {
  45. E,
  46. I
  47. } from "./chunk-MRJEICT6.js";
  48. import {
  49. s3 as s
  50. } from "./chunk-EMJ4ZSM2.js";
  51. import {
  52. r,
  53. t
  54. } from "./chunk-GZT4BVFP.js";
  55. // node_modules/@arcgis/core/core/sql/WhereClauseCache.js
  56. var c2 = class {
  57. constructor(e3, c4) {
  58. this._cache = new e2(e3), this._invalidCache = new e2(c4);
  59. }
  60. get(t3, c4) {
  61. const i = `${c4.uid}:${t3}`, r4 = this._cache.get(i);
  62. if (r4)
  63. return r4;
  64. if (this._invalidCache.get(i) !== void 0)
  65. return null;
  66. try {
  67. const r5 = m2.create(t3, c4);
  68. return this._cache.put(i, r5), r5;
  69. } catch {
  70. return this._invalidCache.put(i, null), null;
  71. }
  72. }
  73. };
  74. // node_modules/@arcgis/core/layers/graphics/data/attributeSupport.js
  75. var s4 = new c2(50, 500);
  76. var n = "feature-store:unsupported-query";
  77. var t2 = " as ";
  78. var r2 = new Set(["esriFieldTypeOID", "esriFieldTypeSmallInteger", "esriFieldTypeInteger", "esriFieldTypeSingle", "esriFieldTypeDouble", "esriFieldTypeLong", "esriFieldTypeDate"]);
  79. function o(i, t3) {
  80. if (!t3)
  81. return true;
  82. const r4 = s4.get(t3, i);
  83. if (!r4)
  84. throw new s(n, "invalid SQL expression", { where: t3 });
  85. if (!r4.isStandardized)
  86. throw new s(n, "where clause is not standard", { where: t3 });
  87. return c3(i, r4.fieldNames, "where clause contains missing fields"), true;
  88. }
  89. function a2(i, t3, r4) {
  90. if (!t3)
  91. return true;
  92. const o2 = s4.get(t3, i);
  93. if (!o2)
  94. throw new s(n, "invalid SQL expression", { having: t3 });
  95. if (!o2.isAggregate)
  96. throw new s(n, "having does not contain a valid aggregate function", { having: t3 });
  97. const a3 = o2.fieldNames;
  98. c3(i, a3, "having contains missing fields");
  99. if (!o2.getExpressions().every((e3) => {
  100. const { aggregateType: s5, field: n2 } = e3, t4 = i.has(n2) && i.get(n2).name;
  101. return r4.some((e4) => {
  102. const { onStatisticField: n3, statisticType: r5 } = e4;
  103. return (i.has(n3) && i.get(n3).name) === t4 && r5.toLowerCase().trim() === s5;
  104. });
  105. }))
  106. throw new s(n, "expressions in having should also exist in outStatistics", { having: t3 });
  107. return true;
  108. }
  109. function l3(e3, i) {
  110. return e3 ? s4.get(e3, i) : null;
  111. }
  112. function c3(i, s5, t3, r4 = true) {
  113. const o2 = [];
  114. for (const u2 of s5)
  115. if (u2 !== "*" && !i.has(u2))
  116. if (r4) {
  117. const s6 = d2(u2);
  118. try {
  119. const t4 = l3(s6, i);
  120. if (!t4)
  121. throw new s(n, "invalid SQL expression", { where: s6 });
  122. if (!t4.isStandardized)
  123. throw new s(n, "expression is not standard", { clause: t4 });
  124. c3(i, t4.fieldNames, "expression contains missing fields");
  125. } catch (a3) {
  126. const e3 = a3 && a3.details;
  127. if (e3 && (e3.clause || e3.where))
  128. throw a3;
  129. e3 && e3.missingFields ? o2.push(...e3.missingFields) : o2.push(u2);
  130. }
  131. } else
  132. o2.push(u2);
  133. if (o2.length)
  134. throw new s(n, t3, { missingFields: o2 });
  135. }
  136. function d2(e3) {
  137. return e3.split(t2)[0];
  138. }
  139. function u(e3) {
  140. return e3.split(t2)[1];
  141. }
  142. function f2(e3, i) {
  143. const s5 = i.get(e3);
  144. return !!s5 && !r2.has(s5.type);
  145. }
  146. // node_modules/@arcgis/core/layers/graphics/data/AttributesBuilder.js
  147. var r3 = class {
  148. constructor(t3, a3, r4) {
  149. this._fieldDataCache = new Map(), this._returnDistinctMap = new Map(), this.returnDistinctValues = t3.returnDistinctValues, this.fieldsIndex = r4, this.featureAdapter = a3;
  150. const l4 = t3.outFields;
  151. if (l4 && !l4.includes("*")) {
  152. this.outFields = l4;
  153. let t4 = 0;
  154. for (const a4 of l4) {
  155. const l5 = d2(a4), u2 = this.fieldsIndex.get(l5), n2 = u2 ? null : l3(l5, r4), c4 = u2 ? u2.name : u(a4) || "FIELD_EXP_" + t4++;
  156. this._fieldDataCache.set(a4, { alias: c4, clause: n2 });
  157. }
  158. }
  159. }
  160. countDistinctValues(t3) {
  161. return this.returnDistinctValues ? (t3.forEach((t4) => this.getAttributes(t4)), this._returnDistinctMap.size) : t3.length;
  162. }
  163. getAttributes(t3) {
  164. const e3 = this._processAttributesForOutFields(t3);
  165. return this._processAttributesForDistinctValues(e3);
  166. }
  167. getFieldValue(t3, e3, i) {
  168. const a3 = i ? i.name : e3;
  169. let r4 = null;
  170. return this._fieldDataCache.has(a3) ? r4 = this._fieldDataCache.get(a3).clause : i || (r4 = l3(e3, this.fieldsIndex), this._fieldDataCache.set(a3, { alias: a3, clause: r4 })), i ? this.featureAdapter.getAttribute(t3, a3) : r4.calculateValue(t3, this.featureAdapter);
  171. }
  172. getNormalizedValue(t3, e3) {
  173. const s5 = e3.normalizationType, i = e3.normalizationTotal;
  174. let r4 = this.getFieldValue(t3, e3.field, e3.fieldInfo);
  175. if (s5 && Number.isFinite(r4)) {
  176. const l4 = this.getFieldValue(t3, e3.normalizationField, e3.normalizationFieldInfo);
  177. r4 = T(r4, s5, l4, i);
  178. }
  179. return r4;
  180. }
  181. getExpressionValue(t3, e3, s5, i) {
  182. const a3 = { attributes: this.featureAdapter.getAttributes(t3), layer: { fields: this.fieldsIndex.fields } }, r4 = i.createExecContext(a3, s5);
  183. return i.executeFunction(e3, r4);
  184. }
  185. getExpressionValues(t3, e3, s5, i) {
  186. const a3 = { fields: this.fieldsIndex.fields };
  187. return t3.map((t4) => {
  188. const r4 = { attributes: this.featureAdapter.getAttributes(t4), layer: a3 }, l4 = i.createExecContext(r4, s5);
  189. return i.executeFunction(e3, l4);
  190. });
  191. }
  192. validateItem(t3, e3) {
  193. return this._fieldDataCache.has(e3) || this._fieldDataCache.set(e3, { alias: e3, clause: l3(e3, this.fieldsIndex) }), this._fieldDataCache.get(e3).clause.testFeature(t3, this.featureAdapter);
  194. }
  195. validateItems(t3, e3) {
  196. return this._fieldDataCache.has(e3) || this._fieldDataCache.set(e3, { alias: e3, clause: l3(e3, this.fieldsIndex) }), this._fieldDataCache.get(e3).clause.testSet(t3, this.featureAdapter);
  197. }
  198. _processAttributesForOutFields(t3) {
  199. const e3 = this.outFields;
  200. if (!e3 || !e3.length)
  201. return this.featureAdapter.getAttributes(t3);
  202. const s5 = {};
  203. for (const i of e3) {
  204. const { alias: e4, clause: a3 } = this._fieldDataCache.get(i);
  205. s5[e4] = a3 ? a3.calculateValue(t3, this.featureAdapter) : this.featureAdapter.getAttribute(t3, e4);
  206. }
  207. return s5;
  208. }
  209. _processAttributesForDistinctValues(e3) {
  210. if (t(e3) || !this.returnDistinctValues)
  211. return e3;
  212. const s5 = this.outFields, i = [];
  213. if (s5)
  214. for (const t3 of s5) {
  215. const { alias: s6 } = this._fieldDataCache.get(t3);
  216. i.push(e3[s6]);
  217. }
  218. else
  219. for (const t3 in e3)
  220. i.push(e3[t3]);
  221. const a3 = `${(s5 || ["*"]).join(",")}=${i.join(",")}`;
  222. let r4 = this._returnDistinctMap.get(a3) || 0;
  223. return this._returnDistinctMap.set(a3, ++r4), r4 > 1 ? null : e3;
  224. }
  225. };
  226. // node_modules/@arcgis/core/layers/graphics/data/QueryEngineResult.js
  227. var v2 = class {
  228. constructor(e3, t3, i) {
  229. this.items = e3, this.query = t3, this.geometryType = i.geometryType, this.hasM = i.hasM, this.hasZ = i.hasZ, this.fieldsIndex = i.fieldsIndex, this.objectIdField = i.objectIdField, this.spatialReference = i.spatialReference, this.featureAdapter = i.featureAdapter;
  230. }
  231. get size() {
  232. return this.items.length;
  233. }
  234. createQueryResponseForCount() {
  235. const e3 = new r3(this.query, this.featureAdapter, this.fieldsIndex);
  236. if (!this.query.outStatistics)
  237. return e3.countDistinctValues(this.items);
  238. const { groupByFieldsForStatistics: t3, having: i, outStatistics: s5 } = this.query, a3 = t3?.length;
  239. if (!!!a3)
  240. return 1;
  241. const r4 = new Map(), n2 = new Map(), o2 = new Set();
  242. for (const l4 of s5) {
  243. const { statisticType: s6 } = l4, a4 = s6 !== "exceedslimit" ? l4.onStatisticField : void 0;
  244. if (!n2.has(a4)) {
  245. const i2 = [];
  246. for (const s7 of t3) {
  247. const t4 = this._getAttributeValues(e3, s7, r4);
  248. i2.push(t4);
  249. }
  250. n2.set(a4, this._calculateUniqueValues(i2, e3.returnDistinctValues));
  251. }
  252. const u2 = n2.get(a4);
  253. for (const t4 in u2) {
  254. const { data: s7, items: a5 } = u2[t4], r5 = s7.join(",");
  255. i && !e3.validateItems(a5, i) || o2.add(r5);
  256. }
  257. }
  258. return o2.size;
  259. }
  260. async createQueryResponse() {
  261. let e3;
  262. if (this.query.outStatistics) {
  263. e3 = this.query.outStatistics.some((e4) => e4.statisticType === "exceedslimit") ? this._createExceedsLimitQueryResponse(this.query) : await this._createStatisticsQueryResponse(this.query);
  264. } else
  265. e3 = this._createFeatureQueryResponse(this.query);
  266. return this.query.returnQueryGeometry && (I(this.query.outSR) && !E(this.query.geometry.spatialReference, this.query.outSR) ? e3.queryGeometry = x({ spatialReference: this.query.outSR, ...g2(this.query.geometry, this.query.geometry.spatialReference, this.query.outSR) }) : e3.queryGeometry = x({ spatialReference: this.query.outSR, ...this.query.geometry })), e3;
  267. }
  268. createSnappingResponse(t3, i) {
  269. const s5 = this.featureAdapter, a3 = A(this.hasZ, this.hasM), { x: r4, y: n2 } = t3.point, o2 = typeof t3.distance == "number" ? t3.distance : t3.distance.x, l4 = typeof t3.distance == "number" ? t3.distance : t3.distance.y, u2 = { candidates: [] }, c4 = this.geometryType === "esriGeometryPolygon", m3 = this._getPointCreator(t3.point, this.spatialReference, i);
  270. for (const d3 of this.items) {
  271. const i2 = s5.getGeometry(d3);
  272. if (t(i2))
  273. continue;
  274. const { coords: h2, lengths: g3 } = i2;
  275. if (t3.types & E2.EDGE) {
  276. let e3 = 0;
  277. for (let t4 = 0; t4 < g3.length; t4++) {
  278. const i3 = g3[t4];
  279. for (let t5 = 0; t5 < i3; t5++, e3 += a3) {
  280. const c5 = h2[e3], g4 = h2[e3 + 1];
  281. if (t5 !== i3 - 1) {
  282. const t6 = h2[e3 + a3], i4 = h2[e3 + a3 + 1], { x: p, y: f3 } = R(r4, n2, c5, g4, t6, i4), y2 = (r4 - p) / o2, x2 = (n2 - f3) / l4, I2 = y2 * y2 + x2 * x2;
  283. I2 <= 1 && u2.candidates.push({ type: "edge", objectId: s5.getObjectId(d3), distance: Math.sqrt(I2), target: m3(p, f3), start: m3(c5, g4), end: m3(t6, i4) });
  284. }
  285. }
  286. }
  287. }
  288. if (t3.types & E2.VERTEX) {
  289. const e3 = c4 ? h2.length - a3 : h2.length;
  290. for (let t4 = 0; t4 < e3; t4 += a3) {
  291. const e4 = h2[t4], i3 = h2[t4 + 1], a4 = (r4 - e4) / o2, c5 = (n2 - i3) / l4, g4 = a4 * a4 + c5 * c5;
  292. g4 <= 1 && u2.candidates.push({ type: "vertex", objectId: s5.getObjectId(d3), distance: Math.sqrt(g4), target: m3(e4, i3) });
  293. }
  294. }
  295. }
  296. return u2.candidates.sort((e3, t4) => e3.distance - t4.distance), u2;
  297. }
  298. _getPointCreator(e3, i, s5) {
  299. const a3 = r(s5) && !E(i, s5) ? (e4) => g2(e4, i, s5) : (e4) => e4;
  300. return e3.z != null && e3.m != null ? (t3, i2) => a3({ x: t3, y: i2, z: e3.z, m: e3.m }) : e3.z != null ? (t3, i2) => a3({ x: t3, y: i2, z: e3.z }) : e3.m != null ? (t3, i2) => a3({ x: t3, y: i2, m: e3.m }) : (e4, t3) => a3({ x: e4, y: t3 });
  301. }
  302. async createSummaryStatisticsResponse(e3) {
  303. const { field: t3, valueExpression: i, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, minValue: n2, maxValue: o2, scale: l4 } = e3, u2 = this.fieldsIndex.isDateField(t3), c4 = await this._getDataValues({ field: t3, valueExpression: i, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, scale: l4 }), m3 = s3({ normalizationType: a3, normalizationField: s5, minValue: n2, maxValue: o2 }), d3 = this.fieldsIndex.get(t3), h2 = { value: 0.5, fieldType: d3?.type }, I2 = H(d3) ? m({ values: c4, supportsNullCount: m3, percentileParams: h2 }) : c({ values: c4, minValue: n2, maxValue: o2, useSampleStdDev: !a3, supportsNullCount: m3, percentileParams: h2 });
  304. return V(I2, u2);
  305. }
  306. async createUniqueValuesResponse(e3) {
  307. const { field: t3, valueExpression: i, domain: s5, returnAllCodedValues: a3, scale: r4 } = e3, n2 = await this._getDataValues({ field: t3, valueExpression: i, scale: r4 }), o2 = g(n2);
  308. return h(o2, s5, a3);
  309. }
  310. async createClassBreaksResponse(e3) {
  311. const { field: t3, valueExpression: i, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, classificationMethod: n2, standardDeviationInterval: o2, minValue: l4, maxValue: u2, numClasses: c4, scale: m3 } = e3, d3 = await this._getDataValues({ field: t3, valueExpression: i, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, scale: m3 }), h2 = y(d3, { field: t3, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, classificationMethod: n2, standardDeviationInterval: o2, minValue: l4, maxValue: u2, numClasses: c4 });
  312. return D(h2, n2);
  313. }
  314. async createHistogramResponse(e3) {
  315. const { field: t3, valueExpression: i, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, classificationMethod: n2, standardDeviationInterval: o2, minValue: l4, maxValue: u2, numBins: c4, scale: m3 } = e3, d3 = await this._getDataValues({ field: t3, valueExpression: i, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, scale: m3 });
  316. return z(d3, { field: t3, normalizationField: s5, normalizationType: a3, normalizationTotal: r4, classificationMethod: n2, standardDeviationInterval: o2, minValue: l4, maxValue: u2, numBins: c4 });
  317. }
  318. _sortFeatures(e3, t3, i) {
  319. if (e3.length > 1 && t3 && t3.length)
  320. for (const s5 of t3.reverse()) {
  321. const t4 = s5.split(" "), a3 = t4[0], r4 = this.fieldsIndex.get(a3), n2 = t4[1] && t4[1].toLowerCase() === "desc", o2 = f(r4?.type, n2);
  322. e3.sort((e4, t5) => {
  323. const s6 = i(e4, a3, r4), n3 = i(t5, a3, r4);
  324. return o2(s6, n3);
  325. });
  326. }
  327. }
  328. _createFeatureQueryResponse(e3) {
  329. const t3 = this.items, { geometryType: i, hasM: s5, hasZ: a3, objectIdField: r4, spatialReference: o2 } = this, { outFields: l4, outSR: u2, quantizationParameters: c4, resultRecordCount: d3, resultOffset: h2, returnZ: g3, returnM: p } = e3, f3 = d3 != null && t3.length > (h2 || 0) + d3, y2 = l4 && (l4.includes("*") ? [...this.fieldsIndex.fields] : l4.map((e4) => this.fieldsIndex.get(e4)));
  330. return { exceededTransferLimit: f3, features: this._createFeatures(e3, t3), fields: y2, geometryType: i, hasM: s5 && p, hasZ: a3 && g3, objectIdFieldName: r4, spatialReference: x(u2 || o2), transform: c4 && s2(c4) || null };
  331. }
  332. _createFeatures(e3, t3) {
  333. const i = new r3(e3, this.featureAdapter, this.fieldsIndex), { hasM: s5, hasZ: a3 } = this, { orderByFields: r4, quantizationParameters: o2, returnGeometry: l4, returnCentroid: c4, maxAllowableOffset: m3, resultOffset: g3, resultRecordCount: p, returnZ: f3 = false, returnM: y2 = false } = e3, x2 = a3 && f3, I2 = s5 && y2;
  334. let T2 = [], V2 = 0;
  335. const F = [...t3];
  336. if (this._sortFeatures(F, r4, (e4, t4, s6) => i.getFieldValue(e4, t4, s6)), l4 || c4) {
  337. const e4 = s2(o2);
  338. if (l4 && !c4)
  339. for (const t4 of F)
  340. T2[V2++] = { attributes: i.getAttributes(t4), geometry: J(this.geometryType, this.hasZ, this.hasM, this.featureAdapter.getGeometry(t4), m3, e4, x2, I2) };
  341. else if (!l4 && c4)
  342. for (const t4 of F)
  343. T2[V2++] = { attributes: i.getAttributes(t4), centroid: O(this, this.featureAdapter.getCentroid(t4, this), e4) };
  344. else
  345. for (const t4 of F)
  346. T2[V2++] = { attributes: i.getAttributes(t4), centroid: O(this, this.featureAdapter.getCentroid(t4, this), e4), geometry: J(this.geometryType, this.hasZ, this.hasM, this.featureAdapter.getGeometry(t4), m3, e4, x2, I2) };
  347. } else
  348. for (const n2 of F) {
  349. const e4 = i.getAttributes(n2);
  350. e4 && (T2[V2++] = { attributes: e4 });
  351. }
  352. const z2 = g3 || 0;
  353. if (p != null) {
  354. const e4 = z2 + p;
  355. T2 = T2.slice(z2, Math.min(T2.length, e4));
  356. }
  357. return T2;
  358. }
  359. _createExceedsLimitQueryResponse(e3) {
  360. let i = false, s5 = Number.POSITIVE_INFINITY, a3 = Number.POSITIVE_INFINITY, r4 = Number.POSITIVE_INFINITY;
  361. for (const t3 of e3.outStatistics)
  362. if (t3.statisticType === "exceedslimit") {
  363. s5 = t3.maxPointCount != null ? t3.maxPointCount : Number.POSITIVE_INFINITY, a3 = t3.maxRecordCount != null ? t3.maxRecordCount : Number.POSITIVE_INFINITY, r4 = t3.maxVertexCount != null ? t3.maxVertexCount : Number.POSITIVE_INFINITY;
  364. break;
  365. }
  366. if (this.geometryType === "esriGeometryPoint")
  367. i = this.items.length > s5;
  368. else if (this.items.length > a3)
  369. i = true;
  370. else {
  371. const e4 = this.hasZ ? this.hasM ? 4 : 3 : this.hasM ? 3 : 2, s6 = this.featureAdapter;
  372. i = this.items.reduce((e5, i2) => {
  373. const a4 = s6.getGeometry(i2);
  374. return e5 + (r(a4) && a4.coords.length || 0);
  375. }, 0) / e4 > r4;
  376. }
  377. return { fields: [{ name: "exceedslimit", type: "esriFieldTypeInteger", alias: "exceedslimit", sqlType: "sqlTypeInteger", domain: null, defaultValue: null }], features: [{ attributes: { exceedslimit: Number(i) } }] };
  378. }
  379. async _createStatisticsQueryResponse(e3) {
  380. const t3 = { attributes: {} }, i = [], s5 = new Map(), a3 = new Map(), r4 = new Map(), n2 = new Map(), o2 = new r3(e3, this.featureAdapter, this.fieldsIndex), l4 = e3.outStatistics, { groupByFieldsForStatistics: c4, having: m3, orderByFields: d3 } = e3, h2 = c4 && c4.length, g3 = !!h2, p = g3 && c4[0], f3 = g3 && !this.fieldsIndex.get(p);
  381. for (const u2 of l4) {
  382. const { outStatisticFieldName: e4, statisticType: l5 } = u2, d4 = u2, y3 = l5 !== "exceedslimit" ? u2.onStatisticField : void 0, x2 = l5 === "percentile_disc" || l5 === "percentile_cont", I2 = l5 === "EnvelopeAggregate" || l5 === "CentroidAggregate" || l5 === "ConvexHullAggregate", T2 = g3 && h2 === 1 && (y3 === p || f3) && l5 === "count";
  383. if (g3) {
  384. if (!r4.has(y3)) {
  385. const e5 = [];
  386. for (const t5 of c4) {
  387. const i2 = this._getAttributeValues(o2, t5, s5);
  388. e5.push(i2);
  389. }
  390. r4.set(y3, this._calculateUniqueValues(e5, o2.returnDistinctValues));
  391. }
  392. const t4 = r4.get(y3);
  393. for (const i2 in t4) {
  394. const { count: a4, data: r5, items: l6, itemPositions: u3 } = t4[i2], h3 = r5.join(",");
  395. if (!m3 || o2.validateItems(l6, m3)) {
  396. const t5 = n2.get(h3) || { attributes: {} };
  397. if (I2) {
  398. t5.aggregateGeometries || (t5.aggregateGeometries = {});
  399. const { aggregateGeometries: e5, outStatisticFieldName: i3 } = await this._getAggregateGeometry(d4, l6);
  400. t5.aggregateGeometries[i3] = e5;
  401. } else {
  402. let i3 = null;
  403. if (T2)
  404. i3 = a4;
  405. else {
  406. const e5 = this._getAttributeValues(o2, y3, s5), t6 = u3.map((t7) => e5[t7]);
  407. i3 = x2 && "statisticParameters" in d4 ? this._getPercentileValue(d4, t6) : this._getStatisticValue(d4, t6, null, o2.returnDistinctValues);
  408. }
  409. t5.attributes[e4] = i3;
  410. }
  411. c4.forEach((e5, i3) => t5.attributes[this.fieldsIndex.get(e5) ? e5 : `EXPR_${i3 + 1}`] = r5[i3]), n2.set(h3, t5);
  412. }
  413. }
  414. } else if (I2) {
  415. t3.aggregateGeometries || (t3.aggregateGeometries = {});
  416. const { aggregateGeometries: e5, outStatisticFieldName: i2 } = await this._getAggregateGeometry(d4, this.items);
  417. t3.aggregateGeometries[i2] = e5;
  418. } else {
  419. const i2 = this._getAttributeValues(o2, y3, s5);
  420. t3.attributes[e4] = x2 && "statisticParameters" in d4 ? this._getPercentileValue(d4, i2) : this._getStatisticValue(d4, i2, a3, o2.returnDistinctValues);
  421. }
  422. i.push({ name: e4, alias: e4, type: "esriFieldTypeDouble" });
  423. }
  424. const y2 = g3 ? Array.from(n2.values()) : [t3];
  425. return this._sortFeatures(y2, d3, (e4, t4) => e4.attributes[t4]), { fields: i, features: y2 };
  426. }
  427. async _getAggregateGeometry(e3, t3) {
  428. const n2 = await import("./geometryEngineJSON-XXKTYTFH.js"), { statisticType: o2, outStatisticFieldName: l4 } = e3, { featureAdapter: u2, spatialReference: c4, geometryType: m3, hasZ: h2, hasM: g3 } = this, p = t3.map((e4) => J(m3, h2, g3, u2.getGeometry(e4))), f3 = n2.convexHull(c4, p, true)[0], y2 = { aggregateGeometries: null, outStatisticFieldName: null };
  429. if (o2 === "EnvelopeAggregate") {
  430. const e4 = f3 ? v(f3) : l2(n2.union(c4, p));
  431. y2.aggregateGeometries = { ...e4, spatialReference: c4 }, y2.outStatisticFieldName = l4 || "extent";
  432. } else if (o2 === "CentroidAggregate") {
  433. const e4 = f3 ? e(f3) : l(l2(n2.union(c4, p)));
  434. y2.aggregateGeometries = { x: e4[0], y: e4[1], spatialReference: c4 }, y2.outStatisticFieldName = l4 || "centroid";
  435. } else
  436. o2 === "ConvexHullAggregate" && (y2.aggregateGeometries = f3, y2.outStatisticFieldName = l4 || "convexHull");
  437. return y2;
  438. }
  439. _getStatisticValue(e3, t3, i, s5) {
  440. const { onStatisticField: a3, statisticType: r4 } = e3;
  441. let n2 = null;
  442. n2 = i?.has(a3) ? i.get(a3) : H(this.fieldsIndex.get(a3)) ? m({ values: t3, returnDistinct: s5 }) : c({ values: t3, minValue: null, maxValue: null, useSampleStdDev: true }), i && i.set(a3, n2);
  443. return n2[r4 === "var" ? "variance" : r4];
  444. }
  445. _getPercentileValue(e3, t3) {
  446. const { onStatisticField: i, statisticParameters: s5, statisticType: a3 } = e3, { value: r4, orderBy: n2 } = s5, o2 = this.fieldsIndex.get(i);
  447. return d(t3, { value: r4, orderBy: n2, fieldType: o2?.type, isDiscrete: a3 === "percentile_disc" });
  448. }
  449. _getAttributeValues(e3, t3, i) {
  450. if (i.has(t3))
  451. return i.get(t3);
  452. const s5 = this.fieldsIndex.get(t3), a3 = this.items.map((i2) => e3.getFieldValue(i2, t3, s5));
  453. return i.set(t3, a3), a3;
  454. }
  455. _getAttributeNormalizedValues(e3, t3) {
  456. return this.items.map((i) => e3.getNormalizedValue(i, { field: t3.field, fieldInfo: this.fieldsIndex.get(t3.field), normalizationField: t3.normalizationField, normalizationFieldInfo: this.fieldsIndex.get(t3.normalizationField), normalizationType: t3.normalizationType, normalizationTotal: t3.normalizationTotal }));
  457. }
  458. async _getAttributeExpressionValues(e3, t3, i) {
  459. const { arcadeUtils: s5 } = await a(), a3 = s5.createFunction(t3), r4 = i && s5.getViewInfo(i);
  460. return e3.getExpressionValues(this.items, a3, r4, s5);
  461. }
  462. _calculateUniqueValues(e3, t3) {
  463. const i = {}, s5 = this.items, a3 = s5.length;
  464. for (let r4 = 0; r4 < a3; r4++) {
  465. const a4 = s5[r4], n2 = [];
  466. for (const t4 of e3)
  467. n2.push(t4[r4]);
  468. const o2 = n2.join(",");
  469. t3 ? i[o2] == null && (i[o2] = { count: 1, data: n2, items: [a4], itemPositions: [r4] }) : i[o2] == null ? i[o2] = { count: 1, data: n2, items: [a4], itemPositions: [r4] } : (i[o2].count++, i[o2].items.push(a4), i[o2].itemPositions.push(r4));
  470. }
  471. return i;
  472. }
  473. async _getDataValues(e3) {
  474. const t3 = new r3(this.query, this.featureAdapter, this.fieldsIndex), { valueExpression: i, field: s5, normalizationField: a3, normalizationType: r4, normalizationTotal: n2, scale: o2 } = e3, l4 = i ? { viewingMode: "map", scale: o2, spatialReference: this.query.outSR || this.spatialReference } : null;
  475. return i ? this._getAttributeExpressionValues(t3, i, l4) : this._getAttributeNormalizedValues(t3, { field: s5, normalizationField: a3, normalizationType: r4, normalizationTotal: n2 });
  476. }
  477. };
  478. function R(e3, t3, i, s5, a3, r4) {
  479. const n2 = a3 - i, o2 = r4 - s5, l4 = n2 * n2 + o2 * o2, u2 = (e3 - i) * n2 + (t3 - s5) * o2, c4 = Math.min(1, Math.max(0, u2 / l4));
  480. return { x: i + n2 * c4, y: s5 + o2 * c4 };
  481. }
  482. function A(e3, t3) {
  483. return e3 ? t3 ? 4 : 3 : t3 ? 3 : 2;
  484. }
  485. var E2;
  486. !function(e3) {
  487. e3[e3.NONE = 0] = "NONE", e3[e3.EDGE = 1] = "EDGE", e3[e3.VERTEX = 2] = "VERTEX";
  488. }(E2 || (E2 = {}));
  489. export {
  490. o,
  491. a2 as a,
  492. l3 as l,
  493. c3 as c,
  494. f2 as f,
  495. v2 as v,
  496. E2 as E
  497. };
  498. //# sourceMappingURL=chunk-6H5PP7QI.js.map