@liberfi.io/ui-predict 0.1.75 → 0.1.76

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.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),reactQuery=require('@tanstack/react-query'),i18n=require('@liberfi.io/i18n'),ui=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),utils=require('@liberfi.io/utils'),walletConnector=require('@liberfi.io/wallet-connector'),ln=require('canvas-confetti'),types=require('@liberfi.io/types'),react$1=require('@liberfi.io/react'),recharts=require('recharts'),uiScaffold=require('@liberfi.io/ui-scaffold'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ln__default=/*#__PURE__*/_interopDefault(ln);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.75");var Ba="0.1.75";var Jt=react.createContext(null);function jn(){let e=react.useContext(Jt);if(!e)throw new Error("usePredictV2Context must be used within a PredictV2Provider");return e}function I(){let{client:e}=jn();return e}function Fa(e){return ["predict-v2","events",e??{}]}async function Aa(e,t){return e.listEvents(t)}function mv(e,t={}){let r=I();return reactQuery.useQuery({queryKey:Fa(e),queryFn:()=>Aa(r,e),...t})}var he=48,Se=4,er={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},M={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ke=M.ALL,lt={[M.ONE_DAY]:er.ONE_MINUTE,[M.ONE_WEEK]:er.ONE_HOUR,[M.ONE_MONTH]:er.ONE_HOUR,[M.ALL]:er.ONE_DAY},tr={[M.ONE_DAY]:300,[M.ONE_WEEK]:3600,[M.ONE_MONTH]:10800,[M.ALL]:1440*60},ct={[M.ONE_DAY]:1440*60,[M.ONE_WEEK]:10080*60,[M.ONE_MONTH]:720*60*60,[M.ALL]:null},ut=1,yv=1,gv=1,vv=99,at={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},xv=at.ONE_WEEK,bv={[at.ONE_HOUR]:60,[at.SIX_HOURS]:60,[at.ONE_DAY]:300,[at.ONE_WEEK]:1800,[at.MAX]:1800};function Xn(e){if(e)return e.tagSlug??e.categorySlug??void 0}function Ir(e={}){let{tagSlugSelection:t,limit:r=48,status:n="open",with_markets:s=true,source:i,sort_by:o,sort_asc:a}=e,l=Xn(t);return {limit:r,status:n,with_markets:s,...i?{source:i}:{},...l?{tag_slug:l}:{},...o?{sort_by:o}:{},...a!==void 0?{sort_asc:a}:{}}}function Lr(e){return ["predict-v2","events-infinite",e]}async function Qr(e,t){return e.listEvents(t)}function Br(e,t){return ["predict-v2","event",e,t]}async function Ur(e,t,r){return e.getEvent(t,r)}function dt(e,t={}){let r=I();return reactQuery.useQuery({queryKey:Br(e.slug,e.source),queryFn:()=>Ur(r,e.slug,e.source),enabled:!!e.slug,...t})}function Zn(e,t={}){let r=I();return reactQuery.useInfiniteQuery({queryKey:Lr(e),queryFn:({pageParam:n})=>Qr(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:n=>n.has_more&&n.next_cursor?n.next_cursor:void 0,...t})}function $a(e){return ["predict-v2","search",e]}function Jn(e,t){let r=I(),n=react.useMemo(()=>({search:e.keyword,limit:e.limit??20,status:e.status??"open",source:e.source,with_markets:e.with_markets??false}),[e.keyword,e.limit,e.status,e.source,e.with_markets]);return reactQuery.useInfiniteQuery({queryKey:$a(n),queryFn:({pageParam:s})=>r.listEvents({...n,...s!==void 0?{cursor:s}:{}}),initialPageParam:void 0,getNextPageParam:s=>s.has_more&&s.next_cursor?s.next_cursor:void 0,enabled:t?.enabled??!!e.keyword})}function Ya(e,t,r){return ["predict-v2","similar-events",e,t,r]}function es(e,t={}){let r=I(),n={limit:e.limit,same_source:e.same_source};return reactQuery.useQuery({queryKey:Ya(e.slug,e.source,n),queryFn:()=>r.getSimilarEvents(e.slug,e.source,n),enabled:!!e.slug,staleTime:5*6e4,...t})}function ja(e,t){return ["predict-v2","market",e,t]}async function Xa(e,t,r){return e.getMarket(t,r)}function Wv(e,t={}){let r=I();return reactQuery.useQuery({queryKey:ja(e.slug,e.source),queryFn:()=>Xa(r,e.slug,e.source),enabled:!!e.slug,...t})}function _r(e,t,r){return ["predict-v2","price-history",e,t,r]}function $v(e,t={}){let r=I();return reactQuery.useQuery({queryKey:_r(e.slug,e.source,e.range),queryFn:()=>r.getPriceHistory(e.slug,e.source,e.range),enabled:!!e.slug,staleTime:6e4,...t})}var tl={[M.ONE_DAY]:"1d",[M.ONE_WEEK]:"1w",[M.ONE_MONTH]:"1m",[M.ALL]:"all"};function ts(e,t=M.ALL){let r=I(),n=tl[t],s=reactQuery.useQueries({queries:e.map(a=>({queryKey:_r(a.slug,a.source,n),queryFn:()=>r.getPriceHistory(a.slug,a.source,n),staleTime:6e4,enabled:!!a.slug}))}),i=s.some(a=>a.isLoading);return {series:react.useMemo(()=>e.map((a,l)=>{let u=s[l]?.data?.points??[];if(u.length>0)return {marketSlug:a.slug,label:a.outcomes?.[0]?.label??a.question,data:u.map(f=>({timestamp:f.t*1e3,price:f.p}))};let d=(a.outcomes?.find(f=>f.label.toLowerCase()==="yes")??a.outcomes?.[0])?.price??.5,m=Date.now();return {marketSlug:a.slug,label:a.outcomes?.[0]?.label??a.question,data:[{timestamp:m-7*864e5,price:d},{timestamp:m,price:d}]}}),[e,s]),isLoading:i}}function nl(e,t){return ["predict-v2","orderbook",e,t]}function rs(e,t={}){let r=I();return reactQuery.useQuery({queryKey:nl(e.slug,e.source),queryFn:()=>r.getOrderbook(e.slug,e.source),enabled:!!e.slug,refetchInterval:5e3,...t})}function ol(e,t){return ["predict-v2","market-trades",e,t]}function ns(e,t={}){let r=I(),n={source:e.source,limit:e.limit,cursor:e.cursor,side:e.side};return reactQuery.useQuery({queryKey:ol(e.slug,n),queryFn:()=>r.listMarketTrades(e.slug,n),enabled:!!e.slug,...t})}function al(e,t){return ["predict-v2","candlesticks",e,t]}function lx(e,t={}){let r=I(),n={interval:e.interval,limit:e.limit};return reactQuery.useQuery({queryKey:al(e.slug,n),queryFn:()=>r.listCandlesticks(e.slug,n),enabled:!!e.slug,staleTime:6e4,...t})}function cl(e,t){return ["predict-v2","positions",e,t]}function rr(e,t={}){let r=I();return reactQuery.useQuery({queryKey:cl(e.source,e.user),queryFn:()=>r.getPositions(e.source,e.user),enabled:!!e.user,staleTime:1e4,...t})}function dl(e){return ["predict-v2","orders",e]}function ss(e,t={}){let r=I();return reactQuery.useQuery({queryKey:dl(e),queryFn:()=>r.listOrders(e),enabled:!!e.wallet_address,...t})}function ml(e,t){return ["predict-v2","order",e,t]}function os(e,t={}){let r=I();return reactQuery.useQuery({queryKey:ml(e.id,e.source),queryFn:()=>r.getOrder(e.id,e.source),enabled:!!e.id,refetchInterval:1e3,...t})}function is(e={}){let t=I(),r=reactQuery.useQueryClient();return reactQuery.useMutation({mutationFn:n=>t.cancelOrder(n.id,n.source),onSuccess:()=>{r.invalidateQueries({queryKey:["predict-v2","orders"]});},...e})}function vl(e){return ["predict-v2","dflow-quote",e]}function as(e,t={}){let r=I(),n=!!e.inputMint&&!!e.outputMint&&!!e.userPublicKey&&e.amount!=="0"&&e.amount!=="";return reactQuery.useQuery({queryKey:vl(e),queryFn:()=>r.createDFlowQuote(e),enabled:n,staleTime:1e4,...t})}function ls(e={}){let t=I(),r=reactQuery.useQueryClient();return reactQuery.useMutation({mutationFn:n=>t.submitDFlowTransaction(n),onSuccess:()=>{r.invalidateQueries({queryKey:["predict-v2","orders"]}),r.invalidateQueries({queryKey:["predict-v2","positions"]});},...e})}function kl(e){return ["predict-v2","trades-by-wallet",e]}function cs(e,t={}){let r=I();return reactQuery.useQuery({queryKey:kl(e),queryFn:()=>r.listTradesByWallet(e),enabled:!!e.wallet,...t})}var pt=react.createContext({});var Ae=react.createContext(null);function us(){let e=react.useContext(pt);if(!e)throw new Error("usePredictContext must be used within a PredictProvider");return e}function P(){let{client:e}=us();return e}function El(e){return ["predict","events",e??{}]}async function Dr(e,t){return await e.getEvents(t)}function mb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:El(e),queryFn:async()=>Dr(r,e),...t})}function Ml(e){return ["predict","events","infinite",e??{}]}function ds(e={},t={}){let r=P();return reactQuery.useInfiniteQuery({queryKey:Ml(e),queryFn:async({pageParam:n})=>Dr(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:n=>n.cursor??void 0,...t})}function Rl(e){return ["predict","event","byId",e.id,e.withNestedMarkets]}async function Ol(e,t){return await e.getEventById(t.id,t.withNestedMarkets)}function nr(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Rl(e),queryFn:async()=>Ol(r,e),...t})}function Il(e){return ["predict","markets",e??{}]}async function Ll(e,t){return await e.getMarkets(t)}function Cb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Il(e),queryFn:async()=>Ll(r,e),...t})}function Bl(e){return ["predict","market","byId",e.id]}async function Ul(e,t){return await e.getMarketById(t.id)}function Mb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Bl(e),queryFn:async()=>Ul(r,e),...t})}function Dl(e){return ["predict","market","byMint",e]}async function Fl(e,t){return await e.getMarketByMint(t)}function Vb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Dl(e),queryFn:async()=>Fl(r,e),...t})}function Wl(e){return ["predict","markets","batch",e]}async function ql(e,t){return await e.getMarketsBatch(t)}function Bb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Wl(e),queryFn:async()=>ql(r,e),enabled:!!(e.tickers?.length||e.mints?.length),...t})}function Hl(e){return ["predict","orderBook",e]}async function Kl(e,t){return await e.getOrderbook(t)}function mt(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Hl(e),queryFn:async()=>Kl(r,e),...t})}function $l(e){return ["predict","orderBook","byMint",e]}async function zl(e,t){return await e.getOrderbookByMint(t)}function Fb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:$l(e),queryFn:async()=>zl(r,e),...t})}function Yl(e){return ["predict","trades",e??{}]}async function Gl(e,t){return await e.getTrades(t)}function fs(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Yl(e),queryFn:async()=>Gl(r,e),...t})}function jl(e){return ["predict","trades","byMint",e]}async function Xl(e,t){return await e.getTradesByMint(t)}function Hb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:jl(e),queryFn:async()=>Xl(r,e),...t})}function Zl(e){return ["predict","onchainTrades","byWallet",e]}async function Ar(e,t){return await e.getOnchainTradesByWallet(t)}function ys(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Zl(e),queryFn:async()=>Ar(r,e),...t})}function Jl(e){return ["predict","onchainTrades","byEvent",e]}async function Wr(e,t){return await e.getOnchainTradesByEvent(t)}function Yb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Jl(e),queryFn:async()=>Wr(r,e),...t})}function ec(e){return ["predict","onchainTrades","byMarket",e]}async function qr(e,t){return await e.getOnchainTradesByMarket(t)}function Gb(e,t={}){let r=P();return reactQuery.useQuery({queryKey:ec(e),queryFn:async()=>qr(r,e),...t})}function Kr(e){return e.cursor??void 0}function tc(e){return ["predict","onchainTrades","byWallet","infinite",e]}function eh(e,t={}){let r=P();return reactQuery.useInfiniteQuery({queryKey:tc(e),queryFn:async({pageParam:n})=>Ar(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kr,...t})}function rc(e){return ["predict","onchainTrades","byEvent","infinite",e]}function th(e,t={}){let r=P();return reactQuery.useInfiniteQuery({queryKey:rc(e),queryFn:async({pageParam:n})=>Wr(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kr,...t})}function nc(e){return ["predict","onchainTrades","byMarket","infinite",e]}function rh(e,t={}){let r=P();return reactQuery.useInfiniteQuery({queryKey:nc(e),queryFn:async({pageParam:n})=>qr(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kr,...t})}function sc(e){return ["predict","candlesticks","event",e]}async function oc(e,t){let{ticker:r,...n}=t;return await e.getEventCandlesticks(r,n)}function ih(e,t={}){let r=P();return reactQuery.useQuery({queryKey:sc(e),queryFn:async()=>oc(r,e),...t})}function Nt(e){return ["predict","candlesticks","market",e]}async function Rt(e,t){let{ticker:r,...n}=t;return await e.getMarketCandlesticks(r,n)}function zr(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Nt(e),queryFn:async()=>Rt(r,e),...t})}function ic(e){return ["predict","candlesticks","market","byMint",e]}async function ac(e,t){let{mintAddress:r,...n}=t;return await e.getMarketCandlesticksByMint(r,n)}function ah(e,t={}){let r=P();return reactQuery.useQuery({queryKey:ic(e),queryFn:async()=>ac(r,e),...t})}var lh=zr;function lc(e){return ["predict","forecast","percentileHistory",e]}async function cc(e,t){return await e.getEventForecastPercentileHistory(t)}function ph(e,t={}){let r=P();return reactQuery.useQuery({queryKey:lc(e),queryFn:async()=>cc(r,e),...t})}function uc(e){return ["predict","forecast","percentileHistory","byMint",e]}async function dc(e,t){return await e.getEventForecastPercentileHistoryByMint(t)}function mh(e,t={}){let r=P();return reactQuery.useQuery({queryKey:uc(e),queryFn:async()=>dc(r,e),...t})}function pc(e){return ["predict","liveData",e]}async function mc(e,t){return await e.getLiveData(t)}function vh(e,t={}){let r=P();return reactQuery.useQuery({queryKey:pc(e),queryFn:async()=>mc(r,e),enabled:e.milestoneIds.length>0,...t})}function fc(e){return ["predict","liveData","byEvent",e]}async function yc(e,t){return await e.getLiveDataByEvent(t)}function xh(e,t={}){let r=P();return reactQuery.useQuery({queryKey:fc(e),queryFn:async()=>yc(r,e),enabled:!!e.eventTicker,...t})}function gc(e){return ["predict","liveData","byMint",e]}async function vc(e,t){return await e.getLiveDataByMint(t)}function bh(e,t={}){let r=P();return reactQuery.useQuery({queryKey:gc(e),queryFn:async()=>vc(r,e),enabled:!!e.mintAddress,...t})}function xc(e){return ["predict","series",e??{}]}async function bc(e,t){return await e.getSeries(t)}function xs(e,t={}){let r=P();return reactQuery.useQuery({queryKey:xc(e),queryFn:async()=>bc(r,e),...t})}function hc(e){return ["predict","series","byTicker",e]}async function kc(e,t){return await e.getSeriesByTicker(t)}function bs(e,t={}){let r=P();return reactQuery.useQuery({queryKey:hc(e),queryFn:async()=>kc(r,e),...t})}function Pc(){return ["predict","tags","byCategories"]}async function Sc(e){return await e.getTagsByCategories()}function Gr(e={}){let t=P();return reactQuery.useQuery({queryKey:Pc(),queryFn:async()=>Sc(t),...e})}function Cc(){return ["predict","filters","bySports"]}async function wc(e){return await e.getFiltersBySports()}function Eh(e={}){let t=P();return reactQuery.useQuery({queryKey:Cc(),queryFn:async()=>wc(t),...e})}var Th=Gr;function Tc(e){return ["predict","search",e]}async function Mc(e,t){return await e.search(t)}function Oh(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Tc(e),queryFn:async()=>Mc(r,e),...t})}function Rc(e){return ["predict","positions","byWallet",e]}async function Oc(e,t){return await e.getPositionsByWallet(t)}function ks(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Rc(e),queryFn:async()=>Oc(r,e),...t})}function _h(){let e=react.useContext(Ae);if(!e)throw new Error("useUserPredictContext must be used within a UserPredictProvider");return e}function Ps(e){let t=react.useContext(Ae);return react.useMemo(()=>t?{positions:t.positions.filter(n=>n.market?.ticker===e.ticker),isLoading:t.isLoading,isAvailable:true}:{positions:[],isLoading:false,isAvailable:false},[t,e.ticker])}function Uc(e){return ["predict","outcomeMints",e??{}]}async function _c(e,t){return await e.getOutcomeMints(t)}function Kh(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Uc(e),queryFn:async()=>_c(r,e),...t})}async function Dc(e,t){return await e.filterOutcomeMints(t)}function $h(e={}){let t=P();return reactQuery.useMutation({mutationFn:async r=>Dc(t,r),...e})}function Ac(e){return ["predict","quote",e]}async function Wc(e,t){return await e.getQuote(t)}function jh(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Ac(e),queryFn:async()=>Wc(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}async function qc(e,t){return await e.createSwap(t)}function e0(e={}){let t=P();return reactQuery.useMutation({mutationFn:async r=>qc(t,r),...e})}async function Hc(e,t){return await e.createSwapInstructions(t)}function t0(e={}){let t=P();return reactQuery.useMutation({mutationFn:async r=>Hc(t,r),...e})}function Kc(e){return ["predict","order",e]}async function $c(e,t){return await e.getOrder(t)}function ws(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Kc(e),queryFn:async()=>$c(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}function zc(e){return ["predict","order","status",e.signature]}async function Yc(e,t){return await e.getOrderStatus(t)}function Es(e,t={}){let r=P();return reactQuery.useQuery({queryKey:zc(e),queryFn:async()=>Yc(r,e),enabled:!!e.signature,refetchInterval:t.refetchInterval??3e3,retry:false,...t})}function Xc(e){return ["predict","intent","quote",e]}async function Zc(e,t){return await e.getIntentQuote(t)}function l0(e,t={}){let r=P();return reactQuery.useQuery({queryKey:Xc(e),queryFn:async()=>Zc(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}async function Jc(e,t){return await e.submitIntentSwap(t)}function c0(e={}){let t=P();return reactQuery.useMutation({mutationFn:async r=>Jc(t,r),...e})}async function tu(e,t){return await e.initPredictionMarket(t)}function m0(e={}){let t=P();return reactQuery.useMutation({mutationFn:async r=>tu(t,r),...e})}function ru(){return ["predict","tokens"]}async function nu(e){return await e.getTokens()}function v0(e={}){let t=P();return reactQuery.useQuery({queryKey:ru(),queryFn:async()=>nu(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}function su(){return ["predict","tokens","decimals"]}async function ou(e){return await e.getTokensWithDecimals()}function x0(e={}){let t=P();return reactQuery.useQuery({queryKey:su(),queryFn:async()=>ou(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}function au(){return ["predict","venues"]}async function lu(e){return await e.getVenues()}function P0(e={}){let t=P();return reactQuery.useQuery({queryKey:au(),queryFn:async()=>lu(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}var Ot=class{ws=null;wsUrl;autoReconnect;reconnectIntervalBase;reconnectMaxInterval;pingInterval;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;pingIntervalId=null;shouldReconnect=true;listeners={connect:[],disconnect:[],reconnecting:[],error:[],price:[],trade:[],orderbook:[],status:[],subscribed:[],unsubscribed:[]};subscriptions={prices:{all:false,tickers:new Set},trades:{all:false,tickers:new Set},orderbook:{all:false,tickers:new Set}};constructor(t){this.wsUrl=t.wsUrl,this.autoReconnect=t.autoReconnect??true,this.reconnectIntervalBase=t.reconnectIntervalBase??1e3,this.reconnectMaxInterval=t.reconnectMaxInterval??3e4,this.pingInterval=t.pingInterval??3e4,t.autoConnect!==false&&this.connect();}connect(){if(!(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))){this.shouldReconnect=true,this.setStatus("connecting");try{this.ws=new WebSocket(this.wsUrl),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus("connected"),this.emit("connect",void 0),this.restoreSubscriptions(),this.startPingInterval();},this.ws.onmessage=t=>{this.handleMessage(t.data);},this.ws.onerror=t=>{let r=new Error("WebSocket error");this.emit("error",r);},this.ws.onclose=t=>{this.stopPingInterval(),this.setStatus("disconnected"),this.emit("disconnect",{code:t.code,reason:t.reason}),this.shouldReconnect&&this.autoReconnect&&this.scheduleReconnect();};}catch(t){this.emit("error",t instanceof Error?t:new Error(String(t))),this.shouldReconnect&&this.autoReconnect&&this.scheduleReconnect();}}}disconnect(){this.shouldReconnect=false,this.stopPingInterval(),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus("disconnected");}isConnected(){return this.ws!==null&&this.ws.readyState===WebSocket.OPEN}getStatus(){return this.status}subscribePrices(t,r){this.subscribeChannel("prices",t);let n=this.on("price",r);return ()=>{n(),this.unsubscribeChannel("prices",t);}}subscribeTrades(t,r){this.subscribeChannel("trades",t);let n=this.on("trade",r);return ()=>{n(),this.unsubscribeChannel("trades",t);}}subscribeOrderbook(t,r){this.subscribeChannel("orderbook",t);let n=this.on("orderbook",r);return ()=>{n(),this.unsubscribeChannel("orderbook",t);}}onStatusChange(t){return this.on("status",t)}on(t,r){return this.listeners[t].push(r),()=>{this.off(t,r);}}off(t,r){let n=this.listeners[t],s=n.indexOf(r);s!==-1&&n.splice(s,1);}removeAllListeners(t){if(t)this.listeners[t].length=0;else for(let r of Object.keys(this.listeners))this.listeners[r].length=0;}subscribeChannel(t,r){let n=this.subscriptions[t];if(r.all)n.all=true,n.tickers.clear();else if(r.tickers&&r.tickers.length>0){n.all=false;for(let s of r.tickers)n.tickers.add(s);}this.sendSubscription("subscribe",t,r);}unsubscribeChannel(t,r){let n=this.subscriptions[t];if(r.all)n.all=false,n.tickers.clear();else if(r.tickers&&r.tickers.length>0)for(let s of r.tickers)n.tickers.delete(s);this.sendSubscription("unsubscribe",t,r);}setStatus(t){this.status!==t&&(this.status=t,this.emit("status",t));}emit(t,r){let n=this.listeners[t];for(let s of n)try{s(r);}catch{}}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return false;try{return this.ws.send(JSON.stringify(t)),!0}catch{return false}}sendSubscription(t,r,n){this.send({type:t,channel:r,all:n.all,tickers:n.tickers});}handleMessage(t){try{let r=JSON.parse(t);switch(r.type){case "ticker":this.emit("price",r);break;case "trade":this.emit("trade",r);break;case "orderbook":this.emit("orderbook",r);break;case "status":break;case "subscribed":this.emit("subscribed",{channel:r.channel,all:r.all,tickers:r.tickers});break;case "unsubscribed":this.emit("unsubscribed",{channel:r.channel,all:r.all,tickers:r.tickers});break;case "pong":break;case "error":this.emit("error",new Error(r.message));break;default:if("channel"in r){let n=r;switch(n.channel){case "prices":this.emit("price",n);break;case "trades":this.emit("trade",n);break;case "orderbook":this.emit("orderbook",n);break}}}}catch{}}scheduleReconnect(){if(this.reconnectTimeout)return;let t=Math.min(this.reconnectIntervalBase*Math.pow(2,this.reconnectAttempts),this.reconnectMaxInterval);this.setStatus("reconnecting"),this.emit("reconnecting",{attempt:this.reconnectAttempts+1,delay:t}),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.reconnectAttempts++,this.connect();},t);}restoreSubscriptions(){for(let t of ["prices","trades","orderbook"]){let r=this.subscriptions[t];r.all?this.sendSubscription("subscribe",t,{all:true}):r.tickers.size>0&&this.sendSubscription("subscribe",t,{tickers:Array.from(r.tickers)});}}startPingInterval(){this.stopPingInterval(),this.pingIntervalId=setInterval(()=>{this.send({type:"ping"});},this.pingInterval);}stopPingInterval(){this.pingIntervalId&&(clearInterval(this.pingIntervalId),this.pingIntervalId=null);}};function sr(e){return new Ot(e)}function M0({wsEndpoint:e,autoConnect:t=true,autoReconnect:r=true,enabled:n=true}){let[s,i]=react.useState("disconnected"),[o,a]=react.useState(null),l=react.useRef(null);react.useEffect(()=>{if(!n){l.current&&(l.current.disconnect(),l.current=null),i("disconnected");return}let d=sr({wsUrl:e,autoConnect:t,autoReconnect:r});l.current=d;let m=d.on("status",g=>{i(g);}),y=d.on("error",g=>{a(g);}),f=d.on("connect",()=>{a(null);});return ()=>{m(),y(),f(),d.disconnect(),l.current=null;}},[e,t,r,n]);let c=react.useCallback(()=>{l.current?.connect();},[]),u=react.useCallback(()=>{l.current?.disconnect();},[]);return {client:l.current,status:s,isConnected:s==="connected",connect:c,disconnect:u,error:o}}function V0(){let e=react.useContext(pt);if(!e)throw new Error("useWsClient must be used within a PredictProvider");let{wsClient:t}=e,[r,n]=react.useState(t?.getStatus()??"disconnected");return react.useEffect(()=>{if(!t){n("disconnected");return}return n(t.getStatus()),t.onStatusChange(n)},[t]),{wsClient:t,wsStatus:r,isWsConnected:r==="connected"}}function Q0({client:e,all:t=false,tickers:r=[],enabled:n=true,onUpdate:s}){let[i,o]=react.useState(new Map),[a,l]=react.useState(false),c=react.useRef(s);return react.useEffect(()=>{c.current=s;},[s]),react.useEffect(()=>{if(!e||!n){l(false);return}if(!t&&r.length===0)return;let u=t?{all:true}:{tickers:r},p=e.subscribePrices(u,d=>{o(m=>{let y=new Map(m);return y.set(d.market_ticker,{yesBid:d.yes_bid,yesAsk:d.yes_ask,noBid:d.no_bid,noAsk:d.no_ask,updatedAt:Date.now()}),y}),c.current?.(d);});return l(true),()=>{p(),l(false);}},[e,t,r.join(","),n]),{prices:i,isSubscribed:a}}function _0({client:e,all:t=false,tickers:r=[],enabled:n=true,maxHistory:s=100,onUpdate:i}){let[o,a]=react.useState([]),[l,c]=react.useState(false),u=react.useRef(i);react.useEffect(()=>{u.current=i;},[i]),react.useEffect(()=>{if(!e||!n){c(false);return}if(!t&&r.length===0)return;let d=t?{all:true}:{tickers:r},m=e.subscribeTrades(d,y=>{let f={tradeId:y.trade_id,marketTicker:y.market_ticker,price:y.price,count:y.count,yesPrice:y.yes_price,noPrice:y.no_price,takerSide:y.taker_side,createdTime:y.created_time};a(g=>{let x=[f,...g];return x.length>s?x.slice(0,s):x}),u.current?.(y);});return c(true),()=>{m(),c(false);}},[e,t,r.join(","),n,s]);let p=react.useCallback(()=>{a([]);},[]);return {trades:o,isSubscribed:l,clearHistory:p}}function A0({client:e,all:t=false,tickers:r=[],enabled:n=true,onUpdate:s}){let[i,o]=react.useState(new Map),[a,l]=react.useState(false),c=react.useRef(s);react.useEffect(()=>{c.current=s;},[s]),react.useEffect(()=>{if(!e||!n){l(false);return}if(!t&&r.length===0)return;let p=t?{all:true}:{tickers:r},d=e.subscribeOrderbook(p,m=>{o(y=>{let f=new Map(y);return f.set(m.market_ticker,{yesBids:m.yes_bids,yesAsks:m.yes_asks,noBids:m.no_bids,noAsks:m.no_asks,updatedAt:Date.now()}),f}),c.current?.(m);});return l(true),()=>{d(),l(false);}},[e,t,r.join(","),n]);let u=react.useCallback(p=>i.get(p),[i]);return {orderbooks:i,isSubscribed:a,getOrderbook:u}}var Bs=["Politics","Sports","Culture","Crypto","Climate","Economics","Mentions","Companies","Financials","Tech & Science"];function Us(){let{data:e,isLoading:t,isError:r,error:n}=Gr();return {data:react.useMemo(()=>{if(!e?.tagsByCategories)return [];let i=o=>{let a=Bs.indexOf(o);return a===-1?Bs.length:a};return Object.entries(e.tagsByCategories).map(([o,a])=>({category:o,tags:a})).sort((o,a)=>i(o.category)-i(a.category))},[e]),isLoading:t,isError:r,error:n??null}}function ir({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:s,onTagSelect:i,trailing:o,pulsingTab:a="Trending",className:l}){let{t:c}=i18n.useTranslation(),u=react.useCallback(()=>{s(null);},[s]),p=c("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",l),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(_s,{label:p,isSelected:t===null,onPress:u,showPulse:p===a}),jsxRuntime.jsx(Su,{}),e.map(d=>jsxRuntime.jsx(_s,{label:d.category,isSelected:t===d.category,onPress:()=>s(d.category),badge:d.badge,showPulse:d.category===a},d.category))]})}),o&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:o})]}),t&&n.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(Ds,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(d=>jsxRuntime.jsx(Ds,{label:d.label,icon:d.icon,isSelected:r===d.label,onPress:()=>i(d.label)},d.label))]})})]})}function _s({label:e,isSelected:t,onPress:r,badge:n,showPulse:s}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[s?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,n&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:n})]})}function Su(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Ds({label:e,icon:t,isSelected:r,onPress:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:n,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function ar({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function qs({onSelect:e,className:t}){let{data:r,isLoading:n}=Us(),[s,i]=react.useState(null),[o,a]=react.useState(null),l=react.useCallback(d=>{if(i(d),a(null),!d)e?.({category:null,tags:null});else {let m=r.find(y=>y.category===d);e?.({category:d,tags:m?.tags??null});}},[r,e]),c=react.useCallback(d=>{if(a(d),d)e?.({category:s,tags:[d]});else {let m=r.find(y=>y.category===s);e?.({category:s,tags:m?.tags??null});}},[r,s,e]);if(n)return jsxRuntime.jsx(ar,{});let p=(r.find(d=>d.category===s)?.tags??[]).map(d=>({label:d}));return jsxRuntime.jsx(ir,{categories:r,selectedCategory:s,selectedTag:o,activeTags:p,onCategorySelect:l,onTagSelect:c,className:t})}function Hs(e={}){let{category:t,tags:r,...n}=e,s=!!t||!!r&&r.length>0,{data:i,isFetching:o,isError:a,error:l}=xs({...t?{category:t}:{},...r&&r.length>0?{tags:r.join(",")}:{},isInitialized:true,status:"active"},{enabled:s}),c=react.useMemo(()=>{if(!s||!i?.series)return;let E=i.series.map(C=>C.ticker).slice(0,25);return E.length>0?E.join(","):void 0},[s,i]),u=react.useMemo(()=>({status:"active",withNestedMarkets:true,sort:"volume24h",order:"desc",limit:48,...n,...c!==void 0?{seriesTickers:c}:{}}),[n,c]),{data:p,isLoading:d,isFetching:m,isFetchingNextPage:y,isError:f,error:g,hasNextPage:x,fetchNextPage:b,refetch:h}=ds(u),v=react.useMemo(()=>p?.pages.flatMap(E=>E.events)??[],[p]),w=s&&!i&&!a;return {data:v,isLoading:w||d,isFetching:o||w||m&&!y,isFetchingMore:y,isError:a||f,error:l??g,hasMore:x,fetchMore:b,refetch:h}}var Cu={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Ks=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Xr=(()=>{let e=t=>{let r=Ks.indexOf(t);return r===-1?Ks.length:r};return Object.entries(Cu).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function wu(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Eu(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function lr({onSelect:e,trailing:t,className:r}){let[n,s]=react.useState(null),[i,o]=react.useState(null),a=react.useCallback(d=>{s(d),o(null),e?.({categorySlug:d,tagSlug:null});},[e]),l=react.useCallback(d=>{o(d),e?.({categorySlug:n,tagSlug:d});},[n,e]),c=wu(Xr),u=Xr.find(d=>d.slug===n),p=Eu(u);return jsxRuntime.jsx(ir,{categories:c,selectedCategory:n,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function Ru({className:e}){return jsxRuntime.jsx(ui.Skeleton,{className:ui.cn("min-h-52 w-full rounded-xl border border-border/80 lg:min-h-72",e)})}function ft({count:e=12}){return jsxRuntime.jsx("div",{className:"@container w-full h-full",children:jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-4 @[768px]:grid-cols-2 @[1024px]:grid-cols-3 @[1280px]:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(Ru,{},r))})})}function Jk(){return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col gap-y-3",children:[jsxRuntime.jsx(ar,{}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(ft,{})})]})}function eP(){return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(lr,{}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(ft,{})})]})}function Gs({value:e,showLabel:t=true}){let r=e/100;return jsxRuntime.jsx("div",{className:"flex-shrink-0 flex flex-col items-center",children:jsxRuntime.jsxs("div",{className:"relative w-16 h-12 lg:w-20 lg:h-14",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 70",children:[jsxRuntime.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",className:"stroke-default-200",strokeWidth:"6",strokeLinecap:"round"}),jsxRuntime.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",className:"stroke-primary",strokeWidth:"6",strokeLinecap:"round",strokeDasharray:`${r*125.6} 125.6`,style:{transition:"stroke-dasharray 0.5s ease-in-out"}})]}),t&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center pt-3 lg:pt-4",children:jsxRuntime.jsxs("span",{className:"text-sm font-bold text-foreground lg:text-base leading-none",children:[e.toFixed(0),"%"]})})]})})}function Zs({event:e,onSelect:t,onSelectOutcome:r}){let{t:n}=i18n.useTranslation(),[s,i]=react.useState(null),o=e.markets||[],a=o.length>2?[...o].sort((C,L)=>Number(L.yesAsk??0)-Number(C.yesAsk??0)):o,l=a.filter(C=>C.status==="active"),c=a.length===1,u=c?a[0]:s,p=react.useMemo(()=>utils.formatAmountUSDCompact((e.volume??0)/100),[e.volume]),d=C=>C.yesAsk?parseFloat(C.yesAsk)*100:null,m=C=>C.noAsk?parseFloat(C.noAsk)*100:null,y=C=>{let L=d(C),Q=m(C);return L!=null?Q==null&&L<=1?"< 1%":g(L):Q!=null?Q<=1?"> 99%":g(100-Q):"0%"},f=C=>{let L=d(C),Q=m(C);return Q!=null?L==null&&Q<=1?"< 1%":g(Q):L!=null?L<=1?"> 99%":g(100-L):"0%"},g=C=>C!=null?`${C.toFixed(0)}%`:"--",x=react.useMemo(()=>{let C=a.some(Q=>Q.status==="active");return a.every(Q=>Q.status==="closed"||Q.status==="determined")?{label:n("predict.event.status.closed"),color:"bg-danger-100/50 text-danger"}:C?{label:n("predict.event.status.live"),color:"bg-primary-100/50 text-primary"}:{label:n("predict.event.status.pending"),color:"bg-warning-100/50 text-warning"}},[a,n]),b=C=>{i(C);},h=()=>{i(null);},v=()=>{u&&r&&r(e,u,"yes");},w=()=>{u&&r&&r(e,u,"no");},O=()=>{t&&t(e);},k=l.slice(0,2),E=l.length>2;return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col justify-between gap-y-1.5 rounded-xl border border-border bg-content1 p-3 transition-all duration-300 cursor-pointer hover:border-primary hover:ring-2 hover:ring-primary/20 focus-within:border-primary focus-within:bg-content2 focus-within:ring-2 focus-within:ring-primary/20 @5xl:gap-y-3 @5xl:p-4",onClick:O,children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-1 flex-col gap-y-1.5 @5xl:gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui.Avatar,{src:e.imageUrl||void 0,name:e.title||"Event",radius:"md",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover:scale-110 @5xl:h-12 @5xl:w-12"}),jsxRuntime.jsx(ui.StyledTooltip,{content:e.title,placement:"bottom",children:jsxRuntime.jsx("p",{className:"flex-1 min-w-0 h-10 @5xl:h-12 text-sm font-semibold @5xl:text-base line-clamp-2",children:e.title})}),c?jsxRuntime.jsx(Gs,{value:d(a[0])??50}):x.label!==n("predict.event.status.live")&&jsxRuntime.jsx("div",{className:`flex-shrink-0 flex items-center gap-x-2 rounded-lg px-2 py-1 text-sm @5xl:px-4 @5xl:py-2 ${x.color}`,children:jsxRuntime.jsx("span",{children:x.label})})]}),u&&!c&&jsxRuntime.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:C=>{C.stopPropagation(),h();},children:[jsxRuntime.jsx("span",{className:"text-left text-xs text-foreground @5xl:text-sm line-clamp-1",children:u.yesSubTitle}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground @5xl:text-lg",children:y(u)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"w-3 h-3 text-default-500 @5xl:w-4 @5xl:h-4"})]})]}),!u&&!c&&k.length>0&&jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-0.5 text-xs @5xl:gap-y-1 @5xl:text-sm",children:[k.map(C=>jsxRuntime.jsxs("button",{type:"button",className:"flex min-h-8 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:L=>{L.stopPropagation(),b(C);},children:[jsxRuntime.jsx("span",{className:"text-left text-xs text-foreground @5xl:text-sm line-clamp-1",children:C.yesSubTitle}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-foreground @5xl:text-base",children:y(C)}),jsxRuntime.jsxs("div",{className:"flex h-full items-center gap-x-3 rounded-lg p-1 @5xl:p-1.5 bg-gradient-to-r from-primary-50/20 via-primary-50/20 to-secondary-50/20",children:[jsxRuntime.jsx("span",{className:"text-primary",children:n("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-default-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:n("predict.market.no")})]})]})]},C.ticker)),E&&jsxRuntime.jsx("span",{className:"text-xxs text-default-500 @5xl:text-xs",children:n("predict.event.moreMarkets",{count:l.length-2})})]}),u&&jsxRuntime.jsxs("div",{className:`flex items-center gap-x-2 text-sm @5xl:text-base ${c?"mt-3":""}`,children:[jsxRuntime.jsxs(ui.Button,{color:"primary",fullWidth:true,className:"group/yes bg-primary-100 text-primary @3xl:!h-12 @3xl:!text-base",size:"sm",onPress:v,children:[jsxRuntime.jsx("span",{className:"group-hover/yes:hidden",children:n("predict.market.yes")}),jsxRuntime.jsx("span",{className:"hidden group-hover/yes:inline",children:y(u)})]}),jsxRuntime.jsxs(ui.Button,{color:"secondary",fullWidth:true,className:"group/no bg-secondary-100 text-secondary @3xl:!h-12 @3xl:!text-base",size:"sm",onPress:w,children:[jsxRuntime.jsx("span",{className:"group-hover/no:hidden",children:n("predict.market.no")}),jsxRuntime.jsx("span",{className:"hidden group-hover/no:inline",children:f(u)})]})]})]}),!u||c?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-xxs text-default-600 hover:text-foreground @5xl:text-xs",onClick:C=>{C.stopPropagation(),O();},children:[jsxRuntime.jsx("span",{children:n("predict.event.showMore")}),jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-3 w-3 @5xl:h-4 @5xl:w-4"})]}),jsxRuntime.jsxs("span",{className:"text-xxs text-default-600 @5xl:text-xs",children:[p," ",n("predict.event.volume")]})]}):jsxRuntime.jsxs("button",{type:"button",className:"flex items-center cursor-pointer gap-x-1 text-xxs text-default-600 hover:text-foreground @5xl:text-xs",onClick:C=>{C.stopPropagation(),h();},children:[jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-3 w-3 @5xl:h-4 @5xl:w-4"}),jsxRuntime.jsx("span",{children:n("predict.event.back")})]})]})}var Hu=640,Ku=768,eo=1024,$u=1280,zu=16,Yu=192,Gu=228,ju=244;function Xu(e){return e>=$u?4:e>=eo?3:e>=Hu?2:1}function Zu(e){return e>=eo?ju:e>=Ku?Gu:Yu}function to({events:e,hasMore:t=false,onFetchMore:r,onSelect:n,onSelectOutcome:s}){let i=react.useRef(null),{width:o=0,height:a=0}=hooks.useResizeObserver({ref:i}),l=Xu(o),c=Zu(o),u=Math.ceil(e.length/l)||0,p=t?u+1:u,d=react.useCallback(f=>f<u,[u]),m=react.useCallback(async()=>{r?.();},[r]),y=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:m,rowCount:p,threshold:3});return jsxRuntime.jsx("div",{ref:i,className:"@container w-full h-full",children:a>0&&jsxRuntime.jsx(reactWindow.List,{style:{height:a},onRowsRendered:y,rowComponent:Ju,rowCount:p,rowHeight:c,rowProps:{events:e,columnCount:l,dataRowCount:u,gap:zu,onSelect:n,onSelectOutcome:s}})})}function Ju({index:e,style:t,events:r,columnCount:n,dataRowCount:s,gap:i,onSelect:o,onSelectOutcome:a}){if(e>=s)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let l=e*n,c=r.slice(l,l+n),u=n-c.length,p={display:"flex",gap:i,height:`calc(100% - ${i}px)`};return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{style:p,children:[c.map(d=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0},children:jsxRuntime.jsx(Zs,{event:d,onSelect:o,onSelectOutcome:a})},d.ticker)),u>0&&Array.from({length:u}).map((d,m)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${m}`))]})})}function no({onSelect:e,onSelectOutcome:t,...r}){let{data:n,hasMore:s,fetchMore:i,isFetching:o}=Hs({limit:48,...r});return o?jsxRuntime.jsx(ft,{count:48}):jsxRuntime.jsx(to,{events:n,hasMore:s,onFetchMore:i,onSelect:e,onSelectOutcome:t})}function NP({onSelect:e,onSelectOutcome:t}){let[r,n]=react.useState({category:null,tags:null}),s=react.useCallback(i=>{n(i);},[]);return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col gap-y-3",children:[jsxRuntime.jsx(qs,{onSelect:s}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(no,{category:r.category,tags:r.tags,onSelect:e,onSelectOutcome:t})})]})}var en={sortPreset:"volume",sortAsc:false,source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function tn(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function oo({isOpen:e,onClose:t,value:r,onChange:n}){let{t:s}=i18n.useTranslation(),[i,o]=react.useState(r),a=react.useCallback(g=>{g?o(r):t();},[r,t]),l=react.useCallback(()=>{o(en);},[]),c=react.useCallback(()=>{n(i),t();},[i,n,t]),u=react.useCallback((g,x)=>{o(b=>({...b,[g]:x}));},[]),p=react.useMemo(()=>tn(i),[i]),d=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"polymarket",label:s("predict.platform.polymarket")},{value:"dflow",label:s("predict.platform.dflow")}],[s]),m=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1d",label:s("predict.filter.lessThanDay")},{value:"7d",label:s("predict.filter.lessThanWeek")},{value:"30d",label:s("predict.filter.lessThanMonth")}],[s]),y=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[s]),f=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[s]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:a,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:s("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(dr,{label:s("predict.filter.platform"),children:jsxRuntime.jsx(pr,{options:d,selected:i.source,onSelect:g=>u("source",g)})}),jsxRuntime.jsx(dr,{label:s("predict.filter.timeRemaining"),children:jsxRuntime.jsx(pr,{options:m,selected:i.timeRemaining,onSelect:g=>u("timeRemaining",g)})}),jsxRuntime.jsx(dr,{label:s("predict.filter.minVolume"),children:jsxRuntime.jsx(pr,{options:y,selected:i.minVolume,onSelect:g=>u("minVolume",g)})}),jsxRuntime.jsx(dr,{label:s("predict.filter.minLiquidity"),children:jsxRuntime.jsx(pr,{options:f,selected:i.minLiquidity,onSelect:g=>u("minLiquidity",g)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:l,children:s("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[s("predict.filter.showResults"),p>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",p,")"]})]})]})})]})})}function dr({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function pr({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(s=>{let i=t===s.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:s.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:s.label},s.value??"__all")})})}var co={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},ao={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Sd=["start_time","volume","liquidity","ending_soon"];function uo({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:s,filterCount:i=0,className:o}){let{t:a}=i18n.useTranslation(),[l,c]=react.useState(false),u=react.useRef(null);react.useEffect(()=>{if(!l)return;let d=y=>{u.current&&!u.current.contains(y.target)&&c(false);},m=y=>{y.key==="Escape"&&c(false);};return document.addEventListener("mousedown",d),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",m);}},[l]);let p=lo[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",o),children:[jsxRuntime.jsxs("div",{ref:u,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(d=>!d),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(p,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:a(ao[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),l&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:Sd.map(d=>{let m=lo[d];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(d),c(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",d===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:a(ao[d])})]},d)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:s,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:a("predict.filter.title")})]})})]})}var lo={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function fo(e={}){let t=react.useMemo(()=>Ir(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets]),{data:r,isLoading:n,isFetching:s,isFetchingNextPage:i,isError:o,error:a,hasNextPage:l,fetchNextPage:c,refetch:u}=Zn(t),p=react.useMemo(()=>r?.pages.flatMap(y=>y.items).filter(y=>y!=null)??[],[r]),d=react.useCallback(()=>{c();},[c]),m=react.useCallback(()=>{u();},[u]);return {data:p,isLoading:n,isFetching:s&&!i,isFetchingMore:i,isError:o,error:a??null,hasMore:l??false,fetchMore:d,refetch:m}}var yo=3,nn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ko={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Rd={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Lt=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function go(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function Od(e){let t=e.outcomes?.map(o=>o.label?.toLowerCase().trim()??"")??[];if(t.some(o=>o==="up")&&t.some(o=>o==="down"))return [nn,Rd];if(t.some(o=>o==="yes")&&t.some(o=>o==="no"))return [nn,ko];let r=t[0]??"",n=t[1]??"",s=go(r)%Lt.length,i=go(n)%Lt.length;return i===s&&(i=(i+1)%Lt.length),[Lt[s],Lt[i]]}function Vd(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Po(e){let t=Vd(e);return t!=null?Math.round(t*100):0}function So(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function vo(e){let t=e.outcomes?.[0];return ((t?.best_ask??t?.price??0)*100).toFixed(1)}function xo(e){let t=e.outcomes?.[1];if(t){let s=t.best_ask??t.price??0;return Math.round(s*100).toString()}let r=e.outcomes?.[0],n=r?.best_ask??r?.price??0;return Math.round((1-n)*100).toString()}function Id(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),s=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),n>0&&i.push(`${n}h`),i.push(`${s}m`),i.join(" ")}var Ld=`
1
+ 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),reactPredict=require('@liberfi.io/react-predict'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),walletConnector=require('@liberfi.io/wallet-connector'),Pt=require('canvas-confetti'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),uiScaffold=require('@liberfi.io/ui-scaffold'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pt__default=/*#__PURE__*/_interopDefault(Pt);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.76");var Wn="0.1.76";var $n={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Wt=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],dt=(()=>{let e=t=>{let r=Wt.indexOf(t);return r===-1?Wt.length:r};return Object.entries($n).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Kt({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:a,pulsingTab:i="Trending",className:c}){let{t:l}=i18n.useTranslation(),d=react.useCallback(()=>{n(null);},[n]),u=l("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",c),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx($t,{label:u,isSelected:t===null,onPress:d,showPulse:u===i}),jsxRuntime.jsx(Yn,{}),e.map(p=>jsxRuntime.jsx($t,{label:p.category,isSelected:t===p.category,onPress:()=>n(p.category),badge:p.badge,showPulse:p.category===i},p.category))]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(zt,{label:l("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(p=>jsxRuntime.jsx(zt,{label:p.label,icon:p.icon,isSelected:r===p.label,onPress:()=>s(p.label)},p.label))]})})]})}function $t({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function Yn(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function zt({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function fl({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function qn(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function jn(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function qt({onSelect:e,trailing:t,className:r}){let[o,n]=react.useState(null),[s,a]=react.useState(null),i=react.useCallback(p=>{n(p),a(null),e?.({categorySlug:p,tagSlug:null});},[e]),c=react.useCallback(p=>{a(p),e?.({categorySlug:o,tagSlug:p});},[o,e]),l=qn(dt),d=dt.find(p=>p.slug===o),u=jn(d);return jsxRuntime.jsx(Kt,{categories:l,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:c,trailing:t,className:r})}var ut={sortPreset:"volume",sortAsc:false,source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function pt(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Gt({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[s,a]=react.useState(r),i=react.useCallback(h=>{h?a(r):t();},[r,t]),c=react.useCallback(()=>{a(ut);},[]),l=react.useCallback(()=>{o(s),t();},[s,o,t]),d=react.useCallback((h,v)=>{a(O=>({...O,[h]:v}));},[]),u=react.useMemo(()=>pt(s),[s]),p=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"dflow",label:n("predict.platform.dflow")}],[n]),m=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),g=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),f=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:i,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx($e,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(ze,{options:p,selected:s.source,onSelect:h=>d("source",h)})}),jsxRuntime.jsx($e,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(ze,{options:m,selected:s.timeRemaining,onSelect:h=>d("timeRemaining",h)})}),jsxRuntime.jsx($e,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(ze,{options:g,selected:s.minVolume,onSelect:h=>d("minVolume",h)})}),jsxRuntime.jsx($e,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(ze,{options:f,selected:s.minLiquidity,onSelect:h=>d("minLiquidity",h)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:c,children:n("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:l,children:[n("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",u,")"]})]})]})})]})})}function $e({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function ze({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let s=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",s?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var Jt={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Qt={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},vo=["start_time","volume","liquidity","ending_soon"];function er({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:a}){let{t:i}=i18n.useTranslation(),[c,l]=react.useState(false),d=react.useRef(null);react.useEffect(()=>{if(!c)return;let p=g=>{d.current&&!d.current.contains(g.target)&&l(false);},m=g=>{g.key==="Escape"&&l(false);};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m);}},[c]);let u=Zt[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",a),children:[jsxRuntime.jsxs("div",{ref:d,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>l(p=>!p),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(u,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i(Qt[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),c&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:vo.map(p=>{let m=Zt[p];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(p),l(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",p===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:i(Qt[p])})]},p)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:s>0?s:void 0,color:"primary",size:"sm",isInvisible:s===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i("predict.filter.title")})]})})]})}var Zt={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};var mt=48,ft=4,Ke={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},j={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Ve=j.ALL,Ol={[j.ONE_DAY]:Ke.ONE_MINUTE,[j.ONE_WEEK]:Ke.ONE_HOUR,[j.ONE_MONTH]:Ke.ONE_HOUR,[j.ALL]:Ke.ONE_DAY},Il={[j.ONE_DAY]:300,[j.ONE_WEEK]:3600,[j.ONE_MONTH]:10800,[j.ALL]:1440*60},_l={[j.ONE_DAY]:1440*60,[j.ONE_WEEK]:10080*60,[j.ONE_MONTH]:720*60*60,[j.ALL]:null},gt=1,Al=1,Dl=1,Hl=99,ge={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Bl=ge.ONE_WEEK,Fl={[ge.ONE_HOUR]:60,[ge.SIX_HOURS]:60,[ge.ONE_DAY]:300,[ge.ONE_WEEK]:1800,[ge.MAX]:1800};function nr(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:s,isError:a,error:i,hasNextPage:c,fetchNextPage:l,refetch:d}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>r?.pages.flatMap(g=>g.items).filter(g=>g!=null)??[],[r]),p=react.useCallback(()=>{l();},[l]),m=react.useCallback(()=>{d();},[d]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:a,error:i??null,hasMore:c??false,fetchMore:p,refetch:m}}function or({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border bg-content1 p-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-3/4 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-full rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-lg"})]})]},r))})}var sr=3,ht={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ur={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},No={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Te=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function ar(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function wo(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [ht,No];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [ht,ur];let r=t[0]??"",o=t[1]??"",n=ar(r)%Te.length,s=ar(o)%Te.length;return s===n&&(s=(s+1)%Te.length),[Te[n],Te[s]]}function Co(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function pr(e){let t=Co(e);return t!=null?Math.round(t*100):0}function mr(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function ir(e){let t=e.outcomes?.[0];return ((t?.best_ask??t?.price??0)*100).toFixed(1)}function lr(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return Math.round(n*100).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return Math.round((1-o)*100).toString()}function Mo(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),s=[];return r>0&&s.push(`${r}d`),o>0&&s.push(`${o}h`),s.push(`${n}m`),s.join(" ")}var To=`
2
2
  .badge-shine { position: relative; overflow: hidden; }
3
3
  .badge-shine::after {
4
4
  content: "";
@@ -16,8 +16,7 @@
16
16
  60% { transform: translate(200%); }
17
17
  100% { transform: translate(200%); }
18
18
  }
19
- `;function Co({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:s,onHover:i}){let[o,a]=react.useState(null),l=e.markets??[],c=react.useMemo(()=>l.length>2?[...l].sort((v,w)=>(w.outcomes?.[0]?.price??0)-(v.outcomes?.[0]?.price??0)):l,[l]),u=c.filter(v=>v.status==="open"),p=c.length===1,d=u.slice(0,yo),m=u.length-yo,y=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),f=o?u.find(v=>v.slug===o)??null:null,g=!!f||p,x=()=>{g||n?.(e);},b=v=>{v.stopPropagation(),f&&(v.preventDefault(),a(null));},h=v=>{v.stopPropagation(),t||(v.preventDefault(),n?.(e));};return jsxRuntime.jsxs("div",{className:ui.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!g&&"cursor-pointer"),onMouseEnter:()=>i?.(e),onClick:x,children:[jsxRuntime.jsx("style",{children:Ld}),jsxRuntime.jsx(Qd,{event:e,href:t,LinkComponent:r,onClick:b,isExpanded:g}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:p?jsxRuntime.jsx(qd,{market:u[0],event:e,formattedVolume:y,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:s}):f?jsxRuntime.jsx(Hd,{market:f,event:e,onCollapse:()=>a(null),onSelectOutcome:s}):jsxRuntime.jsx(Ad,{displayedMarkets:d,moreCount:m,formattedVolume:y,source:e.source,href:t,LinkComponent:r,onMarketClick:v=>a(v.slug),onShowMore:h})})]})}function Qd({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:s}){let i=e.start_at?Id(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:n,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",s&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsxRuntime.jsx(Ud,{event:e})]})}function Bd(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(s=>s.label?.toLowerCase()==="crypto"),n=e.tags?.some(s=>s.label?.toLowerCase()==="live");if(r&&e.end_at){let s=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,o=900*1e3;if(s>0&&s<=o){let a=s<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:s<=i?"5m":"15m",color:a});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Ud({event:e}){let t=react.useMemo(()=>Bd(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,n)=>{switch(r.kind){case "live":return jsxRuntime.jsx(_d,{},n);case "crypto-short":return jsxRuntime.jsx(Dd,{label:r.label,color:r.color},n);case "closed":return jsxRuntime.jsx(Fd,{},n)}})})}function _d(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function Dd({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function Fd(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Ad({displayedMarkets:e,moreCount:t,formattedVolume:r,source:n,href:s,LinkComponent:i,onMarketClick:o,onShowMore:a}){let{t:l}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(c=>{let u=Po(c);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:p=>{p.stopPropagation(),o(c);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:c.outcomes?.[0]?.label??c.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:So(u)}),jsxRuntime.jsx(Wd,{})]})]},c.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui.Linkable,{href:s,LinkComponent:i,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a,children:[l("predict.event.showMore"),jsxRuntime.jsx(Eo,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",l("predict.event.volume"),jsxRuntime.jsx(To,{source:n})]})]})]})}function bo({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:s}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:s})}function wo({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:s="action"}){let{t:i}=i18n.useTranslation(),[o,a]=n?Od(e):[nn,ko],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",u=s==="label"&&l===c?"action":s,p=u==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${vo(e)}\xA2`:i("predict.market.action.yes",{price:vo(e)}),d=u==="label"?`${e.outcomes?.[1]?.label??"No"} ${xo(e)}\xA2`:i("predict.market.action.no",{price:xo(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(bo,{bgColor:o.bg,textColor:o.text,shadowColor:o.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"yes");},children:p}),jsxRuntime.jsx(bo,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"no");},children:d})]})}function Wd(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function qd({market:e,event:t,formattedVolume:r,href:n,LinkComponent:s,onSelect:i,onSelectOutcome:o}){let{t:a}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(wo,{market:e,event:t,onSelectOutcome:o,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui.Linkable,{href:n,LinkComponent:s,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:c=>{c.stopPropagation(),n||(c.preventDefault(),i?.(t));},children:[a("predict.event.viewEvent"),jsxRuntime.jsx(Eo,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",a("predict.event.volume"),jsxRuntime.jsx(To,{source:t.source})]})]})]})}function Hd({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let{t:s}=i18n.useTranslation(),i=Po(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:o=>{o.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:So(i)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(wo,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:o=>{o.stopPropagation(),r();},children:[jsxRuntime.jsx(Kd,{className:"h-3 w-3"}),s("predict.event.back")]})]})}function Eo({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Kd({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function To({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Xd=768,No=1024,Zd=1280,Jd=8,ep=224,tp=304,rp=114;function np(e){return e>=Zd?4:e>=No?3:e>=Xd?2:1}function sp(e){return e>=No?tp:ep}function Ro({events:e,hasMore:t=false,onFetchMore:r,onSelect:n,onSelectOutcome:s,getEventHref:i,LinkComponent:o,onHover:a}){let l=react.useRef(null),c=react.useRef(null),{width:u=0,height:p=0}=hooks.useResizeObserver({ref:l}),d=np(u),m=sp(u),y=Math.ceil(e.length/d)||0,f=!t&&e.length>0,g=y+(t?1:0)+(f?1:0),x=react.useCallback(w=>w<y,[y]),b=react.useCallback(async()=>{r?.();},[r]),h=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:x,loadMoreRows:b,rowCount:g,threshold:3}),v=react.useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:l,className:"@container w-full h-full",children:p>0&&jsxRuntime.jsx(reactWindow.List,{listRef:c,className:"no-scrollbar",style:{height:p},onRowsRendered:h,rowComponent:op,rowCount:g,rowHeight:w=>f&&w===g-1?rp:(m),rowProps:{events:e,columnCount:d,dataRowCount:y,showEndOfList:f,totalRowCount:g,onSelect:n,onSelectOutcome:s,getEventHref:i,LinkComponent:o,onHover:a,onScrollToTop:v}})})}function op({index:e,style:t,events:r,columnCount:n,dataRowCount:s,showEndOfList:i,totalRowCount:o,onSelect:a,onSelectOutcome:l,getEventHref:c,LinkComponent:u,onHover:p,onScrollToTop:d}){if(i&&e===o-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ip,{onScrollToTop:d})});if(e>=s)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let m=e*n,y=r.slice(m,m+n),f=n-y.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[y.map(g=>g==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:Jd},children:jsxRuntime.jsx(Co,{event:g,href:c?.(g),LinkComponent:u,onSelect:a,onSelectOutcome:l,onHover:p})},g.slug)),f>0&&Array.from({length:f}).map((g,x)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${x}`))]})})}function ip({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function Vo({tagSlugSelection:e,limit:t=48,status:r,sort_by:n,sort_asc:s,source:i,with_markets:o,onSelect:a,onSelectOutcome:l,getEventHref:c,LinkComponent:u,onHover:p}){let{data:d,hasMore:m,fetchMore:y,isFetching:f}=fo({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:s,source:i,with_markets:o});return f?jsxRuntime.jsx(ft,{count:48}):jsxRuntime.jsx(Ro,{events:d,hasMore:m,onFetchMore:y,onSelect:a,onSelectOutcome:l,getEventHref:c,LinkComponent:u,onHover:p})}function v2({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:s}){let[i,o]=react.useState({categorySlug:null,tagSlug:null}),[a,l]=react.useState(en),{isOpen:c,onOpen:u,onClose:p}=ui.useDisclosure(),d=react.useCallback(h=>{o(h);},[]),m=react.useCallback(h=>{l(v=>({...v,sortPreset:h}));},[]),y=react.useCallback(h=>{l(v=>({...v,sortAsc:h}));},[]),f=react.useCallback(h=>{l(h);},[]),g=react.useMemo(()=>co[a.sortPreset].sort_by,[a.sortPreset]),x=react.useMemo(()=>tn(a),[a]),b=jsxRuntime.jsx(uo,{sortPreset:a.sortPreset,onSortChange:m,sortAsc:a.sortAsc,onSortAscChange:y,onFilterPress:u,filterCount:x});return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(lr,{onSelect:d,trailing:b}),jsxRuntime.jsx(oo,{isOpen:c,onClose:p,value:a,onChange:f}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Vo,{tagSlugSelection:i,sort_by:g,sort_asc:a.sortAsc,source:a.source,onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:s})})]})}function un(e,t,r){let n=e[t];return n?r==="yes"?n.yesMint:n.noMint:null}var Bt=utils.SOLANA_TOKENS.stablecoins.USDC.address;function yp(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};ln__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{ln__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{ln__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Bo({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:n="buy"}){let{t:s}=i18n.useTranslation(),i=react.useContext(Ae),{status:o}=walletConnector.useAuth(),l=walletConnector.useWallets().find(V=>V.chainNamespace===types.ChainNamespace.SOLANA&&V.isConnected),c=o==="authenticated",u=l?.address,[p,d]=react.useState(r),[m,y]=react.useState(n),[f,g]=react.useState(NaN),x=react.useMemo(()=>un(e.accounts,Bt,p),[e.accounts,p]),{inputMint:b,outputMint:h}=react.useMemo(()=>m==="buy"?{inputMint:Bt,outputMint:x}:{inputMint:x,outputMint:Bt},[m,x]),v=!!b&&!!h&&f>0,w=react.useMemo(()=>Number(p==="yes"?e.yesAsk??.5:e.noAsk??.5),[p,e.yesAsk,e.noAsk]),O=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?w>0?f/w:0:f,[m,f,w]),k=react.useMemo(()=>isNaN(f)||f<=0?0:Math.round(f*1e6),[f]),{data:E,isLoading:C,error:L,refetch:Q}=ws({userPublicKey:u??void 0,inputMint:b??"",outputMint:h??"",amount:k,slippageBps:100},{enabled:v}),K=i?.usdcBalance??null,oe=i?.isLoading??false,Ge=i?.refetch,ge=i?.positions,je=react.useMemo(()=>{if(!ge||!x)return null;let V=ge.find(Te=>Te.mint===x);return V?V.balance:0},[ge,x]),ve=react.useMemo(()=>un(e.accounts,Bt,"yes"),[e.accounts]),Ct=react.useMemo(()=>un(e.accounts,Bt,"no"),[e.accounts]),nt=react.useMemo(()=>{if(!ge||!ve)return null;let V=ge.find(Te=>Te.mint===ve);return V?V.balance:0},[ge,ve]),wt=react.useMemo(()=>{if(!ge||!Ct)return null;let V=ge.find(Te=>Te.mint===Ct);return V?V.balance:0},[ge,Ct]),{data:we}=mt(e.ticker,{refetchInterval:5e3}),st=react.useMemo(()=>(p==="yes"?we?.yesBids:we?.noBids)?.[0]?.price??null,[we,p]),Yt=react.useMemo(()=>(p==="yes"?we?.yesAsks:we?.noAsks)?.[0]?.price??null,[we,p]),Vr=react.useMemo(()=>E?.priceImpactPct?parseFloat(E.priceImpactPct):null,[E]),ot=react.useMemo(()=>{if(isNaN(f)||f<=0)return 0;if(E)return parseInt(E.inAmount)/1e6;if(m==="buy")return f;let V=Number(p==="yes"?e.yesBid??0:e.noBid??0);return f*V},[E,m,p,f,e.yesBid,e.noBid]),Gt=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?O*1:ot,[m,O,ot,f]),Et=Gt-ot,jt=react.useCallback(V=>{y(V),g(NaN);},[]),Tt=react.useCallback(V=>{if(isNaN(V)){g(NaN);return}let Te=Math.max(0,V),Zt=m==="buy"?Math.round(Te*100)/100:Math.round(Te);g(Zt);},[m]);react.useEffect(()=>{v&&Q();},[f,p,m,v,Q]);let Mt=react.useMemo(()=>{let V=[];return (isNaN(f)||f<ut)&&V.push(`Minimum quantity is ${ut}`),e.status!=="active"&&V.push("Market is not active"),m==="buy"&&K!=null&&!isNaN(f)&&f>0&&f>K&&V.push("Insufficient USDC balance"),m==="sell"&&je!=null&&!isNaN(f)&&f>0&&f>je&&V.push("Insufficient shares"),{isValid:V.length===0,errors:V}},[f,e.status,m,K,je]),[U,q]=react.useState(null),[Ee,Qe]=react.useState(false),[it,Xe]=react.useState(null),{data:Xt}=Es({signature:it??""},{enabled:!!it});react.useEffect(()=>{if(!Xt||!it)return;let{status:V}=Xt;V==="closed"?(Qe(false),Xe(null),ui.toast.success(s("predict.trade.submitSuccess")),yp(),g(NaN),Ge?.()):(V==="failed"||V==="expired")&&(Qe(false),Xe(null),ui.toast.error(s("predict.trade.submitError")));},[Xt,it,Ge,s]);let La=react.useCallback(async()=>{if(!(!Mt.isValid||!c||!u||!l||oe)){q(null),Xe(null),Qe(true);try{let V=E;if(V?.transaction||(V=(await Q()).data),!V?.transaction){Qe(!1);return}let Te=Uint8Array.from(atob(V.transaction),Gn=>Gn.charCodeAt(0)),Zt=await l.sendTransaction(Te);q(Zt),Xe(Zt);}catch{ui.toast.error(s("predict.trade.submitError")),Qe(false);}}},[Mt.isValid,c,u,l,E,oe,Q,s]),Qa=react.useCallback(()=>{d(r),y(n),g(NaN),q(null),Xe(null),Qe(false);},[r,n]);return {outcome:p,side:m,quantity:f,shares:O,estimatedCost:ot,potentialPayout:Gt,potentialProfit:Et,isAuthenticated:c,bestBid:st,bestAsk:Yt,order:E??null,priceImpact:Vr,usdcBalance:K,outcomeTokenBalance:je,yesTokenBalance:nt,noTokenBalance:wt,isBalanceLoading:oe,isQuoteLoading:C,isSubmitting:Ee,quoteError:L??null,txHash:U,orderStatus:Xt??null,validation:Mt,setOutcome:d,setSide:jt,setQuantity:Tt,submit:La,reset:Qa}}var kp=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function gr({event:e,market:t,outcome:r,side:n,quantity:s,potentialProfit:i,estimatedCost:o,usdcBalance:a,yesTokenBalance:l,noTokenBalance:c,isBalanceLoading:u,isSubmitting:p,isValid:d,onOutcomeChange:m,onSideChange:y,onQuantityChange:f,onSubmit:g}){let{t:x}=i18n.useTranslation(),b=react.useMemo(()=>{if(p)return x("predict.trade.submitting");let v=x(n==="buy"?"predict.trade.buy":"predict.trade.sell"),w=x(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${v} ${w}`},[p,n,r,x]),h=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]);return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:r==="yes"?"text-bullish":"text-bearish",children:[x(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",x(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:v=>y(v),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:x("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui.Tab,{title:x("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(v=>{let w=v==="yes"?l:c;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(v),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===v?v==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:x(v==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let O=n==="buy"?v==="yes"?t.yesAsk:t.noAsk:v==="yes"?t.yesBid:t.noBid;return O!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(O)*100),"\xA2"]}):null})()]}),n==="sell"&&r===v&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:u?"\u2013":`${w??0} shares`})]},v)})}),n==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1 text-xs text-default-500",children:[jsxRuntime.jsx("img",{src:kp,alt:"USDC",className:"h-4 w-4 rounded-full object-cover"}),jsxRuntime.jsxs("span",{children:[x("predict.trade.balance"),":"]}),jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:a!=null?`$${a.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:x(n==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(s)?void 0:s,onValueChange:v=>{f(v);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},n),jsxRuntime.jsx("div",{className:"flex gap-x-2 justify-end",children:n==="buy"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[[1,5,10,100].map(v=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>f(Math.round(((isNaN(s)?0:s)+v)*100)/100),className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:["+",v,"$"]},v)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:x("common.all")})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[[25,50].map(v=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[v,"%"]},v)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:x("common.all")})]})})]}),!isNaN(s)&&s>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:x(n==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(n==="buy"?i:o).toFixed(2)]})]}),jsxRuntime.jsx(ui.Button,{color:h,fullWidth:true,radius:"lg",size:"lg",isDisabled:!d||p,isLoading:p,onPress:g,children:b})]})}function dn({event:e,market:t,initialSide:r,initialOutcome:n,chain:s}){let{outcome:i,side:o,quantity:a,estimatedCost:l,potentialPayout:c,potentialProfit:u,usdcBalance:p,yesTokenBalance:d,noTokenBalance:m,isBalanceLoading:y,isSubmitting:f,validation:g,setOutcome:x,setSide:b,setQuantity:h,submit:v}=Bo({market:t,initialSide:r,initialOutcome:n,chain:s}),w=walletConnector.useAuthCallback(v);return jsxRuntime.jsx(gr,{event:e,market:t,outcome:i,side:o,quantity:a,estimatedCost:l,potentialPayout:c,potentialProfit:u,usdcBalance:p,yesTokenBalance:d,noTokenBalance:m,isBalanceLoading:y,isSubmitting:f,isValid:g.isValid,validationErrors:g.errors,onOutcomeChange:x,onSideChange:b,onQuantityChange:h,onSubmit:w})}function Cp(){return jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 px-2 py-3 lg:gap-x-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 flex-1 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-10 shrink-0 rounded-md"}),jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg"})]})]})}function Re({marketCount:e=4}){return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-4 lg:gap-y-6 px-1 lg:px-4 lg:max-w-3xl animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 lg:gap-x-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-14 w-14 shrink-0 rounded-lg lg:h-18 lg:w-18"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 min-w-0 flex-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-24 rounded-md lg:w-32"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-48 rounded-md lg:h-6 lg:w-72"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[200px] w-full rounded-xl lg:h-[280px]"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-32 rounded-md"}),jsxRuntime.jsx("div",{className:"flex gap-x-1",children:Array.from({length:4}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-10 rounded-md"},r))})]}),jsxRuntime.jsx("div",{className:"flex flex-col divide-y divide-default-200",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(Cp,{},r))})]})}function vr(){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1 flex-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-28 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-40 rounded-md"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-x-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-12 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-12 rounded-md"})]}),jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 flex-1 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-10 flex-1 rounded-lg"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-14 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-12 w-full rounded-lg"})]})}var Fo=e=>{let{candlestickMarketTickers:t,chartRange:r=ke}=e,n=lt[r],s=ct[r],i=react.useMemo(()=>Math.floor(Date.now()/1e3),[r]),o=P(),{data:a,isLoading:l,error:c}=nr({id:e.eventId,withNestedMarkets:true}),u=react.useMemo(()=>{if(s!=null)return i-s;let h=a?.markets;return h?.length?Math.min(...h.map(v=>v.openTime)):i},[i,s,a?.markets]),{data:p,isLoading:d,error:m}=bs(a?.seriesTicker??"",{enabled:!!a?.seriesTicker}),y=react.useMemo(()=>a?.markets?(t&&t.length>0?t.slice(0,4).map(v=>a.markets.find(w=>w.ticker===v)).filter(v=>v!==void 0):[...a.markets].sort((v,w)=>Number(w.yesAsk??0)-Number(v.yesAsk??0)).slice(0,4)).map(v=>v.ticker):[],[t,a?.markets]),f=reactQuery.useQueries({queries:y.map(h=>({queryKey:Nt({ticker:h,startTs:u,endTs:i,periodInterval:n}),queryFn:()=>Rt(o,{ticker:h,startTs:u,endTs:i,periodInterval:n}),enabled:y.length>0}))}),g=f.some(h=>h.isLoading),x=react.useMemo(()=>{let h=new Map;return y.forEach((v,w)=>{let O=f[w]?.error;O&&h.set(v,O);}),h},[y,f]),b=react.useMemo(()=>{let h=new Map;return y.forEach((v,w)=>{let O=f[w]?.data;O&&h.set(v,O);}),h},[y,f]);return {event:a,isEventLoading:l,eventError:c,series:p,isSeriesLoading:d,seriesError:m,periodInterval:n,candlesticks:b,isCandlesticksLoading:g,candlestickErrors:x}};var Ip=utils.SOLANA_TOKENS.stablecoins.USDC.address;function Ao(e){let{status:t}=walletConnector.useAuth(),n=walletConnector.useWallets().find(c=>c.chainNamespace===types.ChainNamespace.SOLANA&&c.isConnected),s=t==="authenticated",i=n?.address,{data:o,isLoading:a}=react$1.useWalletPortfoliosQuery({chain:types.Chain.SOLANA,address:i??""},{enabled:s&&!!i,refetchInterval:1e4});return {holdings:react.useMemo(()=>{let c=new Map;if(!o?.portfolios||e.length===0)return c;let u=new Map;for(let p of o.portfolios)u.set(p.address,parseFloat(p.amount));for(let p of e){let d=p.accounts[Ip];if(!d)continue;let m=u.get(d.yesMint)??0,y=u.get(d.noMint)??0;(m>0||y>0)&&c.set(p.ticker,{yesShares:m,noShares:y});}return c},[o,e]),isLoading:a}}function qp(e){let{cx:t,cy:r,index:n,dataLength:s,stroke:i}=e;return n!==s-1||t==null||r==null?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:i,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;8;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.1;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3,fill:i})]})}var xr=[{stroke:"hsl(var(--heroui-primary))",id:"colorMarket0"},{stroke:"hsl(var(--heroui-secondary))",id:"colorMarket1"},{stroke:"hsl(var(--heroui-success))",id:"colorMarket2"},{stroke:"hsl(var(--heroui-warning))",id:"colorMarket3"}];function Wo(e,t){let r=new Date(e*1e3);switch(t){case M.ONE_DAY:return r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});case M.ONE_WEEK:case M.ONE_MONTH:return r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false});case M.ALL:default:return r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function Hp(e,t,r){let n=tr[r],s=new Map;e.forEach((l,c)=>{let u=new Map;(l.candlesticks??[]).forEach(d=>{let m=d.end_period_ts-d.end_period_ts%n;u.set(m,d.yes_ask.close);}),s.set(c,u);});let i=new Set;for(let l of s.values())for(let c of l.keys())i.add(c);let o=Array.from(i).sort((l,c)=>l-c),a=new Map;return o.map(l=>{let u={date:new Date(l*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"}),timestamp:l};return t.forEach(p=>{let d=s.get(p)?.get(l);if(d!==void 0)u[p]=Math.round(d*100)/100,a.set(p,u[p]);else {let m=a.get(p);m!==void 0&&(u[p]=m);}}),u})}function qo({candlesticks:e,markets:t=[],isLoading:r,chartRange:n=M.ALL,onDataChange:s}){let[i,o]=react.useState(null),a=react.useRef(s);react.useEffect(()=>{a.current=s;});let l=react.useMemo(()=>e?Array.from(e.keys()).slice(0,4):[],[e]),c=react.useMemo(()=>!e||e.size===0?[]:Hp(e,l,n),[e,l,n]),u=react.useMemo(()=>{if(c.length===0||l.length===0)return [0,100];let y=1/0,f=-1/0;if(c.forEach(v=>{l.forEach(w=>{let O=v[w];O!==void 0&&(y=Math.min(y,O),f=Math.max(f,O));});}),y===1/0||f===-1/0)return [0,100];let g=f-y,x=Math.max(g*.2,5),b=Math.max(0,Math.floor(y-x)),h=Math.min(100,Math.ceil(f+x));return [b,h]},[c,l]),p=react.useCallback(y=>{if(c.length===0)return null;let f=y!==null?c[y]:c[c.length-1];return f?{timestamp:f.timestamp,date:f.date,markets:l.map((g,x)=>{let b=t.find(h=>h.ticker===g);return {id:g,label:b?.yesSubTitle||`Market ${x+1}`,value:f[g]??0,color:xr[x%xr.length].stroke}})}:null},[c,l,t]);react.useEffect(()=>{a.current&&c.length>0&&a.current(p(null));},[c,p]),react.useEffect(()=>{a.current&&a.current(p(i));},[i,p]);let d=react.useCallback(y=>{typeof y?.activeTooltipIndex=="number"&&o(y.activeTooltipIndex);},[]),m=react.useCallback(()=>{o(null);},[]);return r?jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px] flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-default-400 text-sm",children:"Loading chart..."})}):c.length===0?jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px] flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-default-400 text-sm",children:"No price history data"})}):jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px]",children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:c,margin:{top:10,right:16,left:16,bottom:0},onMouseMove:d,onMouseLeave:m,children:[jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",tick:y=>{let{x:f,y:g,payload:x,index:b}=y,h=c.length,w=Math.max(1,Math.ceil(h/6)),O=b===0,k=b===h-1,E=b%w===0;return !O&&!k&&!E?null:jsxRuntime.jsx("text",{x:f,y:g+10,textAnchor:"middle",fill:"hsl(var(--heroui-default-500))",fontSize:10,children:Wo(x.value,n)})},tickLine:false,axisLine:false,interval:0}),jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"hsl(var(--heroui-default-200))"}),jsxRuntime.jsx(recharts.YAxis,{domain:u,tickLine:false,axisLine:false,tick:{fontSize:10,fill:"hsl(var(--heroui-default-500))"},tickFormatter:y=>`${y}%`,width:40}),jsxRuntime.jsx(recharts.Tooltip,{contentStyle:{backgroundColor:"hsl(var(--heroui-content1))",border:"1px solid hsl(var(--heroui-default-200))",borderRadius:"8px",fontSize:"12px"},labelFormatter:y=>Wo(y,n),formatter:(y,f)=>{let x=t.find(b=>b.ticker===f)?.yesSubTitle||f;return [`${y.toFixed(2)}%`,x]}}),l.map((y,f)=>jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:y,stroke:xr[f%xr.length].stroke,strokeWidth:2,isAnimationActive:false,dot:g=>jsxRuntime.jsx(qp,{...g,dataLength:c.length},`dot-${y}-${g.index}`),activeDot:false},y))]})})})}function Ho(){return {timestamp:Date.now()/1e3,date:new Date().toLocaleDateString("en-US",{month:"short",day:"numeric"}),markets:[]}}function $o({marketTicker:e,openTime:t,chartRange:r=ke}){let n=lt[r],s=ct[r],i=react.useMemo(()=>Math.floor(Date.now()/1e3),[r]),o=react.useMemo(()=>s!=null?i-s:t??i,[i,s,t]),{data:a,isLoading:l,isFetching:c,error:u}=zr({ticker:e,startTs:o,endTs:i,periodInterval:n},{enabled:!!e});return {candlesticks:a,isLoading:l,isFetching:c,error:u,periodInterval:n}}var Zp="hsl(var(--heroui-primary))",Jp=[{value:M.ONE_DAY,label:"1D"},{value:M.ONE_WEEK,label:"1W"},{value:M.ONE_MONTH,label:"1M"},{value:M.ALL,label:"ALL"}];function em(e){let{cx:t,cy:r,index:n,dataLength:s,stroke:i}=e;return n!==s-1||t==null||r==null?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:i,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;8;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.1;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3,fill:i})]})}function Yo(e,t){let r=new Date(e*1e3);switch(t){case M.ONE_DAY:return r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});case M.ONE_WEEK:case M.ONE_MONTH:return r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false});case M.ALL:default:return r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function tm(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0)}function rm(e,t){let r=tr[t],n=e.candlesticks??[],s=new Map;for(let o of n){let a=o.end_period_ts-o.end_period_ts%r,l=s.get(a);s.set(a,{close:o.yes_ask.close,volume:(l?.volume??0)+(o.volume??0)});}return Array.from(s.entries()).sort((o,a)=>o[0]-a[0]).map(([o,{close:a,volume:l}])=>({timestamp:o,date:new Date(o*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"}),value:Math.round(a*100)/100,volume:l}))}function Go({candlesticks:e,isLoading:t,chartRange:r,onRangeChange:n}){let s=react.useMemo(()=>e?rm(e,r):[],[e,r]),i=react.useMemo(()=>{if(s.length===0)return [0,100];let o=1/0,a=-1/0;for(let d of s)d.value<o&&(o=d.value),d.value>a&&(a=d.value);if(o===1/0||a===-1/0)return [0,100];let l=a-o,c=Math.max(l*.2,5),u=Math.max(0,Math.floor(o-c)),p=Math.min(100,Math.ceil(a+c));return [u,p]},[s]);return t?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-neutral text-sm",children:"Loading chart..."})}),jsxRuntime.jsx(gn,{chartRange:r,onRangeChange:n})]}):s.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-neutral text-sm",children:"No price history data"})}),jsxRuntime.jsx(gn,{chartRange:r,onRangeChange:n})]}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full",children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:s,margin:{top:10,right:16,left:16,bottom:0},children:[jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",tick:o=>{let{x:a,y:l,payload:c,index:u}=o,p=s.length,m=Math.max(1,Math.ceil(p/6)),y=u===0,f=u===p-1,g=u%m===0;return !y&&!f&&!g?null:jsxRuntime.jsx("text",{x:a,y:l+10,textAnchor:"middle",fill:"hsl(var(--heroui-default-500))",fontSize:10,children:Yo(c.value,r)})},tickLine:false,axisLine:false,interval:0}),jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"hsl(var(--heroui-default-200))"}),jsxRuntime.jsx(recharts.YAxis,{domain:i,tickLine:false,axisLine:false,tick:{fontSize:10,fill:"hsl(var(--heroui-default-500))"},tickFormatter:o=>`${o}%`,width:40}),jsxRuntime.jsx(recharts.Tooltip,{cursor:{stroke:"hsl(var(--heroui-default-300))"},content:({active:o,payload:a})=>{if(!o||!a?.length)return null;let l=a[0].payload,c=Math.round(l.value);return jsxRuntime.jsxs("div",{className:"rounded-lg border border-default-200 bg-content1 px-3 py-2 shadow-md",children:[jsxRuntime.jsxs("div",{className:"text-lg font-semibold text-primary",children:["Yes ",c,"\xA2"]}),jsxRuntime.jsxs("div",{className:"text-sm text-neutral",children:["Vol ",tm(l.volume)," \xB7"," ",Yo(l.timestamp,r)]})]})}}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"value",stroke:Zp,strokeWidth:2,isAnimationActive:false,dot:o=>jsxRuntime.jsx(em,{...o,dataLength:s.length},`dot-${o.index}`),activeDot:false})]})})}),jsxRuntime.jsx(gn,{chartRange:r,onRangeChange:n})]})}function gn({chartRange:e,onRangeChange:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-1",children:Jp.map(r=>{let n=e===r.value;return jsxRuntime.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-md transition-colors cursor-pointer ${n?"bg-primary text-primary-foreground":"bg-default-100 text-default-600 hover:bg-default-200"}`,onClick:()=>t?.(r.value),children:r.label},r.value)})})}function jo({marketTicker:e}){let{data:t,isLoading:r,error:n}=mt(e,{enabled:!!e});return {orderbook:react.useMemo(()=>{if(!t)return null;let{yesBids:i,yesAsks:o,noBids:a,noAsks:l}=t;return {yesBids:i,yesAsks:o,noBids:a,noAsks:l,bestYesBid:i.length>0?i[0].price:null,bestYesAsk:o.length>0?o[0].price:null,bestNoBid:a.length>0?a[0].price:null,bestNoAsk:l.length>0?l[0].price:null,sequence:t.sequence??null}},[t]),isOrderbookLoading:r,orderbookError:n}}function Xo(e,t){let r=e.slice(0,t),n=0;return r.map(s=>(n+=s.quantity,{...s,cumulative:n,depth:0,total:s.price*s.quantity}))}function Zo(e,t){for(let r of e)r.depth=t>0?r.cumulative/t:0;}function ri(e){return `${Math.round(e*100)}\xA2`}function om(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function im(e){return e>=1e6?`$${(e/1e6).toFixed(2)}M`:e>=1e3?`$${(e/1e3).toFixed(2)}K`:e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Jo({row:e,side:t,showType:r=false,onClick:n}){let{t:s}=i18n.useTranslation(),i=t==="ask",o=i?"bg-bullish/10":"bg-bearish/10",a=i?"text-bullish":"text-bearish";return jsxRuntime.jsxs("button",{type:"button",className:"relative grid w-full grid-cols-4 px-2 py-2.5 text-xs cursor-pointer hover:bg-default-100 transition-colors",onClick:()=>n?.(e.price,t),children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${o} transition-[width] duration-200`,style:{width:`${e.depth*100}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 font-mono font-medium ${a} text-left`,children:r?s(i?"predict.trade.bestAsk":"predict.trade.bestBid"):""}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:ri(e.price)}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:om(e.quantity)}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:im(e.total)})]})}function ei({index:e}){let t=["60%","45%","75%","55%","65%","50%","70%","40%"];return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100",style:{width:t[e%t.length]}}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"})]})}function am(){return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"})]}),Array.from({length:vn}).map((e,t)=>jsxRuntime.jsx(ei,{index:t},`ask-${t}`)),jsxRuntime.jsx("div",{className:"flex justify-center border-y border-default-200 px-2 py-2.5",children:jsxRuntime.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-default-100"})}),Array.from({length:vn}).map((e,t)=>jsxRuntime.jsx(ei,{index:t+3},`bid-${t}`))]})}var vn=8;function vt({bids:e,asks:t,isLoading:r=false,maxLevels:n=vn,onPriceClick:s}){let{t:i}=i18n.useTranslation(),{bidRows:o,askRows:a,spread:l,spreadPercent:c}=react.useMemo(()=>{let p=Xo(e,n),d=Xo(t,n),m=Math.max(p[p.length-1]?.cumulative??0,d[d.length-1]?.cumulative??0);Zo(p,m),Zo(d,m);let y=p[0]?.price??null,f=d[0]?.price??null,g=null,x=null;if(y!=null&&f!=null){g=f-y;let b=(y+f)/2;b>0&&(x=Math.round(g/b*1e4)/100);}return {bidRows:p,askRows:d,spread:g,spreadPercent:x}},[e,t,n]);return r?jsxRuntime.jsx(am,{}):o.length===0&&a.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:i("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.total")})]}),jsxRuntime.jsx("div",{className:"flex flex-col-reverse",children:a.map((p,d)=>jsxRuntime.jsx(Jo,{row:p,side:"ask",showType:d===0,onClick:s},p.price))}),l!=null&&jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 border-y border-default-200 px-2 py-2.5 text-xs text-default-500",children:[jsxRuntime.jsxs("span",{children:[i("predict.orderBook.spread"),": ",ri(l)]}),c!=null&&jsxRuntime.jsxs("span",{className:"text-default-400",children:["(",c,"%)"]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:o.map((p,d)=>jsxRuntime.jsx(Jo,{row:p,side:"bid",showType:d===0,onClick:s},p.price))})]})}function um(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(2)}K`:e.toLocaleString(void 0,{maximumFractionDigits:2})}function dm(e){let t=Math.abs(e),r=e>=0?"+":"-";return t>=1e3?`${r}$${(t/1e3).toFixed(1)}K`:t>=1?`${r}$${t.toFixed(2)}`:`${r}$${t.toFixed(4)}`}function ni({positions:e,isLoading:t=false}){let{t:r}=i18n.useTranslation();return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})}):e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:r("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-5 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{children:r("predict.positions.outcome")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.qty")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.avgCost")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.currentPrice")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.pnl")})]}),e.map(n=>{let s=n.position==="YES",i=s?"text-bullish":"text-bearish",o=r(s?"predict.market.yes":"predict.market.no"),a=n.avgCost!=null?`${Math.round(n.avgCost*100)}\xA2`:"\u2014",l=n.currentPrice!=null?`${Math.round(n.currentPrice*100)}\xA2`:"\u2014",c=n.pnl!=null&&n.pnlPercent!=null,u=c&&n.pnl>0?"text-bullish":c&&n.pnl<0?"text-bearish":"text-foreground";return jsxRuntime.jsxs("div",{className:"grid grid-cols-5 px-2 py-2.5 text-xs hover:bg-default-100 transition-colors",children:[jsxRuntime.jsx("span",{className:`font-medium ${i}`,children:o}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:um(n.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:a}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:l}),jsxRuntime.jsx("span",{className:`text-right font-mono ${u}`,children:c?jsxRuntime.jsxs("span",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{children:dm(n.pnl)}),jsxRuntime.jsxs("span",{className:"text-[10px] opacity-70",children:[n.pnlPercent>=0?"+":"",n.pnlPercent.toFixed(1),"%"]})]}):"\u2014"})]},n.mint)})]})}function mm(e){let t=e/1e6;return t>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(2)}K`:t.toLocaleString(void 0,{maximumFractionDigits:2})}function fm(e){return e==null?"\u2014":`${Math.round(e*100)}\xA2`}function ym(e){let t=new Date(e*1e3),r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${n} ${s}:${i}`}function gm({index:e}){let t=["60%","45%","75%","55%","65%"];return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100",style:{width:t[e%t.length]}}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"})]})}function si({trades:e,isLoading:t=false}){let{t:r}=i18n.useTranslation();return t?jsxRuntime.jsx("div",{className:"flex flex-col",children:Array.from({length:6}).map((n,s)=>jsxRuntime.jsx(gm,{index:s},s))}):e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.time")})]}),e.map(n=>{let s=n.side==="yes",i=s?"text-bullish":"text-bearish",o=n.side?r(s?"predict.trade.yes":"predict.trade.no"):"\u2014";return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs hover:bg-default-100 transition-colors",children:[jsxRuntime.jsx("span",{className:`font-medium ${i}`,children:o}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:fm(n.usdPricePerContract)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:mm(n.outputAmount)}),jsxRuntime.jsx("span",{className:"text-right text-default-500",children:ym(n.createdAt)})]},n.id)})]})}function li({market:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[n,s]=react.useState("trade-yes"),[i,o]=react.useState(ke),{orderbook:a,isOrderbookLoading:l}=jo({marketTicker:e.ticker}),{candlesticks:c,isFetching:u}=$o({marketTicker:e.ticker,openTime:e.openTime,chartRange:i}),{positions:p,isLoading:d}=Ps(e),{status:m}=walletConnector.useAuth(),g=walletConnector.useWallets().find(k=>k.chainNamespace===types.ChainNamespace.SOLANA&&k.isConnected)?.address,{data:x,isLoading:b}=ys({walletAddress:g??""},{enabled:(n==="trade-history"||n==="positions")&&m==="authenticated"&&!!g}),h=(x?.trades??[]).filter(k=>k.marketTicker===e.ticker),v=react.useMemo(()=>p.map(k=>{let E=h.filter(oe=>oe.outputMint===k.mint&&oe.usdPricePerContract!=null&&oe.contracts!=null&&oe.contracts>0),C=Sm(E),L=k.position==="YES"?ai(k.market?.yesAsk):ai(k.market?.noAsk),Q=null,K=null;return C!=null&&L!=null&&(Q=(L-C)*k.balance,K=C>0?(L-C)/C*100:null),{...k,avgCost:C,currentPrice:L,pnl:Q,pnlPercent:K}}),[p,h]),w=react.useCallback((k,E)=>{t?.(e,"yes",E==="ask"?"buy":"sell");},[e,t]),O=react.useCallback((k,E)=>{t?.(e,"no",E==="ask"?"buy":"sell");},[e,t]);return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:k=>s(k),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:r("predict.market.tradeYes")},"trade-yes"),jsxRuntime.jsx(ui.Tab,{title:r("predict.market.tradeNo")},"trade-no"),jsxRuntime.jsx(ui.Tab,{title:r("predict.market.graph")},"graph"),jsxRuntime.jsx(ui.Tab,{title:r("predict.positions.title")},"positions"),jsxRuntime.jsx(ui.Tab,{title:r("predict.tradeHistory.title")},"trade-history")]}),jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[n==="trade-yes"&&jsxRuntime.jsx(vt,{bids:a?.yesBids??[],asks:a?.yesAsks??[],isLoading:l,onPriceClick:w}),n==="trade-no"&&jsxRuntime.jsx(vt,{bids:a?.noBids??[],asks:a?.noAsks??[],isLoading:l,onPriceClick:O}),n==="graph"&&jsxRuntime.jsx(Go,{candlesticks:c,isLoading:u,chartRange:i,onRangeChange:o}),n==="positions"&&jsxRuntime.jsx(ni,{positions:v,isLoading:d}),n==="trade-history"&&jsxRuntime.jsx(si,{trades:h,isLoading:b})]})]})}function Sm(e){if(e.length===0)return null;let t=0,r=0;for(let n of e)t+=n.contracts,r+=n.usdPricePerContract*n.contracts;return t>0?r/t:null}function ai(e){if(e==null)return null;let t=Number(e);return Number.isFinite(t)?t:null}var bn=4;function wm(e){let t=e.yesAsk?Math.round(parseFloat(e.yesAsk)*100):null,r=e.noAsk?Math.round(parseFloat(e.noAsk)*100):null;return {yesCents:t,noCents:r}}function yi({markets:e,renderMarketDetail:t,onTradeAction:r,marketHoldings:n}){let{t:s}=i18n.useTranslation(),[i,o]=react.useState(false),[a,l]=react.useState(null);if(e.length===0)return null;let c=e.length>bn,u=i?e:e.slice(0,bn),p=d=>{l(m=>m===d?null:d);};return jsxRuntime.jsxs("div",{className:"flex flex-col divide-y divide-default-200",children:[u.map(d=>{let{yesCents:m,noCents:y}=wm(d),f=a===d.ticker;return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 px-2 py-3 transition-colors hover:bg-content2 lg:gap-x-4 cursor-pointer",onClick:()=>p(d.ticker),role:"button",tabIndex:0,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),p(d.ticker));},children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1 min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium truncate lg:text-base",children:d.yesSubTitle}),(()=>{let g=n?.get(d.ticker);if(!g)return null;let{yesShares:x,noShares:b}=g;return x<=0&&b<=0?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1.5",children:[x>0&&jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"flat",color:"primary",classNames:{base:"h-5",content:"text-[10px] font-medium px-1"},children:s("predict.market.sharesYes",{shares:x%1===0?x:x.toFixed(2)})}),b>0&&jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"flat",color:"secondary",classNames:{base:"h-5",content:"text-[10px] font-medium px-1"},children:s("predict.market.sharesNo",{shares:b%1===0?b:b.toFixed(2)})})]})})()]}),(()=>{let g=m!=null,x=y!=null;return g&&!x&&m<=1?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"< 1%"}):x&&!g&&y<=1?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"> 99%"}):!g&&!x?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"0%"}):jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center lg:text-xl",children:`${m}%`})})(),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 flex-1 justify-end",children:[jsxRuntime.jsx(ui.Button,{size:"sm",color:"primary",className:"w-20 bg-primary-100 text-primary",onPress:()=>r?.(d,"yes","buy"),children:m!=null?s("predict.market.action.yes",{price:m}):s("predict.market.yes")}),jsxRuntime.jsx(ui.Button,{size:"sm",color:"secondary",className:"w-20 bg-secondary-100 text-secondary",onPress:()=>r?.(d,"no","buy"),children:y!=null?s("predict.market.action.no",{price:y}):s("predict.market.no")})]}),f?jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 shrink-0 text-default-400"}):jsxRuntime.jsx(ui.ChevronDownIcon,{className:"h-4 w-4 shrink-0 text-default-400"})]}),f&&t&&jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto px-2 pb-3",children:t(d)})]},d.ticker)}),c&&jsxRuntime.jsx("button",{type:"button",onClick:()=>o(d=>!d),className:"flex items-center justify-center gap-x-1.5 px-2 py-2.5 text-sm text-default-500 transition-colors cursor-pointer hover:text-primary",children:i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:s("predict.event.rules.collapse")}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:s("predict.event.moreMarkets",{count:e.length-bn})}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:"h-4 w-4"})]})})]})}var Rm=new Set(["closed","determined","finalized"]);function hr(e){let t=new Date(e*1e3),r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${s} ${i}:${o}`}function Om({market:e}){let t=Rm.has(e.status),r=react.useMemo(()=>{let s={label:"Market Open",value:hr(e.openTime),isActive:true},i={label:"Market Closes",value:t?hr(e.closeTime):"After the outcome occurs",isActive:t},o={label:"Projected Payout",value:"30 minutes after closing",isActive:e.status==="finalized"};return [s,i,o]},[e.openTime,e.closeTime,e.status,t]),n=react.useMemo(()=>t?null:e.canCloseEarly&&e.earlyCloseCondition?`${e.earlyCloseCondition} Otherwise, it closes by ${hr(e.expirationTime)}.`:`This market closes by ${hr(e.expirationTime)}.`,[t,e.canCloseEarly,e.earlyCloseCondition,e.expirationTime]);return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[r.map((s,i)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${s.isActive?"border-primary bg-primary":"border-default-300 bg-transparent"}`}),i<r.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-default-200"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${i<r.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:s.label}),jsxRuntime.jsx("span",{className:"text-xs text-default-500 lg:text-sm",children:s.value})]})]},s.label)),n&&jsxRuntime.jsx("p",{className:"text-xs text-default-500 mt-3 lg:text-sm",children:n})]})}function vi({markets:e,event:t,series:r}){let{t:n}=i18n.useTranslation(),[s,i]=react.useState(null),o=e.filter(l=>l.rulesPrimary);if(o.length===0)return null;let a=o.find(l=>l.ticker===s)??o[0];return a?.rulesPrimary?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium lg:text-base",children:n("predict.event.rules")}),o.length>1&&jsxRuntime.jsx(ui.Select,{size:"sm","aria-label":"Select market rules",className:"max-w-48",classNames:{trigger:"min-h-8 h-8",value:"text-xs"},selectedKeys:new Set([a.ticker]),onSelectionChange:l=>{if(l==="all")return;let c=Array.from(l);c.length>0&&i(c[0]);},children:o.map(l=>jsxRuntime.jsx(ui.SelectItem,{textValue:l.yesSubTitle,children:jsxRuntime.jsx("span",{className:"text-xs truncate",children:l.yesSubTitle})},l.ticker))}),jsxRuntime.jsx("div",{className:"text-xs text-foreground lg:text-sm",children:a.rulesPrimary}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-default-500 mt-2 lg:text-sm",children:"Timeline and payout"}),jsxRuntime.jsx(Om,{market:a}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-default-400 mt-2 lg:text-xs",children:[r?.ticker&&jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Series:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:r.ticker})]}),t.ticker&&jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Event:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.ticker})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Market:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:a.ticker})]})]})]}):null}var Fm=[{value:M.ONE_DAY,label:"1D"},{value:M.ONE_WEEK,label:"1W"},{value:M.ONE_MONTH,label:"1M"},{value:M.ALL,label:"ALL"}];function bi({event:e,series:t,candlesticks:r,chartRange:n=M.ONE_DAY,periodInterval:s,isCandlesticksLoading:i,onRangeChange:o,selectedMarketTickers:a,onMarketSelectionChange:l,onTradeAction:c}){let{t:u}=i18n.useTranslation(),[p,d]=react.useState(Ho()),[m,y]=react.useState(false),f=react.useRef(null);react.useEffect(()=>{let v=f.current;if(!v)return;let w=false,O=0,k=()=>{let{bottom:C}=v.getBoundingClientRect(),L=w?C<0:C<-20;L!==w&&(w=L,y(L));},E=()=>{cancelAnimationFrame(O),O=requestAnimationFrame(k);};return window.addEventListener("scroll",E,{passive:true,capture:true}),k(),()=>{cancelAnimationFrame(O),window.removeEventListener("scroll",E,{capture:true});}},[]);let g=react.useMemo(()=>[...e.markets||[]].sort((v,w)=>Number(w.yesAsk??0)-Number(v.yesAsk??0)),[e.markets]),{holdings:x}=Ao(g),b=react.useMemo(()=>utils.formatAmountUSDCompact((e.volume??0)/100),[e.volume]),h=react.useMemo(()=>{if(!e.strikeDate)return null;let v=new Date(e.strikeDate*1e3),w=v.toLocaleString("default",{month:"short"}),O=v.getDate(),k=v.getFullYear();return `${w} ${O}, ${k}`},[e.strikeDate]);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-4 lg:gap-y-6 px-1 pb-8 lg:px-4 lg:pb-12 lg:max-w-3xl",children:[jsxRuntime.jsx("div",{ref:f,className:"h-0 w-0"}),jsxRuntime.jsxs("div",{className:`sticky top-0 z-30 flex items-center bg-background/80 backdrop-blur-md transition-all duration-300 ${m?"gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.imageUrl||void 0,name:e.title||"Event",radius:"lg",className:`flex-shrink-0 transition-all duration-300 ${m?"!h-8 !w-8 lg:!h-10 lg:!w-10":"!h-14 !w-14 lg:!h-18 lg:!w-18"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[!m&&(t?.category||t?.tags&&t.tags.length>0)&&jsxRuntime.jsxs("span",{className:"text-xs text-default-500 lg:text-sm truncate",children:[t.category,t.category&&t.tags?.length>0&&" \xB7 ",t.tags?.join(", ")]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${m?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-4",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[p&&p.markets.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-xs lg:text-sm",children:p.markets.map(v=>jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:v.color}}),jsxRuntime.jsx("span",{className:"text-default-600",children:v.label})]},v.id))}),jsxRuntime.jsx(qo,{candlesticks:r,chartRange:n,markets:g,isLoading:i,onDataChange:v=>d(v)}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 mt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 text-xs text-default-500 lg:text-sm",children:[jsxRuntime.jsxs("span",{children:[b," ",u("predict.event.volume")]}),h&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-default-300",children:"\xB7"}),jsxRuntime.jsx("span",{children:u("predict.event.endDate",{date:h})})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-x-1",children:Fm.map(v=>jsxRuntime.jsx("button",{type:"button",onClick:()=>o?.(v.value),className:`px-2 lg:px-3 py-1 text-xs rounded-md transition-colors cursor-pointer ${n===v.value?"bg-primary text-primary-foreground":"bg-default-100 text-default-600 hover:bg-default-200"}`,children:v.label},v.value))}),g.length>1&&jsxRuntime.jsx(ui.Select,{size:"sm",selectionMode:"multiple",placeholder:"Markets","aria-label":"Select markets",className:"min-w-28 max-w-48",classNames:{trigger:"min-h-8 h-8",value:"text-xs"},selectedKeys:a?new Set(a):void 0,onSelectionChange:v=>{if(v==="all")return;let w=Array.from(v);w.length<=4&&l?.(w);},children:jsxRuntime.jsx(ui.SelectSection,{title:`Pick up to ${4} markets`,classNames:{heading:"text-xs text-default-400 px-2 py-1"},children:g.map(v=>jsxRuntime.jsx(ui.SelectItem,{textValue:v.yesSubTitle,children:jsxRuntime.jsx("span",{className:"text-xs truncate",children:v.yesSubTitle})},v.ticker))})})]})]})}),jsxRuntime.jsx(yi,{markets:g,onTradeAction:c,marketHoldings:x,renderMarketDetail:v=>jsxRuntime.jsx(li,{market:v,onTradeAction:c})}),jsxRuntime.jsx(vi,{markets:g,event:e,series:t})]})}function Pn({eventId:e,initialMarketTickers:t,initialChartRange:r=ke,onTradeAction:n}){let[s,i]=react.useState(r),[o,a]=react.useState(t),{event:l,isEventLoading:c,eventError:u,series:p,isSeriesLoading:d,periodInterval:m,candlesticks:y,isCandlesticksLoading:f,candlestickErrors:g}=Fo({eventId:e,candlestickMarketTickers:o,chartRange:s}),x=react.useRef(!!t);react.useEffect(()=>{if(l?.markets&&!x.current){x.current=true;let v=[...l.markets].sort((w,O)=>Number(O.yesAsk??0)-Number(w.yesAsk??0)).slice(0,4).map(w=>w.ticker);a(v);}},[l?.markets]);let b=react.useMemo(()=>v=>{i(v);},[]),h=react.useMemo(()=>v=>{a(v);},[]);return c||d?jsxRuntime.jsx(Re,{}):u||!l?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:u?.message||"Event not found"}):jsxRuntime.jsx(bi,{event:l,series:p,candlesticks:y,chartRange:s,periodInterval:m,isCandlesticksLoading:f,candlestickErrors:g,onRangeChange:b,selectedMarketTickers:o,onMarketSelectionChange:h,onTradeAction:n})}function $C({eventId:e,chain:t,...r}){let{t:n}=i18n.useTranslation(),{isMobile:s}=ui.useScreen(),{isOpen:i,onOpen:o,onClose:a}=ui.useDisclosure(),{data:l,isLoading:c}=nr({id:e,withNestedMarkets:true}),u=react.useMemo(()=>[...l?.markets||[]].sort((g,x)=>Number(x.yesAsk??0)-Number(g.yesAsk??0)),[l?.markets]),[p,d]=react.useState(null),m=react.useCallback((g,x,b)=>{d(h=>({market:g,outcome:x,side:b,version:(h?.version??0)+1})),s&&o();},[s,o]),y=p?.market??u[0];if(c)return s?jsxRuntime.jsx(Re,{}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Re,{})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4",children:jsxRuntime.jsx(vr,{})})})]});let f=p?`${p.market.ticker}-${p.version}`:y?.ticker??"default";return s?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-full pb-20",children:jsxRuntime.jsx(Pn,{eventId:e,onTradeAction:m,...r})}),y&&jsxRuntime.jsx("div",{className:"fixed inset-x-0 bottom-0 z-40 flex justify-center p-3 bg-gradient-to-t from-background via-background/90 to-transparent",children:jsxRuntime.jsx(ui.Button,{color:"primary",size:"lg",className:"w-full max-w-md font-semibold",onPress:o,children:n("predict.trade.action")})}),jsxRuntime.jsx(ui.Drawer,{isOpen:i,onClose:a,placement:"bottom",size:"lg",hideCloseButton:true,classNames:{base:"max-h-[85dvh] rounded-t-2xl",body:"p-0"},children:jsxRuntime.jsx(ui.DrawerContent,{children:jsxRuntime.jsx(ui.DrawerBody,{children:y&&jsxRuntime.jsx(dn,{event:l,market:y,initialSide:p?.side,initialOutcome:p?.outcome,chain:t},f)})})})]}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Pn,{eventId:e,onTradeAction:m,...r})}),y&&jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 flex flex-col gap-y-4",children:jsxRuntime.jsx(dn,{event:l,market:y,initialSide:p?.side,initialOutcome:p?.outcome,chain:t},f)})})]})}function Pr(e){if(!e)return 0;let t=new Date(e).getTime();return Number.isFinite(t)?Math.floor(t/1e3):0}function kr(e){return e==null?null:String(Math.round(e*100))}var tf={pending:"initialized",open:"active",closed:"determined",voided:"finalized"};function Cn(e){let t=e.outcomes[0],r=e.outcomes[1];return {ticker:e.slug,eventTicker:e.event_slug,marketType:"binary",title:t?.label??e.question,subtitle:e.description??e.question,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No",openTime:Pr(e.start_at),closeTime:Pr(e.end_at),expirationTime:Pr(e.expires_at??e.end_at),status:tf[e.status]??"active",volume:e.volume??0,result:e.result??"",openInterest:e.open_interest??0,canCloseEarly:false,rulesPrimary:e.rules?.[0]??"",accounts:{},yesAsk:kr(t?.best_ask??t?.price),yesBid:kr(t?.best_bid),noAsk:kr(r?.best_ask??r?.price),noBid:kr(r?.best_bid),rulesSecondary:e.rules?.slice(1).join(`
20
- `)??null}}function Pi(e){return {ticker:e.slug,seriesTicker:"",title:e.title,subtitle:e.subtitle??"",imageUrl:e.image_url,liquidity:e.liquidity,openInterest:e.open_interest,volume:e.volume!=null?Math.round(e.volume*100):null,volume24h:e.volume_24h!=null?Math.round(e.volume_24h*100):null,strikeDate:Pr(e.end_at),settlementSources:e.settlement_sources?.map(t=>({name:t.name??"",url:t.url})),markets:e.markets?.map(Cn)}}function lf(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};ln__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{ln__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{ln__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Si({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:n="buy"}){let{t:s}=i18n.useTranslation(),{status:i}=walletConnector.useAuth(),a=walletConnector.useWallets().find(U=>U.chainNamespace===types.ChainNamespace.SOLANA&&U.isConnected),l=i==="authenticated",c=a?.address,u=e.source,[p,d]=react.useState(r),[m,y]=react.useState(n),[f,g]=react.useState(NaN),[x,b]=react.useState(false),[h,v]=react.useState(null),w=react.useMemo(()=>{let U=p==="yes"?0:1,q=e.outcomes[U];return m==="buy"?q?.best_ask??q?.price??.5:q?.best_bid??q?.price??.5},[e.outcomes,p,m]),O=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?w>0?f/w:0:f,[m,f,w]),k=react.useMemo(()=>isNaN(f)||f<=0?"0":String(Math.round(f*1e6)),[f]),E=e.provider_meta?.["dflow.yesMint"]??"",C=e.provider_meta?.["dflow.noMint"]??"",L=e.provider_meta?.["dflow.collateralMint"]??"",Q=p==="yes"?E:C,K=m==="buy"?L:Q,oe=m==="buy"?Q:L,Ge=!!K&&!!oe&&!!c&&k!=="0",{data:ge,refetch:je}=as({inputMint:K,outputMint:oe,amount:k,userPublicKey:c??"",slippageBps:100},{enabled:Ge}),{data:ve,isLoading:Ct}=rr({source:u,user:c??""},{enabled:!!c}),nt=react.useMemo(()=>ve&&ve.positions.reduce((q,Ee)=>Ee.side==="USDC"||Ee.side==="collateral"?q+Ee.current_value:q,0)||null,[ve]),wt=react.useMemo(()=>ve?ve.positions.find(q=>q.side?.toLowerCase()==="yes"&&q.market?.slug===e.slug)?.size??0:null,[ve,e.slug]),we=react.useMemo(()=>ve?ve.positions.find(q=>q.side?.toLowerCase()==="no"&&q.market?.slug===e.slug)?.size??0:null,[ve,e.slug]),st=react.useMemo(()=>{if(isNaN(f)||f<=0)return 0;if(m==="buy")return f;let U=p==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return f*U},[m,p,f,e.outcomes]),Yt=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?O*1:st,[m,O,st,f]),Vr=Yt-st,ot=react.useCallback(U=>{y(U),g(NaN);},[]),Gt=react.useCallback(U=>{if(isNaN(U)){g(NaN);return}let q=Math.max(0,U),Ee=m==="buy"?Math.round(q*100)/100:Math.round(q);g(Ee);},[m]),Et=react.useMemo(()=>{let U=[];(isNaN(f)||f<ut)&&U.push(`Minimum quantity is ${ut}`),e.status!=="open"&&U.push("Market is not active"),m==="buy"&&nt!=null&&!isNaN(f)&&f>0&&f>nt&&U.push("Insufficient USDC balance");let q=p==="yes"?wt:we;return m==="sell"&&q!=null&&!isNaN(f)&&f>0&&f>q&&U.push("Insufficient shares"),{isValid:U.length===0,errors:U}},[f,e.status,m,nt,wt,we,p]),{mutateAsync:jt}=ls(),{data:Tt}=os({id:h??"",source:u},{enabled:!!h});react.useEffect(()=>{if(!Tt||!h)return;let{status:U}=Tt;U==="closed"?(b(false),v(null),ui.toast.success(s("predict.trade.submitSuccess")),lf(),g(NaN)):(U==="failed"||U==="expired")&&(b(false),v(null),ui.toast.error(s("predict.trade.submitError")));},[Tt,h,s]);let Mt=react.useCallback(async()=>{if(!(!Et.isValid||!l||!c||!a)){b(true),v(null);try{let Ee=(await je()).data?.transaction;if(!Ee){ui.toast.error(s("predict.trade.submitError")),b(!1);return}let Qe=Uint8Array.from(atob(Ee),Xe=>Xe.charCodeAt(0)),it=await a.sendTransaction(Qe);await jt({signedTransaction:btoa(String.fromCharCode(...Qe)),orderContext:{user_public_key:c,input_mint:K,output_mint:oe,amount:k,price:String(w),side:m==="buy"?"BUY":"SELL",outcome:p==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}}),v(it);}catch{ui.toast.error(s("predict.trade.submitError")),b(false);}}},[Et.isValid,l,c,a,je,jt,K,oe,k,w,m,p,e.slug,s]);return {outcome:p,side:m,quantity:f,estimatedCost:st,potentialPayout:Yt,potentialProfit:Vr,usdcBalance:nt,yesTokenBalance:wt,noTokenBalance:we,isBalanceLoading:Ct,isSubmitting:x,validation:Et,setOutcome:d,setSide:ot,setQuantity:Gt,submit:Mt}}function Tn({event:e,market:t,initialSide:r,initialOutcome:n,chain:s}){let{outcome:i,side:o,quantity:a,estimatedCost:l,potentialPayout:c,potentialProfit:u,usdcBalance:p,yesTokenBalance:d,noTokenBalance:m,isBalanceLoading:y,isSubmitting:f,validation:g,setOutcome:x,setSide:b,setQuantity:h,submit:v}=Si({market:t,initialSide:r,initialOutcome:n,chain:s}),w=walletConnector.useAuthCallback(v),O=react.useMemo(()=>e?Pi(e):void 0,[e]),k=react.useMemo(()=>Cn(t),[t]);return jsxRuntime.jsx(gr,{event:O,market:k,outcome:i,side:o,quantity:a,estimatedCost:l,potentialPayout:c,potentialProfit:u,usdcBalance:p,yesTokenBalance:d,noTokenBalance:m,isBalanceLoading:y,isSubmitting:f,isValid:g.isValid,validationErrors:g.errors,onOutcomeChange:x,onSideChange:b,onQuantityChange:h,onSubmit:w})}function Nn({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=i18n.useTranslation(),[s,i]=react.useState("positions"),o=react.useMemo(()=>e.markets?.map(l=>l.slug)??[],[e.markets]),a=[{key:"positions",label:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:a.map(l=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(l.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",s===l.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:l.label},l.key))}),t?jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[s==="positions"&&jsxRuntime.jsx(ff,{source:e.source,walletAddress:t,marketSlugs:o}),s==="orders"&&jsxRuntime.jsx(gf,{source:e.source,walletAddress:t,marketSlugs:o,onCancelOrder:r}),s==="trades"&&jsxRuntime.jsx(bf,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:n("predict.trade.connectWallet")})]})}function ff({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:i}=rr({source:e,user:t}),o=react.useMemo(()=>s?.positions?r.length===0?s.positions:s.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[s?.positions,r]);return i?jsxRuntime.jsx(On,{rows:3}):o.length===0?jsxRuntime.jsx(Rn,{message:n("predict.positions.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.positions.market")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.positions.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.positions.size")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.positions.avgCost")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.positions.currentPrice")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right",children:n("predict.positions.pnl")})]})}),jsxRuntime.jsx("tbody",{children:o.map((a,l)=>jsxRuntime.jsx(yf,{position:a},`${a.market?.slug??l}-${a.side}`))})]})})}function yf({position:e}){let t=e.pnl>0?"text-success":e.pnl<0?"text-danger":"text-foreground",r=e.pnl>0?"+":"";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground max-w-[180px] truncate",children:e.market?.outcomes?.[0]?.label??e.market?.question??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium uppercase",e.side.toLowerCase()==="yes"?"bg-primary/10 text-primary":"bg-secondary/10 text-secondary"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.size}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:Cr(e.avg_price)}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:Cr(e.current_price)}),jsxRuntime.jsxs("td",{className:ui.cn("py-2 text-right font-mono",t),children:[r,"$",Math.abs(e.pnl).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",r,e.pnl_percent.toFixed(1),"%)"]})]})]})}function gf({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:s}=i18n.useTranslation(),{data:i,isLoading:o}=ss({source:e,wallet_address:t}),a=is(),l=react.useMemo(()=>{if(!i?.items)return [];let u=new Set(["live","open","submitted","pending"]),p=i.items.filter(d=>u.has(d.status));return r.length>0&&(p=p.filter(d=>d.market_id&&r.includes(d.market_id))),p},[i?.items,r]),c=u=>{n?n(u):a.mutate({source:e,id:u});};return o?jsxRuntime.jsx(On,{rows:3}):l.length===0?jsxRuntime.jsx(Rn,{message:s("predict.openOrders.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:s("predict.openOrders.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:s("predict.openOrders.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:s("predict.openOrders.type")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:s("predict.openOrders.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:s("predict.openOrders.filled")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:s("predict.openOrders.status")}),jsxRuntime.jsx("th",{className:"py-2 font-normal"})]})}),jsxRuntime.jsx("tbody",{children:l.map(u=>jsxRuntime.jsx(vf,{order:u,onCancel:()=>c(u.id),isCancelling:a.isPending},u.id))})]})})}function vf({order:e,onCancel:t,isCancelling:r}){let{t:n}=i18n.useTranslation(),s=e.side==="BUY";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",s?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-neutral capitalize",children:e.order_type??"limit"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.price?Cr(parseFloat(e.price)):"\u2014"}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:[e.size_matched??"0","/",e.original_size??"\u2014"]}),jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx(xf,{status:e.status})}),jsxRuntime.jsx("td",{className:"py-2 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:r,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:r?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):n("predict.openOrders.cancel")})})]})}function xf({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function bf({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:n,isLoading:s}=cs({source:e,wallet:t,limit:50}),i=n?.items??[];return s?jsxRuntime.jsx(On,{rows:3}):i.length===0?jsxRuntime.jsx(Rn,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right",children:r("predict.tradeHistory.time")})]})}),jsxRuntime.jsx("tbody",{children:i.map(o=>jsxRuntime.jsx(hf,{trade:o},o.id))})]})})}function hf({trade:e}){let t=e.side.toUpperCase()==="BUY",r=kf(e.timestamp);return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:Cr(e.price)}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.size}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:["$",e.usd_size.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 text-right text-neutral whitespace-nowrap",children:r})]})}function Rn({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:e})}function On({rows:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},r))})}function Cr(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function kf(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),s=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${s}:${i}`}function wf(e){return `${Math.round(e*100)}\xA2`}function Ef(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Tf(e){let t=new Date(e*1e3),r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${n} ${s}:${i}`}function Mi({market:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[n,s]=react.useState("trade-yes"),i=e.source,{data:o,isLoading:a}=rs({slug:e.slug,source:i},{enabled:n==="trade-yes"||n==="trade-no"}),{data:l,isLoading:c}=ns({slug:e.slug,source:i,limit:20},{enabled:n==="activity"}),u=react.useCallback((f,g)=>{t?.(e,"yes",g==="ask"?"buy":"sell");},[e,t]),p=react.useCallback((f,g)=>{t?.(e,"no",g==="ask"?"buy":"sell");},[e,t]),d=react.useMemo(()=>(o?.bids??[]).map(f=>({price:f.price,quantity:f.size})),[o?.bids]),m=react.useMemo(()=>(o?.asks??[]).map(f=>({price:f.price,quantity:f.size})),[o?.asks]),y=l?.items??[];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:f=>s(f),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:r("predict.market.tradeYes")},"trade-yes"),jsxRuntime.jsx(ui.Tab,{title:r("predict.market.tradeNo")},"trade-no"),jsxRuntime.jsx(ui.Tab,{title:r("predict.activity.title")},"activity")]}),jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[n==="trade-yes"&&jsxRuntime.jsx(vt,{bids:d,asks:m,isLoading:a,onPriceClick:u}),n==="trade-no"&&jsxRuntime.jsx(vt,{bids:d,asks:m,isLoading:a,onPriceClick:p}),n==="activity"&&jsxRuntime.jsx(Mf,{trades:y,isLoading:c})]})]})}function Mf({trades:e,isLoading:t}){let{t:r}=i18n.useTranslation();return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})}):e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.time")})]}),e.map(n=>{let s=n.outcome?.toLowerCase()==="yes",i=s?"text-bullish":"text-bearish",o=r(s?"predict.trade.yes":"predict.trade.no");return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs hover:bg-default-100 transition-colors",children:[jsxRuntime.jsx("span",{className:`font-medium ${i}`,children:o}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:wf(n.price)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:Ef(n.size)}),jsxRuntime.jsx("span",{className:"text-right text-default-500",children:Tf(n.timestamp)})]},n.id)})]})}var Bn=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},wr=4,Ni=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Ri(e,t){let r=new Date(e);return t===M.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Oi(e){return `${(e*100).toFixed(2)}%`}var Df=[{range:M.ONE_DAY,label:"1D"},{range:M.ONE_WEEK,label:"1W"},{range:M.ONE_MONTH,label:"1M"},{range:M.ALL,label:"ALL"}];function Ff({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Df.map(({range:r,label:n})=>{let s=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:s?"#f9fafb":"#6b7280",fontWeight:s?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:n},r)})})}function Af({dots:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.map(({cx:t,cy:r,color:n},s)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:n,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3.5,fill:n})]},s))})}function Wf(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(s=>{let i=e.current,o=t.current;if(!i||!o)return;let a=i.getBoundingClientRect(),l=(s.clientX-a.left)/a.width*100;o.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.38) ${l}%)`,o.style.opacity="1";},[]),n=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function qf({active:e,payload:t,label:r,labelMap:n}){if(!e||!t?.length)return null;let s=[...t].filter(i=>i.value!=null).sort((i,o)=>(o.value??0)-(i.value??0));return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?Ri(r):r}),s.map(i=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:i.stroke??i.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(i.dataKey)??i.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:i.value!=null?Oi(i.value):"-"})]},i.dataKey))]})}function Hf({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[s,i]=react.useState(false),o=react.useRef(null);react.useEffect(()=>{if(!s)return;function c(u){o.current&&!o.current.contains(u.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);let a=t.length>=wr,l=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?e.find(c=>c.slug===t[0])?.question??"1 market":`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:o,style:{position:"relative",display:"inline-block",maxWidth:320},children:[jsxRuntime.jsxs("button",{onClick:()=>i(c=>!c),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",minWidth:160,maxWidth:320,userSelect:"none"},children:[l,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:s?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),s&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",wr," markets"]}),e.map(c=>{let u=t.includes(c.slug),p=!u&&a,d=u&&t.length===1,m=r.get(c.slug)??"#6b7280",y=c.outcomes.find(g=>g.label.toLowerCase()==="yes")??c.outcomes[0],f=y?.price!=null?`${Math.round(y.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{d||p||n(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:u?"rgba(255,255,255,0.05)":"transparent",cursor:p||d?"not-allowed":"pointer",opacity:p?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:g=>{!p&&!d&&(g.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:g=>{g.currentTarget.style.background=u?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:u?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:u?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:u&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:u?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),f&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:f})]},c.slug)})]})]})}function Kf({series:e,colorMap:t,currentValues:r}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 16px",padding:"0 2px"},children:e.map(n=>{let s=t.get(n.marketSlug)??"#6b7280",i=r.get(n.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12},children:[jsxRuntime.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:s,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af"},children:n.label}),i!=null&&jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700},children:Oi(i)})]},n.marketSlug)})})}function $f(e){if(e.length===0)return [];let t=new Set;e.forEach(i=>i.data.forEach(o=>t.add(o.timestamp)));let r=Array.from(t).sort((i,o)=>i-o),n=e.map(i=>{let o=new Map;return i.data.forEach(a=>o.set(a.timestamp,a.price)),{slug:i.marketSlug,map:o}}),s=new Map;return r.map(i=>{let o={timestamp:i};return n.forEach(({slug:a,map:l})=>{let c=l.get(i);if(c!==void 0)s.set(a,c),o[a]=c;else {let u=s.get(a);u!==void 0&&(o[a]=u);}}),o})}function Vi(e){return jsxRuntime.jsx(Bn,{children:jsxRuntime.jsx(zf,{...e})})}function zf({event:e,isLoading:t,className:r}){let n=react.useMemo(()=>e.markets??[],[e.markets]),[s,i]=react.useState(()=>n.slice(0,wr).map(k=>k.slug)),[o,a]=react.useState(ke),l=react.useMemo(()=>{let k=new Map;return n.forEach((E,C)=>{k.set(E.slug,Ni[C%Ni.length]);}),k},[n]),c=react.useMemo(()=>n.filter(k=>s.includes(k.slug)),[n,s]),{series:u,isLoading:p}=ts(c,o),d=t||p,m=react.useMemo(()=>{if(u.length>0&&u.some(C=>C.data.length>0))return u;let k=Date.now(),E=864e5;return c.map(C=>{let Q=(C.outcomes?.find(K=>K.label.toLowerCase()==="yes")??C.outcomes?.[0])?.price??.5;return {marketSlug:C.slug,label:C.outcomes?.[0]?.label??C.question,data:[{timestamp:k-7*E,price:Q},{timestamp:k,price:Q}]}})},[u,c]),y=react.useMemo(()=>$f(m),[m]),f=react.useMemo(()=>{if(y.length===0)return [0,1];let k=1/0,E=-1/0;if(s.forEach(L=>{y.forEach(Q=>{let K=Q[L];K!=null&&(K<k&&(k=K),K>E&&(E=K));});}),!isFinite(k))return [0,1];let C=Math.max((E-k)*.15,.05);return [Math.max(0,k-C),Math.min(1,E+C)]},[y,s]),g=react.useMemo(()=>{let k=new Map;return m.forEach(E=>{E.data.length>0&&k.set(E.marketSlug,E.data[E.data.length-1].price);}),k},[m]),x=react.useMemo(()=>{let k=new Map;return m.forEach(E=>k.set(E.marketSlug,E.label)),k},[m]),{wrapperRef:b,overlayRef:h,onMouseMove:v,onMouseLeave:w}=Wf(),O=react.useCallback(k=>{i(E=>E.includes(k)?E.length<=1?E:E.filter(C=>C!==k):E.length>=wr?E:[...E,k]);},[]);return d?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):y.length===0?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[n.length>1&&jsxRuntime.jsx(Hf,{markets:n,selectedSlugs:s,colorMap:l,onToggle:O}),jsxRuntime.jsx(Kf,{series:m,colorMap:l,currentValues:g}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsxs("div",{ref:b,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:v,onMouseLeave:w,children:[jsxRuntime.jsx("div",{ref:h,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:y,margin:{top:8,right:16,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:k=>Ri(k,o),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:f,tickFormatter:k=>`${Math.round(k*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:k=>jsxRuntime.jsx(qf,{...k,labelMap:x}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},isAnimationActive:false}),m.map(k=>{let E=l.get(k.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"stepAfter",dataKey:k.marketSlug,stroke:E,strokeWidth:2,dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:E},connectNulls:true,isAnimationActive:false},k.marketSlug)}),jsxRuntime.jsx(recharts.Customized,{component:k=>{let E=k.xAxisMap?Object.values(k.xAxisMap)[0]?.scale:null,C=k.yAxisMap?Object.values(k.yAxisMap)[0]?.scale:null,L=[];if(E&&C&&y.length>0){let Q=y[y.length-1];m.forEach(K=>{let oe=Q[K.marketSlug];if(oe==null)return;let Ge=E(Q.timestamp),ge=C(oe);Ge==null||ge==null||L.push({cx:Ge,cy:ge,color:l.get(K.marketSlug)??"#6b7280"});});}return jsxRuntime.jsx(Af,{dots:L})}})]})})]}),jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",paddingRight:4,marginTop:2},children:jsxRuntime.jsx(Ff,{value:o,onChange:a})})]})]})}function Un(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function jf(e){return `${Math.round(e*100)}%`}function Li(e){let t=e*100;return t<1&&t>0?"< 1":Number.isInteger(t)?`${t}`:t.toFixed(1)}function _n(e){return e.outcomes?.[0]?.label??e.question}function Ai(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function Qi(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${s} ${i}:${o}`}function Bi(e){let[t,r]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let u=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(u)},[e]),!e)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let s=n-t;if(s<=0)return null;let i=Math.floor(s/864e5),o=Math.floor(s%864e5/36e5),a=Math.floor(s%36e5/6e4),l=Math.floor(s%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(o).padStart(2,"0")}h`),c.push(`${String(a).padStart(2,"0")}m`),c.push(`${String(l).padStart(2,"0")}s`),c.join(" ")}function Ui(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),o=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${s}/${i}/${o} (${l}${c})`}function Wi({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[n,s]=react.useState(false),i=react.useRef(null);react.useEffect(()=>{let d=i.current;if(!d)return;let m=false,y=0,f=()=>{let{bottom:x}=d.getBoundingClientRect(),b=m?x<0:x<-20;b!==m&&(m=b,s(b));},g=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(f);};return window.addEventListener("scroll",g,{passive:true,capture:true}),f(),()=>{cancelAnimationFrame(y),window.removeEventListener("scroll",g,{capture:true});}},[]);let o=react.useMemo(()=>[...e.markets||[]].sort((d,m)=>Un(m)-Un(d)),[e.markets]),a=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),l=Bi(e.start_at),c=Bi(e.end_at),u=Ui(e.start_at),p=Ui(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-4 lg:gap-y-6 px-1 pb-8 lg:px-4 lg:pb-12 lg:max-w-3xl",children:[jsxRuntime.jsx("div",{ref:i,className:"h-0 w-0"}),jsxRuntime.jsxs("div",{className:`sticky top-0 z-30 flex items-center bg-background/80 backdrop-blur-md transition-all duration-300 ${n?"gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:`flex-shrink-0 transition-all duration-300 ${n?"!h-8 !w-8 lg:!h-10 lg:!w-10":"!h-14 !w-14 lg:!h-18 lg:!w-18"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ey,{source:e.source}),e.tags?.slice(0,3).map(d=>jsxRuntime.jsx("span",{className:"text-xs text-neutral truncate",children:d.label},d.slug))]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(l||c)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs text-neutral lg:text-sm font-mono",children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.beginsIn",{time:l})}),u&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:u})]})]}):c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.endsIn",{time:c})}),p&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:p})]})]}):null}),jsxRuntime.jsx(Vi,{event:e}),jsxRuntime.jsxs("div",{className:"text-sm text-neutral",children:[a," ",r("predict.event.volume")]}),jsxRuntime.jsx(Xf,{markets:o,onTradeAction:t}),jsxRuntime.jsx(Jf,{markets:o,event:e})]})}var _i=5;function Xf({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[n,s]=react.useState(false),[i,o]=react.useState(null);if(e.length===0)return null;let a=e.length>_i,l=n?e:e.slice(0,_i),c=u=>{o(p=>p===u?null:u);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:l.map((u,p)=>{let d=Un(u),m=u.outcomes[1]?.best_ask??u.outcomes[1]?.price,y=p===0,f=i===u.slug;return jsxRuntime.jsx(Zf,{market:u,yesPrice:d,noPrice:m??void 0,isTopMarket:y,isExpanded:f,onToggleExpand:()=>c(u.slug),onTradeAction:t},u.slug)})})]}),a&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(u=>!u),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx("svg",{className:ui.cn("h-4 w-4 transition-transform",n&&"rotate-180"),viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}function Zf({market:e,yesPrice:t,noPrice:r,isTopMarket:n,isExpanded:s,onToggleExpand:i,onTradeAction:o}){let{t:a}=i18n.useTranslation(),l=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:i,role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:_n(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:_n(e)}),l&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:jf(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-opacity",n?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:c=>{c.stopPropagation(),o?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:Li(t)})}),jsxRuntime.jsx("button",{type:"button",className:"flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 bg-secondary/10 text-secondary cursor-pointer hover:opacity-80 transition-opacity",onClick:c=>{c.stopPropagation(),o?.(e,"no","buy");},children:r!=null?a("predict.market.action.no",{price:Li(r)}):a("predict.market.no")})]})})]}),s&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"px-2 pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(Mi,{market:e,onTradeAction:o})})})})]})}function Jf({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[n,s]=react.useState(null),[i,o]=react.useState(false),a=e.filter(p=>p.rules&&p.rules.length>0);if(a.length===0)return null;let l=a.find(p=>p.slug===n)??a[0];if(!l?.rules?.length)return null;let c=l.rules.join(`
19
+ `;function fr({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:s}){let[a,i]=react.useState(null),c=e.markets??[],l=react.useMemo(()=>c.length>2?[...c].sort((N,A)=>(A.outcomes?.[0]?.price??0)-(N.outcomes?.[0]?.price??0)):c,[c]),d=l.filter(N=>N.status==="open"),u=l.length===1,p=d.slice(0,sr),m=d.length-sr,g=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),f=a?d.find(N=>N.slug===a)??null:null,h=!!f||u,v=()=>{h||o?.(e);},O=N=>{N.stopPropagation(),f&&(N.preventDefault(),i(null));},R=N=>{N.stopPropagation(),t||(N.preventDefault(),o?.(e));};return jsxRuntime.jsxs("div",{className:ui.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!h&&"cursor-pointer"),onMouseEnter:()=>s?.(e),onClick:v,children:[jsxRuntime.jsx("style",{children:To}),jsxRuntime.jsx(Lo,{event:e,href:t,LinkComponent:r,onClick:O,isExpanded:h}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:u?jsxRuntime.jsx(Bo,{market:d[0],event:e,formattedVolume:g,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n}):f?jsxRuntime.jsx(Fo,{market:f,event:e,onCollapse:()=>i(null),onSelectOutcome:n}):jsxRuntime.jsx(Do,{displayedMarkets:p,moreCount:m,formattedVolume:g,source:e.source,href:t,LinkComponent:r,onMarketClick:N=>i(N.slug),onShowMore:R})})]})}function Lo({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let s=e.start_at?Mo(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),s&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",s]})]}),jsxRuntime.jsx(Oo,{event:e})]})}function Ro(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),s=300*1e3,a=900*1e3;if(n>0&&n<=a){let i=n<=s?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=s?"5m":"15m",color:i});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Oo({event:e}){let t=react.useMemo(()=>Ro(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsxRuntime.jsx(Io,{},o);case "crypto-short":return jsxRuntime.jsx(_o,{label:r.label,color:r.color},o);case "closed":return jsxRuntime.jsx(Ao,{},o)}})})}function Io(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function _o({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function Ao(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Do({displayedMarkets:e,moreCount:t,formattedVolume:r,source:o,href:n,LinkComponent:s,onMarketClick:a,onShowMore:i}){let{t:c}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(l=>{let d=pr(l);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:u=>{u.stopPropagation(),a(l);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:l.outcomes?.[0]?.label??l.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:mr(d)}),jsxRuntime.jsx(Ho,{})]})]},l.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui.Linkable,{href:n,LinkComponent:s,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[c("predict.event.showMore"),jsxRuntime.jsx(vr,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",c("predict.event.volume"),jsxRuntime.jsx(xr,{source:o})]})]})]})}function cr({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:i=>{let c=i.currentTarget;c.style.setProperty("--shadow-offset","2px"),c.style.transform="translateY(2px)";},onMouseLeave:i=>{let c=i.currentTarget;c.style.setProperty("--shadow-offset","4px"),c.style.transform="translateY(0px)";},onClick:o,children:n})}function gr({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:s}=i18n.useTranslation(),[a,i]=o?wo(e):[ht,ur],c=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",l=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=n==="label"&&c===l?"action":n,u=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${ir(e)}\xA2`:s("predict.market.action.yes",{price:ir(e)}),p=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${lr(e)}\xA2`:s("predict.market.action.no",{price:lr(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(cr,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"yes");},children:u}),jsxRuntime.jsx(cr,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"no");},children:p})]})}function Ho(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Bo({market:e,event:t,formattedVolume:r,href:o,LinkComponent:n,onSelect:s,onSelectOutcome:a}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(gr,{market:e,event:t,onSelectOutcome:a,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui.Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:l=>{l.stopPropagation(),o||(l.preventDefault(),s?.(t));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(vr,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",i("predict.event.volume"),jsxRuntime.jsx(xr,{source:t.source})]})]})]})}function Fo({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let{t:n}=i18n.useTranslation(),s=pr(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:mr(s)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(gr,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx(Uo,{className:"h-3 w-3"}),n("predict.event.back")]})]})}function vr({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Uo({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function xr({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Yo=768,br=1024,qo=1280,jo=8,Go=224,Xo=304,Qo=114;function Zo(e){return e>=qo?4:e>=br?3:e>=Yo?2:1}function Jo(e){return e>=br?Xo:Go}function yr({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i}){let c=react.useRef(null),l=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:c}),p=Zo(d),m=Jo(d),g=Math.ceil(e.length/p)||0,f=!t&&e.length>0,h=g+(t?1:0)+(f?1:0),v=react.useCallback(A=>A<g,[g]),O=react.useCallback(async()=>{r?.();},[r]),R=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:v,loadMoreRows:O,rowCount:h,threshold:3}),N=react.useCallback(()=>{l.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:c,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{listRef:l,className:"no-scrollbar",style:{height:u},onRowsRendered:R,rowComponent:es,rowCount:h,rowHeight:A=>f&&A===h-1?Qo:(m),rowProps:{events:e,columnCount:p,dataRowCount:g,showEndOfList:f,totalRowCount:h,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i,onScrollToTop:N}})})}function es({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:s,totalRowCount:a,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u,onScrollToTop:p}){if(s&&e===a-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ts,{onScrollToTop:p})});if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let m=e*o,g=r.slice(m,m+o),f=o-g.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[g.map(h=>h==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:jo},children:jsxRuntime.jsx(fr,{event:h,href:l?.(h),LinkComponent:d,onSelect:i,onSelectOutcome:c,onHover:u})},h.slug)),f>0&&Array.from({length:f}).map((h,v)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${v}`))]})})}function ts({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function kr({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u}){let{data:p,hasMore:m,fetchMore:g,isFetching:f}=nr({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a});return f?jsxRuntime.jsx(or,{count:48}):jsxRuntime.jsx(yr,{events:p,hasMore:m,onFetchMore:g,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u})}function bc({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[s,a]=react.useState({categorySlug:null,tagSlug:null}),[i,c]=react.useState(ut),{isOpen:l,onOpen:d,onClose:u}=ui.useDisclosure(),p=react.useCallback(R=>{a(R);},[]),m=react.useCallback(R=>{c(N=>({...N,sortPreset:R}));},[]),g=react.useCallback(R=>{c(N=>({...N,sortAsc:R}));},[]),f=react.useCallback(R=>{c(R);},[]),h=react.useMemo(()=>Jt[i.sortPreset].sort_by,[i.sortPreset]),v=react.useMemo(()=>pt(i),[i]),O=jsxRuntime.jsx(er,{sortPreset:i.sortPreset,onSortChange:m,sortAsc:i.sortAsc,onSortAscChange:g,onFilterPress:d,filterCount:v});return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(qt,{onSelect:p,trailing:O}),jsxRuntime.jsx(Gt,{isOpen:l,onClose:u,value:i,onChange:f}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(kr,{tagSlugSelection:s,sort_by:h,sort_asc:i.sortAsc,source:i.source,onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n})})]})}function Nr(e){return {title:e.title,imageUrl:e.image_url}}function wr(e){let t=e.outcomes[0],r=e.outcomes[1];return {yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}function ms(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Pt__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Pt__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Pt__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Cr({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:o="buy"}){let{t:n}=i18n.useTranslation(),{status:s}=walletConnector.useAuth(),i=walletConnector.useWallets().find(T=>T.chainNamespace===types.ChainNamespace.SOLANA&&T.isConnected),c=s==="authenticated",l=i?.address,d=e.source,[u,p]=react.useState(r),[m,g]=react.useState(o),[f,h]=react.useState(NaN),[v,O]=react.useState(false),[R,N]=react.useState(null),A=react.useMemo(()=>{let T=u==="yes"?0:1,D=e.outcomes[T];return m==="buy"?D?.best_ask??D?.price??.5:D?.best_bid??D?.price??.5},[e.outcomes,u,m]),q=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?A>0?f/A:0:f,[m,f,A]),Q=react.useMemo(()=>isNaN(f)||f<=0?"0":String(Math.round(f*1e6)),[f]),Pe=e.provider_meta?.["dflow.yesMint"]??"",Ee=e.provider_meta?.["dflow.noMint"]??"",pe=e.provider_meta?.["dflow.collateralMint"]??"",w=u==="yes"?Pe:Ee,X=m==="buy"?pe:w,ee=m==="buy"?w:pe,y=!!X&&!!ee&&!!l&&Q!=="0",{refetch:P}=reactPredict.useDFlowQuote({inputMint:X,outputMint:ee,amount:Q,userPublicKey:l??"",slippageBps:100},{enabled:y}),{data:C,isLoading:z}=reactPredict.usePositions({source:d,user:l??""},{enabled:!!l}),K=react.useMemo(()=>C&&C.positions.reduce((D,oe)=>oe.side==="USDC"||oe.side==="collateral"?D+(oe.current_value??0):D,0)||null,[C]),V=react.useMemo(()=>C?C.positions.find(D=>D.side?.toLowerCase()==="yes"&&D.market?.slug===e.slug)?.size??0:null,[C,e.slug]),me=react.useMemo(()=>C?C.positions.find(D=>D.side?.toLowerCase()==="no"&&D.market?.slug===e.slug)?.size??0:null,[C,e.slug]),ce=react.useMemo(()=>{if(isNaN(f)||f<=0)return 0;if(m==="buy")return f;let T=u==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return f*T},[m,u,f,e.outcomes]),Ne=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?q*1:ce,[m,q,ce,f]),An=Ne-ce,Dn=react.useCallback(T=>{g(T),h(NaN);},[]),Hn=react.useCallback(T=>{if(isNaN(T)){h(NaN);return}let D=Math.max(0,T),oe=m==="buy"?Math.round(D*100)/100:Math.round(D);h(oe);},[m]),lt=react.useMemo(()=>{let T=[];(isNaN(f)||f<gt)&&T.push(`Minimum quantity is ${gt}`),e.status!=="open"&&T.push("Market is not active"),m==="buy"&&K!=null&&!isNaN(f)&&f>0&&f>K&&T.push("Insufficient USDC balance");let D=u==="yes"?V:me;return m==="sell"&&D!=null&&!isNaN(f)&&f>0&&f>D&&T.push("Insufficient shares"),{isValid:T.length===0,errors:T}},[f,e.status,m,K,V,me,u]),{mutateAsync:Ft}=reactPredict.useDFlowSubmit(),{data:ct}=reactPredict.useOrder({id:R??"",source:d},{enabled:!!R});react.useEffect(()=>{if(!ct||!R)return;let{status:T}=ct;T==="closed"?(O(false),N(null),ui.toast.success(n("predict.trade.submitSuccess")),ms(),h(NaN)):(T==="failed"||T==="expired")&&(O(false),N(null),ui.toast.error(n("predict.trade.submitError")));},[ct,R,n]);let Bn=react.useCallback(async()=>{if(!(!lt.isValid||!c||!l||!i)){O(true),N(null);try{let oe=(await P()).data?.transaction;if(!oe){ui.toast.error(n("predict.trade.submitError")),O(!1);return}let Ut=Uint8Array.from(atob(oe),Un=>Un.charCodeAt(0)),Fn=await i.sendTransaction(Ut);await Ft({signedTransaction:btoa(String.fromCharCode(...Ut)),orderContext:{user_public_key:l,input_mint:X,output_mint:ee,amount:Q,price:String(A),side:m==="buy"?"BUY":"SELL",outcome:u==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}}),N(Fn);}catch{ui.toast.error(n("predict.trade.submitError")),O(false);}}},[lt.isValid,c,l,i,P,Ft,X,ee,Q,A,m,u,e.slug,n]);return {outcome:u,side:m,quantity:f,estimatedCost:ce,potentialPayout:Ne,potentialProfit:An,usdcBalance:K,yesTokenBalance:V,noTokenBalance:me,isBalanceLoading:z,isSubmitting:v,validation:lt,setOutcome:p,setSide:Dn,setQuantity:Hn,submit:Bn}}var ys=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function Lr({event:e,market:t,outcome:r,side:o,quantity:n,potentialProfit:s,estimatedCost:a,usdcBalance:i,yesTokenBalance:c,noTokenBalance:l,isBalanceLoading:d,isSubmitting:u,isValid:p,onOutcomeChange:m,onSideChange:g,onQuantityChange:f,onSubmit:h}){let{t:v}=i18n.useTranslation(),[O,R]=react.useState("market"),[N,A]=react.useState(false),q=react.useMemo(()=>{let w=o==="buy"?r==="yes"?t.yesAsk:t.noAsk:r==="yes"?t.yesBid:t.noBid;return w!=null?Math.round(Number(w)*100):null},[o,r,t]),Q=react.useMemo(()=>{if(u)return v("predict.trade.submitting");if(!n||isNaN(n)||n<=0)return v("predict.trade.enterAmount");let w=v(o==="buy"?"predict.trade.buy":"predict.trade.sell"),X=v(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${w} ${X}`},[u,n,o,r,v]),Pe=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]),Ee=()=>{f(Math.floor((i??0)/2*100)/100);},pe=()=>{f(i??0);};return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:r==="yes"?"text-bullish":"text-bearish",children:[v(o==="buy"?"predict.trade.buy":"predict.trade.sell")," ",v(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:O,onSelectionChange:w=>R(w),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.limit")},"limit")]}),q!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[q," \xA2"]})]}),jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:w=>g(w),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(w=>{let X=w==="yes"?c:l;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(w),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===w?w==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:v(w==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let ee=o==="buy"?w==="yes"?t.yesAsk:t.noAsk:w==="yes"?t.yesBid:t.noBid;return ee!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(ee)*100),"\xA2"]}):null})()]}),o==="sell"&&r===w&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:d?"\u2013":`${X??0} shares`})]},w)})}),o==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{children:v("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:ys,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:i!=null?`${i.toFixed(6)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:Ee,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:v("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:pe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:v("predict.trade.max")})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:v(o==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(n)?void 0:n,onValueChange:w=>{f(w);},minValue:0,step:o==="buy"?.01:1,formatOptions:o==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:o==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},o),o==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(w=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{f(Math.floor((r==="yes"?c??0:l??0)*w/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[w,"%"]},w)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{f(r==="yes"?c??0:l??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:v("common.all")})]})]}),!isNaN(n)&&n>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:v(o==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(o==="buy"?s:a).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>A(w=>!w),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:v("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",N&&"rotate-180")})]}),q!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[q,"% chance"]})]}),N&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsxs("span",{children:[v("predict.trade.bestBid"),":"," ",Math.round((t.yesBid??0)*100),"\xA2"]}),jsxRuntime.jsxs("span",{children:[v("predict.trade.bestAsk"),":"," ",Math.round((t.yesAsk??0)*100),"\xA2"]})]})]}),jsxRuntime.jsx(ui.Button,{color:Pe,fullWidth:true,radius:"lg",size:"lg",isDisabled:!p||u||!n||isNaN(n)||n<=0,isLoading:u,onPress:h,children:Q})]})}function Or({event:e,market:t,initialSide:r,initialOutcome:o,chain:n}){let{outcome:s,side:a,quantity:i,estimatedCost:c,potentialPayout:l,potentialProfit:d,usdcBalance:u,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:g,isSubmitting:f,validation:h,setOutcome:v,setSide:O,setQuantity:R,submit:N}=Cr({market:t,initialSide:r,initialOutcome:o,chain:n}),A=walletConnector.useAuthCallback(N),q=react.useMemo(()=>e?Nr(e):void 0,[e]),Q=react.useMemo(()=>wr(t),[t]);return jsxRuntime.jsx(Lr,{event:q,market:Q,outcome:s,side:a,quantity:i,estimatedCost:c,potentialPayout:l,potentialProfit:d,usdcBalance:u,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:g,isSubmitting:f,isValid:h.isValid,validationErrors:h.errors,onOutcomeChange:v,onSideChange:O,onQuantityChange:R,onSubmit:A})}function _r({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=i18n.useTranslation(),[n,s]=react.useState("positions"),a=react.useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:i}=reactPredict.usePositions({source:e.source,user:t??""}),c=react.useMemo(()=>!i?.positions||!t?0:a.length===0?i.positions.length:i.positions.filter(u=>u.market&&a.includes(u.market.slug)).length,[i?.positions,a,t]),d=[{key:"positions",label:c>0?`${o("predict.positions.title")} (${c})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===u.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:u.label},u.key))}),t?jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[n==="positions"&&jsxRuntime.jsx(Ts,{source:e.source,walletAddress:t,marketSlugs:a}),n==="orders"&&jsxRuntime.jsx(Rs,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),n==="trades"&&jsxRuntime.jsx(_s,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:o("predict.trade.connectWallet")})]})}function Ts({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=i18n.useTranslation(),{data:n,isLoading:s}=reactPredict.usePositions({source:e,user:t}),a=react.useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(i=>i.market&&r.includes(i.market.slug)):[],[n?.positions,r]);return s?jsxRuntime.jsx(wt,{rows:3}):a.length===0?jsxRuntime.jsx(Nt,{message:o("predict.positions.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-4 font-normal whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right whitespace-nowrap"})]})}),jsxRuntime.jsx("tbody",{children:a.map((i,c)=>jsxRuntime.jsx(Ls,{position:i},`${i.market?.slug??c}-${i.side}`))})]})})}function Ls({position:e}){let{t}=i18n.useTranslation(),r=e.pnl??0,o=e.pnl_percent??0,n=e.avg_price??0,s=e.current_price??0,a=r>0?"text-success":r<0?"text-danger":"text-foreground",i=r>0?"+":"",c=e.market?.outcomes?.[0]?.label??e.market?.question??"\u2014",l=e.side,d=e.size,u=e.size*s,p=e.market?.end_at?Hs(e.market.end_at):"\u2014";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0 hover:bg-content2/40 transition-colors",children:[jsxRuntime.jsx("td",{className:"py-2 pr-4 max-w-[200px]",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsxRuntime.jsx("span",{className:ui.cn("inline-block text-[10px] font-medium w-fit",l.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:l})]})}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:e.size}),jsxRuntime.jsxs("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:["$",u.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:Qe(n)}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:Qe(s)}),jsxRuntime.jsxs("td",{className:ui.cn("py-2 pr-3 text-right font-mono whitespace-nowrap",a),children:[i,"$",Math.abs(r).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",i,o.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right text-neutral whitespace-nowrap",children:p}),jsxRuntime.jsx("td",{className:"py-2 text-right whitespace-nowrap",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:t("predict.positions.close")})})]})}function Rs({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useOrders({source:e,wallet_address:t}),i=reactPredict.useCancelOrder(),c=react.useMemo(()=>{if(!s?.items)return [];let d=new Set(["live","open","submitted","pending"]),u=s.items.filter(p=>d.has(p.status));return r.length>0&&(u=u.filter(p=>p.market_id&&r.includes(p.market_id))),u},[s?.items,r]),l=d=>{o?o(d.id):i.mutate({source:d.source,id:d.id});};return a?jsxRuntime.jsx(wt,{rows:3}):c.length===0?jsxRuntime.jsx(Nt,{message:n("predict.openOrders.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.type")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.openOrders.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.openOrders.filled")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.status")}),jsxRuntime.jsx("th",{className:"py-2 font-normal"})]})}),jsxRuntime.jsx("tbody",{children:c.map(d=>jsxRuntime.jsx(Os,{order:d,onCancel:()=>l(d),isCancelling:i.isPending},d.id))})]})})}function Os({order:e,onCancel:t,isCancelling:r}){let{t:o}=i18n.useTranslation(),n=e.side==="BUY";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",n?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-neutral capitalize",children:e.order_type??"limit"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.price?Qe(parseFloat(e.price)):"\u2014"}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:[e.size_matched??"0","/",e.original_size??"\u2014"]}),jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx(Is,{status:e.status})}),jsxRuntime.jsx("td",{className:"py-2 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:r,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:r?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):o("predict.openOrders.cancel")})})]})}function Is({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function _s({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:o,isLoading:n}=reactPredict.useTrades({source:e,wallet:t,limit:50}),s=o?.items??[];return n?jsxRuntime.jsx(wt,{rows:3}):s.length===0?jsxRuntime.jsx(Nt,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right",children:r("predict.tradeHistory.time")})]})}),jsxRuntime.jsx("tbody",{children:s.map(a=>jsxRuntime.jsx(As,{trade:a},a.id))})]})})}function As({trade:e}){let t=e.side?.toUpperCase()==="BUY",r=Ds(e.timestamp),o=e.price??0,n=e.usd_size??0;return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:Qe(o)}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.size}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:["$",n.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 text-right text-neutral whitespace-nowrap",children:r})]})}function Nt({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:e})}function wt({rows:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},r))})}function Qe(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Ds(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${s}`}function Hs(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function Oe({marketCount:e=4}){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-14 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-32 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-full max-w-md rounded"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-48 w-full rounded-xl"}),Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-12 w-full rounded-md"},r))]})}function Ar(){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-24 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"})]})}var Br="var(--color-bullish)",Fr="var(--color-bearish)";function Ie(e){if(Math.abs(e)>=1e4){let t=e/1e4;return `${parseFloat(t.toFixed(2))}\u4E07`}return e.toLocaleString()}function Us(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Ws(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let m of e){let g=Math.round(m.price*100);g>=0&&g<=100&&(r[g]+=m.quantity);}for(let m of t){let g=Math.round(m.price*100);g>=0&&g<=100&&(o[g]+=m.quantity);}let n=0,s=0,a=new Float64Array(101),i=new Float64Array(101);for(let m=100;m>=0;m--)n+=r[m],s+=r[m]*m/100,a[m]=n,i[m]=s;let c=0,l=0,d=new Float64Array(101),u=new Float64Array(101);for(let m=0;m<=100;m++)c+=o[m],l+=o[m]*m/100,d[m]=c,u[m]=l;let p=Math.max(a[0]??0,d[100]??0);return Array.from({length:101},(m,g)=>{let f=a[g]>0,h=d[g]>0,v=a[g]||d[g],O=r[g]>0||o[g]>0;return {priceCents:g,displayHeight:Us(v,p),opacity:v>0?O?1:.5:0,isBid:f,isAsk:h,bidCumTotal:a[g],askCumTotal:d[g],bidCumCost:i[g],askCumCost:u[g]}})}function $s({info:e}){let t=e.isBid?Br:Fr,r=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:r,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsxs("div",{style:{marginBottom:4,fontWeight:600},children:[e.priceCents,"\xA2"]}),jsxRuntime.jsxs("div",{style:{color:t},children:[Ie(Math.round(e.cumTotal))," contracts"]}),jsxRuntime.jsxs("div",{style:{color:t},children:["$",Ie(Math.round(e.cumCost))]})]})}var zs=react.memo(function({slot:t,onEnter:r,onLeave:o}){let n=react.useRef(null),s=t.isBid||t.isAsk,a=t.isBid?Br:t.isAsk?Fr:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:s?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:s&&jsxRuntime.jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),Ks=[0,10,20,30,40,50,60,70,80,90,100];function Vs(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:Ks.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Ur({bids:e,asks:t}){let r=react.useMemo(()=>Ws(e,t),[e,t]),o=react.useMemo(()=>{let d=e.length>0?Math.max(...e.map(p=>p.price)):0,u=t.length>0?Math.min(...t.map(p=>p.price)):1;return Math.round((d+u)/2*100)},[e,t]),n=react.useMemo(()=>r.some(d=>d.isBid||d.isAsk),[r]),[s,a]=react.useState(null),i=react.useRef(null),c=react.useCallback((d,u)=>{i.current&&(i.current.style.filter=""),u?(u.style.filter="brightness(1.5)",i.current=u):i.current=null,d.isBid||d.isAsk?a({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):a(null);},[]),l=react.useCallback(()=>{i.current&&(i.current.style.filter="",i.current=null),a(null);},[]);return n?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsxRuntime.jsx($s,{info:s}),r.map(d=>jsxRuntime.jsx(zs,{slot:d,onEnter:c,onLeave:l},d.priceCents))]}),jsxRuntime.jsx(Vs,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No depth data"})}function $r(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function zr(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})]})}function jr({market:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState("depth"),[s,a]=react.useState(reactPredict.ChartRange.ONE_WEEK),i=e.source,{data:c,isLoading:l}=reactPredict.useOrderbook({slug:e.slug,source:i}),{series:d,isLoading:u}=reactPredict.useMarketHistory(o==="chart"?[e]:[],s),p=react.useMemo(()=>(c?.bids??[]).map(v=>({price:v.price,quantity:v.size})),[c?.bids]),m=react.useMemo(()=>(c?.asks??[]).map(v=>({price:v.price,quantity:v.size})),[c?.asks]),g=react.useMemo(()=>p.length>0?Math.max(...p.map(v=>v.price)):null,[p]),f=react.useMemo(()=>m.length>0?Math.min(...m.map(v=>v.price)):null,[m]),h=react.useMemo(()=>{if(g==null||f==null)return null;let v=(f-g)*100;return Math.round(v*10)/10},[g,f]);return jsxRuntime.jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border px-1 py-2 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:h!=null?`${r("predict.orderBook.spread")}: ${Number.isInteger(h)?`${h}\xA2`:`${h.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[g!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[r("predict.trade.bestBid"),": ",$r(g)]}),g!=null&&f!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),f!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[r("predict.trade.bestAsk"),": ",$r(f)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 justify-end gap-x-0.5",children:[jsxRuntime.jsx("button",{type:"button",title:"Depth chart",onClick:()=>n("depth"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="depth"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Orderbook",onClick:()=>n("table"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="table"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Price chart",onClick:()=>n("chart"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="chart"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookChartIcon,{className:"h-4 w-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[o==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?jsxRuntime.jsx(zr,{}):jsxRuntime.jsx(Ur,{bids:p,asks:m})}),o==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?jsxRuntime.jsx(zr,{}):jsxRuntime.jsx(oa,{bids:p,asks:m,bestBid:g??void 0,bestAsk:f??void 0,spread:h??void 0})}),o==="chart"&&jsxRuntime.jsx(aa,{series:d,isLoading:u,chartRange:s,onRangeChange:a})]})]})}var Kr=8;function oa({bids:e,asks:t,spread:r}){let{t:o}=i18n.useTranslation(),n=react.useMemo(()=>[...t].sort((c,l)=>l.price-c.price).slice(0,Kr),[t]),s=react.useMemo(()=>[...e].sort((c,l)=>l.price-c.price).slice(0,Kr),[e]),a=react.useMemo(()=>{let c=[...n,...s].map(l=>l.quantity);return Math.max(...c,1)},[n,s]);return n.length===0&&s.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(c=>jsxRuntime.jsx(Vr,{price:c.price,quantity:c.quantity,side:"ask",maxQty:a},`ask-${c.price}`)),jsxRuntime.jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),s.map(c=>jsxRuntime.jsx(Vr,{price:c.price,quantity:c.quantity,side:"bid",maxQty:a},`bid-${c.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Vr({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",s=Math.min(t/o*100,100),a=n?"bg-bullish/10":"bg-bearish/10",i=n?"text-bullish":"text-bearish",c=Math.round(e*100),l=Ie(Math.round(t)),d=Math.round(t*e),u=`$${Ie(d)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 ${i}`,children:[c,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:l}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var sa=[{value:reactPredict.ChartRange.ONE_DAY,label:"1D"},{value:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{value:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{value:reactPredict.ChartRange.ALL,label:"ALL"}];function aa({series:e,isLoading:t,chartRange:r,onRangeChange:o}){let n=react.useMemo(()=>!e.length||!e[0].data.length?[]:e[0].data.map(s=>({ts:s.timestamp,price:Math.round(s.price*100)})),[e]);return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-[200px]",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})}):n.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-[200px] text-xs text-neutral",children:"No price history"}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:180,children:jsxRuntime.jsxs(recharts.LineChart,{data:n,margin:{top:4,right:4,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.4}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"ts",hide:true}),jsxRuntime.jsx(recharts.YAxis,{domain:["auto","auto"],tickFormatter:s=>`${s}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:10},width:32}),jsxRuntime.jsx(recharts.Tooltip,{formatter:s=>[`${s??0}\xA2`,"Price"],contentStyle:{background:"rgba(17,24,39,0.95)",border:"1px solid #374151",borderRadius:8,fontSize:12},isAnimationActive:false}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"price",stroke:"hsl(var(--heroui-primary))",strokeWidth:2,dot:false,isAnimationActive:false})]})}),jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-1",children:sa.map(s=>jsxRuntime.jsx("button",{type:"button",onClick:()=>o(s.value),className:ui.cn("px-2 py-0.5 rounded text-xs font-medium transition-colors cursor-pointer",r===s.value?"bg-content2 text-foreground":"text-neutral hover:text-foreground"),children:s.label},s.value))})]})}var Lt=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},tt=4,Gr=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Xr(e,t){let r=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Qr(e){return `${(e*100).toFixed(2)}%`}var ha=[{range:reactPredict.ChartRange.ONE_DAY,label:"1D"},{range:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{range:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{range:reactPredict.ChartRange.ALL,label:"ALL"}];function ba({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:ha.map(({range:r,label:o})=>{let n=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function ya({dots:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.map(({cx:t,cy:r,color:o},n)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:o,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3.5,fill:o})]},n))})}function Sa(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(n=>{let s=e.current,a=t.current;if(!s||!a)return;let i=s.getBoundingClientRect(),c=(n.clientX-i.left)/i.width*100;a.style.background=`linear-gradient(to right, transparent ${c}%, rgba(0,0,0,0.38) ${c}%)`,a.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function ka({active:e,payload:t,label:r,labelMap:o}){if(!e||!t?.length)return null;let n=[...t].filter(s=>s.value!=null).sort((s,a)=>(a.value??0)-(s.value??0));return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?Xr(r):r}),n.map(s=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:s.stroke??s.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(s.dataKey)??s.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:s.value!=null?Qr(s.value):"-"})]},s.dataKey))]})}function Pa({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,s]=react.useState(false),a=react.useRef(null);react.useEffect(()=>{if(!n)return;function l(d){a.current&&!a.current.contains(d.target)&&s(false);}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]);let i=t.length>=tt,c=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(l=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(l)??"#6b7280",display:"inline-block"}},l))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?e.find(l=>l.slug===t[0])?.question??"1 market":`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",maxWidth:320},children:[jsxRuntime.jsxs("button",{onClick:()=>s(l=>!l),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",minWidth:160,maxWidth:320,userSelect:"none"},children:[c,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",tt," markets"]}),e.map(l=>{let d=t.includes(l.slug),u=!d&&i,p=d&&t.length===1,m=r.get(l.slug)??"#6b7280",g=l.outcomes.find(h=>h.label.toLowerCase()==="yes")??l.outcomes[0],f=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{p||u||o(l.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:u||p?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!u&&!p&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:d?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.outcomes?.[0]?.label??l.question}),f&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:f})]},l.slug)})]})]})}function Ea({series:e,colorMap:t,displayValues:r}){let o=[...e].sort((n,s)=>(r.get(s.marketSlug)??0)-(r.get(n.marketSlug)??0));return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:o.map(n=>{let s=t.get(n.marketSlug)??"#6b7280",a=r.get(n.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:s,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:n.label}),a!=null&&jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:Qr(a)})]})]},n.marketSlug)})})}function Na(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function wa(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let s=Math.floor(n*o),a=Math.min(Math.floor((n+1)*o),e.length),i=e.slice(s,a),c=i.map(l=>l.price).sort((l,d)=>l-d);r.push({timestamp:i[i.length-1].timestamp,price:Na(c)});}return r}function Ca(e,t=200){if(e.length===0)return [];let r=e.map(i=>({...i,data:wa(i.data,t)})),o=new Set;r.forEach(i=>i.data.forEach(c=>o.add(c.timestamp)));let n=Array.from(o).sort((i,c)=>i-c),s=r.map(i=>{let c=new Map;return i.data.forEach(l=>c.set(l.timestamp,l.price)),{slug:i.marketSlug,map:c}}),a=new Map;return n.map(i=>{let c={timestamp:i};return s.forEach(({slug:l,map:d})=>{let u=d.get(i);if(u!==void 0)a.set(l,u),c[l]=u;else {let p=a.get(l);p!==void 0&&(c[l]=p);}}),c})}function Zr(e){return jsxRuntime.jsx(Lt,{children:jsxRuntime.jsx(Ma,{...e})})}function Ma({event:e,isLoading:t,className:r,volume:o}){let n=react.useMemo(()=>e.markets??[],[e.markets]),s=react.useMemo(()=>[...n].sort((y,P)=>{let C=z=>(z.outcomes.find(K=>K.label.toLowerCase()==="yes")??z.outcomes[0])?.price??0;return C(P)-C(y)}),[n]),[a,i]=react.useState(()=>s.slice(0,tt).map(y=>y.slug)),[c,l]=react.useState(Ve),d=react.useMemo(()=>{let y=new Map;return s.forEach((P,C)=>{y.set(P.slug,Gr[C%Gr.length]);}),y},[n]),u=react.useMemo(()=>n.filter(y=>a.includes(y.slug)),[n,a]),{series:p,isLoading:m}=reactPredict.useMarketHistory(u,c),g=t||m,f=react.useMemo(()=>{if(p.length>0&&p.some(C=>C.data.length>0))return p;let y=Date.now(),P=864e5;return u.map(C=>{let K=(C.outcomes?.find(V=>V.label.toLowerCase()==="yes")??C.outcomes?.[0])?.price??.5;return {marketSlug:C.slug,label:C.outcomes?.[0]?.label??C.question,data:[{timestamp:y-7*P,price:K},{timestamp:y,price:K}]}})},[p,u]),h=react.useMemo(()=>c===reactPredict.ChartRange.ONE_DAY?96:c===reactPredict.ChartRange.ONE_WEEK?168:c===reactPredict.ChartRange.ONE_MONTH?180:300,[c]),v=react.useMemo(()=>Ca(f,h),[f,h]),O=react.useMemo(()=>{if(v.length===0)return [0,1];let y=1/0,P=-1/0;if(a.forEach(z=>{v.forEach(K=>{let V=K[z];V!=null&&(V<y&&(y=V),V>P&&(P=V));});}),!isFinite(y))return [0,1];let C=Math.max((P-y)*.15,.05);return [Math.max(0,y-C),Math.min(1,P+C)]},[v,a]),R=react.useMemo(()=>{let y=new Map;return f.forEach(P=>{P.data.length>0&&y.set(P.marketSlug,P.data[P.data.length-1].price);}),y},[f]),N=react.useMemo(()=>{let y=new Map;return f.forEach(P=>y.set(P.marketSlug,P.label)),y},[f]),{wrapperRef:A,overlayRef:q,onMouseMove:Q,onMouseLeave:Pe}=Sa(),Ee=react.useCallback(y=>{i(P=>P.includes(y)?P.length<=1?P:P.filter(C=>C!==y):P.length>=tt?P:[...P,y]);},[]),[pe,w]=react.useState(null),X=react.useCallback(y=>{let P=y?.activePayload;if(!P?.length){w(null);return}let C=new Map;P.forEach(z=>{z.value!=null&&C.set(z.dataKey,z.value);}),w(C);},[]),ee=react.useCallback(()=>{w(null);},[]);return g?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):v.length===0?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsx(Ea,{series:f,colorMap:d,displayValues:pe??R}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsxs("div",{ref:A,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:Q,onMouseLeave:Pe,children:[jsxRuntime.jsx("div",{ref:q,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:v,margin:{top:8,right:16,left:0,bottom:0},onMouseMove:X,onMouseLeave:ee,children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:y=>Xr(y,c),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:O,tickFormatter:y=>`${Math.round(y*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:y=>jsxRuntime.jsx(ka,{...y,labelMap:N}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},isAnimationActive:false}),f.map(y=>{let P=d.get(y.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:y.marketSlug,stroke:P,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:P},connectNulls:true,isAnimationActive:false},y.marketSlug)}),jsxRuntime.jsx(recharts.Customized,{component:y=>{let P=y.xAxisMap?Object.values(y.xAxisMap)[0]?.scale:null,C=y.yAxisMap?Object.values(y.yAxisMap)[0]?.scale:null,z=[];if(P&&C&&v.length>0){let K=v[v.length-1];f.forEach(V=>{let me=K[V.marketSlug];if(me==null)return;let ce=P(K.timestamp),Ne=C(me);ce==null||Ne==null||z.push({cx:ce,cy:Ne,color:d.get(V.marketSlug)??"#6b7280"});});}return jsxRuntime.jsx(ya,{dots:z})}})]})})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[s.length>1&&jsxRuntime.jsx(Pa,{markets:s,selectedSlugs:a,colorMap:d,onToggle:Ee}),o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{flex:1,color:"#6b7280",fontSize:12,textAlign:"center"},children:["$",Math.round(o).toLocaleString()," vol"]}),jsxRuntime.jsx(ba,{value:c,onChange:l})]})]})]})}function Rt(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function _a(e){return `${Math.round(e*100)}%`}function Jr(e){let t=e*100;return t<1&&t>0?"< 1":Number.isInteger(t)?`${t}`:t.toFixed(1)}function en(e){return e.outcomes?.[0]?.label??e.question}function an(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function tn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),s=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${s}:${a}`}function rn(e){let[t,r]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let s=Math.floor(n/864e5),a=Math.floor(n%864e5/36e5),i=Math.floor(n%36e5/6e4),c=Math.floor(n%6e4/1e3),l=[];return s>0&&l.push(`${s}d`),l.push(`${String(a).padStart(2,"0")}h`),l.push(`${String(i).padStart(2,"0")}m`),l.push(`${String(c).padStart(2,"0")}s`),l.join(" ")}function nn(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),i=-t.getTimezoneOffset(),c=i>=0?"+":"-",l=String(Math.abs(Math.floor(i/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${a} (${c}${l})`}function ln({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:o,isCollapsed:n}=hooks.useScrollCollapse(),s=react.useMemo(()=>[...e.markets||[]].sort((d,u)=>Rt(u)-Rt(d)),[e.markets]),a=rn(e.start_at),i=rn(e.end_at),c=nn(e.start_at),l=nn(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center h-12 backdrop-blur-md transition-all duration-300 ${n?"gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:`flex-shrink-0 transition-all duration-300 ${n?"!h-8 !w-8 lg:!h-10 lg:!w-10":"!h-14 !w-14 lg:!h-18 lg:!w-18"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(Ba,{source:e.source}),e.tags?.slice(0,3).map(d=>jsxRuntime.jsx("span",{className:"text-xs text-neutral truncate",children:d.label},d.slug))]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||i)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs text-neutral lg:text-sm font-mono",children:a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.beginsIn",{time:a})}),c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:c})]})]}):i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.endsIn",{time:i})}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:l})]})]}):null}),jsxRuntime.jsx(Zr,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(Aa,{markets:s,onTradeAction:t}),jsxRuntime.jsx(Ha,{markets:s,event:e})]})}var on=5;function Aa({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(null);if(e.length===0)return null;let i=e.length>on,c=o?e:e.slice(0,on),l=d=>{a(u=>u===d?null:d);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:c.map((d,u)=>{let p=Rt(d),m=d.outcomes[1]?.best_ask??d.outcomes[1]?.price,g=u===0,f=s===d.slug;return jsxRuntime.jsx(Da,{market:d,yesPrice:p,noPrice:m??void 0,isTopMarket:g,isExpanded:f,onToggleExpand:()=>l(d.slug),onTradeAction:t},d.slug)})})]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx("svg",{className:ui.cn("h-4 w-4 transition-transform",o&&"rotate-180"),viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}function Da({market:e,yesPrice:t,noPrice:r,isTopMarket:o,isExpanded:n,onToggleExpand:s,onTradeAction:a}){let{t:i}=i18n.useTranslation(),c=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:en(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:en(e)}),c&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:c})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:_a(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-opacity",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:l=>{l.stopPropagation(),a?.(e,"yes","buy");},children:i("predict.market.action.yes",{price:Jr(t)})}),jsxRuntime.jsx("button",{type:"button",className:"flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 bg-secondary/10 text-secondary cursor-pointer hover:opacity-80 transition-opacity",onClick:l=>{l.stopPropagation(),a?.(e,"no","buy");},children:r!=null?i("predict.market.action.no",{price:Jr(r)}):i("predict.market.no")})]})})]}),n&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"px-2 pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(jr,{market:e,onTradeAction:a})})})})]})}function Ha({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(false),i=e.filter(u=>u.rules&&u.rules.length>0);if(i.length===0)return null;let c=i[0];if(!c?.rules?.length)return null;let l=c.rules.join(`
21
20
 
22
- `),u=c.length>200&&!i?c.slice(0,200)+"...":c;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),a.length>1&&jsxRuntime.jsx("div",{className:"flex gap-x-2 overflow-x-auto",children:a.map(p=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{s(p.slug),o(false);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs transition-colors cursor-pointer",l.slug===p.slug?"bg-content2 text-foreground":"text-neutral hover:bg-content2"),children:_n(p)},p.slug))}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:u}),c.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>o(p=>!p),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(i?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral mt-2 lg:text-sm",children:"Timeline"}),jsxRuntime.jsx("div",{className:"flex flex-col",children:[{label:"Market Open",value:Qi(l.start_at),isActive:true},{label:"Market Closes",value:Qi(l.end_at),isActive:l.status==="closed"||l.status==="voided"}].map((p,d,m)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${p.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),d<m.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${d<m.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:p.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:p.value})]})]},p.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-neutral",children:"Event:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-neutral",children:"Market:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:l.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-neutral",children:"Source:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:Ai(l.source)})]})]})]})}function ey({source:e}){return jsxRuntime.jsxs("span",{className:ui.cn("inline-flex items-center gap-x-1 rounded px-1.5 py-0.5","text-[10px] font-medium leading-none",e==="polymarket"?"bg-blue-500/15 text-blue-400":"bg-primary-500/15 text-primary"),children:[jsxRuntime.jsx("span",{className:ui.cn("h-1.5 w-1.5 rounded-sm",e==="polymarket"?"bg-blue-400":"bg-primary")}),Ai(e)]})}function Fn({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:s,error:i}=dt({slug:e,source:t});return s?jsxRuntime.jsx(Re,{}):i||!n?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsxRuntime.jsx(Wi,{event:n,onTradeAction:r})}function qi(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function oE({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:s}){let{t:i}=i18n.useTranslation(),{isMobile:o}=ui.useScreen(),{isOpen:a,onOpen:l,onClose:c}=ui.useDisclosure(),{data:u,isLoading:p}=dt({slug:e,source:t}),d=react.useMemo(()=>[...u?.markets||[]].sort((b,h)=>qi(h)-qi(b)),[u?.markets]),[m,y]=react.useState(null),f=react.useCallback((b,h,v)=>{y(w=>({market:b,outcome:h,side:v,version:(w?.version??0)+1})),o&&l();},[o,l]),g=m?.market??d[0];if(p)return o?jsxRuntime.jsx(Re,{}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Re,{})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(vr,{})})})]});let x=m?`${m.market.slug}-${m.version}`:g?.slug??"default";return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"w-full pb-20",children:[jsxRuntime.jsx(Fn,{eventSlug:e,source:t,onTradeAction:f}),u&&jsxRuntime.jsx(Nn,{event:u,walletAddress:n}),u&&jsxRuntime.jsx(Hi,{eventSlug:e,source:u.source,onEventClick:s})]}),g&&jsxRuntime.jsx("div",{className:"fixed inset-x-0 bottom-0 z-40 flex justify-center p-3 bg-gradient-to-t from-background via-background/90 to-transparent",children:jsxRuntime.jsx(ui.Button,{color:"primary",size:"lg",className:"w-full max-w-md font-semibold",onPress:l,children:i("predict.trade.action")})}),jsxRuntime.jsx(ui.Drawer,{isOpen:a,onClose:c,placement:"bottom",size:"lg",hideCloseButton:true,classNames:{base:"max-h-[85dvh] rounded-t-2xl",body:"p-0"},children:jsxRuntime.jsx(ui.DrawerContent,{children:jsxRuntime.jsx(ui.DrawerBody,{children:g&&jsxRuntime.jsx(Tn,{event:u,market:g,initialSide:m?.side,initialOutcome:m?.outcome,chain:r},x)})})})]}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1 max-w-3xl",children:[jsxRuntime.jsx(Fn,{eventSlug:e,source:t,onTradeAction:f}),u&&jsxRuntime.jsx(Nn,{event:u,walletAddress:n})]}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsxs("div",{className:"sticky top-4 flex flex-col gap-y-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:[g&&jsxRuntime.jsx(Tn,{event:u,market:g,initialSide:m?.side,initialOutcome:m?.outcome,chain:r},x),u&&jsxRuntime.jsx(Hi,{eventSlug:e,source:u.source,onEventClick:s})]})})]})}function Hi({eventSlug:e,source:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:i}=es({slug:e,source:t,limit:4});return i||!s||s.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:s.map(o=>jsxRuntime.jsx(dy,{event:o,onClick:r},o.slug))})]})}function dy({event:e,onClick:t}){let r=e.markets?.[0]?.outcomes[0]?.price;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-10 shrink-0",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:[Math.round(r*100),"% chance"]})]})]})}function $i(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function fy(e){if(!e)return 0;let t=new Date(e).getTime();return Number.isFinite(t)?Math.floor(t/1e3):0}var fE=e=>{let{candlestickMarketSlugs:t,chartRange:r=ke,source:n}=e,s=lt[r],i=ct[r],o=react.useMemo(()=>Math.floor(Date.now()/1e3),[r]),a=P(),{data:l,isLoading:c,error:u}=dt({slug:e.eventSlug,source:n}),p=react.useMemo(()=>{if(i!=null)return o-i;let x=l?.markets;return x?.length?Math.min(...x.map(b=>fy(b.start_at))):o},[o,i,l?.markets]),d=react.useMemo(()=>l?.markets?(t&&t.length>0?t.slice(0,4).map(b=>l.markets.find(h=>h.slug===b)).filter(b=>b!==void 0):[...l.markets].sort((b,h)=>$i(h)-$i(b)).slice(0,4)).map(b=>b.slug):[],[t,l?.markets]),m=reactQuery.useQueries({queries:d.map(x=>({queryKey:Nt({ticker:x,startTs:p,endTs:o,periodInterval:s}),queryFn:()=>Rt(a,{ticker:x,startTs:p,endTs:o,periodInterval:s}),enabled:d.length>0}))}),y=m.some(x=>x.isLoading),f=react.useMemo(()=>{let x=new Map;return d.forEach((b,h)=>{let v=m[h]?.error;v&&x.set(b,v);}),x},[d,m]),g=react.useMemo(()=>{let x=new Map;return d.forEach((b,h)=>{let v=m[h]?.data;v&&x.set(b,v);}),x},[d,m]);return {event:l,isEventLoading:c,eventError:u,periodInterval:s,candlesticks:g,isCandlesticksLoading:y,candlestickErrors:f}};function zi(e,t){if(!e)return [];let r=e.slice(0,t),n=0,s=r.map(o=>(n+=o.quantity,{...o,cumulative:n,depth:0})),i=s[s.length-1]?.cumulative??1;for(let o of s)o.depth=o.cumulative/i;return s}function Yi({marketTicker:e,maxLevels:t=10,refetchInterval:r=5e3,outcome:n="yes"}){let{data:s,isLoading:i,isFetching:o}=mt(e,{refetchInterval:r||void 0}),a=react.useMemo(()=>n==="yes"?s?.yesBids:s?.noBids,[s,n]),l=react.useMemo(()=>n==="yes"?s?.yesAsks:s?.noAsks,[s,n]),c=react.useMemo(()=>zi(a,t),[a,t]),u=react.useMemo(()=>zi(l,t),[l,t]),p=react.useMemo(()=>c.length===0||u.length===0?null:u[0].price-c[0].price,[c,u]),d=react.useMemo(()=>c.length===0||u.length===0?null:(c[0].price+u[0].price)/2,[c,u]),m=react.useMemo(()=>p===null||d===null||d===0?null:Math.round(p/d*1e4)/100,[p,d]);return {bids:c,asks:u,spread:p,spreadPercent:m,midpoint:d,isLoading:i,isFetching:o}}function Gi({row:e,side:t,onClick:r}){let n=t==="bid",s=n?"bg-primary/10":"bg-danger/10",i=n?"text-primary":"text-danger";return jsxRuntime.jsxs("button",{type:"button",className:"relative flex w-full items-center justify-between px-3 py-1 text-xs hover:bg-default-100 cursor-pointer",onClick:()=>r?.(e.price),children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 ${n?"right-0":"left-0"} ${s}`,style:{width:`${e.depth*100}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 font-medium ${i}`,children:[e.price,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-default-600",children:e.quantity}),jsxRuntime.jsx("span",{className:"relative z-10 text-default-400",children:e.cumulative})]})}function ji(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-1 py-2",children:Array.from({length:5}).map((e,t)=>jsxRuntime.jsx("div",{className:"mx-3 h-4 animate-pulse rounded bg-default-100"},t))})}function Xi({bids:e,asks:t,spread:r,spreadPercent:n,isLoading:s,onPriceClick:i}){let{t:o}=i18n.useTranslation();if(s)return jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:o("predict.orderBook.title")}),jsxRuntime.jsx(ji,{}),jsxRuntime.jsx(ji,{})]});let a=e.length===0&&t.length===0;return jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-default-200 px-3 py-2",children:jsxRuntime.jsx("span",{className:"text-sm font-medium",children:o("predict.orderBook.title")})}),a?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-3 py-1 text-xxs text-default-400",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{children:o("predict.orderBook.qty")}),jsxRuntime.jsx("span",{children:o("predict.orderBook.total")})]}),jsxRuntime.jsx("div",{className:"flex flex-col-reverse",children:t.map(l=>jsxRuntime.jsx(Gi,{row:l,side:"ask",onClick:i},l.price))}),r!==null&&jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 border-y border-default-200 py-1.5 text-xs text-default-500",children:[jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),": ",r,"\xA2"]}),n!==null&&jsxRuntime.jsxs("span",{className:"text-default-400",children:["(",n,"%)"]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(l=>jsxRuntime.jsx(Gi,{row:l,side:"bid",onClick:i},l.price))})]})]})}function HE({marketTicker:e,maxLevels:t,refetchInterval:r,onPriceClick:n,outcome:s}){let{bids:i,asks:o,spread:a,spreadPercent:l,isLoading:c}=Yi({marketTicker:e,maxLevels:t,refetchInterval:r,outcome:s});return jsxRuntime.jsx(Xi,{bids:i,asks:o,spread:a,spreadPercent:l,isLoading:c,onPriceClick:n})}function Ji(e={}){let[t,r]=react.useState(null),[n]=react.useState(null),s=react.useCallback(i=>{r(null);},[]);return {orders:[],isLoading:false,isFetching:false,cancellingOrderId:t,cancelOrder:s,cancelError:n}}function Ey(e){return new Date(e).toLocaleString("default",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ea({orders:e,isLoading:t,cancellingOrderId:r,onCancel:n}){let{t:s}=i18n.useTranslation(),i=react.useMemo(()=>e.map(o=>({key:o.id,side:o.side,outcome:o.outcome,type:o.type,price:o.price,filled:`${o.filledQuantity}/${o.quantity}`,status:o.status,createdAt:Ey(o.createdAt),isCancelling:o.id===r,id:o.id})),[e,r]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:s("predict.openOrders.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((o,a)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},a))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsxs("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:[s("predict.openOrders.title"),e.length>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-default-400",children:["(",e.length,")"]})]}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:s("predict.openOrders.empty")}):jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(ui.StyledTable,{radius:"none","aria-label":"Open orders",className:"min-w-[600px]",children:[jsxRuntime.jsxs(ui.TableHeader,{children:[jsxRuntime.jsx(ui.TableColumn,{textValue:"Side",width:60,children:s("predict.openOrders.side")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Outcome",width:60,children:s("predict.openOrders.outcome")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Type",width:60,children:s("predict.openOrders.type")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Price",width:60,children:s("predict.openOrders.price")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Filled",width:80,children:s("predict.openOrders.filled")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Status",width:70,children:s("predict.openOrders.status")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Time",width:120,children:s("predict.openOrders.time")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Action",width:80,align:"end",children:" "})]}),jsxRuntime.jsx(ui.TableBody,{children:i.map(o=>jsxRuntime.jsxs(ui.TableRow,{children:[jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${o.side==="buy"?"text-primary":"text-danger"}`,children:o.side==="buy"?s("predict.trade.buy"):s("predict.trade.sell")})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs ${o.outcome==="yes"?"text-primary":"text-secondary"}`,children:o.outcome==="yes"?s("predict.trade.yes"):s("predict.trade.no")})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs capitalize",children:o.type})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.price,"\xA2"]})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:o.filled})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs capitalize",children:o.status})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:o.createdAt})}),jsxRuntime.jsx(ui.TableCell,{className:"text-right",children:jsxRuntime.jsx(ui.Button,{size:"sm",variant:"flat",color:"danger",isLoading:o.isCancelling,onPress:()=>n(o.id),children:s("predict.openOrders.cancel")})})]},o.key))})]})})]})}function iT({refetchInterval:e}={}){let{orders:t,isLoading:r,cancellingOrderId:n,cancelOrder:s}=Ji({});return jsxRuntime.jsx(ea,{orders:t,isLoading:r,cancellingOrderId:n,onCancel:s})}function ra({ticker:e,pageSize:t=48}={}){let[r,n]=react.useState(1),[s,i]=react.useState([void 0]),o=s[r-1],a=react.useMemo(()=>({...e?{ticker:e}:{},limit:t,...o?{cursor:o}:{}}),[e,t,o]),{data:l,isLoading:c,isFetching:u}=fs(a),p=l,d=p?.trades??[],m=!!p?.cursor,y=r>1,f=react.useCallback(b=>{b>=1&&b<=s.length&&n(b);},[s.length]),g=react.useCallback(()=>{m&&p?.cursor&&(i(b=>{let h=[...b];return h.length===r&&h.push(p.cursor),h}),n(b=>b+1));},[m,p?.cursor,r]),x=react.useCallback(()=>{y&&n(b=>b-1);},[y]);return {trades:d,isLoading:c,isFetching:u,page:r,pageSize:t,hasNextPage:m,hasPrevPage:y,goToPage:f,nextPage:g,prevPage:x}}function Uy(e){return new Date(e*1e3).toLocaleString("default",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function sa({trades:e,isLoading:t,isFetching:r,page:n,hasNextPage:s,hasPrevPage:i,onNextPage:o,onPrevPage:a}){let{t:l}=i18n.useTranslation(),c=react.useMemo(()=>e.map(u=>({key:u.tradeId,ticker:u.ticker,takerSide:u.takerSide,price:u.price,yesPrice:u.yesPrice,noPrice:u.noPrice,count:u.count,createdAt:Uy(u.createdTime)})),[e]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:l("predict.tradeHistory.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((u,p)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},p))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:l("predict.tradeHistory.title")}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:l("predict.tradeHistory.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:`w-full overflow-x-auto ${r?"opacity-60":""}`,children:jsxRuntime.jsxs(ui.StyledTable,{radius:"none","aria-label":"Trade history",className:"min-w-[480px]",children:[jsxRuntime.jsxs(ui.TableHeader,{children:[jsxRuntime.jsx(ui.TableColumn,{textValue:"Side",width:60,children:l("predict.tradeHistory.side")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Price",width:80,children:l("predict.tradeHistory.price")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Yes",width:60,children:l("predict.trade.yes")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"No",width:60,children:l("predict.trade.no")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Qty",width:60,children:l("predict.tradeHistory.qty")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Time",width:120,children:l("predict.tradeHistory.time")})]}),jsxRuntime.jsx(ui.TableBody,{children:c.map(u=>jsxRuntime.jsxs(ui.TableRow,{children:[jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${u.takerSide==="yes"?"text-primary":"text-secondary"}`,children:u.takerSide==="yes"?l("predict.trade.yes"):l("predict.trade.no")})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[u.price,"\xA2"]})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs text-primary",children:[u.yesPrice,"\xA2"]})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs text-secondary",children:[u.noPrice,"\xA2"]})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:u.count})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:u.createdAt})})]},u.key))})]})}),(i||s)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-default-200 px-3 py-2",children:[jsxRuntime.jsx(ui.Button,{size:"sm",variant:"flat",isDisabled:!i,onPress:a,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-3 w-3"}),children:l("predict.pagination.prev")}),jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:l("predict.pagination.page",{page:n})}),jsxRuntime.jsx(ui.Button,{size:"sm",variant:"flat",isDisabled:!s,onPress:o,endContent:jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-3 w-3"}),children:l("predict.pagination.next")})]})]})]})}function CT({ticker:e,pageSize:t}={}){let{trades:r,isLoading:n,isFetching:s,page:i,hasNextPage:o,hasPrevPage:a,nextPage:l,prevPage:c}=ra({ticker:e,pageSize:t});return jsxRuntime.jsx(sa,{trades:r,isLoading:n,isFetching:s,page:i,hasNextPage:o,hasPrevPage:a,onNextPage:l,onPrevPage:c})}function oa(e={}){let t=react.useMemo(()=>({totalValue:0,totalUnrealizedPnl:0,totalRealizedPnl:0,count:0}),[]);return {positions:[],isLoading:false,isFetching:false,summary:t}}var Tr=e=>utils.formatAmountUSDCompact(e/100);function Wn({value:e}){if(e===0)return jsxRuntime.jsx("span",{className:"text-default-500",children:Tr(0)});let t=e>0;return jsxRuntime.jsxs("span",{className:t?"text-success":"text-danger",children:[t?"+":"",Tr(e)]})}function ia({positions:e,isLoading:t,summary:r,onSell:n}){let{t:s}=i18n.useTranslation(),i=react.useMemo(()=>e.map(o=>({key:`${o.marketId}-${o.outcome}`,marketTitle:o.marketTitle,outcome:o.outcome,quantity:o.quantity,avgCost:o.avgCostBasis,currentPrice:o.currentPrice,value:o.currentPrice*o.quantity,unrealizedPnl:o.unrealizedPnl,position:o})),[e]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:s("predict.positions.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((o,a)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},a))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-default-200 px-3 py-2",children:jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[s("predict.positions.title"),e.length>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-default-400",children:["(",e.length,")"]})]})}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:s("predict.positions.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(ui.StyledTable,{radius:"none","aria-label":"Positions",className:"min-w-[640px]",children:[jsxRuntime.jsxs(ui.TableHeader,{children:[jsxRuntime.jsx(ui.TableColumn,{textValue:"Market",width:200,children:s("predict.positions.market")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Outcome",width:60,children:s("predict.positions.outcome")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Qty",width:50,children:s("predict.positions.qty")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Avg Cost",width:70,children:s("predict.positions.avgCost")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Price",width:60,children:s("predict.positions.currentPrice")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"Value",width:80,children:s("predict.positions.value")}),jsxRuntime.jsx(ui.TableColumn,{textValue:"PnL",width:80,children:s("predict.positions.pnl")})]}),jsxRuntime.jsx(ui.TableBody,{children:i.map(o=>jsxRuntime.jsxs(ui.TableRow,{className:n?"cursor-pointer hover:bg-default-50":"",onClick:()=>n?.(o.position),children:[jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs font-medium line-clamp-1",children:o.marketTitle})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${o.outcome==="yes"?"text-primary":"text-secondary"}`,children:o.outcome==="yes"?s("predict.trade.yes"):s("predict.trade.no")})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:o.quantity})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.avgCost,"\xA2"]})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.currentPrice,"\xA2"]})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:Tr(o.value)})}),jsxRuntime.jsx(ui.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:jsxRuntime.jsx(Wn,{value:o.unrealizedPnl})})})]},o.key))})]})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-default-200 px-3 py-2 text-xs",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-4",children:jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.totalValue"),":"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:Tr(r.totalValue)})]})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-4",children:[jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.unrealizedPnl"),":"," ",jsxRuntime.jsx(Wn,{value:r.totalUnrealizedPnl})]}),jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.realizedPnl"),":"," ",jsxRuntime.jsx(Wn,{value:r.totalRealizedPnl})]})]})]})]})]})}function AT({refetchInterval:e,onSell:t}={}){let{positions:r,isLoading:n,summary:s}=oa({});return jsxRuntime.jsx(ia,{positions:r,isLoading:n,summary:s,onSell:t})}var Zy=10,Jy=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Mr(){let[e,t]=jotai.useAtom(Jy),r=react.useCallback(s=>{let i=s.trim();i&&t(o=>{let a=o.filter(l=>l!==i);return [i,...a].slice(0,Zy)});},[t]),n=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function ua({histories:e,onSelect:t,onClear:r,className:n}){let{t:s}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",n),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:s("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function da({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Mr();return jsxRuntime.jsx(ua,{className:ui.cn(t),histories:r,onSelect:e,onClear:n})}function pa({value:e,onValueChange:t,onClear:r,onEscape:n,className:s}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:s,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:o=>{o.preventDefault(),n?.();},children:"Esc"})})})}function ya({event:e,href:t,LinkComponent:r,onSelect:n,onHover:s,className:i}){let o=e.tags?.[0];return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,className:ui.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:a=>{t&&n&&a.preventDefault(),n?.(e);},onMouseEnter:()=>s?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),o&&jsxRuntime.jsx("span",{className:ui.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:o.label})]})]})}function ga({keyword:e="",limit:t,source:r}){let{data:n,isLoading:s,isFetchingNextPage:i,hasNextPage:o,fetchNextPage:a}=Jn({keyword:e,limit:t,source:r},{enabled:true});return {events:react.useMemo(()=>n?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[n]),isLoading:s,isFetchingNextPage:i,hasNextPage:o??false,fetchNextPage:a}}var kg=56;function ha({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:s,...i}){let{events:o,isLoading:a,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:u}=ga(i),p=react.useRef(null),{height:d}=hooks.useResizeObserver({ref:p}),m=react.useCallback(x=>x<o.length,[o]),y=react.useCallback(async()=>{c&&!l&&await u();},[c,l,u]),f=react.useMemo(()=>c?o.length+1:o.length,[o,c]),g=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:y,rowCount:f,threshold:5});return a?jsxRuntime.jsx(Sg,{className:s}):o.length===0?jsxRuntime.jsx(Cg,{className:s}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",s),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:p,children:jsxRuntime.jsx(reactWindow.List,{style:{height:d},onRowsRendered:g,rowComponent:Pg,rowCount:f,rowHeight:kg,rowProps:{events:o,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function Pg({index:e,style:t,events:r,onSelect:n,getEventHref:s,LinkComponent:i,onHover:o}){let a=r[e];return a?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ya,{event:a,href:s?.(a),LinkComponent:i,onSelect:n,onHover:o})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function Sg({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function Cg({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Ca({onKeywordChange:e}){let[t,r]=react.useState(""),[n,s]=react.useState(""),{addHistory:i}=Mr(),o=hooks.useCallbackRef(e),a=hooks.useCallbackRef(i),l=react.useMemo(()=>utils.debounce(d=>{s(d),o(d),d&&a(d);},500),[o,a]),c=react.useCallback(d=>{r(d),l(d);},[l]),u=react.useCallback(d=>{l.cancel(),r(d),s(d),o(d),d&&a(d);},[l,o,a]),p=react.useCallback(()=>u(""),[u]);return {text:t,keyword:n,setText:c,setKeyword:u,clearKeyword:p}}function wa({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:s,onEscape:i,source:o}){let{text:a,keyword:l,setText:c,setKeyword:u,clearKeyword:p}=Ca({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(pa,{value:a,onValueChange:c,onClear:p,onEscape:i}),!l&&jsxRuntime.jsx(da,{onSelect:u}),jsxRuntime.jsx(ha,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:s,source:o})]})}var zn="predict-search";function jM({id:e=zn}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Ug,{...t})})}function Ug({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:s}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),o=react.useCallback(l=>{n(l);},[n]),a=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:s("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(wa,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:o,onEscape:a})})]})})}function oN({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=i18n.useTranslation(),{isDesktop:s,isMobile:i}=ui.useScreen(),{onOpen:o,onClose:a}=uiScaffold.useAsyncModal(zn),l=hooks.useCallbackRef(e),c=hooks.useCallbackRef(async()=>{let p=await o({params:t});p&&l(p);}),u=hooks.useCallbackRef(()=>{a();});return react.useEffect(()=>{let p=d=>{let m=document.activeElement,y=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");d.key==="/"&&!y&&(d.preventDefault(),c()),d.key==="Escape"&&(d.preventDefault(),u());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[c,u]),jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:!s,onPress:c,variant:i?"flat":"bordered",startContent:s?jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"}):void 0,endContent:s?jsxRuntime.jsx(ui.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui.cn(s&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:s?n("predict.search.placeholder"):jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"})})}function VN({client:e,wsClient:t=null,children:r}){let n=react.useMemo(()=>({client:e,wsClient:t}),[e,t]);return jsxRuntime.jsx(pt.Provider,{value:n,children:r})}var Yg=3e4;function _N({walletAddress:e,pollingInterval:t=Yg,enabled:r=true,children:n}){let{data:s,isLoading:i,error:o,refetch:a}=ks({walletAddress:e},{enabled:r&&!!e,refetchInterval:t}),l=react.useMemo(()=>({positions:s?.positions??[],usdcBalance:s?.usdcBalance??0,isLoading:i,error:o??null,refetch:a}),[s?.positions,s?.usdcBalance,i,o,a]);return jsxRuntime.jsx(Ae.Provider,{value:l,children:n})}function qN({client:e,children:t}){let r=react.useMemo(()=>({client:e}),[e]);return jsxRuntime.jsx(Jt.Provider,{value:r,children:t})}function Na(e,t){let r=new URLSearchParams;t&&r.set("provider",t);for(let[s,i]of Object.entries(e))i!=null&&(typeof i=="object"?r.set(s,JSON.stringify(i)):r.set(s,String(i)));let n=r.toString();return n?`?${n}`:""}function Ra(e){return e}var $t=class{constructor(t,r){this.endpoint=t;this.provider=r;}buildUrl(t,r){let n=Na(r??{},this.provider);return `${this.endpoint}${t}${n}`}async fetch(t,r){let n=this.buildUrl(t,r);return await utils.httpGet(n)}async postRequest(t,r,n){let s=this.buildUrl(t,n);return await utils.httpPost(s,r)}};function Rr(e,t){if(!e)return [];let r=Object.entries(e).map(([n,s])=>({price:parseFloat(n),quantity:s}));return r.sort((n,s)=>t==="desc"?s.price-n.price:n.price-s.price),r}function Oa(e){return {yesBids:Rr(e.yes_bids,"desc"),yesAsks:Rr(e.yes_asks,"asc"),noBids:Rr(e.no_bids,"desc"),noAsks:Rr(e.no_asks,"asc"),sequence:e.sequence}}var Or=class extends $t{constructor(t){super(t,"dflow");}async getEvents(t){return await this.fetch("/v2/event",t??{})}async getEventById(t,r){return await this.fetch(`/v2/event/${t}`,{withNestedMarkets:r})}async getEventCandlesticks(t,r){return await this.fetch(`/v2/event/${t}/candlesticks`,r)}async getEventForecastPercentileHistory(t){let{seriesTicker:r,eventId:n,...s}=t;return await this.fetch(`/v2/event/${r}/${n}/forecast_percentile_history`,s)}async getEventForecastPercentileHistoryByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/event/by-mint/${r}/forecast_percentile_history`,n)}async getMarkets(t){return await this.fetch("/v2/market",t??{})}async getMarketById(t){return await this.fetch(`/v2/market/${t}`)}async getMarketByMint(t){return await this.fetch(`/v2/market/by-mint/${t}`)}async getMarketsBatch(t){return await this.postRequest("/v2/market/batch",t)}async getMarketCandlesticks(t,r){return await this.fetch(`/v2/market/${t}/candlesticks`,r)}async getMarketCandlesticksByMint(t,r){return await this.fetch(`/v2/market/by-mint/${t}/candlesticks`,r)}async getOrderbook(t){let r=await this.fetch(`/v2/orderbook/${t}`);return Oa(r)}async getOrderbookByMint(t){let r=await this.fetch(`/v2/orderbook/by-mint/${t}`);return Oa(r)}async getTrades(t){return await this.fetch("/v2/trades",t??{})}async getTradesByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/trades/by-mint/${r}`,n)}async getOnchainTradesByWallet(t){let{walletAddress:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-wallet/${r}`,n)}async getOnchainTradesByEvent(t){let{eventTicker:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-event/${r}`,n)}async getOnchainTradesByMarket(t){let{marketTicker:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-market/${r}`,n)}async getLiveData(t){return await this.fetch("/v2/live",{milestoneIds:t.milestoneIds.join(",")})}async getLiveDataByEvent(t){let{eventTicker:r,...n}=t;return await this.fetch(`/v2/live/event/${r}`,n)}async getLiveDataByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/live/by-mint/${r}`,n)}async getSeries(t){return await this.fetch("/v2/series",t??{})}async getSeriesByTicker(t){return await this.fetch(`/v2/series/${t}`)}async getTagsByCategories(){return await this.fetch("/v2/tags/by_categories")}async getFiltersBySports(){return await this.fetch("/v2/sports/filters")}async search(t){return await this.fetch("/v2/search",t)}async getPositionsByWallet(t){let{walletAddress:r}=t;return await this.fetch(`/v2/positions/by-wallet/${r}`)}async getOutcomeMints(t){return await this.fetch("/v2/outcome_mints",t??{})}async filterOutcomeMints(t){return await this.postRequest("/v2/filter_outcome_mints",t)}async getQuote(t){return await this.fetch("/v2/swap/quote",t)}async createSwap(t){return await this.postRequest("/v2/swap",t)}async createSwapInstructions(t){return await this.postRequest("/v2/swap/instructions",t)}async getOrder(t){return await this.fetch("/v2/order",t)}async getOrderStatus(t){try{return await this.fetch("/v2/order/status",t)}catch(r){if(r instanceof Error&&/\b404\b/.test(r.message))return {status:"pending",inAmount:"0",outAmount:"0"};throw r}}async getIntentQuote(t){return await this.fetch("/v2/intent/quote",t)}async submitIntentSwap(t){return await this.postRequest("/v2/intent/swap",t)}async initPredictionMarket(t){return await this.fetch("/v2/prediction-market/init",t)}async getTokens(){return await this.fetch("/v2/tokens")}async getTokensWithDecimals(){return await this.fetch("/v2/tokens/decimals")}async getVenues(){return await this.fetch("/v2/venues")}};function be(e){let t=new URLSearchParams;for(let[n,s]of Object.entries(e))s!=null&&t.set(n,String(s));let r=t.toString();return r?`?${r}`:""}var zt=class{constructor(t){this.endpoint=t;}async listEvents(t){let r=be(t??{}),n=`${this.endpoint}/api/v1/events${r}`;return await utils.httpGet(n)}async getEvent(t,r){let n=r?be({source:r}):"",s=`${this.endpoint}/api/v1/events/${encodeURIComponent(t)}${n}`;return await utils.httpGet(s)}async getMarket(t,r){let n=r?be({source:r}):"",s=`${this.endpoint}/api/v1/markets/${encodeURIComponent(t)}${n}`;return await utils.httpGet(s)}async getOrderbook(t,r){let n=be({source:r}),s=`${this.endpoint}/api/v1/markets/${encodeURIComponent(t)}/orderbook${n}`;return await utils.httpGet(s)}async listMarketTrades(t,r){let n=be(r),s=`${this.endpoint}/api/v1/markets/${encodeURIComponent(t)}/trades${n}`;return await utils.httpGet(s)}async getPriceHistory(t,r,n){let s=be({source:r,range:n}),i=`${this.endpoint}/api/v1/markets/${encodeURIComponent(t)}/price-history${s}`;return await utils.httpGet(i)}async listCandlesticks(t,r){let n=be(r??{}),s=`${this.endpoint}/api/v1/markets/${encodeURIComponent(t)}/candlesticks${n}`;return await utils.httpGet(s)}async getSimilarEvents(t,r,n){let s=be({source:r,...n}),i=`${this.endpoint}/api/v1/events/${encodeURIComponent(t)}/similar${s}`;return await utils.httpGet(i)}async getPositions(t,r){let n=be({source:t,user:r}),s=`${this.endpoint}/api/v1/positions${n}`;return await utils.httpGet(s)}async listOrders(t){let r=be(t),n=`${this.endpoint}/api/v1/orders${r}`;return await utils.httpGet(n)}async getOrder(t,r){let n=be({source:r}),s=`${this.endpoint}/api/v1/orders/${encodeURIComponent(t)}${n}`;return await utils.httpGet(s)}async cancelOrder(t,r){let n=be({source:r}),s=`${this.endpoint}/api/v1/orders/${encodeURIComponent(t)}${n}`;return await utils.httpDelete(s)}async createDFlowQuote(t){let r=`${this.endpoint}/api/v1/orders/dflow/quote`;return await utils.httpPost(r,t)}async submitDFlowTransaction(t){let r=`${this.endpoint}/api/v1/orders/dflow/submit`;return await utils.httpPost(r,t)}async listTradesByWallet(t){let r=be(t),n=`${this.endpoint}/api/v1/trades${r}`;return await utils.httpGet(n)}};function Ia(e){return new zt(e)}exports.BasePredictClient=$t;exports.CATEGORIES_V2=Xr;exports.CHART_RANGE_DURATION=ct;exports.CHART_RANGE_PERIOD=lt;exports.CHART_RANGE_SAMPLE_INTERVAL=tr;exports.CandlestickPeriod=er;exports.CategoriesSkeleton=ar;exports.CategoriesUI=ir;exports.CategoriesWidget=qs;exports.CategoriesWidgetV2=lr;exports.ChartRange=M;exports.DEFAULT_CHART_RANGE=ke;exports.DEFAULT_FILTER_STATE=en;exports.DEFAULT_PAGE_SIZE=he;exports.DEFAULT_PRICE_HISTORY_INTERVAL=xv;exports.DflowPredictClient=Or;exports.DflowPredictWsClient=Ot;exports.EventDetailPage=$C;exports.EventDetailPageV2=oE;exports.EventDetailSkeleton=Re;exports.EventDetailUI=bi;exports.EventDetailV2UI=Wi;exports.EventDetailWidget=Pn;exports.EventDetailWidgetV2=Fn;exports.EventItemSkeleton=Ru;exports.EventItemUI=Zs;exports.EventItemV2UI=Co;exports.EventMarketDetailV2Widget=Mi;exports.EventMarketDetailWidget=li;exports.EventPriceChartV2=Vi;exports.EventsFilterV2UI=oo;exports.EventsPage=NP;exports.EventsPageSkeleton=Jk;exports.EventsPageV2=v2;exports.EventsPageV2Skeleton=eP;exports.EventsSkeleton=ft;exports.EventsToolbarV2UI=uo;exports.EventsUI=to;exports.EventsV2UI=Ro;exports.EventsWidget=no;exports.EventsWidgetV2=Vo;exports.MAX_PRICE_HISTORY_MARKETS=Se;exports.ORDER_MAX_PRICE=vv;exports.ORDER_MIN_PRICE=gv;exports.ORDER_MIN_QUANTITY=ut;exports.ORDER_PRICE_STEP=yv;exports.OpenOrdersUI=ea;exports.OpenOrdersWidget=iT;exports.OrderBookUI=Xi;exports.OrderBookWidget=HE;exports.PREDICT_SEARCH_MODAL_ID=zn;exports.PRICE_HISTORY_SAMPLE_INTERVAL=bv;exports.PositionsUI=ia;exports.PositionsWidget=AT;exports.PredictClient=Or;exports.PredictClientV2=zt;exports.PredictContext=pt;exports.PredictProvider=VN;exports.PredictSearchModal=jM;exports.PredictV2Context=Jt;exports.PredictV2Provider=qN;exports.PredictWsClient=Ot;exports.PriceHistoryInterval=at;exports.SORT_PRESETS=co;exports.SearchEventsButton=oN;exports.SearchHistoryUI=ua;exports.SearchHistoryWidget=da;exports.SearchInputUI=pa;exports.SearchResultItemUI=ya;exports.SearchResultListWidget=ha;exports.SearchWidget=wa;exports.TradeFormSkeleton=vr;exports.TradeFormUI=gr;exports.TradeFormV2Widget=Tn;exports.TradeFormWidget=dn;exports.TradeHistoryUI=sa;exports.TradeHistoryWidget=CT;exports.UserActivityV2Section=Nn;exports.UserPredictContext=Ae;exports.UserPredictProvider=_N;exports.buildQuery=Na;exports.candlesticksV2QueryKey=al;exports.countActiveFilters=tn;exports.createDflowPredictWsClient=sr;exports.createPredictClientV2=Ia;exports.createPredictWsClient=sr;exports.createSwap=qc;exports.createSwapInstructions=Hc;exports.dflowQuoteV2QueryKey=vl;exports.eventByIdQueryKey=Rl;exports.eventCandlesticksQueryKey=sc;exports.eventV2QueryKey=Br;exports.eventsInfiniteQueryKey=Ml;exports.eventsQueryKey=El;exports.eventsV2InfiniteQueryKey=Lr;exports.eventsV2QueryKey=Fa;exports.fetchEventById=Ol;exports.fetchEventCandlesticks=oc;exports.fetchEventV2=Ur;exports.fetchEvents=Dr;exports.fetchEventsV2=Aa;exports.fetchEventsV2Page=Qr;exports.fetchFiltersBySports=wc;exports.fetchForecastPercentileHistory=cc;exports.fetchForecastPercentileHistoryByMint=dc;exports.fetchIntentQuote=Zc;exports.fetchLiveData=mc;exports.fetchLiveDataByEvent=yc;exports.fetchLiveDataByMint=vc;exports.fetchMarketById=Ul;exports.fetchMarketByMint=Fl;exports.fetchMarketCandlesticks=Rt;exports.fetchMarketCandlesticksByMint=ac;exports.fetchMarketV2=Xa;exports.fetchMarkets=Ll;exports.fetchMarketsBatch=ql;exports.fetchOnchainTradesByEvent=Wr;exports.fetchOnchainTradesByMarket=qr;exports.fetchOnchainTradesByWallet=Ar;exports.fetchOrder=$c;exports.fetchOrderBook=Kl;exports.fetchOrderBookByMint=zl;exports.fetchOrderStatus=Yc;exports.fetchOutcomeMints=_c;exports.fetchPositionsByWallet=Oc;exports.fetchQuote=Wc;exports.fetchSearch=Mc;exports.fetchSeries=bc;exports.fetchSeriesByTicker=kc;exports.fetchTagsByCategories=Sc;exports.fetchTokens=nu;exports.fetchTokensWithDecimals=ou;exports.fetchTrades=Gl;exports.fetchTradesByMint=Xl;exports.fetchVenues=lu;exports.filterOutcomeMints=Dc;exports.filtersBySportsQueryKey=Cc;exports.forecastPercentileHistoryByMintQueryKey=uc;exports.forecastPercentileHistoryQueryKey=lc;exports.initPredictionMarket=tu;exports.intentQuoteQueryKey=Xc;exports.liveDataByEventQueryKey=fc;exports.liveDataByMintQueryKey=gc;exports.liveDataQueryKey=pc;exports.marketByIdQueryKey=Bl;exports.marketByMintQueryKey=Dl;exports.marketCandlesticksByMintQueryKey=ic;exports.marketCandlesticksQueryKey=Nt;exports.marketTradesV2QueryKey=ol;exports.marketV2QueryKey=ja;exports.marketsBatchQueryKey=Wl;exports.marketsQueryKey=Il;exports.onchainTradesByEventInfiniteQueryKey=rc;exports.onchainTradesByEventQueryKey=Jl;exports.onchainTradesByMarketInfiniteQueryKey=nc;exports.onchainTradesByMarketQueryKey=ec;exports.onchainTradesByWalletInfiniteQueryKey=tc;exports.onchainTradesByWalletQueryKey=Zl;exports.orderBookByMintQueryKey=$l;exports.orderBookQueryKey=Hl;exports.orderQueryKey=Kc;exports.orderStatusQueryKey=zc;exports.orderV2QueryKey=ml;exports.orderbookV2QueryKey=nl;exports.ordersV2QueryKey=dl;exports.outcomeMintsQueryKey=Uc;exports.positionsByWalletQueryKey=Rc;exports.positionsV2QueryKey=cl;exports.priceHistoryV2QueryKey=_r;exports.quoteQueryKey=Ac;exports.resolveEventsV2Params=Ir;exports.resolveTagSlug=Xn;exports.searchQueryKey=Tc;exports.seriesByTickerQueryKey=hc;exports.seriesQueryKey=xc;exports.similarEventsV2QueryKey=Ya;exports.submitIntentSwap=Jc;exports.tagsByCategoriesQueryKey=Pc;exports.toRecord=Ra;exports.tokensQueryKey=ru;exports.tokensWithDecimalsQueryKey=su;exports.tradesByMintQueryKey=jl;exports.tradesByWalletV2QueryKey=kl;exports.tradesQueryKey=Yl;exports.useCancelOrderV2Mutation=is;exports.useCandlesticksV2Query=lx;exports.useCategoriesQuery=Th;exports.useCreateSwapInstructionsMutation=t0;exports.useCreateSwapMutation=e0;exports.useDFlowQuoteV2=as;exports.useDFlowSubmitV2=ls;exports.useEventByIdQuery=nr;exports.useEventCandlesticksQuery=ih;exports.useEventDetail=Fo;exports.useEventDetailV2=fE;exports.useEventV2Query=dt;exports.useEvents=Hs;exports.useEventsCategories=Us;exports.useEventsInfiniteQuery=ds;exports.useEventsQuery=mb;exports.useEventsV2=fo;exports.useEventsV2InfiniteQuery=Zn;exports.useEventsV2Query=mv;exports.useFilterOutcomeMintsMutation=$h;exports.useFiltersBySportsQuery=Eh;exports.useForecastPercentileHistoryByMintQuery=mh;exports.useForecastPercentileHistoryQuery=ph;exports.useInitPredictionMarketMutation=m0;exports.useIntentQuoteQuery=l0;exports.useLiveDataByEventQuery=xh;exports.useLiveDataByMintQuery=bh;exports.useLiveDataQuery=vh;exports.useMarketByIdQuery=Mb;exports.useMarketByMintQuery=Vb;exports.useMarketCandlesticksByMintQuery=ah;exports.useMarketCandlesticksQuery=zr;exports.useMarketHistoryV2=ts;exports.useMarketPositions=Ps;exports.useMarketTradesV2Query=ns;exports.useMarketV2Query=Wv;exports.useMarketsBatchQuery=Bb;exports.useMarketsQuery=Cb;exports.useOnchainTradesByEventInfiniteQuery=th;exports.useOnchainTradesByEventQuery=Yb;exports.useOnchainTradesByMarketInfiniteQuery=rh;exports.useOnchainTradesByMarketQuery=Gb;exports.useOnchainTradesByWalletInfiniteQuery=eh;exports.useOnchainTradesByWalletQuery=ys;exports.useOpenOrders=Ji;exports.useOrderBook=Yi;exports.useOrderBookByMintQuery=Fb;exports.useOrderBookQuery=mt;exports.useOrderQuery=ws;exports.useOrderStatusQuery=Es;exports.useOrderV2Query=os;exports.useOrderbookSubscription=A0;exports.useOrderbookV2Query=rs;exports.useOrdersV2Query=ss;exports.useOutcomeMintsQuery=Kh;exports.usePositions=oa;exports.usePositionsByWalletQuery=ks;exports.usePositionsV2Query=rr;exports.usePredictClient=P;exports.usePredictContext=us;exports.usePredictSearchHistory=Mr;exports.usePredictV2Client=I;exports.usePredictV2Context=jn;exports.usePriceHistoryQuery=lh;exports.usePriceHistoryV2Query=$v;exports.usePricesSubscription=Q0;exports.useQuoteQuery=jh;exports.useSearchEventsInfiniteQuery=Jn;exports.useSearchQuery=Oh;exports.useSearchResultListScript=ga;exports.useSearchScript=Ca;exports.useSeriesByTickerQuery=bs;exports.useSeriesQuery=xs;exports.useSimilarEventsV2Query=es;exports.useSubmitIntentSwapMutation=c0;exports.useTagsByCategoriesQuery=Gr;exports.useTokensQuery=v0;exports.useTokensWithDecimalsQuery=x0;exports.useTradeForm=Bo;exports.useTradeFormV2=Si;exports.useTradeHistory=ra;exports.useTradesByMintQuery=Hb;exports.useTradesByWalletV2Query=cs;exports.useTradesQuery=fs;exports.useTradesSubscription=_0;exports.useUserPredictContext=_h;exports.useVenuesQuery=P0;exports.useWsClient=V0;exports.useWsConnection=M0;exports.venuesQueryKey=au;exports.version=Ba;//# sourceMappingURL=index.js.map
21
+ `),d=l.length>200&&!o?l.slice(0,200)+"...":l;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:d}),l.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(u=>!u),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(u=>!u),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",s&&"rotate-180")})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:[{label:r("predict.event.timeline.open"),value:tn(c.start_at),isActive:true},{label:r("predict.event.timeline.close"),value:tn(c.end_at),isActive:c.status==="closed"||c.status==="voided"}].map((u,p,m)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${u.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),p<m.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<m.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:u.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:u.value})]})]},u.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:c.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:an(c.source)})]})]})]})]})}function Ba({source:e}){return jsxRuntime.jsxs("span",{className:ui.cn("inline-flex items-center gap-x-1 rounded px-1.5 py-0.5","text-[10px] font-medium leading-none",e==="polymarket"?"bg-blue-500/15 text-blue-400":"bg-primary-500/15 text-primary"),children:[jsxRuntime.jsx("span",{className:ui.cn("h-1.5 w-1.5 rounded-sm",e==="polymarket"?"bg-blue-400":"bg-primary")}),an(e)]})}function cn({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:s}=reactPredict.useEvent({slug:e,source:t});return n?jsxRuntime.jsx(Oe,{}):s||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:s?.message||"Event not found"}):jsxRuntime.jsx(ln,{event:o,onTradeAction:r})}function dn({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:s.map(i=>jsxRuntime.jsx(Ka,{event:i,onClick:o},i.slug))})]})}function Ka({event:e,onClick:t}){let r=e.volume;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function un(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Jd({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:s}){let{t:a}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),{isOpen:c,onOpen:l,onClose:d}=ui.useDisclosure(),{data:u,isLoading:p}=reactPredict.useEvent({slug:e,source:t}),m=react.useMemo(()=>[...u?.markets||[]].sort((R,N)=>un(N)-un(R)),[u?.markets]),[g,f]=react.useState(null),h=react.useCallback((R,N,A)=>{f(q=>({market:R,outcome:N,side:A,version:(q?.version??0)+1})),i&&l();},[i,l]),v=g?.market??m[0];if(p)return i?jsxRuntime.jsx(Oe,{}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Oe,{})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(Ar,{})})})]});let O=g?`${g.market.slug}-${g.version}`:v?.slug??"default";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 lg:max-w-7xl lg:gap-y-8 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:s,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:a("common.back")})}),jsxRuntime.jsx(cn,{eventSlug:e,source:t,onTradeAction:h})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[v&&jsxRuntime.jsx(Or,{event:u,market:v,initialSide:g?.side,initialOutcome:g?.outcome,chain:r},O),u&&jsxRuntime.jsx(dn,{eventSlug:e,source:u.source,onEventClick:n})]})]}),u&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx(_r,{event:u,walletAddress:o})})]})}function pn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function oi(e){switch(e){case reactPredict.ChartRange.ONE_DAY:return {interval:"15m",limit:96};case reactPredict.ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case reactPredict.ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case reactPredict.ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var au=e=>{let{candlestickMarketSlugs:t,chartRange:r=Ve,source:o}=e,n=reactPredict.usePredictClient(),s=react.useMemo(()=>oi(r),[r]),{data:a,isLoading:i,error:c}=reactPredict.useEvent({slug:e.eventSlug,source:o}),l=react.useMemo(()=>a?.markets?(t&&t.length>0?t.slice(0,4).map(f=>a.markets.find(h=>h.slug===f)).filter(f=>f!==void 0):[...a.markets].sort((f,h)=>pn(h)-pn(f)).slice(0,4)).map(f=>f.slug):[],[t,a?.markets]),d=reactQuery.useQueries({queries:l.map(g=>({queryKey:reactPredict.candlesticksQueryKey(g,s),queryFn:()=>n.listCandlesticks(g,s),enabled:l.length>0}))}),u=d.some(g=>g.isLoading),p=react.useMemo(()=>{let g=new Map;return l.forEach((f,h)=>{let v=d[h]?.error;v&&g.set(f,v);}),g},[l,d]),m=react.useMemo(()=>{let g=new Map;return l.forEach((f,h)=>{let v=d[h]?.data;v&&g.set(f,v);}),g},[l,d]);return {event:a,isEventLoading:i,eventError:c,candlestickParams:s,candlesticks:m,isCandlesticksLoading:u,candlestickErrors:p}};var ii=10,li=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function at(){let[e,t]=jotai.useAtom(li),r=react.useCallback(n=>{let s=n.trim();s&&t(a=>{let i=a.filter(c=>c!==s);return [s,...i].slice(0,ii)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function vn({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(s=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(s),children:s},s))})]})}function xn({onSelect:e,className:t}){let{histories:r,clearHistories:o}=at();return jsxRuntime.jsx(vn,{className:ui.cn(t),histories:r,onSelect:e,onClear:o})}function hn({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:n,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:s("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:"Esc"})})})}function Sn({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:s}){let a=e.tags?.[0];return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,className:ui.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",s),onClick:i=>{t&&o&&i.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),a&&jsxRuntime.jsx("span",{className:ui.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:a.label})]})]})}function kn({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:s,hasNextPage:a,fetchNextPage:i}=reactPredict.useSearchEvents({keyword:e,limit:t,source:r},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(l=>l.items).filter(l=>l!=null)??[],[o]),isLoading:n,isFetchingNextPage:s,hasNextPage:a??false,fetchNextPage:i}}var Ri=56;function wn({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...s}){let{events:a,isLoading:i,isFetchingNextPage:c,hasNextPage:l,fetchNextPage:d}=kn(s),u=react.useRef(null),{height:p}=hooks.useResizeObserver({ref:u}),m=react.useCallback(v=>v<a.length,[a]),g=react.useCallback(async()=>{l&&!c&&await d();},[l,c,d]),f=react.useMemo(()=>l?a.length+1:a.length,[a,l]),h=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:f,threshold:5});return i?jsxRuntime.jsx(Ii,{className:n}):a.length===0?jsxRuntime.jsx(_i,{className:n}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",n),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{style:{height:p},onRowsRendered:h,rowComponent:Oi,rowCount:f,rowHeight:Ri,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Oi({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:s,onHover:a}){let i=r[e];return i?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(Sn,{event:i,href:n?.(i),LinkComponent:s,onSelect:o,onHover:a})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function Ii({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function _i({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Ln({onKeywordChange:e}){let[t,r]=react.useState(""),[o,n]=react.useState(""),{addHistory:s}=at(),a=hooks.useCallbackRef(e),i=hooks.useCallbackRef(s),c=react.useMemo(()=>utils.debounce(p=>{n(p),a(p),p&&i(p);},500),[a,i]),l=react.useCallback(p=>{r(p),c(p);},[c]),d=react.useCallback(p=>{c.cancel(),r(p),n(p),a(p),p&&i(p);},[c,a,i]),u=react.useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:l,setKeyword:d,clearKeyword:u}}function Rn({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:s,source:a}){let{text:i,keyword:c,setText:l,setKeyword:d,clearKeyword:u}=Ln({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(hn,{value:i,onValueChange:l,onClear:u,onEscape:s}),!c&&jsxRuntime.jsx(xn,{onSelect:d}),jsxRuntime.jsx(wn,{className:"flex-auto min-h-0",keyword:c,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:a})]})}var Ht="predict-search";function Pp({id:e=Ht}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(qi,{...t})})}function qi({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=i18n.useTranslation(),{isMobile:s}=ui.useScreen(),a=react.useCallback(c=>{o(c);},[o]),i=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:s?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(Rn,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:i})})]})})}function Op({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=i18n.useTranslation(),{isDesktop:n,isMobile:s}=ui.useScreen(),{onOpen:a,onClose:i}=uiScaffold.useAsyncModal(Ht),c=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let u=await a({params:t});u&&c(u);}),d=hooks.useCallbackRef(()=>{i();});return react.useEffect(()=>{let u=p=>{let m=document.activeElement,g=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!g&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),d());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[l,d]),jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:l,variant:s?"flat":"bordered",startContent:n?jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsxRuntime.jsx(ui.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui.cn(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"})})}var sl=react.createContext(null);var al=3e4;function il({walletAddress:e,source:t,pollingInterval:r=al,enabled:o=true,children:n}){let s=o&&!!e,{data:a,isLoading:i,error:c,refetch:l}=reactPredict.usePositions({user:e,source:t},{enabled:s,refetchInterval:r}),{data:d,isLoading:u,error:p}=reactPredict.useBalance({user:e,source:t??"dflow"},{enabled:s,refetchInterval:r}),m=react.useMemo(()=>({positions:a?.positions??[],usdcBalance:d?Number(d.balance):0,isLoading:i||u,error:c??p??null,refetch:l}),[a?.positions,d,i,u,c,p,l]);return jsxRuntime.jsx(sl.Provider,{value:m,children:n})}Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=_l;exports.CHART_RANGE_PERIOD=Ol;exports.CHART_RANGE_SAMPLE_INTERVAL=Il;exports.CandlestickPeriod=Ke;exports.CategoriesSkeleton=fl;exports.CategoriesUI=Kt;exports.CategoriesWidget=qt;exports.ChartRange=j;exports.DEFAULT_CHART_RANGE=Ve;exports.DEFAULT_FILTER_STATE=ut;exports.DEFAULT_PAGE_SIZE=mt;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Bl;exports.EventDetailPage=Jd;exports.EventDetailSkeleton=Oe;exports.EventDetailUI=ln;exports.EventDetailWidget=cn;exports.EventItem=fr;exports.EventMarketDepthChartUI=Ur;exports.EventMarketDetailWidget=jr;exports.EventPriceChart=Zr;exports.EventsFilterUI=Gt;exports.EventsPage=bc;exports.EventsSkeleton=or;exports.EventsToolbarUI=er;exports.EventsUI=yr;exports.EventsWidget=kr;exports.MAX_PRICE_HISTORY_MARKETS=ft;exports.ORDER_MAX_PRICE=Hl;exports.ORDER_MIN_PRICE=Dl;exports.ORDER_MIN_QUANTITY=gt;exports.ORDER_PRICE_STEP=Al;exports.PREDICT_SEARCH_MODAL_ID=Ht;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Fl;exports.PredictSearchModal=Pp;exports.PriceHistoryInterval=ge;exports.SORT_PRESETS=Jt;exports.STATIC_CATEGORIES=dt;exports.SearchEventsButton=Op;exports.SearchHistoryUI=vn;exports.SearchHistoryWidget=xn;exports.SearchInputUI=hn;exports.SearchResultItemUI=Sn;exports.SearchResultListWidget=wn;exports.SearchWidget=Rn;exports.SimilarEventCard=Ka;exports.SimilarEventsSection=dn;exports.TradeFormSkeleton=Ar;exports.TradeFormUI=Lr;exports.TradeFormWidget=Or;exports.UserActivitySection=_r;exports.UserPredictProvider=il;exports.countActiveFilters=pt;exports.formatWan=Ie;exports.useEventDetail=au;exports.useEventsInfinite=nr;exports.usePredictSearchHistory=at;exports.useSearchResultListScript=kn;exports.useSearchScript=Ln;exports.useTradeForm=Cr;exports.version=Wn;//# sourceMappingURL=index.js.map
23
22
  //# sourceMappingURL=index.js.map