(window.webpackJsonp=window.webpackJsonp||[]).push([[98],{"./runtime-repl/history/HistorySidebarController.js":function(e,t,r){"use strict";r.r(t),function(e){r.d(t,"default",(function(){return l}));var s=r("../../node_modules/mobx/lib/mobx.module.js"),o=r("./js/modules/services/PermissionRemoteFetchService.js"),n=r("./js/stores/get-store.js"),c=r("./runtime-repl/request-websocket/history/services/WebSocketHistoryService.js"),i=r("./runtime-repl/runner/SyncService.js");class l{async didCreate(){this.store=Object(n.getStore)("HistorySidebarStore"),this.store.setSearchQuery(""),this.wsHistoryStore=Object(n.getStore)("WebSocketHistoryStore"),this.currentWorkspace=Object(n.getStore)("ActiveWorkspaceStore").id,Object(n.getStore)("SyncStatusStore").onSyncAvailable({timeout:5e3}).then((()=>Object(o.fetchViewHistory)(this.currentWorkspace))).then((e=>e[this.currentWorkspace].allowed?c.default.subscribeToRealtimeEvents(this.currentWorkspace):Promise.resolve())).then((t=>{if(!t)return Promise.reject(new Error("Subscription not found"));this.subscription=t,this.subscription.subscribe((({data:t})=>{Object(s.transaction)((()=>{e.forEach(t,(t=>{if(!t)return;const{id:r,value:s,op:o}=t;switch(o){case"create":return this.wsHistoryStore.add(e.assign({id:r,workspace:this.currentWorkspace},s));case"delete":return this.wsHistoryStore.remove(r);case"deleteAll":return this.wsHistoryStore.removeAll()}}))}))}))})).catch((e=>{pm.logger.error("HistorySidebarController~didCreate: Error in subscribing to WebSocket history's realtime events",e)})),await Object(i.fetchMoreRunsInActiveWorkspace)()}beforeDestroy(){this.store=null,this.wsHistoryStore=null,this.subscription&&c.default.unsubscribeFromRealtimeEvents(this.currentWorkspace).catch((e=>pm.logger.error("WebSocketWorkbenchController~beforeDestroy: Error in unsubscribing from WebSocket history's realtime events",e))),this.subscription=null,this.currentWorkspace=null}}}.call(this,r("./node_modules/lodash/lodash.js"))},"./runtime-repl/runner/SyncService.js":function(e,t,r){"use strict";r.r(t),r.d(t,"fetchMoreRunsInActiveWorkspace",(function(){return m}));var s=r("./node_modules/async/dist/async.js"),o=r.n(s),n=r("./js/modules/services/SyncRemoteFetcherService.js"),c=r("./js/modules/sync-helpers/create-changeset.js"),i=r("./js/models/sync/services/SyncIncomingHandler.js"),l=r("./js/stores/get-store.js"),a=r("./runtime-repl/runner/datastores/controllers/RunnerRunController.js"),u=r("./collaboration/workspace/controller/ActiveWorkspaceController.ts"),d=r.n(u);const h="collectionrun";function m(e=20,t=0){return Promise.resolve(Object(l.getStore)("SyncStatusStore")).then((e=>e.onSyncAvailable())).then((()=>async function(){const e=d.a.get();return e?e.id:(pm.logger.error("WorkspaceSession not found in DB"),Promise.reject(Error("Runtime~getActiveWorkspace: WorkspaceSession not found in db")))}())).then((r=>function({workspace:e,count:t,sinceLastRevisionId:r}){return new Promise(((s,l)=>{o.a.waterfall([s=>{n.default.remoteFetch(h,"find",{workspace:e,count:t,since_id:r}).then((e=>s(null,e))).catch((e=>s(e)))},(e,t)=>{const r=e.map((e=>e.id));a.default.getAll({id:r}).then((s=>{const o=s.map((e=>e.id)),n=r.filter((e=>-1===o.indexOf(e))),c=e.filter((e=>-1!==n.indexOf(e.id)));t(null,c)})).catch((e=>t(e)))},(e,t)=>{t(null,e.map((e=>Object(c.default)(h,"import",{instance:e,modelId:e.id,owner:e.owner},{partial:!0}))))},(e,t)=>{const r=e.map((e=>Object(i.processIncomingChangeset)(e).catch((e=>{pm.logger.warn("RunnerRunStore~fetchMoreCollectionRuns: Could not create collection run",e)}))));return Promise.all(r).then((()=>t(null,e))).catch((e=>t(e)))}],(e=>{e?l(e):s()}))}))}({workspace:r,count:e,sinceLastRevisionId:t})))}}}]);