/** * Viz.js 3.4.0 (Graphviz 2.47.0, Expat 2.2.10, Emscripten 2.0.15) * @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT licensed * * This distribution contains other software in object code form: * - [Emscripten](https://github.com/emscripten-core/emscripten/blob/master/LICENSE) * - [Expat](https://github.com/libexpat/libexpat/blob/master/expat/COPYING) * - [Graphviz](https://graphviz.org/license/) */ class e{constructor(e){this._listeners=[];this._nextId=0;this._executing=0;this._worker=e;this._isNodeWorker="function"===typeof e.ref;if(this._isNodeWorker){this._worker.on("message",(e=>this._eventListener({data:e})));this._worker.on("error",(e=>this._listeners.forEach((r=>r(e)))))}else{this._worker.addEventListener("message",(e=>this._eventListener(e)))}}_eventListener(e){const{id:r,error:t,result:s}=e.data;this._listeners[r](t,s);delete this._listeners[r];if(this._isNodeWorker&&--this._executing===0){this._worker.unref()}}render(e,r){return new Promise(((t,s)=>{const i=this._nextId++;if(this._isNodeWorker&&this._executing++===0){this._worker.ref()}this._listeners[i]=function(e,r){if(e){const r=new Error(e.message);if(e.fileName)r.fileName=e.fileName;if(e.lineNumber)r.lineNumber=e.lineNumber;return s(r)}t(r)};this._worker.postMessage({id:i,src:e,options:r})}))}terminate(){return this._worker.terminate()}}class r{constructor(r){if(!r)r={};if(typeof r.workerURL!=="undefined"){this._wrapper=new e(new Worker(r.workerURL,{type:"module"}))}else if(typeof r.worker!=="undefined"){this._wrapper=new e(r.worker)}else{throw new Error("Must specify workerURL or worker option.")}}renderString(e,{format:r="svg",engine:t="dot",files:s=[],images:i=[],yInvert:n=false,nop:o=0}={}){for(const{path:e,width:r,height:t}of i){s.push({path:e,data:'\n'+'\n'+``})}return this._wrapper.render(e,{format:r,engine:t,files:s,yInvert:n,nop:o})}renderJSONObject(e,r={}){let{format:t}=r;if(!t||!t.startsWith("json")){t="json"}return this.renderString(e,{...r,format:t}).then(JSON.parse)}terminateWorker(){return this._wrapper.terminate()}}export default r;