define(["exports","./../modules/cardbuilder/cardbuilder.js"],function(_exports,_cardbuilder){function trimResultByIndex(result,index){result=result.Items.slice(index);return result.length=1,{Items:result,TotalRecordCount:1}}function Spotlight(itemsContainer,getItemsFn,getDefaultItemFn){(this.itemsContainer=itemsContainer).fetchData=function(){var instance=this;return instance._itemsResult?Promise.resolve(trimResultByIndex(instance._itemsResult,instance._currentIndex)):instance.getItemsFn({Limit:20}).then(function(result){return result.Items.length||(result.Items.push(instance._defaultItem),result.TotalRecordCount=1),trimResultByIndex(instance._itemsResult=result,instance._currentIndex)})}.bind(this),itemsContainer.getListOptions=function(){return{renderer:_cardbuilder.default,options:{shape:"backdrop",multiSelect:!1,contextMenu:!1,overlayText:!0,fields:["Name"],cardClass:"wideSpotlightCard"},virtualScrollLayout:"vertical-grid"}}.bind(this),this.getItemsFn=getItemsFn,this._currentIndex=0,this._defaultItem=getDefaultItemFn()}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Spotlight.prototype.resume=function(options){this.paused=!1;var instance=this;return this.itemsContainer.resume(options).then(function(){instance.startInterval()})},Spotlight.prototype.onInterval=function(){var itemsResult,itemsContainer,newIndex;this.paused||(itemsResult=this._itemsResult)&&(itemsContainer=this.itemsContainer,document.body.contains(itemsContainer)?((newIndex=this._currentIndex+1)>=itemsResult.TotalRecordCount&&(newIndex=0),this._currentIndex=newIndex,itemsContainer.refreshItems()):this.clearInterval())},Spotlight.prototype.startInterval=function(){this.interval||(this.interval=setInterval(this.onInterval.bind(this),3e4))},Spotlight.prototype.clearInterval=function(){this.interval&&(clearInterval(this.interval),this.interval=null)},Spotlight.prototype.pause=function(){this.paused=!0,this.clearInterval()},Spotlight.prototype.destroy=function(){this.clearInterval(),this.itemsContainer=null,this._itemsResult=null,this._currentIndex=null,this._defaultItem=null},_exports.default=Spotlight});