define ["https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/graphviz.umd.js"],
(hpccWasm) ->
render = (value, id, showDownloadLink) ->
hpccWasm.Graphviz.load().then (graphviz) ->
svg = graphviz.dot value
div = document.getElementById id
layout = graphviz.layout(value, "svg", "dot")
div.innerHTML = layout
if showDownloadLink
link = document.getElementById (id + "-download")
link.setAttribute "href", "data:image/svg+xml;charset=utf-8," + encodeURIComponent(layout)
return render