import{d as w,P as L,o as s,n as i,w as t,a as e,s as T,cf as U,N as S,cy as C,e as m,V as v,b as I,f as d,c,t as f,M as N,u as R,bg as O,c7 as $,c8 as g,l as B,cO as E,A as M,p as P,q as F,ca as b,cs as j,cP as A,v as _,g as D,i as V,k as x,cQ as y,r as k,F as h,c9 as z,z as K}from"./index-Jv7TaKWs.js";import{_ as W,a as q}from"./ImportDialog-B7DrvLkQ.js";function Q(p){let n;try{n=new URL(p)}catch{return!1}return n.protocol==="http:"||n.protocol==="https:"}const G={key:0},H={key:1},Y=w({__name:"BackendSettings",props:{store:{}},setup(p){const n=p,a=L(()=>n.store),l=u=>{u||((a.value.state.url==null||a.value.state.url.length===0)&&a.value.resetURL(),a.value.ping())};return(u,o)=>(s(),i(N,{class:"mt-1"},{default:t(()=>[e(S,{class:"d-flex justify-center",cols:"2"},{default:t(()=>[T("div",null,[e(U,{inset:"",title:"Enable backend",modelValue:a.value.state.enabled,"onUpdate:modelValue":o[0]||(o[0]=r=>a.value.state.enabled=r)},null,8,["modelValue"])])]),_:1}),e(S,{cols:"10"},{default:t(()=>[e(C,{disabled:!a.value.state.enabled,"hide-details":a.value.state.response.data.length===0,placeholder:a.value.defaults,rules:[r=>r.length===0||m(Q)(r)||"URL is not valid"],"onUpdate:focused":l,class:"my-2",density:"compact",label:"URL of backend","persistent-placeholder":"",modelValue:a.value.state.url,"onUpdate:modelValue":o[2]||(o[2]=r=>a.value.state.url=r),variant:"outlined"},{append:t(()=>[e(v,{onClick:o[1]||(o[1]=r=>a.value.ping()),variant:"outlined"},{append:t(()=>[e(I,{color:a.value.isOK?"green":"red",icon:"mdi:mdi-circle"},null,8,["color"])]),default:t(()=>[d(" ping ")]),_:1})]),details:t(()=>[a.value.isOK&&a.value.isValid?(s(),c("span",G," Response: "+f(a.value.state.response.data),1)):(s(),c("span",H," Error: "+f(a.value.state.error),1))]),_:1},8,["disabled","hide-details","placeholder","rules","modelValue"])]),_:1})]),_:1}))}}),Z=w({__name:"StoreList",props:{modelDBStore:{},modelStore:{},projectDBStore:{},projectStore:{},simulator:{}},setup(p){const n=R(),a=O("project");return(l,u)=>(s(),i(K,{class:"mt-2"},{default:t(()=>[e(W,{modelDBStore:l.modelDBStore,projectDBStore:l.projectDBStore,activator:"#import-dialog"},null,8,["modelDBStore","projectDBStore"]),e(q,{modelDBStore:l.modelDBStore,projectDBStore:l.projectDBStore,activator:"#export-dialog"},null,8,["modelDBStore","projectDBStore"]),e(F,{color:"transparent",density:"compact"},{extension:t(()=>[e($,{modelValue:a.value,"onUpdate:modelValue":u[0]||(u[0]=o=>a.value=o)},{default:t(()=>[e(g,{value:"project"},{default:t(()=>[d(" Project ")]),_:1}),e(g,{value:"model"},{default:t(()=>[d(" Model ")]),_:1}),e(B)]),_:1},8,["modelValue"])]),default:t(()=>[e(E,{size:"small"}),e(M,null,{default:t(()=>[d("Store list")]),_:1}),e(B),e(P,{class:"mx-2",density:"compact"},{default:t(()=>[e(v,{icon:"mdi:mdi-import",id:"import-dialog",style:{"min-width":"40px"},title:"Open dialog to import"}),e(v,{icon:"mdi:mdi-export",id:"export-dialog",style:{"min-width":"40px"},title:"Open dialog to export"})]),_:1})]),_:1}),e(z,{modelValue:a.value,"onUpdate:modelValue":u[1]||(u[1]=o=>a.value=o)},{default:t(()=>[e(b,{value:"project"},{default:t(()=>[m(n).state.devMode?(s(),i(j,{key:l.projectStore.state.projectId},{default:t(()=>[d(" Current project: "+f(m(A)(l.projectStore.state.projectId)),1)]),_:1})):_("",!0),(s(),i(D,{key:l.projectDBStore.state.projects.length,lines:"two",nav:""},{default:t(()=>[e(V,{to:{name:l.simulator+"ProjectNew"}},{prepend:t(()=>[e(I,{icon:"mdi:mdi-plus"})]),default:t(()=>[d(" New project ")]),_:1},8,["to"]),e(x),e(y,null,{default:t(()=>[d("Existing projects")]),_:1}),(s(!0),c(h,null,k(l.projectDBStore.state.projects,(o,r)=>(s(),i(V,{key:r,subtitle:`${o.network.nodes.length} nodes, ${o.network.connections.length} connections`,title:o.name,to:{name:l.simulator+"Project",params:{projectId:o.id}}},null,8,["subtitle","title","to"]))),128))]),_:1}))]),_:1}),e(b,{value:"model"},{default:t(()=>[m(n).state.devMode?(s(),i(j,{key:l.modelStore.modelId},{default:t(()=>[d(" Current model: "+f(l.modelStore.modelId),1)]),_:1})):_("",!0),(s(),i(D,{key:l.modelDBStore.state.models.length,nav:""},{default:t(()=>[e(y,null,{default:t(()=>[d("Existing models")]),_:1}),(s(!0),c(h,null,k(l.modelDBStore.state.models,(o,r)=>(s(),i(V,{key:r,subtitle:o.elementType,title:o.label,to:{name:l.simulator+"Model",params:{modelId:o.id}}},null,8,["subtitle","title","to"]))),128))]),_:1}))]),_:1})]),_:1},8,["modelValue"])]),_:1}))}});export{Y as _,Z as a};
