@abi-software/simulationvuer 3.0.10 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/simulationvuer.js +1689 -1678
- package/dist/simulationvuer.umd.cjs +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/SimulationVuer.vue +44 -1
|
@@ -4783,5 +4783,5 @@ The action could not be handled.`,life:Ia})}},G=pe.computed(()=>{var ce;return((
|
|
|
4783
4783
|
|
|
4784
4784
|
${Jn(Yt(vt))}`,life:Ia}),Se==null||Se.fileIssue(Te)}).finally(()=>{Ee&&(v.value=!1)})})},X=ce=>{const ee=ce.target;if(ee.files)for(const ie of ee.files)_(ie);ee.value=""},oe=pe.ref(0),le=()=>{!C.value||n.omex||++oe.value},ge=ce=>{var ie;if(!oe.value)return;oe.value=0;const ee=(ie=ce.dataTransfer)==null?void 0:ie.files;if(ee)for(const De of Array.from(ee))_(De)},be=()=>{oe.value&&(oe.value-=1)};Se==null||Se.onOpen(ce=>{_(ce)});const Be=()=>{var ce;n.omex||((ce=d.value)==null||ce.click())},ye=pe.ref(!1);Se==null||Se.onOpenRemote(()=>{ye.value=!0});const Pe=()=>{n.omex||(ye.value=!0)},rt=ce=>{_(ce)};Se==null||Se.onOpenSampleLorenz(()=>{ut()});const ut=()=>{n.omex||_("https://github.com/opencor/webapp/raw/refs/heads/main/tests/models/ui/lorenz.omex")};Se==null||Se.onClose(()=>{Ze()});const Ze=()=>{var ce;n.omex||((ce=f.value)==null||ce.closeCurrentFile())};Se==null||Se.onCloseAll(()=>{kt()});const kt=()=>{var ce;n.omex||((ce=f.value)==null||ce.closeAllFiles())},I=pe.ref(!1);Se==null||Se.onResetAll(()=>{I.value=!0});const ae=()=>{Se==null||Se.resetAll()};Se==null||Se.onSelect(ce=>{var ee;(ee=f.value)==null||ee.selectFile(ce)}),pe.onMounted(()=>{var ee;const ce=(ee=c.value)==null?void 0:ee.$el;setTimeout(()=>{S()},Hs),setTimeout(()=>{const ie=document.getElementById(re.value);ie&&ce&&ie.parentElement!==ce&&ce.appendChild(ie)},Hs)});let me=null;return pe.onMounted(()=>{B.value&&pe.nextTick(()=>{var ie,De;const ce=(ie=l.value)==null?void 0:ie.$el,ee=(De=c.value)==null?void 0:De.$el;ce&&ee&&(me=ife(ce,ee,"--main-menu-height"))})}),pe.onBeforeUnmount(()=>{me&&(me(),me=null)}),n.omex?pe.watch(b,ce=>{!ce&&n.omex&&_(n.omex)}):pe.onMounted(()=>{setTimeout(()=>{Se?Se.checkForUpdates(!0):pe.watch(b,ce=>{if(!ce){const ee=Dde("action","");window.location.search?(ee.value=window.location.search.substring(1),window.location.hash&&(ee.value+=window.location.hash),window.history.replaceState({},document.title,window.location.pathname),window.location.reload()):ee.value&&setTimeout(()=>{ee.value.startsWith(Z3)?$(ee.value.slice(Z3.length)):H({severity:"error",summary:"Handling an action",detail:`${ee.value}
|
|
4785
4785
|
|
|
4786
|
-
The action could not be handled.`,life:Ia}),ee.value=""},Hs)}})},Hs)}),(ce,ee)=>{const ie=lS,De=oS,Te=Oc,Ee=Aee,Re=See,Bt=uee,vt=see,dt=aee,yt=YX,Xt=zX,lr=CX,Nr=JY;return a.openBlock(),a.createBlock(a.unref(gS),{ref_key:"blockUiRef",ref:c,class:a.normalizeClass(["opencor overflow-hidden h-full",a.unref(B)?"with-main-menu":""]),blocked:a.unref(E),onClick:S,onFocus:S,onFocusin:S,onKeydown:S,onMousedown:S},{default:a.withCtx(()=>[a.createVNode(ie,{id:a.unref(re),class:a.normalizeClass(a.unref(w)?"visible":"invisible"),group:a.unref(re),"pt:root:style":{position:"absolute"}},null,8,["id","class","group"]),a.withDirectives(a.createVNode(De,null,null,512),[[a.vShow,a.unref(D)]]),a.unref(m).length?(a.openBlock(),a.createBlock(Te,{key:0,class:"m-4",style:{height:"calc(100% - 2rem)"},issues:a.unref(m)},null,8,["issues"])):(a.openBlock(),a.createElementBlock("div",{key:1,class:"h-full flex flex-col",onDragenter:le,onDragover:ee[16]||(ee[16]=a.withModifiers(()=>{},["prevent"])),onDrop:a.withModifiers(ge,["prevent"]),onDragleave:be},[a.createElementVNode("input",{ref_key:"filesRef",ref:d,type:"file",multiple:"",style:{display:"none"},onChange:X},null,544),a.withDirectives(a.createVNode(Ee,null,null,512),[[a.vShow,a.unref(oe)]]),a.unref(B)?(a.openBlock(),a.createBlock(Gye,{key:0,ref_key:"mainMenuRef",ref:l,isActive:a.unref(w),uiEnabled:a.unref(C),hasFiles:a.unref(G),onAbout:xe,onOpen:Be,onOpenRemote:Pe,onOpenSampleLorenz:ut,onClose:Ze,onCloseAll:kt,onSettings:W,onUpdateAvailable:L},null,8,["isActive","uiEnabled","hasFiles"])):a.createCommentVNode("",!0),a.createVNode(Eye,{ref_key:"contentsRef",ref:f,class:"grow min-h-0",isActive:a.unref(w),uiEnabled:a.unref(C),simulationOnly:!!ce.omex,onError:Me,onSimulationData:s},null,8,["isActive","uiEnabled","simulationOnly"]),a.withDirectives(a.createVNode(Re,{message:"Initialising OpenCOR...",progress:ES.value},null,8,["progress"]),[[a.vShow,a.unref(b)]]),a.withDirectives(a.createVNode(Re,{message:"Loading model..."},null,512),[[a.vShow,a.unref(v)]]),a.withDirectives(a.createVNode(Re,{message:a.unref(R),progress:a.unref(A)},null,8,["message","progress"]),[[a.vShow,a.unref(O)]]),a.createVNode(Bt,{visible:a.unref(K),"onUpdate:visible":ee[0]||(ee[0]=wt=>a.isRef(K)?K.value=wt:null),title:a.unref(q),message:a.unref(V),onOk:J},null,8,["visible","title","message"]),a.createVNode(vt,{visible:a.unref(se),"onUpdate:visible":ee[1]||(ee[1]=wt=>a.isRef(se)?se.value=wt:null),title:"Check for Updates...",question:"Version "+a.unref(fe)+" is available. Do you want to download it and install it?",onYes:ve,onNo:ee[2]||(ee[2]=wt=>se.value=!1)},null,8,["visible","question"]),a.createVNode(dt,{visible:a.unref(Y),"onUpdate:visible":ee[3]||(ee[3]=wt=>a.isRef(Y)?Y.value=wt:null),percent:a.unref(ue)},null,8,["visible","percent"]),a.createVNode(Bt,{visible:a.unref(ke),"onUpdate:visible":ee[4]||(ee[4]=wt=>a.isRef(ke)?ke.value=wt:null),title:"Check for Updates...",message:"No updates are available at this time.",onOk:ee[5]||(ee[5]=wt=>ke.value=!1)},null,8,["visible"]),a.createVNode(yt,{visible:a.unref(ye),"onUpdate:visible":ee[6]||(ee[6]=wt=>a.isRef(ye)?ye.value=wt:null),onOpenRemote:rt,onClose:ee[7]||(ee[7]=wt=>ye.value=!1)},null,8,["visible"]),a.createVNode(Xt,{visible:a.unref(Ae),"onUpdate:visible":ee[8]||(ee[8]=wt=>a.isRef(Ae)?Ae.value=wt:null),onClose:ee[9]||(ee[9]=wt=>Ae.value=!1)},null,8,["visible"]),a.createVNode(vt,{visible:a.unref(I),"onUpdate:visible":ee[10]||(ee[10]=wt=>a.isRef(I)?I.value=wt:null),title:"Reset All...",question:"You are about to reset all of your settings. Do you want to proceed?",severity:"danger",onYes:ae,onNo:ee[11]||(ee[11]=wt=>I.value=!1)},null,8,["visible"]),a.createVNode(lr,{visible:a.unref(we),"onUpdate:visible":ee[12]||(ee[12]=wt=>a.isRef(we)?we.value=wt:null),onClose:ee[13]||(ee[13]=wt=>we.value=!1)},null,8,["visible"]),a.createVNode(Nr,{visible:a.unref(ne),"onUpdate:visible":ee[14]||(ee[14]=wt=>a.isRef(ne)?ne.value=wt:null),onClose:ee[15]||(ee[15]=wt=>ne.value=!1)},null,8,["visible"])],32))]),_:1},8,["class","blocked"])}}}),Jye=wo(Kye,[["__scopeId","data-v-a3d59cde"]]),m5="https://models.physiomeproject.org/",Yye=pp(BC,{}),ea=Object.freeze({DATASET_ID:"dataset_id",DATASET_URL:"dataset_url",PMR_PATH:"pmr_path",RAW_COMBINE_ARCHIVE:"raw_combine_archive"});function Xye(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}const ewe={name:"SimulationVuer",components:{PlotVuer:Ua.PlotVuer,SimulationVuerInput:TC,ElButton:mv,ElDivider:vv,ElLoading:PA,OpenCOR:Jye},props:{apiLocation:{required:!0,type:String},id:{required:!0,type:[Number,String,Uint8Array]}},data:function(){let e;if(typeof this.id=="number"?e=ea.DATASET_ID:this.id instanceof Uint8Array?e=ea.RAW_COMBINE_ARCHIVE:Xye(this.id)?e=ea.DATASET_URL:e=ea.PMR_PATH,e===ea.DATASET_ID){const t=new XMLHttpRequest;t.open("GET",this.apiLocation+"/sim/dataset/"+this.id),t.onreadystatechange=()=>{if(t.readyState===4&&t.status===200){const r=JSON.parse(t.responseText);this.name=r.name,this.uuid=r.study!==void 0?r.study.uuid:void 0}},t.send()}return{errorMessage:"",fileManager:void 0,hasFinalisedUi:!1,hasValidSimulationUiInfo:!1,idType:e,instance:void 0,isMounted:!1,isSimulationValid:!0,layout:[],model:void 0,name:null,opencorBasedSimulation:!0,opencorOmexFile:null,output:void 0,perfectScollbarOptions:{suppressScrollX:!0},showUserMessage:!1,simulationResults:{},simulationResultsId:{},simulationUiInfo:{},solver:void 0,userMessage:"",ui:null,uuid:null,activeSubscriptions:[]}},methods:{addDataSubscription(e){var c,l,d,f;if(!e||typeof e!="object"){console.error("addDataSubscription: subscription must be an object.");return}const t="nz.ac.auckland.simulation-data-request",r=0;if(e.id!==t){console.warn(`addDataSubscription: invalid ID (expected '${t}' but got '${e.id}').`);return}if(typeof e.version!="string"){console.warn(`addDataSubscription: missing or non-string version ('${e.version}').`);return}const n=e.version.split(".");if(n.length<1||!/^[0-9]+$/.test(n[0])){console.warn(`addDataSubscription: malformed version ('${e.version}').`);return}const i=parseInt(n[0],10);if(Number.isNaN(i)){console.warn(`addDataSubscription: could not parse the major version from ('${e.version}')`);return}if(i!==r){console.warn(`addDataSubscription: version mismatch (expected v${r}.y.z but got v${e.version}).`);return}const o=e.payload||{},s=[];if(o.windowId==null&&s.push("windowId"),o.ownerId==null&&s.push("ownerId"),o.component||s.push("component"),o.variable||s.push("variable"),s.length){console.warn(`addDataSubscription: payload missing fields: ${s.join(", ")}.`);return}this.activeSubscriptions.push(o);const u=[];(c=e.payload)!=null&&c.withVOI&&u.push("VOI"),u.push(`${(l=e.payload)==null?void 0:l.component}/${(d=e.payload)==null?void 0:d.variable}`),(f=this.$refs.opencorRef)==null||f.trackSimulationData(u)},removeDataSubscription(e){this.activeSubscriptions=this.activeSubscriptions.filter(t=>t.windowId!==e)},onSimulationData(e){const t=e.simulationData||{};let r;this.activeSubscriptions.forEach(n=>{const i=`${n.component}/${n.variable}`;if(t[i]==null){console.warn(`onSimulationData: no data for ${i}.`);return}const o={y:Array.from(t[i]),title:`${n.component}.${n.variable}`};if(n.withVOI)if(t.VOI==null){console.warn("onSimulationData: no data for VOI.");return}else r??(r=Array.from(t.VOI)),o.x=r;this.$emit("data-notification",{id:"nz.ac.auckland.simulation-data-response",version:"0.1.0",payload:{windowId:n.windowId,ownerId:n.ownerId,data:o}})})},plotMetadata(e){return{version:"1.1.0",type:"plot",attrs:{style:"timeseries",layout:this.layout[e]}}},buildSimulationUi(e){if(this.simulationUiInfo=e,this.hasValidSimulationUiInfo=oK(this.simulationUiInfo),!this.hasValidSimulationUiInfo){this.errorMessage="the simulation.json file is malformed";return}if(this.simulationUiInfo.simulation.solvers.forEach(r=>{(r.if===void 0||mp(this,r.if))&&(this.solver=r)}),this.solver===void 0){this.hasValidSimulationUiInfo=!1,this.errorMessage="no solver name and/or solver version specified";return}this.opencorBasedSimulation=this.solver.name===DC,this.simulationUiInfo.output.data.forEach(r=>{this.simulationResultsId[r.id]=r.name});let t=-1;this.simulationUiInfo.output.plots.forEach(r=>{++t,this.layout[t]={paper_bgcolor:"rgba(0, 0, 0, 0)",plot_bgcolor:"rgba(0, 0, 0, 0)",autosize:!0,margin:{t:25,l:55,r:25,b:30,pad:4},loading:!1,options:{responsive:!0,scrollZoom:!0},dragmode:"pan",xaxis:{title:{text:r.xAxisTitle,font:{size:10}}},yaxis:{title:{text:r.yAxisTitle,font:{size:10}}}}}),this.$nextTick(()=>{AC(this)})},runOnOsparc(){window.open(`https://osparc.io/study/${this.uuid}`,"_blank")},viewDataset(){window.open(`https://sparc.science/datasets/${this.id}?type=dataset`,"_blank")},viewWorkspace(){const e=m5+this.id;window.open(e.substring(0,e.lastIndexOf("/")),"_blank")},parametersData(){const e={};return this.simulationUiInfo.parameters.forEach(t=>{e[t.name]=mp(this,t.value)}),e},outputData(){return this.output===void 0&&this.simulationUiInfo.output.data!==void 0&&(this.output=[],this.simulationUiInfo.output.data.forEach(e=>{this.output.push(e.name)})),this.output},retrieveRequest(){const e={solver:this.solver};if(this.opencorBasedSimulation){e.opencor={model_url:this.simulationUiInfo.simulation.opencor.resource,json_config:{}},this.simulationUiInfo.simulation.opencor.endingPoint!==void 0&&this.simulationUiInfo.simulation.opencor.pointInterval!==void 0&&(e.opencor.json_config.simulation={"Ending point":this.simulationUiInfo.simulation.opencor.endingPoint,"Point interval":this.simulationUiInfo.simulation.opencor.pointInterval}),e.opencor.json_config.parameters=this.parametersData();const t=this.outputData();t!==void 0&&(e.opencor.json_config.output=t)}else e.osparc={},e.osparc.job_inputs=this.parametersData();return e},processSimulationResults(e){if(typeof e=="string"){const n=/[ \t]+/g,i=e.trim().split(`
|
|
4787
|
-
`),o=i[0].trim().split(n).length;e={};for(let u=0;u<o;++u)e[u]=[];let s=-1;i.forEach(u=>{++s;let c=-1;u.trim().split(n).forEach(d=>{e[++c][s]=Number(d)})})}const t=new Yye.parser;Object.keys(this.simulationResultsId).forEach(n=>{t.set(n,e[this.simulationResultsId[n]])});let r=-1;this.simulationUiInfo.output.plots.forEach(n=>{this.simulationResults[++r]=[{x:t.evaluate(n.xValue),y:t.evaluate(n.yValue),type:"scatter"}]})},showHttpIssue(e){this.isSimulationValid=!1,this.showUserMessage=!1,this.errorMessage=e.statusText.toLowerCase()+" (<a href='https://httpstatuses.com/"+e.status+"/' target='_blank'>"+e.status+"</a>)"},checkSimulation(e){const t=new XMLHttpRequest;t.open("POST",this.apiLocation+"/check_simulation"),t.setRequestHeader("Content-type","application/json"),t.onreadystatechange=()=>{if(t.readyState===4)if(t.status===200){let r=JSON.parse(t.responseText);if(this.isSimulationValid=r.status==="ok",this.isSimulationValid)if(r.results!==void 0)this.showUserMessage=!1,this.processSimulationResults(r.results);else{let n=this;setTimeout(function(){n.checkSimulation(e)},1e3)}else this.showUserMessage=!1,this.errorMessage=r.description}else this.showHttpIssue(t)},t.send(JSON.stringify(e))},startSimulation(){this.userMessage="Loading simulation results...",this.showUserMessage=!0,this.$nextTick(()=>{this.simulationResults={};const e=new XMLHttpRequest;e.open("POST",this.apiLocation+"/start_simulation"),e.setRequestHeader("Content-type","application/json"),e.onreadystatechange=()=>{if(e.readyState===4)if(e.status===200){let t=JSON.parse(e.responseText);this.isSimulationValid=t.status==="ok",this.isSimulationValid?this.checkSimulation(t.data):(this.showUserMessage=!1,this.errorMessage=t.description)}else this.showHttpIssue(e)},e.send(JSON.stringify(this.retrieveRequest()))})}},created:function(){this.idType===ea.DATASET_ID?(this.userMessage="Retrieving UI information...",this.showUserMessage=!0,this.$nextTick(()=>{const e=new XMLHttpRequest;e.open("GET",this.apiLocation+"/simulation_ui_file/"+this.id),e.onreadystatechange=()=>{e.readyState===4&&(this.showUserMessage=!1,e.status===200?this.$nextTick(()=>{this.buildSimulationUi(JSON.parse(e.responseText))}):this.errorMessage="the simulation dataset could not be retrieved")},e.send()})):this.idType===ea.DATASET_URL?this.opencorOmexFile=this.id:this.idType===ea.PMR_PATH?this.opencorOmexFile=m5+this.id:this.opencorOmexFile=this.id},mounted:function(){this.isMounted=!0,AC(this)}},twe=["element-loading-text"],rwe={key:0,class:"container"},nwe={key:0,class:"default error"},owe={key:1,class:"main"},awe={class:"default name"},iwe={class:"input scrollbar"},swe={class:"buttons-container"},lwe={class:"primary-button"},uwe={key:0,class:"secondary-button"},cwe={class:"secondary-button"},dwe={key:1,class:"default note"},fwe={class:"main-right",ref:"output"},pwe={class:"main-right"},mwe={class:"default error"},hwe=["innerHTML"],gwe={key:1,class:"opencor"};function vwe(e,t,r,n,i,o){const s=vv,u=TC,c=mv,l=a.resolveComponent("PlotVuer"),d=a.resolveComponent("OpenCOR"),f=nf;return a.withDirectives((a.openBlock(),a.createElementBlock("div",{class:"simulation-vuer","element-loading-text":e.userMessage},[e.opencorOmexFile===null?(a.openBlock(),a.createElementBlock("div",rwe,[!e.hasValidSimulationUiInfo&&!e.showUserMessage?(a.openBlock(),a.createElementBlock("p",nwe,[t[4]||(t[4]=a.createElementVNode("span",{class:"error"},"Error:",-1)),a.createTextVNode(" "+a.toDisplayString(e.errorMessage)+".",1)])):a.createCommentVNode("",!0),e.hasValidSimulationUiInfo?(a.openBlock(),a.createElementBlock("div",owe,[a.createElementVNode("div",{class:a.normalizeClass(["main-left",{"with-buttons":e.uuid}])},[a.createElementVNode("p",awe,a.toDisplayString(e.name),1),a.createVNode(s),t[8]||(t[8]=a.createElementVNode("p",{class:"default input-parameters"},"Input parameters",-1)),a.createElementVNode("div",iwe,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.simulationUiInfo.input,(p,m)=>(a.openBlock(),a.createBlock(u,{ref_for:!0,ref:"simInput",defaultValue:p.defaultValue,key:`input-${m}`,name:p.name,maximumValue:p.maximumValue,minimumValue:p.minimumValue,possibleValues:p.possibleValues,stepValue:p.stepValue},null,8,["defaultValue","name","maximumValue","minimumValue","possibleValues","stepValue"]))),128))]),a.createElementVNode("div",swe,[a.createElementVNode("div",lwe,[a.createVNode(c,{type:"primary",size:"small",onClick:t[0]||(t[0]=p=>o.startSimulation())},{default:a.withCtx(()=>[...t[5]||(t[5]=[a.createTextVNode("Run Simulation",-1)])]),_:1})]),e.uuid?(a.openBlock(),a.createElementBlock("div",uwe,[a.createVNode(c,{size:"small",onClick:t[1]||(t[1]=p=>o.runOnOsparc())},{default:a.withCtx(()=>[...t[6]||(t[6]=[a.createTextVNode("Run on oSPARC",-1)])]),_:1})])):a.createCommentVNode("",!0),a.createElementVNode("div",cwe,[a.createVNode(c,{size:"small",onClick:t[2]||(t[2]=p=>o.viewDataset())},{default:a.withCtx(()=>[...t[7]||(t[7]=[a.createTextVNode("View Dataset",-1)])]),_:1})]),e.uuid?(a.openBlock(),a.createElementBlock("p",dwe,"Additional parameters are available on oSPARC")):a.createCommentVNode("",!0)])],2),a.withDirectives(a.createElementVNode("div",fwe,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.simulationUiInfo.output.plots,(p,m)=>(a.openBlock(),a.createBlock(l,{key:`output-${m}`,metadata:o.plotMetadata(m),"data-source":{data:e.simulationResults[m]},plotLayout:e.layout[m],plotType:"plotly-only",selectorUi:!1},null,8,["metadata","data-source","plotLayout"]))),128))],512),[[a.vShow,e.isSimulationValid]]),a.withDirectives(a.createElementVNode("div",pwe,[a.createElementVNode("p",mwe,[t[9]||(t[9]=a.createElementVNode("span",{class:"error"},"Error:",-1)),t[10]||(t[10]=a.createTextVNode()),a.createElementVNode("span",{innerHTML:e.errorMessage},null,8,hwe),t[11]||(t[11]=a.createTextVNode(".",-1))])],512),[[a.vShow,!e.isSimulationValid]])])):a.createCommentVNode("",!0)])):(a.openBlock(),a.createElementBlock("div",gwe,[a.createVNode(d,{ref:"opencorRef",omex:e.opencorOmexFile,theme:"light",onSimulationData:t[3]||(t[3]=p=>o.onSimulationData(p))},null,8,["omex"])]))],8,twe)),[[f,e.showUserMessage]])}const bwe=xC(ewe,[["render",vwe],["__scopeId","data-v-
|
|
4786
|
+
The action could not be handled.`,life:Ia}),ee.value=""},Hs)}})},Hs)}),(ce,ee)=>{const ie=lS,De=oS,Te=Oc,Ee=Aee,Re=See,Bt=uee,vt=see,dt=aee,yt=YX,Xt=zX,lr=CX,Nr=JY;return a.openBlock(),a.createBlock(a.unref(gS),{ref_key:"blockUiRef",ref:c,class:a.normalizeClass(["opencor overflow-hidden h-full",a.unref(B)?"with-main-menu":""]),blocked:a.unref(E),onClick:S,onFocus:S,onFocusin:S,onKeydown:S,onMousedown:S},{default:a.withCtx(()=>[a.createVNode(ie,{id:a.unref(re),class:a.normalizeClass(a.unref(w)?"visible":"invisible"),group:a.unref(re),"pt:root:style":{position:"absolute"}},null,8,["id","class","group"]),a.withDirectives(a.createVNode(De,null,null,512),[[a.vShow,a.unref(D)]]),a.unref(m).length?(a.openBlock(),a.createBlock(Te,{key:0,class:"m-4",style:{height:"calc(100% - 2rem)"},issues:a.unref(m)},null,8,["issues"])):(a.openBlock(),a.createElementBlock("div",{key:1,class:"h-full flex flex-col",onDragenter:le,onDragover:ee[16]||(ee[16]=a.withModifiers(()=>{},["prevent"])),onDrop:a.withModifiers(ge,["prevent"]),onDragleave:be},[a.createElementVNode("input",{ref_key:"filesRef",ref:d,type:"file",multiple:"",style:{display:"none"},onChange:X},null,544),a.withDirectives(a.createVNode(Ee,null,null,512),[[a.vShow,a.unref(oe)]]),a.unref(B)?(a.openBlock(),a.createBlock(Gye,{key:0,ref_key:"mainMenuRef",ref:l,isActive:a.unref(w),uiEnabled:a.unref(C),hasFiles:a.unref(G),onAbout:xe,onOpen:Be,onOpenRemote:Pe,onOpenSampleLorenz:ut,onClose:Ze,onCloseAll:kt,onSettings:W,onUpdateAvailable:L},null,8,["isActive","uiEnabled","hasFiles"])):a.createCommentVNode("",!0),a.createVNode(Eye,{ref_key:"contentsRef",ref:f,class:"grow min-h-0",isActive:a.unref(w),uiEnabled:a.unref(C),simulationOnly:!!ce.omex,onError:Me,onSimulationData:s},null,8,["isActive","uiEnabled","simulationOnly"]),a.withDirectives(a.createVNode(Re,{message:"Initialising OpenCOR...",progress:ES.value},null,8,["progress"]),[[a.vShow,a.unref(b)]]),a.withDirectives(a.createVNode(Re,{message:"Loading model..."},null,512),[[a.vShow,a.unref(v)]]),a.withDirectives(a.createVNode(Re,{message:a.unref(R),progress:a.unref(A)},null,8,["message","progress"]),[[a.vShow,a.unref(O)]]),a.createVNode(Bt,{visible:a.unref(K),"onUpdate:visible":ee[0]||(ee[0]=wt=>a.isRef(K)?K.value=wt:null),title:a.unref(q),message:a.unref(V),onOk:J},null,8,["visible","title","message"]),a.createVNode(vt,{visible:a.unref(se),"onUpdate:visible":ee[1]||(ee[1]=wt=>a.isRef(se)?se.value=wt:null),title:"Check for Updates...",question:"Version "+a.unref(fe)+" is available. Do you want to download it and install it?",onYes:ve,onNo:ee[2]||(ee[2]=wt=>se.value=!1)},null,8,["visible","question"]),a.createVNode(dt,{visible:a.unref(Y),"onUpdate:visible":ee[3]||(ee[3]=wt=>a.isRef(Y)?Y.value=wt:null),percent:a.unref(ue)},null,8,["visible","percent"]),a.createVNode(Bt,{visible:a.unref(ke),"onUpdate:visible":ee[4]||(ee[4]=wt=>a.isRef(ke)?ke.value=wt:null),title:"Check for Updates...",message:"No updates are available at this time.",onOk:ee[5]||(ee[5]=wt=>ke.value=!1)},null,8,["visible"]),a.createVNode(yt,{visible:a.unref(ye),"onUpdate:visible":ee[6]||(ee[6]=wt=>a.isRef(ye)?ye.value=wt:null),onOpenRemote:rt,onClose:ee[7]||(ee[7]=wt=>ye.value=!1)},null,8,["visible"]),a.createVNode(Xt,{visible:a.unref(Ae),"onUpdate:visible":ee[8]||(ee[8]=wt=>a.isRef(Ae)?Ae.value=wt:null),onClose:ee[9]||(ee[9]=wt=>Ae.value=!1)},null,8,["visible"]),a.createVNode(vt,{visible:a.unref(I),"onUpdate:visible":ee[10]||(ee[10]=wt=>a.isRef(I)?I.value=wt:null),title:"Reset All...",question:"You are about to reset all of your settings. Do you want to proceed?",severity:"danger",onYes:ae,onNo:ee[11]||(ee[11]=wt=>I.value=!1)},null,8,["visible"]),a.createVNode(lr,{visible:a.unref(we),"onUpdate:visible":ee[12]||(ee[12]=wt=>a.isRef(we)?we.value=wt:null),onClose:ee[13]||(ee[13]=wt=>we.value=!1)},null,8,["visible"]),a.createVNode(Nr,{visible:a.unref(ne),"onUpdate:visible":ee[14]||(ee[14]=wt=>a.isRef(ne)?ne.value=wt:null),onClose:ee[15]||(ee[15]=wt=>ne.value=!1)},null,8,["visible"])],32))]),_:1},8,["class","blocked"])}}}),Jye=wo(Kye,[["__scopeId","data-v-a3d59cde"]]),m5="https://models.physiomeproject.org/",Yye=pp(BC,{}),ea=Object.freeze({DATASET_ID:"dataset_id",DATASET_URL:"dataset_url",PMR_PATH:"pmr_path",RAW_COMBINE_ARCHIVE:"raw_combine_archive"});function Xye(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}const ewe={name:"SimulationVuer",components:{PlotVuer:Ua.PlotVuer,SimulationVuerInput:TC,ElButton:mv,ElDivider:vv,ElLoading:PA,OpenCOR:Jye},props:{apiLocation:{required:!0,type:String},id:{required:!0,type:[Number,String,Uint8Array]}},data:function(){let e;if(typeof this.id=="number"?e=ea.DATASET_ID:this.id instanceof Uint8Array?e=ea.RAW_COMBINE_ARCHIVE:Xye(this.id)?e=ea.DATASET_URL:e=ea.PMR_PATH,e===ea.DATASET_ID){const t=new XMLHttpRequest;t.open("GET",this.apiLocation+"/sim/dataset/"+this.id),t.onreadystatechange=()=>{if(t.readyState===4&&t.status===200){const r=JSON.parse(t.responseText);this.name=r.name,this.uuid=r.study!==void 0?r.study.uuid:void 0}},t.send()}return{errorMessage:"",fileManager:void 0,hasFinalisedUi:!1,hasValidSimulationUiInfo:!1,idType:e,instance:void 0,isMounted:!1,isSimulationValid:!0,layout:[],model:void 0,name:null,opencorBasedSimulation:!0,opencorOmexFile:null,output:void 0,perfectScollbarOptions:{suppressScrollX:!0},showUserMessage:!1,simulationResults:{},simulationResultsId:{},simulationUiInfo:{},solver:void 0,userMessage:"",ui:null,uuid:null,activeSubscriptions:[]}},methods:{addDataSubscription(e){var c,l,d,f;if(!e||typeof e!="object"){console.error("addDataSubscription: subscription must be an object.");return}const t="nz.ac.auckland.simulation-data-request",r=0;if(e.id!==t){console.warn(`addDataSubscription: invalid ID (expected '${t}' but got '${e.id}').`);return}if(typeof e.version!="string"){console.warn(`addDataSubscription: missing or non-string version ('${e.version}').`);return}const n=e.version.split(".");if(n.length<1||!/^[0-9]+$/.test(n[0])){console.warn(`addDataSubscription: malformed version ('${e.version}').`);return}const i=parseInt(n[0],10);if(Number.isNaN(i)){console.warn(`addDataSubscription: could not parse the major version from ('${e.version}')`);return}if(i!==r){console.warn(`addDataSubscription: version mismatch (expected v${r}.y.z but got v${e.version}).`);return}const o=e.payload||{},s=[];if(o.windowId==null&&s.push("windowId"),o.ownerId==null&&s.push("ownerId"),o.component||s.push("component"),o.variable||s.push("variable"),s.length){console.warn(`addDataSubscription: payload missing fields: ${s.join(", ")}.`);return}this.activeSubscriptions.push(o);const u=[];(c=e.payload)!=null&&c.withVOI&&u.push("VOI"),u.push(`${(l=e.payload)==null?void 0:l.component}/${(d=e.payload)==null?void 0:d.variable}`),(f=this.$refs.opencorRef)==null||f.trackSimulationData(u)},removeDataSubscription(e){var i;const t=this.activeSubscriptions.find(o=>o.windowId===e);if(!t){console.warn(`removeDataSubscription: no active subscription found for id ${e}.`);return}const r=this.activeSubscriptions.some(o=>o.windowId!==e&&o.withVOI),n=this.activeSubscriptions.some(o=>o.windowId!==e&&o.component===t.component&&o.variable===t.variable);if(!r||!n){const o=[];t.withVOI&&!r&&o.push("VOI"),n||o.push(`${t.component}/${t.variable}`),o.length&&((i=this.$refs.opencorRef)==null||i.untrackSimulationData(o))}this.activeSubscriptions=this.activeSubscriptions.filter(o=>o.windowId!==e)},onSimulationData(e){const t=e.simulationData||{};let r;this.activeSubscriptions.forEach(n=>{const i=`${n.component}/${n.variable}`;if(t[i]==null){console.warn(`onSimulationData: no data for ${i}.`);return}const o={y:Array.from(t[i]),title:`${n.component}.${n.variable}`};if(n.withVOI)if(t.VOI==null){console.warn("onSimulationData: no data for VOI.");return}else r??(r=Array.from(t.VOI)),o.x=r;this.$emit("data-notification",{id:"nz.ac.auckland.simulation-data-response",version:"0.1.0",payload:{windowId:n.windowId,ownerId:n.ownerId,data:o}})})},plotMetadata(e){return{version:"1.1.0",type:"plot",attrs:{style:"timeseries",layout:this.layout[e]}}},buildSimulationUi(e){if(this.simulationUiInfo=e,this.hasValidSimulationUiInfo=oK(this.simulationUiInfo),!this.hasValidSimulationUiInfo){this.errorMessage="the simulation.json file is malformed";return}if(this.simulationUiInfo.simulation.solvers.forEach(r=>{(r.if===void 0||mp(this,r.if))&&(this.solver=r)}),this.solver===void 0){this.hasValidSimulationUiInfo=!1,this.errorMessage="no solver name and/or solver version specified";return}this.opencorBasedSimulation=this.solver.name===DC,this.simulationUiInfo.output.data.forEach(r=>{this.simulationResultsId[r.id]=r.name});let t=-1;this.simulationUiInfo.output.plots.forEach(r=>{++t,this.layout[t]={paper_bgcolor:"rgba(0, 0, 0, 0)",plot_bgcolor:"rgba(0, 0, 0, 0)",autosize:!0,margin:{t:25,l:55,r:25,b:30,pad:4},loading:!1,options:{responsive:!0,scrollZoom:!0},dragmode:"pan",xaxis:{title:{text:r.xAxisTitle,font:{size:10}}},yaxis:{title:{text:r.yAxisTitle,font:{size:10}}}}}),this.$nextTick(()=>{AC(this)})},runOnOsparc(){window.open(`https://osparc.io/study/${this.uuid}`,"_blank")},viewDataset(){window.open(`https://sparc.science/datasets/${this.id}?type=dataset`,"_blank")},viewWorkspace(){const e=m5+this.id;window.open(e.substring(0,e.lastIndexOf("/")),"_blank")},parametersData(){const e={};return this.simulationUiInfo.parameters.forEach(t=>{e[t.name]=mp(this,t.value)}),e},outputData(){return this.output===void 0&&this.simulationUiInfo.output.data!==void 0&&(this.output=[],this.simulationUiInfo.output.data.forEach(e=>{this.output.push(e.name)})),this.output},retrieveRequest(){const e={solver:this.solver};if(this.opencorBasedSimulation){e.opencor={model_url:this.simulationUiInfo.simulation.opencor.resource,json_config:{}},this.simulationUiInfo.simulation.opencor.endingPoint!==void 0&&this.simulationUiInfo.simulation.opencor.pointInterval!==void 0&&(e.opencor.json_config.simulation={"Ending point":this.simulationUiInfo.simulation.opencor.endingPoint,"Point interval":this.simulationUiInfo.simulation.opencor.pointInterval}),e.opencor.json_config.parameters=this.parametersData();const t=this.outputData();t!==void 0&&(e.opencor.json_config.output=t)}else e.osparc={},e.osparc.job_inputs=this.parametersData();return e},processSimulationResults(e){if(typeof e=="string"){const n=/[ \t]+/g,i=e.trim().split(`
|
|
4787
|
+
`),o=i[0].trim().split(n).length;e={};for(let u=0;u<o;++u)e[u]=[];let s=-1;i.forEach(u=>{++s;let c=-1;u.trim().split(n).forEach(d=>{e[++c][s]=Number(d)})})}const t=new Yye.parser;Object.keys(this.simulationResultsId).forEach(n=>{t.set(n,e[this.simulationResultsId[n]])});let r=-1;this.simulationUiInfo.output.plots.forEach(n=>{this.simulationResults[++r]=[{x:t.evaluate(n.xValue),y:t.evaluate(n.yValue),type:"scatter"}]})},showHttpIssue(e){this.isSimulationValid=!1,this.showUserMessage=!1,this.errorMessage=e.statusText.toLowerCase()+" (<a href='https://httpstatuses.com/"+e.status+"/' target='_blank'>"+e.status+"</a>)"},checkSimulation(e){const t=new XMLHttpRequest;t.open("POST",this.apiLocation+"/check_simulation"),t.setRequestHeader("Content-type","application/json"),t.onreadystatechange=()=>{if(t.readyState===4)if(t.status===200){let r=JSON.parse(t.responseText);if(this.isSimulationValid=r.status==="ok",this.isSimulationValid)if(r.results!==void 0)this.showUserMessage=!1,this.processSimulationResults(r.results);else{let n=this;setTimeout(function(){n.checkSimulation(e)},1e3)}else this.showUserMessage=!1,this.errorMessage=r.description}else this.showHttpIssue(t)},t.send(JSON.stringify(e))},startSimulation(){this.userMessage="Loading simulation results...",this.showUserMessage=!0,this.$nextTick(()=>{this.simulationResults={};const e=new XMLHttpRequest;e.open("POST",this.apiLocation+"/start_simulation"),e.setRequestHeader("Content-type","application/json"),e.onreadystatechange=()=>{if(e.readyState===4)if(e.status===200){let t=JSON.parse(e.responseText);this.isSimulationValid=t.status==="ok",this.isSimulationValid?this.checkSimulation(t.data):(this.showUserMessage=!1,this.errorMessage=t.description)}else this.showHttpIssue(e)},e.send(JSON.stringify(this.retrieveRequest()))})}},created:function(){this.idType===ea.DATASET_ID?(this.userMessage="Retrieving UI information...",this.showUserMessage=!0,this.$nextTick(()=>{const e=new XMLHttpRequest;e.open("GET",this.apiLocation+"/simulation_ui_file/"+this.id),e.onreadystatechange=()=>{e.readyState===4&&(this.showUserMessage=!1,e.status===200?this.$nextTick(()=>{this.buildSimulationUi(JSON.parse(e.responseText))}):this.errorMessage="the simulation dataset could not be retrieved")},e.send()})):this.idType===ea.DATASET_URL?this.opencorOmexFile=this.id:this.idType===ea.PMR_PATH?this.opencorOmexFile=m5+this.id:this.opencorOmexFile=this.id},mounted:function(){this.isMounted=!0,AC(this)}},twe=["element-loading-text"],rwe={key:0,class:"container"},nwe={key:0,class:"default error"},owe={key:1,class:"main"},awe={class:"default name"},iwe={class:"input scrollbar"},swe={class:"buttons-container"},lwe={class:"primary-button"},uwe={key:0,class:"secondary-button"},cwe={class:"secondary-button"},dwe={key:1,class:"default note"},fwe={class:"main-right",ref:"output"},pwe={class:"main-right"},mwe={class:"default error"},hwe=["innerHTML"],gwe={key:1,class:"opencor"};function vwe(e,t,r,n,i,o){const s=vv,u=TC,c=mv,l=a.resolveComponent("PlotVuer"),d=a.resolveComponent("OpenCOR"),f=nf;return a.withDirectives((a.openBlock(),a.createElementBlock("div",{class:"simulation-vuer","element-loading-text":e.userMessage},[e.opencorOmexFile===null?(a.openBlock(),a.createElementBlock("div",rwe,[!e.hasValidSimulationUiInfo&&!e.showUserMessage?(a.openBlock(),a.createElementBlock("p",nwe,[t[4]||(t[4]=a.createElementVNode("span",{class:"error"},"Error:",-1)),a.createTextVNode(" "+a.toDisplayString(e.errorMessage)+".",1)])):a.createCommentVNode("",!0),e.hasValidSimulationUiInfo?(a.openBlock(),a.createElementBlock("div",owe,[a.createElementVNode("div",{class:a.normalizeClass(["main-left",{"with-buttons":e.uuid}])},[a.createElementVNode("p",awe,a.toDisplayString(e.name),1),a.createVNode(s),t[8]||(t[8]=a.createElementVNode("p",{class:"default input-parameters"},"Input parameters",-1)),a.createElementVNode("div",iwe,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.simulationUiInfo.input,(p,m)=>(a.openBlock(),a.createBlock(u,{ref_for:!0,ref:"simInput",defaultValue:p.defaultValue,key:`input-${m}`,name:p.name,maximumValue:p.maximumValue,minimumValue:p.minimumValue,possibleValues:p.possibleValues,stepValue:p.stepValue},null,8,["defaultValue","name","maximumValue","minimumValue","possibleValues","stepValue"]))),128))]),a.createElementVNode("div",swe,[a.createElementVNode("div",lwe,[a.createVNode(c,{type:"primary",size:"small",onClick:t[0]||(t[0]=p=>o.startSimulation())},{default:a.withCtx(()=>[...t[5]||(t[5]=[a.createTextVNode("Run Simulation",-1)])]),_:1})]),e.uuid?(a.openBlock(),a.createElementBlock("div",uwe,[a.createVNode(c,{size:"small",onClick:t[1]||(t[1]=p=>o.runOnOsparc())},{default:a.withCtx(()=>[...t[6]||(t[6]=[a.createTextVNode("Run on oSPARC",-1)])]),_:1})])):a.createCommentVNode("",!0),a.createElementVNode("div",cwe,[a.createVNode(c,{size:"small",onClick:t[2]||(t[2]=p=>o.viewDataset())},{default:a.withCtx(()=>[...t[7]||(t[7]=[a.createTextVNode("View Dataset",-1)])]),_:1})]),e.uuid?(a.openBlock(),a.createElementBlock("p",dwe,"Additional parameters are available on oSPARC")):a.createCommentVNode("",!0)])],2),a.withDirectives(a.createElementVNode("div",fwe,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.simulationUiInfo.output.plots,(p,m)=>(a.openBlock(),a.createBlock(l,{key:`output-${m}`,metadata:o.plotMetadata(m),"data-source":{data:e.simulationResults[m]},plotLayout:e.layout[m],plotType:"plotly-only",selectorUi:!1},null,8,["metadata","data-source","plotLayout"]))),128))],512),[[a.vShow,e.isSimulationValid]]),a.withDirectives(a.createElementVNode("div",pwe,[a.createElementVNode("p",mwe,[t[9]||(t[9]=a.createElementVNode("span",{class:"error"},"Error:",-1)),t[10]||(t[10]=a.createTextVNode()),a.createElementVNode("span",{innerHTML:e.errorMessage},null,8,hwe),t[11]||(t[11]=a.createTextVNode(".",-1))])],512),[[a.vShow,!e.isSimulationValid]])])):a.createCommentVNode("",!0)])):(a.openBlock(),a.createElementBlock("div",gwe,[a.createVNode(d,{ref:"opencorRef",omex:e.opencorOmexFile,theme:"light",onSimulationData:t[3]||(t[3]=p=>o.onSimulationData(p))},null,8,["omex"])]))],8,twe)),[[f,e.showUserMessage]])}const bwe=xC(ewe,[["render",vwe],["__scopeId","data-v-0ebfcd41"]]);Ht.SimulationVuer=bwe,Object.defineProperty(Ht,Symbol.toStringTag,{value:"Module"})});
|