chunk-FSIQKOJP.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. import {
  2. A,
  3. a as a2,
  4. c as c2,
  5. f as f3,
  6. l,
  7. o as o2,
  8. q
  9. } from "./chunk-OQSZOHTF.js";
  10. import {
  11. t as t2
  12. } from "./chunk-OP2HNSVZ.js";
  13. import {
  14. I as I2,
  15. P,
  16. n,
  17. t as t3,
  18. v as v4
  19. } from "./chunk-UVQJ7AVD.js";
  20. import {
  21. E as E2,
  22. F,
  23. v as v3,
  24. z
  25. } from "./chunk-Y7BZ6TKQ.js";
  26. import {
  27. M,
  28. f as f2,
  29. g
  30. } from "./chunk-VEJPYAE4.js";
  31. import {
  32. F as F2
  33. } from "./chunk-B5O7N7PM.js";
  34. import {
  35. nt
  36. } from "./chunk-JKFWEHNK.js";
  37. import {
  38. v as v2
  39. } from "./chunk-WOXHUQGM.js";
  40. import {
  41. r as r3
  42. } from "./chunk-JLSNMUQJ.js";
  43. import {
  44. C,
  45. a,
  46. f,
  47. w
  48. } from "./chunk-ECY35CJI.js";
  49. import {
  50. h as h2,
  51. r as r2
  52. } from "./chunk-PT62335L.js";
  53. import {
  54. i
  55. } from "./chunk-4T5ZGMEN.js";
  56. import {
  57. o,
  58. u as u2
  59. } from "./chunk-2H5MD622.js";
  60. import {
  61. $
  62. } from "./chunk-3RSFVUKZ.js";
  63. import {
  64. u,
  65. v,
  66. y as y2
  67. } from "./chunk-RMDDCMKS.js";
  68. import {
  69. c
  70. } from "./chunk-VCH45Q2I.js";
  71. import {
  72. E,
  73. I
  74. } from "./chunk-PQFTYGF5.js";
  75. import {
  76. s3 as s2
  77. } from "./chunk-E5O6P5I2.js";
  78. import {
  79. y
  80. } from "./chunk-SPWQ3AWG.js";
  81. import {
  82. b,
  83. x
  84. } from "./chunk-2TIUKVZN.js";
  85. import {
  86. h,
  87. r,
  88. s,
  89. t
  90. } from "./chunk-YXWMMD76.js";
  91. // node_modules/@arcgis/core/layers/graphics/data/QueryEngine.js
  92. function V(e) {
  93. return e.every((e2) => "exceedslimit" !== e2.statisticType);
  94. }
  95. var W = "feature-store:unsupported-query";
  96. var K = new h2(2e6);
  97. var X = 0;
  98. var Y = class {
  99. constructor(e) {
  100. this.capabilities = { query: t2 }, this.geometryType = e.geometryType, this.hasM = e.hasM, this.hasZ = e.hasZ, this.objectIdField = e.objectIdField, this.spatialReference = e.spatialReference, this.definitionExpression = e.definitionExpression, this.featureStore = e.featureStore, this.aggregateAdapter = e.aggregateAdapter, this._changeHandle = this.featureStore.events.on("changed", () => this.clearCache()), this.timeInfo = e.timeInfo, e.cacheSpatialQueries && (this._geometryQueryCache = new r2(X++ + "$$", K)), this.fieldsIndex = new r3(e.fields), e.scheduler && e.priority && (this._frameTask = e.scheduler.registerTask(e.priority));
  101. }
  102. destroy() {
  103. this._frameTask = h(this._frameTask), this.clearCache(), s(this._geometryQueryCache), this._changeHandle = h(this._changeHandle), s(this.fieldsIndex);
  104. }
  105. get featureAdapter() {
  106. return this.featureStore.featureAdapter;
  107. }
  108. get fullExtent() {
  109. const e = this.featureStore.fullBounds;
  110. return t(e) ? null : { xmin: e[0], ymin: e[1], xmax: e[2], ymax: e[3], spatialReference: E2(this.spatialReference) };
  111. }
  112. get timeExtent() {
  113. return this.timeInfo ? (this._timeExtent || (this._timeExtent = t3(this.timeInfo, this.featureStore)), this._timeExtent) : null;
  114. }
  115. clearCache() {
  116. var _a;
  117. (_a = this._geometryQueryCache) == null ? void 0 : _a.clear(), this._allItems = null, this._timeExtent = null;
  118. }
  119. async executeQuery(e, t4) {
  120. try {
  121. return (await this._executeQuery(e, {}, t4)).createQueryResponse();
  122. } catch (i2) {
  123. if (i2 !== F)
  124. throw i2;
  125. return new A([], e, this).createQueryResponse();
  126. }
  127. }
  128. async executeQueryForCount(e = {}, t4) {
  129. try {
  130. return (await this._executeQuery(e, { returnGeometry: false, returnCentroid: false, outSR: null }, t4)).createQueryResponseForCount();
  131. } catch (i2) {
  132. if (i2 !== F)
  133. throw i2;
  134. return 0;
  135. }
  136. }
  137. async executeQueryForExtent(e, t4) {
  138. const i2 = e.outSR;
  139. try {
  140. const s3 = await this._executeQuery(e, { returnGeometry: true, returnCentroid: false, outSR: null }, t4), r4 = s3.size;
  141. if (!r4)
  142. return { count: 0, extent: null };
  143. w(te, C), this.featureStore.forEachBounds(s3.items, (e2) => f(te, e2), ee);
  144. const a3 = { xmin: te[0], ymin: te[1], xmax: te[3], ymax: te[4], spatialReference: E2(this.spatialReference) };
  145. this.hasZ && isFinite(te[2]) && isFinite(te[5]) && (a3.zmin = te[2], a3.zmax = te[5]);
  146. const n2 = g(a3, s3.spatialReference, i2);
  147. if (n2.spatialReference = E2(i2 || this.spatialReference), n2.xmax - n2.xmin == 0) {
  148. const e2 = $(n2.spatialReference);
  149. n2.xmin -= e2, n2.xmax += e2;
  150. }
  151. if (n2.ymax - n2.ymin == 0) {
  152. const e2 = $(n2.spatialReference);
  153. n2.ymin -= e2, n2.ymax += e2;
  154. }
  155. if (this.hasZ && null != n2.zmin && null != n2.zmax && n2.zmax - n2.zmin == 0) {
  156. const e2 = $(n2.spatialReference);
  157. n2.zmin -= e2, n2.zmax += e2;
  158. }
  159. return { count: r4, extent: n2 };
  160. } catch (s3) {
  161. if (s3 === F)
  162. return { count: 0, extent: null };
  163. throw s3;
  164. }
  165. }
  166. async executeQueryForIds(e, t4) {
  167. return this.executeQueryForIdSet(e, t4).then((e2) => Array.from(e2));
  168. }
  169. async executeQueryForIdSet(e, t4) {
  170. try {
  171. const i2 = await this._executeQuery(e, { returnGeometry: true, returnCentroid: false, outSR: null }, t4), s3 = i2.items, r4 = /* @__PURE__ */ new Set();
  172. return await this._reschedule(() => {
  173. for (const e2 of s3)
  174. r4.add(i2.featureAdapter.getObjectId(e2));
  175. }, t4), r4;
  176. } catch (i2) {
  177. if (i2 === F)
  178. return /* @__PURE__ */ new Set();
  179. throw i2;
  180. }
  181. }
  182. async executeQueryForSnapping(e, t4) {
  183. const { point: i2, distance: s3, types: r4 } = e;
  184. if (r4 === q.NONE)
  185. return { candidates: [] };
  186. const a3 = await this._reschedule(() => this._checkQuerySupport(e.query), t4), o3 = !E(i2.spatialReference, this.spatialReference);
  187. o3 && await f2(i2.spatialReference, this.spatialReference);
  188. const u3 = "number" == typeof s3 ? s3 : s3.x, c3 = "number" == typeof s3 ? s3 : s3.y, h3 = { xmin: i2.x - u3, xmax: i2.x + u3, ymin: i2.y - c3, ymax: i2.y + c3, spatialReference: i2.spatialReference }, l2 = o3 ? g(h3, this.spatialReference) : h3;
  189. if (!l2)
  190. return { candidates: [] };
  191. const f4 = (await v2(v(i2), null, { signal: t4 }))[0], m = (await v2(v(l2), null, { signal: t4 }))[0];
  192. if (t(f4) || t(m))
  193. return { candidates: [] };
  194. const p = new A(this._searchFeatures(this._getQueryBBoxes(m.toJSON())), a3, this);
  195. await this._reschedule(() => this._executeObjectIdsQuery(p), t4), await this._reschedule(() => this._executeTimeQuery(p), t4), await this._reschedule(() => this._executeAttributesQuery(p), t4);
  196. const d = f4.toJSON(), y3 = o3 ? g(d, this.spatialReference) : d, g2 = o3 ? Math.max(l2.xmax - l2.xmin, l2.ymax - l2.ymin) / 2 : s3;
  197. return p.createSnappingResponse({ ...e, point: y3, distance: g2 }, i2.spatialReference);
  198. }
  199. async executeQueryForLatestObservations(e, t4) {
  200. if (!this.timeInfo || !this.timeInfo.trackIdField)
  201. throw new s2(W, "Missing timeInfo or timeInfo.trackIdField", { query: e, timeInfo: this.timeInfo });
  202. try {
  203. const i2 = await this._executeQuery(e, {}, t4);
  204. return await this._reschedule(() => this._filterLatest(i2), t4), i2.createQueryResponse();
  205. } catch (s3) {
  206. if (s3 !== F)
  207. throw s3;
  208. return new A([], e, this).createQueryResponse();
  209. }
  210. }
  211. async executeQueryForSummaryStatistics(e = {}, t4, i2) {
  212. const { field: s3, normalizationField: r4, valueExpression: a3 } = t4;
  213. return (await this._getQueryEngineResultForStats(e, { field: s3, normalizationField: r4, valueExpression: a3 }, i2)).createSummaryStatisticsResponse(t4);
  214. }
  215. async executeQueryForUniqueValues(e = {}, t4, i2) {
  216. const { field: s3, field2: r4, field3: a3, valueExpression: n2 } = t4;
  217. return (await this._getQueryEngineResultForStats(e, { field: s3, field2: r4, field3: a3, valueExpression: n2 }, i2)).createUniqueValuesResponse(t4);
  218. }
  219. async executeQueryForClassBreaks(e = {}, t4, i2) {
  220. const { field: s3, normalizationField: r4, valueExpression: a3 } = t4;
  221. return (await this._getQueryEngineResultForStats(e, { field: s3, normalizationField: r4, valueExpression: a3 }, i2)).createClassBreaksResponse(t4);
  222. }
  223. async executeQueryForHistogram(e = {}, t4, i2) {
  224. const { field: s3, normalizationField: r4, valueExpression: a3 } = t4;
  225. return (await this._getQueryEngineResultForStats(e, { field: s3, normalizationField: r4, valueExpression: a3 }, i2)).createHistogramResponse(t4);
  226. }
  227. async _schedule(e, t4) {
  228. return r(this._frameTask) ? this._frameTask.schedule(e, t4) : e(F2);
  229. }
  230. async _reschedule(e, t4) {
  231. return r(this._frameTask) ? this._frameTask.reschedule(e, t4) : e(F2);
  232. }
  233. _getAll(e) {
  234. return t(this._allItems) && (this._allItems = this.featureStore.toArray()), new A(this._allItems, e, this);
  235. }
  236. async _executeQuery(e, t4, i2) {
  237. e = y(e), e = await this._schedule(() => z(e, this.definitionExpression, this.spatialReference), i2), e = await this._reschedule(() => this._checkQuerySupport(e), i2), e = { ...e, ...t4 };
  238. const r4 = await this._reschedule(() => this._executeSceneFilterQuery(e, i2), i2), a3 = await this._reschedule(() => this._executeGeometryQuery(e, r4, i2), i2);
  239. return await this._reschedule(() => this._executeAggregateIdsQuery(a3), i2), await this._reschedule(() => this._executeObjectIdsQuery(a3), i2), await this._reschedule(() => this._executeTimeQuery(a3), i2), await this._reschedule(() => this._executeAttributesQuery(a3), i2), a3;
  240. }
  241. async _executeSceneFilterQuery(e, t4) {
  242. if (t(e.sceneFilter))
  243. return null;
  244. const { outSR: i2, returnGeometry: s3, returnCentroid: r4 } = e, a3 = this.featureStore.featureSpatialReference, o3 = e.sceneFilter.geometry, u3 = t(a3) || E(a3, o3.spatialReference) ? o3 : g(o3, a3);
  245. if (!u3)
  246. return null;
  247. const c3 = s3 || r4, h3 = I(i2) && !E(this.spatialReference, i2) && c3 ? async (e2) => this._project(e2, i2) : (e2) => e2, l2 = this.featureAdapter, f4 = this._searchFeatures(this._getQueryBBoxes(u3));
  248. if ("disjoint" === e.sceneFilter.spatialRelationship) {
  249. if (!f4.length)
  250. return null;
  251. const i3 = /* @__PURE__ */ new Set();
  252. for (const e2 of f4)
  253. i3.add(l2.getObjectId(e2));
  254. const s4 = await this._reschedule(() => this.featureStore.toArray(), t4), r5 = await this._reschedule(async () => {
  255. const r6 = await v4("esriSpatialRelDisjoint", u3, this.geometryType, this.hasZ, this.hasM), a4 = (e2) => !i3.has(l2.getObjectId(e2)) || r6(l2.getGeometry(e2)), n2 = await this._runSpatialFilter(s4, a4, t4);
  256. return new A(n2, e, this);
  257. }, t4);
  258. return h3(r5);
  259. }
  260. if (!f4.length)
  261. return new A([], e, this);
  262. if (this._canExecuteSinglePass(u3, e))
  263. return h3(new A(f4, e, this));
  264. const m = await v4("esriSpatialRelContains", u3, this.geometryType, this.hasZ, this.hasM), p = await this._runSpatialFilter(f4, (e2) => m(l2.getGeometry(e2)), t4);
  265. return h3(new A(p, e, this));
  266. }
  267. async _executeGeometryQuery(i2, s3, r4) {
  268. if (r(s3) && 0 === s3.items.length)
  269. return s3;
  270. i2 = r(s3) ? s3.query : i2;
  271. const { geometry: a3, outSR: u3, spatialRel: c3, returnGeometry: h3, returnCentroid: l2 } = i2, f4 = this.featureStore.featureSpatialReference, m = !a3 || t(f4) || E(f4, a3.spatialReference) ? a3 : g(a3, f4), p = h3 || l2, d = I(u3) && !E(this.spatialReference, u3), y3 = this._geometryQueryCache && t(s3) ? d && p ? JSON.stringify({ originalFilterGeometry: a3, spatialRelationship: c3, outSpatialReference: u3 }) : JSON.stringify({ originalFilterGeometry: a3, spatialRelationship: c3 }) : null, g2 = y3 ? this._geometryQueryCache.get(y3) : null;
  272. if (r(g2))
  273. return new A(g2, i2, this);
  274. const x2 = async (e) => (d && p && await this._project(e, u3), y3 && this._geometryQueryCache.put(y3, e.items, e.items.length + 1), e);
  275. if (!m)
  276. return x2(r(s3) ? s3 : this._getAll(i2));
  277. const _ = this.featureAdapter;
  278. let w2 = this._searchFeatures(this._getQueryBBoxes(a3));
  279. if ("esriSpatialRelDisjoint" === c3) {
  280. if (!w2.length)
  281. return x2(r(s3) ? s3 : this._getAll(i2));
  282. const e = /* @__PURE__ */ new Set();
  283. for (const i3 of w2)
  284. e.add(_.getObjectId(i3));
  285. const t4 = r(s3) ? s3.items : await this._reschedule(() => this.featureStore.toArray(), r4), a4 = await this._reschedule(async () => {
  286. const s4 = await v4(c3, m, this.geometryType, this.hasZ, this.hasM), a5 = (t5) => !e.has(_.getObjectId(t5)) || s4(_.getGeometry(t5)), n2 = await this._runSpatialFilter(t4, a5, r4);
  287. return new A(n2, i2, this);
  288. }, r4);
  289. return x2(a4);
  290. }
  291. if (r(s3)) {
  292. const i3 = new x();
  293. w2 = w2.filter((e) => b(s3.items, e, s3.items.length, i3) >= 0);
  294. }
  295. if (!w2.length) {
  296. const e = new A([], i2, this);
  297. return y3 && this._geometryQueryCache.put(y3, e.items, 1), e;
  298. }
  299. if (this._canExecuteSinglePass(m, i2))
  300. return x2(new A(w2, i2, this));
  301. const S = await v4(c3, m, this.geometryType, this.hasZ, this.hasM), Q = await this._runSpatialFilter(w2, (e) => S(_.getGeometry(e)), r4);
  302. return x2(new A(Q, i2, this));
  303. }
  304. _executeAggregateIdsQuery(e) {
  305. if (0 === e.items.length || !e.query.aggregateIds || !e.query.aggregateIds.length || t(this.aggregateAdapter))
  306. return;
  307. const t4 = /* @__PURE__ */ new Set();
  308. for (const s3 of e.query.aggregateIds) {
  309. this.aggregateAdapter.getFeatureObjectIds(s3).forEach((e2) => t4.add(e2));
  310. }
  311. const i2 = this.featureAdapter.getObjectId;
  312. e.items = e.items.filter((e2) => t4.has(i2(e2)));
  313. }
  314. _executeObjectIdsQuery(e) {
  315. if (0 === e.items.length || !e.query.objectIds || !e.query.objectIds.length)
  316. return;
  317. const t4 = new Set(e.query.objectIds), i2 = this.featureAdapter.getObjectId;
  318. e.items = e.items.filter((e2) => t4.has(i2(e2)));
  319. }
  320. _executeTimeQuery(e) {
  321. if (0 === e.items.length)
  322. return;
  323. const t4 = n(this.timeInfo, e.query.timeExtent, this.featureAdapter);
  324. t(t4) || (e.items = e.items.filter(t4));
  325. }
  326. _executeAttributesQuery(e) {
  327. if (0 === e.items.length)
  328. return;
  329. const t4 = l(e.query.where, this.fieldsIndex);
  330. if (t4) {
  331. if (!t4.isStandardized)
  332. throw new TypeError("Where clause is not standardized");
  333. e.items = e.items.filter((e2) => t4.testFeature(e2, this.featureAdapter));
  334. }
  335. }
  336. async _runSpatialFilter(e, t4, i2) {
  337. if (!t4)
  338. return e;
  339. if (t(this._frameTask))
  340. return e.filter((e2) => t4(e2));
  341. let s3 = 0;
  342. const r4 = new Array(), a3 = async (n2) => {
  343. for (; s3 < e.length; ) {
  344. const o3 = e[s3++];
  345. t4(o3) && (r4.push(o3), n2.madeProgress()), n2.done && await this._reschedule((e2) => a3(e2), i2);
  346. }
  347. };
  348. return this._reschedule((e2) => a3(e2), i2).then(() => r4);
  349. }
  350. _filterLatest(e) {
  351. const { trackIdField: t4, startTimeField: i2, endTimeField: s3 } = this.timeInfo, r4 = s3 || i2, a3 = /* @__PURE__ */ new Map(), n2 = this.featureAdapter.getAttribute;
  352. for (const o3 of e.items) {
  353. const e2 = n2(o3, t4), i3 = n2(o3, r4), s4 = a3.get(e2);
  354. (!s4 || i3 > n2(s4, r4)) && a3.set(e2, o3);
  355. }
  356. e.items = Array.from(a3.values());
  357. }
  358. _canExecuteSinglePass(e, t4) {
  359. const { spatialRel: i2 } = t4;
  360. return I2(e) && ("esriSpatialRelEnvelopeIntersects" === i2 || "esriGeometryPoint" === this.geometryType && ("esriSpatialRelIntersects" === i2 || "esriSpatialRelContains" === i2 || "esriSpatialRelWithin" === i2));
  361. }
  362. async _project(e, t4) {
  363. if (!t4 || E(this.spatialReference, t4))
  364. return e;
  365. const i2 = this.featureAdapter, s3 = await M(e.items.map((e2) => v3(this.geometryType, this.hasZ, this.hasM, i2.getGeometry(e2))), this.spatialReference, t4);
  366. return e.items = s3.map((t5, s4) => i2.cloneWithGeometry(e.items[s4], nt(t5, this.hasZ, this.hasM))), e;
  367. }
  368. _getQueryBBoxes(e) {
  369. if (I2(e)) {
  370. if (u(e))
  371. return [o(e.xmin, e.ymin, e.xmax, e.ymax)];
  372. if (y2(e))
  373. return e.rings.map((e2) => o(Math.min(e2[0][0], e2[2][0]), Math.min(e2[0][1], e2[2][1]), Math.max(e2[0][0], e2[2][0]), Math.max(e2[0][1], e2[2][1])));
  374. }
  375. return [c(u2(), e)];
  376. }
  377. _searchFeatures(e) {
  378. for (const i2 of e)
  379. this.featureStore.forEachInBounds(i2, (e2) => ie.add(e2));
  380. const t4 = Array.from(ie.values());
  381. return ie.clear(), t4;
  382. }
  383. async _checkStatisticsSupport(e, t4) {
  384. if (e.distance < 0 || null != e.geometryPrecision || e.multipatchOption || e.pixelSize || e.relationParam || e.text || e.outStatistics || e.groupByFieldsForStatistics || e.having || e.orderByFields)
  385. throw new s2(W, "Unsupported query options", { query: e });
  386. return this._checkAttributesQuerySupport(e), Promise.all([this._checkStatisticsParamsSupport(t4), P(e, this.geometryType, this.spatialReference), f2(this.spatialReference, e.outSR)]).then(() => e);
  387. }
  388. async _checkStatisticsParamsSupport(e) {
  389. let t4 = [];
  390. if (e.valueExpression) {
  391. const { arcadeUtils: i2 } = await i();
  392. t4 = i2.extractFieldNames(e.valueExpression);
  393. }
  394. if (e.field && t4.push(e.field), e.field2 && t4.push(e.field2), e.field3 && t4.push(e.field3), e.normalizationField && t4.push(e.normalizationField), !t4.length)
  395. throw new s2(W, "params should have at least a field or valueExpression", { params: e });
  396. c2(this.fieldsIndex, t4, "params contains missing fields");
  397. }
  398. async _checkQuerySupport(e) {
  399. if (e.distance < 0 || null != e.geometryPrecision || e.multipatchOption || e.pixelSize || e.relationParam || e.text)
  400. throw new s2(W, "Unsupported query options", { query: e });
  401. return this._checkAttributesQuerySupport(e), this._checkStatisticsQuerySupport(e), Promise.all([P(e, this.geometryType, this.spatialReference), f2(this.spatialReference, e.outSR)]).then(() => e);
  402. }
  403. _checkAttributesQuerySupport(e) {
  404. const { outFields: t4, orderByFields: s3, returnDistinctValues: r4, outStatistics: a3 } = e, n2 = a3 ? a3.map((e2) => e2.outStatisticFieldName && e2.outStatisticFieldName.toLowerCase()).filter(Boolean) : [];
  405. if (s3 && s3.length > 0) {
  406. const e2 = " asc", t5 = " desc", i2 = s3.map((i3) => {
  407. const s4 = i3.toLowerCase();
  408. return s4.includes(e2) ? s4.split(e2)[0] : s4.includes(t5) ? s4.split(t5)[0] : i3;
  409. }).filter((e3) => !n2.includes(e3));
  410. c2(this.fieldsIndex, i2, "orderByFields contains missing fields");
  411. }
  412. if (t4 && t4.length > 0)
  413. c2(this.fieldsIndex, t4, "outFields contains missing fields");
  414. else if (r4)
  415. throw new s2(W, "outFields should be specified for returnDistinctValues", { query: e });
  416. o2(this.fieldsIndex, e.where);
  417. }
  418. _checkStatisticsQuerySupport(e) {
  419. const { outStatistics: t4, groupByFieldsForStatistics: s3, having: r4 } = e, a3 = s3 && s3.length, n2 = t4 && t4.length;
  420. if (r4) {
  421. if (!a3 || !n2)
  422. throw new s2(W, "outStatistics and groupByFieldsForStatistics should be specified with having", { query: e });
  423. a2(this.fieldsIndex, r4, t4);
  424. }
  425. if (n2) {
  426. if (!V(t4))
  427. return;
  428. const r5 = t4.map((e2) => e2.onStatisticField).filter(Boolean);
  429. c2(this.fieldsIndex, r5, "onStatisticFields contains missing fields"), a3 && c2(this.fieldsIndex, s3, "groupByFieldsForStatistics contains missing fields");
  430. for (const s4 of t4) {
  431. const { onStatisticField: t5, statisticType: r6 } = s4;
  432. if (("percentile_disc" === r6 || "percentile_cont" === r6) && "statisticParameters" in s4) {
  433. const { statisticParameters: t6 } = s4;
  434. if (!t6)
  435. throw new s2(W, "statisticParamters should be set for percentile type", { definition: s4, query: e });
  436. } else if ("count" !== r6 && t5 && f3(t5, this.fieldsIndex))
  437. throw new s2(W, "outStatistics contains non-numeric fields", { definition: s4, query: e });
  438. }
  439. }
  440. }
  441. async _getQueryEngineResultForStats(e, t4, i2) {
  442. e = y(e);
  443. try {
  444. e = await this._schedule(() => z(e, this.definitionExpression, this.spatialReference), i2), e = await this._reschedule(() => this._checkStatisticsSupport(e, t4), i2);
  445. const s3 = await this._reschedule(() => this._executeSceneFilterQuery(e, i2), i2), r4 = await this._reschedule(() => this._executeGeometryQuery(e, s3, i2), i2);
  446. return await this._reschedule(() => this._executeAggregateIdsQuery(r4), i2), await this._reschedule(() => this._executeObjectIdsQuery(r4), i2), await this._reschedule(() => this._executeTimeQuery(r4), i2), await this._reschedule(() => this._executeAttributesQuery(r4), i2), r4;
  447. } catch (r4) {
  448. if (r4 !== F)
  449. throw r4;
  450. return new A([], e, this);
  451. }
  452. }
  453. };
  454. var ee = a();
  455. var te = a();
  456. var ie = /* @__PURE__ */ new Set();
  457. export {
  458. Y
  459. };
  460. //# sourceMappingURL=chunk-FSIQKOJP.js.map