import{r as registerInstance,h,g as getElement}from"./index-55faf181.js";var dvnListViewTableCss=":host{-ms-flex:1 1 1px;flex:1 1 1px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden}.table-progress-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-height:calc(14 * var(--spacing-unit))}.error-container{padding:calc(4 * var(--spacing-unit))}";function findStartNode(e,r,t){var n=0;var o=t-1;while(o!==n){var i=Math.floor((o-n)/2+n);if(r[i]<=e&&r[i+1]>e){return i}if(i===n){return o}else{if(r[i]<=e){n=i}else{o=i}}}return t}function findEndNode(e,r,t,n){var o;for(o=r;o<t;o++){if(e[o]>e[r]+n){return o}}return o}var VirtualScroll=function(){function e(e){registerInstance(this,e);this.itemCount=500;this.rowHeight=50;this.renderAhead=0;this.scrollTop=0}e.prototype.componentDidRender=function(){var e=this;setTimeout((function(){e.height=e.el?e.el.offsetHeight:0}),100)};e.prototype.render=function(){var e=this;var r=this,t=r.height,n=r.itemCount,o=r.renderAhead,i=r.rowHeight,l=r.scrollTop;var a=function(e){return i};var s=function(){var e=[0];for(var r=1;r<n;r++){e.push(e[r-1]+a())}return e};var c=s()[n-1]+a();console.log("scrollTop",l);var f=function(){return findStartNode(l,s(),n)};console.log("firstVisibleNode()",f());var u=Math.max(0,f()-o);console.log("startNode",u);var d=function(){return findEndNode(s(),f(),n,t)};var v=Math.min(n-1,d()+o);var p=v-u+1;var g=s()[u];console.log("visibleNodeCount",p);var m=function(){return new Array(p).fill(null).map((function(r,t){return e.renderRow(t+u)}))};console.log("viewportHeight",t);console.log("totalHeight",c);return h("div",{style:{height:800+"px",overflow:"auto",flex:"1",display:"block"},onScroll:function(r){console.log(r.target.scrollTop);e.scrollTop=r.target.scrollTop}},h("div",{style:{height:c+"px",overflow:"hidden",willChange:"transform",position:"relative"}},h("div",{style:{transform:"translateY("+g+"px)"}},m())))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VirtualScroll.style=dvnListViewTableCss;export{VirtualScroll as dvn_virtual_scroll};