text: /**
   * @license
   * Copyright (c) 2014, 2018, Oracle and/or its affiliates.
   * The Universal Permissive License (UPL), Version 1.0
   */
  "use strict";define(["ojs/ojcore","jquery"],function(e,t){e.DomScroller=function(e,r,o){o=o||{},this._data=r,this._asyncIterator=o.asyncIterator,this._element=t(e)[0],this._fetchSize=o.fetchSize,this._fetchSize=this._fetchSize>0?this._fetchSize:25,this._maxCount=o.maxCount,this._maxCount=this._maxCount>0?this._maxCount:500,this._rowCount=o.initialRowCount>0?o.initialRowCount:0,this._successCallback=o.success,this._requestCallback=o.request,this._errorCallback=o.error,this._registerDataSourceEventListeners(),this._fetchTrigger=o.fetchTrigger,(null==this._fetchTrigger||isNaN(this._fetchTrigger))&&(this._fetchTrigger=0),this._initialScrollTop=this._element.scrollTop,t(this._getScrollEventElement()).on("scroll.domscroller",function(e){var t=this._element,r=this._getScrollTop(t),o=t.scrollHeight-t.clientHeight;o>0&&this._handleScrollerScrollTop(r,o)}.bind(this))},e.DomScroller.prototype.setFetchTrigger=function(e){null!=e&&!isNaN(e)&&e>=0&&(this._fetchTrigger=e)},e.DomScroller.prototype._getScrollEventElement=function(){return this._element==document.body||this._element==document.documentElement?window:this._element},e.DomScroller.calculateOffsetTop=function(e,r){for(var o=0,i=r;i&&i!=e&&t.contains(e,i);)o+=i.offsetTop,i=i.offsetParent;return o},e.DomScroller.prototype._getScrollTop=function(e){var t=this._fetchTrigger;return e==document.documentElement&&(void 0===this._useBodyScrollTop&&(this._useBodyScrollTop=this._initialScrollTop==e.scrollTop),this._useBodyScrollTop)?t+document.body.scrollTop:t+e.scrollTop},e.DomScroller.prototype.destroy=function(){this._unregisterDataSourceEventListeners(),t(this._getScrollEventElement()).off("scroll.domscroller")},e.DomScroller.prototype.checkViewport=function(){return this._asyncIterator&&this._element.clientHeight>0&&!this._checkOverflow()?this._fetchMoreRows():Promise.resolve(null)},e.DomScroller.prototype._handleScrollerScrollTop=function(e,t){if(t-e<=1&&e>this._fetchTrigger&&!this._fetchPromise)if(this._asyncIterator){var r=this;this._fetchMoreRows().then(function(e){r._successCallback&&r._successCallback(e)},function(e){r._errorCallback&&r._errorCallback(e)})}else null!=this._errorCallback&&this._errorCallback()},e.DomScroller.prototype._checkOverflow=function(){var e=this._element;return e.scrollHeight>e.clientHeight+this._fetchTrigger},e.DomScroller.prototype._fetchMoreRows=function(){if(this._fetchPromise)return this._fetchPromise;var e=this._maxCount-this._rowCount;if(e>0){this._fetchSize;var t=this;if(e<this._fetchSize&&e,this._asyncIterator)return null!=this._requestCallback&&this._requestCallback(),this._fetchPromise=this._asyncIterator.next().then(function(r){return t._fetchPromise=null,null!=r&&null!=r.value&&(r.value.data.length>0&&(t._rowCount=t._rowCount+r.value.data.length,e<t._fetchSize&&(r.maxCount=t._maxCount,r.maxCountLimit=!0,r.value.data.length>e&&(r.value.data=r.value.data.slice(0,e),r.value.metadata=r.value.metadata.slice(0,e),null!=r.value.fetchParameters&&(r.value.fetchParameters.size=e)))),r.done&&(t._asyncIterator=null)),Promise.resolve(r)}),this._fetchPromise}return Promise.resolve({maxCount:this._maxCount,maxCountLimit:!0})},e.DomScroller.prototype._handleDataRowMutateEvent=function(e){var t=null,r=null;if(null!=e.detail.remove&&(t="remove",r=e.detail.remove),null!=e.detail.add&&(t="add",r=e.detail.add),null!=t){var o,i=r.indexes,l=i.length;for(o=0;o<l;o++){var n=i[o];void 0!==n&&this._rowCount>0&&n<=this._rowCount&&("add"==t?this._rowCount=this._rowCount+1:"remove"==t&&(this._rowCount=this._rowCount-1))}}},e.DomScroller.prototype._registerDataSourceEventListeners=function(){var e,t,r=this._data;if(null!=r)for(this._unregisterDataSourceEventListeners(),this._dataProviderEventHandlers=[],this._dataProviderEventHandlers.push({eventType:"mutate",eventHandler:this._handleDataRowMutateEvent.bind(this)}),e=0;e<this._dataProviderEventHandlers.length;e++)(t=r.addEventListener(this._dataProviderEventHandlers[e].eventType,this._dataProviderEventHandlers[e].eventHandler))&&(this._dataProviderEventHandlers[e].eventHandler=t)},e.DomScroller.prototype._unregisterDataSourceEventListeners=function(){var e,t=this._data;if(null!=this._dataProviderEventHandlers&&null!=t)for(e=0;e<this._dataProviderEventHandlers.length;e++)t.removeEventListener(this._dataProviderEventHandlers[e].eventType,this._dataProviderEventHandlers[e].eventHandler)}});