{"ast":null,"code":"import { Observable } from \"../Misc/observable.js\";\nimport { FlowGraph } from \"./flowGraph.js\";\nimport { defaultValueParseFunction } from \"./serialization.js\";\n/**\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\n */\nexport class FlowGraphCoordinator {\n constructor(\n /**\n * the configuration of the block\n */\n config) {\n var _FlowGraphCoordinator;\n this.config = config;\n this._flowGraphs = [];\n this._customEventsMap = new Map();\n // When the scene is disposed, dispose all graphs currently running on it.\n this.config.scene.onDisposeObservable.add(() => {\n this.dispose();\n });\n // Add itself to the SceneCoordinators list for the Inspector.\n const coordinators = (_FlowGraphCoordinator = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene)) !== null && _FlowGraphCoordinator !== void 0 ? _FlowGraphCoordinator : [];\n coordinators.push(this);\n }\n /**\n * Creates a new flow graph and adds it to the list of existing flow graphs\n * @returns a new flow graph\n */\n createGraph() {\n const graph = new FlowGraph({\n scene: this.config.scene,\n coordinator: this\n });\n this._flowGraphs.push(graph);\n return graph;\n }\n /**\n * Removes a flow graph from the list of existing flow graphs and disposes it\n * @param graph the graph to remove\n */\n removeGraph(graph) {\n const index = this._flowGraphs.indexOf(graph);\n if (index !== -1) {\n graph.dispose();\n this._flowGraphs.splice(index, 1);\n }\n }\n /**\n * Starts all graphs\n */\n start() {\n this._flowGraphs.forEach(graph => graph.start());\n }\n /**\n * Disposes all graphs\n */\n dispose() {\n var _FlowGraphCoordinator2;\n this._flowGraphs.forEach(graph => graph.dispose());\n this._flowGraphs.length = 0;\n // Remove itself from the SceneCoordinators list for the Inspector.\n const coordinators = (_FlowGraphCoordinator2 = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene)) !== null && _FlowGraphCoordinator2 !== void 0 ? _FlowGraphCoordinator2 : [];\n const index = coordinators.indexOf(this);\n if (index !== -1) {\n coordinators.splice(index, 1);\n }\n }\n /**\n * Serializes this coordinator to a JSON object.\n * @param serializationObject the object to serialize to\n * @param valueSerializeFunction the function to use to serialize the value\n */\n serialize(serializationObject, valueSerializeFunction) {\n serializationObject._flowGraphs = [];\n this._flowGraphs.forEach(graph => {\n const serializedGraph = {};\n graph.serialize(serializedGraph, valueSerializeFunction);\n serializationObject._flowGraphs.push(serializedGraph);\n });\n }\n /**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\n static Parse(serializedObject, options) {\n var _options$valueParseFu, _serializedObject$_fl;\n const valueParseFunction = (_options$valueParseFu = options.valueParseFunction) !== null && _options$valueParseFu !== void 0 ? _options$valueParseFu : defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({\n scene: options.scene\n });\n (_serializedObject$_fl = serializedObject._flowGraphs) === null || _serializedObject$_fl === void 0 || _serializedObject$_fl.forEach(serializedGraph => {\n FlowGraph.Parse(serializedGraph, {\n coordinator,\n valueParseFunction,\n pathConverter: options.pathConverter\n });\n });\n return coordinator;\n }\n /**\n * Gets the list of flow graphs\n */\n get flowGraphs() {\n return this._flowGraphs;\n }\n /**\n * Get an observable that will be notified when the event with the given id is fired.\n * @param id the id of the event\n * @returns the observable for the event\n */\n getCustomEventObservable(id) {\n let observable = this._customEventsMap.get(id);\n if (!observable) {\n observable = new Observable();\n this._customEventsMap.set(id, observable);\n }\n return observable;\n }\n /**\n * Notifies the observable for the given event id with the given data.\n * @param id the id of the event\n * @param data the data to send with the event\n */\n notifyCustomEvent(id, data) {\n const observable = this._customEventsMap.get(id);\n if (observable) {\n observable.notifyObservers(data);\n }\n }\n}\n/**\n * @internal\n * A list of all the coordinators per scene. Will be used by the inspector\n */\nFlowGraphCoordinator.SceneCoordinators = new Map();","map":{"version":3,"names":["Observable","FlowGraph","defaultValueParseFunction","FlowGraphCoordinator","constructor","config","_FlowGraphCoordinator","_flowGraphs","_customEventsMap","Map","scene","onDisposeObservable","add","dispose","coordinators","SceneCoordinators","get","push","createGraph","graph","coordinator","removeGraph","index","indexOf","splice","start","forEach","_FlowGraphCoordinator2","length","serialize","serializationObject","valueSerializeFunction","serializedGraph","Parse","serializedObject","options","_options$valueParseFu","_serializedObject$_fl","valueParseFunction","pathConverter","flowGraphs","getCustomEventObservable","id","observable","set","notifyCustomEvent","data","notifyObservers"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FlowGraph/flowGraphCoordinator.js"],"sourcesContent":["import { Observable } from \"../Misc/observable.js\";\nimport { FlowGraph } from \"./flowGraph.js\";\nimport { defaultValueParseFunction } from \"./serialization.js\";\n/**\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\n */\nexport class FlowGraphCoordinator {\n constructor(\n /**\n * the configuration of the block\n */\n config) {\n this.config = config;\n this._flowGraphs = [];\n this._customEventsMap = new Map();\n // When the scene is disposed, dispose all graphs currently running on it.\n this.config.scene.onDisposeObservable.add(() => {\n this.dispose();\n });\n // Add itself to the SceneCoordinators list for the Inspector.\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\n coordinators.push(this);\n }\n /**\n * Creates a new flow graph and adds it to the list of existing flow graphs\n * @returns a new flow graph\n */\n createGraph() {\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });\n this._flowGraphs.push(graph);\n return graph;\n }\n /**\n * Removes a flow graph from the list of existing flow graphs and disposes it\n * @param graph the graph to remove\n */\n removeGraph(graph) {\n const index = this._flowGraphs.indexOf(graph);\n if (index !== -1) {\n graph.dispose();\n this._flowGraphs.splice(index, 1);\n }\n }\n /**\n * Starts all graphs\n */\n start() {\n this._flowGraphs.forEach((graph) => graph.start());\n }\n /**\n * Disposes all graphs\n */\n dispose() {\n this._flowGraphs.forEach((graph) => graph.dispose());\n this._flowGraphs.length = 0;\n // Remove itself from the SceneCoordinators list for the Inspector.\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\n const index = coordinators.indexOf(this);\n if (index !== -1) {\n coordinators.splice(index, 1);\n }\n }\n /**\n * Serializes this coordinator to a JSON object.\n * @param serializationObject the object to serialize to\n * @param valueSerializeFunction the function to use to serialize the value\n */\n serialize(serializationObject, valueSerializeFunction) {\n serializationObject._flowGraphs = [];\n this._flowGraphs.forEach((graph) => {\n const serializedGraph = {};\n graph.serialize(serializedGraph, valueSerializeFunction);\n serializationObject._flowGraphs.push(serializedGraph);\n });\n }\n /**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\n static Parse(serializedObject, options) {\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n serializedObject._flowGraphs?.forEach((serializedGraph) => {\n FlowGraph.Parse(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter });\n });\n return coordinator;\n }\n /**\n * Gets the list of flow graphs\n */\n get flowGraphs() {\n return this._flowGraphs;\n }\n /**\n * Get an observable that will be notified when the event with the given id is fired.\n * @param id the id of the event\n * @returns the observable for the event\n */\n getCustomEventObservable(id) {\n let observable = this._customEventsMap.get(id);\n if (!observable) {\n observable = new Observable();\n this._customEventsMap.set(id, observable);\n }\n return observable;\n }\n /**\n * Notifies the observable for the given event id with the given data.\n * @param id the id of the event\n * @param data the data to send with the event\n */\n notifyCustomEvent(id, data) {\n const observable = this._customEventsMap.get(id);\n if (observable) {\n observable.notifyObservers(data);\n }\n }\n}\n/**\n * @internal\n * A list of all the coordinators per scene. Will be used by the inspector\n */\nFlowGraphCoordinator.SceneCoordinators = new Map();\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,yBAAyB,QAAQ,oBAAoB;AAC9D;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAC9BC,WAAWA;EACX;AACJ;AACA;EACIC,MAAM,EAAE;IAAA,IAAAC,qBAAA;IACJ,IAA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