PageSourceSearch

https://weeklywizdom.com/assets/Watchlist-ru_UP6Yw.js

js weeklywizdom.com collected 2026-10-06 14:15:33 UTC 42,799 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-radix-miDeECL4.js";import{r as h}from"./vendor-react-BBjb5hzp.js";import{s as F,aj as L,U as B,a2 as ae,P as E,V as R,Y as q,Z as M,a0 as A,I as $,p as W,q as G,r as V,t as H,v as S,a4 as re,i as P,E as K,L as ie,ab as Y,u as ue,a3 as z,ay as Q,A as be,j as Z,D as je}from"./index-DGrYQ9Ri.js";import{a as ye,b as we,u as Ne,c as ve,d as ke,e as _e,f as Ae,g as Te,h as Ce}from"./useWatchlist-D7IhpiEk.js";import{u as ne,a as oe,b as ce}from"./vendor-query-CnkSJpBn.js";import{T as le}from"./ticker-search-Ci8fL5DZ.js";import{F as Se}from"./filter-BVHXsfJd.js";import{A as De}from"./arrow-up-down-DBtf_t21.js";import{S as Pe}from"./star-DDiUnaRf.js";import{T as X}from"./trash-2-DaLnfP8R.js";import{T as de}from"./trending-up-Bu39quO3.js";import{T as xe}from"./trending-down-DETM_xh6.js";import{B as J}from"./bell-off-B37aZlJW.js";import{S as U}from"./switch-Dn3zuecP.js";import{g as Fe,b as $e}from"./useTradeCalls-BdufZD-6.js";import{G as I}from"./globe-hlNz3LfB.js";import"./vendor-charts-D_igoWGj.js";import"./vendor-supabase-DwR6CW6F.js";import"./search-DMV43r0l.js";const ee={};function Oe(i,r){const t=i?.map(s=>s.ticker)||[],x=i?.filter(s=>s.asset_type==="crypto").map(s=>s.ticker)||[],a=i?.filter(s=>s.asset_type!=="crypto").map(s=>s.ticker)||[],o=ne({queryKey:["watchlist-prices",t.join(",")],queryFn:async()=>{const s={},[d,c]=await Promise.all([x.length>0?Le(x):{},a.length>0?Ue(a):{}]);return Object.assign(s,d,c),s},enabled:t.length>0,staleTime:30*1e3,refetchInterval:60*1e3,retry:1}),l=o.data?{...o.data}:void 0;if(l&&r)for(const[s,d]of Object.entries(r)){const c=l[s];l[s]={price:d.price,change24h:d.change24h,high24h:d.high24h,low24h:d.low24h,source:c?.source||"bitunix"}}return{...o,data:l}}async function Le(i){const r={};try{const a={};for(const d of i){const c=d.endsWith("USDT")?d:`${d}USDT`;a[d]=c}const o=Object.values(a),{data:l,error:s}=await F.functions.invoke("bitunix-api",{body:{action:"get_prices",symbols:o}});if(!s&&l?.data){const d=l.data;for(const c of i){const g=d[a[c]];g&&(r[c]={price:g,change24h:0,source:"bitunix"})}}}catch{}const t=i.filter(a=>r[a]?.change24h===0);if(t.length>0)try{const a=await te(t);for(const[o,l]of Object.entries(a))r[o]&&(r[o].change24h=l.change24h,r[o].high24h=l.high24h,r[o].low24h=l.low24h)}catch{}const x=i.filter(a=>!r[a]);if(x.length>0)try{const a=await te(x);Object.assign(r,a)}catch{}return r}const Ee={BTC:"bitcoin",ETH:"ethereum",SOL:"solana",BNB:"binancecoin",DOGE:"dogecoin",XRP:"ripple",ADA:"cardano",AVAX:"avalanche-2",DOT:"polkadot",LINK:"chainlink",MATIC:"matic-network",UNI:"uniswap",AAVE:"aave",ATOM:"cosmos",FTM:"fantom",NEAR:"near",OP:"optimism",ARB:"arbitrum",APE:"apecoin",LTC:"litecoin",BCH:"bitcoin-cash",SHIB:"shiba-inu",PEPE:"pepe",SUI:"sui",SEI:"sei-network",TIA:"celestia",JUP:"jupiter-exchange-solana",WIF:"dogwifcoin",BONK:"bonk",INJ:"injective-protocol",RENDER:"render-token",FET:"fetch-ai",TAO:"bittensor",STX:"blockstack",ALGO:"algorand",FARTCOIN:"fartcoin",TRUMP:"official-trump",AI16Z:"ai16z",VIRTUAL:"virtual-protocol",PENGU:"pudgy-penguins",HYPE:"hyperliquid",ENA:"ethena",JTO:"jito-governance-token",ONDO:"ondo-finance",PYTH:"pyth-network",WLD:"worldcoin-wld",TRX:"tron",TON:"the-open-network",RNDR:"render-token",GRT:"the-graph",MKR:"maker",AERO:"aerodrome-finance",DYDX:"dydx-chain"};async function te(i){const r={},t={};for(const c of i)t[c]=c.endsWith("USDT")?c.slice(0,-4):c;const x=[...new Set(Object.values(t))],{data:a}=await F.from("crypto_mappings").select("ticker, coingecko_id").in("ticker",x),o={...Ee,...ee};if(a)for(const c of a)c.coingecko_id&&(o[c.ticker]=c.coingecko_id);const l=i.filter(c=>o[t[c]]),s=i.filter(c=>!o[t[c]]);if(s.length>0&&await Promise.all(s.map(async c=>{const g=t[c];try{const{data:f,error:N}=await F.functions.invoke("bitunix-api",{body:{action:"cg_search",query:g}});if(N)return;const u=(f?.coins||[]).find(w=>w.symbol?.toUpperCase()===g.toUpperCase());u?.id&&(o[g]=u.id,ee[g]=u.id,l.push(c))}catch{}})),l.length===0)return r;const d=[...new Set(l.map(c=>o[t[c]]))].join(",");try{const{data:c,error:g}=await F.functions.invoke("bitunix-api",{body:{action:"cg_prices",ids:d,vs_currencies:"usd",include_24hr_change:!0,include_24hr_high:!0,include_24hr_low:!0}});if(g||!c)return r;for(const f of l){const N=o[t[f]],y=c[N];y?.usd&&(r[f]={price:y.usd,change24h:y.usd_24h_change||0,high24h:y.usd_24h_high,low24h:y.usd_24h_low,source:"coingecko"})}}catch{}return r}async function Ue(i){const r={};try{const{data:t,error:x}=await F.functions.invoke("stock-prices",{body:{action:"batch",tickers:i}});
1if(!x&&t?.success&&t?.quotes)for(const[a,o]of Object.entries(t.quotes))r[a]={price:o.price,change24h:o.changePercent,high24h:o.high,low24h:o.low,source:o.source||"finnhub"}}catch{for(const t of i)try{const x=await fetch(`https://query1.finance.yahoo.com/v8/finance/chart/${t}?interval=1d&range=1d`);if(!x.ok)continue;const o=(await x.json()).chart?.result?.[0]?.meta;if(!o?.regularMarketPrice)continue;r[t]={price:o.regularMarketPrice,change24h:(o.regularMarketPrice-(o.previousClose||0))/(o.previousClose||1)*100,high24h:o.regularMarketDayHigh,low24h:o.regularMarketDayLow,source:"yahoo"}}catch{continue}}return r}function Be({open:i,onOpenChange:r}={}){const{toast:t}=L(),x=ye(),[a,o]=h.useState(!1),l=i!==void 0?i:a,s=r!==void 0?r:o,[d,c]=h.useState(""),[g,f]=h.useState(""),[N,y]=h.useState("crypto"),[u,w]=h.useState(""),[v,_]=h.useState(""),[k,b]=h.useState(""),T=p=>{c(p.symbol),f(p.name),(p.marketType==="crypto"||p.marketType==="stock"||p.marketType==="forex"||p.marketType==="commodity")&&y(p.marketType)},n=async()=>{if(d.trim())try{await x.mutateAsync({ticker:d.trim().toUpperCase(),asset_name:g||void 0,asset_type:N,notes:u||void 0,target_buy_price:v?parseFloat(v):void 0,target_sell_price:k?parseFloat(k):void 0}),c(""),f(""),w(""),_(""),b(""),s(!1),t({title:"Added to watchlist",description:`${d.toUpperCase()} has been added to your watchlist`})}catch(p){t({title:"Error",description:p.message||"Failed to add to watchlist",variant:"destructive"})}};return e.jsxs(B,{open:l,onOpenChange:s,children:[e.jsx(ae,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono font-bold uppercase tracking-wider text-[#00ffa3] hover:text-[#00ffa3]/80 transition-colors",style:{background:"rgba(0,255,163,0.08)",border:"1px solid rgba(0,255,163,0.20)"},children:[e.jsx(E,{className:"h-3.5 w-3.5"}),"Add Asset"]})}),e.jsxs(R,{children:[e.jsx(q,{children:e.jsx(M,{children:"Add to Watchlist"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Ticker"}),e.jsx(le,{value:d,onChange:c,onSelect:T,placeholder:"Search BTC, AAPL, SOL..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Asset Name"}),e.jsx($,{placeholder:"Auto-filled",value:g,onChange:p=>f(p.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Type"}),e.jsxs(W,{value:N,onValueChange:p=>y(p),children:[e.jsx(G,{children:e.jsx(V,{})}
1),e.jsxs(H,{children:[e.jsx(S,{value:"crypto",children:"Crypto"}),e.jsx(S,{value:"stock",children:"Stock"}),e.jsx(S,{value:"forex",children:"Forex"}),e.jsx(S,{value:"commodity",children:"Commodity"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Target Buy ($)"}),e.jsx($,{type:"number",placeholder:"Optional",value:v,onChange:p=>_(p.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Target Sell ($)"}),e.jsx($,{type:"number",placeholder:"Optional",value:k,onChange:p=>b(p.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Notes"}),e.jsx(re,{placeholder:"Add personal notes about this asset...",value:u,onChange:p=>w(p.target.value)})]}),e.jsx("button",{onClick:n,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 text-[11px] font-mono font-bold uppercase tracking-wider text-[#00ffa3] hover:text-[#00ffa3]/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"rgba(0,255,163,0.08)",border:"1px solid rgba(0,255,163,0.20)"},disabled:!d.trim()||x.isPending,children:x.isPending?"Adding...":"Add to Watchlist"})]})]})]})}function Re({prices:i,open:r,onOpenChange:t}){const{toast:x}=L(),a=we(),[o,l]=h.useState(!1),s=r!==void 0?r:o,d=t!==void 0?t:l,[c,g]=h.useState(""),[f,N]=h.useState(""),[y,u]=h.useState("above"),[w,v]=h.useState(""),_=b=>{g(b.symbol),N(b.symbol)},k=async()=>{if(!(!f.trim()||!w))try{const b=i?.[f.toUpperCase()]?.price;await a.mutateAsync({ticker:f.trim().toUpperCase(),asset_type:"crypto",alert_type:y,target_price:parseFloat(w),reference_price:b}),g(""),N(""),v(""),d(!1),x({title:"Alert created",description:`You'll be notified when ${f.toUpperCase()} goes ${y} $${w}`})}catch(b){x({title:"Error",description:b.message||"Failed to create alert",variant:"destructive"})}};return e.jsxs(B,{open:s,onOpenChange:d,children:[e.jsx(ae,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono font-bold uppercase tracking-wider text-[#00d4ff] hover:text-[#00d4ff]/80 transition-colors",style:{background:"rgba(0,212,255,0.08)",border:"1px solid rgba(0,212,255,0.20)"},children:[e.jsx(P,{className:"h-3.5 w-3.5"}),"Add Alert"]})}),e.jsxs(R,{children:[e.jsx(q,{children:e.jsx(M,{children:"Create Price Alert"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Ticker"}),e.jsx(le,{value:c,onChange:g,onSelect:_,placeholder:"Search ticker..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Alert Type"}),e.jsxs(W,{value:y,onValueChange:b=>u(b),children:[e.jsx(G,{children:e.jsx(V,{})}
1),e.jsxs(H,{children:[e.jsx(S,{value:"above",children:"Price goes above"}),e.jsx(S,{value:"below",children:"Price goes below"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{children:"Target Price ($)"}),e.jsx($,{type:"number",placeholder:"0.00",value:w,onChange:b=>v(b.target.value)})]}),e.jsx("button",{onClick:k,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 text-[11px] font-mono font-bold uppercase tracking-wider text-[#00ffa3] hover:text-[#00ffa3]/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"rgba(0,255,163,0.08)",border:"1px solid rgba(0,255,163,0.20)"},disabled:!f.trim()||!w||a.isPending,children:a.isPending?"Creating...":"Create Alert"})]})]})]})}function qe({enrichedWatchlist:i,alerts:r}){return e.jsxs("div",{className:"relative mb-6",children:[e.jsx("div",{className:"h-[2px] w-full",style:{background:"linear-gradient(90deg, #3b82f6, #a855f7, #ff2e50, rgba(255,255,255,0.1))"}}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-0",style:{background:"#0a0e18",border:"1px solid rgba(255,255,255,0.06)",borderTop:"none"},children:[e.jsxs("div",{className:"p-3 sm:p-4",style:{borderRight:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/50 mb-1",children:"Watching"}),e.jsx("div",{className:"text-2xl font-bold text-white font-mono",children:i.length})]}),e.jsxs("div",{className:"p-3 sm:p-4",style:{borderRight:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/50 mb-1",children:"Favorites"}),e.jsx("div",{className:"text-2xl font-bold text-[#ffd700] font-mono",children:i.filter(t=>t.is_favorite).length})]}),e.jsxs("div",{className:"p-3 sm:p-4",style:{borderRight:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/50 mb-1",children:"Active Alerts"}),e.jsx("div",{className:"text-2xl font-bold text-[#00d4ff] font-mono",children:r?.filter(t=>t.is_active).length||0})]}),e.jsxs("div",{className:"p-3 sm:p-4",children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/50 mb-1",children:"Triggered"}),e.jsx("div",{className:"text-2xl font-bold text-[#00ffa3] font-mono",children:r?.filter(t=>t.triggered_at).length||0})]})]})]})}const se={crypto:{bg:"rgba(168,85,247,0.10)",border:"rgba(168,85,247,0.25)",text:"#a855f7"},stock:{bg:"rgba(0,212,255,0.10)",border:"rgba(0,212,255,0.25)",text:"#00d4ff"},forex:{bg:"rgba(0,255,163,0.10)",border:"rgba(0,255,163,0.25)",text:"#00ffa3"},commodity:{bg:"rgba(255,215,0,0.10)",border:"rgba(255,215,0,0.25)",text:"#ffd700"},index:{bg:"rgba(255,140,0,0.10)",border:"rgba(255,140,0,0.25)",text:"#ff8c00"}};function D(i){return se[i]||se.crypto}const Me={BTC:"bitcoin",ETH:"ethereum",SOL:"solana",BNB:"binancecoin",DOGE:"dogecoin",XRP:"ripple",ADA:"cardano",LINK:"chainlink",AVAX:"avalanche-2",DOT:"polkadot",MSTR:"microstrategy"};function We({activeTab:i,setActiveTab:r}){return e.jsx("div",{className:"flex gap-2 mb-4",children:[{key:"watchlist",label:"Watchlist",icon:K},{key:"alerts",label:"Price Alerts",icon:P}].map(({key:t,label:x,icon:a})=>e.jsxs("button",{onClick:()=>r(t),className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono font-bold uppercase tracking-wider transition-colors",style:i===t?{background:"rgba(0,212,255,0.12)",border:"1px solid rgba(0,212,255,0.30)",color:"#00d4ff"}:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.40)"},children:[e.jsx(a,{className:"h-3.5 w-3.5"}),x]},t))})}function Ge({typeFilter:i,setTypeFilter:r,sortBy:t,setSortBy:x,watchlist:a,typeCounts:o}){return e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Se,{className:"h-3 w-3 text-white/30"}),["all","crypto","stock","forex","commodity"].map(l=>{const s=l==="all"?(a||[]).length:o[l]||0;if(l!=="all"&&!s)return null;const d=l!=="all"?D(l):null,c=i===l;return e.jsxs("button",{onClick:()=>r(l),className:"px-2 py-1 text-[10px] font-mono font-bold uppercase tracking-wider transition-colors",style:c?{background:d?.bg||"rgba(0,212,255,0.12)",border:`1px solid ${d?.border||"rgba(0,212,255,0.30)"}`,color:d?.text||"#00d4ff"}:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)",color:"rgba(255,255,255,0.35)"},children:[l==="all"?"All":l," ",s>0&&`(${s})`]},l)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(De,{className:"h-3 w-3 text-white/30"}),["default","name","price","change"].map(l=>e.jsx("button",{onClick:()=>x(l),className:"px-2 py-1 text-[10px] font-mono font-bold uppercase tracking-wider transition-colors",style:t===l?{background:"rgba(0,212,255,0.12)",border:"1px solid rgba(0,212,255,0.30)",color:"#00d4ff"}:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)",color:"rgba(255,255,255,0.35)"},children:l==="default"?"Default":l==="name"?"A-Z":l==="price"?"Price":"% Change"},l))]})]})}function Ve({watchlistLoading:i,enrichedWatchlist:r,pricesLoading:t,toggleFavorite:x,onRemove:a,onSelect:o,onAddFirst:l}){return i?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:[...Array(4)].map((s,d)=>e.jsx("div",{className:"h-40 animate-pulse",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"}},d))}):r.length===0?e.jsxs("div",{className:"py-12 text-center",style:{background:"#0a0e18",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx(K,{className:"h-12 w-12 mx-auto mb-4 text-white/10"}),e.jsx("p",{className:"text-sm font-mono font-bold uppercase tracking-wider text-white/50",children:"Your watchlist is empty"}),e.jsx("p",{className:"text-[11px] font-mono text-white/30 mb-4",children:"Add assets to track their prices"}),e.jsxs("button",{onClick:l,className:"inline-flex items-center gap-1.5 px-4 py-2 text-[11px] font-mono font-bold uppercase tracking-wider text-[#00ffa3] hover:text-[#00ffa3]/80 transition-colors",style:{background:"rgba(0,255,163,0.08)",border:"1px solid rgba(0,255,163,0.20)"},children:[e.jsx(E,{className:"h-3.5 w-3.5"}),"Add your first asset"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:r.map(s=>e.jsxs("div",{className:"relative p-4 transition-all hover:border-white/[0.12] group cursor-pointer",style:{background:"#0a0e18",border:"1px solid rgba(255,255,255,0.06)"},onClick:()=>
1o(s.id),children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px]",style:{background:s.change24h!==void 0?s.change24h>=0?"linear-gradient(90deg, #00ffa3, rgba(0,255,163,0.2))":"linear-gradient(90deg, #ff2e50, rgba(255,46,80,0.2))":"linear-gradient(90deg, rgba(255,255,255,0.1), transparent)"}}),e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:d=>{d.stopPropagation(),x.mutate({id:s.id,is_favorite:!s.is_favorite})},className:`transition-colors ${s.is_favorite?"text-[#ffd700]":"text-white/20 hover:text-[#ffd700]/50"}`,children:e.jsx(Pe,{className:"h-4 w-4",fill:s.is_favorite?"currentColor":"none"})}),e.jsx("span",{className:"font-bold text-lg text-white font-mono tracking-wide",children:s.ticker}),e.jsx("span",{className:"px-1.5 py-0.5 text-[9px] font-mono font-bold uppercase tracking-wider",style:{background:D(s.asset_type).bg,border:`1px solid ${D(s.asset_type).border}`,color:D(s.asset_type).text},children:s.asset_type})]}),e.jsx("button",{className:"h-7 w-7 flex items-center justify-center text-white/20 hover:text-[#ff2e50] opacity-0 group-hover:opacity-100 transition-all",onClick:d=>{d.stopPropagation(),a(s.id,s.ticker)},children:e.jsx(X,{className:"h-3.5 w-3.5"})})]}),s.asset_name&&e.jsx("p",{className:"text-[11px] font-mono text-white/40 -mt-2 mb-3 truncate",children:s.asset_name}),e.jsxs("div",{className:"flex items-end justify-between mb-2",children:[e.jsx("div",{children:s.price?e.jsxs("div",{className:"text-xl font-bold text-white font-mono",children:["$",s.price.toLocaleString(void 0,{maximumFractionDigits:2})]}):t?e.jsx(ie,{className:"h-5 w-5 animate-spin text-white/30"}):e.jsx("span",{className:"text-lg font-mono text-white/30",children:"--"})}),s.change24h!==void 0&&e.jsxs("div",{className:`flex items-center gap-1 text-[12px] font-mono font-bold ${s.change24h>=0?"text-[#00ffa3]":"text-[#ff2e50]"}`,children:[s.change24h>=0?e.jsx(de,{className:"h-3.5 w-3.5"}):e.jsx(xe,{className:"h-3.5 w-3.5"}),s.change24h>=0?"+":"",s.change24h.toFixed(2),"%"]})]}),(s.high24h||s.low24h)&&e.jsxs("div",{className:"flex items-center justify-between text-[10px] font-mono text-white/40 pt-2",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[s.low24h&&e.jsxs("span",{children:["L: ",e.jsxs("span",{className:"text-white/60",children:["$",s.low24h.toLocaleString(void 0,{maximumFractionDigits:2})]})]}),s.high24h&&e.jsxs("span",{children:["H: ",e.jsxs("span",{className:"text-white/60",children:["$",s.high24h.toLocaleString(void 0,{maximumFractionDigits:2})]})]})]}),(s.target_buy_price||s.target_sell_price)&&e.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono mt-2 pt-2",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[s.target_buy_price&&e.jsxs("span",{className:"text-[#00ffa3]",children:["BUY $",s.target_buy_price.toLocaleString()]}),s.target_sell_price&&e.jsxs("span",{className:"text-[#ff2e50]",children:["SELL $",s.target_sell_price.toLocaleString()]})]}),s.notes&&e.jsx("div",{className:"mt-2 pt-2 text-[10px] font-mono text-white/35 line-clamp-2",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:s.notes})]},s.id))})}function He({alerts:i,onToggleActive:r,onDelete:t,onAddFirst:x}){return!i||i.length===0?e.jsxs("div",{className:"py-12 text-center",style:{background:"#0a0e18",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx(P,{className:"h-12 w-12 mx-auto mb-4 text-white/10"}),e.jsx("p",{className:"text-sm font-mono font-bold uppercase tracking-wider text-white/50",children:"No price alerts set"}),e.jsx("p",{className:"text-[11px] font-mono text-white/30 mb-4",children:"Get notified when prices hit your targets"}),e.jsxs("button",{onClick:x,className:"inline-flex items-center gap-1.5 px-4 py-2 text-[11px] font-mono font-bold uppercase tracking-wider text-[#00d4ff] hover:text-[#00d4ff]/80 transition-colors",style:{background:"rgba(0,212,255,0.08)",border:"1px solid rgba(0,212,255,0.20)"},children:[e.jsx(E,{className:"h-3.5 w-3.5"}),"Create your first alert"]})]}):e.jsx("div",{style:{border:"1px solid rgba(255,255,255,0.06)"},children:i.map((a,o)=>e.jsxs("div",{className:`p-4 transition-all hover:bg-white/[0.02] ${a.is_active?"":"opacity-50"}`,style:{background:a.triggered_at?"rgba(0,255,163,0.03)":"rgba(255,255,255,0.01)",borderBottom:o<i.length-1?"1px solid rgba(255,255,255,0.06)":"none",borderLeft:a.triggered_at?"2px solid rgba(0,255,163,0.40)":"2px solid transparent"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 flex items-center justify-center",style:{background:a.is_active?"rgba(0,212,255,0.10)":"rgba(255,255,255,0.03)",border:a.is_active?"1px solid rgba(0,212,255,0.20)":"1px solid rgba(255,255,255,0.06)"},children:a.is_active?e.jsx(P,{className:"h-5 w-5 text-[#00d4ff]"}):e.jsx(J,{className:"h-5 w-5 text-white/30"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-white font-mono tracking-wide",children:a.ticker}),e.jsx("span",{className:"px-1.5 py-0.5 text-[9px] font-mono font-bold uppercase tracking-wider",style:{background:a.alert_type==="above"?"rgba(0,255,163,0.10)":"rgba(255,46,80,0.10)",border:a.alert_type==="above"?"1px solid rgba(0,255,163,0.25)":"1px solid rgba(255,46,80,0.25)",color:a.alert_type==="above"?"#00ffa3":"#ff2e50"},children:a.alert_type==="above"?"↑ Above":"↓ Below"}),a.triggered_at&&e.jsx("span",{className:"px-1.5 py-0.5 text-[9px] font-mono font-bold uppercase tracking-wider text-[#00ffa3]",style:{background:"rgba(0,255,163,0.10)",border:"1px solid rgba(0,255,163,0.25)"},children:"Triggered"})]}),e.jsxs("div",{className:"text-[11px] font-mono text-white/40 mt-0.5",children:["Alert when price goes ",a.alert_type," $",a.target_price?.toLocaleStr
1ing()]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/30",children:"Target"}),e.jsxs("div",{className:"text-sm font-bold text-white font-mono",children:["$",a.target_price?.toLocaleString()]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{className:"h-8 w-8 flex items-center justify-center text-white/30 hover:text-[#00d4ff] transition-colors",onClick:()=>r(a),children:a.is_active?e.jsx(J,{className:"h-4 w-4"}):e.jsx(P,{className:"h-4 w-4"})}),e.jsx("button",{className:"h-8 w-8 flex items-center justify-center text-white/30 hover:text-[#ff2e50] transition-colors",onClick:()=>t(a.id),children:e.jsx(X,{className:"h-4 w-4"})})]})]})]}),a.triggered_at&&e.jsxs("div",{className:"mt-3 pt-3 text-[11px] font-mono text-[#00ffa3]/70",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:["Triggered at $",a.triggered_price?.toLocaleString()," on"," ",new Date(a.triggered_at).toLocaleString()]})]},a.id))})}function Ke(i){return ne({queryKey:["ticker_analyst_notes",i],queryFn:async()=>{if(!i)return[];const{data:r,error:t}=await Y("ticker_analyst_notes").select("*").eq("ticker",i.toUpperCase()).eq("is_published",!0).order("created_at",{ascending:!1});if(t)throw t;return r||[]},enabled:!!i,staleTime:5*60*1e3})}function Ye(){const i=oe();return ce({mutationFn:async r=>{const{data:t,error:x}=await Y("ticker_analyst_notes").insert({ticker:r.ticker.toUpperCase(),analyst_id:r.analyst_id,analyst_name:r.analyst_name||null,title:r.title||null,content:r.content,is_published:!0}).select().single();if(x)throw x;return t},onSuccess:(r,t)=>{i.invalidateQueries({queryKey:["ticker_analyst_notes",t.ticker.toUpperCase()]})}})}function Xe(){const i=oe();return ce({mutationFn:async({id:r,ticker:t})=>{const{error:x}=await Y("ticker_analyst_notes").delete().eq("id",r);if(x)throw x;return{id:r,ticker:t}},onSuccess:r=>{i.invalidateQueries({queryKey:["ticker_analyst_notes",r.ticker.toUpperCase()]})}})}function ze({selectedAsset:i,setSelectedAsset:r,selectedItem:t,prices:x,updateWatchlistItem:a}){const{toast:o}=L(),{isAdmin:l}=ue(),s=t?.ticker??null,{data:d}=Fe(s),{data:c}=Ke(s),{data:g}=$e(),f=Ye(),N=Xe(),[y,u]=h.useState(!1),[w,v]=h.useState(""),[_,k]=h.useState(""),[b,T]=h.useState("");return e.jsx(B,{open:!!i,onOpenChange:n=>!n&&r(null),children:e.jsx(R,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs(q,{children:[e.jsxs(M,{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl font-bold font-mono",children:t.ticker}),e.jsx("span",{className:"px-1.5 py-0.5 text-[9px] font-mono font-bold uppercase tracking-wider",style:{background:D(t.asset_type).bg,border:`1px solid ${D(t.asset_type).border}`,color:D(t.asset_type).text},children:t.asset_type})]}),t.asset_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.asset_name})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/40 mb-1",children:"Current Price"}),t.price?e.jsxs("div",{className:"text-3xl font-bold text-white font-mono",children:["$",t.price.toLocaleString(void 0,{maximumFractionDigits:2})]}):e.jsx("div",{className:"text-xl font-mono text-white/30",children:"--"})]}),t.change24h!==void 0&&e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-mono font-bold ${t.change24h>=0?"text-[#00ffa3]":"text-[#ff2e50]"}`,style:{background:t.change24h>=0?"rgba(0,255,163,0.08)":"rgba(255,46,80,0.08)",border:`1px solid ${t.change24h>=0?"rgba(0,255,163,0.20)":"rgba(255,46,80,0.20)"}`},children:[t.change24h>=0?e.jsx(de,{className:"h-4 w-4"}):e.jsx(xe,{className:"h-4 w-4"}),t.change24h>=0?"+":"",t.change24h.toFixed(2),"%"]})]}),(t.high24h||t.low24h)&&e.jsxs("div",{className:"p-3",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/40 mb-2",children:"24h Range"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-mono text-[#ff2e50]",children:["L: $",t.low24h?.toLocaleStr
1ing(void 0,{maximumFractionDigits:2})]}),e.jsx("div",{className:"flex-1 mx-4 h-1.5 bg-white/5 overflow-hidden",children:t.low24h&&t.high24h&&t.price&&e.jsx("div",{className:"h-full bg-gradient-to-r from-[#ff2e50] via-white/30 to-[#00ffa3]",style:{width:`${Math.min(100,Math.max(0,(t.price-t.low24h)/(t.high24h-t.low24h)*100))}%`}})}),e.jsxs("span",{className:"text-xs font-mono text-[#00ffa3]",children:["H: $",t.high24h?.toLocaleString(void 0,{maximumFractionDigits:2})]})]})]}),e.jsx("div",{children:e.jsx("iframe",{src:`https://s.tradingview.com/widgetembed/?symbol=${encodeURIComponent(t.asset_type==="crypto"?`BINANCE:${t.ticker.replace(/USDT$|USD$/,"")}USDT`:t.ticker)}&interval=60&theme=dark&style=1&hide_side_toolbar=1&allow_symbol_change=0&save_image=0&hide_top_toolbar=0&hide_legend=0`,style:{width:"100%",height:"260px",border:"none",borderRadius:"4px"},loading:"lazy"})}),e.jsxs("div",{className:"p-3",style:{background:"rgba(0,212,255,0.03)",border:"1px solid rgba(0,212,255,0.12)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(z,{className:"h-4 w-4 text-[#00d4ff]"}),e.jsx("span",{className:"text-[10px] font-mono font-bold text-[#00d4ff] uppercase tracking-wider",children:"Active Calls"}),e.jsx("span",{className:"text-[10px] font-mono text-white/30",children:d?.length??0})]}),d&&d.length>0?e.jsx("div",{className:"space-y-2",children:d.map(n=>e.jsxs("div",{className:"p-2.5",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)",borderLeft:`3px solid ${n.direction==="long"?"#00ffa3":"#ff2e50"}`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-[9px] font-mono font-bold uppercase tracking-wider px-1.5 py-0.5",style:{background:n.direction==="long"?"rgba(0,255,163,0.15)":"rgba(255,46,80,0.15)",color:n.direction==="long"?"#00ffa3":"#ff2e50",border:`1px solid ${n.direction==="long"?"rgba(0,255,163,0.30)":"rgba(255,46,80,0.30)"}`},children:n.direction}),e.jsx("span",{className:"text-[9px] font-mono font-bold uppercase tracking-wider px-1.5 py-0.5",style:{background:n.status==="active"?"rgba(0,212,255,0.10)":"rgba(255,215,0,0.10)",color:n.status==="active"?"#00d4ff":"#ffd700",border:`1px solid ${n.status==="active"?"rgba(0,212,255,0.25)":"rgba(255,215,0,0.25)"}`},children:n.status}),n.analyst_name&&e.jsx("span",{className:"text-[10px] font-mono text-white/40 ml-auto",children:n.analyst_name})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[11px] font-mono",children:[n.entry_price&&e.jsxs("div",{children:[e.jsx("span",{className:"text-white/40",children:"Entry: "}),e.jsxs("span",{className:"text-white/80",children:["$",n.entry_price.toLocaleString()]})]}),n.stop_loss&&e.jsxs("div",{children:[e.jsx("span",{className:"text-white/40",children:"SL: "}),e.jsxs("span",{className:"text-[#ff2e50]",children:["$",n.stop_loss.toLocaleString()]})]}),n.take_profit_1&&e.jsxs("div",{children:[e.jsx("span",{className:"text-white/40",children:"TP1: "}),e.jsxs("span",{className:"text-[#00ffa3]",children:["$",n.take_profit_1.toLocaleString()]})]})]})]},n.id))}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx(z,{className:"h-6 w-6 mx-auto mb-2 text-white/10"}),e.jsx("p",{className:"text-[10px] font-mono text-white/30",children:"No active calls for this ticker"})]})]}),e.jsxs("div",{className:"p-3",style:{background:"rgba(168,85,247,0.03)",border:"1px solid rgba(168,85,247,0.12)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Q,{className:"h-4 w-4 text-[#a855f7]"}),e.jsx("span",{className:"text-[10px] font-mono font-bold text-[#a855f7] uppercase tracking-wider",children:"Analyst Commentary"}),e.jsx("span",{className:"text-[10px] font-mono text-white/30",children:c?.length??0}),l&&!y&&e.jsxs("button",{onClick:()=>u(!0),className:"ml-auto flex items-center gap-1 px-2 py-1 text-[10px] font-mono font-bold text-[#a855f7] uppercase tracking-wider transition-colors hover:text-[#a855f7]/80",style:{background:"rgba(168,85,247,0.08)",border:"1px solid rgba(168,85,247,0.20)"},children:[e.jsx(E,{className:"h-3 w-3"})," Add Note"]})]}),l&&y&&e.jsxs("div",{className:"mb-3 p-3 space-y-2",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs(W,{value:w,onValueChange:v,children:[e.jsx(G,{className:"h-8 text-xs",children:e.jsx(V,{placeholder:"Select analyst"})}),e.jsx(H,{children:(g||[]).map(n=>e.jsx(S,{value:n.id,children:n.display_name||n.name},n.id))})]}
1),e.jsx($,{value:_,onChange:n=>k(n.target.value),placeholder:"Title (optional)",className:"h-8 text-xs"}),e.jsx(re,{value:b,onChange:n=>T(n.target.value),placeholder:"Analysis / commentary...",className:"text-xs min-h-[60px]"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:async()=>{if(!w||!b.trim()||!s)return;const n=g?.find(p=>p.id===w);try{await f.mutateAsync({ticker:s,analyst_id:w,analyst_name:n?.display_name||n?.name,title:_||void 0,content:b}),u(!1),v(""),k(""),T(""),o({title:"Note published",description:`Analyst note added for ${s}`})}catch{o({title:"Error",description:"Failed to create note",variant:"destructive"})}},disabled:!w||!b.trim()||f.isPending,className:"flex items-center gap-1 px-3 py-1.5 text-[10px] font-mono font-bold uppercase tracking-wider text-[#00ffa3] disabled:opacity-50 transition-colors",style:{background:"rgba(0,255,163,0.08)",border:"1px solid rgba(0,255,163,0.20)"},children:f.isPending?e.jsx(ie,{className:"h-3 w-3 animate-spin"}):"Publish"}),e.jsx("button",{onClick:()=>{u(!1),v(""),k(""),T("")},className:"px-3 py-1.5 text-[10px] font-mono font-bold uppercase tracking-wider text-white/40 transition-colors",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:"Cancel"})]})]}),c&&c.length>0?e.jsx("div",{className:"space-y-2",children:c.map(n=>e.jsxs("div",{className:"p-2.5",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.title&&e.jsx("span",{className:"text-[12px] font-mono font-bold text-white/80 truncate",children:n.title}),n.analyst_name&&e.jsx("span",{className:"text-[10px] font-mono text-[#a855f7]/70",children:n.analyst_name})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-[9px] font-mono text-white/25",children:new Date(n.created_at).toLocaleDateString()}),l&&e.jsx("button",{onClick:()=>s&&N.mutate({id:n.id,ticker:s}),className:"text-white/20 hover:text-[#ff2e50] transition-colors",children:e.jsx(X,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-[11px] font-mono text-white/60 leading-relaxed whitespace-pre-wrap",children:n.content})]},n.id))}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx(Q,{className:"h-6 w-6 mx-auto mb-2 text-white/10"}),e.jsx("p",{className:"text-[10px] font-mono text-white/30",children:"No analyst notes for this ticker"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.target_buy_price&&e.jsxs("div",{className:"p-3",style:{background:"rgba(0,255,163,0.04)",border:"1px solid rgba(0,255,163,0.12)"},children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-[#00ffa3]/60 mb-1",children:"Target Buy"}),e.jsxs("div",{className:"text-sm font-bold text-[#00ffa3] font-mono",children:["$",t.target_buy_price.toLocaleString()]}),t.price&&e.jsxs("div",{className:"text-[10px] font-mono text-white/30 mt-0.5",children:[((t.target_buy_price-t.price)/t.price*100).toFixed(1),"% from current"]})]}),t.target_sell_price&&e.jsxs("div",{className:"p-3",style:{background:"rgba(255,46,80,0.04)",border:"1px solid rgba(255,46,80,0.12)"},children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-[#ff2e50]/60 mb-1",children:"Target Sell"}),e.jsxs("div",{className:"text-sm font-bold text-[#ff2e50] font-mono",children:["$",t.target_sell_price.toLocaleString()]}),t.price&&e.jsxs("div",{className:"text-[10px] font-mono text-white/30 mt-0.5",children:[((t.target_sell_price-t.price)/t.price*100).toFixed(1),"% from current"]})]})]}),e.jsxs("div",{className:"p-3 space-y-3",style:{background:"rgba(59,130,246,0.03)",border:"1px solid rgba(59,130,246,0.12)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(P,{className:"h-4 w-4 text-[#3b82f6]"}),e.jsx("span",{className:"text-[10px] font-mono font-bold text-[#3b82f6] uppercase tracking-wider",children:"Alert Settings"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] text-white/70 font-medium",children:"Crime Scanner"}),e.jsx("p",{className:"text-[9px] text-white/30 font-mono",children:"Alert when this ticker appears on Crime Scanner"})]}),e.jsx(U,{checked:t.alert_crime!==!1,onCheckedChange:n=>{a.mutate({id:t.id,alert_crime:n})}})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] text-white/70 font-medium",children:"Funding Rate"}),e.jsx("p",{className:"text-[9px] text-white/30 font-mono",children:"Alert on extreme funding rates for this ticker"})]}),e.jsx(U,{checked:t.alert_funding!==!1,onCheckedChange:n=>{a.mutate({id:t.id,alert_funding:n})}})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] text-white/70 font-medium",children:"Volume Spike"}),e.jsx("p",{className:"text-[9px] text-white/30 font-mono",children:"Alert when unusual volume is building on this ticker"})]}),e.jsx(U,{checked:t.alert_volume===!0,onCheckedChange:n=>{a.mutate({id:t.id,alert_volume:n})}})]})]}),e.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/40 mb-2 flex items-center gap-1.5",children:[e.jsx(be,{className:"h-3 w-3"})," Asset Details"]}
1),e.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-1.5",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[11px] font-mono text-white/40",children:"Type"}),e.jsx("span",{className:"text-[11px] font-mono text-white/70 capitalize",children:t.asset_type})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[11px] font-mono text-white/40",children:"Source"}),e.jsx("span",{className:"text-[11px] font-mono text-white/70",children:x?.[t.ticker]?.source||"—"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[11px] font-mono text-white/40",children:"Favorite"}),e.jsx("span",{className:"text-[11px] font-mono text-white/70",children:t.is_favorite?"Yes":"No"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[11px] font-mono text-white/40",children:"Added"}),e.jsx("span",{className:"text-[11px] font-mono text-white/70",children:new Date(t.created_at).toLocaleDateString()})]})]})]}),t.notes&&e.jsxs("div",{className:"p-3",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-white/40 mb-1.5",children:"Notes"}),e.jsx("p",{className:"text-[12px] font-mono text-white/60 leading-relaxed",children:t.notes})]}),e.jsxs("div",{className:"flex gap-2",children:[t.asset_type==="crypto"&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`https://www.coingecko.com/en/coins/${Me[t.ticker.replace("USDT","")]||t.ticker.toLowerCase().replace("usdt","")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-mono font-bold uppercase tracking-wider transition-colors",style:{background:"rgba(0,212,255,0.06)",border:"1px solid rgba(0,212,255,0.15)",color:"#00d4ff"},children:[e.jsx(I,{className:"h-3 w-3"})," CoinGecko"]}),e.jsxs("a",{href:`https://www.tradingview.com/chart/?symbol=BINANCE:${t.ticker.replace("USDT","")}USDT`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-mono font-bold uppercase tracking-wider transition-colors",style:{background:"rgba(168,85,247,0.06)",border:"1px solid rgba(168,85,247,0.15)",color:"#a855f7"},children:[e.jsx(Z,{className:"h-3 w-3"})," TradingView"]})]}),t.asset_type==="stock"&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`https://finance.yahoo.com/quote/${t.ticker}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-mono font-bold uppercase tracking-wider transition-colors",style:{background:"rgba(0,212,255,0.06)",border:"1px solid rgba(0,212,255,0.15)",color:"#00d4ff"},children:[e.jsx(I,{className:"h-3 w-3"})," Yahoo Finance"]}),e.jsxs("a",{href:`https://www.tradingview.com/chart/?symbol=${t.ticker}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-mono font-bold uppercase tracking-wider transition-colors",style:{background:"rgba(168,85,247,0.06)",border:"1px solid rgba(168,85,247,0.15)",color:"#a855f7"},children:[e.jsx(Z,{className:"h-3 w-3"})," TradingView"]})]})]})]})]})})})}function mt(){const{toast:i}=L(),[r,t]=h.useState("watchlist"),[x,a]=h.useState("all"),[o,l]=h.useState("default"),[s,d]=h.useState(null),{data:c,isLoading:g}=Ne(),f=ve(),N=ke(),y=_e(),{data:u,isLoading:w}=Oe(c),{data:v}=Ae(),_=Te(),k=Ce(),[b,T]=h.useState(!1),[n,p]=h.useState(!1),pe=async(j,m)=>{try{await f.mutateAsync(j),i({title:"Removed",description:`${m} removed from watchlist`})}catch(C){i({title:"Error",description:C.message||"Failed to remove",variant:"destructive"})}},he=async j=>{try{await _.mutateAsync(j),i({title:"Alert deleted",description:"Price alert has been removed"})}catch(m){i({title:"Error",description:m.message||"Failed to delete alert",variant:"destructive"})}},ge=async j=>{try{await k.mutateAsync({id:j.id,is_active:!j.is_active})}catch{}},O=h.useMemo(()=>{let j=(c||[]).map(m=>({...m,price:u?.[m.ticker]?.price,change24h:u?.[m.ticker]?.change24h,high24h:u?.[m.ticker]?.high24h,low24h:u?.[m.ticker]?.low24h}));return x!=="all"&&(j=j.filter(m=>m.asset_type===x)),o==="name"?j.sort((m,C)=>m.ticker.localeCompare(C.ticker)):o==="price"?j.sort((m,C)=>(C.price||0)-(m.price||0)):o==="change"&&j.sort((m,C)=>(C.change24h||0)-(m.change24h||0)),j},[c,u,x,o]),me=h.useMemo(()=>{const j={};
1return(c||[]).forEach(m=>{j[m.asset_type]=(j[m.asset_type]||0)+1}),j},[c]),fe=O.find(j=>j.id===s);return e.jsx(je,{children:e.jsxs("main",{className:"px-4 lg:px-6 py-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl sm:text-2xl font-bold text-white flex items-center gap-2 uppercase tracking-wider",children:[e.jsx(K,{className:"h-5 w-5 text-[#ffd700]"}),"Watchlist & Alerts"]}),e.jsx("p",{className:"text-[11px] font-mono text-white/40 mt-1 tracking-wide",children:"Track assets with live prices from Bitunix, Finnhub & CoinGecko"})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsx(Re,{prices:u,open:n,onOpenChange:p}),e.jsx(Be,{open:b,onOpenChange:T})]})]}),e.jsx(qe,{enrichedWatchlist:O,alerts:v}),e.jsx(We,{activeTab:r,setActiveTab:t}),r==="watchlist"&&O.length>0&&e.jsx(Ge,{typeFilter:x,setTypeFilter:a,sortBy:o,setSortBy:l,watchlist:c,typeCounts:me}),r==="watchlist"&&e.jsx(Ve,{watchlistLoading:g,enrichedWatchlist:O,pricesLoading:w,toggleFavorite:N,onRemove:pe,onSelect:d,onAddFirst:()=>T(!0)}),r==="alerts"&&e.jsx(He,{alerts:v,onToggleActive:ge,onDelete:he,onAddFirst:()=>p(!0)}),e.jsx(ze,{selectedAsset:s,setSelectedAsset:d,selectedItem:fe,prices:u,updateWatchlistItem:y})]})})}export{mt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.