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.
- package/.eslintrc.js +61 -0
- package/.prettierignore +6 -0
- package/.prettierrc.js +16 -0
- package/LICENSE +21 -0
- package/README.md +482 -0
- package/coverage/clover.xml +13 -0
- package/coverage/coverage-final.json +96 -0
- package/coverage/coverage-summary.json +60 -0
- package/coverage/lcov-report/base.css +403 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +119 -0
- package/coverage/lcov-report/index.ts.html +109 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +206 -0
- package/coverage/lcov.info +14 -0
- package/dist/cjs/index.cjs +12 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs-legacy/index.cjs +12 -0
- package/dist/cjs-legacy/index.cjs.map +1 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm-legacy/index.mjs +3 -0
- package/dist/esm-legacy/index.mjs.map +1 -0
- package/dist/types/common/index.d.ts +12 -0
- package/dist/types/constants/index.d.ts +4 -0
- package/dist/types/data-structures/base/index.d.ts +2 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +219 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +150 -0
- package/dist/types/data-structures/base/linear-base.d.ts +335 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +236 -0
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +197 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +440 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +807 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +645 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +10 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +312 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -0
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +243 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +333 -0
- package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +332 -0
- package/dist/types/data-structures/graph/index.d.ts +4 -0
- package/dist/types/data-structures/graph/map-graph.d.ts +78 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +347 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +428 -0
- package/dist/types/data-structures/hash/index.d.ts +1 -0
- package/dist/types/data-structures/heap/heap.d.ts +552 -0
- package/dist/types/data-structures/heap/index.d.ts +3 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +32 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +33 -0
- package/dist/types/data-structures/index.d.ts +12 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +437 -0
- package/dist/types/data-structures/linked-list/index.d.ts +3 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +567 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -0
- package/dist/types/data-structures/matrix/index.d.ts +2 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/matrix/navigator.d.ts +55 -0
- package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -0
- package/dist/types/data-structures/queue/deque.d.ts +459 -0
- package/dist/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/data-structures/queue/queue.d.ts +364 -0
- package/dist/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/data-structures/stack/stack.d.ts +324 -0
- package/dist/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/data-structures/tree/tree.d.ts +62 -0
- package/dist/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/data-structures/trie/trie.d.ts +412 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/interfaces/binary-tree.d.ts +60 -0
- package/dist/types/interfaces/doubly-linked-list.d.ts +1 -0
- package/dist/types/interfaces/graph.d.ts +21 -0
- package/dist/types/interfaces/heap.d.ts +1 -0
- package/dist/types/interfaces/index.d.ts +8 -0
- package/dist/types/interfaces/navigator.d.ts +1 -0
- package/dist/types/interfaces/priority-queue.d.ts +1 -0
- package/dist/types/interfaces/segment-tree.d.ts +1 -0
- package/dist/types/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/types/types/common.d.ts +15 -0
- package/dist/types/types/data-structures/base/base.d.ts +13 -0
- package/dist/types/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
- package/dist/types/types/data-structures/binary-tree/index.d.ts +9 -0
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
- package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
- package/dist/types/types/data-structures/graph/index.d.ts +3 -0
- package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
- package/dist/types/types/data-structures/hash/index.d.ts +2 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
- package/dist/types/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/types/data-structures/index.d.ts +12 -0
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/index.d.ts +3 -0
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
- package/dist/types/types/data-structures/matrix/index.d.ts +2 -0
- package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
- package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
- package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
- package/dist/types/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
- package/dist/types/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
- package/dist/types/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/utils/index.d.ts +2 -0
- package/dist/types/types/utils/utils.d.ts +22 -0
- package/dist/types/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/number.d.ts +14 -0
- package/dist/types/utils/utils.d.ts +209 -0
- package/dist/umd/red-black-tree-typed.js +14578 -0
- package/dist/umd/red-black-tree-typed.js.map +1 -0
- package/dist/umd/red-black-tree-typed.min.js +44 -0
- package/dist/umd/red-black-tree-typed.min.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1383 -0
- package/docs/classes/AVLTree.html +2046 -0
- package/docs/classes/AVLTreeNode.html +263 -0
- package/docs/index.html +523 -0
- package/docs/modules.html +45 -0
- package/jest.config.js +8 -0
- package/package.json +113 -0
- package/src/common/index.ts +23 -0
- package/src/constants/index.ts +4 -0
- package/src/data-structures/base/index.ts +2 -0
- package/src/data-structures/base/iterable-element-base.ts +352 -0
- package/src/data-structures/base/iterable-entry-base.ts +246 -0
- package/src/data-structures/base/linear-base.ts +643 -0
- package/src/data-structures/binary-tree/avl-tree-counter.ts +539 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +438 -0
- package/src/data-structures/binary-tree/avl-tree.ts +840 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +331 -0
- package/src/data-structures/binary-tree/binary-tree.ts +2492 -0
- package/src/data-structures/binary-tree/bst.ts +2024 -0
- package/src/data-structures/binary-tree/index.ts +10 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +767 -0
- package/src/data-structures/binary-tree/segment-tree.ts +324 -0
- package/src/data-structures/binary-tree/tree-counter.ts +575 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +549 -0
- package/src/data-structures/graph/abstract-graph.ts +1081 -0
- package/src/data-structures/graph/directed-graph.ts +715 -0
- package/src/data-structures/graph/index.ts +4 -0
- package/src/data-structures/graph/map-graph.ts +132 -0
- package/src/data-structures/graph/undirected-graph.ts +626 -0
- package/src/data-structures/hash/hash-map.ts +813 -0
- package/src/data-structures/hash/index.ts +1 -0
- package/src/data-structures/heap/heap.ts +1020 -0
- package/src/data-structures/heap/index.ts +3 -0
- package/src/data-structures/heap/max-heap.ts +47 -0
- package/src/data-structures/heap/min-heap.ts +36 -0
- package/src/data-structures/index.ts +12 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +876 -0
- package/src/data-structures/linked-list/index.ts +3 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +1050 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
- package/src/data-structures/matrix/index.ts +2 -0
- package/src/data-structures/matrix/matrix.ts +491 -0
- package/src/data-structures/matrix/navigator.ts +124 -0
- package/src/data-structures/priority-queue/index.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +42 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +29 -0
- package/src/data-structures/priority-queue/priority-queue.ts +19 -0
- package/src/data-structures/queue/deque.ts +1001 -0
- package/src/data-structures/queue/index.ts +2 -0
- package/src/data-structures/queue/queue.ts +592 -0
- package/src/data-structures/stack/index.ts +1 -0
- package/src/data-structures/stack/stack.ts +469 -0
- package/src/data-structures/tree/index.ts +1 -0
- package/src/data-structures/tree/tree.ts +115 -0
- package/src/data-structures/trie/index.ts +1 -0
- package/src/data-structures/trie/trie.ts +756 -0
- package/src/index.ts +24 -0
- package/src/interfaces/binary-tree.ts +252 -0
- package/src/interfaces/doubly-linked-list.ts +1 -0
- package/src/interfaces/graph.ts +44 -0
- package/src/interfaces/heap.ts +1 -0
- package/src/interfaces/index.ts +8 -0
- package/src/interfaces/navigator.ts +1 -0
- package/src/interfaces/priority-queue.ts +1 -0
- package/src/interfaces/segment-tree.ts +1 -0
- package/src/interfaces/singly-linked-list.ts +1 -0
- package/src/types/common.ts +25 -0
- package/src/types/data-structures/base/base.ts +34 -0
- package/src/types/data-structures/base/index.ts +1 -0
- package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree.ts +3 -0
- package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/binary-tree.ts +31 -0
- package/src/types/data-structures/binary-tree/bst.ts +19 -0
- package/src/types/data-structures/binary-tree/index.ts +9 -0
- package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -0
- package/src/types/data-structures/graph/abstract-graph.ts +18 -0
- package/src/types/data-structures/graph/directed-graph.ts +2 -0
- package/src/types/data-structures/graph/index.ts +3 -0
- package/src/types/data-structures/graph/map-graph.ts +1 -0
- package/src/types/data-structures/graph/undirected-graph.ts +1 -0
- package/src/types/data-structures/hash/hash-map.ts +19 -0
- package/src/types/data-structures/hash/index.ts +3 -0
- package/src/types/data-structures/heap/heap.ts +6 -0
- package/src/types/data-structures/heap/index.ts +1 -0
- package/src/types/data-structures/heap/max-heap.ts +1 -0
- package/src/types/data-structures/heap/min-heap.ts +1 -0
- package/src/types/data-structures/index.ts +12 -0
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -0
- package/src/types/data-structures/linked-list/index.ts +3 -0
- package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/types/data-structures/matrix/index.ts +2 -0
- package/src/types/data-structures/matrix/matrix.ts +7 -0
- package/src/types/data-structures/matrix/navigator.ts +14 -0
- package/src/types/data-structures/priority-queue/index.ts +3 -0
- package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +3 -0
- package/src/types/data-structures/queue/deque.ts +5 -0
- package/src/types/data-structures/queue/index.ts +2 -0
- package/src/types/data-structures/queue/queue.ts +5 -0
- package/src/types/data-structures/stack/index.ts +1 -0
- package/src/types/data-structures/stack/stack.ts +3 -0
- package/src/types/data-structures/tree/index.ts +1 -0
- package/src/types/data-structures/tree/tree.ts +1 -0
- package/src/types/data-structures/trie/index.ts +1 -0
- package/src/types/data-structures/trie/trie.ts +3 -0
- package/src/types/index.ts +3 -0
- package/src/types/utils/index.ts +2 -0
- package/src/types/utils/utils.ts +33 -0
- package/src/types/utils/validate-type.ts +35 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/number.ts +22 -0
- package/src/utils/utils.ts +350 -0
- package/test/index.test.ts +111 -0
- package/tsconfig.base.json +23 -0
- package/tsconfig.json +12 -0
- package/tsconfig.test.json +8 -0
- package/tsconfig.types.json +15 -0
- package/tsup.config.js +28 -0
- package/tsup.node.config.js +71 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";var redBlackTreeTyped=(()=>{var at=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Ie=(c,t)=>{for(var e in t)at(c,e,{get:t[e],enumerable:!0})},Te=(c,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Re(t))!Fe.call(c,s)&&s!==e&&at(c,s,{get:()=>t[s],enumerable:!(i=Le(t,s))||i.enumerable});return c};var Ce=c=>Te(at({},"__esModule",{value:!0}),c);var mi={};Ie(mi,{TreeSet:()=>ot});var Lt=Object.defineProperty,Rt=c=>{throw TypeError(c)},Se=(c,t,e)=>t in c?Lt(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e,f=(c,t)=>Lt(c,"name",{value:t,configurable:!0}),u=(c,t,e)=>Se(c,typeof t!="symbol"?t+"":t,e),Ft=(c,t,e)=>t.has(c)||Rt("Cannot "+e),d=(c,t,e)=>(Ft(c,t,"read from private field"),e?e.call(c):t.get(c)),A=(c,t,e)=>t.has(c)?Rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,e),B=(c,t,e,i)=>(Ft(c,t,"write to private field"),t.set(c,e),e),It=class{*[Symbol.iterator](...t){yield*this._getIterator(...t)}*entries(){for(let t of this)yield t}*keys(){for(let t of this)yield t[0]}*values(){for(let t of this)yield t[1]}every(t,e){let i=0;for(let s of this)if(!t.call(e,s[1],s[0],i++,this))return!1;return!0}some(t,e){let i=0;for(let s of this)if(t.call(e,s[1],s[0],i++,this))return!0;return!1}forEach(t,e){let i=0;for(let s of this){let[r,n]=s;t.call(e,n,r,i++,this)}}find(t,e){let i=0;for(let s of this){let[r,n]=s;if(t.call(e,n,r,i++,this))return s}}has(t){for(let e of this){let[i]=e;if(i===t)return!0}return!1}hasValue(t){for(let[,e]of this)if(e===t)return!0;return!1}get(t){for(let e of this){let[i,s]=e;if(i===t)return s}}reduce(t,e){let i=e,s=0;for(let r of this){let[n,h]=r;i=t(i,h,n,s++,this)}return i}toArray(){return[...this]}toVisual(){return[...this]}print(){console.log(this.toVisual())}};f(It,"IterableEntryBase");var st=It,Tt=class{constructor(t){if(u(this,"_toElementFn"),t){let{toElementFn:e}=t;if(typeof e=="function")this._toElementFn=e;else if(e)throw new TypeError("toElementFn must be a function type")}}get toElementFn(){return this._toElementFn}*[Symbol.iterator](...t){yield*this._getIterator(...t)}*values(){for(let t of this)yield t}every(t,e){let i=0;for(let s of this)if(e===void 0){if(!t(s,i++,this))return!1}else if(!t.call(e,s,i++,this))return!1;return!0}some(t,e){let i=0;for(let s of this)if(e===void 0){if(t(s,i++,this))return!0}else if(t.call(e,s,i++,this))return!0;return!1}forEach(t,e){let i=0;for(let s of this)e===void 0?t(s,i++,this):t.call(e,s,i++,this)}find(t,e){let i=0;for(let s of this)if(e===void 0){if(t(s,i++,this))return s}else if(t.call(e,s,i++,this))return s}has(t){for(let e of this)if(e===t)return!0;return!1}reduce(t,e){let i=0,s=this[Symbol.iterator](),r;if(arguments.length>=2)r=e;else{let n=s.next();if(n.done)throw new TypeError("Reduce of empty structure with no initial value");r=n.value,i=1}for(let n of s)r=t(r,n,i++,this);return r}toArray(){return[...this]}toVisual(){return[...this]}print(){console.log(this.toVisual())}};f(Tt,"IterableElementBase");var rt=Tt,Ae=f(function(){return"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g,function(c){let t=Math.random()*16|0;return(c=="x"?t:t&3|8).toString(16)})},"uuidV4"),z=f(function(c,t){let e=-1,i=c?c.length:0,s=[];for(;++e<i;){let r=c[e];t(r,e,c)&&(s.push(r),Array.prototype.splice.call(c,e--,1),i--)}return s},"arrayRemove"),Be=f(c=>c<=0?0:1<<31-Math.clz32(c),"getMSB"),j=f((c,t,e,i="Index out of bounds.")=>{if(c<t||c>e)throw new RangeError(i)},"rangeCheck");var q=f(c=>{let t=typeof c;return t==="object"&&c!==null||t==="function"},"isWeakKey"),yt=f((c,t)=>Math.floor((c+t-1)/t),"calcMinUnitsRequired");function et(c){let t=typeof c;return t==="number"?!0:t==="bigint"||t==="string"||t==="boolean"}f(et,"isPrimitiveComparable");function mt(c){if(typeof c.valueOf=="function"){let t=c.valueOf();if(t!==c){if(et(t))return t;if(typeof t=="object"&&t!==null)return mt(t)}}if(typeof c.toString=="function"){let t=c.toString();if(t!=="[object Object]")return t}return null}f(mt,"tryObjectToPrimitive");function X(c,t=!1){if(c==null)return!1;if(et(c))return!0;if(typeof c!="object")return!1;if(c instanceof Date||t)return!0;let e=mt(c);return e==null?!1:et(e)}f(X,"isComparable");var bt=f(c=>({isThunk:!0,fn:c}),"makeTrampolineThunk"),Ct=f(c=>typeof c=="object"&&c!==null&&"isThunk"in c&&c.isThunk,"isTrampolineThunk");function St(c){let t=c;for(;Ct(t);)t=t.fn();return t}f(St,"trampoline");function _t(c){return(...t)=>St(c(...t))}f(_t,"makeTrampoline");async function At(c){let t=await c;for(;Ct(t);)t=await t.fn();return t}f(At,"asyncTrampoline");function Ve(c){return async(...t)=>At(c(...t))}f(Ve,"makeAsyncTrampoline");function De(c,t=32){let e=(c>>>0).toString(2);return e=e.padStart(t,"0"),e}f(De,"toBinaryString");var Ke=class extends st{constructor(t=[],e){if(super(),u(this,"_store",{}),u(this,"_objMap",new Map),u(this,"_toEntryFn"),u(this,"_size",0),u(this,"_hashFn",f(i=>String(i),"_hashFn")),e){let{hashFn:i,toEntryFn:s}=e;i&&(this._hashFn=i),s&&(this._toEntryFn=s)}t&&this.setMany(t)}get store(){return this._store}get objMap(){return this._objMap}get toEntryFn(){return this._toEntryFn}get size(){return this._size}get hashFn(){return this._hashFn}isEmpty(){return this._size===0}clear(){this._store={},this._objMap.clear(),this._size=0}isEntry(t){return Array.isArray(t)&&t.length===2}set(t,e){if(this._isObjKey(t))this.objMap.has(t)||this._size++,this.objMap.set(t,e);else{let i=this._getNoObjKey(t);this.store[i]===void 0&&this._size++,this._store[i]={key:t,value:e}}return!0}setMany(t){let e=[];for(let i of t){let s,r;this.isEntry(i)?[s,r]=i:this._toEntryFn&&([s,r]=this._toEntryFn(i)),s!==void 0&&r!==void 0&&e.push(this.set(s,r))}return e}get(t){var e;if(this._isObjKey(t))return this.objMap.get(t);let i=this._getNoObjKey(t);return(e=this._store[i])==null?void 0:e.value}has(t){return this._isObjKey(t)?this.objMap.has(t):this._getNoObjKey(t)in this.store}delete(t){if(this._isObjKey(t))return this.objMap.has(t)&&this._size--,this.objMap.delete(t);let e=this._getNoObjKey(t);return e in this.store?(delete this.store[e],this._size--,!0):!1}setHashFn(t){return this._hashFn===t?this:(this._hashFn=t,this._rehashNoObj(),this)}clone(){let t={hashFn:this._hashFn,toEntryFn:this._toEntryFn};return this._createLike(this,t)}map(t,e){let i=this._createLike(),s=0;for(let[r,n]of this)i.set(r,t.call(e,n,r,s++,this));return i}filter(t,e){let i=this._createLike(),s=0;for(let[r,n]of this)t.call(e,n,r,s++,this)&&i.set(r,n);return i}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}_rehashNoObj(){let t={};for(let{key:e,value:i}of Object.values(this._store)){let s=this._getNoObjKey(e);t[s]={key:e,value:i}}this._store=t}*_getIterator(){for(let t of Object.values(this.store))yield[t.key,t.value];for(let t of this.objMap)yield t}_isObjKey(t){let e=typeof t;return(e==="object"||e==="function")&&t!==null}_getNoObjKey(t){let e=typeof t,i;return e!=="string"&&e!=="number"&&e!=="symbol"?i=this._hashFn(t):i=t,i}};f(Ke,"HashMap");var ze=class extends st{constructor(t=[],e){if(super(),u(this,"_sentinel"),u(this,"_hashFn",f(i=>String(i),"_hashFn")),u(this,"_objHashFn",f(i=>i,"_objHashFn")),u(this,"_noObjMap",{}),u(this,"_objMap",new WeakMap),u(this,"_head"),u(this,"_tail"),u(this,"_toEntryFn",f(i=>{if(this.isEntry(i))return i;throw new Error("If `entryOrRawElements` does not adhere to [key,value], provide `options.toEntryFn` to transform raw records.")},"_toEntryFn")),u(this,"_size",0),this._sentinel={},this._sentinel.prev=this._sentinel.next=this._head=this._tail=this._sentinel,e){let{hashFn:i,objHashFn:s,toEntryFn:r}=e;i&&(this._hashFn=i),s&&(this._objHashFn=s),r&&(this._toEntryFn=r)}t&&this.setMany(t)}get hashFn(){return this._hashFn}get objHashFn(){return this._objHashFn}get noObjMap(){return this._noObjMap}get objMap(){return this._objMap}get head(){return this._head}get tail(){return this._tail}get toEntryFn(){return this._toEntryFn}get size(){return this._size}get first(){if(this._size!==0)return[this.head.key,this.head.value]}get last(){if(this._size!==0)return[this.tail.key,this.tail.value]}*begin(){let t=this.head;for(;t!==this._sentinel;)yield[t.key,t.value],t=t.next}*reverseBegin(){let t=this.tail;for(;t!==this._sentinel;)yield[t.key,t.value],t=t.prev}set(t,e){let i,s=!this.has(t);if(q(t)){let r=this._objHashFn(t);i=this.objMap.get(r),!i&&s?(i={key:r,value:e,prev:this.tail,next:this._sentinel},this.objMap.set(r,i)):i&&(i.value=e)}else{let r=this._hashFn(t);i=this.noObjMap[r],!i&&s?this.noObjMap[r]=i={key:t,value:e,prev:this.tail,next:this._sentinel}:i&&(i.value=e)}return i&&s&&(this._size===0?(this._head=i,this._sentinel.next=i):(this.tail.next=i,i.prev=this.tail),this._tail=i,this._sentinel.prev=i,this._size++),!0}setMany(t){let e=[];for(let i of t){let s,r;this.isEntry(i)?[s,r]=i:this._toEntryFn&&([s,r]=this._toEntryFn(i)),s!==void 0&&r!==void 0&&e.push(this.set(s,r))}return e}has(t){if(q(t)){let i=this._objHashFn(t);return this.objMap.has(i)}return this._hashFn(t)in this.noObjMap}get(t){if(q(t)){let s=this._objHashFn(t),r=this.objMap.get(s);return r?r.value:void 0}let e=this._hashFn(t),i=this.noObjMap[e];return i?i.value:void 0}at(t){j(t,0,this._size-1);let e=this.head;for(;t--;)e=e.next;return e.value}delete(t){let e;if(q(t)){let i=this._objHashFn(t);if(e=this.objMap.get(i),!e)return!1;this.objMap.delete(i)}else{let i=this._hashFn(t);if(e=this.noObjMap[i],!e)return!1;delete this.noObjMap[i]}return this._deleteNode(e)}deleteWhere(t){let e=this._head,i=0;for(;e!==this._sentinel;){let s=e;if(e=e.next,t(s.key,s.value,i++,this)){if(q(s.key))this._objMap.delete(s.key);else{let r=this._hashFn(s.key);delete this._noObjMap[r]}return this._deleteNode(s)}}return!1}deleteAt(t){j(t,0,this._size-1);let e=this.head;for(;t--;)e=e.next;return this._deleteNode(e)}isEmpty(){return this._size===0}isEntry(t){return Array.isArray(t)&&t.length===2}clear(){this._noObjMap={},this._size=0,this._head=this._tail=this._sentinel.prev=this._sentinel.next=this._sentinel}clone(){let t={hashFn:this._hashFn,objHashFn:this._objHashFn};return this._createLike(this,t)}filter(t,e){let i=this._createLike(),s=0;for(let[r,n]of this)t.call(e,n,r,s,this)&&i.set(r,n),s++;return i}map(t,e){let i=this._createLike(),s=0;for(let[r,n]of this){let[h,o]=t.call(e,n,r,s,this);i.set(h,o),s++}return i}*_getIterator(){let t=this.head;for(;t!==this._sentinel;)yield[t.key,t.value],t=t.next}_deleteNode(t){let{prev:e,next:i}=t;return e.next=i,i.prev=e,t===this.head&&(this._head=i),t===this.tail&&(this._tail=e),this._size-=1,!0}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}};f(ze,"LinkedHashMap");var Bt=class{constructor(t){u(this,"_value"),u(this,"_next"),this._value=t,this._next=void 0}get value(){return this._value}set value(t){this._value=t}get next(){return this._next}set next(t){this._next=t}};f(Bt,"LinkedListNode");var Vt=Bt,Dt=class Kt extends rt{constructor(t){if(super(t),u(this,"_maxLen",-1),t){let{maxLen:e}=t;typeof e=="number"&&e>0&&e%1===0&&(this._maxLen=e)}}get maxLen(){return this._maxLen}indexOf(t,e=0){if(this.length===0)return-1;e<0&&(e=this.length+e),e<0&&(e=0);for(let i=e;i<this.length;i++)if(this.at(i)===t)return i;return-1}lastIndexOf(t,e=this.length-1){if(this.length===0)return-1;e>=this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(let i=e;i>=0;i--)if(this.at(i)===t)return i;return-1}findIndex(t,e){for(let i=0;i<this.length;i++){let s=this.at(i);if(s!==void 0&&t.call(e,s,i,this))return i}return-1}concat(...t){let e=this.clone();for(let i of t)i instanceof Kt?e.pushMany(i):e.push(i);return e}sort(t){let e=this.toArray();e.sort(t),this.clear();for(let i of e)this.push(i);return this}splice(t,e=0,...i){let s=this._createInstance();t=t<0?this.length+t:t,t=Math.max(0,Math.min(t,this.length)),e=Math.max(0,Math.min(e,this.length-t));for(let r=0;r<e;r++){let n=this.deleteAt(t);n!==void 0&&s.push(n)}for(let r=0;r<i.length;r++)this.addAt(t+r,i[r]);return s}join(t=","){return this.toArray().join(t)}toReversedArray(){let t=[];for(let e=this.length-1;e>=0;e--)t.push(this.at(e));return t}reduceRight(t,e){let i=e!=null?e:0;for(let s=this.length-1;s>=0;s--)i=t(i,this.at(s),s,this);return i}slice(t=0,e=this.length){t=t<0?this.length+t:t,e=e<0?this.length+e:e;let i=this._createInstance();for(let s=t;s<e;s++)i.push(this.at(s));return i}fill(t,e=0,i=this.length){if(e=e<0?this.length+e:e,i=i<0?this.length+i:i,e<0&&(e=0),i>this.length&&(i=this.length),e>=i)return this;for(let s=e;s<i;s++)this.setAt(s,t);return this}};f(Dt,"LinearBase");var it=Dt,zt=class extends it{constructor(t){if(super(t),t){let{maxLen:e}=t;typeof e=="number"&&e>0&&e%1===0&&(this._maxLen=e)}}indexOf(t,e=0){let i=this._getIterator(),s=i.next(),r=0;for(;r<e;)s=i.next(),r++;for(;!s.done;){if(s.value===t)return r;s=i.next(),r++}return-1}lastIndexOf(t,e=this.length-1){let i=this._getReverseIterator(),s=i.next(),r=this.length-1;for(;r>e;)s=i.next(),r--;for(;!s.done;){if(s.value===t)return r;s=i.next(),r--}return-1}concat(...t){let e=this.clone();for(let i of t)i instanceof it?e.pushMany(i):e.push(i);return e}slice(t=0,e=this.length){t=t<0?this.length+t:t,e=e<0?this.length+e:e;let i=this._createInstance(),s=this._getIterator(),r=s.next(),n=0;for(;n<t;)r=s.next(),n++;for(let h=t;h<e;h++)i.push(r.value),r=s.next();return i}splice(t,e=0,...i){let s=this._createInstance();t=t<0?this.length+t:t,t=Math.max(0,Math.min(t,this.length)),e=Math.max(0,e);let r=0,n,h,o=this._getNodeIterator();for(let l of o){if(r===t){n=l;break}h=l,r++}for(let l=0;l<e&&n;l++){s.push(n.value);let a=n.next;this.delete(n),n=a}for(let l=0;l<i.length;l++)h?(this.addAfter(h,i[l]),h=h.next):(this.addAt(0,i[l]),h=this._getNodeIterator().next().value);return s}reduceRight(t,e){let i=e!=null?e:0,s=this.length-1;for(let r of this._getReverseIterator())i=t(i,r,s--,this);return i}};f(zt,"LinearLinkedBase");var jt=zt,Ht=class extends Vt{constructor(t){super(t),u(this,"_next"),this._value=t,this._next=void 0}get next(){return this._next}set next(t){this._next=t}};f(Ht,"SinglyLinkedListNode");var dt=Ht,qt=class extends jt{constructor(t=[],e){super(e),u(this,"_equals",Object.is),u(this,"_head"),u(this,"_tail"),u(this,"_length",0),this.pushMany(t)}get head(){return this._head}get tail(){return this._tail}get length(){return this._length}get first(){var t;return(t=this.head)==null?void 0:t.value}get last(){var t;return(t=this.tail)==null?void 0:t.value}static from(t,e){let i=new this([],e);for(let s of t)i.push(s);return i}push(t){let e=this._ensureNode(t);return this.head?(this.tail.next=e,this._tail=e):this._head=this._tail=e,this._length++,this._maxLen>0&&this.length>this._maxLen&&this.shift(),!0}pop(){if(!this.head)return;if(this.head===this.tail){let i=this.head.value;return this._head=void 0,this._tail=void 0,this._length--,i}let t=this.head;for(;t.next!==this.tail;)t=t.next;let e=this.tail.value;return t.next=void 0,this._tail=t,this._length--,e}shift(){if(!this.head)return;let t=this.head;return this._head=this.head.next,this._head||(this._tail=void 0),this._length--,t.value}unshift(t){let e=this._ensureNode(t);return this.head?(e.next=this.head,this._head=e):this._head=this._tail=e,this._length++,!0}pushMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.push(this.toElementFn(i))):e.push(this.push(i));return e}unshiftMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.unshift(this.toElementFn(i))):e.push(this.unshift(i));return e}search(t){let e=this._ensurePredicate(t),i=this.head;for(;i;){if(e(i))return i.value;i=i.next}}at(t){if(t<0||t>=this._length)return;let e=this.head;for(let i=0;i<t;i++)e=e.next;return e.value}isNode(t){return t instanceof dt}getNodeAt(t){if(t<0||t>=this._length)return;let e=this.head;for(let i=0;i<t;i++)e=e.next;return e}deleteAt(t){if(t<0||t>=this._length)return;if(t===0)return this.shift();let e=this.getNodeAt(t),i=this._getPrevNode(e),s=e.value;return i.next=e.next,e===this.tail&&(this._tail=i),this._length--,s}delete(t){if(t===void 0||!this.head)return!1;let e=this.isNode(t)?t:this.getNode(t);if(!e)return!1;let i=this._getPrevNode(e);return i?(i.next=e.next,e===this.tail&&(this._tail=i)):(this._head=e.next,e===this.tail&&(this._tail=void 0)),this._length--,!0}addAt(t,e){if(t<0||t>this._length)return!1;if(t===0)return this.unshift(e);if(t===this._length)return this.push(e);let i=this._ensureNode(e),s=this.getNodeAt(t-1);return i.next=s.next,s.next=i,this._length++,!0}setAt(t,e){let i=this.getNodeAt(t);return i?(i.value=e,!0):!1}isEmpty(){return this._length===0}clear(){this._head=void 0,this._tail=void 0,this._length=0}reverse(){if(!this.head||this.head===this.tail)return this;let t,e=this.head,i;for(;e;)i=e.next,e.next=t,t=e,e=i;return[this._head,this._tail]=[this.tail,this.head],this}getNode(t){if(t===void 0)return;if(this.isNode(t))return t;let e=this._ensurePredicate(t),i=this.head;for(;i;){if(e(i))return i;i=i.next}}addBefore(t,e){let i=this.getNode(t);if(!i)return!1;let s=this._getPrevNode(i),r=this._ensureNode(e);return s?(s.next=r,r.next=i,this._length++):(r.next=this._head,this._head=r,this._tail||(this._tail=r),this._length++),!0}addAfter(t,e){let i=this.getNode(t);if(!i)return!1;let s=this._ensureNode(e);return s.next=i.next,i.next=s,i===this.tail&&(this._tail=s),this._length++,!0}splice(t,e=0,...i){t=Math.max(0,Math.min(t,this.length)),e=Math.max(0,e);let s=this._createInstance(),r=t===0?void 0:this.getNodeAt(t-1),n=r?r.next:this.head,h=0;for(;h<e&&n;)s.push(n.value),n=n.next,h++;let o=n;if(r?r.next=o:this._head=o,o||(this._tail=r),i.length>0){let l,a;for(let _ of i){let g=this._ensureNode(_);l||(l=g),a&&(a.next=g),a=g}r?r.next=l:this._head=l,a.next=o,o||(this._tail=a)}return this._length+=i.length-h,this._length===0&&(this._head=void 0,this._tail=void 0),s}countOccurrences(t){let e=Ut(t,this._equals),i=0,s=this.head;for(;s;)e(s)&&i++,s=s.next;return i}setEquality(t){return this._equals=t,this}deleteWhere(t){let e,i=this.head,s=0;for(;i;){if(t(i.value,s++,this))return e?(e.next=i.next,i===this._tail&&(this._tail=e)):(this._head=i.next,i===this._tail&&(this._tail=void 0)),this._length--,!0;e=i,i=i.next}return!1}clone(){let t=this._createInstance();for(let e of this)t.push(e);return t}filter(t,e){let i=this._createInstance(),s=0;for(let r of this)t.call(e,r,s++,this)&&i.push(r);return i}mapSame(t,e){let i=this._createInstance(),s=0;for(let r of this){let n=e===void 0?t(r,s++,this):t.call(e,r,s++,this);i.push(n)}return i}map(t,e,i){let s=this._createLike([],{...e!=null?e:{},maxLen:this._maxLen}),r=0;for(let n of this)s.push(t.call(i,n,r++,this));return s}createNode(t){return new dt(t)}_isPredicate(t){return typeof t=="function"}_ensureNode(t){return this.isNode(t)?t:this.createNode(t)}_ensurePredicate(t){if(this.isNode(t))return i=>i===t;if(this._isPredicate(t))return t;let e=t;return i=>this._equals(i.value,e)}_getPrevNode(t){if(!this.head||this.head===t)return;let e=this.head;for(;e.next&&e.next!==t;)e=e.next;return e.next===t?e:void 0}*_getIterator(){let t=this.head;for(;t;)yield t.value,t=t.next}*_getReverseIterator(){let t=[...this].reverse();for(let e of t)yield e}*_getNodeIterator(){let t=this.head;for(;t;)yield t,t=t.next}_createInstance(t){let e=this.constructor;return new e([],t)}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}_spawnLike(t){return this._createLike([],t)}};f(qt,"SinglyLinkedList");var je=qt;function Ut(c,t){if(c instanceof dt)return i=>i===c;if(typeof c=="function")return c;let e=c;return i=>t(i.value,e)}f(Ut,"elementOrPredicate");var Gt=class extends Vt{constructor(t){super(t),u(this,"_next"),u(this,"_prev"),this._value=t,this._next=void 0,this._prev=void 0}get next(){return this._next}set next(t){this._next=t}get prev(){return this._prev}set prev(t){this._prev=t}};f(Gt,"DoublyLinkedListNode");var xt=Gt,He=class extends jt{constructor(t=[],e){super(e),u(this,"_equals",Object.is),u(this,"_head"),u(this,"_tail"),u(this,"_length",0),this._head=void 0,this._tail=void 0,this._length=0,e!=null&&e.maxLen&&Number.isInteger(e.maxLen)&&e.maxLen>0&&(this._maxLen=e.maxLen),this.pushMany(t)}get head(){return this._head}get tail(){return this._tail}get length(){return this._length}get first(){var t;return(t=this.head)==null?void 0:t.value}get last(){var t;return(t=this.tail)==null?void 0:t.value}static fromArray(t){return new this(t)}isNode(t){return t instanceof xt}push(t){let e=this._ensureNode(t);return this.head?(e.prev=this.tail,this.tail.next=e,this._tail=e):(this._head=e,this._tail=e),this._length++,this._maxLen>0&&this.length>this._maxLen&&this.shift(),!0}pop(){if(!this.tail)return;let t=this.tail;return this.head===this.tail?(this._head=void 0,this._tail=void 0):(this._tail=t.prev,this.tail.next=void 0),this._length--,t.value}shift(){if(!this.head)return;let t=this.head;return this.head===this.tail?(this._head=void 0,this._tail=void 0):(this._head=t.next,this.head.prev=void 0),this._length--,t.value}unshift(t){let e=this._ensureNode(t);return this.head?(e.next=this.head,this.head.prev=e,this._head=e):(this._head=e,this._tail=e),this._length++,this._maxLen>0&&this._length>this._maxLen&&this.pop(),!0}pushMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.push(this.toElementFn(i))):e.push(this.push(i));return e}unshiftMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.unshift(this.toElementFn(i))):e.push(this.unshift(i));return e}at(t){if(t<0||t>=this._length)return;let e=this.head;for(let i=0;i<t;i++)e=e.next;return e.value}getNodeAt(t){if(t<0||t>=this._length)return;let e=this.head;for(let i=0;i<t;i++)e=e.next;return e}getNode(t){if(t===void 0)return;if(this.isNode(t)){let s=t,r=this.head;for(;r;){if(r===s)return s;r=r.next}let n=f(h=>this._equals(h.value,s.value),"isMatch");for(r=this.head;r;){if(n(r))return r;r=r.next}return}let e=this._ensurePredicate(t),i=this.head;for(;i;){if(e(i))return i;i=i.next}}addAt(t,e){if(t<0||t>this._length)return!1;if(t===0)return this.unshift(e);if(t===this._length)return this.push(e);let i=this._ensureNode(e),s=this.getNodeAt(t-1),r=s.next;return i.prev=s,i.next=r,s.next=i,r.prev=i,this._length++,!0}addBefore(t,e){let i=this.isNode(t)?t:this.getNode(t);if(!i)return!1;let s=this._ensureNode(e);return s.prev=i.prev,i.prev&&(i.prev.next=s),s.next=i,i.prev=s,i===this.head&&(this._head=s),this._length++,!0}addAfter(t,e){let i=this.isNode(t)?t:this.getNode(t);if(!i)return!1;let s=this._ensureNode(e);return s.next=i.next,i.next&&(i.next.prev=s),s.prev=i,i.next=s,i===this.tail&&(this._tail=s),this._length++,!0}setAt(t,e){let i=this.getNodeAt(t);return i?(i.value=e,!0):!1}deleteAt(t){if(t<0||t>=this._length)return;if(t===0)return this.shift();if(t===this._length-1)return this.pop();let e=this.getNodeAt(t),i=e.prev,s=e.next;return i.next=s,s.prev=i,this._length--,e.value}delete(t){let e=this.getNode(t);if(!e)return!1;if(e===this.head)this.shift();else if(e===this.tail)this.pop();else{let i=e.prev,s=e.next;i.next=s,s.prev=i,this._length--}return!0}isEmpty(){return this._length===0}clear(){this._head=void 0,this._tail=void 0,this._length=0}search(t){let e=this._ensurePredicate(t),i=this.head;for(;i;){if(e(i))return i.value;i=i.next}}getBackward(t){let e=this._ensurePredicate(t),i=this.tail;for(;i;){if(e(i))return i.value;i=i.prev}}reverse(){let t=this.head;for([this._head,this._tail]=[this.tail,this.head];t;){let e=t.next;[t.prev,t.next]=[t.next,t.prev],t=e}return this}setEquality(t){return this._equals=t,this}clone(){let t=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen});for(let e of this)t.push(e);return t}filter(t,e){let i=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen}),s=0;for(let r of this)t.call(e,r,s++,this)&&i.push(r);return i}mapSame(t,e){let i=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen}),s=0;for(let r of this){let n=e===void 0?t(r,s++,this):t.call(e,r,s++,this);i.push(n)}return i}map(t,e,i){let s=this._createLike([],{...e!=null?e:{},maxLen:this._maxLen}),r=0;for(let n of this)s.push(t.call(i,n,r++,this));return s}_ensureNode(t){return this.isNode(t)?t:new xt(t)}_ensurePredicate(t){if(this.isNode(t)){let i=t;return s=>s===i}if(typeof t=="function")return t;let e=t;return i=>this._equals(i.value,e)}_getPrevNode(t){return t.prev}_createInstance(t){let e=this.constructor;return new e([],t)}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}*_getIterator(){let t=this.head;for(;t;)yield t.value,t=t.next}*_getReverseIterator(){let t=this.tail;for(;t;)yield t.value,t=t.prev}*_getNodeIterator(){let t=this.head;for(;t;)yield t,t=t.next}};f(He,"DoublyLinkedList");var Wt=class{constructor(t,e,i){u(this,"key"),u(this,"value"),u(this,"forward"),this.key=t,this.value=e,this.forward=new Array(i)}};f(Wt,"SkipListNode");var kt=Wt,qe=class{constructor(t=[],e){if(u(this,"_head",new kt(void 0,void 0,this.maxLevel)),u(this,"_level",0),u(this,"_maxLevel",16),u(this,"_probability",.5),e){let{maxLevel:i,probability:s}=e;typeof i=="number"&&(this._maxLevel=i),typeof s=="number"&&(this._probability=s)}if(t)for(let[i,s]of t)this.add(i,s)}get head(){return this._head}get level(){return this._level}get maxLevel(){return this._maxLevel}get probability(){return this._probability}get first(){let t=this.head.forward[0];return t?t.value:void 0}get last(){let t=this.head;for(let e=this.level-1;e>=0;e--)for(;t.forward[e];)t=t.forward[e];return t.value}add(t,e){let i=new kt(t,e,this._randomLevel()),s=new Array(this.maxLevel).fill(this.head),r=this.head;for(let n=this.level-1;n>=0;n--){for(;r.forward[n]&&r.forward[n].key<t;)r=r.forward[n];s[n]=r}for(let n=0;n<i.forward.length;n++)i.forward[n]=s[n].forward[n],s[n].forward[n]=i;i.forward[0]||(this._level=Math.max(this.level,i.forward.length))}get(t){let e=this.head;for(let i=this.level-1;i>=0;i--)for(;e.forward[i]&&e.forward[i].key<t;)e=e.forward[i];if(e=e.forward[0],e&&e.key===t)return e.value}has(t){return this.get(t)!==void 0}delete(t){let e=new Array(this.maxLevel).fill(this.head),i=this.head;for(let s=this.level-1;s>=0;s--){for(;i.forward[s]&&i.forward[s].key<t;)i=i.forward[s];e[s]=i}if(i=i.forward[0],i&&i.key===t){for(let s=0;s<this.level&&e[s].forward[s]===i;s++)e[s].forward[s]=i.forward[s];for(;this.level>0&&!this.head.forward[this.level-1];)this._level--;return!0}return!1}higher(t){let e=this.head;for(let s=this.level-1;s>=0;s--)for(;e.forward[s]&&e.forward[s].key<=t;)e=e.forward[s];let i=e.forward[0];return i?i.value:void 0}lower(t){let e=this.head,i;for(let s=this.level-1;s>=0;s--){for(;e.forward[s]&&e.forward[s].key<t;)e=e.forward[s];e.key<t&&(i=e)}return i?i.value:void 0}_randomLevel(){let t=1;for(;Math.random()<this.probability&&t<this.maxLevel;)t++;return t}};f(qe,"SkipList");var Ue=class extends rt{constructor(t=[],e){super(e),u(this,"_equals",Object.is),u(this,"_elements",[]),this.pushMany(t)}get elements(){return this._elements}get size(){return this.elements.length}static fromArray(t,e){return new this(t,e)}isEmpty(){return this.elements.length===0}peek(){return this.isEmpty()?void 0:this.elements[this.elements.length-1]}push(t){return this.elements.push(t),!0}pop(){return this.isEmpty()?void 0:this.elements.pop()}pushMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.push(this.toElementFn(i))):e.push(this.push(i));return e}delete(t){let e=this._indexOfByEquals(t);return this.deleteAt(e)}deleteAt(t){return t<0||t>=this.elements.length?!1:this.elements.splice(t,1).length===1}deleteWhere(t){for(let e=0;e<this.elements.length;e++)if(t(this.elements[e],e,this))return this.elements.splice(e,1),!0;return!1}clear(){this._elements=[]}clone(){let t=this._createInstance({toElementFn:this.toElementFn});for(let e of this)t.push(e);return t}filter(t,e){let i=this._createInstance({toElementFn:this.toElementFn}),s=0;for(let r of this)t.call(e,r,s,this)&&i.push(r),s++;return i}mapSame(t,e){let i=this._createInstance({toElementFn:this.toElementFn}),s=0;for(let r of this){let n=e===void 0?t(r,s++,this):t.call(e,r,s++,this);i.push(n)}return i}map(t,e,i){let s=this._createLike([],{...e!=null?e:{}}),r=0;for(let n of this)s.push(i===void 0?t(n,r,this):t.call(i,n,r,this)),r++;return s}setEquality(t){return this._equals=t,this}_indexOfByEquals(t){for(let e=0;e<this.elements.length;e++)if(this._equals(this.elements[e],t))return e;return-1}_createInstance(t){let e=this.constructor;return new e([],t)}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}*_getIterator(){for(let t=0;t<this.elements.length;t++)yield this.elements[t]}};f(Ue,"Stack");var Pt=class Ot extends it{constructor(t=[],e){if(super(e),u(this,"_elements",[]),u(this,"_offset",0),u(this,"_autoCompactRatio",.5),e){let{autoCompactRatio:i=.5}=e;this._autoCompactRatio=i}this.pushMany(t)}get elements(){return this._elements}get offset(){return this._offset}get autoCompactRatio(){return this._autoCompactRatio}set autoCompactRatio(t){this._autoCompactRatio=t}get length(){return this.elements.length-this._offset}get first(){return this.length>0?this.elements[this._offset]:void 0}get last(){return this.length>0?this.elements[this.elements.length-1]:void 0}static fromArray(t){return new Ot(t)}isEmpty(){return this.length===0}push(t){return this.elements.push(t),this._maxLen>0&&this.length>this._maxLen&&this.shift(),!0}pushMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.push(this.toElementFn(i))):e.push(this.push(i));return e}shift(){if(this.length===0)return;let t=this.first;return this._offset+=1,this.elements.length>0&&this.offset/this.elements.length>this.autoCompactRatio&&this.compact(),t}delete(t){for(let e=this._offset;e<this.elements.length;e++)if(Object.is(this.elements[e],t))return this.elements.splice(e,1),!0;return!1}at(t){if(!(t<0||t>=this.length))return this._elements[this._offset+t]}deleteAt(t){if(t<0||t>=this.length)return;let e=this._offset+t,[i]=this.elements.splice(e,1);return i}addAt(t,e){return t<0||t>this.length?!1:(this._elements.splice(this._offset+t,0,e),!0)}setAt(t,e){return t<0||t>=this.length?!1:(this._elements[this._offset+t]=e,!0)}reverse(){return this._elements=this.elements.slice(this._offset).reverse(),this._offset=0,this}clear(){this._elements=[],this._offset=0}compact(){return this._elements=this.elements.slice(this._offset),this._offset=0,!0}splice(t,e=0,...i){t=Math.max(0,Math.min(t,this.length)),e=Math.max(0,Math.min(e,this.length-t));let s=this._offset+t,r=this._elements.splice(s,e,...i);this.elements.length>0&&this.offset/this.elements.length>this.autoCompactRatio&&this.compact();let n=this._createInstance({toElementFn:this.toElementFn,maxLen:this._maxLen});return n._setAutoCompactRatio(this._autoCompactRatio),n.pushMany(r),n}clone(){let t=this._createInstance({toElementFn:this.toElementFn,maxLen:this._maxLen});t._setAutoCompactRatio(this._autoCompactRatio);for(let e=this._offset;e<this.elements.length;e++)t.push(this.elements[e]);return t}filter(t,e){let i=this._createInstance({toElementFn:this.toElementFn,maxLen:this._maxLen});i._setAutoCompactRatio(this._autoCompactRatio);let s=0;for(let r of this)t.call(e,r,s,this)&&i.push(r),s++;return i}map(t,e,i){var s,r;let n=new this.constructor([],{toElementFn:e==null?void 0:e.toElementFn,maxLen:(s=e==null?void 0:e.maxLen)!=null?s:this._maxLen,autoCompactRatio:(r=e==null?void 0:e.autoCompactRatio)!=null?r:this._autoCompactRatio}),h=0;for(let o of this)n.push(i===void 0?t(o,h++,this):t.call(i,o,h++,this));return n}mapSame(t,e){var i;let s=this.constructor,r=new s([],{toElementFn:this.toElementFn,maxLen:this._maxLen,autoCompactRatio:this._autoCompactRatio});(i=r._setAutoCompactRatio)==null||i.call(r,this._autoCompactRatio);let n=0;for(let h of this){let o=e===void 0?t(h,n++,this):t.call(e,h,n++,this);r.push(o)}return r}_setAutoCompactRatio(t){this._autoCompactRatio=t}*_getIterator(){for(let t=this._offset;t<this.elements.length;t++)yield this.elements[t]}*_getReverseIterator(){for(let t=this.length-1;t>=0;t--){let e=this.at(t);e!==void 0&&(yield e)}}_createInstance(t){let e=this.constructor;return new e([],t)}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}};f(Pt,"Queue");var H=Pt,Ge=class extends je{clone(){let t=this._createInstance({toElementFn:this.toElementFn,maxLen:this._maxLen});for(let e of this)t.push(e);return t}};f(Ge,"LinkedListQueue");var We=class extends it{constructor(t=[],e){if(super(e),u(this,"_equals",Object.is),u(this,"_bucketSize",4096),u(this,"_bucketFirst",0),u(this,"_firstInBucket",0),u(this,"_bucketLast",0),u(this,"_lastInBucket",0),u(this,"_bucketCount",0),u(this,"_buckets",[]),u(this,"_length",0),e){let{bucketSize:r}=e;typeof r=="number"&&(this._bucketSize=r)}let i;"length"in t?i=typeof t.length=="function"?t.length():t.length:i=typeof t.size=="function"?t.size():t.size,this._bucketCount=yt(i,this._bucketSize)||1;for(let r=0;r<this._bucketCount;++r)this._buckets.push(new Array(this._bucketSize));let s=yt(i,this._bucketSize);this._bucketFirst=this._bucketLast=(this._bucketCount>>1)-(s>>1),this._firstInBucket=this._lastInBucket=this._bucketSize-i%this._bucketSize>>1,this.pushMany(t)}get bucketSize(){return this._bucketSize}get bucketFirst(){return this._bucketFirst}get firstInBucket(){return this._firstInBucket}get bucketLast(){return this._bucketLast}get lastInBucket(){return this._lastInBucket}get bucketCount(){return this._bucketCount}get buckets(){return this._buckets}get length(){return this._length}get first(){if(this._length!==0)return this._buckets[this._bucketFirst][this._firstInBucket]}get last(){if(this._length!==0)return this._buckets[this._bucketLast][this._lastInBucket]}static fromArray(t,e){return new this(t,e)}push(t){return this._length&&(this._lastInBucket<this._bucketSize-1?this._lastInBucket+=1:this._bucketLast<this._bucketCount-1?(this._bucketLast+=1,this._lastInBucket=0):(this._bucketLast=0,this._lastInBucket=0),this._bucketLast===this._bucketFirst&&this._lastInBucket===this._firstInBucket&&this._reallocate()),this._length+=1,this._buckets[this._bucketLast][this._lastInBucket]=t,this._maxLen>0&&this._length>this._maxLen&&this.shift(),!0}pop(){if(this._length===0)return;let t=this._buckets[this._bucketLast][this._lastInBucket];return this._length!==1&&(this._lastInBucket>0?this._lastInBucket-=1:this._bucketLast>0?(this._bucketLast-=1,this._lastInBucket=this._bucketSize-1):(this._bucketLast=this._bucketCount-1,this._lastInBucket=this._bucketSize-1)),this._length-=1,t}shift(){if(this._length===0)return;let t=this._buckets[this._bucketFirst][this._firstInBucket];return this._length!==1&&(this._firstInBucket<this._bucketSize-1?this._firstInBucket+=1:this._bucketFirst<this._bucketCount-1?(this._bucketFirst+=1,this._firstInBucket=0):(this._bucketFirst=0,this._firstInBucket=0)),this._length-=1,t}unshift(t){return this._length&&(this._firstInBucket>0?this._firstInBucket-=1:this._bucketFirst>0?(this._bucketFirst-=1,this._firstInBucket=this._bucketSize-1):(this._bucketFirst=this._bucketCount-1,this._firstInBucket=this._bucketSize-1),this._bucketFirst===this._bucketLast&&this._firstInBucket===this._lastInBucket&&this._reallocate()),this._length+=1,this._buckets[this._bucketFirst][this._firstInBucket]=t,this._maxLen>0&&this._length>this._maxLen&&this.pop(),!0}pushMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.push(this.toElementFn(i))):e.push(this.push(i));return e}unshiftMany(t=[]){let e=[];for(let i of t)this.toElementFn?e.push(this.unshift(this.toElementFn(i))):e.push(this.unshift(i));return e}isEmpty(){return this._length===0}clear(){this._buckets=[new Array(this._bucketSize)],this._bucketCount=1,this._bucketFirst=this._bucketLast=this._length=0,this._firstInBucket=this._lastInBucket=this._bucketSize>>1}at(t){if(t<0||t>=this._length)return;let{bucketIndex:e,indexInBucket:i}=this._getBucketAndPosition(t);return this._buckets[e][i]}setAt(t,e){j(t,0,this._length-1);let{bucketIndex:i,indexInBucket:s}=this._getBucketAndPosition(t);return this._buckets[i][s]=e,!0}addAt(t,e,i=1){let s=this._length;if(j(t,0,s),t===0)for(;i--;)this.unshift(e);else if(t===this._length)for(;i--;)this.push(e);else{let r=[];for(let n=t;n<this._length;++n){let h=this.at(n);h!==void 0&&r.push(h)}this.cut(t-1,!0);for(let n=0;n<i;++n)this.push(e);for(let n=0;n<r.length;++n)this.push(r[n])}return!0}cut(t,e=!1){if(e){if(t<0)return this.clear(),this;let{bucketIndex:i,indexInBucket:s}=this._getBucketAndPosition(t);return this._bucketLast=i,this._lastInBucket=s,this._length=t+1,this}else{let i=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen});i._setBucketSize(this._bucketSize);for(let s=0;s<=t;s++){let r=this.at(s);r!==void 0&&i.push(r)}return i}}splice(t,e=this._length-t,...i){j(t,0,this._length),e<0&&(e=0),t+e>this._length&&(e=this._length-t);let s=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen});s._setBucketSize(this._bucketSize);for(let n=0;n<e;n++){let h=this.at(t+n);h!==void 0&&s.push(h)}let r=[];for(let n=t+e;n<this._length;n++){let h=this.at(n);h!==void 0&&r.push(h)}this.cut(t-1,!0);for(let n of i)this.push(n);for(let n of r)this.push(n);return s}cutRest(t,e=!1){if(e){if(t<0)return this;let{bucketIndex:i,indexInBucket:s}=this._getBucketAndPosition(t);return this._bucketFirst=i,this._firstInBucket=s,this._length=this._length-t,this}else{let i=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen});i._setBucketSize(this._bucketSize),t<0&&(t=0);for(let s=t;s<this._length;s++){let r=this.at(s);r!==void 0&&i.push(r)}return i}}deleteAt(t){j(t,0,this._length-1);let e;if(t===0)return this.shift();if(t===this._length-1)return e=this.last,this.pop(),e;{let i=this._length-1,{bucketIndex:s,indexInBucket:r}=this._getBucketAndPosition(t);e=this._buckets[s][r];for(let n=t;n<i;n++){let{bucketIndex:h,indexInBucket:o}=this._getBucketAndPosition(n),{bucketIndex:l,indexInBucket:a}=this._getBucketAndPosition(n+1);this._buckets[h][o]=this._buckets[l][a]}return this.pop(),e}}delete(t){let e=this._length;if(e===0)return!1;let i=0,s=0;for(;i<e;){let r=this.at(i);this._equals(r,t)||(this.setAt(s,r),s+=1),i+=1}return this.cut(s-1,!0),!0}deleteWhere(t){for(let e=0;e<this._length;e++){let i=this.at(e);if(t(i,e,this))return this.deleteAt(e),!0}return!1}setEquality(t){return this._equals=t,this}reverse(){this._buckets.reverse().forEach(function(r){r.reverse()});let{_bucketFirst:t,_bucketLast:e,_firstInBucket:i,_lastInBucket:s}=this;return this._bucketFirst=this._bucketCount-e-1,this._bucketLast=this._bucketCount-t-1,this._firstInBucket=this._bucketSize-s-1,this._lastInBucket=this._bucketSize-i-1,this}unique(){if(this._length<=1)return this;let t=1,e=this.at(0);for(let i=1;i<this._length;++i){let s=this.at(i);this._equals(s,e)||(e=s,this.setAt(t++,s))}return this.cut(t-1,!0),this}shrinkToFit(){if(this._length===0)return;let t=[];if(this._bucketFirst!==this._bucketLast){if(this._bucketFirst<this._bucketLast)for(let e=this._bucketFirst;e<=this._bucketLast;++e)t.push(this._buckets[e]);else{for(let e=this._bucketFirst;e<this._bucketCount;++e)t.push(this._buckets[e]);for(let e=0;e<=this._bucketLast;++e)t.push(this._buckets[e])}this._bucketFirst=0,this._bucketLast=t.length-1,this._buckets=t}}clone(){return this._createLike(this,{bucketSize:this.bucketSize,toElementFn:this.toElementFn,maxLen:this._maxLen})}filter(t,e){let i=this._createInstance({toElementFn:this.toElementFn,maxLen:this._maxLen});i._setBucketSize(this._bucketSize);let s=0;for(let r of this)t.call(e,r,s,this)&&i.push(r),s++;return i}mapSame(t,e){let i=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen});i._setBucketSize(this._bucketSize);let s=0;for(let r of this){let n=e===void 0?t(r,s++,this):t.call(e,r,s++,this);i.push(n)}return i}map(t,e,i){let s=this._createLike([],{...e!=null?e:{},bucketSize:this._bucketSize,maxLen:this._maxLen}),r=0;for(let n of this){let h=i===void 0?t(n,r,this):t.call(i,n,r,this);s.push(h),r++}return s}_setBucketSize(t){this._bucketSize=t,this._length===0&&(this._buckets=[new Array(this._bucketSize)],this._bucketCount=1,this._bucketFirst=this._bucketLast=0,this._firstInBucket=this._lastInBucket=this._bucketSize>>1)}*_getIterator(){for(let t=0;t<this._length;++t){let e=this.at(t);e!==void 0&&(yield e)}}_reallocate(t){let e=[],i=t||this._bucketCount>>1||1;for(let s=0;s<i;++s)e[s]=new Array(this._bucketSize);for(let s=this._bucketFirst;s<this._bucketCount;++s)e[e.length]=this._buckets[s];for(let s=0;s<this._bucketLast;++s)e[e.length]=this._buckets[s];e[e.length]=[...this._buckets[this._bucketLast]],this._bucketFirst=i,this._bucketLast=e.length-1;for(let s=0;s<i;++s)e[e.length]=new Array(this._bucketSize);this._buckets=e,this._bucketCount=e.length}_getBucketAndPosition(t){let e,i,s=this._firstInBucket+t;return e=this._bucketFirst+Math.floor(s/this._bucketSize),e>=this._bucketCount&&(e-=this._bucketCount),i=(s+1)%this._bucketSize-1,i<0&&(i=this._bucketSize-1),{bucketIndex:e,indexInBucket:i}}_createInstance(t){let e=this.constructor;return new e([],t)}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}*_getReverseIterator(){for(let t=this._length-1;t>-1;t--){let e=this.at(t);e!==void 0&&(yield e)}}};f(We,"Deque");var Qt=class Xt extends rt{constructor(t=[],e){if(super(e),u(this,"_equals",Object.is),u(this,"_elements",[]),u(this,"_DEFAULT_COMPARATOR",f((i,s)=>{if(typeof i=="object"||typeof s=="object")throw TypeError("When comparing object types, define a custom comparator in options.");return i>s?1:i<s?-1:0},"_DEFAULT_COMPARATOR")),u(this,"_comparator",this._DEFAULT_COMPARATOR),e){let{comparator:i}=e;i&&(this._comparator=i)}this.addMany(t)}get elements(){return this._elements}get size(){return this.elements.length}get leaf(){var t;return(t=this.elements[this.size-1])!=null?t:void 0}static from(t,e){return new this(t,e)}static heapify(t,e){return new Xt(t,e)}add(t){return this._elements.push(t),this._bubbleUp(this.elements.length-1)}addMany(t){let e=[];for(let i of t)if(this.toElementFn){let s=this.add(this.toElementFn(i));e.push(s)}else{let s=this.add(i);e.push(s)}return e}poll(){if(this.elements.length===0)return;let t=this.elements[0],e=this.elements.pop();return this.elements.length&&(this.elements[0]=e,this._sinkDown(0,this.elements.length>>1)),t}peek(){return this.elements[0]}isEmpty(){return this.size===0}clear(){this._elements=[]}refill(t){return this._elements=Array.from(t),this.fix()}has(t){for(let e of this.elements)if(this._equals(e,t))return!0;return!1}delete(t){let e=-1;for(let i=0;i<this.elements.length;i++)if(this._equals(this.elements[i],t)){e=i;break}return e<0?!1:(e===0?this.poll():e===this.elements.length-1?this.elements.pop():(this.elements.splice(e,1,this.elements.pop()),this._bubbleUp(e),this._sinkDown(e,this.elements.length>>1)),!0)}deleteBy(t){let e=-1;for(let i=0;i<this.elements.length;i++)if(t(this.elements[i],i,this)){e=i;break}return e<0?!1:(e===0?this.poll():e===this.elements.length-1?this.elements.pop():(this.elements.splice(e,1,this.elements.pop()),this._bubbleUp(e),this._sinkDown(e,this.elements.length>>1)),!0)}setEquality(t){return this._equals=t,this}dfs(t="PRE"){let e=[],i=f(s=>{let r=2*s+1,n=r+1;s<this.size&&(t==="IN"?(i(r),e.push(this.elements[s]),i(n)):t==="PRE"?(e.push(this.elements[s]),i(r),i(n)):t==="POST"&&(i(r),i(n),e.push(this.elements[s])))},"_dfs");return i(0),e}fix(){let t=[];for(let e=Math.floor(this.size/2)-1;e>=0;e--)t.push(this._sinkDown(e,this.elements.length>>1));return t}sort(){let t=[],e=this._createInstance();for(let i of this.elements)e.add(i);for(;!e.isEmpty();){let i=e.poll();i!==void 0&&t.push(i)}return t}clone(){let t=this._createInstance();for(let e of this.elements)t.add(e);return t}filter(t,e){let i=this._createInstance(),s=0;for(let r of this)(e===void 0?t(r,s++,this):t.call(e,r,s++,this))?i.add(r):s++;return i}map(t,e,i){let{comparator:s,toElementFn:r,...n}=e!=null?e:{};if(!s)throw new TypeError("Heap.map requires options.comparator for EM");let h=this._createLike([],{...n,comparator:s,toElementFn:r}),o=0;for(let l of this){let a=i===void 0?t(l,o++,this):t.call(i,l,o++,this);h.add(a)}return h}mapSame(t,e){let i=this._createInstance(),s=0;for(let r of this){let n=e===void 0?t(r,s++,this):t.call(e,r,s++,this);i.add(n)}return i}get comparator(){return this._comparator}*_getIterator(){for(let t of this.elements)yield t}_bubbleUp(t){let e=this.elements[t];for(;t>0;){let i=t-1>>1,s=this.elements[i];if(this.comparator(s,e)<=0)break;this.elements[t]=s,t=i}return this.elements[t]=e,!0}_sinkDown(t,e){let i=this.elements[t];for(;t<e;){let s=t<<1|1,r=s+1,n=this.elements[s];if(r<this.elements.length&&this.comparator(n,this.elements[r])>0&&(s=r,n=this.elements[r]),this.comparator(n,i)>=0)break;this.elements[t]=n,t=s}return this.elements[t]=i,!0}_createInstance(t){let e=this.constructor;return new e([],{comparator:this.comparator,toElementFn:this.toElementFn,...t!=null?t:{}})}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}_spawnLike(t){return this._createLike([],t)}};f(Qt,"Heap");var nt=Qt,$t=class{constructor(t,e=0){u(this,"element"),u(this,"degree"),u(this,"left"),u(this,"right"),u(this,"child"),u(this,"parent"),u(this,"marked"),this.element=t,this.degree=e,this.marked=!1}};f($t,"FibonacciHeapNode");var Pe=$t,Oe=class{constructor(t){if(u(this,"_root"),u(this,"_size",0),u(this,"_min"),u(this,"_comparator"),this.clear(),this._comparator=t||this._defaultComparator,typeof this.comparator!="function")throw new Error("FibonacciHeap: comparator must be a function.")}get root(){return this._root}get size(){return this._size}get min(){return this._min}get comparator(){return this._comparator}clear(){this._root=void 0,this._min=void 0,this._size=0}add(t){return this.push(t),!0}push(t){let e=this.createNode(t);return e.left=e,e.right=e,this.mergeWithRoot(e),(!this.min||this.comparator(e.element,this.min.element)<=0)&&(this._min=e),this._size++,this}peek(){return this.min?this.min.element:void 0}consumeLinkedList(t){let e=[];if(!t)return e;let i=t,s=!1;for(;!(i===t&&s);)i===t&&(s=!0),e.push(i),i=i.right;return e}mergeWithChild(t,e){t.child?(e.right=t.child.right,e.left=t.child,t.child.right.left=e,t.child.right=e):t.child=e}poll(){return this.pop()}pop(){if(this._size===0)return;let t=this.min;if(t.child){let e=this.consumeLinkedList(t.child);for(let i of e)this.mergeWithRoot(i),i.parent=void 0}return this.removeFromRoot(t),t===t.right?(this._min=void 0,this._root=void 0):(this._min=t.right,this._consolidate()),this._size--,t.element}merge(t){if(t.size!==0){if(this.root&&t.root){let e=this.root,i=t.root,s=e.right,r=i.left;e.right=i,i.left=e,s.left=r,r.right=s}else!this.root&&t.root&&(this._root=t.root);(!this.min||t.min&&this.comparator(t.min.element,this.min.element)<0)&&(this._min=t.min),this._size+=t.size,t.clear()}}createNode(t){return new Pe(t)}isEmpty(){return this._size===0}_defaultComparator(t,e){return t<e?-1:t>e?1:0}mergeWithRoot(t){this.root?(t.right=this.root.right,t.left=this.root,this.root.right.left=t,this.root.right=t):this._root=t}removeFromRoot(t){this.root===t&&(this._root=t.right),t.left&&(t.left.right=t.right),t.right&&(t.right.left=t.left)}_link(t,e){this.removeFromRoot(t),t.left=t,t.right=t,this.mergeWithChild(e,t),e.degree++,t.parent=e}_consolidate(){let t=new Array(this._size),e=this.consumeLinkedList(this.root),i,s,r,n;for(let h of e){for(i=h,r=i.degree;t[r];)s=t[r],this.comparator(i.element,s.element)>0&&(n=i,i=s,s=n),this._link(s,i),t[r]=void 0,r++;t[r]=i}for(let h=0;h<t.length;h++)t[h]&&(!this.min||this.comparator(t[h].element,this.min.element)<=0)&&(this._min=t[h])}};f(Oe,"FibonacciHeap");var Qe=class extends nt{constructor(t=[],e){super(t,{comparator:f((i,s)=>{if(typeof i=="object"||typeof s=="object")throw TypeError("When comparing object types, a custom comparator must be defined in the constructor's options parameter.");return i<s?1:i>s?-1:0},"comparator"),...e})}};f(Qe,"MaxHeap");var Xe=class extends nt{constructor(t=[],e){super(t,e)}};f(Xe,"MinHeap");var Jt=class{constructor(t,e){u(this,"key"),u(this,"value"),this.key=t,this.value=e}};f(Jt,"AbstractVertex");var S=Jt,Yt=class{constructor(t,e){u(this,"value"),u(this,"weight"),u(this,"_hashCode"),this.weight=t!==void 0?t:1,this.value=e,this._hashCode=Ae()}get hashCode(){return this._hashCode}};f(Yt,"AbstractEdge");var Mt=Yt,Zt=class extends st{constructor(t){super(),u(this,"_options",{defaultEdgeWeight:1}),u(this,"_vertexMap",new Map);let e=t==null?void 0:t.graph;this._options={defaultEdgeWeight:1,...e!=null?e:{}}}get options(){return this._options}get vertexMap(){return this._vertexMap}set vertexMap(t){this._vertexMap=t}get size(){return this._vertexMap.size}getVertex(t){return this._vertexMap.get(t)||void 0}hasVertex(t){return this._vertexMap.has(this._getVertexKey(t))}addVertex(t,e){if(t instanceof S)return this._addVertex(t);{let i=this.createVertex(t,e);return this._addVertex(i)}}isVertexKey(t){let e=typeof t;return e==="string"||e==="number"}removeManyVertices(t){let e=[];for(let i of t)e.push(this.deleteVertex(i));return e.length>0}hasEdge(t,e){return!!this.getEdge(t,e)}addEdge(t,e,i,s){if(t instanceof Mt)return this._addEdge(t);if(e instanceof S||typeof e=="string"||typeof e=="number"){if(!(this.hasVertex(t)&&this.hasVertex(e)))return!1;t instanceof S&&(t=t.key),e instanceof S&&(e=e.key);let r=this.createEdge(t,e,i,s);return this._addEdge(r)}else throw new Error("dest must be a Vertex or vertex key while srcOrEdge is an Edge")}setEdgeWeight(t,e,i){let s=this.getEdge(t,e);return s?(s.weight=i,!0):!1}getAllPathsBetween(t,e,i=1e3){let s=[],r=this._getVertex(t),n=this._getVertex(e);if(!(r&&n))return[];let h=[];for(h.push({vertex:r,path:[r]});h.length>0;){let{vertex:o,path:l}=h.pop();if(o===n&&(s.push(l),s.length>=i))return s;let a=this.getNeighbors(o);for(let _ of a)if(!l.includes(_)){let g=[...l,_];h.push({vertex:_,path:g})}}return s}getPathSumWeight(t){var e;let i=0;for(let s=0;s<t.length;s++)i+=((e=this.getEdge(t[s],t[s+1]))==null?void 0:e.weight)||0;return i}getMinCostBetween(t,e,i){if(i===void 0&&(i=!1),i){let s=this.getAllPathsBetween(t,e),r=Number.MAX_SAFE_INTEGER;for(let n of s)r=Math.min(this.getPathSumWeight(n),r);return r}else{let s=this._getVertex(e),r=this._getVertex(t);if(!(r&&s))return;let n=new Map,h=new H([r]);n.set(r,!0);let o=0;for(;h.length>0;){for(let l=0,a=h.length;l<a;l++){let _=h.shift();if(_===s)return o;if(_!==void 0){let g=this.getNeighbors(_);for(let p of g)n.has(p)||(n.set(p,!0),h.push(p))}}o++}return}}getMinPathBetween(t,e,i,s=!1){var r,n;if(i===void 0&&(i=!1),i)if(s){let h=this.getAllPathsBetween(t,e,1e4),o=Number.MAX_SAFE_INTEGER,l=-1,a=0;for(let _ of h){let g=this.getPathSumWeight(_);g<o&&(o=g,l=a),a++}return h[l]||void 0}else return(n=(r=this.dijkstra(t,e,!0,!0))==null?void 0:r.minPath)!=null?n:[];else{let h=[],o=this._getVertex(t),l=this._getVertex(e);if(!(o&&l))return[];let a=f((_,g,p,m)=>{if(p.add(_),_===g){h=[o,...m];return}let x=this.getNeighbors(_);for(let b of x)p.has(b)||(m.push(b),a(b,g,p,m),m.pop());p.delete(_)},"dfs");return a(o,l,new Set,[]),h}}dijkstraWithoutHeap(t,e=void 0,i=!1,s=!1){let r=Number.MAX_SAFE_INTEGER,n,h=[],o=[],l=this._vertexMap,a=new Map,_=new Set,g=new Map,p=this._getVertex(t),m=e?this._getVertex(e):void 0;if(!p)return;for(let w of l){let M=w[1];M instanceof S&&a.set(M,Number.MAX_SAFE_INTEGER)}a.set(p,0),g.set(p,void 0);let x=f(()=>{let w=Number.MAX_SAFE_INTEGER,M;for(let[k,v]of a)_.has(k)||v<w&&(w=v,M=k);return M},"getMinOfNoSeen"),b=f(w=>{for(let M of l){let k=M[1];if(k instanceof S){let v=[k],y=g.get(k);for(;y;)v.push(y),y=g.get(y);let N=v.reverse();M[1]===w&&(h=N),o.push(N)}}},"getPaths");for(let w=1;w<l.size;w++){let M=x();if(M){if(_.add(M),m&&m===M)return i&&(r=a.get(m)||Number.MAX_SAFE_INTEGER),s&&b(m),{distMap:a,preMap:g,seen:_,paths:o,minDist:r,minPath:h};let k=this.getNeighbors(M);for(let v of k)if(!_.has(v)){let y=this.getEdge(M,v);if(y){let N=a.get(M),E=a.get(v);N!==void 0&&E!==void 0&&y.weight+N<E&&(a.set(v,y.weight+N),g.set(v,M))}}}}return i&&a.forEach((w,M)=>{M!==p&&w<r&&(r=w,s&&(n=M))}),s&&b(n),{distMap:a,preMap:g,seen:_,paths:o,minDist:r,minPath:h}}dijkstra(t,e=void 0,i=!1,s=!1){var r;let n=Number.MAX_SAFE_INTEGER,h,o=[],l=[],a=this._vertexMap,_=new Map,g=new Set,p=new Map,m=this._getVertex(t),x=e?this._getVertex(e):void 0;if(!m)return;for(let M of a){let k=M[1];k instanceof S&&_.set(k,Number.MAX_SAFE_INTEGER)}let b=new nt([],{comparator:f((M,k)=>M.key-k.key,"comparator")});b.add({key:0,value:m}),_.set(m,0),p.set(m,void 0);let w=f(M=>{for(let k of a){let v=k[1];if(v instanceof S){let y=[v],N=p.get(v);for(;N;)y.push(N),N=p.get(N);let E=y.reverse();k[1]===M&&(o=E),l.push(E)}}},"getPaths");for(;b.size>0;){let M=b.poll(),k=M==null?void 0:M.key,v=M==null?void 0:M.value;if(k!==void 0&&v){if(g.add(v),x&&x===v)return i&&(n=_.get(x)||Number.MAX_SAFE_INTEGER),s&&w(x),{distMap:_,preMap:p,seen:g,paths:l,minDist:n,minPath:o};let y=this.getNeighbors(v);for(let N of y)if(!g.has(N)){let E=(r=this.getEdge(v,N))==null?void 0:r.weight;if(typeof E=="number"){let T=_.get(N);T!==void 0&&k+E<T&&(b.add({key:k+E,value:N}),p.set(N,v),_.set(N,k+E))}}}}return i&&_.forEach((M,k)=>{k!==m&&M<n&&(n=M,s&&(h=k))}),s&&w(h),{distMap:_,preMap:p,seen:g,paths:l,minDist:n,minPath:o}}bellmanFord(t,e,i,s){i===void 0&&(i=!1),s===void 0&&(s=!1);let r=this._getVertex(t),n=[],h=new Map,o=new Map,l=Number.MAX_SAFE_INTEGER,a=[],_;if(e&&(_=!1),!r)return{hasNegativeCycle:_,distMap:h,preMap:o,paths:n,min:l,minPath:a};let g=this._vertexMap,p=g.size,m=this.edgeSet(),x=m.length;this._vertexMap.forEach(w=>{h.set(w,Number.MAX_SAFE_INTEGER)}),h.set(r,0);for(let w=1;w<p;++w)for(let M=0;M<x;++M){let k=this.getEndsOfEdge(m[M]);if(k){let[v,y]=k,N=m[M].weight,E=h.get(v),T=h.get(y);E!==void 0&&T!==void 0&&h.get(v)!==Number.MAX_SAFE_INTEGER&&E+N<T&&(h.set(y,E+N),s&&o.set(y,v))}}let b;if(i&&h.forEach((w,M)=>{M!==r&&w<l&&(l=w,s&&(b=M))}),s)for(let w of g){let M=w[1];if(M instanceof S){let k=[M],v=o.get(M);for(;v!==void 0;)k.push(v),v=o.get(v);let y=k.reverse();w[1]===b&&(a=y),n.push(y)}}for(let w=0;w<x;++w){let M=this.getEndsOfEdge(m[w]);if(M){let[k]=M,v=m[w].weight,y=h.get(k);y&&y!==Number.MAX_SAFE_INTEGER&&y+v<y&&(_=!0)}}return{hasNegativeCycle:_,distMap:h,preMap:o,paths:n,min:l,minPath:a}}floydWarshall(){var t;let e=[...this._vertexMap],i=e.length,s=[],r=[];for(let n=0;n<i;n++){s[n]=[],r[n]=[];for(let h=0;h<i;h++)r[n][h]=void 0}for(let n=0;n<i;n++)for(let h=0;h<i;h++)s[n][h]=((t=this.getEdge(e[n][1],e[h][1]))==null?void 0:t.weight)||Number.MAX_SAFE_INTEGER;for(let n=0;n<i;n++)for(let h=0;h<i;h++)for(let o=0;o<i;o++)s[h][o]>s[h][n]+s[n][o]&&(s[h][o]=s[h][n]+s[n][o],r[h][o]=e[n][1]);return{costs:s,predecessor:r}}getCycles(t=!1){let e=[],i=new Set,s=f((n,h,o)=>{if(o.has(n)){(!t&&h.length>2||t&&h.length>=2)&&h[0]===n.key&&e.push([...h]);return}o.add(n),h.push(n.key);for(let l of this.getNeighbors(n))l&&s(l,h,o);o.delete(n),h.pop()},"dfs");for(let n of this.vertexMap.values())s(n,[],i);let r=new Map;for(let n of e){let h=[...n].sort().toString();r.has(h)||r.set(h,n)}return[...r].map(n=>n[1])}filter(t,e){let i=[],s=0;for(let[r,n]of this)t.call(e,n,r,s,this)&&i.push([r,n]),s++;return this._createLike(i,this._snapshotOptions())}filterEntries(t,e){let i=[],s=0;for(let[r,n]of this)t.call(e,n,r,s,this)&&i.push([r,n]),s++;return i}map(t,e){let i=[],s=0;for(let[r,n]of this)i.push(t.call(e,n,r,s,this)),s++;return i}clone(){return this._createLike(void 0,this._snapshotOptions())}*_getIterator(){for(let t of this._vertexMap.values())yield[t.key,t.value]}_snapshotOptions(){return{graph:{...this._options}}}_createInstance(t){let e=this.constructor,i=new e,s=t==null?void 0:t.graph;return s?i._options={...i._options,...s}:i._options={...i._options,...this._options},i}_createLike(t,e){let i=this._createInstance(e);if(t)for(let[r,n]of t)i.addVertex(r,n);else for(let[r,n]of this)i.addVertex(r,n);let s=this.edgeSet();for(let r of s){let n=this.getEndsOfEdge(r);if(!n)continue;let[h,o]=n,l=h.key,a=o.key,_=i.hasVertex?i.hasVertex(l):!1,g=i.hasVertex?i.hasVertex(a):!1;if(_&&g){let p=r.weight,m=r.value,x=i.createEdge(l,a,p,m);i._addEdge(x)}}return i}_addVertex(t){return this.hasVertex(t)?!1:(this._vertexMap.set(t.key,t),!0)}_getVertex(t){let e=this._getVertexKey(t);return this._vertexMap.get(e)||void 0}_getVertexKey(t){return t instanceof S?t.key:t}};f(Zt,"AbstractGraph");var te=Zt,ee=class extends S{constructor(t,e){super(t,e)}};f(ee,"DirectedVertex");var gt=ee,ie=class extends Mt{constructor(t,e,i,s){super(i,s),u(this,"src"),u(this,"dest"),this.src=t,this.dest=e}};f(ie,"DirectedEdge");var se=ie,re=class pt extends te{constructor(t){super(t),u(this,"_outEdgeMap",new Map),u(this,"_inEdgeMap",new Map)}get outEdgeMap(){return this._outEdgeMap}set outEdgeMap(t){this._outEdgeMap=t}get inEdgeMap(){return this._inEdgeMap}set inEdgeMap(t){this._inEdgeMap=t}static fromKeys(t){let e=new pt({vertexValueInitializer:f(i=>i,"vertexValueInitializer")});for(let i of t)e.addVertex(i);return e}static fromEntries(t){let e=new pt;for(let[i,s]of t)e.addVertex(i,s);return e}createVertex(t,e){return new gt(t,e)}createEdge(t,e,i,s){var r;return new se(t,e,(r=i!=null?i:this.options.defaultEdgeWeight)!=null?r:1,s)}getEdge(t,e){let i=[];if(t!==void 0&&e!==void 0){let s=this._getVertex(t),r=this._getVertex(e);if(s&&r){let n=this._outEdgeMap.get(s);n&&(i=n.filter(h=>h.dest===r.key))}}return i[0]||void 0}deleteEdgeSrcToDest(t,e){let i=this._getVertex(t),s=this._getVertex(e),r;if(!i||!s)return;let n=this._outEdgeMap.get(i);n&&z(n,o=>o.dest===s.key);let h=this._inEdgeMap.get(s);return h&&(r=z(h,o=>o.src===i.key)[0]||void 0),r}deleteEdge(t,e){let i,s,r;if(this.isVertexKey(t))if(this.isVertexKey(e))s=this._getVertex(t),r=this._getVertex(e);else return;else s=this._getVertex(t.src),r=this._getVertex(t.dest);if(s&&r){let n=this._outEdgeMap.get(s);n&&n.length>0&&z(n,o=>o.src===s.key&&o.dest===(r==null?void 0:r.key));let h=this._inEdgeMap.get(r);h&&h.length>0&&(i=z(h,o=>o.src===s.key&&o.dest===r.key)[0])}return i}deleteVertex(t){let e,i;if(this.isVertexKey(t)?(i=this.getVertex(t),e=t):(i=t,e=this._getVertexKey(t)),i){let s=this.getNeighbors(i);for(let r of s)this.deleteEdgeSrcToDest(i,r);this._outEdgeMap.delete(i),this._inEdgeMap.delete(i)}return this._vertexMap.delete(e)}deleteEdgesBetween(t,e){let i=[];if(t&&e){let s=this.deleteEdgeSrcToDest(t,e),r=this.deleteEdgeSrcToDest(e,t);s&&i.push(s),r&&i.push(r)}return i}incomingEdgesOf(t){let e=this._getVertex(t);return e?this.inEdgeMap.get(e)||[]:[]}outgoingEdgesOf(t){let e=this._getVertex(t);return e?this._outEdgeMap.get(e)||[]:[]}degreeOf(t){return this.outDegreeOf(t)+this.inDegreeOf(t)}inDegreeOf(t){return this.incomingEdgesOf(t).length}outDegreeOf(t){return this.outgoingEdgesOf(t).length}edgesOf(t){return[...this.outgoingEdgesOf(t),...this.incomingEdgesOf(t)]}getEdgeSrc(t){return this._getVertex(t.src)}getEdgeDest(t){return this._getVertex(t.dest)}getDestinations(t){if(t===void 0)return[];let e=[],i=this.outgoingEdgesOf(t);for(let s of i){let r=this.getEdgeDest(s);r&&e.push(r)}return e}topologicalSort(t){t=t!=null?t:"key";let e=new Map;for(let n of this.vertexMap)e.set(n[1],0);let i=[],s=!1,r=f(n=>{e.set(n,1);let h=this.getDestinations(n);for(let o of h){let l=e.get(o);l===0?r(o):l===1&&(s=!0)}e.set(n,2),i.push(n)},"dfs");for(let n of this.vertexMap)e.get(n[1])===0&&r(n[1]);if(!s)return t==="key"&&(i=i.map(n=>n instanceof gt?n.key:n)),i.reverse()}edgeSet(){let t=[];return this._outEdgeMap.forEach(e=>{t=[...t,...e]}),t}getNeighbors(t){let e=[],i=this._getVertex(t);if(i){let s=this.outgoingEdgesOf(i);for(let r of s){let n=this._getVertex(r.dest);n&&e.push(n)}}return e}getEndsOfEdge(t){if(!this.hasEdge(t.src,t.dest))return;let e=this._getVertex(t.src),i=this._getVertex(t.dest);if(e&&i)return[e,i]}isEmpty(){return this.vertexMap.size===0&&this.inEdgeMap.size===0&&this.outEdgeMap.size===0}clear(){this._vertexMap=new Map,this._inEdgeMap=new Map,this._outEdgeMap=new Map}clone(){return super.clone()}tarjan(){let t=new Map,e=new Map,i=new Map,s=0,r=[],n=new Set,h=f(o=>{t.set(o,s),e.set(o,s),s++,r.push(o),n.add(o);let l=this.getNeighbors(o);for(let a of l)t.has(a)?n.has(a)&&e.set(o,Math.min(e.get(o),t.get(a))):(h(a),e.set(o,Math.min(e.get(o),e.get(a))));if(t.get(o)===e.get(o)){let a=[],_;do _=r.pop(),n.delete(_),a.push(_);while(_!==o);i.set(i.size,a)}},"dfs");for(let o of this.vertexMap.values())t.has(o)||h(o);return{dfnMap:t,lowMap:e,SCCs:i}}getDFNMap(){return this.tarjan().dfnMap}getLowMap(){return this.tarjan().lowMap}getSCCs(){return this.tarjan().SCCs}_addEdge(t){if(!(this.hasVertex(t.src)&&this.hasVertex(t.dest)))return!1;let e=this._getVertex(t.src),i=this._getVertex(t.dest);if(e&&i){let s=this._outEdgeMap.get(e);s?s.push(t):this._outEdgeMap.set(e,[t]);let r=this._inEdgeMap.get(i);return r?r.push(t):this._inEdgeMap.set(i,[t]),!0}else return!1}};f(re,"DirectedGraph");var $e=re,ne=class extends S{constructor(t,e){super(t,e)}};f(ne,"UndirectedVertex");var Je=ne,he=class extends Mt{constructor(t,e,i,s){super(i,s),u(this,"endpoints"),this.endpoints=[t,e]}};f(he,"UndirectedEdge");var Ye=he,Ze=class vt extends te{constructor(t){super(t),u(this,"_edgeMap"),this._edgeMap=new Map}get edgeMap(){return this._edgeMap}set edgeMap(t){this._edgeMap=t}static fromKeys(t){let e=new vt({vertexValueInitializer:f(i=>i,"vertexValueInitializer")});for(let i of t)e.addVertex(i);return e}static fromEntries(t){let e=new vt;for(let[i,s]of t)e.addVertex(i,s);return e}createVertex(t,e){return new Je(t,e)}createEdge(t,e,i,s){var r;return new Ye(t,e,(r=i!=null?i:this.options.defaultEdgeWeight)!=null?r:1,s)}getEdge(t,e){var i;let s=[];if(t!==void 0&&e!==void 0){let r=this._getVertex(t),n=this._getVertex(e);r&&n&&(s=(i=this._edgeMap.get(r))==null?void 0:i.filter(h=>h.endpoints.includes(n.key)))}return s&&s[0]||void 0}deleteEdgeBetween(t,e){let i=this._getVertex(t),s=this._getVertex(e);if(!i||!s)return;let r=this._edgeMap.get(i),n;r&&(n=z(r,o=>o.endpoints.includes(s.key))[0]||void 0);let h=this._edgeMap.get(s);return h&&z(h,o=>o.endpoints.includes(i.key)),n}deleteEdge(t,e){let i,s;if(this.isVertexKey(t))if(this.isVertexKey(e))i=this._getVertex(t),s=this._getVertex(e);else return;else i=this._getVertex(t.endpoints[0]),s=this._getVertex(t.endpoints[1]);if(i&&s)return this.deleteEdgeBetween(i,s)}deleteVertex(t){let e,i;this.isVertexKey(t)?(i=this.getVertex(t),e=t):(i=t,e=this._getVertexKey(t));let s=this.getNeighbors(t);return i&&(s.forEach(r=>{let n=this._edgeMap.get(r);if(n){let h=n.filter(o=>!o.endpoints.includes(e));this._edgeMap.set(r,h)}}),this._edgeMap.delete(i)),this._vertexMap.delete(e)}degreeOf(t){var e;let i=this._getVertex(t);return i&&((e=this._edgeMap.get(i))==null?void 0:e.length)||0}edgesOf(t){let e=this._getVertex(t);return e?this._edgeMap.get(e)||[]:[]}edgeSet(){let t=new Set;return this._edgeMap.forEach(e=>{e.forEach(i=>{t.add(i)})}),[...t]}getNeighbors(t){let e=[],i=this._getVertex(t);if(i){let s=this.edgesOf(i);for(let r of s){let n=this._getVertex(r.endpoints.filter(h=>h!==i.key)[0]);n&&e.push(n)}}return e}getEndsOfEdge(t){if(!this.hasEdge(t.endpoints[0],t.endpoints[1]))return;let e=this._getVertex(t.endpoints[0]),i=this._getVertex(t.endpoints[1]);if(e&&i)return[e,i]}isEmpty(){return this.vertexMap.size===0&&this.edgeMap.size===0}clear(){this._vertexMap=new Map,this._edgeMap=new Map}clone(){return super.clone()}tarjan(){let t=new Map,e=new Map,i=[],s=[],r=0,n=f((h,o)=>{t.set(h,r),e.set(h,r),r++;let l=this.getNeighbors(h),a=0;for(let _ of l)if(t.has(_))_!==o&&e.set(h,Math.min(e.get(h),t.get(_)));else{if(a++,n(_,h),e.set(h,Math.min(e.get(h),e.get(_))),e.get(_)>t.get(h)){let g=this.getEdge(h,_);g&&i.push(g)}o!==void 0&&e.get(_)>=t.get(h)&&s.push(h)}o===void 0&&a>1&&s.push(h)},"dfs");for(let h of this.vertexMap.values())t.has(h)||n(h,void 0);return{dfnMap:t,lowMap:e,bridges:i,cutVertices:s}}getBridges(){return this.tarjan().bridges}getCutVertices(){return this.tarjan().cutVertices}getDFNMap(){return this.tarjan().dfnMap}getLowMap(){return this.tarjan().lowMap}_addEdge(t){for(let e of t.endpoints){let i=this._getVertex(e);if(i===void 0)return!1;if(i){let s=this._edgeMap.get(i);s?s.push(t):this._edgeMap.set(i,[t])}}return!0}};f(Ze,"UndirectedGraph");var oe=class extends gt{constructor(t,e,i,s){super(t,e),u(this,"lat"),u(this,"long"),this.lat=i,this.long=s}};f(oe,"MapVertex");var ti=oe,le=class extends se{constructor(t,e,i,s){super(t,e,i,s)}};f(le,"MapEdge");var ei=le,ii=class ae extends $e{constructor(t,e){super(),u(this,"_originCoord",[0,0]),u(this,"_bottomRight"),this._originCoord=t,this._bottomRight=e}get originCoord(){return this._originCoord}get bottomRight(){return this._bottomRight}createVertex(t,e,i=this.originCoord[0],s=this.originCoord[1]){return new ti(t,e,i,s)}createEdge(t,e,i,s){return new ei(t,e,i,s)}clone(){return super.clone()}_snapshotOptions(){return{...super._snapshotOptions(),originCoord:this.originCoord,bottomRight:this.bottomRight}}_createInstance(t){let{originCoord:e,bottomRight:i}=t||{},s=e!=null?e:this.originCoord,r=i!=null?i:this.bottomRight;return new ae(s,r)}};f(ii,"MapGraph");var ue=class{constructor(t,e,i=!0,s=!0){this.low=t,this.high=e,this.includeLow=i,this.includeHigh=s}isInRange(t,e){let i=this.includeLow?e(t,this.low)>=0:e(t,this.low)>0,s=this.includeHigh?e(t,this.high)<=0:e(t,this.high)<0;return i&&s}};f(ue,"Range");var $=ue,fe=class{constructor(t,e){u(this,"key"),u(this,"value"),u(this,"parent"),u(this,"_left"),u(this,"_right"),u(this,"_height",0),u(this,"_color","BLACK"),u(this,"_count",1),this.key=t,this.value=e}get left(){return this._left}set left(t){t&&(t.parent=this),this._left=t}get right(){return this._right}set right(t){t&&(t.parent=this),this._right=t}get height(){return this._height}set height(t){this._height=t}get color(){return this._color}set color(t){this._color=t}get count(){return this._count}set count(t){this._count=t}get familyPosition(){return this.parent?this.parent.left===this?this.left||this.right?"ROOT_LEFT":"LEFT":this.parent.right===this?this.left||this.right?"ROOT_RIGHT":"RIGHT":"MAL_NODE":this.left||this.right?"ROOT":"ISOLATED"}};f(fe,"BinaryTreeNode");var ut=fe,ce=class extends st{constructor(t=[],e){if(super(),u(this,"iterationType","ITERATIVE"),u(this,"_isMapMode",!0),u(this,"_isDuplicate",!1),u(this,"_store",new Map),u(this,"_root"),u(this,"_size",0),u(this,"_NIL",new ut(NaN)),u(this,"_toEntryFn"),u(this,"_DEFAULT_NODE_CALLBACK",f(i=>i?i.key:void 0,"_DEFAULT_NODE_CALLBACK")),e){let{iterationType:i,toEntryFn:s,isMapMode:r,isDuplicate:n}=e;if(i&&(this.iterationType=i),r!==void 0&&(this._isMapMode=r),n!==void 0&&(this._isDuplicate=n),typeof s=="function")this._toEntryFn=s;else if(s)throw TypeError("toEntryFn must be a function type")}t&&this.setMany(t)}get isMapMode(){return this._isMapMode}get isDuplicate(){return this._isDuplicate}get store(){return this._store}get root(){return this._root}get size(){return this._size}get NIL(){return this._NIL}get toEntryFn(){return this._toEntryFn}createNode(t,e){return new ut(t,e)}createTree(t){return this._createInstance(t)}ensureNode(t,e=this.iterationType){if(t===null)return null;if(t!==void 0&&t!==this._NIL){if(this.isNode(t))return t;if(this.isEntry(t)){let i=t[0];return i===null?null:i===void 0?void 0:this.getNode(i,this._root,e)}return this.getNode(t,this._root,e)}}isNode(t){return t instanceof ut}isRaw(t){return this._toEntryFn!==void 0&&typeof t=="object"}isRealNode(t){return t===this._NIL||t===null||t===void 0?!1:this.isNode(t)}isRealNodeOrNull(t){return t===null||this.isRealNode(t)}isNIL(t){return t===this._NIL}isRange(t){return t instanceof $}isLeaf(t){return t=this.ensureNode(t),t===void 0?!1:t===null?!0:!this.isRealNode(t.left)&&!this.isRealNode(t.right)}isEntry(t){return Array.isArray(t)&&t.length===2}isValidKey(t){return t===null?!0:X(t)}add(t){return this.set(t)}set(t,e){let[i]=this._keyValueNodeOrEntryToNodeAndValue(t,e);if(i===void 0)return!1;if(!this._root)return this._setRoot(i),this._isMapMode&&i!==null&&i!==void 0&&this._store.set(i.key,i),this._size=1,!0;let s=new H([this._root]),r;for(;s.length>0;){let n=s.shift();if(n){if(!this._isDuplicate&&i!==null&&n.key===i.key)return this._replaceNode(n,i),this._isMapMode&&i!==null&&this._store.set(n.key,i),!0;r===void 0&&(n.left===void 0||n.right===void 0)&&(r=n),n.left!==null&&n.left&&s.push(n.left),n.right!==null&&n.right&&s.push(n.right)}}return r?(r.left===void 0?r.left=i:r.right===void 0&&(r.right=i),this._isMapMode&&i!==null&&i!==void 0&&this._store.set(i.key,i),this._size++,!0):!1}addMany(t){return this.setMany(t)}setMany(t,e){let i=[],s;e&&(s=e[Symbol.iterator]());for(let r of t){let n;if(s){let h=s.next();h.done||(n=h.value)}this.isRaw(r)&&(r=this._toEntryFn(r)),i.push(this.set(r,n))}return i}merge(t){this.setMany(t,[])}refill(t,e){this.clear(),this.setMany(t,e)}delete(t){let e=[];if(!this._root)return e;let i=this.getNode(t);if(!i)return e;let s=i==null?void 0:i.parent,r,n=i;if(!i.left&&!i.right&&!s)this._setRoot(void 0);else if(i.left){let h=this.getRightMost(o=>o,i.left);if(h){let o=h.parent;n=this._swapProperties(i,h),this._isMapMode&&(this._store.set(i.key,i),this._store.set(h.key,h)),o&&(o.right===h?o.right=h.left:o.left=h.left,r=o)}}else if(s){let{familyPosition:h}=i;h==="LEFT"||h==="ROOT_LEFT"?s.left=i.right:(h==="RIGHT"||h==="ROOT_RIGHT")&&(s.right=i.right),r=s}else this._setRoot(i.right),i.right=void 0;return this._size=this._size-1,e.push({deleted:n,needBalanced:r}),this._isMapMode&&n&&this._store.delete(n.key),e}search(t,e=!1,i=this._DEFAULT_NODE_CALLBACK,s=this._root,r=this.iterationType){if(t===void 0)return[];if(t===null)return[];if(s=this.ensureNode(s),!s)return[];let n=this._ensurePredicate(t),h=[];if(r==="RECURSIVE"){let o=f(l=>{n(l)&&(h.push(i(l)),e)||!this.isRealNode(l.left)&&!this.isRealNode(l.right)||(this.isRealNode(l.left)&&o(l.left),this.isRealNode(l.right)&&o(l.right))},"dfs");o(s)}else{let o=[s];for(;o.length>0;){let l=o.pop();if(this.isRealNode(l)){if(n(l)&&(h.push(i(l)),e))return h;this.isRealNode(l.left)&&o.push(l.left),this.isRealNode(l.right)&&o.push(l.right)}}}return h}getNodes(t,e=!1,i=this._root,s=this.iterationType){return this.search(t,e,r=>r,i,s)}getNode(t,e=this._root,i=this.iterationType){if(this._isMapMode&&t!==null&&t!==void 0&&!this._isPredicate(t)){let s=this._extractKey(t);return s==null?void 0:this._store.get(s)}return this.search(t,!0,s=>s,e,i)[0]}get(t,e=this._root,i=this.iterationType){var s,r;if(this._isMapMode){let n=this._extractKey(t);return n==null||(s=this._store.get(n))==null?void 0:s.value}return(r=this.getNode(t,e,i))==null?void 0:r.value}has(t,e=this._root,i=this.iterationType){if(this._isMapMode&&t!==void 0&&t!==null&&!this._isPredicate(t)){let s=this._extractKey(t);return s==null?!1:this._store.has(s)}return this.search(t,!0,s=>s,e,i).length>0}clear(){this._clearNodes(),this._isMapMode&&this._clearValues()}isEmpty(){return this._size===0}isPerfectlyBalanced(t=this._root){return this.getMinHeight(t)+1>=this.getHeight(t)}isBST(t=this._root,e=this.iterationType){let i=this.ensureNode(t);if(!i)return!0;if(e==="RECURSIVE"){let s=f((h,o,l)=>{if(!this.isRealNode(h))return!0;let a=Number(h.key);return a<=o||a>=l?!1:s(h.left,o,a)&&s(h.right,a,l)},"dfs"),r=s(i,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),n=s(i,Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER);return r||n}else{let s=f((h=!1)=>{let o=[],l=h?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,a=i;for(;this.isRealNode(a)||o.length>0;){for(;this.isRealNode(a);)o.push(a),a=a.left;a=o.pop();let _=Number(a.key);if(!this.isRealNode(a)||!h&&l>=_||h&&l<=_)return!1;l=_,a=a.right}return!0},"checkBST"),r=s(),n=s(!0);return r||n}}getDepth(t,e=this._root){let i=this.ensureNode(t),s=this.ensureNode(e),r=0;for(;i!=null&&i.parent;){if(i===s)return r;r++,i=i.parent}return r}getHeight(t=this._root,e=this.iterationType){if(t=this.ensureNode(t),!this.isRealNode(t))return-1;if(e==="RECURSIVE"){let i=f(s=>{if(!this.isRealNode(s))return-1;let r=i(s.left),n=i(s.right);return Math.max(r,n)+1},"_getMaxHeight");return i(t)}else{let i=[{node:t,depth:0}],s=0;for(;i.length>0;){let{node:r,depth:n}=i.pop();this.isRealNode(r.left)&&i.push({node:r.left,depth:n+1}),this.isRealNode(r.right)&&i.push({node:r.right,depth:n+1}),s=Math.max(s,n)}return s}}getMinHeight(t=this._root,e=this.iterationType){if(t=this.ensureNode(t),!t)return-1;if(e==="RECURSIVE"){let i=f(s=>{if(!this.isRealNode(s)||!this.isRealNode(s.left)&&!this.isRealNode(s.right))return 0;let r=i(s.left),n=i(s.right);return Math.min(r,n)+1},"_getMinHeight");return i(t)}else{let i=[],s=t,r=null,n=new Map;for(;i.length>0||s;)if(this.isRealNode(s))i.push(s),s=s.left;else if(s=i[i.length-1],!this.isRealNode(s.right)||r===s.right){if(s=i.pop(),this.isRealNode(s)){let h=this.isRealNode(s.left)?n.get(s.left):-1,o=this.isRealNode(s.right)?n.get(s.right):-1;n.set(s,1+Math.min(h,o)),r=s,s=null}}else s=s.right;return n.get(t)}}getPathToRoot(t,e=this._DEFAULT_NODE_CALLBACK,i=!1){let s=[],r=this.ensureNode(t);if(!r)return s;for(;r.parent;)s.push(e(r)),r=r.parent;return s.push(e(r)),i?s.reverse():s}getLeftMost(t=this._DEFAULT_NODE_CALLBACK,e=this._root,i=this.iterationType){if(this.isNIL(e))return t(void 0);let s=this.ensureNode(e);if(!this.isRealNode(s))return t(void 0);if(i==="RECURSIVE"){let r=f(n=>{let{left:h}=n;return this.isRealNode(h)?r(h):n},"dfs");return t(r(s))}else{let r=_t(n=>{let{left:h}=n;return this.isRealNode(h)?bt(()=>r(h)):n});return t(r(s))}}getRightMost(t=this._DEFAULT_NODE_CALLBACK,e=this._root,i=this.iterationType){if(this.isNIL(e)||(e=this.ensureNode(e),!e))return t(void 0);if(i==="RECURSIVE"){let s=f(r=>{let{right:n}=r;return this.isRealNode(n)?s(n):r},"dfs");return t(s(e))}else{let s=_t(r=>{let{right:n}=r;return this.isRealNode(n)?bt(()=>s(n)):r});return t(s(e))}}getPredecessor(t){if(this.isRealNode(t.left)){let e=t.left;for(;!this.isRealNode(e)||this.isRealNode(e.right)&&e.right!==t;)this.isRealNode(e)&&(e=e.right);return e}else return t}getSuccessor(t){if(t=this.ensureNode(t),!this.isRealNode(t))return;if(this.isRealNode(t.right))return this.getLeftMost(i=>i,t.right);let e=t.parent;for(;this.isRealNode(e)&&t===e.right;)t=e,e=e.parent;return e}dfs(t=this._DEFAULT_NODE_CALLBACK,e="IN",i=!1,s=this._root,r=this.iterationType,n=!1){return s=this.ensureNode(s),s?this._dfs(t,e,i,s,r,n):[]}bfs(t=this._DEFAULT_NODE_CALLBACK,e=this._root,i=this.iterationType,s=!1){if(e=this.ensureNode(e),!e)return[];let r=[];if(i==="RECURSIVE"){let n=new H([e]),h=f(o=>{if(n.length===0)return;let l=n.shift();r.push(t(l)),s?(l&&this.isRealNodeOrNull(l.left)&&n.push(l.left),l&&this.isRealNodeOrNull(l.right)&&n.push(l.right)):(this.isRealNode(l.left)&&n.push(l.left),this.isRealNode(l.right)&&n.push(l.right)),h(o+1)},"dfs");h(0)}else{let n=new H([e]);for(;n.length>0;){let h=n.length;for(let o=0;o<h;o++){let l=n.shift();r.push(t(l)),s?(l&&this.isRealNodeOrNull(l.left)&&n.push(l.left),l&&this.isRealNodeOrNull(l.right)&&n.push(l.right)):(this.isRealNode(l.left)&&n.push(l.left),this.isRealNode(l.right)&&n.push(l.right))}}}return r}leaves(t=this._DEFAULT_NODE_CALLBACK,e=this._root,i=this.iterationType){e=this.ensureNode(e);let s=[];if(!this.isRealNode(e))return[];if(i==="RECURSIVE"){let r=f(n=>{this.isLeaf(n)&&s.push(t(n)),!(!this.isRealNode(n.left)&&!this.isRealNode(n.right))&&(this.isRealNode(n.left)&&r(n.left),this.isRealNode(n.right)&&r(n.right))},"dfs");r(e)}else{let r=new H([e]);for(;r.length>0;){let n=r.shift();this.isRealNode(n)&&(this.isLeaf(n)&&s.push(t(n)),this.isRealNode(n.left)&&r.push(n.left),this.isRealNode(n.right)&&r.push(n.right))}}return s}listLevels(t=this._DEFAULT_NODE_CALLBACK,e=this._root,i=this.iterationType,s=!1){e=this.ensureNode(e);let r=[];if(!e)return r;if(i==="RECURSIVE"){let n=f((h,o)=>{r[o]||(r[o]=[]),r[o].push(t(h)),s?(h&&this.isRealNodeOrNull(h.left)&&n(h.left,o+1),h&&this.isRealNodeOrNull(h.right)&&n(h.right,o+1)):(h&&h.left&&n(h.left,o+1),h&&h.right&&n(h.right,o+1))},"_recursive");n(e,0)}else{let n=[[e,0]];for(;n.length>0;){let h=n.pop(),[o,l]=h;r[l]||(r[l]=[]),r[l].push(t(o)),s?(o&&this.isRealNodeOrNull(o.right)&&n.push([o.right,l+1]),o&&this.isRealNodeOrNull(o.left)&&n.push([o.left,l+1])):(o&&o.right&&n.push([o.right,l+1]),o&&o.left&&n.push([o.left,l+1]))}}return r}morris(t=this._DEFAULT_NODE_CALLBACK,e="IN",i=this._root){if(i=this.ensureNode(i),!i)return[];let s=[],r=i,n=f(o=>{let l=null,a=null;for(;o;)a=o.right,o.right=l,l=o,o=a;return l},"_reverseEdge"),h=f(o=>{let l=n(o),a=l;for(;a;)s.push(t(a)),a=a.right;n(l)},"_printEdge");switch(e){case"IN":for(;r;){if(r.left){let o=this.getPredecessor(r);if(o.right)o.right=null;else{o.right=r,r=r.left;continue}}s.push(t(r)),r=r.right}break;case"PRE":for(;r;){if(r.left){let o=this.getPredecessor(r);if(o.right)o.right=null;else{o.right=r,s.push(t(r)),r=r.left;continue}}else s.push(t(r));r=r.right}break;case"POST":for(;r;){if(r.left){let o=this.getPredecessor(r);if(o.right===null){o.right=r,r=r.left;continue}else o.right=null,h(r.left)}r=r.right}h(i);break}return s}clone(){let t=this._createInstance();return this._clone(t),t}filter(t,e){let i=this._createInstance(),s=0;for(let[r,n]of this)t.call(e,n,r,s++,this)&&i.set([r,n]);return i}map(t,e,i){let s=this._createLike([],e),r=0;for(let[n,h]of this)s.set(t.call(i,h,n,r++,this));return s}toVisual(t=this._root,e){let i={isShowUndefined:!1,isShowNull:!0,isShowRedBlackNIL:!1,...e};t=this.ensureNode(t);let s="";return t&&(i.isShowUndefined&&(s+=`U for undefined
|
|
2
|
+
`),i.isShowNull&&(s+=`N for null
|
|
3
|
+
`),i.isShowRedBlackNIL&&(s+=`S for Sentinel Node(NIL)
|
|
4
|
+
`),f(n=>{let[h]=this._displayAux(n,i),o="";for(let l of h)o+=l+`
|
|
5
|
+
`;s+=o},"display")(t)),s}print(t,e=this._root){console.log(this.toVisual(e,t))}_dfs(t=this._DEFAULT_NODE_CALLBACK,e="IN",i=!1,s=this._root,r=this.iterationType,n=!1,h=_=>!!_,o=_=>!!_,l=_=>n?this.isRealNodeOrNull(_):this.isRealNode(_),a=_=>this.isRealNodeOrNull(_)){if(s=this.ensureNode(s),!s)return[];let _=[];if(r==="RECURSIVE"){let g=f(p=>{if(!l(p))return;let m=f(()=>{h(p)&&(p==null?void 0:p.left)!==void 0&&g(p==null?void 0:p.left)},"visitLeft"),x=f(()=>{o(p)&&(p==null?void 0:p.right)!==void 0&&g(p==null?void 0:p.right)},"visitRight");switch(e){case"IN":if(m(),a(p)&&(_.push(t(p)),i))return;x();break;case"PRE":if(a(p)&&(_.push(t(p)),i))return;m(),x();break;case"POST":if(m(),x(),a(p)&&(_.push(t(p)),i))return;break}},"dfs");g(s)}else{let g=[{opt:0,node:s}],p=f(b=>{var w;h(b.node)&&g.push({opt:0,node:(w=b.node)==null?void 0:w.left})},"pushLeft"),m=f(b=>{var w;o(b.node)&&g.push({opt:0,node:(w=b.node)==null?void 0:w.right})},"pushRight"),x=f(b=>{l(b.node)&&g.push({opt:1,node:b.node})},"pushRoot");for(;g.length>0;){let b=g.pop();if(b!==void 0&&l(b.node))if(b.opt===1){if(a(b.node)&&b.node!==void 0&&(_.push(t(b.node)),i))return _}else switch(e){case"IN":m(b),x(b),p(b);break;case"PRE":m(b),p(b),x(b);break;case"POST":x(b),m(b),p(b);break}}}return _}*_getIterator(t=this._root){if(t)if(this.iterationType==="ITERATIVE"){let e=[],i=t;for(;i||e.length>0;){for(;this.isRealNode(i);)e.push(i),i=i.left;i=e.pop(),this.isRealNode(i)&&(yield[i.key,i.value],i=i.right)}}else t.left&&this.isRealNode(t)&&(yield*this[Symbol.iterator](t.left)),yield[t.key,t.value],t.right&&this.isRealNode(t)&&(yield*this[Symbol.iterator](t.right))}_snapshotOptions(){return{iterationType:this.iterationType,toEntryFn:this.toEntryFn,isMapMode:this.isMapMode,isDuplicate:this.isDuplicate}}_createInstance(t){let e=this.constructor;return new e([],{...this._snapshotOptions(),...t!=null?t:{}})}_createLike(t=[],e){let i=this.constructor;return new i(t,{...this._snapshotOptions(),...e!=null?e:{}})}_keyValueNodeOrEntryToNodeAndValue(t,e){if(t===void 0)return[void 0,void 0];if(t===null)return[null,void 0];if(this.isNode(t))return[t,e];if(this.isEntry(t)){let[i,s]=t;if(i===void 0)return[void 0,void 0];if(i===null)return[null,void 0];let r=e!=null?e:s;return[this.createNode(i,r),r]}return[this.createNode(t,e),e]}_clone(t){this.bfs(e=>{e===null?t.set(null):t.set([e.key,e.value])},this._root,this.iterationType,!0)}_displayAux(t,e){let{isShowNull:i,isShowUndefined:s,isShowRedBlackNIL:r}=e,n=[["\u2500"],1,0,0];if(t===null&&!i)return n;if(t===void 0&&!s)return n;if(this.isNIL(t)&&!r)return n;if(t!=null){let o=t.key,l=this.isNIL(t)?"S":String(o),a=l.length;return h(l,a,this._displayAux(t.left,e),this._displayAux(t.right,e))}else{let o=t===void 0?"U":"N",l=o.length;return h(o,l,[[""],1,0,0],[[""],1,0,0])}function h(o,l,a,_){let[g,p,m,x]=a,[b,w,M,k]=_,v=" ".repeat(Math.max(0,x+1))+"_".repeat(Math.max(0,p-x-1))+o+"_".repeat(Math.max(0,k))+" ".repeat(Math.max(0,w-k)),y=(m>0?" ".repeat(x)+"/"+" ".repeat(p-x-1):" ".repeat(p))+" ".repeat(l)+(M>0?" ".repeat(k)+"\\"+" ".repeat(w-k-1):" ".repeat(w)),N=[v,y];for(let E=0;E<Math.max(m,M);E++){let T=E<m?g[E]:" ".repeat(p),C=E<M?b[E]:" ".repeat(w);N.push(T+" ".repeat(l)+C)}return[N,p+l+w,Math.max(m,M)+2,p+Math.floor(l/2)]}}_swapProperties(t,e){if(t=this.ensureNode(t),e=this.ensureNode(e),t&&e){let{key:i,value:s}=e,r=this.createNode(i,s);return r&&(e.key=t.key,this._isMapMode||(e.value=t.value),t.key=r.key,this._isMapMode||(t.value=r.value)),e}}_replaceNode(t,e){return t.parent&&(t.parent.left===t?t.parent.left=e:t.parent.right===t&&(t.parent.right=e)),e.left=t.left,e.right=t.right,e.parent=t.parent,this._root===t&&this._setRoot(e),e}_setRoot(t){t&&(t.parent=void 0),this._root=t}_ensurePredicate(t){if(t==null)return e=>!1;if(this._isPredicate(t))return t;if(this.isRealNode(t))return e=>e===t;if(this.isEntry(t)){let[e]=t;return i=>i?i.key===e:!1}return e=>e?e.key===t:!1}_isPredicate(t){return typeof t=="function"}_extractKey(t){if(t===null)return null;if(t!==void 0&&t!==this._NIL)return this.isNode(t)?t.key:this.isEntry(t)?t[0]:t}_setValue(t,e){if(t==null)return!1;let i=this._store.get(t);return i?(i.value=e,!0):!1}_clearNodes(){this._setRoot(void 0),this._size=0}_clearValues(){this._store.clear()}};f(ce,"BinaryTree");var si=ce,_e=class{constructor(t,e){u(this,"key"),u(this,"value"),u(this,"parent"),u(this,"_left"),u(this,"_right"),u(this,"_height",0),u(this,"_color","BLACK"),u(this,"_count",1),this.key=t,this.value=e}get left(){return this._left}set left(t){t&&(t.parent=this),this._left=t}get right(){return this._right}set right(t){t&&(t.parent=this),this._right=t}get height(){return this._height}set height(t){this._height=t}get color(){return this._color}set color(t){this._color=t}get count(){return this._count}set count(t){this._count=t}get familyPosition(){return this.parent?this.parent.left===this?this.left||this.right?"ROOT_LEFT":"LEFT":this.parent.right===this?this.left||this.right?"ROOT_RIGHT":"RIGHT":"MAL_NODE":this.left||this.right?"ROOT":"ISOLATED"}};f(_e,"BSTNode");var Nt=_e,de=class extends si{constructor(t=[],e){super([],e),u(this,"_root"),u(this,"_comparator"),e?"comparator"in e&&e.comparator!==void 0?this._comparator=e.comparator:this._comparator=this._createDefaultComparator():this._comparator=this._createDefaultComparator(),t&&this.setMany(t)}get root(){return this._root}get comparator(){return this._comparator}createNode(t,e){return new Nt(t,e)}ensureNode(t,e=this.iterationType){var i;return(i=super.ensureNode(t,e))!=null?i:void 0}isNode(t){return t instanceof Nt}isValidKey(t){return X(t)}dfs(t=this._DEFAULT_NODE_CALLBACK,e="IN",i=!1,s=this._root,r=this.iterationType){return super.dfs(t,e,i,s,r)}bfs(t=this._DEFAULT_NODE_CALLBACK,e=this._root,i=this.iterationType){return super.bfs(t,e,i,!1)}listLevels(t=this._DEFAULT_NODE_CALLBACK,e=this._root,i=this.iterationType){return super.listLevels(t,e,i,!1)}getNode(t,e=this._root,i=this.iterationType){var s,r;if(t==null)return;if(this._isPredicate(t))return(s=this.getNodes(t,!0,e,i)[0])!=null?s:void 0;if(t instanceof $)return(r=this.getNodes(t,!0,e,i)[0])!=null?r:void 0;let n;if(this.isNode(t))n=t.key;else if(this.isEntry(t)){let _=t[0];if(_==null)return;n=_}else n=t;let h=this.ensureNode(e);if(!h)return;let o=this._NIL,l=h,a=this._comparator;for(;l&&l!==o;){let _=a(n,l.key);if(_===0)return l;l=_<0?l._left:l._right}}search(t,e=!1,i=this._DEFAULT_NODE_CALLBACK,s=this._root,r=this.iterationType){if(t===void 0)return[];if(t===null)return[];if(s=this.ensureNode(s),!s)return[];let n=this.isRange(t),h=!n&&this._isPredicate(t);if(!n&&!h){let _;if(this.isNode(t))_=t.key;else if(this.isEntry(t)){let x=t[0];x!=null&&(_=x)}else _=t;if(_===void 0)return[];let g=this._NIL,p=this._comparator,m=s;for(;m&&m!==g;){let x=p(_,m.key);if(x===0)return[i(m)];m=x<0?m._left:m._right}return[]}let o;n?o=f(_=>_?t.isInRange(_.key,this._comparator):!1,"predicate"):o=this._ensurePredicate(t);let l=f(_=>{if(!_||!this.isRealNode(_.left))return!1;if(n){let g=t,p=g.low,m=g.includeLow;return m&&this._compare(_.key,p)>=0||!m&&this._compare(_.key,p)>0}if(!n&&!this._isPredicate(t)){let g=this._extractKey(t);return g!=null&&this._compare(_.key,g)>0}return!0},"shouldVisitLeft"),a=f(_=>{if(!_||!this.isRealNode(_.right))return!1;if(n){let g=t,p=g.high,m=g.includeHigh;return m&&this._compare(_.key,p)<=0||!m&&this._compare(_.key,p)<0}if(!n&&!this._isPredicate(t)){let g=this._extractKey(t);return g!=null&&this._compare(_.key,g)<0}return!0},"shouldVisitRight");return super._dfs(i,"IN",e,s,r,!1,l,a,()=>!0,_=>!!_&&o(_))}rangeSearch(t,e=this._DEFAULT_NODE_CALLBACK,i=this._root,s=this.iterationType){let r=t instanceof $?t:new $(t[0],t[1]);return this.search(r,!1,e,i,s)}set(t,e){let[i]=this._keyValueNodeOrEntryToNodeAndValue(t,e);if(i===void 0)return!1;if(this._root===void 0)return this._setRoot(i),this._isMapMode&&this.isRealNode(i)&&this._store.set(i.key,i),this._size++,!0;let s=this._root;for(;s!==void 0;){if(this._compare(s.key,i.key)===0)return this._replaceNode(s,i),this._isMapMode&&this.isRealNode(i)&&this._store.set(s.key,i),!0;if(this._compare(s.key,i.key)>0){if(s.left===void 0)return s.left=i,this._isMapMode&&this.isRealNode(i)&&this._store.set(i.key,i),this._size++,!0;s.left!==null&&(s=s.left)}else{if(s.right===void 0)return s.right=i,this._isMapMode&&this.isRealNode(i)&&this._store.set(i.key,i),this._size++,!0;s.right!==null&&(s=s.right)}}return!1}setMany(t,e,i=!0,s=this.iterationType){let r=[],n=e==null?void 0:e[Symbol.iterator]();if(!i){for(let g of t){let p=n==null?void 0:n.next().value;this.isRaw(g)&&(g=this._toEntryFn(g)),r.push(this.set(g,p))}return r}let h=[],o=0;for(let g of t)h.push({key:g,value:n==null?void 0:n.next().value,orgIndex:o++});let l=h.sort(({key:g},{key:p})=>{let m,x;return this.isRaw(g)?m=this._toEntryFn(g)[0]:this.isEntry(g)?m=g[0]:this.isRealNode(g)?m=g.key:m=g,this.isRaw(p)?x=this._toEntryFn(p)[0]:this.isEntry(p)?x=p[0]:this.isRealNode(p)?x=p.key:x=p,m!=null&&x!=null?this._compare(m,x):0}),a=f(g=>{if(g.length===0)return;let p=Math.floor((g.length-1)/2),{key:m,value:x,orgIndex:b}=g[p];if(this.isRaw(m)){let w=this._toEntryFn(m);r[b]=this.set(w)}else r[b]=this.set(m,x);a(g.slice(0,p)),a(g.slice(p+1))},"_dfs");return s==="RECURSIVE"?a(l):f(()=>{let p=[[0,l.length-1]];for(;p.length>0;){let m=p.pop();if(!m)continue;let[x,b]=m;if(x>b)continue;let w=x+Math.floor((b-x)/2),{key:M,value:k,orgIndex:v}=l[w];if(this.isRaw(M)){let y=this._toEntryFn(M);r[v]=this.set(y)}else r[v]=this.set(M,k);p.push([w+1,b]),p.push([x,w-1])}},"_iterate")(),r}ceiling(t,e=this._DEFAULT_NODE_CALLBACK,i){let s,r=this.iterationType;typeof e=="string"?r=e:e&&(s=e,i&&(r=i));let n=this._bound(t,!0,r);return s?n?s(n):void 0:n==null?void 0:n.key}higher(t,e=this._DEFAULT_NODE_CALLBACK,i){let s,r=this.iterationType;typeof e=="string"?r=e:e&&(s=e,i&&(r=i));let n=this._bound(t,!1,r);return s?n?s(n):void 0:n==null?void 0:n.key}floor(t,e=this._DEFAULT_NODE_CALLBACK,i){if(t==null)return void 0;let s,r=this.iterationType;if(typeof e=="string"?r=e:e&&(s=e,i&&(r=i)),this._isPredicate(t)){let h=this._floorByPredicate(t,r);return s?h?s(h):void 0:h==null?void 0:h.key}let n;if(this.isNode(t))n=t.key;else if(this.isEntry(t)){let h=t[0];if(h==null)return void 0;n=h}else n=t;if(n!==void 0){let h=this._floorByKey(n,r);return s?h?s(h):void 0:h==null?void 0:h.key}}lower(t,e,i){if(t==null)return void 0;let s,r=this.iterationType;if(typeof e=="string"?r=e:e&&(s=e,i&&(r=i)),this._isPredicate(t)){let h=this._lowerByPredicate(t,r);return s?h?s(h):void 0:h==null?void 0:h.key}let n;if(this.isNode(t))n=t.key;else if(this.isEntry(t)){let h=t[0];if(h==null)return void 0;n=h}else n=t;if(n!==void 0){let h=this._lowerByKey(n,r);return s?h?s(h):void 0:h==null?void 0:h.key}}lesserOrGreaterTraverse(t=this._DEFAULT_NODE_CALLBACK,e=-1,i=this._root,s=this.iterationType){let r=this.ensureNode(i),n=[];if(!this._root||!r)return n;let h=r.key;if(s==="RECURSIVE"){let o=f(l=>{let a=this._compare(l.key,h);Math.sign(a)==e&&n.push(t(l)),this.isRealNode(l.left)&&o(l.left),this.isRealNode(l.right)&&o(l.right)},"dfs");return o(this._root),n}else{let o=new H([this._root]);for(;o.length>0;){let l=o.shift();if(this.isRealNode(l)){let a=this._compare(l.key,h);Math.sign(a)==e&&n.push(t(l)),this.isRealNode(l.left)&&o.push(l.left),this.isRealNode(l.right)&&o.push(l.right)}}return n}}perfectlyBalance(t=this.iterationType){let e=this.dfs(n=>n,"IN",!1,this._root,t),i=e.length;if(this._clearNodes(),i===0)return!1;let s=f((n,h,o)=>{if(n>h)return;let l=n+(h-n>>1),a=e[l],_=s(n,l-1,a),g=s(l+1,h,a);return a.left=_,a.right=g,a.parent=o,a},"build"),r=s(0,i-1,void 0);return this._setRoot(r),this._size=i,!0}isAVLBalanced(t=this.iterationType){if(!this._root)return!0;let e=!0;if(t==="RECURSIVE"){let i=f(s=>{if(!s)return 0;let r=i(s.left),n=i(s.right);return Math.abs(r-n)>1&&(e=!1),Math.max(r,n)+1},"_height");i(this._root)}else{let i=[],s=this._root,r,n=new Map;for(;i.length>0||s;)if(s)i.push(s),s.left!==null&&(s=s.left);else if(s=i[i.length-1],!s.right||r===s.right){if(s=i.pop(),s){let h=s.left?n.get(s.left):-1,o=s.right?n.get(s.right):-1;if(Math.abs(h-o)>1)return!1;n.set(s,1+Math.max(h,o)),r=s,s=void 0}}else s=s.right}return e}map(t,e,i){let s=this._createLike([],e),r=0;for(let[n,h]of this)s.set(t.call(i,h,n,r++,this));return s}deleteWhere(t,e=!1,i=this._root,s=this.iterationType){let r=this.search(t,e,h=>h,i,s),n=[];for(let h of r){let o=this.delete(h);n=n.concat(o)}return n}_createDefaultComparator(){return(t,e)=>{if(X(t)&&X(e))return t>e?1:t<e?-1:0;if(typeof t=="object"||typeof e=="object")throw TypeError("When comparing object type keys, a custom comparator must be provided in the constructor's options!");return 0}}_floorByKey(t,e){var i,s;if(e==="RECURSIVE"){let r=f(n=>{if(!this.isRealNode(n))return;if(this.comparator(n.key,t)<=0){let o=r(n.right);return o!=null?o:n}else return r(n.left)},"dfs");return r(this.root)}else{let r=this.root,n;for(;this.isRealNode(r);)this.comparator(r.key,t)<=0?(n=r,r=(i=r.right)!=null?i:void 0):r=(s=r.left)!=null?s:void 0;return n}}_floorByPredicate(t,e){if(e==="RECURSIVE"){let i,s=f(r=>{this.isRealNode(r)&&(this.isRealNode(r.left)&&s(r.left),t(r)&&(i=r),this.isRealNode(r.right)&&s(r.right))},"dfs");return s(this.root),i}else{let i=[],s=this.root,r;for(;i.length>0||this.isRealNode(s);)if(this.isRealNode(s))i.push(s),s=s.left;else{let n=i.pop();if(!this.isRealNode(n))break;t(n)&&(r=n),s=n.right}return r}}_lowerByKey(t,e){var i,s;if(e==="RECURSIVE"){let r=f(n=>{if(!this.isRealNode(n))return;if(this.comparator(n.key,t)<0){let o=r(n.right);return o!=null?o:n}else return r(n.left)},"dfs");return r(this.root)}else{let r=this.root,n;for(;this.isRealNode(r);)this.comparator(r.key,t)<0?(n=r,r=(i=r.right)!=null?i:void 0):r=(s=r.left)!=null?s:void 0;return n}}_lowerByPredicate(t,e){if(e==="RECURSIVE"){let i,s=f(r=>{this.isRealNode(r)&&(this.isRealNode(r.left)&&s(r.left),t(r)&&(i=r),this.isRealNode(r.right)&&s(r.right))},"dfs");return s(this.root),i}else{let i=[],s=this.root,r;for(;i.length>0||this.isRealNode(s);)if(this.isRealNode(s))i.push(s),s=s.left;else{let n=i.pop();if(!this.isRealNode(n))break;t(n)&&(r=n),s=n.right}return r}}_bound(t,e,i){if(t==null)return;if(this._isPredicate(t))return this._boundByPredicate(t,i);let s;if(this.isNode(t))s=t.key;else if(this.isEntry(t)){let r=t[0];if(r==null)return;s=r}else s=t;if(s!==void 0)return this._boundByKey(s,e,i)}_boundByKey(t,e,i){var s,r;if(i==="RECURSIVE"){let n=f(h=>{if(!this.isRealNode(h))return;let o=this.comparator(h.key,t);if(e?o>=0:o>0){let a=n(h.left);return a!=null?a:h}else return n(h.right)},"dfs");return n(this.root)}else{let n=this.root,h;for(;this.isRealNode(n);){let o=this.comparator(n.key,t);(e?o>=0:o>0)?(h=n,n=(s=n.left)!=null?s:void 0):n=(r=n.right)!=null?r:void 0}return h}}_boundByPredicate(t,e){if(e==="RECURSIVE"){let i,s=f(r=>{i||!this.isRealNode(r)||(this.isRealNode(r.left)&&s(r.left),!i&&t(r)&&(i=r),!i&&this.isRealNode(r.right)&&s(r.right))},"dfs");return s(this.root),i}else{let i=[],s=this.root;for(;i.length>0||this.isRealNode(s);)if(this.isRealNode(s))i.push(s),s=s.left;else{let r=i.pop();if(!this.isRealNode(r))break;if(t(r))return r;s=r.right}return}}_createInstance(t){let e=this.constructor;return new e([],{...this._snapshotOptions(),...t!=null?t:{}})}_createLike(t=[],e){let i=this.constructor;return new i(t,{...this._snapshotOptions(),...e!=null?e:{}})}_snapshotOptions(){return{...super._snapshotOptions(),comparator:this._comparator}}_keyValueNodeOrEntryToNodeAndValue(t,e){let[i,s]=super._keyValueNodeOrEntryToNodeAndValue(t,e);return i===null?[void 0,void 0]:[i,e!=null?e:s]}_setRoot(t){t&&(t.parent=void 0),this._root=t}_compare(t,e){return this._comparator(t,e)}_deleteByKey(t){let e=this._root;for(;e;){let r=this._compare(e.key,t);if(r===0)break;e=r>0?e.left:e.right}if(!e)return!1;let i=f((r,n)=>{let h=r==null?void 0:r.parent;h?h.left===r?h.left=n:h.right=n:this._setRoot(n),n&&(n.parent=h)},"transplant"),s=f(r=>{if(r){for(;r.left!==void 0&&r.left!==null;)r=r.left;return r}},"minNode");if(e.left===void 0)i(e,e.right);else if(e.right===void 0)i(e,e.left);else{let r=s(e.right);r.parent!==e&&(i(r,r.right),r.right=e.right,r.right&&(r.right.parent=r)),i(e,r),r.left=e.left,r.left&&(r.left.parent=r)}return this._size=Math.max(0,this._size-1),!0}};f(de,"BST");var ge=de,ri=class{constructor({frequency:t=0,max:e}){u(this,"_freq"),u(this,"_max"),u(this,"_freqMap"),u(this,"_msb"),u(this,"_negativeCount"),this._freq=t,this._max=e,this._freqMap={0:0},this._msb=Be(e),this._negativeCount=t<0?e:0}get freqMap(){return this._freqMap}get msb(){return this._msb}get negativeCount(){return this._negativeCount}get freq(){return this._freq}get max(){return this._max}readSingle(t){return this._checkIndex(t),this._readSingle(t)}update(t,e){this._checkIndex(t);let i=this._readSingle(t);this._update(t,e),this._updateNegativeCount(i,i+e)}writeSingle(t,e){this._checkIndex(t),this._writeSingle(t,e)}read(t){if(!Number.isInteger(t))throw new Error("Invalid count");return this._read(Math.max(Math.min(t,this.max),0))}lowerBound(t){if(this.negativeCount>0)throw new Error("Sequence is not non-descending");return this._binarySearch(t,(e,i)=>e<i)}upperBound(t){if(this.negativeCount>0)throw new Error("Must not be descending");return this._binarySearch(t,(e,i)=>e<=i)}getPrefixSum(t){this._checkIndex(t),t++;let e=0;for(;t>0;)e+=this._getFrequency(t),t-=t&-t;return e}_getFrequency(t){return t in this.freqMap?this.freqMap[t]:this.freq*(t&-t)}_updateFrequency(t,e){this.freqMap[t]=this._getFrequency(t)+e}_checkIndex(t){if(!Number.isInteger(t))throw new Error("Invalid index: Index must be an integer.");if(t<0||t>=this.max)throw new Error("Index out of range: Index must be within the range [0, this.max).")}_readSingle(t){t=t+1;let e=this._getFrequency(t),i=t-(t&-t);for(t--;t!==i;)e-=this._getFrequency(t),t-=t&-t;return e}_updateNegativeCount(t,e){t<0&&e>=0?this._negativeCount--:t>=0&&e<0&&this._negativeCount++}_update(t,e){for(t=t+1;t<=this.max;)this._updateFrequency(t,e),t+=t&-t}_writeSingle(t,e){let i=this._readSingle(t);this._update(t,e-i),this._updateNegativeCount(i,e)}_read(t){let e=t,i=0;for(;e;)i+=this._getFrequency(e),e-=e&-e;return i}_binarySearch(t,e){let i=0,s=this.msb<<1,r=t;for(;s>i+1;){let n=i+s>>1,h=this._getFrequency(n);n<=this.max&&e(h,r)?(r-=h,i=n):s=n}return i}};f(ri,"BinaryIndexedTree");var pe=class{constructor(t,e,i,s){u(this,"_start",0),u(this,"_end",0),u(this,"_value"),u(this,"_sum",0),u(this,"_left"),u(this,"_right"),this._start=t,this._end=e,this._sum=i,this._value=s||void 0}get start(){return this._start}set start(t){this._start=t}get end(){return this._end}set end(t){this._end=t}get value(){return this._value}set value(t){this._value=t}get sum(){return this._sum}set sum(t){this._sum=t}get left(){return this._left}set left(t){this._left=t}get right(){return this._right}set right(t){this._right=t}};f(pe,"SegmentTreeNode");var ft=pe,ni=class{constructor(t,e,i){u(this,"_values",[]),u(this,"_start",0),u(this,"_end"),u(this,"_root"),e=e||0,i=i||t.length-1,this._values=t,this._start=e,this._end=i,t.length>0?this._root=this.build(e,i):(this._root=void 0,this._values=[])}get values(){return this._values}get start(){return this._start}get end(){return this._end}get root(){return this._root}build(t,e){if(t>e)return new ft(t,e,0);if(t===e)return new ft(t,e,this._values[t]);let i=t+Math.floor((e-t)/2),s=this.build(t,i),r=this.build(i+1,e),n=new ft(t,e,s.sum+r.sum);return n.left=s,n.right=r,n}updateNode(t,e,i){let s=this.root||void 0;if(!s)return;let r=f((n,h,o,l)=>{if(n.start===n.end&&n.start===h){n.sum=o,l!==void 0&&(n.value=l);return}let a=n.start+Math.floor((n.end-n.start)/2);h<=a?n.left&&r(n.left,h,o,l):n.right&&r(n.right,h,o,l),n.left&&n.right&&(n.sum=n.left.sum+n.right.sum)},"dfs");r(s,t,e,i)}querySumByRange(t,e){let i=this.root||void 0;if(!i)return 0;if(t<0||e>=this.values.length||t>e)return NaN;let s=f((r,n,h)=>{if(n<=r.start&&h>=r.end)return r.sum;let o=r.start+Math.floor((r.end-r.start)/2);if(h<=o)return r.left?s(r.left,n,h):NaN;if(n>o)return r.right?s(r.right,n,h):NaN;{let l=0,a=0;return r.left&&(l=s(r.left,n,o)),r.right&&(a=s(r.right,o+1,h)),l+a}},"dfs");return s(i,t,e)}};f(ni,"SegmentTree");var ve=class{constructor(t,e){u(this,"key"),u(this,"value"),u(this,"parent"),u(this,"_left"),u(this,"_right"),u(this,"_height",0),u(this,"_color","BLACK"),u(this,"_count",1),this.key=t,this.value=e}get left(){return this._left}set left(t){t&&(t.parent=this),this._left=t}get right(){return this._right}set right(t){t&&(t.parent=this),this._right=t}get height(){return this._height}set height(t){this._height=t}get color(){return this._color}set color(t){this._color=t}get count(){return this._count}set count(t){this._count=t}get familyPosition(){return this.parent?this.parent.left===this?this.left||this.right?"ROOT_LEFT":"LEFT":this.parent.right===this?this.left||this.right?"ROOT_RIGHT":"RIGHT":"MAL_NODE":this.left||this.right?"ROOT":"ISOLATED"}};f(ve,"AVLTreeNode");var Et=ve,hi=class extends ge{constructor(t=[],e){super([],e),t&&super.setMany(t)}createNode(t,e){return new Et(t,e)}isNode(t){return t instanceof Et}set(t,e){if(t===null)return!1;let i=super.set(t,e);return i&&this._balancePath(t),i}delete(t){let e=super.delete(t);for(let{needBalanced:i}of e)i&&this._balancePath(i);return e}perfectlyBalance(t=this.iterationType){let e=this.dfs(n=>n,"IN",!1,this._root,t),i=e.length;if(i===0)return!1;this._clearNodes();let s=f((n,h,o)=>{if(n>h)return;let l=n+(h-n>>1),a=e[l];a.left=s(n,l-1,a),a.right=s(l+1,h,a),a.parent=o;let _=a.left?a.left.height:-1,g=a.right?a.right.height:-1;return a.height=Math.max(_,g)+1,a},"build"),r=s(0,i-1,void 0);return this._setRoot(r),this._size=i,!0}map(t,e,i){let s=this._createLike([],e),r=0;for(let[n,h]of this)s.set(t.call(i,h,n,r++,this));return s}_createInstance(t){let e=this.constructor;return new e([],{...this._snapshotOptions(),...t!=null?t:{}})}_createLike(t=[],e){let i=this.constructor;return new i(t,{...this._snapshotOptions(),...e!=null?e:{}})}_swapProperties(t,e){let i=this.ensureNode(t),s=this.ensureNode(e);if(i&&s){let{key:r,value:n,height:h}=s,o=this.createNode(r,n);return o&&(o.height=h,s.key=i.key,this._isMapMode||(s.value=i.value),s.height=i.height,i.key=o.key,this._isMapMode||(i.value=o.value),i.height=o.height),s}}_balanceFactor(t){let e=t.left?t.left.height:-1;return(t.right?t.right.height:-1)-e}_updateHeight(t){let e=t.left?t.left.height:-1,i=t.right?t.right.height:-1;t.height=1+Math.max(e,i)}_balanceLL(t){let e=t.parent,i=t.left;i!==null&&(t.parent=i),i&&i.right&&(i.right.parent=t),i&&(i.parent=e),t===this.root?i&&this._setRoot(i):(e==null?void 0:e.left)===t?e.left=i:e&&(e.right=i),i&&(t.left=i.right,i.right=t),this._updateHeight(t),i&&this._updateHeight(i)}_balanceLR(t){let e=t.parent,i=t.left,s;i&&(s=i.right),t&&s!==null&&(t.parent=s),i&&s!==null&&(i.parent=s),s&&(s.left&&i!==null&&(s.left.parent=i),s.right&&(s.right.parent=t),s.parent=e),t===this.root?s&&this._setRoot(s):e&&(e.left===t?e.left=s:e.right=s),s&&(t.left=s.right,i&&(i.right=s.left),s.left=i,s.right=t),this._updateHeight(t),i&&this._updateHeight(i),s&&this._updateHeight(s)}_balanceRR(t){let e=t.parent,i=t.right;i!==null&&(t.parent=i),i&&(i.left&&(i.left.parent=t),i.parent=e),t===this.root?i&&this._setRoot(i):e&&(e.left===t?e.left=i:e.right=i),i&&(t.right=i.left,i.left=t),this._updateHeight(t),i&&this._updateHeight(i)}_balanceRL(t){let e=t.parent,i=t.right,s;i&&(s=i.left),s!==null&&(t.parent=s),i&&s!==null&&(i.parent=s),s&&(s.left&&(s.left.parent=t),s.right&&i!==null&&(s.right.parent=i),s.parent=e),t===this.root?s&&this._setRoot(s):e&&(e.left===t?e.left=s:e.right=s),s&&(t.right=s.left),i&&s&&(i.left=s.right),s&&(s.left=t),s&&(s.right=i),this._updateHeight(t),i&&this._updateHeight(i),s&&this._updateHeight(s)}_balancePath(t){t=this.ensureNode(t);let e=this.getPathToRoot(t,i=>i,!1);for(let i=0;i<e.length;i++){let s=e[i];if(s)switch(this._updateHeight(s),this._balanceFactor(s)){case-2:s&&s.left&&(this._balanceFactor(s.left)<=0?this._balanceLL(s):this._balanceLR(s));break;case 2:s&&s.right&&(this._balanceFactor(s.right)>=0?this._balanceRR(s):this._balanceRL(s))}}}_replaceNode(t,e){return e.height=t.height,super._replaceNode(t,e)}};f(hi,"AVLTree");var me=class{constructor(t,e,i="BLACK"){u(this,"key"),u(this,"value"),u(this,"parent"),u(this,"_left"),u(this,"_right"),u(this,"_height",0),u(this,"_color","BLACK"),u(this,"_count",1),this.key=t,this.value=e,this.color=i}get left(){return this._left}set left(t){t&&(t.parent=this),this._left=t}get right(){return this._right}set right(t){t&&(t.parent=this),this._right=t}get height(){return this._height}set height(t){this._height=t}get color(){return this._color}set color(t){this._color=t}get count(){return this._count}set count(t){this._count=t}get familyPosition(){return this.parent?this.parent.left===this?this.left||this.right?"ROOT_LEFT":"LEFT":this.parent.right===this?this.left||this.right?"ROOT_RIGHT":"RIGHT":"MAL_NODE":this.left||this.right?"ROOT":"ISOLATED"}};f(me,"RedBlackTreeNode");var J=me,Me=class extends ge{constructor(t=[],e){super([],e),u(this,"_root"),u(this,"_header"),u(this,"_minNode"),u(this,"_maxNode"),this._root=this.NIL,this._header=new J(void 0,void 0,"BLACK"),this._header.parent=this.NIL,this._header._left=this.NIL,this._header._right=this.NIL,t&&this.setMany(t)}get root(){return this._root}createNode(t,e,i="BLACK"){return new J(t,e,i)}isNode(t){return t instanceof J}clear(){super.clear(),this._root=this.NIL,this._header.parent=this.NIL,this._setMinCache(void 0),this._setMaxCache(void 0)}_findNodeByKey(t){var e,i,s;let r=this.NIL,n=this._compare.bind(this),h=(e=this._header.parent)!=null?e:r;for(;h!==r;){let o=n(t,h.key);if(o<0)h=(i=h.left)!=null?i:r;else if(o>0)h=(s=h.right)!=null?s:r;else return h}}_predecessorOf(t){let e=this.NIL;if(t.left&&t.left!==e){let r=t.left;for(;r.right&&r.right!==e;)r=r.right;return r}let i=t,s=t.parent;for(;s&&i===s.left;)i=s,s=s.parent;return s}_successorOf(t){let e=this.NIL;if(t.right&&t.right!==e){let r=t.right;for(;r.left&&r.left!==e;)r=r.left;return r}let i=t,s=t.parent;for(;s&&i===s.right;)i=s,s=s.parent;return s}_attachNewNode(t,e,i){let s=this.NIL;i.parent=t,e==="left"?t.left=i:t.right=i,i.left=s,i.right=s,i.color="RED",this._insertFixup(i),this.isRealNode(this._root)&&(this._root.color="BLACK")}_setMinCache(t){this._minNode=t,this._header._left=t!=null?t:this.NIL}_setMaxCache(t){this._maxNode=t,this._header._right=t!=null?t:this.NIL}_setKVNode(t,e){var i,s,r,n,h,o,l;let a=this.NIL,_=this._comparator,g=this._header,p=(i=g._left)!=null?i:a;if(p!==a){let E=_(t,p.key);if(E===0)return p.value=e,this._isMapMode&&this._store.set(t,p),{node:p,created:!1};let T=p.left;if(E<0&&(T===a||T===null||T===void 0)){let C=this.createNode(t,e);return this._attachNewNode(p,"left",C),this._isMapMode&&this._store.set(C.key,C),this._size++,this._setMinCache(C),g._right===a&&this._setMaxCache(C),{node:C,created:!0}}if(E>0){let C=(s=g._right)!=null?s:a,wt=_(t,C.key);if(wt===0)return C.value=e,this._isMapMode&&this._store.set(t,C),{node:C,created:!1};let lt=C.right;if(wt>0&&(lt===a||lt===null||lt===void 0)){let D=this.createNode(t,e);return this._attachNewNode(C,"right",D),this._isMapMode&&this._store.set(D.key,D),this._size++,this._setMaxCache(D),g._left===a&&this._setMinCache(D),{node:D,created:!0}}}}let m=_,x=this._isMapMode,b=this._store,w=(r=this._header.parent)!=null?r:a,M,k=0;for(;w!==a;)if(M=w,k=m(t,w.key),k<0)w=(n=w.left)!=null?n:a;else if(k>0)w=(h=w.right)!=null?h:a;else return w.value=e,x&&b.set(t,w),{node:w,created:!1};let v=this.createNode(t,e);if(v.parent=M,M?k<0?M.left=v:M.right=v:this._setRoot(v),v.left=a,v.right=a,v.color="RED",this._insertFixup(v),this.isRealNode(this._root))this._root.color="BLACK";else return;x&&b.set(v.key,v),this._size++;let y=(o=this._header._left)!=null?o:a,N=(l=this._header._right)!=null?l:a;return y===a||N===a?(this._setMinCache(v),this._setMaxCache(v)):M===N&&k>0?this._setMaxCache(v):M===y&&k<0?this._setMinCache(v):(m(v.key,y.key)<0&&this._setMinCache(v),m(v.key,N.key)>0&&this._setMaxCache(v)),{node:v,created:!0}}_setKV(t,e){if(this._isMapMode){let s=this._store.get(t);if(s)return s.value=e,!0}return this._setKVNode(t,e)!==void 0}setWithHintNode(t,e,i){var s,r,n,h,o,l,a,_,g,p,m,x,b;if(!i||!this.isRealNode(i))return(s=this._setKVNode(t,e))==null?void 0:s.node;let w=this._compare.bind(this),M=w(t,i.key);if(M===0)return i.value=e,this._isMapMode&&this._store.set(t,i),i;if(M<0){if(!this.isRealNode(i.left)){let y=this.createNode(t,e);if(!this.isRealNode(y))return;this._attachNewNode(i,"left",y),this._isMapMode&&this._store.set(t,y),this._size++;let N=this.NIL,E=(r=this._header._left)!=null?r:N;(E===N||this._compare(y.key,E.key)<0)&&this._setMinCache(y);let T=(n=this._header._right)!=null?n:N;return(T===N||this._compare(y.key,T.key)>0)&&this._setMaxCache(y),y}let v=this._predecessorOf(i);if(v&&w(v.key,t)>=0)return(h=this._setKVNode(t,e))==null?void 0:h.node;if(v&&!this.isRealNode(v.right)){let y=this.createNode(t,e);if(!this.isRealNode(y))return;this._attachNewNode(v,"right",y),this._isMapMode&&this._store.set(t,y),this._size++;let N=this.NIL,E=(o=this._header._left)!=null?o:N;(E===N||this._compare(y.key,E.key)<0)&&this._setMinCache(y);let T=(l=this._header._right)!=null?l:N;return(T===N||this._compare(y.key,T.key)>0)&&this._setMaxCache(y),y}return(a=this._setKVNode(t,e))==null?void 0:a.node}if(!this.isRealNode(i.right)){let v=this.createNode(t,e);if(!this.isRealNode(v))return;this._attachNewNode(i,"right",v),this._isMapMode&&this._store.set(t,v),this._size++;let y=this.NIL,N=(_=this._header._left)!=null?_:y;(N===y||this._compare(v.key,N.key)<0)&&this._setMinCache(v);let E=(g=this._header._right)!=null?g:y;return(E===y||this._compare(v.key,E.key)>0)&&this._setMaxCache(v),v}let k=this._successorOf(i);if(k&&w(k.key,t)<=0)return(p=this._setKVNode(t,e))==null?void 0:p.node;if(k&&!this.isRealNode(k.left)){let v=this.createNode(t,e);if(!this.isRealNode(v))return;this._attachNewNode(k,"left",v),this._isMapMode&&this._store.set(t,v),this._size++;let y=this.NIL,N=(m=this._header._left)!=null?m:y;(N===y||this._compare(v.key,N.key)<0)&&this._setMinCache(v);let E=(x=this._header._right)!=null?x:y;return(E===y||this._compare(v.key,E.key)>0)&&this._setMaxCache(v),v}return(b=this._setKVNode(t,e))==null?void 0:b.node}setWithHint(t,e,i){return this.setWithHintNode(t,e,i)!==void 0}set(t,e){if(!this.isNode(t)){if(t==null)return!1;if(this.isEntry(t)){let n=t[0];if(n==null)return!1;let h=e!=null?e:t[1];return this._setKV(n,h)}return this._setKV(t,e)}let[i,s]=this._keyValueNodeOrEntryToNodeAndValue(t,e);if(!this.isRealNode(i))return!1;let r=this._insert(i);if(r==="CREATED"){if(this.isRealNode(this._root))this._root.color="BLACK";else return!1;if(this._isMapMode){let n=this.getNode(i.key);this.isRealNode(n)&&(n.value=s,this._store.set(n.key,n))}return this._size++,!0}if(r==="UPDATED"){if(this._isMapMode){let n=this.getNode(i.key);this.isRealNode(n)&&(n.value=s,this._store.set(n.key,n))}return!0}return!1}delete(t){if(t===null)return[];let e=[],i;if(this._isPredicate(t)?i=this.getNode(t):i=this.isRealNode(t)?t:this.getNode(t),!i)return e;let s=i===this._minNode,r=i===this._maxNode,n=s?this._successorOf(i):void 0,h=r?this._predecessorOf(i):void 0,o=i.color,l;if(!this.isRealNode(i.left))i.right!==null&&(l=i.right,this._transplant(i,i.right));else if(!this.isRealNode(i.right))l=i.left,this._transplant(i,i.left);else{let a=this.getLeftMost(_=>_,i.right);a&&(o=a.color,a.right!==null&&(l=a.right),a.parent===i?this.isRealNode(l)&&(l.parent=a):(a.right!==null&&(this._transplant(a,a.right),a.right=i.right),this.isRealNode(a.right)&&(a.right.parent=a)),this._transplant(i,a),a.left=i.left,this.isRealNode(a.left)&&(a.left.parent=a),a.color=i.color)}return this._isMapMode&&this._store.delete(i.key),this._size--,this._size<=0?(this._setMinCache(void 0),this._setMaxCache(void 0)):(s&&this._setMinCache(n),r&&this._setMaxCache(h),(!this._minNode||!this.isRealNode(this._minNode))&&this._setMinCache(this.isRealNode(this._root)?this.getLeftMost(a=>a,this._root):void 0),(!this._maxNode||!this.isRealNode(this._maxNode))&&this._setMaxCache(this.isRealNode(this._root)?this.getRightMost(a=>a,this._root):void 0)),o==="BLACK"&&this._deleteFixup(l),e.push({deleted:i,needBalanced:void 0}),e}map(t,e,i){let s=this._createLike([],e),r=0;for(let[n,h]of this)s.set(t.call(i,h,n,r++,this));return s}_createInstance(t){let e=this.constructor;return new e([],{...this._snapshotOptions(),...t!=null?t:{}})}_createLike(t=[],e){let i=this.constructor;return new i(t,{...this._snapshotOptions(),...e!=null?e:{}})}_setRoot(t){let e=this.NIL;t&&(t.parent=void 0),this._root=t,this._header.parent=t!=null?t:e}_replaceNode(t,e){return e.color=t.color,super._replaceNode(t,e)}_insert(t){var e,i,s;let r=this.NIL,n=this._compare.bind(this),h=(e=this._header.parent)!=null?e:r,o,l=0;for(;h!==r;)if(o=h,l=n(t.key,h.key),l<0)h=(i=h.left)!=null?i:r;else if(l>0)h=(s=h.right)!=null?s:r;else return this._replaceNode(h,t),"UPDATED";return t.parent=o,o?l<0?o.left=t:o.right=t:this._setRoot(t),t.left=r,t.right=r,t.color="RED",this._insertFixup(t),"CREATED"}_transplant(t,e){t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._setRoot(e),e&&(e.parent=t.parent)}_insertFixup(t){let e=this._leftRotate.bind(this),i=this._rightRotate.bind(this);for(;t;){let s=t.parent;if(!s||s.color!=="RED")break;let r=s.parent;if(!r)break;if(s===r.left){let n=r.right;if((n==null?void 0:n.color)==="RED"){s.color="BLACK",n.color="BLACK",r.color="RED",t=r;continue}t===s.right&&(t=s,e(t));let h=t==null?void 0:t.parent,o=h==null?void 0:h.parent;h&&o&&(h.color="BLACK",o.color="RED",i(o))}else{let n=r.left;if((n==null?void 0:n.color)==="RED"){s.color="BLACK",n.color="BLACK",r.color="RED",t=r;continue}t===s.left&&(t=s,i(t));let h=t==null?void 0:t.parent,o=h==null?void 0:h.parent;h&&o&&(h.color="BLACK",o.color="RED",e(o))}break}this.isRealNode(this._root)&&(this._root.color="BLACK")}_deleteFixup(t){var e,i,s,r;if(!t||t===this.root||t.color==="BLACK"){t&&(t.color="BLACK");return}for(;t&&t!==this.root&&t.color==="BLACK";){let n=t.parent;if(!n)break;if(t===n.left){let h=n.right;(h==null?void 0:h.color)==="RED"&&(h.color="BLACK",n.color="RED",this._leftRotate(n),h=n.right),((i=(e=h==null?void 0:h.left)==null?void 0:e.color)!=null?i:"BLACK")==="BLACK"?(h&&(h.color="RED"),t=n):(h!=null&&h.left&&(h.left.color="BLACK"),h&&(h.color=n.color),n.color="BLACK",this._rightRotate(n),t=this.root)}else{let h=n.left;(h==null?void 0:h.color)==="RED"&&(h.color="BLACK",n&&(n.color="RED"),this._rightRotate(n),n&&(h=n.left)),((r=(s=h==null?void 0:h.right)==null?void 0:s.color)!=null?r:"BLACK")==="BLACK"?(h&&(h.color="RED"),t=n):(h!=null&&h.right&&(h.right.color="BLACK"),h&&(h.color=n.color),n&&(n.color="BLACK"),this._leftRotate(n),t=this.root)}}t&&(t.color="BLACK")}_leftRotate(t){if(!t||!t.right)return;let e=t.right;t.right=e.left,e.left&&e.left!==this.NIL&&(e.left.parent=t),e.parent=t.parent,t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._setRoot(e),e.left=t,t.parent=e}_rightRotate(t){if(!t||!t.left)return;let e=t.left;t.left=e.right,e.right&&e.right!==this.NIL&&(e.right.parent=t),e.parent=t.parent,t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._setRoot(e),e.right=t,t.parent=e}};f(Me,"RedBlackTree");var ht=Me,I,U,G,we=class W{constructor(t=[],e={}){A(this,I),A(this,U),A(this,G);var i;B(this,G,e.comparator);let s=e.toElementFn,r=(i=e.comparator)!=null?i:W.createDefaultComparator();B(this,U,e.comparator===void 0),B(this,I,new ht([],{comparator:r,isMapMode:e.isMapMode}));for(let n of t){let h=s?s(n):n;this.add(h)}}static createDefaultComparator(){return(t,e)=>{if(typeof t=="number"&&typeof e=="number"){if(Number.isNaN(t)||Number.isNaN(e))throw new TypeError("TreeSet: NaN is not a valid key");let i=Object.is(t,-0)?0:t,s=Object.is(e,-0)?0:e;return i>s?1:i<s?-1:0}if(typeof t=="string"&&typeof e=="string")return t>e?1:t<e?-1:0;if(t instanceof Date&&e instanceof Date){let i=t.getTime(),s=e.getTime();if(Number.isNaN(i)||Number.isNaN(s))throw new TypeError("TreeSet: invalid Date key");return i>s?1:i<s?-1:0}throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys")}}get size(){return d(this,I).size}isEmpty(){return this.size===0}_validateKey(t){if(d(this,U)){if(typeof t=="number"){if(Number.isNaN(t))throw new TypeError("TreeSet: NaN is not a valid key");return}if(typeof t!="string"){if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new TypeError("TreeSet: invalid Date key");return}throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys")}}}add(t){return this._validateKey(t),d(this,I).set(t,void 0),this}has(t){return this._validateKey(t),d(this,I).has(t)}delete(t){var e;this._validateKey(t);let i=d(this,I).delete(t);return Array.isArray(i)&&i.length>0&&!!((e=i[0])!=null&&e.deleted)}clear(){d(this,I).clear()}keys(){return d(this,I).keys()}values(){return this.keys()}*entries(){for(let t of this.keys())yield[t,t]}[Symbol.iterator](){return this.keys()}forEach(t,e){for(let i of this)t.call(e,i,i,this)}map(t,e={},i){let s=new W([],e),r=0;for(let n of this){let h=i===void 0?t(n,r++,this):t.call(i,n,r++,this);s.add(h)}return s}filter(t,e){let i=new W([],{comparator:d(this,G)}),s=0;for(let r of this)(e===void 0?t(r,s++,this):t.call(e,r,s++,this))&&i.add(r);return i}reduce(t,e){let i=e,s=0;for(let r of this)i=t(i,r,s++,this);return i}every(t,e){let i=0;for(let s of this)if(!(e===void 0?t(s,i++,this):t.call(e,s,i++,this)))return!1;return!0}some(t,e){let i=0;for(let s of this)if(e===void 0?t(s,i++,this):t.call(e,s,i++,this))return!0;return!1}find(t,e){let i=0;for(let s of this)if(e===void 0?t(s,i++,this):t.call(e,s,i++,this))return s}toArray(){return[...this]}print(){d(this,I).print()}first(){return d(this,I).getLeftMost()}last(){return d(this,I).getRightMost()}pollFirst(){let t=this.first();if(t!==void 0)return this.delete(t),t}pollLast(){let t=this.last();if(t!==void 0)return this.delete(t),t}ceiling(t){return this._validateKey(t),d(this,I).ceiling(t)}floor(t){return this._validateKey(t),d(this,I).floor(t)}higher(t){return this._validateKey(t),d(this,I).higher(t)}lower(t){return this._validateKey(t),d(this,I).lower(t)}rangeSearch(t,e={}){let{lowInclusive:i=!0,highInclusive:s=!0}=e,[r,n]=t;this._validateKey(r),this._validateKey(n);let h=d(this,I).rangeSearch([r,n]),o=[],l=d(this,I).comparator;for(let a of h)a!==void 0&&(!i&&l(a,r)===0||!s&&l(a,n)===0||o.push(a));return o}clone(){return new W(this,{comparator:d(this,U)?void 0:d(this,G),isMapMode:d(this,I).isMapMode})}};I=new WeakMap;U=new WeakMap;G=new WeakMap;f(we,"TreeSet");var ot=we,oi=class extends J{constructor(t,e=[]){super(t,e)}};f(oi,"TreeMultiMapNode");var L,Y,li=class Z{constructor(t=[],e={}){A(this,L),A(this,Y);var i;let s=(i=e.comparator)!=null?i:ot.createDefaultComparator();B(this,Y,e.comparator===void 0);let r=e.toEntryFn;B(this,L,new ht([],{...e,comparator:s,isMapMode:e.isMapMode}));for(let n of t)if(n!=null){if(r){let[h,o]=r(n);if(h==null)continue;o!==void 0?d(this,L).set(h,Array.isArray(o)?[...o]:[o]):d(this,L).set(h,[]);continue}if(Array.isArray(n)){let[h,o]=n;if(h==null)continue;o!==void 0?d(this,L).set(h,[...o]):d(this,L).set(h,[]);continue}d(this,L).set(n,[])}}_validateKey(t){if(d(this,Y)){if(typeof t=="number"){if(Number.isNaN(t))throw new TypeError("TreeMultiMap: NaN is not a valid key");return}if(typeof t!="string"){if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new TypeError("TreeMultiMap: invalid Date key");return}throw new TypeError("TreeMultiMap: comparator is required for non-number/non-string/non-Date keys")}}}get size(){return d(this,L).size}isEmpty(){return this.size===0}clear(){d(this,L).clear()}count(t){let e=this.get(t);return Array.isArray(e)?e.length:0}get totalSize(){let t=0;for(let[,e]of this)t+=e.length;return t}has(t){return this._validateKey(t),d(this,L).has(t)}get(t){return this._validateKey(t),d(this,L).get(t)}add(t,e){this._validateKey(t);let i=d(this,L).get(t);return i?(i.push(e),!0):d(this,L).set(t,[e])}set(t,e){if(t==null)return!1;if(Array.isArray(t)){let[i,s]=t;if(i==null)return!1;if(e!==void 0)return this.add(i,e);if(s===void 0)return d(this,L).set(i,[]);let r=d(this,L).get(i);return r?(r.push(...s),!0):d(this,L).set(i,[...s])}return e!==void 0?this.add(t,e):d(this,L).set(t,[])}delete(t){return this._validateKey(t),d(this,L).delete(t).length>0}hasEntry(t,e,i=Object.is){let s=this.get(t);return Array.isArray(s)?s.some(r=>i(r,e)):!1}deleteValue(t,e,i=Object.is){let s=this.get(t);if(!Array.isArray(s))return!1;let r=s.findIndex(n=>i(n,e));return r===-1?!1:(s.splice(r,1),s.length===0&&this.delete(t),!0)}deleteValues(t,e,i=Object.is){let s=this.get(t);if(!Array.isArray(s)||s.length===0)return 0;let r=0;for(let n=s.length-1;n>=0;n--)i(s[n],e)&&(s.splice(n,1),r++);return s.length===0&&r>0&&this.delete(t),r}*[Symbol.iterator](){for(let[t,e]of d(this,L))yield[t,e!=null?e:[]]}*keys(){yield*d(this,L).keys()}*values(){for(let[,t]of this)yield t}*entriesOf(t){let e=this.get(t);if(Array.isArray(e))for(let i of e)yield[t,i]}*valuesOf(t){let e=this.get(t);Array.isArray(e)&&(yield*e)}*flatEntries(){for(let[t,e]of this)for(let i of e)yield[t,i]}first(){let t=d(this,L).getLeftMost();if(t===void 0)return;let e=this.get(t);return e===void 0?void 0:[t,e]}last(){let t=d(this,L).getRightMost();if(t===void 0)return;let e=this.get(t);return e===void 0?void 0:[t,e]}pollFirst(){let t=this.first();if(t)return this.delete(t[0]),t}pollLast(){let t=this.last();if(t)return this.delete(t[0]),t}ceiling(t){this._validateKey(t);let e=d(this,L).ceiling(t);if(e===void 0)return;let i=this.get(e);return i===void 0?void 0:[e,i]}floor(t){this._validateKey(t);let e=d(this,L).floor(t);if(e===void 0)return;let i=this.get(e);return i===void 0?void 0:[e,i]}higher(t){this._validateKey(t);let e=d(this,L).higher(t);if(e===void 0)return;let i=this.get(e);return i===void 0?void 0:[e,i]}lower(t){this._validateKey(t);let e=d(this,L).lower(t);if(e===void 0)return;let i=this.get(e);return i===void 0?void 0:[e,i]}print(){d(this,L).print()}forEach(t){for(let[e,i]of this)t(i,e,this)}filter(t){let e=[];for(let[i,s]of this)t(s,i,this)&&e.push([i,s]);return new Z(e,{comparator:this.comparator})}map(t){let e=[];for(let[i,s]of this)e.push(t(s,i,this));return new Z(e,{comparator:this.comparator})}reduce(t,e){let i=e;for(let[s,r]of this)i=t(i,r,s,this);return i}setMany(t){let e=[];for(let i of t)e.push(this.set(i));return e}rangeSearch(t,e){return d(this,L).rangeSearch(t,e)}clone(){return new Z(this,{comparator:this.comparator,isMapMode:d(this,L).isMapMode})}get comparator(){return d(this,L).comparator}};L=new WeakMap;Y=new WeakMap;f(li,"TreeMultiMap");var F,P,O,ai=class Q{constructor(t=[],e={}){A(this,F),A(this,P),A(this,O);var i;B(this,O,e.comparator);let s=e.toEntryFn,r=(i=e.comparator)!=null?i:Q.createDefaultComparator();B(this,P,e.comparator===void 0),B(this,F,new ht([],{comparator:r,isMapMode:e.isMapMode}));for(let n of t){let h,o;if(s)[h,o]=s(n);else{if(!Array.isArray(n)||n.length<2)throw new TypeError("TreeMap: each entry must be a [key, value] tuple");h=n[0],o=n[1]}this.set(h,o)}}static createDefaultComparator(){return(t,e)=>{if(typeof t=="number"&&typeof e=="number"){if(Number.isNaN(t)||Number.isNaN(e))throw new TypeError("TreeMap: NaN is not a valid key");let i=Object.is(t,-0)?0:t,s=Object.is(e,-0)?0:e;return i>s?1:i<s?-1:0}if(typeof t=="string"&&typeof e=="string")return t>e?1:t<e?-1:0;if(t instanceof Date&&e instanceof Date){let i=t.getTime(),s=e.getTime();if(Number.isNaN(i)||Number.isNaN(s))throw new TypeError("TreeMap: invalid Date key");return i>s?1:i<s?-1:0}throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys")}}_validateKey(t){if(d(this,P)){if(typeof t=="number"){if(Number.isNaN(t))throw new TypeError("TreeMap: NaN is not a valid key");return}if(typeof t!="string"){if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new TypeError("TreeMap: invalid Date key");return}throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys")}}}get size(){return d(this,F).size}isEmpty(){return this.size===0}set(t,e){return this._validateKey(t),d(this,F).set(t,e),this}get(t){return this._validateKey(t),d(this,F).get(t)}has(t){return this._validateKey(t),d(this,F).has(t)}delete(t){var e;this._validateKey(t);let i=d(this,F).delete(t);return Array.isArray(i)&&i.length>0&&!!((e=i[0])!=null&&e.deleted)}clear(){d(this,F).clear()}keys(){return d(this,F).keys()}_entryFromKey(t){return[t,d(this,F).get(t)]}*values(){for(let t of this.keys())yield this._entryFromKey(t)[1]}*entries(){for(let t of this.keys())yield this._entryFromKey(t)}[Symbol.iterator](){return this.entries()}forEach(t,e){for(let[i,s]of this)t.call(e,s,i,this)}map(t,e={},i){let s=new Q([],e),r=0;for(let[n,h]of this){let[o,l]=i===void 0?t(h,n,r++,this):t.call(i,h,n,r++,this);s.set(o,l)}return s}filter(t,e){let i=new Q([],{comparator:d(this,O)}),s=0;for(let[r,n]of this)(e===void 0?t(n,r,s++,this):t.call(e,n,r,s++,this))&&i.set(r,n);return i}reduce(t,e){let i=e,s=0;for(let[r,n]of this)i=t(i,n,r,s++,this);return i}every(t,e){let i=0;for(let[s,r]of this)if(!(e===void 0?t(r,s,i++,this):t.call(e,r,s,i++,this)))return!1;return!0}some(t,e){let i=0;for(let[s,r]of this)if(e===void 0?t(r,s,i++,this):t.call(e,r,s,i++,this))return!0;return!1}find(t,e){let i=0;for(let[s,r]of this)if(e===void 0?t(r,s,i++,this):t.call(e,r,s,i++,this))return[s,r]}toArray(){return[...this]}print(){d(this,F).print()}first(){let t=d(this,F).getLeftMost();return t===void 0?void 0:this._entryFromKey(t)}last(){let t=d(this,F).getRightMost();return t===void 0?void 0:this._entryFromKey(t)}pollFirst(){let t=this.first();if(t)return this.delete(t[0]),t}pollLast(){let t=this.last();if(t)return this.delete(t[0]),t}ceiling(t){this._validateKey(t);let e=d(this,F).ceiling(t);return e===void 0?void 0:this._entryFromKey(e)}floor(t){this._validateKey(t);let e=d(this,F).floor(t);return e===void 0?void 0:this._entryFromKey(e)}higher(t){this._validateKey(t);let e=d(this,F).higher(t);return e===void 0?void 0:this._entryFromKey(e)}lower(t){this._validateKey(t);let e=d(this,F).lower(t);return e===void 0?void 0:this._entryFromKey(e)}rangeSearch(t,e={}){let{lowInclusive:i=!0,highInclusive:s=!0}=e,[r,n]=t;this._validateKey(r),this._validateKey(n);let h=d(this,F).rangeSearch([r,n]),o=[],l=d(this,F).comparator;for(let a of h)a!==void 0&&(!i&&l(a,r)===0||!s&&l(a,n)===0||o.push(this._entryFromKey(a)));return o}clone(){return new Q(this,{comparator:d(this,P)?void 0:d(this,O),isMapMode:d(this,F).isMapMode})}};F=new WeakMap;P=new WeakMap;O=new WeakMap;f(ai,"TreeMap");var R,K,ui=class tt{constructor(t=[],e={}){A(this,R),A(this,K),u(this,"_size",0);var i;let s=e.toElementFn,r=(i=e.comparator)!=null?i:ot.createDefaultComparator();B(this,K,e.comparator===void 0),B(this,R,new ht([],{comparator:r,isMapMode:e.isMapMode}));for(let n of t){let h=s?s(n):n;this.add(h)}}_validateKey(t){if(d(this,K)){if(typeof t=="number"){if(Number.isNaN(t))throw new TypeError("TreeMultiSet: NaN is not a valid key");return}if(typeof t!="string"){if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new TypeError("TreeMultiSet: invalid Date key");return}throw new TypeError("TreeMultiSet: comparator is required for non-number/non-string/non-Date keys")}}}_validateCount(t){if(!Number.isSafeInteger(t)||t<0)throw new RangeError("TreeMultiSet: count must be a safe integer >= 0")}get size(){return this._size}get distinctSize(){return d(this,R).size}isEmpty(){return this.size===0}has(t){return this._validateKey(t),this.count(t)>0}count(t){var e;return this._validateKey(t),(e=d(this,R).get(t))!=null?e:0}add(t,e=1){var i;if(this._validateKey(t),this._validateCount(e),e===0)return!1;let r=((i=d(this,R).get(t))!=null?i:0)+e;return d(this,R).set(t,r),this._size+=e,!0}setCount(t,e){var i;this._validateKey(t),this._validateCount(e);let s=(i=d(this,R).get(t))!=null?i:0;return s===e?!1:(e===0?s!==0&&d(this,R).delete(t):d(this,R).set(t,e),this._size+=e-s,!0)}delete(t,e=1){var i;if(this._validateKey(t),this._validateCount(e),e===0)return!1;let s=(i=d(this,R).get(t))!=null?i:0;if(s===0)return!1;let r=Math.min(s,e),n=s-r;return n===0?d(this,R).delete(t):d(this,R).set(t,n),this._size-=r,!0}deleteAll(t){var e;this._validateKey(t);let i=(e=d(this,R).get(t))!=null?e:0;return i===0?!1:(d(this,R).delete(t),this._size-=i,!0)}*keysDistinct(){yield*d(this,R).keys()}*entries(){for(let[t,e]of d(this,R))yield[t,e!=null?e:0]}*[Symbol.iterator](){for(let[t,e]of this.entries())for(let i=0;i<e;i++)yield t}toArray(){return[...this]}toDistinctArray(){return[...this.keysDistinct()]}toEntries(){return[...this.entries()]}get comparator(){return d(this,R)._comparator}clear(){d(this,R).clear(),this._size=0}first(){return d(this,R).getLeftMost()}last(){return d(this,R).getRightMost()}pollFirst(){let t=this.first();if(t!==void 0)return this.deleteAll(t),t}pollLast(){let t=this.last();if(t!==void 0)return this.deleteAll(t),t}ceiling(t){return this._validateKey(t),d(this,R).ceiling(t)}floor(t){return this._validateKey(t),d(this,R).floor(t)}higher(t){return this._validateKey(t),d(this,R).higher(t)}lower(t){return this._validateKey(t),d(this,R).lower(t)}forEach(t){for(let[e,i]of this.entries())t(e,i)}filter(t){let e=new tt([],{comparator:d(this,K)?void 0:this.comparator,isMapMode:d(this,R)._isMapMode});for(let[i,s]of this.entries())t(i,s)&&e.add(i,s);return e}reduce(t,e){let i=e;for(let[s,r]of this.entries())i=t(i,s,r);return i}map(t,e){let i=new tt([],{comparator:e==null?void 0:e.comparator,isMapMode:d(this,R)._isMapMode});for(let[s,r]of this.entries()){let[n,h]=t(s,r);i.add(n,h)}return i}clone(){let t=new tt([],{comparator:d(this,K)?void 0:this.comparator,isMapMode:d(this,R)._isMapMode});for(let[e,i]of this.entries())t.add(e,i);return t}rangeSearch(t,e){let i=e!=null?e:(s=>s);return d(this,R).rangeSearch(t,s=>i(s.key))}print(){d(this,R).print()}};R=new WeakMap;K=new WeakMap;f(ui,"TreeMultiSet");var ye=class extends nt{constructor(t=[],e){super(t,e)}};f(ye,"PriorityQueue");var be=ye,fi=class extends be{constructor(t=[],e){super(t,e)}};f(fi,"MinPriorityQueue");var ci=class extends be{constructor(t=[],e){super(t,{comparator:f((i,s)=>{if(typeof i=="object"||typeof s=="object")throw TypeError("When comparing object types, a custom comparator must be defined in the constructor's options parameter.");return i<s?1:i>s?-1:0},"comparator"),...e})}};f(ci,"MaxPriorityQueue");var _i=class V{constructor(t,e){u(this,"_rows",0),u(this,"_cols",0),u(this,"_data");var i,s,r;if(e){let{rows:n,cols:h,addFn:o,subtractFn:l,multiplyFn:a}=e;typeof n=="number"&&n>0?this._rows=n:this._rows=t.length,typeof h=="number"&&h>0?this._cols=h:this._cols=((i=t[0])==null?void 0:i.length)||0,o&&(this._addFn=o),l&&(this._subtractFn=l),a&&(this._multiplyFn=a)}else this._rows=t.length,this._cols=(r=(s=t[0])==null?void 0:s.length)!=null?r:0;if(t.length>0)this._data=t;else{this._data=[];for(let n=0;n<this.rows;n++)this._data[n]=new Array(this.cols).fill(0)}}get rows(){return this._rows}get cols(){return this._cols}get data(){return this._data}get addFn(){return this._addFn}get subtractFn(){return this._subtractFn}get multiplyFn(){return this._multiplyFn}get(t,e){if(this.isValidIndex(t,e))return this.data[t][e]}set(t,e,i){return this.isValidIndex(t,e)?(this.data[t][e]=i,!0):!1}isMatchForCalculate(t){return this.rows===t.rows&&this.cols===t.cols}add(t){if(!this.isMatchForCalculate(t))throw new Error("Matrix dimensions must match for addition.");let e=[];for(let i=0;i<this.rows;i++){e[i]=[];for(let s=0;s<this.cols;s++){let r=this.get(i,s),n=t.get(i,s);if(r!==void 0&&n!==void 0){let h=this._addFn(r,n);h&&(e[i][s]=h)}}}return new V(e,{rows:this.rows,cols:this.cols,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn})}subtract(t){if(!this.isMatchForCalculate(t))throw new Error("Matrix dimensions must match for subtraction.");let e=[];for(let i=0;i<this.rows;i++){e[i]=[];for(let s=0;s<this.cols;s++){let r=this.get(i,s),n=t.get(i,s);if(r!==void 0&&n!==void 0){let h=this._subtractFn(r,n);h&&(e[i][s]=h)}}}return new V(e,{rows:this.rows,cols:this.cols,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn})}multiply(t){if(this.cols!==t.rows)throw new Error("Matrix dimensions must be compatible for multiplication (A.cols = B.rows).");let e=[];for(let i=0;i<this.rows;i++){e[i]=[];for(let s=0;s<t.cols;s++){let r;for(let n=0;n<this.cols;n++){let h=this.get(i,n),o=t.get(n,s);if(h!==void 0&&o!==void 0){let l=this.multiplyFn(h,o);l!==void 0&&(r=this.addFn(r,l))}}r!==void 0&&(e[i][s]=r)}}return new V(e,{rows:this.rows,cols:t.cols,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn})}transpose(){if(this.data.some(e=>e.length!==this.rows))throw new Error("Matrix must be rectangular for transposition.");let t=[];for(let e=0;e<this.cols;e++){t[e]=[];for(let i=0;i<this.rows;i++){let s=this.get(i,e);s!==void 0&&(t[e][i]=s)}}return new V(t,{rows:this.cols,cols:this.rows,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn})}inverse(){var t;if(this.rows!==this.cols)throw new Error("Matrix must be square for inversion.");let e=[];for(let r=0;r<this.rows;r++){e[r]=this.data[r].slice();for(let n=0;n<this.cols;n++)e[r][this.cols+n]=r===n?1:0}let i=new V(e,{rows:this.rows,cols:this.cols*2,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn});for(let r=0;r<this.rows;r++){let n=r;for(;n<this.rows&&i.get(n,r)===0;)n++;if(n===this.rows)throw new Error("Matrix is singular, and its inverse does not exist.");i._swapRows(r,n);let h=(t=i.get(r,r))!=null?t:1;if(h===0)throw new Error("Matrix is singular, and its inverse does not exist (division by zero).");i._scaleRow(r,1/h);for(let o=0;o<this.rows;o++)if(o!==r){let l=i.get(o,r);l===void 0&&(l=0),i._addScaledRow(o,r,-l)}}let s=[];for(let r=0;r<this.rows;r++)s[r]=i.data[r].slice(this.cols);return new V(s,{rows:this.rows,cols:this.cols,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn})}dot(t){if(this.cols!==t.rows)throw new Error("Number of columns in the first matrix must be equal to the number of rows in the second matrix for dot product.");let e=[];for(let i=0;i<this.rows;i++){e[i]=[];for(let s=0;s<t.cols;s++){let r;for(let n=0;n<this.cols;n++){let h=this.get(i,n),o=t.get(n,s);if(h!==void 0&&o!==void 0){let l=this.multiplyFn(h,o);l!==void 0&&(r=this.addFn(r,l))}}r!==void 0&&(e[i][s]=r)}}return new V(e,{rows:this.rows,cols:t.cols,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn})}isValidIndex(t,e){return t>=0&&t<this.rows&&e>=0&&e<this.cols}clone(){return new V(this.data,{rows:this.rows,cols:this.cols,addFn:this.addFn,subtractFn:this.subtractFn,multiplyFn:this.multiplyFn})}_addFn(t,e){return t===void 0?e:t+e}_subtractFn(t,e){return t-e}_multiplyFn(t,e){return t*e}_swapRows(t,e){let i=this.data[t];this.data[t]=this.data[e],this.data[e]=i}_scaleRow(t,e){for(let i=0;i<this.cols;i++){let s=this.multiplyFn(this.data[t][i],e);s===void 0&&(s=0),this.data[t][i]=s}}_addScaledRow(t,e,i){for(let s=0;s<this.cols;s++){let r=this.multiplyFn(this.data[e][s],i);r===void 0&&(r=0);let n=r,h=this.addFn(this.data[t][s],n);h===void 0&&(h=0),this.data[t][s]=h}}};f(_i,"Matrix");var xe=class ke{constructor(t,e){u(this,"direction"),u(this,"turn"),this.direction=t,this.turn=()=>new ke(e[t],e)}};f(xe,"Character");var di=xe,gi=class{constructor({matrix:t,turning:e,onMove:i,init:{cur:s,charDir:r,VISITED:n}}){u(this,"onMove"),u(this,"_matrix"),u(this,"_cur"),u(this,"_character"),u(this,"_VISITED"),this._matrix=t,this._cur=s,this._character=new di(r,e),this.onMove=i,this.onMove&&this.onMove(this._cur),this._VISITED=n,this._matrix[this._cur[0]][this._cur[1]]=this._VISITED}start(){for(;this.check(this._character.direction)||this.check(this._character.turn().direction);){let{direction:t}=this._character;this.check(t)?this.move(t):this.check(this._character.turn().direction)&&(this._character=this._character.turn())}}check(t){let e,i,s=this._matrix,[r,n]=this._cur;switch(t){case"up":if(i=s[r-1],!i)return!1;e=i[n];break;case"right":e=s[r][n+1];break;case"down":if(i=s[r+1],!i)return!1;e=i[n];break;case"left":e=s[r][n-1];break}return e!==void 0&&e!==this._VISITED}move(t){switch(t){case"up":this._cur[0]--;break;case"right":this._cur[1]++;break;case"down":this._cur[0]++;break;case"left":this._cur[1]--;break}let[e,i]=this._cur;this._matrix[e][i]=this._VISITED,this.onMove&&this.onMove(this._cur)}};f(gi,"Navigator");var Ne=class{constructor(t){u(this,"_key"),u(this,"_children"),u(this,"_isEnd"),this._key=t,this._isEnd=!1,this._children=new Map}get key(){return this._key}set key(t){this._key=t}get children(){return this._children}set children(t){this._children=t}get isEnd(){return this._isEnd}set isEnd(t){this._isEnd=t}};f(Ne,"TrieNode");var ct=Ne,pi=class extends rt{constructor(t=[],e){if(super(e),u(this,"_size",0),u(this,"_caseSensitive",!0),u(this,"_root",new ct("")),e){let{caseSensitive:i}=e;i!==void 0&&(this._caseSensitive=i)}t&&this.addMany(t)}get size(){return this._size}get caseSensitive(){return this._caseSensitive}get root(){return this._root}get _total(){return this._size}add(t){t=this._caseProcess(t);let e=this.root,i=!1;for(let s of t){let r=e.children.get(s);r||(r=new ct(s),e.children.set(s,r)),e=r}return e.isEnd||(i=!0,e.isEnd=!0,this._size++),i}addMany(t){let e=[];for(let i of t)this.toElementFn?e.push(this.add(this.toElementFn(i))):e.push(this.add(i));return e}has(t){t=this._caseProcess(t);let e=this.root;for(let i of t){let s=e.children.get(i);if(!s)return!1;e=s}return e.isEnd}isEmpty(){return this._size===0}clear(){this._size=0,this._root=new ct("")}delete(t){t=this._caseProcess(t);let e=!1,i=f((s,r)=>{let n=t[r],h=s.children.get(n);return h?r===t.length-1?h.isEnd?(h.children.size>0?h.isEnd=!1:s.children.delete(n),e=!0,!0):!1:i(h,r+1)&&!s.isEnd&&h.children.size===0?(s.children.delete(n),!0):!1:!1},"dfs");return i(this.root,0),e&&this._size--,e}getHeight(){let t=this.root,e=0;if(t){let i=f((s,r)=>{r>e&&(e=r);let{children:n}=s;if(n)for(let h of n.entries())i(h[1],r+1)},"bfs");i(t,0)}return e}hasPurePrefix(t){t=this._caseProcess(t);let e=this.root;for(let i of t){let s=e.children.get(i);if(!s)return!1;e=s}return!e.isEnd}hasPrefix(t){t=this._caseProcess(t);let e=this.root;for(let i of t){let s=e.children.get(i);if(!s)return!1;e=s}return!0}hasCommonPrefix(t){t=this._caseProcess(t);let e="",i=f(s=>{if(e+=s.key,e!==t&&!s.isEnd)if(s&&s.children&&s.children.size===1)i(Array.from(s.children.values())[0]);else return},"dfs");return i(this.root),e===t}getLongestCommonPrefix(){let t="",e=f(i=>{if(t+=i.key,!i.isEnd)if(i&&i.children&&i.children.size===1)e(Array.from(i.children.values())[0]);else return},"dfs");return e(this.root),t}getWords(t="",e=Number.MAX_SAFE_INTEGER,i=!1){t=this._caseProcess(t);let s=[],r=0,n=f((o,l)=>{for(let[a,_]of o.children){if(r>=e)return;n(_,l+a)}if(o.isEnd){if(r>=e)return;s.push(l),r++}},"dfs"),h=this.root;if(t)for(let o of t){let l=h.children.get(o);if(l)h=l;else return[]}return(i||h!==this.root)&&n(h,t),s}clone(){let t=this._createInstance();for(let e of this)t.add(e);return t}filter(t,e){let i=this._createInstance(),s=0;for(let r of this)t.call(e,r,s,this)&&i.add(r),s++;return i}map(t,e,i){let s=this._createLike([],e),r=0;for(let n of this){let h=i===void 0?t(n,r++,this):t.call(i,n,r++,this);if(typeof h!="string")throw new TypeError(`Trie.map callback must return string; got ${typeof h}`);s.add(h)}return s}mapSame(t,e){let i=this._createInstance(),s=0;for(let r of this){let n=e===void 0?t(r,s++,this):t.call(e,r,s++,this);i.add(n)}return i}_createInstance(t){let e=this.constructor;return new e([],{toElementFn:this.toElementFn,caseSensitive:this.caseSensitive,...t!=null?t:{}})}_createLike(t=[],e){let i=this.constructor;return new i(t,e)}_spawnLike(t){return this._createLike([],t)}*_getIterator(){function*t(e,i){e.isEnd&&(yield i);for(let[s,r]of e.children)yield*t(r,i+s)}f(t,"_dfs"),yield*t(this.root,"")}_caseProcess(t){return this._caseSensitive||(t=t.toLowerCase()),t}};f(pi,"Trie");var vi=class Ee{constructor(t,e,i){u(this,"_key"),u(this,"_value"),u(this,"_children"),this._key=t,this._value=e||void 0,i&&(this._children=i)}get key(){return this._key}set key(t){this._key=t}get value(){return this._value}set value(t){this._value=t}get children(){return this._children}set children(t){this._children=t}addChildren(t){this._children||(this._children=[]),t instanceof Ee?this._children.push(t):this._children=this._children.concat(t)}getHeight(){let t=0;if(this){let e=f((i,s)=>{s>t&&(t=s);let{_children:r}=i;if(r)for(let n=0,h=r.length;n<h;n++)e(r[n],s+1)},"bfs");e(this,0)}return t}};f(vi,"TreeNode");return Ce(mi);})();
|
|
6
|
+
/*! Bundled license information:
|
|
7
|
+
|
|
8
|
+
data-structure-typed/dist/esm-legacy/index.mjs:
|
|
9
|
+
(**
|
|
10
|
+
* data-structure-typed
|
|
11
|
+
*
|
|
12
|
+
* @author Pablo Zeng
|
|
13
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
14
|
+
* @license MIT License
|
|
15
|
+
*)
|
|
16
|
+
(**
|
|
17
|
+
* data-structure-typed
|
|
18
|
+
* @author Kirk Qi
|
|
19
|
+
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
|
|
20
|
+
* @license MIT License
|
|
21
|
+
*)
|
|
22
|
+
(**
|
|
23
|
+
* @remarks Time O(n log n), Space O(n).
|
|
24
|
+
* data-structure-typed
|
|
25
|
+
* @author Kirk Qi
|
|
26
|
+
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
|
|
27
|
+
* @license MIT License
|
|
28
|
+
*)
|
|
29
|
+
(**
|
|
30
|
+
* data-structure-typed
|
|
31
|
+
*
|
|
32
|
+
* @author Pablo Zeng
|
|
33
|
+
* @copyright Copyright (c) 2022 Pablo Zeng
|
|
34
|
+
* @license MIT License
|
|
35
|
+
*)
|
|
36
|
+
(**
|
|
37
|
+
* data-structure-typed
|
|
38
|
+
*
|
|
39
|
+
* @author Kirk Qi
|
|
40
|
+
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
|
|
41
|
+
* @license MIT License
|
|
42
|
+
*)
|
|
43
|
+
*/
|
|
44
|
+
//# sourceMappingURL=red-black-tree-typed.min.js.map
|