import{w as f,v as c,z as j}from"./chunk-QMGIS6GS-CBZUm-7V.js";import{j as t}from"./jsx-runtime-D_zvdyIk.js";import{U as u}from"./UserButton-C7P-xVhi.js";import{f as l}from"./api-tgDzxHzW.js";import{B as h}from"./polymorphic-factory-EW0USS3V.js";import{G as d}from"./Group-bnACpcuK.js";import{A as x}from"./ActionIcon-BO4DDcDR.js";import{I as v}from"./IconArrowLeft-4qKQ7vAI.js";import{T as w}from"./Title-B0fFn55O.js";import{D as I}from"./Divider-BI4N1hoX.js";import{C as S}from"./Card-BHrMkZ_V.js";import"./Avatar-BMARKXxx.js";import"./Input-I-MjqIR2.js";import"./CloseButton-BDZlzHA2.js";import"./Loader-1VreoqJz.js";import"./index-B4z8r-Ct.js";import"./events-BOd7YSSb.js";import"./Text-CkpJSrnl.js";import"./Stack-BsPYYAFq.js";import"./Button-BhC08Y9X.js";import"./createReactComponent-CwEnMXT7.js";import"./Paper-k397c_lM.js";import"./create-safe-context-CzEsa9t0.js";function V(){return[{title:"Actions | JIVAS Manager"}]}async function W({request:g}){var s,m,p;const r=localStorage.getItem("jivas-host"),a=localStorage.getItem("jivas-agent"),e=a?await l(`${r}/walker/get_agent`,{method:"POST",body:JSON.stringify({agent_id:a}),headers:{"Content-Type":"application/json"}}).then(o=>{if(o!=null&&o.ok)return o==null?void 0:o.json();throw localStorage.removeItem("jivas-agent"),c("/login")}).catch(o=>{throw console.log({err:o}),localStorage.removeItem("jivas-agent"),c("/login")}):null,n=new FormData;n.append("args",'{"base64_prefix": false}'),n.append("module_root","actions.jivas.avatar_action"),n.append("agent_id",((m=(s=e==null?void 0:e.reports)==null?void 0:s[0])==null?void 0:m.id)||""),n.append("walker","get_avatar");const i=await l(`${r}/walker/list_agents`,{method:"POST",body:JSON.stringify({}),headers:{"Content-Type":"application/json"}}).then(o=>o.json()).catch(()=>({reports:[]}));return{selectedAgentInfo:{...((p=e==null?void 0:e.reports)==null?void 0:p[0])||{},thumbnail:""},agents:i==null?void 0:i.reports}}const H=f(function({loaderData:r}){const a=localStorage.getItem("jivas-host"),e=localStorage.getItem("jivas-root-id");return t.jsxs(h,{px:"xl",children:[t.jsxs(d,{justify:"space-between",children:[t.jsxs(d,{children:[t.jsx(x,{color:"dark",size:"sm",component:j,to:"/dashboard",children:t.jsx(v,{})}),t.jsx(w,{order:3,children:"Graph"})]}),t.jsx(h,{children:t.jsx(u,{selectedAgentInfo:r.selectedAgentInfo||null,agents:r.agents})})]}),t.jsx(I,{mt:"xs",mb:"sm"}),t.jsx(S,{px:"0",py:"0",h:"86vh",withBorder:!0,pos:"relative",children:t.jsx("jvgraph-viewer",{className:"min-h-[740px]",host:a,root_node:e,style:{width:"100%",height:"100%",border:"none",outline:"none"}},r.selectedAgentInfo.id)})]})});export{W as clientLoader,H as default,V as meta};
