!function(e){function r(t){if(f[t])return f[t].exports;var n=f[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}var f={};r.m=e,r.c=f,r.d=function(e,f,t){r.o(e,f)||Object.defineProperty(e,f,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var f=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(f,"a",f),f},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=0)}([function(e,r,f){"use strict";var t=[];self.FILTERED_RECORD_LIST=[];self.currentStateData=[],self.filterStr="",self.canLoadMore=!1,self.updateQueryTimer=null,self.refreshing=!0,self.beginIndex=0,self.endIndex=self.beginIndex+500-1,self.IN_DIFF=!1;var n=function(e){var r=null;if(e){var f=e.replace(/\r\n/g,"\n").replace(/\n\n/g,"\n");f=f.replace(/\n*$/,""),"/"===f[0]&&"/"===f[f.length-1]&&(f=f.substring(1,f.length-2)),f=f.replace(/((.+)\n|(.+)$)/g,function(e,r,f){return f?"("+f+")|":"("+r+")"});try{r=new RegExp(f)}catch(e){console.error(e)}}return r};self.resetDisplayRecordIndex=function(){self.beginIndex=0,self.endIndex=self.beginIndex+500-1},self.getFilteredRecords=function(){return self.FILTERED_RECORD_LIST},self.calculateFilteredRecords=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],f=n(self.filterStr);if(e){self.FILTERED_RECORD_LIST=[];for(var s=t.length,l=0;l<s;l++){var d=t[l];(!f||f&&f.test(d.url))&&self.FILTERED_RECORD_LIST.push(d)}}else r.forEach(function(e){var r=self.FILTERED_RECORD_LIST.findIndex(function(r){return e.id===r.id});r>=0?self.FILTERED_RECORD_LIST[r]=e:(!f||f&&f.test(e.url))&&self.FILTERED_RECORD_LIST.push(e)})},self.diffRecords=function(){if(!self.IN_DIFF){self.IN_DIFF=!0;var e=!1,r=self.getFilteredRecords();self.refreshing?(self.beginIndex=r.length-1-500,self.endIndex=r.length-1):self.endIndex>r.length&&(self.endIndex=r.length);var f=r.slice(self.beginIndex,self.endIndex+1),t=self.currentStateData.length;if(f.length!==t)e=!0;else for(var n=0;n<t;n++){var s=self.currentStateData[n],l=f[n];if(s.id!==l.id||!0===l._render){e=!0;break}}self.currentStateData=f,self.postMessage(JSON.stringify({type:"updateData",shouldUpdateRecord:e,recordList:f})),self.IN_DIFF=!1}},self.checkNewRecordsTip=function(){if(!self.IN_DIFF){var e=self.getFilteredRecords().length;self.postMessage(JSON.stringify({type:"updateTip",data:e-self.endIndex>0}))}},self.updateSingle=function(e){t.forEach(function(e){e._render=!1});var r=t.findIndex(function(r){return r.id===e.id});r>=0?(e._render=!0,t[r]=e):t.push(e),self.calculateFilteredRecords(!1,[e])},self.updateMultiple=function(e){t.forEach(function(e){e._render=!1}),e.forEach(function(e){var r=t.findIndex(function(r){return r.id===e.id});r>=0?(e._render=!0,t[r]=e):t.push(e)}),self.calculateFilteredRecords(!1,e)},self.addEventListener("message",function(e){var r=JSON.parse(e.data);switch(r.type){case"diff":self.diffRecords();break;case"updateQuery":r.filterStr!==self.filterStr&&(self.updateQueryTimer&&clearTimeout(self.updateQueryTimer),self.updateQueryTimer=setTimeout(function(){self.resetDisplayRecordIndex(),self.filterStr=r.filterStr,self.calculateFilteredRecords(!0),self.diffRecords()},150));break;case"updateSingle":self.updateSingle(r.data),self.refreshing?self.diffRecords():self.checkNewRecordsTip();break;case"updateMultiple":self.updateMultiple(r.data),self.refreshing?self.diffRecords():self.checkNewRecordsTip();break;case"initRecord":t=r.data,self.calculateFilteredRecords(!0),self.diffRecords();break;case"clear":t=[],self.calculateFilteredRecords(!0),self.diffRecords();break;case"loadMore":if(self.IN_DIFF)return;self.refreshing=!1,r.data>0?self.endIndex+=r.data:self.beginIndex=Math.max(self.beginIndex+r.data,0),self.diffRecords();break;case"updateRefreshing":"boolean"==typeof r.refreshing&&(self.refreshing=r.refreshing,self.refreshing&&self.diffRecords())}})}]);