text: async function cyrestGET(e="",t="",n=defaultBaseUrl){let o=n.concat("/",e);if(""!=t){const e=t;o=o.concat("?",e)}const a=await fetch(o,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}});return await a.json()}async function cyrestDELETE(e="",t="",n=defaultBaseUrl){let o=n.concat("/",e);if(""!=t){const e=t;o=o.concat("?",e)}const a=await fetch(o,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json"}});return await a.text()}async function cyrestPOST(e="",t="",n={},o=defaultBaseUrl){let a=o.concat("/",e);if(""!=t){const e=t;a=a.concat("?",e)}const s=JSON.stringify(n),c=await fetch(a,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:s});return await c.json()}async function cyrestPUT(e="",t="",n={},o=defaultBaseUrl){let a=o.concat("/",e);if(""!=t){const e=t;a=a.concat("?",e)}const s=JSON.stringify(n),c=await fetch(a,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json"},body:s});return await c.json()}async function commandsGET(e,t=defaultBaseUrl){const n=command2getQuery(e,t),o=await fetch(n,{method:"GET",headers:{Accept:"text/plain","Content-Type":"text/plain"}});return await o.text()}async function commandsRun(e,t=defaultBaseUrl){commandsGET(e,t=t)}async function commandsPOST(e,t=defaultBaseUrl){const n=command2PostQueryUrl(e,t);let o=command2PostQueryBody(e);o=JSON.stringify(o);const a=await fetch(n,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:o});return await a.text()}function command2getQuery(e,t=defaultBaseUrl){let n=e.replace(/\ [A-Za-z0-9_-]*=/g,"XXXXXX$&").split("XXXXXX"),o=n[0].replace(" ","/"),a=t.concat("/commands/"),s=encodeURI(a.concat(o)),c=n.slice(1).join(" "),l="",r=[],i=[];if(void 0!==c&&0!=c.length){const e=/[A-Za-z0-9_-]+=/g;r=(r=(c=c.replace(/['"]+/g,"")).match(e)).map(function(e){return e.replace(/=/g,"")});const t=/\ *[A-Za-z0-9_-]+=/g;i=c.split(t).slice(1),l=r[0]+"="+encodeURI(i[0]);for(var u=1;u<r.length;u++){l=l+"&"+(r[u]+"="+encodeURI(i[u]))}return s+"?"+l}return s}function command2PostQueryUrl(e,t=defaultBaseUrl){let n=e.replace(/\ [A-Za-z0-9_-]*=/g,"XXXXXX$&").split("XXXXXX")[0].replace(" ","/"),o=t.concat("/commands/");return encodeURI(o.concat(n))}function command2PostQueryBody(e){let t=e.replace(/\ [A-Za-z0-9_-]*=/g,"XXXXXX$&").split("XXXXXX").slice(1).join(" "),n={},o=[],a=[];if(void 0!==t&&0!=t.length){const e=/[A-Za-z0-9_-]+=/g;o=(o=(t=t.replace(/['"]+/g,"")).match(e)).map(function(e){return e.replace(/=/g,"")});const s=/\ *[A-Za-z0-9_-]+=/g;return a=t.split(s).slice(1),o.forEach((e,t)=>n[e]=a[t]),n}return n={atLeastOneArg:"required"}}async function setCurrentNetwork(e=null,t=defaultBaseUrl){commandsPOST('network set current network=SUID:"'+await getNetworkSuid(e,t)+'"',t=t)}async function renameNetwork(e,t=null,n=defaultBaseUrl){commandsPOST('network rename name="'+e+'" sourceNetwork=SUID:"'+await getNetworkSuid(t,n)+'""',n)}async function getNetworkCount(e=defaultBaseUrl){let t=cyrestGET("networks/count",e),n=t.then(e=>{console.log(e.count)});return n=t.then(e=>e.count)}async function deleteNetwork(e=null,t=defaultBaseUrl){cyrestDELETE("networks/"+await getNetworkSuid(e,t),t=t);console.log("Selected network is deleted.")}async function deleteAllNetworks(e=defaultBaseUrl){cyrestDELETE("networks",e=e);console.log("All networks are deleted.")}async function getNetworkSuid(e=null,t=defaultBaseUrl){let n;if("string"==typeof e||e instanceof String)if("current"==e)n=e;else{(await getNetworkList(t=t)).includes(e)?n=e:console.log("Network does not exist: "+e)}else if("number"==typeof e){if((await cyrestGET("networks",t=t)).includes(e))return console.log(e),e;console.log("Network does not exist: "+e)}else n="current";let o=commandsPOST('network get attribute network="'+n+'" namespace="default" columnList="SUID"',t=t),a=o.then(e=>{console.log("Network suid: "+JSON.parse(e).data[0].SUID)});return a=o.then(e=>JSON.parse(e).data[0].SUID)}async function getNetworkList(e=defaultBaseUrl){if(0==await getNetworkCount(e))return console.log([]),[];let t=await cyrestGET("networks",e=e),n=[];for(const e of t){let t=(await cyrestGET("networks/"+e.toString())).data.name;n.push(t)}return console.log(n),n}async function cytoscapeVersionInfo(e=defaultBaseUrl){let t=cyrestGET("version",e=e);t.then(e=>{console.log("apiVersion: "+e.apiVersion)}),t.then(e=>{console.log("cytoscapeVersion: "+e.cytoscapeVersion)})}async function cytoscapeMemoryStatus(e=defaultBaseUrl){cyrestGET("","",e=e).then(e=>{console.log(e.memoryStatus)})}async function importNetworkFromNDEX(e=e,t,n,o){const a={serverUrl:e,uuid:t,username:n,password:o},s=CYREST_BASE_URL+"/cyndex2/v1/networks";console.log("Calling CyREST POST:",s);const c=await fetch(s,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)}),l=await c.json();console.log("Response JSON: "+JSON.stringify(l));const r=l.data.suid;return console.log("network SUID: "+r),r}async function exportNetworkToNDEx(e=e,t,n,o,a="current",s=null){const c={serverUrl:e,username:t,password:n,metadata:s,isPublic:o};let l=await getNetworkSuid(a=a);console.log(l);const r=CYREST_BASE_URL+"/cyndex2/v1/networks/"+l;console.log("Calling CyREST POST:",r);const i=await fetch(r,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(c)}),u=await i.json();console.log("Response JSON: "+JSON.stringify(u));const d=u.data.suid;return console.log("network SUID: "+d),d}const defaultBaseUrl="http://127.0.0.1:1234/v1",serverUrl="https://ndexbio.org/v2",CYREST_BASE_URL="http://127.0.0.1:1234";let ndex,disabledButton;function displayCX(e,t){const n=document.getElementById(t),o=new cytoscapeCx2js.CyNetworkUtils,a=o.rawCXtoNiceCX(e),s=new cytoscapeCx2js.CxToJs(o);let c={};const l=s.cyElementsFromNiceCX(a,c),r=s.cyStyleFromNiceCX(a,c),i=s.cyBackgroundColorFromNiceCX(a),u=s.getDefaultLayout(),d=s.cyZoomFromNiceCX(a),p=s.cyPanFromNiceCX(a);n.style.backgroundColor=i,cytoscape({container:n,style:r,elements:l,layout:u,zoom:d,pan:p}).fit()}function initNdexClient(){ndex=new ndexClient.NDEx(serverUrl)}function displayNDExCX(e,t){initNdexClient(),ndex.getRawNetwork(e).then(e=>{displayCX(e,t)})}function displayLocalCX(e,t){initNdexClient(),fetch(e).then(function(e){return e.json()}).then(e=>{displayCX(e,t)})}async function checkCytoscape(){try{await cyrestGET("version");disabledButton=!1}catch(e){disabledButton=!0}const e=document.getElementById("cytobutton");disabledButton&&(e.disabled="disabled"),disabledButton&&(document.getElementById("cytobutton").innerText="Download Cytoscape"),disabledButton&&document.getElementById("cytobutton").setAttribute("title","Download Cytoscape")}async function getAvailableApps(e=defaultBaseUrl){commandsGET("apps list available",e=e).then(e=>{console.log("Available apps: "+e)})}async function getInstalledApps(e=defaultBaseUrl){commandsGET("apps list installed",e=e).then(e=>{console.log("Installed apps: "+e)})}async function getDisabledApps(e=defaultBaseUrl){commandsGET("apps list disabled",e=e).then(e=>{console.log("Disabled apps: "+e)})}async function getAppUpdates(e=defaultBaseUrl){commandsGET("apps list updates",e=e)}async function openAppStore(e,t=defaultBaseUrl){commandsGET("apps open appstore app='"+e+"'",t=t)}async function getFilterList(e=defaultBaseUrl){commandsPOST("filter list",e=e).then(e=>{console.log("Filter list: "+JSON.stringify(JSON.parse(e).data))})}async function analyzeNetwork(e=!1,t=defaultBaseUrl){commandsPOST("analyzer analyze directed="+e,t=t).then(e=>{console.log("Analyze network: "+JSON.stringify(JSON.parse(e).data))})}async function getNetworkViews(e=null,t=defaultBaseUrl){let n=cyrestGET("networks/"+await getNetworkSuid(e,t)+"/views",t);n.then(e=>{console.log("Network views suid: "+e)});return n}async function getNetworkViewsSuid(e=null,t=defaultBaseUrl){let n=await getNetworkSuid(e,t);return await getNetworkViews(n,t)}async function fitContent(e=!1,t=null,n=defaultBaseUrl){let o=await getNetworkViewsSuid(t,n);commandsPOST(1==e?"view fit selected view=SUID:"+o:"view fit content view=SUID:"+o,n)}async function setCurrentView(e=null,t=defaultBaseUrl){commandsPOST('view set current view=SUID:"'+await getNetworkViewsSuid(e,t)+'"',t=t)}async function getVisualStyleNames(e=defaultBaseUrl){let t=await cyrestGET("apply/styles",e);return console.log(t),t}async function getCurrentStyle(e=null,t=defaultBaseUrl){let n=await getNetworkSuid(e,t),o=await getNetworkViewsSuid(n,t),a=await cyrestGET("networks/"+n+"/views/"+o+"/currentStyle",t);return console.log(a.title),a.title}async function getArrowShapes(e=defaultBaseUrl){let t=await cyrestGET("styles/visualproperties/EDGE_TARGET_ARROW_SHAPE/values",e);return console.log(t.values),t.values}async function getLineStyles(e=defaultBaseUrl){let t=await cyrestGET("styles/visualproperties/EDGE_LINE_TYPE/values",e);return console.log(t.values),t.values}async function getNodeShapes(e=defaultBaseUrl){let t=await cyrestGET("styles/visualproperties/NODE_SHAPE/values",e);return console.log(t.values),t.values}