data-structure-typed 1.44.1 → 1.45.1
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 +6 -6
- package/CHANGELOG.md +1 -1
- package/README.md +15 -15
- package/benchmark/report.html +15 -15
- package/benchmark/report.json +121 -121
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +230 -37
- package/dist/cjs/data-structures/hash/hash-map.js +427 -115
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-set.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -1
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
- package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/hash/hash-map.d.ts +15 -1
- package/dist/cjs/types/data-structures/hash/index.d.ts +6 -0
- package/dist/cjs/types/data-structures/hash/index.js +20 -0
- package/dist/cjs/types/data-structures/hash/index.js.map +1 -1
- package/dist/cjs/utils/utils.d.ts +3 -0
- package/dist/cjs/utils/utils.js +15 -1
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +230 -37
- package/dist/mjs/data-structures/hash/hash-map.js +433 -121
- package/dist/mjs/types/data-structures/hash/hash-map.d.ts +15 -1
- package/dist/mjs/types/data-structures/hash/index.d.ts +6 -0
- package/dist/mjs/types/data-structures/hash/index.js +6 -1
- package/dist/mjs/utils/utils.d.ts +3 -0
- package/dist/mjs/utils/utils.js +11 -0
- package/dist/umd/data-structure-typed.js +533 -207
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +7 -7
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
- package/src/data-structures/binary-tree/binary-tree.ts +39 -31
- package/src/data-structures/binary-tree/bst.ts +12 -8
- package/src/data-structures/binary-tree/rb-tree.ts +17 -6
- package/src/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
- package/src/data-structures/graph/abstract-graph.ts +46 -31
- package/src/data-structures/graph/directed-graph.ts +10 -5
- package/src/data-structures/graph/map-graph.ts +8 -8
- package/src/data-structures/graph/undirected-graph.ts +9 -9
- package/src/data-structures/hash/hash-map.ts +430 -123
- package/src/data-structures/hash/hash-table.ts +1 -1
- package/src/data-structures/hash/tree-map.ts +2 -1
- package/src/data-structures/hash/tree-set.ts +2 -1
- package/src/data-structures/heap/heap.ts +8 -5
- package/src/data-structures/heap/max-heap.ts +3 -3
- package/src/data-structures/heap/min-heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/matrix2d.ts +1 -1
- package/src/data-structures/matrix/navigator.ts +3 -3
- package/src/data-structures/matrix/vector2d.ts +2 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/priority-queue.ts +3 -3
- package/src/data-structures/queue/deque.ts +5 -4
- package/src/data-structures/queue/queue.ts +2 -2
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/interfaces/graph.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/bst.ts +2 -2
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
- package/src/types/data-structures/hash/hash-map.ts +17 -1
- package/src/types/data-structures/hash/index.ts +7 -0
- package/src/types/data-structures/matrix/navigator.ts +1 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +18 -4
- package/src/utils/utils.ts +16 -3
- package/test/config.ts +1 -1
- package/test/integration/all-in-one.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +19 -19
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +7 -7
- package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/binary-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/bst.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +6 -6
- package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/performance/data-structures/hash/hash-map.test.ts +6 -6
- package/test/performance/data-structures/heap/heap.test.ts +5 -5
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
- package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +4 -4
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +7 -5
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +7 -7
- package/test/performance/data-structures/queue/deque.test.ts +5 -5
- package/test/performance/data-structures/queue/queue.test.ts +6 -6
- package/test/performance/data-structures/stack/stack.test.ts +6 -6
- package/test/performance/data-structures/trie/trie.test.ts +4 -4
- package/test/performance/reportor.ts +15 -13
- package/test/performance/types/reportor.ts +1 -1
- package/test/types/utils/json2html.ts +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +8 -8
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +12 -12
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -76
- package/test/unit/data-structures/binary-tree/bst.test.ts +50 -46
- package/test/unit/data-structures/binary-tree/overall.test.ts +18 -18
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +21 -21
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +37 -37
- package/test/unit/data-structures/graph/abstract-graph.test.ts +9 -8
- package/test/unit/data-structures/graph/directed-graph.test.ts +34 -14
- package/test/unit/data-structures/graph/map-graph.test.ts +1 -1
- package/test/unit/data-structures/graph/overall.test.ts +1 -1
- package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
- package/test/unit/data-structures/hash/coordinate-map.test.ts +1 -1
- package/test/unit/data-structures/hash/coordinate-set.test.ts +1 -1
- package/test/unit/data-structures/hash/hash-map.test.ts +150 -21
- package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
- package/test/unit/data-structures/heap/heap.test.ts +41 -29
- package/test/unit/data-structures/heap/max-heap.test.ts +6 -6
- package/test/unit/data-structures/heap/min-heap.test.ts +6 -6
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +7 -7
- package/test/unit/data-structures/linked-list/skip-list.test.ts +5 -5
- package/test/unit/data-structures/matrix/matrix.test.ts +5 -5
- package/test/unit/data-structures/matrix/matrix2d.test.ts +3 -3
- package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
- package/test/unit/data-structures/matrix/vector2d.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +7 -7
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +19 -13
- package/test/unit/data-structures/queue/deque.test.ts +28 -28
- package/test/unit/data-structures/queue/queue.test.ts +3 -3
- package/test/unit/data-structures/stack/stack.test.ts +1 -1
- package/test/unit/data-structures/tree/tree.test.ts +1 -1
- package/test/unit/data-structures/trie/trie.test.ts +10 -10
- package/test/utils/array.ts +2 -2
- package/test/utils/big-o.ts +4 -4
- package/test/utils/json2html.ts +7 -3
- package/test/utils/number.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";function t(t,e){if(e==null||e>t.length)e=t.length;for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function e(t){if(Array.isArray(t))return t}function r(e){if(Array.isArray(e))return t(e)}function n(t){if(t===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function i(t,e,r,n,i,a,u){try{var o=t[a](u);var s=o.value}catch(t){r(t);return}if(o.done){e(s)}else{Promise.resolve(s).then(n,i)}}function a(t){return function(){var e=this,r=arguments;return new Promise(function(n,a){var u=t.apply(e,r);function o(t){i(u,n,a,o,s,"next",t)}function s(t){i(u,n,a,o,s,"throw",t)}o(undefined)})}}function u(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}}function o(t,e,r){if(S()){o=Reflect.construct}else{o=function t(t,e,r){var n=[null];n.push.apply(n,e);var i=Function.bind.apply(t,n);var a=new i;if(r)m(a,r.prototype);return a}}return o.apply(null,arguments)}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(t,n.key,n)}}function l(t,e,r){if(e)s(t.prototype,e);if(r)s(t,r);return t}function h(t,e,r){if(typeof Reflect!=="undefined"&&Reflect.get){h=Reflect.get}else{h=function t(t,e,r){var n=x(t,e);if(!n)return;var i=Object.getOwnPropertyDescriptor(n,e);if(i.get){return i.get.call(r||t)}return i.value}}return h(t,e,r||t)}function f(t){f=Object.setPrototypeOf?Object.getPrototypeOf:function t(t){return t.__proto__||Object.getPrototypeOf(t)};return f(t)}function v(t,e){if(typeof e!=="function"&&e!==null){throw new TypeError("Super expression must either be null or a function")}t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:true,configurable:true}});if(e)m(t,e)}function c(t,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](t)}else{return t instanceof e}}function d(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function y(t){if(typeof Symbol!=="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function g(t,e){var r=t==null?null:typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(r==null)return;var n=[];var i=true;var a=false;var u,o;try{for(r=r.call(t);!(i=(u=r.next()).done);i=true){n.push(u.value);if(e&&n.length===e)break}}catch(t){a=true;o=t}finally{try{if(!i&&r["return"]!=null)r["return"]()}finally{if(a)throw o}}return n}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(t,e){if(e&&(N(e)==="object"||typeof e==="function")){return e}return n(t)}function m(t,e){m=Object.setPrototypeOf||function t(t,e){t.__proto__=e;return t};return m(t,e)}function b(t,r){return e(t)||g(t,r)||E(t,r)||p()}function x(t,e){while(!Object.prototype.hasOwnProperty.call(t,e)){t=f(t);if(t===null)break}return t}function w(t){return r(t)||y(t)||E(t)||_()}function N(t){"@swc/helpers - typeof";return t&&typeof Symbol!=="undefined"&&t.constructor===Symbol?"symbol":typeof t}function E(e,r){if(!e)return;if(typeof e==="string")return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}function M(t){var e=typeof Map==="function"?new Map:undefined;M=function t(t){if(t===null||!d(t))return t;if(typeof t!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof e!=="undefined"){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return o(t,arguments,f(this).constructor)}r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return m(r,t)};return M(t)}function S(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(t){return false}}function R(t){var e=S();return function r(){var r=f(t),n;if(e){var i=f(this).constructor;n=Reflect.construct(r,arguments,i)}else{n=r.apply(this,arguments)}return k(this,n)}}function T(t,e){var r,n,i,a,u={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(t){return function(e){return s([t,e])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u)try{if(r=1,n&&(i=a[0]&2?n["return"]:a[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;if(n=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:u.label++;return{value:a[1],done:false};case 5:u.label++;n=a[1];a=[0];continue;case 7:a=u.ops.pop();u.trys.pop();continue;default:if(!(i=u.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){u=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){u.label=a[1];break}if(a[0]===6&&u.label<i[1]){u.label=i[1];i=a;break}if(i&&u.label<i[2]){u.label=i[2];u.ops.push(a);break}if(i[2])u.ops.pop();u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t];n=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}function O(t){var e=typeof Symbol==="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length==="number")return{next:function(){if(t&&n>=t.length)t=void 0;return{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var dataStructureTyped=function(){var t=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var o=function(e,r,n){return r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n};var s=function(e,r){for(var n in r)t(e,n,{get:r[n],enumerable:!0})},d=function(n,a,u,o){var s=true,l=false,h=undefined;if(a&&typeof a=="object"||typeof a=="function")try{var f=function(){var r=c.value;!i.call(n,r)&&r!==u&&t(n,r,{get:function(){return a[r]},enumerable:!(o=e(a,r))||o.enumerable})};for(var v=r(a)[Symbol.iterator](),c;!(s=(c=v.next()).done);s=true)f()}catch(t){l=true;h=t}finally{try{if(!s&&v.return!=null){v.return()}}finally{if(l){throw h}}}return n};var y=function(e){return d(t({},"__esModule",{value:!0}),e)};var g=function(t,e,r){return o(t,(typeof e==="undefined"?"undefined":N(e))!="symbol"?e+"":e,r),r};var p={};s(p,{AVLTree:function(){return tz},AVLTreeNode:function(){return tO},AbstractEdge:function(){return ts},AbstractGraph:function(){return tl},AbstractVertex:function(){return to},ArrayDeque:function(){return q},BST:function(){return tM},BSTNode:function(){return tE},BinaryIndexedTree:function(){return tS},BinaryTree:function(){return tN},BinaryTreeNode:function(){return tw},CP:function(){return tx},Character:function(){return tD},CoordinateMap:function(){return x},CoordinateSet:function(){return E},Deque:function(){return H},DirectedEdge:function(){return tf},DirectedGraph:function(){return tv},DirectedVertex:function(){return th},DoublyLinkedList:function(){return C},DoublyLinkedListNode:function(){return L},FamilyPosition:function(){return tm},FibonacciHeap:function(){return te},FibonacciHeapNode:function(){return tt},HashMap:function(){return I},HashTable:function(){return m},HashTableNode:function(){return _},Heap:function(){return $},IterationType:function(){return tk},LinkedListQueue:function(){return D},MapEdge:function(){return tp},MapGraph:function(){return t_},MapVertex:function(){return tg},Matrix2D:function(){return tj},MatrixNTI2D:function(){return tP},MaxHeap:function(){return tr},MaxPriorityQueue:function(){return tu},MinHeap:function(){return tn},MinPriorityQueue:function(){return ta},Navigator:function(){return tK},ObjectDeque:function(){return B},PriorityQueue:function(){return ti},Queue:function(){return K},RBTNColor:function(){return tb},RedBlackTree:function(){return tV},RedBlackTreeNode:function(){return tI},SegmentTree:function(){return tT},SegmentTreeNode:function(){return tR},SinglyLinkedList:function(){return A},SinglyLinkedListNode:function(){return V},SkipList:function(){return F},SkipListNode:function(){return P},Stack:function(){return j},THUNK_SYMBOL:function(){return W},TreeMap:function(){return S},TreeMultimap:function(){return tL},TreeMultimapNode:function(){return tA},TreeNode:function(){return tC},TreeSet:function(){return z},Trie:function(){return tB},TrieNode:function(){return tH},UndirectedEdge:function(){return td},UndirectedGraph:function(){return ty},UndirectedVertex:function(){return tc},Vector2D:function(){return tF},arrayRemove:function(){return G},getMSB:function(){return Z},isThunk:function(){return Q},toThunk:function(){return Y},trampoline:function(){return X},trampolineAsync:function(){return J},uuidV4:function(){return U}});var _=function t(e,r){u(this,t);g(this,"key");g(this,"value");g(this,"next");this.key=e,this.value=r,this.next=null},k=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:t.DEFAULT_CAPACITY,r=arguments.length>1?arguments[1]:void 0;u(this,t);g(this,"_capacity");g(this,"_size");g(this,"_buckets");g(this,"_hashFn");this._hashFn=r||this._defaultHashFn,this._capacity=Math.max(e,t.DEFAULT_CAPACITY),this._size=0,this._buckets=new Array(this._capacity).fill(null)}l(t,[{key:"capacity",get:function t(){return this._capacity}},{key:"size",get:function t(){return this._size}},{key:"buckets",get:function t(){return this._buckets}},{key:"hashFn",get:function t(){return this._hashFn}},{key:"set",value:function e(e,r){var n=this._hash(e),i=new _(e,r);if(!this._buckets[n])this._buckets[n]=i;else{var a=this._buckets[n];for(;a;){if(a.key===e){a.value=r;return}if(!a.next)break;a=a.next}a.next=i}this._size++,this._size/this._capacity>=t.LOAD_FACTOR&&this._expand()}},{key:"get",value:function t(t){var e=this._hash(t),r=this._buckets[e];for(;r;){if(r.key===t)return r.value;r=r.next}}},{key:"delete",value:function t(t){var e=this._hash(t),r=this._buckets[e],n=null;for(;r;){if(r.key===t){n?n.next=r.next:this._buckets[e]=r.next,this._size--,r.next=null;return}n=r,r=r.next}}},{key:"_defaultHashFn",value:function t(t){return(typeof t=="string"?this._murmurStringHashFn(t):this._objectHash(t))%this._capacity}},{key:"_multiplicativeStringHashFn",value:function t(t){var e=String(t),r=0;for(var n=0;n<e.length;n++){var i=e.charCodeAt(n),a=.618033988749895,u=1<<30;r=(r*a+i)%u}return Math.abs(r)}},{key:"_murmurStringHashFn",value:function t(t){var e=String(t),r=0;for(var n=0;n<e.length;n++){var i=e.charCodeAt(n);r=(r^i)*1540483477,r=(r^r>>>15)*668265261,r=r^r>>>15}return Math.abs(r)}},{key:"_hash",value:function t(t){return this.hashFn(t)}},{key:"_stringHash",value:function t(t){var e=0;for(var r=0;r<t.length;r++)e=e*31+t.charCodeAt(r)&4294967295;return e}},{key:"_objectHash",value:function t(t){return this._stringHash(JSON.stringify(t))}},{key:"_expand",value:function t(){var t=this._capacity*2,e=new Array(t).fill(null);var r=true,n=false,i=undefined;try{for(var a=this._buckets[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=u.value;var s=o;for(;s;){var l=this._hash(s.key),h=new _(s.key,s.value);if(!e[l])e[l]=h;else{var f=e[l];for(;f.next;)f=f.next;f.next=h}s=s.next}}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}this._buckets=e,this._capacity=t}}]);return t}();g(k,"DEFAULT_CAPACITY",16),g(k,"LOAD_FACTOR",.75);var m=k;var x=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t){u(this,r);var i;i=e.call(this);g(n(i),"_joint","_");t!==void 0&&(i._joint=t);return i}l(r,[{key:"joint",get:function t(){return this._joint}},{key:"has",value:function t(t){return h(f(r.prototype),"has",this).call(this,t.join(this._joint))}},{key:"set",value:function t(t,e){return h(f(r.prototype),"set",this).call(this,t.join(this._joint),e)}},{key:"get",value:function t(t){return h(f(r.prototype),"get",this).call(this,t.join(this._joint))}},{key:"delete",value:function t(t){return h(f(r.prototype),"delete",this).call(this,t.join(this._joint))}}]);return r}(M(Map));var E=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t){u(this,r);var i;i=e.call(this);g(n(i),"_joint","_");t!==void 0&&(i._joint=t);return i}l(r,[{key:"joint",get:function t(){return this._joint}},{key:"has",value:function t(t){return h(f(r.prototype),"has",this).call(this,t.join(this._joint))}},{key:"add",value:function t(t){return h(f(r.prototype),"add",this).call(this,t.join(this._joint))}},{key:"delete",value:function t(t){return h(f(r.prototype),"delete",this).call(this,t.join(this._joint))}}]);return r}(M(Set));var S=function t(){u(this,t)};var z=function t(){u(this,t)};var I=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.75,n=arguments.length>2?arguments[2]:void 0;var i=this;u(this,t);g(this,"_initialCapacity");g(this,"_loadFactor");g(this,"_capacityMultiplier");g(this,"_size");g(this,"_table");g(this,"_hashFn");this._initialCapacity=e,this._loadFactor=r,this._capacityMultiplier=2,this._size=0,this._table=new Array(e),this._hashFn=n||function(t){var e=String(t),r=0;for(var n=0;n<e.length;n++)r+=e.charCodeAt(n);return r%i.table.length}}l(t,[{key:"initialCapacity",get:function t(){return this._initialCapacity}},{key:"loadFactor",get:function t(){return this._loadFactor}},{key:"capacityMultiplier",get:function t(){return this._capacityMultiplier}},{key:"size",get:function t(){return this._size}},{key:"table",get:function t(){return this._table}},{key:"hashFn",get:function t(){return this._hashFn}},{key:"set",value:function t(t,e){this.size/this.table.length>=this.loadFactor&&this.resizeTable(this.table.length*this.capacityMultiplier);var r=this._hash(t);this.table[r]||(this.table[r]=[]);for(var n=0;n<this.table[r].length;n++)if(this.table[r][n][0]===t){this.table[r][n][1]=e;return}this.table[r].push([t,e]),this._size++}},{key:"get",value:function t(t){var e=this._hash(t);if(this.table[e]){var r=true,n=false,i=undefined;try{for(var a=this.table[e][Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=b(u.value,2),s=o[0],l=o[1];if(s===t)return l}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}}}},{key:"delete",value:function t(t){var e=this._hash(t);if(this.table[e]){for(var r=0;r<this.table[e].length;r++)if(this.table[e][r][0]===t){this.table[e].splice(r,1),this._size--,this.size/this.table.length<this.loadFactor/this.capacityMultiplier&&this.resizeTable(this.table.length/this.capacityMultiplier);return}}}},{key:"entries",value:function t(){var t,e,r,n,i,a,u,o,s,l,h,f,v,c,d,d;return T(this,function(y){switch(y.label){case 0:t=true,e=false,r=undefined,n=true,i=false,a=undefined;y.label=1;case 1:y.trys.push([1,12,13,14]);u=this.table[Symbol.iterator]();y.label=2;case 2:if(!!(n=(o=u.next()).done))return[3,11];s=o.value;if(!s)return[3,10];y.label=3;case 3:y.trys.push([3,8,9,10]);l=s[Symbol.iterator]();y.label=4;case 4:if(!!(t=(h=l.next()).done))return[3,7];f=b(h.value,2),v=f[0],c=f[1];return[4,[v,c]];case 5:y.sent();y.label=6;case 6:t=true;return[3,4];case 7:return[3,10];case 8:d=y.sent();e=true;r=d;return[3,10];case 9:try{if(!t&&l.return!=null){l.return()}}finally{if(e){throw r}}return[7];case 10:n=true;return[3,2];case 11:return[3,14];case 12:d=y.sent();i=true;a=d;return[3,14];case 13:try{if(!n&&u.return!=null){u.return()}}finally{if(i){throw a}}return[7];case 14:return[2]}})}},{key:Symbol.iterator,value:function t(){return this.entries()}},{key:"clear",value:function t(){this._size=0,this._table=new Array(this.initialCapacity)}},{key:"isEmpty",value:function t(){return this.size===0}},{key:"_hash",value:function t(t){return this._hashFn(t)}},{key:"resizeTable",value:function t(t){var e=new Array(t);var r=true,n=false,i=undefined,a=true,u=false,o=undefined;try{for(var s=this._table[Symbol.iterator](),l;!(a=(l=s.next()).done);a=true){var h=l.value;if(h)try{for(var f=h[Symbol.iterator](),v;!(r=(v=f.next()).done);r=true){var c=b(v.value,2),d=c[0],y=c[1];var g=this._hash(d)%t;e[g]||(e[g]=[]),e[g].push([d,y])}}catch(t){n=true;i=t}finally{try{if(!r&&f.return!=null){f.return()}}finally{if(n){throw i}}}}}catch(t){u=true;o=t}finally{try{if(!a&&s.return!=null){s.return()}}finally{if(u){throw o}}}this._table=e}}]);return t}();var V=function t(e){u(this,t);g(this,"value");g(this,"next");this.value=e,this.next=null},A=/*#__PURE__*/function(){function t(){u(this,t);g(this,"_head");g(this,"_tail");g(this,"_length");this._head=null,this._tail=null,this._length=0}l(t,[{key:"head",get:function t(){return this._head}},{key:"tail",get:function t(){return this._tail}},{key:"length",get:function t(){return this._length}},{key:"push",value:function t(t){var e=new V(t);this.head?(this.tail.next=e,this._tail=e):(this._head=e,this._tail=e),this._length++}},{key:"addLast",value:function t(t){this.push(t)}},{key:"pop",value:function t(){if(!this.head)return;if(this.head===this.tail){var t=this.head.value;return this._head=null,this._tail=null,this._length--,t}var e=this.head;for(;e.next!==this.tail;)e=e.next;var r=this.tail.value;return e.next=null,this._tail=e,this._length--,r}},{key:"popLast",value:function t(){return this.pop()}},{key:"shift",value:function t(){if(!this.head)return;var t=this.head;return this._head=this.head.next,this._length--,t.value}},{key:"popFirst",value:function t(){return this.shift()}},{key:"unshift",value:function t(t){var e=new V(t);this.head?(e.next=this.head,this._head=e):(this._head=e,this._tail=e),this._length++}},{key:"addFirst",value:function t(t){this.unshift(t)}},{key:"getAt",value:function t(t){if(t<0||t>=this.length)return;var e=this.head;for(var r=0;r<t;r++)e=e.next;return e.value}},{key:"getNodeAt",value:function t(t){var e=this.head;for(var r=0;r<t;r++)e=e.next;return e}},{key:"deleteAt",value:function t(t){if(t<0||t>=this.length)return;if(t===0)return this.shift();if(t===this.length-1)return this.pop();var e=this.getNodeAt(t-1),r=e.next;return e.next=r.next,this._length--,r.value}},{key:"delete",value:function t(t){if(!t)return!1;var e;c(t,V)?e=t.value:e=t;var r=this.head,n=null;for(;r;){if(r.value===e)return n===null?(this._head=r.next,r===this.tail&&(this._tail=null)):(n.next=r.next,r===this.tail&&(this._tail=n)),this._length--,!0;n=r,r=r.next}return!1}},{key:"insertAt",value:function t(t,e){if(t<0||t>this.length)return!1;if(t===0)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;var r=new V(e),n=this.getNodeAt(t-1);return r.next=n.next,n.next=r,this._length++,!0}},{key:"isEmpty",value:function t(){return this.length===0}},{key:"clear",value:function t(){this._head=null,this._tail=null,this._length=0}},{key:"toArray",value:function t(){var t=[],e=this.head;for(;e;)t.push(e.value),e=e.next;return t}},{key:"reverse",value:function t(){if(!this.head||this.head===this.tail)return;var t=null,e=this.head,r=null;for(;e;)r=e.next,e.next=t,t=e,e=r;var n;n=[this.tail,this.head],this._head=n[0],this._tail=n[1],n}},{key:"find",value:function t(t){var e=this.head;for(;e;){if(t(e.value))return e.value;e=e.next}return null}},{key:"indexOf",value:function t(t){var e=0,r=this.head;for(;r;){if(r.value===t)return e;e++,r=r.next}return-1}},{key:"getNode",value:function t(t){var e=this.head;for(;e;){if(e.value===t)return e;e=e.next}return null}},{key:"insertBefore",value:function t(t,e){if(!this.head)return!1;var r;if(c(t,V)?r=t.value:r=t,this.head.value===r)return this.unshift(e),!0;var n=this.head;for(;n.next;){if(n.next.value===r){var i=new V(e);return i.next=n.next,n.next=i,this._length++,!0}n=n.next}return!1}},{key:"insertAfter",value:function t(t,e){var r;if(c(t,V)?r=t:r=this.getNode(t),r){var n=new V(e);return n.next=r.next,r.next=n,r===this.tail&&(this._tail=n),this._length++,!0}return!1}},{key:"countOccurrences",value:function t(t){var e=0,r=this.head;for(;r;)r.value===t&&e++,r=r.next;return e}},{key:"forEach",value:function t(t){var e=this.head,r=0;for(;e;)t(e.value,r),e=e.next,r++}},{key:"map",value:function e(e){var r=new t,n=this.head;for(;n;)r.push(e(n.value)),n=n.next;return r}},{key:"filter",value:function e(e){var r=new t,n=this.head;for(;n;)e(n.value)&&r.push(n.value),n=n.next;return r}},{key:"reduce",value:function t(t,e){var r=e,n=this.head;for(;n;)r=t(r,n.value),n=n.next;return r}},{key:Symbol.iterator,value:function t(){var t;return T(this,function(e){switch(e.label){case 0:t=this.head;e.label=1;case 1:if(!t)return[3,4];return[4,t.value];case 2:e.sent(),t=t.next;e.label=3;case 3:return[3,1];case 4:return[2]}})}}],[{key:"fromArray",value:function e(e){var r=new t;var n=true,i=false,a=undefined;try{for(var u=e[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){var s=o.value;r.push(s)}}catch(t){i=true;a=t}finally{try{if(!n&&u.return!=null){u.return()}}finally{if(i){throw a}}}return r}}]);return t}();var L=function t(e){u(this,t);g(this,"value");g(this,"next");g(this,"prev");this.value=e,this.next=null,this.prev=null},C=/*#__PURE__*/function(){function t(){u(this,t);g(this,"_head");g(this,"_tail");g(this,"_length");this._head=null,this._tail=null,this._length=0}l(t,[{key:"head",get:function t(){return this._head}},{key:"tail",get:function t(){return this._tail}},{key:"length",get:function t(){return this._length}},{key:"size",get:function t(){return this.length}},{key:"push",value:function t(t){var e=new L(t);this.head?(e.prev=this.tail,this.tail.next=e,this._tail=e):(this._head=e,this._tail=e),this._length++}},{key:"addLast",value:function t(t){this.push(t)}},{key:"pop",value:function t(){if(!this.tail)return;var t=this.tail;return this.head===this.tail?(this._head=null,this._tail=null):(this._tail=t.prev,this.tail.next=null),this._length--,t.value}},{key:"popLast",value:function t(){return this.pop()}},{key:"shift",value:function t(){if(!this.head)return;var t=this.head;return this.head===this.tail?(this._head=null,this._tail=null):(this._head=t.next,this.head.prev=null),this._length--,t.value}},{key:"popFirst",value:function t(){return this.shift()}},{key:"unshift",value:function t(t){var e=new L(t);this.head?(e.next=this.head,this.head.prev=e,this._head=e):(this._head=e,this._tail=e),this._length++}},{key:"addFirst",value:function t(t){this.unshift(t)}},{key:"getFirst",value:function t(){var t;return(t=this.head)===null||t===void 0?void 0:t.value}},{key:"getLast",value:function t(){var t;return(t=this.tail)===null||t===void 0?void 0:t.value}},{key:"getAt",value:function t(t){if(t<0||t>=this.length)return;var e=this.head;for(var r=0;r<t;r++)e=e.next;return e.value}},{key:"getNodeAt",value:function t(t){if(t<0||t>=this.length)return null;var e=this.head;for(var r=0;r<t;r++)e=e.next;return e}},{key:"getNode",value:function t(t){var e=this.head;for(;e;){if(e.value===t)return e;e=e.next}return null}},{key:"insertAt",value:function t(t,e){if(t<0||t>this.length)return!1;if(t===0)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;var r=new L(e),n=this.getNodeAt(t-1),i=n.next;return r.prev=n,r.next=i,n.next=r,i.prev=r,this._length++,!0}},{key:"insertBefore",value:function t(t,e){var r;if(c(t,L)?r=t:r=this.getNode(t),r){var n=new L(e);return n.prev=r.prev,r.prev&&(r.prev.next=n),n.next=r,r.prev=n,r===this.head&&(this._head=n),this._length++,!0}return!1}},{key:"deleteAt",value:function t(t){if(t<0||t>=this.length)return;if(t===0)return this.shift();if(t===this.length-1)return this.pop();var e=this.getNodeAt(t),r=e.prev,n=e.next;return r.next=n,n.prev=r,this._length--,e.value}},{key:"delete",value:function t(t){var e;if(c(t,L)?e=t:e=this.getNode(t),e){if(e===this.head)this.shift();else if(e===this.tail)this.pop();else{var r=e.prev,n=e.next;r.next=n,n.prev=r,this._length--}return!0}return!1}},{key:"toArray",value:function t(){var t=[],e=this.head;for(;e;)t.push(e.value),e=e.next;return t}},{key:"isEmpty",value:function t(){return this.length===0}},{key:"clear",value:function t(){this._head=null,this._tail=null,this._length=0}},{key:"find",value:function t(t){var e=this.head;for(;e;){if(t(e.value))return e.value;e=e.next}return null}},{key:"indexOf",value:function t(t){var e=0,r=this.head;for(;r;){if(r.value===t)return e;e++,r=r.next}return-1}},{key:"findBackward",value:function t(t){var e=this.tail;for(;e;){if(t(e.value))return e.value;e=e.prev}return null}},{key:"toArrayBackward",value:function t(){var t=[],e=this.tail;for(;e;)t.push(e.value),e=e.prev;return t}},{key:"reverse",value:function t(){var t=this.head;var e;for(e=[this.tail,this.head],this._head=e[0],this._tail=e[1],e;t;){var r=t.next;var n;n=[t.next,t.prev],t.prev=n[0],t.next=n[1],n,t=r}}},{key:"forEach",value:function t(t){var e=this.head,r=0;for(;e;)t(e.value,r),e=e.next,r++}},{key:"map",value:function e(e){var r=new t,n=this.head;for(;n;)r.push(e(n.value)),n=n.next;return r}},{key:"filter",value:function e(e){var r=new t,n=this.head;for(;n;)e(n.value)&&r.push(n.value),n=n.next;return r}},{key:"reduce",value:function t(t,e){var r=e,n=this.head;for(;n;)r=t(r,n.value),n=n.next;return r}},{key:"insertAfter",value:function t(t,e){var r;if(c(t,L)?r=t:r=this.getNode(t),r){var n=new L(e);return n.next=r.next,r.next&&(r.next.prev=n),n.prev=r,r.next=n,r===this.tail&&(this._tail=n),this._length++,!0}return!1}},{key:Symbol.iterator,value:function t(){var t;return T(this,function(e){switch(e.label){case 0:t=this.head;e.label=1;case 1:if(!t)return[3,4];return[4,t.value];case 2:e.sent(),t=t.next;e.label=3;case 3:return[3,1];case 4:return[2]}})}}],[{key:"fromArray",value:function e(e){var r=new t;var n=true,i=false,a=undefined;try{for(var u=e[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){var s=o.value;r.push(s)}}catch(t){i=true;a=t}finally{try{if(!n&&u.return!=null){u.return()}}finally{if(i){throw a}}}return r}}]);return t}();var P=function t(e,r,n){u(this,t);g(this,"key");g(this,"value");g(this,"forward");this.key=e,this.value=r,this.forward=new Array(n)},F=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;u(this,t);g(this,"_head");g(this,"_level");g(this,"_maxLevel");g(this,"_probability");this._head=new P(null,null,e),this._level=0,this._maxLevel=e,this._probability=r}l(t,[{key:"head",get:function t(){return this._head}},{key:"level",get:function t(){return this._level}},{key:"maxLevel",get:function t(){return this._maxLevel}},{key:"probability",get:function t(){return this._probability}},{key:"add",value:function t(t,e){var r=new P(t,e,this._randomLevel()),n=new Array(this.maxLevel).fill(this.head),i=this.head;for(var a=this.level-1;a>=0;a--){for(;i.forward[a]&&i.forward[a].key<t;)i=i.forward[a];n[a]=i}for(var u=0;u<r.forward.length;u++)r.forward[u]=n[u].forward[u],n[u].forward[u]=r;r.forward[0]!==null&&(this._level=Math.max(this.level,r.forward.length))}},{key:"get",value:function t(t){var e=this.head;for(var r=this.level-1;r>=0;r--)for(;e.forward[r]&&e.forward[r].key<t;)e=e.forward[r];if(e=e.forward[0],e&&e.key===t)return e.value}},{key:"has",value:function t(t){return this.get(t)!==void 0}},{key:"delete",value:function t(t){var e=new Array(this.maxLevel).fill(this.head),r=this.head;for(var n=this.level-1;n>=0;n--){for(;r.forward[n]&&r.forward[n].key<t;)r=r.forward[n];e[n]=r}if(r=r.forward[0],r&&r.key===t){for(var i=0;i<this.level&&e[i].forward[i]===r;i++)e[i].forward[i]=r.forward[i];for(;this.level>0&&this.head.forward[this.level-1]===null;)this._level--;return!0}return!1}},{key:"getFirst",value:function t(){var t=this.head.forward[0];return t?t.value:void 0}},{key:"getLast",value:function t(){var t=this.head;for(var e=this.level-1;e>=0;e--)for(;t.forward[e];)t=t.forward[e];return t.value}},{key:"higher",value:function t(t){var e=this.head;for(var r=this.level-1;r>=0;r--)for(;e.forward[r]&&e.forward[r].key<=t;)e=e.forward[r];var n=e.forward[0];return n?n.value:void 0}},{key:"lower",value:function t(t){var e=this.head,r=null;for(var n=this.level-1;n>=0;n--){for(;e.forward[n]&&e.forward[n].key<t;)e=e.forward[n];e.key<t&&(r=e)}return r?r.value:void 0}},{key:"_randomLevel",value:function t(){var t=1;for(;Math.random()<this.probability&&t<this.maxLevel;)t++;return t}}]);return t}();var j=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"_elements");this._elements=Array.isArray(e)?e:[]}l(t,[{key:"elements",get:function t(){return this._elements}},{key:"isEmpty",value:function t(){return this.elements.length===0}},{key:"size",value:function t(){return this.elements.length}},{key:"peek",value:function t(){return this.isEmpty()?null:this.elements[this.elements.length-1]}},{key:"push",value:function t(t){return this.elements.push(t),this}},{key:"pop",value:function t(){return this.isEmpty()?null:this.elements.pop()||null}},{key:"toArray",value:function t(){return this.elements.slice()}},{key:"clear",value:function t(){this._elements=[]}},{key:"clone",value:function e(){return new t(this.elements.slice())}}],[{key:"fromArray",value:function e(e){return new t(e)}}]);return t}();var D=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){u(this,r);return e.apply(this,arguments)}l(r,[{key:"enqueue",value:function t(t){this.push(t)}},{key:"dequeue",value:function t(){return this.shift()}},{key:"getFirst",value:function t(){var t;return(t=this.head)===null||t===void 0?void 0:t.value}},{key:"peek",value:function t(){return this.getFirst()}}]);return r}(A),K=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"_nodes");g(this,"_offset");this._nodes=e||[],this._offset=0}l(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"offset",get:function t(){return this._offset}},{key:"size",get:function t(){return this.nodes.length-this.offset}},{key:"push",value:function t(t){return this.nodes.push(t),this}},{key:"shift",value:function t(){if(this.size===0)return;var t=this.getFirst();return this._offset+=1,this.offset*2<this.nodes.length||(this._nodes=this.nodes.slice(this.offset),this._offset=0),t}},{key:"getFirst",value:function t(){return this.size>0?this.nodes[this.offset]:void 0}},{key:"peek",value:function t(){return this.getFirst()}},{key:"getLast",value:function t(){return this.size>0?this.nodes[this.nodes.length-1]:void 0}},{key:"peekLast",value:function t(){return this.getLast()}},{key:"enqueue",value:function t(t){this.push(t)}},{key:"dequeue",value:function t(){return this.shift()}},{key:"getAt",value:function t(t){return this.nodes[t]}},{key:"isEmpty",value:function t(){return this.size===0}},{key:"toArray",value:function t(){return this.nodes.slice(this.offset)}},{key:"clear",value:function t(){this._nodes=[],this._offset=0}},{key:"clone",value:function e(){return new t(this.nodes.slice(this.offset))}},{key:Symbol.iterator,value:function t(){var t,e,r,n,i,a,u;return T(this,function(o){switch(o.label){case 0:t=true,e=false,r=undefined;o.label=1;case 1:o.trys.push([1,6,7,8]);n=this.nodes[Symbol.iterator]();o.label=2;case 2:if(!!(t=(i=n.next()).done))return[3,5];a=i.value;return[4,a];case 3:o.sent();o.label=4;case 4:t=true;return[3,2];case 5:return[3,8];case 6:u=o.sent();e=true;r=u;return[3,8];case 7:try{if(!t&&n.return!=null){n.return()}}finally{if(e){throw r}}return[7];case 8:return[2]}})}}],[{key:"fromArray",value:function e(e){return new t(e)}}]);return t}();var H=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){u(this,r);return e.apply(this,arguments)}return r}(C),B=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"_nodes",{});g(this,"_capacity",Number.MAX_SAFE_INTEGER);g(this,"_first",-1);g(this,"_last",-1);g(this,"_size",0);e!==void 0&&(this._capacity=e)}l(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"capacity",get:function t(){return this._capacity}},{key:"first",get:function t(){return this._first}},{key:"last",get:function t(){return this._last}},{key:"size",get:function t(){return this._size}},{key:"addFirst",value:function t(t){if(this.size===0){var e=Math.floor(this.capacity/2);this._first=e,this._last=e}else this._first--;this.nodes[this.first]=t,this._size++}},{key:"addLast",value:function t(t){if(this.size===0){var e=Math.floor(this.capacity/2);this._first=e,this._last=e}else this._last++;this.nodes[this.last]=t,this._size++}},{key:"popFirst",value:function t(){if(!this.size)return;var t=this.getFirst();return delete this.nodes[this.first],this._first++,this._size--,t}},{key:"getFirst",value:function t(){if(this.size)return this.nodes[this.first]}},{key:"popLast",value:function t(){if(!this.size)return;var t=this.getLast();return delete this.nodes[this.last],this._last--,this._size--,t}},{key:"getLast",value:function t(){if(this.size)return this.nodes[this.last]}},{key:"get",value:function t(t){return this.nodes[this.first+t]||null}},{key:"isEmpty",value:function t(){return this.size<=0}}]);return t}(),q=/*#__PURE__*/function(){function t(){u(this,t);g(this,"_nodes",[])}l(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"size",get:function t(){return this.nodes.length}},{key:"addLast",value:function t(t){return this.nodes.push(t)}},{key:"popLast",value:function t(){var t;return(t=this.nodes.pop())!==null&&t!==void 0?t:null}},{key:"popFirst",value:function t(){var t;return(t=this.nodes.shift())!==null&&t!==void 0?t:null}},{key:"addFirst",value:function t(t){return this.nodes.unshift(t)}},{key:"getFirst",value:function t(){var t;return(t=this.nodes[0])!==null&&t!==void 0?t:null}},{key:"getLast",value:function t(){var t;return(t=this.nodes[this.nodes.length-1])!==null&&t!==void 0?t:null}},{key:"get",value:function t(t){var e;return(e=this.nodes[t])!==null&&e!==void 0?e:null}},{key:"set",value:function t(t,e){return this.nodes[t]=e}},{key:"insert",value:function t(t,e){return this.nodes.splice(t,0,e)}},{key:"delete",value:function t(t){return this.nodes.splice(t,1)}},{key:"isEmpty",value:function t(){return this.nodes.length===0}}]);return t}();var U=function t(){return"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g,function(t){var e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})},G=function t(t,e){var r=-1,n=t?t.length:0,i=[];for(;++r<n;){var a=t[r];e(a,r,t)&&(i.push(a),Array.prototype.splice.call(t,r--,1),n--)}return i},W=Symbol("thunk"),Q=function(t){return typeof t=="function"&&t.__THUNK__===W},Y=function(t){var e=function(){return t()};return e.__THUNK__=W,e},X=function(t){return Object.assign(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}var i=t.apply(void 0,w(r));for(;Q(i)&&typeof i=="function";)i=i();return i},{cont:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return Y(function(){return t.apply(void 0,w(r))})}})},J=function(t){return Object.assign(/*#__PURE__*/a(function(){var e,r,n,i;var a=arguments;return T(this,function(u){switch(u.label){case 0:for(e=a.length,r=new Array(e),n=0;n<e;n++){r[n]=a[n]}return[4,t.apply(void 0,w(r))];case 1:i=u.sent();u.label=2;case 2:if(!(Q(i)&&typeof i=="function"))return[3,5];return[4,i()];case 3:i=u.sent();u.label=4;case 4:return[3,2];case 5:return[2,i]}})}),{cont:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return Y(function(){return t.apply(void 0,w(r))})}})},Z=function(t){return t<=0?0:1<<31-Math.clz32(t)};var $=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"_nodes",[]);g(this,"_comparator");this._comparator=e.comparator,e.nodes&&e.nodes.length>0&&(this._nodes=e.nodes,this.fix())}l(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"comparator",get:function t(){return this._comparator}},{key:"size",get:function t(){return this.nodes.length}},{key:"leaf",get:function t(){var t;return(t=this.nodes[this.size-1])!==null&&t!==void 0?t:void 0}},{key:"add",value:function t(t){return this.push(t)}},{key:"push",value:function t(t){return this.nodes.push(t),this.bubbleUp(this.nodes.length-1),this}},{key:"poll",value:function t(){if(this.nodes.length===0)return;if(this.nodes.length===1)return this.nodes.pop();var t=this.nodes[0];return this.nodes[0]=this.nodes.pop(),this.sinkDown(0),t}},{key:"pop",value:function t(){return this.poll()}},{key:"peek",value:function t(){if(this.nodes.length!==0)return this.nodes[0]}},{key:"isEmpty",value:function t(){return this.size===0}},{key:"clear",value:function t(){this._nodes=[]}},{key:"refill",value:function t(t){this._nodes=t,this.fix()}},{key:"has",value:function t(t){return this.nodes.includes(t)}},{key:"dfs",value:function t(t){var e=this;var r=[],n=function(i){i<e.size&&(t==="in"?(n(2*i+1),r.push(e.nodes[i]),n(2*i+2)):t==="pre"?(r.push(e.nodes[i]),n(2*i+1),n(2*i+2)):t==="post"&&(n(2*i+1),n(2*i+2),r.push(e.nodes[i])))};return n(0),r}},{key:"toArray",value:function t(){return w(this.nodes)}},{key:"getNodes",value:function t(){return this.nodes}},{key:"clone",value:function e(){var e=new t({comparator:this.comparator});return e._nodes=w(this.nodes),e}},{key:"sort",value:function t(){var t=[],e=this.clone();for(;e.size!==0;){var r=e.poll();r&&t.push(r)}return t}},{key:"bubbleUp",value:function t(t){var e=this.nodes[t];for(;t>0;){var r=Math.floor((t-1)/2),n=this.nodes[r];if(this.comparator(e,n)<0)this.nodes[t]=n,this.nodes[r]=e,t=r;else break}}},{key:"sinkDown",value:function t(t){var e=2*t+1,r=2*t+2,n=this.nodes.length,i=t;if(e<n&&this.comparator(this.nodes[e],this.nodes[i])<0&&(i=e),r<n&&this.comparator(this.nodes[r],this.nodes[i])<0&&(i=r),i!==t){var a=this.nodes[t];this.nodes[t]=this.nodes[i],this.nodes[i]=a,this.sinkDown(i)}}},{key:"fix",value:function t(){for(var t=Math.floor(this.size/2);t>=0;t--)this.sinkDown(t)}}],[{key:"heapify",value:function e(e){return new t(e)}}]);return t}(),tt=function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;u(this,t);g(this,"element");g(this,"degree");g(this,"left");g(this,"right");g(this,"child");g(this,"parent");g(this,"marked");this.element=e,this.degree=r,this.marked=!1},te=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"_root");g(this,"_size",0);g(this,"_min");g(this,"_comparator");if(this.clear(),this._comparator=e||this.defaultComparator,typeof this.comparator!="function")throw new Error("FibonacciHeap constructor: given comparator should be a function.")}l(t,[{key:"root",get:function t(){return this._root}},{key:"size",get:function t(){return this._size}},{key:"min",get:function t(){return this._min}},{key:"comparator",get:function t(){return this._comparator}},{key:"clear",value:function t(){this._root=void 0,this._min=void 0,this._size=0}},{key:"add",value:function t(t){return this.push(t)}},{key:"push",value:function t(t){var 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}},{key:"peek",value:function t(){return this.min?this.min.element:void 0}},{key:"consumeLinkedList",value:function t(t){var e=[];if(!t)return e;var r=t,n=!1;for(;!(r===t&&n);)r===t&&(n=!0),r&&(e.push(r),r=r.right);return e}},{key:"mergeWithChild",value:function t(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}},{key:"poll",value:function t(){return this.pop()}},{key:"pop",value:function t(){if(this.size===0)return;var t=this.min;if(t.child){var e=this.consumeLinkedList(t.child);var r=true,n=false,i=undefined;try{for(var a=e[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=u.value;this.mergeWithRoot(o),o.parent=void 0}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}}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}},{key:"merge",value:function t(t){if(t.size!==0){if(this.root&&t.root){var e=this.root,r=t.root,n=e.right,i=r.left;e.right=r,r.left=e,n.left=i,i.right=n}(!this.min||t.min&&this.comparator(t.min.element,this.min.element)<0)&&(this._min=t.min),this._size+=t.size,t.clear()}}},{key:"defaultComparator",value:function t(t,e){return t<e?-1:t>e?1:0}},{key:"createNode",value:function t(t){return new tt(t)}},{key:"mergeWithRoot",value:function t(t){this.root?(t.right=this.root.right,t.left=this.root,this.root.right.left=t,this.root.right=t):this._root=t}},{key:"removeFromRoot",value:function t(t){this.root===t&&(this._root=t.right),t.left&&(t.left.right=t.right),t.right&&(t.right.left=t.left)}},{key:"link",value:function t(t,e){this.removeFromRoot(t),t.left=t,t.right=t,this.mergeWithChild(e,t),e.degree++,t.parent=e}},{key:"consolidate",value:function t(){var t=new Array(this.size),e=this.consumeLinkedList(this.root),r,n,i,a;var u=true,o=false,s=undefined;try{for(var l=e[Symbol.iterator](),h;!(u=(h=l.next()).done);u=true){var f=h.value;for(r=f,i=r.degree;t[i];)n=t[i],this.comparator(r.element,n.element)>0&&(a=r,r=n,n=a),this.link(n,r),t[i]=void 0,i++;t[i]=r}}catch(t){o=true;s=t}finally{try{if(!u&&l.return!=null){l.return()}}finally{if(o){throw s}}}for(var v=0;v<this.size;v++)t[v]&&this.comparator(t[v].element,this.min.element)<=0&&(this._min=t[v])}}]);return t}();var tr=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return e-t;throw new Error("The a, b params of compare function must be number")}};u(this,r);return e.call(this,t)}return r}($);var tn=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return t-e;throw new Error("The a, b params of compare function must be number")}};u(this,r);return e.call(this,t)}return r}($);var ti=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t){u(this,r);return e.call(this,t)}return r}($);var ta=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return t-e;throw new Error("The a, b params of compare function must be number")}};u(this,r);return e.call(this,t)}return r}(ti);var tu=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return e-t;throw new Error("The a, b params of compare function must be number")}};u(this,r);return e.call(this,t)}return r}(ti);var to=function t(e,r){u(this,t);g(this,"key");g(this,"value");this.key=e,this.value=r},ts=/*#__PURE__*/function(){function t(e,r){u(this,t);g(this,"value");g(this,"weight");g(this,"_hashCode");this.weight=e!==void 0?e:1,this.value=r,this._hashCode=U()}l(t,[{key:"hashCode",get:function t(){return this._hashCode}}]);return t}(),tl=/*#__PURE__*/function(){function t(){u(this,t);g(this,"_vertices",new Map)}l(t,[{key:"vertices",get:function t(){return this._vertices}},{key:"getVertex",value:function t(t){return this._vertices.get(t)||null}},{key:"hasVertex",value:function t(t){return this._vertices.has(this._getVertexKey(t))}},{key:"addVertex",value:function t(t,e){if(c(t,to))return this._addVertexOnly(t);{var r=this.createVertex(t,e);return this._addVertexOnly(r)}}},{key:"deleteVertex",value:function t(t){var e=this._getVertexKey(t);return this._vertices.delete(e)}},{key:"removeManyVertices",value:function t(t){var e=[];var r=true,n=false,i=undefined;try{for(var a=t[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=u.value;e.push(this.deleteVertex(o))}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}return e.length>0}},{key:"hasEdge",value:function t(t,e){return!!this.getEdge(t,e)}},{key:"addEdge",value:function t(t,e,r,n){if(c(t,ts))return this._addEdgeOnly(t);if(c(e,to)||typeof e=="string"||typeof e=="number"){if(!(this.hasVertex(t)&&this.hasVertex(e)))return!1;c(t,to)&&(t=t.key),c(e,to)&&(e=e.key);var i=this.createEdge(t,e,r,n);return this._addEdgeOnly(i)}else throw new Error("dest must be a Vertex or vertex key while srcOrEdge is an Edge")}},{key:"setEdgeWeight",value:function t(t,e,r){var n=this.getEdge(t,e);return n?(n.weight=r,!0):!1}},{key:"getAllPathsBetween",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e3;var n=[],i=this._getVertex(t),a=this._getVertex(e);if(!(i&&a))return[];var u=[];for(u.push({vertex:i,path:[i]});u.length>0;){var o=u.pop(),s=o.vertex,l=o.path;if(s===a&&(n.push(l),n.length>=r))return n;var h=this.getNeighbors(s);var f=true,v=false,c=undefined;try{for(var d=h[Symbol.iterator](),y;!(f=(y=d.next()).done);f=true){var g=y.value;if(!l.includes(g)){var p=w(l).concat([g]);u.push({vertex:g,path:p})}}}catch(t){v=true;c=t}finally{try{if(!f&&d.return!=null){d.return()}}finally{if(v){throw c}}}}return n}},{key:"getPathSumWeight",value:function t(t){var e;var r=0;for(var n=0;n<t.length;n++)r+=((e=this.getEdge(t[n],t[n+1]))===null||e===void 0?void 0:e.weight)||0;return r}},{key:"getMinCostBetween",value:function t(t,e,r){if(r===void 0&&(r=!1),r){var n=this.getAllPathsBetween(t,e),i=1/0;var a=true,u=false,o=undefined;try{for(var s=n[Symbol.iterator](),l;!(a=(l=s.next()).done);a=true){var h=l.value;i=Math.min(this.getPathSumWeight(h),i)}}catch(t){u=true;o=t}finally{try{if(!a&&s.return!=null){s.return()}}finally{if(u){throw o}}}return i}else{var f=this._getVertex(e),v=this._getVertex(t);if(!(v&&f))return null;var c=new Map,d=new K([v]);c.set(v,!0);var y=0;for(;d.size>0;){for(var g=0;g<d.size;g++){var p=d.shift();if(p===f)return y;if(p!==void 0){var _=this.getNeighbors(p);var k=true,m=false,b=undefined;try{for(var x=_[Symbol.iterator](),w;!(k=(w=x.next()).done);k=true){var N=w.value;c.has(N)||(c.set(N,!0),d.push(N))}}catch(t){m=true;b=t}finally{try{if(!k&&x.return!=null){x.return()}}finally{if(m){throw b}}}}}y++}return null}}},{key:"getMinPathBetween",value:function t(t,e,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;var a;var u;if(r===void 0&&(r=!1),r)if(n){var o=this.getAllPathsBetween(t,e,1e4),s=1/0,l=-1,h=0;var f=true,v=false,c=undefined;try{for(var d=o[Symbol.iterator](),y;!(f=(y=d.next()).done);f=true){var g=y.value;var p=this.getPathSumWeight(g);p<s&&(s=p,l=h),h++}}catch(t){v=true;c=t}finally{try{if(!f&&d.return!=null){d.return()}}finally{if(v){throw c}}}return o[l]||null}else return(u=(a=this.dijkstra(t,e,!0,!0))===null||a===void 0?void 0:a.minPath)!==null&&u!==void 0?u:[];else{var _=[],k=this._getVertex(t),m=this._getVertex(e);if(!(k&&m))return[];var b=function(t,e,r,n){if(r.add(t),t===e){_=[k].concat(w(n));return}var a=i.getNeighbors(t);var u=true,o=false,s=undefined;try{for(var l=a[Symbol.iterator](),h;!(u=(h=l.next()).done);u=true){var f=h.value;r.has(f)||(n.push(f),b(f,e,r,n),n.pop())}}catch(t){o=true;s=t}finally{try{if(!u&&l.return!=null){l.return()}}finally{if(o){throw s}}}r.delete(t)};return b(k,m,new Set,[]),_}}},{key:"dijkstraWithoutHeap",value:function t(t,e,r,n){r===void 0&&(r=!1),n===void 0&&(n=!1),e===void 0&&(e=null);var i=1/0,a=null,u=[],o=[],s=this._vertices,l=new Map,h=new Set,f=new Map,v=this._getVertex(t),d=e?this._getVertex(e):null;if(!v)return null;var y=true,g=false,p=undefined;try{for(var _=s[Symbol.iterator](),k;!(y=(k=_.next()).done);y=true){var m=k.value;var x=m[1];c(x,to)&&l.set(x,1/0)}}catch(t){g=true;p=t}finally{try{if(!y&&_.return!=null){_.return()}}finally{if(g){throw p}}}l.set(v,0),f.set(v,null);var w=function(){var t=1/0,e=null;var r=true,n=false,i=undefined;try{for(var a=l[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=b(u.value,2),s=o[0],f=o[1];h.has(s)||f<t&&(t=f,e=s)}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}return e},N=function(t){var e=true,r=false,n=undefined;try{for(var i=s[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var l=a.value;var h=l[1];if(c(h,to)){var v=[h],d=f.get(h);for(;d;)v.push(d),d=f.get(d);var y=v.reverse();l[1]===t&&(u=y),o.push(y)}}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}};for(var E=1;E<s.size;E++){var M=w();if(M){if(h.add(M),d&&d===M)return r&&(i=l.get(d)||1/0),n&&N(d),{distMap:l,preMap:f,seen:h,paths:o,minDist:i,minPath:u};var S=this.getNeighbors(M);var R=true,T=false,O=undefined;try{for(var z=S[Symbol.iterator](),I;!(R=(I=z.next()).done);R=true){var V=I.value;if(!h.has(V)){var A=this.getEdge(M,V);if(A){var L=l.get(M),C=l.get(V);L!==void 0&&C!==void 0&&A.weight+L<C&&(l.set(V,A.weight+L),f.set(V,M))}}}}catch(t){T=true;O=t}finally{try{if(!R&&z.return!=null){z.return()}}finally{if(T){throw O}}}}}return r&&l.forEach(function(t,e){e!==v&&t<i&&(i=t,n&&(a=e))}),n&&N(a),{distMap:l,preMap:f,seen:h,paths:o,minDist:i,minPath:u}}},{key:"dijkstra",value:function t(t,e,r,n){r===void 0&&(r=!1),n===void 0&&(n=!1),e===void 0&&(e=null);var i=1/0,a=null,u=[],o=[],s=this._vertices,l=new Map,h=new Set,f=new Map,v=this._getVertex(t),d=e?this._getVertex(e):null;if(!v)return null;var y=true,g=false,p=undefined;try{for(var _=s[Symbol.iterator](),k;!(y=(k=_.next()).done);y=true){var m=k.value;var b=m[1];c(b,to)&&l.set(b,1/0)}}catch(t){g=true;p=t}finally{try{if(!y&&_.return!=null){_.return()}}finally{if(g){throw p}}}var x=new ti({comparator:function(t,e){return t.key-e.key}});x.add({key:0,value:v}),l.set(v,0),f.set(v,null);var w=function(t){var e=true,r=false,n=undefined;try{for(var i=s[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var l=a.value;var h=l[1];if(c(h,to)){var v=[h],d=f.get(h);for(;d;)v.push(d),d=f.get(d);var y=v.reverse();l[1]===t&&(u=y),o.push(y)}}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}};for(;x.size>0;){var N=x.poll(),E=N===null||N===void 0?void 0:N.key,M=N===null||N===void 0?void 0:N.value;if(E!==void 0&&M){if(h.add(M),d&&d===M)return r&&(i=l.get(d)||1/0),n&&w(d),{distMap:l,preMap:f,seen:h,paths:o,minDist:i,minPath:u};var S=this.getNeighbors(M);var R=true,T=false,O=undefined;try{for(var z=S[Symbol.iterator](),I;!(R=(I=z.next()).done);R=true){var V=I.value;if(!h.has(V)){var A;var L=(A=this.getEdge(M,V))===null||A===void 0?void 0:A.weight;if(typeof L=="number"){var C=l.get(V);C&&E+L<C&&(x.add({key:E+L,value:V}),f.set(V,M),l.set(V,E+L))}}}}catch(t){T=true;O=t}finally{try{if(!R&&z.return!=null){z.return()}}finally{if(T){throw O}}}}}return r&&l.forEach(function(t,e){e!==v&&t<i&&(i=t,n&&(a=e))}),n&&w(a),{distMap:l,preMap:f,seen:h,paths:o,minDist:i,minPath:u}}},{key:"bellmanFord",value:function t(t,e,r,n){r===void 0&&(r=!1),n===void 0&&(n=!1);var i=this._getVertex(t),a=[],u=new Map,o=new Map,s=1/0,l=[],h;if(e&&(h=!1),!i)return{hasNegativeCycle:h,distMap:u,preMap:o,paths:a,min:s,minPath:l};var f=this._vertices,v=f.size,d=this.edgeSet(),y=d.length;this._vertices.forEach(function(t){u.set(t,1/0)}),u.set(i,0);for(var g=1;g<v;++g)for(var p=0;p<y;++p){var _=this.getEndsOfEdge(d[p]);if(_){var k=b(_,2),m=k[0],x=k[1],w=d[p].weight,N=u.get(m),E=u.get(x);N!==void 0&&E!==void 0&&u.get(m)!==1/0&&N+w<E&&(u.set(x,N+w),n&&o.set(x,m))}}var M=null;var S=true,R=false,T=undefined;if(r&&u.forEach(function(t,e){e!==i&&t<s&&(s=t,n&&(M=e))}),n)try{for(var O=f[Symbol.iterator](),z;!(S=(z=O.next()).done);S=true){var I=z.value;var V=I[1];if(c(V,to)){var A=[V],L=o.get(V);for(;L!==void 0;)A.push(L),L=o.get(L);var C=A.reverse();I[1]===M&&(l=C),a.push(C)}}}catch(t){R=true;T=t}finally{try{if(!S&&O.return!=null){O.return()}}finally{if(R){throw T}}}for(var P=0;P<y;++P){var F=this.getEndsOfEdge(d[P]);if(F){var j=b(F,1),D=j[0],K=d[P].weight,H=u.get(D);H&&H!==1/0&&H+K<H&&(h=!0)}}return{hasNegativeCycle:h,distMap:u,preMap:o,paths:a,min:s,minPath:l}}},{key:"floydWarshall",value:function t(){var t;var e=w(this._vertices),r=e.length,n=[],i=[];for(var a=0;a<r;a++){n[a]=[],i[a]=[];for(var u=0;u<r;u++)i[a][u]=null}for(var o=0;o<r;o++)for(var s=0;s<r;s++)n[o][s]=((t=this.getEdge(e[o][1],e[s][1]))===null||t===void 0?void 0:t.weight)||1/0;for(var l=0;l<r;l++)for(var h=0;h<r;h++)for(var f=0;f<r;f++)n[h][f]>n[h][l]+n[l][f]&&(n[h][f]=n[h][l]+n[l][f],i[h][f]=e[l][1]);return{costs:n,predecessor:i}}},{key:"tarjan",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;t===void 0&&(t=!1),e===void 0&&(e=!1),r===void 0&&(r=!1),n===void 0&&(n=!1);var a=new Map,u=new Map,o=this._vertices;o.forEach(function(t){a.set(t,-1),u.set(t,1/0)});var s=b(o.values(),1),l=s[0],h=[],f=[],v=0,c=function(r,n){v++,a.set(r,v),u.set(r,v);var o=i.getNeighbors(r),s=0;var d=true,y=false,g=undefined;try{for(var p=o[Symbol.iterator](),_;!(d=(_=p.next()).done);d=true){var k=_.value;if(k!==n){a.get(k)===-1&&(s++,c(k,r));var m=u.get(k),b=u.get(r);b!==void 0&&m!==void 0&&u.set(r,Math.min(b,m));var x=a.get(r);if(m!==void 0&&x!==void 0&&(t&&(r===l&&s>=2||r!==l&&m>=x)&&h.push(r),e&&m>x)){var w=i.getEdge(r,k);w&&f.push(w)}}}}catch(t){y=true;g=t}finally{try{if(!d&&p.return!=null){p.return()}}finally{if(y){throw g}}}};c(l,null);var d=new Map,y=function(){var t=new Map;return u.forEach(function(e,r){var n;t.has(e)?(n=t.get(e))===null||n===void 0?void 0:n.push(r):t.set(e,[r])}),t};r&&(d=y());var g=new Map;if(n){var p=new Map;p.size<1&&(p=y()),p.forEach(function(t,e){t.length>1&&g.set(e,t)})}return{dfnMap:a,lowMap:u,bridges:f,cutVertexes:h,SCCs:d,cycles:g}}},{key:"getDFNMap",value:function t(){return this.tarjan(!1,!1,!1,!1).dfnMap}},{key:"getLowMap",value:function t(){return this.tarjan(!1,!1,!1,!1).lowMap}},{key:"getCycles",value:function t(){return this.tarjan(!1,!1,!1,!0).cycles}},{key:"getCutVertexes",value:function t(){return this.tarjan(!0,!1,!1,!1).cutVertexes}},{key:"getSCCs",value:function t(){return this.tarjan(!1,!1,!0,!1).SCCs}},{key:"getBridges",value:function t(){return this.tarjan(!1,!0,!1,!1).bridges}},{key:"_addVertexOnly",value:function t(t){return this.hasVertex(t)?!1:(this._vertices.set(t.key,t),!0)}},{key:"_getVertex",value:function t(t){var e=this._getVertexKey(t);return this._vertices.get(e)||null}},{key:"_getVertexKey",value:function t(t){return c(t,to)?t.key:t}}]);return t}();var th=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,n){u(this,r);return e.call(this,t,n)}return r}(to),tf=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i,a,o){u(this,r);var s;s=e.call(this,a,o);g(n(s),"src");g(n(s),"dest");s.src=t,s.dest=i;return s}return r}(ts),tv=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){u(this,r);var t;t=e.call(this);g(n(t),"_outEdgeMap",new Map);g(n(t),"_inEdgeMap",new Map);return t}l(r,[{key:"outEdgeMap",get:function t(){return this._outEdgeMap}},{key:"inEdgeMap",get:function t(){return this._inEdgeMap}},{key:"createVertex",value:function t(t,e){return new th(t,e!==null&&e!==void 0?e:t)}},{key:"createEdge",value:function t(t,e,r,n){return new tf(t,e,r!==null&&r!==void 0?r:1,n)}},{key:"getEdge",value:function t(t,e){var r=[];if(t!==null&&e!==null){var n=this._getVertex(t),i=this._getVertex(e);if(n&&i){var a=this._outEdgeMap.get(n);a&&(r=a.filter(function(t){return t.dest===i.key}))}}return r[0]||null}},{key:"deleteEdgeSrcToDest",value:function t(t,e){var r=this._getVertex(t),n=this._getVertex(e),i=null;if(!r||!n)return null;var a=this._outEdgeMap.get(r);a&&G(a,function(t){return t.dest===n.key});var u=this._inEdgeMap.get(n);return u&&(i=G(u,function(t){return t.src===r.key})[0]||null),i}},{key:"deleteEdge",value:function t(t){var e=null,r=this._getVertex(t.src),n=this._getVertex(t.dest);if(r&&n){var i=this._outEdgeMap.get(r);i&&i.length>0&&G(i,function(t){return t.src===r.key});var a=this._inEdgeMap.get(n);a&&a.length>0&&(e=G(a,function(t){return t.dest===n.key})[0])}return e}},{key:"deleteEdgesBetween",value:function t(t,e){var r=[];if(t&&e){var n=this.deleteEdgeSrcToDest(t,e),i=this.deleteEdgeSrcToDest(e,t);n&&r.push(n),i&&r.push(i)}return r}},{key:"incomingEdgesOf",value:function t(t){var e=this._getVertex(t);return e?this.inEdgeMap.get(e)||[]:[]}},{key:"outgoingEdgesOf",value:function t(t){var e=this._getVertex(t);return e?this._outEdgeMap.get(e)||[]:[]}},{key:"degreeOf",value:function t(t){return this.outDegreeOf(t)+this.inDegreeOf(t)}},{key:"inDegreeOf",value:function t(t){return this.incomingEdgesOf(t).length}},{key:"outDegreeOf",value:function t(t){return this.outgoingEdgesOf(t).length}},{key:"edgesOf",value:function t(t){return w(this.outgoingEdgesOf(t)).concat(w(this.incomingEdgesOf(t)))}},{key:"getEdgeSrc",value:function t(t){return this._getVertex(t.src)}},{key:"getEdgeDest",value:function t(t){return this._getVertex(t.dest)}},{key:"getDestinations",value:function t(t){if(t===null)return[];var e=[],r=this.outgoingEdgesOf(t);var n=true,i=false,a=undefined;try{for(var u=r[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){var s=o.value;var l=this.getEdgeDest(s);l&&e.push(l)}}catch(t){i=true;a=t}finally{try{if(!n&&u.return!=null){u.return()}}finally{if(i){throw a}}}return e}},{key:"topologicalSort",value:function t(t){var e=this;t=t!==null&&t!==void 0?t:"key";var r=new Map;var n=true,i=false,a=undefined;try{for(var u=this.vertices[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){var s=o.value;r.set(s[1],0)}}catch(t){i=true;a=t}finally{try{if(!n&&u.return!=null){u.return()}}finally{if(i){throw a}}}var l=[],h=!1,f=function(t){r.set(t,1);var n=e.getDestinations(t);var i=true,a=false,u=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var v=s.value;var c=r.get(v);c===0?f(v):c===1&&(h=!0)}}catch(t){a=true;u=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(a){throw u}}}r.set(t,2),l.push(t)};var v=true,d=false,y=undefined;try{for(var g=this.vertices[Symbol.iterator](),p;!(v=(p=g.next()).done);v=true){var _=p.value;r.get(_[1])===0&&f(_[1])}}catch(t){d=true;y=t}finally{try{if(!v&&g.return!=null){g.return()}}finally{if(d){throw y}}}return h?null:(t==="key"&&(l=l.map(function(t){return c(t,th)?t.key:t})),l.reverse())}},{key:"edgeSet",value:function t(){var t=[];return this._outEdgeMap.forEach(function(e){t=w(t).concat(w(e))}),t}},{key:"getNeighbors",value:function t(t){var e=[],r=this._getVertex(t);if(r){var n=this.outgoingEdgesOf(r);var i=true,a=false,u=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var l=s.value;var h=this._getVertex(l.dest);h&&e.push(h)}}catch(t){a=true;u=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(a){throw u}}}}return e}},{key:"getEndsOfEdge",value:function t(t){if(!this.hasEdge(t.src,t.dest))return null;var e=this._getVertex(t.src),r=this._getVertex(t.dest);return e&&r?[e,r]:null}},{key:"_addEdgeOnly",value:function t(t){if(!(this.hasVertex(t.src)&&this.hasVertex(t.dest)))return!1;var e=this._getVertex(t.src),r=this._getVertex(t.dest);if(e&&r){var n=this._outEdgeMap.get(e);n?n.push(t):this._outEdgeMap.set(e,[t]);var i=this._inEdgeMap.get(r);return i?i.push(t):this._inEdgeMap.set(r,[t]),!0}else return!1}}]);return r}(tl);var tc=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,n){u(this,r);return e.call(this,t,n)}return r}(to),td=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i,a,o){u(this,r);var s;s=e.call(this,a,o);g(n(s),"vertices");s.vertices=[t,i];return s}return r}(ts),ty=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(){u(this,r);var t;t=e.call(this);g(n(t),"_edges");t._edges=new Map;return t}l(r,[{key:"edges",get:function t(){return this._edges}},{key:"createVertex",value:function t(t,e){return new tc(t,e!==null&&e!==void 0?e:t)}},{key:"createEdge",value:function t(t,e,r,n){return new td(t,e,r!==null&&r!==void 0?r:1,n)}},{key:"getEdge",value:function t(t,e){var r=[];if(t!==null&&e!==null){var n;var i=this._getVertex(t),a=this._getVertex(e);i&&a&&(r=(n=this._edges.get(i))===null||n===void 0?void 0:n.filter(function(t){return t.vertices.includes(a.key)}))}return r&&r[0]||null}},{key:"deleteEdgeBetween",value:function t(t,e){var r=this._getVertex(t),n=this._getVertex(e);if(!r||!n)return null;var i=this._edges.get(r),a=null;i&&(a=G(i,function(t){return t.vertices.includes(n.key)})[0]||null);var u=this._edges.get(n);return u&&G(u,function(t){return t.vertices.includes(r.key)}),a}},{key:"deleteEdge",value:function t(t){return this.deleteEdgeBetween(t.vertices[0],t.vertices[1])}},{key:"degreeOf",value:function t(t){var e;var r=this._getVertex(t);return r&&((e=this._edges.get(r))===null||e===void 0?void 0:e.length)||0}},{key:"edgesOf",value:function t(t){var e=this._getVertex(t);return e?this._edges.get(e)||[]:[]}},{key:"edgeSet",value:function t(){var t=new Set;return this._edges.forEach(function(e){e.forEach(function(e){t.add(e)})}),w(t)}},{key:"getNeighbors",value:function t(t){var e=[],r=this._getVertex(t);if(r){var n=this.edgesOf(r);var i=true,a=false,u=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var l=s.value;var h=this._getVertex(l.vertices.filter(function(t){return t!==r.key})[0]);h&&e.push(h)}}catch(t){a=true;u=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(a){throw u}}}}return e}},{key:"getEndsOfEdge",value:function t(t){if(!this.hasEdge(t.vertices[0],t.vertices[1]))return null;var e=this._getVertex(t.vertices[0]),r=this._getVertex(t.vertices[1]);return e&&r?[e,r]:null}},{key:"_addEdgeOnly",value:function t(t){var e=true,r=false,n=undefined;try{for(var i=t.vertices[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var u=a.value;var o=this._getVertex(u);if(o===null)return!1;if(o){var s=this._edges.get(o);s?s.push(t):this._edges.set(o,[t])}}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}return!0}}]);return r}(tl);var tg=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i,a,o){u(this,r);var s;s=e.call(this,t,i);g(n(s),"lat");g(n(s),"long");s.lat=a,s.long=o;return s}return r}(th),tp=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,n,i,a){u(this,r);return e.call(this,t,n,i,a)}return r}(tf),t_=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i){u(this,r);var a;a=e.call(this);g(n(a),"_origin",[0,0]);g(n(a),"_bottomRight");a._origin=t,a._bottomRight=i;return a}l(r,[{key:"origin",get:function t(){return this._origin}},{key:"bottomRight",get:function t(){return this._bottomRight}},{key:"createVertex",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.origin[0],n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.origin[1];return new tg(t,e,r,n)}},{key:"createEdge",value:function t(t,e,r,n){return new tp(t,e,r,n)}}]);return r}(tv);var tk=function(t){return t.ITERATIVE="ITERATIVE",t.RECURSIVE="RECURSIVE",t}(tk||{}),tm=function(t){return t.ROOT="ROOT",t.LEFT="LEFT",t.RIGHT="RIGHT",t.ROOT_LEFT="ROOT_LEFT",t.ROOT_RIGHT="ROOT_RIGHT",t.ISOLATED="ISOLATED",t.MAL_NODE="MAL_NODE",t}(tm||{});var tb=function(t){return t[t.RED=1]="RED",t[t.BLACK=0]="BLACK",t}(tb||{});var tx=function(t){return t.lt="lt",t.eq="eq",t.gt="gt",t}(tx||{});var tw=/*#__PURE__*/function(){function t(e,r){u(this,t);g(this,"key");g(this,"value");g(this,"parent");g(this,"_left");g(this,"_right");this.key=e,this.value=r}l(t,[{key:"left",get:function t(){return this._left},set:function t(t){t&&(t.parent=this),this._left=t}},{key:"right",get:function t(){return this._right},set:function t(t){t&&(t.parent=this),this._right=t}},{key:"familyPosition",get:function t(){var t=this;return this.parent?this.parent.left===t?this.left||this.right?"ROOT_LEFT":"LEFT":this.parent.right===t?this.left||this.right?"ROOT_RIGHT":"RIGHT":"MAL_NODE":this.left||this.right?"ROOT":"ISOLATED"}}]);return t}(),tN=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"iterationType","ITERATIVE");g(this,"_root");g(this,"_size");g(this,"_defaultOneParamCallback",function(t){return t.key});if(e){var r=e.iterationType,n=r===void 0?"ITERATIVE":r;this.iterationType=n}this._size=0}l(t,[{key:"root",get:function t(){return this._root}},{key:"size",get:function t(){return this._size}},{key:"createNode",value:function t(t,e){return new tw(t,e)}},{key:"add",value:function t(t,e){var r=this;var n=function(t,e){var n=new K([t]);for(;n.size>0;){var i=n.shift();if(e&&i.key===e.key){i.value=e.value;return}var a=r._addTo(e,i);if(a!==void 0)return a;i.left&&n.push(i.left),i.right&&n.push(i.right)}},i,a;if(t===null)a=null;else if(this.isNodeKey(t))a=this.createNode(t,e);else if(c(t,tw))a=t;else return;return this.root?i=n(this.root,a):(this._setRoot(a),a?this._size=1:this._size=0,i=this.root),i}},{key:"addMany",value:function t(t,e){var r=this;return t.map(function(t,n){if(c(t,tw))return r.add(t.key,t.value);if(t===null)return r.add(null);var i=e===null||e===void 0?void 0:e[n];return r.add(t,i)})}},{key:"refill",value:function t(t,e){return this.clear(),t.length===this.addMany(t,e).length}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback;var r=[];if(!this.root)return r;(!e||e===this._defaultOneParamCallback)&&c(t,tw)&&(e=function(t){return t});var n=this.getNode(t,e);if(!n)return r;var i=(n===null||n===void 0?void 0:n.parent)?n.parent:null,a,u=n;if(n.left){if(n.left){var o=this.getRightMost(n.left);if(o){var s=o.parent;u=this._swap(n,o),s&&(s.right===o?s.right=o.left:s.left=o.left,a=s)}}}else if(!i)this._setRoot(null);else{var l=n.familyPosition;l==="LEFT"||l==="ROOT_LEFT"?i.left=n.right:(l==="RIGHT"||l==="ROOT_RIGHT")&&(i.right=n.right),a=i}return this._size=this.size-1,r.push({deleted:u,needBalanced:a}),r}},{key:"getDepth",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root;t=this.ensureNotKey(t),e=this.ensureNotKey(e);var r=0;for(;t===null||t===void 0?void 0:t.parent;){if(t===e)return r;r++,t=t.parent}return r}},{key:"getHeight",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;if(t=this.ensureNotKey(t),!t)return-1;if(e==="RECURSIVE"){var r=function(t){if(!t)return-1;var e=r(t.left),n=r(t.right);return Math.max(e,n)+1};return r(t)}else{var n=[{node:t,depth:0}],i=0;for(;n.length>0;){var a=n.pop(),u=a.node,o=a.depth;u.left&&n.push({node:u.left,depth:o+1}),u.right&&n.push({node:u.right,depth:o+1}),i=Math.max(i,o)}return i}}},{key:"getMinHeight",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;if(t=this.ensureNotKey(t),!t)return-1;if(e==="RECURSIVE"){var r=function(t){if(!t||!t.left&&!t.right)return 0;var e=r(t.left),n=r(t.right);return Math.min(e,n)+1};return r(t)}else{var n=[],i=t,a=null,u=new Map;for(;n.length>0||i;)if(i)n.push(i),i=i.left;else if(i=n[n.length-1],!i.right||a===i.right){if(i=n.pop(),i){var o,s;var l=i.left?(o=u.get(i.left))!==null&&o!==void 0?o:-1:-1,h=i.right?(s=u.get(i.right))!==null&&s!==void 0?s:-1:-1;u.set(i,1+Math.min(l,h)),a=i,i=null}}else i=i.right;var f;return(f=u.get(t))!==null&&f!==void 0?f:-1}}},{key:"isPerfectlyBalanced",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root;return this.getMinHeight(t)+1>=this.getHeight(t)}},{key:"getNodes",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.root,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.iterationType;if((!e||e===this._defaultOneParamCallback)&&c(t,tw)&&(e=function(t){return t}),n=this.ensureNotKey(n),!n)return[];var a=[];if(i==="RECURSIVE"){var u=function(n){e(n)===t&&(a.push(n),r)||!n.left&&!n.right||(n.left&&u(n.left),n.right&&u(n.right))};u(n)}else{var o=new K([n]);for(;o.size>0;){var s=o.shift();if(s){if(e(s)===t&&(a.push(s),r))return a;s.left&&o.push(s.left),s.right&&o.push(s.right)}}}return a}},{key:"has",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;return(!e||e===this._defaultOneParamCallback)&&c(t,tw)&&(e=function(t){return t}),this.getNodes(t,e,!0,r,n).length>0}},{key:"getNode",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i;return(!e||e===this._defaultOneParamCallback)&&c(t,tw)&&(e=function(t){return t}),(i=this.getNodes(t,e,!0,r,n)[0])!==null&&i!==void 0?i:null}},{key:"getNodeByKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";if(this.root)if(e==="RECURSIVE"){var r=function(e){if(e.key===t)return e;if(!(!e.left&&!e.right)){if(e.left)return r(e.left);if(e.right)return r(e.right)}};return r(this.root)}else{var n=new K([this.root]);for(;n.size>0;){var i=n.shift();if(i){if(i.key===t)return i;i.left&&n.push(i.left),i.right&&n.push(i.right)}}}}},{key:"ensureNotKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";return this.isNodeKey(t)?this.getNodeByKey(t,e):t}},{key:"get",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i;var a;return(!e||e===this._defaultOneParamCallback)&&c(t,tw)&&(e=function(t){return t}),(a=(i=this.getNode(t,e,r,n))===null||i===void 0?void 0:i.value)!==null&&a!==void 0?a:void 0}},{key:"clear",value:function t(){this._setRoot(void 0),this._size=0}},{key:"isEmpty",value:function t(){return this.size===0}},{key:"getPathToRoot",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;var r=[];if(t=this.ensureNotKey(t),!t)return r;for(;t.parent;)r.push(t),t=t.parent;return r.push(t),e?r.reverse():r}},{key:"getLeftMost",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;var r=this;if(t=this.ensureNotKey(t),!t)return t;if(e==="RECURSIVE"){var n=function(t){return r.isRealNode(t.left)?n(t.left):t};return n(t)}else{var i=X(function(t){return r.isRealNode(t.left)?i.cont(t.left):t});return i(t)}}},{key:"getRightMost",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;var r=this;if(t=this.ensureNotKey(t),!t)return t;if(e==="RECURSIVE"){var n=function(t){return r.isRealNode(t.right)?n(t.right):t};return n(t)}else{var i=X(function(t){return r.isRealNode(t.right)?i.cont(t.right):t});return i(t)}}},{key:"isSubtreeBST",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;if(t=this.ensureNotKey(t),!t)return!0;if(e==="RECURSIVE"){var r=function(t,e,n){return t?t.key<=e||t.key>=n?!1:r(t.left,e,t.key)&&r(t.right,t.key,n):!0};return r(t,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)}else{var n=[],i=Number.MIN_SAFE_INTEGER,a=t;for(;a||n.length>0;){for(;a;)n.push(a),a=a.left;if(a=n.pop(),!a||i>=a.key)return!1;i=a.key,a=a.right}return!0}}},{key:"isBST",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;return this.root===null?!0:this.isSubtreeBST(this.root,t)}},{key:"subTreeTraverse",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.iterationType,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;e=this.ensureNotKey(e);var a=[];if(!e)return a;if(r==="RECURSIVE"){var u=function(e){e!==void 0&&(a.push(t(e)),n?(e&&i.isNodeOrNull(e.left)&&u(e.left),e&&i.isNodeOrNull(e.right)&&u(e.right)):(e&&e.left&&u(e.left),e&&e.right&&u(e.right)))};u(e)}else{var o=[e];for(;o.length>0;){var s=o.pop();s!==void 0&&(a.push(t(s)),n?(s&&this.isNodeOrNull(s.right)&&o.push(s.right),s&&this.isNodeOrNull(s.left)&&o.push(s.left)):(s&&s.right&&o.push(s.right),s&&s.left&&o.push(s.left)))}}return a}},{key:"isRealNode",value:function t(t){return c(t,tw)&&t.key.toString()!=="NaN"}},{key:"isNIL",value:function t(t){return c(t,tw)&&t.key.toString()==="NaN"}},{key:"isNodeOrNull",value:function t(t){return this.isRealNode(t)||t===null}},{key:"isNodeKey",value:function t(t){return typeof t=="number"}},{key:"dfs",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"in",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"ITERATIVE",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;var a=this;if(r=this.ensureNotKey(r),!r)return[];var u=[];if(n==="RECURSIVE"){var o=function(r){switch(e){case"in":i?(r&&a.isNodeOrNull(r.left)&&o(r.left),a.isNodeOrNull(r)&&u.push(t(r)),r&&a.isNodeOrNull(r.right)&&o(r.right)):(r&&r.left&&o(r.left),a.isRealNode(r)&&u.push(t(r)),r&&r.right&&o(r.right));break;case"pre":i?(a.isNodeOrNull(r)&&u.push(t(r)),r&&a.isNodeOrNull(r.left)&&o(r.left),r&&a.isNodeOrNull(r.right)&&o(r.right)):(a.isRealNode(r)&&u.push(t(r)),r&&r.left&&o(r.left),r&&r.right&&o(r.right));break;case"post":i?(r&&a.isNodeOrNull(r.left)&&o(r.left),r&&a.isNodeOrNull(r.right)&&o(r.right),a.isNodeOrNull(r)&&u.push(t(r))):(r&&r.left&&o(r.left),r&&r.right&&o(r.right),a.isRealNode(r)&&u.push(t(r)));break}};o(r)}else{var s=[{opt:0,node:r}];for(;s.length>0;){var l=s.pop();if(!(l===void 0||this.isNIL(l.node))){if(i){if(l.node===void 0)continue}else if(l.node===null||l.node===void 0)continue;if(l.opt===1)u.push(t(l.node));else switch(e){case"in":l.node&&s.push({opt:0,node:l.node.right}),s.push({opt:1,node:l.node}),l.node&&s.push({opt:0,node:l.node.left});break;case"pre":l.node&&s.push({opt:0,node:l.node.right}),l.node&&s.push({opt:0,node:l.node.left}),s.push({opt:1,node:l.node});break;case"post":s.push({opt:1,node:l.node}),l.node&&s.push({opt:0,node:l.node.right}),l.node&&s.push({opt:0,node:l.node.left});break;default:l.node&&s.push({opt:0,node:l.node.right}),s.push({opt:1,node:l.node}),l.node&&s.push({opt:0,node:l.node.left});break}}}}return u}},{key:"bfs",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.iterationType,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;if(e=this.ensureNotKey(e),!e)return[];var a=[];if(r==="RECURSIVE"){var u=new K([e]),o=function(e){if(u.size===0)return;var r=u.shift();a.push(t(r)),n?(r&&i.isNodeOrNull(r.left)&&u.push(r.left),r&&i.isNodeOrNull(r.right)&&u.push(r.right)):(r.left&&u.push(r.left),r.right&&u.push(r.right)),o(e+1)};o(0)}else{var s=new K([e]);for(;s.size>0;){var l=s.size;for(var h=0;h<l;h++){var f=s.shift();a.push(t(f)),n?(f&&this.isNodeOrNull(f.left)&&s.push(f.left),f&&this.isNodeOrNull(f.right)&&s.push(f.right)):(f.left&&s.push(f.left),f.right&&s.push(f.right))}}}return a}},{key:"listLevels",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.iterationType,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;e=this.ensureNotKey(e);var a=[];if(!e)return a;if(r==="RECURSIVE"){var u=function(e,r){a[r]||(a[r]=[]),a[r].push(t(e)),n?(e&&i.isNodeOrNull(e.left)&&u(e.left,r+1),e&&i.isNodeOrNull(e.right)&&u(e.right,r+1)):(e&&e.left&&u(e.left,r+1),e&&e.right&&u(e.right,r+1))};u(e,0)}else{var o=[[e,0]];for(;o.length>0;){var s=o.pop(),l=b(s,2),h=l[0],f=l[1];a[f]||(a[f]=[]),a[f].push(t(h)),n?(h&&this.isNodeOrNull(h.right)&&o.push([h.right,f+1]),h&&this.isNodeOrNull(h.left)&&o.push([h.left,f+1])):(h&&h.right&&o.push([h.right,f+1]),h&&h.left&&o.push([h.left,f+1]))}}return a}},{key:"getPredecessor",value:function t(t){if(t=this.ensureNotKey(t),!!this.isRealNode(t))if(t.left){var e=t.left;for(;!this.isRealNode(e)||this.isRealNode(e.right)&&e.right!==t;)e&&(e=e.right);return e}else return t}},{key:"getSuccessor",value:function t(t){if(t=this.ensureNotKey(t),!t)return;if(t.right)return this.getLeftMost(t.right);var e=t.parent;for(;e&&e&&t===e.right;)t=e,e=e.parent;return e}},{key:"morris",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"in",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root;if(r=this.ensureNotKey(r),r===null)return[];var n=[],i=r,a=function(t){var e=null,r=null;for(;t;)r=t.right,t.right=e,e=t,t=r;return e},u=function(e){var r=a(e),i=r;for(;i;)n.push(t(i)),i=i.right;a(r)};switch(e){case"in":for(;i;){if(i.left){var o=this.getPredecessor(i);if(o.right)o.right=null;else{o.right=i,i=i.left;continue}}n.push(t(i)),i=i.right}break;case"pre":for(;i;){if(i.left){var s=this.getPredecessor(i);if(s.right)s.right=null;else{s.right=i,n.push(t(i)),i=i.left;continue}}else n.push(t(i));i=i.right}break;case"post":for(;i;){if(i.left){var l=this.getPredecessor(i);if(l.right===null){l.right=i,i=i.left;continue}else l.right=null,u(i.left)}i=i.right}u(r);break}return n}},{key:Symbol.iterator,value:function t(){var t,e,r,n,i,a;var u=arguments;return T(this,function(o){switch(o.label){case 0:t=u.length>0&&u[0]!==void 0?u[0]:this.root;if(!t)return[3,12];if(!(this.iterationType==="ITERATIVE"))return[3,6];e=[],r=t;o.label=1;case 1:if(!(r||e.length>0))return[3,5];for(;r;)e.push(r),r=r.left;r=e.pop();n=r;if(!n)return[3,3];return[4,r.key];case 2:n=o.sent();o.label=3;case 3:n,r&&(r=r.right);o.label=4;case 4:return[3,1];case 5:return[3,12];case 6:i=t.left;if(!i)return[3,8];return[5,O(this[Symbol.iterator](t.left))];case 7:i=o.sent();o.label=8;case 8:i;return[4,t.key];case 9:o.sent();a=t.right;if(!a)return[3,11];return[5,O(this[Symbol.iterator](t.right))];case 10:a=o.sent();o.label=11;case 11:a;o.label=12;case 12:return[2]}})}},{key:"print",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root;var e=this;if(t=this.ensureNotKey(t),!t)return;var r=function(t){var e=b(n(t),1),r=e[0];var i=true,a=false,u=undefined;try{for(var o=r[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var l=s.value;console.log(l)}}catch(t){a=true;u=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(a){throw u}}}},n=function(t){var r,i;if(!e.isRealNode(t))return[[],0,0,0];if(e.isRealNode(t)&&!e.isRealNode(t.right)&&!e.isRealNode(t.left)){var a="".concat(t.key),u=a.length,o=1,s=Math.floor(u/2);return[[a],u,o,s]}if(e.isRealNode(t)&&!e.isRealNode(t.right)){var l=b(n(t.left),4),h=l[0],f=l[1],v=l[2],c=l[3],d="".concat(t.key),y=d.length,g=" ".repeat(c+1)+"_".repeat(f-c-1)+d,p=" ".repeat(c)+"/"+" ".repeat(f-c-1+y),_=h.map(function(t){return t+" ".repeat(y)});return[[g,p].concat(w(_)),f+y,v+2,f+Math.floor(y/2)]}if(e.isRealNode(t)&&!e.isRealNode(t.left)){var k=b(n(t.right),4),m=k[0],x=k[1],N=k[2],E=k[3],M="".concat(t.key),S=M.length,R=M+"_".repeat(S)+" ".repeat(x-S),T=" ".repeat(E+S)+"\\"+" ".repeat(x-S-1),O=m.map(function(t){return" ".repeat(E)+t});return[[R,T].concat(w(O)),x+S,N+2,Math.floor(E/2)]}var z=b(n(t.left),4),I=z[0],V=z[1],A=z[2],L=z[3],C=b(n(t.right),4),P=C[0],F=C[1],j=C[2],D=C[3],K="".concat(t.key),H=K.length,B=" ".repeat(L+1)+"_".repeat(V-L-1)+K+"_".repeat(D)+" ".repeat(F-D),q=" ".repeat(L)+"/"+" ".repeat(V-L-1+H+D)+"\\"+" ".repeat(F-D-1);A<j?(r=I).push.apply(r,w(new Array(j-A).fill(" ".repeat(V)))):j<A&&(i=P).push.apply(i,w(new Array(A-j).fill(" ".repeat(F))));var U=I.map(function(t,e){return t+" ".repeat(H)+P[e]});return[[B,q].concat(w(U)),V+F+H,Math.max(A,j)+2,V+Math.floor(H/2)]};r(t)}},{key:"_swap",value:function t(t,e){if(t=this.ensureNotKey(t),e=this.ensureNotKey(e),t&&e){var r=e.key,n=e.value,i=this.createNode(r,n);return i&&(e.key=t.key,e.value=t.value,t.key=i.key,t.value=i.value),e}}},{key:"_addTo",value:function t(t,e){if(this.isNodeKey(e)&&(e=this.getNode(e)),e)return e.left===void 0?(e.left=t,t&&(this._size=this.size+1),e.left):e.right===void 0?(e.right=t,t&&(this._size=this.size+1),e.right):void 0}},{key:"_setRoot",value:function t(t){t&&(t.parent=void 0),this._root=t}}]);return t}();var tE=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i){u(this,r);var a;a=e.call(this,t,i);g(n(a),"parent");g(n(a),"_left");g(n(a),"_right");a.parent=void 0,a._left=void 0,a._right=void 0;return a}l(r,[{key:"left",get:function t(){return this._left},set:function t(t){t&&(t.parent=this),this._left=t}},{key:"right",get:function t(){return this._right},set:function t(t){t&&(t.parent=this),this._right=t}}]);return r}(tw),tM=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t){u(this,r);var i;i=e.call(this,t);g(n(i),"_root");g(n(i),"_comparator",function(t,e){return t-e});if(i._root=void 0,t!==void 0){var a=t.comparator;a!==void 0&&(i._comparator=a)}return i}l(r,[{key:"root",get:function t(){return this._root}},{key:"createNode",value:function t(t,e){return new tE(t,e)}},{key:"add",value:function t(t,e){if(t===null)return;var r,n;if(c(t,tE)?n=t:this.isNodeKey(t)?n=this.createNode(t,e):n=void 0,this.root===void 0)this._setRoot(n),this._size=this.size+1,r=this.root;else{var i=this.root,a=!0;for(;a;)i!==void 0&&n!==void 0?this._compare(i.key,n.key)==="eq"?(n&&(i.value=n.value),a=!1,r=i):this._compare(i.key,n.key)==="gt"?i.left===void 0?(n&&(n.parent=i),i.left=n,this._size=this.size+1,a=!1,r=i.left):i.left&&(i=i.left):this._compare(i.key,n.key)==="lt"&&(i.right===void 0?(n&&(n.parent=i),i.right=n,this._size=this.size+1,a=!1,r=i.right):i.right&&(i=i.right)):a=!1}return r}},{key:"addMany",value:function t(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var a=this;function u(t){return t.indexOf(void 0)===-1}if(!n||!u(t))return h(f(r.prototype),"addMany",this).call(this,t,e).map(function(t){return t!==null&&t!==void 0?t:void 0});var o=[],s=t.map(function(t,r){return[t,e===null||e===void 0?void 0:e[r]]}),l=[];function v(t){var e=true,r=false,n=undefined;try{for(var i=t[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var u=b(a.value,1),o=u[0];if(c(o,tE))return!0}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}return!1}var d=function(t){var e=true,r=false,n=undefined;try{for(var i=t[Symbol.iterator](),u;!(e=(u=i.next()).done);e=true){var o=b(u.value,1),s=o[0];if(a.isNodeKey(s))return!0}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}return!1},y=[],g=[];if(v(s))l=s.sort(function(t,e){return t[0].key-e[0].key});else if(d(s))l=s.sort(function(t,e){return t[0]-e[0]});else throw new Error("Invalid input keysOrNodes");y=l.map(function(t){var e=b(t,1),r=e[0];return r}),g=l.map(function(t){var e=b(t,2),r=e[1];return r});var p=function(t,e){if(t.length===0)return;var r=Math.floor((t.length-1)/2),n=a.add(t[r],e===null||e===void 0?void 0:e[r]);o.push(n),p(t.slice(0,r),e===null||e===void 0?void 0:e.slice(0,r)),p(t.slice(r+1),e===null||e===void 0?void 0:e.slice(r+1))},_=function(){var t=[[0,l.length-1]];for(;t.length>0;){var e=t.pop();if(e){var r=b(e,2),n=r[0],i=r[1];if(n<=i){var u=n+Math.floor((i-n)/2),s=a.add(y[u],g===null||g===void 0?void 0:g[u]);o.push(s),t.push([u+1,i]),t.push([n,u-1])}}}};return i==="RECURSIVE"?p(y,g):_(),o}},{key:"lastKey",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;var r,n,i;var a,u,o;return this._compare(0,1)==="lt"?(a=(r=this.getRightMost(t,e))===null||r===void 0?void 0:r.key)!==null&&a!==void 0?a:0:this._compare(0,1)==="gt"?(u=(n=this.getLeftMost(t,e))===null||n===void 0?void 0:n.key)!==null&&u!==void 0?u:0:(o=(i=this.getRightMost(t,e))===null||i===void 0?void 0:i.key)!==null&&o!==void 0?o:0}},{key:"getNodeByKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";var r=this;if(this.root)if(e==="RECURSIVE"){var n=function(e){if(e.key===t)return e;if(!(!e.left&&!e.right)){if(r._compare(e.key,t)==="gt"&&e.left)return n(e.left);if(r._compare(e.key,t)==="lt"&&e.right)return n(e.right)}};return n(this.root)}else{var i=new K([this.root]);for(;i.size>0;){var a=i.shift();if(a){if(this._compare(a.key,t)==="eq")return a;this._compare(a.key,t)==="gt"&&a.left&&i.push(a.left),this._compare(a.key,t)==="lt"&&a.right&&i.push(a.right)}}}}},{key:"ensureNotKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";return this.isNodeKey(t)?this.getNodeByKey(t,e):t}},{key:"getNodes",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.root,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.iterationType;var a=this;if(n=this.ensureNotKey(n),!n)return[];var u=[];if(i==="RECURSIVE"){var o=function(n){e(n)===t&&(u.push(n),r)||!n.left&&!n.right||(e===a._defaultOneParamCallback?(a._compare(n.key,t)==="gt"&&n.left&&o(n.left),a._compare(n.key,t)==="lt"&&n.right&&o(n.right)):(n.left&&o(n.left),n.right&&o(n.right)))};o(n)}else{var s=new K([n]);for(;s.size>0;){var l=s.shift();if(l){if(e(l)===t&&(u.push(l),r))return u;e===this._defaultOneParamCallback?(this._compare(l.key,t)==="gt"&&l.left&&s.push(l.left),this._compare(l.key,t)==="lt"&&l.right&&s.push(l.right)):(l.left&&s.push(l.left),l.right&&s.push(l.right))}}}return u}},{key:"lesserOrGreaterTraverse",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"lt",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i=this;r=this.ensureNotKey(r);var a=[];if(!r||!this.root)return a;var u=r.key;if(n==="RECURSIVE"){var o=function(r){i._compare(r.key,u)===e&&a.push(t(r)),!(!r.left&&!r.right)&&(r.left&&i._compare(r.left.key,u)===e&&o(r.left),r.right&&i._compare(r.right.key,u)===e&&o(r.right))};return o(this.root),a}else{var s=new K([this.root]);for(;s.size>0;){var l=s.shift();l&&(this._compare(l.key,u)===e&&a.push(t(l)),l.left&&this._compare(l.left.key,u)===e&&s.push(l.left),l.right&&this._compare(l.right.key,u)===e&&s.push(l.right))}return a}}},{key:"perfectlyBalance",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;var e=this;var r=this.dfs(function(t){return t},"in"),n=r.length;if(this.clear(),r.length<1)return!1;if(t==="RECURSIVE"){var i=function(t,n){if(t>n)return;var a=t+Math.floor((n-t)/2),u=r[a];e.add(u.key,u.value),i(t,a-1),i(a+1,n)};return i(0,n-1),!0}else{var a=[[0,n-1]];for(;a.length>0;){var u=a.pop();if(u){var o=b(u,2),s=o[0],l=o[1];if(s<=l){var h=s+Math.floor((l-s)/2),f=r[h];debugger;this.add(f.key,f.value),a.push([h+1,l]),a.push([s,h-1])}}}return!0}}},{key:"isAVLBalanced",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;if(!this.root)return!0;var e=!0;if(t==="RECURSIVE"){var r=function(t){if(!t)return 0;var n=r(t.left),i=r(t.right);return Math.abs(n-i)>1&&(e=!1),Math.max(n,i)+1};r(this.root)}else{var n=[],i=this.root,a,u=new Map;for(;n.length>0||i;)if(i)n.push(i),i=i.left;else if(i=n[n.length-1],!i.right||a===i.right){if(i=n.pop(),i){var o,s;var l=i.left?(o=u.get(i.left))!==null&&o!==void 0?o:-1:-1,h=i.right?(s=u.get(i.right))!==null&&s!==void 0?s:-1:-1;if(Math.abs(l-h)>1)return!1;u.set(i,1+Math.max(l,h)),a=i,i=void 0}}else i=i.right}return e}},{key:"_setRoot",value:function t(t){t&&(t.parent=void 0),this._root=t}},{key:"_compare",value:function t(t,e){var r=this._comparator(t,e);return r>0?"gt":r<0?"lt":"eq"}}]);return r}(tN);var tS=/*#__PURE__*/function(){function t(e){var r=e.frequency,n=r===void 0?0:r,i=e.max;u(this,t);g(this,"_freq");g(this,"_max");g(this,"_freqMap");g(this,"_msb");g(this,"_negativeCount");this._freq=n,this._max=i,this._freqMap={0:0},this._msb=Z(i),this._negativeCount=n<0?i:0}l(t,[{key:"freqMap",get:function t(){return this._freqMap}},{key:"msb",get:function t(){return this._msb}},{key:"negativeCount",get:function t(){return this._negativeCount}},{key:"freq",get:function t(){return this._freq}},{key:"max",get:function t(){return this._max}},{key:"readSingle",value:function t(t){return this._checkIndex(t),this._readSingle(t)}},{key:"update",value:function t(t,e){this._checkIndex(t);var r=this._readSingle(t);this._update(t,e),this._updateNegativeCount(r,r+e)}},{key:"writeSingle",value:function t(t,e){this._checkIndex(t),this._writeSingle(t,e)}},{key:"read",value:function t(t){if(!Number.isInteger(t))throw new Error("Invalid count");return this._read(Math.max(Math.min(t,this.max),0))}},{key:"lowerBound",value:function t(t){if(this.negativeCount>0)throw new Error("Sequence is not non-descending");return this._binarySearch(t,function(t,e){return t<e})}},{key:"upperBound",value:function t(t){if(this.negativeCount>0)throw new Error("Must not be descending");return this._binarySearch(t,function(t,e){return t<=e})}},{key:"getPrefixSum",value:function t(t){this._checkIndex(t),t++;var e=0;for(;t>0;)e+=this._getFrequency(t),t-=t&-t;return e}},{key:"_getFrequency",value:function t(t){return t in this.freqMap?this.freqMap[t]:this.freq*(t&-t)}},{key:"_updateFrequency",value:function t(t,e){this.freqMap[t]=this._getFrequency(t)+e}},{key:"_checkIndex",value:function t(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).")}},{key:"_readSingle",value:function t(t){t=t+1;var e=this._getFrequency(t),r=t-(t&-t);for(t--;t!==r;)e-=this._getFrequency(t),t-=t&-t;return e}},{key:"_updateNegativeCount",value:function t(t,e){t<0&&e>=0?this._negativeCount--:t>=0&&e<0&&this._negativeCount++}},{key:"_update",value:function t(t,e){for(t=t+1;t<=this.max;)this._updateFrequency(t,e),t+=t&-t}},{key:"_writeSingle",value:function t(t,e){var r=this._readSingle(t);this._update(t,e-r),this._updateNegativeCount(r,e)}},{key:"_read",value:function t(t){var e=t,r=0;for(;e;)r+=this._getFrequency(e),e-=e&-e;return r}},{key:"_binarySearch",value:function t(t,e){var r=0,n=this.msb<<1,i=t;for(;n>r+1;){var a=r+n>>1,u=this._getFrequency(a);a<=this.max&&e(u,i)?(i-=u,r=a):n=a}return r}}]);return t}();var tR=function t(e,r,n,i){u(this,t);g(this,"start",0);g(this,"end",0);g(this,"value",null);g(this,"sum",0);g(this,"left",null);g(this,"right",null);this.start=e,this.end=r,this.sum=n,this.value=i||null},tT=/*#__PURE__*/function(){function t(e,r,n){u(this,t);g(this,"_values",[]);g(this,"_start",0);g(this,"_end");g(this,"_root");r=r||0,n=n||e.length-1,this._values=e,this._start=r,this._end=n,e.length>0?this._root=this.build(r,n):(this._root=null,this._values=[])}l(t,[{key:"values",get:function t(){return this._values}},{key:"start",get:function t(){return this._start}},{key:"end",get:function t(){return this._end}},{key:"root",get:function t(){return this._root}},{key:"build",value:function t(t,e){if(t>e)return new tR(t,e,0);if(t===e)return new tR(t,e,this._values[t]);var r=t+Math.floor((e-t)/2),n=this.build(t,r),i=this.build(r+1,e),a=new tR(t,e,n.sum+i.sum);return a.left=n,a.right=i,a}},{key:"updateNode",value:function t(t,e,r){var n=this.root||null;if(!n)return;var i=function(t,e,r,n){if(t.start===t.end&&t.start===e){t.sum=r,n!==void 0&&(t.value=n);return}var a=t.start+Math.floor((t.end-t.start)/2);e<=a?t.left&&i(t.left,e,r,n):t.right&&i(t.right,e,r,n),t.left&&t.right&&(t.sum=t.left.sum+t.right.sum)};i(n,t,e,r)}},{key:"querySumByRange",value:function t(t,e){var r=this.root||null;if(!r)return 0;if(t<0||e>=this.values.length||t>e)return NaN;var n=function(t,e,r){if(e<=t.start&&r>=t.end)return t.sum;var i=t.start+Math.floor((t.end-t.start)/2);if(r<=i)return t.left?n(t.left,e,r):NaN;if(e>i)return t.right?n(t.right,e,r):NaN;{var a=0,u=0;return t.left&&(a=n(t.left,e,i)),t.right&&(u=n(t.right,i+1,r)),a+u}};return n(r,t,e)}}]);return t}();var tO=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i){u(this,r);var a;a=e.call(this,t,i);g(n(a),"height");a.height=0;return a}return r}(tE),tz=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t){u(this,r);return e.call(this,t)}l(r,[{key:"createNode",value:function t(t,e){return new tO(t,e)}},{key:"add",value:function t(t,e){if(t===null)return;var n=h(f(r.prototype),"add",this).call(this,t,e);return n&&this._balancePath(n),n}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback;c(t,tO)&&(e=function(t){return t});var n=h(f(r.prototype),"delete",this).call(this,t,e);var i=true,a=false,u=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var l=s.value,v=l.needBalanced;v&&this._balancePath(v)}}catch(t){a=true;u=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(a){throw u}}}return n}},{key:"_swap",value:function t(t,e){if(t=this.ensureNotKey(t),e=this.ensureNotKey(e),t&&e){var r=e.key,n=e.value,i=e.height,a=this.createNode(r,n);return a&&(a.height=i,e.key=t.key,e.value=t.value,e.height=t.height,t.key=a.key,t.value=a.value,t.height=a.height),e}}},{key:"_balanceFactor",value:function t(t){return t.right?t.left?t.right.height-t.left.height:+t.height:-t.height}},{key:"_updateHeight",value:function t(t){if(!t.left&&!t.right)t.height=0;else if(t.left)t.right?t.height=1+Math.max(t.right.height,t.left.height):t.height=1+t.left.height;else{var e=t.right?t.right.height:0;t.height=1+e}}},{key:"_balancePath",value:function t(t){var e=this.getPathToRoot(t,!1);for(var r=0;r<e.length;r++){var n=e[r];switch(this._updateHeight(n),this._balanceFactor(n)){case-2:n&&n.left&&(this._balanceFactor(n.left)<=0?this._balanceLL(n):this._balanceLR(n));break;case 2:n&&n.right&&(this._balanceFactor(n.right)>=0?this._balanceRR(n):this._balanceRL(n))}}}},{key:"_balanceLL",value:function t(t){var e=t.parent,r=t.left;t.parent=r,r&&r.right&&(r.right.parent=t),r&&(r.parent=e),t===this.root?r&&this._setRoot(r):(e===null||e===void 0?void 0:e.left)===t?e.left=r:e&&(e.right=r),r&&(t.left=r.right,r.right=t),this._updateHeight(t),r&&this._updateHeight(r)}},{key:"_balanceLR",value:function t(t){var e=t.parent,r=t.left,n;r&&(n=r.right),t&&(t.parent=n),r&&(r.parent=n),n&&(n.left&&(n.left.parent=r),n.right&&(n.right.parent=t),n.parent=e),t===this.root?n&&this._setRoot(n):e&&(e.left===t?e.left=n:e.right=n),n&&(t.left=n.right,r&&(r.right=n.left),n.left=r,n.right=t),this._updateHeight(t),r&&this._updateHeight(r),n&&this._updateHeight(n)}},{key:"_balanceRR",value:function t(t){var e=t.parent,r=t.right;t.parent=r,r&&(r.left&&(r.left.parent=t),r.parent=e),t===this.root?r&&this._setRoot(r):e&&(e.left===t?e.left=r:e.right=r),r&&(t.right=r.left,r.left=t),this._updateHeight(t),r&&this._updateHeight(r)}},{key:"_balanceRL",value:function t(t){var e=t.parent,r=t.right,n;r&&(n=r.left),t.parent=n,r&&(r.parent=n),n&&(n.left&&(n.left.parent=t),n.right&&(n.right.parent=r),n.parent=e),t===this.root?n&&this._setRoot(n):e&&(e.left===t?e.left=n:e.right=n),n&&(t.right=n.left),r&&n&&(r.left=n.right),n&&(n.left=t),n&&(n.right=r),this._updateHeight(t),r&&this._updateHeight(r),n&&this._updateHeight(n)}}]);return r}(tM);var tI=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;u(this,r);var o;o=e.call(this,t,i);g(n(o),"color");o.color=a;return o}return r}(tE),tV=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t){u(this,r);var i;i=e.call(this,t);g(n(i),"NIL",new tI(NaN));g(n(i),"_root");g(n(i),"_size",0);i._root=i.NIL;return i}l(r,[{key:"root",get:function t(){return this._root}},{key:"size",get:function t(){return this._size}},{key:"add",value:function t(t,e){var r;if(this.isNodeKey(t))r=this.createNode(t,e,1);else if(c(t,tI))r=t;else return void 0;r.left=this.NIL,r.right=this.NIL;var n,i=this.root;for(;i!==this.NIL;)n=i,i&&r.key<i.key?i=i.left:i=i===null||i===void 0?void 0:i.right;if(r.parent=n,n===void 0?this._setRoot(r):r.key<n.key?n.left=r:n.right=r,r.parent===void 0){r.color=0,this._size++;return}if(r.parent.parent===void 0){this._size++;return}this._fixInsert(r),this._size++}},{key:"createNode",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return new tI(t,e,r)}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback;var r=this;var n=[];return t===null||function(n){var i=r.NIL,a,u;for(;n!==r.NIL;)n&&e(n)===t&&(i=n),n&&t&&e(n)<=t?n=n.right:n=n===null||n===void 0?void 0:n.left;if(i===r.NIL){r._size--;return}u=i;var o=u.color;i.left===r.NIL?(a=i.right,r._rbTransplant(i,i.right)):i.right===r.NIL?(a=i.left,r._rbTransplant(i,i.left)):(u=r.getLeftMost(i.right),o=u.color,a=u.right,u.parent===i?a.parent=u:(r._rbTransplant(u,u.right),u.right=i.right,u.right.parent=u),r._rbTransplant(i,u),u.left=i.left,u.left.parent=u,u.color=i.color),o===0&&r._fixDelete(a),r._size--}(this.root),n}},{key:"isRealNode",value:function t(t){return t!==this.NIL&&t!==void 0}},{key:"getNode",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i;return c(t,tw)&&(e=function(t){return t}),r=this.ensureNotKey(r),(i=this.getNodes(t,e,!0,r,n)[0])!==null&&i!==void 0?i:void 0}},{key:"getSuccessor",value:function t(t){var e;if(t.right!==this.NIL)return(e=this.getLeftMost(t.right))!==null&&e!==void 0?e:void 0;var r=t.parent;for(;r!==this.NIL&&r!==void 0&&t===r.right;)t=r,r=r.parent;return r}},{key:"getPredecessor",value:function t(t){if(t.left!==this.NIL)return this.getRightMost(t.left);var e=t.parent;for(;e!==this.NIL&&t===e.left;)t=e,e=e.parent;return e}},{key:"clear",value:function t(){this._root=this.NIL,this._size=0}},{key:"_setRoot",value:function t(t){t&&(t.parent=void 0),this._root=t}},{key:"_leftRotate",value:function t(t){if(t.right){var e=t.right;t.right=e.left,e.left!==this.NIL&&e.left&&(e.left.parent=t),e.parent=t.parent,t.parent===void 0?this._setRoot(e):t===t.parent.left?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}}},{key:"_rightRotate",value:function t(t){if(t.left){var e=t.left;t.left=e.right,e.right!==this.NIL&&e.right&&(e.right.parent=t),e.parent=t.parent,t.parent===void 0?this._setRoot(e):t===t.parent.right?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}}},{key:"_fixDelete",value:function t(t){var e;for(;t!==this.root&&t.color===0;)t.parent&&t===t.parent.left?(e=t.parent.right,e.color===1&&(e.color=0,t.parent.color=1,this._leftRotate(t.parent),e=t.parent.right),e.left!==void 0&&e.left.color===0&&e.right&&e.right.color===0?(e.color=1,t=t.parent):(e.right&&e.right.color===0&&(e.left&&(e.left.color=0),e.color=1,this._rightRotate(e),e=t.parent.right),e&&(e.color=t.parent.color),t.parent.color=0,e&&e.right&&(e.right.color=0),this._leftRotate(t.parent),t=this.root)):(e=t.parent.left,e.color===1&&(e.color=0,t.parent.color=1,this._rightRotate(t.parent),e=t.parent.left),e&&e.right&&e.right.color===0&&e.right.color===0?(e.color=1,t=t.parent):(e&&e.left&&e.left.color===0&&(e.right&&(e.right.color=0),e.color=1,this._leftRotate(e),e=t.parent.left),e&&(e.color=t.parent.color),t.parent.color=0,e&&e.left&&(e.left.color=0),this._rightRotate(t.parent),t=this.root));t.color=0}},{key:"_rbTransplant",value:function t(t,e){t.parent===void 0?this._setRoot(e):t===t.parent.left?t.parent.left=e:t.parent.right=e,e.parent=t.parent}},{key:"_fixInsert",value:function t(t){var e;for(;t.parent&&t.parent.color===1&&(t.parent.parent&&t.parent===t.parent.parent.right?(e=t.parent.parent.left,e&&e.color===1?(e.color=0,t.parent.color=0,t.parent.parent.color=1,t=t.parent.parent):(t===t.parent.left&&(t=t.parent,this._rightRotate(t)),t.parent.color=0,t.parent.parent.color=1,this._leftRotate(t.parent.parent))):(e=t.parent.parent.right,e&&e.color===1?(e.color=0,t.parent.color=0,t.parent.parent.color=1,t=t.parent.parent):(t===t.parent.right&&(t=t.parent,this._leftRotate(t)),t.parent.color=0,t.parent.parent.color=1,this._rightRotate(t.parent.parent))),t!==this.root););this.root.color=0}}]);return r}(tM);var tA=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;u(this,r);var o;o=e.call(this,t,i);g(n(o),"count");o.count=a;return o}return r}(tO),tL=/*#__PURE__*/function(t){v(r,t);var e=R(r);function r(t){u(this,r);var i;i=e.call(this,t);g(n(i),"_count",0);return i}l(r,[{key:"count",get:function t(){return this._count}},{key:"createNode",value:function t(t,e,r){return new tA(t,e,r)}},{key:"add",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;if(t===null)return;var n,i;if(c(t,tA)?i=this.createNode(t.key,t.value,t.count):t===void 0?i=void 0:i=this.createNode(t,e,r),!this.root)this._setRoot(i),this._size=this.size+1,i&&(this._count+=i.count),n=this.root;else{var a=this.root,u=!0;for(;u;)a?i&&(this._compare(a.key,i.key)==="eq"?(a.value=i.value,a.count+=i.count,this._count+=i.count,u=!1,n=a):this._compare(a.key,i.key)==="gt"?a.left===void 0?(a.left=i,this._size=this.size+1,this._count+=i.count,u=!1,n=a.left):a.left&&(a=a.left):this._compare(a.key,i.key)==="lt"&&(a.right===void 0?(a.right=i,this._size=this.size+1,this._count+=i.count,u=!1,n=a.right):a.right&&(a=a.right))):u=!1}return n&&this._balancePath(n),n}},{key:"addMany",value:function t(t,e){var r=[];for(var n=0;n<t.length;n++){var i=t[n];if(c(i,tA)){r.push(this.add(i.key,i.value,i.count));continue}if(i===void 0){r.push(this.add(NaN,void 0,0));continue}r.push(this.add(i,e===null||e===void 0?void 0:e[n],1))}return r}},{key:"perfectlyBalance",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;var e=this;var r=this.dfs(function(t){return t},"in"),n=r.length;if(r.length<1)return!1;if(this.clear(),t==="RECURSIVE"){var i=function(t,n){if(t>n)return;var a=t+Math.floor((n-t)/2),u=r[a];e.add(u.key,u.value,u.count),i(t,a-1),i(a+1,n)};return i(0,n-1),!0}else{var a=[[0,n-1]];for(;a.length>0;){var u=a.pop();if(u){var o=b(u,2),s=o[0],l=o[1];if(s<=l){var h=s+Math.floor((l-s)/2),f=r[h];this.add(f.key,f.value,f.count),a.push([h+1,l]),a.push([s,h-1])}}}return!0}}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;var n=[];if(!this.root)return n;var i;var a=(i=this.getNode(t,e))!==null&&i!==void 0?i:void 0;if(!a)return n;var u=(a===null||a===void 0?void 0:a.parent)?a.parent:void 0,o,s=a;if(a.count>1&&!r)a.count--,this._count--;else{if(a.left){var l=a.left?this.getRightMost(a.left):void 0;if(l){var h=l.parent;s=this._swap(a,l),h&&(h.right===l?h.right=l.left:h.left=l.left,o=h)}}else if(!u)a.right!==void 0&&this._setRoot(a.right);else{var f=a.familyPosition;f==="LEFT"||f==="ROOT_LEFT"?u.left=a.right:(f==="RIGHT"||f==="ROOT_RIGHT")&&(u.right=a.right),o=u}this._size=this.size-1,s&&(this._count-=s.count)}return n.push({deleted:s,needBalanced:o}),o&&this._balancePath(o),n}},{key:"clear",value:function t(){h(f(r.prototype),"clear",this).call(this),this._count=0}},{key:"_addTo",value:function t(t,e){if(e=this.ensureNotKey(e),e)return e.left===void 0?(e.left=t,t!==void 0&&(this._size=this.size+1,this._count+=t.count),e.left):e.right===void 0?(e.right=t,t!==void 0&&(this._size=this.size+1,this._count+=t.count),e.right):void 0}},{key:"_swap",value:function t(t,e){if(t=this.ensureNotKey(t),e=this.ensureNotKey(e),t&&e){var r=e.key,n=e.value,i=e.count,a=e.height,u=this.createNode(r,n,i);return u&&(u.height=a,e.key=t.key,e.value=t.value,e.count=t.count,e.height=t.height,t.key=u.key,t.value=u.value,t.count=u.count,t.height=u.height),e}}}]);return r}(tz);var tC=/*#__PURE__*/function(){function t(e,r,n){u(this,t);g(this,"key");g(this,"value");g(this,"children");this.key=e,this.value=r||void 0,this.children=n||[]}l(t,[{key:"addChildren",value:function e(e){this.children||(this.children=[]),c(e,t)?this.children.push(e):this.children=this.children.concat(e)}},{key:"getHeight",value:function t(){var t=0;if(this){var e=function(r,n){n>t&&(t=n);var i=r.children;if(i)for(var a=0,u=i.length;a<u;a++)e(i[a],n+1)};e(this,0)}return t}}]);return t}();var tP=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"_matrix");var r=e.row,n=e.col,i=e.initialVal;this._matrix=new Array(r).fill(void 0).map(function(){return new Array(n).fill(i||0)})}l(t,[{key:"toArray",value:function t(){return this._matrix}}]);return t}();var tF=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;u(this,t);this.x=e;this.y=r;this.w=n}l(t,[{key:"isZero",get:function t(){return this.x===0&&this.y===0}},{key:"length",get:function t(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"lengthSq",get:function t(){return this.x*this.x+this.y*this.y}},{key:"rounded",get:function e(){return new t(Math.round(this.x),Math.round(this.y))}},{key:"zero",value:function t(){this.x=0,this.y=0}}],[{key:"add",value:function e(e,r){return new t(e.x+r.x,e.y+r.y)}},{key:"subtract",value:function e(e,r){return new t(e.x-r.x,e.y-r.y)}},{key:"subtractValue",value:function e(e,r){return new t(e.x-r,e.y-r)}},{key:"multiply",value:function e(e,r){return new t(e.x*r,e.y*r)}},{key:"divide",value:function e(e,r){return new t(e.x/r,e.y/r)}},{key:"equals",value:function t(t,e){return t.x===e.x&&t.y===e.y}},{key:"equalsRounded",value:function e(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:12;var i=t.abs(t.subtract(e,r));return i.x<n&&i.y<n}},{key:"normalize",value:function e(e){var r=e.length;return r>2220446049250313e-31?t.divide(e,r):e}},{key:"truncate",value:function e(e,r){return e.length>r?t.multiply(t.normalize(e),r):e}},{key:"perp",value:function e(e){return new t(-e.y,e.x)}},{key:"reverse",value:function e(e){return new t(-e.x,-e.y)}},{key:"abs",value:function e(e){return new t(Math.abs(e.x),Math.abs(e.y))}},{key:"dot",value:function t(t,e){return t.x*e.x+t.y*e.y}},{key:"distance",value:function t(t,e){var r=e.y-t.y,n=e.x-t.x;return Math.sqrt(r*r+n*n)}},{key:"distanceSq",value:function t(t,e){var r=e.y-t.y,n=e.x-t.x;return r*r+n*n}},{key:"sign",value:function t(t,e){return t.y*e.x>t.x*e.y?-1:1}},{key:"angle",value:function e(e){var r=new t(0,-1),n=Math.acos(t.dot(e,r)/(e.length*r.length));return t.sign(e,r)===1?Math.PI*2-n:n}},{key:"random",value:function e(e,r){var n=Math.floor(Math.random()*e-e/2),i=Math.floor(Math.random()*r-r/2);return new t(n,i)}}]);return t}();var tj=/*#__PURE__*/function(){function t(e){u(this,t);g(this,"_matrix");(typeof e==="undefined"?"undefined":N(e))>"u"?this._matrix=t.identity:c(e,tF)?(this._matrix=t.identity,this._matrix[0][0]=e.x,this._matrix[1][0]=e.y,this._matrix[2][0]=e.w):this._matrix=e}l(t,[{key:"m",get:function t(){return this._matrix}},{key:"toVector",value:function t(){return new tF(this._matrix[0][0],this._matrix[1][0])}}],[{key:"empty",get:function t(){return[[],[],[]]}},{key:"identity",get:function t(){return[[1,0,0],[0,1,0],[0,0,1]]}},{key:"add",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var a=0;a<3;a++)n[i][a]=e.m[i][a]+r.m[i][a];return new t(n)}},{key:"subtract",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var a=0;a<3;a++)n[i][a]=e.m[i][a]-r.m[i][a];return new t(n)}},{key:"multiply",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var a=0;a<3;a++){n[i][a]=0;for(var u=0;u<3;u++)n[i][a]+=e.m[i][u]*r.m[u][a]}return new t(n)}},{key:"multiplyByValue",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var a=0;a<3;a++)n[i][a]=e.m[i][a]*r;return new t(n)}},{key:"multiplyByVector",value:function e(e,r){return t.multiply(e,new t(r)).toVector()}},{key:"view",value:function e(e,r){var n=e/2,i=r/2,a=Math.cos(Math.PI);return new t([[1,0,n],[0,a*1,i],[0,0,1]])}},{key:"scale",value:function e(e){return t.multiplyByValue(new t,e)}},{key:"rotate",value:function e(e){var r=Math.cos(e),n=Math.sin(e);return new t([[r,-n,0],[n,r,0],[0,0,1]])}},{key:"translate",value:function e(e){return new t([[1,0,e.x],[0,1,e.y],[0,0,e.w]])}}]);return t}();var tD=function t(e,r){u(this,t);g(this,"direction");g(this,"turn");this.direction=e,this.turn=function(){return new t(r[e],r)}},tK=/*#__PURE__*/function(){function t(e){var r=e.matrix,n=e.turning,i=e.onMove,a=e.init,o=a.cur,s=a.charDir,l=a.VISITED;u(this,t);g(this,"onMove");g(this,"_matrix");g(this,"_cur");g(this,"_character");g(this,"_VISITED");this._matrix=r,this._cur=o,this._character=new tD(s,n),this.onMove=i,this.onMove&&this.onMove(this._cur),this._VISITED=l,this._matrix[this._cur[0]][this._cur[1]]=this._VISITED}l(t,[{key:"start",value:function t(){for(;this.check(this._character.direction)||this.check(this._character.turn().direction);){var t=this._character,e=t.direction;this.check(e)?this.move(e):this.check(this._character.turn().direction)&&(this._character=this._character.turn())}}},{key:"check",value:function t(t){var e,r,n=this._matrix,i=b(this._cur,2),a=i[0],u=i[1];switch(t){case"up":if(r=n[a-1],!r)return!1;e=r[u];break;case"right":e=n[a][u+1];break;case"down":if(r=n[a+1],!r)return!1;e=r[u];break;case"left":e=n[a][u-1];break}return e!==void 0&&e!==this._VISITED}},{key:"move",value:function t(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}var e=b(this._cur,2),r=e[0],n=e[1];this._matrix[r][n]=this._VISITED,this.onMove&&this.onMove(this._cur)}}]);return t}();var tH=function t(e){u(this,t);g(this,"key");g(this,"children");g(this,"isEnd");this.key=e,this.isEnd=!1,this.children=new Map},tB=/*#__PURE__*/function(){function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;u(this,t);g(this,"_caseSensitive");g(this,"_root");var n=true,i=false,a=undefined;if(this._root=new tH(""),this._caseSensitive=r,e)try{for(var o=e[Symbol.iterator](),s;!(n=(s=o.next()).done);n=true){var l=s.value;this.add(l)}}catch(t){i=true;a=t}finally{try{if(!n&&o.return!=null){o.return()}}finally{if(i){throw a}}}}l(t,[{key:"caseSensitive",get:function t(){return this._caseSensitive}},{key:"root",get:function t(){return this._root}},{key:"add",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var a=t[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=u.value;var s=e.children.get(o);s||(s=new tH(o),e.children.set(o,s)),e=s}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}return e.isEnd=!0,!0}},{key:"has",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var a=t[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=u.value;var s=e.children.get(o);if(!s)return!1;e=s}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}return e.isEnd}},{key:"delete",value:function t(t){t=this._caseProcess(t);var e=!1,r=function(n,i){var a=t[i],u=n.children.get(a);return u?i===t.length-1?u.isEnd?(u.children.size>0?u.isEnd=!1:n.children.delete(a),e=!0,!0):!1:r(u,i+1)&&!n.isEnd&&u.children.size===0?(n.children.delete(a),!0):!1:!1};return r(this.root,0),e}},{key:"getHeight",value:function t(){var t=this.root,e=0;if(t){var r=function(t,n){n>e&&(e=n);var i=t.children;var a=true,u=false,o=undefined;if(i)try{for(var s=i.entries()[Symbol.iterator](),l;!(a=(l=s.next()).done);a=true){var h=l.value;r(h[1],n+1)}}catch(t){u=true;o=t}finally{try{if(!a&&s.return!=null){s.return()}}finally{if(u){throw o}}}};r(t,0)}return e}},{key:"hasPurePrefix",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var a=t[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=u.value;var s=e.children.get(o);if(!s)return!1;e=s}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}return!e.isEnd}},{key:"hasPrefix",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var a=t[Symbol.iterator](),u;!(r=(u=a.next()).done);r=true){var o=u.value;var s=e.children.get(o);if(!s)return!1;e=s}}catch(t){n=true;i=t}finally{try{if(!r&&a.return!=null){a.return()}}finally{if(n){throw i}}}return!0}},{key:"hasCommonPrefix",value:function t(t){t=this._caseProcess(t);var e="",r=function(n){if(e+=n.key,e!==t&&!n.isEnd)if(n&&n.children&&n.children.size===1)r(Array.from(n.children.values())[0]);else return};return r(this.root),e===t}},{key:"getLongestCommonPrefix",value:function t(){var t="",e=function(r){if(t+=r.key,!r.isEnd)if(r&&r.children&&r.children.size===1)e(Array.from(r.children.values())[0]);else return};return e(this.root),t}},{key:"getWords",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_SAFE_INTEGER,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t=this._caseProcess(t);var n=[],i=0;function a(t,r){var u=true,o=false,s=undefined;try{for(var l=t.children.keys()[Symbol.iterator](),h;!(u=(h=l.next()).done);u=true){var f=h.value;var v=t.children.get(f);v!==void 0&&a(v,r.concat(f))}}catch(t){o=true;s=t}finally{try{if(!u&&l.return!=null){l.return()}}finally{if(o){throw s}}}if(t.isEnd){if(i>e-1)return;n.push(r),i++}}var u=this.root;var o=true,s=false,l=undefined;if(t)try{for(var h=t[Symbol.iterator](),f;!(o=(f=h.next()).done);o=true){var v=f.value;var c=u.children.get(v);c&&(u=c)}}catch(t){s=true;l=t}finally{try{if(!o&&h.return!=null){h.return()}}finally{if(s){throw l}}}return(r||u!==this.root)&&a(u,t),n}},{key:"_caseProcess",value:function t(t){return this._caseSensitive||(t=t.toLowerCase()),t}}]);return t}();return y(p)}();/**
|
|
1
|
+
"use strict";function t(t,e){if(e==null||e>t.length)e=t.length;for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function e(t){if(Array.isArray(t))return t}function r(e){if(Array.isArray(e))return t(e)}function n(t){if(t===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function i(t,e,r,n,i,u,a){try{var o=t[u](a);var s=o.value}catch(t){r(t);return}if(o.done){e(s)}else{Promise.resolve(s).then(n,i)}}function u(t){return function(){var e=this,r=arguments;return new Promise(function(n,u){var a=t.apply(e,r);function o(t){i(a,n,u,o,s,"next",t)}function s(t){i(a,n,u,o,s,"throw",t)}o(undefined)})}}function a(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}}function o(t,e,r){if(R()){o=Reflect.construct}else{o=function t(t,e,r){var n=[null];n.push.apply(n,e);var i=Function.bind.apply(t,n);var u=new i;if(r)m(u,r.prototype);return u}}return o.apply(null,arguments)}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(t,n.key,n)}}function h(t,e,r){if(e)s(t.prototype,e);if(r)s(t,r);return t}function l(t,e,r){if(typeof Reflect!=="undefined"&&Reflect.get){l=Reflect.get}else{l=function t(t,e,r){var n=b(t,e);if(!n)return;var i=Object.getOwnPropertyDescriptor(n,e);if(i.get){return i.get.call(r||t)}return i.value}}return l(t,e,r||t)}function f(t){f=Object.setPrototypeOf?Object.getPrototypeOf:function t(t){return t.__proto__||Object.getPrototypeOf(t)};return f(t)}function v(t,e){if(typeof e!=="function"&&e!==null){throw new TypeError("Super expression must either be null or a function")}t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:true,configurable:true}});if(e)m(t,e)}function c(t,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](t)}else{return t instanceof e}}function d(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function y(t){if(typeof Symbol!=="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function g(t,e){var r=t==null?null:typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(r==null)return;var n=[];var i=true;var u=false;var a,o;try{for(r=r.call(t);!(i=(a=r.next()).done);i=true){n.push(a.value);if(e&&n.length===e)break}}catch(t){u=true;o=t}finally{try{if(!i&&r["return"]!=null)r["return"]()}finally{if(u)throw o}}return n}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(t,e){if(e&&(E(e)==="object"||typeof e==="function")){return e}return n(t)}function m(t,e){m=Object.setPrototypeOf||function t(t,e){t.__proto__=e;return t};return m(t,e)}function x(t,r){return e(t)||g(t,r)||N(t,r)||p()}function b(t,e){while(!Object.prototype.hasOwnProperty.call(t,e)){t=f(t);if(t===null)break}return t}function w(t){return r(t)||y(t)||N(t)||_()}function E(t){"@swc/helpers - typeof";return t&&typeof Symbol!=="undefined"&&t.constructor===Symbol?"symbol":typeof t}function N(e,r){if(!e)return;if(typeof e==="string")return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}function M(t){var e=typeof Map==="function"?new Map:undefined;M=function t(t){if(t===null||!d(t))return t;if(typeof t!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof e!=="undefined"){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return o(t,arguments,f(this).constructor)}r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return m(r,t)};return M(t)}function R(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(t){return false}}function S(t){var e=R();return function r(){var r=f(t),n;if(e){var i=f(this).constructor;n=Reflect.construct(r,arguments,i)}else{n=r.apply(this,arguments)}return k(this,n)}}function O(t,e){var r,n,i,u,a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return u={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function o(t){return function(e){return s([t,e])}}function s(u){if(r)throw new TypeError("Generator is already executing.");while(a)try{if(r=1,n&&(i=u[0]&2?n["return"]:u[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;if(n=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(i=a.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(u[0]===6&&a.label<i[1]){a.label=i[1];i=u;break}if(i&&a.label<i[2]){a.label=i[2];a.ops.push(u);break}if(i[2])a.ops.pop();a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t];n=0}finally{r=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}function T(t){var e=typeof Symbol==="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length==="number")return{next:function(){if(t&&n>=t.length)t=void 0;return{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var dataStructureTyped=function(){var t=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var o=function(e,r,n){return r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n};var s=function(e,r){for(var n in r)t(e,n,{get:r[n],enumerable:!0})},d=function(n,u,a,o){var s=true,h=false,l=undefined;if(u&&typeof u=="object"||typeof u=="function")try{var f=function(){var r=c.value;!i.call(n,r)&&r!==a&&t(n,r,{get:function(){return u[r]},enumerable:!(o=e(u,r))||o.enumerable})};for(var v=r(u)[Symbol.iterator](),c;!(s=(c=v.next()).done);s=true)f()}catch(t){h=true;l=t}finally{try{if(!s&&v.return!=null){v.return()}}finally{if(h){throw l}}}return n};var y=function(e){return d(t({},"__esModule",{value:!0}),e)};var g=function(t,e,r){return o(t,(typeof e==="undefined"?"undefined":E(e))!="symbol"?e+"":e,r),r};var p={};s(p,{AVLTree:function(){return tC},AVLTreeNode:function(){return tL},AbstractEdge:function(){return tp},AbstractGraph:function(){return t_},AbstractVertex:function(){return tg},ArrayDeque:function(){return to},BST:function(){return tI},BSTNode:function(){return tT},BinaryIndexedTree:function(){return tz},BinaryTree:function(){return tO},BinaryTreeNode:function(){return tS},CP:function(){return W},Character:function(){return tU},CoordinateMap:function(){return b},CoordinateSet:function(){return N},Deque:function(){return tu},DirectedEdge:function(){return tm},DirectedGraph:function(){return tx},DirectedVertex:function(){return tk},DoublyLinkedList:function(){return $},DoublyLinkedListNode:function(){return Z},FamilyPosition:function(){return q},FibonacciHeap:function(){return tl},FibonacciHeapNode:function(){return th},HashMap:function(){return X},HashMapIterator:function(){return Y},HashTable:function(){return m},HashTableNode:function(){return _},Heap:function(){return ts},IterateDirection:function(){return G},IterationType:function(){return H},LinkedListQueue:function(){return tn},MapEdge:function(){return tM},MapGraph:function(){return tR},MapVertex:function(){return tN},Matrix2D:function(){return tq},MatrixNTI2D:function(){return tB},MaxHeap:function(){return tf},MaxPriorityQueue:function(){return ty},MinHeap:function(){return tv},MinPriorityQueue:function(){return td},Navigator:function(){return tG},ObjectDeque:function(){return ta},PriorityQueue:function(){return tc},Queue:function(){return ti},RBTNColor:function(){return U},RedBlackTree:function(){return tF},RedBlackTreeNode:function(){return tP},SegmentTree:function(){return tA},SegmentTreeNode:function(){return tV},SinglyLinkedList:function(){return Q},SinglyLinkedListNode:function(){return J},SkipList:function(){return te},SkipListNode:function(){return tt},Stack:function(){return tr},THUNK_SYMBOL:function(){return A},TreeMap:function(){return R},TreeMultimap:function(){return tj},TreeMultimapNode:function(){return tD},TreeNode:function(){return tK},TreeSet:function(){return I},Trie:function(){return tY},TrieNode:function(){return tW},UndirectedEdge:function(){return tw},UndirectedGraph:function(){return tE},UndirectedVertex:function(){return tb},Vector2D:function(){return tH},arrayRemove:function(){return V},getMSB:function(){return D},isObjOrFunc:function(){return B},isThunk:function(){return L},rangeCheck:function(){return j},throwRangeError:function(){return K},toThunk:function(){return C},trampoline:function(){return P},trampolineAsync:function(){return F},uuidV4:function(){return z}});var _=function t(e,r){a(this,t);g(this,"key");g(this,"value");g(this,"next");this.key=e,this.value=r,this.next=null},k=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:t.DEFAULT_CAPACITY,r=arguments.length>1?arguments[1]:void 0;a(this,t);g(this,"_capacity");g(this,"_size");g(this,"_buckets");g(this,"_hashFn");this._hashFn=r||this._defaultHashFn,this._capacity=Math.max(e,t.DEFAULT_CAPACITY),this._size=0,this._buckets=new Array(this._capacity).fill(null)}h(t,[{key:"capacity",get:function t(){return this._capacity}},{key:"size",get:function t(){return this._size}},{key:"buckets",get:function t(){return this._buckets}},{key:"hashFn",get:function t(){return this._hashFn}},{key:"set",value:function e(e,r){var n=this._hash(e),i=new _(e,r);if(!this._buckets[n])this._buckets[n]=i;else{var u=this._buckets[n];for(;u;){if(u.key===e){u.value=r;return}if(!u.next)break;u=u.next}u.next=i}this._size++,this._size/this._capacity>=t.LOAD_FACTOR&&this._expand()}},{key:"get",value:function t(t){var e=this._hash(t),r=this._buckets[e];for(;r;){if(r.key===t)return r.value;r=r.next}}},{key:"delete",value:function t(t){var e=this._hash(t),r=this._buckets[e],n=null;for(;r;){if(r.key===t){n?n.next=r.next:this._buckets[e]=r.next,this._size--,r.next=null;return}n=r,r=r.next}}},{key:"_defaultHashFn",value:function t(t){return(typeof t=="string"?this._murmurStringHashFn(t):this._objectHash(t))%this._capacity}},{key:"_multiplicativeStringHashFn",value:function t(t){var e=String(t),r=0;for(var n=0;n<e.length;n++){var i=e.charCodeAt(n),u=.618033988749895,a=1<<30;r=(r*u+i)%a}return Math.abs(r)}},{key:"_murmurStringHashFn",value:function t(t){var e=String(t),r=0;for(var n=0;n<e.length;n++){var i=e.charCodeAt(n);r=(r^i)*1540483477,r=(r^r>>>15)*668265261,r=r^r>>>15}return Math.abs(r)}},{key:"_hash",value:function t(t){return this.hashFn(t)}},{key:"_stringHash",value:function t(t){var e=0;for(var r=0;r<t.length;r++)e=e*31+t.charCodeAt(r)&4294967295;return e}},{key:"_objectHash",value:function t(t){return this._stringHash(JSON.stringify(t))}},{key:"_expand",value:function t(){var t=this._capacity*2,e=new Array(t).fill(null);var r=true,n=false,i=undefined;try{for(var u=this._buckets[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=a.value;var s=o;for(;s;){var h=this._hash(s.key),l=new _(s.key,s.value);if(!e[h])e[h]=l;else{var f=e[h];for(;f.next;)f=f.next;f.next=l}s=s.next}}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}this._buckets=e,this._capacity=t}}]);return t}();g(k,"DEFAULT_CAPACITY",16),g(k,"LOAD_FACTOR",.75);var m=k;var b=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t){a(this,r);var i;i=e.call(this);g(n(i),"_joint","_");t!==void 0&&(i._joint=t);return i}h(r,[{key:"joint",get:function t(){return this._joint}},{key:"has",value:function t(t){return l(f(r.prototype),"has",this).call(this,t.join(this._joint))}},{key:"set",value:function t(t,e){return l(f(r.prototype),"set",this).call(this,t.join(this._joint),e)}},{key:"get",value:function t(t){return l(f(r.prototype),"get",this).call(this,t.join(this._joint))}},{key:"delete",value:function t(t){return l(f(r.prototype),"delete",this).call(this,t.join(this._joint))}}]);return r}(M(Map));var N=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t){a(this,r);var i;i=e.call(this);g(n(i),"_joint","_");t!==void 0&&(i._joint=t);return i}h(r,[{key:"joint",get:function t(){return this._joint}},{key:"has",value:function t(t){return l(f(r.prototype),"has",this).call(this,t.join(this._joint))}},{key:"add",value:function t(t){return l(f(r.prototype),"add",this).call(this,t.join(this._joint))}},{key:"delete",value:function t(t){return l(f(r.prototype),"delete",this).call(this,t.join(this._joint))}}]);return r}(M(Set));var R=function t(){a(this,t)};var I=function t(){a(this,t)};var z=function t(){return"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g,function(t){var e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})},V=function t(t,e){var r=-1,n=t?t.length:0,i=[];for(;++r<n;){var u=t[r];e(u,r,t)&&(i.push(u),Array.prototype.splice.call(t,r--,1),n--)}return i},A=Symbol("thunk"),L=function(t){return typeof t=="function"&&t.__THUNK__===A},C=function(t){var e=function(){return t()};return e.__THUNK__=A,e},P=function(t){return Object.assign(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}var i=t.apply(void 0,w(r));for(;L(i)&&typeof i=="function";)i=i();return i},{cont:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return C(function(){return t.apply(void 0,w(r))})}})},F=function(t){return Object.assign(/*#__PURE__*/u(function(){var e,r,n,i;var u=arguments;return O(this,function(a){switch(a.label){case 0:for(e=u.length,r=new Array(e),n=0;n<e;n++){r[n]=u[n]}return[4,t.apply(void 0,w(r))];case 1:i=a.sent();a.label=2;case 2:if(!(L(i)&&typeof i=="function"))return[3,5];return[4,i()];case 3:i=a.sent();a.label=4;case 4:return[3,2];case 5:return[2,i]}})}),{cont:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return C(function(){return t.apply(void 0,w(r))})}})},D=function(t){return t<=0?0:1<<31-Math.clz32(t)},j=function(t,e,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"Index out of bounds.";if(t<e||t>r)throw new RangeError(n)},K=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"The value is off-limits.";throw new RangeError(t)},B=function(t){var e=typeof t==="undefined"?"undefined":E(t);return e==="object"&&t!==null||e==="function"};var H=function(t){return t.ITERATIVE="ITERATIVE",t.RECURSIVE="RECURSIVE",t}(H||{}),q=function(t){return t.ROOT="ROOT",t.LEFT="LEFT",t.RIGHT="RIGHT",t.ROOT_LEFT="ROOT_LEFT",t.ROOT_RIGHT="ROOT_RIGHT",t.ISOLATED="ISOLATED",t.MAL_NODE="MAL_NODE",t}(q||{});var U=function(t){return t[t.RED=1]="RED",t[t.BLACK=0]="BLACK",t}(U||{});var G=function(t){return t[t.DEFAULT=0]="DEFAULT",t[t.REVERSE=1]="REVERSE",t}(G||{});var W=function(t){return t.lt="lt",t.eq="eq",t.gt="gt",t}(W||{});var Y=/*#__PURE__*/function(){function t(e,r,n){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;a(this,t);g(this,"hashMap");g(this,"iterateDirection");g(this,"_node");g(this,"_sentinel");this._node=e,this._sentinel=r,this.iterateDirection=i,this.iterateDirection===0?(this.prev=function(){return this._node.prev===this._sentinel&&K(),this._node=this._node.prev,this},this.next=function(){return this._node===this._sentinel&&K(),this._node=this._node.next,this}):(this.prev=function(){return this._node.next===this._sentinel&&K(),this._node=this._node.next,this},this.next=function(){return this._node===this._sentinel&&K(),this._node=this._node.prev,this}),this.hashMap=n}h(t,[{key:"current",get:function t(){var t=this;return this._node===this._sentinel&&K(),new Proxy([],{get:function(e,r){return r==="0"?t._node.key:r==="1"?t._node.value:(e[0]=t._node.key,e[1]=t._node.value,e[r])},set:function(e,r,n){if(r!=="1")throw new TypeError("prop should be string '1'");return t._node.value=n,!0}})}},{key:"isAccessible",value:function t(){return this._node!==this._sentinel}},{key:"prev",value:function t(){return this}},{key:"next",value:function t(){return this}}]);return t}(),X=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];var r=this;a(this,t);g(this,"OBJ_KEY_INDEX",Symbol("OBJ_KEY_INDEX"));g(this,"_nodes",[]);g(this,"_orgMap",{});g(this,"_head");g(this,"_tail");g(this,"_sentinel");g(this,"_size",0);Object.setPrototypeOf(this._orgMap,null),this._sentinel={},this._sentinel.prev=this._sentinel.next=this._head=this._tail=this._sentinel,e.forEach(function(t){r.set(t[0],t[1])})}h(t,[{key:"size",get:function t(){return this._size}},{key:"begin",get:function t(){return new Y(this._head,this._sentinel,this)}},{key:"end",get:function t(){return new Y(this._sentinel,this._sentinel,this)}},{key:"reverseBegin",get:function t(){return new Y(this._tail,this._sentinel,this,1)}},{key:"reverseEnd",get:function t(){return new Y(this._sentinel,this._sentinel,this,1)}},{key:"front",get:function t(){if(this._size!==0)return[this._head.key,this._head.value]}},{key:"back",get:function t(){if(this._size!==0)return[this._tail.key,this._tail.value]}},{key:"set",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:B(t);var n;if(r){var i=t[this.OBJ_KEY_INDEX];if(i!==void 0)return this._nodes[i].value=e,this._size;Object.defineProperty(t,this.OBJ_KEY_INDEX,{value:this._nodes.length,configurable:!0}),n={key:t,value:e,prev:this._tail,next:this._sentinel},this._nodes.push(n)}else{var u=this._orgMap[t];if(u)return u.value=e,this._size;this._orgMap[t]=n={key:t,value:e,prev:this._tail,next:this._sentinel}}return this._size===0?(this._head=n,this._sentinel.next=n):this._tail.next=n,this._tail=n,this._sentinel.prev=n,++this._size}},{key:"get",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:B(t);if(e){var r=t[this.OBJ_KEY_INDEX];return r!==void 0?this._nodes[r].value:void 0}var n=this._orgMap[t];return n?n.value:void 0}},{key:"getAt",value:function t(t){j(t,0,this._size-1);var e=this._head;for(;t--;)e=e.next;return[e.key,e.value]}},{key:"getIterator",value:function t(t,e){var r;if(e){var n=t[this.OBJ_KEY_INDEX];n===void 0?r=this._sentinel:r=this._nodes[n]}else r=this._orgMap[t]||this._sentinel;return new Y(r,this._sentinel,this)}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:B(t);var r;if(e){var n=t[this.OBJ_KEY_INDEX];if(n===void 0)return!1;delete t[this.OBJ_KEY_INDEX],r=this._nodes[n],delete this._nodes[n]}else{if(r=this._orgMap[t],r===void 0)return!1;delete this._orgMap[t]}return this._deleteNode(r),!0}},{key:"deleteAt",value:function t(t){j(t,0,this._size-1);var e=this._head;for(;t--;)e=e.next;return this._deleteNode(e),this._size}},{key:"isEmpty",value:function t(){return this._size===0}},{key:"clear",value:function t(){this._nodes=[],this._orgMap={},Object.setPrototypeOf(this._orgMap,null),this._size=0,this._head=this._tail=this._sentinel.prev=this._sentinel.next=this._sentinel}},{key:"forEach",value:function t(t){var e=0,r=this._head;for(;r!==this._sentinel;)t([r.key,r.value],e++,this),r=r.next}},{key:Symbol.iterator,value:function t(){var t;return O(this,function(e){switch(e.label){case 0:t=this._head;e.label=1;case 1:if(!(t!==this._sentinel))return[3,4];return[4,[t.key,t.value]];case 2:e.sent(),t=t.next;e.label=3;case 3:return[3,1];case 4:return[2]}})}},{key:"_deleteNode",value:function t(t){var e=t.prev,r=t.next;e.next=r,r.prev=e,t===this._head&&(this._head=r),t===this._tail&&(this._tail=e),this._size-=1}}]);return t}();var J=function t(e){a(this,t);g(this,"value");g(this,"next");this.value=e,this.next=null},Q=/*#__PURE__*/function(){function t(){a(this,t);g(this,"_head");g(this,"_tail");g(this,"_length");this._head=null,this._tail=null,this._length=0}h(t,[{key:"head",get:function t(){return this._head}},{key:"tail",get:function t(){return this._tail}},{key:"length",get:function t(){return this._length}},{key:"push",value:function t(t){var e=new J(t);this.head?(this.tail.next=e,this._tail=e):(this._head=e,this._tail=e),this._length++}},{key:"addLast",value:function t(t){this.push(t)}},{key:"pop",value:function t(){if(!this.head)return;if(this.head===this.tail){var t=this.head.value;return this._head=null,this._tail=null,this._length--,t}var e=this.head;for(;e.next!==this.tail;)e=e.next;var r=this.tail.value;return e.next=null,this._tail=e,this._length--,r}},{key:"popLast",value:function t(){return this.pop()}},{key:"shift",value:function t(){if(!this.head)return;var t=this.head;return this._head=this.head.next,this._length--,t.value}},{key:"popFirst",value:function t(){return this.shift()}},{key:"unshift",value:function t(t){var e=new J(t);this.head?(e.next=this.head,this._head=e):(this._head=e,this._tail=e),this._length++}},{key:"addFirst",value:function t(t){this.unshift(t)}},{key:"getAt",value:function t(t){if(t<0||t>=this.length)return;var e=this.head;for(var r=0;r<t;r++)e=e.next;return e.value}},{key:"getNodeAt",value:function t(t){var e=this.head;for(var r=0;r<t;r++)e=e.next;return e}},{key:"deleteAt",value:function t(t){if(t<0||t>=this.length)return;if(t===0)return this.shift();if(t===this.length-1)return this.pop();var e=this.getNodeAt(t-1),r=e.next;return e.next=r.next,this._length--,r.value}},{key:"delete",value:function t(t){if(!t)return!1;var e;c(t,J)?e=t.value:e=t;var r=this.head,n=null;for(;r;){if(r.value===e)return n===null?(this._head=r.next,r===this.tail&&(this._tail=null)):(n.next=r.next,r===this.tail&&(this._tail=n)),this._length--,!0;n=r,r=r.next}return!1}},{key:"insertAt",value:function t(t,e){if(t<0||t>this.length)return!1;if(t===0)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;var r=new J(e),n=this.getNodeAt(t-1);return r.next=n.next,n.next=r,this._length++,!0}},{key:"isEmpty",value:function t(){return this.length===0}},{key:"clear",value:function t(){this._head=null,this._tail=null,this._length=0}},{key:"toArray",value:function t(){var t=[],e=this.head;for(;e;)t.push(e.value),e=e.next;return t}},{key:"reverse",value:function t(){if(!this.head||this.head===this.tail)return;var t=null,e=this.head,r=null;for(;e;)r=e.next,e.next=t,t=e,e=r;var n;n=[this.tail,this.head],this._head=n[0],this._tail=n[1],n}},{key:"find",value:function t(t){var e=this.head;for(;e;){if(t(e.value))return e.value;e=e.next}return null}},{key:"indexOf",value:function t(t){var e=0,r=this.head;for(;r;){if(r.value===t)return e;e++,r=r.next}return-1}},{key:"getNode",value:function t(t){var e=this.head;for(;e;){if(e.value===t)return e;e=e.next}return null}},{key:"insertBefore",value:function t(t,e){if(!this.head)return!1;var r;if(c(t,J)?r=t.value:r=t,this.head.value===r)return this.unshift(e),!0;var n=this.head;for(;n.next;){if(n.next.value===r){var i=new J(e);return i.next=n.next,n.next=i,this._length++,!0}n=n.next}return!1}},{key:"insertAfter",value:function t(t,e){var r;if(c(t,J)?r=t:r=this.getNode(t),r){var n=new J(e);return n.next=r.next,r.next=n,r===this.tail&&(this._tail=n),this._length++,!0}return!1}},{key:"countOccurrences",value:function t(t){var e=0,r=this.head;for(;r;)r.value===t&&e++,r=r.next;return e}},{key:"forEach",value:function t(t){var e=this.head,r=0;for(;e;)t(e.value,r),e=e.next,r++}},{key:"map",value:function e(e){var r=new t,n=this.head;for(;n;)r.push(e(n.value)),n=n.next;return r}},{key:"filter",value:function e(e){var r=new t,n=this.head;for(;n;)e(n.value)&&r.push(n.value),n=n.next;return r}},{key:"reduce",value:function t(t,e){var r=e,n=this.head;for(;n;)r=t(r,n.value),n=n.next;return r}},{key:Symbol.iterator,value:function t(){var t;return O(this,function(e){switch(e.label){case 0:t=this.head;e.label=1;case 1:if(!t)return[3,4];return[4,t.value];case 2:e.sent(),t=t.next;e.label=3;case 3:return[3,1];case 4:return[2]}})}}],[{key:"fromArray",value:function e(e){var r=new t;var n=true,i=false,u=undefined;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=true){var s=o.value;r.push(s)}}catch(t){i=true;u=t}finally{try{if(!n&&a.return!=null){a.return()}}finally{if(i){throw u}}}return r}}]);return t}();var Z=function t(e){a(this,t);g(this,"value");g(this,"next");g(this,"prev");this.value=e,this.next=null,this.prev=null},$=/*#__PURE__*/function(){function t(){a(this,t);g(this,"_head");g(this,"_tail");g(this,"_length");this._head=null,this._tail=null,this._length=0}h(t,[{key:"head",get:function t(){return this._head}},{key:"tail",get:function t(){return this._tail}},{key:"length",get:function t(){return this._length}},{key:"size",get:function t(){return this.length}},{key:"push",value:function t(t){var e=new Z(t);this.head?(e.prev=this.tail,this.tail.next=e,this._tail=e):(this._head=e,this._tail=e),this._length++}},{key:"addLast",value:function t(t){this.push(t)}},{key:"pop",value:function t(){if(!this.tail)return;var t=this.tail;return this.head===this.tail?(this._head=null,this._tail=null):(this._tail=t.prev,this.tail.next=null),this._length--,t.value}},{key:"popLast",value:function t(){return this.pop()}},{key:"shift",value:function t(){if(!this.head)return;var t=this.head;return this.head===this.tail?(this._head=null,this._tail=null):(this._head=t.next,this.head.prev=null),this._length--,t.value}},{key:"popFirst",value:function t(){return this.shift()}},{key:"unshift",value:function t(t){var e=new Z(t);this.head?(e.next=this.head,this.head.prev=e,this._head=e):(this._head=e,this._tail=e),this._length++}},{key:"addFirst",value:function t(t){this.unshift(t)}},{key:"getFirst",value:function t(){var t;return(t=this.head)===null||t===void 0?void 0:t.value}},{key:"getLast",value:function t(){var t;return(t=this.tail)===null||t===void 0?void 0:t.value}},{key:"getAt",value:function t(t){if(t<0||t>=this.length)return;var e=this.head;for(var r=0;r<t;r++)e=e.next;return e.value}},{key:"getNodeAt",value:function t(t){if(t<0||t>=this.length)return null;var e=this.head;for(var r=0;r<t;r++)e=e.next;return e}},{key:"getNode",value:function t(t){var e=this.head;for(;e;){if(e.value===t)return e;e=e.next}return null}},{key:"insertAt",value:function t(t,e){if(t<0||t>this.length)return!1;if(t===0)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;var r=new Z(e),n=this.getNodeAt(t-1),i=n.next;return r.prev=n,r.next=i,n.next=r,i.prev=r,this._length++,!0}},{key:"insertBefore",value:function t(t,e){var r;if(c(t,Z)?r=t:r=this.getNode(t),r){var n=new Z(e);return n.prev=r.prev,r.prev&&(r.prev.next=n),n.next=r,r.prev=n,r===this.head&&(this._head=n),this._length++,!0}return!1}},{key:"deleteAt",value:function t(t){if(t<0||t>=this.length)return;if(t===0)return this.shift();if(t===this.length-1)return this.pop();var e=this.getNodeAt(t),r=e.prev,n=e.next;return r.next=n,n.prev=r,this._length--,e.value}},{key:"delete",value:function t(t){var e;if(c(t,Z)?e=t:e=this.getNode(t),e){if(e===this.head)this.shift();else if(e===this.tail)this.pop();else{var r=e.prev,n=e.next;r.next=n,n.prev=r,this._length--}return!0}return!1}},{key:"toArray",value:function t(){var t=[],e=this.head;for(;e;)t.push(e.value),e=e.next;return t}},{key:"isEmpty",value:function t(){return this.length===0}},{key:"clear",value:function t(){this._head=null,this._tail=null,this._length=0}},{key:"find",value:function t(t){var e=this.head;for(;e;){if(t(e.value))return e.value;e=e.next}return null}},{key:"indexOf",value:function t(t){var e=0,r=this.head;for(;r;){if(r.value===t)return e;e++,r=r.next}return-1}},{key:"findBackward",value:function t(t){var e=this.tail;for(;e;){if(t(e.value))return e.value;e=e.prev}return null}},{key:"toArrayBackward",value:function t(){var t=[],e=this.tail;for(;e;)t.push(e.value),e=e.prev;return t}},{key:"reverse",value:function t(){var t=this.head;var e;for(e=[this.tail,this.head],this._head=e[0],this._tail=e[1],e;t;){var r=t.next;var n;n=[t.next,t.prev],t.prev=n[0],t.next=n[1],n,t=r}}},{key:"forEach",value:function t(t){var e=this.head,r=0;for(;e;)t(e.value,r),e=e.next,r++}},{key:"map",value:function e(e){var r=new t,n=this.head;for(;n;)r.push(e(n.value)),n=n.next;return r}},{key:"filter",value:function e(e){var r=new t,n=this.head;for(;n;)e(n.value)&&r.push(n.value),n=n.next;return r}},{key:"reduce",value:function t(t,e){var r=e,n=this.head;for(;n;)r=t(r,n.value),n=n.next;return r}},{key:"insertAfter",value:function t(t,e){var r;if(c(t,Z)?r=t:r=this.getNode(t),r){var n=new Z(e);return n.next=r.next,r.next&&(r.next.prev=n),n.prev=r,r.next=n,r===this.tail&&(this._tail=n),this._length++,!0}return!1}},{key:Symbol.iterator,value:function t(){var t;return O(this,function(e){switch(e.label){case 0:t=this.head;e.label=1;case 1:if(!t)return[3,4];return[4,t.value];case 2:e.sent(),t=t.next;e.label=3;case 3:return[3,1];case 4:return[2]}})}}],[{key:"fromArray",value:function e(e){var r=new t;var n=true,i=false,u=undefined;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=true){var s=o.value;r.push(s)}}catch(t){i=true;u=t}finally{try{if(!n&&a.return!=null){a.return()}}finally{if(i){throw u}}}return r}}]);return t}();var tt=function t(e,r,n){a(this,t);g(this,"key");g(this,"value");g(this,"forward");this.key=e,this.value=r,this.forward=new Array(n)},te=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;a(this,t);g(this,"_head");g(this,"_level");g(this,"_maxLevel");g(this,"_probability");this._head=new tt(null,null,e),this._level=0,this._maxLevel=e,this._probability=r}h(t,[{key:"head",get:function t(){return this._head}},{key:"level",get:function t(){return this._level}},{key:"maxLevel",get:function t(){return this._maxLevel}},{key:"probability",get:function t(){return this._probability}},{key:"add",value:function t(t,e){var r=new tt(t,e,this._randomLevel()),n=new Array(this.maxLevel).fill(this.head),i=this.head;for(var u=this.level-1;u>=0;u--){for(;i.forward[u]&&i.forward[u].key<t;)i=i.forward[u];n[u]=i}for(var a=0;a<r.forward.length;a++)r.forward[a]=n[a].forward[a],n[a].forward[a]=r;r.forward[0]!==null&&(this._level=Math.max(this.level,r.forward.length))}},{key:"get",value:function t(t){var e=this.head;for(var r=this.level-1;r>=0;r--)for(;e.forward[r]&&e.forward[r].key<t;)e=e.forward[r];if(e=e.forward[0],e&&e.key===t)return e.value}},{key:"has",value:function t(t){return this.get(t)!==void 0}},{key:"delete",value:function t(t){var e=new Array(this.maxLevel).fill(this.head),r=this.head;for(var n=this.level-1;n>=0;n--){for(;r.forward[n]&&r.forward[n].key<t;)r=r.forward[n];e[n]=r}if(r=r.forward[0],r&&r.key===t){for(var i=0;i<this.level&&e[i].forward[i]===r;i++)e[i].forward[i]=r.forward[i];for(;this.level>0&&this.head.forward[this.level-1]===null;)this._level--;return!0}return!1}},{key:"getFirst",value:function t(){var t=this.head.forward[0];return t?t.value:void 0}},{key:"getLast",value:function t(){var t=this.head;for(var e=this.level-1;e>=0;e--)for(;t.forward[e];)t=t.forward[e];return t.value}},{key:"higher",value:function t(t){var e=this.head;for(var r=this.level-1;r>=0;r--)for(;e.forward[r]&&e.forward[r].key<=t;)e=e.forward[r];var n=e.forward[0];return n?n.value:void 0}},{key:"lower",value:function t(t){var e=this.head,r=null;for(var n=this.level-1;n>=0;n--){for(;e.forward[n]&&e.forward[n].key<t;)e=e.forward[n];e.key<t&&(r=e)}return r?r.value:void 0}},{key:"_randomLevel",value:function t(){var t=1;for(;Math.random()<this.probability&&t<this.maxLevel;)t++;return t}}]);return t}();var tr=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"_elements");this._elements=Array.isArray(e)?e:[]}h(t,[{key:"elements",get:function t(){return this._elements}},{key:"isEmpty",value:function t(){return this.elements.length===0}},{key:"size",value:function t(){return this.elements.length}},{key:"peek",value:function t(){return this.isEmpty()?null:this.elements[this.elements.length-1]}},{key:"push",value:function t(t){return this.elements.push(t),this}},{key:"pop",value:function t(){return this.isEmpty()?null:this.elements.pop()||null}},{key:"toArray",value:function t(){return this.elements.slice()}},{key:"clear",value:function t(){this._elements=[]}},{key:"clone",value:function e(){return new t(this.elements.slice())}}],[{key:"fromArray",value:function e(e){return new t(e)}}]);return t}();var tn=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){a(this,r);return e.apply(this,arguments)}h(r,[{key:"enqueue",value:function t(t){this.push(t)}},{key:"dequeue",value:function t(){return this.shift()}},{key:"getFirst",value:function t(){var t;return(t=this.head)===null||t===void 0?void 0:t.value}},{key:"peek",value:function t(){return this.getFirst()}}]);return r}(Q),ti=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"_nodes");g(this,"_offset");this._nodes=e||[],this._offset=0}h(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"offset",get:function t(){return this._offset}},{key:"size",get:function t(){return this.nodes.length-this.offset}},{key:"push",value:function t(t){return this.nodes.push(t),this}},{key:"shift",value:function t(){if(this.size===0)return;var t=this.getFirst();return this._offset+=1,this.offset*2<this.nodes.length||(this._nodes=this.nodes.slice(this.offset),this._offset=0),t}},{key:"getFirst",value:function t(){return this.size>0?this.nodes[this.offset]:void 0}},{key:"peek",value:function t(){return this.getFirst()}},{key:"getLast",value:function t(){return this.size>0?this.nodes[this.nodes.length-1]:void 0}},{key:"peekLast",value:function t(){return this.getLast()}},{key:"enqueue",value:function t(t){this.push(t)}},{key:"dequeue",value:function t(){return this.shift()}},{key:"getAt",value:function t(t){return this.nodes[t]}},{key:"isEmpty",value:function t(){return this.size===0}},{key:"toArray",value:function t(){return this.nodes.slice(this.offset)}},{key:"clear",value:function t(){this._nodes=[],this._offset=0}},{key:"clone",value:function e(){return new t(this.nodes.slice(this.offset))}},{key:Symbol.iterator,value:function t(){var t,e,r,n,i,u,a;return O(this,function(o){switch(o.label){case 0:t=true,e=false,r=undefined;o.label=1;case 1:o.trys.push([1,6,7,8]);n=this.nodes[Symbol.iterator]();o.label=2;case 2:if(!!(t=(i=n.next()).done))return[3,5];u=i.value;return[4,u];case 3:o.sent();o.label=4;case 4:t=true;return[3,2];case 5:return[3,8];case 6:a=o.sent();e=true;r=a;return[3,8];case 7:try{if(!t&&n.return!=null){n.return()}}finally{if(e){throw r}}return[7];case 8:return[2]}})}}],[{key:"fromArray",value:function e(e){return new t(e)}}]);return t}();var tu=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){a(this,r);return e.apply(this,arguments)}return r}($),ta=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"_nodes",{});g(this,"_capacity",Number.MAX_SAFE_INTEGER);g(this,"_first",-1);g(this,"_last",-1);g(this,"_size",0);e!==void 0&&(this._capacity=e)}h(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"capacity",get:function t(){return this._capacity}},{key:"first",get:function t(){return this._first}},{key:"last",get:function t(){return this._last}},{key:"size",get:function t(){return this._size}},{key:"addFirst",value:function t(t){if(this.size===0){var e=Math.floor(this.capacity/2);this._first=e,this._last=e}else this._first--;this.nodes[this.first]=t,this._size++}},{key:"addLast",value:function t(t){if(this.size===0){var e=Math.floor(this.capacity/2);this._first=e,this._last=e}else this._last++;this.nodes[this.last]=t,this._size++}},{key:"popFirst",value:function t(){if(!this.size)return;var t=this.getFirst();return delete this.nodes[this.first],this._first++,this._size--,t}},{key:"getFirst",value:function t(){if(this.size)return this.nodes[this.first]}},{key:"popLast",value:function t(){if(!this.size)return;var t=this.getLast();return delete this.nodes[this.last],this._last--,this._size--,t}},{key:"getLast",value:function t(){if(this.size)return this.nodes[this.last]}},{key:"get",value:function t(t){return this.nodes[this.first+t]||null}},{key:"isEmpty",value:function t(){return this.size<=0}}]);return t}(),to=/*#__PURE__*/function(){function t(){a(this,t);g(this,"_nodes",[])}h(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"size",get:function t(){return this.nodes.length}},{key:"addLast",value:function t(t){return this.nodes.push(t)}},{key:"popLast",value:function t(){var t;return(t=this.nodes.pop())!==null&&t!==void 0?t:null}},{key:"popFirst",value:function t(){var t;return(t=this.nodes.shift())!==null&&t!==void 0?t:null}},{key:"addFirst",value:function t(t){return this.nodes.unshift(t)}},{key:"getFirst",value:function t(){var t;return(t=this.nodes[0])!==null&&t!==void 0?t:null}},{key:"getLast",value:function t(){var t;return(t=this.nodes[this.nodes.length-1])!==null&&t!==void 0?t:null}},{key:"get",value:function t(t){var e;return(e=this.nodes[t])!==null&&e!==void 0?e:null}},{key:"set",value:function t(t,e){return this.nodes[t]=e}},{key:"insert",value:function t(t,e){return this.nodes.splice(t,0,e)}},{key:"delete",value:function t(t){return this.nodes.splice(t,1)}},{key:"isEmpty",value:function t(){return this.nodes.length===0}}]);return t}();var ts=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"_nodes",[]);g(this,"_comparator");this._comparator=e.comparator,e.nodes&&e.nodes.length>0&&(this._nodes=e.nodes,this.fix())}h(t,[{key:"nodes",get:function t(){return this._nodes}},{key:"comparator",get:function t(){return this._comparator}},{key:"size",get:function t(){return this.nodes.length}},{key:"leaf",get:function t(){var t;return(t=this.nodes[this.size-1])!==null&&t!==void 0?t:void 0}},{key:"add",value:function t(t){return this.push(t)}},{key:"push",value:function t(t){return this.nodes.push(t),this.bubbleUp(this.nodes.length-1),this}},{key:"poll",value:function t(){if(this.nodes.length===0)return;if(this.nodes.length===1)return this.nodes.pop();var t=this.nodes[0];return this.nodes[0]=this.nodes.pop(),this.sinkDown(0),t}},{key:"pop",value:function t(){return this.poll()}},{key:"peek",value:function t(){if(this.nodes.length!==0)return this.nodes[0]}},{key:"isEmpty",value:function t(){return this.size===0}},{key:"clear",value:function t(){this._nodes=[]}},{key:"refill",value:function t(t){this._nodes=t,this.fix()}},{key:"has",value:function t(t){return this.nodes.includes(t)}},{key:"dfs",value:function t(t){var e=this;var r=[],n=function(i){i<e.size&&(t==="in"?(n(2*i+1),r.push(e.nodes[i]),n(2*i+2)):t==="pre"?(r.push(e.nodes[i]),n(2*i+1),n(2*i+2)):t==="post"&&(n(2*i+1),n(2*i+2),r.push(e.nodes[i])))};return n(0),r}},{key:"toArray",value:function t(){return w(this.nodes)}},{key:"getNodes",value:function t(){return this.nodes}},{key:"clone",value:function e(){var e=new t({comparator:this.comparator});return e._nodes=w(this.nodes),e}},{key:"sort",value:function t(){var t=[],e=this.clone();for(;e.size!==0;){var r=e.poll();r&&t.push(r)}return t}},{key:"bubbleUp",value:function t(t){var e=this.nodes[t];for(;t>0;){var r=Math.floor((t-1)/2),n=this.nodes[r];if(this.comparator(e,n)<0)this.nodes[t]=n,this.nodes[r]=e,t=r;else break}}},{key:"sinkDown",value:function t(t){var e=2*t+1,r=2*t+2,n=this.nodes.length,i=t;if(e<n&&this.comparator(this.nodes[e],this.nodes[i])<0&&(i=e),r<n&&this.comparator(this.nodes[r],this.nodes[i])<0&&(i=r),i!==t){var u=this.nodes[t];this.nodes[t]=this.nodes[i],this.nodes[i]=u,this.sinkDown(i)}}},{key:"fix",value:function t(){for(var t=Math.floor(this.size/2);t>=0;t--)this.sinkDown(t)}}],[{key:"heapify",value:function e(e){return new t(e)}}]);return t}(),th=function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;a(this,t);g(this,"element");g(this,"degree");g(this,"left");g(this,"right");g(this,"child");g(this,"parent");g(this,"marked");this.element=e,this.degree=r,this.marked=!1},tl=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"_root");g(this,"_size",0);g(this,"_min");g(this,"_comparator");if(this.clear(),this._comparator=e||this.defaultComparator,typeof this.comparator!="function")throw new Error("FibonacciHeap constructor: given comparator should be a function.")}h(t,[{key:"root",get:function t(){return this._root}},{key:"size",get:function t(){return this._size}},{key:"min",get:function t(){return this._min}},{key:"comparator",get:function t(){return this._comparator}},{key:"clear",value:function t(){this._root=void 0,this._min=void 0,this._size=0}},{key:"add",value:function t(t){return this.push(t)}},{key:"push",value:function t(t){var 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}},{key:"peek",value:function t(){return this.min?this.min.element:void 0}},{key:"consumeLinkedList",value:function t(t){var e=[];if(!t)return e;var r=t,n=!1;for(;!(r===t&&n);)r===t&&(n=!0),r&&(e.push(r),r=r.right);return e}},{key:"mergeWithChild",value:function t(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}},{key:"poll",value:function t(){return this.pop()}},{key:"pop",value:function t(){if(this.size===0)return;var t=this.min;if(t.child){var e=this.consumeLinkedList(t.child);var r=true,n=false,i=undefined;try{for(var u=e[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=a.value;this.mergeWithRoot(o),o.parent=void 0}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}}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}},{key:"merge",value:function t(t){if(t.size!==0){if(this.root&&t.root){var e=this.root,r=t.root,n=e.right,i=r.left;e.right=r,r.left=e,n.left=i,i.right=n}(!this.min||t.min&&this.comparator(t.min.element,this.min.element)<0)&&(this._min=t.min),this._size+=t.size,t.clear()}}},{key:"defaultComparator",value:function t(t,e){return t<e?-1:t>e?1:0}},{key:"createNode",value:function t(t){return new th(t)}},{key:"mergeWithRoot",value:function t(t){this.root?(t.right=this.root.right,t.left=this.root,this.root.right.left=t,this.root.right=t):this._root=t}},{key:"removeFromRoot",value:function t(t){this.root===t&&(this._root=t.right),t.left&&(t.left.right=t.right),t.right&&(t.right.left=t.left)}},{key:"link",value:function t(t,e){this.removeFromRoot(t),t.left=t,t.right=t,this.mergeWithChild(e,t),e.degree++,t.parent=e}},{key:"consolidate",value:function t(){var t=new Array(this.size),e=this.consumeLinkedList(this.root),r,n,i,u;var a=true,o=false,s=undefined;try{for(var h=e[Symbol.iterator](),l;!(a=(l=h.next()).done);a=true){var f=l.value;for(r=f,i=r.degree;t[i];)n=t[i],this.comparator(r.element,n.element)>0&&(u=r,r=n,n=u),this.link(n,r),t[i]=void 0,i++;t[i]=r}}catch(t){o=true;s=t}finally{try{if(!a&&h.return!=null){h.return()}}finally{if(o){throw s}}}for(var v=0;v<this.size;v++)t[v]&&this.comparator(t[v].element,this.min.element)<=0&&(this._min=t[v])}}]);return t}();var tf=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return e-t;throw new Error("The a, b params of compare function must be number")}};a(this,r);return e.call(this,t)}return r}(ts);var tv=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return t-e;throw new Error("The a, b params of compare function must be number")}};a(this,r);return e.call(this,t)}return r}(ts);var tc=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t){a(this,r);return e.call(this,t)}return r}(ts);var td=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return t-e;throw new Error("The a, b params of compare function must be number")}};a(this,r);return e.call(this,t)}return r}(tc);var ty=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{comparator:function(t,e){if(typeof t=="number"&&typeof e=="number")return e-t;throw new Error("The a, b params of compare function must be number")}};a(this,r);return e.call(this,t)}return r}(tc);var tg=function t(e,r){a(this,t);g(this,"key");g(this,"value");this.key=e,this.value=r},tp=/*#__PURE__*/function(){function t(e,r){a(this,t);g(this,"value");g(this,"weight");g(this,"_hashCode");this.weight=e!==void 0?e:1,this.value=r,this._hashCode=z()}h(t,[{key:"hashCode",get:function t(){return this._hashCode}}]);return t}(),t_=/*#__PURE__*/function(){function t(){a(this,t);g(this,"_vertices",new Map)}h(t,[{key:"vertices",get:function t(){return this._vertices}},{key:"getVertex",value:function t(t){return this._vertices.get(t)||null}},{key:"hasVertex",value:function t(t){return this._vertices.has(this._getVertexKey(t))}},{key:"addVertex",value:function t(t,e){if(c(t,tg))return this._addVertexOnly(t);{var r=this.createVertex(t,e);return this._addVertexOnly(r)}}},{key:"deleteVertex",value:function t(t){var e=this._getVertexKey(t);return this._vertices.delete(e)}},{key:"removeManyVertices",value:function t(t){var e=[];var r=true,n=false,i=undefined;try{for(var u=t[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=a.value;e.push(this.deleteVertex(o))}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}return e.length>0}},{key:"hasEdge",value:function t(t,e){return!!this.getEdge(t,e)}},{key:"addEdge",value:function t(t,e,r,n){if(c(t,tp))return this._addEdgeOnly(t);if(c(e,tg)||typeof e=="string"||typeof e=="number"){if(!(this.hasVertex(t)&&this.hasVertex(e)))return!1;c(t,tg)&&(t=t.key),c(e,tg)&&(e=e.key);var i=this.createEdge(t,e,r,n);return this._addEdgeOnly(i)}else throw new Error("dest must be a Vertex or vertex key while srcOrEdge is an Edge")}},{key:"setEdgeWeight",value:function t(t,e,r){var n=this.getEdge(t,e);return n?(n.weight=r,!0):!1}},{key:"getAllPathsBetween",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e3;var n=[],i=this._getVertex(t),u=this._getVertex(e);if(!(i&&u))return[];var a=[];for(a.push({vertex:i,path:[i]});a.length>0;){var o=a.pop(),s=o.vertex,h=o.path;if(s===u&&(n.push(h),n.length>=r))return n;var l=this.getNeighbors(s);var f=true,v=false,c=undefined;try{for(var d=l[Symbol.iterator](),y;!(f=(y=d.next()).done);f=true){var g=y.value;if(!h.includes(g)){var p=w(h).concat([g]);a.push({vertex:g,path:p})}}}catch(t){v=true;c=t}finally{try{if(!f&&d.return!=null){d.return()}}finally{if(v){throw c}}}}return n}},{key:"getPathSumWeight",value:function t(t){var e;var r=0;for(var n=0;n<t.length;n++)r+=((e=this.getEdge(t[n],t[n+1]))===null||e===void 0?void 0:e.weight)||0;return r}},{key:"getMinCostBetween",value:function t(t,e,r){if(r===void 0&&(r=!1),r){var n=this.getAllPathsBetween(t,e),i=1/0;var u=true,a=false,o=undefined;try{for(var s=n[Symbol.iterator](),h;!(u=(h=s.next()).done);u=true){var l=h.value;i=Math.min(this.getPathSumWeight(l),i)}}catch(t){a=true;o=t}finally{try{if(!u&&s.return!=null){s.return()}}finally{if(a){throw o}}}return i}else{var f=this._getVertex(e),v=this._getVertex(t);if(!(v&&f))return null;var c=new Map,d=new ti([v]);c.set(v,!0);var y=0;for(;d.size>0;){for(var g=0;g<d.size;g++){var p=d.shift();if(p===f)return y;if(p!==void 0){var _=this.getNeighbors(p);var k=true,m=false,x=undefined;try{for(var b=_[Symbol.iterator](),w;!(k=(w=b.next()).done);k=true){var E=w.value;c.has(E)||(c.set(E,!0),d.push(E))}}catch(t){m=true;x=t}finally{try{if(!k&&b.return!=null){b.return()}}finally{if(m){throw x}}}}}y++}return null}}},{key:"getMinPathBetween",value:function t(t,e,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;var u;var a;if(r===void 0&&(r=!1),r)if(n){var o=this.getAllPathsBetween(t,e,1e4),s=1/0,h=-1,l=0;var f=true,v=false,c=undefined;try{for(var d=o[Symbol.iterator](),y;!(f=(y=d.next()).done);f=true){var g=y.value;var p=this.getPathSumWeight(g);p<s&&(s=p,h=l),l++}}catch(t){v=true;c=t}finally{try{if(!f&&d.return!=null){d.return()}}finally{if(v){throw c}}}return o[h]||null}else return(a=(u=this.dijkstra(t,e,!0,!0))===null||u===void 0?void 0:u.minPath)!==null&&a!==void 0?a:[];else{var _=[],k=this._getVertex(t),m=this._getVertex(e);if(!(k&&m))return[];var x=function(t,e,r,n){if(r.add(t),t===e){_=[k].concat(w(n));return}var u=i.getNeighbors(t);var a=true,o=false,s=undefined;try{for(var h=u[Symbol.iterator](),l;!(a=(l=h.next()).done);a=true){var f=l.value;r.has(f)||(n.push(f),x(f,e,r,n),n.pop())}}catch(t){o=true;s=t}finally{try{if(!a&&h.return!=null){h.return()}}finally{if(o){throw s}}}r.delete(t)};return x(k,m,new Set,[]),_}}},{key:"dijkstraWithoutHeap",value:function t(t,e,r,n){r===void 0&&(r=!1),n===void 0&&(n=!1),e===void 0&&(e=null);var i=1/0,u=null,a=[],o=[],s=this._vertices,h=new Map,l=new Set,f=new Map,v=this._getVertex(t),d=e?this._getVertex(e):null;if(!v)return null;var y=true,g=false,p=undefined;try{for(var _=s[Symbol.iterator](),k;!(y=(k=_.next()).done);y=true){var m=k.value;var b=m[1];c(b,tg)&&h.set(b,1/0)}}catch(t){g=true;p=t}finally{try{if(!y&&_.return!=null){_.return()}}finally{if(g){throw p}}}h.set(v,0),f.set(v,null);var w=function(){var t=1/0,e=null;var r=true,n=false,i=undefined;try{for(var u=h[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=x(a.value,2),s=o[0],f=o[1];l.has(s)||f<t&&(t=f,e=s)}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}return e},E=function(t){var e=true,r=false,n=undefined;try{for(var i=s[Symbol.iterator](),u;!(e=(u=i.next()).done);e=true){var h=u.value;var l=h[1];if(c(l,tg)){var v=[l],d=f.get(l);for(;d;)v.push(d),d=f.get(d);var y=v.reverse();h[1]===t&&(a=y),o.push(y)}}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}};for(var N=1;N<s.size;N++){var M=w();if(M){if(l.add(M),d&&d===M)return r&&(i=h.get(d)||1/0),n&&E(d),{distMap:h,preMap:f,seen:l,paths:o,minDist:i,minPath:a};var R=this.getNeighbors(M);var S=true,O=false,T=undefined;try{for(var I=R[Symbol.iterator](),z;!(S=(z=I.next()).done);S=true){var V=z.value;if(!l.has(V)){var A=this.getEdge(M,V);if(A){var L=h.get(M),C=h.get(V);L!==void 0&&C!==void 0&&A.weight+L<C&&(h.set(V,A.weight+L),f.set(V,M))}}}}catch(t){O=true;T=t}finally{try{if(!S&&I.return!=null){I.return()}}finally{if(O){throw T}}}}}return r&&h.forEach(function(t,e){e!==v&&t<i&&(i=t,n&&(u=e))}),n&&E(u),{distMap:h,preMap:f,seen:l,paths:o,minDist:i,minPath:a}}},{key:"dijkstra",value:function t(t,e,r,n){r===void 0&&(r=!1),n===void 0&&(n=!1),e===void 0&&(e=null);var i=1/0,u=null,a=[],o=[],s=this._vertices,h=new Map,l=new Set,f=new Map,v=this._getVertex(t),d=e?this._getVertex(e):null;if(!v)return null;var y=true,g=false,p=undefined;try{for(var _=s[Symbol.iterator](),k;!(y=(k=_.next()).done);y=true){var m=k.value;var x=m[1];c(x,tg)&&h.set(x,1/0)}}catch(t){g=true;p=t}finally{try{if(!y&&_.return!=null){_.return()}}finally{if(g){throw p}}}var b=new tc({comparator:function(t,e){return t.key-e.key}});b.add({key:0,value:v}),h.set(v,0),f.set(v,null);var w=function(t){var e=true,r=false,n=undefined;try{for(var i=s[Symbol.iterator](),u;!(e=(u=i.next()).done);e=true){var h=u.value;var l=h[1];if(c(l,tg)){var v=[l],d=f.get(l);for(;d;)v.push(d),d=f.get(d);var y=v.reverse();h[1]===t&&(a=y),o.push(y)}}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}};for(;b.size>0;){var E=b.poll(),N=E===null||E===void 0?void 0:E.key,M=E===null||E===void 0?void 0:E.value;if(N!==void 0&&M){if(l.add(M),d&&d===M)return r&&(i=h.get(d)||1/0),n&&w(d),{distMap:h,preMap:f,seen:l,paths:o,minDist:i,minPath:a};var R=this.getNeighbors(M);var S=true,O=false,T=undefined;try{for(var I=R[Symbol.iterator](),z;!(S=(z=I.next()).done);S=true){var V=z.value;if(!l.has(V)){var A;var L=(A=this.getEdge(M,V))===null||A===void 0?void 0:A.weight;if(typeof L=="number"){var C=h.get(V);C&&N+L<C&&(b.add({key:N+L,value:V}),f.set(V,M),h.set(V,N+L))}}}}catch(t){O=true;T=t}finally{try{if(!S&&I.return!=null){I.return()}}finally{if(O){throw T}}}}}return r&&h.forEach(function(t,e){e!==v&&t<i&&(i=t,n&&(u=e))}),n&&w(u),{distMap:h,preMap:f,seen:l,paths:o,minDist:i,minPath:a}}},{key:"bellmanFord",value:function t(t,e,r,n){r===void 0&&(r=!1),n===void 0&&(n=!1);var i=this._getVertex(t),u=[],a=new Map,o=new Map,s=1/0,h=[],l;if(e&&(l=!1),!i)return{hasNegativeCycle:l,distMap:a,preMap:o,paths:u,min:s,minPath:h};var f=this._vertices,v=f.size,d=this.edgeSet(),y=d.length;this._vertices.forEach(function(t){a.set(t,1/0)}),a.set(i,0);for(var g=1;g<v;++g)for(var p=0;p<y;++p){var _=this.getEndsOfEdge(d[p]);if(_){var k=x(_,2),m=k[0],b=k[1],w=d[p].weight,E=a.get(m),N=a.get(b);E!==void 0&&N!==void 0&&a.get(m)!==1/0&&E+w<N&&(a.set(b,E+w),n&&o.set(b,m))}}var M=null;var R=true,S=false,O=undefined;if(r&&a.forEach(function(t,e){e!==i&&t<s&&(s=t,n&&(M=e))}),n)try{for(var T=f[Symbol.iterator](),I;!(R=(I=T.next()).done);R=true){var z=I.value;var V=z[1];if(c(V,tg)){var A=[V],L=o.get(V);for(;L!==void 0;)A.push(L),L=o.get(L);var C=A.reverse();z[1]===M&&(h=C),u.push(C)}}}catch(t){S=true;O=t}finally{try{if(!R&&T.return!=null){T.return()}}finally{if(S){throw O}}}for(var P=0;P<y;++P){var F=this.getEndsOfEdge(d[P]);if(F){var D=x(F,1),j=D[0],K=d[P].weight,B=a.get(j);B&&B!==1/0&&B+K<B&&(l=!0)}}return{hasNegativeCycle:l,distMap:a,preMap:o,paths:u,min:s,minPath:h}}},{key:"floydWarshall",value:function t(){var t;var e=w(this._vertices),r=e.length,n=[],i=[];for(var u=0;u<r;u++){n[u]=[],i[u]=[];for(var a=0;a<r;a++)i[u][a]=null}for(var o=0;o<r;o++)for(var s=0;s<r;s++)n[o][s]=((t=this.getEdge(e[o][1],e[s][1]))===null||t===void 0?void 0:t.weight)||1/0;for(var h=0;h<r;h++)for(var l=0;l<r;l++)for(var f=0;f<r;f++)n[l][f]>n[l][h]+n[h][f]&&(n[l][f]=n[l][h]+n[h][f],i[l][f]=e[h][1]);return{costs:n,predecessor:i}}},{key:"tarjan",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;t===void 0&&(t=!1),e===void 0&&(e=!1),r===void 0&&(r=!1),n===void 0&&(n=!1);var u=new Map,a=new Map,o=this._vertices;o.forEach(function(t){u.set(t,-1),a.set(t,1/0)});var s=x(o.values(),1),h=s[0],l=[],f=[],v=0,c=function(r,n){v++,u.set(r,v),a.set(r,v);var o=i.getNeighbors(r),s=0;var d=true,y=false,g=undefined;try{for(var p=o[Symbol.iterator](),_;!(d=(_=p.next()).done);d=true){var k=_.value;if(k!==n){u.get(k)===-1&&(s++,c(k,r));var m=a.get(k),x=a.get(r);x!==void 0&&m!==void 0&&a.set(r,Math.min(x,m));var b=u.get(r);if(m!==void 0&&b!==void 0&&(t&&(r===h&&s>=2||r!==h&&m>=b)&&l.push(r),e&&m>b)){var w=i.getEdge(r,k);w&&f.push(w)}}}}catch(t){y=true;g=t}finally{try{if(!d&&p.return!=null){p.return()}}finally{if(y){throw g}}}};c(h,null);var d=new Map,y=function(){var t=new Map;return a.forEach(function(e,r){var n;t.has(e)?(n=t.get(e))===null||n===void 0?void 0:n.push(r):t.set(e,[r])}),t};r&&(d=y());var g=new Map;if(n){var p=new Map;p.size<1&&(p=y()),p.forEach(function(t,e){t.length>1&&g.set(e,t)})}return{dfnMap:u,lowMap:a,bridges:f,cutVertexes:l,SCCs:d,cycles:g}}},{key:"getDFNMap",value:function t(){return this.tarjan(!1,!1,!1,!1).dfnMap}},{key:"getLowMap",value:function t(){return this.tarjan(!1,!1,!1,!1).lowMap}},{key:"getCycles",value:function t(){return this.tarjan(!1,!1,!1,!0).cycles}},{key:"getCutVertexes",value:function t(){return this.tarjan(!0,!1,!1,!1).cutVertexes}},{key:"getSCCs",value:function t(){return this.tarjan(!1,!1,!0,!1).SCCs}},{key:"getBridges",value:function t(){return this.tarjan(!1,!0,!1,!1).bridges}},{key:"_addVertexOnly",value:function t(t){return this.hasVertex(t)?!1:(this._vertices.set(t.key,t),!0)}},{key:"_getVertex",value:function t(t){var e=this._getVertexKey(t);return this._vertices.get(e)||null}},{key:"_getVertexKey",value:function t(t){return c(t,tg)?t.key:t}}]);return t}();var tk=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,n){a(this,r);return e.call(this,t,n)}return r}(tg),tm=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i,u,o){a(this,r);var s;s=e.call(this,u,o);g(n(s),"src");g(n(s),"dest");s.src=t,s.dest=i;return s}return r}(tp),tx=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){a(this,r);var t;t=e.call(this);g(n(t),"_outEdgeMap",new Map);g(n(t),"_inEdgeMap",new Map);return t}h(r,[{key:"outEdgeMap",get:function t(){return this._outEdgeMap}},{key:"inEdgeMap",get:function t(){return this._inEdgeMap}},{key:"createVertex",value:function t(t,e){return new tk(t,e!==null&&e!==void 0?e:t)}},{key:"createEdge",value:function t(t,e,r,n){return new tm(t,e,r!==null&&r!==void 0?r:1,n)}},{key:"getEdge",value:function t(t,e){var r=[];if(t!==null&&e!==null){var n=this._getVertex(t),i=this._getVertex(e);if(n&&i){var u=this._outEdgeMap.get(n);u&&(r=u.filter(function(t){return t.dest===i.key}))}}return r[0]||null}},{key:"deleteEdgeSrcToDest",value:function t(t,e){var r=this._getVertex(t),n=this._getVertex(e),i=null;if(!r||!n)return null;var u=this._outEdgeMap.get(r);u&&V(u,function(t){return t.dest===n.key});var a=this._inEdgeMap.get(n);return a&&(i=V(a,function(t){return t.src===r.key})[0]||null),i}},{key:"deleteEdge",value:function t(t){var e=null,r=this._getVertex(t.src),n=this._getVertex(t.dest);if(r&&n){var i=this._outEdgeMap.get(r);i&&i.length>0&&V(i,function(t){return t.src===r.key});var u=this._inEdgeMap.get(n);u&&u.length>0&&(e=V(u,function(t){return t.dest===n.key})[0])}return e}},{key:"deleteEdgesBetween",value:function t(t,e){var r=[];if(t&&e){var n=this.deleteEdgeSrcToDest(t,e),i=this.deleteEdgeSrcToDest(e,t);n&&r.push(n),i&&r.push(i)}return r}},{key:"incomingEdgesOf",value:function t(t){var e=this._getVertex(t);return e?this.inEdgeMap.get(e)||[]:[]}},{key:"outgoingEdgesOf",value:function t(t){var e=this._getVertex(t);return e?this._outEdgeMap.get(e)||[]:[]}},{key:"degreeOf",value:function t(t){return this.outDegreeOf(t)+this.inDegreeOf(t)}},{key:"inDegreeOf",value:function t(t){return this.incomingEdgesOf(t).length}},{key:"outDegreeOf",value:function t(t){return this.outgoingEdgesOf(t).length}},{key:"edgesOf",value:function t(t){return w(this.outgoingEdgesOf(t)).concat(w(this.incomingEdgesOf(t)))}},{key:"getEdgeSrc",value:function t(t){return this._getVertex(t.src)}},{key:"getEdgeDest",value:function t(t){return this._getVertex(t.dest)}},{key:"getDestinations",value:function t(t){if(t===null)return[];var e=[],r=this.outgoingEdgesOf(t);var n=true,i=false,u=undefined;try{for(var a=r[Symbol.iterator](),o;!(n=(o=a.next()).done);n=true){var s=o.value;var h=this.getEdgeDest(s);h&&e.push(h)}}catch(t){i=true;u=t}finally{try{if(!n&&a.return!=null){a.return()}}finally{if(i){throw u}}}return e}},{key:"topologicalSort",value:function t(t){var e=this;t=t!==null&&t!==void 0?t:"key";var r=new Map;var n=true,i=false,u=undefined;try{for(var a=this.vertices[Symbol.iterator](),o;!(n=(o=a.next()).done);n=true){var s=o.value;r.set(s[1],0)}}catch(t){i=true;u=t}finally{try{if(!n&&a.return!=null){a.return()}}finally{if(i){throw u}}}var h=[],l=!1,f=function(t){r.set(t,1);var n=e.getDestinations(t);var i=true,u=false,a=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var v=s.value;var c=r.get(v);c===0?f(v):c===1&&(l=!0)}}catch(t){u=true;a=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(u){throw a}}}r.set(t,2),h.push(t)};var v=true,d=false,y=undefined;try{for(var g=this.vertices[Symbol.iterator](),p;!(v=(p=g.next()).done);v=true){var _=p.value;r.get(_[1])===0&&f(_[1])}}catch(t){d=true;y=t}finally{try{if(!v&&g.return!=null){g.return()}}finally{if(d){throw y}}}return l?null:(t==="key"&&(h=h.map(function(t){return c(t,tk)?t.key:t})),h.reverse())}},{key:"edgeSet",value:function t(){var t=[];return this._outEdgeMap.forEach(function(e){t=w(t).concat(w(e))}),t}},{key:"getNeighbors",value:function t(t){var e=[],r=this._getVertex(t);if(r){var n=this.outgoingEdgesOf(r);var i=true,u=false,a=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var h=s.value;var l=this._getVertex(h.dest);l&&e.push(l)}}catch(t){u=true;a=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(u){throw a}}}}return e}},{key:"getEndsOfEdge",value:function t(t){if(!this.hasEdge(t.src,t.dest))return null;var e=this._getVertex(t.src),r=this._getVertex(t.dest);return e&&r?[e,r]:null}},{key:"_addEdgeOnly",value:function t(t){if(!(this.hasVertex(t.src)&&this.hasVertex(t.dest)))return!1;var e=this._getVertex(t.src),r=this._getVertex(t.dest);if(e&&r){var n=this._outEdgeMap.get(e);n?n.push(t):this._outEdgeMap.set(e,[t]);var i=this._inEdgeMap.get(r);return i?i.push(t):this._inEdgeMap.set(r,[t]),!0}else return!1}}]);return r}(t_);var tb=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,n){a(this,r);return e.call(this,t,n)}return r}(tg),tw=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i,u,o){a(this,r);var s;s=e.call(this,u,o);g(n(s),"vertices");s.vertices=[t,i];return s}return r}(tp),tE=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(){a(this,r);var t;t=e.call(this);g(n(t),"_edges");t._edges=new Map;return t}h(r,[{key:"edges",get:function t(){return this._edges}},{key:"createVertex",value:function t(t,e){return new tb(t,e!==null&&e!==void 0?e:t)}},{key:"createEdge",value:function t(t,e,r,n){return new tw(t,e,r!==null&&r!==void 0?r:1,n)}},{key:"getEdge",value:function t(t,e){var r=[];if(t!==null&&e!==null){var n;var i=this._getVertex(t),u=this._getVertex(e);i&&u&&(r=(n=this._edges.get(i))===null||n===void 0?void 0:n.filter(function(t){return t.vertices.includes(u.key)}))}return r&&r[0]||null}},{key:"deleteEdgeBetween",value:function t(t,e){var r=this._getVertex(t),n=this._getVertex(e);if(!r||!n)return null;var i=this._edges.get(r),u=null;i&&(u=V(i,function(t){return t.vertices.includes(n.key)})[0]||null);var a=this._edges.get(n);return a&&V(a,function(t){return t.vertices.includes(r.key)}),u}},{key:"deleteEdge",value:function t(t){return this.deleteEdgeBetween(t.vertices[0],t.vertices[1])}},{key:"degreeOf",value:function t(t){var e;var r=this._getVertex(t);return r&&((e=this._edges.get(r))===null||e===void 0?void 0:e.length)||0}},{key:"edgesOf",value:function t(t){var e=this._getVertex(t);return e?this._edges.get(e)||[]:[]}},{key:"edgeSet",value:function t(){var t=new Set;return this._edges.forEach(function(e){e.forEach(function(e){t.add(e)})}),w(t)}},{key:"getNeighbors",value:function t(t){var e=[],r=this._getVertex(t);if(r){var n=this.edgesOf(r);var i=true,u=false,a=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var h=s.value;var l=this._getVertex(h.vertices.filter(function(t){return t!==r.key})[0]);l&&e.push(l)}}catch(t){u=true;a=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(u){throw a}}}}return e}},{key:"getEndsOfEdge",value:function t(t){if(!this.hasEdge(t.vertices[0],t.vertices[1]))return null;var e=this._getVertex(t.vertices[0]),r=this._getVertex(t.vertices[1]);return e&&r?[e,r]:null}},{key:"_addEdgeOnly",value:function t(t){var e=true,r=false,n=undefined;try{for(var i=t.vertices[Symbol.iterator](),u;!(e=(u=i.next()).done);e=true){var a=u.value;var o=this._getVertex(a);if(o===null)return!1;if(o){var s=this._edges.get(o);s?s.push(t):this._edges.set(o,[t])}}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}return!0}}]);return r}(t_);var tN=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i,u,o){a(this,r);var s;s=e.call(this,t,i);g(n(s),"lat");g(n(s),"long");s.lat=u,s.long=o;return s}return r}(tk),tM=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,n,i,u){a(this,r);return e.call(this,t,n,i,u)}return r}(tm),tR=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i){a(this,r);var u;u=e.call(this);g(n(u),"_origin",[0,0]);g(n(u),"_bottomRight");u._origin=t,u._bottomRight=i;return u}h(r,[{key:"origin",get:function t(){return this._origin}},{key:"bottomRight",get:function t(){return this._bottomRight}},{key:"createVertex",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.origin[0],n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.origin[1];return new tN(t,e,r,n)}},{key:"createEdge",value:function t(t,e,r,n){return new tM(t,e,r,n)}}]);return r}(tx);var tS=/*#__PURE__*/function(){function t(e,r){a(this,t);g(this,"key");g(this,"value");g(this,"parent");g(this,"_left");g(this,"_right");this.key=e,this.value=r}h(t,[{key:"left",get:function t(){return this._left},set:function t(t){t&&(t.parent=this),this._left=t}},{key:"right",get:function t(){return this._right},set:function t(t){t&&(t.parent=this),this._right=t}},{key:"familyPosition",get:function t(){var t=this;return this.parent?this.parent.left===t?this.left||this.right?"ROOT_LEFT":"LEFT":this.parent.right===t?this.left||this.right?"ROOT_RIGHT":"RIGHT":"MAL_NODE":this.left||this.right?"ROOT":"ISOLATED"}}]);return t}(),tO=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"iterationType","ITERATIVE");g(this,"_root");g(this,"_size");g(this,"_defaultOneParamCallback",function(t){return t.key});if(e){var r=e.iterationType,n=r===void 0?"ITERATIVE":r;this.iterationType=n}this._size=0}h(t,[{key:"root",get:function t(){return this._root}},{key:"size",get:function t(){return this._size}},{key:"createNode",value:function t(t,e){return new tS(t,e)}},{key:"add",value:function t(t,e){var r=this;var n=function(t,e){var n=new ti([t]);for(;n.size>0;){var i=n.shift();if(e&&i.key===e.key){i.value=e.value;return}var u=r._addTo(e,i);if(u!==void 0)return u;i.left&&n.push(i.left),i.right&&n.push(i.right)}},i,u;if(t===null)u=null;else if(this.isNodeKey(t))u=this.createNode(t,e);else if(c(t,tS))u=t;else return;return this.root?i=n(this.root,u):(this._setRoot(u),u?this._size=1:this._size=0,i=this.root),i}},{key:"addMany",value:function t(t,e){var r=this;return t.map(function(t,n){if(c(t,tS))return r.add(t.key,t.value);if(t===null)return r.add(null);var i=e===null||e===void 0?void 0:e[n];return r.add(t,i)})}},{key:"refill",value:function t(t,e){return this.clear(),t.length===this.addMany(t,e).length}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback;var r=[];if(!this.root)return r;(!e||e===this._defaultOneParamCallback)&&c(t,tS)&&(e=function(t){return t});var n=this.getNode(t,e);if(!n)return r;var i=(n===null||n===void 0?void 0:n.parent)?n.parent:null,u,a=n;if(n.left){if(n.left){var o=this.getRightMost(n.left);if(o){var s=o.parent;a=this._swap(n,o),s&&(s.right===o?s.right=o.left:s.left=o.left,u=s)}}}else if(!i)this._setRoot(null);else{var h=n.familyPosition;h==="LEFT"||h==="ROOT_LEFT"?i.left=n.right:(h==="RIGHT"||h==="ROOT_RIGHT")&&(i.right=n.right),u=i}return this._size=this.size-1,r.push({deleted:a,needBalanced:u}),r}},{key:"getDepth",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root;t=this.ensureNotKey(t),e=this.ensureNotKey(e);var r=0;for(;t===null||t===void 0?void 0:t.parent;){if(t===e)return r;r++,t=t.parent}return r}},{key:"getHeight",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;if(t=this.ensureNotKey(t),!t)return-1;if(e==="RECURSIVE"){var r=function(t){if(!t)return-1;var e=r(t.left),n=r(t.right);return Math.max(e,n)+1};return r(t)}else{var n=[{node:t,depth:0}],i=0;for(;n.length>0;){var u=n.pop(),a=u.node,o=u.depth;a.left&&n.push({node:a.left,depth:o+1}),a.right&&n.push({node:a.right,depth:o+1}),i=Math.max(i,o)}return i}}},{key:"getMinHeight",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;if(t=this.ensureNotKey(t),!t)return-1;if(e==="RECURSIVE"){var r=function(t){if(!t||!t.left&&!t.right)return 0;var e=r(t.left),n=r(t.right);return Math.min(e,n)+1};return r(t)}else{var n=[],i=t,u=null,a=new Map;for(;n.length>0||i;)if(i)n.push(i),i=i.left;else if(i=n[n.length-1],!i.right||u===i.right){if(i=n.pop(),i){var o,s;var h=i.left?(o=a.get(i.left))!==null&&o!==void 0?o:-1:-1,l=i.right?(s=a.get(i.right))!==null&&s!==void 0?s:-1:-1;a.set(i,1+Math.min(h,l)),u=i,i=null}}else i=i.right;var f;return(f=a.get(t))!==null&&f!==void 0?f:-1}}},{key:"isPerfectlyBalanced",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root;return this.getMinHeight(t)+1>=this.getHeight(t)}},{key:"getNodes",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.root,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.iterationType;if((!e||e===this._defaultOneParamCallback)&&c(t,tS)&&(e=function(t){return t}),n=this.ensureNotKey(n),!n)return[];var u=[];if(i==="RECURSIVE"){var a=function(n){e(n)===t&&(u.push(n),r)||!n.left&&!n.right||(n.left&&a(n.left),n.right&&a(n.right))};a(n)}else{var o=new ti([n]);for(;o.size>0;){var s=o.shift();if(s){if(e(s)===t&&(u.push(s),r))return u;s.left&&o.push(s.left),s.right&&o.push(s.right)}}}return u}},{key:"has",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;return(!e||e===this._defaultOneParamCallback)&&c(t,tS)&&(e=function(t){return t}),this.getNodes(t,e,!0,r,n).length>0}},{key:"getNode",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i;return(!e||e===this._defaultOneParamCallback)&&c(t,tS)&&(e=function(t){return t}),(i=this.getNodes(t,e,!0,r,n)[0])!==null&&i!==void 0?i:null}},{key:"getNodeByKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";if(this.root)if(e==="RECURSIVE"){var r=function(e){if(e.key===t)return e;if(!(!e.left&&!e.right)){if(e.left)return r(e.left);if(e.right)return r(e.right)}};return r(this.root)}else{var n=new ti([this.root]);for(;n.size>0;){var i=n.shift();if(i){if(i.key===t)return i;i.left&&n.push(i.left),i.right&&n.push(i.right)}}}}},{key:"ensureNotKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";return this.isNodeKey(t)?this.getNodeByKey(t,e):t}},{key:"get",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i;var u;return(!e||e===this._defaultOneParamCallback)&&c(t,tS)&&(e=function(t){return t}),(u=(i=this.getNode(t,e,r,n))===null||i===void 0?void 0:i.value)!==null&&u!==void 0?u:void 0}},{key:"clear",value:function t(){this._setRoot(void 0),this._size=0}},{key:"isEmpty",value:function t(){return this.size===0}},{key:"getPathToRoot",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;var r=[];if(t=this.ensureNotKey(t),!t)return r;for(;t.parent;)r.push(t),t=t.parent;return r.push(t),e?r.reverse():r}},{key:"getLeftMost",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;var r=this;if(t=this.ensureNotKey(t),!t)return t;if(e==="RECURSIVE"){var n=function(t){return r.isRealNode(t.left)?n(t.left):t};return n(t)}else{var i=P(function(t){return r.isRealNode(t.left)?i.cont(t.left):t});return i(t)}}},{key:"getRightMost",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;var r=this;if(t=this.ensureNotKey(t),!t)return t;if(e==="RECURSIVE"){var n=function(t){return r.isRealNode(t.right)?n(t.right):t};return n(t)}else{var i=P(function(t){return r.isRealNode(t.right)?i.cont(t.right):t});return i(t)}}},{key:"isSubtreeBST",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;if(t=this.ensureNotKey(t),!t)return!0;if(e==="RECURSIVE"){var r=function(t,e,n){return t?t.key<=e||t.key>=n?!1:r(t.left,e,t.key)&&r(t.right,t.key,n):!0};return r(t,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)}else{var n=[],i=Number.MIN_SAFE_INTEGER,u=t;for(;u||n.length>0;){for(;u;)n.push(u),u=u.left;if(u=n.pop(),!u||i>=u.key)return!1;i=u.key,u=u.right}return!0}}},{key:"isBST",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;return this.root===null?!0:this.isSubtreeBST(this.root,t)}},{key:"subTreeTraverse",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.iterationType,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;e=this.ensureNotKey(e);var u=[];if(!e)return u;if(r==="RECURSIVE"){var a=function(e){e!==void 0&&(u.push(t(e)),n?(e&&i.isNodeOrNull(e.left)&&a(e.left),e&&i.isNodeOrNull(e.right)&&a(e.right)):(e&&e.left&&a(e.left),e&&e.right&&a(e.right)))};a(e)}else{var o=[e];for(;o.length>0;){var s=o.pop();s!==void 0&&(u.push(t(s)),n?(s&&this.isNodeOrNull(s.right)&&o.push(s.right),s&&this.isNodeOrNull(s.left)&&o.push(s.left)):(s&&s.right&&o.push(s.right),s&&s.left&&o.push(s.left)))}}return u}},{key:"isRealNode",value:function t(t){return c(t,tS)&&t.key.toString()!=="NaN"}},{key:"isNIL",value:function t(t){return c(t,tS)&&t.key.toString()==="NaN"}},{key:"isNodeOrNull",value:function t(t){return this.isRealNode(t)||t===null}},{key:"isNodeKey",value:function t(t){return typeof t=="number"}},{key:"dfs",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"in",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"ITERATIVE",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;var u=this;if(r=this.ensureNotKey(r),!r)return[];var a=[];if(n==="RECURSIVE"){var o=function(r){switch(e){case"in":i?(r&&u.isNodeOrNull(r.left)&&o(r.left),u.isNodeOrNull(r)&&a.push(t(r)),r&&u.isNodeOrNull(r.right)&&o(r.right)):(r&&r.left&&o(r.left),u.isRealNode(r)&&a.push(t(r)),r&&r.right&&o(r.right));break;case"pre":i?(u.isNodeOrNull(r)&&a.push(t(r)),r&&u.isNodeOrNull(r.left)&&o(r.left),r&&u.isNodeOrNull(r.right)&&o(r.right)):(u.isRealNode(r)&&a.push(t(r)),r&&r.left&&o(r.left),r&&r.right&&o(r.right));break;case"post":i?(r&&u.isNodeOrNull(r.left)&&o(r.left),r&&u.isNodeOrNull(r.right)&&o(r.right),u.isNodeOrNull(r)&&a.push(t(r))):(r&&r.left&&o(r.left),r&&r.right&&o(r.right),u.isRealNode(r)&&a.push(t(r)));break}};o(r)}else{var s=[{opt:0,node:r}];for(;s.length>0;){var h=s.pop();if(!(h===void 0||this.isNIL(h.node))){if(i){if(h.node===void 0)continue}else if(h.node===null||h.node===void 0)continue;if(h.opt===1)a.push(t(h.node));else switch(e){case"in":h.node&&s.push({opt:0,node:h.node.right}),s.push({opt:1,node:h.node}),h.node&&s.push({opt:0,node:h.node.left});break;case"pre":h.node&&s.push({opt:0,node:h.node.right}),h.node&&s.push({opt:0,node:h.node.left}),s.push({opt:1,node:h.node});break;case"post":s.push({opt:1,node:h.node}),h.node&&s.push({opt:0,node:h.node.right}),h.node&&s.push({opt:0,node:h.node.left});break;default:h.node&&s.push({opt:0,node:h.node.right}),s.push({opt:1,node:h.node}),h.node&&s.push({opt:0,node:h.node.left});break}}}}return a}},{key:"bfs",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.iterationType,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;if(e=this.ensureNotKey(e),!e)return[];var u=[];if(r==="RECURSIVE"){var a=new ti([e]),o=function(e){if(a.size===0)return;var r=a.shift();u.push(t(r)),n?(r&&i.isNodeOrNull(r.left)&&a.push(r.left),r&&i.isNodeOrNull(r.right)&&a.push(r.right)):(r.left&&a.push(r.left),r.right&&a.push(r.right)),o(e+1)};o(0)}else{var s=new ti([e]);for(;s.size>0;){var h=s.size;for(var l=0;l<h;l++){var f=s.shift();u.push(t(f)),n?(f&&this.isNodeOrNull(f.left)&&s.push(f.left),f&&this.isNodeOrNull(f.right)&&s.push(f.right)):(f.left&&s.push(f.left),f.right&&s.push(f.right))}}}return u}},{key:"listLevels",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.root,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.iterationType,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;var i=this;e=this.ensureNotKey(e);var u=[];if(!e)return u;if(r==="RECURSIVE"){var a=function(e,r){u[r]||(u[r]=[]),u[r].push(t(e)),n?(e&&i.isNodeOrNull(e.left)&&a(e.left,r+1),e&&i.isNodeOrNull(e.right)&&a(e.right,r+1)):(e&&e.left&&a(e.left,r+1),e&&e.right&&a(e.right,r+1))};a(e,0)}else{var o=[[e,0]];for(;o.length>0;){var s=o.pop(),h=x(s,2),l=h[0],f=h[1];u[f]||(u[f]=[]),u[f].push(t(l)),n?(l&&this.isNodeOrNull(l.right)&&o.push([l.right,f+1]),l&&this.isNodeOrNull(l.left)&&o.push([l.left,f+1])):(l&&l.right&&o.push([l.right,f+1]),l&&l.left&&o.push([l.left,f+1]))}}return u}},{key:"getPredecessor",value:function t(t){if(t=this.ensureNotKey(t),!!this.isRealNode(t))if(t.left){var e=t.left;for(;!this.isRealNode(e)||this.isRealNode(e.right)&&e.right!==t;)e&&(e=e.right);return e}else return t}},{key:"getSuccessor",value:function t(t){if(t=this.ensureNotKey(t),!t)return;if(t.right)return this.getLeftMost(t.right);var e=t.parent;for(;e&&e&&t===e.right;)t=e,e=e.parent;return e}},{key:"morris",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"in",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root;if(r=this.ensureNotKey(r),r===null)return[];var n=[],i=r,u=function(t){var e=null,r=null;for(;t;)r=t.right,t.right=e,e=t,t=r;return e},a=function(e){var r=u(e),i=r;for(;i;)n.push(t(i)),i=i.right;u(r)};switch(e){case"in":for(;i;){if(i.left){var o=this.getPredecessor(i);if(o.right)o.right=null;else{o.right=i,i=i.left;continue}}n.push(t(i)),i=i.right}break;case"pre":for(;i;){if(i.left){var s=this.getPredecessor(i);if(s.right)s.right=null;else{s.right=i,n.push(t(i)),i=i.left;continue}}else n.push(t(i));i=i.right}break;case"post":for(;i;){if(i.left){var h=this.getPredecessor(i);if(h.right===null){h.right=i,i=i.left;continue}else h.right=null,a(i.left)}i=i.right}a(r);break}return n}},{key:Symbol.iterator,value:function t(){var t,e,r,n,i,u;var a=arguments;return O(this,function(o){switch(o.label){case 0:t=a.length>0&&a[0]!==void 0?a[0]:this.root;if(!t)return[3,12];if(!(this.iterationType==="ITERATIVE"))return[3,6];e=[],r=t;o.label=1;case 1:if(!(r||e.length>0))return[3,5];for(;r;)e.push(r),r=r.left;r=e.pop();n=r;if(!n)return[3,3];return[4,r.key];case 2:n=o.sent();o.label=3;case 3:n,r&&(r=r.right);o.label=4;case 4:return[3,1];case 5:return[3,12];case 6:i=t.left;if(!i)return[3,8];return[5,T(this[Symbol.iterator](t.left))];case 7:i=o.sent();o.label=8;case 8:i;return[4,t.key];case 9:o.sent();u=t.right;if(!u)return[3,11];return[5,T(this[Symbol.iterator](t.right))];case 10:u=o.sent();o.label=11;case 11:u;o.label=12;case 12:return[2]}})}},{key:"print",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root;var e=this;if(t=this.ensureNotKey(t),!t)return;var r=function(t){var e=x(n(t),1),r=e[0];var i=true,u=false,a=undefined;try{for(var o=r[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var h=s.value;console.log(h)}}catch(t){u=true;a=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(u){throw a}}}},n=function(t){var r,i;if(!e.isRealNode(t))return[[],0,0,0];if(e.isRealNode(t)&&!e.isRealNode(t.right)&&!e.isRealNode(t.left)){var u="".concat(t.key),a=u.length,o=1,s=Math.floor(a/2);return[[u],a,o,s]}if(e.isRealNode(t)&&!e.isRealNode(t.right)){var h=x(n(t.left),4),l=h[0],f=h[1],v=h[2],c=h[3],d="".concat(t.key),y=d.length,g=" ".repeat(c+1)+"_".repeat(f-c-1)+d,p=" ".repeat(c)+"/"+" ".repeat(f-c-1+y),_=l.map(function(t){return t+" ".repeat(y)});return[[g,p].concat(w(_)),f+y,v+2,f+Math.floor(y/2)]}if(e.isRealNode(t)&&!e.isRealNode(t.left)){var k=x(n(t.right),4),m=k[0],b=k[1],E=k[2],N=k[3],M="".concat(t.key),R=M.length,S=M+"_".repeat(R)+" ".repeat(b-R),O=" ".repeat(N+R)+"\\"+" ".repeat(b-R-1),T=m.map(function(t){return" ".repeat(N)+t});return[[S,O].concat(w(T)),b+R,E+2,Math.floor(N/2)]}var I=x(n(t.left),4),z=I[0],V=I[1],A=I[2],L=I[3],C=x(n(t.right),4),P=C[0],F=C[1],D=C[2],j=C[3],K="".concat(t.key),B=K.length,H=" ".repeat(L+1)+"_".repeat(V-L-1)+K+"_".repeat(j)+" ".repeat(F-j),q=" ".repeat(L)+"/"+" ".repeat(V-L-1+B+j)+"\\"+" ".repeat(F-j-1);A<D?(r=z).push.apply(r,w(new Array(D-A).fill(" ".repeat(V)))):D<A&&(i=P).push.apply(i,w(new Array(A-D).fill(" ".repeat(F))));var U=z.map(function(t,e){return t+" ".repeat(B)+P[e]});return[[H,q].concat(w(U)),V+F+B,Math.max(A,D)+2,V+Math.floor(B/2)]};r(t)}},{key:"_swap",value:function t(t,e){if(t=this.ensureNotKey(t),e=this.ensureNotKey(e),t&&e){var r=e.key,n=e.value,i=this.createNode(r,n);return i&&(e.key=t.key,e.value=t.value,t.key=i.key,t.value=i.value),e}}},{key:"_addTo",value:function t(t,e){if(this.isNodeKey(e)&&(e=this.getNode(e)),e)return e.left===void 0?(e.left=t,t&&(this._size=this.size+1),e.left):e.right===void 0?(e.right=t,t&&(this._size=this.size+1),e.right):void 0}},{key:"_setRoot",value:function t(t){t&&(t.parent=void 0),this._root=t}}]);return t}();var tT=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i){a(this,r);var u;u=e.call(this,t,i);g(n(u),"parent");g(n(u),"_left");g(n(u),"_right");u.parent=void 0,u._left=void 0,u._right=void 0;return u}h(r,[{key:"left",get:function t(){return this._left},set:function t(t){t&&(t.parent=this),this._left=t}},{key:"right",get:function t(){return this._right},set:function t(t){t&&(t.parent=this),this._right=t}}]);return r}(tS),tI=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t){a(this,r);var i;i=e.call(this,t);g(n(i),"_root");g(n(i),"_comparator",function(t,e){return t-e});if(i._root=void 0,t!==void 0){var u=t.comparator;u!==void 0&&(i._comparator=u)}return i}h(r,[{key:"root",get:function t(){return this._root}},{key:"createNode",value:function t(t,e){return new tT(t,e)}},{key:"add",value:function t(t,e){if(t===null)return;var r,n;if(c(t,tT)?n=t:this.isNodeKey(t)?n=this.createNode(t,e):n=void 0,this.root===void 0)this._setRoot(n),this._size=this.size+1,r=this.root;else{var i=this.root,u=!0;for(;u;)i!==void 0&&n!==void 0?this._compare(i.key,n.key)==="eq"?(n&&(i.value=n.value),u=!1,r=i):this._compare(i.key,n.key)==="gt"?i.left===void 0?(n&&(n.parent=i),i.left=n,this._size=this.size+1,u=!1,r=i.left):i.left&&(i=i.left):this._compare(i.key,n.key)==="lt"&&(i.right===void 0?(n&&(n.parent=i),i.right=n,this._size=this.size+1,u=!1,r=i.right):i.right&&(i=i.right)):u=!1}return r}},{key:"addMany",value:function t(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var u=this;function a(t){return t.indexOf(void 0)===-1}if(!n||!a(t))return l(f(r.prototype),"addMany",this).call(this,t,e).map(function(t){return t!==null&&t!==void 0?t:void 0});var o=[],s=t.map(function(t,r){return[t,e===null||e===void 0?void 0:e[r]]}),h=[];function v(t){var e=true,r=false,n=undefined;try{for(var i=t[Symbol.iterator](),u;!(e=(u=i.next()).done);e=true){var a=x(u.value,1),o=a[0];if(c(o,tT))return!0}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}return!1}var d=function(t){var e=true,r=false,n=undefined;try{for(var i=t[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var o=x(a.value,1),s=o[0];if(u.isNodeKey(s))return!0}}catch(t){r=true;n=t}finally{try{if(!e&&i.return!=null){i.return()}}finally{if(r){throw n}}}return!1},y=[],g=[];if(v(s))h=s.sort(function(t,e){return t[0].key-e[0].key});else if(d(s))h=s.sort(function(t,e){return t[0]-e[0]});else throw new Error("Invalid input keysOrNodes");y=h.map(function(t){var e=x(t,1),r=e[0];return r}),g=h.map(function(t){var e=x(t,2),r=e[1];return r});var p=function(t,e){if(t.length===0)return;var r=Math.floor((t.length-1)/2),n=u.add(t[r],e===null||e===void 0?void 0:e[r]);o.push(n),p(t.slice(0,r),e===null||e===void 0?void 0:e.slice(0,r)),p(t.slice(r+1),e===null||e===void 0?void 0:e.slice(r+1))},_=function(){var t=[[0,h.length-1]];for(;t.length>0;){var e=t.pop();if(e){var r=x(e,2),n=r[0],i=r[1];if(n<=i){var a=n+Math.floor((i-n)/2),s=u.add(y[a],g===null||g===void 0?void 0:g[a]);o.push(s),t.push([a+1,i]),t.push([n,a-1])}}}};return i==="RECURSIVE"?p(y,g):_(),o}},{key:"lastKey",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.root,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.iterationType;var r,n,i;var u,a,o;return this._compare(0,1)==="lt"?(u=(r=this.getRightMost(t,e))===null||r===void 0?void 0:r.key)!==null&&u!==void 0?u:0:this._compare(0,1)==="gt"?(a=(n=this.getLeftMost(t,e))===null||n===void 0?void 0:n.key)!==null&&a!==void 0?a:0:(o=(i=this.getRightMost(t,e))===null||i===void 0?void 0:i.key)!==null&&o!==void 0?o:0}},{key:"getNodeByKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";var r=this;if(this.root)if(e==="RECURSIVE"){var n=function(e){if(e.key===t)return e;if(!(!e.left&&!e.right)){if(r._compare(e.key,t)==="gt"&&e.left)return n(e.left);if(r._compare(e.key,t)==="lt"&&e.right)return n(e.right)}};return n(this.root)}else{var i=new ti([this.root]);for(;i.size>0;){var u=i.shift();if(u){if(this._compare(u.key,t)==="eq")return u;this._compare(u.key,t)==="gt"&&u.left&&i.push(u.left),this._compare(u.key,t)==="lt"&&u.right&&i.push(u.right)}}}}},{key:"ensureNotKey",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ITERATIVE";return this.isNodeKey(t)?this.getNodeByKey(t,e):t}},{key:"getNodes",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.root,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.iterationType;var u=this;if(n=this.ensureNotKey(n),!n)return[];var a=[];if(i==="RECURSIVE"){var o=function(n){e(n)===t&&(a.push(n),r)||!n.left&&!n.right||(e===u._defaultOneParamCallback?(u._compare(n.key,t)==="gt"&&n.left&&o(n.left),u._compare(n.key,t)==="lt"&&n.right&&o(n.right)):(n.left&&o(n.left),n.right&&o(n.right)))};o(n)}else{var s=new ti([n]);for(;s.size>0;){var h=s.shift();if(h){if(e(h)===t&&(a.push(h),r))return a;e===this._defaultOneParamCallback?(this._compare(h.key,t)==="gt"&&h.left&&s.push(h.left),this._compare(h.key,t)==="lt"&&h.right&&s.push(h.right)):(h.left&&s.push(h.left),h.right&&s.push(h.right))}}}return a}},{key:"lesserOrGreaterTraverse",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._defaultOneParamCallback,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"lt",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i=this;r=this.ensureNotKey(r);var u=[];if(!r||!this.root)return u;var a=r.key;if(n==="RECURSIVE"){var o=function(r){i._compare(r.key,a)===e&&u.push(t(r)),!(!r.left&&!r.right)&&(r.left&&i._compare(r.left.key,a)===e&&o(r.left),r.right&&i._compare(r.right.key,a)===e&&o(r.right))};return o(this.root),u}else{var s=new ti([this.root]);for(;s.size>0;){var h=s.shift();h&&(this._compare(h.key,a)===e&&u.push(t(h)),h.left&&this._compare(h.left.key,a)===e&&s.push(h.left),h.right&&this._compare(h.right.key,a)===e&&s.push(h.right))}return u}}},{key:"perfectlyBalance",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;var e=this;var r=this.dfs(function(t){return t},"in"),n=r.length;if(this.clear(),r.length<1)return!1;if(t==="RECURSIVE"){var i=function(t,n){if(t>n)return;var u=t+Math.floor((n-t)/2),a=r[u];e.add(a.key,a.value),i(t,u-1),i(u+1,n)};return i(0,n-1),!0}else{var u=[[0,n-1]];for(;u.length>0;){var a=u.pop();if(a){var o=x(a,2),s=o[0],h=o[1];if(s<=h){var l=s+Math.floor((h-s)/2),f=r[l];debugger;this.add(f.key,f.value),u.push([l+1,h]),u.push([s,l-1])}}}return!0}}},{key:"isAVLBalanced",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;if(!this.root)return!0;var e=!0;if(t==="RECURSIVE"){var r=function(t){if(!t)return 0;var n=r(t.left),i=r(t.right);return Math.abs(n-i)>1&&(e=!1),Math.max(n,i)+1};r(this.root)}else{var n=[],i=this.root,u,a=new Map;for(;n.length>0||i;)if(i)n.push(i),i=i.left;else if(i=n[n.length-1],!i.right||u===i.right){if(i=n.pop(),i){var o,s;var h=i.left?(o=a.get(i.left))!==null&&o!==void 0?o:-1:-1,l=i.right?(s=a.get(i.right))!==null&&s!==void 0?s:-1:-1;if(Math.abs(h-l)>1)return!1;a.set(i,1+Math.max(h,l)),u=i,i=void 0}}else i=i.right}return e}},{key:"_setRoot",value:function t(t){t&&(t.parent=void 0),this._root=t}},{key:"_compare",value:function t(t,e){var r=this._comparator(t,e);return r>0?"gt":r<0?"lt":"eq"}}]);return r}(tO);var tz=/*#__PURE__*/function(){function t(e){var r=e.frequency,n=r===void 0?0:r,i=e.max;a(this,t);g(this,"_freq");g(this,"_max");g(this,"_freqMap");g(this,"_msb");g(this,"_negativeCount");this._freq=n,this._max=i,this._freqMap={0:0},this._msb=D(i),this._negativeCount=n<0?i:0}h(t,[{key:"freqMap",get:function t(){return this._freqMap}},{key:"msb",get:function t(){return this._msb}},{key:"negativeCount",get:function t(){return this._negativeCount}},{key:"freq",get:function t(){return this._freq}},{key:"max",get:function t(){return this._max}},{key:"readSingle",value:function t(t){return this._checkIndex(t),this._readSingle(t)}},{key:"update",value:function t(t,e){this._checkIndex(t);var r=this._readSingle(t);this._update(t,e),this._updateNegativeCount(r,r+e)}},{key:"writeSingle",value:function t(t,e){this._checkIndex(t),this._writeSingle(t,e)}},{key:"read",value:function t(t){if(!Number.isInteger(t))throw new Error("Invalid count");return this._read(Math.max(Math.min(t,this.max),0))}},{key:"lowerBound",value:function t(t){if(this.negativeCount>0)throw new Error("Sequence is not non-descending");return this._binarySearch(t,function(t,e){return t<e})}},{key:"upperBound",value:function t(t){if(this.negativeCount>0)throw new Error("Must not be descending");return this._binarySearch(t,function(t,e){return t<=e})}},{key:"getPrefixSum",value:function t(t){this._checkIndex(t),t++;var e=0;for(;t>0;)e+=this._getFrequency(t),t-=t&-t;return e}},{key:"_getFrequency",value:function t(t){return t in this.freqMap?this.freqMap[t]:this.freq*(t&-t)}},{key:"_updateFrequency",value:function t(t,e){this.freqMap[t]=this._getFrequency(t)+e}},{key:"_checkIndex",value:function t(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).")}},{key:"_readSingle",value:function t(t){t=t+1;var e=this._getFrequency(t),r=t-(t&-t);for(t--;t!==r;)e-=this._getFrequency(t),t-=t&-t;return e}},{key:"_updateNegativeCount",value:function t(t,e){t<0&&e>=0?this._negativeCount--:t>=0&&e<0&&this._negativeCount++}},{key:"_update",value:function t(t,e){for(t=t+1;t<=this.max;)this._updateFrequency(t,e),t+=t&-t}},{key:"_writeSingle",value:function t(t,e){var r=this._readSingle(t);this._update(t,e-r),this._updateNegativeCount(r,e)}},{key:"_read",value:function t(t){var e=t,r=0;for(;e;)r+=this._getFrequency(e),e-=e&-e;return r}},{key:"_binarySearch",value:function t(t,e){var r=0,n=this.msb<<1,i=t;for(;n>r+1;){var u=r+n>>1,a=this._getFrequency(u);u<=this.max&&e(a,i)?(i-=a,r=u):n=u}return r}}]);return t}();var tV=function t(e,r,n,i){a(this,t);g(this,"start",0);g(this,"end",0);g(this,"value",null);g(this,"sum",0);g(this,"left",null);g(this,"right",null);this.start=e,this.end=r,this.sum=n,this.value=i||null},tA=/*#__PURE__*/function(){function t(e,r,n){a(this,t);g(this,"_values",[]);g(this,"_start",0);g(this,"_end");g(this,"_root");r=r||0,n=n||e.length-1,this._values=e,this._start=r,this._end=n,e.length>0?this._root=this.build(r,n):(this._root=null,this._values=[])}h(t,[{key:"values",get:function t(){return this._values}},{key:"start",get:function t(){return this._start}},{key:"end",get:function t(){return this._end}},{key:"root",get:function t(){return this._root}},{key:"build",value:function t(t,e){if(t>e)return new tV(t,e,0);if(t===e)return new tV(t,e,this._values[t]);var r=t+Math.floor((e-t)/2),n=this.build(t,r),i=this.build(r+1,e),u=new tV(t,e,n.sum+i.sum);return u.left=n,u.right=i,u}},{key:"updateNode",value:function t(t,e,r){var n=this.root||null;if(!n)return;var i=function(t,e,r,n){if(t.start===t.end&&t.start===e){t.sum=r,n!==void 0&&(t.value=n);return}var u=t.start+Math.floor((t.end-t.start)/2);e<=u?t.left&&i(t.left,e,r,n):t.right&&i(t.right,e,r,n),t.left&&t.right&&(t.sum=t.left.sum+t.right.sum)};i(n,t,e,r)}},{key:"querySumByRange",value:function t(t,e){var r=this.root||null;if(!r)return 0;if(t<0||e>=this.values.length||t>e)return NaN;var n=function(t,e,r){if(e<=t.start&&r>=t.end)return t.sum;var i=t.start+Math.floor((t.end-t.start)/2);if(r<=i)return t.left?n(t.left,e,r):NaN;if(e>i)return t.right?n(t.right,e,r):NaN;{var u=0,a=0;return t.left&&(u=n(t.left,e,i)),t.right&&(a=n(t.right,i+1,r)),u+a}};return n(r,t,e)}}]);return t}();var tL=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i){a(this,r);var u;u=e.call(this,t,i);g(n(u),"height");u.height=0;return u}return r}(tT),tC=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t){a(this,r);return e.call(this,t)}h(r,[{key:"createNode",value:function t(t,e){return new tL(t,e)}},{key:"add",value:function t(t,e){if(t===null)return;var n=l(f(r.prototype),"add",this).call(this,t,e);return n&&this._balancePath(n),n}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback;c(t,tL)&&(e=function(t){return t});var n=l(f(r.prototype),"delete",this).call(this,t,e);var i=true,u=false,a=undefined;try{for(var o=n[Symbol.iterator](),s;!(i=(s=o.next()).done);i=true){var h=s.value,v=h.needBalanced;v&&this._balancePath(v)}}catch(t){u=true;a=t}finally{try{if(!i&&o.return!=null){o.return()}}finally{if(u){throw a}}}return n}},{key:"_swap",value:function t(t,e){if(t=this.ensureNotKey(t),e=this.ensureNotKey(e),t&&e){var r=e.key,n=e.value,i=e.height,u=this.createNode(r,n);return u&&(u.height=i,e.key=t.key,e.value=t.value,e.height=t.height,t.key=u.key,t.value=u.value,t.height=u.height),e}}},{key:"_balanceFactor",value:function t(t){return t.right?t.left?t.right.height-t.left.height:+t.height:-t.height}},{key:"_updateHeight",value:function t(t){if(!t.left&&!t.right)t.height=0;else if(t.left)t.right?t.height=1+Math.max(t.right.height,t.left.height):t.height=1+t.left.height;else{var e=t.right?t.right.height:0;t.height=1+e}}},{key:"_balancePath",value:function t(t){var e=this.getPathToRoot(t,!1);for(var r=0;r<e.length;r++){var n=e[r];switch(this._updateHeight(n),this._balanceFactor(n)){case-2:n&&n.left&&(this._balanceFactor(n.left)<=0?this._balanceLL(n):this._balanceLR(n));break;case 2:n&&n.right&&(this._balanceFactor(n.right)>=0?this._balanceRR(n):this._balanceRL(n))}}}},{key:"_balanceLL",value:function t(t){var e=t.parent,r=t.left;t.parent=r,r&&r.right&&(r.right.parent=t),r&&(r.parent=e),t===this.root?r&&this._setRoot(r):(e===null||e===void 0?void 0:e.left)===t?e.left=r:e&&(e.right=r),r&&(t.left=r.right,r.right=t),this._updateHeight(t),r&&this._updateHeight(r)}},{key:"_balanceLR",value:function t(t){var e=t.parent,r=t.left,n;r&&(n=r.right),t&&(t.parent=n),r&&(r.parent=n),n&&(n.left&&(n.left.parent=r),n.right&&(n.right.parent=t),n.parent=e),t===this.root?n&&this._setRoot(n):e&&(e.left===t?e.left=n:e.right=n),n&&(t.left=n.right,r&&(r.right=n.left),n.left=r,n.right=t),this._updateHeight(t),r&&this._updateHeight(r),n&&this._updateHeight(n)}},{key:"_balanceRR",value:function t(t){var e=t.parent,r=t.right;t.parent=r,r&&(r.left&&(r.left.parent=t),r.parent=e),t===this.root?r&&this._setRoot(r):e&&(e.left===t?e.left=r:e.right=r),r&&(t.right=r.left,r.left=t),this._updateHeight(t),r&&this._updateHeight(r)}},{key:"_balanceRL",value:function t(t){var e=t.parent,r=t.right,n;r&&(n=r.left),t.parent=n,r&&(r.parent=n),n&&(n.left&&(n.left.parent=t),n.right&&(n.right.parent=r),n.parent=e),t===this.root?n&&this._setRoot(n):e&&(e.left===t?e.left=n:e.right=n),n&&(t.right=n.left),r&&n&&(r.left=n.right),n&&(n.left=t),n&&(n.right=r),this._updateHeight(t),r&&this._updateHeight(r),n&&this._updateHeight(n)}}]);return r}(tI);var tP=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;a(this,r);var o;o=e.call(this,t,i);g(n(o),"color");o.color=u;return o}return r}(tT),tF=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t){a(this,r);var i;i=e.call(this,t);g(n(i),"NIL",new tP(NaN));g(n(i),"_root");g(n(i),"_size",0);i._root=i.NIL;return i}h(r,[{key:"root",get:function t(){return this._root}},{key:"size",get:function t(){return this._size}},{key:"add",value:function t(t,e){var r;if(this.isNodeKey(t))r=this.createNode(t,e,1);else if(c(t,tP))r=t;else return void 0;r.left=this.NIL,r.right=this.NIL;var n,i=this.root;for(;i!==this.NIL;)n=i,i&&r.key<i.key?i=i.left:i=i===null||i===void 0?void 0:i.right;if(r.parent=n,n===void 0?this._setRoot(r):r.key<n.key?n.left=r:n.right=r,r.parent===void 0){r.color=0,this._size++;return}if(r.parent.parent===void 0){this._size++;return}this._fixInsert(r),this._size++}},{key:"createNode",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return new tP(t,e,r)}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback;var r=this;var n=[];return t===null||function(n){var i=r.NIL,u,a;for(;n!==r.NIL;)n&&e(n)===t&&(i=n),n&&t&&e(n)<=t?n=n.right:n=n===null||n===void 0?void 0:n.left;if(i===r.NIL){r._size--;return}a=i;var o=a.color;i.left===r.NIL?(u=i.right,r._rbTransplant(i,i.right)):i.right===r.NIL?(u=i.left,r._rbTransplant(i,i.left)):(a=r.getLeftMost(i.right),o=a.color,u=a.right,a.parent===i?u.parent=a:(r._rbTransplant(a,a.right),a.right=i.right,a.right.parent=a),r._rbTransplant(i,a),a.left=i.left,a.left.parent=a,a.color=i.color),o===0&&r._fixDelete(u),r._size--}(this.root),n}},{key:"isRealNode",value:function t(t){return t!==this.NIL&&t!==void 0}},{key:"getNode",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.root,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:this.iterationType;var i;return c(t,tS)&&(e=function(t){return t}),r=this.ensureNotKey(r),(i=this.getNodes(t,e,!0,r,n)[0])!==null&&i!==void 0?i:void 0}},{key:"getSuccessor",value:function t(t){var e;if(t.right!==this.NIL)return(e=this.getLeftMost(t.right))!==null&&e!==void 0?e:void 0;var r=t.parent;for(;r!==this.NIL&&r!==void 0&&t===r.right;)t=r,r=r.parent;return r}},{key:"getPredecessor",value:function t(t){if(t.left!==this.NIL)return this.getRightMost(t.left);var e=t.parent;for(;e!==this.NIL&&t===e.left;)t=e,e=e.parent;return e}},{key:"clear",value:function t(){this._root=this.NIL,this._size=0}},{key:"_setRoot",value:function t(t){t&&(t.parent=void 0),this._root=t}},{key:"_leftRotate",value:function t(t){if(t.right){var e=t.right;t.right=e.left,e.left!==this.NIL&&e.left&&(e.left.parent=t),e.parent=t.parent,t.parent===void 0?this._setRoot(e):t===t.parent.left?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}}},{key:"_rightRotate",value:function t(t){if(t.left){var e=t.left;t.left=e.right,e.right!==this.NIL&&e.right&&(e.right.parent=t),e.parent=t.parent,t.parent===void 0?this._setRoot(e):t===t.parent.right?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}}},{key:"_fixDelete",value:function t(t){var e;for(;t!==this.root&&t.color===0;)t.parent&&t===t.parent.left?(e=t.parent.right,e.color===1&&(e.color=0,t.parent.color=1,this._leftRotate(t.parent),e=t.parent.right),e.left!==void 0&&e.left.color===0&&e.right&&e.right.color===0?(e.color=1,t=t.parent):(e.right&&e.right.color===0&&(e.left&&(e.left.color=0),e.color=1,this._rightRotate(e),e=t.parent.right),e&&(e.color=t.parent.color),t.parent.color=0,e&&e.right&&(e.right.color=0),this._leftRotate(t.parent),t=this.root)):(e=t.parent.left,e.color===1&&(e.color=0,t.parent.color=1,this._rightRotate(t.parent),e=t.parent.left),e&&e.right&&e.right.color===0&&e.right.color===0?(e.color=1,t=t.parent):(e&&e.left&&e.left.color===0&&(e.right&&(e.right.color=0),e.color=1,this._leftRotate(e),e=t.parent.left),e&&(e.color=t.parent.color),t.parent.color=0,e&&e.left&&(e.left.color=0),this._rightRotate(t.parent),t=this.root));t.color=0}},{key:"_rbTransplant",value:function t(t,e){t.parent===void 0?this._setRoot(e):t===t.parent.left?t.parent.left=e:t.parent.right=e,e.parent=t.parent}},{key:"_fixInsert",value:function t(t){var e;for(;t.parent&&t.parent.color===1&&(t.parent.parent&&t.parent===t.parent.parent.right?(e=t.parent.parent.left,e&&e.color===1?(e.color=0,t.parent.color=0,t.parent.parent.color=1,t=t.parent.parent):(t===t.parent.left&&(t=t.parent,this._rightRotate(t)),t.parent.color=0,t.parent.parent.color=1,this._leftRotate(t.parent.parent))):(e=t.parent.parent.right,e&&e.color===1?(e.color=0,t.parent.color=0,t.parent.parent.color=1,t=t.parent.parent):(t===t.parent.right&&(t=t.parent,this._leftRotate(t)),t.parent.color=0,t.parent.parent.color=1,this._rightRotate(t.parent.parent))),t!==this.root););this.root.color=0}}]);return r}(tI);var tD=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t,i){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;a(this,r);var o;o=e.call(this,t,i);g(n(o),"count");o.count=u;return o}return r}(tL),tj=/*#__PURE__*/function(t){v(r,t);var e=S(r);function r(t){a(this,r);var i;i=e.call(this,t);g(n(i),"_count",0);return i}h(r,[{key:"count",get:function t(){return this._count}},{key:"createNode",value:function t(t,e,r){return new tD(t,e,r)}},{key:"add",value:function t(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;if(t===null)return;var n,i;if(c(t,tD)?i=this.createNode(t.key,t.value,t.count):t===void 0?i=void 0:i=this.createNode(t,e,r),!this.root)this._setRoot(i),this._size=this.size+1,i&&(this._count+=i.count),n=this.root;else{var u=this.root,a=!0;for(;a;)u?i&&(this._compare(u.key,i.key)==="eq"?(u.value=i.value,u.count+=i.count,this._count+=i.count,a=!1,n=u):this._compare(u.key,i.key)==="gt"?u.left===void 0?(u.left=i,this._size=this.size+1,this._count+=i.count,a=!1,n=u.left):u.left&&(u=u.left):this._compare(u.key,i.key)==="lt"&&(u.right===void 0?(u.right=i,this._size=this.size+1,this._count+=i.count,a=!1,n=u.right):u.right&&(u=u.right))):a=!1}return n&&this._balancePath(n),n}},{key:"addMany",value:function t(t,e){var r=[];for(var n=0;n<t.length;n++){var i=t[n];if(c(i,tD)){r.push(this.add(i.key,i.value,i.count));continue}if(i===void 0){r.push(this.add(NaN,void 0,0));continue}r.push(this.add(i,e===null||e===void 0?void 0:e[n],1))}return r}},{key:"perfectlyBalance",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.iterationType;var e=this;var r=this.dfs(function(t){return t},"in"),n=r.length;if(r.length<1)return!1;if(this.clear(),t==="RECURSIVE"){var i=function(t,n){if(t>n)return;var u=t+Math.floor((n-t)/2),a=r[u];e.add(a.key,a.value,a.count),i(t,u-1),i(u+1,n)};return i(0,n-1),!0}else{var u=[[0,n-1]];for(;u.length>0;){var a=u.pop();if(a){var o=x(a,2),s=o[0],h=o[1];if(s<=h){var l=s+Math.floor((h-s)/2),f=r[l];this.add(f.key,f.value,f.count),u.push([l+1,h]),u.push([s,l-1])}}}return!0}}},{key:"delete",value:function t(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._defaultOneParamCallback,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;var n=[];if(!this.root)return n;var i;var u=(i=this.getNode(t,e))!==null&&i!==void 0?i:void 0;if(!u)return n;var a=(u===null||u===void 0?void 0:u.parent)?u.parent:void 0,o,s=u;if(u.count>1&&!r)u.count--,this._count--;else{if(u.left){var h=u.left?this.getRightMost(u.left):void 0;if(h){var l=h.parent;s=this._swap(u,h),l&&(l.right===h?l.right=h.left:l.left=h.left,o=l)}}else if(!a)u.right!==void 0&&this._setRoot(u.right);else{var f=u.familyPosition;f==="LEFT"||f==="ROOT_LEFT"?a.left=u.right:(f==="RIGHT"||f==="ROOT_RIGHT")&&(a.right=u.right),o=a}this._size=this.size-1,s&&(this._count-=s.count)}return n.push({deleted:s,needBalanced:o}),o&&this._balancePath(o),n}},{key:"clear",value:function t(){l(f(r.prototype),"clear",this).call(this),this._count=0}},{key:"_addTo",value:function t(t,e){if(e=this.ensureNotKey(e),e)return e.left===void 0?(e.left=t,t!==void 0&&(this._size=this.size+1,this._count+=t.count),e.left):e.right===void 0?(e.right=t,t!==void 0&&(this._size=this.size+1,this._count+=t.count),e.right):void 0}},{key:"_swap",value:function t(t,e){if(t=this.ensureNotKey(t),e=this.ensureNotKey(e),t&&e){var r=e.key,n=e.value,i=e.count,u=e.height,a=this.createNode(r,n,i);return a&&(a.height=u,e.key=t.key,e.value=t.value,e.count=t.count,e.height=t.height,t.key=a.key,t.value=a.value,t.count=a.count,t.height=a.height),e}}}]);return r}(tC);var tK=/*#__PURE__*/function(){function t(e,r,n){a(this,t);g(this,"key");g(this,"value");g(this,"children");this.key=e,this.value=r||void 0,this.children=n||[]}h(t,[{key:"addChildren",value:function e(e){this.children||(this.children=[]),c(e,t)?this.children.push(e):this.children=this.children.concat(e)}},{key:"getHeight",value:function t(){var t=0;if(this){var e=function(r,n){n>t&&(t=n);var i=r.children;if(i)for(var u=0,a=i.length;u<a;u++)e(i[u],n+1)};e(this,0)}return t}}]);return t}();var tB=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"_matrix");var r=e.row,n=e.col,i=e.initialVal;this._matrix=new Array(r).fill(void 0).map(function(){return new Array(n).fill(i||0)})}h(t,[{key:"toArray",value:function t(){return this._matrix}}]);return t}();var tH=/*#__PURE__*/function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;a(this,t);this.x=e;this.y=r;this.w=n}h(t,[{key:"isZero",get:function t(){return this.x===0&&this.y===0}},{key:"length",get:function t(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"lengthSq",get:function t(){return this.x*this.x+this.y*this.y}},{key:"rounded",get:function e(){return new t(Math.round(this.x),Math.round(this.y))}},{key:"zero",value:function t(){this.x=0,this.y=0}}],[{key:"add",value:function e(e,r){return new t(e.x+r.x,e.y+r.y)}},{key:"subtract",value:function e(e,r){return new t(e.x-r.x,e.y-r.y)}},{key:"subtractValue",value:function e(e,r){return new t(e.x-r,e.y-r)}},{key:"multiply",value:function e(e,r){return new t(e.x*r,e.y*r)}},{key:"divide",value:function e(e,r){return new t(e.x/r,e.y/r)}},{key:"equals",value:function t(t,e){return t.x===e.x&&t.y===e.y}},{key:"equalsRounded",value:function e(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:12;var i=t.abs(t.subtract(e,r));return i.x<n&&i.y<n}},{key:"normalize",value:function e(e){var r=e.length;return r>2220446049250313e-31?t.divide(e,r):e}},{key:"truncate",value:function e(e,r){return e.length>r?t.multiply(t.normalize(e),r):e}},{key:"perp",value:function e(e){return new t(-e.y,e.x)}},{key:"reverse",value:function e(e){return new t(-e.x,-e.y)}},{key:"abs",value:function e(e){return new t(Math.abs(e.x),Math.abs(e.y))}},{key:"dot",value:function t(t,e){return t.x*e.x+t.y*e.y}},{key:"distance",value:function t(t,e){var r=e.y-t.y,n=e.x-t.x;return Math.sqrt(r*r+n*n)}},{key:"distanceSq",value:function t(t,e){var r=e.y-t.y,n=e.x-t.x;return r*r+n*n}},{key:"sign",value:function t(t,e){return t.y*e.x>t.x*e.y?-1:1}},{key:"angle",value:function e(e){var r=new t(0,-1),n=Math.acos(t.dot(e,r)/(e.length*r.length));return t.sign(e,r)===1?Math.PI*2-n:n}},{key:"random",value:function e(e,r){var n=Math.floor(Math.random()*e-e/2),i=Math.floor(Math.random()*r-r/2);return new t(n,i)}}]);return t}();var tq=/*#__PURE__*/function(){function t(e){a(this,t);g(this,"_matrix");(typeof e==="undefined"?"undefined":E(e))>"u"?this._matrix=t.identity:c(e,tH)?(this._matrix=t.identity,this._matrix[0][0]=e.x,this._matrix[1][0]=e.y,this._matrix[2][0]=e.w):this._matrix=e}h(t,[{key:"m",get:function t(){return this._matrix}},{key:"toVector",value:function t(){return new tH(this._matrix[0][0],this._matrix[1][0])}}],[{key:"empty",get:function t(){return[[],[],[]]}},{key:"identity",get:function t(){return[[1,0,0],[0,1,0],[0,0,1]]}},{key:"add",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var u=0;u<3;u++)n[i][u]=e.m[i][u]+r.m[i][u];return new t(n)}},{key:"subtract",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var u=0;u<3;u++)n[i][u]=e.m[i][u]-r.m[i][u];return new t(n)}},{key:"multiply",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var u=0;u<3;u++){n[i][u]=0;for(var a=0;a<3;a++)n[i][u]+=e.m[i][a]*r.m[a][u]}return new t(n)}},{key:"multiplyByValue",value:function e(e,r){var n=t.empty;for(var i=0;i<3;i++)for(var u=0;u<3;u++)n[i][u]=e.m[i][u]*r;return new t(n)}},{key:"multiplyByVector",value:function e(e,r){return t.multiply(e,new t(r)).toVector()}},{key:"view",value:function e(e,r){var n=e/2,i=r/2,u=Math.cos(Math.PI);return new t([[1,0,n],[0,u*1,i],[0,0,1]])}},{key:"scale",value:function e(e){return t.multiplyByValue(new t,e)}},{key:"rotate",value:function e(e){var r=Math.cos(e),n=Math.sin(e);return new t([[r,-n,0],[n,r,0],[0,0,1]])}},{key:"translate",value:function e(e){return new t([[1,0,e.x],[0,1,e.y],[0,0,e.w]])}}]);return t}();var tU=function t(e,r){a(this,t);g(this,"direction");g(this,"turn");this.direction=e,this.turn=function(){return new t(r[e],r)}},tG=/*#__PURE__*/function(){function t(e){var r=e.matrix,n=e.turning,i=e.onMove,u=e.init,o=u.cur,s=u.charDir,h=u.VISITED;a(this,t);g(this,"onMove");g(this,"_matrix");g(this,"_cur");g(this,"_character");g(this,"_VISITED");this._matrix=r,this._cur=o,this._character=new tU(s,n),this.onMove=i,this.onMove&&this.onMove(this._cur),this._VISITED=h,this._matrix[this._cur[0]][this._cur[1]]=this._VISITED}h(t,[{key:"start",value:function t(){for(;this.check(this._character.direction)||this.check(this._character.turn().direction);){var t=this._character,e=t.direction;this.check(e)?this.move(e):this.check(this._character.turn().direction)&&(this._character=this._character.turn())}}},{key:"check",value:function t(t){var e,r,n=this._matrix,i=x(this._cur,2),u=i[0],a=i[1];switch(t){case"up":if(r=n[u-1],!r)return!1;e=r[a];break;case"right":e=n[u][a+1];break;case"down":if(r=n[u+1],!r)return!1;e=r[a];break;case"left":e=n[u][a-1];break}return e!==void 0&&e!==this._VISITED}},{key:"move",value:function t(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}var e=x(this._cur,2),r=e[0],n=e[1];this._matrix[r][n]=this._VISITED,this.onMove&&this.onMove(this._cur)}}]);return t}();var tW=function t(e){a(this,t);g(this,"key");g(this,"children");g(this,"isEnd");this.key=e,this.isEnd=!1,this.children=new Map},tY=/*#__PURE__*/function(){function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;a(this,t);g(this,"_caseSensitive");g(this,"_root");var n=true,i=false,u=undefined;if(this._root=new tW(""),this._caseSensitive=r,e)try{for(var o=e[Symbol.iterator](),s;!(n=(s=o.next()).done);n=true){var h=s.value;this.add(h)}}catch(t){i=true;u=t}finally{try{if(!n&&o.return!=null){o.return()}}finally{if(i){throw u}}}}h(t,[{key:"caseSensitive",get:function t(){return this._caseSensitive}},{key:"root",get:function t(){return this._root}},{key:"add",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var u=t[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=a.value;var s=e.children.get(o);s||(s=new tW(o),e.children.set(o,s)),e=s}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}return e.isEnd=!0,!0}},{key:"has",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var u=t[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=a.value;var s=e.children.get(o);if(!s)return!1;e=s}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}return e.isEnd}},{key:"delete",value:function t(t){t=this._caseProcess(t);var e=!1,r=function(n,i){var u=t[i],a=n.children.get(u);return a?i===t.length-1?a.isEnd?(a.children.size>0?a.isEnd=!1:n.children.delete(u),e=!0,!0):!1:r(a,i+1)&&!n.isEnd&&a.children.size===0?(n.children.delete(u),!0):!1:!1};return r(this.root,0),e}},{key:"getHeight",value:function t(){var t=this.root,e=0;if(t){var r=function(t,n){n>e&&(e=n);var i=t.children;var u=true,a=false,o=undefined;if(i)try{for(var s=i.entries()[Symbol.iterator](),h;!(u=(h=s.next()).done);u=true){var l=h.value;r(l[1],n+1)}}catch(t){a=true;o=t}finally{try{if(!u&&s.return!=null){s.return()}}finally{if(a){throw o}}}};r(t,0)}return e}},{key:"hasPurePrefix",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var u=t[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=a.value;var s=e.children.get(o);if(!s)return!1;e=s}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}return!e.isEnd}},{key:"hasPrefix",value:function t(t){t=this._caseProcess(t);var e=this.root;var r=true,n=false,i=undefined;try{for(var u=t[Symbol.iterator](),a;!(r=(a=u.next()).done);r=true){var o=a.value;var s=e.children.get(o);if(!s)return!1;e=s}}catch(t){n=true;i=t}finally{try{if(!r&&u.return!=null){u.return()}}finally{if(n){throw i}}}return!0}},{key:"hasCommonPrefix",value:function t(t){t=this._caseProcess(t);var e="",r=function(n){if(e+=n.key,e!==t&&!n.isEnd)if(n&&n.children&&n.children.size===1)r(Array.from(n.children.values())[0]);else return};return r(this.root),e===t}},{key:"getLongestCommonPrefix",value:function t(){var t="",e=function(r){if(t+=r.key,!r.isEnd)if(r&&r.children&&r.children.size===1)e(Array.from(r.children.values())[0]);else return};return e(this.root),t}},{key:"getWords",value:function t(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_SAFE_INTEGER,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t=this._caseProcess(t);var n=[],i=0;function u(t,r){var a=true,o=false,s=undefined;try{for(var h=t.children.keys()[Symbol.iterator](),l;!(a=(l=h.next()).done);a=true){var f=l.value;var v=t.children.get(f);v!==void 0&&u(v,r.concat(f))}}catch(t){o=true;s=t}finally{try{if(!a&&h.return!=null){h.return()}}finally{if(o){throw s}}}if(t.isEnd){if(i>e-1)return;n.push(r),i++}}var a=this.root;var o=true,s=false,h=undefined;if(t)try{for(var l=t[Symbol.iterator](),f;!(o=(f=l.next()).done);o=true){var v=f.value;var c=a.children.get(v);c&&(a=c)}}catch(t){s=true;h=t}finally{try{if(!o&&l.return!=null){l.return()}}finally{if(s){throw h}}}return(r||a!==this.root)&&u(a,t),n}},{key:"_caseProcess",value:function t(t){return this._caseSensitive||(t=t.toLowerCase()),t}}]);return t}();return y(p)}();/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
4
|
* @author Tyler Zeng
|