chunk-4GGRJYTB.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. import {
  2. a
  3. } from "./chunk-QOV6ITMI.js";
  4. import {
  5. n5 as n
  6. } from "./chunk-Y3WMVFTW.js";
  7. import {
  8. q,
  9. v2 as v,
  10. y2 as y
  11. } from "./chunk-GZT4BVFP.js";
  12. // node_modules/@arcgis/core/core/libs/rbush/PooledRBush.js
  13. var h = class {
  14. constructor(t = 9, i) {
  15. this.compareMinX = l, this.compareMinY = c, this._toBBox = (t2) => t2, this._maxEntries = Math.max(4, t || 9), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), i && (typeof i == "function" ? this._toBBox = i : this._initFormat(i)), this.clear();
  16. }
  17. destroy() {
  18. this.clear(), g.prune(), M.prune(), X.prune(), Y.prune();
  19. }
  20. all(t) {
  21. this._all(this.data, t);
  22. }
  23. search(t, i) {
  24. let n2 = this.data;
  25. const e = this._toBBox;
  26. if (p(t, n2))
  27. for (g.clear(); n2; ) {
  28. for (let s = 0, h2 = n2.children.length; s < h2; s++) {
  29. const h3 = n2.children[s], a3 = n2.leaf ? e(h3) : h3;
  30. p(t, a3) && (n2.leaf ? i(h3) : f(t, a3) ? this._all(h3, i) : g.push(h3));
  31. }
  32. n2 = g.pop();
  33. }
  34. }
  35. collides(t) {
  36. let i = this.data;
  37. const n2 = this._toBBox;
  38. if (!p(t, i))
  39. return false;
  40. for (g.clear(); i; ) {
  41. for (let e = 0, s = i.children.length; e < s; e++) {
  42. const s2 = i.children[e], h2 = i.leaf ? n2(s2) : s2;
  43. if (p(t, h2)) {
  44. if (i.leaf || f(t, h2))
  45. return true;
  46. g.push(s2);
  47. }
  48. }
  49. i = g.pop();
  50. }
  51. return false;
  52. }
  53. load(t) {
  54. if (!t.length)
  55. return this;
  56. if (t.length < this._minEntries) {
  57. for (let i2 = 0, n2 = t.length; i2 < n2; i2++)
  58. this.insert(t[i2]);
  59. return this;
  60. }
  61. let i = this._build(t.slice(0, t.length), 0, t.length - 1, 0);
  62. if (this.data.children.length)
  63. if (this.data.height === i.height)
  64. this._splitRoot(this.data, i);
  65. else {
  66. if (this.data.height < i.height) {
  67. const t2 = this.data;
  68. this.data = i, i = t2;
  69. }
  70. this._insert(i, this.data.height - i.height - 1, true);
  71. }
  72. else
  73. this.data = i;
  74. return this;
  75. }
  76. insert(t) {
  77. return t && this._insert(t, this.data.height - 1), this;
  78. }
  79. clear() {
  80. return this.data = new b([]), this;
  81. }
  82. remove(i) {
  83. if (!i)
  84. return this;
  85. let e, s = this.data, h2 = null, a3 = 0, r2 = false;
  86. const o2 = this._toBBox(i);
  87. for (X.clear(), Y.clear(); s || X.length > 0; ) {
  88. if (s || (s = q(X.pop()), h2 = X.data[X.length - 1], a3 = Y.pop() ?? 0, r2 = true), s.leaf && (e = v(s.children, i, s.children.length, s.indexHint), e !== -1))
  89. return s.children.splice(e, 1), X.push(s), this._condense(X), this;
  90. r2 || s.leaf || !f(s, o2) ? h2 ? (a3++, s = h2.children[a3], r2 = false) : s = null : (X.push(s), Y.push(a3), a3 = 0, h2 = s, s = s.children[0]);
  91. }
  92. return this;
  93. }
  94. toJSON() {
  95. return this.data;
  96. }
  97. fromJSON(t) {
  98. return this.data = t, this;
  99. }
  100. _all(t, i) {
  101. let n2 = t;
  102. for (M.clear(); n2; ) {
  103. if (n2.leaf === true)
  104. for (const t2 of n2.children)
  105. i(t2);
  106. else
  107. M.pushArray(n2.children);
  108. n2 = M.pop() ?? null;
  109. }
  110. }
  111. _build(t, i, n2, e) {
  112. const s = n2 - i + 1;
  113. let h2 = this._maxEntries;
  114. if (s <= h2) {
  115. const e2 = new b(t.slice(i, n2 + 1));
  116. return a2(e2, this._toBBox), e2;
  117. }
  118. e || (e = Math.ceil(Math.log(s) / Math.log(h2)), h2 = Math.ceil(s / h2 ** (e - 1)));
  119. const r2 = new j([]);
  120. r2.height = e;
  121. const o2 = Math.ceil(s / h2), l2 = o2 * Math.ceil(Math.sqrt(h2));
  122. _(t, i, n2, l2, this.compareMinX);
  123. for (let a3 = i; a3 <= n2; a3 += l2) {
  124. const i2 = Math.min(a3 + l2 - 1, n2);
  125. _(t, a3, i2, o2, this.compareMinY);
  126. for (let n3 = a3; n3 <= i2; n3 += o2) {
  127. const s2 = Math.min(n3 + o2 - 1, i2);
  128. r2.children.push(this._build(t, n3, s2, e - 1));
  129. }
  130. }
  131. return a2(r2, this._toBBox), r2;
  132. }
  133. _chooseSubtree(t, i, n2, e) {
  134. for (; e.push(i), i.leaf !== true && e.length - 1 !== n2; ) {
  135. let n3, e2 = 1 / 0, s = 1 / 0;
  136. for (let h2 = 0, a3 = i.children.length; h2 < a3; h2++) {
  137. const a4 = i.children[h2], r2 = m(a4), o2 = u(t, a4) - r2;
  138. o2 < s ? (s = o2, e2 = r2 < e2 ? r2 : e2, n3 = a4) : o2 === s && r2 < e2 && (e2 = r2, n3 = a4);
  139. }
  140. i = n3 || i.children[0];
  141. }
  142. return i;
  143. }
  144. _insert(t, i, n2) {
  145. const e = this._toBBox, s = n2 ? t : e(t);
  146. X.clear();
  147. const h2 = this._chooseSubtree(s, this.data, i, X);
  148. for (h2.children.push(t), o(h2, s); i >= 0 && X.data[i].children.length > this._maxEntries; )
  149. this._split(X, i), i--;
  150. this._adjustParentBBoxes(s, X, i);
  151. }
  152. _split(t, i) {
  153. const n2 = t.data[i], e = n2.children.length, s = this._minEntries;
  154. this._chooseSplitAxis(n2, s, e);
  155. const h2 = this._chooseSplitIndex(n2, s, e);
  156. if (!h2)
  157. return void console.log(" Error: assertion failed at PooledRBush._split: no valid split index");
  158. const r2 = n2.children.splice(h2, n2.children.length - h2), o2 = n2.leaf ? new b(r2) : new j(r2);
  159. o2.height = n2.height, a2(n2, this._toBBox), a2(o2, this._toBBox), i ? t.data[i - 1].children.push(o2) : this._splitRoot(n2, o2);
  160. }
  161. _splitRoot(t, i) {
  162. this.data = new j([t, i]), this.data.height = t.height + 1, a2(this.data, this._toBBox);
  163. }
  164. _chooseSplitIndex(t, i, n2) {
  165. let e, s, h2;
  166. e = s = 1 / 0;
  167. for (let a3 = i; a3 <= n2 - i; a3++) {
  168. const i2 = r(t, 0, a3, this._toBBox), o2 = r(t, a3, n2, this._toBBox), l2 = x(i2, o2), c2 = m(i2) + m(o2);
  169. l2 < e ? (e = l2, h2 = a3, s = c2 < s ? c2 : s) : l2 === e && c2 < s && (s = c2, h2 = a3);
  170. }
  171. return h2;
  172. }
  173. _chooseSplitAxis(t, i, n2) {
  174. const e = t.leaf ? this.compareMinX : l, s = t.leaf ? this.compareMinY : c;
  175. this._allDistMargin(t, i, n2, e) < this._allDistMargin(t, i, n2, s) && t.children.sort(e);
  176. }
  177. _allDistMargin(t, i, n2, e) {
  178. t.children.sort(e);
  179. const s = this._toBBox, h2 = r(t, 0, i, s), a3 = r(t, n2 - i, n2, s);
  180. let l2 = d(h2) + d(a3);
  181. for (let r2 = i; r2 < n2 - i; r2++) {
  182. const i2 = t.children[r2];
  183. o(h2, t.leaf ? s(i2) : i2), l2 += d(h2);
  184. }
  185. for (let r2 = n2 - i - 1; r2 >= i; r2--) {
  186. const i2 = t.children[r2];
  187. o(a3, t.leaf ? s(i2) : i2), l2 += d(a3);
  188. }
  189. return l2;
  190. }
  191. _adjustParentBBoxes(t, i, n2) {
  192. for (let e = n2; e >= 0; e--)
  193. o(i.data[e], t);
  194. }
  195. _condense(i) {
  196. for (let n2 = i.length - 1; n2 >= 0; n2--) {
  197. const e = i.data[n2];
  198. if (e.children.length === 0)
  199. if (n2 > 0) {
  200. const s = i.data[n2 - 1], h2 = s.children;
  201. h2.splice(v(h2, e, h2.length, s.indexHint), 1);
  202. } else
  203. this.clear();
  204. else
  205. a2(e, this._toBBox);
  206. }
  207. }
  208. _initFormat(t) {
  209. const i = ["return a", " - b", ";"];
  210. this.compareMinX = new Function("a", "b", i.join(t[0])), this.compareMinY = new Function("a", "b", i.join(t[1])), this._toBBox = new Function("a", "return {minX: a" + t[0] + ", minY: a" + t[1] + ", maxX: a" + t[2] + ", maxY: a" + t[3] + "};");
  211. }
  212. };
  213. function a2(t, i) {
  214. r(t, 0, t.children.length, i, t);
  215. }
  216. function r(t, i, n2, e, s) {
  217. s || (s = new b([])), s.minX = 1 / 0, s.minY = 1 / 0, s.maxX = -1 / 0, s.maxY = -1 / 0;
  218. for (let h2, a3 = i; a3 < n2; a3++)
  219. h2 = t.children[a3], o(s, t.leaf ? e(h2) : h2);
  220. return s;
  221. }
  222. function o(t, i) {
  223. t.minX = Math.min(t.minX, i.minX), t.minY = Math.min(t.minY, i.minY), t.maxX = Math.max(t.maxX, i.maxX), t.maxY = Math.max(t.maxY, i.maxY);
  224. }
  225. function l(t, i) {
  226. return t.minX - i.minX;
  227. }
  228. function c(t, i) {
  229. return t.minY - i.minY;
  230. }
  231. function m(t) {
  232. return (t.maxX - t.minX) * (t.maxY - t.minY);
  233. }
  234. function d(t) {
  235. return t.maxX - t.minX + (t.maxY - t.minY);
  236. }
  237. function u(t, i) {
  238. return (Math.max(i.maxX, t.maxX) - Math.min(i.minX, t.minX)) * (Math.max(i.maxY, t.maxY) - Math.min(i.minY, t.minY));
  239. }
  240. function x(t, i) {
  241. const n2 = Math.max(t.minX, i.minX), e = Math.max(t.minY, i.minY), s = Math.min(t.maxX, i.maxX), h2 = Math.min(t.maxY, i.maxY);
  242. return Math.max(0, s - n2) * Math.max(0, h2 - e);
  243. }
  244. function f(t, i) {
  245. return t.minX <= i.minX && t.minY <= i.minY && i.maxX <= t.maxX && i.maxY <= t.maxY;
  246. }
  247. function p(t, i) {
  248. return i.minX <= t.maxX && i.minY <= t.maxY && i.maxX >= t.minX && i.maxY >= t.minY;
  249. }
  250. function _(t, i, e, h2, a3) {
  251. const r2 = [i, e];
  252. for (; r2.length; ) {
  253. const i2 = q(r2.pop()), e2 = q(r2.pop());
  254. if (i2 - e2 <= h2)
  255. continue;
  256. const o2 = e2 + Math.ceil((i2 - e2) / h2 / 2) * h2;
  257. a(t, o2, e2, i2, a3), r2.push(e2, o2, o2, i2);
  258. }
  259. }
  260. var g = new n();
  261. var M = new n();
  262. var X = new n();
  263. var Y = new n({ deallocator: void 0 });
  264. var B = class {
  265. constructor() {
  266. this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0;
  267. }
  268. };
  269. var w = class extends B {
  270. constructor() {
  271. super(...arguments), this.height = 1, this.indexHint = new y();
  272. }
  273. };
  274. var b = class extends w {
  275. constructor(t) {
  276. super(), this.children = t, this.leaf = true;
  277. }
  278. };
  279. var j = class extends w {
  280. constructor(t) {
  281. super(), this.children = t, this.leaf = false;
  282. }
  283. };
  284. export {
  285. h
  286. };
  287. //# sourceMappingURL=chunk-4GGRJYTB.js.map