1import{s as e}from"./chunk-C6na_-A5.js";import{A as t,Ft as n,It as r,Ut as i}from"./chunk-gbqK2hCJ.js";import{Pn as a,nn as o,rn as s}from"./chunk-C8PGGBu6.js";import{t as c}from"./chunk-XSH7F-Af.js";import{T as l,_n as u,a as d,ft as f,qn as p,u as m,ut as h,wn as g,yn as _}from"./chunk-DQoBSWPh.js";import{$n as v,A as y,Jn as b,Nr as x,S,b as ee,cn as te,dr as C,ln as ne,n as w,pr as T,pt as E,rr as D,sn as re,tr as O,x as ie}from"./chunk-DRgJXSuW.js";import"./chunk-CeYt8s1b.js";import{N as k,O as A,T as j,c as M,s as N,u as ae}from"./chunk-BZwpnWD5.js";import{n as oe}from"./chunk-BOTkAze52.js";import{_ as P,a as F}from"./chunk-F0IhTJVt2.js";import{n as I,r as L}from"./chunk-C_OmMzFW2.js";import{n as R,t as z}from"./chunk-Cf3nvehA2.js";import{n as se}from"./chunk-gatwFetG2.js";import{t as B}from"./chunk-DeU9pgc62.js";import{t as ce}from"./chunk-CbTsmbh72.js";import{t as le}from"./chunk-B2gU548a2.js";import{c as ue,d as de,f as fe,i as V,m as pe,n as me,p as he,r as ge,t as _e,u as ve}from"./chunk-CPQYzBlC.js";import{t as ye}from"./chunk-Cnq-7Pah.js";import"./chunk-BV_IlImz2.js";import{t as be}from"./chunk-vJRcN-e7.js";import{n as xe,t as H}from"./chunk-DvGDmkN5.js";import"./chunk-CtcrPFZH.js";import{n as U}from"./chunk-B-0LNq-r2.js";import{t as Se}from"./chunk-D5n8Bor2.js";import{r as Ce}from"./chunk-Ct3AzIqw.js";import{t as we}from"./chunk-DFNdX0Ve2.js";import"./chunk-BP5DG6Hd2.js";import{u as Te}from"./chunk-CmfhakA42.js";import{t as Ee}from"./chunk-QzfNpMLf2.js";import{n as De}from"./chunk-zBq76nCq2.js";import{i as W,t as Oe}from"./chunk-D7wbxxXB2.js";import"./chunk-Cp9BKFhg2.js";var G=e(oe(),1),K=e=>e?e.reduce((e,{balance:t,meta:n,price:r})=>{let i=s(t.total.toString(),-n.decimals),a=r?i.times(r).toString():`0`;return e.plus(a)},c(0)):c(0),q=()=>{let{data:e,isLoading:t}=f(),{data:n,isLoading:r}=Ce(),{data:i,isLoading:a}=_(),{data:o,isSettled:l}=m([M.STABLESWAP,M.TOKEN,M.ERC20]),{liquidityTotal:u,farmingTotal:d,assetsTotal:p}=(0,G.useMemo)(()=>{let t=(e?.all??[]).reduce((e,t)=>(e.liquidity=e.liquidity.plus(t.data?.currentTotalDisplay??0),h(t)&&(e.farming=e.farming.plus(t.data?.currentTotalDisplay??0)),e),{liquidity:c(0),farming:c(0)}),r=n.reduce((e,t)=>(e.liquidity=e.liquidity.plus(t.currentTotalDisplay??0),e.farming=e.farming.plus(t.positions.reduce((e,t)=>{let n=s(t.shares.toString(),-t.meta.decimals).times(t.price);return e.plus(n??0)},c(0))),e),{liquidity:c(0),farming:c(0)}),i=K(o?.tokenBalances??[]),a=K(o?.erc20Balances??[]),l=K(o?.stableSwapBalances??[]);return{omnipoolLiquidity:t,assetsTotal:i.plus(a),liquidityTotal:t.liquidity.plus(l).plus(r.liquidity),farmingTotal:t.farming.plus(r.farming)}},[o,n,e?.all]);return{assets:p.toString(),isAssetsLoading:!l,liquidity:u.toString(),farms:d.toString(),isLiquidityLoading:r||t,supply:i?.totalLiquidityUSD??``,borrow:i?.totalBorrowsUSD??``,isBorrowLoading:a}},ke=()=>{let{t:e}=x([`wallet`]);return I(be,{sx:{py:`xxxl`},image:we,header:e(`wallet:myAssets.emptyState.header`),description:e(`wallet:myAssets.emptyState.description`),action:I(D,{variant:`secondary`,asChild:!0,children:L(le,{to:ye.deposit,children:[I(r,{}),e(`wallet:myAssets.emptyState.cta`)]})})})},J=(0,G.memo)(({data:e,isEmpty:t,isLoading:n,searchPhrase:r,sortingProps:i})=>!n&&t?I(ke,{}):I(V,{data:e,isLoading:n,searchPhrase:r,sortingProps:i}));J.displayName=`MyAssets`;var Ae=.01,Y=e=>e.id!==`0`&&!!e.totalDisplay&&c(e.totalDisplay).lte(Ae),je=e=>{let{isMobile:t}=P(),{native:n}=N(),{data:r,isLoading:i}=m([M.TOKEN,M.ERC20]),{assets:a,hasSmallBalances:o}=(0,G.useMemo)(()=>{if(i)return{assets:[],hasSmallBalances:!1};let e=[...r?.tokenBalances??[],...r?.erc20Balances??[]].map(({meta:e,balance:t,price:r})=>{let i=s(t?.total.toString()??`0`,-e.decimals),a=s(t?.transferable.toString()??`0`,-e.decimals),o=r?i.times(r).toString():void 0,c=r?a.times(r).toString():void 0;return{...e,origin:ae(e),total:i.toString(),totalDisplay:o,transferable:a.toString(),transferableDisplay:c,canStake:e.id===n.id,rugCheckData:void 0,reserved:t?.reserved}}).filter(e=>c(e.total).gt(0)).sort(t?me:ge);return{assets:e,hasSmallBalances:e.some(Y)}},[i,r?.tokenBalances,r?.erc20Balances,t,n.id]);return{data:(0,G.useMemo)(()=>e?a:a.filter(e=>!Y(e)),[a,e]),hasSmallBalances:o,isEmpty:a.length===0,isLoading:i}},Me=({papi:e,isReady:t},n)=>ce({queryKey:[`accountReferralShares`,n],queryFn:async()=>{let[t,r,i]=await Promise.all([e.query.Referrals.TotalShares.getValue(),e.query.Referrals.ReferrerShares.getValue(n),e.query.Referrals.TraderShares.getValue(n)]);return{referrerShares:r,traderShares:i,totalShares:t}},enabled:t&&!!n}),Ne=()=>{let e=k(),{account:n}=t(),{native:r}=N(),{data:i,isLoading:a}=B(Me(e,n?.address??``)),{data:o,isLoading:s}=B(d(e,r.id,A)),l=a||s;if(l||!i)return{isLoading:l,data:void 0};let{referrerShares:u,traderShares:f,totalShares:p}=i,m=u+f,h=o?.freeBalance??`1`,_=c(m.toString()).div(p.toString()).mul(h),v=c(u.toString()).div(p.toString()).mul(h);return{isLoading:l,data:{totalRewards:g(_.toString(),r.decimals),referrerRewards:g(v.toString(),r.decimals),symbol:r.symbol}}},X=()=>{let{native:e}=N(),{data:t,isLoading:n}=l(),r=t?.claimableRewardsUsd||0,{claimableValues:{totalUSD:i,isLoading:a}}=W(),{data:o,isLoading:s}=Ee(),{data:u,isLoading:d}=Ne(),f=r<De,p=c(i).lte(0),m=c(o?.maxRewards||`0`).lte(0),h=c(u?.totalRewards||`0`).lte(0),g=f&&p&&h,_=n||a||s||d;return{incentives:{value:r,assetId:`10`,loading:n,isEmpty:f},farming:{value:i,assetId:`10`,loading:a,isEmpty:p}
1,staking:{value:o?.maxRewards||`0`,symbol:e.symbol,loading:s,isEmpty:m},referral:{value:u?.totalRewards||`0`,assetId:e.id,loading:d,isEmpty:h},isEmpty:g,isLoading:_}},Z=({label:e,value:t,isLoading:n})=>L(z,{justify:`space-between`,align:`center`,gap:`l`,children:[I(C,{fs:`p6`,fw:500,lh:1.4,color:F(`text.medium`),children:e}),n?I(T,{width:`4rem`,height:`1em`}):I(C,{fs:`p6`,fw:600,lh:1.4,color:F(`text.high`),children:t})]}),Pe=()=>{let{t:e}=x(`wallet`),{incentives:t,farming:n,referral:r}=X(),[i,{isLoading:a}]=U(t.assetId,t.value),[o,{isLoading:s}]=U(n.assetId,n.value),[c,{isLoading:l}]=U(r.assetId,r.value);return L(y,{gap:`s`,children:[I(Z,{label:e(`rewards.incentives`),value:i,isLoading:t.loading||a}),I(Z,{label:e(`rewards.farmingRewards`),value:o,isLoading:n.loading||s}),I(Z,{label:e(`rewards.referrals`),value:c,isLoading:r.loading||l})]})},Fe=()=>{let{t:e}=x(`wallet`),{papi:t}=k(),{data:n=[]}=j(),{rewards:r=[],refetch:a}=W(),o=Se(),s=u(),c=X(),l=Te();return i({mutationFn:async()=>{let i=Oe(t,n,r),u=await s(),d=t.tx.Referrals.claim_rewards(),f=await o({txs:[...c.incentives.isEmpty?[]:[u],...c.farming.isEmpty?[]:i,...c.referral.isEmpty?[]:[d]],transaction:{toasts:{submitted:e(`rewards.claim.toasts.submitted`),success:e(`rewards.claim.toasts.success`)}}});return await Promise.all([...i.length?[a]:[],l.mutateAsync()]),f}})},Q=(0,G.memo)(()=>{let{t:e}=x([`wallet`,`common`]),{gte:t}=P(),n=t(`lg`),{assets:r,isAssetsLoading:i,liquidity:a,isLiquidityLoading:s,borrow:l,isBorrowLoading:u,supply:d}=q(),f=X(),p=Fe(),[,{price:m,isLoading:h}]=U(f.referral.assetId,f.referral.value),g=(0,G.useMemo)(()=>c(r||0).plus(a||0).minus(l||0).toString(),[r,l,a]),_=(0,G.useMemo)(()=>c(f.incentives.value||0).plus(f.farming.value||0).plus(m||0).toString(),[m,f.farming.value,f.incentives.value]),y=f.isLoading||h,b=[{label:e(`balances.header.netWorth`),value:e(`common:currency`,{value:g}),isLoading:i||s||u},{label:e(`balances.header.assets`),value:e(`common:currency`,{value:r}),isLoading:i},{label:e(`myAssets.totalBorrow`),value:e(`common:currency`,{value:l}),isLoading:u},{label:e(`myAssets.totalSupply`),value:e(`common:currency`,{value:d||0}),isLoading:u},{label:e(`balances.header.liquidity`),value:e(`common:currency`,{value:a}),isLoading:s},{label:e(`myAssets.claimableRewards`),value:e(`common:currency`,{value:_}),isLoading:y,cta:I(v,{asChild:!0,side:`top`,align:`end`,text:!o()&&I(Pe,{}),children:I(ve,{disabled:y||p.isPending||f.isEmpty,onClick:()=>p.mutate(),children:e(`myAssets.claim`)})})}],S=I(fe,{separated:!n,gap:`xxl`,direction:`row`,justify:`flex-start`,py:`m`,children:b.map(({cta:e,...t},n)=>{let r=n===b.length-1;return I(de,{children:e?L(z,{align:`center`,justify:r?`flex-end`:`flex-start`,gap:`base`,width:`100%`,children:[I(w,{wrap:!0,align:r?`right`:`left`,size:`small`,label:t.label,value:t.value,isLoading:t.isLoading}),e]}):I(w,{wrap:!0,size:`small`,align:r?`right`:`left`,label:t.label,value:t.value,isLoading:t.isLoading})},t.label)})});return I(R,{px:`m`,children:n?S:I(E,{orientation:`horizontal`,horizontalEdgeOffset:`m`,children:S})})});Q.displayName=`PortfolioSummary`;var $=[`assets`,`liquidity`,`bonds`],Ie=({searchPhrase:e,onSearchPhraseChange:r,sortingProps:i,liquidityContent:o,bondsContent:s})=>{let{t:l}=x([`wallet`,`common`]),[u,d]=(0,G.useState)(!1),{category:f}=p({from:`/portfolio/`}),{data:m,hasSmallBalances:h,isEmpty:g,isLoading:_}=je(u),{assets:v,isAssetsLoading:y,liquidity:w,isLiquidityLoading:T,borrow:E,isBorrowLoading:D}=q(),k=(0,G.useMemo)(()=>c(v||0).plus(w||0).minus(E||0).toString(),[v,E,w]),{account:A}=t(),j=A?a(A.rawAddress):!1,M=!j||f===`assets`,{byChain:N}=se(A?[A.rawAddress]:[]);return L(z,{direction:`column`,gap:`l`,children:[L(z,{align:[`stretch`,null,`center`],justify:`space-between`,gap:`base`,direction:[`column`,null,`row`],children:[I(C,{as:`h2`,font:`primary`,fs:`h7`,fw:500,children:l(`myAssets.title`)}),L(z,{align:[`stretch`,null,`center`],gap:`l`,direction:[`column-reverse`,null,`row`],width:[`100%`,null,`auto`],children:[h&&L(S,{width:[`100%`,null,`auto`],justify:[`space-between`,null,`flex-start`],children:[I(ie,{children:l(`myAssets.showSmallBalances`)}),I(ee,{checked:u,onCheckedChange:()=>d(e=>!e)})]}),I(b,{value:e,placeholder:l(`common:search.placeholder.assets`),iconStart:n,width:[`100%`,null,`4xl`],onChange:e=>r(e.target.value)})]})]}),L(he,{children:[j&&L(te,{defaultOpen:!0,children:[I(ne,{asChild:!0,children:I(ue,{isExpandable:!0,name:`Hydration`,chainId:2034,totalDisplay:l(`common:currency`,{value:k}),replaceLogoWhenLoading:!1,isLoading:y||T||D})}),I(re,{forceMount:!0,animationDurationMs:400,sx:{overflow:`hidden`},children:L(R,{sx:{minHeight:0},children:[I(Q,{}),I(O,{}),I(H,{gap:`base`,p:`m`,horizontalEdgeOffset:`xl`,items:$.map(e=>({to:`/portfolio/`,title:l(`myAssets.tabs.${e}`),search:{category:e},resetScroll:!1})),renderItem:e=>I(xe,{size:`small`,item:e,variant:`muted`})}),I(O,{}),L(pe,{children:[f===`assets`&&I(J,{data:m,isEmpty:g,isLoading:_,searchPhrase:e,sortingProps:i}),f===`liquidity`&&o,f===`bonds`&&s]})]})})]}),M&&N.map(({chainKey:t,chain:n,balances:r,total:a,isLoading:o,isError:s,refetch:c})=>I(_e,{chain:n,balances:r,total:a,isLoading:o,isError:s,refetch:c,searchPhrase:e,sortingProps:i},t))]})]})};export{$ as n,Ie as t};
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.