@liberfi.io/ui-portfolio 0.1.39 → 0.1.40

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/index.d.mts CHANGED
@@ -16,7 +16,7 @@ declare global {
16
16
  };
17
17
  }
18
18
  }
19
- declare const _default: "0.1.39";
19
+ declare const _default: "0.1.40";
20
20
 
21
21
  /** Action button rendered in the popover action bar. */
22
22
  interface AccountAction {
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ declare global {
16
16
  };
17
17
  }
18
18
  }
19
- declare const _default: "0.1.39";
19
+ declare const _default: "0.1.40";
20
20
 
21
21
  /** Action button rendered in the popover action bar. */
22
22
  interface AccountAction {
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var react=require('react'),uiChainSelect=require('@liberfi.io/ui-chain-select'),utils=require('@liberfi.io/utils'),walletConnector=require('@liberfi.io/wallet-connector'),i18n=require('@liberfi.io/i18n'),ui=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),react$1=require('@liberfi.io/react');typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-portfolio"]="0.1.39");var $t="0.1.39";var re=react.createContext(null);var ne=react.createContext({}),ge=react.createContext({});function se(){let e=react.useContext(ne);if(!e)throw new Error("usePortfolioContext must be used within a PortfolioProvider");return e}function Ae(){let{summary:e,summaryStatus:t}=se();return {data:e,...t}}function ke(){let{status:e,signIn:t,signOut:o}=walletConnector.useAuth(),{data:r}=Ae(),{chain:i,chainNamespace:p}=uiChainSelect.useCurrentChain(),s=walletConnector.useConnectedWallet(i),n=react.useMemo(()=>r?.chain?utils.getNativeToken(r.chain):void 0,[r?.chain]),a=react.useMemo(()=>r?.balanceInUsd?utils.formatAmountUSD(r.balanceInUsd):"--",[r?.balanceInUsd]),l=react.useMemo(()=>r?.balanceInNative?utils.formatAmount(r.balanceInNative):"--",[r?.balanceInNative]);return {status:e,signIn:t,signOut:o,balanceUsdFormatted:a,balanceNativeFormatted:l,nativeToken:n,chainNamespace:p,walletAddress:s?.address??""}}function Te({status:e,signIn:t,signOut:o,balanceUsdFormatted:r,balanceNativeFormatted:i,nativeToken:p,chainNamespace:s,walletAddress:n,actions:a}){let{t:l}=i18n.useTranslation(),{isMobile:d}=ui.useScreen(),{isOpen:c,onClose:b,onOpenChange:C}=ui.useDisclosure(),T=ui.useCopyToClipboard(),x=react.useCallback(()=>{T(n,()=>ui.toast.success(l("common.primaryAddressCopied",{network:s.toUpperCase()})));},[T,s,n]);return e==="unauthenticated"?jsxRuntime.jsx(ui.Button,{isIconOnly:d,size:"sm",color:"primary",radius:"full",disableRipple:true,onPress:t,startContent:d?void 0:jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}),"aria-label":l("common.signIn"),children:d?jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}):l("common.signIn")}):e==="authenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:d,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":l("common.signingIn"),children:l("common.signingIn")}):e==="deauthenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:d,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":l("common.signingOut"),children:l("common.signingOut")}):jsxRuntime.jsxs(ui.StyledPopover,{placement:d?"bottom":"bottom-end",isOpen:c,onOpenChange:C,triggerScaleOnOpen:false,children:[jsxRuntime.jsx(ui.PopoverTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",className:"bg-content2",radius:"full",disableRipple:true,startContent:jsxRuntime.jsx(ui.WalletIcon,{width:16,height:16,className:"text-neutral"}),endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{width:16,height:16,className:ui.cn("text-neutral transition-transform",c&&"rotate-180")}),children:p&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.TokenIcon,{symbol:p.symbol,size:16}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:d?i:`${i} ${p.symbol}`})]})})}),jsxRuntime.jsx(ui.PopoverContent,{children:jsxRuntime.jsxs("div",{className:"w-70 flex flex-col gap-3 py-4",children:[jsxRuntime.jsxs("div",{className:"px-4 flex items-start justify-between",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-xs text-neutral",children:l("common.totalValue")}),jsxRuntime.jsx("span",{className:"text-base font-semibold text-foreground",children:r})]}),jsxRuntime.jsx("div",{className:"flex items-start justify-end gap-0.5",children:jsxRuntime.jsx(ui.StyledTooltip,{content:l("common.copyPrimaryAddress",{network:s.toUpperCase()}),children:jsxRuntime.jsx(ui.Button,{className:"text-xs bg-transparent text-neutral hover:text-foreground h-4 min-h-4 gap-1",startContent:jsxRuntime.jsx(ui.CopyIcon,{width:14,height:14}),disableRipple:true,disableAnimation:true,onPress:x,children:s.toUpperCase()})})})]}),jsxRuntime.jsx(ui.Divider,{}),jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-2 px-4",children:[a?.map(y=>jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-foreground transition-colors hover:text-primary",onClick:()=>{y.onPress(),b();},children:[y.icon,jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:y.label})]},y.key)),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-danger transition-colors hover:text-danger/80",onClick:()=>{o(),b();},children:[jsxRuntime.jsx(ui.SignOutIcon,{width:16,height:16}),jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:l("common.signOut")})]})]})]})})]})}function Po({actions:e}){let t=ke();return jsxRuntime.jsx(Te,{status:t.status,signIn:t.signIn,signOut:t.signOut,balanceUsdFormatted:t.balanceUsdFormatted,balanceNativeFormatted:t.balanceNativeFormatted,nativeToken:t.nativeToken,chainNamespace:t.chainNamespace,walletAddress:t.walletAddress,actions:e})}function Dn(e){if(!e)return 0;let t=Number(e);return Number.isFinite(t)?t:0}function N(e){let t=Math.abs(e),o=e<0?"-":"";return t>=1e6?`${o}$${(t/1e6).toFixed(1)}M`:t>=1e4?`${o}$${(t/1e3).toFixed(1)}K`:t>=1?`${o}$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`:t>=.01?`${o}$${t.toFixed(2)}`:t>0?`${o}<$0.01`:"$0.00"}function ae(e){let t=N(Math.abs(e));return e>0?`+${t}`:e<0?`-${t.replace("-","")}`:t}function ct(e){return `${e>0?"+":""}${e.toFixed(2)}%`}function ut(e){let o=Math.abs(e).toFixed(2).split("."),r=Number(o[0]).toLocaleString("en-US"),i=`.${o[1]}`;return {sign:e<0?"-$":"$",integer:r,decimal:i}}function te(e,t=4,o=4){return e.length<=t+o+3?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`}function Ie(e){return e===0?"0":e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?e.toLocaleString("en-US",{maximumFractionDigits:2}):e>=1?e.toFixed(2):e>=1e-4?e.toFixed(4):"<0.0001"}function mt(e,t){return `https://solscan.io/tx/${e}`}var dt=["#C8FF00","#00E676","#0066FF","#FF6B9D","#8B7BFF","#FF5252","#FFB74D","#4DD0E1"],vo="#3A3A4E";function ft(e){let t=e.reduce((s,n)=>s+n.value,0);if(t<=0)return {items:[]};let o=[...e].sort((s,n)=>n.value-s.value),r=[],i=0,p=0;for(let s of o){let n=s.value/t*100;n<2?i+=s.value:(r.push({name:s.name,symbol:s.symbol,percent:n,value:s.value,color:dt[p%dt.length]}),p++);}return i>0&&r.push({name:"Other",symbol:"OTHER",percent:i/t*100,value:i,color:vo}),{items:r}}function xt(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false})}function Fe({walletId:e,wallets:t,isViewing:o,viewingAddress:r,onSelectWallet:i,onCopyAddress:p,onSearch:s}){let[n,a]=react.useState(false),[l,d]=react.useState(""),c=react.useRef(null),b=!e&&!o,C=t.find(P=>P.id===e),T=o?"External":b?"All Wallets":C?.name??"",x=o?te(r??""):b?"Aggregated":te(C?.address??""),y=o?"bg-[#5C5C72]":b?"bg-[#C8FF00]":"bg-[#00E676]",g=react.useCallback(()=>{let P=l.trim();P.length>=32&&(s(P),d(""));},[l,s]),k=react.useCallback(P=>{P.key==="Enter"&&g();},[g]);return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex items-center gap-2 rounded-lg border px-2.5 py-1.5 transition-colors",o?"border-[rgba(200,255,0,0.2)] bg-[rgba(200,255,0,0.04)]":"border-[#252530] bg-[#16161E] hover:border-[#35354A] hover:bg-[#1C1C26]",o&&"pointer-events-none"),onClick:()=>!o&&a(P=>!P),children:[jsxRuntime.jsx("span",{className:ui.cn("h-[7px] w-[7px] flex-shrink-0 rounded-full",y)}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-[#A0A0B8]",children:T}),jsxRuntime.jsx("span",{className:"font-mono text-xs text-foreground",children:x}),!o&&jsxRuntime.jsx("svg",{className:ui.cn("text-[#5C5C72] transition-transform",n&&"rotate-180"),width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})]}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(false)}),jsxRuntime.jsxs("div",{className:"absolute left-0 top-[calc(100%+4px)] z-50 min-w-[260px] rounded-lg border border-[#252530] bg-[#16161E] p-1 shadow-[0_8px_32px_rgba(0,0,0,0.4)]",children:[jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",b&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{i(void 0),a(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#C8FF00]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:"All Wallets"}),jsxRuntime.jsx("span",{className:"text-[11px] text-[#3A3A4E]",children:"Aggregated"})]}),t.map(P=>jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",e===P.id&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{i(P.id),a(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#00E676]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:P.name}),jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#5C5C72]",children:te(P.address)}),jsxRuntime.jsx("span",{className:"ml-auto font-mono text-[11px] font-medium text-foreground",children:P.balance})]},P.id))]})]})]}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded p-1 text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-[#C8FF00]",b&&!o&&"pointer-events-none opacity-40"),onClick:p,disabled:b&&!o,children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[jsxRuntime.jsx("rect",{x:"4.5",y:"4.5",width:"7",height:"7",rx:"1.5",stroke:"currentColor",strokeWidth:"1.2"}),jsxRuntime.jsx("path",{d:"M9.5 4.5V3a1.5 1.5 0 0 0-1.5-1.5H3A1.5 1.5 0 0 0 1.5 3v5A1.5 1.5 0 0 0 3 9.5h1.5",stroke:"currentColor",strokeWidth:"1.2"})]})}),jsxRuntime.jsx("span",{className:ui.cn("flex-shrink-0 rounded-[3px] px-1.5 py-[3px] text-[9px] font-semibold uppercase tracking-wider",o?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00] animate-[pulse-glow_2s_ease-in-out_infinite]":"bg-[rgba(0,230,118,0.1)] text-[#00E676]"),children:o?"Viewing":"Owner"})]}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex h-[34px] w-[240px] items-center gap-1.5 rounded-lg border border-[#252530] bg-[#16161E] px-2.5 transition-all focus-within:w-[300px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{className:"flex-shrink-0 text-[#5C5C72]",width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{className:"flex-1 border-none bg-transparent font-mono text-xs text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[11px] placeholder:text-[#5C5C72]",placeholder:"Search wallet address\u2026",spellCheck:false,value:l,onChange:P=>d(P.target.value),onKeyDown:k})]}),jsxRuntime.jsx("button",{type:"button",className:"whitespace-nowrap rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:g,children:"View"})]})]})}var le=(r=>(r.SPOT="spot",r.PERPS="perps",r.PREDICTION="prediction",r))(le||{}),He=(o=>(o.NET_WORTH="networth",o.PNL="pnl",o))(He||{}),Ue=(i=>(i.ONE_DAY="1D",i.SEVEN_DAY="7D",i.THIRTY_DAY="30D",i.MAX="Max",i))(Ue||{}),bt={"1D":1,"7D":7,"30D":30,Max:365},Pt=(o=>(o.LONG="long",o.SHORT="short",o))(Pt||{}),ht=(r=>(r.SWAP="swap",r.SEND="send",r.RECEIVE="receive",r))(ht||{}),vt=(o=>(o.ACTIVE="active",o.PENDING="pending",o))(vt||{}),Ct=(o=>(o.WON="won",o.LOST="lost",o))(Ct||{}),St=(r=>(r.POLYMARKET="polymarket",r.DRIFT="drift",r.METADAO="metadao",r))(St||{});var Ao=[{key:"spot",label:"Spot"},{key:"perps",label:"Perps"},{key:"prediction",label:"Prediction"}];function wo(e,t,o,r){switch(e){case "spot":return t;case "perps":return o;case "prediction":return r}}function De({activeTab:e,onTabChange:t,spotValue:o=0,perpsValue:r=0,predictionValue:i=0}){return jsxRuntime.jsx("div",{className:"flex gap-1 border-b border-[#252530] pb-0 pt-5",children:Ao.map(({key:p,label:s})=>{let n=e===p,a=wo(p,o,r,i);return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("relative flex items-center gap-2 border-b-2 px-4 pb-3 pt-2.5 text-[13px] font-medium transition-colors",n?"border-[#C8FF00] text-foreground":"border-transparent text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:()=>t(p),children:[s,!n&&jsxRuntime.jsx("span",{className:"rounded-[10px] bg-[#16161E] px-2 py-0.5 font-mono text-[11px] text-[#5C5C72]",children:N(a)})]},p)})})}function Re({overview:e}){let t=e?.totalValue??0,o=e?.uPnl??0,r=e?.realizedPnl??0,i=e?.totalProfit??0,{sign:p,integer:s,decimal:n}=ut(t);return jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsx("div",{className:"flex items-baseline gap-3",children:jsxRuntime.jsxs("div",{className:"font-mono text-[26px] font-bold leading-none tracking-tight",children:[jsxRuntime.jsx("span",{className:"mr-px text-lg font-medium text-[#C8FF00]",children:p}),s,jsxRuntime.jsx("span",{className:"text-base font-normal text-[#5C5C72]",children:n})]})}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(Ee,{label:"uPNL",value:o}),jsxRuntime.jsx(At,{}),jsxRuntime.jsx(Ee,{label:"Realized",value:r}),jsxRuntime.jsx(At,{}),jsxRuntime.jsx(Ee,{label:"Total Profit",value:i})]})]})}function Ee({label:e,value:t}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[#5C5C72]",children:e}),jsxRuntime.jsx("span",{className:ui.cn("font-mono text-xs font-medium",t>0?"text-[#00E676]":t<0?"text-[#FF5252]":"text-[#5C5C72]"),children:ae(t)})]})}function At(){return jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"})}var Ro=["1D","7D","30D","Max"];function wt(e,t){let o=new Date(e);return t==="1D"?o.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Qo(e){return e==="pnl"?"change":"netWorth"}function Oe({curveType:e,curvePeriod:t,data:o,isLoading:r,onTypeChange:i,onPeriodChange:p}){let s=o?.points??[],n=Qo(e),a=e==="pnl",l=react.useMemo(()=>s.map(x=>a?x.change:x.netWorth),[s,a]),d=l.some(x=>x<0),{minVal:c,maxVal:b}=react.useMemo(()=>{if(l.length===0)return {minVal:0,maxVal:100};let x=Math.min(...l),y=Math.max(...l),g=y-x||1;return {minVal:x-g*.1,maxVal:y+g*.1}},[l]),C=react.useMemo(()=>{if(s.length===0)return [];let x=Math.min(7,s.length),y=Math.max(1,Math.floor((s.length-1)/(x-1))),g=[];for(let P=0;P<s.length;P+=y)g.push({ts:s[P].timestamp,label:wt(s[P].timestamp,t)});let k=s[s.length-1];return g[g.length-1]?.ts!==k.timestamp&&g.push({ts:k.timestamp,label:wt(k.timestamp,t)}),g},[s,t]),T=l[l.length-1]??0;return jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 pt-3",children:[jsxRuntime.jsxs("div",{className:"flex gap-0.5 rounded-[5px] bg-[#16161E] p-0.5",children:[jsxRuntime.jsx(kt,{label:"Net Worth",active:e==="networth",onClick:()=>i("networth")}),jsxRuntime.jsx(kt,{label:"PNL",active:e==="pnl",onClick:()=>i("pnl")})]}),jsxRuntime.jsx("div",{className:"flex gap-0.5",children:Ro.map(x=>jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-[3px] px-2 py-1 text-[10px] font-medium transition-colors",t===x?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00]":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>p(x),children:x},x))})]}),jsxRuntime.jsx("div",{className:"h-[180px] px-4 pt-2",children:r||s.length<2?jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:r?"":"Not enough data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.AreaChart,{data:s,margin:{top:8,right:0,left:0,bottom:0},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{id:"gradAccent",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#C8FF00",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#C8FF00",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradGreen",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#00E676",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#00E676",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradRed",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#FF5252",stopOpacity:0}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#FF5252",stopOpacity:.1})]})]}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",hide:true}),jsxRuntime.jsx(recharts.YAxis,{hide:true,domain:[c,b]}),a&&d&&jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:n,stroke:a?T>=0?"#00E676":"#FF5252":"#C8FF00",strokeWidth:1.5,fill:a?T>=0?"url(#gradGreen)":"url(#gradRed)":"url(#gradAccent)",dot:false,isAnimationActive:false})]})})}),jsxRuntime.jsx("div",{className:"flex justify-between px-4 pb-2.5 pt-1",children:C.map(({ts:x,label:y})=>jsxRuntime.jsx("span",{className:"font-mono text-[9px] text-[#3A3A4E]",children:y},x))})]})}function kt({label:e,active:t,onClick:o}){return jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded px-2.5 py-1 text-[11px] font-medium transition-colors",t?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:o,children:e})}function We({data:e,isLoading:t}){let o=e?.items??[],r=react.useMemo(()=>o.map(i=>({name:i.name,value:i.percent})),[o]);return jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsx("div",{className:"px-4 pb-2 pt-3",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[#A0A0B8]",children:"Distribution"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center justify-center px-4",children:t||o.length===0?jsxRuntime.jsx("div",{className:"flex h-[140px] w-[140px] items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:t?"":"No data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:140,height:140,children:jsxRuntime.jsx(recharts.PieChart,{children:jsxRuntime.jsx(recharts.Pie,{data:r,cx:"50%",cy:"50%",innerRadius:32,outerRadius:55,dataKey:"value",stroke:"none",isAnimationActive:false,children:o.map((i,p)=>jsxRuntime.jsx(recharts.Cell,{fill:i.color},p))})})})}),jsxRuntime.jsx("div",{className:"px-4 pb-3 pt-2",children:o.map((i,p)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 py-[3px] text-[11px]",children:[jsxRuntime.jsx("span",{className:"h-[7px] w-[7px] flex-shrink-0 rounded-[2px]",style:{background:i.color}}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-[#A0A0B8]",children:i.name}),jsxRuntime.jsxs("span",{className:"font-mono text-[10px] text-[#5C5C72]",children:[i.percent.toFixed(1),"%"]}),jsxRuntime.jsx("span",{className:"min-w-[55px] text-right font-mono text-[10px] text-foreground",children:N(i.value)})]},p))})]})}function I(){let e=react.useContext(re);if(!e)throw new Error("usePortfolioClient must be used within a PortfolioClientProvider");return e}function It(e){return ["portfolio","overview",e??{}]}async function Ko(e,t){return await e.getOverview(t)}function Le(e,t={}){let o=I();return reactQuery.useQuery({queryKey:It(e),queryFn:async()=>Ko(o,e),...t})}function Ft(e){return ["portfolio","spot","holdings",e??{}]}async function $o(e,t){return await e.getSpotHoldings(t)}function pe(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Ft(e),queryFn:async()=>$o(o,e),...t})}function Ht(e){return ["portfolio","spot","history",e??{}]}async function jo(e,t){return await e.getSpotHistory(t)}function _e(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Ht(e),queryFn:async()=>jo(o,e),...t})}function Ut(e){return ["portfolio","perps","positions",e??{}]}async function Go(e,t){return await e.getPerpsPositions(t)}function Ve(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Ut(e),queryFn:async()=>Go(o,e),...t})}function Dt(e){return ["portfolio","perps","history",e??{}]}async function Jo(e,t){return await e.getPerpsHistory(t)}function Me(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Dt(e),queryFn:async()=>Jo(o,e),...t})}function Et(e){return ["portfolio","prediction","active",e??{}]}async function er(e,t){return await e.getPredictionBets(t)}function Ke(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Et(e),queryFn:async()=>er(o,e),...t})}function Rt(e){return ["portfolio","prediction","settled",e??{}]}async function or(e,t){return await e.getPredictionSettled(t)}function qe(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Rt(e),queryFn:async()=>or(o,e),...t})}function Qt(e){return ["portfolio","chart",e]}async function nr(e,t){return await e.getChartData(t)}function $e(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Qt(e),queryFn:async()=>nr(o,e),...t})}function ir(){return ["portfolio","distribution"]}function Ye(e){return {data:react.useMemo(()=>ft(e),[e])}}function ar(){let{refetchSummary:e}=se();return e}var xr=15e3;function Bt(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function gr({chain:e,address:t,tokenAddresses:o,pollMs:r=xr}){let i=!!t&&o.length>0,[p,s]=react.useState({}),n=react$1.useWalletPortfoliosByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:i,refetchInterval:r}),a=react$1.useWalletPortfolioPnlsByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:i,refetchInterval:r});react.useEffect(()=>{let T=n.data??[],x=new Map;if(a.data)for(let g of a.data)x.set(g.address,g);let y={};for(let g of T)y[g.address]={...g,pnl:x.get(g.address)??null};s(y);},[n.data,a.data]);let l=react.useRef(""),d=react.useRef(new Set),c=o.slice().sort().join(",");c!==l.current&&(l.current=c,d.current=new Set(o));let b=d.current;react$1.useWalletPortfoliosSubscription({chain:e,address:t},T=>{s(x=>{let y=x;for(let g of T){if(!b.has(g.tokenAddress))continue;let k=y[g.tokenAddress];if(!k)continue;let{chain:P,walletAddress:L,tokenAddress:V,...E}=g,M=Bt(E);Object.keys(M).length!==0&&(y=y===x?{...x}:y,y[g.tokenAddress]={...k,...M});}return y});},{enabled:i}),react$1.useWalletPortfolioPnlsSubscription({chain:e,address:t},T=>{s(x=>{let y=x;for(let g of T){if(!b.has(g.tokenAddress))continue;let k=y[g.tokenAddress];if(!k||!k.pnl)continue;let{walletAddress:P,tokenAddress:L,...V}=g,E=Bt(V);Object.keys(E).length!==0&&(y=y===x?{...x}:y,y[g.tokenAddress]={...k,pnl:{...k.pnl,...E}});}return y});},{enabled:i});let C=react.useCallback(async()=>{await Promise.all([n.refetch(),a.refetch()]);},[n.refetch,a.refetch]);return {tokens:p,isPending:n.isPending,isFetching:n.isFetching||a.isFetching,isError:n.isError,isSuccess:n.isSuccess,error:n.error,refetch:C}}function ze(e){let{defaultTab:t="spot",walletAddresses:o,chain:r}=e??{},[i,p]=react.useState(t),[s,n]=react.useState(void 0),[a,l]=react.useState(void 0),[d,c]=react.useState("networth"),[b,C]=react.useState("7D"),T=a!==void 0,x=react.useMemo(()=>{if(a)return {walletAddresses:[a],chain:r};if(o?.length)return {walletAddresses:o,chain:r}},[o,a,r]),y=Le(x),g=pe(x),k=$e({period:bt[b],...x}),P=Ye(g.data?.holdings??[]),L=react.useMemo(()=>g.data?.holdings.reduce((O,fe)=>O+fe.value,0)??0,[g.data]),V=react.useCallback(O=>{l(O);},[]),E=react.useCallback(()=>{l(void 0);},[]),M=react.useCallback(O=>{n(O);},[]);return {activeTab:i,setActiveTab:p,walletId:s,selectWallet:M,viewingAddress:a,isViewing:T,curveType:d,setCurveType:c,curvePeriod:b,setCurvePeriod:C,portfolioQuery:x,overviewQuery:y,curveQuery:k,distributionQuery:P,spotHoldingsQuery:g,spotValue:L,perpsValue:0,predictionValue:0,enterViewing:V,exitViewing:E}}function Ge(){return jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsxs("div",{className:"flex gap-4 border-b border-[#252530] pb-0 pt-5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-16 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-28 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-32 rounded-md"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 py-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-6 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-14 rounded-[3px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-[240px] rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-12 rounded-[5px]"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"})]}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-32 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[180px] w-full rounded-md"}),jsxRuntime.jsx("div",{className:"mt-2 flex justify-between",children:Array.from({length:7}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-8 rounded"},t))})]}),jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-4 w-24 rounded"}),jsxRuntime.jsx("div",{className:"flex items-center justify-center py-4",children:jsxRuntime.jsx(ui.Skeleton,{className:"h-[140px] w-[140px] rounded-full"})}),jsxRuntime.jsx("div",{className:"space-y-1.5 pt-2",children:Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-full rounded"},t))})]})]}),jsxRuntime.jsxs("div",{className:"pb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-40 rounded-[5px]"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-[5px]"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-5 w-full rounded"}),Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"mb-2 h-12 w-full rounded-[5px]"},t))]})]})}function Xe({viewingAddress:e,onBack:t}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-[rgba(200,255,0,0.12)] bg-[rgba(200,255,0,0.06)] px-6 py-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-full border border-[rgba(200,255,0,0.25)] bg-[rgba(200,255,0,0.07)]",children:jsxRuntime.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M8 3C4.36 3 1.26 5.28 0 8.5c1.26 3.22 4.36 5.5 8 5.5s6.74-2.28 8-5.5C14.74 5.28 11.64 3 8 3z",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8.5",r:"2.5",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"})]})}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-[#C8FF00]",children:"Viewing external portfolio"}),jsxRuntime.jsx("span",{className:"ml-1 font-mono text-[11px] text-[#A0A0B8]",children:te(e)})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:t,children:[jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 2L4 8l6 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to My Portfolio"]})]})}function yr({wallets:e=[],onCopyAddress:t,renderHoldings:o,isLoading:r,...i}){let p=ze(i),{activeTab:s,setActiveTab:n,walletId:a,selectWallet:l,viewingAddress:d,isViewing:c,curveType:b,setCurveType:C,curvePeriod:T,setCurvePeriod:x,portfolioQuery:y,overviewQuery:g,curveQuery:k,distributionQuery:P,spotValue:L,perpsValue:V,predictionValue:E,enterViewing:M,exitViewing:O}=p;return r||g.isLoading&&!g.data?jsxRuntime.jsx(Ge,{}):jsxRuntime.jsxs("div",{children:[c&&d&&jsxRuntime.jsx(Xe,{viewingAddress:d,onBack:O}),jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsx(De,{activeTab:s,onTabChange:n,spotValue:L,perpsValue:V,predictionValue:E}),jsxRuntime.jsx(Fe,{walletId:a,wallets:e,isViewing:c,viewingAddress:d,onSelectWallet:l,onCopyAddress:()=>{if(c&&d)t?.(d);else {let xe=e.find(Ne=>Ne.id===a);xe&&t?.(xe.address);}},onSearch:M}),jsxRuntime.jsx(Re,{overview:g.data}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsx(Oe,{curveType:b,curvePeriod:T,data:k.data,isLoading:k.isLoading,onTypeChange:C,onPeriodChange:x}),jsxRuntime.jsx(We,{data:P.data,isLoading:false})]}),o?.({activeTab:s,portfolioQuery:y,isViewing:c})]})]})}function Pe({open:e,title:t,message:o,confirmLabel:r,cancelLabel:i,onConfirm:p,onCancel:s}){return e?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:s,onKeyDown:n=>{n.key==="Escape"&&s();},role:"button",tabIndex:-1,"aria-label":"Close dialog"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-w-sm rounded-xl border border-[#252530] bg-[#12121A] p-6 shadow-2xl",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-foreground",children:t}),jsxRuntime.jsx("p",{className:"mt-2 text-xs leading-relaxed text-[#A0A0B8]",children:o}),jsxRuntime.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[jsxRuntime.jsx("button",{type:"button",className:"rounded-lg px-4 py-2 text-xs font-medium text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-foreground",onClick:s,children:i}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-lg border px-4 py-2 text-xs font-medium transition-colors","border-[rgba(255,82,82,0.25)] text-[#FF5252]","hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:p,children:r})]})]})]}):null}function tt({activeTab:e,portfolioQuery:t,isViewing:o}){let[r,i]=react.useState("holdings"),[p,s]=react.useState("positions"),[n,a]=react.useState("active"),[l,d]=react.useState(""),[c,b]=react.useState(""),[C,T]=react.useState(""),[x,y]=react.useState(false),[g,k]=react.useState(false),P=react.useCallback(()=>{k(K=>!K);},[]),L=pe(t,{enabled:e==="spot"}),V=_e(t,{enabled:e==="spot"&&r==="history"}),E=Ve(t,{enabled:e==="perps"}),M=Me(t,{enabled:e==="perps"&&p==="history"}),O=Ke(t,{enabled:e==="prediction"}),fe=qe(t,{enabled:e==="prediction"&&n==="settled"}),at=react.useMemo(()=>(L.data?.holdings??[]).filter(q=>{if(x&&q.value<1&&!q.verified)return false;if(l){let ee=l.toLowerCase();return q.name.toLowerCase().includes(ee)||q.symbol.toLowerCase().includes(ee)}return true}),[L.data?.holdings,x,l]),xe=react.useMemo(()=>{let K=E.data?.positions??[];if(!c)return K;let q=c.toLowerCase();return K.filter(ee=>ee.pair.toLowerCase().includes(q))},[E.data?.positions,c]),Ne=react.useMemo(()=>{let K=O.data?.bets??[];if(!C)return K;let q=C.toLowerCase();return K.filter(ee=>ee.market.toLowerCase().includes(q))},[O.data?.bets,C]);return {spotSubTab:r,setSpotSubTab:i,perpsSubTab:p,setPerpsSubTab:s,predictionSubTab:n,setPredictionSubTab:a,spotSearch:l,setSpotSearch:d,perpsSearch:c,setPerpsSearch:b,predictionSearch:C,setPredictionSearch:T,hideSmall:x,setHideSmall:y,groupCollapsed:g,toggleGroupCollapsed:P,spotHoldingsQuery:L,spotHistoryQuery:V,perpsPositionsQuery:E,perpsHistoryQuery:M,predictionBetsQuery:O,predictionSettledQuery:fe,filteredSpotHoldings:at,filteredPerpsPositions:xe,filteredPredictionBets:Ne,isViewing:o}}function J({tabs:e,activeKey:t,onTabChange:o}){return jsxRuntime.jsx("div",{className:"flex gap-0.5",children:e.map(r=>jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-[5px] px-3 py-1.5 text-xs font-medium transition-colors",t===r.key?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>o(r.key),children:r.label},r.key))})}function Z({value:e,onChange:t,placeholder:o}){return jsxRuntime.jsxs("div",{className:"flex h-7 w-40 items-center gap-1 rounded-[5px] border border-[#252530] bg-[#16161E] px-2 transition-all focus-within:w-[200px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",className:"flex-shrink-0 text-[#5C5C72]",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",className:"flex-1 border-none bg-transparent font-mono text-[11px] text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[10px] placeholder:text-[#5C5C72]",placeholder:o,spellCheck:false,value:e,onChange:r=>t(r.target.value)})]})}function W({title:e,hint:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[jsxRuntime.jsx("span",{className:"text-sm text-[#5C5C72]",children:e}),t&&jsxRuntime.jsx("span",{className:"mt-1 text-xs text-[#3A3A4E]",children:t})]})}function ue({label:e,disabled:t,onClick:o}){return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex items-center gap-1 whitespace-nowrap rounded-[5px] border px-3 py-1.5 text-[11px] font-medium transition-colors",t?"pointer-events-none border-[#252530] text-[#3A3A4E]":"border-[rgba(255,82,82,0.25)] text-[#FF5252] hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:o,disabled:t,children:[jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),e]})}function ot({state:e,onClosePosition:t,onCloseAll:o}){let{perpsSubTab:r,setPerpsSubTab:i,perpsSearch:p,setPerpsSearch:s,filteredPerpsPositions:n,perpsHistoryQuery:a,isViewing:l}=e,d=n.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(J,{tabs:[{key:"positions",label:"Open Positions"},{key:"history",label:"Trade History"}],activeKey:r,onTabChange:c=>i(c)}),r==="positions"&&!l&&jsxRuntime.jsx(ue,{label:"Close All",disabled:!d,onClick:()=>o?.()})]}),jsxRuntime.jsx(Z,{value:p,onChange:s,placeholder:"Search pair\u2026"})]}),r==="positions"?jsxRuntime.jsx(hr,{positions:n,isViewing:l,onClose:t}):jsxRuntime.jsx(Cr,{records:a.data?.records??[],isLoading:a.isLoading})]})}function hr({positions:e,isViewing:t,onClose:o}){return e.length===0?jsxRuntime.jsx(W,{title:"No open positions",hint:"Start trading \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsx("span",{children:"Pair / Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"Entry"}),jsxRuntime.jsx("span",{className:"text-right",children:"Mark"}),jsxRuntime.jsx("span",{className:"text-right",children:"uPNL"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(vr,{position:r,isViewing:t,onClose:o},r.id))})]})}function vr({position:e,isViewing:t,onClose:o}){let r=e.side==="long",i=e.uPnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair}),jsxRuntime.jsx("span",{className:ui.cn("rounded px-1.5 py-0.5 text-[10px] font-medium",r?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:r?"Long":"Short"}),jsxRuntime.jsxs("span",{className:"rounded bg-[rgba(200,255,0,0.1)] px-1.5 py-0.5 text-[10px] font-medium text-[#C8FF00]",children:[e.leverage,"\xD7"]})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.size)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.entryPrice)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.markPrice)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",i?"text-[#00E676]":"text-[#FF5252]"),children:ae(e.uPnl)}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Close"})})]})}function Cr({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(W,{title:"No trade history",hint:"Closed positions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsx("span",{children:"Pair"}),jsxRuntime.jsx("span",{children:"Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"PNL"}),jsxRuntime.jsx("span",{className:"text-right",children:"Close Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Sr,{record:o},o.id))})]})}function Sr({record:e}){let t=e.side==="long",o=e.pnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair})]}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Long":"Short"})}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.size)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",o?"text-[#00E676]":"text-[#FF5252]"),children:ae(e.pnl)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.closePrice)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.time})]})}function rt({state:e,onSellBet:t,onSellAll:o}){let{predictionSubTab:r,setPredictionSubTab:i,predictionSearch:p,setPredictionSearch:s,filteredPredictionBets:n,predictionSettledQuery:a,isViewing:l}=e,d=n.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(J,{tabs:[{key:"active",label:"Active Bets"},{key:"settled",label:"Settled"}],activeKey:r,onTabChange:c=>i(c)}),r==="active"&&!l&&jsxRuntime.jsx(ue,{label:"Sell All",disabled:!d,onClick:()=>o?.()})]}),jsxRuntime.jsx(Z,{value:p,onChange:s,placeholder:"Search market\u2026"})]}),r==="active"?jsxRuntime.jsx(wr,{bets:n,isViewing:l,onSell:t}):jsxRuntime.jsx(Tr,{records:a.data?.records??[],isLoading:a.isLoading})]})}var Nr={polymarket:"bg-[rgba(0,102,255,0.12)] text-[#0066FF]",drift:"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]",metadao:"bg-[rgba(255,107,157,0.1)] text-[#FF6B9D]"},Ar={polymarket:"Polymarket",drift:"Drift",metadao:"MetaDAO"};function _t({source:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Nr[e]),children:Ar[e]})}function wr({bets:e,isViewing:t,onSell:o}){return e.length===0?jsxRuntime.jsx(W,{title:"No active bets",hint:"Explore prediction markets \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsx("span",{children:"Market / Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Potential"}),jsxRuntime.jsx("span",{className:"text-right",children:"Status"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(kr,{bet:r,isViewing:t,onSell:o},r.id))})]})}function kr({bet:e,isViewing:t,onSell:o}){return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market}),jsxRuntime.jsx(_t,{source:e.source})]})]}),jsxRuntime.jsx("span",{className:ui.cn("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.stake)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#00E676]",children:N(e.potential)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",e.status==="active"?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]"),children:e.status==="active"?"Active":"Pending"})}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Sell"})})]})}function Tr({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(W,{title:"No settled bets",hint:"Settled predictions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsx("span",{children:"Market"}),jsxRuntime.jsx("span",{children:"Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Result"}),jsxRuntime.jsx("span",{className:"text-right",children:"Payout"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Ir,{record:o},o.id))})]})}function Ir({record:e}){let t=e.result==="won";return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market})]}),jsxRuntime.jsx(_t,{source:e.source}),jsxRuntime.jsx("span",{className:ui.cn("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.stake)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Won":"Lost"})}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#5C5C72]"),children:t?`+${N(e.payout)}`:N(e.payout)})]})}function st({state:e}){let{spotSubTab:t,setSpotSubTab:o,spotSearch:r,setSpotSearch:i,hideSmall:p,setHideSmall:s,groupCollapsed:n,toggleGroupCollapsed:a,filteredSpotHoldings:l,spotHistoryQuery:d}=e;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(J,{tabs:[{key:"holdings",label:"Holdings"},{key:"history",label:"History"}],activeKey:t,onTabChange:c=>o(c)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Z,{value:r,onChange:i,placeholder:"Search token\u2026"}),t==="holdings"&&jsxRuntime.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-[11px] text-[#5C5C72] select-none",children:[jsxRuntime.jsx("input",{type:"checkbox",className:"accent-[#C8FF00]",checked:p,onChange:c=>s(c.target.checked)}),"Hide small"]})]})]}),t==="holdings"?jsxRuntime.jsx(Fr,{holdings:l,groupCollapsed:n,onToggleGroup:a}):jsxRuntime.jsx(Ur,{records:d.data?.trades??[],isLoading:d.isLoading})]})}function Fr({holdings:e,groupCollapsed:t,onToggleGroup:o}){return e.length===0?jsxRuntime.jsx(W,{title:"No tokens found",hint:"Your spot tokens will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsx("span",{children:"Asset"}),jsxRuntime.jsx("span",{className:"text-right",children:"Balance"}),jsxRuntime.jsx("span",{className:"text-right",children:"Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"24h"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72] transition-colors hover:text-[#A0A0B8]",onClick:o,children:[jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",className:ui.cn("transition-transform",t&&"-rotate-90"),children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsxRuntime.jsx("span",{children:"Tokens"}),jsxRuntime.jsx("span",{className:"text-[#3A3A4E]",children:e.length})]}),!t&&jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(Hr,{holding:r},r.tokenAddress))})]})}function Hr({holding:e}){let t=e.change24h>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[e.image?jsxRuntime.jsx("img",{src:e.image,alt:e.symbol,className:"h-7 w-7 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[10px] font-bold text-[#5C5C72]",children:e.symbol.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[10px] text-[#5C5C72]",children:e.symbol})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:Ie(e.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.price)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.value)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#FF5252]"),children:ct(e.change24h)})]})}function Ur({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(W,{title:"No history found",hint:"Transaction history will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:"Type"}),jsxRuntime.jsx("span",{children:"Detail"}),jsxRuntime.jsx("span",{className:"text-right",children:"Amount"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"}),jsxRuntime.jsx("span",{className:"text-right",children:"TxHash"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Qr,{record:o},`${o.txHash}-${o.tokenAddress}`))})]})}var Dr={swap:"bg-[rgba(139,123,255,0.12)] text-[#8B7BFF]",send:"bg-[rgba(255,82,82,0.12)] text-[#FF5252]",receive:"bg-[rgba(0,230,118,0.12)] text-[#00E676]"},Er={swap:"Swap",send:"Send",receive:"Receive"};function Rr(e){return e.type==="swap"&&e.sideTokenSymbol?`${e.tokenSymbol} \u2192 ${e.sideTokenSymbol}`:e.tokenName||e.tokenSymbol}function Qr({record:e}){let t=mt(e.txHash,e.chain);return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Dr[e.type]),children:Er[e.type]})}),jsxRuntime.jsx("span",{className:"truncate text-xs text-foreground",children:Rr(e)}),jsxRuntime.jsxs("span",{className:"text-right font-mono text-xs text-foreground",children:[Ie(e.tokenAmount)," ",e.tokenSymbol]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.valueUsd)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.timestamp?xt(e.timestamp):"\u2014"}),jsxRuntime.jsx("span",{className:"text-right",children:e.txHash?jsxRuntime.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-[11px] text-[#5C5C72] transition-colors hover:text-[#C8FF00]",children:[e.txHash.slice(0,4),"\u2026",e.txHash.slice(-3)]}):jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#3A3A4E]",children:"\u2014"})})]})}function Br({onClosePosition:e,onCloseAllPositions:t,onSellBet:o,onSellAllBets:r,...i}){let p=tt(i),[s,n]=react.useState(null),a=react.useCallback(()=>{n("closeAll");},[]),l=react.useCallback(()=>{n("sellAll");},[]),d=react.useCallback(()=>{s==="closeAll"?t?.():s==="sellAll"&&r?.(),n(null);},[s,t,r]),c=react.useCallback(()=>{n(null);},[]);return jsxRuntime.jsxs("div",{className:"rounded-xl border border-[#1C1C26] bg-[#0E0E16] p-4",children:[(()=>{switch(i.activeTab){case "spot":return jsxRuntime.jsx(st,{state:p});case "perps":return jsxRuntime.jsx(ot,{state:p,onClosePosition:e,onCloseAll:a});case "prediction":return jsxRuntime.jsx(rt,{state:p,onSellBet:o,onSellAll:l});default:return null}})(),jsxRuntime.jsx(Pe,{open:s==="closeAll",title:"Close All Positions",message:"Close all positions? This will route to each protocol to execute.",confirmLabel:"Confirm Close All",cancelLabel:"Cancel",onConfirm:d,onCancel:c}),jsxRuntime.jsx(Pe,{open:s==="sellAll",title:"Sell All Positions",message:"Sell all positions? This will route to each platform to execute.",confirmLabel:"Confirm Sell All",cancelLabel:"Cancel",onConfirm:d,onCancel:c})]})}function Lr({client:e,children:t}){return jsxRuntime.jsx(re.Provider,{value:e,children:t})}var Yr=15e3;function jr(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Vt({chain:e,address:t,enabled:o=true,summaryPollMs:r=Yr}){let{setSummary:i,setSummaryStatus:p,setRefetchSummary:s}=react.useContext(ge),n=react$1.useWalletPortfoliosQuery({chain:e,address:t},{enabled:o,refetchInterval:r}),a=react$1.useWalletPnlQuery({chain:e,address:t},{enabled:o,refetchInterval:r});react.useEffect(()=>{let d=n.isPending||a.isPending,c=n.isFetching||a.isFetching,b=n.isError||a.isError,C=n.isSuccess&&a.isSuccess;p({status:b?"error":C?"success":"pending",fetchStatus:c?"fetching":"idle",isLoading:d&&c,isPending:d,isFetching:c,isRefetching:C&&c,isError:b,isSuccess:C,error:n.error??a.error,dataUpdatedAt:Math.max(n.dataUpdatedAt,a.dataUpdatedAt)});},[n.isPending,n.isFetching,n.isError,n.isSuccess,n.error,n.dataUpdatedAt,a.isPending,a.isFetching,a.isError,a.isSuccess,a.error,a.dataUpdatedAt,p]),react.useEffect(()=>{let d=n.data,c=a.data;!d||!c||i({...c,balanceInUsd:d.balanceInUsd,balanceInNative:d.balanceInNative});},[n.data,a.data,i]),react$1.useWalletPnlSubscription({chain:e,address:t},d=>{i(c=>{if(!c)return c;let b=c;for(let C of d)b={...b,...jr(C)};return b});},{enabled:o});let l=react.useCallback(async()=>{await Promise.all([n.refetch(),a.refetch()]);},[n,a]);react.useEffect(()=>{s(l);},[l,s]);}function Gr({chain:e,address:t,children:o}){let[r,i]=react.useState(null),[p,s]=react.useState(Jr),n=react.useRef(()=>Promise.resolve()),a=react.useCallback(()=>n.current(),[]),l=react.useCallback(b=>{n.current=b;},[]),d=react.useMemo(()=>({summary:r,summaryStatus:p,refetchSummary:a}),[r,p,a]),c=react.useMemo(()=>({setSummary:i,setSummaryStatus:s,setRefetchSummary:l}),[i,s,l]);return jsxRuntime.jsx(ge.Provider,{value:c,children:jsxRuntime.jsx(ne.Provider,{value:d,children:jsxRuntime.jsx(Xr,{chain:e,address:t,children:o})})})}function Xr({chain:e,address:t,children:o}){return Vt({chain:e,address:t,enabled:!!t}),jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}var Jr={status:"pending",fetchStatus:"idle",isLoading:false,isPending:true,isFetching:false,isRefetching:false,isError:false,isSuccess:false,error:null,dataUpdatedAt:0};
2
- exports.AccountInfoUI=Te;exports.AccountInfoWidget=Po;exports.AddressRowUI=Fe;exports.AssetTab=le;exports.AssetTabsUI=De;exports.BalanceRowUI=Re;exports.BatchActionButton=ue;exports.CURVE_PERIOD_VALUE=bt;exports.ConfirmDialog=Pe;exports.CurveCardUI=Oe;exports.CurvePeriod=Ue;exports.CurveType=He;exports.DistributionCardUI=We;exports.HoldingsEmpty=W;exports.HoldingsSearch=Z;exports.HoldingsSectionWidget=Br;exports.HoldingsSubTabs=J;exports.PerpsPanelUI=ot;exports.PerpsPositionSide=Pt;exports.PortfolioClientContext=re;exports.PortfolioClientProvider=Lr;exports.PortfolioContext=ne;exports.PortfolioPageSkeleton=Ge;exports.PortfolioPageWidget=yr;exports.PortfolioProvider=Gr;exports.PredictionBetStatus=vt;exports.PredictionPanelUI=rt;exports.PredictionResult=Ct;exports.PredictionSource=St;exports.SpotHistoryType=ht;exports.SpotPanelUI=st;exports.ViewingBannerUI=Xe;exports.computeDistribution=ft;exports.curveDataQueryKey=Qt;exports.distributionQueryKey=ir;exports.formatPercent=ct;exports.formatSignedUsd=ae;exports.formatTime=xt;exports.formatTokenBalance=Ie;exports.formatUsd=N;exports.getExplorerUrl=mt;exports.overviewQueryKey=It;exports.parseDecimal=Dn;exports.perpsHistoryQueryKey=Dt;exports.perpsPositionsQueryKey=Ut;exports.predictionBetsQueryKey=Et;exports.predictionSettledQueryKey=Rt;exports.splitUsd=ut;exports.spotHistoryQueryKey=Ht;exports.spotHoldingsQueryKey=Ft;exports.truncateAddress=te;exports.useAccountInfo=ke;exports.useCurveDataQuery=$e;exports.useDistributionQuery=Ye;exports.useHoldingsSection=tt;exports.useOverviewQuery=Le;exports.usePerpsHistoryQuery=Me;exports.usePerpsPositionsQuery=Ve;exports.usePortfolioClient=I;exports.usePortfolioContext=se;exports.usePortfolioPage=ze;exports.usePredictionBetsQuery=Ke;exports.usePredictionSettledQuery=qe;exports.useRefetchWalletSummary=ar;exports.useSpotHistoryQuery=_e;exports.useSpotHoldingsQuery=pe;exports.useWalletPortfolios=gr;exports.useWalletSummary=Ae;exports.version=$t;//# sourceMappingURL=index.js.map
1
+ 'use strict';var react=require('react'),uiChainSelect=require('@liberfi.io/ui-chain-select'),utils=require('@liberfi.io/utils'),walletConnector=require('@liberfi.io/wallet-connector'),i18n=require('@liberfi.io/i18n'),ui=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),react$1=require('@liberfi.io/react');typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-portfolio"]="0.1.40");var $t="0.1.40";var re=react.createContext(null);var ne=react.createContext({}),ge=react.createContext({});function se(){let e=react.useContext(ne);if(!e)throw new Error("usePortfolioContext must be used within a PortfolioProvider");return e}function we(){let{summary:e,summaryStatus:t}=se();return {data:e,...t}}function Te(){let{status:e,signIn:t,signOut:o}=walletConnector.useAuth(),{data:r}=we(),{chain:s,chainNamespace:p}=uiChainSelect.useCurrentChain(),i=walletConnector.useConnectedWallet(s),n=react.useMemo(()=>utils.getNativeToken(s),[s]),a=react.useMemo(()=>r?.balanceInUsd?utils.formatAmountUSD(r.balanceInUsd):"--",[r?.balanceInUsd]),l=react.useMemo(()=>r?.balanceInNative?utils.formatAmount(r.balanceInNative):"--",[r?.balanceInNative]);return {status:e,signIn:t,signOut:o,balanceUsdFormatted:a,balanceNativeFormatted:l,nativeToken:n,chainNamespace:p,walletAddress:i?.address??""}}function Ie({status:e,signIn:t,signOut:o,balanceUsdFormatted:r,balanceNativeFormatted:s,nativeToken:p,chainNamespace:i,walletAddress:n,actions:a}){let{t:l}=i18n.useTranslation(),{isMobile:d}=ui.useScreen(),{isOpen:c,onClose:b,onOpenChange:C}=ui.useDisclosure(),T=ui.useCopyToClipboard(),x=react.useCallback(()=>{T(n,()=>ui.toast.success(l("common.primaryAddressCopied",{network:i.toUpperCase()})));},[T,i,n]);return e==="unauthenticated"?jsxRuntime.jsx(ui.Button,{isIconOnly:d,size:"sm",color:"primary",radius:"full",disableRipple:true,onPress:t,startContent:d?void 0:jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}),"aria-label":l("common.signIn"),children:d?jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}):l("common.signIn")}):e==="authenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:d,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":l("common.signingIn"),children:l("common.signingIn")}):e==="deauthenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:d,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":l("common.signingOut"),children:l("common.signingOut")}):jsxRuntime.jsxs(ui.StyledPopover,{placement:d?"bottom":"bottom-end",isOpen:c,onOpenChange:C,triggerScaleOnOpen:false,children:[jsxRuntime.jsx(ui.PopoverTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",className:"bg-content2",radius:"full",disableRipple:true,startContent:jsxRuntime.jsx(ui.WalletIcon,{width:16,height:16,className:"text-neutral"}),endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{width:16,height:16,className:ui.cn("text-neutral transition-transform",c&&"rotate-180")}),children:p&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.TokenIcon,{symbol:p.symbol,size:16}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:d?s:`${s} ${p.symbol}`})]})})}),jsxRuntime.jsx(ui.PopoverContent,{children:jsxRuntime.jsxs("div",{className:"w-70 flex flex-col gap-3 py-4",children:[jsxRuntime.jsxs("div",{className:"px-4 flex items-start justify-between",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-xs text-neutral",children:l("common.totalValue")}),jsxRuntime.jsx("span",{className:"text-base font-semibold text-foreground",children:r})]}),jsxRuntime.jsx("div",{className:"flex items-start justify-end gap-0.5",children:jsxRuntime.jsx(ui.StyledTooltip,{content:l("common.copyPrimaryAddress",{network:i.toUpperCase()}),children:jsxRuntime.jsx(ui.Button,{className:"text-xs bg-transparent text-neutral hover:text-foreground h-4 min-h-4 gap-1",startContent:jsxRuntime.jsx(ui.CopyIcon,{width:14,height:14}),disableRipple:true,disableAnimation:true,onPress:x,children:i.toUpperCase()})})})]}),jsxRuntime.jsx(ui.Divider,{}),jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-2 px-4",children:[a?.map(y=>jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-foreground transition-colors hover:text-primary",onClick:()=>{y.onPress(),b();},children:[y.icon,jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:y.label})]},y.key)),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-danger transition-colors hover:text-danger/80",onClick:()=>{o(),b();},children:[jsxRuntime.jsx(ui.SignOutIcon,{width:16,height:16}),jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:l("common.signOut")})]})]})]})})]})}function Po({actions:e}){let t=Te();return jsxRuntime.jsx(Ie,{status:t.status,signIn:t.signIn,signOut:t.signOut,balanceUsdFormatted:t.balanceUsdFormatted,balanceNativeFormatted:t.balanceNativeFormatted,nativeToken:t.nativeToken,chainNamespace:t.chainNamespace,walletAddress:t.walletAddress,actions:e})}function Dn(e){if(!e)return 0;let t=Number(e);return Number.isFinite(t)?t:0}function N(e){let t=Math.abs(e),o=e<0?"-":"";return t>=1e6?`${o}$${(t/1e6).toFixed(1)}M`:t>=1e4?`${o}$${(t/1e3).toFixed(1)}K`:t>=1?`${o}$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`:t>=.01?`${o}$${t.toFixed(2)}`:t>0?`${o}<$0.01`:"$0.00"}function ae(e){let t=N(Math.abs(e));return e>0?`+${t}`:e<0?`-${t.replace("-","")}`:t}function ct(e){return `${e>0?"+":""}${e.toFixed(2)}%`}function ut(e){let o=Math.abs(e).toFixed(2).split("."),r=Number(o[0]).toLocaleString("en-US"),s=`.${o[1]}`;return {sign:e<0?"-$":"$",integer:r,decimal:s}}function te(e,t=4,o=4){return e.length<=t+o+3?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`}function Fe(e){return e===0?"0":e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?e.toLocaleString("en-US",{maximumFractionDigits:2}):e>=1?e.toFixed(2):e>=1e-4?e.toFixed(4):"<0.0001"}function mt(e,t){return `https://solscan.io/tx/${e}`}var dt=["#C8FF00","#00E676","#0066FF","#FF6B9D","#8B7BFF","#FF5252","#FFB74D","#4DD0E1"],vo="#3A3A4E";function ft(e){let t=e.reduce((i,n)=>i+n.value,0);if(t<=0)return {items:[]};let o=[...e].sort((i,n)=>n.value-i.value),r=[],s=0,p=0;for(let i of o){let n=i.value/t*100;n<2?s+=i.value:(r.push({name:i.name,symbol:i.symbol,percent:n,value:i.value,color:dt[p%dt.length]}),p++);}return s>0&&r.push({name:"Other",symbol:"OTHER",percent:s/t*100,value:s,color:vo}),{items:r}}function xt(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false})}function He({walletId:e,wallets:t,isViewing:o,viewingAddress:r,onSelectWallet:s,onCopyAddress:p,onSearch:i}){let[n,a]=react.useState(false),[l,d]=react.useState(""),c=react.useRef(null),b=!e&&!o,C=t.find(P=>P.id===e),T=o?"External":b?"All Wallets":C?.name??"",x=o?te(r??""):b?"Aggregated":te(C?.address??""),y=o?"bg-[#5C5C72]":b?"bg-[#C8FF00]":"bg-[#00E676]",g=react.useCallback(()=>{let P=l.trim();P.length>=32&&(i(P),d(""));},[l,i]),k=react.useCallback(P=>{P.key==="Enter"&&g();},[g]);return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex items-center gap-2 rounded-lg border px-2.5 py-1.5 transition-colors",o?"border-[rgba(200,255,0,0.2)] bg-[rgba(200,255,0,0.04)]":"border-[#252530] bg-[#16161E] hover:border-[#35354A] hover:bg-[#1C1C26]",o&&"pointer-events-none"),onClick:()=>!o&&a(P=>!P),children:[jsxRuntime.jsx("span",{className:ui.cn("h-[7px] w-[7px] flex-shrink-0 rounded-full",y)}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-[#A0A0B8]",children:T}),jsxRuntime.jsx("span",{className:"font-mono text-xs text-foreground",children:x}),!o&&jsxRuntime.jsx("svg",{className:ui.cn("text-[#5C5C72] transition-transform",n&&"rotate-180"),width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})]}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(false)}),jsxRuntime.jsxs("div",{className:"absolute left-0 top-[calc(100%+4px)] z-50 min-w-[260px] rounded-lg border border-[#252530] bg-[#16161E] p-1 shadow-[0_8px_32px_rgba(0,0,0,0.4)]",children:[jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",b&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{s(void 0),a(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#C8FF00]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:"All Wallets"}),jsxRuntime.jsx("span",{className:"text-[11px] text-[#3A3A4E]",children:"Aggregated"})]}),t.map(P=>jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",e===P.id&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{s(P.id),a(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#00E676]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:P.name}),jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#5C5C72]",children:te(P.address)}),jsxRuntime.jsx("span",{className:"ml-auto font-mono text-[11px] font-medium text-foreground",children:P.balance})]},P.id))]})]})]}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded p-1 text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-[#C8FF00]",b&&!o&&"pointer-events-none opacity-40"),onClick:p,disabled:b&&!o,children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[jsxRuntime.jsx("rect",{x:"4.5",y:"4.5",width:"7",height:"7",rx:"1.5",stroke:"currentColor",strokeWidth:"1.2"}),jsxRuntime.jsx("path",{d:"M9.5 4.5V3a1.5 1.5 0 0 0-1.5-1.5H3A1.5 1.5 0 0 0 1.5 3v5A1.5 1.5 0 0 0 3 9.5h1.5",stroke:"currentColor",strokeWidth:"1.2"})]})}),jsxRuntime.jsx("span",{className:ui.cn("flex-shrink-0 rounded-[3px] px-1.5 py-[3px] text-[9px] font-semibold uppercase tracking-wider",o?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00] animate-[pulse-glow_2s_ease-in-out_infinite]":"bg-[rgba(0,230,118,0.1)] text-[#00E676]"),children:o?"Viewing":"Owner"})]}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex h-[34px] w-[240px] items-center gap-1.5 rounded-lg border border-[#252530] bg-[#16161E] px-2.5 transition-all focus-within:w-[300px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{className:"flex-shrink-0 text-[#5C5C72]",width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{className:"flex-1 border-none bg-transparent font-mono text-xs text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[11px] placeholder:text-[#5C5C72]",placeholder:"Search wallet address\u2026",spellCheck:false,value:l,onChange:P=>d(P.target.value),onKeyDown:k})]}),jsxRuntime.jsx("button",{type:"button",className:"whitespace-nowrap rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:g,children:"View"})]})]})}var le=(r=>(r.SPOT="spot",r.PERPS="perps",r.PREDICTION="prediction",r))(le||{}),Ue=(o=>(o.NET_WORTH="networth",o.PNL="pnl",o))(Ue||{}),De=(s=>(s.ONE_DAY="1D",s.SEVEN_DAY="7D",s.THIRTY_DAY="30D",s.MAX="Max",s))(De||{}),bt={"1D":1,"7D":7,"30D":30,Max:365},Pt=(o=>(o.LONG="long",o.SHORT="short",o))(Pt||{}),ht=(r=>(r.SWAP="swap",r.SEND="send",r.RECEIVE="receive",r))(ht||{}),vt=(o=>(o.ACTIVE="active",o.PENDING="pending",o))(vt||{}),Ct=(o=>(o.WON="won",o.LOST="lost",o))(Ct||{}),St=(r=>(r.POLYMARKET="polymarket",r.DRIFT="drift",r.METADAO="metadao",r))(St||{});var Ao=[{key:"spot",label:"Spot"},{key:"perps",label:"Perps"},{key:"prediction",label:"Prediction"}];function wo(e,t,o,r){switch(e){case "spot":return t;case "perps":return o;case "prediction":return r}}function Ee({activeTab:e,onTabChange:t,spotValue:o=0,perpsValue:r=0,predictionValue:s=0}){return jsxRuntime.jsx("div",{className:"flex gap-1 border-b border-[#252530] pb-0 pt-5",children:Ao.map(({key:p,label:i})=>{let n=e===p,a=wo(p,o,r,s);return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("relative flex items-center gap-2 border-b-2 px-4 pb-3 pt-2.5 text-[13px] font-medium transition-colors",n?"border-[#C8FF00] text-foreground":"border-transparent text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:()=>t(p),children:[i,!n&&jsxRuntime.jsx("span",{className:"rounded-[10px] bg-[#16161E] px-2 py-0.5 font-mono text-[11px] text-[#5C5C72]",children:N(a)})]},p)})})}function Qe({overview:e}){let t=e?.totalValue??0,o=e?.uPnl??0,r=e?.realizedPnl??0,s=e?.totalProfit??0,{sign:p,integer:i,decimal:n}=ut(t);return jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsx("div",{className:"flex items-baseline gap-3",children:jsxRuntime.jsxs("div",{className:"font-mono text-[26px] font-bold leading-none tracking-tight",children:[jsxRuntime.jsx("span",{className:"mr-px text-lg font-medium text-[#C8FF00]",children:p}),i,jsxRuntime.jsx("span",{className:"text-base font-normal text-[#5C5C72]",children:n})]})}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(Re,{label:"uPNL",value:o}),jsxRuntime.jsx(At,{}),jsxRuntime.jsx(Re,{label:"Realized",value:r}),jsxRuntime.jsx(At,{}),jsxRuntime.jsx(Re,{label:"Total Profit",value:s})]})]})}function Re({label:e,value:t}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[#5C5C72]",children:e}),jsxRuntime.jsx("span",{className:ui.cn("font-mono text-xs font-medium",t>0?"text-[#00E676]":t<0?"text-[#FF5252]":"text-[#5C5C72]"),children:ae(t)})]})}function At(){return jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"})}var Ro=["1D","7D","30D","Max"];function wt(e,t){let o=new Date(e);return t==="1D"?o.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Qo(e){return e==="pnl"?"change":"netWorth"}function Be({curveType:e,curvePeriod:t,data:o,isLoading:r,onTypeChange:s,onPeriodChange:p}){let i=o?.points??[],n=Qo(e),a=e==="pnl",l=react.useMemo(()=>i.map(x=>a?x.change:x.netWorth),[i,a]),d=l.some(x=>x<0),{minVal:c,maxVal:b}=react.useMemo(()=>{if(l.length===0)return {minVal:0,maxVal:100};let x=Math.min(...l),y=Math.max(...l),g=y-x||1;return {minVal:x-g*.1,maxVal:y+g*.1}},[l]),C=react.useMemo(()=>{if(i.length===0)return [];let x=Math.min(7,i.length),y=Math.max(1,Math.floor((i.length-1)/(x-1))),g=[];for(let P=0;P<i.length;P+=y)g.push({ts:i[P].timestamp,label:wt(i[P].timestamp,t)});let k=i[i.length-1];return g[g.length-1]?.ts!==k.timestamp&&g.push({ts:k.timestamp,label:wt(k.timestamp,t)}),g},[i,t]),T=l[l.length-1]??0;return jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 pt-3",children:[jsxRuntime.jsxs("div",{className:"flex gap-0.5 rounded-[5px] bg-[#16161E] p-0.5",children:[jsxRuntime.jsx(kt,{label:"Net Worth",active:e==="networth",onClick:()=>s("networth")}),jsxRuntime.jsx(kt,{label:"PNL",active:e==="pnl",onClick:()=>s("pnl")})]}),jsxRuntime.jsx("div",{className:"flex gap-0.5",children:Ro.map(x=>jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-[3px] px-2 py-1 text-[10px] font-medium transition-colors",t===x?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00]":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>p(x),children:x},x))})]}),jsxRuntime.jsx("div",{className:"h-[180px] px-4 pt-2",children:r||i.length<2?jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:r?"":"Not enough data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.AreaChart,{data:i,margin:{top:8,right:0,left:0,bottom:0},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{id:"gradAccent",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#C8FF00",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#C8FF00",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradGreen",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#00E676",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#00E676",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradRed",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#FF5252",stopOpacity:0}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#FF5252",stopOpacity:.1})]})]}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",hide:true}),jsxRuntime.jsx(recharts.YAxis,{hide:true,domain:[c,b]}),a&&d&&jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:n,stroke:a?T>=0?"#00E676":"#FF5252":"#C8FF00",strokeWidth:1.5,fill:a?T>=0?"url(#gradGreen)":"url(#gradRed)":"url(#gradAccent)",dot:false,isAnimationActive:false})]})})}),jsxRuntime.jsx("div",{className:"flex justify-between px-4 pb-2.5 pt-1",children:C.map(({ts:x,label:y})=>jsxRuntime.jsx("span",{className:"font-mono text-[9px] text-[#3A3A4E]",children:y},x))})]})}function kt({label:e,active:t,onClick:o}){return jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded px-2.5 py-1 text-[11px] font-medium transition-colors",t?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:o,children:e})}function Le({data:e,isLoading:t}){let o=e?.items??[],r=react.useMemo(()=>o.map(s=>({name:s.name,value:s.percent})),[o]);return jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsx("div",{className:"px-4 pb-2 pt-3",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[#A0A0B8]",children:"Distribution"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center justify-center px-4",children:t||o.length===0?jsxRuntime.jsx("div",{className:"flex h-[140px] w-[140px] items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:t?"":"No data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:140,height:140,children:jsxRuntime.jsx(recharts.PieChart,{children:jsxRuntime.jsx(recharts.Pie,{data:r,cx:"50%",cy:"50%",innerRadius:32,outerRadius:55,dataKey:"value",stroke:"none",isAnimationActive:false,children:o.map((s,p)=>jsxRuntime.jsx(recharts.Cell,{fill:s.color},p))})})})}),jsxRuntime.jsx("div",{className:"px-4 pb-3 pt-2",children:o.map((s,p)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 py-[3px] text-[11px]",children:[jsxRuntime.jsx("span",{className:"h-[7px] w-[7px] flex-shrink-0 rounded-[2px]",style:{background:s.color}}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-[#A0A0B8]",children:s.name}),jsxRuntime.jsxs("span",{className:"font-mono text-[10px] text-[#5C5C72]",children:[s.percent.toFixed(1),"%"]}),jsxRuntime.jsx("span",{className:"min-w-[55px] text-right font-mono text-[10px] text-foreground",children:N(s.value)})]},p))})]})}function I(){let e=react.useContext(re);if(!e)throw new Error("usePortfolioClient must be used within a PortfolioClientProvider");return e}function It(e){return ["portfolio","overview",e??{}]}async function Ko(e,t){return await e.getOverview(t)}function _e(e,t={}){let o=I();return reactQuery.useQuery({queryKey:It(e),queryFn:async()=>Ko(o,e),...t})}function Ft(e){return ["portfolio","spot","holdings",e??{}]}async function $o(e,t){return await e.getSpotHoldings(t)}function pe(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Ft(e),queryFn:async()=>$o(o,e),...t})}function Ht(e){return ["portfolio","spot","history",e??{}]}async function jo(e,t){return await e.getSpotHistory(t)}function Ve(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Ht(e),queryFn:async()=>jo(o,e),...t})}function Ut(e){return ["portfolio","perps","positions",e??{}]}async function Go(e,t){return await e.getPerpsPositions(t)}function Me(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Ut(e),queryFn:async()=>Go(o,e),...t})}function Dt(e){return ["portfolio","perps","history",e??{}]}async function Jo(e,t){return await e.getPerpsHistory(t)}function Ke(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Dt(e),queryFn:async()=>Jo(o,e),...t})}function Et(e){return ["portfolio","prediction","active",e??{}]}async function er(e,t){return await e.getPredictionBets(t)}function qe(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Et(e),queryFn:async()=>er(o,e),...t})}function Rt(e){return ["portfolio","prediction","settled",e??{}]}async function or(e,t){return await e.getPredictionSettled(t)}function $e(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Rt(e),queryFn:async()=>or(o,e),...t})}function Qt(e){return ["portfolio","chart",e]}async function nr(e,t){return await e.getChartData(t)}function Ye(e,t={}){let o=I();return reactQuery.useQuery({queryKey:Qt(e),queryFn:async()=>nr(o,e),...t})}function ir(){return ["portfolio","distribution"]}function je(e){return {data:react.useMemo(()=>ft(e),[e])}}function ar(){let{refetchSummary:e}=se();return e}var xr=15e3;function Bt(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function gr({chain:e,address:t,tokenAddresses:o,pollMs:r=xr}){let s=!!t&&o.length>0,[p,i]=react.useState({}),n=react$1.useWalletPortfoliosByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:s,refetchInterval:r}),a=react$1.useWalletPortfolioPnlsByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:s,refetchInterval:r});react.useEffect(()=>{let T=n.data??[],x=new Map;if(a.data)for(let g of a.data)x.set(g.address,g);let y={};for(let g of T)y[g.address]={...g,pnl:x.get(g.address)??null};i(y);},[n.data,a.data]);let l=react.useRef(""),d=react.useRef(new Set),c=o.slice().sort().join(",");c!==l.current&&(l.current=c,d.current=new Set(o));let b=d.current;react$1.useWalletPortfoliosSubscription({chain:e,address:t},T=>{i(x=>{let y=x;for(let g of T){if(!b.has(g.tokenAddress))continue;let k=y[g.tokenAddress];if(!k)continue;let{chain:P,walletAddress:L,tokenAddress:V,...E}=g,M=Bt(E);Object.keys(M).length!==0&&(y=y===x?{...x}:y,y[g.tokenAddress]={...k,...M});}return y});},{enabled:s}),react$1.useWalletPortfolioPnlsSubscription({chain:e,address:t},T=>{i(x=>{let y=x;for(let g of T){if(!b.has(g.tokenAddress))continue;let k=y[g.tokenAddress];if(!k||!k.pnl)continue;let{walletAddress:P,tokenAddress:L,...V}=g,E=Bt(V);Object.keys(E).length!==0&&(y=y===x?{...x}:y,y[g.tokenAddress]={...k,pnl:{...k.pnl,...E}});}return y});},{enabled:s});let C=react.useCallback(async()=>{await Promise.all([n.refetch(),a.refetch()]);},[n.refetch,a.refetch]);return {tokens:p,isPending:n.isPending,isFetching:n.isFetching||a.isFetching,isError:n.isError,isSuccess:n.isSuccess,error:n.error,refetch:C}}function Ge(e){let{defaultTab:t="spot",walletAddresses:o,chain:r}=e??{},[s,p]=react.useState(t),[i,n]=react.useState(void 0),[a,l]=react.useState(void 0),[d,c]=react.useState("networth"),[b,C]=react.useState("7D"),T=a!==void 0,x=react.useMemo(()=>{if(a)return {walletAddresses:[a],chain:r};if(o?.length)return {walletAddresses:o,chain:r}},[o,a,r]),y=_e(x),g=pe(x),k=Ye({period:bt[b],...x}),P=je(g.data?.holdings??[]),L=react.useMemo(()=>g.data?.holdings.reduce((O,fe)=>O+fe.value,0)??0,[g.data]),V=react.useCallback(O=>{l(O);},[]),E=react.useCallback(()=>{l(void 0);},[]),M=react.useCallback(O=>{n(O);},[]);return {activeTab:s,setActiveTab:p,walletId:i,selectWallet:M,viewingAddress:a,isViewing:T,curveType:d,setCurveType:c,curvePeriod:b,setCurvePeriod:C,portfolioQuery:x,overviewQuery:y,curveQuery:k,distributionQuery:P,spotHoldingsQuery:g,spotValue:L,perpsValue:0,predictionValue:0,enterViewing:V,exitViewing:E}}function Xe(){return jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsxs("div",{className:"flex gap-4 border-b border-[#252530] pb-0 pt-5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-16 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-28 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-32 rounded-md"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 py-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-6 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-14 rounded-[3px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-[240px] rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-12 rounded-[5px]"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"})]}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-32 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[180px] w-full rounded-md"}),jsxRuntime.jsx("div",{className:"mt-2 flex justify-between",children:Array.from({length:7}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-8 rounded"},t))})]}),jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-4 w-24 rounded"}),jsxRuntime.jsx("div",{className:"flex items-center justify-center py-4",children:jsxRuntime.jsx(ui.Skeleton,{className:"h-[140px] w-[140px] rounded-full"})}),jsxRuntime.jsx("div",{className:"space-y-1.5 pt-2",children:Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-full rounded"},t))})]})]}),jsxRuntime.jsxs("div",{className:"pb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-40 rounded-[5px]"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-[5px]"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-5 w-full rounded"}),Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"mb-2 h-12 w-full rounded-[5px]"},t))]})]})}function Je({viewingAddress:e,onBack:t}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-[rgba(200,255,0,0.12)] bg-[rgba(200,255,0,0.06)] px-6 py-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-full border border-[rgba(200,255,0,0.25)] bg-[rgba(200,255,0,0.07)]",children:jsxRuntime.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M8 3C4.36 3 1.26 5.28 0 8.5c1.26 3.22 4.36 5.5 8 5.5s6.74-2.28 8-5.5C14.74 5.28 11.64 3 8 3z",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8.5",r:"2.5",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"})]})}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-[#C8FF00]",children:"Viewing external portfolio"}),jsxRuntime.jsx("span",{className:"ml-1 font-mono text-[11px] text-[#A0A0B8]",children:te(e)})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:t,children:[jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 2L4 8l6 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to My Portfolio"]})]})}function yr({wallets:e=[],onCopyAddress:t,renderHoldings:o,isLoading:r,...s}){let p=Ge(s),{activeTab:i,setActiveTab:n,walletId:a,selectWallet:l,viewingAddress:d,isViewing:c,curveType:b,setCurveType:C,curvePeriod:T,setCurvePeriod:x,portfolioQuery:y,overviewQuery:g,curveQuery:k,distributionQuery:P,spotValue:L,perpsValue:V,predictionValue:E,enterViewing:M,exitViewing:O}=p;return r||g.isLoading&&!g.data?jsxRuntime.jsx(Xe,{}):jsxRuntime.jsxs("div",{children:[c&&d&&jsxRuntime.jsx(Je,{viewingAddress:d,onBack:O}),jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsx(Ee,{activeTab:i,onTabChange:n,spotValue:L,perpsValue:V,predictionValue:E}),jsxRuntime.jsx(He,{walletId:a,wallets:e,isViewing:c,viewingAddress:d,onSelectWallet:l,onCopyAddress:()=>{if(c&&d)t?.(d);else {let xe=e.find(Ae=>Ae.id===a);xe&&t?.(xe.address);}},onSearch:M}),jsxRuntime.jsx(Qe,{overview:g.data}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsx(Be,{curveType:b,curvePeriod:T,data:k.data,isLoading:k.isLoading,onTypeChange:C,onPeriodChange:x}),jsxRuntime.jsx(Le,{data:P.data,isLoading:false})]}),o?.({activeTab:i,portfolioQuery:y,isViewing:c})]})]})}function Pe({open:e,title:t,message:o,confirmLabel:r,cancelLabel:s,onConfirm:p,onCancel:i}){return e?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:i,onKeyDown:n=>{n.key==="Escape"&&i();},role:"button",tabIndex:-1,"aria-label":"Close dialog"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-w-sm rounded-xl border border-[#252530] bg-[#12121A] p-6 shadow-2xl",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-foreground",children:t}),jsxRuntime.jsx("p",{className:"mt-2 text-xs leading-relaxed text-[#A0A0B8]",children:o}),jsxRuntime.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[jsxRuntime.jsx("button",{type:"button",className:"rounded-lg px-4 py-2 text-xs font-medium text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-foreground",onClick:i,children:s}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-lg border px-4 py-2 text-xs font-medium transition-colors","border-[rgba(255,82,82,0.25)] text-[#FF5252]","hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:p,children:r})]})]})]}):null}function ot({activeTab:e,portfolioQuery:t,isViewing:o}){let[r,s]=react.useState("holdings"),[p,i]=react.useState("positions"),[n,a]=react.useState("active"),[l,d]=react.useState(""),[c,b]=react.useState(""),[C,T]=react.useState(""),[x,y]=react.useState(false),[g,k]=react.useState(false),P=react.useCallback(()=>{k(K=>!K);},[]),L=pe(t,{enabled:e==="spot"}),V=Ve(t,{enabled:e==="spot"&&r==="history"}),E=Me(t,{enabled:e==="perps"}),M=Ke(t,{enabled:e==="perps"&&p==="history"}),O=qe(t,{enabled:e==="prediction"}),fe=$e(t,{enabled:e==="prediction"&&n==="settled"}),at=react.useMemo(()=>(L.data?.holdings??[]).filter(q=>{if(x&&q.value<1&&!q.verified)return false;if(l){let ee=l.toLowerCase();return q.name.toLowerCase().includes(ee)||q.symbol.toLowerCase().includes(ee)}return true}),[L.data?.holdings,x,l]),xe=react.useMemo(()=>{let K=E.data?.positions??[];if(!c)return K;let q=c.toLowerCase();return K.filter(ee=>ee.pair.toLowerCase().includes(q))},[E.data?.positions,c]),Ae=react.useMemo(()=>{let K=O.data?.bets??[];if(!C)return K;let q=C.toLowerCase();return K.filter(ee=>ee.market.toLowerCase().includes(q))},[O.data?.bets,C]);return {spotSubTab:r,setSpotSubTab:s,perpsSubTab:p,setPerpsSubTab:i,predictionSubTab:n,setPredictionSubTab:a,spotSearch:l,setSpotSearch:d,perpsSearch:c,setPerpsSearch:b,predictionSearch:C,setPredictionSearch:T,hideSmall:x,setHideSmall:y,groupCollapsed:g,toggleGroupCollapsed:P,spotHoldingsQuery:L,spotHistoryQuery:V,perpsPositionsQuery:E,perpsHistoryQuery:M,predictionBetsQuery:O,predictionSettledQuery:fe,filteredSpotHoldings:at,filteredPerpsPositions:xe,filteredPredictionBets:Ae,isViewing:o}}function J({tabs:e,activeKey:t,onTabChange:o}){return jsxRuntime.jsx("div",{className:"flex gap-0.5",children:e.map(r=>jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-[5px] px-3 py-1.5 text-xs font-medium transition-colors",t===r.key?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>o(r.key),children:r.label},r.key))})}function Z({value:e,onChange:t,placeholder:o}){return jsxRuntime.jsxs("div",{className:"flex h-7 w-40 items-center gap-1 rounded-[5px] border border-[#252530] bg-[#16161E] px-2 transition-all focus-within:w-[200px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",className:"flex-shrink-0 text-[#5C5C72]",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",className:"flex-1 border-none bg-transparent font-mono text-[11px] text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[10px] placeholder:text-[#5C5C72]",placeholder:o,spellCheck:false,value:e,onChange:r=>t(r.target.value)})]})}function W({title:e,hint:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[jsxRuntime.jsx("span",{className:"text-sm text-[#5C5C72]",children:e}),t&&jsxRuntime.jsx("span",{className:"mt-1 text-xs text-[#3A3A4E]",children:t})]})}function ue({label:e,disabled:t,onClick:o}){return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex items-center gap-1 whitespace-nowrap rounded-[5px] border px-3 py-1.5 text-[11px] font-medium transition-colors",t?"pointer-events-none border-[#252530] text-[#3A3A4E]":"border-[rgba(255,82,82,0.25)] text-[#FF5252] hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:o,disabled:t,children:[jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),e]})}function rt({state:e,onClosePosition:t,onCloseAll:o}){let{perpsSubTab:r,setPerpsSubTab:s,perpsSearch:p,setPerpsSearch:i,filteredPerpsPositions:n,perpsHistoryQuery:a,isViewing:l}=e,d=n.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(J,{tabs:[{key:"positions",label:"Open Positions"},{key:"history",label:"Trade History"}],activeKey:r,onTabChange:c=>s(c)}),r==="positions"&&!l&&jsxRuntime.jsx(ue,{label:"Close All",disabled:!d,onClick:()=>o?.()})]}),jsxRuntime.jsx(Z,{value:p,onChange:i,placeholder:"Search pair\u2026"})]}),r==="positions"?jsxRuntime.jsx(hr,{positions:n,isViewing:l,onClose:t}):jsxRuntime.jsx(Cr,{records:a.data?.records??[],isLoading:a.isLoading})]})}function hr({positions:e,isViewing:t,onClose:o}){return e.length===0?jsxRuntime.jsx(W,{title:"No open positions",hint:"Start trading \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsx("span",{children:"Pair / Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"Entry"}),jsxRuntime.jsx("span",{className:"text-right",children:"Mark"}),jsxRuntime.jsx("span",{className:"text-right",children:"uPNL"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(vr,{position:r,isViewing:t,onClose:o},r.id))})]})}function vr({position:e,isViewing:t,onClose:o}){let r=e.side==="long",s=e.uPnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair}),jsxRuntime.jsx("span",{className:ui.cn("rounded px-1.5 py-0.5 text-[10px] font-medium",r?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:r?"Long":"Short"}),jsxRuntime.jsxs("span",{className:"rounded bg-[rgba(200,255,0,0.1)] px-1.5 py-0.5 text-[10px] font-medium text-[#C8FF00]",children:[e.leverage,"\xD7"]})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.size)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.entryPrice)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.markPrice)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",s?"text-[#00E676]":"text-[#FF5252]"),children:ae(e.uPnl)}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Close"})})]})}function Cr({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(W,{title:"No trade history",hint:"Closed positions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsx("span",{children:"Pair"}),jsxRuntime.jsx("span",{children:"Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"PNL"}),jsxRuntime.jsx("span",{className:"text-right",children:"Close Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Sr,{record:o},o.id))})]})}function Sr({record:e}){let t=e.side==="long",o=e.pnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair})]}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Long":"Short"})}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.size)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",o?"text-[#00E676]":"text-[#FF5252]"),children:ae(e.pnl)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.closePrice)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.time})]})}function nt({state:e,onSellBet:t,onSellAll:o}){let{predictionSubTab:r,setPredictionSubTab:s,predictionSearch:p,setPredictionSearch:i,filteredPredictionBets:n,predictionSettledQuery:a,isViewing:l}=e,d=n.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(J,{tabs:[{key:"active",label:"Active Bets"},{key:"settled",label:"Settled"}],activeKey:r,onTabChange:c=>s(c)}),r==="active"&&!l&&jsxRuntime.jsx(ue,{label:"Sell All",disabled:!d,onClick:()=>o?.()})]}),jsxRuntime.jsx(Z,{value:p,onChange:i,placeholder:"Search market\u2026"})]}),r==="active"?jsxRuntime.jsx(wr,{bets:n,isViewing:l,onSell:t}):jsxRuntime.jsx(Tr,{records:a.data?.records??[],isLoading:a.isLoading})]})}var Nr={polymarket:"bg-[rgba(0,102,255,0.12)] text-[#0066FF]",drift:"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]",metadao:"bg-[rgba(255,107,157,0.1)] text-[#FF6B9D]"},Ar={polymarket:"Polymarket",drift:"Drift",metadao:"MetaDAO"};function _t({source:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Nr[e]),children:Ar[e]})}function wr({bets:e,isViewing:t,onSell:o}){return e.length===0?jsxRuntime.jsx(W,{title:"No active bets",hint:"Explore prediction markets \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsx("span",{children:"Market / Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Potential"}),jsxRuntime.jsx("span",{className:"text-right",children:"Status"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(kr,{bet:r,isViewing:t,onSell:o},r.id))})]})}function kr({bet:e,isViewing:t,onSell:o}){return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market}),jsxRuntime.jsx(_t,{source:e.source})]})]}),jsxRuntime.jsx("span",{className:ui.cn("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.stake)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#00E676]",children:N(e.potential)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",e.status==="active"?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]"),children:e.status==="active"?"Active":"Pending"})}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Sell"})})]})}function Tr({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(W,{title:"No settled bets",hint:"Settled predictions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsx("span",{children:"Market"}),jsxRuntime.jsx("span",{children:"Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Result"}),jsxRuntime.jsx("span",{className:"text-right",children:"Payout"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Ir,{record:o},o.id))})]})}function Ir({record:e}){let t=e.result==="won";return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market})]}),jsxRuntime.jsx(_t,{source:e.source}),jsxRuntime.jsx("span",{className:ui.cn("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.stake)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Won":"Lost"})}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#5C5C72]"),children:t?`+${N(e.payout)}`:N(e.payout)})]})}function it({state:e}){let{spotSubTab:t,setSpotSubTab:o,spotSearch:r,setSpotSearch:s,hideSmall:p,setHideSmall:i,groupCollapsed:n,toggleGroupCollapsed:a,filteredSpotHoldings:l,spotHistoryQuery:d}=e;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(J,{tabs:[{key:"holdings",label:"Holdings"},{key:"history",label:"History"}],activeKey:t,onTabChange:c=>o(c)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Z,{value:r,onChange:s,placeholder:"Search token\u2026"}),t==="holdings"&&jsxRuntime.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-[11px] text-[#5C5C72] select-none",children:[jsxRuntime.jsx("input",{type:"checkbox",className:"accent-[#C8FF00]",checked:p,onChange:c=>i(c.target.checked)}),"Hide small"]})]})]}),t==="holdings"?jsxRuntime.jsx(Fr,{holdings:l,groupCollapsed:n,onToggleGroup:a}):jsxRuntime.jsx(Ur,{records:d.data?.trades??[],isLoading:d.isLoading})]})}function Fr({holdings:e,groupCollapsed:t,onToggleGroup:o}){return e.length===0?jsxRuntime.jsx(W,{title:"No tokens found",hint:"Your spot tokens will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsx("span",{children:"Asset"}),jsxRuntime.jsx("span",{className:"text-right",children:"Balance"}),jsxRuntime.jsx("span",{className:"text-right",children:"Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"24h"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72] transition-colors hover:text-[#A0A0B8]",onClick:o,children:[jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",className:ui.cn("transition-transform",t&&"-rotate-90"),children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsxRuntime.jsx("span",{children:"Tokens"}),jsxRuntime.jsx("span",{className:"text-[#3A3A4E]",children:e.length})]}),!t&&jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(Hr,{holding:r},r.tokenAddress))})]})}function Hr({holding:e}){let t=e.change24h>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[e.image?jsxRuntime.jsx("img",{src:e.image,alt:e.symbol,className:"h-7 w-7 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[10px] font-bold text-[#5C5C72]",children:e.symbol.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[10px] text-[#5C5C72]",children:e.symbol})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:Fe(e.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.price)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:N(e.value)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#FF5252]"),children:ct(e.change24h)})]})}function Ur({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(W,{title:"No history found",hint:"Transaction history will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:"Type"}),jsxRuntime.jsx("span",{children:"Detail"}),jsxRuntime.jsx("span",{className:"text-right",children:"Amount"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"}),jsxRuntime.jsx("span",{className:"text-right",children:"TxHash"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Qr,{record:o},`${o.txHash}-${o.tokenAddress}`))})]})}var Dr={swap:"bg-[rgba(139,123,255,0.12)] text-[#8B7BFF]",send:"bg-[rgba(255,82,82,0.12)] text-[#FF5252]",receive:"bg-[rgba(0,230,118,0.12)] text-[#00E676]"},Er={swap:"Swap",send:"Send",receive:"Receive"};function Rr(e){return e.type==="swap"&&e.sideTokenSymbol?`${e.tokenSymbol} \u2192 ${e.sideTokenSymbol}`:e.tokenName||e.tokenSymbol}function Qr({record:e}){let t=mt(e.txHash,e.chain);return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Dr[e.type]),children:Er[e.type]})}),jsxRuntime.jsx("span",{className:"truncate text-xs text-foreground",children:Rr(e)}),jsxRuntime.jsxs("span",{className:"text-right font-mono text-xs text-foreground",children:[Fe(e.tokenAmount)," ",e.tokenSymbol]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:N(e.valueUsd)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.timestamp?xt(e.timestamp):"\u2014"}),jsxRuntime.jsx("span",{className:"text-right",children:e.txHash?jsxRuntime.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-[11px] text-[#5C5C72] transition-colors hover:text-[#C8FF00]",children:[e.txHash.slice(0,4),"\u2026",e.txHash.slice(-3)]}):jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#3A3A4E]",children:"\u2014"})})]})}function Br({onClosePosition:e,onCloseAllPositions:t,onSellBet:o,onSellAllBets:r,...s}){let p=ot(s),[i,n]=react.useState(null),a=react.useCallback(()=>{n("closeAll");},[]),l=react.useCallback(()=>{n("sellAll");},[]),d=react.useCallback(()=>{i==="closeAll"?t?.():i==="sellAll"&&r?.(),n(null);},[i,t,r]),c=react.useCallback(()=>{n(null);},[]);return jsxRuntime.jsxs("div",{className:"rounded-xl border border-[#1C1C26] bg-[#0E0E16] p-4",children:[(()=>{switch(s.activeTab){case "spot":return jsxRuntime.jsx(it,{state:p});case "perps":return jsxRuntime.jsx(rt,{state:p,onClosePosition:e,onCloseAll:a});case "prediction":return jsxRuntime.jsx(nt,{state:p,onSellBet:o,onSellAll:l});default:return null}})(),jsxRuntime.jsx(Pe,{open:i==="closeAll",title:"Close All Positions",message:"Close all positions? This will route to each protocol to execute.",confirmLabel:"Confirm Close All",cancelLabel:"Cancel",onConfirm:d,onCancel:c}),jsxRuntime.jsx(Pe,{open:i==="sellAll",title:"Sell All Positions",message:"Sell all positions? This will route to each platform to execute.",confirmLabel:"Confirm Sell All",cancelLabel:"Cancel",onConfirm:d,onCancel:c})]})}function Lr({client:e,children:t}){return jsxRuntime.jsx(re.Provider,{value:e,children:t})}var Yr=15e3;function jr(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Vt({chain:e,address:t,enabled:o=true,summaryPollMs:r=Yr}){let{setSummary:s,setSummaryStatus:p,setRefetchSummary:i}=react.useContext(ge),n=react$1.useWalletPortfoliosQuery({chain:e,address:t},{enabled:o,refetchInterval:r}),a=react$1.useWalletPnlQuery({chain:e,address:t},{enabled:o,refetchInterval:r});react.useEffect(()=>{s(null);},[e,t,s]),react.useEffect(()=>{let d=n.isPending||a.isPending,c=n.isFetching||a.isFetching,b=n.isError||a.isError,C=n.isSuccess&&a.isSuccess;p({status:b?"error":C?"success":"pending",fetchStatus:c?"fetching":"idle",isLoading:d&&c,isPending:d,isFetching:c,isRefetching:C&&c,isError:b,isSuccess:C,error:n.error??a.error,dataUpdatedAt:Math.max(n.dataUpdatedAt,a.dataUpdatedAt)});},[n.isPending,n.isFetching,n.isError,n.isSuccess,n.error,n.dataUpdatedAt,a.isPending,a.isFetching,a.isError,a.isSuccess,a.error,a.dataUpdatedAt,p]),react.useEffect(()=>{let d=n.data,c=a.data;!d||!c||s({...c,balanceInUsd:d.balanceInUsd,balanceInNative:d.balanceInNative});},[n.data,a.data,s]),react$1.useWalletPnlSubscription({chain:e,address:t},d=>{s(c=>{if(!c)return c;let b=c;for(let C of d)b={...b,...jr(C)};return b});},{enabled:o});let l=react.useCallback(async()=>{await Promise.all([n.refetch(),a.refetch()]);},[n,a]);react.useEffect(()=>{i(l);},[l,i]);}function Gr({chain:e,address:t,children:o}){let[r,s]=react.useState(null),[p,i]=react.useState(Jr),n=react.useRef(()=>Promise.resolve()),a=react.useCallback(()=>n.current(),[]),l=react.useCallback(b=>{n.current=b;},[]),d=react.useMemo(()=>({summary:r,summaryStatus:p,refetchSummary:a}),[r,p,a]),c=react.useMemo(()=>({setSummary:s,setSummaryStatus:i,setRefetchSummary:l}),[s,i,l]);return jsxRuntime.jsx(ge.Provider,{value:c,children:jsxRuntime.jsx(ne.Provider,{value:d,children:jsxRuntime.jsx(Xr,{chain:e,address:t,children:o})})})}function Xr({chain:e,address:t,children:o}){return Vt({chain:e,address:t,enabled:!!t}),jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}var Jr={status:"pending",fetchStatus:"idle",isLoading:false,isPending:true,isFetching:false,isRefetching:false,isError:false,isSuccess:false,error:null,dataUpdatedAt:0};
2
+ exports.AccountInfoUI=Ie;exports.AccountInfoWidget=Po;exports.AddressRowUI=He;exports.AssetTab=le;exports.AssetTabsUI=Ee;exports.BalanceRowUI=Qe;exports.BatchActionButton=ue;exports.CURVE_PERIOD_VALUE=bt;exports.ConfirmDialog=Pe;exports.CurveCardUI=Be;exports.CurvePeriod=De;exports.CurveType=Ue;exports.DistributionCardUI=Le;exports.HoldingsEmpty=W;exports.HoldingsSearch=Z;exports.HoldingsSectionWidget=Br;exports.HoldingsSubTabs=J;exports.PerpsPanelUI=rt;exports.PerpsPositionSide=Pt;exports.PortfolioClientContext=re;exports.PortfolioClientProvider=Lr;exports.PortfolioContext=ne;exports.PortfolioPageSkeleton=Xe;exports.PortfolioPageWidget=yr;exports.PortfolioProvider=Gr;exports.PredictionBetStatus=vt;exports.PredictionPanelUI=nt;exports.PredictionResult=Ct;exports.PredictionSource=St;exports.SpotHistoryType=ht;exports.SpotPanelUI=it;exports.ViewingBannerUI=Je;exports.computeDistribution=ft;exports.curveDataQueryKey=Qt;exports.distributionQueryKey=ir;exports.formatPercent=ct;exports.formatSignedUsd=ae;exports.formatTime=xt;exports.formatTokenBalance=Fe;exports.formatUsd=N;exports.getExplorerUrl=mt;exports.overviewQueryKey=It;exports.parseDecimal=Dn;exports.perpsHistoryQueryKey=Dt;exports.perpsPositionsQueryKey=Ut;exports.predictionBetsQueryKey=Et;exports.predictionSettledQueryKey=Rt;exports.splitUsd=ut;exports.spotHistoryQueryKey=Ht;exports.spotHoldingsQueryKey=Ft;exports.truncateAddress=te;exports.useAccountInfo=Te;exports.useCurveDataQuery=Ye;exports.useDistributionQuery=je;exports.useHoldingsSection=ot;exports.useOverviewQuery=_e;exports.usePerpsHistoryQuery=Ke;exports.usePerpsPositionsQuery=Me;exports.usePortfolioClient=I;exports.usePortfolioContext=se;exports.usePortfolioPage=Ge;exports.usePredictionBetsQuery=qe;exports.usePredictionSettledQuery=$e;exports.useRefetchWalletSummary=ar;exports.useSpotHistoryQuery=Ve;exports.useSpotHoldingsQuery=pe;exports.useWalletPortfolios=gr;exports.useWalletSummary=we;exports.version=$t;//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map