FeatureServiceSnappingSourceWorker-O4IDMMDZ.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. import {
  2. h,
  3. u as u3
  4. } from "./chunk-5FHVUYVE.js";
  5. import {
  6. Y
  7. } from "./chunk-NP2BYFXT.js";
  8. import "./chunk-6H5PP7QI.js";
  9. import "./chunk-HSPVIAVJ.js";
  10. import "./chunk-XIEPNAEI.js";
  11. import "./chunk-M5BTTMP6.js";
  12. import "./chunk-WQJRLXWG.js";
  13. import "./chunk-ETWBEEKL.js";
  14. import "./chunk-XZA4MVET.js";
  15. import "./chunk-4GGRJYTB.js";
  16. import "./chunk-D5GG5NVO.js";
  17. import "./chunk-USORKAIZ.js";
  18. import "./chunk-Q34L5KZA.js";
  19. import {
  20. S as S2,
  21. c as c3,
  22. d as d3,
  23. x
  24. } from "./chunk-GS2NUWMB.js";
  25. import "./chunk-FUEX356Y.js";
  26. import {
  27. a
  28. } from "./chunk-54AOZV5X.js";
  29. import "./chunk-PK35UGFJ.js";
  30. import "./chunk-ROWZMUVJ.js";
  31. import "./chunk-7IKYLNB5.js";
  32. import "./chunk-P4UZNLD5.js";
  33. import {
  34. ce,
  35. ge,
  36. le
  37. } from "./chunk-FYNVVMWY.js";
  38. import "./chunk-Q52DVFYK.js";
  39. import "./chunk-HBMVUVZX.js";
  40. import "./chunk-QOV6ITMI.js";
  41. import "./chunk-DH2OBAUC.js";
  42. import "./chunk-TNLRDNTC.js";
  43. import {
  44. v
  45. } from "./chunk-T3EUPDKL.js";
  46. import {
  47. e as e3,
  48. o,
  49. r as r2
  50. } from "./chunk-WR32EHFC.js";
  51. import {
  52. b
  53. } from "./chunk-UD63WBG3.js";
  54. import {
  55. g
  56. } from "./chunk-X7DBH4KK.js";
  57. import "./chunk-EWE6EXPY.js";
  58. import "./chunk-KMAHKQ2G.js";
  59. import "./chunk-522WBHUO.js";
  60. import "./chunk-WNCU6BFU.js";
  61. import "./chunk-BJHM4JNS.js";
  62. import "./chunk-F6A2QQ26.js";
  63. import "./chunk-EOSZHC5H.js";
  64. import "./chunk-C43UE3Z5.js";
  65. import {
  66. c as c2,
  67. d as d2
  68. } from "./chunk-RMX2AZ4P.js";
  69. import {
  70. u
  71. } from "./chunk-NE3ESGA6.js";
  72. import {
  73. U,
  74. j,
  75. l
  76. } from "./chunk-YIS6BAC3.js";
  77. import "./chunk-7XXXCK2A.js";
  78. import "./chunk-7ZIDBK7B.js";
  79. import "./chunk-EG5OI4V4.js";
  80. import "./chunk-65BYCSII.js";
  81. import "./chunk-WZQZRKNH.js";
  82. import "./chunk-LRDX4TO7.js";
  83. import {
  84. S
  85. } from "./chunk-RBZL6SRZ.js";
  86. import "./chunk-WDLTDV2L.js";
  87. import "./chunk-TERAW6FT.js";
  88. import {
  89. E,
  90. c,
  91. f as f2,
  92. u as u2,
  93. y as y2
  94. } from "./chunk-N2663GRX.js";
  95. import "./chunk-O4FY3ITT.js";
  96. import "./chunk-JXW4QTJA.js";
  97. import "./chunk-UXF37FQ4.js";
  98. import "./chunk-ZOEK6QHJ.js";
  99. import "./chunk-XNLG7T2T.js";
  100. import "./chunk-IR4PV7VK.js";
  101. import "./chunk-2Z6LERTI.js";
  102. import "./chunk-OWVBLVP3.js";
  103. import {
  104. u as u4
  105. } from "./chunk-WJ3OEUD3.js";
  106. import "./chunk-MXB2XLKV.js";
  107. import "./chunk-ALDCDSPV.js";
  108. import {
  109. n as n3
  110. } from "./chunk-DT6EAZQ5.js";
  111. import "./chunk-HNOZUNJ4.js";
  112. import "./chunk-VNFRAYHO.js";
  113. import "./chunk-R5IG2D6H.js";
  114. import "./chunk-VBRY5KJM.js";
  115. import "./chunk-PDKDCAAD.js";
  116. import {
  117. M2 as M
  118. } from "./chunk-ECW2QABR.js";
  119. import "./chunk-GCDJLKH4.js";
  120. import {
  121. k2 as k
  122. } from "./chunk-MRJEICT6.js";
  123. import {
  124. d,
  125. e,
  126. n,
  127. n2,
  128. y3 as y
  129. } from "./chunk-Y3WMVFTW.js";
  130. import "./chunk-SAS7RONY.js";
  131. import "./chunk-WSRBH7BF.js";
  132. import "./chunk-IHXECKQQ.js";
  133. import {
  134. O,
  135. T,
  136. f,
  137. w
  138. } from "./chunk-ULGDPLM2.js";
  139. import {
  140. s
  141. } from "./chunk-EMJ4ZSM2.js";
  142. import "./chunk-IKP3YN53.js";
  143. import {
  144. e as e2,
  145. i2 as i,
  146. r,
  147. t
  148. } from "./chunk-GZT4BVFP.js";
  149. import "./chunk-A5ICIBVI.js";
  150. // node_modules/@arcgis/core/core/AsyncSequence.js
  151. var r3 = class extends y {
  152. constructor() {
  153. super(...arguments), this.updating = false, this.pending = [];
  154. }
  155. push(s2, t3) {
  156. this.pending.push({ promise: s2, callback: t3 }), this.pending.length === 1 && this._process();
  157. }
  158. _process() {
  159. if (!this.pending.length)
  160. return void (this.updating = false);
  161. this.updating = true;
  162. const s2 = this.pending[0];
  163. s2.promise.then((t3) => s2.callback(t3)).catch(() => {
  164. }).then(() => {
  165. this.pending.shift(), this._process();
  166. });
  167. }
  168. };
  169. e([d()], r3.prototype, "updating", void 0), r3 = e([n2("esri.core.AsyncSequence")], r3);
  170. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/PendingFeatureTile.js
  171. var o2 = class {
  172. constructor(t3, e4) {
  173. this.data = t3, this.resolution = e4, this.state = { type: u5.CREATED }, this.alive = true;
  174. }
  175. process(t3) {
  176. switch (this.state.type) {
  177. case u5.CREATED:
  178. return this.state = this._gotoFetchCount(this.state, t3), this.state.task.promise.then(t3.resume, t3.resume);
  179. case u5.FETCH_COUNT:
  180. break;
  181. case u5.FETCHED_COUNT:
  182. return this.state = this._gotoFetchFeatures(this.state, t3), this.state.task.promise.then(t3.resume, t3.resume);
  183. case u5.FETCH_FEATURES:
  184. break;
  185. case u5.FETCHED_FEATURES:
  186. this.state = this._goToDone(this.state, t3);
  187. case u5.DONE:
  188. }
  189. return null;
  190. }
  191. get debugInfo() {
  192. return { data: this.data, featureCount: this.featureCount, state: this.stateToString };
  193. }
  194. get featureCount() {
  195. switch (this.state.type) {
  196. case u5.CREATED:
  197. case u5.FETCH_COUNT:
  198. return 0;
  199. case u5.FETCHED_COUNT:
  200. return this.state.featureCount;
  201. case u5.FETCH_FEATURES:
  202. return this.state.previous.featureCount;
  203. case u5.FETCHED_FEATURES:
  204. return this.state.features.length;
  205. case u5.DONE:
  206. return this.state.previous.features.length;
  207. }
  208. }
  209. get stateToString() {
  210. switch (this.state.type) {
  211. case u5.CREATED:
  212. return "created";
  213. case u5.FETCH_COUNT:
  214. return "fetch-count";
  215. case u5.FETCHED_COUNT:
  216. return "fetched-count";
  217. case u5.FETCH_FEATURES:
  218. return "fetch-features";
  219. case u5.FETCHED_FEATURES:
  220. return "fetched-features";
  221. case u5.DONE:
  222. return "done";
  223. }
  224. }
  225. _gotoFetchCount(e4, a2) {
  226. return { type: u5.FETCH_COUNT, previous: e4, task: O(async (e5) => {
  227. const s2 = await u4(a2.fetchCount(this, e5));
  228. this.state.type === u5.FETCH_COUNT && (this.state = this._gotoFetchedCount(this.state, s2.ok ? s2.value : 1 / 0));
  229. }) };
  230. }
  231. _gotoFetchedCount(t3, e4) {
  232. return { type: u5.FETCHED_COUNT, featureCount: e4, previous: t3 };
  233. }
  234. _gotoFetchFeatures(e4, a2) {
  235. return { type: u5.FETCH_FEATURES, previous: e4, task: O(async (s2) => {
  236. const r4 = await u4(a2.fetchFeatures(this, e4.featureCount, s2));
  237. this.state.type === u5.FETCH_FEATURES && (this.state = this._gotoFetchedFeatures(this.state, r4.ok ? r4.value : []));
  238. }) };
  239. }
  240. _gotoFetchedFeatures(t3, e4) {
  241. return { type: u5.FETCHED_FEATURES, previous: t3, features: e4 };
  242. }
  243. _goToDone(t3, e4) {
  244. return e4.finish(this, t3.features), { type: u5.DONE, previous: t3 };
  245. }
  246. reset() {
  247. const t3 = this.state;
  248. switch (this.state = { type: u5.CREATED }, t3.type) {
  249. case u5.CREATED:
  250. case u5.FETCHED_COUNT:
  251. case u5.FETCHED_FEATURES:
  252. case u5.DONE:
  253. break;
  254. case u5.FETCH_COUNT:
  255. case u5.FETCH_FEATURES:
  256. t3.task.abort();
  257. }
  258. }
  259. intersects(t3) {
  260. return !(!t(t3) && this.data.extent) || (c(t3, T2), E(this.data.extent, T2));
  261. }
  262. };
  263. var u5;
  264. !function(t3) {
  265. t3[t3.CREATED = 0] = "CREATED", t3[t3.FETCH_COUNT = 1] = "FETCH_COUNT", t3[t3.FETCHED_COUNT = 2] = "FETCHED_COUNT", t3[t3.FETCH_FEATURES = 3] = "FETCH_FEATURES", t3[t3.FETCHED_FEATURES = 4] = "FETCHED_FEATURES", t3[t3.DONE = 5] = "DONE";
  266. }(u5 || (u5 = {}));
  267. var T2 = u2();
  268. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js
  269. var S3 = s.getLogger("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher");
  270. var C = class extends d2 {
  271. constructor(e4) {
  272. super(e4), this.tilesOfInterest = [], this.availability = 0, this.pendingTiles = new Map(), this.pendingEdits = new r3(), this.pendingEditsAbortController = new AbortController();
  273. }
  274. get minimumVerticesPerFeature() {
  275. switch (this.store?.featureStore.geometryType) {
  276. case "esriGeometryPoint":
  277. case "esriGeometryMultipoint":
  278. return 1;
  279. case "esriGeometryPolygon":
  280. return 4;
  281. case "esriGeometryPolyline":
  282. return 2;
  283. }
  284. }
  285. set filter(e4) {
  286. const t3 = this._get("filter"), i2 = this._filterProperties(e4);
  287. JSON.stringify(t3) !== JSON.stringify(i2) && this._set("filter", i2);
  288. }
  289. set customParameters(e4) {
  290. const t3 = this._get("customParameters");
  291. JSON.stringify(t3) !== JSON.stringify(e4) && this._set("customParameters", e4);
  292. }
  293. get configuration() {
  294. return { filter: this.filter, customParameters: this.customParameters, tileInfo: this.tileInfo, tileSize: this.tileSize };
  295. }
  296. set tileInfo(e4) {
  297. const t3 = this._get("tileInfo");
  298. t3 !== e4 && (r(e4) && r(t3) && JSON.stringify(e4) === JSON.stringify(t3) || (this._set("tileInfo", e4), this.store.tileInfo = e4));
  299. }
  300. set tileSize(e4) {
  301. this._get("tileSize") !== e4 && this._set("tileSize", e4);
  302. }
  303. get updating() {
  304. return this.updatingHandles.updating || this.pendingEdits.updating;
  305. }
  306. initialize() {
  307. this._initializeFetchExtent(), this.updatingHandles.add(() => this.configuration, () => this.refresh()), this.updatingHandles.add(() => this.tilesOfInterest, (e4, i2) => {
  308. i(e4, i2, ({ id: e5 }, { id: t3 }) => e5 === t3) || this._process();
  309. }, U);
  310. }
  311. destroy() {
  312. this.pendingTiles.forEach((e4) => this._deletePendingTile(e4)), this.pendingTiles.clear(), this.store.destroy(), this.tilesOfInterest.length = 0, this.pendingEditsAbortController.abort(), this.pendingEditsAbortController = null;
  313. }
  314. refresh() {
  315. this.store.refresh(), this.pendingTiles.forEach((e4) => this._deletePendingTile(e4)), this._process();
  316. }
  317. applyEdits(e4) {
  318. this.pendingEdits.push(e4, async (e5) => {
  319. if (e5.addedFeatures.length === 0 && e5.updatedFeatures.length === 0 && e5.deletedFeatures.length === 0)
  320. return;
  321. for (const [, i2] of this.pendingTiles)
  322. i2.reset();
  323. const t3 = { ...e5, deletedFeatures: e5.deletedFeatures.map(({ objectId: e6, globalId: t4 }) => e6 && e6 !== -1 ? e6 : this._lookupObjectIdByGlobalId(t4)) };
  324. await this.updatingHandles.addPromise(this.store.processEdits(t3, (e6, t4) => this._queryFeaturesById(e6, t4), this.pendingEditsAbortController.signal)), this._processPendingTiles();
  325. });
  326. }
  327. _initializeFetchExtent() {
  328. if (!this.capabilities.query.supportsExtent || !g(this.url))
  329. return;
  330. const e4 = O(async (e5) => {
  331. try {
  332. const t3 = await x(this.url, new b({ where: "1=1", outSpatialReference: this.spatialReference, cacheHint: !!this.capabilities.query.supportsCacheHint || void 0 }), { query: this.configuration.customParameters, signal: e5 });
  333. this.store.extent = M.fromJSON(t3.data?.extent);
  334. } catch (t3) {
  335. w(t3), S3.warn("Failed to fetch data extent", t3);
  336. }
  337. });
  338. this.updatingHandles.addPromise(e4.promise.then(() => this._process())), this.handles.add(n(() => e4.abort()));
  339. }
  340. get debugInfo() {
  341. return { numberOfFeatures: this.store.featureStore.numFeatures, tilesOfInterest: this.tilesOfInterest, pendingTiles: Array.from(this.pendingTiles.values()).map((e4) => e4.debugInfo), storedTiles: this.store.debugInfo };
  342. }
  343. _process() {
  344. this._markTilesNotAlive(), this._createPendingTiles(), this._deletePendingTiles(), this._processPendingTiles();
  345. }
  346. _markTilesNotAlive() {
  347. for (const [, e4] of this.pendingTiles)
  348. e4.alive = false;
  349. }
  350. _createPendingTiles() {
  351. const e4 = this._collectMissingTilesInfo();
  352. if (this._setAvailability(t(e4) ? 1 : e4.coveredArea / e4.fullArea), !t(e4))
  353. for (const { data: t3, resolution: i2 } of e4.missingTiles) {
  354. const e5 = this.pendingTiles.get(t3.id);
  355. e5 ? (e5.resolution = i2, e5.alive = true) : this._createPendingTile(t3, i2);
  356. }
  357. }
  358. _collectMissingTilesInfo() {
  359. let e4 = null;
  360. for (let t3 = this.tilesOfInterest.length - 1; t3 >= 0; t3--) {
  361. const i2 = this.tilesOfInterest[t3], s2 = this.store.process(i2, (e5, t4) => this._verifyTileComplexity(e5, t4));
  362. t(e4) ? e4 = s2 : e4.prepend(s2);
  363. }
  364. return e4;
  365. }
  366. _deletePendingTiles() {
  367. for (const [, e4] of this.pendingTiles)
  368. e4.alive || this._deletePendingTile(e4);
  369. }
  370. _processPendingTiles() {
  371. const e4 = { fetchCount: (e5, t3) => this._fetchCount(e5, t3), fetchFeatures: (e5, t3, i2) => this._fetchFeatures(e5, t3, i2), finish: (e5, t3) => this._finishPendingTile(e5, t3), resume: () => this._processPendingTiles() };
  372. if (this._ensureFetchAllCounts(e4))
  373. for (const [, t3] of this.pendingTiles)
  374. this._verifyTileComplexity(this.store.getFeatureCount(t3.data), t3.resolution) && this.updatingHandles.addPromise(t3.process(e4));
  375. }
  376. _verifyTileComplexity(e4, t3) {
  377. return this._verifyVertexComplexity(e4) && this._verifyFeatureDensity(e4, t3);
  378. }
  379. _verifyVertexComplexity(e4) {
  380. return e4 * this.minimumVerticesPerFeature < E2;
  381. }
  382. _verifyFeatureDensity(e4, t3) {
  383. if (t(this.tileInfo))
  384. return false;
  385. const i2 = this.tileSize * t3;
  386. return e4 * (w2 / (i2 * i2)) < q;
  387. }
  388. _ensureFetchAllCounts(e4) {
  389. let t3 = true;
  390. for (const [, i2] of this.pendingTiles)
  391. i2.state.type < u5.FETCHED_COUNT && this.updatingHandles.addPromise(i2.process(e4)), i2.state.type <= u5.FETCH_COUNT && (t3 = false);
  392. return t3;
  393. }
  394. _finishPendingTile(e4, t3) {
  395. this.store.add(e4.data, t3), this._deletePendingTile(e4), this._updateAvailability();
  396. }
  397. _updateAvailability() {
  398. const e4 = this._collectMissingTilesInfo();
  399. this._setAvailability(t(e4) ? 1 : e4.coveredArea / e4.fullArea);
  400. }
  401. _setAvailability(e4) {
  402. this._set("availability", e4);
  403. }
  404. _createPendingTile(e4, t3) {
  405. const i2 = new o2(e4, t3);
  406. return this.pendingTiles.set(e4.id, i2), i2;
  407. }
  408. _deletePendingTile(e4) {
  409. e4.reset(), this.pendingTiles.delete(e4.data.id);
  410. }
  411. async _fetchCount(e4, t3) {
  412. return this.store.fetchCount(e4.data, this.url, this._createCountQuery(e4), { query: this.customParameters, timeout: x2, signal: t3 });
  413. }
  414. async _fetchFeatures(e4, t3, i2) {
  415. let s2, r4 = 0, o3 = 0, n4 = t3;
  416. for (; ; ) {
  417. const a2 = this._createFeaturesQuery(e4), u6 = this._setPagingParameters(a2, r4, n4), { features: c4, exceededTransferLimit: d4 } = await this._queryFeatures(a2, i2);
  418. if (u6 && (r4 += e2(a2.num)), o3 += c4.length, s2 = s2 ? s2.concat(c4) : c4, n4 = t3 - o3, !u6 || !d4 || n4 <= 0)
  419. return s2;
  420. }
  421. }
  422. _filterProperties(e4) {
  423. return t(e4) ? { where: "1=1", gdbVersion: void 0, timeExtent: void 0 } : { where: e4.where || "1=1", timeExtent: e4.timeExtent, gdbVersion: e4.gdbVersion };
  424. }
  425. _lookupObjectIdByGlobalId(e4) {
  426. const t3 = this.globalIdField, i2 = this.objectIdField;
  427. if (t(t3))
  428. throw new Error("Expected globalIdField to be defined");
  429. let s2 = null;
  430. if (this.store.featureStore.forEach((r4) => {
  431. e4 === r4.attributes[t3] && (s2 = r4.objectId ?? r4.attributes[i2]);
  432. }), t(s2))
  433. throw new Error(`Expected to find a feature with globalId ${e4}`);
  434. return s2;
  435. }
  436. _queryFeaturesById(e4, t3) {
  437. const i2 = this._createFeaturesQuery(null);
  438. return i2.objectIds = e4, this._queryFeatures(i2, t3);
  439. }
  440. _queryFeatures(e4, t3) {
  441. return this.capabilities.query.supportsFormatPBF ? this._queryFeaturesPBF(e4, t3) : this._queryFeaturesJSON(e4, t3);
  442. }
  443. async _queryFeaturesPBF(e4, t3) {
  444. const { sourceSpatialReference: i2 } = this, { data: s2 } = await d3(this.url, e4, new a({ sourceSpatialReference: i2 }), { query: this.configuration.customParameters, timeout: x2, signal: t3 });
  445. return le(s2);
  446. }
  447. async _queryFeaturesJSON(e4, t3) {
  448. const { sourceSpatialReference: i2 } = this, { data: s2 } = await c3(this.url, e4, i2, { query: this.configuration.customParameters, timeout: x2, signal: t3 });
  449. return ce(s2, this.objectIdField);
  450. }
  451. _createCountQuery(e4) {
  452. const t3 = this._createBaseQuery(e4);
  453. return this.capabilities.query.supportsCacheHint && (t3.cacheHint = true), t3;
  454. }
  455. _createFeaturesQuery(e4) {
  456. const t3 = this._createBaseQuery(e4);
  457. return t3.outFields = this.globalIdField ? [this.globalIdField, this.objectIdField] : [this.objectIdField], t3.returnGeometry = true, r(e4) && (this.capabilities.query.supportsResultType ? t3.resultType = "tile" : this.capabilities.query.supportsCacheHint && (t3.cacheHint = true)), t3;
  458. }
  459. _createBaseQuery(e4) {
  460. const t3 = new b({ returnZ: false, returnM: false, geometry: r(this.tileInfo) && r(e4) ? f2(e4.data.extent, this.tileInfo.spatialReference) : void 0 }), i2 = this.configuration.filter;
  461. return r(i2) && (t3.where = i2.where, t3.gdbVersion = i2.gdbVersion, t3.timeExtent = i2.timeExtent), t3.outSpatialReference = this.spatialReference, t3;
  462. }
  463. _setPagingParameters(e4, t3, i2) {
  464. if (!this.capabilities.query.supportsPagination)
  465. return false;
  466. const { supportsMaxRecordCountFactor: s2, supportsCacheHint: r4, tileMaxRecordCount: o3, maxRecordCount: n4, supportsResultType: a2 } = this.capabilities.query, l2 = s2 ? b.MAX_MAX_RECORD_COUNT_FACTOR : 1, u6 = l2 * ((a2 || r4) && o3 ? o3 : n4 || j2);
  467. return e4.start = t3, s2 ? (e4.maxRecordCountFactor = Math.min(l2, Math.ceil(i2 / u6)), e4.num = Math.min(i2, e4.maxRecordCountFactor * u6)) : e4.num = Math.min(i2, u6), true;
  468. }
  469. };
  470. e([d({ constructOnly: true })], C.prototype, "url", void 0), e([d({ constructOnly: true })], C.prototype, "objectIdField", void 0), e([d({ constructOnly: true })], C.prototype, "globalIdField", void 0), e([d({ constructOnly: true })], C.prototype, "capabilities", void 0), e([d({ constructOnly: true })], C.prototype, "sourceSpatialReference", void 0), e([d({ constructOnly: true })], C.prototype, "spatialReference", void 0), e([d({ constructOnly: true })], C.prototype, "store", void 0), e([d({ readOnly: true })], C.prototype, "minimumVerticesPerFeature", null), e([d()], C.prototype, "filter", null), e([d()], C.prototype, "customParameters", null), e([d({ readOnly: true })], C.prototype, "configuration", null), e([d()], C.prototype, "tileInfo", null), e([d()], C.prototype, "tileSize", null), e([d()], C.prototype, "tilesOfInterest", void 0), e([d({ readOnly: true })], C.prototype, "updating", null), e([d({ readOnly: true })], C.prototype, "availability", void 0), C = e([n2("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")], C);
  471. var j2 = 2e3;
  472. var x2 = 6e5;
  473. var E2 = 1e6;
  474. var w2 = 25;
  475. var q = 1;
  476. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileCache.js
  477. var t2 = class {
  478. constructor() {
  479. this._store = new Map(), this._byteSize = 0;
  480. }
  481. set(t3, e4) {
  482. this.delete(t3), this._store.set(t3, e4), this._byteSize += e4.byteSize;
  483. }
  484. delete(t3) {
  485. const e4 = this._store.get(t3);
  486. return !!this._store.delete(t3) && (this._byteSize -= e4.byteSize, true);
  487. }
  488. get(t3) {
  489. return this._used(t3), this._store.get(t3);
  490. }
  491. has(t3) {
  492. return this._used(t3), this._store.has(t3);
  493. }
  494. clear() {
  495. this._store.clear();
  496. }
  497. applyByteSizeLimit(t3, e4) {
  498. for (const [s2, r4] of this._store) {
  499. if (this._byteSize <= t3)
  500. break;
  501. this.delete(s2), e4(r4);
  502. }
  503. }
  504. values() {
  505. return this._store.values();
  506. }
  507. [Symbol.iterator]() {
  508. return this._store[Symbol.iterator]();
  509. }
  510. _used(t3) {
  511. const e4 = this._store.get(t3);
  512. e4 && (this._store.delete(t3), this._store.set(t3, e4));
  513. }
  514. };
  515. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js
  516. var v2 = class extends y {
  517. constructor(e4) {
  518. super(e4), this.tileInfo = null, this.extent = null, this.maximumByteSize = 10 * o.MEGABYTES, this.tileBounds = new h(), this.tiles = new t2(), this.refCounts = new Map(), this.tileFeatureCounts = new Map(), this.tmpBoundingRect = u2();
  519. }
  520. add(e4, t3) {
  521. const s2 = [];
  522. for (const i2 of t3)
  523. this._referenceFeature(i2.objectId) === w3.ADDED && s2.push(i2);
  524. this._addTileStorage(e4, new Set(t3.map(({ objectId: e5 }) => e5)), y3(t3)), this.featureStore.addMany(s2), this.tiles.applyByteSizeLimit(this.maximumByteSize, (e5) => this._removeTileStorage(e5));
  525. }
  526. destroy() {
  527. this.clear(), this.tileFeatureCounts.clear();
  528. }
  529. clear() {
  530. this.featureStore.clear(), this.tileBounds.clear(), this.tiles.clear(), this.refCounts.clear();
  531. }
  532. refresh() {
  533. this.clear(), this.tileFeatureCounts.clear();
  534. }
  535. processEdits(e4, t3, s2) {
  536. return this._processEditsDelete(e4.deletedFeatures.concat(e4.updatedFeatures)), this._processEditsRefetch(e4.addedFeatures.concat(e4.updatedFeatures), t3, s2);
  537. }
  538. _addTileStorage(e4, t3, s2) {
  539. this.tiles.set(e4.id, new S4(e4, t3, s2)), this.tileBounds.set(e4.id, e4.extent), this.tileFeatureCounts.set(e4.id, t3.size);
  540. }
  541. _remove({ id: e4 }) {
  542. const t3 = this.tiles.get(e4);
  543. t3 && this._removeTileStorage(t3);
  544. }
  545. _removeTileStorage(e4) {
  546. const t3 = [];
  547. for (const i2 of e4.objectIds)
  548. this._unreferenceFeature(i2) === w3.REMOVED && t3.push(i2);
  549. this.featureStore.removeManyById(t3);
  550. const s2 = e4.data.id;
  551. this.tiles.delete(s2), this.tileBounds.delete(s2);
  552. }
  553. _processEditsDelete(e4) {
  554. this.featureStore.removeManyById(e4);
  555. for (const [, t3] of this.tiles) {
  556. for (const s2 of e4)
  557. t3.objectIds.delete(s2);
  558. this.tileFeatureCounts.set(t3.data.id, t3.objectIds.size);
  559. }
  560. for (const t3 of e4)
  561. this.refCounts.delete(t3);
  562. }
  563. async _processEditsRefetch(e4, t3, s2) {
  564. const i2 = (await t3(e4, s2)).features, { hasZ: r4, hasM: n4 } = this.featureStore;
  565. for (const l2 of i2) {
  566. const e5 = ge(this.tmpBoundingRect, l2.geometry, r4, n4);
  567. t(e5) || this.tileBounds.forEachInBounds(e5, (e6) => {
  568. const t4 = this.tiles.get(e6);
  569. this.featureStore.add(l2), t4.objectIds.has(l2.objectId) || (t4.objectIds.add(l2.objectId), this._referenceFeature(l2.objectId), this.tileFeatureCounts.set(t4.data.id, t4.objectIds.size));
  570. });
  571. }
  572. }
  573. process(e4, t3 = () => true) {
  574. if (t(this.tileInfo) || !e4.extent || r(this.extent) && !E(c(this.extent, this.tmpBoundingRect), e4.extent))
  575. return new I(e4);
  576. if (this.tiles.has(e4.id))
  577. return new I(e4);
  578. const s2 = this._createTileTree(e4, this.tileInfo);
  579. return this._simplify(s2, t3, null, 0, 1), this._collectMissingTiles(e4, s2, this.tileInfo);
  580. }
  581. get debugInfo() {
  582. return Array.from(this.tiles.values()).map(({ data: e4 }) => ({ data: e4, featureCount: this.tileFeatureCounts.get(e4.id) || 0 }));
  583. }
  584. getFeatureCount(e4) {
  585. return this.tileFeatureCounts.get(e4.id) ?? 0;
  586. }
  587. async fetchCount(e4, t3, s2, i2) {
  588. const r4 = this.tileFeatureCounts.get(e4.id);
  589. if (r4 != null)
  590. return r4;
  591. const o3 = await S2(t3, s2, i2);
  592. return this.tileFeatureCounts.set(e4.id, o3.data.count), o3.data.count;
  593. }
  594. _createTileTree(e4, t3) {
  595. const s2 = new T3(e4.level, e4.row, e4.col);
  596. return t3.updateTileInfo(s2, S.ExtrapolateOptions.POWER_OF_TWO), this.tileBounds.forEachInBounds(e4.extent, (i2) => {
  597. const r4 = this.tiles.get(i2).data;
  598. this._tilesAreRelated(e4, r4) && this._populateChildren(s2, r4, t3, this.tileFeatureCounts.get(r4.id) || 0);
  599. }), s2;
  600. }
  601. _tilesAreRelated(e4, t3) {
  602. if (!e4 || !t3)
  603. return false;
  604. if (e4.level === t3.level)
  605. return e4.row === t3.row && e4.col === t3.col;
  606. const s2 = e4.level < t3.level, i2 = s2 ? e4 : t3, r4 = s2 ? t3 : e4, o3 = 1 << r4.level - i2.level;
  607. return Math.floor(r4.row / o3) === i2.row && Math.floor(r4.col / o3) === i2.col;
  608. }
  609. _populateChildren(e4, t3, s2, i2) {
  610. const r4 = t3.level - e4.level - 1;
  611. if (r4 < 0)
  612. return void (e4.isLeaf = true);
  613. const o3 = t3.row >> r4, l2 = t3.col >> r4, a2 = e4.row << 1, c4 = l2 - (e4.col << 1) + (o3 - a2 << 1), h2 = e4.children[c4];
  614. if (r(h2))
  615. this._populateChildren(h2, t3, s2, i2);
  616. else {
  617. const r5 = new T3(e4.level + 1, o3, l2);
  618. s2.updateTileInfo(r5, S.ExtrapolateOptions.POWER_OF_TWO), e4.children[c4] = r5, this._populateChildren(r5, t3, s2, i2);
  619. }
  620. }
  621. _simplify(e4, t3, s2, i2, r4) {
  622. const o3 = r4 * r4;
  623. if (e4.isLeaf)
  624. return t3(this.getFeatureCount(e4), r4) ? 0 : (this._remove(e4), r(s2) && (s2.children[i2] = null), o3);
  625. const l2 = r4 / 2, a2 = l2 * l2;
  626. let c4 = 0;
  627. for (let h2 = 0; h2 < e4.children.length; h2++) {
  628. const s3 = e4.children[h2];
  629. c4 += r(s3) ? this._simplify(s3, t3, e4, h2, l2) : a2;
  630. }
  631. return c4 === 0 ? this._mergeChildren(e4) : 1 - c4 / o3 < F && (this._purge(e4), r(s2) && (s2.children[i2] = null), c4 = o3), c4;
  632. }
  633. _mergeChildren(e4) {
  634. const t3 = new Set();
  635. let s2 = 0;
  636. this._forEachLeaf(e4, (e5) => {
  637. const i2 = this.tiles.get(e5.id);
  638. if (i2) {
  639. s2 += i2.byteSize;
  640. for (const e6 of i2.objectIds)
  641. t3.has(e6) || (t3.add(e6), this._referenceFeature(e6));
  642. this._remove(e5);
  643. }
  644. }), this._addTileStorage(e4, t3, s2), e4.isLeaf = true, e4.children[0] = e4.children[1] = e4.children[2] = e4.children[3] = null, this.tileFeatureCounts.set(e4.id, t3.size);
  645. }
  646. _forEachLeaf(e4, t3) {
  647. for (const s2 of e4.children)
  648. t(s2) || (s2.isLeaf ? t3(s2) : this._forEachLeaf(s2, t3));
  649. }
  650. _purge(e4) {
  651. if (!t(e4))
  652. if (e4.isLeaf)
  653. this._remove(e4);
  654. else
  655. for (let t3 = 0; t3 < e4.children.length; t3++) {
  656. const s2 = e4.children[t3];
  657. this._purge(s2), e4.children[t3] = null;
  658. }
  659. }
  660. _collectMissingTiles(e4, t3, s2) {
  661. const i2 = new j3(s2, e4, this.extent);
  662. return this._collectMissingTilesRecurse(t3, i2, 1), i2.info;
  663. }
  664. _collectMissingTilesRecurse(e4, t3, s2) {
  665. if (e4.isLeaf)
  666. return;
  667. if (!e4.hasChildren)
  668. return void t3.addMissing(e4.level, e4.row, e4.col, s2);
  669. const i2 = s2 / 2;
  670. for (let r4 = 0; r4 < e4.children.length; r4++) {
  671. const s3 = e4.children[r4];
  672. t(s3) ? t3.addMissing(e4.level + 1, (e4.row << 1) + ((2 & r4) >> 1), (e4.col << 1) + (1 & r4), i2) : this._collectMissingTilesRecurse(s3, t3, i2);
  673. }
  674. }
  675. _referenceFeature(e4) {
  676. const t3 = (this.refCounts.get(e4) || 0) + 1;
  677. return this.refCounts.set(e4, t3), t3 === 1 ? w3.ADDED : w3.UNCHANGED;
  678. }
  679. _unreferenceFeature(e4) {
  680. const t3 = (this.refCounts.get(e4) || 0) - 1;
  681. return t3 === 0 ? (this.refCounts.delete(e4), w3.REMOVED) : (t3 > 0 && this.refCounts.set(e4, t3), w3.UNCHANGED);
  682. }
  683. get test() {
  684. return { tiles: Array.from(this.tiles.values()).map((e4) => `${e4.data.id}:[${Array.from(e4.objectIds)}]`), featureReferences: Array.from(this.refCounts.keys()).map((e4) => `${e4}:${this.refCounts.get(e4)}`) };
  685. }
  686. };
  687. function y3(e4) {
  688. return e4.reduce((e5, t3) => e5 + C2(t3), 0);
  689. }
  690. function C2(e4) {
  691. return 32 + E3(e4.geometry) + r2(e4.attributes);
  692. }
  693. function E3(e4) {
  694. if (t(e4))
  695. return 0;
  696. const t3 = e3(e4.lengths, 4);
  697. return 32 + e3(e4.coords, 8) + t3;
  698. }
  699. e([d({ constructOnly: true })], v2.prototype, "featureStore", void 0), e([d()], v2.prototype, "tileInfo", void 0), e([d()], v2.prototype, "extent", void 0), e([d()], v2.prototype, "maximumByteSize", void 0), v2 = e([n2("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTileStore")], v2);
  700. var S4 = class {
  701. constructor(e4, t3, s2) {
  702. this.data = e4, this.objectIds = t3, this.byteSize = s2;
  703. }
  704. };
  705. var T3 = class {
  706. constructor(e4, t3, s2) {
  707. this.level = e4, this.row = t3, this.col = s2, this.isLeaf = false, this.extent = null, this.children = [null, null, null, null];
  708. }
  709. get hasChildren() {
  710. return !this.isLeaf && (r(this.children[0]) || r(this.children[1]) || r(this.children[2]) || r(this.children[3]));
  711. }
  712. };
  713. var I = class {
  714. constructor(e4, t3 = []) {
  715. this.missingTiles = t3, this.fullArea = 0, this.coveredArea = 0, this.fullArea = y2(e4.extent), this.coveredArea = this.fullArea;
  716. }
  717. prepend(e4) {
  718. this.missingTiles = e4.missingTiles.concat(this.missingTiles), this.coveredArea += e4.coveredArea, this.fullArea += e4.fullArea;
  719. }
  720. };
  721. var j3 = class {
  722. constructor(e4, t3, s2) {
  723. this.tileInfo = e4, this.extent = null, this.info = new I(t3), r(s2) && (this.extent = c(s2));
  724. }
  725. addMissing(e4, t3, s2, i2) {
  726. const r4 = { id: null, level: e4, row: t3, col: s2 };
  727. this.tileInfo.updateTileInfo(r4, S.ExtrapolateOptions.POWER_OF_TWO), t(r4.extent) || r(this.extent) && !E(this.extent, r4.extent) || (this.info.missingTiles.push({ data: r4, resolution: i2 }), this.info.coveredArea -= y2(r4.extent));
  728. }
  729. };
  730. var F = 0.18751;
  731. var w3;
  732. !function(e4) {
  733. e4[e4.ADDED = 0] = "ADDED", e4[e4.REMOVED = 1] = "REMOVED", e4[e4.UNCHANGED = 2] = "UNCHANGED";
  734. }(w3 || (w3 = {}));
  735. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js
  736. var I2 = class extends n3.EventedAccessor {
  737. constructor() {
  738. super(...arguments), this.isInitializing = true, this.whenSetup = T(), this.handles = new u(), this.updatingHandles = new c2(), this.pendingApplyEdits = new Map();
  739. }
  740. get updating() {
  741. return this.featureFetcher.updating || this.isInitializing || this.updatingHandles.updating;
  742. }
  743. destroy() {
  744. this.featureFetcher.destroy(), this.queryEngine.destroy(), this.featureStore.clear(), this.handles.destroy();
  745. }
  746. async setup(e4) {
  747. const { geometryType: t3, objectIdField: i2, timeInfo: r4, fields: s2 } = e4.serviceInfo;
  748. return this.featureStore = new u3({ ...e4.serviceInfo, hasZ: false, hasM: false }), this.queryEngine = new Y({ spatialReference: e4.spatialReference, featureStore: this.featureStore, geometryType: t3, fields: s2, hasZ: false, hasM: false, objectIdField: i2, timeInfo: r4 ? v.fromJSON(r4) : null }), this.featureFetcher = new C({ store: new v2({ featureStore: this.featureStore }), url: e4.serviceInfo.url, objectIdField: e4.serviceInfo.objectIdField, globalIdField: e4.serviceInfo.globalIdField, capabilities: e4.serviceInfo.capabilities, spatialReference: k.fromJSON(e4.spatialReference), sourceSpatialReference: k.fromJSON(e4.serviceInfo.spatialReference) }), this.handles.add([l(() => this.featureFetcher.availability, (e5) => this.emit("notify-availability", { availability: e5 }), U), l(() => this.updating, () => this._notifyUpdating())]), this.whenSetup.resolve(), this.isInitializing = false, this.configure(e4.configuration);
  749. }
  750. async configure(e4) {
  751. return await this.updatingHandles.addPromise(this.whenSetup.promise), this._updateFeatureFetcherConfiguration(e4), { result: {} };
  752. }
  753. async fetchCandidates(e4, t3) {
  754. await this.whenSetup.promise, f(t3);
  755. return { result: await this.queryEngine.executeQueryForSnapping({ point: e4.point, distance: e4.distance, types: e4.types, query: r(e4.filter) ? e4.filter : { where: "1=1" } }, r(t3) ? t3.signal : null) };
  756. }
  757. async updateTiles(e4, t3) {
  758. return await this.updatingHandles.addPromise(this.whenSetup.promise), f(t3), this.featureFetcher.tileSize = e4.tileSize, this.featureFetcher.tilesOfInterest = e4.tiles, this.featureFetcher.tileInfo = r(e4.tileInfo) ? S.fromJSON(e4.tileInfo) : null, { result: {} };
  759. }
  760. async refresh(e4, t3) {
  761. return await this.updatingHandles.addPromise(this.whenSetup.promise), f(t3), this.featureFetcher.refresh(), { result: {} };
  762. }
  763. async whenNotUpdating(e4, t3) {
  764. return await this.updatingHandles.addPromise(this.whenSetup.promise), f(t3), await j(() => !this.updating, t3), f(t3), { result: {} };
  765. }
  766. async getDebugInfo(e4, t3) {
  767. return f(t3), { result: this.featureFetcher.debugInfo };
  768. }
  769. async beginApplyEdits(e4, t3) {
  770. this.updatingHandles.addPromise(this.whenSetup.promise), f(t3);
  771. const i2 = T();
  772. return this.pendingApplyEdits.set(e4.id, i2), this.featureFetcher.applyEdits(i2.promise), this.updatingHandles.addPromise(i2.promise), { result: {} };
  773. }
  774. async endApplyEdits(e4, t3) {
  775. const i2 = this.pendingApplyEdits.get(e4.id);
  776. return i2 && i2.resolve(e4.edits), f(t3), { result: {} };
  777. }
  778. _updateFeatureFetcherConfiguration(e4) {
  779. this.featureFetcher.filter = r(e4.filter) ? b.fromJSON(e4.filter) : null, this.featureFetcher.customParameters = e4.customParameters;
  780. }
  781. _notifyUpdating() {
  782. this.emit("notify-updating", { updating: this.updating });
  783. }
  784. };
  785. function w4() {
  786. return new I2();
  787. }
  788. e([d({ readOnly: true })], I2.prototype, "updating", null), e([d()], I2.prototype, "isInitializing", void 0), I2 = e([n2("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")], I2);
  789. export {
  790. I2 as FeatureServiceSnappingSourceWorker,
  791. w4 as default
  792. };
  793. //# sourceMappingURL=FeatureServiceSnappingSourceWorker-O4IDMMDZ.js.map