import*as Common from"../../common/common.js";import{Events as ViewEvents,GraphView}from"./GraphView.js";export class GraphManager extends Common.ObjectWrapper.ObjectWrapper{constructor(){super(),this._graphMapByContextId=new Map}createContext(t){const e=new GraphView(t);e.addEventListener(ViewEvents.ShouldRedraw,this._notifyShouldRedraw,this),this._graphMapByContextId.set(t,e)}destroyContext(t){if(!this._graphMapByContextId.has(t))return;const e=this._graphMapByContextId.get(t);e&&(e.removeEventListener(ViewEvents.ShouldRedraw,this._notifyShouldRedraw,this),this._graphMapByContextId.delete(t))}hasContext(t){return this._graphMapByContextId.has(t)}clearGraphs(){this._graphMapByContextId.clear()}getGraph(t){return this._graphMapByContextId.get(t)||null}_notifyShouldRedraw(t){const e=t.data;this.dispatchEventToListeners(ViewEvents.ShouldRedraw,e)}}