(window.webpackJsonp=window.webpackJsonp||[]).push([[99],{"./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"),i=r("./runtime-repl/request-websocket/history/services/WebSocketHistoryService.js"),c=r("./integrations/proxy/services/ProxyHistoryService.js"),a=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?i.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 c.default.subscribeSessionEvents(),await Object(a.fetchMoreRunsInActiveWorkspace)()}async beforeDestroy(){this.store=null,this.wsHistoryStore=null,this.subscription&&i.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,await c.default.unsubscribeSessionEvents()}}}.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 b}));var s=r("./node_modules/async/dist/async.js"),o=r.n(s),n=r("./js/modules/services/SyncRemoteFetcherService.js"),i=r("./js/modules/sync-helpers/create-changeset.js"),c=r("./js/models/sync/services/SyncIncomingHandler.js"),a=r("./js/stores/get-store.js"),l=r("./runtime-repl/runner/datastores/controllers/RunnerRunController.js"),u=r("./collaboration/workspace/controller/ActiveWorkspaceController.ts"),d=r.n(u);const h="collectionrun";function b(e=20,t=0){return Promise.resolve(Object(a.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,a)=>{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));l.default.getAll({id:r}).then((s=>{const o=s.map((e=>e.id)),n=r.filter((e=>-1===o.indexOf(e))),i=e.filter((e=>-1!==n.indexOf(e.id)));t(null,i)})).catch((e=>t(e)))},(e,t)=>{t(null,e.map((e=>Object(i.default)(h,"import",{instance:e,modelId:e.id,owner:e.owner},{partial:!0}))))},(e,t)=>{const r=e.map((e=>Object(c.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?a(e):s()}))}))}({workspace:r,count:e,sinceLastRevisionId:t})))}}}]);