tree-set-typed 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/.eslintrc.js +61 -0
  2. package/.prettierignore +6 -0
  3. package/.prettierrc.js +16 -0
  4. package/LICENSE +21 -0
  5. package/README.md +482 -0
  6. package/coverage/clover.xml +13 -0
  7. package/coverage/coverage-final.json +96 -0
  8. package/coverage/coverage-summary.json +60 -0
  9. package/coverage/lcov-report/base.css +403 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +119 -0
  13. package/coverage/lcov-report/index.ts.html +109 -0
  14. package/coverage/lcov-report/prettify.css +1 -0
  15. package/coverage/lcov-report/prettify.js +2 -0
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +206 -0
  18. package/coverage/lcov.info +14 -0
  19. package/dist/cjs/index.cjs +12 -0
  20. package/dist/cjs/index.cjs.map +1 -0
  21. package/dist/cjs-legacy/index.cjs +12 -0
  22. package/dist/cjs-legacy/index.cjs.map +1 -0
  23. package/dist/esm/index.mjs +3 -0
  24. package/dist/esm/index.mjs.map +1 -0
  25. package/dist/esm-legacy/index.mjs +3 -0
  26. package/dist/esm-legacy/index.mjs.map +1 -0
  27. package/dist/types/common/index.d.ts +12 -0
  28. package/dist/types/constants/index.d.ts +4 -0
  29. package/dist/types/data-structures/base/index.d.ts +2 -0
  30. package/dist/types/data-structures/base/iterable-element-base.d.ts +219 -0
  31. package/dist/types/data-structures/base/iterable-entry-base.d.ts +150 -0
  32. package/dist/types/data-structures/base/linear-base.d.ts +335 -0
  33. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +236 -0
  34. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +197 -0
  35. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +440 -0
  36. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -0
  37. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +807 -0
  38. package/dist/types/data-structures/binary-tree/bst.d.ts +645 -0
  39. package/dist/types/data-structures/binary-tree/index.d.ts +10 -0
  40. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +312 -0
  41. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -0
  42. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +243 -0
  43. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +333 -0
  44. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -0
  45. package/dist/types/data-structures/graph/directed-graph.d.ts +332 -0
  46. package/dist/types/data-structures/graph/index.d.ts +4 -0
  47. package/dist/types/data-structures/graph/map-graph.d.ts +78 -0
  48. package/dist/types/data-structures/graph/undirected-graph.d.ts +347 -0
  49. package/dist/types/data-structures/hash/hash-map.d.ts +428 -0
  50. package/dist/types/data-structures/hash/index.d.ts +1 -0
  51. package/dist/types/data-structures/heap/heap.d.ts +552 -0
  52. package/dist/types/data-structures/heap/index.d.ts +3 -0
  53. package/dist/types/data-structures/heap/max-heap.d.ts +32 -0
  54. package/dist/types/data-structures/heap/min-heap.d.ts +33 -0
  55. package/dist/types/data-structures/index.d.ts +12 -0
  56. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +437 -0
  57. package/dist/types/data-structures/linked-list/index.d.ts +3 -0
  58. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +567 -0
  59. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -0
  60. package/dist/types/data-structures/matrix/index.d.ts +2 -0
  61. package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
  62. package/dist/types/data-structures/matrix/navigator.d.ts +55 -0
  63. package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
  64. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -0
  65. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -0
  66. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -0
  67. package/dist/types/data-structures/queue/deque.d.ts +459 -0
  68. package/dist/types/data-structures/queue/index.d.ts +2 -0
  69. package/dist/types/data-structures/queue/queue.d.ts +364 -0
  70. package/dist/types/data-structures/stack/index.d.ts +1 -0
  71. package/dist/types/data-structures/stack/stack.d.ts +324 -0
  72. package/dist/types/data-structures/tree/index.d.ts +1 -0
  73. package/dist/types/data-structures/tree/tree.d.ts +62 -0
  74. package/dist/types/data-structures/trie/index.d.ts +1 -0
  75. package/dist/types/data-structures/trie/trie.d.ts +412 -0
  76. package/dist/types/index.d.ts +23 -0
  77. package/dist/types/interfaces/binary-tree.d.ts +60 -0
  78. package/dist/types/interfaces/doubly-linked-list.d.ts +1 -0
  79. package/dist/types/interfaces/graph.d.ts +21 -0
  80. package/dist/types/interfaces/heap.d.ts +1 -0
  81. package/dist/types/interfaces/index.d.ts +8 -0
  82. package/dist/types/interfaces/navigator.d.ts +1 -0
  83. package/dist/types/interfaces/priority-queue.d.ts +1 -0
  84. package/dist/types/interfaces/segment-tree.d.ts +1 -0
  85. package/dist/types/interfaces/singly-linked-list.d.ts +1 -0
  86. package/dist/types/types/common.d.ts +15 -0
  87. package/dist/types/types/data-structures/base/base.d.ts +13 -0
  88. package/dist/types/types/data-structures/base/index.d.ts +1 -0
  89. package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  90. package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  91. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  92. package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  93. package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
  94. package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
  95. package/dist/types/types/data-structures/binary-tree/index.d.ts +9 -0
  96. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  97. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  98. package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  99. package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  100. package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
  101. package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
  102. package/dist/types/types/data-structures/graph/index.d.ts +3 -0
  103. package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
  104. package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
  105. package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
  106. package/dist/types/types/data-structures/hash/index.d.ts +2 -0
  107. package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
  108. package/dist/types/types/data-structures/heap/index.d.ts +1 -0
  109. package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
  110. package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
  111. package/dist/types/types/data-structures/index.d.ts +12 -0
  112. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
  113. package/dist/types/types/data-structures/linked-list/index.d.ts +3 -0
  114. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
  115. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
  116. package/dist/types/types/data-structures/matrix/index.d.ts +2 -0
  117. package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
  118. package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
  119. package/dist/types/types/data-structures/priority-queue/index.d.ts +3 -0
  120. package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  121. package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  122. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
  123. package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
  124. package/dist/types/types/data-structures/queue/index.d.ts +2 -0
  125. package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
  126. package/dist/types/types/data-structures/stack/index.d.ts +1 -0
  127. package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
  128. package/dist/types/types/data-structures/tree/index.d.ts +1 -0
  129. package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
  130. package/dist/types/types/data-structures/trie/index.d.ts +1 -0
  131. package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
  132. package/dist/types/types/index.d.ts +3 -0
  133. package/dist/types/types/utils/index.d.ts +2 -0
  134. package/dist/types/types/utils/utils.d.ts +22 -0
  135. package/dist/types/types/utils/validate-type.d.ts +19 -0
  136. package/dist/types/utils/index.d.ts +2 -0
  137. package/dist/types/utils/number.d.ts +14 -0
  138. package/dist/types/utils/utils.d.ts +209 -0
  139. package/dist/umd/red-black-tree-typed.js +14578 -0
  140. package/dist/umd/red-black-tree-typed.js.map +1 -0
  141. package/dist/umd/red-black-tree-typed.min.js +44 -0
  142. package/dist/umd/red-black-tree-typed.min.js.map +1 -0
  143. package/docs/.nojekyll +1 -0
  144. package/docs/assets/highlight.css +92 -0
  145. package/docs/assets/main.js +59 -0
  146. package/docs/assets/navigation.js +1 -0
  147. package/docs/assets/search.js +1 -0
  148. package/docs/assets/style.css +1383 -0
  149. package/docs/classes/AVLTree.html +2046 -0
  150. package/docs/classes/AVLTreeNode.html +263 -0
  151. package/docs/index.html +523 -0
  152. package/docs/modules.html +45 -0
  153. package/jest.config.js +8 -0
  154. package/package.json +113 -0
  155. package/src/common/index.ts +23 -0
  156. package/src/constants/index.ts +4 -0
  157. package/src/data-structures/base/index.ts +2 -0
  158. package/src/data-structures/base/iterable-element-base.ts +352 -0
  159. package/src/data-structures/base/iterable-entry-base.ts +246 -0
  160. package/src/data-structures/base/linear-base.ts +643 -0
  161. package/src/data-structures/binary-tree/avl-tree-counter.ts +539 -0
  162. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +438 -0
  163. package/src/data-structures/binary-tree/avl-tree.ts +840 -0
  164. package/src/data-structures/binary-tree/binary-indexed-tree.ts +331 -0
  165. package/src/data-structures/binary-tree/binary-tree.ts +2492 -0
  166. package/src/data-structures/binary-tree/bst.ts +2024 -0
  167. package/src/data-structures/binary-tree/index.ts +10 -0
  168. package/src/data-structures/binary-tree/red-black-tree.ts +767 -0
  169. package/src/data-structures/binary-tree/segment-tree.ts +324 -0
  170. package/src/data-structures/binary-tree/tree-counter.ts +575 -0
  171. package/src/data-structures/binary-tree/tree-multi-map.ts +549 -0
  172. package/src/data-structures/graph/abstract-graph.ts +1081 -0
  173. package/src/data-structures/graph/directed-graph.ts +715 -0
  174. package/src/data-structures/graph/index.ts +4 -0
  175. package/src/data-structures/graph/map-graph.ts +132 -0
  176. package/src/data-structures/graph/undirected-graph.ts +626 -0
  177. package/src/data-structures/hash/hash-map.ts +813 -0
  178. package/src/data-structures/hash/index.ts +1 -0
  179. package/src/data-structures/heap/heap.ts +1020 -0
  180. package/src/data-structures/heap/index.ts +3 -0
  181. package/src/data-structures/heap/max-heap.ts +47 -0
  182. package/src/data-structures/heap/min-heap.ts +36 -0
  183. package/src/data-structures/index.ts +12 -0
  184. package/src/data-structures/linked-list/doubly-linked-list.ts +876 -0
  185. package/src/data-structures/linked-list/index.ts +3 -0
  186. package/src/data-structures/linked-list/singly-linked-list.ts +1050 -0
  187. package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
  188. package/src/data-structures/matrix/index.ts +2 -0
  189. package/src/data-structures/matrix/matrix.ts +491 -0
  190. package/src/data-structures/matrix/navigator.ts +124 -0
  191. package/src/data-structures/priority-queue/index.ts +3 -0
  192. package/src/data-structures/priority-queue/max-priority-queue.ts +42 -0
  193. package/src/data-structures/priority-queue/min-priority-queue.ts +29 -0
  194. package/src/data-structures/priority-queue/priority-queue.ts +19 -0
  195. package/src/data-structures/queue/deque.ts +1001 -0
  196. package/src/data-structures/queue/index.ts +2 -0
  197. package/src/data-structures/queue/queue.ts +592 -0
  198. package/src/data-structures/stack/index.ts +1 -0
  199. package/src/data-structures/stack/stack.ts +469 -0
  200. package/src/data-structures/tree/index.ts +1 -0
  201. package/src/data-structures/tree/tree.ts +115 -0
  202. package/src/data-structures/trie/index.ts +1 -0
  203. package/src/data-structures/trie/trie.ts +756 -0
  204. package/src/index.ts +24 -0
  205. package/src/interfaces/binary-tree.ts +252 -0
  206. package/src/interfaces/doubly-linked-list.ts +1 -0
  207. package/src/interfaces/graph.ts +44 -0
  208. package/src/interfaces/heap.ts +1 -0
  209. package/src/interfaces/index.ts +8 -0
  210. package/src/interfaces/navigator.ts +1 -0
  211. package/src/interfaces/priority-queue.ts +1 -0
  212. package/src/interfaces/segment-tree.ts +1 -0
  213. package/src/interfaces/singly-linked-list.ts +1 -0
  214. package/src/types/common.ts +25 -0
  215. package/src/types/data-structures/base/base.ts +34 -0
  216. package/src/types/data-structures/base/index.ts +1 -0
  217. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  218. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -0
  219. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -0
  220. package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
  221. package/src/types/data-structures/binary-tree/binary-tree.ts +31 -0
  222. package/src/types/data-structures/binary-tree/bst.ts +19 -0
  223. package/src/types/data-structures/binary-tree/index.ts +9 -0
  224. package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
  225. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
  226. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  227. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -0
  228. package/src/types/data-structures/graph/abstract-graph.ts +18 -0
  229. package/src/types/data-structures/graph/directed-graph.ts +2 -0
  230. package/src/types/data-structures/graph/index.ts +3 -0
  231. package/src/types/data-structures/graph/map-graph.ts +1 -0
  232. package/src/types/data-structures/graph/undirected-graph.ts +1 -0
  233. package/src/types/data-structures/hash/hash-map.ts +19 -0
  234. package/src/types/data-structures/hash/index.ts +3 -0
  235. package/src/types/data-structures/heap/heap.ts +6 -0
  236. package/src/types/data-structures/heap/index.ts +1 -0
  237. package/src/types/data-structures/heap/max-heap.ts +1 -0
  238. package/src/types/data-structures/heap/min-heap.ts +1 -0
  239. package/src/types/data-structures/index.ts +12 -0
  240. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -0
  241. package/src/types/data-structures/linked-list/index.ts +3 -0
  242. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -0
  243. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
  244. package/src/types/data-structures/matrix/index.ts +2 -0
  245. package/src/types/data-structures/matrix/matrix.ts +7 -0
  246. package/src/types/data-structures/matrix/navigator.ts +14 -0
  247. package/src/types/data-structures/priority-queue/index.ts +3 -0
  248. package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
  249. package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
  250. package/src/types/data-structures/priority-queue/priority-queue.ts +3 -0
  251. package/src/types/data-structures/queue/deque.ts +5 -0
  252. package/src/types/data-structures/queue/index.ts +2 -0
  253. package/src/types/data-structures/queue/queue.ts +5 -0
  254. package/src/types/data-structures/stack/index.ts +1 -0
  255. package/src/types/data-structures/stack/stack.ts +3 -0
  256. package/src/types/data-structures/tree/index.ts +1 -0
  257. package/src/types/data-structures/tree/tree.ts +1 -0
  258. package/src/types/data-structures/trie/index.ts +1 -0
  259. package/src/types/data-structures/trie/trie.ts +3 -0
  260. package/src/types/index.ts +3 -0
  261. package/src/types/utils/index.ts +2 -0
  262. package/src/types/utils/utils.ts +33 -0
  263. package/src/types/utils/validate-type.ts +35 -0
  264. package/src/utils/index.ts +2 -0
  265. package/src/utils/number.ts +22 -0
  266. package/src/utils/utils.ts +350 -0
  267. package/test/index.test.ts +111 -0
  268. package/tsconfig.base.json +23 -0
  269. package/tsconfig.json +12 -0
  270. package/tsconfig.test.json +8 -0
  271. package/tsconfig.types.json +15 -0
  272. package/tsup.config.js +28 -0
  273. package/tsup.node.config.js +71 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../node_modules/data-structure-typed/dist/esm-legacy/index.mjs"],"sourcesContent":["/**\n * @packageDocumentation\n * @module tree-set-typed\n * \n * TreeSet - A sorted set implementation based on Red-Black Tree\n * \n * @example\n * ```typescript\n * import { TreeSet } from 'tree-set-typed';\n * \n * const set = new TreeSet<number>();\n * set.add(5);\n * set.add(3);\n * set.add(7);\n * \n * console.log([...set]); // [3, 5, 7] - always sorted\n * console.log(set.has(5)); // true\n * console.log(set.first()); // 3\n * console.log(set.last()); // 7\n * ```\n */\n\nexport { TreeSet } from 'data-structure-typed';\nexport type { TreeSetOptions } from 'data-structure-typed';\n","var __defProp = Object.defineProperty;\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateAdd = (obj, member, value) => member.has(obj) ? __typeError(\"Cannot add the same private member more than once\") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), member.set(obj, value), value);\n\n// src/data-structures/base/iterable-entry-base.ts\nvar _IterableEntryBase = class _IterableEntryBase {\n /**\n * Default iterator yielding `[key, value]` entries.\n * @returns Iterator of `[K, V]`.\n * @remarks Time O(n) to iterate, Space O(1)\n */\n *[Symbol.iterator](...args) {\n yield* this._getIterator(...args);\n }\n /**\n * Iterate over `[key, value]` pairs (may yield `undefined` values).\n * @returns Iterator of `[K, V | undefined]`.\n * @remarks Time O(n), Space O(1)\n */\n *entries() {\n for (const item of this) {\n yield item;\n }\n }\n /**\n * Iterate over keys only.\n * @returns Iterator of keys.\n * @remarks Time O(n), Space O(1)\n */\n *keys() {\n for (const item of this) {\n yield item[0];\n }\n }\n /**\n * Iterate over values only.\n * @returns Iterator of values.\n * @remarks Time O(n), Space O(1)\n */\n *values() {\n for (const item of this) {\n yield item[1];\n }\n }\n /**\n * Test whether all entries satisfy the predicate.\n * @param predicate - `(key, value, index, self) => boolean`.\n * @param thisArg - Optional `this` for callback.\n * @returns `true` if all pass; otherwise `false`.\n * @remarks Time O(n), Space O(1)\n */\n every(predicate, thisArg) {\n let index = 0;\n for (const item of this) {\n if (!predicate.call(thisArg, item[1], item[0], index++, this)) {\n return false;\n }\n }\n return true;\n }\n /**\n * Test whether any entry satisfies the predicate.\n * @param predicate - `(key, value, index, self) => boolean`.\n * @param thisArg - Optional `this` for callback.\n * @returns `true` if any passes; otherwise `false`.\n * @remarks Time O(n), Space O(1)\n */\n some(predicate, thisArg) {\n let index = 0;\n for (const item of this) {\n if (predicate.call(thisArg, item[1], item[0], index++, this)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Visit each entry, left-to-right.\n * @param callbackfn - `(key, value, index, self) => void`.\n * @param thisArg - Optional `this` for callback.\n * @remarks Time O(n), Space O(1)\n */\n forEach(callbackfn, thisArg) {\n let index = 0;\n for (const item of this) {\n const [key, value] = item;\n callbackfn.call(thisArg, value, key, index++, this);\n }\n }\n /**\n * Find the first entry that matches a predicate.\n * @param callbackfn - `(key, value, index, self) => boolean`.\n * @param thisArg - Optional `this` for callback.\n * @returns Matching `[key, value]` or `undefined`.\n * @remarks Time O(n), Space O(1)\n */\n find(callbackfn, thisArg) {\n let index = 0;\n for (const item of this) {\n const [key, value] = item;\n if (callbackfn.call(thisArg, value, key, index++, this)) return item;\n }\n return;\n }\n /**\n * Whether the given key exists.\n * @param key - Key to test.\n * @returns `true` if found; otherwise `false`.\n * @remarks Time O(n) generic, Space O(1)\n */\n has(key) {\n for (const item of this) {\n const [itemKey] = item;\n if (itemKey === key) return true;\n }\n return false;\n }\n /**\n * Whether there exists an entry with the given value.\n * @param value - Value to test.\n * @returns `true` if found; otherwise `false`.\n * @remarks Time O(n), Space O(1)\n */\n hasValue(value) {\n for (const [, elementValue] of this) {\n if (elementValue === value) return true;\n }\n return false;\n }\n /**\n * Get the value under a key.\n * @param key - Key to look up.\n * @returns Value or `undefined`.\n * @remarks Time O(n) generic, Space O(1)\n */\n get(key) {\n for (const item of this) {\n const [itemKey, value] = item;\n if (itemKey === key) return value;\n }\n return;\n }\n /**\n * Reduce entries into a single accumulator.\n * @param callbackfn - `(acc, value, key, index, self) => acc`.\n * @param initialValue - Initial accumulator.\n * @returns Final accumulator.\n * @remarks Time O(n), Space O(1)\n */\n reduce(callbackfn, initialValue) {\n let accumulator = initialValue;\n let index = 0;\n for (const item of this) {\n const [key, value] = item;\n accumulator = callbackfn(accumulator, value, key, index++, this);\n }\n return accumulator;\n }\n /**\n * Converts data structure to `[key, value]` pairs.\n * @returns Array of entries.\n * @remarks Time O(n), Space O(n)\n */\n toArray() {\n return [...this];\n }\n /**\n * Visualize the iterable as an array of `[key, value]` pairs (or a custom string).\n * @returns Array of entries (default) or a string.\n * @remarks Time O(n), Space O(n)\n */\n toVisual() {\n return [...this];\n }\n /**\n * Print a human-friendly representation to the console.\n * @remarks Time O(n), Space O(n)\n */\n print() {\n console.log(this.toVisual());\n }\n};\n__name(_IterableEntryBase, \"IterableEntryBase\");\nvar IterableEntryBase = _IterableEntryBase;\n\n// src/data-structures/base/iterable-element-base.ts\nvar _IterableElementBase = class _IterableElementBase {\n /**\n * Create a new iterable base.\n *\n * @param options Optional behavior overrides. When provided, a `toElementFn`\n * is used to convert a raw element (`R`) into a public element (`E`).\n *\n * @remarks\n * Time O(1), Space O(1).\n */\n constructor(options) {\n /**\n * The converter used to transform a raw element (`R`) into a public element (`E`).\n *\n * @remarks\n * Time O(1), Space O(1).\n */\n __publicField(this, \"_toElementFn\");\n if (options) {\n const { toElementFn } = options;\n if (typeof toElementFn === \"function\") this._toElementFn = toElementFn;\n else if (toElementFn) throw new TypeError(\"toElementFn must be a function type\");\n }\n }\n /**\n * Exposes the current `toElementFn`, if configured.\n *\n * @returns The converter function or `undefined` when not set.\n * @remarks\n * Time O(1), Space O(1).\n */\n get toElementFn() {\n return this._toElementFn;\n }\n /**\n * Returns an iterator over the structure's elements.\n *\n * @param args Optional iterator arguments forwarded to the internal iterator.\n * @returns An `IterableIterator<E>` that yields the elements in traversal order.\n *\n * @remarks\n * Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.\n */\n *[Symbol.iterator](...args) {\n yield* this._getIterator(...args);\n }\n /**\n * Returns an iterator over the values (alias of the default iterator).\n *\n * @returns An `IterableIterator<E>` over all elements.\n * @remarks\n * Creating the iterator is O(1); full iteration is Time O(n), Space O(1).\n */\n *values() {\n for (const item of this) yield item;\n }\n /**\n * Tests whether all elements satisfy the predicate.\n *\n * @template TReturn\n * @param predicate Function invoked for each element with signature `(value, index, self)`.\n * @param thisArg Optional `this` binding for the predicate.\n * @returns `true` if every element passes; otherwise `false`.\n *\n * @remarks\n * Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).\n */\n every(predicate, thisArg) {\n let index = 0;\n for (const item of this) {\n if (thisArg === void 0) {\n if (!predicate(item, index++, this)) return false;\n } else {\n const fn = predicate;\n if (!fn.call(thisArg, item, index++, this)) return false;\n }\n }\n return true;\n }\n /**\n * Tests whether at least one element satisfies the predicate.\n *\n * @param predicate Function invoked for each element with signature `(value, index, self)`.\n * @param thisArg Optional `this` binding for the predicate.\n * @returns `true` if any element passes; otherwise `false`.\n *\n * @remarks\n * Time O(n) in the worst case; may exit early on first success. Space O(1).\n */\n some(predicate, thisArg) {\n let index = 0;\n for (const item of this) {\n if (thisArg === void 0) {\n if (predicate(item, index++, this)) return true;\n } else {\n const fn = predicate;\n if (fn.call(thisArg, item, index++, this)) return true;\n }\n }\n return false;\n }\n /**\n * Invokes a callback for each element in iteration order.\n *\n * @param callbackfn Function invoked per element with signature `(value, index, self)`.\n * @param thisArg Optional `this` binding for the callback.\n * @returns `void`.\n *\n * @remarks\n * Time O(n), Space O(1).\n */\n forEach(callbackfn, thisArg) {\n let index = 0;\n for (const item of this) {\n if (thisArg === void 0) {\n callbackfn(item, index++, this);\n } else {\n const fn = callbackfn;\n fn.call(thisArg, item, index++, this);\n }\n }\n }\n // Implementation signature\n find(predicate, thisArg) {\n let index = 0;\n for (const item of this) {\n if (thisArg === void 0) {\n if (predicate(item, index++, this)) return item;\n } else {\n const fn = predicate;\n if (fn.call(thisArg, item, index++, this)) return item;\n }\n }\n return;\n }\n /**\n * Checks whether a strictly-equal element exists in the structure.\n *\n * @param element The element to test with `===` equality.\n * @returns `true` if an equal element is found; otherwise `false`.\n *\n * @remarks\n * Time O(n) in the worst case. Space O(1).\n */\n has(element) {\n for (const ele of this) if (ele === element) return true;\n return false;\n }\n /**\n * Reduces all elements to a single accumulated value.\n *\n * @overload\n * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.\n * @returns The final accumulated value typed as `E`.\n *\n * @overload\n * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`.\n * @param initialValue The initial accumulator value of type `E`.\n * @returns The final accumulated value typed as `E`.\n *\n * @overload\n * @template U The accumulator type when it differs from `E`.\n * @param callbackfn Reducer of signature `(acc: U, value, index, self) => U`.\n * @param initialValue The initial accumulator value of type `U`.\n * @returns The final accumulated value typed as `U`.\n *\n * @remarks\n * Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.\n */\n reduce(callbackfn, initialValue) {\n let index = 0;\n const iter = this[Symbol.iterator]();\n let acc;\n if (arguments.length >= 2) {\n acc = initialValue;\n } else {\n const first = iter.next();\n if (first.done) throw new TypeError(\"Reduce of empty structure with no initial value\");\n acc = first.value;\n index = 1;\n }\n for (const value of iter) {\n acc = callbackfn(acc, value, index++, this);\n }\n return acc;\n }\n /**\n * Materializes the elements into a new array.\n *\n * @returns A shallow array copy of the iteration order.\n * @remarks\n * Time O(n), Space O(n).\n */\n toArray() {\n return [...this];\n }\n /**\n * Returns a representation of the structure suitable for quick visualization.\n * Defaults to an array of elements; subclasses may override to provide richer visuals.\n *\n * @returns A visual representation (array by default).\n * @remarks\n * Time O(n), Space O(n).\n */\n toVisual() {\n return [...this];\n }\n /**\n * Prints `toVisual()` to the console. Intended for quick debugging.\n *\n * @returns `void`.\n * @remarks\n * Time O(n) due to materialization, Space O(n) for the intermediate representation.\n */\n print() {\n console.log(this.toVisual());\n }\n};\n__name(_IterableElementBase, \"IterableElementBase\");\nvar IterableElementBase = _IterableElementBase;\n\n// src/utils/utils.ts\nvar uuidV4 = /* @__PURE__ */ __name(function() {\n return \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\".replace(/[x]/g, function(c) {\n const r = Math.random() * 16 | 0, v = c == \"x\" ? r : r & 3 | 8;\n return v.toString(16);\n });\n}, \"uuidV4\");\nvar arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {\n let i = -1, len = array ? array.length : 0;\n const result = [];\n while (++i < len) {\n const value = array[i];\n if (predicate(value, i, array)) {\n result.push(value);\n Array.prototype.splice.call(array, i--, 1);\n len--;\n }\n }\n return result;\n}, \"arrayRemove\");\nvar getMSB = /* @__PURE__ */ __name((value) => {\n if (value <= 0) {\n return 0;\n }\n return 1 << 31 - Math.clz32(value);\n}, \"getMSB\");\nvar rangeCheck = /* @__PURE__ */ __name((index, min, max, message = \"Index out of bounds.\") => {\n if (index < min || index > max) throw new RangeError(message);\n}, \"rangeCheck\");\nvar throwRangeError = /* @__PURE__ */ __name((message = \"The value is off-limits.\") => {\n throw new RangeError(message);\n}, \"throwRangeError\");\nvar isWeakKey = /* @__PURE__ */ __name((input) => {\n const inputType = typeof input;\n return inputType === \"object\" && input !== null || inputType === \"function\";\n}, \"isWeakKey\");\nvar calcMinUnitsRequired = /* @__PURE__ */ __name((totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize), \"calcMinUnitsRequired\");\nvar roundFixed = /* @__PURE__ */ __name((num, digit = 10) => {\n const multiplier = Math.pow(10, digit);\n return Math.round(num * multiplier) / multiplier;\n}, \"roundFixed\");\nfunction isPrimitiveComparable(value) {\n const valueType = typeof value;\n if (valueType === \"number\") return true;\n return valueType === \"bigint\" || valueType === \"string\" || valueType === \"boolean\";\n}\n__name(isPrimitiveComparable, \"isPrimitiveComparable\");\nfunction tryObjectToPrimitive(obj) {\n if (typeof obj.valueOf === \"function\") {\n const valueOfResult = obj.valueOf();\n if (valueOfResult !== obj) {\n if (isPrimitiveComparable(valueOfResult)) return valueOfResult;\n if (typeof valueOfResult === \"object\" && valueOfResult !== null) return tryObjectToPrimitive(valueOfResult);\n }\n }\n if (typeof obj.toString === \"function\") {\n const stringResult = obj.toString();\n if (stringResult !== \"[object Object]\") return stringResult;\n }\n return null;\n}\n__name(tryObjectToPrimitive, \"tryObjectToPrimitive\");\nfunction isComparable(value, isForceObjectComparable = false) {\n if (value === null || value === void 0) return false;\n if (isPrimitiveComparable(value)) return true;\n if (typeof value !== \"object\") return false;\n if (value instanceof Date) return true;\n if (isForceObjectComparable) return true;\n const comparableValue = tryObjectToPrimitive(value);\n if (comparableValue === null || comparableValue === void 0) return false;\n return isPrimitiveComparable(comparableValue);\n}\n__name(isComparable, \"isComparable\");\nvar makeTrampolineThunk = /* @__PURE__ */ __name((computation) => ({\n isThunk: true,\n // Marker indicating this is a thunk\n fn: computation\n // The deferred computation function\n}), \"makeTrampolineThunk\");\nvar isTrampolineThunk = /* @__PURE__ */ __name((value) => typeof value === \"object\" && // Must be an object\nvalue !== null && // Must not be null\n\"isThunk\" in value && // Must have the 'isThunk' property\nvalue.isThunk, \"isTrampolineThunk\");\nfunction trampoline(initial) {\n let current = initial;\n while (isTrampolineThunk(current)) {\n current = current.fn();\n }\n return current;\n}\n__name(trampoline, \"trampoline\");\nfunction makeTrampoline(fn) {\n return (...args) => trampoline(fn(...args));\n}\n__name(makeTrampoline, \"makeTrampoline\");\nasync function asyncTrampoline(initial) {\n let current = await initial;\n while (isTrampolineThunk(current)) {\n current = await current.fn();\n }\n return current;\n}\n__name(asyncTrampoline, \"asyncTrampoline\");\nfunction makeAsyncTrampoline(fn) {\n return async (...args) => {\n return asyncTrampoline(fn(...args));\n };\n}\n__name(makeAsyncTrampoline, \"makeAsyncTrampoline\");\n\n// src/utils/number.ts\nfunction toBinaryString(num, digit = 32) {\n let binaryString = (num >>> 0).toString(2);\n binaryString = binaryString.padStart(digit, \"0\");\n return binaryString;\n}\n__name(toBinaryString, \"toBinaryString\");\n\n// src/data-structures/hash/hash-map.ts\nvar _HashMap = class _HashMap extends IterableEntryBase {\n /**\n * Create a HashMap and optionally bulk-insert entries.\n * @remarks Time O(N), Space O(N)\n * @param [entryOrRawElements] - Iterable of entries or raw elements to insert.\n * @param [options] - Options: hash function and optional record-to-entry converter.\n * @returns New HashMap instance.\n */\n constructor(entryOrRawElements = [], options) {\n super();\n __publicField(this, \"_store\", {});\n __publicField(this, \"_objMap\", /* @__PURE__ */ new Map());\n __publicField(this, \"_toEntryFn\");\n __publicField(this, \"_size\", 0);\n __publicField(this, \"_hashFn\", /* @__PURE__ */ __name((key) => String(key), \"_hashFn\"));\n if (options) {\n const { hashFn, toEntryFn } = options;\n if (hashFn) this._hashFn = hashFn;\n if (toEntryFn) this._toEntryFn = toEntryFn;\n }\n if (entryOrRawElements) this.setMany(entryOrRawElements);\n }\n /**\n * Get the internal store for non-object keys.\n * @remarks Time O(1), Space O(1)\n * @returns Internal record of string→{key,value}.\n */\n get store() {\n return this._store;\n }\n /**\n * Get the internal Map used for object/function keys.\n * @remarks Time O(1), Space O(1)\n * @returns Map of object→value.\n */\n get objMap() {\n return this._objMap;\n }\n /**\n * Get the raw→entry converter function if present.\n * @remarks Time O(1), Space O(1)\n * @returns Converter function or undefined.\n */\n get toEntryFn() {\n return this._toEntryFn;\n }\n /**\n * Get the number of distinct keys stored.\n * @remarks Time O(1), Space O(1)\n * @returns Current size.\n */\n get size() {\n return this._size;\n }\n /**\n * Get the current hash function for non-object keys.\n * @remarks Time O(1), Space O(1)\n * @returns Hash function.\n */\n get hashFn() {\n return this._hashFn;\n }\n /**\n * Check whether the map is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if size is 0.\n */\n isEmpty() {\n return this._size === 0;\n }\n /**\n * Remove all entries and reset counters.\n * @remarks Time O(N), Space O(1)\n * @returns void\n */\n clear() {\n this._store = {};\n this._objMap.clear();\n this._size = 0;\n }\n /**\n * Type guard: check if a raw value is a [key, value] entry.\n * @remarks Time O(1), Space O(1)\n * @returns True if the value is a 2-tuple.\n */\n isEntry(rawElement) {\n return Array.isArray(rawElement) && rawElement.length === 2;\n }\n /**\n * Insert or replace a single entry.\n * @remarks Time O(1), Space O(1)\n * @param key - Key.\n * @param value - Value.\n * @returns True when the operation succeeds.\n */\n set(key, value) {\n if (this._isObjKey(key)) {\n if (!this.objMap.has(key)) this._size++;\n this.objMap.set(key, value);\n } else {\n const strKey = this._getNoObjKey(key);\n if (this.store[strKey] === void 0) this._size++;\n this._store[strKey] = { key, value };\n }\n return true;\n }\n /**\n * Insert many entries from an iterable.\n * @remarks Time O(N), Space O(N)\n * @param entryOrRawElements - Iterable of entries or raw elements to insert.\n * @returns Array of per-entry results.\n */\n setMany(entryOrRawElements) {\n const results = [];\n for (const rawEle of entryOrRawElements) {\n let key, value;\n if (this.isEntry(rawEle)) [key, value] = rawEle;\n else if (this._toEntryFn) [key, value] = this._toEntryFn(rawEle);\n if (key !== void 0 && value !== void 0) results.push(this.set(key, value));\n }\n return results;\n }\n /**\n * Get the value for a key.\n * @remarks Time O(1), Space O(1)\n * @param key - Key to look up.\n * @returns Value or undefined.\n */\n get(key) {\n var _a;\n if (this._isObjKey(key)) return this.objMap.get(key);\n const strKey = this._getNoObjKey(key);\n return (_a = this._store[strKey]) == null ? void 0 : _a.value;\n }\n /**\n * Check if a key exists.\n * @remarks Time O(1), Space O(1)\n * @param key - Key to test.\n * @returns True if present.\n */\n has(key) {\n if (this._isObjKey(key)) return this.objMap.has(key);\n const strKey = this._getNoObjKey(key);\n return strKey in this.store;\n }\n /**\n * Delete an entry by key.\n * @remarks Time O(1), Space O(1)\n * @param key - Key to delete.\n * @returns True if the key was found and removed.\n */\n delete(key) {\n if (this._isObjKey(key)) {\n if (this.objMap.has(key)) this._size--;\n return this.objMap.delete(key);\n }\n const strKey = this._getNoObjKey(key);\n if (strKey in this.store) {\n delete this.store[strKey];\n this._size--;\n return true;\n }\n return false;\n }\n /**\n * Replace the hash function and rehash the non-object store.\n * @remarks Time O(N), Space O(N)\n * @param fn - New hash function for non-object keys.\n * @returns This map instance.\n */\n setHashFn(fn) {\n if (this._hashFn === fn) return this;\n this._hashFn = fn;\n this._rehashNoObj();\n return this;\n }\n /**\n * Deep clone this map, preserving hashing behavior.\n * @remarks Time O(N), Space O(N)\n * @returns A new map with the same content.\n */\n clone() {\n const opts = { hashFn: this._hashFn, toEntryFn: this._toEntryFn };\n return this._createLike(this, opts);\n }\n /**\n * Map values to a new map with the same keys.\n * @remarks Time O(N), Space O(N)\n * @template VM\n * @param callbackfn - Mapping function (key, value, index, map) → newValue.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new map with transformed values.\n */\n map(callbackfn, thisArg) {\n const out = this._createLike();\n let index = 0;\n for (const [key, value] of this) out.set(key, callbackfn.call(thisArg, value, key, index++, this));\n return out;\n }\n /**\n * Filter entries into a new map.\n * @remarks Time O(N), Space O(N)\n * @param predicate - Predicate (key, value, index, map) → boolean.\n * @param [thisArg] - Value for `this` inside the predicate.\n * @returns A new map containing entries that satisfied the predicate.\n */\n filter(predicate, thisArg) {\n const out = this._createLike();\n let index = 0;\n for (const [key, value] of this) if (predicate.call(thisArg, value, key, index++, this)) out.set(key, value);\n return out;\n }\n /**\n * (Protected) Create a like-kind instance and seed it from an iterable.\n * @remarks Time O(N), Space O(N)\n * @template TK\n * @template TV\n * @template TR\n * @param [entries] - Iterable used to seed the new map.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind map instance.\n */\n _createLike(entries = [], options) {\n const Ctor = this.constructor;\n return new Ctor(entries, options);\n }\n _rehashNoObj() {\n const fresh = {};\n for (const { key, value } of Object.values(this._store)) {\n const sk = this._getNoObjKey(key);\n fresh[sk] = { key, value };\n }\n this._store = fresh;\n }\n *_getIterator() {\n for (const node of Object.values(this.store)) yield [node.key, node.value];\n for (const node of this.objMap) yield node;\n }\n _isObjKey(key) {\n const keyType = typeof key;\n return (keyType === \"object\" || keyType === \"function\") && key !== null;\n }\n _getNoObjKey(key) {\n const keyType = typeof key;\n let strKey;\n if (keyType !== \"string\" && keyType !== \"number\" && keyType !== \"symbol\") {\n strKey = this._hashFn(key);\n } else {\n if (keyType === \"number\") {\n strKey = key;\n } else {\n strKey = key;\n }\n }\n return strKey;\n }\n};\n__name(_HashMap, \"HashMap\");\nvar HashMap = _HashMap;\nvar _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {\n /**\n * Create a LinkedHashMap and optionally bulk-insert entries.\n * @remarks Time O(N), Space O(N)\n * @param [entryOrRawElements] - Iterable of entries or raw elements to insert.\n * @param [options] - Options: hash functions and optional record-to-entry converter.\n * @returns New LinkedHashMap instance.\n */\n constructor(entryOrRawElements = [], options) {\n super();\n __publicField(this, \"_sentinel\");\n __publicField(this, \"_hashFn\", /* @__PURE__ */ __name((key) => String(key), \"_hashFn\"));\n __publicField(this, \"_objHashFn\", /* @__PURE__ */ __name((key) => key, \"_objHashFn\"));\n __publicField(this, \"_noObjMap\", {});\n __publicField(this, \"_objMap\", /* @__PURE__ */ new WeakMap());\n __publicField(this, \"_head\");\n __publicField(this, \"_tail\");\n __publicField(this, \"_toEntryFn\", /* @__PURE__ */ __name((rawElement) => {\n if (this.isEntry(rawElement)) {\n return rawElement;\n }\n throw new Error(\n \"If `entryOrRawElements` does not adhere to [key,value], provide `options.toEntryFn` to transform raw records.\"\n );\n }, \"_toEntryFn\"));\n __publicField(this, \"_size\", 0);\n this._sentinel = {};\n this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;\n if (options) {\n const { hashFn, objHashFn, toEntryFn } = options;\n if (hashFn) this._hashFn = hashFn;\n if (objHashFn) this._objHashFn = objHashFn;\n if (toEntryFn) this._toEntryFn = toEntryFn;\n }\n if (entryOrRawElements) this.setMany(entryOrRawElements);\n }\n get hashFn() {\n return this._hashFn;\n }\n /**\n * Get the hash function for object/weak keys.\n * @remarks Time O(1), Space O(1)\n * @returns Object-hash function.\n */\n get objHashFn() {\n return this._objHashFn;\n }\n /**\n * Get the internal record for non-object keys.\n * @remarks Time O(1), Space O(1)\n * @returns Record of hash→node.\n */\n get noObjMap() {\n return this._noObjMap;\n }\n get objMap() {\n return this._objMap;\n }\n /**\n * Get the head node (first entry) sentinel link.\n * @remarks Time O(1), Space O(1)\n * @returns Head node or sentinel.\n */\n get head() {\n return this._head;\n }\n /**\n * Get the tail node (last entry) sentinel link.\n * @remarks Time O(1), Space O(1)\n * @returns Tail node or sentinel.\n */\n get tail() {\n return this._tail;\n }\n get toEntryFn() {\n return this._toEntryFn;\n }\n get size() {\n return this._size;\n }\n /**\n * Get the first [key, value] pair.\n * @remarks Time O(1), Space O(1)\n * @returns First entry or undefined when empty.\n */\n get first() {\n if (this._size === 0) return;\n return [this.head.key, this.head.value];\n }\n /**\n * Get the last [key, value] pair.\n * @remarks Time O(1), Space O(1)\n * @returns Last entry or undefined when empty.\n */\n get last() {\n if (this._size === 0) return;\n return [this.tail.key, this.tail.value];\n }\n /**\n * Iterate from head → tail.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of [key, value].\n */\n *begin() {\n let node = this.head;\n while (node !== this._sentinel) {\n yield [node.key, node.value];\n node = node.next;\n }\n }\n /**\n * Iterate from tail → head.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of [key, value].\n */\n *reverseBegin() {\n let node = this.tail;\n while (node !== this._sentinel) {\n yield [node.key, node.value];\n node = node.prev;\n }\n }\n /**\n * Insert or replace a single entry; preserves insertion order.\n * @remarks Time O(1), Space O(1)\n * @param key - Key.\n * @param [value] - Value.\n * @returns True when the operation succeeds.\n */\n set(key, value) {\n let node;\n const isNewKey = !this.has(key);\n if (isWeakKey(key)) {\n const hash = this._objHashFn(key);\n node = this.objMap.get(hash);\n if (!node && isNewKey) {\n node = { key: hash, value, prev: this.tail, next: this._sentinel };\n this.objMap.set(hash, node);\n } else if (node) {\n node.value = value;\n }\n } else {\n const hash = this._hashFn(key);\n node = this.noObjMap[hash];\n if (!node && isNewKey) {\n this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };\n } else if (node) {\n node.value = value;\n }\n }\n if (node && isNewKey) {\n if (this._size === 0) {\n this._head = node;\n this._sentinel.next = node;\n } else {\n this.tail.next = node;\n node.prev = this.tail;\n }\n this._tail = node;\n this._sentinel.prev = node;\n this._size++;\n }\n return true;\n }\n setMany(entryOrRawElements) {\n const results = [];\n for (const rawEle of entryOrRawElements) {\n let key, value;\n if (this.isEntry(rawEle)) [key, value] = rawEle;\n else if (this._toEntryFn) [key, value] = this._toEntryFn(rawEle);\n if (key !== void 0 && value !== void 0) results.push(this.set(key, value));\n }\n return results;\n }\n has(key) {\n if (isWeakKey(key)) {\n const hash2 = this._objHashFn(key);\n return this.objMap.has(hash2);\n }\n const hash = this._hashFn(key);\n return hash in this.noObjMap;\n }\n get(key) {\n if (isWeakKey(key)) {\n const hash2 = this._objHashFn(key);\n const node2 = this.objMap.get(hash2);\n return node2 ? node2.value : void 0;\n }\n const hash = this._hashFn(key);\n const node = this.noObjMap[hash];\n return node ? node.value : void 0;\n }\n /**\n * Get the value at a given index in insertion order.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns Value at the index.\n */\n at(index) {\n rangeCheck(index, 0, this._size - 1);\n let node = this.head;\n while (index--) node = node.next;\n return node.value;\n }\n delete(key) {\n let node;\n if (isWeakKey(key)) {\n const hash = this._objHashFn(key);\n node = this.objMap.get(hash);\n if (!node) return false;\n this.objMap.delete(hash);\n } else {\n const hash = this._hashFn(key);\n node = this.noObjMap[hash];\n if (!node) return false;\n delete this.noObjMap[hash];\n }\n return this._deleteNode(node);\n }\n /**\n * Delete the first entry that matches a predicate.\n * @remarks Time O(N), Space O(1)\n * @param predicate - Function (key, value, index, map) → boolean to decide deletion.\n * @returns True if an entry was removed.\n */\n deleteWhere(predicate) {\n let node = this._head;\n let i = 0;\n while (node !== this._sentinel) {\n const cur = node;\n node = node.next;\n if (predicate(cur.key, cur.value, i++, this)) {\n if (isWeakKey(cur.key)) {\n this._objMap.delete(cur.key);\n } else {\n const hash = this._hashFn(cur.key);\n delete this._noObjMap[hash];\n }\n return this._deleteNode(cur);\n }\n }\n return false;\n }\n /**\n * Delete the entry at a given index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns True if removed.\n */\n deleteAt(index) {\n rangeCheck(index, 0, this._size - 1);\n let node = this.head;\n while (index--) node = node.next;\n return this._deleteNode(node);\n }\n isEmpty() {\n return this._size === 0;\n }\n isEntry(rawElement) {\n return Array.isArray(rawElement) && rawElement.length === 2;\n }\n clear() {\n this._noObjMap = {};\n this._size = 0;\n this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;\n }\n clone() {\n const opts = { hashFn: this._hashFn, objHashFn: this._objHashFn };\n return this._createLike(this, opts);\n }\n filter(predicate, thisArg) {\n const out = this._createLike();\n let index = 0;\n for (const [key, value] of this) {\n if (predicate.call(thisArg, value, key, index, this)) out.set(key, value);\n index++;\n }\n return out;\n }\n /**\n * Map each entry to a new [key, value] pair and preserve order.\n * @remarks Time O(N), Space O(N)\n * @template MK\n * @template MV\n * @param callback - Mapping function (key, value, index, map) → [newKey, newValue].\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new map of the same class with transformed entries.\n */\n map(callback, thisArg) {\n const out = this._createLike();\n let index = 0;\n for (const [key, value] of this) {\n const [newKey, newValue] = callback.call(thisArg, value, key, index, this);\n out.set(newKey, newValue);\n index++;\n }\n return out;\n }\n *_getIterator() {\n let node = this.head;\n while (node !== this._sentinel) {\n yield [node.key, node.value];\n node = node.next;\n }\n }\n _deleteNode(node) {\n const { prev, next } = node;\n prev.next = next;\n next.prev = prev;\n if (node === this.head) this._head = next;\n if (node === this.tail) this._tail = prev;\n this._size -= 1;\n return true;\n }\n _createLike(entries = [], options) {\n const Ctor = this.constructor;\n return new Ctor(entries, options);\n }\n};\n__name(_LinkedHashMap, \"LinkedHashMap\");\nvar LinkedHashMap = _LinkedHashMap;\n\n// src/data-structures/base/linear-base.ts\nvar _LinkedListNode = class _LinkedListNode {\n /**\n * Initialize a node.\n * @param value - Element value.\n * @remarks Time O(1), Space O(1)\n */\n constructor(value) {\n __publicField(this, \"_value\");\n __publicField(this, \"_next\");\n this._value = value;\n this._next = void 0;\n }\n /**\n * Element payload getter.\n * @returns Element value.\n * @remarks Time O(1), Space O(1)\n */\n get value() {\n return this._value;\n }\n /**\n * Element payload setter.\n * @param value - New value.\n * @remarks Time O(1), Space O(1)\n */\n set value(value) {\n this._value = value;\n }\n /**\n * Next node getter.\n * @returns Next node or `undefined`.\n * @remarks Time O(1), Space O(1)\n */\n get next() {\n return this._next;\n }\n /**\n * Next node setter.\n * @param value - Next node or `undefined`.\n * @remarks Time O(1), Space O(1)\n */\n set next(value) {\n this._next = value;\n }\n};\n__name(_LinkedListNode, \"LinkedListNode\");\nvar LinkedListNode = _LinkedListNode;\nvar _LinearBase = class _LinearBase extends IterableElementBase {\n /**\n * Construct a linear container with runtime options.\n * @param options - `{ maxLen?, ... }` bounds/behavior options.\n * @remarks Time O(1), Space O(1)\n */\n constructor(options) {\n super(options);\n __publicField(this, \"_maxLen\", -1);\n if (options) {\n const { maxLen } = options;\n if (typeof maxLen === \"number\" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;\n }\n }\n /**\n * Upper bound for length (if positive), or `-1` when unbounded.\n * @returns Maximum allowed length.\n * @remarks Time O(1), Space O(1)\n */\n get maxLen() {\n return this._maxLen;\n }\n /**\n * First index of a value from the left.\n * @param searchElement - Value to match.\n * @param fromIndex - Start position (supports negative index).\n * @returns Index or `-1` if not found.\n * @remarks Time O(n), Space O(1)\n */\n indexOf(searchElement, fromIndex = 0) {\n if (this.length === 0) return -1;\n if (fromIndex < 0) fromIndex = this.length + fromIndex;\n if (fromIndex < 0) fromIndex = 0;\n for (let i = fromIndex; i < this.length; i++) {\n const element = this.at(i);\n if (element === searchElement) return i;\n }\n return -1;\n }\n /**\n * Last index of a value from the right.\n * @param searchElement - Value to match.\n * @param fromIndex - Start position (supports negative index).\n * @returns Index or `-1` if not found.\n * @remarks Time O(n), Space O(1)\n */\n lastIndexOf(searchElement, fromIndex = this.length - 1) {\n if (this.length === 0) return -1;\n if (fromIndex >= this.length) fromIndex = this.length - 1;\n if (fromIndex < 0) fromIndex = this.length + fromIndex;\n for (let i = fromIndex; i >= 0; i--) {\n const element = this.at(i);\n if (element === searchElement) return i;\n }\n return -1;\n }\n /**\n * Find the first index matching a predicate.\n * @param predicate - `(element, index, self) => boolean`.\n * @param thisArg - Optional `this` for callback.\n * @returns Index or `-1`.\n * @remarks Time O(n), Space O(1)\n */\n findIndex(predicate, thisArg) {\n for (let i = 0; i < this.length; i++) {\n const item = this.at(i);\n if (item !== void 0 && predicate.call(thisArg, item, i, this)) return i;\n }\n return -1;\n }\n /**\n * Concatenate elements and/or containers.\n * @param items - Elements or other containers.\n * @returns New container with combined elements (`this` type).\n * @remarks Time O(sum(length)), Space O(sum(length))\n */\n concat(...items) {\n const newList = this.clone();\n for (const item of items) {\n if (item instanceof _LinearBase) {\n newList.pushMany(item);\n } else {\n newList.push(item);\n }\n }\n return newList;\n }\n /**\n * In-place stable order via array sort semantics.\n * @param compareFn - Comparator `(a, b) => number`.\n * @returns This container.\n * @remarks Time O(n log n), Space O(n) (materializes to array temporarily)\n */\n sort(compareFn) {\n const arr = this.toArray();\n arr.sort(compareFn);\n this.clear();\n for (const item of arr) this.push(item);\n return this;\n }\n /**\n * Remove and/or insert elements at a position (array-compatible).\n * @param start - Start index (supports negative index).\n * @param deleteCount - How many to remove.\n * @param items - Elements to insert.\n * @returns Removed elements as a new list (`this` type).\n * @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`\n */\n splice(start, deleteCount = 0, ...items) {\n const removedList = this._createInstance();\n start = start < 0 ? this.length + start : start;\n start = Math.max(0, Math.min(start, this.length));\n deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));\n for (let i = 0; i < deleteCount; i++) {\n const removed = this.deleteAt(start);\n if (removed !== void 0) {\n removedList.push(removed);\n }\n }\n for (let i = 0; i < items.length; i++) {\n this.addAt(start + i, items[i]);\n }\n return removedList;\n }\n /**\n * Join all elements into a string.\n * @param separator - Separator string.\n * @returns Concatenated string.\n * @remarks Time O(n), Space O(n)\n */\n join(separator = \",\") {\n return this.toArray().join(separator);\n }\n /**\n * Snapshot elements into a reversed array.\n * @returns New reversed array.\n * @remarks Time O(n), Space O(n)\n */\n toReversedArray() {\n const array = [];\n for (let i = this.length - 1; i >= 0; i--) {\n array.push(this.at(i));\n }\n return array;\n }\n reduceRight(callbackfn, initialValue) {\n let accumulator = initialValue != null ? initialValue : 0;\n for (let i = this.length - 1; i >= 0; i--) {\n accumulator = callbackfn(accumulator, this.at(i), i, this);\n }\n return accumulator;\n }\n /**\n * Create a shallow copy of a subrange.\n * @param start - Inclusive start (supports negative index).\n * @param end - Exclusive end (supports negative index).\n * @returns New list with the range (`this` type).\n * @remarks Time O(n), Space O(n)\n */\n slice(start = 0, end = this.length) {\n start = start < 0 ? this.length + start : start;\n end = end < 0 ? this.length + end : end;\n const newList = this._createInstance();\n for (let i = start; i < end; i++) {\n newList.push(this.at(i));\n }\n return newList;\n }\n /**\n * Fill a range with a value.\n * @param value - Value to set.\n * @param start - Inclusive start.\n * @param end - Exclusive end.\n * @returns This list.\n * @remarks Time O(n), Space O(1)\n */\n fill(value, start = 0, end = this.length) {\n start = start < 0 ? this.length + start : start;\n end = end < 0 ? this.length + end : end;\n if (start < 0) start = 0;\n if (end > this.length) end = this.length;\n if (start >= end) return this;\n for (let i = start; i < end; i++) {\n this.setAt(i, value);\n }\n return this;\n }\n};\n__name(_LinearBase, \"LinearBase\");\nvar LinearBase = _LinearBase;\nvar _LinearLinkedBase = class _LinearLinkedBase extends LinearBase {\n constructor(options) {\n super(options);\n if (options) {\n const { maxLen } = options;\n if (typeof maxLen === \"number\" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;\n }\n }\n /**\n * Linked-list optimized `indexOf` (forwards scan).\n * @param searchElement - Value to match.\n * @param fromIndex - Start position.\n * @returns Index or `-1`.\n * @remarks Time O(n), Space O(1)\n */\n indexOf(searchElement, fromIndex = 0) {\n const iterator = this._getIterator();\n let current = iterator.next();\n let index = 0;\n while (index < fromIndex) {\n current = iterator.next();\n index++;\n }\n while (!current.done) {\n if (current.value === searchElement) return index;\n current = iterator.next();\n index++;\n }\n return -1;\n }\n /**\n * Linked-list optimized `lastIndexOf` (reverse scan).\n * @param searchElement - Value to match.\n * @param fromIndex - Start position.\n * @returns Index or `-1`.\n * @remarks Time O(n), Space O(1)\n */\n lastIndexOf(searchElement, fromIndex = this.length - 1) {\n const iterator = this._getReverseIterator();\n let current = iterator.next();\n let index = this.length - 1;\n while (index > fromIndex) {\n current = iterator.next();\n index--;\n }\n while (!current.done) {\n if (current.value === searchElement) return index;\n current = iterator.next();\n index--;\n }\n return -1;\n }\n /**\n * Concatenate lists/elements preserving order.\n * @param items - Elements or `LinearBase` instances.\n * @returns New list with combined elements (`this` type).\n * @remarks Time O(sum(length)), Space O(sum(length))\n */\n concat(...items) {\n const newList = this.clone();\n for (const item of items) {\n if (item instanceof LinearBase) {\n newList.pushMany(item);\n } else {\n newList.push(item);\n }\n }\n return newList;\n }\n /**\n * Slice via forward iteration (no random access required).\n * @param start - Inclusive start (supports negative index).\n * @param end - Exclusive end (supports negative index).\n * @returns New list (`this` type).\n * @remarks Time O(n), Space O(n)\n */\n slice(start = 0, end = this.length) {\n start = start < 0 ? this.length + start : start;\n end = end < 0 ? this.length + end : end;\n const newList = this._createInstance();\n const iterator = this._getIterator();\n let current = iterator.next();\n let c = 0;\n while (c < start) {\n current = iterator.next();\n c++;\n }\n for (let i = start; i < end; i++) {\n newList.push(current.value);\n current = iterator.next();\n }\n return newList;\n }\n /**\n * Splice by walking node iterators from the start index.\n * @param start - Start index.\n * @param deleteCount - How many elements to remove.\n * @param items - Elements to insert after the splice point.\n * @returns Removed elements as a new list (`this` type).\n * @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`\n */\n splice(start, deleteCount = 0, ...items) {\n const removedList = this._createInstance();\n start = start < 0 ? this.length + start : start;\n start = Math.max(0, Math.min(start, this.length));\n deleteCount = Math.max(0, deleteCount);\n let currentIndex = 0;\n let currentNode = void 0;\n let previousNode = void 0;\n const iterator = this._getNodeIterator();\n for (const node of iterator) {\n if (currentIndex === start) {\n currentNode = node;\n break;\n }\n previousNode = node;\n currentIndex++;\n }\n for (let i = 0; i < deleteCount && currentNode; i++) {\n removedList.push(currentNode.value);\n const nextNode = currentNode.next;\n this.delete(currentNode);\n currentNode = nextNode;\n }\n for (let i = 0; i < items.length; i++) {\n if (previousNode) {\n this.addAfter(previousNode, items[i]);\n previousNode = previousNode.next;\n } else {\n this.addAt(0, items[i]);\n previousNode = this._getNodeIterator().next().value;\n }\n }\n return removedList;\n }\n reduceRight(callbackfn, initialValue) {\n let accumulator = initialValue != null ? initialValue : 0;\n let index = this.length - 1;\n for (const item of this._getReverseIterator()) {\n accumulator = callbackfn(accumulator, item, index--, this);\n }\n return accumulator;\n }\n};\n__name(_LinearLinkedBase, \"LinearLinkedBase\");\nvar LinearLinkedBase = _LinearLinkedBase;\n\n// src/data-structures/linked-list/singly-linked-list.ts\nvar _SinglyLinkedListNode = class _SinglyLinkedListNode extends LinkedListNode {\n /**\n * Create a list node.\n * @remarks Time O(1), Space O(1)\n * @param value - Element value to store.\n * @returns New node instance.\n */\n constructor(value) {\n super(value);\n __publicField(this, \"_next\");\n this._value = value;\n this._next = void 0;\n }\n /**\n * Get the next node.\n * @remarks Time O(1), Space O(1)\n * @returns Next node or undefined.\n */\n get next() {\n return this._next;\n }\n /**\n * Set the next node.\n * @remarks Time O(1), Space O(1)\n * @param value - Next node or undefined.\n * @returns void\n */\n set next(value) {\n this._next = value;\n }\n};\n__name(_SinglyLinkedListNode, \"SinglyLinkedListNode\");\nvar SinglyLinkedListNode = _SinglyLinkedListNode;\nvar _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {\n /**\n * Create a SinglyLinkedList and optionally bulk-insert elements.\n * @remarks Time O(N), Space O(N)\n * @param [elements] - Iterable of elements or nodes (or raw records if toElementFn is provided).\n * @param [options] - Options such as maxLen and toElementFn.\n * @returns New SinglyLinkedList instance.\n */\n constructor(elements = [], options) {\n super(options);\n __publicField(this, \"_equals\", Object.is);\n __publicField(this, \"_head\");\n __publicField(this, \"_tail\");\n __publicField(this, \"_length\", 0);\n this.pushMany(elements);\n }\n /**\n * Get the head node.\n * @remarks Time O(1), Space O(1)\n * @returns Head node or undefined.\n */\n get head() {\n return this._head;\n }\n /**\n * Get the tail node.\n * @remarks Time O(1), Space O(1)\n * @returns Tail node or undefined.\n */\n get tail() {\n return this._tail;\n }\n /**\n * Get the number of elements.\n * @remarks Time O(1), Space O(1)\n * @returns Current length.\n */\n get length() {\n return this._length;\n }\n /**\n * Get the first element value.\n * @remarks Time O(1), Space O(1)\n * @returns First element or undefined.\n */\n get first() {\n var _a;\n return (_a = this.head) == null ? void 0 : _a.value;\n }\n /**\n * Get the last element value.\n * @remarks Time O(1), Space O(1)\n * @returns Last element or undefined.\n */\n get last() {\n var _a;\n return (_a = this.tail) == null ? void 0 : _a.value;\n }\n /**\n * Create a new list from an iterable of elements.\n * @remarks Time O(N), Space O(N)\n * @template E\n * @template R\n * @template S\n * @param this - The constructor (subclass) to instantiate.\n * @param data - Iterable of elements to insert.\n * @param [options] - Options forwarded to the constructor.\n * @returns A new list populated with the iterable's elements.\n */\n static from(data, options) {\n const list = new this([], options);\n for (const x of data) list.push(x);\n return list;\n }\n /**\n * Append an element/node to the tail.\n * @remarks Time O(1), Space O(1)\n * @param elementOrNode - Element or node to append.\n * @returns True when appended.\n */\n push(elementOrNode) {\n const newNode = this._ensureNode(elementOrNode);\n if (!this.head) {\n this._head = this._tail = newNode;\n } else {\n this.tail.next = newNode;\n this._tail = newNode;\n }\n this._length++;\n if (this._maxLen > 0 && this.length > this._maxLen) this.shift();\n return true;\n }\n /**\n * Remove and return the tail element.\n * @remarks Time O(N), Space O(1)\n * @returns Removed element or undefined.\n */\n pop() {\n if (!this.head) return void 0;\n if (this.head === this.tail) {\n const value2 = this.head.value;\n this._head = void 0;\n this._tail = void 0;\n this._length--;\n return value2;\n }\n let current = this.head;\n while (current.next !== this.tail) current = current.next;\n const value = this.tail.value;\n current.next = void 0;\n this._tail = current;\n this._length--;\n return value;\n }\n /**\n * Remove and return the head element.\n * @remarks Time O(1), Space O(1)\n * @returns Removed element or undefined.\n */\n shift() {\n if (!this.head) return void 0;\n const removed = this.head;\n this._head = this.head.next;\n if (!this._head) this._tail = void 0;\n this._length--;\n return removed.value;\n }\n /**\n * Prepend an element/node to the head.\n * @remarks Time O(1), Space O(1)\n * @param elementOrNode - Element or node to prepend.\n * @returns True when prepended.\n */\n unshift(elementOrNode) {\n const newNode = this._ensureNode(elementOrNode);\n if (!this.head) {\n this._head = this._tail = newNode;\n } else {\n newNode.next = this.head;\n this._head = newNode;\n }\n this._length++;\n return true;\n }\n /**\n * Append a sequence of elements/nodes.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).\n * @returns Array of per-element success flags.\n */\n pushMany(elements) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) ans.push(this.push(this.toElementFn(el)));\n else ans.push(this.push(el));\n }\n return ans;\n }\n /**\n * Prepend a sequence of elements/nodes.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).\n * @returns Array of per-element success flags.\n */\n unshiftMany(elements) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) ans.push(this.unshift(this.toElementFn(el)));\n else ans.push(this.unshift(el));\n }\n return ans;\n }\n /**\n * Find the first value matching a predicate (by node).\n * @remarks Time O(N), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or node predicate to match.\n * @returns Matched value or undefined.\n */\n search(elementNodeOrPredicate) {\n const predicate = this._ensurePredicate(elementNodeOrPredicate);\n let current = this.head;\n while (current) {\n if (predicate(current)) return current.value;\n current = current.next;\n }\n return void 0;\n }\n /**\n * Get the element at a given index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns Element or undefined.\n */\n at(index) {\n if (index < 0 || index >= this._length) return void 0;\n let current = this.head;\n for (let i = 0; i < index; i++) current = current.next;\n return current.value;\n }\n /**\n * Type guard: check whether the input is a SinglyLinkedListNode.\n * @remarks Time O(1), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or predicate.\n * @returns True if the value is a SinglyLinkedListNode.\n */\n isNode(elementNodeOrPredicate) {\n return elementNodeOrPredicate instanceof SinglyLinkedListNode;\n }\n /**\n * Get the node reference at a given index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns Node or undefined.\n */\n getNodeAt(index) {\n if (index < 0 || index >= this._length) return void 0;\n let current = this.head;\n for (let i = 0; i < index; i++) current = current.next;\n return current;\n }\n /**\n * Delete the element at an index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns Removed element or undefined.\n */\n deleteAt(index) {\n if (index < 0 || index >= this._length) return void 0;\n if (index === 0) return this.shift();\n const targetNode = this.getNodeAt(index);\n const prevNode = this._getPrevNode(targetNode);\n const value = targetNode.value;\n prevNode.next = targetNode.next;\n if (targetNode === this.tail) this._tail = prevNode;\n this._length--;\n return value;\n }\n /**\n * Delete the first match by value/node.\n * @remarks Time O(N), Space O(1)\n * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.\n * @returns True if removed.\n */\n delete(elementOrNode) {\n if (elementOrNode === void 0 || !this.head) return false;\n const node = this.isNode(elementOrNode) ? elementOrNode : this.getNode(elementOrNode);\n if (!node) return false;\n const prevNode = this._getPrevNode(node);\n if (!prevNode) {\n this._head = node.next;\n if (node === this.tail) this._tail = void 0;\n } else {\n prevNode.next = node.next;\n if (node === this.tail) this._tail = prevNode;\n }\n this._length--;\n return true;\n }\n /**\n * Insert a new element/node at an index, shifting following nodes.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @param newElementOrNode - Element or node to insert.\n * @returns True if inserted.\n */\n addAt(index, newElementOrNode) {\n if (index < 0 || index > this._length) return false;\n if (index === 0) return this.unshift(newElementOrNode);\n if (index === this._length) return this.push(newElementOrNode);\n const newNode = this._ensureNode(newElementOrNode);\n const prevNode = this.getNodeAt(index - 1);\n newNode.next = prevNode.next;\n prevNode.next = newNode;\n this._length++;\n return true;\n }\n /**\n * Set the element value at an index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @param value - New value.\n * @returns True if updated.\n */\n setAt(index, value) {\n const node = this.getNodeAt(index);\n if (!node) return false;\n node.value = value;\n return true;\n }\n /**\n * Check whether the list is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if length is 0.\n */\n isEmpty() {\n return this._length === 0;\n }\n /**\n * Remove all nodes and reset length.\n * @remarks Time O(N), Space O(1)\n * @returns void\n */\n clear() {\n this._head = void 0;\n this._tail = void 0;\n this._length = 0;\n }\n /**\n * Reverse the list in place.\n * @remarks Time O(N), Space O(1)\n * @returns This list.\n */\n reverse() {\n if (!this.head || this.head === this.tail) return this;\n let prev;\n let current = this.head;\n let next;\n while (current) {\n next = current.next;\n current.next = prev;\n prev = current;\n current = next;\n }\n [this._head, this._tail] = [this.tail, this.head];\n return this;\n }\n /**\n * Find a node by value, reference, or predicate.\n * @remarks Time O(N), Space O(1)\n * @param [elementNodeOrPredicate] - Element, node, or node predicate to match.\n * @returns Matching node or undefined.\n */\n getNode(elementNodeOrPredicate) {\n if (elementNodeOrPredicate === void 0) return;\n if (this.isNode(elementNodeOrPredicate)) return elementNodeOrPredicate;\n const predicate = this._ensurePredicate(elementNodeOrPredicate);\n let current = this.head;\n while (current) {\n if (predicate(current)) return current;\n current = current.next;\n }\n return void 0;\n }\n /**\n * Insert a new element/node before an existing one.\n * @remarks Time O(N), Space O(1)\n * @param existingElementOrNode - Existing element or node.\n * @param newElementOrNode - Element or node to insert.\n * @returns True if inserted.\n */\n addBefore(existingElementOrNode, newElementOrNode) {\n const existingNode = this.getNode(existingElementOrNode);\n if (!existingNode) return false;\n const prevNode = this._getPrevNode(existingNode);\n const newNode = this._ensureNode(newElementOrNode);\n if (!prevNode) {\n newNode.next = this._head;\n this._head = newNode;\n if (!this._tail) this._tail = newNode;\n this._length++;\n } else {\n prevNode.next = newNode;\n newNode.next = existingNode;\n this._length++;\n }\n return true;\n }\n /**\n * Insert a new element/node after an existing one.\n * @remarks Time O(N), Space O(1)\n * @param existingElementOrNode - Existing element or node.\n * @param newElementOrNode - Element or node to insert.\n * @returns True if inserted.\n */\n addAfter(existingElementOrNode, newElementOrNode) {\n const existingNode = this.getNode(existingElementOrNode);\n if (!existingNode) return false;\n const newNode = this._ensureNode(newElementOrNode);\n newNode.next = existingNode.next;\n existingNode.next = newNode;\n if (existingNode === this.tail) this._tail = newNode;\n this._length++;\n return true;\n }\n /**\n * Remove and/or insert elements at a position (array-like behavior).\n * @remarks Time O(N + M), Space O(M)\n * @param start - Start index (clamped to [0, length]).\n * @param [deleteCount] - Number of elements to remove (default 0).\n * @param [items] - Elements to insert after `start`.\n * @returns A new list containing the removed elements (typed as `this`).\n */\n splice(start, deleteCount = 0, ...items) {\n start = Math.max(0, Math.min(start, this.length));\n deleteCount = Math.max(0, deleteCount);\n const removedList = this._createInstance();\n const prevNode = start === 0 ? void 0 : this.getNodeAt(start - 1);\n let cur = prevNode ? prevNode.next : this.head;\n let removedCount = 0;\n while (removedCount < deleteCount && cur) {\n removedList.push(cur.value);\n cur = cur.next;\n removedCount++;\n }\n const afterNode = cur;\n if (prevNode) {\n prevNode.next = afterNode;\n } else {\n this._head = afterNode;\n }\n if (!afterNode) this._tail = prevNode;\n if (items.length > 0) {\n let firstInserted;\n let lastInserted;\n for (const it of items) {\n const node = this._ensureNode(it);\n if (!firstInserted) firstInserted = node;\n if (lastInserted) lastInserted.next = node;\n lastInserted = node;\n }\n if (prevNode) prevNode.next = firstInserted;\n else this._head = firstInserted;\n lastInserted.next = afterNode;\n if (!afterNode) this._tail = lastInserted;\n }\n this._length += items.length - removedCount;\n if (this._length === 0) {\n this._head = void 0;\n this._tail = void 0;\n }\n return removedList;\n }\n /**\n * Count how many nodes match a value/node/predicate.\n * @remarks Time O(N), Space O(1)\n * @param elementOrNode - Element, node, or node predicate to match.\n * @returns Number of matches in the list.\n */\n countOccurrences(elementOrNode) {\n const predicate = elementOrPredicate(elementOrNode, this._equals);\n let count = 0;\n let current = this.head;\n while (current) {\n if (predicate(current)) count++;\n current = current.next;\n }\n return count;\n }\n /**\n * Set the equality comparator used to compare values.\n * @remarks Time O(1), Space O(1)\n * @param equals - Equality predicate (a, b) → boolean.\n * @returns This list.\n */\n setEquality(equals) {\n this._equals = equals;\n return this;\n }\n /**\n * Delete the first node whose value matches a predicate.\n * @remarks Time O(N), Space O(1)\n * @param predicate - Predicate (value, index, list) → boolean to decide deletion.\n * @returns True if a node was removed.\n */\n deleteWhere(predicate) {\n let prev;\n let current = this.head;\n let i = 0;\n while (current) {\n if (predicate(current.value, i++, this)) {\n if (!prev) {\n this._head = current.next;\n if (current === this._tail) this._tail = void 0;\n } else {\n prev.next = current.next;\n if (current === this._tail) this._tail = prev;\n }\n this._length--;\n return true;\n }\n prev = current;\n current = current.next;\n }\n return false;\n }\n /**\n * Deep clone this list (values are copied by reference).\n * @remarks Time O(N), Space O(N)\n * @returns A new list with the same element sequence.\n */\n clone() {\n const out = this._createInstance();\n for (const v of this) out.push(v);\n return out;\n }\n /**\n * Filter values into a new list of the same class.\n * @remarks Time O(N), Space O(N)\n * @param callback - Predicate (value, index, list) → boolean to keep value.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new list with kept values.\n */\n filter(callback, thisArg) {\n const out = this._createInstance();\n let index = 0;\n for (const value of this) if (callback.call(thisArg, value, index++, this)) out.push(value);\n return out;\n }\n /**\n * Map values into a new list of the same class.\n * @remarks Time O(N), Space O(N)\n * @param callback - Mapping function (value, index, list) → newValue.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new list with mapped values.\n */\n mapSame(callback, thisArg) {\n const out = this._createInstance();\n let index = 0;\n for (const value of this) {\n const mv = thisArg === void 0 ? callback(value, index++, this) : callback.call(thisArg, value, index++, this);\n out.push(mv);\n }\n return out;\n }\n /**\n * Map values into a new list (possibly different element type).\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param callback - Mapping function (value, index, list) → newElement.\n * @param [options] - Options for the output list (e.g., maxLen, toElementFn).\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new SinglyLinkedList with mapped values.\n */\n map(callback, options, thisArg) {\n const out = this._createLike([], { ...options != null ? options : {}, maxLen: this._maxLen });\n let index = 0;\n for (const value of this) out.push(callback.call(thisArg, value, index++, this));\n return out;\n }\n /**\n * (Protected) Create a node from a value.\n * @remarks Time O(1), Space O(1)\n * @param value - Value to wrap in a node.\n * @returns A new SinglyLinkedListNode instance.\n */\n createNode(value) {\n return new SinglyLinkedListNode(value);\n }\n /**\n * (Protected) Check if input is a node predicate function.\n * @remarks Time O(1), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or node predicate.\n * @returns True if input is a predicate function.\n */\n _isPredicate(elementNodeOrPredicate) {\n return typeof elementNodeOrPredicate === \"function\";\n }\n /**\n * (Protected) Normalize input into a node instance.\n * @remarks Time O(1), Space O(1)\n * @param elementOrNode - Element or node.\n * @returns A SinglyLinkedListNode for the provided input.\n */\n _ensureNode(elementOrNode) {\n if (this.isNode(elementOrNode)) return elementOrNode;\n return this.createNode(elementOrNode);\n }\n /**\n * (Protected) Normalize input into a node predicate.\n * @remarks Time O(1), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or predicate.\n * @returns A predicate taking a node and returning true/false.\n */\n _ensurePredicate(elementNodeOrPredicate) {\n if (this.isNode(elementNodeOrPredicate)) return (node) => node === elementNodeOrPredicate;\n if (this._isPredicate(elementNodeOrPredicate)) return elementNodeOrPredicate;\n const value = elementNodeOrPredicate;\n return (node) => this._equals(node.value, value);\n }\n /**\n * (Protected) Get the previous node of a given node.\n * @remarks Time O(N), Space O(1)\n * @param node - A node in the list.\n * @returns Previous node or undefined.\n */\n _getPrevNode(node) {\n if (!this.head || this.head === node) return void 0;\n let current = this.head;\n while (current.next && current.next !== node) current = current.next;\n return current.next === node ? current : void 0;\n }\n /**\n * (Protected) Iterate values from head to tail.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of values (E).\n */\n *_getIterator() {\n let current = this.head;\n while (current) {\n yield current.value;\n current = current.next;\n }\n }\n /**\n * (Protected) Iterate values from tail to head.\n * @remarks Time O(N), Space O(N)\n * @returns Iterator of values (E).\n */\n *_getReverseIterator() {\n const reversedArr = [...this].reverse();\n for (const item of reversedArr) yield item;\n }\n /**\n * (Protected) Iterate nodes from head to tail.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of nodes.\n */\n *_getNodeIterator() {\n let current = this.head;\n while (current) {\n yield current;\n current = current.next;\n }\n }\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind list instance.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], options);\n }\n /**\n * (Protected) Create a like-kind instance and seed it from an iterable.\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param [elements] - Iterable used to seed the new list.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind SinglyLinkedList instance.\n */\n _createLike(elements = [], options) {\n const Ctor = this.constructor;\n return new Ctor(elements, options);\n }\n /**\n * (Protected) Spawn an empty like-kind list instance.\n * @remarks Time O(1), Space O(1)\n * @template EM\n * @template RM\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind SinglyLinkedList instance.\n */\n _spawnLike(options) {\n return this._createLike([], options);\n }\n};\n__name(_SinglyLinkedList, \"SinglyLinkedList\");\nvar SinglyLinkedList = _SinglyLinkedList;\nfunction elementOrPredicate(input, equals) {\n if (input instanceof SinglyLinkedListNode) return (node) => node === input;\n if (typeof input === \"function\") return input;\n const value = input;\n return (node) => equals(node.value, value);\n}\n__name(elementOrPredicate, \"elementOrPredicate\");\n\n// src/data-structures/linked-list/doubly-linked-list.ts\nvar _DoublyLinkedListNode = class _DoublyLinkedListNode extends LinkedListNode {\n /**\n * Create a node.\n * @remarks Time O(1), Space O(1)\n * @param value - Element value to store.\n * @returns New node instance.\n */\n constructor(value) {\n super(value);\n __publicField(this, \"_next\");\n __publicField(this, \"_prev\");\n this._value = value;\n this._next = void 0;\n this._prev = void 0;\n }\n /**\n * Get the next node link.\n * @remarks Time O(1), Space O(1)\n * @returns Next node or undefined.\n */\n get next() {\n return this._next;\n }\n /**\n * Set the next node link.\n * @remarks Time O(1), Space O(1)\n * @param value - Next node or undefined.\n * @returns void\n */\n set next(value) {\n this._next = value;\n }\n /**\n * Get the previous node link.\n * @remarks Time O(1), Space O(1)\n * @returns Previous node or undefined.\n */\n get prev() {\n return this._prev;\n }\n /**\n * Set the previous node link.\n * @remarks Time O(1), Space O(1)\n * @param value - Previous node or undefined.\n * @returns void\n */\n set prev(value) {\n this._prev = value;\n }\n};\n__name(_DoublyLinkedListNode, \"DoublyLinkedListNode\");\nvar DoublyLinkedListNode = _DoublyLinkedListNode;\nvar _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {\n /**\n * Create a DoublyLinkedList and optionally bulk-insert elements.\n * @remarks Time O(N), Space O(N)\n * @param [elements] - Iterable of elements or nodes (or raw records if toElementFn is provided).\n * @param [options] - Options such as maxLen and toElementFn.\n * @returns New DoublyLinkedList instance.\n */\n constructor(elements = [], options) {\n super(options);\n __publicField(this, \"_equals\", Object.is);\n __publicField(this, \"_head\");\n __publicField(this, \"_tail\");\n __publicField(this, \"_length\", 0);\n this._head = void 0;\n this._tail = void 0;\n this._length = 0;\n if ((options == null ? void 0 : options.maxLen) && Number.isInteger(options.maxLen) && options.maxLen > 0) {\n this._maxLen = options.maxLen;\n }\n this.pushMany(elements);\n }\n /**\n * Get the head node.\n * @remarks Time O(1), Space O(1)\n * @returns Head node or undefined.\n */\n get head() {\n return this._head;\n }\n /**\n * Get the tail node.\n * @remarks Time O(1), Space O(1)\n * @returns Tail node or undefined.\n */\n get tail() {\n return this._tail;\n }\n /**\n * Get the number of elements.\n * @remarks Time O(1), Space O(1)\n * @returns Current length.\n */\n get length() {\n return this._length;\n }\n /**\n * Get the first element value.\n * @remarks Time O(1), Space O(1)\n * @returns First element or undefined.\n */\n get first() {\n var _a;\n return (_a = this.head) == null ? void 0 : _a.value;\n }\n /**\n * Get the last element value.\n * @remarks Time O(1), Space O(1)\n * @returns Last element or undefined.\n */\n get last() {\n var _a;\n return (_a = this.tail) == null ? void 0 : _a.value;\n }\n /**\n * Create a new list from an array of elements.\n * @remarks Time O(N), Space O(N)\n * @template E\n * @template R\n * @param this - The constructor (subclass) to instantiate.\n * @param data - Array of elements to insert.\n * @returns A new list populated with the array's elements.\n */\n static fromArray(data) {\n return new this(data);\n }\n /**\n * Type guard: check whether the input is a DoublyLinkedListNode.\n * @remarks Time O(1), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or predicate.\n * @returns True if the value is a DoublyLinkedListNode.\n */\n isNode(elementNodeOrPredicate) {\n return elementNodeOrPredicate instanceof DoublyLinkedListNode;\n }\n /**\n * Append an element/node to the tail.\n * @remarks Time O(1), Space O(1)\n * @param elementOrNode - Element or node to append.\n * @returns True when appended.\n */\n push(elementOrNode) {\n const newNode = this._ensureNode(elementOrNode);\n if (!this.head) {\n this._head = newNode;\n this._tail = newNode;\n } else {\n newNode.prev = this.tail;\n this.tail.next = newNode;\n this._tail = newNode;\n }\n this._length++;\n if (this._maxLen > 0 && this.length > this._maxLen) this.shift();\n return true;\n }\n /**\n * Remove and return the tail element.\n * @remarks Time O(1), Space O(1)\n * @returns Removed element or undefined.\n */\n pop() {\n if (!this.tail) return void 0;\n const removed = this.tail;\n if (this.head === this.tail) {\n this._head = void 0;\n this._tail = void 0;\n } else {\n this._tail = removed.prev;\n this.tail.next = void 0;\n }\n this._length--;\n return removed.value;\n }\n /**\n * Remove and return the head element.\n * @remarks Time O(1), Space O(1)\n * @returns Removed element or undefined.\n */\n shift() {\n if (!this.head) return void 0;\n const removed = this.head;\n if (this.head === this.tail) {\n this._head = void 0;\n this._tail = void 0;\n } else {\n this._head = removed.next;\n this.head.prev = void 0;\n }\n this._length--;\n return removed.value;\n }\n /**\n * Prepend an element/node to the head.\n * @remarks Time O(1), Space O(1)\n * @param elementOrNode - Element or node to prepend.\n * @returns True when prepended.\n */\n unshift(elementOrNode) {\n const newNode = this._ensureNode(elementOrNode);\n if (!this.head) {\n this._head = newNode;\n this._tail = newNode;\n } else {\n newNode.next = this.head;\n this.head.prev = newNode;\n this._head = newNode;\n }\n this._length++;\n if (this._maxLen > 0 && this._length > this._maxLen) this.pop();\n return true;\n }\n /**\n * Append a sequence of elements/nodes.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).\n * @returns Array of per-element success flags.\n */\n pushMany(elements) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) ans.push(this.push(this.toElementFn(el)));\n else ans.push(this.push(el));\n }\n return ans;\n }\n /**\n * Prepend a sequence of elements/nodes.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).\n * @returns Array of per-element success flags.\n */\n unshiftMany(elements) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) ans.push(this.unshift(this.toElementFn(el)));\n else ans.push(this.unshift(el));\n }\n return ans;\n }\n /**\n * Get the element at a given index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns Element or undefined.\n */\n at(index) {\n if (index < 0 || index >= this._length) return void 0;\n let current = this.head;\n for (let i = 0; i < index; i++) current = current.next;\n return current.value;\n }\n /**\n * Get the node reference at a given index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns Node or undefined.\n */\n getNodeAt(index) {\n if (index < 0 || index >= this._length) return void 0;\n let current = this.head;\n for (let i = 0; i < index; i++) current = current.next;\n return current;\n }\n /**\n * Find a node by value, reference, or predicate.\n * @remarks Time O(N), Space O(1)\n * @param [elementNodeOrPredicate] - Element, node, or predicate to match.\n * @returns Matching node or undefined.\n */\n getNode(elementNodeOrPredicate) {\n if (elementNodeOrPredicate === void 0) return;\n if (this.isNode(elementNodeOrPredicate)) {\n const target = elementNodeOrPredicate;\n let cur = this.head;\n while (cur) {\n if (cur === target) return target;\n cur = cur.next;\n }\n const isMatch = /* @__PURE__ */ __name((node) => this._equals(node.value, target.value), \"isMatch\");\n cur = this.head;\n while (cur) {\n if (isMatch(cur)) return cur;\n cur = cur.next;\n }\n return void 0;\n }\n const predicate = this._ensurePredicate(elementNodeOrPredicate);\n let current = this.head;\n while (current) {\n if (predicate(current)) return current;\n current = current.next;\n }\n return void 0;\n }\n /**\n * Insert a new element/node at an index, shifting following nodes.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @param newElementOrNode - Element or node to insert.\n * @returns True if inserted.\n */\n addAt(index, newElementOrNode) {\n if (index < 0 || index > this._length) return false;\n if (index === 0) return this.unshift(newElementOrNode);\n if (index === this._length) return this.push(newElementOrNode);\n const newNode = this._ensureNode(newElementOrNode);\n const prevNode = this.getNodeAt(index - 1);\n const nextNode = prevNode.next;\n newNode.prev = prevNode;\n newNode.next = nextNode;\n prevNode.next = newNode;\n nextNode.prev = newNode;\n this._length++;\n return true;\n }\n /**\n * Insert a new element/node before an existing one.\n * @remarks Time O(N), Space O(1)\n * @param existingElementOrNode - Existing element or node.\n * @param newElementOrNode - Element or node to insert.\n * @returns True if inserted.\n */\n addBefore(existingElementOrNode, newElementOrNode) {\n const existingNode = this.isNode(existingElementOrNode) ? existingElementOrNode : this.getNode(existingElementOrNode);\n if (!existingNode) return false;\n const newNode = this._ensureNode(newElementOrNode);\n newNode.prev = existingNode.prev;\n if (existingNode.prev) existingNode.prev.next = newNode;\n newNode.next = existingNode;\n existingNode.prev = newNode;\n if (existingNode === this.head) this._head = newNode;\n this._length++;\n return true;\n }\n /**\n * Insert a new element/node after an existing one.\n * @remarks Time O(N), Space O(1)\n * @param existingElementOrNode - Existing element or node.\n * @param newElementOrNode - Element or node to insert.\n * @returns True if inserted.\n */\n addAfter(existingElementOrNode, newElementOrNode) {\n const existingNode = this.isNode(existingElementOrNode) ? existingElementOrNode : this.getNode(existingElementOrNode);\n if (!existingNode) return false;\n const newNode = this._ensureNode(newElementOrNode);\n newNode.next = existingNode.next;\n if (existingNode.next) existingNode.next.prev = newNode;\n newNode.prev = existingNode;\n existingNode.next = newNode;\n if (existingNode === this.tail) this._tail = newNode;\n this._length++;\n return true;\n }\n /**\n * Set the element value at an index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @param value - New value.\n * @returns True if updated.\n */\n setAt(index, value) {\n const node = this.getNodeAt(index);\n if (!node) return false;\n node.value = value;\n return true;\n }\n /**\n * Delete the element at an index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index.\n * @returns Removed element or undefined.\n */\n deleteAt(index) {\n if (index < 0 || index >= this._length) return;\n if (index === 0) return this.shift();\n if (index === this._length - 1) return this.pop();\n const removedNode = this.getNodeAt(index);\n const prevNode = removedNode.prev;\n const nextNode = removedNode.next;\n prevNode.next = nextNode;\n nextNode.prev = prevNode;\n this._length--;\n return removedNode.value;\n }\n /**\n * Delete the first match by value/node.\n * @remarks Time O(N), Space O(1)\n * @param [elementOrNode] - Element or node to remove.\n * @returns True if removed.\n */\n delete(elementOrNode) {\n const node = this.getNode(elementOrNode);\n if (!node) return false;\n if (node === this.head) this.shift();\n else if (node === this.tail) this.pop();\n else {\n const prevNode = node.prev;\n const nextNode = node.next;\n prevNode.next = nextNode;\n nextNode.prev = prevNode;\n this._length--;\n }\n return true;\n }\n /**\n * Check whether the list is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if length is 0.\n */\n isEmpty() {\n return this._length === 0;\n }\n /**\n * Remove all nodes and reset length.\n * @remarks Time O(N), Space O(1)\n * @returns void\n */\n clear() {\n this._head = void 0;\n this._tail = void 0;\n this._length = 0;\n }\n /**\n * Find the first value matching a predicate scanning forward.\n * @remarks Time O(N), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or predicate to match.\n * @returns Matched value or undefined.\n */\n search(elementNodeOrPredicate) {\n const predicate = this._ensurePredicate(elementNodeOrPredicate);\n let current = this.head;\n while (current) {\n if (predicate(current)) return current.value;\n current = current.next;\n }\n return void 0;\n }\n /**\n * Find the first value matching a predicate scanning backward.\n * @remarks Time O(N), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or predicate to match.\n * @returns Matched value or undefined.\n */\n getBackward(elementNodeOrPredicate) {\n const predicate = this._ensurePredicate(elementNodeOrPredicate);\n let current = this.tail;\n while (current) {\n if (predicate(current)) return current.value;\n current = current.prev;\n }\n return void 0;\n }\n /**\n * Reverse the list in place.\n * @remarks Time O(N), Space O(1)\n * @returns This list.\n */\n reverse() {\n let current = this.head;\n [this._head, this._tail] = [this.tail, this.head];\n while (current) {\n const next = current.next;\n [current.prev, current.next] = [current.next, current.prev];\n current = next;\n }\n return this;\n }\n /**\n * Set the equality comparator used to compare values.\n * @remarks Time O(1), Space O(1)\n * @param equals - Equality predicate (a, b) → boolean.\n * @returns This list.\n */\n setEquality(equals) {\n this._equals = equals;\n return this;\n }\n /**\n * Deep clone this list (values are copied by reference).\n * @remarks Time O(N), Space O(N)\n * @returns A new list with the same element sequence.\n */\n clone() {\n const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n for (const v of this) out.push(v);\n return out;\n }\n /**\n * Filter values into a new list of the same class.\n * @remarks Time O(N), Space O(N)\n * @param callback - Predicate (value, index, list) → boolean to keep value.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new list with kept values.\n */\n filter(callback, thisArg) {\n const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n let index = 0;\n for (const v of this) if (callback.call(thisArg, v, index++, this)) out.push(v);\n return out;\n }\n /**\n * Map values into a new list of the same class.\n * @remarks Time O(N), Space O(N)\n * @param callback - Mapping function (value, index, list) → newValue.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new list with mapped values.\n */\n mapSame(callback, thisArg) {\n const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n let index = 0;\n for (const v of this) {\n const mv = thisArg === void 0 ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);\n out.push(mv);\n }\n return out;\n }\n /**\n * Map values into a new list (possibly different element type).\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param callback - Mapping function (value, index, list) → newElement.\n * @param [options] - Options for the output list (e.g., maxLen, toElementFn).\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new DoublyLinkedList with mapped values.\n */\n map(callback, options, thisArg) {\n const out = this._createLike([], { ...options != null ? options : {}, maxLen: this._maxLen });\n let index = 0;\n for (const v of this) out.push(callback.call(thisArg, v, index++, this));\n return out;\n }\n /**\n * (Protected) Create or return a node for the given input (node or raw element).\n * @remarks Time O(1), Space O(1)\n * @param elementOrNode - Element value or node to normalize.\n * @returns A DoublyLinkedListNode for the provided input.\n */\n _ensureNode(elementOrNode) {\n if (this.isNode(elementOrNode)) return elementOrNode;\n return new DoublyLinkedListNode(elementOrNode);\n }\n /**\n * (Protected) Normalize input into a predicate over nodes.\n * @remarks Time O(1), Space O(1)\n * @param elementNodeOrPredicate - Element, node, or node predicate.\n * @returns A predicate function taking a node and returning true/false.\n */\n _ensurePredicate(elementNodeOrPredicate) {\n if (this.isNode(elementNodeOrPredicate)) {\n const target = elementNodeOrPredicate;\n return (node) => node === target;\n }\n if (typeof elementNodeOrPredicate === \"function\") {\n return elementNodeOrPredicate;\n }\n const value = elementNodeOrPredicate;\n return (node) => this._equals(node.value, value);\n }\n /**\n * (Protected) Get the previous node of a given node.\n * @remarks Time O(1), Space O(1)\n * @param node - A node in the list.\n * @returns Previous node or undefined.\n */\n _getPrevNode(node) {\n return node.prev;\n }\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind list instance.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], options);\n }\n /**\n * (Protected) Create a like-kind instance and seed it from an iterable.\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param [elements] - Iterable used to seed the new list.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind DoublyLinkedList instance.\n */\n _createLike(elements = [], options) {\n const Ctor = this.constructor;\n return new Ctor(elements, options);\n }\n *_getIterator() {\n let current = this.head;\n while (current) {\n yield current.value;\n current = current.next;\n }\n }\n *_getReverseIterator() {\n let current = this.tail;\n while (current) {\n yield current.value;\n current = current.prev;\n }\n }\n *_getNodeIterator() {\n let current = this.head;\n while (current) {\n yield current;\n current = current.next;\n }\n }\n};\n__name(_DoublyLinkedList, \"DoublyLinkedList\");\nvar DoublyLinkedList = _DoublyLinkedList;\n\n// src/data-structures/linked-list/skip-linked-list.ts\nvar _SkipListNode = class _SkipListNode {\n constructor(key, value, level) {\n __publicField(this, \"key\");\n __publicField(this, \"value\");\n __publicField(this, \"forward\");\n this.key = key;\n this.value = value;\n this.forward = new Array(level);\n }\n};\n__name(_SkipListNode, \"SkipListNode\");\nvar SkipListNode = _SkipListNode;\nvar _SkipList = class _SkipList {\n constructor(elements = [], options) {\n __publicField(this, \"_head\", new SkipListNode(void 0, void 0, this.maxLevel));\n __publicField(this, \"_level\", 0);\n __publicField(this, \"_maxLevel\", 16);\n __publicField(this, \"_probability\", 0.5);\n if (options) {\n const { maxLevel, probability } = options;\n if (typeof maxLevel === \"number\") this._maxLevel = maxLevel;\n if (typeof probability === \"number\") this._probability = probability;\n }\n if (elements) {\n for (const [key, value] of elements) this.add(key, value);\n }\n }\n get head() {\n return this._head;\n }\n get level() {\n return this._level;\n }\n get maxLevel() {\n return this._maxLevel;\n }\n get probability() {\n return this._probability;\n }\n get first() {\n const firstNode = this.head.forward[0];\n return firstNode ? firstNode.value : void 0;\n }\n get last() {\n let current = this.head;\n for (let i = this.level - 1; i >= 0; i--) {\n while (current.forward[i]) {\n current = current.forward[i];\n }\n }\n return current.value;\n }\n add(key, value) {\n const newNode = new SkipListNode(key, value, this._randomLevel());\n const update = new Array(this.maxLevel).fill(this.head);\n let current = this.head;\n for (let i = this.level - 1; i >= 0; i--) {\n while (current.forward[i] && current.forward[i].key < key) {\n current = current.forward[i];\n }\n update[i] = current;\n }\n for (let i = 0; i < newNode.forward.length; i++) {\n newNode.forward[i] = update[i].forward[i];\n update[i].forward[i] = newNode;\n }\n if (!newNode.forward[0]) {\n this._level = Math.max(this.level, newNode.forward.length);\n }\n }\n get(key) {\n let current = this.head;\n for (let i = this.level - 1; i >= 0; i--) {\n while (current.forward[i] && current.forward[i].key < key) {\n current = current.forward[i];\n }\n }\n current = current.forward[0];\n if (current && current.key === key) {\n return current.value;\n }\n return void 0;\n }\n has(key) {\n return this.get(key) !== void 0;\n }\n delete(key) {\n const update = new Array(this.maxLevel).fill(this.head);\n let current = this.head;\n for (let i = this.level - 1; i >= 0; i--) {\n while (current.forward[i] && current.forward[i].key < key) {\n current = current.forward[i];\n }\n update[i] = current;\n }\n current = current.forward[0];\n if (current && current.key === key) {\n for (let i = 0; i < this.level; i++) {\n if (update[i].forward[i] !== current) {\n break;\n }\n update[i].forward[i] = current.forward[i];\n }\n while (this.level > 0 && !this.head.forward[this.level - 1]) {\n this._level--;\n }\n return true;\n }\n return false;\n }\n higher(key) {\n let current = this.head;\n for (let i = this.level - 1; i >= 0; i--) {\n while (current.forward[i] && current.forward[i].key <= key) {\n current = current.forward[i];\n }\n }\n const nextNode = current.forward[0];\n return nextNode ? nextNode.value : void 0;\n }\n lower(key) {\n let current = this.head;\n let lastLess = void 0;\n for (let i = this.level - 1; i >= 0; i--) {\n while (current.forward[i] && current.forward[i].key < key) {\n current = current.forward[i];\n }\n if (current.key < key) {\n lastLess = current;\n }\n }\n return lastLess ? lastLess.value : void 0;\n }\n _randomLevel() {\n let level = 1;\n while (Math.random() < this.probability && level < this.maxLevel) {\n level++;\n }\n return level;\n }\n};\n__name(_SkipList, \"SkipList\");\nvar SkipList = _SkipList;\n\n// src/data-structures/stack/stack.ts\nvar _Stack = class _Stack extends IterableElementBase {\n /**\n * Create a Stack and optionally bulk-push elements.\n * @remarks Time O(N), Space O(N)\n * @param [elements] - Iterable of elements (or raw records if toElementFn is set).\n * @param [options] - Options such as toElementFn and equality function.\n * @returns New Stack instance.\n */\n constructor(elements = [], options) {\n super(options);\n __publicField(this, \"_equals\", Object.is);\n __publicField(this, \"_elements\", []);\n this.pushMany(elements);\n }\n /**\n * Get the backing array of elements.\n * @remarks Time O(1), Space O(1)\n * @returns Internal elements array.\n */\n get elements() {\n return this._elements;\n }\n /**\n * Get the number of stored elements.\n * @remarks Time O(1), Space O(1)\n * @returns Current size.\n */\n get size() {\n return this.elements.length;\n }\n /**\n * Create a stack from an array of elements.\n * @remarks Time O(N), Space O(N)\n * @template E\n * @template R\n * @param this - The constructor (subclass) to instantiate.\n * @param elements - Array of elements to push in order.\n * @param [options] - Options forwarded to the constructor.\n * @returns A new Stack populated from the array.\n */\n static fromArray(elements, options) {\n return new this(elements, options);\n }\n /**\n * Check whether the stack is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if size is 0.\n */\n isEmpty() {\n return this.elements.length === 0;\n }\n /**\n * Get the top element without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns Top element or undefined.\n */\n peek() {\n return this.isEmpty() ? void 0 : this.elements[this.elements.length - 1];\n }\n /**\n * Push one element onto the top.\n * @remarks Time O(1), Space O(1)\n * @param element - Element to push.\n * @returns True when pushed.\n */\n push(element) {\n this.elements.push(element);\n return true;\n }\n /**\n * Pop and return the top element.\n * @remarks Time O(1), Space O(1)\n * @returns Removed element or undefined.\n */\n pop() {\n return this.isEmpty() ? void 0 : this.elements.pop();\n }\n /**\n * Push many elements from an iterable.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable of elements (or raw records if toElementFn is set).\n * @returns Array of per-element success flags.\n */\n pushMany(elements) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) ans.push(this.push(this.toElementFn(el)));\n else ans.push(this.push(el));\n }\n return ans;\n }\n /**\n * Delete the first occurrence of a specific element.\n * @remarks Time O(N), Space O(1)\n * @param element - Element to remove (using the configured equality).\n * @returns True if an element was removed.\n */\n delete(element) {\n const idx = this._indexOfByEquals(element);\n return this.deleteAt(idx);\n }\n /**\n * Delete the element at an index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index from the bottom.\n * @returns True if removed.\n */\n deleteAt(index) {\n if (index < 0 || index >= this.elements.length) return false;\n const spliced = this.elements.splice(index, 1);\n return spliced.length === 1;\n }\n /**\n * Delete the first element that satisfies a predicate.\n * @remarks Time O(N), Space O(1)\n * @param predicate - Function (value, index, stack) → boolean to decide deletion.\n * @returns True if a match was removed.\n */\n deleteWhere(predicate) {\n for (let i = 0; i < this.elements.length; i++) {\n if (predicate(this.elements[i], i, this)) {\n this.elements.splice(i, 1);\n return true;\n }\n }\n return false;\n }\n /**\n * Remove all elements and reset storage.\n * @remarks Time O(1), Space O(1)\n * @returns void\n */\n clear() {\n this._elements = [];\n }\n /**\n * Deep clone this stack.\n * @remarks Time O(N), Space O(N)\n * @returns A new stack with the same content.\n */\n clone() {\n const out = this._createInstance({ toElementFn: this.toElementFn });\n for (const v of this) out.push(v);\n return out;\n }\n /**\n * Filter elements into a new stack of the same class.\n * @remarks Time O(N), Space O(N)\n * @param predicate - Predicate (value, index, stack) → boolean to keep value.\n * @param [thisArg] - Value for `this` inside the predicate.\n * @returns A new stack with kept values.\n */\n filter(predicate, thisArg) {\n const out = this._createInstance({ toElementFn: this.toElementFn });\n let index = 0;\n for (const v of this) {\n if (predicate.call(thisArg, v, index, this)) out.push(v);\n index++;\n }\n return out;\n }\n /**\n * Map values into a new stack of the same element type.\n * @remarks Time O(N), Space O(N)\n * @param callback - Mapping function (value, index, stack) → newValue.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new stack with mapped values.\n */\n mapSame(callback, thisArg) {\n const out = this._createInstance({ toElementFn: this.toElementFn });\n let index = 0;\n for (const v of this) {\n const mv = thisArg === void 0 ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);\n out.push(mv);\n }\n return out;\n }\n /**\n * Map values into a new stack (possibly different element type).\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param callback - Mapping function (value, index, stack) → newElement.\n * @param [options] - Options for the output stack (e.g., toElementFn).\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new Stack with mapped elements.\n */\n map(callback, options, thisArg) {\n const out = this._createLike([], { ...options != null ? options : {} });\n let index = 0;\n for (const v of this) {\n out.push(thisArg === void 0 ? callback(v, index, this) : callback.call(thisArg, v, index, this));\n index++;\n }\n return out;\n }\n /**\n * Set the equality comparator used by delete/search operations.\n * @remarks Time O(1), Space O(1)\n * @param equals - Equality predicate (a, b) → boolean.\n * @returns This stack.\n */\n setEquality(equals) {\n this._equals = equals;\n return this;\n }\n /**\n * (Protected) Find the index of a target element using the equality function.\n * @remarks Time O(N), Space O(1)\n * @param target - Element to search for.\n * @returns Index or -1 if not found.\n */\n _indexOfByEquals(target) {\n for (let i = 0; i < this.elements.length; i++) if (this._equals(this.elements[i], target)) return i;\n return -1;\n }\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind stack instance.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], options);\n }\n /**\n * (Protected) Create a like-kind stack and seed it from an iterable.\n * @remarks Time O(N), Space O(N)\n * @template T\n * @template RR\n * @param [elements] - Iterable used to seed the new stack.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind Stack instance.\n */\n _createLike(elements = [], options) {\n const Ctor = this.constructor;\n return new Ctor(elements, options);\n }\n /**\n * (Protected) Iterate elements from bottom to top.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of elements.\n */\n *_getIterator() {\n for (let i = 0; i < this.elements.length; i++) yield this.elements[i];\n }\n};\n__name(_Stack, \"Stack\");\nvar Stack = _Stack;\n\n// src/data-structures/queue/queue.ts\nvar _Queue = class _Queue extends LinearBase {\n /**\n * Create a Queue and optionally bulk-insert elements.\n * @remarks Time O(N), Space O(N)\n * @param [elements] - Iterable of elements (or raw records if toElementFn is set).\n * @param [options] - Options such as toElementFn, maxLen, and autoCompactRatio.\n * @returns New Queue instance.\n */\n constructor(elements = [], options) {\n super(options);\n __publicField(this, \"_elements\", []);\n __publicField(this, \"_offset\", 0);\n __publicField(this, \"_autoCompactRatio\", 0.5);\n if (options) {\n const { autoCompactRatio = 0.5 } = options;\n this._autoCompactRatio = autoCompactRatio;\n }\n this.pushMany(elements);\n }\n /**\n * Get the underlying array buffer.\n * @remarks Time O(1), Space O(1)\n * @returns Backing array of elements.\n */\n get elements() {\n return this._elements;\n }\n /**\n * Get the current start offset into the array.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based offset.\n */\n get offset() {\n return this._offset;\n }\n /**\n * Get the compaction threshold (offset/size).\n * @remarks Time O(1), Space O(1)\n * @returns Auto-compaction ratio in (0,1].\n */\n get autoCompactRatio() {\n return this._autoCompactRatio;\n }\n /**\n * Set the compaction threshold.\n * @remarks Time O(1), Space O(1)\n * @param value - New ratio; compacts when offset/size exceeds this value.\n * @returns void\n */\n set autoCompactRatio(value) {\n this._autoCompactRatio = value;\n }\n /**\n * Get the number of elements currently in the queue.\n * @remarks Time O(1), Space O(1)\n * @returns Current length.\n */\n get length() {\n return this.elements.length - this._offset;\n }\n /**\n * Get the first element (front) without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns Front element or undefined.\n */\n get first() {\n return this.length > 0 ? this.elements[this._offset] : void 0;\n }\n /**\n * Get the last element (back) without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns Back element or undefined.\n */\n get last() {\n return this.length > 0 ? this.elements[this.elements.length - 1] : void 0;\n }\n /**\n * Create a queue from an array of elements.\n * @remarks Time O(N), Space O(N)\n * @template E\n * @param elements - Array of elements to enqueue in order.\n * @returns A new queue populated from the array.\n */\n static fromArray(elements) {\n return new _Queue(elements);\n }\n /**\n * Check whether the queue is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if length is 0.\n */\n isEmpty() {\n return this.length === 0;\n }\n /**\n * Enqueue one element at the back.\n * @remarks Time O(1), Space O(1)\n * @param element - Element to enqueue.\n * @returns True on success.\n */\n push(element) {\n this.elements.push(element);\n if (this._maxLen > 0 && this.length > this._maxLen) this.shift();\n return true;\n }\n /**\n * Enqueue many elements from an iterable.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable of elements (or raw records if toElementFn is set).\n * @returns Array of per-element success flags.\n */\n pushMany(elements) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) ans.push(this.push(this.toElementFn(el)));\n else ans.push(this.push(el));\n }\n return ans;\n }\n /**\n * Dequeue one element from the front (amortized via offset).\n * @remarks Time O(1) amortized, Space O(1)\n * @returns Removed element or undefined.\n */\n shift() {\n if (this.length === 0) return void 0;\n const first = this.first;\n this._offset += 1;\n if (this.elements.length > 0 && this.offset / this.elements.length > this.autoCompactRatio) this.compact();\n return first;\n }\n /**\n * Delete the first occurrence of a specific element.\n * @remarks Time O(N), Space O(1)\n * @param element - Element to remove (strict equality via Object.is).\n * @returns True if an element was removed.\n */\n delete(element) {\n for (let i = this._offset; i < this.elements.length; i++) {\n if (Object.is(this.elements[i], element)) {\n this.elements.splice(i, 1);\n return true;\n }\n }\n return false;\n }\n /**\n * Get the element at a given logical index.\n * @remarks Time O(1), Space O(1)\n * @param index - Zero-based index from the front.\n * @returns Element or undefined.\n */\n at(index) {\n if (index < 0 || index >= this.length) return void 0;\n return this._elements[this._offset + index];\n }\n /**\n * Delete the element at a given index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index from the front.\n * @returns Removed element or undefined.\n */\n deleteAt(index) {\n if (index < 0 || index >= this.length) return void 0;\n const gi = this._offset + index;\n const [deleted] = this.elements.splice(gi, 1);\n return deleted;\n }\n /**\n * Insert a new element at a given index.\n * @remarks Time O(N), Space O(1)\n * @param index - Zero-based index from the front.\n * @param newElement - Element to insert.\n * @returns True if inserted.\n */\n addAt(index, newElement) {\n if (index < 0 || index > this.length) return false;\n this._elements.splice(this._offset + index, 0, newElement);\n return true;\n }\n /**\n * Replace the element at a given index.\n * @remarks Time O(1), Space O(1)\n * @param index - Zero-based index from the front.\n * @param newElement - New element to set.\n * @returns True if updated.\n */\n setAt(index, newElement) {\n if (index < 0 || index >= this.length) return false;\n this._elements[this._offset + index] = newElement;\n return true;\n }\n /**\n * Reverse the queue in-place by compacting then reversing.\n * @remarks Time O(N), Space O(N)\n * @returns This queue.\n */\n reverse() {\n this._elements = this.elements.slice(this._offset).reverse();\n this._offset = 0;\n return this;\n }\n /**\n * Remove all elements and reset offset.\n * @remarks Time O(1), Space O(1)\n * @returns void\n */\n clear() {\n this._elements = [];\n this._offset = 0;\n }\n /**\n * Compact storage by discarding consumed head elements.\n * @remarks Time O(N), Space O(N)\n * @returns True when compaction performed.\n */\n compact() {\n this._elements = this.elements.slice(this._offset);\n this._offset = 0;\n return true;\n }\n /**\n * Remove and/or insert elements at a position (array-like).\n * @remarks Time O(N + M), Space O(M)\n * @param start - Start index (clamped to [0, length]).\n * @param [deleteCount] - Number of elements to remove (default 0).\n * @param [items] - Elements to insert after `start`.\n * @returns A new queue containing the removed elements (typed as `this`).\n */\n splice(start, deleteCount = 0, ...items) {\n start = Math.max(0, Math.min(start, this.length));\n deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));\n const gi = this._offset + start;\n const removedArray = this._elements.splice(gi, deleteCount, ...items);\n if (this.elements.length > 0 && this.offset / this.elements.length > this.autoCompactRatio) this.compact();\n const removed = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });\n removed._setAutoCompactRatio(this._autoCompactRatio);\n removed.pushMany(removedArray);\n return removed;\n }\n /**\n * Deep clone this queue and its parameters.\n * @remarks Time O(N), Space O(N)\n * @returns A new queue with the same content and options.\n */\n clone() {\n const out = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });\n out._setAutoCompactRatio(this._autoCompactRatio);\n for (let i = this._offset; i < this.elements.length; i++) out.push(this.elements[i]);\n return out;\n }\n /**\n * Filter elements into a new queue of the same class.\n * @remarks Time O(N), Space O(N)\n * @param predicate - Predicate (element, index, queue) → boolean to keep element.\n * @param [thisArg] - Value for `this` inside the predicate.\n * @returns A new queue with kept elements.\n */\n filter(predicate, thisArg) {\n const out = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });\n out._setAutoCompactRatio(this._autoCompactRatio);\n let index = 0;\n for (const v of this) {\n if (predicate.call(thisArg, v, index, this)) out.push(v);\n index++;\n }\n return out;\n }\n /**\n * Map each element to a new element in a possibly different-typed queue.\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param callback - Mapping function (element, index, queue) → newElement.\n * @param [options] - Options for the output queue (e.g., toElementFn, maxLen, autoCompactRatio).\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new Queue with mapped elements.\n */\n map(callback, options, thisArg) {\n var _a, _b;\n const out = new this.constructor([], {\n toElementFn: options == null ? void 0 : options.toElementFn,\n maxLen: (_a = options == null ? void 0 : options.maxLen) != null ? _a : this._maxLen,\n autoCompactRatio: (_b = options == null ? void 0 : options.autoCompactRatio) != null ? _b : this._autoCompactRatio\n });\n let index = 0;\n for (const v of this)\n out.push(thisArg === void 0 ? callback(v, index++, this) : callback.call(thisArg, v, index++, this));\n return out;\n }\n /**\n * Map each element to a new value of the same type.\n * @remarks Time O(N), Space O(N)\n * @param callback - Mapping function (element, index, queue) → element.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new queue with mapped elements (same element type).\n */\n mapSame(callback, thisArg) {\n var _a;\n const Ctor = this.constructor;\n const out = new Ctor([], {\n toElementFn: this.toElementFn,\n maxLen: this._maxLen,\n autoCompactRatio: this._autoCompactRatio\n });\n (_a = out._setAutoCompactRatio) == null ? void 0 : _a.call(out, this._autoCompactRatio);\n let index = 0;\n for (const v of this) {\n const mv = thisArg === void 0 ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);\n out.push(mv);\n }\n return out;\n }\n /**\n * (Protected) Set the internal auto-compaction ratio.\n * @remarks Time O(1), Space O(1)\n * @param value - New ratio to assign.\n * @returns void\n */\n _setAutoCompactRatio(value) {\n this._autoCompactRatio = value;\n }\n /**\n * (Protected) Iterate elements from front to back.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of E.\n */\n *_getIterator() {\n for (let i = this._offset; i < this.elements.length; i++) yield this.elements[i];\n }\n /**\n * (Protected) Iterate elements from back to front.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of E.\n */\n *_getReverseIterator() {\n for (let i = this.length - 1; i >= 0; i--) {\n const cur = this.at(i);\n if (cur !== void 0) yield cur;\n }\n }\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind queue instance.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], options);\n }\n /**\n * (Protected) Create a like-kind queue and seed it from an iterable.\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param [elements] - Iterable used to seed the new queue.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind Queue instance.\n */\n _createLike(elements = [], options) {\n const Ctor = this.constructor;\n return new Ctor(elements, options);\n }\n};\n__name(_Queue, \"Queue\");\nvar Queue = _Queue;\nvar _LinkedListQueue = class _LinkedListQueue extends SinglyLinkedList {\n /**\n * Deep clone this linked-list-based queue.\n * @remarks Time O(N), Space O(N)\n * @returns A new queue with the same sequence of elements.\n */\n clone() {\n const out = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });\n for (const v of this) out.push(v);\n return out;\n }\n};\n__name(_LinkedListQueue, \"LinkedListQueue\");\nvar LinkedListQueue = _LinkedListQueue;\n\n// src/data-structures/queue/deque.ts\nvar _Deque = class _Deque extends LinearBase {\n /**\n * Create a Deque and optionally bulk-insert elements.\n * @remarks Time O(N), Space O(N)\n * @param [elements] - Iterable (or iterable-like) of elements/records to insert.\n * @param [options] - Options such as bucketSize, toElementFn, and maxLen.\n * @returns New Deque instance.\n */\n constructor(elements = [], options) {\n super(options);\n __publicField(this, \"_equals\", Object.is);\n __publicField(this, \"_bucketSize\", 1 << 12);\n __publicField(this, \"_bucketFirst\", 0);\n __publicField(this, \"_firstInBucket\", 0);\n __publicField(this, \"_bucketLast\", 0);\n __publicField(this, \"_lastInBucket\", 0);\n __publicField(this, \"_bucketCount\", 0);\n __publicField(this, \"_buckets\", []);\n __publicField(this, \"_length\", 0);\n if (options) {\n const { bucketSize } = options;\n if (typeof bucketSize === \"number\") this._bucketSize = bucketSize;\n }\n let _size;\n if (\"length\" in elements) {\n _size = typeof elements.length === \"function\" ? elements.length() : elements.length;\n } else {\n _size = typeof elements.size === \"function\" ? elements.size() : elements.size;\n }\n this._bucketCount = calcMinUnitsRequired(_size, this._bucketSize) || 1;\n for (let i = 0; i < this._bucketCount; ++i) {\n this._buckets.push(new Array(this._bucketSize));\n }\n const needBucketNum = calcMinUnitsRequired(_size, this._bucketSize);\n this._bucketFirst = this._bucketLast = (this._bucketCount >> 1) - (needBucketNum >> 1);\n this._firstInBucket = this._lastInBucket = this._bucketSize - _size % this._bucketSize >> 1;\n this.pushMany(elements);\n }\n /**\n * Get the current bucket size.\n * @remarks Time O(1), Space O(1)\n * @returns Bucket capacity per bucket.\n */\n get bucketSize() {\n return this._bucketSize;\n }\n /**\n * Get the index of the first bucket in use.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based bucket index.\n */\n get bucketFirst() {\n return this._bucketFirst;\n }\n /**\n * Get the index inside the first bucket.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based index within the first bucket.\n */\n get firstInBucket() {\n return this._firstInBucket;\n }\n /**\n * Get the index of the last bucket in use.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based bucket index.\n */\n get bucketLast() {\n return this._bucketLast;\n }\n /**\n * Get the index inside the last bucket.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based index within the last bucket.\n */\n get lastInBucket() {\n return this._lastInBucket;\n }\n /**\n * Get the number of buckets allocated.\n * @remarks Time O(1), Space O(1)\n * @returns Bucket count.\n */\n get bucketCount() {\n return this._bucketCount;\n }\n /**\n * Get the internal buckets array.\n * @remarks Time O(1), Space O(1)\n * @returns Array of buckets storing values.\n */\n get buckets() {\n return this._buckets;\n }\n /**\n * Get the number of elements in the deque.\n * @remarks Time O(1), Space O(1)\n * @returns Current length.\n */\n get length() {\n return this._length;\n }\n /**\n * Get the first element without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns First element or undefined.\n */\n get first() {\n if (this._length === 0) return;\n return this._buckets[this._bucketFirst][this._firstInBucket];\n }\n /**\n * Get the last element without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns Last element or undefined.\n */\n get last() {\n if (this._length === 0) return;\n return this._buckets[this._bucketLast][this._lastInBucket];\n }\n /**\n * Create a Deque from an array of elements.\n * @remarks Time O(N), Space O(N)\n * @template E\n * @template R\n * @param this - Constructor (subclass) to instantiate.\n * @param data - Array of elements to insert in order.\n * @param [options] - Options forwarded to the constructor.\n * @returns A new Deque populated from the array.\n */\n static fromArray(data, options) {\n return new this(data, options);\n }\n /**\n * Append one element at the back.\n * @remarks Time O(1) amortized, Space O(1)\n * @param element - Element to append.\n * @returns True when appended.\n */\n push(element) {\n if (this._length) {\n if (this._lastInBucket < this._bucketSize - 1) {\n this._lastInBucket += 1;\n } else if (this._bucketLast < this._bucketCount - 1) {\n this._bucketLast += 1;\n this._lastInBucket = 0;\n } else {\n this._bucketLast = 0;\n this._lastInBucket = 0;\n }\n if (this._bucketLast === this._bucketFirst && this._lastInBucket === this._firstInBucket) this._reallocate();\n }\n this._length += 1;\n this._buckets[this._bucketLast][this._lastInBucket] = element;\n if (this._maxLen > 0 && this._length > this._maxLen) this.shift();\n return true;\n }\n /**\n * Remove and return the last element.\n * @remarks Time O(1), Space O(1)\n * @returns Removed element or undefined.\n */\n pop() {\n if (this._length === 0) return;\n const element = this._buckets[this._bucketLast][this._lastInBucket];\n if (this._length !== 1) {\n if (this._lastInBucket > 0) {\n this._lastInBucket -= 1;\n } else if (this._bucketLast > 0) {\n this._bucketLast -= 1;\n this._lastInBucket = this._bucketSize - 1;\n } else {\n this._bucketLast = this._bucketCount - 1;\n this._lastInBucket = this._bucketSize - 1;\n }\n }\n this._length -= 1;\n return element;\n }\n /**\n * Remove and return the first element.\n * @remarks Time O(1) amortized, Space O(1)\n * @returns Removed element or undefined.\n */\n shift() {\n if (this._length === 0) return;\n const element = this._buckets[this._bucketFirst][this._firstInBucket];\n if (this._length !== 1) {\n if (this._firstInBucket < this._bucketSize - 1) {\n this._firstInBucket += 1;\n } else if (this._bucketFirst < this._bucketCount - 1) {\n this._bucketFirst += 1;\n this._firstInBucket = 0;\n } else {\n this._bucketFirst = 0;\n this._firstInBucket = 0;\n }\n }\n this._length -= 1;\n return element;\n }\n /**\n * Prepend one element at the front.\n * @remarks Time O(1) amortized, Space O(1)\n * @param element - Element to prepend.\n * @returns True when prepended.\n */\n unshift(element) {\n if (this._length) {\n if (this._firstInBucket > 0) {\n this._firstInBucket -= 1;\n } else if (this._bucketFirst > 0) {\n this._bucketFirst -= 1;\n this._firstInBucket = this._bucketSize - 1;\n } else {\n this._bucketFirst = this._bucketCount - 1;\n this._firstInBucket = this._bucketSize - 1;\n }\n if (this._bucketFirst === this._bucketLast && this._firstInBucket === this._lastInBucket) this._reallocate();\n }\n this._length += 1;\n this._buckets[this._bucketFirst][this._firstInBucket] = element;\n if (this._maxLen > 0 && this._length > this._maxLen) this.pop();\n return true;\n }\n /**\n * Append a sequence of elements.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable (or iterable-like) of elements/records.\n * @returns Array of per-element success flags.\n */\n pushMany(elements) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) {\n ans.push(this.push(this.toElementFn(el)));\n } else {\n ans.push(this.push(el));\n }\n }\n return ans;\n }\n /**\n * Prepend a sequence of elements.\n * @remarks Time O(N), Space O(1)\n * @param [elements] - Iterable (or iterable-like) of elements/records.\n * @returns Array of per-element success flags.\n */\n unshiftMany(elements = []) {\n const ans = [];\n for (const el of elements) {\n if (this.toElementFn) {\n ans.push(this.unshift(this.toElementFn(el)));\n } else {\n ans.push(this.unshift(el));\n }\n }\n return ans;\n }\n /**\n * Check whether the deque is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if length is 0.\n */\n isEmpty() {\n return this._length === 0;\n }\n /**\n * Remove all elements and reset structure.\n * @remarks Time O(1), Space O(1)\n * @returns void\n */\n clear() {\n this._buckets = [new Array(this._bucketSize)];\n this._bucketCount = 1;\n this._bucketFirst = this._bucketLast = this._length = 0;\n this._firstInBucket = this._lastInBucket = this._bucketSize >> 1;\n }\n /**\n * Get the element at a given position.\n * @remarks Time O(1), Space O(1)\n * @param pos - Zero-based position from the front.\n * @returns Element or undefined.\n */\n at(pos) {\n if (pos < 0 || pos >= this._length) return void 0;\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n return this._buckets[bucketIndex][indexInBucket];\n }\n /**\n * Replace the element at a given position.\n * @remarks Time O(1), Space O(1)\n * @param pos - Zero-based position from the front.\n * @param element - New element value.\n * @returns True if updated.\n */\n setAt(pos, element) {\n rangeCheck(pos, 0, this._length - 1);\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n this._buckets[bucketIndex][indexInBucket] = element;\n return true;\n }\n /**\n * Insert repeated copies of an element at a position.\n * @remarks Time O(N), Space O(1)\n * @param pos - Zero-based position from the front.\n * @param element - Element to insert.\n * @param [num] - Number of times to insert (default 1).\n * @returns True if inserted.\n */\n addAt(pos, element, num = 1) {\n const length = this._length;\n rangeCheck(pos, 0, length);\n if (pos === 0) {\n while (num--) this.unshift(element);\n } else if (pos === this._length) {\n while (num--) this.push(element);\n } else {\n const arr = [];\n for (let i = pos; i < this._length; ++i) {\n const v = this.at(i);\n if (v !== void 0) arr.push(v);\n }\n this.cut(pos - 1, true);\n for (let i = 0; i < num; ++i) this.push(element);\n for (let i = 0; i < arr.length; ++i) this.push(arr[i]);\n }\n return true;\n }\n /**\n * Cut the deque to keep items up to index; optionally mutate in-place.\n * @remarks Time O(N), Space O(1)\n * @param pos - Last index to keep.\n * @param [isCutSelf] - When true, mutate this deque; otherwise return a new deque.\n * @returns This deque if in-place; otherwise a new deque of the prefix.\n */\n cut(pos, isCutSelf = false) {\n if (isCutSelf) {\n if (pos < 0) {\n this.clear();\n return this;\n }\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n this._bucketLast = bucketIndex;\n this._lastInBucket = indexInBucket;\n this._length = pos + 1;\n return this;\n } else {\n const newDeque = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n newDeque._setBucketSize(this._bucketSize);\n for (let i = 0; i <= pos; i++) {\n const v = this.at(i);\n if (v !== void 0) newDeque.push(v);\n }\n return newDeque;\n }\n }\n /**\n * Remove and/or insert elements at a position (array-like behavior).\n * @remarks Time O(N + M), Space O(M)\n * @param start - Start index (clamped to [0, length]).\n * @param [deleteCount] - Number of elements to remove (default: length - start).\n * @param [items] - Elements to insert after `start`.\n * @returns A new deque containing the removed elements (typed as `this`).\n */\n splice(start, deleteCount = this._length - start, ...items) {\n rangeCheck(start, 0, this._length);\n if (deleteCount < 0) deleteCount = 0;\n if (start + deleteCount > this._length) deleteCount = this._length - start;\n const removed = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n removed._setBucketSize(this._bucketSize);\n for (let i = 0; i < deleteCount; i++) {\n const v = this.at(start + i);\n if (v !== void 0) removed.push(v);\n }\n const tail = [];\n for (let i = start + deleteCount; i < this._length; i++) {\n const v = this.at(i);\n if (v !== void 0) tail.push(v);\n }\n this.cut(start - 1, true);\n for (const it of items) this.push(it);\n for (const v of tail) this.push(v);\n return removed;\n }\n /**\n * Cut the deque to keep items from index onward; optionally mutate in-place.\n * @remarks Time O(N), Space O(1)\n * @param pos - First index to keep.\n * @param [isCutSelf] - When true, mutate this deque; otherwise return a new deque.\n * @returns This deque if in-place; otherwise a new deque of the suffix.\n */\n cutRest(pos, isCutSelf = false) {\n if (isCutSelf) {\n if (pos < 0) {\n return this;\n }\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n this._bucketFirst = bucketIndex;\n this._firstInBucket = indexInBucket;\n this._length = this._length - pos;\n return this;\n } else {\n const newDeque = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n newDeque._setBucketSize(this._bucketSize);\n if (pos < 0) pos = 0;\n for (let i = pos; i < this._length; i++) {\n const v = this.at(i);\n if (v !== void 0) newDeque.push(v);\n }\n return newDeque;\n }\n }\n /**\n * Delete the element at a given position.\n * @remarks Time O(N), Space O(1)\n * @param pos - Zero-based position from the front.\n * @returns Removed element or undefined.\n */\n deleteAt(pos) {\n rangeCheck(pos, 0, this._length - 1);\n let deleted;\n if (pos === 0) {\n return this.shift();\n } else if (pos === this._length - 1) {\n deleted = this.last;\n this.pop();\n return deleted;\n } else {\n const length = this._length - 1;\n const { bucketIndex: targetBucket, indexInBucket: targetPointer } = this._getBucketAndPosition(pos);\n deleted = this._buckets[targetBucket][targetPointer];\n for (let i = pos; i < length; i++) {\n const { bucketIndex: curBucket, indexInBucket: curPointer } = this._getBucketAndPosition(i);\n const { bucketIndex: nextBucket, indexInBucket: nextPointer } = this._getBucketAndPosition(i + 1);\n this._buckets[curBucket][curPointer] = this._buckets[nextBucket][nextPointer];\n }\n this.pop();\n return deleted;\n }\n }\n /**\n * Delete the first occurrence of a value.\n * @remarks Time O(N), Space O(1)\n * @param element - Element to remove (using the configured equality).\n * @returns True if an element was removed.\n */\n delete(element) {\n const size = this._length;\n if (size === 0) return false;\n let i = 0;\n let index = 0;\n while (i < size) {\n const oldElement = this.at(i);\n if (!this._equals(oldElement, element)) {\n this.setAt(index, oldElement);\n index += 1;\n }\n i += 1;\n }\n this.cut(index - 1, true);\n return true;\n }\n /**\n * Delete the first element matching a predicate.\n * @remarks Time O(N), Space O(1)\n * @param predicate - Function (value, index, deque) → boolean.\n * @returns True if a match was removed.\n */\n deleteWhere(predicate) {\n for (let i = 0; i < this._length; i++) {\n const v = this.at(i);\n if (predicate(v, i, this)) {\n this.deleteAt(i);\n return true;\n }\n }\n return false;\n }\n /**\n * Set the equality comparator used by delete operations.\n * @remarks Time O(1), Space O(1)\n * @param equals - Equality predicate (a, b) → boolean.\n * @returns This deque.\n */\n setEquality(equals) {\n this._equals = equals;\n return this;\n }\n /**\n * Reverse the deque by reversing buckets and pointers.\n * @remarks Time O(N), Space O(N)\n * @returns This deque.\n */\n reverse() {\n this._buckets.reverse().forEach(function(bucket) {\n bucket.reverse();\n });\n const { _bucketFirst, _bucketLast, _firstInBucket, _lastInBucket } = this;\n this._bucketFirst = this._bucketCount - _bucketLast - 1;\n this._bucketLast = this._bucketCount - _bucketFirst - 1;\n this._firstInBucket = this._bucketSize - _lastInBucket - 1;\n this._lastInBucket = this._bucketSize - _firstInBucket - 1;\n return this;\n }\n /**\n * Deduplicate consecutive equal elements in-place.\n * @remarks Time O(N), Space O(1)\n * @returns This deque.\n */\n unique() {\n if (this._length <= 1) {\n return this;\n }\n let index = 1;\n let prev = this.at(0);\n for (let i = 1; i < this._length; ++i) {\n const cur = this.at(i);\n if (!this._equals(cur, prev)) {\n prev = cur;\n this.setAt(index++, cur);\n }\n }\n this.cut(index - 1, true);\n return this;\n }\n /**\n * Trim unused buckets to fit exactly the active range.\n * @remarks Time O(N), Space O(1)\n * @returns void\n */\n shrinkToFit() {\n if (this._length === 0) return;\n const newBuckets = [];\n if (this._bucketFirst === this._bucketLast) return;\n else if (this._bucketFirst < this._bucketLast) {\n for (let i = this._bucketFirst; i <= this._bucketLast; ++i) {\n newBuckets.push(this._buckets[i]);\n }\n } else {\n for (let i = this._bucketFirst; i < this._bucketCount; ++i) {\n newBuckets.push(this._buckets[i]);\n }\n for (let i = 0; i <= this._bucketLast; ++i) {\n newBuckets.push(this._buckets[i]);\n }\n }\n this._bucketFirst = 0;\n this._bucketLast = newBuckets.length - 1;\n this._buckets = newBuckets;\n }\n /**\n * Deep clone this deque, preserving options.\n * @remarks Time O(N), Space O(N)\n * @returns A new deque with the same content and options.\n */\n clone() {\n return this._createLike(this, {\n bucketSize: this.bucketSize,\n toElementFn: this.toElementFn,\n maxLen: this._maxLen\n });\n }\n /**\n * Filter elements into a new deque of the same class.\n * @remarks Time O(N), Space O(N)\n * @param predicate - Predicate (value, index, deque) → boolean to keep element.\n * @param [thisArg] - Value for `this` inside the predicate.\n * @returns A new deque with kept elements.\n */\n filter(predicate, thisArg) {\n const out = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });\n out._setBucketSize(this._bucketSize);\n let index = 0;\n for (const el of this) {\n if (predicate.call(thisArg, el, index, this)) out.push(el);\n index++;\n }\n return out;\n }\n /**\n * Map elements into a new deque of the same element type.\n * @remarks Time O(N), Space O(N)\n * @param callback - Mapping function (value, index, deque) → newValue.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new deque with mapped values.\n */\n mapSame(callback, thisArg) {\n const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n out._setBucketSize(this._bucketSize);\n let index = 0;\n for (const v of this) {\n const mv = thisArg === void 0 ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);\n out.push(mv);\n }\n return out;\n }\n /**\n * Map elements into a new deque (possibly different element type).\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param callback - Mapping function (value, index, deque) → newElement.\n * @param [options] - Options for the output deque (e.g., bucketSize, toElementFn, maxLen).\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new Deque with mapped elements.\n */\n map(callback, options, thisArg) {\n const out = this._createLike([], {\n ...options != null ? options : {},\n bucketSize: this._bucketSize,\n maxLen: this._maxLen\n });\n let index = 0;\n for (const el of this) {\n const mv = thisArg === void 0 ? callback(el, index, this) : callback.call(thisArg, el, index, this);\n out.push(mv);\n index++;\n }\n return out;\n }\n /**\n * (Protected) Set the internal bucket size.\n * @remarks Time O(1), Space O(1)\n * @param size - Bucket capacity to assign.\n * @returns void\n */\n _setBucketSize(size) {\n this._bucketSize = size;\n if (this._length === 0) {\n this._buckets = [new Array(this._bucketSize)];\n this._bucketCount = 1;\n this._bucketFirst = this._bucketLast = 0;\n this._firstInBucket = this._lastInBucket = this._bucketSize >> 1;\n }\n }\n /**\n * (Protected) Iterate elements from front to back.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of elements.\n */\n *_getIterator() {\n for (let i = 0; i < this._length; ++i) {\n const v = this.at(i);\n if (v !== void 0) yield v;\n }\n }\n /**\n * (Protected) Reallocate buckets to make room near the ends.\n * @remarks Time O(N), Space O(N)\n * @param [needBucketNum] - How many extra buckets to add; defaults to half of current.\n * @returns void\n */\n _reallocate(needBucketNum) {\n const newBuckets = [];\n const addBucketNum = needBucketNum || this._bucketCount >> 1 || 1;\n for (let i = 0; i < addBucketNum; ++i) {\n newBuckets[i] = new Array(this._bucketSize);\n }\n for (let i = this._bucketFirst; i < this._bucketCount; ++i) {\n newBuckets[newBuckets.length] = this._buckets[i];\n }\n for (let i = 0; i < this._bucketLast; ++i) {\n newBuckets[newBuckets.length] = this._buckets[i];\n }\n newBuckets[newBuckets.length] = [...this._buckets[this._bucketLast]];\n this._bucketFirst = addBucketNum;\n this._bucketLast = newBuckets.length - 1;\n for (let i = 0; i < addBucketNum; ++i) {\n newBuckets[newBuckets.length] = new Array(this._bucketSize);\n }\n this._buckets = newBuckets;\n this._bucketCount = newBuckets.length;\n }\n /**\n * (Protected) Translate a logical position to bucket/offset.\n * @remarks Time O(1), Space O(1)\n * @param pos - Zero-based position.\n * @returns An object containing bucketIndex and indexInBucket.\n */\n _getBucketAndPosition(pos) {\n let bucketIndex;\n let indexInBucket;\n const overallIndex = this._firstInBucket + pos;\n bucketIndex = this._bucketFirst + Math.floor(overallIndex / this._bucketSize);\n if (bucketIndex >= this._bucketCount) {\n bucketIndex -= this._bucketCount;\n }\n indexInBucket = (overallIndex + 1) % this._bucketSize - 1;\n if (indexInBucket < 0) {\n indexInBucket = this._bucketSize - 1;\n }\n return { bucketIndex, indexInBucket };\n }\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind deque instance.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], options);\n }\n /**\n * (Protected) Create a like-kind deque seeded by elements.\n * @remarks Time O(N), Space O(N)\n * @template T\n * @template RR\n * @param [elements] - Iterable used to seed the new deque.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind Deque instance.\n */\n _createLike(elements = [], options) {\n const Ctor = this.constructor;\n return new Ctor(elements, options);\n }\n /**\n * (Protected) Iterate elements from back to front.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of elements.\n */\n *_getReverseIterator() {\n for (let i = this._length - 1; i > -1; i--) {\n const v = this.at(i);\n if (v !== void 0) yield v;\n }\n }\n};\n__name(_Deque, \"Deque\");\nvar Deque = _Deque;\n\n// src/data-structures/heap/heap.ts\nvar _Heap = class _Heap extends IterableElementBase {\n /**\n * Create a Heap and optionally bulk-insert elements.\n * @remarks Time O(N), Space O(N)\n * @param [elements] - Iterable of elements (or raw values if toElementFn is set).\n * @param [options] - Options such as comparator and toElementFn.\n * @returns New Heap instance.\n */\n constructor(elements = [], options) {\n super(options);\n __publicField(this, \"_equals\", Object.is);\n __publicField(this, \"_elements\", []);\n __publicField(this, \"_DEFAULT_COMPARATOR\", /* @__PURE__ */ __name((a, b) => {\n if (typeof a === \"object\" || typeof b === \"object\") {\n throw TypeError(\"When comparing object types, define a custom comparator in options.\");\n }\n if (a > b) return 1;\n if (a < b) return -1;\n return 0;\n }, \"_DEFAULT_COMPARATOR\"));\n __publicField(this, \"_comparator\", this._DEFAULT_COMPARATOR);\n if (options) {\n const { comparator } = options;\n if (comparator) this._comparator = comparator;\n }\n this.addMany(elements);\n }\n /**\n * Get the backing array of the heap.\n * @remarks Time O(1), Space O(1)\n * @returns Internal elements array.\n */\n get elements() {\n return this._elements;\n }\n /**\n * Get the number of elements.\n * @remarks Time O(1), Space O(1)\n * @returns Heap size.\n */\n get size() {\n return this.elements.length;\n }\n /**\n * Get the last leaf element.\n * @remarks Time O(1), Space O(1)\n * @returns Last element or undefined.\n */\n get leaf() {\n var _a;\n return (_a = this.elements[this.size - 1]) != null ? _a : void 0;\n }\n /**\n * Create a heap of the same class from an iterable.\n * @remarks Time O(N), Space O(N)\n * @template T\n * @template R\n * @template S\n * @param [elements] - Iterable of elements or raw records.\n * @param [options] - Heap options including comparator.\n * @returns A new heap instance of this class.\n */\n static from(elements, options) {\n return new this(elements, options);\n }\n /**\n * Build a Heap from an iterable in linear time given a comparator.\n * @remarks Time O(N), Space O(N)\n * @template EE\n * @template RR\n * @param elements - Iterable of elements.\n * @param options - Heap options including comparator.\n * @returns A new Heap built from elements.\n */\n static heapify(elements, options) {\n return new _Heap(elements, options);\n }\n /**\n * Insert an element.\n * @remarks Time O(1) amortized, Space O(1)\n * @param element - Element to insert.\n * @returns True.\n */\n add(element) {\n this._elements.push(element);\n return this._bubbleUp(this.elements.length - 1);\n }\n /**\n * Insert many elements from an iterable.\n * @remarks Time O(N log N), Space O(1)\n * @param elements - Iterable of elements or raw values.\n * @returns Array of per-element success flags.\n */\n addMany(elements) {\n const flags = [];\n for (const el of elements) {\n if (this.toElementFn) {\n const ok = this.add(this.toElementFn(el));\n flags.push(ok);\n } else {\n const ok = this.add(el);\n flags.push(ok);\n }\n }\n return flags;\n }\n /**\n * Remove and return the top element.\n * @remarks Time O(log N), Space O(1)\n * @returns Top element or undefined.\n */\n poll() {\n if (this.elements.length === 0) return;\n const value = this.elements[0];\n const last = this.elements.pop();\n if (this.elements.length) {\n this.elements[0] = last;\n this._sinkDown(0, this.elements.length >> 1);\n }\n return value;\n }\n /**\n * Get the current top element without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns Top element or undefined.\n */\n peek() {\n return this.elements[0];\n }\n /**\n * Check whether the heap is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if size is 0.\n */\n isEmpty() {\n return this.size === 0;\n }\n /**\n * Remove all elements.\n * @remarks Time O(1), Space O(1)\n * @returns void\n */\n clear() {\n this._elements = [];\n }\n /**\n * Replace the backing array and rebuild the heap.\n * @remarks Time O(N), Space O(N)\n * @param elements - Iterable used to refill the heap.\n * @returns Array of per-node results from fixing steps.\n */\n refill(elements) {\n this._elements = Array.from(elements);\n return this.fix();\n }\n /**\n * Check if an equal element exists in the heap.\n * @remarks Time O(N), Space O(1)\n * @param element - Element to search for.\n * @returns True if found.\n */\n has(element) {\n for (const el of this.elements) if (this._equals(el, element)) return true;\n return false;\n }\n /**\n * Delete one occurrence of an element.\n * @remarks Time O(N), Space O(1)\n * @param element - Element to delete.\n * @returns True if an element was removed.\n */\n delete(element) {\n let index = -1;\n for (let i = 0; i < this.elements.length; i++) {\n if (this._equals(this.elements[i], element)) {\n index = i;\n break;\n }\n }\n if (index < 0) return false;\n if (index === 0) {\n this.poll();\n } else if (index === this.elements.length - 1) {\n this.elements.pop();\n } else {\n this.elements.splice(index, 1, this.elements.pop());\n this._bubbleUp(index);\n this._sinkDown(index, this.elements.length >> 1);\n }\n return true;\n }\n /**\n * Delete the first element that matches a predicate.\n * @remarks Time O(N), Space O(1)\n * @param predicate - Function (element, index, heap) → boolean.\n * @returns True if an element was removed.\n */\n deleteBy(predicate) {\n let idx = -1;\n for (let i = 0; i < this.elements.length; i++) {\n if (predicate(this.elements[i], i, this)) {\n idx = i;\n break;\n }\n }\n if (idx < 0) return false;\n if (idx === 0) {\n this.poll();\n } else if (idx === this.elements.length - 1) {\n this.elements.pop();\n } else {\n this.elements.splice(idx, 1, this.elements.pop());\n this._bubbleUp(idx);\n this._sinkDown(idx, this.elements.length >> 1);\n }\n return true;\n }\n /**\n * Set the equality comparator used by has/delete operations.\n * @remarks Time O(1), Space O(1)\n * @param equals - Equality predicate (a, b) → boolean.\n * @returns This heap.\n */\n setEquality(equals) {\n this._equals = equals;\n return this;\n }\n /**\n * Traverse the binary heap as a complete binary tree and collect elements.\n * @remarks Time O(N), Space O(H)\n * @param [order] - Traversal order: 'PRE' | 'IN' | 'POST'.\n * @returns Array of visited elements.\n */\n dfs(order = \"PRE\") {\n const result = [];\n const _dfs = /* @__PURE__ */ __name((index) => {\n const left = 2 * index + 1, right = left + 1;\n if (index < this.size) {\n if (order === \"IN\") {\n _dfs(left);\n result.push(this.elements[index]);\n _dfs(right);\n } else if (order === \"PRE\") {\n result.push(this.elements[index]);\n _dfs(left);\n _dfs(right);\n } else if (order === \"POST\") {\n _dfs(left);\n _dfs(right);\n result.push(this.elements[index]);\n }\n }\n }, \"_dfs\");\n _dfs(0);\n return result;\n }\n /**\n * Restore heap order bottom-up (heapify in-place).\n * @remarks Time O(N), Space O(1)\n * @returns Array of per-node results from fixing steps.\n */\n fix() {\n const results = [];\n for (let i = Math.floor(this.size / 2) - 1; i >= 0; i--) {\n results.push(this._sinkDown(i, this.elements.length >> 1));\n }\n return results;\n }\n /**\n * Return all elements in ascending order by repeatedly polling.\n * @remarks Time O(N log N), Space O(N)\n * @returns Sorted array of elements.\n */\n sort() {\n const visited = [];\n const cloned = this._createInstance();\n for (const x of this.elements) cloned.add(x);\n while (!cloned.isEmpty()) {\n const top = cloned.poll();\n if (top !== void 0) visited.push(top);\n }\n return visited;\n }\n /**\n * Deep clone this heap.\n * @remarks Time O(N), Space O(N)\n * @returns A new heap with the same elements.\n */\n clone() {\n const next = this._createInstance();\n for (const x of this.elements) next.add(x);\n return next;\n }\n /**\n * Filter elements into a new heap of the same class.\n * @remarks Time O(N log N), Space O(N)\n * @param callback - Predicate (element, index, heap) → boolean to keep element.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new heap with the kept elements.\n */\n filter(callback, thisArg) {\n const out = this._createInstance();\n let i = 0;\n for (const x of this) {\n if (thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this)) {\n out.add(x);\n } else {\n i++;\n }\n }\n return out;\n }\n /**\n * Map elements into a new heap of possibly different element type.\n * @remarks Time O(N log N), Space O(N)\n * @template EM\n * @template RM\n * @param callback - Mapping function (element, index, heap) → newElement.\n * @param options - Options for the output heap, including comparator for EM.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new heap with mapped elements.\n */\n map(callback, options, thisArg) {\n const { comparator, toElementFn, ...rest } = options != null ? options : {};\n if (!comparator) throw new TypeError(\"Heap.map requires options.comparator for EM\");\n const out = this._createLike([], { ...rest, comparator, toElementFn });\n let i = 0;\n for (const x of this) {\n const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);\n out.add(v);\n }\n return out;\n }\n /**\n * Map elements into a new heap of the same element type.\n * @remarks Time O(N log N), Space O(N)\n * @param callback - Mapping function (element, index, heap) → element.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new heap with mapped elements.\n */\n mapSame(callback, thisArg) {\n const out = this._createInstance();\n let i = 0;\n for (const x of this) {\n const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);\n out.add(v);\n }\n return out;\n }\n /**\n * Get the comparator used to order elements.\n * @remarks Time O(1), Space O(1)\n * @returns Comparator function.\n */\n /**\n * Get the comparator used to order elements.\n * @remarks Time O(1), Space O(1)\n * @returns Comparator function.\n */\n get comparator() {\n return this._comparator;\n }\n *_getIterator() {\n for (const element of this.elements) yield element;\n }\n _bubbleUp(index) {\n const element = this.elements[index];\n while (index > 0) {\n const parent = index - 1 >> 1;\n const parentItem = this.elements[parent];\n if (this.comparator(parentItem, element) <= 0) break;\n this.elements[index] = parentItem;\n index = parent;\n }\n this.elements[index] = element;\n return true;\n }\n _sinkDown(index, halfLength) {\n const element = this.elements[index];\n while (index < halfLength) {\n let left = index << 1 | 1;\n const right = left + 1;\n let minItem = this.elements[left];\n if (right < this.elements.length && this.comparator(minItem, this.elements[right]) > 0) {\n left = right;\n minItem = this.elements[right];\n }\n if (this.comparator(minItem, element) >= 0) break;\n this.elements[index] = minItem;\n index = left;\n }\n this.elements[index] = element;\n return true;\n }\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options to override comparator or toElementFn.\n * @returns A like-kind empty heap instance.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });\n return next;\n }\n /**\n * (Protected) Create a like-kind instance seeded by elements.\n * @remarks Time O(N log N), Space O(N)\n * @template EM\n * @template RM\n * @param [elements] - Iterable of elements or raw values to seed.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind heap instance.\n */\n _createLike(elements = [], options) {\n const Ctor = this.constructor;\n return new Ctor(elements, options);\n }\n /**\n * (Protected) Spawn an empty like-kind heap instance.\n * @remarks Time O(1), Space O(1)\n * @template EM\n * @template RM\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind heap instance.\n */\n _spawnLike(options) {\n return this._createLike([], options);\n }\n};\n__name(_Heap, \"Heap\");\nvar Heap = _Heap;\nvar _FibonacciHeapNode = class _FibonacciHeapNode {\n constructor(element, degree = 0) {\n __publicField(this, \"element\");\n __publicField(this, \"degree\");\n __publicField(this, \"left\");\n __publicField(this, \"right\");\n __publicField(this, \"child\");\n __publicField(this, \"parent\");\n __publicField(this, \"marked\");\n this.element = element;\n this.degree = degree;\n this.marked = false;\n }\n};\n__name(_FibonacciHeapNode, \"FibonacciHeapNode\");\nvar FibonacciHeapNode = _FibonacciHeapNode;\nvar _FibonacciHeap = class _FibonacciHeap {\n /**\n * Create a FibonacciHeap.\n * @remarks Time O(1), Space O(1)\n * @param [comparator] - Comparator to order elements (min-heap by default).\n * @returns New FibonacciHeap instance.\n */\n constructor(comparator) {\n __publicField(this, \"_root\");\n __publicField(this, \"_size\", 0);\n __publicField(this, \"_min\");\n __publicField(this, \"_comparator\");\n this.clear();\n this._comparator = comparator || this._defaultComparator;\n if (typeof this.comparator !== \"function\") throw new Error(\"FibonacciHeap: comparator must be a function.\");\n }\n /**\n * Get the circular root list head.\n * @remarks Time O(1), Space O(1)\n * @returns Root node or undefined.\n */\n get root() {\n return this._root;\n }\n get size() {\n return this._size;\n }\n /**\n * Get the current minimum node.\n * @remarks Time O(1), Space O(1)\n * @returns Min node or undefined.\n */\n get min() {\n return this._min;\n }\n get comparator() {\n return this._comparator;\n }\n clear() {\n this._root = void 0;\n this._min = void 0;\n this._size = 0;\n }\n add(element) {\n this.push(element);\n return true;\n }\n /**\n * Push an element into the root list.\n * @remarks Time O(1) amortized, Space O(1)\n * @param element - Element to insert.\n * @returns This heap.\n */\n push(element) {\n const node = this.createNode(element);\n node.left = node;\n node.right = node;\n this.mergeWithRoot(node);\n if (!this.min || this.comparator(node.element, this.min.element) <= 0) this._min = node;\n this._size++;\n return this;\n }\n peek() {\n return this.min ? this.min.element : void 0;\n }\n /**\n * Collect nodes from a circular doubly linked list starting at head.\n * @remarks Time O(K), Space O(K)\n * @param [head] - Start node of the circular list.\n * @returns Array of nodes from the list.\n */\n consumeLinkedList(head) {\n const elements = [];\n if (!head) return elements;\n let node = head;\n let started = false;\n while (true) {\n if (node === head && started) break;\n else if (node === head) started = true;\n elements.push(node);\n node = node.right;\n }\n return elements;\n }\n /**\n * Insert a node into a parent's child list (circular).\n * @remarks Time O(1), Space O(1)\n * @param parent - Parent node.\n * @param node - Child node to insert.\n * @returns void\n */\n mergeWithChild(parent, node) {\n if (!parent.child) parent.child = node;\n else {\n node.right = parent.child.right;\n node.left = parent.child;\n parent.child.right.left = node;\n parent.child.right = node;\n }\n }\n poll() {\n return this.pop();\n }\n /**\n * Remove and return the minimum element, consolidating the root list.\n * @remarks Time O(log N) amortized, Space O(1)\n * @returns Minimum element or undefined.\n */\n pop() {\n if (this._size === 0) return void 0;\n const z = this.min;\n if (z.child) {\n const elements = this.consumeLinkedList(z.child);\n for (const node of elements) {\n this.mergeWithRoot(node);\n node.parent = void 0;\n }\n }\n this.removeFromRoot(z);\n if (z === z.right) {\n this._min = void 0;\n this._root = void 0;\n } else {\n this._min = z.right;\n this._consolidate();\n }\n this._size--;\n return z.element;\n }\n /**\n * Meld another heap into this heap.\n * @remarks Time O(1), Space O(1)\n * @param heapToMerge - Another FibonacciHeap to meld into this one.\n * @returns void\n */\n merge(heapToMerge) {\n if (heapToMerge.size === 0) return;\n if (this.root && heapToMerge.root) {\n const thisRoot = this.root, otherRoot = heapToMerge.root;\n const thisRootRight = thisRoot.right, otherRootLeft = otherRoot.left;\n thisRoot.right = otherRoot;\n otherRoot.left = thisRoot;\n thisRootRight.left = otherRootLeft;\n otherRootLeft.right = thisRootRight;\n } else if (!this.root && heapToMerge.root) {\n this._root = heapToMerge.root;\n }\n if (!this.min || heapToMerge.min && this.comparator(heapToMerge.min.element, this.min.element) < 0) {\n this._min = heapToMerge.min;\n }\n this._size += heapToMerge.size;\n heapToMerge.clear();\n }\n createNode(element) {\n return new FibonacciHeapNode(element);\n }\n isEmpty() {\n return this._size === 0;\n }\n _defaultComparator(a, b) {\n if (a < b) return -1;\n if (a > b) return 1;\n return 0;\n }\n mergeWithRoot(node) {\n if (!this.root) this._root = node;\n else {\n node.right = this.root.right;\n node.left = this.root;\n this.root.right.left = node;\n this.root.right = node;\n }\n }\n removeFromRoot(node) {\n if (this.root === node) this._root = node.right;\n if (node.left) node.left.right = node.right;\n if (node.right) node.right.left = node.left;\n }\n _link(y, x) {\n this.removeFromRoot(y);\n y.left = y;\n y.right = y;\n this.mergeWithChild(x, y);\n x.degree++;\n y.parent = x;\n }\n _consolidate() {\n const A = new Array(this._size);\n const elements = this.consumeLinkedList(this.root);\n let x, y, d, t;\n for (const node of elements) {\n x = node;\n d = x.degree;\n while (A[d]) {\n y = A[d];\n if (this.comparator(x.element, y.element) > 0) {\n t = x;\n x = y;\n y = t;\n }\n this._link(y, x);\n A[d] = void 0;\n d++;\n }\n A[d] = x;\n }\n for (let i = 0; i < A.length; i++) {\n if (A[i] && (!this.min || this.comparator(A[i].element, this.min.element) <= 0)) this._min = A[i];\n }\n }\n};\n__name(_FibonacciHeap, \"FibonacciHeap\");\nvar FibonacciHeap = _FibonacciHeap;\n\n// src/data-structures/heap/max-heap.ts\nvar _MaxHeap = class _MaxHeap extends Heap {\n /**\n * Create a max-heap. For objects, supply a custom comparator.\n * @param elements Optional initial elements.\n * @param options Optional configuration.\n */\n constructor(elements = [], options) {\n super(elements, {\n comparator: /* @__PURE__ */ __name((a, b) => {\n if (typeof a === \"object\" || typeof b === \"object\") {\n throw TypeError(\n `When comparing object types, a custom comparator must be defined in the constructor's options parameter.`\n );\n }\n if (a < b) return 1;\n if (a > b) return -1;\n return 0;\n }, \"comparator\"),\n ...options\n });\n }\n};\n__name(_MaxHeap, \"MaxHeap\");\nvar MaxHeap = _MaxHeap;\n\n// src/data-structures/heap/min-heap.ts\nvar _MinHeap = class _MinHeap extends Heap {\n /**\n * Create a min-heap.\n * @param elements Optional initial elements.\n * @param options Optional configuration.\n */\n constructor(elements = [], options) {\n super(elements, options);\n }\n};\n__name(_MinHeap, \"MinHeap\");\nvar MinHeap = _MinHeap;\n\n// src/data-structures/graph/abstract-graph.ts\nvar _AbstractVertex = class _AbstractVertex {\n constructor(key, value) {\n __publicField(this, \"key\");\n __publicField(this, \"value\");\n this.key = key;\n this.value = value;\n }\n};\n__name(_AbstractVertex, \"AbstractVertex\");\nvar AbstractVertex = _AbstractVertex;\nvar _AbstractEdge = class _AbstractEdge {\n constructor(weight, value) {\n __publicField(this, \"value\");\n __publicField(this, \"weight\");\n __publicField(this, \"_hashCode\");\n this.weight = weight !== void 0 ? weight : 1;\n this.value = value;\n this._hashCode = uuidV4();\n }\n get hashCode() {\n return this._hashCode;\n }\n};\n__name(_AbstractEdge, \"AbstractEdge\");\nvar AbstractEdge = _AbstractEdge;\nvar _AbstractGraph = class _AbstractGraph extends IterableEntryBase {\n /**\n * Construct a graph with runtime defaults.\n * @param options - `GraphOptions<V>` in `options.graph` (e.g. `vertexValueInitializer`, `defaultEdgeWeight`).\n * @remarks Time O(1), Space O(1)\n */\n constructor(options) {\n super();\n __publicField(this, \"_options\", { defaultEdgeWeight: 1 });\n __publicField(this, \"_vertexMap\", /* @__PURE__ */ new Map());\n const graph = options == null ? void 0 : options.graph;\n this._options = { defaultEdgeWeight: 1, ...graph != null ? graph : {} };\n }\n get options() {\n return this._options;\n }\n get vertexMap() {\n return this._vertexMap;\n }\n set vertexMap(v) {\n this._vertexMap = v;\n }\n get size() {\n return this._vertexMap.size;\n }\n /**\n * Get vertex instance by key.\n * @param vertexKey - Vertex key.\n * @returns Vertex instance or `undefined`.\n * @remarks Time O(1), Space O(1)\n */\n getVertex(vertexKey) {\n return this._vertexMap.get(vertexKey) || void 0;\n }\n /**\n * Whether a vertex exists.\n * @param vertexOrKey - Vertex or key.\n * @returns `true` if present, otherwise `false`.\n * @remarks Time O(1) avg, Space O(1)\n */\n hasVertex(vertexOrKey) {\n return this._vertexMap.has(this._getVertexKey(vertexOrKey));\n }\n /**\n * Add a vertex by key/value or by pre-built vertex.\n * @param keyOrVertex - Vertex key or existing vertex instance.\n * @param value - Optional payload.\n * @returns `true` if inserted; `false` when key already exists.\n * @remarks Time O(1) avg, Space O(1)\n */\n addVertex(keyOrVertex, value) {\n if (keyOrVertex instanceof AbstractVertex) {\n return this._addVertex(keyOrVertex);\n } else {\n const newVertex = this.createVertex(keyOrVertex, value);\n return this._addVertex(newVertex);\n }\n }\n /**\n * Type guard: check if a value is a valid vertex key.\n * @param potentialKey - Value to test.\n * @returns `true` if string/number; else `false`.\n * @remarks Time O(1), Space O(1)\n */\n isVertexKey(potentialKey) {\n const potentialKeyType = typeof potentialKey;\n return potentialKeyType === \"string\" || potentialKeyType === \"number\";\n }\n /**\n * Delete multiple vertices.\n * @param vertexMap - Array of vertices or keys.\n * @returns `true` if any vertex was removed.\n * @remarks Time O(sum(deg)), Space O(1)\n */\n removeManyVertices(vertexMap) {\n const removed = [];\n for (const v of vertexMap) {\n removed.push(this.deleteVertex(v));\n }\n return removed.length > 0;\n }\n /**\n * Whether an edge exists between two vertices.\n * @param v1 - Endpoint A vertex or key.\n * @param v2 - Endpoint B vertex or key.\n * @returns `true` if present; otherwise `false`.\n * @remarks Time O(1) avg, Space O(1)\n */\n hasEdge(v1, v2) {\n const edge = this.getEdge(v1, v2);\n return !!edge;\n }\n /**\n * Add an edge by instance or by `(src, dest, weight?, value?)`.\n * @param srcOrEdge - Edge instance or source vertex/key.\n * @param dest - Destination vertex/key (when adding by pair).\n * @param weight - Edge weight.\n * @param value - Edge payload.\n * @returns `true` if inserted; otherwise `false`.\n * @remarks Time O(1) avg, Space O(1)\n */\n addEdge(srcOrEdge, dest, weight, value) {\n if (srcOrEdge instanceof AbstractEdge) {\n return this._addEdge(srcOrEdge);\n } else {\n if (dest instanceof AbstractVertex || typeof dest === \"string\" || typeof dest === \"number\") {\n if (!(this.hasVertex(srcOrEdge) && this.hasVertex(dest))) return false;\n if (srcOrEdge instanceof AbstractVertex) srcOrEdge = srcOrEdge.key;\n if (dest instanceof AbstractVertex) dest = dest.key;\n const newEdge = this.createEdge(srcOrEdge, dest, weight, value);\n return this._addEdge(newEdge);\n } else {\n throw new Error(\"dest must be a Vertex or vertex key while srcOrEdge is an Edge\");\n }\n }\n }\n /**\n * Set the weight of an existing edge.\n * @param srcOrKey - Source vertex or key.\n * @param destOrKey - Destination vertex or key.\n * @param weight - New weight.\n * @returns `true` if updated; otherwise `false`.\n * @remarks Time O(1) avg, Space O(1)\n */\n setEdgeWeight(srcOrKey, destOrKey, weight) {\n const edge = this.getEdge(srcOrKey, destOrKey);\n if (edge) {\n edge.weight = weight;\n return true;\n } else {\n return false;\n }\n }\n /**\n * Enumerate simple paths up to a limit.\n * @param v1 - Source vertex or key.\n * @param v2 - Destination vertex or key.\n * @param limit - Maximum number of paths to collect.\n * @returns Array of paths (each path is an array of vertices).\n * @remarks Time O(paths) worst-case exponential, Space O(V + paths)\n */\n getAllPathsBetween(v1, v2, limit = 1e3) {\n const paths = [];\n const vertex1 = this._getVertex(v1);\n const vertex2 = this._getVertex(v2);\n if (!(vertex1 && vertex2)) {\n return [];\n }\n const stack = [];\n stack.push({ vertex: vertex1, path: [vertex1] });\n while (stack.length > 0) {\n const { vertex, path } = stack.pop();\n if (vertex === vertex2) {\n paths.push(path);\n if (paths.length >= limit) return paths;\n }\n const neighbors = this.getNeighbors(vertex);\n for (const neighbor of neighbors) {\n if (!path.includes(neighbor)) {\n const newPath = [...path, neighbor];\n stack.push({ vertex: neighbor, path: newPath });\n }\n }\n }\n return paths;\n }\n /**\n * Sum the weights along a vertex path.\n * @param path - Sequence of vertices.\n * @returns Path weight sum (0 if empty or edge missing).\n * @remarks Time O(L), Space O(1) where L is path length\n */\n getPathSumWeight(path) {\n var _a;\n let sum = 0;\n for (let i = 0; i < path.length; i++) {\n sum += ((_a = this.getEdge(path[i], path[i + 1])) == null ? void 0 : _a.weight) || 0;\n }\n return sum;\n }\n /**\n * Minimum hops/weight between two vertices.\n * @param v1 - Source vertex or key.\n * @param v2 - Destination vertex or key.\n * @param isWeight - If `true`, compare by path weight; otherwise by hop count.\n * @returns Minimum cost or `undefined` if missing/unreachable.\n * @remarks Time O((V + E) log V) weighted / O(V + E) unweighted, Space O(V + E)\n */\n getMinCostBetween(v1, v2, isWeight) {\n if (isWeight === void 0) isWeight = false;\n if (isWeight) {\n const allPaths = this.getAllPathsBetween(v1, v2);\n let min = Number.MAX_SAFE_INTEGER;\n for (const path of allPaths) {\n min = Math.min(this.getPathSumWeight(path), min);\n }\n return min;\n } else {\n const vertex2 = this._getVertex(v2);\n const vertex1 = this._getVertex(v1);\n if (!(vertex1 && vertex2)) {\n return void 0;\n }\n const visited = /* @__PURE__ */ new Map();\n const queue = new Queue([vertex1]);\n visited.set(vertex1, true);\n let cost = 0;\n while (queue.length > 0) {\n for (let i = 0, layerSize = queue.length; i < layerSize; i++) {\n const cur = queue.shift();\n if (cur === vertex2) {\n return cost;\n }\n if (cur !== void 0) {\n const neighbors = this.getNeighbors(cur);\n for (const neighbor of neighbors) {\n if (!visited.has(neighbor)) {\n visited.set(neighbor, true);\n queue.push(neighbor);\n }\n }\n }\n }\n cost++;\n }\n return void 0;\n }\n }\n /**\n * Minimum path (as vertex sequence) between two vertices.\n * @param v1 - Source vertex or key.\n * @param v2 - Destination vertex or key.\n * @param isWeight - If `true`, compare by path weight; otherwise by hop count.\n * @param isDFS - For weighted mode only: if `true`, brute-force all paths; if `false`, use Dijkstra.\n * @returns Vertex sequence, or `undefined`/empty when unreachable depending on branch.\n * @remarks Time O((V + E) log V) weighted / O(V + E) unweighted, Space O(V + E)\n */\n getMinPathBetween(v1, v2, isWeight, isDFS = false) {\n var _a, _b;\n if (isWeight === void 0) isWeight = false;\n if (isWeight) {\n if (isDFS) {\n const allPaths = this.getAllPathsBetween(v1, v2, 1e4);\n let min = Number.MAX_SAFE_INTEGER;\n let minIndex = -1;\n let index = 0;\n for (const path of allPaths) {\n const pathSumWeight = this.getPathSumWeight(path);\n if (pathSumWeight < min) {\n min = pathSumWeight;\n minIndex = index;\n }\n index++;\n }\n return allPaths[minIndex] || void 0;\n } else {\n return (_b = (_a = this.dijkstra(v1, v2, true, true)) == null ? void 0 : _a.minPath) != null ? _b : [];\n }\n } else {\n let minPath = [];\n const vertex1 = this._getVertex(v1);\n const vertex2 = this._getVertex(v2);\n if (!(vertex1 && vertex2)) return [];\n const dfs = /* @__PURE__ */ __name((cur, dest, visiting, path) => {\n visiting.add(cur);\n if (cur === dest) {\n minPath = [vertex1, ...path];\n return;\n }\n const neighbors = this.getNeighbors(cur);\n for (const neighbor of neighbors) {\n if (!visiting.has(neighbor)) {\n path.push(neighbor);\n dfs(neighbor, dest, visiting, path);\n path.pop();\n }\n }\n visiting.delete(cur);\n }, \"dfs\");\n dfs(vertex1, vertex2, /* @__PURE__ */ new Set(), []);\n return minPath;\n }\n }\n /**\n * Dijkstra without heap (array-based selection).\n * @param src - Source vertex or key.\n * @param dest - Optional destination for early stop.\n * @param getMinDist - If `true`, compute global minimum distance.\n * @param genPaths - If `true`, also generate path arrays.\n * @returns Result bag or `undefined` if source missing.\n * @remarks Time O(V^2 + E), Space O(V + E)\n */\n dijkstraWithoutHeap(src, dest = void 0, getMinDist = false, genPaths = false) {\n let minDist = Number.MAX_SAFE_INTEGER;\n let minDest = void 0;\n let minPath = [];\n const paths = [];\n const vertexMap = this._vertexMap;\n const distMap = /* @__PURE__ */ new Map();\n const seen = /* @__PURE__ */ new Set();\n const preMap = /* @__PURE__ */ new Map();\n const srcVertex = this._getVertex(src);\n const destVertex = dest ? this._getVertex(dest) : void 0;\n if (!srcVertex) {\n return void 0;\n }\n for (const vertex of vertexMap) {\n const vertexOrKey = vertex[1];\n if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Number.MAX_SAFE_INTEGER);\n }\n distMap.set(srcVertex, 0);\n preMap.set(srcVertex, void 0);\n const getMinOfNoSeen = /* @__PURE__ */ __name(() => {\n let min = Number.MAX_SAFE_INTEGER;\n let minV = void 0;\n for (const [key, value] of distMap) {\n if (!seen.has(key)) {\n if (value < min) {\n min = value;\n minV = key;\n }\n }\n }\n return minV;\n }, \"getMinOfNoSeen\");\n const getPaths = /* @__PURE__ */ __name((minV) => {\n for (const vertex of vertexMap) {\n const vertexOrKey = vertex[1];\n if (vertexOrKey instanceof AbstractVertex) {\n const path = [vertexOrKey];\n let parent = preMap.get(vertexOrKey);\n while (parent) {\n path.push(parent);\n parent = preMap.get(parent);\n }\n const reversed = path.reverse();\n if (vertex[1] === minV) minPath = reversed;\n paths.push(reversed);\n }\n }\n }, \"getPaths\");\n for (let i = 1; i < vertexMap.size; i++) {\n const cur = getMinOfNoSeen();\n if (cur) {\n seen.add(cur);\n if (destVertex && destVertex === cur) {\n if (getMinDist) {\n minDist = distMap.get(destVertex) || Number.MAX_SAFE_INTEGER;\n }\n if (genPaths) {\n getPaths(destVertex);\n }\n return { distMap, preMap, seen, paths, minDist, minPath };\n }\n const neighbors = this.getNeighbors(cur);\n for (const neighbor of neighbors) {\n if (!seen.has(neighbor)) {\n const edge = this.getEdge(cur, neighbor);\n if (edge) {\n const curFromMap = distMap.get(cur);\n const neighborFromMap = distMap.get(neighbor);\n if (curFromMap !== void 0 && neighborFromMap !== void 0) {\n if (edge.weight + curFromMap < neighborFromMap) {\n distMap.set(neighbor, edge.weight + curFromMap);\n preMap.set(neighbor, cur);\n }\n }\n }\n }\n }\n }\n }\n if (getMinDist)\n distMap.forEach((d, v) => {\n if (v !== srcVertex) {\n if (d < minDist) {\n minDist = d;\n if (genPaths) minDest = v;\n }\n }\n });\n if (genPaths) getPaths(minDest);\n return { distMap, preMap, seen, paths, minDist, minPath };\n }\n dijkstra(src, dest = void 0, getMinDist = false, genPaths = false) {\n var _a;\n let minDist = Number.MAX_SAFE_INTEGER;\n let minDest = void 0;\n let minPath = [];\n const paths = [];\n const vertexMap = this._vertexMap;\n const distMap = /* @__PURE__ */ new Map();\n const seen = /* @__PURE__ */ new Set();\n const preMap = /* @__PURE__ */ new Map();\n const srcVertex = this._getVertex(src);\n const destVertex = dest ? this._getVertex(dest) : void 0;\n if (!srcVertex) return void 0;\n for (const vertex of vertexMap) {\n const vertexOrKey = vertex[1];\n if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Number.MAX_SAFE_INTEGER);\n }\n const heap = new Heap([], { comparator: /* @__PURE__ */ __name((a, b) => a.key - b.key, \"comparator\") });\n heap.add({ key: 0, value: srcVertex });\n distMap.set(srcVertex, 0);\n preMap.set(srcVertex, void 0);\n const getPaths = /* @__PURE__ */ __name((minV) => {\n for (const vertex of vertexMap) {\n const vertexOrKey = vertex[1];\n if (vertexOrKey instanceof AbstractVertex) {\n const path = [vertexOrKey];\n let parent = preMap.get(vertexOrKey);\n while (parent) {\n path.push(parent);\n parent = preMap.get(parent);\n }\n const reversed = path.reverse();\n if (vertex[1] === minV) minPath = reversed;\n paths.push(reversed);\n }\n }\n }, \"getPaths\");\n while (heap.size > 0) {\n const curHeapNode = heap.poll();\n const dist = curHeapNode == null ? void 0 : curHeapNode.key;\n const cur = curHeapNode == null ? void 0 : curHeapNode.value;\n if (dist !== void 0) {\n if (cur) {\n seen.add(cur);\n if (destVertex && destVertex === cur) {\n if (getMinDist) {\n minDist = distMap.get(destVertex) || Number.MAX_SAFE_INTEGER;\n }\n if (genPaths) {\n getPaths(destVertex);\n }\n return { distMap, preMap, seen, paths, minDist, minPath };\n }\n const neighbors = this.getNeighbors(cur);\n for (const neighbor of neighbors) {\n if (!seen.has(neighbor)) {\n const weight = (_a = this.getEdge(cur, neighbor)) == null ? void 0 : _a.weight;\n if (typeof weight === \"number\") {\n const distSrcToNeighbor = distMap.get(neighbor);\n if (distSrcToNeighbor !== void 0) {\n if (dist + weight < distSrcToNeighbor) {\n heap.add({ key: dist + weight, value: neighbor });\n preMap.set(neighbor, cur);\n distMap.set(neighbor, dist + weight);\n }\n }\n }\n }\n }\n }\n }\n }\n if (getMinDist) {\n distMap.forEach((d, v) => {\n if (v !== srcVertex) {\n if (d < minDist) {\n minDist = d;\n if (genPaths) minDest = v;\n }\n }\n });\n }\n if (genPaths) {\n getPaths(minDest);\n }\n return { distMap, preMap, seen, paths, minDist, minPath };\n }\n /**\n * Bellman-Ford single-source shortest paths with option to scan negative cycles.\n * @param src - Source vertex or key.\n * @param scanNegativeCycle - If `true`, also detect negative cycles.\n * @param getMin - If `true`, compute global minimum distance.\n * @param genPath - If `true`, generate path arrays via predecessor map.\n * @returns Result bag including distances, predecessors, and optional cycle flag.\n * @remarks Time O(V * E), Space O(V + E)\n */\n bellmanFord(src, scanNegativeCycle, getMin, genPath) {\n if (getMin === void 0) getMin = false;\n if (genPath === void 0) genPath = false;\n const srcVertex = this._getVertex(src);\n const paths = [];\n const distMap = /* @__PURE__ */ new Map();\n const preMap = /* @__PURE__ */ new Map();\n let min = Number.MAX_SAFE_INTEGER;\n let minPath = [];\n let hasNegativeCycle;\n if (scanNegativeCycle) hasNegativeCycle = false;\n if (!srcVertex) return { hasNegativeCycle, distMap, preMap, paths, min, minPath };\n const vertexMap = this._vertexMap;\n const numOfVertices = vertexMap.size;\n const edgeMap = this.edgeSet();\n const numOfEdges = edgeMap.length;\n this._vertexMap.forEach((vertex) => {\n distMap.set(vertex, Number.MAX_SAFE_INTEGER);\n });\n distMap.set(srcVertex, 0);\n for (let i = 1; i < numOfVertices; ++i) {\n for (let j = 0; j < numOfEdges; ++j) {\n const ends = this.getEndsOfEdge(edgeMap[j]);\n if (ends) {\n const [s, d] = ends;\n const weight = edgeMap[j].weight;\n const sWeight = distMap.get(s);\n const dWeight = distMap.get(d);\n if (sWeight !== void 0 && dWeight !== void 0) {\n if (distMap.get(s) !== Number.MAX_SAFE_INTEGER && sWeight + weight < dWeight) {\n distMap.set(d, sWeight + weight);\n if (genPath) preMap.set(d, s);\n }\n }\n }\n }\n }\n let minDest = void 0;\n if (getMin) {\n distMap.forEach((d, v) => {\n if (v !== srcVertex) {\n if (d < min) {\n min = d;\n if (genPath) minDest = v;\n }\n }\n });\n }\n if (genPath) {\n for (const vertex of vertexMap) {\n const vertexOrKey = vertex[1];\n if (vertexOrKey instanceof AbstractVertex) {\n const path = [vertexOrKey];\n let parent = preMap.get(vertexOrKey);\n while (parent !== void 0) {\n path.push(parent);\n parent = preMap.get(parent);\n }\n const reversed = path.reverse();\n if (vertex[1] === minDest) minPath = reversed;\n paths.push(reversed);\n }\n }\n }\n for (let j = 0; j < numOfEdges; ++j) {\n const ends = this.getEndsOfEdge(edgeMap[j]);\n if (ends) {\n const [s] = ends;\n const weight = edgeMap[j].weight;\n const sWeight = distMap.get(s);\n if (sWeight) {\n if (sWeight !== Number.MAX_SAFE_INTEGER && sWeight + weight < sWeight) hasNegativeCycle = true;\n }\n }\n }\n return { hasNegativeCycle, distMap, preMap, paths, min, minPath };\n }\n /**\n * Floyd–Warshall all-pairs shortest paths.\n * @returns `{ costs, predecessor }` matrices.\n * @remarks Time O(V^3), Space O(V^2)\n */\n floydWarshall() {\n var _a;\n const idAndVertices = [...this._vertexMap];\n const n = idAndVertices.length;\n const costs = [];\n const predecessor = [];\n for (let i = 0; i < n; i++) {\n costs[i] = [];\n predecessor[i] = [];\n for (let j = 0; j < n; j++) {\n predecessor[i][j] = void 0;\n }\n }\n for (let i = 0; i < n; i++) {\n for (let j = 0; j < n; j++) {\n costs[i][j] = ((_a = this.getEdge(idAndVertices[i][1], idAndVertices[j][1])) == null ? void 0 : _a.weight) || Number.MAX_SAFE_INTEGER;\n }\n }\n for (let k = 0; k < n; k++) {\n for (let i = 0; i < n; i++) {\n for (let j = 0; j < n; j++) {\n if (costs[i][j] > costs[i][k] + costs[k][j]) {\n costs[i][j] = costs[i][k] + costs[k][j];\n predecessor[i][j] = idAndVertices[k][1];\n }\n }\n }\n }\n return { costs, predecessor };\n }\n /**\n * Enumerate simple cycles (may be expensive).\n * @param isInclude2Cycle - If `true`, include 2-cycles when graph semantics allow.\n * @returns Array of cycles (each as array of vertex keys).\n * @remarks Time exponential in worst-case, Space O(V + E)\n */\n getCycles(isInclude2Cycle = false) {\n const cycles = [];\n const visited = /* @__PURE__ */ new Set();\n const dfs = /* @__PURE__ */ __name((vertex, currentPath, visited2) => {\n if (visited2.has(vertex)) {\n if ((!isInclude2Cycle && currentPath.length > 2 || isInclude2Cycle && currentPath.length >= 2) && currentPath[0] === vertex.key) {\n cycles.push([...currentPath]);\n }\n return;\n }\n visited2.add(vertex);\n currentPath.push(vertex.key);\n for (const neighbor of this.getNeighbors(vertex)) {\n if (neighbor) dfs(neighbor, currentPath, visited2);\n }\n visited2.delete(vertex);\n currentPath.pop();\n }, \"dfs\");\n for (const vertex of this.vertexMap.values()) {\n dfs(vertex, [], visited);\n }\n const uniqueCycles = /* @__PURE__ */ new Map();\n for (const cycle of cycles) {\n const sorted = [...cycle].sort().toString();\n if (uniqueCycles.has(sorted)) continue;\n else {\n uniqueCycles.set(sorted, cycle);\n }\n }\n return [...uniqueCycles].map((cycleString) => cycleString[1]);\n }\n /**\n * Induced-subgraph filter: keep vertices where `predicate(key, value)` is true,\n * and only keep edges whose endpoints both survive.\n * @param predicate - `(key, value, index, self) => boolean`.\n * @param thisArg - Optional `this` for callback.\n * @returns A new graph of the same concrete class (`this` type).\n * @remarks Time O(V + E), Space O(V + E)\n */\n filter(predicate, thisArg) {\n const filtered = [];\n let index = 0;\n for (const [key, value] of this) {\n if (predicate.call(thisArg, value, key, index, this)) {\n filtered.push([key, value]);\n }\n index++;\n }\n return this._createLike(filtered, this._snapshotOptions());\n }\n /**\n * Preserve the old behavior: return filtered entries as an array.\n * @remarks Time O(V), Space O(V)\n */\n filterEntries(predicate, thisArg) {\n const filtered = [];\n let index = 0;\n for (const [key, value] of this) {\n if (predicate.call(thisArg, value, key, index, this)) {\n filtered.push([key, value]);\n }\n index++;\n }\n return filtered;\n }\n map(callback, thisArg) {\n const mapped = [];\n let index = 0;\n for (const [key, value] of this) {\n mapped.push(callback.call(thisArg, value, key, index, this));\n index++;\n }\n return mapped;\n }\n /**\n * Create a deep clone of the graph with the same species.\n * @remarks Time O(V + E), Space O(V + E)\n */\n /**\n * Create a deep clone of the graph with the same species.\n * @returns A new graph of the same concrete class (`this` type).\n * @remarks Time O(V + E), Space O(V + E)\n */\n clone() {\n return this._createLike(void 0, this._snapshotOptions());\n }\n // ===== Same-species factory & cloning helpers =====\n /**\n * Internal iterator over `[key, value]` entries in insertion order.\n * @returns Iterator of `[VertexKey, V | undefined]`.\n * @remarks Time O(V), Space O(1)\n */\n *_getIterator() {\n for (const vertex of this._vertexMap.values()) {\n yield [vertex.key, vertex.value];\n }\n }\n /**\n * Capture configuration needed to reproduce the current graph.\n * Currently the graph has no runtime options, so we return an empty object.\n */\n /**\n * Capture configuration needed to reproduce the current graph.\n * @returns Options bag (opaque to callers).\n * @remarks Time O(1), Space O(1)\n */\n _snapshotOptions() {\n return { graph: { ...this._options } };\n }\n /**\n * Create an empty graph instance of the same concrete species (Directed/Undirected/etc).\n * @remarks Time O(1), Space O(1)\n */\n /**\n * Create an empty graph instance of the same concrete species.\n * @param _options - Snapshot options from `_snapshotOptions()`.\n * @returns A new empty graph instance of `this` type.\n * @remarks Time O(1), Space O(1)\n */\n _createInstance(_options) {\n const Ctor = this.constructor;\n const instance = new Ctor();\n const graph = _options == null ? void 0 : _options.graph;\n if (graph) instance._options = { ...instance._options, ...graph };\n else instance._options = { ...instance._options, ...this._options };\n return instance;\n }\n /**\n * Create a same-species graph populated with the given entries.\n * Also preserves edges between kept vertices from the source graph.\n * @remarks Time O(V + E), Space O(V + E)\n */\n /**\n * Create a same-species graph populated with entries; preserves edges among kept vertices.\n * @param iter - Optional entries to seed the new graph.\n * @param options - Snapshot options.\n * @returns A new graph of `this` type.\n * @remarks Time O(V + E), Space O(V + E)\n */\n _createLike(iter, options) {\n const g = this._createInstance(options);\n if (iter) {\n for (const [k, v] of iter) {\n g.addVertex(k, v);\n }\n } else {\n for (const [k, v] of this) {\n g.addVertex(k, v);\n }\n }\n const edges = this.edgeSet();\n for (const e of edges) {\n const ends = this.getEndsOfEdge(e);\n if (!ends) continue;\n const [va, vb] = ends;\n const ka = va.key;\n const kb = vb.key;\n const hasA = g.hasVertex ? g.hasVertex(ka) : false;\n const hasB = g.hasVertex ? g.hasVertex(kb) : false;\n if (hasA && hasB) {\n const w = e.weight;\n const val = e.value;\n const newEdge = g.createEdge(ka, kb, w, val);\n g._addEdge(newEdge);\n }\n }\n return g;\n }\n /**\n * Insert a pre-built vertex into the graph.\n * @param newVertex - Concrete vertex instance.\n * @returns `true` if inserted; `false` if key already exists.\n * @remarks Time O(1) avg, Space O(1)\n */\n _addVertex(newVertex) {\n if (this.hasVertex(newVertex)) {\n return false;\n }\n this._vertexMap.set(newVertex.key, newVertex);\n return true;\n }\n /**\n * Resolve a vertex key or instance to the concrete vertex instance.\n * @param vertexOrKey - Vertex key or existing vertex.\n * @returns Vertex instance or `undefined`.\n * @remarks Time O(1), Space O(1)\n */\n _getVertex(vertexOrKey) {\n const vertexKey = this._getVertexKey(vertexOrKey);\n return this._vertexMap.get(vertexKey) || void 0;\n }\n /**\n * Resolve a vertex key from a key or vertex instance.\n * @param vertexOrKey - Vertex key or existing vertex.\n * @returns The vertex key.\n * @remarks Time O(1), Space O(1)\n */\n _getVertexKey(vertexOrKey) {\n return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;\n }\n};\n__name(_AbstractGraph, \"AbstractGraph\");\nvar AbstractGraph = _AbstractGraph;\n\n// src/data-structures/graph/directed-graph.ts\nvar _DirectedVertex = class _DirectedVertex extends AbstractVertex {\n constructor(key, value) {\n super(key, value);\n }\n};\n__name(_DirectedVertex, \"DirectedVertex\");\nvar DirectedVertex = _DirectedVertex;\nvar _DirectedEdge = class _DirectedEdge extends AbstractEdge {\n constructor(src, dest, weight, value) {\n super(weight, value);\n __publicField(this, \"src\");\n __publicField(this, \"dest\");\n this.src = src;\n this.dest = dest;\n }\n};\n__name(_DirectedEdge, \"DirectedEdge\");\nvar DirectedEdge = _DirectedEdge;\nvar _DirectedGraph = class _DirectedGraph extends AbstractGraph {\n /**\n * Construct a directed graph with runtime defaults.\n * @param options - `GraphOptions<V>` (e.g. `vertexValueInitializer`, `defaultEdgeWeight`).\n * @remarks Time O(1), Space O(1)\n */\n constructor(options) {\n super(options);\n __publicField(this, \"_outEdgeMap\", /* @__PURE__ */ new Map());\n __publicField(this, \"_inEdgeMap\", /* @__PURE__ */ new Map());\n }\n get outEdgeMap() {\n return this._outEdgeMap;\n }\n set outEdgeMap(v) {\n this._outEdgeMap = v;\n }\n get inEdgeMap() {\n return this._inEdgeMap;\n }\n set inEdgeMap(v) {\n this._inEdgeMap = v;\n }\n /**\n * Construct a directed graph from keys with value initializer `v => v`.\n * @template K - Vertex key type.\n * @param keys - Iterable of vertex keys.\n * @returns DirectedGraph with all keys added.\n * @remarks Time O(V), Space O(V)\n */\n static fromKeys(keys) {\n const g = new _DirectedGraph({\n vertexValueInitializer: /* @__PURE__ */ __name((k) => k, \"vertexValueInitializer\")\n });\n for (const k of keys) g.addVertex(k);\n return g;\n }\n /**\n * Construct a directed graph from `[key, value]` entries.\n * @template V - Vertex value type.\n * @param entries - Iterable of `[key, value]` pairs.\n * @returns DirectedGraph with all vertices added.\n * @remarks Time O(V), Space O(V)\n */\n static fromEntries(entries) {\n const g = new _DirectedGraph();\n for (const [k, v] of entries) g.addVertex(k, v);\n return g;\n }\n /**\n * Create a directed vertex instance. Does not insert into the graph.\n * @param key - Vertex identifier.\n * @param value - Optional payload.\n * @returns Concrete vertex instance.\n * @remarks Time O(1), Space O(1)\n */\n createVertex(key, value) {\n return new DirectedVertex(key, value);\n }\n /**\n * Create a directed edge instance. Does not insert into the graph.\n * @param src - Source vertex key.\n * @param dest - Destination vertex key.\n * @param weight - Edge weight; defaults to `defaultEdgeWeight`.\n * @param value - Edge payload.\n * @returns Concrete edge instance.\n * @remarks Time O(1), Space O(1)\n */\n createEdge(src, dest, weight, value) {\n var _a;\n return new DirectedEdge(src, dest, (_a = weight != null ? weight : this.options.defaultEdgeWeight) != null ? _a : 1, value);\n }\n /**\n * Get the unique edge from `src` to `dest`, if present.\n * @param srcOrKey - Source vertex or key.\n * @param destOrKey - Destination vertex or key.\n * @returns Edge instance or `undefined`.\n * @remarks Time O(1) avg, Space O(1)\n */\n getEdge(srcOrKey, destOrKey) {\n let edgeMap = [];\n if (srcOrKey !== void 0 && destOrKey !== void 0) {\n const src = this._getVertex(srcOrKey);\n const dest = this._getVertex(destOrKey);\n if (src && dest) {\n const srcOutEdges = this._outEdgeMap.get(src);\n if (srcOutEdges) {\n edgeMap = srcOutEdges.filter((edge) => edge.dest === dest.key);\n }\n }\n }\n return edgeMap[0] || void 0;\n }\n /**\n * Delete edge `src -> dest` if present.\n * @param srcOrKey - Source vertex or key.\n * @param destOrKey - Destination vertex or key.\n * @returns Removed edge or `undefined`.\n * @remarks Time O(1) avg, Space O(1)\n */\n deleteEdgeSrcToDest(srcOrKey, destOrKey) {\n const src = this._getVertex(srcOrKey);\n const dest = this._getVertex(destOrKey);\n let removed = void 0;\n if (!src || !dest) {\n return void 0;\n }\n const srcOutEdges = this._outEdgeMap.get(src);\n if (srcOutEdges) {\n arrayRemove(srcOutEdges, (edge) => edge.dest === dest.key);\n }\n const destInEdges = this._inEdgeMap.get(dest);\n if (destInEdges) {\n removed = arrayRemove(destInEdges, (edge) => edge.src === src.key)[0] || void 0;\n }\n return removed;\n }\n /**\n * Delete an edge by instance or by `(srcKey, destKey)`.\n * @param edgeOrSrcVertexKey - Edge instance or source vertex/key.\n * @param destVertexKey - Optional destination vertex/key when deleting by pair.\n * @returns Removed edge or `undefined`.\n * @remarks Time O(1) avg, Space O(1)\n */\n deleteEdge(edgeOrSrcVertexKey, destVertexKey) {\n let removed = void 0;\n let src, dest;\n if (this.isVertexKey(edgeOrSrcVertexKey)) {\n if (this.isVertexKey(destVertexKey)) {\n src = this._getVertex(edgeOrSrcVertexKey);\n dest = this._getVertex(destVertexKey);\n } else {\n return;\n }\n } else {\n src = this._getVertex(edgeOrSrcVertexKey.src);\n dest = this._getVertex(edgeOrSrcVertexKey.dest);\n }\n if (src && dest) {\n const srcOutEdges = this._outEdgeMap.get(src);\n if (srcOutEdges && srcOutEdges.length > 0) {\n arrayRemove(srcOutEdges, (edge) => edge.src === src.key && edge.dest === (dest == null ? void 0 : dest.key));\n }\n const destInEdges = this._inEdgeMap.get(dest);\n if (destInEdges && destInEdges.length > 0) {\n removed = arrayRemove(destInEdges, (edge) => edge.src === src.key && edge.dest === dest.key)[0];\n }\n }\n return removed;\n }\n deleteVertex(vertexOrKey) {\n let vertexKey;\n let vertex;\n if (this.isVertexKey(vertexOrKey)) {\n vertex = this.getVertex(vertexOrKey);\n vertexKey = vertexOrKey;\n } else {\n vertex = vertexOrKey;\n vertexKey = this._getVertexKey(vertexOrKey);\n }\n if (vertex) {\n const neighbors = this.getNeighbors(vertex);\n for (const neighbor of neighbors) {\n this.deleteEdgeSrcToDest(vertex, neighbor);\n }\n this._outEdgeMap.delete(vertex);\n this._inEdgeMap.delete(vertex);\n }\n return this._vertexMap.delete(vertexKey);\n }\n deleteEdgesBetween(v1, v2) {\n const removed = [];\n if (v1 && v2) {\n const v1ToV2 = this.deleteEdgeSrcToDest(v1, v2);\n const v2ToV1 = this.deleteEdgeSrcToDest(v2, v1);\n if (v1ToV2) removed.push(v1ToV2);\n if (v2ToV1) removed.push(v2ToV1);\n }\n return removed;\n }\n /**\n * Incoming edges of a vertex.\n * @param vertexOrKey - Vertex or key.\n * @returns Array of incoming edges.\n * @remarks Time O(deg_in), Space O(deg_in)\n */\n incomingEdgesOf(vertexOrKey) {\n const target = this._getVertex(vertexOrKey);\n if (target) {\n return this.inEdgeMap.get(target) || [];\n }\n return [];\n }\n /**\n * Outgoing edges of a vertex.\n * @param vertexOrKey - Vertex or key.\n * @returns Array of outgoing edges.\n * @remarks Time O(deg_out), Space O(deg_out)\n */\n outgoingEdgesOf(vertexOrKey) {\n const target = this._getVertex(vertexOrKey);\n if (target) {\n return this._outEdgeMap.get(target) || [];\n }\n return [];\n }\n /**\n * Degree (in + out) of a vertex.\n * @param vertexOrKey - Vertex or key.\n * @returns Non-negative integer.\n * @remarks Time O(1) avg, Space O(1)\n */\n degreeOf(vertexOrKey) {\n return this.outDegreeOf(vertexOrKey) + this.inDegreeOf(vertexOrKey);\n }\n inDegreeOf(vertexOrKey) {\n return this.incomingEdgesOf(vertexOrKey).length;\n }\n outDegreeOf(vertexOrKey) {\n return this.outgoingEdgesOf(vertexOrKey).length;\n }\n /**\n * All incident edges of a vertex.\n * @param vertexOrKey - Vertex or key.\n * @returns Array of incident edges.\n * @remarks Time O(deg_in + deg_out), Space O(deg_in + deg_out)\n */\n edgesOf(vertexOrKey) {\n return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];\n }\n getEdgeSrc(e) {\n return this._getVertex(e.src);\n }\n getEdgeDest(e) {\n return this._getVertex(e.dest);\n }\n /**\n * Direct children reachable by one outgoing edge.\n * @param vertex - Vertex or key.\n * @returns Array of neighbor vertices.\n * @remarks Time O(deg_out), Space O(deg_out)\n */\n getDestinations(vertex) {\n if (vertex === void 0) {\n return [];\n }\n const destinations = [];\n const outgoingEdges = this.outgoingEdgesOf(vertex);\n for (const outEdge of outgoingEdges) {\n const child = this.getEdgeDest(outEdge);\n if (child) {\n destinations.push(child);\n }\n }\n return destinations;\n }\n /**\n * Topological sort if DAG; returns `undefined` if a cycle exists.\n * @param propertyName - `'key'` to map to keys; `'vertex'` to keep instances.\n * @returns Array of keys/vertices, or `undefined` when cycle is found.\n * @remarks Time O(V + E), Space O(V)\n */\n topologicalSort(propertyName) {\n propertyName = propertyName != null ? propertyName : \"key\";\n const statusMap = /* @__PURE__ */ new Map();\n for (const entry of this.vertexMap) {\n statusMap.set(entry[1], 0);\n }\n let sorted = [];\n let hasCycle = false;\n const dfs = /* @__PURE__ */ __name((cur) => {\n statusMap.set(cur, 1);\n const children = this.getDestinations(cur);\n for (const child of children) {\n const childStatus = statusMap.get(child);\n if (childStatus === 0) {\n dfs(child);\n } else if (childStatus === 1) {\n hasCycle = true;\n }\n }\n statusMap.set(cur, 2);\n sorted.push(cur);\n }, \"dfs\");\n for (const entry of this.vertexMap) {\n if (statusMap.get(entry[1]) === 0) {\n dfs(entry[1]);\n }\n }\n if (hasCycle) return void 0;\n if (propertyName === \"key\") sorted = sorted.map((vertex) => vertex instanceof DirectedVertex ? vertex.key : vertex);\n return sorted.reverse();\n }\n edgeSet() {\n let edgeMap = [];\n this._outEdgeMap.forEach((outEdges) => {\n edgeMap = [...edgeMap, ...outEdges];\n });\n return edgeMap;\n }\n getNeighbors(vertexOrKey) {\n const neighbors = [];\n const vertex = this._getVertex(vertexOrKey);\n if (vertex) {\n const outEdges = this.outgoingEdgesOf(vertex);\n for (const outEdge of outEdges) {\n const neighbor = this._getVertex(outEdge.dest);\n if (neighbor) {\n neighbors.push(neighbor);\n }\n }\n }\n return neighbors;\n }\n /**\n * Resolve an edge's `[src, dest]` endpoints to vertex instances.\n * @param edge - Edge instance.\n * @returns `[src, dest]` or `undefined` if either endpoint is missing.\n * @remarks Time O(1), Space O(1)\n */\n getEndsOfEdge(edge) {\n if (!this.hasEdge(edge.src, edge.dest)) {\n return void 0;\n }\n const v1 = this._getVertex(edge.src);\n const v2 = this._getVertex(edge.dest);\n if (v1 && v2) {\n return [v1, v2];\n } else {\n return void 0;\n }\n }\n /**\n * Whether the graph has no vertices and no edges.\n * @remarks Time O(1), Space O(1)\n */\n isEmpty() {\n return this.vertexMap.size === 0 && this.inEdgeMap.size === 0 && this.outEdgeMap.size === 0;\n }\n /**\n * Remove all vertices and edges.\n * @remarks Time O(V + E), Space O(1)\n */\n clear() {\n this._vertexMap = /* @__PURE__ */ new Map();\n this._inEdgeMap = /* @__PURE__ */ new Map();\n this._outEdgeMap = /* @__PURE__ */ new Map();\n }\n /**\n * Deep clone as the same concrete class.\n * @returns A new graph of the same concrete class (`this` type).\n * @remarks Time O(V + E), Space O(V + E)\n */\n clone() {\n return super.clone();\n }\n /**\n * Tarjan's algorithm for strongly connected components.\n * @returns `{ dfnMap, lowMap, SCCs }`.\n * @remarks Time O(V + E), Space O(V + E)\n */\n tarjan() {\n const dfnMap = /* @__PURE__ */ new Map();\n const lowMap = /* @__PURE__ */ new Map();\n const SCCs = /* @__PURE__ */ new Map();\n let time = 0;\n const stack = [];\n const inStack = /* @__PURE__ */ new Set();\n const dfs = /* @__PURE__ */ __name((vertex) => {\n dfnMap.set(vertex, time);\n lowMap.set(vertex, time);\n time++;\n stack.push(vertex);\n inStack.add(vertex);\n const neighbors = this.getNeighbors(vertex);\n for (const neighbor of neighbors) {\n if (!dfnMap.has(neighbor)) {\n dfs(neighbor);\n lowMap.set(vertex, Math.min(lowMap.get(vertex), lowMap.get(neighbor)));\n } else if (inStack.has(neighbor)) {\n lowMap.set(vertex, Math.min(lowMap.get(vertex), dfnMap.get(neighbor)));\n }\n }\n if (dfnMap.get(vertex) === lowMap.get(vertex)) {\n const SCC = [];\n let poppedVertex;\n do {\n poppedVertex = stack.pop();\n inStack.delete(poppedVertex);\n SCC.push(poppedVertex);\n } while (poppedVertex !== vertex);\n SCCs.set(SCCs.size, SCC);\n }\n }, \"dfs\");\n for (const vertex of this.vertexMap.values()) {\n if (!dfnMap.has(vertex)) {\n dfs(vertex);\n }\n }\n return { dfnMap, lowMap, SCCs };\n }\n /**\n * DFN index map computed by `tarjan()`.\n * @returns Map from vertex to DFN index.\n * @remarks Time O(V), Space O(V)\n */\n getDFNMap() {\n return this.tarjan().dfnMap;\n }\n /**\n * LOW link map computed by `tarjan()`.\n * @returns Map from vertex to LOW value.\n * @remarks Time O(V), Space O(V)\n */\n getLowMap() {\n return this.tarjan().lowMap;\n }\n /**\n * Strongly connected components computed by `tarjan()`.\n * @returns Map from SCC id to vertices.\n * @remarks Time O(#SCC + V), Space O(V)\n */\n getSCCs() {\n return this.tarjan().SCCs;\n }\n /**\n * Internal hook to attach a directed edge into adjacency maps.\n * @param edge - Edge instance.\n * @returns `true` if inserted; otherwise `false`.\n * @remarks Time O(1) avg, Space O(1)\n */\n _addEdge(edge) {\n if (!(this.hasVertex(edge.src) && this.hasVertex(edge.dest))) {\n return false;\n }\n const srcVertex = this._getVertex(edge.src);\n const destVertex = this._getVertex(edge.dest);\n if (srcVertex && destVertex) {\n const srcOutEdges = this._outEdgeMap.get(srcVertex);\n if (srcOutEdges) {\n srcOutEdges.push(edge);\n } else {\n this._outEdgeMap.set(srcVertex, [edge]);\n }\n const destInEdges = this._inEdgeMap.get(destVertex);\n if (destInEdges) {\n destInEdges.push(edge);\n } else {\n this._inEdgeMap.set(destVertex, [edge]);\n }\n return true;\n } else {\n return false;\n }\n }\n};\n__name(_DirectedGraph, \"DirectedGraph\");\nvar DirectedGraph = _DirectedGraph;\n\n// src/data-structures/graph/undirected-graph.ts\nvar _UndirectedVertex = class _UndirectedVertex extends AbstractVertex {\n constructor(key, value) {\n super(key, value);\n }\n};\n__name(_UndirectedVertex, \"UndirectedVertex\");\nvar UndirectedVertex = _UndirectedVertex;\nvar _UndirectedEdge = class _UndirectedEdge extends AbstractEdge {\n constructor(v1, v2, weight, value) {\n super(weight, value);\n __publicField(this, \"endpoints\");\n this.endpoints = [v1, v2];\n }\n};\n__name(_UndirectedEdge, \"UndirectedEdge\");\nvar UndirectedEdge = _UndirectedEdge;\nvar _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {\n /**\n * Construct an undirected graph with runtime defaults.\n * @param options - `GraphOptions<V>` (e.g. `vertexValueInitializer`, `defaultEdgeWeight`).\n * @remarks Time O(1), Space O(1)\n */\n constructor(options) {\n super(options);\n __publicField(this, \"_edgeMap\");\n this._edgeMap = /* @__PURE__ */ new Map();\n }\n get edgeMap() {\n return this._edgeMap;\n }\n set edgeMap(v) {\n this._edgeMap = v;\n }\n /**\n * Construct an undirected graph from keys with value initializer `v => v`.\n * @template K - Vertex key type.\n * @param keys - Iterable of vertex keys.\n * @returns UndirectedGraph with all keys added.\n * @remarks Time O(V), Space O(V)\n */\n static fromKeys(keys) {\n const g = new _UndirectedGraph({\n vertexValueInitializer: /* @__PURE__ */ __name((k) => k, \"vertexValueInitializer\")\n });\n for (const k of keys) g.addVertex(k);\n return g;\n }\n /**\n * Construct an undirected graph from `[key, value]` entries.\n * @template V - Vertex value type.\n * @param entries - Iterable of `[key, value]` pairs.\n * @returns UndirectedGraph with all vertices added.\n * @remarks Time O(V), Space O(V)\n */\n static fromEntries(entries) {\n const g = new _UndirectedGraph();\n for (const [k, v] of entries) g.addVertex(k, v);\n return g;\n }\n /**\n * Create an undirected vertex instance. Does not insert into the graph.\n * @param key - Vertex identifier.\n * @param value - Optional payload.\n * @returns Concrete vertex instance.\n * @remarks Time O(1), Space O(1)\n */\n createVertex(key, value) {\n return new UndirectedVertex(key, value);\n }\n /**\n * Create an undirected edge instance. Does not insert into the graph.\n * @param v1 - One endpoint key.\n * @param v2 - The other endpoint key.\n * @param weight - Edge weight; defaults to `defaultEdgeWeight`.\n * @param value - Edge payload.\n * @returns Concrete edge instance.\n * @remarks Time O(1), Space O(1)\n */\n createEdge(v1, v2, weight, value) {\n var _a;\n return new UndirectedEdge(v1, v2, (_a = weight != null ? weight : this.options.defaultEdgeWeight) != null ? _a : 1, value);\n }\n /**\n * Get an undirected edge between two vertices, if present.\n * @param v1 - One vertex or key.\n * @param v2 - The other vertex or key.\n * @returns Edge instance or `undefined`.\n * @remarks Time O(1) avg, Space O(1)\n */\n getEdge(v1, v2) {\n var _a;\n let edgeMap = [];\n if (v1 !== void 0 && v2 !== void 0) {\n const vertex1 = this._getVertex(v1);\n const vertex2 = this._getVertex(v2);\n if (vertex1 && vertex2) {\n edgeMap = (_a = this._edgeMap.get(vertex1)) == null ? void 0 : _a.filter((e) => e.endpoints.includes(vertex2.key));\n }\n }\n return edgeMap ? edgeMap[0] || void 0 : void 0;\n }\n /**\n * Delete a single undirected edge between two vertices.\n * @param v1 - One vertex or key.\n * @param v2 - The other vertex or key.\n * @returns Removed edge or `undefined`.\n * @remarks Time O(1) avg, Space O(1)\n */\n deleteEdgeBetween(v1, v2) {\n const vertex1 = this._getVertex(v1);\n const vertex2 = this._getVertex(v2);\n if (!vertex1 || !vertex2) {\n return void 0;\n }\n const v1Edges = this._edgeMap.get(vertex1);\n let removed = void 0;\n if (v1Edges) {\n removed = arrayRemove(v1Edges, (e) => e.endpoints.includes(vertex2.key))[0] || void 0;\n }\n const v2Edges = this._edgeMap.get(vertex2);\n if (v2Edges) {\n arrayRemove(v2Edges, (e) => e.endpoints.includes(vertex1.key));\n }\n return removed;\n }\n /**\n * Delete an edge by instance or by a pair of keys.\n * @param edgeOrOneSideVertexKey - Edge instance or one endpoint vertex/key.\n * @param otherSideVertexKey - Required second endpoint when deleting by pair.\n * @returns Removed edge or `undefined`.\n * @remarks Time O(1) avg, Space O(1)\n */\n deleteEdge(edgeOrOneSideVertexKey, otherSideVertexKey) {\n let oneSide, otherSide;\n if (this.isVertexKey(edgeOrOneSideVertexKey)) {\n if (this.isVertexKey(otherSideVertexKey)) {\n oneSide = this._getVertex(edgeOrOneSideVertexKey);\n otherSide = this._getVertex(otherSideVertexKey);\n } else {\n return;\n }\n } else {\n oneSide = this._getVertex(edgeOrOneSideVertexKey.endpoints[0]);\n otherSide = this._getVertex(edgeOrOneSideVertexKey.endpoints[1]);\n }\n if (oneSide && otherSide) {\n return this.deleteEdgeBetween(oneSide, otherSide);\n } else {\n return;\n }\n }\n /**\n * Delete a vertex and remove it from all neighbor lists.\n * @param vertexOrKey - Vertex or key.\n * @returns `true` if removed; otherwise `false`.\n * @remarks Time O(deg), Space O(1)\n */\n deleteVertex(vertexOrKey) {\n let vertexKey;\n let vertex;\n if (this.isVertexKey(vertexOrKey)) {\n vertex = this.getVertex(vertexOrKey);\n vertexKey = vertexOrKey;\n } else {\n vertex = vertexOrKey;\n vertexKey = this._getVertexKey(vertexOrKey);\n }\n const neighbors = this.getNeighbors(vertexOrKey);\n if (vertex) {\n neighbors.forEach((neighbor) => {\n const neighborEdges = this._edgeMap.get(neighbor);\n if (neighborEdges) {\n const restEdges = neighborEdges.filter((edge) => {\n return !edge.endpoints.includes(vertexKey);\n });\n this._edgeMap.set(neighbor, restEdges);\n }\n });\n this._edgeMap.delete(vertex);\n }\n return this._vertexMap.delete(vertexKey);\n }\n /**\n * Degree of a vertex (# of incident undirected edges).\n * @param vertexOrKey - Vertex or key.\n * @returns Non-negative integer.\n * @remarks Time O(1) avg, Space O(1)\n */\n degreeOf(vertexOrKey) {\n var _a;\n const vertex = this._getVertex(vertexOrKey);\n if (vertex) {\n return ((_a = this._edgeMap.get(vertex)) == null ? void 0 : _a.length) || 0;\n } else {\n return 0;\n }\n }\n /**\n * Incident undirected edges of a vertex.\n * @param vertexOrKey - Vertex or key.\n * @returns Array of incident edges.\n * @remarks Time O(deg), Space O(deg)\n */\n edgesOf(vertexOrKey) {\n const vertex = this._getVertex(vertexOrKey);\n if (vertex) {\n return this._edgeMap.get(vertex) || [];\n } else {\n return [];\n }\n }\n /**\n * Unique set of undirected edges across endpoints.\n * @returns Array of edges.\n * @remarks Time O(E), Space O(E)\n */\n edgeSet() {\n const edgeSet = /* @__PURE__ */ new Set();\n this._edgeMap.forEach((edgeMap) => {\n edgeMap.forEach((edge) => {\n edgeSet.add(edge);\n });\n });\n return [...edgeSet];\n }\n getNeighbors(vertexOrKey) {\n const neighbors = [];\n const vertex = this._getVertex(vertexOrKey);\n if (vertex) {\n const neighborEdges = this.edgesOf(vertex);\n for (const edge of neighborEdges) {\n const neighbor = this._getVertex(edge.endpoints.filter((e) => e !== vertex.key)[0]);\n if (neighbor) {\n neighbors.push(neighbor);\n }\n }\n }\n return neighbors;\n }\n /**\n * Resolve an edge's two endpoints to vertex instances.\n * @param edge - Edge instance.\n * @returns `[v1, v2]` or `undefined` if either endpoint is missing.\n * @remarks Time O(1), Space O(1)\n */\n getEndsOfEdge(edge) {\n if (!this.hasEdge(edge.endpoints[0], edge.endpoints[1])) {\n return void 0;\n }\n const v1 = this._getVertex(edge.endpoints[0]);\n const v2 = this._getVertex(edge.endpoints[1]);\n if (v1 && v2) {\n return [v1, v2];\n } else {\n return void 0;\n }\n }\n /**\n * Whether the graph has no vertices and no edges.\n * @remarks Time O(1), Space O(1)\n */\n isEmpty() {\n return this.vertexMap.size === 0 && this.edgeMap.size === 0;\n }\n /**\n * Remove all vertices and edges.\n * @remarks Time O(V + E), Space O(1)\n */\n clear() {\n this._vertexMap = /* @__PURE__ */ new Map();\n this._edgeMap = /* @__PURE__ */ new Map();\n }\n /**\n * Deep clone as the same concrete class.\n * @returns A new graph of the same concrete class (`this` type).\n * @remarks Time O(V + E), Space O(V + E)\n */\n clone() {\n return super.clone();\n }\n /**\n * Tarjan-based bridge and articulation point detection.\n * @returns `{ dfnMap, lowMap, bridges, cutVertices }`.\n * @remarks Time O(V + E), Space O(V + E)\n */\n tarjan() {\n const dfnMap = /* @__PURE__ */ new Map();\n const lowMap = /* @__PURE__ */ new Map();\n const bridges = [];\n const cutVertices = [];\n let time = 0;\n const dfs = /* @__PURE__ */ __name((vertex, parent) => {\n dfnMap.set(vertex, time);\n lowMap.set(vertex, time);\n time++;\n const neighbors = this.getNeighbors(vertex);\n let childCount = 0;\n for (const neighbor of neighbors) {\n if (!dfnMap.has(neighbor)) {\n childCount++;\n dfs(neighbor, vertex);\n lowMap.set(vertex, Math.min(lowMap.get(vertex), lowMap.get(neighbor)));\n if (lowMap.get(neighbor) > dfnMap.get(vertex)) {\n const edge = this.getEdge(vertex, neighbor);\n if (edge) {\n bridges.push(edge);\n }\n }\n if (parent !== void 0 && lowMap.get(neighbor) >= dfnMap.get(vertex)) {\n cutVertices.push(vertex);\n }\n } else if (neighbor !== parent) {\n lowMap.set(vertex, Math.min(lowMap.get(vertex), dfnMap.get(neighbor)));\n }\n }\n if (parent === void 0 && childCount > 1) {\n cutVertices.push(vertex);\n }\n }, \"dfs\");\n for (const vertex of this.vertexMap.values()) {\n if (!dfnMap.has(vertex)) {\n dfs(vertex, void 0);\n }\n }\n return {\n dfnMap,\n lowMap,\n bridges,\n cutVertices\n };\n }\n /**\n * Get bridges discovered by `tarjan()`.\n * @returns Array of edges that are bridges.\n * @remarks Time O(B), Space O(1)\n */\n getBridges() {\n return this.tarjan().bridges;\n }\n /**\n * Get articulation points discovered by `tarjan()`.\n * @returns Array of cut vertices.\n * @remarks Time O(C), Space O(1)\n */\n getCutVertices() {\n return this.tarjan().cutVertices;\n }\n /**\n * DFN index map computed by `tarjan()`.\n * @returns Map from vertex to DFN index.\n * @remarks Time O(V), Space O(V)\n */\n getDFNMap() {\n return this.tarjan().dfnMap;\n }\n /**\n * LOW link map computed by `tarjan()`.\n * @returns Map from vertex to LOW value.\n * @remarks Time O(V), Space O(V)\n */\n getLowMap() {\n return this.tarjan().lowMap;\n }\n /**\n * Internal hook to attach an undirected edge into adjacency maps.\n * @param edge - Edge instance.\n * @returns `true` if both endpoints exist; otherwise `false`.\n * @remarks Time O(1) avg, Space O(1)\n */\n _addEdge(edge) {\n for (const end of edge.endpoints) {\n const endVertex = this._getVertex(end);\n if (endVertex === void 0) return false;\n if (endVertex) {\n const edgeMap = this._edgeMap.get(endVertex);\n if (edgeMap) {\n edgeMap.push(edge);\n } else {\n this._edgeMap.set(endVertex, [edge]);\n }\n }\n }\n return true;\n }\n};\n__name(_UndirectedGraph, \"UndirectedGraph\");\nvar UndirectedGraph = _UndirectedGraph;\n\n// src/data-structures/graph/map-graph.ts\nvar _MapVertex = class _MapVertex extends DirectedVertex {\n constructor(key, value, lat, long) {\n super(key, value);\n __publicField(this, \"lat\");\n __publicField(this, \"long\");\n this.lat = lat;\n this.long = long;\n }\n};\n__name(_MapVertex, \"MapVertex\");\nvar MapVertex = _MapVertex;\nvar _MapEdge = class _MapEdge extends DirectedEdge {\n constructor(src, dest, weight, value) {\n super(src, dest, weight, value);\n }\n};\n__name(_MapEdge, \"MapEdge\");\nvar MapEdge = _MapEdge;\nvar _MapGraph = class _MapGraph extends DirectedGraph {\n /**\n * Construct a MapGraph.\n * @param originCoord - Origin coordinate `[lat, long]` used as default.\n * @param bottomRight - Optional bottom-right coordinate for bounding boxes.\n * @remarks Time O(1), Space O(1)\n */\n constructor(originCoord, bottomRight) {\n super();\n __publicField(this, \"_originCoord\", [0, 0]);\n __publicField(this, \"_bottomRight\");\n this._originCoord = originCoord;\n this._bottomRight = bottomRight;\n }\n get originCoord() {\n return this._originCoord;\n }\n get bottomRight() {\n return this._bottomRight;\n }\n /**\n * Create a map vertex with optional coordinates.\n * @param key - Vertex identifier.\n * @param value - Optional payload.\n * @param lat - Latitude (defaults to `originCoord[0]`).\n * @param long - Longitude (defaults to `originCoord[1]`).\n * @returns MapVertex instance.\n * @remarks Time O(1), Space O(1)\n */\n createVertex(key, value, lat = this.originCoord[0], long = this.originCoord[1]) {\n return new MapVertex(key, value, lat, long);\n }\n /**\n * Create a map edge (directed) with optional weight/value.\n * @param src - Source key.\n * @param dest - Destination key.\n * @param weight - Edge weight.\n * @param value - Edge payload.\n * @returns MapEdge instance.\n * @remarks Time O(1), Space O(1)\n */\n createEdge(src, dest, weight, value) {\n return new MapEdge(src, dest, weight, value);\n }\n /**\n * Deep clone as the same concrete class.\n * @returns A new graph of the same concrete class (`this` type).\n * @remarks Time O(V + E), Space O(V + E)\n */\n clone() {\n return super.clone();\n }\n /**\n * Include `originCoord` and `bottomRight` so `clone()/filter()` preserve geospatial settings.\n * @returns Options bag extending super snapshot.\n * @remarks Time O(1), Space O(1)\n */\n _snapshotOptions() {\n return { ...super._snapshotOptions(), originCoord: this.originCoord, bottomRight: this.bottomRight };\n }\n /**\n * Re-create a same-species MapGraph instance from snapshot options.\n * @param options - Snapshot options providing `originCoord`/`bottomRight`.\n * @returns Empty MapGraph instance of `this` type.\n * @remarks Time O(1), Space O(1)\n */\n _createInstance(options) {\n const { originCoord, bottomRight } = options || {};\n const oc = originCoord != null ? originCoord : this.originCoord;\n const br = bottomRight != null ? bottomRight : this.bottomRight;\n return new _MapGraph(oc, br);\n }\n};\n__name(_MapGraph, \"MapGraph\");\nvar MapGraph = _MapGraph;\n\n// src/common/index.ts\nvar DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {\n DFSOperation2[DFSOperation2[\"VISIT\"] = 0] = \"VISIT\";\n DFSOperation2[DFSOperation2[\"PROCESS\"] = 1] = \"PROCESS\";\n return DFSOperation2;\n})(DFSOperation || {});\nvar _Range = class _Range {\n constructor(low, high, includeLow = true, includeHigh = true) {\n this.low = low;\n this.high = high;\n this.includeLow = includeLow;\n this.includeHigh = includeHigh;\n }\n // Determine whether a key is within the range\n isInRange(key, comparator) {\n const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;\n const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;\n return lowCheck && highCheck;\n }\n};\n__name(_Range, \"Range\");\nvar Range = _Range;\n\n// src/data-structures/binary-tree/binary-tree.ts\nvar _BinaryTreeNode = class _BinaryTreeNode {\n /**\n * Creates an instance of BinaryTreeNode.\n * @remarks Time O(1), Space O(1)\n *\n * @param key - The key of the node.\n * @param [value] - The value associated with the key.\n */\n constructor(key, value) {\n __publicField(this, \"key\");\n __publicField(this, \"value\");\n __publicField(this, \"parent\");\n __publicField(this, \"_left\");\n __publicField(this, \"_right\");\n __publicField(this, \"_height\", 0);\n __publicField(this, \"_color\", \"BLACK\");\n __publicField(this, \"_count\", 1);\n this.key = key;\n this.value = value;\n }\n /**\n * Gets the left child of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The left child.\n */\n get left() {\n return this._left;\n }\n /**\n * Sets the left child of the node and updates its parent reference.\n * @remarks Time O(1), Space O(1)\n *\n * @param v - The node to set as the left child.\n */\n set left(v) {\n if (v) {\n v.parent = this;\n }\n this._left = v;\n }\n /**\n * Gets the right child of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The right child.\n */\n get right() {\n return this._right;\n }\n /**\n * Sets the right child of the node and updates its parent reference.\n * @remarks Time O(1), Space O(1)\n *\n * @param v - The node to set as the right child.\n */\n set right(v) {\n if (v) {\n v.parent = this;\n }\n this._right = v;\n }\n /**\n * Gets the height of the node (used in self-balancing trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The height.\n */\n get height() {\n return this._height;\n }\n /**\n * Sets the height of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new height.\n */\n set height(value) {\n this._height = value;\n }\n /**\n * Gets the color of the node (used in Red-Black trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The node's color.\n */\n get color() {\n return this._color;\n }\n /**\n * Sets the color of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new color.\n */\n set color(value) {\n this._color = value;\n }\n /**\n * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The subtree node count.\n */\n get count() {\n return this._count;\n }\n /**\n * Sets the count of nodes in the subtree.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new count.\n */\n set count(value) {\n this._count = value;\n }\n /**\n * Gets the position of the node relative to its parent.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').\n */\n get familyPosition() {\n if (!this.parent) {\n return this.left || this.right ? \"ROOT\" : \"ISOLATED\";\n }\n if (this.parent.left === this) {\n return this.left || this.right ? \"ROOT_LEFT\" : \"LEFT\";\n } else if (this.parent.right === this) {\n return this.left || this.right ? \"ROOT_RIGHT\" : \"RIGHT\";\n }\n return \"MAL_NODE\";\n }\n};\n__name(_BinaryTreeNode, \"BinaryTreeNode\");\nvar BinaryTreeNode = _BinaryTreeNode;\nvar _BinaryTree = class _BinaryTree extends IterableEntryBase {\n /**\n * Creates an instance of BinaryTree.\n * @remarks Time O(N * M), where N is the number of items in `keysNodesEntriesOrRaws` and M is the tree size at insertion time (due to O(M) `set` operation). Space O(N) for storing the nodes.\n *\n * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.\n * @param [options] - Configuration options for the tree.\n */\n constructor(keysNodesEntriesOrRaws = [], options) {\n super();\n __publicField(this, \"iterationType\", \"ITERATIVE\");\n __publicField(this, \"_isMapMode\", true);\n __publicField(this, \"_isDuplicate\", false);\n // Map mode acceleration store:\n // - isMapMode=false: unused\n // - isMapMode=true: key -> node reference (O(1) has/getNode + fast get)\n __publicField(this, \"_store\", /* @__PURE__ */ new Map());\n __publicField(this, \"_root\");\n __publicField(this, \"_size\", 0);\n __publicField(this, \"_NIL\", new BinaryTreeNode(NaN));\n __publicField(this, \"_toEntryFn\");\n /**\n * (Protected) Default callback function, returns the node's key.\n * @remarks Time O(1)\n *\n * @param node - The node.\n * @returns The node's key or undefined.\n */\n __publicField(this, \"_DEFAULT_NODE_CALLBACK\", /* @__PURE__ */ __name((node) => node ? node.key : void 0, \"_DEFAULT_NODE_CALLBACK\"));\n if (options) {\n const { iterationType, toEntryFn, isMapMode, isDuplicate } = options;\n if (iterationType) this.iterationType = iterationType;\n if (isMapMode !== void 0) this._isMapMode = isMapMode;\n if (isDuplicate !== void 0) this._isDuplicate = isDuplicate;\n if (typeof toEntryFn === \"function\") this._toEntryFn = toEntryFn;\n else if (toEntryFn) throw TypeError(\"toEntryFn must be a function type\");\n }\n if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);\n }\n /**\n * Gets whether the tree is in Map mode.\n * @remarks In Map mode (default), values are stored in an external Map, and nodes only hold keys. If false, values are stored directly on the nodes. Time O(1)\n *\n * @returns True if in Map mode, false otherwise.\n */\n get isMapMode() {\n return this._isMapMode;\n }\n /**\n * Gets whether the tree allows duplicate keys.\n * @remarks Time O(1)\n *\n * @returns True if duplicates are allowed, false otherwise.\n */\n get isDuplicate() {\n return this._isDuplicate;\n }\n /**\n * Gets the external value store (used in Map mode).\n * @remarks Time O(1)\n *\n * @returns The map storing key-value pairs.\n */\n get store() {\n return this._store;\n }\n /**\n * Gets the root node of the tree.\n * @remarks Time O(1)\n *\n * @returns The root node.\n */\n get root() {\n return this._root;\n }\n /**\n * Gets the number of nodes in the tree.\n * @remarks Time O(1)\n *\n * @returns The size of the tree.\n */\n get size() {\n return this._size;\n }\n /**\n * Gets the sentinel NIL node (used in self-balancing trees like Red-Black Tree).\n * @remarks Time O(1)\n *\n * @returns The NIL node.\n */\n get NIL() {\n return this._NIL;\n }\n /**\n * Gets the function used to convert raw data objects (R) into [key, value] entries.\n * @remarks Time O(1)\n *\n * @returns The conversion function.\n */\n get toEntryFn() {\n return this._toEntryFn;\n }\n /**\n * (Protected) Creates a new node.\n * @remarks Time O(1), Space O(1)\n *\n * @param key - The key for the new node.\n * @param [value] - The value for the new node (used if not in Map mode).\n * @returns The newly created node.\n */\n createNode(key, value) {\n return new BinaryTreeNode(key, value);\n }\n /**\n * Creates a new, empty tree of the same type and configuration.\n * @remarks Time O(1) (excluding options cloning), Space O(1)\n *\n * @param [options] - Optional overrides for the new tree's options.\n * @returns A new, empty tree instance.\n */\n createTree(options) {\n return this._createInstance(options);\n }\n /**\n * Ensures the input is a node. If it's a key or entry, it searches for the node.\n * @remarks Time O(1) if a node is passed. O(N) if a key or entry is passed (due to `getNode` performing a full search). Space O(1) if iterative search, O(H) if recursive (where H is height, O(N) worst-case).\n *\n * @param keyNodeOrEntry - The item to resolve to a node.\n * @param [iterationType=this.iterationType] - The traversal method to use if searching.\n * @returns The resolved node, or null/undefined if not found or input is null/undefined.\n */\n ensureNode(keyNodeOrEntry, iterationType = this.iterationType) {\n if (keyNodeOrEntry === null) return null;\n if (keyNodeOrEntry === void 0) return;\n if (keyNodeOrEntry === this._NIL) return;\n if (this.isNode(keyNodeOrEntry)) return keyNodeOrEntry;\n if (this.isEntry(keyNodeOrEntry)) {\n const key = keyNodeOrEntry[0];\n if (key === null) return null;\n if (key === void 0) return;\n return this.getNode(key, this._root, iterationType);\n }\n return this.getNode(keyNodeOrEntry, this._root, iterationType);\n }\n /**\n * Checks if the given item is a `BinaryTreeNode` instance.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeOrEntry - The item to check.\n * @returns True if it's a node, false otherwise.\n */\n isNode(keyNodeOrEntry) {\n return keyNodeOrEntry instanceof BinaryTreeNode;\n }\n /**\n * Checks if the given item is a raw data object (R) that needs conversion via `toEntryFn`.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeEntryOrRaw - The item to check.\n * @returns True if it's a raw object, false otherwise.\n */\n isRaw(keyNodeEntryOrRaw) {\n return this._toEntryFn !== void 0 && typeof keyNodeEntryOrRaw === \"object\";\n }\n /**\n * Checks if the given item is a \"real\" node (i.e., not null, undefined, or NIL).\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeOrEntry - The item to check.\n * @returns True if it's a real node, false otherwise.\n */\n isRealNode(keyNodeOrEntry) {\n if (keyNodeOrEntry === this._NIL || keyNodeOrEntry === null || keyNodeOrEntry === void 0) return false;\n return this.isNode(keyNodeOrEntry);\n }\n /**\n * Checks if the given item is either a \"real\" node or null.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeOrEntry - The item to check.\n * @returns True if it's a real node or null, false otherwise.\n */\n isRealNodeOrNull(keyNodeOrEntry) {\n return keyNodeOrEntry === null || this.isRealNode(keyNodeOrEntry);\n }\n /**\n * Checks if the given item is the sentinel NIL node.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeOrEntry - The item to check.\n * @returns True if it's the NIL node, false otherwise.\n */\n isNIL(keyNodeOrEntry) {\n return keyNodeOrEntry === this._NIL;\n }\n /**\n * Checks if the given item is a `Range` object.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeEntryOrPredicate - The item to check.\n * @returns True if it's a Range, false otherwise.\n */\n isRange(keyNodeEntryOrPredicate) {\n return keyNodeEntryOrPredicate instanceof Range;\n }\n /**\n * Checks if a node is a leaf (has no real children).\n * @remarks Time O(N) if a key/entry is passed (due to `ensureNode`). O(1) if a node is passed. Space O(1) or O(H) (from `ensureNode`).\n *\n * @param keyNodeOrEntry - The node to check.\n * @returns True if the node is a leaf, false otherwise.\n */\n isLeaf(keyNodeOrEntry) {\n keyNodeOrEntry = this.ensureNode(keyNodeOrEntry);\n if (keyNodeOrEntry === void 0) return false;\n if (keyNodeOrEntry === null) return true;\n return !this.isRealNode(keyNodeOrEntry.left) && !this.isRealNode(keyNodeOrEntry.right);\n }\n /**\n * Checks if the given item is a [key, value] entry pair.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeOrEntry - The item to check.\n * @returns True if it's an entry, false otherwise.\n */\n isEntry(keyNodeOrEntry) {\n return Array.isArray(keyNodeOrEntry) && keyNodeOrEntry.length === 2;\n }\n /**\n * Checks if the given key is valid (comparable or null).\n * @remarks Time O(1), Space O(1)\n *\n * @param key - The key to validate.\n * @returns True if the key is valid, false otherwise.\n */\n isValidKey(key) {\n if (key === null) return true;\n return isComparable(key);\n }\n /**\n * Adds a new node to the tree.\n * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).\n *\n * @param keyNodeOrEntry - The key, node, or entry to add.\n * @returns True if the addition was successful, false otherwise.\n */\n add(keyNodeOrEntry) {\n return this.set(keyNodeOrEntry);\n }\n /**\n * Adds or updates a new node to the tree.\n * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation sets the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).\n *\n * @param keyNodeOrEntry - The key, node, or entry to set or update.\n * @param [value] - The value, if providing just a key.\n * @returns True if the addition was successful, false otherwise.\n */\n set(keyNodeOrEntry, value) {\n const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);\n if (newNode === void 0) return false;\n if (!this._root) {\n this._setRoot(newNode);\n if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);\n this._size = 1;\n return true;\n }\n const queue = new Queue([this._root]);\n let potentialParent;\n while (queue.length > 0) {\n const cur = queue.shift();\n if (!cur) continue;\n if (!this._isDuplicate) {\n if (newNode !== null && cur.key === newNode.key) {\n this._replaceNode(cur, newNode);\n if (this._isMapMode && newNode !== null) this._store.set(cur.key, newNode);\n return true;\n }\n }\n if (potentialParent === void 0 && (cur.left === void 0 || cur.right === void 0)) {\n potentialParent = cur;\n }\n if (cur.left !== null) {\n if (cur.left) queue.push(cur.left);\n }\n if (cur.right !== null) {\n if (cur.right) queue.push(cur.right);\n }\n }\n if (potentialParent) {\n if (potentialParent.left === void 0) {\n potentialParent.left = newNode;\n } else if (potentialParent.right === void 0) {\n potentialParent.right = newNode;\n }\n if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);\n this._size++;\n return true;\n }\n return false;\n }\n /**\n * Adds multiple items to the tree.\n * @remarks Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).\n *\n * @param keysNodesEntriesOrRaws - An iterable of items to set.\n * @returns An array of booleans indicating the success of each individual `set` operation.\n */\n addMany(keysNodesEntriesOrRaws) {\n return this.setMany(keysNodesEntriesOrRaws);\n }\n /**\n * Adds or updates multiple items to the tree.\n * @remarks Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).\n *\n * @param keysNodesEntriesOrRaws - An iterable of items to set or update.\n * @param [values] - An optional parallel iterable of values.\n * @returns An array of booleans indicating the success of each individual `set` operation.\n */\n setMany(keysNodesEntriesOrRaws, values) {\n const inserted = [];\n let valuesIterator;\n if (values) {\n valuesIterator = values[Symbol.iterator]();\n }\n for (let keyNodeEntryOrRaw of keysNodesEntriesOrRaws) {\n let value = void 0;\n if (valuesIterator) {\n const valueResult = valuesIterator.next();\n if (!valueResult.done) {\n value = valueResult.value;\n }\n }\n if (this.isRaw(keyNodeEntryOrRaw)) keyNodeEntryOrRaw = this._toEntryFn(keyNodeEntryOrRaw);\n inserted.push(this.set(keyNodeEntryOrRaw, value));\n }\n return inserted;\n }\n /**\n * Merges another tree into this one by seting all its nodes.\n * @remarks Time O(N * M), same as `setMany`, where N is the size of `anotherTree` and M is the size of this tree. Space O(M) (from `set`).\n *\n * @param anotherTree - The tree to merge.\n */\n merge(anotherTree) {\n this.setMany(anotherTree, []);\n }\n /**\n * Clears the tree and refills it with new items.\n * @remarks Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).\n *\n * @param keysNodesEntriesOrRaws - An iterable of items to set.\n * @param [values] - An optional parallel iterable of values.\n */\n refill(keysNodesEntriesOrRaws, values) {\n this.clear();\n this.setMany(keysNodesEntriesOrRaws, values);\n }\n /**\n * Deletes a node from the tree.\n * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation finds the node, and if it has two children, swaps it with the rightmost node of its left subtree (in-order predecessor) before deleting. Time O(N) in the worst case. O(N) to find the node (`getNode`) and O(H) (which is O(N) worst-case) to find the rightmost node. Space O(1) (if `getNode` is iterative, which it is).\n *\n * @param keyNodeEntryRawOrPredicate - The node to delete.\n * @returns An array containing deletion results (for compatibility with self-balancing trees).\n */\n delete(keyNodeEntryRawOrPredicate) {\n const deletedResult = [];\n if (!this._root) return deletedResult;\n const curr = this.getNode(keyNodeEntryRawOrPredicate);\n if (!curr) return deletedResult;\n const parent = curr == null ? void 0 : curr.parent;\n let needBalanced;\n let orgCurrent = curr;\n if (!curr.left && !curr.right && !parent) {\n this._setRoot(void 0);\n } else if (curr.left) {\n const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);\n if (leftSubTreeRightMost) {\n const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;\n orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);\n if (this._isMapMode) {\n this._store.set(curr.key, curr);\n this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);\n }\n if (parentOfLeftSubTreeMax) {\n if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)\n parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;\n else parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;\n needBalanced = parentOfLeftSubTreeMax;\n }\n }\n } else if (parent) {\n const { familyPosition: fp } = curr;\n if (fp === \"LEFT\" || fp === \"ROOT_LEFT\") {\n parent.left = curr.right;\n } else if (fp === \"RIGHT\" || fp === \"ROOT_RIGHT\") {\n parent.right = curr.right;\n }\n needBalanced = parent;\n } else {\n this._setRoot(curr.right);\n curr.right = void 0;\n }\n this._size = this._size - 1;\n deletedResult.push({ deleted: orgCurrent, needBalanced });\n if (this._isMapMode && orgCurrent) this._store.delete(orgCurrent.key);\n return deletedResult;\n }\n /**\n * Searches the tree for nodes matching a predicate.\n * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). Performs a full DFS (pre-order) scan of the tree. Time O(N), as it may visit every node. Space O(H) for the call stack (recursive) or explicit stack (iterative), where H is the tree height (O(N) worst-case).\n *\n * @template C - The type of the callback function.\n * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.\n * @param [onlyOne=false] - If true, stops after finding the first match.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on matching nodes.\n * @param [startNode=this._root] - The node to start the search from.\n * @param [iterationType=this.iterationType] - Whether to use 'RECURSIVE' or 'ITERATIVE' search.\n * @returns An array of results from the callback function for each matching node.\n */\n search(keyNodeEntryOrPredicate, onlyOne = false, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n if (keyNodeEntryOrPredicate === void 0) return [];\n if (keyNodeEntryOrPredicate === null) return [];\n startNode = this.ensureNode(startNode);\n if (!startNode) return [];\n const predicate = this._ensurePredicate(keyNodeEntryOrPredicate);\n const ans = [];\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (predicate(cur)) {\n ans.push(callback(cur));\n if (onlyOne) return;\n }\n if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right)) return;\n if (this.isRealNode(cur.left)) dfs(cur.left);\n if (this.isRealNode(cur.right)) dfs(cur.right);\n }, \"dfs\");\n dfs(startNode);\n } else {\n const stack = [startNode];\n while (stack.length > 0) {\n const cur = stack.pop();\n if (this.isRealNode(cur)) {\n if (predicate(cur)) {\n ans.push(callback(cur));\n if (onlyOne) return ans;\n }\n if (this.isRealNode(cur.left)) stack.push(cur.left);\n if (this.isRealNode(cur.right)) stack.push(cur.right);\n }\n }\n }\n return ans;\n }\n getNodes(keyNodeEntryOrPredicate, onlyOne = false, startNode = this._root, iterationType = this.iterationType) {\n return this.search(keyNodeEntryOrPredicate, onlyOne, (node) => node, startNode, iterationType);\n }\n /**\n * Gets the first node matching a predicate.\n * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). Time O(N) in the worst case (via `search`). Space O(H) or O(N) (via `search`).\n *\n * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.\n * @param [startNode=this._root] - The node to start the search from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns The first matching node, or undefined if not found.\n */\n getNode(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {\n if (this._isMapMode && keyNodeEntryOrPredicate !== null && keyNodeEntryOrPredicate !== void 0) {\n if (!this._isPredicate(keyNodeEntryOrPredicate)) {\n const key = this._extractKey(keyNodeEntryOrPredicate);\n if (key === null || key === void 0) return;\n return this._store.get(key);\n }\n }\n return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType)[0];\n }\n /**\n * Gets the value associated with a key.\n * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). Time O(1) if in Map mode. O(N) if not in Map mode (uses `getNode`). Space O(1) if in Map mode. O(H) or O(N) otherwise.\n *\n * @param keyNodeEntryOrPredicate - The key, node, or entry to get the value for.\n * @param [startNode=this._root] - The node to start searching from (if not in Map mode).\n * @param [iterationType=this.iterationType] - The traversal method (if not in Map mode).\n * @returns The associated value, or undefined.\n */\n get(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {\n var _a, _b;\n if (this._isMapMode) {\n const key = this._extractKey(keyNodeEntryOrPredicate);\n if (key === null || key === void 0) return;\n return (_a = this._store.get(key)) == null ? void 0 : _a.value;\n }\n return (_b = this.getNode(keyNodeEntryOrPredicate, startNode, iterationType)) == null ? void 0 : _b.value;\n }\n has(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {\n if (this._isMapMode && keyNodeEntryOrPredicate !== void 0 && keyNodeEntryOrPredicate !== null) {\n if (!this._isPredicate(keyNodeEntryOrPredicate)) {\n const key = this._extractKey(keyNodeEntryOrPredicate);\n if (key === null || key === void 0) return false;\n return this._store.has(key);\n }\n }\n return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType).length > 0;\n }\n /**\n * Clears the tree of all nodes and values.\n * @remarks Time O(N) if in Map mode (due to `_store.clear()`), O(1) otherwise. Space O(1)\n */\n clear() {\n this._clearNodes();\n if (this._isMapMode) this._clearValues();\n }\n /**\n * Checks if the tree is empty.\n * @remarks Time O(1), Space O(1)\n *\n * @returns True if the tree has no nodes, false otherwise.\n */\n isEmpty() {\n return this._size === 0;\n }\n /**\n * Checks if the tree is perfectly balanced.\n * @remarks A tree is perfectly balanced if the difference between min and max height is at most 1. Time O(N), as it requires two full traversals (`getMinHeight` and `getHeight`). Space O(H) or O(N) (from height calculation).\n *\n * @param [startNode=this._root] - The node to start checking from.\n * @returns True if perfectly balanced, false otherwise.\n */\n isPerfectlyBalanced(startNode = this._root) {\n return this.getMinHeight(startNode) + 1 >= this.getHeight(startNode);\n }\n /**\n * Checks if the tree is a valid Binary Search Tree (BST).\n * @remarks Time O(N), as it must visit every node. Space O(H) for the call stack (recursive) or explicit stack (iterative), where H is the tree height (O(N) worst-case).\n *\n * @param [startNode=this._root] - The node to start checking from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns True if it's a valid BST, false otherwise.\n */\n isBST(startNode = this._root, iterationType = this.iterationType) {\n const startNodeSired = this.ensureNode(startNode);\n if (!startNodeSired) return true;\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur, min, max) => {\n if (!this.isRealNode(cur)) return true;\n const numKey = Number(cur.key);\n if (numKey <= min || numKey >= max) return false;\n return dfs(cur.left, min, numKey) && dfs(cur.right, numKey, max);\n }, \"dfs\");\n const isStandardBST = dfs(startNodeSired, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n const isInverseBST = dfs(startNodeSired, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER);\n return isStandardBST || isInverseBST;\n } else {\n const checkBST = /* @__PURE__ */ __name((checkMax = false) => {\n const stack = [];\n let prev = checkMax ? Number.MAX_SAFE_INTEGER : Number.MIN_SAFE_INTEGER;\n let curr = startNodeSired;\n while (this.isRealNode(curr) || stack.length > 0) {\n while (this.isRealNode(curr)) {\n stack.push(curr);\n curr = curr.left;\n }\n curr = stack.pop();\n const numKey = Number(curr.key);\n if (!this.isRealNode(curr) || !checkMax && prev >= numKey || checkMax && prev <= numKey) return false;\n prev = numKey;\n curr = curr.right;\n }\n return true;\n }, \"checkBST\");\n const isStandardBST = checkBST();\n const isInverseBST = checkBST(true);\n return isStandardBST || isInverseBST;\n }\n }\n /**\n * Gets the depth of a node (distance from `startNode`).\n * @remarks Time O(H), where H is the depth of the `dist` node relative to `startNode`. O(N) worst-case. Space O(1).\n *\n * @param dist - The node to find the depth of.\n * @param [startNode=this._root] - The node to measure depth from (defaults to root).\n * @returns The depth (0 if `dist` is `startNode`).\n */\n getDepth(dist, startNode = this._root) {\n let distEnsured = this.ensureNode(dist);\n const beginRootEnsured = this.ensureNode(startNode);\n let depth = 0;\n while (distEnsured == null ? void 0 : distEnsured.parent) {\n if (distEnsured === beginRootEnsured) {\n return depth;\n }\n depth++;\n distEnsured = distEnsured.parent;\n }\n return depth;\n }\n /**\n * Gets the maximum height of the tree (longest path from startNode to a leaf).\n * @remarks Time O(N), as it must visit every node. Space O(H) for recursive stack (O(N) worst-case) or O(N) for iterative stack (storing node + depth).\n *\n * @param [startNode=this._root] - The node to start measuring from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns The height ( -1 for an empty tree, 0 for a single-node tree).\n */\n getHeight(startNode = this._root, iterationType = this.iterationType) {\n startNode = this.ensureNode(startNode);\n if (!this.isRealNode(startNode)) return -1;\n if (iterationType === \"RECURSIVE\") {\n const _getMaxHeight = /* @__PURE__ */ __name((cur) => {\n if (!this.isRealNode(cur)) return -1;\n const leftHeight = _getMaxHeight(cur.left);\n const rightHeight = _getMaxHeight(cur.right);\n return Math.max(leftHeight, rightHeight) + 1;\n }, \"_getMaxHeight\");\n return _getMaxHeight(startNode);\n } else {\n const stack = [{ node: startNode, depth: 0 }];\n let maxHeight = 0;\n while (stack.length > 0) {\n const { node, depth } = stack.pop();\n if (this.isRealNode(node.left)) stack.push({ node: node.left, depth: depth + 1 });\n if (this.isRealNode(node.right)) stack.push({ node: node.right, depth: depth + 1 });\n maxHeight = Math.max(maxHeight, depth);\n }\n return maxHeight;\n }\n }\n /**\n * Gets the minimum height of the tree (shortest path from startNode to a leaf).\n * @remarks Time O(N), as it must visit every node. Space O(H) for recursive stack (O(N) worst-case) or O(N) for iterative (due to `depths` Map).\n *\n * @param [startNode=this._root] - The node to start measuring from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns The minimum height (-1 for empty, 0 for single node).\n */\n getMinHeight(startNode = this._root, iterationType = this.iterationType) {\n startNode = this.ensureNode(startNode);\n if (!startNode) return -1;\n if (iterationType === \"RECURSIVE\") {\n const _getMinHeight = /* @__PURE__ */ __name((cur) => {\n if (!this.isRealNode(cur)) return 0;\n if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right)) return 0;\n const leftMinHeight = _getMinHeight(cur.left);\n const rightMinHeight = _getMinHeight(cur.right);\n return Math.min(leftMinHeight, rightMinHeight) + 1;\n }, \"_getMinHeight\");\n return _getMinHeight(startNode);\n } else {\n const stack = [];\n let node = startNode, last = null;\n const depths = /* @__PURE__ */ new Map();\n while (stack.length > 0 || node) {\n if (this.isRealNode(node)) {\n stack.push(node);\n node = node.left;\n } else {\n node = stack[stack.length - 1];\n if (!this.isRealNode(node.right) || last === node.right) {\n node = stack.pop();\n if (this.isRealNode(node)) {\n const leftMinHeight = this.isRealNode(node.left) ? depths.get(node.left) : -1;\n const rightMinHeight = this.isRealNode(node.right) ? depths.get(node.right) : -1;\n depths.set(node, 1 + Math.min(leftMinHeight, rightMinHeight));\n last = node;\n node = null;\n }\n } else node = node.right;\n }\n }\n return depths.get(startNode);\n }\n }\n /**\n * Gets the path from a given node up to the root.\n * @remarks Time O(H), where H is the depth of the `beginNode`. O(N) worst-case. Space O(H) for the result array.\n *\n * @template C - The type of the callback function.\n * @param beginNode - The node to start the path from.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on each node in the path.\n * @param [isReverse=false] - If true, returns the path from root-to-node.\n * @returns An array of callback results.\n */\n getPathToRoot(beginNode, callback = this._DEFAULT_NODE_CALLBACK, isReverse = false) {\n const result = [];\n let beginNodeEnsured = this.ensureNode(beginNode);\n if (!beginNodeEnsured) return result;\n while (beginNodeEnsured.parent) {\n result.push(callback(beginNodeEnsured));\n beginNodeEnsured = beginNodeEnsured.parent;\n }\n result.push(callback(beginNodeEnsured));\n return isReverse ? result.reverse() : result;\n }\n /**\n * Finds the leftmost node in a subtree (the node with the smallest key in a BST).\n * @remarks Time O(H), where H is the height of the left spine. O(N) worst-case. Space O(H) for recursive/trampoline stack.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on the leftmost node.\n * @param [startNode=this._root] - The subtree root to search from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns The callback result for the leftmost node.\n */\n getLeftMost(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n if (this.isNIL(startNode)) return callback(void 0);\n const ensuredStartNode = this.ensureNode(startNode);\n if (!this.isRealNode(ensuredStartNode)) return callback(void 0);\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n const { left } = cur;\n if (!this.isRealNode(left)) return cur;\n return dfs(left);\n }, \"dfs\");\n return callback(dfs(ensuredStartNode));\n } else {\n const dfs = makeTrampoline((cur) => {\n const { left } = cur;\n if (!this.isRealNode(left)) return cur;\n return makeTrampolineThunk(() => dfs(left));\n });\n return callback(dfs(ensuredStartNode));\n }\n }\n /**\n * Finds the rightmost node in a subtree (the node with the largest key in a BST).\n * @remarks Time O(H), where H is the height of the right spine. O(N) worst-case. Space O(H) for recursive/trampoline stack.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on the rightmost node.\n * @param [startNode=this._root] - The subtree root to search from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns The callback result for the rightmost node.\n */\n getRightMost(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n if (this.isNIL(startNode)) return callback(void 0);\n startNode = this.ensureNode(startNode);\n if (!startNode) return callback(void 0);\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n const { right } = cur;\n if (!this.isRealNode(right)) return cur;\n return dfs(right);\n }, \"dfs\");\n return callback(dfs(startNode));\n } else {\n const dfs = makeTrampoline((cur) => {\n const { right } = cur;\n if (!this.isRealNode(right)) return cur;\n return makeTrampolineThunk(() => dfs(right));\n });\n return callback(dfs(startNode));\n }\n }\n /**\n * Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).\n * @remarks This is primarily a helper for Morris traversal. Time O(H), where H is the height of the left subtree. O(N) worst-case. Space O(1).\n *\n * @param node - The node to find the predecessor for.\n * @returns The Morris predecessor.\n */\n getPredecessor(node) {\n if (this.isRealNode(node.left)) {\n let predecessor = node.left;\n while (!this.isRealNode(predecessor) || this.isRealNode(predecessor.right) && predecessor.right !== node) {\n if (this.isRealNode(predecessor)) {\n predecessor = predecessor.right;\n }\n }\n return predecessor;\n } else {\n return node;\n }\n }\n /**\n * Gets the in-order successor of a node in a BST.\n * @remarks Time O(H), where H is the tree height. O(N) worst-case. Space O(H) (due to `getLeftMost` stack).\n *\n * @param [x] - The node to find the successor of.\n * @returns The successor node, or null/undefined if none exists.\n */\n getSuccessor(x) {\n x = this.ensureNode(x);\n if (!this.isRealNode(x)) return void 0;\n if (this.isRealNode(x.right)) {\n return this.getLeftMost((node) => node, x.right);\n }\n let y = x.parent;\n while (this.isRealNode(y) && x === y.right) {\n x = y;\n y = y.parent;\n }\n return y;\n }\n /**\n * Performs a Depth-First Search (DFS) traversal.\n * @remarks Time O(N), visits every node. Space O(H) for the call/explicit stack. O(N) worst-case.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.\n * @param [pattern='IN'] - The traversal order ('IN', 'PRE', 'POST').\n * @param [onlyOne=false] - If true, stops after the first callback.\n * @param [startNode=this._root] - The node to start from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @param [includeNull=false] - If true, includes null nodes in the traversal.\n * @returns An array of callback results.\n */\n dfs(callback = this._DEFAULT_NODE_CALLBACK, pattern = \"IN\", onlyOne = false, startNode = this._root, iterationType = this.iterationType, includeNull = false) {\n startNode = this.ensureNode(startNode);\n if (!startNode) return [];\n return this._dfs(callback, pattern, onlyOne, startNode, iterationType, includeNull);\n }\n /**\n * Performs a Breadth-First Search (BFS) or Level-Order traversal.\n * @remarks Time O(N), visits every node. Space O(N) in the worst case for the queue (e.g., a full last level).\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.\n * @param [startNode=this._root] - The node to start from.\n * @param [iterationType=this.iterationType] - The traversal method ('RECURSIVE' BFS is less common but supported here).\n * @param [includeNull=false] - If true, includes null nodes in the traversal.\n * @returns An array of callback results.\n */\n bfs(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType, includeNull = false) {\n startNode = this.ensureNode(startNode);\n if (!startNode) return [];\n const ans = [];\n if (iterationType === \"RECURSIVE\") {\n const queue = new Queue([\n startNode\n ]);\n const dfs = /* @__PURE__ */ __name((level) => {\n if (queue.length === 0) return;\n const current = queue.shift();\n ans.push(callback(current));\n if (includeNull) {\n if (current && this.isRealNodeOrNull(current.left)) queue.push(current.left);\n if (current && this.isRealNodeOrNull(current.right)) queue.push(current.right);\n } else {\n if (this.isRealNode(current.left)) queue.push(current.left);\n if (this.isRealNode(current.right)) queue.push(current.right);\n }\n dfs(level + 1);\n }, \"dfs\");\n dfs(0);\n } else {\n const queue = new Queue([startNode]);\n while (queue.length > 0) {\n const levelSize = queue.length;\n for (let i = 0; i < levelSize; i++) {\n const current = queue.shift();\n ans.push(callback(current));\n if (includeNull) {\n if (current && this.isRealNodeOrNull(current.left)) queue.push(current.left);\n if (current && this.isRealNodeOrNull(current.right)) queue.push(current.right);\n } else {\n if (this.isRealNode(current.left)) queue.push(current.left);\n if (this.isRealNode(current.right)) queue.push(current.right);\n }\n }\n }\n }\n return ans;\n }\n /**\n * Finds all leaf nodes in the tree.\n * @remarks Time O(N), visits every node. Space O(H) for recursive stack or O(N) for iterative queue.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each leaf node.\n * @param [startNode=this._root] - The node to start from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns An array of callback results.\n */\n leaves(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n startNode = this.ensureNode(startNode);\n const leaves = [];\n if (!this.isRealNode(startNode)) return [];\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (this.isLeaf(cur)) {\n leaves.push(callback(cur));\n }\n if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right)) return;\n if (this.isRealNode(cur.left)) dfs(cur.left);\n if (this.isRealNode(cur.right)) dfs(cur.right);\n }, \"dfs\");\n dfs(startNode);\n } else {\n const queue = new Queue([startNode]);\n while (queue.length > 0) {\n const cur = queue.shift();\n if (this.isRealNode(cur)) {\n if (this.isLeaf(cur)) {\n leaves.push(callback(cur));\n }\n if (this.isRealNode(cur.left)) queue.push(cur.left);\n if (this.isRealNode(cur.right)) queue.push(cur.right);\n }\n }\n }\n return leaves;\n }\n /**\n * Returns a 2D array of nodes, grouped by level.\n * @remarks Time O(N), visits every node. Space O(N) for the result array and the queue/stack.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.\n * @param [startNode=this._root] - The node to start from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @param [includeNull=false] - If true, includes null nodes.\n * @returns A 2D array of callback results.\n */\n listLevels(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType, includeNull = false) {\n startNode = this.ensureNode(startNode);\n const levelsNodes = [];\n if (!startNode) return levelsNodes;\n if (iterationType === \"RECURSIVE\") {\n const _recursive = /* @__PURE__ */ __name((node, level) => {\n if (!levelsNodes[level]) levelsNodes[level] = [];\n levelsNodes[level].push(callback(node));\n if (includeNull) {\n if (node && this.isRealNodeOrNull(node.left)) _recursive(node.left, level + 1);\n if (node && this.isRealNodeOrNull(node.right)) _recursive(node.right, level + 1);\n } else {\n if (node && node.left) _recursive(node.left, level + 1);\n if (node && node.right) _recursive(node.right, level + 1);\n }\n }, \"_recursive\");\n _recursive(startNode, 0);\n } else {\n const stack = [[startNode, 0]];\n while (stack.length > 0) {\n const head = stack.pop();\n const [node, level] = head;\n if (!levelsNodes[level]) levelsNodes[level] = [];\n levelsNodes[level].push(callback(node));\n if (includeNull) {\n if (node && this.isRealNodeOrNull(node.right)) stack.push([node.right, level + 1]);\n if (node && this.isRealNodeOrNull(node.left)) stack.push([node.left, level + 1]);\n } else {\n if (node && node.right) stack.push([node.right, level + 1]);\n if (node && node.left) stack.push([node.left, level + 1]);\n }\n }\n }\n return levelsNodes;\n }\n /**\n * Performs a Morris (threaded) traversal.\n * @remarks This traversal uses O(1) extra space (excluding the result array) by temporarily modifying the tree's right child pointers. Time O(N), as each node is visited a constant number of times. Space O(1) (excluding the `ans` array).\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.\n * @param [pattern='IN'] - The traversal order ('IN', 'PRE', 'POST').\n * @param [startNode=this._root] - The node to start from.\n * @returns An array of callback results.\n */\n morris(callback = this._DEFAULT_NODE_CALLBACK, pattern = \"IN\", startNode = this._root) {\n startNode = this.ensureNode(startNode);\n if (!startNode) return [];\n const ans = [];\n let cur = startNode;\n const _reverseEdge = /* @__PURE__ */ __name((node) => {\n let pre = null;\n let next = null;\n while (node) {\n next = node.right;\n node.right = pre;\n pre = node;\n node = next;\n }\n return pre;\n }, \"_reverseEdge\");\n const _printEdge = /* @__PURE__ */ __name((node) => {\n const tail = _reverseEdge(node);\n let cur2 = tail;\n while (cur2) {\n ans.push(callback(cur2));\n cur2 = cur2.right;\n }\n _reverseEdge(tail);\n }, \"_printEdge\");\n switch (pattern) {\n case \"IN\":\n while (cur) {\n if (cur.left) {\n const predecessor = this.getPredecessor(cur);\n if (!predecessor.right) {\n predecessor.right = cur;\n cur = cur.left;\n continue;\n } else {\n predecessor.right = null;\n }\n }\n ans.push(callback(cur));\n cur = cur.right;\n }\n break;\n case \"PRE\":\n while (cur) {\n if (cur.left) {\n const predecessor = this.getPredecessor(cur);\n if (!predecessor.right) {\n predecessor.right = cur;\n ans.push(callback(cur));\n cur = cur.left;\n continue;\n } else {\n predecessor.right = null;\n }\n } else {\n ans.push(callback(cur));\n }\n cur = cur.right;\n }\n break;\n case \"POST\":\n while (cur) {\n if (cur.left) {\n const predecessor = this.getPredecessor(cur);\n if (predecessor.right === null) {\n predecessor.right = cur;\n cur = cur.left;\n continue;\n } else {\n predecessor.right = null;\n _printEdge(cur.left);\n }\n }\n cur = cur.right;\n }\n _printEdge(startNode);\n break;\n }\n return ans;\n }\n /**\n * Clones the tree.\n * @remarks Time O(N * M), where N is the number of nodes and M is the tree size during insertion (due to `bfs` + `set`, and `set` is O(M)). Space O(N) for the new tree and the BFS queue.\n *\n * @returns A new, cloned instance of the tree.\n */\n clone() {\n const out = this._createInstance();\n this._clone(out);\n return out;\n }\n /**\n * Creates a new tree containing only the entries that satisfy the predicate.\n * @remarks Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion (O(N) iteration + O(M) `set` for each item). Space O(N) for the new tree.\n *\n * @param predicate - A function to test each [key, value] pair.\n * @param [thisArg] - `this` context for the predicate.\n * @returns A new, filtered tree.\n */\n filter(predicate, thisArg) {\n const out = this._createInstance();\n let i = 0;\n for (const [k, v] of this) if (predicate.call(thisArg, v, k, i++, this)) out.set([k, v]);\n return out;\n }\n /**\n * Creates a new tree by mapping each [key, value] pair to a new entry.\n * @remarks Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion. Space O(N) for the new tree.\n *\n * @template MK - New key type.\n * @template MV - New value type.\n * @template MR - New raw type.\n * @param cb - A function to map each [key, value] pair.\n * @param [options] - Options for the new tree.\n * @param [thisArg] - `this` context for the callback.\n * @returns A new, mapped tree.\n */\n map(cb, options, thisArg) {\n const out = this._createLike([], options);\n let i = 0;\n for (const [k, v] of this) out.set(cb.call(thisArg, v, k, i++, this));\n return out;\n }\n /**\n * Generates a string representation of the tree for visualization.\n * @remarks Time O(N), visits every node. Space O(N*H) or O(N^2) in the worst case, as the string width can grow significantly.\n *\n * @param [startNode=this._root] - The node to start printing from.\n * @param [options] - Options to control the output (e.g., show nulls).\n * @returns The string representation of the tree.\n */\n toVisual(startNode = this._root, options) {\n const opts = { isShowUndefined: false, isShowNull: true, isShowRedBlackNIL: false, ...options };\n startNode = this.ensureNode(startNode);\n let output = \"\";\n if (!startNode) return output;\n if (opts.isShowUndefined) output += `U for undefined\n`;\n if (opts.isShowNull) output += `N for null\n`;\n if (opts.isShowRedBlackNIL) output += `S for Sentinel Node(NIL)\n`;\n const display = /* @__PURE__ */ __name((root) => {\n const [lines] = this._displayAux(root, opts);\n let paragraph = \"\";\n for (const line of lines) {\n paragraph += line + \"\\n\";\n }\n output += paragraph;\n }, \"display\");\n display(startNode);\n return output;\n }\n /**\n * Prints a visual representation of the tree to the console.\n * @remarks Time O(N) (via `toVisual`). Space O(N*H) or O(N^2) (via `toVisual`).\n *\n * @param [options] - Options to control the output.\n * @param [startNode=this._root] - The node to start printing from.\n */\n print(options, startNode = this._root) {\n console.log(this.toVisual(startNode, options));\n }\n /**\n * (Protected) Core DFS implementation.\n * @remarks Time O(N), visits every node satisfying predicates. Space O(H) for call/explicit stack. O(N) worst-case.\n *\n * @template C - Callback type.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on nodes.\n * @param [pattern='IN'] - Traversal order.\n * @param [onlyOne=false] - Stop after first match.\n * @param [startNode=this._root] - Starting node.\n * @param [iterationType=this.iterationType] - Traversal method.\n * @param [includeNull=false] - Include nulls.\n * @param [shouldVisitLeft] - Predicate to traverse left.\n * @param [shouldVisitRight] - Predicate to traverse right.\n * @param [shouldVisitRoot] - Predicate to visit root.\n * @param [shouldProcessRoot] - Predicate to process root.\n * @returns Array of callback results.\n */\n _dfs(callback = this._DEFAULT_NODE_CALLBACK, pattern = \"IN\", onlyOne = false, startNode = this._root, iterationType = this.iterationType, includeNull = false, shouldVisitLeft = (node) => !!node, shouldVisitRight = (node) => !!node, shouldVisitRoot = (node) => {\n if (includeNull) return this.isRealNodeOrNull(node);\n return this.isRealNode(node);\n }, shouldProcessRoot = (node) => this.isRealNodeOrNull(node)) {\n startNode = this.ensureNode(startNode);\n if (!startNode) return [];\n const ans = [];\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((node) => {\n if (!shouldVisitRoot(node)) return;\n const visitLeft = /* @__PURE__ */ __name(() => {\n if (shouldVisitLeft(node) && (node == null ? void 0 : node.left) !== void 0) dfs(node == null ? void 0 : node.left);\n }, \"visitLeft\");\n const visitRight = /* @__PURE__ */ __name(() => {\n if (shouldVisitRight(node) && (node == null ? void 0 : node.right) !== void 0) dfs(node == null ? void 0 : node.right);\n }, \"visitRight\");\n switch (pattern) {\n case \"IN\":\n visitLeft();\n if (shouldProcessRoot(node)) {\n ans.push(callback(node));\n if (onlyOne) return;\n }\n visitRight();\n break;\n case \"PRE\":\n if (shouldProcessRoot(node)) {\n ans.push(callback(node));\n if (onlyOne) return;\n }\n visitLeft();\n visitRight();\n break;\n case \"POST\":\n visitLeft();\n visitRight();\n if (shouldProcessRoot(node)) {\n ans.push(callback(node));\n if (onlyOne) return;\n }\n break;\n }\n }, \"dfs\");\n dfs(startNode);\n } else {\n const stack = [{ opt: 0 /* VISIT */, node: startNode }];\n const pushLeft = /* @__PURE__ */ __name((cur) => {\n var _a;\n if (shouldVisitLeft(cur.node)) stack.push({ opt: 0 /* VISIT */, node: (_a = cur.node) == null ? void 0 : _a.left });\n }, \"pushLeft\");\n const pushRight = /* @__PURE__ */ __name((cur) => {\n var _a;\n if (shouldVisitRight(cur.node)) stack.push({ opt: 0 /* VISIT */, node: (_a = cur.node) == null ? void 0 : _a.right });\n }, \"pushRight\");\n const pushRoot = /* @__PURE__ */ __name((cur) => {\n if (shouldVisitRoot(cur.node)) stack.push({ opt: 1 /* PROCESS */, node: cur.node });\n }, \"pushRoot\");\n while (stack.length > 0) {\n const cur = stack.pop();\n if (cur === void 0) continue;\n if (!shouldVisitRoot(cur.node)) continue;\n if (cur.opt === 1 /* PROCESS */) {\n if (shouldProcessRoot(cur.node) && cur.node !== void 0) {\n ans.push(callback(cur.node));\n if (onlyOne) return ans;\n }\n } else {\n switch (pattern) {\n case \"IN\":\n pushRight(cur);\n pushRoot(cur);\n pushLeft(cur);\n break;\n case \"PRE\":\n pushRight(cur);\n pushLeft(cur);\n pushRoot(cur);\n break;\n case \"POST\":\n pushRoot(cur);\n pushRight(cur);\n pushLeft(cur);\n break;\n }\n }\n }\n }\n return ans;\n }\n /**\n * (Protected) Gets the iterator for the tree (default in-order).\n * @remarks Time O(N) for full iteration. O(H) to get the first element. Space O(H) for the iterative stack. O(H) for recursive stack.\n *\n * @param [node=this._root] - The node to start iteration from.\n * @returns An iterator for [key, value] pairs.\n */\n *_getIterator(node = this._root) {\n if (!node) return;\n if (this.iterationType === \"ITERATIVE\") {\n const stack = [];\n let current = node;\n while (current || stack.length > 0) {\n while (this.isRealNode(current)) {\n stack.push(current);\n current = current.left;\n }\n current = stack.pop();\n if (this.isRealNode(current)) {\n yield [current.key, current.value];\n current = current.right;\n }\n }\n } else {\n if (node.left && this.isRealNode(node)) {\n yield* this[Symbol.iterator](node.left);\n }\n yield [node.key, node.value];\n if (node.right && this.isRealNode(node)) {\n yield* this[Symbol.iterator](node.right);\n }\n }\n }\n /**\n * (Protected) Snapshots the current tree's configuration options.\n * @remarks Time O(1)\n *\n * @template TK, TV, TR - Generic types for the options.\n * @returns The options object.\n */\n _snapshotOptions() {\n return {\n iterationType: this.iterationType,\n toEntryFn: this.toEntryFn,\n isMapMode: this.isMapMode,\n isDuplicate: this.isDuplicate\n };\n }\n /**\n * (Protected) Creates a new, empty instance of the same tree constructor.\n * @remarks Time O(1)\n *\n * @template TK, TV, TR - Generic types for the new instance.\n * @param [options] - Options for the new tree.\n * @returns A new, empty tree.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Protected) Creates a new instance of the same tree constructor, potentially with different generic types.\n * @remarks Time O(N) (or as per constructor) due to processing the iterable.\n *\n * @template TK, TV, TR - Generic types for the new instance.\n * @param [iter=[]] - An iterable to populate the new tree.\n * @param [options] - Options for the new tree.\n * @returns A new tree.\n */\n _createLike(iter = [], options) {\n const Ctor = this.constructor;\n return new Ctor(iter, { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Protected) Converts a key, node, or entry into a standardized [node, value] tuple.\n * @remarks Time O(1)\n *\n * @param keyNodeOrEntry - The input item.\n * @param [value] - An optional value (used if input is just a key).\n * @returns A tuple of [node, value].\n */\n _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value) {\n if (keyNodeOrEntry === void 0) return [void 0, void 0];\n if (keyNodeOrEntry === null) return [null, void 0];\n if (this.isNode(keyNodeOrEntry)) return [keyNodeOrEntry, value];\n if (this.isEntry(keyNodeOrEntry)) {\n const [key, entryValue] = keyNodeOrEntry;\n if (key === void 0) return [void 0, void 0];\n else if (key === null) return [null, void 0];\n const finalValue = value != null ? value : entryValue;\n return [this.createNode(key, finalValue), finalValue];\n }\n return [this.createNode(keyNodeOrEntry, value), value];\n }\n /**\n * (Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.\n * @remarks Time O(N * M) (O(N) BFS + O(M) `set` for each node).\n *\n * @param cloned - The new, empty tree instance to populate.\n */\n _clone(cloned) {\n this.bfs(\n (node) => {\n if (node === null) cloned.set(null);\n else {\n cloned.set([node.key, node.value]);\n }\n },\n this._root,\n this.iterationType,\n true\n // Include nulls\n );\n }\n /**\n * (Protected) Recursive helper for `toVisual`.\n * @remarks Time O(N), Space O(N*H) or O(N^2)\n *\n * @param node - The current node.\n * @param options - Print options.\n * @returns Layout information for this subtree.\n */\n _displayAux(node, options) {\n const { isShowNull, isShowUndefined, isShowRedBlackNIL } = options;\n const emptyDisplayLayout = [[\"\\u2500\"], 1, 0, 0];\n if (node === null && !isShowNull) {\n return emptyDisplayLayout;\n } else if (node === void 0 && !isShowUndefined) {\n return emptyDisplayLayout;\n } else if (this.isNIL(node) && !isShowRedBlackNIL) {\n return emptyDisplayLayout;\n } else if (node !== null && node !== void 0) {\n const key = node.key, line = this.isNIL(node) ? \"S\" : String(key), width = line.length;\n return _buildNodeDisplay(\n line,\n width,\n this._displayAux(node.left, options),\n this._displayAux(node.right, options)\n );\n } else {\n const line = node === void 0 ? \"U\" : \"N\", width = line.length;\n return _buildNodeDisplay(line, width, [[\"\"], 1, 0, 0], [[\"\"], 1, 0, 0]);\n }\n function _buildNodeDisplay(line, width, left, right) {\n const [leftLines, leftWidth, leftHeight, leftMiddle] = left;\n const [rightLines, rightWidth, rightHeight, rightMiddle] = right;\n const firstLine = \" \".repeat(Math.max(0, leftMiddle + 1)) + \"_\".repeat(Math.max(0, leftWidth - leftMiddle - 1)) + line + \"_\".repeat(Math.max(0, rightMiddle)) + \" \".repeat(Math.max(0, rightWidth - rightMiddle));\n const secondLine = (leftHeight > 0 ? \" \".repeat(leftMiddle) + \"/\" + \" \".repeat(leftWidth - leftMiddle - 1) : \" \".repeat(leftWidth)) + \" \".repeat(width) + (rightHeight > 0 ? \" \".repeat(rightMiddle) + \"\\\\\" + \" \".repeat(rightWidth - rightMiddle - 1) : \" \".repeat(rightWidth));\n const mergedLines = [firstLine, secondLine];\n for (let i = 0; i < Math.max(leftHeight, rightHeight); i++) {\n const leftLine = i < leftHeight ? leftLines[i] : \" \".repeat(leftWidth);\n const rightLine = i < rightHeight ? rightLines[i] : \" \".repeat(rightWidth);\n mergedLines.push(leftLine + \" \".repeat(width) + rightLine);\n }\n return [\n mergedLines,\n leftWidth + width + rightWidth,\n Math.max(leftHeight, rightHeight) + 2,\n leftWidth + Math.floor(width / 2)\n ];\n }\n }\n /**\n * (Protected) Swaps the key/value properties of two nodes.\n * @remarks Time O(1)\n *\n * @param srcNode - The source node.\n * @param destNode - The destination node.\n * @returns The `destNode` (now holding `srcNode`'s properties).\n */\n _swapProperties(srcNode, destNode) {\n srcNode = this.ensureNode(srcNode);\n destNode = this.ensureNode(destNode);\n if (srcNode && destNode) {\n const { key, value } = destNode;\n const tempNode = this.createNode(key, value);\n if (tempNode) {\n destNode.key = srcNode.key;\n if (!this._isMapMode) destNode.value = srcNode.value;\n srcNode.key = tempNode.key;\n if (!this._isMapMode) srcNode.value = tempNode.value;\n }\n return destNode;\n }\n return void 0;\n }\n /**\n * (Protected) Replaces a node in the tree with a new node, maintaining children and parent links.\n * @remarks Time O(1)\n *\n * @param oldNode - The node to be replaced.\n * @param newNode - The node to insert.\n * @returns The `newNode`.\n */\n _replaceNode(oldNode, newNode) {\n if (oldNode.parent) {\n if (oldNode.parent.left === oldNode) {\n oldNode.parent.left = newNode;\n } else if (oldNode.parent.right === oldNode) {\n oldNode.parent.right = newNode;\n }\n }\n newNode.left = oldNode.left;\n newNode.right = oldNode.right;\n newNode.parent = oldNode.parent;\n if (this._root === oldNode) {\n this._setRoot(newNode);\n }\n return newNode;\n }\n /**\n * (Protected) Sets the root node and clears its parent reference.\n * @remarks Time O(1)\n *\n * @param v - The node to set as root.\n */\n _setRoot(v) {\n if (v) {\n v.parent = void 0;\n }\n this._root = v;\n }\n _ensurePredicate(keyNodeEntryOrPredicate) {\n if (keyNodeEntryOrPredicate === null || keyNodeEntryOrPredicate === void 0)\n return (node) => node ? false : false;\n if (this._isPredicate(keyNodeEntryOrPredicate)) return keyNodeEntryOrPredicate;\n if (this.isRealNode(keyNodeEntryOrPredicate))\n return (node) => node === keyNodeEntryOrPredicate;\n if (this.isEntry(keyNodeEntryOrPredicate)) {\n const [key] = keyNodeEntryOrPredicate;\n return (node) => {\n if (!node) return false;\n return node.key === key;\n };\n }\n return (node) => {\n if (!node) return false;\n return node.key === keyNodeEntryOrPredicate;\n };\n }\n /**\n * (Protected) Checks if an item is a predicate function.\n * @remarks Time O(1)\n *\n * @param p - The item to check.\n * @returns True if it's a function.\n */\n _isPredicate(p) {\n return typeof p === \"function\";\n }\n /**\n * (Protected) Extracts the key from a key, node, or entry.\n * @remarks Time O(1)\n *\n * @param keyNodeOrEntry - The item.\n * @returns The extracted key.\n */\n _extractKey(keyNodeOrEntry) {\n if (keyNodeOrEntry === null) return null;\n if (keyNodeOrEntry === void 0) return;\n if (keyNodeOrEntry === this._NIL) return;\n if (this.isNode(keyNodeOrEntry)) return keyNodeOrEntry.key;\n if (this.isEntry(keyNodeOrEntry)) return keyNodeOrEntry[0];\n return keyNodeOrEntry;\n }\n /**\n * (Protected) Sets a value in the external store (Map mode).\n * @remarks Time O(1) (average for Map.set).\n *\n * @param key - The key.\n * @param value - The value.\n * @returns True if successful.\n */\n _setValue(key, value) {\n if (key === null || key === void 0) return false;\n const node = this._store.get(key);\n if (!node) return false;\n node.value = value;\n return true;\n }\n /**\n * (Protected) Clears all nodes from the tree.\n * @remarks Time O(1)\n */\n _clearNodes() {\n this._setRoot(void 0);\n this._size = 0;\n }\n /**\n * (Protected) Clears all values from the external store.\n * @remarks Time O(N)\n */\n _clearValues() {\n this._store.clear();\n }\n};\n__name(_BinaryTree, \"BinaryTree\");\nvar BinaryTree = _BinaryTree;\n\n// src/data-structures/binary-tree/bst.ts\nvar _BSTNode = class _BSTNode {\n /**\n * Creates an instance of BSTNode.\n * @remarks Time O(1), Space O(1)\n *\n * @param key - The key of the node.\n * @param [value] - The value associated with the key.\n */\n constructor(key, value) {\n __publicField(this, \"key\");\n __publicField(this, \"value\");\n __publicField(this, \"parent\");\n __publicField(this, \"_left\");\n __publicField(this, \"_right\");\n __publicField(this, \"_height\", 0);\n __publicField(this, \"_color\", \"BLACK\");\n __publicField(this, \"_count\", 1);\n this.key = key;\n this.value = value;\n }\n /**\n * Gets the left child of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The left child.\n */\n get left() {\n return this._left;\n }\n /**\n * Sets the left child of the node and updates its parent reference.\n * @remarks Time O(1), Space O(1)\n *\n * @param v - The node to set as the left child.\n */\n set left(v) {\n if (v) v.parent = this;\n this._left = v;\n }\n /**\n * Gets the right child of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The right child.\n */\n get right() {\n return this._right;\n }\n /**\n * Sets the right child of the node and updates its parent reference.\n * @remarks Time O(1), Space O(1)\n *\n * @param v - The node to set as the right child.\n */\n set right(v) {\n if (v) v.parent = this;\n this._right = v;\n }\n /**\n * Gets the height of the node (used in self-balancing trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The height.\n */\n get height() {\n return this._height;\n }\n /**\n * Sets the height of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new height.\n */\n set height(value) {\n this._height = value;\n }\n /**\n * Gets the color of the node (used in Red-Black trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The node's color.\n */\n get color() {\n return this._color;\n }\n /**\n * Sets the color of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new color.\n */\n set color(value) {\n this._color = value;\n }\n /**\n * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The subtree node count.\n */\n get count() {\n return this._count;\n }\n /**\n * Sets the count of nodes in the subtree.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new count.\n */\n set count(value) {\n this._count = value;\n }\n /**\n * Gets the position of the node relative to its parent.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').\n */\n get familyPosition() {\n if (!this.parent) {\n return this.left || this.right ? \"ROOT\" : \"ISOLATED\";\n }\n if (this.parent.left === this) {\n return this.left || this.right ? \"ROOT_LEFT\" : \"LEFT\";\n } else if (this.parent.right === this) {\n return this.left || this.right ? \"ROOT_RIGHT\" : \"RIGHT\";\n }\n return \"MAL_NODE\";\n }\n};\n__name(_BSTNode, \"BSTNode\");\nvar BSTNode = _BSTNode;\nvar _BST = class _BST extends BinaryTree {\n /**\n * Creates an instance of BST.\n * @remarks Time O(N log N) or O(N^2) depending on `isBalanceAdd` in `addMany` and input order. Space O(N).\n *\n * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.\n * @param [options] - Configuration options for the BST, including comparator.\n */\n constructor(keysNodesEntriesOrRaws = [], options) {\n super([], options);\n __publicField(this, \"_root\");\n /**\n * The comparator function used to determine the order of keys in the tree.\n \n * @remarks Time O(1) Space O(1)\n */\n __publicField(this, \"_comparator\");\n if (options) {\n if (\"comparator\" in options && options.comparator !== void 0) {\n this._comparator = options.comparator;\n } else {\n this._comparator = this._createDefaultComparator();\n }\n } else {\n this._comparator = this._createDefaultComparator();\n }\n if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);\n }\n /**\n * Gets the root node of the tree.\n * @remarks Time O(1)\n *\n * @returns The root node.\n */\n get root() {\n return this._root;\n }\n /**\n * Gets the comparator function used by the tree.\n * @remarks Time O(1)\n *\n * @returns The comparator function.\n */\n get comparator() {\n return this._comparator;\n }\n /**\n * (Protected) Creates a new BST node.\n * @remarks Time O(1), Space O(1)\n *\n * @param key - The key for the new node.\n * @param [value] - The value for the new node (used if not in Map mode).\n * @returns The newly created BSTNode.\n */\n createNode(key, value) {\n return new BSTNode(key, value);\n }\n /**\n * Ensures the input is a node. If it's a key or entry, it searches for the node.\n * @remarks Time O(log N) (height of the tree), O(N) worst-case.\n *\n * @param keyNodeOrEntry - The item to resolve to a node.\n * @param [iterationType=this.iterationType] - The traversal method to use if searching.\n * @returns The resolved node, or undefined if not found.\n */\n ensureNode(keyNodeOrEntry, iterationType = this.iterationType) {\n var _a;\n return (_a = super.ensureNode(keyNodeOrEntry, iterationType)) != null ? _a : void 0;\n }\n /**\n * Checks if the given item is a `BSTNode` instance.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeOrEntry - The item to check.\n * @returns True if it's a BSTNode, false otherwise.\n */\n isNode(keyNodeOrEntry) {\n return keyNodeOrEntry instanceof BSTNode;\n }\n /**\n * Checks if the given key is valid (comparable).\n * @remarks Time O(1)\n *\n * @param key - The key to validate.\n * @returns True if the key is valid, false otherwise.\n */\n isValidKey(key) {\n return isComparable(key);\n }\n /**\n * Performs a Depth-First Search (DFS) traversal.\n * @remarks Time O(N), visits every node. Space O(log N) for the call/explicit stack. O(N) worst-case.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.\n * @param [pattern='IN'] - The traversal order ('IN', 'PRE', 'POST').\n * @param [onlyOne=false] - If true, stops after the first callback.\n * @param [startNode=this._root] - The node to start from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns An array of callback results.\n */\n dfs(callback = this._DEFAULT_NODE_CALLBACK, pattern = \"IN\", onlyOne = false, startNode = this._root, iterationType = this.iterationType) {\n return super.dfs(callback, pattern, onlyOne, startNode, iterationType);\n }\n /**\n * Performs a Breadth-First Search (BFS) or Level-Order traversal.\n * @remarks Time O(N), visits every node. Space O(N) in the worst case for the queue.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.\n * @param [startNode=this._root] - The node to start from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns An array of callback results.\n */\n bfs(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n return super.bfs(callback, startNode, iterationType, false);\n }\n /**\n * Returns a 2D array of nodes, grouped by level.\n * @remarks Time O(N), visits every node. Space O(N) for the result array and the queue/stack.\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.\n * @param [startNode=this._root] - The node to start from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns A 2D array of callback results.\n */\n listLevels(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n return super.listLevels(callback, startNode, iterationType, false);\n }\n /**\n * Gets the first node matching a predicate.\n * @remarks Time O(log N) if searching by key, O(N) if searching by predicate. Space O(log N) or O(N).\n *\n * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.\n * @param [startNode=this._root] - The node to start the search from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns The first matching node, or undefined if not found.\n */\n getNode(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {\n var _a, _b;\n if (keyNodeEntryOrPredicate === null || keyNodeEntryOrPredicate === void 0) return void 0;\n if (this._isPredicate(keyNodeEntryOrPredicate)) {\n return (_a = this.getNodes(keyNodeEntryOrPredicate, true, startNode, iterationType)[0]) != null ? _a : void 0;\n }\n if (keyNodeEntryOrPredicate instanceof Range) {\n return (_b = this.getNodes(\n keyNodeEntryOrPredicate,\n true,\n startNode,\n iterationType\n )[0]) != null ? _b : void 0;\n }\n let targetKey;\n if (this.isNode(keyNodeEntryOrPredicate)) {\n targetKey = keyNodeEntryOrPredicate.key;\n } else if (this.isEntry(keyNodeEntryOrPredicate)) {\n const k = keyNodeEntryOrPredicate[0];\n if (k === null || k === void 0) return void 0;\n targetKey = k;\n } else {\n targetKey = keyNodeEntryOrPredicate;\n }\n const start = this.ensureNode(startNode);\n if (!start) return void 0;\n const NIL = this._NIL;\n let cur = start;\n const cmpFn = this._comparator;\n while (cur && cur !== NIL) {\n const c = cmpFn(targetKey, cur.key);\n if (c === 0) return cur;\n cur = c < 0 ? cur._left : cur._right;\n }\n return void 0;\n }\n /**\n * Searches the tree for nodes matching a predicate, key, or range.\n * @remarks This is an optimized search for a BST. If searching by key or range, it prunes branches.\n * Time O(H + M) for key/range search (H=height, M=matches). O(N) for predicate search.\n * Space O(log N) for the stack.\n *\n * @template C - The type of the callback function.\n * @param keyNodeEntryOrPredicate - The key, node, entry, predicate, or range to search for.\n * @param [onlyOne=false] - If true, stops after finding the first match.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on matching nodes.\n * @param [startNode=this._root] - The node to start the search from.\n * @param [iterationType=this.iterationType] - Whether to use 'RECURSIVE' or 'ITERATIVE' search.\n * @returns An array of results from the callback function for each matching node.\n */\n search(keyNodeEntryOrPredicate, onlyOne = false, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n if (keyNodeEntryOrPredicate === void 0) return [];\n if (keyNodeEntryOrPredicate === null) return [];\n startNode = this.ensureNode(startNode);\n if (!startNode) return [];\n const isRange = this.isRange(keyNodeEntryOrPredicate);\n const isPred = !isRange && this._isPredicate(keyNodeEntryOrPredicate);\n if (!isRange && !isPred) {\n let targetKey;\n if (this.isNode(keyNodeEntryOrPredicate)) {\n targetKey = keyNodeEntryOrPredicate.key;\n } else if (this.isEntry(keyNodeEntryOrPredicate)) {\n const k = keyNodeEntryOrPredicate[0];\n if (k !== null && k !== void 0) targetKey = k;\n } else {\n targetKey = keyNodeEntryOrPredicate;\n }\n if (targetKey === void 0) return [];\n const NIL = this._NIL;\n const cmpFn = this._comparator;\n let cur = startNode;\n while (cur && cur !== NIL) {\n const c = cmpFn(targetKey, cur.key);\n if (c === 0) return [callback(cur)];\n cur = c < 0 ? cur._left : cur._right;\n }\n return [];\n }\n let predicate;\n if (isRange) {\n predicate = /* @__PURE__ */ __name((node) => {\n if (!node) return false;\n return keyNodeEntryOrPredicate.isInRange(node.key, this._comparator);\n }, \"predicate\");\n } else {\n predicate = this._ensurePredicate(keyNodeEntryOrPredicate);\n }\n const shouldVisitLeft = /* @__PURE__ */ __name((cur) => {\n if (!cur) return false;\n if (!this.isRealNode(cur.left)) return false;\n if (isRange) {\n const range = keyNodeEntryOrPredicate;\n const leftS = range.low;\n const leftI = range.includeLow;\n return leftI && this._compare(cur.key, leftS) >= 0 || !leftI && this._compare(cur.key, leftS) > 0;\n }\n if (!isRange && !this._isPredicate(keyNodeEntryOrPredicate)) {\n const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);\n return benchmarkKey !== null && benchmarkKey !== void 0 && this._compare(cur.key, benchmarkKey) > 0;\n }\n return true;\n }, \"shouldVisitLeft\");\n const shouldVisitRight = /* @__PURE__ */ __name((cur) => {\n if (!cur) return false;\n if (!this.isRealNode(cur.right)) return false;\n if (isRange) {\n const range = keyNodeEntryOrPredicate;\n const rightS = range.high;\n const rightI = range.includeHigh;\n return rightI && this._compare(cur.key, rightS) <= 0 || !rightI && this._compare(cur.key, rightS) < 0;\n }\n if (!isRange && !this._isPredicate(keyNodeEntryOrPredicate)) {\n const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);\n return benchmarkKey !== null && benchmarkKey !== void 0 && this._compare(cur.key, benchmarkKey) < 0;\n }\n return true;\n }, \"shouldVisitRight\");\n return super._dfs(\n callback,\n \"IN\",\n // In-order is efficient for range/key search\n onlyOne,\n startNode,\n iterationType,\n false,\n shouldVisitLeft,\n shouldVisitRight,\n () => true,\n // shouldVisitRoot (always visit)\n (cur) => !!cur && predicate(cur)\n // shouldProcessRoot (only process if predicate matches)\n );\n }\n /**\n * Performs an optimized search for nodes within a given key range.\n * @remarks Time O(H + M), where H is tree height and M is the number of matches.\n *\n * @template C - The type of the callback function.\n * @param range - A `Range` object or a `[low, high]` tuple.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on matching nodes.\n * @param [startNode=this._root] - The node to start the search from.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns An array of callback results.\n */\n rangeSearch(range, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {\n const searchRange = range instanceof Range ? range : new Range(range[0], range[1]);\n return this.search(searchRange, false, callback, startNode, iterationType);\n }\n /**\n * Adds a new node to the BST based on key comparison.\n * @remarks Time O(log N), where H is tree height. O(N) worst-case (unbalanced tree), O(log N) average. Space O(1).\n *\n * @param keyNodeOrEntry - The key, node, or entry to set.\n * @param [value] - The value, if providing just a key.\n * @returns True if the addition was successful, false otherwise.\n */\n set(keyNodeOrEntry, value) {\n const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);\n if (newNode === void 0) return false;\n if (this._root === void 0) {\n this._setRoot(newNode);\n if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);\n this._size++;\n return true;\n }\n let current = this._root;\n while (current !== void 0) {\n if (this._compare(current.key, newNode.key) === 0) {\n this._replaceNode(current, newNode);\n if (this._isMapMode && this.isRealNode(newNode)) this._store.set(current.key, newNode);\n return true;\n } else if (this._compare(current.key, newNode.key) > 0) {\n if (current.left === void 0) {\n current.left = newNode;\n if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);\n this._size++;\n return true;\n }\n if (current.left !== null) current = current.left;\n } else {\n if (current.right === void 0) {\n current.right = newNode;\n if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);\n this._size++;\n return true;\n }\n if (current.right !== null) current = current.right;\n }\n }\n return false;\n }\n /**\n * Adds multiple items to the tree.\n * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced set).\n * If false, adds items one by one. Time O(N * H), which is O(N^2) worst-case.\n * Space O(N) for sorting and recursion/iteration stack.\n *\n * @param keysNodesEntriesOrRaws - An iterable of items to set.\n * @param [values] - An optional parallel iterable of values.\n * @param [isBalanceAdd=true] - If true, builds a balanced tree from the items.\n * @param [iterationType=this.iterationType] - The traversal method for balanced set (recursive or iterative).\n * @returns An array of booleans indicating the success of each individual `set` operation.\n */\n setMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {\n const inserted = [];\n const valuesIterator = values == null ? void 0 : values[Symbol.iterator]();\n if (!isBalanceAdd) {\n for (let kve of keysNodesEntriesOrRaws) {\n const val = valuesIterator == null ? void 0 : valuesIterator.next().value;\n if (this.isRaw(kve)) kve = this._toEntryFn(kve);\n inserted.push(this.set(kve, val));\n }\n return inserted;\n }\n const realBTNExemplars = [];\n let i = 0;\n for (const kve of keysNodesEntriesOrRaws) {\n realBTNExemplars.push({ key: kve, value: valuesIterator == null ? void 0 : valuesIterator.next().value, orgIndex: i++ });\n }\n const sorted = realBTNExemplars.sort(({ key: a }, { key: b }) => {\n let keyA, keyB;\n if (this.isRaw(a)) keyA = this._toEntryFn(a)[0];\n else if (this.isEntry(a)) keyA = a[0];\n else if (this.isRealNode(a)) keyA = a.key;\n else keyA = a;\n if (this.isRaw(b)) keyB = this._toEntryFn(b)[0];\n else if (this.isEntry(b)) keyB = b[0];\n else if (this.isRealNode(b)) keyB = b.key;\n else keyB = b;\n if (keyA != null && keyB != null) return this._compare(keyA, keyB);\n return 0;\n });\n const _dfs = /* @__PURE__ */ __name((arr) => {\n if (arr.length === 0) return;\n const mid = Math.floor((arr.length - 1) / 2);\n const { key, value, orgIndex } = arr[mid];\n if (this.isRaw(key)) {\n const entry = this._toEntryFn(key);\n inserted[orgIndex] = this.set(entry);\n } else {\n inserted[orgIndex] = this.set(key, value);\n }\n _dfs(arr.slice(0, mid));\n _dfs(arr.slice(mid + 1));\n }, \"_dfs\");\n const _iterate = /* @__PURE__ */ __name(() => {\n const n = sorted.length;\n const stack = [[0, n - 1]];\n while (stack.length > 0) {\n const popped = stack.pop();\n if (!popped) continue;\n const [l, r] = popped;\n if (l > r) continue;\n const m = l + Math.floor((r - l) / 2);\n const { key, value, orgIndex } = sorted[m];\n if (this.isRaw(key)) {\n const entry = this._toEntryFn(key);\n inserted[orgIndex] = this.set(entry);\n } else {\n inserted[orgIndex] = this.set(key, value);\n }\n stack.push([m + 1, r]);\n stack.push([l, m - 1]);\n }\n }, \"_iterate\");\n if (iterationType === \"RECURSIVE\") _dfs(sorted);\n else _iterate();\n return inserted;\n }\n ceiling(keyNodeEntryOrPredicate, callback = this._DEFAULT_NODE_CALLBACK, iterationType) {\n let actualCallback = void 0;\n let actualIterationType = this.iterationType;\n if (typeof callback === \"string\") {\n actualIterationType = callback;\n } else if (callback) {\n actualCallback = callback;\n if (iterationType) {\n actualIterationType = iterationType;\n }\n }\n const node = this._bound(keyNodeEntryOrPredicate, true, actualIterationType);\n if (!actualCallback) {\n return node == null ? void 0 : node.key;\n }\n return node ? actualCallback(node) : void 0;\n }\n higher(keyNodeEntryOrPredicate, callback = this._DEFAULT_NODE_CALLBACK, iterationType) {\n let actualCallback = void 0;\n let actualIterationType = this.iterationType;\n if (typeof callback === \"string\") {\n actualIterationType = callback;\n } else if (callback) {\n actualCallback = callback;\n if (iterationType) {\n actualIterationType = iterationType;\n }\n }\n const node = this._bound(keyNodeEntryOrPredicate, false, actualIterationType);\n if (!actualCallback) {\n return node == null ? void 0 : node.key;\n }\n return node ? actualCallback(node) : void 0;\n }\n floor(keyNodeEntryOrPredicate, callback = this._DEFAULT_NODE_CALLBACK, iterationType) {\n if (keyNodeEntryOrPredicate === null || keyNodeEntryOrPredicate === void 0) {\n if (typeof callback === \"string\" || !callback) {\n return void 0;\n }\n return void 0;\n }\n let actualCallback = void 0;\n let actualIterationType = this.iterationType;\n if (typeof callback === \"string\") {\n actualIterationType = callback;\n } else if (callback) {\n actualCallback = callback;\n if (iterationType) {\n actualIterationType = iterationType;\n }\n }\n if (this._isPredicate(keyNodeEntryOrPredicate)) {\n const node = this._floorByPredicate(keyNodeEntryOrPredicate, actualIterationType);\n if (!actualCallback) {\n return node == null ? void 0 : node.key;\n }\n return node ? actualCallback(node) : void 0;\n }\n let targetKey;\n if (this.isNode(keyNodeEntryOrPredicate)) {\n targetKey = keyNodeEntryOrPredicate.key;\n } else if (this.isEntry(keyNodeEntryOrPredicate)) {\n const key = keyNodeEntryOrPredicate[0];\n if (key === null || key === void 0) {\n if (typeof callback === \"string\" || !callback) {\n return void 0;\n }\n return void 0;\n }\n targetKey = key;\n } else {\n targetKey = keyNodeEntryOrPredicate;\n }\n if (targetKey !== void 0) {\n const node = this._floorByKey(targetKey, actualIterationType);\n if (!actualCallback) {\n return node == null ? void 0 : node.key;\n }\n return node ? actualCallback(node) : void 0;\n }\n if (typeof callback === \"string\" || !callback) {\n return void 0;\n }\n return void 0;\n }\n lower(keyNodeEntryOrPredicate, callback, iterationType) {\n if (keyNodeEntryOrPredicate === null || keyNodeEntryOrPredicate === void 0) {\n if (typeof callback === \"string\" || !callback) {\n return void 0;\n }\n return void 0;\n }\n let actualCallback = void 0;\n let actualIterationType = this.iterationType;\n if (typeof callback === \"string\") {\n actualIterationType = callback;\n } else if (callback) {\n actualCallback = callback;\n if (iterationType) {\n actualIterationType = iterationType;\n }\n }\n if (this._isPredicate(keyNodeEntryOrPredicate)) {\n const node = this._lowerByPredicate(keyNodeEntryOrPredicate, actualIterationType);\n if (!actualCallback) {\n return node == null ? void 0 : node.key;\n }\n return node ? actualCallback(node) : void 0;\n }\n let targetKey;\n if (this.isNode(keyNodeEntryOrPredicate)) {\n targetKey = keyNodeEntryOrPredicate.key;\n } else if (this.isEntry(keyNodeEntryOrPredicate)) {\n const key = keyNodeEntryOrPredicate[0];\n if (key === null || key === void 0) {\n if (typeof callback === \"string\" || !callback) {\n return void 0;\n }\n return void 0;\n }\n targetKey = key;\n } else {\n targetKey = keyNodeEntryOrPredicate;\n }\n if (targetKey !== void 0) {\n const node = this._lowerByKey(targetKey, actualIterationType);\n if (!actualCallback) {\n return node == null ? void 0 : node.key;\n }\n return node ? actualCallback(node) : void 0;\n }\n if (typeof callback === \"string\" || !callback) {\n return void 0;\n }\n return void 0;\n }\n /**\n * Traverses the tree and returns nodes that are lesser or greater than a target node.\n * @remarks Time O(N), as it performs a full traversal. Space O(log N) or O(N).\n *\n * @template C - The type of the callback function.\n * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on matching nodes.\n * @param [lesserOrGreater=-1] - -1 for lesser, 1 for greater, 0 for equal.\n * @param [targetNode=this._root] - The node to compare against.\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns An array of callback results.\n */\n lesserOrGreaterTraverse(callback = this._DEFAULT_NODE_CALLBACK, lesserOrGreater = -1, targetNode = this._root, iterationType = this.iterationType) {\n const targetNodeEnsured = this.ensureNode(targetNode);\n const ans = [];\n if (!this._root || !targetNodeEnsured) return ans;\n const targetKey = targetNodeEnsured.key;\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n const compared = this._compare(cur.key, targetKey);\n if (Math.sign(compared) == lesserOrGreater) ans.push(callback(cur));\n if (this.isRealNode(cur.left)) dfs(cur.left);\n if (this.isRealNode(cur.right)) dfs(cur.right);\n }, \"dfs\");\n dfs(this._root);\n return ans;\n } else {\n const queue = new Queue([this._root]);\n while (queue.length > 0) {\n const cur = queue.shift();\n if (this.isRealNode(cur)) {\n const compared = this._compare(cur.key, targetKey);\n if (Math.sign(compared) == lesserOrGreater) ans.push(callback(cur));\n if (this.isRealNode(cur.left)) queue.push(cur.left);\n if (this.isRealNode(cur.right)) queue.push(cur.right);\n }\n }\n return ans;\n }\n }\n /**\n * Rebuilds the tree to be perfectly balanced.\n * @remarks Time O(N) (O(N) for DFS, O(N) for sorted build). Space O(N) for node array and recursion stack.\n *\n * @param [iterationType=this.iterationType] - The traversal method for the initial node export.\n * @returns True if successful, false if the tree was empty.\n */\n perfectlyBalance(iterationType = this.iterationType) {\n const nodes = this.dfs((node) => node, \"IN\", false, this._root, iterationType);\n const n = nodes.length;\n this._clearNodes();\n if (n === 0) return false;\n const build = /* @__PURE__ */ __name((l, r, parent) => {\n if (l > r) return void 0;\n const m = l + (r - l >> 1);\n const root = nodes[m];\n const leftChild = build(l, m - 1, root);\n const rightChild = build(m + 1, r, root);\n root.left = leftChild;\n root.right = rightChild;\n root.parent = parent;\n return root;\n }, \"build\");\n const newRoot = build(0, n - 1, void 0);\n this._setRoot(newRoot);\n this._size = n;\n return true;\n }\n /**\n * Checks if the tree meets the AVL balance condition (height difference <= 1).\n * @remarks Time O(N), as it must visit every node to compute height. Space O(log N) for recursion or O(N) for iterative map.\n *\n * @param [iterationType=this.iterationType] - The traversal method.\n * @returns True if the tree is AVL balanced, false otherwise.\n */\n isAVLBalanced(iterationType = this.iterationType) {\n if (!this._root) return true;\n let balanced = true;\n if (iterationType === \"RECURSIVE\") {\n const _height = /* @__PURE__ */ __name((cur) => {\n if (!cur) return 0;\n const leftHeight = _height(cur.left);\n const rightHeight = _height(cur.right);\n if (Math.abs(leftHeight - rightHeight) > 1) balanced = false;\n return Math.max(leftHeight, rightHeight) + 1;\n }, \"_height\");\n _height(this._root);\n } else {\n const stack = [];\n let node = this._root, last = void 0;\n const depths = /* @__PURE__ */ new Map();\n while (stack.length > 0 || node) {\n if (node) {\n stack.push(node);\n if (node.left !== null) node = node.left;\n } else {\n node = stack[stack.length - 1];\n if (!node.right || last === node.right) {\n node = stack.pop();\n if (node) {\n const left = node.left ? depths.get(node.left) : -1;\n const right = node.right ? depths.get(node.right) : -1;\n if (Math.abs(left - right) > 1) return false;\n depths.set(node, 1 + Math.max(left, right));\n last = node;\n node = void 0;\n }\n } else node = node.right;\n }\n }\n }\n return balanced;\n }\n /**\n * Creates a new BST by mapping each [key, value] pair to a new entry.\n * @remarks Time O(N * H), where N is nodes in this tree, and H is height of the new tree during insertion.\n * Space O(N) for the new tree.\n *\n * @template MK - New key type.\n * @template MV - New value type.\n * @template MR - New raw type.\n * @param callback - A function to map each [key, value] pair.\n * @param [options] - Options for the new BST.\n * @param [thisArg] - `this` context for the callback.\n * @returns A new, mapped BST.\n */\n map(callback, options, thisArg) {\n const out = this._createLike([], options);\n let index = 0;\n for (const [key, value] of this) {\n out.set(callback.call(thisArg, value, key, index++, this));\n }\n return out;\n }\n /**\n * Deletes nodes that match a key, node, entry, predicate, or range.\n *\n * @remarks\n * Time Complexity: O(N) for search + O(M log N) for M deletions, where N is tree size.\n * Space Complexity: O(M) for storing matched nodes and result map.\n *\n * @template K - The key type.\n * @template V - The value type.\n *\n * @param keyNodeEntryOrPredicate - The search criteria. Can be one of:\n * - A key (type K): searches for exact key match using the comparator.\n * - A BSTNode: searches for the matching node in the tree.\n * - An entry tuple: searches for the key-value pair.\n * - A NodePredicate function: tests each node and returns true for matches.\n * - A Range object: searches for nodes whose keys fall within the specified range (inclusive/exclusive based on range settings).\n * - null or undefined: treated as no match, returns empty results.\n *\n * @param onlyOne - If true, stops the search after finding the first match and only deletes that one node.\n * If false (default), searches for and deletes all matching nodes.\n *\n * @param startNode - The node to start the search from. Can be:\n * - A key, node, or entry: the method resolves it to a node and searches from that subtree.\n * - null or undefined: defaults to the root, searching the entire tree.\n * - Default value: this._root (the tree's root).\n *\n * @param iterationType - Controls the internal traversal implementation:\n * - 'RECURSIVE': uses recursive function calls for traversal.\n * - 'ITERATIVE': uses explicit stack-based iteration.\n * - Default: this.iterationType (the tree's default iteration mode).\n *\n * @returns A Map<K, boolean> containing the deletion results:\n * - Key: the matched node's key.\n * - Value: true if the deletion succeeded, false if it failed (e.g., key not found during deletion phase).\n * - If no nodes match the search criteria, the returned map is empty.\n */\n deleteWhere(keyNodeEntryOrPredicate, onlyOne = false, startNode = this._root, iterationType = this.iterationType) {\n const toDelete = this.search(keyNodeEntryOrPredicate, onlyOne, (node) => node, startNode, iterationType);\n let results = [];\n for (const node of toDelete) {\n const deleteInfo = this.delete(node);\n results = results.concat(deleteInfo);\n }\n return results;\n }\n /**\n * (Protected) Creates the default comparator function for keys that don't have a custom comparator.\n * @remarks Time O(1) Space O(1)\n * @returns The default comparator function.\n */\n _createDefaultComparator() {\n return (a, b) => {\n if (isComparable(a) && isComparable(b)) {\n if (a > b) return 1;\n if (a < b) return -1;\n return 0;\n }\n if (typeof a === \"object\" || typeof b === \"object\") {\n throw TypeError(\n `When comparing object type keys, a custom comparator must be provided in the constructor's options!`\n );\n }\n return 0;\n };\n }\n /**\n * (Protected) Binary search for floor by key with pruning optimization.\n * Performs standard BST binary search, choosing left or right subtree based on comparator result.\n * Finds first node where key <= target.\n * @remarks Time O(h) where h is tree height.\n *\n * @param key - The target key to search for.\n * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).\n * @returns The first node with key <= target, or undefined if none exists.\n */\n _floorByKey(key, iterationType) {\n var _a, _b;\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (!this.isRealNode(cur)) return void 0;\n const cmp = this.comparator(cur.key, key);\n if (cmp <= 0) {\n const rightResult = dfs(cur.right);\n return rightResult != null ? rightResult : cur;\n } else {\n return dfs(cur.left);\n }\n }, \"dfs\");\n return dfs(this.root);\n } else {\n let current = this.root;\n let result = void 0;\n while (this.isRealNode(current)) {\n const cmp = this.comparator(current.key, key);\n if (cmp <= 0) {\n result = current;\n current = (_a = current.right) != null ? _a : void 0;\n } else {\n current = (_b = current.left) != null ? _b : void 0;\n }\n }\n return result;\n }\n }\n /**\n * (Protected) In-order traversal search for floor by predicate.\n * Falls back to linear in-order traversal when predicate-based search is required.\n * Returns the last node that satisfies the predicate function.\n * @remarks Time Complexity: O(n) since it may visit every node.\n * Space Complexity: O(h) for recursion, O(h) for iterative stack.\n *\n * @param predicate - The predicate function to test nodes.\n * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).\n * @returns The last node satisfying predicate (highest key), or undefined if none found.\n */\n _floorByPredicate(predicate, iterationType) {\n if (iterationType === \"RECURSIVE\") {\n let result = void 0;\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (!this.isRealNode(cur)) return;\n if (this.isRealNode(cur.left)) dfs(cur.left);\n if (predicate(cur)) {\n result = cur;\n }\n if (this.isRealNode(cur.right)) dfs(cur.right);\n }, \"dfs\");\n dfs(this.root);\n return result;\n } else {\n const stack = [];\n let current = this.root;\n let result = void 0;\n while (stack.length > 0 || this.isRealNode(current)) {\n if (this.isRealNode(current)) {\n stack.push(current);\n current = current.left;\n } else {\n const node = stack.pop();\n if (!this.isRealNode(node)) break;\n if (predicate(node)) {\n result = node;\n }\n current = node.right;\n }\n }\n return result;\n }\n }\n /**\n * (Protected) Binary search for lower by key with pruning optimization.\n * Performs standard BST binary search, choosing left or right subtree based on comparator result.\n * Finds first node where key < target.\n * @remarks Time O(h) where h is tree height.\n *\n * @param key - The target key to search for.\n * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).\n * @returns The first node with key < target, or undefined if none exists.\n */\n _lowerByKey(key, iterationType) {\n var _a, _b;\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (!this.isRealNode(cur)) return void 0;\n const cmp = this.comparator(cur.key, key);\n if (cmp < 0) {\n const rightResult = dfs(cur.right);\n return rightResult != null ? rightResult : cur;\n } else {\n return dfs(cur.left);\n }\n }, \"dfs\");\n return dfs(this.root);\n } else {\n let current = this.root;\n let result = void 0;\n while (this.isRealNode(current)) {\n const cmp = this.comparator(current.key, key);\n if (cmp < 0) {\n result = current;\n current = (_a = current.right) != null ? _a : void 0;\n } else {\n current = (_b = current.left) != null ? _b : void 0;\n }\n }\n return result;\n }\n }\n /**\n * (Protected) In-order traversal search for lower by predicate.\n * Falls back to linear in-order traversal when predicate-based search is required.\n * Returns the node that satisfies the predicate and appears last in in-order traversal.\n * @remarks Time Complexity: O(n) since it may visit every node.\n * Space Complexity: O(h) for recursion, O(h) for iterative stack.\n *\n * @param predicate - The predicate function to test nodes.\n * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).\n * @returns The last node satisfying predicate (highest key < target), or undefined if none found.\n */\n _lowerByPredicate(predicate, iterationType) {\n if (iterationType === \"RECURSIVE\") {\n let result = void 0;\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (!this.isRealNode(cur)) return;\n if (this.isRealNode(cur.left)) dfs(cur.left);\n if (predicate(cur)) {\n result = cur;\n }\n if (this.isRealNode(cur.right)) dfs(cur.right);\n }, \"dfs\");\n dfs(this.root);\n return result;\n } else {\n const stack = [];\n let current = this.root;\n let result = void 0;\n while (stack.length > 0 || this.isRealNode(current)) {\n if (this.isRealNode(current)) {\n stack.push(current);\n current = current.left;\n } else {\n const node = stack.pop();\n if (!this.isRealNode(node)) break;\n if (predicate(node)) {\n result = node;\n }\n current = node.right;\n }\n }\n return result;\n }\n }\n /**\n * (Protected) Core bound search implementation supporting all parameter types.\n * Unified logic for both lowerBound and upperBound.\n * Resolves various input types (Key, Node, Entry, Predicate) using parent class utilities.\n * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.\n * @param isLower - True for lowerBound (>=), false for upperBound (>).\n * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).\n * @returns The first matching node, or undefined if no such node exists.\n */\n _bound(keyNodeEntryOrPredicate, isLower, iterationType) {\n if (keyNodeEntryOrPredicate === null || keyNodeEntryOrPredicate === void 0) {\n return void 0;\n }\n if (this._isPredicate(keyNodeEntryOrPredicate)) {\n return this._boundByPredicate(keyNodeEntryOrPredicate, iterationType);\n }\n let targetKey;\n if (this.isNode(keyNodeEntryOrPredicate)) {\n targetKey = keyNodeEntryOrPredicate.key;\n } else if (this.isEntry(keyNodeEntryOrPredicate)) {\n const key = keyNodeEntryOrPredicate[0];\n if (key === null || key === void 0) {\n return void 0;\n }\n targetKey = key;\n } else {\n targetKey = keyNodeEntryOrPredicate;\n }\n if (targetKey !== void 0) {\n return this._boundByKey(targetKey, isLower, iterationType);\n }\n return void 0;\n }\n /**\n * (Protected) Binary search for bound by key with pruning optimization.\n * Performs standard BST binary search, choosing left or right subtree based on comparator result.\n * For lowerBound: finds first node where key >= target.\n * For upperBound: finds first node where key > target.\n * @param key - The target key to search for.\n * @param isLower - True for lowerBound (>=), false for upperBound (>).\n * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).\n * @returns The first node matching the bound condition, or undefined if none exists.\n */\n _boundByKey(key, isLower, iterationType) {\n var _a, _b;\n if (iterationType === \"RECURSIVE\") {\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (!this.isRealNode(cur)) return void 0;\n const cmp = this.comparator(cur.key, key);\n const condition = isLower ? cmp >= 0 : cmp > 0;\n if (condition) {\n const leftResult = dfs(cur.left);\n return leftResult != null ? leftResult : cur;\n } else {\n return dfs(cur.right);\n }\n }, \"dfs\");\n return dfs(this.root);\n } else {\n let current = this.root;\n let result = void 0;\n while (this.isRealNode(current)) {\n const cmp = this.comparator(current.key, key);\n const condition = isLower ? cmp >= 0 : cmp > 0;\n if (condition) {\n result = current;\n current = (_a = current.left) != null ? _a : void 0;\n } else {\n current = (_b = current.right) != null ? _b : void 0;\n }\n }\n return result;\n }\n }\n /**\n * (Protected) In-order traversal search by predicate.\n * Falls back to linear in-order traversal when predicate-based search is required.\n * Returns the first node that satisfies the predicate function.\n * Note: Predicate-based search cannot leverage BST's binary search optimization.\n * Time Complexity: O(n) since it may visit every node.\n * @param predicate - The predicate function to test nodes.\n * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).\n * @returns The first node satisfying predicate, or undefined if none found.\n */\n _boundByPredicate(predicate, iterationType) {\n if (iterationType === \"RECURSIVE\") {\n let result = void 0;\n const dfs = /* @__PURE__ */ __name((cur) => {\n if (result || !this.isRealNode(cur)) return;\n if (this.isRealNode(cur.left)) dfs(cur.left);\n if (!result && predicate(cur)) {\n result = cur;\n }\n if (!result && this.isRealNode(cur.right)) dfs(cur.right);\n }, \"dfs\");\n dfs(this.root);\n return result;\n } else {\n const stack = [];\n let current = this.root;\n while (stack.length > 0 || this.isRealNode(current)) {\n if (this.isRealNode(current)) {\n stack.push(current);\n current = current.left;\n } else {\n const node = stack.pop();\n if (!this.isRealNode(node)) break;\n if (predicate(node)) {\n return node;\n }\n current = node.right;\n }\n }\n return void 0;\n }\n }\n /**\n * (Protected) Creates a new, empty instance of the same BST constructor.\n * @remarks Time O(1)\n *\n * @template TK, TV, TR - Generic types for the new instance.\n * @param [options] - Options for the new BST.\n * @returns A new, empty BST.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Protected) Creates a new instance of the same BST constructor, potentially with different generic types.\n * @remarks Time O(N log N) or O(N^2) (from constructor) due to processing the iterable.\n *\n * @template TK, TV, TR - Generic types for the new instance.\n * @param [iter=[]] - An iterable to populate the new BST.\n * @param [options] - Options for the new BST.\n * @returns A new BST.\n */\n _createLike(iter = [], options) {\n const Ctor = this.constructor;\n return new Ctor(iter, { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Protected) Snapshots the current BST's configuration options.\n * @remarks Time O(1)\n *\n * @template TK, TV, TR - Generic types for the options.\n * @returns The options object.\n */\n _snapshotOptions() {\n return {\n ...super._snapshotOptions(),\n comparator: this._comparator\n };\n }\n /**\n * (Protected) Converts a key, node, or entry into a standardized [node, value] tuple.\n * @remarks Time O(1)\n *\n * @param keyNodeOrEntry - The input item.\n * @param [value] - An optional value (used if input is just a key).\n * @returns A tuple of [node, value].\n */\n _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value) {\n const [node, entryValue] = super._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);\n if (node === null) return [void 0, void 0];\n return [node, value != null ? value : entryValue];\n }\n /**\n * (Protected) Sets the root node and clears its parent reference.\n * @remarks Time O(1)\n *\n * @param v - The node to set as root.\n */\n _setRoot(v) {\n if (v) v.parent = void 0;\n this._root = v;\n }\n /**\n * (Protected) Compares two keys using the tree's comparator and reverse setting.\n * @remarks Time O(1) Space O(1)\n *\n * @param a - The first key.\n * @param b - The second key.\n * @returns A number (1, -1, or 0) representing the comparison.\n */\n _compare(a, b) {\n return this._comparator(a, b);\n }\n /**\n * (Private) Deletes a node by its key.\n * @remarks Standard BST deletion algorithm. Time O(log N), O(N) worst-case. Space O(1).\n *\n * @param key - The key of the node to delete.\n * @returns True if the node was found and deleted, false otherwise.\n */\n _deleteByKey(key) {\n let node = this._root;\n while (node) {\n const cmp = this._compare(node.key, key);\n if (cmp === 0) break;\n node = cmp > 0 ? node.left : node.right;\n }\n if (!node) return false;\n const transplant = /* @__PURE__ */ __name((u, v) => {\n const p = u == null ? void 0 : u.parent;\n if (!p) {\n this._setRoot(v);\n } else if (p.left === u) {\n p.left = v;\n } else {\n p.right = v;\n }\n if (v) v.parent = p;\n }, \"transplant\");\n const minNode = /* @__PURE__ */ __name((x) => {\n if (!x) return void 0;\n while (x.left !== void 0 && x.left !== null) x = x.left;\n return x;\n }, \"minNode\");\n if (node.left === void 0) {\n transplant(node, node.right);\n } else if (node.right === void 0) {\n transplant(node, node.left);\n } else {\n const succ = minNode(node.right);\n if (succ.parent !== node) {\n transplant(succ, succ.right);\n succ.right = node.right;\n if (succ.right) succ.right.parent = succ;\n }\n transplant(node, succ);\n succ.left = node.left;\n if (succ.left) succ.left.parent = succ;\n }\n this._size = Math.max(0, this._size - 1);\n return true;\n }\n};\n__name(_BST, \"BST\");\nvar BST = _BST;\n\n// src/data-structures/binary-tree/binary-indexed-tree.ts\nvar _BinaryIndexedTree = class _BinaryIndexedTree {\n /**\n * The constructor initializes the properties of an object, including default frequency, maximum\n * value, a freqMap data structure, the most significant bit, and the count of negative frequencies.\n * @param - - `frequency`: The default frequency value. It is optional and has a default\n * value of 0.\n */\n constructor({ frequency = 0, max }) {\n __publicField(this, \"_freq\");\n __publicField(this, \"_max\");\n __publicField(this, \"_freqMap\");\n __publicField(this, \"_msb\");\n __publicField(this, \"_negativeCount\");\n this._freq = frequency;\n this._max = max;\n this._freqMap = { 0: 0 };\n this._msb = getMSB(max);\n this._negativeCount = frequency < 0 ? max : 0;\n }\n /**\n * The function returns the frequency map of numbers.\n * @returns The `_freqMap` property, which is a record with number keys and number values, is being\n * returned.\n */\n get freqMap() {\n return this._freqMap;\n }\n /**\n * The function returns the value of the _msb property.\n * @returns The `_msb` property of the object.\n */\n get msb() {\n return this._msb;\n }\n /**\n * The function returns the value of the _negativeCount property.\n * @returns The method is returning the value of the variable `_negativeCount`, which is of type\n * `number`.\n */\n get negativeCount() {\n return this._negativeCount;\n }\n /**\n * The above function returns the value of the protected variable `_freq`.\n * @returns The frequency value stored in the protected variable `_freq`.\n */\n get freq() {\n return this._freq;\n }\n /**\n * The above function returns the maximum value.\n * @returns The maximum value stored in the variable `_max`.\n */\n get max() {\n return this._max;\n }\n /**\n * The function \"readSingle\" reads a single number from a specified index.\n * @param {number} index - The `index` parameter is a number that represents the index of an element in a\n * collection or array.\n * @returns a number.\n */\n readSingle(index) {\n this._checkIndex(index);\n return this._readSingle(index);\n }\n /**\n * The \"update\" function updates the value at a given index by adding a delta and triggers a callback\n * to notify of the change.\n * @param {number} position - The `index` parameter represents the index of the element that needs to be\n * updated in the data structure.\n * @param {number} change - The \"delta\" parameter represents the change in value that needs to be\n * applied to the frequency at the specified index.\n */\n update(position, change) {\n this._checkIndex(position);\n const freqCur = this._readSingle(position);\n this._update(position, change);\n this._updateNegativeCount(freqCur, freqCur + change);\n }\n /**\n * The function \"writeSingle\" checks the index and writes a single value with a given frequency.\n * @param {number} index - The `index` parameter is a number that represents the index of an element. It\n * is used to identify the specific element that needs to be written.\n * @param {number} freq - The `freq` parameter represents the frequency value that needs to be\n * written.\n */\n writeSingle(index, freq) {\n this._checkIndex(index);\n this._writeSingle(index, freq);\n }\n /**\n * The read function takes a count parameter, checks if it is an integer, and returns the result of\n * calling the _read function with the count parameter clamped between 0 and the maximum value.\n * @param {number} count - The `count` parameter is a number that represents the number of items to\n * read.\n * @returns a number.\n */\n read(count) {\n if (!Number.isInteger(count)) {\n throw new Error(\"Invalid count\");\n }\n return this._read(Math.max(Math.min(count, this.max), 0));\n }\n /**\n * The function returns the lower bound of a non-descending sequence that sums up to a given number.\n * @param {number} sum - The `sum` parameter is a number that represents the target sum that we want\n * to find in the sequence.\n * @returns The lowerBound function is returning a number.\n */\n lowerBound(sum) {\n if (this.negativeCount > 0) {\n throw new Error(\"Sequence is not non-descending\");\n }\n return this._binarySearch(sum, (x, y) => x < y);\n }\n /**\n * The upperBound function returns the index of the first element in a sequence that is greater than\n * or equal to a given sum.\n * @param {number} sum - The \"sum\" parameter is a number that represents the target sum that we want\n * to find in the sequence.\n * @returns The upperBound function is returning a number.\n */\n upperBound(sum) {\n if (this.negativeCount > 0) {\n throw new Error(\"Must not be descending\");\n }\n return this._binarySearch(sum, (x, y) => x <= y);\n }\n /**\n * The function calculates the prefix sum of an array using a binary indexed tree.\n * @param {number} i - The parameter \"i\" in the function \"getPrefixSum\" represents the index of the element in the\n * array for which we want to calculate the prefix sum.\n * @returns The function `getPrefixSum` returns the prefix sum of the elements in the binary indexed tree up to index\n * `i`.\n */\n getPrefixSum(i) {\n this._checkIndex(i);\n i++;\n let sum = 0;\n while (i > 0) {\n sum += this._getFrequency(i);\n i -= i & -i;\n }\n return sum;\n }\n /**\n * The function returns the value of a specific index in a freqMap data structure, or a default value if\n * the index is not found.\n * @param {number} index - The `index` parameter is a number that represents the index of a node in a\n * freqMap data structure.\n * @returns a number.\n */\n _getFrequency(index) {\n if (index in this.freqMap) {\n return this.freqMap[index];\n }\n return this.freq * (index & -index);\n }\n /**\n * The function _updateFrequency adds a delta value to the element at the specified index in the freqMap array.\n * @param {number} index - The index parameter is a number that represents the index of the freqMap\n * element that needs to be updated.\n * @param {number} delta - The `delta` parameter represents the change in value that needs to be\n * added to the freqMap at the specified `index`.\n */\n _updateFrequency(index, delta) {\n this.freqMap[index] = this._getFrequency(index) + delta;\n }\n /**\n * The function checks if the given index is valid and within the range.\n * @param {number} index - The parameter \"index\" is of type number and represents the index value\n * that needs to be checked.\n */\n _checkIndex(index) {\n if (!Number.isInteger(index)) {\n throw new Error(\"Invalid index: Index must be an integer.\");\n }\n if (index < 0 || index >= this.max) {\n throw new Error(\"Index out of range: Index must be within the range [0, this.max).\");\n }\n }\n /**\n * The function calculates the sum of elements in an array up to a given index using a binary indexed\n * freqMap.\n * @param {number} index - The `index` parameter is a number that represents the index of an element in a\n * data structure.\n * @returns a number.\n */\n _readSingle(index) {\n index = index + 1;\n let sum = this._getFrequency(index);\n const z = index - (index & -index);\n index--;\n while (index !== z) {\n sum -= this._getFrequency(index);\n index -= index & -index;\n }\n return sum;\n }\n /**\n * The function `_updateNegativeCount` updates a counter based on changes in frequency values.\n * @param {number} freqCur - The current frequency value.\n * @param {number} freqNew - The freqNew parameter represents the new frequency value.\n */\n _updateNegativeCount(freqCur, freqNew) {\n if (freqCur < 0 && freqNew >= 0) {\n this._negativeCount--;\n } else if (freqCur >= 0 && freqNew < 0) {\n this._negativeCount++;\n }\n }\n /**\n * The `_update` function updates the values in a binary indexed freqMap starting from a given index and\n * propagating the changes to its parent nodes.\n * @param {number} index - The `index` parameter is a number that represents the index of the element in\n * the data structure that needs to be updated.\n * @param {number} delta - The `delta` parameter represents the change in value that needs to be\n * applied to the elements in the data structure.\n */\n _update(index, delta) {\n index = index + 1;\n while (index <= this.max) {\n this._updateFrequency(index, delta);\n index += index & -index;\n }\n }\n /**\n * The `_writeSingle` function updates the frequency at a specific index and triggers a callback if\n * the frequency has changed.\n * @param {number} index - The `index` parameter is a number that represents the index of the element\n * being modified or accessed.\n * @param {number} freq - The `freq` parameter represents the new frequency value that needs to be\n * written to the specified index `index`.\n */\n _writeSingle(index, freq) {\n const freqCur = this._readSingle(index);\n this._update(index, freq - freqCur);\n this._updateNegativeCount(freqCur, freq);\n }\n /**\n * The `_read` function calculates the sum of values in a binary freqMap up to a given count.\n * @param {number} count - The `count` parameter is a number that represents the number of elements\n * to read from the freqMap.\n * @returns the sum of the values obtained from calling the `_getFrequency` method for each index in the\n * range from `count` to 1.\n */\n _read(count) {\n let index = count;\n let sum = 0;\n while (index) {\n sum += this._getFrequency(index);\n index -= index & -index;\n }\n return sum;\n }\n /**\n * The function `_binarySearch` performs a binary search to find the largest number that satisfies a given\n * condition.\n * @param {number} sum - The sum parameter is a number that represents the target sum value.\n * @param before - The `before` parameter is a function that takes two numbers `x` and `y` as\n * arguments and returns a boolean value. It is used to determine if `x` is less than or equal to\n * `y`. The purpose of this function is to compare two numbers and determine their order.\n * @returns the value of the variable \"left\".\n */\n _binarySearch(sum, before) {\n let left = 0;\n let right = this.msb << 1;\n let sumT = sum;\n while (right > left + 1) {\n const middle = left + right >> 1;\n const sumM = this._getFrequency(middle);\n if (middle <= this.max && before(sumM, sumT)) {\n sumT -= sumM;\n left = middle;\n } else {\n right = middle;\n }\n }\n return left;\n }\n};\n__name(_BinaryIndexedTree, \"BinaryIndexedTree\");\nvar BinaryIndexedTree = _BinaryIndexedTree;\n\n// src/data-structures/binary-tree/segment-tree.ts\nvar _SegmentTreeNode = class _SegmentTreeNode {\n /**\n * The constructor initializes the properties of a SegmentTreeNode object.\n * @param {number} start - The `start` parameter represents the starting index of the segment covered\n * by this node in a segment tree.\n * @param {number} end - The `end` parameter represents the end index of the segment covered by this\n * node in a segment tree.\n * @param {number} sum - The `sum` parameter represents the sum of the values in the range covered by\n * the segment tree node.\n * @param {SegmentTreeNodeVal | undefined} [value] - The `value` parameter is an optional parameter\n * of type `SegmentTreeNodeVal`. It represents the value associated with the segment tree node.\n */\n constructor(start, end, sum, value) {\n __publicField(this, \"_start\", 0);\n __publicField(this, \"_end\", 0);\n __publicField(this, \"_value\");\n __publicField(this, \"_sum\", 0);\n __publicField(this, \"_left\");\n __publicField(this, \"_right\");\n this._start = start;\n this._end = end;\n this._sum = sum;\n this._value = value || void 0;\n }\n /**\n * The function returns the value of the protected variable _start.\n * @returns The start value, which is of type number.\n */\n get start() {\n return this._start;\n }\n /**\n * The above function sets the value of the \"start\" property.\n * @param {number} value - The value parameter is of type number.\n */\n set start(value) {\n this._start = value;\n }\n /**\n * The function returns the value of the protected variable `_end`.\n * @returns The value of the protected property `_end`.\n */\n get end() {\n return this._end;\n }\n /**\n * The above function sets the value of the \"end\" property.\n * @param {number} value - The value parameter is a number that represents the new value for the end\n * property.\n */\n set end(value) {\n this._end = value;\n }\n /**\n * The function returns the value of a segment tree node.\n * @returns The value being returned is either a `SegmentTreeNodeVal` object or `undefined`.\n */\n get value() {\n return this._value;\n }\n /**\n * The function sets the value of a segment tree node.\n * @param {SegmentTreeNodeVal | undefined} value - The `value` parameter is of type\n * `SegmentTreeNodeVal` or `undefined`.\n */\n set value(value) {\n this._value = value;\n }\n /**\n * The function returns the value of the sum property.\n * @returns The method is returning the value of the variable `_sum`.\n */\n get sum() {\n return this._sum;\n }\n /**\n * The above function sets the value of the sum property.\n * @param {number} value - The parameter \"value\" is of type \"number\".\n */\n set sum(value) {\n this._sum = value;\n }\n /**\n * The function returns the left child of a segment tree node.\n * @returns The `left` property of the `SegmentTreeNode` object is being returned. It is of type\n * `SegmentTreeNode` or `undefined`.\n */\n get left() {\n return this._left;\n }\n /**\n * The function sets the value of the left property of a SegmentTreeNode object.\n * @param {SegmentTreeNode | undefined} value - The value parameter is of type SegmentTreeNode or\n * undefined.\n */\n set left(value) {\n this._left = value;\n }\n /**\n * The function returns the right child of a segment tree node.\n * @returns The `getRight()` method is returning a value of type `SegmentTreeNode` or `undefined`.\n */\n get right() {\n return this._right;\n }\n /**\n * The function sets the right child of a segment tree node.\n * @param {SegmentTreeNode | undefined} value - The `value` parameter is of type `SegmentTreeNode |\n * undefined`. This means that it can accept either a `SegmentTreeNode` object or `undefined` as its\n * value.\n */\n set right(value) {\n this._right = value;\n }\n};\n__name(_SegmentTreeNode, \"SegmentTreeNode\");\nvar SegmentTreeNode = _SegmentTreeNode;\nvar _SegmentTree = class _SegmentTree {\n /**\n * The constructor initializes the values, start, end, and root properties of an object.\n * @param {number[]} values - An array of numbers that will be used to build a binary search tree.\n * @param {number} [start] - The `start` parameter is the index of the first element in the `values` array that should\n * be included in the range. If no value is provided for `start`, it defaults to 0, which means the range starts from\n * the beginning of the array.\n * @param {number} [end] - The \"end\" parameter is the index of the last element in the \"values\" array that should be\n * included in the range. If not provided, it defaults to the index of the last element in the \"values\" array.\n */\n constructor(values, start, end) {\n __publicField(this, \"_values\", []);\n __publicField(this, \"_start\", 0);\n __publicField(this, \"_end\");\n __publicField(this, \"_root\");\n start = start || 0;\n end = end || values.length - 1;\n this._values = values;\n this._start = start;\n this._end = end;\n if (values.length > 0) {\n this._root = this.build(start, end);\n } else {\n this._root = void 0;\n this._values = [];\n }\n }\n /**\n * The function returns an array of numbers.\n * @returns An array of numbers is being returned.\n */\n get values() {\n return this._values;\n }\n /**\n * The function returns the value of the protected variable _start.\n * @returns The start value, which is of type number.\n */\n get start() {\n return this._start;\n }\n /**\n * The function returns the value of the protected variable `_end`.\n * @returns The value of the protected property `_end`.\n */\n get end() {\n return this._end;\n }\n /**\n * The function returns the root node of a segment tree.\n * @returns The `root` property of the class `SegmentTreeNode` or `undefined` if it is not defined.\n */\n get root() {\n return this._root;\n }\n /**\n * The build function creates a segment tree by recursively dividing the given range into smaller segments and assigning\n * the sum of values to each segment.\n * @param {number} start - The `start` parameter represents the starting index of the segment or range for which we are\n * building the segment tree.\n * @param {number} end - The \"end\" parameter represents the ending index of the segment or range for which we want to\n * build a segment tree.\n * @returns a SegmentTreeNode object.\n */\n build(start, end) {\n if (start > end) {\n return new SegmentTreeNode(start, end, 0);\n }\n if (start === end) return new SegmentTreeNode(start, end, this._values[start]);\n const mid = start + Math.floor((end - start) / 2);\n const left = this.build(start, mid);\n const right = this.build(mid + 1, end);\n const cur = new SegmentTreeNode(start, end, left.sum + right.sum);\n cur.left = left;\n cur.right = right;\n return cur;\n }\n /**\n * The function updates the value of a node in a segment tree and recalculates the sum of its children if they exist.\n * @param {number} index - The index parameter represents the index of the node in the segment tree that needs to be\n * updated.\n * @param {number} sum - The `sum` parameter represents the new value that should be assigned to the `sum` property of\n * the `SegmentTreeNode` at the specified `index`.\n * @param {SegmentTreeNodeVal} [value] - The `value` parameter is an optional value that can be assigned to the `value`\n * property of the `SegmentTreeNode` object. It is not currently used in the code, but you can uncomment the line `//\n * cur.value = value;` and pass a value for `value` in the\n * @returns The function does not return anything.\n */\n updateNode(index, sum, value) {\n const root = this.root || void 0;\n if (!root) {\n return;\n }\n const dfs = /* @__PURE__ */ __name((cur, index2, sum2, value2) => {\n if (cur.start === cur.end && cur.start === index2) {\n cur.sum = sum2;\n if (value2 !== void 0) cur.value = value2;\n return;\n }\n const mid = cur.start + Math.floor((cur.end - cur.start) / 2);\n if (index2 <= mid) {\n if (cur.left) {\n dfs(cur.left, index2, sum2, value2);\n }\n } else {\n if (cur.right) {\n dfs(cur.right, index2, sum2, value2);\n }\n }\n if (cur.left && cur.right) {\n cur.sum = cur.left.sum + cur.right.sum;\n }\n }, \"dfs\");\n dfs(root, index, sum, value);\n }\n /**\n * The function `querySumByRange` calculates the sum of values within a given range in a segment tree.\n * @param {number} indexA - The starting index of the range for which you want to calculate the sum.\n * @param {number} indexB - The parameter `indexB` represents the ending index of the range for which you want to\n * calculate the sum.\n * @returns The function `querySumByRange` returns a number.\n */\n querySumByRange(indexA, indexB) {\n const root = this.root || void 0;\n if (!root) {\n return 0;\n }\n if (indexA < 0 || indexB >= this.values.length || indexA > indexB) {\n return NaN;\n }\n const dfs = /* @__PURE__ */ __name((cur, i, j) => {\n if (i <= cur.start && j >= cur.end) {\n return cur.sum;\n }\n const mid = cur.start + Math.floor((cur.end - cur.start) / 2);\n if (j <= mid) {\n if (cur.left) {\n return dfs(cur.left, i, j);\n } else {\n return NaN;\n }\n } else if (i > mid) {\n if (cur.right) {\n return dfs(cur.right, i, j);\n } else {\n return NaN;\n }\n } else {\n let leftSum = 0;\n let rightSum = 0;\n if (cur.left) {\n leftSum = dfs(cur.left, i, mid);\n }\n if (cur.right) {\n rightSum = dfs(cur.right, mid + 1, j);\n }\n return leftSum + rightSum;\n }\n }, \"dfs\");\n return dfs(root, indexA, indexB);\n }\n};\n__name(_SegmentTree, \"SegmentTree\");\nvar SegmentTree = _SegmentTree;\n\n// src/data-structures/binary-tree/avl-tree.ts\nvar _AVLTreeNode = class _AVLTreeNode {\n /**\n * Creates an instance of AVLTreeNode.\n * @remarks Time O(1), Space O(1)\n *\n * @param key - The key of the node.\n * @param [value] - The value associated with the key.\n */\n constructor(key, value) {\n __publicField(this, \"key\");\n __publicField(this, \"value\");\n __publicField(this, \"parent\");\n __publicField(this, \"_left\");\n __publicField(this, \"_right\");\n __publicField(this, \"_height\", 0);\n __publicField(this, \"_color\", \"BLACK\");\n __publicField(this, \"_count\", 1);\n this.key = key;\n this.value = value;\n }\n /**\n * Gets the left child of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The left child.\n */\n get left() {\n return this._left;\n }\n /**\n * Sets the left child of the node and updates its parent reference.\n * @remarks Time O(1), Space O(1)\n *\n * @param v - The node to set as the left child.\n */\n set left(v) {\n if (v) {\n v.parent = this;\n }\n this._left = v;\n }\n /**\n * Gets the right child of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The right child.\n */\n get right() {\n return this._right;\n }\n /**\n * Sets the right child of the node and updates its parent reference.\n * @remarks Time O(1), Space O(1)\n *\n * @param v - The node to set as the right child.\n */\n set right(v) {\n if (v) {\n v.parent = this;\n }\n this._right = v;\n }\n /**\n * Gets the height of the node (used in self-balancing trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The height.\n */\n get height() {\n return this._height;\n }\n /**\n * Sets the height of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new height.\n */\n set height(value) {\n this._height = value;\n }\n /**\n * Gets the color of the node (used in Red-Black trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The node's color.\n */\n get color() {\n return this._color;\n }\n /**\n * Sets the color of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new color.\n */\n set color(value) {\n this._color = value;\n }\n /**\n * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The subtree node count.\n */\n get count() {\n return this._count;\n }\n /**\n * Sets the count of nodes in the subtree.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new count.\n */\n set count(value) {\n this._count = value;\n }\n /**\n * Gets the position of the node relative to its parent.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').\n */\n get familyPosition() {\n if (!this.parent) {\n return this.left || this.right ? \"ROOT\" : \"ISOLATED\";\n }\n if (this.parent.left === this) {\n return this.left || this.right ? \"ROOT_LEFT\" : \"LEFT\";\n } else if (this.parent.right === this) {\n return this.left || this.right ? \"ROOT_RIGHT\" : \"RIGHT\";\n }\n return \"MAL_NODE\";\n }\n};\n__name(_AVLTreeNode, \"AVLTreeNode\");\nvar AVLTreeNode = _AVLTreeNode;\nvar _AVLTree = class _AVLTree extends BST {\n /**\n * Creates an instance of AVLTree.\n * @remarks Time O(N log N) (from `setMany` with balanced set). Space O(N).\n *\n * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.\n * @param [options] - Configuration options for the AVL tree.\n */\n constructor(keysNodesEntriesOrRaws = [], options) {\n super([], options);\n if (keysNodesEntriesOrRaws) super.setMany(keysNodesEntriesOrRaws);\n }\n /**\n * (Protected) Creates a new AVL tree node.\n * @remarks Time O(1), Space O(1)\n *\n * @param key - The key for the new node.\n * @param [value] - The value for the new node.\n * @returns The newly created AVLTreeNode.\n */\n createNode(key, value) {\n return new AVLTreeNode(key, value);\n }\n /**\n * Checks if the given item is an `AVLTreeNode` instance.\n * @remarks Time O(1), Space O(1)\n *\n * @param keyNodeOrEntry - The item to check.\n * @returns True if it's an AVLTreeNode, false otherwise.\n */\n isNode(keyNodeOrEntry) {\n return keyNodeOrEntry instanceof AVLTreeNode;\n }\n /**\n * Sets a new node to the AVL tree and balances the tree path.\n * @remarks Time O(log N) (O(H) for BST set + O(H) for `_balancePath`). Space O(H) for path/recursion.\n *\n * @param keyNodeOrEntry - The key, node, or entry to set.\n * @param [value] - The value, if providing just a key.\n * @returns True if the addition was successful, false otherwise.\n */\n set(keyNodeOrEntry, value) {\n if (keyNodeOrEntry === null) return false;\n const inserted = super.set(keyNodeOrEntry, value);\n if (inserted) this._balancePath(keyNodeOrEntry);\n return inserted;\n }\n /**\n * Deletes a node from the AVL tree and re-balances the tree.\n * @remarks Time O(log N) (O(H) for BST delete + O(H) for `_balancePath`). Space O(H) for path/recursion.\n *\n * @param keyNodeOrEntry - The node to delete.\n * @returns An array containing deletion results.\n */\n delete(keyNodeOrEntry) {\n const deletedResults = super.delete(keyNodeOrEntry);\n for (const { needBalanced } of deletedResults) {\n if (needBalanced) {\n this._balancePath(needBalanced);\n }\n }\n return deletedResults;\n }\n /**\n * Rebuilds the tree to be perfectly balanced.\n * @remarks AVL trees are already height-balanced, but this makes them *perfectly* balanced (minimal height and all leaves at N or N-1).\n * Time O(N) (O(N) for DFS, O(N) for sorted build). Space O(N) for node array and recursion stack.\n *\n * @param [iterationType=this.iterationType] - The traversal method for the initial node export.\n * @returns True if successful, false if the tree was empty.\n */\n perfectlyBalance(iterationType = this.iterationType) {\n const nodes = this.dfs((node) => node, \"IN\", false, this._root, iterationType);\n const n = nodes.length;\n if (n === 0) return false;\n this._clearNodes();\n const build = /* @__PURE__ */ __name((l, r, parent) => {\n if (l > r) return void 0;\n const m = l + (r - l >> 1);\n const root = nodes[m];\n root.left = build(l, m - 1, root);\n root.right = build(m + 1, r, root);\n root.parent = parent;\n const lh = root.left ? root.left.height : -1;\n const rh = root.right ? root.right.height : -1;\n root.height = Math.max(lh, rh) + 1;\n return root;\n }, \"build\");\n const newRoot = build(0, n - 1, void 0);\n this._setRoot(newRoot);\n this._size = n;\n return true;\n }\n /**\n * Creates a new AVLTree by mapping each [key, value] pair.\n * @remarks Time O(N log N) (O(N) iteration + O(log M) `set` for each item into the new tree). Space O(N) for the new tree.\n *\n * @template MK - New key type.\n * @template MV - New value type.\n * @template MR - New raw type.\n * @param callback - A function to map each [key, value] pair.\n * @param [options] - Options for the new AVLTree.\n * @param [thisArg] - `this` context for the callback.\n * @returns A new, mapped AVLTree.\n */\n map(callback, options, thisArg) {\n const out = this._createLike([], options);\n let index = 0;\n for (const [key, value] of this) {\n out.set(callback.call(thisArg, value, key, index++, this));\n }\n return out;\n }\n /**\n * (Protected) Creates a new, empty instance of the same AVLTree constructor.\n * @remarks Time O(1)\n *\n * @template TK, TV, TR - Generic types for the new instance.\n * @param [options] - Options for the new tree.\n * @returns A new, empty tree.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Protected) Creates a new instance of the same AVLTree constructor, potentially with different generic types.\n * @remarks Time O(N log N) (from constructor) due to processing the iterable.\n *\n * @template TK, TV, TR - Generic types for the new instance.\n * @param [iter=[]] - An iterable to populate the new tree.\n * @param [options] - Options for the new tree.\n * @returns A new AVLTree.\n */\n _createLike(iter = [], options) {\n const Ctor = this.constructor;\n return new Ctor(iter, { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Protected) Swaps properties of two nodes, including height.\n * @remarks Time O(H) (due to `ensureNode`), but O(1) if nodes are passed directly.\n *\n * @param srcNode - The source node.\n * @param destNode - The destination node.\n * @returns The `destNode` (now holding `srcNode`'s properties).\n */\n _swapProperties(srcNode, destNode) {\n const srcNodeEnsured = this.ensureNode(srcNode);\n const destNodeEnsured = this.ensureNode(destNode);\n if (srcNodeEnsured && destNodeEnsured) {\n const { key, value, height } = destNodeEnsured;\n const tempNode = this.createNode(key, value);\n if (tempNode) {\n tempNode.height = height;\n destNodeEnsured.key = srcNodeEnsured.key;\n if (!this._isMapMode) destNodeEnsured.value = srcNodeEnsured.value;\n destNodeEnsured.height = srcNodeEnsured.height;\n srcNodeEnsured.key = tempNode.key;\n if (!this._isMapMode) srcNodeEnsured.value = tempNode.value;\n srcNodeEnsured.height = tempNode.height;\n }\n return destNodeEnsured;\n }\n return void 0;\n }\n /**\n * (Protected) Calculates the balance factor (height(right) - height(left)).\n * @remarks Time O(1) (assumes heights are stored).\n *\n * @param node - The node to check.\n * @returns The balance factor (positive if right-heavy, negative if left-heavy).\n */\n _balanceFactor(node) {\n const left = node.left ? node.left.height : -1;\n const right = node.right ? node.right.height : -1;\n return right - left;\n }\n /**\n * (Protected) Recalculates and updates the height of a node based on its children's heights.\n * @remarks Time O(1) (assumes children's heights are correct).\n *\n * @param node - The node to update.\n */\n _updateHeight(node) {\n const leftHeight = node.left ? node.left.height : -1;\n const rightHeight = node.right ? node.right.height : -1;\n node.height = 1 + Math.max(leftHeight, rightHeight);\n }\n /**\n * (Protected) Performs a Left-Left (LL) rotation (a single right rotation).\n * @remarks Time O(1), Space O(1)\n *\n * @param A - The unbalanced node (root of the unbalanced subtree).\n */\n _balanceLL(A) {\n const parentOfA = A.parent;\n const B = A.left;\n if (B !== null) A.parent = B;\n if (B && B.right) {\n B.right.parent = A;\n }\n if (B) B.parent = parentOfA;\n if (A === this.root) {\n if (B) this._setRoot(B);\n } else {\n if ((parentOfA == null ? void 0 : parentOfA.left) === A) {\n parentOfA.left = B;\n } else {\n if (parentOfA) parentOfA.right = B;\n }\n }\n if (B) {\n A.left = B.right;\n B.right = A;\n }\n this._updateHeight(A);\n if (B) this._updateHeight(B);\n }\n /**\n * (Protected) Performs a Left-Right (LR) double rotation.\n * @remarks Time O(1), Space O(1)\n *\n * @param A - The unbalanced node (root of the unbalanced subtree).\n */\n _balanceLR(A) {\n const parentOfA = A.parent;\n const B = A.left;\n let C = void 0;\n if (B) {\n C = B.right;\n }\n if (A && C !== null) A.parent = C;\n if (B && C !== null) B.parent = C;\n if (C) {\n if (C.left) {\n if (B !== null) C.left.parent = B;\n }\n if (C.right) {\n C.right.parent = A;\n }\n C.parent = parentOfA;\n }\n if (A === this.root) {\n if (C) this._setRoot(C);\n } else {\n if (parentOfA) {\n if (parentOfA.left === A) {\n parentOfA.left = C;\n } else {\n parentOfA.right = C;\n }\n }\n }\n if (C) {\n A.left = C.right;\n if (B) B.right = C.left;\n C.left = B;\n C.right = A;\n }\n this._updateHeight(A);\n if (B) this._updateHeight(B);\n if (C) this._updateHeight(C);\n }\n /**\n * (Protected) Performs a Right-Right (RR) rotation (a single left rotation).\n * @remarks Time O(1), Space O(1)\n *\n * @param A - The unbalanced node (root of the unbalanced subtree).\n */\n _balanceRR(A) {\n const parentOfA = A.parent;\n const B = A.right;\n if (B !== null) A.parent = B;\n if (B) {\n if (B.left) {\n B.left.parent = A;\n }\n B.parent = parentOfA;\n }\n if (A === this.root) {\n if (B) this._setRoot(B);\n } else {\n if (parentOfA) {\n if (parentOfA.left === A) {\n parentOfA.left = B;\n } else {\n parentOfA.right = B;\n }\n }\n }\n if (B) {\n A.right = B.left;\n B.left = A;\n }\n this._updateHeight(A);\n if (B) this._updateHeight(B);\n }\n /**\n * (Protected) Performs a Right-Left (RL) double rotation.\n * @remarks Time O(1), Space O(1)\n *\n * @param A - The unbalanced node (root of the unbalanced subtree).\n */\n _balanceRL(A) {\n const parentOfA = A.parent;\n const B = A.right;\n let C = void 0;\n if (B) {\n C = B.left;\n }\n if (C !== null) A.parent = C;\n if (B && C !== null) B.parent = C;\n if (C) {\n if (C.left) {\n C.left.parent = A;\n }\n if (C.right) {\n if (B !== null) C.right.parent = B;\n }\n C.parent = parentOfA;\n }\n if (A === this.root) {\n if (C) this._setRoot(C);\n } else {\n if (parentOfA) {\n if (parentOfA.left === A) {\n parentOfA.left = C;\n } else {\n parentOfA.right = C;\n }\n }\n }\n if (C) A.right = C.left;\n if (B && C) B.left = C.right;\n if (C) C.left = A;\n if (C) C.right = B;\n this._updateHeight(A);\n if (B) this._updateHeight(B);\n if (C) this._updateHeight(C);\n }\n /**\n * (Protected) Traverses up the tree from the specified node, updating heights and performing rotations as needed.\n * @remarks Time O(log N) (O(H)), as it traverses the path to root. Space O(H) for the path array.\n *\n * @param node - The node to start balancing from (e.g., the newly inserted node or parent of the deleted node).\n */\n _balancePath(node) {\n node = this.ensureNode(node);\n const path = this.getPathToRoot(node, (node2) => node2, false);\n for (let i = 0; i < path.length; i++) {\n const A = path[i];\n if (A) {\n this._updateHeight(A);\n switch (this._balanceFactor(A)) {\n case -2:\n if (A && A.left) {\n if (this._balanceFactor(A.left) <= 0) {\n this._balanceLL(A);\n } else {\n this._balanceLR(A);\n }\n }\n break;\n case 2:\n if (A && A.right) {\n if (this._balanceFactor(A.right) >= 0) {\n this._balanceRR(A);\n } else {\n this._balanceRL(A);\n }\n }\n }\n }\n }\n }\n /**\n * (Protected) Replaces a node, ensuring height is copied.\n * @remarks Time O(1)\n *\n * @param oldNode - The node to be replaced.\n * @param newNode - The node to insert.\n * @returns The `newNode`.\n */\n _replaceNode(oldNode, newNode) {\n newNode.height = oldNode.height;\n return super._replaceNode(oldNode, newNode);\n }\n};\n__name(_AVLTree, \"AVLTree\");\nvar AVLTree = _AVLTree;\n\n// src/data-structures/binary-tree/red-black-tree.ts\nvar _RedBlackTreeNode = class _RedBlackTreeNode {\n /**\n * Create a Red-Black Tree node.\n * @remarks Time O(1), Space O(1)\n * @param key - Node key.\n * @param [value] - Node value (unused in map mode trees).\n * @param color - Node color.\n */\n constructor(key, value, color = \"BLACK\") {\n __publicField(this, \"key\");\n __publicField(this, \"value\");\n __publicField(this, \"parent\");\n __publicField(this, \"_left\");\n __publicField(this, \"_right\");\n __publicField(this, \"_height\", 0);\n __publicField(this, \"_color\", \"BLACK\");\n __publicField(this, \"_count\", 1);\n this.key = key;\n this.value = value;\n this.color = color;\n }\n /**\n * Get the left child pointer.\n * @remarks Time O(1), Space O(1)\n * @returns Left child node, or null/undefined.\n */\n get left() {\n return this._left;\n }\n /**\n * Set the left child and update its parent pointer.\n * @remarks Time O(1), Space O(1)\n * @param v - New left node, or null/undefined.\n * @returns void\n */\n set left(v) {\n if (v) {\n v.parent = this;\n }\n this._left = v;\n }\n /**\n * Get the right child pointer.\n * @remarks Time O(1), Space O(1)\n * @returns Right child node, or null/undefined.\n */\n get right() {\n return this._right;\n }\n /**\n * Set the right child and update its parent pointer.\n * @remarks Time O(1), Space O(1)\n * @param v - New right node, or null/undefined.\n * @returns void\n */\n set right(v) {\n if (v) {\n v.parent = this;\n }\n this._right = v;\n }\n /**\n * Gets the height of the node (used in self-balancing trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The height.\n */\n get height() {\n return this._height;\n }\n /**\n * Sets the height of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new height.\n */\n set height(value) {\n this._height = value;\n }\n /**\n * Gets the color of the node (used in Red-Black trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The node's color.\n */\n get color() {\n return this._color;\n }\n /**\n * Sets the color of the node.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new color.\n */\n set color(value) {\n this._color = value;\n }\n /**\n * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).\n * @remarks Time O(1), Space O(1)\n *\n * @returns The subtree node count.\n */\n get count() {\n return this._count;\n }\n /**\n * Sets the count of nodes in the subtree.\n * @remarks Time O(1), Space O(1)\n *\n * @param value - The new count.\n */\n set count(value) {\n this._count = value;\n }\n /**\n * Gets the position of the node relative to its parent.\n * @remarks Time O(1), Space O(1)\n *\n * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').\n */\n get familyPosition() {\n if (!this.parent) {\n return this.left || this.right ? \"ROOT\" : \"ISOLATED\";\n }\n if (this.parent.left === this) {\n return this.left || this.right ? \"ROOT_LEFT\" : \"LEFT\";\n } else if (this.parent.right === this) {\n return this.left || this.right ? \"ROOT_RIGHT\" : \"RIGHT\";\n }\n return \"MAL_NODE\";\n }\n};\n__name(_RedBlackTreeNode, \"RedBlackTreeNode\");\nvar RedBlackTreeNode = _RedBlackTreeNode;\nvar _RedBlackTree = class _RedBlackTree extends BST {\n constructor(keysNodesEntriesOrRaws = [], options) {\n super([], options);\n __publicField(this, \"_root\");\n /**\n * (Internal) Header sentinel:\n * - header.parent -> root\n * - header._left -> min (or NIL)\n * - header._right -> max (or NIL)\n *\n * IMPORTANT:\n * - This header is NOT part of the actual tree.\n * - Do NOT use `header.left` / `header.right` accessors for wiring: those setters update `NIL.parent`\n * and can corrupt sentinel invariants / cause hangs. Only touch `header._left/_right`.\n */\n __publicField(this, \"_header\");\n /**\n * (Internal) Cache of the current minimum and maximum nodes.\n * Used for fast-path insert/update when keys are monotonic or near-boundary.\n */\n __publicField(this, \"_minNode\");\n __publicField(this, \"_maxNode\");\n this._root = this.NIL;\n this._header = new RedBlackTreeNode(void 0, void 0, \"BLACK\");\n this._header.parent = this.NIL;\n this._header._left = this.NIL;\n this._header._right = this.NIL;\n if (keysNodesEntriesOrRaws) {\n this.setMany(keysNodesEntriesOrRaws);\n }\n }\n /**\n * Get the current root node.\n * @remarks Time O(1), Space O(1)\n * @returns Root node, or undefined.\n */\n get root() {\n return this._root;\n }\n /**\n * Create a red-black node for the given key/value (value ignored in map mode).\n * @remarks Time O(1), Space O(1)\n * @param key - See parameter type for details.\n * @param [value] - See parameter type for details.\n * @param color - See parameter type for details.\n * @returns A new RedBlackTreeNode instance.\n */\n createNode(key, value, color = \"BLACK\") {\n return new RedBlackTreeNode(key, value, color);\n }\n /**\n * Type guard: check whether the input is a RedBlackTreeNode.\n * @remarks Time O(1), Space O(1)\n * @param keyNodeOrEntry - See parameter type for details.\n * @returns True if the value is a RedBlackTreeNode.\n */\n isNode(keyNodeOrEntry) {\n return keyNodeOrEntry instanceof RedBlackTreeNode;\n }\n /**\n * Remove all nodes and clear the key→value store (if in map mode).\n * @remarks Time O(n), Space O(1)\n * @returns void\n */\n /**\n * Remove all nodes and clear internal caches.\n * @remarks Time O(n) average, Space O(1)\n */\n clear() {\n super.clear();\n this._root = this.NIL;\n this._header.parent = this.NIL;\n this._setMinCache(void 0);\n this._setMaxCache(void 0);\n }\n /**\n * (Internal) Find a node by key using a tight BST walk (no allocations).\n *\n * NOTE: This uses `header.parent` as the canonical root pointer.\n * @remarks Time O(log n) average, Space O(1)\n */\n _findNodeByKey(key) {\n var _a, _b, _c;\n const NIL = this.NIL;\n const cmp = this._compare.bind(this);\n let cur = (_a = this._header.parent) != null ? _a : NIL;\n while (cur !== NIL) {\n const c = cmp(key, cur.key);\n if (c < 0) cur = (_b = cur.left) != null ? _b : NIL;\n else if (c > 0) cur = (_c = cur.right) != null ? _c : NIL;\n else return cur;\n }\n return void 0;\n }\n /**\n * (Internal) In-order predecessor of a node in a BST.\n * @remarks Time O(log n) average, Space O(1)\n */\n _predecessorOf(node) {\n const NIL = this.NIL;\n if (node.left && node.left !== NIL) {\n let cur2 = node.left;\n while (cur2.right && cur2.right !== NIL) cur2 = cur2.right;\n return cur2;\n }\n let cur = node;\n let p = node.parent;\n while (p && cur === p.left) {\n cur = p;\n p = p.parent;\n }\n return p;\n }\n /**\n * (Internal) In-order successor of a node in a BST.\n * @remarks Time O(log n) average, Space O(1)\n */\n _successorOf(node) {\n const NIL = this.NIL;\n if (node.right && node.right !== NIL) {\n let cur2 = node.right;\n while (cur2.left && cur2.left !== NIL) cur2 = cur2.left;\n return cur2;\n }\n let cur = node;\n let p = node.parent;\n while (p && cur === p.right) {\n cur = p;\n p = p.parent;\n }\n return p;\n }\n /**\n * (Internal) Attach a new node directly under a known parent/side (no search).\n *\n * This is a performance-oriented helper used by boundary fast paths and hinted insertion.\n * It will:\n * - wire parent/child pointers (using accessors, so parent pointers are updated)\n * - initialize children to NIL\n * - mark the new node RED, then run insert fix-up\n *\n * Precondition: the chosen slot (parent.left/parent.right) is empty (NIL/null/undefined).\n * @remarks Time O(log n) average, Space O(1)\n */\n _attachNewNode(parent, side, node) {\n const NIL = this.NIL;\n node.parent = parent;\n if (side === \"left\") parent.left = node;\n else parent.right = node;\n node.left = NIL;\n node.right = NIL;\n node.color = \"RED\";\n this._insertFixup(node);\n if (this.isRealNode(this._root)) this._root.color = \"BLACK\";\n }\n /**\n * (Internal) a single source of truth for min/max is header._left/_right.\n * Keep legacy _minNode/_maxNode mirrored for compatibility.\n * @remarks Time O(1), Space O(1)\n */\n /**\n * (Internal) Update min cache pointers (header._left is the canonical min pointer).\n * @remarks Time O(1), Space O(1)\n */\n _setMinCache(node) {\n this._minNode = node;\n this._header._left = node != null ? node : this.NIL;\n }\n /**\n * (Internal) Update max cache pointers (header._right is the canonical max pointer).\n * @remarks Time O(1), Space O(1)\n */\n _setMaxCache(node) {\n this._maxNode = node;\n this._header._right = node != null ? node : this.NIL;\n }\n /**\n * (Internal) Core set implementation returning the affected node.\n *\n * Hot path goals:\n * - Avoid double walks (search+insert): do a single traversal that either updates or inserts.\n * - Use header min/max caches to fast-path boundary inserts.\n * - Keep header._left/_right as canonical min/max pointers.\n *\n * Return value:\n * - `{ node, created:false }` when an existing key is updated\n * - `{ node, created:true }` when a new node is inserted\n * - `undefined` only on unexpected internal failure.\n * @remarks Time O(log n) average, Space O(1)\n */\n _setKVNode(key, nextValue) {\n var _a, _b, _c, _d, _e, _f, _g;\n const NIL = this.NIL;\n const comparator = this._comparator;\n const header = this._header;\n const minN = (_a = header._left) != null ? _a : NIL;\n if (minN !== NIL) {\n const cMin = comparator(key, minN.key);\n if (cMin === 0) {\n minN.value = nextValue;\n if (this._isMapMode) this._store.set(key, minN);\n return { node: minN, created: false };\n }\n const minL = minN.left;\n if (cMin < 0 && (minL === NIL || minL === null || minL === void 0)) {\n const newNode2 = this.createNode(key, nextValue);\n this._attachNewNode(minN, \"left\", newNode2);\n if (this._isMapMode) this._store.set(newNode2.key, newNode2);\n this._size++;\n this._setMinCache(newNode2);\n if (header._right === NIL) this._setMaxCache(newNode2);\n return { node: newNode2, created: true };\n }\n if (cMin > 0) {\n const maxN = (_b = header._right) != null ? _b : NIL;\n const cMax = comparator(key, maxN.key);\n if (cMax === 0) {\n maxN.value = nextValue;\n if (this._isMapMode) this._store.set(key, maxN);\n return { node: maxN, created: false };\n }\n const maxR = maxN.right;\n if (cMax > 0 && (maxR === NIL || maxR === null || maxR === void 0)) {\n const newNode2 = this.createNode(key, nextValue);\n this._attachNewNode(maxN, \"right\", newNode2);\n if (this._isMapMode) this._store.set(newNode2.key, newNode2);\n this._size++;\n this._setMaxCache(newNode2);\n if (header._left === NIL) this._setMinCache(newNode2);\n return { node: newNode2, created: true };\n }\n }\n }\n const cmp = comparator;\n const isMapMode = this._isMapMode;\n const store = this._store;\n let current = (_c = this._header.parent) != null ? _c : NIL;\n let parent;\n let lastCompared = 0;\n while (current !== NIL) {\n parent = current;\n lastCompared = cmp(key, current.key);\n if (lastCompared < 0) current = (_d = current.left) != null ? _d : NIL;\n else if (lastCompared > 0) current = (_e = current.right) != null ? _e : NIL;\n else {\n current.value = nextValue;\n if (isMapMode) store.set(key, current);\n return { node: current, created: false };\n }\n }\n const newNode = this.createNode(key, nextValue);\n newNode.parent = parent;\n if (!parent) {\n this._setRoot(newNode);\n } else if (lastCompared < 0) {\n parent.left = newNode;\n } else {\n parent.right = newNode;\n }\n newNode.left = NIL;\n newNode.right = NIL;\n newNode.color = \"RED\";\n this._insertFixup(newNode);\n if (this.isRealNode(this._root)) this._root.color = \"BLACK\";\n else return void 0;\n if (isMapMode) store.set(newNode.key, newNode);\n this._size++;\n const hMin = (_f = this._header._left) != null ? _f : NIL;\n const hMax = (_g = this._header._right) != null ? _g : NIL;\n if (hMin === NIL || hMax === NIL) {\n this._setMinCache(newNode);\n this._setMaxCache(newNode);\n } else if (parent === hMax && lastCompared > 0) {\n this._setMaxCache(newNode);\n } else if (parent === hMin && lastCompared < 0) {\n this._setMinCache(newNode);\n } else {\n if (cmp(newNode.key, hMin.key) < 0) this._setMinCache(newNode);\n if (cmp(newNode.key, hMax.key) > 0) this._setMaxCache(newNode);\n }\n return { node: newNode, created: true };\n }\n /**\n * (Internal) Boolean wrapper around `_setKVNode`.\n *\n * Includes a map-mode update fast-path:\n * - If `isMapMode=true` and the key already exists in `_store`, then updating the value does not\n * require any tree search/rotation (tree shape depends only on key).\n * - This path is intentionally limited to `nextValue !== undefined` to preserve existing\n * semantics for `undefined` values.\n * @remarks Time O(log n) average, Space O(1)\n */\n _setKV(key, nextValue) {\n if (this._isMapMode) {\n const store = this._store;\n const node = store.get(key);\n if (node) {\n node.value = nextValue;\n return true;\n }\n }\n return this._setKVNode(key, nextValue) !== void 0;\n }\n /**\n * Insert/update using a hint node to speed up nearby insertions.\n *\n * close to the expected insertion position (often the previously returned node in a loop).\n *\n * When the hint is a good fit (sorted / nearly-sorted insertion), this can avoid most of the\n * normal root-to-leaf search and reduce constant factors.\n *\n * When the hint does not match (random workloads), this will fall back to the normal set path.\n * @remarks Time O(log n) average, Space O(1)\n */\n setWithHintNode(key, value, hint) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;\n if (!hint || !this.isRealNode(hint)) {\n return (_a = this._setKVNode(key, value)) == null ? void 0 : _a.node;\n }\n const cmp = this._compare.bind(this);\n const c0 = cmp(key, hint.key);\n if (c0 === 0) {\n hint.value = value;\n if (this._isMapMode) this._store.set(key, hint);\n return hint;\n }\n if (c0 < 0) {\n if (!this.isRealNode(hint.left)) {\n const newNode = this.createNode(key, value);\n if (!this.isRealNode(newNode)) return void 0;\n this._attachNewNode(hint, \"left\", newNode);\n if (this._isMapMode) this._store.set(key, newNode);\n this._size++;\n const NIL = this.NIL;\n const hMin = (_b = this._header._left) != null ? _b : NIL;\n if (hMin === NIL || this._compare(newNode.key, hMin.key) < 0) this._setMinCache(newNode);\n const hMax = (_c = this._header._right) != null ? _c : NIL;\n if (hMax === NIL || this._compare(newNode.key, hMax.key) > 0) this._setMaxCache(newNode);\n return newNode;\n }\n const pred = this._predecessorOf(hint);\n if (pred && cmp(pred.key, key) >= 0) {\n return (_d = this._setKVNode(key, value)) == null ? void 0 : _d.node;\n }\n if (pred && !this.isRealNode(pred.right)) {\n const newNode = this.createNode(key, value);\n if (!this.isRealNode(newNode)) return void 0;\n this._attachNewNode(pred, \"right\", newNode);\n if (this._isMapMode) this._store.set(key, newNode);\n this._size++;\n const NIL = this.NIL;\n const hMin = (_e = this._header._left) != null ? _e : NIL;\n if (hMin === NIL || this._compare(newNode.key, hMin.key) < 0) this._setMinCache(newNode);\n const hMax = (_f = this._header._right) != null ? _f : NIL;\n if (hMax === NIL || this._compare(newNode.key, hMax.key) > 0) this._setMaxCache(newNode);\n return newNode;\n }\n return (_g = this._setKVNode(key, value)) == null ? void 0 : _g.node;\n }\n if (!this.isRealNode(hint.right)) {\n const newNode = this.createNode(key, value);\n if (!this.isRealNode(newNode)) return void 0;\n this._attachNewNode(hint, \"right\", newNode);\n if (this._isMapMode) this._store.set(key, newNode);\n this._size++;\n const NIL = this.NIL;\n const hMin = (_h = this._header._left) != null ? _h : NIL;\n if (hMin === NIL || this._compare(newNode.key, hMin.key) < 0) this._setMinCache(newNode);\n const hMax = (_i = this._header._right) != null ? _i : NIL;\n if (hMax === NIL || this._compare(newNode.key, hMax.key) > 0) this._setMaxCache(newNode);\n return newNode;\n }\n const succ = this._successorOf(hint);\n if (succ && cmp(succ.key, key) <= 0) {\n return (_j = this._setKVNode(key, value)) == null ? void 0 : _j.node;\n }\n if (succ && !this.isRealNode(succ.left)) {\n const newNode = this.createNode(key, value);\n if (!this.isRealNode(newNode)) return void 0;\n this._attachNewNode(succ, \"left\", newNode);\n if (this._isMapMode) this._store.set(key, newNode);\n this._size++;\n const NIL = this.NIL;\n const hMin = (_k = this._header._left) != null ? _k : NIL;\n if (hMin === NIL || this._compare(newNode.key, hMin.key) < 0) this._setMinCache(newNode);\n const hMax = (_l = this._header._right) != null ? _l : NIL;\n if (hMax === NIL || this._compare(newNode.key, hMax.key) > 0) this._setMaxCache(newNode);\n return newNode;\n }\n return (_m = this._setKVNode(key, value)) == null ? void 0 : _m.node;\n }\n /**\n * Boolean wrapper for setWithHintNode.\n * @remarks Time O(log n) average, Space O(1)\n */\n setWithHint(key, value, hint) {\n return this.setWithHintNode(key, value, hint) !== void 0;\n }\n /**\n * Insert or update a key/value (map mode) or key-only (set mode).\n *\n * This method is optimized for:\n * - monotonic inserts via min/max boundary fast paths\n * - updates via a single-pass search (no double walk)\n *\n * @remarks Time O(log n) average, Space O(1)\n */\n set(keyNodeOrEntry, value) {\n if (!this.isNode(keyNodeOrEntry)) {\n if (keyNodeOrEntry === null || keyNodeOrEntry === void 0) return false;\n if (this.isEntry(keyNodeOrEntry)) {\n const key = keyNodeOrEntry[0];\n if (key === null || key === void 0) return false;\n const nextValue = value != null ? value : keyNodeOrEntry[1];\n return this._setKV(key, nextValue);\n }\n return this._setKV(keyNodeOrEntry, value);\n }\n const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);\n if (!this.isRealNode(newNode)) return false;\n const insertStatus = this._insert(newNode);\n if (insertStatus === \"CREATED\") {\n if (this.isRealNode(this._root)) {\n this._root.color = \"BLACK\";\n } else {\n return false;\n }\n if (this._isMapMode) {\n const n = this.getNode(newNode.key);\n if (this.isRealNode(n)) {\n n.value = newValue;\n this._store.set(n.key, n);\n }\n }\n this._size++;\n return true;\n }\n if (insertStatus === \"UPDATED\") {\n if (this._isMapMode) {\n const n = this.getNode(newNode.key);\n if (this.isRealNode(n)) {\n n.value = newValue;\n this._store.set(n.key, n);\n }\n }\n return true;\n }\n return false;\n }\n /**\n * Delete a node by key/node/entry and rebalance as needed.\n * @remarks Time O(log n) average, Space O(1)\n * @param keyNodeEntryRawOrPredicate - Key, node, or [key, value] entry identifying the node to delete.\n * @returns Array with deletion metadata (removed node, rebalancing hint if any).\n */\n delete(keyNodeEntryRawOrPredicate) {\n if (keyNodeEntryRawOrPredicate === null) return [];\n const results = [];\n let nodeToDelete;\n if (this._isPredicate(keyNodeEntryRawOrPredicate)) nodeToDelete = this.getNode(keyNodeEntryRawOrPredicate);\n else nodeToDelete = this.isRealNode(keyNodeEntryRawOrPredicate) ? keyNodeEntryRawOrPredicate : this.getNode(keyNodeEntryRawOrPredicate);\n if (!nodeToDelete) {\n return results;\n }\n const willDeleteMin = nodeToDelete === this._minNode;\n const willDeleteMax = nodeToDelete === this._maxNode;\n const nextMin = willDeleteMin ? this._successorOf(nodeToDelete) : void 0;\n const nextMax = willDeleteMax ? this._predecessorOf(nodeToDelete) : void 0;\n let originalColor = nodeToDelete.color;\n let replacementNode;\n if (!this.isRealNode(nodeToDelete.left)) {\n if (nodeToDelete.right !== null) {\n replacementNode = nodeToDelete.right;\n this._transplant(nodeToDelete, nodeToDelete.right);\n }\n } else if (!this.isRealNode(nodeToDelete.right)) {\n replacementNode = nodeToDelete.left;\n this._transplant(nodeToDelete, nodeToDelete.left);\n } else {\n const successor = this.getLeftMost((node) => node, nodeToDelete.right);\n if (successor) {\n originalColor = successor.color;\n if (successor.right !== null) replacementNode = successor.right;\n if (successor.parent === nodeToDelete) {\n if (this.isRealNode(replacementNode)) {\n replacementNode.parent = successor;\n }\n } else {\n if (successor.right !== null) {\n this._transplant(successor, successor.right);\n successor.right = nodeToDelete.right;\n }\n if (this.isRealNode(successor.right)) {\n successor.right.parent = successor;\n }\n }\n this._transplant(nodeToDelete, successor);\n successor.left = nodeToDelete.left;\n if (this.isRealNode(successor.left)) {\n successor.left.parent = successor;\n }\n successor.color = nodeToDelete.color;\n }\n }\n if (this._isMapMode) this._store.delete(nodeToDelete.key);\n this._size--;\n if (this._size <= 0) {\n this._setMinCache(void 0);\n this._setMaxCache(void 0);\n } else {\n if (willDeleteMin) this._setMinCache(nextMin);\n if (willDeleteMax) this._setMaxCache(nextMax);\n if (!this._minNode || !this.isRealNode(this._minNode)) {\n this._setMinCache(this.isRealNode(this._root) ? this.getLeftMost((n) => n, this._root) : void 0);\n }\n if (!this._maxNode || !this.isRealNode(this._maxNode)) {\n this._setMaxCache(this.isRealNode(this._root) ? this.getRightMost((n) => n, this._root) : void 0);\n }\n }\n if (originalColor === \"BLACK\") {\n this._deleteFixup(replacementNode);\n }\n results.push({ deleted: nodeToDelete, needBalanced: void 0 });\n return results;\n }\n /**\n * Transform entries into a like-kind red-black tree with possibly different key/value types.\n * @remarks Time O(n) average, Space O(n)\n * @template MK\n * @template MV\n * @template MR\n * @param callback - Mapping function from (key, value, index, tree) to a new [key, value].\n * @param [options] - See parameter type for details.\n * @param [thisArg] - See parameter type for details.\n * @returns A new RedBlackTree with mapped entries.\n */\n map(callback, options, thisArg) {\n const out = this._createLike([], options);\n let index = 0;\n for (const [key, value] of this) {\n out.set(callback.call(thisArg, value, key, index++, this));\n }\n return out;\n }\n /**\n * (Internal) Create an empty instance of the same concrete tree type.\n * @remarks Time O(1) average, Space O(1)\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n return new Ctor([], { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Internal) Create a like-kind tree (same concrete class) populated from an iterable.\n * @remarks Time O(m log m) average (m = iterable length), Space O(m)\n */\n _createLike(iter = [], options) {\n const Ctor = this.constructor;\n return new Ctor(iter, { ...this._snapshotOptions(), ...options != null ? options : {} });\n }\n /**\n * (Internal) Set the root pointer and keep header.parent in sync.\n * @remarks Time O(1), Space O(1)\n */\n _setRoot(v) {\n const NIL = this.NIL;\n if (v) {\n v.parent = void 0;\n }\n this._root = v;\n this._header.parent = v != null ? v : NIL;\n }\n /**\n * (Internal) Replace a node in place while preserving its color.\n * @remarks Time O(1) average, Space O(1)\n */\n _replaceNode(oldNode, newNode) {\n newNode.color = oldNode.color;\n return super._replaceNode(oldNode, newNode);\n }\n /**\n * (Protected) Standard BST insert followed by red-black fix-up.\n * @remarks Time O(log n) average, Space O(1)\n * @param node - Node to insert.\n * @returns Status string: 'CREATED' or 'UPDATED'.\n */\n _insert(node) {\n var _a, _b, _c;\n const NIL = this.NIL;\n const cmp = this._compare.bind(this);\n let current = (_a = this._header.parent) != null ? _a : NIL;\n let parent;\n let lastCompared = 0;\n while (current !== NIL) {\n parent = current;\n lastCompared = cmp(node.key, current.key);\n if (lastCompared < 0) {\n current = (_b = current.left) != null ? _b : NIL;\n } else if (lastCompared > 0) {\n current = (_c = current.right) != null ? _c : NIL;\n } else {\n this._replaceNode(current, node);\n return \"UPDATED\";\n }\n }\n node.parent = parent;\n if (!parent) {\n this._setRoot(node);\n } else if (lastCompared < 0) {\n parent.left = node;\n } else {\n parent.right = node;\n }\n node.left = NIL;\n node.right = NIL;\n node.color = \"RED\";\n this._insertFixup(node);\n return \"CREATED\";\n }\n /**\n * (Protected) Transplant a subtree in place of another during deletion.\n * @remarks Time O(1), Space O(1)\n * @param u - Node to replace.\n * @param v - Replacement subtree root (may be undefined).\n * @returns void\n */\n _transplant(u, v) {\n if (!u.parent) {\n this._setRoot(v);\n } else if (u === u.parent.left) {\n u.parent.left = v;\n } else {\n u.parent.right = v;\n }\n if (v) {\n v.parent = u.parent;\n }\n }\n /**\n * (Protected) Restore red-black properties after insertion (recolor/rotate).\n * @remarks Time O(log n) average, Space O(1)\n * @param z - Recently inserted node.\n * @returns void\n */\n _insertFixup(z) {\n const leftRotate = this._leftRotate.bind(this);\n const rightRotate = this._rightRotate.bind(this);\n while (z) {\n const p = z.parent;\n if (!p || p.color !== \"RED\") break;\n const gp = p.parent;\n if (!gp) break;\n if (p === gp.left) {\n const y = gp.right;\n if ((y == null ? void 0 : y.color) === \"RED\") {\n p.color = \"BLACK\";\n y.color = \"BLACK\";\n gp.color = \"RED\";\n z = gp;\n continue;\n }\n if (z === p.right) {\n z = p;\n leftRotate(z);\n }\n const p2 = z == null ? void 0 : z.parent;\n const gp2 = p2 == null ? void 0 : p2.parent;\n if (p2 && gp2) {\n p2.color = \"BLACK\";\n gp2.color = \"RED\";\n rightRotate(gp2);\n }\n } else {\n const y = gp.left;\n if ((y == null ? void 0 : y.color) === \"RED\") {\n p.color = \"BLACK\";\n y.color = \"BLACK\";\n gp.color = \"RED\";\n z = gp;\n continue;\n }\n if (z === p.left) {\n z = p;\n rightRotate(z);\n }\n const p2 = z == null ? void 0 : z.parent;\n const gp2 = p2 == null ? void 0 : p2.parent;\n if (p2 && gp2) {\n p2.color = \"BLACK\";\n gp2.color = \"RED\";\n leftRotate(gp2);\n }\n }\n break;\n }\n if (this.isRealNode(this._root)) this._root.color = \"BLACK\";\n }\n /**\n * (Protected) Restore red-black properties after deletion (recolor/rotate).\n * @remarks Time O(log n) average, Space O(1)\n * @param node - Child that replaced the deleted node (may be undefined).\n * @returns void\n */\n _deleteFixup(node) {\n var _a, _b, _c, _d;\n if (!node || node === this.root || node.color === \"BLACK\") {\n if (node) {\n node.color = \"BLACK\";\n }\n return;\n }\n while (node && node !== this.root && node.color === \"BLACK\") {\n const parent = node.parent;\n if (!parent) {\n break;\n }\n if (node === parent.left) {\n let sibling = parent.right;\n if ((sibling == null ? void 0 : sibling.color) === \"RED\") {\n sibling.color = \"BLACK\";\n parent.color = \"RED\";\n this._leftRotate(parent);\n sibling = parent.right;\n }\n if (((_b = (_a = sibling == null ? void 0 : sibling.left) == null ? void 0 : _a.color) != null ? _b : \"BLACK\") === \"BLACK\") {\n if (sibling) sibling.color = \"RED\";\n node = parent;\n } else {\n if (sibling == null ? void 0 : sibling.left) sibling.left.color = \"BLACK\";\n if (sibling) sibling.color = parent.color;\n parent.color = \"BLACK\";\n this._rightRotate(parent);\n node = this.root;\n }\n } else {\n let sibling = parent.left;\n if ((sibling == null ? void 0 : sibling.color) === \"RED\") {\n sibling.color = \"BLACK\";\n if (parent) parent.color = \"RED\";\n this._rightRotate(parent);\n if (parent) sibling = parent.left;\n }\n if (((_d = (_c = sibling == null ? void 0 : sibling.right) == null ? void 0 : _c.color) != null ? _d : \"BLACK\") === \"BLACK\") {\n if (sibling) sibling.color = \"RED\";\n node = parent;\n } else {\n if (sibling == null ? void 0 : sibling.right) sibling.right.color = \"BLACK\";\n if (sibling) sibling.color = parent.color;\n if (parent) parent.color = \"BLACK\";\n this._leftRotate(parent);\n node = this.root;\n }\n }\n }\n if (node) {\n node.color = \"BLACK\";\n }\n }\n /**\n * (Protected) Perform a left rotation around x.\n * @remarks Time O(1), Space O(1)\n * @param x - Pivot node to rotate around.\n * @returns void\n */\n _leftRotate(x) {\n if (!x || !x.right) {\n return;\n }\n const y = x.right;\n x.right = y.left;\n if (y.left && y.left !== this.NIL) {\n y.left.parent = x;\n }\n y.parent = x.parent;\n if (!x.parent) {\n this._setRoot(y);\n } else if (x === x.parent.left) {\n x.parent.left = y;\n } else {\n x.parent.right = y;\n }\n y.left = x;\n x.parent = y;\n }\n /**\n * (Protected) Perform a right rotation around y.\n * @remarks Time O(1), Space O(1)\n * @param y - Pivot node to rotate around.\n * @returns void\n */\n _rightRotate(y) {\n if (!y || !y.left) {\n return;\n }\n const x = y.left;\n y.left = x.right;\n if (x.right && x.right !== this.NIL) {\n x.right.parent = y;\n }\n x.parent = y.parent;\n if (!y.parent) {\n this._setRoot(x);\n } else if (y === y.parent.left) {\n y.parent.left = x;\n } else {\n y.parent.right = x;\n }\n x.right = y;\n y.parent = x;\n }\n};\n__name(_RedBlackTree, \"RedBlackTree\");\nvar RedBlackTree = _RedBlackTree;\n\n// src/data-structures/binary-tree/tree-set.ts\nvar _core, _isDefaultComparator, _userComparator;\nvar _TreeSet = class _TreeSet {\n /**\n * Create a TreeSet from an iterable of keys or raw elements.\n *\n * @param elements - Iterable of keys, or raw elements if `toElementFn` is provided.\n * @param options - Configuration options including optional `toElementFn` to transform raw elements.\n * @throws {TypeError} When using the default comparator and encountering unsupported key types,\n * or invalid keys (e.g. `NaN`, invalid `Date`).\n * @example\n * // Standard usage with keys\n * const set = new TreeSet([3, 1, 2]);\n *\n * // Using toElementFn to transform raw objects\n * const users = [{ id: 3, name: 'Alice' }, { id: 1, name: 'Bob' }];\n * const set = new TreeSet<number, User>(users, { toElementFn: u => u.id });\n */\n constructor(elements = [], options = {}) {\n __privateAdd(this, _core);\n __privateAdd(this, _isDefaultComparator);\n __privateAdd(this, _userComparator);\n var _a;\n __privateSet(this, _userComparator, options.comparator);\n const toElementFn = options.toElementFn;\n const comparator = (_a = options.comparator) != null ? _a : _TreeSet.createDefaultComparator();\n __privateSet(this, _isDefaultComparator, options.comparator === void 0);\n __privateSet(this, _core, new RedBlackTree([], { comparator, isMapMode: options.isMapMode }));\n for (const item of elements) {\n const k = toElementFn ? toElementFn(item) : item;\n this.add(k);\n }\n }\n /**\n * Create the strict default comparator.\n *\n * Supports:\n * - `number` (rejects `NaN`; treats `-0` and `0` as equal)\n * - `string`\n * - `Date` (orders by `getTime()`, rejects invalid dates)\n *\n * For other key types, a custom comparator must be provided.\n */\n static createDefaultComparator() {\n return (a, b) => {\n if (typeof a === \"number\" && typeof b === \"number\") {\n if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(\"TreeSet: NaN is not a valid key\");\n const aa = Object.is(a, -0) ? 0 : a;\n const bb = Object.is(b, -0) ? 0 : b;\n return aa > bb ? 1 : aa < bb ? -1 : 0;\n }\n if (typeof a === \"string\" && typeof b === \"string\") {\n return a > b ? 1 : a < b ? -1 : 0;\n }\n if (a instanceof Date && b instanceof Date) {\n const ta = a.getTime();\n const tb = b.getTime();\n if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(\"TreeSet: invalid Date key\");\n return ta > tb ? 1 : ta < tb ? -1 : 0;\n }\n throw new TypeError(\"TreeSet: comparator is required for non-number/non-string/non-Date keys\");\n };\n }\n /**\n * Number of elements in the set.\n */\n get size() {\n return __privateGet(this, _core).size;\n }\n /**\n * Whether the set is empty.\n */\n isEmpty() {\n return this.size === 0;\n }\n _validateKey(key) {\n if (!__privateGet(this, _isDefaultComparator)) return;\n if (typeof key === \"number\") {\n if (Number.isNaN(key)) throw new TypeError(\"TreeSet: NaN is not a valid key\");\n return;\n }\n if (typeof key === \"string\") return;\n if (key instanceof Date) {\n if (Number.isNaN(key.getTime())) throw new TypeError(\"TreeSet: invalid Date key\");\n return;\n }\n throw new TypeError(\"TreeSet: comparator is required for non-number/non-string/non-Date keys\");\n }\n /**\n * Add a key to the set (no-op if already present).\n * @remarks Expected time O(log n)\n */\n add(key) {\n this._validateKey(key);\n __privateGet(this, _core).set(key, void 0);\n return this;\n }\n /**\n * Test whether a key exists.\n * @remarks Expected time O(log n)\n */\n has(key) {\n this._validateKey(key);\n return __privateGet(this, _core).has(key);\n }\n /**\n * Delete a key.\n * @returns `true` if the key existed; otherwise `false`.\n * @remarks Expected time O(log n)\n */\n delete(key) {\n var _a;\n this._validateKey(key);\n const res = __privateGet(this, _core).delete(key);\n return Array.isArray(res) && res.length > 0 && !!((_a = res[0]) == null ? void 0 : _a.deleted);\n }\n /**\n * Remove all keys.\n */\n clear() {\n __privateGet(this, _core).clear();\n }\n /**\n * Iterate over keys in ascending order.\n */\n keys() {\n return __privateGet(this, _core).keys();\n }\n /**\n * Iterate over values in ascending order.\n *\n * Note: for Set-like containers, `values()` is the same as `keys()`.\n */\n values() {\n return this.keys();\n }\n /**\n * Iterate over `[value, value]` pairs (native Set convention).\n *\n * Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during iteration.\n */\n *entries() {\n for (const k of this.keys()) yield [k, k];\n }\n [Symbol.iterator]() {\n return this.keys();\n }\n /**\n * Visit each value in ascending order.\n *\n * Callback follows native Set convention: `(value, value2, set)`.\n */\n forEach(cb, thisArg) {\n for (const k of this) cb.call(thisArg, k, k, this);\n }\n /**\n * Create a new TreeSet by mapping each value to a new key.\n *\n * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.\n * @remarks Time O(n log n) expected, Space O(n)\n */\n map(callbackfn, options = {}, thisArg) {\n const out = new _TreeSet([], options);\n let index = 0;\n for (const v of this) {\n const mk = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);\n out.add(mk);\n }\n return out;\n }\n /**\n * Create a new TreeSet containing only values that satisfy the predicate.\n * @remarks Time O(n log n) expected, Space O(n)\n */\n filter(callbackfn, thisArg) {\n const out = new _TreeSet([], { comparator: __privateGet(this, _userComparator) });\n let index = 0;\n for (const v of this) {\n const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);\n if (ok) out.add(v);\n }\n return out;\n }\n /**\n * Reduce values into a single accumulator.\n * @remarks Time O(n), Space O(1)\n */\n reduce(callbackfn, initialValue) {\n let acc = initialValue;\n let index = 0;\n for (const v of this) acc = callbackfn(acc, v, index++, this);\n return acc;\n }\n /**\n * Test whether all values satisfy a predicate.\n * @remarks Time O(n), Space O(1)\n */\n every(callbackfn, thisArg) {\n let index = 0;\n for (const v of this) {\n const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);\n if (!ok) return false;\n }\n return true;\n }\n /**\n * Test whether any value satisfies a predicate.\n * @remarks Time O(n), Space O(1)\n */\n some(callbackfn, thisArg) {\n let index = 0;\n for (const v of this) {\n const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);\n if (ok) return true;\n }\n return false;\n }\n /**\n * Find the first value that satisfies a predicate.\n * @remarks Time O(n), Space O(1)\n */\n find(callbackfn, thisArg) {\n let index = 0;\n for (const v of this) {\n const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);\n if (ok) return v;\n }\n return void 0;\n }\n /**\n * Materialize the set into an array of keys.\n * @remarks Time O(n), Space O(n)\n */\n toArray() {\n return [...this];\n }\n /**\n * Print a human-friendly representation.\n * @remarks Time O(n), Space O(n)\n */\n print() {\n __privateGet(this, _core).print();\n }\n // Navigable operations\n /**\n * Smallest key in the set.\n */\n first() {\n return __privateGet(this, _core).getLeftMost();\n }\n /**\n * Largest key in the set.\n */\n last() {\n return __privateGet(this, _core).getRightMost();\n }\n /**\n * Remove and return the smallest key.\n */\n pollFirst() {\n const k = this.first();\n if (k === void 0) return void 0;\n this.delete(k);\n return k;\n }\n /**\n * Remove and return the largest key.\n */\n pollLast() {\n const k = this.last();\n if (k === void 0) return void 0;\n this.delete(k);\n return k;\n }\n /**\n * Smallest key that is >= the given key.\n */\n ceiling(key) {\n this._validateKey(key);\n return __privateGet(this, _core).ceiling(key);\n }\n /**\n * Largest key that is <= the given key.\n */\n floor(key) {\n this._validateKey(key);\n return __privateGet(this, _core).floor(key);\n }\n /**\n * Smallest key that is > the given key.\n */\n higher(key) {\n this._validateKey(key);\n return __privateGet(this, _core).higher(key);\n }\n /**\n * Largest key that is < the given key.\n */\n lower(key) {\n this._validateKey(key);\n return __privateGet(this, _core).lower(key);\n }\n /**\n * Return all keys in a given range.\n *\n * @param range `[low, high]`\n * @param options Inclusive/exclusive bounds (defaults to inclusive).\n */\n rangeSearch(range, options = {}) {\n const { lowInclusive = true, highInclusive = true } = options;\n const [low, high] = range;\n this._validateKey(low);\n this._validateKey(high);\n const keys = __privateGet(this, _core).rangeSearch([low, high]);\n const out = [];\n const cmp = __privateGet(this, _core).comparator;\n for (const k of keys) {\n if (k === void 0) continue;\n if (!lowInclusive && cmp(k, low) === 0) continue;\n if (!highInclusive && cmp(k, high) === 0) continue;\n out.push(k);\n }\n return out;\n }\n /**\n * Creates a shallow clone of this set.\n * @remarks Time O(n log n), Space O(n)\n * @example\n * const original = new TreeSet([1, 2, 3]);\n * const copy = original.clone();\n * copy.add(4);\n * original.has(4); // false (original unchanged)\n */\n clone() {\n return new _TreeSet(this, {\n comparator: __privateGet(this, _isDefaultComparator) ? void 0 : __privateGet(this, _userComparator),\n isMapMode: __privateGet(this, _core).isMapMode\n });\n }\n};\n_core = new WeakMap();\n_isDefaultComparator = new WeakMap();\n_userComparator = new WeakMap();\n__name(_TreeSet, \"TreeSet\");\nvar TreeSet = _TreeSet;\n\n// src/data-structures/binary-tree/tree-multi-map.ts\nvar _TreeMultiMapNode = class _TreeMultiMapNode extends RedBlackTreeNode {\n constructor(key, value = []) {\n super(key, value);\n }\n};\n__name(_TreeMultiMapNode, \"TreeMultiMapNode\");\nvar TreeMultiMapNode = _TreeMultiMapNode;\nvar _core2, _isDefaultComparator2;\nvar _TreeMultiMap = class _TreeMultiMap {\n /**\n * Creates a new TreeMultiMap.\n * @param keysNodesEntriesOrRaws - Initial entries, or raw elements if `toEntryFn` is provided.\n * @param options - Configuration options including optional `toEntryFn` to transform raw elements.\n * @remarks Time O(m log m), Space O(m) where m is the number of initial entries\n * @example\n * // Standard usage with entries\n * const mmap = new TreeMultiMap([['a', ['x', 'y']], ['b', ['z']]]);\n *\n * // Using toEntryFn to transform raw objects\n * const players = [{ score: 100, items: ['sword'] }, { score: 200, items: ['shield', 'bow'] }];\n * const mmap = new TreeMultiMap(players, { toEntryFn: p => [p.score, p.items] });\n */\n constructor(keysNodesEntriesOrRaws = [], options = {}) {\n __privateAdd(this, _core2);\n __privateAdd(this, _isDefaultComparator2);\n var _a;\n const comparator = (_a = options.comparator) != null ? _a : TreeSet.createDefaultComparator();\n __privateSet(this, _isDefaultComparator2, options.comparator === void 0);\n const toEntryFn = options.toEntryFn;\n __privateSet(this, _core2, new RedBlackTree([], { ...options, comparator, isMapMode: options.isMapMode }));\n for (const x of keysNodesEntriesOrRaws) {\n if (x === null || x === void 0) continue;\n if (toEntryFn) {\n const [k, bucket] = toEntryFn(x);\n if (k === null || k === void 0) continue;\n if (bucket !== void 0) {\n __privateGet(this, _core2).set(k, Array.isArray(bucket) ? [...bucket] : [bucket]);\n } else {\n __privateGet(this, _core2).set(k, []);\n }\n continue;\n }\n if (Array.isArray(x)) {\n const [k, bucket] = x;\n if (k === null || k === void 0) continue;\n if (bucket !== void 0) {\n __privateGet(this, _core2).set(k, [...bucket]);\n } else {\n __privateGet(this, _core2).set(k, []);\n }\n continue;\n }\n __privateGet(this, _core2).set(x, []);\n }\n }\n /**\n * Validates the key against the default comparator rules.\n * @remarks Time O(1), Space O(1)\n */\n _validateKey(key) {\n if (!__privateGet(this, _isDefaultComparator2)) return;\n if (typeof key === \"number\") {\n if (Number.isNaN(key)) throw new TypeError(\"TreeMultiMap: NaN is not a valid key\");\n return;\n }\n if (typeof key === \"string\") return;\n if (key instanceof Date) {\n if (Number.isNaN(key.getTime())) throw new TypeError(\"TreeMultiMap: invalid Date key\");\n return;\n }\n throw new TypeError(\"TreeMultiMap: comparator is required for non-number/non-string/non-Date keys\");\n }\n /**\n * Number of distinct keys.\n * @remarks Time O(1), Space O(1)\n */\n get size() {\n return __privateGet(this, _core2).size;\n }\n /**\n * Whether the map is empty.\n * @remarks Time O(1), Space O(1)\n */\n isEmpty() {\n return this.size === 0;\n }\n /**\n * Removes all entries from the map.\n * @remarks Time O(1), Space O(1)\n */\n clear() {\n __privateGet(this, _core2).clear();\n }\n /**\n * Bucket length for a key (missing => 0).\n * @remarks Time O(log n), Space O(1)\n */\n count(key) {\n const b = this.get(key);\n return Array.isArray(b) ? b.length : 0;\n }\n /**\n * Total number of values across all buckets (Σ bucket.length).\n * @remarks Time O(n), Space O(1)\n */\n get totalSize() {\n let sum = 0;\n for (const [, bucket] of this) sum += bucket.length;\n return sum;\n }\n /**\n * Whether the map contains the given key.\n * @remarks Time O(log n), Space O(1)\n */\n has(key) {\n this._validateKey(key);\n return __privateGet(this, _core2).has(key);\n }\n /**\n * Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).\n * @remarks Time O(log n), Space O(1)\n */\n get(key) {\n this._validateKey(key);\n return __privateGet(this, _core2).get(key);\n }\n /**\n * Append a single value.\n * @remarks Time O(log n), Space O(1)\n */\n add(key, value) {\n this._validateKey(key);\n const bucket = __privateGet(this, _core2).get(key);\n if (bucket) {\n bucket.push(value);\n return true;\n }\n return __privateGet(this, _core2).set(key, [value]);\n }\n set(entry, value) {\n if (entry === null || entry === void 0) return false;\n if (Array.isArray(entry)) {\n const [k, bucket] = entry;\n if (k === null || k === void 0) return false;\n if (value !== void 0) return this.add(k, value);\n if (bucket === void 0) {\n return __privateGet(this, _core2).set(k, []);\n }\n const existing = __privateGet(this, _core2).get(k);\n if (existing) {\n existing.push(...bucket);\n return true;\n }\n return __privateGet(this, _core2).set(k, [...bucket]);\n }\n if (value !== void 0) return this.add(entry, value);\n return __privateGet(this, _core2).set(entry, []);\n }\n /**\n * Deletes a key and its entire bucket.\n * @remarks Time O(log n), Space O(1)\n */\n delete(key) {\n this._validateKey(key);\n return __privateGet(this, _core2).delete(key).length > 0;\n }\n /**\n * Check if a specific value exists in a key's bucket.\n * @remarks Time O(log n + m), Space O(1) where m is bucket size\n */\n hasEntry(key, value, eq = Object.is) {\n const bucket = this.get(key);\n if (!Array.isArray(bucket)) return false;\n return bucket.some((v) => eq(v, value));\n }\n /**\n * Delete a single occurrence of a value from a key's bucket.\n * @remarks Time O(log n + m), Space O(1) where m is bucket size\n */\n deleteValue(key, value, eq = Object.is) {\n const bucket = this.get(key);\n if (!Array.isArray(bucket)) return false;\n const idx = bucket.findIndex((v) => eq(v, value));\n if (idx === -1) return false;\n bucket.splice(idx, 1);\n if (bucket.length === 0) this.delete(key);\n return true;\n }\n /**\n * Delete all occurrences of a value from a key's bucket.\n * @remarks Time O(log n + m), Space O(1) where m is bucket size\n */\n deleteValues(key, value, eq = Object.is) {\n const bucket = this.get(key);\n if (!Array.isArray(bucket) || bucket.length === 0) return 0;\n let removed = 0;\n for (let i = bucket.length - 1; i >= 0; i--) {\n if (eq(bucket[i], value)) {\n bucket.splice(i, 1);\n removed++;\n }\n }\n if (bucket.length === 0 && removed > 0) this.delete(key);\n return removed;\n }\n // ---- iteration (bucket view) ----\n /**\n * Iterates over all entries as [key, bucket] pairs.\n * @remarks Time O(n), Space O(1)\n */\n *[Symbol.iterator]() {\n for (const [k, v] of __privateGet(this, _core2)) {\n yield [k, v != null ? v : []];\n }\n }\n /**\n * Iterates over all keys.\n * @remarks Time O(n), Space O(1)\n */\n *keys() {\n yield* __privateGet(this, _core2).keys();\n }\n /**\n * Iterates over all buckets.\n * @remarks Time O(n), Space O(1)\n */\n *values() {\n for (const [, bucket] of this) yield bucket;\n }\n // ---- entry-flat views ----\n /**\n * Iterates over all entries for a specific key.\n * @remarks Time O(log n + m), Space O(1) where m is bucket size\n */\n *entriesOf(key) {\n const bucket = this.get(key);\n if (!Array.isArray(bucket)) return;\n for (const v of bucket) yield [key, v];\n }\n /**\n * Iterates over all values for a specific key.\n * @remarks Time O(log n + m), Space O(1) where m is bucket size\n */\n *valuesOf(key) {\n const bucket = this.get(key);\n if (!Array.isArray(bucket)) return;\n yield* bucket;\n }\n /**\n * Iterates over all [key, value] pairs (flattened from buckets).\n * @remarks Time O(T), Space O(1) where T is totalSize\n */\n *flatEntries() {\n for (const [k, bucket] of this) {\n for (const v of bucket) yield [k, v];\n }\n }\n // ━━━ Navigable methods (return [K, V[]] | undefined) ━━━\n /**\n * Returns the entry with the smallest key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);\n * map.first(); // [1, ['a']]\n */\n first() {\n const k = __privateGet(this, _core2).getLeftMost();\n if (k === void 0) return void 0;\n const b = this.get(k);\n return b === void 0 ? void 0 : [k, b];\n }\n /**\n * Returns the entry with the largest key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);\n * map.last(); // [2, ['b']]\n */\n last() {\n const k = __privateGet(this, _core2).getRightMost();\n if (k === void 0) return void 0;\n const b = this.get(k);\n return b === void 0 ? void 0 : [k, b];\n }\n /**\n * Removes and returns the entry with the smallest key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);\n * map.pollFirst(); // [1, ['a']]\n * map.has(1); // false\n */\n pollFirst() {\n const e = this.first();\n if (!e) return void 0;\n this.delete(e[0]);\n return e;\n }\n /**\n * Removes and returns the entry with the largest key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);\n * map.pollLast(); // [2, ['b']]\n * map.has(2); // false\n */\n pollLast() {\n const e = this.last();\n if (!e) return void 0;\n this.delete(e[0]);\n return e;\n }\n /**\n * Returns the entry with the smallest key >= given key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);\n * map.ceiling(15); // [20, ['b']]\n * map.ceiling(20); // [20, ['b']]\n */\n ceiling(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core2).ceiling(key);\n if (k === void 0) return void 0;\n const b = this.get(k);\n return b === void 0 ? void 0 : [k, b];\n }\n /**\n * Returns the entry with the largest key <= given key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);\n * map.floor(25); // [20, ['b']]\n * map.floor(20); // [20, ['b']]\n */\n floor(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core2).floor(key);\n if (k === void 0) return void 0;\n const b = this.get(k);\n return b === void 0 ? void 0 : [k, b];\n }\n /**\n * Returns the entry with the smallest key > given key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);\n * map.higher(10); // [20, ['b']]\n * map.higher(15); // [20, ['b']]\n */\n higher(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core2).higher(key);\n if (k === void 0) return void 0;\n const b = this.get(k);\n return b === void 0 ? void 0 : [k, b];\n }\n /**\n * Returns the entry with the largest key < given key.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);\n * map.lower(20); // [10, ['a']]\n * map.lower(15); // [10, ['a']]\n */\n lower(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core2).lower(key);\n if (k === void 0) return void 0;\n const b = this.get(k);\n return b === void 0 ? void 0 : [k, b];\n }\n // ━━━ Tree utilities ━━━\n /**\n * Prints the internal tree structure (for debugging).\n * @remarks Time O(n), Space O(n)\n */\n print() {\n __privateGet(this, _core2).print();\n }\n /**\n * Executes a callback for each entry.\n * @remarks Time O(n), Space O(1)\n */\n forEach(callback) {\n for (const [k, v] of this) {\n callback(v, k, this);\n }\n }\n /**\n * Creates a new map with entries that pass the predicate.\n * @remarks Time O(n), Space O(n)\n */\n filter(predicate) {\n const filtered = [];\n for (const [k, v] of this) {\n if (predicate(v, k, this)) filtered.push([k, v]);\n }\n return new _TreeMultiMap(filtered, { comparator: this.comparator });\n }\n /**\n * Creates a new map by transforming each entry.\n * @remarks Time O(n log n), Space O(n)\n */\n map(mapper) {\n const mapped = [];\n for (const [k, v] of this) {\n mapped.push(mapper(v, k, this));\n }\n return new _TreeMultiMap(mapped, { comparator: this.comparator });\n }\n /**\n * Reduces all entries to a single value.\n * @remarks Time O(n), Space O(1)\n */\n reduce(callback, initialValue) {\n let acc = initialValue;\n for (const [k, v] of this) {\n acc = callback(acc, v, k, this);\n }\n return acc;\n }\n /**\n * Sets multiple entries at once.\n * @remarks Time O(m log n), Space O(m) where m is input size\n */\n setMany(keysNodesEntriesOrRaws) {\n const results = [];\n for (const x of keysNodesEntriesOrRaws) {\n results.push(this.set(x));\n }\n return results;\n }\n /**\n * Searches for entries within a key range.\n * @remarks Time O(log n + k), Space O(k) where k is result size\n */\n rangeSearch(range, callback) {\n return __privateGet(this, _core2).rangeSearch(range, callback);\n }\n /**\n * Creates a shallow clone of this map.\n * @remarks Time O(n log n), Space O(n)\n */\n clone() {\n return new _TreeMultiMap(this, { comparator: this.comparator, isMapMode: __privateGet(this, _core2).isMapMode });\n }\n /**\n * Expose comparator for advanced usage/testing (read-only).\n * @remarks Time O(1), Space O(1)\n */\n get comparator() {\n return __privateGet(this, _core2).comparator;\n }\n};\n_core2 = new WeakMap();\n_isDefaultComparator2 = new WeakMap();\n__name(_TreeMultiMap, \"TreeMultiMap\");\nvar TreeMultiMap = _TreeMultiMap;\n\n// src/data-structures/binary-tree/tree-map.ts\nvar _core3, _isDefaultComparator3, _userComparator2;\nvar _TreeMap = class _TreeMap {\n /**\n * Create a TreeMap from an iterable of `[key, value]` entries or raw elements.\n *\n * @param entries - Iterable of `[key, value]` tuples, or raw elements if `toEntryFn` is provided.\n * @param options - Configuration options including optional `toEntryFn` to transform raw elements.\n * @throws {TypeError} If any entry is not a 2-tuple-like value (when no toEntryFn), or when using\n * the default comparator and encountering unsupported/invalid keys (e.g. `NaN`, invalid `Date`).\n * @example\n * // Standard usage with entries\n * const map = new TreeMap([['a', 1], ['b', 2]]);\n *\n * // Using toEntryFn to transform raw objects\n * const users = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const map = new TreeMap<number, User, User>(users, { toEntryFn: u => [u.id, u] });\n */\n constructor(entries = [], options = {}) {\n __privateAdd(this, _core3);\n __privateAdd(this, _isDefaultComparator3);\n __privateAdd(this, _userComparator2);\n var _a;\n __privateSet(this, _userComparator2, options.comparator);\n const toEntryFn = options.toEntryFn;\n const comparator = (_a = options.comparator) != null ? _a : _TreeMap.createDefaultComparator();\n __privateSet(this, _isDefaultComparator3, options.comparator === void 0);\n __privateSet(this, _core3, new RedBlackTree([], { comparator, isMapMode: options.isMapMode }));\n for (const item of entries) {\n let k;\n let v;\n if (toEntryFn) {\n [k, v] = toEntryFn(item);\n } else {\n if (!Array.isArray(item) || item.length < 2) {\n throw new TypeError(\"TreeMap: each entry must be a [key, value] tuple\");\n }\n k = item[0];\n v = item[1];\n }\n this.set(k, v);\n }\n }\n /**\n * Create the strict default comparator.\n *\n * Supports:\n * - `number` (rejects `NaN`; treats `-0` and `0` as equal)\n * - `string`\n * - `Date` (orders by `getTime()`, rejects invalid dates)\n *\n * For other key types, a custom comparator must be provided.\n */\n static createDefaultComparator() {\n return (a, b) => {\n if (typeof a === \"number\" && typeof b === \"number\") {\n if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(\"TreeMap: NaN is not a valid key\");\n const aa = Object.is(a, -0) ? 0 : a;\n const bb = Object.is(b, -0) ? 0 : b;\n return aa > bb ? 1 : aa < bb ? -1 : 0;\n }\n if (typeof a === \"string\" && typeof b === \"string\") {\n return a > b ? 1 : a < b ? -1 : 0;\n }\n if (a instanceof Date && b instanceof Date) {\n const ta = a.getTime();\n const tb = b.getTime();\n if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(\"TreeMap: invalid Date key\");\n return ta > tb ? 1 : ta < tb ? -1 : 0;\n }\n throw new TypeError(\"TreeMap: comparator is required for non-number/non-string/non-Date keys\");\n };\n }\n _validateKey(key) {\n if (!__privateGet(this, _isDefaultComparator3)) return;\n if (typeof key === \"number\") {\n if (Number.isNaN(key)) throw new TypeError(\"TreeMap: NaN is not a valid key\");\n return;\n }\n if (typeof key === \"string\") return;\n if (key instanceof Date) {\n if (Number.isNaN(key.getTime())) throw new TypeError(\"TreeMap: invalid Date key\");\n return;\n }\n throw new TypeError(\"TreeMap: comparator is required for non-number/non-string/non-Date keys\");\n }\n /**\n * Number of entries in the map.\n */\n get size() {\n return __privateGet(this, _core3).size;\n }\n /**\n * Whether the map is empty.\n */\n isEmpty() {\n return this.size === 0;\n }\n /**\n * Set or overwrite a value for a key.\n * @remarks Expected time O(log n)\n */\n set(key, value) {\n this._validateKey(key);\n __privateGet(this, _core3).set(key, value);\n return this;\n }\n /**\n * Get the value under a key.\n * @remarks Expected time O(log n)\n */\n get(key) {\n this._validateKey(key);\n return __privateGet(this, _core3).get(key);\n }\n /**\n * Test whether a key exists.\n * @remarks Expected time O(log n)\n */\n has(key) {\n this._validateKey(key);\n return __privateGet(this, _core3).has(key);\n }\n /**\n * Delete a key.\n * @returns `true` if the key existed; otherwise `false`.\n * @remarks Expected time O(log n)\n */\n delete(key) {\n var _a;\n this._validateKey(key);\n const res = __privateGet(this, _core3).delete(key);\n return Array.isArray(res) && res.length > 0 && !!((_a = res[0]) == null ? void 0 : _a.deleted);\n }\n /**\n * Remove all entries.\n */\n clear() {\n __privateGet(this, _core3).clear();\n }\n /**\n * Iterate over keys in ascending order.\n */\n keys() {\n return __privateGet(this, _core3).keys();\n }\n _entryFromKey(k) {\n return [k, __privateGet(this, _core3).get(k)];\n }\n /**\n * Iterate over values in ascending key order.\n *\n * Note: values may be `undefined` (TreeMap allows storing `undefined`, like native `Map`).\n */\n *values() {\n for (const k of this.keys()) yield this._entryFromKey(k)[1];\n }\n /**\n * Iterate over `[key, value]` entries in ascending key order.\n *\n * Note: values may be `undefined`.\n */\n *entries() {\n for (const k of this.keys()) yield this._entryFromKey(k);\n }\n [Symbol.iterator]() {\n return this.entries();\n }\n /**\n * Visit each entry in ascending key order.\n *\n * Note: callback value may be `undefined`.\n */\n forEach(cb, thisArg) {\n for (const [k, v] of this) cb.call(thisArg, v, k, this);\n }\n /**\n * Create a new TreeMap by mapping each entry to a new `[key, value]` entry.\n *\n * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.\n * @remarks Time O(n log n) expected, Space O(n)\n */\n map(callbackfn, options = {}, thisArg) {\n const out = new _TreeMap([], options);\n let index = 0;\n for (const [k, v] of this) {\n const [mk, mv] = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);\n out.set(mk, mv);\n }\n return out;\n }\n /**\n * Create a new TreeMap containing only entries that satisfy the predicate.\n * @remarks Time O(n log n) expected, Space O(n)\n */\n filter(callbackfn, thisArg) {\n const out = new _TreeMap([], { comparator: __privateGet(this, _userComparator2) });\n let index = 0;\n for (const [k, v] of this) {\n const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);\n if (ok) out.set(k, v);\n }\n return out;\n }\n /**\n * Reduce entries into a single accumulator.\n * @remarks Time O(n), Space O(1)\n */\n reduce(callbackfn, initialValue) {\n let acc = initialValue;\n let index = 0;\n for (const [k, v] of this) acc = callbackfn(acc, v, k, index++, this);\n return acc;\n }\n /**\n * Test whether all entries satisfy a predicate.\n * @remarks Time O(n), Space O(1)\n */\n every(callbackfn, thisArg) {\n let index = 0;\n for (const [k, v] of this) {\n const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);\n if (!ok) return false;\n }\n return true;\n }\n /**\n * Test whether any entry satisfies a predicate.\n * @remarks Time O(n), Space O(1)\n */\n some(callbackfn, thisArg) {\n let index = 0;\n for (const [k, v] of this) {\n const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);\n if (ok) return true;\n }\n return false;\n }\n /**\n * Find the first entry that satisfies a predicate.\n * @returns The first matching `[key, value]` tuple, or `undefined`.\n * @remarks Time O(n), Space O(1)\n */\n find(callbackfn, thisArg) {\n let index = 0;\n for (const [k, v] of this) {\n const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);\n if (ok) return [k, v];\n }\n return void 0;\n }\n /**\n * Materialize the map into an array of `[key, value]` tuples.\n * @remarks Time O(n), Space O(n)\n */\n toArray() {\n return [...this];\n }\n /**\n * Print a human-friendly representation.\n * @remarks Time O(n), Space O(n)\n */\n print() {\n __privateGet(this, _core3).print();\n }\n // Navigable operations (return entry tuples)\n // Note: returned tuple values may be `undefined`.\n /**\n * Smallest entry by key.\n */\n first() {\n const k = __privateGet(this, _core3).getLeftMost();\n return k === void 0 ? void 0 : this._entryFromKey(k);\n }\n /**\n * Largest entry by key.\n */\n last() {\n const k = __privateGet(this, _core3).getRightMost();\n return k === void 0 ? void 0 : this._entryFromKey(k);\n }\n /**\n * Remove and return the smallest entry.\n */\n pollFirst() {\n const entry = this.first();\n if (!entry) return void 0;\n this.delete(entry[0]);\n return entry;\n }\n /**\n * Remove and return the largest entry.\n */\n pollLast() {\n const entry = this.last();\n if (!entry) return void 0;\n this.delete(entry[0]);\n return entry;\n }\n /**\n * Smallest entry whose key is >= the given key.\n */\n ceiling(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core3).ceiling(key);\n return k === void 0 ? void 0 : this._entryFromKey(k);\n }\n /**\n * Largest entry whose key is <= the given key.\n */\n floor(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core3).floor(key);\n return k === void 0 ? void 0 : this._entryFromKey(k);\n }\n /**\n * Smallest entry whose key is > the given key.\n */\n higher(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core3).higher(key);\n return k === void 0 ? void 0 : this._entryFromKey(k);\n }\n /**\n * Largest entry whose key is < the given key.\n */\n lower(key) {\n this._validateKey(key);\n const k = __privateGet(this, _core3).lower(key);\n return k === void 0 ? void 0 : this._entryFromKey(k);\n }\n /**\n * Return all entries in a given key range.\n *\n * @param range `[low, high]`\n * @param options Inclusive/exclusive bounds (defaults to inclusive).\n */\n rangeSearch(range, options = {}) {\n const { lowInclusive = true, highInclusive = true } = options;\n const [low, high] = range;\n this._validateKey(low);\n this._validateKey(high);\n const keys = __privateGet(this, _core3).rangeSearch([low, high]);\n const out = [];\n const cmp = __privateGet(this, _core3).comparator;\n for (const k of keys) {\n if (k === void 0) continue;\n if (!lowInclusive && cmp(k, low) === 0) continue;\n if (!highInclusive && cmp(k, high) === 0) continue;\n out.push(this._entryFromKey(k));\n }\n return out;\n }\n /**\n * Creates a shallow clone of this map.\n * @remarks Time O(n log n), Space O(n)\n * @example\n * const original = new TreeMap([['a', 1], ['b', 2]]);\n * const copy = original.clone();\n * copy.set('c', 3);\n * original.has('c'); // false (original unchanged)\n */\n clone() {\n return new _TreeMap(this, {\n comparator: __privateGet(this, _isDefaultComparator3) ? void 0 : __privateGet(this, _userComparator2),\n isMapMode: __privateGet(this, _core3).isMapMode\n });\n }\n};\n_core3 = new WeakMap();\n_isDefaultComparator3 = new WeakMap();\n_userComparator2 = new WeakMap();\n__name(_TreeMap, \"TreeMap\");\nvar TreeMap = _TreeMap;\n\n// src/data-structures/binary-tree/tree-multi-set.ts\nvar _core4, _isDefaultComparator4;\nvar _TreeMultiSet = class _TreeMultiSet {\n // total occurrences (sumCounts)\n /**\n * Creates a new TreeMultiSet.\n * @param elements - Initial elements to add, or raw elements if `toElementFn` is provided.\n * @param options - Configuration options including optional `toElementFn` to transform raw elements.\n * @remarks Time O(m log m), Space O(m) where m is the number of initial elements\n * @example\n * // Standard usage with elements\n * const mset = new TreeMultiSet([1, 2, 2, 3]);\n *\n * // Using toElementFn to transform raw objects\n * const items = [{ score: 100 }, { score: 200 }, { score: 100 }];\n * const mset = new TreeMultiSet<number, Item>(items, { toElementFn: item => item.score });\n */\n constructor(elements = [], options = {}) {\n __privateAdd(this, _core4);\n __privateAdd(this, _isDefaultComparator4);\n __publicField(this, \"_size\", 0);\n var _a;\n const toElementFn = options.toElementFn;\n const comparator = (_a = options.comparator) != null ? _a : TreeSet.createDefaultComparator();\n __privateSet(this, _isDefaultComparator4, options.comparator === void 0);\n __privateSet(this, _core4, new RedBlackTree([], { comparator, isMapMode: options.isMapMode }));\n for (const item of elements) {\n const k = toElementFn ? toElementFn(item) : item;\n this.add(k);\n }\n }\n /**\n * Validates the key against the default comparator rules.\n * @remarks Time O(1), Space O(1)\n */\n _validateKey(key) {\n if (!__privateGet(this, _isDefaultComparator4)) return;\n if (typeof key === \"number\") {\n if (Number.isNaN(key)) throw new TypeError(\"TreeMultiSet: NaN is not a valid key\");\n return;\n }\n if (typeof key === \"string\") return;\n if (key instanceof Date) {\n if (Number.isNaN(key.getTime())) throw new TypeError(\"TreeMultiSet: invalid Date key\");\n return;\n }\n throw new TypeError(\"TreeMultiSet: comparator is required for non-number/non-string/non-Date keys\");\n }\n /**\n * Validates that count is a non-negative safe integer.\n * @remarks Time O(1), Space O(1)\n */\n _validateCount(n) {\n if (!Number.isSafeInteger(n) || n < 0) throw new RangeError(\"TreeMultiSet: count must be a safe integer >= 0\");\n }\n /**\n * Total occurrences (sumCounts).\n * @remarks Time O(1), Space O(1)\n */\n get size() {\n return this._size;\n }\n /**\n * Number of distinct keys.\n * @remarks Time O(1), Space O(1)\n */\n get distinctSize() {\n return __privateGet(this, _core4).size;\n }\n /**\n * Whether the multiset is empty.\n * @remarks Time O(1), Space O(1)\n */\n isEmpty() {\n return this.size === 0;\n }\n /**\n * Whether the multiset contains the given key.\n * @remarks Time O(log n), Space O(1)\n */\n has(key) {\n this._validateKey(key);\n return this.count(key) > 0;\n }\n /**\n * Returns the count of occurrences for the given key.\n * @remarks Time O(log n), Space O(1)\n */\n count(key) {\n var _a;\n this._validateKey(key);\n return (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;\n }\n /**\n * Add `n` occurrences of `key`.\n * @returns True if the multiset changed.\n * @remarks Time O(log n), Space O(1)\n */\n add(key, n = 1) {\n var _a;\n this._validateKey(key);\n this._validateCount(n);\n if (n === 0) return false;\n const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;\n const next = old + n;\n __privateGet(this, _core4).set(key, next);\n this._size += n;\n return true;\n }\n /**\n * Set count for `key` to exactly `n`.\n * @returns True if changed.\n * @remarks Time O(log n), Space O(1)\n */\n setCount(key, n) {\n var _a;\n this._validateKey(key);\n this._validateCount(n);\n const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;\n if (old === n) return false;\n if (n === 0) {\n if (old !== 0) __privateGet(this, _core4).delete(key);\n } else {\n __privateGet(this, _core4).set(key, n);\n }\n this._size += n - old;\n return true;\n }\n /**\n * Delete `n` occurrences of `key` (default 1).\n * @returns True if any occurrence was removed.\n * @remarks Time O(log n), Space O(1)\n */\n delete(key, n = 1) {\n var _a;\n this._validateKey(key);\n this._validateCount(n);\n if (n === 0) return false;\n const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;\n if (old === 0) return false;\n const removed = Math.min(old, n);\n const next = old - removed;\n if (next === 0) __privateGet(this, _core4).delete(key);\n else __privateGet(this, _core4).set(key, next);\n this._size -= removed;\n return true;\n }\n /**\n * Delete all occurrences of the given key.\n * @returns True if any occurrence was removed.\n * @remarks Time O(log n), Space O(1)\n */\n deleteAll(key) {\n var _a;\n this._validateKey(key);\n const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;\n if (old === 0) return false;\n __privateGet(this, _core4).delete(key);\n this._size -= old;\n return true;\n }\n /**\n * Iterates over distinct keys (each key yielded once).\n * @remarks Time O(n), Space O(1)\n */\n *keysDistinct() {\n yield* __privateGet(this, _core4).keys();\n }\n /**\n * Iterates over entries as [key, count] pairs.\n * @remarks Time O(n), Space O(1)\n */\n *entries() {\n for (const [k, v] of __privateGet(this, _core4)) {\n yield [k, v != null ? v : 0];\n }\n }\n /**\n * Expanded iteration (default). Each key is yielded `count(key)` times.\n * @remarks Time O(size), Space O(1) where size is total occurrences\n */\n *[Symbol.iterator]() {\n for (const [k, c] of this.entries()) {\n for (let i = 0; i < c; i++) yield k;\n }\n }\n /**\n * Returns an array with all elements (expanded).\n * @remarks Time O(size), Space O(size)\n */\n toArray() {\n return [...this];\n }\n /**\n * Returns an array with distinct keys only.\n * @remarks Time O(n), Space O(n)\n */\n toDistinctArray() {\n return [...this.keysDistinct()];\n }\n /**\n * Returns an array of [key, count] entries.\n * @remarks Time O(n), Space O(n)\n */\n toEntries() {\n return [...this.entries()];\n }\n /**\n * Expose comparator for advanced usage/testing (read-only).\n * @remarks Time O(1), Space O(1)\n */\n get comparator() {\n return __privateGet(this, _core4)._comparator;\n }\n // ━━━ clear ━━━\n /**\n * Remove all elements from the multiset.\n * @remarks Time O(1), Space O(1)\n * @example\n * const ms = new TreeMultiSet([1, 2, 2, 3]);\n * ms.clear();\n * ms.size; // 0\n */\n clear() {\n __privateGet(this, _core4).clear();\n this._size = 0;\n }\n // ━━━ Navigable methods ━━━\n /**\n * Returns the smallest key, or undefined if empty.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([3, 1, 4]);\n * ms.first(); // 1\n */\n first() {\n return __privateGet(this, _core4).getLeftMost();\n }\n /**\n * Returns the largest key, or undefined if empty.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([3, 1, 4]);\n * ms.last(); // 4\n */\n last() {\n return __privateGet(this, _core4).getRightMost();\n }\n /**\n * Removes all occurrences of the smallest key and returns it.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([1, 1, 2, 3]);\n * ms.pollFirst(); // 1\n * ms.has(1); // false\n */\n pollFirst() {\n const key = this.first();\n if (key === void 0) return void 0;\n this.deleteAll(key);\n return key;\n }\n /**\n * Removes all occurrences of the largest key and returns it.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([1, 2, 3, 3]);\n * ms.pollLast(); // 3\n * ms.has(3); // false\n */\n pollLast() {\n const key = this.last();\n if (key === void 0) return void 0;\n this.deleteAll(key);\n return key;\n }\n /**\n * Returns the smallest key >= given key, or undefined.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([10, 20, 30]);\n * ms.ceiling(15); // 20\n * ms.ceiling(20); // 20\n */\n ceiling(key) {\n this._validateKey(key);\n return __privateGet(this, _core4).ceiling(key);\n }\n /**\n * Returns the largest key <= given key, or undefined.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([10, 20, 30]);\n * ms.floor(25); // 20\n * ms.floor(20); // 20\n */\n floor(key) {\n this._validateKey(key);\n return __privateGet(this, _core4).floor(key);\n }\n /**\n * Returns the smallest key > given key, or undefined.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([10, 20, 30]);\n * ms.higher(10); // 20\n * ms.higher(15); // 20\n */\n higher(key) {\n this._validateKey(key);\n return __privateGet(this, _core4).higher(key);\n }\n /**\n * Returns the largest key < given key, or undefined.\n * @remarks Time O(log n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([10, 20, 30]);\n * ms.lower(20); // 10\n * ms.lower(15); // 10\n */\n lower(key) {\n this._validateKey(key);\n return __privateGet(this, _core4).lower(key);\n }\n // ━━━ Functional methods ━━━\n /**\n * Iterates over distinct keys with their counts.\n * @remarks Time O(n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);\n * ms.forEach((key, count) => console.log(`${key}: ${count}`));\n * // 1: 2, 2: 1, 3: 3\n */\n forEach(callback) {\n for (const [k, c] of this.entries()) {\n callback(k, c);\n }\n }\n /**\n * Creates a new TreeMultiSet with entries that match the predicate.\n * @remarks Time O(n log n), Space O(n)\n * @example\n * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);\n * const filtered = ms.filter((key, count) => count >= 2);\n * // TreeMultiSet { 1: 2, 3: 3 }\n */\n filter(predicate) {\n const result = new _TreeMultiSet([], {\n comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,\n isMapMode: __privateGet(this, _core4)._isMapMode\n });\n for (const [k, c] of this.entries()) {\n if (predicate(k, c)) {\n result.add(k, c);\n }\n }\n return result;\n }\n /**\n * Reduces the multiset to a single value.\n * @remarks Time O(n), Space O(1)\n * @example\n * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);\n * const total = ms.reduce((acc, key, count) => acc + count, 0); // 6\n */\n reduce(callback, initialValue) {\n let acc = initialValue;\n for (const [k, c] of this.entries()) {\n acc = callback(acc, k, c);\n }\n return acc;\n }\n /**\n * Maps keys and counts to a new TreeMultiSet.\n * When multiple keys map to the same new key, counts are merged (added).\n * @remarks Time O(n log n), Space O(n)\n * @example\n * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);\n * const mapped = ms.map((key, count) => [key * 10, count]);\n * // TreeMultiSet { 10: 2, 20: 1, 30: 3 }\n * @example\n * // Collision: counts merge\n * const ms = new TreeMultiSet([1, 2, 3]);\n * const merged = ms.map((key, count) => [key % 2, count]);\n * // { 0: 1, 1: 2 } (1 and 3 both map to 1, counts add)\n */\n map(mapper, options) {\n const result = new _TreeMultiSet([], {\n comparator: options == null ? void 0 : options.comparator,\n isMapMode: __privateGet(this, _core4)._isMapMode\n });\n for (const [k, c] of this.entries()) {\n const [newKey, newCount] = mapper(k, c);\n result.add(newKey, newCount);\n }\n return result;\n }\n /**\n * Creates an independent copy of this multiset.\n * @remarks Time O(n log n), Space O(n)\n * @example\n * const ms = new TreeMultiSet([1, 1, 2]);\n * const copy = ms.clone();\n * copy.add(3);\n * ms.has(3); // false (original unchanged)\n */\n clone() {\n const result = new _TreeMultiSet([], {\n comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,\n isMapMode: __privateGet(this, _core4)._isMapMode\n });\n for (const [k, c] of this.entries()) {\n result.add(k, c);\n }\n return result;\n }\n // ━━━ Tree utilities ━━━\n /**\n * Returns keys within the given range.\n * @remarks Time O(log n + k), Space O(k) where k is result size\n * @example\n * const ms = new TreeMultiSet([10, 20, 30, 40, 50]);\n * ms.rangeSearch([15, 45]); // [20, 30, 40]\n */\n rangeSearch(range, callback) {\n const cb = callback != null ? callback : ((k) => k);\n return __privateGet(this, _core4).rangeSearch(range, (node) => cb(node.key));\n }\n /**\n * Prints the internal tree structure (for debugging).\n * @remarks Time O(n), Space O(n)\n * @example\n * const ms = new TreeMultiSet([1, 2, 3]);\n * ms.print();\n */\n print() {\n __privateGet(this, _core4).print();\n }\n};\n_core4 = new WeakMap();\n_isDefaultComparator4 = new WeakMap();\n__name(_TreeMultiSet, \"TreeMultiSet\");\nvar TreeMultiSet = _TreeMultiSet;\n\n// src/data-structures/priority-queue/priority-queue.ts\nvar _PriorityQueue = class _PriorityQueue extends Heap {\n constructor(elements = [], options) {\n super(elements, options);\n }\n};\n__name(_PriorityQueue, \"PriorityQueue\");\nvar PriorityQueue = _PriorityQueue;\n\n// src/data-structures/priority-queue/min-priority-queue.ts\nvar _MinPriorityQueue = class _MinPriorityQueue extends PriorityQueue {\n /**\n * Creates a min-priority queue.\n * @param elements Optional initial elements to insert.\n * @param options Optional configuration (e.g., `comparator`, `toElementFn`).\n * @remarks Complexity — Time: O(n log n) when inserting n elements incrementally; Space: O(n).\n */\n constructor(elements = [], options) {\n super(elements, options);\n }\n};\n__name(_MinPriorityQueue, \"MinPriorityQueue\");\nvar MinPriorityQueue = _MinPriorityQueue;\n\n// src/data-structures/priority-queue/max-priority-queue.ts\nvar _MaxPriorityQueue = class _MaxPriorityQueue extends PriorityQueue {\n /**\n * Creates a max-priority queue.\n * @param elements Optional initial elements to insert.\n * @param options Optional configuration (e.g., `comparator`, `toElementFn`).\n * @throws {TypeError} Thrown when using the default comparator with object elements (provide a custom comparator).\n * @remarks Complexity — Time: O(n log n) when inserting n elements incrementally; Space: O(n).\n */\n constructor(elements = [], options) {\n super(elements, {\n comparator: /* @__PURE__ */ __name((a, b) => {\n if (typeof a === \"object\" || typeof b === \"object\") {\n throw TypeError(\n `When comparing object types, a custom comparator must be defined in the constructor's options parameter.`\n );\n }\n if (a < b) return 1;\n if (a > b) return -1;\n return 0;\n }, \"comparator\"),\n ...options\n });\n }\n};\n__name(_MaxPriorityQueue, \"MaxPriorityQueue\");\nvar MaxPriorityQueue = _MaxPriorityQueue;\n\n// src/data-structures/matrix/matrix.ts\nvar _Matrix = class _Matrix {\n /**\n * The constructor function initializes a matrix object with the provided data and options, or with\n * default values if no options are provided.\n * @param {number[][]} data - A 2D array of numbers representing the data for the matrix.\n * @param [options] - The `options` parameter is an optional object that can contain the following\n * properties:\n */\n constructor(data, options) {\n __publicField(this, \"_rows\", 0);\n __publicField(this, \"_cols\", 0);\n __publicField(this, \"_data\");\n var _a, _b, _c;\n if (options) {\n const { rows, cols, addFn, subtractFn, multiplyFn } = options;\n if (typeof rows === \"number\" && rows > 0) this._rows = rows;\n else this._rows = data.length;\n if (typeof cols === \"number\" && cols > 0) this._cols = cols;\n else this._cols = ((_a = data[0]) == null ? void 0 : _a.length) || 0;\n if (addFn) this._addFn = addFn;\n if (subtractFn) this._subtractFn = subtractFn;\n if (multiplyFn) this._multiplyFn = multiplyFn;\n } else {\n this._rows = data.length;\n this._cols = (_c = (_b = data[0]) == null ? void 0 : _b.length) != null ? _c : 0;\n }\n if (data.length > 0) {\n this._data = data;\n } else {\n this._data = [];\n for (let i = 0; i < this.rows; i++) {\n this._data[i] = new Array(this.cols).fill(0);\n }\n }\n }\n /**\n * The function returns the number of rows.\n * @returns The number of rows.\n */\n get rows() {\n return this._rows;\n }\n /**\n * The function returns the value of the protected variable _cols.\n * @returns The number of columns.\n */\n get cols() {\n return this._cols;\n }\n /**\n * The function returns a two-dimensional array of numbers.\n * @returns The data property, which is a two-dimensional array of numbers.\n */\n get data() {\n return this._data;\n }\n /**\n * The above function returns the value of the _addFn property.\n * @returns The value of the property `_addFn` is being returned.\n */\n get addFn() {\n return this._addFn;\n }\n /**\n * The function returns the value of the _subtractFn property.\n * @returns The `_subtractFn` property is being returned.\n */\n get subtractFn() {\n return this._subtractFn;\n }\n /**\n * The function returns the value of the _multiplyFn property.\n * @returns The `_multiplyFn` property is being returned.\n */\n get multiplyFn() {\n return this._multiplyFn;\n }\n /**\n * The `get` function returns the value at the specified row and column index if it is a valid index.\n * @param {number} row - The `row` parameter represents the row index of the element you want to\n * retrieve from the data array.\n * @param {number} col - The parameter \"col\" represents the column number of the element you want to\n * retrieve from the data array.\n * @returns The `get` function returns a number if the provided row and column indices are valid.\n * Otherwise, it returns `undefined`.\n */\n get(row, col) {\n if (this.isValidIndex(row, col)) {\n return this.data[row][col];\n }\n }\n /**\n * The set function updates the value at a specified row and column in a two-dimensional array.\n * @param {number} row - The \"row\" parameter represents the row index of the element in a\n * two-dimensional array or matrix. It specifies the row where the value will be set.\n * @param {number} col - The \"col\" parameter represents the column index of the element in a\n * two-dimensional array.\n * @param {number} value - The value parameter represents the number that you want to set at the\n * specified row and column in the data array.\n * @returns a boolean value. It returns true if the index (row, col) is valid and the value is\n * successfully set in the data array. It returns false if the index is invalid and the value is not\n * set.\n */\n set(row, col, value) {\n if (this.isValidIndex(row, col)) {\n this.data[row][col] = value;\n return true;\n }\n return false;\n }\n /**\n * The function checks if the dimensions of the given matrix match the dimensions of the current\n * matrix.\n * @param {Matrix} matrix - The parameter `matrix` is of type `Matrix`.\n * @returns a boolean value.\n */\n isMatchForCalculate(matrix) {\n return this.rows === matrix.rows && this.cols === matrix.cols;\n }\n /**\n * The `add` function adds two matrices together, returning a new matrix with the result.\n * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.\n * @returns The `add` method returns a new `Matrix` object that represents the result of adding the\n * current matrix with the provided `matrix` parameter.\n */\n add(matrix) {\n if (!this.isMatchForCalculate(matrix)) {\n throw new Error(\"Matrix dimensions must match for addition.\");\n }\n const resultData = [];\n for (let i = 0; i < this.rows; i++) {\n resultData[i] = [];\n for (let j = 0; j < this.cols; j++) {\n const a = this.get(i, j), b = matrix.get(i, j);\n if (a !== void 0 && b !== void 0) {\n const added = this._addFn(a, b);\n if (added) {\n resultData[i][j] = added;\n }\n }\n }\n }\n return new _Matrix(resultData, {\n rows: this.rows,\n cols: this.cols,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n }\n /**\n * The `subtract` function performs element-wise subtraction between two matrices and returns a new\n * matrix with the result.\n * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class. It\n * represents the matrix that you want to subtract from the current matrix.\n * @returns a new Matrix object with the result of the subtraction operation.\n */\n subtract(matrix) {\n if (!this.isMatchForCalculate(matrix)) {\n throw new Error(\"Matrix dimensions must match for subtraction.\");\n }\n const resultData = [];\n for (let i = 0; i < this.rows; i++) {\n resultData[i] = [];\n for (let j = 0; j < this.cols; j++) {\n const a = this.get(i, j), b = matrix.get(i, j);\n if (a !== void 0 && b !== void 0) {\n const subtracted = this._subtractFn(a, b);\n if (subtracted) {\n resultData[i][j] = subtracted;\n }\n }\n }\n }\n return new _Matrix(resultData, {\n rows: this.rows,\n cols: this.cols,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n }\n /**\n * The `multiply` function performs matrix multiplication between two matrices and returns the result\n * as a new matrix.\n * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.\n * @returns a new Matrix object.\n */\n multiply(matrix) {\n if (this.cols !== matrix.rows) {\n throw new Error(\"Matrix dimensions must be compatible for multiplication (A.cols = B.rows).\");\n }\n const resultData = [];\n for (let i = 0; i < this.rows; i++) {\n resultData[i] = [];\n for (let j = 0; j < matrix.cols; j++) {\n let sum;\n for (let k = 0; k < this.cols; k++) {\n const a = this.get(i, k), b = matrix.get(k, j);\n if (a !== void 0 && b !== void 0) {\n const multiplied = this.multiplyFn(a, b);\n if (multiplied !== void 0) {\n sum = this.addFn(sum, multiplied);\n }\n }\n }\n if (sum !== void 0) resultData[i][j] = sum;\n }\n }\n return new _Matrix(resultData, {\n rows: this.rows,\n cols: matrix.cols,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n }\n /**\n * The transpose function takes a matrix and returns a new matrix that is the transpose of the\n * original matrix.\n * @returns The transpose() function returns a new Matrix object with the transposed data.\n */\n transpose() {\n if (this.data.some((row) => row.length !== this.rows)) {\n throw new Error(\"Matrix must be rectangular for transposition.\");\n }\n const resultData = [];\n for (let j = 0; j < this.cols; j++) {\n resultData[j] = [];\n for (let i = 0; i < this.rows; i++) {\n const trans = this.get(i, j);\n if (trans !== void 0) resultData[j][i] = trans;\n }\n }\n return new _Matrix(resultData, {\n rows: this.cols,\n cols: this.rows,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n }\n /**\n * The `inverse` function calculates the inverse of a square matrix using Gaussian elimination.\n * @returns a Matrix object, which represents the inverse of the original matrix.\n */\n inverse() {\n var _a;\n if (this.rows !== this.cols) {\n throw new Error(\"Matrix must be square for inversion.\");\n }\n const augmentedMatrixData = [];\n for (let i = 0; i < this.rows; i++) {\n augmentedMatrixData[i] = this.data[i].slice();\n for (let j = 0; j < this.cols; j++) {\n augmentedMatrixData[i][this.cols + j] = i === j ? 1 : 0;\n }\n }\n const augmentedMatrix = new _Matrix(augmentedMatrixData, {\n rows: this.rows,\n cols: this.cols * 2,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n for (let i = 0; i < this.rows; i++) {\n let pivotRow = i;\n while (pivotRow < this.rows && augmentedMatrix.get(pivotRow, i) === 0) {\n pivotRow++;\n }\n if (pivotRow === this.rows) {\n throw new Error(\"Matrix is singular, and its inverse does not exist.\");\n }\n augmentedMatrix._swapRows(i, pivotRow);\n const pivotElement = (_a = augmentedMatrix.get(i, i)) != null ? _a : 1;\n if (pivotElement === 0) {\n throw new Error(\"Matrix is singular, and its inverse does not exist (division by zero).\");\n }\n augmentedMatrix._scaleRow(i, 1 / pivotElement);\n for (let j = 0; j < this.rows; j++) {\n if (j !== i) {\n let factor = augmentedMatrix.get(j, i);\n if (factor === void 0) factor = 0;\n augmentedMatrix._addScaledRow(j, i, -factor);\n }\n }\n }\n const inverseData = [];\n for (let i = 0; i < this.rows; i++) {\n inverseData[i] = augmentedMatrix.data[i].slice(this.cols);\n }\n return new _Matrix(inverseData, {\n rows: this.rows,\n cols: this.cols,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n }\n /**\n * The dot function calculates the dot product of two matrices and returns a new matrix.\n * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.\n * @returns a new Matrix object.\n */\n dot(matrix) {\n if (this.cols !== matrix.rows) {\n throw new Error(\n \"Number of columns in the first matrix must be equal to the number of rows in the second matrix for dot product.\"\n );\n }\n const resultData = [];\n for (let i = 0; i < this.rows; i++) {\n resultData[i] = [];\n for (let j = 0; j < matrix.cols; j++) {\n let sum;\n for (let k = 0; k < this.cols; k++) {\n const a = this.get(i, k), b = matrix.get(k, j);\n if (a !== void 0 && b !== void 0) {\n const multiplied = this.multiplyFn(a, b);\n if (multiplied !== void 0) {\n sum = this.addFn(sum, multiplied);\n }\n }\n }\n if (sum !== void 0) resultData[i][j] = sum;\n }\n }\n return new _Matrix(resultData, {\n rows: this.rows,\n cols: matrix.cols,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n }\n /**\n * The function checks if a given row and column index is valid within a specified range.\n * @param {number} row - The `row` parameter represents the row index of a two-dimensional array or\n * matrix. It is a number that indicates the specific row in the matrix.\n * @param {number} col - The \"col\" parameter represents the column index in a two-dimensional array\n * or grid. It is used to check if the given column index is valid within the bounds of the grid.\n * @returns A boolean value is being returned.\n */\n isValidIndex(row, col) {\n return row >= 0 && row < this.rows && col >= 0 && col < this.cols;\n }\n /**\n * The `clone` function returns a new instance of the Matrix class with the same data and properties\n * as the original instance.\n * @returns The `clone()` method is returning a new instance of the `Matrix` class with the same data\n * and properties as the current instance.\n */\n clone() {\n return new _Matrix(this.data, {\n rows: this.rows,\n cols: this.cols,\n addFn: this.addFn,\n subtractFn: this.subtractFn,\n multiplyFn: this.multiplyFn\n });\n }\n _addFn(a, b) {\n if (a === void 0) return b;\n return a + b;\n }\n _subtractFn(a, b) {\n return a - b;\n }\n _multiplyFn(a, b) {\n return a * b;\n }\n /**\n * The function `_swapRows` swaps the positions of two rows in an array.\n * @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.\n * @param {number} row2 - The `row2` parameter is the index of the second row that you want to swap\n * with the first row.\n */\n _swapRows(row1, row2) {\n const temp = this.data[row1];\n this.data[row1] = this.data[row2];\n this.data[row2] = temp;\n }\n /**\n * The function scales a specific row in a matrix by a given scalar value.\n * @param {number} row - The `row` parameter represents the index of the row in the matrix that you\n * want to scale. It is a number that indicates the position of the row within the matrix.\n * @param {number} scalar - The scalar parameter is a number that is used to multiply each element in\n * a specific row of a matrix.\n */\n _scaleRow(row, scalar) {\n for (let j = 0; j < this.cols; j++) {\n let multiplied = this.multiplyFn(this.data[row][j], scalar);\n if (multiplied === void 0) multiplied = 0;\n this.data[row][j] = multiplied;\n }\n }\n /**\n * The function `_addScaledRow` multiplies a row in a matrix by a scalar value and adds it to another\n * row.\n * @param {number} targetRow - The targetRow parameter represents the index of the row in which the\n * scaled values will be added.\n * @param {number} sourceRow - The sourceRow parameter represents the index of the row from which the\n * values will be scaled and added to the targetRow.\n * @param {number} scalar - The scalar parameter is a number that is used to scale the values in the\n * source row before adding them to the target row.\n */\n _addScaledRow(targetRow, sourceRow, scalar) {\n for (let j = 0; j < this.cols; j++) {\n let multiplied = this.multiplyFn(this.data[sourceRow][j], scalar);\n if (multiplied === void 0) multiplied = 0;\n const scaledValue = multiplied;\n let added = this.addFn(this.data[targetRow][j], scaledValue);\n if (added === void 0) added = 0;\n this.data[targetRow][j] = added;\n }\n }\n};\n__name(_Matrix, \"Matrix\");\nvar Matrix = _Matrix;\n\n// src/data-structures/matrix/navigator.ts\nvar _Character = class _Character {\n /**\n * The constructor function takes in a direction and turning object and sets the direction and turn properties of the\n * Character class.\n * @param {Direction} direction - The direction parameter is used to specify the current direction of the character. It\n * can be any value that represents a direction, such as \"north\", \"south\", \"east\", or \"west\".\n * @param {Turning} turning - The `turning` parameter is an object that maps each direction to the corresponding\n * turning direction. It is used to determine the new direction when the character turns.\n */\n constructor(direction, turning) {\n __publicField(this, \"direction\");\n __publicField(this, \"turn\");\n this.direction = direction;\n this.turn = () => new _Character(turning[direction], turning);\n }\n};\n__name(_Character, \"Character\");\nvar Character = _Character;\nvar _Navigator = class _Navigator {\n /**\n * The constructor initializes the Navigator object with the given parameters and sets the current position as visited\n * in the matrix.\n * @param - - `matrix`: a 2D array representing the grid or map\n */\n constructor({ matrix, turning, onMove, init: { cur, charDir, VISITED } }) {\n __publicField(this, \"onMove\");\n __publicField(this, \"_matrix\");\n __publicField(this, \"_cur\");\n __publicField(this, \"_character\");\n __publicField(this, \"_VISITED\");\n this._matrix = matrix;\n this._cur = cur;\n this._character = new Character(charDir, turning);\n this.onMove = onMove;\n if (this.onMove) this.onMove(this._cur);\n this._VISITED = VISITED;\n this._matrix[this._cur[0]][this._cur[1]] = this._VISITED;\n }\n /**\n * The \"start\" function moves the character in its current direction until it encounters an obstacle, then it turns the\n * character and repeats the process.\n */\n start() {\n while (this.check(this._character.direction) || this.check(this._character.turn().direction)) {\n const { direction } = this._character;\n if (this.check(direction)) {\n this.move(direction);\n } else if (this.check(this._character.turn().direction)) {\n this._character = this._character.turn();\n }\n }\n }\n /**\n * The function checks if there is a valid move in the specified direction in a matrix.\n * @param {Direction} direction - The direction parameter is a string that represents the direction in which to check.\n * It can be one of the following values: 'up', 'right', 'down', or 'left'.\n * @returns a boolean value.\n */\n check(direction) {\n let forward, row;\n const matrix = this._matrix;\n const [i, j] = this._cur;\n switch (direction) {\n case \"up\":\n row = matrix[i - 1];\n if (!row) return false;\n forward = row[j];\n break;\n case \"right\":\n forward = matrix[i][j + 1];\n break;\n case \"down\":\n row = matrix[i + 1];\n if (!row) return false;\n forward = row[j];\n break;\n case \"left\":\n forward = matrix[i][j - 1];\n break;\n }\n return forward !== void 0 && forward !== this._VISITED;\n }\n /**\n * The `move` function updates the current position based on the given direction and updates the matrix accordingly.\n * @param {Direction} direction - The `direction` parameter is a string that represents the direction in which to move.\n * It can have one of the following values: 'up', 'right', 'down', or 'left'.\n */\n move(direction) {\n switch (direction) {\n case \"up\":\n this._cur[0]--;\n break;\n case \"right\":\n this._cur[1]++;\n break;\n case \"down\":\n this._cur[0]++;\n break;\n case \"left\":\n this._cur[1]--;\n break;\n }\n const [i, j] = this._cur;\n this._matrix[i][j] = this._VISITED;\n if (this.onMove) this.onMove(this._cur);\n }\n};\n__name(_Navigator, \"Navigator\");\nvar Navigator = _Navigator;\n\n// src/data-structures/trie/trie.ts\nvar _TrieNode = class _TrieNode {\n /**\n * Create a Trie node with a character key.\n * @remarks Time O(1), Space O(1)\n * @returns New TrieNode instance.\n */\n constructor(key) {\n __publicField(this, \"_key\");\n __publicField(this, \"_children\");\n __publicField(this, \"_isEnd\");\n this._key = key;\n this._isEnd = false;\n this._children = /* @__PURE__ */ new Map();\n }\n /**\n * Get the character key of this node.\n * @remarks Time O(1), Space O(1)\n * @returns Character key string.\n */\n get key() {\n return this._key;\n }\n /**\n * Set the character key of this node.\n * @remarks Time O(1), Space O(1)\n * @param value - New character key.\n * @returns void\n */\n set key(value) {\n this._key = value;\n }\n /**\n * Get the child map of this node.\n * @remarks Time O(1), Space O(1)\n * @returns Map from character to child node.\n */\n get children() {\n return this._children;\n }\n /**\n * Replace the child map of this node.\n * @remarks Time O(1), Space O(1)\n * @param value - New map of character → node.\n * @returns void\n */\n set children(value) {\n this._children = value;\n }\n /**\n * Check whether this node marks the end of a word.\n * @remarks Time O(1), Space O(1)\n * @returns True if this node ends a word.\n */\n get isEnd() {\n return this._isEnd;\n }\n /**\n * Mark this node as the end of a word or not.\n * @remarks Time O(1), Space O(1)\n * @param value - Whether this node ends a word.\n * @returns void\n */\n set isEnd(value) {\n this._isEnd = value;\n }\n};\n__name(_TrieNode, \"TrieNode\");\nvar TrieNode = _TrieNode;\nvar _Trie = class _Trie extends IterableElementBase {\n /**\n * Create a Trie and optionally bulk-insert words.\n * @remarks Time O(totalChars), Space O(totalChars)\n * @param [words] - Iterable of strings (or raw records if toElementFn is provided).\n * @param [options] - Options such as toElementFn and caseSensitive.\n * @returns New Trie instance.\n */\n constructor(words = [], options) {\n super(options);\n __publicField(this, \"_size\", 0);\n __publicField(this, \"_caseSensitive\", true);\n __publicField(this, \"_root\", new TrieNode(\"\"));\n if (options) {\n const { caseSensitive } = options;\n if (caseSensitive !== void 0) this._caseSensitive = caseSensitive;\n }\n if (words) {\n this.addMany(words);\n }\n }\n /**\n * Get the number of stored words.\n * @remarks Time O(1), Space O(1)\n * @returns Word count.\n */\n get size() {\n return this._size;\n }\n /**\n * Get whether comparisons are case-sensitive.\n * @remarks Time O(1), Space O(1)\n * @returns True if case-sensitive.\n */\n get caseSensitive() {\n return this._caseSensitive;\n }\n /**\n * Get the root node.\n * @remarks Time O(1), Space O(1)\n * @returns Root TrieNode.\n */\n get root() {\n return this._root;\n }\n /**\n * (Protected) Get total count for base class iteration.\n * @remarks Time O(1), Space O(1)\n * @returns Total number of elements.\n */\n get _total() {\n return this._size;\n }\n /**\n * Insert one word into the trie.\n * @remarks Time O(L), Space O(L)\n * @param word - Word to insert.\n * @returns True if the word was newly added.\n */\n add(word) {\n word = this._caseProcess(word);\n let cur = this.root;\n let isNewWord = false;\n for (const c of word) {\n let nodeC = cur.children.get(c);\n if (!nodeC) {\n nodeC = new TrieNode(c);\n cur.children.set(c, nodeC);\n }\n cur = nodeC;\n }\n if (!cur.isEnd) {\n isNewWord = true;\n cur.isEnd = true;\n this._size++;\n }\n return isNewWord;\n }\n /**\n * Insert many words from an iterable.\n * @remarks Time O(ΣL), Space O(ΣL)\n * @param words - Iterable of strings (or raw records if toElementFn is provided).\n * @returns Array of per-word 'added' flags.\n */\n addMany(words) {\n const ans = [];\n for (const word of words) {\n if (this.toElementFn) {\n ans.push(this.add(this.toElementFn(word)));\n } else {\n ans.push(this.add(word));\n }\n }\n return ans;\n }\n /**\n * Check whether a word exists.\n * @remarks Time O(L), Space O(1)\n * @param word - Word to search for.\n * @returns True if present.\n */\n has(word) {\n word = this._caseProcess(word);\n let cur = this.root;\n for (const c of word) {\n const nodeC = cur.children.get(c);\n if (!nodeC) return false;\n cur = nodeC;\n }\n return cur.isEnd;\n }\n /**\n * Check whether the trie is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if size is 0.\n */\n isEmpty() {\n return this._size === 0;\n }\n /**\n * Remove all words and reset to a fresh root.\n * @remarks Time O(1), Space O(1)\n * @returns void\n */\n clear() {\n this._size = 0;\n this._root = new TrieNode(\"\");\n }\n /**\n * Delete one word if present.\n * @remarks Time O(L), Space O(1)\n * @param word - Word to delete.\n * @returns True if a word was removed.\n */\n delete(word) {\n word = this._caseProcess(word);\n let isDeleted = false;\n const dfs = /* @__PURE__ */ __name((cur, i) => {\n const char = word[i];\n const child = cur.children.get(char);\n if (child) {\n if (i === word.length - 1) {\n if (child.isEnd) {\n if (child.children.size > 0) {\n child.isEnd = false;\n } else {\n cur.children.delete(char);\n }\n isDeleted = true;\n return true;\n }\n return false;\n }\n const res = dfs(child, i + 1);\n if (res && !cur.isEnd && child.children.size === 0) {\n cur.children.delete(char);\n return true;\n }\n return false;\n }\n return false;\n }, \"dfs\");\n dfs(this.root, 0);\n if (isDeleted) {\n this._size--;\n }\n return isDeleted;\n }\n /**\n * Compute the height (max depth) of the trie.\n * @remarks Time O(N), Space O(H)\n * @returns Maximum depth from root to a leaf.\n */\n getHeight() {\n const startNode = this.root;\n let maxDepth = 0;\n if (startNode) {\n const bfs = /* @__PURE__ */ __name((node, level) => {\n if (level > maxDepth) {\n maxDepth = level;\n }\n const { children } = node;\n if (children) {\n for (const child of children.entries()) {\n bfs(child[1], level + 1);\n }\n }\n }, \"bfs\");\n bfs(startNode, 0);\n }\n return maxDepth;\n }\n /**\n * Check whether input is a proper prefix of at least one word.\n * @remarks Time O(L), Space O(1)\n * @param input - String to test as prefix.\n * @returns True if input is a prefix but not a full word.\n */\n hasPurePrefix(input) {\n input = this._caseProcess(input);\n let cur = this.root;\n for (const c of input) {\n const nodeC = cur.children.get(c);\n if (!nodeC) return false;\n cur = nodeC;\n }\n return !cur.isEnd;\n }\n /**\n * Check whether any word starts with input.\n * @remarks Time O(L), Space O(1)\n * @param input - String to test as prefix.\n * @returns True if input matches a path from root.\n */\n hasPrefix(input) {\n input = this._caseProcess(input);\n let cur = this.root;\n for (const c of input) {\n const nodeC = cur.children.get(c);\n if (!nodeC) return false;\n cur = nodeC;\n }\n return true;\n }\n /**\n * Check whether the trie’s longest common prefix equals input.\n * @remarks Time O(min(H,L)), Space O(1)\n * @param input - Candidate longest common prefix.\n * @returns True if input equals the common prefix.\n */\n hasCommonPrefix(input) {\n input = this._caseProcess(input);\n let commonPre = \"\";\n const dfs = /* @__PURE__ */ __name((cur) => {\n commonPre += cur.key;\n if (commonPre === input) return;\n if (cur.isEnd) return;\n if (cur && cur.children && cur.children.size === 1) dfs(Array.from(cur.children.values())[0]);\n else return;\n }, \"dfs\");\n dfs(this.root);\n return commonPre === input;\n }\n /**\n * Return the longest common prefix among all words.\n * @remarks Time O(H), Space O(1)\n * @returns The longest common prefix string.\n */\n getLongestCommonPrefix() {\n let commonPre = \"\";\n const dfs = /* @__PURE__ */ __name((cur) => {\n commonPre += cur.key;\n if (cur.isEnd) return;\n if (cur && cur.children && cur.children.size === 1) dfs(Array.from(cur.children.values())[0]);\n else return;\n }, \"dfs\");\n dfs(this.root);\n return commonPre;\n }\n /**\n * Collect words under a prefix up to a maximum count.\n * @remarks Time O(K·L), Space O(K·L)\n * @param [prefix] - Prefix to match; default empty string for root.\n * @param [max] - Maximum number of words to return; default is Number.MAX_SAFE_INTEGER.\n * @param [isAllWhenEmptyPrefix] - When true, collect from root even if prefix is empty.\n * @returns Array of collected words (at most max).\n */\n getWords(prefix = \"\", max = Number.MAX_SAFE_INTEGER, isAllWhenEmptyPrefix = false) {\n prefix = this._caseProcess(prefix);\n const words = [];\n let found = 0;\n const dfs = /* @__PURE__ */ __name((node, word) => {\n for (const [char, childNode] of node.children) {\n if (found >= max) return;\n dfs(childNode, word + char);\n }\n if (node.isEnd) {\n if (found >= max) return;\n words.push(word);\n found++;\n }\n }, \"dfs\");\n let startNode = this.root;\n if (prefix) {\n for (const c of prefix) {\n const nodeC = startNode.children.get(c);\n if (nodeC) {\n startNode = nodeC;\n } else {\n return [];\n }\n }\n }\n if (isAllWhenEmptyPrefix || startNode !== this.root) dfs(startNode, prefix);\n return words;\n }\n /**\n * Deep clone this trie by iterating and inserting all words.\n * @remarks Time O(ΣL), Space O(ΣL)\n * @returns A new trie with the same words and options.\n */\n clone() {\n const next = this._createInstance();\n for (const x of this) next.add(x);\n return next;\n }\n /**\n * Filter words into a new trie of the same class.\n * @remarks Time O(ΣL), Space O(ΣL)\n * @param predicate - Predicate (word, index, trie) → boolean to keep word.\n * @param [thisArg] - Value for `this` inside the predicate.\n * @returns A new trie containing words that satisfy the predicate.\n */\n filter(predicate, thisArg) {\n const results = this._createInstance();\n let index = 0;\n for (const word of this) {\n if (predicate.call(thisArg, word, index, this)) {\n results.add(word);\n }\n index++;\n }\n return results;\n }\n map(callback, options, thisArg) {\n const newTrie = this._createLike([], options);\n let i = 0;\n for (const x of this) {\n const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);\n if (typeof v !== \"string\") {\n throw new TypeError(`Trie.map callback must return string; got ${typeof v}`);\n }\n newTrie.add(v);\n }\n return newTrie;\n }\n /**\n * Map words into a new trie of the same element type.\n * @remarks Time O(ΣL), Space O(ΣL)\n * @param callback - Mapping function (word, index, trie) → string.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new trie with mapped words.\n */\n mapSame(callback, thisArg) {\n const next = this._createInstance();\n let i = 0;\n for (const key of this) {\n const mapped = thisArg === void 0 ? callback(key, i++, this) : callback.call(thisArg, key, i++, this);\n next.add(mapped);\n }\n return next;\n }\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind trie instance.\n */\n _createInstance(options) {\n const Ctor = this.constructor;\n const next = new Ctor([], {\n toElementFn: this.toElementFn,\n caseSensitive: this.caseSensitive,\n ...options != null ? options : {}\n });\n return next;\n }\n /**\n * (Protected) Create a like-kind trie and seed it from an iterable.\n * @remarks Time O(ΣL), Space O(ΣL)\n * @template RM\n * @param [elements] - Iterable used to seed the new trie.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind Trie instance.\n */\n _createLike(elements = [], options) {\n const Ctor = this.constructor;\n return new Ctor(elements, options);\n }\n /**\n * (Protected) Spawn an empty like-kind trie instance.\n * @remarks Time O(1), Space O(1)\n * @template RM\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind Trie instance.\n */\n _spawnLike(options) {\n return this._createLike([], options);\n }\n /**\n * (Protected) Iterate all words in lexicographic order of edges.\n * @remarks Time O(ΣL), Space O(H)\n * @returns Iterator of words.\n */\n *_getIterator() {\n function* _dfs(node, path) {\n if (node.isEnd) {\n yield path;\n }\n for (const [char, childNode] of node.children) {\n yield* _dfs(childNode, path + char);\n }\n }\n __name(_dfs, \"_dfs\");\n yield* _dfs(this.root, \"\");\n }\n /**\n * (Protected) Normalize a string according to case sensitivity.\n * @remarks Time O(L), Space O(L)\n * @param str - Input string to normalize.\n * @returns Normalized string based on caseSensitive.\n */\n _caseProcess(str) {\n if (!this._caseSensitive) {\n str = str.toLowerCase();\n }\n return str;\n }\n};\n__name(_Trie, \"Trie\");\nvar Trie = _Trie;\n\n// src/data-structures/tree/tree.ts\nvar _TreeNode = class _TreeNode {\n /**\n * The constructor function initializes a TreeNode object with a key, optional value, and optional\n * children.\n * @param {string} key - A string representing the key of the tree node.\n * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the\n * value associated with the node. If no value is provided, it defaults to `undefined`.\n * @param {TreeNode<V>[]} [children] - The `children` parameter is an optional array of `TreeNode<V>`\n * objects. It represents the child nodes of the current node. If no children are provided, the\n * default value is an empty array.\n */\n constructor(key, value, children) {\n __publicField(this, \"_key\");\n __publicField(this, \"_value\");\n __publicField(this, \"_children\");\n this._key = key;\n this._value = value || void 0;\n if (children) this._children = children;\n }\n /**\n * The function returns the value of the protected variable _key.\n * @returns The value of the `_key` property, which is a string.\n */\n get key() {\n return this._key;\n }\n /**\n * The above function sets the value of a protected variable called \"key\".\n * @param {string} value - The value parameter is a string that represents the value to be assigned\n * to the key.\n */\n set key(value) {\n this._key = value;\n }\n /**\n * The function returns the value stored in a variable, or undefined if the variable is empty.\n * @returns The value of the variable `_value` is being returned.\n */\n get value() {\n return this._value;\n }\n /**\n * The function sets the value of a variable.\n * @param {V | undefined} value - The parameter \"value\" is of type \"V | undefined\", which means it\n * can accept a value of type \"V\" or it can be undefined.\n */\n set value(value) {\n this._value = value;\n }\n /**\n * The function returns an array of TreeNode objects or undefined.\n * @returns The `children` property is being returned. It is of type `TreeNode<V>[] | undefined`,\n * which means it can either be an array of `TreeNode<V>` objects or `undefined`.\n */\n get children() {\n return this._children;\n }\n /**\n * The function sets the value of the children property of a TreeNode object.\n * @param {TreeNode<V>[] | undefined} value - The value parameter is of type TreeNode<V>[] |\n * undefined. This means that it can accept an array of TreeNode objects or undefined.\n */\n set children(value) {\n this._children = value;\n }\n /**\n * The function `addChildren` adds one or more child nodes to the current node.\n * @param {TreeNode<V> | TreeNode<V>[]} children - The `children` parameter can be either a single\n * `TreeNode<V>` object or an array of `TreeNode<V>` objects.\n */\n addChildren(children) {\n if (!this._children) {\n this._children = [];\n }\n if (children instanceof _TreeNode) {\n this._children.push(children);\n } else {\n this._children = this._children.concat(children);\n }\n }\n /**\n * The function `getHeight()` calculates the maximum depth of a tree structure by performing a\n * breadth-first search.\n * @returns the maximum depth or height of the tree.\n */\n getHeight() {\n let maxDepth = 0;\n if (this) {\n const bfs = /* @__PURE__ */ __name((node, level) => {\n if (level > maxDepth) {\n maxDepth = level;\n }\n const { _children } = node;\n if (_children) {\n for (let i = 0, len = _children.length; i < len; i++) {\n bfs(_children[i], level + 1);\n }\n }\n }, \"bfs\");\n bfs(this, 0);\n }\n return maxDepth;\n }\n};\n__name(_TreeNode, \"TreeNode\");\nvar TreeNode = _TreeNode;\n/**\n * data-structure-typed\n *\n * @author Pablo Zeng\n * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>\n * @license MIT License\n */\n/**\n * data-structure-typed\n * @author Kirk Qi\n * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>\n * @license MIT License\n */\n/**\n * @remarks Time O(n log n), Space O(n).\n * data-structure-typed\n * @author Kirk Qi\n * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>\n * @license MIT License\n */\n/**\n * data-structure-typed\n *\n * @author Pablo Zeng\n * @copyright Copyright (c) 2022 Pablo Zeng\n * @license MIT License\n */\n/**\n * data-structure-typed\n *\n * @author Kirk Qi\n * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>\n * @license MIT License\n */\n\nexport { AVLTree, AVLTreeNode, AbstractEdge, AbstractGraph, AbstractVertex, BST, BSTNode, BinaryIndexedTree, BinaryTree, BinaryTreeNode, Character, DFSOperation, Deque, DirectedEdge, DirectedGraph, DirectedVertex, DoublyLinkedList, DoublyLinkedListNode, FibonacciHeap, FibonacciHeapNode, HashMap, Heap, IterableElementBase, IterableEntryBase, LinkedHashMap, LinkedListQueue, MapEdge, MapGraph, MapVertex, Matrix, MaxHeap, MaxPriorityQueue, MinHeap, MinPriorityQueue, Navigator, PriorityQueue, Queue, Range, RedBlackTree, RedBlackTreeNode, SegmentTree, SegmentTreeNode, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, Stack, TreeMap, TreeMultiMap, TreeMultiMapNode, TreeMultiSet, TreeNode, TreeSet, Trie, TrieNode, UndirectedEdge, UndirectedGraph, UndirectedVertex, arrayRemove, asyncTrampoline, calcMinUnitsRequired, getMSB, isComparable, isTrampolineThunk, isWeakKey, makeAsyncTrampoline, makeTrampoline, makeTrampolineThunk, rangeCheck, roundFixed, throwRangeError, toBinaryString, trampoline, uuidV4 };\n//# sourceMappingURL=index.mjs.map\n//# sourceMappingURL=index.mjs.map"],"mappings":"mdAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KCAA,IAAIC,GAAY,OAAO,eACnBC,GAAeC,GAAQ,CACzB,MAAM,UAAUA,CAAG,CACrB,EACIC,GAAkB,CAACC,EAAKC,EAAKC,IAAUD,KAAOD,EAAMJ,GAAUI,EAAKC,EAAK,CAAE,WAAY,GAAM,aAAc,GAAM,SAAU,GAAM,MAAAC,CAAM,CAAC,EAAIF,EAAIC,CAAG,EAAIC,EACtJC,EAAS,CAACC,EAAQF,IAAUN,GAAUQ,EAAQ,OAAQ,CAAE,MAAAF,EAAO,aAAc,EAAK,CAAC,EACnFG,EAAgB,CAACL,EAAKC,EAAKC,IAAUH,GAAgBC,EAAK,OAAOC,GAAQ,SAAWA,EAAM,GAAKA,EAAKC,CAAK,EACzGI,GAAgB,CAACN,EAAKO,EAAQT,IAAQS,EAAO,IAAIP,CAAG,GAAKH,GAAY,UAAYC,CAAG,EACpFU,EAAe,CAACR,EAAKO,EAAQE,KAAYH,GAAcN,EAAKO,EAAQ,yBAAyB,EAAGE,EAASA,EAAO,KAAKT,CAAG,EAAIO,EAAO,IAAI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E,GAAO,MAAM,EAIpB,IAAI4C,GAAY,MAAMA,EAAU,CAW9B,YAAYC,EAAKC,EAAOC,EAAU,CAChCC,EAAc,KAAM,MAAM,EAC1BA,EAAc,KAAM,QAAQ,EAC5BA,EAAc,KAAM,WAAW,EAC/B,KAAK,KAAOH,EACZ,KAAK,OAASC,GAAS,OACnBC,IAAU,KAAK,UAAYA,EACjC,CAKA,IAAI,KAAM,CACR,OAAO,KAAK,IACd,CAMA,IAAI,IAAID,EAAO,CACb,KAAK,KAAOA,CACd,CAKA,IAAI,OAAQ,CACV,OAAO,KAAK,MACd,CAMA,IAAI,MAAMA,EAAO,CACf,KAAK,OAASA,CAChB,CAMA,IAAI,UAAW,CACb,OAAO,KAAK,SACd,CAMA,IAAI,SAASA,EAAO,CAClB,KAAK,UAAYA,CACnB,CAMA,YAAYC,EAAU,CACf,KAAK,YACR,KAAK,UAAY,CAAC,GAEhBA,aAAoBH,GACtB,KAAK,UAAU,KAAKG,CAAQ,EAE5B,KAAK,UAAY,KAAK,UAAU,OAAOA,CAAQ,CAEnD,CAMA,WAAY,CACV,IAAIE,EAAW,EACf,GAAI,KAAM,CACR,IAAMC,EAAsBC,EAAO,CAACC,EAAMC,IAAU,CAC9CA,EAAQJ,IACVA,EAAWI,GAEb,GAAM,CAAE,UAAAC,CAAU,EAAIF,EACtB,GAAIE,EACF,QAASC,EAAI,EAAGC,EAAMF,EAAU,OAAQC,EAAIC,EAAKD,IAC/CL,EAAII,EAAUC,CAAC,EAAGF,EAAQ,CAAC,CAGjC,EAAG,KAAK,EACRH,EAAI,KAAM,CAAC,CACb,CACA,OAAOD,CACT,CACF,EACAE,EAAOP,GAAW,UAAU","names":["src_exports","__export","TreeSet","__defProp","__typeError","msg","__defNormalProp","obj","key","value","__name","target","__publicField","__accessCheck","member","__privateGet","getter","__privateAdd","__privateSet","setter","_IterableEntryBase","args","item","predicate","thisArg","index","callbackfn","itemKey","elementValue","initialValue","accumulator","IterableEntryBase","_IterableElementBase","options","toElementFn","element","ele","iter","acc","first","IterableElementBase","uuidV4","r","arrayRemove","array","i","len","result","getMSB","rangeCheck","min","max","message","isWeakKey","__name","input","inputType","calcMinUnitsRequired","totalQuantity","unitSize","isPrimitiveComparable","value","valueType","__name","tryObjectToPrimitive","obj","valueOfResult","stringResult","isComparable","isForceObjectComparable","comparableValue","makeTrampolineThunk","computation","isTrampolineThunk","trampoline","initial","current","makeTrampoline","fn","args","asyncTrampoline","makeAsyncTrampoline","toBinaryString","num","digit","binaryString","_HashMap","IterableEntryBase","entryOrRawElements","options","__publicField","key","hashFn","toEntryFn","rawElement","strKey","results","rawEle","_a","opts","callbackfn","thisArg","out","index","predicate","entries","Ctor","fresh","sk","node","keyType","_LinkedHashMap","IterableEntryBase","entryOrRawElements","options","__publicField","__name","key","rawElement","hashFn","objHashFn","toEntryFn","node","value","isNewKey","isWeakKey","hash","results","rawEle","hash2","node2","index","rangeCheck","predicate","cur","opts","thisArg","out","callback","newKey","newValue","prev","next","entries","Ctor","_LinkedListNode","value","__publicField","__name","LinkedListNode","_LinearBase","IterableElementBase","options","maxLen","searchElement","fromIndex","predicate","thisArg","item","items","newList","compareFn","arr","start","deleteCount","removedList","i","removed","separator","array","callbackfn","initialValue","accumulator","end","LinearBase","_LinearLinkedBase","iterator","current","index","c","currentIndex","currentNode","previousNode","node","nextNode","LinearLinkedBase","_SinglyLinkedListNode","SinglyLinkedListNode","_SinglyLinkedList","elements","_a","data","list","x","elementOrNode","newNode","value2","ans","el","elementNodeOrPredicate","targetNode","prevNode","newElementOrNode","prev","next","existingElementOrNode","existingNode","cur","removedCount","afterNode","firstInserted","lastInserted","it","elementOrPredicate","count","equals","out","v","callback","mv","reversedArr","Ctor","SinglyLinkedList","input","_DoublyLinkedListNode","DoublyLinkedListNode","_DoublyLinkedList","target","isMatch","removedNode","_SkipListNode","key","value","level","__publicField","__name","SkipListNode","_SkipList","elements","options","maxLevel","probability","firstNode","current","i","newNode","update","nextNode","lastLess","_Stack","IterableElementBase","elements","options","__publicField","element","ans","el","idx","index","predicate","i","out","v","thisArg","callback","mv","equals","target","Ctor","__name","_Queue","LinearBase","elements","options","__publicField","autoCompactRatio","value","element","ans","el","first","i","index","gi","deleted","newElement","start","deleteCount","items","removedArray","removed","out","predicate","thisArg","v","callback","_a","_b","Ctor","mv","cur","__name","Queue","_LinkedListQueue","SinglyLinkedList","_Deque","LinearBase","elements","options","__publicField","bucketSize","_size","calcMinUnitsRequired","i","needBucketNum","data","element","ans","el","pos","bucketIndex","indexInBucket","rangeCheck","num","length","arr","v","isCutSelf","newDeque","start","deleteCount","items","removed","tail","it","deleted","targetBucket","targetPointer","curBucket","curPointer","nextBucket","nextPointer","size","index","oldElement","predicate","equals","bucket","_bucketFirst","_bucketLast","_firstInBucket","_lastInBucket","prev","cur","newBuckets","thisArg","out","callback","mv","addBucketNum","overallIndex","Ctor","__name","_Heap","IterableElementBase","elements","options","__publicField","__name","a","b","comparator","_a","element","flags","el","ok","value","last","index","predicate","idx","equals","order","result","_dfs","left","right","results","i","visited","cloned","x","top","next","callback","thisArg","out","toElementFn","rest","v","parent","parentItem","halfLength","minItem","Ctor","Heap","_FibonacciHeapNode","degree","FibonacciHeapNode","_FibonacciHeap","node","head","started","z","heapToMerge","thisRoot","otherRoot","thisRootRight","otherRootLeft","y","A","d","t","_MaxHeap","Heap","elements","options","__name","a","b","_MinHeap","Heap","elements","options","__name","_AbstractVertex","key","value","__publicField","__name","AbstractVertex","_AbstractEdge","weight","uuidV4","AbstractEdge","_AbstractGraph","IterableEntryBase","options","graph","v","vertexKey","vertexOrKey","keyOrVertex","newVertex","potentialKey","potentialKeyType","vertexMap","removed","v1","v2","srcOrEdge","dest","newEdge","srcOrKey","destOrKey","edge","limit","paths","vertex1","vertex2","stack","vertex","path","neighbors","neighbor","newPath","_a","sum","i","isWeight","allPaths","min","visited","queue","Queue","cost","layerSize","cur","isDFS","_b","minIndex","index","pathSumWeight","minPath","dfs","visiting","src","getMinDist","genPaths","minDist","minDest","distMap","seen","preMap","srcVertex","destVertex","getMinOfNoSeen","minV","getPaths","parent","reversed","curFromMap","neighborFromMap","d","heap","Heap","a","b","curHeapNode","dist","distSrcToNeighbor","scanNegativeCycle","getMin","genPath","hasNegativeCycle","numOfVertices","edgeMap","numOfEdges","j","ends","s","sWeight","dWeight","idAndVertices","n","costs","predecessor","k","isInclude2Cycle","cycles","currentPath","visited2","uniqueCycles","cycle","sorted","cycleString","predicate","thisArg","filtered","callback","mapped","_options","Ctor","instance","iter","g","edges","e","va","vb","ka","kb","hasA","hasB","w","val","AbstractGraph","_DirectedVertex","DirectedVertex","_DirectedEdge","DirectedEdge","_DirectedGraph","keys","entries","srcOutEdges","arrayRemove","destInEdges","edgeOrSrcVertexKey","destVertexKey","v1ToV2","v2ToV1","target","destinations","outgoingEdges","outEdge","child","propertyName","statusMap","entry","hasCycle","children","childStatus","outEdges","dfnMap","lowMap","SCCs","time","inStack","SCC","poppedVertex","DirectedGraph","_UndirectedVertex","UndirectedVertex","_UndirectedEdge","UndirectedEdge","_UndirectedGraph","v1Edges","v2Edges","edgeOrOneSideVertexKey","otherSideVertexKey","oneSide","otherSide","neighborEdges","restEdges","edgeSet","bridges","cutVertices","childCount","end","endVertex","_MapVertex","DirectedVertex","key","value","lat","long","__publicField","__name","MapVertex","_MapEdge","DirectedEdge","src","dest","weight","MapEdge","_MapGraph","DirectedGraph","originCoord","bottomRight","options","oc","br","_Range","low","high","includeLow","includeHigh","key","comparator","lowCheck","highCheck","__name","Range","_BinaryTreeNode","value","__publicField","v","BinaryTreeNode","_BinaryTree","IterableEntryBase","keysNodesEntriesOrRaws","options","node","iterationType","toEntryFn","isMapMode","isDuplicate","keyNodeOrEntry","keyNodeEntryOrRaw","keyNodeEntryOrPredicate","isComparable","newNode","queue","Queue","potentialParent","cur","values","inserted","valuesIterator","valueResult","anotherTree","keyNodeEntryRawOrPredicate","deletedResult","curr","parent","needBalanced","orgCurrent","leftSubTreeRightMost","parentOfLeftSubTreeMax","fp","onlyOne","callback","startNode","predicate","ans","dfs","stack","_a","_b","startNodeSired","min","max","numKey","isStandardBST","isInverseBST","checkBST","checkMax","prev","dist","distEnsured","beginRootEnsured","depth","_getMaxHeight","leftHeight","rightHeight","maxHeight","_getMinHeight","leftMinHeight","rightMinHeight","last","depths","beginNode","isReverse","result","beginNodeEnsured","ensuredStartNode","left","makeTrampoline","makeTrampolineThunk","right","predecessor","x","y","pattern","includeNull","level","current","levelSize","i","leaves","levelsNodes","_recursive","head","_reverseEdge","pre","next","_printEdge","tail","cur2","out","thisArg","k","cb","opts","output","root","lines","paragraph","line","shouldVisitLeft","shouldVisitRight","shouldVisitRoot","shouldProcessRoot","visitLeft","visitRight","pushLeft","pushRight","pushRoot","Ctor","iter","entryValue","finalValue","cloned","isShowNull","isShowUndefined","isShowRedBlackNIL","emptyDisplayLayout","width","_buildNodeDisplay","leftLines","leftWidth","leftMiddle","rightLines","rightWidth","rightMiddle","firstLine","secondLine","mergedLines","leftLine","rightLine","srcNode","destNode","tempNode","oldNode","p","BinaryTree","_BSTNode","BSTNode","_BST","targetKey","start","NIL","cmpFn","c","isRange","isPred","range","leftS","leftI","benchmarkKey","rightS","rightI","searchRange","isBalanceAdd","kve","val","realBTNExemplars","sorted","a","b","keyA","keyB","_dfs","arr","mid","orgIndex","entry","popped","l","r","m","actualCallback","actualIterationType","lesserOrGreater","targetNode","targetNodeEnsured","compared","nodes","n","build","leftChild","rightChild","newRoot","balanced","_height","index","toDelete","results","deleteInfo","rightResult","isLower","cmp","leftResult","transplant","u","minNode","succ","BST","_BinaryIndexedTree","frequency","getMSB","position","change","freqCur","freq","count","sum","delta","z","freqNew","before","sumT","middle","sumM","_SegmentTreeNode","start","end","sum","value","__publicField","__name","SegmentTreeNode","_SegmentTree","values","mid","left","right","cur","index","root","dfs","index2","sum2","value2","indexA","indexB","i","j","leftSum","rightSum","_AVLTreeNode","key","value","__publicField","v","__name","AVLTreeNode","_AVLTree","BST","keysNodesEntriesOrRaws","options","keyNodeOrEntry","inserted","deletedResults","needBalanced","iterationType","nodes","node","n","build","l","r","parent","m","root","lh","rh","newRoot","callback","thisArg","out","index","Ctor","iter","srcNode","destNode","srcNodeEnsured","destNodeEnsured","height","tempNode","left","leftHeight","rightHeight","A","parentOfA","B","C","path","node2","oldNode","newNode","_RedBlackTreeNode","key","value","color","__publicField","v","__name","RedBlackTreeNode","_RedBlackTree","BST","keysNodesEntriesOrRaws","options","keyNodeOrEntry","_a","_b","_c","NIL","cmp","cur","c","node","cur2","p","parent","side","nextValue","_d","_e","_f","_g","comparator","header","minN","cMin","minL","newNode2","maxN","cMax","maxR","isMapMode","store","current","lastCompared","newNode","hMin","hMax","hint","_h","_i","_j","_k","_l","_m","c0","pred","succ","newValue","insertStatus","keyNodeEntryRawOrPredicate","results","nodeToDelete","willDeleteMin","willDeleteMax","nextMin","nextMax","originalColor","replacementNode","successor","n","callback","thisArg","out","index","Ctor","iter","oldNode","u","z","leftRotate","rightRotate","gp","y","p2","gp2","sibling","x","RedBlackTree","_core","_isDefaultComparator","_userComparator","_TreeSet","elements","__privateAdd","__privateSet","toElementFn","item","k","a","b","aa","bb","ta","tb","__privateGet","res","cb","callbackfn","mk","initialValue","acc","range","lowInclusive","highInclusive","low","high","keys","TreeSet","_TreeMultiMapNode","_core2","_isDefaultComparator2","_TreeMultiMap","keysNodesEntriesOrRaws","options","__privateAdd","_a","comparator","TreeSet","__privateSet","toEntryFn","RedBlackTree","x","k","bucket","__privateGet","key","b","sum","value","entry","existing","eq","v","idx","removed","i","e","callback","predicate","filtered","mapper","mapped","initialValue","acc","results","range","__name","_core3","_isDefaultComparator3","_userComparator2","_TreeMap","entries","options","__privateAdd","_a","__privateSet","toEntryFn","comparator","RedBlackTree","item","k","v","a","b","aa","bb","ta","tb","key","__privateGet","value","res","cb","thisArg","callbackfn","out","index","mk","mv","initialValue","acc","entry","range","lowInclusive","highInclusive","low","high","keys","cmp","__name","_core4","_isDefaultComparator4","_TreeMultiSet","elements","options","__privateAdd","__publicField","_a","toElementFn","comparator","TreeSet","__privateSet","RedBlackTree","item","k","key","__privateGet","n","next","old","removed","v","c","callback","predicate","result","initialValue","acc","mapper","newKey","newCount","range","cb","node","__name","_PriorityQueue","Heap","elements","options","__name","PriorityQueue","_MinPriorityQueue","_MaxPriorityQueue","PriorityQueue","elements","options","__name","a","b","_Matrix","data","options","__publicField","_a","_b","_c","rows","cols","addFn","subtractFn","multiplyFn","i","row","col","value","matrix","resultData","j","a","b","added","subtracted","sum","k","multiplied","trans","augmentedMatrixData","augmentedMatrix","pivotRow","pivotElement","factor","inverseData","row1","row2","temp","scalar","targetRow","sourceRow","scaledValue","__name","_Character","direction","turning","__publicField","__name","Character","_Navigator","matrix","onMove","cur","charDir","VISITED","forward","row","i","j","_TrieNode","key","__publicField","value","__name","TrieNode","_Trie","IterableElementBase","words","options","caseSensitive","word","cur","isNewWord","c","nodeC","ans","isDeleted","dfs","i","char","child","startNode","maxDepth","bfs","node","level","children","input","commonPre","prefix","max","isAllWhenEmptyPrefix","found","childNode","next","x","predicate","thisArg","results","index","callback","newTrie","v","mapped","Ctor","elements","_dfs","path","str","_TreeNode","key","value","children","__publicField","maxDepth","bfs","__name","node","level","_children","i","len"]}