1import{_ as Y}from"./BDZsAkX8.js";import{g as I,c as l,m as s,n as B,o as i,C,q as T,k as E,a as e,d as k,t as p,b as S,D as L,F as O,w as R,r as V,p as $}from"./DDfpvU8e.js";import{f as M}from"./z33KNcP6.js";import{f as U,u as P}from"./C6RDAlVY.js";const K=["viewBox","width","height"],q=["points","stroke"],z=["cx","cy","fill"],H=I({__name:"Sparkline",props:{values:{},width:{default:160},height:{default:40},stroke:{default:"currentColor"},fill:{default:"none"}},setup(g){const d=g,v=C(()=>{const n=d.values;if(n.length===0)return{points:"",area:"",endX:0,endY:0};if(n.length===1){const f=d.height/2;return{points:`0,${f} ${d.width},${f}`,area:"",endX:d.width,endY:f}}const h=Math.min(...n),y=Math.max(...n)-h||1,m=2,j=d.height-m*2,b=d.width/(n.length-1),x=n.map((f,N)=>{const F=N*b,D=m+(1-(f-h)/y)*j;return`${F.toFixed(1)},${D.toFixed(1)}`}),_=x[x.length-1].split(",");return{points:x.join(" "),area:`${x[0].split(",")[0]},${d.height} ${x.join(" ")} ${_[0]},${d.height}`,endX:parseFloat(_[0]),endY:parseFloat(_[1])}}),A=C(()=>{const n=d.values;return n.length<2?null:n[n.length-1]>=n[0]});return(n,h)=>(i(),l("svg",{viewBox:`0 0 ${g.width} ${g.height}`,width:g.width,height:g.height,preserveAspectRatio:"none",style:{display:"inline-block","vertical-align":"middle"}},[s(v).points?(i(),l("polyline",{key:0,points:s(v).points,fill:"none",stroke:s(A)===!1?"#f87171":g.stroke,"stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,q)):B("",!0),s(v).points?(i(),l("circle",{key:1,cx:s(v).endX,cy:s(v).endY,r:"2.5",fill:s(A)===!1?"#f87171":g.stroke},null,8,z)):B("",!0)],8,K))}}),G={class:"mb-5 flex flex-wrap items-end justify-between gap-3"},J={key:0,class:"mt-1 flex flex-wrap items-end gap-4"},Q={class:"font-mono text-4xl font-bold tracking-tight",style:{color:"var(--skin-text)"}},W={key:0,class:"flex items-end gap-2"},Z={key:1,class:"font-mono text-[10px] opacity-60"},tt={key:0,class:"text-sm opacity-70"},et={key:1,class:"rounded-lg border p-4 text-sm opacity-80",style:{"border-color":"color-mix(in srgb, var(--skin-border) 70%, transparent)"}},st={key:2,class:"space-y-4"},nt={class:"flex flex-wrap items-center justify-between gap-2"},ot={class:"ml-2 font-mono text-[10px] uppercase tracking-wider opacity-60"},at={class:"font-mono text-sm"},lt={key:0,class:"mt-2 text-xs opacity-60"},it={key:1,class:"mt-3 w-full text-sm"},rt={class:"py-1 pr-3 font-mono"},ct={class:"py-1 pr-3 text-right font-mono"},dt={class:"py-1 pr-3 text-right font-mono opacity-80"},ut={class:"py-1 pr-3 text-right font-mono"},pt={class:"py-1 pr-3 font-mono text-[11px] opacity-70"},vt=I({__name:"index",async setup(g){let d,v;const n=T().params.orgId,h=$([]),w=$({}),y=$({}),m=$({}),j=$([]),b=$(!0);async function x(){b.value=!0;try{const[a,t]=await Promise.all([$fetch(`/api/orgs/${n}/accounts`),$fetch(`/api/orgs/${n}/assets`)]);h.value=a.accounts,w.value=Object.fromEntries(t.assets.map(u=>[u.id,u]));const c=await Promise.all(h.value.map(async u=>{const X=await $fetch(`/api/orgs/${n}/accounts/${u.id}/holdings`);return[u.id,X.holdings]}));y.value=Object.fromEntries(c);const o=[...new Set(Object.values(y.value).flat().map(u=>u.asset_id))];if(o.length>0){const u=await $fetch(`/api/orgs/${n}/prices?assetIds=${o.join(",")}`);m.value=u.prices}else m.value={};$fetch(`/api/orgs/${n}/snapshot`,{method:"POST"}).catch(()=>null);const r=await $fetch(`/api/orgs/${n}/snapshots?days=7`).catch(()=>({snapshots:[]}));j.value=r.snapshots}finally{b.value=!1}}const _=C(()=>j.value.map(a=>Number(a.total_usd))),f=C(()=>{const a=_.value;if(a.length<2)return{pct:null,direction:"flat"};const t=a[0],c=a[a.length-1];if(t===0)return{pct:null,direction:c>0?"up":"flat"};const o=(c-t)/t*100;return{pct:o,direction:o>.01?"up":o<-.01?"down":"flat"}});[d,v]=E(()=>x()),await d,v();function N(a){const t=w.value[a.asset_id];return t?P(a.raw_balance,t.decimals,m.value[a.asset_id]??null):null}function F(a){const t=y.value[a]||[];let c=0,o=!1;for(const r of t){const u=N(r);u!==null&&(c+=u,o=!0)}return o?c:t.length===0?0:null}const D=C(()=>{let a=0,t=!1;for(const c of h.value){const o=F(c.id);o!==null&&(a+=o,t=!0)}return t?a:h.value.length===0?0:null});return(a,t)=>{const c=Y;return i(),l("div",null,[e("div",G,[e("div",null,[t[1]||(t[1]=e("h1",{class:"text-xl font-bold",style:{color:"var(--skin-accent)"}},"Overview",-1)),b.value?B("",!0):(i(),l("div",J,[e("p",Q,[k(p(s(U)(s(D)))+" ",1),t[0]||(t[0]=e("span",{class:"ml-2 align-middle font-sans text-xs uppercase tracking-wider opacity-60"},"portfolio",-1))]),s(_).length>=2?(i(),l("div",W,[S(H,{values:s(_),width:160,height:40,stroke:s(f).direction==="down"?"#f87171":"var(--skin-accent)",style:{opacity:"0.95"}},null,8,["values","stroke"]),e("span",{class:"font-mono text-xs",style:L({color:s(f).direction==="down"?"#f87171":"var(--skin-accent)"})},[s(f).pct!==null?(i(),l(O,{key:0},[k(p(s(f).pct>=0?"+":"")+p(s(f).pct.toFixed(2))+"% · 7d ",1)],64)):B("",!0)],4)])):j.value.length===1?(i(),l("span",Z," history starts now · sparkline will fill in over the next several visits ")):B("",!0)]))]),S(c,{to:`/orgs/${s(n)}/accounts`,class:"rounded border px-2 py-1 text-xs",style:{"border-color":"color-mix(in srgb, var(--skin-border) 60%, transparent)"}},{default:R(()=>[...t[2]||(t[2]=[k(" Manage accounts ",-1)])]),_:1},8,["to"])]),b.value?(i(),l("p",tt,"Loadingâ¦")):h.value.length===0?(i(),l("div",et,[t[4]||(t[4]=k(" No accounts yet. ",-1)),S(c,{to:`/orgs/${s(n)}/accounts`,class:"underline"},{default:R(()=>[...t[3]||(t[3]=[k("Create one",-1)])]),_:1},8,["to"]),t[5]||(t[5]=k(" to start tracking balances. ",-1))])):(i(),l("div",st,[(i(!0),l(O,null,V(h.value,o=>(i(),l("div",{key:o.id,class:"rounded-lg border p-4",style:{"border-color":"color-mix(in srgb, var(--skin-border) 70%, transparent)",background:"color-mix(in srgb, var(--skin-panel) 90%, var(--skin-bg) 10%)"}},[e("div",nt,[e("div",null,[S(c,{to:`/orgs/${s(n)}/accounts/${o.id}`,class:"font-semibold underline-offset-2 hover:underline"},{default:R(()=>[k(p(o.label),1)]),_:2},1032,["to"]),e("span",ot,p(o.kind)+" · "+p(o.custody_kind),1)]),e("div",at,p(s(U)(F(o.id))),1)]),(y.value[o.id]||[]).length===0?(i(),l("div",lt," No holdings. ")):(i(),l("table",it,[t[6]||(t[6]=e("thead",null,[e("tr",{class:"text-left font-mono text-[10px] uppercase tracking-wider opacity-60"},[e("th",{class:"py-1 pr-3"},"Asset"),e("th",{class:"py-1 pr-3 text-right"},"Balance"),e("th",{class:"py-1 pr-3 text-right"},"USD price"),e("th",{class:"py-1 pr-3 text-right"},"USD value"),e("th",{class:"py-1 pr-3"},"Chain")])],-1)),e("tbody",null,[(i(!0),l(O,null,V(y.value[o.id],r=>(i(),l("tr",{key:r.asset_id},[e("td",rt,p(w.value[r.asset_id]?.symbol||r.asset_id),1),e("td",ct,p(s(M)(r.raw_balance,w.value[r.asset_id]?.decimals??0)),1),e("td",dt,p(m.value[r.asset_id]!==void 0&&m.value[r.asset_id]!==null?s(U)(m.value[r.asset_id]):"â"),1),e("td",ut,p(s(U)(N(r))),1),e("td",pt,p(w.value[r.asset_id]?.chain_id||"?"),1)]))),128))])]))]))),128))]))])}}});
1export{vt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.