const sparnatural=document.querySelector("spar-natural"),queryString=window.location.search,urlParams=new URLSearchParams(queryString),lang=urlParams.get("lang");console.log("init sparnatural..."),sparnatural.addEventListener("init",(e=>{sparnatural.configuration={headers:{"User-Agent":"This is Sparnatural calling"},autocomplete:{maxItems:40}}})),sparnatural.addEventListener("queryUpdated",(e=>{var a=sparnatural.expandSparql(e.detail.queryString);yasqe.setValue(a),document.getElementById("query-json").value=JSON.stringify(e.detail.queryJson);for(const a in yasr.plugins)yasr.plugins[a].notifyQuery&&yasr.plugins[a].notifyQuery(e.detail.queryJson)})),sparnatural.addEventListener("submit",(e=>{sparnatural.disablePlayBtn(),yasqe.query()})),console.log("init yasr & yasqe...");const yasqe=new Yasqe(document.getElementById("yasqe"),{requestConfig:{endpoint:$("#endpoint").text()},copyEndpointOnNewTab:!1});Yasr.registerPlugin("TableX",SparnaturalYasguiPlugins.TableX),Yasr.registerPlugin("Map",SparnaturalYasguiPlugins.MapPlugin),delete Yasr.plugins.table;const yasr=new Yasr(document.getElementById("yasr"),{pluginOrder:["TableX","Response","Map"],defaultPlugin:"TableX",getUsedPrefixes:yasqe.getPrefixesFromQuery,drawOutputSelector:!1,drawDownloadIcon:!1,persistency:{prefix:!1,results:{key:!1}}});yasqe.on("queryResponse",(function(e,a,n){yasr.setResponse(a,n),sparnatural.enablePlayBtn()})),document.getElementById("switch-language").onclick=function(){document.querySelector("spar-natural").setAttribute("lang","en"),sparnatural.display()},document.getElementById("export").onclick=function(){var e=JSON.stringify(JSON.parse(document.getElementById("query-json").value),null,2);$("#export-json").val(e),$("#exportModal").modal("show")},document.getElementById("load").onclick=function(){$("#loadModal").modal("show")},document.getElementById("loadJson").onclick=function(){sparnatural.loadQuery(JSON.parse(document.getElementById("load-json").value)),$("#loadModal").modal("hide")},document.getElementById("clear").onclick=function(){sparnatural.clear()};