Socket
Socket
Sign inDemoInstall

virtual-scroller

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

virtual-scroller - npm Package Compare versions

Comparing version 1.7.3 to 1.7.4

bundle/index-bypass.html

2

bundle/virtual-scroller-dom.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,c=[];s=function(e){if(0===c.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=c.slice(0);c.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return c.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<c.length;t++)c[t].handle===e&&(c[t].cancelled=!0)}}var d=function(e){return s.call(i,e)};d.cancel=function(){a.apply(i,arguments)},d.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=d.cancel;function f(e,t){var n=Date.now(),i=d(function r(){Date.now()-n>=t?e():i=d(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){return!t||"object"!==I(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function b(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),e}var C=function(){function e(t){y(this,e),this.element=t}return b(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e,t){var n,i=this,r=t.container;if("undefined"!=typeof ResizeObserver){var o=new ResizeObserver(function(t){t[0];e()});o.observe(this.element),n=function(){return o.unobserve(i.element)}}var s=(new x).onResize(e,{container:r});return function(){n&&n(),s()}}}]),e}(),x=function(e){function t(){return y(this,t),v(this,p(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(t,C),b(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e,t){var n=t.container,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var O="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function T(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var E=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"getChildElementTopCoordinate",value:function(e,t){return e.childNodes[t].getBoundingClientRect().top}},{key:"getChildElementHeight",value:function(e,t){return this.getElementHeight(e.childNodes[t])}},{key:"getChildElementsCount",value:function(e){return e.childNodes.length}},{key:"clearElement",value:function(e){!function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(e)}},{key:"getElementHeight",value:function(e){return e.getBoundingClientRect().height}}])&&T(t.prototype,n),i&&T(t,i),e}();function k(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function M(){if(A()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,k(["[virtual-scroller]"].concat(n)))}}function R(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(M.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,k(["[virtual-scroller]"].concat(t)))}function A(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function L(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var P=function(){function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=t,this.getContainerElement=n,this.getState=i,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<this.screen.getChildElementsCount(n))return this.screen.getChildElementHeight(n,i)}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(M("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),M("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);M("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&M("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&L(t.prototype,n),i&&L(t,i),e}();function V(e){return(V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var _=Object.prototype.hasOwnProperty;function U(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){N(e,t,n[t])})}return e}function j(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var D=250,z=100,F=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),N(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:Y.MANUAL})}),N(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:Y.SCROLL})}),N(this,"restoreScrollPositionFromState",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),N(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),N(this,"layout",function(){return s.updateLayout()}),N(this,"onResize",(i=function(){if(s.isRendered){var e=s.scrollableContainerWidth,t=s.scrollableContainerHeight;if(s.scrollableContainerWidth=s.scrollableContainer.getWidth(),s.scrollableContainerHeight=s.scrollableContainer.getHeight(),s.scrollableContainerWidth===e){if(s.scrollableContainerHeight===t)return;s.onUpdateShownItemIndexes({reason:Y.RESIZE})}else{M("~ Scrollable container size changed, re-measure item heights. ~"),s.redoLayoutReason=Y.RESIZE;var n=s.getInitialLayoutState();M("Reset state to",n),s.setState(n)}}},r=D,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),N(this,"willUpdateState",function(e,t){}),N(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(U(e,t))return!0;if("object"!==V(e)||null===e||"object"!==V(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!_.call(t,n[r])||!U(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){M("~ Rendered ~");var n=s.redoLayoutReason;s.redoLayoutReason=void 0;var i=e.items,r=t.items;if(r!==i){var o=!0,a=s.getItemsDiff(i,r);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;l>0&&(s.itemHeights.onPrepend(l),s.restoreScrollAfterRenderValues&&(o=!1,s.restoreScrollAfterRender()))}else s.itemHeights.initialize();o&&(n=Y.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered(),n?s.redoLayoutRightAfterRender({reason:n}):void 0}}),N(this,"updateShownItemIndexes",function(){M("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterMeasuringItemHeights,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&M("Columns count",s.getColumnsCount()),M("First shown item index",t),M("Last shown item index",n),M("Before items height",o),M("After items height (actual or estimated)",a),M("Average item height (calculated on previous render)",s.itemHeights.getAverage()),A()&&(M("Item heights",s.getState().itemHeights.slice()),M("Item states",s.getState().itemStates.slice())),i&&(s.redoLayoutReason=Y.ITEM_HEIGHT_NOT_MEASURED),s.validateWillBeHiddenItemHeightsAndState(t,n),s.onBeforeShowItems(s.getState().items,s.getState().itemHeights,t,n),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),N(this,"updateShownItemIndexesRecursive",function(){s.layoutInProgress=!0,s.updateShownItemIndexes()}),N(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()){if(s.onUserStopsScrollingTimer&&(g(s.onUserStopsScrollingTimer),s.onUserStopsScrollingTimer=void 0),t===Y.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(M(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n){if(s.layoutTimer)return;return void(s.onUserStopsScrollingTimer=f(function(){s.isRendered&&s.onUpdateShownItemIndexes({reason:Y.STOPPED_SCROLLING})},z))}}s.layoutTimer&&(g(s.layoutTimer),s.layoutTimer=void 0),M("~ Calculate Layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}});var l=a.getState,u=a.setState,h=a.onStateChange,c=a.customState,d=a.preserveScrollPositionAtBottomOnMount,m=a.measureItemsBatchSize,I=a.getScrollableContainer,v=a.getColumnsCount,p=a.getItemId,S=a.tbody,y=a._useTimeoutInRenderLoop,w=a.bypass,b=a.estimatedItemHeight,H=a.onItemInitialRender,T=a.onItemFirstRender,k=a.scrollableContainer,L=a.preserveScrollPositionOfTheBottomOfTheListOnMount,j=a.state;if(this.renderer="DOM",M("~ Initialize ~"),j&&(n=j.items),!k&&I&&(k=I()),"DOM"!==this.renderer)throw new Error('Unknown renderer: "'.concat(this.renderer,'"'));if(k?this.scrollableContainer=new C(k):"undefined"!=typeof window&&(this.scrollableContainer=new x),S){if("DOM"!==this.renderer)throw new Error("`tbody` option is only supported for DOM renderer");M("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(M("~ <tbody/> not supported ~"),R(O),w=!0)}if(w&&M('~ "bypass" mode ~'),this.bypass=w,this._useTimeoutInRenderLoop=y,this.isItemEqual=p?function(e,t){return p(e)===p(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=b,this.onStateChange=h,this.measureItemsBatchSize=void 0===m?50:m,this._getColumnsCount=v,H?this.onItemInitialRender=H:T&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&T(t)}),M("Items count",n.length),b&&M("Estimated item height",b),u?(this.getState=l,this.setState=function(e){M("Set state",e),u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){M("Set state",e);var t=s.getState(),n=B({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),j&&M("Initial state (passed)",j),"DOM"!==this.renderer)throw new Error('Unknown renderer: "'.concat(this.renderer,'"'));this.screen=new E,this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new P(this.screen,this.getContainerElement,this.getState),this.scrollableContainer&&(d&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),L=d),L&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(j||this.getInitialState(c))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=B({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return M("Initial state (autogenerated)",n),M("First shown item index",n.firstShownItemIndex),M("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1);var o=new Array(i);return this.onBeforeShowItems(n,o,e,t),{itemHeights:o,columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");M("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPositionFromState(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize,{container:this.getContainerElement()})),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:Y.MOUNT})}},{key:"onRendered",value:function(){this.measureVerticalSpacing(),this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.screen.getElementHeight(this.getContainerElement())}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),g(this.onUserStopsScrollingTimer),g(this.watchContainerElementCoordinatesTimer),g(this.layoutTimer))}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&g(this.layoutTimer),this.layoutTimer=f(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){M("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacingValue();void 0===e?M("Not enough items rendered to measure vertical spacing"):(M("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"measureVerticalSpacingValue",value:function(){var e=this.getContainerElement();if(this.screen.getChildElementsCount(e)>1)for(var t=this.screen.getChildElementTopCoordinate(e,0),n=this.screen.getChildElementHeight(e,0),i=1;i<this.screen.getChildElementsCount(e);){var r=this.screen.getChildElementTopCoordinate(e,i),o=this.screen.getChildElementHeight(e,i);if(r!==t)return r-(t+n);n=Math.max(n,o),i++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t)this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n)}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){A()&&(M("~ Item state changed ~"),M("Item",e),M("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),M("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){M("~ Re-measure item height ~"),M("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return R('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return M("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");M("Previous height",t),M("New height",n),t!==n&&(M("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:Y.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,c=0,d=0,m=void 0;d<a&&(m=u*a+d)<s;){var f=this.getState().itemHeights[m];if(void 0===f){M("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(c=Math.max(c,f),void 0===i&&n+o+c>e&&(M("First shown row index",u),i=u*a),n+o+c+h>t)return M("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};d++}o+=c,o+=h,u++}return void 0!==i&&void 0===r&&M("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterRenderValues&&(s<this.restoreScrollAfterRenderValues.index&&(s=this.restoreScrollAfterRenderValues.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterMeasuringItemHeights:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;M("The entire list is off-screen. No items are visible.")}else M("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&M("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:Y.TOP_OFFSET_CHANGED}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=f(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"captureScroll",value:function(e,t,n){if(0!==e.length&&0!==n){var i=this.getState().firstShownItemIndex,r=this.getContainerElement(),o=this.screen.getChildElementTopCoordinate(r,0);if(i>0)for(var s=this.getState().itemHeights,a=i-1;a>=0;)o+=s[a]+this.getVerticalSpacing(),a--;this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===e&&this.restoreScrollAfterRenderValues.nextItems===t||(this.restoreScrollAfterRenderValues={previousItems:e,nextItems:t,index:n,visibleAreaTop:o})}}},{key:"restoreScrollAfterRender",value:function(){M("~ Restore Scroll Position ~");var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;this.restoreScrollAfterRenderValues=void 0;var i=this.screen.getChildElementTopCoordinate(this.getContainerElement(),t)-n;0===i?M("Scroll position hasn't changed"):(M("Scroll down by",i),this.scrollTo(0,this.getScrollY()+i))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights;M("~ Update items ~");var h=this.getItemsDiff(n,e);if(h){var c=h.prependedItemsCount,d=h.appendedItemsCount;c>0&&(M("Prepend",c,"items"),u=new Array(c).concat(u),l&&(l=new Array(c).concat(l))),d>0&&(M("Append",d,"items"),u=u.concat(new Array(d)),l&&(l=l.concat(new Array(d)))),r+=c,o+=c;this.getVerticalSpacing();var m=this.getColumnsCount();if(c%m==0){var f=c/m,g=Math.ceil(d/m);s+=f*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=g*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u);c>0&&(t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition)&&(r=0,s=0,this.captureScroll(n,e,c))}else M("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),M("Previous items",n),M("New items",e),u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;M("~ Update state ~"),M("First shown item index",r),M("Last shown item index",o),M("Before items height",s),M("After items height (actual or estimated)",a),this.onBeforeShowItems(e,u,r,o),this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){for(var r=0;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}}])&&j(t.prototype,n),i&&j(t,i),e}(),Y={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"top offset changed"};function G(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function W(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return function(){function e(t,n,i){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),q(this,"onStateChange",function(e,t){var n=e.items,i=e.firstShownItemIndex,o=e.lastShownItemIndex,s=e.beforeItemsHeight,a=e.afterItemsHeight;M("~ On state change ~"),M("Previous state",t),M("New state",e),r.tbody||(r.container.style.paddingTop=H(s),r.container.style.paddingBottom=H(a));var l=t&&n===t.items&&n.length>0;if(l){M("Incremental rerender");for(var u=t.lastShownItemIndex;u>=t.firstShownItemIndex;)u>=i&&u<=o||(M("Remove item index",u),r.unmountItem(r.container.childNodes[u-t.firstShownItemIndex])),u--}else for(M("Rerender from scratch");r.container.firstChild;)r.unmountItem(r.container.firstChild);for(var h=l,c=h&&r.container.firstChild,d=i;d<=o;){if(l&&d>=t.firstShownItemIndex&&d<=t.lastShownItemIndex)h&&(h=!1);else{var m=r.renderItem(n[d]);h?(M("Prepend item index",d),r.container.insertBefore(m,c)):(M("Append item index",d),r.container.appendChild(m))}d++}}),q(this,"onUnmount",function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),q(this,"destroy",function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),q(this,"stop",function(){r.virtualScroller.stop()}),this.container=t,this.renderItem=i;var s=o.onMount,a=o.onItemUnmount,l=G(o,["onMount","onItemUnmount"]);this.onItemUnmount=a,this.tbody="TBODY"===this.container.tagName,this.virtualScroller=new F(function(){return r.container},n,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){q(e,t,n[t])})}return e}({},l,{tbody:this.tbody,onStateChange:this.onStateChange})),s&&s(),this.virtualScroller.listen()}var t,n,i;return t=e,(n=[{key:"unmountItem",value:function(e){this.container.removeChild(e),this.onItemUnmount&&this.onItemUnmount(e)}},{key:"onItemHeightChange",value:function(e){this.virtualScroller.onItemHeightChange(e)}},{key:"updateItems",value:function(e,t){this.setItems(e,t)}},{key:"setItems",value:function(e,t){this.virtualScroller.setItems(e,t)}},{key:"getItemCoordinates",value:function(e){return this.virtualScroller.getItemCoordinates(e)}}])&&W(t.prototype,n),i&&W(t,i),e}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,c=[];s=function(e){if(0===c.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=c.slice(0);c.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return c.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<c.length;t++)c[t].handle===e&&(c[t].cancelled=!0)}}var d=function(e){return s.call(i,e)};d.cancel=function(){a.apply(i,arguments)},d.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=d.cancel;function f(e,t){var n=Date.now(),i=d(function r(){Date.now()-n>=t?e():i=d(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return e.toFixed(2)+"px"}var p="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function v(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var y=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"getChildElementTopOffset",value:function(e,t){return e.childNodes[t].getBoundingClientRect().top}},{key:"getChildElementHeight",value:function(e,t){return this.getElementHeight(e.childNodes[t])}},{key:"getChildElementsCount",value:function(e){return e.childNodes.length}},{key:"clearElement",value:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}},{key:"getElementHeight",value:function(e){return e.getBoundingClientRect().height}}])&&v(t.prototype,n),i&&v(t,i),e}();function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function b(e,t){return!t||"object"!==S(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t){return(C=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function T(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function x(e,t,n){return t&&H(e.prototype,t),n&&H(e,n),e}var O=function(){function e(t){T(this,e),this.element=t}return x(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollToY",value:function(e){this.element.scrollTo(0,e)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e,t){var n,i=this,r=t.container;if("undefined"!=typeof ResizeObserver){var o=new ResizeObserver(function(t){t[0];e()});o.observe(this.element),n=function(){return o.unobserve(i.element)}}var s=k(e,{container:r});return function(){n&&n(),s()}}}]),e}(),L=function(e){function t(){return T(this,t),b(this,w(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&C(e,t)}(t,O),x(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e,t){return k(e,{container:t.container})}}]),t}();function k(e,t){var n=t.container,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}var E={name:"DOM",createScreen:function(){return new y},createScrollableContainer:function(e){return e?new O(e):"undefined"!=typeof window?new L:void 0}};function A(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function R(){if(P()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,A(["[virtual-scroller]"].concat(n)))}}function M(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(R.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,A(["[virtual-scroller]"].concat(t)))}function P(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function V(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var B=function(){function e(t){var n=t.bypass,i=t.estimatedItemHeight,r=t.measureItemsBatchSize,o=t.getVerticalSpacing,s=t.getColumnsCount,a=t.getItemHeight,l=t.getAverageItemHeight;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.bypass=n,this.estimatedItemHeight=i,this.measureItemsBatchSize=r,this.getVerticalSpacing=o,this.getColumnsCount=s,this.getItemHeight=a,this.getAverageItemHeight=l}var t,n,i;return t=e,(n=[{key:"getInitialLayoutValues",value:function(e){var t,n,i=e.bypass,r=e.itemsCount,o=e.visibleAreaHeightIncludingMargins,s=o?this.getEstimatedRowsCountForHeight(o):1;return r>0&&(t=0,n=this.getLastShownItemIndex(t,r,s,i)),{beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:t,lastShownItemIndex:n}}},{key:"getLastShownItemIndex",value:function(e,t,n,i){return this.bypass||i?t-1:Math.min(e+(n*this.getColumnsCount()-1),t-1)}},{key:"getEstimatedRowsCountForHeight",value:function(e){var t=this.getEstimatedItemHeight();return t?Math.ceil((e+this.getVerticalSpacing())/(t+this.getVerticalSpacing())):1}},{key:"getEstimatedItemHeight",value:function(){return this.getAverageItemHeight()||this.estimatedItemHeight||0}},{key:"updateLayoutForItemsDiff",value:function(e,t,n){var i=t.prependedItemsCount,r=t.appendedItemsCount,o=n.itemsCount;e.firstShownItemIndex+=i,e.lastShownItemIndex+=i;var s=this.getColumnsCount();if(i%s==0){var a=i/s,l=Math.ceil(r/s),u=this.getAverageItemHeight(),h=this.getVerticalSpacing();e.beforeItemsHeight+=a*(u+h),e.afterItemsHeight+=l*(h+u)}else e.beforeItemsHeight=this.getBeforeItemsHeight(firstShownItemIndex,lastShownItemIndex),e.afterItemsHeight=this.getAfterItemsHeight(firstShownItemIndex,lastShownItemIndex,o)}},{key:"_getVisibleItemIndexes",value:function(e,t,n,i){for(var r,o,s=this.getColumnsCount(),a=0,l=Math.ceil(i/s),u=0;u<l;){for(var h=i>(u+1)*s?this.getVerticalSpacing():0,c=0,d=0,m=void 0;d<s&&(m=u*s+d)<i;){var f=this.getItemHeight(m);if(void 0===f){R("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===r&&(r=u*s);var g=t-(n+a);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:r,lastShownItemIndex:o=Math.min((u+this.getEstimatedRowsCountForHeight(g))*s-1,i-1)}}if(c=Math.max(c,f),void 0===r&&n+a+c>e&&(R("First shown row index",u),r=u*s),n+a+c+h>t)return R("Last shown row index",u),void 0!==r&&(o=Math.min((u+1)*s-1,i-1)),{firstShownItemIndex:r,lastShownItemIndex:o};d++}a+=c,a+=h,u++}return void 0!==r&&void 0===o&&R("Last item index (is fully visible)",o=i-1),{firstShownItemIndex:r,lastShownItemIndex:o}}},{key:"getVisibleItemIndexes",value:function(e,t,n,i){var r=this._getVisibleItemIndexes(e,t,n,i),o=r.firstNonMeasuredItemIndex,s=r.firstShownItemIndex,a=r.lastShownItemIndex,l=void 0!==o;if(l&&this.measureItemsBatchSize){var u=o+this.measureItemsBatchSize-1,h=this.getColumnsCount();a=Math.min(a,Math.ceil(u/h)*h-1)}return{firstShownItemIndex:s,lastShownItemIndex:a,redoLayoutAfterMeasuringItemHeights:l}}},{key:"getNonVisibleListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getItemHeight(0)}}},{key:"getItemIndexes",value:function(e,t,n,i,r){if(n+i>e&&n<t){var o=this.getVisibleItemIndexes(e,t,n,r);if(void 0!==o.firstShownItemIndex)return o;R("The entire list is off-screen. No items are visible.")}else R("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t){for(var n=this.getColumnsCount(),i=Math.floor(e/n),r=0,o=0;o<i;){for(var s=0,a=0;a<n;)s=Math.max(s,this.getItemHeight(o*n+a)||this.getAverageItemHeight()),a++;r+=s,r+=this.getVerticalSpacing(),o++}return r}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.ceil(n/i),o=0,s=Math.floor(t/i)+1;s<r;){for(var a=0,l=0,u=void 0;l<i&&(u=s*i+l)<n;)a=Math.max(a,this.getItemHeight(u)||this.getAverageItemHeight()),l++;o+=this.getVerticalSpacing(),o+=a,s++}return o}},{key:"getShownItemIndexes",value:function(e){var t=e.listHeight,n=e.itemsCount,i=e.visibleAreaIncludingMargins,r=e.listTopOffsetInsideScrollableContainer;return this.bypass?{firstShownItemIndex:0,lastShownItemIndex:n-1}:this.getItemIndexes(i.top,i.bottom,r,t,n)||this.getNonVisibleListShownItemIndexes()}},{key:"showItemsFromTheStart",value:function(e){e.firstShownItemIndex=0,e.beforeItemsHeight=0}}])&&V(t.prototype,n),i&&V(t,i),e}(),N={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"list top offset changed"};function U(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var _=function(){function e(t){var n=t.updateLayout,i=t.getListTopOffsetInsideScrollableContainer;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.updateLayout=n,this.getListTopOffsetInsideScrollableContainer=i}var t,n,i;return t=e,(n=[{key:"onGotListTopOffset",value:function(e){void 0===this.listTopOffsetInsideScrollableContainer&&this.start(),this.listTopOffsetInsideScrollableContainer=e}},{key:"start",value:function(){this.isRendered=!0,this.watchListTopOffset()}},{key:"stop",value:function(){this.isRendered=!1,g(this.watchListTopOffsetTimer)}},{key:"watchListTopOffset",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.listTopOffsetInsideScrollableContainer&&e.getListTopOffsetInsideScrollableContainer()!==e.listTopOffsetInsideScrollableContainer&&e.updateLayout({reason:N.TOP_OFFSET_CHANGED}),Date.now()-t<D&&(e.watchListTopOffsetTimer=f(n,j)))}()}}])&&U(t.prototype,n),i&&U(t,i),e}(),j=500,D=3e3;function z(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var F=function(){function e(t){var n,i,r,o,s,a,l=this,u=t.bypass,h=t.scrollableContainer,c=t.getContainerElement,d=t.updateLayout,m=t.resetStateAndLayout;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o=function(){if(l.isRendered){var e=l.scrollableContainerWidth,t=l.scrollableContainerHeight;if(l.scrollableContainerWidth=l.scrollableContainer.getWidth(),l.scrollableContainerHeight=l.scrollableContainer.getHeight(),l.scrollableContainerWidth===e){if(l.scrollableContainerHeight===t)return;l.updateLayout({reason:N.RESIZE})}else l.resetStateAndLayout()}},s=Y,r=function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];g(a),a=f(function(){return o.apply(e,n)},s)},(i="onResize")in(n=this)?Object.defineProperty(n,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[i]=r,this.bypass=u,this.scrollableContainer=h,this.getContainerElement=c,this.updateLayout=d,this.resetStateAndLayout=m}var t,n,i;return t=e,(n=[{key:"listen",value:function(){this.bypass||(this.isRendered=!0,this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize,{container:this.getContainerElement()}))}},{key:"stop",value:function(){this.isRendered=!1,this.scrollableContainerUnlistenResize&&this.scrollableContainerUnlistenResize()}}])&&z(t.prototype,n),i&&z(t,i),e}(),Y=250;function G(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function W(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var q=function(){function e(t){var n=this,i=t.bypass,r=t.scrollableContainer,o=t.updateLayout,s=t.initialScrollPosition,a=t.onScrollPositionChange,l=t.isImmediateLayoutScheduled,u=t.hasNonRenderedItemsAtTheTop,h=t.hasNonRenderedItemsAtTheBottom,c=t.getLatestLayoutVisibleAreaIncludingMargins,d=t.preserveScrollPositionOfTheBottomOfTheListOnMount;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),W(this,"updateScrollPosition",function(){n.onScrollPositionChange(n.getScrollY())}),W(this,"onScroll",function(){n.cancelOnUserStopsScrollingTimer();var e=n.getLatestLayoutVisibleAreaIncludingMargins()&&(n.getScrollY()<n.getLatestLayoutVisibleAreaIncludingMargins().top&&n.hasNonRenderedItemsAtTheTop()||n.getScrollY()+n.scrollableContainer.getHeight()>n.getLatestLayoutVisibleAreaIncludingMargins().bottom&&n.hasNonRenderedItemsAtTheBottom());if(R(e?"The user has scrolled far enough: force re-layout":"The user hasn't scrolled too much: delay re-layout"),e)n.updateLayout({reason:N.SCROLL});else{if(n.isImmediateLayoutScheduled())return;n.onUserStopsScrollingTimer=f(function(){n.onUserStopsScrollingTimer=void 0,n.updateLayout({reason:N.STOPPED_SCROLLING})},Z)}}),this.bypass=i,this.scrollableContainer=r,this.updateLayout=o,this.initialScrollPosition=s,this.onScrollPositionChange=a,this.isImmediateLayoutScheduled=l,this.hasNonRenderedItemsAtTheTop=u,this.hasNonRenderedItemsAtTheBottom=h,this.getLatestLayoutVisibleAreaIncludingMargins=c,d&&r&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:r.getContentHeight()})}var t,n,i;return t=e,(n=[{key:"listen",value:function(){void 0!==this.initialScrollPosition&&this.scrollToY(this.initialScrollPosition),this.onScrollPositionChange&&(this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition)),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&this.scrollToY(this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight))}},{key:"stop",value:function(){this.removeScrollPositionListener&&this.removeScrollPositionListener(),this.removeScrollListener&&this.removeScrollListener(),this.cancelOnUserStopsScrollingTimer()}},{key:"scrollToY",value:function(e){this.scrollableContainer.scrollToY(e)}},{key:"scrollByY",value:function(e){this.scrollToY(this.getScrollY()+e)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"cancelOnUserStopsScrollingTimer",value:function(){this.onUserStopsScrollingTimer&&(g(this.onUserStopsScrollingTimer),this.onUserStopsScrollingTimer=void 0)}},{key:"onLayout",value:function(){this.cancelOnUserStopsScrollingTimer()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}}])&&G(t.prototype,n),i&&G(t,i),e}(),Z=100;function J(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var K=function(){function e(t){var n=t.screen,i=t.getContainerElement,r=t.scrollBy;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=n,this.getContainerElement=i,this.scrollBy=r}var t,n,i;return t=e,(n=[{key:"captureScroll",value:function(e){var t=e.previousItems,n=e.newItems,i=e.prependedItemsCount;if(0!==t.length&&0!==i){var r=this.getContainerElement(),o=this.screen.getChildElementTopOffset(r,0);this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===t&&this.restoreScrollAfterRenderValues.newItems===n||(this.restoreScrollAfterRenderValues={previousItems:t,newItems:n,index:i,visibleAreaTop:o})}}},{key:"getAnchorItemIndex",value:function(){return this.restoreScrollAfterRenderValues.index}},{key:"shouldRestoreScrollAfterRender",value:function(){return void 0!==this.restoreScrollAfterRenderValues}},{key:"getScrollDifference",value:function(){var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;return this.restoreScrollAfterRenderValues=void 0,this.screen.getChildElementTopOffset(this.getContainerElement(),t)-n}}])&&J(t.prototype,n),i&&J(t,i),e}();function Q(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var X=function(){function e(t,n,i,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=t,this.getContainerElement=n,this._get=i,this._set=r,this.reset()}var t,n,i;return t=e,(n=[{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initialize",value:function(e){for(var t=0;t<e.length;){if(void 0===e[t]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=t-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=t),this.measuredItemsHeight+=e[t];t++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<this.screen.getChildElementsCount(n))return this.screen.getChildElementHeight(n,i)}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){if(void 0!==e){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(R("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),R("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);R("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&R("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&Q(t.prototype,n),i&&Q(t,i),e}();function $(e){return($="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var ee=Object.prototype.hasOwnProperty;function te(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function ne(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){re(e,t,n[t])})}return e}function ie(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function re(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var oe=function(){function e(t,n){var i=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),re(this,"getListTopOffsetInsideScrollableContainer",function(){var e=i.scrollableContainer.getTopOffset(i.getContainerElement());return i.waitForStylesToLoad.onGotListTopOffset(e),e}),re(this,"willUpdateState",function(e,t){}),re(this,"didUpdateState",function(e){var t=i.getState();if(i.onStateChange&&(function(e,t){if(te(e,t))return!0;if("object"!==$(e)||null===e||"object"!==$(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!ee.call(t,n[r])||!te(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||i.onStateChange(t,e)),e&&i.isRendered){R("~ Rendered ~"),i.newItemsPending=void 0,i.layoutResetPending=void 0;var n=i.redoLayoutReason;i.redoLayoutReason=void 0;var r=e.items,o=t.items;if(o!==r){var s=!0,a=i.getItemsDiff(r,o);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;if(l>0&&(i.itemHeights.onPrepend(l),i.restoreScroll.shouldRestoreScrollAfterRender())){s=!1,R("~ Restore Scroll Position ~");var u=i.restoreScroll.getScrollDifference();u?(R("Scroll down by",u),i.scroll.scrollByY(u)):R("Scroll position hasn't changed")}}else i.itemHeights.reset(),i.itemHeights.initialize(i.getState().itemHeights);s&&(n=N.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||i.onRenderedNewLayout(),n?i.redoLayoutRightAfterRender({reason:n}):void 0}}),re(this,"updateShownItemIndexes",function(){R("~ Layout results "+(i.bypass?"(bypass) ":"")+"~");var e=i.getVisibleAreaBoundsIncludingMargins();i.latestLayoutVisibleAreaIncludingMargins=e;var t=i.getListTopOffsetInsideScrollableContainer(),n=i.layout.getShownItemIndexes({listHeight:i.screen.getElementHeight(i.getContainerElement()),itemsCount:i.getItemsCount(),visibleAreaIncludingMargins:e,listTopOffsetInsideScrollableContainer:t}),r=n.firstShownItemIndex,o=n.lastShownItemIndex,s=n.redoLayoutAfterMeasuringItemHeights;i.restoreScroll.shouldRestoreScrollAfterRender()&&(o<i.restoreScroll.getAnchorItemIndex()&&(o=i.restoreScroll.getAnchorItemIndex()),s=!1);var a=i.layout.getBeforeItemsHeight(r,o),l=i.layout.getAfterItemsHeight(r,o,i.getItemsCount());i._getColumnsCount&&R("Columns count",i.getColumnsCount()),R("First shown item index",r),R("Last shown item index",o),R("Before items height",a),R("After items height (actual or estimated)",l),R("Average item height (calculated on previous render)",i.itemHeights.getAverage()),P()&&(R("Item heights",i.getState().itemHeights.slice()),R("Item states",i.getState().itemStates.slice())),s&&(i.redoLayoutReason=N.ITEM_HEIGHT_NOT_MEASURED),i.validateWillBeHiddenItemHeights(r,o),i.onBeforeShowItems(i.getState().items,i.getState().itemHeights,r,o),i.setState({firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:a,afterItemsHeight:l})}),re(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;0!==i.getItemsCount()&&(i.scroll.onLayout(),i.layoutTimer&&(g(i.layoutTimer),i.layoutTimer=void 0),R("~ Calculate Layout (on ".concat(t,") ~")),i.updateShownItemIndexes())}),re(this,"updateLayout",function(){return i.onUpdateShownItemIndexes({reason:N.MANUAL})}),re(this,"layout",function(){return i.updateLayout()});var o=r.getState,s=r.setState,a=r.onStateChange,l=r.customState,u=r.preserveScrollPositionAtBottomOnMount,h=r.preserveScrollPositionOfTheBottomOfTheListOnMount,c=r.initialScrollPosition,d=r.onScrollPositionChange,m=r.measureItemsBatchSize,f=r.getScrollableContainer,I=r.getColumnsCount,v=r.getItemId,y=r.tbody,S=r._useTimeoutInRenderLoop,b=r.bypass,w=r.estimatedItemHeight,C=r.onItemInitialRender,T=r.onItemFirstRender,H=r.scrollableContainer,x=r.state,O=r.renderingEngine;if(R("~ Initialize ~"),x&&(n=x.items),!H&&f&&(H=f()),O||(O=E),this.screen=O.createScreen(),this.scrollableContainer=O.createScrollableContainer(H),y){if("DOM"!==O.name)throw new Error("`tbody` option is only supported for DOM rendering engine");R("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(R("~ <tbody/> not supported ~"),M(p),b=!0)}b&&R('~ "bypass" mode ~'),this.bypass=b,this._useTimeoutInRenderLoop=S,this.isItemEqual=v?function(e,t){return v(e)===v(t)}:function(e,t){return e===t},this.initialItems=n,this.onStateChange=a,this._getColumnsCount=I,C?this.onItemInitialRender=C:T&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=i.getState().items.indexOf(e);t>=0&&T(t)}),R("Items count",n.length),w&&R("Estimated item height",w),s?(this.getState=o,this.setState=function(e){R("Set state",e),s(e,{willUpdateState:i.willUpdateState,didUpdateState:i.didUpdateState})}):(this.getState=function(){return i.state},this.setState=function(e){R("Set state",e);var t=i.getState(),n=ne({},t,e);i.willUpdateState(n,t),i.state=n,i.didUpdateState(t)}),x&&R("Initial state (passed)",x),this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new X(this.screen,this.getContainerElement,function(e){return i.getState().itemHeights[e]},function(e,t){return i.getState().itemHeights[e]=t}),this.layout=new B({bypass:b,estimatedItemHeight:w,measureItemsBatchSize:void 0===m?50:m,getVerticalSpacing:function(){return i.getVerticalSpacing()},getColumnsCount:function(){return i.getColumnsCount()},getItemHeight:function(e){return i.getState().itemHeights[e]},getAverageItemHeight:function(){return i.itemHeights.getAverage()}}),this.resize=new F({bypass:b,scrollableContainer:this.scrollableContainer,getContainerElement:this.getContainerElement,updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},resetStateAndLayout:function(){R("~ Scrollable container size changed, re-measure item heights. ~"),i.redoLayoutReason=N.RESIZE,i.layoutResetPending=!0,R("Reset state"),i.setState(i.getInitialLayoutState(i.newItemsPending||i.getState().items))}}),u&&console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),this.preserveScrollPositionOfTheBottomOfTheListOnMount=h||u,this.scroll=new q({bypass:this.bypass,scrollableContainer:this.scrollableContainer,updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},initialScrollPosition:c,onScrollPositionChange:d,isImmediateLayoutScheduled:function(){return i.layoutTimer},hasNonRenderedItemsAtTheTop:function(){return i.getState().firstShownItemIndex>0},hasNonRenderedItemsAtTheBottom:function(){return i.getState().lastShownItemIndex<i.getItemsCount()-1},getLatestLayoutVisibleAreaIncludingMargins:function(){return i.latestLayoutVisibleAreaIncludingMargins},preserveScrollPositionOfTheBottomOfTheListOnMount:this.preserveScrollPositionOfTheBottomOfTheListOnMount}),this.restoreScroll=new K({screen:this.screen,getContainerElement:this.getContainerElement}),this.waitForStylesToLoad=new _({updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},getListTopOffsetInsideScrollableContainer:this.getListTopOffsetInsideScrollableContainer}),this.setState(x||this.getInitialState(l))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems,n=ne({},e,this.getInitialLayoutState(t),{items:t,itemStates:new Array(t.length)});return R("Initial state (autogenerated)",n),R("First shown item index",n.firstShownItemIndex),R("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutValues",value:function(e){var t=e.itemsCount,n=e.bypass;return this.layout.getInitialLayoutValues({bypass:n,itemsCount:t,visibleAreaHeightIncludingMargins:this.scrollableContainer&&2*this.getMargin()+this.scrollableContainer.getHeight()})}},{key:"getInitialLayoutState",value:function(e){var t=e.length,n=this.getInitialLayoutValues({itemsCount:t,bypass:this.preserveScrollPositionOfTheBottomOfTheListOnMount}),i=n.firstShownItemIndex,r=n.lastShownItemIndex,o=n.beforeItemsHeight,s=n.afterItemsHeight,a=new Array(t);return this.onBeforeShowItems(e,a,i,r),{itemHeights:a,columnsCount:this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0,verticalSpacing:void 0,firstShownItemIndex:i,lastShownItemIndex:r,beforeItemsHeight:o,afterItemsHeight:s}}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");R("~ Rendered (initial) ~"),this.isRendered=!0,this.onRenderedNewLayout(),this.resize.listen(),this.scroll.listen(),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount||this.onUpdateShownItemIndexes({reason:N.MOUNT})}},{key:"onRenderedNewLayout",value:function(){var e,t,n;this.measureVerticalSpacing(),this.itemHeights.measureNonPreviouslyMeasuredItemHeights(this.getState().firstShownItemIndex,this.getState().lastShownItemIndex),this.tbody&&(e=this.getContainerElement(),t=this.getState().beforeItemsHeight,n=this.getState().afterItemsHeight,e.style.setProperty("--VirtualScroller-paddingTop",I(t)),e.style.setProperty("--VirtualScroller-paddingBottom",I(n)))}},{key:"getVisibleAreaBoundsIncludingMargins",value:function(){var e=this.scroll.getVisibleAreaBounds();return e.top-=this.getMargin(),e.bottom+=this.getMargin(),e}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.resize.stop(),this.scroll.stop(),this.waitForStylesToLoad.stop(),this.layoutTimer&&(g(this.layoutTimer),this.layoutTimer=void 0)}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&g(this.layoutTimer),this.layoutTimer=f(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){R("~ Measure item vertical spacing ~");var e=function(e){var t=e.container,n=e.screen;if(n.getChildElementsCount(t)>1)for(var i=n.getChildElementTopOffset(t,0),r=n.getChildElementHeight(t,0),o=1;o<n.getChildElementsCount(t);){var s=n.getChildElementTopOffset(t,o),a=n.getChildElementHeight(t,o);if(s!==i)return s-(i+r);r=Math.max(r,a),o++}}({container:this.getContainerElement(),screen:this.screen});void 0===e?R("Not enough items rendered to measure vertical spacing"):(R("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){P()&&(R("~ Item state changed ~"),R("Item",e),R("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),R("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){R("~ Re-measure item height ~"),R("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return M('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return R("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");R("Previous height",t),R("New height",n),t!==n&&(R("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:N.ITEM_HEIGHT_CHANGED}))}},{key:"validateWillBeHiddenItemHeights",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&R("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getState().items,r=this.getState(),o=r.itemStates,s=r.itemHeights;R("~ Update items ~");var a=this.getItemsDiff(i,e);if(a&&!this.layoutResetPending){var l=this.getState();t={firstShownItemIndex:l.firstShownItemIndex,lastShownItemIndex:l.lastShownItemIndex,beforeItemsHeight:l.beforeItemsHeight,afterItemsHeight:l.afterItemsHeight};var u=a.prependedItemsCount,h=a.appendedItemsCount;u>0&&(R("Prepend",u,"items"),s=new Array(u).concat(s),o&&(o=new Array(u).concat(o))),h>0&&(R("Append",h,"items"),s=s.concat(new Array(h)),o&&(o=o.concat(new Array(h)))),this.layout.updateLayoutForItemsDiff(t,a,{itemsCount:e.length}),u>0&&(n.preserveScrollPositionOnPrependItems||n.preserveScrollPosition)&&0===this.getState().firstShownItemIndex&&(this.restoreScroll.captureScroll({previousItems:i,newItems:e,prependedItemsCount:u}),this.layout.showItemsFromTheStart(t))}else R("Items have changed, and",a?"a re-layout from scratch has been requested.":"it's not a simple append and/or prepend.","Rerender the entire list from scratch."),R("Previous items",i),R("New items",e),s=new Array(e.length),o=new Array(e.length),t=this.getInitialLayoutValues({itemsCount:e.length});R("~ Update state ~"),R("First shown item index",t.firstShownItemIndex),R("Last shown item index",t.lastShownItemIndex),R("Before items height",t.beforeItemsHeight),R("After items height (actual or estimated)",t.afterItemsHeight),this.onBeforeShowItems(e,s,t.firstShownItemIndex,t.lastShownItemIndex),this.newItemsPending=e,this.setState(ne({},t,{items:e,itemStates:o,itemHeights:s}))}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){for(var r=0;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}}])&&ie(t.prototype,n),i&&ie(t,i),e}();function se(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function ae(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function le(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return function(){function e(t,n,i){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),le(this,"onStateChange",function(e,t){var n=e.items,i=e.firstShownItemIndex,o=e.lastShownItemIndex,s=e.beforeItemsHeight,a=e.afterItemsHeight;R("~ On state change ~"),R("Previous state",t),R("New state",e),r.tbody||(r.container.style.paddingTop=I(s),r.container.style.paddingBottom=I(a));var l=t&&n===t.items&&n.length>0;if(l){R("Incremental rerender");for(var u=t.lastShownItemIndex;u>=t.firstShownItemIndex;)u>=i&&u<=o||(R("Remove item index",u),r.unmountItem(r.container.childNodes[u-t.firstShownItemIndex])),u--}else for(R("Rerender from scratch");r.container.firstChild;)r.unmountItem(r.container.firstChild);for(var h=l,c=h&&r.container.firstChild,d=i;d<=o;){if(l&&d>=t.firstShownItemIndex&&d<=t.lastShownItemIndex)h&&(h=!1);else{var m=r.renderItem(n[d]);h?(R("Prepend item index",d),r.container.insertBefore(m,c)):(R("Append item index",d),r.container.appendChild(m))}d++}}),le(this,"onUnmount",function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),le(this,"destroy",function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),le(this,"stop",function(){r.virtualScroller.stop()}),this.container=t,this.renderItem=i;var s=o.onMount,a=o.onItemUnmount,l=se(o,["onMount","onItemUnmount"]);this.onItemUnmount=a,this.tbody="TBODY"===this.container.tagName,this.virtualScroller=new oe(function(){return r.container},n,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){le(e,t,n[t])})}return e}({},l,{tbody:this.tbody,onStateChange:this.onStateChange})),s&&s(),this.virtualScroller.listen()}var t,n,i;return t=e,(n=[{key:"unmountItem",value:function(e){this.container.removeChild(e),this.onItemUnmount&&this.onItemUnmount(e)}},{key:"onItemHeightChange",value:function(e){this.virtualScroller.onItemHeightChange(e)}},{key:"updateItems",value:function(e,t){this.setItems(e,t)}},{key:"setItems",value:function(e,t){this.virtualScroller.setItems(e,t)}}])&&ae(t.prototype,n),i&&ae(t,i),e}()});
//# sourceMappingURL=virtual-scroller-dom.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):(e=e||self).VirtualScroller=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var i,r=(function(e){(function(){var t,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-o)/1e6},n=process.hrtime,r=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(e.exports=function(){return Date.now()-i},i=Date.now()):(e.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(n)}(i={exports:{}},i.exports),i.exports),o="undefined"==typeof window?n:window,s=["moz","webkit"],a="AnimationFrame",l=o["request"+a],u=o["cancel"+a]||o["cancelRequest"+a],h=0;!l&&h<s.length;h++)l=o[s[h]+"Request"+a],u=o[s[h]+"Cancel"+a]||o[s[h]+"CancelRequest"+a];if(!l||!u){var c=0,m=0,d=[];l=function(e){if(0===d.length){var t=r(),n=Math.max(0,1e3/60-(t-c));c=n+t,setTimeout(function(){var e=d.slice(0);d.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(c)}catch(e){setTimeout(function(){throw e},0)}},Math.round(n))}return d.push({handle:++m,callback:e,cancelled:!1}),m},u=function(e){for(var t=0;t<d.length;t++)d[t].handle===e&&(d[t].cancelled=!0)}}var f=function(e){return l.call(o,e)};f.cancel=function(){u.apply(o,arguments)},f.polyfill=function(e){e||(e=o),e.requestAnimationFrame=l,e.cancelAnimationFrame=u};var g=f.cancel;function p(e,t){var n=Date.now(),i=f(function r(){Date.now()-n>=t?e():i=f(r)});return{clear:function(){return g(i)}}}function I(e){e&&e.clear()}function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function S(e,t){return!t||"object"!==v(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function O(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),e}var x=function(){function e(t){C(this,e),this.element=t}return O(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e,t){var n,i=this,r=t.container;if("undefined"!=typeof ResizeObserver){var o=new ResizeObserver(function(t){t[0];e()});o.observe(this.element),n=function(){return o.unobserve(i.element)}}var s=(new H).onResize(e,{container:r});return function(){n&&n(),s()}}}]),e}(),H=function(e){function t(){return C(this,t),S(this,y(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(t,x),O(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e,t){var n=t.container,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}}]),t}();function R(e){return e.toFixed(2)+"px"}var T="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function k(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var E=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"getChildElementTopCoordinate",value:function(e,t){return e.childNodes[t].getBoundingClientRect().top}},{key:"getChildElementHeight",value:function(e,t){return this.getElementHeight(e.childNodes[t])}},{key:"getChildElementsCount",value:function(e){return e.childNodes.length}},{key:"clearElement",value:function(e){!function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(e)}},{key:"getElementHeight",value:function(e){return e.getBoundingClientRect().height}}])&&k(t.prototype,n),i&&k(t,i),e}();function M(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function P(){if(L()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,M(["[virtual-scroller]"].concat(n)))}}function A(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(P.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,M(["[virtual-scroller]"].concat(t)))}function L(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function _(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var V=function(){function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=t,this.getContainerElement=n,this.getState=i,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<this.screen.getChildElementsCount(n))return this.screen.getChildElementHeight(n,i)}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(P("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),P("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);P("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&P("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&_(t.prototype,n),i&&_(t,i),e}();function B(e){return(B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var U=Object.prototype.hasOwnProperty;function j(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){D(e,t,n[t])})}return e}function z(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=250,q=100,W=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),D(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:Y.MANUAL})}),D(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:Y.SCROLL})}),D(this,"restoreScrollPositionFromState",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),D(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),D(this,"layout",function(){return s.updateLayout()}),D(this,"onResize",(i=function(){if(s.isRendered){var e=s.scrollableContainerWidth,t=s.scrollableContainerHeight;if(s.scrollableContainerWidth=s.scrollableContainer.getWidth(),s.scrollableContainerHeight=s.scrollableContainer.getHeight(),s.scrollableContainerWidth===e){if(s.scrollableContainerHeight===t)return;s.onUpdateShownItemIndexes({reason:Y.RESIZE})}else{P("~ Scrollable container size changed, re-measure item heights. ~"),s.redoLayoutReason=Y.RESIZE;var n=s.getInitialLayoutState();P("Reset state to",n),s.setState(n)}}},r=F,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),D(this,"willUpdateState",function(e,t){}),D(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(j(e,t))return!0;if("object"!==B(e)||null===e||"object"!==B(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!U.call(t,n[r])||!j(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){P("~ Rendered ~");var n=s.redoLayoutReason;s.redoLayoutReason=void 0;var i=e.items,r=t.items;if(r!==i){var o=!0,a=s.getItemsDiff(i,r);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;l>0&&(s.itemHeights.onPrepend(l),s.restoreScrollAfterRenderValues&&(o=!1,s.restoreScrollAfterRender()))}else s.itemHeights.initialize();o&&(n=Y.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered(),n?s.redoLayoutRightAfterRender({reason:n}):void 0}}),D(this,"updateShownItemIndexes",function(){P("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterMeasuringItemHeights,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&P("Columns count",s.getColumnsCount()),P("First shown item index",t),P("Last shown item index",n),P("Before items height",o),P("After items height (actual or estimated)",a),P("Average item height (calculated on previous render)",s.itemHeights.getAverage()),L()&&(P("Item heights",s.getState().itemHeights.slice()),P("Item states",s.getState().itemStates.slice())),i&&(s.redoLayoutReason=Y.ITEM_HEIGHT_NOT_MEASURED),s.validateWillBeHiddenItemHeightsAndState(t,n),s.onBeforeShowItems(s.getState().items,s.getState().itemHeights,t,n),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),D(this,"updateShownItemIndexesRecursive",function(){s.layoutInProgress=!0,s.updateShownItemIndexes()}),D(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()){if(s.onUserStopsScrollingTimer&&(I(s.onUserStopsScrollingTimer),s.onUserStopsScrollingTimer=void 0),t===Y.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(P(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n){if(s.layoutTimer)return;return void(s.onUserStopsScrollingTimer=p(function(){s.isRendered&&s.onUpdateShownItemIndexes({reason:Y.STOPPED_SCROLLING})},q))}}s.layoutTimer&&(I(s.layoutTimer),s.layoutTimer=void 0),P("~ Calculate Layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}});var l=a.getState,u=a.setState,h=a.onStateChange,c=a.customState,m=a.preserveScrollPositionAtBottomOnMount,d=a.measureItemsBatchSize,f=a.getScrollableContainer,g=a.getColumnsCount,v=a.getItemId,S=a.tbody,y=a._useTimeoutInRenderLoop,b=a.bypass,C=a.estimatedItemHeight,w=a.onItemInitialRender,O=a.onItemFirstRender,R=a.scrollableContainer,k=a.preserveScrollPositionOfTheBottomOfTheListOnMount,M=a.state;if(this.renderer="DOM",P("~ Initialize ~"),M&&(n=M.items),!R&&f&&(R=f()),"DOM"!==this.renderer)throw new Error('Unknown renderer: "'.concat(this.renderer,'"'));if(R?this.scrollableContainer=new x(R):"undefined"!=typeof window&&(this.scrollableContainer=new H),S){if("DOM"!==this.renderer)throw new Error("`tbody` option is only supported for DOM renderer");P("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(P("~ <tbody/> not supported ~"),A(T),b=!0)}if(b&&P('~ "bypass" mode ~'),this.bypass=b,this._useTimeoutInRenderLoop=y,this.isItemEqual=v?function(e,t){return v(e)===v(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=C,this.onStateChange=h,this.measureItemsBatchSize=void 0===d?50:d,this._getColumnsCount=g,w?this.onItemInitialRender=w:O&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&O(t)}),P("Items count",n.length),C&&P("Estimated item height",C),u?(this.getState=l,this.setState=function(e){P("Set state",e),u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){P("Set state",e);var t=s.getState(),n=N({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),M&&P("Initial state (passed)",M),"DOM"!==this.renderer)throw new Error('Unknown renderer: "'.concat(this.renderer,'"'));this.screen=new E,this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new V(this.screen,this.getContainerElement,this.getState),this.scrollableContainer&&(m&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),k=m),k&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(M||this.getInitialState(c))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=N({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return P("Initial state (autogenerated)",n),P("First shown item index",n.firstShownItemIndex),P("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1);var o=new Array(i);return this.onBeforeShowItems(n,o,e,t),{itemHeights:o,columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");P("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPositionFromState(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize,{container:this.getContainerElement()})),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:Y.MOUNT})}},{key:"onRendered",value:function(){this.measureVerticalSpacing(),this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.screen.getElementHeight(this.getContainerElement())}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),I(this.onUserStopsScrollingTimer),I(this.watchContainerElementCoordinatesTimer),I(this.layoutTimer))}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&I(this.layoutTimer),this.layoutTimer=p(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",R(t)),e.style.setProperty("--VirtualScroller-paddingBottom",R(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){P("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacingValue();void 0===e?P("Not enough items rendered to measure vertical spacing"):(P("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"measureVerticalSpacingValue",value:function(){var e=this.getContainerElement();if(this.screen.getChildElementsCount(e)>1)for(var t=this.screen.getChildElementTopCoordinate(e,0),n=this.screen.getChildElementHeight(e,0),i=1;i<this.screen.getChildElementsCount(e);){var r=this.screen.getChildElementTopCoordinate(e,i),o=this.screen.getChildElementHeight(e,i);if(r!==t)return r-(t+n);n=Math.max(n,o),i++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t)this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n)}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){L()&&(P("~ Item state changed ~"),P("Item",e),P("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),P("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){P("~ Re-measure item height ~"),P("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return A('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return P("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");P("Previous height",t),P("New height",n),t!==n&&(P("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:Y.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,c=0,m=0,d=void 0;m<a&&(d=u*a+m)<s;){var f=this.getState().itemHeights[d];if(void 0===f){P("Item index ".concat(d,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:d,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(c=Math.max(c,f),void 0===i&&n+o+c>e&&(P("First shown row index",u),i=u*a),n+o+c+h>t)return P("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};m++}o+=c,o+=h,u++}return void 0!==i&&void 0===r&&P("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterRenderValues&&(s<this.restoreScrollAfterRenderValues.index&&(s=this.restoreScrollAfterRenderValues.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterMeasuringItemHeights:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;P("The entire list is off-screen. No items are visible.")}else P("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&P("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:Y.TOP_OFFSET_CHANGED}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=p(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"captureScroll",value:function(e,t,n){if(0!==e.length&&0!==n){var i=this.getState().firstShownItemIndex,r=this.getContainerElement(),o=this.screen.getChildElementTopCoordinate(r,0);if(i>0)for(var s=this.getState().itemHeights,a=i-1;a>=0;)o+=s[a]+this.getVerticalSpacing(),a--;this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===e&&this.restoreScrollAfterRenderValues.nextItems===t||(this.restoreScrollAfterRenderValues={previousItems:e,nextItems:t,index:n,visibleAreaTop:o})}}},{key:"restoreScrollAfterRender",value:function(){P("~ Restore Scroll Position ~");var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;this.restoreScrollAfterRenderValues=void 0;var i=this.screen.getChildElementTopCoordinate(this.getContainerElement(),t)-n;0===i?P("Scroll position hasn't changed"):(P("Scroll down by",i),this.scrollTo(0,this.getScrollY()+i))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights;P("~ Update items ~");var h=this.getItemsDiff(n,e);if(h){var c=h.prependedItemsCount,m=h.appendedItemsCount;c>0&&(P("Prepend",c,"items"),u=new Array(c).concat(u),l&&(l=new Array(c).concat(l))),m>0&&(P("Append",m,"items"),u=u.concat(new Array(m)),l&&(l=l.concat(new Array(m)))),r+=c,o+=c;this.getVerticalSpacing();var d=this.getColumnsCount();if(c%d==0){var f=c/d,g=Math.ceil(m/d);s+=f*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=g*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u);c>0&&(t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition)&&(r=0,s=0,this.captureScroll(n,e,c))}else P("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),P("Previous items",n),P("New items",e),u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;P("~ Update state ~"),P("First shown item index",r),P("Last shown item index",o),P("Before items height",s),P("After items height (actual or estimated)",a),this.onBeforeShowItems(e,u,r,o),this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){for(var r=0;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}}])&&z(t.prototype,n),i&&z(t,i),e}(),Y={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"top offset changed"};function G(){return(G=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function K(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function J(e){return(J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Z(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $(e,t){return($=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ee(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var te=t.elementType||t.oneOfType([t.string,t.func,t.object]),ne=function(t){function n(t){var i,r,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=this,o=Q(n).call(this,t),i=!o||"object"!==J(o)&&"function"!=typeof o?X(r):o,ee(X(i),"container",e.createRef()),ee(X(i),"onItemStateChange",new Array(i.props.items.length)),ee(X(i),"onItemHeightChange",new Array(i.props.items.length)),ee(X(i),"itemRefs",new Array(i.props.items.length)),ee(X(i),"itemKeyPrefixes",[]),ee(X(i),"updateLayout",function(){return i.virtualScroller.updateLayout()}),ee(X(i),"layout",function(){return i.updateLayout()}),ee(X(i),"onItemInitialRender",function(){var e=i.props.onItemInitialRender;e&&e.apply(void 0,arguments)}),ee(X(i),"onItemFirstRender",function(){var e=i.props.onItemFirstRender;e&&e.apply(void 0,arguments)}),i.previousItemsProperty=t.items,i.generateItemKeyPrefix(),i.createVirtualScroller(),i}var i,r,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&$(e,t)}(n,e.Component),i=n,(r=[{key:"createVirtualScroller",value:function(){var e=this,t=this.props,n=t.as,i=t.items,r=t.initialState,o=t.initialCustomState,s=t.onStateChange,a=t.estimatedItemHeight,l=t.preserveScrollPositionOfTheBottomOfTheListOnMount,u=t.preserveScrollPositionAtBottomOnMount,h=t.measureItemsBatchSize,c=t.scrollableContainer,m=t.getScrollableContainer,d=t.getColumnsCount,f=t.getItemId,g=t.bypass;this.virtualScroller=new W(function(){return e.container.current},i,{_useTimeoutInRenderLoop:!0,estimatedItemHeight:a,bypass:g,onItemInitialRender:this.onItemInitialRender,onItemFirstRender:this.onItemFirstRender,preserveScrollPositionOfTheBottomOfTheListOnMount:l,preserveScrollPositionAtBottomOnMount:u,shouldUpdateLayoutOnScreenResize:this.shouldUpdateLayoutOnScreenResize,measureItemsBatchSize:h,scrollableContainer:c,getScrollableContainer:m,getColumnsCount:d,getItemId:f,tbody:"tbody"===n,state:r,customState:o,onStateChange:s,getState:function(){return e.state},setState:function(t,n){var i=n.willUpdateState,r=n.didUpdateState;e.willUpdateState=i,e.didUpdateState=r,e.state?e.setState(t):(i(t),e.state=t,r())}})}},{key:"shouldUseRefs",value:function(){var e,t=this.props.itemComponent;return(e=t).prototype&&e.prototype.isReactComponent}},{key:"getItemKey",value:function(e,t){var n=this.props.getItemId;return n?n(e):"".concat(this.itemKeyPrefix,":").concat(t)}},{key:"getItemCoordinates",value:function(e){return this.virtualScroller.getItemCoordinates(e)}},{key:"updateItem",value:function(e){return this.renderItem(e)}},{key:"renderItem",value:function(e){var t=this;if(void 0===(e=this.getItemIndex(e)))return A("Item ".concat(JSON.stringify(e),' not found when calling ".renderItem()"'));if(!this.shouldUseRefs())return A("`.renderItem(i)` has been called but the `component` doesn't allow `ref`s. Only `component`s that're `React.Component`s support this feature.");if(this.itemRefs[e]&&this.itemRefs[e].current){var n=this.props.items,i=n[e];this.itemRefs[e].current.forceUpdate(function(){if(t._isMounted){var e=n.indexOf(i);e>=0&&t.virtualScroller.onItemHeightChange(e)}})}}},{key:"getItemIndex",value:function(e){if("number"==typeof e)return e;if("object"===J(e)&&null!==e){var t=this.props,n=t.items,i=t.getItemId,r=e;for(e=0;e<n.length;){if(i){if(i(r)===i(n[e]))return e}else if(r===n[e])return e;e++}}}},{key:"getItemRef",value:function(t){return this.itemRefs[t]||(this.itemRefs[t]=e.createRef()),this.itemRefs[t]}},{key:"getOnItemStateChange",value:function(e){var t=this;return this.onItemStateChange[e]||(this.onItemStateChange[e]=function(n){return t.virtualScroller.onItemStateChange(e,n)}),this.onItemStateChange[e]}},{key:"getOnItemHeightChange",value:function(e){var t=this;return this.onItemHeightChange[e]||(this.onItemHeightChange[e]=function(){return t.virtualScroller.onItemHeightChange(e)}),this.onItemHeightChange[e]}},{key:"generateItemKeyPrefix",value:function(){var e=String(Math.random()).slice(2);if(this.itemKeyPrefixes.indexOf(e)>=0)return this.generateItemKeyPrefix();this.itemKeyPrefixes.push(e),this.itemKeyPrefix=e}},{key:"componentDidMount",value:function(){var e=this.props.onMount;e&&e(),this._isMounted=!0,this.virtualScroller.listen()}},{key:"getSnapshotBeforeUpdate",value:function(e,t){return this.state!==t&&this.willUpdateState(this.state,t),null}},{key:"componentDidUpdate",value:function(e,t){this.state!==t&&this.didUpdateState(t);var n=this.props,i=n.items,r=n.preserveScrollPosition,o=n.preserveScrollPositionOnPrependItems;i!==e.items&&this.virtualScroller.setItems(i,{preserveScrollPositionOnPrependItems:o||r})}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.virtualScroller.stop()}},{key:"render",value:function(){var t=this,n=this.props,i=n.as,r=n.itemComponent,o=n.itemComponentProps,s=(n.items,n.estimatedItemHeight,n.bypass,n.preserveScrollPositionOnPrependItems),a=n.preserveScrollPosition,l=(n.preserveScrollPositionOfTheBottomOfTheListOnMount,n.preserveScrollPositionAtBottomOnMount,n.measureItemsBatchSize,n.scrollableContainer,n.getScrollableContainer,n.getColumnsCount,n.initialState,n.initialCustomState,n.onStateChange,n.onItemInitialRender,n.onItemFirstRender,n.getItemId),u=(n.onMount,n.className),h=K(n,["as","itemComponent","itemComponentProps","items","estimatedItemHeight","bypass","preserveScrollPositionOnPrependItems","preserveScrollPosition","preserveScrollPositionOfTheBottomOfTheListOnMount","preserveScrollPositionAtBottomOnMount","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","initialState","initialCustomState","onStateChange","onItemInitialRender","onItemFirstRender","getItemId","onMount","className"]),c=this.virtualScroller.getState(),m=c.items,d=c.itemStates,f=c.firstShownItemIndex,g=c.lastShownItemIndex,p=c.beforeItemsHeight,I=c.afterItemsHeight,v=this.props.items,S=m;if(this.itemsPropertyWasChanged||(this.itemsPropertyWasChanged=this.props.items!==this.previousItemsProperty),this.previousItemsProperty=this.props.items,this.itemsPropertyWasChanged&&v!==S){var y=this.virtualScroller.getItemsDiff(S,v);y&&0===y.prependedItemsCount&&y.appendedItemsCount>0||(y&&(s||a)&&this.virtualScroller.captureScroll(S,v,y.prependedItemsCount),l||this.generateItemKeyPrefix(),this.itemRefs=new Array(v.length))}var b=this.virtualScroller.tbody;return e.createElement(i,G({},h,{ref:this.container,className:b?u?u+" VirtualScroller":"VirtualScroller":u,style:{paddingTop:b?void 0:R(p),paddingBottom:b?void 0:R(I)}}),m.map(function(n,i){return i>=f&&i<=g?e.createElement(r,G({},o,{ref:t.shouldUseRefs()?t.getItemRef(i):void 0,key:t.getItemKey(n,i),state:d&&d[i],onStateChange:t.getOnItemStateChange(i),onHeightChange:t.getOnItemHeightChange(i)}),n):null}))}}])&&Z(i.prototype,r),o&&Z(i,o),n}();return ee(ne,"propTypes",{as:te,items:t.arrayOf(t.object).isRequired,itemComponent:te.isRequired,itemComponentProps:t.object,estimatedItemHeight:t.number,bypass:t.bool,preserveScrollPositionOnPrependItems:t.bool,preserveScrollPosition:t.bool,preserveScrollPositionOfTheBottomOfTheListOnMount:t.bool,preserveScrollPositionAtBottomOnMount:t.bool,measureItemsBatchSize:t.number,scrollableContainer:t.any,getScrollableContainer:t.func,getColumnsCount:t.func,getItemId:t.func,className:t.string,onMount:t.func,onItemInitialRender:t.func,onItemFirstRender:t.func,onStateChange:t.func,initialCustomState:t.object,initialState:t.shape({items:t.arrayOf(t.object).isRequired,itemStates:t.arrayOf(t.any),firstShownItemIndex:t.number.isRequired,lastShownItemIndex:t.number.isRequired,beforeItemsHeight:t.number.isRequired,afterItemsHeight:t.number.isRequired,itemHeights:t.arrayOf(t.number).isRequired,columnsCount:t.number,verticalSpacing:t.number})}),ee(ne,"defaultProps",{as:"div"}),ne});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):(e=e||self).VirtualScroller=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var i,r=(function(e){(function(){var t,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-o)/1e6},n=process.hrtime,r=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(e.exports=function(){return Date.now()-i},i=Date.now()):(e.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(n)}(i={exports:{}},i.exports),i.exports),o="undefined"==typeof window?n:window,s=["moz","webkit"],a="AnimationFrame",l=o["request"+a],u=o["cancel"+a]||o["cancelRequest"+a],h=0;!l&&h<s.length;h++)l=o[s[h]+"Request"+a],u=o[s[h]+"Cancel"+a]||o[s[h]+"CancelRequest"+a];if(!l||!u){var c=0,m=0,f=[];l=function(e){if(0===f.length){var t=r(),n=Math.max(0,1e3/60-(t-c));c=n+t,setTimeout(function(){var e=f.slice(0);f.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(c)}catch(e){setTimeout(function(){throw e},0)}},Math.round(n))}return f.push({handle:++m,callback:e,cancelled:!1}),m},u=function(e){for(var t=0;t<f.length;t++)f[t].handle===e&&(f[t].cancelled=!0)}}var d=function(e){return l.call(o,e)};d.cancel=function(){u.apply(o,arguments)},d.polyfill=function(e){e||(e=o),e.requestAnimationFrame=l,e.cancelAnimationFrame=u};var g=d.cancel;function p(e,t){var n=Date.now(),i=d(function r(){Date.now()-n>=t?e():i=d(r)});return{clear:function(){return g(i)}}}function I(e){e&&e.clear()}function v(e){return e.toFixed(2)+"px"}var y="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function S(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var b=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"getChildElementTopOffset",value:function(e,t){return e.childNodes[t].getBoundingClientRect().top}},{key:"getChildElementHeight",value:function(e,t){return this.getElementHeight(e.childNodes[t])}},{key:"getChildElementsCount",value:function(e){return e.childNodes.length}},{key:"clearElement",value:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}},{key:"getElementHeight",value:function(e){return e.getBoundingClientRect().height}}])&&S(t.prototype,n),i&&S(t,i),e}();function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function w(e,t){return!t||"object"!==C(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function H(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function x(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function P(e,t,n){return t&&x(e.prototype,t),n&&x(e,n),e}var R=function(){function e(t){H(this,e),this.element=t}return P(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollToY",value:function(e){this.element.scrollTo(0,e)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e,t){var n,i=this,r=t.container;if("undefined"!=typeof ResizeObserver){var o=new ResizeObserver(function(t){t[0];e()});o.observe(this.element),n=function(){return o.unobserve(i.element)}}var s=k(e,{container:r});return function(){n&&n(),s()}}}]),e}(),L=function(e){function t(){return H(this,t),w(this,O(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&T(e,t)}(t,R),P(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e,t){return k(e,{container:t.container})}}]),t}();function k(e,t){var n=t.container,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}var M={name:"DOM",createScreen:function(){return new b},createScrollableContainer:function(e){return e?new R(e):"undefined"!=typeof window?new L:void 0}};function E(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function A(){if(V()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,E(["[virtual-scroller]"].concat(n)))}}function B(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(A.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,E(["[virtual-scroller]"].concat(t)))}function V(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function _(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var U=function(){function e(t){var n=t.bypass,i=t.estimatedItemHeight,r=t.measureItemsBatchSize,o=t.getVerticalSpacing,s=t.getColumnsCount,a=t.getItemHeight,l=t.getAverageItemHeight;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.bypass=n,this.estimatedItemHeight=i,this.measureItemsBatchSize=r,this.getVerticalSpacing=o,this.getColumnsCount=s,this.getItemHeight=a,this.getAverageItemHeight=l}var t,n,i;return t=e,(n=[{key:"getInitialLayoutValues",value:function(e){var t,n,i=e.bypass,r=e.itemsCount,o=e.visibleAreaHeightIncludingMargins,s=o?this.getEstimatedRowsCountForHeight(o):1;return r>0&&(t=0,n=this.getLastShownItemIndex(t,r,s,i)),{beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:t,lastShownItemIndex:n}}},{key:"getLastShownItemIndex",value:function(e,t,n,i){return this.bypass||i?t-1:Math.min(e+(n*this.getColumnsCount()-1),t-1)}},{key:"getEstimatedRowsCountForHeight",value:function(e){var t=this.getEstimatedItemHeight();return t?Math.ceil((e+this.getVerticalSpacing())/(t+this.getVerticalSpacing())):1}},{key:"getEstimatedItemHeight",value:function(){return this.getAverageItemHeight()||this.estimatedItemHeight||0}},{key:"updateLayoutForItemsDiff",value:function(e,t,n){var i=t.prependedItemsCount,r=t.appendedItemsCount,o=n.itemsCount;e.firstShownItemIndex+=i,e.lastShownItemIndex+=i;var s=this.getColumnsCount();if(i%s==0){var a=i/s,l=Math.ceil(r/s),u=this.getAverageItemHeight(),h=this.getVerticalSpacing();e.beforeItemsHeight+=a*(u+h),e.afterItemsHeight+=l*(h+u)}else e.beforeItemsHeight=this.getBeforeItemsHeight(firstShownItemIndex,lastShownItemIndex),e.afterItemsHeight=this.getAfterItemsHeight(firstShownItemIndex,lastShownItemIndex,o)}},{key:"_getVisibleItemIndexes",value:function(e,t,n,i){for(var r,o,s=this.getColumnsCount(),a=0,l=Math.ceil(i/s),u=0;u<l;){for(var h=i>(u+1)*s?this.getVerticalSpacing():0,c=0,m=0,f=void 0;m<s&&(f=u*s+m)<i;){var d=this.getItemHeight(f);if(void 0===d){A("Item index ".concat(f,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===r&&(r=u*s);var g=t-(n+a);return{firstNonMeasuredItemIndex:f,firstShownItemIndex:r,lastShownItemIndex:o=Math.min((u+this.getEstimatedRowsCountForHeight(g))*s-1,i-1)}}if(c=Math.max(c,d),void 0===r&&n+a+c>e&&(A("First shown row index",u),r=u*s),n+a+c+h>t)return A("Last shown row index",u),void 0!==r&&(o=Math.min((u+1)*s-1,i-1)),{firstShownItemIndex:r,lastShownItemIndex:o};m++}a+=c,a+=h,u++}return void 0!==r&&void 0===o&&A("Last item index (is fully visible)",o=i-1),{firstShownItemIndex:r,lastShownItemIndex:o}}},{key:"getVisibleItemIndexes",value:function(e,t,n,i){var r=this._getVisibleItemIndexes(e,t,n,i),o=r.firstNonMeasuredItemIndex,s=r.firstShownItemIndex,a=r.lastShownItemIndex,l=void 0!==o;if(l&&this.measureItemsBatchSize){var u=o+this.measureItemsBatchSize-1,h=this.getColumnsCount();a=Math.min(a,Math.ceil(u/h)*h-1)}return{firstShownItemIndex:s,lastShownItemIndex:a,redoLayoutAfterMeasuringItemHeights:l}}},{key:"getNonVisibleListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getItemHeight(0)}}},{key:"getItemIndexes",value:function(e,t,n,i,r){if(n+i>e&&n<t){var o=this.getVisibleItemIndexes(e,t,n,r);if(void 0!==o.firstShownItemIndex)return o;A("The entire list is off-screen. No items are visible.")}else A("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t){for(var n=this.getColumnsCount(),i=Math.floor(e/n),r=0,o=0;o<i;){for(var s=0,a=0;a<n;)s=Math.max(s,this.getItemHeight(o*n+a)||this.getAverageItemHeight()),a++;r+=s,r+=this.getVerticalSpacing(),o++}return r}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.ceil(n/i),o=0,s=Math.floor(t/i)+1;s<r;){for(var a=0,l=0,u=void 0;l<i&&(u=s*i+l)<n;)a=Math.max(a,this.getItemHeight(u)||this.getAverageItemHeight()),l++;o+=this.getVerticalSpacing(),o+=a,s++}return o}},{key:"getShownItemIndexes",value:function(e){var t=e.listHeight,n=e.itemsCount,i=e.visibleAreaIncludingMargins,r=e.listTopOffsetInsideScrollableContainer;return this.bypass?{firstShownItemIndex:0,lastShownItemIndex:n-1}:this.getItemIndexes(i.top,i.bottom,r,t,n)||this.getNonVisibleListShownItemIndexes()}},{key:"showItemsFromTheStart",value:function(e){e.firstShownItemIndex=0,e.beforeItemsHeight=0}}])&&_(t.prototype,n),i&&_(t,i),e}(),j={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"list top offset changed"};function N(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var z=function(){function e(t){var n=t.updateLayout,i=t.getListTopOffsetInsideScrollableContainer;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.updateLayout=n,this.getListTopOffsetInsideScrollableContainer=i}var t,n,i;return t=e,(n=[{key:"onGotListTopOffset",value:function(e){void 0===this.listTopOffsetInsideScrollableContainer&&this.start(),this.listTopOffsetInsideScrollableContainer=e}},{key:"start",value:function(){this.isRendered=!0,this.watchListTopOffset()}},{key:"stop",value:function(){this.isRendered=!1,I(this.watchListTopOffsetTimer)}},{key:"watchListTopOffset",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.listTopOffsetInsideScrollableContainer&&e.getListTopOffsetInsideScrollableContainer()!==e.listTopOffsetInsideScrollableContainer&&e.updateLayout({reason:j.TOP_OFFSET_CHANGED}),Date.now()-t<F&&(e.watchListTopOffsetTimer=p(n,D)))}()}}])&&N(t.prototype,n),i&&N(t,i),e}(),D=500,F=3e3;function Y(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var q=function(){function e(t){var n,i,r,o,s,a,l=this,u=t.bypass,h=t.scrollableContainer,c=t.getContainerElement,m=t.updateLayout,f=t.resetStateAndLayout;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o=function(){if(l.isRendered){var e=l.scrollableContainerWidth,t=l.scrollableContainerHeight;if(l.scrollableContainerWidth=l.scrollableContainer.getWidth(),l.scrollableContainerHeight=l.scrollableContainer.getHeight(),l.scrollableContainerWidth===e){if(l.scrollableContainerHeight===t)return;l.updateLayout({reason:j.RESIZE})}else l.resetStateAndLayout()}},s=W,r=function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];I(a),a=p(function(){return o.apply(e,n)},s)},(i="onResize")in(n=this)?Object.defineProperty(n,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[i]=r,this.bypass=u,this.scrollableContainer=h,this.getContainerElement=c,this.updateLayout=m,this.resetStateAndLayout=f}var t,n,i;return t=e,(n=[{key:"listen",value:function(){this.bypass||(this.isRendered=!0,this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize,{container:this.getContainerElement()}))}},{key:"stop",value:function(){this.isRendered=!1,this.scrollableContainerUnlistenResize&&this.scrollableContainerUnlistenResize()}}])&&Y(t.prototype,n),i&&Y(t,i),e}(),W=250;function G(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function K(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var J=function(){function e(t){var n=this,i=t.bypass,r=t.scrollableContainer,o=t.updateLayout,s=t.initialScrollPosition,a=t.onScrollPositionChange,l=t.isImmediateLayoutScheduled,u=t.hasNonRenderedItemsAtTheTop,h=t.hasNonRenderedItemsAtTheBottom,c=t.getLatestLayoutVisibleAreaIncludingMargins,m=t.preserveScrollPositionOfTheBottomOfTheListOnMount;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),K(this,"updateScrollPosition",function(){n.onScrollPositionChange(n.getScrollY())}),K(this,"onScroll",function(){n.cancelOnUserStopsScrollingTimer();var e=n.getLatestLayoutVisibleAreaIncludingMargins()&&(n.getScrollY()<n.getLatestLayoutVisibleAreaIncludingMargins().top&&n.hasNonRenderedItemsAtTheTop()||n.getScrollY()+n.scrollableContainer.getHeight()>n.getLatestLayoutVisibleAreaIncludingMargins().bottom&&n.hasNonRenderedItemsAtTheBottom());if(A(e?"The user has scrolled far enough: force re-layout":"The user hasn't scrolled too much: delay re-layout"),e)n.updateLayout({reason:j.SCROLL});else{if(n.isImmediateLayoutScheduled())return;n.onUserStopsScrollingTimer=p(function(){n.onUserStopsScrollingTimer=void 0,n.updateLayout({reason:j.STOPPED_SCROLLING})},Z)}}),this.bypass=i,this.scrollableContainer=r,this.updateLayout=o,this.initialScrollPosition=s,this.onScrollPositionChange=a,this.isImmediateLayoutScheduled=l,this.hasNonRenderedItemsAtTheTop=u,this.hasNonRenderedItemsAtTheBottom=h,this.getLatestLayoutVisibleAreaIncludingMargins=c,m&&r&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:r.getContentHeight()})}var t,n,i;return t=e,(n=[{key:"listen",value:function(){void 0!==this.initialScrollPosition&&this.scrollToY(this.initialScrollPosition),this.onScrollPositionChange&&(this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition)),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&this.scrollToY(this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight))}},{key:"stop",value:function(){this.removeScrollPositionListener&&this.removeScrollPositionListener(),this.removeScrollListener&&this.removeScrollListener(),this.cancelOnUserStopsScrollingTimer()}},{key:"scrollToY",value:function(e){this.scrollableContainer.scrollToY(e)}},{key:"scrollByY",value:function(e){this.scrollToY(this.getScrollY()+e)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"cancelOnUserStopsScrollingTimer",value:function(){this.onUserStopsScrollingTimer&&(I(this.onUserStopsScrollingTimer),this.onUserStopsScrollingTimer=void 0)}},{key:"onLayout",value:function(){this.cancelOnUserStopsScrollingTimer()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}}])&&G(t.prototype,n),i&&G(t,i),e}(),Z=100;function Q(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var X=function(){function e(t){var n=t.screen,i=t.getContainerElement,r=t.scrollBy;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=n,this.getContainerElement=i,this.scrollBy=r}var t,n,i;return t=e,(n=[{key:"captureScroll",value:function(e){var t=e.previousItems,n=e.newItems,i=e.prependedItemsCount;if(0!==t.length&&0!==i){var r=this.getContainerElement(),o=this.screen.getChildElementTopOffset(r,0);this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===t&&this.restoreScrollAfterRenderValues.newItems===n||(this.restoreScrollAfterRenderValues={previousItems:t,newItems:n,index:i,visibleAreaTop:o})}}},{key:"getAnchorItemIndex",value:function(){return this.restoreScrollAfterRenderValues.index}},{key:"shouldRestoreScrollAfterRender",value:function(){return void 0!==this.restoreScrollAfterRenderValues}},{key:"getScrollDifference",value:function(){var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;return this.restoreScrollAfterRenderValues=void 0,this.screen.getChildElementTopOffset(this.getContainerElement(),t)-n}}])&&Q(t.prototype,n),i&&Q(t,i),e}();function $(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var ee=function(){function e(t,n,i,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=t,this.getContainerElement=n,this._get=i,this._set=r,this.reset()}var t,n,i;return t=e,(n=[{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initialize",value:function(e){for(var t=0;t<e.length;){if(void 0===e[t]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=t-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=t),this.measuredItemsHeight+=e[t];t++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<this.screen.getChildElementsCount(n))return this.screen.getChildElementHeight(n,i)}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){if(void 0!==e){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(A("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),A("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);A("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&A("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&$(t.prototype,n),i&&$(t,i),e}();function te(e){return(te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var ne=Object.prototype.hasOwnProperty;function ie(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){se(e,t,n[t])})}return e}function oe(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ae=function(){function e(t,n){var i=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),se(this,"getListTopOffsetInsideScrollableContainer",function(){var e=i.scrollableContainer.getTopOffset(i.getContainerElement());return i.waitForStylesToLoad.onGotListTopOffset(e),e}),se(this,"willUpdateState",function(e,t){}),se(this,"didUpdateState",function(e){var t=i.getState();if(i.onStateChange&&(function(e,t){if(ie(e,t))return!0;if("object"!==te(e)||null===e||"object"!==te(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!ne.call(t,n[r])||!ie(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||i.onStateChange(t,e)),e&&i.isRendered){A("~ Rendered ~"),i.newItemsPending=void 0,i.layoutResetPending=void 0;var n=i.redoLayoutReason;i.redoLayoutReason=void 0;var r=e.items,o=t.items;if(o!==r){var s=!0,a=i.getItemsDiff(r,o);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;if(l>0&&(i.itemHeights.onPrepend(l),i.restoreScroll.shouldRestoreScrollAfterRender())){s=!1,A("~ Restore Scroll Position ~");var u=i.restoreScroll.getScrollDifference();u?(A("Scroll down by",u),i.scroll.scrollByY(u)):A("Scroll position hasn't changed")}}else i.itemHeights.reset(),i.itemHeights.initialize(i.getState().itemHeights);s&&(n=j.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||i.onRenderedNewLayout(),n?i.redoLayoutRightAfterRender({reason:n}):void 0}}),se(this,"updateShownItemIndexes",function(){A("~ Layout results "+(i.bypass?"(bypass) ":"")+"~");var e=i.getVisibleAreaBoundsIncludingMargins();i.latestLayoutVisibleAreaIncludingMargins=e;var t=i.getListTopOffsetInsideScrollableContainer(),n=i.layout.getShownItemIndexes({listHeight:i.screen.getElementHeight(i.getContainerElement()),itemsCount:i.getItemsCount(),visibleAreaIncludingMargins:e,listTopOffsetInsideScrollableContainer:t}),r=n.firstShownItemIndex,o=n.lastShownItemIndex,s=n.redoLayoutAfterMeasuringItemHeights;i.restoreScroll.shouldRestoreScrollAfterRender()&&(o<i.restoreScroll.getAnchorItemIndex()&&(o=i.restoreScroll.getAnchorItemIndex()),s=!1);var a=i.layout.getBeforeItemsHeight(r,o),l=i.layout.getAfterItemsHeight(r,o,i.getItemsCount());i._getColumnsCount&&A("Columns count",i.getColumnsCount()),A("First shown item index",r),A("Last shown item index",o),A("Before items height",a),A("After items height (actual or estimated)",l),A("Average item height (calculated on previous render)",i.itemHeights.getAverage()),V()&&(A("Item heights",i.getState().itemHeights.slice()),A("Item states",i.getState().itemStates.slice())),s&&(i.redoLayoutReason=j.ITEM_HEIGHT_NOT_MEASURED),i.validateWillBeHiddenItemHeights(r,o),i.onBeforeShowItems(i.getState().items,i.getState().itemHeights,r,o),i.setState({firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:a,afterItemsHeight:l})}),se(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;0!==i.getItemsCount()&&(i.scroll.onLayout(),i.layoutTimer&&(I(i.layoutTimer),i.layoutTimer=void 0),A("~ Calculate Layout (on ".concat(t,") ~")),i.updateShownItemIndexes())}),se(this,"updateLayout",function(){return i.onUpdateShownItemIndexes({reason:j.MANUAL})}),se(this,"layout",function(){return i.updateLayout()});var o=r.getState,s=r.setState,a=r.onStateChange,l=r.customState,u=r.preserveScrollPositionAtBottomOnMount,h=r.preserveScrollPositionOfTheBottomOfTheListOnMount,c=r.initialScrollPosition,m=r.onScrollPositionChange,f=r.measureItemsBatchSize,d=r.getScrollableContainer,g=r.getColumnsCount,p=r.getItemId,v=r.tbody,S=r._useTimeoutInRenderLoop,b=r.bypass,C=r.estimatedItemHeight,w=r.onItemInitialRender,O=r.onItemFirstRender,T=r.scrollableContainer,H=r.state,x=r.renderingEngine;if(A("~ Initialize ~"),H&&(n=H.items),!T&&d&&(T=d()),x||(x=M),this.screen=x.createScreen(),this.scrollableContainer=x.createScrollableContainer(T),v){if("DOM"!==x.name)throw new Error("`tbody` option is only supported for DOM rendering engine");A("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(A("~ <tbody/> not supported ~"),B(y),b=!0)}b&&A('~ "bypass" mode ~'),this.bypass=b,this._useTimeoutInRenderLoop=S,this.isItemEqual=p?function(e,t){return p(e)===p(t)}:function(e,t){return e===t},this.initialItems=n,this.onStateChange=a,this._getColumnsCount=g,w?this.onItemInitialRender=w:O&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=i.getState().items.indexOf(e);t>=0&&O(t)}),A("Items count",n.length),C&&A("Estimated item height",C),s?(this.getState=o,this.setState=function(e){A("Set state",e),s(e,{willUpdateState:i.willUpdateState,didUpdateState:i.didUpdateState})}):(this.getState=function(){return i.state},this.setState=function(e){A("Set state",e);var t=i.getState(),n=re({},t,e);i.willUpdateState(n,t),i.state=n,i.didUpdateState(t)}),H&&A("Initial state (passed)",H),this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new ee(this.screen,this.getContainerElement,function(e){return i.getState().itemHeights[e]},function(e,t){return i.getState().itemHeights[e]=t}),this.layout=new U({bypass:b,estimatedItemHeight:C,measureItemsBatchSize:void 0===f?50:f,getVerticalSpacing:function(){return i.getVerticalSpacing()},getColumnsCount:function(){return i.getColumnsCount()},getItemHeight:function(e){return i.getState().itemHeights[e]},getAverageItemHeight:function(){return i.itemHeights.getAverage()}}),this.resize=new q({bypass:b,scrollableContainer:this.scrollableContainer,getContainerElement:this.getContainerElement,updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},resetStateAndLayout:function(){A("~ Scrollable container size changed, re-measure item heights. ~"),i.redoLayoutReason=j.RESIZE,i.layoutResetPending=!0,A("Reset state"),i.setState(i.getInitialLayoutState(i.newItemsPending||i.getState().items))}}),u&&console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),this.preserveScrollPositionOfTheBottomOfTheListOnMount=h||u,this.scroll=new J({bypass:this.bypass,scrollableContainer:this.scrollableContainer,updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},initialScrollPosition:c,onScrollPositionChange:m,isImmediateLayoutScheduled:function(){return i.layoutTimer},hasNonRenderedItemsAtTheTop:function(){return i.getState().firstShownItemIndex>0},hasNonRenderedItemsAtTheBottom:function(){return i.getState().lastShownItemIndex<i.getItemsCount()-1},getLatestLayoutVisibleAreaIncludingMargins:function(){return i.latestLayoutVisibleAreaIncludingMargins},preserveScrollPositionOfTheBottomOfTheListOnMount:this.preserveScrollPositionOfTheBottomOfTheListOnMount}),this.restoreScroll=new X({screen:this.screen,getContainerElement:this.getContainerElement}),this.waitForStylesToLoad=new z({updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},getListTopOffsetInsideScrollableContainer:this.getListTopOffsetInsideScrollableContainer}),this.setState(H||this.getInitialState(l))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems,n=re({},e,this.getInitialLayoutState(t),{items:t,itemStates:new Array(t.length)});return A("Initial state (autogenerated)",n),A("First shown item index",n.firstShownItemIndex),A("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutValues",value:function(e){var t=e.itemsCount,n=e.bypass;return this.layout.getInitialLayoutValues({bypass:n,itemsCount:t,visibleAreaHeightIncludingMargins:this.scrollableContainer&&2*this.getMargin()+this.scrollableContainer.getHeight()})}},{key:"getInitialLayoutState",value:function(e){var t=e.length,n=this.getInitialLayoutValues({itemsCount:t,bypass:this.preserveScrollPositionOfTheBottomOfTheListOnMount}),i=n.firstShownItemIndex,r=n.lastShownItemIndex,o=n.beforeItemsHeight,s=n.afterItemsHeight,a=new Array(t);return this.onBeforeShowItems(e,a,i,r),{itemHeights:a,columnsCount:this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0,verticalSpacing:void 0,firstShownItemIndex:i,lastShownItemIndex:r,beforeItemsHeight:o,afterItemsHeight:s}}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");A("~ Rendered (initial) ~"),this.isRendered=!0,this.onRenderedNewLayout(),this.resize.listen(),this.scroll.listen(),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount||this.onUpdateShownItemIndexes({reason:j.MOUNT})}},{key:"onRenderedNewLayout",value:function(){var e,t,n;this.measureVerticalSpacing(),this.itemHeights.measureNonPreviouslyMeasuredItemHeights(this.getState().firstShownItemIndex,this.getState().lastShownItemIndex),this.tbody&&(e=this.getContainerElement(),t=this.getState().beforeItemsHeight,n=this.getState().afterItemsHeight,e.style.setProperty("--VirtualScroller-paddingTop",v(t)),e.style.setProperty("--VirtualScroller-paddingBottom",v(n)))}},{key:"getVisibleAreaBoundsIncludingMargins",value:function(){var e=this.scroll.getVisibleAreaBounds();return e.top-=this.getMargin(),e.bottom+=this.getMargin(),e}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.resize.stop(),this.scroll.stop(),this.waitForStylesToLoad.stop(),this.layoutTimer&&(I(this.layoutTimer),this.layoutTimer=void 0)}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&I(this.layoutTimer),this.layoutTimer=p(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){A("~ Measure item vertical spacing ~");var e=function(e){var t=e.container,n=e.screen;if(n.getChildElementsCount(t)>1)for(var i=n.getChildElementTopOffset(t,0),r=n.getChildElementHeight(t,0),o=1;o<n.getChildElementsCount(t);){var s=n.getChildElementTopOffset(t,o),a=n.getChildElementHeight(t,o);if(s!==i)return s-(i+r);r=Math.max(r,a),o++}}({container:this.getContainerElement(),screen:this.screen});void 0===e?A("Not enough items rendered to measure vertical spacing"):(A("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){V()&&(A("~ Item state changed ~"),A("Item",e),A("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),A("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){A("~ Re-measure item height ~"),A("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return B('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return A("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");A("Previous height",t),A("New height",n),t!==n&&(A("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:j.ITEM_HEIGHT_CHANGED}))}},{key:"validateWillBeHiddenItemHeights",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&A("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getState().items,r=this.getState(),o=r.itemStates,s=r.itemHeights;A("~ Update items ~");var a=this.getItemsDiff(i,e);if(a&&!this.layoutResetPending){var l=this.getState();t={firstShownItemIndex:l.firstShownItemIndex,lastShownItemIndex:l.lastShownItemIndex,beforeItemsHeight:l.beforeItemsHeight,afterItemsHeight:l.afterItemsHeight};var u=a.prependedItemsCount,h=a.appendedItemsCount;u>0&&(A("Prepend",u,"items"),s=new Array(u).concat(s),o&&(o=new Array(u).concat(o))),h>0&&(A("Append",h,"items"),s=s.concat(new Array(h)),o&&(o=o.concat(new Array(h)))),this.layout.updateLayoutForItemsDiff(t,a,{itemsCount:e.length}),u>0&&(n.preserveScrollPositionOnPrependItems||n.preserveScrollPosition)&&0===this.getState().firstShownItemIndex&&(this.restoreScroll.captureScroll({previousItems:i,newItems:e,prependedItemsCount:u}),this.layout.showItemsFromTheStart(t))}else A("Items have changed, and",a?"a re-layout from scratch has been requested.":"it's not a simple append and/or prepend.","Rerender the entire list from scratch."),A("Previous items",i),A("New items",e),s=new Array(e.length),o=new Array(e.length),t=this.getInitialLayoutValues({itemsCount:e.length});A("~ Update state ~"),A("First shown item index",t.firstShownItemIndex),A("Last shown item index",t.lastShownItemIndex),A("Before items height",t.beforeItemsHeight),A("After items height (actual or estimated)",t.afterItemsHeight),this.onBeforeShowItems(e,s,t.firstShownItemIndex,t.lastShownItemIndex),this.newItemsPending=e,this.setState(re({},t,{items:e,itemStates:o,itemHeights:s}))}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){for(var r=0;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}}])&&oe(t.prototype,n),i&&oe(t,i),e}();function le(){return(le=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function ue(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function he(e){return(he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ce(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function me(e){return(me=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function fe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function de(e,t){return(de=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ge(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var pe=t.elementType||t.oneOfType([t.string,t.func,t.object]),Ie=function(t){function n(t){var i,r,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=this,o=me(n).call(this,t),i=!o||"object"!==he(o)&&"function"!=typeof o?fe(r):o,ge(fe(i),"container",e.createRef()),ge(fe(i),"onItemStateChange",new Array(i.props.items.length)),ge(fe(i),"onItemHeightChange",new Array(i.props.items.length)),ge(fe(i),"itemRefs",new Array(i.props.items.length)),ge(fe(i),"itemKeyPrefixes",[]),ge(fe(i),"updateLayout",function(){return i.virtualScroller.updateLayout()}),ge(fe(i),"layout",function(){return i.updateLayout()}),ge(fe(i),"onItemInitialRender",function(){var e=i.props.onItemInitialRender;e&&e.apply(void 0,arguments)}),ge(fe(i),"onItemFirstRender",function(){var e=i.props.onItemFirstRender;e&&e.apply(void 0,arguments)}),i.previousItemsProperty=t.items,i.generateItemKeyPrefix(),i.createVirtualScroller(),i}var i,r,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&de(e,t)}(n,e.Component),i=n,(r=[{key:"createVirtualScroller",value:function(){var e=this,t=this.props,n=t.as,i=t.items,r=t.initialState,o=t.initialCustomState,s=t.onStateChange,a=t.estimatedItemHeight,l=t.preserveScrollPositionOfTheBottomOfTheListOnMount,u=t.preserveScrollPositionAtBottomOnMount,h=t.initialScrollPosition,c=t.onScrollPositionChange,m=t.measureItemsBatchSize,f=t.scrollableContainer,d=t.getScrollableContainer,g=t.getColumnsCount,p=t.getItemId,I=t.bypass;this.virtualScroller=new ae(function(){return e.container.current},i,{_useTimeoutInRenderLoop:!0,estimatedItemHeight:a,bypass:I,onItemInitialRender:this.onItemInitialRender,onItemFirstRender:this.onItemFirstRender,preserveScrollPositionOfTheBottomOfTheListOnMount:l,preserveScrollPositionAtBottomOnMount:u,initialScrollPosition:h,onScrollPositionChange:c,shouldUpdateLayoutOnScreenResize:this.shouldUpdateLayoutOnScreenResize,measureItemsBatchSize:m,scrollableContainer:f,getScrollableContainer:d,getColumnsCount:g,getItemId:p,tbody:"tbody"===n,state:r,customState:o,onStateChange:s,getState:function(){return e.state},setState:function(t,n){var i=n.willUpdateState,r=n.didUpdateState;e.willUpdateState=i,e.didUpdateState=r,e.state?e.setState(t):(i(t),e.state=t,r())}})}},{key:"shouldUseRefs",value:function(){var e,t=this.props.itemComponent;return(e=t).prototype&&e.prototype.isReactComponent}},{key:"getItemKey",value:function(e,t){var n=this.props.getItemId;return n?n(e):"".concat(this.itemKeyPrefix,":").concat(t)}},{key:"updateItem",value:function(e){return this.renderItem(e)}},{key:"renderItem",value:function(e){var t=this;if(void 0===(e=this.getItemIndex(e)))return B("Item ".concat(JSON.stringify(e),' not found when calling ".renderItem()"'));if(!this.shouldUseRefs())return B("`.renderItem(i)` has been called but the `component` doesn't allow `ref`s. Only `component`s that're `React.Component`s support this feature.");if(this.itemRefs[e]&&this.itemRefs[e].current){var n=this.props.items,i=n[e];this.itemRefs[e].current.forceUpdate(function(){if(t._isMounted){var e=n.indexOf(i);e>=0&&t.virtualScroller.onItemHeightChange(e)}})}}},{key:"getItemIndex",value:function(e){if("number"==typeof e)return e;if("object"===he(e)&&null!==e){var t=this.props,n=t.items,i=t.getItemId,r=e;for(e=0;e<n.length;){if(i){if(i(r)===i(n[e]))return e}else if(r===n[e])return e;e++}}}},{key:"getItemRef",value:function(t){return this.itemRefs[t]||(this.itemRefs[t]=e.createRef()),this.itemRefs[t]}},{key:"getOnItemStateChange",value:function(e){var t=this;return this.onItemStateChange[e]||(this.onItemStateChange[e]=function(n){return t.virtualScroller.onItemStateChange(e,n)}),this.onItemStateChange[e]}},{key:"getOnItemHeightChange",value:function(e){var t=this;return this.onItemHeightChange[e]||(this.onItemHeightChange[e]=function(){return t.virtualScroller.onItemHeightChange(e)}),this.onItemHeightChange[e]}},{key:"generateItemKeyPrefix",value:function(){var e=String(Math.random()).slice(2);if(this.itemKeyPrefixes.indexOf(e)>=0)return this.generateItemKeyPrefix();this.itemKeyPrefixes.push(e),this.itemKeyPrefix=e}},{key:"componentDidMount",value:function(){var e=this.props.onMount;e&&e(),this._isMounted=!0,this.virtualScroller.listen()}},{key:"getSnapshotBeforeUpdate",value:function(e,t){return this.state!==t&&this.willUpdateState(this.state,t),null}},{key:"componentDidUpdate",value:function(e,t){this.state!==t&&this.didUpdateState(t);var n=this.props,i=n.items,r=n.preserveScrollPosition,o=n.preserveScrollPositionOnPrependItems;i!==e.items&&this.virtualScroller.setItems(i,{preserveScrollPositionOnPrependItems:o||r})}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.virtualScroller.stop()}},{key:"render",value:function(){var t=this,n=this.props,i=n.as,r=n.itemComponent,o=n.itemComponentProps,s=(n.items,n.estimatedItemHeight,n.bypass,n.preserveScrollPositionOnPrependItems),a=n.preserveScrollPosition,l=(n.preserveScrollPositionOfTheBottomOfTheListOnMount,n.preserveScrollPositionAtBottomOnMount,n.initialScrollPosition,n.onScrollPositionChange,n.measureItemsBatchSize,n.scrollableContainer,n.getScrollableContainer,n.getColumnsCount,n.initialState,n.initialCustomState,n.onStateChange,n.onItemInitialRender,n.onItemFirstRender,n.getItemId),u=(n.onMount,n.className),h=ue(n,["as","itemComponent","itemComponentProps","items","estimatedItemHeight","bypass","preserveScrollPositionOnPrependItems","preserveScrollPosition","preserveScrollPositionOfTheBottomOfTheListOnMount","preserveScrollPositionAtBottomOnMount","initialScrollPosition","onScrollPositionChange","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","initialState","initialCustomState","onStateChange","onItemInitialRender","onItemFirstRender","getItemId","onMount","className"]),c=this.virtualScroller.getState(),m=c.items,f=c.itemStates,d=c.firstShownItemIndex,g=c.lastShownItemIndex,p=c.beforeItemsHeight,I=c.afterItemsHeight,y=this.props.items,S=m;if(this.itemsPropertyWasChanged||(this.itemsPropertyWasChanged=this.props.items!==this.previousItemsProperty),this.previousItemsProperty=this.props.items,this.itemsPropertyWasChanged&&y!==S){var b=this.virtualScroller.getItemsDiff(S,y);if(b&&0===b.prependedItemsCount&&b.appendedItemsCount>0);else{if(b){var C=b.prependedItemsCount;C>0&&(s||a)&&0===d&&this.virtualScroller.restoreScroll.captureScroll({previousItems:S,newItems:y,prependedItemsCount:C})}l||this.generateItemKeyPrefix(),this.itemRefs=new Array(y.length)}}var w=this.virtualScroller.tbody;return e.createElement(i,le({},h,{ref:this.container,className:w?u?u+" VirtualScroller":"VirtualScroller":u,style:{paddingTop:w?void 0:v(p),paddingBottom:w?void 0:v(I)}}),m.map(function(n,i){return i>=d&&i<=g?e.createElement(r,le({},o,{ref:t.shouldUseRefs()?t.getItemRef(i):void 0,key:t.getItemKey(n,i),state:f&&f[i],onStateChange:t.getOnItemStateChange(i),onHeightChange:t.getOnItemHeightChange(i)}),n):null}))}}])&&ce(i.prototype,r),o&&ce(i,o),n}();return ge(Ie,"propTypes",{as:pe,items:t.arrayOf(t.object).isRequired,itemComponent:pe.isRequired,itemComponentProps:t.object,estimatedItemHeight:t.number,bypass:t.bool,preserveScrollPositionOnPrependItems:t.bool,preserveScrollPosition:t.bool,preserveScrollPositionOfTheBottomOfTheListOnMount:t.bool,preserveScrollPositionAtBottomOnMount:t.bool,measureItemsBatchSize:t.number,scrollableContainer:t.any,getScrollableContainer:t.func,getColumnsCount:t.func,getItemId:t.func,className:t.string,onMount:t.func,onItemInitialRender:t.func,onItemFirstRender:t.func,initialScrollPosition:t.number,onScrollPositionChange:t.func,onStateChange:t.func,initialCustomState:t.object,initialState:t.shape({items:t.arrayOf(t.object).isRequired,itemStates:t.arrayOf(t.any),firstShownItemIndex:t.number.isRequired,lastShownItemIndex:t.number.isRequired,beforeItemsHeight:t.number.isRequired,afterItemsHeight:t.number.isRequired,itemHeights:t.arrayOf(t.number).isRequired,columnsCount:t.number,verticalSpacing:t.number})}),ge(Ie,"defaultProps",{as:"div"}),Ie});
//# sourceMappingURL=virtual-scroller-react.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,c=[];s=function(e){if(0===c.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=c.slice(0);c.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return c.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<c.length;t++)c[t].handle===e&&(c[t].cancelled=!0)}}var d=function(e){return s.call(i,e)};d.cancel=function(){a.apply(i,arguments)},d.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=d.cancel;function f(e,t){var n=Date.now(),i=d(function r(){Date.now()-n>=t?e():i=d(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){return!t||"object"!==I(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function b(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),e}var C=function(){function e(t){y(this,e),this.element=t}return b(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e,t){var n,i=this,r=t.container;if("undefined"!=typeof ResizeObserver){var o=new ResizeObserver(function(t){t[0];e()});o.observe(this.element),n=function(){return o.unobserve(i.element)}}var s=(new x).onResize(e,{container:r});return function(){n&&n(),s()}}}]),e}(),x=function(e){function t(){return y(this,t),v(this,p(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(t,C),b(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e,t){var n=t.container,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var T="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function E(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var k=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"getChildElementTopCoordinate",value:function(e,t){return e.childNodes[t].getBoundingClientRect().top}},{key:"getChildElementHeight",value:function(e,t){return this.getElementHeight(e.childNodes[t])}},{key:"getChildElementsCount",value:function(e){return e.childNodes.length}},{key:"clearElement",value:function(e){!function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(e)}},{key:"getElementHeight",value:function(e){return e.getBoundingClientRect().height}}])&&E(t.prototype,n),i&&E(t,i),e}();function O(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function M(){if(A()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,O(["[virtual-scroller]"].concat(n)))}}function R(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(M.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,O(["[virtual-scroller]"].concat(t)))}function A(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function L(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var P=function(){function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=t,this.getContainerElement=n,this.getState=i,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<this.screen.getChildElementsCount(n))return this.screen.getChildElementHeight(n,i)}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(M("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),M("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);M("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&M("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&L(t.prototype,n),i&&L(t,i),e}();function V(e){return(V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var _=Object.prototype.hasOwnProperty;function U(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){D(e,t,n[t])})}return e}function N(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j=250,z=100,F=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),D(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:Y.MANUAL})}),D(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:Y.SCROLL})}),D(this,"restoreScrollPositionFromState",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),D(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),D(this,"layout",function(){return s.updateLayout()}),D(this,"onResize",(i=function(){if(s.isRendered){var e=s.scrollableContainerWidth,t=s.scrollableContainerHeight;if(s.scrollableContainerWidth=s.scrollableContainer.getWidth(),s.scrollableContainerHeight=s.scrollableContainer.getHeight(),s.scrollableContainerWidth===e){if(s.scrollableContainerHeight===t)return;s.onUpdateShownItemIndexes({reason:Y.RESIZE})}else{M("~ Scrollable container size changed, re-measure item heights. ~"),s.redoLayoutReason=Y.RESIZE;var n=s.getInitialLayoutState();M("Reset state to",n),s.setState(n)}}},r=j,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),D(this,"willUpdateState",function(e,t){}),D(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(U(e,t))return!0;if("object"!==V(e)||null===e||"object"!==V(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!_.call(t,n[r])||!U(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){M("~ Rendered ~");var n=s.redoLayoutReason;s.redoLayoutReason=void 0;var i=e.items,r=t.items;if(r!==i){var o=!0,a=s.getItemsDiff(i,r);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;l>0&&(s.itemHeights.onPrepend(l),s.restoreScrollAfterRenderValues&&(o=!1,s.restoreScrollAfterRender()))}else s.itemHeights.initialize();o&&(n=Y.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered(),n?s.redoLayoutRightAfterRender({reason:n}):void 0}}),D(this,"updateShownItemIndexes",function(){M("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterMeasuringItemHeights,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&M("Columns count",s.getColumnsCount()),M("First shown item index",t),M("Last shown item index",n),M("Before items height",o),M("After items height (actual or estimated)",a),M("Average item height (calculated on previous render)",s.itemHeights.getAverage()),A()&&(M("Item heights",s.getState().itemHeights.slice()),M("Item states",s.getState().itemStates.slice())),i&&(s.redoLayoutReason=Y.ITEM_HEIGHT_NOT_MEASURED),s.validateWillBeHiddenItemHeightsAndState(t,n),s.onBeforeShowItems(s.getState().items,s.getState().itemHeights,t,n),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),D(this,"updateShownItemIndexesRecursive",function(){s.layoutInProgress=!0,s.updateShownItemIndexes()}),D(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()){if(s.onUserStopsScrollingTimer&&(g(s.onUserStopsScrollingTimer),s.onUserStopsScrollingTimer=void 0),t===Y.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(M(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n){if(s.layoutTimer)return;return void(s.onUserStopsScrollingTimer=f(function(){s.isRendered&&s.onUpdateShownItemIndexes({reason:Y.STOPPED_SCROLLING})},z))}}s.layoutTimer&&(g(s.layoutTimer),s.layoutTimer=void 0),M("~ Calculate Layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}});var l=a.getState,u=a.setState,h=a.onStateChange,c=a.customState,d=a.preserveScrollPositionAtBottomOnMount,m=a.measureItemsBatchSize,I=a.getScrollableContainer,v=a.getColumnsCount,p=a.getItemId,S=a.tbody,y=a._useTimeoutInRenderLoop,w=a.bypass,b=a.estimatedItemHeight,H=a.onItemInitialRender,E=a.onItemFirstRender,O=a.scrollableContainer,L=a.preserveScrollPositionOfTheBottomOfTheListOnMount,N=a.state;if(this.renderer="DOM",M("~ Initialize ~"),N&&(n=N.items),!O&&I&&(O=I()),"DOM"!==this.renderer)throw new Error('Unknown renderer: "'.concat(this.renderer,'"'));if(O?this.scrollableContainer=new C(O):"undefined"!=typeof window&&(this.scrollableContainer=new x),S){if("DOM"!==this.renderer)throw new Error("`tbody` option is only supported for DOM renderer");M("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(M("~ <tbody/> not supported ~"),R(T),w=!0)}if(w&&M('~ "bypass" mode ~'),this.bypass=w,this._useTimeoutInRenderLoop=y,this.isItemEqual=p?function(e,t){return p(e)===p(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=b,this.onStateChange=h,this.measureItemsBatchSize=void 0===m?50:m,this._getColumnsCount=v,H?this.onItemInitialRender=H:E&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&E(t)}),M("Items count",n.length),b&&M("Estimated item height",b),u?(this.getState=l,this.setState=function(e){M("Set state",e),u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){M("Set state",e);var t=s.getState(),n=B({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),N&&M("Initial state (passed)",N),"DOM"!==this.renderer)throw new Error('Unknown renderer: "'.concat(this.renderer,'"'));this.screen=new k,this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new P(this.screen,this.getContainerElement,this.getState),this.scrollableContainer&&(d&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),L=d),L&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(N||this.getInitialState(c))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=B({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return M("Initial state (autogenerated)",n),M("First shown item index",n.firstShownItemIndex),M("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1);var o=new Array(i);return this.onBeforeShowItems(n,o,e,t),{itemHeights:o,columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");M("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPositionFromState(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize,{container:this.getContainerElement()})),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:Y.MOUNT})}},{key:"onRendered",value:function(){this.measureVerticalSpacing(),this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.screen.getElementHeight(this.getContainerElement())}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),g(this.onUserStopsScrollingTimer),g(this.watchContainerElementCoordinatesTimer),g(this.layoutTimer))}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&g(this.layoutTimer),this.layoutTimer=f(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){M("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacingValue();void 0===e?M("Not enough items rendered to measure vertical spacing"):(M("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"measureVerticalSpacingValue",value:function(){var e=this.getContainerElement();if(this.screen.getChildElementsCount(e)>1)for(var t=this.screen.getChildElementTopCoordinate(e,0),n=this.screen.getChildElementHeight(e,0),i=1;i<this.screen.getChildElementsCount(e);){var r=this.screen.getChildElementTopCoordinate(e,i),o=this.screen.getChildElementHeight(e,i);if(r!==t)return r-(t+n);n=Math.max(n,o),i++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t)this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n)}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){A()&&(M("~ Item state changed ~"),M("Item",e),M("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),M("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){M("~ Re-measure item height ~"),M("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return R('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return M("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");M("Previous height",t),M("New height",n),t!==n&&(M("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:Y.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,c=0,d=0,m=void 0;d<a&&(m=u*a+d)<s;){var f=this.getState().itemHeights[m];if(void 0===f){M("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(c=Math.max(c,f),void 0===i&&n+o+c>e&&(M("First shown row index",u),i=u*a),n+o+c+h>t)return M("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};d++}o+=c,o+=h,u++}return void 0!==i&&void 0===r&&M("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterRenderValues&&(s<this.restoreScrollAfterRenderValues.index&&(s=this.restoreScrollAfterRenderValues.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterMeasuringItemHeights:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;M("The entire list is off-screen. No items are visible.")}else M("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&M("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:Y.TOP_OFFSET_CHANGED}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=f(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"captureScroll",value:function(e,t,n){if(0!==e.length&&0!==n){var i=this.getState().firstShownItemIndex,r=this.getContainerElement(),o=this.screen.getChildElementTopCoordinate(r,0);if(i>0)for(var s=this.getState().itemHeights,a=i-1;a>=0;)o+=s[a]+this.getVerticalSpacing(),a--;this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===e&&this.restoreScrollAfterRenderValues.nextItems===t||(this.restoreScrollAfterRenderValues={previousItems:e,nextItems:t,index:n,visibleAreaTop:o})}}},{key:"restoreScrollAfterRender",value:function(){M("~ Restore Scroll Position ~");var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;this.restoreScrollAfterRenderValues=void 0;var i=this.screen.getChildElementTopCoordinate(this.getContainerElement(),t)-n;0===i?M("Scroll position hasn't changed"):(M("Scroll down by",i),this.scrollTo(0,this.getScrollY()+i))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights;M("~ Update items ~");var h=this.getItemsDiff(n,e);if(h){var c=h.prependedItemsCount,d=h.appendedItemsCount;c>0&&(M("Prepend",c,"items"),u=new Array(c).concat(u),l&&(l=new Array(c).concat(l))),d>0&&(M("Append",d,"items"),u=u.concat(new Array(d)),l&&(l=l.concat(new Array(d)))),r+=c,o+=c;this.getVerticalSpacing();var m=this.getColumnsCount();if(c%m==0){var f=c/m,g=Math.ceil(d/m);s+=f*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=g*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u);c>0&&(t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition)&&(r=0,s=0,this.captureScroll(n,e,c))}else M("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),M("Previous items",n),M("New items",e),u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;M("~ Update state ~"),M("First shown item index",r),M("Last shown item index",o),M("Before items height",s),M("After items height (actual or estimated)",a),this.onBeforeShowItems(e,u,r,o),this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){for(var r=0;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}}])&&N(t.prototype,n),i&&N(t,i),e}(),Y={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"top offset changed"};return F});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,c=[];s=function(e){if(0===c.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=c.slice(0);c.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return c.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<c.length;t++)c[t].handle===e&&(c[t].cancelled=!0)}}var d=function(e){return s.call(i,e)};d.cancel=function(){a.apply(i,arguments)},d.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=d.cancel;function f(e,t){var n=Date.now(),i=d(function r(){Date.now()-n>=t?e():i=d(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return e.toFixed(2)+"px"}var p="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function v(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var y=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"getChildElementTopOffset",value:function(e,t){return e.childNodes[t].getBoundingClientRect().top}},{key:"getChildElementHeight",value:function(e,t){return this.getElementHeight(e.childNodes[t])}},{key:"getChildElementsCount",value:function(e){return e.childNodes.length}},{key:"clearElement",value:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}},{key:"getElementHeight",value:function(e){return e.getBoundingClientRect().height}}])&&v(t.prototype,n),i&&v(t,i),e}();function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function b(e,t){return!t||"object"!==S(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t){return(C=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function T(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function x(e,t,n){return t&&H(e.prototype,t),n&&H(e,n),e}var L=function(){function e(t){T(this,e),this.element=t}return x(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollToY",value:function(e){this.element.scrollTo(0,e)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e,t){var n,i=this,r=t.container;if("undefined"!=typeof ResizeObserver){var o=new ResizeObserver(function(t){t[0];e()});o.observe(this.element),n=function(){return o.unobserve(i.element)}}var s=E(e,{container:r});return function(){n&&n(),s()}}}]),e}(),O=function(e){function t(){return T(this,t),b(this,w(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&C(e,t)}(t,L),x(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e,t){return E(e,{container:t.container})}}]),t}();function E(e,t){var n=t.container,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}var k={name:"DOM",createScreen:function(){return new y},createScrollableContainer:function(e){return e?new L(e):"undefined"!=typeof window?new O:void 0}};function A(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function R(){if(P()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,A(["[virtual-scroller]"].concat(n)))}}function M(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(R.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,A(["[virtual-scroller]"].concat(t)))}function P(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function V(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var B=function(){function e(t){var n=t.bypass,i=t.estimatedItemHeight,r=t.measureItemsBatchSize,o=t.getVerticalSpacing,s=t.getColumnsCount,a=t.getItemHeight,l=t.getAverageItemHeight;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.bypass=n,this.estimatedItemHeight=i,this.measureItemsBatchSize=r,this.getVerticalSpacing=o,this.getColumnsCount=s,this.getItemHeight=a,this.getAverageItemHeight=l}var t,n,i;return t=e,(n=[{key:"getInitialLayoutValues",value:function(e){var t,n,i=e.bypass,r=e.itemsCount,o=e.visibleAreaHeightIncludingMargins,s=o?this.getEstimatedRowsCountForHeight(o):1;return r>0&&(t=0,n=this.getLastShownItemIndex(t,r,s,i)),{beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:t,lastShownItemIndex:n}}},{key:"getLastShownItemIndex",value:function(e,t,n,i){return this.bypass||i?t-1:Math.min(e+(n*this.getColumnsCount()-1),t-1)}},{key:"getEstimatedRowsCountForHeight",value:function(e){var t=this.getEstimatedItemHeight();return t?Math.ceil((e+this.getVerticalSpacing())/(t+this.getVerticalSpacing())):1}},{key:"getEstimatedItemHeight",value:function(){return this.getAverageItemHeight()||this.estimatedItemHeight||0}},{key:"updateLayoutForItemsDiff",value:function(e,t,n){var i=t.prependedItemsCount,r=t.appendedItemsCount,o=n.itemsCount;e.firstShownItemIndex+=i,e.lastShownItemIndex+=i;var s=this.getColumnsCount();if(i%s==0){var a=i/s,l=Math.ceil(r/s),u=this.getAverageItemHeight(),h=this.getVerticalSpacing();e.beforeItemsHeight+=a*(u+h),e.afterItemsHeight+=l*(h+u)}else e.beforeItemsHeight=this.getBeforeItemsHeight(firstShownItemIndex,lastShownItemIndex),e.afterItemsHeight=this.getAfterItemsHeight(firstShownItemIndex,lastShownItemIndex,o)}},{key:"_getVisibleItemIndexes",value:function(e,t,n,i){for(var r,o,s=this.getColumnsCount(),a=0,l=Math.ceil(i/s),u=0;u<l;){for(var h=i>(u+1)*s?this.getVerticalSpacing():0,c=0,d=0,m=void 0;d<s&&(m=u*s+d)<i;){var f=this.getItemHeight(m);if(void 0===f){R("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===r&&(r=u*s);var g=t-(n+a);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:r,lastShownItemIndex:o=Math.min((u+this.getEstimatedRowsCountForHeight(g))*s-1,i-1)}}if(c=Math.max(c,f),void 0===r&&n+a+c>e&&(R("First shown row index",u),r=u*s),n+a+c+h>t)return R("Last shown row index",u),void 0!==r&&(o=Math.min((u+1)*s-1,i-1)),{firstShownItemIndex:r,lastShownItemIndex:o};d++}a+=c,a+=h,u++}return void 0!==r&&void 0===o&&R("Last item index (is fully visible)",o=i-1),{firstShownItemIndex:r,lastShownItemIndex:o}}},{key:"getVisibleItemIndexes",value:function(e,t,n,i){var r=this._getVisibleItemIndexes(e,t,n,i),o=r.firstNonMeasuredItemIndex,s=r.firstShownItemIndex,a=r.lastShownItemIndex,l=void 0!==o;if(l&&this.measureItemsBatchSize){var u=o+this.measureItemsBatchSize-1,h=this.getColumnsCount();a=Math.min(a,Math.ceil(u/h)*h-1)}return{firstShownItemIndex:s,lastShownItemIndex:a,redoLayoutAfterMeasuringItemHeights:l}}},{key:"getNonVisibleListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getItemHeight(0)}}},{key:"getItemIndexes",value:function(e,t,n,i,r){if(n+i>e&&n<t){var o=this.getVisibleItemIndexes(e,t,n,r);if(void 0!==o.firstShownItemIndex)return o;R("The entire list is off-screen. No items are visible.")}else R("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t){for(var n=this.getColumnsCount(),i=Math.floor(e/n),r=0,o=0;o<i;){for(var s=0,a=0;a<n;)s=Math.max(s,this.getItemHeight(o*n+a)||this.getAverageItemHeight()),a++;r+=s,r+=this.getVerticalSpacing(),o++}return r}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.ceil(n/i),o=0,s=Math.floor(t/i)+1;s<r;){for(var a=0,l=0,u=void 0;l<i&&(u=s*i+l)<n;)a=Math.max(a,this.getItemHeight(u)||this.getAverageItemHeight()),l++;o+=this.getVerticalSpacing(),o+=a,s++}return o}},{key:"getShownItemIndexes",value:function(e){var t=e.listHeight,n=e.itemsCount,i=e.visibleAreaIncludingMargins,r=e.listTopOffsetInsideScrollableContainer;return this.bypass?{firstShownItemIndex:0,lastShownItemIndex:n-1}:this.getItemIndexes(i.top,i.bottom,r,t,n)||this.getNonVisibleListShownItemIndexes()}},{key:"showItemsFromTheStart",value:function(e){e.firstShownItemIndex=0,e.beforeItemsHeight=0}}])&&V(t.prototype,n),i&&V(t,i),e}(),_={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"list top offset changed"};function N(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var U=function(){function e(t){var n=t.updateLayout,i=t.getListTopOffsetInsideScrollableContainer;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.updateLayout=n,this.getListTopOffsetInsideScrollableContainer=i}var t,n,i;return t=e,(n=[{key:"onGotListTopOffset",value:function(e){void 0===this.listTopOffsetInsideScrollableContainer&&this.start(),this.listTopOffsetInsideScrollableContainer=e}},{key:"start",value:function(){this.isRendered=!0,this.watchListTopOffset()}},{key:"stop",value:function(){this.isRendered=!1,g(this.watchListTopOffsetTimer)}},{key:"watchListTopOffset",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.listTopOffsetInsideScrollableContainer&&e.getListTopOffsetInsideScrollableContainer()!==e.listTopOffsetInsideScrollableContainer&&e.updateLayout({reason:_.TOP_OFFSET_CHANGED}),Date.now()-t<D&&(e.watchListTopOffsetTimer=f(n,j)))}()}}])&&N(t.prototype,n),i&&N(t,i),e}(),j=500,D=3e3;function z(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var F=function(){function e(t){var n,i,r,o,s,a,l=this,u=t.bypass,h=t.scrollableContainer,c=t.getContainerElement,d=t.updateLayout,m=t.resetStateAndLayout;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o=function(){if(l.isRendered){var e=l.scrollableContainerWidth,t=l.scrollableContainerHeight;if(l.scrollableContainerWidth=l.scrollableContainer.getWidth(),l.scrollableContainerHeight=l.scrollableContainer.getHeight(),l.scrollableContainerWidth===e){if(l.scrollableContainerHeight===t)return;l.updateLayout({reason:_.RESIZE})}else l.resetStateAndLayout()}},s=Y,r=function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];g(a),a=f(function(){return o.apply(e,n)},s)},(i="onResize")in(n=this)?Object.defineProperty(n,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[i]=r,this.bypass=u,this.scrollableContainer=h,this.getContainerElement=c,this.updateLayout=d,this.resetStateAndLayout=m}var t,n,i;return t=e,(n=[{key:"listen",value:function(){this.bypass||(this.isRendered=!0,this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize,{container:this.getContainerElement()}))}},{key:"stop",value:function(){this.isRendered=!1,this.scrollableContainerUnlistenResize&&this.scrollableContainerUnlistenResize()}}])&&z(t.prototype,n),i&&z(t,i),e}(),Y=250;function G(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function W(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var q=function(){function e(t){var n=this,i=t.bypass,r=t.scrollableContainer,o=t.updateLayout,s=t.initialScrollPosition,a=t.onScrollPositionChange,l=t.isImmediateLayoutScheduled,u=t.hasNonRenderedItemsAtTheTop,h=t.hasNonRenderedItemsAtTheBottom,c=t.getLatestLayoutVisibleAreaIncludingMargins,d=t.preserveScrollPositionOfTheBottomOfTheListOnMount;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),W(this,"updateScrollPosition",function(){n.onScrollPositionChange(n.getScrollY())}),W(this,"onScroll",function(){n.cancelOnUserStopsScrollingTimer();var e=n.getLatestLayoutVisibleAreaIncludingMargins()&&(n.getScrollY()<n.getLatestLayoutVisibleAreaIncludingMargins().top&&n.hasNonRenderedItemsAtTheTop()||n.getScrollY()+n.scrollableContainer.getHeight()>n.getLatestLayoutVisibleAreaIncludingMargins().bottom&&n.hasNonRenderedItemsAtTheBottom());if(R(e?"The user has scrolled far enough: force re-layout":"The user hasn't scrolled too much: delay re-layout"),e)n.updateLayout({reason:_.SCROLL});else{if(n.isImmediateLayoutScheduled())return;n.onUserStopsScrollingTimer=f(function(){n.onUserStopsScrollingTimer=void 0,n.updateLayout({reason:_.STOPPED_SCROLLING})},Z)}}),this.bypass=i,this.scrollableContainer=r,this.updateLayout=o,this.initialScrollPosition=s,this.onScrollPositionChange=a,this.isImmediateLayoutScheduled=l,this.hasNonRenderedItemsAtTheTop=u,this.hasNonRenderedItemsAtTheBottom=h,this.getLatestLayoutVisibleAreaIncludingMargins=c,d&&r&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:r.getContentHeight()})}var t,n,i;return t=e,(n=[{key:"listen",value:function(){void 0!==this.initialScrollPosition&&this.scrollToY(this.initialScrollPosition),this.onScrollPositionChange&&(this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition)),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&this.scrollToY(this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight))}},{key:"stop",value:function(){this.removeScrollPositionListener&&this.removeScrollPositionListener(),this.removeScrollListener&&this.removeScrollListener(),this.cancelOnUserStopsScrollingTimer()}},{key:"scrollToY",value:function(e){this.scrollableContainer.scrollToY(e)}},{key:"scrollByY",value:function(e){this.scrollToY(this.getScrollY()+e)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"cancelOnUserStopsScrollingTimer",value:function(){this.onUserStopsScrollingTimer&&(g(this.onUserStopsScrollingTimer),this.onUserStopsScrollingTimer=void 0)}},{key:"onLayout",value:function(){this.cancelOnUserStopsScrollingTimer()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}}])&&G(t.prototype,n),i&&G(t,i),e}(),Z=100;function J(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var K=function(){function e(t){var n=t.screen,i=t.getContainerElement,r=t.scrollBy;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=n,this.getContainerElement=i,this.scrollBy=r}var t,n,i;return t=e,(n=[{key:"captureScroll",value:function(e){var t=e.previousItems,n=e.newItems,i=e.prependedItemsCount;if(0!==t.length&&0!==i){var r=this.getContainerElement(),o=this.screen.getChildElementTopOffset(r,0);this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===t&&this.restoreScrollAfterRenderValues.newItems===n||(this.restoreScrollAfterRenderValues={previousItems:t,newItems:n,index:i,visibleAreaTop:o})}}},{key:"getAnchorItemIndex",value:function(){return this.restoreScrollAfterRenderValues.index}},{key:"shouldRestoreScrollAfterRender",value:function(){return void 0!==this.restoreScrollAfterRenderValues}},{key:"getScrollDifference",value:function(){var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;return this.restoreScrollAfterRenderValues=void 0,this.screen.getChildElementTopOffset(this.getContainerElement(),t)-n}}])&&J(t.prototype,n),i&&J(t,i),e}();function Q(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var X=function(){function e(t,n,i,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.screen=t,this.getContainerElement=n,this._get=i,this._set=r,this.reset()}var t,n,i;return t=e,(n=[{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initialize",value:function(e){for(var t=0;t<e.length;){if(void 0===e[t]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=t-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=t),this.measuredItemsHeight+=e[t];t++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<this.screen.getChildElementsCount(n))return this.screen.getChildElementHeight(n,i)}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){if(void 0!==e){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(R("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),R("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);R("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&R("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&Q(t.prototype,n),i&&Q(t,i),e}();function $(e){return($="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var ee=Object.prototype.hasOwnProperty;function te(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function ne(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){re(e,t,n[t])})}return e}function ie(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function re(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return function(){function e(t,n){var i=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),re(this,"getListTopOffsetInsideScrollableContainer",function(){var e=i.scrollableContainer.getTopOffset(i.getContainerElement());return i.waitForStylesToLoad.onGotListTopOffset(e),e}),re(this,"willUpdateState",function(e,t){}),re(this,"didUpdateState",function(e){var t=i.getState();if(i.onStateChange&&(function(e,t){if(te(e,t))return!0;if("object"!==$(e)||null===e||"object"!==$(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!ee.call(t,n[r])||!te(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||i.onStateChange(t,e)),e&&i.isRendered){R("~ Rendered ~"),i.newItemsPending=void 0,i.layoutResetPending=void 0;var n=i.redoLayoutReason;i.redoLayoutReason=void 0;var r=e.items,o=t.items;if(o!==r){var s=!0,a=i.getItemsDiff(r,o);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;if(l>0&&(i.itemHeights.onPrepend(l),i.restoreScroll.shouldRestoreScrollAfterRender())){s=!1,R("~ Restore Scroll Position ~");var u=i.restoreScroll.getScrollDifference();u?(R("Scroll down by",u),i.scroll.scrollByY(u)):R("Scroll position hasn't changed")}}else i.itemHeights.reset(),i.itemHeights.initialize(i.getState().itemHeights);s&&(n=_.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||i.onRenderedNewLayout(),n?i.redoLayoutRightAfterRender({reason:n}):void 0}}),re(this,"updateShownItemIndexes",function(){R("~ Layout results "+(i.bypass?"(bypass) ":"")+"~");var e=i.getVisibleAreaBoundsIncludingMargins();i.latestLayoutVisibleAreaIncludingMargins=e;var t=i.getListTopOffsetInsideScrollableContainer(),n=i.layout.getShownItemIndexes({listHeight:i.screen.getElementHeight(i.getContainerElement()),itemsCount:i.getItemsCount(),visibleAreaIncludingMargins:e,listTopOffsetInsideScrollableContainer:t}),r=n.firstShownItemIndex,o=n.lastShownItemIndex,s=n.redoLayoutAfterMeasuringItemHeights;i.restoreScroll.shouldRestoreScrollAfterRender()&&(o<i.restoreScroll.getAnchorItemIndex()&&(o=i.restoreScroll.getAnchorItemIndex()),s=!1);var a=i.layout.getBeforeItemsHeight(r,o),l=i.layout.getAfterItemsHeight(r,o,i.getItemsCount());i._getColumnsCount&&R("Columns count",i.getColumnsCount()),R("First shown item index",r),R("Last shown item index",o),R("Before items height",a),R("After items height (actual or estimated)",l),R("Average item height (calculated on previous render)",i.itemHeights.getAverage()),P()&&(R("Item heights",i.getState().itemHeights.slice()),R("Item states",i.getState().itemStates.slice())),s&&(i.redoLayoutReason=_.ITEM_HEIGHT_NOT_MEASURED),i.validateWillBeHiddenItemHeights(r,o),i.onBeforeShowItems(i.getState().items,i.getState().itemHeights,r,o),i.setState({firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:a,afterItemsHeight:l})}),re(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;0!==i.getItemsCount()&&(i.scroll.onLayout(),i.layoutTimer&&(g(i.layoutTimer),i.layoutTimer=void 0),R("~ Calculate Layout (on ".concat(t,") ~")),i.updateShownItemIndexes())}),re(this,"updateLayout",function(){return i.onUpdateShownItemIndexes({reason:_.MANUAL})}),re(this,"layout",function(){return i.updateLayout()});var o=r.getState,s=r.setState,a=r.onStateChange,l=r.customState,u=r.preserveScrollPositionAtBottomOnMount,h=r.preserveScrollPositionOfTheBottomOfTheListOnMount,c=r.initialScrollPosition,d=r.onScrollPositionChange,m=r.measureItemsBatchSize,f=r.getScrollableContainer,I=r.getColumnsCount,v=r.getItemId,y=r.tbody,S=r._useTimeoutInRenderLoop,b=r.bypass,w=r.estimatedItemHeight,C=r.onItemInitialRender,T=r.onItemFirstRender,H=r.scrollableContainer,x=r.state,L=r.renderingEngine;if(R("~ Initialize ~"),x&&(n=x.items),!H&&f&&(H=f()),L||(L=k),this.screen=L.createScreen(),this.scrollableContainer=L.createScrollableContainer(H),y){if("DOM"!==L.name)throw new Error("`tbody` option is only supported for DOM rendering engine");R("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(R("~ <tbody/> not supported ~"),M(p),b=!0)}b&&R('~ "bypass" mode ~'),this.bypass=b,this._useTimeoutInRenderLoop=S,this.isItemEqual=v?function(e,t){return v(e)===v(t)}:function(e,t){return e===t},this.initialItems=n,this.onStateChange=a,this._getColumnsCount=I,C?this.onItemInitialRender=C:T&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=i.getState().items.indexOf(e);t>=0&&T(t)}),R("Items count",n.length),w&&R("Estimated item height",w),s?(this.getState=o,this.setState=function(e){R("Set state",e),s(e,{willUpdateState:i.willUpdateState,didUpdateState:i.didUpdateState})}):(this.getState=function(){return i.state},this.setState=function(e){R("Set state",e);var t=i.getState(),n=ne({},t,e);i.willUpdateState(n,t),i.state=n,i.didUpdateState(t)}),x&&R("Initial state (passed)",x),this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new X(this.screen,this.getContainerElement,function(e){return i.getState().itemHeights[e]},function(e,t){return i.getState().itemHeights[e]=t}),this.layout=new B({bypass:b,estimatedItemHeight:w,measureItemsBatchSize:void 0===m?50:m,getVerticalSpacing:function(){return i.getVerticalSpacing()},getColumnsCount:function(){return i.getColumnsCount()},getItemHeight:function(e){return i.getState().itemHeights[e]},getAverageItemHeight:function(){return i.itemHeights.getAverage()}}),this.resize=new F({bypass:b,scrollableContainer:this.scrollableContainer,getContainerElement:this.getContainerElement,updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},resetStateAndLayout:function(){R("~ Scrollable container size changed, re-measure item heights. ~"),i.redoLayoutReason=_.RESIZE,i.layoutResetPending=!0,R("Reset state"),i.setState(i.getInitialLayoutState(i.newItemsPending||i.getState().items))}}),u&&console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),this.preserveScrollPositionOfTheBottomOfTheListOnMount=h||u,this.scroll=new q({bypass:this.bypass,scrollableContainer:this.scrollableContainer,updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},initialScrollPosition:c,onScrollPositionChange:d,isImmediateLayoutScheduled:function(){return i.layoutTimer},hasNonRenderedItemsAtTheTop:function(){return i.getState().firstShownItemIndex>0},hasNonRenderedItemsAtTheBottom:function(){return i.getState().lastShownItemIndex<i.getItemsCount()-1},getLatestLayoutVisibleAreaIncludingMargins:function(){return i.latestLayoutVisibleAreaIncludingMargins},preserveScrollPositionOfTheBottomOfTheListOnMount:this.preserveScrollPositionOfTheBottomOfTheListOnMount}),this.restoreScroll=new K({screen:this.screen,getContainerElement:this.getContainerElement}),this.waitForStylesToLoad=new U({updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},getListTopOffsetInsideScrollableContainer:this.getListTopOffsetInsideScrollableContainer}),this.setState(x||this.getInitialState(l))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems,n=ne({},e,this.getInitialLayoutState(t),{items:t,itemStates:new Array(t.length)});return R("Initial state (autogenerated)",n),R("First shown item index",n.firstShownItemIndex),R("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutValues",value:function(e){var t=e.itemsCount,n=e.bypass;return this.layout.getInitialLayoutValues({bypass:n,itemsCount:t,visibleAreaHeightIncludingMargins:this.scrollableContainer&&2*this.getMargin()+this.scrollableContainer.getHeight()})}},{key:"getInitialLayoutState",value:function(e){var t=e.length,n=this.getInitialLayoutValues({itemsCount:t,bypass:this.preserveScrollPositionOfTheBottomOfTheListOnMount}),i=n.firstShownItemIndex,r=n.lastShownItemIndex,o=n.beforeItemsHeight,s=n.afterItemsHeight,a=new Array(t);return this.onBeforeShowItems(e,a,i,r),{itemHeights:a,columnsCount:this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0,verticalSpacing:void 0,firstShownItemIndex:i,lastShownItemIndex:r,beforeItemsHeight:o,afterItemsHeight:s}}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");R("~ Rendered (initial) ~"),this.isRendered=!0,this.onRenderedNewLayout(),this.resize.listen(),this.scroll.listen(),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount||this.onUpdateShownItemIndexes({reason:_.MOUNT})}},{key:"onRenderedNewLayout",value:function(){var e,t,n;this.measureVerticalSpacing(),this.itemHeights.measureNonPreviouslyMeasuredItemHeights(this.getState().firstShownItemIndex,this.getState().lastShownItemIndex),this.tbody&&(e=this.getContainerElement(),t=this.getState().beforeItemsHeight,n=this.getState().afterItemsHeight,e.style.setProperty("--VirtualScroller-paddingTop",I(t)),e.style.setProperty("--VirtualScroller-paddingBottom",I(n)))}},{key:"getVisibleAreaBoundsIncludingMargins",value:function(){var e=this.scroll.getVisibleAreaBounds();return e.top-=this.getMargin(),e.bottom+=this.getMargin(),e}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.resize.stop(),this.scroll.stop(),this.waitForStylesToLoad.stop(),this.layoutTimer&&(g(this.layoutTimer),this.layoutTimer=void 0)}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&g(this.layoutTimer),this.layoutTimer=f(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){R("~ Measure item vertical spacing ~");var e=function(e){var t=e.container,n=e.screen;if(n.getChildElementsCount(t)>1)for(var i=n.getChildElementTopOffset(t,0),r=n.getChildElementHeight(t,0),o=1;o<n.getChildElementsCount(t);){var s=n.getChildElementTopOffset(t,o),a=n.getChildElementHeight(t,o);if(s!==i)return s-(i+r);r=Math.max(r,a),o++}}({container:this.getContainerElement(),screen:this.screen});void 0===e?R("Not enough items rendered to measure vertical spacing"):(R("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){P()&&(R("~ Item state changed ~"),R("Item",e),R("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),R("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){R("~ Re-measure item height ~"),R("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return M('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return R("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");R("Previous height",t),R("New height",n),t!==n&&(R("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:_.ITEM_HEIGHT_CHANGED}))}},{key:"validateWillBeHiddenItemHeights",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&R("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getState().items,r=this.getState(),o=r.itemStates,s=r.itemHeights;R("~ Update items ~");var a=this.getItemsDiff(i,e);if(a&&!this.layoutResetPending){var l=this.getState();t={firstShownItemIndex:l.firstShownItemIndex,lastShownItemIndex:l.lastShownItemIndex,beforeItemsHeight:l.beforeItemsHeight,afterItemsHeight:l.afterItemsHeight};var u=a.prependedItemsCount,h=a.appendedItemsCount;u>0&&(R("Prepend",u,"items"),s=new Array(u).concat(s),o&&(o=new Array(u).concat(o))),h>0&&(R("Append",h,"items"),s=s.concat(new Array(h)),o&&(o=o.concat(new Array(h)))),this.layout.updateLayoutForItemsDiff(t,a,{itemsCount:e.length}),u>0&&(n.preserveScrollPositionOnPrependItems||n.preserveScrollPosition)&&0===this.getState().firstShownItemIndex&&(this.restoreScroll.captureScroll({previousItems:i,newItems:e,prependedItemsCount:u}),this.layout.showItemsFromTheStart(t))}else R("Items have changed, and",a?"a re-layout from scratch has been requested.":"it's not a simple append and/or prepend.","Rerender the entire list from scratch."),R("Previous items",i),R("New items",e),s=new Array(e.length),o=new Array(e.length),t=this.getInitialLayoutValues({itemsCount:e.length});R("~ Update state ~"),R("First shown item index",t.firstShownItemIndex),R("Last shown item index",t.lastShownItemIndex),R("Before items height",t.beforeItemsHeight),R("After items height (actual or estimated)",t.afterItemsHeight),this.onBeforeShowItems(e,s,t.firstShownItemIndex,t.lastShownItemIndex),this.newItemsPending=e,this.setState(ne({},t,{items:e,itemStates:o,itemHeights:s}))}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){for(var r=0;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}}])&&ie(t.prototype,n),i&&ie(t,i),e}()});
//# sourceMappingURL=virtual-scroller.js.map
<!-- `virtual-scroller`: in `.updateItems()` handle a case when `items.length` is the same, in which case find different items and if those items are rendered then maybe update them on screen and update their height, if the items are past rendered then maybe just discard all item heights past rendered, if the items are before rendered then maybe ignore and it will jump on scroll up which is kinda acceptable. -->
1.7.4 / 31.12.2020
==================
* Removed `scrollY` from `VirtualScroller`'s `state`: instead, pass `initialScrollPosition` and `onScrollPositionChange()` options to `VirtualScroller` constructor (or the same properties to the React component).
* Removed `getItemCoordinates(i)` function.
* Added `renderingEngine` option.
* Refactored.
1.7.3 / 30.12.2020

@@ -4,0 +15,0 @@ ==================

@@ -8,3 +8,3 @@ "use strict";

var _log = _interopRequireWildcard(require("./log"));
var _debug = _interopRequireWildcard(require("./utility/debug"));

@@ -22,3 +22,3 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }

function () {
function ItemHeights(screen, getContainerElement, getState) {
function ItemHeights(screen, getContainerElement, getItemHeight, setItemHeight) {
_classCallCheck(this, ItemHeights);

@@ -28,16 +28,8 @@

this.getContainerElement = getContainerElement;
this.getState = getState;
this.initialize();
this._get = getItemHeight;
this._set = setItemHeight;
this.reset();
}
_createClass(ItemHeights, [{
key: "initialize",
value: function initialize() {
this.reset();
if (this.getState()) {
this.initializeFromState(this.getState());
}
}
}, {
key: "reset",

@@ -68,5 +60,4 @@ value: function reset() {

}, {
key: "initializeFromState",
value: function initializeFromState(_ref) {
var itemHeights = _ref.itemHeights;
key: "initialize",
value: function initialize(itemHeights) {
var i = 0;

@@ -126,3 +117,6 @@

value: function measureNonPreviouslyMeasuredItemHeights(firstShownItemIndex, lastShownItemIndex) {
// Reset `this.measuredItemsHeight` if it's not a "continuous" measured items list:
// If no items are rendered, don't measure anything.
if (firstShownItemIndex === undefined) {
return;
} // Reset `this.measuredItemsHeight` if it's not a "continuous" measured items list:
// if a group of items has been measured previously, and now it has rendered a completely

@@ -132,6 +126,8 @@ // different group of items, and there's a non-measured "gap" between those two groups,

// For example, this could happen when `.setItems()` prepends a lot of new items.
if (this.firstMeasuredItemIndex !== undefined) {
if (firstShownItemIndex > this.lastMeasuredItemIndex + 1 || lastShownItemIndex < this.firstMeasuredItemIndex - 1) {
// Reset.
(0, _log["default"])('Non-measured items gap detected. Reset first and last measured item indexes.');
(0, _debug["default"])('Non-measured items gap detected. Reset first and last measured item indexes.');
this.reset();

@@ -159,7 +155,7 @@ }

nonPreviouslyMeasuredItemIndexes.push(i);
(0, _log["default"])('Item', i, 'hasn\'t been previously measured');
(0, _debug["default"])('Item', i, 'hasn\'t been previously measured');
var height = this._measureItemHeight(i, firstShownItemIndex);
(0, _log["default"])('Height', height);
(0, _debug["default"])('Height', height);

@@ -233,3 +229,3 @@ this._set(i, height); // Update average item height calculation variables

if (previousHeight !== _height) {
(0, _log["default"])('Item', i, 'height has changed from', previousHeight, 'to', _height, 'while it was shown, and ".onItemHeightChange(i)" hasn\'t been called yet. This is not necessarily a bug, and could happen, for example, when there\'re several `onItemHeightChange(i)` calls issued at the same time.');
(0, _debug["default"])('Item', i, 'height has changed from', previousHeight, 'to', _height, 'while it was shown, and ".onItemHeightChange(i)" hasn\'t been called yet. This is not necessarily a bug, and could happen, for example, when there\'re several `onItemHeightChange(i)` calls issued at the same time.');
}

@@ -325,12 +321,2 @@ }

}, {
key: "_get",
value: function _get(i) {
return this.getState().itemHeights[i];
}
}, {
key: "_set",
value: function _set(i, height) {
this.getState().itemHeights[i] = height;
}
}, {
key: "onPrepend",

@@ -337,0 +323,0 @@ value: function onPrepend(count) {

'use strict'
exports = module.exports = require('../commonjs/DOMVirtualScroller').default
exports['default'] = require('../commonjs/DOMVirtualScroller').default
exports = module.exports = require('../commonjs/DOM/VirtualScroller').default
exports['default'] = require('../commonjs/DOM/VirtualScroller').default

@@ -1,1 +0,1 @@

export { default } from '../modules/DOMVirtualScroller'
export { default } from '../modules/DOM/VirtualScroller'
{
"private": true,
"name": "virtual-scroller-dom",
"version": "1.0.0",
"name": "virtual-scroller/dom",
"main": "index.commonjs.js",

@@ -6,0 +5,0 @@ "module": "index.js",

@@ -7,3 +7,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

import log, { isDebug, reportError } from './log';
import log, { isDebug, reportError } from './utility/debug';

@@ -13,3 +13,3 @@ var ItemHeights =

function () {
function ItemHeights(screen, getContainerElement, getState) {
function ItemHeights(screen, getContainerElement, getItemHeight, setItemHeight) {
_classCallCheck(this, ItemHeights);

@@ -19,16 +19,8 @@

this.getContainerElement = getContainerElement;
this.getState = getState;
this.initialize();
this._get = getItemHeight;
this._set = setItemHeight;
this.reset();
}
_createClass(ItemHeights, [{
key: "initialize",
value: function initialize() {
this.reset();
if (this.getState()) {
this.initializeFromState(this.getState());
}
}
}, {
key: "reset",

@@ -59,5 +51,4 @@ value: function reset() {

}, {
key: "initializeFromState",
value: function initializeFromState(_ref) {
var itemHeights = _ref.itemHeights;
key: "initialize",
value: function initialize(itemHeights) {
var i = 0;

@@ -117,3 +108,6 @@

value: function measureNonPreviouslyMeasuredItemHeights(firstShownItemIndex, lastShownItemIndex) {
// Reset `this.measuredItemsHeight` if it's not a "continuous" measured items list:
// If no items are rendered, don't measure anything.
if (firstShownItemIndex === undefined) {
return;
} // Reset `this.measuredItemsHeight` if it's not a "continuous" measured items list:
// if a group of items has been measured previously, and now it has rendered a completely

@@ -123,2 +117,4 @@ // different group of items, and there's a non-measured "gap" between those two groups,

// For example, this could happen when `.setItems()` prepends a lot of new items.
if (this.firstMeasuredItemIndex !== undefined) {

@@ -314,12 +310,2 @@ if (firstShownItemIndex > this.lastMeasuredItemIndex + 1 || lastShownItemIndex < this.firstMeasuredItemIndex - 1) {

}, {
key: "_get",
value: function _get(i) {
return this.getState().itemHeights[i];
}
}, {
key: "_set",
value: function _set(i, height) {
this.getState().itemHeights[i] = height;
}
}, {
key: "onPrepend",

@@ -326,0 +312,0 @@ value: function onPrepend(count) {

{
"name": "virtual-scroller",
"version": "1.7.3",
"version": "1.7.4",
"description": "A component for efficiently rendering large lists of variable height items",

@@ -5,0 +5,0 @@ "main": "index.commonjs.js",

'use strict'
exports = module.exports = require('../commonjs/ReactVirtualScroller').default
exports['default'] = require('../commonjs/ReactVirtualScroller').default
exports = module.exports = require('../commonjs/react/VirtualScroller').default
exports['default'] = require('../commonjs/react/VirtualScroller').default

@@ -1,1 +0,1 @@

export { default } from '../modules/ReactVirtualScroller'
export { default } from '../modules/react/VirtualScroller'
{
"private": true,
"name": "virtual-scroller-react",
"version": "1.0.0",
"name": "virtual-scroller/react",
"main": "index.commonjs.js",

@@ -6,0 +5,0 @@ "module": "index.js",

# VirtualScroller
An open-source implementation of Twitter's [`VirtualScroller`](https://medium.com/@paularmstrong/twitter-lite-and-high-performance-react-progressive-web-apps-at-scale-d28a00e780a3) component: a component for efficiently rendering large lists of *variable height* items. Automatically measures items as they're rendered and supports items of variable height. Also includes a [React](#react) component for those who're using React.
A universal open-source implementation of Twitter's [`VirtualScroller`](https://medium.com/@paularmstrong/twitter-lite-and-high-performance-react-progressive-web-apps-at-scale-d28a00e780a3) component: a component for efficiently rendering large lists of *variable height* items. Automatically measures items as they're rendered and supports items of variable/dynamic height. Also includes a [React](#react) component for those who're using React. Also provides a low-level component that supports any type of [rendering engine](#rendering-engine), not just DOM.

@@ -40,7 +40,7 @@ ## Demo

It works by measuring each list item's height as it's being rendered and then as the user scrolls it hides the items which are no longer visible and shows the now-visible items as they're scrolled to. The hidden items on top are compensated by setting `padding-top` on the container, and the hidden items on the bottom are compensated by setting `padding-bottom` on the container. The component listens to `scroll` / `resize` events and re-renders the currently visible items as the user scrolls (or if the browser window is resized).
`VirtualScroller` works by measuring each list item's height as it's being rendered, and then, as the user scrolls, it hides the items that are no longer visible, and shows the now-visible items as they're scrolled to. The hidden items at the top are compensated by setting `padding-top` on the list element, and the hidden items at the bottom are compensated by setting `padding-bottom` on the list element. The component listens to `scroll` / `resize` events and re-renders the currently visible items as the user scrolls (or if the browser window is resized).
Go to the [demo](https://catamphetamine.gitlab.io/virtual-scroller) page, open Developer Tools ("Elements" tab), find `<div id="root"/>` element, expand it, see `<div id="messages"/>` element, expand it and observe the changes to it while scrolling the page.
To observe list item elements being dynamically mounted and unmounted, go to the [demo](https://catamphetamine.gitlab.io/virtual-scroller) page, open Developer Tools ("Elements" tab), find `<div id="root"/>` element, expand it, see `<div id="messages"/>` element, expand it and observe the changes to it while scrolling the page.
List items can also have inter-item spacing via `margin-top` / `margin-bottom` or `border-top` / `border-bottom`, see the [Gotchas](#gotchas) section for more details on how to do that properly.
To add some inter-item spacing, one could use `margin-top` / `margin-bottom` or `border-top` / `border-bottom`: see the [Gotchas](#gotchas) section for more details on how to do that properly.

@@ -57,24 +57,15 @@ ## Install

The default export is the low-level `VirtualScroller` class: it implements the core logic of a `VirtualScroller` component and can be used for building a `VirtualScroller` component for any UI framework. Hence, it's not meant to be used in applications directly: instead, see the high-level components exported from [`virtual-scroller/dom`](#dom) and [`virtual-scroller/react`](#react) packages.
The default export is a low-level `VirtualScroller` class: it implements the core logic of a `VirtualScroller` component and can be used for building a `VirtualScroller` component for any UI framework or even any [rendering engine](#rendering-engine) other than DOM. Hence, the core component is not meant to be used in applications directly: instead, use the high-level components exported from [`virtual-scroller/dom`](#dom) or [`virtual-scroller/react`](#react) packages.
```js
import VirtualScroller from 'virtual-scroller'
#### State
const virtualScroller = new VirtualScroller(getContainerElement, items, options)
The core `VirtualScroller` component works by dynamically updating its `state` as the user scrolls the page. The `state` provides the calculations on which items should be rendered (and which should not) depending on the current scroll position. A high-level wrapper around `VirtualScroller` supplies a function that renders the actual list using the information from the `state`.
// Start listening to scroll events.
virtualScroller.listen()
<details>
<summary>Show the list of all <code>state</code> properties</summary>
// Stop listening to scroll events.
virtualScroller.stop()
```
#####
* `getContainerElement()` function returns a "container" DOM Element where the list will be rendered.
* `items` is the list of items.
* `options` is the list of options.
A high-level wrapper should supply either `getState`/`setState` functions, or `onStateChange` function (or both of them), and those functions are gonna be responsible for rendering the actual list using the information from `state`.
### State
`VirtualScroller` works by updating its `state` as the user scrolls the page. The `state` provides the calculations on which items should be rendered depending on the scroll position. `VirtualScroller` itself doesn't perform any rendering: a developer must either supply `getState`/`setState` options or `onStateChange` option (or both), and those functions are gonna be the ones actually rendering the list based on the `VirtualScroller` `state`.
The main `state` properties are:

@@ -103,10 +94,39 @@

* `scrollY: number?` — The current page scroll position (page vertical scroll offset). If initial `state` is passed to `VirtualScroller`, then the page will be scrolled to `state.scrollY` on `.render()`.
</details>
### Example
#### Example
Here's an example of implementing [`virtual-scroller/dom`](#dom) on top of the low-level `VirtualScroller` class _(advanced)_:
<details>
<summary>A general idea of using the low-level <code>VirtualScroller</code> class.</summary>
#####
```js
import VirtualScroller from 'virtual-scroller'
const virtualScroller = new VirtualScroller(getContainerElement, items, options)
// Start listening to scroll events.
virtualScroller.listen()
// Stop listening to scroll events.
virtualScroller.stop()
```
* `getContainerElement()` function returns the list "element" that is gonna contain all list item "elements".
* `items` is the list of items.
* `options` is the list of options.
</details>
#####
<details>
<summary>An example of implementing a high-level <code>virtual-scroller/dom</code> component on top of the low-level <code>VirtualScroller</code> class.
</summary>
#####
```js
import VirtualScroller from 'virtual-scroller'
const items = [

@@ -194,7 +214,11 @@ { title: 'Apple' },

```
</details>
### Options
#### Options
Available `VirtualScroller` `options`:
<details>
<summary>Show the list of all available core <code>VirtualScroller</code> <code>options</code>.</summary>
#####
* `estimatedItemHeight: number` — Is used for the initial render of the list: determines how many list items are rendered initially to cover the screen height plus some extra vertical margin for future scrolling. If not set then the list first renders just the first item, measures it, and then assumes it to be the `estimatedItemHeight` from which it calculates how many items to show on the second render pass to fill the screen height plus some extra vertical margin for future scrolling. Therefore, this setting is only for the initial render minor optimization and is not required.

@@ -231,5 +255,11 @@

* `getColumnsCount(container: ScrollableContainer): number` — (advanced) Provides support for ["grid"](#grid-layout) layout. The `container` argument provides a `.getWidth()` method.
</details>
`VirtualScroller` class instance provides methods:
#####
<details>
<summary>Show the list of all available core <code>VirtualScroller</code> instance methods.</summary>
#####
* `listen()` — Starts `VirtualScroller` listening for scroll events. Should be called immediately after the list has been rendered on a page.

@@ -250,10 +280,13 @@

* `getItemCoordinates(i: number): object` — Returns coordinates of item with index `i` relative to the document: `top` is the top offset of the item relative to the start of the document, `bottom` is the top offset of the item's bottom edge relative to the start of the document, `height` is the item's height.
<!-- * `getItemCoordinates(i: number): object` — Returns coordinates of item with index `i` relative to the "scrollable container": `top` is the top offset of the item relative to the start of the "scrollable container", `bottom` is the top offset of the item's bottom edge relative to the start of the "scrollable container", `height` is the item's height. -->
* `updateLayout()` — (advanced) Triggers a re-layout of `VirtualScroller`. It's what's called every time on page scroll or window resize. You most likely won't ever need to call this method manually. Still, it can be called manually when the list's top position changes not as a result of scrolling the page or resizing the window. For example, if some DOM elements above the list are removed (like a closeable "info" panel) or collapsed (like an "accordion" panel), then the list's top position changes, which means that now some of the previoulsy shown items might go off screen, and the user might be seeing a blank area where items haven't been rendered yet because they were off-screen during the previous `VirtualScroller` layout. `VirtualScroller` automatically performs a layout only on page scroll or window resize; in all other cases, when layout needs to be re-run, call it manually via this instance method.
</details>
## DOM
This is an example of using `virtual-scroller/dom` component. It's the source code of the [DOM demo](https://catamphetamine.gitlab.io/virtual-scroller/index-dom.html).
`virtual-scroller/dom` component implements a `VirtualScroller` in a standard [Document Object Model](https://en.wikipedia.org/wiki/Document_Object_Model) environment (a web browser).
Here's an example of using `virtual-scroller/dom` component (it's basically the source code for the [DOM demo](https://catamphetamine.gitlab.io/virtual-scroller/index-dom.html)).
```js

@@ -301,3 +334,7 @@ import VirtualScroller from 'virtual-scroller/dom'

```
<details>
<summary>Show the list of DOM <code>VirtualScroller</code> arguments and options.</summary>
#####
DOM `VirtualScroller` constructor takes arguments:

@@ -315,15 +352,28 @@

* `onItemUnmount(itemElement)` — Is called after a `VirtualScroller` item DOM `Element` is unmounted. Can be used to add DOM `Element` ["pooling"](https://github.com/ChrisAntaki/dom-pool#what-performance-gains-can-i-expect).
</details>
DOM `VirtualScroller` instance provides methods:
#####
<details>
<summary>Show the list of DOM <code>VirtualScroller</code> instance methods.</summary>
#####
* `setItems(items, options)` — A proxy for the corresponding `VirtualScroller` method.
* `onItemHeightChange(i)` — A proxy for the corresponding `VirtualScroller` method.
* `onItemStateChange(i, itemState)` — A proxy for the corresponding `VirtualScroller` method.
* `getItemCoordinates(i)` — A proxy for the corresponding `VirtualScroller` method.
<!-- * `getItemCoordinates(i)` — A proxy for the corresponding `VirtualScroller` method. -->
* `stop()` — A proxy for the corresponding `VirtualScroller` method.
</details>
## React
This is an example of using the React `virtual-scroller/react` component. It's the source code of the [React demo](https://catamphetamine.gitlab.io/virtual-scroller).
`virtual-scroller/react` component implements a `VirtualScroller` in a [React](https://reactjs.org/) environment.
Here's an example of using `virtual-scroller/react` component (it's basically the source code for the [React demo](https://catamphetamine.gitlab.io/virtual-scroller)).
```js

@@ -378,20 +428,39 @@ import React from 'react'

React `<VirtualScroller/>` component receives properties:
<details>
<summary>Show the list of React <code>&lt;VirtualScroller/&gt;</code> properties.</summary>
#####
* `items` — The items list.
* `itemComponent` — List item component. Receives the list item as the `children` property. Can optionally receive `state` and `onSaveState()` properties for saving list item state before unmounting it and then restoring that state after the item is re-mounted (for example, this supports "Show more" buttons, "Expand YouTube video" buttons, etc). For best performance, make sure it's a `React.PureComponent` or a `React.memo()`, otherwise it'll be re-rendering as the user scrolls.
* `itemComponentProps: object` — (optional) The props passed to `itemComponent`.
* `as` — A component used as a container for the list items. Is `"div"` by default.
* `estimatedItemHeight: number` — (optional) The `estimatedItemHeight` option of `VirtualScroller` class.
* `bypass: boolean` — (optional) The `bypass` option of `VirtualScroller` class.
* `preserveScrollPositionOnPrependItems: boolean` — (optional) The `preserveScrollPositionOnPrependItems` option of `VirtualScroller.setItems()` method.
* `preserveScrollPositionOfTheBottomOfTheListOnMount: boolean` — (optional) The `preserveScrollPositionOfTheBottomOfTheListOnMount` option of `VirtualScroller`.
* `measureItemsBatchSize: number` — (optional) The `measureItemsBatchSize` option of `VirtualScroller`.
* `getColumnsCount(): number` — (optional) The `getColumnsCount()` option of `VirtualScroller`.
<!-- * `onMount()` — (optional) Is called after `<VirtualScroller/>` component has been mounted and before `VirtualScroller.onMount()` is called. -->
* `getItemId(item): any` — (optional) The `getItemId` option of `VirtualScroller` class. The React component also uses it as a source for a React `key` for rendering an `item`. If `getItemId()` is not supplied, then item `key`s are autogenerated from a random-generated prefix (that changes every time `items` are updated) and an `item` index. Can be used to prevent `<VirtualScroller/>` from re-rendering all visible items every time `items` property is updated.
* `onItemInitialRender(item)` — (optional) The `onItemInitialRender` option of `VirtualScroller` class.
* `shouldUpdateLayoutOnScreenResize(event)` — (optional) The `shouldUpdateLayoutOnScreenResize` option of `VirtualScroller` class.
* `initialState: object` — (optional) The initial state for `VirtualScroller`: the `state` option of `VirtualScroller`. For example, can be used to quicky restore the list on "Back" navigation.
* `initialCustomState: object` — (advanced) (optional) The initial "custom" state for `VirtualScroller`: the `customState` option of `VirtualScroller`. It can be used to initialize the "custom" part of `VirtualScroller` state in cases when `VirtualScroller` state is used to store some "custom" list state.
* `onStateChange(newState: object, prevState: object)` — (optional) Is called whenever `VirtualScroller` `state` is updated (including setting the initial `state`). For example, can be used to keep `VirtualScroller` `state` copy in an instance variable and later in `componentWillUnmount()` persist it somewhere in global application state for quickly restoring it later on "Back" navigation:

@@ -420,27 +489,75 @@

```
</details>
`itemComponent` receives properties:
#####
<details>
<summary>Show the list of properties passed to <code>itemComponent</code>.</summary>
#####
* `children` — The item.
* `state` — Item's state. Can be used for storing and then restoring the state of components which are about to be shown again after being previously hidden. For example, consider a post with an "Expand YouTube Video" button. If a user clicks the button the post is expanded and its height changes. Then the user scrolls down until the post is no longer visible and so it's no longer rendered. Then the user scrolls back up and the post is visible again and so it's rendered again. If the "Expand YouTube Video" state wasn't preserved then the list items would "jump" for the expanded minus non-expanded height difference. To avoid that, some `{ videoExpanded: true }` `state` could be passed to the post component which would make it auto-expand the video on mount and so the list items wouldn't "jump". For that, `onStateChange({ videoExpanded: true })` would have to be called when the user clicks the "Expand YouTube Video" button.
* `onStateChange(itemState)` — A proxy for `VirtualScroller.onItemStateChange(i, itemState)`. Call this function to update item's `state`.
* `onHeightChange()` — A proxy for `VirtualScroller.onItemHeightChange(i)`. Call this function to re-measure the item if it shrinks in height.
</details>
React `<VirtualScroller/>` component instance provides methods:
#####
<details>
<summary>Show the list of React <code>&lt;VirtualScroller/&gt;</code> instance methods.</summary>
#####
* `renderItem(i)` — Calls `.forceUpdate()` on the `itemComponent` instance for the item with index `i`. Does nothing if the item isn't currently rendered. Is only supported for `itemComponent`s that are `React.Component`s. The `i` item index argument could be replaced with the item object itself, in which case `<VirtualScroller/>` will find the index of the item by itself.
* `getItemCoordinates(i)` — A proxy for the corresponding `VirtualScroller` method.
<!-- * `getItemCoordinates(i)` — A proxy for the corresponding `VirtualScroller` method. -->
* `updateLayout()` — A proxy for the corresponding `VirtualScroller` method.
</details>
## Rendering Engine
`VirtualScroller` is written in such a way that it supports any type of a rendering engine, not just DOM. For example, it could support something like React Native or `<canvas/>`: for that, someone would have to write custom versions of [`Screen.js`](https://gitlab.com/catamphetamine/virtual-scroller/-/blob/master/source/DOM/Screen.js) and [`ScrollableContainer.js`](https://gitlab.com/catamphetamine/virtual-scroller/-/blob/master/source/DOM/ScrollableContainer.js), and then instruct `VirtualScroller` to use those instead of the default ones by passing custom `renderingEngine` configuration when constructing a `VirtualScroller` instance:
```js
import VirtualScroller from 'virtual-scroller'
import Screen from './Screen'
import ScrollableContainer from './ScrollableContainer'
new VirtualScroller(getContainerElement, {
scrollableContainer,
renderingEngine: {
name: 'Non-DOM Rendering Engine',
createScreen() {
return new Screen()
},
createScrollableContainer(scrollableContainer) {
return new ScrollableContainer(scrollableContainer)
}
},
...
})
```
`getContainerElement()` function would simply return a list "element", whatever that could mean. The concept of an "element" is "something, that can be rendered", so it could be anything, not just a DOM Element. Any operations with "elements" are done either in `Screen.js` or in `ScrollableContainer.js`: `Screen.js` defines the operations that could be applied to an "element", such as getting its height or getting its child elements' heights, and `ScrollableContainer.js` defines the operations that could be applied to a "scrollable container", such as getting its dimensions, listening for "resize" and "scroll" events, controlling scroll position, etc.
## Dynamically Loaded Lists
All previous examples described cases with a static `items` list. When there's a need to update the `items` list, one could use `virtualScroller.setItems(newItems)` instance method. For example, when the user clicks "Show previous items" button, the `newItems` should be set to `previousItems.concat(currentlyShownItems)`, and when the user clicks "Show next items" button, the `newItems` should be set to `currentlyShownItems.concat(nextItems)`.
All previous examples described cases with a static `items` list. When there's a need to update the `items` list dynamically, one can use `virtualScroller.setItems(newItems)` instance method. For example, when the user clicks "Show previous items" button, the `newItems` should be `previousItems.concat(currentlyShownItems)`, and when the user clicks "Show next items" button, the `newItems` should be `currentlyShownItems.concat(nextItems)`.
When using `virtual-scroller/dom` component, a developer should call `.setItems(newItems)` instance method in order to update the items.
<details>
<summary>Find out what are "incremental" and "non-incremental" items updates, and why "incremental" updates are better.</summary>
#####
When using `virtual-scroller/dom` component, a developer should call `.setItems(newItems)` instance method in order to update items.
When using `virtual-scroller/react` React component, it calls `.setItems(newItems)` method automatically when new `items` property is passed.
The basic equality check (`===`) is used to intelligently compare `newItems` to the existing `items`. If a simple append and/or prepend operation is detected, then the list seamlessly transitions from the current state to the new state, preserving its state and scroll position. If, however, the items have been updated in such a way that it's not a simple append and/or prepend operation, then the entire list is rerendered from scratch, losing its state and resetting the scroll position. There're valid use cases for both situations.
The basic equality check (`===`) is used to intelligently compare `newItems` to the existing `items`. If `getItemId()` parameter is passed, then items are compared by their ids rather than by themselves. If a simple append and/or prepend operation is detected, then the update is an "incremental" one, and the list seamlessly transitions from the current state to the new state, preserving its state and scroll position. If, however, the items have been updated in such a way that it's not a simple append and/or prepend operation, then such update is a "non-incremental" one, and the entire list is rerendered from scratch, losing its state and resetting the scroll position. There're valid use cases for both situations.

@@ -458,2 +575,3 @@ For example, suppose a user navigates to a page where a list of `items: object[]` is shown using a `VirtualScroller`. When a user scrolls down to the last item in the list, a developer might want to query the database for the newly added items, and then show those new items to the user. In that case, the developer could send a query to the API with `afterId: number` parameter being the `id: number` of the last item in the list, and the API would then return a list of the `newItems: object[]` whose `id: number` is greater than the `afterId: number` parameter. Then, the developer would append the `newItems: object[]` to the `items: object[]`, and then call `VirtualScroller.setItems()` with the updated `items: object[]`, resulting in a "seamless" update of the list, preserving its state and scroll position.

For implementing "infinite scroll" lists, a developer could also use [`on-scroll-to`](https://gitlab.com/catamphetamine/on-scroll-to) component.
</details>

@@ -545,4 +663,9 @@ ## Grid Layout

### Only the first item is rendered on page load.
### If only the first item is rendered on page load in dev mode.
<details>
<summary>See the description of this very rare dev mode bug.</summary>
#####
`VirtualScroller` calculates the shown item indexes when its `.onMount()` method is called, but if the page styles are applied after `VirtualScroller` is mounted (for example, if styles are applied via javascript, like Webpack does it in dev mode with its `style-loader`) then the list might not render correctly and will only show the first item. The reason for that is because calling `.getBoundingClientRect()` on the list container DOM element on mount returns "incorrect" `top` position because the styles haven't been applied yet, and so `VirtualScroller` thinks it's offscreen.

@@ -562,2 +685,3 @@

This type of a bug doesn't occur in production, but it can appear in development mode when using Webpack. The workaround `VirtualScroller` implements for such cases is calling `.getBoundingClientRect()` on the list container DOM element periodically (every second) to check if the `top` coordinate has changed as a result of CSS being applied: if it has then it recalculates the shown item indexes and re-renders.
</details>

@@ -564,0 +688,0 @@ ## Debug

@@ -1,16 +0,10 @@

import log, { isDebug, reportError } from './log'
import log, { isDebug, reportError } from './utility/debug'
export default class ItemHeights {
constructor(screen, getContainerElement, getState) {
constructor(screen, getContainerElement, getItemHeight, setItemHeight) {
this.screen = screen
this.getContainerElement = getContainerElement
this.getState = getState
this.initialize()
}
initialize() {
this._get = getItemHeight
this._set = setItemHeight
this.reset()
if (this.getState()) {
this.initializeFromState(this.getState())
}
}

@@ -41,3 +35,3 @@

*/
initializeFromState({ itemHeights }) {
initialize(itemHeights) {
let i = 0

@@ -90,2 +84,6 @@ while (i < itemHeights.length) {

measureNonPreviouslyMeasuredItemHeights(firstShownItemIndex, lastShownItemIndex) {
// If no items are rendered, don't measure anything.
if (firstShownItemIndex === undefined) {
return
}
// Reset `this.measuredItemsHeight` if it's not a "continuous" measured items list:

@@ -268,10 +266,2 @@ // if a group of items has been measured previously, and now it has rendered a completely

_get(i) {
return this.getState().itemHeights[i]
}
_set(i, height) {
this.getState().itemHeights[i] = height
}
onPrepend(count) {

@@ -278,0 +268,0 @@ if (this.firstMeasuredItemIndex !== undefined) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc