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.5 to 1.7.6

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 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}(),U={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 _(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 N=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:U.TOP_OFFSET_CHANGED}),Date.now()-t<D&&(e.watchListTopOffsetTimer=f(n,j)))}()}}])&&_(t.prototype,n),i&&_(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:U.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:U.SCROLL});else{if(n.isImmediateLayoutScheduled())return;n.onUserStopsScrollingTimer=f(function(){n.onUserStopsScrollingTimer=void 0,n.updateLayout({reason:U.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:"measureItemHeights",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=U.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=U.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:U.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}),x&&this.itemHeights.initialize(x.itemHeights),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=U.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 N({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:U.MOUNT})}},{key:"onRenderedNewLayout",value:function(){var e,t,n;this.measureVerticalSpacing(),this.itemHeights.measureItemHeights(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:U.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}()});
!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 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 H(e,t,n){return t&&x(e.prototype,t),n&&x(e,n),e}var O=function(){function e(t){T(this,e),this.element=t}return H(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),H(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(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,A(["[virtual-scroller]"].concat(n)))}}function M(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).warn.apply(e,A(["[virtual-scroller]"].concat(n)))}function P(){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 V(){if("undefined"!=typeof window)return!0===window.VirtualScrollerDebug||"debug"===window.VirtualScrollerDebug}function B(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,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}}])&&B(t.prototype,n),i&&B(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 j=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<z&&(e.watchListTopOffsetTimer=f(n,D)))}()}}])&&N(t.prototype,n),i&&N(t,i),e}(),D=500,z=3e3;function F(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(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=G,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()}}])&&F(t.prototype,n),i&&F(t,i),e}(),G=250;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}var Z=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),q(this,"updateScrollPosition",function(){n.onScrollPositionChange(n.getScrollY())}),q(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})},J)}}),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()}}}])&&W(t.prototype,n),i&&W(t,i),e}(),J=100;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 Q=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}}])&&K(t.prototype,n),i&&K(t,i),e}();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)}}var $=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:"measureItemHeights",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&&M("Item",s,"height was",l,"before it was hidden, but, after showing it again, its height is",u,". Perhaps you forgot to persist the item's state by calling `onItemStateChange(i, newState)` when it changed, and that state got lost when the item element was unmounted, which resulted in a different height when the item was shown again, but with the missing state.")}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)}}])&&X(t.prototype,n),i&&X(t,i),e}();function ee(e){return(ee="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 te=Object.prototype.hasOwnProperty;function ne(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function ie(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){oe(e,t,n[t])})}return e}function re(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 oe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var se=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),oe(this,"getListTopOffsetInsideScrollableContainer",function(){var e=i.scrollableContainer.getTopOffset(i.getContainerElement());return i.waitForStylesToLoad.onGotListTopOffset(e),e}),oe(this,"willUpdateState",function(e,t){}),oe(this,"didUpdateState",function(e){var t=i.getState();if(i.onStateChange&&(function(e,t){if(ne(e,t))return!0;if("object"!==ee(e)||null===e||"object"!==ee(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(!te.call(t,n[r])||!ne(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}}),oe(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;if(i.restoreScroll.shouldRestoreScrollAfterRender()&&(o<i.restoreScroll.getAnchorItemIndex()&&(o=i.restoreScroll.getAnchorItemIndex()),s=!1),!i.validateWillBeHiddenItemHeightsAreAccurate(r,o))return R("~ Some of the will-be-hidden item heights have changed since they've last been measured. Redo layout. ~"),i.updateShownItemIndexes();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()),V()&&(R("Item heights",i.getState().itemHeights.slice()),R("Item states",i.getState().itemStates.slice())),s&&(i.redoLayoutReason=_.ITEM_HEIGHT_NOT_MEASURED),i.onBeforeShowItems(i.getState().items,i.getState().itemHeights,r,o),i.setState({firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:a,afterItemsHeight:l})}),oe(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())}),oe(this,"updateLayout",function(){return i.onUpdateShownItemIndexes({reason:_.MANUAL})}),oe(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,x=r.scrollableContainer,H=r.state,O=r.renderingEngine;if(R("~ Initialize ~"),H&&(n=H.items),!x&&f&&(x=f()),O||(O=E),this.screen=O.createScreen(),this.scrollableContainer=O.createScrollableContainer(x),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 ~"),P(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){M("`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=ie({},t,e);i.willUpdateState(n,t),i.state=n,i.didUpdateState(t)}),H&&R("Initial state (passed)",H),this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new $(this.screen,this.getContainerElement,function(e){return i.getState().itemHeights[e]},function(e,t){return i.getState().itemHeights[e]=t}),H&&this.itemHeights.initialize(H.itemHeights),this.layout=new U({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 Y({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&&M("`preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),this.preserveScrollPositionOfTheBottomOfTheListOnMount=h||u,this.scroll=new Z({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 Q({screen:this.screen,getContainerElement:this.getContainerElement}),this.waitForStylesToLoad=new j({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=ie({},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(){M("`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){M("`.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.measureItemHeights(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(){M("`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){M("`.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){V()&&(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 P('"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.");R("Previous height",t),R("New height",n),t!==n&&(R("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:_.ITEM_HEIGHT_CHANGED}))}},{key:"validateWillBeHiddenItemHeightsAreAccurate",value:function(e,t){for(var n=!0,i=this.getState().firstShownItemIndex;i<=this.getState().lastShownItemIndex;){if(i>=e&&i<=t);else{var r=this.getState().itemHeights[i],o=this.remeasureItemHeight(i);o!==r&&(n=!1,M("Item",i,"will be unmounted at next render. Its height has changed from",r,"to",o,"since it was last measured. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed."))}i++}return 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(ie({},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)}}])&&re(t.prototype,n),i&&re(t,i),e}();function ae(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 le(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 ue(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),ue(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++}}),ue(this,"onUnmount",function(){M("`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),ue(this,"destroy",function(){M("`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),ue(this,"stop",function(){r.virtualScroller.stop()}),this.container=t,this.renderItem=i;var s=o.onMount,a=o.onItemUnmount,l=ae(o,["onMount","onItemUnmount"]);this.onItemUnmount=a,this.tbody="TBODY"===this.container.tagName,this.virtualScroller=new se(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){ue(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)}}])&&le(t.prototype,n),i&&le(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,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 R(e,t,n){return t&&x(e.prototype,t),n&&x(e,n),e}var P=function(){function e(t){H(this,e),this.element=t}return R(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,P),R(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 P(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:"measureItemHeights",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}),H&&this.itemHeights.initialize(H.itemHeights),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.measureItemHeights(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});
!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 y(e){return e.toFixed(2)+"px"}var v="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 w(e){return(w="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 C(e,t){return!t||"object"!==w(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 R(e,t,n){return t&&x(e.prototype,t),n&&x(e,n),e}var P=function(){function e(t){H(this,e),this.element=t}return R(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),C(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,P),R(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 A={name:"DOM",createScreen:function(){return new b},createScrollableContainer:function(e){return e?new P(e):"undefined"!=typeof window?new L:void 0}};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 E(){if(_()){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 B(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).warn.apply(e,M(["[virtual-scroller]"].concat(n)))}function V(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(E.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 _(){if("undefined"!=typeof window)return!0===window.VirtualScrollerDebug||"debug"===window.VirtualScrollerDebug}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 j=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){E("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&&(E("First shown row index",u),r=u*s),n+a+c+h>t)return E("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&&E("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;E("The entire list is off-screen. No items are visible.")}else E("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}}])&&U(t.prototype,n),i&&U(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 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 D=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:N.TOP_OFFSET_CHANGED}),Date.now()-t<Y&&(e.watchListTopOffsetTimer=p(n,F)))}()}}])&&z(t.prototype,n),i&&z(t,i),e}(),F=500,Y=3e3;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 W=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:N.RESIZE})}else l.resetStateAndLayout()}},s=G,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()}}])&&q(t.prototype,n),i&&q(t,i),e}(),G=250;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)}}function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=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),J(this,"updateScrollPosition",function(){n.onScrollPositionChange(n.getScrollY())}),J(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(E(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=p(function(){n.onUserStopsScrollingTimer=void 0,n.updateLayout({reason:N.STOPPED_SCROLLING})},Q)}}),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()}}}])&&K(t.prototype,n),i&&K(t,i),e}(),Q=100;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)}}var $=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}}])&&X(t.prototype,n),i&&X(t,i),e}();function ee(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 te=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:"measureItemHeights",value:function(e,t){if(void 0!==e){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(E("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),E("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);E("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&&B("Item",s,"height was",l,"before it was hidden, but, after showing it again, its height is",u,". Perhaps you forgot to persist the item's state by calling `onItemStateChange(i, newState)` when it changed, and that state got lost when the item element was unmounted, which resulted in a different height when the item was shown again, but with the missing state.")}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)}}])&&ee(t.prototype,n),i&&ee(t,i),e}();function ne(e){return(ne="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 ie=Object.prototype.hasOwnProperty;function re(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function oe(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){ae(e,t,n[t])})}return e}function se(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 ae(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=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),ae(this,"getListTopOffsetInsideScrollableContainer",function(){var e=i.scrollableContainer.getTopOffset(i.getContainerElement());return i.waitForStylesToLoad.onGotListTopOffset(e),e}),ae(this,"willUpdateState",function(e,t){}),ae(this,"didUpdateState",function(e){var t=i.getState();if(i.onStateChange&&(function(e,t){if(re(e,t))return!0;if("object"!==ne(e)||null===e||"object"!==ne(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(!ie.call(t,n[r])||!re(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||i.onStateChange(t,e)),e&&i.isRendered){E("~ 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,E("~ Restore Scroll Position ~");var u=i.restoreScroll.getScrollDifference();u?(E("Scroll down by",u),i.scroll.scrollByY(u)):E("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}}),ae(this,"updateShownItemIndexes",function(){E("~ 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;if(i.restoreScroll.shouldRestoreScrollAfterRender()&&(o<i.restoreScroll.getAnchorItemIndex()&&(o=i.restoreScroll.getAnchorItemIndex()),s=!1),!i.validateWillBeHiddenItemHeightsAreAccurate(r,o))return E("~ Some of the will-be-hidden item heights have changed since they've last been measured. Redo layout. ~"),i.updateShownItemIndexes();var a=i.layout.getBeforeItemsHeight(r,o),l=i.layout.getAfterItemsHeight(r,o,i.getItemsCount());i._getColumnsCount&&E("Columns count",i.getColumnsCount()),E("First shown item index",r),E("Last shown item index",o),E("Before items height",a),E("After items height (actual or estimated)",l),E("Average item height (calculated on previous render)",i.itemHeights.getAverage()),_()&&(E("Item heights",i.getState().itemHeights.slice()),E("Item states",i.getState().itemStates.slice())),s&&(i.redoLayoutReason=N.ITEM_HEIGHT_NOT_MEASURED),i.onBeforeShowItems(i.getState().items,i.getState().itemHeights,r,o),i.setState({firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:a,afterItemsHeight:l})}),ae(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;0!==i.getItemsCount()&&(i.scroll.onLayout(),i.layoutTimer&&(I(i.layoutTimer),i.layoutTimer=void 0),E("~ Calculate Layout (on ".concat(t,") ~")),i.updateShownItemIndexes())}),ae(this,"updateLayout",function(){return i.onUpdateShownItemIndexes({reason:N.MANUAL})}),ae(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,y=r.tbody,S=r._useTimeoutInRenderLoop,b=r.bypass,w=r.estimatedItemHeight,C=r.onItemInitialRender,O=r.onItemFirstRender,T=r.scrollableContainer,H=r.state,x=r.renderingEngine;if(E("~ Initialize ~"),H&&(n=H.items),!T&&d&&(T=d()),x||(x=A),this.screen=x.createScreen(),this.scrollableContainer=x.createScrollableContainer(T),y){if("DOM"!==x.name)throw new Error("`tbody` option is only supported for DOM rendering engine");E("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(E("~ <tbody/> not supported ~"),V(v),b=!0)}b&&E('~ "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,C?this.onItemInitialRender=C:O&&(this.onItemInitialRender=function(e){B("`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=i.getState().items.indexOf(e);t>=0&&O(t)}),E("Items count",n.length),w&&E("Estimated item height",w),s?(this.getState=o,this.setState=function(e){E("Set state",e),s(e,{willUpdateState:i.willUpdateState,didUpdateState:i.didUpdateState})}):(this.getState=function(){return i.state},this.setState=function(e){E("Set state",e);var t=i.getState(),n=oe({},t,e);i.willUpdateState(n,t),i.state=n,i.didUpdateState(t)}),H&&E("Initial state (passed)",H),this.getContainerElement=t,t()&&this.screen.clearElement(t()),this.itemHeights=new te(this.screen,this.getContainerElement,function(e){return i.getState().itemHeights[e]},function(e,t){return i.getState().itemHeights[e]=t}),H&&this.itemHeights.initialize(H.itemHeights),this.layout=new j({bypass:b,estimatedItemHeight:w,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 W({bypass:b,scrollableContainer:this.scrollableContainer,getContainerElement:this.getContainerElement,updateLayout:function(e){var t=e.reason;return i.onUpdateShownItemIndexes({reason:t})},resetStateAndLayout:function(){E("~ Scrollable container size changed, re-measure item heights. ~"),i.redoLayoutReason=N.RESIZE,i.layoutResetPending=!0,E("Reset state"),i.setState(i.getInitialLayoutState(i.newItemsPending||i.getState().items))}}),u&&B("`preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),this.preserveScrollPositionOfTheBottomOfTheListOnMount=h||u,this.scroll=new Z({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 $({screen:this.screen,getContainerElement:this.getContainerElement}),this.waitForStylesToLoad=new D({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=oe({},e,this.getInitialLayoutState(t),{items:t,itemStates:new Array(t.length)});return E("Initial state (autogenerated)",n),E("First shown item index",n.firstShownItemIndex),E("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(){B("`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){B("`.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");E("~ 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.measureItemHeights(this.getState().firstShownItemIndex,this.getState().lastShownItemIndex),this.tbody&&(e=this.getContainerElement(),t=this.getState().beforeItemsHeight,n=this.getState().afterItemsHeight,e.style.setProperty("--VirtualScroller-paddingTop",y(t)),e.style.setProperty("--VirtualScroller-paddingBottom",y(n)))}},{key:"getVisibleAreaBoundsIncludingMargins",value:function(){var e=this.scroll.getVisibleAreaBounds();return e.top-=this.getMargin(),e.bottom+=this.getMargin(),e}},{key:"onUnmount",value:function(){B("`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){B("`.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){E("~ 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?E("Not enough items rendered to measure vertical spacing"):(E("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){_()&&(E("~ Item state changed ~"),E("Item",e),E("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),E("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){E("~ Re-measure item height ~"),E("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return V('"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 B("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.");E("Previous height",t),E("New height",n),t!==n&&(E("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:N.ITEM_HEIGHT_CHANGED}))}},{key:"validateWillBeHiddenItemHeightsAreAccurate",value:function(e,t){for(var n=!0,i=this.getState().firstShownItemIndex;i<=this.getState().lastShownItemIndex;){if(i>=e&&i<=t);else{var r=this.getState().itemHeights[i],o=this.remeasureItemHeight(i);o!==r&&(n=!1,B("Item",i,"will be unmounted at next render. Its height has changed from",r,"to",o,"since it was last measured. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed."))}i++}return 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;E("~ 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&&(E("Prepend",u,"items"),s=new Array(u).concat(s),o&&(o=new Array(u).concat(o))),h>0&&(E("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 E("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."),E("Previous items",i),E("New items",e),s=new Array(e.length),o=new Array(e.length),t=this.getInitialLayoutValues({itemsCount:e.length});E("~ Update state ~"),E("First shown item index",t.firstShownItemIndex),E("Last shown item index",t.lastShownItemIndex),E("Before items height",t.beforeItemsHeight),E("After items height (actual or estimated)",t.afterItemsHeight),this.onBeforeShowItems(e,s,t.firstShownItemIndex,t.lastShownItemIndex),this.newItemsPending=e,this.setState(oe({},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)}}])&&se(t.prototype,n),i&&se(t,i),e}();function ue(){return(ue=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 he(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 ce(e){return(ce="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 me(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 fe(e){return(fe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function de(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function pe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ie=t.elementType||t.oneOfType([t.string,t.func,t.object]),ye=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=fe(n).call(this,t),i=!o||"object"!==ce(o)&&"function"!=typeof o?de(r):o,pe(de(i),"container",e.createRef()),pe(de(i),"onItemStateChange",new Array(i.props.items.length)),pe(de(i),"onItemHeightChange",new Array(i.props.items.length)),pe(de(i),"itemRefs",new Array(i.props.items.length)),pe(de(i),"itemKeyPrefixes",[]),pe(de(i),"updateLayout",function(){return i.virtualScroller.updateLayout()}),pe(de(i),"layout",function(){return i.updateLayout()}),pe(de(i),"onItemInitialRender",function(){var e=i.props.onItemInitialRender;e&&e.apply(void 0,arguments)}),pe(de(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&&ge(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 le(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 V("Item ".concat(JSON.stringify(e),' not found when calling ".renderItem()"'));if(this.shouldUseRefs()&&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"===ce(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=he(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,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 b=this.virtualScroller.getItemsDiff(S,v);if(b&&0===b.prependedItemsCount&&b.appendedItemsCount>0);else{if(b){var w=b.prependedItemsCount;w>0&&(s||a)&&0===d&&this.virtualScroller.restoreScroll.captureScroll({previousItems:S,newItems:v,prependedItemsCount:w})}l||this.generateItemKeyPrefix(),this.itemRefs=new Array(v.length)}}var C=this.virtualScroller.tbody;return e.createElement(i,ue({},h,{ref:this.container,className:C?u?u+" VirtualScroller":"VirtualScroller":u,style:{paddingTop:C?void 0:y(p),paddingBottom:C?void 0:y(I)}}),m.map(function(n,i){return i>=d&&i<=g?e.createElement(r,ue({},o,{key:t.getItemKey(n,i),ref:t.shouldUseRefs()?t.getItemRef(i):void 0,state:f&&f[i],onStateChange:t.getOnItemStateChange(i),onHeightChange:t.getOnItemHeightChange(i)}),n):null}))}}])&&me(i.prototype,r),o&&me(i,o),n}();return pe(ye,"propTypes",{as:Ie,items:t.arrayOf(t.object).isRequired,itemComponent:Ie.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})}),pe(ye,"defaultProps",{as:"div"}),ye});
//# 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 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:"measureItemHeights",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}),x&&this.itemHeights.initialize(x.itemHeights),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.measureItemHeights(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}()});
!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=A(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 A(e,{container:t.container})}}]),t}();function A(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 L(e):"undefined"!=typeof window?new O:void 0}};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 R(){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,k(["[virtual-scroller]"].concat(n)))}}function M(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).warn.apply(e,k(["[virtual-scroller]"].concat(n)))}function P(){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,k(["[virtual-scroller]"].concat(t)))}function V(){if("undefined"!=typeof window)return!0===window.VirtualScrollerDebug||"debug"===window.VirtualScrollerDebug}function B(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.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}}])&&B(t.prototype,n),i&&B(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 j=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<z&&(e.watchListTopOffsetTimer=f(n,D)))}()}}])&&U(t.prototype,n),i&&U(t,i),e}(),D=500,z=3e3;function F(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(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=G,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()}}])&&F(t.prototype,n),i&&F(t,i),e}(),G=250;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}var Z=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),q(this,"updateScrollPosition",function(){n.onScrollPositionChange(n.getScrollY())}),q(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})},J)}}),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()}}}])&&W(t.prototype,n),i&&W(t,i),e}(),J=100;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 Q=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}}])&&K(t.prototype,n),i&&K(t,i),e}();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)}}var $=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:"measureItemHeights",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&&M("Item",s,"height was",l,"before it was hidden, but, after showing it again, its height is",u,". Perhaps you forgot to persist the item's state by calling `onItemStateChange(i, newState)` when it changed, and that state got lost when the item element was unmounted, which resulted in a different height when the item was shown again, but with the missing state.")}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)}}])&&X(t.prototype,n),i&&X(t,i),e}();function ee(e){return(ee="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 te=Object.prototype.hasOwnProperty;function ne(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function ie(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){oe(e,t,n[t])})}return e}function re(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 oe(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),oe(this,"getListTopOffsetInsideScrollableContainer",function(){var e=i.scrollableContainer.getTopOffset(i.getContainerElement());return i.waitForStylesToLoad.onGotListTopOffset(e),e}),oe(this,"willUpdateState",function(e,t){}),oe(this,"didUpdateState",function(e){var t=i.getState();if(i.onStateChange&&(function(e,t){if(ne(e,t))return!0;if("object"!==ee(e)||null===e||"object"!==ee(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(!te.call(t,n[r])||!ne(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}}),oe(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;if(i.restoreScroll.shouldRestoreScrollAfterRender()&&(o<i.restoreScroll.getAnchorItemIndex()&&(o=i.restoreScroll.getAnchorItemIndex()),s=!1),!i.validateWillBeHiddenItemHeightsAreAccurate(r,o))return R("~ Some of the will-be-hidden item heights have changed since they've last been measured. Redo layout. ~"),i.updateShownItemIndexes();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()),V()&&(R("Item heights",i.getState().itemHeights.slice()),R("Item states",i.getState().itemStates.slice())),s&&(i.redoLayoutReason=N.ITEM_HEIGHT_NOT_MEASURED),i.onBeforeShowItems(i.getState().items,i.getState().itemHeights,r,o),i.setState({firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:a,afterItemsHeight:l})}),oe(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())}),oe(this,"updateLayout",function(){return i.onUpdateShownItemIndexes({reason:N.MANUAL})}),oe(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=E),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 ~"),P(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){M("`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=ie({},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 $(this.screen,this.getContainerElement,function(e){return i.getState().itemHeights[e]},function(e,t){return i.getState().itemHeights[e]=t}),x&&this.itemHeights.initialize(x.itemHeights),this.layout=new _({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 Y({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&&M("`preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),this.preserveScrollPositionOfTheBottomOfTheListOnMount=h||u,this.scroll=new Z({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 Q({screen:this.screen,getContainerElement:this.getContainerElement}),this.waitForStylesToLoad=new j({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=ie({},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(){M("`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){M("`.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.measureItemHeights(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(){M("`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){M("`.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){V()&&(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 P('"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.");R("Previous height",t),R("New height",n),t!==n&&(R("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:N.ITEM_HEIGHT_CHANGED}))}},{key:"validateWillBeHiddenItemHeightsAreAccurate",value:function(e,t){for(var n=!0,i=this.getState().firstShownItemIndex;i<=this.getState().lastShownItemIndex;){if(i>=e&&i<=t);else{var r=this.getState().itemHeights[i],o=this.remeasureItemHeight(i);o!==r&&(n=!1,M("Item",i,"will be unmounted at next render. Its height has changed from",r,"to",o,"since it was last measured. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed."))}i++}return 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(ie({},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)}}])&&re(t.prototype,n),i&&re(t,i),e}()});
//# sourceMappingURL=virtual-scroller.js.map

@@ -10,6 +10,8 @@ "use strict";

var _debug = _interopRequireDefault(require("../utility/debug"));
var _debug = _interopRequireWildcard(require("../utility/debug"));
var _px = _interopRequireDefault(require("../utility/px"));
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -118,3 +120,3 @@

_defineProperty(this, "onUnmount", function () {
console.warn('[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');
(0, _debug.warn)('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');

@@ -125,3 +127,3 @@ _this.stop();

_defineProperty(this, "destroy", function () {
console.warn('[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');
(0, _debug.warn)('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');

@@ -128,0 +130,0 @@ _this.stop();

@@ -205,26 +205,6 @@ "use strict";

} else {
// // Validate the item's height right after showing it after being hidden,
// // because, if the stored item's state isn't applied properly, the item's
// // height might be incorrect when it's rendered with that state not applied,
// // and so a developer could know that there's a bug in their code.
//
// Actually, don't perform a strict previously measured item height validation
// here, because there could be valid cases when the item's height has changed
// by this time before the `.onItemHeightChange(i)` call has been executed.
// For example, suppose there's a list of several items on a page,
// and those items are in "minimized" state (having height 100px).
// Then, a user clicks an "Expand all items" button, and all items
// in the list are expanded (expanded item height is gonna be 700px).
// `VirtualScroller` demands that `.onItemHeightChange(i)` is called
// in such cases, and the developer has properly added the code to do that.
// So, if there were 10 "minimized" items visible on a page, then there
// will be 10 individual `.onItemHeightChange(i)` calls. No issues so far.
// But, as the first `.onItemHeightChange(i)` call executes, it immediately
// ("synchronously") triggers a re-layout, and immediately after that re-layout
// `itemHeights.measureItemHeights()` function is called,
// that detects the height mismatch for all the rest of the items.
// So, even though the developer has written their code properly, there're
// still situations when the item's height could have changed by this time,
// and the `.onItemHeightChange(i)` call hasn't been executed for this item yet.
//
// Validate the item's height right after showing it after being hidden,
// because, if the stored item's state isn't applied properly, the item's
// height might be incorrect when it's rendered with that state not applied,
// and so a developer could know that there's a bug in their code.
var previousHeight = this._get(i);

@@ -235,3 +215,3 @@

if (previousHeight !== _height) {
(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.');
(0, _debug.warn)('Item', i, 'height was', previousHeight, 'before it was hidden, but, after showing it again, its height is', _height, '. Perhaps you forgot to persist the item\'s state by calling `onItemStateChange(i, newState)` when it changed, and that state got lost when the item element was unmounted, which resulted in a different height when the item was shown again, but with the missing state.');
}

@@ -238,0 +218,0 @@ }

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

// https://github.com/facebook/react/issues/16309
// So only uses `ref`s for `React.Component`s.
// So it only uses `ref`s for `React.Component`s.
var itemComponent = this.props.itemComponent;

@@ -295,32 +295,30 @@ return isComponentClass(itemComponent);

if (!this.shouldUseRefs()) {
return (0, _debug.reportError)('`.renderItem(i)` has been called but the `component` doesn\'t allow `ref`s. Only `component`s that\'re `React.Component`s support this feature.');
} // The item may be non-rendered when `.renderItem(i)` is called on it.
// For example, when there's a "parent comment" having several "replies"
// each of which has an autogenerated quote of the "parent comment"
// and then the "parent comment" is updated (for example, a YouTube video
// link gets parsed into an embedded video player) and all of its "replies"
// should be updated too to show the parsed video title instead of the URL,
// so `.renderItem(i)` is simply called on all of the "parent post"'s replies
// regardless of some of those replies being rendered or not.
if (this.shouldUseRefs()) {
// The item may be non-rendered when `.renderItem(i)` is called on it.
// For example, when there's a "parent comment" having several "replies"
// each of which has an autogenerated quote of the "parent comment"
// and then the "parent comment" is updated (for example, a YouTube video
// link gets parsed into an embedded video player) and all of its "replies"
// should be updated too to show the parsed video title instead of the URL,
// so `.renderItem(i)` is simply called on all of the "parent post"'s replies
// regardless of some of those replies being rendered or not.
if (this.itemRefs[i] && this.itemRefs[i].current) {
var items = this.props.items; // Stores `item` here because the `i` index
// might have changed when the callback is called,
// or the item even may have been removed.
var item = items[i];
this.itemRefs[i].current.forceUpdate(function () {
if (_this3._isMounted) {
// Recalculates the `i` index here because it
// might have changed when the callback is called,
// or the item even may have been removed.
var _i = items.indexOf(item);
if (this.itemRefs[i] && this.itemRefs[i].current) {
var items = this.props.items; // Stores `item` here because the `i` index
// might have changed when the callback is called,
// or the item even may have been removed.
var item = items[i];
this.itemRefs[i].current.forceUpdate(function () {
if (_this3._isMounted) {
// Recalculates the `i` index here because it
// might have changed when the callback is called,
// or the item even may have been removed.
var _i = items.indexOf(item);
if (_i >= 0) {
_this3.virtualScroller.onItemHeightChange(_i);
if (_i >= 0) {
_this3.virtualScroller.onItemHeightChange(_i);
}
}
}
});
});
}
}

@@ -619,4 +617,4 @@ }

return _react["default"].createElement(Component, _extends({}, itemComponentProps, {
key: _this6.getItemKey(item, i),
ref: _this6.shouldUseRefs() ? _this6.getItemRef(i) : undefined,
key: _this6.getItemKey(item, i),
state: itemStates && itemStates[i],

@@ -623,0 +621,0 @@ onStateChange: _this6.getOnItemStateChange(i),

@@ -7,2 +7,3 @@ "use strict";

exports["default"] = log;
exports.warn = warn;
exports.reportError = reportError;

@@ -31,3 +32,5 @@ exports.isDebug = isDebug;

function reportError() {
function warn() {
var _console2;
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

@@ -37,2 +40,10 @@ args[_key2] = arguments[_key2];

(_console2 = console).warn.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
}
function reportError() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
if (typeof window !== 'undefined') {

@@ -53,6 +64,6 @@ // In a web browser.

} else {
var _console2;
var _console3;
// On a server.
(_console2 = console).error.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
(_console3 = console).error.apply(_console3, _toConsumableArray(['[virtual-scroller]'].concat(args)));
}

@@ -62,4 +73,6 @@ }

function isDebug() {
return typeof window !== 'undefined' && window.VirtualScrollerDebug;
if (typeof window !== 'undefined') {
return window.VirtualScrollerDebug === true || window.VirtualScrollerDebug === 'debug';
}
}
//# sourceMappingURL=debug.js.map

@@ -207,2 +207,14 @@ "use strict";

redoLayoutAfterMeasuringItemHeights = false;
} // Validate the heights of items to be hidden on next render.
// For example, a user could click a "Show more" button,
// or an "Expand YouTube video" button, which would result
// in the actual height of the list item being different
// from what has been initially measured in `this.itemHeights[i]`,
// if the developer didn't call `.onItemStateChange()` and `.onItemHeightChange(i)`.
if (!_this.validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex)) {
// Redo layout, now with the correct item heights.
(0, _debug["default"])('~ Some of the will-be-hidden item heights have changed since they\'ve last been measured. Redo layout. ~');
return _this.updateShownItemIndexes();
} // Measure "before" items height.

@@ -236,13 +248,5 @@

_this.redoLayoutReason = _Layout.LAYOUT_REASON.ITEM_HEIGHT_NOT_MEASURED;
} // Validate the heights of items to be hidden on next render.
// For example, a user could click a "Show more" button,
// or an "Expand YouTube video" button, which would result
// in the actual height of the list item being different
// from what has been initially measured in `this.itemHeights[i]`,
// if the developer didn't call `.onItemStateChange()` and `.onItemHeightChange(i)`.
} // Optionally preload items to be rendered.
_this.validateWillBeHiddenItemHeights(firstShownItemIndex, lastShownItemIndex); // Optionally preload items to be rendered.
_this.onBeforeShowItems(_this.getState().items, _this.getState().itemHeights, firstShownItemIndex, lastShownItemIndex); // Render.

@@ -405,3 +409,3 @@

this.onItemInitialRender = function (item) {
console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");
(0, _debug.warn)('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.');

@@ -547,3 +551,3 @@ var _this$getState = _this.getState(),

if (preserveScrollPositionAtBottomOnMount) {
console.warn('[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`');
(0, _debug.warn)('`preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`');
}

@@ -713,3 +717,3 @@

value: function onMount() {
console.warn('[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.');
(0, _debug.warn)('`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.');
this.listen();

@@ -720,3 +724,3 @@ }

value: function render() {
console.warn('[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead.');
(0, _debug.warn)('`.render()` instance method name is deprecated, use `.listen()` instance method name instead.');
this.listen();

@@ -787,3 +791,3 @@ }

value: function onUnmount() {
console.warn('[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');
(0, _debug.warn)('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');
this.stop();

@@ -794,3 +798,3 @@ }

value: function destroy() {
console.warn('[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');
(0, _debug.warn)('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');
this.stop();

@@ -932,3 +936,3 @@ }

// `.onItemHeightChange(i)` gets called.
return (0, _debug["default"])('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.');
return (0, _debug.warn)('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.');
}

@@ -957,4 +961,5 @@

}, {
key: "validateWillBeHiddenItemHeights",
value: function validateWillBeHiddenItemHeights(firstShownItemIndex, lastShownItemIndex) {
key: "validateWillBeHiddenItemHeightsAreAccurate",
value: function validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex) {
var isValid = true;
var i = this.getState().firstShownItemIndex;

@@ -1000,3 +1005,4 @@

if (actualItemHeight !== previouslyMeasuredItemHeight) {
(0, _debug["default"])('Item', i, 'will be unmounted at next render. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, '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.');
isValid = false;
(0, _debug.warn)('Item', i, 'will be unmounted at next render. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, 'since it was last measured. This is not necessarily a bug, and could happen, for example, when there\'re several `onItemHeightChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed.');
}

@@ -1007,2 +1013,4 @@ }

}
return isValid;
}

@@ -1009,0 +1017,0 @@ /**

@@ -16,3 +16,3 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

import VirtualScrollerCore from '../VirtualScroller';
import log from '../utility/debug';
import log, { warn } from '../utility/debug';
import px from '../utility/px';

@@ -107,3 +107,3 @@

_defineProperty(this, "onUnmount", function () {
console.warn('[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');
warn('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');

@@ -114,3 +114,3 @@ _this.stop();

_defineProperty(this, "destroy", function () {
console.warn('[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');
warn('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');

@@ -117,0 +117,0 @@ _this.stop();

@@ -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 './utility/debug';
import log, { warn, isDebug, reportError } from './utility/debug';

@@ -197,26 +197,6 @@ var ItemHeights =

} else {
// // Validate the item's height right after showing it after being hidden,
// // because, if the stored item's state isn't applied properly, the item's
// // height might be incorrect when it's rendered with that state not applied,
// // and so a developer could know that there's a bug in their code.
//
// Actually, don't perform a strict previously measured item height validation
// here, because there could be valid cases when the item's height has changed
// by this time before the `.onItemHeightChange(i)` call has been executed.
// For example, suppose there's a list of several items on a page,
// and those items are in "minimized" state (having height 100px).
// Then, a user clicks an "Expand all items" button, and all items
// in the list are expanded (expanded item height is gonna be 700px).
// `VirtualScroller` demands that `.onItemHeightChange(i)` is called
// in such cases, and the developer has properly added the code to do that.
// So, if there were 10 "minimized" items visible on a page, then there
// will be 10 individual `.onItemHeightChange(i)` calls. No issues so far.
// But, as the first `.onItemHeightChange(i)` call executes, it immediately
// ("synchronously") triggers a re-layout, and immediately after that re-layout
// `itemHeights.measureItemHeights()` function is called,
// that detects the height mismatch for all the rest of the items.
// So, even though the developer has written their code properly, there're
// still situations when the item's height could have changed by this time,
// and the `.onItemHeightChange(i)` call hasn't been executed for this item yet.
//
// Validate the item's height right after showing it after being hidden,
// because, if the stored item's state isn't applied properly, the item's
// height might be incorrect when it's rendered with that state not applied,
// and so a developer could know that there's a bug in their code.
var previousHeight = this._get(i);

@@ -227,3 +207,3 @@

if (previousHeight !== _height) {
log('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.');
warn('Item', i, 'height was', previousHeight, 'before it was hidden, but, after showing it again, its height is', _height, '. Perhaps you forgot to persist the item\'s state by calling `onItemStateChange(i, newState)` when it changed, and that state got lost when the item element was unmounted, which resulted in a different height when the item was shown again, but with the missing state.');
}

@@ -230,0 +210,0 @@ }

@@ -220,3 +220,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

// https://github.com/facebook/react/issues/16309
// So only uses `ref`s for `React.Component`s.
// So it only uses `ref`s for `React.Component`s.
var itemComponent = this.props.itemComponent;

@@ -281,32 +281,30 @@ return isComponentClass(itemComponent);

if (!this.shouldUseRefs()) {
return reportError('`.renderItem(i)` has been called but the `component` doesn\'t allow `ref`s. Only `component`s that\'re `React.Component`s support this feature.');
} // The item may be non-rendered when `.renderItem(i)` is called on it.
// For example, when there's a "parent comment" having several "replies"
// each of which has an autogenerated quote of the "parent comment"
// and then the "parent comment" is updated (for example, a YouTube video
// link gets parsed into an embedded video player) and all of its "replies"
// should be updated too to show the parsed video title instead of the URL,
// so `.renderItem(i)` is simply called on all of the "parent post"'s replies
// regardless of some of those replies being rendered or not.
if (this.shouldUseRefs()) {
// The item may be non-rendered when `.renderItem(i)` is called on it.
// For example, when there's a "parent comment" having several "replies"
// each of which has an autogenerated quote of the "parent comment"
// and then the "parent comment" is updated (for example, a YouTube video
// link gets parsed into an embedded video player) and all of its "replies"
// should be updated too to show the parsed video title instead of the URL,
// so `.renderItem(i)` is simply called on all of the "parent post"'s replies
// regardless of some of those replies being rendered or not.
if (this.itemRefs[i] && this.itemRefs[i].current) {
var items = this.props.items; // Stores `item` here because the `i` index
// might have changed when the callback is called,
// or the item even may have been removed.
var item = items[i];
this.itemRefs[i].current.forceUpdate(function () {
if (_this3._isMounted) {
// Recalculates the `i` index here because it
// might have changed when the callback is called,
// or the item even may have been removed.
var _i = items.indexOf(item);
if (this.itemRefs[i] && this.itemRefs[i].current) {
var items = this.props.items; // Stores `item` here because the `i` index
// might have changed when the callback is called,
// or the item even may have been removed.
var item = items[i];
this.itemRefs[i].current.forceUpdate(function () {
if (_this3._isMounted) {
// Recalculates the `i` index here because it
// might have changed when the callback is called,
// or the item even may have been removed.
var _i = items.indexOf(item);
if (_i >= 0) {
_this3.virtualScroller.onItemHeightChange(_i);
if (_i >= 0) {
_this3.virtualScroller.onItemHeightChange(_i);
}
}
}
});
});
}
}

@@ -605,4 +603,4 @@ }

return React.createElement(Component, _extends({}, itemComponentProps, {
key: _this6.getItemKey(item, i),
ref: _this6.shouldUseRefs() ? _this6.getItemRef(i) : undefined,
key: _this6.getItemKey(item, i),
state: itemStates && itemStates[i],

@@ -609,0 +607,0 @@ onStateChange: _this6.getOnItemStateChange(i),

@@ -20,3 +20,5 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

}
export function reportError() {
export function warn() {
var _console2;
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

@@ -26,2 +28,9 @@ args[_key2] = arguments[_key2];

(_console2 = console).warn.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
}
export function reportError() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
if (typeof window !== 'undefined') {

@@ -42,11 +51,13 @@ // In a web browser.

} else {
var _console2;
var _console3;
// On a server.
(_console2 = console).error.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
(_console3 = console).error.apply(_console3, _toConsumableArray(['[virtual-scroller]'].concat(args)));
}
}
export function isDebug() {
return typeof window !== 'undefined' && window.VirtualScrollerDebug;
if (typeof window !== 'undefined') {
return window.VirtualScrollerDebug === true || window.VirtualScrollerDebug === 'debug';
}
}
//# sourceMappingURL=debug.js.map

@@ -27,3 +27,3 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

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

@@ -190,2 +190,14 @@

redoLayoutAfterMeasuringItemHeights = false;
} // Validate the heights of items to be hidden on next render.
// For example, a user could click a "Show more" button,
// or an "Expand YouTube video" button, which would result
// in the actual height of the list item being different
// from what has been initially measured in `this.itemHeights[i]`,
// if the developer didn't call `.onItemStateChange()` and `.onItemHeightChange(i)`.
if (!_this.validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex)) {
// Redo layout, now with the correct item heights.
log('~ Some of the will-be-hidden item heights have changed since they\'ve last been measured. Redo layout. ~');
return _this.updateShownItemIndexes();
} // Measure "before" items height.

@@ -219,13 +231,5 @@

_this.redoLayoutReason = LAYOUT_REASON.ITEM_HEIGHT_NOT_MEASURED;
} // Validate the heights of items to be hidden on next render.
// For example, a user could click a "Show more" button,
// or an "Expand YouTube video" button, which would result
// in the actual height of the list item being different
// from what has been initially measured in `this.itemHeights[i]`,
// if the developer didn't call `.onItemStateChange()` and `.onItemHeightChange(i)`.
} // Optionally preload items to be rendered.
_this.validateWillBeHiddenItemHeights(firstShownItemIndex, lastShownItemIndex); // Optionally preload items to be rendered.
_this.onBeforeShowItems(_this.getState().items, _this.getState().itemHeights, firstShownItemIndex, lastShownItemIndex); // Render.

@@ -388,3 +392,3 @@

this.onItemInitialRender = function (item) {
console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");
warn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.');

@@ -530,3 +534,3 @@ var _this$getState = _this.getState(),

if (preserveScrollPositionAtBottomOnMount) {
console.warn('[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`');
warn('`preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`');
}

@@ -696,3 +700,3 @@

value: function onMount() {
console.warn('[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.');
warn('`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.');
this.listen();

@@ -703,3 +707,3 @@ }

value: function render() {
console.warn('[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead.');
warn('`.render()` instance method name is deprecated, use `.listen()` instance method name instead.');
this.listen();

@@ -770,3 +774,3 @@ }

value: function onUnmount() {
console.warn('[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');
warn('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.');
this.stop();

@@ -777,3 +781,3 @@ }

value: function destroy() {
console.warn('[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');
warn('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.');
this.stop();

@@ -915,3 +919,3 @@ }

// `.onItemHeightChange(i)` gets called.
return log('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.');
return warn('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.');
}

@@ -940,4 +944,5 @@

}, {
key: "validateWillBeHiddenItemHeights",
value: function validateWillBeHiddenItemHeights(firstShownItemIndex, lastShownItemIndex) {
key: "validateWillBeHiddenItemHeightsAreAccurate",
value: function validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex) {
var isValid = true;
var i = this.getState().firstShownItemIndex;

@@ -983,3 +988,4 @@

if (actualItemHeight !== previouslyMeasuredItemHeight) {
log('Item', i, 'will be unmounted at next render. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, '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.');
isValid = false;
warn('Item', i, 'will be unmounted at next render. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, 'since it was last measured. This is not necessarily a bug, and could happen, for example, when there\'re several `onItemHeightChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed.');
}

@@ -990,2 +996,4 @@ }

}
return isValid;
}

@@ -992,0 +1000,0 @@ /**

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

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

import VirtualScrollerCore from '../VirtualScroller'
import log from '../utility/debug'
import log, { warn } from '../utility/debug'
import px from '../utility/px'

@@ -107,3 +107,3 @@

onUnmount = () => {
console.warn('[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.')
warn('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.')
this.stop()

@@ -114,3 +114,3 @@ }

destroy = () => {
console.warn('[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.')
warn('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.')
this.stop()

@@ -117,0 +117,0 @@ }

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

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

@@ -167,30 +167,10 @@ export default class ItemHeights {

} else {
// // Validate the item's height right after showing it after being hidden,
// // because, if the stored item's state isn't applied properly, the item's
// // height might be incorrect when it's rendered with that state not applied,
// // and so a developer could know that there's a bug in their code.
//
// Actually, don't perform a strict previously measured item height validation
// here, because there could be valid cases when the item's height has changed
// by this time before the `.onItemHeightChange(i)` call has been executed.
// For example, suppose there's a list of several items on a page,
// and those items are in "minimized" state (having height 100px).
// Then, a user clicks an "Expand all items" button, and all items
// in the list are expanded (expanded item height is gonna be 700px).
// `VirtualScroller` demands that `.onItemHeightChange(i)` is called
// in such cases, and the developer has properly added the code to do that.
// So, if there were 10 "minimized" items visible on a page, then there
// will be 10 individual `.onItemHeightChange(i)` calls. No issues so far.
// But, as the first `.onItemHeightChange(i)` call executes, it immediately
// ("synchronously") triggers a re-layout, and immediately after that re-layout
// `itemHeights.measureItemHeights()` function is called,
// that detects the height mismatch for all the rest of the items.
// So, even though the developer has written their code properly, there're
// still situations when the item's height could have changed by this time,
// and the `.onItemHeightChange(i)` call hasn't been executed for this item yet.
//
// Validate the item's height right after showing it after being hidden,
// because, if the stored item's state isn't applied properly, the item's
// height might be incorrect when it's rendered with that state not applied,
// and so a developer could know that there's a bug in their code.
const previousHeight = this._get(i)
const height = this._measureItemHeight(i, firstShownItemIndex)
if (previousHeight !== height) {
log('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.')
warn('Item', i, 'height was', previousHeight, 'before it was hidden, but, after showing it again, its height is', height, '. Perhaps you forgot to persist the item\'s state by calling `onItemStateChange(i, newState)` when it changed, and that state got lost when the item element was unmounted, which resulted in a different height when the item was shown again, but with the missing state.')
}

@@ -197,0 +177,0 @@ }

@@ -253,3 +253,3 @@ import React from 'react'

// https://github.com/facebook/react/issues/16309
// So only uses `ref`s for `React.Component`s.
// So it only uses `ref`s for `React.Component`s.
const { itemComponent } = this.props

@@ -301,30 +301,29 @@ return isComponentClass(itemComponent)

}
if (!this.shouldUseRefs()) {
return reportError('`.renderItem(i)` has been called but the `component` doesn\'t allow `ref`s. Only `component`s that\'re `React.Component`s support this feature.')
}
// The item may be non-rendered when `.renderItem(i)` is called on it.
// For example, when there's a "parent comment" having several "replies"
// each of which has an autogenerated quote of the "parent comment"
// and then the "parent comment" is updated (for example, a YouTube video
// link gets parsed into an embedded video player) and all of its "replies"
// should be updated too to show the parsed video title instead of the URL,
// so `.renderItem(i)` is simply called on all of the "parent post"'s replies
// regardless of some of those replies being rendered or not.
if (this.itemRefs[i] && this.itemRefs[i].current) {
const { items } = this.props
// Stores `item` here because the `i` index
// might have changed when the callback is called,
// or the item even may have been removed.
const item = items[i]
this.itemRefs[i].current.forceUpdate(() => {
if (this._isMounted) {
// Recalculates the `i` index here because it
// might have changed when the callback is called,
// or the item even may have been removed.
const i = items.indexOf(item)
if (i >= 0) {
this.virtualScroller.onItemHeightChange(i)
if (this.shouldUseRefs()) {
// The item may be non-rendered when `.renderItem(i)` is called on it.
// For example, when there's a "parent comment" having several "replies"
// each of which has an autogenerated quote of the "parent comment"
// and then the "parent comment" is updated (for example, a YouTube video
// link gets parsed into an embedded video player) and all of its "replies"
// should be updated too to show the parsed video title instead of the URL,
// so `.renderItem(i)` is simply called on all of the "parent post"'s replies
// regardless of some of those replies being rendered or not.
if (this.itemRefs[i] && this.itemRefs[i].current) {
const { items } = this.props
// Stores `item` here because the `i` index
// might have changed when the callback is called,
// or the item even may have been removed.
const item = items[i]
this.itemRefs[i].current.forceUpdate(() => {
if (this._isMounted) {
// Recalculates the `i` index here because it
// might have changed when the callback is called,
// or the item even may have been removed.
const i = items.indexOf(item)
if (i >= 0) {
this.virtualScroller.onItemHeightChange(i)
}
}
}
})
})
}
}

@@ -596,4 +595,4 @@ }

{...itemComponentProps}
key={this.getItemKey(item, i)}
ref={this.shouldUseRefs() ? this.getItemRef(i) : undefined}
key={this.getItemKey(item, i)}
state={itemStates && itemStates[i]}

@@ -600,0 +599,0 @@ onStateChange={this.getOnItemStateChange(i)}

@@ -7,2 +7,6 @@ export default function log(...args) {

export function warn(...args) {
console.warn(...['[virtual-scroller]'].concat(args))
}
export function reportError(...args) {

@@ -30,3 +34,6 @@ if (typeof window !== 'undefined') {

export function isDebug() {
return typeof window !== 'undefined' && window.VirtualScrollerDebug
if (typeof window !== 'undefined') {
return window.VirtualScrollerDebug === true
|| window.VirtualScrollerDebug === 'debug'
}
}

@@ -26,3 +26,3 @@ // For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.

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

@@ -166,3 +166,3 @@

this.onItemInitialRender = (item) => {
console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.")
warn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.')
const { items } = this.getState()

@@ -288,3 +288,3 @@ const i = items.indexOf(item)

if (preserveScrollPositionAtBottomOnMount) {
console.warn('[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`')
warn('`preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`')
}

@@ -432,3 +432,3 @@

onMount() {
console.warn('[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.')
warn('`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.')
this.listen()

@@ -438,3 +438,3 @@ }

render() {
console.warn('[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead.')
warn('`.render()` instance method name is deprecated, use `.listen()` instance method name instead.')
this.listen()

@@ -509,3 +509,3 @@ }

onUnmount() {
console.warn('[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.')
warn('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.')
this.stop()

@@ -515,3 +515,3 @@ }

destroy() {
console.warn('[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.')
warn('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.')
this.stop()

@@ -706,3 +706,3 @@ }

// `.onItemHeightChange(i)` gets called.
return log('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.')
return warn('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.')
}

@@ -726,3 +726,4 @@ log('Previous height', previousHeight)

*/
validateWillBeHiddenItemHeights(firstShownItemIndex, lastShownItemIndex) {
validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex) {
let isValid = true
let i = this.getState().firstShownItemIndex

@@ -767,3 +768,4 @@ while (i <= this.getState().lastShownItemIndex) {

if (actualItemHeight !== previouslyMeasuredItemHeight) {
log('Item', i, 'will be unmounted at next render. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, '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.')
isValid = false
warn('Item', i, 'will be unmounted at next render. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, 'since it was last measured. This is not necessarily a bug, and could happen, for example, when there\'re several `onItemHeightChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed.')
}

@@ -773,2 +775,3 @@ }

}
return isValid
}

@@ -825,2 +828,13 @@

}
// Validate the heights of items to be hidden on next render.
// For example, a user could click a "Show more" button,
// or an "Expand YouTube video" button, which would result
// in the actual height of the list item being different
// from what has been initially measured in `this.itemHeights[i]`,
// if the developer didn't call `.onItemStateChange()` and `.onItemHeightChange(i)`.
if (!this.validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex)) {
// Redo layout, now with the correct item heights.
log('~ Some of the will-be-hidden item heights have changed since they\'ve last been measured. Redo layout. ~')
return this.updateShownItemIndexes();
}
// Measure "before" items height.

@@ -855,9 +869,2 @@ const beforeItemsHeight = this.layout.getBeforeItemsHeight(

}
// Validate the heights of items to be hidden on next render.
// For example, a user could click a "Show more" button,
// or an "Expand YouTube video" button, which would result
// in the actual height of the list item being different
// from what has been initially measured in `this.itemHeights[i]`,
// if the developer didn't call `.onItemStateChange()` and `.onItemHeightChange(i)`.
this.validateWillBeHiddenItemHeights(firstShownItemIndex, lastShownItemIndex)
// Optionally preload items to be rendered.

@@ -864,0 +871,0 @@ this.onBeforeShowItems(

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 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 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 not supported yet

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